From a3e7ac1fc68c6cca3d6d61a784c70cebf23e579d Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 10 Sep 2026 11:13:10 +0300 Subject: [PATCH] test(adoption): revision guard witness for optimistic rollback (#500 AC6) Issue: #500 User-Visible: no --- test/config-adoption.test.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/config-adoption.test.mjs b/test/config-adoption.test.mjs index b871599f..97a3250c 100644 --- a/test/config-adoption.test.mjs +++ b/test/config-adoption.test.mjs @@ -380,6 +380,19 @@ test('AC6: a conflict reload or a newer mutation wins over a rejected candidate assert.equal(same.config.spaces[0].title, 'Newer local edit'); }); +test('AC6: an attempt from an older revision cannot roll back the same content accepted at a newer one (#442 AC2)', () => { + const adoption = adoptedWith(cfg('Server before'), 3); + const attempted = cfg('Draft'); + const attempt = adoption.beginOptimistic(adoption.config, attempted); + adoption.stageLocalConfig(attempted); + // the queued write for the very same body was accepted meanwhile + adoption.acceptConfigWrite(attempted, { rev: 4 }); + assert.equal(contentFingerprint(adoption.config), attempt.attemptedFingerprint, 'content is identical — only the revision differs'); + assert.equal(adoption.rollbackOptimistic(attempt), false, 'the revision guard alone must refuse'); + assert.equal(adoption.config, attempted); + assert.equal(adoption.configRev, 4); +}); + test('AC6: newer in-place content on the attempted root also wins (#442)', () => { const adoption = adoptedWith(cfg('Server before'), 3); const attempted = cfg('Draft');