Skip to content

spatial_correlation.py edits recorded signal counts in place — move the proximity weights to the formulas so a count is a count (roadmap Phase 2, D1) #2813

Closed

Description

@squid-protocol

Part of #2812 (Phase 2; decision D1 in docs/contract_roadmap.md, approved 2026-09-06). Pairs with #2765, which cannot be answered while the number it is asking about already carries a weight.

The leak

core/spatial_correlation.py runs six proximity pairs after detection (documented in core/README.md's proximity table; the ×3 flux was documented and pinned by #2631 for #2546) and writes the result into the recorded signal count:

# Block 6, The OOM Bomb
counts["state_mutation"] += cascading_flux * 2   # +2 on top of the raw hit = x3 net
mitigations["amplified_cascading_flux"] = mitigations.get(...) + cascading_flux

So state_mutation in file_data, every recorder (SARIF, SBOM, SQLite, the LLM brief), both golden masters and every keyword-rosetta manifest is raw + 2 × cascading, not a count. The same shape applies to the silencer dampener on high_risk_execution and the race/exfiltration amplifiers. #2631 made the raw count recoverable (raw = recorded − 2 × amplified), which was the right first move; this issue is the second: the recorded number becomes the raw count and the weight is applied where it is consumed.

Why it matters beyond tidiness: the corpus plants two mutations per language and reads 2–6 depending on whether a decoy string sits within 150 characters of them (ledger state-flux-branch-weighting, 11 cells; string-literal-selective-shielding, 38 cells after #2535's re-reading). A weighted count cannot be held equal by any corpus, and a contract for state_mutation (#2765) written against it would be a contract for a score.

Fix shape (score-neutral by construction)

  1. spatial_correlation.py: apply_dampener_correlations / apply_amplifier_correlations stop mutating counts; they write only to mitigations (the keys already exist: amplified_cascading_flux, amplified_race_conditions, amplified_leaks, amplified_rce, the mitigated counts).
  2. signal_processor.py: one helper, _weighted(raw_signals, mitigations, key), returning exactly what the recorded count used to be (state_mutation: raw + 2 × amplified_cascading_flux, etc.). Every consumer of an affected signal reads it — _calc_state_flux, the flux density at ~L1382, the tech-debt term at ~L1431, the bottleneck ledger at ~L1940, spatial_correlation.py's own downstream reads at L164/L273, and security_lens.py if it reads the recorded value.
  3. Recorders: keep a weighted figure under its own key (state_mutation_weighted or the telemetry block) so user-facing SARIF/SBOM numbers do not change meaning silently; the audit report's "Contextual Mitigations & Amplifications" already shows the components.
  4. tests/core_engine/test_spatial_correlation.py: the five docs(core): document + pin the ×3 cascading-flux weighting (closes #2546) #2631 pins move from asserting counts[...] to asserting mitigations[...] + the helper's output; add one pin that _weighted() reproduces the old recorded value on the same fixtures.
  5. core/README.md proximity table: "recorded count" column becomes "weighted view".

Proof

  • Both golden masters: every risk_* column byte-identical before and after; the bless diff is signal-column-only (attribute per language before blessing — CLAUDE.md "Scoping a bless").
  • keyword-rosetta: state_mutation lands on the planted 2 in the ~21 languages the ledger lists; state-flux-branch-weighting flips still_reproduces: false with the verifying scan; the report's correlation category goes to 0.
  • audit_risk_equations.py, audit_length_invariance.py unchanged.

Label rosetta:rebless-owed; corpus re-bless PR against engine main after merge.

Activity

  1. added
    enhancement
    metrics
    core-engine
    on Sep 6, 2026
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-engineenhancementmetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions