Skip to content

Commit 02be1fd

Browse files
sahrizviclaude
andcommitted
fix(workspace): count unsynced memory against the workspace's own setting
Found end-to-end, not by unit tests. Against a live backend, `status` reported `{local: 14, unsynced: 14}` while `sync` on the same project answered `{gated: true, skipped: 14}` — the menu headline promising a backlog that the sweep then refused to move. `pendingCount` gated only on the pilot flag, while `backfill` also refuses when the BOUND WORKSPACE has memory switched off. So on a workspace with memory disabled, every local block counted as outstanding and no action could clear it. This is the drift `partitionPending` was extracted to prevent — the extraction made the comparison shared but left the two gates different, which is the same bug one level up. Both now ask the same question. Regression coverage for this is the end-to-end run, not a unit test: the unit suite's temporary project has no memory blocks, so an assertion there would pass whatever the gate did. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6
1 parent ae80f16 commit 02be1fd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,18 @@ function partitionPending(
658658
* payload. Index read only — no network, no writes — so a status line can call it.
659659
*
660660
* Deliberately shares ``partitionPending`` with the sweep rather than re-deriving
661-
* the comparison: this number is a promise about what ``backfill`` would do. */
661+
* the comparison: this number is a promise about what ``backfill`` would do.
662+
*
663+
* That promise includes the workspace's own memory setting, not just the pilot
664+
* flag. ``backfill`` refuses outright when the bound workspace has memory off,
665+
* so counting index misses in that state advertises a backlog no action can
666+
* clear — a status line saying "14 not synced" above a sync that answers
667+
* "memory is off for this project". Found end-to-end; both gates have to be the
668+
* same gate. */
662669
export async function pendingCount(blocks: MemoryBlock[], binding: CachedBinding | null): Promise<number> {
663670
if (blocks.length === 0) return 0
671+
if (!isEnabled()) return 0
672+
if (binding && !(await memoryEnabled(binding))) return 0
664673
return partitionPending(blocks, binding, await readIndex()).pending.length
665674
}
666675

0 commit comments

Comments
 (0)