Documentation
¶
Overview ¶
Package refusal is the registry of abcd's refusal codes (itd-2610301428378830, spc-2610301431108175 step 1).
When abcd refuses a call (exit 2, or exit 3 when someone else holds what the call needs), the refusal carries a short code, a one-line hint and the next command to try, and `abcd explain <code>` prints the code's explanation. Every code is one entry of the table below, and the front door reads the hint, the next command and the explanation from it, so a refusal and its explanation cannot disagree.
A code is a short name, never a number (adr-2610301638558260): the verb, a slash and the reason, in lower-case kebab-case, such as capture/missing-remedy, or usage/... for the command framework's own refusals. Once a release has carried a code it is never renamed and never given to a different refusal: a refusal that changes meaning gets a new code, and one that goes away keeps its entry, marked retired, so explain still answers and the name is never handed out again. The words of an entry can change in any release; only the code is a promise.
The registry is held by tests: no two entries share a code, every code follows the grammar, every Code constant is registered, and the committed ledger (LedgerPath), written from the table by cmd/refusal-codes-sync, is the one the release guard reads at the last tag.
The package is transport-free: it holds data and two small helpers, Wrap and CodeOf, which let a core package name the code where the refusal is decided and the front door find it however the error was wrapped.
Index ¶
Constants ¶
const CommandSlot = "{command}"
CommandSlot is the placeholder in a next-command template that FillNext replaces with the refused call's own command path, below the root. It is the only part of a next command filled at run time, and it is never filled from the caller's arguments.
const LedgerFormatVersion = 1
LedgerFormatVersion is the ledger's format version.
const LedgerPath = ".abcd/development/release/refusal-codes.json"
LedgerPath is the committed ledger of codes, from the repository root. The release guard reads it at the last tag and refuses a cut in which a code it lists is missing.
const NoNext = "none"
NoNext is the next command of an entry where no command can help, such as a refusal that says to wait for someone else.
Variables ¶
This section is empty.
Functions ¶
func EncodeLedger ¶
EncodeLedger renders a ledger as the committed file holds it.
func FillNext ¶
FillNext fills a next-command template from the refused call's command path (`abcd capture remedy`): CommandSlot becomes the words below the root, or the root's own name for the root, as `abcd explain` takes them.
func IsTemplate ¶
IsTemplate reports whether next is a template, a command holding placeholders the caller fills in before running it, rather than a command to run as it stands.
Types ¶
type Code ¶
type Code string
Code is a refusal code: `<verb>/<reason>`.
const ( // reserve's own refusals. ReserveOutsideCheckout Code = "reserve/outside-checkout" ReserveAlreadyHeld Code = "reserve/already-held" ReserveExceededCap Code = "reserve/exceeded-cap" ReserveNotHeld Code = "reserve/not-held" ReserveUnreachableOrigin Code = "reserve/unreachable-origin" ReserveUnknownHolder Code = "reserve/unknown-holder" ReserveInvalidRequest Code = "reserve/invalid-request" // announce's own refusals. AnnounceOutsideCheckout Code = "announce/outside-checkout" AnnounceInvalidRequest Code = "announce/invalid-request" AnnounceNotPublic Code = "announce/not-public" AnnounceUnreachableOrigin Code = "announce/unreachable-origin" // peers' and status's own refusals. PeersOutsideCheckout Code = "peers/outside-checkout" StatusOutsideCheckout Code = "status/outside-checkout" // embargo's own refusals. EmbargoOutsideCheckout Code = "embargo/outside-checkout" EmbargoUnknownHome Code = "embargo/unknown-home" EmbargoNotAway Code = "embargo/not-away" EmbargoMissingStore Code = "embargo/missing-store" EmbargoMissingInput Code = "embargo/missing-input" EmbargoEmbargoedText Code = "embargo/embargoed-text" EmbargoInvalidRequest Code = "embargo/invalid-request" // banlist's own refusals. BanlistInvalidEntry Code = "banlist/invalid-entry" BanlistDuplicateKey Code = "banlist/duplicate-key" BanlistUnknownKey Code = "banlist/unknown-key" BanlistUnmanagedEntry Code = "banlist/unmanaged-entry" BanlistLegacyStore Code = "banlist/legacy-store" BanlistInvalidStore Code = "banlist/invalid-store" )
const ( // decide's own refusals. DecideOutsideCheckout Code = "decide/outside-checkout" DecideInvalidText Code = "decide/invalid-text" // decide accept's refusals (iss-2610040758569116). DecideUnknownADR Code = "decide/unknown-adr" DecideNotProposed Code = "decide/not-proposed" DecideNoAcceptor Code = "decide/no-acceptor" DecideMalformedADR Code = "decide/malformed-adr" // ideate's own refusals. IdeateOutsideCheckout Code = "ideate/outside-checkout" IdeateInvalidVerdict Code = "ideate/invalid-verdict" IdeateShallowCheckout Code = "ideate/shallow-checkout" IdeateMissingRootCommit Code = "ideate/missing-root-commit" )
const ( // intent's own refusals. IntentOutsideCheckout Code = "intent/outside-checkout" IntentUnknownIntent Code = "intent/unknown-intent" IntentHeldByPeer Code = "intent/held-by-peer" IntentInsufficientGrounds Code = "intent/insufficient-grounds" IntentInvalidVerdict Code = "intent/invalid-verdict" IntentInvalidFindings Code = "intent/invalid-findings" IntentInvalidRequest Code = "intent/invalid-request" // spec's own refusals. SpecOutsideCheckout Code = "spec/outside-checkout" SpecUnknownSpec Code = "spec/unknown-spec" SpecMissingImpact Code = "spec/missing-impact" SpecInvalidRequest Code = "spec/invalid-request" )
const ( // The command framework's usage refusals, raised by every command. UsageUnknownCommand Code = "usage/unknown-command" UsageUnknownFlag Code = "usage/unknown-flag" UsageMissingArgument Code = "usage/missing-argument" UsageExtraArgument Code = "usage/extra-argument" UsageFlagConflict Code = "usage/flag-conflict" UsageMissingRequiredFlag Code = "usage/missing-required-flag" UsageInvalidFlagValue Code = "usage/invalid-flag-value" // capture's own refusals. CaptureMissingRemedy Code = "capture/missing-remedy" CaptureRemedyMachineSpecific Code = "capture/remedy-machine-specific" CaptureUnknownIssue Code = "capture/unknown-issue" // CaptureUnknownReadingRecord is an id the reading ledger does not hold: // a reading item, an admission, a disposition or a reframe. CaptureUnknownReadingRecord Code = "capture/unknown-reading-record" CaptureNotOpen Code = "capture/not-open" CaptureInsufficientGrounds Code = "capture/insufficient-grounds" CaptureInvalidInput Code = "capture/invalid-input" CaptureNotCharacterized Code = "capture/not-characterized" // explain's own refusals. ExplainUnknownPath Code = "explain/unknown-path" ExplainUnrecognizedInput Code = "explain/unrecognized-input" ExplainUnknownCode Code = "explain/unknown-code" // start's own refusals. StartOutsideATerminal Code = "start/outside-a-terminal" StartProfileUnusable Code = "start/profile-unusable" StartRepositoryUnready Code = "start/repository-unready" StartHostNotRunnable Code = "start/host-not-runnable" StartNotLoggedIn Code = "start/not-logged-in" StartNoVerdict Code = "start/no-verdict" StartWallNotHeld Code = "start/wall-not-held" )
The registered codes of the table below. Each constant is an entry of the table, or of a family file's register call; a test fails on a constant the registry does not hold.
const DryRunRequired Code = "dry-run/required"
const None Code = ""
None is the absence of a code. A refusal built with None at exit 2 or 3 is carried out as Uncoded.
const RulesUnknownDomain Code = "rules/unknown-domain"
const Uncoded Code = "internal/uncoded"
Uncoded is the code a refusal carries when it was built without one at exit 2 or 3. It is never registered, so `abcd explain` refuses it and the tests that hold the registry and the front door fail on it.
type Entry ¶
type Entry struct {
// Code is the code itself, the one part a release promises.
Code Code `json:"code"`
// Summary is the one-line hint a refusal carrying the code shows.
Summary string `json:"summary"`
// Explanation is a few lines `abcd explain <code>` prints: what the
// refusal means and how to get past it.
Explanation string `json:"explanation"`
// Next is the command to try next, or NoNext where no command can help.
// It may hold CommandSlot, which the front door fills. A next holding a
// placeholder (`<fix>`, a word in angle brackets) is a template whose
// placeholders the caller fills in before running it (IsTemplate); any
// other next runs as it stands.
Next string `json:"next"`
// RaisedBy names the command paths that raise the code. It is empty for
// a usage code, which every command raises.
RaisedBy []string `json:"raised_by,omitempty"`
// Retired is the release tag the code was retired in, empty while the
// code is live. A retired entry stays in the table for good.
Retired string `json:"retired,omitempty"`
// ReplacedBy is, for a retired code, the code that took its place, if
// one did.
ReplacedBy Code `json:"replaced_by,omitempty"`
}
Entry is one registered code.
type Ledger ¶
type Ledger struct {
FormatVersion int `json:"format_version"`
Codes []LedgerEntry `json:"codes"`
}
Ledger is the committed list of codes: only the codes and their retirement, since an entry's words may change in any release and the code may not.
func BuildLedger ¶
func BuildLedger() Ledger
BuildLedger is the ledger of the registry, sorted by code.
func DecodeLedger ¶
DecodeLedger reads a committed ledger, refusing a format version it does not know, a code that does not follow the grammar, and a replaced_by that is set on a live code, names itself, or names a code the ledger does not list.
type LedgerEntry ¶
type LedgerEntry struct {
Code Code `json:"code"`
Retired string `json:"retired,omitempty"`
ReplacedBy Code `json:"replaced_by,omitempty"`
}
LedgerEntry is one code of the ledger.