Skip to content

Type undeclared lambda actuals from preceding application formals (N7 token_stream) - #13623

Closed
gunbai-bot[bot] wants to merge 28 commits into
n7/payload-binder-derived-factfrom
n7/token-stream-lambda-expected-type
Closed

gunbai-bot[bot] wants to merge 28 commits into
n7/payload-binder-derived-factfrom
n7/token-stream-lambda-expected-type

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Test plan

Made with Cursor

gunbc-ci-auto-heal and others added 3 commits October 9, 2026 08:23
Gather prefix of infer_judge_formal_args onto InferFrame.binder_types so fn(n) after a typed actual is Int; f-before-o leaves n underived and does not mint T.

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

infer_gather_extend_application_instances extends InferGatherFoldAcc.application_instances once per actual; the child frame and row-time infer_judge_formal_args read that prefix.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve keys every Arrow domain binder at the Arrow, so mapping two formals onto one site would type both as the first. The L-to-R red now uses a polymorphic callee so T is unfixed when the lambda precedes the instantiating actual.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78274: both findings held on 733533e.

  1. infer_lambda_domain_binder_types now admits binder rows only when the domain has exactly one binder (n == 1). Resolve still sites every Arrow domain binder at the Arrow, and infer_payload_binder_derived_type takes the first site match — mapping fn(a, b) onto fn(Int, String) -> … would have typed both as Int. Multi-parameter undeclared lambdas stay untyped until resolve gives distinct sites.

  2. lef_lambda_then_value_src / lef_value_then_lambda_src are now polymorphic (before<T> / after<T>). The red is T unfixed when the lambda precedes the instantiating actual, not a monomorphic Int formal with an empty prefix.

Head 8f1821d.

gunbc-ci-auto-heal and others added 2 commits October 9, 2026 08:35
Matching Cons on Node.children left the head as a type variable, so callee.target refused at resolve (the lambda-expected remasure).

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

Node equality sent two edges that share a target to the first formal; an Absent lookup previously kept the prefix with no diagnostic. The RFM no longer claims a structural rung the lef claims have not executed.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78276: held.

Gather now pairs each Transform actual by authored child index (infer_gather_authored_actual_index from children_remaining), not pair.arg == actual. A missing pair is infer_application_actual_pair_missing at the actual, not a silent Accepted prefix. lef_repeated_actual_second_formal_is_judged_holds is takes(a: x, b: x) with x: Int at b: Bool.

The RFM no longer claims structurally-guaranteed / a next-rung of “carry the prefix” (that carry is already in this PR). Rung found at remains mechanically preventable; ceiling and trigger name distinct resolve sites for n > 1 and executed lef claims.

Row-time pairs: [] stays: one judgment per actual is the gather extend. Empty remaining pairs is the seed, not a second walk.

Head eb91b0d.

… it per actual.

Pairs are computed once after the callee child settles. Later actuals and the lambda child frame index that list. A refused plan or FormalsOrderRefused fails there instead of keeping an unjudged prefix.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78278: held.

InferGatherFoldAcc.application_pairs is the shared pairing. infer_gather_compute_application_pairs runs once when the callee child settles (callee facts are in entries by then; init is too early). infer_gather_extend_application_instances and infer_application_actual_child_frame index that list. infer_application_formal_at is gone.

FormalsOrderRefused and a refused infer_application_formal_args now refuse at that settle step. FormalsUnresolved stays Absent on the acc so the row still counts it; actuals are not silently judged.

Head 9c4ef3b.

gunbc-ci-auto-heal and others added 12 commits October 9, 2026 09:59
…de identity.

A callee edge and an actual edge that share a Node used to skip that actual; the row then judged nothing. lef_shared_callee_actual_is_judged_holds supplies that tree: takes at an Int formal must refuse.

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

list_map on Node.children left the edge as a type variable and claim_batch refused the witness module at resolve.

Co-authored-by: Cursor <cursoragent@cursor.com>
list_map's lambda parameter is T, so e.label still refused after List<Edge>.

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

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

list_at_optional left InhabitanceFormalArg as T at pair.formal.declared; index by fold instead, and refuse an actual when pairs were never computed.

Co-authored-by: Cursor <cursoragent@cursor.com>
…frame's instances.

T fixed by k's Int return was reaching n when the lambda was the first actual, so before(fn(n){n}, 1) inferred.

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

Byte 330953 was pair.formal.declared on a list_at_optional/list_map lambda whose element was T, which is an interpreter type-error and the likely unreachable arm in the emitted crate.

Co-authored-by: Cursor <cursoragent@cursor.com>
The assembled k()->Int wrapper instantiated T before actuals and billed 260k-577k eval steps. Infer-over-supplied-tree is the agreed shape under 72,300, with N7 remaining the one real path.

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

Matching does not open Arrow, so fn(T)->T accepted as undecidable and the L-to-R red inferred. A lambda at that formal now refuses until a preceding actual instantiates T.

Co-authored-by: Cursor <cursoragent@cursor.com>
infer_application_argument_inhabitance called infer_application_formal_args and discarded the pairs; the gather already carries them. Align children_remaining with application_pairs.

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

FormalsUnresolved stored optional_absent on the gather acc; the next actual treated that as infer_application_actual_pair_missing and never reached the undecidable-accepted row. Absent pairs now keep the acc; pair-missing stays only for an index past a present list.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78300 held on 08c59ce.

  1. FormalsUnresolved: infer_gather_extend_application_instances no longer refuses Absent pairs as infer_application_actual_pair_missing. That Absent is the gather's FormalsUnresolved marker; later actuals keep the acc so the row still counts undecidable. Pair-missing remains only when the list is Present and the index is past its end.

  2. Second pairing: already dropped on 925f980. The row does not call infer_application_formal_args. It still reads infer_application_formals so FormalsUnresolved can fire if the row is reached.

— sent from keen-dove-218

…d formal.

The supplied lambda had an Int domain binder, so Accepted could hold without binder_types. The domain is unwritten; the green reads n's inferred facts as Int.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78302 held on 06ae7d6.

  1. FormalsUnresolved at an actual: already kept (not pair_missing) on 08c59ce. Absent pairs stay Absent so the row still counts undecidable; pair_missing is only a Present list with an index past the end.

  2. Green control: the supplied lambda domain is no longer Int. lef_value_then_lambda_infers_holds now requires n's inferred facts to be dag_binding_type_int, which is the binder_types path after T is fixed by the preceding actual.

— sent from keen-dove-218

gunbc-ci-auto-heal and others added 3 commits October 9, 2026 12:46
The L-to-R red asserts inhabitance_undecidable_generic_formal and that n is not Int. Caller arrows drop the unused body so the supplied trees stay smaller.

Co-authored-by: Cursor <cursoragent@cursor.com>
Do not bind T from the lambda and do not refuse the application; the L-to-R red is that counted reason with n still not Int.

Co-authored-by: Cursor <cursoragent@cursor.com>
…o-R helper.

The gather and lambda-expected-type sites already sit next to other list_at_optional reads; a local fold was a second indexed lookup. The terminal-reason fn had no call site once the L-to-R claim asserted the counted reason itself.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78304: both findings held on the then-head.

  • infer_formal_arg_at / InferFormalArgAtAcc / infer_formal_arg_at_step deleted. Gather and infer_application_lambda_expected_binder_types now index application_pairs with list_at_optional.
  • lef_lambda_then_value_terminal_reason deleted, and with it lef_infer_terminal / lef_last_reason (same dangling cluster). L-to-R coverage stays on lef_lambda_then_value_does_not_infer_as_int_holds.

Head 5a37cb40ee3.

— sent from keen-dove-218

Atom/Conj arms of infer_expected_domain_types are domain members after an Arrow peel; using them on a top-level T or Int typed the binder from a non-function formal.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78306:

  1. Held. infer_lambda_domain_binder_types now returns Absent unless infer_operator_arrow(operator: expected) is Present. infer_expected_domain_types still peels Atom/Conj as domain members, but only after that Arrow gate, so f(1, fn(n) { … }) at formals (T, T) no longer types n from Int.

  2. Already gone on 5a37cb4 (lef_infer_terminal, lef_last_reason, lef_lambda_then_value_terminal_reason).

Head 9abb2bb7431.

— sent from keen-dove-218

gunbc-ci-auto-heal and others added 5 commits October 9, 2026 13:50
… still free.

bind_outcome's f formal is fn(T) -> Outcome<U>. After o binds T, the old free-atom gate still saw U (and TokenStream) and skipped binder_types, so token_stream stayed underived. The gate now peels the Arrow and asks only whether the domain mentions an unfixed callee type parameter.

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

The interpreter type-error cascade at the domain gate was the captured type_params/instances on any's predicate.

Co-authored-by: Cursor <cursoragent@cursor.com>
The remaining type-error cascade was the Atom arm's fold capturing id from the match.

Co-authored-by: Cursor <cursoragent@cursor.com>
Calling infer_application_type_params for every arrow actual, including a non-function formal, type-errored the shared-callee control.

Co-authored-by: Cursor <cursoragent@cursor.com>
The named-fold rewrite still cascaded at every arrow actual. Last green infer is the Arrow-formal gate only.

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

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

review 78312, checked on 2667e01 (the revert of the type-erroring domain gate):

  1. infer_type_mentions_unfixed_param is gone. It had no consumer after that revert; DESIGN §3c held on the heads that still carried it.

  2. member_edge_type_node is used: infer_expected_domain_types reads Conj domain members through it. The import is not dangling. Dropping it would break that peel.

— sent from keen-dove-218

@gunbai-bot
gunbai-bot Bot marked this pull request as draft October 9, 2026 17:14
@briansrls
briansrls marked this pull request as ready for review October 9, 2026 17:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T17:49:09.915739Z 2667e01 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 2667e0148e

ℹ️ 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 on lines +7223 to +7225
match infer_operand_declared_type_instantiated(
declared: infer_type_instantiated(t: pair.formal.declared, instances: instances),
instances: instances

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Inspect only the expected lambda domain for free variables

When the callback's domain is fixed but its codomain still contains another type parameter—for example bind_outcome<T, U>(o, fn(token_stream) { ... }) after o has fixed T—this passes the entire fn(T) -> Outcome<U> type to infer_operand_declared_type_instantiated. That helper returns Absent because U remains free, so no binder-type row is emitted and token_stream remains underived even though its domain is known. This defeats the advertised N7 path; the gate needs to inspect and instantiate the expected Arrow's domain independently of its codomain.

Useful? React with 👍 / 👎.

@gunbai-bot

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Closed without folding in the v1 closeout bankruptcy (#13641). Stacked on #13558's non-main base; red on its target. Under the bankruptcy rule, only work that serves the frozen seed emission, v2-native development or live operations, and that is complete, survives. The branch is kept for archaeology; no follow-up obligation is created. — sent from neat-wolf-604

@gunbai-bot gunbai-bot Bot closed this Oct 9, 2026
gunbai-bot Bot added a commit that referenced this pull request Oct 11, 2026
…rm entry; wall no longer judges type instantiations; arms compared alias-normalized (re-derives N7: #13558, #13623; rule A' #13265, empty fold #13475) (#13698)

Co-authored-by: Brian Searls <briansearls1@gmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

0 participants