Repository navigation
Measurement tiers (#2994): SURFACE_FAMILIES, snapshot percentiles, count relations — additive, legacy frozen - #2995
Merged
Merged
Conversation
…alaxy#2994)
Tier 1 of the measurement-tier reform: a declarative {family: [signal, ...]}
map over SIGNAL_SCHEMA's 95 names, grouping 63 of them into 22 families
(memory, cleanup, guards, danger, concurrency, connectivity, io, crypto,
ipc, time, serialization, regex, events, tests, docs, debt, mutation,
dead_code, credential, threat, ml_ai, ui). The remaining 32 are declared
exempt in SURFACE_FAMILY_EXEMPT with a one-line reason each, in four
groups: structural-shape (11), style/naming (8), ownership (1), paradigm
(3), sec_* lens duplicates (7), always-zero placeholders (2).
Both are standalone top-level constants (not nested in RECORDING_SCHEMAS),
matching the existing ENGINE_CONSTANTS/APERTURE_CONFIG pattern.
tests/core_engine/test_surface_families_contract.py is the enforced
contract: every SIGNAL_SCHEMA name in exactly one family XOR exempt, every
member/exempt entry a real SIGNAL_SCHEMA name, no fam_*/pct_fam_*/pct_vec_*/
rel_* column collides with an existing file_data column, and the 22/63/32
reconciliation is pinned.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
…entiles (gitgalaxy#2994)
Tier 1/3 (calculate_risk_vector, before the main return): sums raw_signals
(never the mitigation-suppressed exposure_vector -- families are "raw
truth by construction") into telemetry["surface_families"] per
SURFACE_FAMILIES, and derives telemetry["surface_relations"]:
guard_balance_ratio = guards / (danger + 1)
alloc_cleanup_pairing = cleanup / (memory + 1)
A suppressed legacy risk_safety_score can coexist with a nonzero `guards`
family total -- pinned by a dedicated suppression-interplay test.
Tier 2 (_compute_snapshot_percentiles, new method): ranks the 22 family
sums and 13 RISK_SCHEMA legacy-vector values into snapshot-relative Hazen
percentiles (pct = (avg_rank - 0.5) / N * 100, 2dp, ties -> mean rank).
All-zero series read 0.0 for every file (never a false-median 50); N=1
reads 50.0 for every series. Called from summarize_galaxy_metrics
IMMEDIATELY AFTER _normalize_temporal_metrics -- load-bearing ordering,
since Pass 2 rewrites risk_vector's churn slot in place and percentiles
must rank the post-normalization value. Writes
telemetry["surface_percentiles"] = {"fam": {...}, "vec": {...}}.
Both hooks are additive only: risk_vector/hit_vector/file_impact and the
summarize_galaxy_metrics return dict (the golden-mastered audit JSON) are
untouched.
The three early-return paths in calculate_risk_vector (critical-leak
override, minified override, literature override) do not compute
surface_families/surface_relations -- record_keeper.py's tel.get(...)
already defaults those to 0/0.0, so this is a deliberate scope decision
(single hook point, per the verified plan anchor) rather than an oversight.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
… (gitgalaxy#2994) Dynamic column generation, same pattern as risk_cols/hit_cols: 22 fam_<name> INTEGER, 22 pct_fam_<name> REAL, 13 pct_vec_<risk-slug> REAL, and rel_guard_balance/rel_alloc_cleanup REAL -- 59 new file_data columns, canonical order (families, then legacy-vector percentiles, then relations) shared across the CREATE TABLE, the guarded-ALTER heal, and the INSERT. folder_data is untouched. New _ensure_columns(cursor, table, col_defs) helper generalizes the existing guarded-ALTER precedent (is_zero_dependency_mode et al.) into a loop, so a pre-#2994 database gets the new columns healed in via ALTER TABLE ADD COLUMN instead of failing the INSERT. The INSERT triple-edit (row_data, column list, CREATE) reads tel.get("surface_families"/"surface_percentiles"/"surface_relations", {}) with 0/0.0 defaults, so files whose telemetry never computed tier values (the early-return paths in calculate_risk_vector) still insert cleanly. Tests: schema presence, data round-trip, missing-telemetry defaults, an ALTER-heal round-trip test (drop one column from each of the four groups, re-run, confirm both healing and correct values), and a direct unit test of _ensure_columns's idempotency. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
…2994)
Display-only section, directly below the legacy section 6 sigmoid table:
per-family repo total, files-with-signal count, P90 file value, and top
file, plus the two relations as repo medians. A percentile-semantics line
explains the snapshot-relative reading ("87" = 87th percentile of THIS
repo, not a calibrated risk threshold).
Nothing here is golden-mastered -- section 6 reads risk_vector (the
audit-recorder's hashed contract); this reads
telemetry["surface_families"/"surface_percentiles"/"surface_relations"],
which audit_recorder never touches (see the companion keyset-unchanged
guard test in test_audit_recorder.py).
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
…metry (gitgalaxy#2994) audit_recorder's output is hashed WHOLE by the golden-master corpus -- any new key breaks every master. This test proves the enforced constraint: adding telemetry["surface_families"/"surface_percentiles"/ "surface_relations"] to a file's raw pipeline state produces a byte-identical audit_recorder JSON payload, because the recorder reads an explicit whitelist of telemetry keys and never dumps the dict wholesale. Belt-and-suspenders check that none of the new tier vocabulary (fam_guards, rel_guard_balance, etc.) leaked into any key anywhere in the payload. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
…(gitgalaxy#2994) Adds "The tier model" section to docs/vectors.md: the four-tier design table, Tier 1 (SURFACE_FAMILIES, the raw-truth suppression semantics), Tier 2 (snapshot percentiles, the Hazen formula, the all-zero-series-is-0 and N=1-is-50 rules, and a firewall 50.0-cutoff migration note -- supply_chain_firewall.py is unaffected by this reform, no code change), Tier 3 (the two relations), where tiers surface, and the golden-master constraint that keeps audit_recorder's output byte-identical. Cross-refs gitgalaxy#2994 from the document's intro and References section. docs/wiki/02-09-signal-processing.md (the file:line-verified home of calculate_risk_vector/summarize_galaxy_metrics) gets a short pointer to the new tier layer and a Related Components link to vectors.md. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
…2994 signal_processor.py/record_keeper.py grew (new SURFACE_FAMILIES binding, the tier-computation block, the _ensure_columns helper, the dynamic column-gen/CREATE/INSERT additions), shifting every pre-existing baseline finding below the insertion points. Regenerated per ruff_audit.py's documented SCOPE & LIMITATIONS path (line numbers aren't stable baseline keys); confirmed zero new rule violations beyond the shifts -- the two genuinely new findings this branch introduced (an unused `# noqa: S608` and a PERF203 on the new _ensure_columns loop) were fixed in code, not baselined. Baseline count: 26 -> 22 (four pre-existing trailing-whitespace findings were incidentally fixed by edits that touched their lines). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RS9yZk89DyCmECaARkBmdB
Contributor
CodeQL's unused-variable finding on the N=1 test exposed a real semantic inversion: the count==1 branch preceded the all-zero check, so an absent surface on a single-file snapshot read 50.0 -- exactly the "absent signal must not read as mid-band" failure the all-zero rule exists to prevent. Reordered: all-zero -> 0.0 at every N (including N=1); N=1 with a nonzero value -> 50.0 unchanged. Docstring, docs/vectors.md rule text, and the N=1 test corrected (which also removes the unused idx_cog CodeQL flagged). Co-Authored-By: Claude Fable 5 <[email protected]>
Owner
Author
|
CodeQL's unused-variable nit turned out to be load-bearing: the flagged test line sat next to a semantic inversion — the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #2994 per the approved plan. Additive only — 1,348 insertions, zero deletions in legacy code paths; every
risk_*value emitted byte-identically (golden-crucible triage: the single failing check reproduces identically on unmodifieda1a2d717— the known venv/networkx leg mismatch — with zero diffs touching risk/hit/telemetry).Tier 1 —
SURFACE_FAMILIES: 22 declarative families over 63/95 signals +SURFACE_FAMILY_EXEMPT(32, each with a reason), enforced by a partition contract test. Families sum raw counts — deliberately exempt from mitigation suppression (tested).Tier 2 —
_compute_snapshot_percentiles: Hazen average-rank, 35 series (22 fam + 13 vec), all-zero series → 0.0, N=1 → 50; runs immediately after_normalize_temporal_metrics(churn-ordering commented + tested).Tier 3 —
rel_guard_balance,rel_alloc_cleanup(count÷count, mechanism-documented).DB: 59 new
file_datacolumns (dynamic generation,_ensure_columnsALTER-heal for existing DBs, round-trip + heal tested). Brief: new §6b Surface Family Profile. Docs: the tier model indocs/vectors.md+ wiki cross-ref; firewall 50.0-cutoff noted as future migration.Verification: full suite 8,593 passed / 0 failed; ruff/mypy/dead-key audits clean (baseline regen = line-shifts only; 2 genuinely-new findings fixed in code); audit-recorder keyset-unchanged guard added. Live end-to-end: scanned
db-tutorialwith the branch —fam = Σ membersexact over 1,884 checked cells, percentiles bounded with the all-zero rule confirmed in the wild (fam_cryptoabsent → pct 0.0), relations populated.Zero tuned constants in any new measurement. Follow-ups on record: optional file-split of signal_processor (legacy vs tiers) as hygiene-only PR; gpu payload tier keys; firewall percentile migration.
Supersedes #2984/#2979 (closed). Evidence chain: #2991 → #2993 → #2994; epic #2982.
🤖 Generated with Claude Code