Skip to content

matlab: mandatory 'out = x' return-convention assignments count as state_mutation (+450% vs median) — intended? #2654

Closed

Description

@squid-protocol

Found by the #2560 rosetta classification sweep (matlab #2588). Filed as a question per the sweep's flag — a second opinion is wanted before treating it as a defect.

Observation

matlab's state_mutation sits at +450% vs the corpus median — the widest deviation in the functional/misc family. Hand-decomposition of the 19 raw (pre-flux-amplification) hits: roughly 11 are the mandatory out = <name> output-assignment return convention — MATLAB has no return <value> statement; every function result IS an assignment to a declared output variable. The remaining hits are genuine plants (clear/clearvars, note=, etc.) plus the documented x3 proximity amplification (#2546) and decoy-string phantom-branch trigger (#2535).

Question

Should MATLAB's return-convention assignments count as state_mutation? Arguments both ways:

  • Count them (current behavior): MATLAB's return really is assignment; the rule is consistent with the engine's occurrence-counting philosophy; expected_signals.json has baked these counts since 2026-08-31.
  • Exclude them: no other language's return x feeds state_mutation, so cross-language comparisons systematically read MATLAB as ~5x more mutation-heavy for identical intent; a rule tweak excluding assignments to declared output variables (visible in the enclosing function [out] = name(...) signature) would align it.

If current behavior is affirmed, the resolution is a validated corpus ledger entry (return-assignment-counted-as-mutation, intended-morphology) rather than a code change — either way the shape should stop being unledgered.

Cause-key return-assignment-counted-as-mutation; found via keyword-rosetta classification.

Activity

  1. added
    question
    core-engine
    on Sep 2, 2026
  2. squid-protocol commented on Sep 4, 2026

    @squid-protocol
    OwnerAuthor

    Answer: no — the return-convention assignments should not count, and the discriminator is narrower than either option this issue sketched. Fix in #2703, corpus re-bless in squid-protocol/keyword-rosetta#47.

    Re-derived first, since the +450% here was measured pre-Batch-A and the medians have moved a long way since: matlab's state_mutation cell is now 25 against a corpus median of 2 — the widest deviation in the bias table. The hand-decomposition in this issue holds exactly: 19 raw hits, 15 of them the return convention, and #2546's ×3 flux weighting turns those into the whole cell.

    Why "affirm + ledger it" is the wrong call. The rosetta corpus makes the equivalence explicit: c writes return env;, go writes return env, matlab writes out = env;. Same statement, same probe, and matlab is the only language charged for it. That is not intended morphology — it is precisely the cross-language incomparability the harness exists to find. fortran and abap dodge it only because their corpus probes are SUBROUTINE/FORM (no return value); matlab's function out = ... is already the most faithful translation MATLAB permits, so there is nothing to fix corpus-side either.

    Why "exclude assignments to declared output variables" — the option this issue proposed — is also wrong. I measured it against real MATLAB (language-crucible's eeglab) before implementing it, and it drops 63 of 1321 hits, most of which are not returns. runica.m uses weights as the accumulator for an entire ICA loop and assigns it repeatedly; y, sphere, bias are the same. Excluding every write to an output variable would blind the metric on exactly the code where it matters.

    What shipped instead. The discriminator is not on the assignment's line — it is whether the enclosing function ever reads the name back:

    • every occurrence a bare LHS (out = env;, never mentioned again) → the return channel, dropped
    • read in an expression, out = out + i, out(i) = x, passed as an argument → working state, every hit kept

    Implemented as a matlab_return_channel entry in #2674's registry-declared _scope_filters. Results:

    • keyword-rosetta: 19 → 4 raw, cell 25 → 4. rosetta_audit 45/46 PASS with matlab the only mover.
    • eeglab: 1321 → 1306 (1.1%), and every one of the 15 drops is a terminal binding — com = '', varargout = { [] [] 0 {} [] }, name = dirName;, h = uimenu(varargin{:});, this = class(TMP, 'eegobj'). runica.m is untouched at 440 → 440. In parsepluginname the two outputs are judged independently: write-only name drops, read-back vers keeps every hit.

    Downstream, measured with bias_report.py against the fixed engine — seven cells move corpus-wide, all matlab, every one toward the median:

    metric before after median
    state_mutation 25 4 2
    cog_raw 0.22 0.055 0.06
    structural_mass 16.46 11.21 9.84
    risk_state_flux 81.53 19.72 9.44
    risk_cognitive_load 13.80 2.358 2.36

    matlab's findings row goes 7 red / 0 amber → 3 red / 1 amber. cog_raw and risk_cognitive_load land on the median, which resolves the deferral in the corpus ledger's composite-nonlinearity-amplifies-in-band-inputs entry — it excluded matlab's composites specifically because this issue's input deviation was inflating them, and it was right.

    One casualty worth recording (also in the corpus PR): main.m was state-flux-branch-weighting's cleanest per-function proof of the ×3 amplification — 12 = probe_branch's 3 raw ×3 + three functions' 1 raw ×1. That evidence only ever existed because of this defect: probe_branch's three out = k are three return k. It is retired rather than re-planted, since a matlab-only mutation added to keep the demonstration would break the 12-probe program's cross-language equivalence. go's b.go and dockerfile's per-RUN scoping remain the entry's proofs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-enginequestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions