feat: HC-112 IR v2 — typed values, cascade trace, SHA-256 hashes#20
Conversation
…text echo - `hypercode.ir/v2` schema: typed property values (int/bool/string), winner and losers with specificity/order/file/line, per-node SHA-256 Merkle hash (stable over resolved values; provenance changes do not alter the hash), document-level hash, context echo, resolver name+version - `hypercode emit --ir-version 1|2` (default v2; v1 kept for compat) - `Sources/Hypercode/Crypto/SHA256.swift` — CryptoKit wrapper (macOS 13+) - `Schema/hypercode-ir-v2.schema.json` — JSON Schema for v2 IR - `@contracts []` stub in every property (filled by HC-111) - Tests: SHA-256 NIST vectors (3), v2 JSON structure, hash determinism Co-Authored-By: Claude Haiku 4.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: 2cac4be769
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
Introduces Hypercode IR v2 emission (typed scalar values, cascade trace metadata, and SHA-256 hashing) while retaining IR v1 compatibility, and updates the CLI/tests/docs accordingly.
Changes:
- Add
TypedValueparsing/inference in.hcsparsing and propagate typed values through resolution (ResolvedValue+ cascade winner/losers). - Add IR v2 emitter output (context + resolver metadata + hashes) and a CLI
--ir-version 1|2flag (v2 default, v1 preserved). - Add CryptoKit-backed SHA-256 wrapper + NIST vector tests, plus IR v2 JSON Schema and planning docs.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/HypercodeTests/WhiteLabelTests.swift | Update assertions to typed resolved property values. |
| Tests/HypercodeTests/SHA256Tests.swift | Add SHA-256 NIST/FIPS test vectors. |
| Tests/HypercodeTests/HCSReaderTests.swift | Update .hcs reader tests for typed values. |
| Tests/HypercodeTests/EmitterTests.swift | Add IR v2 structure/hash determinism tests; label v1 tests as legacy. |
| Tests/HypercodeTests/CascadeResolverTests.swift | Update cascade tests for typed values and add losers retention test. |
| Sources/HypercodeCLI/main.swift | Add --ir-version flag; pass .hcs file paths for provenance; emit v1/v2. |
| Sources/Hypercode/HCS/Resolver.swift | Carry typed values + winner/losers trace; add provenance file support. |
| Sources/Hypercode/HCS/CascadeSheetReader.swift | Parse .hcs properties into TypedValue; plumb optional source file path. |
| Sources/Hypercode/HCS/CascadeSheet.swift | Introduce TypedValue + Match; add Rule.file. |
| Sources/Hypercode/Emit/Emitter.swift | Implement v2 IR emission and hashing; keep v1 legacy output. |
| Sources/Hypercode/Crypto/SHA256.swift | Add CryptoKit-backed SHA-256 wrapper and digest hex formatting. |
| Schema/hypercode-ir-v2.schema.json | Add JSON Schema for IR v2 validation. |
| DOCS/Workplan.md | Add HC-110..112 workplan and PR sequencing notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ent-hash text matches implementation (root order, unsorted) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… identifiers Review follow-up on #20: the v2 emitter interpolated object keys unescaped, so a context key containing a quote produced invalid JSON. Keys now go through the same escape() as string values, and the CLI rejects --ctx keys that are not Hypercode identifiers (the lexical class @Dimension names live in), so a typo fails loudly instead of silently matching no context block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
hypercode.ir/v2schema with typed property values (int/bool/string/float), winner + losers per property, per-node SHA-256 hash, document hash, context echo, resolver metadatahypercode emit --ir-version 1|2CLI flag (v2 is default; v1 kept for compatibility)SHA256wrapper (Sources/Hypercode/Crypto/SHA256.swift) — macOS 13+ target makes this zero-costSchema/hypercode-ir-v2.schema.json— JSON Schema for v2 IR validation@contracts: []stub in every property record (filled by HC-111 in PR-4)Node hash covers stable resolved content (type + class + id + resolved values + child hashes); changing which rule won without changing the value does not alter the hash.
Depends on PR-1 (
feat/hc-112-substrate) forTypedValue,Match, andlosers.Test plan
EmitterTests.testJSONEmit,testYAMLEmit)🤖 Generated with Claude Code