write_to_file publishes its own whole-file read as never-read, and drops the approved outside-workspace identity (split unit planned from pull 2444)
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- tooling
Direzione di ricerca
Start in src/core/tools/WriteToFileTool.ts, where the prevent-focus arm reads the whole file without recording an observation and both publish calls (saveDirectly, saveChanges) use the old argument lists. Then read src/core/tools/guardedWrite.ts (the never-read branch) and the parameter handling in src/integrations/editor/DiffViewProvider.ts. Done means the new spec writeToFileTool.guardedPublish.spec.ts fails before the change and passes after, asserting the publish arguments and the recorded observation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What the code prints
At head 8948d9a30d4865cc6cd955144debf7f94735453d, src/core/tools/WriteToFileTool.ts still publishes with the pre-guard argument lists: saveDirectly is called with five arguments at line 135 and saveChanges with two at line 167, so the guarded kinds and the approved-target arguments stay defaulted.
- The prevent-focus arm reads the whole file itself at line 114 and records no observation. guardedWrite therefore finds obs undefined and takes its never-read branch (src/core/tools/guardedWrite.ts lines 674-682, createIfAbsent): it refuses a target that this very arm had just read end to end. The arm holds the complete content and the guard is told nothing about it.
- Neither arm threads the approved outside-workspace identity that saveChanges (src/integrations/editor/DiffViewProvider.ts lines 530-541) and saveDirectly (lines 1689-1704) exist to receive, while the tool computes isOutsideWorkspace at line 88 and puts it only into the approval payload at line 94.
- The diff-view arm behaves as designed and is not part of this unit: open() records a partial preview observation only when none exists (DiffViewProvider.ts 203-206) and a verified empty placeholder as complete (239-259), so a never-read existing file correctly gets the re-read remediation and a new file publishes against the placeholder token.
Measured size of the fix
32 changed executable lines in package extension, measured with the repo gate's own function (scripts/stryker-diff.mjs buildManifest over the drafted working-tree diff; 49 raw lines added, 4 deleted). The ceiling is 500 changed executable lines per package. Drafted source is preserved in the lane capture at .tmp-n202237-cutshape/sec83/WriteToFileTool-draft.ts.
This is why the fix is a unit of its own rather than a commit on pull 2444: that pull is priced by the hosted gate itself at 1315 changed executable lines (log line of job 132565556554) against the 500 ceiling, so the gate refuses there whatever this delta is, and carrying it would buy the change no mutation proof. On its own branch the delta is 32 of 500 and the gate can run on it.
Plan for the unit
- Branch n20/w2f-publish-guard from main at f015dae5326501ef5eb70616ac698828465b0deb.
- src/core/tools/WriteToFileTool.ts: bracket the prevent-focus arm's whole-file read with stats and record it as a complete observation only while the bracketing stats agree; name the guarded kind the operation is (update for an existing target, create for an absent one); capture canonicalizeForApproval before the ask for an outside-workspace target and thread it, plus the approved flag, into both publish arms. No knob, no suppression, no directive.
- Add the regression spec at the lowest layer that would have failed: src/core/tools/tests/writeToFileTool.guardedPublish.spec.ts, asserting the arguments the two publish calls receive and the observation the prevent-focus arm records - not merely that a method was called.
- Prove both directions: the new spec red at the pinned head blob, green with the fix; counts printed by each run with the transcripts named and the on-disk hash of the pinned source captured before the run starts.
- Run the local mutation preflight on the unit delta (its own base, not main) before pushing, with no Stryker disable directive added.
- Lint with the shared prune switch left off from a real pnpm install --frozen-lockfile, prove src/eslint-suppressions.json byte identical to its blob, add no changeset and no changelog entry per AGENTS.md.
Gaps this unit does not claim to close
- Host scenario: no recorded extension-host scenario exercises the refusal. Both recorded write_to_file scenarios create new files (fixture ids call_write_to_file_create_001 and call_write_to_file_nested_001, expected payload fragments "operation":"created"), so a green host run on that suite shows no regression and does not clear the refusal path. A host scenario that overwrites an existing file would have to be written and is not claimed here.
- Assertion hole, the same one apply_diff had before its own spec: src/core/tools/tests/writeToFileTool.spec.ts asserts only that saveChanges was called (expect(mockCline.diffViewProvider.saveChanges).toHaveBeenCalled()) and never reads its arguments, so it passes identically with and without the fix.
Where this came from
Named for provenance, with no verdict asked of anyone: pull 2444 (https://github.com/Zoo-Code-Org/Zoo-Code/pull/2444) is where this class of defect was found while repairing that pull's red required leg e2e-mock; the sibling tool was named there and left unfixed. Queue rows q4352 (this unit) and q4344 (the 2444 leg) carry the lane records.
- Lingua principale
- TypeScript
- Stelle
- 2k
- Fork
- 301
- Merge medio
- 3g 14h
- PR unite (30g)
- 103
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Zoo-Code-Org/Zoo-Code
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Zoo-Code-Org/Zoo-Code#2773 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Zoo-Code-Org/Zoo-Code#2717 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Zoo-Code-Org/Zoo-Code#2515 ·
I maintainer di solito rispondono entro 3 giorni
-
fix(scripts): stryker-diff.mjs spawns the extensionless .bin shim and cannot run on WindowsForse già presa @easonLiangWorldedtech l’ha presa 15 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Zoo-Code-Org/Zoo-Code#2514 ·
I maintainer di solito rispondono entro 3 giorni
-
[BUG] search_files hides matching text on long linesForse già presa @DananjayaNadun l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Zoo-Code-Org/Zoo-Code#2496 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di Zoo-Code-Org/Zoo-Code
Issue simili
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
EPPIcenter/sampledb3#162 ·
-
Particle-1 modelAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
tashfeenahmed/freellmapi#2169 ·
I maintainer di solito rispondono entro 1 giorno
-
via-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
🎙️ task - feat(mechanic): pave git.pull.close, a close of a superseded pull with its why on recordAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ehmpathy/rhachet-roles-ehmpathy#1576 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
vercel-labs/ui#1563 ·
I maintainer di solito rispondono entro 1 giorno