Repository navigation
fix(cycle): let read-only stages write only inside their $TMPDIR - #273
Conversation
Since #269 a review, rereview or issue review could write no file, so the comment body its skill writes to $TMPDIR/pr-comment.md for --body-file could not exist and no review could publish. The hook now allows those stages to edit paths that resolve strictly inside the dispatch's TMPDIR, and allowed_tool_patterns grants one Edit(//<tmpdir>/**) rule so Claude's default permission mode approves the same write. The repository, .git, Git's configuration, sibling temporary directories, '..' and symlinks out of TMPDIR stay refused. Closes #272
Code Cycle initial review[CCR-20261019-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2Verdict: Summary and scopeReviewed the full accumulated diff The fix is correct for its stated goal (#272): a non-writing stage (
Findings[REV-001] · medium · open · - · blocks:no — The Edit grant covers host-owned files the executor keeps in the same
|
| Command | Result |
|---|---|
python3 -m unittest discover -s tests |
exit 1 — Ran 1601 tests in 430.694s, FAILED (failures=1, errors=62); environmental, see below |
python3 -m unittest tests.test_stage_permissions (recovery: the PR's module alone) |
exit 0 — Ran 69 tests, OK (includes every new test) |
python3 scripts/validate-package.py |
exit 0 — VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned |
git log -1 --format=format:probe-from-git-log --output=$TMPDIR/probe.txt |
allowed by the stage hook; wrote an 18-byte file (pre-existing risk evidence) |
Write $TMPDIR/pr-comment.md (this comment body) |
succeeded under this dispatch's policy |
Why the full suite failed here (environment, not code):
- 62 errors, all in
test_validate_package.ValidatePackageTests:copy_package()→shutil.copytreehits[Errno 13] Permission deniedon the clone's.bashrc,.gitconfig,.mcp.json,.claude/settings.json,.gitmodulesand similar entries. The reviewer's bubblewrap sandbox masks those paths against reads, and the copy fails before any assertion runs. - 1 failure,
test_executors.ReadOnlyVerificationTests.test_scratch_never_uses_a_temp_parent_inside_the_checkout: withgettempdir()patched into the checkout, the fallback candidates/tmpand/var/tmp(scripts/executors.py:143-150) are not writable in this sandbox, so it raisesno temporary directory outside the dispatch checkout. - Recovery tried: ran the PR's own test module on its own (passes). Nothing else within this stage's command table and sandbox can lift the read masks or make
/tmpwritable.
Unverified
- The full configured suite in an unrestricted environment (see above). The Windows CI shards run it.
- REV-001 was not reproduced by execution (on purpose; see the finding).
- The Windows
//c/...spelling is covered by a test that runs only onos.name == "nt"; here it rests on the Windows CI shards and the author's live probe. Context7 was not available in this dispatch to recheck Claude Code's path-rule documentation. - The configured
python3 -m unittest(third verification command) is the same suite aspython3 -m unittest discover -s tests, so it was not run a second time.
CI (policy: parallel, not waited for)
Re-read just before publishing, on head 1400f39:
| Check | State |
|---|---|
| Skills, manifests, and Bash installer | pass |
| Windows test shard (windows-1) | pass |
| Windows test shard (windows-2) | pass |
| Windows test shard (windows-3) | pass (pending at the first read) |
| Windows test shard (windows-4) | pass |
| PowerShell installer | pass |
All 6 reported checks passed. The Windows shards run the full suite that this sandbox could not complete.
Residual risks
- The only test-shard checks are Windows ones, and this sandbox's Linux run was environment-blocked. I did not check whether
Skills, manifests, and Bash installeralso runs the unit suite on Linux. - REV-001 (edit scope wider than the documented need).
- The pre-existing
$TMPDIR+ prefix-verification execution path described above. - The author notes that a real review publishing on GitHub through the new rule is only proven after merge.
…e-tmpdir # Conflicts: # tests/test_stage_permissions.py
…TMPDIR REV-001 on PR #273: Edit(//<tmpdir>/**) also covered the files Claude keeps in the same directory (materialised settings, tasks/ output, bash-edit-diff/), so a read-only stage could overwrite a background verification log. Both barriers now name only pr-comment.md, report.md, reply.md and top-level <check>.log, and the hook refuses a helper name that is not directly in $TMPDIR or resolves to another file there. Refs #272
Evidence for a manual merge decision: head
|
Summary
Since #269, a read-only stage (
review,rereview,issue_review) cannot write any file, so the comment body its skill writes to$TMPDIR/pr-comment.mdforgh pr comment --body-filenever exists, and no review can publish. Observed on PR #271's round 0 review.check_file_edit: a non-writing stage may edit only paths that resolve strictly insidepolicy.tmpdir(viainside_tmpdir, which resolves..and symlinks). Writing stages keep their rules;.gitand Git configuration stay refused for every stage.allowed_tool_patterns: adds oneEdit(//<tmpdir>/**)rule (plus the resolved spelling when it differs), so Claude's--permission-mode defaultapproves the same write in-pmode. Windows paths use Claude's//c/...form.docs/host-permissions.md) and the executor comment updated.Verification
python3 -m unittest discover -s tests: 1601 tests, OK.python3 scripts/validate-package.py: VALID.$TMPDIRtargets; denied repository,$TMPDIRitself, siblingcode-cycle-tmp-*,..traversal, a symlink inside$TMPDIRpointing out,.gitinside$TMPDIR, relative paths, and a missingtmpdir; exactly one Edit rule per role; end to end Write →gh pr comment --body-file $TMPDIR/pr-comment.mdthrough both barriers.-p --permission-mode default --allowedTools "Edit(//<dir>/**)"): the write inside the directory succeeded and the write outside it was blocked.Closes #272