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
- func ComparativeRunFor(repoRoot, run string) (string, error)
- func ItemFate(repoRoot, run, item string) (issueschema.ItemFate, error)
- func LedgerRoot(cwd string) (string, error)
- func PromotedInto(repoRoot string, iss Issue) (string, error)
- func ValidateReadingRecord(content string) (map[string]any, error)
- func WithLedgerLock(repoRoot string, fn func() error) error
- type CaptureRequest
- type CaptureResult
- type Category
- type DispositionRequest
- type DispositionResult
- type DriftFinding
- type IngestReadingRequest
- type IngestReadingResult
- type Issue
- type IssueDriftRequest
- type IssueDriftResult
- type LinkRequest
- type LinkResult
- type ListRequest
- type ListResult
- type MentionEvidence
- type MentionRow
- type MentionsRequest
- type MentionsResult
- type MigrateChange
- type MigrateRequest
- type MigrateResult
- type PromoteRequest
- type PromoteResult
- type ReadingItem
- type ReadingRecordRef
- type ResolveRequest
- type ResolvedBy
- type Severity
- type SkipRecord
- type Source
- type State
- type StatusRequest
- type StatusResult
- type TransitionResult
- type WontfixRequest
Constants ¶
const ( // DriftOneSided: an intent names a ledger record in related_issues that does // not name the intent back in related_intents — or a reading item names an // intent that does not name it back. An ISSUE naming an intent that does not // name it back is not drift: an issue may be captured already related to an // intent it was never promoted into, and the reading item carries no such // loose relation, which is why the two ends are judged differently. DriftOneSided = "one_sided" // DriftDangling: either end names a record this tree does not hold. DriftDangling = "dangling" // DriftShippedUnresolved: a shipped intent names an issue that is not in // resolved/ — the intent delivered, and the observation it graduated from // still reads as unaddressed (or as declined, in wontfix/). DriftShippedUnresolved = "shipped_unresolved" // DriftRetiredField: a record still carries a retired back-link key, which no // reader reads; `abcd capture migrate --apply` rewrites it. DriftRetiredField = "retired_field" )
The drift kinds IssueDrift reports. Each names one way the promote join (itd-4 AC3) can stop reading the same from both ends.
const ( // StrengthRecord — the id was named by a commit that touched only the record // tiers (.abcd/**). Somebody wrote ABOUT the record. That is the weakest // signal there is, and it is listed last. StrengthRecord = "record" // StrengthTree — the id was named by a commit that changed something outside // the record tiers. Somebody did work and said which record it was about. StrengthTree = "tree" // StrengthResolves — a commit DECLARED `Resolves: iss-N` and the record is // still in open/. Nothing about this one is ambiguous: somebody said the // change fixed it and the ledger never moved. StrengthResolves = "resolves" )
The strength vocabulary, weakest to strongest. A row carries the strongest evidence found for its id; every piece of evidence is still listed under it.
const BlockedByFlagHelp = "comma-separated iss-N ids this issue is blocked by; each must exist in the ledger — " + blockedByDocs
BlockedByFlagHelp is the --blocked-by flag's help on both verbs that take it, exported so the front doors render one sentence rather than two copies.
const LedgerName = "the issue ledger"
LedgerName is the noun the ledger's root refusals are phrased with. It is the ledger's half of gitutil.CheckoutRoot's contract — the resolution and the refusal policy are shared, and only the noun is this store's.
const LedgerRelPath = recordid.IssuesRelDir
LedgerRelPath is the ledger root relative to the repo worktree.
const PositionComparative = "comparative"
PositionComparative is the comparative position's token, as the run record spells it. It is stated here rather than imported because core/reading imports this package and not the other way round; issueschema.ReadingPositions is the vocabulary both are held to.
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") // ErrGroundsRefused means the triage's grounds argument was absent, outside // the closed vocabulary, malformed, or below the substance floor. It is one // sentinel for every one of those because they are one thing to a caller — // the argument was not usable and nothing was written — and a surface that // distinguished them by exit code would teach a script that a misspelled // token is a different KIND of failure from a missing one // (iss-2608300930057882). ErrGroundsRefused = errors.New("grounds refused") // 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 ¶
func ComparativeRunFor ¶ added in v0.8.0
ComparativeRunFor returns the lowest committed comparative run id whose `candidate_run` names run, or the empty string when none does.
It reads the RUN RECORDS under the durable readings family, which is where a run's commit marker lives: a directory holding a parked manifest and no run record is a run that never happened, and it answers nothing here.
The LOWEST match rather than any match, so two comparative runs over one widening run — a legitimate state, since a second comparative run before any disposition is a second run — resolve to one answer that does not depend on the order the filesystem returned.
func ItemFate ¶ added in v0.8.0
func ItemFate(repoRoot, run, item string) (issueschema.ItemFate, error)
ItemFate reports what the ledger says has happened to one reading item of one run: the dispositions standing over it, and the admissions naming it as their proposal.
The admission side is keyed on the (run, proposal) PAIR, exactly as core/lint's admittedProposals keys it, and for the reason that function records: keying on the proposal alone made a proposal id a global silencer (iss-2608300935215868). An admission whose own `run` field disagrees with the directory it sits in counts under neither — the record contradicts itself about which candidate set it joined, and honouring either half would let the other lie.
An absent store is a STATE, not a fault: a repository that has dispositioned or admitted nothing has an item with no fate, which is exactly what a comparative assembly needs to find.
func LedgerRoot ¶ added in v0.8.0
LedgerRoot answers the question every front door has to ask before it touches the ledger: which checkout's ledger does a caller standing in cwd address?
It is the ledger's door onto gitutil.CheckoutRoot and holds no resolution of its own. The question is not ledger-specific — the decision store asked it next, and reached the same failure one directory further out (iss-2609091707224329) — so the three-state answer, git's toplevel or one of two refusals, is resolved once there and named here. What is ledger-specific is the noun the refusals carry, which is all this function supplies.
It exists because the CLI used to skip asking at all: every capture verb handed its working directory to resolveRoots as an explicit repo root, so the discovery below was never reached and a verb run from a subdirectory addressed a ledger that was not there — a read reported open 0 against a populated checkout, and a write minted a second ledger under the subdirectory and reported success with a repo-relative path that looked ordinary (iss-2609090951291524).
The resolution deliberately does not fall through to discoverRepoRoot's marker walk, which accepts any directory merely carrying the name and grew neither the shape check nor the ownership gate its rules-root sibling has (iss-2609090947359464). That walk is unreachable in shipped code, and routing the front doors through it would be the one change that makes it live.
func PromotedInto ¶ added in v0.10.0
PromotedInto names the intent iss was promoted into, or "" — the read-side form of the question promote asks before it writes, for a surface that renders a record's next move.
func ValidateReadingRecord ¶ added in v0.8.0
ValidateReadingRecord parses one committed reading record and validates it against the family's schema, returning its frontmatter.
It is the WRITER's own check, offered to a reader. The cold-reading assembler admits one widening run's records as a comparative reading's candidate set (adr-2609021016272867), and it has to know that what it is about to hand over is a reading record at the widening position rather than whatever a file of that name happens to hold. Exporting this check rather than writing a second one is the rule this file's header already states for the two READERS of the disposition question: two readers are tolerable, two answers are not.
func WithLedgerLock ¶ added in v0.7.0
WithLedgerLock runs fn while holding this ledger's exclusive allocator lock, for a caller OUTSIDE this package that mutates the ledger's files directly.
The cold-reading ingest verb is the one such caller: its orphan sweep unlinks reading records whose run never committed, and without this that delete races this package's own readers. Exporting the lock rather than the path is what keeps one file the lock: a caller that rebuilt the path would be holding a different lock the day this one moves.
It is NOT reentrant — an flock blocks a second acquisition in the same process — so a caller must not hold it across any exported verb of this package, every one of which takes it internally.
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
// LapsedAt is the RFC 3339 instant the discipline gave way. There is no
// default and none may be invented: the wall clock at write-up is exactly the
// value the lapse log exists to distinguish itself from (spc-60).
LapsedAt string
RelatedIntents []string
RelatedSpecs []string
BlockedBy []string // iss-N dependency edges; each must match ^iss-[0-9]+$
ForceID string // migrator-only; "" = auto-allocate
// ProductionMode is how the issue's text was produced (itd-178): one of the
// closed provenance vocabulary, or empty for the vocabulary's default. There
// is no free-text form. The record's `origin` has no request member at all —
// it is derived from which command ran, and a capture is researcher-authored
// by construction.
ProductionMode string
}
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 DispositionRequest ¶ added in v0.7.0
type DispositionRequest struct {
RepoRoot string
IssuesRoot string
// Item is the reading item this answers (rdi-N).
Item string
// State is one of issueschema.DispositionStates, subject to the per-position
// availability rule.
State string
// Grounds is disposition_grounds: free text, required on every state except
// held.
Grounds string
// ExitCondition is required on held and refused elsewhere.
ExitCondition string
// Supersedes names the standing disposition this one replaces (dsp-N) — the
// only exit from a hold.
Supersedes string
// Recurs cites prior item ids: the recorded form of the researcher's warm
// recognition of a persistence. Never a mechanical join, and never a state.
Recurs []string
// HoldFrameLocation / HoldMoscow are the RESERVED two-axis hold field. Both
// are refused while populated; the grammars are stated and dormant.
HoldFrameLocation string
HoldMoscow string
}
DispositionRequest writes one disposition, keyed to one reading item.
type DispositionResult ¶ added in v0.7.0
type DispositionResult struct {
ID string `json:"id"`
Item string `json:"item"`
State string `json:"state"`
Position string `json:"position"`
Path string `json:"path"`
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
}
DispositionResult is the outcome of a successful Disposition.
func Disposition ¶ added in v0.7.0
func Disposition(req DispositionRequest) (DispositionResult, error)
Disposition writes the researcher's answer to one reading item, into a directory keyed by the ITEM and a file keyed by the disposition's own id.
The two keys settle requirements that pull against each other. Status is the presence of the keyed directory — one probe, never a folder-membership question. And a disposition still has an id of its own, so the only exit from a held state (a superseding disposition that CITES the one it replaces) has something to cite. The superseded record stays in place: a hold that vanished when it was answered would take its own exit condition with it (adr-3 — the location is the state, and git is the history).
type DriftFinding ¶ added in v0.10.0
type DriftFinding struct {
Kind string `json:"kind"`
Record string `json:"record"`
Other string `json:"other"`
Path string `json:"path"`
Message string `json:"message"`
}
DriftFinding is one broken join. Record is the record carrying the edge the finding is about, Other the record that edge names; Path is Record's path, repo-relative.
type IngestReadingRequest ¶ added in v0.7.0
type IngestReadingRequest struct {
RepoRoot string
IssuesRoot string
// Run is the run identifier (rdg-N) minted by the assembler.
Run string
// Manifest is the content-hash reference to the run's committed manifest,
// which is what makes the assembly re-runnable and diffable.
Manifest string
Position string
Regime string
Items []ReadingItem
}
IngestReadingRequest writes one run's items into the ledger. Position and Regime come from the reading's DEFINITION, never from operator input, and are therefore run-level rather than per-item.
type IngestReadingResult ¶ added in v0.7.0
type IngestReadingResult struct {
Run string `json:"run"`
Records []ReadingRecordRef `json:"records"`
// Redacted counts the spans the ledger redactor rewrote across every item
// written, and Degraded is non-empty when it ran with a weakened pattern set.
// Both exist so a surface can SAY the text was altered.
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
}
IngestReadingResult is the outcome of a successful ingest.
func IngestReading ¶ added in v0.7.0
func IngestReading(req IngestReadingRequest) (IngestReadingResult, error)
IngestReading writes one reading record per item under readings/<run-id>/rdi-<N>.md. Every id is minted (adr-45) and never derived from the item's content, so two runs returning the same tension carry different ids for free — a re-raise stays distinguishable from its first appearance, and the recurrence signal survives.
It is the ledger's record WRITER, not a payload validator: the output contract that "validated" refers to belongs to the cold-reading output contract, which calls this and adds no second validation path. What is enforced here is the RECORD schema — the envelope, the position's own body, and the reserved fields — which is this package's to refuse.
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"`
// LapsedAt is the RFC 3339 instant at which a recorded discipline gave way —
// the lapse itself, never the write-up (spc-60). Required exactly when
// Category is lapse; optional, and rarely meaningful, for every other.
LapsedAt string `json:"lapsed_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
// Grounds is the record's recorded conjectures, in the order they were
// written: one `<token>: <text>` value in the shared core/grounds vocabulary
// per grounds-bearing act. Appended by promote, resolve and wontfix; never by
// the create path, because an observation being filed is not yet a conjecture
// being pursued.
//
// It is a LIST because recording is append-only. A record promoted and then
// resolved carries both conjectures, and the earlier one is precisely what a
// later reader checks the outcome against (iss-2608301657354776). The values
// live in the body's `## Grounds` section, not in frontmatter: a frontmatter
// scalar is set, and setting is what destroyed the first of them.
Grounds []string `json:"grounds,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 IssueDriftRequest ¶ added in v0.10.0
IssueDriftRequest is the input to IssueDrift. Now stamps the receipt; the zero value means the current time.
type IssueDriftResult ¶ added in v0.10.0
type IssueDriftResult struct {
Scanned int `json:"scanned"`
Findings []DriftFinding `json:"findings"`
// ReceiptPath is the repo-relative report this run left in the local tier.
ReceiptPath string `json:"receipt_path"`
}
IssueDriftResult is the outcome of one drift walk.
func IssueDrift ¶ added in v0.10.0
func IssueDrift(req IssueDriftRequest) (IssueDriftResult, error)
IssueDrift walks the intent store and the issue ledger (readings included) and reports every place the promote join does not read the same from both ends: the bidirectional cross-reference check itd-4 AC3 names, in the shape the predecessor store's spc-23 gave it. It writes nothing to either store; it leaves one report under .abcd/.work.local/logs/audit/issue-drift-<ts>/, and the front door decides what the findings mean for its exit code.
type LinkRequest ¶ added in v0.10.0
type LinkRequest struct {
RepoRoot string
IssuesRoot string
ID string // the subject iss-N, in any status folder
BlockedBy []string // iss-N ids to append to the record's blocked_by
Unblock []string // iss-N ids to remove from it
}
LinkRequest edits one record's blocked_by edges AFTER capture (iss-2609200951237670). Unblock is applied first, then BlockedBy, so the same id on both sides is removed and re-added — a documented net no-op. At least one of the two must be non-empty.
type LinkResult ¶ added in v0.10.0
type LinkResult struct {
ID string `json:"id"`
Path string `json:"path"`
BlockedBy []string `json:"blocked_by"`
}
LinkResult is the outcome of a successful Link: the subject, its repo-relative path, and the blocked_by list AS WRITTEN. An emptied list comes back as an empty list, never null — the field is the point of the verb.
func Link ¶ added in v0.10.0
func Link(req LinkRequest) (LinkResult, error)
Link appends to, or removes from, one record's blocked_by list — the post-hoc form of capture's --blocked-by, for the ordinary case the create-time flag cannot serve: the blocker captured after the blocked record, or in another lane. The subject may sit in ANY status folder and never moves: a resolved record's edges are history, still editable, and the write is the same in-place stamp promote uses from any folder (find, checksum-read, rewrite the frontmatter, validate the result against the folder it is in, atomic write under the ledger lock). The derived-priority reader picks the change up with no other change, because it reads the field this rewrites.
Every refusal is raised before anything is written: the targets through validateBlockers (capture's own validator), and an --unblock of an id the list does not currently hold, which is refused naming the current list — removing an edge that is not there is a wrong belief about the record, not a no-op.
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 MentionEvidence ¶ added in v0.9.0
type MentionEvidence struct {
Commit string `json:"commit"`
Date string `json:"date"`
Subject string `json:"subject"`
Strength string `json:"strength"`
}
MentionEvidence is one commit that named a record, and how it named it.
type MentionRow ¶ added in v0.9.0
type MentionRow struct {
ID string `json:"id"`
Severity Severity `json:"severity,omitempty"`
Path string `json:"path,omitempty"`
Strength string `json:"strength"`
Evidence []MentionEvidence `json:"evidence"`
}
MentionRow is one open record the walk found named, with every mention that named it. A row with no evidence is never emitted: a row nobody can check is an accusation, not a listing.
type MentionsRequest ¶ added in v0.9.0
type MentionsRequest struct {
RepoRoot string
IssuesRoot string
// Ref is the history to walk. Empty means the repository's default branch,
// resolved without touching the network.
Ref string
}
MentionsRequest asks for the listing over one repository.
type MentionsResult ¶ added in v0.9.0
type MentionsResult struct {
Ref string `json:"ref"`
Commits int `json:"commits"`
OpenRecords int `json:"open_records"`
Rows []MentionRow `json:"rows"`
Skipped []SkipRecord `json:"skipped"`
}
MentionsResult is the advisory listing. Ref and Commits say what was walked, so a reader can tell an empty listing from an unwalked history.
func Mentions ¶ added in v0.9.0
func Mentions(req MentionsRequest) (MentionsResult, error)
Mentions lists open records whose ids are named by the history of Ref with no resolution behind them. Strictly read-only: it runs read-only git commands and the ledger's own List, and writes nothing anywhere.
type MigrateChange ¶ added in v0.10.0
type MigrateChange struct {
ID string `json:"id"`
Path string `json:"path"` // repo-relative
// Retired is the retired line the record carries, `key: value`, or empty
// when the record carries none and changes only because the OTHER end of a
// join it belongs to did.
Retired string `json:"retired,omitempty"`
// Key is the successor list the record carries after the change, and List
// its full value then.
Key string `json:"key"`
List []string `json:"list"`
}
MigrateChange is one record the migration rewrites (or would rewrite).
type MigrateRequest ¶ added in v0.10.0
MigrateRequest is the input to Migrate. Apply false reports what would change and writes nothing.
type MigrateResult ¶ added in v0.10.0
type MigrateResult struct {
Applied bool `json:"applied"`
// Scanned counts the ledger records and intents read.
Scanned int `json:"scanned"`
Changes []MigrateChange `json:"changes"`
// Notes are joins the migration completed from one end only because the
// other end names a record this tree does not hold. The drift check reports
// the same joins as dangling; the migration writes what it can.
Notes []string `json:"notes,omitempty"`
}
MigrateResult reports a migration run.
func Migrate ¶ added in v0.10.0
func Migrate(req MigrateRequest) (MigrateResult, error)
Migrate rewrites the promote join's retired back-links into the names itd-4 AC3 gives them, across the issue ledger, the readings store and the intent store: `promoted_to: itd-M` on a ledger record becomes a member of its `related_intents`, and `promoted_from: <id>` on an intent becomes the first member of its `related_issues`.
"Promoted" is the two-sided PAIR under the new names (see promotedInto), where the old scheme let either end say it alone. So a join an older abcd wrote from one end only — a link-mode promote of a hand-filed draft stamped the ledger half alone — is completed from the other end as well, or the migrated tree would stop saying the record was promoted at all.
Nothing else moves: a loose `related_intents` entry is kept where it is, and a record carrying no retired key and joined to nothing that did is left byte-identical. The run is idempotent. It holds the ledger lock for the whole apply, so no verb writes the ledger between the read and the rewrite.
type PromoteRequest ¶
type PromoteRequest struct {
RepoRoot string
IssuesRoot string
// ID is the record to graduate: an iss-N, or the rdi-N of a reading item
// that has been dispositioned.
ID string
LinkIntent string // itd-N; "" mints
// Grounds is the REQUIRED conjecture behind the promotion, in the shared
// `<token>: <text>` grammar (core/grounds). A capture routed to an intent
// draft is a conjecture being pursued, and there is nothing to stage here:
// promote mints the value in the same call, so it has no corpus to fix.
Grounds string
// ProductionMode is how the MINTED DRAFT's seed text was produced (itd-178),
// or empty for the vocabulary's default. It has no effect in stamp-only mode,
// where nothing is minted. The draft's `origin` is not a member here: promote
// is the one shipped path that derives a record from another record, so it
// derives extracted-from-record from what it did rather than from what it was
// told.
ProductionMode string
}
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 is the source record's status. For an issue that is its status
// directory; for a reading item it is the STANDING DISPOSITION's state,
// because that family's status signal is the presence of the keyed
// disposition and never folder membership.
IssueStatus State `json:"issue_status"`
IssuePath string `json:"issue_path"`
IntentID string `json:"intent_id"`
IntentPath string `json:"intent_path"`
Linked bool `json:"linked"`
// BackEdgeKept names the record a linked draft's `related_issues` ALREADY
// carried first, when this call appended beside it. An intent occasioned by
// several records is promoted from one and joined to the others, so an
// existing back-edge is kept first and reported rather than refused or
// overwritten (itd-2609020625400169, first scope condition). Empty on every
// other outcome, the mint included.
BackEdgeKept string `json:"back_edge_kept,omitempty"`
// Redacted / Degraded mirror TransitionResult: the grounds text is free prose
// written to the same committed ledger, so it goes through the same redactor
// and reports the same way. Rewriting somebody's reasoning in silence is worse
// than not recording it.
Redacted int `json:"redacted,omitempty"`
Degraded string `json:"redaction_degraded,omitempty"`
}
PromoteResult is the outcome of a successful Promote. Paths are repo-relative. Linked reports stamp-only mode (no draft minted this call).
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), the issue named in the draft's `related_issues` — then appends the minted itd-N to the issue's `related_intents`. The two halves are itd-4 AC3's bidirectional join, and the pair — an intent the record names that names the record back — is what "promoted" means (see promotedInto). 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> --grounds '...'`), carrying the promotion's own grounds, single-quoted, so the remedy runs as printed in any shell — an interactive one included.
Every refusal that can be established from the bytes in hand is therefore raised BEFORE the mint: the grounds text, whether the record is one the validators would let the stamp write at all, and whether it can take the append. What is left to the stamp is what only a write under the lock can discover, which is the residue the remedy above is for — never a deterministic refusal that would leak one draft per attempt.
type ReadingItem ¶ added in v0.7.0
type ReadingItem struct {
// Pattern is the pattern named — required at every position and in every
// supply regime.
Pattern string
// Body carries exactly the fields the run's position declares
// (issueschema.ReadingBodyFields). A field from another position's body is
// refused: one record type, four bodies, and an item belongs to one of them.
Body map[string]string
// OccasionedBy is RESERVED and dormant — the join key of the surprise entry,
// populated in Iteration 2. A populated value is refused until the shape is
// ruled, so the reservation is a behaviour rather than a comment.
OccasionedBy string
}
ReadingItem is one thing the instrument returned: the pattern it named (an envelope field, because a universal core condition must not live in a variant part) plus the position-typed body.
type ReadingRecordRef ¶ added in v0.7.0
ReadingRecordRef is one written reading record: its minted id and its repo-relative path.
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)
// Grounds is the REQUIRED conjecture behind the resolution, in the shared
// `<token>: <text>` grammar (core/grounds). There is no default and none may
// be invented: a route recorded without its reasoning is the evaporation
// itd-179 exists to close, and resolve mints the value in the same call, so
// it has no corpus to fix and refuses from the start.
Grounds string
// ProductionMode RESTAMPS the record's production_mode (itd-178). A
// resolution note is new text with its own mode, so the key is not frozen at
// mint — but an empty value leaves the existing stamp alone rather than
// overwriting it with a default, because a transition that declares nothing
// has made no claim about how the note was produced. `origin` is never
// rewritten: where a record came from does not change when it is resolved.
ProductionMode string
}
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"`
// Relinked lists every relative markdown link the transition repointed
// because it named the issue's old path in open/ (iss-2609250846525896).
Relinked []relink.Rewrite `json:"relinked,omitempty"`
// RelinkError is a NON-FATAL report of a repoint that failed part-way: the
// issue has moved and the transition stands, so the surface prints it
// loudly, and record-lint's links_resolve names any link left behind.
RelinkError string `json:"relink_error,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 and the `declined:` grounds derived from it. wontfix/ carries no impact (issue_impact_valid gates resolved/ only), so no judgement is stamped.
It needs no new required flag: transition already refuses an empty reason, so a wontfix could never be recorded without grounds — what it lacked was the TYPE. Grounds overrides the text when the conjecture is worth stating separately from the user-facing reason.
type WontfixRequest ¶
type WontfixRequest struct {
RepoRoot string
IssuesRoot string
ID string
Reason string
// Grounds optionally overrides the text stamped as `declined: <text>`. A
// wontfix can never be recorded without grounds — transition already refuses
// an empty Reason — so what it lacked was the TYPE, not the text, and the
// reason supplies the default. The override exists because the user-facing
// reason and the conjecture are not always the same sentence. The token stays
// declined: a non-action is what that value names.
Grounds string
// ProductionMode restamps production_mode on the same terms as
// ResolveRequest's: declared restamps, absent leaves the stamp alone.
ProductionMode string
}
WontfixRequest moves an open issue to wontfix/.