{"file":"worker/project/queue.ts","version":318,"total":378,"from":1,"to":378,"lines":[{"n":1,"text":"// The merge queue: publishes to shared waiting for their batch's check.","atom":"a0","author":"init","version":0},{"n":2,"text":"// Writes go through QueueHost; today the host is Project.","atom":"a0","author":"init","version":0},{"n":3,"text":"","atom":"a0","author":"init","version":0},{"n":4,"text":"import { type AtomId, buildAtom, type Graph, type ReadView } from \"../../src/engine/index.ts\";","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":5,"text":"import { unionOverlay } from \"../../src/engine/state-source.ts\";","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":6,"text":"import { autoSettledOf } from \"./autosettle.ts\";","atom":"a2345","author":"autosettle","version":211},{"n":7,"text":"import type { Pair } from \"./collisions.ts\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { definedTwice } from \"./definitions.ts\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { heldMessage, keptOf, lostLines } from \"./markers.ts\";","atom":"a1647","author":"speed","version":160},{"n":10,"text":"import { clip } from \"./news.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"import { ProjectError } from \"./project-error.ts\";","atom":"a0","author":"init","version":0},{"n":12,"text":"import { projectFileIn } from \"./project-helpers.ts\";","atom":"a184","author":"engine","version":25},{"n":13,"text":"import type {","atom":"a0","author":"init","version":0},{"n":14,"text":"\tAgentState,","atom":"a0","author":"init","version":0},{"n":15,"text":"\tBlobs,","atom":"a0","author":"init","version":0},{"n":16,"text":"\tCollision,","atom":"a0","author":"init","version":0},{"n":17,"text":"\tEntry,","atom":"a0","author":"init","version":0},{"n":18,"text":"\tModes,","atom":"a0","author":"init","version":0},{"n":19,"text":"\tPublishAnswer,","atom":"a0","author":"init","version":0},{"n":20,"text":"\tPullReason,","atom":"a0","author":"init","version":0},{"n":21,"text":"\tQueuedPublish,","atom":"a0","author":"init","version":0},{"n":22,"text":"\tSettled,","atom":"a0","author":"init","version":0},{"n":23,"text":"} from \"./project-types.ts\";","atom":"a0","author":"init","version":0},{"n":24,"text":"import { last, SHARED, type Space } from \"./spaces.ts\";","atom":"a0","author":"init","version":0},{"n":25,"text":"import { treeHash } from \"./tree.ts\";","atom":"a0","author":"init","version":0},{"n":26,"text":"import { modesOf } from \"./view-changes.ts\";","atom":"a0","author":"init","version":0},{"n":27,"text":"","atom":"a0","author":"init","version":0},{"n":28,"text":"/** What the merge queue needs from a project. */","atom":"a0","author":"init","version":0},{"n":29,"text":"export interface QueueHost {","atom":"a0","author":"init","version":0},{"n":30,"text":"\treadonly graph: Graph;","atom":"a0","author":"init","version":0},{"n":31,"text":"\tcheckerReady(): boolean;","atom":"a0","author":"init","version":0},{"n":32,"text":"\tsharedView(): ReadView;","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":33,"text":"\tsharedOverlay?(atoms: readonly AtomId[]): ReadView;","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":34,"text":"\tsharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView;","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":35,"text":"\tqueued(): readonly QueuedPublish[];","atom":"a0","author":"init","version":0},{"n":36,"text":"\tqueuedId(): number;","atom":"a0","author":"init","version":0},{"n":37,"text":"\tcheckingHas(id: number): boolean;","atom":"a0","author":"init","version":0},{"n":38,"text":"\treplaceChecking(ids: Iterable<number>): void;","atom":"a0","author":"init","version":0},{"n":39,"text":"\tuncheck(id: number): void;","atom":"a0","author":"init","version":0},{"n":40,"text":"\tneedInit(): void;","atom":"a0","author":"init","version":0},{"n":41,"text":"\tshared(): Space;","atom":"a0","author":"init","version":0},{"n":42,"text":"\tsetOf(space: Space): ReadonlySet<AtomId>;","atom":"a0","author":"init","version":0},{"n":43,"text":"\tview(set: ReadonlySet<AtomId>): ReadView;","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":44,"text":"\tagentSet(agent: AgentState): Set<AtomId>;","atom":"a0","author":"init","version":0},{"n":45,"text":"\tagentView(agent: AgentState): ReadView;","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":46,"text":"\tpairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];","atom":"a0","author":"init","version":0},{"n":47,"text":"\tdescribe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision;","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":48,"text":"\ttouchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;","atom":"a1354","author":"codex-capacity-chair","version":143},{"n":49,"text":"\trefuse(","atom":"a0","author":"init","version":0},{"n":50,"text":"\t\tagent: AgentState,","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\tspace: Space,","atom":"a0","author":"init","version":0},{"n":52,"text":"\t\tvia: \"publish\" | \"land\",","atom":"a0","author":"init","version":0},{"n":53,"text":"\t\ttime: number,","atom":"a0","author":"init","version":0},{"n":54,"text":"\t\tcollisions: Collision[],","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\tentries: Entry[],","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\tmessage?: string,","atom":"a1647","author":"speed","version":160},{"n":57,"text":"\t): { ok: false; collisions: Collision[] };","atom":"a0","author":"init","version":0},{"n":58,"text":"\tcurrentChange(agent: AgentState, time: number): number | undefined;","atom":"a0","author":"init","version":0},{"n":59,"text":"\tnextAt(): number;","atom":"a0","author":"init","version":0},{"n":60,"text":"\tapply(entry: Entry): void;","atom":"a0","author":"init","version":0},{"n":61,"text":"\tagentOf(name: string): AgentState;","atom":"a0","author":"init","version":0},{"n":62,"text":"\trequireClosed(tie: { deps: readonly AtomId[] }, union: ReadonlySet<AtomId>): void;","atom":"a0","author":"init","version":0},{"n":63,"text":"\tnewsForOthers(publisher: AgentState, space: Space, version: number, entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":64,"text":"\tsettledNews(agent: AgentState, version: number, settled: readonly Settled[], entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":65,"text":"\taddressedNews(agent: AgentState, version: number, entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":66,"text":"\treviewNews(agent: AgentState, version: number, entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":67,"text":"\tqueueNews(agent: AgentState, items: readonly { key: string; text: string }[], entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":68,"text":"\tflush(entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":69,"text":"}","atom":"a0","author":"init","version":0},{"n":70,"text":"","atom":"a0","author":"init","version":0},{"n":71,"text":"/** Whether shared's project file (abso.json, else avcs.json) turns the merge queue on (`\"queue\": true`). */","atom":"a184","author":"engine","version":25},{"n":72,"text":"export function queueOn(host: QueueHost): boolean {","atom":"a0","author":"init","version":0},{"n":73,"text":"\tif (!host.checkerReady()) return false;","atom":"a0","author":"init","version":0},{"n":74,"text":"\tconst file = projectFileIn(host.sharedView());","atom":"a184","author":"engine","version":25},{"n":75,"text":"\tif (!file) return false;","atom":"a184","author":"engine","version":25},{"n":76,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":77,"text":"\t\treturn (JSON.parse(file.text) as { queue?: unknown }).queue === true;","atom":"a184","author":"engine","version":25},{"n":78,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\treturn false;","atom":"a0","author":"init","version":0},{"n":80,"text":"\t}","atom":"a0","author":"init","version":0},{"n":81,"text":"}","atom":"a0","author":"init","version":0},{"n":82,"text":"","atom":"a0","author":"init","version":0},{"n":83,"text":"/** With the queue on, nothing lands in shared unchecked; land and pluck don't go through the queue yet. */","atom":"a0","author":"init","version":0},{"n":84,"text":"export function notQueuedYet(host: QueueHost, what: string): void {","atom":"a0","author":"init","version":0},{"n":85,"text":"\tif (queueOn(host))","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\tthrow new ProjectError(","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\t\t\"conflict\",","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t\t`${what} doesn't go through the merge queue yet; switch to shared, take the changes into your draft, and push`,","atom":"a876","author":"rename","version":100},{"n":89,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":90,"text":"}","atom":"a0","author":"init","version":0},{"n":91,"text":"","atom":"a0","author":"init","version":0},{"n":92,"text":"/** Atoms of every queued publish, or only other agents' with `except`. */","atom":"a0","author":"init","version":0},{"n":93,"text":"export function queuedAtoms(host: QueueHost, except?: string): Set<AtomId> {","atom":"a0","author":"init","version":0},{"n":94,"text":"\treturn new Set(","atom":"a0","author":"init","version":0},{"n":95,"text":"\t\thost","atom":"a0","author":"init","version":0},{"n":96,"text":"\t\t\t.queued()","atom":"a0","author":"init","version":0},{"n":97,"text":"\t\t\t.filter((q) => q.agent !== except)","atom":"a0","author":"init","version":0},{"n":98,"text":"\t\t\t.flatMap((q) => q.changes),","atom":"a0","author":"init","version":0},{"n":99,"text":"\t);","atom":"a0","author":"init","version":0},{"n":100,"text":"}","atom":"a0","author":"init","version":0},{"n":101,"text":"","atom":"a0","author":"init","version":0},{"n":102,"text":"/**","atom":"a0","author":"init","version":0},{"n":103,"text":" * Queue the agent's publish (#39). It is checked first against shared and","atom":"a0","author":"init","version":0},{"n":104,"text":" * every publish queued ahead of it, as if those had landed: lines both","atom":"a0","author":"init","version":0},{"n":105,"text":" * changed, and names defined twice, are refused now, so the queue only ever","atom":"a0","author":"init","version":0},{"n":106,"text":" * holds publishes that merge cleanly with each other.","atom":"a0","author":"init","version":0},{"n":107,"text":" */","atom":"a0","author":"init","version":0},{"n":108,"text":"export function enqueue(","atom":"a0","author":"init","version":0},{"n":109,"text":"\thost: QueueHost,","atom":"a0","author":"init","version":0},{"n":110,"text":"\tagent: AgentState,","atom":"a0","author":"init","version":0},{"n":111,"text":"\tmessage: string,","atom":"a0","author":"init","version":0},{"n":112,"text":"\ttime: number,","atom":"a0","author":"init","version":0},{"n":113,"text":"\tdraft: readonly AtomId[],","atom":"a0","author":"init","version":0},{"n":114,"text":"\tresolves: readonly AtomId[],","atom":"a0","author":"init","version":0},{"n":115,"text":"\tentries: Entry[],","atom":"a0","author":"init","version":0},{"n":116,"text":"): PublishAnswer {","atom":"a0","author":"init","version":0},{"n":117,"text":"\tconst space = host.shared();","atom":"a0","author":"init","version":0},{"n":118,"text":"\tconst mineQueued = queuedAtoms(host);","atom":"a0","author":"init","version":0},{"n":119,"text":"\tconst changes = draft.filter((id) => !mineQueued.has(id));","atom":"a0","author":"init","version":0},{"n":120,"text":"\tif (changes.length === 0) return { ok: true, version: last(space), changes: 0 };","atom":"a0","author":"init","version":0},{"n":121,"text":"\tconst ahead = queuedAtoms(host, agent.name);","atom":"a0","author":"init","version":0},{"n":122,"text":"\tconst now = host.setOf(space);","atom":"a0","author":"init","version":0},{"n":123,"text":"\tif (ahead.size > 0) {","atom":"a0","author":"init","version":0},{"n":124,"text":"\t\tconst landed = unionOverlay(now, ahead);","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":125,"text":"\t\tconst theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed);","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":126,"text":"\t\tconst yoursView = host.sharedAgentOverlay","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":127,"text":"\t\t\t? host.sharedAgentOverlay(agent, [...ahead])","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":128,"text":"\t\t\t: host.view(unionOverlay(landed, host.agentSet(agent)));","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":129,"text":"\t\tconst queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id));","atom":"a0","author":"init","version":0},{"n":130,"text":"\t\tconst collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => {","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":131,"text":"\t\t\tconst c = host.describe(p, host.agentView(agent), theirsView, agent.space);","atom":"a0","author":"init","version":0},{"n":132,"text":"\t\t\tconst q = queuedBy(p.theirs);","atom":"a0","author":"init","version":0},{"n":133,"text":"\t\t\treturn q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c;","atom":"a0","author":"init","version":0},{"n":134,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\tconst mine = new Set(changes);","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\tfor (const file of [...host.touchedFiles(changes, [yoursView])].sort()) {","atom":"a0","author":"init","version":0},{"n":137,"text":"\t\t\tif (!yoursView.hasFile(file)) continue;","atom":"a0","author":"init","version":0},{"n":138,"text":"\t\t\tfor (const [name, defs] of definedTwice(yoursView, file)) {","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\t\t\tconst yours = defs.find((d) => d.lines.some((l) => mine.has(host.graph.line(l)!.atom)));","atom":"a0","author":"init","version":0},{"n":140,"text":"\t\t\t\tconst theirs = defs.find((d) => d.lines.some((l) => ahead.has(host.graph.line(l)!.atom)));","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\t\t\tif (!yours || !theirs) continue;","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t\t\tconst q = queuedBy(host.graph.line(theirs.lines.find((l) => ahead.has(host.graph.line(l)!.atom))!)!.atom)!;","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\t\t\tcollisions.push({","atom":"a0","author":"init","version":0},{"n":144,"text":"\t\t\t\t\tkind: \"duplicate\",","atom":"a0","author":"init","version":0},{"n":145,"text":"\t\t\t\t\tname,","atom":"a0","author":"init","version":0},{"n":146,"text":"\t\t\t\t\tfile,","atom":"a0","author":"init","version":0},{"n":147,"text":"\t\t\t\t\tyours: { lines: [yours.start + 1, yours.end], text: `${yours.text}\\n` },","atom":"a716","author":"pinch","version":78},{"n":148,"text":"\t\t\t\t\ttheirs: {","atom":"a0","author":"init","version":0},{"n":149,"text":"\t\t\t\t\t\tlines: [theirs.start + 1, theirs.end],","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\t\t\t\t\ttext: `${theirs.text}\\n`,","atom":"a716","author":"pinch","version":78},{"n":151,"text":"\t\t\t\t\t\tagent: q.agent,","atom":"a0","author":"init","version":0},{"n":152,"text":"\t\t\t\t\t\tmessage: q.message,","atom":"a0","author":"init","version":0},{"n":153,"text":"\t\t\t\t\t\tversion: last(space),","atom":"a0","author":"init","version":0},{"n":154,"text":"\t\t\t\t\t\tqueued: q.id,","atom":"a0","author":"init","version":0},{"n":155,"text":"\t\t\t\t\t},","atom":"a0","author":"init","version":0},{"n":156,"text":"\t\t\t\t});","atom":"a0","author":"init","version":0},{"n":157,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":158,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":159,"text":"\t\tif (collisions.length > 0) return host.refuse(agent, space, \"publish\", time, collisions, entries, message);","atom":"a1647","author":"speed","version":160},{"n":160,"text":"\t}","atom":"a0","author":"init","version":0},{"n":161,"text":"\tconst view = host.agentView(agent);","atom":"a0","author":"init","version":0},{"n":162,"text":"\tconst auto = autoSettledOf(message);","atom":"a2345","author":"autosettle","version":211},{"n":163,"text":"\tconst settled: Settled[] = agent.marked","atom":"a0","author":"init","version":0},{"n":164,"text":"\t\t.filter((r) => r.space === SHARED)","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\t.map((r) => {","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\t\tconst lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\t\tconst lost = lostLines(lines, r);","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\t\tconst held = heldMessage(agent, r.file);","atom":"a1647","author":"speed","version":160},{"n":169,"text":"\t\t\tconst by = auto.get(r.file);","atom":"a2345","author":"autosettle","version":211},{"n":170,"text":"\t\t\treturn {","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\t\t\tfile: r.file,","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t\t\tkept: keptOf(lines, r),","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t\t\ttheirs: { agent: r.agent, version: r.version },","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\t\t\t...(lost.length > 0 ? { lost } : {}),","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\t\t\t...(held ? { held } : {}),","atom":"a1647","author":"speed","version":160},{"n":176,"text":"\t\t\t\t...(by ? { auto: by } : {}),","atom":"a2345","author":"autosettle","version":211},{"n":177,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":178,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":179,"text":"\tconst id = host.queuedId() + 1;","atom":"a0","author":"init","version":0},{"n":180,"text":"\tconst entry: Entry = {","atom":"a0","author":"init","version":0},{"n":181,"text":"\t\ttype: \"queued\",","atom":"a0","author":"init","version":0},{"n":182,"text":"\t\tagent: agent.name,","atom":"a0","author":"init","version":0},{"n":183,"text":"\t\tid,","atom":"a0","author":"init","version":0},{"n":184,"text":"\t\tmessage,","atom":"a0","author":"init","version":0},{"n":185,"text":"\t\ttime,","atom":"a0","author":"init","version":0},{"n":186,"text":"\t\tchanges,","atom":"a0","author":"init","version":0},{"n":187,"text":"\t\tresolves: [...resolves],","atom":"a0","author":"init","version":0},{"n":188,"text":"\t\t...(settled.length > 0 ? { settled } : {}),","atom":"a0","author":"init","version":0},{"n":189,"text":"\t\tchange: host.currentChange(agent, time) ?? host.nextAt(),","atom":"a0","author":"init","version":0},{"n":190,"text":"\t};","atom":"a0","author":"init","version":0},{"n":191,"text":"\tentries.push(entry);","atom":"a0","author":"init","version":0},{"n":192,"text":"\thost.apply(entry);","atom":"a0","author":"init","version":0},{"n":193,"text":"\tconst queued = host.queued();","atom":"a0","author":"init","version":0},{"n":194,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":195,"text":"\t\tok: true,","atom":"a0","author":"init","version":0},{"n":196,"text":"\t\tqueued: id,","atom":"a0","author":"init","version":0},{"n":197,"text":"\t\tposition: queued.length,","atom":"a0","author":"init","version":0},{"n":198,"text":"\t\tahead: queued.length - 1,","atom":"a0","author":"init","version":0},{"n":199,"text":"\t\tchanges: changes.length,","atom":"a0","author":"init","version":0},{"n":200,"text":"\t\t...(settled.length > 0 ? { settled } : {}),","atom":"a0","author":"init","version":0},{"n":201,"text":"\t};","atom":"a0","author":"init","version":0},{"n":202,"text":"}","atom":"a0","author":"init","version":0},{"n":203,"text":"","atom":"a0","author":"init","version":0},{"n":204,"text":"/** The merge queue now (#39): waiting publishes in order, and which are in the batch being checked. */","atom":"a0","author":"init","version":0},{"n":205,"text":"export function queue(host: QueueHost): {","atom":"a0","author":"init","version":0},{"n":206,"text":"\titems: { id: number; agent: string; message: string; time: number; changes: number; checking: boolean }[];","atom":"a0","author":"init","version":0},{"n":207,"text":"} {","atom":"a0","author":"init","version":0},{"n":208,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":209,"text":"\t\titems: host.queued().map((q) => ({","atom":"a0","author":"init","version":0},{"n":210,"text":"\t\t\tid: q.id,","atom":"a0","author":"init","version":0},{"n":211,"text":"\t\t\tagent: q.agent,","atom":"a0","author":"init","version":0},{"n":212,"text":"\t\t\tmessage: q.message,","atom":"a0","author":"init","version":0},{"n":213,"text":"\t\t\ttime: q.time,","atom":"a0","author":"init","version":0},{"n":214,"text":"\t\t\tchanges: q.changes.length,","atom":"a0","author":"init","version":0},{"n":215,"text":"\t\t\tchecking: host.checkingHas(q.id),","atom":"a0","author":"init","version":0},{"n":216,"text":"\t\t})),","atom":"a0","author":"init","version":0},{"n":217,"text":"\t};","atom":"a0","author":"init","version":0},{"n":218,"text":"}","atom":"a0","author":"init","version":0},{"n":219,"text":"","atom":"a0","author":"init","version":0},{"n":220,"text":"/** Mark the first `n` queued publishes as the batch being checked (0 ends it). Not logged. */","atom":"a0","author":"init","version":0},{"n":221,"text":"export function queueChecking(host: QueueHost, n: number): number[] {","atom":"a0","author":"init","version":0},{"n":222,"text":"\tconst ids = host","atom":"a0","author":"init","version":0},{"n":223,"text":"\t\t.queued()","atom":"a0","author":"init","version":0},{"n":224,"text":"\t\t.slice(0, Math.max(0, n))","atom":"a0","author":"init","version":0},{"n":225,"text":"\t\t.map((q) => q.id);","atom":"a0","author":"init","version":0},{"n":226,"text":"\thost.replaceChecking(ids);","atom":"a0","author":"init","version":0},{"n":227,"text":"\treturn [...ids];","atom":"a0","author":"init","version":0},{"n":228,"text":"}","atom":"a0","author":"init","version":0},{"n":229,"text":"","atom":"a0","author":"init","version":0},{"n":230,"text":"/** Shared with the first `n` queued publishes on top (#39): the files a batch's check runs on, and their tree hash. */","atom":"a0","author":"init","version":0},{"n":231,"text":"export function queueCandidate(","atom":"a0","author":"init","version":0},{"n":232,"text":"\thost: QueueHost,","atom":"a0","author":"init","version":0},{"n":233,"text":"\tn: number,","atom":"a0","author":"init","version":0},{"n":234,"text":"): {","atom":"a0","author":"init","version":0},{"n":235,"text":"\tids: number[];","atom":"a0","author":"init","version":0},{"n":236,"text":"\tfiles: Record<string, string>;","atom":"a0","author":"init","version":0},{"n":237,"text":"\tmodes: Modes;","atom":"a0","author":"init","version":0},{"n":238,"text":"\tblobs: Blobs;","atom":"a0","author":"init","version":0},{"n":239,"text":"\ttree: string;","atom":"a0","author":"init","version":0},{"n":240,"text":"} {","atom":"a0","author":"init","version":0},{"n":241,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":242,"text":"\tconst items = host.queued().slice(0, Math.max(0, n));","atom":"a0","author":"init","version":0},{"n":243,"text":"\tconst changes = items.flatMap((q) => q.changes);","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":244,"text":"\tconst view =","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":245,"text":"\t\tchanges.length === 0","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":246,"text":"\t\t\t? host.sharedView()","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":247,"text":"\t\t\t: host.sharedOverlay","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":248,"text":"\t\t\t\t? host.sharedOverlay(changes)","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":249,"text":"\t\t\t\t: host.view(unionOverlay(host.setOf(host.shared()), changes));","atom":"a1799","author":"codex-capacity-chair","version":164},{"n":250,"text":"\tconst files = view.files();","atom":"a0","author":"init","version":0},{"n":251,"text":"\tconst modes = modesOf(view);","atom":"a0","author":"init","version":0},{"n":252,"text":"\tconst blobs = view.blobs();","atom":"a0","author":"init","version":0},{"n":253,"text":"\treturn { ids: items.map((q) => q.id), files, modes, blobs, tree: treeHash({ files, modes, blobs }) };","atom":"a0","author":"init","version":0},{"n":254,"text":"}","atom":"a0","author":"init","version":0},{"n":255,"text":"","atom":"a0","author":"init","version":0},{"n":256,"text":"/**","atom":"a0","author":"init","version":0},{"n":257,"text":" * Land the first `n` queued publishes (#39), in order, each as its own","atom":"a0","author":"init","version":0},{"n":258,"text":" * version, after their batch passed. Each tells others what arrived, its","atom":"a0","author":"init","version":0},{"n":259,"text":" * author that it landed, and the authors of what it settled what it kept.","atom":"a0","author":"init","version":0},{"n":260,"text":" */","atom":"a0","author":"init","version":0},{"n":261,"text":"export function queueLand(host: QueueHost, n: number, time: number): { versions: { id: number; version: number }[] } {","atom":"a0","author":"init","version":0},{"n":262,"text":"\tconst entries: Entry[] = [];","atom":"a0","author":"init","version":0},{"n":263,"text":"\tconst out: { id: number; version: number }[] = [];","atom":"a0","author":"init","version":0},{"n":264,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":265,"text":"\t\tfor (const q of host.queued().slice(0, Math.max(0, n))) {","atom":"a0","author":"init","version":0},{"n":266,"text":"\t\t\tconst agent = host.agentOf(q.agent);","atom":"a0","author":"init","version":0},{"n":267,"text":"\t\t\tconst space = host.shared();","atom":"a0","author":"init","version":0},{"n":268,"text":"\t\t\tconst union = unionOverlay(host.setOf(space), q.changes);","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":269,"text":"\t\t\tconst view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union);","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":270,"text":"\t\t\tconst tie = buildAtom(view, {","atom":"a1787","author":"codex-capacity-chair","version":163},{"n":271,"text":"\t\t\t\tauthor: q.agent,","atom":"a0","author":"init","version":0},{"n":272,"text":"\t\t\t\tmessage: q.message,","atom":"a0","author":"init","version":0},{"n":273,"text":"\t\t\t\ttime,","atom":"a0","author":"init","version":0},{"n":274,"text":"\t\t\t\tneeds: [...q.changes],","atom":"a0","author":"init","version":0},{"n":275,"text":"\t\t\t\tresolves: q.resolves.filter((id) => union.has(id)),","atom":"a0","author":"init","version":0},{"n":276,"text":"\t\t\t});","atom":"a0","author":"init","version":0},{"n":277,"text":"\t\t\thost.requireClosed(tie, union);","atom":"a0","author":"init","version":0},{"n":278,"text":"\t\t\tconst version = last(space) + 1;","atom":"a0","author":"init","version":0},{"n":279,"text":"\t\t\tconst entry: Entry = {","atom":"a0","author":"init","version":0},{"n":280,"text":"\t\t\t\ttype: \"publish\",","atom":"a0","author":"init","version":0},{"n":281,"text":"\t\t\t\tagent: q.agent,","atom":"a0","author":"init","version":0},{"n":282,"text":"\t\t\t\tversion,","atom":"a0","author":"init","version":0},{"n":283,"text":"\t\t\t\tmessage: q.message,","atom":"a0","author":"init","version":0},{"n":284,"text":"\t\t\t\ttime,","atom":"a0","author":"init","version":0},{"n":285,"text":"\t\t\t\tchanges: q.changes,","atom":"a0","author":"init","version":0},{"n":286,"text":"\t\t\t\ttie,","atom":"a0","author":"init","version":0},{"n":287,"text":"\t\t\t\t// The agent may have edited since it queued, so its draft isn't reset as an immediate publish's is.","atom":"a0","author":"init","version":0},{"n":288,"text":"\t\t\t\trebase: false,","atom":"a0","author":"init","version":0},{"n":289,"text":"\t\t\t\t...(q.settled ? { settled: q.settled } : {}),","atom":"a0","author":"init","version":0},{"n":290,"text":"\t\t\t\tqueued: q.id,","atom":"a0","author":"init","version":0},{"n":291,"text":"\t\t\t\tchange: q.change ?? host.nextAt(),","atom":"a0","author":"init","version":0},{"n":292,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":293,"text":"\t\t\tentries.push(entry);","atom":"a0","author":"init","version":0},{"n":294,"text":"\t\t\thost.apply(entry);","atom":"a0","author":"init","version":0},{"n":295,"text":"\t\t\thost.uncheck(q.id);","atom":"a0","author":"init","version":0},{"n":296,"text":"\t\t\thost.newsForOthers(agent, space, version, entries);","atom":"a0","author":"init","version":0},{"n":297,"text":"\t\t\thost.settledNews(agent, version, q.settled ?? [], entries);","atom":"a0","author":"init","version":0},{"n":298,"text":"\t\t\thost.addressedNews(agent, version, entries);","atom":"a0","author":"init","version":0},{"n":299,"text":"\t\t\thost.reviewNews(agent, version, entries);","atom":"a0","author":"init","version":0},{"n":300,"text":"\t\t\thost.queueNews(","atom":"a0","author":"init","version":0},{"n":301,"text":"\t\t\t\tagent,","atom":"a0","author":"init","version":0},{"n":302,"text":"\t\t\t\t[{ key: `landed ${q.id}`, text: `Your queued push \"${clip(q.message)}\" landed as version ${version}.` }],","atom":"a876","author":"rename","version":100},{"n":303,"text":"\t\t\t\tentries,","atom":"a0","author":"init","version":0},{"n":304,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":305,"text":"\t\t\tout.push({ id: q.id, version });","atom":"a0","author":"init","version":0},{"n":306,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":307,"text":"\t} finally {","atom":"a0","author":"init","version":0},{"n":308,"text":"\t\thost.flush(entries);","atom":"a0","author":"init","version":0},{"n":309,"text":"\t}","atom":"a0","author":"init","version":0},{"n":310,"text":"\treturn { versions: out };","atom":"a0","author":"init","version":0},{"n":311,"text":"}","atom":"a0","author":"init","version":0},{"n":312,"text":"","atom":"a0","author":"init","version":0},{"n":313,"text":"/**","atom":"a0","author":"init","version":0},{"n":314,"text":" * Take a queued publish out (#39): its check failed, or its author withdrew","atom":"a0","author":"init","version":0},{"n":315,"text":" * it. Its changes are simply still in its author's draft. Later queued","atom":"a0","author":"init","version":0},{"n":316,"text":" * publishes that build on its changes come out with it.","atom":"a0","author":"init","version":0},{"n":317,"text":" */","atom":"a0","author":"init","version":0},{"n":318,"text":"export function queuePull(","atom":"a0","author":"init","version":0},{"n":319,"text":"\thost: QueueHost,","atom":"a0","author":"init","version":0},{"n":320,"text":"\tid: number,","atom":"a0","author":"init","version":0},{"n":321,"text":"\treason: Exclude<PullReason, \"depends\">,","atom":"a0","author":"init","version":0},{"n":322,"text":"\ttime: number,","atom":"a0","author":"init","version":0},{"n":323,"text":"\toutput?: string,","atom":"a0","author":"init","version":0},{"n":324,"text":"): { pulled: number[] } {","atom":"a0","author":"init","version":0},{"n":325,"text":"\tconst entries: Entry[] = [];","atom":"a0","author":"init","version":0},{"n":326,"text":"\tconst pulled: number[] = [];","atom":"a0","author":"init","version":0},{"n":327,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":328,"text":"\t\tconst first = host.queued().find((q) => q.id === id);","atom":"a0","author":"init","version":0},{"n":329,"text":"\t\tif (!first) throw new ProjectError(\"not-found\", `nothing is queued with id ${id}`);","atom":"a0","author":"init","version":0},{"n":330,"text":"\t\tconst gone = new Set<AtomId>();","atom":"a0","author":"init","version":0},{"n":331,"text":"\t\tfor (const q of [...host.queued()]) {","atom":"a0","author":"init","version":0},{"n":332,"text":"\t\t\tconst builds = q.id !== id && q.changes.some((c) => host.graph.atom(c).deps.some((d) => gone.has(d)));","atom":"a0","author":"init","version":0},{"n":333,"text":"\t\t\tif (q.id !== id && !builds) continue;","atom":"a0","author":"init","version":0},{"n":334,"text":"\t\t\tconst why: PullReason = q.id === id ? reason : \"depends\";","atom":"a0","author":"init","version":0},{"n":335,"text":"\t\t\tconst tail = output ? output.split(\"\\n\").slice(-20).join(\"\\n\").slice(-4000) : undefined;","atom":"a0","author":"init","version":0},{"n":336,"text":"\t\t\tconst entry: Entry = { type: \"pulled\", id: q.id, time, reason: why, ...(tail ? { output: tail } : {}) };","atom":"a0","author":"init","version":0},{"n":337,"text":"\t\t\tentries.push(entry);","atom":"a0","author":"init","version":0},{"n":338,"text":"\t\t\thost.apply(entry);","atom":"a0","author":"init","version":0},{"n":339,"text":"\t\t\tfor (const c of q.changes) gone.add(c);","atom":"a0","author":"init","version":0},{"n":340,"text":"\t\t\tpulled.push(q.id);","atom":"a0","author":"init","version":0},{"n":341,"text":"\t\t\tconst said =","atom":"a0","author":"init","version":0},{"n":342,"text":"\t\t\t\twhy === \"failed\"","atom":"a0","author":"init","version":0},{"n":343,"text":"\t\t\t\t\t? `the project's check failed on it on top of version ${last(host.shared())}${tail ? `:\\n${tail}` : \"\"}`","atom":"a0","author":"init","version":0},{"n":344,"text":"\t\t\t\t\t: why === \"withdrawn\"","atom":"a0","author":"init","version":0},{"n":345,"text":"\t\t\t\t\t\t? \"you withdrew it\"","atom":"a0","author":"init","version":0},{"n":346,"text":"\t\t\t\t\t\t: `it builds on queued push ${id}, which was turned back`;","atom":"a876","author":"rename","version":100},{"n":347,"text":"\t\t\thost.queueNews(","atom":"a0","author":"init","version":0},{"n":348,"text":"\t\t\t\thost.agentOf(q.agent),","atom":"a0","author":"init","version":0},{"n":349,"text":"\t\t\t\t[","atom":"a0","author":"init","version":0},{"n":350,"text":"\t\t\t\t\t{","atom":"a0","author":"init","version":0},{"n":351,"text":"\t\t\t\t\t\tkey: `pulled ${q.id}`,","atom":"a0","author":"init","version":0},{"n":352,"text":"\t\t\t\t\t\ttext: `Your queued push \"${clip(q.message)}\" was turned back: ${said}. Its changes are still in your draft.`,","atom":"a876","author":"rename","version":100},{"n":353,"text":"\t\t\t\t\t},","atom":"a0","author":"init","version":0},{"n":354,"text":"\t\t\t\t],","atom":"a0","author":"init","version":0},{"n":355,"text":"\t\t\t\tentries,","atom":"a0","author":"init","version":0},{"n":356,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":357,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":358,"text":"\t} finally {","atom":"a0","author":"init","version":0},{"n":359,"text":"\t\thost.flush(entries);","atom":"a0","author":"init","version":0},{"n":360,"text":"\t}","atom":"a0","author":"init","version":0},{"n":361,"text":"\treturn { pulled };","atom":"a0","author":"init","version":0},{"n":362,"text":"}","atom":"a0","author":"init","version":0},{"n":363,"text":"","atom":"a0","author":"init","version":0},{"n":364,"text":"/** The agent withdraws its queued publishes (#39): refused while one is in the batch being checked. */","atom":"a0","author":"init","version":0},{"n":365,"text":"export function unqueue(host: QueueHost, agentName: string, time: number): { pulled: number[] } {","atom":"a0","author":"init","version":0},{"n":366,"text":"\tconst mine = host.queued().filter((q) => q.agent === agentName);","atom":"a0","author":"init","version":0},{"n":367,"text":"\tif (mine.length === 0) throw new ProjectError(\"not-found\", `${agentName} has nothing queued`);","atom":"a0","author":"init","version":0},{"n":368,"text":"\tconst busy = mine.find((q) => host.checkingHas(q.id));","atom":"a0","author":"init","version":0},{"n":369,"text":"\tif (busy)","atom":"a0","author":"init","version":0},{"n":370,"text":"\t\tthrow new ProjectError(","atom":"a0","author":"init","version":0},{"n":371,"text":"\t\t\t\"conflict\",","atom":"a0","author":"init","version":0},{"n":372,"text":"\t\t\t`queued push ${busy.id} is being checked; it lands or is turned back in about a minute (abso drop takes it back after it lands)`,","atom":"a876","author":"rename","version":100},{"n":373,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":374,"text":"\tconst pulled: number[] = [];","atom":"a0","author":"init","version":0},{"n":375,"text":"\tfor (const q of mine)","atom":"a0","author":"init","version":0},{"n":376,"text":"\t\tif (host.queued().some((x) => x.id === q.id)) pulled.push(...queuePull(host, q.id, \"withdrawn\", time).pulled);","atom":"a0","author":"init","version":0},{"n":377,"text":"\treturn { pulled };","atom":"a0","author":"init","version":0},{"n":378,"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":"a184","author":"engine","message":"","time":1791531853932,"timeIso":"2026-10-09T07:44:13.932Z","publish":{"draft":null,"version":25,"agent":"engine","message":"Read abso.json first, then avcs.json (abso 224, ask 238): one helper (projectFileIn) for the queue, files kept whole, reviewers and init; publish, init and git intake check both files the same way; when shared has both, abso.json counts and status says avcs.json is ignored (status answer projectFile, printed by abso status). .abso/ is kept out of projects like .avcs/. Old projects with only avcs.json work as before.","time":1791531874263,"timeIso":"2026-10-09T07:44:34.263Z"}},{"atom":"a716","author":"pinch","message":"","time":1791611690170,"timeIso":"2026-10-10T05:54:50.170Z","publish":{"draft":null,"version":78,"agent":"pinch","message":"Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.","time":1791612106058,"timeIso":"2026-10-10T06:01:46.058Z"}},{"atom":"a876","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"}},{"atom":"a1354","author":"codex-capacity-chair","message":"","time":1791854964720,"timeIso":"2026-10-13T01:29:24.720Z","publish":{"draft":null,"version":143,"agent":"codex-capacity-chair","message":"Add inactive disk projection provider and verified transactional readers (#16)","time":1791855032023,"timeIso":"2026-10-13T01:30:32.023Z"}},{"atom":"a1647","author":"speed","message":"","time":1791922236994,"timeIso":"2026-10-13T20:10:36.994Z","publish":{"draft":null,"version":160,"agent":"speed","message":"A held push keeps its message, and why tells every settle: the refusal stores the push's message; why on a line kept by abso settle --yours, --theirs or --both names the collision it was kept from, and both kinds of settle list the settler's held push with its reason; the settle's news and the change page carry it too, and a lone push's change now lists the refusals on its way","time":1791922755559,"timeIso":"2026-10-13T20:19:15.559Z"}},{"atom":"a1787","author":"codex-capacity-chair","message":"","time":1791949753900,"timeIso":"2026-10-14T03:49:13.900Z","publish":{"draft":null,"version":163,"agent":"codex-capacity-chair","message":"Integrate reviewed disk-backed operations, queue and bounded read caches","time":1791949753900,"timeIso":"2026-10-14T03:49:13.900Z"}},{"atom":"a1799","author":"codex-capacity-chair","message":"","time":1791952693890,"timeIso":"2026-10-14T04:38:13.890Z","publish":{"draft":null,"version":164,"agent":"codex-capacity-chair","message":"Fix disk-backed historical paths, empty queues and canonical frame integrity","time":1791952865078,"timeIso":"2026-10-14T04:41:05.078Z"}},{"atom":"a2345","author":"autosettle","message":"","time":1792036574145,"timeIso":"2026-10-15T03:56:14.145Z","publish":{"draft":null,"version":211,"agent":"autosettle","message":"Settled automatically, on the record and in the other agent's news (abso-core 23)\n\nThe client's re-push after settling by itself now ends its message with a fixed trailer, one line per file: 'Settled automatically (abso 19):' then '- <file>: kept <side>, confidence 0.81. <reason>' (or 'by a check in code'). autoTrailer writes it and autoSettledOf reads it back, both in worker/project/autosettle.ts. Publish and the merge queue put it on each settle record as settled[].auto {pick, by, confidence, reason}, so the website can mark the version. The other agent's news says 'X settled its collision with your version N in <file> automatically, as abso's model advised (confidence 0.81), pushing version V: ...' and still outlasts a sync.\n\nTests: autosettle.test.ts 9 (trailer round trip, news words), the client's settle/held tests 21, held-push, markers, project, same-line. Typecheck and server typecheck clean. Local open server under act: the trailer is written as above.","time":1792036574787,"timeIso":"2026-10-15T03:56:14.787Z"}}]}