taskforce-loop-engineering 0.16.1 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +16 -0
- package/docs/isolated-verification.md +81 -0
- package/lib/core.mjs +67 -7
- package/lib/isolated-verification.mjs +47 -0
- package/lib/openclaw-diagnostic-source.mjs +71 -0
- package/package.json +6 -4
- package/scripts/final-judgement-self-test.mjs +325 -0
- package/scripts/isolated-verification-self-test.mjs +201 -0
- package/scripts/isolated-verify-self-test.py +133 -0
- package/scripts/isolated-verify.py +418 -0
- package/scripts/openclaw-diagnostic-source-self-test.mjs +27 -0
- package/scripts/openclaw-doctor.mjs +27 -8
- package/scripts/openclaw-install-self-test.mjs +111 -3
- package/scripts/openclaw-smoke.mjs +14 -5
- package/scripts/project-gate-reconciliation-self-test.mjs +36 -1
- package/skills/taskforce-loop-engineering/SKILL.md +15 -1
- package/skills/taskforce-loop-engineering/references/frozen-input-verification.md +40 -0
- package/skills/taskforce-loop-engineering/references/npm-package.md +8 -1
- package/skills/taskforce-loop-engineering/references/openclaw-diagnostics.md +93 -0
- package/skills/taskforce-loop-engineering/references/scope-task-acceptance.md +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.16.3 - 2026-10-27
|
|
6
|
+
|
|
7
|
+
- Preserve task-scoped human-input gates during reconciliation; keep task acceptance distinct from project completion and unresolved authority blockers.
|
|
8
|
+
- Improve English/Chinese scope inference for coordinated negation, neither/nor, double negatives and unrelated negative context, with paired bounded-task/project regressions. Scope inference remains heuristic.
|
|
9
|
+
- Add opt-in Linux frozen-input verification using Python, bubblewrap and strace with PID-namespace decoding: declared inputs, preserved executable modes, host-owned traces and receipts, and no nonisolated fallback.
|
|
10
|
+
- Audit failed path probes with raw traversal semantics, traced cwd/process inheritance and proven procfs self aliases. Unknown process/fd aliases and unresolved internal symlinks fail closed; this can reject legitimate optional accesses and is not unrestricted syscall emulation.
|
|
11
|
+
- Publish updated repository skill references for scope/gates, isolated verification, runtime requirements and evidence boundaries. Publication does not upgrade existing CLI installations or generated integrations.
|
|
12
|
+
|
|
13
|
+
## 0.16.2 - 2026-10-24
|
|
14
|
+
|
|
15
|
+
- Discover OpenClaw diagnostic channel/account pairs from the selected CLI, with explicit source channel, account and target filters. Doctor covers all matching accounts; smoke covers one source per run.
|
|
16
|
+
- Fail closed on malformed account inventories, missing installation records, executable mismatch and managed notifier/dispatcher drift.
|
|
17
|
+
- Preserve the installed CLI invocation for profile-sensitive wrappers and isolate inherited human-input/notification sources in diagnostic subprocesses, preventing wrong-route false positives without changing production notification precedence.
|
|
18
|
+
- Add Feishu, Telegram and Slack regression coverage with actual CLI/source/dry-run assertions; synchronize distributed skill instructions and acceptance boundaries. Dry-run diagnostics do not prove real message delivery, and publishing does not upgrade existing integrations.
|
|
19
|
+
|
|
5
20
|
## 0.16.1 - 2026-10-23
|
|
6
21
|
|
|
7
22
|
- Restrict terminal-lock governance exemptions to accepted, gate-free later reviews. A `needs_human_acceptance` project label no longer hides current blockers or failed acceptance; protect ordinary retries and context recovery with terminal-checkpoint regressions through both core and installed mock dispatchers.
|
package/README.md
CHANGED
|
@@ -1103,6 +1103,10 @@ commands. It records the branch, worktree path, verification results, `git
|
|
|
1103
1103
|
status --short`, `git diff --stat`, and `git diff --name-status` in the run
|
|
1104
1104
|
artifact, plus untracked file names.
|
|
1105
1105
|
|
|
1106
|
+
On Linux, code queues can opt into frozen-input, fail-closed verification via
|
|
1107
|
+
`worktree.isolatedVerification`. See [isolated verification](docs/isolated-verification.md)
|
|
1108
|
+
for the input contract, host requirements, receipt rules, and limits.
|
|
1109
|
+
|
|
1106
1110
|
Create a starter config:
|
|
1107
1111
|
|
|
1108
1112
|
```bash
|
|
@@ -1423,3 +1427,15 @@ https://clawhub.ai/ambitioncn/skills/taskforce-loop-engineering
|
|
|
1423
1427
|
# P2 multi-agent control plane
|
|
1424
1428
|
|
|
1425
1429
|
Loop Engineering includes typed executable todos with capability/authority-aware atomic claim, lease and fencing, deterministic dependency/quota scheduling, durable peer handoff, orphan recovery, and P0/P1 safety integration. See [docs/multi-agent-control-plane.md](docs/multi-agent-control-plane.md) for the data contract, CLI, and migration path.
|
|
1430
|
+
|
|
1431
|
+
### Multi-IM diagnostic probes
|
|
1432
|
+
|
|
1433
|
+
OpenClaw doctor discovers channels/accounts using `openclaw channels list --json`
|
|
1434
|
+
in the selected CLI/profile environment and dry-runs each configured account. It
|
|
1435
|
+
does not assume Feishu. Smoke uses the first successfully checked source; choose
|
|
1436
|
+
a specific route with `--source-channel telegram --source-account personal`. Both
|
|
1437
|
+
commands accept `--source-target` for channel plugins requiring a special target
|
|
1438
|
+
format. Targets are synthetic by default and notification probes always use
|
|
1439
|
+
dry-run; success does not prove real delivery. Missing/invalid inventories and
|
|
1440
|
+
unmatched explicit selections fail rather than silently falling back to Feishu.
|
|
1441
|
+
Smoke still executes a real isolated worker task and cleans its temporary queue.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Isolated verification for code queues
|
|
2
|
+
|
|
3
|
+
Linux code queues can opt into fail-closed verification by adding
|
|
4
|
+
`worktree.isolatedVerification` beside `worktree.verifyCommands`:
|
|
5
|
+
|
|
6
|
+
```json
|
|
7
|
+
{
|
|
8
|
+
"worktree": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"verifyCommands": ["python3 -m unittest discover -s tests"],
|
|
11
|
+
"isolatedVerification": {
|
|
12
|
+
"inputs": ["src", "tests", "pyproject.toml"],
|
|
13
|
+
"runtimeFiles": []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`inputs` are exact project files or recursive directories. They are frozen into
|
|
20
|
+
a private read-only snapshot with file permission bits preserved. Input identity
|
|
21
|
+
includes file content, size, and permission bits, so mode-only changes invalidate
|
|
22
|
+
the stability checks and change the digest; symlinks, missing paths, and special files fail
|
|
23
|
+
closed. Do not list generated output directories. Commands run from `/work`,
|
|
24
|
+
with `/out` as their only persistent writable output. The environment has no
|
|
25
|
+
inherited proxy, `NODE_OPTIONS`, home directory, or network access. The host
|
|
26
|
+
must have `python3`, `bwrap`, and `strace`; no nonisolated fallback exists.
|
|
27
|
+
|
|
28
|
+
`runtimeFiles` is an optional list of exact regular files under `/home` or `/opt` (for
|
|
29
|
+
example, a user-local Node binary). Each is mounted read-only at its original
|
|
30
|
+
path and hashed before and after execution. System files under `/usr`, `/bin`,
|
|
31
|
+
`/lib`, `/lib64`, and `/etc` are mounted read-only by the backend. Directory
|
|
32
|
+
toolchains, browser profiles, Docker, Git replay, and networked gates are not
|
|
33
|
+
supported by this generic backend. Use a separately reviewed project-specific
|
|
34
|
+
gate for those, and do not mark its result as this backend's receipt.
|
|
35
|
+
|
|
36
|
+
Each command gets a fresh, unguessable evidence directory containing the input
|
|
37
|
+
snapshot, host-owned trace, output, logs, and `terminal.json`. Loop accepts a
|
|
38
|
+
verification only when its process exits zero **and** the receipt proves a
|
|
39
|
+
zero-exit command, declared reads, unchanged source/snapshot/tool files, and
|
|
40
|
+
process-group cleanup. All commands in one verification group must share the
|
|
41
|
+
same input digest. Failed file accesses are checked against the recorded working
|
|
42
|
+
directory or directory descriptor, including nested paths and resumed calls.
|
|
43
|
+
Swallowing a missing undeclared input error does not make verification pass.
|
|
44
|
+
Missing, malformed, stale, or red receipts fail verification.
|
|
45
|
+
The queue run records the evidence directory and digest in its verification
|
|
46
|
+
artifact. `code-task-run` repeats isolated verification after applying a
|
|
47
|
+
reviewed patch; its evidence lives beside the project root in
|
|
48
|
+
`.loop-isolation-evidence/<task-id>/`.
|
|
49
|
+
|
|
50
|
+
This is a verification backend, not an automatic project dependency inventory
|
|
51
|
+
or a substitute for independent acceptance review. Each project must declare
|
|
52
|
+
its inputs and prove its dynamic dependencies with a real command and negative
|
|
53
|
+
control before making isolation mandatory for that queue.
|
|
54
|
+
|
|
55
|
+
### File trace compatibility
|
|
56
|
+
|
|
57
|
+
The host strace must support `--decode-pids=pidns`; unavailable support fails
|
|
58
|
+
closed. The supervisor traces process creation, chdir and fchdir as well as file
|
|
59
|
+
syscalls, to resolve relative access/exec probes across child processes and PID
|
|
60
|
+
namespaces. C byte escapes (including octal UTF-8 filenames) are decoded;
|
|
61
|
+
truncated or unresolved failed paths are rejected. Genuinely absent optional
|
|
62
|
+
files are allowed; existing undeclared source paths remain rejected even when
|
|
63
|
+
the verification command swallows the error. Snapshot ancestor directories are
|
|
64
|
+
readable because they contain only the frozen declared descendants.
|
|
65
|
+
|
|
66
|
+
Failed project-path probes retain their original components for source availability checks: a missing or non-directory ancestor before `..` is not collapsed into an available input. Reachable parent-relative undeclared inputs still fail verification.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Failed project-path attempts are walked component by component in the sandbox
|
|
70
|
+
namespace before mapping `/work` to the source. Re-entering `/work` through `..`
|
|
71
|
+
and repeated leading slashes cannot bypass undeclared-input auditing. Missing,
|
|
72
|
+
non-directory, and trailing-slash components retain kernel traversal semantics.
|
|
73
|
+
The supervisor models its explicit mount roots and runtime-file ancestors;
|
|
74
|
+
unresolved traversal through dynamic external mounts or symlink ancestors fails
|
|
75
|
+
closed. This is bounded trace auditing, not unrestricted syscall emulation.
|
|
76
|
+
|
|
77
|
+
Failed `/proc/self/cwd`, `/proc/thread-self/cwd` and self `root` probes are
|
|
78
|
+
resolved using the traced process cwd or the sandbox root before source-input
|
|
79
|
+
auditing. Raw suffix components are retained. Unresolved process/fd aliases
|
|
80
|
+
(including `/dev/fd`) fail closed; optional accesses via unknown dynamic aliases
|
|
81
|
+
may therefore be rejected. This does not claim general procfs emulation.
|
package/lib/core.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { createHash, randomUUID } from 'node:crypto';
|
|
|
9
9
|
import { contextPolicy, contextRotation, readBoundedJson, validHandoff, handoffCheckpoint } from './context-budget.mjs';
|
|
10
10
|
import { listSteps } from './execution-ledger.mjs';
|
|
11
11
|
import { readAndVerifyEvidence } from './production-evidence.mjs';
|
|
12
|
+
import { validateIsolatedVerification, runIsolatedVerification, isolatedEvidenceDir } from './isolated-verification.mjs';
|
|
12
13
|
|
|
13
14
|
export const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
14
15
|
|
|
@@ -1335,7 +1336,12 @@ async function gateProjectMetadata(root, task, checkpoint) {
|
|
|
1335
1336
|
}
|
|
1336
1337
|
|
|
1337
1338
|
function gateInvalidity(gate, spec) {
|
|
1338
|
-
|
|
1339
|
+
// Human-input gates may be task-scoped and intentionally have no project
|
|
1340
|
+
// binding. Project reconciliation must leave those gates alone; only a gate
|
|
1341
|
+
// that explicitly names a missing project is stale project state.
|
|
1342
|
+
if (!spec) return gate.project_id
|
|
1343
|
+
? { code: 'project_not_found', status: 'superseded' }
|
|
1344
|
+
: null;
|
|
1339
1345
|
const backlog = new Map((spec.backlog ?? []).map((item) => [String(item.id), item]));
|
|
1340
1346
|
for (const id of gate.requirement_ids ?? []) {
|
|
1341
1347
|
const requirement = backlog.get(String(id));
|
|
@@ -3469,7 +3475,36 @@ export function inferTaskScope(task) {
|
|
|
3469
3475
|
// win; otherwise phrases such as "do not call the overall project complete"
|
|
3470
3476
|
// incorrectly turn an accepted milestone into an endlessly requeued project
|
|
3471
3477
|
// task.
|
|
3472
|
-
|
|
3478
|
+
// Apply the same object-local negation rule to EVERY local-scope cue.
|
|
3479
|
+
// Removing a negated cue also prevents a nested cue ("backlog item" or
|
|
3480
|
+
// "第一步") from overriding the project objective.
|
|
3481
|
+
const cue = /有界.{0,20}?里程碑|bounded.{0,30}?milestone|(?:only\s*|仅|只)(?:推进|处理|执行|完成|验证)|阶段完成|任务完成|第\s*(?:\d+|一)\s*(?:项|步)|选项\s*\d+|boundary item|backlog item|(?:取消|撤销|移除).{0,40}(?:功能|范围|计划|必做|门槛)|(?:cancel|remove|drop|withdraw).{0,40}(?:feature|scope|requirement|backlog item|completion gate)|(?:product[-_ ]scope|产品范围).{0,20}(?:decision|amendment|决策|修订)/g;
|
|
3482
|
+
// Negation governs the following object phrase, including arbitrary modifiers.
|
|
3483
|
+
// End its scope at clause/contrast boundaries or an explicit context object,
|
|
3484
|
+
// not at a whitelist of adjectives (first/initial/one/etc.). Coordinated
|
|
3485
|
+
// comma + or/and phrases share the governing negation.
|
|
3486
|
+
const negatedPrefix = (prefix) => {
|
|
3487
|
+
// Explicit double-negative obligations are affirmative. Do not count every
|
|
3488
|
+
// negative word: unrelated prohibitions can coexist in the same clause.
|
|
3489
|
+
prefix = prefix.replace(/(?:\b(?:not|never)|n['’]t)\s+(?:fail\s+to|avoid(?:\s+doing)?)\b|\bwithout\s+failing\s+to\b|(?:不能不|不得不|不是不)/g, ' ');
|
|
3490
|
+
const negations = [...prefix.matchAll(/(?:不|勿|别)|\b(?:not|never|no|without|neither|nor)\b|n['’]t\b/g)];
|
|
3491
|
+
if (!negations.length) return false;
|
|
3492
|
+
const tail = prefix.slice(negations.at(-1).index);
|
|
3493
|
+
// These boundaries introduce a separate affirmative instruction after a
|
|
3494
|
+
// negated context, e.g. without deploying the project ... implement X.
|
|
3495
|
+
return !/(?:project[-_ ]level\b[^,;.!?]*\b(?:implement|complete|do|execute)\b)|(?:前提下|情况下)|,\s*(?:and|or)\s+(?:implement|complete|execute|do)\b|\bwithout\s+\w+ing\b[^,;.!?]*\b(?:implement|complete|execute|do)\b|\b(?:while|then|however|instead)\b/.test(tail);
|
|
3496
|
+
};
|
|
3497
|
+
const boundedMilestone = requestText.split(/[,,](?!\s*(?:or\b|and\b|nor\b|或|以及))|[。;;.!?\n]|\bbut\b|而是|但是/).some((clause) => {
|
|
3498
|
+
let prefix = '';
|
|
3499
|
+
let offset = 0;
|
|
3500
|
+
for (const match of clause.matchAll(cue)) {
|
|
3501
|
+
prefix += clause.slice(offset, match.index);
|
|
3502
|
+
if (!negatedPrefix(prefix)) return true;
|
|
3503
|
+
// Keep the governing negation for coordinated/nested local cues.
|
|
3504
|
+
offset = match.index + match[0].length;
|
|
3505
|
+
}
|
|
3506
|
+
return false;
|
|
3507
|
+
});
|
|
3473
3508
|
if (boundedMilestone) return 'scoped_task';
|
|
3474
3509
|
return /project[-_ ]level|项目级|完整项目|整体项目|single milestone|单(?:一)?里程碑/.test(requestText)
|
|
3475
3510
|
? 'project'
|
|
@@ -5212,6 +5247,10 @@ function validateWorktreeConfig(worktree) {
|
|
|
5212
5247
|
throw new Error('worktree.verifyCommands must be an array of non-empty strings.');
|
|
5213
5248
|
}
|
|
5214
5249
|
}
|
|
5250
|
+
validateIsolatedVerification(worktree.isolatedVerification);
|
|
5251
|
+
if (worktree.isolatedVerification && !worktree.verifyCommands?.length) {
|
|
5252
|
+
throw new Error('worktree.isolatedVerification requires verifyCommands.');
|
|
5253
|
+
}
|
|
5215
5254
|
}
|
|
5216
5255
|
|
|
5217
5256
|
function validateRetryConfig(retry) {
|
|
@@ -8002,7 +8041,11 @@ export async function codeTaskRun(root, queue, options = {}) {
|
|
|
8002
8041
|
root,
|
|
8003
8042
|
options.timeoutMs ?? options.config?.timeoutMs,
|
|
8004
8043
|
progress,
|
|
8005
|
-
'final-verification'
|
|
8044
|
+
'final-verification',
|
|
8045
|
+
options.config?.worktree?.isolatedVerification ? {
|
|
8046
|
+
...options.config.worktree.isolatedVerification,
|
|
8047
|
+
evidenceBase: path.join(path.dirname(root), '.loop-isolation-evidence', taskId)
|
|
8048
|
+
} : null
|
|
8006
8049
|
);
|
|
8007
8050
|
finalVerification.ok = finalVerification.commands.every((entry) => entry.result.exitCode === 0);
|
|
8008
8051
|
finalVerification.status = finalVerification.ok ? 'passed' : 'failed';
|
|
@@ -9849,9 +9892,10 @@ async function inspectWorktree(worktree) {
|
|
|
9849
9892
|
};
|
|
9850
9893
|
}
|
|
9851
9894
|
|
|
9852
|
-
async function runVerifyCommands(commands, cwd, timeoutMs, progress = null, phase = 'verification') {
|
|
9895
|
+
async function runVerifyCommands(commands, cwd, timeoutMs, progress = null, phase = 'verification', isolation = null) {
|
|
9853
9896
|
const results = [];
|
|
9854
9897
|
const list = commands ?? [];
|
|
9898
|
+
let sharedInputDigest = null;
|
|
9855
9899
|
for (let index = 0; index < list.length; index++) {
|
|
9856
9900
|
const cmd = list[index];
|
|
9857
9901
|
progress?.emit(phase, 'running', `Running verification ${index + 1}/${list.length}`, {
|
|
@@ -9860,12 +9904,24 @@ async function runVerifyCommands(commands, cwd, timeoutMs, progress = null, phas
|
|
|
9860
9904
|
cmd
|
|
9861
9905
|
});
|
|
9862
9906
|
const startedAt = new Date().toISOString();
|
|
9863
|
-
const result = await
|
|
9907
|
+
const result = isolation ? await runIsolatedVerification({ cwd, command: cmd,
|
|
9908
|
+
inputs: isolation.inputs, runtimeFiles: isolation.runtimeFiles,
|
|
9909
|
+
evidenceDir: isolatedEvidenceDir(isolation.evidenceBase, index),
|
|
9910
|
+
timeoutMs, runCommand, shellQuote }) : await runCommand(cmd, { cwd, timeoutMs });
|
|
9911
|
+
if (isolation && result.exitCode === 0) {
|
|
9912
|
+
if (sharedInputDigest !== null && sharedInputDigest !== result.isolation.inputDigest) {
|
|
9913
|
+
result.exitCode = 1;
|
|
9914
|
+
result.isolation.status = 'failed_or_unknown';
|
|
9915
|
+
result.isolation.reason = 'verification input digest changed between commands';
|
|
9916
|
+
} else {
|
|
9917
|
+
sharedInputDigest = result.isolation.inputDigest;
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9864
9920
|
results.push({
|
|
9865
9921
|
cmd,
|
|
9866
9922
|
startedAt,
|
|
9867
9923
|
finishedAt: new Date().toISOString(),
|
|
9868
|
-
result: compactCommandResult(result)
|
|
9924
|
+
result: { ...compactCommandResult(result), ...(result.isolation ? { isolation: result.isolation } : {}) }
|
|
9869
9925
|
});
|
|
9870
9926
|
progress?.emit(phase, result.exitCode === 0 ? 'passed' : 'failed', `Verification ${index + 1}/${list.length} exited ${result.exitCode}`, {
|
|
9871
9927
|
commandIndex: index + 1,
|
|
@@ -10172,7 +10228,11 @@ export async function runQueueOnce(root, options) {
|
|
|
10172
10228
|
const recoveryMax = Number(options.retry?.runtimeRecoveryMaxAttempts ?? 2);
|
|
10173
10229
|
finalStatus = recoveryCount < recoveryMax ? 'runtime_interrupted' : 'runtime_blocked';
|
|
10174
10230
|
} else if (dispatch?.exitCode === 0 && worktreeEnabled(options)) {
|
|
10175
|
-
verification = await runVerifyCommands(options.worktree?.verifyCommands ?? [], worktree.path, timeoutMs, progress
|
|
10231
|
+
verification = await runVerifyCommands(options.worktree?.verifyCommands ?? [], worktree.path, timeoutMs, progress,
|
|
10232
|
+
'verification', options.worktree?.isolatedVerification ? {
|
|
10233
|
+
...options.worktree.isolatedVerification,
|
|
10234
|
+
evidenceBase: path.join(taskRuntimeDirFor(root, queue, task.id), 'verification-evidence')
|
|
10235
|
+
} : null);
|
|
10176
10236
|
const verifyOk = verification.every((entry) => entry.result.exitCode === 0);
|
|
10177
10237
|
finalStatus = verifyOk ? 'completed' : 'verify_failed';
|
|
10178
10238
|
} else {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const runner = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../scripts/isolated-verify.py');
|
|
7
|
+
|
|
8
|
+
export function validateIsolatedVerification(config) {
|
|
9
|
+
if (config === undefined) return;
|
|
10
|
+
if (!config || typeof config !== 'object' || Array.isArray(config) ||
|
|
11
|
+
!Array.isArray(config.inputs) || !config.inputs.length ||
|
|
12
|
+
config.inputs.some((name) => typeof name !== 'string' || !name || path.isAbsolute(name) || name.split(/[\\/]/).includes('..'))) {
|
|
13
|
+
throw new Error('worktree.isolatedVerification.inputs must be nonempty safe relative paths.');
|
|
14
|
+
}
|
|
15
|
+
if (config.runtimeFiles !== undefined && (!Array.isArray(config.runtimeFiles) ||
|
|
16
|
+
config.runtimeFiles.some((name) => typeof name !== 'string' || !/^\/(home|opt)\//.test(name) ||
|
|
17
|
+
name.split('/').includes('..') || path.normalize(name) !== name))) {
|
|
18
|
+
throw new Error('worktree.isolatedVerification.runtimeFiles must be absolute /home or /opt files.');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function runIsolatedVerification({ cwd, command, inputs, runtimeFiles = [], evidenceDir, timeoutMs, runCommand, shellQuote }) {
|
|
23
|
+
const runnerHash = createHash('sha256').update(await readFile(runner)).digest('hex');
|
|
24
|
+
const commandLine = ['python3', runner, '--root', cwd, '--inputs-json', JSON.stringify(inputs),
|
|
25
|
+
'--runtime-files-json', JSON.stringify(runtimeFiles), '--command', command, '--evidence', evidenceDir,
|
|
26
|
+
'--timeout', String(Math.max(1, Math.ceil((timeoutMs ?? 300000) / 1000)))].map(shellQuote).join(' ');
|
|
27
|
+
const result = await runCommand(commandLine, { cwd, timeoutMs: (timeoutMs ?? 300000) + 10000 });
|
|
28
|
+
let terminal = null;
|
|
29
|
+
try { terminal = JSON.parse(await readFile(path.join(evidenceDir, 'terminal.json'), 'utf8')); } catch { /* no receipt is failure */ }
|
|
30
|
+
const afterHash = createHash('sha256').update(await readFile(runner)).digest('hex');
|
|
31
|
+
const accepted = result.exitCode === 0 && !result.timedOut && runnerHash === afterHash &&
|
|
32
|
+
terminal?.version === 1 && terminal.status === 'passed' && terminal.command === command &&
|
|
33
|
+
/^[0-9a-f]{64}$/.test(terminal.input_digest ?? '') && terminal.exit_code === 0 &&
|
|
34
|
+
terminal.read_trace_verified === true && terminal.snapshot_unchanged === true &&
|
|
35
|
+
terminal.source_unchanged === true && terminal.process_group_gone === true &&
|
|
36
|
+
terminal.host_tools_unchanged === true && terminal.runtime_files_unchanged === true;
|
|
37
|
+
return {
|
|
38
|
+
...result,
|
|
39
|
+
exitCode: accepted ? 0 : 1,
|
|
40
|
+
isolation: { status: accepted ? 'passed' : 'failed_or_unknown', evidenceDir,
|
|
41
|
+
inputDigest: terminal?.input_digest ?? null, runnerSha256: runnerHash }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isolatedEvidenceDir(base, index) {
|
|
46
|
+
return path.join(base, `isolation-${index + 1}-${randomUUID()}`);
|
|
47
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { access, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
async function executableIdentity(command, root) {
|
|
7
|
+
if (typeof command !== 'string' || !command.trim()) throw new Error('Missing OpenClaw executable');
|
|
8
|
+
const candidates = command.includes(path.sep)
|
|
9
|
+
? [path.resolve(root, command)]
|
|
10
|
+
: String(process.env.PATH || '').split(path.delimiter).map((dir) => path.resolve(root, dir, command));
|
|
11
|
+
for (const candidate of candidates) {
|
|
12
|
+
try { await access(candidate, constants.X_OK); return await realpath(candidate); } catch { /* try next PATH entry */ }
|
|
13
|
+
}
|
|
14
|
+
throw new Error('Cannot resolve OpenClaw executable');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Bind discovery to the recorded installation and its unchanged generated callers.
|
|
18
|
+
export async function verifyDiagnosticRuntime(args) {
|
|
19
|
+
const manifest = JSON.parse(await readFile(path.join(args.root, 'runtime/loop-engineering-openclaw-install.json'), 'utf8'));
|
|
20
|
+
if (manifest.status !== 'installed') throw new Error('OpenClaw installation is incomplete');
|
|
21
|
+
const selected = await executableIdentity(args.openclawBin, args.root);
|
|
22
|
+
const installed = await executableIdentity(manifest.openclawBin, args.root);
|
|
23
|
+
if (selected !== installed) throw new Error('Diagnostic OpenClaw CLI differs from installed CLI; select the installed executable or explicitly repair the integration');
|
|
24
|
+
for (const file of ['scripts/loops/openclaw-loop-notify.mjs', 'scripts/loops/openclaw-loop-dispatch.mjs']) {
|
|
25
|
+
const entry = manifest.managedFiles?.find((item) => item.path === file);
|
|
26
|
+
const content = await readFile(path.join(args.root, file));
|
|
27
|
+
if (!entry?.sha256 || createHash('sha256').update(content).digest('hex') !== entry.sha256) {
|
|
28
|
+
throw new Error('Installed notifier/dispatcher differs from install manifest; repair the integration before diagnostics');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Preserve the recorded invocation name: symlink names can select profiles.
|
|
32
|
+
return manifest.openclawBin;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Discover through the selected CLI/profile; never read or print channel credentials.
|
|
36
|
+
export async function diagnosticSources(args, run) {
|
|
37
|
+
const result = await run(args.openclawBin, ['channels', 'list', '--json'], { cwd: args.root });
|
|
38
|
+
if (result.code !== 0) throw new Error('Cannot discover OpenClaw channels for this profile');
|
|
39
|
+
let chat;
|
|
40
|
+
try { chat = JSON.parse(result.stdout).chat; } catch { throw new Error('Invalid OpenClaw channels JSON'); }
|
|
41
|
+
if (!chat || typeof chat !== 'object' || Array.isArray(chat)) throw new Error('Missing OpenClaw chat channel inventory');
|
|
42
|
+
const sources = [];
|
|
43
|
+
for (const [channel, entry] of Object.entries(chat)) {
|
|
44
|
+
if (args.sourceChannel && channel !== args.sourceChannel) continue;
|
|
45
|
+
const accounts = Array.isArray(entry) ? entry : entry?.accounts;
|
|
46
|
+
if (!channel.trim() || !Array.isArray(accounts)) throw new Error('Malformed OpenClaw channel account list');
|
|
47
|
+
for (const account of accounts) {
|
|
48
|
+
if (typeof account !== 'string' || !account.trim()) throw new Error('Malformed OpenClaw account entry');
|
|
49
|
+
if (args.sourceAccount && account !== args.sourceAccount) continue;
|
|
50
|
+
sources.push({ channel, account, target: args.sourceTarget || diagnosticTarget(channel), reply_to: '1' });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!sources.length) throw new Error('No matching configured IM channel/account; check the selected OpenClaw profile or --source-channel/--source-account');
|
|
54
|
+
return sources;
|
|
55
|
+
}
|
|
56
|
+
function diagnosticTarget(channel) {
|
|
57
|
+
if (channel === 'telegram') return '1';
|
|
58
|
+
if (channel === 'discord') return 'channel:100000000000000001';
|
|
59
|
+
if (channel === 'slack') return 'channel:C00000000000';
|
|
60
|
+
if (channel === 'whatsapp' || channel === 'signal') return '+12025550100';
|
|
61
|
+
if (channel === 'feishu') return 'user:loop-diagnostic-dry-run';
|
|
62
|
+
return 'loop-diagnostic-dry-run';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Diagnostic subprocesses must not inherit a stale higher-precedence route.
|
|
66
|
+
export function diagnosticEnvironment(env = process.env) {
|
|
67
|
+
const clean = { ...env };
|
|
68
|
+
delete clean.LOOP_HUMAN_INPUT_SOURCE;
|
|
69
|
+
delete clean.LOOP_NOTIFICATION_SOURCE;
|
|
70
|
+
return clean;
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taskforce-loop-engineering",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "OpenClaw-native loop engineering CLI, templates, and skill for verifiable agent work loops.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"run-loop-cron.sh": "scripts/run-loop-cron.sh"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "npm run check:human-gates && npm run check && npm run check:competitive && npm run check:operator-workspace",
|
|
21
|
+
"test": "npm run check:isolation && npm run check:human-gates && npm run check && npm run check:competitive && npm run check:operator-workspace",
|
|
22
|
+
"check:isolation": "node --check lib/isolated-verification.mjs && python3 -c \"import ast; ast.parse(open('scripts/isolated-verify.py').read())\" && python3 scripts/isolated-verify-self-test.py && node scripts/isolated-verification-self-test.mjs",
|
|
22
23
|
"check:operator-workspace": "node --check scripts/operator-workspace-final-judgement.mjs && node --check scripts/dashboard-autostart-install.mjs && node scripts/dashboard-autostart-self-test.mjs && node scripts/operator-workspace-final-judgement.mjs",
|
|
23
24
|
"check:competitive": "node --check lib/transactional-state-kernel.mjs && node --check lib/goal-api.mjs && node scripts/competitive-acceptance.mjs",
|
|
24
25
|
"check:adapters": "node --check lib/runtime-adapter-sdk.mjs && node scripts/runtime-adapter-conformance.mjs && node scripts/agent-team-control-plane-self-test.mjs",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"demo:adapter": "node examples/adapter-sdk-demo.mjs",
|
|
27
28
|
"check:production-trust": "node --check lib/runtime-adapter-v1.mjs && node --check lib/durable-journal.mjs && node --check lib/execution-ledger.mjs && node --check lib/production-evidence.mjs && node --check lib/upgrade-planner.mjs && node scripts/production-acceptance.mjs",
|
|
28
29
|
"check:config-drift": "node scripts/distribution-skill-self-test.mjs && node --check scripts/config-drift-self-test.mjs && node scripts/config-drift-self-test.mjs",
|
|
29
|
-
"check:openclaw-install": "node --check scripts/openclaw-install.mjs && node --check scripts/openclaw-doctor.mjs && node --check scripts/openclaw-smoke.mjs && node --check scripts/openclaw-manage.mjs && node scripts/openclaw-install-self-test.mjs",
|
|
30
|
+
"check:openclaw-install": "node --check scripts/openclaw-install.mjs && node --check scripts/openclaw-doctor.mjs && node --check scripts/openclaw-smoke.mjs && node --check scripts/openclaw-manage.mjs && node scripts/openclaw-install-self-test.mjs && node scripts/openclaw-diagnostic-source-self-test.mjs && DIAGNOSTIC_TEST_CHANNEL=telegram node scripts/openclaw-install-self-test.mjs && DIAGNOSTIC_TEST_CHANNEL=slack node scripts/openclaw-install-self-test.mjs",
|
|
30
31
|
"check:hermes-install": "node --check scripts/hermes-install.mjs && node --check scripts/hermes-doctor.mjs && node --check scripts/hermes-smoke.mjs && node scripts/hermes-install-self-test.mjs",
|
|
31
32
|
"check:project-gates": "node --check lib/core.mjs && node scripts/project-gate-reconciliation-self-test.mjs && node scripts/project-relay-self-test.mjs",
|
|
32
33
|
"check:human-gates": "node --check lib/human-gate-command.mjs && node --check lib/human-gate-channel-adapter.mjs && node scripts/human-gate-command-self-test.mjs && node scripts/human-gate-final-judgement.mjs",
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
"./quota": "./lib/quota-runtime-decision.mjs",
|
|
42
43
|
"./todo-control-plane": "./lib/todo-control-plane.mjs",
|
|
43
44
|
"./human-gate-command": "./lib/human-gate-command.mjs",
|
|
44
|
-
"./human-gate-channel-adapter": "./lib/human-gate-channel-adapter.mjs"
|
|
45
|
+
"./human-gate-channel-adapter": "./lib/human-gate-channel-adapter.mjs",
|
|
46
|
+
"./isolated-verification": "./lib/isolated-verification.mjs"
|
|
45
47
|
},
|
|
46
48
|
"engines": {
|
|
47
49
|
"node": ">=22"
|