tr-plugin-meta-harness 0.3.0 → 0.5.27

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 (94) hide show
  1. package/DESIGN.md +86 -0
  2. package/README.md +257 -11
  3. package/capability/BRICK.md +1 -1
  4. package/capability/index.mjs +154 -13
  5. package/cli.mjs +426 -41
  6. package/package.json +15 -3
  7. package/plugin.json +1457 -119
  8. package/skills/meta-harness/SKILL.md +63 -25
  9. package/src/adoption.mjs +102 -0
  10. package/src/agent-user.mjs +194 -0
  11. package/src/alerts.mjs +220 -14
  12. package/src/cascade.mjs +185 -0
  13. package/src/chat.mjs +80 -0
  14. package/src/codex-models.mjs +54 -0
  15. package/src/compat-harness.mjs +117 -0
  16. package/src/control.mjs +145 -0
  17. package/src/coordinator.mjs +267 -358
  18. package/src/dispatch-request.mjs +76 -0
  19. package/src/dispatch.mjs +119 -0
  20. package/src/documentation-authority.mjs +57 -0
  21. package/src/documentation.mjs +120 -32
  22. package/src/executor.mjs +101 -22
  23. package/src/gate-adapters/agy.mjs +155 -0
  24. package/src/gate-adapters/claude.mjs +303 -0
  25. package/src/gate-adapters/cline.mjs +111 -0
  26. package/src/gate-adapters/codex.mjs +164 -0
  27. package/src/gate-adapters/cursor.mjs +164 -0
  28. package/src/gate-adapters/devin.mjs +116 -0
  29. package/src/gate-adapters/dsh.mjs +284 -0
  30. package/src/gate-adapters/grok.mjs +112 -0
  31. package/src/gate-adapters/hermes.mjs +217 -0
  32. package/src/gate-adapters/hook-files.mjs +156 -0
  33. package/src/gate-adapters/index.mjs +131 -0
  34. package/src/gate-adapters/openclaw-plugin/gate-client.js +205 -0
  35. package/src/gate-adapters/openclaw-plugin/index.js +25 -0
  36. package/src/gate-adapters/openclaw-plugin/openclaw.plugin.json +9 -0
  37. package/src/gate-adapters/openclaw-plugin/package.json +15 -0
  38. package/src/gate-adapters/openclaw.mjs +288 -0
  39. package/src/gate-adapters/pi.mjs +146 -0
  40. package/src/gate.mjs +18 -0
  41. package/src/harness-updates.mjs +170 -0
  42. package/src/included-usage.mjs +344 -0
  43. package/src/jobs.mjs +135 -0
  44. package/src/json-reply.mjs +22 -0
  45. package/src/learner.mjs +97 -67
  46. package/src/maintenance.mjs +18 -0
  47. package/src/mcp-server.mjs +228 -0
  48. package/src/model-catalog.mjs +195 -0
  49. package/src/model-selection.mjs +67 -0
  50. package/src/paths.mjs +23 -0
  51. package/src/pool.mjs +69 -0
  52. package/src/process-manager.mjs +246 -0
  53. package/src/process-worker.mjs +18 -0
  54. package/src/reasoning.mjs +231 -0
  55. package/src/remote-operation.mjs +76 -0
  56. package/src/review.mjs +241 -0
  57. package/src/reviews.mjs +25 -0
  58. package/src/router-benchmark-corpus.mjs +16 -0
  59. package/src/router-benchmark.mjs +208 -0
  60. package/src/router.mjs +265 -346
  61. package/src/runtime.mjs +30 -8
  62. package/src/session/claude.mjs +358 -0
  63. package/src/session/codex.mjs +501 -0
  64. package/src/session/result.mjs +90 -0
  65. package/src/session/resume.mjs +393 -0
  66. package/src/session/run.mjs +258 -0
  67. package/src/session-jobs.mjs +77 -0
  68. package/src/setup.mjs +6 -3
  69. package/src/ssss-store.mjs +20 -0
  70. package/src/telemetry.mjs +267 -0
  71. package/src/termination.mjs +28 -0
  72. package/src/threads.mjs +150 -0
  73. package/src/usage-queue.mjs +137 -0
  74. package/src/verify-ssss.mjs +102 -0
  75. package/src/worker.mjs +955 -84
  76. package/src/worktree.mjs +244 -0
  77. package/ui/chunks/adapter-docs-freshness.md +16 -0
  78. package/ui/chunks/chat-handoff.md +26 -0
  79. package/ui/chunks/fleet-maintenance.md +21 -0
  80. package/ui/chunks/harness-inventory.md +21 -0
  81. package/ui/chunks/included-access.md +18 -0
  82. package/ui/chunks/included-usage-verification.md +15 -0
  83. package/ui/chunks/independent-review.md +17 -0
  84. package/ui/chunks/managed-execution.md +20 -0
  85. package/ui/chunks/official-documentation.md +18 -0
  86. package/ui/chunks/quota-recovery.md +21 -0
  87. package/ui/chunks/review-routing-decision.md +16 -0
  88. package/ui/chunks/route-work.md +18 -0
  89. package/ui/chunks/routing-evidence.md +18 -0
  90. package/ui/chunks/run-ledger.md +18 -0
  91. package/ui/chunks/session-controls.md +16 -0
  92. package/ui/home.js +198 -0
  93. package/ui/DESIGN.md +0 -32
  94. package/ui/card.js +0 -845
package/DESIGN.md ADDED
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: Metaharness
3
+ description: A clear handoff from Total Recall's brain selection to the operator's chosen Chat harness.
4
+ colors:
5
+ canvas: '#0c1427'
6
+ background: '{colors.canvas}'
7
+ surface: '#1e293b'
8
+ text: '#f1f5f9'
9
+ muted: '#94a3b8'
10
+ signal: '#38bdf8'
11
+ primary: '#3b82f6'
12
+ line: '#334155'
13
+ success: '#10b981'
14
+ warning: '#f59e0b'
15
+ danger: '#ef4444'
16
+ typography:
17
+ title:
18
+ fontFamily: system-ui, sans-serif
19
+ fontSize: 18px
20
+ fontWeight: 650
21
+ lineHeight: 1.2
22
+ body:
23
+ fontFamily: system-ui, sans-serif
24
+ fontSize: 14px
25
+ lineHeight: 1.5
26
+ label:
27
+ fontFamily: ui-monospace, monospace
28
+ fontSize: 11px
29
+ fontWeight: 600
30
+ letterSpacing: 0.08em
31
+ rounded:
32
+ frame: 8px
33
+ spacing:
34
+ inset: 16px
35
+ row: 12px
36
+ components:
37
+ chat-handoff:
38
+ backgroundColor: '{colors.canvas}'
39
+ textColor: '{colors.text}'
40
+ typography: '{typography.body}'
41
+ rounded: '{rounded.frame}'
42
+ padding: '{spacing.inset}'
43
+ ---
44
+
45
+ ## Overview
46
+
47
+ Metaharness works like a dispatch board. Readers should understand the selected
48
+ harness, the brain scope and the next action from a quick scan.
49
+
50
+ ## Colors
51
+
52
+ Use the deep navy {colors.canvas} under pale {colors.text}. Reserve blue
53
+ {colors.signal} for the route between the brain selection and its destination.
54
+ Use status colors for verified outcomes from the host.
55
+
56
+ ## Typography
57
+
58
+ Use the quiet, compact {typography.label} for handoff stages. Use
59
+ {typography.title} for the section heading and {typography.body} for instructions.
60
+
61
+ ## Layout
62
+
63
+ Give the heading and route a full-width row at narrow drawer sizes. Stack route
64
+ stages when their labels would wrap. In a wider drawer, use one route line.
65
+
66
+ ## Elevation & Depth
67
+
68
+ Separate the saved route from its controls with a single border. Keep the
69
+ workflow blocks flat so their order stays clear when combined in a drawer.
70
+
71
+ ## Shapes
72
+
73
+ Use compact rounded frames and controls. Label the route stages with text.
74
+
75
+ ## Components
76
+
77
+ The Chat handoff block explains the route. The native Home shows the saved
78
+ harness, registered choices and the optional destination. The bottom drawer
79
+ supplies brain selection and the launch and copy controls. Each operational
80
+ block describes one separate workflow and its observed owner data.
81
+
82
+ ## Do's and Don'ts
83
+
84
+ Show the route in reading order. Keep operational state sourced from Metaharness.
85
+ Keep the handoff marker still and show clear focus and loading states. Use text
86
+ to distinguish saved configuration, draft behavior and unavailable reads.
package/README.md CHANGED
@@ -1,22 +1,133 @@
1
- # Command Fleet
1
+ # Metaharness
2
2
 
3
- All nine adapters share one plugin: Claude Code, Codex, Antigravity, Cursor,
4
- DSH, Grok, Muse, Pi and Hermes. `runtime <agent> ...` exposes their native runtime
5
- commands; DSH observations and Hermes gateway management live here as well.
3
+ ## Quick start
4
+
5
+ Run these commands with the installed Total Recall CLI. Check candidate retrieval and routing on the local checkout.
6
+
7
+ ### First workflow
8
+
9
+ ```sh
10
+ total-recall meta-harness catalog --json
11
+ ```
12
+
13
+ Read supported adapter IDs and the available permission categories from the catalog.
14
+
15
+ [Local CLI screenshot](docs/projects/in-progress/METAHARNESS_QUICKSTART/quickstart.png) · [Project tracker](docs/projects/in-progress/METAHARNESS_QUICKSTART/METAHARNESS_QUICKSTART_PROJECT_TRACKER.md)
16
+
17
+ ### Practical workflow
18
+
19
+ Start `total-recall meta-harness orchestrate "<task>" --execute --json` with the calling harness's native background function. The tracked command exits with the completed orchestration result. Executed routes and coordination runs also return the final result by default. Use `--background` to explicitly detach and get a job ID. `watch <job-id> --json` is available for an on-demand status check.
20
+
21
+ Run `total-recall meta-harness router-benchmark --json` from a Total Recall source checkout, or use `--core-root /path/to/total-recall` when running from another repository. Read the retrieval metrics, labels and readiness scenarios in the result. Omit `--save` to avoid creating a report record. This benchmark does not execute an agent or call a provider.
22
+
23
+ Catalog entries describe adapters. Local binaries, authentication, quotas, and a completed run are separate evidence. Dispatch or route with `--execute` can create worktrees, invoke metered coding agents, and affect the destination repository.
24
+
25
+ When Metaharness runs as root on Linux, Claude runs as a dedicated non-root Unix
26
+ account with `--permission-mode bypassPermissions`. The operator must provision
27
+ that account with a readable, writable home, install the Linux `acl` package, and
28
+ select it on that node:
29
+
30
+ ```sh
31
+ total-recall meta-harness agent-user <name>
32
+ total-recall meta-harness agent-user --json
33
+ total-recall meta-harness agent-user --clear
34
+ ```
35
+
36
+ Managed agents cannot change this setting. Dispatch refuses an unset user, uid 0,
37
+ an unusable home or a failed ACL grant. ACLs give the account write access to its
38
+ checkout, read access to git metadata, bootstrap files and executables, and
39
+ execute-only access to ancestor directories. Git common directories and `.git`
40
+ entries, including nested repositories, receive read-only protection after all
41
+ other grants. Agent-owned metadata and metadata symlinks are refused. Before
42
+ root runs git after the agent, the harness checks the recorded metadata's type,
43
+ identity, root ownership and exact pointer bytes, and rejects newly created nested
44
+ git metadata. A refused commit preserves the checkout for recovery. Ownership is
45
+ never changed. Git trusts only this checkout through the child process's runtime
46
+ `safe.directory` setting. HOME, USER and LOGNAME select the account; Claude still
47
+ receives its subscription token from Total Recall Auth.
48
+
49
+ Claude's MCP server gets access only to this job's inbox/events under the root
50
+ brain, plus plugin source and Node. `ask`, replies and `operator` approvals use
51
+ those files. `rules` approvals call `total-recall decision run`, which cannot read
52
+ root's brain or Auth store as the agent user, so they deny on failure. MCP alert
53
+ delivery also requires root's Auth access and may fail; questions and approvals
54
+ remain visible through `watch`. No brain or secret-store ACL is granted to work
55
+ around these limits. Other platforms and non-root launches retain their existing
56
+ identity and configuration.
57
+
58
+ `total-recall meta-harness router-benchmark --json` evaluates the real host
59
+ `shortlistActions -> queryCliSemanticIndex` and owner `routeTask` separately.
60
+ It reads the complete installed composable CLI library; no plugin tasks or
61
+ provider calls run. `--k 20 --repeats 3 --catalog-samples 24` are defaults.
62
+ Use `--core-root /absolute/core` to select one verified Total Recall source for both
63
+ catalog CLI and retrieval imports. The library runs as `node <root>/bin/total-recall.mjs`;
64
+ an installed runner cannot override the selection. `TR_PACKAGE_ROOT` remains the
65
+ default host and may also be needed by the owner CLI storage imports at startup.
66
+
67
+ Independent semantic, ambiguous, multi-step and unavailable cases are separate
68
+ from mechanically generated catalog-description probes. Harness cases exercise
69
+ real routing against controlled ready/inactive/quota scenarios, not live readiness.
70
+ JSON includes corpus data/version/hash, catalog fingerprint/hash, source hashes,
71
+ timestamps, individual rankings, recall@k, MRR, top-one accuracy, label coverage,
72
+ candidate reduction and typed-question UTF-8 bytes. Question bytes are a payload
73
+ size measurement, not actual provider prompt usage or token savings. Multiple
74
+ expected groups require all steps; alternatives within a group are interchangeable.
75
+ Absent labels lower coverage and remain in recall denominators.
76
+
77
+ First-call latency excludes module loading and OS cold-cache guarantees; warm
78
+ latency covers subsequent corpus passes. Catalog queries include all declared
79
+ CLI/API/MCP/nested-router capabilities; actionable shortlist measurements are
80
+ separate and exclude unsupported/inactive declarations. Missing installed surfaces
81
+ are explicit coverage gaps. Real-core declaration fixtures are correctness tests,
82
+ separate from live catalog measurements. Retrieval has no abstention or
83
+ activation-enforcement contract: refusal correctness, live execution quality,
84
+ costs and tokens stay null. Scenario refusal correctness belongs to the harness layer.
85
+
86
+ Use `--corpus cases.json` for schema-1 `{id,version,cases}` (plus `schemaVersion:1`),
87
+ with capability cases `{id,layer:"capability",surface:"cli",intent,groups:[[label]],provenance}`;
88
+ surface may also be `api`, `mcp`, or `router`. Harness cases use `layer:"harness"`,
89
+ `scenario:"ready"|"inactive"|"quota"` and `expected:["codex","claude"]` (empty
90
+ means refuse). Labels use declared IDs such as `plugin:auth:cli:status`. Legacy CLI aliases
91
+ resolve from declaration identities, never from router responses.
92
+ `--catalog-samples 0` disables generated probes.
93
+
94
+ `--min-recall`, `--min-mrr`, `--max-p95-ms` fail with exit 1 when unmet.
95
+ `--baseline report.json --max-recall-drop 0` rejects recall regression against a
96
+ matching corpus/catalog/configuration; source hashes may differ for before/after.
97
+ `--allow-catalog-change` permits changed catalogs only with the same fixed corpus
98
+ and compatible resolved label mappings. Use `--catalog-samples 0` or a fixed
99
+ external corpus to compare changing catalogs; dynamic probes remain catalog specific.
100
+ Invalid input or unavailable catalog also fails. `--save` explicitly persists the
101
+ report through the validated owner SSSS ledger and native events; normal routing
102
+ receipts are untouched. Without it the result is returned only on stdout.
103
+
104
+ Built-in and validated custom adapters share one plugin. Use `dispatch` or
105
+ `route --execute` for agent work. `runtime <agent> ...` accepts supported maintenance
106
+ commands such as `codex login status`, `hermes gateway status`, and `dsh models`.
107
+ Manage gateway services through their owning plugins. `cli-agents` is an alias
108
+ for `meta-harness`.
6
109
 
7
110
  `total-recall cli-agents setup` connects all nine native instruction surfaces.
8
111
  The declared setup operation also runs during daemon-owned plugin refresh.
9
- Every dispatched agent receives a freshly checked Total Recall context, complete
10
- core help, installed plugin operations and composed commands. Setup failure or
11
- an unready context stops dispatch.
112
+ Every dispatched agent receives freshly assembled Total Recall task context and
113
+ a preflight receipt. The configured context budget is honored. Complete CLI,
114
+ plugin and composed-command inventories are supplied in a private temporary
115
+ reference file, keeping their full metadata out of the inline prompt. That file
116
+ is removed after execution. Setup failure or an unready context stops dispatch.
12
117
 
13
118
  `docs-refresh`, `docs-ensure`, `docs-status`, `docs-read` and `docs-search` manage
14
119
  downloaded official documentation rather than a list of links. Content is hashed,
15
120
  bounded and refreshed after 24 hours. Maintenance uses the existing Total Recall
16
- daemon's plugin task, refreshing one stale adapter per run. Failed pages remain
121
+ daemon's plugin task, attempting every stale adapter per run. Failed pages remain
17
122
  visible as failures and cannot certify complete coverage; successful cached
18
123
  content remains readable. `setup --node <recorded-node>` selects maintenance
19
- placement without creating a second scheduler.
124
+ placement for `maintenance`, `maintenance --models` and `alerts check` without
125
+ creating a second scheduler. `maintenance --harnesses` runs daily on the same node and updates each installed
126
+ harness with that harness's own update command; `--dry-run` reports what is waiting and changes
127
+ nothing. Hermes is asked first, because its update restarts the gateway; pi, cline, openclaw and DSH wait
128
+ while a copy is running. The Hermes and Cursor gates run through a launcher outside the Total Recall
129
+ package, so an update of Total Recall cannot leave their fail-closed hooks without a command. Each maintenance step reports its failures. A failed
130
+ setup or gate install does not prevent documentation refresh for other harnesses.
20
131
 
21
132
  Standalone Total Recall owner for CLI-agent discovery and explicit mesh command execution. Install with `total-recall plugin install <path-or-private-git-url>`. Installation rebuilds the plugin inventory, CLI library and connected instruction surfaces. No model account is created or selected automatically.
22
133
 
@@ -27,6 +138,21 @@ total-recall cli-agents inspect --node <recorded-node> --json
27
138
  total-recall cli-agents run-command --stdin --json < request.json
28
139
  ```
29
140
 
141
+ Check adoption without launching a model:
142
+
143
+ ```sh
144
+ total-recall meta-harness adoption --json
145
+ total-recall meta-harness adoption --node <recorded-node> --json
146
+ total-recall meta-harness adoption --all --json
147
+ ```
148
+
149
+ The report separates native login and hook configuration from recent hook
150
+ decisions and completed managed runs. Its run evidence is historical; use the
151
+ timestamps and last attempt to see whether an agent has since stopped working.
152
+ Native hook activity alone does not prove that an agent was launched through
153
+ Metaharness. A fleet report lists offline nodes, missing CLI access, and
154
+ installed versions that cannot provide adoption evidence.
155
+
30
156
  `request.json` selects one installed plugin operation, its literal arguments, a node and an agent:
31
157
 
32
158
  ```json
@@ -42,11 +168,29 @@ total-recall cli-agents run-command --stdin --json < request.json
42
168
  }
43
169
  ```
44
170
 
45
- For remote nodes, supply `execution.cwd` as an explicit absolute workspace. `agent: "direct"` runs the actual installed Total Recall CLI without a model. Remote access comes from recorded mesh entities and verified SSH configuration; unavailable nodes or binaries produce errors. Secrets are never accepted in an agent prompt. Existing account metadata is inspected without printing credentials or substituting provider API keys.
171
+ For remote nodes, supply `execution.cwd` as an explicit absolute workspace. `agent: "direct"` runs the actual installed Total Recall CLI without a model. A remote agent task enters the destination's installed Metaharness and records its receipt there. Remote access comes from recorded mesh entities and verified SSH configuration; unavailable nodes or binaries produce errors. Secrets are never accepted in an agent prompt. Existing account metadata is inspected without printing credentials or substituting provider API keys.
46
172
 
47
173
  The four permissions are strict boolean **command-effect admission controls**. They allow or deny the selected plugin command before dispatch. They are not a network policy or an OS sandbox for every action a model might propose. Supported adapter write modes are scoped through the vendor CLI; vendor approval and sandbox defaults stay enabled. The host's authenticated authorization still applies.
48
174
 
49
- A completed model turn is distinct from a completed plugin operation. Structured results return `commandExecutionVerified: false` for agent turns; only direct CLI execution returns a command exit receipt. Muse preserves its actual headless JSONL log and documented process exit status rather than treating session-protocol notifications as headless output. Do not infer working accounts, provider delivery or successful mutations from discovery or fixture tests.
175
+ The foreground `dispatch --stdin` request accepts `timeoutMs` from 1 to 540000, defaulting to 300000. Use the managed process or background execution commands for longer jobs. A Claude write request can include explicit `allowedTools` rules such as `["Bash(git status *)"]`. Native permission denials surface as failed dispatch receipts. Agent turn completion and command verification are separate fields.
176
+
177
+ A native login probe reads account metadata. A headless request can still fail if the provider rejects that login. Signed-out and expired Claude subscription sessions produce a failed receipt with `failureKind: "auth"`. Renew the subscription sign-in on the dispatch node and retry a scoped dispatch to verify execution. See [Claude Code authentication](https://code.claude.com/docs/en/iam#renew-an-expiring-login).
178
+
179
+ ### Included usage
180
+
181
+ Run `total-recall meta-harness included-enforce` to limit this node's managed dispatches to included usage. Use `included-status --probe --json` to see the Claude billing bindings and read current Codex allowance without an agent turn. Codex uses the built-in ChatGPT route and requires the signed-in plan to report no paid credit.
182
+
183
+ To approve OpenRouter on this node, run `total-recall meta-harness openrouter-bind <harness> <auth-key-name> --model <openrouter-model-id> --json`. Then select that harness by name when dispatching. Automatic routing continues to choose from the included subscription pool.
184
+
185
+ Run `total-recall harness dispatch codex "Run pwd and report the output" --json` to see the final reply and `toolResults`. Codex, Claude, DSH, Pi, Hermes and OpenClaw report native tool outcomes, available exit codes and bounded output. OpenClaw reports `toolEvidenceError` if its gateway cannot return the run's tool results. For background jobs, run `total-recall meta-harness process logs <job-id> --json` and read `toolResults` in the completion record. Adoption receipts retain the outcomes without the output text.
186
+
187
+ For Claude Max, sign in on the execution host with `claude auth login --claudeai`. Check that Usage credits are off in the account's Usage settings. Pass `{"organization":"<orgId from claude auth status>","usageCreditsEnabled":false}` to `included-bind-claude-plan --stdin`. Metaharness prefers the bound plan and checks the native login on every turn. Keep Usage credits off on that account. Claude manages that switch and enforces the plan limits. [Claude's subscription and SDK billing](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan)
188
+
189
+ Before using `included-bind-claude --stdin`, verify the Max credit grant, key hint and organization in Claude Console. Supply `keyName` (the Total Recall Auth entry), `organization`, the masked `keyHint`, `expiresAt`, `creditSource: "claude-max"`, `paidBalanceCents: 0` and false values for `autoReload`, `paymentMethod` and `invoiced`. The binding expires with the observed grant. Reverify after a key or billing change.
190
+
191
+ `usage-queue --json` lists deferred jobs. Use `usage-retry <id>` after the reported reset to run a replayable job through the same policy, or `usage-cancel <id>` to cancel it. Review a job marked `needsReview` in the original workspace before resubmitting it. A queued result has `queued: true` and a `queueId` and has not succeeded.
192
+
193
+ A completed model turn is distinct from a completed plugin operation. `commandExecutionVerified` requires a successful native shell result. Direct CLI execution returns the CLI process's exit receipt. Muse preserves its actual headless JSONL log and documented process exit status. Verify accounts, provider delivery and mutations through the real runtime.
50
194
 
51
195
  ## Primary contracts checked 2026-10-14
52
196
 
@@ -63,3 +207,105 @@ A completed model turn is distinct from a completed plugin operation. Structured
63
207
  | Hermes | [Official command reference](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/reference/cli-commands.md) |
64
208
 
65
209
  Cursor discovery uses `cursor-agent`; an ambiguous `agent` binary is not assumed to be Cursor. Missing installations are listed as unavailable. Unknown authentication requires explicit agent selection and remains unverified until a real run. Tests exercise literal stdin, bounded child-process cleanup, command admission, recorded SSH access, account checks and completed-result parsing. Run suites on the configured sanctioned test node.
210
+
211
+ ## Isolated task workflows
212
+
213
+ ```sh
214
+ total-recall meta-harness route "describe the task" --json
215
+ total-recall meta-harness route "describe the task" --execute --gate --background --json
216
+ total-recall meta-harness coordinate "describe the task" --mode pipeline --execute --gate --background --json
217
+ total-recall meta-harness review --staged --author <author-harness> --json
218
+ ```
219
+
220
+ Pipeline stages use isolated branches and independent verification. Council
221
+ assessments run concurrently; race candidates require a passing deterministic
222
+ gate. Failed stages stop subsequent work and clean failed checkouts. Deliverable
223
+ branches remain available for review and are never merged automatically. Empty
224
+ diffs return `NO_DIFF`; unreadable reviews never become approvals. Unknown login
225
+ state requires explicit `--allow-unknown-auth`.
226
+
227
+ Single-agent remote commands use recorded mesh access and an explicit absolute
228
+ workspace. Coordinated isolated work and gates reject unsupported remote placement;
229
+ remote worktree/gate transport remains an acceptance gap.
230
+
231
+ All agent dispatch paths, including agent-mediated plugin commands, append native
232
+ SSSS execution receipts. Actual process exit and finish metadata are distinct from
233
+ verification results; unavailable model metadata remains null. Thread operations
234
+ include list, show, create, update, close and delete, using native SSSS state.
235
+
236
+ Every review result is stored in an append-only SSSS ledger beside the thread
237
+ store. It retains the selected diff, commit, reviewer, verdict and disposition,
238
+ including failed reviews and `NO_DIFF`. `reviews --json` reads the ledger.
239
+ Deleting a thread does not remove its reviews. A failed ledger write returns
240
+ `ok: false` with `reviewStoreError` and the completed result.
241
+
242
+ `learn` reports scorecards, walls and proposals from run receipts. Routing reads
243
+ these receipts directly. The memory emit option has been removed.
244
+
245
+ `threads cleanup-fixtures --dry-run` previews the one-time cleanup of exact test
246
+ fixture titles. `threads cleanup-fixtures` applies it and stores the removed IDs,
247
+ titles, statuses, source test files and retained IDs in the same SSSS operation.
248
+ Real end-to-end job threads stay in place, including failed attempts.
249
+
250
+ Custom adapter declarations preserve scoped credentials, optional authentication
251
+ probes and HTTPS documentation URLs. IDs and paths reject traversal and symbolic
252
+ links. Credentials reach only the declaring runner through the auth store. A
253
+ changed documentation URL invalidates old cache freshness.
254
+
255
+ ## Hooks in each harness
256
+
257
+ This plugin owns the adapter for each harness: how a hook call is read, how an answer is written, and where the hook is installed. Total Recall core owns the decision. It warns by default. `total-recall preflight mode` shows or changes that, and shows whether a warning can reach the agent in each harness.
258
+
259
+ `total-recall preflight install --all` installs the hook for every harness present, and maintenance repeats it. `preflight verify` reports `not wired` for Cline, which runs hooks only from plugin code that has not been built. OpenClaw also runs hooks only from plugin code, so this plugin ships one in `src/gate-adapters/openclaw-plugin/`. The installer copies it to `~/.openclaw/total-recall-gate`, registers it through OpenClaw's own CLI, and reloads it in the running gateway. A written file is not proof that a harness runs it, so check `preflight report` for decisions from a real session.
260
+
261
+ Codex skips a new hook until you trust it in `/hooks`. Native subagents are never gated.
262
+
263
+ See `docs/guides/preflight-gate.md` in Total Recall for the full table.
264
+
265
+ ## Verification status
266
+
267
+ The active five-file suite and evidence live in
268
+ `docs/projects/in-progress/META_HARNESS_UNIFICATION/`. Completion requires current
269
+ owner/core suites, plugin/scaffold validation, real dashboard inspection and
270
+ recorded acceptance evidence. Fixture tests do not certify live accounts, remote
271
+ execution or recurring maintenance. The operator requires completing verification
272
+ before Metaharness runs task work.
273
+
274
+ Cloudroom setup material remains under `cloudroom/`. Its plugin implementation
275
+ follows this foundation and requires its own current audit and plan.
276
+
277
+ ### Installed and standalone verification
278
+
279
+ Use the installed plugin for CLI execution and maintenance. The repository has a pure planning capability under `capability/`. The current manifest does not declare it for vendoring. See the [Metaharness tracker](docs/projects/in-progress/META_HARNESS_UNIFICATION/META_HARNESS_UNIFICATION_PROJECT_TRACKER.md) for current package, execution and hook acceptance.
280
+
281
+ ## Default Chat
282
+
283
+ Open **Metaharness** from the dashboard's Plugins folder to select and save a
284
+ default harness. The Chat drawer uses that default with the selected brains.
285
+ Customize the native Home in `DESIGN.md`. The owner blocks in `ui/chunks/`
286
+ cover execution, routing, usage, documentation, maintenance and run evidence.
287
+
288
+ `total-recall meta-harness chat-default codex --json` sets the host's default
289
+ Chat harness. Choose an adapter from the catalog or from the choices returned
290
+ by `total-recall meta-harness chat-target --json`. The default applies to every
291
+ brain selection.
292
+
293
+ For example, `total-recall meta-harness chat-target --brains global,project:docs --json`
294
+ returns the chosen harness and draft context for those two brain IDs. A Codex
295
+ target opens a native draft that the operator can review before sending. Other
296
+ harnesses can use an explicit HTTPS launch URL configured with `--url` and
297
+ copyable context. Use a launch URL without embedded credentials, a query, or a
298
+ fragment. Omitting `--url` selects the adapter's built-in handoff, if available.
299
+
300
+ ## Using this from an agent
301
+
302
+ Send work here to run it in another agent harness, or to find out which harness should take it. Native subagents are separate and never need this.
303
+
304
+ ```bash
305
+ total-recall meta-harness route "<task>" --json
306
+ total-recall meta-harness route "<task>" --execute --json
307
+ total-recall meta-harness status
308
+ total-recall meta-harness docs-search --agent <agent> --query "<terms>"
309
+ ```
310
+
311
+ Raw commands this plugin owns: direct harness runs such as `codex exec`, `claude -p`, `agy -p` and `dsh --profile headless`. It also declares the router, so the gate points agents at `route` once per task.
@@ -1,4 +1,4 @@
1
- # Meta Harness Capability Brick
1
+ # Metaharness Capability Brick
2
2
 
3
3
  A zero-dependency, host-free pure ES module providing universal agent harness discovery, two-stage complexity classification, cost-vs-frontier routing, gate cascade evaluation, and execution envelope construction.
4
4
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Meta Harness Capability Brick
2
+ * Metaharness Capability Brick
3
3
  * Zero-dependency, host-free pure ES module for agent routing,
4
4
  * complexity classification, adapter discovery, gate cascades, and SSSS receipts.
5
5
  * Works identically in any standalone app, edge device, workstation, or cloud environment.
@@ -34,7 +34,7 @@ export const ADAPTER_CATALOG = {
34
34
  contextLimit: 200000,
35
35
  modalities: ['text', 'code'],
36
36
  features: ['subagents', 'mcp', 'headless', 'compact', 'plan_mode'],
37
- flags: { prompt: '-p', nonInteractive: '--permission-mode acceptEdits', planMode: '--permission-mode plan', output: '--output-format json' }
37
+ flags: { prompt: '-p', nonInteractive: '--permission-mode bypassPermissions', planMode: '--permission-mode plan', output: '--output-format json' }
38
38
  },
39
39
  codex: {
40
40
  id: 'codex',
@@ -49,7 +49,7 @@ export const ADAPTER_CATALOG = {
49
49
  contextLimit: 128000,
50
50
  modalities: ['text', 'code'],
51
51
  features: ['mcp', 'headless', 'streaming'],
52
- flags: { prompt: 'exec', nonInteractive: '--sandbox workspace-write', planMode: '--sandbox read-only', output: '--json' }
52
+ flags: { prompt: 'exec', nonInteractive: '--sandbox danger-full-access', planMode: '--sandbox read-only', output: '--json' }
53
53
  },
54
54
  grok: {
55
55
  id: 'grok',
@@ -86,10 +86,10 @@ export const ADAPTER_CATALOG = {
86
86
  name: 'Hermes Agent Runtime',
87
87
  bin: 'hermes',
88
88
  family: 'nous-open-weights',
89
- tier: 'local',
90
- billingModel: 'local',
89
+ tier: 'budget',
90
+ billingModel: 'metered',
91
91
  speed: 'fast',
92
- costScore: 1,
92
+ costScore: 3,
93
93
  qualityScore: 8.2,
94
94
  contextLimit: 65536,
95
95
  modalities: ['text', 'code'],
@@ -256,15 +256,27 @@ export function classifyTaskComplexity(taskDescription, options = {}) {
256
256
  score += 30;
257
257
  factors.push('security-sensitive');
258
258
  }
259
- if (/multi-file|across (all|every)|entire (repo|fleet)|worktree/.test(text)) {
259
+ if (/multi-file|across (all|every)|entire (repo|fleet)|worktree|every (mesh )?(node|machine|host|repo)|(all|several|multiple) (repos|repositories|nodes|machines)|\bmesh\b|\bfleet\b/.test(text)) {
260
260
  score += 25;
261
261
  factors.push('broad-blast-radius');
262
262
  }
263
+ if (/\bproduction\b|\bdeploy|roll ?out|\bdroplet\b|\bcore\b|\bmigration\b|\brelease\b/.test(text)) {
264
+ score += 15;
265
+ factors.push('production-or-core');
266
+ }
263
267
  if (/benchmark|telemetry|concurrency|race condition|memory leak/.test(text)) {
264
268
  score += 20;
265
269
  factors.push('complex-debugging');
266
270
  }
267
- if (/typo|rename|docstring|comment|formatting|readme|lint fix/.test(text)) {
271
+ // Several distinct pieces of work (comma or semicolon separated clauses, phases) are not one edit.
272
+ const clauses = text.split(/[,;]|\band then\b|\bthen\b|\bplus\b/).filter(part => part.trim().split(/\s+/).length >= 3).length;
273
+ if (clauses >= 4 || /phases? \d+ (and|&) \d+/.test(text)) {
274
+ score += 15;
275
+ factors.push('multi-part-work');
276
+ }
277
+ // An easy-sounding word ("rename", "readme") lowers the score only when nothing else carries risk:
278
+ // a rename across repositories or a credential change is not a typo fix.
279
+ if (/typo|rename|docstring|comment|formatting|readme|lint fix/.test(text) && factors.length === 0) {
268
280
  score -= 30;
269
281
  factors.push('low-complexity-edit');
270
282
  }
@@ -341,7 +353,9 @@ function resolveAdapterEntry(h, catalog = ADAPTER_CATALOG) {
341
353
  export function selectOptimalHarness(taskDescription, availableHarnesses = [], quotaStatus = {}, options = {}) {
342
354
  const catalog = options.catalog || ADAPTER_CATALOG;
343
355
  const empiricalScorecard = options.empiricalScorecard || {};
344
- const complexity = classifyTaskComplexity(taskDescription, options);
356
+ const base = classifyTaskComplexity(taskDescription, options);
357
+ // A caller with a better classifier (such as a typed decision) may supply the tier.
358
+ const complexity = options.tierOverride ? { ...base, tier: options.tierOverride } : base;
345
359
 
346
360
  const pool = availableHarnesses.length > 0
347
361
  ? availableHarnesses.map(h => resolveAdapterEntry(h, catalog))
@@ -357,7 +371,7 @@ export function selectOptimalHarness(taskDescription, availableHarnesses = [], q
357
371
  return true;
358
372
  });
359
373
 
360
- const candidates = viable.length > 0 ? viable : pool;
374
+ const candidates = viable;
361
375
  const isFrontier = complexity.tier === 'frontier';
362
376
  const isLocal = complexity.tier === 'local';
363
377
 
@@ -378,6 +392,10 @@ export function selectOptimalHarness(taskDescription, availableHarnesses = [], q
378
392
  if (q && q.status === 'needs_auth') {
379
393
  rawUtility -= 6.0;
380
394
  }
395
+ // No login probe exists for this harness, so it ranks below one verified as signed in
396
+ if (q && q.status === 'unverified') {
397
+ rawUtility -= 1.0;
398
+ }
381
399
 
382
400
  // Factor in empirical local pass rate if at least 2 runs recorded
383
401
  const emp = empiricalScorecard[h.id] || empiricalScorecard[h.bin];
@@ -397,7 +415,7 @@ export function selectOptimalHarness(taskDescription, availableHarnesses = [], q
397
415
  }).sort((a, b) => b.utility - a.utility);
398
416
 
399
417
  return {
400
- selected: ranked[0]?.harness || pool[0]?.id || pool[0]?.bin || null,
418
+ selected: ranked[0]?.harness || null,
401
419
  complexity,
402
420
  candidates: ranked
403
421
  };
@@ -495,6 +513,8 @@ export function evaluateGateCascade(currentHarness, gateResults = {}, availableH
495
513
  export function computeEmpiricalScorecard(historyRuns = []) {
496
514
  const summary = {};
497
515
  for (const run of historyRuns) {
516
+ // Quota walls, sign-in gaps and process failures say nothing about the harness's work.
517
+ if (['quota', 'auth', 'process', 'not-ready'].includes(run.failureKind)) continue;
498
518
  const h = run.harness || 'unknown';
499
519
  if (!summary[h]) {
500
520
  summary[h] = { total: 0, passed: 0, failed: 0, totalDurationMs: 0, passRate: 0, avgDurationMs: 0 };
@@ -518,7 +538,126 @@ export function computeEmpiricalScorecard(historyRuns = []) {
518
538
  }
519
539
 
520
540
  /**
521
- * Meta Harness Brick Factory
541
+ * Synthesize raw subagent output through a strict "One-Way Valve" filter.
542
+ * Compresses verbose exploratory dumps, file trees, and search outputs into
543
+ * a dense, structured context digest bounded by maxChars (default 2000 chars, ~500 tokens).
544
+ * Prevents downstream context rot across multi-step orchestration.
545
+ */
546
+ export function synthesizeOneWayValve(rawOutput, options = {}) {
547
+ const maxChars = options.maxChars || 2000;
548
+ const text = String(rawOutput || '').trim();
549
+ if (!text) return 'No findings reported.';
550
+
551
+ // Extract file paths, line references, and key findings
552
+ const fileLines = text.split('\n');
553
+ const filesFound = new Set();
554
+ const keyObservations = [];
555
+
556
+ for (const line of fileLines) {
557
+ const trimmed = line.trim();
558
+ if (!trimmed) continue;
559
+ // Match potential file paths: e.g. src/foo.js, /path/to/file.mjs:42
560
+ const pathMatch = trimmed.match(/(?:[a-zA-Z0-9_-]+\/)+[a-zA-Z0-9._-]+\.[a-zA-Z0-9]+/);
561
+ if (pathMatch) {
562
+ filesFound.add(pathMatch[0]);
563
+ }
564
+ if (/^(found|note|warning|error|exports|function|class|symbol|defined|status|schema|todo|fixme)/i.test(trimmed) || trimmed.startsWith('- ') || trimmed.startsWith('* ')) {
565
+ if (keyObservations.length < 15) {
566
+ keyObservations.push(trimmed.replace(/^[-*]\s*/, ''));
567
+ }
568
+ }
569
+ }
570
+
571
+ const parts = [];
572
+ if (filesFound.size > 0) {
573
+ parts.push(`Relevant Files: ${Array.from(filesFound).slice(0, 10).join(', ')}`);
574
+ }
575
+ if (keyObservations.length > 0) {
576
+ parts.push(`Key Findings:\n- ${keyObservations.join('\n- ')}`);
577
+ }
578
+
579
+ let digest = parts.join('\n\n');
580
+ if (!digest || digest.length < 50) {
581
+ digest = text.length > maxChars ? `${text.slice(0, maxChars - 20)}... [truncated]` : text;
582
+ } else if (digest.length > maxChars) {
583
+ digest = `${digest.slice(0, maxChars - 20)}... [truncated]`;
584
+ }
585
+
586
+ return digest;
587
+ }
588
+
589
+ /**
590
+ * Decompose a multi-step task into specialized subagent stages:
591
+ * 1. Explorer (read-only codebase sweep, zero-cost / local preference)
592
+ * 2. Architect (modular design & file contracts, frontier preference)
593
+ * 3. Implementer (code authoring & unit test generation)
594
+ * 4. Verifier (adversarial code audit in isolated worktree, distinct model family)
595
+ */
596
+ export function decomposeTask(taskDescription, options = {}) {
597
+ const task = String(taskDescription || '').trim();
598
+ if (!task) throw new Error('Task description is required for decomposition');
599
+
600
+ const complexity = classifyTaskComplexity(task, options);
601
+ const catalog = options.catalog || ADAPTER_CATALOG;
602
+ const available = options.availableHarnesses?.length ? options.availableHarnesses : Object.keys(catalog);
603
+ const entry = id => catalog[id] || {};
604
+ const byQuality = [...available].sort((a, b) => (entry(b).qualityScore ?? 0) - (entry(a).qualityScore ?? 0));
605
+ const byCost = [...available].sort((a, b) => (entry(a).costScore ?? 99) - (entry(b).costScore ?? 99));
606
+
607
+ // Explorer takes the cheapest harness, Architect the strongest
608
+ const explorerHarness = byCost[0] || null;
609
+ const architectHarness = byQuality[0] || null;
610
+ const implementerHarness = byQuality.find(id => id !== architectHarness && id !== explorerHarness) || architectHarness;
611
+
612
+ // Verifier must come from a different model family. Without one, it stays null rather than grading its own work.
613
+ const verifierHarness = byQuality.find(id => entry(id).family && entry(id).family !== entry(implementerHarness).family) || null;
614
+ const tierOf = id => entry(id).tier || null;
615
+
616
+ return {
617
+ task,
618
+ complexity,
619
+ crossFamilyVerification: Boolean(verifierHarness),
620
+ stages: [
621
+ {
622
+ id: 'stage-1-explore',
623
+ role: 'Explorer',
624
+ preferredHarness: explorerHarness,
625
+ tier: tierOf(explorerHarness),
626
+ permissions: { read: true, write: false },
627
+ objective: 'Sweep workspace, locate relevant files, inspect interfaces, and read official documentation without context bloat.',
628
+ valveFilter: true
629
+ },
630
+ {
631
+ id: 'stage-2-architect',
632
+ role: 'Architect',
633
+ preferredHarness: architectHarness,
634
+ tier: tierOf(architectHarness),
635
+ permissions: { read: true, write: false },
636
+ objective: 'Synthesize Explorer digest into modular architectural blueprint, interface contracts, and verification gates.'
637
+ },
638
+ {
639
+ id: 'stage-3-implement',
640
+ role: 'Implementer',
641
+ preferredHarness: implementerHarness,
642
+ tier: tierOf(implementerHarness),
643
+ permissions: { read: true, write: true },
644
+ objective: 'Author production implementation files and test cases strictly following the Architectural blueprint.'
645
+ },
646
+ {
647
+ id: 'stage-4-verify',
648
+ role: 'Verifier',
649
+ preferredHarness: verifierHarness,
650
+ tier: tierOf(verifierHarness),
651
+ worktreeIsolated: true,
652
+ permissions: { read: true, write: false },
653
+ objective: 'Adversarial code review and quality gate verification executed in an isolated Git worktree with a distinct model family.'
654
+ }
655
+ ]
656
+ };
657
+ }
658
+
659
+ /**
660
+ * Metaharness Brick Factory
522
661
  */
523
662
  export function createMetaHarness(customAdapters = {}) {
524
663
  const mergedAdapters = { ...ADAPTER_CATALOG, ...customAdapters };
@@ -529,6 +668,8 @@ export function createMetaHarness(customAdapters = {}) {
529
668
  select: (task, available, quotas, opts) => selectOptimalHarness(task, available, quotas, { ...opts, catalog: mergedAdapters }),
530
669
  buildEnvelope: (task, opts) => buildBootstrapEnvelope(task, opts),
531
670
  evaluateCascade: (harness, gates, available) => evaluateGateCascade(harness, gates, available),
532
- scorecard: (runs) => computeEmpiricalScorecard(runs)
671
+ scorecard: (runs) => computeEmpiricalScorecard(runs),
672
+ decompose: (task, opts) => decomposeTask(task, { ...opts, catalog: mergedAdapters }),
673
+ valve: (raw, opts) => synthesizeOneWayValve(raw, opts)
533
674
  };
534
675
  }