Documentation
¶
Overview ¶
Package report is the written account a repository abcd manages files back to abcd itself, and the inbox it waits in (itd-2609221656361680, spc-2609221657168936).
A report is a markdown file: a machine-readable block between `---` lines beside prose the reporter writes. abcd issues the template (Template), checks a filled one against it (Parse), and files it into the user account's machine store:
~/.abcd.noindex/inbox/<received-stamp>-<sender-key>.md one waiting report ~/.abcd.noindex/inbox/promoted/<same name> a report filed as a capture ~/.abcd.noindex/inbox/promoted.jsonl which capture each became
The inbox lives beside the history, transcript, worktree, sources, labs and run stores, never in either repository's tree. The sender key is the sending repository's full root-commit SHA, the key the other machine-scoped stores use. Nothing in a report names where it is written or read: the file name is derived by abcd from the clock and the key, and every field is data that is rendered, never opened.
A report arrives from another repository, so everything in it is untrusted input. Its size is bounded (MaxBytes), a control byte anywhere refuses it, a field that names a filesystem location refuses it, and every front door sanitises what it prints. Nothing is filed as a record until a person or a session runs Promote, and what Promote files carries the sender's root-commit key and a generic description, never the sender's name.
Core never writes to stdout; the CLI front door formats what these functions return.
Index ¶
Constants ¶
const ( // StateWaiting is a report nobody has acted on. StateWaiting = "waiting" // StatePromoted is a report filed as a capture; it is kept, not deleted. StatePromoted = "promoted" // StateUnreadable is a waiting file this abcd cannot read: a later template // version, or bytes that are not a report. It is listed, never dropped. StateUnreadable = "unreadable" )
The states an inbox entry can be in.
const AbcdRootCommit = "488a0aa96ac5de805348635b27036addf15cddc2"
AbcdRootCommit is abcd's own identity as git records it: the root commit of its repository. Every report is about abcd, so a report is promoted only in a checkout whose root commit is this one; anywhere else the capture would plant an abcd defect in an unrelated repository's ledger.
It is a pinned constant rather than something derived at run time. A root commit cannot change without rewriting every commit after it, so the value is as fixed as the module path, and a constant fails closed: a shallow clone, a rewritten history or an archive copy is refused rather than guessed at. The derivations on offer are weaker. The binary's embedded build revision is absent from a dirty or checkout-less build, and proves only that the checkout holds that one commit; the module path is text any repository can declare. TestAbcdRootCommitIsThisCheckouts holds the constant to the checkout the tests run in, so it cannot drift silently. A fork shares abcd's root commit and is abcd's code, so it promotes.
const GenericSender = "a managed repository"
GenericSender is the description that stands in for a sender's name in anything abcd files from a report (decision 4: identity in the inbox, fingerprint in the record).
const MaxBytes = 32 << 10
MaxBytes bounds a whole report. A report is written at the moment of a finding (scope condition 2); a run's whole account is a document the report points at, not the report's body.
const SchemaVersion = 1
SchemaVersion is the template version this abcd writes and reads. A report carrying any other version is listed as unreadable, naming the version, and is never dropped or half-read.
const Source = "managed-repo"
Source is the capture source a promoted report is filed under.
Variables ¶
var ErrRefused = errors.New("refused")
ErrRefused is the class of every refusal a report can earn: a malformed block, a field outside its bounds, an unknown template version at filing, an id that names no report. Nothing is written for a refused act. The CLI maps it to exit 2.
var Kinds = []string{"defect", "enhancement"}
Kinds is the closed vocabulary of what a report asks for.
Functions ¶
func EnvelopeSender ¶ added in v0.12.0
EnvelopeSender reads the sender's name from a filed report's envelope alone, for a report the parser refuses (a later template, a malformed reporter field): the envelope is abcd's own writing and sits in the same block, so the inbox can say who is asking even where it cannot read what they ask. The name is returned only when the block names it once, in the shape a filing writes, beside a sender_key once that is fileKey, the key the file is filed by; any other file names nobody, and "" is returned.
func SetAbcdRootCommitForTest ¶
func SetAbcdRootCommitForTest(sha string) (restore func())
SetAbcdRootCommitForTest repoints the root commit Promote accepts, so a test can promote into a throwaway repository, and returns the restore.
func Template ¶
Template returns the skeleton a reporter fills: the block with every key the validator reads, its closed vocabularies named in comments, and a prose placeholder. abcdVersion is the running binary's version, filled in so the reporter need not look it up. The skeleton as issued is refused by Parse (its title and prose are empty), so an unfilled template can never be filed.
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
State string `json:"state"`
ReceivedAt string `json:"received_at"`
SenderKey string `json:"sender_key"`
// SenderName is the sender's name, shown plainly here and nowhere abcd
// commits anything.
SenderName string `json:"sender_name,omitempty"`
Kind string `json:"kind,omitempty"`
Severity string `json:"severity,omitempty"`
Title string `json:"title,omitempty"`
// Unreadable says why a waiting file could not be read, naming the template
// version when that is the reason.
Unreadable string `json:"unreadable,omitempty"`
// PromotedTo is the capture a promoted report became.
PromotedTo string `json:"promoted_to,omitempty"`
// Report is the whole report, on Show only.
Report *Report `json:"report,omitempty"`
// contains filtered or unexported fields
}
Entry is one report as the inbox shows it.
type FieldError ¶
FieldError is a refusal that names the field it is about.
func (*FieldError) Error ¶
func (e *FieldError) Error() string
func (*FieldError) Unwrap ¶
func (e *FieldError) Unwrap() error
Unwrap classes every FieldError as a refusal.
type Filed ¶
type Filed struct {
ID string `json:"id"`
// Path is the report's location with the home directory written as `~`, so
// no output carries the account's absolute path.
Path string `json:"path"`
}
Filed is where a report landed.
type Promoted ¶
type Promoted struct {
Report string `json:"report"`
Capture string `json:"capture"`
// Path is the capture's repository-relative path.
Path string `json:"path"`
// Redacted and Degraded are the capture redactor's own report, relayed so
// the person who promoted can see the text was altered.
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
// Resumed says this call completed an earlier promotion that filed its
// capture but did not finish moving the report: nothing new was filed.
Resumed bool `json:"resumed,omitempty"`
// Match is the filing-time match's outcome (itd-2609212137116617) when
// the promotion asked for one: the links written onto the capture, the
// near misses, or why nothing was compared.
Match *match.Outcome `json:"match,omitempty"`
}
Promoted is what a promotion filed.
func Promote ¶
Promote files a waiting report as a capture in the ledger of the repository at ledgerRoot, through capture's own core, so the promoted report is an ordinary ledger record, redacted by the ledger's own scanner before it is written. The capture carries the sender's root-commit key and GenericSender, never the sender's name, and the report's id as its evidence. The report is then moved to the promoted folder and kept. Promotions are serialised by the inbox's lock, so two sessions cannot file one report twice.
The promotion is recorded in the promoted log before the report is moved, so a move that fails leaves a report still waiting whose capture is already on record. Promoting it again files nothing: it finishes the move and names the capture the first attempt filed (Resumed).
mc, when non-nil, runs capture's filing-time match (itd-2609212137116617) on the report's own title and prose, and the capture carries a typed link naming each likely double, exactly as a capture filed by hand does. nil files the capture unmatched.
type Report ¶
type Report struct {
SchemaVersion int `json:"schema_version"`
Kind string `json:"kind"`
Severity string `json:"severity"`
Category string `json:"category"`
Title string `json:"title"`
AbcdVersion string `json:"abcd_version"`
Surface string `json:"surface"`
Remedy string `json:"remedy,omitempty"`
Evidence []string `json:"evidence"`
Prose string `json:"prose"`
// The envelope. Empty on a submission; required on a filed report.
ReceivedAt string `json:"received_at,omitempty"`
SenderKey string `json:"sender_key,omitempty"`
SenderName string `json:"sender_name,omitempty"`
}
Report is one parsed report: the reporter's block and prose, and, for a report read back from the inbox, the envelope abcd stamped on it at filing.
type Sender ¶
Sender is the repository a report comes from: its root-commit key, which is what anything committed carries, and its name, which only the inbox shows.
type VersionError ¶
type VersionError struct {
Version string
}
VersionError is a report whose template version this abcd does not know. It is a refusal at filing and an "unreadable" listing in the inbox.
func (*VersionError) Error ¶
func (e *VersionError) Error() string
func (*VersionError) Unwrap ¶
func (e *VersionError) Unwrap() error
Unwrap classes every VersionError as a refusal.