Repository navigation
fix(antigravity): reconcile folded turn authority, footer background tasks, and silent schedule status - #3799
Conversation
af81d19 to
1bef7ba
Compare
deepcoldy
left a comment
There was a problem hiding this comment.
审查结论
基于 PR head 1bef7ba28cbfcacf6197c8dd34cbd87fbcc6d69f 复核;本地仅将同一内容 rebase 到当前 master,三个提交的 patch-id 均不变。Antigravity transcript 回收与 footer 计数主路径未发现新的 P0/P1;但静默看板状态存在一个可达的 P2 生产误判。前述两个测试缺口均通过变异复验确认,另有一个 P3 元数据清理问题。
P2:非静默准入覆盖不完整,人工工作可持续被标成纯静默巡检
isActiveTurnSilentSchedule 依赖 noteNonSilentTurnActivity 推进序号(src/core/silent-schedule-turns.ts:85-92,99-152),但该登记只接入了部分入口。比如:
- 失败卡
retry_turn在src/im/lark/card-handler.ts:4441-4475生成新 turnId 并调用sendWorkerInput,既没有调用noteNonSilentTurnActivity,也没有更新ds.currentTurnId;retry_last_task(同文件:4236-4293)等路径形状相同。 - 决策看板已有会话的非静默注入在
src/core/session-manager.ts:5652-5656只有input.silent时 arm,没有非静默分支;这与同文件:5306-5307的定时续跑处理不一致。
真实 worker-pool 组件 + 模拟 worker IPC 的探针(会话 cliId=claude-code,故不限于 agy)复现序列:
- arm 一个静默回合并收到其 working 帧,SessionRow 为
activeTurnSilentSchedule=true; - 以新 turnId 调
sendWorkerInput模拟人工重试,返回true(已准入); - 立即重组 SessionRow,仍为
true; - 再收到旧静默 turnId 的工作帧(type-ahead 折叠或滞后归因),仍为
true。
探针实际输出为 silentImmediatelyAfterAdmission=true、silentAfterAnotherSilentAttributedFrame=true。同一真值也驱动 src/core/worker-pool.ts:24566-24662 的 SSE patch,因此消费者不会及时收到 false。/quote(card-handler.ts:2610)本身更新了 currentTurnId,有序列外的 id 不一致兜底,仍只属于入口不一致;真正产生持续误判的是上述没有该兜底的入口。
建议在统一的真实准入边界处理非静默登记并发布状态翻转(send/fork 都覆盖,显式排除已 arm 的静默回合),而不是继续逐个卡片入口补漏;并加入“静默运行中人工重试准入后立即 false”的回归测试。此问题只影响新增看板/SSE 状态语义,不影响本 PR 的 agy transcript authority 回收与 footer 计数。
P2(测试缺口):两个生产守卫正确,但 PR 自带测试未钉住
- 非静默序号守卫:临时禁用
src/core/silent-schedule-turns.ts:141的lastNonSilentTurnSeq > meta.seq判断后,PR 相关 4 个测试文件仍为 76/76 绿;直提后滞后帧重归因探针由 false 变为 true(咬红),恢复生产代码后转绿。 - directSubmit 非静默登记:临时禁用
src/core/worker-pool.ts:24466-24468后,同样为 76/76 绿;无terminal_input前置、直接收到directSubmitworking 帧的集成探针咬红,恢复后转绿。
建议分别把这两个场景补进 test/silent-schedule-turns.test.ts 与 test/background-wait-card.test.ts。现有 background-wait-card.test.ts:776-789 在 directSubmit 前先发了 terminal_input,所以覆盖不到第二条独立登记路径。
P3:TTL 读路径只清 registry,新增的元数据可突破原有上限
src/core/silent-schedule-turns.ts:69-74 在 isSilentScheduledTurn 发现 TTL 到期时只删除 silentScheduledTurns,没有同步删除 silentScheduledTurnMeta(也没有清理同 id 的 latestSilentScheduledTurn)。假时钟连续执行 300 轮“arm → 读路径到期 → 下一轮 arm”后,实测 registrySize=0、metadataSize=300,绕过 MAX_SILENT_TURNS_PER_SESSION=256 的约束。增长较慢且不影响判定结果,故列 P3;建议到期路径复用统一的 disarm/清理逻辑,并用假时钟补边界测试。
验证
- 恢复后的最终定向回归:上述 4 个测试文件 76/76 通过。
- 上述两个变异下均为 PR 自带测试全绿、定向探针咬红;恢复后两探针转绿。
- 人工重试生产探针在未变异代码上稳定复现上述两个 true。
bun run typecheck通过;git diff --check通过;所有变异与临时探针均已还原/删除。
deepcoldy
left a comment
There was a problem hiding this comment.
补充审查:相同提示词回收存在 P1
对更多候选场景执行真实函数探针后,确认以下问题。前两项会把尚未消费的候选输入误判为 completed,调用方随后会删除队列并退役 turnId,存在跳过用户/定时输入的风险;因此需要更正上一条“未发现 P0/P1”的结论。
P1-A:前一条相同文本尚未落盘时,其 USER_INPUT + DONE 可冒充新候选
rememberSubmittedTurnText 在 literal write 前只采样当前 transcript size(src/worker.ts:6919-6940,26105-26107),而文本匹配只要求 lineFileOffset >= minByteOffset(src/services/antigravity-transcript.ts:1247-1275)。如果前一条同文输入的记录在采样后才落盘,它的记录和 DONE 也满足这个新下界。
真实 rememberSubmittedTurnText + findCompletedAntigravityTurnIds 探针:
- transcript 为空时为
schedule:new采样相同静态提示词,得到minByteOffset=0; - 只写入前一条同文运行的 USER_INPUT + PLANNER_RESPONSE DONE,不写入
schedule:new自己的输入; - 实际返回
incorrectlyCompleted=["schedule:new"]。
src/worker.ts:8891-8905 会据此 dropQueuedTurnRecord / markTurnRetired。需要为每次提交绑定独立、可证明归属的 USER_INPUT occurrence,而不能把“采样后的任意同文记录”当作本次提交证据;应覆盖前一条记录延迟落盘的回归用例。
P1-B:compact/full 切换时直接混用两套字节坐标
采样时 resolveAntigravityTranscriptPath 可能选中 compact,prompt_ready 时却选中后创建的 full(src/worker.ts:6926-6937,8851-8852);full/compact 同记录的字节偏移不同,但比较时没有使用已有的 mapAntigravityCompactOffsetToFull。
探针先把一条完整同文运行写入 compact,再为新候选实际采样到 minByteOffset=1348;随后创建同一批历史记录的 full 视图。该条采样前已存在的 USER_INPUT 在 full 中起点为 5011,仅因坐标系不同就越过下界;候选没有新输入,实际仍返回 incorrectlyCompleted=["schedule:sibling"]。应同时保存采样文件类型,切换到 sibling 时先转换 offset,再与统一 transcript 的坐标比较;这一项与 P1-A 需要分别修,单做 offset 转换不能覆盖前记录延迟落盘。
P2:reattach 后,无 message_location 的定时回合仍无法完成回收
recentSubmittedTurnTexts 仅是 worker 内存 Map(src/worker.ts:6916-6918)。worker reattach 后,恢复的 schedule candidate 在 src/worker.ts:8872-8878 没有 submittedText;定时提示词又没有 Lark message_location,因此即使 transcript 已有该提示词的 USER_INPUT + DONE,真实查询仍返回 completed=[]。这会保留本 PR 试图消除的 queueAfterActiveTurn 卡死场景。
现有 reattach 测试 test/antigravity-folded-turn-authority.test.ts:421-452 只覆盖带 message_location 的 om_B/om_C,没有覆盖静态定时提示词。建议从 durable scheduled-input/marker 恢复正文与位置,或提供其他安全归属证据,并增加 reattach + schedule 的集成用例。
P2:空行被当成页脚边界,可把普通输出误报成后台任务
src/adapters/cli/antigravity.ts:226 接受空行作为 footer 上边界,与函数注释“带分隔线边界的真实页脚”不一致。真实解析结果:
prose\n\n? for shortcuts · 4 task(s)→4Allow this command?\n\n? for shortcuts · 2 task(s)→2
这两类屏幕都没有原生 composer/分隔线证据,却会制造后台任务数;除看板误报外,src/core/idle-worker-sweeper.ts:226-228 等活 worker 守卫也会把输出文本当成真实工作。建议要求正向原生布局证据,不能只靠 blank boundary。
P2:静默回合已终态,screen-bound 分支仍可持续返回 active
src/core/silent-schedule-turns.ts:114-152 在 lastScreenTurnId 分支没有应用 latest-fallback 已有的 terminal guard。真实纯函数探针设置 live worker + working、当前代际的静默 screenTurnId,以及同 turnId 的 lastTurnTerminalStatus=completed,结果仍为 active=true。
turn_terminal 在 src/core/worker-pool.ts:26588-26596 只记录 terminal 并调度卡片兜底,没有清理 screen binding 或发布该字段;2 秒兜底在 :7215-7217 也明确是 display-only,不更新 dashboard 执行态。因此没有后续 idle screen 时,该错误不会由现有兜底消除。建议对 screen-bound turn 同样排除已终态记录,并在精确 terminal 到达时清理/发布 false。
P2:worker 退出与部分非静默准入的 SSE 补丁不完整
真实 worker-pool exit 探针的实际结果是:
{
"rowSilent": false,
"silentFalsePatch": false,
"rowBackgroundTasks": 2,
"backgroundClearedPatch": false
}新组装的行因 worker=null 已不再静默,但 src/core/worker-pool.ts:28711-28717 只发布 webPort/workerPid,已连接客户端按 patch 合并,仍保留 activeTurnSilentSchedule=true。同一处的 backgroundTaskCount 未清是既有清理缺口,新 agy footer 来源也会继承;建议统一在 generation retirement 清理并发布。
另一个同类点是 src/core/session-manager.ts:5307:非静默 scheduled continuation 会推进序号、让新组装的行变 false,但没有像 beginNewTurn / terminal_input 一样发布 false patch;无后续 screen frame 时 SSE 同样滞留。建议把这些状态迁移收敛到共享的发布辅助函数。
补充验证
以上结果均来自未变异生产代码的真实函数/真实 worker-pool 组件探针;临时文件已删除,生产工作区无 diff。前一条中的 76/76 定向测试与 typecheck 结论不变,这些场景正是当前测试未覆盖的缺口。
1bef7ba to
316e004
Compare
|
感谢细致审查,三条意见已全部收敛到最新 commit
本地验证: |
316e004 to
fb310f9
Compare
|
已看到补充审查意见,6 项问题已全部按 commit 收敛并重推(新 head Commit 1 (
|
fb310f9 to
b089d32
Compare
Antigravity folds type-ahead messages into an active run and settles them together before returning to idle. In normal send mode without per-turn transcript terminals, a lagging PID marker or queued type-ahead record could re-acquire activeTurnAuthority for an already-completed turn at prompt_ready, blocking later queueAfterActiveTurn schedules indefinitely. Check native Antigravity transcript consumption and non-tool PLANNER_RESPONSE completion (fail-closed while busy, non-durable turns only) before ready settlement so completed folded turns are retired without disturbing live successors, durable retries, or the queued-ready-transition contract. Also log active-turn deferral truthfully instead of Writing to PTY.
In normal botmux-send mode Antigravity does not run the structured transcript bridge, so active background commands and schedule timers reported in its native footer (? for shortcuts ... N task(s) / esc to cancel ... N task(s)) were not surfaced via screen_update.backgroundTasks. Parse the viewport-tail native footer conservatively (requiring the real footer boundary, preserving the last count when no footer is visible, and clearing to 0 when the footer drops task(s)), fold it into refreshBackgroundWait without holding foreground activeTurnAuthority, and reset on respawn, stopScreenUpdates, and conversation switches.
Track the currently executing screen_update turn and worker generation on DaemonSession so consumers can distinguish a pure silent scheduled poll from interactive or non-silent work without clearing the silentScheduledTurns suppression registry. Centralize non-silent turn admission tracking at the real worker-pool admission boundaries (sendWorkerInput, forkWorker, forkAdoptWorker, queued activation tail, direct raw_input/inject_command, and readonly task continuation) so card retries, decision-board injections, and direct submissions immediately clear activeTurnSilentSchedule and emit SSE patches. Also clean up silentScheduledTurnMeta and latestSilentScheduledTurn on TTL expiry and eviction.
b089d32 to
b99e304
Compare
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
deepcoldy
left a comment
There was a problem hiding this comment.
在作者最新 head b99e3048 基础上追加两个增量提交:
c019e8c8:retireWorkerProcessOnly同步清理并发布静默运行态与后台任务数,覆盖其先清空ds.worker、导致后续 exit 事件无法进入清理分支的路径。d152a45d:advanceAncestorSessionTurn保留提升回合与剩余 queued turns 的antigravityReconcileHint,任一可选字段非法时拒绝整份 hint,避免外部推进后 reattach 静态定时回合失去归属证据或从 byte zero 误配同文旧记录。
作者 head 已包含 P1/P2/P3 的主体修复;本次验证覆盖了同文延迟落盘、compact/full 偏移换算、reattach、页脚边界、终态/退出及 TTL 元数据。新增测试分别验证 process-only retirement 和 marker hint 保留,两个对应变异均咬红后恢复。
验证结果:
bun run build与 typecheck 通过。- 最终组合 vitest:3 文件 97 项通过;transcript/scheduler/terminal 另 6 文件 861 项通过。
- Bun runtime:3 文件 64 项通过。
- marker:34 项通过(已含在上述 97 项中)。
- 完整 vitest unit 已启动,结果将另行补充。
- 独立对抗复核发现并已关闭一个 P2:合法 hash 搭配非法 offset 曾被削弱为从 byte zero 匹配,现已改为整份 hint 拒绝;同一独立上下文复验
completed=[],process-only retirement、合法 hint 保留、错误 consumed turn 不推进及截断 marker 保护均通过。
影响面:未改动作者的 occurrence 算法;新增改动只涉及通用 worker 退役时的 dashboard 状态清理,以及 agy marker 元数据透传。其它 CLI 只共享退役清理路径,不改变执行/投递协议。
最新作者 rebase 已消除与 master 的冲突;GitHub 当前显示 MERGEABLE。
deepcoldy
left a comment
There was a problem hiding this comment.
补充完整 vitest unit 结果(最终 head d152a45dbb):
- 总结:exit code 1;52 个测试文件、140 项测试失败;3021 个文件、60839 项测试通过,188 项跳过。
- 失败清单不包含本次修改的
test/background-wait-card.test.ts、test/session-marker-resolve.test.ts、test/antigravity-folded-turn-authority.test.ts等新增/直接相关测试;这些文件已在最终 head 上单独全部通过。 - 两条
restart-reattach-antigravity.integration.test.ts失败均在首个 worker ready 之前,日志明确为 tmux socketFile name too long,尚未进入本 PR 的回收/reattach 逻辑。其它多数失败也呈真实 tmux/bwrap/权限/CLI 启动或网络夹具形态;未把这些环境失败归因于本 PR,但也未逐项把所有 140 项都证明为基线问题。
因此完整 unit 不是绿的,不能写成全量通过。合码判断应使用定向回归、独立对抗复核及 CI 分片结果,而不是把本次完整运行忽略掉。
Co-Authored-By: Claude Code <[email protected]>
deepcoldy
left a comment
There was a problem hiding this comment.
CI 已全部通过(d152a45d → 7d23ef7a5a):
- run
45472698418attempt 2 的最终结论为success,build、network-boundary、全部二进制、4 个 vitest shard 和 4 个 Bun shard 均为 pass。 test (1/4)的 topic-index SQLitedatabase is locked首次失败未涉及本 PR 文件;该文件本地复跑 29/29 通过后,按 Re-run failed jobs 重试,shard 已通过。- macOS hosted pool 首次未分配 runner 导致的 Darwin 取消,在新 head 的 run 中已通过。
- GitHub 当前 head 为
7d23ef7a5a7c627c9e56563ddd0cc4db169a2515,状态为OPEN MERGEABLE。
本地之前因超长 tmux socket 路径产生的集成失败与 CI runner 的路径环境不同,未据此判定 PR 回归;上述 CI 结果才是本 head 的完整分片结果。
…-status Sync PR deepcoldy#3799 with latest master (through deepcoldy#3798); combined tree == merge-tree prediction bf48da1, typecheck/build and 464 related tests pass locally.
deepcoldy
left a comment
There was a problem hiding this comment.
合并增量复审(head b443bafdf96c16a9d353a3d125cf5866ece1ff3a):
- 父提交为
7d23ef7a5a与1987742097;git merge-tree --write-tree预测为bf48da1c992cfa57675b52b2034c58cb46bea4df,与合并提交实际 tree 逐字一致,未发现手工改写。 - 重点核对了 #3800 的 type-ahead prompt sidecar 注册/清理与本 PR 的 reconcileHint:两条路径职责不同,未发生 hint 字段丢失或序数归属改写。#3791 的忙碌证据读取与本 PR 的 compact/full offset 映射也未见接口冲突。
- 合并树 vitest:16 个相关测试文件 357/357 通过;Bun 腿 4 个文件 72/72 通过;typecheck 通过。
- 覆盖 P1-A 延迟落盘、P1-B 坐标换算、marker hint 持久化/非法字段拒绝、process-only retirement、退出契约,以及 #3800/#3791/#3782 的相邻流程。
代码侧未发现新的阻断问题。CI 首跑仍在途,另以 CI 状态为准,不在此处提前标记通过。
deepcoldy
left a comment
There was a problem hiding this comment.
合并增量复审(head b443bafdf96c16a9d353a3d125cf5866ece1ff3a):
- 父提交为
7d23ef7a5a与1987742097;git merge-tree --write-tree预测为bf48da1c992cfa57675b52b2034c58cb46bea4df,与合并提交实际 tree 逐字一致,未发现手工改写。 - 重点核对了 #3800 的 type-ahead prompt sidecar 注册/清理与本 PR 的 reconcileHint:两条路径职责不同,未发生 hint 字段丢失或序数归属改写。#3791 的忙碌证据读取与本 PR 的 compact/full offset 映射也未见接口冲突。
- 合并树 vitest:16 个相关测试文件 357/357 通过;Bun 腿 4 个文件 72/72 通过;typecheck 通过。
- 覆盖 P1-A 延迟落盘、P1-B 坐标换算、marker hint 持久化/非法字段拒绝、process-only retirement、退出契约,以及 #3800/#3791/#3782 的相邻流程。
代码侧未发现新的阻断问题。CI 首跑仍在途,另以 CI 状态为准,不在此处提前标记通过。
|
合并 head
|
|
感谢 @big-omega 高质量的实现与多轮配合,已 squash 合入 master(8792e56709)。 这条链路最终的关键修复——用带 SHA-256 摘要、采样文件坐标和 skipPriorMatches 序数的 reconcileHint(随 PID marker 持久化、非法字段整份拒绝)解决同文延迟落盘误回收与 compact/full 坐标混用,fail-closed 边界和测试覆盖都很扎实;reattach 静态定时、非静默统一准入边界、退役状态清理、TTL 元数据清理也都收敛干净。 本 PR 评审提出的问题已全部闭合,无遗留 follow-up。评审中暴露的 CI 偶发(topic-search-index-store 在高负载 runner 上 SQLite database is locked)与本 PR 无关,已另开 #3812 跟踪根治。期待后续继续贡献。 |
|
🚀 Released in v3.59.32 |
Summary
Fixes three production issues observed on Antigravity (
agy) sessions and downstream status consumers:1. P0: Reconcile completed folded Antigravity turns at
prompt_ready(6fa79c6f)botmux sendmode (no per-turn transcript bridge terminals),botmux send --response-kind finalpromotes the next queued turnBon the PID marker (advanceAncestorSessionTurn), andmarkPromptReady()then re-acquiresactiveTurnAuthorityfor already-completedBviasyncQueuedTurnsFromMarkerDisk()/advanceQueuedTypeAheadTurn(). LaterqueueAfterActiveTurn: trueschedules are then blocked indefinitely while the CLI sits idle at>, and non-emptypendingMessagesblocksidlepublication.src/services/antigravity-transcript.ts: addfindCompletedAntigravityTurnIds()(fail-closed while transcript is busy; matches<message_location message_id="..."/>strictly before<user_message>, or exactsubmittedTextwith a pre-writeminByteOffsetlower bound so repeated static prompts cannot match earlier finished runs; requires a subsequent non-empty, non-toolPLANNER_RESPONSE DONE).src/worker.ts: addreconcileCompletedAntigravityTurnsAtPromptReady()beforedecideQueuedReadyTransition()inmarkPromptReady()for non-durable turns only (dispatchAttempt === undefined), preserving live successors, durable retries of the sameturnId, and thequeued-ready-transition.tscontract whenBis still executing. Also fixsendToPty()logging whenactiveTurnBlocks(next)defers a write.2. Antigravity native footer background task count (
520e13b7)scheduletimers shown in its native footer (? for shortcuts ... N task(s) · /tasks/esc to cancel · N task(s)) were not surfaced viascreen_update.backgroundTasks→ds.backgroundTaskCount.src/adapters/cli/antigravity.ts: addparseAntigravityFooterBackgroundTasks()anchored strictly to the viewport-tail footer with separator boundary (handling narrow 2-line wraps, returningundefinedwhen no real footer is visible so previous counts are preserved, and returning0oncetask(s)disappears).src/worker.ts: fold parsed counts intorefreshBackgroundWait()without holding foregroundactiveTurnAuthority, and reset on CLI spawn,stopScreenUpdates(), and conversation switches.3. Expose
activeTurnSilentScheduleon session rows and SSE (5127ae14)workingstatus was a pure silent scheduled poll vs interactive human/bot work.src/core/types.ts,src/core/silent-schedule-turns.ts,src/core/dashboard-rows.ts,src/core/worker-pool.ts,src/core/session-manager.ts,src/daemon.ts: track per-generationlastScreenTurnIdand monotonic non-silent admission sequence (turnOrderSeq/lastNonSilentTurnSeq/silentScheduledTurnMeta), exposeactiveTurnSilentSchedule: trueviaisActiveTurnSilentSchedule()without clearingsilentScheduledTurns, guard against stale/terminated frames and Web Terminal direct submits, and publish SSEsession.updatepatches on transitions.Verification
npm run typecheck(passed)npx vitest run --project unit:test/antigravity-folded-turn-authority.test.ts(11 passed)test/antigravity-footer-background-tasks.test.ts(8 passed)test/silent-schedule-turns.test.ts(13 passed)test/background-wait-card.test.ts(44 passed)test/antigravity-idle-composer.test.ts(36 passed)test/antigravity-transcript.test.ts(36 passed)test/worker-terminal-authority-release.test.ts(26 passed)test/worker-turn-idle.test.ts(17 passed)test/dashboard-aggregator.test.ts(24 passed)