Skip to content

rosetta[python]: cross-language consistency — 5 red / 3 amber metrics, 5 ledgered shapes #2593

Closed as not planned

Description

@squid-protocol

Part of #2560 — per-language tracking for the keyword-rosetta control corpus (built for #1096). Planted intent is identical in every language, so every deviation below is measured bias vs. the 46-language median, validated in the corpus's deviation ledger. 🔴 = beyond ±50% of the cross-language median, 🟡 = ±25–50%.

Triage order (per the epic): structure detection first, then signal/keyword rules, then risk-score consequences — §3's numbers are downstream of §1–§2 and re-baseline as those fix. Cross-cutting engine issues (e.g. #2535/#2546) fix many languages at once; this issue tracks this language's residual after each cross-cutting fix lands, and closes when the language sits inside the ±25% band on every comparable metric (or every remaining deviation is ledgered as intended morphology).

1. Structure detection (fix first)

In band — no structure-level deviations.

2. Signal / keyword deviations

  • 🔴 comment_lines: 52 vs median 30 (+73%)
  • 🔴 doc: 2 vs median 1 (+100%)
  • 🔴 io: 6 vs median 3 (+100%)
  • 🔴 state_mutation: 2 vs median 6 (-67%)
  • 🟡 safety: 3 vs median 2 (+50%)
  • 🟡 test: 3 vs median 2 (+50%)

3. Risk-exposure consequences (downstream)

  • 🔴 risk_cognitive_load: 4.821 vs median 15.1444 (-68%)
  • 🟡 risk_api_exposure: 7.35003 vs median 5.31104 (+38%)

Ledgered shapes touching python

defect type issue evidence summary
api-contextual-baseline-fix engine-semantic #2536 — galaxyscope.py ~2145 ('THE CONTEXTUAL BASELINE FIX'): a file imported by others (popularity > 0) has orphaned_logic converted into api before recording
census-requires-git-tracked engine-semantic — — GalaxyScope's census enumerates git-tracked files only; an untracked folder scans as '0 files mapped' with no per-file warning
assert-overlaps-safety-and-test keyword-overlap — — python's test rule includes \bassert\b and the safety rule includes assert: one planted assert counts both
os-sys-prefix-overlaps-io keyword-overlap — — python-family io rule matches the os./sys
string-literal-selective-shielding upstream-question #2535 — Keywords inside one string literal ('if eval fails, try open') count toward branch (+2), safety (+1), io (+1) but eval does NOT count toward high_risk_execution (routes …
Decoy outcomes (file-level evidence)
  • main.py · never calls eval and no while loop (comment): stripped: contributed 0 (prism comment stripping works)
  • a.py · could open a socket in prose only (comment): stripped: contributed 0
  • a.py · MESSAGE = "if eval fails, try open" (string): PARTIAL: if/try/open COUNT from inside the literal (branch +2, safety +1, io +1, baked into a.py expectations) but eval does NOT (feeds sec_tainted_injection instead) — literal shielding is selective by signal family; candidate upstream issue
  • b.py · the try keyword stays in prose (comment): stripped: contributed 0
  • c.py · HACK_LEVEL = level (code): reverse decoy works: identifier did not count, the # HACK comment did (fragile_debt = 1 exactly)

Reproduce / evidence

Activity

  1. added
    metrics
    core-engine
    on Aug 31, 2026
  2. squid-protocol commented on Sep 1, 2026

    @squid-protocol
    OwnerAuthor

    Sweep update (2026-08-31)

    Worked via the rosetta-language-sweep skill's five-cause taxonomy. Live numbers before starting
    (tools/language_deviations.py python) didn't quite match this issue's original body — comment_lines
    was red live but not listed in §1 above; treated the live numbers as authoritative per the skill's
    guidance.

    Before → after: 5🔴 / 3🟡 → 4🔴 / 3🟡 (37 comparable metrics).

    Fixed (bucket 1: real engine bug)

    • io: 6 → 4 (median 3). os\./sys\. matched ANY attribute access, overlapping globals'
      own os.environ/sys.argv/sys.path — a planted globals read was double-counted as io too.
      Negative lookaheads now carve out exactly those three tokens.
    • test: 3 → 2 (median 2, now in-band). \bassert\b was double-counted by both safety and
      test — a bare assert is a validation signal, not a testing-framework signal. Removed from test.
    • Engine PR: gitgalaxy#2626 (merged pending
      review). Corpus re-baseline: keyword-rosetta#13.
      Ledger: os-sys-prefix-overlaps-io (resolved for python), assert-overlaps-safety-and-test
      (python removed from languages_seen, still reproduces for c/perl).

    Not fixed — bucket 5 (median inflation elsewhere, python is honest)

    Not fixed — out of scope for this pass, filed separately

    • doc: 2 vs median 1 (+100%) — the """/''' docstring pattern counts both the opening and
      closing delimiter as separate matches. Related to the string-literal-shielding upstream question
      (#2535); not re-investigated here.
    • comment_lines: 52 vs median 30 (+73%), new finding, not python-specific: filed as
      #2625 — comment_lines = total_loc − coding_loc,
      but total_loc includes blank lines while coding_loc doesn't, so blank lines get folded into
      "documentation" engine-wide. Python's corpus shells just have a higher blank-line ratio than most
      language shells, so it surfaces loudest here (jcl's own §10 capstone independently noted the same
      root cause for its comment_lines residual).
    • risk_api_exposure/risk_cognitive_load (§3): downstream shadows of the above; not chased
      individually per the epic's rule.

    Remaining blocked on

    Closing criterion: not met yet — io is now amber (not green), safety/doc/comment_lines
    remain out of band, all blocked on cross-cutting issues rather than anything left to do in python's
    own rule file. Leaving this issue open pending #2546/#2535/#2625; re-run
    tools/language_deviations.py python after any of those land to see if python re-baselines into
    band on its own.

  3. squid-protocol commented on Sep 1, 2026

    @squid-protocol
    OwnerAuthor

    Choreography completed (2026-09-01)

    Follow-up to the sweep update above — the cross-repo loose ends are now closed:

    Issue state unchanged per the close-criterion note above: stays open, blocked on the
    cross-cutting fixes (#2546 safety/state_mutation medians, #2535 doc, #2625 comment_lines) —
    re-run tools/language_deviations.py python after any of those land.

  4. squid-protocol commented on Sep 3, 2026

    @squid-protocol
    OwnerAuthor

    Status: 1🔴 / 2🟡 unexplained, 5 further out-of-band cell(s) accounted for

    Generated from docs/bias_data.json + deviation_ledger.json by tools/issue_status.py, using the same verdict machinery bias_report.py --gate runs on (gitgalaxy#2669 E.1), so this comment and the gate cannot disagree about what is left.

    Still unexplained — the work this issue tracks

    metric value median dev group
    🟡 keyword_hits 197 148 +33% structure
    🟡 betweenness_score 0.05 0.08333 -40% signals
    🔴 risk_api_exposure 9.061 5.289 +71% risk

    Out of band, but accounted for

    ledgered — a validated ledger entry names this language and this metric

    • cog_raw — composite-nonlinearity-amplifies-in-band-inputs
    • control_flow_ratio — control-flow-ratio-denominator-is-a-vocabulary-tally
    • risk_cognitive_load — path-and-extension-modifiers
    • risk_documentation — path-and-extension-modifiers
    • structural_mass — composite-nonlinearity-amplifies-in-band-inputs

    Close criterion (gitgalaxy#2669 Batch E.4)

    python tools/language_deviations.py python exits 1: 3 unexplained cell(s) remain. Each needs a fix, or a validated ledger entry saying why it is correct, before this issue can close.

  5. squid-protocol commented on Sep 6, 2026

    @squid-protocol
    OwnerAuthor

    Closed 2026-09-06 as superseded by #2812 (docs/contract_roadmap.md, decision D2). Every out-of-band cell for python is accounted for (the gate reads 0 unexplained) and is now tracked by cause family, not by language: the ledger entry that explains it, its cause category in keyword-rosetta's docs/bias_data.json["cell_categories"] (echo / inherency / extraction / correlation / scoring), and the family issue #2812 lists for that cause. Live standing at any time: python tools/language_deviations.py python in keyword-rosetta, or docs/findings_by_language.md#python.

    This is a change of axis, not a claim that python is green. The §10 capstone in docs/language_status/python.md is written when the language reads clean by language_deviations.py, by whichever family PR gets it there — no longer tied to this issue.

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-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions