Skip to content

the H-11 marker freshness window is hardcoded in five places with nothing tying them together #567

Description

@SUaDtL

The 30-minute H-11 authoring-marker window is declared independently in five modules:

file line
core/pysrc/pre-write.py 116
core/pysrc/pre-edit.py 207
core/pysrc/_bashguardlib.py 1084
core/pysrc/git-enforce.py 234
core/pysrc/_protectedstatelib.py MARKER_FRESHNESS_MINUTES

There is no import relationship between them and no test asserting they agree. Changing one silently desynchronizes a security window across enforcement flanks, and nothing goes red.

How it surfaced

Found during an adversarial pass on the protected-state registry (#564, workstream B1). A mutation campaign showed MARKER_FRESHNESS_MINUTES = 1000 passing the entire suite, because the freshness tests computed their expected ages from the implementation constant rather than pinning the value. That specific tautology is fixed — a direct value assertion now kills the mutant — but the fix only pins the fifth copy. The other four remain unpinned and unrelated.

The module also carried a comment claiming the window was "reused verbatim (not re-declared)". It was re-declared. The comment has been corrected to name all five declarations and state plainly that no shared source exists, so the drift is at least documented rather than denied.

Why this is worth fixing rather than documenting

The maintainer's standing direction is to move process rules out of prose "suggestions" an agent may or may not honor and into deterministic helpers and hooks — enforced rather than advised. Five hand-maintained copies of a security constant is the advised shape. A single source plus one agreement test is the enforced one.

It is also asymmetric in the dangerous direction: a narrowing drift breaks a minting lane loudly and gets fixed, while a widening drift silently extends how long a stale marker admits writes, and nothing surfaces it.

Why it was not fixed in place

The remediation agent deliberately declined the refactor and took the lower-risk option offered. The four other declarations live in H-11 and H-14 enforcement gates that run in every consumer repo on every session, the slice's scope was one library module and its tests, and the win is structural rather than behavioral. Correct call for that context; the work belongs in its own lane with its own review.

Shape

  • One constant with a single declaration, most plausibly in _hooklib beside marker_fresh itself, which is already the one freshness implementation every caller delegates to.
  • The four enforcement hooks import it rather than restating it.
  • One test asserting every flank resolves the same window, so a future re-hardcoding fails loudly.
  • Worth checking while in there whether all five should be one window, or whether any divergence is intentional and undocumented — the answer changes the fix from "share the constant" to "name the two windows".

Acceptance

  • Exactly one declaration of the H-11 window
  • All four enforcement flanks resolve it by import
  • A test fails if any flank reintroduces a literal
  • Any intentional divergence is named and separately constant-ized rather than collapsed by accident

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsev:medTribunal/triage: medium severity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions