loki-mode 11.3.0 → 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 (215) 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/voter-agents.sh +1 -1
  11. package/autonomy/loki +99 -75
  12. package/autonomy/run.sh +30 -18
  13. package/autonomy/sandbox.sh +1 -1
  14. package/autonomy/tui.sh +6 -5
  15. package/autonomy/verify.sh +1 -1
  16. package/bin/loki +166 -59
  17. package/completions/_loki +2 -0
  18. package/completions/loki.bash +2 -2
  19. package/dashboard/__init__.py +1 -1
  20. package/dashboard/server.py +25 -31
  21. package/docs/ARCHITECTURE.md +337 -0
  22. package/docs/BRANDING.md +124 -0
  23. package/docs/CLI-REFERENCE.md +7 -1
  24. package/docs/COMPONENTS.md +447 -0
  25. package/docs/DEPLOYMENT.md +9 -9
  26. package/docs/DOCKER.md +469 -0
  27. package/docs/INSTALLATION.md +67 -1045
  28. package/docs/KNOWN-ISSUES.md +11 -35
  29. package/docs/TESTING.md +161 -0
  30. package/docs/air-gapped.md +1 -2
  31. package/docs/alternative-installations.md +14 -24
  32. package/docs/architecture/DECISIONS.md +333 -0
  33. package/docs/audit-logging.md +7 -7
  34. package/docs/authentication.md +3 -3
  35. package/docs/authorization.md +1 -1
  36. package/docs/certification/04-production-deployment/lab.md +6 -6
  37. package/docs/certification/04-production-deployment/lesson.md +4 -4
  38. package/docs/certification/README.md +1 -1
  39. package/docs/control-plane-container.md +2 -2
  40. package/docs/dev/real-run.md +34 -0
  41. package/docs/dev/release-checklist.md +2 -2
  42. package/docs/exit-codes.md +3 -3
  43. package/docs/git-workflow.md +3 -3
  44. package/docs/metrics.md +37 -55
  45. package/docs/network-security.md +1 -1
  46. package/docs/siem-integration.md +5 -5
  47. package/docs/v10/CLI-MODERN.md +4 -3
  48. package/docs/v10/DECISIONS.md +44 -0
  49. package/docs/v10/DEPS.md +22 -22
  50. package/docs/v10/ENGINE.md +1 -1
  51. package/docs/v10/FAILURE-CLASSES.md +118 -1
  52. package/docs/v10/FOUNDER-QUEUE.md +1 -0
  53. package/docs/v10/GUARDS.md +13 -0
  54. package/docs/v10/LEGACY-REMOVAL.md +4 -6
  55. package/docs/v10/METRICS.md +2 -2
  56. package/docs/v10/MODERNIZE.md +1 -1
  57. package/docs/v10/OPERATING-MODEL.md +2 -1
  58. package/docs/v10/PROGRESS.md +29 -0
  59. package/docs/v11/COST-HALF.md +352 -0
  60. package/docs/v11/MARKET-SLICES.md +315 -0
  61. package/docs/v11/REGISTRIES.md +730 -0
  62. package/loki-ts/data/model-pricing.json +52 -24
  63. package/loki-ts/dist/loki.js +1036 -957
  64. package/mcp/__init__.py +1 -1
  65. package/package.json +1 -1
  66. package/packages/control-plane/dist/server.js +2467 -736
  67. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  68. package/src/protocols/mcp-client.js +6 -2
  69. package/src/protocols/mcp-server.js +13 -3
  70. package/tools/audit-docs.py +1 -1
  71. package/web-app/dist/assets/{AdminPage-D_e45uTw.js → AdminPage-CMkHNJbF.js} +1 -1
  72. package/web-app/dist/assets/{Avatar-T3nIpoaf.js → Avatar-BJyjV7Zi.js} +1 -1
  73. package/web-app/dist/assets/{Badge-BKqb59pP.js → Badge-D572l0uq.js} +1 -1
  74. package/web-app/dist/assets/{Button-DjVlkh8_.js → Button-T4BnOZgl.js} +1 -1
  75. package/web-app/dist/assets/{CockpitPage-DXJgLGmh.js → CockpitPage-Cj_GFsNn.js} +1 -1
  76. package/web-app/dist/assets/{ComparePage-BRP_eVc_.js → ComparePage-A8m4ZXak.js} +1 -1
  77. package/web-app/dist/assets/{ErrorBoundary-CLjpGLjC.js → ErrorBoundary-hugCg5yg.js} +1 -1
  78. package/web-app/dist/assets/{EvidenceReceiptPanel-DX-vb4Xy.js → EvidenceReceiptPanel-CuJKDC2G.js} +1 -1
  79. package/web-app/dist/assets/{GitHubIssuesPanel-214HVHtX.js → GitHubIssuesPanel-BYGKjarC.js} +1 -1
  80. package/web-app/dist/assets/{GitHubPRsPanel-BEiZKc4t.js → GitHubPRsPanel-c7sFIJlf.js} +1 -1
  81. package/web-app/dist/assets/{HomePage-VvMHS5ga.js → HomePage-A1MIkG2P.js} +2 -2
  82. package/web-app/dist/assets/{LoginPage-5WD-v7n3.js → LoginPage-8KQMRhtR.js} +1 -1
  83. package/web-app/dist/assets/{MagicPage-DUQT_Jye.js → MagicPage-C05QW2Lx.js} +1 -1
  84. package/web-app/dist/assets/{MetricsPage-lga-z79v.js → MetricsPage-Oukv5hme.js} +1 -1
  85. package/web-app/dist/assets/{NotFoundPage-CGhBX3G1.js → NotFoundPage-DKIwsawz.js} +1 -1
  86. package/web-app/dist/assets/{ProjectPage-CdzF2GzZ.js → ProjectPage-DwFRPLCG.js} +3 -3
  87. package/web-app/dist/assets/{ProjectsPage-DRG64N8s.js → ProjectsPage-CgY4YYDX.js} +1 -1
  88. package/web-app/dist/assets/{SettingsPage-5fzW9Frb.js → SettingsPage-BpfcSjUA.js} +1 -1
  89. package/web-app/dist/assets/{ShowcasePage-DrTdxO4y.js → ShowcasePage-BqBakC4K.js} +1 -1
  90. package/web-app/dist/assets/{SystemSettingsPage-C9Mqs6Rd.js → SystemSettingsPage-CZLu5VB0.js} +1 -1
  91. package/web-app/dist/assets/{TeamsPage-CUGPdSWo.js → TeamsPage-D55S1jKz.js} +1 -1
  92. package/web-app/dist/assets/{TemplatesPage-CNraDY0F.js → TemplatesPage-D3SydvxN.js} +1 -1
  93. package/web-app/dist/assets/{TerminalOutput-BIu_6Pea.js → TerminalOutput-hNg8G1-e.js} +1 -1
  94. package/web-app/dist/assets/{activity-Bk-kgqaf.js → activity-D2C0VagO.js} +1 -1
  95. package/web-app/dist/assets/{bell-BXmUdmo8.js → bell-CMvYi36w.js} +1 -1
  96. package/web-app/dist/assets/{bot-CiuzXxUR.js → bot-BvtQ6lmo.js} +1 -1
  97. package/web-app/dist/assets/{check-BEzjXppd.js → check-B13xkXed.js} +1 -1
  98. package/web-app/dist/assets/{chevron-left-AYWCXHf8.js → chevron-left-emu6r49E.js} +1 -1
  99. package/web-app/dist/assets/{circle-alert-BNg2uSRq.js → circle-alert-CExlwjuy.js} +1 -1
  100. package/web-app/dist/assets/{clock-DTj0kkGT.js → clock-D7Uas3oL.js} +1 -1
  101. package/web-app/dist/assets/{cloud-x4nTDBLT.js → cloud-CkB4S86C.js} +1 -1
  102. package/web-app/dist/assets/{code-xml-BVh_MLrk.js → code-xml-SL9IIWIn.js} +1 -1
  103. package/web-app/dist/assets/{database-DdfBaowG.js → database-BQFkd7t1.js} +1 -1
  104. package/web-app/dist/assets/{dollar-sign-XuYFmAOY.js → dollar-sign-qHmnNYsU.js} +1 -1
  105. package/web-app/dist/assets/{file-code-corner-D4cRnmeL.js → file-code-corner-C2YUDP0K.js} +1 -1
  106. package/web-app/dist/assets/{file-plus-CyoVlHc_.js → file-plus-C_ooIkDe.js} +1 -1
  107. package/web-app/dist/assets/{globe-Y6IK2RPW.js → globe-CQ-GL485.js} +1 -1
  108. package/web-app/dist/assets/{hammer-BKzr9VZI.js → hammer-U05L_D7V.js} +1 -1
  109. package/web-app/dist/assets/{index-B20cSx5G.js → index-CooHd7I-.js} +3 -3
  110. package/web-app/dist/assets/{layers-DebNOhGS.js → layers-Buo17rjW.js} +1 -1
  111. package/web-app/dist/assets/{loader-circle-DyGbrEgd.js → loader-circle-15vK3oV1.js} +1 -1
  112. package/web-app/dist/assets/{lock-BKPpyt20.js → lock-BeXLebuJ.js} +1 -1
  113. package/web-app/dist/assets/{package-egF5Wi4y.js → package-MVh_6-6R.js} +1 -1
  114. package/web-app/dist/assets/{plus-OiEgKIc-.js → plus-Dh_nd9vS.js} +1 -1
  115. package/web-app/dist/assets/{refresh-cw-CzKvrONq.js → refresh-cw-C9cBJEAT.js} +1 -1
  116. package/web-app/dist/assets/{rotate-ccw-Bu2mII0p.js → rotate-ccw-D3PAtzST.js} +1 -1
  117. package/web-app/dist/assets/{scroll-text-CSkiyax8.js → scroll-text-DZCoXQjo.js} +1 -1
  118. package/web-app/dist/assets/{server-DlPthJFw.js → server-OCOLI5J_.js} +1 -1
  119. package/web-app/dist/assets/{shield-alert-CbpHWQQX.js → shield-alert-oVhmf1_h.js} +1 -1
  120. package/web-app/dist/assets/{thumbs-up-DgGpZe-Q.js → thumbs-up-B-kbX4vN.js} +1 -1
  121. package/web-app/dist/assets/{trash-2-BV3GlCB-.js → trash-2-EL6moveW.js} +1 -1
  122. package/web-app/dist/assets/{trending-down-Y4TJtXhD.js → trending-down-Cl3kjpsx.js} +1 -1
  123. package/web-app/dist/assets/{trending-up-DsDNoHZY.js → trending-up-DST7I6M2.js} +1 -1
  124. package/web-app/dist/assets/{upload-gkThrc_I.js → upload-CUOT780G.js} +1 -1
  125. package/web-app/dist/assets/{usePolling-jpNSeNAe.js → usePolling-Djmt90eb.js} +1 -1
  126. package/web-app/dist/assets/{user-3Zez1WOK.js → user-BRBohA6J.js} +1 -1
  127. package/web-app/dist/index.html +1 -1
  128. package/docs/ARCHITECTURE-OVERVIEW.md +0 -209
  129. package/docs/AUTONOMI-ECOSYSTEM.md +0 -107
  130. package/docs/COCKPIT-SPEC.md +0 -72
  131. package/docs/COCKPIT-UX-MANDATE.md +0 -53
  132. package/docs/COMPETITIVE-ANALYSIS.md +0 -303
  133. package/docs/COMPETITIVE-NEXT-10.md +0 -316
  134. package/docs/COMPETITIVE-RALPH-ZEROSHOT-2026-07-08.md +0 -81
  135. package/docs/DASHBOARD-9.12-EVIDENCE.md +0 -97
  136. package/docs/DASHBOARD-ARCHITECTURE.md +0 -425
  137. package/docs/DASHBOARD_V2_CHECKLIST.md +0 -243
  138. package/docs/DEMOS.md +0 -63
  139. package/docs/ENTERPRISE-IDENTITY-ROADMAP.md +0 -206
  140. package/docs/EVIDENCE-RECEIPT-BUILD-APPLICABILITY.md +0 -79
  141. package/docs/FEAT-PRDREUSE-DOCKER-PLAN.md +0 -144
  142. package/docs/GATE-FAILURE-TRIAGE.md +0 -254
  143. package/docs/HANDOFF-2026-08-03.md +0 -439
  144. package/docs/LOOP-CANDIDATE-PROPOSAL-v1.md +0 -167
  145. package/docs/LOOP-HARNESS-AUDIT.md +0 -684
  146. package/docs/MERGE-DEDUP-MAP.md +0 -420
  147. package/docs/MERGE-ROUTE-MAP.md +0 -139
  148. package/docs/MODEL-REGISTRY-PLAN.md +0 -155
  149. package/docs/OUTCOME-FRONTIER.md +0 -536
  150. package/docs/P2-SPEC-ROBUSTNESS-PLAN.md +0 -192
  151. package/docs/PLANS-INDEX.md +0 -32
  152. package/docs/PRD-REUSE-DONE-RECOGNITION-PLAN.md +0 -536
  153. package/docs/PROMPT-ABLATION-RESULT.md +0 -97
  154. package/docs/R4-TRUST-TRAJECTORY-DESIGN.md +0 -127
  155. package/docs/R5-AUTO-WIKI-DESIGN.md +0 -137
  156. package/docs/R6-ROLLBACK-CHECKPOINT-PLAN.md +0 -107
  157. package/docs/R7-ZERO-CONFIG-FIRST-RUN-PLAN.md +0 -137
  158. package/docs/R8-SHAREABLE-TEAM-ASSETS-PLAN.md +0 -129
  159. package/docs/R9-OPEN-CORE-HOOKS-PLAN.md +0 -113
  160. package/docs/RARV-C-100X-PLAN.md +0 -286
  161. package/docs/RARV-C-LOOP-EFFICIENCY-PLAN.md +0 -470
  162. package/docs/SHAREABLE-PROOF-PLAN.md +0 -194
  163. package/docs/SONNET5-DEFAULT-PLAN.md +0 -157
  164. package/docs/SPEED-AND-FIRST-PASS-PLAN.md +0 -281
  165. package/docs/STALE-STATE-AUDIT.md +0 -174
  166. package/docs/SYNERGY-TASKS.md +0 -143
  167. package/docs/TASKLIST-ACCURACY-PLAN.md +0 -355
  168. package/docs/TOP-100-BACKLOG.md +0 -159
  169. package/docs/V8-ACCEPTANCE-TRIAGE-2026-07-24.md +0 -114
  170. package/docs/V8-COMPLEXITY-AUDIT-2026-07-24.md +0 -45
  171. package/docs/V8-MAJOR-RELEASE-PLAN.md +0 -137
  172. package/docs/V8-OVERNIGHT-PLAN-2026-07-25.md +0 -82
  173. package/docs/V8-SDK-RESEARCH-RAW.md +0 -129
  174. package/docs/WELCOME-OPENER-PLAN.md +0 -106
  175. package/docs/adoption-baseline-2026-07-31.md +0 -84
  176. package/docs/architecture/bmad-integration-epic.md +0 -271
  177. package/docs/architecture/bmad-integration-review.md +0 -86
  178. package/docs/architecture/bmad-integration-validation.md +0 -249
  179. package/docs/architecture/bmad-loki-voice-agent-council-analysis.md +0 -61
  180. package/docs/auto-claude-comparison.md +0 -250
  181. package/docs/bug-fixes/agent-01-cli-fixes.md +0 -101
  182. package/docs/bug-fixes/agent-02-purplelab-fixes.md +0 -88
  183. package/docs/bug-fixes/agent-03-dashboard-fixes.md +0 -119
  184. package/docs/bug-fixes/agent-04-memory-fixes.md +0 -105
  185. package/docs/bug-fixes/agent-05-provider-fixes.md +0 -86
  186. package/docs/bug-fixes/agent-06-integration-fixes.md +0 -101
  187. package/docs/bug-fixes/agent-07-dash-run-fixes.md +0 -101
  188. package/docs/bug-fixes/agent-08-docker-fixes.md +0 -164
  189. package/docs/bug-fixes/agent-09-e2e-build-fixes.md +0 -69
  190. package/docs/bug-fixes/agent-10-e2e-fullstack-fixes.md +0 -102
  191. package/docs/bug-fixes/agent-11-e2e-session-fixes.md +0 -70
  192. package/docs/bug-fixes/agent-12-scenario-fixes.md +0 -120
  193. package/docs/bug-fixes/agent-13-enterprise-fixes.md +0 -143
  194. package/docs/bug-fixes/agent-14-uat-newuser-fixes.md +0 -88
  195. package/docs/bug-fixes/agent-15-uat-poweruser-fixes.md +0 -132
  196. package/docs/bug-fixes/agent-19-code-review.md +0 -316
  197. package/docs/bug-fixes/agent-20-architecture-review.md +0 -331
  198. package/docs/competitive/bolt-new-analysis.md +0 -579
  199. package/docs/competitive/emergence-others-analysis.md +0 -605
  200. package/docs/competitive/replit-lovable-analysis.md +0 -622
  201. package/docs/dashboard-guide.md +0 -487
  202. package/docs/enterprise/migration.md +0 -265
  203. package/docs/history/one-run-audit.md +0 -304
  204. package/docs/plans/FORGE-AUTONOMOUS-QUEUE.md +0 -312
  205. package/docs/plans/ULTRAPLAN-FORGE-BAAS.md +0 -612
  206. package/docs/plans/UT2-6-LSP-DIAGNOSTIC-BROADCAST.md +0 -394
  207. package/docs/prd-purple-lab-ide.md +0 -152
  208. package/docs/prd-purple-lab-platform-v2.md +0 -223
  209. package/docs/prd-purple-lab-platform.md +0 -319
  210. package/docs/retrospectives/v7.5.15-fleet-postmortem.md +0 -325
  211. package/docs/retrospectives/v7.5.15-honesty-audit.md +0 -136
  212. package/docs/retrospectives/v7.5.15-llm-failure-modes.md +0 -49
  213. package/docs/show-hn-post.md +0 -46
  214. package/docs/test-scenarios/enterprise-scenarios.md +0 -732
  215. package/docs/thick2thin.md +0 -173
@@ -1,127 +0,0 @@
1
- # R4: Visible Trust Trajectory - Design Note
2
-
3
- Status: implemented in worktree (not yet merged). Author: R4 release team.
4
- Verified against live source on 2026-06-03 (v7.8.3 worktree base; R1/R3/R5
5
- already shipped, so the arc is further along than the loki-plan doc states).
6
-
7
- ## The story no competitor tells
8
-
9
- Devin, Cursor, Windsurf, Claude Code, Aider et al. show you a single run.
10
- None show you whether the agent is getting more trustworthy on YOUR repo over
11
- time. Loki already runs a 3-reviewer council + RARV-C closure on every run and
12
- persists the result. R4 makes the resulting TRUST TRAJECTORY visible:
13
-
14
- - council approve-rate trending UP
15
- - gate pass-rate trending UP
16
- - iterations-to-completion trending DOWN
17
- - human interventions trending DOWN
18
-
19
- If the agent is earning autonomy on this repo, the trajectory shows it. That is
20
- compounding, repo-specific proof of trust -> stickiness.
21
-
22
- ## Honest-data rule (non-negotiable)
23
-
24
- Every number derives from REAL persisted run records. Never fabricate a trend.
25
- With fewer than 2 runs, the trajectory is reported as "not enough history yet"
26
- (insufficient=true), never a fake direction.
27
-
28
- ## Data source (REUSED, not new)
29
-
30
- R3 already established `.loki/proofs/<run_id>/proof.json` as the persistent,
31
- one-per-run history record (written by `autonomy/lib/proof-generator.py` at run
32
- completion, on both success and failure, unless `LOKI_PROOF=0`). The R3 cost
33
- timeline endpoint (`dashboard/server.py` `/api/cost/timeline`) already mines
34
- this exact directory for per-run cost history.
35
-
36
- R4 mines the SAME directory for the trust signals already present in each
37
- proof.json:
38
-
39
- | Trust signal | proof.json path | Notes |
40
- |-------------------------|------------------------------------------|-------|
41
- | council pass (per run) | `council.final_verdict` | APPROVE/APPROVED/COMPLETE => pass |
42
- | council ratio (per run) | `council.reviewers[].vote` (APPROVE/...) | secondary signal when verdict absent |
43
- | gate pass-rate (per run)| `quality_gates.passed` / `.total` | already aggregated by generator |
44
- | iterations (per run) | `iterations` (int or {count}) | iterations-to-completion |
45
- | files changed (per run) | `files_changed.count` | context, not a trust axis |
46
- | timestamp | `generated_at` (ISO 8601) | ordering axis |
47
-
48
- Human interventions: there is no per-run intervention counter persisted in
49
- proof.json today. Rather than fabricate one or add new instrumentation in this
50
- slice, R4 reports interventions as a derived best-effort signal ONLY when the
51
- proof carries it (`council.interventions` or top-level `interventions`), and
52
- otherwise marks that axis `available=false` with an honest note. This keeps the
53
- honest-data rule intact and leaves a clean seam for a future per-run
54
- intervention counter (a one-line add in proof-generator.py).
55
-
56
- ## Direction calculation (up / down / flat)
57
-
58
- For each numeric axis across the time-ordered run series:
59
-
60
- 1. Split the series into an earlier half and a later half (median split; odd
61
- counts drop the middle point so the two halves never overlap).
62
- 2. Compare the mean of the later half vs the earlier half.
63
- 3. delta = later_mean - earlier_mean. Direction:
64
- - `flat` if |delta| <= epsilon (epsilon scaled per axis; rates use 0.01).
65
- - `up` / `down` by sign of delta.
66
- 4. "Good direction" is axis-specific: higher is better for council/gate pass
67
- rates; lower is better for iterations + interventions. The `improving`
68
- boolean encodes whether the direction is the good one, so the UI can color
69
- green/red without re-encoding the per-axis polarity.
70
-
71
- Rationale for half-split vs least-squares slope: half-split is robust to a
72
- single noisy run, needs no float regression in bash, and is trivially testable
73
- with fixtures. A 2-run series degrades to last-vs-first, which is correct.
74
-
75
- ## Persistence (under .loki/metrics/, REUSED dir)
76
-
77
- The aggregated trajectory is persisted to
78
- `.loki/metrics/trust-trajectory.json` (schema_version 1). This is a derived
79
- cache, written by the `loki trust` command and the dashboard endpoint so other
80
- surfaces can read a single source of truth. It is NOT authoritative state: it
81
- is always recomputable from `.loki/proofs/`. Deleting it loses nothing.
82
-
83
- ## Surfaces
84
-
85
- 1. CLI: `loki trust [--json]` (NEW Bun-native command, mirrors `loki kpis`
86
- exactly). Falls through to a bash `cmd_trust` when bun is absent (kpis had
87
- no bash fallback; R4 adds one because the Python derivation is shared and
88
- trivial to call from bash, giving real bash+Bun parity).
89
- - `loki kpis` stays a single-run snapshot. R4 does NOT duplicate it; `trust`
90
- is the across-runs trajectory view. `loki kpis` output gains a one-line
91
- pointer to `loki trust` (no behavior change).
92
-
93
- 2. Dashboard endpoint: `GET /api/trust/trajectory` (NEW, mirrors
94
- `/api/cost/timeline`). Reads `.loki/proofs/*/proof.json`, returns the
95
- per-run series + per-axis direction + insufficient flag.
96
-
97
- 3. Dashboard panel: standalone `legacy-ui-static/trust.html` + `/trust` route
98
- (mirrors `cost.html` + `/cost`), plus a nav entry and SPA section in
99
- `build-standalone.js` (mirrors the cost panel wiring exactly).
100
-
101
- 4. WS push: the `_push_loki_state_loop` broadcasts a `trust_update` message
102
- when the trajectory's overall improving-count changes (mirrors the R3
103
- `budget_status` transition push). No new channel; reuses manager.broadcast.
104
-
105
- ## Parity + no-duplication audit
106
-
107
- - Data: reuses `.loki/proofs/` (R1/R3). No new run-time instrumentation.
108
- - Endpoint: new route, but copies the `/api/cost/timeline` read pattern and
109
- the `_proofs_dir()` / `_safe_json_read` helpers verbatim in spirit.
110
- - Panel: new `trust.html`, structurally a sibling of `cost.html`.
111
- - CLI: new `trust`, structurally a sibling of `kpis`. `kpis` unchanged except a
112
- one-line see-also.
113
- - Shared derivation: a single Python module
114
- (`autonomy/lib/trust_trajectory.py`) is the source of truth; the dashboard
115
- endpoint imports it, and the bash `cmd_trust` shells out to it. The Bun
116
- command reimplements the same pure logic in TS (parity-tested), matching how
117
- `kpis` has both a TS derivation and reads the same JSON the bash side writes.
118
-
119
- ## Test plan
120
-
121
- - Python: `tests/test_trust_trajectory.py` - aggregation from fixture
122
- proof.json files, direction calc (up/down/flat) per axis polarity, the
123
- insufficient-history (<2 runs) case, no-PII (only derived numbers + run_id +
124
- timestamps leave the function), malformed proof.json skipped not fatal.
125
- - TS: `loki-ts/tests/metrics/trust.test.ts` - same aggregation + direction
126
- parity on identical fixtures, insufficient case, JSON/human formatting.
127
- - All mocked from on-disk fixtures. No provider calls, no paid calls.
@@ -1,137 +0,0 @@
1
- # R5: Auto-wiki + Cited Codebase Q&A (Loki's DeepWiki) -- Design Note
2
-
3
- Status: implemented in worktree (do not commit to main). Target release: R5 of the
4
- competitive-stickiness arc. NO version bump in this worktree.
5
-
6
- ## Goal
7
-
8
- A persistent, queryable per-project wiki generated from the codebase, surfaced in
9
- the dashboard, with cited answers. Loki's answer to Devin DeepWiki. Sections cite
10
- the real source files they were built from; `loki wiki ask` returns a grounded,
11
- cited answer (citations = `file:line`). Generation is incremental: it skips when
12
- the codebase has not changed (reuses the R1 codebase-signature idea).
13
-
14
- ## What already exists (verified against source, 2026-06-03)
15
-
16
- | Asset | File | Reused? |
17
- |---|---|---|
18
- | `loki docs generate` (LLM-written README/ARCHITECTURE/...) | `autonomy/loki:20577` (`cmd_docs`) | Patterns reused: `_docs_scan_project`, `_docs_build_context`, `_docs_invoke_provider`, `_docs_write_manifest`. Not the command itself -- docs has no citations and no Q&A. |
19
- | Proof-of-run generator (Python core, thin CLI readers) | `autonomy/lib/proof-generator.py`, bash `cmd_proof`, `loki-ts/src/commands/proof.ts` | Architecture precedent reused exactly: Python core does the heavy work; bash + Bun are thin readers; dashboard exposes read APIs. |
20
- | PII redaction | `autonomy/lib/proof_redact.py` (`redact_tree`, `_redact_paths`) | Reused: wiki output is normalized to repo-relative paths and passed through the redactor so no `/Users/<name>/...` leaks. |
21
- | Org knowledge graph | `memory/knowledge_graph.py` (`OrganizationKnowledgeGraph`) | Token-overlap scoring idea reused (`_tokenize` / `query_patterns`). NOT a codebase index -- it aggregates `.loki/memory/semantic/*.json` patterns across projects, keyed on `~/.loki/knowledge`. See "Honest reuse" below. |
22
- | Memory retrieval | `memory/retrieval.py` (`MemoryRetrieval`) | Inspected. It retrieves memory entries (episodic/semantic/procedural), NOT source code. Not a code indexer. Not reused for code retrieval. |
23
- | Dashboard read-API + traversal-safety | `dashboard/server.py:7191` (`_safe_proof_run_dir`) | Pattern reused for the wiki section/path param (`_safe_wiki_section`). |
24
- | Dashboard web components | `legacy-ui/components/*.js` (Web Components) | New `loki-wiki-browser.js` follows the same `LokiElement` convention; registered in `index.js`. |
25
-
26
- ### Honest reuse statement
27
-
28
- The task says "reuse memory/knowledge_graph.py and memory/retrieval.py." Both were
29
- read. Neither is a *codebase* index: `knowledge_graph.py` aggregates cross-project
30
- *memory patterns* (`.loki/memory/semantic`), and `retrieval.py` retrieves *memory
31
- entries*, not source files. There was no existing per-file code index to query for
32
- grounded citations. So R5 adds a new lightweight, dependency-free code index
33
- (`autonomy/lib/wiki_index.py`) and reuses the parts that genuinely fit: the
34
- token-overlap retrieval scoring (ported from `knowledge_graph._tokenize` /
35
- `query_patterns`), the docs scanner, the proof manifest/signature idea, and the
36
- redactor. Reuse is stated where real; not fabricated to satisfy a constraint.
37
-
38
- ChromaDB (`tools/index-codebase.py`, MEMORY.md) is an OPTIONAL future backend. The
39
- core deliberately does NOT depend on it: it needs Docker + python3.12 and is not
40
- CI-safe. Default retrieval is deterministic and dependency-light.
41
-
42
- ## The grounding contract (the part that must be right)
43
-
44
- Fabricated citations are made structurally impossible, not merely prompt-discouraged:
45
-
46
- 1. **Index**: `wiki_index.py` scans source files (git-tracked when available, else a
47
- filtered `find`), splits each into line-anchored chunks
48
- `{file, start_line, end_line, text}` where `file` is REPO-RELATIVE.
49
- 2. **Retrieve** (`ask`): deterministic token-overlap scoring (no LLM, no network)
50
- selects the top-K chunks for the question. Each is a record we own.
51
- 3. **Prompt**: the LLM sees NUMBERED chunks `[1]..[K]` and is told to cite by chunk
52
- index only (`[1]`, `[2]`). It never emits raw paths.
53
- 4. **Map + validate**: indices in the answer are mapped back to `{file, start_line}`
54
- from the retrieval records. Every citation is then validated against the
55
- filesystem (file exists AND start_line <= file length). Non-resolving citations
56
- are DROPPED. The LLM can only reference chunks we supplied, and only ones that
57
- resolve on disk -- so a fabricated citation cannot survive.
58
- 5. **generate**: per-section "sources" are CODE-DERIVED (the files the scanner read,
59
- the real def/class line numbers from a grep parse), not LLM-emitted. The LLM
60
- writes prose; the citation list comes from the index.
61
-
62
- If the LLM is unavailable (CI, no provider), `ask` returns an EXTRACTIVE answer
63
- (the top chunk snippets with their real citations) and `generate` writes a
64
- template-based wiki whose citations are still the real scanned files. No fabrication
65
- in any path.
66
-
67
- ## Mocking the LLM in CI
68
-
69
- The Python core reads `LOKI_WIKI_LLM_STUB`:
70
- - unset -> call the real provider via the same path `_docs_invoke_provider` uses
71
- (`claude -p` etc.), OR fall back to extractive/template if no provider on PATH.
72
- - set to a file path -> read the stubbed completion from that file.
73
- - set to any other value -> use it literally as the completion.
74
-
75
- Tests set `LOKI_WIKI_LLM_STUB` so CI makes ZERO paid calls. This mirrors how the
76
- proof tests fake `gh`/`open` via PATH and env.
77
-
78
- ## Storage layout (per project, generated)
79
-
80
- ```
81
- .loki/wiki/
82
- wiki.json # structured: sections[], each with title, body, citations[]
83
- index.md # human-readable rendered wiki (overview + module list)
84
- architecture.md # rendered architecture section
85
- modules.md # rendered key-modules section
86
- data-flow.md # rendered data-flow section
87
- wiki-manifest.json # signature (git sha + per-file content hash), generated_at
88
- code-index.json # the chunk index (file, start_line, end_line, tokens)
89
- ```
90
-
91
- NOTE: `.loki/wiki/` (this deliverable, per-project, generated, gitignored) is a
92
- DIFFERENT namespace from the repo-root `wiki/` (the GitHub wiki in the release
93
- workflow). R5 never touches the latter.
94
-
95
- ## Incremental regeneration (R1 signature idea)
96
-
97
- `wiki-manifest.json` stores a `signature` = sha256 over (git HEAD sha + sorted list
98
- of `path:content-hash` for every scanned source file). `loki wiki generate` computes
99
- the current signature; if it equals the stored one, it SKIPS regeneration and prints
100
- "up to date" (unless `--force`). This is the same cheap-incremental idea as the docs
101
- manifest and the R1 codebase signature.
102
-
103
- ## Command surface
104
-
105
- ```
106
- loki wiki generate [path] [--force] # build/refresh .loki/wiki/ (incremental)
107
- loki wiki show [section] # print rendered wiki (or one section)
108
- loki wiki ask "<question>" # grounded, cited answer (file:line)
109
- ```
110
-
111
- ## Build surface (mirrors the proof precedent)
112
-
113
- - `autonomy/lib/wiki_index.py` -- scan + chunk + token-overlap retrieve + signature
114
- (importable module; underscore name).
115
- - `autonomy/lib/wiki-generator.py` -- generate wiki.json + rendered md (LLM or
116
- template), citations code-derived; subprocess-invoked (hyphen in name, like
117
- proof-generator.py).
118
- - `autonomy/lib/wiki-ask.py` -- retrieve K chunks, prompt (stub-aware), map + validate
119
- citations, print grounded answer. Subprocess-invoked.
120
- - bash `cmd_wiki` in `autonomy/loki` (generate|show|ask) -- thin dispatcher to Python.
121
- - Bun `loki-ts/src/commands/wiki.ts` -- native `show` (reads `.loki/wiki/`); `generate`
122
- and `ask` delegate to the bash/Python core (heavy work, provider). Added to the
123
- `bin/loki` allowlist and `cli.ts` switch.
124
- - Dashboard: `GET /api/wiki` (list sections + manifest), `GET /api/wiki/{section}`,
125
- `POST /api/wiki/ask` -- all traversal-safe; web component `loki-wiki-browser.js`.
126
-
127
- ## Tests
128
-
129
- - `tests/test_wiki_index.py` -- chunking is line-accurate; retrieval is deterministic;
130
- signature stable + changes on edit; repo-relative paths only.
131
- - `tests/test_wiki_generator.py` -- generate on a fixture repo; citations point to REAL
132
- files; incremental skip when unchanged; LLM stubbed; no absolute paths (no PII).
133
- - `tests/test_wiki_ask.py` -- `ask` returns grounded answer; every citation resolves on
134
- disk; a stub that emits a bogus `[99]` index is dropped (anti-fabrication).
135
- - `tests/cli/test-wiki-command.sh` -- bash route generate/show/ask on a fixture, stubbed.
136
- - `loki-ts/tests/commands/wiki.test.ts` -- Bun `show` parity with the rendered md.
137
- - `tests/dashboard/test_wiki_routes.py` -- API list/get/ask + traversal rejection.
@@ -1,107 +0,0 @@
1
- # R6: 1-Click Rollback + Checkpoint UX (Design Note)
2
-
3
- Status: implemented in this worktree (not committed to main). For integrator cherry-pick.
4
- Goal: make Loki's existing checkpoint/rollback infra EXCELLENT and OBVIOUS so users
5
- run autonomous work boldly, knowing a mistake is one action from undone.
6
-
7
- ## 1. Verified existing code (read, not assumed)
8
-
9
- ### Checkpoint writers (THREE divergent formats, one shared index.jsonl)
10
-
11
- | Writer | ID format | Files captured | Source |
12
- |---|---|---|---|
13
- | `create_checkpoint()` (automatic, per iteration) | `cp-{iter}-{epoch}` | `state/orchestrator.json`, `autonomy-state.json`, `queue/{pending,completed,in-progress,current-task}.json` | `autonomy/run.sh:7373` |
14
- | `cmd_checkpoint create` (manual CLI) | `cp-{ts}` | `session.json`, `dashboard-state.json`, `queue/`, `memory/`, `metrics/`, `council/` (recursive copy) | `autonomy/loki:16122` |
15
- | `POST /api/checkpoints` (dashboard) | `chk-{ts}` | `dashboard-state.json`, `session.json`, `queue/` | `dashboard/server.py:5085` |
16
-
17
- All three append to `.loki/state/checkpoints/index.jsonl` (field names differ; the
18
- dashboard `GET /api/checkpoints` normalizes them).
19
-
20
- ### Restore (rollback) paths
21
-
22
- | Path | Restores | Source |
23
- |---|---|---|
24
- | `rollback_to_checkpoint()` (internal, run.sh) | state + queue json (NOT autonomy-state) | `autonomy/run.sh:7473` |
25
- | `loki checkpoint rollback <id>` (bash CLI) | glob-restores whatever is in the cp dir | `autonomy/loki:16263` |
26
- | `loki rollback to|latest <id>` (Bun) | the 5 RESTORE_FILES | `loki-ts/src/commands/rollback.ts` + `loki-ts/src/runner/checkpoint.ts:632` |
27
-
28
- ### Bun runner checkpoint API (`loki-ts/src/runner/checkpoint.ts`, 700 lines)
29
- - `createCheckpoint`, `listCheckpoints`, `readCheckpoint`, `rollbackToCheckpoint` (planner),
30
- `executeRollback` (copier). Byte-for-byte parity with bash `create_checkpoint`.
31
- - `metadata.json` keys are pinned by `loki-ts/tests/runner/checkpoint.test.ts:62-91`
32
- (`Object.keys(m).sort()`) -- they MUST NOT change.
33
-
34
- ### Dashboard
35
- - `GET /api/checkpoints`, `GET /api/checkpoints/{id}`, `POST /api/checkpoints` exist.
36
- - The UI component `legacy-ui/components/loki-checkpoint-viewer.js` (601 lines) ALREADY
37
- renders list + create + rollback-with-two-step-confirm and POSTs to
38
- `POST /api/checkpoints/{id}/rollback` -- but that endpoint **did not exist**. The
39
- dashboard rollback button was DEAD.
40
-
41
- ## 2. Three decisions (verified facts, not assumptions)
42
-
43
- ### Decision A: what "truly undo an iteration" restores
44
- Verified fact: Loki does NOT commit per iteration (`grep "git commit" autonomy/run.sh`
45
- finds only merge-conflict `git add`, no per-iteration commit). Therefore the captured
46
- `git_sha` is HEAD (the last commit), and `git reset --hard <git_sha>` would discard the
47
- iteration's work PLUS anything since the last commit -- it cannot reconstruct a specific
48
- iteration's working tree. The pre-existing printed hint `git reset --hard <git_sha>`
49
- (run.sh:7541, loki:16314) was therefore actively MISLEADING.
50
-
51
- Resolution: capture a real working-tree snapshot at checkpoint time via `git stash create`
52
- (captures tracked changes without disturbing the tree), then ANCHOR it with
53
- `git update-ref refs/loki/cp/<id> <sha>` so `git gc` cannot prune the dangling commit.
54
- The snapshot sha is written to a SIDECAR file `worktree-snapshot.txt` in the checkpoint
55
- dir (NOT metadata.json, to preserve byte parity). Restore of code is opt-in
56
- (`loki rollback to <id> --code`) because it overwrites tracked files; by default the
57
- durable, correct recovery command is printed: `git stash apply refs/loki/cp/<id>`.
58
-
59
- State + `.loki/CONTINUITY.md` (the iteration/conversation handoff context) are
60
- auto-restored -- this is the always-on "undo the iteration's state + context".
61
-
62
- Honest gap: `git stash create` captures tracked changes only; it does NOT capture
63
- untracked or ignored files. Files the iteration newly ADDED and never committed are not in
64
- the snapshot, and an apply will not delete them. Documented, not hidden.
65
-
66
- ### Decision B: re-undoability invariant
67
- Every restore path FORCES a pre-rollback snapshot of current state before overwriting, so
68
- a rollback is itself trivially undoable. The Bun `executePlan`, the dashboard endpoint, and
69
- bash `cmd_rollback` all create a forced checkpoint first (bash `create_checkpoint`
70
- early-returns on a clean tree, so the new code path forces it). The human dashboard path
71
- ALSO keeps the existing two-step confirm. Autonomous paths never block on a prompt.
72
-
73
- ### Decision C: do not add a 4th format, do not unify the 3
74
- Unifying would break the byte-for-byte parity test; a 4th compounds the problem. The new
75
- dashboard restore endpoint GLOB-restores whatever the checkpoint dir contains (mirrors bash
76
- `cmd_checkpoint rollback`), so it works for all three writers. New fields go in sidecars.
77
-
78
- ## 3. Changes (parity-organized)
79
-
80
- - **bash `autonomy/loki`**: add top-level `rollback)` dispatch + `cmd_rollback`
81
- (`list|show|to|latest`, `--code` flag). `to|latest` delegate to the existing
82
- `cmd_checkpoint rollback` restore body after forcing a pre-rollback snapshot, then
83
- optionally apply the anchored code snapshot. Prominent "you can undo this" output.
84
- - **bash `autonomy/run.sh`**: `create_checkpoint` also copies `CONTINUITY.md`, creates +
85
- anchors the worktree snapshot (sidecar), echoes the checkpoint id; `rollback_to_checkpoint`
86
- also restores `CONTINUITY.md` and forces the pre-rollback snapshot. The per-iteration call
87
- site emits a prominent "Checkpoint <id> created -- undo with `loki rollback to <id>`".
88
- The misleading `git reset --hard` hint replaced with `git stash apply refs/loki/cp/<id>`.
89
- - **Bun `loki-ts/src/runner/checkpoint.ts`**: copy `CONTINUITY.md` into the checkpoint
90
- (additive, parity-safe), add `CONTINUITY.md` to RESTORE_FILES, expose
91
- `executeRollbackWithSnapshot` that forces a pre-rollback snapshot before restoring.
92
- metadata.json keys unchanged.
93
- - **Bun `loki-ts/src/commands/rollback.ts`**: `executePlan` forces a pre-rollback snapshot
94
- before restoring; HELP text made honest about state+context restore and the printed code
95
- command.
96
- - **dashboard `dashboard/server.py`**: add `POST /api/checkpoints/{id}/rollback`
97
- (`require_scope("control")`, `_sanitize_checkpoint_id`, forced pre-snapshot, glob-restore).
98
- Un-deads the existing UI button.
99
-
100
- ## 4. Tests (extend existing suites, no parallels)
101
- - `loki-ts/tests/runner/checkpoint.test.ts`: CONTINUITY round-trip restore + forced
102
- pre-rollback snapshot.
103
- - `loki-ts/tests/commands/rollback.test.ts`: `to` forces a pre-rollback snapshot (re-undo).
104
- - `tests/test-checkpoint-cli.sh`: top-level `loki rollback list|to|latest`, restore actually
105
- reverts, pre-rollback snapshot exists.
106
- - `dashboard/tests/test_rollback_endpoint.py`: POST rollback reverts, scope, 404.
107
- No paid model calls anywhere.
@@ -1,137 +0,0 @@
1
- # R7: Zero-config killer first run (time-to-first-value)
2
-
3
- Design note for the R7 release in the competitive-stickiness arc. Worktree
4
- deliverable for the integrator to cherry-pick. NO version bumps here.
5
-
6
- ## Goal
7
-
8
- Convert trials to habits. The #1 acquisition-to-retention gate is the first
9
- run. Today a blank first run is mediocre and Loki's deep RARV-C / council can
10
- feel heavy on run 1. R7 = a frictionless first run: a user types
11
- `loki start "<one line>"` (or `loki start` in an existing repo) and sees a
12
- VISIBLE valuable artifact in minutes, with depth opt-in later.
13
-
14
- Honest "fast": we do NOT fake progress. We actually shorten the path by running
15
- a lightweight execution profile first (capped iterations, completion council
16
- off, simple complexity tier, heavy phases off) so the first visible artifact
17
- plus a proof-of-run land quickly. "Go deeper" = re-run plain `loki start` for
18
- the full RARV-C depth.
19
-
20
- ## Verified current behavior (real code, traced 2026-06-03)
21
-
22
- - `cmd_start()` (`autonomy/loki:746`) is the unified entry. It parses args,
23
- calls `detect_arg_type()` (`autonomy/loki:667`), then dispatches:
24
- issue -> `cmd_run`; prd -> sets `prd_file`; empty -> no-PRD path; unknown
25
- -> treated as a PRD path for back-compat.
26
- - `cmd_start` ends in `_loki_new_session_exec "$RUN_SH" ...` (`autonomy/loki:1678`).
27
- Every branch of `_loki_new_session_exec` (`autonomy/loki:167-186`) uses
28
- `exec`, so NOTHING after that line in `cmd_start` runs. Any end-of-run
29
- message must live in `run.sh`, not after the exec in `cmd_start`.
30
- - `cmd_quick()` (`autonomy/loki:8849`) already synthesizes a PRD from a
31
- one-line task and sets the lightweight profile
32
- (`LOKI_MAX_ITERATIONS=3`, `LOKI_COMPLEXITY=simple`,
33
- `LOKI_COUNCIL_ENABLED=false`, heavy phases off), then execs `run.sh`.
34
- - No-PRD + generated-PRD-reuse (v7.8.1): in `run.sh` around line 11102,
35
- `decide_generated_prd_action()` (`run.sh:4032`) returns reuse|update|generate
36
- for the no-arg in-repo path; signature persisted by
37
- `persist_prd_signature_if_present()` (`run.sh:4064`).
38
- - Proof-of-run (R1): `generate_proof_of_run()` (`run.sh:4101`) wraps
39
- `autonomy/lib/proof-generator.py`. It runs at session end (`run.sh:13312`)
40
- on both success and failure, gated only by `LOKI_PROOF` (NOT by council
41
- state), writing `.loki/proofs/<run_id>/{proof.json,index.html}`. Viewable
42
- via `loki proof list` / `loki proof open <id>` (Bun-routed, `bin/loki:119`).
43
-
44
- ### The exact gap R7 closes (traced, not assumed)
45
-
46
- `loki start "build a todo app"` TODAY:
47
- 1. `detect_arg_type("build a todo app")` returns `unknown` (has spaces, no
48
- extension, not a file, not an issue ref).
49
- 2. The PRD-not-found guard at `autonomy/loki:1243` and `:1268` only fires for
50
- `*.md|*.json|*.txt|*.yaml|*.yml`, so a brief with spaces slips past.
51
- 3. `prd_file="build a todo app"` is passed to `run.sh`, which fails:
52
- `[ERROR] PRD file not found: build a todo app`.
53
-
54
- So the one-line-brief path is broken today. R7 makes it work. This is ADDITIVE:
55
- no existing valid input (`.md` PRD, issue ref, single-token name) changes
56
- behavior.
57
-
58
- ## Design (additive, no behavior change to existing inputs)
59
-
60
- 1. `detect_arg_type`: add a `brief` return ONLY for args that contain
61
- whitespace and match none of the file/issue/path patterns. A single-token
62
- `unknown` arg still falls back to PRD path (back-compat preserved).
63
- 2. `--brief "<text>"` explicit flag: deterministic escape hatch for the rare
64
- single-word brief (e.g. `loki start --brief "snake"`).
65
- 3. Shared helper `synthesize_brief_prd <file> <text>`: factored so `cmd_quick`
66
- and the new brief path write the same forward-looking PRD. The brief PRD is
67
- written to `.loki/brief-prd-$$.md` -- DISTINCT from `.loki/generated-prd.md`
68
- so it never pollutes the v7.8.1 generated-PRD-reuse signature logic
69
- (generated-prd is for codebase analysis of an existing repo; brief is a
70
- forward spec).
71
- 4. `cmd_start` brief sub-path: set the lightweight TTFV profile (same env as
72
- quick), synthesize the brief PRD, set `LOKI_TTFV=brief`, then continue
73
- through the normal exec path. Upfront framing ("fast first pass") is printed
74
- BEFORE the exec.
75
- 5. `cmd_start` no-arg in-repo path: UNCHANGED execution (existing no-PRD +
76
- reuse, full RARV-C depth), but set `LOKI_TTFV=repo` so the end-of-run
77
- what-next framing appears.
78
- 6. `run.sh` end-of-session: after proof generation, when `LOKI_TTFV` is set and
79
- stdout is a TTY, call `print_ttfv_next_steps <mode> <result>`. The wording
80
- BRANCHES on mode so the message always matches what actually ran:
81
- - `brief`: lightweight first pass, council off; proof has diffs/cost/time
82
- (NO council verdicts, because the council was disabled).
83
- - `repo`: full-depth codebase analysis, council on; proof has
84
- diffs/cost/time/council verdicts.
85
- Both point at `loki proof list` / `loki proof open` (the visible artifact)
86
- and the depth opt-in. Gated so it is silent in CI / pipes and never fires
87
- for normal PRD runs. Factored into `print_ttfv_next_steps` so it is
88
- unit-testable.
89
-
90
- Honesty note: the `brief` message intentionally does NOT advertise "council
91
- verdicts" because brief mode runs with the council off (`_collect_council` in
92
- proof-generator.py finds no council state, so that proof section is blank on the
93
- brief path). The `repo` message claims verdicts because the full-depth path runs
94
- the council. This keeps the end-of-run summary truthful per the no-fabrication
95
- rule.
96
-
97
- ### Why fast is honest
98
-
99
- The brief path uses the same lightweight profile `cmd_quick` already ships:
100
- 3 iterations max, council off, simple tier, heavy phases (perf, a11y,
101
- regression, UAT, web-research) off. That genuinely shortens the path to first
102
- visible value. We do not print fake progress or claim work that did not happen;
103
- the proof-of-run is generated from real `.loki/` state. Depth is opt-in: the
104
- end-of-run message tells the user to re-run plain `loki start` (or
105
- `loki start <prd.md>`) for the full council-gated build.
106
-
107
- ## Parity (bash + Bun)
108
-
109
- `loki start` and `loki quick` are NOT in the Bun shim allowlist
110
- (`bin/loki:119`), so dispatch is bash-only by design; this change is bash-only
111
- for the CLI surface. The runtime pieces it reuses are already shared across
112
- routes: `proof-generator.py` (one implementation, both routes) and the no-PRD /
113
- generated-PRD-reuse path in `run.sh` (both routes source run.sh). No Bun CLI
114
- change is required for parity.
115
-
116
- ## Files
117
-
118
- - `autonomy/loki`: `detect_arg_type` brief return; `--brief` flag;
119
- `synthesize_brief_prd` helper; `cmd_quick` refactor to use it; `cmd_start`
120
- brief sub-path + `LOKI_TTFV` wiring; help text.
121
- - `autonomy/run.sh`: end-of-session TTFV what-next block.
122
- - `tests/cli/test_zero_config_first_run.sh`: new test suite.
123
-
124
- ## Tests (no paid runs; mock via early exit)
125
-
126
- Following `tests/cli/test_start_run_unified.sh`: extract `detect_arg_type` and
127
- `synthesize_brief_prd` in a subshell and assert on them; force `cmd_start` to
128
- exit before `run.sh` boots via `--provider nonexistent-provider`.
129
-
130
- - `detect_arg_type("build a todo app")` = `brief`; single tokens still `unknown`;
131
- `.md` still `prd`; issue refs still `issue`; empty still `empty`.
132
- - `synthesize_brief_prd` writes a PRD containing the brief text and TTFV markers.
133
- - `loki start "<brief>"` enters the brief path (lightweight env, not
134
- "PRD file not found").
135
- - `loki start --brief "<one word>"` works.
136
- - existing-repo no-arg path still routes to no-PRD (unchanged).
137
- - `loki start <prd.md>` (real PRD) still routes to PRD mode (no regression).
@@ -1,129 +0,0 @@
1
- # R8: Shareable Team Assets - Design Note
2
-
3
- Status: implemented in this worktree (isolated; not committed to main).
4
- Goal (per arc): turn individual setup into org lock-in / network effects by
5
- making a team's invested assets EXPORTABLE and IMPORTABLE across a team or org,
6
- so setup compounds into shared value (the skills-marketplace stickiness dynamic).
7
-
8
- ## 1. Inventory of existing machinery (verified against real source)
9
-
10
- Before writing anything, the existing export/import/share + memory machinery
11
- was read in full. Findings:
12
-
13
- | Mechanism | Location | What it actually does | Reused? |
14
- |---|---|---|---|
15
- | `cmd_export` | `autonomy/loki:6254` | Per-run SESSION SNAPSHOT: json / markdown / csv / timeline of one `.loki/` run. Not portable across teams, not redacted. | Reused its `_export_check_overwrite` guard. |
16
- | `cmd_import` | `autonomy/loki:4722` | Imports GitHub ISSUES into `.loki/queue/`. Unrelated to assets. | Not applicable (different domain). |
17
- | `cmd_share` | `autonomy/loki:25147` | Uploads a session REPORT as a GitHub gist. | Not applicable (report, not assets). |
18
- | `cmd_memory` | `autonomy/loki:14475` | Lists/show cross-project learnings in `~/.loki/learnings/*.jsonl`. No tarball export. | Same source dir reused as an asset category. |
19
- | `proof_redact.py` | `autonomy/lib/proof_redact.py` | Single redaction chokepoint (R1). `redact_tree(obj)`, `redact_value(s)`, `set_context()`, `RULES_VERSION`. | REUSED as-is. No second redactor written. |
20
- | agent registry | `agents/types.json` | Shipped agent types. `cmd_agent` (`autonomy/loki:19509`) reads it from the install dir. | Bundled as the `agents` category. |
21
- | PRD templates | `templates/*.md` | 21 templates; read from `$SKILL_DIR/templates` at runtime (`autonomy/loki:9781`, `8840`). | Bundled as `templates`. |
22
- | council config | `<project>/.loki/council/*.json` | `config.json` / `state.json` (`autonomy/loki:16688`, `autonomy/run.sh:3643`). | Bundled as `council`. |
23
- | project memory | `<project>/.loki/memory/{episodic,semantic,skills,...}` (`autonomy/run.sh:3183`) | Per-project episodic/semantic/procedural memory. | Bundled as `memory`. |
24
- | R5 wiki | `<project>/.loki/wiki/**` (`autonomy/loki:22881`) | Cited per-project wiki. | Bundled as `wiki` (opt-in). |
25
-
26
- Key negative finding: there is NO separate per-user "custom agent" store.
27
- "Custom agents" == the `agents/types.json` registry. We do not invent one
28
- (that would be the parallel-machinery trap the task forbids).
29
-
30
- ## 2. Why `loki assets` is NOT a duplicate of `cmd_export`
31
-
32
- - `cmd_export` = per-run session snapshot, one format at a time, not redacted,
33
- not portable. Scope: "what happened in this run".
34
- - `loki assets` = portable, redacted, multi-category TEAM-ASSET tarball.
35
- Scope: "the reusable setup a team invested in", designed to travel to
36
- another clone/org. Different scope, different artifact, different lifetime.
37
-
38
- Concrete reuse (not a fork): `_export_check_overwrite` (overwrite guard) and
39
- the `proof_redact` chokepoint. No new redactor, no parallel exporter.
40
-
41
- ## 3. Asset map and the deliberate export/import asymmetry
42
-
43
- | Category | Export source | Bundle path | Import restore root |
44
- |---|---|---|---|
45
- | learnings | `~/.loki/learnings/*.jsonl` | `learnings/` | `$HOME/.loki/learnings` |
46
- | memory | `<project>/.loki/memory/**` | `memory/` | `<cwd>/.loki/memory` |
47
- | agents | `$SKILL_DIR/agents/types.json` | `agents/` | `<cwd>/agents` |
48
- | templates | `$SKILL_DIR/templates/*.md` | `templates/` | `<cwd>/templates` |
49
- | council | `<project>/.loki/council/*.json` | `council/` | `<cwd>/.loki/council` |
50
- | wiki (opt-in) | `<project>/.loki/wiki/**` | `wiki/` | `<cwd>/.loki/wiki` |
51
-
52
- The export and import repo_root values are DELIBERATELY DIFFERENT (enforced in
53
- `cmd_assets`, not in the Python helper):
54
-
55
- - EXPORT reads agents/templates from the loki install (`$SKILL_DIR`), because
56
- that is where a team's edited registry/templates live and are read at
57
- runtime.
58
- - IMPORT writes agents/templates under the caller's cwd (the target clone
59
- root) BY DEFAULT, NEVER silently back into the install. Writing into
60
- `$SKILL_DIR` would clobber the live install with redacted copies (this was
61
- caught and fixed during development: a bash smoke test that used `$SKILL_DIR`
62
- on import overwrote the worktree's real `agents/types.json` and templates;
63
- default restore root changed to cwd, damage reverted).
64
- - `loki assets import --into-install` opts back into `$SKILL_DIR` for
65
- agents/templates only, so a GLOBAL-INSTALL user (the primary install path per
66
- CLAUDE.md) gets them read at runtime. This is the symmetric round-trip
67
- (export reads $SKILL_DIR, import --into-install writes $SKILL_DIR). It is
68
- opt-in because the default cwd target is non-destructive.
69
-
70
- memory/learnings/council/wiki restore to `$HOME/.loki` or `<cwd>/.loki` and
71
- take effect immediately regardless of the flag.
72
-
73
- ## 4. Redaction (single chokepoint, all file types)
74
-
75
- `autonomy/lib/assets_bundle.py` calls `proof_redact.set_context(home, repo)`
76
- then dispatches by extension before any byte is written into the tarball:
77
- - `.json` -> parse -> `redact_tree` -> reserialize
78
- - `.jsonl` -> per-line parse -> `redact_tree` -> reserialize
79
- - `.md` / `.txt` / other -> `redact_value` on the whole string
80
-
81
- Originals on disk are never modified (verified by test). Secrets seeded into
82
- each of md, jsonl, and json are all stripped (verified by test + live leak
83
- scan).
84
-
85
- Scope of redaction (honest): proof_redact strips SECRETS / KEYS / TOKENS /
86
- connection-string credentials / absolute home+repo PATHS, per its frozen
87
- `RULES_VERSION`. It does NOT do general PII (emails, author names, free text).
88
- The accurate claim for this feature is "no secrets/keys/home-paths leak," not
89
- "no PII." The authoritative evidence is the leak-scan test
90
- (`test_imported_assets_contain_no_secrets`), not the manifest count.
91
-
92
- ## 5. Honest gaps / limitations
93
-
94
- - agents/templates restore relative to cwd by default; loki reads them from its
95
- install at runtime, so a global-install user should pass `--into-install` (or
96
- copy the restored `agents/` + `templates/` into their install). Documented in
97
- `--help` and the module docstring. memory/learnings/council/wiki are
98
- effective immediately.
99
- - Round-trip is SEMANTICALLY FAITHFUL but REFORMATTED, not byte-identical:
100
- JSON files come back `indent=2`, and JSONL merge canonicalizes lines
101
- (sort_keys). Content/semantics are preserved; whitespace/key-order are not.
102
- - The export-reads-install / import-writes-cwd asymmetry lives in the bash
103
- `cmd_assets`, not the Python helper. The Python tests pass roots explicitly
104
- so they cover the helper mechanics; the bash asymmetry is covered by
105
- `tests/test_assets_cli.sh` (export with SKILL_DIR=A, import from cwd=B,
106
- assert agents land in B).
107
- - The manifest `redactions` count covers structured (json/jsonl) redactions
108
- only; `redact_value` (md/text) and path collapses are not counted (the
109
- redaction still HAPPENS). The authoritative no-PII evidence is the
110
- `test_imported_assets_contain_no_secrets` leak-scan test, not the count.
111
- - `agents/types.json` and `templates/*.md` are repo-shipped defaults; a bundle
112
- from a fresh checkout re-ships the stock set. Value = captured team DELTAS
113
- travelling with the baseline.
114
- - The placement tests assert files land at the mapped path; they do not assert
115
- the importing loki reads them at runtime (that is the global-install gap
116
- above).
117
-
118
- ## 6. bash + Bun parity
119
-
120
- `assets` is NOT in the `bin/loki` Bun allowlist (`bin/loki:119`), so it falls
121
- through the shim's default branch to the bash CLI (`bin/loki:145`), exactly like
122
- `bench`. Parity is free via fall-through; no Bun command is needed or added.
123
-
124
- ## 7. Files
125
-
126
- - `autonomy/lib/assets_bundle.py` (new) - bundler/redactor/restorer helper.
127
- - `autonomy/loki` (modified) - `cmd_assets` + dispatch case.
128
- - `tests/test_assets_bundle.py` (new) - 13 tests.
129
- - `docs/R8-SHAREABLE-TEAM-ASSETS-PLAN.md` (this note).