{"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z","changes":12,"change":4607,"files":["client/src/issues.ts","client/src/local-server.d.mts","client/src/local-server.mjs","client/src/local-store.ts","client/test/local.test.ts"],"draft":null,"diff":[{"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/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":38,"removed":7,"diff":"--- a/client/src/local-store.ts\n+++ b/client/src/local-store.ts\n@@ -189,6 +189,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 +242,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 +264,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,7 +283,8 @@\n \topened.clear();\n }\n \n-const PROJECT_PATH = /^\\/p\\/([^/]+)\\//;\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 const NAME = /^[A-Za-z0-9._-]{1,100}$/;\n const json = (status: number, body: unknown) => Response.json(body, { status });\n \n@@ -312,8 +325,25 @@\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\tconst s = await loadServer();\n@@ -329,7 +359,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 +370,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@@ -358,5 +391,3 @@\n \t\t}\n \t};\n }\n-\n-const issuesNone = async () => json(404, { error: \"issues, asks and news aren't in local projects yet\" });"},{"path":"client/test/local.test.ts","added":23,"removed":0,"diff":"--- a/client/test/local.test.ts\n+++ b/client/test/local.test.ts\n@@ -104,6 +104,29 @@\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 \n describe(\"where a local project's store is\", () => {"}],"ci":null}