Repository navigation
fix(sync): 为会话启动刷新增加冷却和并发复用 - #1683
Conversation
|
未发现当前 diff 中可确认的问题,无需提出审查 finding。 PR 描述的测试记录充分:包含构建、类型检查、lint、232 项单元测试,以及使用构建后真实 CLI 的 5 项端到端测试;覆盖冷却复用、并发锁等待、新 checkout 下发、显式刷新和失败重试。其余 provider/agent 组合已明确留给 CI,不构成阻断项。 本次仅只读审查指定 diff,未运行、构建或安装 PR 中的任何内容。 |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
I built main (38e1361) and this head (b28426b), and ran the session-start hook against a local bare remote, counting git pull calls. The cooldown does what the body says:
| Case | main | this head |
|---|---|---|
| Three session starts after a manual pull | 1 / 1 / 1 pulls | 0 / 0 / 0, stamp unchanged |
| A push to the remote inside the 60 s window | seen at once | seen after the window, as the member guide says |
| Remote failing, then restored | retried every start | retried after the failure |
| Two overlapping starts, then a third | 1 / 0 / 1 | 1 / 0 / 0, the second waits and delivers |
[P1 阻断] A failed fetch now deletes the 24-hour inline record, so a new worktree gets no team skills while the remote is down
pullTeamRepo now removes last-fetch.json when the fetch fails (src/pull.ts, the transitionTeamRepo(...).catch branch). That file is not only the 60-second cooldown: the post-checkout inline pull reads it with the 24-hour TTL (teamFetchedWithinTtl(localConfig) in the options.inline branch) to deliver from the cached clone without refetching.
To reproduce in a workspace install:
- Run
teamai pullwhile the remote is up, then age the stamp to 5 minutes. That is inside the 24 hours and outside the 60 seconds. - Make the remote unreachable and run one session start. Its fetch fails.
- Run
git worktree add.
Result:
- main: the stamp survives step 2, the hook reads the cached clone (
fetched within the TTL, not refetched), and the new worktree has the team's skills. - this head: the stamp is gone after step 2, so the hook refetches, the fetch fails again, and the new worktree has no team skill.
This contradicts the body's "现有 inline TTL 保持原有语义" and the new line in data-directory-layout.md. The stamp is only written after a successful fetch, so the cooldown is already correct without the delete. Dropping that rm fixes it. The rm after a failed submodule update changes the inline TTL the same way: keep it or drop it, but make the design note say which.
[P3 可选] A session start can now spend most of the pull handler's budget waiting
A start can wait up to 60 s for the scope lock and then fetch, inside the 120 s pull handler budget, so a slow holder plus a slow fetch could time out. I did not reproduce it.
CI was still running at this head when I checked. The CI review found nothing; the case above is why I disagree.
A failed session-start fetch deleted last-fetch.json, which is also the 24-hour inline TTL record, so a new worktree created while the remote was down got no team resources. The stamp is only written after a complete refresh, so the cooldown stays correct without the delete. A failed submodule update now also leaves the previous stamp in place.
I pushed b6c1c2c on top of your branch to close the blocking item, so this can land:
Locally: Real CLI, isolated HOME, local bare team origin:
I will approve and squash-merge once CI is green on this head. Thanks for the cooldown. |
PR 描述包含充分的构建、单元测试及真实 CLI 验证记录,不存在缺少端到端记录的问题;但上述断言与当前实现矛盾,需要修正并重新核验。其余 provider/agent 组合留给 CI 不构成阻断。 此前审查未提出具体 finding,无需标记已解决项。本次仅只读指定 diff,未运行、构建或安装 PR 内容。 |
On the two points in the latest CI review:
|
此前的 E2E 断言问题已解决: PR 描述包含构建、单元测试及构建后真实 CLI 的端到端验证记录,满足测试记录要求;其余 provider/agent 组合明确留给 CI,不构成阻断项。 本次仅只读检查指定 diff,未运行、构建或安装 PR 中的任何内容。 |
…tself a session start
此前的 E2E 断言问题已解决: PR 描述包含构建、类型检查、lint、单元测试及构建后真实 CLI 的端到端验证记录,满足测试记录要求;其余 provider/agent 组合明确留给 CI,不构成阻断项。 本次仅只读检查指定 diff,未运行、构建或安装 PR 中的任何内容。 |
CI at 49be912 failed on two tests that predate my commits (they failed at b28426b too). I pushed fixes for both; neither changes runtime code:
Locally: |
此前的 E2E 断言问题已解决: PR 描述包含构建、类型检查、lint、单元测试及构建后真实 CLI 的端到端验证记录,满足测试记录要求;其余 provider/agent 组合明确留给 CI,不构成阻断项。 本次仅只读检查指定 diff,未运行、构建或安装 PR 中的任何内容。 |
|
未发现当前指定 diff 中可确认、需要提出的 finding。 此前问题已处理:
PR 描述的测试记录充分,包含构建、类型检查、lint、232 项单元测试及构建后真实 CLI 的 5 项端到端测试。其余 provider/agent 组合明确留给 CI,不构成阻断项。 本次仅只读审查指定 diff,未运行、构建或安装 PR 中的任何内容。 |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at d50d363. All 18 checks are green and the CI review has no findings: session starts reuse a successful refresh for 60 seconds, overlapping starts wait for the same lock, and a failed refresh keeps the last successful stamp, so new worktrees still get the team resources while the remote is down. Thanks for the cooldown.
修复会话启动时重复刷新团队仓库的问题。预热后,连续三次 SessionStart 原来各执行一次
git pull;现在在 60 秒内复用最近成功的刷新。Closes #1681
验证基于最新
origin/main(38e13613),在独立 worktree 中完成。先增加回归测试,确认原代码在连续启动、冷却复用和锁等待场景失败,再实现修复。已通过:
npm run buildnpm run typechecknpm run lint(含文档检查)npm test -- src/__tests__/pull-skip-sync.test.ts src/__tests__/hook-handlers.test.ts src/__tests__/pull-prepare-checkout.test.ts src/__tests__/pull-submodule-skip-sync.test.ts src/__tests__/pull-sync-truth.test.ts:232 项通过。npm run test:e2e -- src/__tests__/e2e/session-start-refresh-1681.test.ts:5 项通过,使用构建后的真实 CLI、本地 bare remote、隔离配置和 Git Trace2,未修改构建产物。真实 CLI 记录:
环境:macOS、Node v22.22.3、Git 2.50.1。验证覆盖 git provider 的 Claude 启动入口和 Cursor 下发。其余 provider/agent 组合留给 CI。现有
new-checkout-trigger.test.ts的 9 项用例因要求 Git >=2.54 而跳过;本 PR 新增的 hookless checkout 场景已独立通过。行为取舍:团队远端的新提交可能最多延迟 60 秒被自动刷新发现;需要立即同步时执行
teamai pull。