Skip to content

fix: keep following cd past a plain command substitution (0.7.3) - #15

Merged
sofus-common merged 2 commits into
mainfrom
fix/0.7.3-guard-substitution-cd
Nov 8, 2026
Merged

sofus-common merged 2 commits into
mainfrom
fix/0.7.3-guard-substitution-cd

Conversation

@sofus-common

@sofus-common sofus-common commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Guard hook false denial, follow-up 4 of #14. Hook-only patch: 0.7.2 -> 0.7.3, changelog entry ## 0.7.3 - 2026-11-08, both manifests bumped.

Cause

The denied command in the 0.7.2 manual-harness run was cd "<project>" && mkdir -p .sdlc/changes/<slug> && cd .sdlc/changes/<slug> && D=$(date +%Y-%m-%d) && cat > spec.md <<'EOF' .... The trigger was the $(date ...) between the two cds, not the absolute cd. Any parenthesis made shellWritesOutsideSdlc stop following directory changes, so spec.md counted as a project file. The abstract chain (absolute cd, other commands, relative cd) already passed on 0.7.2; those cases are in the tests as regression pins.

Change

hooks/edit_guard.py: before the parenthesis check, a $(...) that holds no directory change and no nested parenthesis is dropped from the text checked. It cannot move the shell, and its inner commands are still scanned as segments, so a write inside it is still seen. One regex, two lines.

Still denied (tested)

  • same chain ending in a write outside .sdlc/, or in .sdlc/../ traversal
  • absolute cd to a directory outside the project
  • cd in a subshell ( ... ), a group, a nested shell, or inside a $(...)
  • a write inside the substitution that lands outside .sdlc/

Known limit

A $(...) in quotes (D="$(date +%F)") still stops the following, because quoted text is hidden from the scan and the substitution inside it cannot be checked. Documented in the changelog.

Checks

  • python scripts/test_edit_guard.py: red on the real-shape command before the change, green after. Dropping the "no cd inside" condition makes an existing negative fail.
  • python scripts/check_version.py, --self-test, python scripts/test_behavior_check.py, claude plugin validate .: pass.
  • Behavior suite not run (hook-only, as in 0.7.1). Codex does not load the hook.

🤖 Generated with Claude Code

sofus-common and others added 2 commits November 8, 2026 10:27
The guard hook stopped following directory changes at any parenthesis, so
`cd <project> && ... && cd .sdlc/changes/<slug> && D=$(date +%F) && cat > spec.md`
counted spec.md as a project write. A `$(...)` with no cd and no nested
parenthesis cannot move the shell, so it no longer stops the following; its
inner commands are still scanned. Subshells, groups, nested shells, quoted
substitutions, outside directories, and .sdlc/.. traversal are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sofus-common
sofus-common merged commit 4c6986b into main Nov 8, 2026
2 checks passed
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