Skip to content

fix(#367): read has_credentials from durable hit/risk vectors, not equations - #2376

Merged
squid-protocol merged 2 commits into
mainfrom
fix/issue-367-has-credentials-e2e
Aug 28, 2026
Merged

fix(#367): read has_credentials from durable hit/risk vectors, not equations#2376
squid-protocol merged 2 commits into
mainfrom
fix/issue-367-has-credentials-e2e

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #367.

Background

#367 (has_credentials SQLite column permanently 0) was closed by #381,
which read file_data["equations"]["sec_hardcoded_secrets"]. #381's test
only ever fed a hand-built equations dict, so it proved the arithmetic
but not that the real pipeline delivers that dict intact.

Population-scale validation (#1144: 718 repos, 1,201,836 files) reopened
it — has_credentials was still 100% zero, while risk_secrets_risk
had genuine nonzero values for 437 files in the same dataset.
file_data["equations"] is not a durable carrier: it's rebuilt / emptied
/ per-key del'd across several galaxyscope.py phases before
record_keeper.py reads it.

Fix

Read the durable carriers instead:

  • hit_vector["sec_hardcoded_secrets"] — raw SecurityLens count
  • risk_vector["secrets_risk"] — thresholded score; also spiked to 100
    for critical leaks via a path that zeroes the hit_vector
    (signal_processor.py:360), so both slots are checked

These are the same vectors record_keeper.py already writes as the
threat_private_info and risk_secrets_risk columns — the ones #1144
confirms carry real data. equations is kept only as a last-resort
fallback.

Tests

  • Existing positive assertion now exercises the durable path — the mock's
    equations dict deliberately has no sec_hardcoded_secrets key.
  • New test_has_credentials_zero_without_signal: both durable slots empty
    • empty equations ⇒ column stays 0 (guards against an always-on read).
  • 41/41 tests/tools_recorders/ pass; mypy / dead-key / ast-accuracy
    clean; ruff baseline regen is confirmed pure line-shift (separate
    commit).

Not in scope

#368 (binary_anomaly) has the same equations-durability bug plus its
own open question (whether scan_binary() output reaches file_data for
binary files at all). Left for a separate PR.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits August 28, 2026 09:28
…uations

#381 fixed the always-zero has_credentials SQLite column by reading
file_data["equations"]["sec_hardcoded_secrets"], verified only against a
hand-built equations dict. Population-scale validation (#1144: 718 repos,
1.2M files) showed the column still 100% zero -- file_data["equations"]
is not a durable carrier, it's rebuilt/emptied/pruned across several
galaxyscope.py phases before record_keeper.py reads it.

Read the durable carriers instead: hit_vector["sec_hardcoded_secrets"]
(raw SecurityLens count) and risk_vector["secrets_risk"] (thresholded
score, also spiked to 100 for critical leaks via a path that zeroes the
hit_vector -- so both slots are checked). These are the same vectors this
recorder already writes as the threat_private_info / risk_secrets_risk
columns, which #1144 confirms carry real nonzero data for 437 files in
the same dataset. equations kept only as a last-resort fallback.

Tests: positive assertion now exercises the durable path (mock's
equations dict deliberately has no sec_hardcoded_secrets key); new
test_has_credentials_zero_without_signal guards against an always-on
read.

Closes #367.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The #367 fix inserts ~24 lines above the pre-existing W291/RUF005
baseline findings in record_keeper.py; audit_check.py --regenerate
confirms all 10 are pure line-shifts (same file/code/message), no new
findings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine data-integrity Issues relating to RAM state or SQLite database fidelity schema Data schema updates for JSON outputs or SQLite tables labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit dae0df1 into main Aug 28, 2026
64 checks passed
@squid-protocol
squid-protocol deleted the fix/issue-367-has-credentials-e2e branch August 28, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended behavior or logic failure in the engine data-integrity Issues relating to RAM state or SQLite database fidelity schema Data schema updates for JSON outputs or SQLite tables

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG/DATA-INTEGRITY] record_keeper.py's "has_credentials" SQLite column is always False -- no producer exists

1 participant