taskforce-loop-engineering 0.15.21 → 0.16.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 (40) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/MIGRATING.md +80 -0
  3. package/README.md +37 -8
  4. package/bin/loop-engineering.mjs +142 -114
  5. package/docs/architecture.md +3 -2
  6. package/docs/human-gate-command.md +1 -1
  7. package/docs/operator-dashboard.md +16 -5
  8. package/docs/operator-workspace-project.md +2 -2
  9. package/docs/production-trust-contract.md +9 -2
  10. package/docs/transactional-kernel-and-goal-api.md +3 -1
  11. package/lib/action-reservations.mjs +21 -23
  12. package/lib/core.mjs +643 -109
  13. package/lib/durable-journal.mjs +23 -6
  14. package/lib/execution-ledger.mjs +4 -4
  15. package/lib/file-mutex.mjs +102 -0
  16. package/lib/human-gate-channel-adapter.mjs +4 -2
  17. package/lib/human-gate-command.mjs +5 -3
  18. package/lib/operator-dashboard.mjs +72 -10
  19. package/lib/production-evidence.mjs +37 -15
  20. package/lib/quota-runtime-decision.mjs +11 -6
  21. package/lib/redaction.mjs +34 -0
  22. package/lib/todo-control-plane.mjs +12 -16
  23. package/lib/transactional-state-kernel.mjs +96 -18
  24. package/package.json +2 -3
  25. package/scripts/dashboard-autostart-install.mjs +33 -8
  26. package/scripts/dashboard-autostart-self-test.mjs +12 -3
  27. package/scripts/final-judgement-self-test.mjs +21 -0
  28. package/scripts/hermes-install-self-test.mjs +8 -1
  29. package/scripts/hermes-install.mjs +29 -8
  30. package/scripts/hermes-smoke.mjs +2 -1
  31. package/scripts/human-gate-command-self-test.mjs +34 -5
  32. package/scripts/install-shared.mjs +61 -0
  33. package/scripts/openclaw-install-self-test.mjs +47 -1
  34. package/scripts/openclaw-install.mjs +42 -17
  35. package/scripts/openclaw-manage.mjs +22 -3
  36. package/scripts/openclaw-smoke.mjs +2 -1
  37. package/scripts/project-relay-self-test.mjs +145 -1
  38. package/scripts/run-loop-cron.sh +22 -7
  39. package/scripts/safety-regression-self-test.mjs +349 -0
  40. package/skills/taskforce-loop-engineering/SKILL.md +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,60 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.16.0 - 2026-10-10
6
+
7
+ ### Upgrade notes
8
+
9
+ This release changes several behaviours on purpose; see `MIGRATING.md`.
10
+
11
+ - Dashboard Human Gate buttons need an operator token: run `loop-engineering dashboard-operator-add --actor-id <id>` and enter the printed token in the dashboard. Without a registered operator the dashboard is browse-only.
12
+ - Chat replies to a gate card must include the generation, e.g. `/approve gate_x@2`; cards show the exact `reply_command`.
13
+ - Patch exports made by earlier versions must be re-exported before `code-worktree-cleanup` removes a dirty worktree.
14
+ - CLI flags reject missing values and non-integer numbers (`--timeout-ms 10m` is now an error, not 10 ms).
15
+ - Evidence `passed` is recomputed from thresholds, scenarios and compatibility; set `LOOP_EVIDENCE_HMAC_KEY` for a tamper-resistant seal.
16
+ - Re-run `loop-engineering-openclaw-manage --action upgrade --confirm-upgrade` (Hermes: rerun the installer with `--confirm-install --force`) so generated workspace files and units pick up the installer fixes.
17
+
18
+ ### Security and data loss
19
+
20
+ - Dashboard Human Gate commands now require an operator token (`dashboard-operator-add` / `dashboard-operator-remove`); the acting identity comes from the token instead of the request body, requests must be `application/json`, and loopback dashboards reject foreign `Host` headers (DNS rebinding). Gate evidence served by `/api/v1/gates` is redacted, and redaction now recognises camelCase keys such as `accessToken` and `Authorization` while keeping `fencing_token` visible. Without a registered operator, dashboard gate commands are disabled.
21
+ - Reject task ids that are not plain identifiers in every `--task-id` lookup, so `queue-cancel`, `queue-requeue` and review decisions cannot move or delete files outside the queue.
22
+ - `code-worktree-export` writes the complete patch, including untracked files as new-file diffs, instead of the last 60,000 characters; cleanup force-removes a dirty worktree only when its export manifest is complete and the worktree still matches it. Older exports must be re-exported before cleanup.
23
+ - Keep Human Gates for tasks outside any project waiting instead of cancelling them as `project_not_found` on the next status or run.
24
+
25
+ ### Exactly-once execution and crash safety
26
+
27
+ - Stop classifying successful (exit 0) dispatches as recoverable runtime interruptions when the answer merely mentions free-text failure vocabulary such as "rate limit" or "connection reset"; only structured runtime trailers may override a zero exit, so completed work is no longer replayed.
28
+ - Exactly-once queue execution: the runner renews its queue lease while a task runs, stale-lock reclaim is serialized so two runners cannot both take the lock, and a stale active copy of a task that already finished is quarantined instead of re-executed. Orphan recovery stops after `retry.orphanRecoveryMaxAttempts` (default 3) and moves the task to `failed/` as `orphan_recovery_exhausted`.
29
+ - Canceling, parking or requeueing an active task now stops its dispatcher, and the runner no longer writes a second copy of a task an operator moved; a requeued or resumed task ignores supersede markers written before it was restarted. Amending a task that has just finished no longer recreates it in `active/`.
30
+ - Queue files are written atomically; an unreadable lock is reclaimed after a grace period and unreadable queued or active task files are moved to `quarantine/` instead of blocking the queue. Concurrent enqueues with the same title get distinct ids instead of overwriting each other.
31
+ - Action reservations, the todo control plane, the execution ledger and the durable journal share a token-owned file mutex (`lib/file-mutex.mjs`): stale locks are reclaimed under a second guard and only the owner releases a lock, so concurrent waiters can no longer both enter and grant one idempotency key to two requests. A settle or release reported after the claim's lease expired now becomes an `unknown` outcome for reconciliation, keeping the worker's evidence.
32
+ - `TransactionalStateKernel` persists issued fencing tokens and rejects released or superseded leases; `replayEffect` holds the lease across execute and commit and records an intent first, so an effect runs at most once even across crashes (`reconcileEffect` settles an interrupted one).
33
+ - `DurableJournal` serializes appends and discards a torn final line before appending, so a crash mid-write or concurrent appends no longer corrupt the chain permanently.
34
+ - Spawn failures (missing working directory, NUL bytes) become failed commands instead of crashing the runner, and the completion notification strips NUL bytes and records its result.
35
+ - Decode command output as UTF-8 across chunk boundaries so multi-byte text in patches and logs is not corrupted.
36
+ - Requeued worktree tasks continue in their existing branch and worktree instead of failing with "branch already exists", so runtime recovery and project continuation work in code queues.
37
+ - A handoff packet expires when its todo is recovered, so a stale accept can no longer reclaim a recovered or completed todo; the quota ledger serializes spend so concurrent slices are not lost.
38
+
39
+ ### Project relay
40
+
41
+ - Let relay status reconciliation follow a relay task's revision lineage, so an item accepted after a revision round is completed instead of stalling the relay; independent duplicate lineages and lineages without exactly one accepted round still fail closed.
42
+ - Run scheduler relay maintenance only while holding the queue lock with no active task, and abandon a reconciliation write when the backlog changed after it was read, so concurrent agent edits are never overwritten.
43
+ - Retry a relay that was skipped because the queue was busy on a later idle scheduler tick, under the same fail-closed checks, only when the most recently enqueued backlog-bound task is completed and accepted, so a failed or canceled relay task still stops the chain; report it as `projectRelay` with `relayMaintenance` status.
44
+ - Skip the scheduler's relay scan when a cheap fingerprint of queue state and project relay files is unchanged, with an hourly full pass for in-place edits, and read each task file once per pass; an unreadable task file reports `relayMaintenance: "error"` instead of failing the tick.
45
+ - Treat duplicate or malformed backlog rows as unusable for relay predecessors, dependencies, and candidates instead of letting the last duplicate win.
46
+
47
+ ### Installers
48
+
49
+ - systemd units now write `WorkingDirectory=` as the literal path (systemd does not decode escapes there), so scheduler and dashboard services start for workspaces whose path contains spaces or non-ASCII characters; the dashboard installer escapes `ExecStart=` by UTF-8 byte like the others. Installers, manage and smoke scripts resolve their own files with `fileURLToPath`, so a package installed under a path with spaces works.
50
+ - the OpenClaw and Hermes manifests are written before the scheduler is enabled, so a failed install is still uninstallable; reinstalling replaces an unchanged managed `AGENTS.md` block (a hand-edited one only with `--force`) and keeps the manifest consistent, so language or queue changes no longer block uninstall. OpenClaw uninstall stops and removes the dashboard service and gateway drop-ins it installed, upgrade keeps the recorded dashboard listen mode, and installers no longer repoint a dashboard that serves another workspace (`dashboard-autostart-install --force` overrides).
51
+
52
+ ### Other fixes
53
+
54
+ - Project inference matches project names as whole tokens ("ui" no longer matches "build"), `json-value` checks compare JSON independent of key order, and applying the same revision plan (or `queue-revision-next`) twice no longer enqueues a duplicate revision without `--force`.
55
+ - Redaction is shared (`lib/redaction.mjs`) by evidence, execution ledger and dashboard: camelCase credentials are redacted, `fencing_token` and token counters stay visible. Evidence sealing recomputes `passed` from thresholds, scenarios and compatibility, and supports an HMAC seal via `LOOP_EVIDENCE_HMAC_KEY`; the unkeyed SHA-256 seal is documented as corruption detection only.
56
+ - Card-bound chat replies must name the generation they answer (`/approve gate_x@2`); each card button lists its `reply_command`, and a reply without one returns `generation_required` instead of always failing as stale.
57
+ - CLI flags now reject a missing value, a value that is the next flag, and non-integer numbers (`--timeout-ms 10m`). `run-loop-cron.sh` logs and alerts on an unreadable config and accepts an alert command with arguments. Patch headers with git-quoted non-ASCII paths are parsed, so the dirty-target check covers them. Removed the nonexistent `main` entry from `package.json`; CI runs adapter, production-trust and pack checks instead of repeating the competitive check.
58
+
5
59
  ## 0.15.21 - 2026-09-30
6
60
 
7
61
  - Add opt-in reconciliation of mutable project relay backlog statuses against unique accepted done-task evidence, while preserving fail-closed project, backlog, and task-binding checks.
package/MIGRATING.md CHANGED
@@ -1,3 +1,83 @@
1
+ # Migrating to Taskforce Loop Engineering 0.16.0
2
+
3
+ 0.16.0 is a correctness and security release. No artifact rewrite is needed:
4
+ queue, project, reservation, journal and kernel files written by 0.15.x are read
5
+ in place. A few behaviours change on purpose.
6
+
7
+ ## Upgrade steps
8
+
9
+ ```bash
10
+ npm install -g taskforce-loop-engineering@0.16.0
11
+ # OpenClaw workspaces
12
+ loop-engineering-openclaw-manage --root /path/to/workspace --action upgrade-plan
13
+ loop-engineering-openclaw-manage --root /path/to/workspace --action upgrade --confirm-upgrade
14
+ # Hermes workspaces
15
+ loop-engineering-hermes-install --root /path/to/workspace --confirm-install --force
16
+ ```
17
+
18
+ Upgrading regenerates the scheduler unit with a literal `WorkingDirectory=`, so
19
+ workspaces whose path contains spaces or non-ASCII characters start correctly.
20
+ An upgrade keeps the recorded `--dashboard-listen` mode. If the per-user
21
+ dashboard already serves another workspace, the installer now leaves it alone
22
+ and reports `dashboardAutostart.skipped`.
23
+
24
+ ## Dashboard Human Gate decisions need an operator token
25
+
26
+ `POST /api/v1/gate-commands` previously accepted any caller and trusted the
27
+ `actor_id` in the request. It now requires a registered operator:
28
+
29
+ ```bash
30
+ loop-engineering dashboard-operator-add --actor-id alice --root /path/to/workspace
31
+ ```
32
+
33
+ Enter the printed token in the dashboard's "Operator token" field (it is shown
34
+ once; only its SHA-256 digest is stored in `configs/loops/dashboard-operators.json`).
35
+ The gate's `allowed_actors` must contain that actor id. Remove access with
36
+ `dashboard-operator-remove`. Until an operator exists, the dashboard is
37
+ browse-only. Loopback dashboards also reject requests whose `Host` is not
38
+ `127.0.0.1`, `localhost` or `[::1]`; add other names with `--allowed-host`.
39
+
40
+ ## Chat replies name the gate generation
41
+
42
+ Card-bound replies must now be `/approve gate_<id>@<generation>`,
43
+ `/reject gate_<id>@<generation>` or
44
+ `/request_revision gate_<id>@<generation> <reason>`. Cards include the exact
45
+ `reply_command` for each button. A reply without a generation returns
46
+ `generation_required` instead of being applied to whatever generation is
47
+ current.
48
+
49
+ ## Code worktree cleanup needs a complete export
50
+
51
+ `code-worktree-export` now writes the full patch including untracked files and
52
+ records `complete` and `contentSha256` in its manifest. Cleanup of a dirty
53
+ worktree refuses exports from earlier versions
54
+ (`dirty_export_incomplete_reexport_required`) and worktrees changed after the
55
+ export (`dirty_worktree_changed_since_export`). Re-export with `--force`, then
56
+ clean up.
57
+
58
+ ## Stricter CLI values
59
+
60
+ A flag followed by nothing or by another flag (`--title --task x`) and
61
+ non-integer numeric values (`--timeout-ms 10m`, `--limit abc`) are now errors.
62
+ Scripts that relied on the old lenient parsing must pass explicit values.
63
+
64
+ ## Evidence and redaction
65
+
66
+ `sealEvidence` recomputes `passed` from thresholds, scenarios and compatibility,
67
+ so a report whose metrics fail cannot be sealed as passed. The default seal is a
68
+ plain SHA-256 digest that detects corruption only; set `LOOP_EVIDENCE_HMAC_KEY`
69
+ (or pass `{ key }`) for an HMAC seal, and supply the same key when verifying.
70
+ Redaction now also covers camelCase credentials such as `accessToken` and
71
+ `Authorization`, while `fencing_token` and token counters stay visible.
72
+
73
+ ## Queue runtime
74
+
75
+ The runner renews its lease, so `leaseMs` no longer needs headroom for the
76
+ longest possible run. Orphaned active tasks are recovered at most
77
+ `retry.orphanRecoveryMaxAttempts` times (default 3) and then moved to `failed/`
78
+ as `orphan_recovery_exhausted`. Unreadable task files are moved to
79
+ `runtime/loops/<queue>/quarantine/` for inspection instead of blocking the queue.
80
+
1
81
  # Migrating to Taskforce Loop Engineering 0.12.0
2
82
 
3
83
  ## Goal API and primary CLI
package/README.md CHANGED
@@ -37,9 +37,9 @@ offline and fixture-only: it performs no model call or external side effect.
37
37
  Copy `templates/github-production-trust.yml` into `.github/workflows/` only
38
38
  when publication is separately approved.
39
39
 
40
- ## Read-only operator dashboard (P3)
40
+ ## Operator dashboard (P3)
41
41
 
42
- Version 0.12 adds a dependency-free operator projection over projects, queues, P0 gates, P1 action reservations and P2 typed todo ownership. Use `dashboard-inspect`, `dashboard-health`, `dashboard-export`, or `dashboard-serve`. Gateway autostart installation supports local-only and Tailnet-only listening without binding all interfaces. See [docs/operator-dashboard.md](docs/operator-dashboard.md) for API, security and schema details.
42
+ Version 0.12 adds a dependency-free operator projection over projects, queues, P0 gates, P1 action reservations and P2 typed todo ownership. Use `dashboard-inspect`, `dashboard-health`, `dashboard-export`, or `dashboard-serve`. Gateway autostart installation supports local-only and Tailnet-only listening without binding all interfaces. Human Gate decisions from the dashboard require an operator token from `dashboard-operator-add`. See [docs/operator-dashboard.md](docs/operator-dashboard.md) for API, security and schema details.
43
43
 
44
44
  The consolidated P0-P3 local release contract and evidence ledger are recorded in [docs/release-0.12-acceptance.md](docs/release-0.12-acceptance.md). Publishing, tagging, pushing, and production installation remain separate release actions.
45
45
 
@@ -223,6 +223,16 @@ older managed integrations. Uninstall first disables the timer, then removes
223
223
  only clean managed files, units, and that exact instructions block; queue
224
224
  runtime is explicitly retained.
225
225
 
226
+ The manifest is written before the scheduler is enabled, so an install that
227
+ fails part-way can still be uninstalled. Reinstalling (for example with another
228
+ `--language` or `--queue`) replaces the managed `AGENTS.md` block when it is
229
+ unchanged since the last install; a hand-edited block is only replaced with
230
+ `--force`. The dashboard service is shared by every workspace of a user: an
231
+ install leaves a dashboard that serves another workspace untouched and reports
232
+ it as skipped, uninstall stops and removes the dashboard only when it is still
233
+ the one this installation wrote, and upgrade keeps the recorded
234
+ `--dashboard-listen` mode.
235
+
226
236
  ## Hermes Agent conversation installer
227
237
 
228
238
  Hermes Agent is supported through a native dispatcher and notifier while the
@@ -439,16 +449,33 @@ must be readable. The runner enqueues at most one
439
449
  dependency-ready item after the accepted task; duplicate markers, a busy
440
450
  queue, human gates, missing authority, or accepted project terminal state stop
441
451
  the relay. The existing scheduler executes that queued item on its next tick.
452
+ If the queue was busy when the task was accepted, a later non-plan-only
453
+ scheduler tick that holds the queue lock with no active task retries the relay,
454
+ under the same checks, when the most recently enqueued backlog-bound task is
455
+ completed and accepted. A failed or canceled relay task stops the chain until a
456
+ person acts on it.
457
+ To keep idle ticks cheap, this relay maintenance runs a full scan only when a
458
+ fingerprint changes: task file names in each queue state directory, the
459
+ project spec, and the size and modification time of its backlog and acceptance
460
+ files. A full pass also runs at least hourly (`relayMaintenanceFullIntervalMs`)
461
+ to pick up in-place edits the fingerprint cannot see, such as a rewritten final
462
+ judgement; skipping a pass can only delay a relay, never act on stale state.
463
+ The tick reports `relayMaintenance` as `completed`, `unchanged`, `error`,
464
+ `queue_locked`, `queue_active`, or `not_configured`. Backlog rows
465
+ with duplicate ids can neither satisfy a predecessor or dependency nor be relayed.
442
466
  The relay does not infer safe work from prose or promote project acceptance.
443
467
 
444
468
  Projects with a mutable `backlogSource` may also set
445
469
  `relayStatusReconciliation: true`. After an accepted task, Loop changes a
446
470
  `ready` local-only relay item to `completed` only when exactly one matching
447
- same-project task is in the done queue and its persisted final judgement is
448
- `ready_to_apply` without a human gate. Missing, duplicate, failed, gated, or
471
+ same-project relay lineage (the relay task plus any `revisionOf` revision
472
+ rounds bound to the same item) is in the done queue and exactly one of its
473
+ persisted final judgements is `ready_to_apply` without a human gate. Missing, duplicate, failed, gated, or
449
474
  external-action tasks leave the source unchanged. Reconciliation is idempotent
450
- and also runs on subsequent non-plan-only scheduler ticks, so an interrupted
451
- completion write can recover. It does not change the project acceptance ledger or requirement matrix. Do
475
+ and also runs on subsequent non-plan-only scheduler ticks that hold the queue
476
+ lock with no active task, so an interrupted completion write can recover. If
477
+ the backlog changes after reconciliation reads it, the write is abandoned
478
+ (`conflict: true`) instead of overwriting the newer version. It does not change the project acceptance ledger or requirement matrix. Do
452
479
  not enable it on an immutable or generated authoritative backlog source.
453
480
 
454
481
  ## Observability
@@ -502,8 +529,10 @@ LOOP_WORKDIR=/path/to/workspace \
502
529
  run-loop-cron.sh configs/loops/workspace-health.json
503
530
  ```
504
531
 
505
- Set `LOOP_ALERT_COMMAND` to a command that accepts one message argument when
506
- you want non-zero loop exits to notify a channel.
532
+ Set `LOOP_ALERT_COMMAND` to a command (it may include its own arguments, for
533
+ example `openclaw message send --target ops`) when you want non-zero loop exits
534
+ or an unreadable config to notify a channel; the message is appended as one
535
+ final argument. A failing alert command is recorded in the cron log.
507
536
 
508
537
  ## Queue Runner
509
538
 
@@ -100,11 +100,13 @@ import {
100
100
  wakeAgent
101
101
  } from '../lib/todo-control-plane.mjs';
102
102
  import {
103
+ addDashboardOperator,
103
104
  buildOperatorProjection,
104
105
  createDashboardServer,
105
106
  dashboardHealth,
106
107
  exportDashboard,
107
- filterProjection
108
+ filterProjection,
109
+ removeDashboardOperator
108
110
  } from '../lib/operator-dashboard.mjs';
109
111
  import { doctorGoal, initGoal, reviewGoal, runGoal, statusGoal } from '../lib/goal-api.mjs';
110
112
 
@@ -112,125 +114,136 @@ function parseArgs(argv) {
112
114
  const args = { _: [], root: process.cwd(), json: false, force: false };
113
115
  for (let i = 0; i < argv.length; i++) {
114
116
  const a = argv[i];
115
- if (a === '--root') args.root = path.resolve(argv[++i]);
116
- else if (a === '--config') args.config = argv[++i];
117
- else if (a === '--queue') args.queue = argv[++i];
118
- else if (a === '--project') args.project = argv[++i];
119
- else if (a === '--id') args.id = argv[++i];
120
- else if (a === '--name') args.name = argv[++i];
121
- else if (a === '--brief') args.brief = argv[++i];
122
- else if (a === '--goal') args.goal = argv[++i];
123
- else if (a === '--title') args.title = argv[++i];
124
- else if (a === '--task') args.task = argv[++i];
125
- else if (a === '--message') args.message = argv[++i];
126
- else if (a === '--strategy') args.strategy = argv[++i];
127
- else if (a === '--strategy-file') args.strategyFile = argv[++i];
128
- else if (a === '--file') args.file = argv[++i];
129
- else if (a === '--dispatcher') args.dispatcher = argv[++i];
130
- else if (a === '--preflight-config') args.preflightConfig = argv[++i];
131
- else if (a === '--timeout-ms') args.timeoutMs = Number.parseInt(argv[++i], 10);
132
- else if (a === '--lease-ms') args.leaseMs = Number.parseInt(argv[++i], 10);
133
- else if (a === '--stale-active-ms') args.staleActiveMs = Number.parseInt(argv[++i], 10);
134
- else if (a === '--initial-interval') args.initialIntervalMs = argv[++i];
135
- else if (a === '--min-interval') args.minIntervalMs = argv[++i];
136
- else if (a === '--max-interval') args.maxIntervalMs = argv[++i];
137
- else if (a === '--jitter') args.jitterMs = argv[++i];
138
- else if (a === '--progress-report-interval') args.progressReportIntervalMs = argv[++i];
139
- else if (a === '--progress-report-idle-interval') args.progressReportIdleIntervalMs = argv[++i];
140
- else if (a === '--max-attempts') args.maxAttempts = Number.parseInt(argv[++i], 10);
141
- else if (a === '--max-tasks') args.maxTasks = Number.parseInt(argv[++i], 10);
142
- else if (a === '--retry-delay-ms') args.retryDelayMs = Number.parseInt(argv[++i], 10);
143
- else if (a === '--retry-exit-codes') args.retryExitCodes = argv[++i].split(',').filter(Boolean).map((v) => Number.parseInt(v, 10));
117
+ // A flag's value must exist and must not be the next flag (`--title
118
+ // --task x`); numeric flags must be whole integers, not "10m" or "abc".
119
+ const value = () => {
120
+ const next = argv[++i];
121
+ if (next === undefined || /^--[a-z][a-z0-9-]*$/.test(next)) throw new Error(`${a} requires a value.`);
122
+ return next;
123
+ };
124
+ const integer = (raw = value()) => {
125
+ if (!/^-?\d+$/.test(String(raw).trim())) throw new Error(`${a} must be an integer, received ${JSON.stringify(raw)}.`);
126
+ return Number(raw);
127
+ };
128
+ if (a === '--root') args.root = path.resolve(value());
129
+ else if (a === '--config') args.config = value();
130
+ else if (a === '--queue') args.queue = value();
131
+ else if (a === '--project') args.project = value();
132
+ else if (a === '--id') args.id = value();
133
+ else if (a === '--name') args.name = value();
134
+ else if (a === '--brief') args.brief = value();
135
+ else if (a === '--goal') args.goal = value();
136
+ else if (a === '--title') args.title = value();
137
+ else if (a === '--task') args.task = value();
138
+ else if (a === '--message') args.message = value();
139
+ else if (a === '--strategy') args.strategy = value();
140
+ else if (a === '--strategy-file') args.strategyFile = value();
141
+ else if (a === '--file') args.file = value();
142
+ else if (a === '--dispatcher') args.dispatcher = value();
143
+ else if (a === '--preflight-config') args.preflightConfig = value();
144
+ else if (a === '--timeout-ms') args.timeoutMs = integer();
145
+ else if (a === '--lease-ms') args.leaseMs = integer();
146
+ else if (a === '--stale-active-ms') args.staleActiveMs = integer();
147
+ else if (a === '--initial-interval') args.initialIntervalMs = value();
148
+ else if (a === '--min-interval') args.minIntervalMs = value();
149
+ else if (a === '--max-interval') args.maxIntervalMs = value();
150
+ else if (a === '--jitter') args.jitterMs = value();
151
+ else if (a === '--progress-report-interval') args.progressReportIntervalMs = value();
152
+ else if (a === '--progress-report-idle-interval') args.progressReportIdleIntervalMs = value();
153
+ else if (a === '--max-attempts') args.maxAttempts = integer();
154
+ else if (a === '--max-tasks') args.maxTasks = integer();
155
+ else if (a === '--retry-delay-ms') args.retryDelayMs = integer();
156
+ else if (a === '--retry-exit-codes') args.retryExitCodes = value().split(',').filter(Boolean).map((v) => integer(v));
144
157
  else if (a === '--check') {
145
158
  if (!args.checks) args.checks = [];
146
- args.checks.push(argv[++i]);
159
+ args.checks.push(value());
147
160
  }
148
- else if (a === '--task-id') args.taskId = argv[++i];
149
- else if (a === '--todo-id') args.todoId = argv[++i];
150
- else if (a === '--agent-id') args.agentId = argv[++i];
151
- else if (a === '--target-agent-id') args.targetAgentId = argv[++i];
152
- else if (a === '--handoff-id') args.handoffId = argv[++i];
153
- else if (a === '--todo-json') args.todoJson = argv[++i];
154
- else if (a === '--agent-json') args.agentJson = argv[++i];
155
- else if (a === '--payload-json') args.payloadJson = argv[++i];
156
- else if (a === '--state') args.todoState = argv[++i];
157
- else if (a === '--run-id') args.runId = argv[++i];
158
- else if (a === '--output') args.output = argv[++i];
161
+ else if (a === '--task-id') args.taskId = value();
162
+ else if (a === '--todo-id') args.todoId = value();
163
+ else if (a === '--agent-id') args.agentId = value();
164
+ else if (a === '--target-agent-id') args.targetAgentId = value();
165
+ else if (a === '--handoff-id') args.handoffId = value();
166
+ else if (a === '--todo-json') args.todoJson = value();
167
+ else if (a === '--agent-json') args.agentJson = value();
168
+ else if (a === '--payload-json') args.payloadJson = value();
169
+ else if (a === '--state') args.todoState = value();
170
+ else if (a === '--run-id') args.runId = value();
171
+ else if (a === '--output') args.output = value();
159
172
  else if (a === '--output-dir') {
160
173
  const next = argv[i + 1];
161
- args.outputDir = !next || next.startsWith('--') ? true : argv[++i];
174
+ args.outputDir = !next || next.startsWith('--') ? true : value();
162
175
  }
163
- else if (a === '--patch-output') args.patchOutput = argv[++i];
164
- else if (a === '--review-output') args.reviewOutput = argv[++i];
165
- else if (a === '--closeout-output') args.closeoutOutput = argv[++i];
166
- else if (a === '--review') args.review = argv[++i];
167
- else if (a === '--patch') args.patch = argv[++i];
168
- else if (a === '--plan') args.plan = argv[++i];
169
- else if (a === '--from') args.from = argv[++i];
170
- else if (a === '--from-review') args.fromReview = argv[++i];
171
- else if (a === '--applied-report') args.appliedReport = argv[++i];
172
- else if (a === '--apply-report') args.applyReport = argv[++i];
173
- else if (a === '--repair-plan') args.repairPlan = argv[++i];
174
- else if (a === '--bootstrap-dir') args.bootstrapDir = argv[++i];
175
- else if (a === '--baseline') args.baseline = argv[++i];
176
- else if (a === '--baseline-output') args.baselineOutput = argv[++i];
177
- else if (a === '--drift-report') args.driftReport = argv[++i];
178
- else if (a === '--drift-severity') args.driftSeverity = argv[++i];
179
- else if (a === '--drift-summary-format') args.driftSummaryFormat = argv[++i];
180
- else if (a === '--drift-allow') args.driftAllow = argv[++i];
181
- else if (a === '--drift-allow-file') args.driftAllowFile = argv[++i];
182
- else if (a === '--type') args.type = argv[++i];
183
- else if (a === '--owner') args.owner = argv[++i];
184
- else if (a === '--repo') args.repo = argv[++i];
185
- else if (a === '--branch') args.branch = argv[++i];
186
- else if (a === '--label') args.label = argv[++i];
187
- else if (a === '--workflow') args.workflow = argv[++i];
188
- else if (a === '--readme') args.readme = argv[++i];
189
- else if (a === '--section-title') args.sectionTitle = argv[++i];
190
- else if (a === '--expires-at') args.expiresAt = argv[++i];
191
- else if (a === '--ttl') args.ttl = argv[++i];
192
- else if (a === '--action') args.action = argv[++i];
193
- else if (a === '--plans-dir') args.plansDir = argv[++i];
194
- else if (a === '--stale-after') args.staleAfter = argv[++i];
195
- else if (a === '--until') args.until = argv[++i];
196
- else if (a === '--reason') args.reason = argv[++i];
197
- else if (a === '--wait-kind') args.waitKind = argv[++i];
198
- else if (a === '--wait-id') args.waitId = argv[++i];
199
- else if (a === '--execution-key') args.executionKey = argv[++i];
200
- else if (a === '--idempotency-key') args.idempotencyKey = argv[++i];
201
- else if (a === '--kind') args.kind = argv[++i];
202
- else if (a === '--authorization-scope') args.authorizationScope = argv[++i];
203
- else if (a === '--request-json') args.requestJson = argv[++i];
204
- else if (a === '--fencing-token') args.fencingToken = Number.parseInt(argv[++i], 10);
176
+ else if (a === '--patch-output') args.patchOutput = value();
177
+ else if (a === '--review-output') args.reviewOutput = value();
178
+ else if (a === '--closeout-output') args.closeoutOutput = value();
179
+ else if (a === '--review') args.review = value();
180
+ else if (a === '--patch') args.patch = value();
181
+ else if (a === '--plan') args.plan = value();
182
+ else if (a === '--from') args.from = value();
183
+ else if (a === '--from-review') args.fromReview = value();
184
+ else if (a === '--applied-report') args.appliedReport = value();
185
+ else if (a === '--apply-report') args.applyReport = value();
186
+ else if (a === '--repair-plan') args.repairPlan = value();
187
+ else if (a === '--bootstrap-dir') args.bootstrapDir = value();
188
+ else if (a === '--baseline') args.baseline = value();
189
+ else if (a === '--baseline-output') args.baselineOutput = value();
190
+ else if (a === '--drift-report') args.driftReport = value();
191
+ else if (a === '--drift-severity') args.driftSeverity = value();
192
+ else if (a === '--drift-summary-format') args.driftSummaryFormat = value();
193
+ else if (a === '--drift-allow') args.driftAllow = value();
194
+ else if (a === '--drift-allow-file') args.driftAllowFile = value();
195
+ else if (a === '--type') args.type = value();
196
+ else if (a === '--owner') args.owner = value();
197
+ else if (a === '--repo') args.repo = value();
198
+ else if (a === '--branch') args.branch = value();
199
+ else if (a === '--label') args.label = value();
200
+ else if (a === '--workflow') args.workflow = value();
201
+ else if (a === '--readme') args.readme = value();
202
+ else if (a === '--section-title') args.sectionTitle = value();
203
+ else if (a === '--expires-at') args.expiresAt = value();
204
+ else if (a === '--ttl') args.ttl = value();
205
+ else if (a === '--action') args.action = value();
206
+ else if (a === '--plans-dir') args.plansDir = value();
207
+ else if (a === '--stale-after') args.staleAfter = value();
208
+ else if (a === '--until') args.until = value();
209
+ else if (a === '--reason') args.reason = value();
210
+ else if (a === '--wait-kind') args.waitKind = value();
211
+ else if (a === '--wait-id') args.waitId = value();
212
+ else if (a === '--execution-key') args.executionKey = value();
213
+ else if (a === '--idempotency-key') args.idempotencyKey = value();
214
+ else if (a === '--kind') args.kind = value();
215
+ else if (a === '--authorization-scope') args.authorizationScope = value();
216
+ else if (a === '--request-json') args.requestJson = value();
217
+ else if (a === '--fencing-token') args.fencingToken = integer();
205
218
  else if (a === '--completed') args.completed = true;
206
- else if (a === '--outcome') args.outcome = argv[++i];
207
- else if (a === '--evidence') args.evidence = argv[++i];
208
- else if (a === '--recovery-signal') args.recoverySignal = argv[++i];
209
- else if (a === '--now') args.now = argv[++i];
210
- else if (a === '--reminder-interval-ms') args.reminderIntervalMs = Number.parseInt(argv[++i], 10);
211
- else if (a === '--escalation-interval-ms') args.escalationIntervalMs = Number.parseInt(argv[++i], 10);
212
- else if (a === '--wait-timeout-ms') args.waitTimeoutMs = Number.parseInt(argv[++i], 10);
213
- else if (a === '--max-reminders') args.maxReminders = Number.parseInt(argv[++i], 10);
214
- else if (a === '--decision') args.decision = argv[++i];
215
- else if (a === '--comment') args.comment = argv[++i];
216
- else if (a === '--reviewer') args.reviewer = argv[++i];
217
- else if (a === '--limit') args.limit = Number.parseInt(argv[++i], 10);
218
- else if (a === '--host') args.host = argv[++i];
219
- else if (a === '--port') args.port = Number.parseInt(argv[++i], 10);
220
- else if (a === '--query') args.query = argv[++i];
221
- else if (a === '--max-age-seconds') args.maxAgeSeconds = Number.parseInt(argv[++i], 10);
222
- else if (a === '--notify-command') args.notifyCommand = argv[++i];
223
- else if (a === '--gate-id') args.gateId = argv[++i];
224
- else if (a === '--input') args.input = argv[++i];
219
+ else if (a === '--outcome') args.outcome = value();
220
+ else if (a === '--evidence') args.evidence = value();
221
+ else if (a === '--recovery-signal') args.recoverySignal = value();
222
+ else if (a === '--now') args.now = value();
223
+ else if (a === '--reminder-interval-ms') args.reminderIntervalMs = integer();
224
+ else if (a === '--escalation-interval-ms') args.escalationIntervalMs = integer();
225
+ else if (a === '--wait-timeout-ms') args.waitTimeoutMs = integer();
226
+ else if (a === '--max-reminders') args.maxReminders = integer();
227
+ else if (a === '--decision') args.decision = value();
228
+ else if (a === '--comment') args.comment = value();
229
+ else if (a === '--reviewer') args.reviewer = value();
230
+ else if (a === '--limit') args.limit = integer();
231
+ else if (a === '--host') args.host = value();
232
+ else if (a === '--port') args.port = integer();
233
+ else if (a === '--query') args.query = value();
234
+ else if (a === '--max-age-seconds') args.maxAgeSeconds = integer();
235
+ else if (a === '--notify-command') args.notifyCommand = value();
236
+ else if (a === '--gate-id') args.gateId = value();
237
+ else if (a === '--input') args.input = value();
225
238
  else if (a === '--secret-input') args.secretInput = true;
226
239
  else if (a === '--non-secret-input') args.nonSecretInput = true;
227
- else if (a === '--source-channel') args.sourceChannel = argv[++i];
228
- else if (a === '--source-target') args.sourceTarget = argv[++i];
229
- else if (a === '--source-account') args.sourceAccount = argv[++i];
230
- else if (a === '--source-message-id') args.sourceMessageId = argv[++i];
231
- else if (a === '--backlog-item-id') args.backlogItemId = argv[++i];
232
- else if (a === '--source-reply-to') args.sourceReplyTo = argv[++i];
233
- else if (a === '--progress-notify-command') args.progressNotifyCommand = argv[++i];
240
+ else if (a === '--source-channel') args.sourceChannel = value();
241
+ else if (a === '--source-target') args.sourceTarget = value();
242
+ else if (a === '--source-account') args.sourceAccount = value();
243
+ else if (a === '--source-message-id') args.sourceMessageId = value();
244
+ else if (a === '--backlog-item-id') args.backlogItemId = value();
245
+ else if (a === '--source-reply-to') args.sourceReplyTo = value();
246
+ else if (a === '--progress-notify-command') args.progressNotifyCommand = value();
234
247
  else if (a === '--include-active') args.includeActive = true;
235
248
  else if (a === '--plan-only') args.planOnly = true;
236
249
  else if (a === '--force-due') args.forceDue = true;
@@ -258,6 +271,8 @@ function parseArgs(argv) {
258
271
  else if (a === '--allow-dirty') args.allowDirty = true;
259
272
  else if (a === '--include-orphans') args.includeOrphans = true;
260
273
  else if (a === '--allow-non-loopback') args.allowNonLoopback = true;
274
+ else if (a === '--allowed-host') (args.allowedHosts ??= []).push(value());
275
+ else if (a === '--actor-id') args.actorId = value();
261
276
  else if (a === '--json') args.json = true;
262
277
  else if (a === '--force') args.force = true;
263
278
  else if (a === '--help' || a === '-h') args.help = true;
@@ -1633,7 +1648,9 @@ Advanced compatibility commands:
1633
1648
  loop-engineering dashboard-inspect [--id todo-id] [--state state] [--query text] [--root <workspace>] [--json]
1634
1649
  loop-engineering dashboard-health [--max-age-seconds 3600] [--root <workspace>] [--json]
1635
1650
  loop-engineering dashboard-export --output-dir directory [--root <workspace>] [--json]
1636
- loop-engineering dashboard-serve [--host 127.0.0.1] [--port 0] [--allow-non-loopback] [--root <workspace>]
1651
+ loop-engineering dashboard-serve [--host 127.0.0.1] [--port 0] [--allow-non-loopback] [--allowed-host name:port] [--root <workspace>]
1652
+ loop-engineering dashboard-operator-add --actor-id id [--root <workspace>]
1653
+ loop-engineering dashboard-operator-remove --actor-id id [--root <workspace>]
1637
1654
  loop-engineering repair-plan --id name [--output repair-plan.json] [--root <workspace>] [--json] [--force]
1638
1655
  loop-engineering project-intake --name project --brief "Project brief" [--type auto|web_app|code_project|research|content|ops|qa|knowledge_base|infra_audit|assistant_workflow] [--queue name] [--check "npm test"] [--root <workspace>] [--json]
1639
1656
  loop-engineering project-plan --project project [--root <workspace>] [--json] [--force]
@@ -5729,14 +5746,25 @@ async function main() {
5729
5746
 
5730
5747
  async function dashboardCommand(command, args) {
5731
5748
  if (command === 'dashboard-serve') {
5732
- const server = await createDashboardServer(args.root, { host: args.host, port: args.port, allowNonLoopback: args.allowNonLoopback });
5749
+ const server = await createDashboardServer(args.root, { host: args.host, port: args.port, allowNonLoopback: args.allowNonLoopback, allowedHosts: args.allowedHosts });
5733
5750
  const address = server.address();
5734
- console.log(JSON.stringify({ status: 'serving', read_only: true, address }, null, 2));
5751
+ console.log(JSON.stringify({ status: 'serving', read_only: false, gate_commands: 'operator_token_required', address }, null, 2));
5735
5752
  return new Promise((resolve) => {
5736
5753
  const stop = () => server.close(() => resolve(0));
5737
5754
  process.once('SIGINT', stop); process.once('SIGTERM', stop);
5738
5755
  });
5739
5756
  }
5757
+ if (command === 'dashboard-operator-add') {
5758
+ if (!args.actorId) throw new Error('dashboard-operator-add requires --actor-id.');
5759
+ const result = await addDashboardOperator(args.root, { actorId: args.actorId });
5760
+ console.log(JSON.stringify({ ...result, note: 'Store this token now; only its SHA-256 digest is kept. Re-running rotates it.' }, null, 2));
5761
+ return 0;
5762
+ }
5763
+ if (command === 'dashboard-operator-remove') {
5764
+ if (!args.actorId) throw new Error('dashboard-operator-remove requires --actor-id.');
5765
+ console.log(JSON.stringify(await removeDashboardOperator(args.root, { actorId: args.actorId }), null, 2));
5766
+ return 0;
5767
+ }
5740
5768
  if (command === 'dashboard-export') {
5741
5769
  if (!args.outputDir || args.outputDir === true) throw new Error('dashboard-export requires --output-dir.');
5742
5770
  console.log(JSON.stringify(await exportDashboard(args.root, args.outputDir, { now: args.now }), null, 2));
@@ -400,8 +400,9 @@ LOOP_WORKDIR=/path/to/workspace \
400
400
  run-loop-cron.sh configs/loops/workspace-health.json
401
401
  ```
402
402
 
403
- Set `LOOP_ALERT_COMMAND` to a command that accepts one message argument if your
404
- environment should send an alert when the runner exits non-zero.
403
+ Set `LOOP_ALERT_COMMAND` to a command (arguments allowed) if your environment
404
+ should send an alert when the runner exits non-zero or the config cannot be
405
+ read; the message is appended as one final argument.
405
406
 
406
407
  ## Adaptive Queue Scheduler
407
408
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  Each gate records project, task, Gate ID, action, reason, impact, risk, cost/budget, evidence, Dashboard URL, expiry, generation, allowed actors and one or more exact source bindings. Commands require `gate_id`, `expected_generation`, actor identity, channel/message binding, reply binding for reply commands, and an idempotency key. Successful commands produce durable receipts. Per-gate exclusive creation plus the generation fence makes only the first valid cross-interface command commit.
6
6
 
7
- Allowed mutations are card-button callbacks and replies matching `/approve gate_<id>`, `/reject gate_<id>`, or `/request_revision gate_<id> <reason>` where the reply is bound to the registered card. Ordinary language, ordinal references, quotes, forwards and screenshots are ignored or rejected.
7
+ Allowed mutations are card-button callbacks and replies matching `/approve gate_<id>@<generation>`, `/reject gate_<id>@<generation>`, or `/request_revision gate_<id>@<generation> <reason>` where the reply is bound to the registered card. The generation is required because a chat reply carries no other proof of which card version was answered; each card button lists its exact `reply_command`, and a reply without a generation returns `generation_required`. Ordinary language, ordinal references, quotes, forwards and screenshots are ignored or rejected.
8
8
 
9
9
  High/critical risk, production, external publication, irreversible work, or cost at/above the configured threshold enters `awaiting_confirmation` and increments generation. A second command against the new generation is required. `request_revision` writes a revision artifact, increments generation, and invalidates old cards. Clients refresh from `/api/v1/gates`; processed cards render disabled.
10
10