Documentation
¶
Overview ¶
Package receipt is the preview gate's record (iss-2611281623098395): a verb that moves, rewrites or deletes a record or a transcript runs for real only after a dry run of the same call, over the same state, within Bound.
The dry run writes a receipt keyed on the call (the command and its arguments) and holding a digest of the state it read: the checkout's HEAD, when the verb acts on one, and the bytes of every path its plan touches. The real run plans again first, so a refusal the plan meets is the same refusal either way, then consumes the receipt for its call: one that is missing, older than Bound, or whose state no longer matches the state the real run reads refuses the run before anything is written. The receipt is removed when it is consumed, so one dry run admits one real run.
The receipts live in the checkout's local tier (LocalRelDir), or in abcd's home (HomeLeaf) for a verb that acts on no checkout, such as `history discard --root-sha` or `--pending`. The bound is the decision recorded with the gate: long enough to read a plan and run it, short enough that a plan is not acted on after the session that read it has moved on.
The package is transport-free: it writes no output, and its refusal is an error the front door renders.
Index ¶
Constants ¶
const Bound = 30 * time.Minute
Bound is how long a dry run's receipt admits the real run.
const BoundText = "30 minutes"
BoundText is Bound as a refusal and the docs say it.
const HomeLeaf = "dry-runs"
HomeLeaf is the home store, below abcd's home.
const LocalRelDir = localtier.RelDir + "/dry-runs"
LocalRelDir is the checkout store, below the repository root.
Variables ¶
This section is empty.
Functions ¶
func Consume ¶
Consume admits the real run of c over st: it finds the receipt the dry run of c wrote, refuses one older than Bound or written over another state, and removes it. A refusal is a *Refusal carrying refusal.DryRunRequired. Two real runs racing for one receipt are settled by the removal: the one whose removal finds the receipt gone is refused as if it had none.
Types ¶
type Call ¶
Call is one invocation as the gate keys it: the command path below the root, then the positional arguments, then every flag the caller set as --name=value in name order, the output and dry-run flags left out.
type Reason ¶
type Reason string
Reason is why a real run found no receipt to stand on.
const ( // Missing is no dry run of this call on record. Missing Reason = "missing" // Stale is a dry run of this call older than Bound. Stale Reason = "stale" // Mismatch is a dry run of this call over a state that has changed since. Mismatch Reason = "mismatch" // Future is a dry run of this call dated more than a minute ahead of the // clock, whose age the gate cannot judge. Future Reason = "future" )
type Receipt ¶
type Receipt struct {
SchemaVersion int `json:"schema_version"`
Command string `json:"command"`
Call string `json:"call"`
State string `json:"state"`
Head string `json:"head,omitempty"`
Paths []PathState `json:"paths"`
At time.Time `json:"at"`
}
Receipt is one dry run's record.
type Refusal ¶
Refusal is a real run the gate refused. Changed names what moved under a mismatched receipt: "HEAD", or each touched path whose bytes differ or that one of the two runs touches and the other does not.
type State ¶
State is what a run read: the checkout's HEAD (empty for a verb that acts on no checkout, or a branch with no commit) and each touched path.
func Items ¶
Items is the state of a plan that acts on things other than files — the worktrees a prune removes, the branches a sweep deletes on origin: head, and each item by the name a refusal shows, with the digest of what the run judged of it, in name order. A thing the dry run would act on and the real run would not, or the reverse, differs as a path does.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is where receipts are kept: a checkout's local tier, or abcd's home.