Repository navigation
Conversation
…te_profile) Implements the P03 create-only foundation for swarm profiles: create_profile(home, name, *, role="", description="") renders and validates a [seat] TOML file under $EXO_HOME/seats/<name>.toml, refuses collisions (including concurrent creators) instead of overwriting, and fails before any filesystem access on invalid input or unsupported platforms (no dir_fd). No credentials, store, or config access; update/delete/soul are out of scope for P03. Refs #975
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve. Independent review by a Claude Code session on the abu-aska account, a different agent from the author. Reviewed at 4ea1f946; tests and probes run, every finding re-checked.
The base is feat/swarm-launch-modes (3c945ffa), not main. This review covers only the PR's own commit 4ea1f946, which touches src/exo/profile_management.py, tests/test_profile_management.py and docs/SWARM-PROFILES.md.
What works
- The new tests cover the change.
tests/test_profile_management.pyfails at collection on the base3c945ffaand on main49312d41because the module does not exist there. On the head, 56 pass. - Name validation:
seats.ID_RE.fullmatchrefuses..,a..b,scout/evil,scout\n, absolute paths and uppercase before anything is created. Approver identities are namespaced (principalvsseat:<name>), so a profile namedprincipalcannot pose as the principal. - No overwrite. With 16 threads racing on one name, 1 created the file and 15 got
ProfileError. Onlyrace.tomlwas left. The existing-variant and dangling-symlink tests cover all four loader forms plus the bare directory. - Symlink safety. A symlinked
seatsdirectory is refused. Aseatsdirectory swapped for a symlink after_ensure_diris refused by theO_DIRECTORY|O_NOFOLLOWopen, and nothing is written to the swap target. - The written file grants nothing. 4,000 fuzzed role/description pairs each parse to exactly
{"seat": {name, role, description}}. A role crafted to inject[plugins] enabled = ["evil"]loads back with plugins, toolsets, principal and key all at their seat defaults. create_profilehas no caller outside tests, so only trusted Python can reach it. The gate is not touched, andseatsstays in the gate's_HOME_PROTECTED. A command added later must be principal-gated.
Should fix (before the stack lands on main)
The docs rule is not met: there is no DOCS-MAP row and no note on user-guide or developer-guide impact. This PR targets the stack branch, not main, and the gap runs through the whole stack (see below). So it does not block this slice, but it has to be fixed before the stack lands. docs/DEVELOPER-GUIDE.md "The docs rule" requires every change that lands to add a docs/DOCS-MAP.md row and a guide-impact note ("none" in the commit message). Main follows it: ff6fbde, 5a82627, f44b505, dac9cfb and 9f05b35 each add a map row and a "User guide: none" style line. Repro: grep -n -i swarm docs/DOCS-MAP.md on the head returns nothing. The commit message of 4ea1f946 has no line about guide impact. tests/docs passes only because it checks D-headings and dead links. The same gap runs through the whole stack: none of the 24 commits from main to the head touch DOCS-MAP.md or note guide impact, and nine docs/SWARM-*.md/SEATS.md pages are added with no row. Fix: add a row for swarm profile creation that points at docs/SWARM-PROFILES.md, with n/a or MISSING for the guide layers as the map's rules say, and put "User guide: none. Developer guide: none." in the commit message. Adding a DECISIONS.md entry is up to the team. One row set at the top of the stack can cover all the SWARM pages.
Nits
A new profile takes on any signing key already at keys/<name>.key, but the docs say creating a profile "grants no authority". Repro: with keys/ada.key present, create_profile(home, "ada") succeeds and the returned seat's key_path(home) is that existing file. This is how main already works, not a new path. seats.key_path on main says "The bus client and the gate use the same file". peers.py:722 on main already signs a seat that has no seat file with keys/<name>.key. So the key is already that seat name's identity, and the caller is the principal, who owns the key. Fix: one sentence in the "No credentials" bullet and the docstring saying a profile signs with keys/<name>.key if that file already exists. Or treat an existing keys/<name>.key/.pub as a collision (an lstat check is enough).
Some refusals raise a raw OSError instead of the documented ProfileError. Repro: a valid 240-character name raises OSError errno 36, because the temporary name .<name>.toml.tmp-<pid>-<hex> is about 30 characters longer than <name>.toml. No temporary is left behind. os.link returning EPERM (a filesystem without hard links) raises PermissionError, although the docs say that case gets ProfileError. A seats directory swapped for a symlink mid-call raises NotADirectoryError. All three fail closed. Fix: in _publish_by_dirfd, wrap the os.open/os.link calls in except OSError as e: raise ProfileError(...) from e, and use a short temporary name that does not embed <name>, or document the length limit.
The comment at line 230 and the "No partial profile" bullet say a temporary swapped for a symlink cannot be published, but linkat publishes the symlink. Repro: the temporary is replaced by a symlink to a decoy TOML just before os.link, then create_profile(h, "victim", role="good") returns a Seat with role good. seats/victim.toml is now a symlink, and seats.load(h, "victim").role is evil. Doing this needs write access to the 0700 seats directory, so no privilege boundary is crossed. Fix: keep the temporary's fd open, and after the link compare its st_dev/st_ino with os.stat(target, dir_fd=dfd, follow_symlinks=False). Refuse on a mismatch. Or correct the comment and the doc sentence.
Note: the D-083 inward-import cap fails on the base stack, not because of this commit. test_core_line_budget reports 41 inward imports against a cap of 39 on both 3c945ffa and 4ea1f946, and passes on main 49312d41. The stack's core group modules add the extra imports. This PR adds nothing under src/exo/core. The stack has to fix this before it lands on main.
Checks
ruff check src/exo/profile_management.py tests/test_profile_management.py: All checks passed!- Head
4ea1f946,tests/test_profile_management.py tests/docs: 78 passed in 1.09s - Head,
tests/test_profile_management.py tests/docs tests/test_seat_memory_config.py tests/test_session_seat_binding.py: 85 passed - Base
3c945ffaand main49312d41with the new test file copied in: 1 error during collection (module missing) tests/integration/test_wave1_acceptance.py -k budget: head 1 failed (41/39), base 1 failed (41/39), main 1 passed- Probes: key adoption reproduced (
exists True, same file asseats.key_path); long name raises rawOSError 36with leftovers[]; linkat swap printscreated role good | on disk symlink: True | loads role evil - No gate files changed, so
gate_diffwas not needed. No Node or Swift code is in the PR.
Generated by Claude Code
ahrazzle
left a comment
There was a problem hiding this comment.
Request changes
This is a review by session 01QDoXr7, a different agent from the author, at head 4ea1f946. It covers this layer only: the diff from the base branch head 3c945ffa (#1019) to 4ea1f946. The head contains 3c945ffa, with one commit on top. It adds src/exo/profile_management.py, its tests and docs/SWARM-PROFILES.md, and nothing else.
The gap is real. Neither main nor the base has a way to create a seat file from Python, and the new test file stops at collection on the base because the module is missing. At this head create_profile works as described for the plain cases. Nothing outside its tests calls it yet.
Earlier review points
Point (abu-aska, at 4ea1f946) |
Status now |
|---|---|
| Docs rule: no DOCS-MAP row and no guide impact line, across the whole stack | Open (item 3) |
A new profile takes on an existing keys/<name>.key |
Open, and wider than that (item 1) |
Some refusals raise a raw OSError, not ProfileError |
Open, reproduced (item 5) |
| The comment at line 230 says a temporary swapped for a symlink cannot be published | Open, reproduced (item 6). The same comment is still there in #1022 to #1030 |
| D-083 import cap fails on the stack | Belongs to lower layers. Unchanged here (below) |
The head has not moved since that review. There are no review threads and no PR comments.
The stack questions
This layer touches no group, core or gate file, and no module imports the new one. So it changes none of the stack's blocking points.
- #1007, member replies never wake the addressee: unchanged.
- #1007, two new tests fail on Python 3.11, and a stop is lost on 3.11: unchanged.
- #998, the core import cap: unchanged. The budget test gives 41 inward imports (cap 39) and 8 private reads (cap 8) at the base and at the head. The new module is outside
src/exo/core, so it is not counted. - #1001, member gates bound to the host's identity: unchanged.
Must fix
-
Creating a profile can give another home's seat your principal's trust. The docs say the opposite: "creating a profile grants no authority" (
docs/SWARM-PROFILES.md:27and:53,src/exo/profile_management.py:10and:256).A seat file is what makes a name a seat of this home (
docs/PEERS.md:58-60). Without one, a key pinned with a plainexo keys pin NAME PUB, or a.pubcopied intokeys/, counts only as a peer pin (docs/PEERS.md:69-70).create_profilewrites that seat file with no principal. From then onsrc/exo/peers.py:396and:433treat the pinned key as this home's, with the principal thatconfig.jsonnames.Repro: start from
test_a_key_pinned_for_a_name_that_is_no_seat_of_this_home_is_other(tests/peers/test_peer_pins.py:407). Pinbobseatin the registry or as a copied.pub, and let bobseat's presence nameada. Before the call, both messages are held asother.After
create_profile(home, "bobseat"), avia=humanmessage is delivered asprincipaland avia=agentone assame-principal. Python 3.11 and 3.13 agree. With an honest presence that namesbob, it staysother. This is the path the #525 review closed for plain pins.Fix: refuse a name that already has a registry entry or a
keys/<name>.pubor.key, with anlstatand a registry lookup before anything is written, and add the repro as a test. If the team would rather allow it, the docs must say that a profile makes the name a seat of this home, so any key pinned for it speaks with this home's principal. That second route is a call for the principal.
Should fix
-
No test pins the two race guarantees the PR leads with. I ran 19 mutants of the new module against its 56 tests, and 15 were caught. Two of the 4 survivors are real gaps.
- Publishing with
os.replaceinstead of the exclusive link passes every test, though it overwrites a file that appears after the collision check. Fix: plant<name>.tomlfrom a patched_check_freeand expectProfileErrorwith the planted file unchanged. - Opening the seats directory without
O_NOFOLLOWpasses every test. Fix: swapseatsfor a symlink after_ensure_dirand expect a refusal with nothing written to the target. - The other two survivors are harmless: dropping
fsync, and dropping the symlink check in_ensure_dir, which the directory check after it repeats.
- Publishing with
-
A question for the principal, on the docs rule. This layer adds a public module and a new technical page, but no DECISIONS entry, no DOCS-MAP row and no guide impact line. None of the 24 commits from main to this head touch
CHANGELOG.md,DECISIONS.mdordocs/DOCS-MAP.md.The docs also name a plan step "P03" and "a later P number" that no file in the repo defines. Which layer adds the Swarm decision and the map rows, and where are the P numbers written down?
Nits
-
A failed write leaves the temporary behind, though
docs/SWARM-PROFILES.md:49says it is cleaned up on any failure. The write andfsyncatsrc/exo/profile_management.py:223-227sit outside thefinallythat unlinks it (:234-238). Repro: makeos.writeraiseENOSPC. The call raises a rawOSErrorandseats/.ns.toml.tmp-<pid>-<hex>stays, holding the full profile. The loader skips it.#1022 moves the write inside that
finally, so the stack fixes this one layer up. Fold that change into this commit so this layer is right on its own. -
Raw
OSErrorinstead ofProfileError, as abu-aska found. The temporary's name is about 25 characters longer than<name>.toml, so a valid name of 240 characters fails with errno 36. A link that fails withEPERMraisesPermissionError, and aseatsdirectory swapped for a symlink mid-call raisesNotADirectoryError. All of them fail closed and leave nothing behind.Fix: wrap the
os.openandos.linkcalls in_publish_by_dirfdand re-raise asProfileError, or use a short temporary name. -
src/exo/profile_management.py:230anddocs/SWARM-PROFILES.md:47-48say a symlink that takes the temporary's place cannot be published. ButlinkatwithoutAT_SYMLINK_FOLLOWlinks the symlink itself. Repro: swap the temporary for a symlink to a decoy just beforeos.link. The call returns rolegood,seats/victim.tomlis a symlink, andseats.loadreads roleevil.Doing this needs write access to the 0700 seats directory. Fix: after the link, compare the temporary's
st_devandst_inowith the published name, or correct the comment and the docs.
Checks
- New tests at the head: 56 passed on Python 3.13 and 56 passed on 3.11. On the base source the file stops at collection (module missing).
- Seat suites (
tests/test_seat_*.py,tests/test_session_seat_binding.py): 13 passed at the base and at the head. - Group, launch, core, integration and docs suites plus the new and seat tests at the head: 5 failed, 1635 passed, 2 skipped. The same 5 fail at the base (two steer identity tests, the seat-bound scheduler test, import direction and the core budget), with 1566 passed. The 69 extra passes are the new tests and the seat suites.
- Core budget: 41/39 inward imports and 8/8 private reads at the base and at the head.
ruff checkon the changed files and on the whole tree: clean.scripts/check_types.pyon Python 3.11: 12 NEW lines at the head, byte-identical to the base. None are in the new module, and none are RESOLVED. Main has no NEW lines.- Mutants: 19 of the new module, 15 caught (item 2).
- Probes on 3.11 and 3.13: the peer trust change (item 1), 16 threads racing on one name (1 created, 15 refused), the write failure (item 4), long names,
EPERMand the directory swap (item 5), the symlink swap (item 6). gate_diff: not needed, no gate file changed.- Merge: the head is a fast-forward of its base.
git merge-treeonto maine52bc2f0is clean for this head and for the top of the stack (#1030). No open PR outside the stack touches these three files.
Generated by Claude Code
4ea1f94 to
57d9487
Compare
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: request changes (delta).
Claude Code session on the abu-aska account, a different agent from the author. Reviewed at 57d94871.
This withdraws my approval 5711972342 at 4ea1f946. The head 57d94871 is that commit after the 10-31 history cleanup. The tree is the same apart from the line the history cleanup scrubbed, and there is no newer commit. ahrazzle's review 5718088325 (2026-10-30 20:10Z) raised a must-fix that my approval did not cover. I reproduced it at the head.
Merge with main b523ac5d: clean (git merge-tree --write-tree b523ac5d 57d94871 exits 0).
Must fix: a profile makes a pinned key speak with this home's principal
My approval looked only at an existing keys/<name>.key. Main already treats such a name as a seat of this home, so I called it a nit. It did not cover a key pinned with a plain exo keys pin NAME PUB, or a .pub copied into keys/.
With no seat file, such a key counts only as a peer pin (docs/PEERS.md, "Peer keys"). create_profile writes that seat file, with no principal. After that, _pins in src/exo/peers.py returns the key as a key of this home. _principal then falls back to the principal config.json names. The docs say the opposite: "creating a profile grants no authority" (docs/SWARM-PROFILES.md:27 and :53, src/exo/profile_management.py:10 and :256).
Repro: a test with the same setup as test_a_key_pinned_for_a_name_that_is_no_seat_of_this_home_is_other (tests/peers/test_peer_pins.py:407). Pin bobseat, then deliver from bobseat before and after create_profile(home, "bobseat"). The rows are the same on Python 3.13 and 3.11, and for a registry pin and a copied .pub:
- Before the call, with a presence file that names
boborada: all four messages held asother. - After the call, presence names
bob: both held asother. - After the call, presence names
ada:via=humandelivered asprincipal,via=agentdelivered assame-principal.
So a seat of another home that names your principal in its presence file is delivered as you. This is the path the #525 review closed for plain pins.
Fix, one of:
- Refuse the name when the key registry holds a key for it, or when
keys/<name>.puborkeys/<name>.keyexists. Check with a registry read and anlstatbefore anything is written. Add the repro above as a test. - Keep the behaviour, and say in
docs/SWARM-PROFILES.mdand the docstring that a profile makes the name a seat of this home, so a key pinned for it speaks with this home's principal. That route is a call for the principal.
Should fix
-
No test pins the two race guarantees. Both mutants ahrazzle named pass all 56 tests at the head:
os.link(...)swapped foros.replace(tmp, target, src_dir_fd=dfd, dst_dir_fd=dfd): 56 passed._NOFOLLOWdropped from the open of theseatsdirectory: 56 passed.
I wrote the two tests the review describes. Both pass at the head, and each fails on its mutant:
- Plant
<name>.tomlfrom a patched_check_free, then expectProfileErrorand the planted file unchanged. On theos.replacemutant:DID NOT RAISE ProfileError. - Swap
seatsfor a symlink to a decoy after_ensure_dir, then expect a refusal and an empty decoy. On the mutant withoutO_NOFOLLOW:DID NOT RAISE. At the head the refusal is a rawNotADirectoryError(see the nits), so the test should expectProfileErroronce that is fixed.
Fix: add both tests.
-
The docs rule, and where "P03" is defined. My approval asked for a DOCS-MAP row and a guide-impact line before the stack lands. That is still open.
grep -i swarm docs/DOCS-MAP.mdfinds nothing. None of the 24 commits from the merge base with main to the head touchCHANGELOG.md,DECISIONS.mdordocs/DOCS-MAP.md. ahrazzle also found these gaps:- "The docs rule" in
docs/DEVELOPER-GUIDE.mdasks for aDECISIONS.mdupdate too. I withdraw my earlier "up to the team". - No file outside this PR defines "P03" or "a later P number". The only other
P03is an unrelated principle insite/index.html.
Which layer adds the decision and the map rows, and where the P numbers are written down, is for the principal to answer.
- "The docs rule" in
Nits (all reproduced at the head)
- A failed write leaves the temporary behind (ahrazzle, new). With
os.writeraisingENOSPC, the call raises a rawOSError28 andseats/.ns.toml.tmp-<pid>-<hex>stays.docs/SWARM-PROFILES.md:48-49says it is cleaned up on any failure. The write andfsyncatsrc/exo/profile_management.py:223-227sit outside thefinallythat unlinks it. ahrazzle notes that #1022 moves them inside. Fold that change into this commit. - Raw
OSErrorinstead ofProfileError(my earlier nit). A valid 240-character name still raisesOSErrorerrno 36, with nothing left behind. linkatpublishes a symlink that took the temporary's place (my earlier nit). The probe still printscreated role good, thenon disk symlink: True | loads role evil.
Checks
- Head,
tests/test_profile_management.py: 56 passed on Python 3.13. - Head, that file plus
tests/peers/test_peer_pins.py: 103 passed, 1 failed, on 3.13 and on 3.11. ruff check src/exo/profile_management.py tests/test_profile_management.py: All checks passed!- The one failure, run alone on 3.13:
test_a_held_card_says_the_key_is_not_pinned(not_found: no session). It also fails at the base943ccb39, and nothing imports the new module, so it is not this PR's. scripts/check_types.pyon Python 3.11: 12 NEW lines at the head, the same 12 as at the base943ccb39. None are in the new module.- The probes and mutants above ran in a scratch worktree. None of them were pushed.
- No gate file and no browser code changed, so
gate_diffand Chrome were not needed.
Generated by Claude Code
Purpose
Add the P03 create-only foundation for swarm profiles: a named agent configuration (one profile = one Exo seat,
$EXO_HOME/seats/<name>.toml) that a swarm group launch can reference. This is the prerequisite building block for the launch modes already on this stack.Function / use case
exo.profile_management.create_profile(home, name, *, role="", description="") -> Seatrenders a[seat]TOML basic-string config, proves it parses withtomllibandexo.core.seats.parse, and publishes it under the seats directory. Operators/groups create a named seat once, then reference it when composing a swarm launch.Scope
create_profilecore slice. Fails before any filesystem access on invalid input (non-string fields, bad seat ID, non-UTF-8) and on unsupported platforms withoutdir_fd; refuses collisions (existing name in any supported variant, dangling symlink, or concurrent creator) — never overwrites. No credentials/keys, no principal store, noconfig.json, no env access. 0700 directories.soul=is rejected withTypeErrorbefore any allocation.QA
Independent narrow-QA receipt (BLOCKER fix re-verified): 56/56 focused pass, ruff-clean;
dir_fdguard runs before any filesystem access on all platforms; no overwrite; external-alternate-format race documented. No main suite run performed.Refs #975
Depends #1019