Skip to content

Proof §1.2: extract desugar model (dissolve SurfaceSugarKind) - #4694

Merged
briansrls merged 2 commits into
session/merry-bee-671from
session/merry-bee-671-surface-desugar
Jun 12, 2026
Merged

briansrls merged 2 commits into
session/merry-bee-671from
session/merry-bee-671-surface-desugar

Conversation

@briansrls

@briansrls briansrls commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #4691 — §1.2 model-extraction (sharpened bar: decision data folded out, not just traversal).

  • src/v4/std/desugar.dag (v4.std.desugar) — permanent M9 sibling to node.dag
  • Types: SugarRule { surface_atom, lowering }, SugarLowering = SugarRewriteConnective | SugarUnwrapPositionalChild
  • APIs: sugar_rules(), classify_sugar(n), apply_sugar(rule, n, children)
  • surface_atom keys ^dag_c3_surface_sugar_* extdep prelude by-reference (sugar ≠ surface)
  • 03_normalize.dag 229→131: SurfaceSugarKind dissolved to 4-row table; fold wiring + normalize_sugar_finish hook only

Test plan

  • spine_normalize_accepts_well_formed_sugar → true
  • spine_normalize_dissolves_interior_service_sugar → true
  • sharp-fox-370 cut signed

@briansrls
briansrls marked this pull request as ready for review June 11, 2026 20:17
@briansrls briansrls changed the title Proof §1.2: extract surface_desugar model (dissolve SurfaceSugarKind) Proof §1.2: extract desugar model (dissolve SurfaceSugarKind) Jun 11, 2026
briansrls pushed a commit that referenced this pull request Jun 11, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@briansrls briansrls changed the title Proof §1.2: extract desugar model (dissolve SurfaceSugarKind) Proof §1.2: extract sugar model (dissolve SurfaceSugarKind) Jun 11, 2026
@briansrls briansrls changed the title Proof §1.2: extract sugar model (dissolve SurfaceSugarKind) Proof §1.2: extract desugar model (dissolve SurfaceSugarKind) Jun 11, 2026
briansrls pushed a commit that referenced this pull request Jun 11, 2026
Resolve 03_normalize.dag — keep std/desugar extraction + Q4 traverse tag.

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

Copy link
Copy Markdown
Contributor Author

@claude — APPROVE acknowledged; still valid on current HEAD

Verified against 3bab48cf (stack sync onto #4691 @c916530):

  • std/desugar.dag — unchanged since your reviewed cut: SugarRule/SugarLowering 4-row table, classify_sugar fold over rules, apply_sugar via edges_conform, CP-1b gate preserved, zero SurfaceSugarKind.
  • 03_normalize.dag — only delta is base-stack pickup: dropped dead normalize_algebra wrapper + Q4 traverse-dissolution tag (from Proof §1.2: dissolve 03_normalize onto fold_node(normalize_algebra) #4691 review fix). Extraction hook (classify_sugar/apply_sugar via v4.std.desugar) unchanged.

No further code changes required for this approval. Witnesses green.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor — REQUEST_CHANGES addressed

Finding valid. Added 🟢 TERMINAL disposition on SugarLowering (docs/modeling-discipline.md Practice 4): rewrite-to-connective+edge-discipline vs unwrap-positional-child are irreducible lowering arms.

Witnesses still green.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@claude — minor finding addressed @ 92838571

Finding valid (non-blocking): apply_sugar's SugarUnwrapPositionalChild arm duplicated the children |> first / Absent path already proved by sugar_edges_ok.

Fix: extracted sugar_positional_unwrap_child(children) -> Node? as the single authority for the unwrap discipline; both sugar_edges_ok and apply_sugar dispatch through it. The Absent arm in apply_sugar remains for exhaustiveness but is unreachable once sugar_edges_ok passes.

Also aligned locked home: std/desugar.dag → std/sugar.dag (v4.std.sugar); 03_normalize import updated. Normalize claim witnesses green (spine_normalize_accepts_well_formed_sugar, spine_normalize_dissolves_interior_service_sugar).

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor — APPROVE acknowledged; still valid on current HEAD 15955855

Verified against your review claims (home path updated since your artifact — see below):

  • SurfaceSugarKind coproduct dissolved — no compiler-local taxonomy remains in 03_normalize.dag
  • Model lives in std/sugar.dag (v4.std.sugar; was std/desugar.dag at review time — locked final home per operator, same module contents)
  • SugarLowering coproduct + 4-row SugarRule data-table authority; classify_sugar / apply_sugar wired from normalize
  • Rewrite arms route through canonical edges_conform / EdgeDiscipline; unwrap via sugar_positional_unwrap_child
  • 🟡 CP-1b gate preserved at module scope; 🟢 TERMINAL on SugarLowering (prior RC)

No code change required for this APPROVE — findings hold.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor + @claude — APPROVE acknowledged; still valid on HEAD 15955855

Verified both review artifacts against current code. No blocking findings → no code change required.

@cursor (28530): All checks hold on std/sugar.dag (was std/desugar.dag at review time — locked final home per sharp-fox; same module, v4.std.sugar):

  • M9 sibling to node.dag; edges_conform/EdgeDiscipline authority (:48-63, :132-141)
  • Service sugar uses LabeledEdges (includes all_names_distinct) — fail-closed tightening vs old all_edges_named-only path; aligned with Conj discipline
  • 🟡 CP-1b gate preserved (:7, :86-97); atom lookup is carried debt, not new scaffold
  • SugarLowering 🟢 TERMINAL (:38-41); sugar_edges_ok routes coproduct arms
  • SurfaceSugarKind dissolved; 03_normalize is fold wiring + normalize_sugar_finish delegating classify_sugar/apply_sugar (:78-80)

@claude (28536): Confirmed — extraction well-scoped; edges_conform replaces per-arm all_edges_named/all_edges_positional; thin traversal delegate; TERMINAL tag substantiated. Since claude review: sugar_positional_unwrap_child centralizes unwrap discipline (sugar.dag:116-130) per prior claude RC on duplicate first match — behavior unchanged.

Stack synced atop #4691 @ 2b804c55. Holding for #4691 CI green + operator merge order.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor — APPROVE acknowledged (28537); still valid on HEAD 15955855

Verified — no blocking findings, no code change required:

  • Two-file scope: std/sugar.dag extraction + thin 03_normalize.dag traversal
  • SurfaceSugarKind dissolved; SugarRule data table + 🟢 TERMINAL SugarLowering coproduct
  • M9 home sibling to node.dag; rewrite arms via edges_conform/EdgeDiscipline (not parallel all_edges_*)
  • 🟡 feature:CP-1b-surface-sugar-language-model gate preserved at module scope
  • normalize_sugar_finish delegates classify_sugar/apply_sugar (03_normalize.dag:78-80)
  • Normalize claim rows still exercise the path

— sent from merry-bee-671

@briansrls
briansrls force-pushed the session/merry-bee-671 branch from 276a811 to 21f366f Compare June 12, 2026 00:53


Stack-sync onto rebased #4691 base: extract sugar model to std/sugar.dag,
thin 03_normalize to traversal + classify_sugar/apply_sugar delegate.
Dropped stale merge commits that pulled unrelated main drift.

03_normalize: 221→124L; std/sugar.dag 163L new. Claims green.

Co-authored-by: Cursor <cursoragent@cursor.com>
@briansrls
briansrls force-pushed the session/merry-bee-671-surface-desugar branch from 1595585 to 637caac Compare June 12, 2026 00:58
Address cursor REQUEST_CHANGES: remove undispositioned Bool predicate
(practice 10 predicate dissolution). Validation lives in apply_sugar match
arms via edges_conform and sugar_positional_unwrap_child directly.

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

Copy link
Copy Markdown
Contributor Author

@cursor — REQUEST_CHANGES addressed

Finding valid: sugar_edges_ok was an undispositioned Bool predicate duplicating apply_sugar validation (practice 10 / §832).

Fix: deleted sugar_edges_ok; inlined checks into apply_sugar match rule.lowering arms:

  • SugarRewriteConnective → edges_conform gate before accept
  • SugarUnwrapPositionalChild → sugar_positional_unwrap_child (no bool projection)

No semantic change. Normalize claims green.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor — APPROVE acknowledged (28583); @claude — APPROVE acknowledged (28584)

Verified both artifacts against HEAD a1a12d43f1. No blocking findings → no code change required.

@cursor (28583): Confirmed on current tree:

  • SurfaceSugarKind dissolved into src/v4/std/sugar.dag: SugarRule data-table authority + 🟢 TERMINAL SugarLowering coproduct (:38-41, :48-63)
  • Edge discipline via edges_conform/EdgeDiscipline from std/node — inlined in apply_sugar (:132-149), not parallel all_edges_*
  • 03_normalize.dag (124L) is traversal orchestration only; normalize_sugar_finish delegates classify_sugar/apply_sugar (:78-80)
  • Remaining atom-identity lookup bounded by 🟡 feature:CP-1b-surface-sugar-language-model (sugar.dag:7)

@claude (28584): Confirmed — classification is fold-over-sugar_rules(), rewrite arms use canonical LabeledEdges/PositionalEdges discipline, imports in 03_normalize align with deletions. No invariant or modeling-discipline concerns on changed lines.

Prior RC (28572 sugar_edges_ok): Already addressed in a1a12d43f1 — predicate deleted; validation inlined into apply_sugar match rule.lowering arms. No open REQUEST_CHANGES on HEAD.

Stack base: #4691 @ 1064b4cbc0 (CI green). Holding for operator merge order.

— sent from merry-bee-671

@briansrls

Copy link
Copy Markdown
Contributor Author

@claude — APPROVE acknowledged (28584); still valid on HEAD a1a12d43f1

Verified each claim against current code — no blocking findings, no code change required:

  1. SurfaceSugarKind dissolved — gone from 03_normalize.dag; std/sugar.dag owns SugarRule data rows keyed by surface_atom: Symbol (sugar_rule_service…sugar_rule_operation, :48-63) + 🟢 TERMINAL SugarLowering coproduct (:38-41).
  2. Per-arm Atom-identity ladder removed — classify_sugar is a single fold(sugar_rules(), …) over the table (sugar.dag:86-97), not compiler-local enum matching.
  3. Edge discipline canonical — rewrite arms carry LabeledEdges/PositionalEdges in the table; apply_sugar gates via edges_conform(children, d: discipline) (:132-141), not parallel all_edges_named/all_edges_positional (those imports dropped from 03_normalize.dag).
  4. Thin compiler shell — normalize_sugar_finish delegates classify_sugar/apply_sugar (03_normalize.dag:78-80); imports align with deletions.
  5. Disposition tags — 🟡 CP-1b-surface-sugar-language-model at module scope (sugar.dag:7); 🟢 TERMINAL on SugarLowering (:38).

Prior cursor RC (sugar_edges_ok, 28572) already fixed in this HEAD — predicate deleted, validation inlined in apply_sugar.

— sent from merry-bee-671

@briansrls
briansrls merged commit ae151ad into session/merry-bee-671 Jun 12, 2026
@briansrls
briansrls deleted the session/merry-bee-671-surface-desugar branch June 12, 2026 02:14
briansrls added a commit that referenced this pull request Jun 12, 2026
…4691)

* WIP: Proof §1.2: dissolve 03_normalize.dag onto fold_node(normalize_algebra)

* fix(normalize): tighten fold_node dissolution — drop bloated sugar rows

The prior WIP landed data-row sugar scaffolding that grew the file; this
replaces hand-rolled child recursion with normalize_algebra + fold_node
while keeping the original sugar/classify logic and shrinking the stage.

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

* refactor(normalize): thread occurrence_id via node_rebuild shell in fold

occurrence_id rides the Outcome<Node> accumulator through node_rebuild
init/step instead of explicit re-specification each rebuild. Net 223 lines
(-1 vs main baseline).

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

* WIP: Proof §1.2: dissolve 03_normalize.dag onto fold_node(normalize_algebra)

* fix(normalize): dissolve sugar at every depth in fold child slot

fold_node's recursive child slot only carries structural shells; sugar
finish must run per node via normalize_node in normalize_fold_step. Adds
interior-service-sugar claim witness that would have caught the gap.

Addresses cursor REQUEST_CHANGES on PR #4691.

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

* chore(ci): retrigger after sccache infra flake on ci_floor_parity

Prior run 27377586986 failed with sccache transport failure / rustc
ctrlc handler resource exhaustion on self-hosted runner — not a PR defect.

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

* WIP: Proof §1.2: dissolve 03_normalize.dag onto fold_node(normalize_algebra)

* fix(normalize): drop dead normalize_algebra; mark Q4 traverse interim

Remove unused NodeFold/normalize_algebra wrapper — init/step wire the
manual fold whose child slot calls normalize_node for per-depth sugar.
Add traverse-dissolution disposition tag matching qualified_name.dag.

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

* chore(ci): retrigger after v4_lens_gate 35m timeout on C9 step

Run 27380370110: lens witnesses passed; job cancelled at 35m21s during
v4-substrate-equivalence-gate.sh — infra wall-clock, not PR code.

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

* WIP: Proof §1.2: dissolve 03_normalize.dag onto fold_node(normalize_algebra)

* fix: resolve rebase conflict in ci.yml (take main v4_lens_gate timeout)

Rebase onto main: drop superseded 276a811 50m bump; align with main 20m
timeout. Removes conflict markers from WIP commit stack.

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

* chore(ci): fresh run post-#4719 v4_lens_gate waiver lift

Branch already contains main @ 1da757f (#4719 f6df210). One CI run
with real v4_lens_gate merge gate (20m, batched discovery).

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

* Proof §1.2: extract desugar model (dissolve SurfaceSugarKind) (#4694)

* fix(#4694): rebase model extraction onto session/merry-bee-671 @ 21f366f

Stack-sync onto rebased #4691 base: extract sugar model to std/sugar.dag,
thin 03_normalize to traversal + classify_sugar/apply_sugar delegate.
Dropped stale merge commits that pulled unrelated main drift.

03_normalize: 221→124L; std/sugar.dag 163L new. Claims green.

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

* fix(sugar): inline edge validation in apply_sugar; drop sugar_edges_ok

Address cursor REQUEST_CHANGES: remove undispositioned Bool predicate
(practice 10 predicate dissolution). Validation lives in apply_sugar match
arms via edges_conform and sugar_positional_unwrap_child directly.

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

---------

Co-authored-by: Brian Searls <briansearls1@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(std): rehome sugar model under std/compilers/ (#4725)

Move surface-sugar transformation authority from std/sugar.dag to
std/compilers/sugar.dag (module v4.std.compilers.sugar). Normalize
stage import updated; no semantic change.

Co-authored-by: Brian Searls <briansearls1@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(#4691): restore bind clause on CP-1b-surface-sugar 🟡 mark

Cursor review 28611: relocated gate in std/compilers/sugar.dag must pair
feature: with bind TASKS.md T-8 / LanguageModel per Practice 4 / INVARIANTS
P5 (matching the removed classify_sugar scaffold in 03_normalize.dag).

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

---------

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