Repository navigation
Description
Roadmap Phase 3 (docs/contract_roadmap.md, epic #2812), next by the mechanical audit after the raw_state_unreferenced census (#2866): the safety row is draft and carries 2 of the report's 19 open-defect cells (embedded_python 4 vs median 2, haskell 3 vs 2; both extraction in the cause table).
_c("safety", "safety", "site", "Defensive programming constructs that prevent crashes at runtime", planted=True)Consumers: the high_risk×safety proximity pair's silencer dampeners (spatial_correlation.py:215 — safety positions dampen amplified-RCE hits), _calc_safety (WEIGHT_DEFENSE, fidelity-weighted), the safety_score formula (verification·fid_test + safety·fid_safety − bypassed·2.0), FIDELITY_SIGNALS, the "Error & Exception Exposure" report row, the statistical_auditor extraction-density group.
The two open cells (finditer verdicts against corpus main)
- embedded_python = 4 (a.py 2 + b.py 2) — two diseases:
- a.py's single planted guard
assert isinstance(value, int)records 2: the rule's bareassertand bareisinstanceboth fire on one statement. One defensive statement is one site. - b.py's two bare
except:— the safety_bypasses plant, the anti-safety marker — also count as safety (exceptsits in both rules; manifest records the dualsafety: 2, safety_bypasses: 2). A swallowed exception is the opposite of a runtime guard; one owner.
- a.py's single planted guard
- haskell = 3 (a.hs 2 + c.hs 1) — two diseases:
- a.hs's "plant" is only a type signature:
probeSafety :: Maybe Int -> Either Int Int(body= 0, nothing defensive at the value level) records 2 via theMaybe/Eithertype constructors. A type annotation is not a runtime defensive construct — the ledger already states this from the typescript side (typescript-type-keywords-count-as-safety:unknown|never|voidcounted as guards, explicitly deferred to be "audited with" this family) and it is state_mutation corollary 2's shape (IORef Intin a signature is not a write). The plant was authored to the old rule and needs a genuine value-level guard. - c.hs's
finally— cleanup's plant — double-counts as safety (ledgerhaskell-finally-dual-cleanup-safety, keyword-overlap, still reproduces).
- a.hs's "plant" is only a type signature:
Also visible from main without a red cell: haskell's rule counts bare pure and return (the two most common words in any Haskell file) and the bare data constructors Just|Nothing|Right|Left (a constructor in an ordinary expression, not a handled-absence site); embedded_python's bare getattr/hasattr are reflection reads, not guards. The full 46-language rule_probe sweep lands in docs/safety_rule_contract.md's audit table.
What the contract must state
- One hit is a site that handles or forestalls a runtime failure — a guarded region (try/catch/bracket), a runtime assertion or validation call, a handled-absence branch, a watchdog — at the value level, in a form an ordinary identifier cannot match.
- Statement, not tokens (the a.py shape): a guard statement with a validation call inside it is one site.
- Value level, not type level (the a.hs/typescript shape): a type annotation (
Maybe,Either,unknown,never) is invisible; the handled-absence branch (fromMaybe, a totalcasewith theNothingarm, a null-check) is the site. - One owner (the b.py/c.hs shape): a bare/broad
exceptis safety_bypasses'; a cleanup combinator (finally,ensure,defer) is cleanup's; the runtime guard the language ships (assert) is safety's, never test's (test has no stated contract: c and embedded_python count safety's planted assert, and perl's Test::More::ok( fires the rule twice #2852's boundary, from the other side). - The ambiguity anchor: everyday words (
try,catch,mask,pure,return) fire only in their guard form. - Stated absence where the language has no runtime-failure surface (markdown is the existing n/a; the audit decides if any join it).
Done in the #2765/#2841/#2852/#2858/#2866 shape
docs/safety_rule_contract.md, the sheet row → stated, one cross-language test_safety_contract_<N>.py, engine PR labelled rosetta:rebless-owed, corpus PR with the re-plants (haskell's value-level guard; embedded_python's single-count guard) and both cells' ledger entries resolved. Expected: safety open defects 2 → 0, every corpus language reading 2. Watch the layer boundary: safety positions feed the proximity dampeners, so the bless scope must name only safety + the dampened pair's formulas; and safety_bypasses (planted, same files) must not move.
Activity