agent-steward 0.0.3 → 0.0.4

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 (171) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +3 -3
  3. package/ROADMAP-STRATEGY.md +9 -9
  4. package/ROADMAP.md +50 -34
  5. package/dist/core/dlq-api.d.ts +44 -0
  6. package/dist/core/dlq-api.d.ts.map +1 -0
  7. package/dist/core/dlq-api.js +68 -0
  8. package/dist/core/dry-run.d.ts.map +1 -1
  9. package/dist/core/dry-run.js +18 -1
  10. package/dist/core/lock.d.ts +20 -4
  11. package/dist/core/lock.d.ts.map +1 -1
  12. package/dist/core/lock.js +97 -22
  13. package/dist/core/one-shot.d.ts +5 -1
  14. package/dist/core/one-shot.d.ts.map +1 -1
  15. package/dist/core/one-shot.js +33 -8
  16. package/dist/core/opencode-cli.d.ts +28 -0
  17. package/dist/core/opencode-cli.d.ts.map +1 -0
  18. package/dist/core/opencode-cli.js +74 -0
  19. package/dist/core/opencode-models.d.ts +62 -0
  20. package/dist/core/opencode-models.d.ts.map +1 -0
  21. package/dist/core/opencode-models.js +277 -0
  22. package/dist/core/ps-wrapper.d.ts +1 -1
  23. package/dist/core/ps-wrapper.d.ts.map +1 -1
  24. package/dist/core/ps-wrapper.js +11 -1
  25. package/dist/core/record-history.d.ts +15 -0
  26. package/dist/core/record-history.d.ts.map +1 -1
  27. package/dist/core/record-history.js +56 -32
  28. package/dist/core/router/dispatch.d.ts +36 -0
  29. package/dist/core/router/dispatch.d.ts.map +1 -0
  30. package/dist/core/router/dispatch.js +59 -0
  31. package/dist/core/router/escalation.d.ts +47 -0
  32. package/dist/core/router/escalation.d.ts.map +1 -0
  33. package/dist/core/router/escalation.js +87 -0
  34. package/dist/core/router/planner.d.ts +53 -0
  35. package/dist/core/router/planner.d.ts.map +1 -0
  36. package/dist/core/router/planner.js +113 -0
  37. package/dist/core/router/rules.d.ts +46 -0
  38. package/dist/core/router/rules.d.ts.map +1 -0
  39. package/dist/core/router/rules.js +85 -0
  40. package/dist/core/run-panel-api.d.ts +94 -0
  41. package/dist/core/run-panel-api.d.ts.map +1 -0
  42. package/dist/core/run-panel-api.js +169 -0
  43. package/dist/core/schedule-gate.js +5 -1
  44. package/dist/core/schedule-v2.d.ts +34 -0
  45. package/dist/core/schedule-v2.d.ts.map +1 -1
  46. package/dist/core/schedule-v2.js +91 -5
  47. package/dist/core/scheduler/at-fallback.d.ts +55 -2
  48. package/dist/core/scheduler/at-fallback.d.ts.map +1 -1
  49. package/dist/core/scheduler/at-fallback.js +135 -5
  50. package/dist/core/scheduler/linux.d.ts +10 -1
  51. package/dist/core/scheduler/linux.d.ts.map +1 -1
  52. package/dist/core/scheduler/linux.js +29 -11
  53. package/dist/core/scheduler/posix.d.ts.map +1 -1
  54. package/dist/core/scheduler/posix.js +25 -1
  55. package/dist/core/scheduler/registry.d.ts +11 -0
  56. package/dist/core/scheduler/registry.d.ts.map +1 -1
  57. package/dist/core/scheduler/registry.js +83 -21
  58. package/dist/core/scheduler/run-now.d.ts +16 -0
  59. package/dist/core/scheduler/run-now.d.ts.map +1 -0
  60. package/dist/core/scheduler/run-now.js +28 -0
  61. package/dist/core/secrets.d.ts.map +1 -1
  62. package/dist/core/secrets.js +125 -28
  63. package/dist/core/session.d.ts.map +1 -1
  64. package/dist/core/session.js +18 -11
  65. package/dist/core/task-name.d.ts +24 -0
  66. package/dist/core/task-name.d.ts.map +1 -0
  67. package/dist/core/task-name.js +40 -0
  68. package/dist/core/wrappers/bash.d.ts.map +1 -1
  69. package/dist/core/wrappers/bash.js +49 -4
  70. package/dist/db/capability-repo.d.ts +83 -0
  71. package/dist/db/capability-repo.d.ts.map +1 -0
  72. package/dist/db/capability-repo.js +182 -0
  73. package/dist/db/history-repo.d.ts +8 -0
  74. package/dist/db/history-repo.d.ts.map +1 -1
  75. package/dist/db/history-repo.js +19 -0
  76. package/dist/db/index.d.ts +4 -0
  77. package/dist/db/index.d.ts.map +1 -1
  78. package/dist/db/index.js +39 -1
  79. package/dist/db/migrate.d.ts.map +1 -1
  80. package/dist/db/migrate.js +3 -1
  81. package/dist/db/run-context.d.ts +103 -0
  82. package/dist/db/run-context.d.ts.map +1 -0
  83. package/dist/db/run-context.js +224 -0
  84. package/dist/db/run-dlq.d.ts +100 -0
  85. package/dist/db/run-dlq.d.ts.map +1 -0
  86. package/dist/db/run-dlq.js +191 -0
  87. package/dist/db/run-resume.d.ts +5 -2
  88. package/dist/db/run-resume.d.ts.map +1 -1
  89. package/dist/db/run-resume.js +30 -11
  90. package/dist/db/runs-repo.d.ts +13 -5
  91. package/dist/db/runs-repo.d.ts.map +1 -1
  92. package/dist/db/runs-repo.js +28 -5
  93. package/dist/db/schema.d.ts +2 -2
  94. package/dist/db/schema.d.ts.map +1 -1
  95. package/dist/db/schema.js +154 -2
  96. package/dist/db/settings-repo.d.ts +11 -0
  97. package/dist/db/settings-repo.d.ts.map +1 -1
  98. package/dist/db/settings-repo.js +25 -0
  99. package/dist/db/step-idempotency.d.ts +51 -0
  100. package/dist/db/step-idempotency.d.ts.map +1 -0
  101. package/dist/db/step-idempotency.js +136 -0
  102. package/dist/index.d.ts +4 -4
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +102 -4
  105. package/dist/rpc.d.ts +678 -0
  106. package/dist/rpc.d.ts.map +1 -1
  107. package/dist/rpc.js +235 -0
  108. package/dist/server.d.ts +31 -0
  109. package/dist/server.d.ts.map +1 -1
  110. package/dist/server.js +95 -35
  111. package/dist/types.d.ts.map +1 -1
  112. package/dist/types.js +7 -0
  113. package/dist/workspaces.d.ts +25 -3
  114. package/dist/workspaces.d.ts.map +1 -1
  115. package/dist/workspaces.js +43 -8
  116. package/docs/ARCHITECTURE.md +229 -5
  117. package/docs/CONCEPT.md +171 -91
  118. package/docs/EXECUTION-LOOP.md +196 -0
  119. package/docs/README.ru.md +2 -2
  120. package/docs/README.zh.md +3 -3
  121. package/docs/SAFETY.md +122 -0
  122. package/docs/SAVINGS.md +29 -0
  123. package/docs/SAVINGS.ru.md +29 -0
  124. package/docs/SAVINGS.zh.md +18 -0
  125. package/gui-experimental.cjs +8 -8
  126. package/locales/en.json +67 -0
  127. package/locales/ru.json +67 -0
  128. package/locales/zh.json +67 -0
  129. package/package.json +28 -3
  130. package/scripts/audit-bundle.mjs +215 -0
  131. package/src/core/dlq-api.ts +98 -0
  132. package/src/core/dry-run.ts +25 -1
  133. package/src/core/lock.ts +95 -22
  134. package/src/core/one-shot.ts +36 -8
  135. package/src/core/opencode-cli.ts +103 -0
  136. package/src/core/opencode-models.ts +315 -0
  137. package/src/core/ps-wrapper.ts +11 -1
  138. package/src/core/record-history.ts +75 -37
  139. package/src/core/router/dispatch.ts +94 -0
  140. package/src/core/router/escalation.ts +129 -0
  141. package/src/core/router/planner.ts +166 -0
  142. package/src/core/router/rules.ts +109 -0
  143. package/src/core/run-panel-api.ts +262 -0
  144. package/src/core/schedule-gate.ts +6 -2
  145. package/src/core/schedule-v2.ts +114 -5
  146. package/src/core/scheduler/at-fallback.ts +190 -5
  147. package/src/core/scheduler/linux.ts +32 -10
  148. package/src/core/scheduler/posix.ts +20 -1
  149. package/src/core/scheduler/registry.ts +107 -26
  150. package/src/core/scheduler/run-now.ts +32 -0
  151. package/src/core/secrets.ts +127 -27
  152. package/src/core/session.ts +23 -10
  153. package/src/core/task-name.ts +67 -0
  154. package/src/core/wrappers/bash.ts +49 -4
  155. package/src/db/capability-repo.ts +285 -0
  156. package/src/db/history-repo.ts +22 -0
  157. package/src/db/index.ts +37 -1
  158. package/src/db/migrate.ts +3 -1
  159. package/src/db/run-context.ts +370 -0
  160. package/src/db/run-dlq.ts +310 -0
  161. package/src/db/run-resume.ts +48 -12
  162. package/src/db/runs-repo.ts +30 -7
  163. package/src/db/schema.ts +154 -2
  164. package/src/db/settings-repo.ts +31 -0
  165. package/src/db/step-idempotency.ts +185 -0
  166. package/src/gui.tsx +515 -0
  167. package/src/index.ts +124 -4
  168. package/src/rpc.ts +251 -0
  169. package/src/server.ts +112 -36
  170. package/src/types.ts +9 -0
  171. package/src/workspaces.ts +58 -9
@@ -1 +1 @@
1
- {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,UAO5B,CAAC;AAIF;;;GAGG;AACH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S,CAI9D;AAED,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM/E;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA6ChE;AAED,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAkElF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAenD;AAED,kDAAkD;AAClD,wBAAgB,eAAe,IAAI,MAAM,CAGxC"}
@@ -87,22 +87,42 @@ export function readWorkspaceEnvFile(envFile) {
87
87
  return {};
88
88
  }
89
89
  }
90
+ /** Ошибка конфигурации: в env workspace остались неразрешённые `${secret:NAME}`. */
91
+ export class MissingWorkspaceSecretsError extends Error {
92
+ constructor(workspaceName, secrets) {
93
+ super(`Workspace "${workspaceName}": не найдены секреты: ${secrets.join(", ")}. ` +
94
+ "Запуск отменён, чтобы не подставлять литералы ${secret:...} в окружение задачи.");
95
+ this.name = "MissingWorkspaceSecretsError";
96
+ this.workspaceName = workspaceName;
97
+ this.secrets = secrets;
98
+ }
99
+ }
90
100
  /**
91
- * Итоговые env-переменные workspace: сначала .env-файл, затем явные пары
92
- * (пары важнее файла). Ссылки `${secret:NAME}` разворачиваются из
93
- * зашифрованного хранилища (Спринт 26); отсутствующий секрет даёт пустую
94
- * строку и предупреждение с именем — без значения. Никогда не бросает.
101
+ * Итоговые env-переменные workspace вместе со списком отсутствующих секретов.
102
+ * Ссылки `${secret:NAME}` не подменяются пустой строкой: имя попадает в
103
+ * `missing`, а сама ссылка остаётся в env — вызывающая сторона решает,
104
+ * прервать запуск или только предупредить.
95
105
  */
96
- export function resolveWorkspaceEnv(workspace, allowedSecretNames) {
106
+ export function resolveWorkspaceEnvDetailed(workspace, allowedSecretNames) {
97
107
  if (!workspace)
98
- return {};
108
+ return { env: {}, missing: [] };
99
109
  const merged = {
100
110
  ...readWorkspaceEnvFile(workspace.envFile),
101
111
  ...(workspace.env ?? {}),
102
112
  };
103
113
  const resolved = resolveSecretRefs(merged, allowedSecretNames);
114
+ return { env: resolved.env, missing: resolved.missing };
115
+ }
116
+ /**
117
+ * Итоговые env-переменные workspace: сначала .env-файл, затем явные пары
118
+ * (пары важнее файла). Отсутствующий секрет даёт предупреждение с именем,
119
+ * но не значение. Никогда не бросает — для запуска задачи используйте
120
+ * writeWorkspaceEnvFile(), который в этом случае отказывает.
121
+ */
122
+ export function resolveWorkspaceEnv(workspace, allowedSecretNames) {
123
+ const resolved = resolveWorkspaceEnvDetailed(workspace, allowedSecretNames);
104
124
  if (resolved.missing.length > 0) {
105
- console.warn(`[workspace] "${workspace.name}": не найдены секреты: ${resolved.missing.join(", ")}`);
125
+ console.warn(`[workspace] "${workspace?.name ?? ""}": не найдены секреты: ${resolved.missing.join(", ")}`);
106
126
  }
107
127
  return resolved.env;
108
128
  }
@@ -142,12 +162,27 @@ export function workspaceEnvDir(pluginDir) {
142
162
  *
143
163
  * Возвращает путь к файлу или undefined, если у workspace нет переменных.
144
164
  * Пустой env удаляет ранее созданный файл. На POSIX права 0600.
165
+ *
166
+ * Если хотя бы один `${secret:NAME}` не разрешён, старый env-файл удаляется
167
+ * и бросается MissingWorkspaceSecretsError: задача не должна запускаться с
168
+ * литералом `${secret:...}` вместо значения (P2-21).
145
169
  */
146
170
  export function writeWorkspaceEnvFile(workspace, pluginDir, sanitizedName, allowedSecretNames) {
147
171
  if (!workspace)
148
172
  return undefined;
149
173
  const file = join(workspaceEnvDir(pluginDir), `${sanitizedName}.env`);
150
- const env = resolveWorkspaceEnv(workspace, allowedSecretNames);
174
+ const { env, missing } = resolveWorkspaceEnvDetailed(workspace, allowedSecretNames);
175
+ if (missing.length > 0) {
176
+ // Fail closed: не оставляем старый файл, иначе обёртка продолжит
177
+ // подхватывать устаревшие значения секретов.
178
+ try {
179
+ rmSync(file, { force: true });
180
+ }
181
+ catch {
182
+ // файла нет — не ошибка
183
+ }
184
+ throw new MissingWorkspaceSecretsError(workspace.name, missing);
185
+ }
151
186
  const keys = Object.keys(env);
152
187
  if (!keys.length) {
153
188
  try {
@@ -141,6 +141,14 @@ cloud model — without involving a model for known step types.
141
141
  Агент хочет прочитать файл → роутер смотрит в таблицу → видит `direct + local` →
142
142
  выполняет напрямую, без MCP, без модели.
143
143
 
144
+ Реализация (Спринт 36.5.a): `src/core/router/rules.ts` — замороженная таблица
145
+ `STATIC_ROUTE_RULES`, `routeStaticStep(taskType)` (нормализует `Run Tests` /
146
+ `run-tests` → `run_tests`), `isStaticTaskType`, `listStaticRouteRules`.
147
+ Модуль не импортирует ни БД, ни модель, ни транспорт, поэтому горячий путь
148
+ физически не может стоить токенов; неизвестный тип возвращает `undefined` и
149
+ передаётся слою 2. Покрытие — `test-router-rules.mjs` (22 проверки, включая
150
+ 1000 маршрутизаций быстрее 50 мс).
151
+
144
152
  ### Слой 2 — Capability Map (0 токенов, быстро)
145
153
 
146
154
  SQLite-таблица `task_type → model / success_rate / avg_cost / avg_time /
@@ -152,6 +160,15 @@ last_10_runs`. Обучается на исходах гейта (CONCEPT §9 le
152
160
  Это и есть learning loop: роутер учится на гейтах и становится точнее без затрат
153
161
  токенов на само решение.
154
162
 
163
+ Реализация (Спринт 36.5.b): `src/db/capability-repo.ts`, таблица `capability_map`
164
+ (`SCHEMA_VERSION = 6`). `recordCapabilityOutcome` обновляет счётчики, считает
165
+ `success_rate` и скользящие средние стоимости/времени, хранит `last_10_runs`
166
+ (JSON, новые справа). `decideCapabilityRoute` решает по правилам:
167
+ меньше `MIN_RUNS_FOR_DECISION = 3` исходов → `explore` (решает слой 3),
168
+ `≥ 0.85` → `local`, `≤ 0.30` → `cloud`, между порогами → `review`. Пороги
169
+ передаются параметром, поэтому политика меняется без миграции данных.
170
+ Покрытие — `test-capability-map.mjs`.
171
+
155
172
  ### Слой 3 — локальная модель (только декомпозиция и неоднозначность)
156
173
 
157
174
  Модель не маршрутизирует каждый шаг. Она только:
@@ -160,6 +177,12 @@ last_10_runs`. Обучается на исходах гейта (CONCEPT §9 le
160
177
 
161
178
  После этого каждый шаг проходит через Слой 1 и Слой 2.
162
179
 
180
+ **Реализация (Спринт 36.5.c):** `src/core/router/planner.ts`. `planMission(mission, { decomposer, maxSteps })` вызывает декомпозер — локальную модель — один раз на миссию и нормализует типы через `normalizeTaskType`; без декомпозера работает `decomposeHeuristically` по ключевым словам, без сети и модели. `planMissionSync` — вариант для синхронных мест. Шаг плана содержит только `stepName` и `taskType`, маршрут по-прежнему выбирают слои 1–2; типы вне статических правил собираются в `ambiguousTaskTypes` для `decideCapabilityRoute`. Пустая миссия, пустой или битый план модели — ошибка, а не молчаливый план. Покрытие — `test-planner.mjs`.
181
+
182
+ **Реализация (Спринт 36.5.d):** `escalateAfterGate(current, gate)` в `src/core/router/escalation.ts` решает судьбу шага по одному флагу `passed` и таблице переходов `local → cloud → review → blocked`. Модуль не импортирует ни БД, ни модель, ни сеть: это чистые функции (`nextGateTarget`, `isEscalationExhausted`, `escalationChain`), поэтому 1000 решений стоят доли миллисекунды. Переход в `blocked` означает, что автоматических уровней больше нет и нужен человек.
183
+
184
+ Слои 1–2 собираются в `routeStep(taskType, thresholds)` из `src/core/router/dispatch.ts`: сначала статическое правило (0 токенов), затем Capability Map. Для `review` и `explore` маршрут возвращается без транспорта и исполнителя — исполнять пока нечего. Модуль не импортирует `planner`, поэтому известный тип задачи не может случайно дойти до модели; это закреплено тестом `test-router-dispatch.mjs`, который также проверяет, что статика не оставляет записей в `capability_map` и работает ещё до инициализации БД.
185
+
163
186
  ### Эскалация
164
187
 
165
188
  При провале гейта роутер эскалирует в облако **по правилу**, без участия модели.
@@ -202,7 +225,12 @@ last_10_runs`. Обучается на исходах гейта (CONCEPT §9 le
202
225
  | `src/core/cron-to-schtasks.ts` | Cron → Task Scheduler translation |
203
226
  | `src/core/schedule-v2.ts` | Extended cron parser/matcher, timezone math, launch windows, poll-mode decisions |
204
227
  | `src/core/schedule-gate.ts` | Wrapper-side gate: cron re-check (poll mode), window postpone, defer-file |
205
- | `src/db/` | SQLite access: schema, migrations, repositories, recovery; `runs-repo.ts` keeps durable `runs`/`run_steps` state, `run-journal.ts` writes transitions around each step, `run-resume.ts` continues a crashed chain |
228
+ | `src/db/` | SQLite access: schema, migrations, repositories, recovery; `runs-repo.ts` keeps durable `runs`/`run_steps` state, `run-journal.ts` writes transitions around each step, `run-resume.ts` continues a crashed chain, `step-idempotency.ts` replays steps by key, `run-dlq.ts` parks deterministically failed steps |
229
+ | `src/core/router/rules.ts` | Router layer 1: static rules task type → transport + executor, normalization, no imports (0 tokens) |
230
+ | `src/db/capability-repo.ts` | Router layer 2: Capability Map - gate outcomes per task type, success_rate, moving averages, last 10 runs, threshold decision |
231
+ | `src/core/router/planner.ts` | Router layer 3: mission decomposition (model once per mission) and heuristic fallback, steps carry type only, routing stays in layers 1-2 |
232
+ | `src/core/router/dispatch.ts` | Router assembly: `routeStep` runs layer 1 then layer 2 and returns transport/executor, never imports the planner |
233
+ | `src/core/router/escalation.ts` | Gate failure escalation `local → cloud → review → blocked` by pure transition table, no DB, no model |
206
234
  | `src/shared/jobs-view.ts` | Task view shared by the GUI and dashboard |
207
235
 
208
236
  ## Scheduling backends
@@ -355,7 +383,7 @@ the whole plugin directory (database, logs, locks, wrappers, prompts) with
355
383
 
356
384
  Schema evolution is additive: `applySchema` runs `CREATE TABLE IF NOT EXISTS` on every
357
385
  connection and adds missing columns after `PRAGMA table_info`, so upgrading the plugin
358
- never requires a manual migration. `SCHEMA_VERSION` (currently `3`) is stored in
386
+ never requires a manual migration. `SCHEMA_VERSION` (currently `6`) is stored in
359
387
  `PRAGMA user_version`; incremental steps live in `MIGRATIONS`.
360
388
 
361
389
  ### Durable run state (Sprint 36.1)
@@ -371,8 +399,8 @@ execution:
371
399
  `src/db/runs-repo.ts` owns the transitions and rejects invalid ones
372
400
  (`InvalidTransitionError`). A failed step can be retried explicitly (`retryStep`),
373
401
  which increments `attempt` and returns it to `running`. The tables survive process
374
- crashes and reconnects, which is the prerequisite for resume (36.2) and
375
- idempotent steps (36.3).
402
+ crashes and reconnects, which is the prerequisite for resume (36.2),
403
+ idempotent steps (36.3) and the dead letter queue (36.4).
376
404
 
377
405
  `src/db/run-journal.ts` (Sprint 36.1.b) writes every transition to disk before
378
406
  and after executing the step body: `beginStepAttempt` commits `running` + `started_at`
@@ -411,13 +439,165 @@ failure, but the run still ends `failed`. This is covered by
411
439
  `test-run-resume.mjs`, including a real `kill -9` in the middle of a four-step
412
440
  chain.
413
441
 
442
+ The crash path is also exercised nightly by `test-chaos-dag.mjs`: a child process
443
+ runs a four-step chain, the parent sends `SIGKILL` right after the next step has
444
+ committed `running`, and the test then verifies the durable state (`passed` steps
445
+ are untouched, the victim is `running` with `attempt = 1`, later steps are
446
+ `pending`), `PRAGMA integrity_check = ok`, recovery to `failed` with
447
+ `attempt = 1`, and a resume that retries the victim with `attempt = 2` and never
448
+ re-invokes handlers of completed steps. `.github/workflows/nightly.yml` runs it
449
+ on a schedule on Windows and Ubuntu; locally it is `npm run test:chaos`.
450
+
451
+ ### Idempotent steps (Sprint 36.3)
452
+
453
+ `run_steps.idempotency_key` is unique per run: schema v4 deduplicates legacy
454
+ duplicates (keeping the first row, nulling the rest) and replaces the old
455
+ non-unique index with the partial unique index `idx_run_steps_key_unique
456
+ (run_id, idempotency_key) WHERE idempotency_key IS NOT NULL`. The index is
457
+ created in the migration, after the dedupe — the same ordering trap as
458
+ `position`.
459
+
460
+ `src/db/step-idempotency.ts` exposes `runStepOnce` / `runStepOnceAsync`:
461
+
462
+ 1. a key that belongs to another step in the same run is rejected with
463
+ `IdempotencyConflictError`;
464
+ 2. an already `passed`/`skipped` step is **replayed** from `output_json` — the
465
+ body is not called, `attempt` does not grow and no side effect repeats
466
+ (`replayed: true`, `executed: false`);
467
+ 3. a `failed` step is retried with `attempt + 1`, so a transient error does not
468
+ turn into a permanent skip;
469
+ 4. a `running` step, or a second call for the same key while the first is still
470
+ inside the body, raises `StepInFlightError` — the in-process `inFlight` set
471
+ covers parallel async calls, the unique index covers the database;
472
+ 5. a missing step is created with the key, then executed through the journal
473
+ from 36.1.b.
474
+
475
+ The same key is allowed in different runs; `test-step-idempotency.mjs` covers
476
+ first execution, replay from cache (including after reconnect), conflicts,
477
+ retry and parallel deduplication.
478
+
479
+ ### Dead letter queue (Sprint 36.4)
480
+
481
+ A step that fails on every attempt is not transient: resuming the run again just
482
+ burns another attempt and hides the real problem. Schema v5 adds `run_dlq`, the
483
+ durable queue of deterministically failed steps:
484
+
485
+ | Column | Purpose |
486
+ | --- | --- |
487
+ | `run_id`, `step_name` | Which step dead-lettered; cascade-deleted with the run |
488
+ | `status` | `open → retried` or `open → discarded` |
489
+ | `reason` | `attempts-exhausted` (automatic scan) or `manual` |
490
+ | `error`, `attempts` | Snapshot of the failure at the moment of enqueue |
491
+ | `resolved_at`, `resolution` | When and how the entry was closed (`manual-retry`, `discarded`) |
492
+
493
+ `src/db/run-dlq.ts` provides:
494
+
495
+ 1. `scanDeadLetters({ runId?, minAttempts = 3, limit })` selects steps with
496
+ `status = failed` and `attempt >= threshold` and enqueues only new ones. The
497
+ partial unique index `idx_run_dlq_open_unique (run_id, step_name) WHERE
498
+ status = 'open'` makes enqueue idempotent, so a repeated scan does not create
499
+ duplicates.
500
+ 2. `retryDeadLetter(id)` is the manual retry: it reopens the failed run, calls
501
+ `retryStep` (attempt + 1, step back to `running`) and closes the entry as
502
+ `retried` with `resolution = manual-retry`. Closed entries cannot be retried
503
+ or discarded twice.
504
+ 3. `discardDeadLetter(id, resolution = "discarded")` closes the entry without
505
+ touching the step — the run stays failed.
506
+ 4. `listDeadLetters` / `countDeadLetters` filter `open` or `all` for dashboards
507
+ (36.6) and metrics.
508
+
509
+ `retryDeadLetter` calls `reopenRun` and `retryStep`, which each open their own
510
+ transaction. `withTransaction` therefore nests through `SAVEPOINT` when a
511
+ transaction is already active, keeping the whole retry atomic instead of failing
512
+ with `cannot start a transaction within a transaction`. `test-run-dlq.mjs`
513
+ covers the threshold, idempotent scans, manual retry, discard, cascade delete,
514
+ reconnect and the v4 → v5 migration.
515
+
516
+ ### Dead letter queue in the GUI (Sprint 36.6)
517
+
518
+ The side panel exposes the queue through `src/core/dlq-api.ts`, a thin facade
519
+ that normalises the filter (`open` by default, plus `all`/`retried`/`discarded`)
520
+ and clamps the limit, then calls `listDeadLetters` / `retryDeadLetter` /
521
+ `discardDeadLetter`. RPC methods `list_dlq`, `retry_dlq` and `discard_dlq` are
522
+ declared in `src/rpc.ts` and handled in `src/index.ts`; the two mutations are
523
+ audited as `dlq.retry` and `dlq.discard`. `retry_dlq` only prepares the step
524
+ (reopen + `attempt + 1` + entry closed) — the handler itself is executed by a
525
+ later resume, so the panel never claims a step has already run. The UI section
526
+ shows the open count, status filter, creation time, run/step, reason, attempts,
527
+ error and status-aware actions; retry and discard ask for confirmation and
528
+ refresh the list through the same facade. `test-dlq-gui.mjs` checks the RPC/GUI
529
+ wiring, locale parity and the facade behaviour on a temporary SQLite database.
530
+
531
+ ### Pause with context injection (Sprint 36.7)
532
+
533
+ The durable run model gains a new table `run_injections` (`SCHEMA_VERSION = 7`, migration step 7)
534
+ with columns `id`, `run_id` (cascade delete from `runs`), `step_name`, `kind` (`comment` /
535
+ `file` / `artifact`), `content`, `author`, `metadata_json`, `created_at`, `consumed_at`,
536
+ `consumed_by_step`, `consumed_attempt`, plus indexes `idx_run_injections_run(run_id, created_at)`
537
+ and a partial index `idx_run_injections_pending(run_id, step_name) WHERE consumed_at IS NULL`.
538
+
539
+ A run can be paused between steps: `RunStatus` gains `paused` with transitions
540
+ `pending → running/paused/cancelled`, `running → paused/passed/failed/cancelled`,
541
+ `paused → running/passed/cancelled`. `pauseRunRecord(id)` sets `paused` without filling
542
+ `finished_at`. `pauseRun(runId, input)` in `src/db/run-context.ts` requires an existing,
543
+ non-terminal run with no step currently `running`, addresses the first unfinished step (or an
544
+ explicit `stepName`), rejects completed/missing targets, and stores one injection per provided
545
+ payload (`comment`, `file` with path/content/title, `artifact` with name/content). Secrets are
546
+ masked on write: `redactSecretsInText` covers text/comment/file content, and a recursive
547
+ `redactValue` with `SENSITIVE_KEY_RE` masks whole values of sensitive JSON keys
548
+ (`*TOKEN*`, `*SECRET*`, `*PASSWORD*`, `*API_KEY*`, `*CREDENTIAL*`, `*AUTH*`, ...) to `***`.
549
+ A single injection is capped at `MAX_INJECTION_CONTENT` (100 kB).
550
+
551
+ `listRunInjections(runId, { pendingOnly })` returns history ordered by creation time, exposing
552
+ author, masked content and consumption state. `pendingInjectionsForStep(runId, stepName)` returns
553
+ the not-yet-consumed injections addressed to a step.
554
+
555
+ `StepHandler` now receives `(step, context: StepContext)` where `StepContext.injections` holds
556
+ the injections for that step. `resumeRunSync` / `resumeRun` pass them before executing each step,
557
+ and after a successful step call `consumeInjections(ids, stepName, attempt)` to mark the
558
+ injections consumed exactly once (retry keeps them for the next attempt). `finalize` calls
559
+ `consumeOrphanInjections` so injections addressed to already-completed steps do not look pending
560
+ in the history, and supports `paused → passed` when no steps remain. `ResumeResult` gains
561
+ `injected: string[]`. `test-run-context.mjs` covers schema v7, pause-before-start / pause-between
562
+ steps / explicit targeting, comment + file + artifact with secret masking and author visibility,
563
+ single-consumption on resume, repeated resume without re-delivery, pause without context,
564
+ validation errors (missing/completed/running target, terminal run, no unfinished steps, empty
565
+ path, artifact without content, oversized content), async resume and cascade delete on run
566
+ removal.
567
+
568
+ ### Pause and resume in the GUI (Sprint 36.8)
569
+
570
+ `src/core/run-panel-api.ts` is the GUI-facing facade over durable runs. `listRunPanel({ filter, limit })`
571
+ accepts `active` (pending/running/paused/failed), `all`, or a concrete run status, normalizes the
572
+ limit to 1..100 and returns compact `RunPanelRun` entries: status, progress (`doneSteps` /
573
+ `totalSteps`), first unfinished `currentStep` with a stable `anchor`, up to 20 context injections
574
+ (content preview capped at 500 characters, author, timestamps, consumer) and the count of pending
575
+ injections. `active` is also reported for the panel badge.
576
+
577
+ `pauseRunPanel(runId, { comment, author, stepName? })` delegates to `pauseRun`, returning
578
+ `{ success: false, error }` instead of throwing, so the GUI can show the database error next to the
579
+ button. `resumeRunPanel(runId)` only prepares the run: it accepts `paused` or `failed`, calls
580
+ `reopenRun` (status becomes `running`), and returns the next unfinished step from `findResumeStep`.
581
+ Actual step execution remains with `resumeRun` / the DAG executor; the facade never pretends that a
582
+ step ran.
583
+
584
+ RPC methods `list_durable_runs`, `pause_durable_run` and `resume_durable_run` are declared in
585
+ `src/rpc.ts`, implemented in `src/index.ts`, and audited as `run.pause` / `run.resume` (target is the
586
+ run id). The GUI section «⏯️ Запуски DAG» in `src/gui.tsx` renders the run list with status filter,
587
+ progress, current-step anchor link, a comment field, pause/resume buttons with confirmation, a
588
+ blocked pause plus warning while the current step is `running`, and the context history with author
589
+ and consumer. Locales ru/en/zh stay in sync. `test-pause-gui.mjs` verifies the RPC contract, locale
590
+ parity, current-step/progress output, pause with masked comment and author, active/paused filters,
591
+ resume preparation, rejection of a repeated resume, end-to-end comment delivery through
592
+ `resumeRun`, running-step rejection, failed-run resume and list limits.
593
+
414
594
  ## Interfaces
415
595
 
416
596
  | Interface | Audience | Entry point |
417
597
  | --- | --- | --- |
418
598
  | Agent tools | AI agent | 26 tools registered via `ctx.tool.transform` |
419
599
  | Agent skill | AI agent | `skills/scheduled-job-best-practices` |
420
- | RPC | Sidebar GUI | `src/rpc.ts` contracts, 44 methods |
600
+ | RPC | Sidebar GUI | `src/rpc.ts` contracts, 47 methods |
421
601
  | Sidebar GUI | Human | `gui-experimental.cjs` |
422
602
  | Web dashboard | Human | `startDashboardServer` (localhost, random/fixed port) |
423
603
 
@@ -557,3 +737,47 @@ after the agent with the user's privileges and are not filtered by tool policy.
557
737
  | New agent tool | Add a zod schema + execute function, register in `ctx.tool.transform`, add an RPC contract |
558
738
  | New dashboard panel | Extend `server.ts` routes and the HTML template |
559
739
  | New matrix policy | Extend `MatrixConfig` in `task-transfer.ts` and the logic in `core/matrix.ts` |
740
+
741
+ ## Mission runtime и гибридные входы (план 38–40)
742
+
743
+ > Статус: спека. Что уже в коде, а что нет — [ROADMAP.md](../ROADMAP.md) §1.
744
+
745
+ Система гибридная: ядро (**mission runtime**) не знает про планировщик ОС.
746
+ Планировщик — адаптер входа, регистрация опциональна.
747
+
748
+ ### Классы входа
749
+
750
+ | Класс | Вход | Регистрация в ОС | Реализация |
751
+ |---|---|---|---|
752
+ | Ad-hoc | `run_mission` / CLI / GUI / RPC | нет | план 38 |
753
+ | Внутренний | chain / DAG / retry / escalation | нет | сейчас через `backend.runTask` + force-маркер; план 40 — напрямую в runtime |
754
+ | Registered | cron / once / file / git / mcp-event / webhook | да (cron/once) | есть: `core/scheduler/*`, `file-watcher`, `git-trigger`, `integrations` |
755
+
756
+ ### Объекты
757
+
758
+ | Объект | Содержимое | Таблица |
759
+ |---|---|---|
760
+ | Миссия | цель + scope + gate-спека + safety + бюджет | `missions` (план 38, опциональный шаблон) |
761
+ | Задача | миссия-шаблон + триггер | `tasks` (есть) |
762
+ | Запуск | durable-исполнение: шаги, попытки, вердикты | `runs` / `run_steps` (есть, SCHEMA_VERSION 7) |
763
+ | Исход гейта | вердикт + provenance + экономика | `gate_outcomes` (план 40) |
764
+
765
+ ### Путь исполнения (целевой)
766
+
767
+ ```
768
+ вход → intake (gate + safety → политика + бюджет) → createRun(trigger_kind)
769
+ → planner → [route → context compile → execute → GATE]* → artifact → report
770
+ ```
771
+
772
+ Существующий путь планировщика (`wrapper → opencode run → record-history → history`)
773
+ сохраняется для обратной совместимости; в 40 он подключается к runtime и создаёт
774
+ durable-run, а исходы гейта пишутся в ledger.
775
+
776
+ ### Что переиспользуется
777
+
778
+ - Durable state: `db/runs-repo`, `run-journal`, `run-resume`, `step-idempotency`, `run-context`.
779
+ - Роутинг: `core/router/rules|dispatch|escalation|planner`, `db/capability-repo`.
780
+ - Права и секреты: `core/permissions`, `core/secrets` (scoped-инъекция).
781
+ - Телеметрия: `core/otel`, `core/prometheus`, `core/structured-log`.
782
+ - Пауза с инъекциями: `db/run-context` + `core/run-panel-api` → основа approval-гейта.
783
+ - Retrieval для scaffolding: подход bag-of-words из `notification_embeddings`.