{"file":"client/src/queue.ts","version":2,"draft":"login-timeout","total":179,"from":1,"to":179,"lines":[{"n":1,"text":"// The merge queue on the client (#39): with \"queue\": true in abso.json, a","atom":"a238","author":"review","version":28},{"n":2,"text":"// publish to shared waits in the queue until a batch with it passes the","atom":"a0","author":"init","version":0},{"n":3,"text":"// project's check, and lands, or is pulled with the check's output. publish","atom":"a0","author":"init","version":0},{"n":4,"text":"// waits for that, up to a cap under the chat's 2-minute command limit; status","atom":"a0","author":"init","version":0},{"n":5,"text":"// shows the queue; abso unqueue takes a queued publish back.","atom":"a0","author":"init","version":0},{"n":6,"text":"","atom":"a0","author":"init","version":0},{"n":7,"text":"import { type Api, newsLines, type QueueItem, type QueueState } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { type Parsed, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { type Env, type Output, open, plural } from \"./commands.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import { logNews } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"","atom":"a0","author":"init","version":0},{"n":12,"text":"/** How long publish waits by default: under the 2 minutes a Claude Code shell command gets (#39). */","atom":"a388","author":"infra-split","version":39},{"n":13,"text":"export const WAIT_SECONDS = 100;","atom":"a0","author":"init","version":0},{"n":14,"text":"","atom":"a0","author":"init","version":0},{"n":15,"text":"/** Exit code for a publish still in the queue when the wait ends (#39). */","atom":"a0","author":"init","version":0},{"n":16,"text":"export const STILL_QUEUED = 3;","atom":"a0","author":"init","version":0},{"n":17,"text":"","atom":"a0","author":"init","version":0},{"n":18,"text":"export type QueueOutcome =","atom":"a0","author":"init","version":0},{"n":19,"text":"\t| { readonly kind: \"landed\"; readonly version: number; readonly news: string[] }","atom":"a0","author":"init","version":0},{"n":20,"text":"\t| { readonly kind: \"pulled\"; readonly text: string; readonly news: string[] }","atom":"a0","author":"init","version":0},{"n":21,"text":"\t/** Out of the queue, but neither the last round nor the news says how (another round ran since, or the news was taken). */","atom":"a0","author":"init","version":0},{"n":22,"text":"\t| { readonly kind: \"gone\"; readonly news: string[] }","atom":"a0","author":"init","version":0},{"n":23,"text":"\t| { readonly kind: \"waiting\"; readonly state: QueueState | undefined };","atom":"a0","author":"init","version":0},{"n":24,"text":"","atom":"a0","author":"init","version":0},{"n":25,"text":"/** Where a queued publish stands: being checked, or how many wait ahead of it. */","atom":"a0","author":"init","version":0},{"n":26,"text":"export function standing(items: readonly QueueItem[], id: number): string {","atom":"a0","author":"init","version":0},{"n":27,"text":"\tconst at = items.findIndex((q) => q.id === id);","atom":"a0","author":"init","version":0},{"n":28,"text":"\tif (at < 0) return \"out of the queue\";","atom":"a0","author":"init","version":0},{"n":29,"text":"\tif (items[at]!.checking) {","atom":"a0","author":"init","version":0},{"n":30,"text":"\t\tconst batch = items.filter((q) => q.checking).length;","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\treturn batch === 1 ? \"being checked\" : `being checked in a batch of ${batch}`;","atom":"a0","author":"init","version":0},{"n":32,"text":"\t}","atom":"a0","author":"init","version":0},{"n":33,"text":"\treturn at === 0 ? \"next to be checked\" : `waiting, ${at} ${at === 1 ? \"publish\" : \"publishes\"} ahead of it`;","atom":"a0","author":"init","version":0},{"n":34,"text":"}","atom":"a0","author":"init","version":0},{"n":35,"text":"","atom":"a0","author":"init","version":0},{"n":36,"text":"/**","atom":"a0","author":"init","version":0},{"n":37,"text":" * Wait for queued publish `id` to land or be pulled, polling the queue every","atom":"a0","author":"init","version":0},{"n":38,"text":" * `pollMs` until `waitMs` has passed. A failed poll isn't a failed publish:","atom":"a0","author":"init","version":0},{"n":39,"text":" * it tries again until the time is up. The outcome comes from the last","atom":"a0","author":"init","version":0},{"n":40,"text":" * round, else from the news that says it (which is taken, so it's handed back","atom":"a0","author":"init","version":0},{"n":41,"text":" * to print).","atom":"a0","author":"init","version":0},{"n":42,"text":" */","atom":"a0","author":"init","version":0},{"n":43,"text":"export async function waitForQueued(","atom":"a0","author":"init","version":0},{"n":44,"text":"\tapi: Api,","atom":"a0","author":"init","version":0},{"n":45,"text":"\tid: number,","atom":"a0","author":"init","version":0},{"n":46,"text":"\twaitMs: number,","atom":"a0","author":"init","version":0},{"n":47,"text":"\tsay: (line: string) => void,","atom":"a0","author":"init","version":0},{"n":48,"text":"\tpollMs = 3000,","atom":"a0","author":"init","version":0},{"n":49,"text":"): Promise<QueueOutcome> {","atom":"a0","author":"init","version":0},{"n":50,"text":"\tconst until = Date.now() + waitMs;","atom":"a0","author":"init","version":0},{"n":51,"text":"\tlet state: QueueState | undefined;","atom":"a0","author":"init","version":0},{"n":52,"text":"\tlet said = \"\";","atom":"a0","author":"init","version":0},{"n":53,"text":"\twhile (Date.now() < until) {","atom":"a0","author":"init","version":0},{"n":54,"text":"\t\tawait new Promise((ok) => setTimeout(ok, Math.min(pollMs, Math.max(0, until - Date.now()))));","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\ttry {","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\t\tstate = await api.queueState();","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\t} catch {","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\tif (!state.items.some((q) => q.id === id)) return outcomeOf(api, id, state);","atom":"a0","author":"init","version":0},{"n":61,"text":"\t\tconst now = state.paused","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\t\t? `the queue is paused: ${state.paused.reason}; next try ${state.paused.nextTry.slice(11, 16)} UTC`","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t\t: standing(state.items, id);","atom":"a0","author":"init","version":0},{"n":64,"text":"\t\tif (now !== said) say(`abso: your publish is ${now}.\\n`);","atom":"a84","author":"review","version":16},{"n":65,"text":"\t\tsaid = now;","atom":"a0","author":"init","version":0},{"n":66,"text":"\t}","atom":"a0","author":"init","version":0},{"n":67,"text":"\treturn { kind: \"waiting\", state };","atom":"a0","author":"init","version":0},{"n":68,"text":"}","atom":"a0","author":"init","version":0},{"n":69,"text":"","atom":"a0","author":"init","version":0},{"n":70,"text":"async function outcomeOf(api: Api, id: number, state: QueueState): Promise<QueueOutcome> {","atom":"a0","author":"init","version":0},{"n":71,"text":"\tconst all = await api.news().then(","atom":"a0","author":"init","version":0},{"n":72,"text":"\t\t(a) => newsLines(a.news),","atom":"a0","author":"init","version":0},{"n":73,"text":"\t\t() => [] as string[],","atom":"a0","author":"init","version":0},{"n":74,"text":"\t);","atom":"a0","author":"init","version":0},{"n":75,"text":"\t// The news names the outcome; one publish per agent is the usual case, so the newest such line is ours.","atom":"a0","author":"init","version":0},{"n":76,"text":"\t// publish says the outcome itself, so that line isn't printed again as news.","atom":"a0","author":"init","version":0},{"n":77,"text":"\tconst said = [...all]","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\t.reverse()","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\t.find((n) => /^Your queued publish \".*\" (landed as version \\d+|was pulled: )/s.test(n));","atom":"a0","author":"init","version":0},{"n":80,"text":"\tconst news = all.filter((n) => n !== said);","atom":"a0","author":"init","version":0},{"n":81,"text":"\tconst last = state.last;","atom":"a0","author":"init","version":0},{"n":82,"text":"\tconst landed =","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\tlast && (last.kind === \"landed\" || last.kind === \"pulled\") ? last.versions.find((v) => v.id === id) : undefined;","atom":"a0","author":"init","version":0},{"n":84,"text":"\tif (landed) return { kind: \"landed\", version: landed.version, news };","atom":"a0","author":"init","version":0},{"n":85,"text":"\tconst version = said === undefined ? undefined : /landed as version (\\d+)\\.$/.exec(said)?.[1];","atom":"a0","author":"init","version":0},{"n":86,"text":"\tif (version !== undefined) return { kind: \"landed\", version: Number(version), news };","atom":"a0","author":"init","version":0},{"n":87,"text":"\tif (said !== undefined) return { kind: \"pulled\", text: said, news };","atom":"a0","author":"init","version":0},{"n":88,"text":"\tif (last?.kind === \"pulled\" && last.pulled.includes(id))","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\t\tkind: \"pulled\",","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\t\ttext: `Your queued publish was pulled: the project's check failed on it.${last.output ? `\\n${last.output.trimEnd()}` : \"\"}`,","atom":"a0","author":"init","version":0},{"n":92,"text":"\t\t\tnews,","atom":"a0","author":"init","version":0},{"n":93,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":94,"text":"\treturn { kind: \"gone\", news };","atom":"a0","author":"init","version":0},{"n":95,"text":"}","atom":"a0","author":"init","version":0},{"n":96,"text":"","atom":"a0","author":"init","version":0},{"n":97,"text":"/**","atom":"a0","author":"init","version":0},{"n":98,"text":" * A pull, said for the publisher (#39): the check's output","atom":"a388","author":"infra-split","version":39},{"n":99,"text":" * first, then the verdict as the last line, since that's the line an agent","atom":"a0","author":"init","version":0},{"n":100,"text":" * acts on. The engine's news has the output in the middle of its sentence.","atom":"a0","author":"init","version":0},{"n":101,"text":" */","atom":"a0","author":"init","version":0},{"n":102,"text":"export function pulledText(news: string): string {","atom":"a0","author":"init","version":0},{"n":103,"text":"\tconst m =","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t/^Your queued publish (\".*\") was pulled: ([^\\n]*?)(?::\\n([\\s\\S]*?))?\\.? Its changes are still in your draft\\.$/s.exec(","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\t\tnews.replace(/\\n\\. Its changes/, \". Its changes\"),","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":107,"text":"\tif (!m) return `${news}\\nNot published. Fix it, then publish again.`;","atom":"a0","author":"init","version":0},{"n":108,"text":"\tconst output = m[3]?.trimEnd() ?? \"\";","atom":"a0","author":"init","version":0},{"n":109,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":110,"text":"\t\t...(output === \"\" ? [] : [\"The check's output ends:\", output]),","atom":"a0","author":"init","version":0},{"n":111,"text":"\t\t`Not published: your queued publish ${m[1]} was pulled: ${m[2]!.replace(/\\.$/, \"\")}. Its changes are still in your draft; fix them, then publish again.`,","atom":"a0","author":"init","version":0},{"n":112,"text":"\t].join(\"\\n\");","atom":"a0","author":"init","version":0},{"n":113,"text":"}","atom":"a0","author":"init","version":0},{"n":114,"text":"","atom":"a0","author":"init","version":0},{"n":115,"text":"/** The lines status shows about the queue: who waits, what is being checked, a pause. Nothing while it's empty. */","atom":"a0","author":"init","version":0},{"n":116,"text":"export function queueText(queue: QueueState | null | undefined, me: string): string[] {","atom":"a0","author":"init","version":0},{"n":117,"text":"\tif (!queue) return [];","atom":"a0","author":"init","version":0},{"n":118,"text":"\tconst lines: string[] = [];","atom":"a0","author":"init","version":0},{"n":119,"text":"\tif (queue.items.length > 0) {","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\tconst checking = queue.items.filter((q) => q.checking);","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\tconst waiting = queue.items.filter((q) => !q.checking);","atom":"a0","author":"init","version":0},{"n":122,"text":"\t\tconst who = (q: QueueItem) => `${q.agent === me ? `yours (${q.id})` : q.agent}`;","atom":"a0","author":"init","version":0},{"n":123,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":124,"text":"\t\t\t`Merge queue: ${[","atom":"a0","author":"init","version":0},{"n":125,"text":"\t\t\t\tchecking.length > 0","atom":"a0","author":"init","version":0},{"n":126,"text":"\t\t\t\t\t? `checking ${checking.length === 1 ? who(checking[0]!) : `a batch of ${checking.length} (${checking.map(who).join(\", \")})`}`","atom":"a0","author":"init","version":0},{"n":127,"text":"\t\t\t\t\t: \"\",","atom":"a0","author":"init","version":0},{"n":128,"text":"\t\t\t\twaiting.length > 0 ? `waiting: ${waiting.map(who).join(\", \")}` : \"\",","atom":"a0","author":"init","version":0},{"n":129,"text":"\t\t\t]","atom":"a0","author":"init","version":0},{"n":130,"text":"\t\t\t\t.filter((p) => p !== \"\")","atom":"a0","author":"init","version":0},{"n":131,"text":"\t\t\t\t.join(\"; \")}.`,","atom":"a0","author":"init","version":0},{"n":132,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":133,"text":"\t}","atom":"a0","author":"init","version":0},{"n":134,"text":"\tif (queue.paused)","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\t\t`The merge queue is paused since ${queue.paused.since.slice(11, 16)} UTC: ${queue.paused.reason}; next try ${queue.paused.nextTry.slice(11, 16)} UTC.`,","atom":"a0","author":"init","version":0},{"n":137,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":138,"text":"\treturn lines;","atom":"a0","author":"init","version":0},{"n":139,"text":"}","atom":"a0","author":"init","version":0},{"n":140,"text":"","atom":"a0","author":"init","version":0},{"n":141,"text":"/**","atom":"a307","author":"pinch","version":36},{"n":142,"text":" * What abso waiting --mine says about this agent's own publishes in the merge queue: where each stands, whether","atom":"a307","author":"pinch","version":36},{"n":143,"text":" * the queue is paused, and how the outcome comes. Nothing when none of theirs waits.","atom":"a307","author":"pinch","version":36},{"n":144,"text":" */","atom":"a307","author":"pinch","version":36},{"n":145,"text":"export function queuedLines(queue: QueueState | null | undefined, me: string): string[] {","atom":"a307","author":"pinch","version":36},{"n":146,"text":"\tconst items = queue?.items ?? [];","atom":"a307","author":"pinch","version":36},{"n":147,"text":"\tconst mine = items.filter((q) => q.agent === me);","atom":"a307","author":"pinch","version":36},{"n":148,"text":"\tif (mine.length === 0) return [];","atom":"a307","author":"pinch","version":36},{"n":149,"text":"\treturn [","atom":"a307","author":"pinch","version":36},{"n":150,"text":"\t\t...mine.map(","atom":"a307","author":"pinch","version":36},{"n":151,"text":"\t\t\t(q) => `Your publish ${q.id} (${JSON.stringify(q.message)}) is in the merge queue: ${standing(items, q.id)}.`,","atom":"a307","author":"pinch","version":36},{"n":152,"text":"\t\t),","atom":"a307","author":"pinch","version":36},{"n":153,"text":"\t\t...(queue?.paused ? [`The merge queue is paused: ${queue.paused.reason}.`] : []),","atom":"a307","author":"pinch","version":36},{"n":154,"text":"\t\t`${mine.length === 1 ? \"It lands or is pulled\" : \"Each lands or is pulled\"} once the project's check runs on it; the outcome comes as news, and abso unqueue takes ${mine.length === 1 ? \"it\" : \"them\"} back.`,","atom":"a307","author":"pinch","version":36},{"n":155,"text":"\t];","atom":"a307","author":"pinch","version":36},{"n":156,"text":"}","atom":"a307","author":"pinch","version":36},{"n":157,"text":"","atom":"a307","author":"pinch","version":36},{"n":158,"text":"/** abso unqueue: take this agent's queued publishes back; their changes stay in the draft. */","atom":"a0","author":"init","version":0},{"n":159,"text":"export async function runUnqueue(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":160,"text":"\tif (args.positionals.length > 0)","atom":"a0","author":"init","version":0},{"n":161,"text":"\t\tthrow new UsageError(\"unqueue takes no arguments: it takes back every publish of yours still in the merge queue\");","atom":"a0","author":"init","version":0},{"n":162,"text":"\tconst { root, api } = open(env);","atom":"a0","author":"init","version":0},{"n":163,"text":"\tconst answer = await api.unqueue();","atom":"a0","author":"init","version":0},{"n":164,"text":"\t// The engine says it as news too (\"you withdrew it\"); this command's own text says the same, so it isn't printed twice.","atom":"a0","author":"init","version":0},{"n":165,"text":"\tconst news = await api.news().then(","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\t(a) => newsLines(a.news),","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\t() => [] as string[],","atom":"a0","author":"init","version":0},{"n":168,"text":"\t);","atom":"a0","author":"init","version":0},{"n":169,"text":"\tlogNews(root, news);","atom":"a0","author":"init","version":0},{"n":170,"text":"\tconst others = news.filter((n) => !/^Your queued publish \".*\" was pulled: you withdrew it\\./s.test(n));","atom":"a0","author":"init","version":0},{"n":171,"text":"\tconst ids = answer.pulled;","atom":"a0","author":"init","version":0},{"n":172,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\ttext: [","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\t\t`Took back ${ids.length === 1 ? `queued publish ${ids[0]}` : `queued publishes ${ids.join(\", \")}`}: ${ids.length === 1 ? \"its\" : \"their\"} changes are still in your draft, unpublished.`,","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\t\t...others.map((n) => `  ${n}`),","atom":"a0","author":"init","version":0},{"n":176,"text":"\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":177,"text":"\t\tjson: { pulled: ids, news: others },","atom":"a0","author":"init","version":0},{"n":178,"text":"\t};","atom":"a0","author":"init","version":0},{"n":179,"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":"a84","author":"review","message":"","time":1791520995119,"timeIso":"2026-10-09T04:43:15.119Z","publish":{"draft":null,"version":16,"agent":"review","message":"The client says abso, not avcs, in everything a person reads: the hints after an issue view and abso issue new, the help for issue, issues, ask, answer and waiting, the 'abso:' prefix on notices from run, publish --check, the queue and serve, the 'News from abso' header, the MCP server's name and the claude mcp add example, and the view mod's status line. Only printed words changed: file and folder names (avcs.json, .avcs/, ~/.avcs/token), environment variables and wire headers are as they were, and the tests were updated to the new words (704 pass, biome ci clean).","time":1791521002669,"timeIso":"2026-10-09T04:43:22.669Z"}},{"atom":"a238","author":"review","message":"","time":1791539181105,"timeIso":"2026-10-09T09:46:21.105Z","publish":{"draft":null,"version":28,"agent":"review","message":"Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)","time":1791539181568,"timeIso":"2026-10-09T09:46:21.568Z"}},{"atom":"a307","author":"pinch","message":"","time":1791545326429,"timeIso":"2026-10-09T11:28:46.429Z","publish":{"draft":null,"version":36,"agent":"pinch","message":"waiting --mine lists your publishes still in the merge queue: where each stands (being checked, or how many wait ahead of it), whether the queue is paused, and that the outcome comes as news; --json carries them as queued. A server without a queue, or one that can't be read, leaves them out rather than failing the asks.","time":1791545326646,"timeIso":"2026-10-09T11:28:46.646Z"}},{"atom":"a388","author":"infra-split","message":"","time":1791548567277,"timeIso":"2026-10-09T12:22:47.277Z","publish":{"draft":null,"version":39,"agent":"infra-split","message":"More comments and test names give their reason without naming who raised it\n\nThe same cleanup as version 37, for notes it missed because they were wrapped or worded differently: \"(#37, Playtester 1)\" becomes \"(#37)\", \"(#39, agreed with Engine)\" becomes \"(#39)\", and a commit hash after a name goes with the name. Issue numbers stay. No behavior changes.","time":1791548569542,"timeIso":"2026-10-09T12:22:49.542Z"}}]}