refactor(examples): collapse supervisor-loop's duplicate runners into one WORKER_BACKEND knob#429
Merged
Merged
Conversation
… 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
approved these changes
Jul 1, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From the examples DX audit backlog (#428). The
supervisor-loopexample'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 inbackend: 'bridge'vs'sandbox'.run-supervisor-mcp.ts— threw forWORKER_BACKEND=sandboxdespite its header headlining "flip WORKER_BACKEND=sandbox … with zero other changes."The collapse
shared.tsgains the two real swap seams:buildWorkerBackend()(returns the workerExecutorConfigfor bridge or sandbox — constructing theSandboxClientwhen sandbox) andresolveSupervisorBrain()(router brain if a key is present, else the scripted $0 brain).run-bridge.ts+run-sandbox.ts(198L, 2 files) → onerun.ts(67L).WORKER_BACKENDis the only knob.run-supervisor-mcp.tsdeletes its local throwingworkerBackend()and reusesbuildWorkerBackend()— so the "one knob, zero changes" claim is now true (sandbox works, no throw).run.ts.Net: ~130 fewer lines, one fewer file, and the thesis is now real — no doc/code lie.
Verification
tests/supervisor-loop-example.test.ts(importsshared.ts) still passes — the refactor kept its exports (demoCheck/demoGoal/expectedAnswer/scriptedSupervisorChat) intact.