Skip to content

Resolve workflow-gate repo root from the edited file's path, not cwd - #243

Merged
joshft merged 2 commits into
mainfrom
chore/issue-242-workflow-gate-resolves-state-from-cwd-no
Jul 4, 2026
Merged

Resolve workflow-gate repo root from the edited file's path, not cwd#243
joshft merged 2 commits into
mainfrom
chore/issue-242-workflow-gate-resolves-state-from-cwd-no

Conversation

@joshft

@joshft joshft commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

hooks/workflow-gate.sh resolved the repo root — and therefore the workflow
state 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's
state and burned its override budget.

Fix

Re-resolve REPO_ROOT — and the derived CONFIG_FILE, ARTIFACTS_DIR,
STATE_FILE, and gate branch — from the edited file's nearest existing ancestor
directory (git -C <dir> rev-parse --show-toplevel). 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. PAT-001 fail-closed posture is preserved throughout.

Tests

  • New RED→GREEN repro in tests/test-workflow-gate.sh
    (test_sibling_repo_file_not_gated_by_cwd_workflow): an edit to a file in a
    separate repo with no active workflow is now allowed (exit 0); a regression
    guard confirms same-repo restrictive-phase edits are still blocked (exit 2).
  • Full suite: 102/0. test-dynamic-rigor.sh: 260/0.
  • CI-superset: shellcheck (--severity=warning), sync.sh --check, and
    check-no-pending-sfg-lift.sh all clean.

Provenance

Resolved autonomously by /cchores with agent-separated TDD — one agent wrote
the failing repro test, a separate agent wrote the fix. Verified GREEN and
CI-superset-clean before opening.

Closes #242

joshft and others added 2 commits July 4, 2026 03:07
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
joshft merged commit b824954 into main Jul 4, 2026
5 checks passed
@joshft
joshft deleted the chore/issue-242-workflow-gate-resolves-state-from-cwd-no branch July 4, 2026 10:43
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.
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.

workflow-gate resolves state from cwd, not the edited file's repo — false-blocks edits in sibling git worktrees

1 participant