@aibyzero/cm-workflow 0.16.0 → 0.16.1
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/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +20 -0
- package/README.md +2 -2
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +8 -2
- package/package.json +1 -1
- package/runtime/js/cm-ai/checklist-coverage.mjs +70 -0
- package/runtime/js/cm-ai/effect-contract.mjs +3 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +37 -1
- package/runtime/js/cm-ai/review-package.mjs +29 -3
- package/runtime/js/cm-ai/task-runner.mjs +10 -4
- package/runtime/js/cm-fix/cause-invocation.mjs +17 -4
- package/runtime/js/cm-fix/execution.mjs +30 -22
- package/runtime/js/cm-fix/final-review.mjs +18 -11
- package/runtime/js/cm-fix/finish.mjs +14 -1
- package/runtime/js/cm-security/scan.mjs +7 -1
- package/scripts/cm-ai-checklist-coverage.test.mjs +116 -0
- package/scripts/cm-ai-verification-gate.test.mjs +18 -0
- package/scripts/cm-fix-cross-session-host.test.mjs +100 -0
- package/scripts/cm-fix-execution.test.mjs +33 -0
- package/scripts/cm-fix-host.mjs +11 -5
- package/scripts/cm-fix-repair-owner.test.mjs +22 -18
- package/scripts/cm-review-dependency-snapshot.test.mjs +85 -0
- package/scripts/cm-review-inventory.test.mjs +42 -0
- package/scripts/cm-security.test.mjs +24 -0
- package/skills/cm-fix/references/js-host.md +18 -1
- package/templates/auto-update/cm-update.sh +51 -0
|
@@ -6,22 +6,25 @@ import {digest,json,need,shape,requestFor,validIdentity,failureCode} from '../cm
|
|
|
6
6
|
import {readReviewPackage} from '../cm-ai/review-package.mjs';
|
|
7
7
|
import {validateReviewDispatchGrant} from '../cm-ai/durable-runner-state.mjs';
|
|
8
8
|
import {inspectProviderReview} from '../cm-ai/provider-review-observation.mjs';
|
|
9
|
-
import {validateCauseReviewer} from './cause-invocation.mjs';
|
|
9
|
+
import {validateCauseReviewer,fixHostContexts} from './cause-invocation.mjs';
|
|
10
10
|
import {inspectFixWalkthrough} from './walkthrough.mjs';
|
|
11
11
|
import {inspectFixRegressionFailure} from './regression-evidence.mjs';
|
|
12
12
|
|
|
13
13
|
// Preserve old persisted configuration bytes: reuse its reviewer model settings,
|
|
14
14
|
// never its cause-review authority or actual provider thread.
|
|
15
15
|
export function fixFinalReviewConfiguration(configuration,causeThread=null){
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const hosts=fixHostContexts(configuration);
|
|
17
|
+
const base=validateCauseReviewer(configuration.causeReview,hosts);
|
|
18
|
+
return {hostContextId:configuration.hostContextId,...(hosts.length>1?{hostContextIds:hosts}:{}),
|
|
19
|
+
reviewer:{...base,reviewerId:'fix-final-reviewer',
|
|
18
20
|
adapterId:`${base.provider}-review-adapter`,contextId:'fix-final-review-context',
|
|
19
21
|
excludedThreadIds:[...new Set([...base.excludedThreadIds,...(causeThread?[causeThread]:[])])]}};
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
function expectation(request,configuration){
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const hosts=fixHostContexts(configuration);
|
|
26
|
+
return {request,developerThreadId:hosts[0],
|
|
27
|
+
excludedThreadIds:[...configuration.reviewer.excludedThreadIds,...hosts.slice(1),request.contextId]};
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// Immediate diagnostics only, never approval or replay evidence. Do not expose
|
|
@@ -43,14 +46,14 @@ function reviewDiagnostic(phase,error,event=null){
|
|
|
43
46
|
}
|
|
44
47
|
export function inspectFixFinalRegistration(raw,configuration){
|
|
45
48
|
const value=json(raw,12*1024*1024);shape(value,['request','authorizationAt','registeredAt','grant']);
|
|
46
|
-
const reviewer=validateCauseReviewer(configuration.reviewer,configuration
|
|
49
|
+
const reviewer=validateCauseReviewer(configuration.reviewer,fixHostContexts(configuration),configuration.reviewFeedback?34:33),request=value.request;
|
|
47
50
|
need(request.provider===reviewer.provider&&request.requestedModel===reviewer.requestedModel&&request.contextId===reviewer.contextId,'final_registration_mismatch');
|
|
48
51
|
const pkg=readReviewPackage(request.payload.reviewPackage);
|
|
49
52
|
const previous=configuration.reviewFeedback?inspectFixRepairReview(configuration.reviewFeedback,pkg.identity):null;
|
|
50
53
|
need(pkg.handoff&&digest(request.payload.priorReview)===digest(previous?.review??null),'final_handoff_required');
|
|
51
54
|
if(previous)need(reviewer.excludedThreadIds.includes(previous.providerThreadId),'final_context_mismatch');
|
|
52
55
|
validateReviewDispatchGrant(value.grant,{request,reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,
|
|
53
|
-
packageDigest:pkg.packageDigest,hostContextIds:
|
|
56
|
+
packageDigest:pkg.packageDigest,hostContextIds:fixHostContexts(configuration),authorizationAt:value.authorizationAt,registeredAt:value.registeredAt});
|
|
54
57
|
inspectProviderReview(JSON.stringify({version:1,kind:'cm-provider-review-observation',requestDigest:request.requestDigest,
|
|
55
58
|
events:[],result:{status:'failed',code:'in_progress'}}),JSON.stringify(expectation(request,configuration)));
|
|
56
59
|
return value;
|
|
@@ -96,16 +99,20 @@ export function inspectFixRepairReview(raw,nextIdentity){
|
|
|
96
99
|
...(value.regressionFailure?{regressionFailure:value.regressionFailure}:{})});
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
// The persisted feedback carries the configuration of the session that recorded
|
|
103
|
+
// it. A later session passes its own host contexts so its grants are accepted too.
|
|
104
|
+
export function fixRevisionReviewConfiguration(feedback,nextIdentity,hostContextIds=null){
|
|
100
105
|
const previous=inspectFixRepairReview(feedback,nextIdentity),config=json(feedback.configuration);
|
|
101
|
-
return {...config,reviewer:{...config.reviewer,excludedThreadIds:[...new Set([...config.reviewer.excludedThreadIds,previous.providerThreadId])]},reviewFeedback:feedback};
|
|
106
|
+
return {...config,...(hostContextIds&&hostContextIds.length>1?{hostContextIds}:{}),reviewer:{...config.reviewer,excludedThreadIds:[...new Set([...config.reviewer.excludedThreadIds,previous.providerThreadId])]},reviewFeedback:feedback};
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{authorize,run}){
|
|
105
110
|
const pkg=readReviewPackage(reviewPackage);need(pkg.handoff,'final_handoff_required');
|
|
106
|
-
const config=json(configuration,12*1024*1024);shape(config,['hostContextId','reviewer'
|
|
111
|
+
const config=json(configuration,12*1024*1024);shape(config,['hostContextId','reviewer',
|
|
112
|
+
...(Object.hasOwn(config,'hostContextIds')?['hostContextIds']:[]),
|
|
113
|
+
...(Object.hasOwn(config,'reviewFeedback')?['reviewFeedback']:[])]);
|
|
107
114
|
const previous=config.reviewFeedback?inspectFixRepairReview(config.reviewFeedback,pkg.identity):null;
|
|
108
|
-
const reviewer=validateCauseReviewer(config.reviewer,config
|
|
115
|
+
const reviewer=validateCauseReviewer(config.reviewer,fixHostContexts(config),previous?34:33);
|
|
109
116
|
if(previous)need(reviewer.excludedThreadIds.includes(previous.providerThreadId),'final_context_mismatch');
|
|
110
117
|
need(Number.isInteger(timeoutMs)&&timeoutMs>0&&timeoutMs<=3600000,'invalid_timeout');
|
|
111
118
|
need(typeof authorize==='function'&&typeof run==='function','final_review_unavailable');
|
|
@@ -94,10 +94,23 @@ export function finishFix({specsRoot,identity,configuration,status,registeredAt}
|
|
|
94
94
|
need(['closeout_required','closeout_incomplete','completed'].includes(status.stage),'fix_closeout_unavailable');
|
|
95
95
|
requireCloseoutEvidence(status);
|
|
96
96
|
const feature=`fix-${identity.taskId.slice(6)}`,reviewsDir=path.join(specsRoot,'.reviews');
|
|
97
|
+
// Git delivery is its own logged event (runtime/logging.md: commit/push/
|
|
98
|
+
// pull_request), not a precondition of task completion: cm-ai completes under
|
|
99
|
+
// every delivery mode and leaves Git to the executor, and this skill's own
|
|
100
|
+
// SKILL.md documents branch and draft-mr for fix too. Demanding 'diff' here
|
|
101
|
+
// instead locked out every project cm-init generates for a repo with a remote,
|
|
102
|
+
// and the obvious workaround was impossible: findConfig only reads the project
|
|
103
|
+
// root, which is inside the business snapshot, so editing the mode invalidates
|
|
104
|
+
// the very N5 evidence re-checked three lines below.
|
|
105
|
+
// Pinning the mode rather than dictating it keeps the contract from shifting
|
|
106
|
+
// while completion records are written. Today the snapshot notices such an edit
|
|
107
|
+
// first, so this is the local, explicit statement of that invariant rather than
|
|
108
|
+
// its only enforcement; it stays correct if the snapshot rules ever change.
|
|
109
|
+
const delivery=loadConfig({projectRoot:configuration.reproduction.cwd}).policies.delivery;
|
|
97
110
|
const verify=()=>{
|
|
98
111
|
const owned=assertOwned();if(types.isPromise(owned))Promise.prototype.then.call(owned,()=>{},()=>{});
|
|
99
112
|
need(owned===undefined,'fix_owner_required');
|
|
100
|
-
need(loadConfig({projectRoot:configuration.reproduction.cwd}).policies.delivery===
|
|
113
|
+
need(loadConfig({projectRoot:configuration.reproduction.cwd}).policies.delivery===delivery,'fix_delivery_changed');
|
|
101
114
|
const gate=checkN5({handoff:path.join(reviewsDir,`${feature}-${identity.taskId}-a${identity.attempt}-handoff.json`),
|
|
102
115
|
reviewsDir,feature,task:identity.taskId,projectRoot:configuration.reproduction.cwd,requireLearning:true});
|
|
103
116
|
need(digest(gate)===digest(status.n5.gate),'n5_evidence_changed');
|
|
@@ -45,7 +45,13 @@ const git=(project,args,optional=false)=>{
|
|
|
45
45
|
need(!result.error&&result.status===0,'git_read_failed');return result.stdout;
|
|
46
46
|
};
|
|
47
47
|
const paths=bytes=>decode(bytes).split('\0').filter(Boolean);
|
|
48
|
-
|
|
48
|
+
// `.env` 家族默认按真实密钥保护、不读取。但 .env.example / .env.sample /
|
|
49
|
+
// .env.template / .env.dist 是提交进仓库、给人照抄的占位文件,恰恰需要被扫到——
|
|
50
|
+
// 真密钥误写进示例文件是常见事故。这里只放行这四种明确的示例后缀,
|
|
51
|
+
// 其余 .env.* (.env.local、.env.production 等)保持保护。
|
|
52
|
+
const exampleEnv=/(^|\/)\.env\.(?:example|sample|template|dist)$/i;
|
|
53
|
+
const protectedPath=file=>!exampleEnv.test(file)
|
|
54
|
+
&&/(^|\/)(?:\.env(?:\..*)?|credentials[^/]*|id_rsa|id_ed25519)(\/|$)|\.(?:pem|key|p12|pfx)$/i.test(file);
|
|
49
55
|
const controlPath=file=>/(^|\/)(?:\.gitignore|\.gitleaks[^/]*|\.semgrep[^/]*|osv-scanner\.toml|\.gitmodules)$/.test(file);
|
|
50
56
|
const maps=['docs/architecture.md','docs/codebase-context/00-index.md','docs/codebase-context/07-business-logic.md'];
|
|
51
57
|
const locks=/(^|\/)(?:package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|poetry\.lock|Pipfile\.lock|requirements[^/]*\.txt|Cargo\.lock|go\.sum|Gemfile\.lock|composer\.lock|packages\.lock\.json)$/;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
import {checklistGaps, extractChecklists} from '../runtime/js/cm-ai/checklist-coverage.mjs';
|
|
8
|
+
import {deliveredText} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
9
|
+
|
|
10
|
+
// The task line that produced the real rejection on the reference project.
|
|
11
|
+
const realTask = '- [x] T-003: 按 `test-cases.json` 的 browser 用例在本地 `npm start` 页面走查:'
|
|
12
|
+
+ '3 条未完成时点击后全部变为已完成且 `剩余 0 项`、空列表与全部已完成时按钮 disabled、'
|
|
13
|
+
+ '删除一条后点击本按钮撤销仍可用;并核对既有筛选/搜索/编辑/删除/清理已完成/清空全部不回归\n'
|
|
14
|
+
+ '- T-003: 浏览器证据必须逐用例标注输入方式(鼠标/键盘/脚本)与起始存储;'
|
|
15
|
+
+ '按钮状态类用例必须分别记录**列表为空、有未完成、全部已完成**三种情形下 `#mark-all-done` 的 `disabled` 值。';
|
|
16
|
+
|
|
17
|
+
// Exactly the rows the independent reviewer quoted from the rejected round.
|
|
18
|
+
const rejectedEvidence = '## 已有功能不回归\n单条添加 删除 撤销删除 筛选「已完成」 搜索「王」 计数 剩余 N 项\n'
|
|
19
|
+
+ '本文档不涉及需要打桩的确认对话框。';
|
|
20
|
+
|
|
21
|
+
// This is the case the whole module exists for. A human reviewer spent a full
|
|
22
|
+
// round finding it; the entries are countable, so it should not have cost one.
|
|
23
|
+
test('the entries the real review rejected over are reported before dispatch', () => {
|
|
24
|
+
const gaps = checklistGaps(realTask, rejectedEvidence);
|
|
25
|
+
const regression = gaps.find(gap => gap.total === 6);
|
|
26
|
+
assert.notEqual(regression, undefined, '六项回归清单未被识别');
|
|
27
|
+
assert.deepEqual([...regression.missing], ['编辑', '清理已完成', '清空全部不回归']);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('a delivery covering every entry reports no gap for that list', () => {
|
|
31
|
+
const complete = '筛选 搜索 编辑 删除 清理已完成 清空全部 都走查过了';
|
|
32
|
+
assert.equal(checklistGaps('核对既有筛选/搜索/编辑/删除/清理已完成/清空全部不回归', complete).length, 0);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// The first and last entry absorb the surrounding sentence, so verbatim
|
|
36
|
+
// matching alone would report a gap for a delivery that actually covered them.
|
|
37
|
+
test('the first and last entry match without their absorbed sentence context', () => {
|
|
38
|
+
const task = '核对既有筛选/搜索/清空全部不回归';
|
|
39
|
+
assert.equal(checklistGaps(task, '筛选 搜索 清空全部').length, 0);
|
|
40
|
+
assert.deepEqual([...checklistGaps(task, '筛选 清空全部')[0].missing], ['搜索']);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('both enumeration forms are extracted and nothing else is invented', () => {
|
|
44
|
+
const lists = extractChecklists(realTask);
|
|
45
|
+
const sizes = lists.map(list => list.items.length).sort();
|
|
46
|
+
assert.deepEqual(sizes, [3, 3, 6], `抽出来的清单不对: ${JSON.stringify(lists)}`);
|
|
47
|
+
// A two-entry pair is a phrase, not a checklist.
|
|
48
|
+
assert.deepEqual([...extractChecklists('核对新增/删除两条路径')], []);
|
|
49
|
+
assert.deepEqual([...extractChecklists('')], []);
|
|
50
|
+
assert.deepEqual([...extractChecklists(null)], []);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('results are frozen so a caller cannot edit the report into a pass', () => {
|
|
54
|
+
const gaps = checklistGaps('核对既有筛选/搜索/编辑不回归', '筛选');
|
|
55
|
+
assert.throws(() => { gaps.push({}); }, TypeError);
|
|
56
|
+
assert.throws(() => { gaps[0].missing.length = 0; }, TypeError);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Advisory means advisory. Wording differs legitimately between the task and
|
|
60
|
+
// the evidence, and this module must never be read as a verdict.
|
|
61
|
+
test('a synonym the module cannot see is reported as a gap, which is why it only advises', () => {
|
|
62
|
+
const gaps = checklistGaps('分别记录**列表为空、有未完成、全部已完成**三种情形', '空列表 有未完成 全部已完成');
|
|
63
|
+
assert.deepEqual([...gaps[0].missing], ['列表为空'],
|
|
64
|
+
'这是已知的误报:同义不同字。它只提醒,不判定。');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('oversized or non-string input yields no report instead of throwing', () => {
|
|
68
|
+
assert.deepEqual([...checklistGaps('核对既有筛选/搜索/编辑不回归', '')], []);
|
|
69
|
+
assert.deepEqual([...checklistGaps('核对既有筛选/搜索/编辑不回归', null)], []);
|
|
70
|
+
assert.deepEqual([...extractChecklists('核'.repeat(512 * 1024 + 1))], []);
|
|
71
|
+
// An evidence body past the cap is truncated, not rejected.
|
|
72
|
+
const padded = 'x'.repeat(512 * 1024) + '编辑';
|
|
73
|
+
assert.deepEqual([...checklistGaps('核对既有筛选/搜索/编辑不回归', padded)[0].missing],
|
|
74
|
+
['核对既有筛选', '搜索', '编辑不回归']);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function fixture(fn) {
|
|
78
|
+
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'cm-checklist-')));
|
|
79
|
+
try { return fn(root); } finally { fs.rmSync(root, { recursive: true, force: true }); }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The evidence usually lives in a scope file, not in the gate answers, so the
|
|
83
|
+
// reminder is worthless if it cannot read the delivery.
|
|
84
|
+
test('scope files are read, and unreadable entries contribute nothing rather than failing', () => fixture(root => {
|
|
85
|
+
fs.writeFileSync(path.join(root, 'qa.md'), '编辑 清理已完成');
|
|
86
|
+
fs.writeFileSync(path.join(root, 'big.md'), 'x'.repeat(256 * 1024 + 1));
|
|
87
|
+
fs.writeFileSync(path.join(root, 'binary.md'), Buffer.from([0x61, 0x00, 0x62]));
|
|
88
|
+
fs.symlinkSync('qa.md', path.join(root, 'link.md'));
|
|
89
|
+
fs.mkdirSync(path.join(root, 'dir.md'));
|
|
90
|
+
|
|
91
|
+
assert.match(deliveredText(root, ['qa.md']), /清理已完成/);
|
|
92
|
+
for (const entry of ['big.md', 'binary.md', 'link.md', 'dir.md', 'missing.md', '', 42])
|
|
93
|
+
assert.equal(deliveredText(root, [entry]), '', `${entry} 不该被读进来`);
|
|
94
|
+
assert.equal(deliveredText(root, 'not-an-array'), '');
|
|
95
|
+
assert.equal(deliveredText(null, ['qa.md']), '');
|
|
96
|
+
// A readable file still counts when it sits beside unreadable ones.
|
|
97
|
+
assert.match(deliveredText(root, ['missing.md', 'qa.md', 'big.md']), /编辑/);
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
// The gate's verdict is the gate's. This module reports alongside it.
|
|
101
|
+
test('the gate emits the reminder without letting it change the verdict', async () => {
|
|
102
|
+
const source = fs.readFileSync(new URL('../runtime/js/cm-ai/host-conversation-execution.mjs',
|
|
103
|
+
import.meta.url), 'utf8');
|
|
104
|
+
const gate = /const verificationGate=options\.verificationPrecheck===true\?([\s\S]*?)\n \}:null;/.exec(source);
|
|
105
|
+
assert.notEqual(gate, null, 'verificationGate not found');
|
|
106
|
+
assert.match(gate[1], /checklistGaps\(/);
|
|
107
|
+
assert.match(gate[1], /diagnostic:'checklist_coverage'/);
|
|
108
|
+
assert.match(gate[1], /advisory:true/);
|
|
109
|
+
// The returned verdict must still be the gate's own, unqualified by coverage.
|
|
110
|
+
assert.match(gate[1], /return \{satisfied:verdict\.satisfied\};/);
|
|
111
|
+
assert.equal(/satisfied:verdict\.satisfied&&/.test(gate[1]), false,
|
|
112
|
+
'coverage was folded into the verdict; it must stay advisory');
|
|
113
|
+
// Any throw inside the reminder must not reach the caller.
|
|
114
|
+
const reminder = /\/\/ Advisory only\.[\s\S]*?\}catch\{[^}]*\}/.exec(gate[1]);
|
|
115
|
+
assert.notEqual(reminder, null, 'the reminder is not wrapped in its own try/catch');
|
|
116
|
+
});
|
|
@@ -96,3 +96,21 @@ test('the batch driver decides retryability from the shared predicate', async ()
|
|
|
96
96
|
assert.equal(developmentRetryable({state:'blocked',code:'package_mismatch'}),false);
|
|
97
97
|
assert.equal(developmentRetryable({state:'unknown',code:'verification_precheck_failed'}),false);
|
|
98
98
|
});
|
|
99
|
+
|
|
100
|
+
// The gate is fed by task-runner, and the previous version sent only the
|
|
101
|
+
// verification section. Unit tests on the validator alone could not see that,
|
|
102
|
+
// which is exactly how the description requirements slipped through to the
|
|
103
|
+
// independent review. Assert the payload the runner actually builds.
|
|
104
|
+
test('the gate receives both the task description and the verification section', async () => {
|
|
105
|
+
const {default:fs}=await import('node:fs');
|
|
106
|
+
const source=fs.readFileSync(new URL('../runtime/js/cm-ai/task-runner.mjs',import.meta.url),'utf8');
|
|
107
|
+
const body=/async function verificationSatisfied\(checks\) \{([\s\S]*?)\n \}/.exec(source);
|
|
108
|
+
assert.notEqual(body,null,'verificationSatisfied not found');
|
|
109
|
+
assert.match(body[1],/specification\?\.task\?\.description/);
|
|
110
|
+
assert.match(body[1],/specification\?\.task\?\.verification/);
|
|
111
|
+
// Both must reach the payload, each only when actually written.
|
|
112
|
+
assert.match(body[1],/written\(description\)\?\{description\}/);
|
|
113
|
+
assert.match(body[1],/written\(verification\)\?\{verification\}/);
|
|
114
|
+
// The gate steps aside only when neither exists.
|
|
115
|
+
assert.match(body[1],/if\(!written\(verification\)&&!written\(description\)\)return true;/);
|
|
116
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {execFileSync} from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
import {fixHostContexts, validateCauseReviewer} from '../runtime/js/cm-fix/cause-invocation.mjs';
|
|
9
|
+
import {validateReviewDispatchGrant} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
10
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
|
+
|
|
12
|
+
const DURABLE = '01a0bfd9-e7c3-7fa2-9808-206649615754';
|
|
13
|
+
const LIVE = '01a0c2b5-c2e2-7af1-8831-d6702c9a0d16';
|
|
14
|
+
const reviewer = {reviewerId: 'fix-cause-reviewer', adapterId: 'codex-cause-review-adapter', provider: 'codex',
|
|
15
|
+
requestedModel: 'gpt-6-astra', contextId: 'fix-cause-review-context', excludedThreadIds: []};
|
|
16
|
+
|
|
17
|
+
test('the durable host always comes first and a second one is optional', () => {
|
|
18
|
+
assert.deepEqual(fixHostContexts({hostContextId: DURABLE}), [DURABLE]);
|
|
19
|
+
assert.deepEqual(fixHostContexts({hostContextId: DURABLE, hostContextIds: [DURABLE, LIVE]}), [DURABLE, LIVE]);
|
|
20
|
+
// The resumed session can never displace the session the run is bound to.
|
|
21
|
+
// A malformed id is refused by the shared id() validator, a malformed set by
|
|
22
|
+
// this function's own bound; both are refusals, so accept either code.
|
|
23
|
+
const refused = error => ['invalid_host_context', 'invalid_input'].includes(error.code);
|
|
24
|
+
for (const hosts of [[LIVE, DURABLE], [LIVE], [DURABLE, DURABLE], [DURABLE, LIVE, 'third'], [],
|
|
25
|
+
[DURABLE, ''], [DURABLE, null], 'not-an-array'])
|
|
26
|
+
assert.throws(() => fixHostContexts({hostContextId: DURABLE, hostContextIds: hosts}),
|
|
27
|
+
refused, JSON.stringify(hosts));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('a resumed session is a host, so it cannot also be the reviewer', () => {
|
|
31
|
+
assert.deepEqual(validateCauseReviewer(reviewer, [DURABLE, LIVE]), reviewer);
|
|
32
|
+
for (const host of [DURABLE, LIVE])
|
|
33
|
+
assert.throws(() => validateCauseReviewer({...reviewer, contextId: host}, [DURABLE, LIVE]),
|
|
34
|
+
{code: 'invalid_cause_reviewer'}, host);
|
|
35
|
+
// Excluding a host does not launder it into an acceptable reviewer either.
|
|
36
|
+
assert.throws(() => validateCauseReviewer({...reviewer, contextId: LIVE, excludedThreadIds: [LIVE]},
|
|
37
|
+
[DURABLE, LIVE]), {code: 'invalid_cause_reviewer'});
|
|
38
|
+
assert.throws(() => validateCauseReviewer(reviewer, [DURABLE, LIVE, 'third']), {code: 'invalid_cause_reviewer'});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// This is the claim the whole change rests on: the live session signs new grants
|
|
42
|
+
// while the durable session's old grants still replay. Neither may be widened
|
|
43
|
+
// into accepting a host the run never had.
|
|
44
|
+
test('a grant signed by either host is accepted and a third host is not', () => {
|
|
45
|
+
const request = {identity: {repositoryId: 'wue', runId: 'r', taskId: 'T-001', attempt: 1},
|
|
46
|
+
invocationId: 'invocation-1', requestDigest: digest({request: 1}), contextId: reviewer.contextId};
|
|
47
|
+
const issuedAt = 1_700_000_000_000;
|
|
48
|
+
const grantFor = hostContextId => {
|
|
49
|
+
const body = {version: 1, kind: 'cm-review-dispatch-grant', grantId: 'grant-1',
|
|
50
|
+
adapterId: reviewer.adapterId, invocationId: request.invocationId, requestDigest: request.requestDigest,
|
|
51
|
+
identity: request.identity, reviewerId: reviewer.reviewerId, logicalContextId: request.contextId,
|
|
52
|
+
packageDigest: digest({pkg: 1}), hostContextId, decisionId: 'decision-1', decision: 'approved',
|
|
53
|
+
issuedAt, expiresAt: issuedAt + 60000};
|
|
54
|
+
return {...body, grantDigest: digest(body)};
|
|
55
|
+
};
|
|
56
|
+
const expected = {request, reviewerId: reviewer.reviewerId, adapterId: reviewer.adapterId,
|
|
57
|
+
packageDigest: digest({pkg: 1}), hostContextIds: [DURABLE, LIVE],
|
|
58
|
+
authorizationAt: issuedAt, registeredAt: issuedAt + 1};
|
|
59
|
+
for (const host of [DURABLE, LIVE])
|
|
60
|
+
assert.equal(validateReviewDispatchGrant(grantFor(host), expected).hostContextId, host);
|
|
61
|
+
assert.throws(() => validateReviewDispatchGrant(grantFor('01a0c2b5-0000-0000-0000-000000000000'), expected),
|
|
62
|
+
{code: 'runner_grant'});
|
|
63
|
+
// A single-host run keeps refusing the session that never owned it.
|
|
64
|
+
assert.throws(() => validateReviewDispatchGrant(grantFor(LIVE), {...expected, hostContextIds: [DURABLE]}),
|
|
65
|
+
{code: 'runner_grant'});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// The flag exists so a new session can declare the old one. It must not become a
|
|
69
|
+
// way to plant an arbitrary host onto a run being created.
|
|
70
|
+
test('--original-host-context is refused when creating a run', () => {
|
|
71
|
+
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'cm-fix-cross-')));
|
|
72
|
+
try {
|
|
73
|
+
const cwd = path.join(root, 'code');
|
|
74
|
+
fs.mkdirSync(cwd);
|
|
75
|
+
fs.writeFileSync(path.join(cwd, 'value.mjs'), 'export const value=1;');
|
|
76
|
+
const config = path.join(root, 'controls.json');
|
|
77
|
+
fs.writeFileSync(config, JSON.stringify({specsRoot: null, identity: {repositoryId: 'fixture',
|
|
78
|
+
runId: 'cross-session', taskId: 'T-FIX-cross', attempt: 1}, defect: 'Synthetic defect for the flag check',
|
|
79
|
+
reproduction: {cwd, command: [process.execPath, '-e', "process.stderr.write('BUG');process.exit(3)"],
|
|
80
|
+
expectedFailure: {exitCode: 3, outputIncludes: 'BUG'}, timeoutMs: 1000}}));
|
|
81
|
+
const host = fileURLToPathname(new URL('./cm-fix-host.mjs', import.meta.url));
|
|
82
|
+
const run = extra => {
|
|
83
|
+
try {
|
|
84
|
+
return execFileSync(process.execPath, [host, 'serve', '--config', config, ...extra],
|
|
85
|
+
{input: '', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe']});
|
|
86
|
+
} catch (error) { return `${error.stdout ?? ''}${error.stderr ?? ''}`; }
|
|
87
|
+
};
|
|
88
|
+
assert.match(run(['--mode', 'create', '--host-context', LIVE, '--allow-reproduction',
|
|
89
|
+
'--original-host-context', DURABLE]), /fix_original_host_context_unavailable/);
|
|
90
|
+
// Creating without it gets past that refusal, which is what proves the refusal is
|
|
91
|
+
// the flag and not the rest of the launch. How far past depends on the host: the
|
|
92
|
+
// durable store needs Node >= 24.14, and CI validates on 22, where the platform
|
|
93
|
+
// gate stops the launch later in openFixExecution. Either outcome clears the flag
|
|
94
|
+
// check above it; only fix_original_host_context_unavailable would not.
|
|
95
|
+
assert.match(run(['--mode', 'create', '--host-context', LIVE, '--allow-reproduction']),
|
|
96
|
+
/host_ready|unsupported_platform/);
|
|
97
|
+
} finally { fs.rmSync(root, {recursive: true, force: true}); }
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
function fileURLToPathname(url) { return decodeURIComponent(url.pathname); }
|
|
@@ -92,3 +92,36 @@ test('legacy observation without attempts can publish, finish and resume without
|
|
|
92
92
|
assert.equal(fs.readFileSync(path.join(cwd,'visits'),'utf8'),'1');
|
|
93
93
|
}finally{owner.close();}
|
|
94
94
|
}));
|
|
95
|
+
|
|
96
|
+
const reviewer={reviewerId:'fix-cause-reviewer',adapterId:'codex-cause-review-adapter',provider:'codex',
|
|
97
|
+
requestedModel:'gpt-6-astra',contextId:'fix-cause-review-context',excludedThreadIds:[]};
|
|
98
|
+
const statePath=options=>path.join(options.specsRoot,'.reviews','.execution',identity.runId,'state.json');
|
|
99
|
+
|
|
100
|
+
test('a later session resumes the original run without rewriting its records',()=>fixture(async(options,cwd)=>{
|
|
101
|
+
const bridge=createHostToolBridge();
|
|
102
|
+
bridge.attach(row=>{if(row.type==='host_request')bridge.accept({type:'host_result',sessionId:row.sessionId,
|
|
103
|
+
callId:row.callId,requestDigest:row.requestDigest,result:cause});});
|
|
104
|
+
let owner=openFixExecution(options,{bridge});
|
|
105
|
+
try{assert.equal((await owner.advance({authorized:true})).stage,'red_test_required');}finally{owner.close();}
|
|
106
|
+
const before=fs.readFileSync(statePath(options));
|
|
107
|
+
// The chat session that created the run is gone; the durable record keeps it.
|
|
108
|
+
owner=openFixExecution({...options,create:false,hostContextId:'actual-resumed-host'},{bridge});
|
|
109
|
+
try{
|
|
110
|
+
assert.equal((await owner.advance()).stage,'red_test_required');
|
|
111
|
+
assert.equal(fs.readFileSync(path.join(cwd,'visits'),'utf8'),'1');
|
|
112
|
+
}finally{owner.close();bridge.close();}
|
|
113
|
+
assert.deepEqual(fs.readFileSync(statePath(options)),before);
|
|
114
|
+
assert.equal(JSON.parse(before).records[0].payload.configuration.hostContextId,'actual-fixture-host');
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
test('resuming never rewrites the durable host or accepts a reviewer-shaped session',()=>fixture(async(options)=>{
|
|
118
|
+
const configuration={...options.configuration,causeReview:reviewer};
|
|
119
|
+
openFixExecution({...options,configuration}).close();
|
|
120
|
+
// Moving the durable host is still a different run configuration.
|
|
121
|
+
assert.throws(()=>openFixExecution({...options,configuration,create:false,
|
|
122
|
+
configuration:{...configuration,hostContextId:'other-host'}}),{code:'fingerprint_mismatch'});
|
|
123
|
+
// A resumed session is still a host, so it cannot be the independent reviewer.
|
|
124
|
+
assert.throws(()=>openFixExecution({...options,configuration,create:false,
|
|
125
|
+
hostContextId:reviewer.contextId}),{code:'invalid_cause_reviewer'});
|
|
126
|
+
openFixExecution({...options,configuration,create:false,hostContextId:'actual-resumed-host'}).close();
|
|
127
|
+
}));
|
package/scripts/cm-fix-host.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {id,json,need,shape,digest} from '../runtime/js/cm-ai/effect-contract.mjs
|
|
|
11
11
|
import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
|
|
12
12
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
13
13
|
|
|
14
|
-
const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--runtime codex|claude] [--review-config PATH] [--allow-cause-review] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime defaults to codex; claude uses its own matching diagnostic receipt and cannot reuse Codex preflight or disabledSkills settings. Runtime selection is bound to recovery; switching providers requires a separate run. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
|
|
14
|
+
const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--original-host-context ID] [--runtime codex|claude] [--review-config PATH] [--allow-cause-review] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime defaults to codex; claude uses its own matching diagnostic receipt and cannot reuse Codex preflight or disabledSkills settings. Runtime selection is bound to recovery; switching providers requires a separate run. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
|
|
15
15
|
|
|
16
16
|
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr,reviewWorkerFactory=null}={}){
|
|
17
17
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Omit specsRoot or use null for a bare project: the same owner stores archives in docs/fixes and reviews in docs/fixes/.reviews, uses the original no-specs log mode, and skips METRICS. No specs skeleton is created. Visual-only reproduction/redTest may use kind:visual with cwd, timeoutMs, before:{path,sha256,kind:screenshot|video,description}, reason explaining why automated red cannot be written, environment, steps and expected; redTest also has testFiles:[]. No testAuthor or fake red/green command. Repair/regression/review/finish permissions remain mandatory. qa_browser returns actual after carrier metadata; missing evidence blocks.\n');
|
|
@@ -20,8 +20,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
20
20
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('recover_final_review requires --allow-final-review-recovery and exact latest invocationId/packageDigest, previousInvocationStopped:true, and a nonempty reason. The legacy first continuation remains once-only. A further continuation additionally requires a fresh startup --final-review-recovery-invocation ID matching the latest unknown invocation, authorizing exactly one new call. Confirm the previous process stopped; this is a trusted host acknowledgment, not an automatic liveness check. Preparation dispatches nothing. Later final_review requires recovery permission and --allow-final-review; additional cycles require the same invocation binding after restart. Old records, task attempt, reviewed package and the original Review/N5/finish remain unchanged. No automatic retry, cancelled/complete-verdict recovery, missing-thread recovery, business-revision recovery or source-drift bypass. status adds a read-only progress projection, not authorization or current-source verification.\n');
|
|
21
21
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('N6 child configuration may include qaSource {feature, identity, packageDigest, testRunId, handoffDigest}; derive the separate fixed child identity with qaFixIdentity. It requires --allow-qa-fix in addition to existing action flags. Close the parent host first: the original specs-wide owner lock is shared. Creation/resume rechecks the current failed round, project, report and policy; the source is bound to the original fix configuration. This does not resume the parent or automatically rerun QA, and does not authorize provider calls, installation or Git.\n');
|
|
22
22
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Second-round retrospective uses the cumulative original baseline, including previously authored tests and Learning scope. It persists the current round reflection and reaches revision_handoff_ready or revision_learning_writeback_required; neither state completes the task or publishes a new handoff. From revision_handoff_ready, handoff publishes a separate a2 handoff containing cumulative changes, current reflection, original red evidence and prior review/Learning history; final_review_package then reads that bound package. Pending Learning blocks publication. final_review requires --allow-final-review, uses fresh-thread exclusions and carries prior findings; publish_review writes the original r2 evidence and review log, and check_n5 runs the original Learning-aware gate. Approval reaches revision_post_review_regression_required, not completion.\n');
|
|
23
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('prepare_revision requires --allow-repair and either a published first-round changes_requested review or an approved first-round review followed by a package-bound walkthrough result of failed. The latter preserves the approved verdict and carries separate walkthrough failure evidence; passed, blocked, unknown, or drifted evidence cannot authorize this repair. An approved first-round review followed by package-bound post-review regression defect_remaining or regressed can also prepare the second repair when all baseline commands produced complete results. The regression commands must match the first reviewed handoff; passed, inconclusive, unavailable or partial evidence is refused. Regression and walkthrough failure feedback are mutually exclusive and neither replaces the next independent review. It rereads project Learning and persists the second-round preparation in the original store, preserving first-round evidence. repair then uses the original business scope and findings with separate second-round records. regression requires --allow-regression and reruns the original test commands against the second repair, preserving the original red evidence. Success reaches revision_handoff_required, not completion; handoff and final_review use the second-round package; review evidence publication and N5 are connected; post_review_regression requires --allow-regression and reaches revision_closeout_required after the original checks; walkthrough requires --allow-walkthrough and binds the second-round package and identity; finish reuses the original closeout with --allow-finish
|
|
24
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nAdditional operation: publish_dossier writes a private immutable fixes/YYYYMMDD-slug.md closeout snapshot; missing evidence is explicit and the task remains incomplete. In observation it writes the recorded reproduction summary and expected evidence to the same fixes archive, preserving its date across restart and refusing user-content conflicts; it does not repair or complete the task. In observation, finish with --allow-finish records run_done as observing and releases the owner lock without task_done or metrics; end the existing transport with host_close or EOF. resume accepts evidenceFiles (1-3 explicit specs-local files) and binds them to the prior observing exit and dossier without resetting task attempt. It reaches observation_resume_prepared; evidence drift blocks continuation. advance from prepared rereads Learning and reruns the original reproduction command, then passes selected evidence references to the original diagnosis capability. Recovery uses separate records without resetting attempt; unknown outcomes are not redispatched. Unreproduced, blocked or still-insufficient evidence stays incomplete. Before resumed execution, the original resume log binds the observation exit and selected evidence digests, restoring the same run to running without a new task start. Recovered handoffs bind exact selected evidence bytes and pre-observation history under the original size and review gates; legacy recovered handoffs lacking that material remain readable but cannot claim current review coverage. Recovered closeout preserves the exact observation archive prefix and original filename, appends the recovery results, and uses the existing finish gate; user-modified continuations are refused. If recovery still cannot reproduce the defect or diagnosis still needs evidence, publish_dossier appends the latest observation and authorized finish records a second bound observing exit without task completion or metrics. After a recorded observing exit, resume can bind another explicit evidence selection to the latest exit and archive. Observation cycles retain prior records and archive bytes, do not reset task attempts or review rounds, and require separately authorized advance; unknown outcomes are not retried. Multi-cycle handoffs include the exact prior archive under the original size limit. walkthrough requires configured module-mapped flows and --allow-walkthrough; it runs declared commands or uses existing qa_browser/qa_logic host capabilities. Static support cannot pass a walkthrough. Browser execution remains limited to the authorized current-host environment; no install or provider authority is implied.\nRepair completion via finish requires --allow-finish,
|
|
23
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('prepare_revision requires --allow-repair and either a published first-round changes_requested review or an approved first-round review followed by a package-bound walkthrough result of failed. The latter preserves the approved verdict and carries separate walkthrough failure evidence; passed, blocked, unknown, or drifted evidence cannot authorize this repair. An approved first-round review followed by package-bound post-review regression defect_remaining or regressed can also prepare the second repair when all baseline commands produced complete results. The regression commands must match the first reviewed handoff; passed, inconclusive, unavailable or partial evidence is refused. Regression and walkthrough failure feedback are mutually exclusive and neither replaces the next independent review. It rereads project Learning and persists the second-round preparation in the original store, preserving first-round evidence. repair then uses the original business scope and findings with separate second-round records. regression requires --allow-regression and reruns the original test commands against the second repair, preserving the original red evidence. Success reaches revision_handoff_required, not completion; handoff and final_review use the second-round package; review evidence publication and N5 are connected; post_review_regression requires --allow-regression and reaches revision_closeout_required after the original checks; walkthrough requires --allow-walkthrough and binds the second-round package and identity; finish reuses the original closeout with --allow-finish, preserving first-round history and recording completion for attempt 2. Second-round learning_writeback requires --allow-learning-writeback, includes the resulting AGENTS.md in the cumulative review package and preserves prior Learning history; pending or unknown writeback cannot advance to handoff. A lost repair or regression result stays unknown and is not redispatched.\n');
|
|
24
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nAdditional operation: publish_dossier writes a private immutable fixes/YYYYMMDD-slug.md closeout snapshot; missing evidence is explicit and the task remains incomplete. In observation it writes the recorded reproduction summary and expected evidence to the same fixes archive, preserving its date across restart and refusing user-content conflicts; it does not repair or complete the task. In observation, finish with --allow-finish records run_done as observing and releases the owner lock without task_done or metrics; end the existing transport with host_close or EOF. resume accepts evidenceFiles (1-3 explicit specs-local files) and binds them to the prior observing exit and dossier without resetting task attempt. It reaches observation_resume_prepared; evidence drift blocks continuation. advance from prepared rereads Learning and reruns the original reproduction command, then passes selected evidence references to the original diagnosis capability. Recovery uses separate records without resetting attempt; unknown outcomes are not redispatched. Unreproduced, blocked or still-insufficient evidence stays incomplete. Before resumed execution, the original resume log binds the observation exit and selected evidence digests, restoring the same run to running without a new task start. Recovered handoffs bind exact selected evidence bytes and pre-observation history under the original size and review gates; legacy recovered handoffs lacking that material remain readable but cannot claim current review coverage. Recovered closeout preserves the exact observation archive prefix and original filename, appends the recovery results, and uses the existing finish gate; user-modified continuations are refused. If recovery still cannot reproduce the defect or diagnosis still needs evidence, publish_dossier appends the latest observation and authorized finish records a second bound observing exit without task completion or metrics. After a recorded observing exit, resume can bind another explicit evidence selection to the latest exit and archive. Observation cycles retain prior records and archive bytes, do not reset task attempts or review rounds, and require separately authorized advance; unknown outcomes are not retried. Multi-cycle handoffs include the exact prior archive under the original size limit. walkthrough requires configured module-mapped flows and --allow-walkthrough; it runs declared commands or uses existing qa_browser/qa_logic host capabilities. Static support cannot pass a walkthrough. Browser execution remains limited to the authorized current-host environment; no install or provider authority is implied.\nRepair completion via finish requires --allow-finish, a reviewed diagnosis, a modern handoff and a passed walkthrough. It accepts any configured policies.delivery and only requires that the mode stay unchanged while completion records are written; Git delivery is a separate logged event, not a precondition. It rechecks the original N5 gate, finalizes the generated dossier, records reviewed lessons, task_done, metrics and run_done. It resumes partial closeout without redispatch and refuses user-modified dossier conflicts. Branch/MR delivery still requires separate authorization; this command does not execute Git.\n');return 0;}
|
|
25
25
|
let owner,bridge;
|
|
26
26
|
try{
|
|
27
27
|
need(argv.length>=8&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--mode'
|
|
@@ -29,10 +29,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
29
29
|
need(['create','resume'].includes(argv[4]),'invalid_arguments');id(argv[6]);
|
|
30
30
|
const extra=new Map();
|
|
31
31
|
for(let index=8;index<argv.length;index++){
|
|
32
|
-
const flag=argv[index];need(!extra.has(flag)&&['--runtime','--review-config','--final-review-recovery-invocation','--allow-qa-fix','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
32
|
+
const flag=argv[index];need(!extra.has(flag)&&['--runtime','--review-config','--original-host-context','--final-review-recovery-invocation','--allow-qa-fix','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
33
33
|
if(flag.startsWith('--allow-'))extra.set(flag,true);
|
|
34
34
|
else{need(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments');extra.set(flag,argv[++index]);}
|
|
35
35
|
}
|
|
36
|
+
// A run created in an earlier session keeps that session in its durable record.
|
|
37
|
+
// Resume declares it here so the stored fingerprint and history still match,
|
|
38
|
+
// while --host-context stays the real current session for every live decision.
|
|
39
|
+
const originalHostContext=extra.get('--original-host-context')??null;
|
|
40
|
+
if(originalHostContext!==null){id(originalHostContext);need(argv[4]==='resume','fix_original_host_context_unavailable');}
|
|
36
41
|
const recoveryInvocationId=extra.get('--final-review-recovery-invocation')??null;
|
|
37
42
|
if(recoveryInvocationId!==null){id(recoveryInvocationId);need(extra.has('--allow-final-review-recovery'),'fix_review_recovery_authorization_required');}
|
|
38
43
|
const runtime=extra.get('--runtime')??'codex';need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
@@ -61,7 +66,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
61
66
|
permissions:[...extra.keys()],workerFactory:reviewWorkerFactory});
|
|
62
67
|
bridge=createHostToolBridge();
|
|
63
68
|
owner=openFixExecution({specsRoot:config.specsRoot??null,identity:config.identity,create:argv[4]==='create',
|
|
64
|
-
|
|
69
|
+
hostContextId:argv[6],
|
|
70
|
+
configuration:{hostContextId:originalHostContext??argv[6],defect:config.defect,reproduction:config.reproduction,
|
|
65
71
|
...(Object.hasOwn(config,'protectSpecs')?{protectSpecs:config.protectSpecs}:{}),
|
|
66
72
|
...(Object.hasOwn(config,'qaSource')?{qaSource:config.qaSource}:{}),
|
|
67
73
|
...(runtime==='claude'?{runtime}:{}),
|