Documentation
¶
Overview ¶
Package capture is abcd's transport-agnostic issue-ledger engine: the write side of a per-repo issue ledger that replaces the free-form .work/issues.md. Every capability is a function taking a structured request and returning a structured result; nothing here writes to stdout or knows about a CLI, MCP, or prompt surface. The front doors under internal/surface/* marshal these results for their transport.
The ledger lives at <repoRoot>/.abcd/work/issues with three status directories (open/, resolved/, wontfix/) whose folder membership IS the status signal — there is no status: frontmatter field. Each issue is a YAML-frontmatter + Markdown-body file named iss-<N>-<slug>.md with an unpadded, per-repo id namespace.
This package ports scripts/abcd/_issue_lib.py + issue_workflow.py to Go.
Index ¶
- Constants
- Variables
- type CaptureRequest
- type CaptureResult
- type Category
- type Issue
- type ListRequest
- type ListResult
- type PromoteRequest
- type PromoteResult
- type ResolveRequest
- type ResolvedBy
- type Severity
- type SkipRecord
- type Source
- type State
- type StatusRequest
- type StatusResult
- type TransitionResult
- type WontfixRequest
Constants ¶
const LedgerRelPath = ".abcd/work/issues"
LedgerRelPath is the ledger root relative to the repo worktree.
Variables ¶
var ( // ErrUnknownIssueID means the id was absent from all three dirs. ErrUnknownIssueID = errors.New("unknown issue id") // ErrTransitionConflict means the id was found but not in open/ (already // resolved/wontfixed), or a concurrent move consumed it. ErrTransitionConflict = errors.New("transition conflict") // ErrDuplicateIssueID means a ForceID (or on-disk state) collided. ErrDuplicateIssueID = errors.New("duplicate issue id") // ErrAllocatorContention means the lock timed out or the O_EXCL retry // budget was exhausted. ErrAllocatorContention = errors.New("allocator contention") // ErrChecksumMismatch means a concurrent edit occurred during a transition. ErrChecksumMismatch = errors.New("checksum mismatch") // ErrInvariantViolation means frontmatter passed the schema but violates a // folder-status cross-field invariant. ErrInvariantViolation = errors.New("invariant violation") // ErrMalformedFrontmatter means frontmatter could not be parsed or failed // schema validation. ErrMalformedFrontmatter = errors.New("malformed frontmatter") // ErrMissingRequiredField means a schema-required field was absent. ErrMissingRequiredField = errors.New("missing required field") // ErrPathUnsafe means the ledger root or a status dir is a symlink. ErrPathUnsafe = errors.New("path unsafe") )
Sentinel errors the surface maps to exit codes and messages. Core never prints them.
Functions ¶
This section is empty.
Types ¶
type CaptureRequest ¶
type CaptureRequest struct {
RepoRoot string
IssuesRoot string
Text string // markdown body
Severity Severity
Category Category
Source Source
Slug string // caller-supplied; normalised to kebab-case
FoundDuring string // required, non-empty
FoundAt string // optional; "" omits the field
RelatedIntents []string
RelatedSpecs []string
BlockedBy []string // iss-N dependency edges; each must match ^iss-[0-9]+$
ForceID string // migrator-only; "" = auto-allocate
}
CaptureRequest is the input to Capture (append a new issue).
type CaptureResult ¶
type CaptureResult struct {
ID string `json:"id"`
Slug string `json:"slug"`
Path string `json:"path"`
Status State `json:"status"` // always "open"
// Redacted counts the spans the ledger redactor rewrote on write, and
// Degraded is non-empty when it ran with a weakened pattern set. Both exist
// so a surface can SAY the text was altered: redacting in silence would edit
// a finding's content without telling whoever filed it (loud-staging).
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
}
CaptureResult is the outcome of a successful Capture. The timestamp-numeric mint (adr-45) consults no refs, so the max+1 era's mint_warning degrade note no longer exists on this result.
func Capture ¶
func Capture(req CaptureRequest) (CaptureResult, error)
Capture appends a new issue to open/ with an auto-assigned (or forced) iss-N. The write is transactional: a zero-byte placeholder is reserved, and on any failure it is swept. Returns the committed path under open/.
type Issue ¶
type Issue struct {
SchemaVersion int `json:"schema_version"`
ID string `json:"id"`
Slug string `json:"slug"`
Severity Severity `json:"severity"`
Category Category `json:"category"`
Source Source `json:"source"`
FoundDuring string `json:"found_during"`
FoundAt string `json:"found_at,omitempty"`
RelatedIntents []string `json:"related_intents,omitempty"`
RelatedSpecs []string `json:"related_specs,omitempty"`
RelatedIssues []string `json:"related_issues,omitempty"`
BlockedBy []string `json:"blocked_by,omitempty"` // iss-N dependency edges
PromotedTo string `json:"promoted_to,omitempty"`
Resolution string `json:"resolution,omitempty"`
WontfixReason string `json:"wontfix_reason,omitempty"`
ResolvedBy *ResolvedBy `json:"resolved_by,omitempty"`
Status State `json:"status"` // derived from folder
Path string `json:"path"` // repo-relative locator (iss-81)
Body string `json:"body"`
// BlockedByOpen is the derived subset of BlockedBy whose targets are still in
// open/ (the priority projection populated by List/Status). Not a stored
// field: an empty slice means the issue is unblocked.
BlockedByOpen []string `json:"blocked_by_open,omitempty"`
}
Issue is a fully-read ledger entry (frontmatter + provenance + body).
type ListRequest ¶
ListRequest queries one state (or "all").
type ListResult ¶
type ListResult struct {
Issues []Issue `json:"issues"`
Skipped []SkipRecord `json:"skipped"`
}
ListResult is Issues sorted ascending by numeric N plus a corrupt roster.
func List ¶
func List(req ListRequest) (ListResult, error)
List scans one state (or all) and returns issues sorted ascending by numeric N plus a roster of unparseable files. Read-only: no preamble, no dir creation, tolerant of a virgin/absent ledger.
type PromoteRequest ¶
type PromoteRequest struct {
RepoRoot string
IssuesRoot string
ID string // iss-N
LinkIntent string // itd-N; "" mints
}
PromoteRequest is the input to Promote: graduate an issue into an intent. LinkIntent, when non-empty, selects the stamp-only mode that links an EXISTING draft (itd-N) instead of minting one — the repair path after a stamp failure, and the "I already filed the intent by hand" path.
type PromoteResult ¶
type PromoteResult struct {
IssueID string `json:"issue_id"`
IssueStatus State `json:"issue_status"`
IssuePath string `json:"issue_path"`
IntentID string `json:"intent_id"`
IntentPath string `json:"intent_path"`
Linked bool `json:"linked"`
MintWarning string `json:"mint_warning,omitempty"`
}
PromoteResult is the outcome of a successful Promote. Paths are repo-relative. Linked reports stamp-only mode (no draft minted this call). MintWarning is the loud-degrade note from the intent-id refs-union scan (empty when the scan completed, and always empty in link mode) — the surface MUST render it so a degrade to working-tree-only minting is never silent.
func Promote ¶
func Promote(req PromoteRequest) (PromoteResult, error)
Promote graduates an issue into an intent without retyping (spc-24, step 2 of the record walk). Default mode mints an intent draft — slug reused from the issue, body carrying a by-id pointer to the issue rather than a copy (SSOT), promoted_from back-edge in the draft's frontmatter — then stamps the issue's promoted_to with the minted itd-N. Promotion is orthogonal to fix-status: the issue may sit in any status directory and never moves.
Ordering + residue contract: mint first, stamp second. No cross-store lock is attempted — the ledger lock alone guards the stamp, exactly as transition does — so a failure after the mint leaves an orphan draft; the returned error names the draft and the stamp-only remedy (`capture promote <iss-N> --intent <itd-N>`).
type ResolveRequest ¶
type ResolveRequest struct {
RepoRoot string
IssuesRoot string
ID string
Resolution string
// Impact is the product judgement resolved/ requires (issue_impact_valid):
// one of the shared changelog enum's values (additive|breaking|fix|internal).
// There is no default — an empty or invalid value is refused, never invented,
// so a resolved record the tool mints always satisfies its own blocker.
Impact string
// ShippedIn optionally names the release that already carried this work, as a
// tag (v0.6.2). It is a MIGRATION mechanism for the ledger-hygiene case:
// closing a record for a fix released long ago. A repository abcd manages from
// its first commit should never need it, because RS001 makes resolution ride
// the fixing commit and the cut is then right by construction. The derivation reads it and leaves such a record out
// of the current cut, so the release record cannot announce old work as new
// (iss-2608241612087533). Absent by default — the ordinary resolution is for
// work shipping in the release being prepared, and it must never be guessed.
ShippedIn string
// ByIntent / BySpec / ByCommit are the optional resolved_by provenance
// members (spc-25): the intent, spec, or commit that fixed the issue.
// Ids must exist in their record store (any bucket); the sha is
// shape-checked only. All optional — absent members are never defaulted.
ByIntent string // itd-N
BySpec string // spc-N
ByCommit string // 7–64 hex chars (64 covers a SHA-256 repo)
}
ResolveRequest moves an open issue to resolved/.
type ResolvedBy ¶
type ResolvedBy struct {
Intent string `json:"intent,omitempty"`
Spec string `json:"spec,omitempty"`
Commit string `json:"commit,omitempty"`
}
ResolvedBy is an optional structured pointer to what resolved an issue.
type SkipRecord ¶
SkipRecord surfaces a corrupt/invalid ledger file without failing the scan.
type State ¶
type State string
State is a ledger status directory (or "all" for a cross-status scan).
type StatusRequest ¶
StatusRequest is the input to the read-only status render.
type StatusResult ¶
type StatusResult struct {
OpenCount int `json:"open_count"`
ResolvedCount int `json:"resolved_count"`
WontfixCount int `json:"wontfix_count"`
RecentOpen []Issue `json:"recent_open"` // up to 10, newest first
Skipped []SkipRecord `json:"skipped"`
}
StatusResult is the bare-invocation status snapshot (guaranteed no mutation).
func Status ¶
func Status(req StatusRequest) (StatusResult, error)
Status is a pure read: counts per status dir plus up to 10 most-recent open issues (newest first). Guaranteed no mutation.
type TransitionResult ¶
type TransitionResult struct {
ID string `json:"id"`
Path string `json:"path"`
FromStatus State `json:"from_status"`
ToStatus State `json:"to_status"`
ResolvedBy *ResolvedBy `json:"resolved_by,omitempty"`
// Redacted / Degraded mirror CaptureResult: a resolution or wontfix note is
// free text written to the same committed ledger, so it goes through the
// same redactor and reports the same way.
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
}
TransitionResult is the outcome of a Resolve or Wontfix. ResolvedBy echoes the provenance members a Resolve wrote (nil on a flagless resolve and on every Wontfix — a non-action points at nothing).
func Resolve ¶
func Resolve(req ResolveRequest) (TransitionResult, error)
Resolve moves an open issue to resolved/, writing the resolution note and the product impact. resolved/ is gated by issue_impact_valid, so the impact is validated against the shared changelog enum up front (empty or invalid is refused, never defaulted) and stamped bare alongside the note — the tool's own resolve path can never mint a record its own blocker rejects.
The optional ByIntent/BySpec/ByCommit members land as the structured resolved_by object (spc-25) in the same atomic transition. Ids are validated for existence in their record store before anything is written; the sha is shape-checked only (its home may be the remote, and shallow or rebased states must not refuse a legitimate resolution). No members → no resolved_by key at all: provenance is optional, never defaulted.
func Wontfix ¶
func Wontfix(req WontfixRequest) (TransitionResult, error)
Wontfix moves an open issue to wontfix/, writing the wontfix_reason note. wontfix/ carries no impact (issue_impact_valid gates resolved/ only), so no judgement is stamped.