tumwater 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -13
- package/dist/build-info.json +2 -2
- package/dist/src/agent/agent-args.js +8 -9
- package/dist/src/agent/agent-backend.js +8 -6
- package/dist/src/agent/backend-traits.js +42 -25
- package/dist/src/agent/claude/claude-account.js +71 -204
- package/dist/src/agent/claude/claude-args.js +9 -6
- package/dist/src/agent/claude/claude-backend.js +10 -10
- package/dist/src/agent/claude/claude-env.js +1 -1
- package/dist/src/agent/claude/claude-stream.js +4 -3
- package/dist/src/agent/claude/claude-write-guard.js +49 -0
- package/dist/src/agent/claude/write-guard-hook.js +13 -0
- package/dist/src/agent/codex/codex-account.js +119 -0
- package/dist/src/agent/codex/codex-args.js +181 -0
- package/dist/src/agent/codex/codex-backend.js +279 -0
- package/dist/src/agent/codex/codex-catalog.js +97 -0
- package/dist/src/agent/codex/codex-env.js +18 -0
- package/dist/src/agent/codex/codex-hook-trust.js +246 -0
- package/dist/src/agent/codex/codex-patch-paths.js +36 -0
- package/dist/src/agent/codex/codex-rollout.js +179 -0
- package/dist/src/agent/codex/codex-stream.js +402 -0
- package/dist/src/agent/codex/codex-write-guard.js +86 -0
- package/dist/src/agent/codex/write-guard-hook.js +12 -0
- package/dist/src/agent/image-input.js +29 -24
- package/dist/src/agent/notes-shim.js +11 -12
- package/dist/src/agent/opencode/opencode-args.js +0 -1
- package/dist/src/agent/opencode/opencode-backend.js +12 -9
- package/dist/src/agent/opencode/opencode-catalog.js +55 -29
- package/dist/src/agent/opencode/opencode-config.js +19 -14
- package/dist/src/agent/opencode/opencode-env.js +0 -1
- package/dist/src/agent/opencode/opencode-session-id.js +1 -2
- package/dist/src/agent/opencode/opencode-stream.js +1 -1
- package/dist/src/agent/opencode/write-guard-plugin/index.js +48 -0
- package/dist/src/agent/role-notes-write.js +5 -6
- package/dist/src/agent/run-agent.js +465 -448
- package/dist/src/agent/run-settle.js +214 -0
- package/dist/src/agent/session-ledger.js +86 -16
- package/dist/src/agent/subscription-account.js +220 -0
- package/dist/src/agent/write-guard.js +148 -0
- package/dist/src/backlog/backlog-archive.js +246 -55
- package/dist/src/backlog/backlog-cli-view.js +280 -0
- package/dist/src/backlog/backlog-cli.js +85 -274
- package/dist/src/backlog/backlog-commit.js +4 -5
- package/dist/src/backlog/backlog-eligibility.js +175 -242
- package/dist/src/backlog/backlog-index.js +149 -0
- package/dist/src/backlog/backlog-md.js +54 -6
- package/dist/src/backlog/backlog-parts.js +254 -0
- package/dist/src/backlog/backlog-release.js +117 -0
- package/dist/src/backlog/backlog-render.js +27 -0
- package/dist/src/backlog/backlog-structure.js +99 -156
- package/dist/src/backlog/backlog-write.js +40 -127
- package/dist/src/backlog/backlog.js +21 -6
- package/dist/src/backlog/question-answer.js +21 -15
- package/dist/src/baseline/main-baseline.js +89 -20
- package/dist/src/baseline/main-culprit.js +94 -0
- package/dist/src/baseline/main-guardrails.js +209 -0
- package/dist/src/baseline/main-red.js +139 -32
- package/dist/src/baseline/main-revert.js +133 -0
- package/dist/src/baseline/main-watch.js +184 -0
- package/dist/src/brief/brief-edit.js +9 -11
- package/dist/src/brief/brief.js +31 -51
- package/dist/src/budget/budget.js +30 -20
- package/dist/src/budget/fallback-breaker.js +26 -27
- package/dist/src/build/build-check-detect.js +23 -15
- package/dist/src/build/build-check-events.js +25 -6
- package/dist/src/build/build-check-report.js +49 -9
- package/dist/src/build/build-check-scoped.js +18 -11
- package/dist/src/build/build-check.js +2 -1
- package/dist/src/build/build-info.js +2 -3
- package/dist/src/build/build-stage.js +9 -14
- package/dist/src/build/dep-install.js +1 -2
- package/dist/src/change/change-data.js +123 -31
- package/dist/src/change/change-render.js +46 -5
- package/dist/src/cli/brief-command.js +3 -4
- package/dist/src/cli/cli-args.js +118 -33
- package/dist/src/cli/cli-command-args.js +46 -18
- package/dist/src/cli/cli-editor.js +2 -1
- package/dist/src/cli/cli-flag-specs.js +150 -45
- package/dist/src/cli/cli-init.js +51 -0
- package/dist/src/cli/cli-marker-commands.js +4 -4
- package/dist/src/cli/cli-query-commands.js +308 -590
- package/dist/src/cli/cli-repo-gate.js +11 -1
- package/dist/src/cli/cli-role-command.js +420 -0
- package/dist/src/cli/cli-start-summary.js +160 -0
- package/dist/src/cli/{cli-run.js → cli-start.js} +165 -237
- package/dist/src/cli/completion.js +149 -22
- package/dist/src/cli/config-commands.js +41 -18
- package/dist/src/cli/follow-view.js +75 -0
- package/dist/src/cli/help.js +189 -73
- package/dist/src/cli/log-commands.js +148 -82
- package/dist/src/cli/question-commands.js +205 -10
- package/dist/src/cli.js +106 -43
- package/dist/src/collections.js +26 -10
- package/dist/src/concurrency/check-permit.js +20 -3
- package/dist/src/concurrency/lock.js +17 -13
- package/dist/src/concurrency/provider-lease.js +44 -8
- package/dist/src/concurrency/semaphore.js +102 -26
- package/dist/src/config/config-aliases.js +0 -1
- package/dist/src/config/config-editable-keys.js +13 -1
- package/dist/src/config/config-fallbacks.js +93 -56
- package/dist/src/config/config-field-checks.js +40 -10
- package/dist/src/config/config-keys.js +30 -8
- package/dist/src/config/config-live.js +63 -24
- package/dist/src/config/config-request.js +137 -0
- package/dist/src/config/config-schema.js +31 -24
- package/dist/src/config/config-selector-checks.js +123 -0
- package/dist/src/config/config-validation-agents.js +80 -0
- package/dist/src/config/config-validation-model.js +116 -0
- package/dist/src/config/config-validation.js +141 -199
- package/dist/src/config/config-views.js +127 -53
- package/dist/src/config/config-write-core.js +135 -0
- package/dist/src/config/config-write.js +131 -264
- package/dist/src/config/config.js +48 -38
- package/dist/src/config/model-selector.js +34 -34
- package/dist/src/doctor/doctor-backlog-bugs.js +287 -0
- package/dist/src/doctor/doctor-backlog-plans.js +263 -0
- package/dist/src/doctor/doctor-backlog.js +100 -496
- package/dist/src/doctor/doctor-check-names.js +81 -0
- package/dist/src/doctor/doctor-checks.js +52 -579
- package/dist/src/doctor/doctor-claude-checks.js +145 -0
- package/dist/src/doctor/doctor-codex-checks.js +279 -0
- package/dist/src/doctor/doctor-contention-checks.js +380 -0
- package/dist/src/doctor/doctor-holds.js +82 -66
- package/dist/src/doctor/doctor-install.js +2 -1
- package/dist/src/doctor/doctor-model-checks.js +236 -402
- package/dist/src/doctor/doctor-notify.js +3 -4
- package/dist/src/doctor/doctor-opencode-checks.js +162 -0
- package/dist/src/doctor/doctor-orphans.js +182 -63
- package/dist/src/doctor/doctor-project-checks.js +303 -0
- package/dist/src/doctor/doctor.js +121 -77
- package/dist/src/doctor/image-probe.js +21 -8
- package/dist/src/doctor/outcome.js +3 -2
- package/dist/src/doctor/probe.js +7 -11
- package/dist/src/events/event-format.js +181 -86
- package/dist/src/events/event-labels.js +12 -5
- package/dist/src/events/event-legacy.js +39 -15
- package/dist/src/events/event-read.js +39 -39
- package/dist/src/events/event-tally.js +16 -0
- package/dist/src/events/event-window.js +60 -24
- package/dist/src/events/events.js +30 -13
- package/dist/src/events/notify.js +7 -7
- package/dist/src/failure/failure-cluster.js +12 -12
- package/dist/src/failure/failure-data.js +56 -56
- package/dist/src/failure/failure-render.js +31 -23
- package/dist/src/failure/failure-state-change.js +17 -12
- package/dist/src/failure/time-spend.js +99 -35
- package/dist/src/files/files.js +111 -35
- package/dist/src/files/json-files.js +3 -3
- package/dist/src/files/json-object.js +28 -7
- package/dist/src/files/stat-cache.js +2 -2
- package/dist/src/files/tail.js +1 -1
- package/dist/src/gates/bootstrap-gates.js +4 -5
- package/dist/src/gates/budget-gates.js +177 -84
- package/dist/src/gates/disk-gate.js +1 -1
- package/dist/src/gates/gate-polls.js +108 -58
- package/dist/src/gates/maintenance-quota.js +10 -13
- package/dist/src/gates/pause-gates.js +28 -10
- package/dist/src/gates/readiness.js +7 -3
- package/dist/src/gates/role-cap-gates.js +8 -8
- package/dist/src/gates/startup-gate.js +94 -32
- package/dist/src/gates/streak-gate.js +54 -30
- package/dist/src/git/commit-message.js +77 -46
- package/dist/src/git/git-diff.js +16 -10
- package/dist/src/git/git-run.js +79 -38
- package/dist/src/git/git.js +36 -34
- package/dist/src/git/slot-salvage.js +253 -0
- package/dist/src/git/slots-state.js +6 -6
- package/dist/src/git/worktree-pool.js +132 -38
- package/dist/src/git/worktree-use.js +4 -11
- package/dist/src/git/worktree.js +94 -37
- package/dist/src/gui/gui-admin-endpoints.js +96 -0
- package/dist/src/gui/gui-args.js +79 -8
- package/dist/src/gui/gui-backlog-commands.js +42 -18
- package/dist/src/gui/gui-backlog-endpoints.js +155 -0
- package/dist/src/gui/gui-command.js +8 -13
- package/dist/src/gui/gui-config-commands.js +94 -72
- package/dist/src/gui/gui-endpoint-commands.js +4 -3
- package/dist/src/gui/gui-endpoint-common.js +4 -4
- package/dist/src/gui/gui-endpoints.js +11 -380
- package/dist/src/gui/gui-history-endpoints.js +301 -0
- package/dist/src/gui/gui-operator-commands.js +108 -13
- package/dist/src/gui/gui-prompt-commands.js +11 -14
- package/dist/src/gui/gui-report-endpoints.js +90 -0
- package/dist/src/gui/gui-server.js +11 -4
- package/dist/src/gui/gui-team-commands.js +7 -7
- package/dist/src/gui/http-body.js +1 -1
- package/dist/src/history/history-data.js +122 -234
- package/dist/src/history/history-queued.js +147 -0
- package/dist/src/history/history-render.js +42 -22
- package/dist/src/history/history.js +193 -49
- package/dist/src/inbox/inbox-attachments.js +29 -30
- package/dist/src/inbox/inbox-cancel.js +10 -11
- package/dist/src/inbox/inbox-edit.js +9 -9
- package/dist/src/inbox/inbox-submit.js +18 -18
- package/dist/src/inbox/inbox-top.js +25 -9
- package/dist/src/inbox/inbox.js +42 -43
- package/dist/src/inbox/pending-prompt.js +26 -26
- package/dist/src/inbox/prompt-commands.js +62 -49
- package/dist/src/inbox/prompt-not-before.js +2 -2
- package/dist/src/init/init-templates.js +1 -2
- package/dist/src/init/init.js +28 -23
- package/dist/src/merge/backlog-conflicts.js +215 -35
- package/dist/src/merge/merge-batch.js +14 -8
- package/dist/src/merge/merge-cancel.js +53 -0
- package/dist/src/merge/merge-check-failures.js +44 -22
- package/dist/src/merge/merge-core.js +81 -32
- package/dist/src/merge/merge-diff.js +5 -4
- package/dist/src/merge/merge-drain.js +150 -11
- package/dist/src/merge/merge-git.js +177 -38
- package/dist/src/merge/merge-pipeline.js +15 -3
- package/dist/src/merge/merge-post-review.js +90 -0
- package/dist/src/merge/merge-queue-render.js +49 -11
- package/dist/src/merge/merge-queue.js +31 -15
- package/dist/src/merge/merge-requeue.js +102 -0
- package/dist/src/merge/merge-slot.js +61 -16
- package/dist/src/merge/merge-stack.js +33 -11
- package/dist/src/merge/merge-to-main.js +86 -27
- package/dist/src/merge/merge-top.js +69 -0
- package/dist/src/merge/merge-verify.js +12 -10
- package/dist/src/notes-cli.js +30 -15
- package/dist/src/operator/operator-commands.js +192 -81
- package/dist/src/operator/operator-intent.js +69 -42
- package/dist/src/operator/operator-requests.js +35 -40
- package/dist/src/operator/retire.js +5 -6
- package/dist/src/operator/revert.js +142 -34
- package/dist/src/orchestrator/orchestrator-launch.js +60 -52
- package/dist/src/orchestrator/orchestrator-poll.js +320 -0
- package/dist/src/orchestrator/orchestrator-scheduling.js +68 -369
- package/dist/src/orchestrator/orchestrator.js +128 -369
- package/dist/src/orchestrator/retention.js +42 -8
- package/dist/src/orchestrator/scheduling-admit.js +116 -0
- package/dist/src/orchestrator/scheduling-scope.js +201 -0
- package/dist/src/orchestrator/scheduling-skip.js +185 -0
- package/dist/src/orchestrator/startup-migration-steps.js +8 -7
- package/dist/src/orchestrator/startup-migrations.js +11 -7
- package/dist/src/paths.js +116 -49
- package/dist/src/pi/command-shape.js +12 -1
- package/dist/src/pi/pi-args.js +6 -4
- package/dist/src/pi/pi-backend.js +6 -6
- package/dist/src/pi/pi-bin.js +54 -63
- package/dist/src/pi/pi-listed-models.js +53 -0
- package/dist/src/pi/pi-models.js +63 -30
- package/dist/src/pi/pi-run-result.js +1 -1
- package/dist/src/pi/pi-settings.js +1 -1
- package/dist/src/pi/pi-stream.js +6 -6
- package/dist/src/pi/pi-watchdogs.js +18 -19
- package/dist/src/pi-extension/bounded-output.js +5 -3
- package/dist/src/pi-extension/context-budget.js +2 -2
- package/dist/src/pi-extension/context-shake.js +1 -1
- package/dist/src/pi-extension/context-window.js +0 -1
- package/dist/src/pi-extension/full-output.js +3 -10
- package/dist/src/pi-extension/strip-thinking.js +0 -1
- package/dist/src/pi-extension/trim-system-prompt.js +3 -4
- package/dist/src/pi-extension/write-guard.js +37 -0
- package/dist/src/process/launch-services.js +1 -2
- package/dist/src/process/node-bin.js +16 -0
- package/dist/src/process/process-group.js +8 -18
- package/dist/src/process/process.js +41 -2
- package/dist/src/process/run-marker.js +18 -6
- package/dist/src/process/supervisor.js +22 -21
- package/dist/src/prompt/dialect.js +17 -2
- package/dist/src/prompt/gate-notes.js +203 -0
- package/dist/src/prompt/gate-prompts.js +121 -211
- package/dist/src/prompt/notes-backlog.js +181 -0
- package/dist/src/prompt/principles.js +1 -2
- package/dist/src/prompt/prompt-followup.js +19 -14
- package/dist/src/prompt/prompt.js +129 -204
- package/dist/src/redeploy/redeploy-policy.js +24 -19
- package/dist/src/redeploy/redeploy-probes.js +1 -1
- package/dist/src/redeploy/redeploy.js +2 -3
- package/dist/src/redeploy/redeployer.js +20 -20
- package/dist/src/redeploy/self-reload.js +2 -1
- package/dist/src/report/report-data.js +161 -77
- package/dist/src/report/report-fold.js +129 -52
- package/dist/src/report/report-main-red.js +55 -0
- package/dist/src/report/report-render.js +133 -64
- package/dist/src/report/report-types.js +1 -0
- package/dist/src/report/report.js +26 -9
- package/dist/src/request-timeouts.js +2 -2
- package/dist/src/review/known-flakes.js +100 -1
- package/dist/src/review/post-merge-review.js +106 -0
- package/dist/src/review/protected-edits.js +4 -5
- package/dist/src/review/review-followup.js +8 -8
- package/dist/src/review/review-precheck.js +66 -23
- package/dist/src/review/review-run.js +395 -0
- package/dist/src/review/review-verdict.js +2 -2
- package/dist/src/review/review.js +155 -360
- package/dist/src/review/secret-leaks.js +36 -16
- package/dist/src/review/suite-rerun.js +0 -1
- package/dist/src/roles/legacy-role-migration.js +80 -7
- package/dist/src/roles/role-catalog.js +69 -12
- package/dist/src/roles/role-guidance.js +55 -20
- package/dist/src/roles/role-labels.js +1 -2
- package/dist/src/roles/role-render.js +67 -50
- package/dist/src/roles/role-view.js +59 -47
- package/dist/src/roles/roles.js +31 -31
- package/dist/src/roles/runner-ids.js +97 -0
- package/dist/src/run/acceptance-greps.js +119 -0
- package/dist/src/run/feedback-filings.js +51 -0
- package/dist/src/{tick → run}/qa-coverage.js +9 -27
- package/dist/src/{tick/tick-apply.js → run/run-apply.js} +95 -94
- package/dist/src/run/run-detail-data.js +179 -0
- package/dist/src/run/run-detail-render.js +98 -0
- package/dist/src/run/run-detail.js +168 -0
- package/dist/src/{tick/tick-finalize.js → run/run-finalize.js} +72 -60
- package/dist/src/{tick/tick-outcome.js → run/run-outcome.js} +6 -7
- package/dist/src/{tick/tick-prompt.js → run/run-prompt.js} +108 -73
- package/dist/src/{tick/tick-resume.js → run/run-resume.js} +55 -26
- package/dist/src/{tick/tick-stage.js → run/run-stage.js} +108 -50
- package/dist/src/{tick/tick-timing.js → run/run-timing.js} +43 -41
- package/dist/src/{tick/tick-usage.js → run/run-usage.js} +45 -37
- package/dist/src/{tick/tick-verdict.js → run/run-verdict.js} +91 -56
- package/dist/src/run/selfcheck-digest.js +40 -0
- package/dist/src/run/stage-backlog-checks.js +249 -0
- package/dist/src/run/stage-check.js +172 -0
- package/dist/src/run/stage-path-checks.js +730 -0
- package/dist/src/{loop → runner}/leftover.js +80 -25
- package/dist/src/{loop → runner}/model-fallback.js +12 -12
- package/dist/src/runner/revision.js +202 -0
- package/dist/src/{loop/loop-fallback.js → runner/runner-fallback.js} +8 -8
- package/dist/src/runner/runner-outcome.js +107 -0
- package/dist/src/{loop/loop-pi.js → runner/runner-pi.js} +140 -131
- package/dist/src/{loop/loop-recovery.js → runner/runner-recovery.js} +21 -15
- package/dist/src/{loop/loop-tick.js → runner/runner-run.js} +218 -240
- package/dist/src/{loop/loop-state.js → runner/runner-state-load.js} +61 -114
- package/dist/src/runner/runner-state.js +102 -0
- package/dist/src/{loop/loop.js → runner/runner.js} +123 -120
- package/dist/src/scheduling/backoff.js +38 -38
- package/dist/src/scheduling/claims.js +35 -22
- package/dist/src/scheduling/once-round.js +22 -22
- package/dist/src/scheduling/quiet-hours.js +5 -6
- package/dist/src/scheduling/scheduling.js +74 -64
- package/dist/src/scheduling/work-merged-cache.js +2 -2
- package/dist/src/status/status-budget.js +55 -47
- package/dist/src/status/status-data.js +43 -16
- package/dist/src/status/status-inbox.js +2 -2
- package/dist/src/status/status-install.js +0 -1
- package/dist/src/status/status-polls.js +28 -28
- package/dist/src/status/status-roles.js +39 -13
- package/dist/src/team/error-storm.js +8 -8
- package/dist/src/team/failure-spread.js +2 -2
- package/dist/src/team/orchestrator-info.js +15 -9
- package/dist/src/team/reclaim.js +5 -6
- package/dist/src/team/team-hold.js +7 -7
- package/dist/src/team/team-polls.js +91 -50
- package/dist/src/team/team-state.js +8 -2
- package/dist/src/text/datetime.js +63 -17
- package/dist/src/text/format.js +48 -11
- package/dist/src/text/markdown.js +8 -5
- package/dist/src/text/phrases.js +57 -23
- package/dist/src/text/suggest.js +1 -1
- package/dist/src/text/text.js +67 -13
- package/dist/src/ui/badges.js +65 -37
- package/dist/src/ui/gui/gui-client-backlog.js +292 -0
- package/dist/src/ui/gui/gui-client-boot.js +32 -26
- package/dist/src/ui/gui/gui-client-composer.js +8 -9
- package/dist/src/ui/gui/gui-client-drawer-config.js +212 -0
- package/dist/src/ui/gui/gui-client-drawer.js +126 -285
- package/dist/src/ui/gui/gui-client-feed.js +271 -0
- package/dist/src/ui/gui/gui-client-history.js +434 -67
- package/dist/src/ui/gui/gui-client-labels.js +1 -2
- package/dist/src/ui/gui/gui-client-markdown.js +1 -2
- package/dist/src/ui/gui/gui-client-model.js +27 -36
- package/dist/src/ui/gui/gui-client-operator.js +55 -51
- package/dist/src/ui/gui/gui-client-pending.js +227 -23
- package/dist/src/ui/gui/gui-client-report-chart.js +464 -0
- package/dist/src/ui/gui/gui-client-report.js +87 -427
- package/dist/src/ui/gui/{gui-client-loops.js → gui-client-roles.js} +43 -44
- package/dist/src/ui/gui/gui-client-settings.js +56 -4
- package/dist/src/ui/gui/gui-client-team.js +25 -465
- package/dist/src/ui/gui/gui-client.js +27 -25
- package/dist/src/ui/gui/gui-icons.js +0 -2
- package/dist/src/ui/gui/gui-page.js +9 -7
- package/dist/src/ui/gui/gui-styles.js +34 -34
- package/dist/src/ui/progress-data.js +9 -11
- package/dist/src/ui/{tick-progress-model.js → run-progress-model.js} +31 -31
- package/dist/src/ui/status-model.js +133 -125
- package/dist/src/ui/status-payload.js +136 -49
- package/dist/src/ui/status-render.js +101 -82
- package/dist/src/ui/team-alerts.js +248 -57
- package/dist/src/ui/tone.js +5 -6
- package/dist/src/ui/transcript-run.js +58 -0
- package/dist/src/ui/transcript-tail.js +28 -20
- package/dist/src/ui/transcript.js +63 -23
- package/dist/src/ui/tui/tui-app.js +0 -1
- package/dist/src/ui/tui/tui-backlog.js +51 -14
- package/dist/src/ui/tui/tui-editor-answer.js +27 -31
- package/dist/src/ui/tui/tui-editor-attach.js +3 -5
- package/dist/src/ui/tui/tui-editor-backends.js +132 -0
- package/dist/src/ui/tui/tui-editor-brief.js +10 -12
- package/dist/src/ui/tui/tui-editor-budget.js +35 -31
- package/dist/src/ui/tui/tui-editor-claude-reserve.js +24 -0
- package/dist/src/ui/tui/tui-editor-concurrency.js +24 -0
- package/dist/src/ui/tui/tui-editor-config.js +86 -0
- package/dist/src/ui/tui/tui-editor-entry.js +36 -47
- package/dist/src/ui/tui/tui-editor-fallback.js +31 -0
- package/dist/src/ui/tui/tui-editor-instances.js +37 -0
- package/dist/src/ui/tui/tui-editor-instructions.js +136 -0
- package/dist/src/ui/tui/tui-editor-interval.js +11 -9
- package/dist/src/ui/tui/tui-editor-model.js +29 -0
- package/dist/src/ui/tui/tui-editor-notes.js +3 -5
- package/dist/src/ui/tui/tui-editor-notify.js +25 -0
- package/dist/src/ui/tui/tui-editor-pause.js +48 -59
- package/dist/src/ui/tui/tui-editor-prompt.js +11 -16
- package/dist/src/ui/tui/tui-editor-provider-caps.js +27 -0
- package/dist/src/ui/tui/tui-editor-queued.js +5 -9
- package/dist/src/ui/tui/tui-editor-quiet.js +99 -35
- package/dist/src/ui/tui/tui-editor-retire.js +4 -6
- package/dist/src/ui/tui/tui-editor-role-key.js +76 -0
- package/dist/src/ui/tui/tui-editor-role-model.js +28 -0
- package/dist/src/ui/tui/tui-editor-search.js +45 -33
- package/dist/src/ui/tui/tui-editor-session.js +60 -34
- package/dist/src/ui/tui/tui-editor-slots.js +23 -0
- package/dist/src/ui/tui/tui-editors.js +35 -2
- package/dist/src/ui/tui/tui-frame.js +56 -11
- package/dist/src/ui/tui/tui-history.js +8 -9
- package/dist/src/ui/tui/tui-input.js +13 -11
- package/dist/src/ui/tui/tui-keymap.js +0 -1
- package/dist/src/ui/tui/tui-keys.js +24 -9
- package/dist/src/ui/tui/tui-pane-activity.js +14 -11
- package/dist/src/ui/tui/tui-pane-backlog.js +171 -126
- package/dist/src/ui/tui/tui-pane-brief.js +0 -1
- package/dist/src/ui/tui/tui-pane-ctx.js +2 -2
- package/dist/src/ui/tui/tui-pane-health.js +58 -8
- package/dist/src/ui/tui/tui-pane-history.js +402 -82
- package/dist/src/ui/tui/tui-pane-pending.js +308 -13
- package/dist/src/ui/tui/tui-pane-queued.js +71 -55
- package/dist/src/ui/tui/tui-pane-report.js +46 -14
- package/dist/src/ui/tui/tui-pane-session.js +25 -6
- package/dist/src/ui/tui/tui-pane-transcript.js +111 -37
- package/dist/src/ui/tui/tui-pane.js +80 -23
- package/dist/src/ui/tui/tui-panes.js +100 -30
- package/dist/src/ui/tui/tui.js +14 -14
- package/dist/src/verdict/fix-claim.js +82 -32
- package/dist/src/verdict/no-change.js +4 -4
- package/dist/src/verdict/refusal.js +40 -16
- package/dist/src/verdict/reply-contract.js +42 -31
- package/dist/src/version.js +0 -1
- package/package.json +2 -1
- package/dist/src/loop/revision.js +0 -70
- package/dist/src/roles/loop-ids.js +0 -77
- package/dist/src/tick/stage-check.js +0 -419
- package/dist/src/tick/telemetry-digest.js +0 -25
- package/dist/src/tick/tick-detail-data.js +0 -108
- package/dist/src/tick/tick-detail.js +0 -163
- package/dist/src/ui/gui/gui-client-sound.js +0 -53
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { APPROVED_PATCH_IDS_MAX, REVIEW_RESUME_LIMIT, saveRunnerStateBestEffort } from "../runner/runner-state.js";
|
|
2
|
+
import { modelSelectorField, resolvedBackendConfig, reviewRunConfig } from "../config/config-views.js";
|
|
3
|
+
import { logEventBestEffort, warnEventBestEffort } from "../events/events.js";
|
|
4
|
+
import { git } from "../git/git-run.js";
|
|
5
|
+
import { changeBaseRev, headOf } from "../git/git.js";
|
|
6
|
+
import { aheadOfMainDiff, revisionInterdiff } from "../git/git-diff.js";
|
|
7
|
+
import { resetWorktreeToMain } from "../git/worktree.js";
|
|
8
|
+
import { nativeLogPath, piLogPath } from "../paths.js";
|
|
9
|
+
import { readPrinciples } from "../prompt/principles.js";
|
|
10
|
+
import { buildReviewPrompt, buildReviewResumePrompt } from "../prompt/gate-prompts.js";
|
|
11
|
+
import { backendSessionResumable } from "../agent/agent-backend.js";
|
|
12
|
+
import { requestNoRerun, requestVerdict } from "./review-followup.js";
|
|
13
|
+
import { parseVerdict } from "./review-verdict.js";
|
|
14
|
+
import { recordReview } from "../run/run-apply.js";
|
|
15
|
+
import { shortSha } from "../text/format.js";
|
|
16
|
+
import { suiteRerunWarning } from "./suite-rerun.js";
|
|
17
|
+
import { setMergeStage } from "../merge/merge-slot.js";
|
|
18
|
+
/** Attach the review gate's pi runs onto a partial GateResult — `run` plus the optional
|
|
19
|
+
* verdict-recovery follow-up (`followUpRun`) and no-re-run nudge (`nudgeRun`) fields, each
|
|
20
|
+
* present only when its turn actually ran. Spelled once so every return site of
|
|
21
|
+
* reviewAheadOfMain that carries runs shares one shape for the usage-folding caller
|
|
22
|
+
* (merge-core.ts folds run, then followUpRun, then nudgeRun), instead of one conditional
|
|
23
|
+
* spread per site that a new run kind would have to update everywhere. */
|
|
24
|
+
export function withRuns(r, run, followUp, nudge) {
|
|
25
|
+
return {
|
|
26
|
+
...r,
|
|
27
|
+
run,
|
|
28
|
+
...(followUp ? { followUpRun: followUp } : {}),
|
|
29
|
+
...(nudge ? { nudgeRun: nudge } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Put the worktree back on the exact head the gate reviewed: the reviewer's only output is its
|
|
33
|
+
* verdict, so a commit it made must never reach the merge pin or the next re-review. */
|
|
34
|
+
export async function restoreReviewedHead(wt, head, root, role) {
|
|
35
|
+
const now = await headOf(wt, "HEAD").catch(() => null);
|
|
36
|
+
if (now && now !== head) {
|
|
37
|
+
warnEventBestEffort(root, role, `the reviewer moved HEAD to ${shortSha(now)} during review; restored the reviewed head ${shortSha(head)}`);
|
|
38
|
+
}
|
|
39
|
+
await git(wt, "reset", "--hard", head);
|
|
40
|
+
}
|
|
41
|
+
/** Consecutive failed reviews of one branch HEAD after which the leftover is discarded with
|
|
42
|
+
* a warning: a misconfigured reviewer model must not be able to wedge a role into re-reviewing
|
|
43
|
+
* the same commit forever. */
|
|
44
|
+
export const REVIEW_FAILURE_LIMIT = 3;
|
|
45
|
+
function combineSignals(a, b) {
|
|
46
|
+
return a ? AbortSignal.any([a, b]) : b;
|
|
47
|
+
}
|
|
48
|
+
/** The reviewer run: resume-vs-fresh session choice, prompt, run, follow-up turns, verdict parse
|
|
49
|
+
* and the approve/reject bookkeeping. Called by reviewAttempt once the deterministic gate has
|
|
50
|
+
* passed the change on to a reviewer. */
|
|
51
|
+
export async function runReviewer(ctx, state, input) {
|
|
52
|
+
const { root, role, wt, mainBranch, config } = ctx;
|
|
53
|
+
const { head, reviewedPatchId, overlap, knownMainFailures, retry, summary, commitBody, highFriction } = input;
|
|
54
|
+
const { reject, keep, settleFailedCheck } = input;
|
|
55
|
+
// The reviewer's model selector (plans/model-tiers.md "Observability"): resolved from the
|
|
56
|
+
// same config the run below gets, so the event names what the reviewer actually runs on —
|
|
57
|
+
// the budget fallback included. Omitted when no model is configured (pi's own default).
|
|
58
|
+
const reviewCfg = reviewRunConfig(config);
|
|
59
|
+
// The team claude config dir (plans/notes-command.md "Keeping funes out of team runs"), so
|
|
60
|
+
// a claude review's resume guard looks under the same dir the review run writes its transcript
|
|
61
|
+
// to — a team that set one must resume under it, not the default ~/.claude.
|
|
62
|
+
const claudeConfigDir = resolvedBackendConfig(config, "claude").configDir;
|
|
63
|
+
// A progressing timeout left this run's session for the next attempt (RunnerState.reviewResume):
|
|
64
|
+
// resume it only while the patch is unchanged (the same diff), the resume budget lasts, and
|
|
65
|
+
// the directory still holds a gate session to `--continue`. Otherwise the stale marker is
|
|
66
|
+
// cleared and this attempt reviews the change from scratch.
|
|
67
|
+
const priorResume = state.reviewResume;
|
|
68
|
+
const resuming = priorResume !== undefined &&
|
|
69
|
+
priorResume.patchId === reviewedPatchId &&
|
|
70
|
+
priorResume.attempts < REVIEW_RESUME_LIMIT &&
|
|
71
|
+
backendSessionResumable(priorResume.sessionDir, {
|
|
72
|
+
kind: "gate",
|
|
73
|
+
agent: reviewCfg.agent ?? "pi",
|
|
74
|
+
}, claudeConfigDir);
|
|
75
|
+
if (resuming) {
|
|
76
|
+
// Count the resume before the run: a crash must not let the same session be resumed
|
|
77
|
+
// forever without ever spending the budget.
|
|
78
|
+
priorResume.attempts += 1;
|
|
79
|
+
saveRunnerStateBestEffort(root, state);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
state.reviewResume = undefined;
|
|
83
|
+
}
|
|
84
|
+
// The directory this run actually uses: a resumed attempt continues the timed-out run's
|
|
85
|
+
// session, a fresh one its own. Both the run and its follow-up turns must target this dir —
|
|
86
|
+
// a follow-up that used ctx.sessionDir while the review resumed another dir would
|
|
87
|
+
// `--continue` a session that never held this review.
|
|
88
|
+
const reviewSessionDir = resuming ? state.reviewResume.sessionDir : ctx.sessionDir;
|
|
89
|
+
// The follow-up turns (verdict recovery, no-re-run nudge) continue the just-finished review,
|
|
90
|
+
// so they must read the same directory. A fresh run's dir is already ctx's, so only a resume
|
|
91
|
+
// needs the override.
|
|
92
|
+
const followupCtx = reviewSessionDir === ctx.sessionDir ? ctx : { ...ctx, sessionDir: reviewSessionDir };
|
|
93
|
+
logEventBestEffort(root, {
|
|
94
|
+
source: role,
|
|
95
|
+
type: "review_start",
|
|
96
|
+
head,
|
|
97
|
+
...(ctx.revisionRound !== undefined ? { revision: ctx.revisionRound } : {}),
|
|
98
|
+
...(resuming ? { resumed: true } : {}),
|
|
99
|
+
...modelSelectorField(reviewCfg),
|
|
100
|
+
});
|
|
101
|
+
// Persist the phase BEFORE the run so a dashboard mid-review shows "reviewing" and a crash
|
|
102
|
+
// mid-review is distinguishable from a crash mid-author-run on resume (stray edits are the
|
|
103
|
+
// reviewer's then, not the author's). Cleared at run end alongside `running`.
|
|
104
|
+
state.phase = "review";
|
|
105
|
+
saveRunnerStateBestEffort(root, state);
|
|
106
|
+
// Freeze the revision the diff is measured from once, before the run: main moves while a
|
|
107
|
+
// merge is approved, and a reviewer comparing against the live `main` ref reads another role's
|
|
108
|
+
// just-merged work as this change reverting it (BUGS.md 2026-10-06). The prompt names this SHA
|
|
109
|
+
// and tells the reviewer to compare against it instead.
|
|
110
|
+
const base = await changeBaseRev(wt, mainBranch);
|
|
111
|
+
const diff = await aheadOfMainDiff(wt, mainBranch);
|
|
112
|
+
// A revision's re-review gets the prior review's objections and the interdiff between the two
|
|
113
|
+
// versions (plans/revise-rejected.md part 2/2), so it checks what the revision had to resolve
|
|
114
|
+
// instead of starting from no memory. A missing prior object yields an empty interdiff, never
|
|
115
|
+
// a throw (revisionInterdiff).
|
|
116
|
+
const priorReview = ctx.priorReview
|
|
117
|
+
? {
|
|
118
|
+
round: ctx.revisionRound ?? 1,
|
|
119
|
+
reasons: ctx.priorReview.reasons,
|
|
120
|
+
interdiff: await revisionInterdiff(wt, mainBranch, ctx.priorReview.sha, head),
|
|
121
|
+
}
|
|
122
|
+
: undefined;
|
|
123
|
+
// The reviewer run's wall time rides on its verdict event: a reviewer that takes an hour per
|
|
124
|
+
// merge on local hardware is a team-level cost an operator must be able to see.
|
|
125
|
+
const reviewStartedAt = Date.now();
|
|
126
|
+
// The reviewer's started tool calls: the no-re-run rule always stands (tumwater runs the
|
|
127
|
+
// check), so the suite-rerun tripwire below always applies.
|
|
128
|
+
const reviewerCalls = [];
|
|
129
|
+
// The merge cell switches to the reviewer run's live detail (no-op outside a queued
|
|
130
|
+
// merge). runPi writes the run's `tumwater_run` label line before spawning pi, and that
|
|
131
|
+
// line resets the gate progress accumulator, so the cell never shows a previous run's counts.
|
|
132
|
+
setMergeStage(root, role, overlap ? "reviewing-check" : "reviewing");
|
|
133
|
+
// A check that already went red has aborted the overlap: no reviewer run starts, the verdict
|
|
134
|
+
// below is the gate's alone.
|
|
135
|
+
if (overlap?.abort.signal.aborted)
|
|
136
|
+
return settleFailedCheck(overlap, await overlap.gate);
|
|
137
|
+
// The author's claimed WHY/RISK/VERIFIED ride along when present — checking those claims
|
|
138
|
+
// against the actual diff is exactly the adversarial angle (recovery merges reconstruct
|
|
139
|
+
// them from the pinned commit's message).
|
|
140
|
+
const pi = await ctx.runGatePi({
|
|
141
|
+
cwd: wt,
|
|
142
|
+
kind: "gate",
|
|
143
|
+
prompt: resuming
|
|
144
|
+
? buildReviewResumePrompt(base, state.reviewResume.patchId)
|
|
145
|
+
: buildReviewPrompt(diff, summary, commitBody, readPrinciples(root), highFriction, base, undefined, priorReview, knownMainFailures),
|
|
146
|
+
// The reviewer runs on its own time budget (review.timeoutSeconds), never longer than a
|
|
147
|
+
// run's: a timed-out review is a FAILED run (pi.ok false), so it takes the dead-backend
|
|
148
|
+
// path below — commit kept, no strike — and re-merges through the author's next run
|
|
149
|
+
// instead of holding the merge queue for a whole authoring run.
|
|
150
|
+
config: reviewCfg,
|
|
151
|
+
// This run's own session directory (per-run, keyed by run and pinned sha): a follow-up
|
|
152
|
+
// turn, or a later attempt that resumes this review, continues exactly this run instead
|
|
153
|
+
// of whichever review wrote last. A fresh review carries no --continue — the reviewer
|
|
154
|
+
// must not inherit the author's context — and old files are collected by the age-based
|
|
155
|
+
// prune at orchestrator start.
|
|
156
|
+
sessionDir: reviewSessionDir,
|
|
157
|
+
...(resuming ? { continueSession: true } : {}),
|
|
158
|
+
sessionName: `tumwater-review-${role}-${ctx.runNumber}`,
|
|
159
|
+
rawLogFile: piLogPath(root, role),
|
|
160
|
+
nativeLogFile: nativeLogPath(root, role, reviewCfg.agent ?? "pi"),
|
|
161
|
+
// Label this run in the shared transcript (src/ui/transcript.ts renders it as
|
|
162
|
+
// `── review @ <ts> ──`) so an operator can tell reviewer runs from author runs.
|
|
163
|
+
label: "review",
|
|
164
|
+
signal: overlap ? combineSignals(ctx.signal, overlap.abort.signal) : ctx.signal,
|
|
165
|
+
// A stalled tool call during review hangs the gate just like one during authoring —
|
|
166
|
+
// name it in the event feed while the quiet watchdog still counts down.
|
|
167
|
+
onToolCallStalled: (message) => warnEventBestEffort(root, role, message),
|
|
168
|
+
onToolCallStart: (toolName, args) => {
|
|
169
|
+
reviewerCalls.push({ toolName, args });
|
|
170
|
+
},
|
|
171
|
+
// A gate run that read an image its model cannot see is logged, not killed (plans/
|
|
172
|
+
// image-input.md "Detecting a blind read"): the reviewer keeps working from what it CAN
|
|
173
|
+
// see, and the image_blind line names the file, the model, and this run so the operator
|
|
174
|
+
// knows the diff was judged under a blind read.
|
|
175
|
+
onBlindRead: (path, action) => logEventBestEffort(root, {
|
|
176
|
+
source: role,
|
|
177
|
+
type: "image_blind",
|
|
178
|
+
run: ctx.runNumber,
|
|
179
|
+
path,
|
|
180
|
+
model: reviewCfg.model,
|
|
181
|
+
action,
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
// A reviewer told the pre-check passed that re-ran the full suite anyway held the merge
|
|
185
|
+
// slot and loaded the shared host for a result the harness already had (BUGS.md 2026-09-23:
|
|
186
|
+
// scratch copies under /tmp, `npm ci` and `npm test` there). Warned on every outcome, abort
|
|
187
|
+
// included — the run happened either way; the verdict itself is not touched.
|
|
188
|
+
const rerun = suiteRerunWarning(reviewerCalls);
|
|
189
|
+
if (rerun)
|
|
190
|
+
warnEventBestEffort(root, role, rerun);
|
|
191
|
+
// Join the overlapped check (Fast merge part 12): a gate that did not pass settles the attempt;
|
|
192
|
+
// a green gate lets the reviewer's outcome stand, and a reviewer that finished first waited
|
|
193
|
+
// here for the gate.
|
|
194
|
+
if (overlap) {
|
|
195
|
+
if (!overlap.done)
|
|
196
|
+
setMergeStage(root, role, "build-check");
|
|
197
|
+
const pre = await overlap.gate;
|
|
198
|
+
if (pre.resolved)
|
|
199
|
+
return settleFailedCheck(overlap, pre, pi);
|
|
200
|
+
retry.pre = { verifiedHead: pre.verifiedHead, knownMainFailures: pre.knownMainFailures };
|
|
201
|
+
}
|
|
202
|
+
const verifiedHead = retry.pre?.verifiedHead;
|
|
203
|
+
if (pi.aborted) {
|
|
204
|
+
// Shutdown mid-review: fail closed — the commit stays on the branch and the
|
|
205
|
+
// resumed/following run re-reviews it via the combined ahead-of-main diff. Any resume
|
|
206
|
+
// marker from an earlier attempt is dropped: an abort says nothing about the diff, and the
|
|
207
|
+
// next attempt starts clean rather than inheriting a half-counted session.
|
|
208
|
+
state.reviewResume = undefined;
|
|
209
|
+
return keep(withRuns({ decision: "failed", aborted: true }, pi, null, null));
|
|
210
|
+
}
|
|
211
|
+
// The bounded nudge (BUGS.md 2026-10-02): the reviewer broke the no-re-run rule despite a
|
|
212
|
+
// green pre-check, so one turn on its own session names the call and asks it to finish
|
|
213
|
+
// without re-running. A repeat on the nudge's own tool calls fails the review — strike-free,
|
|
214
|
+
// commit kept, re-reviewed under the normal path — instead of paying a third suite run.
|
|
215
|
+
let nudge = null;
|
|
216
|
+
let nudgeRepeat = null;
|
|
217
|
+
if (rerun && pi.ok) {
|
|
218
|
+
const nudgeCalls = [];
|
|
219
|
+
nudge = await requestNoRerun(followupCtx, rerun, nudgeCalls);
|
|
220
|
+
if (nudge?.aborted) {
|
|
221
|
+
return keep(withRuns({ decision: "failed", aborted: true }, pi, null, nudge));
|
|
222
|
+
}
|
|
223
|
+
nudgeRepeat = nudge ? (suiteRerunWarning(nudgeCalls) ?? null) : null;
|
|
224
|
+
if (nudgeRepeat) {
|
|
225
|
+
warnEventBestEffort(root, role, `${nudgeRepeat} the repeat fails this review: the commit stays, and the merge re-reviews it without a third suite run`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
let verdict = parseVerdict(pi.verdictText ?? "");
|
|
229
|
+
// The nudge turn's reply can carry the verdict the review run lost — use it before spending
|
|
230
|
+
// any other recovery turn, but never on a repeat (the repeat fails the review regardless).
|
|
231
|
+
if (!verdict && nudge && !nudgeRepeat) {
|
|
232
|
+
const recovered = parseVerdict(nudge.verdictText ?? "");
|
|
233
|
+
if (recovered) {
|
|
234
|
+
verdict = recovered;
|
|
235
|
+
warnEventBestEffort(root, role, "the reviewer's reply had no VERDICT line — recovered it with the no-re-run nudge turn on its session");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// A run that FAILED (`ok` false: transport error, failed spawn, timeout) produced no reply,
|
|
239
|
+
// so no follow-up is attempted — it is evidence about the backend, and the strike-free
|
|
240
|
+
// branch below keeps it that way (BUGS.md 2026-09-20). Only a run that completed and
|
|
241
|
+
// replied without a parseable VERDICT earns the recovery turn: that is evidence about the
|
|
242
|
+
// reviewer's output format, not about the diff, and it is as recoverable as the author
|
|
243
|
+
// side's missing SUMMARY (BUGS.md 2026-09-29). The nudge turn is the bounded follow-up when
|
|
244
|
+
// the reviewer broke the no-re-run rule — one turn total, so a spent nudge never earns the
|
|
245
|
+
// verdict-recovery turn on top.
|
|
246
|
+
let followUp = null;
|
|
247
|
+
if (!verdict && pi.ok && !nudge) {
|
|
248
|
+
followUp = await requestVerdict(followupCtx);
|
|
249
|
+
if (followUp?.aborted)
|
|
250
|
+
return keep(withRuns({ decision: "failed", aborted: true }, pi, followUp, nudge));
|
|
251
|
+
const recovered = followUp ? parseVerdict(followUp.verdictText ?? "") : null;
|
|
252
|
+
if (recovered) {
|
|
253
|
+
verdict = recovered;
|
|
254
|
+
warnEventBestEffort(root, role, "the reviewer's reply had no VERDICT line — recovered it with a follow-up turn on its own session");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// A repeat after the nudge (BUGS.md 2026-10-02): the reviewer re-ran the suite on the nudge
|
|
258
|
+
// turn too. Fail the review — strike-free like a dead backend (BUGS.md 2026-09-20): the
|
|
259
|
+
// commit stays for the next merge's re-review, the discard counter never advances, and no
|
|
260
|
+
// rejection is recorded against the author's diff.
|
|
261
|
+
if (nudgeRepeat) {
|
|
262
|
+
const message = `${nudgeRepeat} The review is failed on this repeat: the commit is kept, and the merge re-reviews it under the normal path.`;
|
|
263
|
+
logEventBestEffort(root, { source: role, type: "review_failed", head, message, attempt: retry.attempt, durationMs: Date.now() - reviewStartedAt });
|
|
264
|
+
state.reviewResume = undefined;
|
|
265
|
+
recordReview(state, "failed", [message], head);
|
|
266
|
+
return keep(withRuns({ decision: "failed", detail: message }, pi, followUp, nudge));
|
|
267
|
+
}
|
|
268
|
+
if (!verdict) {
|
|
269
|
+
return settleUnparsedReview(ctx, state, input, {
|
|
270
|
+
pi, followUp, nudge, resuming, reviewSessionDir, reviewStartedAt, reviewCfg, claudeConfigDir,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (verdict.verdict === "reject") {
|
|
274
|
+
const rejected = await reject(verdict.reasons, Date.now() - reviewStartedAt);
|
|
275
|
+
return withRuns({ ...rejected }, pi, followUp, nudge);
|
|
276
|
+
}
|
|
277
|
+
// Approve: record the reviewed HEAD and discard any stray working-tree edits the reviewer
|
|
278
|
+
// made while reading around — its only output channel is the verdict. The patch-id keys the
|
|
279
|
+
// approval to the diff it judged; unreadable, it is not remembered.
|
|
280
|
+
state.lastApprovedHead = head;
|
|
281
|
+
if (reviewedPatchId !== undefined) {
|
|
282
|
+
const kept = (state.approvedPatchIds ?? []).filter((id) => id !== reviewedPatchId);
|
|
283
|
+
state.approvedPatchIds = [...kept, reviewedPatchId].slice(-APPROVED_PATCH_IDS_MAX);
|
|
284
|
+
}
|
|
285
|
+
state.reviewResume = undefined;
|
|
286
|
+
recordReview(state, "approve", verdict.reasons, head);
|
|
287
|
+
state.unreviewFailures = 0;
|
|
288
|
+
await restoreReviewedHead(wt, head, root, role);
|
|
289
|
+
logEventBestEffort(root, {
|
|
290
|
+
source: role,
|
|
291
|
+
type: "review_verdict",
|
|
292
|
+
head,
|
|
293
|
+
reason: verdict.reasons[0],
|
|
294
|
+
durationMs: Date.now() - reviewStartedAt,
|
|
295
|
+
});
|
|
296
|
+
return withRuns({ decision: "approved", verifiedHead }, pi, followUp, nudge);
|
|
297
|
+
}
|
|
298
|
+
/** Settle a review that produced no verdict: a dead backend keeps the commit (strike-free, retried
|
|
299
|
+
* in place while retries last), a reply that stayed unparseable counts a strike per HEAD and
|
|
300
|
+
* discards the leftover at REVIEW_FAILURE_LIMIT. */
|
|
301
|
+
async function settleUnparsedReview(ctx, state, input, outcome) {
|
|
302
|
+
const { root, role, wt, mainBranch } = ctx;
|
|
303
|
+
const { head, retry, reviewedPatchId, keep } = input;
|
|
304
|
+
const { pi, followUp, nudge, resuming, reviewSessionDir, reviewStartedAt, reviewCfg, claudeConfigDir } = outcome;
|
|
305
|
+
const followUpError = followUp && !followUp.ok ? followUp.errorMessage : undefined;
|
|
306
|
+
// The nudge turn's own death is backend evidence, exactly like the verdict-recovery
|
|
307
|
+
// follow-up's: a nudge that died with a transport error is the backend failing after the
|
|
308
|
+
// reviewer judged nothing — about the world, never about the diff — so the strike-free
|
|
309
|
+
// branch below must see it, and its error names the failure.
|
|
310
|
+
const nudgeError = nudge && !nudge.ok ? nudge.errorMessage : undefined;
|
|
311
|
+
// A progressing timeout of the REVIEW run itself (never a follow-up or nudge turn, both of
|
|
312
|
+
// which run only after pi ok) leaves the session for the next attempt while the patch is
|
|
313
|
+
// identifiable and the resume budget lasts. That is what makes the recorded failure honest:
|
|
314
|
+
// while a resume remains the next attempt continues this review, and once the budget is
|
|
315
|
+
// spent or the failure cannot resume, it reviews the change from scratch (BUGS.md
|
|
316
|
+
// 2026-09-30). A string rewrite of runPi's exact suffix, so any other cause — and the plain
|
|
317
|
+
// no-progress timeout, which promises nothing — passes through untouched.
|
|
318
|
+
const resumeAttempts = resuming ? state.reviewResume?.attempts ?? 0 : 0;
|
|
319
|
+
const resumeRemains = !pi.ok &&
|
|
320
|
+
!pi.aborted &&
|
|
321
|
+
pi.timedOutProgressing &&
|
|
322
|
+
reviewedPatchId !== undefined &&
|
|
323
|
+
resumeAttempts < REVIEW_RESUME_LIMIT &&
|
|
324
|
+
// The promise must be one the next attempt can keep: only a dir whose backend still
|
|
325
|
+
// holds a gate session to resume earns the marker (and the "continues this review"
|
|
326
|
+
// wording). Without this a backend that leaves no session file would record a resume the
|
|
327
|
+
// next attempt silently declines, reviewing from scratch anyway.
|
|
328
|
+
backendSessionResumable(reviewSessionDir, {
|
|
329
|
+
kind: "gate",
|
|
330
|
+
agent: reviewCfg.agent ?? "pi",
|
|
331
|
+
}, claudeConfigDir);
|
|
332
|
+
const reviewTimeoutRewrite = (message) => message.replace(" — session and worktree edits preserved for resume", resumeRemains
|
|
333
|
+
? " — the commit is kept; the next attempt continues this review"
|
|
334
|
+
: " — the commit is kept; the next attempt reviews it from scratch");
|
|
335
|
+
const message = reviewTimeoutRewrite(followUpError ??
|
|
336
|
+
nudgeError ??
|
|
337
|
+
pi.errorMessage ??
|
|
338
|
+
`no parseable VERDICT line in the reviewer's reply${nudge
|
|
339
|
+
? ", even after the no-re-run nudge turn on its session"
|
|
340
|
+
: followUp
|
|
341
|
+
? ", even after a follow-up turn on its session"
|
|
342
|
+
: ""}`);
|
|
343
|
+
logEventBestEffort(root, { source: role, type: "review_failed", head, message, attempt: retry.attempt, durationMs: Date.now() - reviewStartedAt });
|
|
344
|
+
// A dead reviewer must never destroy committed work (BUGS.md 2026-09-20): leave the commit
|
|
345
|
+
// for the next run's re-review and do not advance the per-HEAD discard counter. That
|
|
346
|
+
// holds for the review run itself (BUGS.md 2026-09-20), for the verdict-recovery
|
|
347
|
+
// follow-up (BUGS.md 2026-09-29), and for the no-re-run nudge turn (BUGS.md 2026-10-02):
|
|
348
|
+
// each one's death is the backend failing after the reviewer had already judged nothing —
|
|
349
|
+
// evidence about the world, never about the diff.
|
|
350
|
+
if (!pi.ok || (followUp && !followUp.ok) || (nudge && !nudge.ok)) {
|
|
351
|
+
if (resumeRemains) {
|
|
352
|
+
// Record the session this run used (the resumed directory, or this fresh run's own),
|
|
353
|
+
// so the next attempt `--continue`s exactly it.
|
|
354
|
+
state.reviewResume = {
|
|
355
|
+
patchId: reviewedPatchId,
|
|
356
|
+
sessionDir: reviewSessionDir,
|
|
357
|
+
attempts: resumeAttempts,
|
|
358
|
+
at: Date.now(),
|
|
359
|
+
};
|
|
360
|
+
saveRunnerStateBestEffort(root, state);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
state.reviewResume = undefined;
|
|
364
|
+
}
|
|
365
|
+
const configError = pi.configError || Boolean(followUp?.configError) || Boolean(nudge?.configError);
|
|
366
|
+
// Retried in place (reviewAheadOfMain): the failure is about the world, so the verify tries
|
|
367
|
+
// the reviewer again before the attempt ends. A configuration error can never succeed.
|
|
368
|
+
if (retry.retriesLeft > 0 && !configError) {
|
|
369
|
+
return keep(withRuns({ decision: "failed", detail: message, retryable: true }, pi, followUp, nudge));
|
|
370
|
+
}
|
|
371
|
+
recordReview(state, "failed", [message], head);
|
|
372
|
+
return keep(withRuns({ decision: "failed", detail: message, ...(configError ? { configError: true } : {}) }, pi, followUp, nudge));
|
|
373
|
+
}
|
|
374
|
+
// Consecutive failures of THIS HEAD only: a new commit (new HEAD) starts fresh. Read
|
|
375
|
+
// *before* overwriting lastReview with this failure.
|
|
376
|
+
// Retry before counting: the strike below is per verify's final outcome, not per run.
|
|
377
|
+
if (retry.retriesLeft > 0) {
|
|
378
|
+
state.reviewResume = undefined;
|
|
379
|
+
return keep(withRuns({ decision: "failed", detail: message, retryable: true }, pi, followUp, nudge));
|
|
380
|
+
}
|
|
381
|
+
const prev = state.lastReview;
|
|
382
|
+
const sameHead = prev?.verdict === "failed" && prev.head === head;
|
|
383
|
+
state.reviewResume = undefined;
|
|
384
|
+
state.unreviewFailures = (sameHead ? (state.unreviewFailures ?? 0) : 0) + 1;
|
|
385
|
+
recordReview(state, "failed", [message], head);
|
|
386
|
+
let discarded = false;
|
|
387
|
+
if ((state.unreviewFailures ?? 0) >= REVIEW_FAILURE_LIMIT) {
|
|
388
|
+
await resetWorktreeToMain(wt, mainBranch);
|
|
389
|
+
state.unreviewFailures = 0; // The HEAD is gone; nothing left to count against.
|
|
390
|
+
discarded = true;
|
|
391
|
+
warnEventBestEffort(root, role, `discarding unreviewed leftover after ${REVIEW_FAILURE_LIMIT} failed reviews (${shortSha(head)})`);
|
|
392
|
+
}
|
|
393
|
+
const failed = { ...withRuns({ decision: "failed", detail: message }, pi, followUp, nudge), ...(discarded ? { discarded: true } : {}) };
|
|
394
|
+
return discarded ? failed : keep(failed);
|
|
395
|
+
}
|
|
@@ -150,8 +150,8 @@ function textWithoutVerdictLines(text, matches) {
|
|
|
150
150
|
* revision re-review is asked to check the prior objections FIRST, so a reviewer may open its
|
|
151
151
|
* numbered reasons with a statement that they are all resolved — e.g. "Prior objections 1–10
|
|
152
152
|
* are all resolved — …". That resolution is not an objection, yet every reasons[0] consumer
|
|
153
|
-
* (the gate's detail, a
|
|
154
|
-
* next-
|
|
153
|
+
* (the gate's detail, a role's lastError, the digest's rejection clusters, the author's
|
|
154
|
+
* next-run note) would name it as the outstanding rejection and tell the author to fix it.
|
|
155
155
|
* Dropping only from the FRONT keeps a line that reports an objection still open — those are
|
|
156
156
|
* real objections and stay. */
|
|
157
157
|
function withoutResolvedPriorObjections(reasons) {
|