Repository navigation
fix(workspaceindex): import gitsafe under the Twigpine module path - #1153
Conversation
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
|
@kevincodex1 one more thing, so this doesn't repeat. 18 other open PRs still add imports with the old path, and 12 of them carry approvals: #685, #796, #882, #892, #893, #894, #895, #897, #941, #953, #987 and #993. None of them builds on current main until main is merged in and those imports are renamed, and their green checks won't show it, because nothing makes a PR re-run CI against current main before it merges. Required status checks with "require branches to be up to date before merging" in the main ruleset would. I'm letting the authors of the approved ones know, and my own PRs are getting the same update. |
…#866) * fix(agent): stop a denied tool looping past the repeated-failure halt The repeated-failure guard keys its streak on the first 80 characters of the error text. A permission denial reads "Error: Permission denied for <tool>: <reason>", and reason names the path or command that was refused, so the text differs on every call while describing the same unchanging refusal. Each call therefore rebuilt the record at count 1 and toolFailureStopAt was never reached. Not hypothetical. A headless run made 384 denied calls over 26 minutes under a halt set to 6, produced no files, and reported nothing. #702 already hit this shape once and fixed it by making one error message id-invariant; that works per message and needs every future message to remember. Denials now key on their DenialCategory instead, which is a small closed enum the loop already sets on the result, so the class is fixed rather than one instance of it. Adds a second, content-blind counter beside the streak. The signature-keyed one cannot by construction see a tool that fails with a genuinely different error every time, and that is still a tool that is not working. It counts consecutive failures regardless of the error and is cleared only by a success of that same tool, so changing how a tool fails is not progress and neither is some other tool succeeding. It stops at 12 rather than 6 on purpose: a model iterating on a tricky edit legitimately fails a few times with different errors while converging, which is the same reasoning that moved toolFailureStopAt from 4 to 6. Two counters, tripping on either, is what both of the agent CLIs I compared against arrived at independently after hitting this bug — a tight bound on identical failures ORed with a looser bound that no amount of varying the error can reset. Every guard is mutation-checked. Reverting the denial re-key fails TestPermissionDenialStreakSurvivesVaryingReasonText; deleting the content-blind bound, or letting a signature change reset it, each fail TestToolFailingWithDifferentErrorsEveryTimeStillStops and TestSuccessResetsBothFailureCounters. One existing test call site gains the new parameter. * fix(agent): count denials as failures and report the bound that tripped Addresses both blocking findings from @anandh8x's review. He was right on both, and the first was fatal: the previous commit was a no-op in production. loop.go passed isRetriableToolError as the guard's `failed` flag, and that returns false for any categorized denial (a policy refusal is deliberately not retriable). observeToolResult therefore took its success branch and DELETED the record before it could key on DenialReason, so a denied tool still looped to the turn limit. The re-key was correct and unreachable. The flag is now split. `failed` counts a denial toward the streaks; `hintable` stays retriable-only, because a schema hint is the wrong response to a refusal — the call shape is fine, the answer was no. Collapsing the two is what made a caller unable to express "count this but do not coach the model about it". Second finding: outcome.Count returned the signature-keyed record.count even when the content-blind counter was what tripped the stop. With twelve distinct errors that count is 1, so the final answer told the user a tool "failed 1 time in a row with the same error". The outcome now carries the counter that actually fired plus a Varied flag, and the stop answer says "each with a different error" in that case. Every earlier test passed while the production path was broken, because they called observeToolResult directly with failed=true. So the important addition here is TestRunStopsARepeatedlyDeniedToolAtTheFailureBound, which drives Run itself: a tool that always prompts, an approver that always denies, and a different command per turn so the denial reason varies as it does in a real run. Verified by reverting the fix: the run makes 10 denied calls instead of halting at 6 and dies on the no-output guard 13 turns later, while the helper-level test stays green — which is precisely why this shipped in the first place. * fix(agent): count uncategorized policy refusals in the halt guard Reported by jatmn, and he is right that the guard missed the paths it most needed to cover. countedFailure asked `DenialReason != DenialNone`, but a category is only attached where a TYPED denial is built. A headless run leaves OnPermissionRequest nil, so the loop never reaches that branch and the registry returns a bare `Error: Permission required ...` with no category. A sandbox preflight denial on a non-shell tool loses its SandboxDecision converting to ToolResult and arrives as an uncategorized `Sandbox block`. isRetriableToolError rejects both, so both operands were false, observeToolResult took its success branch, and the record the guard accumulates was cleared. The same refused call could then repeat to MaxTurns, which is the loop this PR exists to stop. The text patterns for those outcomes already existed, enumerated inside isRetriableToolError. They simply were not reachable from the counting question. They are now a shared isPolicyRefusal predicate that both callers use, so the two questions cannot drift apart again, which is how they diverged in the first place. Also, denials no longer feed the execution-profile failure-streak trigger. That trigger restores the displaced turn budget and reasoning effort on the theory that a tool is struggling and needs room. A policy refusal is not a struggling tool, it is an answer, and spending the one-shot escalation on one contradicts the trigger's documented retriable-failure contract. Denials still count for the halt; they just no longer buy more budget. On coverage, honestly: the new tests pin the PREDICATE, including both uncategorized shapes, and I verified by mutation that removing the text branch fails them. They do NOT pin the wiring. Mutating countedFailure leaves them green, which is the same unit-versus-call-path gap that produced the original defect here. A Run-level test through the headless path is what would close it and this commit does not add one. * fix(agent): stop the halt answer claiming a pattern the counters do not track jatmn's P3. The final answer overclaimed in both directions. The content-blind bound said "each with a different error". anyErrorCount only establishes that the tool failed consecutively without a success. Five A, five B and two C reaches 12 without any signature repeating six times, and three of those errors were shared, so "each different" is false. It now says "varying errors", which is what reaching 12 without tripping the signature bound actually proves: no signature repeated six times in a row. The signature bound said "with the same error", which is false the other way for a denial streak. A denial keys on its CATEGORY precisely because the prose embeds the path or command refused and therefore differs on every call. That streak now reports as refused rather than as one repeated error, carried on a Refused flag derived from the signature prefix. The one claim that IS justified is kept: an error-signature streak really did repeat the same signature, so that wording stands. The existing denial test asserted the old "same error" phrasing, so it was describing the very defect this fixes; it now expects the refusal wording. Tests: the three wordings against their counters, plus the mixed-signature regression jatmn asked for, driven through the real counter rather than asserted about the strings in isolation, so it proves the 5/5/2 run trips the content-blind bound and is not described as all-different. * fix(agent): do not classify successful tool output as a policy refusal isPolicyRefusal decides on denial category, then permission metadata, then output text. None of those questions is meaningful about a call the tool completed, and the last one is answered by content the model does not control. isRetriableToolError gated on StatusError before calling in, so the boundary held while that was the only caller. Extracting the helper and calling it from the counting path dropped the gate: an allowed bash printing "Sandbox block", or a read_file returning a document that quotes it, set policyRefusal, made countedFailure true, and recorded a failure against the tool's signature. Six such successes tripped the same-signature stop and ended a healthy run with "the `bash` tool failed 6 times in a row with the same error". The gate belongs in the classifier rather than at each caller, because the next caller will forget it too. Covered by a direct StatusOK classifier case over every signal the helper reads, and by an end-to-end run of ten successful greps whose output quotes the phrase. Both fail against the ungated helper: the run halts at 6 with the refusal answer above. * test(agent): drive the uncategorized refusal paths through Run The categorized denial was never the gap. The gap is a refusal arriving with DenialReason empty, because a category is attached only where a typed denial is built: a headless run leaves OnPermissionRequest nil and the registry gate returns a bare "Permission required for ...", and a sandbox preflight denial on a non-shell tool loses its SandboxDecision converting to ToolResult and arrives as a bare "Sandbox block". Testing that through the helper proves nothing. The first version of this fix passed every helper test while being a no-op in production, because the loop asked a different question than the tests did. Both cases here go through Run and pin what the loop does with the classification: halt at the bound, never execute the tool, and withhold the profile's one-shot failure escalation. Each half of the wiring falsifies the tests on its own. Dropping policyRefusal from countedFailure lets the headless refusal run 13 turns instead of halting at 6. Dropping the empty-outcome branch for the posture controller reports posture_escalations = 1 instead of 0. * fix(agent): classify a policy refusal from provenance, never from tool output isPolicyRefusal fell back to matching phrases in the model-visible output, and output is tool-controlled. bash preserves arbitrary stdout and stderr on a StatusError for any nonzero exit, so an allowed command running `printf 'Sandbox block\n' >&2; exit 1` had actually executed, carried no denial category, and was still classified as refused. read_file returning a document that quotes one of the phrases did the same, which is the likelier way a real session hits it. The loop then withheld the retry hint and the profile failure-streak recovery and accumulated the executed failure toward the refusal halt, so a later stop told the user a tool had been refused when it had run. The registry already had the structured facts and dropped them on the floor. Every path that returns BEFORE the tool runs now carries one marker naming which gate refused: sandbox deny, sandbox approval required, permission required, permission denied. That includes the two cases that were previously uncategorized, the headless prompt refusal and the sandbox preflight denial on a non-shell tool, neither of which builds a typed DenialReason. isPolicyRefusal reads DenialReason, permission metadata and that marker, and nothing else. markStructuredSandboxDenial already stated this rule for the sandbox adapter, "Classification is never inferred from stdout or stderr"; this carries the same guarantee across the remaining gates. Coverage runs in both directions. The existing refusal fixtures now carry the provenance their production paths attach rather than relying on their text, and there is a Run-level regression where an allowed tool that ran, failed, and printed each recognized phrase still receives the retry hint. Reverting the classifier to substrings fails all three tests, including every phrase of the Run-level one. * fix(tools): give capture_artifact's configuration refusals the same provenance as the gates capture_artifact rejects in RejectBeforePermission, which the registry returns straight back before any of the gates that attach provenance. Its valid-but-unavailable calls therefore reached the classifier with no denial category, no permission metadata and no refusal marker, so they were read as ordinary retriable failures: the model got the schema hint telling it to fix arguments that were already valid, and the call could consume the profile failure-streak escalation, for a tool that never executed and that no argument change can enable. PolicyRefusalToolNotEnabled existed for exactly this and I never wired it. The missing-artifact-directory and disabled-driver branches carry it now. The malformed-argument branch deliberately stays an ordinary error. That one IS fixable by trying again differently, which is what the hint is for, so marking every early rejection would trade one wrong answer for another. Both directions are covered. Checked the rest of the class rather than only the reported tool: web_fetch, browser_launch, browser_connect, browser_open, desktop_windows, desktop_snapshot and terminal_session all reject on arguments alone, which is correctly retriable. capture_artifact was the only one refusing on configuration. Also rebased onto current main rather than carrying the two merge commits, per the same requirement raised on #886. * fix(agent): give a marker-only refusal the same identity the guard keys on The registry marks its pre-execution refusals in metadata, and isPolicyRefusal read that marker while observeToolResult keyed on DenialReason, which those paths leave empty. The guard fell back to errorSignature(output), so two refusals of the same category with different wording looked like two different failures and the streak restarted at 1 on every call. A model alternating capture_artifact's browser_screenshot and browser_pdf against a disabled driver is refused identically each time, and never tripped the six-call refusal halt. Only the generic twelve-error fallback stopped the run, reporting varied errors rather than a repeated refusal. The category is derived once now, at the boundary where a tools.Result becomes a ToolResult, and both the classification and the streak read that one value. It had to go in twice, because a RejectBeforePermission refusal takes its own constructor, and that is the route capture_artifact actually takes. Deriving it at the producers instead would have left the same gap for the next path that returns before the gates. One behaviour change worth stating plainly rather than burying. A headless prompt refusal is marked too, so it now carries a category and the stop answer says the tool was refused rather than that it failed with the same error. The bound is unchanged, and the new wording is the accurate one: the tool never ran. The test that pinned the old wording is updated, along with the comment that explained why it was uncategorized. * fix(agent): type the refusal identity and carry the halt to terminal status Three defects with one shape: provenance was encoded in a string, recovered by inspecting that string, and then not carried far enough. The same-identity streak keyed on one string namespace holding both a normalized error signature and a synthetic "denial:<category>" key, with provenance recovered afterwards by testing for that prefix. Trusted provenance and untrusted content in one namespace is a namespace the untrusted side can write into: a command printing exactly "denial:permission_denied" and exiting non-zero acquired the identity of a real permission refusal and the run reported it as refused although it executed every time. The identity is now a (kind, key) pair, so no output can spell a refusal. The content-blind bound reported only that the failures varied, and it fires precisely when no identity repeated, so the identity present at the end says nothing about the eleven before it. Alternating two refusal categories reached twelve without either reaching six and the answer described a tool that never ran as having failed. The record now carries the aggregate, and the guard returns a typed cause instead of two overlapping booleans, with the mixed case named rather than left to whichever field a switch tested first. The halt returned straight out of the tool loop, so it never crossed the completion gate the max-turns paths go through. Under RequireCompletionSignal zero exec treats only Incomplete as exit 4, so a task denied six times came back as a successful automation result having done none of the work. Also closes two coverage gaps that made the markers untestable: reverting either the sandbox deny marker in registry.go or the disabled-driver refusal in local_capture.go left both suites green. The sandbox case now runs a real engine evaluation through Run and asserts the body was skipped; the capture case configures an artifact root with one driver enabled so it reaches the disabled-driver branch instead of returning at the missing-directory one, with a sibling case pinning that a malformed argument stays retriable. * fix(agent): close out advertised tool calls by what actually happened Parallel read-ahead broke the assumption the aborted placeholders were written under. executeParallelReadBatch runs an entire eligible run of read calls before the loop consumes any of them, so "not consumed yet" stopped meaning "not executed". Every terminal branch closed out the calls after the current index as aborted, and a sibling that had already run was recorded that way: its real result discarded, and its callbacks, trace counter, task observation, loaded tools and images lost with it. Where the sibling is a successful read, execution may already have committed file-observation credit for content the model never receives, so the authorization state disagreed with the transcript. Each remaining call is now put in the state that is true of it. A completed one is finalized exactly once with the same bookkeeping the main path performs; an unstarted one still gets a placeholder so every tool_use keeps its answering tool_result. The guard is deliberately not consulted for a drained sibling: it cannot reverse a decision already made, it is only owed an honest record. All three early returns go through one helper rather than repeating the assumption, so the next stop condition inherits the fix instead of the bug. * fix(agent): authenticate refusal provenance and separate completion from abort Two things this branch left keyed on something that could disagree with the fact it stands for. A tool that ran and failed could claim the registry refused it before it ran. IsPolicyRefusalResult trusted a metadata key, and Registry.RunWithOptions forwards an executed result and its Meta unchanged, so a tool could set it by mistake, by copying metadata forward from something it called, or on purpose. The loop then withheld the retry hint, suppressed the failure-streak recovery, counted the call in refusal accounting, and could tell the user a tool was refused when it had executed. That is the output-text trust problem one layer down. The execution boundary now strips the marker, so no value survives running, recognized or invented. Pre-execution refusals are untouched, including RejectBeforePermission, which decides before any of this. precomputedResultFor treated any batch entry carrying an abort error as unstarted. Producing a result and asking the run to stop are different facts, and executeToolCall's cancelled-permission path returns both: an earlier sibling reaching a terminal branch would discard the real cancellation result and write an aborted placeholder over it. The batch now records what it ran, where that is known, and the placeholder is reserved for entries that produced nothing. The terminal decision is unchanged; draining only makes the record honest. * test(agent): pin a drained read-ahead sibling's image through the guard halt The halt drains read-ahead siblings that already ran and records them as completed, images included. Images now reach the transcript through the turn's deferred builder, and nothing checked that a drained sibling's image still went through it: dropping it left every test green. The probe tool returns an image from the sibling and the run must carry exactly one image message. * chore: follow the Twigpine module path main moved the module to github.com/Twigpine/zero in #1105. Rename this branch's imports to match, including the two in internal/workspaceindex that main itself still carries until #1153 lands. * chore(agent): drop two unused zero-value constants failureKindNone and toolFailureCauseNone were never referenced, so the pinned unused check flagged them. The zero values stay reserved with a blank identifier. * fix(agent): report mixed guard halts as mixed and pair drained siblings - toolFailureIncompleteReason gains the mixed branch, so a headless run halted by the content-blind bound over failures and refusals says the tool failed or was refused, as the stop answer does. - closeOutRemaining sets ToolCallProviderID on a drained sibling's tool result, matching the consumption path, so a strict replay can pair it. - executedToolResult strips permission_action as well as the refusal marker. The loop reads a denied permission action as a refusal, so an executed failure carrying one was counted toward the refusal halt. The key is a tools constant now, and the loop uses it too. - The parallel read-ahead comment says what differs from sequential execution: a halt can leave up to seven sibling reads already run. Reported by @jatmn.
…separately (#883) * feat(tui): put unsafe mode in the shift+tab cycle behind a confirm key Unsafe was reachable only via --skip-permissions-unsafe at launch, which is bad discoverability: the mode exists, works, and nothing in the TUI tells you so. It is now the third position in the shift+tab cycle, alongside auto and ask. What it is NOT is reachable by repeating a navigation key. Unsafe turns permission prompts off entirely, so shift+tab only ever OFFERS it; committing takes ctrl+g while that offer is live. Press shift+tab again instead and the offer is declined and the cycle continues to auto, so every mode stays reachable with shift+tab alone. The offer lives on the model across keypresses, and that is the part worth being careful about: a stale flag would turn a later innocent ctrl+g into a silent drop into unsafe. So it is cleared unconditionally at the top of the key handler and re-armed only by the shift+tab branch. Forgetting a path therefore cancels the offer rather than leaving it live, which is the harmless direction to be wrong in. Tests drive the real handler for eight different cancelling keys and assert the consequence, not just the flag. ctrl+g is guarded in the case expression rather than the body, so without a live offer the key is not consumed at all and falls through to whatever would normally handle it. That is what stops it being a standalone shortcut into unsafe, and there is a test that presses it repeatedly from every other mode. Leaving unsafe stays one press and is never gated. Getting stricter should not need confirming. Returning to auto from ask now costs two presses, since it passes through the offer. That is inherent to a third position in a cycle rather than a regression, and TestShiftTabCyclesPermissionMode was updated to walk the whole loop rather than assume two positions. An earlier draft of this had the second shift+tab commit unsafe, which silently removed ask -> auto from the cycle entirely. TestPermissionModeCycleNeverReaches UnsafeOnItsOwn walks the full loop and asserts every mode stays reachable, so that cannot come back unnoticed. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(sandbox): stop classifying local dev servers as network egress `python -m http.server` was denied with "network access requires approval". Serving files out of the workspace on a local port is not reaching out, and treating it as egress made the single most common thing an agent is asked to do while building something stop for an approval that protected nobody. The analyzer already had a localServerPrograms map sitting beside networkPrograms, but commandUsesNetwork returned true for it anyway, so the distinction had been drawn and never acted on. It is acted on now: AnalysisResult carries LocalServer separately, so the information is preserved rather than dropped, and a caller that does care about inbound can still see it. Covers the same set consistently. `next dev` and `npm run dev` are the same intent, so classifying one as binding and the other as fetching would have left users hitting exactly the same wall through the other door. Both are LocalServer now, across npm, pnpm, yarn and bun, as a direct subcommand and behind `run`. What still counts as network is unchanged: install, add, ci, create, publish, login, exec, and every fetching program. `npx http-server` in particular stays network, because npx downloads the package when it is missing; the test caught that when a first pass flipped it, which is why the bind-versus-fetch pairs are now pinned side by side in the table. The unparseable fallback regex is updated to agree. Left alone it would have flagged an obfuscated dev server for network while the same command written plainly did not, which is the kind of inconsistency that is very hard to explain to whoever hits it. Being honest about the edge: some of these touch the network incidentally, and `npm run dev` may install first. The claim is narrow, that BINDING is not EGRESS, not that dev tooling is inert. Anything that actually fetches still matches through its own program or subcommand. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * refactor: rename the unsafe permission mode to full-auto "unsafe" was a judgement rather than a description, and it sat oddly beside auto and ask. full-auto says what the mode does and reads as the obvious third step: ask, auto, full-auto. Not "unrestricted", which was the other candidate and is factually wrong. This mode turns off permission PROMPTS. The OS sandbox stays on, the write jail still holds, and a label implying nothing restrains the agent would be wrong in the dangerous direction. The on-disk value changes to "full-auto" and "unsafe" is accepted permanently as an alias rather than migrated. That value lives in user configs and in scripts, and a session silently falling back to auto because its saved mode no longer parsed would be a confusing downgrade rather than a visible error. --full-auto is the new flag; --skip-permissions-unsafe keeps working and is documented as the deprecated spelling. The exec warning names "the full-auto flag" generically, because either spelling reaches it and the bool does not record which was typed: claiming --full-auto when the caller passed the old one would be a small lie in a warning, which is the wrong place for one. The warning also says "prompt-gated tools run without approval" rather than anything broader, for the same reason the mode is not called unrestricted. What deliberately does NOT change is the colour. The name can be calm; the indicator should not be, so full-auto keeps the alarm style in the status bar and the ctrl+g confirm gate is untouched. The Go "unsafe" package is imported in fifteen files here, so the rename was done by identifier token only and the imports were verified intact afterwards rather than assumed. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix: keep the old permission-mode constant names as deprecated aliases The rename broke CI, and it broke it in the merge rather than on the branch: this branch is ten commits behind main, CI builds the merge, and newer main code still references PermissionModeUnsafe and PermissionUnsafe. Deleting a constant that other work is actively using turns an ordinary merge into a compile failure for whoever merges second. Both old names are restored as deprecated aliases of the full-auto constants. Same value, so behaviour is identical, and code on either side of the rename compiles. My local check missed this because `go test ./internal/...` returned "ok (cached)" for internal/agent, and a cached result cannot catch a compile error. Verified this time with -count=1 and against an actual trial merge with origin/main rather than the branch alone. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix: make the full-auto rename reach the values that travel as data The rename kept a Go alias for PermissionModeUnsafe, which covers callers that name the constant. It does not cover a mode that moves as a string, and several do, so those paths went on comparing against "unsafe" and stopped matching. Three places were affected: - swarm permissionRank did not rank "full-auto", so it scored 0, the strictest tier. A full-auto parent clamped its members harder than an ask parent. - specialist specialistAutonomy did not match it either, so a full-auto parent's specialists dropped to read-only "low" autonomy. - the agent loop compares Options.PermissionMode directly, so a caller passing the old spelling got prompts instead of full-auto. All three fail safe, which is why nothing broke loudly. Added agent.NormalizePermissionMode and applied it at the single point the loop reads the mode off Options, and taught the swarm and specialist constants both spellings. Their existing tables only listed "unsafe", which is exactly how the rename passed review. Separately, permission_mode_arm_test.go was never compiled. Go read the trailing "_arm" as a GOARCH constraint and excluded the file from every amd64 build, so the five tests covering the shift+tab full-auto offer had never run, locally or in CI. Two panicked once they did. The file is renamed, the model construction fixed, and a repository-wide test now fails on any _test.go whose name ends in a GOOS/GOARCH token without an explicit build tag. With those tests actually running, the offer gate had a real hole: unsafeArmed was cleared only in the key handler, so a paste or a mouse click left the offer live and a later ctrl+g committed full-auto with nobody having accepted it. Paste and deliberate mouse actions now cancel it. Passive motion does not, since terminals stream motion while tracking is on and cancelling on a twitch would make the confirm key unreachable. Also: commandRunsLocalServer matched on program name alone, so "next build" and "vite build" claimed to bind a port while compiling. Nothing reads the flag yet, which is why it could be wrong quietly. Fixed to require a serving subcommand, falling back to bare-invocation behaviour when firstSubcommand lands on an option value rather than a subcommand. Remaining wording fixes name full-auto rather than unsafe in the retry reasons, the exec warning, and the shell-escape notice. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * test(tui): move the plan-mode guard onto advancePermissionMode The rebase renamed nextPermissionMode to advancePermissionMode, and main's plan-mode test still called the old name, so internal/tui did not build. Also asserts the second return value. Plan must never carry a full-auto OFFER either, or two presses from Plan would reach the mode that turns permission prompts off entirely, starting from the one mode that promises no mutation. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(sandbox,cli,tui): keep serving commands gated, and accept the canonical mode All five of jatmn's findings. The two P1s were the same mistake in two places: the LocalServer classification was treated as a REPLACEMENT for Network when nothing consumes it. No policy or runner code reads LocalServer, so classifying a serving command as local-only granted it no host listener; it only removed the network approval it used to get, and the command then ran under the default deny profile. On Linux that is a network namespace and on macOS (deny network*), so `python -m http.server` and `vite` started with no prompt and could not serve a preview to the operator's browser. The package-manager half is the sharper one. `npm run dev` is matched by SCRIPT NAME, and the repository decides what `dev` and `predev` actually do; either can curl before anything binds a port. On Windows the approval gate IS the network protection, so inferring no-egress from a name lets that egress run unprompted. LocalServer is now additive: the classification stays, because a scoped host-listener path will want it, and the approval path stays until that path exists. One line covers both findings, since both flow through the same classification. The PR's own tests asserted the premise being corrected, so they were rewritten rather than flipped: building still counts as no egress, serving now asserts it keeps BOTH the LocalServer classification and the network approval, and the table rows moved with it. The three P2s: resolveExecPermissionMode accepted only the deprecated `unsafe`, so `--permission-mode full-auto` failed usage validation before NormalizePermissionMode was ever reached, while the warning code already had an unreachable full-auto branch. It now accepts the canonical spelling and keeps unsafe as the alias, and the usage text names full-auto. newModel copied the raw mode through while the TUI tests only for PermissionModeFullAuto, so an entry point handed the accepted legacy value rejected ! shell escapes, published a prompting peer identity and chose low self-correction, even though agent.Run normalized the same run to full-auto. One value, two behaviours, decided by which layer looked at it. It is normalized at the TUI boundary now. Both completion inventories listed only --skip-permissions-unsafe, so no generated shell script could suggest the documented --full-auto. Both now carry the canonical flag alongside the deprecated alias. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(tui): cancel the full-auto offer when the terminal loses focus Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(sandbox,tui,cli): close the unparseable network gap and the deferred-input arm Five findings from review. The unparseable fallback lost the serving forms on the reasoning that they bind rather than fetch. The AST path sets Network for every recognized LocalServer anyway, deliberately, because nothing consumes LocalServer yet and `npm run dev` is matched by script name where the repository decides what dev and predev do. So dropping them did not align the two paths, it split them: the POSIX parser rejects Windows shell syntax the invoked shell accepts, and if "%OS%"=="Windows_NT" (npm run dev) else (npm start) came back parsed=false network=false while every parseable spelling got network. That is the approval gate disappearing on the platform where it is the only egress control. Restored as a superset, with a regression that asserts both spellings of the same intent classify alike and fails loudly if the parser ever learns the syntax. tea.PasteMsg cancels the full-auto offer, but a right-click paste does not arrive that way: it starts a clipboard read, and shift+tab can reach the offer while that read is in flight. The delayed delivery inserted text and left the arm alive, so an ordinary ctrl+g afterwards turned permission prompts off with the user several actions past the confirmation. Cleared before the branches, on the image delivery too, and on transcribed dictation for the same reason. Specialist registration read the raw CLI fields while execution read the resolved mode, so `--permission-mode full-auto` composed a registry without Task and swarm tooling while `--auto high` and `--full-auto` composed one with it. The mode is resolved before the registry now and the predicate consumes it, so a new alias cannot create another unequal capability set. The full-auto warning matched the typed --permission-mode value against three spellings while the resolver accepts four, so `--permission-mode full_auto` was told --auto high was responsible. It echoes what was typed instead of matching a list that has already drifted once. Help and validation text still led with the deprecated spelling: --permission-mode listed "unsafe" as its value, --auto high was described as enabling "unsafe tools", and the root-flag errors named --skip-permissions-unsafe. All now present full-auto as the mode and the primary flag; the deprecated alias stays where its compatibility is the point. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(tui,sandbox): cancel the offer on a streaming partial, and derive the network fallback from the analyzer Two findings, both follow-ons to fixes I made last round. A streaming dictation partial did not cancel the full-auto offer. The final transcript did, and my note there said starting dictation is a keypress that already clears the arm, which does not cover this: the offer can be armed AFTER dictation is running, the next partial rewrites the composer, and active dictation is not a blocking modal, so an ordinary ctrl+g still confirmed with the user several actions past the confirmation. Cleared at the dispatch boundary rather than inside handleDictationPartial, so a future partial-delivery path inherits the rule. The regression drives a genuinely live session and fails if the partial never reaches the composer, so it cannot pass on a session-mismatch early return. The unparseable network fallback is meant to be a superset of everything the AST path flags, and it was maintained as a separate inventory, so it drifted. The analyzer accepts "py" as a Python launcher and the regex listed only python, python2 and python3: py -m http.server 8000 parsed=true network=true if "%OS%"=="Windows_NT" (py -m http.server 8000) else (..) parsed=false network=false if "%OS%"=="Windows_NT" (python -m http.server ...) else .. parsed=false network=true On Windows that approval IS the egress control. Rather than adding the alias and leaving two lists to drift again, the launchers are one named inventory the analyzer uses at both call sites, and the fallback test iterates it, so a launcher added there fails immediately if the regex does not cover it. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(sandbox): a flagged invocation classifies like its unflagged self at any arity Raised by CodeRabbit. Skipping flags is not enough, because it does not skip the words they CONSUME: `npm --prefix ./web install` resolved to "./web", the option's VALUE, and stopped being recognised at all — so a command genuinely fetching from the network lost the approval its plain spelling gets. The first fix offered a fixed window of two positions. That covers exactly ONE value-taking option, and a second walks straight past it. Measured before this change: npm --prefix ./web install -> network (correct) npm --prefix ./web --loglevel warn install -> NOT network npm --registry https://r.test --prefix ./web install -> NOT network pnpm -C ./web --filter web add left-pad -> NOT network All four genuinely fetch. ADJACENCY DECIDES NOW, because it is the actual grammar: an option can only consume the word immediately after it. Every leading operand sitting right after a flag might be that flag's value, so each opens another position; the first operand NOT preceded by a flag cannot be anyone's value, and the window closes there. The arity is counted rather than assumed, and no option is ever named — which was the point of not enumerating them, since that is four tools each free to add one. The run has to be CONTIGUOUS, not a count of flags anywhere in the line. Counting every flag lets TRAILING options widen the window back over words they have nothing to do with, and three cases flip to false positives when it does: npm run --grep foo --tag dev -> network AND localServer npm run test --reporter x --filter dev -> network npm run build --a x --b start -> network The false positives the old cap protected against are unaffected, and for a stronger reason than the cap gave: `npm run build --workspace dev` and `npm run test -- --grep start` put an unflagged operand FIRST, so the window is one position wide however many flags follow. The cap held only because two happened to be short enough. Tested as a PROPERTY rather than a list: each flagged form is paired against its unflagged baseline, so a change that shifts both still fails. Eight pairs, the "="-joined forms and repeated flags included. Two mutations, each caught — restoring the fixed window mis-classifies five, dropping the contiguity requirement widens three. Also from a verification pass: The doc comment claimed the cap at two was justified purely by argument-position false positives and never said a second value-taking option defeated it. It now describes what ships. `npm --prefix dev install` reads a directory named "dev" as a script name. Pinned rather than fixed: the ambiguity is the point of the window, Network is already correct because the install really does fetch, and LocalServer only implies Network — so the union is conservative in the safe direction. An earlier note justified leaving internal/tui/session.go unnormalised by saying the value feeds transcript rendering and the render cache. It feeds only the cache fingerprint — grepping every reader of PermissionMode in that package returns render_cache.go and nothing else — so the tradeoff described did not exist. It is normalised now, and two spellings of one mode no longer evict the cache for nothing. The ACP tests asserted on ConfigOptions[1], a magic index that would move onto a different option if the advertised order changed. They select by ID. Rebased onto ad34dc8. Pre-existing here and on main: TestRunDoctorFormatsRedactedProviderDiagnostics and TestRunDoctorConnectivityProbesProvider exit 3 in this environment. Origin-Session: local-c962d7 | Claude Code | 5 prompts Origin-Snapshot: 3bb420a0a97b * fix(sandbox): keep framework builds under the network gate Splitting LocalServer out of the network classification also dropped localServerPrograms from commandUsesNetwork, so next build, vite build, nuxt generate and astro check came back Network=false. Those CLIs run the repository config, plugins and application code during a build as surely as during a serve, and on the platforms where the approval gate is the network boundary an ordinary shell grant would have run them without the separate network decision main applies. The test that pinned Network=false for builds is replaced. Network stays conservative for the whole framework inventory; LocalServer alone carries the serve/build distinction. The framework classifier now walks the positions a subcommand can occupy instead of reading the first operand, so a global option before the subcommand (vite --config vite.prod.ts build) no longer makes a build count as a server. Regressions: build-like and option-bearing forms are Network=true and LocalServer=false at the analyzer, serving forms are both, and Engine.Evaluate still returns the network prompt for a framework build after a bash allow grant. Reported by @gnanam1990. * fix(tui): keep the full-auto offer visible before ctrl+g can accept it The offer renders through modeLabel into the left chip, and several statuses replaced that chip wholesale: an active recording, a transcription, and a model download. Arming while the mic was live therefore showed REC while ctrl+g still committed full-auto, so the user was asked to confirm something the footer never put in front of them, and permission prompts went away. offerOwnsStatusChip makes a live offer outrank the statuses that merely report what is happening, in both statusLine branches, since the tiny and non-tiny paths reach the chip differently. The two confirmations that ask their own question still win, because those are what the user just pressed a key for. The confirm key consults the same rule through offerConfirmable, which takes the armed flag as an argument because the handler captures and clears m.unsafeArmed before its switch runs. Sharing one expression is the point: an offer that cannot be displayed is not one that can be accepted, so a status added later cannot reopen the gap by taking the chip. The regression asserts the implication through the real renderer and the real handler, matrixed over the contending states and three widths: if the mode became full-auto, the frame shown before the key contained the offer. It also asserts the converse, so a fix that merely made confirmation unreachable would fail it. Reported by @jatmn. * fix(tui): deliver peer callbacks to the event loop through an ordered forwarder Service.UpdateIdentity invokes the held-release handler synchronously for every message that becomes deliverable, and the shell calls UpdateIdentity from inside Update on the shift+tab and ctrl+g paths that change the permission class. The handler called program.Send, which waits on the unbuffered message channel that only the loop reads, and the loop was inside that Update: confirming full-auto with a bypass-mode peer's message held froze the shell. Peer callbacks now append to a FIFO drained by one goroutine, so the caller returns, order among peer events is kept, and a late callback after exit returns on the cancelled program context. The wiring is a function with a fake-able service so the regression drives a real Bubble Tea program through the production shape. * test(cli): isolate user state in the full-auto parity helper and pin it execListToolsFor supplied a temporary cwd and a mocked provider config, but runWithDeps filled the rest with production dependencies, so --list-tools refreshed the developer's models cache, started their MCP servers and could touch their config before returning. The helper applies isolateCLIUserState first, and the helper-isolation table now covers it. * fix(tui): only offer full-auto where the footer can show the confirmation key The footer reserves columns for a docked pet before it renders the status line, so at 24 and 30 columns the offer came out truncated with no ctrl+g in sight while ctrl+g still confirmed. The armed flag now means what it says only when the footer, at its effective width after the reservation, shows the key: the decision is made on the same truncation the footer applies, an offer that cannot be shown is not raised, and a live offer is withdrawn when the terminal shrinks under it. Pinned through the complete View at 24 and 30 columns with a pet, with 30 pet-free and 96 with a pet as controls. * fix(tui): end a full-auto offer on cross-session peer traffic The offer made by shift+tab is valid only until the next user-visible input transition, whatever delivers it. Paste, blur, mouse, the clipboard and dictation all honoured that; peer delivery did not. A peer message raises an approval prompt or lands in the inbox, a held message is released after a mode sync, a status line or a peer error is appended to the transcript, an approval expires and its prompt goes away. Each changes what the user is looking at, so shift+tab, then peer traffic, then an unrelated ctrl+g still entered full-auto with the confirmation several events behind them. The offer is cleared for the whole peer message family at the dispatch boundary in updateModel, not in the three handlers the report named. Those were the ones that reproduced; the decision, expiry and error deliveries are the same kind of transition and were armed the same way, and a rule written per handler is a rule the next handler forgets. isPeerDelivery is a closed list, and a test reads the package source for every peer*Msg type and fails by name if one is not classified and not driven. The regression sends one production message of each of the seven types through Update, requires the offer gone and ctrl+g to leave the mode alone, and then requires a fresh shift+tab to offer and confirm again, so it cannot pass on a mode cycle that has become unreachable. The message that needs approval also has to have raised its prompt. Reported by jatmn. * chore: follow the Twigpine module path main moved the module to github.com/Twigpine/zero in #1105. Rename this branch's imports to match, including the two in internal/workspaceindex that main itself still carries until #1153 lands. * refactor(cli): use PermissionModeFullAuto instead of its deprecated alias This branch marks PermissionModeUnsafe deprecated, so staticcheck reports SA1019 at every use outside the agent package, including three in cli and one in a test that came in from main. The alias is the same value, so nothing behaves differently. * fix: honor the resolved mode, network inventory, and peer admission decision Explicit permission modes were still registering specialist tools from raw flags, the unparseable network fallback had drifted off the analyzer's fetch subcommands, a hidden full-auto offer trapped Shift+Tab on Ask, and a peer timeout left the queued message runnable after refusal. Co-authored-by: Cursor <[email protected]> * fix: stop the models.dev refresh from racing test cleanup rpmTestDeps redirected the cache into TempDir but left the background fetch enabled, so the writer recreated zero/ while RemoveAll was deleting it. The peer admission test now releases its stalled drainer before stopping the forwarder. Co-authored-by: Cursor <[email protected]> * fix: preserve network approval for quoted package-manager options Keep quoted and escaped option fragments together in the unparseable-command fallback. Verify the network approval decision and cover exact-fit full-auto offers through the real footer and key handler. * fix: invalidate full-auto offers at BTW session boundaries A BTW fork copied the pending offer into both the side model and the saved main model. Main-session events were then dispatched to the hidden model before the visible side could drop its offer. Disarm before taking the fork snapshot and at the common main-session routing boundary. A fresh offer can still be confirmed on the side. With the new tests on the previous code, Ctrl+G after forking, restoring main, and receiving a main completion or permission request returned full-auto (want ask). The tests pass with both resets. Exercise the canonical --full-auto flag in the interactive root flag-order matrix alongside its legacy alias. --------- Co-authored-by: KRATOS <[email protected]> Co-authored-by: jatmn <[email protected]> Co-authored-by: Cursor <[email protected]>
What changed
Two import lines in
internal/workspaceindex, fromgithub.com/Gitlawb/zero/internal/gitsafetogithub.com/Twigpine/zero/internal/gitsafe.Why
#1149 was opened before #1105 moved the module path, and it was merged a minute after #1105, so its two imports of
internal/gitsafestill used the old path. Nothing providesgithub.com/Gitlawb/zeroany more, somaindoesn't build at 2ffe183:Every CI job on that commit failed. No other Go file on
mainimports the old path.Verification
On Windows, at this branch:
go build ./...,go vet ./...,gofmtandgit diff HEAD --checkare clean.go test ./...passes.go run ./cmd/zero-release buildandsmokepass.govulncheck ./...reports no vulnerabilities.Summary by CodeRabbit