Commit Graph
5 Commits
Author SHA1 Message Date
Menghuan1918 f7a11ddbfe fix(host): root a detached session at its stored header, not a full log read
cwdOf() resolves the cwd for every file/Git route, and a cold (detached)
session paid one host observation per call: sessionQuery.observeSession({
projectionMode: 'all' }) decodes the whole zstd artifact and hydrates every
projection to answer with one workingDirectory string. The 0.28.1
single-flight only covered /sidebar/api, while the real startup fan-out
never goes through it: the fs-watch socket sends one frame PER WATCHED
DIRECTORY (server resolves cwd before it even reads the op), /sidebar/file
and /sidebar/html resolve per resource, upload/write per call. A 39 MB
session was therefore decoded dozens of times in parallel — the 44-read
OOM on 0.28.0 and the 36 reads reported against 0.28.1 are the same path,
not a broken dedupe.

A detached session now resolves through sessionPersistence.stat(), which
reads the first zstd frame only (header-only, never the log), memoized per
session id (headers are immutable) and shared in-flight across concurrent
asks. activeWorktreeRootOf() answers a detached session with that address
and no longer folds the stored log. Once the host attaches the session the
committed working_directory and linked-worktree following resume as before.

Trade-off (documented): until attach, the sidebar roots at the original
project rather than the agent's last directory/worktree.

tests/smoke.spec.ts rewrites the cwd group (header ahead of a stale hint,
one header read per session, 12 concurrent asks share one, stat absent or
failing falls back to the hint, live committed directory wins, relative
header cwd still refused) and tests/active-worktree.spec.ts pins that a
detached session performs no persistence read and no git probe.
2026-10-27 11:36:09 +08:00
ymac 099128d1b6 merge origin/dev into fix/worktree-root-address-base
四处冲突,都不是「选一边」能了事的:

1) `src/active-worktree.ts` 的头注释:上游这半个月把模块重写了一遍(cwd 解析收敛:
   TTL 15s、在飞去重、三个缓存加 LRU 上界、`working-directory/change` 作为证据边界),
   本分支加的是「工作区内只有同仓库的 linked worktree 才采纳」(#952)。两边都保留:
   一句讲采纳判定,一句讲证据边界。

2/3) `isLinkedWorktree` 一带:上游保留布尔缓存 + 每次探测,本分支把它换成
   `gitIdentityOf`(一次 `rev-parse` 同时给出 git dir 与 common dir,并带自己的缓存),
   由它派生出 `isLinkedWorktree` 与 `isAdoptableTop`。合并后**只留身份缓存**
   (布尔缓存成为同一趟探测的第二份副本,且负结果两边都缓存),`cachePut` 给身份缓存
   补上 LRU 上界,模块头注释的「三个缓存」正好仍是三个。

4) `AGENTS.md`:上游把 §3 整体搬进 `docs/host-contracts.md`(原 §3.4 的 1–12 条按原编号),
   本分支往旧 §3.4 追加了第 13 条(会话地址基准)。取上游的 `AGENTS.md`,把第 13 条
   按新家的体例写进 `docs/host-contracts.md` §B(编号 13 接在第 12 条后),并把四处
   「第 1–12 条」更新为「第 1–13 条」。

顺带:`tests/active-worktree.spec.ts` 的 `rmSync` 导入在上游侧被同一个文件的重排吃掉,
补回。

门禁:typecheck 干净;全量 vitest 2691 passed / 17 skipped / 1 failed(唯一红是既有的
smoke 写 `$HOME` 被本机沙箱 EPERM 拒);`active-worktree` / `worktree-address` /
`native-surface` 70 passed。
2026-10-18 23:19:59 +08:00
Menghuan1918 66c91091bc chore(release): adapt to DSH 0.2.1-rc.1 for 0.28.0 2026-10-17 14:03:22 +08:00
Menghuan1918 4ebd3e9bdd chore: adapt sidebar to DSH 0.2.1-alpha.5 2026-10-17 02:12:44 +08:00
Menghuan1918 af2aeb2889 docs(agents): AGENTS.md 收敛为规则清单(67KB → 10.8KB),深度参考移入 docs/
- AGENTS.md 只留每次都要遵守的规则与索引:§0 分支模型、§1 硬约束、§2 挂载
  门禁与钉版禁忌、§3 版本适配与抬基线清单、§4 发版、§5 开发规则、§6 去哪找
- 原 §3.4 宿主契约第 1–12 条与 0.1.5–0.1.7 沿用至今的约束移入
  docs/host-contracts.md,**编号保持不变**——代码 / 测试 / 文档里既有的
  「AGENTS.md §3.4 第 N 条」与 `§3.10` 引用仍能命中
- 删掉测试地图长清单与 CI 取证叙事:契约本就在各 spec 头注释、docs/plans 与
  CHANGELOG 里,AGENTS.md 只留索引与那几条会真咬人的跨平台规则
- 订正过期事实:testTimeout 30s、chunk 名真源 CHUNK_NAMES、markdownTextProps
  渲染点、minimumReleaseAgeExclude 所在脚本、0.1.7 线最后支持版 v0.22.1
2026-10-16 18:35:51 +08:00