feat: HC-124 — end-to-end AI codegen demo#24
Conversation
The RFC §9.7 pipeline made runnable: service spec → IR v2 → one generated Python module per .hc node → the same contracts validate the artifacts. - generated/*.py — Claude-generated modules embedding the source node's hash and per-value provenance comments; the service actually runs - check.py (stdlib only) — freshness by node-hash comparison (Merkle: a one-line port edit marks exactly api_server.py + the root wiring stale, logger/database untouched) and HC2104-gen conformance of embedded values against contracts[] echoed in the IR (catches a hand-edited port: 99999) - generate.sh — scoped regeneration of stale modules via `claude -p`, fed the IR subtree of each stale node; no stale module — no LLM call - CI runs check.py on every push, so the committed artifacts can never drift from the spec silently - workplan: HC-124 marked done; DOCS/Usage.md §5 links the runnable loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9d7a939bb
ℹ️ 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".
Review follow-up on #24: check.py imports the generated modules, which left compiled .pyc files in the tree. Bytecode is a build artifact — removed and ignored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a runnable end-to-end demo of the RFC §9.7 pipeline, showing spec-driven Python code generation per node (with embedded node hashes + provenance) and a CI-enforced verification loop that detects artifact drift and scopes regeneration.
Changes:
- Adds
Examples/codegen-demo/including committed generated Python modules,check.py(freshness + conformance checks), andgenerate.sh(regenerate only stale modules viaclaude -p). - Wires the demo into CI (runs
check.pyon every push/PR) and updates docs/workplan to reference the runnable loop. - Updates
.gitignoreto ignore Python bytecode caches.
Reviewed changes
Copilot reviewed 6 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| workplan.md | Marks HC-124 as completed with pointers to the runnable demo and CI checks. |
| Examples/codegen-demo/README.md | Documents how to run the demo, interpret freshness/conformance, and regenerate. |
| Examples/codegen-demo/generated/service.py | Generated “wiring” module for /Service demonstrating node-hash embedding. |
| Examples/codegen-demo/generated/logger.py | Generated module for /Service/Logger with provenance-annotated CONFIG. |
| Examples/codegen-demo/generated/database.py | Generated module for /Service/Database with provenance-annotated CONFIG. |
| Examples/codegen-demo/generated/api_server.py | Generated module for /Service/APIServer with provenance-annotated CONFIG. |
| Examples/codegen-demo/generate.sh | Script to regenerate only stale modules using Claude + IR subtree prompts. |
| Examples/codegen-demo/check.py | Stdlib-only validator that re-emits IR, checks freshness, and validates embedded values. |
| DOCS/Usage.md | Links to the runnable loop and positions hypercode diff as the future productized comparator. |
| .gitignore | Ignores __pycache__/ and *.pyc. |
| .github/workflows/swift.yml | Adds a CI step to run the codegen demo’s check.py. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ty paths, mktemp trap - check.py now enforces what its docstring promised: a key under a required contract must be present in CONFIG (dropping 'port' from a generated module is a violation), and a CONFIG key the spec doesn't resolve is flagged as drift. - Conformance respects module boundaries: a module owns its node's subtree up to the next generated module, so the wiring module's empty CONFIG stays valid. - Node paths use selector identity (type[.class][#id]) — the same addressing as 'hypercode diff' — so same-type siblings can't collide silently (ambiguity is a hard error); generate.sh resolves the same paths and cleans up its temp IR via an EXIT trap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
The RFC §9.7 pipeline, made runnable:
Examples/codegen-demo/shows the full loop spec → IR v2 → generated code → validated by the same contracts.generated/*.py— one Claude-generated Python module per.hcnode, each embedding its source node's hash and per-value provenance comments (# APIServer > Listen @ Examples/service.hcs:26). The service runs:python3 generated/service.py→('0.0.0.0', 8080).check.py(stdlib only) — two checks against a fresh IR emit:port: 8080 → 9090spec edit marks exactlyapi_server.py+ the root wiring stale (Merkle), leavinglogger.py/database.pyuntouched — regeneration is scoped, the review-compression story is demonstrable;HC2104-gen): values embedded in generated code are validated against thecontracts[]echoed in the IR — a hand-editedport: 99999in a "generated" file is caught with the governing selector named.generate.sh— regenerates only stale modules viaclaude -p, feeding each the IR subtree of its node. No stale module — no LLM call.check.pyon every push: committed artifacts cannot silently drift from the spec.workplan.md: HC-124 marked done;DOCS/Usage.md§5 links the runnable loop.Stacked on #23 (base:
feat/hc-111-value-validation).Test plan
check.py— all 4 modules FRESH, contracts conformant (runs in CI now)port: 99999) →error[HC2104-gen], exit 2python3 generated/service.pyruns and listens config is correct🤖 Generated with Claude Code