loki-mode 11.3.0 → 11.3.2

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 (242) hide show
  1. package/README.md +68 -650
  2. package/SKILL.md +5 -5
  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/efficiency_cost.py +8 -0
  10. package/autonomy/lib/engine10-push.sh +22 -8
  11. package/autonomy/lib/prd-enrich.sh +1 -1
  12. package/autonomy/lib/voter-agents.sh +1 -1
  13. package/autonomy/loki +161 -105
  14. package/autonomy/run.sh +30 -18
  15. package/autonomy/sandbox.sh +1 -1
  16. package/autonomy/tui.sh +6 -5
  17. package/autonomy/verify.sh +1 -1
  18. package/bin/loki +195 -59
  19. package/completions/_loki +8 -0
  20. package/completions/loki.bash +3 -3
  21. package/dashboard/__init__.py +1 -1
  22. package/dashboard/server.py +47 -45
  23. package/docs/AGENT-CHANGE-RECEIPT.md +2 -2
  24. package/docs/ARCHITECTURE.md +337 -0
  25. package/docs/BRANDING.md +124 -0
  26. package/docs/CLI-REFERENCE.md +11 -1
  27. package/docs/COMPONENTS.md +447 -0
  28. package/docs/DEPLOYMENT.md +9 -9
  29. package/docs/DOCKER.md +469 -0
  30. package/docs/INSTALLATION.md +67 -1045
  31. package/docs/KNOWN-ISSUES.md +11 -35
  32. package/docs/OTEL-COLLECTOR.md +24 -0
  33. package/docs/ROUTING-EVIDENCE.md +32 -0
  34. package/docs/TESTING.md +161 -0
  35. package/docs/air-gapped.md +1 -2
  36. package/docs/alternative-installations.md +14 -24
  37. package/docs/architecture/DECISIONS.md +333 -0
  38. package/docs/audit-logging.md +7 -7
  39. package/docs/authentication.md +3 -3
  40. package/docs/authorization.md +1 -1
  41. package/docs/certification/04-production-deployment/lab.md +6 -6
  42. package/docs/certification/04-production-deployment/lesson.md +4 -4
  43. package/docs/certification/README.md +1 -1
  44. package/docs/control-plane-container.md +2 -2
  45. package/docs/dev/real-run.md +34 -0
  46. package/docs/dev/release-checklist.md +2 -2
  47. package/docs/environment-variables.md +1 -0
  48. package/docs/exit-codes.md +3 -3
  49. package/docs/git-workflow.md +3 -3
  50. package/docs/metrics.md +37 -55
  51. package/docs/network-security.md +1 -1
  52. package/docs/siem-integration.md +5 -5
  53. package/docs/spec-first-intent.md +28 -0
  54. package/docs/v10/CLI-MODERN.md +7 -3
  55. package/docs/v10/DECISIONS.md +59 -0
  56. package/docs/v10/DEPS.md +22 -22
  57. package/docs/v10/ENGINE.md +1 -1
  58. package/docs/v10/FAILURE-CLASSES.md +212 -1
  59. package/docs/v10/FOUNDER-QUEUE.md +1 -0
  60. package/docs/v10/GUARDS.md +31 -0
  61. package/docs/v10/GUIDE.md +7 -5
  62. package/docs/v10/LEGACY-REMOVAL.md +4 -6
  63. package/docs/v10/METRICS.md +14 -2
  64. package/docs/v10/MODERNIZE.md +1 -1
  65. package/docs/v10/OPERATING-MODEL.md +4 -3
  66. package/docs/v10/PROGRESS.md +35 -0
  67. package/docs/v11/COST-HALF.md +352 -0
  68. package/docs/v11/INTOTO-AGENT-CHANGE-PREDICATE.md +77 -0
  69. package/docs/v11/MARKET-SLICES.md +315 -0
  70. package/docs/v11/MCP-2026-07-28.md +55 -0
  71. package/docs/v11/REGISTRIES.md +730 -0
  72. package/docs/v11/VERIFY-PR-SANDBOX.md +41 -0
  73. package/loki-ts/data/model-pricing.json +52 -24
  74. package/loki-ts/dist/loki.js +1185 -945
  75. package/mcp/__init__.py +1 -1
  76. package/mcp/v10_tools.py +29 -0
  77. package/package.json +9 -11
  78. package/packages/control-plane/dist/ask-tools-server.js +8 -2
  79. package/packages/control-plane/dist/server.js +15832 -12361
  80. package/packages/control-plane/drizzle/0006_token_sessions.sql +1 -0
  81. package/packages/control-plane/drizzle/meta/0006_snapshot.json +807 -0
  82. package/packages/control-plane/drizzle/meta/_journal.json +7 -0
  83. package/packages/control-plane/src/db/schema.ts +1 -0
  84. package/packages/control-plane/src/server/routes/cost.ts +4 -3
  85. package/packages/control-plane/src/server/runs.ts +3 -3
  86. package/packages/control-plane/ui/dist/assets/index-DbLzr87u.js +190 -0
  87. package/packages/control-plane/ui/dist/index.html +1 -1
  88. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  89. package/providers/opencode.sh +2 -3
  90. package/src/observability/genai-spans.js +104 -0
  91. package/src/observability/otel-bridge.js +49 -1
  92. package/src/observability/otel.js +2 -2
  93. package/src/protocols/mcp-client.js +6 -2
  94. package/src/protocols/mcp-server.js +191 -6
  95. package/src/protocols/transport/sse.js +23 -2
  96. package/tools/audit-docs.py +1 -1
  97. package/web-app/dist/assets/{AdminPage-D_e45uTw.js → AdminPage-DuRQZsF9.js} +1 -1
  98. package/web-app/dist/assets/{Avatar-T3nIpoaf.js → Avatar-7GtOQvsO.js} +1 -1
  99. package/web-app/dist/assets/{Badge-BKqb59pP.js → Badge-CYgTnIxj.js} +1 -1
  100. package/web-app/dist/assets/{Button-DjVlkh8_.js → Button-rYSyIu7X.js} +1 -1
  101. package/web-app/dist/assets/{CockpitPage-DXJgLGmh.js → CockpitPage-9adANY4o.js} +1 -1
  102. package/web-app/dist/assets/{ComparePage-BRP_eVc_.js → ComparePage-DEG2oA-R.js} +1 -1
  103. package/web-app/dist/assets/{ErrorBoundary-CLjpGLjC.js → ErrorBoundary-CwtvY4xs.js} +1 -1
  104. package/web-app/dist/assets/{EvidenceReceiptPanel-DX-vb4Xy.js → EvidenceReceiptPanel-DTT73pPB.js} +1 -1
  105. package/web-app/dist/assets/{GitHubIssuesPanel-214HVHtX.js → GitHubIssuesPanel-CpWZLz2x.js} +1 -1
  106. package/web-app/dist/assets/{GitHubPRsPanel-BEiZKc4t.js → GitHubPRsPanel-H293R7E2.js} +1 -1
  107. package/web-app/dist/assets/{HomePage-VvMHS5ga.js → HomePage-B11Imp9k.js} +2 -2
  108. package/web-app/dist/assets/{LoginPage-5WD-v7n3.js → LoginPage-BZBgx5Jr.js} +1 -1
  109. package/web-app/dist/assets/{MagicPage-DUQT_Jye.js → MagicPage-B27S4_X8.js} +1 -1
  110. package/web-app/dist/assets/{MetricsPage-lga-z79v.js → MetricsPage-CfbJWNDG.js} +1 -1
  111. package/web-app/dist/assets/{NotFoundPage-CGhBX3G1.js → NotFoundPage-Tp_4zMSm.js} +1 -1
  112. package/web-app/dist/assets/{ProjectPage-CdzF2GzZ.js → ProjectPage-CM4fgMsV.js} +3 -3
  113. package/web-app/dist/assets/{ProjectsPage-DRG64N8s.js → ProjectsPage-DP2Fvsrd.js} +1 -1
  114. package/web-app/dist/assets/{SettingsPage-5fzW9Frb.js → SettingsPage-C4G9-EAy.js} +1 -1
  115. package/web-app/dist/assets/{ShowcasePage-DrTdxO4y.js → ShowcasePage-Dj-n4dwu.js} +1 -1
  116. package/web-app/dist/assets/{SystemSettingsPage-C9Mqs6Rd.js → SystemSettingsPage-BqMLpuGt.js} +1 -1
  117. package/web-app/dist/assets/{TeamsPage-CUGPdSWo.js → TeamsPage-mIH8H96m.js} +1 -1
  118. package/web-app/dist/assets/{TemplatesPage-CNraDY0F.js → TemplatesPage-BagW-v4n.js} +1 -1
  119. package/web-app/dist/assets/{TerminalOutput-BIu_6Pea.js → TerminalOutput-CTQRHhnK.js} +1 -1
  120. package/web-app/dist/assets/{activity-Bk-kgqaf.js → activity-DNQiBDDL.js} +1 -1
  121. package/web-app/dist/assets/{bell-BXmUdmo8.js → bell-Coiwdad1.js} +1 -1
  122. package/web-app/dist/assets/{bot-CiuzXxUR.js → bot-Cou-rTgR.js} +1 -1
  123. package/web-app/dist/assets/{check-BEzjXppd.js → check-CsF-XtQp.js} +1 -1
  124. package/web-app/dist/assets/{chevron-left-AYWCXHf8.js → chevron-left-BJiy55Ht.js} +1 -1
  125. package/web-app/dist/assets/{circle-alert-BNg2uSRq.js → circle-alert-D6-pQQWq.js} +1 -1
  126. package/web-app/dist/assets/{clock-DTj0kkGT.js → clock-BOGqwgt9.js} +1 -1
  127. package/web-app/dist/assets/{cloud-x4nTDBLT.js → cloud-DsxhTtf5.js} +1 -1
  128. package/web-app/dist/assets/{code-xml-BVh_MLrk.js → code-xml-CxJDHUlE.js} +1 -1
  129. package/web-app/dist/assets/{database-DdfBaowG.js → database-BJePscl_.js} +1 -1
  130. package/web-app/dist/assets/{dollar-sign-XuYFmAOY.js → dollar-sign-6qWGAkZo.js} +1 -1
  131. package/web-app/dist/assets/{file-code-corner-D4cRnmeL.js → file-code-corner-DcOtYeDb.js} +1 -1
  132. package/web-app/dist/assets/{file-plus-CyoVlHc_.js → file-plus-WuRyLFo0.js} +1 -1
  133. package/web-app/dist/assets/{globe-Y6IK2RPW.js → globe-r-xCP4DE.js} +1 -1
  134. package/web-app/dist/assets/{hammer-BKzr9VZI.js → hammer-DTt0SsCB.js} +1 -1
  135. package/web-app/dist/assets/{index-B20cSx5G.js → index-BkbXyH8y.js} +3 -3
  136. package/web-app/dist/assets/{layers-DebNOhGS.js → layers-BvZhvSMY.js} +1 -1
  137. package/web-app/dist/assets/{loader-circle-DyGbrEgd.js → loader-circle-3gosTei9.js} +1 -1
  138. package/web-app/dist/assets/{lock-BKPpyt20.js → lock-CZZMxP0U.js} +1 -1
  139. package/web-app/dist/assets/{package-egF5Wi4y.js → package-C5A8CkJr.js} +1 -1
  140. package/web-app/dist/assets/{plus-OiEgKIc-.js → plus-Btv7tTIF.js} +1 -1
  141. package/web-app/dist/assets/{refresh-cw-CzKvrONq.js → refresh-cw-DsWLXgs_.js} +1 -1
  142. package/web-app/dist/assets/{rotate-ccw-Bu2mII0p.js → rotate-ccw-DOVDjway.js} +1 -1
  143. package/web-app/dist/assets/{scroll-text-CSkiyax8.js → scroll-text-smySzlrX.js} +1 -1
  144. package/web-app/dist/assets/{server-DlPthJFw.js → server-b5PHsqAU.js} +1 -1
  145. package/web-app/dist/assets/{shield-alert-CbpHWQQX.js → shield-alert-BD7FDlh-.js} +1 -1
  146. package/web-app/dist/assets/{thumbs-up-DgGpZe-Q.js → thumbs-up-CAsFzbyE.js} +1 -1
  147. package/web-app/dist/assets/{trash-2-BV3GlCB-.js → trash-2-BJ35qHgl.js} +1 -1
  148. package/web-app/dist/assets/{trending-down-Y4TJtXhD.js → trending-down-Ozrd26cZ.js} +1 -1
  149. package/web-app/dist/assets/{trending-up-DsDNoHZY.js → trending-up-BhnMcM32.js} +1 -1
  150. package/web-app/dist/assets/{upload-gkThrc_I.js → upload-JVHfdwoA.js} +1 -1
  151. package/web-app/dist/assets/{usePolling-jpNSeNAe.js → usePolling-CTzbDV-e.js} +1 -1
  152. package/web-app/dist/assets/{user-3Zez1WOK.js → user-Bks3-GYv.js} +1 -1
  153. package/web-app/dist/index.html +1 -1
  154. package/docs/ARCHITECTURE-OVERVIEW.md +0 -209
  155. package/docs/AUTONOMI-ECOSYSTEM.md +0 -107
  156. package/docs/COCKPIT-SPEC.md +0 -72
  157. package/docs/COCKPIT-UX-MANDATE.md +0 -53
  158. package/docs/COMPETITIVE-ANALYSIS.md +0 -303
  159. package/docs/COMPETITIVE-NEXT-10.md +0 -316
  160. package/docs/COMPETITIVE-RALPH-ZEROSHOT-2026-07-08.md +0 -81
  161. package/docs/DASHBOARD-9.12-EVIDENCE.md +0 -97
  162. package/docs/DASHBOARD-ARCHITECTURE.md +0 -425
  163. package/docs/DASHBOARD_V2_CHECKLIST.md +0 -243
  164. package/docs/DEMOS.md +0 -63
  165. package/docs/ENTERPRISE-IDENTITY-ROADMAP.md +0 -206
  166. package/docs/EVIDENCE-RECEIPT-BUILD-APPLICABILITY.md +0 -79
  167. package/docs/FEAT-PRDREUSE-DOCKER-PLAN.md +0 -144
  168. package/docs/GATE-FAILURE-TRIAGE.md +0 -254
  169. package/docs/HANDOFF-2026-08-03.md +0 -439
  170. package/docs/LOOP-CANDIDATE-PROPOSAL-v1.md +0 -167
  171. package/docs/LOOP-HARNESS-AUDIT.md +0 -684
  172. package/docs/MERGE-DEDUP-MAP.md +0 -420
  173. package/docs/MERGE-ROUTE-MAP.md +0 -139
  174. package/docs/MODEL-REGISTRY-PLAN.md +0 -155
  175. package/docs/OUTCOME-FRONTIER.md +0 -536
  176. package/docs/P2-SPEC-ROBUSTNESS-PLAN.md +0 -192
  177. package/docs/PLANS-INDEX.md +0 -32
  178. package/docs/PRD-REUSE-DONE-RECOGNITION-PLAN.md +0 -536
  179. package/docs/PROMPT-ABLATION-RESULT.md +0 -97
  180. package/docs/R4-TRUST-TRAJECTORY-DESIGN.md +0 -127
  181. package/docs/R5-AUTO-WIKI-DESIGN.md +0 -137
  182. package/docs/R6-ROLLBACK-CHECKPOINT-PLAN.md +0 -107
  183. package/docs/R7-ZERO-CONFIG-FIRST-RUN-PLAN.md +0 -137
  184. package/docs/R8-SHAREABLE-TEAM-ASSETS-PLAN.md +0 -129
  185. package/docs/R9-OPEN-CORE-HOOKS-PLAN.md +0 -113
  186. package/docs/RARV-C-100X-PLAN.md +0 -286
  187. package/docs/RARV-C-LOOP-EFFICIENCY-PLAN.md +0 -470
  188. package/docs/SHAREABLE-PROOF-PLAN.md +0 -194
  189. package/docs/SONNET5-DEFAULT-PLAN.md +0 -157
  190. package/docs/SPEED-AND-FIRST-PASS-PLAN.md +0 -281
  191. package/docs/STALE-STATE-AUDIT.md +0 -174
  192. package/docs/SYNERGY-TASKS.md +0 -143
  193. package/docs/TASKLIST-ACCURACY-PLAN.md +0 -355
  194. package/docs/TOP-100-BACKLOG.md +0 -159
  195. package/docs/V8-ACCEPTANCE-TRIAGE-2026-07-24.md +0 -114
  196. package/docs/V8-COMPLEXITY-AUDIT-2026-07-24.md +0 -45
  197. package/docs/V8-MAJOR-RELEASE-PLAN.md +0 -137
  198. package/docs/V8-OVERNIGHT-PLAN-2026-07-25.md +0 -82
  199. package/docs/V8-SDK-RESEARCH-RAW.md +0 -129
  200. package/docs/WELCOME-OPENER-PLAN.md +0 -106
  201. package/docs/adoption-baseline-2026-07-31.md +0 -84
  202. package/docs/architecture/bmad-integration-epic.md +0 -271
  203. package/docs/architecture/bmad-integration-review.md +0 -86
  204. package/docs/architecture/bmad-integration-validation.md +0 -249
  205. package/docs/architecture/bmad-loki-voice-agent-council-analysis.md +0 -61
  206. package/docs/auto-claude-comparison.md +0 -250
  207. package/docs/bug-fixes/agent-01-cli-fixes.md +0 -101
  208. package/docs/bug-fixes/agent-02-purplelab-fixes.md +0 -88
  209. package/docs/bug-fixes/agent-03-dashboard-fixes.md +0 -119
  210. package/docs/bug-fixes/agent-04-memory-fixes.md +0 -105
  211. package/docs/bug-fixes/agent-05-provider-fixes.md +0 -86
  212. package/docs/bug-fixes/agent-06-integration-fixes.md +0 -101
  213. package/docs/bug-fixes/agent-07-dash-run-fixes.md +0 -101
  214. package/docs/bug-fixes/agent-08-docker-fixes.md +0 -164
  215. package/docs/bug-fixes/agent-09-e2e-build-fixes.md +0 -69
  216. package/docs/bug-fixes/agent-10-e2e-fullstack-fixes.md +0 -102
  217. package/docs/bug-fixes/agent-11-e2e-session-fixes.md +0 -70
  218. package/docs/bug-fixes/agent-12-scenario-fixes.md +0 -120
  219. package/docs/bug-fixes/agent-13-enterprise-fixes.md +0 -143
  220. package/docs/bug-fixes/agent-14-uat-newuser-fixes.md +0 -88
  221. package/docs/bug-fixes/agent-15-uat-poweruser-fixes.md +0 -132
  222. package/docs/bug-fixes/agent-19-code-review.md +0 -316
  223. package/docs/bug-fixes/agent-20-architecture-review.md +0 -331
  224. package/docs/competitive/bolt-new-analysis.md +0 -579
  225. package/docs/competitive/emergence-others-analysis.md +0 -605
  226. package/docs/competitive/replit-lovable-analysis.md +0 -622
  227. package/docs/dashboard-guide.md +0 -487
  228. package/docs/enterprise/migration.md +0 -265
  229. package/docs/history/one-run-audit.md +0 -304
  230. package/docs/plans/FORGE-AUTONOMOUS-QUEUE.md +0 -312
  231. package/docs/plans/ULTRAPLAN-FORGE-BAAS.md +0 -612
  232. package/docs/plans/UT2-6-LSP-DIAGNOSTIC-BROADCAST.md +0 -394
  233. package/docs/prd-purple-lab-ide.md +0 -152
  234. package/docs/prd-purple-lab-platform-v2.md +0 -223
  235. package/docs/prd-purple-lab-platform.md +0 -319
  236. package/docs/retrospectives/v7.5.15-fleet-postmortem.md +0 -325
  237. package/docs/retrospectives/v7.5.15-honesty-audit.md +0 -136
  238. package/docs/retrospectives/v7.5.15-llm-failure-modes.md +0 -49
  239. package/docs/show-hn-post.md +0 -46
  240. package/docs/test-scenarios/enterprise-scenarios.md +0 -732
  241. package/docs/thick2thin.md +0 -173
  242. package/packages/control-plane/ui/dist/assets/index-DcBJXjCJ.js +0 -190
@@ -1,470 +0,0 @@
1
- # RARV-C Loop-Efficiency Upgrade Plan (ultracode phase)
2
-
3
- > SUPERSEDED by `docs/RARV-C-100X-PLAN.md` (v8.0.0 arc, 2026-07-13). Kept as history.
4
- > Anchors here are grounded to v7.121.5 and have DRIFTED; use the 100X plan for current
5
- > file:line and for the native-primitives-already-adopted findings.
6
-
7
-
8
- Architect: synthesis of the six cookbook pattern sets against the current
9
- Loki RARV-C loop. This is a PLAN, not code. Every proposed change carries a
10
- constraint bucket and a bench-gate. No benchmark numbers are asserted here --
11
- the harness (Deliverable #1) produces them.
12
-
13
- Grounded against v7.121.5 source. Line numbers drift; re-verify with grep
14
- before editing.
15
-
16
- ---
17
-
18
- ## 0. The one-line thesis
19
-
20
- The competitors' edge is INFRASTRUCTURE, not loop rigor. Our proof /
21
- never-fake-green RARV-C is the moat. So this plan optimizes the loop's
22
- EFFICIENCY (cost, wall-clock, iterations-to-completion) and NEVER trades away
23
- verification rigor. The lever that proves it is a bench that measures the
24
- moat's OUTPUT (verified pass rate, from a deterministic grader) independently
25
- of the loop's own self-assessment.
26
-
27
- ---
28
-
29
- ## 1. The gap split
30
-
31
- ### 1a. Already-scoped INFRASTRUCTURE (NOT this plan's target)
32
-
33
- Yesterday's competitor research (reuse, do not re-run) found the
34
- Replit/Emergent/Bolt advantage is mostly infrastructure: per-build sandbox
35
- isolation, snapshot/checkpoint, warm pools, fast provisioning. That work is
36
- already scoped as #2b / #8b / #10 in
37
- `autonomi-saas/docs/NEXT-AFTER-2026-07-08.md`.
38
-
39
- The entire `sandboxes-production` cookbook maps 1:1 onto that scoped k8s work.
40
- Treat it as a reference implementation, do NOT re-derive it, and do NOT rank
41
- it here:
42
-
43
- | Cookbook technique | Already-scoped item |
44
- |---|---|
45
- | Pod-per-session = blast radius | Per-build isolation (#2b) |
46
- | Per-session volume + SessionStore mirror (local-first, async, non-fatal) | Snapshot/resume, durability C->A (#10) |
47
- | Lease + heartbeat + reclaim-on-lapse | dead-run-holds-worker (#14) |
48
- | Idempotent get-or-create keyed on session id | (implicit in per-build spawn) |
49
- | Standby warm pool, egress NetworkPolicy, gateway auth, OTel | k8s tier-3 infra |
50
-
51
- Their loops are NOT more rigorous (Replit ships zero tests). We are ahead on
52
- verification. Do not re-architect that lead.
53
-
54
- Three `sandboxes-production` techniques are net-new for Loki but are
55
- SAFETY/HEALING, not cost/speed/iterations, so they are explicitly OUT of this
56
- plan's ranked list (name them, do not smuggle them in):
57
- - Two-phase investigate(read-only) -> remediate(write) split for
58
- self-heal-from-logs.
59
- - Narrow-scoped write tools + `PreToolUse` content-validation hooks
60
- (block-and-let-agent-adapt).
61
- - archive-vs-delete + optimistic-concurrency version check on state updates.
62
-
63
- ### 1b. LOOP EFFICIENCY (THIS plan's target)
64
-
65
- Cost, wall-clock, iterations-to-completion, at constant verified-pass-rate.
66
- The `managed-agents`, `agent-patterns`, and `evals-observability` cookbooks
67
- target this. Techniques: evaluator-optimizer to converge in fewer passes,
68
- outcome-grader discipline to stop early when genuinely done, cheaper model
69
- routing, root-cause-clustered parallel fix-loops, plan-big-execute-small
70
- coordinator economics.
71
-
72
- **Honest caveat up front (ponytail rung 2 -- reuse what exists):** the biggest
73
- iterations-win is LARGELY ALREADY SHIPPED. The framework already has
74
- explicit-completion-claim, tunable `COUNCIL_CHECK_INTERVAL`, the tier-aware
75
- `_council_effective_min_iter` floor (v7.105), and the
76
- `COUNCIL_STAGNATION_LIMIT` circuit breaker. The cookbook's outcome-grader and
77
- evaluator-optimizer patterns ARE, structurally, the completion council plus
78
- findings-injection we already run. So most items below are "TUNE an existing
79
- knob and let the bench prove the setting," NOT "build a new grader." Proposing
80
- to build what exists would itself be a fabrication.
81
-
82
- ---
83
-
84
- ## 2. Deliverable #1: the metric harness (BUILD THIS FIRST)
85
-
86
- We cannot claim "least cost / fewer iterations" without measured before/after.
87
- Founder rule: measurable before/after every commit; an unmeasured claim is a
88
- fabrication under anti-fake-green. So the harness ships before any loop change.
89
-
90
- ### 2a. Reuse, do not rebuild (the lazy path is the correct path)
91
-
92
- Verified against source: the harness is ~95% already built.
93
-
94
- - `benchmarks/bench/` already has the frozen contract (`bench_schema.py`,
95
- `SCHEMA_VERSION = "1.0"`), a runner (`runner.py`), a deterministic grader
96
- (`success = exit==0`, held-out `acceptance.overlay` copied in AFTER the
97
- agent finishes), a loki adapter (`adapters/loki.py`), a price table
98
- (`prices.json`), and `loki bench` + `loki bench verify`.
99
- - `bench_schema.py` ALREADY carries the fields we need: `iterations`
100
- (`setdefault("iterations", 0)`), `duration_s`, `cost_usd`, `tokens_in/out`,
101
- `cache_read_tokens`, `success` (grader-set).
102
- - `adapters/loki.py` ALREADY reads iteration count from `.loki` state
103
- (`_read_iteration_count`, session.json/autonomy-state.json) and captures
104
- `duration_s`.
105
- - The credibility invariant is ENFORCED in code: `validate_adapter_output()`
106
- REJECTS any adapter dict carrying `success/quality/passed/score/verdict`.
107
- Only the grader sets outcome. This is exactly the "grade the artifact, never
108
- the loop's self-assessment" rule -- already a code invariant, not a
109
- convention.
110
- - `benchmarks/speed-benchmark.sh` ALREADY parses the target's
111
- `.loki/events.jsonl` for `act_iterations` and `wall_clock_s` from an
112
- ISOLATED source copy (never the worktree).
113
-
114
- So Deliverable #1 is NOT a build. It is: lock a corpus, reconcile one metric
115
- source, baseline, and wire the gate.
116
-
117
- ### 2b. The four target metrics -> where each comes from
118
-
119
- | Metric | Source (already exists) |
120
- |---|---|
121
- | verified-pass-rate | grader `success = exit==0` on held-out acceptance -> `success_rate` = n_success/n_trials. NEVER council/`completion_claimed`. |
122
- | $/build | `cost_usd` per task (adapter tokens x frozen `prices.json`); `cost_usd_per_solved` aggregate already in schema. |
123
- | iterations-to-completion | `iterations` field, populated by `adapters/loki.py` `_read_iteration_count`. |
124
- | wall-clock/build | `duration_s` (adapter wall-clock around the subprocess). |
125
-
126
- ### 2c. The genuine delta (small, concrete)
127
-
128
- 1. **Reconcile the iterations source (harden, do not duplicate).**
129
- `adapters/loki.py` reads `iteration` from `session.json`;
130
- `speed-benchmark.sh` parses `events.jsonl`. These CAN disagree. Pick ONE
131
- canonical source so both harnesses agree -- prefer the `events.jsonl`
132
- `iteration_complete` count (it is the real per-session timeline; session
133
- state can be mid-write). Make `adapters/loki.py` read events.jsonl with
134
- session.json as fallback. One parser, copied from
135
- `speed-benchmark.sh` lines ~119-179. Bucket (a).
136
- 2. **Confirm wall-clock coverage.** `duration_s` already exists; verify it is
137
- the full subprocess wall-clock, not per-iteration. If it is, no new field
138
- is needed and we avoid touching the frozen schema at all. If a distinct
139
- `wall_clock_s` is truly required, it is an ADDITIVE optional field
140
- (`setdefault`), but the schema header says "do not change without updating
141
- SCHEMA_VERSION and every slice" -- so treat any field add as a
142
- SCHEMA_VERSION bump + all-slice update. PREFER reusing `duration_s`.
143
- 3. **Lock the corpus.** 5-15 fixed specs under `benchmarks/bench/tasks/` (or
144
- a new `benchmarks/corpus/`), each with machine-checkable held-out
145
- acceptance (exit code / http status / file exists / regex). Dev on 2, run
146
- on all. `task_hash` (spec + acceptance + model, already computed) is the
147
- reproducibility anchor.
148
- 4. **Ship the 2-spec smoke sanity check:** one spec that MUST pass, one
149
- deliberately-underspecified that MUST fail; assert
150
- `verified_pass == [True, False]`. If the grader cannot tell those apart it
151
- measures nothing. This is the single runnable check the harness leaves
152
- behind.
153
-
154
- ### 2d. Reproducibility contract (frozen across every before/after)
155
-
156
- - Corpus, grader (acceptance harness), and `prices.json` are FROZEN across a
157
- before/after pair. Changing any of them destroys comparability exactly like
158
- swapping a grader model would. Adding output fields is safe (`task_hash`
159
- covers spec+acceptance+model); changing the corpus is not.
160
- - Every results file persists `loki_version` + `task_hash` + price-table hash
161
- so any past number is reproducible and its config travels with it
162
- (`benchmarks/results/<version>-<stamp>.json`, already the pattern).
163
- - Baseline = N real off-worktree builds = real dollars and hours. Run from an
164
- isolated source copy with cwd AND `LOKI_TARGET_DIR` pinned to scratch, per
165
- the never-run-from-worktree rule. Per-build try/except + hard timeout: a
166
- crashed/hung build scores 0 (fail), never aborts the batch. Retry a build
167
- only on infra error (network/rate-limit), NEVER on a real failure.
168
-
169
- ### 2e. The gate rule (operationalizes anchors 1 + 3)
170
-
171
- > A loop-efficiency change SHIPS iff it improves at least one of
172
- > {iterations-to-completion, $/build, wall-clock} BEYOND THE BASELINE'S NOISE
173
- > BAND AND does not regress verified-pass-rate, measured on the frozen corpus
174
- > vs the committed baseline.
175
-
176
- No change ships unless the bench moves the right way. That one rule is anchor
177
- 1 (optimize efficiency, never trade the proof-moat) and anchor 3
178
- (bench-gated, no unmeasured claims) made mechanical.
179
-
180
- ### 2e-HARDENING (advisor 2026-07-08 - blocking; decided BEFORE any results)
181
-
182
- Three holes that make an unhardened bench produce fake-green "wins":
183
-
184
- 1. **NOISE FLOOR (blocking).** Agentic builds are non-deterministic; iterations
185
- /$/wall-clock vary run-to-run. "Improves the right direction" with no variance
186
- threshold ships random noise as a win ~half the time. RULE: the baseline
187
- reports SPREAD (std dev or min-max across trials), not just means. A change
188
- ships only if its metric moves BEYOND the baseline's noise band (mean delta >
189
- baseline trial std, or non-overlapping min-max). If an effect is smaller than
190
- trial variance at N trials, either raise trials or report "no measurable
191
- effect" and DO NOT ship. The noise bar is decided now, not rationalized after.
192
- 2. **RECONCILE-METRICS-FIRST (blocking).** Fix the iterations source (2c.1 ->
193
- events.jsonl canonical) BEFORE baselining. Baselining on an ambiguous source
194
- (session.json vs events.jsonl disagree) corrupts every iterations before/after.
195
- This is a PREREQUISITE step, not parallel.
196
- 3. **CORPUS FROM DISCRIMINATORS (expensive to reverse - frozen at baseline).**
197
- Do NOT pick "5-15 representative specs." Derive the corpus BACKWARD from what
198
- each ranked change must discriminate:
199
- - Rank 2 (tier routing): MUST include HARD specs that must stay on the strong
200
- model without pass-rate regression, else the anchor-1 guard (cheap tier must
201
- not regress hard builds) is untestable and you ship a silent regression.
202
- - Rank 3 (parallel fix-loops): MUST include specs that produce MULTI-CLUSTER
203
- failures.
204
- - Rank 5 (distilled returns): MUST include TOKEN-HEAVY specs.
205
- Mix: simple + hard + multi-failure + token-heavy. Frozen once baselined (2d).
206
-
207
- ### 2f. Cost envelope + honesty pre-commit
208
- - Envelope: ~5-10 specs x 3 trials x (1 baseline + ~7 ranked changes) ~= 120-240
209
- real builds = real dollars + hours. START SMALL: prove the full pipeline
210
- (baseline->one change->measure->gate) on a 3-spec corpus FIRST to validate the
211
- machinery mechanically, THEN build the real discriminator-derived corpus and
212
- baseline. Grow corpus only if variance demands it.
213
- - HONESTY PRE-COMMIT: the plan already says most iteration wins are shipped;
214
- expect single-digit-% to maybe-2x from tuning, NOT 100x. Pre-commit to reporting
215
- the real number even if unimpressive, and to stating plainly: "the loop is
216
- near-optimal; the real 100x is the INFRA work (already scoped #2b/#10), not
217
- here." Do not let the measurement spend create pressure to dress up a small
218
- delta - that would be fake-green.
219
-
220
- ---
221
-
222
- ## 3. Ranked upgrade list
223
-
224
- Ranked by (impact / effort), bucket-(a) first. Every item names its cookbook
225
- pattern, expected effect, bucket, bench validation, and rough effort.
226
-
227
- Bucket key:
228
- - **(a)** ORCHESTRATION-LEVEL -- changeable now (run.sh model routing, council
229
- gating, iteration control constants, sub-invocation that does NOT feed the
230
- next prompt). No `build_prompt()` change.
231
- - **(b)** NEEDS FOUNDER AUTHORIZATION -- requires unlocking `build_prompt()`
232
- (60-fixture byte-mirror parity lock).
233
- - **(c)** NEEDS OFF-WORKTREE REAL-BUILD VALIDATION -- cannot be proven without
234
- real builds that must NOT run from the worktree.
235
-
236
- Discriminator for (a) vs (b): *does the change alter `build_prompt()` output
237
- text?* If it changes what text enters the next prompt (findings, rubric,
238
- feedback), it is (b). If it only changes WHEN the council convenes, WHICH model
239
- runs, or a sub-invocation whose output is not concatenated into the next
240
- prompt, it is (a). Prompt-touching patterns are SPLIT into their (a) and (b)
241
- halves below -- do not file a whole pattern under one bucket.
242
-
243
- ---
244
-
245
- ### Rank 1 -- Tune the completion-council convergence knobs
246
-
247
- - **Pattern:** outcome-grader "stop early when genuinely done" +
248
- evaluator-optimizer "PASS gate stops the loop the moment criteria are met"
249
- (`managed-agents`, `agent-patterns`). We already HAVE the grader (the
250
- council). This item TUNES it, does not build it.
251
- - **Concrete:** sweep `COUNCIL_CHECK_INTERVAL` (default 5,
252
- `completion-council.sh:84`), `_council_effective_min_iter`
253
- (`:3555`), and `COUNCIL_STAGNATION_LIMIT` (default 5, `:132`) on the corpus;
254
- pick the settings that cut iterations-to-completion without regressing
255
- verified-pass-rate. Also verify the explicit-completion-claim fast path
256
- (`:3601`) fires on the corpus (the v7.105 lever: a done-at-1 build should
257
- stop near iter 1, not grind to the next interval).
258
- - **Effect:** fewer wasted idle iterations -> lower $/build + wall-clock.
259
- Largest iterations lever that is NOT already maxed.
260
- - **Bucket:** (a). Constants + gating only; no prompt text.
261
- - **Bench validation:** iterations + $/build must drop, verified-pass-rate
262
- flat. If pass-rate drops, the interval is too aggressive -- revert.
263
- - **Effort:** LOW (constant sweep + bench runs). Cost is the real-build $.
264
-
265
- ### Rank 2 -- Model-tier routing by task complexity
266
-
267
- - **Pattern:** Routing (`agent-patterns`) -- a cheap classifier routes easy
268
- inputs to the cheap model, hard ones to the strong model; plan-big-
269
- execute-small coordinator economics (`managed-agents`).
270
- - **Concrete:** `LOKI_SESSION_MODEL` is the single largest cost lever
271
- (`run.sh:16932`) and today it is one pinned tier for the whole run. Wire
272
- `detect_complexity()` (`run.sh:1338`) -> session tier so simple specs pin
273
- cheaper (haiku/sonnet) and complex specs pin higher, instead of a flat
274
- default. Keep it a unified intelligent default (opt-out knob), never a
275
- fragmented set of flags.
276
- - **Effect:** direct $/build reduction on the simple-spec majority; strong
277
- model reserved for the hard tail. Dominant cost lever.
278
- - **Bucket:** (a). Model selection, no prompt text.
279
- - **Bench validation:** $/build drops on simple-spec corpus members,
280
- verified-pass-rate flat across ALL members (guard: cheaper tier must not
281
- regress pass on the hard ones -- that is the anchor-1 trap).
282
- - **Effort:** LOW-MED. `detect_complexity` already exists; wire it to the tier
283
- map and gate on the bench.
284
-
285
- ### Rank 3 -- Root-cause-clustered parallel fix-loops
286
-
287
- - **Pattern:** iterate-fix-failing-tests + "cluster before you parallelize"
288
- (`managed-agents`); Parallelization for independent slices
289
- (`agent-patterns`).
290
- - **Concrete:** on a code-review/test BLOCK, bucket failures by root module
291
- and fan out ONE fix-worker per INDEPENDENT cluster (worktree per cluster),
292
- then re-run the WHOLE suite once at merge as the independent verify. Do NOT
293
- fan out per-test -- failures share root causes, per-test workers duplicate
294
- the same fix and conflict (the cookbook's own `test_mean` caveat).
295
- - **Effect:** wall-clock collapse on multi-cluster failures (parallel vs
296
- serial); fewer iterations via root-cause (not symptom) fixes.
297
- - **Bucket:** (a) for the orchestration (fan-out + merge + whole-suite
298
- re-verify happen in run.sh / fleet, no prompt-text change). (c) for
299
- proving it -- parallel worktree fix-loops must be validated off-worktree on
300
- real multi-failure builds.
301
- - **Bench validation:** wall-clock drops on corpus members that produce
302
- multi-cluster failures; verified-pass-rate flat (the merge whole-suite
303
- re-run is the non-negotiable guard against over-fix/regression).
304
- - **Effort:** MED. Clustering heuristic + worktree fan-out + merge verify.
305
-
306
- ### Rank 4 -- Per-role tool-scoping in the SDLC fleet
307
-
308
- - **Pattern:** coordinate-specialist-team "narrowest tool allowlist per role"
309
- (`managed-agents`); tool descriptions drive behavior.
310
- - **Concrete:** give each fleet role (architect, dev, SDET, reviewer) the
311
- minimal allowed-tools list it needs (reviewer: read-only; researcher:
312
- web+read only). Claude and Codex both support per-invocation tool
313
- restriction -- provider-agnostic.
314
- - **Effect:** fewer wrong-turn iterations (a reviewer cannot wander into
315
- bash); smaller blast radius. Iterations lever, modest.
316
- - **Bucket:** (a). Invocation tool lists, no prompt text.
317
- - **Bench validation:** iterations flat-or-down, verified-pass-rate flat. This
318
- one mostly de-risks; expect small bench movement. If the bench does not
319
- move, ship only if it reduces wrong-turn incidents in the transcript
320
- (secondary signal), else defer (ponytail: do not ship a no-op).
321
- - **Effort:** LOW.
322
-
323
- ### Rank 5 -- Structured distilled-return contract for workers (coordinator economics)
324
-
325
- - **Pattern:** plan-big-execute-small "workers return DISTILLED summaries, not
326
- raw material" + XML/JSON structured handoff (`managed-agents`,
327
- `agent-patterns`).
328
- - **Concrete:** enforce that fleet workers return a small structured payload
329
- (JSON) up to the coordinator, never dump raw file/log/page content back up
330
- the chain. Keeps the coordinator context small -> cheaper, sharper
331
- synthesis. Gate the fan-out on a granularity heuristic (only shard genuinely
332
- token-heavy INDEPENDENT slices; the cookbook warns over-sharding RAISES the
333
- bill and narrow tasks do not pay).
334
- - **Effect:** $/build reduction on token-heavy multi-worker builds; guards
335
- against the degenerate "one frontier round-trip for nothing" case.
336
- - **Bucket:** (a) for the worker return contract and fan-out granularity
337
- gate (fleet orchestration). NOTE: if the distilled summaries are
338
- concatenated into the NEXT `build_prompt()` iteration, that concatenation
339
- path is (b) -- keep the contract change on the worker->coordinator hop, not
340
- the coordinator->next-prompt hop, to stay in (a).
341
- - **Bench validation:** $/build drops on token-heavy corpus members;
342
- verified-pass-rate flat (guard: distillation must not summarize away
343
- nuance the grader checks).
344
- - **Effort:** MED.
345
-
346
- ### Rank 6 -- Confidence-calibrated escalation lane (already partly shipped)
347
-
348
- - **Pattern:** gate-human-in-the-loop decide/escalate calibration
349
- (`managed-agents`).
350
- - **Concrete:** the uncertainty-gated escalation is already default-on
351
- (`run.sh:18236`). This item TUNES the confidence threshold so the confident
352
- majority stays in the fast/cheap autonomous lane and only the genuinely
353
- low-confidence + unsafe tail escalates/handoffs (never fake-greens, never
354
- blocks-to-ask -- honors the no-human-in-loop runtime rule). Route the
355
- low-confidence tail to a stronger model rather than a human where the action
356
- is reversible.
357
- - **Effect:** avoids MAX_ITERATIONS burn on stuck loops (caps wasted
358
- iterations); reserves expensive lane for the tail.
359
- - **Bucket:** (a). Threshold + routing, no prompt text.
360
- - **Bench validation:** iterations drop on corpus members that currently
361
- thrash toward the cap; verified-pass-rate flat.
362
- - **Effort:** LOW.
363
-
364
- ### Rank 7 -- Enriched findings-injection text (FOUNDER-GATED)
365
-
366
- - **Pattern:** evaluator-optimizer "feed specific feedback + prior attempts
367
- back to the generator" + outcome-grader rubric discipline
368
- (`agent-patterns`, `managed-agents`). This is our highest-leverage
369
- iterations lever AND the most likely to be byte-locked.
370
- - **Concrete:** `LOKI_INJECT_FINDINGS` already injects structured per-finding
371
- records into the next prompt (default-on). ENRICHING that injected TEXT
372
- (better-targeted, rubric-shaped, one-bullet-per-failure format) would make
373
- each retry more directed and converge in fewer passes. BUT the injected text
374
- flows through `build_prompt()`, whose output is pinned by the 60-fixture
375
- SHA-256 parity lock (`loki-ts/tests/parity/build_prompt.test.ts`,
376
- `loki-ts/src/runner/build_prompt.ts`, gold under
377
- `loki-ts/tests/fixtures/build_prompt/`).
378
- - **Split (per anchor 2):**
379
- - (a) part: tuning WHEN findings are injected / WHICH findings are selected
380
- (selection logic upstream of the prompt) -- changeable now if it does not
381
- alter the emitted text bytes.
382
- - (b) part: changing the injected TEXT / format / rubric wording -- requires
383
- founder authorization to unlock the byte-lock, then regenerate all 60
384
- fixtures via `run-bash.sh` and keep bash<->TS parity 60/60.
385
- - **Effect:** fewer iterations-to-completion (directed retries). Potentially
386
- large, but gated.
387
- - **Bucket:** (b) for the text change; (a) for the selection-logic half.
388
- - **Bench validation:** iterations drop, verified-pass-rate flat-or-up. Prove
389
- off-worktree (hermetic Bun integration test with stub judge, then real
390
- builds).
391
- - **Effort:** MED code + HIGH process (founder unlock + fixture regen +
392
- full council + local-ci). Do NOT start the (b) half without authorization.
393
-
394
- ---
395
-
396
- ## 4. Sequencing for the ultracode phase
397
-
398
- 1. **Deliverable #1 first: lock the harness + baseline.** Reconcile the
399
- iterations source (2c.1), confirm wall-clock coverage (2c.2), lock the 5-15
400
- spec corpus (2c.3), ship the 2-spec smoke check (2c.4), then run the
401
- baseline: N real off-worktree builds -> committed
402
- `benchmarks/results/<baseline>.json`. Nothing else ships until this exists.
403
- 2. **Bucket-(a) wins, ranked, each bench-gated.** In order: Rank 1 (council
404
- knob sweep) -> Rank 2 (complexity->tier routing) -> Rank 6 (escalation
405
- threshold) -> Rank 4 (per-role tool scoping) -> Rank 3 orchestration half
406
- -> Rank 5 worker-return contract. Each one: change, re-run corpus, apply
407
- the gate rule (2e). If the bench does not move the right way, do not ship
408
- it (ponytail: no no-ops).
409
- 3. **Bucket-(c) validation for anything needing real parallel builds** (Rank 3
410
- fix-loop fan-out): prove off-worktree on real multi-failure builds before
411
- shipping.
412
- 4. **Founder-gated items LAST.** Rank 7 (b) half only after: (i) bucket-(a)
413
- wins are banked and measured, (ii) explicit founder authorization to unlock
414
- `build_prompt()`, (iii) fixture regen + 60/60 parity + full 3-reviewer
415
- council + local-ci green. Do the (a) selection-logic half of Rank 7 in
416
- step 2 if it stands alone.
417
- 5. **Every ship:** full gate is back (Wednesday 2026-07-08, the 1-week
418
- relaxation has expired). Runtime/council changes = full 3-reviewer council
419
- (2 Opus + 1 Sonnet, unanimous APPROVE, loop to 3/3) + `local-ci.sh` green +
420
- watch all GH workflows. Prove RARV-C changes with hermetic Bun integration
421
- tests (stub judge, `LOKI_OVERRIDE_REAL_JUDGE=0`, mkdtemp scratch, no token
422
- cost) -- pattern already established in
423
- `loki-ts/tests/integration/override_on_block.test.ts`.
424
-
425
- ---
426
-
427
- ## 5. Explicit "do NOT do" list
428
-
429
- Tempting things that re-architect the moat, hit the byte-lock, or fabricate
430
- numbers:
431
-
432
- 1. **Do NOT replace the completion council with a single-LLM outcome-grader.**
433
- That kills the 3-reviewer rigor moat -- the exact thing we are ahead on.
434
- Lift the rubric DISCIPLINE (checkable criteria, evidence-earned pass,
435
- one-bullet-per-failure feedback, same-gap non-convergence detection), NOT
436
- the single-judge architecture.
437
- 2. **Do NOT add an LLM-judge to the bench grader.** The grader is
438
- deterministic (`success = exit==0` on held-out acceptance) and the
439
- credibility invariant is enforced in code
440
- (`validate_adapter_output` rejects any self-judged key). An LLM judge is a
441
- second thing you must hold fixed and it breaks the invariant. Specs are
442
- code -- acceptance is machine-checkable for free.
443
- 3. **Do NOT trust `completion_claimed` / council APPROVE as the bench pass
444
- signal.** That is grading the loop's self-assessment -- the fake-green
445
- failure mode. Pass = independent deterministic acceptance only.
446
- 4. **Do NOT touch `build_prompt()` output text without founder authorization.**
447
- 60-fixture SHA-256 byte-mirror parity lock. Any text change = regenerate
448
- gold + keep bash<->TS 60/60 or CI (`parity-drift`) fails. This gates
449
- Rank 7's (b) half.
450
- 5. **Do NOT change the corpus, grader, or price table across a before/after
451
- pair.** Comparability dies; the number becomes a fabrication. Additive
452
- output fields are safe; corpus churn is not.
453
- 6. **Do NOT cite the cookbook's headline numbers as ours.** "~2.5x cheaper /
454
- ~3x faster" (plan-big-execute-small) and "84-98% billed at worker rate" are
455
- THEIR task on THEIR corpus. Our numbers come from our harness, later.
456
- 7. **Do NOT over-shard plan-big-execute-small or fan fix-workers per-test.**
457
- The cookbook's own caveats: over-sharding RAISES the bill (delegation floor
458
- cost), narrow tasks do not pay, and per-test workers duplicate shared-root
459
- fixes and conflict. Cluster by root cause first, then parallelize across
460
- clusters.
461
- 8. **Do NOT run a real engine build from the worktree to validate any of
462
- this.** TARGET_DIR resolves onto the worktree and self-mutates it. Baseline
463
- and all (c) validation run from an isolated source copy with cwd +
464
- `LOKI_TARGET_DIR` pinned to scratch (the speed-benchmark.sh discipline).
465
- 9. **Do NOT re-scope the sandboxes-production infra work here.** It is already
466
- #2b/#8b/#10 in autonomi-saas. Reference the cookbook as an impl, do not
467
- re-derive or re-rank it.
468
- 10. **Do NOT ship a change that does not move the bench the right way.** The
469
- gate rule (2e) is binding: improve >=1 of {iterations, $/build,
470
- wall-clock} AND no verified-pass-rate regression, or it does not ship.
@@ -1,194 +0,0 @@
1
- # Shareable Proof-of-Run: Implementation Plan (v7.19.3)
2
-
3
- Architect plan for adding opt-in shareability to the proof-of-run artifact
4
- without breaking the v7.18.2 zero-egress posture. Design only.
5
-
6
- ## 1. Verified current state
7
-
8
- All claims read from source.
9
-
10
- **Generator** `autonomy/lib/proof-generator.py` (689 lines)
11
- - `_build_proof` (line 366) assembles the frozen schema v1.0 dict. `deployment`
12
- set at line 401: `{"deployed_url": deployed_url, "public_url": None}`.
13
- `public_url` is ALWAYS `None` at generate time. This is the publish-time
14
- injection slot the design hangs on.
15
- - `_build_social_hook` (line 444) computes the one-line hook from already-redacted
16
- fields only: `cost.usd` via `_fmt_usd_hook` (line 427), `files_changed.count`,
17
- and council ratio via `_council_ratio` (line 406). Cost clause omitted when usd
18
- is None (never fabricates `$0.00`).
19
- - `_render_html` (line 562) loads `proof-template.html`, replaces
20
- `__PROOF_OG_DESCRIPTION__` (og + twitter metas) with `_attr_esc(hook)`, then
21
- replaces `__PROOF_JSON__` (escaping `<` as `<`). Falls back to
22
- `_render_fallback_html` (line 470) when template missing.
23
- - CHOKEPOINT: `generate` (line 582) calls `proof_redact.redact_tree(proof)` once
24
- (line 609), refuses to emit if redaction did not run (line 613), applies length
25
- caps AFTER redaction (line 619), then hashes and writes proof.json + index.html.
26
-
27
- **Template** `autonomy/lib/proof-template.html` (803 lines)
28
- - Self-contained / zero-egress by contract (header comment lines 1-40). Social
29
- meta lines 46-55: og:title, og:description, twitter:card=summary,
30
- twitter:description. Line 46: "No og:image (would break self-containment)" -
31
- preserved by this plan.
32
- - Hero markup lines 261-265 (`.hero`, `#heroLine`, `#heroSub`, `#heroActions`);
33
- `.hero-actions`/`.btn` CSS at 105-115. `renderHero` (line 426) builds the hero
34
- client-side. `renderCta` (line 732) emits command blocks with `data-copy`.
35
- - `wireCopy` (line 762) is a delegated click handler keying off `data-copy`,
36
- using `navigator.clipboard` with `execCommand` fallback. PATTERN to mirror for
37
- share buttons + copy-link.
38
- - Template reads `deployment.public_url` at line 466 (`renderTier1`).
39
-
40
- **CLI** `autonomy/loki`
41
- - `cmd_proof` (line 26277): list/show/open/share. `share` (26393) gates
42
- `--hosted` to `_loki_hosted_publish_proof` (26113, posts redacted bytes to
43
- `LOKI_HOSTED_ENDPOINT`, honest "no backend yet" otherwise), else uploads
44
- index.html AS-IS to a gist via `_loki_gist_upload` (26021, `gh gist create`,
45
- exposes `LOKI_LAST_GIST_URL`). The default gist path never fills public_url or
46
- re-renders.
47
- - Social hook is reimplemented inline in Python at 26503-26553 (duplicates
48
- `_build_social_hook`). This plan adds no third copy.
49
-
50
- **Dashboard** `dashboard/server.py`: `_proofs_dir` (7668), `_safe_proof_run_dir`
51
- (7672, realpath-contained), `GET /api/proofs` (7689). Read-only consumer;
52
- untouched.
53
-
54
- **Redaction** `autonomy/lib/proof_redact.py`: `redact_tree` (266),
55
- `redact_value` (260), `set_context`/`reset_context` (37/51), `RULES_VERSION =
56
- "1.0"` (29). Reused, never reinvented.
57
-
58
- **Existing tests**: `tests/test_proof_html.py` (`test_no_external_resource_refs`
59
- forbids `src=`, `@import`, `url(http`, any non-allowlisted `https?://`; allowlist
60
- only `github.com/asklokesh/loki-mode`; plus null-cost-never-renders-$0.00),
61
- `tests/test_proof_redaction.py` (secret-class + e2e), `tests/cli/test-proof-command.sh`,
62
- `tests/dashboard/test_proofs_routes.py`.
63
-
64
- **Dependency posture**: no Pillow/cairo/cairosvg. Local PNG rasterization would
65
- add a dependency and break the zero-dep local posture - ruled out.
66
-
67
- ## 2. The og:image decision
68
-
69
- CHOSEN: keep the local proof zero-egress with NO og:image; add a branded in-page
70
- card rendered from the redacted dict; inject og:image and share-target URLs ONLY
71
- at publish time via the existing `deployment.public_url` slot, on an
72
- HTML-serving host.
73
-
74
- - Option (a) data-URI og:image: REJECTED. og:image is spec'd as a URL; scrapers
75
- do not reliably honor data-URI og:image. Bloat for zero benefit.
76
- - Option (b) separate card file referenced only at publish: PARTIALLY ADOPTED. A
77
- real og:image needs a public URL, absent at generate time. Reference no image
78
- at generate; at publish (only if the proof reaches an HTML-serving host
79
- returning a public URL) that host is where og:image is set.
80
- - Option (c) branded in-page card: ADOPTED as the always-on self-contained
81
- visual. Inline CSS / inline SVG, rendered client-side from the redacted dict.
82
- Zero egress, zero new deps, redaction-safe.
83
-
84
- HONEST GIST LIMITATION: `loki proof share <id>` publishes to a GitHub Gist. The
85
- gist page serves GitHub's own og tags (profile picture), not the uploaded HTML's
86
- og tags; `raw.githubusercontent.com` serves `text/plain`, not scraped. So the
87
- gist path does NOT produce a rich preview of the proof card. Only an
88
- HTML-serving host returning a real public URL served as `text/html` (the
89
- `LOKI_HOSTED_ENDPOINT` seam) can. Stated plainly in docs + CLI output.
90
-
91
- UNIFYING INSIGHT: og:image, share-button `url=`, and copy-link all need a public
92
- URL absent at `file://` generate time. All three key off
93
- `deployment.public_url`: null at generate (share degrades to text-only/hidden),
94
- populated at publish.
95
-
96
- ## 3. Disjoint dev slices
97
-
98
- Binding constraints (every slice): no VERSION bump; no commits; no emojis; no em
99
- or en dashes (ASCII hyphen only); no new runtime dependencies; the default
100
- generate path stays byte-for-byte zero network calls.
101
-
102
- **Slice A - Template: branded card + JS-click share buttons**
103
- (`autonomy/lib/proof-template.html` only)
104
- - Style the hero (261-265) into a branded card: what was built (files_changed +
105
- spec source), verified (council verdict/ratio + gates), cost (cost.usd),
106
- duration (wall_clock_sec), plus Loki/Autonomi branding. Inline CSS / inline SVG.
107
- Rendered by `renderHero` from the redacted dict; no new schema fields.
108
- - Add a share row in `.hero-actions` using `data-share` attributes (mirror
109
- `data-copy`): X/Twitter, LinkedIn, Copy link. NO literal `https://` href in
110
- static HTML (keeps `test_no_external_resource_refs` green). A new delegated
111
- handler assembles the intent URL at click time:
112
- - X: `https://twitter.com/intent/tweet?text=<hook>&url=<public_url>` (hook from
113
- og:description meta; public_url from parsed proof).
114
- - LinkedIn: `https://www.linkedin.com/sharing/share-offsite/?url=<public_url>`
115
- (URL only; LinkedIn ignores prefilled text).
116
- - Copy link: writes public_url via the clipboard path wireCopy uses.
117
- - When public_url is null (default local case): share buttons hide or fall back
118
- to copy-the-hook-text; never emit a broken `url=`.
119
- - og:image meta only as empty/absent default; populated by the publish path.
120
-
121
- **Slice B - Generator: hook plumbing + public_url passthrough**
122
- (`autonomy/lib/proof-generator.py` only)
123
- - Add `LOKI_PROOF_SHARE_BUTTONS` (default ON; justified below) conditionally
124
- including the share-row markers. Reuse `_build_social_hook`.
125
- - public_url stays None at generate. Optional `LOKI_PROOF_PUBLIC_URL` env, when
126
- set, threads into deployment.public_url BEFORE the redaction chokepoint.
127
- Default None. No og:image here. No network calls.
128
-
129
- **Slice C - CLI: publish-time re-render + og:image/public_url injection**
130
- (`autonomy/loki` only; OWNS the re-render)
131
- - Hosted path (`_loki_hosted_publish_proof`, 26113): after the host returns a
132
- public URL, re-render with deployment.public_url set + og:image set to the
133
- host-minted card URL, then upload. Re-render reuses the generator (env var) so
134
- redaction runs again over the URL-injected dict - never a hand-built body.
135
- - Gist path: byte-for-byte unchanged EXCEPT one honest stdout note (gist previews
136
- show GitHub's og tags, not the proof card; point to --hosted). Do not fabricate
137
- a public_url for gist.
138
-
139
- **Slice D - Docs** (this file + a short note in proof docs / wiki): zero-egress
140
- invariant, opt-in publish path, gist-vs-hosted preview reality, LinkedIn text
141
- limitation.
142
-
143
- Recommended parallelism: A, B, D in parallel; C after B's flag contract is
144
- agreed.
145
-
146
- ## 4. Test plan
147
-
148
- Model on `tests/test_proof_html.py`, `tests/test_proof_redaction.py`.
149
-
150
- 1. Default generate path zero-egress: extend `test_no_external_resource_refs` -
151
- generate with share buttons ON, assert NO `src=`, no `@import`, no `url(http`,
152
- no `https?://` URL except the github.com/asklokesh/loki-mode allowlist. The
153
- load-bearing guard that the JS-click design adds no literal share URLs.
154
- 2. Redaction holds on card + share text: reuse the e2e pattern - plant secrets in
155
- council summaries / spec / diffs, generate, assert none survive anywhere in
156
- index.html incl. card markup + og:description. Card renders ONLY redacted
157
- fields.
158
- 3. Share button URLs well-formed + prefilled: unit-test the JS URL assembly -
159
- given public_url, X intent contains URL-encoded hook + url=<public_url>;
160
- LinkedIn contains url=<public_url> no text; copy-link copies public_url. Null
161
- public_url -> no malformed url=.
162
- 4. og:image populated ONLY on publish: default page has no og:image; simulate
163
- hosted re-render with a public URL, assert og:image + public_url populated and
164
- re-redacted; gist path leaves page unchanged + prints the note.
165
- 5. Null-cost credibility preserved: card never shows `$0.00` when cost uncollected.
166
-
167
- ## 5. Honest limits
168
-
169
- - Data-URI og:image not reliably scraped (og:image is spec'd as a URL); not used.
170
- - GitHub gist yields no rich preview of the proof card (gist page = GitHub og
171
- tags; raw = text/plain).
172
- - A rich social preview requires an HTML-serving host returning a public URL (the
173
- LOKI_HOSTED_ENDPOINT seam or any static HTML host the user configures). No
174
- official Loki hosted backend yet; the seam is honest about this.
175
- - LinkedIn share ignores prefilled text; it scrapes the destination og tags, so
176
- LinkedIn previews depend on the hosted og:image. X intent carries the hook.
177
- - Sharing is manual / opt-in: a button is inert until clicked; no auto egress.
178
- - No hosted gallery / discovery feed in this release.
179
-
180
- Share-buttons default ON: with JS-click construction there is no literal external
181
- URL in the static page and no network call until the user clicks. The buttons are
182
- inert markup until acted on, so they cannot violate the default zero-egress
183
- invariant. Default ON maximizes the word-of-mouth lever at zero cost to the
184
- posture; `LOKI_PROOF_SHARE_BUTTONS=0` opts out.
185
-
186
- ## Zero-egress invariant (precise)
187
-
188
- - STAYS zero-egress (byte-for-byte zero network calls): generating a proof and
189
- opening the local index.html. No og:image, no src=, no @import, no web fonts,
190
- no literal share URLs. Card + hook render from the embedded redacted JSON.
191
- Share buttons present but inert.
192
- - OPT-IN egress (only on explicit user action): clicking a share button, copying
193
- the link, and `loki proof share <id>` / `--hosted`. og:image and
194
- deployment.public_url are populated only on the hosted publish re-render.