Skip to content

Refactor nested GrammarExpr sequences to FormalProduction flat-list rhs across extdeps Wave-1/2a language files (prereqs met: #3796 + #3805 on main) - #3837

Closed
briansrls wants to merge 2 commits into
mainfrom
session/sleek-ferret-165
Closed

briansrls wants to merge 2 commits into
mainfrom
session/sleek-ferret-165

Conversation

@briansrls

@briansrls briansrls commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Converts XxxGrammarRelationRow.production from GrammarProduction (with nested GrammarExpr Sequence tree) to FormalProduction (flat List<FormalGrammarSymbol> rhs) across all Wave-1/2a extdeps language files. This is the forward step enabled by formal_production_to_node landing in grammar.dag (#3805) and completes the T-4.17 grammar-as-data migration for the relation-row carrier type.

Files changed: cpp.dag, java.dag, kotlin.dag, go.dag, wasm.dag (plus the WIP commit already on branch covering rust.dag, swift.dag, typescript.dag).

Per-file changes:

  • cpp/java/wasm: add xxx_formal_terminal_symbol, xxx_formal_rhs_from_token_classes, xxx_formal_production_mvp1_fn_add helpers; update XxxGrammarRelationRow.production type; switch xxx_grammar_relation_row_node to formal_production_to_node; add FormalProduction/FormalTerminal/FormalTerminalOccurrence/FormalNonterminal/FormalGrammarSymbol/formal_production_to_node to grammar imports, remove grammar_production_to_node
  • kotlin: add kotlin_formal_production_from_nonempty helper; update kotlin_grammar_relation_row_node to use formal production + formal_production_to_node + direct kotlin_mvp1_emitted_add_fn_node() call
  • go: fix incomplete WIP — row.production.emitted access fails now that production is FormalProduction; use go_mvp1_emitted_add_fn_node() directly
  • rust/swift/typescript: already covered by WIP commit on branch

GrammarProduction/GrammarExpr scaffold retained for grammar roots (CP-1b dual-carrier hold). The GramBuild1State + grammar_sequence_from_token_classes adapters are preserved as they still serve grammar root builders.

Test plan

  • ctrl-build -- cargo run -p v2-compiler --bin v2-compiler -- compile --source-root src/v4 --output-dir /tmp/gunbc-v4-check-sleek-ferret → compiled: 273 files emitted, 0 diagnostics
  • python3 scripts/strict_deprose_dag.py --check → OK

briansrls and others added 2 commits May 28, 2026 20:43
…for all Wave-1/2a language files

Converts XxxGrammarRelationRow.production from GrammarProduction to FormalProduction
across all remaining extdeps language files: cpp, java, kotlin (plus fixes to the WIP
partial work on go and wasm).

- cpp/java/kotlin: add formal_terminal_symbol + formal_rhs + formal_production helpers;
  update relation row type + constructor; switch grammar_relation_row_node to
  formal_production_to_node; add FormalProduction/FormalTerminal/etc. to grammar imports
- go: fix incomplete WIP — emitted no longer from row.production.emitted (GrammarProduction
  field); use go_mvp1_emitted_add_fn_node() directly since GoGrammarRelationRow has
  no emitted field
- wasm: add missing formal terminal/rhs/production helpers

GrammarProduction + GrammarExpr scaffold retained for grammar roots (CP-1b dual-carrier hold).
All 273 files compile with 0 diagnostics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@briansrls
briansrls marked this pull request as ready for review May 28, 2026 20:59
@briansrls

Copy link
Copy Markdown
Contributor Author

Superseded by #3828 (valiant-boar-99) which covers all 10 files including dag.dag and python.dag. Good work on the local validation — the broader PR will carry this forward.

@briansrls briansrls closed this May 28, 2026

@briansrls briansrls left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review metadata

  • Provider / model: codex / unknown
  • Commit: 3dfab499 · Trigger: schedule
  • Thinking: 236s wall

BLOCKING (2)

Root Cause

  • src/v4/extdeps/languages/go.dag FormalProduction correctly carries only lhs/rhs, but GoGrammarRelationRow was not widened to carry emitted output after that split → add an emitted Node field or shared relation carrier and project row.emitted.
  • src/v4/extdeps/languages/kotlin.dag KotlinGrammarRelationRow still derives only production/tokens after FormalProduction drops emitted → model emitted on the row or shared grammar-relation carrier and have the projection consume that field.

⚠️ Two relation-row projections now synthesize emitted output instead of carrying it through the model.

go_named_edge(name: grammar_relation_field_production, target: grammar_production_to_node(production: row.production)),
go_named_edge(name: grammar_relation_field_emitted, target: row.production.emitted),
go_named_edge(name: grammar_relation_field_production, target: formal_production_to_node(production: row.production)),
go_named_edge(name: grammar_relation_field_emitted, target: go_mvp1_emitted_add_fn_node()),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BLOCKING: The relation-row projection now fabricates the MVP1 emitted node instead of reading an emitted fact from the row, so replacing GrammarProduction with FormalProduction silently drops emission authority and violates INVARIANTS.md P2 facts-flow-forward.

kotlin_named_edge(
name: grammar_relation_field_emitted,
target: production.emitted
target: kotlin_mvp1_emitted_add_fn_node()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BLOCKING: The relation-row projection hardcodes kotlin_mvp1_emitted_add_fn_node after switching to FormalProduction, leaving emitted output outside the row’s typed authority and violating INVARIANTS.md P2 single-authority/facts-flow-forward.

@briansrls
briansrls deleted the session/sleek-ferret-165 branch June 1, 2026 18:43
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