Skip to content

P5 O4 M1: route D's grant custody (U7) as library code - #399

Merged
SSFSKIM merged 10 commits into
masterfrom
p5-o4-m1
Oct 31, 2026
Merged

SSFSKIM merged 10 commits into
masterfrom
p5-o4-m1

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 31, 2026

Copy link
Copy Markdown
Owner

P5 O4 M1: route D's grant custody (U7), built as library code

This is M1 of docs/doperpowers/plans/2026-10-31-p5-o4-services.md, the first milestone of P5's child O4. Behaviour does not change: nothing composes the new modules yet, the wire is untouched, and main still writes format 1 under Electron's safeStorage.

  • src/services/connectors/custody.ts. fileKeyCustody(directory) keeps route D's grants under a 32-byte key file that the machine holds.
    • The key is created at an exclusive temporary file (O_CREAT|O_EXCL|O_NOFOLLOW, mode 0600) and linked into place.
    • The key must be exactly 0600, a regular file, this uid's and 32 bytes. The directory is tightened to 0700, and refused when it is a link or another uid's.
    • Records are sealed with AES-256-GCM: a fresh 12-byte nonce, a 16-byte tag, and the connection id as AAD.
    • The Time Machine exclusion runs through O10's helper, moved to src/shared/fs/backup-exclusion.ts. While the key.excluded marker is absent it is retried once per load. It is a no-op off darwin, and a failure never fails the key.
  • src/main/connectors/oauth-store.ts. The store writes line 1 as the format its sealer names (Electron /1, the file key /2). A file of another format reads unreadable, as before. list() reads formats before it asks the sealer, so foreign files are listed without one.
  • src/main/connectors/legacy-custody.ts. listLegacy and adoptLegacy form a one-pass adoption driver.
    • It checks available(), then runs a probe round trip through the sealer. A failed probe stops the pass.
    • After a probe that passes, a damaged or malformed record is left and the pass goes on.
    • The driver never writes or deletes a file. The conditional replacement is the machine's, in M2.
  • src/shared/connectors/{sealer,oauth-types}.ts. These are the shared contracts; oauth-types was moved with git mv. Lint rules A and B hold.
  • Spec record. Decision Log D32 to D36. D32 and D34 are as the architect answered them.

Validation Evidence

  • Class 1a is green on head 7b7061223 (tree 66c07bcc0426a6824ff3c0400e037f86e8810e63). Command: scripts/ci-gate.sh <wt> --gates static,unit,probes --class1a pool --runner macos --peer none. Result: ci-gate: run 41198687728 success, https://github.com/SSFSKIM/MAWS/actions/runs/41198687728. The jobs static, probes and unit 1/4 to 4/4 all succeeded.

  • The earlier run 41197010126 on 224b87d85 failed static. The maws-app secret scan's generic-api-key rule read an import list in oauth-root.ts as a key. Commit 438924398 reorders the import. node --test .github/scripts/maws-app-scan.test.mjs then passed 8 of 8 on the committed tree.

  • Focused suites, run on the MacBook:

    Suite Result
    custody 24/24
    legacy-custody 13/13
    oauth-store 31/31
    oauth-root 11/11
    other connectors, keys and backup-exclusion files passed

    pnpm typecheck and eslint on the touched files exit 0.

  • unit:darwin is not run. None of the 17 darwin-guarded unit files imports a changed module (checked by grep over their imports).

  • Task review: Approved, with no Critical or Important findings. The reviewer read the custody as a credential store. Its one Minor, a malformed v1 file uncounted, is fixed in 7b7061223.

Residue

None.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)

… and the record types on neutral ground

The sealer interface, the safeStorage interface, the e2e custody facts and the two format constants live in
src/shared/connectors/sealer.ts; the record types move to src/shared/connectors/oauth-types.ts and O10's backup
exclusion helper to src/shared/fs/ (git mv), so main's legacy reader and the services library share them without
importing each other (D20, D5). The store writes sealer.format on line 1 and hands the sealer the connection id; a
file of another format stays unreadable, read without the sealer, and list() reads every format line before it asks
for availability. The Electron sealer names maws-connector-oauth/1 and the e2e guard keeps its sealer's format, so
main's store still writes v1: no behaviour changes.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
src/services/connectors/custody.ts: fileKeyCustody(directory), a ConnectorOAuthSealer of format
maws-connector-oauth/2 over <directory>/key, 32 random bytes made on first use at an O_EXCL|O_NOFOLLOW temporary
linked into place (one key under racing first uses, never a short one after a crash), 0600 in the 0700
directory, the directory excluded from Time Machine once before the key is linked and key.excluded recording it.
A key of another mode, a link, another uid's, not a regular file or of the wrong length is refused, never
replaced. Seals AES-256-GCM, a fresh 12-byte nonce, the connection id as associated data. Nothing imports it
until M2. The store over it is pinned in main's store suite (format 2, a copy under another id unreadable, a
profile's format 1 files listed unreadable with no key made).

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
src/main/connectors/legacy-custody.ts: listLegacy(directory) names the format 1 files from their first line,
with no sealer; adoptLegacy({directory, sealer, adopt, log}) asks the sealer's availability once, opens each
format 1 record and hands it to the injected adopt, never writing or deleting a file, and logs the counts. It
stops at the first record the sealer cannot open while none has opened (a denied Keychain is not retried in
the launch); once one has opened, a failure is that record's damage and the pass goes on. Nothing composes it
until M2.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…s format; a key removed as it was linked refuses as missing

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
… creation, the exclusion retried while unmarked, the store-over-custody cases' home); §B and M2's Touches name where the Electron sealer lives

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…ion's pass, D34's retry a no-op off darwin and never failing the key (the architect's answers)

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…d while key.excluded is absent (D34)

An existing key with no marker gets the exclusion asked once per custody instance, at its first key read, and
the marker written on a true answer; with the marker present it is never asked. A false or failed answer is
logged and the key is still made or used.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…exclusion that throws never fails the key

adoptLegacy seals and opens a fixed probe through the given sealer after available(): a failed round trip
(a throw or a different text) stops the pass with every record left and none opened; after a passing probe a
record that does not open is that file's damage, left unopened wherever it sorts, and the pass goes on (D32's
rule replaced). The custody catches a synchronous throw from excludeFromBackup as it does a rejection, and a
test pins the default helper as a no-op off darwin (nothing spawned, no marker).

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…can's generic-api-key rule does not read it as a key

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…ped, by the adoption

readLegacy tells a file gone or no longer format 1 (forgotten or adopted since the listing: skipped) from one
that still starts with the format 1 line but whose envelope is not the store's (no body, a line too many, over
the store's bound): left under its own reason, malformed, never handed to the sealer.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM
SSFSKIM merged commit cfb59ea into master Oct 31, 2026
SSFSKIM added a commit that referenced this pull request Oct 31, 2026
…3239a67, Outcomes and retrospective written; P5 Decision Log 169 records wave 2's first landings (#398, #399, #401), their cadence and the owner's answers; the ledger and the tracker gain their rows

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