{"file":"server/test/engine-project.test.ts","version":318,"total":57,"from":1,"to":57,"lines":[{"n":1,"text":"import assert from \"node:assert/strict\";","atom":"a1468","author":"speed","version":150},{"n":2,"text":"import { describe, it } from \"node:test\";","atom":"a1468","author":"speed","version":150},{"n":3,"text":"import { answer } from \"../../worker/project/http.ts\";","atom":"a1468","author":"speed","version":150},{"n":4,"text":"import { EngineProject, SqliteLog } from \"../src/engine-project.ts\";","atom":"a1468","author":"speed","version":150},{"n":5,"text":"import { memoryStorage } from \"./helpers.ts\";","atom":"a1468","author":"speed","version":150},{"n":6,"text":"","atom":"a1468","author":"speed","version":150},{"n":7,"text":"describe(\"the engine over the object's SQLite log\", () => {","atom":"a1468","author":"speed","version":150},{"n":8,"text":"\tit(\"extracts feed events without retaining a page of canonical payloads\", (t) => {","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":9,"text":"\t\tconst storage = memoryStorage();","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":10,"text":"\t\tt.after(() => storage.db.close());","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":11,"text":"\t\tconst project = EngineProject.open(storage);","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":12,"text":"\t\tanswer(project, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } });","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":13,"text":"\t\tanswer(project, \"sync\", \"alice\", {});","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":14,"text":"\t\tanswer(project, \"record\", \"alice\", { files: { \"a.txt\": \"two\\n\" } });","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":15,"text":"\t\tanswer(project, \"publish\", \"alice\", { message: \"Changed\" });","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":16,"text":"\t\tconst expected = project.feed(0, 500);","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":17,"text":"\t\tconst original = SqliteLog.prototype.since;","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":18,"text":"\t\tlet reads = 0;","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":19,"text":"\t\tt.mock.method(SqliteLog.prototype, \"since\", function (this: SqliteLog, from: number, limit: number) {","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":20,"text":"\t\t\tassert.equal(limit, 1, \"feed must release each canonical payload before reading another\");","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":21,"text":"\t\t\treads++;","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":22,"text":"\t\t\treturn original.call(this, from, limit);","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":23,"text":"\t\t});","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":24,"text":"\t\tassert.deepEqual(project.feed(0, 500), expected);","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":25,"text":"\t\tassert.equal(reads, expected.next);","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":26,"text":"\t\tassert.deepEqual(project.feed(1, 2).events, expected.events.slice(1, 3));","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":27,"text":"\t});","atom":"a1599","author":"codex-capacity-chair","version":158},{"n":28,"text":"\tit(\"serves init, records and pushes through answer(), and holds a collision\", () => {","atom":"a1468","author":"speed","version":150},{"n":29,"text":"\t\tconst storage = memoryStorage();","atom":"a1468","author":"speed","version":150},{"n":30,"text":"\t\tconst p = EngineProject.open(storage);","atom":"a1468","author":"speed","version":150},{"n":31,"text":"\t\tassert.equal(answer(p, \"init\", undefined, { files: { \"a.txt\": \"one\\ntwo\\nthree\\n\" } }).status, 200);","atom":"a1468","author":"speed","version":150},{"n":32,"text":"\t\tfor (const agent of [\"alice\", \"bob\"]) assert.equal(answer(p, \"sync\", agent, {}).status, 200);","atom":"a1468","author":"speed","version":150},{"n":33,"text":"\t\tanswer(p, \"record\", \"alice\", { files: { \"a.txt\": \"one\\nTWO by alice\\nthree\\n\" } });","atom":"a1468","author":"speed","version":150},{"n":34,"text":"\t\tanswer(p, \"record\", \"bob\", { files: { \"a.txt\": \"one\\ntwo by bob\\nthree\\n\" } });","atom":"a1468","author":"speed","version":150},{"n":35,"text":"\t\tconst first = answer(p, \"publish\", \"alice\", { message: \"Alice's two\" });","atom":"a1468","author":"speed","version":150},{"n":36,"text":"\t\tassert.deepEqual(first, { status: 200, body: { ok: true, version: 1, changes: 1 } });","atom":"a1468","author":"speed","version":150},{"n":37,"text":"\t\tconst second = answer(p, \"publish\", \"bob\", { message: \"Bob's two\" }).body as { ok: boolean; collisions: unknown[] };","atom":"a1468","author":"speed","version":150},{"n":38,"text":"\t\tassert.equal(second.ok, false);","atom":"a1468","author":"speed","version":150},{"n":39,"text":"\t\tassert.equal(second.collisions.length, 1);","atom":"a1468","author":"speed","version":150},{"n":40,"text":"\t});","atom":"a1468","author":"speed","version":150},{"n":41,"text":"","atom":"a1468","author":"speed","version":150},{"n":42,"text":"\tit(\"loads the same project back from the log\", () => {","atom":"a1468","author":"speed","version":150},{"n":43,"text":"\t\tconst storage = memoryStorage();","atom":"a1468","author":"speed","version":150},{"n":44,"text":"\t\tconst p = EngineProject.open(storage);","atom":"a1468","author":"speed","version":150},{"n":45,"text":"\t\tanswer(p, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } });","atom":"a1468","author":"speed","version":150},{"n":46,"text":"\t\tanswer(p, \"sync\", \"alice\", {});","atom":"a1468","author":"speed","version":150},{"n":47,"text":"\t\tanswer(p, \"record\", \"alice\", { files: { \"a.txt\": \"one\\ntwo\\n\" } });","atom":"a1468","author":"speed","version":150},{"n":48,"text":"\t\tanswer(p, \"publish\", \"alice\", { message: \"Add two\" });","atom":"a1468","author":"speed","version":150},{"n":49,"text":"\t\tconst again = EngineProject.open(storage);","atom":"a1468","author":"speed","version":150},{"n":50,"text":"\t\tassert.equal(again.shared().version, 1);","atom":"a1468","author":"speed","version":150},{"n":51,"text":"\t\tassert.equal(again.shared().files[\"a.txt\"], \"one\\ntwo\\n\");","atom":"a1468","author":"speed","version":150},{"n":52,"text":"\t\tconst log = new SqliteLog(storage);","atom":"a1468","author":"speed","version":150},{"n":53,"text":"\t\tassert.equal(log.sharedVersion(), 1);","atom":"a1468","author":"speed","version":150},{"n":54,"text":"\t\tassert.deepEqual(log.lastPublish()?.agent, \"alice\");","atom":"a1468","author":"speed","version":150},{"n":55,"text":"\t\tassert.equal(log.logSize().entries, log.seq());","atom":"a1468","author":"speed","version":150},{"n":56,"text":"\t});","atom":"a1468","author":"speed","version":150},{"n":57,"text":"});","atom":"a1468","author":"speed","version":150}],"atoms":[{"atom":"a1468","author":"speed","message":"","time":1791907183832,"timeIso":"2026-10-13T15:59:43.832Z","publish":{"draft":null,"version":150,"agent":"speed","message":"Open server: the project Worker, Durable Object and Artifacts (issue 17)","time":1791907522179,"timeIso":"2026-10-13T16:05:22.179Z"}},{"atom":"a1599","author":"codex-capacity-chair","message":"","time":1791916379418,"timeIso":"2026-10-13T18:32:59.418Z","publish":{"draft":null,"version":158,"agent":"codex-capacity-chair","message":"Integrate opt-in disk-first project runtime with cold-object transactions","time":1791917879117,"timeIso":"2026-10-13T18:57:59.117Z"}}]}