Skip to content

feat: HC-112 IR v2 — typed values, cascade trace, SHA-256 hashes#20

Merged
SoundBlaster merged 4 commits into
mainfrom
feat/hc-112-ir-v2
Jun 12, 2026
Merged

feat: HC-112 IR v2 — typed values, cascade trace, SHA-256 hashes#20
SoundBlaster merged 4 commits into
mainfrom
feat/hc-112-ir-v2

Conversation

@SoundBlaster

Copy link
Copy Markdown
Member

Summary

  • hypercode.ir/v2 schema with typed property values (int/bool/string/float), winner + losers per property, per-node SHA-256 hash, document hash, context echo, resolver metadata
  • hypercode emit --ir-version 1|2 CLI flag (v2 is default; v1 kept for compatibility)
  • CryptoKit-backed SHA256 wrapper (Sources/Hypercode/Crypto/SHA256.swift) — macOS 13+ target makes this zero-cost
  • Schema/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) for TypedValue, Match, and losers.

Test plan

  • 54 tests green
  • SHA-256 NIST vectors: empty string, "abc", 56-byte FIPS message
  • v2 JSON structure: version, context echo, resolver, documentHash, hash, winner/losers/contracts present
  • Hash determinism: same resolved content → identical hash; different value → different hash
  • v1 emitter output unchanged (EmitterTests.testJSONEmit, testYAMLEmit)

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings June 10, 2026 21:53

@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: 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".

Comment thread Sources/Hypercode/Emit/Emitter.swift
Comment thread Schema/hypercode-ir-v2.schema.json
Comment thread Sources/Hypercode/HCS/CascadeSheetReader.swift Outdated

Copilot AI 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.

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 TypedValue parsing/inference in .hcs parsing 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|2 flag (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.

Comment thread Sources/Hypercode/Emit/Emitter.swift
Comment thread Sources/Hypercode/Emit/Emitter.swift
Comment thread Sources/Hypercode/Emit/Emitter.swift
Comment thread DOCS/Workplan.md
Comment thread DOCS/Workplan.md Outdated
Comment thread DOCS/Workplan.md Outdated
Comment thread DOCS/Workplan.md Outdated
SoundBlaster and others added 2 commits June 12, 2026 00:45
…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>
@SoundBlaster SoundBlaster changed the base branch from main to feat/hc-112-substrate June 12, 2026 13:00
@SoundBlaster SoundBlaster changed the base branch from feat/hc-112-substrate to main June 12, 2026 13:52
@SoundBlaster SoundBlaster merged commit 6d0adb8 into main Jun 12, 2026
5 checks 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