report

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const AbcdRootCommit = abcdrepo.RootCommit

AbcdRootCommit is abcd's own identity as git records it: the root commit of its repository (abcdrepo.RootCommit, where the reasons it is a pinned constant are kept). 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. 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.

View Source
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).

View Source
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.

View Source
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.

View Source
const Source = "managed-repo"

Source is the capture source a promoted report is filed under.

Variables

View Source
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.

View Source
var Kinds = []string{"defect", "enhancement"}

Kinds is the closed vocabulary of what a report asks for.

Functions

func EnvelopeSender added in v0.12.0

func EnvelopeSender(data []byte, fileKey string) string

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

func Template(abcdVersion string) []byte

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.

func List

func List() ([]Entry, error)

List returns the waiting reports, the unreadable ones among them, newest first. It reads and never writes: an absent inbox is an empty list, and nothing is filed.

func Show

func Show(id string) (Entry, error)

Show returns one report, waiting or promoted, whole. The id is checked for its shape before anything is read, and it is only ever compared with the names already in the inbox: it never becomes a path.

type FieldError

type FieldError struct {
	Field  string
	Reason string
}

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.

func File

func File(r Report, s Sender) (Filed, error)

File stamps a parsed report with its sender and the received time and writes it into the inbox by an exclusive create. The file holds what Parse accepted, written back by abcd, so nothing the reporter wrote chooses a byte of its name or reaches the file unparsed.

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

func Promote(ledgerRoot, id string, mc *match.Config) (Promoted, error)

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.

func Parse

func Parse(data []byte) (Report, error)

Parse reads a report as a reporter submits it: the envelope keys are abcd's and a submission carrying one is refused. An unknown template version is a *VersionError; any other defect is a *FieldError naming the field.

type Sender

type Sender struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

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.

func SenderOf

func SenderOf(root string) (Sender, error)

SenderOf resolves the sender for the checkout at root: the full root-commit SHA, and the name of the repository's main checkout directory (a worktree reports under its repository's name, not its own directory's). A repository with no commit has no key and cannot report.

type Tally

type Tally struct {
	Reports int `json:"reports"`
	Senders int `json:"senders"`
}

Tally is the greeting's two numbers.

func Count

func Count() (Tally, error)

Count returns how many reports wait and from how many repositories. It reads file names only, so the greeting costs one directory listing however large the reports are, and an unreadable report counts: it waits like any other.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL