Repository navigation
Add the verdict state machine - #2
Merged
Merged
Conversation
A pure nextVerdict(prev, event, aliases) over lookup results, claims, named deadlines and errors. Encodes fail closed, monotonic verdicts and claims that only downgrade, with a transition table and checks over every event sequence up to length 3. Adds ADR 0003 and documents the state machine and notifications in ARCHITECTURE.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
src/types.ts: discriminated unions for lookup results, claims, verdict states, events andreason codes.
src/verdict.ts:nextVerdict(prev, event, aliases), a pure function with no I/O or clock.It maps the current verdict and one event (lookup result, claim, lookup or claim deadline,
error) to the next verdict.
test/verdict.test.ts: one test per transition, plus checks over every event sequence upto length 3 (1,463 sequences) for the three invariants.
docs/adr/0003-claim-only-downgrades.md, and the state machine with its invariants inARCHITECTURE.md.Why
This is the security core, and it needs no API to build or test.
OWNER_KNOWNis where theperson being called will be told whose agent it is;
MISMATCHis where they will be warnedthat the agent claimed someone else (see "Notifications" in
ARCHITECTURE.md). It encodesfail closed and
monotonic verdicts (ADR 0002) and the rule that a caller's
claim can only lower a verdict (ADR 0003).
Decisions a reviewer may question:
lookuporclaim). A late lookup timer firing inOWNER_KNOWNmust not close the claim window early.
IDENTIFYINGare kept. Otherwise a caller who lies before thelookup finishes would end up as
VERIFIED_NO_CLAIM.VERIFIEDandVERIFIED_NO_CLAIMcan still drop toMISMATCHon a later claim forsomeone else. Only
MISMATCHandUNVERIFIEDare final.case-insensitive.
How to test
Not in this PR
name.
events (PR 5).
nextVerdicttakes them as an argument; config does not have themyet.
claim_timeoutis defined but only produced once the orchestrator exists.comes later.