Skip to content

P5 O11 M1: apps/org-protocol, the signed org state and v2 event signatures - #202

Merged
SSFSKIM merged 37 commits into
masterfrom
p5-o11-m1
Oct 27, 2026
Merged

SSFSKIM merged 37 commits into
masterfrom
p5-o11-m1

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 27, 2026

Copy link
Copy Markdown
Owner

P5 O11 M1, the protocol package (docs/doperpowers/plans/2026-10-27-p5-o11-hub-v2.md, M1).

What this lands

apps/org-protocol is the one implementation of the remote layer's signed org state (RL5) and v2 log-event signatures (RL8). The hub (M3–M7), the machines' endpoint (O10), desk-web (O13) and the app's main all import it. It uses WebCrypto only, and its imports carry .ts extensions, so Node loads it unbundled.

  • Keys and signing. P-256 keys, and signing inputs under the domains in Interfaces §A. Every verify function returns a verdict for any wire input, and none of them throws.
  • The org state chain. Genesis, successors, root transitions and endorsements are verified here. The chain also carries:
    • the machine ref;
    • machineNames, which binds each name to one ref for the life of the org;
    • retired and revoked key records, kept in the chain (RL Decision Logs 19–26);
    • one holder per key;
    • delegation-prefix namespaces, kept disjoint from enrolled names, with a revoked delegation's prefix and id reserved for good.
  • Certificates, listings, endpoint records and grants. Machine certificates use structural refs (<delegation id>_…), and their retirement is signed by the certificate's own delegation. Listings and endpoint records are verified, contested refs are refused for every claimant, and grants carry machineKey.
  • v2 events. Writers resolve through machineNames, and retirement is judged by the event's signed created. The signature binds org and project. The dual-coding order is pinned: sig first, then DX1's mac.
  • The enrollment MAC. Each field is length-prefixed; the domain is smns-enroll-mac-v1.
  • Vectors. vectors/ holds 273 cases, replayed in Node, rerun with fresh keys, re-derived with node:crypto, and replayed in workerd from a Worker bundle.
  • desk-hub/protocol. Its RFC 8785 canonicalizer and base64url moved into the package byte for byte, and desk-hub/protocol re-exports every name. Its 87 runtime exports are unchanged.
  • Root config. One additive line each in package.json (typecheck), vitest.config.ts (projects), eslint.config.js (the neutrality rule's files) and .github/scripts/gate-affected.mjs.
  • For the architect: .github/maws-app/gitleaks.toml gains one allowlist entry. The secret scan flagged the vectors' machineKey values, which are public key ids, as generic-api-key. The entry is ANDed to the exact file apps/org-protocol/vectors/vectors.json, the generic-key rule and a 22-character base64url value.
  • The O11 document. M1 is ticked, the parent and remote layer are re-pinned at master, and Interfaces §A is revised to the built API. The Decision Log records every ruling taken during the build, including the remote layer's Decision Logs 19–26, which this milestone fed.

Validation Evidence

  • Package tests: pnpm --filter org-protocol test gives 25/25. The vector replay gives 0 failures across 273 cases. Each fix wave's new vectors failed before its fix, and turning off each rule fails its own vectors (/tmp/dsk-scripts/p5-o11/task-1-report.md).
  • Consumers: desk-hub's protocol tests give 186/186, including the Node and workerd replay and DX1's verify accepting both dual-coded events. desk-web gives 918/918. The org-protocol, desk-hub and desk-web typechecks are clean, and eslint on the touched files is clean.
  • Review: doperpowers:reviewer-high and reviewer-medium ran first, then four reviewer-high re-reviews across seven fix waves. The last one returned correct on f2bd48d..d9b16a5. reviewer-medium's second re-review was cut off by the sol gateway ("content flagged"); its findings had already been relayed, and the high re-reviews covered its integration lens.
  • CI: scripts/ci-gate.sh /tmp/maws-o11-m1 --gates static,unit,probes,e2e:desk-web on f02a0a9a4: GREEN, https://github.com/SSFSKIM/MAWS/actions/runs/40443041603 (plan, static, probes, unit 1–4/4, e2e:desk-web success).

Open items for later children (recorded in the O11 Decision Log)

  • verifyGrant covers enrolled machines, not certificate VMs (O10).
  • A bundled certificate under a revoked delegation reads revoked before its signature is checked. It's a refusal either way.
  • Recovery against an already-accepted forged chain past a transition's fromVersion is O10's question.
  • Provisioning keys' null maxUses/offlineRevokeS map to numbers at M4.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)

… RL8 signed events)

The remote layer's one protocol package, created with RL5's signed org state
and RL8's signed log events (Interfaces §A of the O11 execution document):
P-256 keys and kids, genesis, successors on the head, endorsed devices, root
transitions by the recovery key, grants, delegation-signed machine
certificates, machine-signed listings and endpoint records, the
writer-to-signer rule, and the v2 event signature bound to org and project.
Every verification is pure and returns a Verdict code.

Vectors in apps/org-protocol/vectors/ (95 cases, 2 dual-coded events), with a
replay every consumer runs; the package's suites replay them in Node and in
workerd, check the encodings with Node's own crypto, and rerun the scenario
with fresh keys. desk-hub replays them through the workspace and from a
Worker-style bundle in Miniflare, and checks the dual-coded events' macs with
DX1's verify unchanged.

desk-hub's canonicalizer and base64url move into the package byte for byte,
with the member-id, machine-name, ISO-time and writer rules; desk-hub/protocol
re-exports every name. The neutral runtime declarations move with them and
gain ECDSA, ECDH, HKDF and AES-GCM. Root config gains the package's typecheck,
vitest project, eslint neutrality path and the gate's bundle-reader tree.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…tions are async

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…11-m1

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…ine ref binding)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…d VM, the per-writer seq check and O14's certificate revocation

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…rom revocation

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…a sminos-side race for O14/O12)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Review findings (reviewer-high, reviewer-medium), each pinned by a refusing vector:
- verifyEvent refuses a state of another org than the event's context;
- several held root transitions authorize a successor whatever their order;
- root-set keys, the recovery key and a transition's new keys must be real
  P-256 points, not only encodings;
- a lone surrogate (or anything RFC 8785 cannot write) in any wire input is
  `malformed`, never a thrown error, in every public verify.

The machine ref (RL DL 19, P5 DL 21): RL5 machine entries carry `ref`,
unique and immutable; every contract `machine` field carries the ref; machine
certificates are {org, machine: ref, name, pub, delegation, use, issued}; a
ref an entry holds, or two live certificates claim with different keys, is
contested (`contested-ref`, `contestedRefs`). `machineNames` is the
append-only record of every (name, ref) pair, a name never given to another
ref (`name-retired`); log writers resolve `<name>/…` through it. The
enrollment MAC length-prefixes (name, machinePub, ref, tokenId).

Vectors regenerated: 134 cases, 2 dual-coded events, 4 enrollment MACs.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
RL5 gains `retired`: keys that left honestly, each with its point and holder
so a verifier holding only the head can verify their past events. A key the
state drops without retiring it is revoked. A successor keeps an entry,
drops it (revoking the key), or retires a key the head held under that
holder; a revoked key never comes back and a notAfter never moves.

Delegation certificates get a retirement record (smns-cert-retire-v1, its
delegation key or an admin device) and a revocation record
(smns-cert-revoke-v1, an admin device only), served beside the
certificates as one `Certificates` bundle. A retired, revoked or
delegation-less certificate is not live and contests nothing, so a
recreated VM can take its old name under a new ref; a name two live
certificates claim under different refs is contested.

RL8: signerFor returns signers with a notAfter; an event signed by a retired
key verifies when the signer's own timestamp is at or before it (a
machine's covered `ts`, a device's covered `created`, never the hub's
`ts`), and a revoked key's events never verify. `contested-ref` becomes
`contested`.

Vectors regenerated: 165 cases, 2 dual-coded events, 4 enrollment MACs.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…y as it stops being current)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…gistry's set in M3, the endpoint's in O10

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
RL DL 22: a key enters `retired` only in the step it stops being current.
retiredKept already enforced it (a new entry must be held by the head under
its holder, and absent from the successor's current keys); vectors now pin
a dropped retirement re-added and a key dropped two steps before retired.

RL DL 23: a revoked key never becomes current again. revokedBy(prev, next)
returns the key ids a step revokes; verifySuccessor takes an optional
{ revokedKeyIds } and refuses a successor that makes one current with the
new verdict `revoked`. Vectors: re-adding a revoked device with and without
the set, and revokedBy on a device removal, a dropped retirement and a plain
retirement.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…ment's M1 and M2 records joined

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…aims only, retired history kept

- A certificate retirement retires only certificates of its signer's own delegation (or any, by an admin), and
  every certificate the path uses is authenticated: another delegation can't retire a VM through a shaped
  object or a certificate of its own carrying the VM's key.
- A ref an entry holds, claimed by an authenticated live certificate, is contested for every claimant, the
  entry included (machineKeys, listings, endpoint records, events); contestedRefs counts live claims only.
- Collision with the state's identities applies to live claims only: a retired or expired certificate keeps
  its time-bounded history when its name or ref is enrolled later.
- verifyEvent judges a key allowed more than once by the most lenient signer (a certificate and its renewal).
- A retired device key's hub/<member> words verify after the member leaves, while the retirement stays.
- A key retired in the head is never current in the successor, so a dropped retirement can't reset notAfter.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…rwise; the Registry's revoked set dropped

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…ate-bound names (provisional, with RL DL 24)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…itive names)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…eys never current again)

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…ate refs, grants' keys (RL DL 24-25)

- RL5 gains `revoked: {keyId, holder}[]`, append-only, for device, machine, delegation and certificate keys.
  A device's or machine's key leaving the state enters `retired` or `revoked` in that step; a delegation's
  key only `revoked`; a `retired` entry leaves only into `revoked`. A revoked key is never current or
  retired, and a retired key never current again (K1 -> K2 -> K1 refused); a successor holding a revoked
  key is `revoked`. Every rule needs the state and its predecessor alone, so `revokedBy` and
  verifySuccessor's `revokedKeyIds` are gone.
- Delegations: id, pub and prefix fixed; `expires` moves only while both values lie ahead; dropping one
  revokes its key and every certificate under it. Delegation ids are 32 lowercase hex.
- Admin retirement and revocation of a certificate are state edits: CertRevocation and admin-signed
  CertRetirement records are gone; the bundle is {certs, retirements}. A certificate is retired at the
  earliest of its delegation's expires, the state's retired entry and its own delegation's records; a
  revocation overrides all.
- Name namespaces: no machineNames name under a delegation's prefix, no prefix matching or nesting in
  another, by the lower-cased key. A certificate's ref starts with its delegation's id and `_`.
- Grants name their machine key (`machineKey`, a key id); a grant for another key is `not-listed`.
- Records and events signed by a revoked key, or a certificate under a revoked delegation, read `revoked`.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…entials

A grant's `machineKey` (RL DL 24) is a key id, base64url of 16 bytes of SHA-256 over a public key, and
the vector generator draws fresh keys each run, so the entry allows the shape, narrowed to vectors.json.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…reated anchor

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
…gations stay reserved (RL DL 26)

- Every v2 event carries a signed `created`; retirement compares against it for machine and device events
  alike, never `ts`. verifyEvent refuses an event without one (malformed); signEvent refuses to sign it.
- A revoked delegation's holder is {delegation, prefix}. Its prefix and id stay reserved for the life of the
  org: the namespace rules count revoked prefixes beside live ones, no delegation reuses a known id, and
  no entry's ref (or machineNames ref) starts with a known delegation id and `_`.
- Dropping a delegation moves its certificates' retired keys (refs `<id>_…`) into `revoked`: no `retired`
  entry stays under a revoked delegation, so an admin-retired certificate never outlives it.
- A revival reads `revoked` ahead of the whole-state rules it also breaks.

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
… recorded wherever it reappears

keysAccounted counted a key as kept whenever any holder still held it, so a delegation dropped while its
key became an enrolled machine's needed no revocation, freeing its prefix for a new delegation to certify
the old VMs' keys again. A key now counts as kept only under the same holder, and a state holds no key
under two holders (devices, a device's channel and step-up, machines, delegations, the recovery key).

Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
Sminos-Session: desk-sminos-orchestrator#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T03:25:26.782104Z f02a0a9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM
SSFSKIM merged commit 0ef0b86 into master Oct 27, 2026
SSFSKIM added a commit that referenced this pull request Oct 27, 2026
Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant