Skip to content

docs(examples): tighten the good/great examples — simpler, zero capability lost#377

Merged
drewstone merged 1 commit into
mainfrom
docs/examples-tighten
Jun 24, 2026
Merged

docs(examples): tighten the good/great examples — simpler, zero capability lost#377
drewstone merged 1 commit into
mainfrom
docs/examples-tighten

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

Tightens the GOOD/GREAT examples a prior three-persona review flagged as marginal-but-left-alone. Every change makes the example simpler / clearer / more reusable while keeping exactly what it does and teaches — fixtures are extracted (not deleted), concepts de-duped (not dropped), an offline mode added (not removed). Verified each touched example still typechecks, runs, and keeps its output/teaching.

What was tightened (per example)

  1. driver-loop — extracted the ~70-line worker/adapter/validator fixture to scripted-worker.ts so the driver (the subject) leads. The fold demo + the THE FOLD, PART 1/2 anchors are unchanged. Subject file 211 → 146 lines (+81-line sibling). Output identical.
  2. researcher-loop — extracted the ~100-line hand-written fixture to synthetic-researcher.ts so the runLoop + inline-fanout wiring leads. The namespace-leak hard-fail demo is intact (the leak candidate is still pruned, the in-namespace candidate wins). Subject file 201 → 78 lines (+147-line sibling). Output identical.
  3. recursive-supervisor — extracted the inline executor-registry plumbing + as-casts to inline-executor.ts so the scope.spawn conserved-budget lesson leads. Part 1 (raw scope.spawn), Part 2 (fanout combinator), and the rejected-third-spawn budget-exhausted demo all kept. Subject file 205 → 131 lines (+94-line sibling). Output identical.
  4. strategy-suiteADDED an offline mode: an in-process mock OpenAI-compatible router (mock-router.ts) gated on the absence of TANGLE_API_KEY. The whole comparison now runs end-to-end with zero credentials, driving the REAL runBenchmark machinery (Supervisor, conserved budget pool, every strategy, the env's own check) against localhost. The live Tangle router stays the drop-in upgrade. Capability added, none lost.
  5. chat-handler — the hand-rolled NDJSON drain stays (agent-runtime exports no decoder — checked), but a note now marks it illustrative and points at handleChatTurn as the framing owner so consumers don't think they must re-implement it. Lifecycle envelope demo unchanged.
  6. intelligence-recommend — now imports the shared scaffolding (DemoScenario / scenarios / agent / judge / scriptedWinner / profile) from improve.ts instead of duplicating ~50 lines, so it reads as "improve, but the findings come from a recorded trace" — its actual new idea (recordTrace → findings → improve) is all that's left. improve.ts's main() is guarded with an entry-check so the import doesn't double-run. 134 → 88 lines. Both outputs identical.
  7. stream-backends — the inline SandboxEvent is now the real exported union from @tangle-network/sandbox (a status the SDK adds is a compile error here, not a silent miss). The OpenAI-compatible backend now defaults to the real OpenAI endpoint so the OPENAI_* env names are honest, with a note that you can point it at the Tangle router. All three transports kept.
  8. sanitized-telemetry-streaming — collapsed the near-duplicate safe/verbose halves into one drain(label, collector) helper. Both demonstrated states are kept: default-redaction (PII/args/result/uri stripped) and opt-in verbose (those fields exposed). The task.intent PII footgun note stays.
  9. runtime-run — dropped the cosmetic task.metadata workspaceId/threadId duplication of the explicit startRuntimeRun args (these never flowed into the row's typed columns — verified in src/runtime-run.ts). Persisted row identical.

Skipped (no no-capability-loss simplification available)

  • supervisor-loop / mcp-delegation / fleet-delegation / agents-of-all-shapes — left as-is per the brief. Their review flags were already addressed, or the "fix" would ADD ceremony (e.g. a 40-member fake SandboxInstance helper). No change made deliberately.
  • chat-handler decoder swap — agent-runtime exports the NDJSON producer/framing side (handleChatTurn), not a consumer-side decoder, so there is nothing to import; took the lighter "add a note" path the brief allows.

Verification

  • pnpm run build, pnpm run typecheck (src + typecheck:examples), pnpm run lint, pnpm run docs:check — all green (docs freshness: no drift; 0 errors).
  • Ran every materially-changed example offline; each keeps its exact output/teaching.
  • strategy-suite confirmed to run end-to-end with NO creds (clean exit, mock server closes via finally).
  • Merges cleanly into origin/main (git merge-tree).

…ility lost

- driver-loop: extract the worker/adapter/validator fixture to scripted-worker.ts so the driver (the subject) leads; keep the fold demo + THE FOLD anchors
- researcher-loop: extract the hand-written fixture to synthetic-researcher.ts so the runLoop + inline-fanout wiring leads; keep the namespace-leak hard-fail
- recursive-supervisor: extract the executor-registry plumbing to inline-executor.ts so the scope.spawn lesson leads; keep Part 1 + Part 2 + the budget-exhausted demo
- strategy-suite: add an offline mode — an in-process mock OpenAI-compatible router (mock-router.ts) gated on the absence of TANGLE_API_KEY; live router stays the upgrade
- chat-handler: note the NDJSON drain is illustrative (no decoder is exported); point at handleChatTurn as the framing owner
- intelligence-recommend: import the shared scaffolding from improve.ts (de-dup ~50 lines); guard improve.ts main() so import does not double-run
- stream-backends: import the real SandboxEvent union; default the OpenAI-compatible backend to the real OpenAI endpoint so OPENAI_* names are honest
- sanitized-telemetry-streaming: collapse the near-duplicate safe/verbose halves into one drain helper, both demonstrated states kept
- runtime-run: drop the cosmetic task.metadata workspaceId/threadId duplication of the explicit args

@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 PR — 7f19b4b4

Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-24T15:35:59Z

@drewstone drewstone merged commit b6ac445 into main Jun 24, 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