Documentation
¶
Overview ¶
Package recordid is abcd's canonical home for the record-id space: the native timestamp-numeric mint (mint.go), the read-side resolver (resolve.go), and the one record-filename grammar both sides parse (this file).
THE MINT (adr-45; mechanics per spc-33): every minting family allocates <family>-<yymmddHHMMSS><4 random digits> through Minter.Mint — time-ordered, coordination-free, offline, and reading no maximum anywhere, so two minters sharing a stale view, or two current checkouts sharing the same view, can never converge on one id. Captures (iss), intents (itd), specs (spc), the reading families and the scope-condition markers all mint this way; a family adopts the seam by holding a Minter and naming its family tag, never by carrying an allocator of its own (adr-45 ruling 3). ADRs keep their hand-numbered zero-padded filename ordinal, ruled at its own turn.
The armed record-lint uniqueness rules (issue_id_unique, intent_lifecycle, spec_id_unique) stay as the scheme's fail-safe — the cheap assertion that the scheme held — never the primary defence (adr-45 ruling 5).
Index ¶
- Variables
- func FilenameNumRe(prefix string) *regexp.Regexp
- func SplitRecordFilename(family, name string) (id, slug string, ok bool)
- func ValidIntentID(id string) bool
- func ValidReadingItemID(id string) bool
- func ValidReadingRunID(id string) bool
- func ValidSpecID(id string) bool
- type Minter
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var CitedIDRe = regexp.MustCompile(`^(?:adr|itd|iss|spc)-[0-9]+$`)
CitedIDRe is the canonical grammar of a cited record id: one of the four id-bearing family prefixes, a hyphen, and a bare decimal N. It is exported because every ingest boundary that accepts a citation must bound and shape the string BEFORE it is looked up or echoed, and they must all agree on the shape.
Functions ¶
func FilenameNumRe ¶ added in v0.6.8
FilenameNumRe is the canonical record-filename grammar for a prose-handle family (iss/itd/spc): <prefix>-<N>[-<slug>].md, capturing N. It is the ONE grammar the read-side resolver matches, so a second copy in another package would drift and let a gate accept a filename the resolver later refuses when the record is cited. It is exported so record-lint validates each store's filenames against exactly this pattern rather than a looser local copy that accepted an arbitrary tail (iss-2608270908346617).
func SplitRecordFilename ¶ added in v0.6.8
SplitRecordFilename splits a record filename of the given family into the id it claims and the slug segment that follows it. family is the prefix without its hyphen ("iss", "itd", "spc") or "" for the ADR store's zero-padded numeric names; a filename of any other family does not match, so a stray record in a store's directory is not read as one of that store's.
It is the ONE splitter for that question, called by both the ledger reader (core/capture's filename ↔ frontmatter invariants) and the record-lint gate that judges the committed corpus — the same reason ValidIntentID and ValidSpecID live here rather than being restated on each side. Two hand-kept copies would let a record pass the gate and then fail the reader, which is the split this package exists to prevent.
The slug it returns is compared EXACTLY, never as a prefix. Every store applies its length cap while deriving the slug — before that one value forks into the filename and the frontmatter — so a filename is never a truncated form of a longer field, and a prefix tolerance would license the drift the comparison is there to catch.
func ValidIntentID ¶ added in v0.6.7
ValidIntentID reports whether id is a well-formed intent id (itd-N).
func ValidReadingItemID ¶ added in v0.7.0
ValidReadingItemID reports whether id is a well-formed reading item id (rdi-N).
It joins its run-id sibling for the same reason. The ledger writer builds a record filename out of it, and the cold-reading ingest verb's rollback DELETES by it — a delete bounded by a pattern is only as bounded as the pattern, and two copies of one grammar is how the writer and the deleter come to disagree about which files belong to a run.
func ValidReadingRunID ¶ added in v0.7.0
ValidReadingRunID reports whether id is a well-formed reading run id (rdg-N).
It is the THIRD path-building record id, and it joins the two above for their reason rather than getting a fourth copy of the pattern: the reading ledger writer (core/capture) and the cold-reading ingest verb (core/reading) both build a directory name out of a run id that arrives from outside — an ingest's run id comes off an untrusted payload — so a traversal id must be refused by exactly one rule, before either side touches a path.
func ValidSpecID ¶ added in v0.6.7
ValidSpecID reports whether id is a well-formed spec id (spc-N).
Types ¶
type Minter ¶
type Minter struct {
// Now supplies the mint instant; nil means time.Now.
Now func() time.Time
// Entropy supplies the suffix draw; nil means crypto/rand.Reader.
Entropy io.Reader
}
Minter mints native timestamp-numeric record ids. Both fields are seams for tests; the zero value is the production configuration (time.Now and crypto/rand).
func (Minter) Mint ¶
Mint returns a fresh native id for family (e.g. "iss"): the family tag, the UTC second stamp, and a uniform 4-digit suffix. It reads nothing — no ledger, no refs, no maximum — so two minters can never converge on one id by sharing a stale view; only a same-second suffix coincidence remains, which is the armed uniqueness detectors' residue to assert (adr-45 ruling 5).
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is the live record-id set of one repository, read once. It is a snapshot: build it at the start of a validation pass and use it throughout, so every citation in one payload is judged against the same view of the record.
func NewResolver ¶
NewResolver reads repoRoot's record families and returns the resolver over them.
An ABSENT family is not an error — a repository need not carry every store, and its ids simply do not resolve. An unreadable family that IS present IS an error: reporting "this id names no record" when the truth is "the store could not be read" would refuse a correct citation, so the scan fails closed and lets the caller say what actually happened.