@andorra-labs/code 0.1.10 → 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.
- package/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +36 -0
- package/dist/src/app-server/protocol.d.ts +1 -0
- package/dist/src/app-server.d.ts +34 -1
- package/dist/src/app-server.js +264 -54
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +8 -0
- package/dist/src/completion.js +19 -1
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/graph-manager-chat.js +13 -13
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-server.js +9 -9
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +262 -93
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +4 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +11 -11
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +3 -2
- package/dist/src/graphs.js +3 -2
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/react-runtime.js +121 -14
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/terminal-ui.js +2 -2
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# Graph Manager chat in Graph Studio
|
|
2
|
-
|
|
3
|
-
Date: 2026-11-13. Status: approved 2026-11-13.
|
|
4
|
-
|
|
5
|
-
## Intent
|
|
6
|
-
|
|
7
|
-
Building a graph by hand in Graph Studio means knowing node types, ports, routes and limits. The bundled
|
|
8
|
-
`andorra:graph-manager` skill already knows how to design and edit graphs through the `graphs` tool, but you
|
|
9
|
-
can only reach it from a regular task, away from the graph you are looking at. This feature puts that
|
|
10
|
-
assistant next to the open graph. A **Graph Manager** button opens a side chat. You pick the provider and
|
|
11
|
-
model, and the agent starts already knowing which graph is open, so it can help you create or change that
|
|
12
|
-
graph without leaving the editor.
|
|
13
|
-
|
|
14
|
-
## Goals
|
|
15
|
-
|
|
16
|
-
- A **Graph Manager** button in Graph Studio's toolbar whenever a graph is open (saved or new).
|
|
17
|
-
- When you create a new graph, a closable tip next to the button says you can let Graph Manager build it.
|
|
18
|
-
- The button opens a side panel in the editor with a provider and model picker and a chat.
|
|
19
|
-
- Each chat runs the `andorra:graph-manager` skill. Its first message tells the agent the open graph's id and
|
|
20
|
-
name, and the provider and model you chose.
|
|
21
|
-
- It works the same in the desktop app (Graph Studio in its iframe) and in a browser (`andorra graph`).
|
|
22
|
-
- When the agent saves a revision of the open graph, the canvas shows it.
|
|
23
|
-
|
|
24
|
-
## Non-goals
|
|
25
|
-
|
|
26
|
-
- No new graph tool. The agent uses the existing `graphs` tool and the existing skill.
|
|
27
|
-
- No native desktop panel. The desktop shows the same in-editor panel through the iframe.
|
|
28
|
-
- No attachments, voice, slash-skill menu or other composer features from the main chat.
|
|
29
|
-
- No change to how regular tasks run.
|
|
30
|
-
|
|
31
|
-
## Anti-goals (a failure even if it works)
|
|
32
|
-
|
|
33
|
-
- The agent edits graph files on disk, or saves graphs without the user seeing an approval.
|
|
34
|
-
- The chat silently overwrites unsaved canvas edits with the agent's revision.
|
|
35
|
-
- Opening the panel leaves a stray engine process, listener or temp folder after the editor closes.
|
|
36
|
-
- The desktop's own task engine is blocked or busy because Graph Manager is talking.
|
|
37
|
-
|
|
38
|
-
## Constraints found in the code
|
|
39
|
-
|
|
40
|
-
- Graph Studio is `src/graph-ui/` (plain JS, no bundler), served by `startGraphServer` in
|
|
41
|
-
`src/graph-server.ts` on loopback with a bearer token. In the desktop, the engine starts that server
|
|
42
|
-
in-process (`src/app-server.ts`, `editorTask`), and `GraphEditorView.tsx` embeds it in a sandboxed iframe.
|
|
43
|
-
In a browser, `andorra graph` starts it alone (`src/graph-editor-session.ts`).
|
|
44
|
-
- An engine runs one task at a time (`engine-busy`). The desktop engine that hosts the graph server may be
|
|
45
|
-
running the user's task, so the chat cannot share it.
|
|
46
|
-
- `run.start` takes `task`, `provider`, `model`, `workspace`, `sessionId` (+ `continueSession`) and
|
|
47
|
-
`runPermissions`. A task that begins with `/graph-manager` invokes the skill (`resolveSkillInvocation`).
|
|
48
|
-
Events (`run.event`, `run.approval`, `run.question`, `run.completed`, `run.failed`) stream on stdout;
|
|
49
|
-
`run.approve`, `run.answer` and `run.cancel` answer them.
|
|
50
|
-
- The skill says the `graphs` tool needs shell permission and is never given to subagents.
|
|
51
|
-
- The graph server already lists providers and models (`GET /api/provider-models`).
|
|
52
|
-
- A new graph has no revision until it is saved; the agent's `andorra_graph_begin` with `mode: "create"`
|
|
53
|
-
creates it.
|
|
54
|
-
|
|
55
|
-
## Approaches
|
|
56
|
-
|
|
57
|
-
- **A. The graph server runs a dedicated engine session (chosen).** On first use the graph server spawns
|
|
58
|
-
`andorra app-server --stdio` as a child process and relays one session to the panel. Reuses multi-turn
|
|
59
|
-
history, streaming, approvals, questions, cancel and model selection. Costs one extra process while a chat
|
|
60
|
-
is open, which must be stopped with the editor.
|
|
61
|
-
- **B. One in-process run per message.** The graph server calls `runDefaultGraph` with earlier turns as
|
|
62
|
-
`history`. No extra process, but memory, streaming, approvals and cancel would be rebuilt by hand: a second,
|
|
63
|
-
thinner engine to maintain.
|
|
64
|
-
- **C. A native desktop panel plus a browser chat.** Twice the work, and the two would drift apart.
|
|
65
|
-
|
|
66
|
-
The user picked A because the hard parts of a chat already exist in the engine.
|
|
67
|
-
|
|
68
|
-
## Design
|
|
69
|
-
|
|
70
|
-
### Server: `src/graph-manager-chat.ts` (new) and routes in `graph-server.ts`
|
|
71
|
-
|
|
72
|
-
A `GraphManagerChat` owned by the graph server, created lazily:
|
|
73
|
-
|
|
74
|
-
- **Engine.** Spawns the running CLI's own entry (`process.execPath` + the CLI script) with
|
|
75
|
-
`app-server --stdio`, the same `ANDORRACODE_HOME` (the user's real home, so sign-in, providers and graphs
|
|
76
|
-
match). One child per graph server. It is killed when the graph server closes and on process exit. It is
|
|
77
|
-
also stopped after 10 minutes with no connected panel, but only while no run is working and no approval or
|
|
78
|
-
question is pending: the `graphs` tool keeps unpublished drafts in the engine's memory.
|
|
79
|
-
- **Workspace.** The chat's workspace (child cwd and `run.start` `workspace`) is a dedicated empty folder,
|
|
80
|
-
`<config directory>/graph-manager/workspace`, created on first use. The graph server's own `directory` is
|
|
81
|
-
the config directory, not a project, and `ask-for-approval` lets an agent edit files inside its workspace
|
|
82
|
-
without asking; an empty, dedicated folder means there is nothing on disk to edit and the chat's sessions
|
|
83
|
-
stay out of the user's project task lists.
|
|
84
|
-
- **Agent.** The run uses a single top-level agent node (shell permission, no Orchestrator intake): the skill
|
|
85
|
-
says delegated subagents never get the `graphs` tool, and the default graph's Orchestrator would interview
|
|
86
|
-
the user before every message. If `run.start` only takes saved graph ids, add an internal built-in
|
|
87
|
-
single-agent graph id for this purpose, hidden from graph lists.
|
|
88
|
-
- **Clients.** Several panels can connect to one graph server (the desktop iframe and a browser tab). They
|
|
89
|
-
share one conversation: every client receives the stream, and any client can send, approve or cancel.
|
|
90
|
-
- **Starting a chat.** `POST /api/manager/start` `{ provider, model, graph, saved, message }` creates the
|
|
91
|
-
session with `sessions.create` (name `Graph Manager: <graph name>`, pinned with `renamed` so automatic
|
|
92
|
-
titling keeps it) and calls `run.start` with:
|
|
93
|
-
- `task`: the bundled skill invoked by its full id (`andorra:graph-manager`, so an installed skill also
|
|
94
|
-
named `graph-manager` cannot shadow it; the builder confirms the exact invocation syntax
|
|
95
|
-
`resolveSkillInvocation` accepts), followed by a context block and the user's message:
|
|
96
|
-
```
|
|
97
|
-
You are helping in Graph Studio. Open graph: "<name>", id <id> (saved revision N | not saved yet).
|
|
98
|
-
The canvas below is what the user sees now, including edits not yet saved. Work from it, and save your
|
|
99
|
-
changes under this same graph id (mode "create" when it is not saved yet, "edit" otherwise).
|
|
100
|
-
Selected model: <provider>/<model>. Use it for new agent nodes unless the user asks otherwise.
|
|
101
|
-
<canvas graph JSON>
|
|
102
|
-
<user message>
|
|
103
|
-
```
|
|
104
|
-
- The canvas is the editor's current graph definition (`state.graph`, including unsaved edits), sent with
|
|
105
|
-
every message, not only the first, so the agent always works from what is on screen. A graph over the
|
|
106
|
-
server's body limit is refused with a clear message rather than truncated.
|
|
107
|
-
- `provider`, `model` as chosen; `workspace` = the graph server's cwd;
|
|
108
|
-
`runPermissions: "ask-for-approval"` so every graph write and shell use stops for approval in the panel.
|
|
109
|
-
- **Follow-ups.** `POST /api/manager/message` `{ text, graph, saved }` (canvas included again) sends `run.start` with the same `sessionId` and
|
|
110
|
-
`continueSession: true` when idle, or `run.steer` while a run is working.
|
|
111
|
-
- **Answers.** `POST /api/manager/approve` `{ id, approved }`, `POST /api/manager/answer` `{ id, value }`,
|
|
112
|
-
`POST /api/manager/cancel`, `POST /api/manager/reset` (new conversation; the old session stays in history).
|
|
113
|
-
- **Events.** `GET /api/manager/stream?token=` is a server-sent-events stream (like `/api/activity/stream`)
|
|
114
|
-
carrying a reduced event shape: `assistant.delta`, `assistant.message`, `tool` (name + one-line summary),
|
|
115
|
-
`approval`, `question`, `state` (`idle` | `working` | `awaiting`), `error`, `graph.saved` `{ graphId }`.
|
|
116
|
-
A reconnecting client gets the conversation so far as one `snapshot` event.
|
|
117
|
-
- All routes use the existing bearer token check and require a signed-in account, like graph saves.
|
|
118
|
-
|
|
119
|
-
### Editor: `src/graph-ui/manager.js` + `manager.css` (new)
|
|
120
|
-
|
|
121
|
-
- **Button.** A **Graph Manager** button in the editor toolbar, shown whenever `state.graph` is set.
|
|
122
|
-
- **Tip.** After `newGraph()` (not after Duplicate or import), a small popover anchored to the button:
|
|
123
|
-
"Let Graph Manager build this graph with you." with a close button. Closing it, or opening the panel,
|
|
124
|
-
stores `andorra.graphManager.tipDismissed` in `localStorage`, so it shows once per browser profile. It
|
|
125
|
-
never covers the canvas's own first-run hints.
|
|
126
|
-
- **Panel.** A right-hand side panel (resizable, closable) that narrows the canvas instead of covering it.
|
|
127
|
-
Header: provider + model selects filled from `/api/provider-models`, defaulting to the last choice
|
|
128
|
-
(`localStorage`) or the graph's first agent node's model; a New chat button. Body: the transcript with
|
|
129
|
-
Markdown text, compact tool lines, approval cards (Approve / Deny) and question cards. Footer: a text box
|
|
130
|
-
with Send and Stop.
|
|
131
|
-
- **Model changes.** Changing the model before the first message just changes the start. Changing it
|
|
132
|
-
mid-chat applies from the next message (`run.setModel` when idle is not needed; the next `run.start`
|
|
133
|
-
carries the new pair).
|
|
134
|
-
- **Graph switches.** The panel follows the open graph: switching graphs offers "Start a new chat about
|
|
135
|
-
<name>?" and keeps the old conversation until the user agrees.
|
|
136
|
-
- **Applying the agent's work.** The panel records the canvas it sent with the latest message. On
|
|
137
|
-
`graph.saved` for the open graph id: if the canvas is unchanged since that message (or is still the
|
|
138
|
-
untouched starter, `state.untouched`), it opens the new revision directly; if the user edited the canvas
|
|
139
|
-
after sending, it shows a bar, "Graph Manager saved revision N. Load it?", and never discards edits
|
|
140
|
-
without that click. Because the agent saves under the open graph's id, a new graph turns into its first
|
|
141
|
-
saved revision in place.
|
|
142
|
-
|
|
143
|
-
### Desktop
|
|
144
|
-
|
|
145
|
-
No new desktop UI. The panel is inside the iframe. `GraphEditorView.tsx` only needs the iframe tall and wide
|
|
146
|
-
enough as it already is; the desktop engine is untouched because the chat has its own engine process.
|
|
147
|
-
|
|
148
|
-
## Decided by the user
|
|
149
|
-
|
|
150
|
-
- Desktop and browser both get the feature (in-editor panel).
|
|
151
|
-
- Approach A: the graph server runs a dedicated engine session.
|
|
152
|
-
- The agent receives the current canvas, including unsaved edits, with every message, and saves under the
|
|
153
|
-
open graph's id.
|
|
154
|
-
|
|
155
|
-
## Calls I made (correct any of these)
|
|
156
|
-
|
|
157
|
-
- Permissions are fixed at Ask for approval. Publishing, deleting and restoring a graph always stop for an
|
|
158
|
-
approval card (`DURABLE_ACTIONS` in `src/graph-tool.ts`); file edits are harmless because the workspace is
|
|
159
|
-
an empty dedicated folder.
|
|
160
|
-
- Chat sessions are ordinary saved sessions named `Graph Manager: <graph name>`, filed under the dedicated
|
|
161
|
-
workspace, so they never appear in a project's task list.
|
|
162
|
-
- One shared conversation per graph server, across all connected panels.
|
|
163
|
-
- The tip shows once per browser profile, not once per graph.
|
|
164
|
-
- One conversation at a time per editor; New chat starts a fresh session.
|
|
165
|
-
- The idle engine stops after 10 minutes without a connected panel.
|
|
166
|
-
|
|
167
|
-
## Left to the builder
|
|
168
|
-
|
|
169
|
-
- Event mapping from the engine's `run.event` stream to the reduced panel events.
|
|
170
|
-
- Exact layout and styling, following `studio.css` tokens in light and dark.
|
|
171
|
-
- Detecting `graph.saved` (from `graphs` tool results or the graph store's revision change).
|
|
172
|
-
- Tests in `test/` for the server routes (with a fake engine) and the tip/button logic, and the QA plan at
|
|
173
|
-
`tests/graph-manager-chat-test-plan.md`.
|
|
174
|
-
|
|
175
|
-
## Refinements made while planning
|
|
176
|
-
|
|
177
|
-
- The skill is loaded by the hidden Graph Manager graph's own node instruction (`andorra:graph-manager` by full
|
|
178
|
-
id) rather than a `/graph-manager` slash prefix: `resolveSkillInvocation` JSON-escapes everything after the
|
|
179
|
-
name into its arguments, which would mangle the canvas JSON, and the instruction cannot be shadowed by an
|
|
180
|
-
installed skill of the same name.
|
|
181
|
-
- The panel receives whole assistant messages (`agent.message`), not token deltas; the engine does not
|
|
182
|
-
stream partial text on this path.
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
# Jev pricing: Free credits and Premium fair use
|
|
2
|
-
|
|
3
|
-
Date: 2026-11-14 · Status: proposed
|
|
4
|
-
|
|
5
|
-
## Intent
|
|
6
|
-
|
|
7
|
-
Change how hosted Jev decisions are allowed per plan, and make the account surfaces say so:
|
|
8
|
-
|
|
9
|
-
- **Free**: 100 Jev calls per rolling 30 days (they come back as old calls age out).
|
|
10
|
-
- **Legacy and Paid**: unlimited, subject to fair use: at most 250 per UTC day and at most 2,500
|
|
11
|
-
per rolling 30 days.
|
|
12
|
-
- The website's account center reflects the new terms, shows an "odometer" of every Jev call the
|
|
13
|
-
account has made, and an estimate of tokens Jev saved.
|
|
14
|
-
- The app (desktop Settings → Account, Portal, and the CLI/TUI footer) stops showing "/ 1,000".
|
|
15
|
-
|
|
16
|
-
## Goals
|
|
17
|
-
|
|
18
|
-
- One enforcement mechanism for both plans: an optional per-UTC-day cap plus a rolling 30-day cap.
|
|
19
|
-
- Old clients (0.1.8 and earlier, already installed) keep working without a crash or a wrong lockout.
|
|
20
|
-
- The tokens-saved figure is labeled an estimate and traceable to the Performance page's data.
|
|
21
|
-
|
|
22
|
-
## Non-goals
|
|
23
|
-
|
|
24
|
-
- Purchasable credits, top-ups, Stripe billing changes.
|
|
25
|
-
- Deploying the infra stack or releasing the website (stop at merged PRs; the owner deploys).
|
|
26
|
-
- Changing who is on which plan (`premium_policy.membership_tier` is unchanged). Production runs
|
|
27
|
-
`PremiumPromotionEnabled=true` with no dates, so every account is Legacy today and the Free
|
|
28
|
-
path has no live users until the owner ends or dates the promotion at deploy time (owner's
|
|
29
|
-
choice; the template is not touched).
|
|
30
|
-
- Changing the shared `GLOBAL_DAILY_LIMIT` (10,000/day across all accounts) — unchanged.
|
|
31
|
-
|
|
32
|
-
## Anti-goals
|
|
33
|
-
|
|
34
|
-
- Presenting the Premium caps as an allowance ("12 / 250") in normal use: Premium reads as
|
|
35
|
-
unlimited with a fair-use note.
|
|
36
|
-
- Fabricating figures: usage the service did not report stays "—"/"Unavailable", as today.
|
|
37
|
-
|
|
38
|
-
## Approaches considered (rolling 30-day cap)
|
|
39
|
-
|
|
40
|
-
- **A. Rolling window over daily counters — chosen.** Keep per-user daily counters for 31+ days
|
|
41
|
-
(TTL raised from 2 days). Before reserving, read the last 30 daily counters (one
|
|
42
|
-
`BatchGetItem`, consistent reads) and refuse if `sum >= windowLimit`; then the existing
|
|
43
|
-
transaction reserves today's counter (conditioned on the daily cap) and bumps the lifetime
|
|
44
|
-
counter. True rolling as asked; ~30 extra reads per call (≈$7.50 per million calls on demand);
|
|
45
|
-
bursts can overshoot the 30-day cap by the number of concurrent in-flight calls, acceptable for
|
|
46
|
-
fair use.
|
|
47
|
-
- B. Fixed 30-day periods anchored at signup: exact and cheap, "Refills <date>", but not rolling —
|
|
48
|
-
a heavy user can use 2× the cap across a boundary. Rejected.
|
|
49
|
-
|
|
50
|
-
## Design
|
|
51
|
-
|
|
52
|
-
### Server (`infra/andorra-auth/proxy.py`, `template.json`)
|
|
53
|
-
|
|
54
|
-
Limits per plan, from environment (template defaults shown):
|
|
55
|
-
|
|
56
|
-
| Plan | Daily cap (UTC day) | 30-day cap |
|
|
57
|
-
| --- | --- | --- |
|
|
58
|
-
| free | none | `FREE_WINDOW_LIMIT=100` |
|
|
59
|
-
| legacy, paid | `PAID_DAILY_LIMIT=250` | `PAID_WINDOW_LIMIT=2500` |
|
|
60
|
-
|
|
61
|
-
`FREE_DAILY_LIMIT` is removed. Free has no separate daily cap (the window cap bounds it).
|
|
62
|
-
|
|
63
|
-
Reservation (`POST /v1/decisions`):
|
|
64
|
-
1. Read the user's daily counters for the 30 UTC days ending today (today and the 29 before).
|
|
65
|
-
2. If `sum >= windowLimit` → 429.
|
|
66
|
-
3. Transaction as today: today's counter `+1` conditioned on the daily cap (Free: no condition
|
|
67
|
-
besides the window check), global counter conditioned on `GLOBAL_DAILY_LIMIT`, lifetime `+1`.
|
|
68
|
-
Daily keys get a TTL of 32 days after their day.
|
|
69
|
-
4. 429 body keeps `error: "daily_limit_reached"` (old clients recognise it and back off) and adds
|
|
70
|
-
`limitScope: "user" | "window" | "global"` and `resetsAt`: for `user`/`global` the next UTC
|
|
71
|
-
midnight; for `window` the moment the oldest counted day leaves the window (the first day in
|
|
72
|
-
the window with a non-zero count, plus 30 days).
|
|
73
|
-
|
|
74
|
-
Display (`GET /v1/me`) adds, without removing existing fields:
|
|
75
|
-
- `fairUse: true` for legacy/paid, `false` for free.
|
|
76
|
-
- `windowDecisionLimit`, `windowDecisionUsed`, `windowDays: 30`, `windowDecisionResetsAt` (when
|
|
77
|
-
the next call returns; only when the window has usage).
|
|
78
|
-
- `dailyDecisionLimit` stays for compatibility: 250 for legacy/paid, and for free the window
|
|
79
|
-
limit (100), so an old client still sees a sane bound. `dailyDecisionUsed`,
|
|
80
|
-
`dailyDecisionResetsAt`, and `decisionsSinceRollout` (the odometer) are unchanged.
|
|
81
|
-
- `estimatedTokensSavedPerDecision` is **not** sent by the server; the estimate lives with the
|
|
82
|
-
Performance data on the website (see below).
|
|
83
|
-
|
|
84
|
-
Admin metrics (`infra/admin` in the website repo) read the quota table by key prefix; the longer
|
|
85
|
-
daily TTL only means more `user#<sub>#<day>` items stay around — verify the admin rollup filters
|
|
86
|
-
by day and is unaffected.
|
|
87
|
-
|
|
88
|
-
### App (this repo)
|
|
89
|
-
|
|
90
|
-
- `src/membership.ts`: parse and validate the new fields (non-negative safe integers, ISO dates);
|
|
91
|
-
an invalid field is dropped, not fatal.
|
|
92
|
-
- `src/account-presentation.ts` (footer + notice):
|
|
93
|
-
- Premium: `Jev 12 today · fair use` (no denominator). Notice text: "Unlimited Jev calls,
|
|
94
|
-
fair use: 250 per UTC day, 2,500 per 30 days."
|
|
95
|
-
- Free: `Jev 37/100 · 30d`. Notice: "100 Jev calls per 30 days."
|
|
96
|
-
- `src/decision/providers/AndorraDecisionProvider.ts` + `src/transcript.ts`: read `limitScope`;
|
|
97
|
-
`window` maps to a new reason `decision_window_limit_reached` shown as "30-day Jev limit
|
|
98
|
-
reached" (Free: "Free Jev calls used up for now"), with the return date when given. The fact
|
|
99
|
-
service gate treats it like the daily limit (stop asking until `resetsAt`).
|
|
100
|
-
- Desktop `settingsDisplay.decisionUsage` / `SettingsView` Quota / `PortalView` UsageRows:
|
|
101
|
-
- Premium: row "Jev calls today: 12" with sub-note "Unlimited · fair use". A meter appears only
|
|
102
|
-
when today's count ≥ 80% of the daily cap or the 30-day count ≥ 80% of the 30-day cap, and
|
|
103
|
-
then shows whichever is closer (e.g. "212 / 250 today").
|
|
104
|
-
- Free: meter "37 / 100 · last 30 days" with "more return <date>".
|
|
105
|
-
- "Since rollout" row renamed "All-time Jev calls" (the odometer figure).
|
|
106
|
-
- The app-server protocol (`src/app-server/protocol.ts`, `desktop/src/engine/protocol.ts`) and
|
|
107
|
-
`src/app-server.ts` pass the new fields through.
|
|
108
|
-
|
|
109
|
-
### Website (`Andorra-Code-Website`)
|
|
110
|
-
|
|
111
|
-
- `src/auth.ts` `Membership`: parse the new fields.
|
|
112
|
-
- `src/AccountCenter.tsx`:
|
|
113
|
-
- Plan descriptions: Free "100 JEV calls every 30 days"; Legacy/Paid "Unlimited JEV calls, fair
|
|
114
|
-
use: up to 250 a day and 2,500 per 30 days."
|
|
115
|
-
- Usage pane: an **odometer** — the all-time count rendered as rolling digit wheels (CSS
|
|
116
|
-
transform per digit, animates once on load; `prefers-reduced-motion` shows static digits),
|
|
117
|
-
labeled "JEV calls, all time".
|
|
118
|
-
- **Estimated tokens saved** tile: `all-time calls × TOKENS_SAVED_PER_JEV_CALL`, compact
|
|
119
|
-
formatted, with the note "Estimate from our benchmark runs" linking to `/performance`.
|
|
120
|
-
- Free: "Used in the last 30 days 37 of 100" + "More return <date>". Premium: "Today 12",
|
|
121
|
-
"Last 30 days 340", fair-use caps listed as rows, no allowance bar unless ≥ 80%.
|
|
122
|
-
- `src/performance.ts`: export `JEV_QUESTIONS` per benchmark for the `andorra-018-jev` row
|
|
123
|
-
(TB 2.1: 112, SWE-bench: 211 — the `jev_telemetry` "requested" totals in the 0.1.8 run
|
|
124
|
-
READMEs in `Andorra-Bench-archive-v018`) and
|
|
125
|
-
`TOKENS_SAVED_PER_JEV_CALL = (tokens(JEV off) − tokens(JEV on)) / JEV questions(JEV on)` over
|
|
126
|
-
TB 2.1 + SWE-bench, computed from the same constants the page uses (prompt + completion
|
|
127
|
-
tokens): (258,941,871 − 158,606,273) / 323 ≈ 310,637. **Owner's choice:** per question, not per
|
|
128
|
-
HTTP call. One hosted call carries one or more questions, so multiplying the odometer (hosted
|
|
129
|
-
calls) by a per-question figure underestimates — the conservative side. A unit test pins the
|
|
130
|
-
derivation.
|
|
131
|
-
- Odometer label: "JEV calls" with the small note "counted since the counter started" — the
|
|
132
|
-
lifetime counter began at rollout, so "all time" would overstate.
|
|
133
|
-
|
|
134
|
-
## Constraints
|
|
135
|
-
|
|
136
|
-
- The infra change is not live until the stack is deployed; the app and website must handle a
|
|
137
|
-
service that does not yet send the new fields (fall back to today's daily display).
|
|
138
|
-
- Work in worktrees; open ready-for-review PRs to `main` in both repos; Codex review loop per
|
|
139
|
-
`AGENTS.md`; QA test plan at `tests/jev-fair-use-pricing-test-plan.md`.
|
|
140
|
-
|
|
141
|
-
## Calls made by the designer (not decided by the owner)
|
|
142
|
-
|
|
143
|
-
- Free has no separate daily cap; the window cap covers it.
|
|
144
|
-
- 429 keeps the `daily_limit_reached` error code for old clients; scope is in `limitScope`.
|
|
145
|
-
- Premium meter appears only past 80% of a cap.
|
|
146
|
-
- Tokens-saved constant lives in the website's performance data, not the server.
|
|
147
|
-
- An old client (0.1.8) on an account locked by the 30-day cap sees a "daily quota reached" 429
|
|
148
|
-
while `/v1/me` still shows today's count under 250; accepted — it backs off correctly and the
|
|
149
|
-
new clients show the real reason. No figure is faked to make old clients read "exhausted".
|
|
150
|
-
- Existing Free accounts' last-30-days usage counts toward the 100 immediately (daily counters
|
|
151
|
-
older than 2 days have already expired, so in practice at most ~2 days of history counts).
|
|
152
|
-
|
|
153
|
-
## Left to the builder
|
|
154
|
-
|
|
155
|
-
- Exact copy and styling of the odometer and tiles, within the site's existing account styles.
|
|
156
|
-
- Test structure; reuse existing fakes in `test_proxy.py`, `membership.test.ts`, desktop tests.
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Deterministic efficiency evaluation of the opt-in JEV efficiency features.
|
|
3
|
-
//
|
|
4
|
-
// npm run build
|
|
5
|
-
// node scripts/jev-efficiency-eval.mjs [--out <file.json>] [--md <file.md>] [--workload <id>]
|
|
6
|
-
//
|
|
7
|
-
// Runs every workload in tests/jev-efficiency/workloads.mjs under the shipped baseline, under each
|
|
8
|
-
// feature alone, and under every feature together, against scripted models, tools and decision
|
|
9
|
-
// providers. It compares what the runtime actually sent — the number of model requests and the
|
|
10
|
-
// serialized size of each request — and what the runtime recorded in its own events, then checks
|
|
11
|
-
// the result against the acceptance criteria in tests/jev-efficiency/criteria.json, which were
|
|
12
|
-
// written before any candidate result existed. Feature-disabled runs are compared byte for byte
|
|
13
|
-
// with the baseline.
|
|
14
|
-
//
|
|
15
|
-
// What this is: a mechanism and opportunity evaluation with fixed responses. What it is not:
|
|
16
|
-
// evidence that a live model behaves the same with less context, a token measurement (scripted
|
|
17
|
-
// adapters report no usage, and characters are not tokens), or a cost figure (no price is known
|
|
18
|
-
// for a mock model). The report says so in its `measurement` block.
|
|
19
|
-
import assert from 'node:assert/strict';
|
|
20
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
21
|
-
import { dirname, join, resolve } from 'node:path';
|
|
22
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
23
|
-
import { performance } from 'node:perf_hooks';
|
|
24
|
-
|
|
25
|
-
const args = process.argv.slice(2);
|
|
26
|
-
const option = name => { const index = args.indexOf(name); return index >= 0 ? args[index + 1] : undefined; };
|
|
27
|
-
// `fileURLToPath` decodes the percent escapes a raw `URL.pathname` keeps, so a checkout path with
|
|
28
|
-
// spaces resolves to the directory that exists instead of its percent-encoded ghost.
|
|
29
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
30
|
-
const load = file => import(pathToFileURL(join(root, 'dist/src', file)).href);
|
|
31
|
-
const runtime = {
|
|
32
|
-
...(await load('hardened-runtime.js')),
|
|
33
|
-
...(await load('decision/DecisionManager.js')),
|
|
34
|
-
...(await load('agent-execution.js')),
|
|
35
|
-
};
|
|
36
|
-
const { workloads } = await import(pathToFileURL(join(root, 'tests/jev-efficiency/workloads.mjs')).href);
|
|
37
|
-
const criteria = JSON.parse(await readFile(join(root, 'tests/jev-efficiency/criteria.json'), 'utf8'));
|
|
38
|
-
const only = option('--workload');
|
|
39
|
-
|
|
40
|
-
const FEATURES = ['preparedContinuations', 'postflightOnlyWithCandidates', 'toolResultFiltering', 'contextSelection', 'catalogSelection', 'adaptiveRouting'];
|
|
41
|
-
const routingConfig = { enabled: true, maxEscalations: 1, tiers: { economy: { provider: 'local', model: 'small' }, balanced: { provider: 'local', model: 'medium' }, premium: { provider: 'cloud', model: 'large' } } };
|
|
42
|
-
const configFor = mode => mode === 'baseline' ? undefined
|
|
43
|
-
: mode === 'disabled' ? {}
|
|
44
|
-
: mode === 'all' ? Object.fromEntries(FEATURES.map(feature => [feature, feature === 'adaptiveRouting' ? routingConfig : true]))
|
|
45
|
-
: { [mode]: mode === 'adaptiveRouting' ? routingConfig : true };
|
|
46
|
-
|
|
47
|
-
/** Run one workload under one configuration and measure what the runtime sent and recorded. */
|
|
48
|
-
async function measure(workload, mode) {
|
|
49
|
-
const config = configFor(mode);
|
|
50
|
-
const requests = [];
|
|
51
|
-
const events = [];
|
|
52
|
-
const probe = {
|
|
53
|
-
adapter: (model, adapter) => ({ ...adapter, generate: async request => {
|
|
54
|
-
requests.push({ model, messages: structuredClone(request.messages), tools: request.tools.map(({ name, description, parameters }) => ({ name, description, parameters })) });
|
|
55
|
-
return adapter.generate(request);
|
|
56
|
-
} }),
|
|
57
|
-
onEvent: event => { events.push(event); },
|
|
58
|
-
};
|
|
59
|
-
const prepared = await workload.run(config, runtime);
|
|
60
|
-
const started = performance.now();
|
|
61
|
-
let result;
|
|
62
|
-
try { result = await prepared.execute(probe); } finally { await prepared.cleanup(); }
|
|
63
|
-
const wallMs = Math.round(performance.now() - started);
|
|
64
|
-
const count = type => events.filter(event => event.type === type).length;
|
|
65
|
-
const sum = (type, field) => events.filter(event => event.type === type).reduce((total, event) => total + (Number(event.data[field]) || 0), 0);
|
|
66
|
-
const serialized = requests.map(request => JSON.stringify({ messages: request.messages, tools: request.tools }));
|
|
67
|
-
return {
|
|
68
|
-
workload: workload.id, mode, config: config ?? null,
|
|
69
|
-
outcome: prepared.outcomeOf(result, requests), status: result.status, reason: result.reason ?? null,
|
|
70
|
-
modelRequests: requests.length,
|
|
71
|
-
requestsByModel: requests.reduce((acc, request) => ({ ...acc, [request.model]: (acc[request.model] ?? 0) + 1 }), {}),
|
|
72
|
-
totalRequestChars: serialized.reduce((total, text) => total + text.length, 0),
|
|
73
|
-
firstRequestToolSchemaChars: requests[0] ? JSON.stringify(requests[0].tools).length : 0,
|
|
74
|
-
toolResultChars: requests.reduce((total, request) => total + request.messages.filter(message => message.role === 'tool').reduce((inner, message) => inner + message.content.length, 0), 0),
|
|
75
|
-
jevRequests: count('decision.requested'),
|
|
76
|
-
jevQuestions: sum('decision.requested', 'questions') || events.filter(event => event.type === 'decision.requested').reduce((total, event) => total + (event.data.questions?.length ?? 0), 0),
|
|
77
|
-
jevCriticalPathMs: sum('efficiency.postflight.awaited', 'waitMs'),
|
|
78
|
-
postflightSkipped: count('efficiency.postflight.skipped'),
|
|
79
|
-
bypassedTurns: count('decision.turn_bypassed'),
|
|
80
|
-
preparedDeclared: count('efficiency.prepared.declared'),
|
|
81
|
-
preparationChars: sum('efficiency.prepared.declared', 'chars'),
|
|
82
|
-
preparedExecuted: count('efficiency.prepared.executed'),
|
|
83
|
-
preparedRejected: count('efficiency.prepared.rejected'),
|
|
84
|
-
filteredResults: count('efficiency.tool_result.filtered'),
|
|
85
|
-
filteredOriginalChars: sum('efficiency.tool_result.filtered', 'originalChars'),
|
|
86
|
-
filteredKeptChars: sum('efficiency.tool_result.filtered', 'keptChars'),
|
|
87
|
-
expansions: count('efficiency.tool_result.expanded'),
|
|
88
|
-
expandedChars: sum('efficiency.tool_result.expanded', 'chars'),
|
|
89
|
-
retrievalSkipped: count('efficiency.context.retrieval_skipped'),
|
|
90
|
-
contextCandidates: sum('efficiency.context.selected', 'candidates'),
|
|
91
|
-
contextSelected: sum('efficiency.context.selected', 'selected'),
|
|
92
|
-
contextOmitted: sum('efficiency.context.selected', 'omitted'),
|
|
93
|
-
contextDuplicates: count('efficiency.context.duplicate'),
|
|
94
|
-
catalogOmitted: sum('efficiency.catalog.selected', 'omitted'),
|
|
95
|
-
catalogRestorations: count('decision.tools_restored'),
|
|
96
|
-
skillCatalogDeduplicated: events.filter(event => event.type === 'efficiency.skills.catalog' && event.data.reason === 'duplicate').length,
|
|
97
|
-
routingDecisions: count('efficiency.routing.decided'),
|
|
98
|
-
routingApplied: events.filter(event => event.type === 'efficiency.routing.decided' && event.data.applied === true).length,
|
|
99
|
-
routingTiers: events.filter(event => event.type === 'efficiency.routing.decided').map(event => `${event.data.tier ?? 'baseline'}:${event.data.reason}`),
|
|
100
|
-
escalations: events.filter(event => event.type === 'agent.retry' && event.data.escalation === true).length,
|
|
101
|
-
economyRequests: requests.filter(request => request.model === 'small').length,
|
|
102
|
-
premiumRequests: requests.filter(request => request.model === 'large').length,
|
|
103
|
-
wallMs,
|
|
104
|
-
providerUsage: result.usage && (result.usage.inputTokens || result.usage.outputTokens) ? result.usage : 'unmeasured (scripted adapter reports no usage)',
|
|
105
|
-
cost: 'unavailable (no price is known for a mock model)',
|
|
106
|
-
...(prepared.extraOf ? prepared.extraOf(requests) : {}),
|
|
107
|
-
extra: result.extra ?? null,
|
|
108
|
-
serialized,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const metric = (row, key) => row[key];
|
|
113
|
-
function check(row, baseline, spec) {
|
|
114
|
-
const failures = [];
|
|
115
|
-
const compare = (key, rule) => {
|
|
116
|
-
const value = metric(row, key), base = metric(baseline, key);
|
|
117
|
-
if (rule.deltaFromBaseline !== undefined && value !== base + rule.deltaFromBaseline) failures.push(`${key}=${value}, expected baseline ${base} ${rule.deltaFromBaseline >= 0 ? '+' : ''}${rule.deltaFromBaseline}`);
|
|
118
|
-
if (rule.atMostBaseline && value > base) failures.push(`${key}=${value} exceeds baseline ${base}`);
|
|
119
|
-
if (rule.lessThanBaseline && !(value < base)) failures.push(`${key}=${value} is not below baseline ${base}`);
|
|
120
|
-
if (rule.ratioOfBaselineBelow !== undefined && !(value < base * rule.ratioOfBaselineBelow)) failures.push(`${key}=${value} is not below ${rule.ratioOfBaselineBelow} × baseline ${base}`);
|
|
121
|
-
if (rule.min !== undefined && value < rule.min) failures.push(`${key}=${value} is below ${rule.min}`);
|
|
122
|
-
if (rule.max !== undefined && value > rule.max) failures.push(`${key}=${value} is above ${rule.max}`);
|
|
123
|
-
};
|
|
124
|
-
for (const [key, rule] of Object.entries(spec)) {
|
|
125
|
-
if (['workload', 'mode', '$comment'].includes(key)) continue;
|
|
126
|
-
if (key === 'outcome') { if (row.outcome !== rule) failures.push(`outcome=${row.outcome}, expected ${rule}`); continue; }
|
|
127
|
-
if (key === 'outcomeMatchesBaseline') { if (rule && row.outcome !== baseline.outcome) failures.push(`outcome=${row.outcome}, baseline ${baseline.outcome}`); continue; }
|
|
128
|
-
if (key === 'outcomeNotWorseThanBaseline') { if (rule && row.outcome !== 'completed' && row.outcome !== baseline.outcome) failures.push(`outcome=${row.outcome}, baseline ${baseline.outcome}`); continue; }
|
|
129
|
-
if (['revision', 'history'].includes(key)) continue;
|
|
130
|
-
if (key === 'premiumOrBaselineForComplex') { if (rule && row.premiumRequests === 0 && (row.requestsByModel.medium ?? 0) === 0) failures.push('the complex task ran on neither premium nor baseline'); continue; }
|
|
131
|
-
compare(key, rule);
|
|
132
|
-
}
|
|
133
|
-
return failures;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const selected = workloads.filter(workload => !only || workload.id === only);
|
|
137
|
-
const rows = [];
|
|
138
|
-
const verdicts = [];
|
|
139
|
-
for (const workload of selected) {
|
|
140
|
-
const baseline = await measure(workload, 'baseline');
|
|
141
|
-
const disabled = await measure(workload, 'disabled');
|
|
142
|
-
rows.push(baseline, disabled);
|
|
143
|
-
// Feature-disabled must be the baseline byte for byte: same requests, same sizes, same outcome.
|
|
144
|
-
const identical = JSON.stringify(disabled.serialized) === JSON.stringify(baseline.serialized) && disabled.outcome === baseline.outcome;
|
|
145
|
-
verdicts.push({ workload: workload.id, mode: 'disabled', passed: identical, failures: identical ? [] : ['feature-disabled requests differ from the baseline'] });
|
|
146
|
-
for (const mode of [...FEATURES, 'all']) {
|
|
147
|
-
const row = await measure(workload, mode);
|
|
148
|
-
rows.push(row);
|
|
149
|
-
const specs = criteria.checks.filter(spec => (spec.workload === workload.id || spec.workload === '*') && spec.mode === mode);
|
|
150
|
-
const failures = specs.flatMap(spec => check(row, baseline, spec));
|
|
151
|
-
verdicts.push({ workload: workload.id, mode, applicable: specs.length > 0, passed: failures.length === 0, failures });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const columns = ['mode', 'outcome', 'modelRequests', 'totalRequestChars', 'firstRequestToolSchemaChars', 'toolResultChars', 'jevRequests', 'jevCriticalPathMs', 'bypassedTurns', 'preparedRejected', 'filteredResults', 'expansions', 'failureEvidenceVisible', 'contextOmitted', 'contextDuplicates', 'catalogOmitted', 'skillCatalogDeduplicated', 'routingApplied', 'escalations', 'wallMs'];
|
|
156
|
-
const lines = ['# JEV efficiency evaluation (deterministic replay)', '', `Baseline commit: ${process.env.JEV_EVAL_BASELINE ?? 'see PR'}. Measurement: serialized request characters and runtime events from scripted models; tokens and cost are unmeasured. Fixed-response replay evaluates the mechanism, not live model behavior.`, ''];
|
|
157
|
-
for (const workload of selected) {
|
|
158
|
-
lines.push(`## ${workload.id}`, '', workload.description, '', `| ${columns.join(' | ')} |`, `| ${columns.map(() => '---').join(' | ')} |`);
|
|
159
|
-
for (const row of rows.filter(item => item.workload === workload.id)) lines.push(`| ${columns.map(column => String(row[column] ?? '')).join(' | ')} |`);
|
|
160
|
-
lines.push('');
|
|
161
|
-
for (const verdict of verdicts.filter(item => item.workload === workload.id)) {
|
|
162
|
-
if (verdict.applicable === false) continue;
|
|
163
|
-
lines.push(`- ${verdict.mode}: ${verdict.passed ? 'pass' : 'FAIL'}${verdict.failures.length ? ` (${verdict.failures.join('; ')})` : ''}`);
|
|
164
|
-
}
|
|
165
|
-
lines.push('');
|
|
166
|
-
}
|
|
167
|
-
const failed = verdicts.filter(verdict => verdict.applicable !== false && !verdict.passed);
|
|
168
|
-
lines.push(`## Verdict`, '', failed.length ? `${failed.length} check(s) failed.` : 'Every acceptance criterion passed.', '');
|
|
169
|
-
const report = {
|
|
170
|
-
measurement: {
|
|
171
|
-
method: 'deterministic replay: scripted model responses, scripted tools, scripted decision provider',
|
|
172
|
-
sizes: 'serialized request characters (JSON of messages and tool schemas); not tokens and not billed usage',
|
|
173
|
-
tokens: 'unmeasured: scripted adapters report no provider usage',
|
|
174
|
-
cost: 'unavailable: no price is known for a mock model',
|
|
175
|
-
jevLatency: 'scripted provider answers immediately; critical-path waits reflect the runtime path only',
|
|
176
|
-
liveBehavior: 'not evaluated: a live model may behave differently with less context',
|
|
177
|
-
},
|
|
178
|
-
criteria, rows: rows.map(({ serialized, ...row }) => ({ ...row, requestChars: serialized.map(text => text.length) })), verdicts,
|
|
179
|
-
};
|
|
180
|
-
const out = option('--out') ?? join(root, 'tests/jev-efficiency/results/latest.json');
|
|
181
|
-
const md = option('--md') ?? join(root, 'tests/jev-efficiency/results/latest.md');
|
|
182
|
-
await mkdir(dirname(out), { recursive: true });
|
|
183
|
-
await writeFile(out, JSON.stringify(report, null, 2) + '\n');
|
|
184
|
-
await writeFile(md, lines.join('\n'));
|
|
185
|
-
process.stdout.write(lines.join('\n'));
|
|
186
|
-
process.stdout.write(`\nWritten: ${out}\n${md}\n`);
|
|
187
|
-
assert.equal(failed.length, 0, `${failed.length} acceptance check(s) failed`);
|