Skip to content

MQ-1: list literals lower whole as their free-monoid construction, through the one value reader - #12208

Merged
gunbai-bot[bot] merged 62 commits into
mainfrom
session/lively-koi-275
Sep 26, 2026
Merged

gunbai-bot[bot] merged 62 commits into
mainfrom
session/lively-koi-275

Conversation

@gunbai-bot

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

Copy link
Copy Markdown
Contributor

MQ-1 (work item adhoc-6c4a2f19-afa). The base is main.

What changes

A list literal is the flat free-monoid introduction. List<T> is std.algebra FreeMonoid<T> (dag/std/algebra.dag). [e1, .., en] lowers to one Transform. Its head is the resolved reference to std.algebra.FreeMonoid, and its remaining positional children are the elements in order. [] is the Transform with the head alone.

  • Authority for the shape: std.literal_elaboration UnicodeScalarSequenceUnfold. It names the flat list-literal node as "the language's canonical FreeMonoid introduction" and rejects a cons^n nesting for two reasons: it is O(n²) under a sequence-backed carrier, and n-deep it exceeds the emitter's bounded recursion fuel.
  • Recorded reversal. This PR first lowered to a right-nested list_append over freemonoid_singleton calls. That forked the authority above. Reading std.literal_elaboration for the caret slice surfaced it, and the gentle-koi-724 / neat-boar-16 ruling reversed it to the flat form before landing. The nested lowering and freemonoid_singleton (left with no consumer, §3c) are deleted.
  • One producer, body_lower_list_literal, reached from body_lower_primary_expr. Every value position reads through body_lower_value_lowered, so all of them get it: call args, field inits, let values, operands and scrutinees. There are no per-position fixes.
    • Each element is lowered whole. One that can't be lowered refuses at the element (body_lowering_reason_list_element_unlowered).
    • An unreadable literal shape refuses as body_lowering_reason_list_literal_shape_unread.
  • One infer introduction case in v2.compiler.infer, infer_transform_freemonoid_introduction. It runs before application inhabitance, because the head is a type and not a function.
    • All elements must unify to one T, compared with provenance stripped. The first element that differs refuses located at that element (infer_list_element_type_mismatch).
    • The result type is FreeMonoid<T>.
    • [] derives no T here: it stays on the counted GroundingNotDerived frontier rather than receiving a guessed T.
  • The head names std.algebra, not v2.std.algebra. v2.std.algebra imports v2.std.node, so the list literals in v2.std.node itself would otherwise close a node → algebra → node cycle.
    • freemonoid_empty, list_append and list_snoc_item moved into std.algebra next to FreeMonoid, delete-first with no re-export.
    • Every consumer is repointed: ~200 import lines, the complexity lens's dotted calls, two embedded fixture programs and the census citations.
    • The self-host behavioral shims now use one bridge std_algebra.rs (review 70892).
  • Deleted: the call-argument-only refusal (body_lowering_reason_list_literal_unlowered and its route).
  • The RFM row list_literal_has_no_lowered_form records the climb, the form and the reversal.

Evidence

🤖 Generated with Claude Code

Brian Searls and others added 17 commits September 23, 2026 20:10
…d arguments no longer refuse the whole module

gunbc#12145 stopped the operand reader narrowing a sequence to its left element,
which had read h(q: a) as h and [a] as [. body_lower_call_arg_value read every
argument with that reader alone, so a nested call, record, caret symbol or
parenthesised group became call_argument_unread and its whole module refused
normalize. An argument's value is now lowered by body_lower_value_lowered (the
field-initializer / if-condition reader), with the operand reader as fallback.
A parenthesised group lowers to its inner expression instead of its first atom.
A list literal anywhere in an argument value still refuses, at the list
(body_lowering_reason_list_literal_unlowered): body lowering has no lowered form
for a list literal yet, so reading it would trade a refusal for a silent drop.
Witness: v2.test.claim.namespace_xl0.call_argument_value_resolve_refusal.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e no longer refuses the whole match

body_lower_match_scrutinee_optional read the scrutinee with the operand reader
alone: before gunbc#12145 match t(p: x) {..} narrowed to t, after it the match
refused as match_arm_navigation_refused (64 of the 133 still-refusing sample
modules). The scrutinee now goes through body_lower_value_lowered, operand reader
as fallback, refusal propagated. Witness claim: an undeclared name inside a call
scrutinee refuses at resolve at its atom.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ments read through the value reader

Stacked on #12173 (call arguments and match scrutinees via body_lower_value_lowered).
body_lower_operator_operand reads a non-operator operand whole via body_lower_value_lowered
before refusing operator_operand_unread; a function value in argument position is carried as
its preserved shell under value_carried_unlowered (the field-initializer disposition) instead of
refusing its module as call_argument_unread (weather.dag, gen-one's first fatal). Claim
v2.test.claim.namespace_xl0.value_position_whole_read with production-route shape assertions;
RFM row fold_rewrite_regression_visible_only_at_whole_route_identity_diff.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… outcome, not dropped (review 70746)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rom the #12198 srv1 diff)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e_query and node_subtree_nodes, no untyped edge field access (entry resolve refused '.target' on T)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…RFM receipts folded into lowering_accessor_collapses_a_sequence_operand as an exposure/coverage gap, not a new regression row (side-chat review)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ough the value reader

[] -> v2.std.algebra.freemonoid_empty(); [e] -> freemonoid_singleton(item: e);
[e1..en] -> right-nested list_append(left: singleton(e1), right: ..). One producer
(body_lower_list_literal) reached from body_lower_primary_expr, so every value
position gets it; each element lowers whole via body_lower_value_lowered and an
element that cannot lower refuses located at it. The call-argument
list_literal_unlowered refusal is deleted. Declares freemonoid_singleton (the
free monoid's generator embedding) beside freemonoid_empty.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… shape of the operator_operand_unread files; the bare call lowered before the fallback (srv1: M1/M2 stayed green)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…eclared body name refused at its atom; operator-operand fallback and its non-discriminating claims dropped (owned by #12194)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tionally so the rostered named-label drop does not red it

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…; lambda claims enrolled expected-red as the MQ frontier; shape claims read an ingest without the lambda fixtures; RFM receipt updated

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
 landed) into MQ-1

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gunbc-ci-auto-heal and others added 4 commits September 24, 2026 12:26
…'s landed versions

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…branch hunk the squash did not land is not this PR's)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…-resolve under #12194's match-scrutinee controls; list_literal_has_no_lowered_form records the climb and cites the renamed and new claims

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…clared; move freemonoid_empty, freemonoid_singleton, list_append, list_snoc_item there (delete-first, no re-export) and repoint every consumer

v2.std.algebra imports v2.std.node, so v2.std.node's own list literals lowered to
v2.std.algebra calls would close a node -> algebra -> node cycle; v2 collapses onto
dag/std. Adds the self-reference claim: a module std.algebra's own list literals
resolve to its own qualified names, and its twin without list_append refuses at resolve.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…bridge std_algebra.rs (FreeMonoid + list_snoc_item) replaces the v2_std_algebra.rs bridge and normalize's FreeMonoid-only stub

The emitted 03_normalize, 03_body_producer and use_site_verdict now import
list_snoc_item from std.algebra; their transport rows, shim libs and normalize's
declared source refs point at the one bridge (review 70892).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gunbai-bot

gunbai-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review 70892 in 6350074. The finding was right. The emitted 03_normalize, 03_body_producer and use_site_verdict all import list_snoc_item from std.algebra after the move, but the only Rust shim for it was the v2_std_algebra.rs bridge, and normalize had a second std_algebra.rs stub that held only FreeMonoid.

What changed:

  • One bridge, dag/gunbc/instruments/self_host_std_bridge_shims/std_algebra.rs, now holds FreeMonoid and list_snoc_item.
  • The v2_std_algebra.rs bridge and normalize's stub are deleted, so there is no second copy.
  • The transport rows (self_host_module_behavioral_transport_roster), the three shim lib.rs files, and normalize's declared_source_refs all point at the new bridge.
  • No other shim or witness file referenced crate::v2_std_algebra.

Rung: this is consistent by inspection, not by execution. I haven't built these instruments; the build that exercises them is the self-host behavioral run.

— sent from lively-koi-275

…ebra FreeMonoid reference, elements positional in order -- with one infer introduction case

Reverses the right-nested list_append lowering: std.literal_elaboration
UnicodeScalarSequenceUnfold names the flat list-literal introduction as the
language's FreeMonoid introduction and rejects cons^n on cost and emitter fuel, so
the nested form forked that authority (ruling: gentle-koi-724 / neat-boar-16).
04_infer types the introduction: every element unifies to one T (compared with
provenance stripped), a differing element refuses located at it, [] stays on the
GroundingNotDerived frontier. freemonoid_singleton is deleted (no consumer left).
Claims: flat shape reader, 200-element depth control, infer introduction controls;
the std.algebra self-reference twin now omits FreeMonoid itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@briansrls briansrls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Exact-head re-review of 56a00a6b7765aad1d78889cac502bc4ae06350ae: APPROVE.

Review 5311185213 is closed.

  1. Element-type equality is now structural rather than atom-only. infer_type_equal_ignoring_provenance delegates to the existing exact structural equality fold; the supplied nested-equal case establishes FreeMonoid<FreeMonoid<Int>>, and the nested-mismatch case refuses at the differing inner list.

  2. The positive inference contract now reads the exact FreeMonoid argument. The Int claim requires FreeMonoid<Int>, and the Bool twin both establishes FreeMonoid<Bool> and rejects FreeMonoid<Int>.

  3. The std.algebra bridge transition has executed rather than remaining source inspection. use_site_verdict passes on both the PR and the main control; body_producer passes here while main stops at its independently stale claim-run path; 03_normalize reaches the same unrelated emitted-crate E0308 on both. The shared bridge itself remains unchanged at this exact head, and the former count literal is now an identity join. That closes the pairing concern without over-reading the unrelated normalize failure as a successful behavioral receipt.

The #12202 integration is also complete: the canonical list-introduction reader recognizes the exact std.algebra.FreeMonoid head in both the pre-resolve qualified-spine form and post-resolve declaration-reference form; application_head_read returns NotApplicationHead before ordinary application classification. Controls establish that a lowered list argument and a resolved list introduction are not applications, while the call enclosing a list remains an application.

The flat representation, whole-element ordering controls, 200-element depth control, first-only/drop-head/reversal mutations, self-reference qualification after #12240, and the 0/35 list_literal_unlowered result are mutually consistent. All five exact-head checks are green, including the floor and emitted build.

The stated residuals are honest and do not block this slice: the seven-test canary remains downstream of #12210, and target emission of the 200-element value within fuel remains a separate frontier rather than being claimed here.

Non-blocking documentation cleanup: the PR body still contains the older wording that the std.algebra self-reference is expected-red and that the flat head needs a re-run. Both are superseded by the evidence at this head and should be refreshed before merge, but they do not reopen source review.

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Sep 25, 2026
gunbai-bot Bot pushed a commit that referenced this pull request Sep 25, 2026
… (survives #12208 deleting the list-literal cause)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 25, 2026
…12298, #12184, ...)

- self-host instruments take main's versions (#12275 links only emitted bytes); #12208's
  std_algebra.rs bridge is deleted with the rest of the std-bridge shim directory it lived in.
- body_lowering_fold keeps main's anonymous_binder + symbol_intern_lexeme imports with
  lower_list_introduction; native_frontier_ratchet (#12184) repointed to std.algebra.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gunbai-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
… into session/zesty-stag-363

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…required-regen (the moved freemonoid_empty / list_append / list_snoc_item); remove a helper script the previous merge commit picked up by accident

The merge queue dequeued #12208 on 'Stage0 mirrors match what this seed emits' (FAIL generated
surface drift: std_algebra.rs). Regenerated at a033fa1: round 1 drifted on std_algebra.rs only,
round 2 reported first_generation_equal=true (planned=161 adjudicated=161).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gunbai-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
…ge (review 71421 on #12283); on neither main nor #12208's head

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
briansrls pushed a commit that referenced this pull request Sep 26, 2026
…ucer class

v2 Foundation Mgr attributed gunbc#12210's cost by a controlled comparison this lane did
not run: v2.std.compilers.target_model at 43 seconds on main, 54 with #12208 alone, and a
TIMEOUT at 30 minutes with #12208 plus #12210, so the cost arrives with #12210 and not with
#12208. A declaration split flagged 54 declarations, of which 26 exceed a 2-minute cap
against about 0.2 seconds without #12210, and every one of the 26 is function literals
passed as ordinary call arguments and nested inside each other. Cost multiplies per nesting
level, about 6 seconds at two levels to timeout at five or more.

That is corroboration rather than a second telling. It reaches the same multiplicative shape
this row measured -- 0.2, 0.6, 3.2 and 24.1 seconds over depths 1 to 4 against a
nested-match control flat at 0.2 -- by a different method, on a different subject, in a
different binary. Two independently derived measurements agreeing on the shape is why the
attribution is admitted without re-deriving it, and why the ON/OFF pair prepared here is
WITHDRAWN UNRUN: spending a build to re-derive an attributed cause is the redundant work
DESIGN section 2 forbids.

The repair in progress has each function literal lower its own body ONCE instead of
re-entering the general walker, which names a body-lowering boundary. So by this row's own
refinement clause it refines INTO body_producer_work_is_not_bounded_by_its_declared_input
rather than standing beside it, and that row's confirmed specimen is restored by a different
route than the census evidence withdrawn from it yesterday: the candidate that survived is
re-entry into a general walker, while the separating experiment's two candidates, node count
and spine depth, remain refuted. The ordered-choice and memo candidates are now SUPERSEDED
rather than merely unproven, and parse is not the paying stage.

Neither row reports the class as climbed. The repair is unpushed, its verification is the 54
flagged declarations rerun against #12208 alone, and 28 of those 54 have no stated
disposition. The tiny fixtures stay as the INDEPENDENT regression ladder: the nested ladder
must return to about 0.2 seconds AND the nested-match control must stay unchanged, because
the ladder alone is satisfiable by a policy cap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…es.dag keeps main's any, moved fns stay on std.algebra

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Sep 26, 2026
Merged via the queue into main with commit 575fc48 Sep 26, 2026
5 checks passed
@gunbai-bot
gunbai-bot Bot deleted the session/lively-koi-275 branch September 26, 2026 14:52
gunbai-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
…n's; the retired lambda / fn-literal chunks stay retired; warm producers kept
gunbai-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
…roducer roster keep the stack's #12210 retirements and additions; std_algebra.rs mirror verified by --required-regen
gunbai-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
…idue, not in main's #12208 and not part of this PR

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@briansrls
briansrls restored the session/lively-koi-275 branch September 26, 2026 22:40
gunbai-bot Bot pushed a commit that referenced this pull request Sep 30, 2026
… duplicate RFM; partition 21/3

Addresses GitHub review 5369451225.

Co-Authored-By: Claude Opus 5.5 (1M context) <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