You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d8c34aa
Browse filesBrowse the repository at this point in the historyBrowse files
easonLiangWorldedtech
committed
fix(tools): stat-match the create placeholder + fail-closed save cleanup (S4b, #1375)
CR incremental review on d037753 raised two findings on the create
branch of open() (DiffViewProvider.ts):
1. A placeholder another writer touched between open()'s fs.writeFile() and
the observation was recorded as a complete observation of content open()
never read (and would let the token-guarded cleanup unlink the writer's
file). The create branch now verifies the placeholder with the same S2
stat-matched contract as the modify branch: pre-stat, utf-8 read, post-
stat; only a stat-matched empty read records the token as a complete
observation. A non-empty read or stat mismatch (or a failed post-stat)
records nothing, so the prior observation is untouched and the save fails
closed.
2. A rejected save with a collected task threw before the discard-only
cleanup, leaking the empty placeholder. The fail-closed throw now sits
inside the try block so the task-unavailable rejection flows through the
same cleanup as a guard verdict (token-guarded placeholder unlink, dirty
discard, diff close). The cleanup token is captured in open() whether or
not the task is still live: it is provider state used only for cleanup,
while the observation (task state) stays gated on a live task.
Specs: the placeholder-observation tests now stat-match (two bigint stats +
utf-8 read); the collected-task case expects the cleanup token to be
captured with no observation; new cases cover a writer-contested
placeholder, a failed post-stat, and a bracketing-stat mismatch.
164/164 affected suites; tsc --noEmit and eslint --max-warnings=0 clean;
suppression counts unchanged.
@@ -401,18 +419,21 @@ export class DiffViewProvider {
401
419
// changed after the preview or the target was never observed, with the
402
420
// standard re-read-then-retry remediation.
403
421
constsaveTask=this.taskRef.deref()
404
-
if(!saveTask){
405
-
// Fail closed: without the owning task the observation registry is
406
-
// unreachable and the save cannot be guarded.
407
-
thrownewError("Cannot guard the write: the owning task is no longer available")
408
-
}
409
422
try{
423
+
if(!saveTask){
424
+
// Fail closed: without the owning task the observation registry is
425
+
// unreachable and the save cannot be guarded. The rejection flows
426
+
// through the same discard-only cleanup as a guard verdict, so a
427
+
// dead task cannot leave the empty placeholder behind either.
428
+
thrownewError("Cannot guard the write: the owning task is no longer available")
429
+
}
410
430
// Stryker disable next-line StringLiteral: "" is semantically identical to "update" in guardedWrite (only "edit" and "create" take distinct branches), so the StringLiteral mutant is equivalent at this sole production call site.
0 commit comments