mixdog 1.3.5 → 1.4.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.
Files changed (341) hide show
  1. package/NOTICE.md +2 -2
  2. package/README.md +2 -2
  3. package/package.json +2 -11
  4. package/scripts/daemon-stub.mjs +1 -1
  5. package/scripts/gate-local.mjs +4 -2
  6. package/scripts/native-release-status.mjs +2 -2
  7. package/scripts/recall-history-cases.json +1 -1
  8. package/scripts/suite-health.mjs +10 -1
  9. package/scripts/test.mjs +7 -11
  10. package/src/agents/reviewer/AGENT.md +7 -11
  11. package/src/agents/reviewer/agent.json +1 -1
  12. package/src/defaults/shipped-history.json +17 -1
  13. package/src/defaults/skills/browser-use/SKILL.md +59 -11
  14. package/src/defaults/skills/code-tidy/SKILL.md +142 -270
  15. package/src/defaults/skills/code-tidy/references/agent-cleanup.md +4 -4
  16. package/src/defaults/skills/code-tidy/references/cleanup-report.md +31 -76
  17. package/src/defaults/skills/code-tidy/references/dead-code.md +6 -12
  18. package/src/defaults/skills/computer-use/SKILL.md +33 -9
  19. package/src/defaults/skills/setup/SKILL.md +22 -0
  20. package/src/defaults/skills/setup/references/actions.md +39 -5
  21. package/src/defaults/skills/setup/references/surfaces.md +11 -2
  22. package/src/defaults/skills/visualize/SKILL.md +2 -1
  23. package/src/lib/rules-builder.cjs +10 -8
  24. package/src/rules/agent/AGENT.md +6 -6
  25. package/src/rules/lead/LEAD.md +18 -20
  26. package/src/rules/shared/05-tool-calls.md +5 -6
  27. package/src/rules/shared/10-tool-workflow.md +2 -0
  28. package/src/rules/shared/60-verification.md +7 -5
  29. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -3
  30. package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +3 -1
  31. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +3 -1
  32. package/src/runtime/agent/orchestrator/config.mjs +17 -1
  33. package/src/runtime/agent/orchestrator/context/collect.mjs +3 -0
  34. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +72 -67
  35. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +54 -1
  36. package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +3 -3
  37. package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +176 -72
  38. package/src/runtime/agent/orchestrator/mcp/client.mjs +19 -0
  39. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +181 -133
  40. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +42 -6
  41. package/src/runtime/agent/orchestrator/providers/anthropic-cache-warm.mjs +165 -0
  42. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  43. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +4 -1
  44. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request/gzip-post.mjs +14 -14
  45. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +145 -66
  46. package/src/runtime/agent/orchestrator/providers/anthropic-overload-fallback.mjs +25 -3
  47. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +64 -33
  48. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +135 -87
  49. package/src/runtime/agent/orchestrator/providers/antigravity-transport.mjs +123 -102
  50. package/src/runtime/agent/orchestrator/providers/cache-warm-admission.mjs +90 -0
  51. package/src/runtime/agent/orchestrator/providers/cursor-wire-transport.mjs +25 -9
  52. package/src/runtime/agent/orchestrator/providers/cursor.mjs +22 -13
  53. package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +17 -3
  54. package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +52 -10
  55. package/src/runtime/agent/orchestrator/providers/model-proxy-channel.d.mts +8 -1
  56. package/src/runtime/agent/orchestrator/providers/model-proxy-channel.mjs +1 -0
  57. package/src/runtime/agent/orchestrator/providers/npm-cli-version.mjs +11 -3
  58. package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +2 -1
  59. package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +10 -9
  60. package/src/runtime/agent/orchestrator/providers/openai-ws-send/send-context.mjs +22 -3
  61. package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/attempt-context.mjs +43 -5
  62. package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/handshake-failure.mjs +3 -1
  63. package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/stream-failure.mjs +6 -3
  64. package/src/runtime/agent/orchestrator/providers/provider-error-kind.mjs +65 -1
  65. package/src/runtime/agent/orchestrator/providers/quota-reading.mjs +38 -12
  66. package/src/runtime/agent/orchestrator/providers/registry.mjs +26 -0
  67. package/src/runtime/agent/orchestrator/providers/retry-executor.mjs +39 -7
  68. package/src/runtime/agent/orchestrator/providers/statusline-route-meta.mjs +6 -0
  69. package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +12 -7
  70. package/src/runtime/agent/orchestrator/runtime-core/compaction-config-keys.mjs +62 -0
  71. package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +37 -16
  72. package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-delta.mjs +100 -23
  73. package/src/runtime/agent/orchestrator/runtime-core/session-text.mjs +2 -0
  74. package/src/runtime/agent/orchestrator/runtime-core/tool-bridge.mjs +19 -4
  75. package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +125 -30
  76. package/src/runtime/agent/orchestrator/session/cache-warm.mjs +792 -0
  77. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +133 -22
  78. package/src/runtime/agent/orchestrator/session/compaction-archive-capture.mjs +475 -58
  79. package/src/runtime/agent/orchestrator/session/compaction-archive.mjs +42 -17
  80. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +4 -1
  81. package/src/runtime/agent/orchestrator/session/human-gate/gate.mjs +11 -5
  82. package/src/runtime/agent/orchestrator/session/human-gate/outbound-policy.mjs +0 -2
  83. package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +36 -4
  84. package/src/runtime/agent/orchestrator/session/human-gate/store.mjs +1 -1
  85. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +18 -22
  86. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +32 -3
  87. package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +3 -1
  88. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +1 -1
  89. package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +17 -3
  90. package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +7 -2
  91. package/src/runtime/agent/orchestrator/session/loop/tool-exec/after-hook.mjs +2 -1
  92. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +3 -2
  93. package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +16 -2
  94. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +16 -1
  95. package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +10 -0
  96. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +3 -10
  97. package/src/runtime/agent/orchestrator/session/loop/tool-phase.mjs +12 -3
  98. package/src/runtime/agent/orchestrator/session/manager/ask-queue.mjs +12 -2
  99. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +19 -1
  100. package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +133 -90
  101. package/src/runtime/agent/orchestrator/session/manager/ask-turn-state.mjs +31 -4
  102. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +30 -18
  103. package/src/runtime/agent/orchestrator/session/manager/owner-route-fallbacks.mjs +23 -13
  104. package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +11 -2
  105. package/src/runtime/agent/orchestrator/session/manager/provider-replay.mjs +13 -0
  106. package/src/runtime/agent/orchestrator/session/manager/route-fallback-chain.mjs +129 -0
  107. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +20 -2
  108. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +2 -0
  109. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +8 -0
  110. package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +1 -1
  111. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +7 -2
  112. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +102 -15
  113. package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +18 -5
  114. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +19 -8
  115. package/src/runtime/agent/orchestrator/session/prompt-cache-idle-gaps.mjs +113 -0
  116. package/src/runtime/agent/orchestrator/session/prompt-cache-touch-store.mjs +127 -0
  117. package/src/runtime/agent/orchestrator/session/routine-result.mjs +36 -9
  118. package/src/runtime/agent/orchestrator/session/sensitive-projection.mjs +100 -0
  119. package/src/runtime/agent/orchestrator/session/sensitive-values.mjs +257 -0
  120. package/src/runtime/agent/orchestrator/session/side-question-store.mjs +20 -7
  121. package/src/runtime/agent/orchestrator/session/side-question.mjs +18 -0
  122. package/src/runtime/agent/orchestrator/session/skill-update-notice.mjs +60 -0
  123. package/src/runtime/agent/orchestrator/session/store/live-state.mjs +6 -3
  124. package/src/runtime/agent/orchestrator/session/store/save-delta.mjs +9 -5
  125. package/src/runtime/agent/orchestrator/session/store/serialize.mjs +9 -8
  126. package/src/runtime/agent/orchestrator/session/store/session-persistence-events.mjs +29 -0
  127. package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +8 -6
  128. package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +12 -2
  129. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +44 -14
  130. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +84 -3
  131. package/src/runtime/agent/orchestrator/session/stored-attachment-history.mjs +32 -0
  132. package/src/runtime/agent/orchestrator/session/thinking-binding.mjs +108 -0
  133. package/src/runtime/agent/orchestrator/session/tool-batch/pre-dispatch.mjs +2 -2
  134. package/src/runtime/agent/orchestrator/session/tool-batch/record-outcome.mjs +2 -1
  135. package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +18 -1
  136. package/src/runtime/agent/orchestrator/session/transcript-restore/tool-result-status.mjs +9 -7
  137. package/src/runtime/agent/orchestrator/session/transcript-restore/tool-result-text.mjs +2 -2
  138. package/src/runtime/agent/orchestrator/session/turn-failure.mjs +5 -1
  139. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +5 -2
  140. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +12 -1
  141. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/misuse-guard.mjs +240 -0
  142. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/result-format.mjs +1 -1
  143. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/shell-cwd.mjs +38 -0
  144. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +25 -5
  145. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +65 -7
  146. package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +7 -1
  147. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +36 -13
  148. package/src/runtime/browser-bridge/action-schema.mjs +13 -2
  149. package/src/runtime/browser-bridge/client.mjs +73 -8
  150. package/src/runtime/browser-bridge/input-fields.mjs +8 -9
  151. package/src/runtime/browser-bridge/mail-links.mjs +107 -0
  152. package/src/runtime/browser-bridge/tool-defs.mjs +1 -1
  153. package/src/runtime/channels/lib/config.mjs +6 -61
  154. package/src/runtime/channels/lib/crash-log.mjs +1 -1
  155. package/src/runtime/channels/lib/event-pipeline.mjs +4 -19
  156. package/src/runtime/channels/lib/event-queue.mjs +3 -18
  157. package/src/runtime/channels/lib/owned-runtime/automation-services.mjs +2 -2
  158. package/src/runtime/channels/lib/owned-runtime/automation-start.mjs +3 -4
  159. package/src/runtime/channels/lib/owned-runtime/config-reload.mjs +4 -59
  160. package/src/runtime/channels/lib/owned-runtime/owned-start.mjs +33 -115
  161. package/src/runtime/channels/lib/owned-runtime/owned-stop.mjs +5 -22
  162. package/src/runtime/channels/lib/owned-runtime/state.mjs +2 -8
  163. package/src/runtime/channels/lib/owned-runtime.mjs +6 -23
  164. package/src/runtime/channels/lib/parent-bridge.mjs +2 -2
  165. package/src/runtime/channels/lib/runtime-paths.mjs +4 -43
  166. package/src/runtime/channels/lib/scheduler.mjs +33 -147
  167. package/src/runtime/channels/lib/schedules-db.mjs +34 -11
  168. package/src/runtime/channels/lib/status-snapshot.mjs +1 -1
  169. package/src/runtime/channels/lib/tool-dispatch.mjs +1 -2
  170. package/src/runtime/channels/lib/webhooks-db.mjs +5 -9
  171. package/src/runtime/channels/lib/worker-bootstrap.mjs +0 -1
  172. package/src/runtime/channels/lib/worker-ipc.mjs +0 -1
  173. package/src/runtime/channels/lib/worker-main.mjs +10 -34
  174. package/src/runtime/computer-bridge/action-schema.mjs +42 -1
  175. package/src/runtime/computer-bridge/actions.mjs +9 -1
  176. package/src/runtime/computer-bridge/client.mjs +180 -8
  177. package/src/runtime/computer-bridge/core-actions.mjs +2 -2
  178. package/src/runtime/computer-bridge/error-recovery.mjs +27 -2
  179. package/src/runtime/computer-bridge/linux-readiness.mjs +65 -23
  180. package/src/runtime/computer-bridge/pending-continuation.mjs +1 -1
  181. package/src/runtime/connectors/connector-accounts-mcp.mjs +230 -0
  182. package/src/runtime/connectors/gmail-app-password.mjs +172 -39
  183. package/src/runtime/connectors/google-mcp.mjs +10 -12
  184. package/src/runtime/memory/lib/pg/adapter.mjs +77 -70
  185. package/src/runtime/memory/lib/pg/supervisor.mjs +24 -12
  186. package/src/runtime/memory/lib/runtime-fetcher.mjs +23 -5
  187. package/src/runtime/session-search/session-search-db.mjs +73 -9
  188. package/src/runtime/session-search/session-search-ingest.mjs +110 -20
  189. package/src/runtime/shared/abort-race.mjs +89 -0
  190. package/src/runtime/shared/agent-avatar.d.mts +0 -1
  191. package/src/runtime/shared/agent-kind.mjs +4 -3
  192. package/src/runtime/shared/bounded-download.mjs +8 -3
  193. package/src/runtime/shared/config.mjs +2 -13
  194. package/src/runtime/shared/connector-accounts.mjs +20 -10
  195. package/src/runtime/shared/connector-catalog.d.mts +29 -0
  196. package/src/runtime/shared/connector-catalog.mjs +150 -0
  197. package/src/runtime/shared/connector-triggers.mjs +22 -19
  198. package/src/runtime/shared/defaults-separation.mjs +2 -14
  199. package/src/runtime/shared/delegated-approval-host.mjs +103 -11
  200. package/src/runtime/shared/err-text.mjs +24 -15
  201. package/src/runtime/shared/file-permissions.d.mts +0 -8
  202. package/src/runtime/shared/file-permissions.mjs +0 -11
  203. package/src/runtime/shared/git-direct.test-support.mjs +19 -0
  204. package/src/runtime/shared/heartbeat-interval.d.mts +4 -0
  205. package/src/runtime/shared/heartbeat-interval.mjs +19 -0
  206. package/src/runtime/shared/idle-auto-clear-gate.mjs +104 -0
  207. package/src/runtime/shared/llm/usage-rollup.mjs +1 -1
  208. package/src/runtime/shared/mixy-presence.mjs +22 -0
  209. package/src/runtime/shared/orchestration.d.mts +2 -0
  210. package/src/runtime/shared/pg-schema-db.mjs +27 -16
  211. package/src/runtime/shared/profile-config.cjs +1 -1
  212. package/src/runtime/shared/prompt-origin.d.mts +4 -0
  213. package/src/runtime/shared/prompt-origin.mjs +21 -0
  214. package/src/runtime/shared/provider-accounts.mjs +7 -1
  215. package/src/runtime/shared/provider-display-name.mjs +29 -0
  216. package/src/runtime/shared/provider-timeout-phase.mjs +2 -0
  217. package/src/runtime/shared/routine-trigger.d.mts +2 -0
  218. package/src/runtime/shared/routine-trigger.mjs +10 -0
  219. package/src/runtime/shared/sensitive-path-rules.d.mts +2 -10
  220. package/src/runtime/shared/sensitive-path-rules.mjs +19 -41
  221. package/src/runtime/shared/session-activity-signal.mjs +34 -1
  222. package/src/runtime/shared/session-sidebar-host.d.mts +1 -1
  223. package/src/runtime/shared/session-sidebar-host.mjs +7 -3
  224. package/src/runtime/shared/session-turn-prelude.mjs +18 -0
  225. package/src/runtime/shared/tool-result-summary.mjs +1 -14
  226. package/src/runtime/shared/worktrees/test-support.mjs +9 -4
  227. package/src/runtime/terminal-bridge/client.mjs +10 -1
  228. package/src/runtime/visualize-bridge/client.mjs +27 -8
  229. package/src/runtime/visualize-bridge/tool-defs.mjs +22 -8
  230. package/src/runtime/visualize-bridge/tool-meta.d.mts +5 -0
  231. package/src/runtime/visualize-bridge/tool-meta.mjs +22 -0
  232. package/src/runtime/web-search/lib/fetch-pipeline.mjs +2 -2
  233. package/src/session-runtime/agent-home-delivery.mjs +448 -185
  234. package/src/session-runtime/agent-task-sessions.mjs +329 -180
  235. package/src/session-runtime/boot/apis.mjs +9 -0
  236. package/src/session-runtime/boot/infrastructure.mjs +4 -0
  237. package/src/session-runtime/boot/providers.mjs +3 -0
  238. package/src/session-runtime/boot/tools.mjs +6 -1
  239. package/src/session-runtime/config-lifecycle.mjs +6 -0
  240. package/src/session-runtime/connector-merge-migration.mjs +305 -0
  241. package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +132 -28
  242. package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +2 -0
  243. package/src/session-runtime/lifecycle/inheritance.mjs +16 -3
  244. package/src/session-runtime/lifecycle/session-catalog.mjs +3 -1
  245. package/src/session-runtime/lifecycle/teardown/runtime-stops.mjs +50 -4
  246. package/src/session-runtime/lifecycle/teardown.mjs +23 -5
  247. package/src/session-runtime/mcp-glue/server-catalog.mjs +55 -3
  248. package/src/session-runtime/mcp-oauth-login.mjs +5 -3
  249. package/src/session-runtime/mixy-heartbeat.mjs +153 -33
  250. package/src/session-runtime/notification-bus.mjs +31 -117
  251. package/src/session-runtime/notification-completion-queue.mjs +54 -0
  252. package/src/session-runtime/notification-listeners.mjs +76 -0
  253. package/src/session-runtime/owned-automation-run.mjs +2 -1
  254. package/src/session-runtime/prewarm/channel-start.mjs +3 -7
  255. package/src/session-runtime/resource-mcp-api.mjs +143 -224
  256. package/src/session-runtime/resource-mcp-connector-accounts.mjs +163 -0
  257. package/src/session-runtime/resource-mcp-oauth-api.mjs +217 -0
  258. package/src/session-runtime/resource-mcp-secrets.mjs +82 -0
  259. package/src/session-runtime/resource-mcp-servers.mjs +78 -0
  260. package/src/session-runtime/resource-mcp-store.mjs +49 -0
  261. package/src/session-runtime/routine-owner.mjs +40 -9
  262. package/src/session-runtime/services/agent-tool/close-flow.mjs +3 -0
  263. package/src/session-runtime/services/agent-tool/spawn-preset.mjs +7 -2
  264. package/src/session-runtime/services/agent-tool/tag-registry.mjs +1 -0
  265. package/src/session-runtime/services/agent-tool/worker-index/awaiting-user-sync.mjs +51 -0
  266. package/src/session-runtime/services/agent-tool/worker-index/disposal.mjs +55 -0
  267. package/src/session-runtime/services/agent-tool/worker-index/released-store.mjs +123 -0
  268. package/src/session-runtime/services/agent-tool/worker-index/restart-settlement.mjs +112 -0
  269. package/src/session-runtime/services/agent-tool/worker-index/row-reads.mjs +36 -0
  270. package/src/session-runtime/services/agent-tool/worker-index/row-shape.mjs +2 -0
  271. package/src/session-runtime/services/agent-tool/worker-index/row-store.mjs +17 -4
  272. package/src/session-runtime/services/agent-tool/worker-index/row-writes.mjs +58 -0
  273. package/src/session-runtime/services/agent-tool/worker-index.mjs +41 -241
  274. package/src/session-runtime/services/agent-tool/worker-rows.mjs +3 -0
  275. package/src/session-runtime/services/channel-admin.mjs +7 -13
  276. package/src/session-runtime/services/channel-session-router.mjs +4 -2
  277. package/src/session-runtime/services/seeds.mjs +0 -28
  278. package/src/session-runtime/session-compaction-sync.mjs +27 -0
  279. package/src/session-runtime/session-create/session-options.mjs +1 -0
  280. package/src/session-runtime/settings-builtin-tools-api.mjs +11 -0
  281. package/src/session-runtime/settings-compaction-api.mjs +2 -40
  282. package/src/session-runtime/settings-system-api.mjs +13 -1
  283. package/src/session-runtime/setup-tool/agent-settings-actions.mjs +65 -0
  284. package/src/session-runtime/setup-tool/executor.mjs +145 -22
  285. package/src/session-runtime/setup-tool/extended-actions.mjs +8 -3
  286. package/src/session-runtime/setup-tool/session-route-actions.mjs +152 -0
  287. package/src/session-runtime/setup-tool/settings-contract.mjs +4 -3
  288. package/src/session-runtime/setup-tool/tool-defs.mjs +64 -5
  289. package/src/session-runtime/tool-policy/agent-profile-fold.mjs +17 -13
  290. package/src/session-runtime/tool-policy/policy-stage.mjs +16 -2
  291. package/src/session-runtime/turn/turn-run/ask-callbacks.mjs +1 -0
  292. package/src/session-runtime/workflow-agents-api/style-and-mode.mjs +4 -0
  293. package/src/standalone/channel-transport/client-registry/client-records.mjs +65 -0
  294. package/src/standalone/channel-transport/client-registry/client-registration.mjs +118 -0
  295. package/src/standalone/channel-transport/client-registry.mjs +24 -163
  296. package/src/standalone/channel-transport.mjs +1 -1
  297. package/src/standalone/daemon-channels-loader.mjs +10 -8
  298. package/src/standalone/daemon-session-control/list-page.mjs +72 -0
  299. package/src/standalone/daemon-session-control/request.mjs +51 -0
  300. package/src/standalone/daemon-session-control/room-host.mjs +57 -0
  301. package/src/standalone/daemon-session-control/route-control.mjs +48 -0
  302. package/src/standalone/daemon-session-control/send-turn.mjs +60 -0
  303. package/src/standalone/daemon-session-control/worktree-control.mjs +40 -0
  304. package/src/standalone/daemon-session-control.mjs +124 -188
  305. package/src/standalone/daemon.mjs +26 -3
  306. package/src/standalone/session-client.mjs +7 -3
  307. package/src/standalone/session-protocol.mjs +5 -0
  308. package/src/standalone/session-service/agent-tree/agent-child.mjs +1 -0
  309. package/src/standalone/session-service/quota-resume.mjs +3 -0
  310. package/src/standalone/session-service/retention/busy.mjs +65 -1
  311. package/src/standalone/session-service/session-calls/session-action.mjs +23 -2
  312. package/src/standalone/session-service/session-calls/session-views.mjs +8 -0
  313. package/src/standalone/session-tool-output.mjs +15 -7
  314. package/src/tui/app/model-options.mjs +3 -28
  315. package/src/tui/dist/index.mjs +58 -64
  316. package/src/tui/session/agent-job-feed/model-notification.mjs +3 -0
  317. package/src/tui/session/initial-state.mjs +3 -0
  318. package/src/tui/session/notice-surface.mjs +7 -1
  319. package/src/tui/session/queue-helpers.mjs +3 -42
  320. package/src/tui/session/session-api/routes-agent-definitions.mjs +14 -2
  321. package/src/tui/session/session-api/routes-write.mjs +5 -1
  322. package/src/tui/session/session-api/routes.mjs +1 -0
  323. package/src/tui/session/session-api/settings.mjs +17 -1
  324. package/src/tui/session/session-flow/auto-clear.mjs +4 -33
  325. package/src/tui/session/session-flow/drain-closed-queue.mjs +38 -0
  326. package/src/tui/session/session-flow/drain-enqueue.mjs +86 -0
  327. package/src/tui/session/session-flow/drain-retry.mjs +35 -0
  328. package/src/tui/session/session-flow/drain.mjs +118 -149
  329. package/src/tui/session/session-flow/queue/entry-shape.mjs +5 -0
  330. package/src/tui/session/session-flow/queue/take-entries.mjs +5 -2
  331. package/src/tui/session/tool-approval-delegation.mjs +64 -0
  332. package/src/tui/session/tool-approval-request.mjs +39 -0
  333. package/src/tui/session/tool-approval-settle.mjs +62 -0
  334. package/src/tui/session/tool-approval.mjs +69 -115
  335. package/src/tui/session/tui-steering-persist.mjs +8 -1
  336. package/src/tui/session/turn-stream.mjs +19 -2
  337. package/src/tui/session/turn.mjs +1 -0
  338. package/src/vendor/statusline/bin/statusline-route.mjs +1 -219
  339. package/src/vendor/statusline/src/gateway/route-meta.mjs +35 -13
  340. package/scripts/code-graph-description-contract.mjs +0 -188
  341. package/src/runtime/channels/lib/owned-runtime/ownership-refresh.mjs +0 -36
@@ -12,286 +12,158 @@ dependencies:
12
12
 
13
13
  # Code tidy (tidy tool)
14
14
 
15
- Use the applicable layers, cheapest and safest first: project formatters and
16
- linters through `tidy`, structural rule packs, then agent-level cleanup.
17
- Every layer preserves behavior and public API; this is not a bug hunt.
18
- The schema owns action fields; this file owns scope, order, and boundaries.
19
-
20
- Investigate and clean the selected scope in approved partition-sized rounds,
21
- then report the outcome. `references/agent-cleanup.md` owns the analysis and
22
- risk classification; `references/cleanup-report.md` owns candidate tracking,
23
- completion criteria, and the closing report.
24
-
25
- ## 1. Which job
26
- **Hard rule — tidy owns format/lint/structure/cleanup, not feature work.**
27
- New behavior, refactors that change a public API, and adding formatter configs
28
- are not this skill. A correctness bug found while cleaning is reported under
29
- "Bugs found", never folded into a cleanup edit.
30
- **Hard rule — never invent a formatter config**: a project that already has
31
- Biome, Prettier, clang-format, rustfmt, gofmt, or equivalent keeps it. Do not
32
- add or rewrite `biome.json`, `.prettierrc`, `.clang-format`, or similar unless
33
- the user asks.
34
- **Mode**: `apply` unless the user asks to check, review, or "just report" —
35
- report-only requests stay read-only across all layers and never edit; the report
36
- lists what would change. Apply still follows the active workflow's approval rules.
37
- **Focus**: an explicit restriction applies to every layer. "Formatting only"
38
- excludes lint fixes and structural or semantic cleanup; "only dead code"
39
- excludes unrelated formatting and refactoring. Skip unrelated investigations
40
- and fixes, but retain checks needed to verify the requested work. If a tool
41
- cannot isolate that operation, use evidenced targeted edits or report the
42
- limitation and ask before widening the work.
43
-
44
- ## 2. Scope and investigation
45
- 1. **Get the scope from the user.** Accept named files, directories, a feature
46
- area resolved to confirmed paths, or an explicitly requested whole project.
47
- If absent or ambiguous, ask before scanning or editing. Never infer scope
48
- from recent changes, a diff, a branch, a commit, or session activity.
49
- 2. Recommend that the user commit their existing work before an apply run, so
50
- it starts from a clean checkpoint; do not commit for them or make this a
51
- requirement for read-only investigation. Use Git mainly for one initial
52
- status check and a final scoped diff. A dirty tree requires preserving the
53
- existing edits, not automatically stashing or discarding them.
54
- 3. Drop deleted, binary, generated, vendored files and lockfiles unless the
55
- user explicitly included them. Read and run direct consumers and covering
56
- tests as needed; editing them outside the selected area needs approval.
57
- New, non-ignored files are included without staging. Never widen the edit
58
- scope silently.
59
- 4. Pass the current round's approved paths on every `scan`/`check`/`fix`;
60
- use `paths:["."]` only for an explicitly requested whole project that fits
61
- one round. Result: every layer sees the same round scope, which the report names.
62
- 5. **Establish the baseline before any edit** with the narrowest documented
63
- tests and typecheck covering the current round's approved behavior. Reuse current results
64
- when their inputs have not changed. Record pre-existing failures separately.
65
- A broken runner blocks changes requiring it; continue independent work and
66
- report the blocked scope as unfinished.
67
- 6. **Complete read-only investigation per round before cleanup.** Partition
68
- scopes too large for one review (an explicitly requested whole project or
69
- several directories) by directory or responsibility. Each partition is one
70
- round: deterministic check on its paths (or the dry-run plan in section 3)
71
- → deletion ladder → lenses → apply by tier → verification → round close.
72
- - **Size each partition so one round can actually finish it.** The round
73
- owes the ladder on every source unit in the partition and the lenses on
74
- every survivor; a partition that cannot get that pass is too big, so split
75
- it further before starting. Hundreds of files in one partition is the
76
- usual failure.
77
- - **Run the whole set of partitions through to the end.** Start the next
78
- partition as soon as a round closes. Do not pause for user input between
79
- rounds — section 7 owns reporting.
80
- - **Keep every round attributable.** Rounds in progress at the same time
81
- edit disjoint files, and each round's verification reflects only its own
82
- edits. Each round declares the test lane it uses (runner plus paths); two
83
- rounds never share a lane that cannot run concurrently, because a
84
- load-sensitive suite then fails for a reason neither round owns.
85
- - **The partition list and the accumulated candidate inventory are durable
86
- state**: they must survive turn boundaries instead of being rebuilt from
87
- scratch.
88
- - Finish all applicable read-only checks and lens analysis for the current
89
- round before its edits, not for the whole scope. Accumulate registered
90
- candidates across rounds using `references/cleanup-report.md`.
91
- - Read per-rule and per-directory counts from check/fix/results first;
92
- select the rules and directories relevant to this round, then page only
93
- those with `tidy action:'results'` filters. Read every selected page of the
94
- current round's cached run before another check/fix replaces it. Never
95
- page a whole-project run row by row or treat unreviewed in-scope results
96
- as clean. Pagination is not engine truncation; do not rerun engines just
97
- to see remaining rows.
98
- - Actual engine truncation, timeouts, failed diagnostic checks, or scope
99
- leakage mark the affected partition **unfinished**, not clean; they do
100
- not invalidate other partitions.
101
- - Blocked checks stop dependent edits; continue only approved independent
102
- work and report the unfinished portion.
15
+ Layers, cheapest and safest first: project formatters and linters through
16
+ `tidy`, structural rule packs, then agent-level cleanup. Every layer preserves
17
+ behavior and public API; this is not a bug hunt. The `tidy` schema owns action
18
+ fields; this file owns scope, order, and boundaries. Verification follows the
19
+ shared rule: finish all planned edits, then check once (section 5).
20
+
21
+ ## 1. Job and mode
22
+ - Tidy owns format, lint, structure, and cleanup, not feature work. New
23
+ behavior and public-API refactors are out of scope. A correctness bug found
24
+ while cleaning goes under "Bugs found", never into a cleanup edit.
25
+ - Never invent a formatter config. A project with Biome, Prettier,
26
+ clang-format, rustfmt, gofmt, or equivalent keeps it; add or rewrite
27
+ `biome.json`, `.prettierrc`, `.clang-format` and the like only when asked.
28
+ - Mode is `apply` unless the user asks to check, review, or "just report";
29
+ report-only stays read-only on every layer and lists what would change.
30
+ - An explicit focus restricts every layer ("formatting only" excludes lint
31
+ and semantic cleanup; "only dead code" excludes unrelated formatting). If
32
+ the tool cannot isolate it, use targeted edits or report the limitation
33
+ and ask before widening.
34
+
35
+ ## 2. Scope
36
+ 1. Scope comes from the user: named files, directories, a feature area
37
+ resolved to confirmed paths, or an explicitly requested whole project. If
38
+ absent or ambiguous, ask first. Never infer it from a diff, branch,
39
+ commit, or recent activity.
40
+ 2. Recommend (do not require, do not do it for them) that the user commit
41
+ existing work before an apply run. A dirty tree means preserve those edits.
42
+ 3. Drop deleted, binary, generated, vendored files and lockfiles unless
43
+ explicitly included. Consumers and covering tests may be read; editing
44
+ them outside the scope needs approval. New non-ignored files are included.
45
+ 4. Pass the approved paths on every `scan`/`check`/`fix`; `paths:["."]` only
46
+ for an explicitly requested whole project.
47
+ 5. Too large to review in one pass (whole project, many directories):
48
+ partition by directory or responsibility so every source unit gets the
49
+ ladder and every survivor the lenses; hundreds of files per partition is
50
+ the usual failure. Work through all partitions without pausing for input.
51
+ Keep the partition list and candidate list across turns.
52
+ 6. Read per-rule and per-directory counts first, then page only relevant
53
+ rows with `tidy action:'results'` filters; never treat unreviewed in-scope
54
+ results as clean. Real engine truncation, timeouts, or scope leakage mark
55
+ that partition **unfinished**, not clean. Blocked checks stop dependent
56
+ edits only.
103
57
 
104
58
  ## 3. Deterministic layers
105
- 1. `tidy action:'scan'` first: languages and engines (used / missing /
106
- `installHint`). Scan never downloads and never returns `needsApproval`.
107
- 2. **Hard rule — downloads are automatic under the default `auto` policy;
108
- only when the user set `tidy.downloads` to `ask` does a result carry
109
- `needsApproval` — then ask once**, list engines and bytes, and re-call
110
- that action with `approveDownloads:true`.
111
- 3. **Hard rule — engines run only through tidy, and never get installed by
112
- hand** (rustfmt, gofmt, dart, swift, zig, mix, dotnet): report
113
- `installHint`. Managed engines download only through tidy (`auto`,
114
- `approveDownloads`, or `action:'install'`). An ad-hoc `npx <engine>`, global
115
- binary, or package script is not verification — the name can resolve to an
116
- unrelated package and report a false clean. An engine tidy cannot resolve
59
+ 1. `tidy action:'scan'` first (languages, engines used/missing,
60
+ `installHint`). Scan never downloads.
61
+ 2. Downloads are automatic under the default `auto` policy. Only when
62
+ `tidy.downloads` is `ask` does a result carry `needsApproval`: ask once,
63
+ listing engines and bytes, then re-call with `approveDownloads:true`.
64
+ 3. Engines run only through `tidy` and are never installed by hand
65
+ (rustfmt, gofmt, dart, swift, zig, mix, dotnet: report `installHint`). An
66
+ ad-hoc `npx <engine>`, global binary, or package script is not
67
+ verification and may report a false clean. An engine `tidy` cannot resolve
117
68
  leaves its check blocked, never clean.
118
- 4. Plan the approved deterministic work with `fix` without `apply:true`;
119
- do not repeat an equivalent `check` first. Use one combined plan when both
120
- engines and structural rules are in scope:
121
- - `structural:false` disables structural rules, not engine lint fixes.
122
- - `structural:true` (the default) runs ordinary engines as well as rules;
123
- it is not a structure-only pass. Do not precede it with a redundant
124
- engine-only pass. The current tool has no structure-only selector.
125
- - For restricted work, follow the Focus boundary above rather than using
126
- a combined apply that also changes unrelated code.
127
- 5. Treat the engine dry run as diagnostics and candidate files, not a preview
128
- of the exact resulting patch. Apply recalculates work; it does not replay a
129
- frozen preview. If inputs or approved operations change before writing,
130
- refresh the affected plan. Use `apply:true` only after the current round's
131
- complete plan is approved, then review the actual changes against that scope.
132
- 6. A dry run with no proposed fixes skips apply. Rules without a fix
133
- (`no-empty-catch`, `no-nested-ternary`, `no-any-cast`,
69
+ 4. Plan with `fix` without `apply:true`; no separate `check` first. The dry
70
+ run is diagnostics and candidate files, not a frozen patch; apply
71
+ recalculates. `structural:true` (default) also runs ordinary engines;
72
+ `structural:false` disables structural rules only, not engine lint fixes.
73
+ For a restricted focus, do not use a combined apply that touches unrelated
74
+ code.
75
+ 5. Apply with `apply:true` once the plan for the scope is settled, then review
76
+ the actual changes. Skip apply when the dry run proposes nothing.
77
+ Rules without a fix (`no-empty-catch`, `no-nested-ternary`, `no-any-cast`,
134
78
  `no-boolean-literal-compare`, `no-debug-statement`, `todo-marker`) are
135
- diagnostics for the agent layer, not changes. Skip a layer the scan shows
136
- has nothing to do. Keep the engine pass separable from the agent edits: a
137
- reformat folded into semantic changes makes the diff unreviewable, so
138
- report them as distinct change sets.
139
- Stop affected writes on an engine or structural failure, truncation, or
140
- rejected edit; a partial result is not success. Do not retry unchanged input
141
- or apply findings from the failed portion of the plan.
79
+ diagnostics for the agent layer. Keep the engine pass a distinct change
80
+ set from semantic edits. On engine or structural failure, truncation, or a
81
+ rejected edit, stop affected writes; a partial result is not success.
142
82
 
143
83
  ## 4. Agent-level cleanup
144
- Read `references/agent-cleanup.md` first: it owns the deletion ladder, the
145
- lens checklists, the slop categories, and the risk tiers. Also read
84
+ Read `references/agent-cleanup.md` (ladder, lenses, slop, risk tiers); also
146
85
  `references/test-suite-slop.md` when tests are in scope, and
147
- `references/cleanup-report.md` before registering the first candidate. This
148
- section owns the order. After context compaction, re-read only the file the
149
- next step needs.
150
-
151
- 1. **Lock behavior.** Use the baseline established in section 2. A file with no test covering
152
- the behavior you will touch gets either the narrowest regression test that
153
- pins its observable output, or only SAFE-tier changes — say which. Prose
154
- files (skills, prompts, docs) have no behavior to pin.
155
- Before extracting or moving anything, search the test suite for guards that
156
- pin source text — tests reading source files as text, asserting statement or
157
- call ordering, or restricting where an identifier may appear — and record
158
- what each pins (`references/agent-cleanup.md` lists the shapes). A partition
159
- whose guards were not searched does not start extracting.
160
- 2. **Ladder, then lenses.** Run the deletion ladder on every selected source unit
161
- in the current round; only survivors go through the four lenses (reuse,
162
- quality, efficiency, altitude). Engine diagnostics point at units; they never
163
- define the round's coverage. A round that reviewed only the units an engine
164
- flagged is **unfinished**, not complete: say so in its close and name what
165
- stayed unreviewed. Every finding carries a path-plus-symbol location, a cost, an action, a
166
- confidence, and a risk tier; findings without evidence are dropped, and
167
- consult history only when code, contracts, and tests leave intent unclear;
168
- `git blame` is not a mandatory step for each removal. Unresolved intent
169
- lowers confidence and blocks deletion, rather than justifying it.
170
- The four lenses run over the ladder survivors and yield one merged,
171
- deduplicated finding list.
172
- 3. **Execute in approved bounded rounds.**
173
- - Use the partitions from section 2; accumulate the inventory across rounds,
174
- close each round with its brief note, and start the next partition
175
- immediately.
176
- - Within one file or module, CAREFUL source units must be edited
177
- sequentially. A round cut off mid-unit ends with that unit finished and
178
- wired into its callers, or reverted: never leave behind a new module
179
- nothing imports.
180
- - Apply by tier: SAFE as one batch; CAREFUL one source unit at a time; RISKY
181
- reported, never auto-applied. Within a tier: comments → dead code →
182
- defensive code → duplication → complexity → abstraction → performance.
183
- Use targeted checks at meaningful behavior boundaries and run the
184
- documented final tests/typecheck once after the round. Targeted checks
185
- include the tests that import each edited module (found with `code_graph`
186
- dependents or grep). Do not rerun
187
- unaffected checks after every comment or mechanical edit.
188
- - Structural items from the table below are CAREFUL unless their row says
189
- otherwise; dead code follows
190
- `references/dead-code.md`.
191
- - After the last tier lands in a round, re-run `tidy check` over the same
192
- paths once: removals leave new unused imports and newly orphaned helpers
193
- behind. Apply only SAFE findings from that cascade pass and add any
194
- remaining findings to the inventory — one pass, never a loop.
195
- 4. **Stop rules.** Three failed attempts on one file → stop and escalate with
196
- what was tried. A deeper fix larger than the cleanup → report it as its own
197
- task. Principles cannot pick between two rewrites → apply neither, record
86
+ `references/cleanup-report.md` for recording and the closing report.
87
+
88
+ 1. **Pin behavior (read-only).** Search the tests for source-text guards
89
+ (shapes in `agent-cleanup.md`) before extracting or moving anything. A file
90
+ whose touched behavior no test covers gets the narrowest regression test
91
+ that pins it, or only SAFE changes. Prose files have no behavior to pin.
92
+ 2. **Ladder, then lenses.** Run the deletion ladder on every selected source
93
+ unit, then the four lenses on the survivors. Engine diagnostics point at
94
+ units; they do not define coverage. A partition reviewed only where an
95
+ engine flagged is unfinished. Each finding has a path+symbol location,
96
+ cost, action, confidence, and risk tier; drop findings without evidence.
97
+ Use history only when code, contracts, and tests leave intent unclear;
98
+ unresolved intent blocks deletion.
99
+ 3. **Apply by tier.** SAFE as one batch; CAREFUL one source unit at a time,
100
+ each finished and wired into its callers (never leave a new module nothing
101
+ imports); RISKY is reported, never auto-applied. Order within a tier:
102
+ comments, dead code, defensive code, duplication, complexity, abstraction,
103
+ performance. Dead code follows `references/dead-code.md`.
104
+ 4. **Stop rules.** Three failed attempts on one file: stop and escalate with
105
+ what was tried. A deeper fix larger than the cleanup: report it as its own
106
+ task. Principles cannot pick between two rewrites: apply neither, record
198
107
  both.
199
108
 
200
- The following are investigation signals, not registered candidates or permission
201
- for an automatic rewrite; `references/cleanup-report.md` owns registration.
202
-
203
- | Structural signal | Decision |
204
- |---|---|
205
- | File > 1,000 lines | Identify separable responsibilities and verify the cost of splitting |
206
- | Function > 50 lines, or nesting > 3 | Below roughly 100 lines, length alone is not a reason to act: name the symptom (duplication, a defect, demonstrated difficulty of change) or leave it. Above it, confirm mixed responsibilities or avoidable nesting before extracting |
207
- | Duplicated small helpers across files | Consolidate only when intent and behavior match |
208
- | Comments describing history (`extracted verbatim`, `moved from`, `behavior-preserving move`) | Remove only when no protected content or parsing behavior is lost |
209
- | Underscore-prefixed names exported across modules | Treat a rename as a RISKY contract change; report, never auto-rename |
210
- | Dead code / unused exports | Verify through the dead-code procedure before removing |
211
-
212
- Do not "improve" names, control flow, or types beyond the ladder, the lenses,
213
- and this table.
214
-
215
- Size alone neither mandates a split nor makes one RISKY. A confirmed
216
- responsibility-based split preserving behavior and entry points is CAREFUL:
217
- extract one source unit at a time with its required modules, and verify direct
218
- consumers. An extracted unit takes only the values it reads — a parameter it
219
- never uses is a defect, and the call site stops passing it. Moving the entire
220
- body elsewhere or cutting it into numbered chunks does not resolve the finding.
221
- An unperformed confirmed split stays unfinished.
222
-
223
- ## 5. Keep — never remove or rename
109
+ Structural signals are leads, not candidates: file > 1,000 lines, function
110
+ > 50 lines or nesting > 3 (under ~100 lines, act only on a named symptom:
111
+ duplication, a defect, demonstrated difficulty of change), duplicated small
112
+ helpers (consolidate only when intent matches), history comments (remove only
113
+ if no protected content is lost), underscore-prefixed names exported across
114
+ modules (rename is RISKY). Do not improve names, control flow, or types
115
+ beyond the ladder, lenses, and these signals. A confirmed
116
+ responsibility-based split that preserves behavior and entry points is
117
+ CAREFUL; an extracted unit takes only the values it reads. Moving a whole
118
+ body elsewhere or cutting it into numbered chunks resolves nothing.
119
+
120
+ ## 5. Check once, then fix
121
+ After every planned edit in the assigned scope is done, run the project's
122
+ documented tests/typecheck covering the touched behavior and `tidy check` on
123
+ the scope, once, in parallel. No check, build, lint, test, or formatter run
124
+ before that. If it fails, read the full logs, finish the fixes, and rerun only
125
+ the failed or invalidated checks. A failure on code you did not touch is
126
+ pre-existing: report it separately. A broken runner leaves its scope
127
+ unverified: say so. Skipped or failed checks never count as passed.
128
+
129
+ If checks fail and cannot be fixed, undo only this run's edits with targeted
130
+ patches, preserving prior or concurrent work. Never use `git checkout`,
131
+ `reset`, `restore`, or `stash` as rollback; if the edits cannot be separated
132
+ safely, leave them and report the blocker.
133
+
134
+ New findings from the final `tidy check` (e.g. imports orphaned by removals)
135
+ are fixed once if SAFE; others are reported.
136
+
137
+ ## 6. Keep: never remove or rename
224
138
  - Validation and error handling at a trust boundary (user input, external
225
139
  API, file, network) unless an adversarial test proves the guard redundant.
226
140
  - Export names, API routes, CLI flags, DB columns, config keys, event names,
227
- wire strings — contracts; a rename is RISKY even when the name is bad.
141
+ wire strings: contracts. A rename is RISKY even when the name is bad.
228
142
  - Anything on the never-dead list in `references/dead-code.md`.
229
- - An empty catch or ignored error that may be intentional — flag it.
230
- - Complexity serving a current compatibility obligation, staged migration,
231
- or vendored-code isolation. Use the legacy retirement procedure in
232
- `references/dead-code.md` before treating an old path as obsolete.
233
- - License, copyright and SPDX notices; compiler, linter and bundler directives;
234
- public API documentation; security and compatibility explanations. A history
235
- phrase alone is not permission to remove attribution. Embedded block comments
236
- may separate tokens or carry significant line breaks: leave them for manual
237
- review, and preserve parsing and behavior when editing any comment.
238
- - The project's own idioms: `AGENTS.md`/`CLAUDE.md`/lint config beat a
239
- generic idiom; clarity beats fewer lines; nested ternaries are flattened,
240
- never introduced.
241
-
242
- ## 6. Pitfalls
243
- - Missing toolchain engine → `installHint` only; continue other engines and
244
- report that engine's check as blocked, not clean.
245
- - User declines downloads → skip those engines; say so.
246
- - Tests/typecheck fail after apply → stop and undo only this run's edits with
247
- targeted patches while preserving prior or concurrent work. Never use
248
- automatic `git checkout`, `reset`, `restore`, or `stash` as rollback. If the
249
- edits cannot be separated safely, leave them intact and report the blocker.
250
- Do not continue until the affected verification is green again.
251
- - Formatter config missing and the user did not ask to add one → tidy
252
- defaults / detected engines; never write a config file.
253
- - Structural engine unavailable (missing or outdated mixdog-graph) → `check` /
254
- `fix` fail with a rebuild remedy; `scan` still succeeds and names the binary
255
- in `notes`. Retry with `structural:false` for formatters/linters only; never
256
- treat missing structural matches as clean. A per-language rule-pack error
257
- leaves only that language's structural pass unfinished; results for other
258
- languages and engines remain usable.
259
- - A selected area too large for one review → default to directory or
260
- responsibility partitions for every layer, one complete round at a time.
261
- The inventory grows across rounds, not up front. Do not infer a smaller
262
- scope from a diff or ask for commits to divide the review.
263
- - A dead-code scanner report is a candidate list, not proof → verify per
264
- `references/dead-code.md` before deleting.
265
-
266
- ## 7. Round close and final report
267
- Close each round in the conversation with a few lines: the partition, its test
268
- lane, what landed, the verification result including every check that could not
269
- run, the round's function counts over 50, 100 and 150 lines (taken from the
270
- function-length summary in the `tidy` check/fix result), and whether the
271
- round is complete or unfinished. Report all three counts: decomposition moves
272
- mass downward, so functions over 100 falling while functions over 50 rise is
273
- progress, and a single threshold hides it. Keep the inventory in `references/cleanup-report.md` form as you go;
274
- do not spend a full report on every round.
275
-
276
- Deliver the full report once, after the last partition, using the
277
- reconciliation, completion criteria, and report template in
278
- `references/cleanup-report.md`. It carries one consolidated list of everything
279
- that needs the user's decision — RISKY findings, bugs found, unresolved intent,
280
- unfinished candidates — so those questions arrive together at the end instead
281
- of interrupting the cycle. Do not create a separate report file unless
282
- requested.
283
-
284
- Interrupt the cycle only for a blocker that makes continuing impossible or an
285
- approval the active workflow requires.
286
-
287
- ## 8. References
288
- - `references/agent-cleanup.md` — before section 4: behavior boundary, ladder,
289
- lenses, slop categories with keep/fix rules, risk tiers.
290
- - `references/test-suite-slop.md` — during section 4 when tests are in scope:
291
- redundant-coverage patterns and the evidence gate before deleting tests.
292
- - `references/cleanup-report.md` — before registering the first candidate and
293
- at section 7: inventory format, statuses, reconciliation, final report
294
- template.
295
- - `references/dead-code.md` — before removing any unused symbol, file, or
296
- dependency, or retiring a legacy path: candidate sources, usage and side-effect
297
- verification, compatibility retirement, never-dead list, removal order.
143
+ - An empty catch or ignored error that may be intentional: flag it.
144
+ - Complexity serving a current compatibility obligation, staged migration, or
145
+ vendored-code isolation (see legacy retirement in `dead-code.md`).
146
+ - License, copyright, SPDX notices; compiler, linter, bundler directives;
147
+ public API docs; security and compatibility explanations. Block comments
148
+ that may separate tokens or carry significant line breaks are left for
149
+ manual review.
150
+ - The project's own idioms (`AGENTS.md`/`CLAUDE.md`/lint config) over generic
151
+ ones; clarity over fewer lines; nested ternaries are flattened, never added.
152
+
153
+ ## 7. Pitfalls
154
+ - Missing engine: `installHint` only; continue others; that check is blocked.
155
+ - User declines downloads: skip those engines and say so.
156
+ - Structural engine unavailable (missing or outdated mixdog-graph): `check`/
157
+ `fix` fail with a rebuild remedy; `scan` still works. Retry with
158
+ `structural:false` for formatters/linters only; missing structural matches
159
+ are never clean. A per-language rule-pack error leaves only that language
160
+ unfinished.
161
+ - A dead-code scanner report is a candidate list, not proof; verify per
162
+ `references/dead-code.md`.
163
+
164
+ ## 8. Reporting
165
+ Report once, after the last partition, using `references/cleanup-report.md`.
166
+ Put everything needing the user's decision in one list at the end: RISKY
167
+ findings, bugs found, unresolved intent, unfinished candidates. Do not pause
168
+ between partitions except for a blocker or a required approval. No separate
169
+ report file unless requested.
@@ -40,7 +40,7 @@ evidence as `kept`.
40
40
  ## Deletion ladder
41
41
 
42
42
  Run the ladder on every selected unit (function, class, module, config knob)
43
- in the current round before looking for smells. Only code that lands on the
43
+ in scope before looking for smells. Only code that lands on the
44
44
  last rung goes on to the lenses.
45
45
 
46
46
  | Rung | Question | Typical win |
@@ -55,7 +55,7 @@ in-place cleanup; take it before analysing the unit's smells.
55
55
 
56
56
  ## Lenses
57
57
 
58
- Each lens judges the current partition's units and may search the whole
58
+ Each lens judges the units in scope and may search the whole
59
59
  repository for evidence (an existing helper, a sibling call site); a finding
60
60
  without a path-plus-symbol pointer is dropped. Run every lens unless the user named a focus.
61
61
  Judge each selected function or class in its full context, including relevant
@@ -116,8 +116,8 @@ Every finding carries one tier:
116
116
 
117
117
  | Tier | Meaning | Examples | Handling |
118
118
  |---|---|---|---|
119
- | SAFE | equivalence established, including initialization and parsing | verified unused binding with no initialization effects, nonsemantic comment, redundant type assertion | apply as one batch; verify the affected behavior without repeating unchanged checks |
120
- | CAREFUL | same semantics, structure changes | rename a local, flatten a ternary, guard clause, verified wrapper inlining, extract a helper, split responsibilities while preserving entry points, consolidate duplicates, name a magic number | apply one source unit at a time (including required new modules); targeted verification at behavior boundaries, final checks once; undo only this run's edits on failure |
119
+ | SAFE | equivalence established, including initialization and parsing | verified unused binding with no initialization effects, nonsemantic comment, redundant type assertion | apply as one batch |
120
+ | CAREFUL | same semantics, structure changes | rename a local, flatten a ternary, guard clause, verified wrapper inlining, extract a helper, split responsibilities while preserving entry points, consolidate duplicates, name a magic number | apply one source unit at a time (including required new modules); verified by the single final check; undo only this run's edits if it cannot be fixed |
121
121
  | RISKY | may change behavior or a contract | public API or export rename, route/DB column/config key rename, error-handling change, concurrency change, N+1 restructuring, altitude fix in shared infrastructure | report only, with the test coverage status; never auto-apply |
122
122
 
123
123
  Conflict resolution when lenses disagree: correctness > the user's stated