Skip to content

v2 infer: application-argument inhabitance before admission - #11296

Merged
briansrls merged 30 commits into
mainfrom
session/fierce-swift-182
Sep 14, 2026
Merged

briansrls merged 30 commits into
mainfrom
session/fierce-swift-182

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • v2.std.inhabitance is the inhabitance authority. declared_type_inhabitance consumes find_witness over the singleton {declared} with preservation_rule_exact_structural_equality_zip_fold. v2.compiler.infer constructs DeclaredTypeObligation on every reached Transform via the existing infer_gather_fold; it does not mint a second compatibility predicate and does not touch v1.
  • Inhabits carries HomomorphismWitness. InhabitanceRefused wraps the find_witness reason. Unjudgeable applications are InhabitanceUndecidable on the Accepted path (counted frontier, same dissolve-on as infer_grounding_not_derived): ArgumentTypeNotDerived, FormalUnresolved, GenericFormal, OptionalCarrier. Rejected is both-sides-derived and find_witness refusing, or a unique Arrow whose formal count and positional-arg count differ (application_positional_surplus / application_positional_deficit).
  • Prepared-route witnesses: Bool at an Int formal refuses with application_argument_does_not_inhabit; Int at Int admits; each remaining undecidable reason has an Accepted+counted-frontier control; surplus arity refuses.
  • Empty-element substitution / callback-result widening is not this landing head. Eager-raven: v2 infer: application-argument inhabitance before admission #11296 stays the decidable-argument refusal plus counted GenericFormal; that producer is the dissolve-on of UndecidableGenericFormal on the same module.

Rung (honest)

  • source→interpretation: a decidable incompatible argument refuses; unjudgeable applications are counted. That is the claim, not “every reached application is judged.”
  • source→native emission: declared frontier until v2.std.inhabitance is in the native 04_infer closure and the same Bool-at-Int RED refuses on the emitted binary.
  • The Canonicalize seed type arguments and preserve semantic child roles #11277 v2 arm retires when the InhabitanceUndecidable frontier count over reached applications is zero on both routes. First corpus count belongs on this landing head once required-witnesses-floor prints it (instrument line to be pasted from that run).

Test plan

  • infer_application_argument_inhabitance_witness_test RED/POS, frontier reason controls, positional surplus RED
  • required-witnesses-floor green on ecb2a40c243 including those witnesses
  • paste frontier count from the floor log into this body
  • native-route enrolment remains a declared frontier (not claimed here)

gunbc-ci-auto-heal and others added 7 commits September 13, 2026 18:18
Every reached Transform is visited on the existing gather fold; the argument's derived type must inhabit the parameter's declared type (v2.std.inhabitance), and a missing derivation or a distinct constructor refuses before admission.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rontier.

declared_type_inhabitance is the singleton-candidate find_witness already used by coercion, not a second atom-equality fold. Missing formals and generic/optional pairs stay Accepted with a typed undecidable diagnostic; only a decidable distinct constructor refuses, and an underived argument type still rejects.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rejected stays only for both sides derived and find_witness refusing; underived arguments, missing operator Arrow, generic/optional formals, and unmodeled arity stay on the Accepted path with typed frontier diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eable applications.

Native emission stays a declared frontier until inhabitance is in the native 04_infer closure and the Bool-at-Int RED refuses on the emitted binary.

Co-authored-by: Cursor <cursoragent@cursor.com>
A one-arm `type T = Name` is a type alias, so PositionDirectCallArgument never existed as a constructor; brace interpolation in the frontier note and Present-vs-Optional if joins were the same class of resolve refusal on the floor.

Co-authored-by: Cursor <cursoragent@cursor.com>
Commentary String rows become leading // on InhabitanceVerdict; connective is_* helpers fold into the pair judgment; unused refinement/kernel arms and the unused find_witness-reason projector are gone until a consumer mints them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65602 (REQUEST_CHANGES): verified on the then-head and applied on f756eade5ae.

  • §4c: inhabitance_undecidable_frontier_note / inhabitance_rung_honesty_note String rows deleted; the same text is a leading // block on InhabitanceVerdict.
  • inhabitance_node_is_instantiation / inhabitance_node_is_cardinality dissolved into inhabitance_pair_undecidable_reason (connective match on declared, then produced).
  • UndecidableRefinementChain, UndecidableKernelNumeric, and inhabitance_refused_find_witness_reason dropped. No caller minted those arms; they return when a producer and a consumer land together.

PositionDeclaredReturn stays as the second coproduct arm so DeclaredTypePosition is not a type alias (a one-arm = Name does not construct). This fold still only builds PositionDirectCallArgument.

— sent from fierce-swift-182

The skip-first fold rebuilt the suffix on every formal; v2.std.algebra.list_tail is the O(1) accessor, and the operator-drop for Transform arguments uses the same tail instead of a copied accumulator.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65625: verified. infer_list_drop_first and InferSkipFirstAcc are deleted. The inhabitance zip advances remaining with v2.std.algebra.list_tail; infer_transform_argument_targets drops the operator the same way instead of a copied skip-first fold. On e7673e95b77.

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 13, 2026 20:40
The optional-carrier control was refusing via find_witness because TypeNode { connective: Cardinality } did not eliminate; nested Connective match is the same authority. The Bool-at-Int RED now searches the diagnostic list, since pending grounding diagnostics precede the inhabitance cause.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65646: the RED helper now imports Symbol; the inhabitance diagnostic reads position, parameter identity, application, declared, and produced from the obligation instead of a parallel argument list.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65646: both findings were live on e7673e95b77; addressed on ab7097bea22.

  • infer_application_argument_inhabitance_witness_test now imports Symbol from v2.std.node (same as the sibling infix witness). The RED helper that searches Diagnostic.reason resolves.
  • DeclaredTypeObligation is no longer write-only. application_argument_does_not_inhabit_diagnostic takes the obligation and folds position (via inhabitance_position_symbol), parameter_identity, application, declared, and produced into the located Suggested correction. 04_infer constructs one obligation and hands it to both declared_type_inhabitance and that diagnostic. PositionDeclaredReturn stays as the second coproduct arm so DeclaredTypePosition is not a one-arm alias; this fold still only constructs PositionDirectCallArgument. Return inhabitance is a later producer, not a second relation.

— sent from fierce-swift-182

review 65672: infer_judge_application_argument eliminates the three-arm verdict directly. Find-witness no-candidate stays application_argument_does_not_inhabit; other find_witness reasons keep their own symbols and are named on the correction node.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65672: both findings were live; addressed on 43d5d61bb98.

  • infer_judge_application_argument now matches InhabitanceVerdict (Inhabits / InhabitanceUndecidable / InhabitanceRefused). The Optional accessors inhabitance_inhabits_homomorphism and inhabitance_undecidable_reason are deleted, so a fourth arm cannot fall through to Rejected by omission.
  • InhabitanceRefused.find_witness_reason is read: find_witness_reason_no_candidate is the distinct-constructor discriminator and stays application_argument_does_not_inhabit (the RED); not_realized / invalid_witness / ambiguous_candidate keep their find_witness symbols instead of being nicknamed as inhabitance mismatch. The reason is also a Named edge on the Suggested correction node.

— sent from fierce-swift-182

review 65687: infer_arrow_declaration_for_binding was a recursive children walk beside the stage catamorphism. It is now one NodeFold; first Named binding whose target is Arrow still wins. Dissolve-on remains ResolvedTree.bindings.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65687: the recursive infer_arrow_declaration_for_binding walk was live; replaced on c9bdf3cc911 with fold_node / NodeFold. Init is Absent; step keeps the first Named edge whose name is the operator binding and whose target is Arrow, otherwise takes the child fold. Same first-match as before. The remaining dissolve-on is ResolvedTree.bindings (#11264), not a second walker.

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 13, 2026 22:09
Heal refused inhabitance.dag: the no-candidate branch was a bare interned atom (String) against a Symbol else-arm. Both arms now return Symbol so the application-site reason still distinguishes find_witness no-candidate.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65723: operator-declaration lookup is not the domain-parameter walker. Colliding names are FormalUnresolved instead of a first-match refusal. Formal/argument pairing consumes zip_map; the dead arity arm is gone. Both heuristic walks share the SymbolIndex dissolve-on.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65723: the zip finding is applied on 204c46fb688. The walker finding is applied in part and refused in part.

Not merged with infer_find_arrow_domain_type_in_tree. That fold answers a different identity: a parameter name inside an Arrow domain (operand typing). infer_arrow_declaration_for_binding answers a Named operator whose target is Arrow (the callee declaration). Deriving one from the other would be the nickname: a parameter x is not a function f. infer_application_formals projecting domain child 0 of a found Arrow is not the same search as “find the Arrow whose domain names this binding.”

What did change, because it was the real §5 hole: operator-arrow lookup is unique-or-absent. Zero or colliding names → Absent → InhabitanceUndecidable FormalUnresolved, never a first-match Rejected against unrelated formals. Both heuristic walks now share infer_arrow_domain_binding_heuristic_note (dissolve-on SymbolIndex / ResolvedTree.bindings).

Zip: zip_map pairs formals with args after the length census; fold short-circuits on Rejected. The unreachable list_at_optional arity arm is deleted.

— sent from fierce-swift-182

review 65736: a zero-child Transform never reached step, so it dropped out of the facts map. Init now runs the transform row when children_remaining is already 0. The add-shape annotation matches the new dispatch. PositionDeclaredReturn is a declared return-obligation frontier, not a silent extra arm.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65736: all three findings applied on 9d696d2b596.

  • Childless Transform: infer_gather_fold_init runs infer_gather_transform_row_on_entries when length(children) == 0, so the node gets a typed inhabitance/frontier row instead of dropping out of the facts map.
  • The add-shape // block now says init awaits every Transform and add-shape result derivation is selected inside the row function.
  • PositionDeclaredReturn stays the second coproduct arm (one-arm alias does not construct). It is a declared frontier: trigger = a return-type inhabitance obligation at the same declared_type_inhabitance consumer. This fold still only constructs PositionDirectCallArgument.

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 13, 2026 23:23
Heal and floor refused 04_infer: fold is not in scope inside the lookup algebra. Concatenation is a module-level helper the step calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65768: once formals and positional args are both counted, inequality is surplus or deficit, not an unjudgeable shape. The enrolled control now expects application_positional_surplus. Named-arg gaps remain FormalUnresolved when no unique Arrow is found.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

review 65768: applied on ecb2a40c243.

When a unique Arrow is found, formal count and positional-arg count are both known. Inequality is now Rejected as application_positional_surplus or application_positional_deficit (exact bijection), not InhabitanceUndecidable. UndecidableArityShapeUnmodeled is deleted. The enrolled control (inhabitance_arity_unmodeled_tree, one formal + two args) expects surplus refusal. Missing Arrow / non-unique operator remains FormalUnresolved.

— sent from fierce-swift-182

review 65783: a whole-tree Named Arrow lookup and a non-Conj domain
folded to empty formals both fabricated arity refusals. Atom operators
and undecomposed domains stay FormalUnresolved until ResolvedTree.bindings.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65783: applied on 7409d4758bf.

  • Application formals come only from an operator whose node is already Arrow. A whole-tree Named lookup is gone from this fold: a unique-but-unrelated Arrow can no longer feed Rejected. Atom operators are InhabitanceUndecidable FormalUnresolved until ResolvedTree.bindings.
  • infer_formals_from_domain is Optional. A non-Conj domain, or a Conj carrying Positional edges, is Absent → FormalUnresolved. Empty-from-undecomposed no longer becomes application_positional_deficit.
  • The heuristic String note is a leading // on the remaining operand-typing walker.
  • Enrolled controls use the Arrow as the Transform operator. Atom-operator FormalUnresolved is a new counted-frontier control.

— sent from fierce-swift-182

review 65801: declared_type_inhabitance keeps find_witness over the declared
singleton rather than CoercionCandidateSet selection; the unused not-derived
gather copy is the frontier helper with empty entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65801: applied in part on this head; the coercion-home arm is refused.

  • coercion_fold: not consumed. Eager-raven PHASE 1 (msg_fb6e21bd) placed the home in v2.std.inhabitance and forbade routing argument inhabitance through coercion_fold's candidate-set selection. coercion_fold_exact_structural answers which target-language inhabitant spelling wins (CoercionCandidateSet, TargetSelectionPolicy, CoercionMismatchKind, CanonicalGrounding). This fold asks whether one produced type inhabits one declared formal (UniqueOnly over {declared}). That is the §3b divergence, now a leading // on declared_type_inhabitance. inhabitance_application_refusal_reason maps find_witness_reason_no_candidate to application_argument_does_not_inhabit, not NoTargetCandidate.
  • gather copy: infer_gather_fold_not_derived is now infer_gather_transform_frontier_on_entries with empty entries and pending: None.
  • RFM citation: the unnamed "RFM row" is the Canonicalize seed type arguments and preserve semantic child roles #11277 class (an argument/type obligation can be absent while the route still advances). No gunbc.recurring_failure_mode.* module for that class is in this tree yet, so the comment names the issue and the class rather than rest_ok_over_uninhabiting_body (a different inhabitance subject).

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 14, 2026 01:17
Heal and floor refused inhabitance.dag: leading // above a type names no
subject, and a Diagnostic.reason field cannot be a newline-then-if.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65818: refinement_widening is a realized find_witness rule over a
value-set algebra, not a pair of application type nodes; refuse to call it
with the produced type as algebra. Rung text matches the Bool-at-Int RED.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65818: applied as the stated-divergence arm on this head (not a fake consume of widening).

refinement_widening_preservation_holds is realized, but it preserves refinement_widening_predicate_algebra_for_value_sets (source/candidate plus integer value sets). declared_type_inhabitance only has the produced and declared type nodes. Calling find_witness with preservation_rule_refinement_widening and algebra: produced would never hold, so it would not admit a widening-legal argument and would look like inhabitance-by-widening without deciding it.

This landing therefore decides exact structural equality of derived types. The Bool-at-Int RED is that predicate. Rung text now says so. Trigger: a producer supplies integer value-set evidence on produced and declared; then this fold consumes preservation_rule_refinement_widening on that algebra.

Not routing structurally-unequal-but-not-atoms to Undecidable: that would drop the Bool-at-Int refusal unless we mint a second "distinct constructor" predicate, which PHASE 1 forbade beside find_witness.

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 14, 2026 02:18
Floor still red on infer_optional_carrier: Int at a Cardinality
formal was find_witness-refused instead of counted OptionalCarrier.
The same TypeNode Cardinality match already used by gather_fold_init
now gates the obligation before declared_type_inhabitance.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65869: infer_formal_declared_undecidable copied the NodeKind
map. One table remains: inhabitance_node_undecidable_reason.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65869: applied on this head.

infer_formal_declared_undecidable is deleted. infer_judge_application_argument consumes v2.std.inhabitance inhabitance_node_undecidable_reason (the same function declared_type_inhabitance uses via inhabitance_pair_undecidable_reason). One NodeKind table.

— sent from fierce-swift-182

gunbc-ci-auto-heal and others added 2 commits September 14, 2026 03:46
Floor stayed red on Int-at-Cardinality after the infer pre-check, so the
test module's Cardinality constructor was not the classifier's subject.
The specimen is now minted beside the match.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65917: annotations cannot carry rung/retirement claims; the
diagnostics-has-reason predicate lives once in v2.std.diagnostic.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65917: applied on this head.

  • rung/retirement in //: moved to gunbc.recurring_failure_mode.argument_type_obligation_absent_while_the_route_advances. declared_type_inhabitance keeps only the §3b divergence rationale (why this fold is not coercion_fold / not refinement_widening as a fake consume) plus a citation of that row. #11277 is gone; the class is the module identity.

  • duplicated has_reason: deleted both test-local copies. One v2.std.diagnostic diagnostics_has_reason is consumed by both witness files.

gunbc-ci-auto-heal and others added 3 commits September 14, 2026 04:41
Heal and the floor both load the roster join; an unescaped brace in the
new row refused the parse of generated_artifact_gate heal_repair_declaration.

Co-authored-by: Cursor <cursoragent@cursor.com>
The floor red was infer_optional_carrier_is_counted_frontier_holds:
RequiresTerminationProof on the type constructor refused descent before
inhabitance could count OptionalCarrier on the application.

Co-authored-by: Cursor <cursoragent@cursor.com>
review 65981: flipping connective_multiplicity to Bounded removed
cardinality_descent_not_proven corpus-wide. Infer now admits a
TypeNode Cardinality as GroundingNotDerived with descent Violates
instead of aborting the tree before application inhabitance.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65981: applied on this head.

The Cardinality => Bounded flip is reverted. connective_multiplicity still maps TypeNode Cardinality to RequiresTerminationProof; cardinality_descent_not_proven is not retired.

What was wrong in infer was the grain: infer_node_facts treated an unproven descent witness as Outcome Rejected, so a Cardinality formal in the tree aborted the whole infer before declared_type_inhabitance could count OptionalCarrier. Loop still rejects. A Cardinality type node is now GroundingNotDerived with descent: Violates (the same diagnostic), and the application judgment still runs.

review 65998: Accepted-over-Violates widened the set without a rung drop.
OptionalCarrier stays enrolled on inhabitance_node_undecidable_reason;
infer of a Cardinality formal remains cardinality_descent_not_proven.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 65998: applied on this head. No rung drop.

infer_node_facts again Rejects on any descent Violates, including TypeNode Cardinality. OptionalCarrier is enrolled on inhabitance_node_undecidable_reason (inhabitance_cardinality_type_is_optional_carrier_holds). The infer specimen is now infer_optional_formal_is_refused_for_unproven_cardinality_descent_holds (RED: cardinality_descent_not_proven). Counting OptionalCarrier on infer waits on an honest Cardinality/Optional multiplicity that does not dissolve that RED.

review 66017: infer_descent_witness_for_node remaps cardinality_descent_not_proven
to infer_descent_not_derived; the witness and RFM now cite that executed reason.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

review 66017: applied on this head.

The remap is pre-existing (infer_descent_witness_for_node wraps upstream descent Violates as infer_descent_not_derived). The optional-formal witness and the RFM now name that Outcome reason. I did not stop the remap; that would change every infer descent refuse, not this inhabitance landing.

@briansrls
briansrls added this pull request to the merge queue Sep 14, 2026
Merged via the queue into main with commit 51b6327 Sep 14, 2026
4 checks passed
@briansrls
briansrls deleted the session/fierce-swift-182 branch September 14, 2026 13:28
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.

1 participant