Repository navigation
feat(ci): catch boundary and async mistakes before review - #49
Conversation
allisonmahmood
left a comment
There was a problem hiding this comment.
Two-axis review of feat/issue-38-taste-as-lint vs origin/main (8c09545...8740608), against #38. Extra sections after Spec are method and YAGNI, as requested.
Issue 38 asked for base taste-as-lint now (CLI @patchy/core only, console/process.env at entrypoints + packages/config, no-explicit-any + type-aware no-floating-promises, format check in CI, prettier-only pre-commit) and Effect rules later, listed as a port-map build step.
What landed matches that shape: one root eslint.config.js, a synthetic tsconfig.lint.json so type-aware lint does not need ^build, pnpm format:check in the lint job, and lint-staged → Prettier only. Effect rules stayed out of ESLint and were written onto #23.
Standards
No hard documented-standard breaches. Dependency pins (exact esbuild/npm, TS v6, parse5 catalog) are untouched. CLI still talks to @patchy/core only (docs/agents/domain.md, packages/cli/CONTEXT.md). any removal matches the repo’s typesafety bias. app.ts / public-url.ts / json-db.ts / packages/config/src/index.ts / scripts/*.mjs are wrap-only besides the items below.
Judgement calls
Shotgun Surgery — one commit turns on format:check and also retouches CLI/db/start logic, then Prettier-rewrites examples/plan.html, skill HTML, docs/ADRs, and pnpm-lock.yaml quotes. The reformat is required for the new CI gate, but it buries the typed hunks.
Divergent Change — root lint is now workspace-wide, while six packages still ship an ESLint-8 CLI and turbo still builds first:
// package.json
"lint": "eslint \"**/*.{ts,mts,cts,tsx}\"",// packages/cli/package.json (and the other packages)
"lint": "eslint src --ext .ts",// turbo.json
"lint": { "dependsOn": ["^build"] }pnpm lint (CI) is the real gate. turbo run lint / pnpm --filter … lint still lint src only, so they miss tests the new no-explicit-any / no-floating-promises rules cover. Leftover dual entry points.
Allowlist is file-coarse (eslint.config.js). One override turns off both no-console and process.env for packages/config/**/*.ts (config does not log) and the whole CLI index.ts. readEnv is the intended chokepoint but is not enforced inside that file. Simple, and CLI console is the publishing interface (packages/cli/CONTEXT.md). Splitting the two rules would be tighter, not required.
tsconfig.lint.json paths map @patchy/{config,core,db,storage} → src/index.ts so type-aware lint need not ^build. Correct. Lint tsconfig would still resolve @patchy/db from CLI files; no-restricted-imports is the real domain gate.
postgres-db any → row types is a real typesafety fix, not a cast wrapper. CLI parsers (parseWhoamiResponse / parseUploadResponse / readResponseJson) are real guards, not one-line casts. Fail-closed cache/identity on a non-object JSON body is a behavior tighten.
void shutdown() in apps/server/src/start.ts satisfies no-floating-promises without changing SIGINT fire-and-forget.
lint-staged is prettier-only; eslint is CI-only. Matches keep-it-simple.
Spec
Base rules are in eslint.config.js. Type-aware lint uses parserOptions.project → tsconfig.lint.json. CI runs pnpm format:check. Pre-commit is Prettier-only via lint-staged. Effect rules did not land in ESLint.
(a) Missing / partial
“Done when: pnpm lint fails on each of the base rules.” Config would flag CLI import '@patchy/db', console.log / process.env outside the allowlist, : any, and an unhandled Promise. There is no test or probe that proves each rule fires. PR verification only ran a green pnpm lint.
“the port map has the Effect rules listed as a build step.” Effect rules correctly stay out of this PR. The listing is a comment on #23 (chart-the-map), not on a port map. No child map exists; #23 is still the wayfinder task.
(b) Not asked for
“Format check in CI” asked for a gate, not a rewrite. Diff Prettiers shipped HTML (examples/plan.html, skill welcome-draft.html), skill docs, ADRs, SELF_HOSTING.md, package files arrays, lockfile quotes, and scripts/*.mjs. (A one-time normalize is implied by turning the gate on against a dirty tree.)
“Package-boundary no-restricted-imports (the CLI depends only on @patchy/core).” Extra pattern bans CLI ../ imports. Spec was CLI-only @patchy/*; CLI-only is what was asked.
Also extra: turbo.json globalDependencies after pnpm lint left turbo; simple-git-hooks allowBuilds (needed for the hook).
CLI JSON parsers and Postgres row types are to satisfy “no-explicit-any back on”, not product scope.
(c) Implemented, but broader / off
“No console / process.env outside entrypoints and packages/config.” Allowlist also disables both for **/*.test.* and test/postgres.ts (called “composition roots”). Tests are not entrypoints. packages/db/src/migrate.ts is an extra unnamed entry.
no-restricted-properties only matches process.env member access (import { env } from "node:process" and const p = process; p.env would not fire). .mjs scripts and CLI test helpers are outside the lint glob.
Fully met: no-explicit-any error; no-floating-promises error with project wired; format check in CI; formatter-only pre-commit; Effect rules deferred.
Method
The method is the right one for this ticket. “Taste as lint” is an ESLint policy, not a new module, not eslint-plugin-boundaries, not a per-package config forest. One root flat config + one type-aware block + one CLI override + one allowlist is the smallest shape that matches #38.
Three caveats on how it was wired:
-
Lint resolution is looser than
tsc.tsconfig.lint.jsonpath-maps every@patchy/*to source so lint can run without building. Real package tsconfigs do not: the CLI maps only@patchy/core, everyone else is NodeNext →dist. A CLI file can typeimport "@patchy/db"under eslint and still be rejected by package typecheck.no-restricted-importsis the actual boundary. Fine if you know it; easy to forget. -
The turbo lint cutover is unfinished. Root
pnpm lintused to beturbo run lint. It is now a workspace eslint invocation (correct: one program, onetsconfig.lint.json). The turbolinttask,globalDependenciesaddition, and six package"lint": "eslint src --ext .ts"scripts are leftover. CI never hits them. Either finish the cut (delete the dead path) or keep turbo as the gate and drop the root one-liner. -
Package.json cannot be the CLI boundary.
@patchy/cliis an esbuild bundle and does not even list@patchy/coreas a dependency. Lint is the only enforcement that a futureimport "@patchy/db"fails. That is why the rule belongs here, not independencies.
The code moves that are policy, not wrap: void shutdown(); postgres map*(row: any) → query<DraftRow>(); CLI body: any → parsers. Env was already at getServerConfig / CLI readEnv / start.ts / migrate.ts. Nobody extracted a new env layer just to please the linter.
YAGNI / beautiful code
The policy file is ~70 obvious lines. That is the beautiful part. readEnv and direct console.* were already on main. Tests were rewrapped, not re-clevered. void shutdown() is the floating-promise idiom, not a wrapper factory. Postgres row types and the CLI response parsers are the honest cost of turning any back on — Matt-Pocock-shaped, not one-line casts.
Would delete:
- The CLI parent-directory import regex. The ticket said “depends only on
@patchy/core.” The CLI is one file;from "../…"has no current customer. - The leftover turbo/package
lintentry points (andturbo.jsonglobalDependenciesif root eslint stays the gate).
Would keep: the parsers, the row types, void, the HTML/markdown one-time normalize (format-check cannot go green otherwise).
Would not do: extract env/console wrappers, split the allowlist into two override blocks, add a lint-rule regression suite. The ticket’s “pnpm lint fails on each of the base rules” is an acceptance check you run once by violating a file, not a new test package.
One real behavior change mixed into the lint PR: a 200 whose JSON body is not an object used to flow undefined into the draft cache; it now errors. Fail-closed and better, but it is not a formatting change.
Verdict: mostly-fine, with prettier blast + unfinished turbo cutover as the two things that make a small policy ticket look like size:l.
Standards: 0 hard violations, 3 judgement calls — worst is the leftover dual lint path (root eslint vs turbo/--filter src --ext .ts).
Spec: 2 partial, 2 broader-than-asked — worst is the allowlist treating every *.test.ts as an entrypoint for both console and process.env, against “entrypoints and packages/config.”
|
I verified the review against the source and the current green CI run. I will address two findings:
|
|
I’m not changing the remaining observations:
|
The repository’s lint and CI gates let package-boundary violations, direct environment/output access, unsafe TypeScript, floating promises, and unformatted changes reach review. That left architectural and async mistakes as reviewer-only concerns.
This makes ESLint type-aware across every TypeScript extension, restricts the CLI to
@patchy/core, keepsconsoleandprocess.envat composition roots, and adds a CI formatting gate. The pre-commit hook runs only Prettier, and the existing tree is normalized once so the new check starts green.The Effect-port-specific lint step is recorded on #23 for the port map to inherit.
Verification
pnpm lint.mtscoveragepnpm format:checkpnpm typecheckpnpm test— 454 tests passedCloses #38
Built with OpenAI Codex GPT-5.6 in the Oh My Pi coding harness.