Skip to content

Commit dec06df

Browse files
S4b (Zoo-Code-Org#1375): name the rejection the committed-publish rows were asserting
The three teardown-ownership rows moved to Promise.allSettled when the cancellation they describe started landing after the guarded publish, and allSettled plus a status check is a fine way to watch a promise reject - it is also how a row ends up asserting that something rejected somewhere. Each of the three now binds the reason and asserts both halves of it: the class, and the message that identifies the window the row describes - a cancellation that arrived after the guarded publish had committed. A conflict from a different window satisfies the class alone and would have let these rows pass for the wrong reason. The durability row in guardedWrite.spec gains the other direction of the same state: a full-file publish whose parent-directory fsync failed records a complete observation (complete === true), because staysPartial is true only for an edit authorized by a partial read - which is what the partial row beside it pins. A caveat about durability has to be distinguishable from a half-applied write, and reporting the wrong one of the two would have made the error nicer without making it true. Test-only. DiffViewProvider 168 passed, guardedWrite 73 passed, eslint exit 0 and prettier clean on both files, src/eslint-suppressions.json unchanged.
1 parent 13a943d commit dec06df

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎src/core/tools/__tests__/guardedWrite.spec.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,10 @@ describe("guardedWrite (S4a, epic #1375)", () => {
13621362
// file this very write changed, and recording nothing would withdraw authority the
13631363
// tool earned by writing the content itself.
13641364
expect(task.observationRegistry.get(target)?.version).toBe("v2")
1365+
// The other direction of the same state: this publish replaced a complete file the
1366+
// model had read, so a caveat about durability must not report the write as
1367+
// half-applied - a consumer has to tell 'landed, not durable' from 'half-applied'.
1368+
expect(task.observationRegistry.get(target)?.complete).toBe(true)
13651369
expect(failure.message).toContain("committed, not durable")
13661370
expect(failure.committedVersion).toBe("v2")
13671371
})

‎src/integrations/editor/__tests__/DiffViewProvider.spec.ts‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,7 +3726,13 @@ describe("DiffViewProvider", () => {
37263726
const settled = await Promise.allSettled([save, revert])
37273727
expect(settled[0].status).toBe("fulfilled")
37283728
expect(settled[1].status).toBe("rejected")
3729-
expect((settled[1] as PromiseRejectedResult).reason).toBeInstanceOf(CommittedWriteBufferConflictError)
3729+
const rejection = (settled[1] as PromiseRejectedResult).reason as CommittedWriteBufferConflictError
3730+
expect(rejection).toBeInstanceOf(CommittedWriteBufferConflictError)
3731+
// Not merely that something rejected: this is the window the row describes - a
3732+
// cancellation that arrived after the guarded publish had committed.
3733+
expect(rejection.message).toContain(
3734+
"revertChanges: a cancellation arrived after the guarded publish had committed.",
3735+
)
37303736

37313737
// One pass over the tabs, and the cancellation did not repeat the document revert.
37323738
// Only this provider's tab is touched, by either caller.
@@ -3776,7 +3782,13 @@ describe("DiffViewProvider", () => {
37763782
// swallowed, so this row keeps testing tab and reset counts on its own.
37773783
const settled = await Promise.allSettled([save, revert])
37783784
expect(settled[0].status).toBe("fulfilled")
3779-
expect((settled[1] as PromiseRejectedResult).reason).toBeInstanceOf(CommittedWriteBufferConflictError)
3785+
const rejection = (settled[1] as PromiseRejectedResult).reason as CommittedWriteBufferConflictError
3786+
expect(rejection).toBeInstanceOf(CommittedWriteBufferConflictError)
3787+
// Not merely that something rejected: this is the window the row describes - a
3788+
// cancellation that arrived after the guarded publish had committed.
3789+
expect(rejection.message).toContain(
3790+
"revertChanges: a cancellation arrived after the guarded publish had committed.",
3791+
)
37803792

37813793
// The owning pass restored the preview tabs exactly once, and the waiting caller
37823794
// finalized the session exactly once - the pass that ran the tabs does not reset, so
@@ -3861,7 +3873,13 @@ describe("DiffViewProvider", () => {
38613873
})
38623874
// The caller that asked for the undo is told which of the two it got.
38633875
expect(settled[1].status).toBe("rejected")
3864-
expect((settled[1] as PromiseRejectedResult).reason).toBeInstanceOf(CommittedWriteBufferConflictError)
3876+
const rejection = (settled[1] as PromiseRejectedResult).reason as CommittedWriteBufferConflictError
3877+
expect(rejection).toBeInstanceOf(CommittedWriteBufferConflictError)
3878+
// Not merely that something rejected: this is the window the row describes - a
3879+
// cancellation that arrived after the guarded publish had committed.
3880+
expect(rejection.message).toContain(
3881+
"revertChanges: a cancellation arrived after the guarded publish had committed.",
3882+
)
38653883
})
38663884

38673885
// Row 4507760734 (measured): the guarded path treats the commit as the point of no return,

0 commit comments

Comments
 (0)