@opendesignai/harness 0.4.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.4.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.4.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.4.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
 
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
@@ -54,9 +54,9 @@ Ratchet reads the version declaration from `dependencies` or `devDependencies` i
54
54
  --lint-config <path> default: .oxlintrc.json
55
55
  ```
56
56
 
57
- `--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.
58
58
 
59
- 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`.
60
60
 
61
61
  ## How to fix a failure
62
62
 
@@ -24,7 +24,18 @@ Build URLs with a helper in the API client (add one if missing) and call the hel
24
24
 
25
25
  ## Exemptions
26
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.
27
+ String literals and templates without substitutions are allowed in these routing forms:
28
+
29
+ - Registration with `get`, `post`, `put`, `patch`, `delete`, `head`, `options`, `connect`, `trace`, `all` or `use` takes the path first. A later argument must be an inline function. Recognized routers also accept a handler reference, factory call, array or spread.
30
+ - On a recognized router, `route` takes the path first and needs a second argument (`route(path, subApp)`) or a chained route method call (`route(path).get(handler)`).
31
+ - Registration with `on` takes a path or an array of paths second, after a literal HTTP method or an array of literal HTTP methods. The same handler check applies.
32
+ - Path dispatch covers equality and inequality in either operand order, the first argument to `startsWith`, and a `switch` case when the value being checked is named `pathname` or is a property with that name.
33
+
34
+ The rule follows chained route method calls to the original receiver. It recognizes receivers named `app`, `router`, `routes`, `server`, `hono` and `fastify`, constructors named `Hono`, `Router` and `KoaRouter`, and factories named `express`, `Router` and `fastify`. For member expressions such as `service.router` and `express.Router`, it uses the final property name. Receivers named `axios`, `ky` and `client` are always checked, including through route method chains.
35
+
36
+ A differently named HTTP client with an inline callback can match the registration pattern. A custom router with only a named handler, a route configured through an object and dispatch on a different property such as `req.path` can still report. Calls such as `fetch("/api/x")` and `axios.get("/api/x")`, URL construction and exported path constants continue to report.
37
+
38
+ Use an owner-reviewed `overrides` entry in the lint config for the API client layer and routing forms outside these patterns. Inline disable comments are rejected. Existing debt stays in `oxlint-suppressions.json` and may only shrink.
28
39
 
29
40
  ## Options
30
41
 
package/docs/verify.md CHANGED
@@ -24,7 +24,15 @@ Quick and default mode compare the working tree with the merge base of `HEAD` an
24
24
 
25
25
  The `lint-scope` check guards alternate lint configs and ignored tracked files in every mode. To omit it for a run, pass `--skip lint-scope`.
26
26
 
27
- The local base ref comes from `--base <ref>`, then a nonblank `OD_HARNESS_BASE`, then `verify.base`, then `origin/main`. For example, the pilot branch can commit `"verify": {"base": "origin/pilot/mfe"}` in `.harness/config.json`. An unavailable ref or history without a merge base exits 2 with a fetch hint. CI requires `--base <ref>` and compares directly with that commit, which must be available in the checkout.
27
+ The local base ref comes from `--base <ref>`, then a nonblank `OD_HARNESS_BASE`, then `verify.base`, then `origin/main`. For example, the pilot branch can commit `"verify": {"base": "origin/pilot/mfe"}` in `.harness/config.json`. Verify resolves this base before running any checks, including ratchet. An unavailable ref or history without a merge base exits 2 with a fetch hint. For a remote-free task sandbox, set `OD_HARNESS_BASE` to the initial snapshot SHA before starting the agent. The fixed SHA also covers changes the agent later commits. CI requires `--base <ref>` and compares directly with that commit, which must be available in the checkout.
28
+
29
+ ## Local concurrency
30
+
31
+ Default and `--ci` runs on a developer machine share host-level slots across repositories and worktrees. The slot count defaults to the number of available logical CPUs divided by four, rounded down with a minimum of two. Set `OD_HARNESS_VERIFY_SLOTS` to a positive integer to override it. Runs wait for a slot when all slots are occupied. The default slot directory in the OS temporary directory is `od-harness-verify-slots-<uid>` on POSIX and `od-harness-verify-slots` elsewhere. Set `OD_HARNESS_SLOT_DIR` to a nonblank path to override it.
32
+
33
+ When multiple slots are occupied, verify sets thread and worker defaults for new subprocesses using the available CPU count and current slot occupancy. Explicit environment settings take precedence. When only one slot is occupied, verify leaves the tool defaults in effect. `--quick`, `--no-slot`, `OD_HARNESS_NO_SLOT=1`, and a truthy `CI` or `GITHUB_ACTIONS` environment variable bypass slots and their thread defaults.
34
+
35
+ On macOS, `od-harness doctor` suggests a `.metadata_never_index` marker in the parent directory when neither a linked worktree nor its parent has the marker. This advisory helps reduce Spotlight indexing during parallel runs.
28
36
 
29
37
  ## Repository configuration
30
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendesignai/harness",
3
- "version": "0.4.0-alpha.0",
3
+ "version": "0.5.0-alpha.0",
4
4
  "description": "OpenDesign harness: od/* lint rules for Oxlint (ESLint plugin format), presets, file size budget, baseline ratchet and incremental duplication and unused-code gates",
5
5
  "keywords": [
6
6
  "eslint-plugin",
@@ -16,6 +16,7 @@
16
16
  "od/no-cjk-literal": "error",
17
17
  "od/no-constant-flag": "error",
18
18
  "od/no-commented-out-code": "error",
19
+ "eslint/no-control-regex": "off",
19
20
  "typescript/ban-ts-comment": "error",
20
21
  "react/rules-of-hooks": "error",
21
22
  "react/exhaustive-deps": "error",