fix(memory): extend background-maintenance lock discipline to the periodic prepare path (issue #324) - #333
Merged
Merged
Conversation
LeXwDeXforce-pushed
the
fix/memory-lock-discipline
branch
2 times, most recently
from
August 18, 2026 04:05
2f0b6ff to
87eb01aCompare…iodic prepare path (issue #324)
LeXwDeXforce-pushed
the
fix/memory-lock-discipline
branch
from
August 18, 2026 04:09
87eb01a to
cfb42e8CompareUh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景(issue #324 debt 2)
审计报告:
docs/audit-dag-memory-goal-2026-08-18.md(MEM-01 / MEM-02 / MEM-03)。周期
prepare在fence.withLiveIdentity+lock.withProject之下内联跑周期维护(2 次模型调用)——违反模块自己在memory.ts注释中成文的锁纪律("模型调用在 fence/lock 之外")。叠加 #329 退役墙钟后,一条持续流式的慢推理调用可以把跨进程 identity fence 持有任意长时间,饿死并发的/compactcheckpoint、memory_search、worktree admission 与 identity upgrade(EffectFlock等待者 5 分钟后LockTimeoutError)。变更
memory.tsprepareUnsafe镜像checkpointUnsafe形状:due 维护在 fence 之后经kickMaintenance后台运行(每项目至多一个在飞作业);prepare 渲染维护前快照,提交结果在后续 prepare 浮现(fix(memory): SSE-liveness debt — wall-clock guard contradicts streaming principle; periodic prepare path still long-holds locks #324 明示语义)。shouldMatch=false)不再读 store、不拿 fence/lock——纯内存节奏记账。maintain(裸store.updateTopics、依赖调用方持锁的旧形状)。searchUnsafe:行为不变(fix(memory): SSE-liveness debt — wall-clock guard contradicts streaming principle; periodic prepare path still long-holds locks #324 验收要求保留同查询合并),把"matcher 有意在锁内运行以合并同查询"这一取舍显式写进注释。catchCause的瞬态行为变为 CONTEXT.md 声明的设计语义;"失败仅 logWarning、未向用户暴露"的一半仍在,留待 follow-up。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 ✅