-
Notifications
You must be signed in to change notification settings - Fork 1
feat: HC-112 IR v2 — typed values, cascade trace, SHA-256 hashes #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2cac4be
feat: HC-112 IR v2 — typed values, cascade trace, SHA-256 hashes, con…
SoundBlaster 7c1b215
Merge branch 'feat/hc-112-substrate' into feat/hc-112-ir-v2
SoundBlaster ab3a5fc
docs: address #20 review — D4 reflects shipped SHA-256 wrapper, docum…
SoundBlaster 5f11f36
fix: harden IR JSON boundary — escape object keys, gate --ctx keys to…
SoundBlaster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://0al-spec.github.io/Hypercode/schema/hypercode-ir-v2.schema.json", | ||
| "title": "Hypercode IR v2", | ||
| "description": "Hypercode resolved-graph IR v2: typed values, cascade trace (winner + losers), per-node SHA-256 hashes, context echo, resolver metadata. Contracts field is empty until HC-111.", | ||
| "type": "object", | ||
| "required": ["version", "context", "resolver", "documentHash", "nodes"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "version": { | ||
| "type": "string", | ||
| "const": "hypercode.ir/v2" | ||
| }, | ||
| "context": { | ||
| "type": "object", | ||
| "description": "Echo of the --ctx flags supplied at resolution time.", | ||
| "additionalProperties": { "type": "string" } | ||
| }, | ||
| "resolver": { | ||
| "type": "object", | ||
| "required": ["name", "version"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "name": { "type": "string" }, | ||
| "version": { "type": "string" } | ||
| } | ||
| }, | ||
| "documentHash": { | ||
| "type": "string", | ||
| "description": "SHA-256 of newline-joined root-node hashes (document-level fingerprint).", | ||
| "pattern": "^[0-9a-f]{64}$" | ||
| }, | ||
| "nodes": { | ||
| "type": "array", | ||
| "items": { "$ref": "#/$defs/resolvedNode" } | ||
| } | ||
| }, | ||
| "$defs": { | ||
| "resolvedNode": { | ||
| "type": "object", | ||
| "required": ["type", "hash", "properties", "children"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "type": { "type": "string" }, | ||
| "class": { "type": "string" }, | ||
| "id": { "type": "string" }, | ||
| "hash": { | ||
| "type": "string", | ||
| "description": "SHA-256 of the node's stable content (type, class?, id?, resolved values, child hashes).", | ||
| "pattern": "^[0-9a-f]{64}$" | ||
| }, | ||
| "properties": { | ||
| "type": "object", | ||
| "additionalProperties": { "$ref": "#/$defs/resolvedProperty" } | ||
| }, | ||
| "children": { | ||
| "type": "array", | ||
| "items": { "$ref": "#/$defs/resolvedNode" } | ||
| } | ||
| } | ||
| }, | ||
| "resolvedProperty": { | ||
| "type": "object", | ||
| "required": ["value", "winner", "losers", "contracts"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "value": { | ||
| "description": "The winning resolved value (typed).", | ||
| "oneOf": [ | ||
| { "type": "string" }, | ||
| { "type": "integer" }, | ||
| { "type": "number" }, | ||
| { "type": "boolean" } | ||
| ] | ||
| }, | ||
| "winner": { "$ref": "#/$defs/matchEntry" }, | ||
| "losers": { | ||
| "type": "array", | ||
| "items": { "$ref": "#/$defs/matchEntry" } | ||
| }, | ||
| "contracts": { | ||
| "type": "array", | ||
| "description": "Accumulated selector contracts (HC-111). Empty until contracts are added to .hcs files.", | ||
| "items": { "$ref": "#/$defs/contractEntry" } | ||
| } | ||
| } | ||
| }, | ||
| "matchEntry": { | ||
| "type": "object", | ||
| "required": ["selector", "specificity", "order", "line", "value"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "selector": { "type": "string" }, | ||
| "specificity": { | ||
| "type": "array", | ||
| "description": "[ids, classes, types]", | ||
| "items": { "type": "integer" }, | ||
| "minItems": 3, | ||
| "maxItems": 3 | ||
| }, | ||
| "order": { "type": "integer" }, | ||
| "line": { "type": "integer" }, | ||
| "file": { "type": "string" }, | ||
| "value": { | ||
| "oneOf": [ | ||
| { "type": "string" }, | ||
| { "type": "integer" }, | ||
| { "type": "number" }, | ||
| { "type": "boolean" } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "contractEntry": { | ||
| "type": "object", | ||
| "required": ["selector", "type", "required"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "selector": { "type": "string" }, | ||
| "type": { "type": "string", "enum": ["string", "int", "float", "bool"] }, | ||
| "required": { "type": "boolean" }, | ||
| "min": { "type": "number" }, | ||
| "max": { "type": "number" } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import CryptoKit | ||
|
|
||
| // Thin wrapper around CryptoKit.SHA256 so the rest of the library uses a | ||
| // stable internal interface. CryptoKit is available on all supported targets | ||
| // (macOS 10.15+; this package requires macOS 13). | ||
|
|
||
| struct SHA256Digest { | ||
| let bytes: [UInt8] | ||
|
|
||
| var hexString: String { | ||
| bytes.map { String(format: "%02x", $0) }.joined() | ||
| } | ||
| } | ||
|
|
||
| enum SHA256 { | ||
| static func hash(_ input: [UInt8]) -> SHA256Digest { | ||
| let digest = CryptoKit.SHA256.hash(data: input) | ||
| return SHA256Digest(bytes: Array(digest)) | ||
| } | ||
|
|
||
| static func hash(utf8 string: String) -> SHA256Digest { | ||
| hash(Array(string.utf8)) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.