recordid

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

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

Documentation

Overview

Package 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 legacy max+1 allocator support this file keeps for the families that have not yet adopted the mint seam.

THE NATIVE MINT (adr-45; mechanics per spc-33): an adopted family mints <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 can never converge on one id. Captures (iss) mint this way; itd/spc adopt the same seam as configuration at their own turn (rollout per adr-45 ruling 3). The armed record-lint uniqueness rules (issue_id_unique, intent_lifecycle, spec_id_unique) stay as the scheme's fail-safe, no longer the primary defence.

THE LEGACY ALLOCATOR (itd/spc until they adopt): every ledger mints "max observed N, plus one". Historically each ledger looked only at ITS OWN WORKING TREE, so two branches cut from the same base silently minted the same next id — invisible on each branch, surfacing only at merge (iss-115, iss-120: two programmes both minted spc-10/spc-11, iss-110/iss-111). MaxAcrossRefs is the one home for the git-ref side of that maximum: it scans every local branch and remote-tracking ref for a family's highest id, so a branch that has ALREADY committed a higher id is seen even though its file is absent from the current working tree. Each remaining ledger keeps its own working-tree scan (which alone sees uncommitted mints) and folds this in — union, then +1. Its residual window — two branches that BOTH mint before either commits — is exactly the mechanism that produced the 2026-08-19/20 collisions (iss-330, the itd-114 field test) and is why the native mint replaces this allocator family by family rather than hardening it.

Index

Constants

This section is empty.

Variables

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

This section is empty.

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

func (m Minter) Mint(family string) (string, error)

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 RefScan

type RefScan struct {
	Max      int
	Degraded bool
	Reason   string
}

RefScan is the outcome of scanning git refs for a family's highest id N.

Max is the best-effort highest N observed (0 when none, or when the scan could not run). Degraded is true when a repository is present but git could not read it (git absent/broken over a real repo) or a ref query failed — in which case Max reflects only what was seen before the failure and the caller mints from the working tree essentially alone, so it MUST surface Warning() rather than fall back silently. A directory that is simply NOT a repository is not degraded (there are no refs to collide against): Max is 0 and Warning() is empty.

func MaxAcrossRefs

func MaxAcrossRefs(repoRoot, prefix string, dirs []string) RefScan

MaxAcrossRefs returns the highest N in filenames of the form <prefix>-<N>[-<slug>].md under any of dirs (repo-relative, slash-separated), across every local branch (refs/heads) and remote-tracking ref (refs/remotes) of the repository at repoRoot.

It NEVER returns an error: a git-absent host, a repoRoot outside a work tree, or a failed ref query degrade LOUDLY (Degraded=true, a path-free Reason) and the best-effort Max seen so far is returned. The caller then mints max(workingTreeMax, RefScan.Max)+1 and surfaces Warning() — so a degraded scan never silently narrows the id space it can see.

Only branch TIPS are scanned (a committed id lives in the tip's tree), so the cost is O(distinct branch tips), not O(history). Uncommitted files on other branches are deliberately out of scope — see the package doc's residual window.

func (RefScan) Warning

func (s RefScan) Warning() string

Warning renders the loud-degrade note for a surface to print (stderr / result envelope), or "" when the scan completed. It never leaks a path — Reason is a short, path-free cause.

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

func NewResolver(repoRoot string) (*Resolver, error)

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.

func (*Resolver) Len

func (r *Resolver) Len() int

Len reports how many record ids resolved — the size of the live record.

func (*Resolver) Lookup

func (r *Resolver) Lookup(id string) (string, bool)

Lookup returns the repo-relative path of the record id, and whether it exists. A malformed id simply does not resolve — callers that must distinguish "malformed" from "absent" check CitedIDRe first, which they do anyway to bound the string before echoing it.

Jump to

Keyboard shortcuts

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