Documentation
¶
Overview ¶
Package spotcheck keeps the spot-check's record (itd-2610301750162657, spc-2610301925429250): the work abcd decided with no person involved, recorded as it happens, for a later draw to read.
THE STORE. The record lives on one branch of the shared remote, BranchRef on origin, tracked at TrackingRef. It is an orphan whose tree holds folders of small JSON files, each written once and never edited: handbacks/ holds the drain's hand-backs and decisions/ the automated facilitator's decisions (the drain's judgements a model answered and the merge gate's in auto mode). Each file's name ends in a short hash of its content, so a name stands for one content: two records that differ in anything are two files, and two writers never write one file two ways.
A write is committed on this checkout's local copy, LocalRef, at once, touching no HEAD, index or working tree, and reaches no network. LocalRef lives outside refs/heads/ and refs/remotes/, so no fetch moves it and every worktree of the checkout shares it: a lane's worktree removed after its landing takes none of its records with it. A record counts as kept only when the local copy holds a file of its name with its content; nothing read from origin's copy makes a record count as kept. One write commits all the records it is handed together, as one commit.
push, which no verb calls yet, carries the local copy to origin: one fetch of the branch, the records origin lacks laid over its tip, and one plain push, never forced, so nothing another writer pushed is dropped; a push origin rejects is tried once more after a fresh fetch, and one that fails again leaves every record on the local copy for the next push. The lay-over never moves the local copy, which holds only this checkout's own writes.
Everything read from the store was written by another session, account or machine, so it is read strictly: names are checked against the forms this package writes and against the hash of their content, each file is bounded and strictly decoded, the number of files a read takes is bounded, and a store that cannot be read is an error, never an empty store.
FREE TEXT. A record's free text is cleaned by one rule that depends on nothing of the machine or account writing or reading it (clean): the text holds no "\" and no "~", and a word that holds a "/" begins with an ASCII letter or digit, has one right before every "/", and holds nothing but ASCII letters, digits, ".", "_", "-" and "/". A run of non-space characters that would break the rule is replaced whole by one fixed placeholder, so a bare repository-relative path such as internal/core/x_test.go stays, and every other word holding a "/" goes: an absolute or home-relative path, an address such as file:// or https://, an option or a name written straight against a path (-I/usr/include, CFLAGS=-I/x, file=a/b), a path in quotes, brackets or backticks, a path with a line number or punctuation written against it (internal/x.go:12, internal/x.go,), and a path that begins with a dot (.abcd/config.json). Control and invisible characters separate words and are removed. A text over its bound is cut between words: the word the cut falls in goes whole and the cut is marked by a word of its own, so a text cleaned twice reads the same as one cleaned once. The read side checks a stored text with the same function, so two readers of one store agree on what it holds.
WHO A COMMIT NAMES. Every git command that makes an object or moves a ref runs through one helper (storeGit) whose environment names abcd's fixed identity as author and committer, whatever the environment held, with the dates in UTC. The record names its writer only by its holder id, the form the reservations use.
Index ¶
- Constants
- Variables
- func AfterLanding(parent context.Context, o Observed) string
- func Holder() string
- func RegisterLandingsReader(r LandingsReader)
- type Batch
- type Beacon
- type Config
- type Cycle
- type CycleWindow
- type Decision
- type GroupDraw
- type HandBack
- type Item
- type Judgement
- type LandingRow
- type LandingsReader
- type Observed
- type Population
- type PushResult
- type Records
- type Sample
- type WindowOpen
- type Written
Constants ¶
const ( KeyWindowDays = "spotcheck.window_days" KeyWindowChanges = "spotcheck.window_changes" KeyPerGroup = "spotcheck.per_group" DefaultWindowDays = 7 DefaultPerGroup = 10 )
The configuration's keys, bundled defaults and bounds.
const ( CyclesDir = "cycles" ItemsDir = "items" JudgementsDir = "judgements" WindowOpenFile = "window-open.json" )
The draw's folders and files.
const ( ClosedByDays = "days" ClosedByChanges = "changes" )
The words a cycle's window closes by.
const ( SizeFull = "full" SizeHalved = "halved" )
The sizes a sample takes.
const ( VerdictSound = "sound" VerdictWrong = "wrong" )
The verdicts a judgement gives.
const ( GroupDrainLanded = "drain-landed" GroupAutomaticMerges = "automatic-merges" GroupDrainHandBacks = "drain-hand-backs" GroupFacilitatorDecisions = "facilitator-decisions" )
The four groups, in the order a cycle holds them.
const ( RoleFacilitator = "facilitator" RoleHumanFacilitator = "human-facilitator" RoleProductThinker = "product-thinker" )
The roles an item is for.
const ( ClassDrain = "drain" ClassAutomatic = "automatic" )
The landings classes the draw reads, as the reader names them.
const ( // Branch is the store's branch on origin. Branch = claim.SpotcheckBranch // BranchRef is the branch as a full ref on origin. BranchRef = "refs/heads/" + Branch // TrackingRef is where a fetch keeps origin's copy. TrackingRef = "refs/remotes/" + claim.Remote + "/" + Branch // LocalRef is this checkout's local copy: every record this checkout // wrote, and nothing another writer wrote. LocalRef = "refs/abcd/spotcheck" )
The store's refs.
const ( HandBacksDir = "handbacks" DecisionsDir = "decisions" )
The store's folders.
const ( KindDrainJudgement = "drain-judgement" KindMergeGate = "merge-gate" )
The kinds of decision a decisions/ file holds.
const ( SiteLand = "land" SiteLane = "lane" // SiteRearm is the merge gate asked afresh when a release hold re-arms a // withdrawn merge (landing's rearmGate). SiteRearm = "rearm" )
The sites a merge-gate decision is recorded from.
const ( // BeaconTimeout bounds the beacon's fetch, every host it asks together. BeaconTimeout = 10 * time.Second )
The beacon's bounds.
const ChainHash = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971"
ChainHash is the quicknet chain's hash, as its info reply names it, read on 31 October 2026 (.abcd/development/research/notes/ 2026-10-31-drand-beacon-verification-sota.md). Every round is asked of the chain by this hash.
const DrawRule = "" /* 187-byte string literal not displayed */
DrawRule says how a cycle's draw is recomputed from its record, so anyone can repeat it.
const DrawTimeout = 3 * time.Minute
DrawTimeout bounds one observation that draws: the fetch, the beacon, the landings read and the push together.
const SchemaVersion = 1
SchemaVersion is the version every record this package writes carries; a record of any other version is not read.
const SiteDrain = "drain"
SiteDrain is the third observing site, a drain move, beside SiteLand and SiteLane.
const ( // WriteTimeout bounds one write, all of its git commands together. Each // is local, so a write that takes longer is a git that hangs, and the // write is given up rather than hold its caller. WriteTimeout = 10 * time.Second )
Bounds.
Variables ¶
var ErrNoOrigin = errors.New("this checkout has no remote named " + claim.Remote + ", so the spot-check keeps no record here")
ErrNoOrigin is a checkout with no remote named origin: there is no shared remote to keep the record on, and nothing is written.
Functions ¶
func AfterLanding ¶
AfterLanding observes a landing for the spot-check and answers a note for the caller's own text, "" when there is nothing to say. A checkout with no remote named origin keeps no spot-check, and the note is "".
func Holder ¶
func Holder() string
Holder is this account's holder id, the form a reservation names its holder by (claim.KeptHolderID: read, never minted), or "" when none can be read: a record then names no writer.
func RegisterLandingsReader ¶
func RegisterLandingsReader(r LandingsReader)
RegisterLandingsReader is how the landings reader makes itself known to the draw, once, as its package is linked.
Types ¶
type Beacon ¶
type Beacon struct {
URL string `json:"url"`
ChainHash string `json:"chain_hash"`
Round uint64 `json:"round"`
Signature string `json:"signature"`
Randomness string `json:"randomness"`
FetchedAt time.Time `json:"fetched_at"`
}
Beacon is the round a cycle was drawn from, as the cycle record keeps it, so anyone can repeat the verification later.
type Config ¶
Config is the spotcheck block as resolved. WindowChanges 0 is unset: only the days close the window.
type Cycle ¶
type Cycle struct {
SchemaVersion int `json:"schema_version"`
ID string `json:"id"`
FromCommit string `json:"from_commit"`
ToCommit string `json:"to_commit"`
FromTime time.Time `json:"from_time"`
ToTime time.Time `json:"to_time"`
ClosedBy string `json:"closed_by"`
Window CycleWindow `json:"window"`
Site string `json:"site"`
Beacon Beacon `json:"beacon"`
Draw string `json:"draw"`
Sample Sample `json:"sample"`
Groups []GroupDraw `json:"groups"`
Holder string `json:"holder,omitempty"`
}
Cycle is one draw, cycles/<id>.json.
type CycleWindow ¶
type CycleWindow struct {
Days int `json:"days"`
Changes int `json:"changes"`
Commits int `json:"commits"`
Defaults bool `json:"defaults,omitempty"`
}
CycleWindow is the window's bounds as the default branch configured them at the window's start (windowConfig): WindowDays, and WindowChanges, 0 when unset; Commits, the first-parent commits the window spans; and Defaults, true when the block did not read there and the bundled defaults counted the window.
type Decision ¶
type Decision struct {
SchemaVersion int `json:"schema_version"`
Kind string `json:"kind"`
At time.Time `json:"at"`
Holder string `json:"holder,omitempty"`
// A drain judgement: the issue, the question put, the answer and the
// hand-back kind a yes named, the model that answered, the drain's rule
// record and the reason given.
Issue string `json:"issue,omitempty"`
Question string `json:"question,omitempty"`
Answer string `json:"answer,omitempty"`
AnswerKind string `json:"answer_kind,omitempty"`
Model string `json:"model,omitempty"`
Rule string `json:"rule,omitempty"`
Reason string `json:"reason,omitempty"`
// A merge-gate decision: where it was asked, the pull request and its
// head, and the gate's answer as the gate gave it: whether it armed, the
// method, its reason, and whether it rests on an answer the gate could
// not read; and the facts the gate set as it decided: the mode it ran in,
// whether the author can write to the repository and whether a person's
// approval counted (both always present on a merge-gate record).
Site string `json:"site,omitempty"`
PR int `json:"pr,omitempty"`
Head string `json:"head,omitempty"`
Arm bool `json:"arm,omitempty"`
Method string `json:"method,omitempty"`
Why string `json:"why,omitempty"`
Unread bool `json:"unread,omitempty"`
Mode string `json:"mode,omitempty"`
AuthorCanWrite *bool `json:"author_can_write,omitempty"`
ApprovalCounted *bool `json:"approval_counted,omitempty"`
// ModeLayer is the configuration layer that declared the mode (the
// repository, the machine or the bundled default), and ReceiptNamedHead
// whether a review receipt that stands named the head: both set by the
// gate as it decided, so a reader takes them as fields, never from the
// reason. A record written before the gate set them carries neither.
ModeLayer string `json:"mode_layer,omitempty"`
ReceiptNamedHead *bool `json:"receipt_named_head,omitempty"`
}
Decision is one of the automated facilitator's decisions, as decisions/ holds it: the drain's judgement a model answered (KindDrainJudgement) or the merge gate's in auto mode over a pull request whose author can write, with no person's approval counted (KindMergeGate). Each kind sets its own fields and leaves the other's empty.
type GroupDraw ¶
type GroupDraw struct {
Group string `json:"group"`
Population Population `json:"population"`
Drawn []string `json:"drawn"`
}
GroupDraw is one group of a cycle: its population and the keys drawn.
type HandBack ¶
type HandBack struct {
SchemaVersion int `json:"schema_version"`
At time.Time `json:"at"`
Issue string `json:"issue"`
// From, Kind and Route are the drain's own words for where the hand-back
// came from, what kind it is and where it went.
From string `json:"from"`
Kind string `json:"kind"`
Route string `json:"route"`
// Rule is the rule a field hand-back names; DrainRule the decision record
// the drain read its rule from.
Rule string `json:"rule,omitempty"`
DrainRule string `json:"drain_rule,omitempty"`
Reason string `json:"reason"`
// PR is the lane's pull request, when the lane opened one; RunID the
// lane's run.
PR int `json:"pr,omitempty"`
RunID string `json:"run_id,omitempty"`
// Blob is the issue record's blob on origin's default branch when the
// hand-back was routed.
Blob string `json:"blob,omitempty"`
Holder string `json:"holder,omitempty"`
}
HandBack is one of the drain's hand-backs, as handbacks/ holds it.
type Item ¶
type Item struct {
SchemaVersion int `json:"schema_version"`
Cycle string `json:"cycle"`
Number int `json:"number"`
Group string `json:"group"`
Key string `json:"key"`
Roles []string `json:"roles"`
Landing *LandingRow `json:"landing,omitempty"`
HandBack *HandBack `json:"hand_back,omitempty"`
Decision *Decision `json:"decision,omitempty"`
}
Item is one drawn item, items/<cycle-id>/<nnn>-<group>-<key>.json: the state it had at the draw, copied in, so what a person later sees as then never rests on a later read.
type Judgement ¶
type Judgement struct {
SchemaVersion int `json:"schema_version"`
Cycle string `json:"cycle"`
Item string `json:"item"`
Role string `json:"role"`
Verdict string `json:"verdict"`
}
Judgement is the part of a judgement file, judgements/<cycle-id>/<item stem>.<role>.json, the sample size reads: the cycle, item and role it judges, which its path must repeat, and its verdict. Its other fields are the review lane's.
type LandingRow ¶
type LandingRow struct {
Commit string `json:"commit"`
When time.Time `json:"when"`
PR int `json:"pr,omitempty"`
MergedHead string `json:"merged_head,omitempty"`
Class string `json:"class"`
RuleKind string `json:"rule_kind,omitempty"`
RuleID string `json:"rule_id,omitempty"`
RulePath string `json:"rule_path,omitempty"`
Lane string `json:"lane,omitempty"`
Mode string `json:"mode,omitempty"`
Resolves []string `json:"resolves,omitempty"`
Delivers []string `json:"delivers,omitempty"`
Unattended bool `json:"unattended"`
// ForgeUnread says the reader could not settle the row's approval from
// history and could not read the forge's answer: such a row refuses the
// draw, so a person's approval is never drawn as unattended on a guess.
ForgeUnread bool `json:"-"`
}
LandingRow is one landing as the draw copies it into an item: the reader's row in typed fields alone. The reader's own words for why it classed a row as it did stay with the reader.
type LandingsReader ¶
type LandingsReader func(ctx context.Context, root, from, to string) ([]LandingRow, error)
LandingsReader reads the landings of the default branch from (exclusive) to (inclusive), both full object names, under ctx.
type Observed ¶
type Observed struct {
Root string
Default string
// Site is SiteLane, SiteLand or SiteDrain.
Site string
// Now is the observing instant; zero is time.Now.
Now time.Time
}
Observed is one landing abcd proved: the checkout, origin's default branch as just fetched, and the site that proved it.
type Population ¶
type Population struct {
Count int `json:"count"`
Keys []string `json:"keys,omitempty"`
First string `json:"first,omitempty"`
Last string `json:"last,omitempty"`
SHA256 string `json:"sha256,omitempty"`
}
Population is a group's keys, whole up to maxListedKeys and otherwise by their range and hash.
type PushResult ¶
type PushResult struct {
// Commit is origin's copy after the push, "" when nothing was pushed.
Commit string
// Pushed counts the records the push carried that origin lacked.
Pushed int
// Unreadable names each file origin or the local copy held under a
// record's name whose content its name does not give: the copy whose
// content it does give is kept, and origin's when neither does.
Unreadable []string
}
PushResult is what one push carried to origin.
type Records ¶
type Records struct {
HandBacks []HandBack
Decisions []Decision
Unreadable []string
// contains filtered or unexported fields
}
Records is what the store holds at one ref, read strictly: every file whose name and content are one this package writes, and Unreadable naming each file that is not. A ref that cannot be read is an error.
type Sample ¶
type Sample struct {
PerGroup int `json:"per_group"`
Size int `json:"size"`
Why string `json:"why"`
// Counted are the closed cycles the size was decided over, newest first.
Counted []string `json:"counted"`
}
Sample is the size a cycle drew at and why.
type WindowOpen ¶
type WindowOpen struct {
SchemaVersion int `json:"schema_version"`
Commit string `json:"commit"`
At time.Time `json:"at"`
Holder string `json:"holder,omitempty"`
}
WindowOpen is window-open.json: where and when the first window opened.
type Written ¶
type Written struct {
// Wrote counts the records the write committed, and Kept those the local
// copy already held.
Wrote, Kept int
// Failed counts the records the write tried to commit and could not, and
// Err says why; Err is ErrNoOrigin, with nothing counted, for a checkout
// with no remote named origin.
Failed int
Err error
// Unkeepable says, for each record the store cannot keep at all (no
// time, an id outside the store's form), why.
Unkeepable []string
}
Written is what one write did with its batch.
func Write ¶
Write commits every record of b the local copy does not already hold, as one commit on the local copy, touching no HEAD, index or working tree and reaching no network. A record is already held when the local copy holds a file of its name with its content, and a merge-gate decision when the local copy holds one over the same pull request and head with the same answer, at any time (gateHeld); nothing read from origin's copy is read for either. A file of a record's name with other content is replaced by the record. The local copy is moved only from the value the write read (a compare-and-swap): another writer of the checkout that moved it first makes this one read it again, maxTries times in all. Every git command runs under parent and WriteTimeout.