Skip to content

Emitter: a cloned Rc match scrutinee owes Clone on its generics wherever the match sits (native broker product_data_class E0599) - #13255

Queued
gunbai-bot[bot] wants to merge 5 commits into
mainfrom
loyal-gull-749/rc-match-clone-walk
Queued

gunbai-bot[bot] wants to merge 5 commits into
mainfrom
loyal-gull-749/rc-match-clone-walk

Conversation

@gunbai-bot

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

Copy link
Copy Markdown
Contributor

Native broker wave 2D (program: gentle-dove-36), class H: E0599 the method clone exists for enum DataEffectAdmission<C, T>, but its trait bounds were not satisfied at gunbc.product.data_class admit_data_effect. Checked first, as asked: gunbc#13078's head still carries this error (probed on the broker), and #13160 is the std_key_relation case, so neither covers it.

Re-derivation (DESIGN §6b)

Base emission: pub fn admit_data_effect<C, T: Clone>(classified: Rc<Classified<C, T>>, sink: Rc<Sink<C>>, …), whose fold step is |acc: Rc<DataEffectAdmission<C, T>>, c| match (*acc.clone()).clone() { … }. Cloning the scrutinee needs DataEffectAdmission<C, T>: Clone, so derive(Clone) needs C: Clone as well as T. T earned its bound from another rule (the seed stores a bare T). C occurs only in a phantom-like position (Sink<C>), so nothing bounded it.

The authority that owns this fact already exists: v1.compiler.trait_bound_witness v1_rc_match_scrutinee_clone_bound_param_names. A match whose Rc scrutinee is dereferenced and cloned owes Clone on the scrutinee type's arguments that are the fn's own generics. Its caller in v1_fn_body_derived_clone_param_names read it only when the fn body was itself a top-level match. That was a declared boundary, TraitBoundWitnessScope BoundedToDirectTopLevelMatchBody, and its stated next-rung trigger was a recursive body walker once a real specimen needed it. admit_data_effect is that specimen: the match is a fold step's body. The earliest unjustified boundary is the scope of the reading, not the rule.

Change

  • v1.compiler.emit_rust v1_fn_body_rc_match_clone_bound_param_names: walks every match in the body, with the same shape as the existing equality walker. Generous traversal, exact predicate: analyze_rc_match still decides whether the match derefs, and the pure core is unchanged. v1_fn_body_derived_clone_param_names calls it in place of the top-level-only read, so the call-forwarding rule, which re-derives a callee's bounds through this same function, inherits it.
  • v1.compiler.trait_bound_witness: TraitBoundWitnessScope / BoundedToDirectTopLevelMatchBody is deleted, as BoundedToDirectSingleCallLambdaBody was when the clone-forwarding half was widened. The notes now record the trigger firing.
  • Stage0 mirrors (v1_compiler_emit_rust.rs, v1_compiler_trait_bound_witness.rs) via claim_executor --required-regen. Pass 2 is a fixed point, so with the rebuilt emitter no other v1 seed mirror's emitted Clone bounds changed.

Control: //gunbc/instruments:native-emission-controls, emitted, built, run

control_first_refusal<A, B> matches admit_data_effect's shape. B earns Clone elsewhere because the seed stores it by value; A is carried only in a phantom ControlTag<A>, as Sink<C> is. The step matches on the cloned accumulator. Cases: no refusal keeps the seed (=7); red: the first refusal wins; red: a refused result is not admitted.

  • Before: emitted header control_first_refusal<A, B: Clone>; label exit 2, E0599: the method clone exists for enum ControlAdmission<A, B>, but its trait bounds were not satisfied.
  • After: emitted header <A: Clone, B: Clone>; label exit 0, every case held.

Two earlier fixture drafts were not discriminating: a bare value: T parameter, then a two-generic compound parameter. Both compiled on base because other rules already bounded every generic. They were replaced, not kept. A control that greens on both arms proves nothing.

Broker probe

On this head the broker crate checks with 143 errors and no product_data_class error; the E0599 at product_data_class.rs:478 is present on main. This head sits on a newer main than my earlier probes, so I am not quoting a two-arm count delta. The identity-level fact is that site's removal.

🤖 Generated with Claude Code

Brian Searls and others added 2 commits October 4, 2026 10:27
…wherever the match sits

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.

LAND on code/modeling. This is the declared scope trigger firing, not a new Clone heuristic. v1_rc_match_scrutinee_clone_bound_param_names remains the one exact predicate for whether a cloned/dereferenced Rc match scrutinee owes bounds; the new function only removes the unjustified top-level-body visibility limit by walking the finite expression tree, then unions the same answers. Keeping the walk in emit_rust also preserves the existing dependency direction rather than moving Node traversal into trait_bound_witness and creating a cycle.

The production specimen is structurally discriminating: C is not bounded by the other existing rules, the nested fold-step match needs DataEffectAdmission<C,T>: Clone, and the base emits <C, T: Clone> while the repaired head emits both bounds. The control reproduces that asymmetry with A phantom-carried and B independently bounded, and its behavioral cases prevent a compile-only fixture from standing as the whole proof. Deleting BoundedToDirectTopLevelMatchBody is correct because its named recursive-walker trigger has now fired.

Floor and generated are green. The exact-head emit-build job is still running, so treat this approval as the substantive LAND verdict and wait for the aggregate witnesses workflow before queueing.

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 5, 2026
Any commits made after this event will not be merged.
@gunbai-bot
gunbai-bot Bot removed this pull request from the merge queue due to a manual request Oct 5, 2026
@gunbai-bot gunbai-bot Bot closed this Oct 6, 2026
@gunbai-bot gunbai-bot Bot reopened this Oct 6, 2026
@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 6, 2026
Any commits made after this event will not be merged.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 7, 2026
gunbc-ci-auto-heal and others added 2 commits October 7, 2026 09:11
Union both native_emission_controls case rows; stage0 emit_rust mirror left as ours for regeneration.

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

Re-review after the approval at 6c3b5e2. The movement is main integration plus regeneration, with no new branch-owned compiler logic. Merge commit 44c317b has the approved head and current main as its parents. Its native-emission-controls resolution preserves main's generic-empty-map population and adds this PR's three rc-match-clone identities and executable cases; neither side survives only in the roster. Exact head 65e6e17 changes only the generated v1_compiler_emit_rust.rs mirror. Exact-head rust-unit-tests, generated, emit-build, floor, and aggregate witnesses all pass, including all-target lint and the stage0 fixed-point check. No blocker found.

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 7, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
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