Repository navigation
Conversation
Add a bounded preflight that answers one question before any engine is built: would two members of a group write into the same folder or the same git working tree? - `exo.core.group_workspace` provides `validate_workspaces` and `git_worktree_root`. Each member's path must be an absolute existing directory; pairwise overlap is decided twice, by canonical path comparison and by filesystem identity (`st_dev`, `st_ino`), so a case alias or second directory entry naming one folder is caught. Nesting is likewise decided by `is_relative_to` and by comparing a member's identity against the other member's folder and every ancestor of it. - A working tree is identified by the nearest `.git` marker (folder for a normal checkout, file for a linked worktree), `lstat`-ed only. No git subprocess runs, and no `.git` contents are read. - Any probe that cannot be made (permission error) fails closed with `WorkspaceError`: "I could not compare these" is never read as "they differ". - `GroupComposition(..., workspace_check=True)` runs the check inside the existing pre-construction validation, over each member's effective cwd (the seat's own folder when it exists, else the injected cwd, else the process folder), so a refusal raises `CompositionError` before any plugin load or engine construction. - `workspace_check` is strict: any non-bool raises `CompositionError`. Default behaviour is unchanged: the flag is off, nothing is locked, nothing is sandboxed, no folder is created, and no engine cwd changes. The check reads paths only, and it does not cover every G10 condition. Docs in `docs/SWARM-WORKSPACES.md` and `docs/SWARM-COMPOSITION.md`. Refs #975
abu-aska
left a comment
There was a problem hiding this comment.
Comment review of #1039 at head 11993ba. I verified the new module and the wiring by reading the diff; I did not run the tests (no local checkout here).
Verified:
- The preflight is opt-in and off by default:
GroupComposition(..., workspace_check=True)is the only path that calls it, and the default-flag test covers the flag-off case. - Refusal happens in
__call__after the unknown-member check and before any_member_bindingcall, so no plugin load or engine construction precedes it, matching the PR description. validate_workspacesfails closed: a probe error in_canonical_dir,git_worktree_root,_same_dir, or_stat_identityraisesWorkspaceErrorinstead of being read as "different", andGroupComposition._check_workspacesmaps that toCompositionError.- The
.gitmarker is onlylstat-ed ingit_worktree_root, never opened or parsed, and no git subprocess is used anywhere in the new module. - Separate linked worktrees of one repo are accepted (each has its own
.gitmarker), while two members in one working tree are refused, and nesting is checked both by canonical path and by(st_dev, st_ino)ancestor identity in both directions. workspace_checkis strict-bool: a non-bool raisesCompositionErrorbefore anything else in__init__.
Not approving yet, for checkable reasons:
- CI is red on this head:
test (ubuntu-latest, py3.11)andtest (ubuntu-latest, py3.13)failed andtypesfailed, whilelintpassed and both macOS jobs were still queued. The PR body claims 76 local passes for the two touched test files, but the failing CI step is only named "Root suite failure", so the failing test (or type error) is not identifiable from the check summary. Please surface the failing test names and thecheck_types.pyerror, and reconcile them with the local-pass claim before this is merged. - Relative seat cwd edge in
GroupComposition._effective_cwd: a relativeseat.cwdthat happens to exist as a directory relative to the process cwd is returned verbatim (str(p)), andvalidate_workspacesthen rejects it as non-absolute. The testtest_workspace_check_relative_seat_cwd_is_dropped_not_usedsays a relative seat cwd is dropped, not used. Please confirm whatCoreEnginedoes with a relative seat cwd: if the engine drops it,_effective_cwdshould drop it too (only accept an absolute seat cwd); if the engine uses it, the preflight should resolve it rather than reject a folder the member would actually use. Either way the current code and the test name disagree for the exists-relative-to-process-cwd case. - Minor doc check:
docs/SWARM-COMPOSITION.mdsays the preflight runs "after member validation" and for a one-member group too. That matches the code (unknown-member check first, then the preflight for any member list), but the one-member path skips the identity-chain probe entirely (chainsis only built whenlen(names) > 1), so a one-member group's check is its own path checks only. That is fine, but worth one sentence indocs/SWARM-WORKSPACES.mdso a reader does not expect an identity probe for a lone member.
No merge concern on the shape of the change itself: nothing is created, locked, or rewritten, and the returned mapping is immutable.
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 11993ba2; tests and probes run, every finding re-checked.
Scope: commit 11993ba only (git diff c91ba801..11993ba2, 6 files, +1008/-3). The head has not moved since the review started.
What works
- The new tests test the change. On base c91ba80 with the head's test files, both files fail to collect (
exo.core.group_workspaceis missing). With only the new module copied onto base and base'sgroup_composition.py, 14 of the 15 new composition tests fail. The 15th,test_workspace_check_default_off_rejects_nothing, passes on base by design. On the head:75 passed, 1 skipped. The skip is the real case-insensitive filesystem test on Linux; the mocked twin runs. - The default path is unchanged. With the flag off, the only new code that runs is
isinstance(workspace_check, bool)on a keyword-onlyFalse, plus oneif. All base composition tests pass unchanged on the head. Probes with the flag off compose exactly as before: relative, NUL and~usercwds are all accepted, as on base. - The check runs before any construction. It runs in
__call__after the unknown-member check and before_member_binding, plugin discovery,CoreEngine(...)andclaim_writer().c.engines == {}after every refusal. - The effective cwd matches the engine.
_effective_cwdhas the same logic asEngine._seat_cwd(seat) or cwd or os.getcwd(). Group member sessions are inserted without a cwd (GroupStore.create), so tools useengine.cwd. Tools expand~(registry.py:107-108), so expanding it in the preflight agrees with them. - Path probes I ran:
b/../avsa-> refused, "share the folder".b/../a/subvsa-> refused, "overlap".- A symlink to a descendant -> refused, "overlap".
- A dangling
.gitsymlink marker -> counted as a worktree (lstat), so two folders under it are refused. C:\work\aand a UNC path -> refused, "not absolute".- NFC vs NFD names on ext4 (really two folders) -> accepted. On a normalization-insensitive filesystem the identity check covers it.
- Error messages carry only member names and the given or canonical paths. The marker is only
lstat-ed and no file content is read, so nothing secret can leak. - D-083: the scorecard is 41 inward imports / 8 private reads on both base and head. The only new import is core -> core (
exo.core.group_workspace). No new inward import and no new private read. - mypy:
group_workspace.pyis clean.group_composition.pyhas the same 6 errors as base, with only the line numbers shifted. There is no new error on this commit's lines.
Should fix
- A bind mount of a member's subfolder passes the check, while the module and
validate_workspacesdocstrings say a bind mount "cannot slip through".- Repro, real bind mount in a private mount namespace:
mount --bind a/sub c, thenvalidate_workspaces({'x': a, 'y': c})-> ACCEPTED, althoughcanda/subhave the same inode. - Cause: the identity chain walks only the path's own parents, never the source's parents.
- The PR body excludes bind mounts. Fix the two docstrings to match it, and list "an alias of a descendant (bind mount, second directory entry)" under "What it is not" in SWARM-WORKSPACES.md.
- Repro, real bind mount in a private mount namespace:
- A NUL byte or unknown
~userin a cwd raises ValueError or RuntimeError instead of WorkspaceError or CompositionError.- Repro,
GroupComposition(..., workspace_check=True):cwd=str(b)+'\x00'->ValueError: lstat: embedded null character in path.cwd='~nosuchuser_zz/w'->RuntimeError: Could not determine home directory.
- It still fails closed: nothing is built. But it breaks the documented "failures raise CompositionError".
- Fix: move
expanduser()inside thetryin_canonical_dir, mapValueError/RuntimeErrortoWorkspaceError, and do the same for the seat path in_effective_cwd. Add two test rows.
- Repro,
- Docs rule (before the stack lands on main): no DECISIONS.md entry, no DOCS-MAP row for
docs/SWARM-WORKSPACES.md, no CHANGELOG line, and no "user guide: none / developer guide: none" in the commit message.git diff --staton those three files is empty, andgrep -c SWARM docs/DOCS-MAP.mdis 0 (the gap is shared with earlier stack commits).
Nits
test_git_marker_contents_are_never_readdoes not detect a read. A mutant that callsmarker.read_text()after thelstatstill passes (1 passed), because the.gitfile stays readable under a 0o500 folder. Monkeypatchopen/os.open/Path.read_textto raise instead.test_workspace_check_relative_seat_cwd_is_dropped_not_usedsays the engine ignores a relative seat cwd, but it uses one that exists. Withrel/under the process cwd, the engine uses'rel'when the flag is off. With the flag on, the composition is refused with "not absolute". That is fail-closed and documented, but the docstring is wrong and the existing-relative case is not tested.- The PR body says
76 passed. On Linux it is75 passed, 1 skipped.
Notes (no change needed for this PR)
- One-shot check (TOCTOU). The canonical mapping is discarded, and the engine resolves
seat.cwdagain (is_dir) a moment later. A seat folder removed in between would fall back to the injected cwd unchecked. The docs already call this a one-shot check, not a lock. - No check for a workspace inside the exo store or a secret folder. That is out of the stated scope; store writes are the gate's job.
- Nothing in the product turns the check on yet.
group_launch.pydoes not passworkspace_check, so it is opt-in only for direct hosts.
Checks
ruff checkon the 4 touched Python files:All checks passed!- Head:
tests/test_group_workspace.py tests/test_group_composition.py:75 passed, 1 skipped in 4.51s - Base c91ba80 + head tests:
2 errors during collection. Base + new module + head composition tests:14 failed, 19 passed. tests/test_group_*.py5x idle:324 passed, 1 skippedeach time. 5x under 3 busy CPU loops:324 passed, 1 skippedeach time.tests/docs/test_docs_map.py: passed.test_core_line_budget: fails identically on base and head (41 inward product imports (cap 39)), inherited.- mypy 2.4.0 (
--python-version 3.11) on the touched modules: 6 errors on base, the same 6 on head, none ingroup_workspace.py. - CI on 11993ba: lint green. The test jobs (ubuntu/macOS, py3.11/3.13) and
typesare red. These are the inherited collection error (tests/agents/test_delegate_routes.py:ModuleNotFoundError: No module named 'test_tiers', the same on base) and the inherited mypy baseline, not this commit.
Generated by Claude Code
11993ba to
9837200
Compare
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve (re-verification at the rewritten head). Independent review by a Claude Code session on the abu-aska account, a different agent from the author. The exo history cleanup (discussion #1045) rewrote this branch, so my approval at 11993ba2 no longer covers the head. This review is for 98372003.
- Same content as the tree I approved. I compared the approved commit
11993ba2with the rewritten head98372003.git diffbetween them changes onlyskills/github-pr-audit/SKILL.md, the one line the cleanup scrubbed. Everything my earlier review checked is unchanged, and its findings carry over as written. - No removed material. I checked this without relying on any list of removed objects. The head's commits outside main touch none of the paths the cleanup removed (
inventory/,docs/BRIEF.md,scripts/deploy-site.sh). They add no/Users/home path, and no commit message contains one. The head'sskills/github-pr-audit/SKILL.mdis not the old, unscrubbed version. - Clean ancestry. I fetched the head into a fresh clone of the rewritten repository. Its 33 commits outside main share main's root commits. Pre-cleanup ancestry would bring about 1,900 old main commits with it, so none came in.
- Merge: merges cleanly with the rewritten main
ef4d7252. - CI was re-triggered on this head after the cleanup. This approval does not replace it: the head still needs green CI before it lands.
Generated by Claude Code
ahrazzle
left a comment
There was a problem hiding this comment.
Approve
This is a review by session 01QDoXr7, a different agent from the author, at head 98372003. It covers this layer only: the one commit on top of the base branch head a658d37a (#1038). That commit touches 6 files.
The gap is real at the base. There, three members whose engines all resolve to one folder compose without a word, and GroupComposition(..., workspace_check=True) raises TypeError. At the head, the same group with the flag on is refused with CompositionError before any engine is built. With the flag off it composes as before.
This layer adds no test failure and no blocking point of its own. Nothing outside tests turns the flag on yet. src/exo/group_launch.py:152 builds GroupComposition without it. The items below should be fixed before the stack lands on main.
Earlier review points
abu-aska reviewed at 11993ba2 (a comment, then an approval). The history cleanup rewrote that head into 98372003, and abu-aska approved again there. The two trees differ only in the one cleaned line of skills/github-pr-audit/SKILL.md.
| Point (abu-aska) | Status now |
|---|---|
| CI is red | Inherited. At 98372003, ubuntu 3.11, ubuntu 3.13 and macOS 3.11 stop at collection on tests/agents/test_delegate_routes.py (No module named 'test_tiers', from #1030). macOS 3.13 is still queued. So the new tests never ran in CI. types fails with the base's NEW list. Lint passes. |
| A relative seat cwd that exists is used by the engine but refused by the preflight, and the test name says it is "dropped" | Open (Nit 1) |
docs/SWARM-WORKSPACES.md should say a lone member gets no identity probe |
Open (Nit 2) |
| A bind mount of a subfolder passes, though two docstrings say it cannot | Open. Reproduced, with one more case (Should fix 1) |
A NUL byte or an unknown ~user in a cwd escapes as ValueError or RuntimeError |
Open. Reproduced on Python 3.11 and 3.13, with two more cases (Should fix 2) |
| Docs rule: no DECISIONS entry, DOCS-MAP row or guide impact line | Open (Should fix 4) |
test_git_marker_contents_are_never_read cannot see a read |
Open. Confirmed with a mutant (Nit 3) |
| The PR body says 76 passed | Open (Nit 4) |
The stack questions
- Core import cap (#998): 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 imports only the standard library.
- Member gates bound to the host's identity (#1001): unchanged. The preflight runs before
_member_bindingand does not touch the plugin or gate binding. - #1007 items 1 to 3 (a member reply wakes nobody, two tests fail on Python 3.11, a stop lost on Python 3.11): unchanged. This layer does not touch the conversation, runtime or host code. On Python 3.11 the same two conversation tests fail at the base and at the head.
- #1038's open points (no test covers the conversation turn slot, a stale "documentation-only" sentence): unchanged. This layer does not touch the turn slot or its docs.
Should fix
-
src/exo/core/group_workspace.py:146-147says a bind mount "cannot slip through" the nesting check, and:123-124makes the same claim. A bind mount of a subfolder does slip through, and the PR body says bind mounts are not covered.- Repro: in a private mount namespace, bind-mount
repo/subatmnt, with a.gitfolder inrepo.validate_workspaces({"a": repo, "b": mnt})is accepted, thoughbwrites insidea. - One more case:
{"a": repo/other, "b": mnt}is also accepted, though both sit in one working tree. - Only the same-folder case is caught:
{"a": repo/sub, "b": mnt}is refused. - Fix: drop "a bind mount" from those two docstrings and add bind mounts to "What it is not" in
docs/SWARM-WORKSPACES.md.
- Repro: in a private mount namespace, bind-mount
-
Some bad cwds escape as a bare exception, not as
CompositionErrororWorkspaceError.docs/SWARM-COMPOSITION.md:54says failures raiseCompositionError.docs/SWARM-WORKSPACES.md:7-8saysvalidate_workspacesreturns or raisesWorkspaceError.- Repro: a seat cwd whose last part is 300 characters long. With the flag off, the result is
CompositionError: ... [Errno 36] File name too long. With the flag on, a bareOSErrorescapes fromPath.is_dir()atsrc/exo/core/group_composition.py:145. - abu-aska's cases hold too. An injected cwd with a NUL byte gives
ValueError.~nosuchuser/was the injected or the seat cwd givesRuntimeError. - The public function has the same gap.
validate_workspacescalled directly with a NUL byte or an unknown~userraisesValueErrororRuntimeError, notWorkspaceError. - All of these hold on Python 3.11 and 3.13. It still fails closed, and nothing is built.
- Fix: in
_canonical_dir(group_workspace.py:71-82), moveexpanduser()inside thetryand mapValueErrorandRuntimeErrortoWorkspaceError. In_check_workspaces(group_composition.py:149-154), also map anOSError,ValueErrororRuntimeErrorfrom_effective_cwd. Add test rows.
- Repro: a seat cwd whose last part is 300 characters long. With the flag off, the result is
-
The docs do not match the code in two places.
docs/SWARM-WORKSPACES.md:85-86says the preflight "does not re-implement" the engine's seat cwd rule and runs over cwds the host "has already decided on".GroupComposition._effective_cwd(group_composition.py:135-147) is a copy ofEngine._seat_cwd.docs/SWARM-COMPOSITION.md:53-54says members in one working tree are refused "(nested worktrees included)". That holds only when one member's folder holds the other's.docs/SWARM-WORKSPACES.md:71-72says a nested checkout counts as its own tree.- Probe, with the flag on:
outer/srcbeside a nested checkout atouter/vendor/lib, or beside a linked worktree atouter/wt, is accepted. - Fix: one sentence each.
-
The docs rule is not met, and this needs the principal.
- The commit adds a new core module and a new technical doc, but no DECISIONS entry, no DOCS-MAP row for
docs/SWARM-WORKSPACES.md, and no "user guide: none" line in the commit message. No command passes the flag, so no CHANGELOG line is needed. No earlier Swarm layer has these either. - Question: is G10 an approved policy, and which decision records it? No doc in the repository defines G10, and the PR says this is not the full G10 policy.
- Question: should the launch path (
group_launch.create) take the flag, or stay off for every user path until the rest of G10 lands? If it takes the flag, note that the owner's own engine is not part of the check.
- The commit adds a new core module and a new technical doc, but no DECISIONS entry, no DOCS-MAP row for
Nits
tests/test_group_composition.py:395is named..._relative_seat_cwd_is_dropped_not_used, but an existing relative seat cwd is used. Repro: withrel/cwdunder the process folder, the engine runs inrel/cwdwith the flag off, and the check refuses it as "not absolute" with the flag on. It fails closed. A mutant that drops every relative seat cwd also passes all tests, so neither behaviour is pinned.docs/SWARM-WORKSPACES.mdshould say a lone member gets no identity probe.group_workspace.py:194builds identity chains only for two or more members.tests/test_group_workspace.py:403-410cannot see a read of the.gitmarker. It only makes the folder read-only, so the file stays readable. Repro: a mutant that reads the.gitfile right after thelstatpasses all 75 tests.- The PR body says 76 passed. On Linux it is 75 passed and 1 skipped. The skip is the real case-insensitive filesystem test.
Checks
All runs below are mine, at 98372003 and its base a658d37a.
- The two new test files at the head: 75 passed, 1 skipped, on Python 3.13 and on 3.11.
- The new tests at the base: both new test files fail to collect. With only the new module added to the base, 14 of the 15 new composition tests fail. The 15th checks that the flag is off by default and passes by design.
- 18 mutants of the new code (fail-open probes, same tree, nesting, flag wiring, effective cwd, check order, error mapping, a marker read, a relative seat cwd): 15 are caught. The path-nesting mutant survives because the identity check covers it. The other two back Nit 1 and Nit 3.
- Touched suites on Python 3.13 (the group test files, three related files,
tests/core,tests/integrationandtests/docs): head 5 failed, 1,834 passed, 3 skipped. Base 5 failed, 1,777 passed, 2 skipped. The same 5 fail on both (steer x2, scheduler, import direction, budget). - The same suites on Python 3.11: head 7 failed, 1,832 passed, 3 skipped. Base 7 failed, 1,775 passed, 2 skipped. The 2 extra failures on both are #1007's conversation tests. On both Pythons the 57 extra passes and 1 extra skip are the 58 new tests.
- The one test that uses a real case-insensitive filesystem skips on Linux, and CI has not reached it on macOS. I could not mount one here. The mocked identity tests cover the same logic.
ruff checkon the whole tree and on the 4 changed Python files: clean.git diff --check: clean.ruff format --checkwould reformat the 4 changed files, but the 2 older ones were already unformatted at the base, and CI does not run it.- Budget test: counted lines go from 18,866 to 19,140, with no ceiling (D-083). Both structure tests fail the same way at the base and the head.
scripts/check_types.pyon Python 3.11: the head and the base give the same 15 NEW lines, all from lower layers, and RESOLVED is empty.- Probes through the real
GroupCompositionat the base and the head, on Python 3.13 and 3.11: a shared folder, a relative seat cwd, nested and linked checkouts, a stray.gitfile, a too-long seat cwd, NUL bytes and an unknown~user. NUL bytes, an unknown~user, too-long paths and a symlink loop also went tovalidate_workspacesdirectly. A bind-mount probe ran in a private mount namespace. - gate_diff: not needed. No gate file is touched.
- Merge: the head is one commit on its base, so it lands as a fast forward.
git merge-tree --write-treeof mainef4d7252and98372003is clean, so the whole stack still merges onto main. - History: I fetched the head into a fresh clone of the rewritten repository. No pre-cleanup commit is reachable from it, and no commit message or added line in the stack holds a home path.
- No open PR is stacked on this branch, and no other open PR adds a workspace check.
Generated by Claude Code
What this adds
An opt-in preflight for group composition that answers one question before any engine is built: would two members of the group write into the same folder, or into the same git working tree? If the answer is yes, the group is refused.
This is not a lock, a sandbox, or a new default. The flag is off unless a host asks for it.
How it decides
Each member's effective working folder is resolved the same way the engine resolves it: the seat's own folder when it exists, else the injected
cwd, else the process folder. That folder must be an absolute path to an existing directory.Two folders are then compared in two ways:
is_relative_toin either direction).st_dev,st_ino), gathering the folder's own identity plus every ancestor's. A pair overlaps when one member's folder identity appears in the other's ancestor chain. This is what catches a case alias on a case-insensitive filesystem (Repovsrepo/sub), and a second path to one folder, which plain string comparison misses.A working tree is found by walking up from the resolved path to the nearest
.gitmarker — a folder in a normal checkout, a file in a linked worktree. Two members in separate worktrees of the same repository are accepted; only overlap is refused. The marker is only everlstat-ed, never opened or parsed, so no config, hooks, or other contents of an unknown.gitare read.No git subprocess is run anywhere in the check.
The check fails closed. When a probe cannot be answered (a permission error, an unexpected
statfailure), it raisesWorkspaceErrorrather than guessing. "I could not compare these" is never reported as "they differ".workspace_checkis a strict bool: passing anything else raisesCompositionErrorinstead of being read as truthy.Where it runs
GroupComposition(..., workspace_check=True)folds the preflight into the validation that already happens before construction, so a refusal raisesCompositionErrorbefore any plugin is loaded or engine is built. No partial construction is left behind.What did not change
What it does not cover
This is a narrow path-overlap check, not the full G10 policy. It deliberately does not attempt to reason about symlinks resolved after the check, bind mounts, network shares whose identity can change, or writes that escape a working folder at runtime.
Verification
76 passedfortests/test_group_workspace.pyandtests/test_group_composition.py.ruff checkon the four touched Python files: all checks passed.Tests cover: same folder, nesting in both directions, case alias on a case-insensitive filesystem, separate worktrees accepted, same worktree refused, relative and missing paths, fail-closed on probe error, strict-bool rejection, and unchanged default behaviour with the flag off.
Refs #975