loki-mode 11.2.2 → 11.3.1

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 (216) hide show
  1. package/README.md +68 -650
  2. package/SKILL.md +4 -4
  3. package/VERSION +1 -1
  4. package/autonomy/completion-council.sh +2 -2
  5. package/autonomy/context-tracker.py +4 -4
  6. package/autonomy/council-v2.sh +1 -1
  7. package/autonomy/grill.sh +1 -1
  8. package/autonomy/lib/done-recognition.sh +1 -1
  9. package/autonomy/lib/prd-enrich.sh +1 -1
  10. package/autonomy/lib/skill-link-heal.sh +78 -1
  11. package/autonomy/lib/voter-agents.sh +1 -1
  12. package/autonomy/loki +99 -75
  13. package/autonomy/run.sh +30 -18
  14. package/autonomy/sandbox.sh +1 -1
  15. package/autonomy/tui.sh +6 -5
  16. package/autonomy/verify.sh +1 -1
  17. package/bin/loki +166 -59
  18. package/completions/_loki +2 -0
  19. package/completions/loki.bash +2 -2
  20. package/dashboard/__init__.py +1 -1
  21. package/dashboard/server.py +25 -31
  22. package/docs/ARCHITECTURE.md +337 -0
  23. package/docs/BRANDING.md +124 -0
  24. package/docs/CLI-REFERENCE.md +7 -1
  25. package/docs/COMPONENTS.md +447 -0
  26. package/docs/DEPLOYMENT.md +9 -9
  27. package/docs/DOCKER.md +469 -0
  28. package/docs/INSTALLATION.md +67 -1045
  29. package/docs/KNOWN-ISSUES.md +11 -35
  30. package/docs/TESTING.md +161 -0
  31. package/docs/air-gapped.md +1 -2
  32. package/docs/alternative-installations.md +14 -24
  33. package/docs/architecture/DECISIONS.md +333 -0
  34. package/docs/audit-logging.md +7 -7
  35. package/docs/authentication.md +3 -3
  36. package/docs/authorization.md +1 -1
  37. package/docs/certification/04-production-deployment/lab.md +6 -6
  38. package/docs/certification/04-production-deployment/lesson.md +4 -4
  39. package/docs/certification/README.md +1 -1
  40. package/docs/control-plane-container.md +2 -2
  41. package/docs/dev/real-run.md +34 -0
  42. package/docs/dev/release-checklist.md +2 -2
  43. package/docs/exit-codes.md +3 -3
  44. package/docs/git-workflow.md +3 -3
  45. package/docs/metrics.md +37 -55
  46. package/docs/network-security.md +1 -1
  47. package/docs/siem-integration.md +5 -5
  48. package/docs/v10/CLI-MODERN.md +4 -3
  49. package/docs/v10/DECISIONS.md +44 -0
  50. package/docs/v10/DEPS.md +22 -22
  51. package/docs/v10/ENGINE.md +1 -1
  52. package/docs/v10/FAILURE-CLASSES.md +129 -1
  53. package/docs/v10/FOUNDER-QUEUE.md +1 -0
  54. package/docs/v10/GUARDS.md +13 -0
  55. package/docs/v10/LEGACY-REMOVAL.md +4 -6
  56. package/docs/v10/METRICS.md +2 -2
  57. package/docs/v10/MODERNIZE.md +1 -1
  58. package/docs/v10/OPERATING-MODEL.md +2 -1
  59. package/docs/v10/PROGRESS.md +29 -0
  60. package/docs/v11/COST-HALF.md +352 -0
  61. package/docs/v11/MARKET-SLICES.md +315 -0
  62. package/docs/v11/REGISTRIES.md +730 -0
  63. package/loki-ts/data/model-pricing.json +52 -24
  64. package/loki-ts/dist/loki.js +1036 -957
  65. package/mcp/__init__.py +1 -1
  66. package/package.json +1 -1
  67. package/packages/control-plane/dist/server.js +2467 -736
  68. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  69. package/src/protocols/mcp-client.js +6 -2
  70. package/src/protocols/mcp-server.js +13 -3
  71. package/tools/audit-docs.py +1 -1
  72. package/web-app/dist/assets/{AdminPage-C-iMLNxe.js → AdminPage-CMkHNJbF.js} +1 -1
  73. package/web-app/dist/assets/{Avatar-C7VUvwsO.js → Avatar-BJyjV7Zi.js} +1 -1
  74. package/web-app/dist/assets/{Badge-tGvQEhnw.js → Badge-D572l0uq.js} +1 -1
  75. package/web-app/dist/assets/{Button-_iHlH_yL.js → Button-T4BnOZgl.js} +1 -1
  76. package/web-app/dist/assets/{CockpitPage-J_nNjbcR.js → CockpitPage-Cj_GFsNn.js} +1 -1
  77. package/web-app/dist/assets/{ComparePage-B05ui6Xt.js → ComparePage-A8m4ZXak.js} +1 -1
  78. package/web-app/dist/assets/{ErrorBoundary-Bxex6DLn.js → ErrorBoundary-hugCg5yg.js} +1 -1
  79. package/web-app/dist/assets/{EvidenceReceiptPanel-BsgWfdD1.js → EvidenceReceiptPanel-CuJKDC2G.js} +1 -1
  80. package/web-app/dist/assets/{GitHubIssuesPanel-DZBhZ8_X.js → GitHubIssuesPanel-BYGKjarC.js} +1 -1
  81. package/web-app/dist/assets/{GitHubPRsPanel-BaxlAl6R.js → GitHubPRsPanel-c7sFIJlf.js} +1 -1
  82. package/web-app/dist/assets/{HomePage-mVJvzqbF.js → HomePage-A1MIkG2P.js} +2 -2
  83. package/web-app/dist/assets/{LoginPage-B0zd4A_G.js → LoginPage-8KQMRhtR.js} +1 -1
  84. package/web-app/dist/assets/{MagicPage-DXLQ-y_R.js → MagicPage-C05QW2Lx.js} +1 -1
  85. package/web-app/dist/assets/{MetricsPage-CLS34Xvr.js → MetricsPage-Oukv5hme.js} +1 -1
  86. package/web-app/dist/assets/{NotFoundPage-BXG8PbNV.js → NotFoundPage-DKIwsawz.js} +1 -1
  87. package/web-app/dist/assets/{ProjectPage-D3kFFC0F.js → ProjectPage-DwFRPLCG.js} +3 -3
  88. package/web-app/dist/assets/{ProjectsPage-2bFn-gnC.js → ProjectsPage-CgY4YYDX.js} +1 -1
  89. package/web-app/dist/assets/{SettingsPage-CBM0ziWE.js → SettingsPage-BpfcSjUA.js} +1 -1
  90. package/web-app/dist/assets/{ShowcasePage-BTaXhjI3.js → ShowcasePage-BqBakC4K.js} +1 -1
  91. package/web-app/dist/assets/{SystemSettingsPage-BrC2hyAr.js → SystemSettingsPage-CZLu5VB0.js} +1 -1
  92. package/web-app/dist/assets/{TeamsPage-oqxdbVbY.js → TeamsPage-D55S1jKz.js} +1 -1
  93. package/web-app/dist/assets/{TemplatesPage-CEbUIY21.js → TemplatesPage-D3SydvxN.js} +1 -1
  94. package/web-app/dist/assets/{TerminalOutput-aIoWLbJA.js → TerminalOutput-hNg8G1-e.js} +1 -1
  95. package/web-app/dist/assets/{activity-CPyi45gt.js → activity-D2C0VagO.js} +1 -1
  96. package/web-app/dist/assets/{bell-BhaNBaJp.js → bell-CMvYi36w.js} +1 -1
  97. package/web-app/dist/assets/{bot-Da8REaEP.js → bot-BvtQ6lmo.js} +1 -1
  98. package/web-app/dist/assets/{check-DPj99ArM.js → check-B13xkXed.js} +1 -1
  99. package/web-app/dist/assets/{chevron-left-CkxonN0X.js → chevron-left-emu6r49E.js} +1 -1
  100. package/web-app/dist/assets/{circle-alert-C0JkB1y5.js → circle-alert-CExlwjuy.js} +1 -1
  101. package/web-app/dist/assets/{clock-COzFIiWi.js → clock-D7Uas3oL.js} +1 -1
  102. package/web-app/dist/assets/{cloud-bjkac4kn.js → cloud-CkB4S86C.js} +1 -1
  103. package/web-app/dist/assets/{code-xml-hlKlvXUJ.js → code-xml-SL9IIWIn.js} +1 -1
  104. package/web-app/dist/assets/{database-D555S5Km.js → database-BQFkd7t1.js} +1 -1
  105. package/web-app/dist/assets/{dollar-sign-CVcApzcD.js → dollar-sign-qHmnNYsU.js} +1 -1
  106. package/web-app/dist/assets/{file-code-corner-UORaMIcO.js → file-code-corner-C2YUDP0K.js} +1 -1
  107. package/web-app/dist/assets/{file-plus-ALJtDoI2.js → file-plus-C_ooIkDe.js} +1 -1
  108. package/web-app/dist/assets/{globe-CPlrM_IC.js → globe-CQ-GL485.js} +1 -1
  109. package/web-app/dist/assets/{hammer-qaGZHpja.js → hammer-U05L_D7V.js} +1 -1
  110. package/web-app/dist/assets/{index-BcXljIAO.js → index-CooHd7I-.js} +3 -3
  111. package/web-app/dist/assets/{layers-BV8R9VUK.js → layers-Buo17rjW.js} +1 -1
  112. package/web-app/dist/assets/{loader-circle-6TlDS9Tu.js → loader-circle-15vK3oV1.js} +1 -1
  113. package/web-app/dist/assets/{lock-B9t6oWI0.js → lock-BeXLebuJ.js} +1 -1
  114. package/web-app/dist/assets/{package-2gEUAtZJ.js → package-MVh_6-6R.js} +1 -1
  115. package/web-app/dist/assets/{plus-DXocxPjU.js → plus-Dh_nd9vS.js} +1 -1
  116. package/web-app/dist/assets/{refresh-cw-D3dWHBd6.js → refresh-cw-C9cBJEAT.js} +1 -1
  117. package/web-app/dist/assets/{rotate-ccw-CvuWqaSB.js → rotate-ccw-D3PAtzST.js} +1 -1
  118. package/web-app/dist/assets/{scroll-text-ktmD_xJY.js → scroll-text-DZCoXQjo.js} +1 -1
  119. package/web-app/dist/assets/{server-E7pZtj5A.js → server-OCOLI5J_.js} +1 -1
  120. package/web-app/dist/assets/{shield-alert-968j9z0V.js → shield-alert-oVhmf1_h.js} +1 -1
  121. package/web-app/dist/assets/{thumbs-up-Tz_8rpU_.js → thumbs-up-B-kbX4vN.js} +1 -1
  122. package/web-app/dist/assets/{trash-2-Drh9IIj8.js → trash-2-EL6moveW.js} +1 -1
  123. package/web-app/dist/assets/{trending-down-DCQXtVSL.js → trending-down-Cl3kjpsx.js} +1 -1
  124. package/web-app/dist/assets/{trending-up-BIiwQbWV.js → trending-up-DST7I6M2.js} +1 -1
  125. package/web-app/dist/assets/{upload-sCbPkfmy.js → upload-CUOT780G.js} +1 -1
  126. package/web-app/dist/assets/{usePolling-BMIg6ZVT.js → usePolling-Djmt90eb.js} +1 -1
  127. package/web-app/dist/assets/{user-kGzXC3V2.js → user-BRBohA6J.js} +1 -1
  128. package/web-app/dist/index.html +1 -1
  129. package/docs/ARCHITECTURE-OVERVIEW.md +0 -209
  130. package/docs/AUTONOMI-ECOSYSTEM.md +0 -107
  131. package/docs/COCKPIT-SPEC.md +0 -72
  132. package/docs/COCKPIT-UX-MANDATE.md +0 -53
  133. package/docs/COMPETITIVE-ANALYSIS.md +0 -303
  134. package/docs/COMPETITIVE-NEXT-10.md +0 -316
  135. package/docs/COMPETITIVE-RALPH-ZEROSHOT-2026-07-08.md +0 -81
  136. package/docs/DASHBOARD-9.12-EVIDENCE.md +0 -97
  137. package/docs/DASHBOARD-ARCHITECTURE.md +0 -425
  138. package/docs/DASHBOARD_V2_CHECKLIST.md +0 -243
  139. package/docs/DEMOS.md +0 -63
  140. package/docs/ENTERPRISE-IDENTITY-ROADMAP.md +0 -206
  141. package/docs/EVIDENCE-RECEIPT-BUILD-APPLICABILITY.md +0 -79
  142. package/docs/FEAT-PRDREUSE-DOCKER-PLAN.md +0 -144
  143. package/docs/GATE-FAILURE-TRIAGE.md +0 -254
  144. package/docs/HANDOFF-2026-08-03.md +0 -439
  145. package/docs/LOOP-CANDIDATE-PROPOSAL-v1.md +0 -167
  146. package/docs/LOOP-HARNESS-AUDIT.md +0 -684
  147. package/docs/MERGE-DEDUP-MAP.md +0 -420
  148. package/docs/MERGE-ROUTE-MAP.md +0 -139
  149. package/docs/MODEL-REGISTRY-PLAN.md +0 -155
  150. package/docs/OUTCOME-FRONTIER.md +0 -536
  151. package/docs/P2-SPEC-ROBUSTNESS-PLAN.md +0 -192
  152. package/docs/PLANS-INDEX.md +0 -32
  153. package/docs/PRD-REUSE-DONE-RECOGNITION-PLAN.md +0 -536
  154. package/docs/PROMPT-ABLATION-RESULT.md +0 -97
  155. package/docs/R4-TRUST-TRAJECTORY-DESIGN.md +0 -127
  156. package/docs/R5-AUTO-WIKI-DESIGN.md +0 -137
  157. package/docs/R6-ROLLBACK-CHECKPOINT-PLAN.md +0 -107
  158. package/docs/R7-ZERO-CONFIG-FIRST-RUN-PLAN.md +0 -137
  159. package/docs/R8-SHAREABLE-TEAM-ASSETS-PLAN.md +0 -129
  160. package/docs/R9-OPEN-CORE-HOOKS-PLAN.md +0 -113
  161. package/docs/RARV-C-100X-PLAN.md +0 -286
  162. package/docs/RARV-C-LOOP-EFFICIENCY-PLAN.md +0 -470
  163. package/docs/SHAREABLE-PROOF-PLAN.md +0 -194
  164. package/docs/SONNET5-DEFAULT-PLAN.md +0 -157
  165. package/docs/SPEED-AND-FIRST-PASS-PLAN.md +0 -281
  166. package/docs/STALE-STATE-AUDIT.md +0 -174
  167. package/docs/SYNERGY-TASKS.md +0 -143
  168. package/docs/TASKLIST-ACCURACY-PLAN.md +0 -355
  169. package/docs/TOP-100-BACKLOG.md +0 -159
  170. package/docs/V8-ACCEPTANCE-TRIAGE-2026-07-24.md +0 -114
  171. package/docs/V8-COMPLEXITY-AUDIT-2026-07-24.md +0 -45
  172. package/docs/V8-MAJOR-RELEASE-PLAN.md +0 -137
  173. package/docs/V8-OVERNIGHT-PLAN-2026-07-25.md +0 -82
  174. package/docs/V8-SDK-RESEARCH-RAW.md +0 -129
  175. package/docs/WELCOME-OPENER-PLAN.md +0 -106
  176. package/docs/adoption-baseline-2026-07-31.md +0 -84
  177. package/docs/architecture/bmad-integration-epic.md +0 -271
  178. package/docs/architecture/bmad-integration-review.md +0 -86
  179. package/docs/architecture/bmad-integration-validation.md +0 -249
  180. package/docs/architecture/bmad-loki-voice-agent-council-analysis.md +0 -61
  181. package/docs/auto-claude-comparison.md +0 -250
  182. package/docs/bug-fixes/agent-01-cli-fixes.md +0 -101
  183. package/docs/bug-fixes/agent-02-purplelab-fixes.md +0 -88
  184. package/docs/bug-fixes/agent-03-dashboard-fixes.md +0 -119
  185. package/docs/bug-fixes/agent-04-memory-fixes.md +0 -105
  186. package/docs/bug-fixes/agent-05-provider-fixes.md +0 -86
  187. package/docs/bug-fixes/agent-06-integration-fixes.md +0 -101
  188. package/docs/bug-fixes/agent-07-dash-run-fixes.md +0 -101
  189. package/docs/bug-fixes/agent-08-docker-fixes.md +0 -164
  190. package/docs/bug-fixes/agent-09-e2e-build-fixes.md +0 -69
  191. package/docs/bug-fixes/agent-10-e2e-fullstack-fixes.md +0 -102
  192. package/docs/bug-fixes/agent-11-e2e-session-fixes.md +0 -70
  193. package/docs/bug-fixes/agent-12-scenario-fixes.md +0 -120
  194. package/docs/bug-fixes/agent-13-enterprise-fixes.md +0 -143
  195. package/docs/bug-fixes/agent-14-uat-newuser-fixes.md +0 -88
  196. package/docs/bug-fixes/agent-15-uat-poweruser-fixes.md +0 -132
  197. package/docs/bug-fixes/agent-19-code-review.md +0 -316
  198. package/docs/bug-fixes/agent-20-architecture-review.md +0 -331
  199. package/docs/competitive/bolt-new-analysis.md +0 -579
  200. package/docs/competitive/emergence-others-analysis.md +0 -605
  201. package/docs/competitive/replit-lovable-analysis.md +0 -622
  202. package/docs/dashboard-guide.md +0 -487
  203. package/docs/enterprise/migration.md +0 -265
  204. package/docs/history/one-run-audit.md +0 -304
  205. package/docs/plans/FORGE-AUTONOMOUS-QUEUE.md +0 -312
  206. package/docs/plans/ULTRAPLAN-FORGE-BAAS.md +0 -612
  207. package/docs/plans/UT2-6-LSP-DIAGNOSTIC-BROADCAST.md +0 -394
  208. package/docs/prd-purple-lab-ide.md +0 -152
  209. package/docs/prd-purple-lab-platform-v2.md +0 -223
  210. package/docs/prd-purple-lab-platform.md +0 -319
  211. package/docs/retrospectives/v7.5.15-fleet-postmortem.md +0 -325
  212. package/docs/retrospectives/v7.5.15-honesty-audit.md +0 -136
  213. package/docs/retrospectives/v7.5.15-llm-failure-modes.md +0 -49
  214. package/docs/show-hn-post.md +0 -46
  215. package/docs/test-scenarios/enterprise-scenarios.md +0 -732
  216. package/docs/thick2thin.md +0 -173
@@ -0,0 +1,352 @@
1
+ # COST-HALF: Loki dollars per verified task against raw claude -p (D91 item 11)
2
+
3
+ Status: design, Architect draft 2026-10-08 rev 3 (D93 routing call in LD-01, PRICE-01 merged into PRICE-TRUTH, AS-01 mapped to the built CH-02). This revision folds in the paper survey
4
+ (autonomi-dev research/2026-10-08-cost-half/PAPERS.md) and the CTO slice order.
5
+ Moat order holds: Seal accuracy and Wall integrity come before every saving. No slice lets the implementer
6
+ see, read earlier, or edit the Wall checks. No slice skips wall, verify, commit, seal or pr.
7
+
8
+ ## 0. Honest target (for METRICS)
9
+
10
+ - Trivial and small tasks: about 0.5x raw per verified task. This is reachable because the gap is mostly
11
+ fixed overhead (cold sessions, prefix writes, effort). The lean arm already beats raw on small tasks:
12
+ 27/29 at $0.16 vs raw 27/29 at $0.24 (PROGRESS.md 2026-09-28T02:57Z; METRICS default arm 26/29 at $0.3946).
13
+ - Medium tasks: 0.6x to 0.8x raw, unless the cascade (rank 3) does better. PAPERS.md section 5 lands the
14
+ multiplicative stack near raw parity on medium. Half on medium needs Haiku carrying implement work, or a
15
+ much smaller token footprint than raw. Both are unproven.
16
+ - Every claim is a B9 row: raw arm vs Loki arm, n>=3, usd per SOLVED task (not mean per run), solve-rate
17
+ 95% CI, and p90 usd reported separately. A lever that drops the solve rate below raw's lower CI bound fails
18
+ regardless of savings (PAPERS.md section 6).
19
+
20
+ ## 1. Where the money goes (measured)
21
+
22
+ ### 1.1 Prices (PAPERS.md 1.1, claude.com pricing page read 2026-10-08), $/MTok
23
+
24
+ | model | input | 5m cache write | cache read | output |
25
+ |---|---|---|---|---|
26
+ | Opus 5.5 | 4.00 | 5.00 | 0.20 | 20.00 |
27
+ | Sonnet 5.5 | 2.00 | 2.50 | 0.10 | 10.00 |
28
+ | Haiku 5.5, prompt <= 100K | 0.10 | 0.125 | 0.01 | 0.50 |
29
+ | Haiku 5.5, prompt > 100K | 0.50 | 0.625 | 0.05 | 2.50 |
30
+
31
+ - Sonnet is 2x cheaper than Opus. Haiku is 20x cheaper than Sonnet, but only under 100K.
32
+ - Cache reads cost 0.05x input on Opus and Sonnet.
33
+ - The advisor tool definition alone is about 1,000 prompt tokens per request.
34
+ - Drift found: loki-ts/data/model-pricing.json says Opus is 5/25/0.5/6.25 and Sonnet's cache read is
35
+ 0.2. Run spend comes from the SDK's total_cost_usd (runner/sdk_stream_parser.ts:545), so measured runs are
36
+ not affected. Budget estimates in runner/budget.ts:65 do read the json. That is slice PRICE-01.
37
+
38
+ ### 1.2 Per-stage tokens (the only per-stage measurement on disk)
39
+
40
+ Source: docs/v10/METRICS.md "S41-04 Per-stage token table" (E-98f, claude-opus-5-5, 7 medium pub-* tasks,
41
+ raw files ~/loki-ci-logs/eval/e98f-engine/*/result-cost*.json). Mean per session, priced with 1.1:
42
+
43
+ | stage | n | cache_read | cache_write | output | Sonnet $ | Opus $ |
44
+ |---|---|---|---|---|---|---|
45
+ | intake already-done | 18 | 46,305 | 8,742 | 590 | 0.032 | 0.065 |
46
+ | plan | 36 | 44,547 | 8,784 | 2,038 | 0.047 | 0.094 |
47
+ | wall | 16 | 67,611 | 14,512 | 5,530 | 0.098 | 0.197 |
48
+ | implement mean | 58 | 982,144 | 33,750 | 10,893 | 0.292 | 0.583 |
49
+ | implement p50 | | 654,959 | | | 0.259 | 0.518 |
50
+ | fix round 1 | 10 | 116,340 | 10,765 | 2,256 | 0.061 | 0.122 |
51
+ | fix round 2 | 4 | 78,512 | 6,691 | 2,463 | 0.049 | 0.098 |
52
+
53
+ - Input tokens are under 60 per session, so they are negligible.
54
+ - Cache reads are 94.5% of all tokens.
55
+ - Time share: implement 72.5%, wall 23%. Wall hit its 90s limit in 9 of 21 runs.
56
+ - Implement plus wall are about 74% of a medium run's dollars: (0.292 + 0.098) / 0.530 at Sonnet prices.
57
+
58
+ ### 1.3 Lead-supplied totals (CH-M1 re-measures them per stage through scripts/real-run.sh)
59
+
60
+ - Trivial fixture: $0.09 to $0.11 across 4 cold sessions (project-model, intake, wall, implement). Intake takes 12 to 20s.
61
+ - Router on: +27% to +44%, with 0 advisor calls.
62
+ - FireLater#17: raw $0.40 vs Loki $1.73. The fixture receipt
63
+ (loki-ts/tests/fixtures/pr-body-firelater17/receipt.json) carries totals only.
64
+ - Project-model per-stage cost is NOT on disk. It stays unmeasured until CH-M1.
65
+
66
+ ### 1.4 Root causes, traced to code
67
+
68
+ 1. Effort. Implement, fix and wall run tier "development", which maps to effort high
69
+ (providers/claude_flags.ts:24, applied at runner/providers.ts:649). No engine10 stage sets opts.effort.
70
+ Raw runs Opus 5.5 at medium. Per unit of work, implement costs about 1.4x raw on the same model (PAPERS.md 1.2).
71
+ 2. Session graph. Four cold sessions on a normal task, each a separate process
72
+ (engine10/session.ts createSessionRunner). Each pays a first-turn prefix write of about 8.7K tokens
73
+ ($0.022 at Sonnet) and re-reads the files it needs. Resume exists only for fix and defaults off
74
+ (runner/session_resume.ts:38).
75
+ 3. The prefix is not shared even on one model. resolveSystemPrompt (providers.ts:680) sends the claude_code
76
+ preset with dynamic cwd and git sections, and wall runs in a mkdtemp cwd. LOKI_E10_PREFIX=lean
77
+ (providers.ts:624) defaults off. tests/e10ext/prefix_identity.test.ts guards only the first 200 bytes of
78
+ the brief, never system plus tools.
79
+ 4. The critical path is serial. Implement waits for wall (machine.ts:12-13 FLOW), and wall writes into
80
+ repoDir and base-runs there (wall.ts:195-203).
81
+ 5. Router overhead. planRouterSession (providers.ts:359) attaches the advisor to every engine10 session,
82
+ plan is pinned to Opus (router/plan_route.ts), and FC-35 keeps plan on small tasks.
83
+ 6. Implement's cache_read grows with turns times context size. There is no observation masking and no
84
+ budget stop before the 480s limit.
85
+
86
+ ## 2. Common Wall checks (every slice, in addition to its own)
87
+
88
+ - W-FLAG: every behavior change ships behind a flag that defaults off. With the flag off, all engine10
89
+ goldens are byte-identical (router_optout_golden, never_below_raw, receipt goldens). A B9 row decides the
90
+ default-on flip, which is a one-line follow-up slice.
91
+ - W-MOAT: bash tests/moat/run.sh is green, and `git diff --stat main -- tests/moat` is empty (P1 portable
92
+ proof, P2 honest verdict, P3 the Wall, P9 Rule of Two).
93
+ - W-B9: B9 raw vs Loki, n>=3, on scripts/b9-scoreboard.sh with the raw arm (eng-b9-raw-arm) and
94
+ scripts/real-run.sh on trivial-sum (eng-real-run). One lever per arm. Report usd per solved, solve rate
95
+ with CI, p50/p90 wall, p90 usd, and cache_read/cache_creation.
96
+ - W-ACCEPT: acceptance test first (red), then the change (green), plus one mutation that turns it red.
97
+ - W-BUILD: tsc clean, dist rebuilt in the main checkout, test-release-dist-guard passes. No emojis, em dashes or en dashes.
98
+
99
+ ## 3. Slices in CTO order
100
+
101
+ Each slice has an exclusive FILES set. DEPENDS means it merges after another slice, and a shared file is
102
+ sequenced, never concurrent. Full 60-line cards for ER-01, WC-01a and WC-01b were sent to team-lead
103
+ 2026-10-08 and are restated in short form here.
104
+
105
+ ### Wave 1 (staff now; disjoint files)
106
+
107
+ **ER-01 EFFORT-RIGHTSIZE (rank 1). START FIRST. Target 11.3.2.**
108
+ - FILES:
109
+ - loki-ts/src/engine10/effort_policy.ts (new, pure)
110
+ - loki-ts/src/engine10/session.ts (childEnv effort precedence and a per-session `effort` in recordCost)
111
+ - loki-ts/src/engine10/stages/fix.ts (pass fixEffort)
112
+ - loki-ts/tests/engine10/effort_policy.test.ts (new)
113
+ - dist
114
+ - Change: under LOKI_E10_EFFORT_POLICY=rerun:
115
+ - implement and wall run at medium;
116
+ - fix round 1 runs at high;
117
+ - fix round 2+ runs at xhigh only when the failure is code-owned (testFailures.length > 0, the same signal as
118
+ router/unit_model.ts:47), otherwise high.
119
+ - Precedence: the user's LOKI_E10_EFFORT, then opts.effort, then the policy. This fixes session.ts:56, which
120
+ would otherwise beat a user override.
121
+ - Accept:
122
+ - the stage matrix on child envs;
123
+ - a user LOKI_E10_EFFORT=low wins everywhere;
124
+ - with the flag off, no env gains LOKI_E10_EFFORT;
125
+ - mutation: forcing high turns the test red.
126
+ - B9 pass: solve rate within CI and usd per solved down at least 20%.
127
+ - Tier MEDIUM, 25 min.
128
+ - Expected 20 to 25% on medium runs. Basis: medium effort is about 70% of high's cost on the same model
129
+ (PAPERS.md B6), applied to the 74% implement plus wall share (1.2).
130
+
131
+ **WC-01a WALL-CONCURRENT part a (rank 6). START FIRST. Pure refactor.**
132
+ - FILES: loki-ts/src/engine10/stages/wall.ts, loki-ts/tests/engine10/wall_split.test.ts (new), dist.
133
+ - Change: split wallStage into wallAuthor() and installWall(ctx, authored, baseDir).
134
+ - wallAuthor() is the session plus the compile check, and writes only to runDir/wall/sealed.
135
+ - installWall() copies the tests in, runs the base run in baseDir, drops not_run tests, and returns
136
+ readOnlyFiles, base_run and alreadySatisfied.
137
+ - wallStage = author, then install(repoDir), so outputs are identical to today.
138
+ - Accept:
139
+ - outputs deep-equal before and after the split;
140
+ - wallAuthor leaves repoDir clean;
141
+ - the existing wall, fc23 and E-54 tests pass unchanged.
142
+ - Tier HIGH (moat file), 30 min.
143
+ - Saving: none alone. It enables WC-01b.
144
+
145
+ **CP-01 CACHE-PREFIX (rank 7). Was CH-01. Lever 6 for the 11.3.2 cut.**
146
+ - FILES:
147
+ - loki-ts/src/runner/providers.ts (only the engine10 block near lines 616-630 and resolveSystemPrompt near 674-690)
148
+ - loki-ts/src/features/lean_prefix.ts
149
+ - loki-ts/tests/e10ext/system_prefix_identity.test.ts (new)
150
+ - dist
151
+ - Change: under LOKI_E10_STABLE_PREFIX=1, engine10 sessions send
152
+ `{type:"preset", preset:"claude_code", excludeDynamicSections:true}`. This option is in the pinned sdk.d.ts
153
+ and moves cwd, git and memory into the first user message. No run id, timestamp, path, branch or stage name
154
+ goes in system or tools.
155
+ - Accept:
156
+ - JSON.stringify(systemPrompt) and allowedTools are identical for intake, project-model, plan,
157
+ wall (mkdtemp cwd), implement and fix, across two fake runs with different cwd, branch and clock;
158
+ - mutation: injecting the date or cwd turns it red;
159
+ - live trivial fixture: sessions 2..N have first-turn cache_creation under 2,000 tokens (today about 8,700).
160
+ - B9 pass: trivial-sum usd per run down at least 10%.
161
+ - Tier MEDIUM, 30 min.
162
+ - Expected $0.017 per extra Sonnet session ($0.034 Opus), 15 to 25% on trivial, under 5% on medium.
163
+ Basis: E-65 prefix of 7,136 tokens x (2.50 - 0.10) / 1e6.
164
+ - Moat: the shared static prefix is content-addressed. It carries no Wall content and no shared conversation.
165
+
166
+ **CH-M1 per-stage cost and cache table (measurement; every W-B9 check uses it)**
167
+ - FILES: scripts/cost-stage-table.sh (new), tests/test-cost-stage-table.sh (new, registered in the runner and
168
+ shard table, with timeout -k, shellcheck clean).
169
+ - Change: reads a run's cost events and prints, per stage: n, tokens, effort, model, dollars at the 1.1
170
+ prices, and cache_hit_ratio.
171
+ - Tier LOW, 20 min.
172
+
173
+ ### Wave 2
174
+
175
+ **WC-01b WALL-CONCURRENT part b (rank 6). DEPENDS WC-01a.**
176
+ - FILES: loki-ts/src/engine10/machine.ts, loki-ts/tests/engine10/wall_concurrent.test.ts (new), dist.
177
+ - Change: under LOKI_E10_WALL_CONCURRENT=1, the flow is intake, then [(plan if run) -> implement] alongside
178
+ wallAuthor, then installWall, then verify.
179
+ - The base run uses a detached worktree at baseSha (the verify.ts:184 mechanism) with node_modules and .venv
180
+ symlinked from repoDir. A no-deps worktree would turn every Wall test into not_run, and not_run tests get dropped.
181
+ - If implement touched a manifest or lockfile, base_run records deps:"head" and seal notes it.
182
+ - An abort before install installs nothing (E-54).
183
+ - Accept:
184
+ - implement starts before wallAuthor ends;
185
+ - implement's tree contains no sealed path while it runs;
186
+ - install happens once, before verify;
187
+ - with the flag off, outputs are byte-identical.
188
+ - Explicit loss: implement no longer gets the Wall tests as read-only targets (implement.ts:29 reads an
189
+ empty prior.wall), and Wall's already_satisfied exit moves after implement. B9 must report implement's
190
+ first-pass rate.
191
+ - Tier HIGH, 30 min, unanimous opus review plus CTO sign-off.
192
+ - Expected latency down 20 to 45s per run; cost flat. B9 pass: p50 down at least 20s, solve within CI.
193
+
194
+ **LD-01 LEAN-DEFAULT plus the routing call (rank 2; CTO amendment D93, absorbs old CH-10). DEPENDS CP-01 (cache-stable prefix) and ER-01 (session.ts).**
195
+ - One plan gate, two inputs (reconciles the routing call with the LOKI_NEED_PLAN marker):
196
+ - Under LOKI_ROUTER=1, Opus ALWAYS makes the routing decision, as one short structured-output call:
197
+ - cache-stable prefix (CP-01) and effort low;
198
+ - SDK `outputFormat: {type:"json_schema"}` with the schema
199
+ `{size: "trivial"|"small"|"medium"|"large", units: [...], needs_full_plan: boolean}`;
200
+ - measured target cost under $0.01.
201
+ The full Opus PLAN session runs only when needs_full_plan is true. Trivial and small tasks go straight to
202
+ the routed executor on the lean path.
203
+ - The LOKI_NEED_PLAN marker is no longer a separate trigger. It becomes a second INPUT to the same gate:
204
+ - implement's first turn can raise the gate from false to true (plan runs once, then implement resumes);
205
+ - nothing lowers it from true to false.
206
+ - With the router off (LOKI_E10_PLAN=on_request), there is no routing call, and the gate's inputs are the
207
+ marker and the Project Model's "spans more than one context" fact.
208
+ - The gate records why the plan ran or was skipped as one of: `route_call`, `marker`, `project_model` or
209
+ `skipped`, in route.json and the receipt.
210
+ - FC-35 R-B is unchanged: with the router on, route.json is ALWAYS written (a route, or routed:false with the
211
+ reason). A failed, timed-out or malformed routing call records routed:false with the reason and runs the
212
+ full plan, so the fail-safe always leans toward more planning, never less.
213
+ - LD-01 FILES (gate plus routing call):
214
+ - loki-ts/src/engine10/plan_gate.ts (new, pure: the gate over route_call, marker and project_model inputs, plus
215
+ the marker parse beside LOKI_ALREADY_DONE)
216
+ - loki-ts/src/engine10/stages/plan.ts (routing call; the full plan only when the gate is true)
217
+ - loki-ts/src/runner/router/plan_route.ts (pinOpus applies to the routing call)
218
+ - loki-ts/src/runner/router/route_record.ts (size, units, needs_full_plan, plan reason, call cost)
219
+ - loki-ts/src/engine10/sizing.ts (the lean path is no longer small-only)
220
+ - loki-ts/tests/engine10/plan_gate.test.ts (new)
221
+ - dist
222
+ - LD-02 FILES (the marker as a late input): stages/implement.ts (brief text describing the marker),
223
+ engine10/machine.ts (plan-then-resume branch), loki-ts/tests/engine10/plan_on_request.test.ts (new).
224
+ DEPENDS LD-01, CP-01 and WC-01b (machine.ts).
225
+ - Accept LD-01 (red first):
226
+ - with the router on, a fake routing call returning needs_full_plan:false runs no plan session and still
227
+ writes route.json with size, units and reason `skipped`;
228
+ - needs_full_plan:true runs the full plan once, with reason `route_call`;
229
+ - a malformed or failed call records routed:false plus the reason and runs the full plan;
230
+ - route_record_agreement.test.ts (FC-35 fixture) stays green;
231
+ - with the router off and the flags off, outputs are byte-identical (router_optout_golden);
232
+ - mutation: skipping the route.json write when needs_full_plan is false turns the test red.
233
+ - Accept LD-02:
234
+ - a fake implement with no marker runs no plan;
235
+ - with the marker, plan runs once and implement resumes with it, with reason `marker`;
236
+ - the marker can never cancel a plan the routing call requested.
237
+ - Wall never skips: wall, verify, commit, seal and pr are never skippable, and that is asserted in
238
+ plan_gate.test.ts.
239
+ - Wall checks: the common set in section 2, plus:
240
+ - the B9 row on trivial-sum shows the routing call's cost below 10% of the run's total cost (n>=3, read
241
+ from the call's cost event via CH-M1);
242
+ - router-on cost at most 1.05x router-off on trivial-sum (D89 Amendment 2);
243
+ - B9 medium: solve rate within CI, usd per solved down at least 25%.
244
+ - Tier HIGH (FC-35 behavior, flow next to seal), 30 min per part. Reviewers: unanimous opus.
245
+ - Expected: 25 to 45% overall.
246
+ - Basis: lean arm $0.16 vs default $0.39 on small (measured). Medium is unmeasured.
247
+ - Under the router, the Opus plan session on small tasks (about $0.094 at S41-04 mean tokens, table 1.2)
248
+ becomes a call under $0.01, which removes most of the measured +27% to +44% router overhead.
249
+
250
+ **PRICE-01: MERGED INTO PRICE-TRUTH.** eng-price-truth owns loki-ts/data/model-pricing.json under PRICE-TRUTH
251
+ (the 1.1 drift: Opus 4/20/0.20/5, Sonnet cache read 0.10). No separate COST-HALF slice.
252
+
253
+ ### Wave 3
254
+
255
+ **CS-01 CASCADE (rank 3). DEPENDS ER-01.**
256
+ - FILES:
257
+ - loki-ts/src/runner/router/decision.ts
258
+ - loki-ts/src/runner/router/unit_model.ts
259
+ - loki-ts/src/engine10/sizing.ts (cascadeImplementModel; after LD-01)
260
+ - loki-ts/tests/engine10/never_below_raw.test.ts (allowlist)
261
+ - loki-ts/tests/engine10/cascade_ladder.test.ts (new)
262
+ - Change: under LOKI_E10_CASCADE_LADDER=1, implement starts on Sonnet 5.5 at medium. A code-owned FAIL after
263
+ fix round 1 escalates the next round to Opus 5.5 at high. Harness, env and lint failures never climb (L5).
264
+ - Accept: a Sonnet implement whose verify fails twice on tests produces exactly one Opus fix session, and the
265
+ receipt points to the escalation evidence.
266
+ - B9 pass for the half-cost claim: usd per solved at most 0.5x raw, with solve rate not below raw's lower CI bound.
267
+ - Tier HIGH (Engine Law L1 never-below-raw), 30 min.
268
+ - Expected 0.4x to 0.7x raw per solved on tasks Sonnet solves first time. The hard tail costs more.
269
+
270
+ **HB-01, HB-02, HB-03 HAIKU-BOUNDED (rank 4). One stage per slice. Each is checked by execution.**
271
+ - HB-01: the Project Model session on Haiku. FILES: loki-ts/src/project_model/discover.ts plus a test.
272
+ - Check: the discovered test command must run on the base tree.
273
+ - HB-02: already-done on Haiku. FILES: loki-ts/src/engine10/already_done.ts plus a test.
274
+ - Check: it must cite files, and verify confirms (advisory only, never a verdict).
275
+ - HB-03: the Wall author on Haiku. FILES: sizing.ts wallModel (after CS-01) plus a test.
276
+ - Check: a Wall with zero F2P tests retries once on Sonnet. Wall F2P rate is reported and must not be lower
277
+ than the Sonnet Wall's. Depends on F2P-01.
278
+ - All three: prompts stay under 100K (autoCompactWindow), and a prompt over 100K routes to Sonnet to avoid the
279
+ 5x tier. Flag LOKI_E10_AUX_MODEL=haiku. Each model pin is added to the never_below_raw allowlist.
280
+ - Tier: HB-01 and HB-02 MEDIUM; HB-03 HIGH (Wall quality). 25 to 30 min each.
281
+ - Expected: these stages drop to about 1/20th of Sonnet price, 10 to 25% of run cost overall.
282
+
283
+ **F2P-01 F2P-GATE (rank 5). Pairs with T2. DEPENDS WC-01a.**
284
+ - FILES:
285
+ - loki-ts/src/engine10/stages/wall.ts (classify F2P vs P2P in installWall)
286
+ - loki-ts/src/engine10/stages/verify.ts
287
+ - loki-ts/src/engine10/stages/seal.ts (wall.f2p, wall.p2p)
288
+ - loki-ts/src/engine10/pr_body.ts
289
+ - tests
290
+ - Change: a Wall test is proof only if it fails on the base tree. Zero F2P tests seals NOT PROVEN for the
291
+ change, not FAIL.
292
+ - Accept: a fixture with one F2P and one P2P test gives f2p=1, p2p=1; deleting the fix flips verify to FAIL;
293
+ P2P-only seals NOT PROVEN.
294
+ - Tier HIGH (Seal), 30 min; split verify and seal into F2P-02 if it goes over budget.
295
+ - No cost change. Receipt precision goes up, and the accuracy-vs-raw claim rests on it.
296
+
297
+ **BS-01 BUDGET-STOP (rank 8). DEPENDS ER-01 (fix.ts).**
298
+ - FILES: loki-ts/src/runner/budget.ts, loki-ts/src/engine10/no_progress.ts (new), tests.
299
+ - Change: implement and fix sessions get a dollar budget from the run cap (maxBudgetUsd is already plumbed) and a
300
+ no-progress stop (no file change and no test run for N turns). The stop is classified and escalates once
301
+ through CS-01.
302
+ - Tier MEDIUM, 30 min.
303
+ - B9 pass: p90 usd down at least 30%, solve within CI. Expected mean down 10 to 20%.
304
+
305
+ **AS-01 ADVISOR-ONLY-SONNET (rank 9). Was CH-02. Stage scoping BUILT as 7cce4ae85 (branch slice-CH-02).**
306
+ - What is built:
307
+ - under LOKI_ROUTER=1, engine10/session.ts childEnv sets LOKI_ADVISOR_SCOPE=off on every stage except plan and
308
+ fix;
309
+ - router/advisor_probe.ts treats that as unavailable, so the executor stays Sonnet;
310
+ - test: tests/engine10/advisor_scope.test.ts.
311
+ - The router ships OFF, so the effect is default-off.
312
+ - It touches session.ts, so ER-01 rebases on it.
313
+ - Remaining (AS-02, measure first):
314
+ - never attach the advisor to an Opus executor (route decision unit test);
315
+ - default stays off until B9 arm 4 vs arm 2 shows router-on cost <= 1.05x router-off with solve at least equal
316
+ (D89).
317
+ - Once LD-01 lands, the plan stage's advisor applies to the full plan only, never to the routing call.
318
+ - FILES: loki-ts/src/runner/router/session_route.ts plus a test. Tier MEDIUM, 25 min.
319
+ - Expected: removes about 1,000 advisor-definition tokens per request on unmarked sessions (PAPERS.md 1.1).
320
+
321
+ ### Backlog, in order
322
+
323
+ 1. **OBS-MASKING** (rank 10): clear old tool results past a token threshold in implement and fix.
324
+ FILES: providers.ts SDK settings (after CP-01). Expected 20 to 40% on long runs only.
325
+ 2. **MODEL-SEEDED-REPOMAP** (rank 11; absorbs old CH-07 context diet and CH-06 prefetch):
326
+ - FILES: engine10/repomap.ts, engine10/relevant_files.ts.
327
+ - The model names seeds, and the harness returns top-k signatures by personalized PageRank within a token
328
+ budget.
329
+ - Prefetched facts never include Wall source or Wall base-run output.
330
+ 3. **SECOND-CANDIDATE-AFTER-FAIL** (rank 12): after fix round 1 fails, a fresh candidate is selected by F2P pass
331
+ count. FILES: runner/attempts.ts, stages/fix.ts. Accuracy lever on the hard tail.
332
+
333
+ Support slices that stay in the queue: WARM-FIX (old CH-03, LOKI_E10_FIX_RESUME on by default, after ER-01
334
+ releases fix.ts), CACHE-TTL (old CH-04, promptCacheTtl 5m, after CP-01), and B9-RATIO (old CH-14, usd per
335
+ verified ratio row in scripts/b9-scoreboard.sh, prints MISS above 0.5).
336
+
337
+ Superseded: old CH-10 (FC-35 Opus plan, now the D93 routing call) and CH-12 (L0 stage declaration) are folded into LD-01. Old CH-11
338
+ (stagger wall behind plan) is replaced by WC-01b. Old CH-08 (100K ceiling) is folded into HB-*. Old CH-09
339
+ (one intake session) is folded into HB-01 and HB-02.
340
+
341
+ ## 4. Order for the 11.3.2 cut (about 05:50Z)
342
+
343
+ - Staff now: ER-01, WC-01a, CP-01, CH-M1. No two of them share a file.
344
+ - In the cut: ER-01 and CP-01 merged flag-off. WC-01a merged (no behavior change).
345
+ - Flag flips only on a passing B9 row (n>=3).
346
+ - WC-01b is HIGH with a 60-minute reviewer budget, so it is realistic for the next cut, flag-off.
347
+
348
+ ## 5. Research basis
349
+
350
+ PAPERS.md ranks 1 to 12 map one-to-one to the slices above. The sources and the B9 protocol are in that file,
351
+ sections 4 and 6. Section 5 of that file (the multiplicative stack, medium issue, raw $0.40) is the basis for the
352
+ 0.6x to 0.8x medium target in section 0.