Repository navigation
feat(tools): route the remaining write tools through the guard (U7, #1375) - #1918
Open
easonLiangWorldedtech wants to merge 201 commits into
Open
easonLiangWorldedtech wants to merge 201 commits into
easonLiangWorldedtech wants to merge 201 commits into
Conversation
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.
This unit routes the five remaining write tools —
apply_diff,write_to_file,edit,edit_file,search_replace— through the shared write guard. After this unit no tool path overwrites a file the model has not read: an unearned write fails with the re-read remediation instead of publishing.A write outside every workspace root is no longer rejected outright. The tool layer classifies the path against all workspace folders, asks the user, and forwards the approval to the guard, which re-checks containment against the approved roots before it publishes.
This unit is the seventh of nine pull requests for epic #1375. The chain is tracked on #1991.
Related GitHub Issue
Closes: #2426 (this unit's tracking issue). Refs: #1991 (chain tracking), #1375 (epic), #2317 (directory-identity binding, which the staging guard in this unit addresses). The template form is used for the unit's own tracking issue; no closing reference is used for the chain or the epic, because the maintainer closes those when the series lands.
Description
What this pull request changes:
DiffViewProvider.saveDirectly()andguardedWrite()with an explicit write kind, so a targeted edit is never treated as a full-file replacement.bigintfs.statpair and observes it only when both tokens match, so a publish is authorized by the exact bytes the hunks were computed from. A stat failure leaves the file unobserved and does not fail the read.Diff size. The branch carries its own copies of the earlier units' content, so the GitHub diff shows that content as context. Measured over
base...headfrom the merge base41cf71a72c45fefb69b6be785c4620669f41c1e9to head284f1309bdca: 80 files, of which 51 sit outside the test directories,27924additions and431deletions over 201 commits; the pull-request fields read 80 files, 27924 additions, 431 deletions and 200 commits, so the two agree. The merge base equals the base commit, so the head is 200 commits ahead and 0 behind: no refresh is pending.Test-file scope. No
webview-uifile remains in the diff: measured at head284f1309bdca, 0 of the 80 changed files sit underwebview-ui/. The fivewebview-uitest files that were in this diff earlier in the chain were removed from it, the last of them answering review row 4568686689.Review focus: the tool classes named above,
src/core/tools/guardedWrite.ts, and the specs named below.Test Procedure
From the repository root, with dependencies installed:
Measured at head
f3496c6e9295on 2026-12-04 by the pull request author's lead, on the same bytes as the checks below. The only commit since then,284f1309bdca, changes files underdocs/architecture/tlaonly, so the suite figures below apply to the current head unchanged:webview-uifile is in the diff and the vitest entry point does not resolve in the worktree this measurement was taken in; the last recorded measurement of it is 207 test files and 2736 tests at head6e0c6db634f6.The repository gates all exit 0 on the same bytes: format check, root lint, root type check, src lint, src type check, Code QA workflow (7 tests), translations (68 tests), knip, knip-production, knip-policy (8 tests), MCP integration, lifecycle model check, and the mutation channel unit tests (106 tests).
One lint invocation in that run exited 2 because it was given root-relative paths; re-run with source-relative paths it exited 0 and left
src/eslint-suppressions.jsonbyte-identical to the committed blob. The correction is recorded in the run log rather than dropped.Environment: Windows, unit layer only. The end-to-end and visual lanes run in CI.
Pre-Submission Checklist
src/eslint-suppressions.jsonunchanged: no suppression count increased.--max-warnings=0rather than relying on suppressions.Visual Snapshots
Not applicable. No rendered surface changed; the approval prompt is the existing one.
Videos (interaction / animation only)
Not applicable.
Documentation Updates
No user-facing documentation change. The guard is internal behaviour of the write tools, and the model-facing remediation text already existed in earlier units. No changeset and no changelog edit, per AGENTS.md.
Additional Notes
284f1309bdca, nowebview-uifile is in the diff at all, so there is no out-of-scopewebview-uifile to explain. Of the 80 changed files, 30 are underdocs/(the TLA+ models this unit writes alongside the code) and 49 sit outside test directories -webview-ui/src/utils/validate.tsis the same blob at the base and at this head (aa34fa4e8d39, 11,598 bytes) - and that file is the only place in this campaign where review row 4568686689 (Major, maintainability, anchored at line 140 of the file, now marked addressed by the reviewer) is answered: it asks that each credential-rejection case be paired with a valid configuration asserted throughvalidateApiConfigurationExcludingModelErrors, and the answer is commit e632244. A census of the 79 open pull requests authored by this account found none that changeswebview-ui/src/utils/validate.tsand none other that carries this file, so no open pull request exists to move it to. The scope check has failed twice while this disclosure was already in the description, which is measured evidence that prose does not clear it; a routing request covering this file and the groups named on fix(webview): send stable view-state id on launch and re-pin per-view state #1552 is recorded in comment7294670772, which lives on fix(webview): send stable view-state id on launch and re-pin per-view state #1552 rather than here.284f1309bdcatheextensionpackage holds 2626 changed executable lines and no other package is over 500, so the check fails on this head as it did on its predecessors while all seven required contexts pass. Two ways out need a maintainer: a narrow exclusion for the packages the check names, or authorization to split the chain further with a tracking issue that carries the plan before a split pull request opens. No Stryker disable comment and no suppression change is used in place of that decision.Get in Touch
Reviewer and maintainer questions are welcome as comments on this pull request or on #1991.