fix(edge-worker): stop-hook ignores pre-existing untracked files (CYPACK-1196)#1204
Open
cyrusagent wants to merge 2 commits into
Open
fix(edge-worker): stop-hook ignores pre-existing untracked files (CYPACK-1196)#1204cyrusagent wants to merge 2 commits into
cyrusagent wants to merge 2 commits into
Conversation
…ACK-1196) Switch `inspectGitGuardrail` to `git status --porcelain --untracked-files=no` so stray untracked files in the customer's worktree (scratch files, env files, IDE artifacts outside .gitignore) no longer block end-of-session. Preserve the "forgot to ship a new file" check by adding a PostToolUse `IntentToAddHook` that runs `git add --intent-to-add` on files touched by Write/Edit/MultiEdit/NotebookEdit — those still show up as a tracked diff in the guardrail. No-ops for non-git cwd, gitignored paths, already-tracked paths, and missing paths. Hook follows the same strategy pattern as PrMarkerHook: injectable `IntentToAddGitClient` interface separates git/fs side effects from the precondition policy in `applyIntentToAdd`. Reported by Cooper @ QuitCarbon.
PaytonWebber
approved these changes
May 12, 2026
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.
Assignee: @PaytonWebber (payton)
Summary
Fixes CYPACK-1196. The Stop-hook guardrail was treating every line of
git status --porcelain(including untracked??lines) as unshipped work. Customers whose worktrees contained stray untracked files outside.gitignore(scratch files, env files, IDE artifacts) got wedged: committing was wrong, and the agent looped trying to satisfy a condition it could not resolve.Approach
Layered fix that preserves the original guardrail goal (catching forgotten new files Cyrus wrote but didn't commit):
IntentToAddHook(new) — PostToolUse hook onWrite/Edit/MultiEdit/NotebookEditrunsgit add --intent-to-addon the file the tool touched. Intent-to-add marks the file as tracked-with-empty-content, so the guardrail (git diffsemantics) surfaces it if left uncommitted. No-op for: non-git cwd, gitignored paths, already-tracked paths, missing paths.inspectGitGuardrailnow usesgit status --porcelain --untracked-files=no. Combined with Say hi [CEE-574] #1, pre-existing untracked junk is ignored while forgotten new files Cyrus wrote still block.SOLID notes
The new hook follows the same strategy pattern as
PrMarkerHook:IntentToAddGitClientinterface separates git/fs side effects (DIP)DefaultIntentToAddGitClientimplements it against the realgitbinary (SRP)applyIntentToAddholds the precondition policy as a pure function over the client (testable without spawning git)Trade-off (documented in the issue)
Files created via Bash (e.g.
echo > foo, codegen, scaffolders) that Cyrus forgets togit addare no longer flagged. Every variant of instrumenting Bash to close this gap either reintroduces Cooper's bug, adds significant per-call overhead, or relies on brittle command-line parsing. Failing safe in this direction (missed nag, not customer-blocking loop) is the right call; the PR-marker early-exit and the unchanged unpushed-commits check provide partial coverage.Test plan
inspectGitGuardrailreturnsnullfor the Cooper case (untracked-only worktree)inspectGitGuardrailstill blocks on tracked-file modificationsinspectGitGuardrailstill blocks on--intent-to-addfiles (forgotten new files preserved)inspectGitGuardrailstill blocks on unpushed commitsapplyIntentToAddis a no-op for non-git cwd, missing paths, gitignored paths, already-tracked pathsIntentToAddHookmatcher covers Write/Edit/MultiEdit/NotebookEdit and excludes Bash/Read