@opendesignai/harness 0.0.0-stage → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,157 @@
1
+ # Adopting od-harness in a repository
2
+
3
+ The goal of the adoption change: lint, size budget and baseline ratchet run in CI as the single required check `harness-gates`; all existing debt is frozen in baselines, and only new violations fail.
4
+
5
+ ## 1. Install
6
+
7
+ Install from the public npm registry, `alpha` dist-tag, and pin both packages exactly. Oxlint must be the version od-harness is tested with (its `peerDependencies`).
8
+
9
+ ```sh
10
+ pnpm add -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
11
+ # or: npm install -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
12
+ ```
13
+
14
+ Releases are published to npm under the `opendesignai` organization with the `alpha` dist-tag. The first alpha releases are published by hand from the tarball that `pnpm pack` writes (never `npm publish` from the checkout, which would ship `catalog:` and `workspace:` specifiers); a CI release workflow with npm trusted publishing follows once the package exists. To try an unreleased change, install such a tarball directly, for example `"@opendesignai/harness": "file:vendor/opendesignai-harness-0.1.0-alpha.0.tgz"`.
15
+
16
+ Add a `.node-version` file if the repository does not have one; CI sets up Node from it.
17
+
18
+ ## 2. Configure Oxlint
19
+
20
+ Create `.oxlintrc.json` at the repository root:
21
+
22
+ ```json
23
+ {
24
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
25
+ "extends": [
26
+ "./node_modules/@opendesignai/harness/presets/base.json",
27
+ "./node_modules/@opendesignai/harness/presets/platform-boundary.json"
28
+ ],
29
+ "ignorePatterns": ["**/dist/**", "**/build/**", "**/vendor/**", "studio/src/i18n/**"],
30
+ "rules": {
31
+ "od/no-shell-imports-product": [
32
+ "error",
33
+ {
34
+ "shell": ["studio/src/"],
35
+ "product": ["studio/src/motion/game/", "studio/src/super-agent/gamePublish/"],
36
+ "aliases": { "@/": "studio/src/" }
37
+ }
38
+ ],
39
+ "od/no-raw-storage": ["error", { "wrapper": "studio/src/utils/safeStorage.ts" }]
40
+ },
41
+ "overrides": [
42
+ { "files": ["studio/src/utils/safeStorage.ts"], "rules": { "od/no-raw-storage": "off" } },
43
+ {
44
+ "files": ["gateway/**", "server.ts"],
45
+ "rules": { "od/no-api-path-literal": "off", "od/no-raw-fetch": "off" }
46
+ }
47
+ ]
48
+ }
49
+ ```
50
+
51
+ - Presets: always `base`; add `platform-boundary` where shell and product code share the repository (od-platform, the openmotion pilot branch, opengame); add `product` in product packages.
52
+ - `od/no-product-literal` defaults to the full product names (`opengame`, `openmotion`), because the short ids `game` and `motion` are also ordinary words in product code. Platform repositories, where the short ids are product identities (manifest `name`, `/api/<name>/`), list them explicitly: `"od/no-product-literal": ["error", { "products": ["opengame", "openmotion", "game", "motion"] }]`.
53
+ - `react-compiler`: add `./node_modules/@opendesignai/harness/presets/react-compiler.json` as the last `extends` entry in a repository that uses React Compiler. od-platform extends it from the start; a product repository adds it in the change that turns React Compiler on, not before. It turns on the eight React Compiler-derived rules that `base` turns off (`react/refs`, `react/set-state-in-effect`, …), so it only works after `base`. Why: [ADR 0002](decisions/0002-react-compiler-rules.md).
54
+ - `extends` takes file paths, not package names, so keep the `./node_modules/…` prefix.
55
+ - The base preset reports unused disable directives as errors (`options.reportUnusedDisableDirectives`); there is no need to repeat it here.
56
+ - The base preset already turns `od/no-cjk-literal` off in tests and fixtures (`*.test.*`, `*.spec.*`, `__tests__/`, `__fixtures__/`, `fixtures/`). Exclude the repository's own i18n catalog, as `ignorePatterns` does above.
57
+ - Exemptions are `overrides` entries in this file. The file belongs to the platform owner (CODEOWNERS); every exemption is reviewed there, never inline.
58
+ - CODEOWNERS also gives the platform owner `package.json` (the harness version) and `.harness/config.json`. `od-harness ratchet` admits new rule IDs into an existing baseline only in a change to `.oxlintrc.json` or the harness version, so this review is what guards the baselines ([ratchet](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)). A new baseline file it admits only in the adoption change, without relying on review.
59
+ - Run Oxlint from the repository root: path options (`shell`, `product`) are relative to the working directory.
60
+
61
+ Add scripts:
62
+
63
+ ```json
64
+ {
65
+ "scripts": {
66
+ "lint": "oxlint --deny-warnings",
67
+ "size": "od-harness size",
68
+ "ratchet": "od-harness ratchet --base origin/main"
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## 3. Clean up what cannot be baselined
74
+
75
+ Unused disable directives are reported as errors but cannot go into `oxlint-suppressions.json` (opengame had 44, openmotion 43). Run `oxlint --fix` (removes some) and delete the remaining reported comments by hand. This includes disable comments for rules the presets turn off, such as `oxlint-disable-line react/refs` without the `react-compiler` preset (3 in each of the two).
76
+
77
+ Also remove disable comments that name no rule (`/* eslint-disable */`, `// eslint-disable-next-line`, `/* oxlint-disable */`). They switch off every rule in their range, `od/*` included, and `eslint-comments/no-restricted-disable` rejects them. Do not baseline them: the baseline would then hold one `eslint-comments` entry while the violations they hide never show up in it. To find them:
78
+
79
+ ```sh
80
+ git grep -n -E '(eslint|oxlint)-disable(-next-line|-line)?[[:space:]]*(\*/|--|$)'
81
+ ```
82
+
83
+ Upstream `@eslint-community/eslint-plugin-eslint-comments` crashes under Oxlint 1.96.0 on such a comment in the first line of a file, which drops every `od/*` result for that file. The base preset therefore loads od-harness's wrapper of the plugin (`dist/eslint-comments.mjs`), which reports these comments on their own line instead; see [docs/upstream/oxc-negative-column.md](https://github.com/nexu-io/od-harness/blob/main/docs/upstream/oxc-negative-column.md).
84
+
85
+ ## 4. Generate the baselines (only if there is existing debt)
86
+
87
+ If `pnpm exec oxlint` and `pnpm exec od-harness size` already pass, skip this step: see [Adopting with zero debt](#adopting-with-zero-debt).
88
+
89
+ On a clean checkout of the branch you are adopting on:
90
+
91
+ ```sh
92
+ pnpm exec oxlint --suppress-all # writes oxlint-suppressions.json
93
+ pnpm exec oxlint # must now pass
94
+ pnpm exec od-harness size --init # writes .harness/size-baseline.json
95
+ ```
96
+
97
+ Commit both files. `--suppress-all` and `size --init` are adoption-only commands; afterwards the baselines only shrink.
98
+
99
+ If some generated or vendored source is exempt from the size budget, list it in `.harness/config.json` before `--init`:
100
+
101
+ ```json
102
+ { "size": { "ignore": ["studio/src/generated/**"] } }
103
+ ```
104
+
105
+ `od-harness ratchet` accepts a new baseline file only in the change that adds `@opendesignai/harness` to `package.json`, so generate the baselines in the adoption change itself. A baseline that the adoption change does not create cannot be added later.
106
+
107
+ ### Adopting with zero debt
108
+
109
+ A repository whose code already passes (od-platform) adopts without baselines:
110
+
111
+ - do not run `oxlint --suppress-all` or `od-harness size --init`, and do not commit `oxlint-suppressions.json` or `.harness/size-baseline.json`;
112
+ - every violation fails CI from the first day and is fixed, never frozen;
113
+ - `od-harness ratchet` rejects any later change that creates either baseline file, also a harness upgrade or a change to `.oxlintrc.json`, and also when an administrator merges without owner review, as long as the caller's workflow keeps `ratchet` on (turning a gate off is a reviewed workflow change). This keeps the repository at zero: violations that an upgrade or a config change brings, including a newly extended `react-compiler` preset, are fixed in that change, not frozen.
114
+
115
+ ## 5. Call the gate in CI
116
+
117
+ `.github/workflows/harness.yml`:
118
+
119
+ ```yaml
120
+ name: harness
121
+
122
+ on:
123
+ pull_request:
124
+ push:
125
+ branches: [main]
126
+ merge_group:
127
+
128
+ permissions:
129
+ contents: read
130
+
131
+ jobs:
132
+ harness-gates:
133
+ uses: nexu-io/od-harness/.github/workflows/gates.yml@v1
134
+ with:
135
+ commands: pnpm test # optional
136
+ ```
137
+
138
+ - The workflow picks pnpm (`pnpm-lock.yaml`) or `npm ci` (`package-lock.json`), sets up Node from `.node-version` and checks out the full history so `ratchet` can read the base commit.
139
+ - It always runs the gates, in this order: `oxlint --deny-warnings`, `od-harness size`, `od-harness ratchet --base "$HARNESS_BASE_REF"`, through `pnpm exec` or `npx --no-install`. Then it runs each line of `commands` (for example `pnpm test`, or `npm test` with npm). Every command runs even after a failure, and the job fails if any failed.
140
+ - `HARNESS_BASE_REF` is the PR base, the merge-queue base, or the previous commit on push.
141
+ - Inputs: `lint`, `size`, `ratchet` (booleans, default `true`; turning one off is a change to this workflow file and goes through owner review), `commands` (default empty), `working-directory`, `node-version-file`, `fetch-depth`, `timeout-minutes`, `runs-on`.
142
+ - Do not repeat `pnpm lint`, `od-harness size` or `od-harness ratchet` in `commands`: the gates already run them, from one definition in od-harness.
143
+ - Make the check `harness-gates / harness-gates` required in the branch ruleset.
144
+ - Reference the workflow by the git tag `v1` (`gates.yml@v1`), as above.
145
+
146
+ ## Day to day
147
+
148
+ | Situation | What to do |
149
+ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
150
+ | Lint reports a new violation | Fix it. Do not add a disable comment (rejected) or touch the baseline (ratchet fails). |
151
+ | You fixed existing debt | Run `oxlint --prune-suppressions` and commit the smaller `oxlint-suppressions.json`; CI fails until you do. |
152
+ | A frozen file got smaller | Run `od-harness size --update` and commit; CI fails until you do. |
153
+ | A frozen file must grow | Move code out of it instead. |
154
+ | A file is deleted or moved | Prune both baselines. A moved file does not keep its debt: `ratchet` rejects entries for paths the base does not have, so fix the violations at the new path until the owner-reviewed `od-harness baseline move` exists. |
155
+ | Upgrading od-harness adds a rule | On an otherwise clean branch, run `oxlint --suppress-all` to baseline the new rule; `ratchet` accepts new rule IDs only when the harness version or `.oxlintrc.json` changed in the same change. A repository without `oxlint-suppressions.json` fixes the violations instead; `ratchet` does not let it create one. |
156
+ | Upgrading od-harness turns a rule off | Run `oxlint --prune-suppressions` and delete the disable comments that became unused, in the upgrade change. |
157
+ | Turning on React Compiler | Extend `react-compiler` after `base` in the same change. Fix what it reports, or, in a repository that has `oxlint-suppressions.json`, baseline it there (`oxlint --suppress-all` on an otherwise clean branch); `ratchet` accepts the new rule IDs because `.oxlintrc.json` changed. |
@@ -0,0 +1,74 @@
1
+ # 0001: Run od rules with Oxlint, write them in ESLint plugin format
2
+
3
+ - Status: accepted (2026-12-03)
4
+ - Scope: how `od/*` rules are written, which linter runs them, how existing debt is baselined, and single-file checks in agent hooks
5
+ - Evidence: the linter evaluation (ESLint, Oxlint and Biome on opengame `f1119f03c6` and openmotion `69f15883f`) and a survey of 65 well-known active repositories, both from 2026-12-03
6
+ - Supersedes: an earlier draft that chose ESLint
7
+
8
+ ## Context
9
+
10
+ The 2026-12-03 review set the gate principle: every rule that a program can check becomes a linter rule and blocks in CI. Biome and Oxlint were both proposed; the original harness plan used ESLint 10 with typescript-eslint (no type-aware rules). The decision was to measure against four criteria first:
11
+
12
+ 1. Can it host `od/*` custom rules, each with its own rule ID and a three-part message?
13
+ 2. Can it block only new violations, with a per-file × per-rule baseline?
14
+ 3. Can a single file be checked in under one second, including process start-up?
15
+ 4. Can it run in Claude Code and Codex PostToolUse hooks and exit 2 on new violations?
16
+
17
+ Each linter implemented three representative rules: `od/no-locale-branch` (AST pattern), `od/no-shell-imports-product` (path-based import boundary that reads configuration) and `od/no-raw-storage`.
18
+
19
+ ## Options
20
+
21
+ | | ESLint 10.16.0 | Oxlint 1.96.0 | Biome 2.6.10 |
22
+ | ------------------------------------------ | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
23
+ | Custom rules | Stable rule API; all three rules; rules read options | Loads the ESLint plugin unchanged through `jsPlugins`; hits identical to ESLint line by line. JS plugins are marked "alpha and not subject to semver" | GritQL cannot see the file path; path-based rules need the Developer Preview JS plugins; plugins cannot read options; same-file alias tracking took 9.9 s per file and had to be dropped (opengame: 20 fewer hits) |
24
+ | Block only new violations | Native bulk suppressions | Native `--suppress-all` / `--prune-suppressions`, same file format as ESLint; the flags are not in `--help` and the docs PR is unmerged | None; needs a wrapper script |
25
+ | Single-file cold start (1,603 / 109 lines) | 304 / 224 ms | 73 / 61 ms | 89 / 37 ms (without alias tracking) |
26
+ | Whole repository (opengame) | 6.8 s | 0.45 s | 1.1 s |
27
+ | Hook (fake Claude / Codex payloads) | Works, 0.23–0.34 s | Works, 0.08–0.09 s | Works through a wrapper, 0.11–0.15 s |
28
+ | Forbid inline disables of `od/*` | Yes | Yes (eslint-comments plugin loaded as a JS plugin) | No |
29
+
30
+ Survey (65 hand-picked active repositories, 2026-12-03): 20 use Oxlint as their main linter, 18 of them migrated from ESLint in 2026 (Vite, Vitest, Electron, Sentry, vercel/ai, tRPC, Turborepo, tldraw, PostHog, Twenty, Plane, Langfuse, LobeChat and others); at least 14 load custom JS plugin rules. Sentry's setup matches ours: design-system rules plus an `oxlint-suppressions.json` baseline. 30 still use ESLint, mostly framework repositories (React, Vue, Svelte) and the Codex and Gemini CLIs; 6 lint with Biome.
31
+
32
+ ## Decision
33
+
34
+ 1. **Oxlint runs the rules**, pinned to an exact version in od-harness (no `^`).
35
+ 2. **Rules are written as an ESLint plugin**, loaded by Oxlint as a JS plugin, one rule ID per rule. Rules use only the ESLint API that Oxlint's JS plugins support: no type information, no `parserServices`, options that are plain JSON. The same plugin can be run by ESLint again at any time.
36
+ 3. **Existing debt lives in `oxlint-suppressions.json`** and may only shrink; CI compares it with the base commit.
37
+ 4. **No bypass**: `@eslint-community/eslint-plugin-eslint-comments` is loaded as a JS plugin to reject `eslint-disable` and `oxlint-disable` comments for `od/*` and `rules-of-hooks`; unused disable directives are reported.
38
+ 5. **No Biome; ESLint is the fallback only.** CI never runs two linters.
39
+ 6. Type-aware rules (for example floating promises) stay off. Oxlint's type-aware mode depends on TypeScript 7; revisit once the repositories are on TypeScript 7.
40
+
41
+ ## Consequences
42
+
43
+ Benefits:
44
+
45
+ - About 0.07 s per file and 0.5 s per repository, so hooks and local verification cost almost nothing and there is room for the repositories to grow.
46
+ - Same toolchain family as Vite 8 (Rolldown, Oxc), in line with where the ecosystem is moving.
47
+ - Rule code is not tied to the runner; switching back to ESLint is a configuration change.
48
+
49
+ Costs and follow-ups:
50
+
51
+ - **Upgrade risk**: the JS plugin API is not covered by semver and the bulk suppression flags are undocumented. Before an Oxlint upgrade merges, two checks must agree completely: (1) the rule cases, including the 13 cases from the linter evaluation (in the `no-locale-branch`, `no-raw-storage` and `no-shell-imports-product` cases), under ESLint's RuleTester and through the Oxlint CLI (`test/oxlint-conformance.test.ts`); (2) the hit comparison on real code: ESLint and Oxlint must report the same lines for `od/no-locale-branch`, `od/no-raw-storage` and `od/no-shell-imports-product` (`node scripts/hit-compare.ts <snapshot-dir>...` on opengame and openmotion checkouts; at the measured commits 399 / 129 / 65 and 73 / 119 / 15 hits).
52
+ - **Noise when a baseline is exceeded**: once a file × rule count is exceeded, the whole group is reported (in the evaluation: one new hit, 68 lines). Hooks and local verification must filter by changed lines before showing results to an agent.
53
+ - **Unused disable directives** are not accepted into the ESLint baseline (opengame 39, openmotion 38); check the same for Oxlint and clean them up in the adoption change if needed.
54
+ - **Baselines are keyed by file path**: moving a file resurfaces its debt, so a `baseline move` command is needed before directories move.
55
+ - **`exhaustive-deps` is Oxlint's own implementation**, so counts change (opengame: ESLint 152, Oxlint 165); the differences were not reviewed one by one.
56
+
57
+ ## Review triggers (any one of them reopens running the rules with ESLint)
58
+
59
+ - After an Oxlint upgrade, the rule cases or the hit comparison diverge and cannot be fixed within one release cycle.
60
+ - Oxlint removes or breaks the bulk suppression flags.
61
+ - A required rule can only be written with ESLint-specific APIs (for example `parserServices`).
62
+
63
+ Cost of switching back: the plugin code does not change; the configuration is rewritten as `eslint.config.mjs`; the baseline file format is the same and is regenerated once with ESLint rule IDs. This assumes ESLint can parse the repository's TypeScript: typescript-eslint 8.74 supports TypeScript below 6.1 only, so a repository already on TypeScript 7 that switches back must pin the parser to TypeScript 6, as this repository's `tools/ts-eslint-parser` does.
64
+
65
+ ## Addendum: what the first version measured (od-harness 0.1.0-alpha.0, 2026-12-03)
66
+
67
+ - Configuration is `.oxlintrc.json` with `extends` (file paths, resolved relative to the extending file; package names are not resolved), not `oxlint.config.ts`.
68
+ - `options.reportUnusedDisableDirectives` takes effect from an extended configuration too (checked through two levels of `extends`, from a local file and from a preset in `node_modules`), although Oxlint's configuration schema describes it as root-only. The base preset sets it to `error`; `test/presets.test.ts` and `pnpm smoke` check that a consumer without the option still gets the errors, so an upgrade that changes this fails there.
69
+ - Unused disable directives are **not** accepted into `oxlint-suppressions.json` either (openmotion 40, opengame 41 at severity `error`). `oxlint --fix` removes some of them (same-line `oxlint-disable-line`); the rest are removed by hand in the adoption change.
70
+ - Exceeding a file × rule count reports the whole group under Oxlint too (one new hit in a file with 179 baselined hits: 180 reported).
71
+ - A disable comment that names no rule (`/* eslint-disable */`) makes `@eslint-community/eslint-plugin-eslint-comments` report at column -1. ESLint accepts that; Oxlint 1.96.0 throws a RangeError on line 1, and the file loses every JS plugin diagnostic (all `od/*`). The presets load a thin wrapper of the plugin (`src/eslint-comments/`) that reports at column 0 instead. A naive clamp that keeps the report's end inside the comment is suppressed by the comment itself, so the wrapper uses a zero-width location; `test/presets.test.ts` covers every directive form. Upstream issue draft: `docs/upstream/oxc-negative-column.md`.
72
+ - `oxlint --suppress-all` also freezes `eslint-comments/no-restricted-disable` reports. Inline disables that exist at adoption become baseline debt; `od-harness ratchet` keeps that count from growing.
73
+ - Oxlint reports columns in UTF-8 bytes (native rules too); ESLint reports UTF-16 code units. Lines agree. The conformance suite converts before comparing.
74
+ - With `correctness` enabled and the react plugin on, Oxlint also runs its React Compiler-derived correctness rules (`react/refs`, `react/set-state-in-effect`, `react/immutability`, …), which add several hundred baseline entries per repository. The base preset turns them off and the opt-in `react-compiler` preset turns them on ([0002](0002-react-compiler-rules.md)).
@@ -0,0 +1,34 @@
1
+ # 0002: Keep the React Compiler rules out of the base preset
2
+
3
+ - Status: accepted (2026-12-03)
4
+ - Scope: which of Oxlint's `react/*` correctness rules the `base` preset runs
5
+ - Evidence: trial runs of the presets on opengame `f1119f03c6` and openmotion `69f15883f7` (Oxlint 1.96.0, `pnpm trial`), 2026-12-03
6
+
7
+ ## Context
8
+
9
+ The `base` preset turns on Oxlint's whole `correctness` category with the `react` plugin. In Oxlint 1.96.0 that category includes eight rules derived from React Compiler's checks:
10
+
11
+ `react/refs`, `react/set-state-in-effect`, `react/immutability`, `react/preserve-manual-memoization`, `react/purity`, `react/use-memo`, `react/incompatible-library`, `react/static-components`.
12
+
13
+ They check the assumptions React Compiler relies on. Neither product repository uses React Compiler, and none of the eight is in the harness plan's rule table. In the trial they made up a large share of what the presets reported:
14
+
15
+ | Repository | Diagnostics | From the eight rules | Largest |
16
+ | ---------- | ----------- | -------------------- | ------------------------------------- |
17
+ | openmotion | 4,299 | 681 (15.8%) | `refs` 395, `set-state-in-effect` 213 |
18
+ | opengame | 7,489 | 890 (11.9%) | `refs` 464, `set-state-in-effect` 316 |
19
+
20
+ The diagnostics are the baseline entries (openmotion 4,259, opengame 7,448) plus the unused disable directives that cannot be baselined (40, 41).
21
+
22
+ ## Decision
23
+
24
+ 1. `base` turns the eight rules off explicitly. `react/rules-of-hooks` and `react/exhaustive-deps` stay on.
25
+ 2. A separate preset, `presets/react-compiler.json`, turns the eight rules on as errors. It is extended after `base` (a later `extends` entry wins, so listed before `base` it has no effect).
26
+ 3. od-platform extends `react-compiler` from the start. A product repository extends it in the change that turns React Compiler on.
27
+
28
+ ## Consequences
29
+
30
+ - Trial after the change: openmotion baseline 3,578 entries in 500 files (was 4,259 in 629), opengame 6,558 in 547 files (was 7,448 in 682). With `react-compiler` extended again, both repositories report exactly the earlier 681 and 890.
31
+ - Disable comments for these rules become unused directives under `base` alone, and unused directives are errors. Both snapshots have three `oxlint-disable-line react/refs` comments (unused directives: openmotion 43, opengame 44). The adoption change deletes them, or the repository extends `react-compiler`.
32
+ - Turning `react-compiler` on later changes `.oxlintrc.json`, so `od-harness ratchet` accepts the new rule IDs in that change. A repository that has `oxlint-suppressions.json` can freeze the existing hits there (`oxlint --suppress-all` on an otherwise clean branch); a repository without it fixes them, because only the adoption change may create a baseline file.
33
+ - This decision covers the eight rules above only. Oxlint 1.96.0's `correctness` category has further React rules in the same area (`react/set-state-in-render`, `react/globals`, `react/error-boundaries`, `react/void-use-memo`); they stay in `base` and report nothing on either snapshot.
34
+ - Versioning (README, "Versioning"): a change that makes a preset report more, such as putting these rules back into `base`, only ships in a minor or major version; a change that only turns rules off, like this one, may ship in a patch version.
@@ -0,0 +1,49 @@
1
+ # od-harness ratchet
2
+
3
+ Baselines may only shrink. `od-harness ratchet --base <ref>` compares the working tree with the base commit (in CI: `"$HARNESS_BASE_REF"`, the PR base).
4
+
5
+ It fails when:
6
+
7
+ | Check | Fails when |
8
+ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `oxlint-suppressions.json`, per rule | the total count of any rule ID grew (summed over all files). Debt may move between files as long as the total does not grow. |
10
+ | `oxlint-suppressions.json`, new rule IDs | a rule appears that the base did not have, unless `.oxlintrc.json` or the `@opendesignai/harness` version in `package.json` changed in the same change (both are owner-reviewed). |
11
+ | `oxlint-suppressions.json`, new files | an entry names a file that the base commit does not have. New files do not get a baseline, also not in the adoption change or together with a new rule ID; a moved or renamed file counts as new until `od-harness baseline move` exists. |
12
+ | both baselines, stale entries | an entry names a file that no longer exists. |
13
+ | `.harness/size-baseline.json` | an entry was raised, or a file was added. |
14
+ | both baselines, new baseline file | the base commit has no such file, unless the same change adds `@opendesignai/harness` to `package.json` (the adoption change). Upgrading the harness or changing `.oxlintrc.json` does not count. |
15
+
16
+ A baseline file may only appear in the adoption change: the change that adds `@opendesignai/harness` to `package.json`, where the base lists it in neither `dependencies` nor `devDependencies`. Then the comparison with the base is skipped and reported. Any later change that creates `oxlint-suppressions.json` or `.harness/size-baseline.json` fails, also one that upgrades the harness or changes `.oxlintrc.json`: a repository that was adopted without a baseline (no existing debt) keeps it that way, and the violations an upgrade or a config change brings are fixed in that change instead of frozen. This does not depend on review, so it holds even when a change is merged without the owner's approval, as long as the caller's workflow keeps `ratchet` on (turning a gate off is a reviewed workflow change).
17
+
18
+ Paths are read relative to the directory `ratchet` runs in, both in the working tree and at the base commit, so it works from a `working-directory` inside a larger repository. `package.json` is read there too, so the adoption change adds `@opendesignai/harness` to the `package.json` of that directory (the `working-directory` of `gates.yml`, which also holds the lockfile).
19
+
20
+ ## Why a config or version change admits new rule IDs
21
+
22
+ The condition follows the harness plan: a rule ID may enter the baseline only in a change that also changes `.oxlintrc.json` or the `@opendesignai/harness` version in `package.json`. The ratchet does not check whether that change is what enabled the rule. Two things keep this from becoming a way around the gate:
23
+
24
+ - new files never enter a baseline (above), so new code cannot hide debt behind a new rule ID;
25
+ - `.oxlintrc.json` and `package.json` belong to the platform owner in CODEOWNERS, so every change that admits a new rule ID is reviewed by the owner.
26
+
27
+ This condition does not admit a new baseline file: only the adoption change may create one (above), so a repository without baselines cannot gain one through a config change or an upgrade, reviewed or not.
28
+
29
+ A narrower condition is left to a later version.
30
+
31
+ The version is read from `dependencies` or `devDependencies` in `package.json`. With a pnpm catalog (`"catalog:"`) the version lives in `pnpm-workspace.yaml`, so an upgrade does not count as a version change there; it admits new rule IDs only together with a change to `.oxlintrc.json`.
32
+
33
+ ## Options
34
+
35
+ ```text
36
+ --base <ref> required; any commit-ish (sha, branch, tag)
37
+ --suppressions <path> default: oxlint-suppressions.json
38
+ --lint-config <path> default: .oxlintrc.json
39
+ ```
40
+
41
+ Exit codes: 0 pass, 1 a check failed, 2 usage error (for example an unknown ref; check out with `fetch-depth: 0`).
42
+
43
+ ## How to fix a failure
44
+
45
+ - **A rule's total grew**: restore `oxlint-suppressions.json` from the base, fix the violations Oxlint reports, then run `oxlint --prune-suppressions` (it can only shrink the file). Never run `oxlint --suppress-all` to get a change through.
46
+ - **Stale entry**: run `oxlint --prune-suppressions` or `od-harness size --update`.
47
+ - **New file in the baseline**: restore the entries from the base, fix the violations in the new file, then run `oxlint --prune-suppressions`. For a moved file, fix the violations at the new path.
48
+ - **New baseline file**: delete it and fix what `oxlint` or `od-harness size` reports. `oxlint --suppress-all` and `od-harness size --init` are for the adoption change only.
49
+ - **Size baseline loosened**: restore the entry and move code out of the file.
@@ -0,0 +1,35 @@
1
+ # od/no-api-path-literal
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ String literals, template literals (by their first fixed part) and JSX attribute strings that start with an API path prefix:
8
+
9
+ ```ts
10
+ const url = "/motion-api/games/" + id;
11
+ const play = `/motion-api/games/${id}/play/index.html`;
12
+ path.replace(/^\/api\//, "/motion-api/");
13
+ ```
14
+
15
+ The bare prefix (`"/api"`) also counts. Module specifiers, type-only literals and regular expressions are not reported.
16
+
17
+ ## Why
18
+
19
+ Hand-written API paths scatter knowledge of the backend layout across the UI. When a prefix or parameter changes (`rev`, `gameStartup`), every copy has to be found by hand; `'/motion-api/'` literals outside the client went from 33 to 73 in opengame.
20
+
21
+ ## How to fix
22
+
23
+ Build URLs with a helper in the API client (add one if missing) and call the helper.
24
+
25
+ ## Exemptions
26
+
27
+ The API client layer, and server code that defines the routes, are exempted with an `overrides` entry in the lint config (owner review). Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
28
+
29
+ ## Options
30
+
31
+ ```json
32
+ ["error", { "prefixes": ["/api/", "/motion-api/"], "client": "studio/src/api" }]
33
+ ```
34
+
35
+ `prefixes` defaults to the value shown; `client` only changes the message text.
@@ -0,0 +1,38 @@
1
+ # od/no-cjk-literal
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ String literals, template literals and JSX text that contain Chinese, Japanese or Korean characters (Han, Hiragana, Katakana, Hangul):
8
+
9
+ ```tsx
10
+ const title = "标题";
11
+ throw new Error("请求失败");
12
+ return <span>中文</span>;
13
+ ```
14
+
15
+ Comments, module specifiers and type-only literals are not reported. CJK punctuation alone (`,。`) is not reported.
16
+
17
+ ## Why
18
+
19
+ Copy hard-coded in source skips translation review and cannot follow the user's locale; logs and errors in Chinese are unreadable for part of the team and for most tooling. opengame had 1,597 such literals.
20
+
21
+ ## How to fix
22
+
23
+ Move user-facing copy into the i18n catalog (every supported locale) and render it with `t("<key>")`. Write logs, error messages and identifiers in English.
24
+
25
+ ## Exemptions
26
+
27
+ Tests and fixtures are excluded by the base preset: `**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`, `**/__fixtures__/**` and `**/fixtures/**`. i18n catalogs differ per repository, so each repository excludes its own in the lint config (`ignorePatterns` or an `overrides` entry, owner review), as do test helpers outside those patterns. Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
28
+
29
+ ## Options
30
+
31
+ ```json
32
+ [
33
+ "error",
34
+ { "pattern": "[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}]" }
35
+ ]
36
+ ```
37
+
38
+ `pattern` is a regular expression evaluated with the `u` flag.
@@ -0,0 +1,33 @@
1
+ # od/no-constant-flag
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ A module-level `const` whose name reads like a feature toggle and whose value is a boolean literal (`true`, `false`, `!0`, `!1`, optionally `as const`):
8
+
9
+ ```ts
10
+ const trailersEnabled = false;
11
+ export const SHOW_STARTER_GIFT_BAR = true;
12
+ const NEW_NAV_ENABLED = !0;
13
+ ```
14
+
15
+ Default name pattern: `…Enabled`, `…Disabled`, `…Flag`, `…_ENABLED`, `…_DISABLED`, `…_FLAG`, `ENABLE_…`, `DISABLE_…`, `FEATURE_…`, `FF_…`, `SHOW_…`, `HIDE_…`, `USE_…`, `enable…`, `disable…`, `show…`, `hide…`. `let` declarations and constants inside functions are not reported.
16
+
17
+ ## Why
18
+
19
+ A hard-coded toggle has no owner or expiry, cannot be switched per environment, and its dead branch stays in the bundle. New entries and replaced navigation items should go through the flag registry instead.
20
+
21
+ ## How to fix
22
+
23
+ Register the flag in the feature-flag registry (owner, expiry date, default off) and read it from there. If the decision is final, delete the constant and the branch it guards.
24
+
25
+ ## Exemptions
26
+
27
+ None inline: disable comments are rejected. A constant that is not a toggle should be renamed so it does not read like one. The rule has almost no existing debt (one or two hits per repository), so it is meant to block from day one.
28
+
29
+ ## Options
30
+
31
+ ```json
32
+ ["error", { "pattern": "<regular expression for the name, anchored automatically>" }]
33
+ ```
@@ -0,0 +1,55 @@
1
+ # od/no-error-message-match
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ Decisions that depend on the wording of an error message:
8
+
9
+ ```ts
10
+ if (msg.includes("timed out")) …
11
+ if (err.message.startsWith("fetch failed")) …
12
+ if (/socket hang up/i.test(err.message)) …
13
+ if (error.message === "Not found") …
14
+ const lower = String(error).toLowerCase();
15
+ if (lower.includes("econnreset")) …
16
+ ```
17
+
18
+ An expression holds error message text when it is:
19
+
20
+ - a `.message` member (`err.message`, `error?.message`);
21
+ - an identifier matching `identifierPattern` (default, case-insensitive: `msg`, `errMsg`, `errorMessage`, `errText`, `errorText`, …);
22
+ - `String(e)` where `e` matches `errorPattern` (default `e`, `err`, `error`, `ex`, `exc`, `exception`, `cause`);
23
+ - `toLowerCase()` / `trim()` / similar on any of the above, `x ?? ""`, or a conditional with such a branch;
24
+ - a same-file variable initialised from any of the above (unless `trackAliases` is `false`).
25
+
26
+ Reported: `includes` / `startsWith` / `endsWith` / `indexOf` / `match` / `search` with a string or regex literal, `regex.test(message)`, and equality with a string literal.
27
+
28
+ ## Why
29
+
30
+ The producer of the error does not know anyone depends on its wording. When it is reworded the branch, or the telemetry attribution built on it, silently stops matching. opengame's `tracking/tool-fields.ts` alone attributes errors through 121 such `includes` calls on gateway error text.
31
+
32
+ ## How to fix
33
+
34
+ Give the error a stable machine-readable signal at the source (an error `code`, a typed error class checked with `instanceof`, or a structured result) and branch on that.
35
+
36
+ ## Exemptions
37
+
38
+ Adapters for third-party errors that expose nothing but text belong in one module that maps them to codes; that module is exempted with an `overrides` entry in the lint config (owner review). Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
39
+
40
+ ## Options
41
+
42
+ ```json
43
+ [
44
+ "error",
45
+ {
46
+ "identifierPattern": "^(?:msg|err(?:or)?_?(?:msg|message|text))$",
47
+ "errorPattern": "^(?:e|err|error|ex|exc|exception|cause)$",
48
+ "trackAliases": true
49
+ }
50
+ ]
51
+ ```
52
+
53
+ ## Limits
54
+
55
+ A plain `message` or `text` identifier is not treated as error text unless it is assigned from one (chat messages are common). Alias tracking is per file and by name.
@@ -0,0 +1,51 @@
1
+ # od/no-locale-branch
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ A conditional (`? :` or `if`) whose test is derived from the locale and where either branch contains non-empty copy (a string literal, a template literal or JSX text):
8
+
9
+ ```tsx
10
+ const title = isZh ? "标题" : "Title";
11
+ const greeting = locale === "zh-CN" ? `你好 ${name}` : `Hello ${name}`;
12
+ if (useI18n().locale.startsWith("zh")) { … "…" … }
13
+ ```
14
+
15
+ "Derived from the locale" means, looking through `!`, `&&`, `||`, parentheses and TypeScript wrappers:
16
+
17
+ 1. an identifier matching `aliasPattern` (default `^is(Zh|Chinese|Cn|CN|En|English)$`);
18
+ 2. an equality comparison that mentions `locale` (an identifier or a `.locale` member such as `useI18n().locale`);
19
+ 3. `startsWith` / `endsWith` / `includes` called on such a value;
20
+ 4. a same-file `const`/`let` alias of any of the above (`const zh = locale.startsWith("zh")`), unless `trackAliases` is `false`.
21
+
22
+ A bare mention such as `/^zh/.test(locale)` does not count.
23
+
24
+ ## Why
25
+
26
+ Branching on the locale hard-codes one translation per branch, skips translation review and breaks as soon as a third locale exists. The `isZh` alias is the main way around name-based checks (zh branches grew from 59 to 1,023 after the switch), which is why aliases are tracked.
27
+
28
+ ## How to fix
29
+
30
+ Move the copy into the i18n catalog for every supported locale and render it with `t()`:
31
+
32
+ ```tsx
33
+ const { t } = useI18n();
34
+ const title = t("studio.header.title");
35
+ ```
36
+
37
+ Values that are not copy (URLs, number formats) go into a locale-keyed table read by key, not into a branch.
38
+
39
+ ## Exemptions
40
+
41
+ Inline `eslint-disable` / `oxlint-disable` comments for `od/*` rules are rejected by `eslint-comments/no-restricted-disable`. Existing debt is recorded in `oxlint-suppressions.json` when the repository adopts the rule and may only shrink. A file that legitimately needs locale branches is exempted with an `overrides` entry in the lint config, which the owner reviews.
42
+
43
+ ## Options
44
+
45
+ ```json
46
+ ["error", { "trackAliases": true, "aliasPattern": "^is(Zh|Chinese|Cn|CN|En|English)$" }]
47
+ ```
48
+
49
+ ## Limits
50
+
51
+ Alias tracking is per file and by name, not by scope. Ported from the prototype of the linter evaluation ([ADR 0001](../decisions/0001-oxlint.md)), where ESLint and Oxlint reported identical lines on opengame (399) and openmotion (73).
@@ -0,0 +1,27 @@
1
+ # od/no-process-env
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ `process.env` (and `process["env"]`) where `process` is the global. A local or imported `process` is not reported.
8
+
9
+ ## Why
10
+
11
+ Scattered `process.env.X` reads give a variable no declared type, default, owner or documentation, and each call site parses it differently. The opengame backend reads 95 distinct variables from 50 files, 22 of them added in the measured window.
12
+
13
+ ## How to fix
14
+
15
+ Declare each variable once in the env registry module (name, type, default, description) and import the typed value from there.
16
+
17
+ ## Exemptions
18
+
19
+ The env registry module is exempted with an `overrides` entry in the lint config, as are build scripts and config files if the repository decides so (owner review). Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
20
+
21
+ ## Options
22
+
23
+ ```json
24
+ ["error", { "registry": "shared/env.ts" }]
25
+ ```
26
+
27
+ `registry` only changes the message text.
@@ -0,0 +1,35 @@
1
+ # od/no-product-literal
2
+
3
+ Presets: `platform-boundary`, `product`
4
+
5
+ ## What it reports
6
+
7
+ Code that branches on product identity:
8
+
9
+ ```ts
10
+ if (product === "opengame") …
11
+ const brand = currentProductId() === "opengame" ? "OpenGame" : "OpenMotion";
12
+ switch (scheme) { case "openmotion": … }
13
+ ```
14
+
15
+ Reported: equality comparisons (`===`, `!==`, `==`, `!=`) where one side is a product id literal or a call to a product-id accessor, and `case` clauses with a product id. Plain strings, arrays and object keys are not reported.
16
+
17
+ ## Why
18
+
19
+ Platform code must work for any product without naming one. Each `=== "opengame"` is a place that silently does the wrong thing for the next product and keeps product knowledge in the shell.
20
+
21
+ ## How to fix
22
+
23
+ Describe the difference in the product manifest (`open-design.json`) or the product registry and read it from there, or check a capability. Brand names, URLs and feature differences are manifest data.
24
+
25
+ ## Exemptions
26
+
27
+ The product registry or identity module that maps ids to manifests can be exempted with an `overrides` entry in the lint config (owner review). Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
28
+
29
+ ## Options
30
+
31
+ ```json
32
+ ["error", { "products": ["opengame", "openmotion"], "accessors": ["currentProductId"] }]
33
+ ```
34
+
35
+ Both default to the values shown. Setting an option replaces its default.