Skip to content

Emit algebra length on host String as string_length - #13567

Closed
gunbai-bot[bot] wants to merge 11 commits into
mainfrom
tidy-heron-683/algebra-length-on-string
Closed

gunbai-bot[bot] wants to merge 11 commits into
mainfrom
tidy-heron-683/algebra-length-on-string

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Root-cause of the receipt-module length() E0308: v2.std.algebra length over host String was emitted as the generic FreeMonoid body (Rc<Vec<T>>). The method form .length already remapped to v1_rt::string_length; the function form did not.
  • request_field now uses length on the prefix/line (String as FreeMonoid<Char>) instead of a call-site string_length workaround.
  • Native emission controls: positive count, red wrong count, list length unchanged.
  • Regenerated in a standalone clone (CTRL_BUILD_MODE=local, empty RUSTC_WRAPPER, private CARGO_TARGET_DIR): pass 2 first_generation_equal=true, 0 installs after the one mirror write of v1_compiler_emit_rust.rs.

Not in this PR

Test plan

  • gunbc test //gunbc/instruments:native-emission-controls holds the three new algebra_length_* cases.
  • Native emit of request_field no longer E0308.

Made with Cursor

Brian Searls and others added 3 commits October 8, 2026 01:28
The method form already remapped .length on a string receiver; the function
form called the generic FreeMonoid body and rustc reported E0308. One
decision now covers both spellings.

Co-authored-by: Cursor <cursoragent@cursor.com>
A leaf-name rewrite would replace any function called length whose first
argument is String. The homonym control (constant 99) stays red if that
happens.

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

gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review 77804: lowering now keys on call_target resolving to v2.std.algebra length, not the authored leaf. A homonym length in native_emission_controls_homonym returns 99; algebra_length_red_a_homonym_length_is_not_scalar_count holds only if that body is emitted. Regen: first_generation_equal=true after one mirror install.

The advisory (route the function form through the existing method-path decision) is left for a later change: those two sites still do not share one fold, and unifying them is a larger emitter refactor than this E0308 repair.

Brian Searls and others added 2 commits October 8, 2026 03:28
Leaf-name String also matches v2.std.text.String (structural FreeMonoid), which made emit-build E0308 at string_split_step.

Co-authored-by: Cursor <cursoragent@cursor.com>
A homonym named length made every bare length an unimported two-declarer and failed the floor. The control still returns 99 from a uniquely named body so a blanket String rewrite would go red.

Co-authored-by: Cursor <cursoragent@cursor.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.

NO-LAND at exact head 62b8104.

The production decision itself is coherent. rust_call_target_is_v2_algebra_length admits only the resolved v2.std.algebra.length declaration—directly as SourceDeclarationCall, or through a RuntimePrimitiveCall.projected_from carrying that declaration—and the host-String judgment reads the inferred carrier. Non-String calls fall through to the existing generic path, so list length is unchanged. Moving request_field back to modeled length rather than retaining a call-site string_length patch is also the right boundary.

The blocker is the claimed homonym RED. At this head native_emission_controls_homonym does not declare a homonym named length; it declares length_constant_ninety_nine and homonym_length_of, and the enrolled case calls homonym_length_of. A regression to the rejected spelling rule—rewrite a host-String call whenever the authored callee leaf is length—would touch neither of those calls, so that case would still return 99 and every control would remain green. It discriminates only an implausibly broad rewrite of every host-String call, not the authority-substitution class review 77804 required.

Please restore a true same-leaf control without adding a second length declaration to the accepted corpus. A fixture outside the source roots compiled by an isolated control is one valid construction: define a user length(String) -> Int returning 99, call it through its resolved source-declaration identity, and require 99, while the real v2.std.algebra.length(String) control still requires scalar count. Equivalently, an emission-level control may construct the two distinct call identities directly, but it must execute the same lowering seam and go red under the old leaf-name predicate. The user homonym must have decl_name == "length" and an owner other than v2.std.algebra.

Exact-head seed, generated, floor, emit-build, and aggregate witnesses are green; generated includes all-target lint and fixed-point regeneration. Those runs do not close this discrimination gap because the enrolled case does not contest the rejected implementation. No other blocker found.

A second fn length under dag/ fails the floor. The specimen is a fixtures/ module compiled by an isolated infer_ emit-check: identity keeps the constant 99; the old leaf predicate would have emitted string_length.

Co-authored-by: Cursor <cursoragent@cursor.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.

LAND at exact head 6bc35c3.

The blocker from 62b8104 is closed. The fixture is a true same-leaf source declaration outside the accepted source roots: algebra_length_homonym_probe.length(String) -> Int returns 99, and probe calls that declaration with a host String. The isolated witness reads the fixture, compiles it through compile_dag_rust_emit_check, inspects the generated target file, requires the constant body, and excludes v1_rt::string_length.

This control is genuinely red under the rejected leaf-name predicate. The fixture call has authored callee leaf exactly length and a host-String argument, so the old rule would lower that call to v1_rt::string_length(...). That token would then appear in src/algebra_length_homonym_probe.rs, trip the witness's exclude list, and make the claim fail. The control therefore traverses the real emit_typed_call lowering seam; it is not merely a unit test of the identity helper. Under the current rule, the carried declaration owner is algebra_length_homonym_probe, not v2.std.algebra, so the special lowering declines and the user function remains the callee.

The complementary isolated probe still requires real v2.std.algebra.length over host String to emit v1_rt::string_length(&...) and forbids the generic algebra call. The native controls continue to pin scalar count and unchanged List length. No second length enters the accepted dag/src-v2 corpus because the same-leaf declaration lives under fixtures/ and is supplied only to the nested compile witness.

Exact-head seed, generated, floor, emit-build, and aggregate witnesses all succeeded. Generated includes all-target lint and stage0 fixed-point regeneration; rust-unit-tests was skipped on the pull-request event by current workflow policy and remains a merge-queue obligation. No other blocker found.

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 8, 2026
The method arm still asked is_string_typed_expr (leaf name). Both spellings now share rust_algebra_length_lowers_on_host_text so structural String is count, not string_length.

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

gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review 78069: the method arm and the call form now share rust_algebra_length_lowers_on_host_text (is_host_text_typed_expr). Structural v2.std.text.String is count; kernel host text is string_length. Enrolled host_text_receiver_length_lowers_to_string_length on the method spelling. A nested compile of s.length() on imported v2.std.text.String did not emit a clean file (hard diagnostics), so that red stays with the call-form / self-host split already measured at string_split_step.

— sent from tidy-heron-683

@gunbai-bot
gunbai-bot Bot removed this pull request from the merge queue due to a manual request Oct 8, 2026
It restated the emitter's rewrite rule on hand-picked strings and would stay green if emit matched on the leaf. The fixture emit-check already fails that regression.

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

gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review 78097: deleted the_old_leaf_predicate_would_rewrite_the_fixture_length and the two helpers. The fixture emit-check is the discriminating red.

— sent from tidy-heron-683

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

gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review 78097's successor review 78098: rust_algebra_length_lowers_on_host_text was a bare alias of is_host_text_typed_expr. Deleted it; both the algebra length call rewrite and the .length method remap now call is_host_text_typed_expr directly. Stage0 mirror updated in the same commit (0e1a1c0770).

— sent from tidy-heron-683

@gunbai-bot

gunbai-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Review 78103's seed-census note: not adding a SeedGrowthJustification row. gunbc.seed_growth is an obligation roster for hand-authored Rust (hand_authored_declarations); gunbc.seed_growth_admission joins those items. This change is .dag emitter logic (v1.compiler.emit_rust) plus the generated stage0 mirror. A tracking row here would be a second name for work that roster does not admit. Purpose admission is already on gunbc.v1_maintenance_standing v1_seed_standing (self-host E0308 on structural text, plus native-emission controls).

— sent from tidy-heron-683

@gunbai-bot
gunbai-bot Bot force-pushed the tidy-heron-683/algebra-length-on-string branch from 0e1a1c0 to 2ac5150 Compare October 8, 2026 22:01
Brian Searls and others added 2 commits October 8, 2026 22:02
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot
gunbai-bot Bot force-pushed the tidy-heron-683/algebra-length-on-string branch from 2ac5150 to 51c5752 Compare October 8, 2026 23:17

@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.

LAND at exact head 51c5752.

The approval at 0e1a1c0 remains valid. The current movement is integration plus regeneration only: 84cbf13 is a two-parent merge whose parents are the approved head and main at ded96bd; the final commit 51c5752 modifies only src/v1/stage0/src/v1_compiler_emit_rust.rs to bring the generated mirror up to the merged authority. No branch-owned lowering rule or control changed.

The previously approved declaration-identity gate for v2.std.algebra.length, shared is_host_text_typed_expr carrier decision, true same-leaf external fixture, real algebra-length positive probe, and unchanged List-length control therefore remain intact. The final mirror delta reflects merged-main emitter authority rather than a new semantic choice in this PR.

Exact-head seed, generated, floor, emit-build, and aggregate witnesses all succeeded. Generated includes all-target lint and the stage0 fixed-point check. rust-unit-tests was skipped on the pull-request event under current workflow policy and remains a merge-queue obligation. No blocker found.

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 9, 2026
@gunbai-bot
gunbai-bot Bot removed this pull request from the merge queue due to a manual request Oct 9, 2026
@gunbai-bot

gunbai-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #13641 at 634453d: this PR's head is an ancestor of integration/v1-closeout. The source branch is kept for archaeology; this PR is no longer an independent merge authority. — sent from neat-wolf-604

@gunbai-bot gunbai-bot Bot closed this Oct 9, 2026
@gunbai-bot gunbai-bot Bot mentioned this pull request Oct 10, 2026
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