Skip to content

Consolidation 02_parse Level-1b — RE-SPAWN (prior fierce-wren died): migrate the remaining GrammarExpr hand-match queries (expr_direct_left_corner_list, expr_has_undefined_nonterminal, parse_expr) onto fold_grammar_expr (the Level-1 catamorphism, now on main). Additive + equivalence-preserving; pars - #4639

Merged
briansrls merged 4 commits into
mainfrom
session/calm-gull-609
Jun 11, 2026

Conversation

@briansrls

@briansrls briansrls commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Migrates the remaining three GrammarExpr hand-match queries in src/v4/compiler/02_parse.dag onto fold_grammar_expr (Level-1 catamorphism from #4637):

  • expr_direct_left_corner_list — GrammarExprCornerFold product threads nullable alongside corners through a single fold (Sequence gates right corners on left nullability).
  • expr_has_undefined_nonterminal — GrammarExprFold<Bool> algebra; does not follow nonterminal references into productions.
  • parse_expr — fold_grammar_expr builds a deferred ParseExprWalk; parse_expr_run_walk interprets with token threading (equivalent to the prior direct-recursion shape, including T-8 span stamping).

Additive + equivalence-preserving: no match expr arms remain in 02_parse.dag.

Test plan

  • parse_table_token_position_indices_no_extra_append_holds — green by execution
  • parse_table_nullable_morphism_holds — green by execution
  • parse_table_grammar_expr_projection_holds — green by execution
  • parse_table_left_corner_morphism_holds — green by execution (new)
  • parse_table_undefined_nonterminal_morphism_holds — green by execution (new)
  • grammar_validation.dag claims — still deferred (T-22 runner / contains-Variant gap); parse_expr exercised there when T-22 lands

@briansrls
briansrls marked this pull request as ready for review June 10, 2026 18:30
@briansrls

Copy link
Copy Markdown
Contributor Author

Addressing the review findings in 6be0645c:

Finding 1 (ParseExprWalk parallel representation): Valid. The fold stage here is identity-shaped — structural recursion over GrammarExpr is dissolved into fold_grammar_expr, but interpretation still requires a per-variant match on the interim ParseExprWalk coproduct. That is not full walker dissolution.

Fixed by downgrading both ParseExprWalk and parse_expr from 🟢 to 🟡 with bounded dissolution receipts:

  • ParseExprWalk: parallel 1:1 mirror; dissolve-on-arrival via a higher-order GrammarExprFold algebra whose handlers thread tokens and yield ParseExprResult directly (trigger: Level-2 parse-walk algebra in std/grammar.dag or T-8 parse-result projection unification).
  • parse_expr: marked as partial migration — fold dissolves structural recursion; parse_expr_run_walk remains interim interpretation. Forbidden to claim full dissolution until the higher-order algebra lands.

The two query consumers (expr_direct_left_corner_list, expr_has_undefined_nonterminal) remain genuine fold-algebra consumers with non-identity combine semantics — unchanged.

Finding 2 (Sequence nullable threading): Confirmed correct. left_fold.nullable is fold_grammar_expr applied with the same Bool nullable algebra as expr_is_nullable_given_set over the left subtree — equivalent to recomputing expr_is_nullable_given_set(expr: left, nullable_set). Added an inline comment at expr_corner_fold_sequence documenting this.

All five parse_table_claims witnesses still green by execution on this HEAD.

— sent from calm-gull-609

@briansrls
briansrls force-pushed the session/calm-gull-609 branch from 6be0645 to 1d7b27a Compare June 10, 2026 23:22
@briansrls
briansrls merged commit a25033f into main Jun 11, 2026
11 checks passed
@briansrls
briansrls deleted the session/calm-gull-609 branch June 11, 2026 00:00
briansrls pushed a commit that referenced this pull request Jun 11, 2026
Prior merge commit left conflict markers in glob_discovery.dag. Pin
updated via v4-glob-discovery-project.sh projection (main #4639 + four
comprep bodied-emit claims).

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jun 11, 2026
…etting consumer #4623) (#4627)

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: bump glob_discovered_smoke_marker_count for comprep bodied emit claim

The new unified_claim_comprep_ts_bodied_emit_add_fn distributed marker
raises the glob-discovery projection from 80 to 81 rows; v4_lens_gate
substrate-equivalence check was failing on the mismatch.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: merge main and bump glob marker count to 82 for CI substrate gate

Main gained unified_claim_comprep_eval_by_execution (#4624); combined with
this branch's bodied-emit marker the glob-discovery projection is 82 rows.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: bodied-arrow translate E-9 fallback and minus-catalog comprep lex

Route body-scope atoms structurally when coercion/grounding cannot apply,
and give the §4.5 minus-catalog perturb fixture its own wave1+minus lex so
discriminating emit claims stay faithful without polluting extdeps.

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

* fix: narrow comprep emit claim to E-10 emit-source consumer

Honest scope: witnesses assert emit source text and discriminating mutates,
not Node execution of emitted TS. Runtime add(2,3)=5 stays in
comprep_eval_by_execution; Node emit exercise awaits emit-host wiring.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: E-9 body-scope atom carrier in translate_mvp1 coercion fallback

Branch on algebra_ref_is_grounded so operator/param refs use explicit
translate_type_fold_init instead of target type realization; operand
bindings reader uses fold+list_snoc_item (order-preserving, type-correct).

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: wire CanonicalOperation algebra_field witness end-to-end

Encode OpAdd.algebra_field on operator-realization and primitive-apply
operation wires; decode and compare full operation in catalog lookup and
expr projection. Drop dead bodied-arrow grammar match; tag E-9 mvp1 carry.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: fail-closed value-expr wire decode and comprep emit diagnostics

Use bind_outcome in comprep_ts_emit_from_producer_tree so producer and
emit diagnostics merge on success and reject with pending on failure.
Add primitive-apply wire schema validation that rejects positional edges,
unknown named fields, and duplicate operation slots before operand decode.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: land operator catalog lookup in value_expression (unblocks compile)

Adding TargetOperatorRealizationCatalogLookup to target_model.dag breaks
TargetModel field resolution across the v4 closure; implement fail-closed
catalog wire validation + lookup in value_expression instead, consuming
target_model row decoders and target_operator_realization_row_edge.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: Atom-rooted wire decoders for operator shape and binding refs

find_named_child requires Conj roots; operator-shape and binding-ref wires
are Atom-discriminant nodes. Decode via direct child fold so catalog lookup
and value-expr token emission succeed on the producer path.

Also fail-closed when multiple bodied-scaffold translation rows match
(grammar_relation_row_with_bodied_scaffold).

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

* fix: tag E-9 structural-carry fallback when grounding witness is ungrounded

Align the algebra_ref_is_grounded=false branch in translate_mvp1_coerce_from_grounding_or_evidence with the sibling rejection-path 🟡 disposition so both fail-open translate_type_fold_init arms share explicit dissolution metadata.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix(ci): use release profile for parity lib-test compile guard

The ci_floor_parity guard spawned a debug-profile `cargo test -p
v2-compiler --lib --no-run`, cold-compiling serde under sccache on shared
runners and flaking with EAGAIN. Match the release shared closure instead.

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

* fix: resolve glob_discovery merge conflict markers (pin → 90)

Prior merge commit left conflict markers in glob_discovery.dag. Pin
updated via v4-glob-discovery-project.sh projection (main #4639 + four
comprep bodied-emit claims).

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix: land T6 value-expression substrate fold for emit tokens

Move operator-catalog lookup and shape-driven token emission into target_model.dag
so 06_value_expression delegates through the substrate fold; avoids DSL keyword
pitfalls (operation/realization/Node coproduct arms) that broke type-checking.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix(#4627): route wave1 slot validation through declared inhabitants; carve translate

Dissolve P2 extdep TS symbol leaks in 06_value_expression by validating wave-1
add signature slots via target_model declared-inhabitants catalog helpers.
Revert 06_translate bodied-arrow routing to main (moves to B3 #4641).
Replace emit-source COMPREP with fold-level witnesses on the (a)-fold delegate.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix(#4627): dedupe wave-1 signature authority; drop bodied-scaffold decode dead code

Address api-review REQUEST_CHANGES: route value_expression wave-1 gate through
target_wave1_add_signature_matches (single substrate authority; IR kernel
^dag_binding_type_int pre-coercion lives in target_model only). Remove
translate-carved bodied-scaffold decode/compose APIs with zero call sites until
B3 #4641. Land arrow_domain_named_param_bindings accessor in node_query for the
unified param-binding convergence (consumer wiring follows with vivid).

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix(#4627): dissolve :215 via arrow_domain_named_param_bindings membership

Merge-gate (a): replace fixture binding-name equality in
value_expr_arrow_body_scope_binding_valid with general-arity membership
against node_query arrow_domain_named_param_bindings. Reshape
body_producer MVP arrow positional-0 domain to Conj Named binding_id
edges (constructor = accessor source of truth). Expand
surface_op_atom_to_canonical 🟡 to Practice-4 shape.

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

* WIP: RUNTIME commits on #4627 (session/lively-badger-242 @ d976bb4): body_pr

* fix(#4627): Practice-10 disposition on predicate consumers; Outcome bind path

Move 🟡 to live-path consumers (value_expr_arrow_has_transform_body,
value_expr_wave1_add_signature_matches_for_target). Tag target_model wave-1
signature Bool family. Refactor body-scope binding through bind_outcome on
arrow_domain_named_param_bindings. Delete unused positional_child_atom helpers.

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

* fix(#4627): dissolve eval_wave1_argument_binding_key via arrow_domain_named_param_bindings

Dissolve the 🟡-gated eval_wave1_argument_binding_key hardcoded index→param_name
table (^dag_binding_param_x/y): eval_bind_wave1_argument now takes param_names:
List<Symbol> and resolves binding keys via list_nth, sourced from
arrow_domain_named_param_bindings on the callee Arrow's domain Conj.

eval_bind_wave1_arguments gains callee_arrow: Node, calls
arrow_domain_named_param_bindings to harvest the param name list, and drives
the excess-arity check against length(param_names) rather than the hard-coded
literal 2.

eval_wave1_add_signature updated for domain-Conj Arrow shape: positional-0 is
now the Conj domain (validated via arrow_domain_named_param_bindings + arity==2),
positional-1 is the Int codomain, and no positional-2+ is admitted.

Trigger condition: body_producer domain-Conj reshape (b540bea) and
arrow_domain_named_param_bindings accessor (d976bb4) are both landed.
Bind: node://adhoc-9a72d4fb-8c2 COMPREP-WAVE1-EVAL dissolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* fix(#4627): dissolve indexed-list walker via list_at_optional

Replace hand-rolled FreeMonoid recursion in transform_positional_operand_binding
with node_positional_child_targets + list_at_optional substrate lookup (Practice 10).

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

* fix(target_model): dissolve operator catalog lookup via PassingCandidateFold

Route target_operator_realization_catalog_lookup through the same
PassingCandidateFold step pattern as #4648 atom catalog dissolution;
drop hand-rolled match_count/first_matching_row. Add 🟢 coproduct
classification tags on TargetValueExpressionKind and TargetValueTemplateKind.

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

* fix(target_model): witness operator-catalog fail-open skip semantics

Align operator catalog lookup with #4648 atom pattern: catalog
wire_schema_valid checks structure only; lookup_step skips
Rejected row decodes. Add target_model_operator_lookup_dissolution
claim with malformed-row fail-open witness.

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

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

* WIP: T6 SKELETON-IMPLEMENTER: real Arrow.body -> translated TS -> Node -> add

---------

Co-authored-by: Brian Searls <briansearls1@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Sonnet 4.6 <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.

1 participant