@remnic/core 10.0.115 → 10.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.116",
|
|
4
4
|
"description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -3386,7 +3386,7 @@
|
|
|
3386
3386
|
"core"
|
|
3387
3387
|
],
|
|
3388
3388
|
"peerDependencies": {
|
|
3389
|
-
"@remnic/coding-graph": "^10.0.
|
|
3389
|
+
"@remnic/coding-graph": "^10.0.116"
|
|
3390
3390
|
},
|
|
3391
3391
|
"peerDependenciesMeta": {
|
|
3392
3392
|
"@remnic/coding-graph": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdtempSync, readdirSync, existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, rmSync, statSync, truncateSync, utimesSync } from "node:fs";
|
|
2
|
+
import { mkdtempSync, readdirSync, existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, rmSync, statSync, truncateSync, utimesSync, renameSync } from "node:fs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import { hostname } from "node:os";
|
|
@@ -1375,3 +1375,57 @@ test("a listing skips an unreadably long inbox beside a drained body without rea
|
|
|
1375
1375
|
s.cleanup();
|
|
1376
1376
|
}
|
|
1377
1377
|
});
|
|
1378
|
+
|
|
1379
|
+
const PINNED_MTIME_S = 1_700_000_000;
|
|
1380
|
+
|
|
1381
|
+
/** Plain io, except every append leaves the inbox mtime at a known whole second, so a test can
|
|
1382
|
+
* change exactly one of inode, size and mtime afterwards. */
|
|
1383
|
+
function pinnedMtimeIo() {
|
|
1384
|
+
const io = plainIo();
|
|
1385
|
+
return {
|
|
1386
|
+
...io,
|
|
1387
|
+
append: async (filePath: string, content: string) => {
|
|
1388
|
+
await io.append(filePath, content);
|
|
1389
|
+
utimesSync(filePath, PINNED_MTIME_S, PINNED_MTIME_S);
|
|
1390
|
+
},
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/** Hand "a","b" in, change the inbox so "b" is gone and only `changed` differs, hand "a","b","c" in. */
|
|
1395
|
+
async function handInAfterInboxChangedOnlyIn(changed: "inode" | "size" | "mtime"): Promise<string[]> {
|
|
1396
|
+
const s = setup();
|
|
1397
|
+
try {
|
|
1398
|
+
const claims = new BufferDrainClaims(s.stateDir, pinnedMtimeIo());
|
|
1399
|
+
s.seedSession("sess-1", entry([turn("a", at(0))]));
|
|
1400
|
+
await claims.claimFromSessionFile("sess-1", makeLease());
|
|
1401
|
+
await claims.mergeIntoClaim("sess-1", entry([turn("a", at(0)), turn("b", at(1))]));
|
|
1402
|
+
const file = inboxFile(s.stateDir, "sess-1");
|
|
1403
|
+
const before = statSync(file);
|
|
1404
|
+
const text = readFileSync(file, "utf8");
|
|
1405
|
+
// "z" keeps the byte length; "zz" grows it by one.
|
|
1406
|
+
const replaced = text.replace('"content":"b"', changed === "size" ? '"content":"zz"' : '"content":"z"');
|
|
1407
|
+
assert.notEqual(replaced, text, "fixture: b was in the inbox");
|
|
1408
|
+
if (changed === "inode") {
|
|
1409
|
+
writeFileSync(`${file}.new`, replaced);
|
|
1410
|
+
renameSync(`${file}.new`, file);
|
|
1411
|
+
} else {
|
|
1412
|
+
writeFileSync(file, replaced);
|
|
1413
|
+
}
|
|
1414
|
+
utimesSync(file, changed === "mtime" ? PINNED_MTIME_S + 100 : PINNED_MTIME_S, changed === "mtime" ? PINNED_MTIME_S + 100 : PINNED_MTIME_S);
|
|
1415
|
+
const after = statSync(file);
|
|
1416
|
+
assert.equal(after.ino === before.ino, changed !== "inode", "fixture: inode");
|
|
1417
|
+
assert.equal(after.size === before.size, changed !== "size", "fixture: size");
|
|
1418
|
+
assert.equal(after.mtimeMs === before.mtimeMs, changed !== "mtime", "fixture: mtime");
|
|
1419
|
+
await claims.mergeIntoClaim("sess-1", entry([turn("a", at(0)), turn("b", at(1)), turn("c", at(2))]));
|
|
1420
|
+
return (await claims.load("sess-1"))?.entry.turns.map((t) => t.content) ?? [];
|
|
1421
|
+
} finally {
|
|
1422
|
+
s.cleanup();
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
for (const changed of ["inode", "size", "mtime"] as const) {
|
|
1427
|
+
test(`a hand-in sends the whole entry again when only the inbox ${changed} changed`, async () => {
|
|
1428
|
+
const contents = await handInAfterInboxChangedOnlyIn(changed);
|
|
1429
|
+
assert.ok(contents.includes("b") && contents.includes("c"), `b is handed in again, not lost: ${contents.join(",")}`);
|
|
1430
|
+
});
|
|
1431
|
+
}
|