Resolve workflow-gate repo root from the edited file's path, not cwd - #243
Merged
joshft merged 2 commits intoJul 4, 2026
Merged
Conversation
hooks/workflow-gate.sh derived REPO_ROOT — and thus the workflow state file and gate branch — from the hook's current working directory. When an edited file lived in a sibling git worktree or separate checkout, the gate applied the cwd repo's active phase restrictions to that edit and false-blocked it, even though the file's own repo had no active workflow. The only workaround (override) mutated the wrong workflow's state and burned its override budget. Re-resolve REPO_ROOT (and CONFIG_FILE, ARTIFACTS_DIR, STATE_FILE, and the gate branch) from the edited file's nearest existing ancestor directory. Fall back to the cwd-based root when the file is not in any git repo or its directory is unresolvable — the pre-existing behavior, not a new fail-open path. Bash tool calls (no file path) keep cwd resolution. Preserves PAT-001 fail-closed posture.
joshft
deleted the
chore/issue-242-workflow-gate-resolves-state-from-cwd-no
branch
July 4, 2026 10:43
This was referenced Jul 4, 2026
joshft
added a commit
that referenced
this pull request
Jul 11, 2026
Minor release: /cchores protected-file affordance (#255), Design Contract Checker lens registry (#261), sanctioned meta sole-writer (#246), InstructionsLoaded/PAT-001 (#221), plus fixes for the affordance capability probe (#264), audit-trail/workflow-gate repo attribution (#244, #243), two ARG_MAX overflows (#212, #211), and the workflow-gate fail-open (#208). Bumps .claude-plugin/marketplace.json plugins[0].version 3.1.1 -> 3.2.0 so the plugin cache picks up the affordance and its capability-probe fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hooks/workflow-gate.shresolved the repo root — and therefore the workflowstate file and the gate branch — from the hook's current working directory
rather than from the repo that owns the edited file. Edits to files living in a
sibling git worktree or separate checkout were gated by the cwd repo's active
phase and false-blocked, even though the file's own repo had no active workflow.
The only workaround (
workflow-advance.sh override) mutated the wrong workflow'sstate and burned its override budget.
Fix
Re-resolve
REPO_ROOT— and the derivedCONFIG_FILE,ARTIFACTS_DIR,STATE_FILE, and gate branch — from the edited file's nearest existing ancestordirectory (
git -C <dir> rev-parse --show-toplevel). Fall back to the cwd-basedroot when the file is not in any git repo or its directory is unresolvable — the
pre-existing behavior, not a new fail-open path. Bash tool calls (no file path)
keep cwd resolution. PAT-001 fail-closed posture is preserved throughout.
Tests
tests/test-workflow-gate.sh(
test_sibling_repo_file_not_gated_by_cwd_workflow): an edit to a file in aseparate repo with no active workflow is now allowed (exit 0); a regression
guard confirms same-repo restrictive-phase edits are still blocked (exit 2).
test-dynamic-rigor.sh: 260/0.--severity=warning),sync.sh --check, andcheck-no-pending-sfg-lift.shall clean.Provenance
Resolved autonomously by
/cchoreswith agent-separated TDD — one agent wrotethe failing repro test, a separate agent wrote the fix. Verified GREEN and
CI-superset-clean before opening.
Closes #242