Repository navigation
Conversation
tkt028
force-pushed
the
fm/firstmate-599-configdir-mergeblock
branch
3 times, most recently
from
July 31, 2026 02:12
b07f241 to
0afb760
Compare
Owner
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1024 at |
Owner
|
Automated reminder: this PR still looks blocked on a rebase or merge conflict fix. If you are still interested, please rebase onto the current base branch, resolve the conflict, and push. If I do not hear back, I may close this as inactive. |
Why: an unattended crewmate could still land its own work through `gh api .../pulls/N/merge`. The two gh api rules used ":*" mid-pattern, which Claude Code rejects and SKIPS, so the merge guard never bit while every fresh spawn also stopped on a blocking Settings Warning dialog. Root cause: ":*" is prefix-match syntax and is legal only at the end of a pattern; "*" is the mid-pattern wildcard. Move the generated settings.local.json into bin/fm-crew-settings-lib.sh so the turn-end Stop hook and the merge block provably ride in one document, and cover both with tests/fm-crew-settings.test.sh. Motivated-by: tkt028/tkt-env#1244
tkt028
force-pushed
the
fm/firstmate-599-configdir-mergeblock
branch
from
August 13, 2026 13:26
0afb760 to
1654c76
Compare
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.
What Changed
gh apimerge rules that used:*mid-pattern — syntax Claude Code rejects and skips, so the merge guard never bit while every fresh spawn also stopped on a blocking Settings Warning dialog. The rule list is now per-executable and addsgh-axi pr mergeplus the GraphQLmergePullRequestshape, and it rides underpermissions.askbecause a crewmate launched with--dangerously-skip-permissionscan bypass allow/deny but not an "ask" it has no approver for..claude/settings.local.jsonout ofbin/fm-spawn.shinto the newbin/fm-crew-settings-lib.sh, so the busy-state hooks, the turn-end touch, and the merge block provably ride in one document (a single redirect writes the file, so a second writer would truncate the first). The library also carries its own shell-quoting and JSON escaping, which fixes hostile turn-end/state paths corrupting the document.tests/fm-crew-settings.test.sh(11 invariants, wired intofm-test-run.sh) anddocs/verification/crew-merge-block.mdholding the live-binary evidence the hermetic tests cannot carry; documented the coverage boundary in the library,docs/scripts.md, and the harness-adapters skill — rules match only the top-level command string, so wrapper indirection (bin/fm-pr-merge.sh,bash -c), stdin-fed GraphQL, and local landing stay ungated (open issue crewmate merge block is defeated by indirection - including the repo's own sanctioned merge entrypoints #2319), and a merge-block stop must not be cleared the same reflexive way as a launch-time trust dialog.Risk Assessment
permissions.askcontrol on every claude crewmate whose wrapper-script bypass surface and interactive-wedge failure mode were consciously accepted rather than mitigated.Testing
Ran the new
tests/fm-crew-settings.test.shplus the full changed-file selection (45 scripts, 0 failures, 2 unrelated environment gate skips), then went past unit level: I spawned a real claude crewmate throughbin/fm-spawn.shand captured the.claude/settings.local.jsonit actually wrote, confirmed with the live Claude Code 2.1.231 binary that it loads with noInvalid settingssection while the pre-fixBash(gh api:*/merge*)control still reproduces thewas skippedrejection, and finally launched a--dangerously-skip-permissionssession in that directory which blocked all six merge verbs (gh, gh-axi, both REST endpoints, the GraphQL mutation, tk-feature land) while ordinaryghreads ran — the exact end-user behavior the fix exists to restore. This is a CLI/config surface with no rendered UI, so the evidence is command transcripts and the generated settings file rather than screenshots.Evidence: Consolidated evidence write-up (spawn output, doctor comparison, bypass-mode block table)
Evidence: settings.local.json written by a real fm-spawn.sh crewmate spawn
{"hooks":["SessionEnd","Stop","StopFailure","UserPromptSubmit"],"ask":["Bash(gh pr merge:*)","Bash(gh-axi pr merge:*)","Bash(gh api *pulls/*/merge*)","Bash(gh api *repos/*/merges*)","Bash(gh api graphql*mergePullRequest*)","Bash(tk-feature land:*)","Bash(tk-feature-land:*)"]}Evidence: claude doctor 2.1.231 — malformed control vs library output vs real spawned file
=== negative control (pre-fix rules, ':' mid-pattern) === Invalid settings - .../live/bad/.claude/settings.local.json > permissions.ask: Invalid permission rule "Bash(gh api:/merge*)" was skipped: The :* pattern must be at the end. Move :* to the end for prefix matching, or use * for wildcard matching - .../live/bad/.claude/settings.local.json > permissions.ask: Invalid permission rule "Bash(gh api:/merges)" was skipped: ... === fixed rules, file as generated by fm_crew_settings_local_json === (no Invalid settings section) === real fm-spawn-generated crewmate worktree file === (no Invalid settings section)Evidence: Live --dangerously-skip-permissions session: merge verbs blocked, reads executed
| Command | Executed or Blocked | |---|---| | gh --version | Executed (gh version 2.95.0) | | gh pr merge --help | Blocked | | gh-axi pr merge --help | Blocked | | gh api --method PUT repos/tkt028/no-such-repo-zzz9/pulls/1/merge | Blocked | | gh api --method POST repos/tkt028/no-such-repo-zzz9/merges | Blocked | | gh api graphql -f query="mutation { mergePullRequest(...) }" | Blocked | | gh api repos/cli/cli/pulls/1/files | Executed (returned file list) | | tk-feature land --help | Blocked | Every block surfaced as: Claude requested permissions to use Bash, but you haven't granted it yet.Evidence: Harness used to run the real spawn and capture its settings file
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 6 issues found → auto-fixed (2) ✅
bin/fm-crew-settings-lib.sh:56- The merge block only matches top-level Bash command strings, so any indirection defeats it — most importantly the repo's own sanctioned merge entrypoints. AGENTS.md:323 says "Usebin/fm-pr-merge.shfor every task PR merge ... andbin/fm-merge-local.shfor approved local-only landing", and neither has a rule. A claude crewmate working in a firstmate worktree (this branch was produced exactly that way) can runbin/fm-pr-merge.sh <id> <pr-url>, which shells out togh-axi pr mergein a subprocess that nopermissions.askrule ever sees, and the PR lands. Same forbash -c 'gh pr merge ...'. The library's "Known residual" block (lines 46-51) documents only the GraphQL-from-stdin case, which understates the gap and reads as if wrapper scripts were considered and covered. Either add rules for the twobin/fm-*merge*.shentrypoints or state the indirection class explicitly in the residual. Separately,Bash(tk-feature land:*)/Bash(tk-feature-land:*)hardcode an operator-specific external toolchain into every crewmate's settings while the product's own merge scripts are ungated — worth a second look at what the list is scoped to.docs/verification/crew-merge-block.md:90- The prose asserts "the two REST merge endpoints ... are all covered", but the live evidence that supported that claim was deleted in b7a7ac7. The original table provedgh api --method PUT repos/.../pulls/1/mergeandgh api --method POST repos/.../mergeswere refused; the replacement table tests onlygh --version,gh pr merge --help,gh-axi pr merge --help, a GraphQL mutation, and apulls/N/filesread. SoBash(gh api *pulls/*/merge*)andBash(gh api *repos/*/merges*)— the two patterns whose:*-mid-pattern syntax bug is the entire reason this branch exists — now have zero live matching evidence anywhere, in a record whose stated job (line 7) is to "hold the live-binary evidence" the hermetic tests cannot carry. The hermetic tests only assert the strings are present, not that Claude Code matches them.docs/verification/crew-merge-block.md:13- The Conditions note says the--dangerously-skip-permissionssession table "was not re-run: it exercises the rule patterns, and those are byte-for-byte unchanged by the hook addition" — but the same commit (b7a7ac7) added two new rules (Bash(gh-axi pr merge:*),Bash(gh api graphql*mergePullRequest*)) and replaced the table with a demonstrably different live run: different commands, a different refusal message (Claude requested permissions to use Bash...vs the previousPermission to use Bash with command ... has been denied.), and rows for rules that did not exist before. The patterns were therefore not unchanged and the table was re-run, so the header's "Verified on 2026-07-25 with Claude Code 2.1.220" and this scoping sentence no longer describe the record's own contents.docs/verification/crew-merge-block.md:84- This branch introducespermissions.askinto every claude crewmate's settings for the first time, which creates a new wedge mode the fleet has no detector for. The doc states it: in the interactive TUI a crewmate actually runs in, a matched rule surfaces as a pane-blocking prompt, so the turn never ends, Stop/StopFailure/SessionEnd never fire, the turn-end file is never touched, and the busy record staysbusyforever. I found nothing that classifies a permission dialog —bin/fm-composer-lib.shhas no such screen class, andbin/fm-inactive-reconcile.shonly acts ondone/failedstate and explicitly leavesworkingto "existing supervision semantics". The only mitigation shipped is prose in.agents/skills/harness-adapters/SKILL.md:196telling a human not to reflexively clear it, which requires a human to peek in the first place. Worth deciding whether a wedged-on-permission-prompt detector is a prerequisite or a follow-up.bin/fm-crew-settings-lib.sh:20- The merge block exists only for theclaude*harness —bin/fm-spawn.shwrites.claude/settings.local.jsonin that case arm alone, and grok/codex/opencode/pi/cursor/kimi/muse crewmates get no equivalent (grok explicitly cannot, since it needs a hook-trust grant firstmate will not make). That is inherent to the mechanism, but neither the new verification record nor the SKILL.md addition says so, and both are titled generically enough ("Crewmate merge-block verification") to read as fleet-wide protection. One sentence naming the harness scope would keep a reader from over-trusting it.bin/fm-crew-settings-lib.sh:40-fm_crew_shell_quoteandfm_crew_json_escapeare a third and fourth copy of logicbin/fm-spawn.shalready carries asshell_quote(line 1078) andjson_escape(line 1476), now both sourced into the same process. The new copies are strictly better — the sed-basedjson_escapeescapes only\and"and would emit a raw newline/tab into a JSON scalar — yet fm-spawn's weaker one is still what writes the grok hook command at line 2515, which interpolates a filesystem path the same way. Consolidating both pairs into one shared owner would remove the duplication and close the weaker escaper's gap in the same move.🔧 Fix: restore REST endpoint evidence, fix verification run provenance
1 info still open:
docs/verification/crew-merge-block.md:58- The new Conditions rule at line 12 states "each section names the run it came from," and the other two runs are pinned precisely (2026-07-25 / Claude Code 2.1.220 / commit4073f59596e2, and 2026-08-13 / 2.1.231 / commitbbff368ec698). Thepermissions.ask-under-bypass section names its run only relationally — "Captured afterBash(gh-axi pr merge:*)andBash(gh api graphql*mergePullRequest*)joined the rule list" — with no date and no Claude Code version. That is the record's single most load-bearing run (it is what establishes that an unanswerableaskstops a bypass-mode crewmate at all), and the wholewas skippedfinding above it demonstrates that this engine's behavior is version-dependent, so a future reader cannot tell whether the evidence predates a version bump. Adding the date + version + commit for that session would close the gap the rest of this commit just closed everywhere else.🔧 Fix: pin bypass-table run date, state uncaptured build
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-crew-settings.test.sh— all 11 invariants pass (JSON validity, four busy hooks, turn-end path, co-residency with the merge block,:*-at-the-end syntax, 7 merge verbs, per-executable rules, no over-blocking, hostile-path quoting, fm-spawn delegation)bash bin/fm-test-run.sh --changed --base 96876db31009d011694a0174a460d2c587f2c6c8— 45 scripts,FM_TEST_SUMMARY total=45 failed=0 skipped_gate=2(skips arepipackage /tscabsent in this environment)Manual: ran the realbin/fm-spawn.sh evidence-task <proj> --mode no-mistakes --yolo offwith a fake tmux pane and isolated git worktree, then inspected the.claude/settings.local.jsonit wrote (/var/folders/.../no-mistakes-evidence/01KZXEVPHAF5FW5X45WYSYS171/spawn-evidence.sh)Manual:claude doctor(Claude Code 2.1.231) in three directories — pre-fix malformed-rule control, library output, and the real spawned fileManual:claude -p --dangerously-skip-permissions '...run each command and report whether it executed...'inside the generated settings directory, exercisinggh pr merge,gh-axi pr merge,gh api --method PUT .../pulls/1/merge,gh api --method POST .../merges,gh api graphqlmergePullRequest,tk-feature land --help, plusgh --versionand a read-onlygh apiGET as negative controlsbin/fm-crew-settings-lib.sh:46- The merge block's coverage boundary is now documented (rules match only the top-level command string, so wrapper indirection and local landing are ungated), but the mechanism itself is unchanged and open issue crewmate merge block is defeated by indirection - including the repo's own sanctioned merge entrypoints #2319 leaves the resolution undecided between adding rules for the sanctioned entrypoints, accepting the documented boundary, or moving enforcement below the command string. I chose documentation only, since changing the rule list would be a behaviour and threat-model change outside this documentation pass.docs/scripts.md:53- bin/fm-spawn.sh writes this settings document for scout tasks as well as ship crewmates (the write is gated only on KIND != secondmate), while every doc surface calls it "the claude crewmate's" file. Harmless today (a scout never lands work, and the dialog-handling guidance applies identically), so I left the wording alone rather than churn four surfaces for a nuance the change did not introduce.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.