Skip to content

Commit 358fa87

Browse files
committed
fix(workspace): archiveNow reads through fetchKnownRecords, warns on truncation
`archiveNow` was calling `MemoryApi.list()` directly. Once a workspace has >= LIST_LIMIT records and the block the user wants to delete is beyond that window, the `records.find(...)` fallback returns undefined, the `if (!current) return` branch takes it silently, and the block stays live in the cloud — every later session re-injects it with no diagnostic trace. Route the read through `fetchKnownRecords()` (same as `push`), and log a warning on the truncated-no-find path so the failure mode is at least observable. Small semantics: a "not truncated + not found" no-op is still correct (the block genuinely isn't there); the warning only fires when truncation is the plausible explanation. (altimate-harness-bot #1116 comment 3841102064.)
1 parent f6b8c32 commit 358fa87

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

packages/opencode/src/altimate/workspace/memory-sync.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,13 @@ async function archiveNow(
505505
})
506506
const entry = await readIndexEntry(key)
507507

508-
// The read exists to recover the record's current text so the archive can
509-
// preserve it, and to find the record at all when the index cannot answer.
510-
// It is also why archiving fails when the result is truncated.
511-
const records = await MemoryApi.list()
508+
// Read through ``fetchKnownRecords`` so a truncated response is detectable
509+
// — a workspace with >= LIST_LIMIT records that includes the target block
510+
// beyond the window would silently fall through the ``!current`` branch and
511+
// the delete would no-op. The block then stays live in the cloud and gets
512+
// re-injected on every session with no diagnostic trace. (altimate-harness-
513+
// bot #1116 comment 3841102064.)
514+
const { records, truncated } = await fetchKnownRecords()
512515

513516
// The index is per-machine and is discarded on account switch, corruption or
514517
// a wiped state directory. Without a fallback, deleting a block on a machine
@@ -524,7 +527,18 @@ async function archiveNow(
524527
records.find((r) =>
525528
isSameBlock(r, { id: blockId, scope, tags: [], content: "", created: "", updated: "" } as MemoryBlock, binding),
526529
)
527-
if (!current) return
530+
if (!current) {
531+
if (truncated) {
532+
// Distinguish "record isn't there" (silent no-op is correct) from
533+
// "record is beyond the LIST_LIMIT window" (silent no-op leaves a
534+
// live block whose delete looks successful client-side).
535+
log.warn(
536+
"could not archive block — record set is truncated at LIST_LIMIT; the block may still be live in the cloud",
537+
{ blockId, scope, limit: LIST_LIMIT },
538+
)
539+
}
540+
return
541+
}
528542

529543
const now = new Date().toISOString()
530544
const metadata: MirrorMetadata = {

0 commit comments

Comments
 (0)