Skip to content

Allow review stages to validate staged comments - #317

Merged
datacas merged 3 commits into
mainfrom
task-307
Oct 23, 2026
Merged

datacas merged 3 commits into
mainfrom
task-307

Conversation

@datacas

@datacas datacas commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Allow review, rereview, and resolve stages to run the installed comment validator only against the staged pr-comment.md in the dispatch temp directory.
  • Require review and rereview to validate the staged comment before publishing, and document the permission.

Issue: #307

Diagnosis

The symptom is that review and rereview cannot run the installed validator on their staged comment. The existing command-table test asserted the validator was absent from review patterns, and the role guard allowed it only for resolve; I did not run a separate pre-change hook reproduction. The issue’s cause matches the code. The invariant is that only the installed script with exactly one pr-comment.md argument resolving directly inside the dispatch TMPDIR or its claude-<uid> child is allowed. A widened issue search found #306, which explicitly notes that #307 touches the same resolve command table for a separate allowance; it identifies merge-order overlap, not a dependency. The code search covered the validator policy, role prompts, tests, and host-permissions documentation.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Allow narrow staged-comment validation for review roles and require validation before publishing scripts/stage_permissions.py, skills/cc-initial-review/SKILL.md, skills/cc-rereview/SKILL.md, tests/test_stage_permissions.py, docs/host-permissions.md tests/test_stage_permissions.py python3 -m unittest discover -s tests (1,764 passed); python3 scripts/validate-package.py passed; python3 -m unittest passed (0 discovered) independent

Documentation updated in docs/host-permissions.md.

Closes #307

@datacas

datacas commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle initial review — PR #317 (work item #307)

[CCR-20261023-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

Verdict: CHANGES_REQUESTED for head 18c45f5d21c1b65a71c55abfe94178a1a27cdcff.

Summary and scope

I reviewed the whole diff from merge base 84ad811c5cf606045a38738c1556960a2c05b89d to head 18c45f5d21c1b65a71c55abfe94178a1a27cdcff: 156 lines across scripts/stage_permissions.py, tests/test_stage_permissions.py, skills/cc-initial-review/SKILL.md, skills/cc-rereview/SKILL.md and docs/host-permissions.md. I checked it against the acceptance criteria and the scope clarification in #307.

The hook side is sound. _check_words now allows review, rereview and resolve to run the installed validator with exactly one argument. That argument must be named pr-comment.md, and it must pass the existing is_tmpdir_helper check, which tests both the name and the resolved path. The prompt note and the docs page are updated.

Two problems block approval:

  • The new absolute-path --allowedTools patterns do not match the commands an agent actually types. Claude's first permission barrier therefore still denies the absolute forms that Stages are denied the installed comment validator #307 reports.
  • The new test is not portable to Windows. It very likely causes the failing windows-4 shard.

Findings

[REV-001] · medium · open · - · blocks:yes — Absolute validator allowedTools patterns never match the typed command

scripts/stage_permissions.py:1394-1402

allowed_tool_patterns builds the nested wildcard with _absolute_rule_path(tmpdir). That helper renders a Claude file-path rule: on POSIX it returns "/" + as_posix(), so /tmp/code-cycle-tmp-X becomes //tmp/code-cycle-tmp-X (see scripts/stage_permissions.py:1445-1454). It is the right form inside Edit(...)/Write(...) rules. Inside a Bash(...) pattern, though, Claude compares it with the literal command string. As a result, Bash(python3 <validator> //tmp/code-cycle-tmp-X/claude-*/pr-comment.md) never matches python3 <validator> /tmp/code-cycle-tmp-X/claude-1000/pr-comment.md.

For a native Claude dispatch, printenv TMPDIR returns exactly that nested directory. In this dispatch it returned /tmp/code-cycle-tmp-csz9z2jt/claude-1000. So the absolute form an agent is most likely to type, which is the form #307 reports as denied (/tmp/code-cycle-tmp-*/pr-comment.md), is still refused by --allowedTools. The hook does not rescue it: it returns no decision for allowed commands (hook_main), so --allowedTools stays the gate.

Two related gaps:

  • The top-level absolute prefix and the wildcard are built only from the resolved TMPDIR. The Edit/Write rules just below (:1430) deliberately cover both the literal and the resolved path (Read-only Claude stages still cannot write $TMPDIR/pr-comment.md: executor temp dir is a subdirectory #280). With a symlinked temp root, such as macOS /var → /private/var, the path printed by printenv TMPDIR is never pre-allowed.
  • On Windows, shlex.quote wraps the backslash path in single quotes, so that prefix does not match an unquoted command either.

The test only asserts any("claude-*/pr-comment.md" in pattern ...), so it cannot catch any of this.

Expected: build the Bash patterns from plain command-form paths, both literal and resolved, without the // path-rule prefix. Then assert the exact nested pattern in the test.

Evidence: code inspection, plus the observed printenv TMPDIR value. A live allowedTools check is not possible from this stage, because the dispatch runs the installed runtime from main.

[REV-002] · medium · open · - · blocks:yes — New validator test is not portable to Windows

tests/test_stage_permissions.py:695-702

The new test interpolates Path(policy.tmpdir) paths into commands without quotes, for example f"python3 {validator} {absolute}". On Windows these paths contain backslashes. parse_command treats an unquoted \ as an escape (scripts/stage_permissions.py:330-335), so C:\Users\…\pr-comment.md is parsed as a relative C:Users…pr-comment.md. self.allowed(...) then fails.

The pattern assertion Bash(python3 {validator} {absolute}:*) also fails on Windows for two reasons:

  • production quotes that path with shlex.quote;
  • production uses resolve(), which expands 8.3 short names such as RUNNER~1.

Existing tests in the same file single-quote absolute paths (for example lines 293 and 363) for this reason.

test_stage_permissions is assigned to shard windows-4 (scripts/windows-test-shards.json:111), and that shard is failing on this head. I could not read the job log: this stage's command table denies both gh run view and gh api …/check-runs/…/annotations. The causal link is therefore unverified, but the code shows the test cannot pass on Windows.

[REV-003] · low · open · - · blocks:no — Validation step is unconditional on the manual and Orca path

skills/cc-initial-review/SKILL.md:494-496, skills/cc-rereview/SKILL.md:513-515

cc-resolve-comments scopes its equivalent step to "For a native dispatch" and says that "the runtime supplies the absolute path" (skills/cc-resolve-comments/SKILL.md:711-718). The new review and rereview steps have neither qualifier. A manual run, or an Orca worker (whose temp handling the skills explicitly exempt), is told to run "the installed" validator before publishing, without a path or a fallback. #307 asks for these steps to follow the resolver's contract. Suggest the same "For a native dispatch … the runtime supplies the absolute path" wording.

[REV-004] · low · open · - · blocks:no — No test pins the new SKILL.md validation steps

tests/test_stage_permissions.py:705-706

The test checks that prompt_note contains "before publishing" for review and rereview. Nothing asserts the new numbered steps in cc-initial-review and cc-rereview, and validate-package.py does not check them either. A later edit could drop them silently. This is optional hardening.

Security triage

.code-cycle.yml declares no security_review.always_when rule, so the defaults apply. My own reading activated the audit: the change widens the closed command table of three stages, which is security tooling. No label applies.

I ran the audit inline and found no vulnerability:

  • The allowed script is the runtime's own validate-triage-comment.py (Path(__file__)), not a repository file.
  • The command must have exactly three words.
  • The argument must be named pr-comment.md and must pass is_tmpdir_helper, which checks the literal and resolved name and parent and rejects symlink escapes and sibling code-cycle-tmp-* directories.
  • Environment assignments, chaining and extra arguments remain denied by the parser and the length check.
  • The validator only reads and parses the file.
  • The :* prefix patterns are wider than the hook rule, but the hook is the binding check.

Commands executed

Command Result
python3 -m unittest discover -s tests exit 0, Ran 1764 tests … OK (Linux/WSL)
python3 scripts/validate-package.py exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest exit 0, Ran 0 tests (top-level discovery finds nothing; configured command)
python3 -m unittest tests.test_stage_permissions -k validator exit 0, 1 test OK on Linux
printenv TMPDIR /tmp/code-cycle-tmp-csz9z2jt/claude-1000 (the nested claude-<uid> form)

Unverified

  • REV-001: runtime behaviour of --allowedTools matching. This dispatch uses the installed runtime from main, so the new patterns cannot be exercised live here. The finding rests on code inspection of _absolute_rule_path and the observed TMPDIR shape.
  • REV-002: the Windows failure log. gh run view 39974348197 --job 120484955972 --log-failed and gh api repos/datacas/code-cycle-toolkit/check-runs/120484955972/annotations are denied by this stage's command table.
  • Diff hash: I confirmed the diff file's line count (156). sha256sum is not in this stage's table, so the SHA-256 was not recomputed.

CI (policy: parallel; read once, not awaited)

Head 18c45f5d21c1b65a71c55abfe94178a1a27cdcff, workflow "Validate package":

Check State
Skills, manifests, and Bash installer pass
Windows test shard (windows-1) pending
Windows test shard (windows-2) pass
Windows test shard (windows-3) pass
Windows test shard (windows-4) fail (contains test_stage_permissions; see REV-002)

The aggregate job "Require all Windows test shards to pass" and the Windows package validation job depend on the shards and have not reported yet. The cycle's CI gate decides on these checks.

Residual risk

  • Even after REV-001 and REV-002 are fixed, the allowedTools/hook pairing for the validator should be confirmed in one real dispatch on Linux, and ideally on macOS and Windows.
  • The double space in the prompt note ("$TMPDIR/pr-comment.md". Validate…) is cosmetic only.

Documentation

docs/host-permissions.md owns the stage command-table concept and is updated in this PR.

@datacas

datacas commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle resolution — PR #317 (work item #307)

Status: PARTIALLY_RESOLVED for head 921e9e8d5e81b4bafa815138865c66c6125d596d.

Triage

[CCT-20261023-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:18c45f5d21c1b65a71c55abfe94178a1a27cdcff · schema:2

I classified all four findings against the reviewed head before evaluating the fixes. Each described a real issue in this change, so each disposition is valid.

[CCR-20261023-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

Applied fixes

[REV-001] · medium · resolved · valid · blocks:yes — Absolute validator patterns did not match command paths

Updated allowed_tool_patterns to build Bash command patterns from both the literal and resolved TMPDIR paths in shell form. Nested Claude paths use the same command-form paths; Claude file-rule // formatting is no longer used for Bash patterns. Tests assert each exact direct and nested pattern.

[REV-002] · medium · resolved · valid · blocks:yes — Validator test failed on Windows paths

Quoted absolute paths in the policy test with shlex.quote, preserving backslashes as one argument on Windows. The failed windows-4 log confirmed the test's unquoted path was parsed incorrectly and python3 was consequently denied. The dependent PowerShell installer check failed its shard guard, so both failures were caused by this change and are addressed by the test fix.

[REV-003] · low · resolved · valid · blocks:no — Validation instructions lacked native-dispatch scope

Qualified the new steps in skills/cc-initial-review/SKILL.md and skills/cc-rereview/SKILL.md for native dispatches, where the runtime provides $TMPDIR; manual and Orca runs use their host-provided temporary-file workflow.

[REV-004] · low · resolved · valid · blocks:no — Skill validation steps were not covered by tests

Added a regression test that checks both skill files retain the native-dispatch scope, staged path, validator and before-publishing instruction.

No findings were rejected or left open. docs/host-permissions.md already documents the validator allowance and its stage scope; it needed no further edit.

Verification

  • rtk python3 -m unittest discover -s tests — exit 0; 1,765 tests passed.
  • rtk python3 scripts/validate-package.py — exit 0; package validation passed.
  • rtk python3 -m unittest — exit 0; 0 tests discovered, as configured.
  • rtk git diff --check — exit 0.
  • Security review of the changed permission paths found no confirmed vulnerability. The hook still restricts the validator to the installed script, one pr-comment.md argument and a helper path confined to TMPDIR.
  • Verification is verified_with_reservations: a live Claude --allowedTools dispatch could not be exercised from this stage, so the required runtime boundary remains unverified. The tests do verify the generated patterns and hook decisions.

CI on the pushed head

Head 921e9e8d5e81b4bafa815138865c66c6125d596d: all five checks were queued at the single post-push snapshot — Skills, manifests, and Bash installer, and Windows test shards windows-1 through windows-4. They remain pending; this stage did not wait for remote CI.

The fix commit is 921e9e8d5e81b4bafa815138865c66c6125d596d. No additional residual issue was found in the change delta.

@datacas

datacas commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle rereview — PR #317 (work item #307)

[CCR-20261023-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

Earlier runs on this change request:

[CCR-20261023-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

[CCT-20261023-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:18c45f5d21c1b65a71c55abfe94178a1a27cdcff · schema:2

Verdict: CHANGES_REQUESTED for head 921e9e8d5e81b4bafa815138865c66c6125d596d. The previous review was on 18c45f5d21c1b65a71c55abfe94178a1a27cdcff.

What changed since the previous review

Commit 921e9e8 ("Fix staged validator review findings") changes three things:

  • allowed_tool_patterns now builds the validator's Bash patterns from both the literal and the resolved TMPDIR. It uses shlex.quote and no longer uses the // path-rule prefix.
  • The validator test now quotes absolute paths and asserts the exact direct and nested patterns. A new test pins the SKILL.md steps.
  • The new steps in cc-initial-review and cc-rereview are now limited to native dispatches.

I read the whole accumulated diff again: 184 lines from merge base 84ad811c5cf606045a38738c1556960a2c05b89d, covering the same five files.

Previous findings

[REV-001] · medium · open · valid · blocks:yes — Absolute validator allowedTools patterns never match the typed command

scripts/stage_permissions.py:1403-1405

The fix is partial. The direct-path prefix python3 <validator> /tmp/code-cycle-tmp-X/pr-comment.md is now correct for both the literal and the resolved root, and the // prefix is gone.

The nested wildcard is still wrong. It is built as shlex.quote(str(root / "claude-*" / "pr-comment.md")). Python's shlex.quote treats * as unsafe, so it wraps the whole argument in single quotes. The generated rule is therefore:

Bash(python3 <validator> '/tmp/code-cycle-tmp-X/claude-*/pr-comment.md')

The quote characters are literal in the rule. A command typed the usual way, without quotes, does not match it:

python3 <validator> /tmp/code-cycle-tmp-X/claude-1000/pr-comment.md

Only an agent that happens to single-quote the path matches.

The nested form matters most. In this dispatch, printenv TMPDIR returned /tmp/code-cycle-tmp-dhyx55o8/claude-1000, so the absolute path an agent derives from it is the nested one. That is the form #307 reports as denied. The hook accepts that command (the test's self.allowed(... nested ...) passes), so --allowedTools is still the barrier that refuses it.

The new test asserts the same shlex.quote output that production generates. It confirms the quotes; it does not check that the pattern matches a typed command.

Expected fix: quote only the root and append the literal suffix, for example f"{shlex.quote(str(root))}/claude-*/pr-comment.md". On POSIX that leaves the root unquoted, and on Windows shlex.quote still quotes it. Alternatively, emit both an unquoted and a quoted variant. Then test the pattern against the unquoted nested command, for example with fnmatch, rather than against its own construction.

Evidence: code inspection of lines 1403-1405, the stdlib shlex.quote contract, and the printenv TMPDIR value above. Live --allowedTools matching cannot be exercised from this stage, because the dispatch runs the installed runtime from main. I could not read Claude Code's matching documentation either: the Context7 call was not permitted in this stage. If Claude Code strips quotes before it matches wildcard rules, this finding does not apply. Nothing I could check here shows that it does.

[REV-002] · medium · resolved · valid · blocks:yes — New validator test is not portable to Windows

tests/test_stage_permissions.py:690-705

Resolved and verified. Absolute and sibling paths are now passed through shlex.quote. The pattern assertions iterate over the same literal and resolved roots that production uses, so 8.3 short names are covered. The test passes locally on Linux, and Windows test shard (windows-4), which contains test_stage_permissions, passed on this head (6m33s).

[REV-003] · low · resolved · valid · blocks:no — Validation step is unconditional on the manual and Orca path

skills/cc-initial-review/SKILL.md:494-498, skills/cc-rereview/SKILL.md:513-517

Resolved. Both steps now begin "For a native dispatch, the runtime supplies the absolute path" and route manual and Orca runs to their host-provided temporary-file workflow, which matches cc-resolve-comments. test_review_skills_scope_comment_validation_to_native_dispatches passes.

[REV-004] · low · resolved · valid · blocks:no — No test pins the new SKILL.md validation steps

tests/test_stage_permissions.py:715-721

Resolved. The new test asserts the native-dispatch scope, the staged path, the validator name and "before publishing" in both skills. It passes.

New findings

None.

Security triage

.code-cycle.yml declares no security_review.always_when rule. My own reading activated the audit, because the change widens the closed command table of three stages.

Audit result: no vulnerability.

  • The fix commit adds only first-barrier --allowedTools patterns.
  • The hook remains the binding check. It requires the installed validate-triage-comment.py (Path(__file__)), exactly three words, and an argument named pr-comment.md that passes is_tmpdir_helper, which checks the literal and resolved path and rejects symlink escapes and sibling dispatch directories.
  • A claude-* wildcard can match more strings than the hook accepts, such as a claude-x/../ traversal. The hook's resolved-path check refuses those.
  • The validator only reads the file.

Verification

Command Result
python3 -m unittest discover -s tests exit 0, Ran 1765 tests … OK (Linux/WSL)
python3 scripts/validate-package.py exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest exit 0, Ran 0 tests (the configured top-level command discovers nothing)
python3 -m unittest tests.test_stage_permissions -k validator -k native_dispatches -v exit 0, 2 tests OK
printenv TMPDIR /tmp/code-cycle-tmp-dhyx55o8/claude-1000 (nested claude-<uid> form)

Unverified:

  • Live Claude --allowedTools matching for the new patterns (REV-001), for the reason given under that finding.
  • The diff file's SHA-256 was not recomputed. Its line count (184) and the head SHA match the runtime's evidence.

CI (policy: parallel; read once, not awaited)

Head 921e9e8d5e81b4bafa815138865c66c6125d596d, workflow "Validate package":

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
Windows test shard (windows-4) pass
PowerShell installer pending

The cycle's CI gate decides on the pending check.

Residual risk

After REV-001 is fixed, the validator's allowedTools/hook pairing should still be confirmed in one real native Claude dispatch whose TMPDIR is the nested form.

Documentation

docs/host-permissions.md owns the stage command-table concept. It already lists the validator allowance and the stages that receive it, and the fix commit needed no further documentation change.

…ools (#307)

shlex.quote wrapped the whole claude-* wildcard path in literal single quotes, so an unquoted nested command never matched. Quote only the root, keep the fully quoted variant, and test the pattern against the typed command.
@datacas

datacas commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle resolution — PR #317 (work item #307)

Status: RESOLVED for head 6b19166555a2db7e871bfceae491d06ad5c61f78.

Triage

[CCT-20261023-002] · cheap_coder · anthropic/claude-sonnet-5-5→? · high · triaged:921e9e8d5e81b4bafa815138865c66c6125d596d · schema:2

REV-001 survived a claimed fix: the rereview reopened it. I reproduced it before editing and did not republish it not_applicable. Its disposition stays valid, as frozen by the first triage. REV-002, REV-003 and REV-004 were already resolved in the rereview and are unchanged.

Earlier runs on this change request:

[CCR-20261023-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

[CCR-20261023-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

[CCT-20261023-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:18c45f5d21c1b65a71c55abfe94178a1a27cdcff · schema:2

Findings

[REV-001] · medium · resolved · valid · blocks:yes — Absolute validator allowedTools patterns never match the typed command

scripts/stage_permissions.py:1399-1409, tests/test_stage_permissions.py:707-718

Reproduction. The rereview was right. shlex.quote('/tmp/code-cycle-tmp-X/claude-*/pr-comment.md') returns the same path wrapped in single quotes, because * is not in shlex's safe character set. The generated rule was Bash(python3 <validator> '/tmp/code-cycle-tmp-X/claude-*/pr-comment.md'). The quote characters are literal in that rule, so the unquoted command an agent types from printenv TMPDIR never matches it. The earlier test asserted the same shlex.quote output that production builds, so it could not see this.

Cause. The wildcard suffix was quoted together with the root. The first fix removed the // path-rule prefix but still quoted the whole wildcard path.

Fix. The nested pattern now quotes only the root and appends the literal suffix: {shlex.quote(root)}/claude-*/pr-comment.md. On POSIX the root stays unquoted. On Windows shlex.quote still quotes it. The fully quoted variant is kept for an agent that quotes the whole argument. This is done for both the literal and the resolved TMPDIR.

Regression test. test_review_resolve_and_rereview_get_only_the_staged_triage_validator asserts both exact patterns. It also uses fnmatch to check that the nested pattern matches the nested command as typed, unquoted, for every root where the root needs no quoting. Before the fix the unquoted match fails; I confirmed that from the reproduction above, not by running the old test.

The hook is unchanged and remains the binding check: the installed script, exactly one pr-comment.md argument, and a path confined to TMPDIR.

[REV-002] · medium · resolved · valid · blocks:yes — New validator test is not portable to Windows

Resolved in 921e9e8 and confirmed by the rereview. Windows shard windows-4 passed on that head. The change here does not alter that behaviour: the added fnmatch assertion runs only where the root needs no quoting.

[REV-003] · low · resolved · valid · blocks:no — Validation step is unconditional on the manual and Orca path

Resolved in 921e9e8 and confirmed by the rereview. Not touched in this round.

[REV-004] · low · resolved · valid · blocks:no — No test pins the new SKILL.md validation steps

Resolved in 921e9e8 and confirmed by the rereview. Not touched in this round.

Fix delta review

Delta base is 921e9e8d5e81b4bafa815138865c66c6125d596d, the head of the latest trusted rereview receipt. It is an ancestor of the new head (git merge-base --is-ancestor exited 0). The delta is 2 files, 15 insertions and 4 deletions.

I reviewed it inline. The change only adds one more first-barrier --allowedTools pattern form for the same installed script and the same pr-comment.md file name. No P0 or P1 finding came out of it.

Security triage: this stays inside the command-table area that the review already audited. The only addition is an equivalent pattern spelling for the same command shape. The hook, which refuses extra arguments, other file names and paths outside TMPDIR, is unchanged. I found no vulnerability.

Verification (agent-reported)

Command Result
python3 -m unittest tests.test_stage_permissions exit 0, 82 tests OK
python3 -m unittest discover -s tests exit 0, Ran 1765 tests … OK
python3 scripts/validate-package.py exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest exit 0, Ran 0 tests (the configured top-level command discovers nothing)

Conclusion: verified_with_reservations. Live Claude --allowedTools matching could not be exercised from this stage, because the dispatch runs the installed runtime from main. Whether Claude Code strips quotes before matching is not documented anywhere I could reach. The fix removes the quoted form as the only form, which holds under either behaviour. One real native dispatch with a nested TMPDIR should still confirm the pairing.

Not run: the staged-comment validator. python3 /home/datacas/.code-cycle/runtime/validate-triage-comment.py "$TMPDIR/pr-comment.md" was denied by this stage's hook ("'python3' is not in the resolve stage's command table"), also with the absolute path and for the cycle_journal.py permissions command. I followed the run-line and finding-header formats of the already-validated comments on this change request instead.

Environment assumptions shared with CI: none specific to this round. The new assertion does not depend on the global Git identity or on tools outside the repository.

CI on the pushed head

Head 6b19166555a2db7e871bfceae491d06ad5c61f78: read once right after the push. GitHub reported no checks yet (0 passed, 0 failed, 0 pending). This is not a pass; the checks had not been registered at read time. This stage did not wait for remote CI.

Documentation

docs/host-permissions.md already documents the validator allowance and the stages that get it. This round changes only the spelling of a generated pattern, not visible behaviour, a command or a configuration key, so no docs page changes.

Fix commit: 6b19166555a2db7e871bfceae491d06ad5c61f78.

@datacas

datacas commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle rereview — PR #317 (work item #307)

[CCR-20261023-003] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

Earlier runs on this change request:

[CCT-20261023-002] · cheap_coder · anthropic/claude-sonnet-5-5→? · high · triaged:921e9e8d5e81b4bafa815138865c66c6125d596d · schema:2

[CCR-20261023-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

[CCR-20261023-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2

[CCT-20261023-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:18c45f5d21c1b65a71c55abfe94178a1a27cdcff · schema:2

Verdict: REVIEW_PASSED_AWAITING_CI for head 6b19166555a2db7e871bfceae491d06ad5c61f78. The previous rereview was on 921e9e8d5e81b4bafa815138865c66c6125d596d. No open finding blocks approval. Four required Windows shards were still pending when I read the checks, so this is not an approval. The cycle's CI gate decides.

What changed since the previous review

Commit 6b19166 ("fix(runtime): match the unquoted nested validator command in allowedTools") changes two things:

  • In allowed_tool_patterns, the nested validator wildcard now quotes only the TMPDIR root and appends the literal /claude-*/pr-comment.md suffix. The fully quoted variant stays for agents that quote the whole argument. Both forms are emitted for the literal and the resolved root.
  • The validator test asserts both exact patterns. Where the root needs no quoting, it also uses fnmatch to check that the unquoted nested command matches the new pattern as typed.

I read the whole accumulated diff again: 199 lines from merge base 84ad811c5cf606045a38738c1556960a2c05b89d. It covers the same five files: scripts/stage_permissions.py, tests/test_stage_permissions.py, skills/cc-initial-review/SKILL.md, skills/cc-rereview/SKILL.md and docs/host-permissions.md.

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Absolute validator allowedTools patterns never match the typed command

scripts/stage_permissions.py:1394-1408, tests/test_stage_permissions.py:707-718

Resolved and verified by execution. For each root, the generated rules are now:

  • Bash(python3 <validator> <root>/pr-comment.md:*), the direct path;
  • Bash(python3 <validator> <root>/claude-*/pr-comment.md), the nested path with the root quoted only when it needs quoting, so it is unquoted on POSIX;
  • Bash(python3 <validator> '<root>/claude-*/pr-comment.md'), the fully quoted variant.

Rules are built for the literal and the resolved TMPDIR. On this host (/tmp/...) the root needs no quoting, so the test's fnmatch check runs. It passed: the unquoted command python3 <validator> <root>/claude-1000/pr-comment.md matches the new nested pattern. This is the shape printenv TMPDIR produces in a native dispatch; here it returned /tmp/code-cycle-tmp-r36xslac/claude-1000. The hook still accepts the same command and refuses reply.md, a sibling dispatch directory and an extra argument (self.allowed / self.denied in the same test). The hook is the binding check.

The wildcard placement matches the existing gh api repos/<repo>/check-runs/* rules in the same function.

[REV-002] · medium · resolved · valid · blocks:yes — New validator test is not portable to Windows

Still resolved. The new fnmatch assertion is guarded by shlex.quote(str(root)) == str(root), so it is skipped for Windows roots that need quoting. The rest of the test still quotes absolute paths. Windows test shard (windows-4) is pending on this head (see CI).

[REV-003] · low · resolved · valid · blocks:no — Validation step is unconditional on the manual and Orca path

Still resolved. The skill files did not change in this round. test_review_skills_scope_comment_validation_to_native_dispatches passes.

[REV-004] · low · resolved · valid · blocks:no — No test pins the new SKILL.md validation steps

Still resolved. The same test passes.

New findings

None.

Security triage

.code-cycle.yml declares no security_review.always_when rule. My own reading activated the audit, because the change widens the closed command table of three stages.

Audit result: no vulnerability. The delta only adds an unquoted spelling of a first-barrier --allowedTools pattern for the same installed script and the same file name.

  • The claude-* wildcard can match more strings than the hook accepts, for example a claude-x/../ traversal or an extra trailing word.
  • The hook rejects those. It requires exactly three words, the installed validate-triage-comment.py, an argument named pr-comment.md, and is_tmpdir_helper to pass. That function checks the literal and resolved path and rejects symlink escapes and sibling dispatch directories.
  • The hook is unchanged since the previous audit.

Verification

Command Result
python3 -m unittest discover -s tests exit 0, Ran 1765 tests in 214.610s … OK (Linux/WSL)
python3 scripts/validate-package.py exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest exit 0, Ran 0 tests (the configured top-level command discovers nothing)
python3 -m unittest tests.test_stage_permissions -k validator -k native_dispatches -v exit 0, 2 tests OK (includes the fnmatch assertion)
printenv TMPDIR /tmp/code-cycle-tmp-r36xslac/claude-1000 (nested claude-<uid> form)

Unverified:

  • Live Claude --allowedTools matching. This dispatch runs the installed runtime from main, so the new rules cannot be exercised here. fnmatch stands in for Claude Code's matcher; it is not the matcher itself.
  • Staged-comment validator. I did not run it on this comment. The installed runtime from main denied python3 /home/datacas/.code-cycle/runtime/validate-triage-comment.py /tmp/code-cycle-tmp-r36xslac/claude-1000/pr-comment.md with "'python3' is not in the rereview stage's command table". This is the same gap that Stages are denied the installed comment validator #307 fixes. The comment follows the run-line and finding-header formats of the earlier validated comments.
  • Diff hash. The SHA-256 of the diff file was not recomputed. Its line count (199) and the head SHA match the runtime's evidence.

CI (policy: parallel; read once, not awaited)

Head 6b19166555a2db7e871bfceae491d06ad5c61f78, workflow "Validate package":

Check State
Skills, manifests, and Bash installer pass (4m32s)
Windows test shard (windows-1) pending
Windows test shard (windows-2) pending
Windows test shard (windows-3) pending
Windows test shard (windows-4) pending

The PowerShell installer and Windows aggregate jobs had not reported yet. The cycle's CI gate decides on these checks.

Residual risk

Confirm the validator's allowedTools/hook pairing in one real native Claude dispatch whose TMPDIR has the nested form, once this runtime is installed.

Documentation

docs/host-permissions.md owns the stage command-table concept. It documents the validator allowance for review, rereview and resolve, limited to pr-comment.md directly in $TMPDIR or its claude-<uid> child. This round changes only the spelling of a generated pattern, so that page needs no update.

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.

Stages are denied the installed comment validator

1 participant