- MCP
- show on this site's /mcp
- CLI
- abso show 108 --json
- JSON
- /christopher/abso-core/versions/108?format=json
Implement bounded sequential client recording for #606
of shared·codex-prose-authorship-1··Not checked
Version 107 · Files at version 108
5 files, 399 lines added, 32 removed.
--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -231,7 +231,13 @@
234− const text = await res.text();
239+ throw new ApiError(`${method} ${path} response body ended unexpectedly: ${reason}`, res.status);
235241 // 409 is a refusal that says what to do (a drop took out lines your work builds on): print it as it is.
--- a/client/src/commands.ts
+++ b/client/src/commands.ts
@@ -41,6 +41,7 @@
4343import { applyMode, type FullMode, foldModes, onDisk, PLAIN, readKnownModes, writeKnownModes } from "./modes.ts";
4546
@@ -213,38 +214,77 @@
215216 if (sent === 0) return { sent: 0, paths, deleted, changed: [], news: undefined, leftOut, turnedBinary };
216− await uploadBlobs(api, blobs);
217− const answer = await api.record(
218− Object.fromEntries(files),
219− {},
220− modes,
221− Object.fromEntries([...blobs].map(([rel, b]) => [rel, b.sha])),
244+ // Commit known state only after this batch is confirmed; earlier successful batches stay committed on later failure.
249+ for (const rel of new Set([...Object.keys(batch.files), ...Object.keys(batch.blobs)])) knownBlobs.delete(rel);
223− if (!answer.ok) throw new Error(`the server refused the record: ${answer.reason ?? "no reason given"}`);
224− // Forget before writing: after a rename that changes only case, known/a.ts and known/A.ts are one file on Windows and macOS.
225− for (const [rel, text] of files) if (text === null) forgetKnown(root, rel);
226− for (const [rel, text] of files) if (text !== null) writeKnown(root, rel, text);
227− const knownBlobs = readKnownBlobs(root);
228− if (blobs.size > 0 || [...files.keys()].some((rel) => knownBlobs.has(rel))) {
229− for (const rel of files.keys()) knownBlobs.delete(rel);
230− for (const [rel, b] of blobs) {
231− forgetKnown(root, rel);
232− knownBlobs.set(rel, b.sha);
233− }
234− writeKnownBlobs(root, knownBlobs);
235− }
236− const gone = [...files].filter(([, text]) => text === null).map(([rel]) => rel);
237− const knownModes = readKnownModes(root);
238− if (Object.keys(modes).length > 0 || gone.some((rel) => knownModes.has(rel))) {
239− foldModes(knownModes, modes, gone);
240− writeKnownModes(root, knownModes);
241− }
242− // Another spelling of an existing file went in as that file (#49); a new name not in composed form gets a gentle word.
243− heard(root, [
244− ...newsLines(answer.news),
245− ...(answer.spelling ?? []).map(spellingText),
246− ...(answer.uncomposed ?? []).map(uncomposedText),
247− ]);
271+ const changed = answers.flatMap((answer) => (Array.isArray(answer.changed) ? answer.changed : []));
--- /dev/null
+++ b/client/src/record-batches.ts
@@ -0,0 +1,125 @@
3+
11+
19+
21+
27+ super(`Not recorded: ${path} needs a ${bytes}-byte record request by itself, over the ${budget}-byte limit.`);
34+
46+
58+
60+export function batchRecordItems(items: readonly RecordItem[], budget = RECORD_BODY_BUDGET): RecordBatch[] {
72+ if (current.length === 0) throw new RecordItemTooLargeError(item.path, serializedRecordBytes(candidate), budget);
82+
91+
92+/** Retry only an outcome that may have been accepted; an identical record is a no-op once its state landed. */
93+export async function sendRecordBatch(api: RecordApi, batch: RecordBatch): Promise<RecordAnswer> {
101+ (error.status !== undefined && (error.status < 200 || (error.status >= 300 && error.status < 500)))
104+ // The server diffs whole-file state against the agent's current view. Replaying these exact maps is idempotent.
108+
120+ if (!answer.ok) throw new Error(`the server refused the record: ${answer.reason ?? "no reason given"}`);
--- /dev/null
+++ b/client/test/record-batches.test.ts
@@ -0,0 +1,161 @@
14+
15+test("batches use serialized UTF-8 bytes and keep text, mode, blob, and deletion entries atomic", () => {
25+
38+
40+ assert.throws(() => batchRecordItems([{ path: "big.txt", text: "x".repeat(100) }], 20), /Not recorded: big\.txt/);
43+
44+test("an ambiguous lost reply retries the exact batch once, then returns the accepted result", async () => {
67+
68+test("the real Api transport retries an accepted request when reading its response stream fails", async () => {
97+
98+test("the real Api transport does not retry a definite refusal with a broken response stream", async () => {
118+
127+ await assert.rejects(sendRecordBatch(api, { files: { "a.txt": "x" }, modes: {}, blobs: {}, paths: ["a.txt"] }));
130+
131+test("later batch failure stops the sequence and confirms only successful batches", async () => {
--- /dev/null
+++ b/worker/project/test/record-idempotence.test.ts
@@ -0,0 +1,35 @@
4+
7+
8+test("replaying identical recorded text, deletion, blob, and mode changes adds no semantic events", () => {
19+
27+ assert.equal(store.entries.length, afterFirst, "an identical replay appends no semantic events");
30+