Skip to content

risk_documentation becomes the per-unit coverage ratio (#2908 Phase 3) - #2938

Merged
squid-protocol merged 2 commits into
mainfrom
feat/2908-p3-equation
Sep 10, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/2908-p3-equation

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

#2908 Phase 3 — the equation. _calc_documentation is now the contract ratio (docs/risk_documentation_contract.md §1): per extracted unit, weight = (public_weight 2.0 if public else 1) + the unit's own reflection_metaprogramming hits; undocumented units expose their weight; the score is 100 × exposed/total × (1 − umbrella_shield 0.5 × doc_umbrella). No units → 0.0 emitted, n/a inferred by the reporting layer (D6). The six density-era tuning keys are gone; the call site passes units + umbrella only (D4: loc, doc_loc, fid, ownership, opaque_execution, popularity, silo and mp all leave).

One decision surfaced by measurement, folded into the formula and the contract doc: the unit population excludes synthetic slices (#2691/#2792). sqlite's CREATE_Statement buckets otherwise scored its a/b/c at 100 where the contract declares n/a — and since function_data excludes those buckets, the score could not be reproduced from its recorded inputs. The contract doc's acceptance §5 is amended to the measured n/a class (html, markdown, sqlite; dockerfile/jcl/yaml do extract units — the grammar-recognised keyword constructs #2728 kept in the population).

Measured

  • audit_score_inputs.py documentation over the corpus at this engine: 185 files, 0 residuals; every a/b/c with units reads 100 (129 files), the n/a class reads 0.0 with unit count 0 (13 files), mains read the acceptance shapes (75 / 85.71 / unweighted 75; the splits are the api-contract cells the epic surfaces on purpose).
  • Sensitivity is linear by construction: −12.5 points per documented unit of 8 — no sigmoid to turn ±1 count into ±13 points.
  • audit_risk_equations.py: _calc_documentation moved to NOT_TIER_PARAMETERIZED, confirmed tier-blind.
  • audit_length_invariance.py: documentation now checked for invariance over the whole LOC sweep (equality, not tolerance) — the length-leak row (rho −0.83) is resolved by construction; the bias-report row flips in Phase 4.

Corpus

  • rosetta_audit --allow-regressions: 46 languages, 0 regressions, 0 pre-existing, 0 broken (counts untouched — this PR is score-layer only).
  • Corpus manifest risk_documentation values are owed a re-bless (Phase 4, rosetta:rebless-owed); engine merges first per ROSETTA_AUDIT.md.

Golden masters

  • Both legs blessed via crucible_check.py --update --yes; verification re-run green (full_precision PASS, zero_dependency PASS).
  • bless_scope on each fixture: 2203 differences, 0 topological, all under Documentation Exposure and its declared aggregates (documentation, avg_documentation, exposures/documentation highest/lowest, undocumented_critical_path). 1769 files moved — every file with units re-prices, which is the point of the contract.
  • Crucible avg_documentation 7.52 → 52.36: the ratio prices real undocumented public surface that the retired density sigmoid kept near its floor (the −0.83 length leak seen from the other side). Phase 5 runs the before/after on curl + cics-genapp and decides D5 on evidence.

Tests

  • New pins: test_signal_processor.py acceptance-table test (100 / 75 / 6-of-7 / unweighted / reflection weighting / synthetic-bucket exclusion), Test 40 rewritten for the ratio; test_uef_length_invariance.py re-pinned (documentation flat 100 in the synthetic sweep at every length and tier) + an exact-equality invariance test.
  • audit_score_inputs.py documentation adapter reads the per-unit function_data columns (is_public, is_documented, state_heat_triggers); audit_documentation_inputs.py (Phase 0's decomposition of the retired formula) retires.
  • Full suite green; audit_check battery all clear; ruff baseline regenerated (one pre-existing finding's line shifted, no new findings).

Closes nothing on its own — the epic's Phase 4 (corpus re-bless + bias report) is next; #2719's dynamism intent and #2771's per-unit granularity are now live in the shipped equation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BLztFhLH42oxWBKEvwfdBb

squid-protocol and others added 2 commits September 10, 2026 06:25
The equation is docs/risk_documentation_contract.md §1, verbatim: of a file's
extracted units, the weight-share not covered by an anchored doc match, public
units double (public_weight 2.0), a unit's own reflection_metaprogramming hits
raise its weight, the doc_umbrella shields multiplicatively (umbrella_shield
0.5). No units -> 0.0 emitted; the reporting layer infers n/a (D6). The unit
population excludes the slicer's synthetic buckets (#2691/#2792) -- sqlite's
CREATE_Statement buckets otherwise read as 100 where the contract declares n/a,
and the score would not reproduce from function_data.

Leaves the equation per D4: doc_loc, ownership, opaque_execution, the LOC
denominator and sigmoid, the popularity/silo/mp multipliers, and the six
density-era tuning keys. audit_score_inputs' documentation adapter now
reproduces from the recorded per-unit columns (185 corpus files, 0 residuals);
audit_documentation_inputs.py (the Phase-0 decomposition of the retired
density formula) retires with it. audit_risk_equations confirms the formula
tier-blind; the length-invariance audit asserts documentation invariant over
the whole sweep, equality not tolerance.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BLztFhLH42oxWBKEvwfdBb
…#2908 Phase 3)

Both legs via crucible_check --update --yes; bless_scope on each: 2203
differences, all under Documentation Exposure and its declared aggregates
(documentation, avg_documentation, exposures/documentation highest/lowest,
undocumented_critical_path). Crucible avg_documentation 7.5 -> 52.4: the
ratio prices real undocumented surface the dead density sigmoid sat under.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BLztFhLH42oxWBKEvwfdBb
@squid-protocol squid-protocol added the rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge label Sep 10, 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 90ddb3b into main Sep 10, 2026
39 of 40 checks passed
@squid-protocol
squid-protocol deleted the feat/2908-p3-equation branch September 10, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant