Documentation
¶
Overview ¶
Package lint is abcd's record-drift gate: it reads a JSON config and lints the markdown design record, returning findings. It performs no I/O beyond reading files under a caller-supplied repo root — no printing, no os.Exit — so it is fully testable and reusable across surfaces.
Index ¶
- Constants
- Variables
- func CanonicalClaimType(v string) (string, bool)
- func DaysBetween(from, to time.Time) int
- func DeriveReleaseContentSha(root, released string) (string, error)
- func DocumentsInRoots(cfg Config, repoRoot string) (int, error)
- func FloatingJudgeModel(model string) string
- func HandleLess(a, b string) bool
- func PersonaAttribution(text string) (string, bool)
- func PrincipleEvidence(raw string) ([]string, bool)
- func PrincipleLinkIn(text string) (string, bool)
- func PrunedInRoots(cfg Config, repoRoot string) ([]string, error)
- func ReleaseGateManifestHash(repoRoot string) (string, error)
- func ReleasedVersion(root, rev string) (string, error)
- func SaveBaseline(path string, b Baseline) error
- func SetBriefFlagCheck(fn func(repoRoot string) ([]BriefFlagMiss, error))
- func SetIssueReader(fn func(content, status, path string) error)
- func SetRecordBodyCheck(fn func(rel, content string) error)
- func SetSupersessionChain(...)
- func UnwrapPrincipleLinks(text string) string
- func ValidateBannedToken(t BannedToken) error
- type BannedToken
- type Baseline
- type BaselineEntry
- type BaselineError
- type BriefFlagMiss
- type CitationPolicySet
- type CitationSite
- type CitationSummary
- type CitedURL
- type CommittedTier
- type Config
- type ContestedItem
- type DecisionsAppendReport
- type Finding
- type GateReceipt
- type IndexSpec
- type IntentLink
- type OpenHold
- type OutstandingItem
- type OutstandingReadings
- type PrincipleStatement
- type ProseBaseline
- type ProseBaselineEntry
- type ProseCitation
- type ReceiptCheck
- type ReceiptFinding
- type ReceiptProblem
- type RecordEdge
- type RecordGraph
- type RecordNode
- type ReleaseGate
- type RuleConfig
- type SpecLink
- type SpecLinkIndex
- type SupersessionLink
- type TokenChecker
- type UnreadableAnswer
- type UnsafePath
- type WideningRun
Constants ¶
const ( // OutcomeAlive means the URL resolved to a live document. OutcomeAlive = "alive" // OutcomeBroken means it did not, and the gate must block on it. OutcomeBroken = "broken" )
The outcomes a checked citation can have. Two values, not a free string: the gate branches on this, so an unrecognised outcome is a refusal at load.
const ( // VerificationAutomatic means the refresh verb's fetcher established it. VerificationAutomatic = "automatic" // VerificationManual means a human confirmed it after the fetcher could not. VerificationManual = "manual" )
The verification labels. This is the "automatic or manual" axis of AC 2 — WHO established the outcome, never how.
const ( ClaimCriterion = "criterion" ClaimCausal = "causal" ClaimContext = "context" )
The claim vocabulary: the design documents' three words for the claim kinds intents carry, and the shipped intent token read as an alias for the causal kind (itd-177, itd-190). Nothing refuses the alias and nothing writes it.
const BaselineSchemaVersion = 1
BaselineSchemaVersion is the only baseline schema this build understands. A document declaring anything else is refused rather than best-effort parsed: the gate must never enforce a record whose meaning it is guessing at.
const CitationNagWindowDays = 30
CitationNagWindowDays is how far ahead of the blocking threshold the release preflight starts naming entries. A month is enough notice to clear a manual queue before a release, and short enough that the nag still means something.
const DecisionsLedger = ".abcd/work/DECISIONS.md"
DecisionsLedger is the repo-relative path of the append-only decision log.
const DefaultBaselinePath = ".abcd/citations-baseline.json"
DefaultBaselinePath is the committed baseline's repo-relative home. It sits beside the other committed machine records under .abcd/ (docs-lint.json, record-lint.json, rules.json) rather than inside the development record, because it is configuration the gate reads on every commit, not design material.
const DefaultProseBaselinePath = ".abcd/prose-citations-baseline.json"
DefaultProseBaselinePath is the committed baseline's repo-relative home. It sits beside the other committed machine records under .abcd/ — record-lint.json, citations-baseline.json — because it is a record the gate reads on every commit.
const DefaultRecordLintConfigPath = ".abcd/record-lint.json"
DefaultRecordLintConfigPath is the repository's record-lint configuration, repo-relative: the one a writer consults to learn what the gate will refuse.
const PrincipleStatementLabel = "The rule"
PrincipleStatementLabel is the bold label that opens a principle's statement paragraph. The statement is the H1 title and this paragraph, and nothing after it; the reading assembler projects exactly that, and principle_claims refuses a typed statement carrying anything the projection could not keep.
const ProseBaselineSchemaVersion = 1
ProseBaselineSchemaVersion is the only baseline schema this build understands. A document declaring anything else is refused rather than best-effort parsed: a gate must never enforce a record whose meaning it is guessing at.
const ReleaseWorkflowPath = ".github/workflows/release.yml"
ReleaseWorkflowPath is the workflow that arms the receipt gate: the release job's `--require-gate` list is the trust root for which semantic gates a release requires (the in-tree record-lint config is committer-editable and is deliberately not consulted for it).
const SurfaceCoverageLabel = "" /* 143-byte string literal not displayed */
SurfaceCoverageLabel opens every surface_coverage finding (itd-147 ac-7). The rule checks that rows exist, in the surfaces index and in each chapter's `## Sub-verbs` table, and agree with the plugin surface and the command-tree snapshot; it reads no chapter prose. A green run once read as a chapter-correctness gate while false prose claims sat beside the rows it checked, so each finding says which check it is. What keeps a chapter's flags and sub-verbs true is its generated appendix and the drift test over it (internal/surface/cli), not this rule.
Variables ¶
var ClaimTypes = []string{ClaimCriterion, ClaimCausal, ClaimContext}
ClaimTypes is the closed vocabulary, in the order a refusal names it.
var ErrReceiptConfig = errors.New("receipt gate: cannot load the record-lint config the release job arms")
ErrReceiptConfig is returned when the gate is armed but record-lint's config cannot be loaded — the release job would stop at the same point.
var PrincipleKeys = []string{"claim_type", "reference", "comparison", "evidence"}
PrincipleKeys are the four claim keys a principle may declare, in the order a finding lists them.
Functions ¶
func CanonicalClaimType ¶ added in v0.11.1
CanonicalClaimType reads a claim_type value into the vocabulary: one of the three, or the alias read as causal. ok is false for anything else.
func DaysBetween ¶
DaysBetween counts whole calendar days, both ends normalised to UTC midnight. Comparing instants would make the 180-day boundary depend on the hour the gate happened to run.
It is exported because the refresh verb decides which entries are stale enough to re-check and MUST get the same answer as the gate that will later warn on them. Two copies of this arithmetic is two chances for a boundary to drift, which would surface as a URL the verb thinks current and the gate thinks overdue, with nothing to say which is right.
func DeriveReleaseContentSha ¶ added in v0.6.8
DeriveReleaseContentSha resolves the reviewed CONTENT commit a release's semantic gate must be armed against, by reading the RECEIPTS DIRECTORY of the released tree rather than by walking commit ancestry (HEAD^2^ / HEAD^).
The old HEAD-ancestry derivation is unsafe under a batched merge queue (iss-355): main advances one push per batch, so `github.sha` is the batch TIP, and `HEAD^2^` of that tip resolves the LAST-merged PR's pre-merge commit — an unrelated PR whenever the release roll is not the final entry in its batch. The `git merge-base --is-ancestor` guard passes for that unrelated commit (it is on the released lineage), and the run wedges after the immutable tag exactly as iss-326 records, by a route the pre-merge check cannot close because batch composition is decided by the queue.
The receipts name the commit they gate: a semantic-pass receipt lives at .abcd/work/reviews/<content-sha>/<gate>.json, so <content-sha> is carried by the directory name, present in the released tree, and independent of where the release roll sat in its batch. This derivation therefore enumerates the receipt subdirectories of the released tree, keeps those whose name is a commit that is an ancestor of `released`, and returns the NEAREST such ancestor — the content commit of THIS release, since every earlier release's receipts sit further back on the shared history.
It fails closed: an unreadable listing, no receipt directory on the released lineage, or two equidistant candidates all return an error rather than a guess, so an armed gate never resolves to the wrong commit or to nothing.
func DocumentsInRoots ¶ added in v0.10.0
DocumentsInRoots counts the markdown documents a Lint over cfg reads through its roots: the documents every per-document rule (banned tokens, links, the citation family) checks. Zero beside an armed config means those rules read nothing, which a front door must say rather than report a count that implies a check happened (loud-staging; ruling G2, 2026-09-23). The roots are contained exactly as LintAt contains them, and a root that does not resolve is the same configuration error.
func FloatingJudgeModel ¶ added in v0.12.0
FloatingJudgeModel reports why a receipt's judgeModel is a floating alias rather than a pinned snapshot, or "" when it is pinned. The runbook's rule is that a receipt names the judge that produced it so the pass can be re-run against the same judge; an id that resolves to whatever the vendor serves today cannot be. Pinned means the id carries a version or date component — claude-opus-4-8, Claude Fable 5, a dated suffix — which is what the documented example and every committed receipt satisfy. Refused: a bare family name with no digit anywhere (opus, claude-sonnet), and a rolling alias, which names "latest" whether or not a version fragment precedes it (claude-opus-4-latest floats within the 4 line exactly as claude-opus-latest floats across lines). The check is deliberately shape-only — it knows no vendor's catalogue. The docs review's record applies it too, so it saves no receipt this gate would refuse.
func HandleLess ¶
HandleLess orders two record handles by store prefix, then NUMERICALLY — so adr-9 precedes adr-10, which a plain string sort gets backwards and which a reader of any rendered list notices immediately.
It is exported alongside the graph because every consumer that renders a record list needs exactly this order, and the obvious second implementation is a plain string sort that looks right until the store passes nine records.
func PersonaAttribution ¶ added in v0.10.0
PersonaAttribution returns the first persona name text attributes words to in the `said <Name>,` or `says <Name>,` form the persona_registry rule reads, and whether it found one. The release page refuses one in headline prose, where no quote is verified against its source.
func PrincipleEvidence ¶ added in v0.11.1
PrincipleEvidence is principleEvidence for a caller outside the lint: the one reader of evidence's grammar.
func PrincipleLinkIn ¶ added in v0.11.1
PrincipleLinkIn returns the first link of any shape the text carries, and whether it carries one: the one answer both readers give to "does this statement link?".
func PrunedInRoots ¶ added in v0.11.1
PrunedInRoots names the gitignored paths the per-file walk over cfg's roots prunes, repo-relative and sorted, a wholly ignored directory once with its trailing slash. A front door reports them, so a lint that skipped a cached clone says it did rather than reading as a smaller tree (loud-staging). The roots are contained exactly as LintAt contains them.
func ReleaseGateManifestHash ¶ added in v0.12.0
ReleaseGateManifestHash is the hash a manifest-era receipt must echo: sha256 over the committed release-gate manifest's bytes, "" when the repository has no manifest (the pre-manifest era, where no receipt carries one).
func ReleasedVersion ¶ added in v0.11.0
ReleasedVersion is the version the released tree at rev names, read by the same strict reader the derivation binds the receipts with. The release gate compares it with the pushed tag (iss-2609251945586202), so the tag and the receipts are bound to one reading of the tree and never to two. It refuses exactly where the derivation does: no CHANGELOG.md, no dated release, or a newest release heading the reader cannot parse.
func SaveBaseline ¶
SaveBaseline validates and writes a baseline atomically. Validation runs on the way OUT as well as in, so a producer bug can never commit a record the gate would then refuse to load.
func SetBriefFlagCheck ¶ added in v0.13.3
func SetBriefFlagCheck(fn func(repoRoot string) ([]BriefFlagMiss, error))
SetBriefFlagCheck registers the reader brief_flag_landed asks. Pass docfidelity.UnlandedFlags.
func SetIssueReader ¶ added in v0.11.1
SetIssueReader registers the issue ledger's reader for the record_schema reader-parity leg. Pass capture.ReadRefusal.
func SetRecordBodyCheck ¶ added in v0.11.1
SetRecordBodyCheck registers the site renderer's body check for the record_schema body leg. Pass site.CheckRecordBody.
func SetSupersessionChain ¶ added in v0.12.0
func SetSupersessionChain(fn func(repoRoot string, links []SupersessionLink, id string) (chain []string, endID, endBucket, problem string, err error))
SetSupersessionChain registers the supersession chain reader stale_edge follows. Pass intent.SupersessionChainOf.
func UnwrapPrincipleLinks ¶ added in v0.11.1
UnwrapPrincipleLinks replaces every labelled link with its label, on the renderedTexts precedent: the target is a citation and the label is prose. What it cannot unwrap, a link with no label, it leaves for PrincipleLinkIn.
func ValidateBannedToken ¶
func ValidateBannedToken(t BannedToken) error
ValidateBannedToken reports whether one banned-token entry is loadable by THIS linter — the engine that enforces the public banlist layer. It exists so a writer of that config (`abcd banlist add --public`) validates through the same compile the gate itself performs, on the exact string it is about to store, rather than through a second reading that could accept an entry the gate then refuses. The error is returned for the caller to discard or wrap: it quotes the expression, which is safe for a public pattern and never safe for a private one.
Types ¶
type BannedToken ¶
type BannedToken struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
Message string `json:"message"`
Severity string `json:"severity"`
// Successor is the machine-readable old->new mapping: what to use instead of
// the banned token. It is REQUIRED (a ban with no successor left its
// replacement in prose only, iss-51) and is auto-cited in the finding message.
Successor string `json:"successor"`
// AllowContext lists regexps that, if any matches the same line, suppress
// the finding (the token is legitimate in that context). It is REQUIRED to be
// non-empty: every ban must declare where its token is legitimately allowed.
AllowContext []string `json:"allow_context"`
// SkipCodeFences omits fenced-code lines from scanning. A nil pointer means
// the family's default: true for a documentation token, whose fenced example
// is not prose; false for a `names/` token, the name gate, which reaches the
// whole public surface, where a fence is published as readily as prose
// (iss-2609252251320133). Set it to override either default.
SkipCodeFences *bool `json:"skip_code_fences"`
// ExtraRoots are repo-relative directories or files THIS token alone reads in
// addition to the configuration's Roots. Every text file there is read, not
// only markdown, because a rules file written in JSON is abcd's own text as
// much as a page is; exempt_paths, exempt_if_status, the allow_context escape
// and the fence default apply as they do under Roots. It widens one ban
// without arming the rest of the family — a spelling or present-tense token —
// over trees that are not documentation (itd-2609212137129937: the role word
// is refused in the command pages and the rules files). A file the Roots walk
// already read is not read twice.
ExtraRoots []string `json:"extra_roots,omitempty"`
}
BannedToken is one entry in the banned_tokens family (check A).
type Baseline ¶
type Baseline struct {
// SchemaVersion pins the document's shape. Required.
SchemaVersion int `json:"schema_version"`
// Entries is keyed by the cited URL exactly as it appears in the docs.
Entries map[string]BaselineEntry `json:"entries"`
}
Baseline is the committed citation record: one entry per cited URL.
func LoadBaseline ¶
LoadBaseline reads, decodes, and validates a committed baseline.
A missing file is returned as the underlying os.ErrNotExist, so the caller can distinguish "this repo has no baseline yet" (a state the gate reports as one finding) from "this repo has a corrupt baseline" (a refusal).
type BaselineEntry ¶
type BaselineEntry struct {
// URL optionally restates the map key. It is redundant by design — a
// committed record reads better in a diff when each entry names itself — and
// is validated to AGREE with its key rather than being a second source of
// truth. Empty is fine; disagreeing is a refusal.
URL string `json:"url,omitempty"`
// FinalURL is the address the citation actually resolved to after redirects.
// When it differs from the cited URL, the docs are citing a stale address and
// the gate says so.
FinalURL string `json:"final_url"`
// LastChecked is when the outcome was established. This is THE staleness
// clock — the same clock for automatic and manual entries alike, so a human
// verification buys no exemption from ageing (AC 3).
LastChecked string `json:"last_checked"`
// Outcome is OutcomeAlive or OutcomeBroken.
Outcome string `json:"outcome"`
// Verification is VerificationAutomatic or VerificationManual — who
// established the outcome.
Verification string `json:"verification"`
// VerifiedOn is the date that verification was recorded.
VerifiedOn string `json:"verified_on"`
}
BaselineEntry is one URL's record.
Every field here answers "what is true about this link", and none answers "how did we find out". That omission is the schema's contract (AC 2), pinned by TestBaselineHasNoMethodFieldByConstruction.
type BaselineError ¶
type BaselineError struct {
// contains filtered or unexported fields
}
BaselineError is a malformed-baseline refusal. It is a distinct type so a caller can tell a bad record from an I/O fault without string matching.
func (*BaselineError) Error ¶
func (e *BaselineError) Error() string
type BriefFlagMiss ¶ added in v0.13.3
BriefFlagMiss is one review flag whose replacement no line of its chapter carries: the flag's line in File, the chapter it names, its replacement, and why the chapter does not carry it.
type CitationPolicySet ¶
type CitationPolicySet struct {
// BaselineRel is repo-relative — the only form that may reach a message or
// machine output, so no developer-identity path is ever rendered.
BaselineRel string
// BaselinePath is absolute, for reading and writing.
BaselinePath string
WarnDays int
BlockDays int
}
CitationPolicySet is the resolved citation-baseline policy: where the record lives, in both the form messages use and the form I/O uses, and the two staleness thresholds.
func CitationPolicy ¶
func CitationPolicy(cfg Config, repoRoot string) (CitationPolicySet, error)
CitationPolicy resolves the citation-baseline settings a repo's config declares, filling in spc-17's defaults for anything it leaves unset.
It exists so the refresh verb and the gate read the SAME policy: the verb decides which entries are stale enough to re-check from the very number the lint will later warn on, rather than from a second copy of 180 that drifts.
It is also the containment choke point for the one config value that steers a WRITE. `.abcd/docs-lint.json` is a committed file, so a contributor controls it; `abcd docs cite refresh` then hands `baseline` to SaveBaseline, which MkdirAll's the parent. Without the check below, a `baseline` of "../../../etc/x.json" turns a routine refresh into an arbitrary-file-write primitive that escapes the repository. Every reader and both writers resolve the path through here, so one check covers all four.
type CitationSite ¶
CitationSite is one place a URL is cited: a repo-relative page and a 1-based line. A URL cited from several pages carries one site per occurrence, so the manual queue can tell the maintainer where to look.
type CitationSummary ¶
type CitationSummary struct {
// Present reports whether a baseline file exists at all.
Present bool `json:"present"`
// Cited is how many distinct URLs the documentation cites.
Cited int `json:"cited"`
// Recorded is how many of those have a baseline entry; Missing is the rest.
Recorded int `json:"recorded"`
Missing int `json:"missing"`
// Broken counts entries recorded as broken.
Broken int `json:"broken"`
// Manual counts entries a human established. They age on the same clock as
// automatic ones, so this is reported, never subtracted from the stale count.
Manual int `json:"manual"`
// Stale counts entries past the warn threshold (which includes every
// approaching and overdue one); Overdue counts those past the blocking one;
// Approaching counts the band just short of blocking.
Stale int `json:"stale"`
Overdue int `json:"overdue"`
Approaching int `json:"approaching"`
// OldestChecked is the earliest last_checked date among cited entries.
OldestChecked string `json:"oldest_checked,omitempty"`
// OverdueURLs and ApproachingURLs name what a nag must list, sorted.
OverdueURLs []string `json:"overdue_urls,omitempty"`
ApproachingURLs []string `json:"approaching_urls,omitempty"`
}
CitationSummary is the committed baseline's state against the repo's current citations. Every count is over the CITED set: an entry for a URL the docs no longer cite is not a health problem, it is something the next refresh drops.
func CitationAgeSummary ¶
func CitationAgeSummary(cfg Config, repoRoot string) (CitationSummary, error)
CitationAgeSummary grades the baseline against the wall clock.
func CitationAgeSummaryAt ¶
CitationAgeSummaryAt is CitationAgeSummary with the clock supplied, so the band boundaries are testable exactly.
A missing baseline is reported, not an error: a repo that has not refreshed yet is a state a status line must be able to describe. A MALFORMED one is still an error — a record the gate cannot read is not a health report.
func (CitationSummary) Healthy ¶
func (s CitationSummary) Healthy() bool
Healthy reports whether the baseline needs no attention: every citation has a current, unbroken receipt.
type CitedURL ¶
type CitedURL struct {
URL string `json:"url"`
Sites []CitationSite `json:"sites"`
}
CitedURL is one distinct cited address and everywhere it is cited.
func CollectCitedURLs ¶
CollectCitedURLs walks cfg.Roots and returns the repo's distinct cited URLs, sorted by address so a refresh run and its baseline diff are deterministic.
"Cited" means what the lint means by it: a URL on a footnote-definition line (including its wrapped continuation lines), never one in body prose. A missing root is skipped rather than an error, matching Lint.
type CommittedTier ¶ added in v0.13.3
type CommittedTier struct {
// Rel is the tier's repo-relative, slash-separated path.
Rel string
// Label names the tier in a finding or a gap, for a person.
Label string
}
CommittedTier is one committed tier of the three-tier .abcd/ layout: a directory the repository lint's three-tier-layout rule requires, and the directory `abcd ahoy install` creates when it is missing.
func CommittedTiers ¶ added in v0.13.3
func CommittedTiers() []CommittedTier
CommittedTiers is the one list of the committed tiers. The lint rule that requires them and the install that creates them both read it, so the two cannot disagree about what a set-up repository holds (iss-2610071538028804). The local-ephemeral tier is not in it: it is gitignored and created on demand, so a fresh clone rightly has none.
type Config ¶
type Config struct {
// Roots are repo-relative directories the lint walks (markdown record).
Roots []string `json:"roots"`
// BannedTokens are line-level substring/regex bans (check family A).
BannedTokens []BannedToken `json:"banned_tokens"`
// Rules holds the per-check configuration for the remaining families,
// keyed by rule id (no_git_metadata, links_resolve, ...).
Rules map[string]RuleConfig `json:"rules"`
// ExemptPaths are repo-relative path prefixes whose files skip the
// content-AUTHORING checks (banned_tokens, persona_registry) — the historical,
// non-forward-looking part of the record, which is excused from how it is
// written but never from being well-formed. Both intent-tree checks
// (intent_lifecycle, intent_impact_valid — they share one scan) stay universal
// (iss-39); the spec-store checks (spec_lifecycle, spec_id_unique) still skip an
// exempt file. record_schema is cross-store and never consults this at all.
ExemptPaths []string `json:"exempt_paths"`
// NameRoots are repo-relative directories or files the name gate — the
// banned_tokens whose id carries the `names/` prefix, the public banlist
// layer — reads in addition to Roots. Every text file there is read, not only
// markdown (a script names a project as readily as a page does), and only the
// `names/` family runs: the rest of the family is a writing rule for the
// documentation, and a name ban is about the whole public surface (iss-279).
// exempt_paths and exempt_if_status apply as they do under Roots.
NameRoots []string `json:"name_roots"`
// ExemptIfStatus lists leading-frontmatter status: values that likewise
// exempt a file from the content-authoring checks (e.g. superseded records).
ExemptIfStatus []string `json:"exempt_if_status"`
}
Config is the on-disk record-lint configuration (.abcd/record-lint.json).
func ArmAgentDiff ¶ added in v0.6.8
ArmAgentDiff returns cfg with agent_contract's changelog sub-check pointed at a git revision range. It is the same arming shape as ArmReceiptGate and for the same reason: the sub-check asks whether a CHANGE announced itself, so it needs a diff, and the caller (a CI invocation, `record-lint -agent-diff`) is the one that knows which. It is deliberately NOT a config key — a range read out of the committed file would let a committer point the gate at an empty diff.
Arming only WIDENS the rule: an empty range leaves the changelog sub-check a no-op while the frontmatter and canary sub-checks run either way. The rule's own Enabled flag is untouched, so this cannot switch a disabled rule on. The input cfg is not mutated (the Rules map is copied).
func ArmCitationOverdue ¶
ArmCitationOverdue returns cfg with the citation staleness blocker armed: an entry past the block threshold becomes a BLOCKER finding rather than the warn the commit gate emits.
It follows ArmReceiptGate's shape deliberately. The promotion is the CALLER's decision — a release gate, not the in-tree config — so a repo cannot defang its own release by writing "overdue_severity": "warn" into a committed file, and an ordinary commit is never calendar-blocked (spc-17). What arming does NOT do is enable a rule the repo turned off: promoting a severity is the release gate's business, adopting a rule is the repo's.
func ArmReceiptGate ¶
ArmReceiptGate returns cfg with the receipt_gate rule armed for a release: it is enabled, pointed at the target commit, and its required-gates list is set to the caller's list verbatim. This is how a release runs the gate: the CALLER (a CI workflow) supplies the arming, so the decision to gate, the target commit, and the required-gates list are trust-rooted to the workflow rather than the in-tree, committer-editable config (phase-2 review Finding 2). The caller's list is authoritative even when empty: an empty list clears the gates so checkReceiptGate fails closed, rather than inheriting a config a committer could have shrunk (an argless arming must not silently pick up in-tree gates). The input cfg is not mutated (the Rules map is copied). Other rules are unchanged; the deterministic gates still run alongside.
func LoadConfig ¶
LoadConfig reads and decodes a record-lint config file. The config is a trust boundary: it is a committed, cross-repo-clonable file (a hostile clone can commit .abcd/docs-lint.json as a git mode-120000 symlink), and the read is reachable automatically through the session hooks (ahoy.Detect), so it is guarded exactly like its .abcd/*.json siblings guard.Load and rules.Load — a symlinked config directory or leaf is refused, a FIFO/device leaf returns immediately instead of hanging the open, and an over-cap file is rejected rather than read into an OOM. Error strings stay path-free (iss-29); the os.IsNotExist branch is preserved so callers that default an absent config still work.
func LoadConfigInRoot ¶ added in v0.6.8
LoadConfigInRoot reads and validates a lint config confined to root: every path component is resolved inside root, so a symlinked ancestor cannot walk the read out of the tree, and the leaf is size- and regular-file-guarded the same way LoadConfig's is. Callers that already hold an os.Root for the repo (the site build, for one) use this so their config read matches the ancestor-symlink containment their other reads have, rather than re-opening by absolute path.
func (Config) ArmedChecks ¶ added in v0.10.0
ArmedChecks counts the checks a Lint over this configuration runs: every banned token and every enabled rule. Zero means a lint runs nothing, and a front door must say so rather than report a finding count that implies a check happened (loud-staging; iss-2609150805167646). A disabled rule is inert and is not counted. Every rule a loaded config names is one the lint runs: validateRuleNames refuses any other at load, so a misspelt name cannot be counted here as a check that ran.
type ContestedItem ¶ added in v0.7.0
type ContestedItem struct {
Item string `json:"item"`
Run string `json:"run"`
Path string `json:"path"`
// Standing is every standing id, sorted — the whole fault, not a sample.
Standing []string `json:"standing"`
// Illegible names the standing ids whose record no reader can read. The
// prescribed hand repair — write supersedes_disposition into the records no
// longer meant to stand — is inert on such a record, whose supersession is
// discarded with the rest of its frontmatter, so the reader has to know
// which ones need their frontmatter repaired first (iss-2608300848049813).
Illegible []string `json:"illegible,omitempty"`
}
ContestedItem is one item with more than one standing answer.
type DecisionsAppendReport ¶ added in v0.11.1
type DecisionsAppendReport struct {
// Base and Head are the refs the caller named, for the report's wording.
Base, Head string
// Skipped is non-empty when there was no usable base for this event (an empty
// value, or the all-zeroes placeholder): nothing was checked, and the front
// door says so rather than reading the empty range as a clean one.
Skipped string
// Checked is how many commits base..head held, merges included.
Checked int
// Findings are the violations, every one a blocker.
Findings []Finding
}
DecisionsAppendReport is one run of the gate over a range.
func CheckDecisionsAppend ¶ added in v0.11.1
func CheckDecisionsAppend(root, base, head string) (DecisionsAppendReport, error)
CheckDecisionsAppend runs DA001–DA004 over every commit in base..head of the repository at root, merges included.
base is resolved once, through gitutil.ResolveRangeBase: an empty value or the null object name is a skip (Report.Skipped), and anything that names no commit is an error. Every error is "the gate could not answer" — a repository git cannot read, a shallow checkout, a ref that resolves to nothing or is option-shaped, a git probe that failed, a merge whose bound cannot be anchored — and a front door reports it as its own polarity (exit 2), never as a pass and never as a rule violation.
type Finding ¶
Finding is one lint violation. File is repo-relative; Line is 1-based (0 when the finding is not tied to a specific line, e.g. a missing directory README).
func Lint ¶
Lint runs every enabled check family against the record under repoRoot and returns the findings sorted deterministically. An error is returned only for malformed configuration (e.g. an uncompilable regexp, or a persona_registry roster that is missing, unparsable, or empty); a walkable-but-missing root is skipped, not an error.
func LintAt ¶
LintAt is Lint with the clock supplied by the caller. Only the citation baseline's staleness arithmetic reads it, but it is a parameter rather than a wall-clock read inside the check so the 180- and 365-day boundaries are testable exactly, and so a gate's verdict is a function of its inputs.
func PersonaFindingsInText ¶ added in v0.10.0
PersonaFindingsInText runs the persona_registry rule, exactly as cfg arms it, over one text that sits outside cfg.Roots. The release page is the case: it is written to RELEASE.md at the repository root, which record-lint's roots do not reach (the root cannot be listed there, because a configured root that does not exist is a refusal and the page arrives with the first feature cut). The cut runs this over the rendered page before writing it. A rule that is not armed returns nothing; a roster that cannot be read is an error.
type GateReceipt ¶ added in v0.12.0
type GateReceipt struct {
// Problems is every reason the receipt gate refuses the receipt; empty is
// a PROMOTE the gate accepts.
Problems []Finding
// Parsed reports that a receipt naming the commit was read and parsed, so
// Verdict and Failing are the receipt's own.
Parsed bool
Verdict string
Failing []ReceiptFinding
}
GateReceipt is what CheckGateReceipt read for one gate at one commit.
func CheckGateReceipt ¶ added in v0.12.0
func CheckGateReceipt(repoRoot, receiptsDir, commit, gate string) (GateReceipt, error)
CheckGateReceipt runs the receipt gate for one gate against commit, reading receipts under receiptsDir (repo-relative, laid out <dir>/<commit>/<gate>.json).
type IndexSpec ¶
type IndexSpec struct {
// ID names the region: the document fences it with `<!-- index: <id> -->`
// and `<!-- /index -->`.
ID string `json:"id"`
// Doc is the enumerating document, repo-relative.
Doc string `json:"doc"`
// Dir is the enumerated directory, repo-relative. In absent mode it is the
// base each listed path resolves against.
Dir string `json:"dir"`
// Entry is the regexp a backticked token in the region must match to count as
// an entry. It is what keeps the rule off the prose around the list: a token
// the pattern does not describe (a flag, a tool name) is not an entry.
Entry string `json:"entry"`
// DirEntry is the mirror of Entry on the directory side: the regexp a file's
// stem must match to be an entry, reduced to submatch 1 when the pattern has a
// group. It is what lets a document enumerate records by IDENTITY rather than
// by filename — `itd-8` for `itd-8-with-code-bundling.md` — without a second
// rule: without it the two sides can only agree when the document transcribes
// whole slugs, which is a listing nobody writes by hand. Empty compares whole
// stems.
DirEntry string `json:"dir_entry"`
// Suffix is the file extension an exact index enumerates (".md" lists file
// stems); empty enumerates the directory's immediate subdirectories.
Suffix string `json:"suffix"`
// Mode is "exact" (default — the listing and the directory must agree) or
// "absent" (every listed path must NOT exist, the planned-seams shape).
Mode string `json:"mode"`
}
IndexSpec is one index_drift pair — a hand-written enumeration of a directory's contents, and the directory it must agree with.
type IntentLink ¶
type IntentLink struct {
// ID is the intent id (itd-N), taken from the frontmatter when well-formed
// and from the filename otherwise.
ID string
// Bucket is the lifecycle directory holding it (drafts, planned, shipped,
// disciplines, superseded), or "" for a file outside a known bucket.
Bucket string
// Path is the record's repo-relative path.
Path string
// SpecID is the raw spec_id frontmatter value (which may be a YAML null).
SpecID string
}
IntentLink is one intent record as the link index sees it: which bucket holds it (the lifecycle state, because directory-as-truth) and which spec it names.
type OpenHold ¶ added in v0.7.0
type OpenHold struct {
Item string `json:"item"`
Disposition string `json:"disposition"`
ExitCondition string `json:"exit_condition"`
Path string `json:"path"`
}
OpenHold is one standing `held` disposition, rendered with the exit condition that is the only thing distinguishing a hold from a parking space.
type OutstandingItem ¶ added in v0.7.0
type OutstandingItem struct {
Item string `json:"item"`
Run string `json:"run"`
Path string `json:"path"`
}
OutstandingItem is one reading item nobody has answered.
type OutstandingReadings ¶ added in v0.7.0
type OutstandingReadings struct {
Undispositioned []OutstandingItem `json:"undispositioned"`
// Unadmitted names widening PROPOSALS that are neither admitted nor declined
// (spc-67). The widening position's answer set is wider than a disposition —
// an admission record carrying its grounds answers a proposal, and so does a
// decline — so the same question needs one more branch here rather than a
// parallel rule beside it: two rules asking one question diverge, and the
// first divergence between them is silent.
//
// Acceptance at the widening position IS admission, so an accepted proposal
// with no admission record is an admission whose grounds were never written.
// That is the case this leg exists for: uniform adoption of everything a
// reading proposes is equally consistent with careful judgement and with
// abdication, and only the grounds tell the two apart.
Unadmitted []OutstandingItem `json:"unadmitted,omitempty"`
OpenHolds []OpenHold `json:"open_holds"`
// Unsafe names the repo-relative directories the walk declined to enter
// because they are not real directories. core/capture REFUSES these outright,
// because its read is followed by a write; this walk is genuinely read-only,
// so it declines and SAYS SO instead. Going quiet is the thing it must not do:
// a tree nobody walked looks exactly like a tree with nothing in it, and "no
// outstanding items" is the one answer this report must never give by
// accident.
Unsafe []UnsafePath `json:"unsafe,omitempty"`
// Cyclic names items whose dispositions supersede one another, so every
// answer is retired and none stands. It is a ledger fault, not an unanswered
// item: reporting it as outstanding would be a confident wrong statement about
// an item that has been answered twice, and would invite exactly the fresh
// uncited answer the write path refuses.
Cyclic []OutstandingItem `json:"cyclic,omitempty"`
// Contested names items on which more than one disposition stands. It is not
// an exotic state: two branches each answer an item, both merge without
// conflict, and neither cites the other. Picking the first by id resolved that
// silently — an `accepted` sorting first hid a `held` and its exit condition,
// and no line said two answers stood. The report names every standing id and
// resolves nothing, because which answer is in force is the researcher's
// judgement and there is nothing here to make it from.
Contested []ContestedItem `json:"contested,omitempty"`
// Unreadable names items whose SOLE standing answer is a record no reader can
// read. Such a record has no state, so it matched none of the report's cases
// and the item simply vanished from the board — and an item whose only answer
// is unreadable is the case most in need of a line, not least.
Unreadable []UnreadableAnswer `json:"unreadable,omitempty"`
// WideningRuns is the per-run answer count of every widening run whose
// answers the walk could read, ordered by run.
WideningRuns []WideningRun `json:"widening_runs,omitempty"`
}
OutstandingReadings is the whole report, ordered deterministically.
func ReadReadingOutstanding ¶ added in v0.7.0
func ReadReadingOutstanding(repoRoot, issuesDir string) (OutstandingReadings, error)
ReadReadingOutstanding builds the report from the ledger at issuesDir (repo-relative). It is exported because the report has two surfaces — the lint findings and the bare capture status board — and two implementations of one question would be two answers to it. An absent readings tree is not an error: a repository that has commissioned no reading is in a state, not a fault.
func (OutstandingReadings) Empty ¶ added in v0.7.0
func (r OutstandingReadings) Empty() bool
Empty reports whether there is nothing outstanding — the ordinary state of a repository that has commissioned no reading, and the state a surface renders as silence rather than as a heading with nothing under it.
type PrincipleStatement ¶ added in v0.11.1
type PrincipleStatement struct {
// Title is the H1 title, ATX with any closing hashes removed or setext with
// its lines joined, and TitleLine its first 0-based line; TitleLine is -1
// when the document carries no H1.
Title string
TitleLine int
// Start and End bound the paragraph's lines, [Start, End), 0-based, the
// label still on the first.
Start, End int
}
PrincipleStatement is where a principle's statement sits in its document: the H1 title and the `**The rule.**` labelled paragraph, and nothing else. A `## The rule` heading is NOT a statement (iss-2609261039132350): a principle has one heading, its H1, and a section would carry everything under it, the reasons and the bounds included.
It is the one derivation of the statement. The reading assembler projects it and principle_claims judges it, and two readers deriving it separately are how a gate came to judge a paragraph while the projection sent a title above it (iss-2609261039134673).
func FindPrincipleStatement ¶ added in v0.11.1
func FindPrincipleStatement(lines []string) (PrincipleStatement, bool)
FindPrincipleStatement locates a principle's statement in its lines (the whole document, frontmatter included). ok is false when the document carries no live `**The rule.**` paragraph, whatever headings it has.
type ProseBaseline ¶ added in v0.9.0
type ProseBaseline struct {
SchemaVersion int `json:"schema_version"`
IDs []ProseBaselineEntry `json:"ids"`
}
ProseBaseline is the committed record of ids the gate carries.
type ProseBaselineEntry ¶ added in v0.9.0
type ProseBaselineEntry struct {
// ID is the canonical handle (lower-case family, unpadded number).
ID string `json:"id"`
// Class is one of proseBaselineClasses.
Class string `json:"class"`
// Note says why this id does not resolve, in the author's words. Required:
// the baseline is a ruling, and a ruling with no reasoning is an allowlist.
Note string `json:"note"`
}
ProseBaselineEntry is one carried id and the ruling that carries it.
type ProseCitation ¶ added in v0.11.1
ProseCitation is one record id a line of prose cites that the rule refuses: it names no record, the baseline does not carry it, and its line carries no escape marker. Line is 1-based.
func UnresolvedProseCitationsInRecord ¶ added in v0.11.1
func UnresolvedProseCitationsInRecord(repoRoot, rel, text string) ([]ProseCitation, error)
UnresolvedProseCitationsInRecord is UnresolvedProseCitationsInText under the repository's own record-lint configuration. A repository with no configuration gates nothing, and the answer is empty; a configuration that cannot be read is an error, since the question cannot then be answered.
func UnresolvedProseCitationsInText ¶ added in v0.11.1
func UnresolvedProseCitationsInText(cfg Config, repoRoot, rel, text string) ([]ProseCitation, error)
UnresolvedProseCitationsInText runs prose_citation_resolves over text a writer is about to put into the record at rel, BEFORE it is written: the one resolver, the committed baseline and the line escape marker, read exactly as the gate reads them. A writer composing a record from a host-delegated payload asks this first, because a payload the writer accepts must never produce a record the gate then refuses (iss-2609231036448320). A configuration that does not arm the rule, or whose record stores do not hold rel, gates nothing, and the answer is empty. text is a fragment of a record body, never its frontmatter.
type ReceiptCheck ¶ added in v0.11.0
type ReceiptCheck struct {
Gate ReleaseGate `json:"release_gate"`
// Released is HEAD, the commit the derivation reads the receipts tree of.
Released string `json:"released,omitempty"`
// Commit is the content commit the receipts must name: the one derived from
// the receipts directory, or — when no receipts directory names a commit on
// this lineage — HEAD, the roll commit a first receipt must name.
Commit string `json:"commit,omitempty"`
// Derived reports that Commit came from the release job's derivation. When
// false the release job's derive step itself refuses, and DeriveError is its
// reason.
Derived bool `json:"derived"`
DeriveError string `json:"derive_error,omitempty"`
// Problems is every refusal the gate would raise, one per gate.
Problems []ReceiptProblem `json:"problems"`
// Uncommitted lists working-tree changes under the receipts directory. The
// release job reads the committed tree, so a receipt that exists only here
// would pass locally and be missing there: any such change refuses.
Uncommitted []string `json:"uncommitted,omitempty"`
// Pass is the verdict: exactly when the release job's receipt gate admits
// the same repository state.
Pass bool `json:"pass"`
}
ReceiptCheck is the local verdict of the release job's receipt gate.
func CheckReleaseReceipts ¶ added in v0.11.0
func CheckReleaseReceipts(root string) (ReceiptCheck, error)
CheckReleaseReceipts runs the release job's receipt gate against root's HEAD, locally. It is the release job's reader, not a model of it: the same derivation, the same arming and the same check, with the required gates read from the committed release workflow. A workflow that arms no gate passes with nothing required, exactly as the release job has no gate step to fail.
type ReceiptFinding ¶ added in v0.12.0
type ReceiptFinding struct {
Disposition string `json:"disposition"`
// Doc is "brief" or "public": which document the sentence stands in. A
// public-doc sentence is reported and never refuses in this rung.
Doc string `json:"doc,omitempty"`
Chapter string `json:"chapter,omitempty"`
Sentence string `json:"sentence,omitempty"`
Evidence string `json:"evidence,omitempty"`
// Replacement is the reviewer's drafted correction of Sentence, which
// `abcd docs fidelity --apply` writes into the chapter and flags.
Replacement string `json:"replacement,omitempty"`
}
ReceiptFinding is one entry of a receipt's failing list. The release gate reads its Disposition only; the doc-fidelity gate (itd-60) also reads the sentence a reviewer found false, where it stands, and the evidence, so a refusal can name the sentence rather than a count.
type ReceiptProblem ¶ added in v0.11.0
type ReceiptProblem struct {
Gate string `json:"gate,omitempty"`
Path string `json:"path"`
Message string `json:"message"`
}
ReceiptProblem is one reason the receipt gate refuses: the gate it concerns ("" for a refusal of the arming itself), the receipt path it expected, and the release job's own message, which names the commit the receipt must name.
type RecordEdge ¶
type RecordEdge struct {
From string `json:"from"`
To string `json:"to"`
Field string `json:"field"`
}
RecordEdge is one typed reference: the record that declares it, the handle it names, and the frontmatter field it was read out of. The field is kept rather than collapsed into a relation name because the same relation is spelled from both ends (an intent's `spec_id` and a spec's `intent` are one link) and only the consumer knows whether it wants them folded.
type RecordGraph ¶
type RecordGraph struct {
Nodes []RecordNode `json:"nodes"`
Edges []RecordEdge `json:"edges"`
Dangling []RecordEdge `json:"dangling"`
// Retired are the ids some record declares it superseded, bounded by each
// store's allocation high-water mark exactly as the rule bounds them. The
// ADR lifecycle prunes a superseded file and keeps the trace in its
// successor's `supersedes`, so a handle naming a retired id is accounted for
// even though no file answers to it — and a consumer counting unresolved
// references needs that distinction to avoid reporting the record's own
// bookkeeping as breakage.
Retired []string `json:"retired"`
}
RecordGraph is the whole corpus: every record, every typed reference that resolves to one, and every reference that names a record no file carries.
func LoadRecordGraph ¶
func LoadRecordGraph(cfg Config, repoRoot string) (RecordGraph, error)
LoadRecordGraph reads every configured record store once and returns the corpus as a graph. It is the record_schema rule's scan, exported: cfg is the same lint configuration the rule runs from, and a store the configuration does not name (or whose directory is absent) contributes nothing, exactly as it contributes no findings.
The result is fully ordered — nodes by store then id number, edges by their two endpoints and field — so a caller that serialises it gets the same bytes from the same tree.
type RecordNode ¶
type RecordNode struct {
// ID is the record's prose handle (adr-47, itd-135, spc-38, iss-100).
ID string `json:"id"`
// Type is the store's name: adr, intent, spec, issue.
Type string `json:"type"`
// Lifecycle is the bucket directory the record sits in (drafts, planned,
// shipped, open, resolved …). It is empty for a flat store, whose records
// carry their state in frontmatter rather than in a directory.
Lifecycle string `json:"lifecycle"`
// Title is the record's H1, or its first body line where the store's records
// carry no heading, or the handle where the file is empty.
Title string `json:"title"`
// Path is the record file, repo-relative and slash-separated.
Path string `json:"path"`
// Date is the frontmatter `date` where the record carries one, else empty.
// A record without one is dated from git by the consumer, not here.
Date string `json:"date,omitempty"`
// Status, Kind and Severity are the frontmatter fields the stores use to
// grade a record, carried where present and empty where not.
Status string `json:"status,omitempty"`
Kind string `json:"kind,omitempty"`
Severity string `json:"severity,omitempty"`
}
RecordNode is one record in the corpus.
type ReleaseGate ¶ added in v0.11.0
type ReleaseGate struct {
// Workflow is the repo-relative path that was read.
Workflow string `json:"workflow"`
// Present reports that the workflow exists.
Present bool `json:"present"`
// Armed reports that the workflow runs the receipt gate at all. A workflow
// with no semantic gate configured runs none, and the deterministic gates
// alone admit its releases.
Armed bool `json:"armed"`
// Gates are the required gate names, in the order the workflow lists them.
Gates []string `json:"required_gates"`
}
ReleaseGate is what a repository's release workflow arms its receipt gate with, read from the committed workflow.
func ReadReleaseGate ¶ added in v0.11.0
func ReadReleaseGate(root string) (ReleaseGate, error)
ReadReleaseGate reads the receipt-gate arming out of root's release workflow. Comment lines are skipped, so prose describing the gate never arms it. An absent workflow is not an error: it arms nothing, and Present says so.
type RuleConfig ¶
type RuleConfig struct {
Enabled bool `json:"enabled"`
Severity string `json:"severity"`
// Fields is the no_git_metadata banned frontmatter key list.
Fields []string `json:"fields"`
// Exempt is a glob allowlist of repo-relative paths (filepath.Match, so `*`
// stays inside one directory). directory_coverage reads it for directories
// excused a README; links_resolve reads it for files whose links are not
// checked — a tool-mandated mirror of a root file, whose relative links
// resolve from the root and not from the mirror's directory — and over its
// ExtraRoots, for files whose links the extra walk skips.
Exempt []string `json:"exempt"`
// ExtraRoots are repo-relative trees links_resolve walks for links ALONE,
// beyond Roots: the working tier (.abcd/work) holds relative links in the issue
// ledger, DECISIONS.md and CONTEXT.md, and adding it to Roots would arm every
// content rule there too (iss-2608230752354927). harness_leak reads its own
// ExtraRoots the same way, for the leak class alone: the ledger is committed
// free text outside the record's Roots (iss-2608301306580014).
ExtraRoots []string `json:"extra_roots"`
// IntentsDir is the intents subdirectory (relative to a root) read by the
// intent-tree rules, intent_lifecycle and intent_impact_valid. Rules that name
// the same directory share one scan of it. spec_lifecycle also reads it to
// resolve the intent corpus its specs link to.
IntentsDir string `json:"intents_dir"`
// SpecsDir is the spec_lifecycle specs subdirectory (relative to a root),
// mirroring IntentsDir. Default "specs".
SpecsDir string `json:"specs_dir"`
// IssuesDir is the issue-ledger root (repo-relative) read by the ledger rules,
// issue_id_unique and issue_impact_valid; it holds the open/, resolved/, and
// wontfix/ status directories. Default .abcd/work/issues. It lies outside Roots
// — the rules read the ledger and run once, sharing one scan of it.
// reading_outstanding reads the same root's SIBLING families (readings/,
// dispositions/), which is why they are named relative to it rather than
// configured twice.
IssuesDir string `json:"issues_dir"`
// Allowlist is the stray_root_docs permitted basename-stem list (upper-cased,
// extension-stripped) for top-level markdown files.
Allowlist []string `json:"allowlist"`
// Registry is a rule's registry file, repo-relative. For persona_registry it
// is the persona roster (.abcd/development/personas.json); for
// surface_coverage it is the brief surface table
// (.abcd/development/brief/04-surfaces/README.md); for glossary_family_pointer
// and record_family_key it is the record-families page whose table is the
// closed set of families (default <glossary_dir>/core/record-families.md).
Registry string `json:"registry"`
// CommandsDir is the surface_coverage plugin-command directory (commands);
// each *.md file (README and BareCommand excepted) is a shipped command
// surface. It lies outside Roots — the rule reads the surface tree and
// cross-checks the brief. The directory is flat: a harness maps a
// subdirectory of it to an extra namespace segment, so a file one level down
// registers as /<plugin>:<dir>:<verb> rather than the documented
// /<plugin>:<verb>.
CommandsDir string `json:"commands_dir"`
// BareCommand is the CommandsDir file stem that backs the plugin's BARE
// top-level command rather than a /<plugin>:<verb> surface — for abcd, the
// `abcd.md` whose registry row is the bare `/abcd`. It is excluded from the
// command-surface set the way README is, because the registry names it
// without a sub-verb and matching it by name would demand a row that cannot
// exist. Empty means the plugin has no such file.
BareCommand string `json:"bare_command"`
// SkillsDir is the surface_coverage skills directory (skills); each immediate
// subdirectory is a shipped skill surface. Also outside Roots.
SkillsDir string `json:"skills_dir"`
// Snapshot is the committed command-tree snapshot surface_coverage's
// sub-verb pass checks table rows against (spc-27), repo-relative — for
// abcd, .abcd/development/release/surface.json, whose bytes the surface
// drift test keeps equal to the live cobra tree. Empty leaves the sub-verb
// grain unarmed (the pre-spc-27 surface-grain check only).
Snapshot string `json:"snapshot"`
// HostDelegated lists surfaces whose workflow runs in the host agent with
// no Go verb (consult, ingest, prepare-this-repo): their sub-verb tables
// are format-checked only, never compared to the cobra tree. Explicit
// config, never a hard-coded skip — an unlisted surface gets the full
// comparison.
HostDelegated []string `json:"host_delegated"`
// OperatorInternal lists top-level verbs absent from the surface registry
// by design (spec, rules, hook, completion — operator plumbing, not
// product surface): the sub-verb reverse sweep does not demand a surface
// file for them. Explicit config, same rationale as HostDelegated.
OperatorInternal []string `json:"operator_internal"`
// Target is the context_status_free single-file target, repo-relative
// (.abcd/work/CONTEXT.md). The rule runs even though the target lies outside
// Roots; a missing target is not an error.
Target string `json:"target"`
// Patterns is the context_status_free line-match regexp list; when empty the
// rule falls back to contextStatusDefaultPatterns.
Patterns []string `json:"patterns"`
// Section is the context_citation_currency heading matcher: the rule reads only
// the section of Target whose heading matches (the sharp-edges list), because a
// citation to a terminal record is legitimate everywhere else. Empty falls back
// to defaultContextSection.
Section string `json:"section"`
// ReceiptsDir is the receipt_gate directory of sha-keyed semantic-pass
// receipts (VSA-shaped JSON), repo-relative (default .abcd/work/reviews).
// Outside Roots.
ReceiptsDir string `json:"receipts_dir"`
// RequiredGates lists the semantic gates that must each have a PROMOTE receipt
// for the target commit before a release (e.g. docs-currency-reviewer,
// iss35-brief-surface-crosscheck).
RequiredGates []string `json:"required_gates"`
// Commit is the receipt_gate target commit sha whose receipts are verified.
// Release-time input (release.yml supplies the tagged commit); empty while the
// rule is disabled for ordinary development.
Commit string `json:"commit"`
// Runbook is the gate_lockstep runbook path (its numbered "Deterministic
// gates" list), repo-relative.
Runbook string `json:"runbook"`
// Workflow is the gate_lockstep CI workflow path — the source of truth for the
// deterministic gate list, repo-relative.
Workflow string `json:"workflow"`
// Job is the gate_lockstep workflow job whose step names are the gate list.
Job string `json:"job"`
// IgnoreSteps are workflow step names that are setup, not gates, and so are
// excluded from the lockstep comparison.
IgnoreSteps []string `json:"ignore_steps"`
// MinGates is the gate_lockstep non-empty floor: each side must parse at least
// this many gates or the rule fails closed (an under-count means the parser or
// a heading/job rename silently dropped gates). It is the safety net that makes
// the hand-parse fail-closed. Enforced as at least 1 when the rule is enabled.
MinGates int `json:"min_gates"`
// GlossaryDir is the forbidden_synonyms (GL002) glossary directory, repo-relative
// (default .abcd/development/brief/glossary). The rule walks it for term files and
// reads each term's forbidden_synonyms frontmatter list — the glossary is the
// single source of truth for what a forbidden synonym is. glossary_family_pointer
// and record_family_key read the same directory's term files.
GlossaryDir string `json:"glossary_dir"`
// Enforce is the forbidden_synonyms subset that GL002 mechanically gates. Each
// entry MUST be declared as a forbidden_synonym by some glossary term (the rule
// errors otherwise, so the config can never gate a word the glossary does not
// forbid). Enforcement is a deliberate subset because most forbidden synonyms
// ("user", "release", "project", "feature", ...) are common English words whose
// live-prose false-positive rate blows the detector's budget; "epic" is the
// mechanically-clean member (itd-43). Promotion path: add a synonym here once the
// corpus is swept clean of its non-substituting uses.
Enforce []string `json:"enforce"`
// ExemptPrefixes are repo-relative path prefixes whose files GL002 skips — the
// historical, git-tracked records the rename intent (itd-43 AC1) exempts:
// research/, decisions/ (dated ADRs), plans/ (dated), shipped/superseded intents,
// the issue ledger, and review records. The glossary directory itself is always
// exempt (a term file names its own forbidden synonyms legitimately).
ExemptPrefixes []string `json:"exempt_prefixes"`
// AllowContext lists regexps that, if any matches a line, suppress every GL002
// finding on that line — the legitimate-mention escape (naming the old token in an
// external reference like `epic-review`, or the rename itself `epic->spec`).
AllowContext []string `json:"allow_context"`
// CrosswalkHeading is the citation_crosswalk_rows heading matcher: a table is
// judged a crosswalk only when its nearest preceding heading matches this
// regexp. Default defaultCrosswalkHeading. Keying on the heading rather than on
// table shape is what keeps the rule off every ordinary table in the corpus.
CrosswalkHeading string `json:"crosswalk_heading"`
// RefusedDomains is the citation_source_policy list of aggregator domains a
// citation may not point at. Matching is host-normalised (case-folded, www.
// dropped) and covers subdomains. It ships EMPTY: naming a domain is a
// project's editorial policy, never something the gate invents for it.
RefusedDomains []string `json:"refused_domains"`
// Baseline is the citation_baseline record's repo-relative path. Default
// DefaultBaselinePath.
Baseline string `json:"baseline"`
// WarnAfterDays is the citation_baseline staleness warn threshold in days
// (spc-17: 180). Zero means the default.
WarnAfterDays int `json:"warn_after_days"`
// BlockAfterDays is the age at which an entry becomes OVERDUE and is reported
// under the citation_baseline_overdue rule id (spc-17: 365). Zero means the
// default.
BlockAfterDays int `json:"block_after_days"`
// OverdueSeverity is the severity of a citation_baseline_overdue finding. It
// defaults to warn because the COMMIT gate never calendar-blocks (spc-17);
// the release gate is what promotes it to a blocker.
OverdueSeverity string `json:"overdue_severity"`
// RecordStores are the record_schema stores: the repo-relative directory of
// each identified record store, keyed by id prefix (adr, itd, spc, iss). The
// rule reasons ACROSS the stores, which straddle Roots (the issue ledger is
// working-tier, the rest is the design record), so each is named repo-relative
// here. An unnamed or absent store contributes nothing. Only the LOCATIONS are
// configurable — which lifecycle buckets each store declares is the record's
// schema and lives in code, so a config can never quietly add or hide one.
RecordStores map[string]string `json:"record_stores"`
// Indexes are the index_drift pairs: each names a marked region in a document
// and the directory that region enumerates. The rule reads documents outside
// Roots (a package or command README lives beside its code), so the pairs are
// declared here rather than discovered by the walk.
Indexes []IndexSpec `json:"indexes"`
// Changelog is the delivery_state changelog, repo-relative. Default
// "CHANGELOG.md". It sits at the repo root, outside Roots.
Changelog string `json:"changelog"`
// IntentsRoot is the delivery_state intents store, repo-relative — the whole
// store, not a subdirectory of a root, because the rule resolves a cited id to
// the lifecycle bucket holding it and the changelog it reads is repo-scoped.
// Default .abcd/development/intents.
IntentsRoot string `json:"intents_root"`
// DeliverySections are additional changelog change-type headings delivery_state
// reads as delivery claims. They are UNIONED with deliveryStateSections, never
// substituted for them: a repo names its own headings here to widen the gate,
// and a config that could narrow it could silently disarm it.
DeliverySections []string `json:"delivery_sections"`
// AgentsDir is the agent_contract prompt tree, repo-relative (default
// "agents"). It lies outside Roots — an agent prompt is not a record, so the
// rule walks the tree itself rather than the tree being added to Roots and
// judged by the record stores' schema.
AgentsDir string `json:"agents_dir"`
// DiffRange is the agent_contract changelog sub-check's git revision range.
// It is supplied by the CALLER (ArmAgentDiff, from a CI invocation) rather
// than read out of the in-tree config, for the reason ArmReceiptGate states:
// the decision to check a diff, and which diff, is trust-rooted to the
// workflow, not to the committer-editable file. Empty makes the sub-check a
// no-op — there is no diff to make a statement about.
DiffRange string `json:"-"`
// contains filtered or unexported fields
}
RuleConfig is the shared shape for the non-token check families. Only the fields relevant to a given rule are populated.
type SpecLink ¶
type SpecLink struct {
// ID is the spec id (spc-N) from frontmatter, "" when malformed or absent.
ID string
// Bucket is the lifecycle directory holding it: "open" or "closed".
Bucket string
// Path is the spec's repo-relative path.
Path string
// IntentID is the raw intent frontmatter value — the back-link.
IntentID string
// Intents is the raw `intents:` list a bundle's shared spec carries: every
// member it realises, the first being IntentID (itd-34). Empty on an
// ordinary spec.
Intents []string
// contains filtered or unexported fields
}
SpecLink is one spec record as the link index sees it. The unexported fields carry what the spec-lifecycle lint needs from the same read — the frontmatter with its line numbers, and whether the file is content-exempt — so the tree is walked once for both consumers.
type SpecLinkIndex ¶
type SpecLinkIndex struct {
Intents []IntentLink
Specs []SpecLink
}
SpecLinkIndex is ONE traversal of the intent buckets and the spec store, shared by every consumer that must reason about the intent↔spec link.
It exists because two consumers ask opposite questions of the same two trees. spec_lifecycle walks the specs and asks whether each names an intent that agrees with it; the release cut walks the intents and asks whether any still sitting in planned/ has no OPEN spec left — a merged feature whose record never moved, which is invisible to the shipped/-tree diff and would silently under-bump the release. Two walks would be two answers about one tree, so there is one scan and two readings of it — and since an intent owns one or more specs (adr-2609151513118583), both readings derive that set through SpecsForIntent rather than each resolving a scalar of its own.
func ScanSpecLinks ¶
func ScanSpecLinks(repoRoot, intentsDir, specsDir string, top Config) (SpecLinkIndex, error)
ScanSpecLinks reads the intent buckets and the spec store once, both relative to repoRoot. A missing tree contributes nothing and is not an error, mirroring the rest of the record lint: an unpopulated repository is a state, not a fault. A tree that is present but cannot be read IS a fault and is returned: both halves fail closed, so no consumer ever reads an index that says "nothing here" about records it merely failed to open.
top supplies the content exemptions. They are recorded per spec rather than applied here, because they exempt a file from the lint's CONTENT checks — they do not mean the record stopped existing, which is the only thing the release cut asks about.
func (SpecLinkIndex) IntentSpecID ¶
func (x SpecLinkIndex) IntentSpecID() map[string]string
IntentSpecID maps each known intent id to its raw spec_id value.
func (SpecLinkIndex) KnownIntents ¶
func (x SpecLinkIndex) KnownIntents() map[string]bool
KnownIntents is the set of intent ids present anywhere in the corpus.
func (SpecLinkIndex) SpecBucket ¶
func (x SpecLinkIndex) SpecBucket(specID string) (string, bool)
SpecBucket resolves a spec_id value to the lifecycle bucket holding that spec.
Matching is on the spec NUMBER, not the literal string, because a spec_id is written both bare (`spc-9`) and with its slug (`spc-9-thing`) across the record; comparing literals would silently fail to resolve half the corpus and make a fail-closed gate fail open.
func (SpecLinkIndex) SpecsForIntent ¶ added in v0.9.0
func (x SpecLinkIndex) SpecsForIntent(intentID string) []SpecLink
SpecsForIntent returns every spec whose back-link names the given intent.
An intent owns one or more specs (adr-2609151513118583, invariant 17), and the spec's own `intent:` field is the source of truth for that link: nothing on the intent side carries a set. Every consumer of this index that must reason about the whole set — the bidirectional check, and the release cut's stale-intent question — derives it here, so there is one answer to "which specs realise this intent".
Matching is canonical on both sides, so a zero-padded spelling on either side resolves. It goes through recordid.SameID — the SAME primitive the spec store compares with — rather than a private canonicaliser, because this index and that store answer one question ("which specs realise this intent") for two callers, and two implementations of one question are two answers waiting to diverge. SameID also fails closed where the private form did not: a value that is not a record id at all (`intent: null`) matches nothing, so two unresolvable back-links no longer group into one pseudo-intent.
type SupersessionLink ¶ added in v0.12.0
type SupersessionLink = struct{ ID, Bucket, SupersededBy string }
SupersessionLink is one intent as a supersession chain reads it: its id, the bucket it sits in, and the successor its `superseded_by` names. It aliases the same unnamed struct intent.ChainLink does, so intent.SupersessionChainOf registers here as it is.
type TokenChecker ¶
type TokenChecker struct {
// contains filtered or unexported fields
}
TokenChecker is a compiled banned-token set, ready to run over text.
func NewTokenChecker ¶
func NewTokenChecker(tokens []BannedToken) (*TokenChecker, error)
NewTokenChecker compiles a configuration's banned_tokens. It refuses the same entries `LintAt` refuses, on the same compile, so a caller cannot arm a set the gate itself would not load.
func (*TokenChecker) Len ¶
func (tc *TokenChecker) Len() int
Len reports how many bans are armed. A checker with none is inert, and a caller that would otherwise walk a whole tree to find nothing can say so.
func (*TokenChecker) LintComposed ¶
func (tc *TokenChecker) LintComposed(name, text string, fenced bool, source []string) []Finding
LintComposed lints text that has been LIFTED out of a source file — a span the website selected and rendered — and so no longer carries the source's line structure, its fence markers, or its line-level allow comments.
The escape has to keep working across that lift, or every ban would harden silently the moment its text was composed. `source` is the source file's own lines, and a match is exempt when some source line both CONTAINS the matched text and carries the token's allow context: the same line-level judgement the file walk makes, made about the line the composed text actually came from.
`fenced` says whether the text was rendered as a code block, so a ban that skips code fences in a file skips it here for the same reason. It is a parameter rather than something read back out of the text because composed text HAS no fence markers: looking for them would find a backtick that is content and silently stop checking from there, which is a gate passing by not looking.
Passing a nil `source` is the strict reading — no line can grant an escape — which is what a caller with no source to point at should get.
type UnreadableAnswer ¶ added in v0.7.0
type UnreadableAnswer struct {
Item string `json:"item"`
Run string `json:"run"`
Path string `json:"path"`
Disposition string `json:"disposition"`
}
UnreadableAnswer is one item whose standing disposition cannot be read.
type UnsafePath ¶ added in v0.7.0
UnsafePath is one path the walk declined to read, with the reason it declined. The reason travels with the path because one line served every failure and was false for most of them: an oversized or permission-refused REGULAR FILE was described as "not a real directory", which sends the reader to look for a symlink that is not there.
type WideningRun ¶ added in v0.11.1
type WideningRun struct {
Run string `json:"run"`
Items int `json:"items"`
Admitted int `json:"admitted"`
Declined int `json:"declined"`
Held int `json:"held"`
// Outstanding names the proposals carrying neither an admission nor a
// `declined` or `held` disposition, sorted. Never null.
Outstanding []string `json:"outstanding"`
}
WideningRun is one widening run's answer count (spc-2609020626040342): how many proposals it returned, how many were admitted, declined and held, and which carry neither an admission nor a `declined` or `held` disposition. It makes the admitted-against-declined count — the evidence that the admission asymmetry is being exercised — a query rather than an inspection.
It is reported only for a run whose every widening item's answer the walk could read without ambiguity. A run holding an unreadable item, an unreadable admission, an answer the walk declined to read, or a contested, cyclic or illegible disposition supports no count, so its summary stands down; the report's other lists already name what stood in the way.
Source Files
¶
- adridunique.go
- agentcontract.go
- baseline.go
- briefflags.go
- citations.go
- citesummary.go
- collect.go
- config.go
- contextcurrency.go
- crossstore.go
- decisionsappend.go
- deliverystate.go
- edges.go
- gatereceipt.go
- graph.go
- guardedread.go
- harnessleak.go
- indexdrift.go
- intentsota.go
- linkanchors.go
- linksextra.go
- lint.go
- persona.go
- principles.go
- prosecitations.go
- provenance.go
- readingoutstanding.go
- recordfamilies.go
- releasegate_derive.go
- releasereceipts.go
- schema.go
- schema_bundle.go
- schema_target.go
- speclinks.go
- subverbs.go
- textlint.go
- tiers.go
- unreleased.go