Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 294 --json
JSON
/christopher/abso-core/versions/294?format=json

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.

of shared·pinch··Not checked

Version 293 · Files at version 294

5 files, 72 lines added, 9 removed.

--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -28,6 +28,7 @@
2828import { ignoredHere } from "./fetch.ts";
2929import { loadIgnore, relativeTo } from "./folder.ts";
3030import type { AskReply } from "./issues-wire.ts";
31+import { isLocal, LOCAL_BASE } from "./local-store.ts";
3132import { queuedLines, standing } from "./queue.ts";
3233import { seenText, shortWhen } from "./times.ts";
3334
@@ -36,6 +37,11 @@
3637/** The folder, with its Api pointed at the Issues Worker: the token goes only where tokenGoesTo allows, as for the avcs server. */
3738export function openIssues(env: Env): { root: string; config: Config; api: Api } {
3839 const { root, config, api } = open(env);
40+ // A local project's issues are in its store, where the open server keeps them: at /issues.
41+ if (isLocal(config.server)) {
42+ api.issuesServer = `${LOCAL_BASE}/issues`;
43+ return { root, config, api };
44+ }
3945 // An explicit --server goes to that server's own Issues Worker: ABSO_ISSUES_SERVER doesn't redirect it.
4046 const server =
4147 (env.server === undefined ? fromEnv(env.env, "ISSUES_SERVER") : undefined) ||
--- a/client/src/local-server.d.mts
+++ b/client/src/local-server.d.mts
@@ -1,3 +1,5 @@
11// The types of local-server.mjs: as much of the open server as the client calls.
22export declare function handle(request: Request, env: unknown, ctx: unknown, issues: unknown): Promise<Response>;
33export declare const ProjectObject: new (ctx: unknown, env: unknown) => object;
4+export declare const IssueProject: new (ctx: unknown, env: unknown) => object;
5+export declare function issuesFetch(request: Request, env: unknown, ctx: unknown, route: unknown): Promise<Response>;
--- a/client/src/local-server.mjs
+++ b/client/src/local-server.mjs
@@ -1,6 +1,7 @@
1−// The open server's router and project object, for local projects (local-store.ts). Plain JS, with its types in
2−// local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types
1+// The open server's router, project object and issues, for local projects (local-store.ts). Plain JS, with its types
2+// in local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types
33// (server/tsconfig.json). The build and Node follow these imports as usual.
44
5+export { IssueProject, issuesFetch } from "../../server/src/issues-entry.ts";
56export { ProjectObject } from "../../server/src/project-object.ts";
67export { handle } from "../../server/src/router.ts";
--- a/client/src/local-store.ts
+++ b/client/src/local-store.ts
@@ -189,6 +189,8 @@
189189 DatabaseSync: new (path: string) => Db;
190190 handle: (request: Request, env: unknown, ctx: unknown, issues: unknown) => Promise<Response>;
191191 ProjectObject: new (ctx: unknown, env: unknown) => object;
192+ IssueProject: new (ctx: unknown, env: unknown) => object;
193+ issuesFetch: (request: Request, env: unknown, ctx: unknown, route: unknown) => Promise<Response>;
192194};
193195let server: Promise<Server> | undefined;
194196
@@ -240,7 +242,13 @@
240242 `local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`,
241243 );
242244 }
243− return { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject };
245+ return {
246+ DatabaseSync: sqlite.DatabaseSync,
247+ handle: loaded.handle,
248+ ProjectObject: loaded.ProjectObject,
249+ IssueProject: loaded.IssueProject,
250+ issuesFetch: loaded.issuesFetch,
251+ };
244252 })();
245253 return server;
246254}
@@ -256,6 +264,10 @@
256264 object: object | undefined;
257265 /** PRAGMA data_version when this process last used the project: it changes when another process writes. */
258266 seen: number | undefined;
267+ /** The project's issues, asks and news: issues.sqlite beside it, opened when a call first reaches them. */
268+ issues?: { db: Db; storage: ReturnType<typeof storageOver> };
269+ /** The issues object for the call under way: made again for each call, as another process may have written. */
270+ issueObject?: object;
259271}
260272
261273/** Every store file this process has open: closed when its command ends (closeLocalStores). */
@@ -271,7 +283,8 @@
271283 opened.clear();
272284}
273285
274−const PROJECT_PATH = /^\/p\/([^/]+)\//;
286+/** A project's calls, and its issues, asks and news, which the open server keeps at /issues/p/<project>/. */
287+const PROJECT_PATH = /^(?:\/issues)?\/p\/([^/]+)\//;
275288const NAME = /^[A-Za-z0-9._-]{1,100}$/;
276289const json = (status: number, body: unknown) => Response.json(body, { status });
277290
@@ -312,8 +325,25 @@
312325 return p.object;
313326 },
314327 },
315− // Issues, asks and news aren't in local projects yet: a start note's issue hooks find nothing to call.
316− ISSUES_DO: { idFromName: (n: string) => n, get: () => ({}) },
328+ ISSUES_DO: {
329+ idFromName: (n: string) => n,
330+ get: (n: string) => {
331+ const p = open.get(n);
332+ if (!p || n !== name) throw new LocalError(`no local project ${n}`);
333+ if (p.issues === undefined || !opened.has(p.issues.db)) {
334+ const db = new opening!.DatabaseSync(join(dir, name, "issues.sqlite"));
335+ opened.add(db);
336+ db.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL");
337+ p.issues = { db, storage: storageOver(db) };
338+ }
339+ // Its writes need no lock of their own: every call holds the project file's (see below).
340+ p.issueObject ??= new opening!.IssueProject(
341+ { id: { toString: () => n, name: n }, storage: p.issues.storage },
342+ env(name),
343+ );
344+ return p.issueObject;
345+ },
346+ },
317347 });
318348 return async (input, init = {}) => {
319349 const s = await loadServer();
@@ -329,7 +359,10 @@
329359 headers.set("authorization", `Bearer ${LOCAL_TOKEN}`);
330360 const request = new Request(url, { ...init, headers });
331361 const waits: Promise<unknown>[] = [];
362+ // Every call, issues ones too, holds the project file's lock, so local writers of the project and of its
363+ // issues take one lock in one order.
332364 p.db.exec("BEGIN IMMEDIATE");
365+ p.issueObject = undefined;
333366 try {
334367 const version = (p.db.prepare("PRAGMA data_version").get() as { data_version: number }).data_version;
335368 if (p.seen !== undefined && version !== p.seen) p.object = undefined;
@@ -337,7 +370,7 @@
337370 request,
338371 env(name),
339372 { waitUntil: (w: Promise<unknown>) => waits.push(w) },
340− issuesNone,
373+ s.issuesFetch,
341374 );
342375 await Promise.allSettled(waits);
343376 // The answer is read whole before the write is kept, so a body that fails to arrive keeps nothing either.
@@ -358,5 +391,3 @@
358391 }
359392 };
360393}
361−
362−const issuesNone = async () => json(404, { error: "issues, asks and news aren't in local projects yet" });
--- a/client/test/local.test.ts
+++ b/client/test/local.test.ts
@@ -104,6 +104,29 @@
104104 assert.notEqual(held.exit, 0);
105105 assert.match(held.out + held.err, /collision/);
106106 });
108+ it("issues, asks and news work too, kept in issues.sqlite beside the project", async () => {
109+ const opened = await run(alice, "issue", "new", "Fix the parser", "--agent", "bob");
110+ assert.equal(opened.exit, 0, opened.out + opened.err);
111+ assert.ok(existsSync(join(store, "demo", "issues.sqlite")));
112+ const listed = await run(bob, "issues");
113+ assert.equal(listed.exit, 0, listed.err);
114+ assert.match(listed.out, /Fix the parser/);
115+ const started = await run(bob, "start", "Parser fix", "--issue", "1");
116+ assert.equal(started.exit, 0, started.out + started.err);
117+ const asked = await run(alice, "ask", "bob", "Which grammar?", "--issue", "1");
118+ assert.equal(asked.exit, 0, asked.out + asked.err);
119+ const waiting = await run(bob, "waiting", "--mine");
120+ assert.equal(waiting.exit, 0, waiting.err);
121+ assert.match(waiting.out, /Which grammar\?/);
122+ const answered = await run(bob, "answer", "1", "The new one");
123+ assert.equal(answered.exit, 0, answered.out + answered.err);
124+ const news = await run(alice, "news");
125+ assert.equal(news.exit, 0, news.err);
126+ assert.match(news.out, /The new one/);
127+ const issue = await run(alice, "issue", "1");
128+ assert.match(issue.out, /In progress|bob/);
129+ });
107130});
108131
109132describe("where a local project's store is", () => {