clearotron 0.5.0 → 0.5.1-beta.1

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.
Files changed (129) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/INSTALL.md +351 -308
  3. package/QUICKSTART.md +12 -4
  4. package/README.md +12 -7
  5. package/THIRD-PARTY-NOTICES.md +4 -4
  6. package/bin/README.md +14 -11
  7. package/bin/clearotron.mjs +1 -1
  8. package/bin/connect.mjs +73 -25
  9. package/bin/example.mjs +4 -2
  10. package/bin/onboard.mjs +647 -352
  11. package/bin/start.mjs +213 -66
  12. package/bin/update.mjs +26 -13
  13. package/build-info.json +2 -2
  14. package/docs/CLIENT-MCP.md +1 -1
  15. package/docs/PORTAL.md +2 -2
  16. package/docs/architecture/02-architecture.md +3 -3
  17. package/docs/architecture/04-configuration-reference.md +2 -3
  18. package/docs/architecture/05-config-governance.md +1 -1
  19. package/docs/architecture/06-operations-runbook.md +1 -1
  20. package/driver/CHANGELOG.md +91 -0
  21. package/driver/README.md +2 -2
  22. package/driver/config-inventory.mjs +20 -11
  23. package/driver/contract-e3-backlog.mjs +27 -27
  24. package/driver/contract-e3-baseline.json +2 -2
  25. package/driver/contract-vocabulary.mjs +1 -1
  26. package/driver/degraded-parts.mjs +67 -3
  27. package/driver/dev-portal.mjs +1 -1
  28. package/driver/digest-queue.mjs +5 -5
  29. package/driver/driver.config.mjs +9 -9
  30. package/driver/engine/CONTRACT.md +1 -1
  31. package/driver/engine/anthropic-agent.mjs +4 -2
  32. package/driver/engine/jx-turn.mjs +10 -2
  33. package/driver/engine/mcp/band-server.mjs +1 -21
  34. package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
  35. package/driver/engine/mcp/clarivate-server.mjs +2 -18
  36. package/driver/engine/mcp/fixture-register-server.mjs +33 -0
  37. package/driver/engine/mcp/gather-config.mjs +48 -7
  38. package/driver/engine/mcp/recording-server.mjs +206 -14
  39. package/driver/engine/mcp/supplemental.mjs +4 -2
  40. package/driver/engine/openai-agent.mjs +3 -1
  41. package/driver/engine/probe.mjs +10 -0
  42. package/driver/filing-goods.mjs +95 -0
  43. package/driver/findings-model.mjs +3 -0
  44. package/driver/gateway.mjs +42 -40
  45. package/driver/how-it-runs.mjs +103 -0
  46. package/driver/knockout-assess-record.mjs +54 -4
  47. package/driver/knockout-correction-record.mjs +342 -0
  48. package/driver/knockout-frame-record.mjs +4 -2
  49. package/driver/knockout-register-read.mjs +705 -0
  50. package/driver/knockout-register-record.mjs +222 -0
  51. package/driver/knockout-review-record.mjs +96 -25
  52. package/driver/narrative-refutation-record.mjs +87 -1
  53. package/driver/order-tables.mjs +23 -0
  54. package/driver/owner-use-check.mjs +5 -2
  55. package/driver/package.json +1 -1
  56. package/driver/partial-payload-baseline.json +8 -0
  57. package/driver/pipeline-knockout.mjs +506 -313
  58. package/driver/pipeline.mjs +179 -86
  59. package/driver/portal-local-auth.mjs +7 -1
  60. package/driver/portal-service.mjs +99 -9
  61. package/driver/progress.mjs +2 -2
  62. package/driver/publish/index.mjs +18 -21
  63. package/driver/publish/knockout.mjs +40 -18
  64. package/driver/publish/render-knockout.mjs +40 -27
  65. package/driver/publish/report-dates.mjs +43 -0
  66. package/driver/recall-reconciliation.mjs +2 -2
  67. package/driver/record-goods.mjs +50 -9
  68. package/driver/register-count.mjs +12 -59
  69. package/driver/register-fixture-marker.mjs +22 -0
  70. package/driver/register-plan.mjs +48 -0
  71. package/driver/register-records.mjs +84 -266
  72. package/driver/register-taint.mjs +2 -2
  73. package/driver/repair-composers.mjs +15 -8
  74. package/driver/result-noun-fields.mjs +6 -2
  75. package/driver/run-requirements.mjs +111 -37
  76. package/driver/runner.mjs +9 -16
  77. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  78. package/driver/skills/knockout-assess/SKILL.md +101 -100
  79. package/driver/skills/knockout-frame/SKILL.md +3 -1
  80. package/driver/skills/knockout-register-read/SKILL.md +77 -0
  81. package/driver/stages-knockout.mjs +159 -98
  82. package/driver/stages.mjs +4 -2
  83. package/driver/suite-census.json +435 -81
  84. package/driver/systemd/README.md +2 -2
  85. package/driver/unit-environment.mjs +19 -0
  86. package/driver/verify-knockout.mjs +175 -39
  87. package/driver/verify.mjs +10 -9
  88. package/mcp-server/CHANGELOG.md +8 -0
  89. package/mcp-server/CONNECT.md +4 -0
  90. package/mcp-server/demo-mode.mjs +6 -0
  91. package/mcp-server/lib/demo-texts.mjs +38 -0
  92. package/mcp-server/lib/http-handler.mjs +7 -1
  93. package/mcp-server/lib/knockout.mjs +3 -2
  94. package/mcp-server/lib/options.mjs +3 -1
  95. package/mcp-server/lib/plan.mjs +6 -1
  96. package/mcp-server/lib/runs.mjs +7 -2
  97. package/mcp-server/mint-token.mjs +1 -1
  98. package/mcp-server/package.json +1 -1
  99. package/mcp-server/serve.mjs +11 -0
  100. package/mcp-server/server.mjs +13 -5
  101. package/package.json +1 -1
  102. package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
  103. package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-fPqAU0sx.js} +237 -231
  104. package/portal-ui/dist/index.html +2 -2
  105. package/portal-ui/package.json +4 -4
  106. package/providers/README.md +4 -4
  107. package/providers/_shared/execute-plan.mjs +45 -1
  108. package/providers/_shared/term-shape.mjs +1 -1
  109. package/providers/clarivate/src/capabilities.js +7 -6
  110. package/providers/clarivate/src/core.js +11 -7
  111. package/providers/clarivate/src/wider-list.js +104 -0
  112. package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
  113. package/providers/oauth-mcp-bridge/package.json +1 -1
  114. package/providers/signa/src/capabilities.js +0 -9
  115. package/scripts/e2e-first-time.mjs +8 -7
  116. package/scripts/freeze-example-run.mjs +2 -2
  117. package/scripts/settings-render-check.mjs +5 -3
  118. package/scripts/test-run.mjs +8 -2
  119. package/shared/client-door.mjs +11 -8
  120. package/shared/connect-clients.mjs +10 -4
  121. package/shared/demo-connection.mjs +43 -0
  122. package/shared/demo-start-args.mjs +7 -2
  123. package/shared/invocation.mjs +18 -3
  124. package/shared/permanent-install.mjs +24 -0
  125. package/shared/scope.mjs +8 -1
  126. package/shared/server-units.mjs +37 -1
  127. package/shared/stdio-connect.mjs +43 -21
  128. package/shared/trigger-lane.mjs +7 -0
  129. package/shared/tty-style.mjs +21 -5
package/INSTALL.md CHANGED
@@ -3,21 +3,22 @@
3
3
  [QUICKSTART.md](QUICKSTART.md) gets one search running in three commands. This is everything else.
4
4
 
5
5
  Two documents in one file, and most readers need only the first. The engine needs no agent gateway — the
6
- reasoning stages' only external LLM dependency is a coding CLI: the Claude CLI (the default) or the codex
6
+ reasoning stages' only external LLM dependency is a coding CLI: the Claude CLI or the codex
7
7
  CLI. Two other lanes call model APIs of their own: web research (`PERPLEXITY_API_KEY`, required for the
8
8
  three clearance searches — §1; a Knockout search runs without it and discloses the half it skipped).
9
9
  The native-script candidate lane no longer asks for a key of its own: it runs on
10
10
  whichever program the run already chose, so there is nothing extra to set up for it.
11
11
 
12
12
  **To install it and run one clearance, read §1 → §5 and stop.** That is prerequisites, install,
13
- configuration, the free-register route if you want it, the config-store model, and a headless run. Nothing
14
- after §5 is needed to produce a report.
13
+ configuration, the free-register route if you want it, the config-store model, the free demo, and the
14
+ portal, where you order your first paid search. Nothing after §5 is needed to produce a report.
15
15
 
16
16
  | | Sections | For |
17
17
  |---|---|---|
18
- | **Installing** | §1 Prerequisites · §2 Install · §3 Configuration · §3a Free register route · §3b Paying through a cloud account · §4 Config store · §5 Run a clearance | Anyone |
19
- | **Operating** | §6 Start the product · §7 The MCP server · §8 Access control and isolation | Running it as a service for other people |
20
- | **Reference** | §9 What an integrator supplies · §10 Licence | — |
18
+ | **Installing** | §1 Prerequisites · §2 Install · §3 Configuration · §3a Free register route · §3b Paying through a cloud account · §4 Config store · §5 Start the product | Anyone |
19
+ | **Without the portal** | §6 Run a clearance | Anyone who orders from a job file |
20
+ | **Operating** | §7 The MCP server · §8 Access control and isolation | Running it as a service for other people |
21
+ | **Reference** | §9 What an integrator supplies · §10 Licence · §11 From the repository | — |
21
22
 
22
23
  Before §3, decide which register you are using — it is the first real choice and the fastest route is
23
24
  **Signa**, one self-serve key. The ladder and what each tier can search:
@@ -57,7 +58,8 @@ run is [mcp-server/CONNECT.md](mcp-server/CONNECT.md), and why something is the
57
58
 
58
59
  On WSL, a program on the Windows side can hold a port that WSL reports as free, and the browser reaches
59
60
  it first. VS Code's Remote-SSH port forwarding is the common case. If the page that opens is not this
60
- install's sign-in, run the same command again with `--port 28802`, or any free number.
61
+ install's sign-in, run the same command again with `--port 28802`. It opens that number and the next
62
+ two, so any number works whose next two are free as well.
61
63
 
62
64
  A *hosted* deployment runs the product as systemd user units, so it needs Linux —
63
65
  [driver/systemd/README.md](driver/systemd/README.md).
@@ -81,7 +83,7 @@ run is [mcp-server/CONNECT.md](mcp-server/CONNECT.md), and why something is the
81
83
 
82
84
  | `CLEAROTRON_AI` | Program | Signed-in laptop | A machine you cannot complete a sign-in on |
83
85
  |---|---|---|---|
84
- | `anthropic-agent` (default) | `claude` | run the program setup installed (doctor prints its path), or `claude` if the machine has its own, once — rides your subscription | `claude setup-token` once anywhere you *can* log in, then put it on the server as `CLAUDE_CODE_OAUTH_TOKEN` |
86
+ | `anthropic-agent` | `claude` | run the program setup installed (doctor prints its path), or `claude` if the machine has its own, once — rides your subscription | `claude setup-token` once anywhere you *can* log in, then put it on the server as `CLAUDE_CODE_OAUTH_TOKEN` |
85
87
  | `openai-agent` | `codex` | `login` on the program setup installed (doctor prints its path), or `codex login` if the machine has its own | `login --device-auth` on the same program — prints a code you complete on another device |
86
88
 
87
89
  **The right-hand column is about where you can complete a sign-in, not about whether the machine has a
@@ -112,7 +114,9 @@ run is [mcp-server/CONNECT.md](mcp-server/CONNECT.md), and why something is the
112
114
  - **A register credential**, and **`PERPLEXITY_API_KEY`**. Both are required for a real run and both
113
115
  fail closed at preflight — before a stage has spent, never at the grid after. The one exception is a
114
116
  Knockout search, which runs keyless: it returns register filing counts and states on the report that
115
- the open-web half did not run.
117
+ the open-web half did not run. Only the native-language investigation of China, Hong Kong, Taiwan or
118
+ Macau uses `SERPAPI_API_KEY`: it searches the Chinese marketplaces through Baidu. Without it, those
119
+ marketplaces come back as a disclosed gap.
116
120
 
117
121
  Which register you pick is the first real decision, and the tiers are not equally easy to reach.
118
122
  [providers/README.md](providers/README.md) is the canonical ladder and
@@ -143,34 +147,19 @@ testing, or while a stable is being prepared; it built and the suite passed, and
143
147
  register through it.
144
148
 
145
149
  **npm's global form works too**, where npm's global directory is yours to write:
146
- `npm install -g clearotron`, then `npx clearotron install`. On a Linux Node from the distribution or
150
+ `npm install -g clearotron`, then `npx clearotron install`. For the beta,
151
+ `npm install -g clearotron@beta`, then `clearotron install`. On a Linux Node from the distribution or
147
152
  NodeSource that directory is `/usr`, owned by root, and npm refuses with `EACCES`. Do not answer that
148
- with `sudo`; install under your home instead: `npm install -g clearotron --prefix ~/.local`.
153
+ with `sudo`; install under your home instead: `npm install -g clearotron --prefix ~/.local`, or
154
+ `npm install -g clearotron@beta --prefix ~/.local` for the beta, then `~/.local/bin/clearotron install`.
149
155
 
150
156
  **Upgrade production to stables only.** What each channel promises and how often one is cut:
151
157
  **[docs/RELEASES.md](docs/RELEASES.md)**.
152
158
 
153
- The rest of this section is about the two ways a package reaches you, which is a separate question from
154
- which version it is.
159
+ A clone of the repository is the working tree, not a way to install the product. It is for
160
+ contributors, and §11 covers it.
155
161
 
156
- There are two routes in, and they are not variations on one another. **If you were sent a `.tgz` file,
157
- you want the second one** — the first assumes access to the repository, which someone installing the package does not have.
158
-
159
- ### From the repository
160
-
161
- **This is the development tree, and it is for contributors.** If you want to run a clearance, take one
162
- of the two routes above instead. A clone is not a smaller version of the package — it carries the
163
- fixtures and sample companies the project develops against, and those load as real records. They
164
- are not yours and they are not in the package, which excludes them deliberately.
165
-
166
- ```
167
- git clone <this-repo> && cd <repo>
168
- npm install # installs all workspaces
169
- npm test # offline, fixture-backed suites — no network, no gateway, no spend
170
- ```
171
-
172
- `npm test` belongs to **this** route only. It runs our test files, and those do not travel in a package
173
- — see *From a packaged tarball* below, which never asks you to run it.
162
+ The rest of this section is for a reader who was sent a `.tgz` file.
174
163
 
175
164
  ### From a packaged tarball
176
165
 
@@ -183,11 +172,11 @@ mkdir ~/app && cd ~/app
183
172
  npm init -y
184
173
  npm install /path/to/clearotron-<version>.tgz
185
174
  npx clearotron install # the wizard
186
- clearotron doctor # reads; writes nothing, calls nobody
175
+ npx clearotron doctor # reads; writes nothing, calls nobody
187
176
  ```
188
177
 
189
178
  `npx` works from `~/app` because npm links a **dependency's** `bin` into the consuming project — the
190
- same mechanism the note below explains, arriving here from the other side. **You do not need to `cd`
179
+ same mechanism §11 explains, arriving here from the other side. **You do not need to `cd`
191
180
  into `node_modules`**, and you should not: that directory belongs to your package manager, and anything
192
181
  you write inside it can be replaced by the next `npm install`.
193
182
 
@@ -195,90 +184,6 @@ you write inside it can be replaced by the next `npm install`.
195
184
  there is nothing for it to run; what you get is a refusal, and the refusal's advice is written for
196
185
  somebody working in a checkout. Nothing is wrong with your install.
197
186
 
198
- ### Cutting a package (maintainers)
199
-
200
- Skip this unless you are the one producing the `.tgz`.
201
-
202
- **`npm pack` alone is not the command.** The repository manifest carries
203
- `overrides: { "buffers": "$buffers" }`, which resolves only inside the checkout; a consumer installing that
204
- tarball dies with `Unable to resolve reference $buffers` before a single file is written. Five consecutive
205
- releases went out that way. **The published manifest has to be sealed** — that key stripped from the
206
- tarball, the repository's own manifest left untouched. Which route does it depends on the tree you are on:
207
-
208
- - **A tree that carries `cut/`**: `node scripts/pack-publishable.mjs`. It packs, strips, reconciles against
209
- the withheld-file list and scans the packed tree in one step.
210
- - **A public checkout**, which is what the release workflow runs on: `npm pack`, then
211
- `node scripts/release-artifact-seal.mjs --tarball <path>`. `pack-publishable.mjs` refuses here — it needs
212
- `cut/packed-artifact.mjs`, which a public tree does not carry, and exits 2 rather than packing something
213
- nobody checked.
214
-
215
- Either way, prove it before publishing it:
216
-
217
- node scripts/release-install-check.mjs --tarball <path>
218
-
219
- That installs the artefact as a dependency of a throwaway project, which is the only shape this failure
220
- exists in. Installing at the root of a checkout and `npm install --dry-run` both exit 0 on a tarball that
221
- refuses for every real user.
222
-
223
- Two further constraints, both of which stop a package being cut from just anywhere:
224
-
225
- - **The de-identification scan needs a full clone.** It refuses a shallow one (exit 2 — a check that could
226
- not look, not a pass) because it walks history it cannot see.
227
- - **It also needs its table**, passed with `--blocklist` (or `CLEAROTRON_IDENTIFIER_BLOCKLIST`), and
228
- that table lives in the private config store rather than in this repository. Without it the scan
229
- exits 2 rather than arming a weaker rule set quietly.
230
-
231
- Both refusals are correct and neither is a workaround to route around.
232
-
233
- This repository *is* the `clearotron` package, and npm links a package's `bin` into
234
- `node_modules/.bin` only for its **dependencies** — never for the package itself. So after `npm install`
235
- succeeds there is no `clearotron` on your `PATH` and none in `node_modules/.bin`; a bare `clearotron`
236
- would be `command not found` with nothing having failed.
237
-
238
- **`npx` resolves the local package by walking up from the current directory, so it works from the
239
- project root and any subdirectory of it — and nowhere else.** From your home directory the same line
240
- gets you npm's `could not determine executable to run`, which names no product and suggests no fix.
241
- That is why this document tells you to `cd` in first, and why every command below assumes you are still
242
- there. On the repository route "the project" is the checkout; on the packaged route it is the directory
243
- you ran `npm init` in — and on that route `clearotron` IS a dependency, so `npx` finds it in
244
- `node_modules/.bin` exactly as the paragraph above describes.
245
-
246
- **`clearotron install` (§3) puts the short form on your `PATH`**, and every command after it in this
247
- document uses that form. Use it rather than a fresh `npx clearotron`: `npx` resolves whichever version npm
248
- picks at that moment — the stable, unless you name a channel — and does not hand over to the copy the
249
- install placed. You can stop typing `npx` after it:
250
- it writes a small shim to `~/.local/bin/clearotron` pointing at this checkout. That directory needs no
251
- root — `npm link` would want npm's global prefix, which on a default install is `/usr` and refuses
252
- without it. Most login profiles add `~/.local/bin` to `PATH` only if it already existed when the shell
253
- started, so in the terminal that ran the install you may need `export PATH="$HOME/.local/bin:$PATH"`
254
- once; a new login shell picks it up by itself. The install prints which of the two you are in, and the
255
- product's own advice follows suit — `clearotron doctor` names the form that works from where you are
256
- standing, whichever that is.
257
-
258
- `npm test` is the fast tier, **on the repository route**. `npm run test:full` adds the files that drive
259
- the orchestrator end to end and is what CI runs before a merge; [CONTRIBUTING.md](CONTRIBUTING.md) draws
260
- the line between them. Either way nothing is contacted and nothing is billed — the suite says so before
261
- it starts. Neither runs on a packaged install: the test files are not in the package.
262
-
263
- The engine itself has no build step. The **portal UI does** — `portal-ui/` is React + Vite — but its
264
- built bundle (`portal-ui/dist/`) is **not committed to git**: it travels in the published package and
265
- CI builds it, so a tarball install is already runnable while a clone needs one build first. You also
266
- need to build after changing something under `portal-ui/src`:
267
-
268
- ```
269
- npm run tokens # regenerate the design tokens from shared/brand.mjs, if colours changed
270
- npm run build:ui # build portal-ui/dist — the portal serves this, not the sources
271
- ```
272
-
273
- **`portal-ui/dist` is build output.** The portal serves that bundle rather than the sources, so run the
274
- build after cloning if the directory is not there, and again whenever you change anything under
275
- `portal-ui/src`. Until the bundle exists the UI answers with a 503 that says exactly this, and the API
276
- keeps working throughout.
277
-
278
- `npm test` exercises the driver and MCP server against recorded fixtures; it never calls a model or a
279
- provider, so it is safe to run on any machine that has the repository. "Safe anywhere" is about spend,
280
- not about where it will run — on a packaged tree it refuses, as above.
281
-
282
187
  ## 2a. Removing it
283
188
 
284
189
  An install is not one directory, so removing it is not one command. Everything it writes is listed here.
@@ -288,14 +193,35 @@ Read the list before you delete anything: one of these directories holds your re
288
193
  background services, `clearotron stop` stops them and removes their unit files. `clearotron status` says
289
194
  which of the two you have.
290
195
 
291
- **The program.** Installed globally, `npm rm -g clearotron` removes it. Installed by `clearotron install`
292
- (which is also what a demo run from `npx` leaves behind), it lives in two places under `~/.local`:
196
+ **The program.** Installed by `clearotron install`, or with
197
+ `npm install -g clearotron --prefix ~/.local`, it lives in two places under `~/.local`:
293
198
 
294
199
  ```
295
200
  ~/.local/lib/node_modules/clearotron
296
201
  ~/.local/bin/clearotron
297
202
  ```
298
203
 
204
+ `npm rm -g --prefix ~/.local clearotron` removes both. Without the prefix, npm looks in its own global
205
+ directory, finds nothing, and prints "up to date". Installed with `npm install -g clearotron` and no
206
+ prefix, `npm rm -g clearotron` removes the program. Installed from a packaged tarball, it is in the
207
+ folder §2 had you create, `~/app`: delete that folder. On those two routes setup also put the
208
+ `clearotron` command in `~/.local/bin/clearotron`: delete that file too.
209
+
210
+ **The reasoning program, if setup installed it.** Setup puts Claude Code or the Codex CLI in one folder,
211
+ `~/.local/share/clearotron/engines`, or where `CLEAROTRON_ENGINES_DIR` points. Delete the folder to
212
+ remove it.
213
+
214
+ **What the reasoning program keeps for itself.** Claude Code keeps its sign-in and settings in
215
+ `~/.claude` and `~/.claude.json`, and setup's engine check creates them if they were not there.
216
+ Claude Code also keeps a cache in `~/.cache/claude-cli-nodejs`.
217
+ The Codex CLI keeps its sign-in in `~/.codex`. They belong to that program, not to Clearotron: remove them
218
+ only if nothing else on the machine uses it.
219
+
220
+ **npm's copy, if you ran `npx`.** `npx clearotron` keeps the package it downloaded in npm's cache, under
221
+ `~/.npm/_npx`, beside anything else you have run with `npx`. Deleting `~/.npm/_npx` removes all of them;
222
+ npm downloads again the next time it is asked.
223
+ Any `npm install` also keeps what it downloaded in npm's cache, `~/.npm/_cacache`; `npm cache clean --force` empties it.
224
+
299
225
  **The settings, and the keys.** `~/.config/clearotron/.env` holds this install's signing secrets, so
300
226
  deleting it invalidates every key it ever issued. Beside it: `~/.config/clearotron/token-denylist`, the
301
227
  list of keys you revoked, and `~/.config/clearotron/running`, which records a product running in a
@@ -344,6 +270,11 @@ configuration differ; to change one, change it in both. It is not the
344
270
  same file as `~/.config/clearotron/.env`, which configures the product when you run it yourself. Delete
345
271
  both, or you leave a file of credentials in your home for services that no longer exist.
346
272
 
273
+ **Codex's working folders, on a Codex install.** Clearotron runs each Codex turn in a folder of its own
274
+ under `~/.cache/clearotron/codex-homes` (under `$XDG_CACHE_HOME` when that is set, and
275
+ `%LOCALAPPDATA%\clearotron` on Windows). A turn's folder goes when the turn ends; the folder that holds
276
+ them stays. Delete `~/.cache/clearotron` to remove it.
277
+
347
278
  Nothing else on the machine is ours: no system-wide files, no services outside your own user, and nothing
348
279
  in `/etc`, `/usr` or `/var`.
349
280
 
@@ -384,8 +315,8 @@ and now there is a single name.
384
315
 
385
316
  Variables not in this table are internal tunables. They keep their names.
386
317
 
387
- **Two paths and one provider are the whole required set.** `CLEAROTRON_DATABASE` picks the register
388
- (§1); `CLEAROTRON_REPORTS_DIR` says where finished reports are published; `CLEAROTRON_WORK_DIR` says where
318
+ **Two paths, one register and one AI are the whole required set.** `CLEAROTRON_DATABASE` picks the register and `CLEAROTRON_AI` the AI (§1);
319
+ `CLEAROTRON_REPORTS_DIR` says where finished reports are published; `CLEAROTRON_WORK_DIR` says where
389
320
  runs happen. The pool has **no default at all** — unset, the engine refuses and names the variable
390
321
  rather than choosing a directory on your behalf, because the wrong choice writes a report into an
391
322
  archive somebody else owns. The workspace root defaults to `$HOME/trademark/workspace`, which is also
@@ -431,27 +362,29 @@ CLEAROTRON_BRAND_PRODUCT=Trademark clearance # what the deliverable is called
431
362
  # CLEAROTRON_ADMINISTRATOR_CONTACT=it@your-firm.example
432
363
 
433
364
  # ── Register provider (choose ONE) ─────────────────────────────────────
434
- CLEAROTRON_DATABASE=clarivate # REQUIRED — corsearch | clarivate | signa | euipo | uspto-local | free-tier
365
+ CLEAROTRON_DATABASE=signa # REQUIRED — signa | free-tier | euipo | uspto-local | corsearch | clarivate
435
366
  # No default: unset, a run refuses.
436
- CLARIVATE_API_KEY=... # the credential for the provider named above
437
- # CLARIVATE_API_BASE=... # optional; defaults to the adapter's base
438
- # CORSEARCH_SESSION_KEY=...
439
- # SIGNA_API_KEY=...
367
+ SIGNA_API_KEY=... # the credential for the provider named above
440
368
  # SIGNA_BASE_URL=... # optional; defaults to the adapter's base
441
369
  # CORSEARCH_SESSION_KEY=... # …or an enterprise vendor, via a sales agreement
442
- # CLARIVATE_API_KEY=... / CLARIVATE_API_BASE=...
370
+ # CLARIVATE_API_KEY=...
371
+ # CLARIVATE_API_BASE=... # optional; defaults to the adapter's base
443
372
  # USPTO_LOCAL_DB=/var/lib/trademark/uspto/us.db # no vendor account — see §3a below
444
373
 
445
374
  # ── …or the FREE EU register, as the provider (no subscription) ────────
446
375
  # CLEAROTRON_DATABASE=euipo
447
376
  # EUIPO_CLIENT_ID=... / EUIPO_CLIENT_SECRET=...
448
- EUIPO_ENVIRONMENT=production # REQUIRED with euipo — sandbox | production are SEPARATE
377
+ # EUIPO_ENVIRONMENT=production # REQUIRED with euipo — sandbox | production are SEPARATE
449
378
  # deployments over different corpora. There is no default:
450
379
  # unset, the adapter refuses by name.
451
380
 
452
- # ── Web research — REQUIRED for all four products (see §1) ─────────────
381
+ # ── Web research — REQUIRED for the three clearance searches (see §1) ──
382
+ # A Knockout search runs without it and states on the report that the open-web half did not run.
453
383
  PERPLEXITY_API_KEY=...
454
384
 
385
+ # ── Chinese marketplaces — only the native-language investigation of China, Hong Kong, Taiwan or Macau
386
+ # SERPAPI_API_KEY=... # without it, those marketplaces come back as a disclosed gap
387
+
455
388
  # ── Optional data sources ──────────────────────────────────────────────
456
389
  # Case law has NO token variable. Access is free and immediate, and setup is a one-time OAuth login
457
390
  # per source — providers/oauth-mcp-bridge/README.md. Unset, the lane stays dark and the run records
@@ -483,7 +416,9 @@ the packets are being written and are waiting for an integrator to consume them.
483
416
 
484
417
  `uspto-local` searches a copy of the United States register that you build on your own disk from
485
418
  USPTO's public bulk data. No vendor, no invoice, and no extra software — Node 22 ships the database
486
- engine it uses.
419
+ engine it uses. The download does need a free USPTO.gov account, which asks for ID.me identity
420
+ verification, and the API key from it in `USPTO_API_KEY`; nothing is billed.
421
+ `clearotron sync --from-file <archive>` builds from an archive you already have, with no key.
487
422
 
488
423
  **The bill is time and disk, not money.** From one complete build read end to end on 2026-08-11 (767
489
424
  files, backfile and dailies): **41.5 GB** downloaded, **~9 hours** to ingest at 4.6 GB/h, **20 GB** of
@@ -677,145 +612,12 @@ becomes an incident on a real deployment rather than a bundled one:
677
612
 
678
613
  Copy or author the companies, context packs and project overlays you want; assume you inherit none.
679
614
 
680
- ## 5. Run a headless clearance report
681
-
682
- 1. Make sure `CLEAROTRON_AI` names the engine you want (`anthropic-agent` or `openai-agent`), its CLI is
683
- authenticated, and your active register provider's credential is set. `clearotron doctor
684
- --probe-engine` answers all three, and the engine half of it by actually running a turn — an
685
- executable on `PATH` that is signed out passes every other check and fails at the first stage.
686
-
687
- 2. Write a **job file**. The required fields are an `id`, a `forwarder` handle, at least one mark
688
- **name**, and either classes or a goods description — a company profile can supply the last one.
689
- `msgId` is optional: it threads the reply into the original email, and a job without one is warned,
690
- not refused. A minimal neutral example:
691
-
692
- ```json
693
- {
694
- "id": "job-2026-0001",
695
- "msgId": "<intake-2026-0001@example.com>",
696
- "forwarder": "alex",
697
- "forwarderEmail": "alex@example.com",
698
- "forwarderDomain": "example.com",
699
- "marks": [{ "ref": "TM-0001", "name": "IRONWHISK", "classes": [9, 42] }],
700
- "goods": "cloud software for weather analytics",
701
- "jurisdictions": ["US"],
702
- "product": "knockout-search"
703
- }
704
- ```
705
-
706
- **`product` names which of the four searches you are ordering, and the example names it on purpose.**
707
- It orders a **Knockout search over one territory** — the cheapest of the four and the fastest way to
708
- prove the install works end to end. It is not the product you would order for a real matter; it is the
709
- one that answers "does this run at all" in minutes rather than hours. Change it when you have a matter.
710
-
711
- | product | case law | native language |
712
- |---|---|---|
713
- | `knockout-search` | no | not offered |
714
- | `global-preliminary-search` | no | not offered |
715
- | `multi-country-focus-search` | no | offered |
716
- | `full-country-search` | **yes** | **automatic** |
717
-
718
- **Omit it and the territories decide — in a direction that will surprise you.** No `jurisdictions`
719
- gives you `global-preliminary-search`; two or more give `multi-country-focus-search`; and naming
720
- **exactly one country** gives `full-country-search`, the deepest of the four, which turns case law on
721
- and runs the native-language investigation automatically.
722
-
723
- **That is why the example above names `product` even though it lists one territory.** Delete the
724
- `product` line and this job — one country — becomes a `full-country-search`: the deepest of the four,
725
- case law on, native-language investigation running, hours instead of minutes. Narrowing the scope to
726
- make a first run smaller orders **more** work, not less, and naming `product` is what stops the scope
727
- deciding for you. An unknown value is a clarify, never a silent substitute.
728
-
729
-
730
- 3. Run the pipeline:
731
-
732
- ```
733
- clearotron run --job job.json
734
- ```
735
-
736
- **The example above is sized in minutes; a real clearance is sized in hours.**
737
- The engine sizes a knockout search at 5 to 10 minutes — which is what this job orders — and a clearance
738
- at up to 2.5 hours.
739
- The example run in `demo/` took 2 h 35 m, and it is a clearance, not a knockout. A
740
- single stage of a clearance can legitimately run 45 minutes — let it finish.
741
- [How long a run takes](#how-long-a-run-takes) below gives the provenance of each figure.
742
-
743
- This run sends the matter off the machine — the mark, its classes, the goods wording, and the
744
- company's context reach a reasoning provider and Perplexity, and the mark and its variants reach your
745
- register. Before the first live matter, read
746
- [what leaves the machine](docs/architecture/09-security-and-data.md#what-leaves-the-machine).
747
-
748
- The driver resolves the profile, runs the reasoning stages as headless CLI turns, gates delivery on
749
- its internal refutation verdict, and then:
750
-
751
- - **publishes** the report (HTML + Markdown) and an Excel audit into `CLEAROTRON_REPORTS_DIR`; and
752
- - writes **`_driver/delivery.json`** in the run directory — a self-contained handoff packet:
753
-
754
- ```
755
- { runId, agent, forwarder, forwarderEmail, msgId, conversationId, subject, emailBodyHtml, url,
756
- verdict, markName, whatsappTo, whatsappText }
757
- ```
758
-
759
- This packet **is the delivery contract**: an integrator's channel wiring reads it and sends the report
760
- by email/chat. The engine never sends messages itself — the report is already published regardless.
761
- Failures, intake rejections, duplicate skips and late-bind acks ride the same outbox seam as
762
- self-contained event packets — the full catalog + the integrator loop is
763
- [docs/DELIVERY.md](docs/DELIVERY.md); intake (the enqueue CLI, the job JSON, queue lifecycle,
764
- dedup) is [docs/INTAKE.md](docs/INTAKE.md).
765
-
766
- ### How long a run takes
767
-
768
- Hours, not minutes.
769
-
770
- **One measured run.** The sample in `demo/` took **2 h 35 m** from `startedAt` to
771
- `deliveredAt` (`run/status.json`) — one mark, two classes, one register, 214 register calls, 37 model
772
- dispatches. That is 1.29× the 2 hours the run quoted itself.
773
-
774
- **What the engine quotes.** A knockout search is sized at 5 to 10 minutes. A clearance starts at 1.5 hours
775
- and runs to 2.5 hours — one range for every clearance, whichever lanes it carries
776
- (`driver/effort-model.mjs`). The quote used to add half an hour each for the case-law reading, the
777
- native-language lane and a single-territory deep-dive; the delivered walls refuted that, so the adders
778
- were removed.
779
-
780
- **What the stages declare.** Every stage carries a timeout — the longest is 45 minutes, and the 16
781
- together sum to 5.6 hours (`driver/stages.mjs`). Fan-out members run in parallel and a retry adds to
782
- the wall, so the sum sizes the stages rather than the run.
783
-
784
- What moves the wall is the fan-out: how many search axes the register plan compiles, whether the
785
- marketplace sweep splits in half, how many findings need cards, and how many registers the product
786
- sweeps. Every run records its own quote against its actual wall in `status.json`. A stage still going
787
- after half an hour is not hung — the longest stage timeout is 45 minutes, and the engine hard-kills
788
- anything that overruns its own.
789
-
790
- ### If a run stops before it delivers
791
-
792
- A clearance run takes hours, so it will sometimes stop part-way: you close the lid, the machine reboots,
793
- or the model provider caps you mid-run. **Nothing is lost.** Every finished stage stays on disk and a
794
- resume re-runs only what is missing or invalid.
795
-
796
- The command that continues a run is printed whenever a run ends badly — copy the line it gives you:
797
-
798
- ```
799
- node /path/to/driver/pipeline.mjs --job /path/to/job.json --resume <codename>
800
- ```
801
-
802
- A run stopped by a **provider rate limit** or parked for **automatic recovery** does not need you at all
803
- — it resumes on its own as soon as its window passes, provided something is watching for it. On a server
804
- that is the systemd units in `driver/systemd/`. Everywhere else, run the watcher yourself:
805
-
806
- ```
807
- clearotron run-queue --watch
808
- ```
809
-
810
- That polls every 90 seconds for queued jobs and for parked runs whose window has elapsed, and it resumes
811
- them. It also notices when the machine has been asleep, so a cap that lifted overnight is picked up when
812
- you open the laptop rather than at the next scheduled poll. Leave it running alongside your work; `Ctrl-C`
813
- stops it, and anything still parked waits for the next time you start it.
615
+ ## 5. Start the product on this machine
814
616
 
815
- ## 6. Start the product on this machine
617
+ This is the product: a portal you sign in to, order a clearance from, and read the report in.
816
618
 
817
- Everything above runs the engine from a job file. This is the product: a portal you sign in to, order a
818
- clearance from, and read the report in.
619
+ See it before you buy anything: `npx clearotron demo` replays finished clearances with no account, no
620
+ key, and no network. `npx clearotron@beta demo` replays the beta's.
819
621
 
820
622
  **Plain `clearotron start` runs in the foreground and stops when this terminal closes** — Ctrl-C, a
821
623
  dropped SSH session, a shut laptop lid ending the session: the portal goes with it. That is the right
@@ -830,24 +632,27 @@ clearotron stop # stop it and give the box back — plain `sta
830
632
  `--background` never touches the assistant connector: `clearotron connect` opens that door
831
633
  and `clearotron disconnect` closes it, separately and on purpose.
832
634
 
833
- **If anything else on this host already runs this product, set its ports first.** The portal (18802)
834
- and the engine door (18790) are **fixed defaults shared by every checkout on a machine**, so a second
835
- instance collides with the first and `start` refuses rather than quietly moving. Give it its own pair
635
+ **If anything else on this host already runs this product, set its ports first.** `start` opens three:
636
+ the portal (18802), the engine door (18790) and the client door (18811). They are **fixed defaults shared
637
+ by every install on a machine**, so a second instance meets the first one's ports. Give it its own three
836
638
  before the first start:
837
639
 
838
640
  ```
839
- PORTAL_SERVICE_PORT=18820 TRADEMARK_MCP_HTTP_PORT=18821 clearotron start
641
+ PORTAL_SERVICE_PORT=18820 TRADEMARK_MCP_HTTP_PORT=18821 CLIENT_MCP_HTTP_PORT=18822 clearotron start
840
642
  ```
841
643
 
842
- A test instance beside a live one needs more than two ports — §8, *Two instances on one machine*, is the
843
- whole boundary. On a host running nothing else, ignore this and carry on:
644
+ `clearotron start --port 18820` opens the same three: 18820, 18821 and 18822.
645
+
646
+ A test instance beside a live one needs more than its own ports — §8, *Two instances on one machine*, is
647
+ the whole boundary. On a host running nothing else, ignore this and carry on:
844
648
 
845
649
  ```
846
650
  clearotron start
847
651
  ```
848
652
 
849
- One command. It starts the portal and the engine door the portal's Start button calls, waits until both
850
- answer, and prints one address to open. `Ctrl-C` stops both. The second run asks nothing.
653
+ One command. It starts the portal, the engine door the portal's Start button calls, the client door an
654
+ assistant connects to, and the worker that runs what you order. It waits until the portal and the engine
655
+ door answer, and prints one address to open. `Ctrl-C` stops all of them. The second run asks nothing.
851
656
 
852
657
  **This is not `npx clearotron demo`, and the two are not interchangeable.**
853
658
 
@@ -856,7 +661,7 @@ answer, and prints one address to open. `Ctrl-C` stops both. The second run asks
856
661
  | what it is | a finished report, replayed | the running product |
857
662
  | credentials | none | whatever a real run needs (§3) |
858
663
  | model calls | none | yes, once you order a clearance |
859
- | what you can do | read | sign in, configure, order, read |
664
+ | what you can do | sign in and read; an order opens the finished example for that search | sign in, configure, order, read |
860
665
 
861
666
  Use the demo to see what this system produces. Use `clearotron start` to run it.
862
667
 
@@ -936,14 +741,16 @@ A queued job whose worker is not running says so on the portal rather than sitti
936
741
  identity edge (§8 for what separates one instance from another); this command touches none of them and
937
742
  is not a way to set them up.
938
743
 
939
- **And it does not keep this install up to date.** Nothing here pulls; your checkout stays on the commit
940
- you cloned until you run `npx clearotron update`, which fast-forwards and reinstalls dependencies. It
941
- refuses over a configuration store kept inside the checkout, and it refuses while a run is queued or in
942
- flight — `npm ci` rebuilds `node_modules` under whatever is running, and a clearance assembled from
943
- halves of two builds does not fail, it answers wrongly.
744
+ **And it does not keep this install up to date.** `clearotron update` does. On a package install on
745
+ Linux or macOS it installs the newest stable, or for a beta install the newest beta or stable, whichever
746
+ is later; on Windows it names the npm command to run instead. In a git checkout it fast-forwards the
747
+ checkout and reinstalls dependencies. Either way it refuses over a
748
+ configuration store kept inside the install's own folder, and it refuses while a run is queued or in
749
+ flight — an update replaces the program's files under whatever is running, and a clearance assembled
750
+ from halves of two builds does not fail, it answers wrongly.
944
751
 
945
- **To make that automatic**, this repository ships a unit and an hourly timer that run exactly that
946
- command, with the same two refusals. They are generic — the checkout path comes from your
752
+ **To make that automatic in a git checkout**, this repository ships a unit and an hourly timer that run
753
+ exactly that command, with the same two refusals. They are generic — the checkout path comes from your
947
754
  `EnvironmentFile` — and they neither start nor stop a queue drainer:
948
755
 
949
756
  ```
@@ -964,28 +771,163 @@ any running program that started before your checkout last moved. **It does not
964
771
  supervisor owns a service is a property of your deployment, not of this checkout — so restarting is
965
772
  yours to do, and now yours to know about.
966
773
 
967
- ### Ports, and two warnings you will see
968
-
969
- The portal is on 18802 and the engine door on 18790, both loopback, and both are **fixed defaults for
970
- every checkout on the host** rather than per-install values. They move separately: the portal with
971
- `clearotron start --port <n>` or `PORTAL_SERVICE_PORT=<n>`, the engine door with
972
- `TRADEMARK_MCP_HTTP_PORT=<n>`. A port already in use produces a sentence saying which port and which
973
- variable to change, before anything starts — it will not quietly pick another, because whatever sits in
974
- front of it is still addressed to the old one.
774
+ ### Ports
975
775
 
976
- Two lines on a fresh install look worse than they are:
776
+ The portal is on 18802, the engine door on 18790 and the client door on 18811, all loopback, and all
777
+ three are **fixed defaults for every install on the host** rather than per-install values. Each has its
778
+ own variable: `PORTAL_SERVICE_PORT`, `TRADEMARK_MCP_HTTP_PORT` and `CLIENT_MCP_HTTP_PORT`.
779
+ `clearotron start --port <n>` puts the portal on n, and the engine door and the client door on n+1 and
780
+ n+2 unless their own variables are set.
977
781
 
978
- - *"skills overlay unset — company risk frameworks will resolve to this repo's demo fixtures."* On a
979
- demo install they **are** the demo fixtures, and the warning is correct to fire: it exists so that a
980
- real deployment never shows a synthetic framework as a company's own. It goes quiet once
981
- `CLEAROTRON_CUSTOMERS_DIR` and `CLEAROTRON_INSTRUCTIONS_DIR` point at your own config store (§4).
982
- - *"saved searches ON — store=…"* names a directory under `~/trademark/`, not your repository. Editing a
983
- **company profile**, however, still commits into this checkout until `PROFILE_REPO_ROOT` names a
984
- config store of your own. Point it at one before you edit a profile you intend to keep.
782
+ `start` checks every port before anything starts. A port in use is refused when you set its variable, or
783
+ when `CF_ACCESS_TEAM` or an `*_OIDC_ISSUER` setting says a proxy or a sign-in provider sits in front,
784
+ because whatever is in front is still addressed to that number. The refusal names the port and the
785
+ variable to change. Any other port in use moves to the next free number, and `start` prints where it went.
985
786
 
986
787
  `driver/dev-portal.mjs` is **not** this. It is a loopback pool browser for people working on the engine,
987
788
  its own header says never to expose it, and nothing here starts it.
988
789
 
790
+ ## 6. Run a headless clearance report
791
+
792
+ 1. Make sure `CLEAROTRON_AI` names the engine you want (`anthropic-agent` or `openai-agent`), its CLI is
793
+ authenticated, and your active register provider's credential is set. `clearotron doctor
794
+ --probe-engine` answers all three, and the engine half of it by actually running a turn — an
795
+ executable on `PATH` that is signed out passes every other check and fails at the first stage.
796
+
797
+ 2. Write a **job file**. The required fields are an `id`, a `forwarder` handle, at least one mark
798
+ **name**, and either classes or a goods description — a company profile can supply the last one.
799
+ `msgId` is optional: it threads the reply into the original email, and a job without one is warned,
800
+ not refused. A minimal neutral example:
801
+
802
+ ```json
803
+ {
804
+ "id": "job-2026-0001",
805
+ "msgId": "<intake-2026-0001@example.com>",
806
+ "forwarder": "alex",
807
+ "forwarderEmail": "alex@example.com",
808
+ "forwarderDomain": "example.com",
809
+ "marks": [{ "ref": "TM-0001", "name": "IRONWHISK", "classes": [9, 42] }],
810
+ "goods": "cloud software for weather analytics",
811
+ "jurisdictions": ["US"],
812
+ "product": "knockout-search"
813
+ }
814
+ ```
815
+
816
+ **`product` names which of the four searches you are ordering, and the example names it on purpose.**
817
+ It orders a **Knockout search over one territory** — the cheapest of the four and the fastest way to
818
+ prove the install works end to end. It is not the product you would order for a real matter; it is the
819
+ one that answers "does this run at all" in minutes rather than hours. Change it when you have a matter.
820
+
821
+ | product | case law | native language |
822
+ |---|---|---|
823
+ | `knockout-search` | no | not offered |
824
+ | `global-preliminary-search` | no | not offered |
825
+ | `multi-country-focus-search` | no | offered |
826
+ | `full-country-search` | **yes** | **automatic** |
827
+
828
+ **Omit it and the territories decide — in a direction that will surprise you.** No `jurisdictions`
829
+ gives you `global-preliminary-search`; two or more give `multi-country-focus-search`; and naming
830
+ **exactly one country** gives `full-country-search`, the deepest of the four, which turns case law on
831
+ and runs the native-language investigation automatically.
832
+
833
+ **That is why the example above names `product` even though it lists one territory.** Delete the
834
+ `product` line and this job — one country — becomes a `full-country-search`: the deepest of the four,
835
+ case law on, native-language investigation running, hours instead of minutes. Narrowing the scope to
836
+ make a first run smaller orders **more** work, not less, and naming `product` is what stops the scope
837
+ deciding for you. An unknown value is a clarify, never a silent substitute.
838
+
839
+
840
+ 3. Run the pipeline:
841
+
842
+ ```
843
+ clearotron run --job job.json
844
+ ```
845
+
846
+ **The example above is sized in minutes; a real clearance is sized in hours.**
847
+ The engine sizes a knockout search at 5 to 10 minutes — which is what this job orders — and a clearance
848
+ at up to 2.5 hours.
849
+ The three clearances in `demo/` took 64 to 74 minutes each, and its knockout search 4 minutes. A
850
+ single stage of a clearance can legitimately run 45 minutes — let it finish.
851
+ [How long a run takes](#how-long-a-run-takes) below gives the provenance of each figure.
852
+
853
+ This run sends the matter off the machine — the mark, its classes, the goods wording, and the
854
+ company's context reach a reasoning provider and Perplexity, and the mark and its variants reach your
855
+ register. Before the first live matter, read
856
+ [what leaves the machine](docs/architecture/09-security-and-data.md#what-leaves-the-machine).
857
+
858
+ The driver resolves the profile, runs the reasoning stages as headless CLI turns, gates delivery on
859
+ its internal refutation verdict, and then:
860
+
861
+ - **publishes** the report (HTML + Markdown) and an Excel audit into `CLEAROTRON_REPORTS_DIR`; and
862
+ - writes **`_driver/delivery.json`** in the run directory — a self-contained handoff packet:
863
+
864
+ ```
865
+ { runId, agent, forwarder, forwarderEmail, msgId, conversationId, subject, emailBodyHtml, url,
866
+ verdict, markName, whatsappTo, whatsappText }
867
+ ```
868
+
869
+ This packet **is the delivery contract**: an integrator's channel wiring reads it and sends the report
870
+ by email/chat. The engine never sends messages itself — the report is already published regardless.
871
+ Failures, intake rejections, duplicate skips and late-bind acks ride the same outbox seam as
872
+ self-contained event packets — the full catalog + the integrator loop is
873
+ [docs/DELIVERY.md](docs/DELIVERY.md); intake (the enqueue CLI, the job JSON, queue lifecycle,
874
+ dedup) is [docs/INTAKE.md](docs/INTAKE.md).
875
+
876
+ ### How long a run takes
877
+
878
+ Minutes for a knockout search, an hour or more for a clearance.
879
+
880
+ **Four measured runs.** Each sample in `demo/` records its own wall, from `startedAt` to `deliveredAt`
881
+ in `run/status.json`. The three clearances took **64 to 74 minutes** each, quicker than the quote
882
+ below; the knockout search took **4 minutes**.
883
+
884
+ **What the engine quotes.** A knockout search is sized at 5 to 10 minutes. A clearance starts at 1.5 hours
885
+ and runs to 2.5 hours — one range for every clearance, whichever lanes it carries
886
+ (`driver/effort-model.mjs`). The quote used to add half an hour each for the case-law reading, the
887
+ native-language lane and a single-territory deep-dive; the delivered walls refuted that, so the adders
888
+ were removed.
889
+
890
+ **What the stages declare.** Every stage carries a timeout — the longest is 45 minutes, and the 16
891
+ together sum to 5.6 hours (`driver/stages.mjs`). Fan-out members run in parallel and a retry adds to
892
+ the wall, so the sum sizes the stages rather than the run.
893
+
894
+ What moves the wall is the fan-out: how many search axes the register plan compiles, whether the
895
+ marketplace sweep splits in half, how many findings need cards, and how many registers the product
896
+ sweeps. Every run records its own quote against its actual wall in `status.json`. A stage still going
897
+ after half an hour is not hung — the longest stage timeout is 45 minutes, and the engine hard-kills
898
+ anything that overruns its own.
899
+
900
+ ### If a run stops before it delivers
901
+
902
+ A clearance run takes hours, so it will sometimes stop part-way: you close the lid, the machine reboots,
903
+ or the model provider caps you mid-run. **Nothing is lost.** Every finished stage stays on disk and a
904
+ resume re-runs only what is missing or invalid.
905
+
906
+ The command that continues a run is printed whenever a run ends badly — copy the line it gives you:
907
+
908
+ ```
909
+ clearotron run --job /path/to/job.json --resume <codename>
910
+ ```
911
+
912
+ The job file can be left out:
913
+
914
+ ```
915
+ clearotron run --resume <codename>
916
+ ```
917
+
918
+ A run stopped by a **provider rate limit** or parked for **automatic recovery** does not need you at all
919
+ — it resumes on its own as soon as its window passes, provided something is watching for it. On a server
920
+ that is the systemd units in `driver/systemd/`. Everywhere else, run the watcher yourself:
921
+
922
+ ```
923
+ clearotron run-queue --watch
924
+ ```
925
+
926
+ That polls every 90 seconds for queued jobs and for parked runs whose window has elapsed, and it resumes
927
+ them. It also notices when the machine has been asleep, so a cap that lifted overnight is picked up when
928
+ you open the laptop rather than at the next scheduled poll. Leave it running alongside your work; `Ctrl-C`
929
+ stops it, and anything still parked waits for the next time you start it.
930
+
989
931
  ## 7. Run the MCP interrogation server
990
932
 
991
933
  The MCP server lets an external AI app read and question completed runs. Two entrypoints share one tool
@@ -994,10 +936,10 @@ set:
994
936
  - **stdio (local, full tools):**
995
937
 
996
938
  ```
997
- node mcp-server/server.mjs
939
+ clearotron mcp
998
940
  ```
999
941
 
1000
- Register it as a stdio MCP server in your desktop/CLI AI app (Claude Desktop/Code, Cursor, …). It
942
+ In a git checkout, `node mcp-server/server.mjs` starts the same server. Register it as a stdio MCP server in your desktop/CLI AI app (Claude Desktop/Code, Cursor, …). It
1001
943
  serves the read tools (list/read/trace/search/telemetry/coverage) plus a gated, single-step "what-if"
1002
944
  that re-runs one stage in a sandbox.
1003
945
 
@@ -1007,7 +949,8 @@ set:
1007
949
  node mcp-server/http-server.mjs
1008
950
  ```
1009
951
 
1010
- A Streamable-HTTP surface a remote user adds to their chat app by URL.
952
+ That path is relative to a git checkout. On a package install it is relative to the package's folder,
953
+ `~/.local/lib/node_modules/clearotron` when `clearotron install` placed it. A Streamable-HTTP surface a remote user adds to their chat app by URL.
1011
954
 
1012
955
  **What it serves depends on who is asking, and one half of it spends money.** A caller the edge
1013
956
  identifies gets the **read** tools (list/read/trace/search/telemetry/coverage) — no spend, no shell.
@@ -1036,7 +979,7 @@ set:
1036
979
 
1037
980
  The client connector is the door a company's assistant talks to, and it
1038
981
  is **part of the product** rather than something a deployment invents. A reader who reaches the
1039
- Use-your-AI page and finds Connect buttons that do nothing has been failed by the install, not by
982
+ Connect your AI page and finds Connect buttons that do nothing has been failed by the install, not by
1040
983
  their own integration work.
1041
984
 
1042
985
  **Two shapes, and the line between them is what your assistant can do — not where it runs.** Ruling
@@ -1065,9 +1008,9 @@ So an install behind `ssh -L` or an editor's port forward serves shape 1 perfect
1065
1008
  shape 2 at all, however the reader reaches the portal. `clearotron connect` says so plainly rather
1066
1009
  than printing an address that will be rejected.
1067
1010
 
1068
- **The address is set once, at install.** `npx clearotron install` asks for it — *"the address companies'
1069
- assistants reach this install at"* — and writes `CLEAROTRON_CLIENT_MCP_URL`, which is the single value the
1070
- Use-your-AI page, a report's Ask-your-AI control and `doctor` all read. Leave it empty on a local
1011
+ **The address is set once, at install.** `npx clearotron install` asks for it — *"Optional: the public connector
1012
+ address"* — and writes `CLEAROTRON_CLIENT_MCP_URL`, which is the single value the
1013
+ Connect your AI page, a report's Ask AI control and `doctor` all read. Leave it empty on a local
1071
1014
  install: every one of those surfaces then shows its honest empty state, which is correct for a machine
1072
1015
  with no public address. Changing it later is editing that one setting and restarting.
1073
1016
 
@@ -1162,7 +1105,7 @@ bills Claude through an API key or a cloud account, never a Claude subscription,
1162
1105
  require.
1163
1106
 
1164
1107
  **The guest list.** `CLEAROTRON_ACCESS_FILE` turns account scoping on for **every face at once** — the
1165
- portal, the MCP read face, and the client connector. `clearotron start` (§6) writes one into its
1108
+ portal, the MCP read face, and the client connector. `clearotron start` (§5) writes one into its
1166
1109
  state directory the first time it runs: you, with access to everything, your organisation if setup was
1167
1110
  told its name, and nobody else yet.
1168
1111
  [examples/grants.example.json](examples/grants.example.json) is a runnable guest list over the demo
@@ -1312,7 +1255,7 @@ that fails at boot, which reads as a broken install rather than as a port alread
1312
1255
  Set all seven. Nothing else separates them.
1313
1256
 
1314
1257
  A deployment that once ran the service twice for a different reason — one door needing a key and the
1315
- other a proxy identity — no longer has to; see *One process, two doors* in §9. That is an
1258
+ other a proxy identity — no longer has to; see *One process, two doors* in §7. That is an
1316
1259
  authentication arrangement and has nothing to do with this one. The seven above are still all required.
1317
1260
 
1318
1261
  ## 9. What the integrator supplies
@@ -1380,3 +1323,103 @@ answer on any of them:
1380
1323
 
1381
1324
  The licence covers the code and grants no rights in the names or marks — see `TRADEMARKS.md` for
1382
1325
  running a deployment under your own brand.
1326
+
1327
+ ## 11. From the repository
1328
+
1329
+ **This is the development tree, and it is for contributors.** If you want to run a clearance, install the
1330
+ package as §2 shows instead. A clone is not a smaller version of the package — it carries the
1331
+ fixtures and sample companies the project develops against, and those load as real records. They
1332
+ are not yours and they are not in the package, which excludes them deliberately.
1333
+
1334
+ ```
1335
+ git clone <this-repo> && cd <repo>
1336
+ npm install # installs all workspaces
1337
+ npm test # offline, fixture-backed suites — no network, no gateway, no spend
1338
+ ```
1339
+
1340
+ `npm test` belongs to **this** route only. It runs our test files, and those do not travel in a package
1341
+ — see *From a packaged tarball* in §2, which never asks you to run it.
1342
+
1343
+ This repository *is* the `clearotron` package, and npm links a package's `bin` into
1344
+ `node_modules/.bin` only for its **dependencies** — never for the package itself. So after `npm install`
1345
+ succeeds there is no `clearotron` on your `PATH` and none in `node_modules/.bin`; a bare `clearotron`
1346
+ would be `command not found` with nothing having failed.
1347
+
1348
+ **`npx` resolves the local package by walking up from the current directory, so it works from the
1349
+ project root and any subdirectory of it — and nowhere else.** From your home directory the same line
1350
+ gets you npm's `could not determine executable to run`, which names no product and suggests no fix.
1351
+ That is why this document tells you to `cd` in first, and why every command below assumes you are still
1352
+ there. On the repository route "the project" is the checkout; on the packaged route it is the directory
1353
+ you ran `npm init` in — and on that route `clearotron` IS a dependency, so `npx` finds it in
1354
+ `node_modules/.bin` exactly as the paragraph above describes.
1355
+
1356
+ **`clearotron install` (§2) puts the short form on your `PATH`**, and every command after it in this
1357
+ document uses that form. Use it rather than a fresh `npx clearotron`: `npx` resolves whichever version npm
1358
+ picks at that moment — the stable, unless you name a channel — and does not hand over to the copy the
1359
+ install placed. You can stop typing `npx` after it:
1360
+ it writes a small shim to `~/.local/bin/clearotron` pointing at this checkout. That directory needs no
1361
+ root — `npm link` would want npm's global prefix, which on a default install is `/usr` and refuses
1362
+ without it. Most login profiles add `~/.local/bin` to `PATH` only if it already existed when the shell
1363
+ started, so in the terminal that ran the install you may need `export PATH="$HOME/.local/bin:$PATH"`
1364
+ once; a new login shell picks it up by itself. The install prints which of the two you are in, and the
1365
+ product's own advice follows suit — `clearotron doctor` names the form that works from where you are
1366
+ standing, whichever that is.
1367
+
1368
+ `npm test` is the fast tier, **on the repository route**. `npm run test:full` adds the files that drive
1369
+ the orchestrator end to end and is what CI runs before a merge; [CONTRIBUTING.md](CONTRIBUTING.md) draws
1370
+ the line between them. Either way nothing is contacted and nothing is billed — the suite says so before
1371
+ it starts. Neither runs on a packaged install: the test files are not in the package.
1372
+
1373
+ The engine itself has no build step. The **portal UI does** — `portal-ui/` is React + Vite — but its
1374
+ built bundle (`portal-ui/dist/`) is **not committed to git**: it travels in the published package and
1375
+ CI builds it, so a tarball install is already runnable while a clone needs one build first. You also
1376
+ need to build after changing something under `portal-ui/src`:
1377
+
1378
+ ```
1379
+ npm run tokens # regenerate the design tokens from shared/brand.mjs, if colours changed
1380
+ npm run build:ui # build portal-ui/dist — the portal serves this, not the sources
1381
+ ```
1382
+
1383
+ **`portal-ui/dist` is build output.** The portal serves that bundle rather than the sources, so run the
1384
+ build after cloning if the directory is not there, and again whenever you change anything under
1385
+ `portal-ui/src`. Until the bundle exists the UI answers with a 503 that says exactly this, and the API
1386
+ keeps working throughout.
1387
+
1388
+ `npm test` exercises the driver and MCP server against recorded fixtures; it never calls a model or a
1389
+ provider, so it is safe to run on any machine that has the repository. "Safe anywhere" is about spend,
1390
+ not about where it will run — on a packaged tree it refuses, as above.
1391
+
1392
+ ### Cutting a package (maintainers)
1393
+
1394
+ Skip this unless you are the one producing the `.tgz`.
1395
+
1396
+ **`npm pack` alone is not the command.** The repository manifest carries
1397
+ `overrides: { "buffers": "$buffers" }`, which resolves only inside the checkout; a consumer installing that
1398
+ tarball dies with `Unable to resolve reference $buffers` before a single file is written. Five consecutive
1399
+ releases went out that way. **The published manifest has to be sealed** — that key stripped from the
1400
+ tarball, the repository's own manifest left untouched. Which route does it depends on the tree you are on:
1401
+
1402
+ - **A tree that carries `cut/`**: `node scripts/pack-publishable.mjs`. It packs, strips, reconciles against
1403
+ the withheld-file list and scans the packed tree in one step.
1404
+ - **A public checkout**, which is what the release workflow runs on: `npm pack`, then
1405
+ `node scripts/release-artifact-seal.mjs --tarball <path>`. `pack-publishable.mjs` refuses here — it needs
1406
+ `cut/packed-artifact.mjs`, which a public tree does not carry, and exits 2 rather than packing something
1407
+ nobody checked.
1408
+
1409
+ Either way, prove it before publishing it:
1410
+
1411
+ node scripts/release-install-check.mjs --tarball <path>
1412
+
1413
+ That installs the artefact as a dependency of a throwaway project, which is the only shape this failure
1414
+ exists in. Installing at the root of a checkout and `npm install --dry-run` both exit 0 on a tarball that
1415
+ refuses for every real user.
1416
+
1417
+ Two further constraints, both of which stop a package being cut from just anywhere:
1418
+
1419
+ - **The de-identification scan needs a full clone.** It refuses a shallow one (exit 2 — a check that could
1420
+ not look, not a pass) because it walks history it cannot see.
1421
+ - **It also needs its table**, passed with `--blocklist` (or `CLEAROTRON_IDENTIFIER_BLOCKLIST`), and
1422
+ that table lives in the private config store rather than in this repository. Without it the scan
1423
+ exits 2 rather than arming a weaker rule set quietly.
1424
+
1425
+ Both refusals are correct and neither is a workaround to route around.