Runs and levels (core): deploy approvals with domi-approve, the security member, display offers; v0.12.0 #14
Reference in New Issue
Block a user
Delete Branch "feature/runs-core"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Core part of "Runs and levels" (Custos docs/11_runs_and_levels.md, sections 3, 4, 5 and the Core row of the test matrix). Release v0.12.0 after review; not tagged.
What
custos-sign: deploy approvals
approval_check(text, now_secs) -> Result<Approval, Error>: parses the canonical JSON (v,run,repo,commit,pipeline,version,targets,expires), checks every member, writes it again in canonical form and compares bytes; then the expiry (> now,<= now + 3600).approval_parse(text)is the same without the clock (for filling the audit of a refused or expired request; never used to sign).approval(secret, key_id, text, timestamp, run) -> Result<String, Error>: checks again, requires the JSON's run =run, then the existing prehashedminisign()with file nameapproval-<run>.json. No new crypto.run_id_ok,Approval::canonical,MAX_APPROVAL(8 KiB),APPROVAL_MAX_AHEAD(3600),Error::Approval(&'static str).custos-vault: signing
SignKind::Approval("approval"),Request.approval,Request.run,Context.version(skipped when empty),AuditEntry.run(skipped when none).domi-approve(Ed25519, role release, "Domi deploy approval", the release keys' scope) is made bysigning_create(Role::Release, …);signing_add_approve(now)adds it to release keys made by an older core.signing_check_at(req, now);signing_check(req)keeps its signature and usesnow_ms().approvalonly bydomi-approve(Ed25519, release),domi-approvesigns nothing else;runrequired and equal to the JSON's; a malformedrunon any request isinvalid;approvaltext on another kind isinvalid; a non-empty contextrepo/pipeline/commit/versionthat differs from the JSON isinvalid; scope is checked against the JSON's repo and pipeline.custos-vault: provision — store
display, outcomeconfirmed. A display is an offer, neveraccepted/approved/generated/replaced;confirmedonly withdisplay. Noconfirmed-wrong: Custos only sends a code its own check accepted, and does not see the server's exit 10.custos-vault: security — new body member
security(docs/FORMAT.md): Setup window,finished, ticked items, kept scope, append-only audit (newest 5 000). Level computed: Setup forstarted <= now < untilof an unfinished window; else Hardened with any tick; else Standard. Expiry written lazily (setup-expired,finished = until) by the first change after it. Pure rules:accept_all_allowed,replacing_line_preticked,ssh_needs_auth,totp_offer_allowed,hello_for_approvals.Docs: SIGNING.md (approval kind, domi-approve, canonical form, compatibility), FORMAT.md (security member, display/confirmed, the values older cores refuse).
Deviations from the design, to decide
security,run,versionand thedomi-approvekey (an older core ignores them; tested against a mirror of the 0.11.0 parser). But asigningaudit entry of kindapproval, or aprovisionentry with storedisplay/ outcomeconfirmed, is an enum value core 0.11.0 does not know, and it refuses the whole vault (Corrupted), as docs/FORMAT.md already documents for unknown values. So after the first approval request or display offer, a desktop rollback to a 0.11 core cannot open the vault. Tests pin this (an_older_reader_..._but_not_approval_entries,an_older_reader_refuses_display_and_confirmed). Options if that is not acceptable: keep these entries in a member old readers ignore (e.g.signing.audit2), or record them in thesecurityaudit instead. Not done here without a decision.\thashed. The design writestimestamp:<now>\tfile:approval-<run>.json; reusing the existing minisign path gives…\tfile:approval-<run>.json\thashed, which is what minisign itself writes for a prehashed signature and what our other.minisigfiles carry.minisign -Vand minisign-verify accept it (tested). The hub must not compare the comment literally without\thashed.approval(...)returnsResult<String, Error>(notString): it re-checks the text and the run.Adversarial self-review
\u0041,\/, spaces,1.0, duplicate or unknown keys, leading/trailing whitespace, a trailing newline): each is refused because the text is rewritten and compared byte for byte, and each has a test.deny_unknown_fieldsand serde's duplicate-field error are a second layer. A quote/backslash in a target round-trips (\",\\). Raw non-ASCII is canonical; the same character via\uis not, so there is exactly one spelling. Size is capped before parsing (8 KiB). Numbers:expiresis u64, so negative, float and string forms fail to parse;u64::MAXfails the hour check withsaturating_add. Possible gap: a target that is all spaces, or leading/trailing spaces, is allowed (printable); the card shows it literally.repo: Arcain the context andrepo: Fabricain the JSON to pass scope: refused, scope uses the JSON, and a differing non-empty context member isinvalid.runin the request must equal the JSON's run; the signature namesapproval-<run>.json. Replay across runs is the hub's check (run, expiry); expiry is at most an hour.domi-approvecannot sign minisign/manifest digests (so it cannot be tricked into signing an installer), and no other key (release, test, code-signing, root) signsapproval. A crafted vault with a test-roledomi-approvecannot sign approvals (role must be release), so no auto-approval path exists.Approval::Autoon it is refused like any release key.security. Older cores ignore and, when they save, drop the member: level back to Standard, checklist unticked, audit lost (same model assigning/provision, documented). Dropping makes things less permissive in one way (Setup gone) but unticks hardening, e.g.no-ssh; that is the documented "every Custos that saves must be 0.12.0+".untilitself is Standard,until - 1is Setup,startedis Setup,started - 1is Standard (a clock set back does not give Setup before its start); tested. Restarting while in Setup returns the same window and writes nothing. If the clock goes back belowstartedwhile a window is open,security_start_setupstarts a new window at the earlier time (not an extension in wall time, but worth knowing).security_level/security_viewnever mutate; expiry is written by the next change only, so a vault that is only read keepsfinishedempty (level is still right).until <= started,finishedwithoutsetup, a kept-scope prefix that is empty, too long or has control characters: the vault refuses to open (Corrupted); tested by editing the decrypted body and sealing it again. Same strictness assigning/provision, so a future core adding an item makes this core refuse such a vault: the next item needs the same compatibility decision as point 1.setup-expiredis written once becausefinishedis set when it is.domi-approve's seed is covered by the existing "no API path returns a private key" test (now 7 keys, with an approval signed). Errors carry static reasons or names (repo/pipeline in out-of-scope messages, as before).Tests
cargo test --workspace --release: all green.(doc-tests unchanged.) Each new test was first seen failing to compile, then failing an assertion against a stub, except:
a_display_offer_is_recorded_as_confirmed_and_survives_a_reopen(the two enum variants are the whole change, so it passed once they compiled),a_vault_that_never_had_setup_is_standardandvalues_are_spelled_as_docs_format_says(the stub's default and the real types), and the two older-reader tests (the approval key and approval entries; display/confirmed), written after those features as characterization tests of the compatibility in point 1.