clearotron 0.5.0 → 0.5.1-beta.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.
Files changed (123) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/INSTALL.md +334 -302
  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 +562 -336
  11. package/bin/start.mjs +184 -36
  12. package/bin/update.mjs +26 -13
  13. package/build-info.json +2 -2
  14. package/docs/PORTAL.md +2 -2
  15. package/docs/architecture/02-architecture.md +3 -3
  16. package/docs/architecture/04-configuration-reference.md +1 -2
  17. package/docs/architecture/05-config-governance.md +1 -1
  18. package/docs/architecture/06-operations-runbook.md +1 -1
  19. package/driver/CHANGELOG.md +77 -0
  20. package/driver/README.md +2 -2
  21. package/driver/config-inventory.mjs +20 -11
  22. package/driver/contract-e3-backlog.mjs +27 -27
  23. package/driver/contract-e3-baseline.json +2 -2
  24. package/driver/contract-vocabulary.mjs +1 -1
  25. package/driver/degraded-parts.mjs +67 -3
  26. package/driver/dev-portal.mjs +1 -1
  27. package/driver/digest-queue.mjs +5 -5
  28. package/driver/driver.config.mjs +9 -9
  29. package/driver/engine/CONTRACT.md +1 -1
  30. package/driver/engine/anthropic-agent.mjs +4 -2
  31. package/driver/engine/mcp/band-server.mjs +1 -21
  32. package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
  33. package/driver/engine/mcp/clarivate-server.mjs +2 -18
  34. package/driver/engine/mcp/fixture-register-server.mjs +33 -0
  35. package/driver/engine/mcp/gather-config.mjs +48 -7
  36. package/driver/engine/mcp/recording-server.mjs +206 -14
  37. package/driver/engine/mcp/supplemental.mjs +4 -2
  38. package/driver/engine/openai-agent.mjs +3 -1
  39. package/driver/engine/probe.mjs +10 -0
  40. package/driver/filing-goods.mjs +95 -0
  41. package/driver/findings-model.mjs +3 -0
  42. package/driver/gateway.mjs +42 -40
  43. package/driver/knockout-assess-record.mjs +54 -4
  44. package/driver/knockout-correction-record.mjs +342 -0
  45. package/driver/knockout-frame-record.mjs +4 -2
  46. package/driver/knockout-register-read.mjs +705 -0
  47. package/driver/knockout-register-record.mjs +222 -0
  48. package/driver/knockout-review-record.mjs +96 -25
  49. package/driver/narrative-refutation-record.mjs +87 -1
  50. package/driver/order-tables.mjs +23 -0
  51. package/driver/owner-use-check.mjs +5 -2
  52. package/driver/package.json +1 -1
  53. package/driver/partial-payload-baseline.json +8 -0
  54. package/driver/pipeline-knockout.mjs +506 -313
  55. package/driver/pipeline.mjs +179 -86
  56. package/driver/portal-local-auth.mjs +7 -1
  57. package/driver/portal-service.mjs +62 -6
  58. package/driver/progress.mjs +2 -2
  59. package/driver/publish/index.mjs +18 -21
  60. package/driver/publish/knockout.mjs +40 -18
  61. package/driver/publish/render-knockout.mjs +40 -27
  62. package/driver/publish/report-dates.mjs +43 -0
  63. package/driver/recall-reconciliation.mjs +2 -2
  64. package/driver/record-goods.mjs +50 -9
  65. package/driver/register-count.mjs +12 -59
  66. package/driver/register-fixture-marker.mjs +22 -0
  67. package/driver/register-plan.mjs +48 -0
  68. package/driver/register-records.mjs +84 -266
  69. package/driver/register-taint.mjs +2 -2
  70. package/driver/repair-composers.mjs +15 -8
  71. package/driver/result-noun-fields.mjs +6 -2
  72. package/driver/run-requirements.mjs +54 -4
  73. package/driver/runner.mjs +4 -13
  74. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  75. package/driver/skills/knockout-assess/SKILL.md +101 -100
  76. package/driver/skills/knockout-frame/SKILL.md +3 -1
  77. package/driver/skills/knockout-register-read/SKILL.md +77 -0
  78. package/driver/stages-knockout.mjs +159 -98
  79. package/driver/stages.mjs +4 -2
  80. package/driver/suite-census.json +389 -71
  81. package/driver/systemd/README.md +2 -2
  82. package/driver/verify-knockout.mjs +175 -39
  83. package/driver/verify.mjs +10 -9
  84. package/mcp-server/CHANGELOG.md +4 -0
  85. package/mcp-server/CONNECT.md +4 -0
  86. package/mcp-server/demo-mode.mjs +6 -0
  87. package/mcp-server/lib/demo-texts.mjs +38 -0
  88. package/mcp-server/lib/http-handler.mjs +7 -1
  89. package/mcp-server/lib/knockout.mjs +3 -2
  90. package/mcp-server/lib/options.mjs +3 -1
  91. package/mcp-server/lib/plan.mjs +6 -1
  92. package/mcp-server/mint-token.mjs +1 -1
  93. package/mcp-server/package.json +1 -1
  94. package/mcp-server/serve.mjs +11 -0
  95. package/mcp-server/server.mjs +13 -5
  96. package/package.json +1 -1
  97. package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
  98. package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-C1oE78Wk.js} +161 -195
  99. package/portal-ui/dist/index.html +2 -2
  100. package/portal-ui/package.json +4 -4
  101. package/providers/README.md +4 -4
  102. package/providers/_shared/execute-plan.mjs +45 -1
  103. package/providers/_shared/term-shape.mjs +1 -1
  104. package/providers/clarivate/src/capabilities.js +7 -6
  105. package/providers/clarivate/src/core.js +11 -7
  106. package/providers/clarivate/src/wider-list.js +104 -0
  107. package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
  108. package/providers/oauth-mcp-bridge/package.json +1 -1
  109. package/providers/signa/src/capabilities.js +0 -9
  110. package/scripts/e2e-first-time.mjs +8 -7
  111. package/scripts/freeze-example-run.mjs +2 -2
  112. package/scripts/settings-render-check.mjs +5 -3
  113. package/scripts/test-run.mjs +8 -2
  114. package/shared/client-door.mjs +11 -8
  115. package/shared/connect-clients.mjs +10 -4
  116. package/shared/demo-connection.mjs +43 -0
  117. package/shared/demo-start-args.mjs +7 -2
  118. package/shared/invocation.mjs +18 -3
  119. package/shared/permanent-install.mjs +14 -0
  120. package/shared/scope.mjs +8 -1
  121. package/shared/stdio-connect.mjs +43 -21
  122. package/shared/trigger-lane.mjs +7 -0
  123. 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
@@ -150,27 +154,10 @@ with `sudo`; install under your home instead: `npm install -g clearotron --prefi
150
154
  **Upgrade production to stables only.** What each channel promises and how often one is cut:
151
155
  **[docs/RELEASES.md](docs/RELEASES.md)**.
152
156
 
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.
157
+ A clone of the repository is the working tree, not a way to install the product. It is for
158
+ contributors, and §11 covers it.
155
159
 
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.
160
+ The rest of this section is for a reader who was sent a `.tgz` file.
174
161
 
175
162
  ### From a packaged tarball
176
163
 
@@ -183,11 +170,11 @@ mkdir ~/app && cd ~/app
183
170
  npm init -y
184
171
  npm install /path/to/clearotron-<version>.tgz
185
172
  npx clearotron install # the wizard
186
- clearotron doctor # reads; writes nothing, calls nobody
173
+ npx clearotron doctor # reads; writes nothing, calls nobody
187
174
  ```
188
175
 
189
176
  `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`
177
+ same mechanism §11 explains, arriving here from the other side. **You do not need to `cd`
191
178
  into `node_modules`**, and you should not: that directory belongs to your package manager, and anything
192
179
  you write inside it can be replaced by the next `npm install`.
193
180
 
@@ -195,90 +182,6 @@ you write inside it can be replaced by the next `npm install`.
195
182
  there is nothing for it to run; what you get is a refusal, and the refusal's advice is written for
196
183
  somebody working in a checkout. Nothing is wrong with your install.
197
184
 
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
185
  ## 2a. Removing it
283
186
 
284
187
  An install is not one directory, so removing it is not one command. Everything it writes is listed here.
@@ -288,14 +191,31 @@ Read the list before you delete anything: one of these directories holds your re
288
191
  background services, `clearotron stop` stops them and removes their unit files. `clearotron status` says
289
192
  which of the two you have.
290
193
 
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`:
194
+ **The program.** Installed globally, `npm rm -g clearotron` removes it. Installed by `clearotron install`,
195
+ it lives in two places under `~/.local`:
293
196
 
294
197
  ```
295
198
  ~/.local/lib/node_modules/clearotron
296
199
  ~/.local/bin/clearotron
297
200
  ```
298
201
 
202
+ Installed from a packaged tarball, it is in the folder §2 had you create, `~/app`: delete that folder.
203
+
204
+ **The reasoning program, if setup installed it.** Setup puts Claude Code or the Codex CLI in one folder,
205
+ `~/.local/share/clearotron/engines`, or where `CLEAROTRON_ENGINES_DIR` points. Delete the folder to
206
+ remove it.
207
+
208
+ **What the reasoning program keeps for itself.** Claude Code keeps its sign-in and settings in
209
+ `~/.claude` and `~/.claude.json`, and setup's engine check creates them if they were not there.
210
+ Claude Code also keeps a cache in `~/.cache/claude-cli-nodejs`.
211
+ The Codex CLI keeps its sign-in in `~/.codex`. They belong to that program, not to Clearotron: remove them
212
+ only if nothing else on the machine uses it.
213
+
214
+ **npm's copy, if you ran `npx`.** `npx clearotron` keeps the package it downloaded in npm's cache, under
215
+ `~/.npm/_npx`, beside anything else you have run with `npx`. Deleting `~/.npm/_npx` removes all of them;
216
+ npm downloads again the next time it is asked.
217
+ Any `npm install` also keeps what it downloaded in npm's cache, `~/.npm/_cacache`; `npm cache clean --force` empties it.
218
+
299
219
  **The settings, and the keys.** `~/.config/clearotron/.env` holds this install's signing secrets, so
300
220
  deleting it invalidates every key it ever issued. Beside it: `~/.config/clearotron/token-denylist`, the
301
221
  list of keys you revoked, and `~/.config/clearotron/running`, which records a product running in a
@@ -384,8 +304,8 @@ and now there is a single name.
384
304
 
385
305
  Variables not in this table are internal tunables. They keep their names.
386
306
 
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
307
+ **Two paths, one register and one AI are the whole required set.** `CLEAROTRON_DATABASE` picks the register and `CLEAROTRON_AI` the AI (§1);
308
+ `CLEAROTRON_REPORTS_DIR` says where finished reports are published; `CLEAROTRON_WORK_DIR` says where
389
309
  runs happen. The pool has **no default at all** — unset, the engine refuses and names the variable
390
310
  rather than choosing a directory on your behalf, because the wrong choice writes a report into an
391
311
  archive somebody else owns. The workspace root defaults to `$HOME/trademark/workspace`, which is also
@@ -431,27 +351,29 @@ CLEAROTRON_BRAND_PRODUCT=Trademark clearance # what the deliverable is called
431
351
  # CLEAROTRON_ADMINISTRATOR_CONTACT=it@your-firm.example
432
352
 
433
353
  # ── Register provider (choose ONE) ─────────────────────────────────────
434
- CLEAROTRON_DATABASE=clarivate # REQUIRED — corsearch | clarivate | signa | euipo | uspto-local | free-tier
354
+ CLEAROTRON_DATABASE=signa # REQUIRED — signa | free-tier | euipo | uspto-local | corsearch | clarivate
435
355
  # 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=...
356
+ SIGNA_API_KEY=... # the credential for the provider named above
440
357
  # SIGNA_BASE_URL=... # optional; defaults to the adapter's base
441
358
  # CORSEARCH_SESSION_KEY=... # …or an enterprise vendor, via a sales agreement
442
- # CLARIVATE_API_KEY=... / CLARIVATE_API_BASE=...
359
+ # CLARIVATE_API_KEY=...
360
+ # CLARIVATE_API_BASE=... # optional; defaults to the adapter's base
443
361
  # USPTO_LOCAL_DB=/var/lib/trademark/uspto/us.db # no vendor account — see §3a below
444
362
 
445
363
  # ── …or the FREE EU register, as the provider (no subscription) ────────
446
364
  # CLEAROTRON_DATABASE=euipo
447
365
  # EUIPO_CLIENT_ID=... / EUIPO_CLIENT_SECRET=...
448
- EUIPO_ENVIRONMENT=production # REQUIRED with euipo — sandbox | production are SEPARATE
366
+ # EUIPO_ENVIRONMENT=production # REQUIRED with euipo — sandbox | production are SEPARATE
449
367
  # deployments over different corpora. There is no default:
450
368
  # unset, the adapter refuses by name.
451
369
 
452
- # ── Web research — REQUIRED for all four products (see §1) ─────────────
370
+ # ── Web research — REQUIRED for the three clearance searches (see §1) ──
371
+ # A Knockout search runs without it and states on the report that the open-web half did not run.
453
372
  PERPLEXITY_API_KEY=...
454
373
 
374
+ # ── Chinese marketplaces — only the native-language investigation of China, Hong Kong, Taiwan or Macau
375
+ # SERPAPI_API_KEY=... # without it, those marketplaces come back as a disclosed gap
376
+
455
377
  # ── Optional data sources ──────────────────────────────────────────────
456
378
  # Case law has NO token variable. Access is free and immediate, and setup is a one-time OAuth login
457
379
  # per source — providers/oauth-mcp-bridge/README.md. Unset, the lane stays dark and the run records
@@ -483,7 +405,9 @@ the packets are being written and are waiting for an integrator to consume them.
483
405
 
484
406
  `uspto-local` searches a copy of the United States register that you build on your own disk from
485
407
  USPTO's public bulk data. No vendor, no invoice, and no extra software — Node 22 ships the database
486
- engine it uses.
408
+ engine it uses. The download does need a free USPTO.gov account, which asks for ID.me identity
409
+ verification, and the API key from it in `USPTO_API_KEY`; nothing is billed.
410
+ `clearotron sync --from-file <archive>` builds from an archive you already have, with no key.
487
411
 
488
412
  **The bill is time and disk, not money.** From one complete build read end to end on 2026-08-11 (767
489
413
  files, backfile and dailies): **41.5 GB** downloaded, **~9 hours** to ingest at 4.6 GB/h, **20 GB** of
@@ -677,145 +601,12 @@ becomes an incident on a real deployment rather than a bundled one:
677
601
 
678
602
  Copy or author the companies, context packs and project overlays you want; assume you inherit none.
679
603
 
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.
604
+ ## 5. Start the product on this machine
814
605
 
815
- ## 6. Start the product on this machine
606
+ This is the product: a portal you sign in to, order a clearance from, and read the report in.
816
607
 
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.
608
+ See it before you buy anything: `npx clearotron demo` replays finished clearances with no account, no
609
+ key, and no network. `npx clearotron@beta demo` replays the beta's.
819
610
 
820
611
  **Plain `clearotron start` runs in the foreground and stops when this terminal closes** — Ctrl-C, a
821
612
  dropped SSH session, a shut laptop lid ending the session: the portal goes with it. That is the right
@@ -830,24 +621,27 @@ clearotron stop # stop it and give the box back — plain `sta
830
621
  `--background` never touches the assistant connector: `clearotron connect` opens that door
831
622
  and `clearotron disconnect` closes it, separately and on purpose.
832
623
 
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
624
+ **If anything else on this host already runs this product, set its ports first.** `start` opens three:
625
+ the portal (18802), the engine door (18790) and the client door (18811). They are **fixed defaults shared
626
+ by every install on a machine**, so a second instance meets the first one's ports. Give it its own three
836
627
  before the first start:
837
628
 
838
629
  ```
839
- PORTAL_SERVICE_PORT=18820 TRADEMARK_MCP_HTTP_PORT=18821 clearotron start
630
+ PORTAL_SERVICE_PORT=18820 TRADEMARK_MCP_HTTP_PORT=18821 CLIENT_MCP_HTTP_PORT=18822 clearotron start
840
631
  ```
841
632
 
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:
633
+ `clearotron start --port 18820` opens the same three: 18820, 18821 and 18822.
634
+
635
+ A test instance beside a live one needs more than its own ports — §8, *Two instances on one machine*, is
636
+ the whole boundary. On a host running nothing else, ignore this and carry on:
844
637
 
845
638
  ```
846
639
  clearotron start
847
640
  ```
848
641
 
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.
642
+ One command. It starts the portal, the engine door the portal's Start button calls, the client door an
643
+ assistant connects to, and the worker that runs what you order. It waits until the portal and the engine
644
+ door answer, and prints one address to open. `Ctrl-C` stops all of them. The second run asks nothing.
851
645
 
852
646
  **This is not `npx clearotron demo`, and the two are not interchangeable.**
853
647
 
@@ -856,7 +650,7 @@ answer, and prints one address to open. `Ctrl-C` stops both. The second run asks
856
650
  | what it is | a finished report, replayed | the running product |
857
651
  | credentials | none | whatever a real run needs (§3) |
858
652
  | model calls | none | yes, once you order a clearance |
859
- | what you can do | read | sign in, configure, order, read |
653
+ | what you can do | sign in and read; an order opens the finished example for that search | sign in, configure, order, read |
860
654
 
861
655
  Use the demo to see what this system produces. Use `clearotron start` to run it.
862
656
 
@@ -936,14 +730,16 @@ A queued job whose worker is not running says so on the portal rather than sitti
936
730
  identity edge (§8 for what separates one instance from another); this command touches none of them and
937
731
  is not a way to set them up.
938
732
 
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.
733
+ **And it does not keep this install up to date.** `clearotron update` does. On a package install on
734
+ Linux or macOS it installs the newest stable, or for a beta install the newest beta or stable, whichever
735
+ is later; on Windows it names the npm command to run instead. In a git checkout it fast-forwards the
736
+ checkout and reinstalls dependencies. Either way it refuses over a
737
+ configuration store kept inside the install's own folder, and it refuses while a run is queued or in
738
+ flight — an update replaces the program's files under whatever is running, and a clearance assembled
739
+ from halves of two builds does not fail, it answers wrongly.
944
740
 
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
741
+ **To make that automatic in a git checkout**, this repository ships a unit and an hourly timer that run
742
+ exactly that command, with the same two refusals. They are generic — the checkout path comes from your
947
743
  `EnvironmentFile` — and they neither start nor stop a queue drainer:
948
744
 
949
745
  ```
@@ -964,28 +760,163 @@ any running program that started before your checkout last moved. **It does not
964
760
  supervisor owns a service is a property of your deployment, not of this checkout — so restarting is
965
761
  yours to do, and now yours to know about.
966
762
 
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.
763
+ ### Ports
975
764
 
976
- Two lines on a fresh install look worse than they are:
765
+ The portal is on 18802, the engine door on 18790 and the client door on 18811, all loopback, and all
766
+ three are **fixed defaults for every install on the host** rather than per-install values. Each has its
767
+ own variable: `PORTAL_SERVICE_PORT`, `TRADEMARK_MCP_HTTP_PORT` and `CLIENT_MCP_HTTP_PORT`.
768
+ `clearotron start --port <n>` puts the portal on n, and the engine door and the client door on n+1 and
769
+ n+2 unless their own variables are set.
977
770
 
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.
771
+ `start` checks every port before anything starts. A port in use is refused when you set its variable, or
772
+ when `CF_ACCESS_TEAM` or an `*_OIDC_ISSUER` setting says a proxy or a sign-in provider sits in front,
773
+ because whatever is in front is still addressed to that number. The refusal names the port and the
774
+ variable to change. Any other port in use moves to the next free number, and `start` prints where it went.
985
775
 
986
776
  `driver/dev-portal.mjs` is **not** this. It is a loopback pool browser for people working on the engine,
987
777
  its own header says never to expose it, and nothing here starts it.
988
778
 
779
+ ## 6. Run a headless clearance report
780
+
781
+ 1. Make sure `CLEAROTRON_AI` names the engine you want (`anthropic-agent` or `openai-agent`), its CLI is
782
+ authenticated, and your active register provider's credential is set. `clearotron doctor
783
+ --probe-engine` answers all three, and the engine half of it by actually running a turn — an
784
+ executable on `PATH` that is signed out passes every other check and fails at the first stage.
785
+
786
+ 2. Write a **job file**. The required fields are an `id`, a `forwarder` handle, at least one mark
787
+ **name**, and either classes or a goods description — a company profile can supply the last one.
788
+ `msgId` is optional: it threads the reply into the original email, and a job without one is warned,
789
+ not refused. A minimal neutral example:
790
+
791
+ ```json
792
+ {
793
+ "id": "job-2026-0001",
794
+ "msgId": "<intake-2026-0001@example.com>",
795
+ "forwarder": "alex",
796
+ "forwarderEmail": "alex@example.com",
797
+ "forwarderDomain": "example.com",
798
+ "marks": [{ "ref": "TM-0001", "name": "IRONWHISK", "classes": [9, 42] }],
799
+ "goods": "cloud software for weather analytics",
800
+ "jurisdictions": ["US"],
801
+ "product": "knockout-search"
802
+ }
803
+ ```
804
+
805
+ **`product` names which of the four searches you are ordering, and the example names it on purpose.**
806
+ It orders a **Knockout search over one territory** — the cheapest of the four and the fastest way to
807
+ prove the install works end to end. It is not the product you would order for a real matter; it is the
808
+ one that answers "does this run at all" in minutes rather than hours. Change it when you have a matter.
809
+
810
+ | product | case law | native language |
811
+ |---|---|---|
812
+ | `knockout-search` | no | not offered |
813
+ | `global-preliminary-search` | no | not offered |
814
+ | `multi-country-focus-search` | no | offered |
815
+ | `full-country-search` | **yes** | **automatic** |
816
+
817
+ **Omit it and the territories decide — in a direction that will surprise you.** No `jurisdictions`
818
+ gives you `global-preliminary-search`; two or more give `multi-country-focus-search`; and naming
819
+ **exactly one country** gives `full-country-search`, the deepest of the four, which turns case law on
820
+ and runs the native-language investigation automatically.
821
+
822
+ **That is why the example above names `product` even though it lists one territory.** Delete the
823
+ `product` line and this job — one country — becomes a `full-country-search`: the deepest of the four,
824
+ case law on, native-language investigation running, hours instead of minutes. Narrowing the scope to
825
+ make a first run smaller orders **more** work, not less, and naming `product` is what stops the scope
826
+ deciding for you. An unknown value is a clarify, never a silent substitute.
827
+
828
+
829
+ 3. Run the pipeline:
830
+
831
+ ```
832
+ clearotron run --job job.json
833
+ ```
834
+
835
+ **The example above is sized in minutes; a real clearance is sized in hours.**
836
+ The engine sizes a knockout search at 5 to 10 minutes — which is what this job orders — and a clearance
837
+ at up to 2.5 hours.
838
+ The three clearances in `demo/` took 64 to 74 minutes each, and its knockout search 4 minutes. A
839
+ single stage of a clearance can legitimately run 45 minutes — let it finish.
840
+ [How long a run takes](#how-long-a-run-takes) below gives the provenance of each figure.
841
+
842
+ This run sends the matter off the machine — the mark, its classes, the goods wording, and the
843
+ company's context reach a reasoning provider and Perplexity, and the mark and its variants reach your
844
+ register. Before the first live matter, read
845
+ [what leaves the machine](docs/architecture/09-security-and-data.md#what-leaves-the-machine).
846
+
847
+ The driver resolves the profile, runs the reasoning stages as headless CLI turns, gates delivery on
848
+ its internal refutation verdict, and then:
849
+
850
+ - **publishes** the report (HTML + Markdown) and an Excel audit into `CLEAROTRON_REPORTS_DIR`; and
851
+ - writes **`_driver/delivery.json`** in the run directory — a self-contained handoff packet:
852
+
853
+ ```
854
+ { runId, agent, forwarder, forwarderEmail, msgId, conversationId, subject, emailBodyHtml, url,
855
+ verdict, markName, whatsappTo, whatsappText }
856
+ ```
857
+
858
+ This packet **is the delivery contract**: an integrator's channel wiring reads it and sends the report
859
+ by email/chat. The engine never sends messages itself — the report is already published regardless.
860
+ Failures, intake rejections, duplicate skips and late-bind acks ride the same outbox seam as
861
+ self-contained event packets — the full catalog + the integrator loop is
862
+ [docs/DELIVERY.md](docs/DELIVERY.md); intake (the enqueue CLI, the job JSON, queue lifecycle,
863
+ dedup) is [docs/INTAKE.md](docs/INTAKE.md).
864
+
865
+ ### How long a run takes
866
+
867
+ Minutes for a knockout search, an hour or more for a clearance.
868
+
869
+ **Four measured runs.** Each sample in `demo/` records its own wall, from `startedAt` to `deliveredAt`
870
+ in `run/status.json`. The three clearances took **64 to 74 minutes** each, quicker than the quote
871
+ below; the knockout search took **4 minutes**.
872
+
873
+ **What the engine quotes.** A knockout search is sized at 5 to 10 minutes. A clearance starts at 1.5 hours
874
+ and runs to 2.5 hours — one range for every clearance, whichever lanes it carries
875
+ (`driver/effort-model.mjs`). The quote used to add half an hour each for the case-law reading, the
876
+ native-language lane and a single-territory deep-dive; the delivered walls refuted that, so the adders
877
+ were removed.
878
+
879
+ **What the stages declare.** Every stage carries a timeout — the longest is 45 minutes, and the 16
880
+ together sum to 5.6 hours (`driver/stages.mjs`). Fan-out members run in parallel and a retry adds to
881
+ the wall, so the sum sizes the stages rather than the run.
882
+
883
+ What moves the wall is the fan-out: how many search axes the register plan compiles, whether the
884
+ marketplace sweep splits in half, how many findings need cards, and how many registers the product
885
+ sweeps. Every run records its own quote against its actual wall in `status.json`. A stage still going
886
+ after half an hour is not hung — the longest stage timeout is 45 minutes, and the engine hard-kills
887
+ anything that overruns its own.
888
+
889
+ ### If a run stops before it delivers
890
+
891
+ A clearance run takes hours, so it will sometimes stop part-way: you close the lid, the machine reboots,
892
+ or the model provider caps you mid-run. **Nothing is lost.** Every finished stage stays on disk and a
893
+ resume re-runs only what is missing or invalid.
894
+
895
+ The command that continues a run is printed whenever a run ends badly — copy the line it gives you:
896
+
897
+ ```
898
+ clearotron run --job /path/to/job.json --resume <codename>
899
+ ```
900
+
901
+ The job file can be left out:
902
+
903
+ ```
904
+ clearotron run --resume <codename>
905
+ ```
906
+
907
+ A run stopped by a **provider rate limit** or parked for **automatic recovery** does not need you at all
908
+ — it resumes on its own as soon as its window passes, provided something is watching for it. On a server
909
+ that is the systemd units in `driver/systemd/`. Everywhere else, run the watcher yourself:
910
+
911
+ ```
912
+ clearotron run-queue --watch
913
+ ```
914
+
915
+ That polls every 90 seconds for queued jobs and for parked runs whose window has elapsed, and it resumes
916
+ them. It also notices when the machine has been asleep, so a cap that lifted overnight is picked up when
917
+ you open the laptop rather than at the next scheduled poll. Leave it running alongside your work; `Ctrl-C`
918
+ stops it, and anything still parked waits for the next time you start it.
919
+
989
920
  ## 7. Run the MCP interrogation server
990
921
 
991
922
  The MCP server lets an external AI app read and question completed runs. Two entrypoints share one tool
@@ -994,10 +925,10 @@ set:
994
925
  - **stdio (local, full tools):**
995
926
 
996
927
  ```
997
- node mcp-server/server.mjs
928
+ clearotron mcp
998
929
  ```
999
930
 
1000
- Register it as a stdio MCP server in your desktop/CLI AI app (Claude Desktop/Code, Cursor, …). It
931
+ 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
932
  serves the read tools (list/read/trace/search/telemetry/coverage) plus a gated, single-step "what-if"
1002
933
  that re-runs one stage in a sandbox.
1003
934
 
@@ -1007,7 +938,8 @@ set:
1007
938
  node mcp-server/http-server.mjs
1008
939
  ```
1009
940
 
1010
- A Streamable-HTTP surface a remote user adds to their chat app by URL.
941
+ That path is relative to a git checkout. On a package install it is relative to the package's folder,
942
+ `~/.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
943
 
1012
944
  **What it serves depends on who is asking, and one half of it spends money.** A caller the edge
1013
945
  identifies gets the **read** tools (list/read/trace/search/telemetry/coverage) — no spend, no shell.
@@ -1162,7 +1094,7 @@ bills Claude through an API key or a cloud account, never a Claude subscription,
1162
1094
  require.
1163
1095
 
1164
1096
  **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
1097
+ portal, the MCP read face, and the client connector. `clearotron start` (§5) writes one into its
1166
1098
  state directory the first time it runs: you, with access to everything, your organisation if setup was
1167
1099
  told its name, and nobody else yet.
1168
1100
  [examples/grants.example.json](examples/grants.example.json) is a runnable guest list over the demo
@@ -1312,7 +1244,7 @@ that fails at boot, which reads as a broken install rather than as a port alread
1312
1244
  Set all seven. Nothing else separates them.
1313
1245
 
1314
1246
  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
1247
+ other a proxy identity — no longer has to; see *One process, two doors* in §7. That is an
1316
1248
  authentication arrangement and has nothing to do with this one. The seven above are still all required.
1317
1249
 
1318
1250
  ## 9. What the integrator supplies
@@ -1380,3 +1312,103 @@ answer on any of them:
1380
1312
 
1381
1313
  The licence covers the code and grants no rights in the names or marks — see `TRADEMARKS.md` for
1382
1314
  running a deployment under your own brand.
1315
+
1316
+ ## 11. From the repository
1317
+
1318
+ **This is the development tree, and it is for contributors.** If you want to run a clearance, install the
1319
+ package as §2 shows instead. A clone is not a smaller version of the package — it carries the
1320
+ fixtures and sample companies the project develops against, and those load as real records. They
1321
+ are not yours and they are not in the package, which excludes them deliberately.
1322
+
1323
+ ```
1324
+ git clone <this-repo> && cd <repo>
1325
+ npm install # installs all workspaces
1326
+ npm test # offline, fixture-backed suites — no network, no gateway, no spend
1327
+ ```
1328
+
1329
+ `npm test` belongs to **this** route only. It runs our test files, and those do not travel in a package
1330
+ — see *From a packaged tarball* in §2, which never asks you to run it.
1331
+
1332
+ This repository *is* the `clearotron` package, and npm links a package's `bin` into
1333
+ `node_modules/.bin` only for its **dependencies** — never for the package itself. So after `npm install`
1334
+ succeeds there is no `clearotron` on your `PATH` and none in `node_modules/.bin`; a bare `clearotron`
1335
+ would be `command not found` with nothing having failed.
1336
+
1337
+ **`npx` resolves the local package by walking up from the current directory, so it works from the
1338
+ project root and any subdirectory of it — and nowhere else.** From your home directory the same line
1339
+ gets you npm's `could not determine executable to run`, which names no product and suggests no fix.
1340
+ That is why this document tells you to `cd` in first, and why every command below assumes you are still
1341
+ there. On the repository route "the project" is the checkout; on the packaged route it is the directory
1342
+ you ran `npm init` in — and on that route `clearotron` IS a dependency, so `npx` finds it in
1343
+ `node_modules/.bin` exactly as the paragraph above describes.
1344
+
1345
+ **`clearotron install` (§3) puts the short form on your `PATH`**, and every command after it in this
1346
+ document uses that form. Use it rather than a fresh `npx clearotron`: `npx` resolves whichever version npm
1347
+ picks at that moment — the stable, unless you name a channel — and does not hand over to the copy the
1348
+ install placed. You can stop typing `npx` after it:
1349
+ it writes a small shim to `~/.local/bin/clearotron` pointing at this checkout. That directory needs no
1350
+ root — `npm link` would want npm's global prefix, which on a default install is `/usr` and refuses
1351
+ without it. Most login profiles add `~/.local/bin` to `PATH` only if it already existed when the shell
1352
+ started, so in the terminal that ran the install you may need `export PATH="$HOME/.local/bin:$PATH"`
1353
+ once; a new login shell picks it up by itself. The install prints which of the two you are in, and the
1354
+ product's own advice follows suit — `clearotron doctor` names the form that works from where you are
1355
+ standing, whichever that is.
1356
+
1357
+ `npm test` is the fast tier, **on the repository route**. `npm run test:full` adds the files that drive
1358
+ the orchestrator end to end and is what CI runs before a merge; [CONTRIBUTING.md](CONTRIBUTING.md) draws
1359
+ the line between them. Either way nothing is contacted and nothing is billed — the suite says so before
1360
+ it starts. Neither runs on a packaged install: the test files are not in the package.
1361
+
1362
+ The engine itself has no build step. The **portal UI does** — `portal-ui/` is React + Vite — but its
1363
+ built bundle (`portal-ui/dist/`) is **not committed to git**: it travels in the published package and
1364
+ CI builds it, so a tarball install is already runnable while a clone needs one build first. You also
1365
+ need to build after changing something under `portal-ui/src`:
1366
+
1367
+ ```
1368
+ npm run tokens # regenerate the design tokens from shared/brand.mjs, if colours changed
1369
+ npm run build:ui # build portal-ui/dist — the portal serves this, not the sources
1370
+ ```
1371
+
1372
+ **`portal-ui/dist` is build output.** The portal serves that bundle rather than the sources, so run the
1373
+ build after cloning if the directory is not there, and again whenever you change anything under
1374
+ `portal-ui/src`. Until the bundle exists the UI answers with a 503 that says exactly this, and the API
1375
+ keeps working throughout.
1376
+
1377
+ `npm test` exercises the driver and MCP server against recorded fixtures; it never calls a model or a
1378
+ provider, so it is safe to run on any machine that has the repository. "Safe anywhere" is about spend,
1379
+ not about where it will run — on a packaged tree it refuses, as above.
1380
+
1381
+ ### Cutting a package (maintainers)
1382
+
1383
+ Skip this unless you are the one producing the `.tgz`.
1384
+
1385
+ **`npm pack` alone is not the command.** The repository manifest carries
1386
+ `overrides: { "buffers": "$buffers" }`, which resolves only inside the checkout; a consumer installing that
1387
+ tarball dies with `Unable to resolve reference $buffers` before a single file is written. Five consecutive
1388
+ releases went out that way. **The published manifest has to be sealed** — that key stripped from the
1389
+ tarball, the repository's own manifest left untouched. Which route does it depends on the tree you are on:
1390
+
1391
+ - **A tree that carries `cut/`**: `node scripts/pack-publishable.mjs`. It packs, strips, reconciles against
1392
+ the withheld-file list and scans the packed tree in one step.
1393
+ - **A public checkout**, which is what the release workflow runs on: `npm pack`, then
1394
+ `node scripts/release-artifact-seal.mjs --tarball <path>`. `pack-publishable.mjs` refuses here — it needs
1395
+ `cut/packed-artifact.mjs`, which a public tree does not carry, and exits 2 rather than packing something
1396
+ nobody checked.
1397
+
1398
+ Either way, prove it before publishing it:
1399
+
1400
+ node scripts/release-install-check.mjs --tarball <path>
1401
+
1402
+ That installs the artefact as a dependency of a throwaway project, which is the only shape this failure
1403
+ exists in. Installing at the root of a checkout and `npm install --dry-run` both exit 0 on a tarball that
1404
+ refuses for every real user.
1405
+
1406
+ Two further constraints, both of which stop a package being cut from just anywhere:
1407
+
1408
+ - **The de-identification scan needs a full clone.** It refuses a shallow one (exit 2 — a check that could
1409
+ not look, not a pass) because it walks history it cannot see.
1410
+ - **It also needs its table**, passed with `--blocklist` (or `CLEAROTRON_IDENTIFIER_BLOCKLIST`), and
1411
+ that table lives in the private config store rather than in this repository. Without it the scan
1412
+ exits 2 rather than arming a weaker rule set quietly.
1413
+
1414
+ Both refusals are correct and neither is a workaround to route around.