Skip to content

Commit 822a2fd

Browse files
committed
fix(test): mock returns memory-add envelope so seed doesn't classify as declined
The `re-recording an unchanged binding does not re-seed` test broke after harness-bot round hardened isPostBindSeeded to count `declined` as failure (commit 8b19309). The test's mock returned the workspace-list shape `{datamates:[...]}` for every URL, including the memory POST — the mirror sees no id in the response and correctly classifies the block as declined, so the seed stays unfinished and the second `recordApproved Binding` retries it (5 fetches instead of 3). Route the mock by URL: memory POST returns `{result:{results:[{id}]}}`, memory list returns `[]`, everything else keeps the workspace-list shape. The seed now genuinely completes on first call; the second warm correctly short-circuits. All 22 workspace-cache tests green locally.
1 parent 86403e1 commit 822a2fd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/opencode/test/altimate/plugin/workspace.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,30 @@ describe("workspace binding cache", () => {
226226

227227
let calls = 0
228228
const originalFetch = globalThis.fetch
229+
// Return URL-shaped responses. The mem-POST endpoint must return the
230+
// ``{result:{results:[{id}]}}`` envelope the mirror code expects — a
231+
// response without an id classifies as ``declined``, which by design
232+
// leaves the seed unfinished and forces a retry on the next warm.
233+
// (harness-bot #1116 comment 3840503346 hardened that gate.)
234+
let memPostSerial = 0
229235
globalThis.fetch = (async (_input?: unknown, _init?: unknown) => {
230236
calls++
237+
const url = String(_input)
238+
if (url.includes("/datamates/memory/") && !url.includes("/list")) {
239+
memPostSerial += 1
240+
return new Response(
241+
JSON.stringify({
242+
result: { results: [{ id: `mock-mem-${memPostSerial}`, event: "ADD" }] },
243+
}),
244+
{ status: 200, headers: { "Content-Type": "application/json" } },
245+
)
246+
}
247+
if (url.includes("/datamates/memory/list")) {
248+
return new Response(JSON.stringify([]), {
249+
status: 200,
250+
headers: { "Content-Type": "application/json" },
251+
})
252+
}
231253
return new Response(JSON.stringify({ datamates: [{ id: 9, name: "Warm", memory_enabled: true }] }), {
232254
status: 200,
233255
headers: { "Content-Type": "application/json" },

0 commit comments

Comments
 (0)