feat(lint): add opt-in --require-prereg rule for rule-#9 fields#83
Merged
Conversation
Lift the rule-#9 pre-registration check (Hypothesis, Success/Acceptance, Pivot, Measurement, Anchor) from Minsky's repo-local scripts/check-rule-9-tasksmd-fields.mjs into @tasks-md/lint as a first-class opt-in rule. The pattern prevents post-hoc fishing for flattering metrics (Munafò et al. 2017) and pre-registers the give-up criterion (Ries 2011, pivot-or-persevere) by forcing the team to declare what observable a non-trivial change is expected to move *before* the code is written. spec.md § rule-9-pre-registration-block already documents the fields (PR #78); this PR ships the deterministic gate. Why it's opt-in: - Most TASKS.md files won't want every task pre-registered. Teams that want machine-enforced rule-#9 discipline pass `--require-prereg`. - Adopting on an existing repo is a two-step ratchet: `--prereg-allowlist=<file>` grandfathers legacy IDs while preventing *new* tasks from regressing. Allowlisted blocks still surface in the count so the operator sees remaining backfill debt. Surface: - `tasks-lint --require-prereg TASKS.md` — enforce the five fields - `tasks-lint --require-prereg --prereg-allowlist=.prereg-allowlist TASKS.md` — ratchet adoption - `import { parseRule9Blocks, classifyRule9Blocks, parseAllowlistFile, lintRule9Content } from "@tasks-md/lint"` — programmatic API Tests: 16 new tests (62 total in @tasks-md/lint); parser/MCP unaffected. --- _🤖 Written by an agent, not Fyodor. Ping me if this looks off._
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this is needed
spec.md § rule-9-pre-registration-block (PR #78) documents the five rule-#9 fields — Hypothesis, Success / Acceptance, Pivot, Measurement, Anchor — but there's no deterministic gate that enforces them. Without the gate, the rule is just spec — operators silently drop Success or Pivot and the rule degrades to wish-list. This PR ships the gate.
The pattern prevents post-hoc fishing for flattering metrics (Munafò et al. 2017) and pre-registers the give-up criterion (Ries 2011, pivot-or-persevere) by forcing the team to declare what observable a non-trivial change is expected to move before the code is written.
The check has been running successfully in Minsky's repo as a repo-local script (`scripts/check-rule-9-tasksmd-fields.mjs`) for six weeks. This PR lifts the logic into `@tasks-md/lint` so any team can adopt it without copy-pasting a script.
Why opt-in
Most TASKS.md files won't want every task pre-registered — the rule is for teams that want machine-enforced rule-#9 discipline. The flag keeps default behavior unchanged and signals adoption explicitly.
Adopting on an existing repo is usually a two-step ratchet — `--prereg-allowlist=` lets you grandfather legacy task IDs while preventing new tasks from regressing. Grandfathered blocks still surface in the count summary so the operator sees remaining backfill debt without breaking the build.
What
Surface
```bash tasks-lint --require-prereg TASKS.md # enforce the five fields tasks-lint --require-prereg --prereg-allowlist=.prereg-allowlist TASKS.md # ratchet adoption ```
Programmatic API (re-exported from `@tasks-md/lint`):
```ts import { parseRule9Blocks, classifyRule9Blocks, parseAllowlistFile, lintRule9Content } from "@tasks-md/lint"; ```
Output
``` Checked 1 file(s), found 2 error(s) rule-#9 pre-registration: scanned 12 block(s); clean=8, grandfathered=2, blocking=2 ```
Per-block errors:
``` ERROR: TASKS.md: rule-#9 task 'metrics-endpoint' missing Pivot, Anchor; add the field(s) — see https://github.com/tasksmd/tasks.md/blob/main/spec.md#rule-9-pre-registration-block ```
Files changed
Test plan
Linked
🤖 Written by an agent, not Fyodor. Ping me if this looks off.