@opendesignai/harness 0.3.0-alpha.0 → 0.5.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.
package/dist/plugin.d.mts CHANGED
@@ -36,6 +36,6 @@ interface Plugin {
36
36
  rules: Record<string, PluginRule>;
37
37
  }
38
38
  /** Kept in sync with package.json by test/plugin.test.ts. */
39
- export declare const VERSION = "0.3.0-alpha.0";
39
+ export declare const VERSION = "0.5.0-alpha.0";
40
40
  declare const plugin: Plugin;
41
41
  export { type Plugin, type PluginRule, type RuleContextLike, type RuleMeta, plugin as default };
package/dist/plugin.mjs CHANGED
@@ -210,6 +210,122 @@ function compileRegExp(pattern, flags, option) {
210
210
  // src/plugin/rules/no-api-path-literal.ts
211
211
  const RULE$12 = "no-api-path-literal";
212
212
  const DEFAULT_PREFIXES = ["/api/", "/motion-api/"];
213
+ const ROUTE_METHODS = /* @__PURE__ */ new Set([
214
+ "get",
215
+ "post",
216
+ "put",
217
+ "patch",
218
+ "delete",
219
+ "head",
220
+ "options",
221
+ "connect",
222
+ "trace",
223
+ "all",
224
+ "use",
225
+ "route",
226
+ "on"
227
+ ]);
228
+ const ROUTER_NAMES = /* @__PURE__ */ new Set([
229
+ "app",
230
+ "router",
231
+ "routes",
232
+ "server",
233
+ "hono",
234
+ "fastify"
235
+ ]);
236
+ const ROUTER_CONSTRUCTORS = /* @__PURE__ */ new Set([
237
+ "Hono",
238
+ "Router",
239
+ "KoaRouter"
240
+ ]);
241
+ const ROUTER_FACTORIES = /* @__PURE__ */ new Set([
242
+ "express",
243
+ "Router",
244
+ "fastify"
245
+ ]);
246
+ const CLIENT_NAMES = /* @__PURE__ */ new Set([
247
+ "axios",
248
+ "ky",
249
+ "client"
250
+ ]);
251
+ const HANDLER_REFERENCES = /* @__PURE__ */ new Set([
252
+ "Identifier",
253
+ "MemberExpression",
254
+ "CallExpression",
255
+ "ArrayExpression",
256
+ "SpreadElement"
257
+ ]);
258
+ const HTTP_METHOD = /^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|CONNECT|TRACE)$/i;
259
+ const EQUALITY_OPERATORS = /* @__PURE__ */ new Set([
260
+ "==",
261
+ "===",
262
+ "!=",
263
+ "!=="
264
+ ]);
265
+ function isHttpMethod(node) {
266
+ const method = staticString(node);
267
+ return method !== null && HTTP_METHOD.test(method);
268
+ }
269
+ function routeMethod(callee) {
270
+ const method = callee && propertyName(callee);
271
+ return method !== null && ROUTE_METHODS.has(method) ? method : null;
272
+ }
273
+ function routeRoot(node) {
274
+ let root = unwrap(node) ?? node;
275
+ while (root.type === "CallExpression") {
276
+ const callee = unwrap(root.callee);
277
+ if (callee?.type !== "MemberExpression" || routeMethod(callee) === null) break;
278
+ root = unwrap(callee.object) ?? callee.object;
279
+ }
280
+ return root;
281
+ }
282
+ function followedByRouteCall(call) {
283
+ const member = call.parent;
284
+ if (member?.type !== "MemberExpression" || member.object !== call) return false;
285
+ const next = member.parent;
286
+ return next?.type === "CallExpression" && next.callee === member && routeMethod(member) !== null;
287
+ }
288
+ function isRouteRegistration(node, call, callee) {
289
+ const method = routeMethod(callee);
290
+ if (method === null) return false;
291
+ const pathIndex = method === "on" ? 1 : 0;
292
+ const path = call.arguments[pathIndex];
293
+ const isOnPathElement = method === "on" && path?.type === "ArrayExpression" && node.parent === path;
294
+ if (path !== node && !isOnPathElement) return false;
295
+ if (method === "on") {
296
+ const verbs = unwrap(call.arguments[0]);
297
+ if (!(verbs?.type === "ArrayExpression" ? verbs.elements.length > 0 && verbs.elements.every(isHttpMethod) : isHttpMethod(verbs))) return false;
298
+ }
299
+ const root = routeRoot(callee.object);
300
+ const receiver = calleeName(root.type === "CallExpression" || root.type === "NewExpression" ? root.callee : root);
301
+ if (receiver !== null && CLIENT_NAMES.has(receiver)) return false;
302
+ let routerNames = ROUTER_NAMES;
303
+ if (root.type === "CallExpression") routerNames = ROUTER_FACTORIES;
304
+ if (root.type === "NewExpression") routerNames = ROUTER_CONSTRUCTORS;
305
+ const namedRouter = receiver !== null && routerNames.has(receiver);
306
+ if (method === "route") return namedRouter && (call.arguments.length >= 2 || followedByRouteCall(call));
307
+ return call.arguments.slice(pathIndex + 1).some((argument) => {
308
+ const handler = unwrap(argument);
309
+ return handler !== null && (handler.type === "ArrowFunctionExpression" || handler.type === "FunctionExpression" || namedRouter && HANDLER_REFERENCES.has(handler.type));
310
+ });
311
+ }
312
+ function isPathname(node) {
313
+ const value = unwrap(node);
314
+ if (!value) return false;
315
+ return value.type === "Identifier" ? value.name === "pathname" : propertyName(value) === "pathname";
316
+ }
317
+ function isRouteDefinition(node) {
318
+ const parent = node.parent;
319
+ if (!parent) return false;
320
+ if (parent.type === "BinaryExpression" && EQUALITY_OPERATORS.has(parent.operator)) return parent.left === node && isPathname(parent.right) || parent.right === node && isPathname(parent.left);
321
+ if (parent.type === "SwitchCase" && parent.test === node) return parent.parent?.type === "SwitchStatement" && isPathname(parent.parent.discriminant);
322
+ const call = parent.type === "ArrayExpression" ? parent.parent : parent;
323
+ if (call?.type !== "CallExpression") return false;
324
+ const callee = unwrap(call.callee);
325
+ if (callee?.type !== "MemberExpression") return false;
326
+ if (propertyName(callee) === "startsWith") return call.arguments[0] === node && isPathname(callee.object);
327
+ return isRouteRegistration(node, call, callee);
328
+ }
213
329
  const noApiPathLiteral = {
214
330
  meta: {
215
331
  type: "problem",
@@ -248,7 +364,9 @@ const noApiPathLiteral = {
248
364
  function check(node, text) {
249
365
  if (isModuleSource(node) || isInTypePosition(node)) return;
250
366
  const prefix = matchPrefix(text);
251
- if (prefix !== null) context.report({
367
+ if (prefix === null) return;
368
+ if (staticString(node) !== null && isRouteDefinition(node)) return;
369
+ context.report({
252
370
  node,
253
371
  messageId: "apiPath",
254
372
  data: {
@@ -1640,7 +1758,7 @@ const noWindowBus = {
1640
1758
  };
1641
1759
  // src/plugin/version.ts
1642
1760
  /** Kept in sync with package.json by test/plugin.test.ts. */
1643
- const VERSION = "0.3.0-alpha.0";
1761
+ const VERSION = "0.5.0-alpha.0";
1644
1762
  // src/plugin/index.ts
1645
1763
  const plugin = {
1646
1764
  meta: {
package/dist/report.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as isGitHubActions } from "./child-env-cPBUueQI.mjs";
1
+ import { i as isGitHubActions } from "./child-env-BX7ENXDG.mjs";
2
2
  // src/cli/diagnostic.ts
3
3
  function diagnosticMessage({ message, fix, exemption, docs, severity }) {
4
4
  return [
package/docs/adopting.md CHANGED
@@ -11,7 +11,7 @@ pnpm add -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
11
11
  # or: npm install -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
12
12
  ```
13
13
 
14
- pnpm 12 checks every version it installs against `minimumReleaseAge` (1,440 minutes unless the repository sets it): a version published more recently needs an entry in `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`, and CI's frozen install checks the lockfile against both. To adopt or upgrade to an od-harness release within that window, install the exact version and commit its entry, for example `"@opendesignai/harness@0.3.0-alpha.0"`. Under pnpm's built-in setting, which is not strict, `pnpm install` writes the entry itself; a repository that sets `minimumReleaseAge` approves it at pnpm's prompt or adds it by hand. The entry can go once the release is older than the window; the pnpm documentation describes these settings.
14
+ pnpm 12 checks every version it installs against `minimumReleaseAge` (1,440 minutes unless the repository sets it): a version published more recently needs an entry in `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`, and CI's frozen install checks the lockfile against both. To adopt or upgrade to an od-harness release within that window, install the exact version and commit its entry, for example `"@opendesignai/harness@0.5.0-alpha.0"`. Under pnpm's built-in setting, which is not strict, `pnpm install` writes the entry itself; a repository that sets `minimumReleaseAge` approves it at pnpm's prompt or adds it by hand. The entry can go once the release is older than the window; the pnpm documentation describes these settings.
15
15
 
16
16
  Releases are published to npm under the `opendesignai` organization with the `alpha` dist-tag, by the release workflow through npm trusted publishing ([README, Versioning](../README.md#versioning)). To try an unreleased change, run `pnpm pack` in an od-harness checkout and install the tarball it writes (never the checkout itself, which has `catalog:` and `workspace:` specifiers), for example `"@opendesignai/harness": "file:vendor/opendesignai-harness-0.1.0-alpha.0.tgz"`.
17
17
 
@@ -59,7 +59,7 @@ Create `.oxlintrc.json` at the repository root:
59
59
  - The base preset reports unused disable directives as errors (`options.reportUnusedDisableDirectives`) and fails the run on warnings (`options.denyWarnings`); there is no need to repeat either here. A rule this file sets to `"warn"` therefore fails the run like an error: during adoption, baseline its findings or turn it off rather than leave it at `warn`.
60
60
  - 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.
61
61
  - Exemptions are `overrides` entries in this file. The file belongs to the platform owner (CODEOWNERS); every exemption is reviewed there, never inline.
62
- - CODEOWNERS also gives the platform owner `package.json` (the harness version), `.harness/config.json` and the knip configuration (step 3a). `od-harness ratchet` admits new rule IDs into an existing baseline only in a change that upgrades the harness, or whose `.oxlintrc.json` change turns those rules on, so this review is what guards the baselines ([ratchet](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)). With a pnpm catalog, `pnpm-workspace.yaml` holds the harness version: give it to the owner too. A new baseline file it admits only in the adoption change, without relying on review.
62
+ - CODEOWNERS also gives the platform owner `package.json` (the harness version), `.harness/config.json` and the knip configuration (step 3a). `od-harness ratchet` allows existing rule totals to grow only in the harness upgrade change. New rule IDs may enter an existing baseline when upgrading the harness or when a change to `.oxlintrc.json` turns them on. Give the platform owner `pnpm-workspace.yaml` too if a pnpm catalog holds the harness version. A new baseline file is allowed only in the adoption change ([ratchet](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)).
63
63
  - Run Oxlint from the repository root: path options (`shell`, `product`) are relative to the working directory.
64
64
 
65
65
  Add scripts:
@@ -104,6 +104,26 @@ After type-checking, run `node lint-config.mts > .oxlintrc.json` from the reposi
104
104
 
105
105
  If you also commit `lint-config.mts` and run `od-harness unused`, register the file as a knip entry point. Add `"lint:config": "node lint-config.mts > .oxlintrc.json"` under `scripts` in `package.json`, or add `lint-config.mts` to `entry` in `knip.json`. Without an entry point, `unused` reports the script as a new unused file.
106
106
 
107
+ ### Testing and strict types
108
+
109
+ Add either or both optional presets after `base` in the root `.oxlintrc.json`:
110
+
111
+ ```json
112
+ {
113
+ "extends": [
114
+ "./node_modules/@opendesignai/harness/presets/base.json",
115
+ "./node_modules/@opendesignai/harness/presets/testing.json",
116
+ "./node_modules/@opendesignai/harness/presets/strict-types.json"
117
+ ]
118
+ }
119
+ ```
120
+
121
+ - `base` already checks TypeScript directives. It reports `@ts-ignore`, `@ts-nocheck`, and `@ts-expect-error` without a description. Use a described `@ts-expect-error` for a deliberate negative type test. `@ts-check` is allowed.
122
+ - `testing` reports skipped and focused Vitest tests. It explicitly turns off the other Vitest rules inherited from `correctness`, including `vitest/expect-expect`. Keep any Vitest rules your repository explicitly enables in its root `rules` or in a preset listed after `testing`. Oxlint uses the last `extends` entry for conflicting settings, then applies root `rules`. Additional categories selected by the repository can enable Vitest rules in those categories.
123
+ - `strict-types` reports any explicit TypeScript `any`. It runs with the ordinary Oxlint binary and can be adopted independently of `type-aware`.
124
+
125
+ On the three pilot snapshots, the new `base` check and `testing` each added zero diagnostics. `strict-types` reported 1,691 violations of `typescript/no-explicit-any` in opengame, 203 in openmotion, and zero in od-platform. Nine previously unused disable directives in each product snapshot began suppressing the rule, so total diagnostics increased by 1,682 in opengame and 194 in openmotion. Measure the final configuration in your repository to size the adoption change. Fix the findings, or record the newly enabled rules in an existing baseline as part of the reviewed configuration change. Repositories that adopted without a baseline fix the findings in that change. [ADR 0005](decisions/0005-test-weakening-rules.md) · [Ratchet rules](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)
126
+
107
127
  ### Type-aware linting
108
128
 
109
129
  Install the exact backend version as a direct dev dependency when opting in. The harness declares it as an optional peer. Oxlint exits with status 1 if it cannot find the backend executable. Oxlint 1.95 and 1.96 require tsgolint 7.0.2008 or later. Every harness PR that upgrades Oxlint must upgrade the tsgolint pin in the same PR.
@@ -150,7 +170,7 @@ With a non-root `working-directory` in `gates.yml`, keep `.oxlintrc.json` at the
150
170
 
151
171
  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).
152
172
 
153
- The `base` preset's `od/no-swallowed-catch` reports empty catch blocks and rejection handlers, as well as handlers that only return a constant such as `null`, `undefined`, an empty string, or a boolean. A probe is exempt when `try` contains one direct call (optionally `await`ed) followed by `return true`, and `catch` contains only `return false`. The call must be free of assignments, increments, decrements, inline functions and chained calls. Non-empty string literals and non-empty template literals without interpolations are exempt in catch blocks and promise rejection handlers. When upgrading, fix newly reported sites in the upgrade change. Run `oxlint --prune-suppressions` to remove any stale entries after the fixes. See [the rule page](rules/no-swallowed-catch.md).
173
+ The `base` preset's `od/no-swallowed-catch` reports empty catch blocks and rejection handlers, as well as handlers that only return a constant such as `null`, `undefined`, an empty string, or a boolean. A probe is exempt when `try` contains one direct call (optionally `await`ed) followed by `return true`, and `catch` contains only `return false`. The call must be free of assignments, increments, decrements, inline functions and chained calls. Non-empty string literals and non-empty template literals without interpolations are exempt in catch blocks and promise rejection handlers. If an upgrade reports more violations and the repository has `oxlint-suppressions.json`, run `oxlint --suppress-all` on an otherwise clean branch and commit the additional suppressions for existing files with the upgrade. Ratchet allows the increase only in that change. A repository without a baseline fixes the violations in the upgrade change. Run `oxlint --prune-suppressions` to remove any stale entries after fixes. See [the rule page](rules/no-swallowed-catch.md).
154
174
 
155
175
  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 both `eslint-comments/no-restricted-disable` and `unicorn/no-abusive-eslint-disable` reject them, one report each. Do not baseline them: the baseline would then hold those two entries while the violations they hide never show up in it. To find them:
156
176
 
@@ -294,7 +314,7 @@ Set `clones: true` and `unused: true` in the change that adopts or upgrades to a
294
314
  | A file or directory is moved | `git mv` (the move must be staged), fix the imports, then, before committing, `od-harness baseline move <old path> <new path>`; commit the baselines with the moved files in the same change. Each new file must still be its old file: a rename git sees (`git diff -M30% -l0`), nothing else counts. The move is reviewed with the change that makes it: `ratchet` lists each moved entry in its output, and where CODEOWNERS covers every path the owner reviews it like any other change. See [baseline move](baseline-move.md). |
295
315
  | `od-harness clones` reports a clone | Extract the shared code instead of copying it. Generated or vendored code goes into `clones.ignore` (owner review); the marker text `jscpd:ignore-start` or `jscpd:ignore-end` on added or edited lines (in a comment, a string or code) of the files jscpd scans—`.es`, `.es6` and files without those extensions whose first line is a shebang that contains `node` included—and tracked files among them that `.gitignore` or `.ignore` excludes, fail the gate. |
296
316
  | `od-harness unused` reports a finding | Delete the unused file, export or dependency, or use it. Code used where knip cannot see it is declared in the knip configuration (owner review); the tags `@public`, `@beta` and `@alias` in a comment (a block comment, or a line comment on a line of its own), and tracked files that `.gitignore` excludes, fail the gate. |
297
- | 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 in the change that upgrades the harness. A repository without `oxlint-suppressions.json` fixes the violations instead; `ratchet` does not let it create one. |
317
+ | An upgrade reports more violations | If the repository already has `oxlint-suppressions.json`, run `oxlint --suppress-all` on an otherwise clean branch and commit the additional suppressions for existing files with the upgrade. Ratchet allows existing rule totals to grow only in that change. A repository without a baseline fixes the violations in the upgrade change. |
298
318
  | Upgrading od-harness turns a rule off | Run `oxlint --prune-suppressions` and delete the disable comments that became unused, in the upgrade change. |
299
319
  | 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 this `.oxlintrc.json` change turns them on (it compares the effective configurations; an unrelated edit to `.oxlintrc.json` admits nothing). |
300
320
  | Turning on type-aware linting | Install the pinned backend and extend `type-aware` after `base`. Fix the findings or add the newly enabled rules to an existing baseline in the same change. [Type-aware linting](#type-aware-linting) |
@@ -0,0 +1,28 @@
1
+ # 0005: Check test weakening and TypeScript escapes with separate presets
2
+
3
+ - Status: accepted (2026-12-05)
4
+ - Evidence: harness-bench 1F at `583c3a3465cfd3d45905b94994528d1f9a1903db` and read-only lint runs with Oxlint 1.96.0 on the snapshots below.
5
+
6
+ ## Decision
7
+
8
+ 1. Enable `typescript/ban-ts-comment` as an error in `base` with Oxlint's default options. It rejects `@ts-ignore` and `@ts-nocheck`, requires a description for `@ts-expect-error`, and allows `@ts-check`. The owner chose to allow rule-specific lint disables for this rule under the existing disable policy.
9
+ 2. Offer `testing` as an opt-in preset with `vitest/no-disabled-tests` and `vitest/no-focused-tests` as errors. The owner kept `base` framework-agnostic. Loading Vitest with `correctness` would enable 17 rules by default. Beyond the two selected rules and `expect-expect`, the other 14 produced 6,185 diagnostics in opengame, 6,163 in openmotion, and zero in od-platform. The preset explicitly disables those 14 rules and `expect-expect`. Consumers can enable their own Vitest rules in root `rules` or a later `extends` entry.
10
+ 3. Offer `strict-types` as a separate opt-in preset with `typescript/no-explicit-any` as an error. The owner chose separate adoption because the rollout costs differ. Explicit `any` is widespread in the two product snapshots and includes deliberate invalid inputs and simplified mocks in tests.
11
+
12
+ Assertion policy belongs to the consumer. With its default options, `vitest/expect-expect` reported 51 diagnostics each in opengame and openmotion and zero in od-platform. In the sample of ten findings per product, nine in opengame and eight in openmotion came from helpers that already performed assertions. Each sample also included a render smoke test. Consumers can configure the assertion helpers they rely on when they choose to enable the rule.
13
+
14
+ ## Verified impact
15
+
16
+ | Snapshot | Revision | Linted files | Added by `base` | Added by `testing` | Added by `strict-types` |
17
+ | ----------- | ------------------------------------------ | -----------: | --------------: | -----------------: | ----------------------: |
18
+ | opengame | `85b8351bc97ebb25d78482fc8667654675957cb5` | 5,033 | 0 | 0 | 1,691 in 209 files |
19
+ | openmotion | `69f15883f73694b7506282e4662cc071b6923b45` | 5,185 | 0 | 0 | 203 in 66 files |
20
+ | od-platform | `ed94b40ee45779fc9fa44c873d4666d77b6f0894` | 93 | 0 | 0 | 0 |
21
+
22
+ The counts compare each configuration with the previous `base` on the same source revision using `oxlint -c <config> --disable-nested-config --format json .` from the snapshot root. Each optional preset was measured with `base`. In each product, nine previously unused disable directives started matching `typescript/no-explicit-any`. Those nine reports drop out of the full output, so the net increases are 1,682 and 194. The openmotion snapshot has a duplicate declaration in `studio/src/motion/SettingsCenter.test.tsx` in all runs, so counts reflect the files and rules Oxlint could analyze.
23
+
24
+ The harness-bench fixture confirms that `base` reports TW-04 and TW-05, `testing` adds TW-01 and TW-02, and `strict-types` adds TW-06. The assertion probe TW-03 and the controls TW-07 and TW-08 pass in all four configurations. Effective-config tests verify the two Vitest errors and the precedence of root `rules` and `extends`. [Adopting the presets](../adopting.md#testing-and-strict-types)
25
+
26
+ ## Release
27
+
28
+ Ship this in a minor release because `base` can report new errors. [Versioning policy](../../README.md#versioning)
package/docs/hooks.md CHANGED
@@ -47,6 +47,16 @@ error. Stop runs the command after a session changes tracked or untracked files,
47
47
  including changes the session committed. It compares with the merge base of
48
48
  `OD_HARNESS_BASE`, `verify.base`, or `origin/main`, in that order. Hook continuation
49
49
  flags and a saved fingerprint prevent repeated blocks for the same findings.
50
+ For a dirty session with a configured Stop check, an unresolved base, missing common
51
+ ancestor, or a command that cannot complete verification shares the limit of two
52
+ Stop blocks per round with check findings. Antigravity receives `continue` with
53
+ the reason on each block. Once the limit is reached, Stop allows completion with
54
+ a `NOT VERIFIED:` warning and records the status for the worktree. Later Stop
55
+ calls retry the check until it can reach a result. Local `od-harness verify`
56
+ reports the saved warning on stderr and runs its own checks with the usual exit
57
+ codes. The warning clears when Stop reaches a result or finds no changes.
58
+ In a remote-free sandbox, set `OD_HARNESS_BASE` to the initial snapshot SHA
59
+ before starting the agent.
50
60
  Stop keeps a combined 64 KiB tail of the check's stdout and stderr for feedback.
51
61
 
52
62
  Claude Code resolves policy from `CLAUDE_PROJECT_DIR` and uses both sets of policy
@@ -62,8 +72,55 @@ tracking metadata pass without a warning. After an edit, the hook runs the
62
72
  local Oxlint with the repository root `.oxlintrc.json` when present and uses the
63
73
  bulk baseline and changed lines to identify excess diagnostics. Antigravity
64
74
  appends diagnostics and a reminder for each applicable ancestor `AGENTS.md`
65
- below the repository root, once per directory, to the original tool result. Session state is stored in the user's private
66
- temporary directory.
75
+ below the repository root, once per directory, to the original tool result.
76
+ Session state and decision logs share the private `os.tmpdir()/od-harness-<uid>`
77
+ directory on Unix. The temporary parent must be owned by the current user or
78
+ have the sticky bit set. If the parent is unsafe, pre-tool policy still runs and
79
+ skips saving the session snapshot and decision log. Set `TMPDIR` to a private
80
+ directory you own to restore writes.
81
+
82
+ Windows continues to use `os.tmpdir()/od-harness` with the permissions of the
83
+ user's temporary directory. After upgrading on Unix, sessions start with fresh
84
+ state and reports read from the new directory. You can leave the old
85
+ `os.tmpdir()/od-harness` directory in place or delete it if it belongs to you
86
+ and you no longer need its state or logs.
87
+
88
+ ## Local decision log
89
+
90
+ Each `pre-bash` and `pre-edit` decision adds one JSON line, including plain
91
+ allows. Records contain the UTC time, agent, event, decision, rule ID, a
92
+ static reason, and SHA-256 hashes of the resolved repository root and the
93
+ shell command or edit target path. A multi-file edit hashes the JSON array of
94
+ target paths in payload order. Unavailable inputs have null hashes. Runtime
95
+ failures that block the call use the `hook-error` rule ID. Notices issued by a
96
+ policy rule use that rule's ID.
97
+
98
+ By default the log keeps commands, raw paths, and file contents out of the
99
+ records. The reason is the rule's description because the message shown to the
100
+ agent can include input values. Set `OD_HARNESS_HOOK_LOG=full` to include the
101
+ first 2,000 characters of each shell command. Shell text may contain credentials
102
+ or inline file contents. Edit payloads and patches are excluded in both modes.
103
+ Set `OD_HARNESS_HOOK_LOG=0` to stop writing and pruning logs.
104
+
105
+ Logs are stored locally as `decisions-YYYY-MM-DD.jsonl` in the state directory.
106
+ New files are created with mode `0600`. Before appending, the hook checks that
107
+ the daily file would stay within 5 MiB. When creating the daily file, it also
108
+ tries to delete logs older than the latest 14 UTC days, including today.
109
+ Concurrent appends near the limit can exceed it by a few records. Logging is
110
+ best effort and leaves the hook decision unchanged if a record cannot be saved.
111
+
112
+ Run `od-harness hooks report [--days N] [--format text|json]` to summarize
113
+ the latest 1 to 14 UTC days, including today. `N` is a decimal integer. The
114
+ default is 14 days and text output. The report groups records by agent,
115
+ decision, and rule. The ratios use all recorded decisions and the agent's
116
+ recorded decisions as denominators.
117
+ The rule ranking counts denials, requests for approval, and allows with a
118
+ notice. Run the report with `OD_HARNESS_HOOK_LOG=full` to display up to five
119
+ stored shell command samples from denials, approval requests, and allows with a
120
+ notice. Unsafe or unreadable state paths produce one line of guidance on
121
+ stderr and exit code 2. Decision counts measure recorded interventions.
122
+ Estimating a false-positive rate also requires identifying which interventions
123
+ were incorrect.
67
124
 
68
125
  ## Three-agent capability and verification matrix
69
126
 
@@ -123,13 +180,22 @@ Paths are normalized (POSIX `/` and Windows `\` separators, `.` and `..` resolut
123
180
 
124
181
  The allowlist does not cover installs that leave out devDependencies (`npm ci --omit=dev`, `pnpm install --frozen-lockfile --prod`): they remove the harness and fall under row 23. The hook reads the effective installation options and exported values. For example, `npm_config_omit=optional npm ci` retains development dependencies. The pnpm `clean` and `purge` built-ins remove `node_modules`. When a package defines a script of the invoked name, the hook checks its body.
125
182
 
183
+ ### Git override allowlist
184
+
185
+ - Existing keys: `color.*`, `core.pager`, `advice.*`, `user.name`, `user.email`.
186
+ - Local conflict resolution and initialization: `rerere.*`, `merge.conflictStyle`, `init.defaultBranch`.
187
+ - Diff and log display: `diff.algorithm`, `diff.context`, `diff.interHunkContext`, `diff.renames`, `log.abbrevCommit`, `log.date`, `log.decorate`.
188
+ - Patch formatting: `format.numbered`, `format.subjectPrefix`, `format.thread`.
189
+
190
+ These additions apply to `git -c` overrides. The hook still denies `--config-env` and keys such as `diff.external`, `diff.<driver>.command` and `diff.<driver>.textconv` that configure executable commands.
191
+
126
192
  ## Complete rule matrix
127
193
 
128
194
  | Row | Category | Examples | `cc` | `codex` | `agy` |
129
195
  | --- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | ---------------------------- | ---------------------------- |
130
196
  | 1 | Bypass git hooks | `git commit --no-verify` / `-n` / `-anm` / `-nm wip` (a value-taking letter ends a cluster, so `git commit -m"fix: …"` is not `-n`); `git push --no-verify`; `git -c core.hooksPath=…`; `git config core.hooksPath …`; `git --config-env=core.hooksPath=…`. Subcommand long options match any prefix git accepts (`--no-verif`, `--no-ver`) | `deny` | `deny` | `deny` |
131
197
  | 2 | Git config via env | `GIT_CONFIG_COUNT`, `GIT_CONFIG_KEY_<n>`, `GIT_CONFIG_VALUE_<n>`, `GIT_CONFIG_PARAMETERS`, `GIT_CONFIG_GLOBAL`, `GIT_CONFIG_SYSTEM`, `GIT_CONFIG` in any assignment (`X=1 cmd`, `env`, `arch -e`, `export`, `declare -x`, `typeset -x`, `set -a`). (`GIT_DIR`/`GIT_WORK_TREE`/`GIT_INDEX_FILE`/`GIT_EXEC_PATH` and their option forms `git --git-dir`, `--work-tree`, `--exec-path=<dir>`: `ask` / `deny` / `deny`.) | `deny` | `deny` | `deny` |
132
- | 3 | Non-allowlisted `git -c` | Any key outside `color.*`, `core.pager`, `advice.*`, `user.name`, `user.email`, or any `--config-env` | `deny` | `deny` | `deny` |
198
+ | 3 | Non-allowlisted `git -c` | Keys outside the [Git override allowlist](#git-override-allowlist), or any `--config-env` | `deny` | `deny` | `deny` |
133
199
  | 4 | Push to integration branch | `main`, `master`, `release/*`, `cloud/main`, `hooks.integrationBranches` (default `pilot/mfe`) — any push, force, or delete; also a refspec whose source is dynamic but whose destination is static (`"$(git rev-parse HEAD):refs/heads/main"`), and a dynamic destination whose static text names `pilot/` or an integration branch. Destinations are read as git matches them: `HEAD:heads/main`, `HEAD:refs/heads/main` and `heads/main` without a colon name `main` (`HEAD:heads-up/x` does not) | `deny` | `deny` | `deny` |
134
200
  | 5 | Push other `pilot/*` | `git push origin pilot/b3-ts7` | `ask` | `allow-with-notice` | `allow-with-notice` |
135
201
  | 6 | Force push / delete `pilot/*` | `git push -f origin pilot/b3-ts7`, `+HEAD:pilot/x`, `--delete pilot/x` (also `--delet`), `:pilot/x`, and `"$SRC:pilot/x"` (a dynamic source may be empty or `+…`) | `deny` | `deny` | `deny` |
@@ -146,12 +212,16 @@ The allowlist does not cover installs that leave out devDependencies (`npm ci --
146
212
  | 16 | Shell write to D/G files | Redirections (`>`, `>>`, `>\|`, `&>`, `<>`), `tee`, `cp`, `mv` (src & dst), `install`, `ln`, `rm`, `touch`, `truncate`, `dd of=`, `sed -i`, `perl -i`, `rsync`, `ditto`, GNU `g`-prefixed tools (`gsed`, `gcp`, …), `python -m json.tool <in> <out>`, `git checkout <rev> -- <path>`, `git restore --source`, `git rm`, `git mv`, `find -delete` / `find -exec … {}` (with the paths `find` can be shown to match), `curl -o`, `wget -O`, inline scripts that call a file-writing API (`node -e`, `python -c`, `perl -e`, `ruby -e`, `deno eval`, `bun -e`, and here-docs or here-strings fed to these interpreters). Targets with brace expressions are expanded (`touch .github/workflows/{a,b}.yml`, `mv package.json{,.bak}`); targets with an unquoted glob are denied when some protected path matches the glob (`> oxlint-suppressions.jso[n]`, `rm -rf .g*`, `mv *.json /tmp/`). Opaque bulk writes covering repo root (`git apply`, `patch`, `unzip`, `tar -x`) → `ask` / `deny` / `deny`. | `deny` | `deny` | `deny` |
147
213
  | 17 | Edit tool on D-class file | `Edit`, `Write`, `MultiEdit`, `NotebookEdit`, `apply_patch`, `write_file`, `edit_file` targeting D-class (whether the agent routes the call to `pre-edit` or `pre-bash`) | `deny` | `deny` | `deny` |
148
214
  | 18 | Edit tool on G-class file | Same edit tools targeting G-class (`AGENTS.md` only when managed block is touched) | `ask` | `allow-with-notice` | `allow-with-notice` |
149
- | 19 | Package manager dep mutations | `npm install <pkg>`, `npm i -D`, `npm uninstall`, `npm pkg set`, `pnpm add`/`remove`/`update`, `yarn add`/`remove`/`upgrade`; npm and pnpm aliases and npm abbreviations count as the command they stand for (`npm add`, `npm isntall`, `pnpm rm`, `npm unpub`) | `ask` | `allow-with-notice` | `allow-with-notice` |
215
+ | 19 | Package manager dep mutations | `npm install <pkg>` (except a literal `-g` enabling global mode), `npm i -D`, `npm uninstall`, `npm pkg set`, `pnpm add`/`remove`/`update`, `yarn add`/`remove`/`upgrade`; npm and pnpm aliases and npm abbreviations count as the command they stand for (`npm add`, `npm isntall`, `pnpm rm`, `npm unpub`) | `ask` | `allow-with-notice` | `allow-with-notice` |
150
216
  | 20 | Regenerate harness | `od-harness init`, `od-harness agents sync` (without `--check`) | `ask` | `allow-with-notice` | `allow-with-notice` |
151
217
  | 21 | Pipe to interpreter | `… \| sh`, `… \| bash`, `… \| (bash)`, `… \| { sh; }`, `… \| source /dev/stdin`, `bash <(…)`, `source <(…)`, `bash < <(…)` when the program is not the output of a static `echo`/`printf` | `deny` | `deny` | `deny` |
152
- | 22 | Opaque / unparseable | Unrecognized syntax, dynamic command name, dynamic `eval`/`bash -c`, dynamic `git`/`gh`/package-manager subcommand (`git $(printf push) …`), inline code that starts a process (`os.system`, `child_process`, `subprocess`, backticks), a glob in the command name (`g* push`), a word after a wrapper that its options do not explain (`timeout --unknown 9 …`), depth > 8: deny keyword → `deny`; ask keyword → `cc: ask`, `codex/agy: deny`; neither → allow + log notice. More than 256 nested wrappers → `deny` on all three agents | keyword | keyword | keyword |
218
+ | 22 | Opaque / unparseable | Unrecognized syntax, dynamic command name, dynamic `eval`/`bash -c`, dynamic `git`/`gh`/package-manager subcommand (`git $(printf push) …`), unresolved or gated keywords in an inline process command (such as arguments to `os.system`, `child_process` or `subprocess`), a glob in the command name (`g* push`), a word after a wrapper that its options do not explain (`timeout --unknown 9 …`), depth > 8: deny keyword → `deny`; ask keyword → `cc: ask`, `codex/agy: deny`; neither → allow + log notice. More than 256 nested wrappers → `deny` on all three agents | keyword | keyword | keyword |
153
219
  | 23 | Disable harness itself | `npm uninstall` / `pnpm remove` `@opendesignai/harness` → `deny` (all); `rm -r node_modules` or `node_modules/.pnpm`, installs without devDependencies (`npm ci --omit=dev`, `npm install --production`, `pnpm install --prod`/`-P`, `yarn --production`, `NODE_ENV=production npm ci`) and `npm prune` / `pnpm prune --prod` → `ask` / `deny` / `deny`. Also `deny` (all): `npm pkg delete`/`set` on the harness or a whole dependency map (`npm pkg delete devDependencies`) and installs that put another package under the harness name (`npm i @opendesignai/harness@npm:left-pad`, `…@file:…`, `…@link:…`, git and URL specs). Also `ask` / `deny` / `deny`: `npm config set omit dev`, `npm set production=true`, `pnpm config set production true`, writes of `omit=dev`, `production=true` or `only=prod` to an `.npmrc` or `npmrc` file (`echo omit=dev >> .npmrc`, here-docs, `… \| tee -a .npmrc`), and `npm_config_omit=dev` or `NODE_ENV=production` set with `export`, `declare -x` or under `set -a` before an install. `rm -rf node_modules/@opendesignai/harness` and the pnpm store copy `node_modules/.pnpm/@opendesignai+harness@*` hit row 16 `deny` | `deny` / `ask` | `deny` | `deny` |
154
220
 
221
+ `tar -x -C` may extract to a known directory other than the repository root or a protected directory, including an ordinary subdirectory of the repository. The hook checks the final directory and any earlier directory active when archive members were selected. An explicit destination the hook cannot resolve is gated. Without `-C`, the working directory is the destination.
222
+
223
+ The hook consumes required option arguments in the separate and attached forms described by the [GNU tar manual](https://www.gnu.org/software/tar/manual/tar.html#Option-Summary) and the [bsdtar manual](https://man.freebsd.org/cgi/man.cgi?query=tar&sektion=1). It reads `-s` as a bsdtar substitution when its value has the form `/old/new/` with optional modifiers or another delimiter. A word following an unrecognized option or an option with an optional `=value`, such as `--checkpoint`, is still treated as a potential archive member. `-T`, `--files-from`, and GNU `--add-file` select members in the active directory. GNU `-K` and `--starting-file` also make the working directory a potential extraction destination.
224
+
155
225
  ## Shell parser and opaque fallback
156
226
 
157
227
  `src/hook/shell/` implements a zero-dependency POSIX sh lexer, recursive-descent parser, and static analyzer that classifies commands without executing or evaluating them:
@@ -166,7 +236,7 @@ The allowlist does not cover installs that leave out devDependencies (`npm ci --
166
236
  - **Wrapper stripping:** unwraps `env` (including `-S`/`--split-string` scripts in every spelling: `-S'…'`, `-iS'…'`, `--split-string=…`, and BSD `-P <path>`), `sudo`, `doas`, `time`, `nice`, `nohup`, `timeout`, `stdbuf`, `command` (skipping read-only `-v`/`-V`), `builtin`, `exec`, `noglob`, `nocorrect`, `xargs`, `watch`, `setsid`, `flock`, `ionice`, `caffeinate`, `arch` (including `-e NAME=value`), `npx`, `bunx`, `uvx`, `uv run`, `corepack`, `pnpm exec`/`dlx`/`x` (including shell mode `-c`/`--shell-mode`), `npm exec`/`npm x` (including `-c`), and `yarn dlx`/`exec`. `pnpm <bin>` and `yarn <bin>` (a first argument that is not a pnpm/yarn command, such as `pnpm oxlint --suppress-all`) are analyzed as running that binary as well as the package-manager command. Each wrapper's own options are read the way the tool reads them: short-option clusters with attached or separate values (`nice -n5`, `nice -5`, `timeout -sKILL 5`, `ionice -c3`, `stdbuf -oL`, `sudo -u root -g wheel`, `xargs -n1 -P4`), GNU `xargs -l` with an optional attached line count, long options with `=` or a separate value and their unambiguous prefixes (`nice --adj=5`, `timeout --kill-after 1 5`), and `--`. `sudo -s` / `-i` (and `--shell`, `--login`) without a command run a shell, which reads a here-doc or here-string as its program. After a wrapper, a word that starts with `-` or is all digits and that the wrapper's options do not explain (`timeout --unknown 9 git …`) is skipped, and the whole command also goes through the keyword fallback. Up to 256 nested wrappers are unwrapped; a longer chain is denied as opaque.
167
237
  - **Commands run by other commands:** `find … -exec`/`-execdir`/`-ok` subcommands, with `{}` replaced by the paths the expression can be shown to match (each starting point under `-maxdepth 0` or without filtering tests, and `<start>/<name>` for literal `-name` values, literal `-path` values); `find -delete` is analyzed as `rm -rf` of the same paths, so `find . -name '*.log' -delete` stays allowed. `git rebase -x/--exec`, `git bisect run` and `git submodule foreach` commands. `bash --rcfile <file> -c …` and `--init-file`.
168
238
  - **Programs fed to a shell:** `-c` scripts; here-docs and here-strings on `sh`/`bash`/… and on `source`/`.` reading `/dev/stdin`; process substitutions `bash <(…)`, `source <(…)`, `bash < <(…)`; pipelines into a shell, `source /dev/stdin`, or a subshell or group whose first command is a shell reading stdin (`… | (bash)`, `… | { sh; }`). A static `echo`/`printf` program is parsed; anything else is row 21.
169
- - **Inline interpreter code** (`node -e`, `python -c`, `perl -e`, `ruby -e`, `deno eval`, `bun -e`, and here-docs or here-strings fed to `python`, `python -`, `node`, `perl`, `ruby`, `bun`): the code counts as a shell write only when it calls a file-writing API (`writeFile`, `open(…, 'w')`, `write_text`, `os.remove`, `shutil.copy`, `File.write`, `unlink`, `>` modes, …) and names a protected path. Explicit read flags such as Node's `fs.constants.O_RDONLY` and Ruby's `r:UTF-8` are recognized. Perl `sysopen` supplies its path after the handle, and Python `logging.basicConfig` supplies it through `filename`. Code that starts a process (`os.system`, `subprocess`, `child_process`, `exec*`, `spawn*`, backticks, `%x`, `qx`) goes through the keyword fallback, and its string literals, and lists of string literals joined with spaces (`subprocess.run(['git', 'push', 'origin', 'main'])`, `spawnSync('git', ['push', …])`), are parsed as commands.
239
+ - **Inline interpreter code** (`node -e`, `python -c`, `perl -e`, `ruby -e`, `deno eval`, `bun -e`, and programs fed on stdin): the hook checks the actual target of recognized literal file writes, such as `open('config.json', 'w')`, `Path('config.json').write_text(…)` and `fs.writeFileSync('config.json', …)`. When it cannot determine the write target, the hook checks the script for protected path segments. Explicit read modes such as Node's `fs.constants.O_RDONLY` and Ruby's `r:UTF-8` are recognized. Process checks inspect the command argument to recognized execution APIs, including string commands, literal argv lists and spawn-style calls. Ruby and Perl backticks are treated as command substitutions. Here-doc text fed to another interpreter is parsed as shell only where the shell performs its own command substitutions or the interpreter explicitly starts a shell command. Other inline process forms rely on the controls under [Known limits](#known-limits).
170
240
  - **Opaque fallback & Windows PowerShell:** commands that cannot be resolved statically (or non-POSIX syntax such as zsh `=(...)` or PowerShell/cmd) fall back to keyword matching (`DENY_KEYWORDS` and `ASK_KEYWORDS`) plus PowerShell destructive/write idioms (`Remove-Item -Recurse … .git`, `Set-Content`, `Out-File`, `Add-Content`). For `eval` with partially dynamic arguments (e.g. `eval "git" $UNSET_VAR "push" origin main`), the analyzer evaluates both the opaque keyword fallback and the static-token projection so obvious protected actions still hit structured rules.
171
241
  - **Dynamic write targets:** when a write target is not static (`> "$OUT"`), the hook looks for a protected path name only in the simple command that writes and in the assignments its variables came from (`F=$(echo .oxlintrc.json); echo x > "$F"`, `for f in .oxlintrc.json …`, `read F <<< …`), not in the rest of the compound command (owner decision on review I5). `cat package.json | jq -r .version > "$OUT"` is allowed; `git diff -- package.json > "$OUT"` is still denied because the writing command names `package.json`.
172
242
  - **Static analysis boundaries:** because `pre-bash` classifies commands without evaluating shell expansions or running interpreters, obfuscations that assemble tokens only at runtime — such as runtime string concatenation inside inline scripts (`python3 -c "open('.oxlint'+'rc.json','w')"`, `getattr(os, 'sys' + 'tem')`), commands a nested script reads from an outer here-string (`bash -c 'source /dev/stdin' <<< '…'`), or writes performed inside external script files (`node scripts/custom.mjs`, `source script.sh`) — are inherent boundaries of static pre-execution analysis. The command families the hook deliberately does not chase (other interpreters, constant propagation, file-writing commands it does not model) are listed under [Known limits](#known-limits). Those cases are backstopped by the runtime's post-execution D-class file hash verification (`PostToolUse` + `Stop`) and the server-side controls listed there, and ultimately enforced by CI (`harness-gates`).
@@ -178,8 +248,6 @@ The allowlist does not cover installs that leave out devDependencies (`npm ci --
178
248
  The owner decisions keep these strict readings; each errs toward denying:
179
249
 
180
250
  - A dynamic write target in a command that itself names a protected file (`git diff -- package.json > "$OUT"`): `deny`.
181
- - Inline code that both calls a file-writing API and mentions a protected path, even when it writes elsewhere (`node -e "fs.writeFileSync('v.txt', require('./package.json').version)"`): `deny`.
182
- - Inline code that starts a process and contains an ask keyword (`push`, `merge`, `package.json`, …) in any string: `ask` on Claude Code, `deny` on Codex and Antigravity.
183
251
  - `git --git-dir=…` / `--work-tree=…` / `--exec-path=…`, even for read-only subcommands: `ask` / `deny` / `deny`.
184
252
  - A git option prefix that git itself would reject as ambiguous (`git push --d origin pilot/x`, `git commit --no-v`) is read as the dangerous option.
185
253
  - A refspec with a dynamic source and a `pilot/*` destination (`"$SRC:pilot/x"`): `deny`, since the source may be empty (a deletion) or start with `+`.
@@ -198,9 +266,11 @@ What backstops them:
198
266
 
199
267
  ### Other interpreters and pass-through channels (review I3)
200
268
 
201
- Commands run through a language or tool whose programs the analyzer does not parse, or handed to git or `gh` in a setting that runs them later:
269
+ The December 6 decision limits inline keyword checks to recognized execution arguments. Other inline process forms use the same backstops.
270
+
271
+ Commands in this family run through languages or tools the analyzer does not parse, or through Git or `gh` settings that execute them later:
202
272
 
203
- - `awk 'BEGIN{system("git push origin main")}'`, `tcsh -c 'git push origin main'`, `expect -c 'spawn git push origin main; expect eof'`, `printf 'x:\n\tgit push origin main\n' | make -f - x`, `python3 -c "os.execlp('git','git','push','origin','main')"`.
273
+ - `awk 'BEGIN{system("git push origin main")}'`, `tcsh -c 'git push origin main'`, `expect -c 'spawn git push origin main; expect eof'`, `printf 'x:\n\tgit push origin main\n' | make -f - x`.
204
274
  - `GIT_EDITOR='git push origin main;:' git commit --allow-empty`, `gh alias set --shell p 'git push origin main' && gh p`, `git send-pack <remote> HEAD:refs/heads/main`.
205
275
 
206
276
  Backstop: branch rulesets (pushes and merges), npm publish environment approval (publishing).
@@ -228,7 +298,7 @@ Backstop: the CI gates (baseline ratchet, code owner review of protected files),
228
298
  All handlers are registered through `defineHook()` in `src/hook/define.ts`:
229
299
 
230
300
  - **PreToolUse (`pre-bash`, `pre-edit`) fails closed:** any error — synchronous throw, async rejection, empty/invalid/non-object/oversize (> 1 MiB) stdin, unreadable config, missing dependency (e.g. `git` not in PATH), or internal deadline expiration (`4s` for cc, `8s` for codex/agy) — emits an explicit `deny` response (`permissionDecision: "deny"` for cc/codex; `{"decision":"deny","reason":"…"}` for agy). Unknown agent/event routes also fail closed.
231
- - **Non-PreToolUse (`stop`, `post-tool`, `session-start`, `pre-invocation`) fails open with notice:** errors never emit `block` or `continue` (which would trap the agent in a loop); they emit an allow response plus a visible warning (`systemMessage` on cc/codex, `injectSteps` or stderr warning on agy).
301
+ - **Non-PreToolUse (`stop`, `post-tool`, `session-start`, `pre-invocation`) fails open with notice:** hook infrastructure errors emit an allow response plus a visible warning (`systemMessage` on cc/codex, `injectSteps` or stderr warning on agy). A configured Stop check that cannot verify changes shares the two-block limit with findings, then allows completion and records the `NOT VERIFIED:` status.
232
302
  - **Single emission & EPIPE safety:** fallback failure outputs are pre-built at registration time; `emit()` runs at most once even if both deadline and rejection occur, and catches stdout `EPIPE` errors cleanly.
233
303
  - **Routing by tool:** `pre-bash` and `pre-edit` both evaluate a call by its tool, not by the event it arrived on: a shell tool (`Bash`, `run_command`) is checked as a command and an edit tool (`Edit`, `Write`, `MultiEdit`, `NotebookEdit`, `apply_patch`, `write_file`, `edit_file`) by its targets, so an agent configuration that routes `Write` to `pre-bash` still denies a D-class target. A missing command or target on a known tool fails closed on either event; other tools are allowed (explicitly on Antigravity).
234
304
  - **Missing-package exception (A4-1b):** the launcher distinguishes "harness package not yet installed" from runtime errors and allows with a visible notice so a fresh clone is not deadlocked before `npm ci` / `pnpm install --frozen-lockfile`.
package/docs/ratchet.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # od-harness ratchet
2
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). For a local run, `od-harness ratchet --merge-base origin/main` compares with the commit the branch left `origin/main` at (below).
3
+ `od-harness ratchet --base <ref>` compares the working tree with the base commit (in CI: `"$HARNESS_BASE_REF"`, the PR base). For a local run, `od-harness ratchet --merge-base origin/main` compares with the commit the branch left `origin/main` at (below).
4
4
 
5
5
  It fails when:
6
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 the same change upgrades `@opendesignai/harness` or its `.oxlintrc.json` change turns that rule on ([below](#why-a-config-or-version-change-admits-new-rule-ids); both 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 file keeps the entry of its old path ([moved files](#moved-files)). |
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 (except a [moved file](#moved-files)). |
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. |
7
+ | Check | Fails when |
8
+ | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `oxlint-suppressions.json`, existing rule IDs | a rule's total count across all files grows from a positive count at the base, unless the same change upgrades `@opendesignai/harness` ([below](#why-a-config-or-version-change-admits-new-rule-ids)). |
10
+ | `oxlint-suppressions.json`, new rule IDs | a rule appears that the base did not have, unless the harness version declaration changes or `.oxlintrc.json` turns that rule on ([below](#why-a-config-or-version-change-admits-new-rule-ids), both 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 file keeps the entry of its old path ([moved files](#moved-files)). |
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 (except a [moved file](#moved-files)). |
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
15
 
16
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
17
 
@@ -25,28 +25,25 @@ Entries may follow a file to a new path; [`od-harness baseline move`](baseline-m
25
25
  - the old path had an entry in the same baseline at the base and no longer exists (spelled exactly so, also on file systems that ignore case);
26
26
  - the moved entry holds no more than the old one did (per rule, or in lines), and each old entry moves to one file only.
27
27
 
28
- The rule totals are compared as always, so a move never lets a total grow. Accepted moves are listed in the output (`baseline entry moved from …`, `frozen size moved from …`); rejected ones say which condition failed.
28
+ The same rule total checks apply to moves. Accepted moves are listed in the output (`baseline entry moved from …`, `frozen size moved from …`); rejected ones say which condition failed.
29
29
 
30
30
  ## Why a config or version change admits new rule IDs
31
31
 
32
- A rule ID may enter the baseline only in the change that turns the rule on: an owner-reviewed upgrade of `@opendesignai/harness` or change to `.oxlintrc.json`.
33
-
34
- - **The harness version changed** (`dependencies` or `devDependencies` of `package.json`; for a pnpm catalog reference, `catalog:`, the harness entries of the nearest `pnpm-workspace.yaml`): every new rule ID is admitted. Which rules an upgrade turns on cannot be told in CI (below).
35
- - **Otherwise, `.oxlintrc.json` changed**: a new rule ID is admitted only when this change turns that rule on. The rule is on in the change's effective configuration, at the top level or in an override, and its settings differ from the base's: another severity or other options, or an override with other `files`. An unrelated edit (an `ignorePatterns` entry, another rule) admits nothing, and neither does restating a rule that a preset or a category already turns on.
36
- - **Neither changed**: no new rule ID is admitted.
32
+ - **The harness version increased.** Existing rule totals may grow only when both versions resolve to exact SemVer versions and the new version is higher, including prerelease precedence. A minor or major release can make an existing rule report more, so the upgrade can include the resulting suppressions for existing files. Ratchet reports the old and new totals and versions.
33
+ - **The harness version declaration changed.** This admits every new rule ID.
34
+ - **Otherwise, `.oxlintrc.json` can admit a new rule ID.** The rule must be on in the change's effective configuration, at the top level or in an override, and its settings must differ from the base's in severity, options or override `files`. An unrelated edit (an `ignorePatterns` entry, another rule) admits nothing, and neither does restating a rule that a preset or a category already turns on.
37
35
 
38
36
  The effective configurations come from Oxlint 1.96.0: `oxlint -c <file> --print-config` prints a configuration file with `extends` resolved and categories expanded into rules; `overrides` keep their globs, so an override counts by its `files` and settings. For the base, `ratchet` writes the base commit to a temporary directory (as `unused` does) and links the working tree's `node_modules` into it, so the base's `.oxlintrc.json` extends the installed presets and loads the installed plugins. That is exact because the harness version did not change. If Oxlint cannot print either configuration (it cannot load a plugin, or it is not installed), `ratchet` compares the rule settings written in the two files instead, and says so in the output; then only rules the change sets itself are admitted. Only the file `--lint-config` names counts: nested `.oxlintrc.json` files are separate configurations, which Oxlint prints separately.
39
37
 
40
38
  In an effective configuration where `options.typeAware` is unset or false, type-aware rules count as off at the top level and in overrides. When either side has type-aware linting off, `ratchet` reads the rule metadata once from `oxlint --rules --format json` to identify those rules. Enabling `options.typeAware` can therefore admit a type-aware rule that a category already listed as enabled. It must still be enabled in the change's effective configuration. If the metadata command fails, `ratchet` reports an environment error.
41
39
 
42
- An upgrade keeps the broader condition: CI installs the change's dependencies only, so the base's configuration would be read with the new harness's presets, a rule the upgrade adds would look enabled at the base already, and the upgrade could not baseline it. Narrowing that case needs the rule list of every harness version in the package ([Next steps](../README.md#next-steps)). Two things keep the remaining room from becoming a way around the gate:
40
+ CI installs the change's dependencies only. Reading the base's configuration with the new harness's presets would make a rule added by the upgrade look enabled at the base. Identifying which rule IDs an upgrade adds needs the rule list of every harness version in the package ([Next steps](../README.md#next-steps)).
43
41
 
44
- - new files never enter a baseline (above), so new code cannot hide debt behind a new rule ID;
45
- - `.oxlintrc.json`, `package.json` and `pnpm-workspace.yaml` belong to the platform owner in CODEOWNERS, so every change that admits a new rule ID is reviewed by the owner.
42
+ New files are excluded from baselines in both version and configuration changes. `.oxlintrc.json`, `package.json` and `pnpm-workspace.yaml` belong to the platform owner in CODEOWNERS. The owner reviews the changes to version declarations and lint configuration that affect baselines.
46
43
 
47
44
  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.
48
45
 
49
- The version is read from `dependencies` or `devDependencies` in `package.json`. With a pnpm catalog (`"catalog:"`), the lines that name `@opendesignai/harness` in the nearest `pnpm-workspace.yaml` (from the working directory up to the repository root) are compared as well, so a catalog upgrade counts as a version change. Only the change that adds the harness to `package.json` is the adoption change, also with a catalog.
46
+ Ratchet reads the version declaration from `dependencies` or `devDependencies` in `package.json`. To compare SemVer versions, it resolves the referenced catalog in the nearest `pnpm-workspace.yaml` on each side. For new rule IDs, it also checks for changes to the lines that name `@opendesignai/harness` in the working tree's nearest `pnpm-workspace.yaml` and the same path at the base. Only the change that adds the harness to `package.json` is the adoption change, also with a catalog.
50
47
 
51
48
  ## Options
52
49
 
@@ -57,9 +54,9 @@ The version is read from `dependencies` or `devDependencies` in `package.json`.
57
54
  --lint-config <path> default: .oxlintrc.json
58
55
  ```
59
56
 
60
- `--merge-base <ref>` works like od-platform's `check-api --merge-base`: the base is `git merge-base HEAD <ref>`, so commits that landed on `<ref>` after the branch left it (a baseline that shrank there) do not show up as growth. When `<ref>` does not resolve (not fetched) or HEAD and `<ref>` share no history (a shallow clone), the check is skipped with a warning and exit code 0. CI passes `--base` (gates.yml), which never skips.
57
+ `--merge-base <ref>` compares with the commit where the current branch diverged from `<ref>`. A baseline tightened on the base branch after divergence does not count as growth on the current branch. If the ref is missing or there is no common ancestor, ratchet exits 2. Fetch the intended branch (for example, `git fetch origin main`), deepen a shallow clone with `git fetch --unshallow`, or select the correct integration commit for the checkout. CI uses the supplied `--base` commit directly.
61
58
 
62
- Exit code 0 means the check passed or `--merge-base` skipped it. Exit code 1 means the check failed. Exit code 2 means a usage or environment error. Usage errors, such as combining `--base` and `--merge-base`, print the diagnostic and help text. Environment errors print one line, for example when `--base` cannot resolve (check out with `fetch-depth: 0`), the command runs outside a git work tree, or a baseline is malformed. The base's `oxlint-suppressions.json` is read leniently so a change can repair it. A file that maps to anything but an object in that baseline counts as having no entries. An entry for a new file is reported whatever its counts, also `"count": 0`.
59
+ Exit code 0 means the check passed. Exit code 1 means the check failed. Exit code 2 means a usage or environment error. Usage errors, such as combining `--base` and `--merge-base`, print the diagnostic and help text. Environment errors print one line, for example when `--base` cannot resolve (check out with `fetch-depth: 0`), the command runs outside a git work tree, or a baseline is malformed. The base's `oxlint-suppressions.json` is read leniently so a change can repair it. A file that maps to anything but an object in that baseline counts as having no entries. An entry for a new file is reported whatever its counts, also `"count": 0`.
63
60
 
64
61
  ## How to fix a failure
65
62