fix(memory): unify host paths under real-day current

This commit is contained in:
冰朔 2026-09-04 15:30:08 +08:00
commit 0c21f4e4af
18 changed files with 184 additions and 42 deletions

View file

@ -117,6 +117,21 @@ test("event writes are immutable and an id collision fails closed", (t) => {
assert.throws(() => appendEvent({ ...root, event: { ...original, why: "changed" } }), /EVENT_ID_COLLISION/u);
});
test("an older idempotent event cannot move CURRENT backward", (t) => {
const root = roots(t);
const first = event(1, "2026-09-04T08:00:00+08:00");
const second = event(2, "2026-09-04T09:00:00+08:00");
appendEvent({ ...root, event: first });
appendEvent({ ...root, event: second });
const before = readCurrent(root);
const repeated = appendEvent({ ...root, event: first });
const after = readCurrent(root);
assert.equal(repeated.state, "IDEMPOTENT_OLDER_EVENT_NO_POINTER_MOVEMENT");
assert.equal(after.last_event_id, second.event_id);
assert.equal(after.current_pointer_sha256, before.current_pointer_sha256);
assert.throws(() => appendEvent({ ...root, event: { ...event(3, "2026-09-04T08:30:00+08:00"), event_id: "NEW-OLDER-EVENT" } }), /OUT_OF_ORDER_EVENT_REQUIRES_CURRENT_CORRECTION_EVENT/u);
});
test("store scope and symlink components fail closed", (t) => {
const root = roots(t);
assert.throws(() => appendEvent({ allowedRoot: root.allowedRoot, storeRoot: path.join(root.allowedRoot, "..", "escape"), event: event(1) }), /STORE_OUTSIDE_ALLOWED_ROOT/u);