{"draft":null,"from":293,"to":318,"files":[{"path":"client/src/ci.ts","added":50,"removed":4,"diff":"--- a/client/src/ci.ts\n+++ b/client/src/ci.ts\n@@ -80,6 +80,43 @@\n \treturn lines;\n }\n \n+/** A stored pipeline run as runRuns lists it: what the CI lines need of it. */\n+interface StoredRun {\n+\treadonly id: number;\n+\treadonly version: number;\n+\treadonly state: string;\n+\treadonly file: string;\n+}\n+\n+/** The stored pipeline runs, newest first, from the server's `pipelines` read; empty for anything else. */\n+export function storedRuns(raw: unknown): StoredRun[] {\n+\tconst runs = (raw as { runs?: unknown } | null)?.runs;\n+\tif (!Array.isArray(runs)) return [];\n+\treturn runs.filter(\n+\t\t(r): r is StoredRun =>\n+\t\t\ttypeof r === \"object\" &&\n+\t\t\tr !== null &&\n+\t\t\tNumber.isInteger((r as StoredRun).id) &&\n+\t\t\tNumber.isInteger((r as StoredRun).version) &&\n+\t\t\ttypeof (r as StoredRun).state === \"string\" &&\n+\t\t\ttypeof (r as StoredRun).file === \"string\",\n+\t);\n+}\n+\n+/** One stored run in a line, with where its jobs are. */\n+export function runLine(run: StoredRun): string {\n+\tconst how = run.state === \"planned\" ? \"was planned, not run,\" : run.state === \"running\" ? \"is running\" : run.state;\n+\treturn `Pipeline run ${run.id} (${run.file}) ${how} on version ${run.version}. abso pipeline runs ${run.id} shows its jobs.`;\n+}\n+\n+/**\n+ * Whether the built-in check (abso.json's setup, build and check) had nothing of its own to run. With stored runs, that is\n+ * about the built-in check, not the project's CI, so it isn't said as the project's (abso 719).\n+ */\n+export function builtInHasNothing(ci: CiStatus): boolean {\n+\treturn ci.red === null && ci.skipped?.reason.startsWith(\"nothing to run\") === true;\n+}\n+\n /** A shared version's mark in abso log; \"not checked\" says nothing, since most versions in a busy hour are covered by a newer one's job. */\n export function ciMarkText(mark: CiMark | undefined): string {\n \tswitch (mark) {\n@@ -143,11 +180,20 @@\n \t\t}\n \t\tif (typed !== undefined) {\n \t\t\tif (!/^\\d+$/.test(typed)) throw new UsageError(`a version is a number (got ${JSON.stringify(typed)})`);\n-\t\t\tconst job = await api.ci(Number(typed));\n-\t\t\treturn { text: jobText(job).join(\"\\n\"), json: { ...job } };\n+\t\t\tconst [job, raw] = await Promise.all([api.ci(Number(typed)), api.pipelineRuns().catch(() => null)]);\n+\t\t\tconst run = storedRuns(raw).find((r) => r.version === job.version);\n+\t\t\t// A version the built-in check never ran, with a pipeline run of its own: the run is its CI (abso 719).\n+\t\t\tconst text = run !== undefined && job.result === \"none\" ? [runLine(run)] : jobText(job);\n+\t\t\treturn { text: text.join(\"\\n\"), json: { ...job } };\n \t\t}\n-\t\tconst [ci, status] = await Promise.all([api.ci(), api.status()]);\n-\t\tconst lines = ciText(ci, status.version);\n+\t\tconst [ci, status, raw] = await Promise.all([api.ci(), api.status(), api.pipelineRuns().catch(() => null)]);\n+\t\tconst newest = storedRuns(raw)[0];\n+\t\tconst lines =\n+\t\t\tnewest === undefined\n+\t\t\t\t? ciText(ci, status.version)\n+\t\t\t\t: builtInHasNothing(ci)\n+\t\t\t\t\t? [runLine(newest)]\n+\t\t\t\t\t: [...ciText(ci, status.version), runLine(newest)];\n \t\treturn {\n \t\t\ttext: [\n \t\t\t\t`shared is at version ${status.version}.`,"},{"path":"client/src/issues.ts","added":6,"removed":0,"diff":"--- a/client/src/issues.ts\n+++ b/client/src/issues.ts\n@@ -28,6 +28,7 @@\n import { ignoredHere } from \"./fetch.ts\";\n import { loadIgnore, relativeTo } from \"./folder.ts\";\n import type { AskReply } from \"./issues-wire.ts\";\n+import { isLocal, LOCAL_BASE } from \"./local-store.ts\";\n import { queuedLines, standing } from \"./queue.ts\";\n import { seenText, shortWhen } from \"./times.ts\";\n \n@@ -36,6 +37,11 @@\n /** The folder, with its Api pointed at the Issues Worker: the token goes only where tokenGoesTo allows, as for the avcs server. */\n export function openIssues(env: Env): { root: string; config: Config; api: Api } {\n \tconst { root, config, api } = open(env);\n+\t// A local project's issues are in its store, where the open server keeps them: at /issues.\n+\tif (isLocal(config.server)) {\n+\t\tapi.issuesServer = `${LOCAL_BASE}/issues`;\n+\t\treturn { root, config, api };\n+\t}\n \t// An explicit --server goes to that server's own Issues Worker: ABSO_ISSUES_SERVER doesn't redirect it.\n \tconst server =\n \t\t(env.server === undefined ? fromEnv(env.env, \"ISSUES_SERVER\") : undefined) ||"},{"path":"client/src/join-commands.ts","added":5,"removed":0,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -154,6 +154,11 @@\n \tif (findRoot(root) === root) throw new UsageError(`${root} already has .abso/config.json`);\n \tconst project = str(args, \"project\");\n \tif (!project) throw new UsageError(\"give the project a name with --project <name>\");\n+\t// Checked before any call: a name like \"..\" would otherwise go out as part of the request's path.\n+\tif (!NAME.test(project))\n+\t\tthrow new UsageError(\n+\t\t\t`project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`,\n+\t\t);\n \tif (bool(args, \"public\") && bool(args, \"private\")) throw new UsageError(\"--public or --private, not both\");\n \tconst local = localFrom(args, env, \"init\");\n \t// A box signed in here, and no other credential asked for: the project is made as the person who approved the box,"},{"path":"client/src/local-server.d.mts","added":2,"removed":0,"diff":"--- a/client/src/local-server.d.mts\n+++ b/client/src/local-server.d.mts\n@@ -1,3 +1,5 @@\n // The types of local-server.mjs: as much of the open server as the client calls.\n export declare function handle(request: Request, env: unknown, ctx: unknown, issues: unknown): Promise<Response>;\n export declare const ProjectObject: new (ctx: unknown, env: unknown) => object;\n+export declare const IssueProject: new (ctx: unknown, env: unknown) => object;\n+export declare function issuesFetch(request: Request, env: unknown, ctx: unknown, route: unknown): Promise<Response>;"},{"path":"client/src/local-server.mjs","added":3,"removed":2,"diff":"--- a/client/src/local-server.mjs\n+++ b/client/src/local-server.mjs\n@@ -1,6 +1,7 @@\n-// The open server's router and project object, for local projects (local-store.ts). Plain JS, with its types in\n-// local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types\n+// The open server's router, project object and issues, for local projects (local-store.ts). Plain JS, with its types\n+// in local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types\n // (server/tsconfig.json). The build and Node follow these imports as usual.\n \n+export { IssueProject, issuesFetch } from \"../../server/src/issues-entry.ts\";\n export { ProjectObject } from \"../../server/src/project-object.ts\";\n export { handle } from \"../../server/src/router.ts\";"},{"path":"client/src/local-store.ts","added":56,"removed":11,"diff":"--- a/client/src/local-store.ts\n+++ b/client/src/local-store.ts\n@@ -159,7 +159,8 @@\n \n /** Workers' crypto.DigestStream, which the blob store hashes uploads with. */\n async function installDigestStream(): Promise<void> {\n-\tconst c = globalThis.crypto as unknown as { DigestStream?: unknown };\n+\t// Through a cast: abso's worker compiles this file too (tool.lock.json), and its types have no globalThis.crypto.\n+\tconst c = (globalThis as unknown as { crypto: { DigestStream?: unknown } }).crypto;\n \tif (c.DigestStream) return;\n \tconst { createHash } = await import(\"node:crypto\");\n \tclass DigestStream extends WritableStream<Uint8Array> {\n@@ -189,6 +190,8 @@\n \tDatabaseSync: new (path: string) => Db;\n \thandle: (request: Request, env: unknown, ctx: unknown, issues: unknown) => Promise<Response>;\n \tProjectObject: new (ctx: unknown, env: unknown) => object;\n+\tIssueProject: new (ctx: unknown, env: unknown) => object;\n+\tissuesFetch: (request: Request, env: unknown, ctx: unknown, route: unknown) => Promise<Response>;\n };\n let server: Promise<Server> | undefined;\n \n@@ -240,7 +243,13 @@\n \t\t\t\t`local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`,\n \t\t\t);\n \t\t}\n-\t\treturn { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject };\n+\t\treturn {\n+\t\t\tDatabaseSync: sqlite.DatabaseSync,\n+\t\t\thandle: loaded.handle,\n+\t\t\tProjectObject: loaded.ProjectObject,\n+\t\t\tIssueProject: loaded.IssueProject,\n+\t\t\tissuesFetch: loaded.issuesFetch,\n+\t\t};\n \t})();\n \treturn server;\n }\n@@ -256,6 +265,10 @@\n \tobject: object | undefined;\n \t/** PRAGMA data_version when this process last used the project: it changes when another process writes. */\n \tseen: number | undefined;\n+\t/** The project's issues, asks and news: issues.sqlite beside it, opened when a call first reaches them. */\n+\tissues?: { db: Db; storage: ReturnType<typeof storageOver> };\n+\t/** The issues object for the call under way: made again for each call, as another process may have written. */\n+\tissueObject?: object;\n }\n \n /** Every store file this process has open: closed when its command ends (closeLocalStores). */\n@@ -271,8 +284,10 @@\n \topened.clear();\n }\n \n-const PROJECT_PATH = /^\\/p\\/([^/]+)\\//;\n-const NAME = /^[A-Za-z0-9._-]{1,100}$/;\n+/** A project's calls, and its issues, asks and news, which the open server keeps at /issues/p/<project>/. */\n+const PROJECT_PATH = /^(?:\\/issues)?\\/p\\/([^/]+)\\//;\n+/** A project's name is also its folder in the store, so it never starts with a dot (\".\" and \"..\" would leave it). */\n+const NAME = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,99}$/;\n const json = (status: number, body: unknown) => Response.json(body, { status });\n \n /**\n@@ -312,10 +327,39 @@\n \t\t\t\treturn p.object;\n \t\t\t},\n \t\t},\n-\t\t// Issues, asks and news aren't in local projects yet: a start note's issue hooks find nothing to call.\n-\t\tISSUES_DO: { idFromName: (n: string) => n, get: () => ({}) },\n+\t\tISSUES_DO: {\n+\t\t\tidFromName: (n: string) => n,\n+\t\t\tget: (n: string) => {\n+\t\t\t\tconst p = open.get(n);\n+\t\t\t\tif (!p || n !== name) throw new LocalError(`no local project ${n}`);\n+\t\t\t\tif (p.issues === undefined || !opened.has(p.issues.db)) {\n+\t\t\t\t\tconst db = new opening!.DatabaseSync(join(dir, name, \"issues.sqlite\"));\n+\t\t\t\t\topened.add(db);\n+\t\t\t\t\tdb.exec(\"PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL\");\n+\t\t\t\t\tp.issues = { db, storage: storageOver(db) };\n+\t\t\t\t}\n+\t\t\t\t// Its writes need no lock of their own: every call holds the project file's (see below).\n+\t\t\t\tp.issueObject ??= new opening!.IssueProject(\n+\t\t\t\t\t{ id: { toString: () => n, name: n }, storage: p.issues.storage },\n+\t\t\t\t\tenv(name),\n+\t\t\t\t);\n+\t\t\t\treturn p.issueObject;\n+\t\t\t},\n+\t\t},\n \t});\n-\treturn async (input, init = {}) => {\n+\t// One call at a time, as a Durable Object takes them: a call holds its project's write transaction across awaits,\n+\t// and the connection can't start a second (two calls at once come from Promise.all in ci and waiting --mine).\n+\tlet last: Promise<unknown> = Promise.resolve();\n+\treturn (input, init) => {\n+\t\tconst next = last.then(\n+\t\t\t() => call(input, init),\n+\t\t\t() => call(input, init),\n+\t\t);\n+\t\tlast = next.catch(() => {});\n+\t\treturn next;\n+\t};\n+\n+\tasync function call(input: string, init: RequestInit = {}): Promise<Response> {\n \t\tconst s = await loadServer();\n \t\topening = s;\n \t\tconst url = new URL(input);\n@@ -329,7 +373,10 @@\n \t\theaders.set(\"authorization\", `Bearer ${LOCAL_TOKEN}`);\n \t\tconst request = new Request(url, { ...init, headers });\n \t\tconst waits: Promise<unknown>[] = [];\n+\t\t// Every call, issues ones too, holds the project file's lock, so local writers of the project and of its\n+\t\t// issues take one lock in one order.\n \t\tp.db.exec(\"BEGIN IMMEDIATE\");\n+\t\tp.issueObject = undefined;\n \t\ttry {\n \t\t\tconst version = (p.db.prepare(\"PRAGMA data_version\").get() as { data_version: number }).data_version;\n \t\t\tif (p.seen !== undefined && version !== p.seen) p.object = undefined;\n@@ -337,7 +384,7 @@\n \t\t\t\trequest,\n \t\t\t\tenv(name),\n \t\t\t\t{ waitUntil: (w: Promise<unknown>) => waits.push(w) },\n-\t\t\t\tissuesNone,\n+\t\t\t\ts.issuesFetch,\n \t\t\t);\n \t\t\tawait Promise.allSettled(waits);\n \t\t\t// The answer is read whole before the write is kept, so a body that fails to arrive keeps nothing either.\n@@ -356,7 +403,5 @@\n \t\t\t// Where the Workers runtime answers a throw with a 500, so does this.\n \t\t\treturn json(500, { error: e instanceof Error ? e.message : String(e) });\n \t\t}\n-\t};\n+\t}\n }\n-\n-const issuesNone = async () => json(404, { error: \"issues, asks and news aren't in local projects yet\" });"},{"path":"client/src/main.ts","added":22,"removed":2,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -79,6 +79,7 @@\n import { runAmend, runDrop, runFollow, runLabel, runLabels, runPluck } from \"./versions.ts\";\n import { runVisibility } from \"./visibility-commands.ts\";\n import { checkVisitor } from \"./visitor.ts\";\n+import { handoffText, patFromFile, webLogin } from \"./web-session.ts\";\n \n interface CommandDef {\n \treadonly flags: FlagSpec;\n@@ -212,13 +213,32 @@\n \t\t\tprojects: \"string\",\n \t\t\trole: \"string\",\n \t\t\tdays: \"string\",\n+\t\t\tweb: \"boolean\",\n+\t\t\tsite: \"string\",\n+\t\t\t\"pat-file\": \"string\",\n \t\t},\n \t\tusage:\n-\t\t\t\"abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]\",\n+\t\t\t\"abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file> [--site http://localhost:<port>]]\",\n \t\tabout:\n-\t\t\t\"Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only.\",\n+\t\t\t\"Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box, but only to the projects the box was granted and at most as a writer, until the box is revoked or ends (or, with --pat-file, as the test account whose PAT that file holds, at most as a writer). It writes issues, replies, answers, groups and announcements, and changes no members, roles, visibility, keys, boxes or settings. The box's sign-in, the PAT and the session never appear. It goes only to the staging website beside this folder's staging server; any other server, prod included, is refused and nothing is sent. --site, with --pat-file only, points it at a website on this machine (http://localhost or 127.0.0.1).\",\n \t\trun: async (args, env) => {\n \t\t\tconst server = boxServer(args, env);\n+\t\t\tif (bool(args, \"web\")) {\n+\t\t\t\tconst patFile = str(args, \"pat-file\");\n+\t\t\t\tconst { handoff, site } = await webLogin({\n+\t\t\t\t\tserver,\n+\t\t\t\t\tsite: str(args, \"site\"),\n+\t\t\t\t\tkind: patFile === undefined ? \"box\" : \"pat\",\n+\t\t\t\t\tcredential: () => {\n+\t\t\t\t\t\tif (patFile !== undefined) return patFromFile(patFile);\n+\t\t\t\t\t\tconst record = readBox(server);\n+\t\t\t\t\t\tif (record === undefined || record.expiresAt <= Date.now())\n+\t\t\t\t\t\t\tthrow new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);\n+\t\t\t\t\t\treturn record.credential;\n+\t\t\t\t\t},\n+\t\t\t\t});\n+\t\t\t\treturn { text: handoffText(handoff, site, patFile === undefined), json: { ...handoff } };\n+\t\t\t}\n \t\t\tconst open =\n \t\t\t\tbool(args, \"no-browser\") || browserSkip(env.env, process.platform) !== null\n \t\t\t\t\t? undefined"},{"path":"client/src/news-stream.ts","added":4,"removed":2,"diff":"--- a/client/src/news-stream.ts\n+++ b/client/src/news-stream.ts\n@@ -135,8 +135,10 @@\n \t\t\t} catch (err) {\n \t\t\t\tdeps.note(`(abso news --follow: couldn't read the news: ${(err as Error).message}; showing the frames)`);\n \t\t\t}\n-\t\t\tif (items.length > 0) for (const line of items) show(line);\n-\t\t\telse for (const line of these) if (!shown.includes(line)) show(line);\n+\t\t\tfor (const line of items) show(line);\n+\t\t\t// A frame the read didn't cover still shows: on a server that counts a frame as heard, its item never comes back\n+\t\t\t// from the read. A catch-up frame names several items, so a frame holding a shown item counts as covered.\n+\t\t\tfor (const frame of these) if (!shown.some((line) => frame.includes(line) || line.includes(frame))) show(frame);\n \t\t} while (again);\n \t\trunning = undefined;\n \t};"},{"path":"client/src/web-session.ts","added":141,"removed":0,"diff":"--- /dev/null\n+++ b/client/src/web-session.ts\n@@ -0,0 +1,141 @@\n+// abso login --web: a staging website session for the person a box is signed in as, opened in an agent's own browser, with\n+// no secret in the agent's hands. The website's /login/handoff takes this box's sign-in (or a test account's PAT, from a file)\n+// and answers a one-use link that works for a minute; opening it signs that browser in. Only the link is printed: never the\n+// box's sign-in, the PAT or the session cookie, which the website sets in the browser itself.\n+\n+import { readFileSync } from \"node:fs\";\n+import { UsageError } from \"./args.ts\";\n+\n+/** The website beside each staging server. Prod has none here: agents never sign in to the website on prod. */\n+const STAGING_SITES: Readonly<Record<string, string>> = {\n+\t\"https://abso-staging.chrisazy.workers.dev\": \"https://abso-website-staging.chrisazy.workers.dev\",\n+\t\"https://avcs-staging.chrisazy.workers.dev\": \"https://abso-website-staging.chrisazy.workers.dev\",\n+};\n+\n+/** What the website answers: the link, when it stops working, and who and until when it signs in. */\n+export interface Handoff {\n+\treadonly url: string;\n+\treadonly expiresAt: string;\n+\treadonly account: string;\n+\treadonly name: string;\n+\treadonly sessionEnds: string;\n+}\n+\n+/**\n+ * The website a handoff's credential goes to (Security condition 6, Code Review): the staging website beside the folder's own\n+ * staging server, from the fixed list above, and never an origin from a flag. A server that isn't on the list is refused,\n+ * prod included. --site is only for a test account's PAT on this machine (http://localhost or 127.0.0.1); a box's sign-in\n+ * takes no --site at all.\n+ */\n+export function siteFor(server: string, site: string | undefined, kind: \"box\" | \"pat\"): string {\n+\tconst origin = new URL(server).origin;\n+\tconst known = STAGING_SITES[origin];\n+\tif (known === undefined)\n+\t\tthrow new UsageError(\n+\t\t\t`abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. Nothing was sent.`,\n+\t\t);\n+\tif (site === undefined) return known;\n+\tif (kind === \"box\")\n+\t\tthrow new UsageError(`--site isn't taken with a box's sign-in, which goes only to ${known}. Nothing was sent.`);\n+\tlet url: URL | null = null;\n+\ttry {\n+\t\turl = new URL(site);\n+\t} catch {\n+\t\t// Not an address: refused below.\n+\t}\n+\tif (url === null || url.protocol !== \"http:\" || (url.hostname !== \"localhost\" && url.hostname !== \"127.0.0.1\"))\n+\t\tthrow new UsageError(\n+\t\t\t\"--site, with --pat-file, names this machine only (http://localhost:<port> or http://127.0.0.1:<port>). Nothing was sent.\",\n+\t\t);\n+\treturn url.origin;\n+}\n+\n+/**\n+ * abso login --web: where the credential would go is settled before it is read, so a refusal reads and sends nothing\n+ * (Security). `credential` reads the box's sign-in or the PAT only once the website is one it may go to.\n+ */\n+export async function webLogin(options: {\n+\treadonly server: string;\n+\treadonly site: string | undefined;\n+\t/** A box's sign-in, or a test account's PAT (--pat-file). */\n+\treadonly kind: \"box\" | \"pat\";\n+\treadonly credential: () => string;\n+\treadonly fetcher?: typeof fetch;\n+}): Promise<{ handoff: Handoff; site: string }> {\n+\tconst site = siteFor(options.server, options.site, options.kind);\n+\treturn { handoff: await webHandoff(site, options.credential(), options.fetcher), site };\n+}\n+\n+/** A PAT from the file --pat-file names: read here, never printed. */\n+export function patFromFile(path: string): string {\n+\tlet text: string;\n+\ttry {\n+\t\ttext = readFileSync(path, \"utf8\").trim();\n+\t} catch {\n+\t\tthrow new UsageError(`--pat-file names ${path}, which abso can't read`);\n+\t}\n+\tif (!/^abso_pat_[A-Za-z0-9_-]{16,200}$/.test(text))\n+\t\tthrow new UsageError(`--pat-file names ${path}, which doesn't hold a PAT`);\n+\treturn text;\n+}\n+\n+/** Words from the website, with any secret this call sent taken out. */\n+function scrubbed(text: string, secret: string): string {\n+\treturn text.split(secret).join(\"[the credential]\").slice(0, 300);\n+}\n+\n+/** Asks the website for a handoff link with `credential` (a box sign-in or a PAT) in Authorization. */\n+export async function webHandoff(site: string, credential: string, fetcher: typeof fetch = fetch): Promise<Handoff> {\n+\tlet res: Response;\n+\ttry {\n+\t\tres = await fetcher(`${site}/login/handoff`, {\n+\t\t\tmethod: \"POST\",\n+\t\t\theaders: { authorization: `Bearer ${credential}`, accept: \"application/json\" },\n+\t\t\tredirect: \"error\",\n+\t\t\tsignal: AbortSignal.timeout(30_000),\n+\t\t});\n+\t} catch (err) {\n+\t\tthrow new UsageError(`couldn't reach ${site}: ${scrubbed((err as Error).message, credential)}`);\n+\t}\n+\tconst text = await res.text().catch(() => \"\");\n+\tlet body: Partial<Handoff> & { error?: unknown } = {};\n+\ttry {\n+\t\tbody = JSON.parse(text) as typeof body;\n+\t} catch {\n+\t\t// Not JSON: the status says enough.\n+\t}\n+\tif (!res.ok) {\n+\t\tconst why = typeof body.error === \"string\" ? body.error : `it answered ${res.status}`;\n+\t\tthrow new UsageError(\n+\t\t\tres.status === 404\n+\t\t\t\t? `${site} doesn't hand out sign-in links (its key sign-in is off, or it isn't staging)`\n+\t\t\t\t: `${site} refused: ${scrubbed(why, credential)}`,\n+\t\t);\n+\t}\n+\tif (\n+\t\ttypeof body.url !== \"string\" ||\n+\t\t!body.url.startsWith(`${site}/login/handoff#`) ||\n+\t\ttypeof body.expiresAt !== \"string\" ||\n+\t\ttypeof body.account !== \"string\"\n+\t)\n+\t\tthrow new UsageError(`${site} answered something that isn't a sign-in link`);\n+\treturn {\n+\t\turl: body.url,\n+\t\texpiresAt: body.expiresAt,\n+\t\taccount: body.account,\n+\t\tname: typeof body.name === \"string\" ? body.name : body.account,\n+\t\tsessionEnds: typeof body.sessionEnds === \"string\" ? body.sessionEnds : body.expiresAt,\n+\t};\n+}\n+\n+/** What abso login --web says: the one link, how long it works, who it signs in as, and what it reaches (Security). */\n+export function handoffText(h: Handoff, site: string, boxed = true, now = Date.now()): string {\n+\tconst seconds = Math.max(0, Math.round((Date.parse(h.expiresAt) - now) / 1000));\n+\tconst reach = boxed\n+\t\t? \"only to the projects this box was granted, at most as a writer, until the box is revoked or ends\"\n+\t\t: \"at most as a writer\";\n+\treturn [\n+\t\t`Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once. It reaches ${reach}:`,\n+\t\th.url,\n+\t].join(\"\\n\");\n+}"},{"path":"client/test/ci-runs.test.ts","added":60,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/ci-runs.test.ts\n@@ -0,0 +1,60 @@\n+// abso ci for a project whose CI is its pipeline file (abso 719): test-byoc on 2026-10-16 had no abso.json, and abso ci\n+// said \"nothing to run\" while its abso.yml's run 8 was going. The stored run is the project's CI there.\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { builtInHasNothing, runLine, storedRuns } from \"../src/ci.ts\";\n+\n+const base = { latest: null, checked: null, running: null, red: null, behind: null } as const;\n+const nothing = {\n+\tversion: 6,\n+\tfrom: 6,\n+\treason: \"nothing to run: no abso.json, and package.json has no test, typecheck or vite\",\n+\tat: \"2026-10-16T16:47:00.000Z\",\n+};\n+\n+test(\"the stored runs are read strictly, newest first as the server lists them\", () => {\n+\tconst runs = storedRuns({\n+\t\tblocked: null,\n+\t\truns: [\n+\t\t\t{ id: 8, version: 6, state: \"running\", file: \"abso.yml\", started: 1 },\n+\t\t\t{ id: \"7\", version: 6, state: \"failed\", file: \"abso.yml\" },\n+\t\t\t{ id: 6, version: 5, state: \"failed\", file: \"abso.yml\" },\n+\t\t],\n+\t});\n+\tassert.deepEqual(\n+\t\truns.map((r) => r.id),\n+\t\t[8, 6],\n+\t);\n+\tassert.deepEqual(storedRuns(null), []);\n+\tassert.deepEqual(storedRuns({ runs: \"no\" }), []);\n+});\n+\n+test(\"a run in a line names its file, its state and where its jobs are\", () => {\n+\tassert.equal(\n+\t\trunLine({ id: 8, version: 6, state: \"running\", file: \"abso.yml\" }),\n+\t\t\"Pipeline run 8 (abso.yml) is running on version 6. abso pipeline runs 8 shows its jobs.\",\n+\t);\n+\tassert.equal(\n+\t\trunLine({ id: 7, version: 6, state: \"failed\", file: \"abso.yml\" }),\n+\t\t\"Pipeline run 7 (abso.yml) failed on version 6. abso pipeline runs 7 shows its jobs.\",\n+\t);\n+\tassert.equal(\n+\t\trunLine({ id: 2, version: 1, state: \"planned\", file: \"abso.yml\" }),\n+\t\t\"Pipeline run 2 (abso.yml) was planned, not run, on version 1. abso pipeline runs 2 shows its jobs.\",\n+\t);\n+});\n+\n+test(\"only the built-in check's own nothing to run is set aside, never a red or another skip\", () => {\n+\tassert.equal(builtInHasNothing({ ...base, skipped: nothing }), true);\n+\tassert.equal(builtInHasNothing({ ...base, skipped: { ...nothing, reason: \"CI is off\" } }), false);\n+\tassert.equal(builtInHasNothing({ ...base }), false);\n+\tassert.equal(\n+\t\tbuiltInHasNothing({\n+\t\t\t...base,\n+\t\t\tred: { version: 6, agent: null, message: null, lastGood: null },\n+\t\t\tskipped: nothing,\n+\t\t}),\n+\t\tfalse,\n+\t);\n+});"},{"path":"client/test/local.test.ts","added":54,"removed":4,"diff":"--- a/client/test/local.test.ts\n+++ b/client/test/local.test.ts\n@@ -4,11 +4,12 @@\n \n import assert from \"node:assert/strict\";\n import { spawnSync } from \"node:child_process\";\n-import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n import { tmpdir } from \"node:os\";\n import { join } from \"node:path\";\n import { after, before, describe, it } from \"node:test\";\n import { fileURLToPath } from \"node:url\";\n+import { closeLocalStores, LOCAL_BASE, localFetch } from \"../src/local-store.ts\";\n import { main } from \"../src/main.ts\";\n import { stateDir } from \"../src/state-dir.ts\";\n \n@@ -41,7 +42,12 @@\n }\n const text = (dir: string, rel: string) => readFileSync(join(dir, rel), \"utf8\");\n \n-describe(\"a local project, with the network off\", () => {\n+/** A copy of the client without the open server beside it (a platform that pins only client/) has no local projects to test. */\n+const noServer = existsSync(fileURLToPath(new URL(\"../../server/src/router.ts\", import.meta.url)))\n+\t? false\n+\t: \"no server/src beside this client, so no local projects\";\n+\n+describe(\"a local project, with the network off\", { skip: noServer }, () => {\n \tlet alice: string;\n \tlet bob: string;\n \tbefore(() => {\n@@ -104,9 +110,53 @@\n \t\tassert.notEqual(held.exit, 0);\n \t\tassert.match(held.out + held.err, /collision/);\n \t});\n+\n+\tit(\"issues, asks and news work too, kept in issues.sqlite beside the project\", async () => {\n+\t\tconst opened = await run(alice, \"issue\", \"new\", \"Fix the parser\", \"--agent\", \"bob\");\n+\t\tassert.equal(opened.exit, 0, opened.out + opened.err);\n+\t\tassert.ok(existsSync(join(store, \"demo\", \"issues.sqlite\")));\n+\t\tconst listed = await run(bob, \"issues\");\n+\t\tassert.equal(listed.exit, 0, listed.err);\n+\t\tassert.match(listed.out, /Fix the parser/);\n+\t\tconst started = await run(bob, \"start\", \"Parser fix\", \"--issue\", \"1\");\n+\t\tassert.equal(started.exit, 0, started.out + started.err);\n+\t\tconst asked = await run(alice, \"ask\", \"bob\", \"Which grammar?\", \"--issue\", \"1\");\n+\t\tassert.equal(asked.exit, 0, asked.out + asked.err);\n+\t\tconst waiting = await run(bob, \"waiting\", \"--mine\");\n+\t\tassert.equal(waiting.exit, 0, waiting.err);\n+\t\tassert.match(waiting.out, /Which grammar\\?/);\n+\t\tconst answered = await run(bob, \"answer\", \"1\", \"The new one\");\n+\t\tassert.equal(answered.exit, 0, answered.out + answered.err);\n+\t\tconst news = await run(alice, \"news\");\n+\t\tassert.equal(news.exit, 0, news.err);\n+\t\tassert.match(news.out, /The new one/);\n+\t\tconst issue = await run(alice, \"issue\", \"1\");\n+\t\tassert.match(issue.out, /In progress|bob/);\n+\t});\n+\n+\tit(\"two calls at once on one project are both answered, one after the other\", async () => {\n+\t\t// As abso ci and waiting --mine make them, with Promise.all.\n+\t\tconst local = localFetch(store);\n+\t\tconst answers = await Promise.all([local(`${LOCAL_BASE}/p/demo/queue`), local(`${LOCAL_BASE}/p/demo/queue`)]);\n+\t\tcloseLocalStores();\n+\t\tfor (const a of answers) assert.equal(a.status, 200, await a.text());\n+\t});\n+\n+\tit(\"a project's name can't start with a dot, so its folder stays inside the store\", async () => {\n+\t\tconst dir = temp(\"dots\");\n+\t\twriteFileSync(join(dir, \"a.txt\"), \"x\\n\");\n+\t\tfor (const name of [\"..\", \".hidden\"]) {\n+\t\t\tconst r = await run(dir, \"init\", \"--local\", \"--project\", name, \"--agent\", \"a\");\n+\t\t\tassert.equal(r.exit, 1, r.out + r.err);\n+\t\t\t// The name rule says why, before any call is made (a \"..\" would collapse the call's path).\n+\t\t\tassert.match(r.err, /project names are letters, digits, dot, dash and underscore/);\n+\t\t}\n+\t\tassert.ok(!existsSync(join(store, \"..\", \"project.sqlite\")));\n+\t\tassert.deepEqual(readdirSync(dir), [\"a.txt\"], \"init left nothing behind\");\n+\t});\n });\n \n-describe(\"where a local project's store is\", () => {\n+describe(\"where a local project's store is\", { skip: noServer }, () => {\n \tit(\"--store inside the folder is kept in its settings and left out of its files\", async () => {\n \t\tstore = temp(\"unused\");\n \t\tconst dir = temp(\"venv\");\n@@ -141,7 +191,7 @@\n \t});\n });\n \n-describe(\"local commands as their own processes\", () => {\n+describe(\"local commands as their own processes\", { skip: noServer }, () => {\n \t// The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is.\n \tconst entry = fileURLToPath(new URL(\"../abso.ts\", import.meta.url));\n \tconst cli = (cwd: string, processStore: string, ...argv: string[]) =>"},{"path":"client/test/news-stream.test.ts","added":12,"removed":0,"diff":"--- a/client/test/news-stream.test.ts\n+++ b/client/test/news-stream.test.ts\n@@ -155,6 +155,18 @@\n \tawait follow(old.deps);\n \tassert.deepEqual(old.lines, [\"fe told you: hello\"]);\n \n+\t// On that server a read can find other news waiting: the frame's own item still shows (Code Review, 291).\n+\tconst mixed = world([{ frames: [\"fe told you: hello\"], close: { code: 1006 } }]);\n+\tmixed.deps.take = async () => [\"cloud: an older item\"];\n+\tawait follow(mixed.deps);\n+\tassert.deepEqual(mixed.lines, [\"cloud: an older item\", \"fe told you: hello\"]);\n+\n+\t// A catch-up frame names the first few waiting items and how many more: the read shows them all, the frame adds nothing.\n+\tconst catchUp = world([{ frames: [\"fe told you: hello\\ncloud: ship it?\\nand 1 more\"], close: { code: 1006 } }]);\n+\tcatchUp.deps.take = async () => [\"fe told you: hello\", \"cloud: ship it?\", \"desk: a third\"];\n+\tawait follow(catchUp.deps);\n+\tassert.deepEqual(catchUp.lines, [\"fe told you: hello\", \"cloud: ship it?\", \"desk: a third\"]);\n+\n \t// A read that fails shows the frames and says why.\n \tconst down = world([{ frames: [\"fe told you: hello\"], close: { code: 1006 } }]);\n \tdown.deps.take = async () => {"},{"path":"client/test/web-session.test.ts","added":106,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/web-session.test.ts\n@@ -0,0 +1,106 @@\n+// abso login --web: a staging website session handed to a browser as a one-use link, with no secret printed.\n+\n+import assert from \"node:assert/strict\";\n+import { mkdtempSync, writeFileSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join } from \"node:path\";\n+import { test } from \"node:test\";\n+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from \"../src/web-session.ts\";\n+\n+const SITE = \"https://abso-website-staging.chrisazy.workers.dev\";\n+const STAGING = \"https://abso-staging.chrisazy.workers.dev\";\n+const BOX = `abso_bx_${\"C\".repeat(43)}`;\n+const PAT = `abso_pat_${\"A\".repeat(40)}`;\n+const NOW = Date.UTC(2026, 9, 16, 9, 0, 0);\n+\n+test(\"the credential goes only to the staging website beside the folder's staging server (Security condition 6)\", () => {\n+\tassert.equal(siteFor(STAGING, undefined, \"box\"), SITE);\n+\tassert.equal(siteFor(\"https://avcs-staging.chrisazy.workers.dev/\", undefined, \"pat\"), SITE);\n+\t// A server that isn't staging is refused, prod included, whatever is asked.\n+\tassert.throws(\n+\t\t() => siteFor(\"https://api.abso.dev\", undefined, \"box\"),\n+\t\t/for staging.*never sign in to the website on prod/,\n+\t);\n+\tassert.throws(() => siteFor(\"https://api.abso.dev\", \"http://localhost:8871\", \"pat\"), /for staging/);\n+\t// A box's sign-in takes no --site, not even the staging website's own address.\n+\tassert.throws(() => siteFor(STAGING, SITE, \"box\"), /isn't taken with a box's sign-in/);\n+\tassert.throws(() => siteFor(STAGING, \"http://localhost:8871\", \"box\"), /isn't taken with a box's sign-in/);\n+\t// A PAT may name this machine over http, and nothing else.\n+\tassert.equal(siteFor(STAGING, \"http://localhost:8871/x\", \"pat\"), \"http://localhost:8871\");\n+\tassert.equal(siteFor(STAGING, \"http://127.0.0.1:8871\", \"pat\"), \"http://127.0.0.1:8871\");\n+\tfor (const elsewhere of [\"https://anywhere.example\", SITE, \"https://localhost:8871\", \"not a url\"])\n+\t\tassert.throws(() => siteFor(STAGING, elsewhere, \"pat\"), /names this machine only/, elsewhere);\n+});\n+\n+test(\"a refused handoff reads no credential and sends no request\", async () => {\n+\tconst sent: string[] = [];\n+\tconst fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch;\n+\tlet read = 0;\n+\tconst credential = () => (read++, BOX);\n+\tfor (const asked of [\n+\t\t{ server: \"https://api.abso.dev\", site: undefined, kind: \"box\" as const },\n+\t\t{ server: STAGING, site: \"https://anywhere.example\", kind: \"box\" as const },\n+\t\t{ server: STAGING, site: SITE, kind: \"box\" as const },\n+\t\t{ server: \"https://api.abso.dev\", site: \"http://localhost:8871\", kind: \"pat\" as const },\n+\t\t{ server: STAGING, site: \"https://anywhere.example\", kind: \"pat\" as const },\n+\t])\n+\t\tawait assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked));\n+\tassert.deepEqual(sent, []);\n+\tassert.equal(read, 0);\n+\t// Allowed, it goes to the staging website only.\n+\tawait webLogin({ server: STAGING, site: undefined, kind: \"pat\", credential: () => PAT, fetcher }).catch(() => {});\n+\tassert.deepEqual(sent, [`${SITE}/login/handoff`]);\n+});\n+\n+test(\"the credential goes in Authorization only, and the answer is the one link and who it signs in as\", async () => {\n+\tconst seen: { url: string; authorization: string | null; body: unknown }[] = [];\n+\tconst fetcher = (async (url: string, init: RequestInit) => {\n+\t\tseen.push({ url, authorization: new Headers(init.headers).get(\"authorization\"), body: init.body ?? null });\n+\t\treturn Response.json({\n+\t\t\turl: `${SITE}/login/handoff#${\"t\".repeat(50)}`,\n+\t\t\texpiresAt: new Date(NOW + 60_000).toISOString(),\n+\t\t\taccount: \"acct_person1\",\n+\t\t\tname: \"christopher\",\n+\t\t\tsessionEnds: \"2026-10-16T21:00:00.000Z\",\n+\t\t});\n+\t}) as typeof fetch;\n+\tconst h = await webHandoff(SITE, BOX, fetcher);\n+\tassert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);\n+\tconst text = handoffText(h, SITE, true, NOW);\n+\tassert.match(text, /within 60 seconds/);\n+\tassert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/);\n+\tassert.match(text, /only to the projects this box was granted, at most as a writer/);\n+\tassert.match(handoffText(h, SITE, false, NOW), /It reaches at most as a writer:/);\n+\tassert.match(text, /\\/login\\/handoff#t{50}$/);\n+\tassert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/);\n+});\n+\n+test(\"a refusal says why without the credential; an answer that isn't the site's own link is refused\", async () => {\n+\tconst echo = (async () =>\n+\t\tResponse.json({ error: `that key was refused: ${BOX}` }, { status: 401 })) as unknown as typeof fetch;\n+\tawait assert.rejects(webHandoff(SITE, BOX, echo), (err: Error) => {\n+\t\tassert.match(err.message, /refused: that key was refused: \\[the credential\\]/);\n+\t\tassert.doesNotMatch(err.message, /abso_bx_/);\n+\t\treturn true;\n+\t});\n+\tconst off = (async () => Response.json({ error: \"not found\" }, { status: 404 })) as unknown as typeof fetch;\n+\tawait assert.rejects(webHandoff(SITE, BOX, off), /doesn't hand out sign-in links/);\n+\tconst elsewhere = (async () =>\n+\t\tResponse.json({\n+\t\t\turl: \"https://elsewhere.example/login/handoff#x\",\n+\t\t\texpiresAt: new Date(NOW).toISOString(),\n+\t\t\taccount: \"acct_x\",\n+\t\t})) as unknown as typeof fetch;\n+\tawait assert.rejects(webHandoff(SITE, BOX, elsewhere), /isn't a sign-in link/);\n+});\n+\n+test(\"--pat-file reads a PAT from its file, and refuses a file that doesn't hold one\", () => {\n+\tconst dir = mkdtempSync(join(tmpdir(), \"abso-web-\"));\n+\tconst good = join(dir, \"pat\");\n+\twriteFileSync(good, `abso_pat_${\"A\".repeat(40)}\\n`);\n+\tassert.equal(patFromFile(good), `abso_pat_${\"A\".repeat(40)}`);\n+\tconst bad = join(dir, \"not\");\n+\twriteFileSync(bad, \"hello\");\n+\tassert.throws(() => patFromFile(bad), /doesn't hold a PAT/);\n+\tassert.throws(() => patFromFile(join(dir, \"missing\")), /can't read/);\n+});"}],"unmatched":[]}