feat(b1): loop/emit.py writer API + LangGraph recipe - #21
Conversation
…e time Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A runnable LangGraph graph whose terminal node ships proof-of-done through
loop.emit: do_work writes an artifact, verify re-reads it from disk, and
conclude records an evidence-backed Succeeded (or an honest FailedUnverifiable).
The emitted contract passes `loop doctor` independently of the graph.
- examples/langgraph-emit/{graph_example.py,README.md} — the runnable recipe
- docs/integrations/langgraph.md — the 10-line integration guide
- scripts/test_langgraph_recipe.py — end-to-end acceptance test, env-guarded on
langgraph (skips when absent, keeping the package zero-dependency)
- .github/workflows/ci.yml — a `recipe (langgraph)` job that installs LangGraph
and runs the recipe test
- CHANGELOG.md — Unreleased B1 entry
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 666d5d904a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| receipts = paths.loop_dir / "receipts" / "receipts.jsonl" | ||
| issues: list[dict] = [] | ||
| _validate_record(record, "receipt", receipts, _validation_mode(), issues) |
There was a problem hiding this comment.
Reject negative receipt costs without jsonschema
In the default zero-dependency install, _validation_mode() returns structural-fallback; that fallback only checks required/const fields for receipts and does not enforce the schema's non-negative tokens/cost_usd. Because this path trusts _validate_record() before writing, emit.append_receipt(..., cost_usd=-5) is accepted, loop doctor reports ok, and loop metrics sums the negative cost, corrupting cost-per-success. Add explicit stdlib checks for receipt numeric fields before writing.
Useful? React with 👍 / 👎.
PR2 (B1) of the adoption-slices plan (docs/superpowers/plans/2026-07-03-adoption-slices.md).
What
loop/emit.py— pure-stdlib writer API for foreign runtimes:open_contract,append_iteration,append_receipt,terminate,EmitError. Enforces the G1 evidence rule at write time: an evidence-free (or contradictory)Succeededterminal is refused before anything touches disk, andcriteria_metvalues must be booleans, so every artifact it writes passesloop doctorby construction. Writer only — no orchestration, no execution, no subprocesses; zero third-party runtime dependencies.examples/langgraph-emit/(runnable graph whose terminal node callsemit.terminate),docs/integrations/langgraph.md, and an env-guarded end-to-end test that runs the example and validates the emitted contract with an independentloop doctorsubprocess.recipe-langgraphjob (langgraph is a dev dependency of the example/CI job only; the canonical suite skips the recipe test without it).Review trail
Per-task reviews (spec + quality): both Approved. Whole-branch review: Ready to merge — Yes; its one recommended hardening (the
criteria_metbool guard) is folded in as666d5d9and re-review approved.Tests
uv run --with pytest --with pyyaml python -B -m pytest -q -p no:cacheprovider scripts): 234 passed / 8 skipped (baseline 220/7 at branch; +14 emit/recipe tests, +1 env-guarded skip).🤖 Generated with Claude Code
https://claude.ai/code/session_01As92NaD7jMDbnQTqXDzBVa