Skip to content

feat(lint): add six policy rules mined from nine agent rebuilds - #345

Merged
BenSheridanEdwards merged 5 commits into
mainfrom
feat/rebuild-lint-rules
Nov 10, 2026
Merged

BenSheridanEdwards merged 5 commits into
mainfrom
feat/rebuild-lint-rules

Conversation

@BenSheridanEdwards

@BenSheridanEdwards BenSheridanEdwards commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Why does this feature exist?

What changed?

One idea above 400 lines: six policy rules mined from one set of rebuilds, with the fixtures that prove each and the type programs their test helpers need. About 780 of the 1,701 added lines are lint fixtures in scripts/oxlint-policy.test.ts, and about 550 are the six rules.

  • Six rules in tooling/oxlint-plugin-policy.js, at error in the result-root override of oxlint.config.ts. They are the feat(lint): add six policy rules mined from nine agent rebuilds #341 rules with the fix(lint): apply the review fixes to the six rebuild rules #342 review fixes and the later follow-ups from the to-do branch:
    • policy/one-status-from-hooks: a use* hook returns one status union, not a query's data, isPending, isError or status as separate fields. It reads through const list = useQuery(…), const { data, isError } = useQuery(…) and list.data?.[0].
    • policy/test-unwraps-values: a test unwraps with present() or unwrap(). ?? '' fails, and so does x.ok ? x.value… : <literal>. It also runs on each result's web/e2e/**/*.ts, in a new override.
    • policy/test-imports-the-type: a test redeclares no type its folder already exports.
    • policy/message-uses-its-limit: a message interpolates its limit constant instead of hard-coding the number.
    • policy/reexport-only-from-index: this is the issue's policy/import-types-from-their-owner, renamed in fix(lint): apply the review fixes to the six rebuild rules #342 review because it covers values as well as types. A slice re-exports only from its own index.ts.
    • policy/keep-rejections: no .catch(() => undefined) or .then(ok, () => false) that throws the error away.
  • present() and unwrap() live in tooling/jest/test-globals.ts, with a test. The Jest setup makes them globals, because a package's unit test may import nothing outside its package. tooling/types/test-globals.d.ts types them. apps/web/e2e/fixtures.ts holds its own five-line copies, and a unit test holds those to the same behaviour.
  • Type programs: three test programs (tsconfig.test.json, tsconfig.api.test.json, and the new tsconfig.node.test.json for web contract tests) alone see the present and unwrap globals. tsconfig.json, tsconfig.api.json and tsconfig.node.json exclude tests, so production code or an E2E spec that calls either fails pnpm typecheck. The Jest types also move out of the web and api programs, so web and api source cannot call expect or jest. tsconfig.node.json keeps them because it checks jest.setup.ts and jest.config.ts. pnpm typecheck now checks seven programs.
  • Reference hit fixed: on main the rules find one hit. apps/web/src/routes/greeting/useGreeting.ts dropped the fire-and-forget record's rejection with .catch(() => undefined). It now settles the promise with void Promise.allSettled([...]), the form ADR 0124 prescribes. The failure is still ignored on purpose, and the rejection stays in the settled result. This is not a rewrite to dodge the rule.
  • Not carried over from the to-do branch: the to-do reference fixes (todos/application.test.ts, e2e/todos.spec.ts, TodosPage.test.tsx), the todos wording in no-restricted-imports and the to-do probe paths. The lint fixtures keep the to-do rebuild samples they were mined from, as synthetic paths in a temporary tree.
  • Docs: ADR 0124, six rows in CONVENTIONS.md, rows in ARCHITECTURE.md, the program list in QUALITY_GATES.md and PR_QUALITY.md, and the program count in docs/NORTH_STAR.md.
  • Guarded files: oxlint.config.ts, tooling/oxlint-plugin-policy.js and docs/NORTH_STAR.md change, so enforcement-approval waits for the maintainer's tick. The change only adds rules and corrects a count; nothing is loosened.

Behavioural Proof (with video and screenshots)

  • Video: Not applicable: lint rules, test helpers, type programs and one hook refactor that keeps the same behaviour; nothing renders differently.
  • Screenshots: Not applicable: no user-visible state changed, so there is no new screen to capture.
  • Behaviour tests:
    • Each rule fired on the real rebuild sample it was mined from, measured in feat(lint): add six policy rules mined from nine agent rebuilds #341 over the nine rebuild clones: one-status-from-hooks 9 of 9, test-unwraps-values 6 of 9, test-imports-the-type 3 of 9, message-uses-its-limit 3 of 9, reexport-only-from-index 4 of 9, keep-rejections 2 of 9. Those samples, such as r5's useTodos and domain.ts, are invalid fixtures in scripts/oxlint-policy.test.ts, and each fails with its rule's message.
    • On this branch before the useGreeting.ts fix, pnpm lint:policy reported exactly one finding: useGreeting.ts:38:12 policy(keep-rejections). After the fix it reports none.
    • useGreeting.test.tsx passes, including "keeps the greeting visible when recording fails".
    • Review fixes are proved red, then green. The gap-10/$10 fixture, the destructured-query and indexed-read fixtures (useDestructured.ts, useFirst.ts) and the broken-link scan test each fail on the plugin before the fix (4 failed, 509 passed) and pass after it (513 passed).
  • E2E mapping: unchanged. apps/web/e2e/recent-greetings.spec.ts "shows the names greeted on the page, newest first" covers the record call that useGreeting makes.

Verification Summary

  • Head commit: 310a0e1
  • PRDs checked: docs/prd/greeting.md, docs/prd/recent-greetings.md
  • PRD impact: No behaviour change: useGreeting still records each greeted name and still ignores a failed record, only through a settled promise instead of a swallowed rejection.
  • North Star commit: f1a8fa0d55e77874b9a4c4613a50b6c1fa25265c
  • Commands run (e.g. pnpm verify, pnpm e2e): pnpm lint:anti-slop, pnpm verify, pnpm e2e, and the real pre-commit and pre-push hooks, on the final head.
  • Results: pnpm verify passes at 310a0e1 in the real pre-push hook (85 suites, 3,103 Jest tests; contract, integration, changed-file coverage, build and size), and pnpm e2e passes 15 tests. pnpm typecheck passes all seven programs. pnpm lint:anti-slop passes on the clean tracked tree. 310a0e1 merges main at c74604d (fix: close audit findings in the UI, api and gate scripts #347 and docs: bring guidance in line with the current gates #348) into the reviewed c3b27ac with no conflict; the PR's own changes are unchanged. The first pre-push attempt at 310a0e1 failed only on load timeouts (tooling/trial/review.test.ts 5-second limits and a killed scripts/bench/run.test.ts child) at load average 225, and the retry passed unchanged.
  • Definition of Done (.agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied locally; enforcement-approval waits for the maintainer's tick on the guarded files.
  • pnpm verify
  • pnpm e2e
  • Behaviour is covered by the E2E map when user-visible behaviour changed.
  • Logic is unit-tested where logic changed.
  • Accessibility considered and verified for interactive/UI changes.
  • The diff follows .agents/project/ARCHITECTURE.md and CONVENTIONS.md; new decisions recorded as ADRs.
  • No gates were bypassed or weakened.
  • Known risks or skipped checks (with reason, risk, and rollback):
    • Known limits, recorded in ADR 0124: message-uses-its-limit still matches prose such as Step 10 of 12 when a limit is exactly 10, and test-imports-the-type matches a type by name across the folder.
    • The nine rebuild clones are not on this machine, so the per-rule hit counts come from feat(lint): add six policy rules mined from nine agent rebuilds #341's run. The samples themselves are fixtures here.
    • Editors: tests now type-check in their own programs, and nothing references those from tsconfig.json, so an editor's TypeScript server may open a test file in an inferred project. pnpm typecheck is the source of truth. A solution-style tsconfig can follow if that hurts.
    • Locally, every checkout shares the Pact file at $TMPDIR/art-pact. A run on another branch can leave interactions there that this branch's provider rejects. PACT_DIR set to a private folder avoids it, and CI is unaffected. The to-do branch fixes this separately.
    • Follow-ups from the third review, accepted for later: reexport-only-from-index misses export default of an imported name and an export { x } above its import; one-status-from-hooks misses an object built inside useMemo; keep-rejections flags any method named .catch or .then, and void Promise.allSettled([p]) ignores a failure on purpose the same way the banned form does, so the rule bans the form rather than the behaviour; isSpecFile overlaps isTestFile; the tsconfig comments call two programs "the Node program".
    • Rollback: revert the merge commit; the rules, helpers, type programs and the useGreeting change go together.

PRD Behaviours to Review

  • docs/prd/greeting.md: Greets the visitor by name. Evidence: greeting.spec.ts tests "greets a name through the api" and "collapses runs of inner whitespace in the name" pass in pnpm e2e.
  • docs/prd/greeting.md: Asks for a name before it calls the api. Evidence: greeting.spec.ts test "asks for a name and sends no request when the name is blank" passes in pnpm e2e.
  • docs/prd/greeting.md: The api rejects a blank name. Evidence: greeting.spec.ts test "the api rejects a blank name as a bad request" passes in pnpm e2e; the api is unchanged.
  • docs/prd/greeting.md: Says so when the api fails. Evidence: greeting.spec.ts test "says so when the api fails" passes in pnpm e2e.
  • docs/prd/greeting.md: Works for every visitor. Evidence: the three accessibility.spec.ts greeting tests pass in pnpm e2e; no markup changed.
  • docs/prd/recent-greetings.md: Shows the names greeted on the page, newest first. Evidence: recent-greetings.spec.ts test "shows the names greeted on the page, newest first" passes in pnpm e2e and exercises the changed record call.
  • docs/prd/recent-greetings.md: Stays closed until asked. Evidence: recent-greetings.spec.ts test "stays closed until asked" passes in pnpm e2e.
  • docs/prd/recent-greetings.md: Records each greeted name. Evidence: recent-greetings.spec.ts test "records each greeted name with surrounding whitespace trimmed" passes in pnpm e2e.
  • docs/prd/recent-greetings.md: Lists the newest name first, at most ten. Evidence: recent-greetings.spec.ts test "lists the newest name first and keeps at most ten names" passes in pnpm e2e.
  • docs/prd/recent-greetings.md: The api rejects a blank name. Evidence: recent-greetings.spec.ts test "rejects a blank recent greeting name as a bad request" passes in pnpm e2e; the api is unchanged.

PR Proof Law

  • I followed .agents/project/PR_QUALITY.md and .agents/skills/pr-quality-contract/SKILL.md; the PR quality check verifies the proof format.

🤖 Generated with Claude Code

BenSheridanEdwards and others added 2 commits November 9, 2026 18:15
Extracts the rules from #341 and its review fixes (#342 and the
follow-ups on feat/todo-example-app) onto main, so #337 closes
without the to-do app.

- tooling/oxlint-plugin-policy.js: one-status-from-hooks,
  test-unwraps-values, test-imports-the-type, message-uses-its-limit,
  reexport-only-from-index and keep-rejections, at error in the
  result-root override; test-unwraps-values also runs on web/e2e.
- present() and unwrap() as Jest test globals typed only for the two
  new test type programs, and as five-line helpers in e2e/fixtures.ts.
- ADR 0124 records the rules, their limits and the fixtures.
- The greeting reference had one hit: useGreeting dropped its record
  rejection with .catch(() => undefined); it now settles the promise
  with Promise.allSettled.

Closes #337

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- message-uses-its-limit: a limit after -, / or : is part of a class
  name, fraction or time, so 'gap-10 px-4' beside MAX_ITEMS = 10 passes.
  A fixture pins it and fails on the old pattern.
- Web contract tests type-check in a new tsconfig.node.test.json that
  sees the test globals; tsconfig.node.json keeps e2e specs, which run
  in Playwright, away from them.
- The Jest types move from tsconfig.json and tsconfig.api.json to the
  test programs, so production code cannot call expect or jest.
- ADR 0124 records the class-name pass and that test-imports-the-type
  matches a type by name across the folder.
- The docs and North Star name the seven type programs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added confidence: red A required gate is failing or pending, or evidence is unavailable. confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap. and removed confidence: red A required gate is failing or pending, or evidence is unavailable. labels Nov 9, 2026
- one-status-from-hooks reads a name destructured from a query
  (const { data, isError } = useQuery(...)) and an index into a field
  (list.data?.[0]) as reads of that query; both had passed.
- message-uses-its-limit skips a limit after $, so 'Save $10 today'
  passes; ADR 0124 records that a limit of 10 still matches prose
  such as 'Step 10 of 12'.
- test-imports-the-type skips a broken link or a folder named like a
  module when it scans a test's folder, instead of throwing.
- QUALITY_GATES and test-globals.d.ts say exactly what the test
  programs alone see: the globals, with no Jest types in web or api.

Each new fixture fails on the previous plugin and passes on this one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added confidence: red A required gate is failing or pending, or evidence is unavailable. confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap. and removed confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap. confidence: red A required gate is failing or pending, or evidence is unavailable. labels Nov 9, 2026
@github-actions github-actions Bot added confidence: red A required gate is failing or pending, or evidence is unavailable. and removed confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap. labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Enforcement sign-off

Ran at Tuesday, the 10th of November, at 12:30 pm on commit 310a0e1.

This PR changes gated enforcement or product intent, so it needs sign-off.

File What changed How it affects
docs/NORTH_STAR.md Rewrites the section 1. Lint beats instructions; Adds product requirements The toolchain combines Biome, Oxlint, strict TypeScript over seven programs, Fallow boundaries and; Removes product requirements The toolchain combines Biome, Oxlint, strict TypeScript over four programs, Fallow boundaries and Product intent now includes The toolchain combines Biome, Oxlint, strict TypeScript over seven programs, Fallow boundaries and instead of The toolchain combines Biome, Oxlint, strict TypeScript over four programs, Fallow boundaries and; implementation and behaviour tests must follow the revised intent
oxlint.config.ts Turns on 7 lint rules at error: policy/one-status-from-hooks, policy/test-unwraps-values, policy/test-imports-the-type, policy/message-uses-its-limit and 3 more; Changes lint option files (4) from "['{apps,packages}/*/src/**', 'showcase/*/*/src/**']" to "['{apps,showcase/*}/web/e2e/**/*.ts']"; Changes lint option files (5) from not set to "['{apps,packages}/*/src/**', 'showcase/*/*/src/**']" Changes lint coverage or inherited configuration: ignore and exclude patterns bypass checking; files and includes patterns select checked paths; extends loads the named rule configuration; The named lint rules run at the stated severity; warnings and errors block verification
tooling/oxlint-plugin-policy.js Adds the lint rule one-status-from-hooks; Adds the lint rule test-unwraps-values; Adds the lint rule test-imports-the-type; Adds the lint rule message-uses-its-limit; Adds the lint rule reexport-only-from-index; Adds the lint rule keep-rejections Adds rule implementations available to the lint configuration; configured severities decide whether they block

@BenSheridanEdwards: tick to approve.

  • Approve these enforcement changes at 310a0e1 ticked by Ben Sheridan Edwards at Tuesday, the 10th of November, at 12:30 pm (@BenSheridanEdwards)

@github-actions github-actions Bot added confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap. and removed confidence: red A required gate is failing or pending, or evidence is unavailable. labels Nov 10, 2026
@BenSheridanEdwards
BenSheridanEdwards merged commit 5cd630f into main Nov 10, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confidence: amber Required gates passed, with an E2E, PRD, unit coverage or import blast-radius gap.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint: six policy rules mined from nine agent rebuilds

1 participant