Skip to content

refactor(examples): collapse supervisor-loop's duplicate runners into one WORKER_BACKEND knob#429

Merged
drewstone merged 1 commit into
mainfrom
chore/examples-backlog
Jul 1, 2026
Merged

refactor(examples): collapse supervisor-loop's duplicate runners into one WORKER_BACKEND knob#429
drewstone merged 1 commit into
mainfrom
chore/examples-backlog

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

From the examples DX audit backlog (#428). The supervisor-loop example's own thesis is "the worker backend is the ONLY knob" — but it shipped three runners contradicting it:

  • run-bridge.ts + run-sandbox.ts — ~80% duplicate scaffolding differing only in backend: 'bridge' vs 'sandbox'.
  • run-supervisor-mcp.tsthrew for WORKER_BACKEND=sandbox despite its header headlining "flip WORKER_BACKEND=sandbox … with zero other changes."

The collapse

  • shared.ts gains the two real swap seams: buildWorkerBackend() (returns the worker ExecutorConfig for bridge or sandbox — constructing the SandboxClient when sandbox) and resolveSupervisorBrain() (router brain if a key is present, else the scripted $0 brain).
  • run-bridge.ts + run-sandbox.ts (198L, 2 files) → one run.ts (67L). WORKER_BACKEND is the only knob.
  • run-supervisor-mcp.ts deletes its local throwing workerBackend() and reuses buildWorkerBackend() — so the "one knob, zero changes" claim is now true (sandbox works, no throw).
  • READMEs (example + catalog) updated to the single run.ts.

Net: ~130 fewer lines, one fewer file, and the thesis is now real — no doc/code lie.

Verification

  • examples typecheck 0; lint clean (359 files).
  • The offline tests/supervisor-loop-example.test.ts (imports shared.ts) still passes — the refactor kept its exports (demoCheck/demoGoal/expectedAnswer/scriptedSupervisorChat) intact.

… one WORKER_BACKEND knob

The example's own thesis is 'the worker backend is the ONLY knob' — but it had THREE runners: run-bridge.ts
+ run-sandbox.ts (~80% duplicate scaffolding differing only in backend: 'bridge' vs 'sandbox'), and
run-supervisor-mcp.ts which THREW for sandbox despite headlining 'flip WORKER_BACKEND=sandbox, zero changes'.

- shared.ts gains buildWorkerBackend() (returns the ExecutorConfig for bridge OR sandbox, constructing the
  SandboxClient when sandbox) + resolveSupervisorBrain() (router-if-key else scripted). The two swap seams.
- run-bridge.ts + run-sandbox.ts (198L, 2 files) → one run.ts (67L). WORKER_BACKEND is the only knob.
- run-supervisor-mcp.ts: deletes its local throwing workerBackend(), reuses buildWorkerBackend() — so the
  'one knob' claim is now TRUE (sandbox works, no throw).
- READMEs (example + catalog) updated to the single run.ts.

Net: ~130 fewer lines, one fewer file, the thesis is now real. Verified: examples typecheck 0; lint clean;
the offline supervisor-loop-example.test.ts (which imports shared.ts) still passes.

@tangletools tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved drewstone PR — 32d40ff5

This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: drewstone_author · 2026-07-01T02:38:17Z

@drewstone drewstone merged commit ca303bb into main Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants