Skip to content

Bind the classifier-equivalence invariant and close the invalid-JSON target arm (deferred #1044 review suggestions) #1057

Description

@The01Geek

Follow-up to PR #1044 (issue #1006), which re-keyed pin retirement on site identity. Its review graded these 🟡 Suggestion and they were not merge-blocking; captured here rather than dropped. Both are about future drift, not current correctness — the change's own negative control (a literal retired at its own site is still reported) was verified before merge and covers today's behavior.

1. The classifier-equivalence coupled invariant has no binding test

test_resolved_target_token_matches_the_classifier_three_shapes asserts _resolved_target_token / _site_retirement_key against hardcoded literals ("docs/x.md", "/__pin_corpus_runtime__/CI_BUNDLE") rather than against what the classifier actually produces. So the two are only coincidentally in agreement: a change to the classifier's target resolution would leave this test green while retirement keying silently diverged from it.

This is the repo's own coupled-invariant hazard — two sites that must agree, with the test asserting one side's literal instead of binding them. The fix is to derive the expected token from the classifier in the test, so a divergence cannot pass.

Why it matters more here than usual: retirement keying is a security-adjacent gate. A silent divergence between "how a target is classified" and "how a retirement is keyed" reopens exactly the class of mismatch #1006 existed to close — a pin poisoned or spared by the wrong key — and it would present as an unsatisfiable finding with no exit, the original symptom.

2. Fail-closed coverage gap: invalid-JSON resolved_target cell

test_malformed_retirement_manifest_site_fields_fail_closed exercises the source-side JSONDecodeError and the non-string source/target arms, but not an invalid-JSON resolved_target cell — the json.loads(row[target_index]) decode-error arm. Bundle-target retirements are the rows that carry a non-trivial target, so this is the arm most likely to meet a malformed cell in practice.

3. Informational — docstring nit

_repo_relative_or_none's docstring calls itself "the one copy of the abspath/commonpath/relpath computation the file otherwise repeats" while the same sentence points at a genuine second, raising copy (_relative_target_path). Behavior-inert; the accurate phrasing is "the non-raising copy".

Acceptance Criteria

  • The classifier-equivalence test derives its expected token from the classifier rather than from hardcoded literals, so a divergence between target classification and retirement keying turns the test RED. Prove it is binding: change the classifier's resolution and confirm the test fails.
  • The invalid-JSON resolved_target decode-error arm is exercised and asserted to fail closed.
  • Neither change re-adjudicates any individual pin (out of scope, per Pin retirement is keyed by literal while revival authorization is keyed by site #1006) and neither weakens the own-site negative control — a literal retired at its own site must still be reported, with that assertion still discriminating.
  • The docstring is corrected.
  • lib/test/run.sh reports zero failures and zero skips.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions