Repository navigation
T-30 — generated hollow-alias .dag checker (Node->Outcome fail-closed; substrate-native) #3359
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
Changes from 13 commits
188b924
ea88f72
8f3765e
d320570
0bc1b82
ed46a3b
c01b099
6e18dd4
bd60903
beaa52b
ef2780a
1c42962
3f3f47c
27f3e4d
168ff08
ed5bc02
3d6d2d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,151 @@ | ||
| // src/v4/std/fact_density.dag | ||
| // Scope: P2-staging substrate witness. | ||
| // Owns: SourceSpecReadFact | ||
| // Consumes: | ||
| // Status: drafted. | ||
| // Anchor: https://github.com/gunb-ai/gunbc/blob/main/INVARIANTS.md | ||
| // Scope: T-30 generated structural hollow-alias checker — a pure Node -> Outcome gate that fails closed on a malformed carrier or a carrier reading zero spec facts. | ||
| // Owns: SourceSpecReadFact, fact_density_kernel_ambient_string, fact_density_kernel_ambient_int, fact_density_kernel_ambient_bool, fact_density_kernel_ambient_char, fact_density_kernel_ambient_list, fact_density_kernel_ambient_map, symbol_is_kernel_ambient, fact_density_nat, classify_density, connective_spec_fact, carrier_is_hollow, fact_density_hollow_alias, fact_density_malformed_carrier, hollow_alias_diagnostic, malformed_carrier_diagnostic, hollow_alias_gate, module_no_hollow_alias. | ||
| // Consumes: std node, std diagnostic, std nat, std cardinality. | ||
| // Status: T-30 generated checker; P2-staging until operator-closure wires pipeline enforcement. | ||
| // Anchor: https://github.com/gunb-ai/gunbc/blob/main/src/v4/TASKS.md | ||
|
|
||
| module v4.std.fact_density | ||
|
|
||
|
|
||
| import v4.std.node { | ||
| Node, | ||
| Edge, | ||
| Connective, | ||
| Atom, | ||
| Conj, | ||
| Disj, | ||
| Arrow, | ||
| Cardinality, | ||
| Instantiation, | ||
| TypeNode, | ||
| ComputationNode, | ||
| Symbol, | ||
| node_well_formed | ||
| } | ||
| import v4.std.diagnostic { | ||
| Outcome, | ||
| Produced, | ||
| Rejected, | ||
| Diagnostic, | ||
| NodeLocus, | ||
| Unavailable, | ||
| UserInputBoundary | ||
| } | ||
| import v4.std.nat { Nat, Zero, Succ } | ||
| import v4.std.cardinality { NonZeroNat } | ||
This comment was marked as resolved.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This finding is a diff-only review artifact — The generated checker compiles clean: No code change needed for this thread. — sent from bold-bear-747 |
||
|
|
||
|
|
||
| data fact_density_kernel_ambient_string: Symbol = fact_density_kernel_ambient_string | ||
| data fact_density_kernel_ambient_int: Symbol = fact_density_kernel_ambient_int | ||
| data fact_density_kernel_ambient_bool: Symbol = fact_density_kernel_ambient_bool | ||
| data fact_density_kernel_ambient_char: Symbol = fact_density_kernel_ambient_char | ||
| data fact_density_kernel_ambient_list: Symbol = fact_density_kernel_ambient_list | ||
| data fact_density_kernel_ambient_map: Symbol = fact_density_kernel_ambient_map | ||
|
|
||
|
|
||
| fn symbol_is_kernel_ambient(s: Symbol) -> Bool { | ||
| s == fact_density_kernel_ambient_string || | ||
| s == fact_density_kernel_ambient_int || | ||
| s == fact_density_kernel_ambient_bool || | ||
| s == fact_density_kernel_ambient_char || | ||
| s == fact_density_kernel_ambient_list || | ||
| s == fact_density_kernel_ambient_map | ||
| } | ||
|
|
||
|
|
||
| // 🟢 coproduct dissolution — DECISIONS.md classification ledger: SourceSpecReadFact. | ||
| type SourceSpecReadFact | ||
| = NamedFieldFacts { density: NonZeroNat } | ||
| | KernelAmbientAtom { atom: Symbol } | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| | NoFact | ||
|
|
||
|
|
||
| fn fact_density_nat(children: List<Edge>) -> Nat { | ||
| fold(children, init: Zero, f: fn(acc, _) { | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| Succ { prev: acc } | ||
| }) | ||
| } | ||
|
|
||
|
|
||
| fn classify_density(facts: Nat) -> SourceSpecReadFact { | ||
| match facts { | ||
| Zero => NoFact | ||
| Succ { prev: p } => NamedFieldFacts { density: NonZeroNat { prev: p } } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fn connective_spec_fact(c: Connective, facts: Nat) -> SourceSpecReadFact { | ||
| match c { | ||
| Atom { identity: id } => | ||
| if symbol_is_kernel_ambient(s: id) { | ||
| KernelAmbientAtom { atom: id } | ||
| } else { | ||
| classify_density(facts: facts) | ||
| } | ||
| Conj => classify_density(facts: facts) | ||
| Disj => classify_density(facts: facts) | ||
| Arrow => classify_density(facts: facts) | ||
| Cardinality => classify_density(facts: facts) | ||
| Instantiation => classify_density(facts: facts) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fn carrier_is_hollow(carrier: Node) -> Bool { | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| match carrier.kind { | ||
| ComputationNode { behavior: _ } => false | ||
| TypeNode { connective: c } => | ||
| match connective_spec_fact(c: c, facts: fact_density_nat(children: carrier.children)) { | ||
| NoFact => true | ||
| NamedFieldFacts { density: _ } => false | ||
| KernelAmbientAtom { atom: _ } => false | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| data fact_density_hollow_alias: Symbol = fact_density_hollow_alias | ||
| data fact_density_malformed_carrier: Symbol = fact_density_malformed_carrier | ||
|
|
||
|
|
||
| fn hollow_alias_diagnostic(carrier: Node) -> Diagnostic { | ||
| Diagnostic { | ||
| reason: fact_density_hollow_alias, | ||
| at: NodeLocus { node: carrier }, | ||
| correction: Unavailable { reason: UserInputBoundary } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fn malformed_carrier_diagnostic(carrier: Node) -> Diagnostic { | ||
| Diagnostic { | ||
| reason: fact_density_malformed_carrier, | ||
| at: NodeLocus { node: carrier }, | ||
| correction: Unavailable { reason: UserInputBoundary } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fn hollow_alias_gate(carrier: Node) -> Outcome<Bool> { | ||
| if node_well_formed(n: carrier) { | ||
| if carrier_is_hollow(carrier: carrier) { | ||
| Rejected { diagnostic: hollow_alias_diagnostic(carrier: carrier) } | ||
| } else { | ||
| Produced { value: true } | ||
| } | ||
| } else { | ||
| Rejected { diagnostic: malformed_carrier_diagnostic(carrier: carrier) } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fn module_no_hollow_alias(declarations: List<Node>) -> Outcome<Bool> { | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| fold(declarations, init: Produced { value: true }, f: fn(acc, d) { | ||
| match acc { | ||
| Rejected { diagnostic: dg } => Rejected { diagnostic: dg } | ||
| Produced { value: _ } => hollow_alias_gate(carrier: d) | ||
| } | ||
| }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // src/v4/test/claim/manual/fact_density_anchor.dag | ||
| // Scope: T-30 v2-bootstrap compile anchor — exercises the generated hollow-alias gate on a hollow alias, a fact-bundle carrier, and a kernel-ambient atom. | ||
| // Owns: fact_density_anchor_int32_symbol, fact_density_anchor_width_field, fact_density_anchor_signedness_field, fact_density_anchor_hollow_alias, fact_density_anchor_fact_bundle, fact_density_anchor_kernel_ambient_bool, anchor_hollow_alias_rejected, anchor_fact_bundle_produced, anchor_kernel_ambient_bool_exempt. | ||
| // Consumes: std fact_density, std node, std diagnostic. | ||
| // Status: scaffold — compile-only until T-22; gate logic pinned in std/fact_density.dag. | ||
| // Anchor: https://github.com/gunb-ai/gunbc/blob/main/src/v4/TASKS.md | ||
|
|
||
| module v4.test.claim.manual.fact_density_anchor | ||
|
|
||
|
|
||
| import v4.std.fact_density { | ||
| hollow_alias_gate, | ||
| fact_density_kernel_ambient_bool | ||
| } | ||
| import v4.std.node { | ||
| Node, | ||
| TypeNode, | ||
| Atom, | ||
| Conj, | ||
| Edge, | ||
| Named, | ||
| Symbol | ||
| } | ||
| import v4.std.diagnostic { Outcome } | ||
|
|
||
|
|
||
| data fact_density_anchor_int32_symbol: Symbol = fact_density_anchor_int32_symbol | ||
|
|
||
| data fact_density_anchor_hollow_alias: Node = Node { | ||
| kind: TypeNode { connective: Atom { identity: fact_density_anchor_int32_symbol } }, | ||
| children: [] | ||
| } | ||
|
|
||
|
|
||
| data fact_density_anchor_width_field: Symbol = fact_density_anchor_width_field | ||
| data fact_density_anchor_signedness_field: Symbol = fact_density_anchor_signedness_field | ||
|
|
||
| data fact_density_anchor_fact_bundle: Node = Node { | ||
| kind: TypeNode { connective: Conj }, | ||
| children: [ | ||
| Edge { | ||
| label: Named { name: fact_density_anchor_width_field }, | ||
| target: fact_density_anchor_hollow_alias | ||
| }, | ||
| Edge { | ||
| label: Named { name: fact_density_anchor_signedness_field }, | ||
| target: fact_density_anchor_hollow_alias | ||
| } | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| data fact_density_anchor_kernel_ambient_bool: Node = Node { | ||
| kind: TypeNode { connective: Atom { identity: fact_density_kernel_ambient_bool } }, | ||
| children: [] | ||
| } | ||
|
|
||
|
|
||
| fn anchor_hollow_alias_rejected() -> Outcome<Bool> { | ||
| hollow_alias_gate(carrier: fact_density_anchor_hollow_alias) | ||
| } | ||
|
|
||
|
|
||
| fn anchor_fact_bundle_produced() -> Outcome<Bool> { | ||
| hollow_alias_gate(carrier: fact_density_anchor_fact_bundle) | ||
| } | ||
|
|
||
|
|
||
| fn anchor_kernel_ambient_bool_exempt() -> Outcome<Bool> { | ||
| hollow_alias_gate(carrier: fact_density_anchor_kernel_ambient_bool) | ||
| } |
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.