@basein/runner 0.2.11 → 0.3.0

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 (144) hide show
  1. package/README.md +540 -350
  2. package/dist/auth/client.d.ts +65 -3
  3. package/dist/auth/client.js +305 -53
  4. package/dist/bin/bir-hooks.d.ts +72 -31
  5. package/dist/bin/bir-hooks.js +176 -284
  6. package/dist/bin/bir-proxy.d.ts +17 -2
  7. package/dist/bin/bir-proxy.js +222 -28
  8. package/dist/bin/bir-scenario.d.ts +61 -10
  9. package/dist/bin/bir-scenario.js +704 -135
  10. package/dist/bin/bir.d.ts +14 -8
  11. package/dist/bin/bir.js +2937 -488
  12. package/dist/bin/investigate.js +41 -16
  13. package/dist/bin/scenario-edit.d.ts +43 -10
  14. package/dist/bin/scenario-edit.js +281 -80
  15. package/dist/bin/scenario-liveness.d.ts +194 -0
  16. package/dist/bin/scenario-liveness.js +459 -0
  17. package/dist/bin/scenario-stderr.d.ts +43 -0
  18. package/dist/bin/scenario-stderr.js +76 -0
  19. package/dist/bin/service-read.d.ts +88 -0
  20. package/dist/bin/service-read.js +128 -0
  21. package/dist/bin/setup.d.ts +19 -0
  22. package/dist/bin/setup.js +146 -20
  23. package/dist/config/adapters/claude-code.d.ts +92 -14
  24. package/dist/config/adapters/claude-code.js +291 -101
  25. package/dist/config/adapters/generic.d.ts +4 -1
  26. package/dist/config/adapters/generic.js +13 -14
  27. package/dist/config/generate.d.ts +392 -14
  28. package/dist/config/generate.js +666 -19
  29. package/dist/config/mcp-approval.d.ts +76 -0
  30. package/dist/config/mcp-approval.js +210 -0
  31. package/dist/config/node-path.d.ts +42 -0
  32. package/dist/config/node-path.js +102 -0
  33. package/dist/config/overrides.d.ts +62 -0
  34. package/dist/config/overrides.js +136 -0
  35. package/dist/config/resolve.d.ts +70 -8
  36. package/dist/config/resolve.js +186 -15
  37. package/dist/control/client.d.ts +22 -0
  38. package/dist/control/client.js +26 -7
  39. package/dist/control/correlation.d.ts +23 -5
  40. package/dist/control/correlation.js +0 -0
  41. package/dist/control/daemon.d.ts +400 -18
  42. package/dist/control/daemon.js +1105 -102
  43. package/dist/control/discovery.d.ts +77 -5
  44. package/dist/control/discovery.js +186 -11
  45. package/dist/control/ensure-hook.d.ts +61 -0
  46. package/dist/control/ensure-hook.js +160 -8
  47. package/dist/control/paths.d.ts +26 -0
  48. package/dist/control/paths.js +34 -0
  49. package/dist/control/pin-guard.d.ts +83 -0
  50. package/dist/control/pin-guard.js +534 -0
  51. package/dist/control/recorder-keeper.d.ts +229 -0
  52. package/dist/control/recorder-keeper.js +721 -0
  53. package/dist/control/recorder-main.d.ts +73 -0
  54. package/dist/control/recorder-main.js +778 -0
  55. package/dist/control/server.d.ts +707 -31
  56. package/dist/control/server.js +2803 -306
  57. package/dist/control/transcript.d.ts +21 -1
  58. package/dist/control/transcript.js +378 -112
  59. package/dist/index.d.ts +5 -1
  60. package/dist/index.js +5 -1
  61. package/dist/jsonrpc/framing.d.ts +76 -12
  62. package/dist/jsonrpc/framing.js +216 -59
  63. package/dist/proxy/intercept.d.ts +49 -5
  64. package/dist/proxy/intercept.js +188 -59
  65. package/dist/proxy/relay.d.ts +16 -0
  66. package/dist/proxy/relay.js +77 -5
  67. package/dist/proxy/revive.d.ts +122 -0
  68. package/dist/proxy/revive.js +251 -0
  69. package/dist/proxy/session.d.ts +222 -14
  70. package/dist/proxy/session.js +708 -99
  71. package/dist/record/housekeeping.d.ts +71 -0
  72. package/dist/record/housekeeping.js +417 -0
  73. package/dist/record/recorder.d.ts +51 -3
  74. package/dist/record/recorder.js +3 -0
  75. package/dist/record/redact.d.ts +103 -9
  76. package/dist/record/redact.js +659 -30
  77. package/dist/record/remote-recorder.d.ts +327 -32
  78. package/dist/record/remote-recorder.js +1517 -187
  79. package/dist/record/switchable-recorder.d.ts +126 -0
  80. package/dist/record/switchable-recorder.js +351 -0
  81. package/dist/record/truncate.d.ts +40 -1
  82. package/dist/record/truncate.js +111 -4
  83. package/dist/replay/bash-channel.d.ts +35 -0
  84. package/dist/replay/bash-channel.js +133 -0
  85. package/dist/replay/bundle.d.ts +10 -0
  86. package/dist/replay/bundle.js +10 -0
  87. package/dist/replay/controller.d.ts +371 -20
  88. package/dist/replay/controller.js +1185 -111
  89. package/dist/replay/derive.d.ts +1 -0
  90. package/dist/replay/derive.js +81 -24
  91. package/dist/replay/executor.d.ts +51 -16
  92. package/dist/replay/executor.js +114 -41
  93. package/dist/replay/handover.d.ts +54 -1
  94. package/dist/replay/handover.js +55 -5
  95. package/dist/replay/logic.d.ts +62 -10
  96. package/dist/replay/logic.js +140 -22
  97. package/dist/replay/plan.d.ts +201 -27
  98. package/dist/replay/plan.js +581 -141
  99. package/dist/replay/safety.d.ts +72 -0
  100. package/dist/replay/safety.js +303 -0
  101. package/dist/replay/source-run.d.ts +10 -0
  102. package/dist/replay/source-run.js +80 -35
  103. package/dist/replay/targets.d.ts +15 -1
  104. package/dist/replay/targets.js +62 -4
  105. package/dist/replay/tool-error.d.ts +15 -1
  106. package/dist/replay/tool-error.js +33 -1
  107. package/dist/replay/types.d.ts +7 -4
  108. package/dist/upstream/client.d.ts +56 -3
  109. package/dist/upstream/client.js +61 -4
  110. package/dist/upstream/headers.d.ts +43 -0
  111. package/dist/upstream/headers.js +90 -0
  112. package/dist/upstream/http-client.d.ts +213 -22
  113. package/dist/upstream/http-client.js +1034 -168
  114. package/dist/upstream/http-transport.d.ts +143 -0
  115. package/dist/upstream/http-transport.js +391 -0
  116. package/dist/upstream/lazy-client.d.ts +8 -0
  117. package/dist/upstream/lazy-client.js +29 -1
  118. package/dist/upstream/sse.d.ts +78 -0
  119. package/dist/upstream/sse.js +189 -0
  120. package/dist/upstream/stdio-client.d.ts +61 -1
  121. package/dist/upstream/stdio-client.js +356 -33
  122. package/dist/util/atomic-write.d.ts +29 -0
  123. package/dist/util/atomic-write.js +96 -0
  124. package/dist/util/journal.d.ts +15 -0
  125. package/dist/util/journal.js +48 -3
  126. package/dist/util/log.d.ts +10 -0
  127. package/dist/util/log.js +28 -1
  128. package/dist/util/off-switch.d.ts +46 -0
  129. package/dist/util/off-switch.js +91 -0
  130. package/dist/util/service-health.d.ts +133 -0
  131. package/dist/util/service-health.js +217 -0
  132. package/docs/BaseInstRunner.md +694 -621
  133. package/docs/calculatedReplay.md +1625 -1244
  134. package/docs/calculatedReplayGuide.md +1212 -879
  135. package/docs/installRun.md +1013 -772
  136. package/docs/loginWeb.md +627 -607
  137. package/docs/mcpmark.md +49 -16
  138. package/docs/my-first-sample.md +569 -545
  139. package/docs/quickstart.md +384 -271
  140. package/docs/t-bench.md +406 -394
  141. package/package.json +58 -57
  142. package/production.md +1371 -0
  143. package/scripts/install.ps1 +97 -6
  144. package/scripts/install.sh +104 -7
package/docs/mcpmark.md CHANGED
@@ -86,8 +86,8 @@ identical prompt the recorded values *are* the right ones.
86
86
  ```
87
87
  claude -p (cwd = the run dir)
88
88
  ├── mcp__bir__run_scenario ─────────────▶ bir-scenario ──┐ direct-mode delivery
89
- │ │ (§4.4 — needs a trusted
90
- └── mcp__postgres__* ──▶ bir-proxy ──▶ postgres-mcp │ workspace, or it is denied)
89
+ │ │ (§4.4 — allowed by bir's
90
+ └── mcp__postgres__* ──▶ bir-proxy ──▶ postgres-mcp │ hook once a plan is announced)
91
91
  │ (uvx, │
92
92
  reports every call mcp<2) │
93
93
  ▼ │ ▼
@@ -200,13 +200,17 @@ no `pipx`; both are equivalent here.
200
200
  Then:
201
201
 
202
202
  ```bash
203
- bir install --replay --local
203
+ bir install --replay --local --server postgres
204
204
  ```
205
205
 
206
- That wraps `postgres` with `bir-proxy`, installs the hooks into `.claude/settings.json`, and
207
- adds the `bir` scenario server that direct mode delivers through. Note the port it reports —
206
+ That writes a copy of `postgres` wrapped with `bir-proxy` into this project's local scope in
207
+ `~/.claude.json` (`.mcp.json` stays as written), installs the hooks into
208
+ `.claude/settings.local.json`, and adds the `bir` scenario server that direct mode delivers
209
+ through. `--server postgres` is needed in a fresh directory: Claude Code never asks about a
210
+ local-scope server, so `bir install` copies a `.mcp.json` server only once Claude Code has
211
+ approved it, and otherwise prints `postgres — left unwrapped`. Note the port it reports —
208
212
  it picks a free one (**53411** here, not the 53455 the incident demo uses), and the hook
209
- URLs in `settings.json` are written for that port.
213
+ URLs in `settings.local.json` are written for that port.
210
214
 
211
215
  ### 4.4 Deny the built-ins — this is the whole ballgame
212
216
 
@@ -235,13 +239,28 @@ Ignoring 2 permissions.allow entries from .claude/settings.json:
235
239
  this workspace has not been trusted.
236
240
  ```
237
241
 
238
- This is not cosmetic, and it fails *asymmetrically* in the worst possible way:
242
+ This is not cosmetic, and it fails *asymmetrically*. Which half breaks depends on the
243
+ runner version.
239
244
 
240
- - `mcp__postgres__*` keeps working, because bir's own `PreToolUse` answers
245
+ **Current runner.** bir no longer approves wrapped MCP calls, other than a step a steered
246
+ replay pins. For an ordinary
247
+ `mcp__postgres__*` call its `PreToolUse` answers with no permission decision and joins the
248
+ proxy's report by argument fingerprint ([server.ts](../src/control/server.ts),
249
+ `injectionDecision`). With the allow list gone those calls fall to Claude Code's own
250
+ permission check, and in `-p` mode they are denied, so trial 1 cannot even record the task.
251
+ `mcp__bir__run_scenario` is now the tool the hook allows itself, and only while this
252
+ session's direct plan has been announced (never in plan mode; your own deny and ask rules
253
+ still apply). If `run_scenario` is refused anyway, or the model's first call is some other
254
+ tool, the plan is retired without running a step (`replay.vetoed`, booked `not_steered`)
255
+ and the model does the task.
256
+
257
+ **0.2.12 and earlier, which §11 measured.** The other way round:
258
+
259
+ - `mcp__postgres__*` kept working, because bir's own `PreToolUse` answered
241
260
  `permissionDecision: "allow"` on the correlation path ([server.ts:859](../src/control/server.ts#L859)).
242
- - `mcp__bir__run_scenario` is the **one** tool bir deliberately passes through
243
- ([controller.ts:301](../src/replay/controller.ts#L301) → `{kind:"passthrough"}`), so it gets
244
- no hook-granted allow. With the allow list gone it is denied, and in `-p` mode a denial is
261
+ - `mcp__bir__run_scenario` was the **one** tool bir deliberately passed through
262
+ ([controller.ts:301](../src/replay/controller.ts#L301) → `{kind:"passthrough"}`), so it got
263
+ no hook-granted allow. With the allow list gone it was denied, and in `-p` mode a denial is
245
264
  final:
246
265
 
247
266
  ```
@@ -249,18 +268,22 @@ This is not cosmetic, and it fails *asymmetrically* in the worst possible way:
249
268
  but you haven't granted it yet.
250
269
  ```
251
270
 
252
- The plan then arms in `direct` mode, the model cannot reach the delivery tool, it does the
253
- task by hand, and the first manual call triggers divergence. Everything *looks* healthy —
254
- the task passes and the audit log says `mode=direct` — while the saving is negative. §11 is
271
+ The plan then armed in `direct` mode, the model could not reach the delivery tool, it did the
272
+ task by hand, and the first manual call triggered divergence. Everything *looked* healthy —
273
+ the task passed and the audit log said `mode=direct` — while the saving was negative. §11 is
255
274
  the measurement.
256
275
 
257
- Fix before the first replay, either by running `claude` interactively in the directory once
276
+ Fix before the first trial, either by running `claude` interactively in the directory once
258
277
  and accepting the trust dialog, or by setting in `~/.claude.json`:
259
278
 
260
279
  ```json
261
280
  "projects": { "C:/Users/Admin/Desktop/BasIns/mcpmark-hys": { "hasTrustDialogAccepted": true } }
262
281
  ```
263
282
 
283
+ Other ways to let the postgres calls through: `--allowedTools` on the `claude -p` line, or
284
+ `BIR_CORRELATION_DECISION=allow` in the shell that starts `bir-hooks` (§4.5), which brings
285
+ back 0.2.12's auto-approval of every wrapped call.
286
+
264
287
  ### 4.5 Start the control server, in this directory
265
288
 
266
289
  ```bash
@@ -505,6 +528,11 @@ roughly the cost of just doing the task, plus overhead.
505
528
  **The mechanism is sound; the delivery channel was blocked.** Nothing in these six trials
506
529
  measures direct mode's actual saving, because direct delivery never once happened.
507
530
 
531
+ *Superseded by later runners (§4.4):* bir now allows `run_scenario` itself for an announced
532
+ direct plan, and a direct plan whose delivery never happens is retired without running a
533
+ step. An untrusted directory no longer produces these `diverged` rows; it shows up as denied
534
+ `mcp__postgres__*` calls instead.
535
+
508
536
  ### Next
509
537
 
510
538
  1. Trust the workspace (§4.4). Without it every replay measures the divergence path.
@@ -744,9 +772,14 @@ and read every `sampleValue` as though it were about to be pasted into a shell.
744
772
  | §13 (2) | a step whose tool returned `Error:` logged `ok=true` | [tool-error.ts](../src/replay/tool-error.ts): an MCP result with `isError: true` is a `failed` step at stage `tool_call`, in direct, divergence and steer mode alike. Since 2026-09-19 a leading `Error` text with `isError: false` no longer counts: replay judges a step by the same rule the recorder does |
745
773
  | §13 (3) | `steered_full` booked a saving on errored steps | [controller.ts](../src/replay/controller.ts): any errored step forces `outcome: "failed"`, which books a baseline sample |
746
774
  | §12 header | bundle said "previously recorded" for live work | [bundle.ts](../src/replay/bundle.ts): a bundle with no recorded entry says the work was just executed and its side effects are in place |
747
- | §12 session | `/scenario/run` picked the first unfinished session | [server.ts](../src/control/server.ts): it picks the session whose plan is armed |
775
+ | §12 session | `/scenario/run` picked the first unfinished session | [server.ts](../src/control/server.ts): it runs only the plan of the session whose `run_scenario` call is waiting for it, matched on Claude Code's tool-use id where the host sends one; with none waiting it answers `no_plan` and runs nothing |
748
776
  | §12 latent | direct-mode bundle uncapped | [plan.ts](../src/replay/plan.ts): `runToCompletion` caps at `MAX_REPLAY_REASON` |
749
777
  | §6 | `steps_pinned` reported 1 for sequential pins | [controller.ts](../src/replay/controller.ts): counted as each pin threads, not from `pinned.size` |
750
778
 
751
779
  Not yet re-measured. Trials 9+ need a re-`calc` (the scenario must be regenerated for the
752
780
  validation pass to run) and then the §5 protocol again from a fresh baseline.
781
+
782
+ Before re-running on a runner newer than 0.2.12, read §4.3–4.4 again: `bir install` needs
783
+ `--server postgres` to wrap a fresh directory's server, and wrapped `mcp__postgres__*` calls
784
+ need the trusted `allow` list (or `--allowedTools`) even to record trial 1, while
785
+ `run_scenario` is now allowed by bir's hook.