Public: anyone can read this; the crew can change it.

Automate a review finding as a lint or test: Direction: the owner says pipeline first (#6534, #6611, #5276, #3316, #6217, #64 #13377

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The "pipeline first" check already existed (directionRefusal in scripts/gate.ts, rule in src/kernel/direction.ts, from #11037 and #12365). It only fired on pages added to the tree. Reviewers kept repeating the comment because of that gap: #10380, a page redesign, edits an existing page and passed untouched.

Notes

shipped production is serving it deploy 59903fa

opened this

The "pipeline first" check already existed (directionRefusal in scripts/gate.ts, rule in src/kernel/direction.ts, from #11037 and #12365). It only fired on pages added to the tree. Reviewers kept repeating the comment because of that gap: #10380, a page redesign, edits an existing page and passed untouched. This pull closes that gap.

What changed

  • directionProblems now takes the changed-line count per file. An existing page (src/web/pages/.ts), TUI screen or docs/features/.md with 150 or more changed lines counts as a feature, like an added one (REDESIGN_LINES in src/kernel/direction.ts).
  • directionRefusal in scripts/gate.ts now passes those counts, read from git diff --numstat.
  • The refusal text is unchanged, so the failure still names rule "pipeline first". It tells the author to change the pipeline or add a Direction: <why this goes ahead of the pipeline items> line of 10+ characters to a commit message.
  • The "small and single-purpose" cap (MAX_FEATURES, MAX_FILES) applies to the waived redesign too.
  • test/direction.test.ts has a new test that fails without the change. A 150-line edit is refused, a 149-line edit passes, a Direction line waives it, and a pipeline change passes it.

Checks run: test/direction.test.ts and test/direction-refusal.test.ts pass (8 tests). bun x tsc --noEmit is clean. bun scripts/gate.ts --fix reported nothing to rewrap.

Left out

  • Small edits to existing pages stay unasked. The existing test says edits are never asked, and a bug fix should not need a waiver.
  • New non-page web components (src/web/*.ts) and MCP tools are not counted as feature surfaces.
  • The 150-line threshold is a judgement call, easy to tune.
  • The Direction line is still read from commit messages only, not from the pull description.
  • I did not add a plan with keep_plan or record an estimate.

Try it: on a branch, rewrite more than 150 lines of any src/web/pages/*.ts with no pipeline change, then run bun scripts/gate.ts. It fails naming rule "pipeline first".

Closes #13375

2 earlier comments · 2 events
commented

The "pipeline first" check already existed (directionRefusal in scripts/gate.ts, rule in src/kernel/direction.ts, from #11037 and #12365). It only fired on pages added to the tree. Reviewers kept repeating the comment because of that gap: #10380, a page redesign, edits an existing page and passed untouched. This pull closes that gap.

What changed

  • directionProblems now takes the changed-line count per file. An existing page (src/web/pages/.ts), TUI screen or docs/features/.md with 150 or more changed lines counts as a feature, like an added one (REDESIGN_LINES in src/kernel/direction.ts).
  • directionRefusal in scripts/gate.ts now passes those counts, read from git diff --numstat.
  • The refusal text is unchanged, so the failure still names rule "pipeline first". It tells the author to change the pipeline or add a Direction: <why this goes ahead of the pipeline items> line of 10+ characters to a commit message.
  • The "small and single-purpose" cap (MAX_FEATURES, MAX_FILES) applies to the waived redesign too.
  • test/direction.test.ts has a new test that fails without the change. A 150-line edit is refused, a 149-line edit passes, a Direction line waives it, and a pipeline change passes it.

Checks run: test/direction.test.ts and test/direction-refusal.test.ts pass (8 tests). bun x tsc --noEmit is clean. bun scripts/gate.ts --fix reported nothing to rewrap.

Left out

  • Small edits to existing pages stay unasked. The existing test says edits are never asked, and a bug fix should not need a waiver.
  • New non-page web components (src/web/*.ts) and MCP tools are not counted as feature surfaces.
  • The 150-line threshold is a judgement call, easy to tune.
  • The Direction line is still read from commit messages only, not from the pull description.
  • I did not add a plan with keep_plan or record an estimate.

Try it: on a branch, rewrite more than 150 lines of any src/web/pages/*.ts with no pipeline change, then run bun scripts/gate.ts. It fails naming rule "pipeline first".

Changes requested — before the latest push

The rule is sound and the unit test fails without the change. Two things to fix in one round: (1) the numstat wiring in scripts/gate.ts is untested, and (2) it mis-keys renamed files. No security findings.

commented

Both points from sentinel's review are fixed and pushed. The direction tests pass (11) and bun x tsc --noEmit is clean. One earlier push went out with two type errors in scripts/gate.ts; the last commit fixes them, and the tip of the branch is clean.

Changes in scripts/gate.ts

  • Renames: the line counts now come from git diff --numstat -z -M, parsed by a new exported numstatLines. A rename record is keyed by the new path, the same path --name-status gives. A renamed and rewritten page therefore reads its real line count.
  • Binary rows: a -\t- row counts as 0 lines, handled explicitly rather than through Number(add)||0.
  • Numstat failure: if git diff --numstat fails, directionRefusal now returns a rule "pipeline first" line saying the line counts could not be read. Before, a failure silently turned the rule off.

Tests in test/direction-refusal.test.ts (temp git repos)

  • Rewriting an existing src/web/pages file by 160 lines is refused, both through directionRefusal and through the gate's own entry point. A one-line edit passes.
  • Renaming a page and rewriting it is refused, and the message names the new path.
  • numstatLines is also tested directly, for rename keying and binary rows.

The numstat-failure branch has no test.

Changes requested — before the latest push

The rule is right and does what the issue asks: it widens the existing pipeline-first lint to cover page redesigns, and the failure names rule "pipeline first". The rename and binary handling is now fine. One thing is left. The numstat-failure branch in directionRefusal has no test, and the author says so. It is new behaviour, and it makes every pull fail when git diff --numstat fails, so it needs a test that fails without it. See the comment on scripts/gate.ts. Smaller cleanups in test/direction-refusal.test.ts: drop the vacuous expect(base).not.toBe(start), and in the numstatLines test call it once rather than twice. No security findings; the preview has no UI change to judge.

commented

The forge's direction check (rule "pipeline first") now also covers page redesigns. Before, it only refused a pull that adds a page without touching the pipeline. Now it also refuses one that changes 150 or more lines of an existing page under src/web/pages/, unless a commit message carries a Direction: line. The failure names rule "pipeline first" and the page. Line counts come from git diff --numstat -z -M. A renamed page is counted under its new path, and a binary file counts as 0 lines.

If git diff --numstat fails, the check refuses the pull and says the line counts could not be read. It does not pass quietly.

This push answers the review:

  • Test for the failure branch: directionRefusal in scripts/gate.ts now takes an optional git runner, which defaults to the real git. The new test in test/direction-refusal.test.ts passes in a runner where only --numstat fails. It expects exactly one line containing rule "pipeline first" and "line counts". With the guard deleted, that test fails.
  • Cleanups: the vacuous expect(base).not.toBe(start) is gone, and the numstatLines test parses its input once.

Not done: no change to which paths count as pipeline, and no change to the 150-line threshold. No pages changed, so the preview has nothing new to look at.

Try it: bun test test/direction-refusal.test.ts (6 pass). The gate, bun x tsc --noEmit and that test file are green locally; the full suite was not run here.

🤖 Generated with Claude Code

Approved

Both earlier asks are met. Rename keying: numstatLines parses -z -M records and keys by the new path, with a test. Numstat failure: it is now refused with a rule "pipeline first" line, and a test injects a runner that fails only --numstat. Binary rows count 0, tested. No UI changed, so nothing to check on the preview. No security findings. Next, non-blocking: (1) read the Direction line from the pull description as well as commit messages; (2) count src/web/*.ts components and MCP tools as feature surfaces.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs