Skip to content

fix(memory): extend background-maintenance lock discipline to the periodic prepare path (issue #324) - #333

Merged
LeXwDeX merged 1 commit into
devfrom
fix/memory-lock-discipline
Aug 18, 2026
Merged

fix(memory): extend background-maintenance lock discipline to the periodic prepare path (issue #324)#333
LeXwDeX merged 1 commit into
devfrom
fix/memory-lock-discipline

Conversation

@LeXwDeX

@LeXwDeXLeXwDeX commented Aug 18, 2026

Copy link
Copy Markdown
Owner

背景(issue #324 debt 2)

审计报告:docs/audit-dag-memory-goal-2026-08-18.md(MEM-01 / MEM-02 / MEM-03)。

周期 preparefence.withLiveIdentity + lock.withProject 之下内联跑周期维护(2 次模型调用)——违反模块自己在 memory.ts 注释中成文的锁纪律("模型调用在 fence/lock 之外")。叠加 #329 退役墙钟后,一条持续流式的慢推理调用可以把跨进程 identity fence 持有任意长时间,饿死并发的 /compact checkpoint、memory_search、worktree admission 与 identity upgrade(EffectFlock 等待者 5 分钟后 LockTimeoutError)。

变更

memory.ts

CONTEXT.md 增补两条不变量:维护永不跨模型调用持锁;search 跨单次有界 matcher 调用持锁是已声明的取舍。

测试

  • 调整被钉死的"周期维护同步"语义:runs due maintenance without refreshing retrieval context for a later turn 改为 polling 等待后台维护完成(fix(memory): SSE-liveness debt — wall-clock guard contradicts streaming principle; periodic prepare path still long-holds locks #324 预告的调整)。
  • 新增回归 keeps the fence and project lock free while background maintenance streams:维护模型调用在飞期间,并发 checkpoint(需要同一 fence+lock 的渲染 select)必须在 2s 内完成——旧内联形状下会饿死在 fence 上。
  • coalesces concurrent identical queries without consuming another query slot 原样通过(搜索合并行为未变)。

验证

  • bun typecheck(packages/opencode)✅
  • bun test test/memory test/tool/memory-search.test.ts:96 pass / 0 fail ✅
  • bun test test/server/httpapi-memory-wiring.test.ts test/session/system.test.ts:10 pass / 0 fail ✅

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@LeXwDeX