Skip to content

feat(core): recorded signal counts are raw counts; proximity weights move to a weighted view (#2813, D1) - #2815

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2813-raw-counts
Sep 6, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/2813-raw-counts

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2813

Part of #2812 (contract roadmap Phase 2, decision D1). One layer per PR: this is the correlation → score boundary; no rule regex, slicer or formula changes.

What changes

A recorded signal count is a count. The six proximity pairs in core/spatial_correlation.py used to add their weights into counts[...] in place (×3 cascading flux, the silencer dampener, the ×5 / ×100 / +1 amplifiers), so state_mutation in file_data, every recorder, both golden masters and every keyword-rosetta manifest was raw + 2 × cascading — a score wearing a count's name. They now write only to the per-file mitigation_telemetry tally.

  • core/spatial_correlation.py: PROXIMITY_WEIGHTS (signal → tally key × weight), weighted_count(), weighted_view(). apply_dampener_correlations / apply_amplifier_correlations lose their counts parameter. Block 0 tallies under its own key amplified_exfiltration: amplified_leaks is the Active Hemorrhage's key (galaxyscope.py Phase 5.5) and the two used to share it, so a weighted memory_scraping could not be told apart from a hemorrhaging secret.
  • metrics/signal_processor.py: _weighted() builds the score-layer view once per file from raw_signals + mitigation_telemetry; every _calc_*, the structural-magnitude file_mass and the archetype fingerprint read it. hit_vector carries the raw counts.
  • Consumers that combine counts into a derived number also read the weighted view, so nothing downstream moves: security/security_auditor.py (the ML feature frame — the trained model saw weighted inputs; dropping that is a retrain, not this fix) and metrics/statistical_auditor.py (the outlier / dead-code / threat gates).
  • Telemetry fix found on the way: signal_processor.py wrote the galaxyscope:ignore suppression list into telemetry["mitigation_telemetry"], not the detector's tally dict — so "6. Contextual Mitigations & Amplifications" read None Detected for all 2,817 golden-master files and the docs(core): document + pin the ×3 cascading-flux weighting (closes #2546) #2631 "raw is recoverable from telemetry" promise never reached the report. The slot now carries the tally (suppressions folded in as 1-tallies, the shape the recorders already accept).
  • Recorders (item 3 of the issue): telemetry["weighted_signals"] holds the weighted figure for each adjusted signal under its own key; the audit report shows it in section 6 beside the tally (State Mutations / Variable Reassignments (Weighted View): 7), the LLM brief likewise. SQLite / SARIF / section 7 are the raw counts. The section-7 label still says "(Net Mitigated Signals)" — renaming that JSON key touches every file in both golden masters and belongs with the README copy in Phase 5.
  • Docs: core/README.md proximity table (tally key + weighted view columns; the two same-shaped adjustments that remain in place — rce_funnel ×50 in coding_analysis() and the Active Hemorrhage — are named), signal_contracts.py STREAM_CONTRACT corollary 3 (+ re-rendered docs/signal_contracts.md), how_to_add_a_language.md RULE 18.

Proof (as specified in #2813)

Both golden masters: every risk_* column byte-identical. The bless diff (uncapped, golden_diff.deep_compare) touches only two sections per file:

golden master total diffs 6. Contextual Mitigations (None Detected → tally) 7. Structural Signatures anything else
full precision 2,822 1,187 1,635 0
zero dependency 2,822 1,187 1,635 0

Section 7 (full precision) moves exactly the five signals the weight table names, each in the predicted direction, across 42 languages: state_mutation ↓ 1,096 files, high_risk_execution ↑ 147 (the silencer no longer subtracts), memory_alloc ↑ 120, concurrency ↓ 137, sec_tainted_injection ↓ 135. No topological coordinate, structural magnitude, archetype, drift or ecosystem-summary line moved.

  • tests/core_engine/test_signal_processor.py::test_signal_processor_weighted_view_is_score_neutral: raw + tally scores byte-identical to the old weighted counts (risk_vector, file_impact, archetype fingerprint), hit_vector raw, telemetry carries both.
  • tests/core_engine/test_spatial_correlation.py: the five docs(core): document + pin the ×3 cascading-flux weighting (closes #2546) #2631 flux pins assert the tally + weighted_count(); one new pin per pair reproducing the old recorded value; the weight table itself.
  • tests/tools/audit_risk_equations.py, audit_length_invariance.py: unchanged (both pass).
  • keyword-rosetta, verified locally against this branch (PYTHONPATH shadow, full-precision venv): verify_language.py 45/46 PASS. The one mismatch is the predicted shape: agc_assembly c.agc memory_alloc expected 0, got 1 (the alloc a same-function cleanup mitigates is now recorded raw; the mitigation is in the tally). state_mutation already lands on its pinned value in all 46 languages — the ledger's 21-language list under state-flux-branch-weighting is decayed: since fix(standards): stop counting bare return as branch in 6 languages (closes #2545) #2634 dropped return from branch, the ×3 no longer fires on any corpus file, which is exactly what Phase 0's decayed-entry check is for.

Found on the way

  • Dead C preprocessor branches (#if 0) are counted at file and function level; the macro shield only serves brace matching #2814 — test_detector_c_macro_dead_branch_shield passed only through the silencer: the strcpy in a #if 0 branch is counted at file and function level, the macro shield only serves brace matching. The test now pins the actual behaviour and points at the issue.
  • The issue's expectation that ~21 corpus languages' state_mutation would drop to the planted 2 was based on a decayed ledger entry; the corpus effect is one cell (above). The crucible (real repositories) is where the weights actually fired: 1,096 files' state_mutation.

Cross-repo

🤖 Generated with Claude Code

…move to a weighted view (#2813, D1)

The six proximity pairs in core/spatial_correlation.py used to add their
weights into counts[...] in place (x3 cascading flux, the silencer dampener,
the x5 / x100 / +1 amplifiers), so state_mutation in every recorder, both
golden masters and every corpus manifest was raw + 2 * cascading. They now
tally only; PROXIMITY_WEIGHTS + weighted_count() give the score layer the
figure the recorded count used to carry, so every risk_* column, structural
magnitude and coordinate in both golden masters is byte-identical (2,822
diffs each, all in the per-file mitigation/signature sections).

Also: signal_processor wrote the galaxyscope:ignore list into the
mitigation_telemetry slot, so the audit report's section 6 was None
Detected for all 2,817 files; it now carries the detector's tally plus a
weighted_signals block. Block 0 tallies under amplified_exfiltration
(amplified_leaks is the Active Hemorrhage's key). test_detector's dead-branch
test passed only via the silencer; pinned against #2814.

Closes #2813

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@squid-protocol squid-protocol added metrics Heuristics, risk exposures, and topological math updates core-engine Modifications to the central physics and parsing engine rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit d55b53e into main Sep 6, 2026
71 checks passed
@squid-protocol
squid-protocol deleted the fix/2813-raw-counts branch September 6, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-engine Modifications to the central physics and parsing engine metrics Heuristics, risk exposures, and topological math updates rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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)

1 participant