#6898

code-modernization: Rules traced counts all P0 rules against modules no rule is tied to (reimagine infra services can never be PROVEN)

Openpiotrlaczykowskiopened 4d ago

Plugin: code-modernization 1.0.0, scripts/trace_rules.py (module_view, ~line 431) as used by proof_pack.py check 2 "Rules traced"

When nothing ties any rule to a module by name, the module "answers for" every rule (tied = False, "nothing ties a rule to it by name, so every rule counts"). On the reimagine track this hits every infrastructure service that implements no business rule (deploy charts/hook, a sync protocol package, ops scripts): they get Rules traced: 84 of 84 P0 rule(s) are not named by any test: RULE-001, ... and can never be PROVEN.

The only ways to make the check pass are to name business rules in tests of code that does not implement them (fake evidence) or to tie them in notes, which is the opposite of what the check is for.

A related false tie: a JUnit file that a monorepo script writes into one service's test-results/ but that contains another package's tests (named [RULE-273] ...) ties RULE-273 to the wrong module.

Expected: an untied module is "no business rule claimed" (pass, or a neutral N/A shown in the pack), not "answers for all rules". Uplift (whole code kept) is the only case where "all rules" makes sense. Optionally let notes declare Rules: none (infrastructure).

Activity

1
piotrlaczykowski3d ago

Proposed minimal fix. Today module_view() falls back to counting every rule when nothing ties a rule to the module ("an empty list must never pass"), which is the right default for a rewrite module, but for reimagine infrastructure services (deployment charts, CI/ops scripts, an offline sync protocol) it makes PROVEN unreachable: they would need to name all P0 rules.

Suggestion: let a person declare it, and keep the safe default otherwise. In the module's notes file (the same files trace_rules.NOTES_NAMES already reads), a line such as

Rules: none — <reason, e.g. deployment charts and migration hook; no business rule of the legacy is implemented here>

and in check_rules():

     view = trace_rules.module_view(tr, subject["rel"])
+    if not view["tied"] and subject["track"] == "reimagine":
+        why = trace_rules.declared_no_rules(subject["path"])   # the "Rules: none — reason" line, or None
+        if why:
+            return row("rules", "na", "A person declared that this module implements no business rule: %s" % why)
     p0 = [r for r in view["rows"] if r["priority"] == "P0"]

na already exists for uplifts, so the verdict logic needs no change, and the declaration is visible in VERIFICATION.md for the reviewer to accept or reject at sign-off. A module that is tied to at least one rule by name keeps today's behavior.