Skip to content

feat(b1): loop/emit.py writer API + LangGraph recipe - #21

Merged
SollanSystems merged 3 commits into
mainfrom
feat/b1-emit-api
Jul 4, 2026
Merged

SollanSystems merged 3 commits into
mainfrom
feat/b1-emit-api

Conversation

@SollanSystems

Copy link
Copy Markdown
Owner

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) Succeeded terminal is refused before anything touches disk, and criteria_met values must be booleans, so every artifact it writes passes loop doctor by construction. Writer only — no orchestration, no execution, no subprocesses; zero third-party runtime dependencies.
  • LangGraph recipeexamples/langgraph-emit/ (runnable graph whose terminal node calls emit.terminate), docs/integrations/langgraph.md, and an env-guarded end-to-end test that runs the example and validates the emitted contract with an independent loop doctor subprocess.
  • CI — new recipe-langgraph job (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_met bool guard) is folded in as 666d5d9 and re-review approved.

Tests

  • With langgraph: recipe + emit → 14 passed.
  • Canonical suite (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

SollanSystems and others added 3 commits July 4, 2026 12:21
…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>
Copilot AI review requested due to automatic review settings July 4, 2026 16:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@SollanSystems
SollanSystems merged commit c377f0f into main Jul 4, 2026
5 checks passed
@SollanSystems
SollanSystems deleted the feat/b1-emit-api branch July 4, 2026 16:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread loop/emit.py
}
receipts = paths.loop_dir / "receipts" / "receipts.jsonl"
issues: list[dict] = []
_validate_record(record, "receipt", receipts, _validation_mode(), issues)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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