{"file":"worker/project/test/notes.test.ts","version":318,"total":133,"from":1,"to":133,"lines":[{"n":1,"text":"// Notes on lines (#44, step 2): a note is anchored to line ids, so it stays","atom":"a0","author":"init","version":0},{"n":2,"text":"// on the code it's about while others change the file around it. The lines'","atom":"a0","author":"init","version":0},{"n":3,"text":"// authors, the change's agent and the thread hear it as news. An objection","atom":"a0","author":"init","version":0},{"n":4,"text":"// whose lines are all changed or taken out is \"addressed\", and its writer","atom":"a0","author":"init","version":0},{"n":5,"text":"// hears so; only the writer closes a note.","atom":"a0","author":"init","version":0},{"n":6,"text":"","atom":"a0","author":"init","version":0},{"n":7,"text":"import assert from \"node:assert/strict\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { test } from \"node:test\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { type EditBody, MemoryStore, Project } from \"../project.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"","atom":"a0","author":"init","version":0},{"n":11,"text":"function edit(project: Project, agent: string, body: EditBody, time: number): void {","atom":"a0","author":"init","version":0},{"n":12,"text":"\tconst a = project.edit(agent, body, time);","atom":"a0","author":"init","version":0},{"n":13,"text":"\tif (!a.ok) throw new Error(`edit by ${agent} was out of step`);","atom":"a0","author":"init","version":0},{"n":14,"text":"}","atom":"a0","author":"init","version":0},{"n":15,"text":"","atom":"a0","author":"init","version":0},{"n":16,"text":"const AUTH = \"export function login(user) {\\n  return check(user);\\n}\\n\";","atom":"a0","author":"init","version":0},{"n":17,"text":"","atom":"a0","author":"init","version":0},{"n":18,"text":"function setup() {","atom":"a0","author":"init","version":0},{"n":19,"text":"\tconst store = new MemoryStore();","atom":"a0","author":"init","version":0},{"n":20,"text":"\tconst project = new Project(store, { now: () => 100 });","atom":"a0","author":"init","version":0},{"n":21,"text":"\tproject.init({ \"auth.ts\": \"// auth\\n\", \"notes.md\": \"# notes\\n\" }, 0);","atom":"a0","author":"init","version":0},{"n":22,"text":"\tfor (const a of [\"builder\", \"security\", \"writer\"]) project.sync(a);","atom":"a0","author":"init","version":0},{"n":23,"text":"\tproject.starting(\"builder\", \"Sign-in\", [\"auth.ts\"], 1);","atom":"a0","author":"init","version":0},{"n":24,"text":"\tedit(project, \"builder\", { file: \"auth.ts\", content: `// auth\\n${AUTH}` }, 2);","atom":"a0","author":"init","version":0},{"n":25,"text":"\tproject.publish(\"builder\", \"Add login\", 3);","atom":"a0","author":"init","version":0},{"n":26,"text":"\tfor (const a of [\"security\", \"writer\"]) project.sync(a);","atom":"a0","author":"init","version":0},{"n":27,"text":"\treturn { project, store };","atom":"a0","author":"init","version":0},{"n":28,"text":"}","atom":"a0","author":"init","version":0},{"n":29,"text":"","atom":"a0","author":"init","version":0},{"n":30,"text":"test(\"a note follows its lines as the file changes around them, and reaches the author as news\", () => {","atom":"a0","author":"init","version":0},{"n":31,"text":"\tconst { project, store } = setup();","atom":"a0","author":"init","version":0},{"n":32,"text":"\tconst noteAt = store.entries.findIndex((e) => e.type === \"starting\");","atom":"a0","author":"init","version":0},{"n":33,"text":"\tconst n = project.note(","atom":"a0","author":"init","version":0},{"n":34,"text":"\t\t\"security\",","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\t{ file: \"auth.ts\", from: 3, to: 3, text: \"check doesn't verify the state\", kind: \"objection\" },","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\t4,","atom":"a0","author":"init","version":0},{"n":37,"text":"\t);","atom":"a0","author":"init","version":0},{"n":38,"text":"\tassert.deepEqual(n, { id: 1, change: noteAt, lines: [3, 3] });","atom":"a0","author":"init","version":0},{"n":39,"text":"\tconst news = project.news(\"builder\").news;","atom":"a0","author":"init","version":0},{"n":40,"text":"\tassert.ok(","atom":"a0","author":"init","version":0},{"n":41,"text":"\t\tnews.some((x) =>","atom":"a0","author":"init","version":0},{"n":42,"text":"\t\t\tx.startsWith('security objects on auth.ts line 3 (change \"Sign-in\"): \"check doesn\\'t verify the state\". Fix it'),","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\t),","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\tJSON.stringify(news),","atom":"a0","author":"init","version":0},{"n":45,"text":"\t);","atom":"a0","author":"init","version":0},{"n":46,"text":"\t// writer adds lines above: the note moves down with its line.","atom":"a0","author":"init","version":0},{"n":47,"text":"\tedit(project, \"writer\", { file: \"auth.ts\", old: \"// auth\\n\", new: \"// auth\\n// sign-in, see notes.md\\n\\n\" }, 5);","atom":"a0","author":"init","version":0},{"n":48,"text":"\tproject.publish(\"writer\", \"Header\", 6);","atom":"a0","author":"init","version":0},{"n":49,"text":"\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":50,"text":"\t\tproject.notes({ file: \"auth.ts\" }).notes.map((x) => [x.id, x.lines, x.state]),","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\t[[1, [5, 5], \"open\"]],","atom":"a0","author":"init","version":0},{"n":52,"text":"\t);","atom":"a0","author":"init","version":0},{"n":53,"text":"\t// On the change page.","atom":"a0","author":"init","version":0},{"n":54,"text":"\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\tproject.change(noteAt).notes.map((x) => [x.agent, x.kind, x.text]),","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\t[[\"security\", \"objection\", \"check doesn't verify the state\"]],","atom":"a0","author":"init","version":0},{"n":57,"text":"\t);","atom":"a0","author":"init","version":0},{"n":58,"text":"});","atom":"a0","author":"init","version":0},{"n":59,"text":"","atom":"a0","author":"init","version":0},{"n":60,"text":"test(\"replies make a thread whose writers hear each other; read marks are quiet\", () => {","atom":"a0","author":"init","version":0},{"n":61,"text":"\tconst { project } = setup();","atom":"a0","author":"init","version":0},{"n":62,"text":"\tproject.note(\"security\", { file: \"auth.ts\", from: 2, to: 4, text: \"Why no rate limit?\" }, 4);","atom":"a0","author":"init","version":0},{"n":63,"text":"\tproject.news(\"builder\");","atom":"a0","author":"init","version":0},{"n":64,"text":"\tconst r = project.note(\"builder\", { reply: 1, text: \"The Worker limits it before this.\" }, 5);","atom":"a0","author":"init","version":0},{"n":65,"text":"\tassert.deepEqual(r.lines, [2, 4]);","atom":"a0","author":"init","version":0},{"n":66,"text":"\tassert.ok(project.news(\"security\").news.some((x) => x.startsWith(\"builder replies on auth.ts lines 2-4\")));","atom":"a0","author":"init","version":0},{"n":67,"text":"\tproject.note(\"writer\", { file: \"auth.ts\", from: 2, to: 2, text: \"read\", kind: \"read\" }, 6);","atom":"a0","author":"init","version":0},{"n":68,"text":"\tassert.equal(project.news(\"builder\").news.length, 0, \"a read mark sends no news\");","atom":"a0","author":"init","version":0},{"n":69,"text":"\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\tproject.notes().notes.map((x) => [x.id, x.reply, x.kind]),","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\t[","atom":"a0","author":"init","version":0},{"n":72,"text":"\t\t\t[1, null, \"comment\"],","atom":"a0","author":"init","version":0},{"n":73,"text":"\t\t\t[2, 1, \"comment\"],","atom":"a0","author":"init","version":0},{"n":74,"text":"\t\t\t[3, null, \"read\"],","atom":"a0","author":"init","version":0},{"n":75,"text":"\t\t],","atom":"a0","author":"init","version":0},{"n":76,"text":"\t);","atom":"a0","author":"init","version":0},{"n":77,"text":"});","atom":"a0","author":"init","version":0},{"n":78,"text":"","atom":"a0","author":"init","version":0},{"n":79,"text":"test(\"fixing every line an objection is on marks it addressed and tells its writer; only the writer closes it\", () => {","atom":"a0","author":"init","version":0},{"n":80,"text":"\tconst { project } = setup();","atom":"a0","author":"init","version":0},{"n":81,"text":"\tproject.note(\"security\", { file: \"auth.ts\", from: 3, to: 3, text: \"verify the state\", kind: \"objection\" }, 4);","atom":"a0","author":"init","version":0},{"n":82,"text":"\tedit(","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\tproject,","atom":"a0","author":"init","version":0},{"n":84,"text":"\t\t\"builder\",","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\t{ file: \"auth.ts\", old: \"  return check(user);\\n\", new: \"  return check(user, state);\\n\" },","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\t5,","atom":"a0","author":"init","version":0},{"n":87,"text":"\t);","atom":"a0","author":"init","version":0},{"n":88,"text":"\tproject.publish(\"builder\", \"Check the state\", 6);","atom":"a0","author":"init","version":0},{"n":89,"text":"\tassert.equal(project.notes().notes[0]!.state, \"addressed\");","atom":"a0","author":"init","version":0},{"n":90,"text":"\tassert.ok(","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\tproject","atom":"a0","author":"init","version":0},{"n":92,"text":"\t\t\t.news(\"security\")","atom":"a0","author":"init","version":0},{"n":93,"text":"\t\t\t.news.some((x) => x.startsWith(\"builder's version 2 changed every line your objection 1 on auth.ts was on\")),","atom":"a0","author":"init","version":0},{"n":94,"text":"\t);","atom":"a0","author":"init","version":0},{"n":95,"text":"\tassert.throws(() => project.closeNote(\"builder\", 1, \"resolved\", 7), /only security, who wrote note 1, can close it/);","atom":"a0","author":"init","version":0},{"n":96,"text":"\tassert.equal(project.closeNote(\"security\", 1, \"resolved\", 7).state, \"resolved\");","atom":"a0","author":"init","version":0},{"n":97,"text":"\tassert.ok(project.news(\"builder\").news.some((x) => x.includes(\"security resolved its objection on auth.ts\")));","atom":"a0","author":"init","version":0},{"n":98,"text":"});","atom":"a0","author":"init","version":0},{"n":99,"text":"","atom":"a0","author":"init","version":0},{"n":100,"text":"test(\"a note on someone's unpushed draft sits on their lines and belongs to their change\", () => {","atom":"a895","author":"rename","version":100},{"n":101,"text":"\tconst { project, store } = setup();","atom":"a0","author":"init","version":0},{"n":102,"text":"\tproject.starting(\"builder\", \"Logout\", undefined, 4);","atom":"a0","author":"init","version":0},{"n":103,"text":"\tconst logout = store.entries.length - 1;","atom":"a0","author":"init","version":0},{"n":104,"text":"\tedit(project, \"builder\", { file: \"auth.ts\", old: \"}\\n\", new: \"}\\nexport function logout() {}\\n\" }, 5);","atom":"a0","author":"init","version":0},{"n":105,"text":"\tconst n = project.note(","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t\"security\",","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t{ file: \"auth.ts\", from: 5, to: 5, text: \"clear the session too\", of: \"builder\" },","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\t6,","atom":"a0","author":"init","version":0},{"n":109,"text":"\t);","atom":"a0","author":"init","version":0},{"n":110,"text":"\tassert.deepEqual([n.change, n.lines], [logout, [5, 5]]);","atom":"a0","author":"init","version":0},{"n":111,"text":"\tassert.throws(","atom":"a0","author":"init","version":0},{"n":112,"text":"\t\t() => project.note(\"security\", { file: \"auth.ts\", from: 1, to: 1, text: \"x\", of: \"nobody\" }, 7),","atom":"a0","author":"init","version":0},{"n":113,"text":"\t\t/there is no agent \"nobody\"/,","atom":"a0","author":"init","version":0},{"n":114,"text":"\t);","atom":"a0","author":"init","version":0},{"n":115,"text":"});","atom":"a0","author":"init","version":0},{"n":116,"text":"","atom":"a0","author":"init","version":0},{"n":117,"text":"test(\"notes check their input, and come back the same from the log\", () => {","atom":"a0","author":"init","version":0},{"n":118,"text":"\tconst { project, store } = setup();","atom":"a0","author":"init","version":0},{"n":119,"text":"\tassert.throws(","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\t() => project.note(\"security\", { file: \"auth.ts\", from: 9, to: 9, text: \"x\" }, 4),","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\t/from and to are line numbers in auth.ts, 1 to 4/,","atom":"a0","author":"init","version":0},{"n":122,"text":"\t);","atom":"a0","author":"init","version":0},{"n":123,"text":"\tassert.throws(() => project.note(\"security\", { file: \"auth.ts\", from: 1, text: \"\" }, 4), /a note needs \\{text\\}/);","atom":"a0","author":"init","version":0},{"n":124,"text":"\tassert.throws(","atom":"a0","author":"init","version":0},{"n":125,"text":"\t\t() => project.note(\"security\", { file: \"auth.ts\", from: 1, text: \"x\", kind: \"approve\" }, 4),","atom":"a0","author":"init","version":0},{"n":126,"text":"\t\t/kind is comment, objection or read/,","atom":"a0","author":"init","version":0},{"n":127,"text":"\t);","atom":"a0","author":"init","version":0},{"n":128,"text":"\tassert.throws(() => project.note(\"security\", { reply: 7, text: \"x\" }, 4), /there is no note 7/);","atom":"a0","author":"init","version":0},{"n":129,"text":"\tproject.note(\"security\", { file: \"auth.ts\", from: 2, to: 3, text: \"hm\" }, 4);","atom":"a0","author":"init","version":0},{"n":130,"text":"\tproject.closeNote(\"security\", 1, \"withdrawn\", 5);","atom":"a0","author":"init","version":0},{"n":131,"text":"\tconst again = Project.load(store.entries, new MemoryStore(), { now: () => 100 });","atom":"a0","author":"init","version":0},{"n":132,"text":"\tassert.deepEqual(again.notes(), project.notes());","atom":"a0","author":"init","version":0},{"n":133,"text":"});","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a895","author":"rename","message":"","time":1791659799126,"timeIso":"2026-10-10T19:16:39.126Z","publish":{"draft":null,"version":100,"agent":"rename","message":"abso publish is now abso push, abso sync is now abso pull (abso 427)\n\nCommands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; \"shared\" stays the noun (\"Pushed version N\"). No aliases, no notices. A queued push that was \"pulled\" is now \"turned back\", so pull means one thing.\n\npush -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch.\n\nKept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.","time":1791659833853,"timeIso":"2026-10-10T19:17:13.853Z"}}]}