Repository navigation
refactor(todos): share the title rules between the api and the web (ADR 0127) - #344
Conversation
26c5235 to
75e5efd
Compare
- ADR 0128 (renumbered from 0127, which draft #344 holds) amends ADR 0059: duplicates.ignore keeps one showcase/** entry in place of named per-result entries, because every trial result copies the reference's template files and would fail its own audit on them. 0059's status and ARCHITECTURE.md say so; health.ignore is unchanged. - The docs state the duplication check as the script enforces it: a threshold of 0 or above 0.001 fails the gate. - boundaries.test.ts runs the gate's Fallow steps one by one without a shell, so a checkout path with a space cannot break them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ADR 0128 (renumbered from 0127, which draft #344 holds) amends ADR 0059: duplicates.ignore keeps one showcase/** entry in place of named per-result entries, because every trial result copies the reference's template files and would fail its own audit on them. 0059's status and ARCHITECTURE.md say so; health.ignore is unchanged. - The docs state the duplication check as the script enforces it: a threshold of 0 or above 0.001 fails the gate. - boundaries.test.ts runs the gate's Fallow steps one by one without a shell, so a checkout path with a space cannot break them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ADR 0128 (renumbered from 0127, which draft #344 holds) amends ADR 0059: duplicates.ignore keeps one showcase/** entry in place of named per-result entries, because every trial result copies the reference's template files and would fail its own audit on them. 0059's status and ARCHITECTURE.md say so; health.ignore is unchanged. - The docs state the duplication check as the script enforces it: a threshold of 0 or above 0.001 fails the gate. - boundaries.test.ts runs the gate's Fallow steps one by one without a shell, so a checkout path with a space cannot break them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rnings (#346) * feat(gates): fail the gate on Fallow, Playwright worker and runner warnings - pnpm arch:gate runs scripts/check-fallow-severity.mjs first, which fails when a Fallow rule, override or rule-pack rule is set to warn. Fallow reports a warn finding and exits 0, so the gate refuses the setting. boundaries.test.ts proves it on a seeded repository. - The Playwright fixture listens on the browser context, so a popup, another page or a dedicated worker that warns or throws fails the test, and records console.warn, console.error and Node warnings in the test's own process. - pnpm e2e:console-guard proves seven new failing cases and runs three fixture mutants in one child run, so its servers still start twice. - ADR 0127 records the decision and what stays outside it; the North Star states warnings-as-failures as a guarantee. Closes #231 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(gates): fail the audit on any Fallow clone group fallow audit reports a clone group as a warning, returns the warn verdict and exits 0 unless duplicates.threshold is set. The first gate run of this branch showed it: a duplicated block in the guard cases passed. - .fallowrc.jsonc sets duplicates.threshold to 0.001, so any clone group fails the audit; showcase results stay out because they copy the reference's template files by design. Main has no clone group. - check-fallow-severity.mjs also fails a config with duplication on and no threshold, and is split into small functions. - boundaries.test.ts proves both: a committed clone gives warn and exit 0 without the threshold, fail and exit 1 with it. - The popup guard cases share one helper instead of a copied block. - ADR 0127 records that Fallow's zone log lines are diagnostics, not findings, and stay non-fatal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(gates): keep the duplicates ignore list first and multi-line for the benchmark scripts/bench/generate.mjs appends its clones to duplicates.ignore and needs that list first in the block; a comment inside the list keeps Biome from folding it onto one line. The boundaries tests set the threshold to 0 rather than strip the block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(gates): apply the first review's findings to the warning guards - Node prints its own process warnings through console.error, so the fixture recorded one warning twice and the runner-warning mutant failed in CI. The console patch now skips text that starts with "(node:<pid>) "; the warning listener records each one once. - The proof's children run without NO_COLOR, as CI does: beside FORCE_COLOR it makes Node warn at worker start, which hid the bug. - A failing fixture attaches console-guard.json with its exact unexpected and missing lists, and the proof compares those instead of scraping single-line strings from the assertion diff. - Two more mutants: popup pages and the console.warn patch. - The console patch formats arguments with util.format, so a prototype-less object is recorded instead of throwing. - check-fallow-severity.mjs requires a duplication threshold above 0 and at most 0.001; a threshold of 5 now fails the gate too. - The North Star names the four tools whose warn-severity findings fail, and ADR 0127 is retitled to match and lists commitlint's warn rules as outside the guarantee. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(gates): apply the second review's findings to the warning guards - ADR 0128 (renumbered from 0127, which draft #344 holds) amends ADR 0059: duplicates.ignore keeps one showcase/** entry in place of named per-result entries, because every trial result copies the reference's template files and would fail its own audit on them. 0059's status and ARCHITECTURE.md say so; health.ignore is unchanged. - The docs state the duplication check as the script enforces it: a threshold of 0 or above 0.001 fails the gate. - boundaries.test.ts runs the gate's Fallow steps one by one without a shell, so a checkout path with a space cannot break them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(adr): align ADR 0059's body with the showcase duplication exemption ADR 0059's Decision and Consequences still described per-result duplicates.ignore entries; they now point to ADR 0128 for code duplication and keep the per-result rule for health.ignore only. check-fallow-severity.mjs treats a config with no rule pack as having none, so it names each warn rule instead of throwing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(gates): bring the warning-guard docs in line with ADR 0128 - ADR 0086's Consequences say what it covered as first merged and point to ADR 0128 for pages, workers, the test process and Fallow. - ADR 0079's status names its amendment by ADR 0128. - QUALITY_GATES states the Playwright and Fallow warning guards. - ADR 0128 and check-fallow-severity.mjs say the threshold is a share of every line Fallow analyses, and when one clone group stays above it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(gates): scope the AGENTS warning row and amend ADR 0034 - AGENTS.md says Fallow fails on a warn-severity finding and that its log lines stay output, matching the North Star and ADR 0128. - ADR 0034 said no showcase result gets an exception; its status now names ADR 0128's code-duplication exemption, and 0128 lists 0034 among the records it amends. - ADR 0128 describes the seeded thresholds as the test sets them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(gates): say service-worker console calls fail the test A service worker's console.warn or console.error reaches the browser context, so the fixture records it; only the browser's own lifecycle logs stay outside. ADR 0128's Amends list is one item per record, ADR 0079 names the full threshold bound, and ADR 0059's status says its title now holds for styling, complexity and health only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Six of nine agent rebuilds wrote the to-do title rules twice, in the api domain and in the web form, because the web may import the api by type only. ADR 0127 (Proposed) weighs the status quo, a shared pure module and api-only validation, and proposes a pure rules.ts in each api feature that the domain and the web form both import, with the zone, contract, structure and manifest changes it needs. Issue 338.
Prototype for ADR 0127. apps/api/src/features/todos/rules.ts holds TITLE_MAX_LENGTH, TITLE_MESSAGES and normaliseTitle and imports nothing. The domain's checkTitle and the web's todoFormSchema both use it; the web imports it as @repo/api/todos/rules, the api package's one runtime export. Fallow gains the api-rules zone: the domain, routes and web features may import it by value, and it imports no other role. contract/rules-pure bans tRPC, Effect, React and Node there, tsconfig.domain.json compiles it without Node or DOM, and route-colocation accepts the subpath from the same result only. The web lists @repo/api as a dependency now that it ships code from it. Seeded boundary and structure tests cover each new allowance and each new failure; the contract and trial inclusion pins gain api-rules, and ADR 0127 lists them. Behaviour is unchanged.
75e5efd to
6a587fd
Compare
|
This PR needs no enforcement or product intent sign-off. |
Opus review — APPROVEReviewed head Verdict: APPROVE. No blocking findings. The shared title rules live in one import-free Non-blocking only: ADR 0127 is still marked Proposed while ARCHITECTURE.md already cites it; AGENTS.md's co-location sentence is stale; one schema test is mostly circular (literals are covered elsewhere); the new All required hosted checks were green at this head, enforcement-approval passed with no sign-off required, and the PR body has no wait-for-Ben wording. |
Why does this feature exist?
Enter a title,Use 100 characters or fewer) were written twice, inapps/api/src/features/todos/domain.tsandapps/web/src/routes/todos/todoFormSchema.ts, as the reference does (SLOP finding R1). In six rebuilds the web copy hard-codes100while the api interpolates its constant (P4), and two split normalising across the schema and the hook (B4). The architecture forces the duplication: the web may import the api by type only.Base: rebased onto
main(e7653ac); #335 was closed unmerged. This PR retains ADR 0127 and its prototype.Closes #338
What changed?
Rebase follow-up: the merge-remedy test ignores the script path when checking its text, so a worktree named
rebase-344cannot cause a false failure. All 20 targeted tests pass.ADR 0127 (Proposed) (
4de0820): context, three options (status quo; a small shared pure module that the api domain and the web form import; api-only validation with the web reading api errors), the decision, consequences, and a table of every zone and import-rule change. It proposes option 2 with the module in the api feature, so the api stays the owner the PRD names and each result stays self-contained.Prototype (
a090f11):apps/api/src/features/todos/rules.tsholdsTITLE_MAX_LENGTH,TITLE_MESSAGESandnormaliseTitleand imports nothing.domain.tsbuildscheckTitlefrom it;todoFormSchema.tsdecodes withnormaliseTitleand checks the shared limit and messages. Both copies are gone.@repo/api/todos/rules:apps/api/package.jsonadds the export./*/ruleswith adefaultcondition;.stays types-only.apps/web/package.jsonmoves@repo/apifromdevDependenciestodependencies(lockfile updated, no new package)..fallowrc.jsoncadds the zoneapi-rules;api-domain,web-routesandweb-featuresmay import it by value; it may import no other role, types included, likeui.contract.rules.jsoncaddscontract/rules-pure(no tRPC, Effect, React or Node).tsconfig.domain.jsoncompilesrules.tswith no Node or DOM.structure.mjsroute-colocationaccepts@<scope>/api/<feature>/rulesfrom the same result only. Diagrams regenerated.@repo/api/todos/domainand another result's rules.rules.test.tstakes the normaliser cases fromdomain.test.ts;todoFormSchema.test.tsasserts the form uses the api's limit and messages. The contract and trial-inclusion pins gainapi-rules.ARCHITECTURE.md(role table, api file roles, rules table, route co-location) andCONVENTIONS.md(contract and file-role tables) namerules.ts.Behavioural Proof (with video and screenshots)
apps/api/src/features/todos/rules.test.ts,domain.test.ts,apps/web/src/routes/todos/todoFormSchema.test.ts(shared limit and messages),TodosPage.test.tsx;tooling/architecture/boundaries.test.tsandstructure.test.tsfor the new rules. The new tests failed first (5 failed beforerules.tsand the config existed).a090f11.Verification Summary
e3e180b9024c3d51c5ec4c38783ef9306aa79b87pnpm verify,pnpm e2e):pnpm lint:anti-slop,pnpm verify,pnpm e2e; targetedpnpm exec jest --selectProjects tooling --runTestsByPath scripts/require-up-to-date-main.test.ts.6a587fd: 96 unit/tooling suites, 3232 tests; contract and integration passed; E2E 32/32. JS 109.66 kB / 110 kB; CSS 2.72 kB / 5 kB. Earlier runs exposed a script-path assertion fixed here and worktree snapshot interference while committing; the final clean-tree run passed. Hosted checks and deployed runtime remain unverified..agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied locally, but this is a draft for Chief's architecture decision.pnpm verifypnpm e2e.agents/project/ARCHITECTURE.mdandCONVENTIONS.md; new decisions recorded as ADRs.api-rules, by value, and@repo/apigains one runtime export. It is bounded by Fallow (only the domain, routes and web features may import it, and it imports no role), bycontract/rules-pureand by the domain tsconfig. No hook, workflow, budget, guarded file or severity changes, and no gate was bypassed; the box above stays unticked because the boundary does widen.@repo/ui, which imports no role" becomes "...except into@repo/uiand a feature'srules.ts, which import no role", and "route value and type imports stay within their own folder,@repo/ui, the api-client public barrel and external npm packages" becomes "...the api-client public barrel, their own api's feature rules (@<scope>/api/<feature>/rules) and external npm packages".check:shared-literals, to fail on a long string present in bothapps/api/srcandapps/web/src..nvmrcpins 22; CI runs the pinned version.PRD Behaviours to Review
docs/prd/todos.md: Says so when the list fails to load. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Marks a to-do done and active again, in place. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Edits a title in place, normalised. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Deletes a to-do at once. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Clears every done to-do, whatever the filter, and only while one is done. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Keeps the done to-dos and says so when clearing fails. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Shows only the latest failure, until the next change starts. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Says so when the list fails to load after a change. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Reads the list when the page opens and after each successful change. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Shows loading until the list arrives. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Loads an empty list and adds a normalised title. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Rejects blank and too-long titles. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Filters to active or done to-dos and back to all. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Hides a newly done to-do from Active. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Shows an empty message for an unmatched filter. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.docs/prd/todos.md: Passes the automated accessibility scan. Evidence: unchanged behaviour;pnpm e2epassed all 32 tests on6a587fd.PR Proof Law
.agents/project/PR_QUALITY.mdand.agents/skills/pr-quality-contract/SKILL.md; thePR qualitycheck verifies the proof format.