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
|
@@ -9,6 +9,8 @@ assert.equal(inferTaskScope({ body: '继续同一整体项目,仅推进 T-01
|
|
|
9
9
|
assert.equal(inferTaskScope({ body: 'Continue the project, only complete boundary item 2' }), 'scoped_task');
|
|
10
10
|
assert.equal(inferTaskScope({ body: '继续同一整体项目,取消团队功能并从项目完成门槛中移除,其他 backlog 不变' }), 'scoped_task');
|
|
11
11
|
assert.equal(inferTaskScope({ body: 'Continue the overall project with a product-scope amendment: remove the team feature from the completion gate.' }), 'scoped_task');
|
|
12
|
+
assert.equal(inferTaskScope({ body: '把外部证据列为项目级 deferred gates。本轮作为有界本地工程里程碑,完成 TECH-01030;不宣称整体项目完成。' }), 'scoped_task');
|
|
13
|
+
assert.equal(inferTaskScope({ body: 'Project-level evidence remains deferred; this round is a bounded local engineering milestone.' }), 'scoped_task');
|
|
12
14
|
|
|
13
15
|
{
|
|
14
16
|
const devPlan = { checkpoints: [{ id: 'cp1' }] };
|
|
@@ -448,3 +450,326 @@ for (const status of ['blocked', 'revise']) {
|
|
|
448
450
|
];
|
|
449
451
|
assert.deepEqual(selectEffectiveAcceptanceReviews({ checkpoints: [{ id: 'cp1' }] }, { reviews }).map(r => r.checkpointId), ['gate']);
|
|
450
452
|
}
|
|
453
|
+
|
|
454
|
+
for (const body of [
|
|
455
|
+
'完成完整项目,不要将本轮缩成有界本地里程碑',
|
|
456
|
+
'Complete the project-level objective, not a bounded milestone',
|
|
457
|
+
'Complete the project-level objective; do not reduce this round to a bounded local milestone',
|
|
458
|
+
"Complete the project-level objective; don't reduce it to a bounded milestone",
|
|
459
|
+
'完成完整项目;本轮不是有界本地里程碑',
|
|
460
|
+
]) assert.equal(inferTaskScope({ body }), 'project', body);
|
|
461
|
+
|
|
462
|
+
// Paired negation targets: a project prohibition must not negate a milestone.
|
|
463
|
+
for (const body of [
|
|
464
|
+
'本轮做有界本地里程碑而不是完整项目',
|
|
465
|
+
'Implement a bounded milestone without completing the project-level objective',
|
|
466
|
+
'Not the project-level objective, but a bounded milestone',
|
|
467
|
+
'不是完整项目,而是本轮做有界本地里程碑',
|
|
468
|
+
]) assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
469
|
+
for (const body of [
|
|
470
|
+
'完成完整项目,本轮不做有界本地里程碑',
|
|
471
|
+
'完成完整项目,本轮不应仅做有界本地里程碑',
|
|
472
|
+
'Complete the project-level objective without reducing it to a bounded milestone',
|
|
473
|
+
'Complete the project-level objective, never just a bounded milestone',
|
|
474
|
+
]) assert.equal(inferTaskScope({ body }), 'project', body);
|
|
475
|
+
|
|
476
|
+
// Unrelated prohibitions must not negate the requested object.
|
|
477
|
+
for (const body of [
|
|
478
|
+
'在不部署完整项目的前提下本轮完成有界本地里程碑',
|
|
479
|
+
'Without deploying the project-level application implement a bounded milestone',
|
|
480
|
+
'完整项目不部署,本轮只完成第一步',
|
|
481
|
+
'Complete the project-level objective later; only complete a backlog item',
|
|
482
|
+
]) assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
483
|
+
for (const body of [
|
|
484
|
+
'完成完整项目,不要只完成第一步',
|
|
485
|
+
'Complete the project-level objective, not merely a bounded milestone or backlog item',
|
|
486
|
+
'完成完整项目,不要仅推进第一步',
|
|
487
|
+
'Complete the project-level objective, not a backlog item',
|
|
488
|
+
'完成完整项目,不要取消功能',
|
|
489
|
+
]) assert.equal(inferTaskScope({ body }), 'project', body);
|
|
490
|
+
|
|
491
|
+
for (const body of [
|
|
492
|
+
'完整项目以后做,本轮完成有界可验收里程碑',
|
|
493
|
+
'Project-level delivery later, implement a bounded local/testable milestone',
|
|
494
|
+
]) assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
495
|
+
|
|
496
|
+
// Ordinal modifiers and stopping verbs remain local to the negated object.
|
|
497
|
+
for (const body of [
|
|
498
|
+
'Complete the project-level objective, not just the first bounded milestone',
|
|
499
|
+
'Complete the project-level objective, without stopping at a bounded milestone',
|
|
500
|
+
'Complete the project-level objective, do not stop at the first bounded milestone or backlog item',
|
|
501
|
+
'Complete the project-level objective, not only the next bounded milestone',
|
|
502
|
+
]) assert.equal(inferTaskScope({ body }), 'project', body);
|
|
503
|
+
for (const body of [
|
|
504
|
+
'Without deploying the project-level application implement the first bounded milestone',
|
|
505
|
+
'Do not stop the project-level service while implementing a bounded milestone',
|
|
506
|
+
'Project-level delivery later; stop at the first bounded milestone',
|
|
507
|
+
'Complete the first bounded milestone without stopping the project-level service',
|
|
508
|
+
]) assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
509
|
+
|
|
510
|
+
// Negated object phrases accept modifiers, not a fixed adjective vocabulary.
|
|
511
|
+
for (const modifier of ['initial', 'one', 'second', 'smallest useful', 'independently testable', 'newly requested']) {
|
|
512
|
+
for (const suffix of ['', ', or a backlog item', ', and a backlog item']) {
|
|
513
|
+
const body = `Complete the project-level objective, not merely ${modifier} bounded milestone${suffix}`;
|
|
514
|
+
assert.equal(inferTaskScope({ body }), 'project', body);
|
|
515
|
+
}
|
|
516
|
+
const body = `Project-level delivery later; implement ${modifier} bounded milestone`;
|
|
517
|
+
assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
518
|
+
}
|
|
519
|
+
for (const body of [
|
|
520
|
+
'完成完整项目,不应停留在有界里程碑',
|
|
521
|
+
'完成完整项目,不应仅仅满足于一个有界本地里程碑',
|
|
522
|
+
'Complete the project-level objective, not a bounded milestone, or a backlog item',
|
|
523
|
+
'Do not reduce the project-level objective to a bounded milestone',
|
|
524
|
+
'Complete the project-level objective, not just the initial bounded milestone',
|
|
525
|
+
]) assert.equal(inferTaskScope({ body }), 'project', body);
|
|
526
|
+
for (const body of [
|
|
527
|
+
'Do not deploy, implement a bounded milestone for the project-level objective',
|
|
528
|
+
'Do not stop the service while implementing a bounded milestone for the project-level objective',
|
|
529
|
+
'Complete the project-level objective later, not today, implement a bounded milestone',
|
|
530
|
+
'完成完整项目之前,在不部署的前提下完成有界里程碑',
|
|
531
|
+
'Complete the project-level objective later, implement a bounded milestone, or a backlog item',
|
|
532
|
+
]) assert.equal(inferTaskScope({ body }), 'scoped_task', body);
|
|
533
|
+
|
|
534
|
+
// Independent boundary review: coordination, double negatives and context switches.
|
|
535
|
+
for (const [body, expected] of [
|
|
536
|
+
[
|
|
537
|
+
"Complete the project-level objective, not a bounded milestone, nor a backlog item",
|
|
538
|
+
"project"
|
|
539
|
+
],
|
|
540
|
+
[
|
|
541
|
+
"Complete the project-level objective, neither a bounded milestone nor a backlog item",
|
|
542
|
+
"project"
|
|
543
|
+
],
|
|
544
|
+
[
|
|
545
|
+
"Complete the project-level objective, not only a bounded milestone but also not merely a backlog item",
|
|
546
|
+
"project"
|
|
547
|
+
],
|
|
548
|
+
[
|
|
549
|
+
"Complete the project-level objective, not only a bounded milestone but also the entire delivery",
|
|
550
|
+
"project"
|
|
551
|
+
],
|
|
552
|
+
[
|
|
553
|
+
"完成完整项目,不仅是有界里程碑,而且不是仅完成第一步",
|
|
554
|
+
"project"
|
|
555
|
+
],
|
|
556
|
+
[
|
|
557
|
+
"完成完整项目,不做有界里程碑,也不只完成第一步",
|
|
558
|
+
"project"
|
|
559
|
+
],
|
|
560
|
+
[
|
|
561
|
+
"Project-level delivery later; do not fail to complete a bounded milestone",
|
|
562
|
+
"scoped_task"
|
|
563
|
+
],
|
|
564
|
+
[
|
|
565
|
+
"Project-level delivery later; do not avoid implementing a bounded milestone",
|
|
566
|
+
"scoped_task"
|
|
567
|
+
],
|
|
568
|
+
[
|
|
569
|
+
"完整项目以后做,本轮不能不完成有界里程碑",
|
|
570
|
+
"scoped_task"
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
"完整项目以后做,本轮不是不完成有界里程碑",
|
|
574
|
+
"scoped_task"
|
|
575
|
+
],
|
|
576
|
+
[
|
|
577
|
+
"Project-level delivery later; implement a bounded milestone, not a backlog item",
|
|
578
|
+
"scoped_task"
|
|
579
|
+
],
|
|
580
|
+
[
|
|
581
|
+
"Complete the project-level objective, not a bounded milestone; implement a backlog item",
|
|
582
|
+
"scoped_task"
|
|
583
|
+
],
|
|
584
|
+
[
|
|
585
|
+
"Complete the project-level objective, not a bounded milestone, and implement a backlog item",
|
|
586
|
+
"scoped_task"
|
|
587
|
+
],
|
|
588
|
+
[
|
|
589
|
+
"完成完整项目,不做有界里程碑,改为只完成第一步",
|
|
590
|
+
"scoped_task"
|
|
591
|
+
],
|
|
592
|
+
[
|
|
593
|
+
"Without deploying anything implement a bounded milestone for the project-level objective",
|
|
594
|
+
"scoped_task"
|
|
595
|
+
],
|
|
596
|
+
[
|
|
597
|
+
"Do not deploy the service and then implement a bounded milestone for the project-level objective",
|
|
598
|
+
"scoped_task"
|
|
599
|
+
],
|
|
600
|
+
[
|
|
601
|
+
"Complete the project-level objective, never stop at a bounded milestone, nor a backlog item",
|
|
602
|
+
"project"
|
|
603
|
+
],
|
|
604
|
+
[
|
|
605
|
+
"Complete the project-level objective, not a bounded milestone, however implement a backlog item",
|
|
606
|
+
"scoped_task"
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
"Complete the project-level objective, not a bounded milestone, nor a backlog item",
|
|
610
|
+
"project"
|
|
611
|
+
],
|
|
612
|
+
[
|
|
613
|
+
"Complete the project-level objective, not a bounded milestone nor a backlog item",
|
|
614
|
+
"project"
|
|
615
|
+
],
|
|
616
|
+
[
|
|
617
|
+
"Complete the project-level objective, not a bounded milestone, or a backlog item",
|
|
618
|
+
"project"
|
|
619
|
+
],
|
|
620
|
+
[
|
|
621
|
+
"Complete the project-level objective, not a bounded milestone or a backlog item",
|
|
622
|
+
"project"
|
|
623
|
+
],
|
|
624
|
+
[
|
|
625
|
+
"Complete the project-level objective, not a bounded milestone, and a backlog item",
|
|
626
|
+
"project"
|
|
627
|
+
],
|
|
628
|
+
[
|
|
629
|
+
"Project-level delivery later; implement a bounded milestone",
|
|
630
|
+
"scoped_task"
|
|
631
|
+
],
|
|
632
|
+
[
|
|
633
|
+
"Project-level delivery later; complete a bounded milestone",
|
|
634
|
+
"scoped_task"
|
|
635
|
+
],
|
|
636
|
+
[
|
|
637
|
+
"Project-level delivery later; execute a bounded milestone",
|
|
638
|
+
"scoped_task"
|
|
639
|
+
]
|
|
640
|
+
]) assert.equal(inferTaskScope({ body }), expected, body);
|
|
641
|
+
|
|
642
|
+
for (const [body, expected] of [
|
|
643
|
+
[
|
|
644
|
+
"Project-level delivery later; do not fail to complete a bounded milestone",
|
|
645
|
+
"scoped_task"
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
"Project-level delivery later; don't fail to complete a bounded milestone",
|
|
649
|
+
"scoped_task"
|
|
650
|
+
],
|
|
651
|
+
[
|
|
652
|
+
"Project-level delivery later; don’t fail to complete a bounded milestone",
|
|
653
|
+
"scoped_task"
|
|
654
|
+
],
|
|
655
|
+
[
|
|
656
|
+
"Project-level delivery later; never fail to complete a bounded milestone",
|
|
657
|
+
"scoped_task"
|
|
658
|
+
],
|
|
659
|
+
[
|
|
660
|
+
"Project-level delivery later; do not avoid complete a bounded milestone",
|
|
661
|
+
"scoped_task"
|
|
662
|
+
],
|
|
663
|
+
[
|
|
664
|
+
"Project-level delivery later; without failing to complete a bounded milestone",
|
|
665
|
+
"scoped_task"
|
|
666
|
+
],
|
|
667
|
+
[
|
|
668
|
+
"Complete the project-level objective, neither a bounded milestone, nor a backlog item",
|
|
669
|
+
"project"
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
"Complete the project-level objective, not a bounded milestone, nor a backlog item",
|
|
673
|
+
"project"
|
|
674
|
+
],
|
|
675
|
+
[
|
|
676
|
+
"Complete the project-level objective, never stop at a bounded milestone, nor a backlog item",
|
|
677
|
+
"project"
|
|
678
|
+
],
|
|
679
|
+
[
|
|
680
|
+
"Complete the project-level objective later; not a bounded milestone, and implement a bounded milestone",
|
|
681
|
+
"scoped_task"
|
|
682
|
+
],
|
|
683
|
+
[
|
|
684
|
+
"Complete the project-level objective later; not a bounded milestone, and complete a bounded milestone",
|
|
685
|
+
"scoped_task"
|
|
686
|
+
],
|
|
687
|
+
[
|
|
688
|
+
"Complete the project-level objective later; not a bounded milestone, and execute a bounded milestone",
|
|
689
|
+
"scoped_task"
|
|
690
|
+
],
|
|
691
|
+
[
|
|
692
|
+
"Complete the project-level objective, neither a backlog item, nor a backlog item",
|
|
693
|
+
"project"
|
|
694
|
+
],
|
|
695
|
+
[
|
|
696
|
+
"Complete the project-level objective, not a backlog item, nor a backlog item",
|
|
697
|
+
"project"
|
|
698
|
+
],
|
|
699
|
+
[
|
|
700
|
+
"Complete the project-level objective, never stop at a backlog item, nor a backlog item",
|
|
701
|
+
"project"
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
"Complete the project-level objective later; not a bounded milestone, and implement a backlog item",
|
|
705
|
+
"scoped_task"
|
|
706
|
+
],
|
|
707
|
+
[
|
|
708
|
+
"Complete the project-level objective later; not a bounded milestone, and complete a backlog item",
|
|
709
|
+
"scoped_task"
|
|
710
|
+
],
|
|
711
|
+
[
|
|
712
|
+
"Complete the project-level objective later; not a bounded milestone, and execute a backlog item",
|
|
713
|
+
"scoped_task"
|
|
714
|
+
],
|
|
715
|
+
[
|
|
716
|
+
"Complete the project-level objective, neither the boundary item, nor a backlog item",
|
|
717
|
+
"project"
|
|
718
|
+
],
|
|
719
|
+
[
|
|
720
|
+
"Complete the project-level objective, not the boundary item, nor a backlog item",
|
|
721
|
+
"project"
|
|
722
|
+
],
|
|
723
|
+
[
|
|
724
|
+
"Complete the project-level objective, never stop at the boundary item, nor a backlog item",
|
|
725
|
+
"project"
|
|
726
|
+
],
|
|
727
|
+
[
|
|
728
|
+
"Complete the project-level objective later; not a bounded milestone, and implement the boundary item",
|
|
729
|
+
"scoped_task"
|
|
730
|
+
],
|
|
731
|
+
[
|
|
732
|
+
"Complete the project-level objective later; not a bounded milestone, and complete the boundary item",
|
|
733
|
+
"scoped_task"
|
|
734
|
+
],
|
|
735
|
+
[
|
|
736
|
+
"Complete the project-level objective later; not a bounded milestone, and execute the boundary item",
|
|
737
|
+
"scoped_task"
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
"完整项目以后做,本轮不能不完成有界里程碑",
|
|
741
|
+
"scoped_task"
|
|
742
|
+
],
|
|
743
|
+
[
|
|
744
|
+
"完整项目以后做,本轮不得不完成有界里程碑",
|
|
745
|
+
"scoped_task"
|
|
746
|
+
],
|
|
747
|
+
[
|
|
748
|
+
"完整项目以后做,本轮不是不完成有界里程碑",
|
|
749
|
+
"scoped_task"
|
|
750
|
+
],
|
|
751
|
+
[
|
|
752
|
+
"Complete not only a bounded milestone but also the entire project-level objective",
|
|
753
|
+
"project"
|
|
754
|
+
],
|
|
755
|
+
[
|
|
756
|
+
"Not only avoid deployment but also implement a bounded milestone for the project-level objective",
|
|
757
|
+
"scoped_task"
|
|
758
|
+
],
|
|
759
|
+
[
|
|
760
|
+
"本轮不仅完成有界里程碑,而且完成完整项目",
|
|
761
|
+
"project"
|
|
762
|
+
],
|
|
763
|
+
[
|
|
764
|
+
"完整项目以后做,本轮不仅不部署,而且只完成第一步",
|
|
765
|
+
"scoped_task"
|
|
766
|
+
],
|
|
767
|
+
[
|
|
768
|
+
"Complete the project-level objective, not a bounded milestone and not a backlog item",
|
|
769
|
+
"project"
|
|
770
|
+
],
|
|
771
|
+
[
|
|
772
|
+
"Complete the project-level objective, neither a bounded milestone, nor a backlog item",
|
|
773
|
+
"project"
|
|
774
|
+
]
|
|
775
|
+
]) assert.equal(inferTaskScope({ body }), expected, body);
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { chmod, mkdtemp, mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { realpathSync } from 'node:fs';
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import { enqueueTask, runCommand, runQueueOnce } from '../lib/core.mjs';
|
|
8
|
+
import { runIsolatedVerification, validateIsolatedVerification } from '../lib/isolated-verification.mjs';
|
|
9
|
+
|
|
10
|
+
const base = await mkdtemp(path.join(tmpdir(), 'loop-isolation-self-test-'));
|
|
11
|
+
const quote = (value) => "'" + String(value).replaceAll("'", "'\"'\"'") + "'";
|
|
12
|
+
const run = async (project, command, inputs, label, runtimeFiles = []) => {
|
|
13
|
+
const evidenceDir = path.join(base, label);
|
|
14
|
+
const result = await runIsolatedVerification({ cwd: project, command, inputs, runtimeFiles,
|
|
15
|
+
evidenceDir, timeoutMs: 15000, runCommand, shellQuote: quote });
|
|
16
|
+
let terminal;
|
|
17
|
+
try { terminal = JSON.parse(await readFile(path.join(evidenceDir, 'terminal.json'), 'utf8')); }
|
|
18
|
+
catch { throw new Error(`missing isolation terminal: ${JSON.stringify(result)}`); }
|
|
19
|
+
return { result, terminal };
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
assert.throws(() => validateIsolatedVerification({ inputs: ['../private'] }), /safe relative/);
|
|
23
|
+
assert.throws(() => validateIsolatedVerification({ inputs: ['input.txt'], runtimeFiles: ['/etc/passwd'] }), /runtimeFiles/);
|
|
24
|
+
|
|
25
|
+
const pythonProject = path.join(base, 'python-project');
|
|
26
|
+
await mkdir(pythonProject);
|
|
27
|
+
await writeFile(path.join(pythonProject, 'input.txt'), 'hello\n');
|
|
28
|
+
await writeFile(path.join(pythonProject, 'hidden.txt'), 'private\n');
|
|
29
|
+
const python = await run(pythonProject, 'cat input.txt > /out/result.txt', ['input.txt'], 'python-pass');
|
|
30
|
+
assert.equal(python.result.exitCode, 0, JSON.stringify(python.terminal) + '\n' +
|
|
31
|
+
(await readFile(path.join(base, 'python-pass', 'stderr.log'), 'utf8')).slice(0, 500));
|
|
32
|
+
assert.equal(python.terminal.status, 'passed');
|
|
33
|
+
assert.equal((await readFile(path.join(base, 'python-pass', 'output', 'result.txt'), 'utf8')).trim(), 'hello');
|
|
34
|
+
|
|
35
|
+
const hidden = await run(pythonProject, 'cat hidden.txt >/dev/null 2>&1 || true', ['input.txt'], 'undeclared');
|
|
36
|
+
assert.equal(hidden.terminal.exit_code, 0);
|
|
37
|
+
assert.equal(hidden.result.exitCode, 1);
|
|
38
|
+
assert.match(hidden.terminal.read_violations.join(' '), /undeclared available project input/);
|
|
39
|
+
|
|
40
|
+
// Root/nested reads must produce the same rejection, even after swallowing errors.
|
|
41
|
+
await mkdir(path.join(pythonProject, 'sub'));
|
|
42
|
+
await writeFile(path.join(pythonProject, 'sub', 'input.txt'), 'nested\n');
|
|
43
|
+
await writeFile(path.join(pythonProject, 'sub', 'hidden.txt'), 'private\n');
|
|
44
|
+
for (const [label, command] of [
|
|
45
|
+
['nested', 'cd sub; cat hidden.txt >/dev/null 2>&1 || true'],
|
|
46
|
+
['parent', 'cd sub; cat ../hidden.txt >/dev/null 2>&1 || true'],
|
|
47
|
+
]) {
|
|
48
|
+
const probe = await run(pythonProject, command, ['input.txt', 'sub/input.txt'], label);
|
|
49
|
+
assert.equal(probe.terminal.exit_code, 0);
|
|
50
|
+
assert.equal(probe.result.exitCode, 1);
|
|
51
|
+
assert.match(probe.terminal.read_violations.join(' '), /undeclared available project input/);
|
|
52
|
+
}
|
|
53
|
+
// Optional probes are allowed only when the source path is genuinely absent.
|
|
54
|
+
for (const [label, command] of [
|
|
55
|
+
['missing-root-parent', 'cat /nonexistent_r4/../work/hidden.txt >/dev/null 2>&1 || true'],
|
|
56
|
+
['missing-root-reentry', 'cat /work/../nonexistent_r4/../work/hidden.txt >/dev/null 2>&1 || true'],
|
|
57
|
+
['missing-alias', 'cat /work/../work/missing.txt >/dev/null 2>&1 || true'],
|
|
58
|
+
['missing-alias-parent', 'cat //work/absent/../hidden.txt >/dev/null 2>&1 || true'],
|
|
59
|
+
['file-alias-parent', 'cat ../work/input.txt/../hidden.txt >/dev/null 2>&1 || true'],
|
|
60
|
+
['missing-parent', 'cat absent/../hidden.txt >/dev/null 2>&1 || true'],
|
|
61
|
+
['nondirectory-parent', 'cat input.txt/../hidden.txt >/dev/null 2>&1 || true'],
|
|
62
|
+
['missing-trailing-slash', 'cat hidden.txt/ >/dev/null 2>&1 || true'],
|
|
63
|
+
['optional-exec', './optional.sh >/dev/null 2>&1 || true'],
|
|
64
|
+
['optional-access', `python3 -c "import os; assert not os.access('absent.txt', os.R_OK)"`],
|
|
65
|
+
['optional-nested', `cd sub; python3 -c "import os; assert not os.access('absent.txt', os.R_OK)"`],
|
|
66
|
+
['optional-unicode', "cat '不存在.txt' >/dev/null 2>&1 || true"],
|
|
67
|
+
['optional-fchdir', `python3 -c "import os; fd=os.open('sub', os.O_RDONLY); os.fchdir(fd); assert not os.access('absent.txt', os.R_OK)"`],
|
|
68
|
+
]) {
|
|
69
|
+
const probe = await run(pythonProject, command, ['input.txt', 'sub/input.txt'], label);
|
|
70
|
+
assert.equal(probe.result.exitCode, 0, label + JSON.stringify(probe.terminal));
|
|
71
|
+
}
|
|
72
|
+
for (const [label, command] of [
|
|
73
|
+
['relative-alias', 'cat ../work/hidden.txt >/dev/null 2>&1 || true'],
|
|
74
|
+
['absolute-alias', 'cat /work/../work/hidden.txt >/dev/null 2>&1 || true'],
|
|
75
|
+
['double-slash', 'cat //work/hidden.txt >/dev/null 2>&1 || true'],
|
|
76
|
+
['multi-reentry', 'cat /work/../../work/sub/../../work/hidden.txt >/dev/null 2>&1 || true'],
|
|
77
|
+
['existing-parent', 'cat sub/../hidden.txt >/dev/null 2>&1 || true'],
|
|
78
|
+
['hidden-access', `python3 -c "import os; os.access('hidden.txt', os.R_OK)"`],
|
|
79
|
+
['hidden-nested-access', `cd sub; python3 -c "import os; os.access('hidden.txt', os.R_OK)"`],
|
|
80
|
+
['hidden-exec', './hidden.txt >/dev/null 2>&1 || true'],
|
|
81
|
+
['hidden-fchdir', `python3 -c "import os; fd=os.open('sub', os.O_RDONLY); os.fchdir(fd); os.access('hidden.txt', os.R_OK)"`],
|
|
82
|
+
]) {
|
|
83
|
+
const probe = await run(pythonProject, command, ['input.txt', 'sub/input.txt'], label);
|
|
84
|
+
assert.equal(probe.terminal.exit_code, 0, label);
|
|
85
|
+
assert.equal(probe.result.exitCode, 1, label);
|
|
86
|
+
assert.match(probe.terminal.read_violations.join(' '), /undeclared available project input/, label);
|
|
87
|
+
}
|
|
88
|
+
for (const [index, name] of ['中文.txt', 'quote".txt', 'back\\slash.txt'].entries()) {
|
|
89
|
+
await writeFile(path.join(pythonProject, name), 'content');
|
|
90
|
+
const allowed = await run(pythonProject, `cat ${quote(name)} >/out/result`, [name], `filename-${index}`);
|
|
91
|
+
assert.equal(allowed.result.exitCode, 0, JSON.stringify(allowed.terminal));
|
|
92
|
+
const denied = await run(pythonProject, `cat ${quote(name)} >/dev/null 2>&1 || true`, ['input.txt'], `filename-hidden-${index}`);
|
|
93
|
+
assert.equal(denied.result.exitCode, 1, JSON.stringify(denied.terminal));
|
|
94
|
+
assert.match(denied.terminal.read_violations.join(' '), /undeclared available project input/);
|
|
95
|
+
}
|
|
96
|
+
const nestedPass = await run(pythonProject, 'cd sub; cat input.txt > /out/result',
|
|
97
|
+
['sub/input.txt'], 'nested-pass');
|
|
98
|
+
assert.equal(nestedPass.result.exitCode, 0, JSON.stringify(nestedPass.terminal));
|
|
99
|
+
await writeFile(path.join(pythonProject, 'test.sh'), '#!/bin/sh\ncat input.txt > /out/executed\n');
|
|
100
|
+
await chmod(path.join(pythonProject, 'test.sh'), 0o755);
|
|
101
|
+
const executable = await run(pythonProject, './test.sh', ['test.sh', 'input.txt'], 'exec-pass');
|
|
102
|
+
assert.equal(executable.result.exitCode, 0, JSON.stringify(executable.terminal));
|
|
103
|
+
await chmod(path.join(pythonProject, 'test.sh'), 0o744);
|
|
104
|
+
const changedMode = await run(pythonProject, './test.sh', ['test.sh', 'input.txt'], 'mode-change');
|
|
105
|
+
assert.equal(changedMode.result.exitCode, 0);
|
|
106
|
+
assert.notEqual(executable.terminal.input_digest, changedMode.terminal.input_digest);
|
|
107
|
+
|
|
108
|
+
const forged = await run(pythonProject, 'printf "fake" > /tmp/trace.log; cat hidden.txt >/dev/null 2>&1 || true',
|
|
109
|
+
['input.txt'], 'forged-trace');
|
|
110
|
+
assert.equal(forged.terminal.exit_code, 0);
|
|
111
|
+
assert.equal(forged.result.exitCode, 1);
|
|
112
|
+
assert.equal(forged.terminal.status, 'failed_or_unknown');
|
|
113
|
+
await symlink(base, path.join(pythonProject, 'outside'));
|
|
114
|
+
const linked = await run(pythonProject, 'true', ['outside/python-project/input.txt'], 'symlink-ancestor');
|
|
115
|
+
assert.equal(linked.result.exitCode, 1);
|
|
116
|
+
assert.match(linked.terminal.error, /symlink input ancestor/);
|
|
117
|
+
|
|
118
|
+
const nodeProject = path.join(base, 'node-project');
|
|
119
|
+
await mkdir(nodeProject);
|
|
120
|
+
await writeFile(path.join(nodeProject, 'input.txt'), 'node\n');
|
|
121
|
+
await writeFile(path.join(nodeProject, 'app.js'), 'require("fs").readFileSync("input.txt");\n');
|
|
122
|
+
const nodeBinary = realpathSync(process.execPath);
|
|
123
|
+
const node = await run(nodeProject, `${nodeBinary} app.js`,
|
|
124
|
+
['input.txt', 'app.js'], 'node-pass', nodeBinary.startsWith('/usr/') ? [] : [nodeBinary]);
|
|
125
|
+
assert.equal(node.result.exitCode, 0);
|
|
126
|
+
assert.equal(node.terminal.status, 'passed');
|
|
127
|
+
assert.equal(node.terminal.read_trace_verified, true);
|
|
128
|
+
|
|
129
|
+
const queueProject = path.join(base, 'queue-project');
|
|
130
|
+
await mkdir(queueProject);
|
|
131
|
+
await writeFile(path.join(queueProject, '.gitignore'), 'runtime/\n');
|
|
132
|
+
await writeFile(path.join(queueProject, 'input.txt'), 'queue\n');
|
|
133
|
+
await writeFile(path.join(queueProject, 'hidden.txt'), 'not declared\n');
|
|
134
|
+
await mkdir(path.join(queueProject, 'sub'));
|
|
135
|
+
await writeFile(path.join(queueProject, 'sub/input.txt'), 'nested\n');
|
|
136
|
+
await writeFile(path.join(queueProject, 'test.sh'), '#!/bin/sh\ncat input.txt > /out/result.txt\n');
|
|
137
|
+
await chmod(path.join(queueProject, 'test.sh'), 0o755);
|
|
138
|
+
const git = (...args) => execFileSync('git', args, { cwd: queueProject, stdio: 'pipe' });
|
|
139
|
+
git('init', '-q');
|
|
140
|
+
git('config', 'user.email', 'loop@example.invalid');
|
|
141
|
+
git('config', 'user.name', 'loop');
|
|
142
|
+
git('add', '-A');
|
|
143
|
+
git('commit', '-qm', 'fixture');
|
|
144
|
+
await enqueueTask(queueProject, { queue: 'isolated', title: 'verify fixture', task: 'Run bounded verification' });
|
|
145
|
+
const queued = await runQueueOnce(queueProject, { queue: 'isolated', dispatcher: 'true',
|
|
146
|
+
worktree: { enabled: true, baseDir: 'runtime/loops/isolated/worktrees', branchPrefix: 'loop/isolated',
|
|
147
|
+
verifyCommands: ['./test.sh'], isolatedVerification: { inputs: ['input.txt', 'test.sh'] } } });
|
|
148
|
+
const queueVerification = queued.run?.verification ?? queued.verification;
|
|
149
|
+
assert.equal(queueVerification?.[0]?.result?.isolation?.status, 'passed', JSON.stringify(queued).slice(0, 2000));
|
|
150
|
+
assert.match(queueVerification[0].result.isolation.inputDigest, /^[0-9a-f]{64}$/);
|
|
151
|
+
await enqueueTask(queueProject, { queue: 'isolated', title: 'reject hidden input', task: 'Prove fail closed' });
|
|
152
|
+
const rejected = await runQueueOnce(queueProject, { queue: 'isolated', dispatcher: 'true',
|
|
153
|
+
worktree: { enabled: true, baseDir: 'runtime/loops/isolated/worktrees', branchPrefix: 'loop/isolated',
|
|
154
|
+
verifyCommands: ['cd sub; cat ../hidden.txt >/dev/null 2>&1 || true'], isolatedVerification: { inputs: ['input.txt', 'sub/input.txt'] } } });
|
|
155
|
+
assert.equal(rejected.status, 'verify_failed');
|
|
156
|
+
assert.equal(rejected.run.verification[0].result.isolation.status, 'failed_or_unknown');
|
|
157
|
+
|
|
158
|
+
// Exercise path semantics through the real disposable queue, not only the parser.
|
|
159
|
+
for (const [label, command, expected] of [
|
|
160
|
+
['bin-missing', 'cat /bin/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
161
|
+
['bin-hidden', 'cat /bin/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
162
|
+
['lib-missing', 'cat /lib/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
163
|
+
['lib-hidden', 'cat /lib/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
164
|
+
['usr-missing', 'cat /usr/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
165
|
+
['usr-hidden', 'cat /usr/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
166
|
+
['etc-missing', 'cat /etc/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
167
|
+
['etc-hidden', 'cat /etc/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
168
|
+
['lib64-missing', 'cat /lib64/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
169
|
+
['lib64-hidden', 'cat /lib64/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
170
|
+
['bin-kind', 'test -d /bin && ! test -L /bin', 'passed'],
|
|
171
|
+
['-proc-self-cwd-hidden.txt', 'cat /proc/self/cwd/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
172
|
+
['-proc-self-cwd-missing.txt', 'cat /proc/self/cwd/missing.txt 2>/dev/null || true', 'passed'],
|
|
173
|
+
['-proc-self-cwd-absent-dotdot-hidden.txt', 'cat /proc/self/cwd/absent/../hidden.txt 2>/dev/null || true', 'passed'],
|
|
174
|
+
['-proc-self-cwd-hidden.txt-', 'cat /proc/self/cwd/hidden.txt/ 2>/dev/null || true', 'passed'],
|
|
175
|
+
['-proc-thread-self-cwd-hidden.txt', 'cat /proc/thread-self/cwd/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
176
|
+
['-proc-thread-self-cwd-missing.txt', 'cat /proc/thread-self/cwd/missing.txt 2>/dev/null || true', 'passed'],
|
|
177
|
+
['-proc-thread-self-cwd-absent-dotdot-hidden.txt', 'cat /proc/thread-self/cwd/absent/../hidden.txt 2>/dev/null || true', 'passed'],
|
|
178
|
+
['-proc-thread-self-cwd-hidden.txt-', 'cat /proc/thread-self/cwd/hidden.txt/ 2>/dev/null || true', 'passed'],
|
|
179
|
+
['-proc-self-root-work-hidden.txt', 'cat /proc/self/root/work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
180
|
+
['-proc-self-root-work-missing.txt', 'cat /proc/self/root/work/missing.txt 2>/dev/null || true', 'passed'],
|
|
181
|
+
['-proc-self-root-work-absent-dotdot-hidden.txt', 'cat /proc/self/root/work/absent/../hidden.txt 2>/dev/null || true', 'passed'],
|
|
182
|
+
['-proc-self-root-work-hidden.txt-', 'cat /proc/self/root/work/hidden.txt/ 2>/dev/null || true', 'passed'],
|
|
183
|
+
['dynamic-fd', 'cat /dev/fd/9/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
184
|
+
['missing-parent', 'cat absent/../hidden.txt 2>/dev/null || true', 'passed'],
|
|
185
|
+
['existing-parent', 'cat sub/../hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
186
|
+
['relative-alias', 'cat ../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
187
|
+
['absolute-alias', 'cat /work/../work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
188
|
+
['double-slash', 'cat //work/hidden.txt 2>/dev/null || true', 'failed_or_unknown'],
|
|
189
|
+
['missing-alias', 'cat //work/../work/missing.txt 2>/dev/null || true', 'passed'],
|
|
190
|
+
['file-alias', 'cat ../work/input.txt/../hidden.txt 2>/dev/null || true', 'passed'],
|
|
191
|
+
]) {
|
|
192
|
+
await enqueueTask(queueProject, { queue: 'path-' + label, title: label, task: 'Verify path semantics' });
|
|
193
|
+
const outcome = await runQueueOnce(queueProject, { queue: 'path-' + label, dispatcher: 'true',
|
|
194
|
+
worktree: { enabled: true, baseDir: 'runtime/loops/path-' + label + '/worktrees',
|
|
195
|
+
branchPrefix: 'loop/path-' + label, verifyCommands: [command],
|
|
196
|
+
isolatedVerification: { inputs: ['input.txt', 'sub/input.txt'] } } });
|
|
197
|
+
assert.equal(outcome.run.verification[0]?.result?.isolation?.status, expected, JSON.stringify(outcome));
|
|
198
|
+
if (expected !== 'passed') assert.equal(outcome.status, 'verify_failed');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
console.log('isolated verification: two projects passed; undeclared input and forged trace rejected');
|