Repository navigation
P5: a machine key speaks for one ref whatever the route (409 key-held), and one member-email grammar - #338
Merged
Conversation
Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…ocol judgeEntry, entryDevice, isPairedDeviceId and isRpId move byte for byte into apps/org-protocol/src/pairing.ts, exported through index.ts; their input becomes the package-owned structural PendingEntry, which the hub's PendingDevice satisfies. admin.ts imports judgeEntry from org-protocol and re-exports the three it exported before, so its suites and the two test importers are unchanged. pairing.test.ts pins the judges directly: a good entry, a wrong MAC, a wrong class, an already-listed id, a bad id and rpId, and what no state could list. Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…overy directories Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…'s amend runs it before signing successorProblems names, before signing, every check verifySuccessor makes on an ordinary successor but the signatures; stateProblems names the whole-state rules by code, and stateInvariants is now its reading. verifySuccessor's verdicts and their order are unchanged (the vectors replay as before). deployment admin's amend (and propose) refuse a successor with a problem, naming its codes, before anything is signed or kept pending. Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…overy directory Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…ts fails fast verifySuccessor judges the whole state before the root signature, so the problem list stateInvariants built was open to any envelope: 120 copies of one delegation made 7,140 diagnostics. stateInvariants now stops at the first problem and builds no detail. The full diagnostics keep at most PROBLEMS_PER_CODE (8) problems per code, and build each detail as a thunk only for a problem they keep. onDetail counts what is built. Verdicts and their order are unchanged. Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…for unauthenticated input (comment only) Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…r's email is written isMemberEmail is the app hub client's address grammar, moved to the package byte for byte: one @, no space or control character, at most 64 characters before it and 253 after. The hub client reads /api/me through it, unchanged. Strict where an email is written. successorProblems names `email-grammar` for a member that is new, or whose email changed, in the successor; an unchanged member is never judged, so a head that already holds an email outside the grammar can still be followed, and fixed. deployment admin's genesis, the one admin verb that writes a member (the admin, as /api/me names them), refuses an email outside it before the recovery key is made, with nothing written, signed or posted; every other verb's successor already passes successorProblems in amend. Tolerant where one is read, as before: isOrgState takes any non-empty text and verifySuccessor makes no email rule (a test pins that the successor successorProblems refuses verifies once signed); the hub resolves and projects members by any text, lower-cased. The app hub client's /api/me read was already this grammar (O8 M1's review, so a hostile hub can't reflect the token as an email), and stays so. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…-held) The hub kept any key a redeemed machine posted, so a key the head already held reached the admin's listing successor, which successorProblems (key-held-twice) or a verifier then refused. One holder per key (RL5) is now refused at the post, after the existing 201 / 200 / 409 key-posted / 409 ref-taken: - the head holding the key as current under any other holder: a machine of another ref, or a device, a delegation or the recovery key, all of which key-held-twice counts; - the head holding it retired or revoked, whatever the ref. Retired and removed machines' keys still count as held, because the model never lets either be current again: a retired entry stays or moves to revoked (keysAccounted), a state holding a retired key is retired-key-held and one holding a revoked key is refused revoked. A retired key still speaks for its ref's history up to its notAfter (machineSigners), so as anyone's current key again its notAfter would bound nothing; - another enrollment's posted key under another ref: machine_keys rows are never deleted, and the real endpoint mints a fresh key at every enrollment (src/endpoint/enroll.ts), so a repeat across refs is a bug or a forgery, and the two machines could never both be listed. The machine of the posted ref is no other holder: a rename keeps the key and the ref, and the machine enrolls again under the new name with both (O11 M6; relay-fences' rename cases). ref-taken has already held the ref to the poster's name by then. A kept certificate's key is not counted: no verifier refuses a state entry that shares one, and storeCert does not refuse the converse. keepMachineKey is async now (a revoked entry is named by key id), and judges and keeps in one synchronous step after that await, re-checking the poster's enrollment there as storeCert does. heldKeys is exported from org-protocol so the hub reads the state's holders by the package's own rule. admin-verbs' successorProblems case posted m1's key under a twin, which the hub now refuses; it is a holder another signer lists while the owner compares instead, which only the pre-sign check can see. identity.ts and O10's route listing name the new answer. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
The review's one gap: every holder kind the refusal names now has its case, the delegation's included. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…icates both ways The architect's ruling on the open question of e40d88b: one holder per key spans the hub's certificates, in both directions, so posting order never decides which ref holds a key. - POST /machine/key (keepMachineKey) refuses a key a kept certificate holds under another ref, 409 key-held, like the state's holders and other enrollments' keys. - POST /machine/cert (storeCert) refuses a certificate whose key another holder has under another ref, 409 key-held: a machine, device or delegation of the org state, its recovery key, or another enrollment's posted key. A key retired or revoked in the state was already refused first by verifyMachineCert (409 expired, 409 revoked), whatever the ref; another certificate for the key stays 409 conflict. - The same ref is fine both ways: a VM's own key posted under its own ref, before or after its certificate. The certificate's check runs in storeCert's synchronous commit, not its judgment: a machine's key post moves neither the head nor the certificates, so only the commit sees one made during the certificate's awaits. keepMachineKey's sync step reads the certificates likewise, so of two posts at once one is kept and the other refused. The refused certificate reaches its caller as 409 {error: "key-held", message} on POST /machine/cert; mawsd's endpoint provision throws CertRefused ("the hub refused the machine's certificate: 409 key-held"), exits failed, and keeps provisioning.json, whose rerun posts the same certificate and is refused again. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
The architect's ruling: the grammar keeps a hostile hub from reflecting the bearer token as an email, a security reason. With the grammar enforced where an email is written, the strict read can refuse only legacy data, and production has none. A change to the grammar checks the stored emails before it ships. The comment at the read, and isMemberEmail's own, say so, so nobody tolerates it away. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
SSFSKIM
added a commit
that referenced
this pull request
Oct 29, 2026
…tes both ways), one member email grammar, O8 M4a's first two tasks; two tracker rows from its residue Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
This was referenced Oct 29, 2026
SSFSKIM
added a commit
that referenced
this pull request
Oct 29, 2026
…dits.ts refuses bad-email through org-protocol's isMemberEmail, hub-client's EMAIL dropped; email-grammar among the pre-sign codes; the admin suite's twin case as #338 left it Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
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.
A key speaks for one ref, whatever route it came by; one email grammar
Two hardenings of the org's records, ruled by the MAWS architect (P5's spec owner) after M4a's review. Built on P5 O8 M4a's
successorProblemscommits (5935f62, 5922119, 37ce207), which have not landed.(A)
409 key-heldonPOST /machine/keyandPOST /machine/certUntil now the hub kept any key a redeemed machine posted. A key the head already held went on to the admin's listing successor, where
successorProblems(key-held-twice) refused it before signing, or a verifier refused it after. A certificate could likewise certify a key the state or an enrollment held under another ref, and nothing refused that. The hub now refuses both at their posts.The invariant (the architect's ruling): one holder per key spans the hub's records as well as the state, so the order of posts never decides which ref holds a key.
A key is held by another holder when:
key-held-twicecounts all of them. The hub reads the holders through the package's ownheldKeys, now exported.retiredentry stays or moves torevoked(keysAccounted);retired-key-held, and one holding a revoked key is refusedrevoked;notAfter(machineSigners), so as anyone's current key again, itsnotAfterwould bound nothing.machine_keysrows are never deleted, and the real endpoint mints a fresh key at every enrollment (src/endpoint/enroll.ts), so a repeat across refs is a bug or a forgery.machineSigners,machineOwners).The same ref is fine, both ways. O11 M6's rename keeps the key and the ref, and the machine then enrolls under the new name with both (
relay-fences.test.ts's rename cases, which fail if this is counted). A VM's own key posted under its own ref is taken before or after its certificate. On/machine/key,ref-takenhas already held the ref to the poster's name by then.POST /machine/key(keepMachineKey) checks after its existing answers:201kept,200the same again,409 key-posted,409 ref-taken. It is now async, because a revoked entry is named only by key id. After that one await, it re-checks the poster's enrollment, judges and keeps the key in one synchronous step, asstoreCertdoes.POST /machine/cert(storeCert) checks in its synchronous commit, not in its judgment. A machine's key post moves neither the head nor the certificates, so only the commit sees one made during the certificate's awaits. Of two posts at once, one is kept and the other refused. Its existing answers come first:verifyMachineCert(409 expired,409 revoked), whatever the ref;409 conflict.How a refused certificate reaches its caller.
409 {"error": "key-held", "message": "the certificate's key is <holder>: certify a fresh key"}.endpoint provision(src/endpoint/provision.ts,settle) throwsCertRefused: "the hub refused the machine's certificate: 409 key-held". The command exits failed with that line.provisioning.jsonis kept, so a rerun posts the same certificate and is refused again. A VM recreated with a fresh key provisions.enrollDelegatedthrows "the certificate was refused: 409 {…}".A refused machine key reaches mawsd's
endpoint enrollas "the hub refused the machine's key: 409 key-held".Both answers are named in
apps/desk-hub/src/protocol/identity.ts(MACHINE_KEY_PATHandMACHINE_CERT_PATH), andkey-heldis in O10's route listing (docs/doperpowers/plans/2026-10-27-p5-o10-endpoint.md). Nothing reads either route's codes by name, so no client changes. sminos never calls these routes. O11's own decision entry (line 601) is a dated record, left as written.M4a's admin case "a machine posting a key m1 holds" posted m1's key under a twin, which the hub now refuses. That case is now a holder that another signer lists while the owner compares the posted key, which only the pre-sign check can see. Its assertion is unchanged.
(B) One email grammar
isMemberEmail(org-protocol,names.ts) is the app hub client's grammar, byte for byte:/^[^\s@\p{Cc}]{1,64}@[^\s@\p{Cc}]{1,253}$/u.src/main/org/hub-client.tsnow uses it.successorProblemsnamesemail-grammarfor a member who is new, or whose email changed, in the successor. An unchanged member is never judged, so a head already holding an email outside the grammar can still be followed, and fixed.deployment admin genesis, the one admin verb that writes a member (the admin, as/api/menames them), refuses an email outside the grammar before the recovery key is made. Nothing is written, signed or posted.successorProblemsinamend, and none adds a member or changes an email.isOrgStatetakes any non-empty text, andverifySuccessormakes no email rule. A test pins that the successorsuccessorProblemsrefuses for its email verifies once signed.registry.tsresolve,org-chain.tsprojectMembersandsubmit)./api/me, for security (the architect's ruling).hub-client.me()takes the email only in this grammar, as it has since O8 M1's review, so a hostile hub can't reflect the bearer token as an email.hub-client.ts:134) andisMemberEmailcarry a comment saying so, so nobody tolerates it away.Sequencing with M4a
This branch sits on M4a's
successorProblemscommits. Whichever of this PR and M4a lands second switches M4a's own composer (src/main/org/edits.ts,member.addandmember.email) toisMemberEmail. The same PR addsemail-grammarto O8's §M list of pre-sign codes. Nothing here touches M4a's later work or the O8 plan.Residue
OrgAdmincomposes withoutsuccessorProblems.apps/desk-hub/deploy/org-admin.ts, staging's test device, composes a throwaway org's genesis, and successors such as acceptance's member add. It signs and posts with no pre-sign check and no email grammar, so a broken successor surfaces as the hub's refusal. The architect writes the tracker row at landing.keepMachineKey's key-id await. The re-check there isstoreCert's pattern.Deploy
The hub change takes effect only with a production deploy of
desk-hub, which is the owner's. Nothing here ran against production.Gates
identity.ts,names.tsandorg-state.ts.successor-problems(66) and the app'shub-client(4);org-enrollment(26),org-delegations,relay-fences,relay,history-attestations,app-connection,deploy/admin-verbs(39), anddeploy/adminwithprotocol(241).Review
Commits
isMemberEmail), strict where a member's email is written.POST /machine/keyrefuses a key another holder has (409 key-held)./machine/keyrefuses a key a certificate holds under another ref, and/machine/certa certificate whose key another holder has./api/me's email stays strict, and the code says why.Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)