@andorra-labs/code 0.1.9 → 0.1.11

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 (212) hide show
  1. package/README.md +28 -208
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/agent-execution.js +56 -0
  4. package/dist/src/app-server/protocol.d.ts +109 -1
  5. package/dist/src/app-server/protocol.js +8 -1
  6. package/dist/src/app-server.d.ts +59 -1
  7. package/dist/src/app-server.js +418 -63
  8. package/dist/src/auth/index.d.ts +1 -1
  9. package/dist/src/auth/index.js +1 -1
  10. package/dist/src/auth/store.d.ts +17 -1
  11. package/dist/src/auth/store.js +25 -2
  12. package/dist/src/automation-service.js +1 -1
  13. package/dist/src/browser-session.d.ts +8 -0
  14. package/dist/src/browser-session.js +27 -1
  15. package/dist/src/browser-ui/app.js +255 -33
  16. package/dist/src/browser-ui/index.html +9 -9
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/cli.js +10 -5
  20. package/dist/src/coding-tools.d.ts +24 -0
  21. package/dist/src/coding-tools.js +71 -8
  22. package/dist/src/command-screens.js +1 -1
  23. package/dist/src/commands.d.ts +1 -1
  24. package/dist/src/commands.js +2 -2
  25. package/dist/src/completion-gates.d.ts +42 -7
  26. package/dist/src/completion-gates.js +55 -9
  27. package/dist/src/completion.d.ts +9 -1
  28. package/dist/src/completion.js +20 -2
  29. package/dist/src/dashboard-view.js +2 -2
  30. package/dist/src/deadline.js +4 -0
  31. package/dist/src/decision/checks.js +1 -1
  32. package/dist/src/file-diff.d.ts +105 -0
  33. package/dist/src/file-diff.js +244 -0
  34. package/dist/src/graph-manager-chat.js +4 -4
  35. package/dist/src/graph-runner.js +39 -2
  36. package/dist/src/graph-sync.d.ts +8 -0
  37. package/dist/src/graph-sync.js +54 -3
  38. package/dist/src/graph-tool.js +1 -1
  39. package/dist/src/graph-ui/app.js +303 -129
  40. package/dist/src/graph-ui/controls.css +43 -22
  41. package/dist/src/graph-ui/controls.js +31 -1
  42. package/dist/src/graph-ui/embed.js +56 -7
  43. package/dist/src/graph-ui/icons.js +5 -0
  44. package/dist/src/graph-ui/index.html +3 -3
  45. package/dist/src/graph-ui/manager-state.js +2 -2
  46. package/dist/src/graph-ui/manager.css +19 -18
  47. package/dist/src/graph-ui/manager.js +5 -5
  48. package/dist/src/graph-ui/skill-picker.js +5 -5
  49. package/dist/src/graph-ui/studio-canvas.js +16 -16
  50. package/dist/src/graph-ui/studio.css +18 -15
  51. package/dist/src/graph-ui/studio.js +99 -42
  52. package/dist/src/graph-ui/style.css +125 -80
  53. package/dist/src/graph-ui/theme.js +2 -2
  54. package/dist/src/graph-ui/tokens.css +33 -29
  55. package/dist/src/graphs.d.ts +10 -3
  56. package/dist/src/graphs.js +15 -4
  57. package/dist/src/mcp.d.ts +75 -0
  58. package/dist/src/mcp.js +240 -8
  59. package/dist/src/membership-errors.d.ts +7 -1
  60. package/dist/src/membership-errors.js +9 -3
  61. package/dist/src/provider-keys.d.ts +5 -1
  62. package/dist/src/provider-keys.js +7 -3
  63. package/dist/src/provider-settings.d.ts +4 -1
  64. package/dist/src/provider-settings.js +46 -5
  65. package/dist/src/pull-requests.d.ts +42 -6
  66. package/dist/src/pull-requests.js +11 -3
  67. package/dist/src/qa/guidance.js +6 -19
  68. package/dist/src/qa/index.d.ts +0 -2
  69. package/dist/src/qa/index.js +0 -2
  70. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  71. package/dist/src/qa/profile/QaProfile.js +6 -2
  72. package/dist/src/qa/tools.d.ts +19 -1
  73. package/dist/src/qa/tools.js +20 -145
  74. package/dist/src/react-runtime.js +134 -16
  75. package/dist/src/read-document-doc.d.ts +20 -0
  76. package/dist/src/read-document-doc.js +524 -0
  77. package/dist/src/read-document-docx.d.ts +21 -0
  78. package/dist/src/read-document-docx.js +584 -0
  79. package/dist/src/read-document-text.d.ts +29 -0
  80. package/dist/src/read-document-text.js +67 -0
  81. package/dist/src/read-document-tool.d.ts +48 -0
  82. package/dist/src/read-document-tool.js +162 -0
  83. package/dist/src/read-document.d.ts +78 -0
  84. package/dist/src/read-document.js +353 -0
  85. package/dist/src/read-image.d.ts +29 -2
  86. package/dist/src/read-image.js +42 -17
  87. package/dist/src/remote/engine-pool.js +18 -6
  88. package/dist/src/runtime.d.ts +19 -0
  89. package/dist/src/runtime.js +10 -1
  90. package/dist/src/screen-selection.d.ts +38 -0
  91. package/dist/src/screen-selection.js +103 -0
  92. package/dist/src/session-changes.d.ts +122 -0
  93. package/dist/src/session-changes.js +804 -0
  94. package/dist/src/side-panel.d.ts +6 -1
  95. package/dist/src/side-panel.js +12 -10
  96. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  97. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  98. package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
  99. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  100. package/dist/src/skills/bundled/provenance.json +4 -4
  101. package/dist/src/skills/runtime-skills.js +3 -3
  102. package/dist/src/stall-recovery.d.ts +15 -0
  103. package/dist/src/stall-recovery.js +17 -0
  104. package/dist/src/telemetry/schema.d.ts +1 -1
  105. package/dist/src/telemetry/schema.js +1 -2
  106. package/dist/src/terminal-ui.d.ts +64 -20
  107. package/dist/src/terminal-ui.js +312 -82
  108. package/dist/src/time-limit.d.ts +53 -0
  109. package/dist/src/time-limit.js +79 -0
  110. package/dist/src/tool-diff-stats.d.ts +9 -0
  111. package/dist/src/tool-diff-stats.js +20 -0
  112. package/dist/src/tool-names.d.ts +1 -1
  113. package/dist/src/tool-result-filter.js +1 -1
  114. package/dist/src/tools.js +118 -9
  115. package/dist/src/transcript.d.ts +11 -0
  116. package/dist/src/transcript.js +15 -3
  117. package/dist/src/types.d.ts +12 -0
  118. package/dist/src/usage-analytics.d.ts +3 -1
  119. package/dist/src/usage-analytics.js +16 -2
  120. package/package.json +6 -26
  121. package/dist/src/qa/api/http-runner.d.ts +0 -3
  122. package/dist/src/qa/api/http-runner.js +0 -47
  123. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  124. package/dist/src/qa/git/ChangeDetector.js +0 -177
  125. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  126. package/dist/src/qa/git/DiffReviewer.js +0 -115
  127. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  128. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  129. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  130. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  131. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  132. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  133. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  134. package/dist/src/qa/runners/CommandRunner.js +0 -96
  135. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  136. package/dist/src/qa/runners/TestRunner.js +0 -66
  137. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  138. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  139. package/dist/src/qa/runtime-detect.d.ts +0 -10
  140. package/dist/src/qa/runtime-detect.js +0 -72
  141. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  142. package/dist/src/qa/security/DependencyScanner.js +0 -167
  143. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  144. package/dist/src/qa/security/SecretScanner.js +0 -55
  145. package/docs/README.md +0 -36
  146. package/docs/agents/README.md +0 -62
  147. package/docs/agents/install-for-agents.md +0 -56
  148. package/docs/agents/mcp-server.md +0 -212
  149. package/docs/agents/subagent-mode.md +0 -149
  150. package/docs/concepts/README.md +0 -47
  151. package/docs/concepts/jev-actionable-routing.md +0 -113
  152. package/docs/concepts/jev-decision-thresholds.md +0 -412
  153. package/docs/concepts/jev-efficiency.md +0 -217
  154. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  155. package/docs/concepts/limits.md +0 -52
  156. package/docs/concepts/memory.md +0 -10
  157. package/docs/concepts/security.md +0 -50
  158. package/docs/concepts/workspace-instructions.md +0 -29
  159. package/docs/getting-started/README.md +0 -82
  160. package/docs/getting-started/accounts.md +0 -78
  161. package/docs/getting-started/configure-providers.md +0 -132
  162. package/docs/guides/README.md +0 -13
  163. package/docs/guides/browser.md +0 -39
  164. package/docs/guides/desktop-app.md +0 -414
  165. package/docs/guides/extensions.md +0 -102
  166. package/docs/guides/graph-builder.md +0 -116
  167. package/docs/guides/headless.md +0 -46
  168. package/docs/guides/tui.md +0 -75
  169. package/docs/guides/update.md +0 -70
  170. package/docs/guides/web-search.md +0 -51
  171. package/docs/guides/windows-code-signing.md +0 -319
  172. package/docs/llms.txt +0 -45
  173. package/docs/reference/README.md +0 -7
  174. package/docs/reference/cli.md +0 -76
  175. package/docs/reference/config.md +0 -91
  176. package/docs/reference/slash-commands.md +0 -59
  177. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  178. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  179. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  180. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  181. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  182. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  183. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  184. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  185. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  186. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  187. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  188. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  189. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  190. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  191. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  192. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  193. package/scripts/jev-efficiency-eval.mjs +0 -187
  194. package/scripts/jev-efficiency-live.mjs +0 -193
  195. package/scripts/zcode-engine-replay.mjs +0 -223
  196. package/tests/agent-centric-mcp-test-plan.md +0 -208
  197. package/tests/analytics-settings-test-plan.md +0 -165
  198. package/tests/browser-cli-smoke.mjs +0 -276
  199. package/tests/browser-test-plan.md +0 -280
  200. package/tests/chat-side-panel-test-plan.md +0 -309
  201. package/tests/decision-engine-test-plan.md +0 -163
  202. package/tests/default-active-jev-test-plan.md +0 -85
  203. package/tests/harness-extensions-test-plan.md +0 -113
  204. package/tests/jev-all-decisions-test-plan.md +0 -156
  205. package/tests/jev-efficiency/criteria.json +0 -158
  206. package/tests/jev-efficiency/workloads.mjs +0 -242
  207. package/tests/jev-efficiency-test-plan.md +0 -198
  208. package/tests/permissions-sandbox-probe.mjs +0 -74
  209. package/tests/permissions-test-plan.md +0 -191
  210. package/tests/product-telemetry-test-plan.md +0 -536
  211. package/tests/thinking-stream-preview-test-plan.md +0 -136
  212. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -1,412 +0,0 @@
1
- # Jev decision thresholds: what the 3D-Dodge run shows
2
-
3
- **Status:** analysis of one run, with a second run's numbers, a post-#354 one-pass pair, and the
4
- Little Harvest run of 2026-11-01 added below. Recommendation: keep
5
- every threshold as it is, calibrate the hosted service, close three context gaps in the harness,
6
- and stop awaiting the postflight round when it cannot act. No threshold was changed.
7
-
8
- The 3D-Dodge benchmark (`Benchmarks/3D-Dodge/`, added in [Andorra-Labs/Andorra-Code#344](https://github.com/Andorra-Labs/Andorra-Code/pull/344)) ran the Software Engineer graph on
9
- `glm-5.3-flash` twice, once with hosted Jev and once without. The Jev run asked 172 questions over
10
- 27 rounds, got 142 answers, and applied none of them: the model saw the same 30-tool catalog as the
11
- no-Jev run (plus `prepare_steps`), and every one of its 27 turns went to the coding model. The
12
- rounds cost 19.8 s. This page answers whether the thresholds in
13
- [`DecisionPolicy`](../../src/decision/DecisionPolicy.ts) are too strict for the signal the service
14
- produces, whether the service's calibration is the problem, or both.
15
-
16
- Numbers come from the run's `trajectory/run-events.jsonl` and `meta.json` under
17
- `Benchmarks/3D-Dodge/runs/2026-10-31_andorra-code_jev_glm-5.3-flash_8fb1b581/`.
18
-
19
- ## What gates each action
20
-
21
- | Question | Decisive at | What a decisive answer does |
22
- | --- | --- | --- |
23
- | `tool_family_*` | ≤0.20 | Removes that family's schemas from the catalog (`routeToolFamilies`). A yes does nothing. |
24
- | `needs_external_docs` | ≤0.20 / ≥0.80 | Removes web schemas / adds a "consult primary docs" directive. |
25
- | `needs_delegation` | ≤0.20 / ≥0.80 | "Prefer the current agent" directive / role contract in `spawn_subagent` (with `delegation_role` ≥0.90). |
26
- | `needs_codegraph`, `needs_memory` | 0.80 / 0.20, 0.85 / 0.15 | Skip or request automatic retrieval. Only asked when the retrieval is available. |
27
- | `security_sensitive`, `architecture_affecting` | ≥0.95 / ≤0.05 | Yes forces full-suite verification. Both must be decisively **no** before a completion shortcut is allowed. |
28
- | `verification_tier` (choice) | ≥0.90 | Adds the tier's verification directive. |
29
- | `task_complexity` (score) | confidence ≥0.80 | A score ≥0.8 forces full-suite verification and a milestone directive. |
30
- | Six post-tool booleans | ≥0.95 / ≤0.05 | Yes adds a one-line directive to the next prompt. Each prepared-step kind also needs its own boolean to be a decisive yes (`permittedContinuation`). |
31
- | `next_action` (choice) | confidence and probability ≥0.95 | Runs a prepared step without a model turn. The runtime passes 0.95 here, not the 0.90 default. |
32
-
33
- A prepared step runs only when all of these hold: the model called `prepare_steps` in the
34
- batch whose results are being judged (steps are cleared when the model resumes), `next_action`
35
- picked it at ≥0.95, the step's kind gate is a decisive yes, fewer than three automatic turns have
36
- run in a row, and for `complete` the invocation was read-only with every todo completed.
37
-
38
- ### When the post-tool round holds up the next turn
39
-
40
- `next_action` is only asked when the judged batch prepared candidates. Without candidates the
41
- round can do one thing, add a one-line directive, so the runtime (`src/hardened-runtime.ts`)
42
- starts that round and builds the next model request without waiting for it; the directive, if
43
- the answer crosses its bar, is added to the first request built after the answer arrives, and an
44
- answer that a newer round, a steer or a follow-up has superseded is dropped. A round with
45
- candidates is awaited before the next request, because its answer may replace that request with
46
- the prepared step. The round's telemetry (`decision.requested`, `decision.completed`,
47
- `decision.fallback`) is unchanged either way, and a run waits for its last in-flight round before
48
- `agent.session.completed` so every round in the log is paired. On the 3D-Dodge runs above, where
49
- the model called `prepare_steps` once in 47 turns, this removes the serial wait (about 0.8 s per
50
- turn) from every other turn without changing what reaches the model.
51
-
52
- ## What the service answered
53
-
54
- ### Preflight (one round, 15 questions)
55
-
56
- Two answers were decisive: `needs_delegation` 0.10 (adds the "prefer the current agent" directive)
57
- and `security_sensitive` 0.03. Everything else sat in the uncertain band:
58
- `needs_external_docs` 0.43, `architecture_affecting` 0.09 (needs ≤0.05), `verification_tier`
59
- `targeted` at 0.62, `task_complexity` 0.515 at confidence 0.20, `skill_role` at 0.39.
60
-
61
- The meta file's `decisionsApplied: 0` is accurate for what matters (no schema removed, no turn
62
- skipped) but undercounts: `decision.applied` is only emitted for CodeGraph and memory, so the
63
- delegation directive that did fire is invisible to the benchmark.
64
-
65
- Tool families, against what the agent then used (36 calls):
66
-
67
- | Family | Probability | Calls in the run | A ≤0.30 cut would have |
68
- | --- | --- | --- | --- |
69
- | filesystem-write | 0.88 | `Write` 1 | kept it |
70
- | browser | 0.75 | `qa.browser_session` 13 | kept it |
71
- | artifact | 0.47 | 0 | kept it |
72
- | shell | 0.42 | 6 (`PowerShell` 1 failed, `NativeExec` 2, `AsyncProcess` 3) | kept it |
73
- | filesystem-read | 0.30 | 0 | removed it, harmlessly |
74
- | code-search | 0.30 | 3 (`Glob` on an empty workspace, `Grep` twice for a string in its own file, 1 failed) | removed it; `restore_tools` would have been needed for three marginal calls |
75
- | codegraph | 0.28 | 0 | removed it, harmlessly |
76
- | git | 0.25 | 1 (`git_read`, failed: the workspace is not a repository) | removed it, harmlessly |
77
-
78
- The task was "create a game in a single HTML file" in an empty folder that is not a git
79
- repository. A calibrated classifier should put git, codegraph and filesystem-read well under 0.20
80
- for that task. But the preflight snapshot gives the service no workspace facts (file count,
81
- whether a repository exists), only the task text, the node instruction and the family list, so
82
- 0.25-0.30 is a hedge the harness partly invited.
83
-
84
- ### Post-tool (26 rounds, 21 answered, 5 `decision_service_unavailable`)
85
-
86
- Each row is one round: the tools whose results were judged, the six probabilities, and what the
87
- model did next. `!` marks a failed call.
88
-
89
- | Turn | Judged results | answered | investigate | retry | change | verify | complete | Model's next call |
90
- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
91
- | 1 | PowerShell! | 0.06 | 0.57 | 0.31 | 0.87 | 0.06 | 0.02 | Glob |
92
- | 2 | Glob | 0.45 | 0.49 | 0.35 | 0.83 | 0.08 | 0.03 | update_todos, prepare_steps, Write |
93
- | 3 | update_todos, prepare_steps, Write | 0.52 | 0.41 | 0.32 | 0.64 | 0.47 | 0.23 | qa.inspect_project (`next_action` at 0.72) |
94
- | 6 | NativeExec | 0.21 | 0.52 | 0.45 | 0.77 | 0.12 | 0.05 | Grep |
95
- | 7 | Grep! | 0.06 | 0.70 | 0.39 | 0.90 | 0.07 | 0.02 | NativeExec |
96
- | 8 | NativeExec | 0.25 | 0.54 | 0.46 | 0.76 | 0.15 | 0.08 | Grep, qa.browser |
97
- | 10 | update_todos, AsyncProcess | 0.17 | 0.55 | 0.43 | 0.82 | 0.14 | 0.05 | AsyncProcess, qa.browser |
98
- | 12 | update_todos!, qa.browser_session | 0.19 | 0.60 | 0.45 | 0.86 | 0.17 | 0.10 | update_todos, qa.browser_session |
99
- | 13 | update_todos, qa.browser_session | 0.33 | 0.57 | 0.43 | 0.82 | 0.28 | 0.20 | qa.browser_session |
100
- | 14 | qa.browser_session | 0.20 | 0.60 | 0.46 | 0.84 | 0.20 | 0.12 | qa.browser_session |
101
- | 15 | qa.browser_session | 0.36 | 0.60 | 0.43 | 0.82 | 0.26 | 0.20 | qa.browser_session |
102
- | 16 | qa.browser_session | 0.20 | 0.60 | 0.45 | 0.85 | 0.19 | 0.12 | qa.browser_session |
103
- | 17 | qa.browser_session | 0.20 | 0.62 | 0.43 | 0.85 | 0.18 | 0.10 | qa.browser_session |
104
- | 18 | qa.browser_session! | 0.05 | 0.54 | 0.42 | 0.87 | 0.10 | 0.04 | qa.browser_session |
105
- | 19 | qa.browser_session | 0.11 | 0.61 | 0.48 | 0.84 | 0.16 | 0.09 | qa.browser_session |
106
- | 20 | qa.browser_session | 0.23 | 0.61 | 0.48 | 0.84 | 0.18 | 0.14 | qa.browser_session |
107
- | 21 | qa.browser_session | 0.13 | 0.53 | 0.47 | 0.84 | 0.16 | 0.10 | qa.browser_session |
108
- | 22 | qa.browser_session | 0.12 | 0.54 | 0.47 | 0.83 | 0.15 | 0.09 | qa.browser_session |
109
- | 23 | qa.browser_session | 0.24 | 0.54 | 0.46 | 0.83 | 0.20 | 0.14 | qa.browser_session |
110
- | 24 | qa.browser_session | 0.13 | 0.60 | 0.47 | 0.84 | 0.16 | 0.09 | update_todos, qa.deep |
111
- | 26 | AsyncProcess, update_todos | 0.12 | 0.56 | 0.43 | 0.86 | 0.11 | 0.07 | completion accepted |
112
-
113
- Rounds 4, 5, 9, 11 and 25 got no answer (service unavailable). Round 25 was the one that judged
114
- the `qa.deep` gate result, so the service never saw the evidence that the task was verified.
115
-
116
- Summary statistics over the 21 answered rounds, split by whether a judged call had failed:
117
-
118
- | Question | Mean (SD) | After a failure (n=4) | After success (n=17) | Rounds ≥0.80 / ≤0.20 |
119
- | --- | --- | --- | --- | --- |
120
- | `result_answered_question` | 0.21 (0.12) | 0.09 | 0.23 | 0 / 10 |
121
- | `needs_more_investigation` | 0.57 (0.06) | 0.60 | 0.56 | 0 / 0 |
122
- | `should_retry` | 0.43 (0.05) | 0.39 | 0.44 | 0 / 0 |
123
- | `strategy_should_change` | 0.83 (0.05) | 0.88 | 0.82 | 18 / 0 |
124
- | `ready_for_verification` | 0.17 (0.09) | 0.10 | 0.19 | 0 / 16 |
125
- | `likely_complete` | 0.10 (0.06) | 0.05 | 0.11 | 0 / 18 |
126
-
127
- ## Thresholds, calibration, or the questions?
128
-
129
- **Calibration first, question context second, thresholds not at all.**
130
-
131
- - **The answers barely move.** Every post-tool question has a standard deviation of 0.05-0.12
132
- across 21 rounds whose evidence ranged from a refused shell to a passing QA gate. The gap
133
- between a failed and a successful round is 0.04-0.14 on every question. Whatever threshold is
134
- chosen, an answer that does not change with the evidence either fires every round or never.
135
- - **`strategy_should_change` is biased high.** Mean 0.83, at or above 0.80 in 18 of 21 rounds,
136
- including the eleven consecutive rounds where `qa.browser_session` was succeeding and the model
137
- correctly kept driving the game. Lowering the bar to 0.80 would have injected "change
138
- investigation strategy; do not repeat the same failed approach" into 18 prompts, wrongly in at
139
- least 17, into a run that succeeded. At 0.90 it fires once (round 7, after the `Grep` path
140
- error, where the model did change course), which is a sample of one.
141
- - **`should_retry` points the wrong way.** It is lower after failures (0.39) than after
142
- successes (0.44). No threshold rescues an inverted signal.
143
- - **`likely_complete` never approached the bar when it was true.** Its maximum was 0.23; in the
144
- round immediately before the model completed it was 0.07. Even a 0.50 bar would not have fired.
145
- The decisive **no** answers (six rounds ≤0.05) were correct, but a no on this question does
146
- nothing. Part of this is a context gap: the runtime requires every todo to be completed before
147
- it allows a completion shortcut, yet the post-tool snapshot never tells the service the todo
148
- state, and the round that judged the `qa.deep` verdict failed.
149
- - **`ready_for_verification` peaked at the right moment** (0.47, right after the `Write`), and
150
- the model did go to verification next. That is the only question where a lower bar would have
151
- fired once and been right, but 0.47 is below a coin flip and the same bar (≤0.47) would have
152
- fired nowhere else, so it is noise that happened to land.
153
- - **The one `next_action` round agreed with the model.** The model called `prepare_steps` once
154
- in 27 turns (turn 3), so candidates existed for one round. Its next call, `qa.inspect_project`,
155
- was exactly the prepared `inspect_profile` step. The service answered at confidence 0.72
156
- against a 0.95 bar, and the step's kind gate (`needs_more_investigation` ≥0.95) stood at 0.41.
157
- A hit there would have saved one model turn (mean 7.5 s in this run). It is the strongest case
158
- for a looser bar in the whole run, and it is one round, with the service hedging at 0.72 on a
159
- choice it had the evidence to make.
160
- - **Preflight families were hedges, not confident noes.** Four families sat at 0.25-0.30. A
161
- ≤0.30 cut would have removed four families, three of them harmlessly, in this run. It would also
162
- have cut `code-search`, which the model used three times, and the answers were not confident
163
- enough to defend the cut if the next task is different. With no workspace facts in the
164
- snapshot, the service was asked to guess.
165
-
166
- The 0.95 / 0.05 bar on "skip the coding model and act" is a safety choice. Nothing above
167
- justifies loosening it: there is no threshold between the current values and 0.50 that would have
168
- produced more correct actions than wrong ones in this run. Loosening the 0.80 / 0.20 family bar
169
- to 0.30 would have been a net win here only because the hedged families happened to be the unused
170
- ones.
171
-
172
- ## The second run
173
-
174
- A second JEV run of the same prompt (`5ffd22e8`, same day, model and endpoint; yolo mode
175
- throughout) is under `Benchmarks/3D-Dodge/runs/2026-10-31_andorra-code_jev_glm-5.3-flash_5ffd22e8/`.
176
- It asked 129 questions over 20 rounds (1 preflight, 19 postflight), got 105 answers, applied none,
177
- and 4 rounds fell back on `decision_service_unavailable`. Its rounds cost 16.4 s.
178
-
179
- Post-tool answers over the 15 answered rounds:
180
-
181
- | Question | Mean (SD) | Min–max | Rounds ≥0.95 / ≤0.05 |
182
- | --- | --- | --- | --- |
183
- | `result_answered_question` | 0.32 (0.13) | 0.20–0.70 | 0 / 0 |
184
- | `needs_more_investigation` | 0.37 (0.07) | 0.13–0.43 | 0 / 0 |
185
- | `should_retry` | 0.52 (0.03) | 0.43–0.56 | 0 / 0 |
186
- | `strategy_should_change` | 0.50 (0.11) | 0.12–0.59 | 0 / 0 |
187
- | `ready_for_verification` | 0.29 (0.09) | 0.17–0.54 | 0 / 0 |
188
- | `likely_complete` | 0.21 (0.10) | 0.09–0.47 | 0 / 0 |
189
-
190
- Nothing crossed either bar. The model never called `prepare_steps`, so `next_action` was never
191
- asked and no turn could have been skipped. The preflight repeated the first run almost exactly
192
- (`needs_delegation` 0.12, `security_sensitive` 0.03, families at 0.26–0.44 apart from
193
- filesystem-write 0.87 and browser 0.74).
194
-
195
- Two things the second run adds:
196
-
197
- - **The answers are not stable between runs.** `strategy_should_change` averaged 0.83 in the
198
- first run and 0.50 in the second, and `should_retry` 0.43 against 0.52, on trajectories that
199
- differ mostly in which `qa.browser_session` operations were called. A question whose mean moves
200
- by 0.33 between two near-identical runs while its standard deviation within a run is 0.05–0.11
201
- is not reading the per-round evidence.
202
- - **The round's cost was paid synchronously.** When these runs were recorded the runtime awaited
203
- the postflight round between a turn's tool results and the next model request
204
- (`src/hardened-runtime.ts`, `decisionManager.postflight`). The benchmark's "Tool end → next
205
- request" metric measures that window: 884 ms and 1,021 ms per turn with Jev, 237 ms and 240 ms
206
- without, so about 0.8 s per turn and 16–19 s per run. That was the whole of Jev's direct cost in
207
- these runs, and with the answers above it bought no decision. The runtime now awaits the round
208
- only when it can act (see "When the post-tool round holds up the next turn" above).
209
-
210
- ## After the non-blocking post-tool round
211
-
212
- `Benchmarks/3D-Dodge-OnePass/` ran the same game with QA forbidden, on a build that has
213
- [Andorra-Labs/Andorra-Code#354](https://github.com/Andorra-Labs/Andorra-Code/pull/354): one Jev
214
- run and one without, three requests each.
215
-
216
- | | Jev `625d4c10` | No Jev `88797a24` |
217
- |---|---|---|
218
- | Wall time | 110.4 s | 102.0 s |
219
- | Tool end → next request (mean) | 111 ms | 95 ms |
220
- | Jev rounds (preflight / post-tool) | 1 / 2, all answered | — |
221
- | Awaited Jev time | 817 ms (preflight) | — |
222
- | Decisions applied | 0 (one guidance line) | — |
223
-
224
- - **The post-tool round no longer costs wall time.** Both rounds ran while the next request was in
225
- flight. The 16 ms gap difference is the cost of starting them.
226
- - **The preflight is now the only awaited round,** at 0.8–0.9 s per run in all three Jev runs,
227
- and in none of them did it remove a tool or set a verification tier.
228
- - **The preflight judged a placeholder.** The prompt was pasted as an attachment, so the task
229
- text, which is what the preflight receives, was "See the attached file(s)." The tool-family
230
- answers (0.23–0.64) were for a task the service could not read, including the instruction not
231
- to use terminals or browsers.
232
- - **The last post-tool round can never act.** Its answer arrived 1.1 s into the final request and
233
- the run ended after it. A decisive answer would have had no request left to reach.
234
- - The remaining 7.6 s of the gap is the model: 3.2k more output tokens on the turn that wrote the
235
- file, partly offset by a shorter final reply.
236
-
237
- ## The Little Harvest run: why no post-tool directive reached the model
238
-
239
- A 25-minute Jev run of the Little Harvest prompt on 2026-11-01 (run `ef9363f2`, `glm-5.3-flash`
240
- on the GX10 endpoint, `--prompt --yolo --json`, 64 model requests, 60 post-tool rounds, 58 answered)
241
- was checked for the directives the non-blocking round is supposed to deliver. None of the 64 logged
242
- requests carried a `Runtime Jev decisions` message. Seven rounds had looked confident:
243
- `strategy_should_change` reached 0.79–0.85 and `needs_more_investigation` 0.72–0.81. The reason is
244
- the bar, not the delivery:
245
-
246
- - **No answer crossed 0.95.** The six post-tool booleans are decisive at ≥0.95 / ≤0.05
247
- (`DecisionPolicy.boolean`). The highest answer in the run was 0.85, so `postToolGuidance` returned
248
- an empty directive for all 58 rounds and there was nothing to carry. This is the threshold this
249
- page recommends keeping: in the first 3D-Dodge run `strategy_should_change` sat at 0.83 across 18
250
- of 21 rounds of a run that succeeded, and a 0.80 bar would have injected "change strategy" into 17
251
- prompts wrongly.
252
- - **The late-arrival path would have carried a decisive answer.** Each of the seven answers arrived
253
- 0.66–1.01 s into the request built right after its tool batch, and the request after that was
254
- built 2.3–12.4 s later, so the answer would have been applied at the top of that iteration and
255
- carried by it. The following round answers about a second after that request is built, too late
256
- to overwrite the pending answer. The run never called `prepare_steps`, so every round took the
257
- non-blocking path. `test/decision-post-tool.test.ts` ("a late post-tool answer is carried by
258
- exactly one request…") pins both halves: 0.85 yields no directive, 0.96 yields one directive on
259
- the request after the answer and none on the one after that.
260
- - **The trajectory log is the request.** `src/trajectory.ts` records the `messages` array the
261
- runtime passes to the provider (the clone taken at the top of the iteration), and the ephemeral
262
- todo snapshot appears in every logged request, so a trailing directive would have been logged too.
263
-
264
- What the run did show is the preflight acting against the prompt. The prompt said "Do not create a
265
- development plan, write a QA report, run automated tests, or produce placeholder implementations."
266
- The preflight scored `task_complexity` 0.9725 at confidence 0.92, which `decisionExecutionGuidance`
267
- (`src/decision/toolFamilies.ts`) turns into two system-prompt directives regardless of the chosen
268
- `verification_tier` (here `targeted` at 0.15): "Run the affected full test suite, build, and
269
- applicable static checks" and "Break this complex task into explicit milestones and verify
270
- integration between changed components." The no-Jev sibling run of the same prompt (`bf4dc7b3`) had
271
- no such block. The block carries the caveat "never overrides explicit user instructions", which
272
- leaves the contradiction for the coding model to resolve on every request. Both runs still ended with
273
- a comparable number of browser QA calls (27 with Jev, 33 without), so this run does not show the
274
- directive changing behavior, but it is the one place where Jev added instructions the user had
275
- forbidden. Filtering preflight directives against explicit prohibitions in the task before they are
276
- injected is a harness-side follow-up (see below), not a threshold question.
277
-
278
- ### A paired A/B on small tasks, same day
279
-
280
- To see whether Jev reduces coding-model work at all, three small tasks were run with `jevEnabled`
281
- on and off from the same signed-in home, on the same provider (GX10 `glm-5.3-flash`), with the
282
- shipped defaults (no `efficiency` switches), each from a fresh copy of its seed folder, order
283
- alternating per repetition: a greenfield Node CLI with a `node:test` suite, a seeded bugfix with a
284
- failing suite, and a read-only investigation of a seeded HTTP service. Every run passed an executable
285
- check of its result in both arms. One no-Jev bugfix run crashed at startup before any model request
286
- (a native-module access violation, not Jev) and its pair was replaced.
287
-
288
- | Pair | Requests Jev / none | Input tokens Jev / none | Directives reaching the model |
289
- | --- | --- | --- | --- |
290
- | greenfield 1 | 7 / 6 | 142,710 / 80,438 | 1 (`result_answered_question`, on the final request) |
291
- | greenfield 2 | 9 / 7 | 143,793 / 131,237 | 0 |
292
- | bugfix 1 | 8 / 9 | 125,692 / 154,582 | 0 |
293
- | bugfix 2 | 7 / 8 | 90,287 / 103,677 | 0 |
294
- | investigate 1 | 7 / 5 | 107,325 / 67,272 | 4 (`needs_more_investigation`, requests 4–7) |
295
- | investigate 2 | 7 / 8 | 94,654 / 133,550 | 2 (`needs_more_investigation`) |
296
- | **Total** | **45 / 43** | **704,461 / 670,756** | 7 of 45 requests |
297
-
298
- Three pairs favor each arm; the net is +2 requests and +5 % input tokens with Jev, and the spread
299
- within one arm (greenfield without Jev: 80k and 131k; investigation without Jev: 67k and 134k) is
300
- larger than the gap between arms. Jev neither saved nor clearly cost model work on these tasks. What
301
- the runs show about the mechanism:
302
-
303
- - **The lever that skips a turn never engaged.** `prepare_steps` was called 0 times in all seven
304
- Jev runs (and 0 times in the 64-turn Little Harvest run), so `next_action` was never asked and
305
- `decision.turn_bypassed` is 0 everywhere. The switches that prepare steps without the model's help
306
- (`efficiency.preparedContinuations`, `postflightOnlyWithCandidates`) are off by default and were
307
- not measured.
308
- - **The directives that did fire asked for more work.** Six post-tool answers crossed 0.95 in 37
309
- rounds, five of them `needs_more_investigation` on the investigation task. "Gather the missing
310
- evidence before completing" sat on four consecutive requests of the first pair, and the model
311
- answered it with two extra search turns (`Grep`, `Grep`, `git_read`) before completing where the
312
- no-Jev run completed two requests earlier. Of the six directives, five add work; the two that
313
- could end work early (`result_answered_question`, `likely_complete`) crossed the bar once, on a
314
- final request, where nothing was left to save.
315
- - **The directive stays until a newer answer replaces it.** Consecutive rounds re-answering ≥0.95
316
- keep the same line on every request, so a directive that was right once keeps nudging after the
317
- model has acted on it.
318
- - **Fixed cost per request.** The `prepare_steps` schema (about 1,650 serialized characters) and the
319
- preflight directive block (about 480) ride every request with Jev on, roughly 2,100 characters,
320
- almost all of it cache reads on this provider.
321
- - **The preflight is consistent.** `task_complexity` repeated within ±0.02 per task across
322
- repetitions (0.25 bugfix, 0.26 greenfield, 0.63 investigation), and `verification_tier` was
323
- `full-tests` at confidence 1.0 for the bugfix, whose prompt already asked for the suite.
324
-
325
- ## Jev availability: the run that silently had no Jev
326
-
327
- While re-running the A/B of 2026-11-01 on the installed build, 7 of 12 Jev-arm runs had no decision
328
- round at all, and nothing in the run log or on stderr said why. The run's membership lookup
329
- (`getMembership`, `src/membership.ts`) had answered "not signed in" on a signed-in account:
330
- `AuthManager.verify` caught every failure of `jwtVerify` as a rejected credential, including a failed
331
- fetch of the JSON Web Key Set, which every fresh process performs on its first verification. Twenty-five
332
- consecutive verifications inside one process and thirty consecutive `/me` calls all succeeded, so the
333
- failure is transient and per process. Two changes:
334
-
335
- - `verify` reports a key-set fetch failure (jose's timeout or non-200 error, a failed fetch, a transport
336
- error anywhere in the cause chain) as `network`, which the membership client already treats as
337
- `unavailable`. A signature, issuer, audience or claim failure is still `invalid_token`.
338
- - The CLI retries an unavailable lookup once (the lookup itself has a five-second budget, and a cold
339
- account service answered in 5.9 s once and in about 0.5 s afterwards) and, when Jev still cannot run,
340
- records `decision.unavailable` (`reason`: `not_signed_in`, `membership_unavailable` or the transport
341
- failure reason) in the run log and prints one notice. A run without Jev is now visible as such, and
342
- the eval suite (`eval/`) excludes it from a Jev arm instead of averaging it in.
343
-
344
- The CLI also takes `--jev on|off` as a session-only policy, so an A/B needs no configuration edits.
345
- ## Recommended changes
346
-
347
- ### Service side (do these first)
348
-
349
- 1. **Calibrate the six post-tool booleans against outcome labels.** The benchmark trajectories
350
- give labels for free: a judged call that failed and was then retried with different arguments
351
- (`should_retry` yes), a successful call followed by the same tool again (`strategy_should_change`
352
- no), the round before an accepted completion (`likely_complete` yes). Target: on these six
353
- questions, answers after a failed round and after a successful round should differ by more
354
- than the current 0.04-0.14, and `strategy_should_change` must not sit at 0.83 while the
355
- approach is working.
356
- 2. **Be decisive on `next_action` when the evidence is in the snapshot.** The candidate
357
- description said "after index.html is written: get QA profile", and the judged result was the
358
- `Write` of `index.html`. 0.72 on that is a hedge.
359
- 3. **Put the tool-family answers for a greenfield task where they belong.** "Create one HTML
360
- file" with no repository facts should still put git and codegraph under 0.20.
361
- 4. **Availability.** 5 of 26 post-tool rounds (19%) returned `decision_service_unavailable` in
362
- a six-minute run. The lost round included the verification verdict.
363
-
364
- ### Harness side (no threshold change)
365
-
366
- These are follow-ups, not part of this analysis, and the first needs the service to accept the
367
- fields before the harness sends them:
368
-
369
- 1. **Send what the gates already require.** The post-tool snapshot should carry a bounded todo
370
- summary (counts by status), since the completion shortcut requires every todo to be completed
371
- and the service cannot see them. The preflight snapshot should carry workspace facts (whether
372
- the folder is empty, whether it is a git repository, a file-count bucket) so the family
373
- questions are not guesses.
374
- 2. **Count applied decisions honestly.** Emit a `decision.applied` (or sibling) event when
375
- `routeToolFamilies` omits schemas and when `decisionExecutionGuidance` or `postToolGuidance`
376
- adds a directive, so a benchmark's "decisions applied" matches what reached the model. Log
377
- whether `next_action` chose `llm` (a fixed identifier) so a missed short-circuit can be
378
- evaluated after the fact without exposing model-authored step IDs.
379
- 3. **Record the HTTP status class on `decision.provider_error`.** Every non-401, non-429 failure
380
- is reported as `decision_service_unavailable`, which hides whether the five failures were 5xx,
381
- 4xx rejections of the snapshot, or network errors.
382
- 4. **Do not await a postflight round that cannot act.** Done: without prepared-step candidates the
383
- round's only possible effect is a directive for the following prompt, which is applied when
384
- it arrives. Awaiting it only when candidates exist keeps the short-circuit intact and removes
385
- about 0.8 s per model turn from every run where the model does not call `prepare_steps`, which
386
- in these two runs was 46 of 47 turns. See "When the post-tool round holds up the next turn"
387
- and `tests/jev-postflight-nonblocking-test-plan.md`.
388
- 5. **Give the preflight the attachment text.** When the task text is the attachment-only
389
- placeholder, the preflight's task should carry the text of small text attachments (or a
390
- bounded excerpt), since that is where the request is.
391
- 6. **Take the preflight off the critical path.** It is the only awaited round left. Starting it
392
- before the graph starts would hide it, if its inputs can be assembled that early. Applying a
393
- late answer to a later request is not an option for tool routing, because changing the tool
394
- list mid-run discards the cached prompt prefix.
395
- 7. **Filter preflight directives against the task's explicit prohibitions.** The Little Harvest run
396
- injected "run the full test suite" and "break the task into milestones" into a prompt that
397
- forbade automated tests and a development plan. The caveat line leaves the contradiction to the
398
- coding model on every request; dropping the optional directive before injection, and recording
399
- that it was dropped, keeps Jev advisory.
400
- 8. **Make the "stop" signals able to save a turn, and the "more" signals less sticky.** In the A/B
401
- the only decisive post-tool answers asked for more investigation and persisted across requests,
402
- while `result_answered_question` and `likely_complete` fired once, too late. A directive that has
403
- been carried by one request could be withheld until a later round re-crosses the bar on new
404
- evidence, and a decisive `likely_complete` without a prepared `complete` candidate does nothing
405
- today.
406
-
407
- ### When a threshold change would be justified
408
-
409
- Revisit the bars only with a labeled set from several runs where, for the question in hand, the
410
- answers after the labeled-yes rounds and after the labeled-no rounds are separated by at least
411
- 0.30 on average. Until the service's answers discriminate, a lower bar changes how often Jev acts,
412
- not how often it is right.
@@ -1,217 +0,0 @@
1
- # Efficiency features: fewer coding-model turns, smaller requests
2
-
3
- **Status:** implemented behind independent switches, all off by default. Each switch was evaluated on
4
- its own with deterministic replay (`npm run eval:jev`); none has been validated on a live model, so
5
- none is enabled until a paired live evaluation shows preserved quality at lower cost.
6
-
7
- The agent runtime spends money in three ways: the number of coding-model requests, the size of each
8
- request (every turn resends the whole conversation), and the model tier each request runs on. The
9
- features below attack each of those without widening what the hosted decision service receives, and
10
- without touching permissions, approvals, required verification or user control.
11
-
12
- ## The decision hierarchy
13
-
14
- Every change here follows one order:
15
-
16
- 1. **Deterministic runtime logic for facts already known.** A process exit code, an empty workspace,
17
- a missing repository, an unchanged context block, a test report's pass/fail counts: ordinary code
18
- settles these and spends no decision request on them.
19
- 2. **Jev for bounded semantic choices among known alternatives**, using only the question types the
20
- hosted service supports today (`src/decision/providers/questions.ts`). The service accepts no new
21
- question ids, so every selection that would need a new question stays deterministic.
22
- 3. **The coding model for new code, new arguments, diagnosis and unfamiliar reasoning.**
23
-
24
- Jev never generates code, commands, paths, summaries or answers; never grants permissions; never
25
- overrides graph steps or user instructions; never treats an exit code of zero as task completion;
26
- and never turns tool output into instructions. On timeout, malformed output, uncertainty or an
27
- unavailable service the runtime falls back to ordinary execution, as before.
28
-
29
- ## Configuration
30
-
31
- ```json
32
- {
33
- "efficiency": {
34
- "preparedContinuations": false,
35
- "postflightOnlyWithCandidates": false,
36
- "toolResultFiltering": false,
37
- "toolResultFilterThresholdChars": 6000,
38
- "contextSelection": false,
39
- "catalogSelection": false,
40
- "adaptiveRouting": {
41
- "enabled": false,
42
- "tiers": { "economy": { "provider": "local", "model": "small" }, "balanced": { "provider": "local" }, "premium": { "provider": "cloud", "model": "large" } },
43
- "maxEscalations": 1,
44
- "pricing": { "local/small": { "inputPerMillionUsd": 0.1, "outputPerMillionUsd": 0.4, "cacheReadPerMillionUsd": 0.01 } }
45
- }
46
- }
47
- }
48
- ```
49
-
50
- Omitting the block, or any switch, is the shipped behavior byte for byte (`test/jev-efficiency-runtime.test.ts`
51
- compares the serialized requests). To roll a feature back, remove its switch; no run state depends on it.
52
- The switches are read from `config.json` by the CLI and the desktop engine (`src/cli.ts`, `src/app-server.ts`).
53
-
54
- ## 1. Prepared continuations (`preparedContinuations`)
55
-
56
- The coding model already prepares concrete next steps with `prepare_steps` (`src/decision/PreparedSteps.ts`),
57
- and a Jev round selects among them after the batch's results. With this switch an `investigate` or
58
- `verify` step may declare `when: "success" | "failure" | "always"`. The outcome of the batch that
59
- prepared it is a known fact, so the first step whose trigger matches runs right after that batch
60
- without a decision request. Only that one step runs deterministically; its own results are judged by
61
- a round like any other, with the remaining steps as candidates, so a chain of automatic actions still
62
- ends at the existing limit of three.
63
-
64
- Everything that restricted automatic actions still does: retries and completions never trigger, a
65
- step whose tool is not in the catalog is rejected when prepared, the fingerprint rule blocks repeating
66
- an unsafe action, approvals and hooks run, and the step is revalidated against the catalog the turn
67
- advertises and the permission state it was authored under immediately before execution. Steering,
68
- follow-ups and a model resumption discard prepared steps (`efficiency.prepared.invalidated`).
69
-
70
- Accounting: `decision.turn_bypassed` is emitted only after the prepared action executed. A step the
71
- catalog, a hook, invalid arguments or an approval rejected produced an error observation the model
72
- has to read, so it is reported as `efficiency.prepared.rejected` and never as a saved turn.
73
- `efficiency.prepared.declared` carries the serialized size of every `prepare_steps` call, so the
74
- preparation overhead is in the ledger next to the turn it may save.
75
-
76
- ## 2. No post-tool round without a decision (`postflightOnlyWithCandidates`)
77
-
78
- The post-tool round is already non-blocking when the batch prepared no candidates
79
- (`docs/concepts/jev-decision-thresholds.md`): its only possible effect is one advisory line in a later
80
- prompt. Under this switch that round is not requested at all (`efficiency.postflight.skipped`,
81
- reason `no_candidates`). A round with candidates is requested and awaited as before, and the wait it
82
- puts on the critical path is recorded separately (`efficiency.postflight.awaited`, `waitMs`).
83
-
84
- ## 3. Tool-result filtering (`toolResultFiltering`)
85
-
86
- `src/tool-result-filter.ts` parses bulky shell, search and listing results once, at insertion, before
87
- they enter the model-visible conversation. It recognizes test reports (node:test, vitest/jest,
88
- pytest, cargo, go), compiler output, search results, directory listings and progress-heavy logs. A
89
- filtered result keeps the executed command's exit status (the `Tool error: Exit code: N` line stays
90
- in place), every failure with its assertion and stack frames, the summary counts, warnings, the
91
- first and last lines, and a trailer made only of counts that names the archived original:
92
-
93
- ```text
94
- [Tool output filtered (test-report): 2387 of 2416 lines omitted; passLines=600 failLines=2 summaryLines=4. Complete original: tool-output://<invocation>/1 (use expand_tool_output with ref, offset and limit).]
95
- ```
96
-
97
- Nothing is reworded: the module assembles excerpts and counts and writes no summary of its own, so
98
- an instruction hidden in a test name cannot reach the structured trailer. The complete original is
99
- kept in an invocation-scoped archive (and in the run's artifact store when one exists, as `0600`
100
- files) and expanded by reference and range through `expand_tool_output`, whose schema joins the
101
- catalog only once something was archived. Another invocation's reference is refused. Expansions are
102
- recorded (`efficiency.tool_result.expanded`) so a model that reads the original back is charged for it.
103
-
104
- Never filtered: source reads, patch hunks, skill and memory content (not candidates at all), tool
105
- errors other than a non-zero exit (the text is the evidence), outputs at or under the threshold,
106
- formats the parser does not recognize (the existing clip and pressure-driven compaction stay as the
107
- fallbacks), and a filtered result that would not be at least 20% smaller. A filtered observation is
108
- reported as truncated, so no prepared completion may rest on it.
109
-
110
- Semantic selection by Jev of which excerpts to keep would require sending excerpts the hosted service
111
- is not contracted to receive. It is not implemented; the deterministic path stands alone.
112
-
113
- Finding from the evaluation: the shipped 24,000-character clip drops both failing tests of a
114
- 600-test report, because they sit past the clip. Filtering keeps them.
115
-
116
- ## 4. Context selection and retrieval gating (`contextSelection`)
117
-
118
- Before retrieval, `src/workspace-facts.ts` collects bounded facts (empty or not, file-count bucket,
119
- `.git` present, manifest names). An empty workspace has no source to explore and no repository
120
- history to recall, so both automatic retrievals are skipped on that fact alone
121
- (`efficiency.context.retrieval_skipped`). A missing repository gates nothing; the index and memory
122
- services report their own availability as before.
123
-
124
- After retrieval, `src/context-selection.ts` ranks what came back by bounded lexical evidence
125
- (identifiers shared with the task, weighted toward a candidate's own path or title), keeps mandatory
126
- items, keeps the dependencies of everything kept, and lists what it omitted with the tool that
127
- fetches it (`repo_explore`, `Read`, `memory_search`). The repository block is selected per file
128
- inside the CodeGraph query so the ledger records only what was injected; memory entries are selected
129
- and the block rebuilt from the kept entries, unchanged in wording. The selection is content-level and
130
- deterministic; it never claims a Jev judgment it did not make.
131
-
132
- A block whose exact text already sits in the conversation a node inherits from its predecessor is not
133
- injected again (`efficiency.context.duplicate`); a changed file produces different text and is
134
- injected as new. Memory entries remain untrusted evidence.
135
-
136
- ## 5. Tool catalog and skills (`catalogSelection`)
137
-
138
- `src/tool-catalog.ts` builds a task-appropriate catalog from the tools the node is already permitted
139
- to use. Only certainties omit a family: no repository and no git wording omits `git`; an unavailable
140
- index omits `codegraph`; an empty workspace omits `memory`; `web`, `browser` and `subagents` are
141
- omitted when nothing in the task indicates them. Protected core tools, tools the node names
142
- explicitly, unknown families, and every tool an inherited transcript already called are kept, the last
143
- so providers that validate historical tool calls against the catalog still see the schema. The
144
- selection is a pure function of its inputs (byte-stable ordering), computed once per attempt, and it
145
- is applied only when the schema characters it saves exceed the cost of the omission note plus the
146
- `restore_tools` schema. Everything omitted stays restorable through `restore_tools` with the same
147
- permission checks (`efficiency.catalog.restored`).
148
-
149
- The skill catalog is ordered by relevance to the task within its budget, explicitly requested and
150
- inherited skills first and whole, the rest named without descriptions so they stay loadable. Skill
151
- bodies were already loaded lazily by the `Skill` tool; a catalog block already present in the inherited
152
- conversation is not re-inserted.
153
-
154
- ## 6. Adaptive model-tier routing (`adaptiveRouting`)
155
-
156
- Off unless `enabled: true` and at least one tier names a configured provider and model. A node that
157
- pins a provider or model, a run started with an explicit model (`--model`, a desktop override, a live
158
- selection) and a delegated child are never re-tiered. The decision is taken once per attempt before
159
- the conversation is built: a decisive security or architecture answer from the preflight, or risk
160
- wording in the task, routes to `premium`; a short mechanical task (rename, typo, formatting,
161
- changelog) routes to `economy`; a complexity score with confidence routes by its value; anything
162
- else keeps the baseline (`efficiency.routing.decided`, reason `low_confidence`). A tier the
163
- configuration cannot resolve keeps the baseline too.
164
-
165
- Escalation is upward only, at most `maxEscalations` per node (default 1), and only after a defined
166
- failure (`repeatedToolFailure`, `maxIterations`, `maxCompletionRepairs`, or an exhausted
167
- prepared-step metadata allowance); a cancellation or a deadline is not evidence. The
168
- escalated attempt is a fresh conversation (no provider continuation or reasoning state crosses
169
- models), told which workspace files the previous attempt already changed so it inspects rather than
170
- repeats them, and billed to the same node budget as every attempt before it.
171
-
172
- Cost reporting uses only prices the configuration supplies (`pricing`, keyed `provider/model`); a
173
- model without a price reports "cost unavailable", never zero. The runtime assigns no capability or
174
- quality rating to any model.
175
-
176
- ## Accounting
177
-
178
- Every feature emits `efficiency.<feature>.<outcome>` events with fixed reason codes
179
- (`EFFICIENCY_REASONS` in `src/efficiency.ts`), folded into a local `efficiency` tally on the run's
180
- telemetry capture (`src/telemetry/capture.ts`). The tally is never uploaded; the emitter copies named
181
- fields only. The existing `decision.*` events, `decision.turn_bypassed`, provider usage and the
182
- Benchmarks metrics are unchanged.
183
-
184
- What is measured, and how it is labeled:
185
-
186
- | Figure | Source | Label |
187
- | --- | --- | --- |
188
- | Model requests, input, output, cache read/write | provider usage, as before | observed |
189
- | Request size | serialized JSON of messages and tool schemas | deterministic comparison, characters, not tokens |
190
- | Jev requests, latency, critical-path wait | `decision.*` and `efficiency.postflight.awaited` | observed |
191
- | Saved input of a bypassed turn | usage dashboard estimate from the preceding measured request | counterfactual estimate |
192
- | Cost | configured prices only | unavailable when no price is configured |
193
-
194
- Optimizations are applied in sequence and each delta is attributed once: a filtered result enters
195
- the conversation smaller, and the pressure-driven compaction that may later retire it sees only the
196
- smaller text. A skipped model call is counted as a bypassed turn and nothing else is credited for it.
197
-
198
- ## Evaluation
199
-
200
- ```bash
201
- npm run build
202
- npm run test:jev # focused unit and integration suites
203
- npm run eval:jev # deterministic replay: baseline, each feature alone, all together
204
- npm run eval:jev:live # optional paired live evaluation; needs ANDORRA_LIVE_EVAL=1 and ANDORRA_LIVE_EVAL_HOME, a dedicated home signed in with an evaluation account (its config is used as is; only the efficiency block changes per run, and a probe run must show decisions being requested before any pair is spent)
205
- ```
206
-
207
- The deterministic evaluation (`scripts/jev-efficiency-eval.mjs`, workloads in
208
- `tests/jev-efficiency/workloads.mjs`, criteria in `tests/jev-efficiency/criteria.json`) writes
209
- `tests/jev-efficiency/results/latest.{json,md}`. It compares what the runtime actually sent under
210
- scripted models, tools and a scripted decision provider. It is a mechanism and opportunity
211
- evaluation: a live model may behave differently with less context, scripted adapters report no
212
- tokens, and no cost is known for a mock model. The acceptance criteria were written before the first
213
- run; the two revisions made afterwards are recorded in the file with their reasons, and neither
214
- loosened a per-feature size or count threshold.
215
-
216
- Live savings and quality preservation are unvalidated. Until a paired live evaluation exists, every
217
- feature stays off by default.