返回 DeepSeek-Reasonix
SESSION_SWITCH_SIDEBAR_REGRESSION.md
根目录 / docs / SESSION_SWITCH_SIDEBAR_REGRESSION.md
1 # Session switching and sidebar identity / 会话切换与侧栏身份回归
2
3 ## Reproduced mechanisms / 已复现机制
4
5 Canonical `OpenSession` emits `runtime:rebuilt` and `agent:ready` before returning.
6 The passive readiness handler and explicit navigation both hydrated the target,
7 while rebuild notifications could restart its follower. A gated host fixture
8 reproduced three baseline calls for one selection, including reads before the
9 target binding committed. The navigation intent now owns hydration through its
10 completion; stale completion cannot release a newer intent. Repeated notices
11 for the same runtime epoch preserve its follower, while an actual replacement
12 still creates a new subscription. Prompt bookkeeping still resets on rebuild.
13
14 规范会话的打开接口会在返回前发送重建和就绪事件。被动就绪处理与主动打开流程
15 都加载目标历史,重建通知还可能重启订阅。使用可控异步屏障,修复前一次选择
16 触发了三次 baseline 读取,其中包含绑定提交前的读取。现在由当前导航意图统一
17 负责加载;旧操作结束不能释放新操作的归属。同一运行时的重复通知保留订阅,
18 真正替换运行时仍建立新订阅,审批等重建状态继续正常重置。
19
20 Reviewed versions of a legacy source inherited its unversioned path alias.
21 Separately, older source spellings could normalize to one alias while belonging
22 to different durable sessions. The renderer's mounted-key cache allowed those
23 canonical sessions to share a React key. Reordering a three-row fixture left
24 four DOM rows before the fix, without creating any session data.
25
26 旧来源的独立审核版本错误地继承了无版本路径别名;旧路径拼写归一化也可能让
27 独立会话共享来源别名。前端挂载键缓存允许两个规范会话共用 React key。
28 修复前,三条数据在重排后留下四条 DOM 行,无需新建任何会话即可复现增长。
29
30 The source owner now publishes only version-specific aliases for reviewed
31 sessions and removes ambiguous cross-owner aliases. Exact durable receipts
32 remain independently addressable. The renderer also refuses to transfer an
33 already owned mounted key to another canonical SessionRef, including rows
34 already loaded from older hosts. Unambiguous source adoption keeps its row key.
35
36 修复后,审核版本只使用其版本身份,多个会话争用的别名不会作为唯一身份发布,
37 原有持久化回执仍可分别寻址。前端不再把已归属一个规范会话的挂载键交给另一个
38 会话,兼容旧宿主已经返回的行;无歧义的来源迁移仍保留原挂载键。
39
40 ## Regression checks / 回归验证
41
42 Each bounded history read also opened its locator database for both freshness
43 validation and paging. Both opens ran a whole-database integrity audit. History
44 locators now opt into bounded, process-local audit certificates: a successful
45 full check can be reused only for the same file identity, size, mtime and SQLite
46 header, with no nonempty WAL. Replacement, writes, WAL data, failed audits and
47 mutation during opening/auditing invalidate reuse. No SQLite handles are retained;
48 other stores retain their existing default full audits and rebuild validation.
49
50 有界历史读取还会为新鲜度校验和分页分别打开定位索引,每次都执行整库完整性
51 校验。历史索引现在显式启用有界、进程内的校验凭据:仅当文件身份、大小、修改
52 时间和 SQLite 文件头一致,且没有非空 WAL 时,才复用此前成功的完整校验。
53 替换、写入、WAL 数据、校验失败及打开/校验期间的变化均使复用失效。不保留
54 SQLite 连接或文件句柄;其他存储默认的完整校验及重建校验保持原有行为。
55
56 - `canonical-navigation-hydration.test.tsx`: publication barriers, one baseline,
57 late duplicate notices, genuine runtime replacement, superseded navigation,
58 and failed-open cleanup. / 验证提交屏障、单次读取、迟到通知、真实替换、
59 快速切换及失败后的归属释放。
60 - `project-session-row-identity.test.tsx`: source adoption followed by repeated
61 sibling reorder/insertion/removal with conflicting legacy aliases, without
62 DOM growth or React warnings. / 验证来源迁移及冲突别名下反复重排、插入、删除。
63 - `TestWorkspaceSourceAliasesKeepReviewedSessionsIndependent` and
64 `TestWorkspaceSourceAliasesRejectAmbiguousPathOwnership`: backend alias
65 ownership with unchanged independent receipts. / 验证后端别名归属和独立回执。
66 - `TestIntegrityReuse*`: unchanged files, nonempty WAL, replacement with equal
67 size/mtime, SQLite header changes, failed audits, concurrent mutation, quick
68 versus full audit separation, real constraint corruption, concurrent readers
69 and bounded certificates. `BenchmarkHistoryProjectionRepeatedOpen` compares
70 the old full-audit path with reuse over a roughly 100 MiB SQLite fixture.
71 / 覆盖文件不变、非空 WAL、等大小/时间替换、文件头变化、失败及并发变化、
72 快速/完整校验隔离、真实约束损坏、并发读取和凭据容量;另以约 100 MiB 的
73 SQLite 夹具对比完整重复校验和复用校验的开销。
74 - `node bench/session-switch-sidebar.mjs`: real Chromium, 50 catalog refreshes,
75 five opens, no premature reads, one target baseline per open, clean console.
76 The fixture is included in `pnpm test:session-loading-browser`.
77 / Chromium 验证 50 次列表刷新与五次打开,绑定前零读取,每次打开一次 baseline,
78 控制台无警告;已纳入会话加载浏览器测试。
79
80 Existing transcript, tab switching, new-session races, topic activation,
81 pending-prompt, app-lifecycle, historical-source/version, sidebar browser,
82 typecheck and production build gates cover adjacent contracts. Desktop Go
83 alias/source regressions are also run with the race detector.
84
85 现有 transcript、标签切换、新建会话竞态、话题激活、审批、应用生命周期、
86 历史来源及版本、侧栏浏览器、类型检查和生产构建用于覆盖相邻行为;Desktop Go
87 别名及来源测试同时执行竞态检测。
88
89 Local measurement on a 110,911,488-byte SQLite fixture (ten measured opens):
90 full audits averaged 44.15 ms/open, reused audits 3.42 ms/open. The same-toolchain
91 isolated frontend baseline measured 2,107,855 initial raw bytes; the fix measured
92 2,108,229 (+374 bytes, 0.018%). The raw ceiling is 2059.0 KiB, retaining the
93 existing 186-byte producer margin; compressed, CSS and chunk budgets are unchanged.
94
95 本地 110,911,488 字节 SQLite 夹具的十次读取均值:完整重复校验为 44.15 ms,
96 复用校验为 3.42 ms。同工具链隔离构建的首屏未压缩基线为 2,107,855 字节,
97 修复后为 2,108,229 字节(增加 374 字节,0.018%)。未压缩阈值为 2059.0 KiB,
98 保留原有的 186 字节构建环境余量;压缩体积、CSS 和分块预算未放宽。
99
100 Local acceptance / 本地验收:
101
102 | Gate / 检查 | Result / 结果 |
103 | --- | --- |
104 | Root `go test -p 4 ./...` | Passed, 158 tested packages / 通过,158 个有测试的包 |
105 | Projection/session race suites and Desktop targeted race tests | Passed / 通过 |
106 | Frontend transcript, navigation, prompt and app lifecycle tests | Passed / 通过 |
107 | Production build, source/test typechecks and bundle gates | Passed / 通过 |
108 | Chromium sidebar and session-loading suites | Passed / 通过 |
109 | Repository lint and affected Go/desktop lint | Passed / 通过 |
110 | Windows amd64 Desktop cross-build | Passed; not a Windows runtime test / 通过;不代表 Windows 实机验证 |
111
112 ## Evidence boundaries / 证据边界
113
114 These are synthetic local regressions, not a replay of the user's private
115 session or a Windows performance measurement. Browser fixture elapsed times
116 include controlled publication and input actions; do not report them as a
117 production speedup. `recovered.duration_ms` also includes the first successful
118 delta poll after baseline installation, which may wait 25 seconds when idle.
119 Global `readDiagnostics` counters are not a per-session timing trace.
120
121 测试使用本地构造数据,不是用户私有会话的回放,也不是 Windows 性能实测。
122 浏览器夹具耗时包含受控提交及输入操作,不能当作生产环境提速数据。
123 `recovered.duration_ms` 包含 baseline 安装后的首次成功增量轮询,空闲时可能
124 额外等待 25 秒;全局 `readDiagnostics` 也不能当作单会话的阶段耗时。
125
126 No persisted format, conversation content, or provider-visible prompt changes
127 are required. The follow-up below adds an optional Desktop event field and a
128 local read-only RPC. / 本修复无需修改存储格式、会话正文或模型可见的提示词;
129 下述补充修复新增一个可选 Desktop 事件字段及本机只读 RPC。
130
131 ## Follow-up on latest main-v2 / 最新主线上的同类修复
132
133 Baseline: `origin/main-v2` at `8cc804e687` (2026-10-24). All original fixes
134 were rebased onto that commit before the following changes.
135 基线为 2026-10-24 的 `origin/main-v2`,提交 `8cc804e687`;原有修复先变基,
136 再补齐以下同类问题。
137
138 ### Canonical aliases / 明确会话身份与别名
139
140 Page merging, incomplete pages, pinned rows and runtime overlays now share a
141 resolver that gives host/session identity precedence. Only a unique owner can
142 adopt a legacy source; conflicting canonical rows remain independent. An
143 ambiguous source retained alongside canonical versions receives a separate
144 mounted key. Unidentified live tabs still adopt their own placeholders.
145 分页、不完整目录页、置顶行及运行状态叠加统一使用身份解析器,优先采用
146 host/session 身份;仅唯一归属的旧来源可以合并。存在歧义的来源与独立历史版本
147 保持区分,挂载键互不冲突;尚未取得 SessionID 的活跃标签页仍能接管自己的占位行。
148
149 Archive fences retain each canonical owner independently, including source
150 archive receipts naming multiple adopted targets. Another session's alias or
151 larger lifecycle generation cannot hide a sibling or release its archive.
152 归档屏障按明确会话分别保存,来源归档回执包含多个已迁移目标时亦如此。
153 其他会话共享别名或更高生命周期版本,不会误隐藏同级会话或解除其归档屏障。
154
155 `session-alias-isolation.test.ts` failed all four initial cases before the fix;
156 it also covers multi-target source receipts. Existing runtime projection tests
157 protect pathless live-tab adoption. React and Chromium cover repeated reorder,
158 pagination, archive, unrelated sibling publication, and exact restoration.
159 新增身份测试在修复前四项均失败,并补充多目标来源回执测试;既有运行状态测试
160 保护无路径标签页迁移。React 和 Chromium 覆盖反复重排、分页、归档、同级会话
161 更新及准确恢复。
162
163 ### Derived read indexes / 派生读取索引
164
165 All history and search opens now go through `openHistoryProjection` or
166 `openSearchProjection`, including body ranges, attachment authorization,
167 exports, freshness checks and incremental updates. Rebuilds still validate
168 their newly populated database; unrelated authoritative stores keep full checks.
169 所有历史及搜索索引打开统一经过上述入口,覆盖正文分块、附件授权、导出、
170 新鲜度检查和增量更新。重建仍校验新生成的数据库,其他权威存储仍执行完整校验。
171
172 `TestSessionReadPathsReuseIntegrityAndRecheckChanges` uses SQLite CHECK-expression
173 probes to count actual integrity audits through query APIs, without timing
174 thresholds. Before repair, three unchanged attachment lookups performed three
175 extra audits; export and search performed six each. After repair, unchanged
176 reads perform zero extra audits, and external writes require a new audit.
177 该测试利用 SQLite CHECK 表达式观测实际完整性校验次数,不依赖机器耗时阈值。
178 修复前三次附件查询额外校验三次,导出和搜索各六次;修复后未变化的读取不再
179 额外校验,外部写入仍强制重新校验。正文分块及历史窗口一并覆盖。
180
181 ### Remote hydration / 远程历史加载
182
183 The real remote hook reproduced an extra baseline when the same ready barrier
184 arrived during mounting. State publications now carry a monotonic per-tab
185 `hydrationRevision`; `RemoteTabHydrationState` reads the same publication under
186 the route lock, without contacting Serve. A frontend owner joins in-flight or
187 installed baselines for that revision, rejects old barriers, and permits retries
188 after failure. New ready-to-ready revisions still reload after reset, resume or
189 ownership transfer. Disconnect invalidates pending completion. Explicit user
190 retry remains available.
191 真实远程 Hook 已复现:挂载期间到达相同 ready 通知会额外读取一次基线。
192 状态通知现在携带标签页内递增的 `hydrationRevision`;新增只读 RPC 在路由发布锁内
193 读取同一状态,不访问远端 Serve。前端按版本复用正在加载或已安装的基线,拒绝旧
194 通知,失败后可重试。真实重置、恢复或归属切换产生的新版本仍会重新加载;断线
195 使未完成的旧响应失效,用户显式重试功能保留。
196
197 | Contract / 契约 | Compatibility / 兼容行为 |
198 | --- | --- |
199 | Optional event revision / 可选通知版本 | Old renderers ignore it; missing revisions preserve legacy ready invalidations. / 旧前端忽略新增字段,缺少版本时保留原 ready 重载语义。 |
200 | Read-only mount snapshot / 只读挂载快照 | An unavailable command falls back to existing hydration. / 旧宿主缺少该命令时回退到原加载流程。 |
201 | Session/provider data / 会话与模型数据 | No persisted or provider-visible bytes change. / 不修改持久化格式或模型可见内容。 |
202
203 Deterministic hook, owner and Go publication tests cover duplicate notifications,
204 genuine resets, supersession, failure retry, disconnect, legacy notifications and
205 atomic mount snapshots. Chromium verifies duplicate ready, newer resets and an
206 older baseline completing after the latest one. The new regressions run through
207 `pnpm test:session-switch-regression`, also required by the session-loading browser suite.
208 确定性 Hook、归属管理器及 Go 发布测试覆盖重复通知、真实重置、快速替换、失败重试、
209 断线、旧通知兼容及挂载状态原子读取;Chromium 验证重复 ready、新版本重置和旧基线
210 晚到。新增回归统一纳入上述命令,并接入会话加载浏览器测试。
211
212 The complete fix measures 2,109,361 initial raw bytes versus 2,107,862 on isolated
213 latest main-v2 with the same toolchain (+1,499 bytes, 0.071%). The raw ceiling is
214 2060.2 KiB, retaining the established 186-byte producer margin. All compressed,
215 CSS, locale, chunk and history residency budgets are unchanged.
216 同工具链隔离构建最新主线为 2,107,862 首屏未压缩字节,完整修复为 2,109,361 字节
217 (增加 1,499 字节,0.071%)。未压缩阈值为 2060.2 KiB,保留既有 186 字节生产构建
218 余量;压缩体积、CSS、语言包、分块及历史驻留预算均保持原有要求。
219
220 ### Final local acceptance / 最终本地验收
221
222 Verified on macOS, 2026-10-25 / 于 2026-10-25 在 macOS 本地验证:
223
224 | Gate / 检查 | Result / 结果 |
225 | --- | --- |
226 | Root `go test -p 4 ./...` | 158 packages passed / 158 个包通过 |
227 | Desktop CI partition inventory and all 12 groups | All passed; 3,249 test/example/fuzz entry points assigned / 全部通过,清单覆盖 3,249 个测试、示例及模糊测试入口 |
228 | Projection/history and Desktop navigation/publication race tests | Passed / 通过 |
229 | Frontend typechecks, transcript, remote, app lifecycle, 18 sidebar test files | Passed / 通过 |
230 | Session-loading Chromium suite and final local/remote regression fixture | Passed / 通过 |
231 | Production build and bundle budgets; both Go modules' lint; repolint; generated contract/inventory | Passed / 通过 |
232 | Windows amd64 Desktop cross-build | Passed; not a Windows execution / 编译通过,非 Windows 实机运行 |
233
234 Desktop broad validation uses the existing `desktop-windows-go-tests.mjs`
235 partitions, whose inventory check proves complete coverage. Its own TestMain
236 and per-test helpers isolate homes; leave inherited `REASONIX_HOME` unset.
237 The terminal-state notification regression now parses and checks state, error,
238 publication revision and exactly one notification instead of rejecting the
239 additive revision field through an obsolete full-JSON string comparison. The
240 affected Q-S partition was rerun successfully after that contract update.
241 Desktop 全量验证采用既有分组工具及完整性清单。测试入口和逐测试辅助函数自行
242 隔离目录,应清除继承的 `REASONIX_HOME` 覆盖。终止状态通知回归现解析并检查状态、
243 错误、发布版本和恰好一次通知,替代会拒绝新增可选字段的旧完整 JSON 字符串比较;
244 更新契约后,受影响的 Q-S 分组已完整重跑通过。
245
246 ## Projection path admission / 索引路径构造边界
247
248 The integrity-audit path originates from the host's `FilesystemPersistence.Root`,
249 the fixed `.query-cache` directory, a canonical SessionID, and a fixed history
250 or search filename. Public query admission already validates the SessionRef.
251 The shared `sessionProjectionPath` constructor now independently rejects
252 non-local or invalid canonical IDs before joining any path. It no longer
253 reduces an invalid identity with `filepath.Base`, which could otherwise alias
254 another session or leave the per-session cache directory. SQLite and integrity
255 proof reads consume the same constructed path; no CodeQL suppression is added.
256
257 完整性校验路径由宿主的 `FilesystemPersistence.Root`、固定 `.query-cache` 目录、
258 规范 SessionID 和固定历史或搜索文件名构成。公开查询入口已有 SessionRef 校验;
259 共用路径构造函数现在也会在拼接前独立拒绝非本地路径及非法会话身份,不再通过
260 `filepath.Base` 将非法输入降为另一个会话名或脱离单会话缓存目录。SQLite 打开与
261 校验凭据读取使用同一个构造结果,没有增加 CodeQL 忽略规则。
262
263 `TestProjectionPathsRejectInvalidSessionIdentity` covers parent traversal,
264 absolute and multi-component IDs, Windows separators/reserved names, empty/dot
265 IDs, control bytes and oversized IDs, while retaining valid Unicode IDs and
266 roots containing spaces or punctuation. The unchanged-file audit, WAL and
267 replacement-during-open regressions remain in the race-test gate.
268 新增测试覆盖父目录跳转、绝对路径、多段身份、Windows 分隔符和保留名、空值与
269 点目录、控制字符及超长身份,同时保持 Unicode 身份和含空格、标点的正常根目录
270 可用;文件未变时复用、WAL 变化和打开期间替换的回归仍保留在竞态检查中。
271
272 ## Surviving-renderer recovery / 服务重启后的前端恢复
273
274 Remote tab IDs survive a desktop service restart, while their publication
275 revisions restart from zero. The hydration owner must therefore retire its
276 revision watermark when the native service generation changes or becomes
277 unavailable. The existing `desktop:resync` event then reads the replacement
278 service's publication and establishes one baseline. Repeated recovery signals
279 inside the same service remain coalesced; old baseline/state-RPC completions
280 cannot install the retired service's revision. Shutdown sends no subscription
281 cleanup to the replacement service, and resident transcript content is retained.
282
283 桌面服务重启会沿用远程标签页 ID,但通知版本从零重新计数。因此,原生服务代次
284 变化或服务不可用时必须清除旧加载归属及版本水位,再由已有 `desktop:resync`
285 事件读取新服务状态并建立一次基线。同一服务内的重复恢复信号仍会合并;旧基线
286 及旧状态 RPC 晚到不能覆盖新服务的版本。关闭旧服务时不向新服务发送订阅清理,
287 已展示的历史内容保持可读。
288
289 The real hook regression failed before this repair (no baseline after restart).
290 It now covers restart with and without a shutdown event, stale state responses,
291 and duplicate resync. Chromium verifies restart to revision 1 on the surviving
292 surface. This adds 311 initial raw bytes over the prior fix: 2,109,672 versus
293 2,107,862 on main-v2 (+1,810 bytes, 0.086%). The raw ceiling is 2060.5 KiB with
294 the same 186-byte producer margin; other bundle limits remain unchanged.
295 真实 Hook 回归在修复前失败(重启后没有新基线),现覆盖有、无关闭通知的重启、
296 旧状态响应及重复 resync;Chromium 验证存活界面接纳从 1 开始的新版本。首屏原始
297 体积较上一轮修复增加 311 字节,完整修复为 2,109,672 字节,比主线增加 1,810 字节
298 (0.086%);阈值为 2060.5 KiB,保留同样的 186 字节生产构建余量,其他限额不变。
299
299 lines MARKDOWN