Skip to content

feat(lint): add opt-in --require-prereg rule for rule-#9 fields#83

Merged
fyodoriv merged 1 commit into
mainfrom
feat/lint-rule-9-prereg
May 21, 2026
Merged

feat(lint): add opt-in --require-prereg rule for rule-#9 fields#83
fyodoriv merged 1 commit into
mainfrom
feat/lint-rule-9-prereg

Conversation

@fyodoriv
Copy link
Copy Markdown
Collaborator

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

  • `packages/lint/src/rule9.ts` (new) — pure functions: `parseRule9Blocks`, `classifyRule9Blocks`, `parseAllowlistFile`, `lintRule9Content`
  • `packages/lint/src/rule9.test.ts` (new) — 16 tests
  • `packages/lint/src/cli.ts` — `--require-prereg` + `--prereg-allowlist=` flag plumbing
  • `packages/lint/src/lint.ts` — re-export rule9 module
  • `packages/lint/README.md` — opt-in section, summary table row

Test plan

  • `npm run build -w packages/lint` — clean
  • `npm test -w packages/lint` — 62/62 (16 new + 46 existing)
  • `npm test -w packages/parser` — 84/84 (unaffected)
  • `npm test -w packages/mcp` — 111/111 (unaffected)
  • Default behavior is unchanged when `--require-prereg` is NOT set (one CLI test pins this)
  • Allowlist file parsing handles blank lines, comments, inline comments
  • Acceptance is treated as equivalent to Success (matches existing spec semantics)

Linked


🤖 Written by an agent, not Fyodor. Ping me if this looks off.

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._
@fyodoriv fyodoriv merged commit 5bff64d into main May 21, 2026
4 checks passed
@fyodoriv fyodoriv deleted the feat/lint-rule-9-prereg branch May 21, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant