@aibyzero/cm-workflow 0.16.5 → 0.16.7
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/AGENTS.md +14 -0
- package/CHANGELOG.md +19 -1
- package/README.md +17 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +28 -7
- package/docs/js-workflow-control.md +96 -6
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +34 -10
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +9 -5
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -34
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +93 -31
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +13 -57
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +34 -15
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +8 -5
- package/runtime/js/cm-ai/drive-bootstrap.mjs +22 -12
- package/runtime/js/cm-ai/drive-core.mjs +9 -3
- package/runtime/js/cm-ai/durable-runner-state.mjs +146 -14
- package/runtime/js/cm-ai/effect-contract.mjs +1 -1
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/host-bootstrap.mjs +70 -20
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +59 -17
- package/runtime/js/cm-ai/host-documentation.mjs +2 -2
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +54 -8
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +22 -5
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +3 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +36 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +15 -0
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/review-package.mjs +11 -0
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-runner.mjs +176 -25
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +183 -40
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/finish.mjs +2 -19
- package/runtime/js/cm-fix/host-review.mjs +25 -6
- package/runtime/js/cm-fix/host.mjs +4 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/log-events.mjs +29 -0
- package/runtime/js/cm-fix/metrics.mjs +3 -2
- package/runtime/js/cm-fix/progress.mjs +4 -0
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-host.mjs +2 -1
- package/runtime/js/cm-prd/review-publication.mjs +23 -13
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/cm-test/recovery.mjs +4 -4
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-admission.mjs +14 -3
- package/scripts/cm-ai-batch-drive.mjs +52 -23
- package/scripts/cm-ai-batch-drive.test.mjs +47 -2
- package/scripts/cm-ai-batch-host.mjs +44 -16
- package/scripts/cm-ai-batch-run.mjs +77 -29
- package/scripts/cm-ai-bootstrap-flow.test.mjs +3 -2
- package/scripts/cm-ai-bootstrap-merge.test.mjs +118 -1
- package/scripts/cm-ai-bootstrap.test.mjs +80 -87
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +15 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +102 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +2 -2
- package/scripts/cm-ai-drive.mjs +73 -28
- package/scripts/cm-ai-drive.test.mjs +119 -1
- package/scripts/cm-ai-feature-selection.test.mjs +178 -0
- package/scripts/cm-ai-host.mjs +79 -27
- package/scripts/cm-ai-host.test.mjs +88 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-protected-scope.test.mjs +194 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +21 -0
- package/scripts/cm-ai-review-failure.test.mjs +71 -11
- package/scripts/cm-ai-run.mjs +94 -19
- package/scripts/cm-ai-run.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-check-drive.test.mjs +1 -0
- package/scripts/cm-check-runtime.sh +11 -0
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +1 -1
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-fix-drive.mjs +28 -13
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +17 -10
- package/scripts/cm-fix-large-log.test.mjs +113 -0
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +7 -1
- package/scripts/cm-host-qa-executor.test.mjs +329 -3
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +34 -7
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +26 -6
- package/scripts/cm-prd-host.test.mjs +4 -0
- package/scripts/cm-prd-review-host.test.mjs +17 -0
- package/scripts/cm-prd-session-recovery.test.mjs +44 -2
- package/scripts/cm-prd-task-grouping.test.mjs +206 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-scope-recovery.test.mjs +5 -3
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +146 -10
- package/scripts/cm-task-gate.py +1 -0
- package/scripts/cm-test-branch-impact.test.mjs +11 -0
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +3 -1
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +10 -1
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +16 -7
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +30 -2
- package/skills/cm-prd/SKILL.md +5 -4
- package/skills/cm-prd/references/spec-self-check.md +3 -1
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {selectExternalModels} from '../cm-ai/external-models.mjs';
|
|
2
|
+
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
3
|
+
import {createNativeUsageLog} from '../cm-ai/native-usage-log.mjs';
|
|
1
4
|
// Shared fix-specific diagnostics, authorities and lazy provider adapters.
|
|
2
5
|
import {fileURLToPath} from 'node:url';
|
|
3
6
|
import {codexWorker,preflightMatches} from '../cm-ai/worker-codex.mjs';
|
|
@@ -9,9 +12,12 @@ import {fixFinalReviewConfiguration} from './final-review.mjs';
|
|
|
9
12
|
import {digest,id,json,need} from '../cm-ai/effect-contract.mjs';
|
|
10
13
|
|
|
11
14
|
const DEFAULT_REVIEW_TIMEOUT_MS=900000;
|
|
12
|
-
export function createFixReviewHost({codeProject,hostContextId,runtime='codex',review=null,permissions=[],workerFactory=null}){
|
|
15
|
+
export function createFixReviewHost({codeProject,hostContextId,runtime='codex',review=null,permissions=[],workerFactory=null,externalModels=null,executionPolicy=null,specsDir=null}){
|
|
13
16
|
id(hostContextId);need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
17
|
+
const policy=executionPolicy===null?null:readExecutionPolicy(executionPolicy);
|
|
14
18
|
const allowed=new Set(json(permissions)),config=review===null?null:json(review);
|
|
19
|
+
const pair=externalModels?selectExternalModels(externalModels,[runtime]).providers[runtime]:null;
|
|
20
|
+
need(!pair||!config||(config.model===pair.model&&config.effort===pair.effort),'external_model_pair_conflict');
|
|
15
21
|
const matches=runtime==='claude'?claudePreflightMatches:preflightMatches;
|
|
16
22
|
const worker=workerFactory??(runtime==='claude'?claudeWorker:codexWorker);
|
|
17
23
|
need(runtime!=='claude'||!config||config.disabledSkills.length===0,'invalid_review_config');
|
|
@@ -20,23 +26,36 @@ export function createFixReviewHost({codeProject,hostContextId,runtime='codex',r
|
|
|
20
26
|
// Review transport budget from the review configuration (outside its
|
|
21
27
|
// authorized digest), shared by the worker and the owner's review watchdog.
|
|
22
28
|
const timeoutMs=config?.timeoutMs??DEFAULT_REVIEW_TIMEOUT_MS;
|
|
23
|
-
const workerOptions=config?{cwd:codeProject,model:config.model,disabledSkills:config.disabledSkills,
|
|
29
|
+
const workerOptions=config?{cwd:codeProject,model:config.model,...(pair?{effort:pair.effort}:{}),disabledSkills:config.disabledSkills,
|
|
24
30
|
promptTransport:'stdin',preflight:config.preflight,timeoutMs,
|
|
25
31
|
schemaPath:fileURLToPath(new URL('../cm-ai/review-result.schema.json',import.meta.url))}:null;
|
|
26
32
|
const assertReviewReady=()=>need(config&&matches(config.preflight,workerOptions),'tool_preflight_missing');
|
|
27
33
|
if(enabled)assertReviewReady();
|
|
28
34
|
const reviewer=config?{reviewerId:'fix-cause-reviewer',adapterId:`${runtime}-cause-review-adapter`,provider:runtime,
|
|
29
35
|
requestedModel:config.model,contextId:'fix-cause-review-context',excludedThreadIds:[],
|
|
30
|
-
workerConfigurationDigest:digest({cwd:codeProject,model:config.model,disabledSkills:config.disabledSkills,
|
|
31
|
-
promptTransport:'stdin',...(runtime==='claude'?{runtime}:{})})}:null;
|
|
36
|
+
workerConfigurationDigest:digest({cwd:codeProject,model:config.model,...(pair?{effort:pair.effort}:{}),disabledSkills:config.disabledSkills,
|
|
37
|
+
promptTransport:'stdin',...(runtime==='claude'?{runtime}:{}),...(policy?{executionPolicy:policy}:{})})}:null;
|
|
32
38
|
const authorityFor=(reviewer,permission)=>createHostReviewAuthority({hostContextId,
|
|
33
39
|
reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,
|
|
34
40
|
decide:async()=>allowed.has(permission)?{status:'approved'}:{status:'denied',code:'permission_denied'}});
|
|
35
41
|
const authority=config?authorityFor(reviewer,'--allow-cause-review'):null;
|
|
36
42
|
const finalAuthority=config?authorityFor(fixFinalReviewConfiguration({hostContextId,causeReview:reviewer}).reviewer,'--allow-final-review'):null;
|
|
43
|
+
const runReview=(request,control,cause)=>{
|
|
44
|
+
let log=null,usage={usage_state:'unavailable'},result;
|
|
45
|
+
const native=worker({...workerOptions,...(policy?{onUsage:value=>{usage=value;},onUsageClaim:()=>{
|
|
46
|
+
log??=createNativeUsageLog({definition:{codeProject,specsDir,feature:request.identity.feature??'fix'},request,provider:runtime,role:'reviewer',workflow:'cm-fix'});
|
|
47
|
+
log.claimed();
|
|
48
|
+
}}: {})});
|
|
49
|
+
const complete=()=>log?.complete(usage,control.signal.aborted?'cancelled':result?.status==='succeeded'?'success':'error');
|
|
50
|
+
try{
|
|
51
|
+
const pending=(cause?createCauseReviewRun(native,runtime,policy):(runtime==='claude'?createClaudeReviewRun:createCodexReviewRun)(native,policy))(request,control);
|
|
52
|
+
if(!policy)return pending;
|
|
53
|
+
return Promise.resolve(pending).then(value=>{result=value;return value;}).finally(complete);
|
|
54
|
+
}catch(error){complete();throw error;}
|
|
55
|
+
};
|
|
37
56
|
return {reviewer,authority,finalAuthority,execution:{assertReviewReady,
|
|
38
57
|
...(config?{causeReview:{authorize:authority.authorize,timeoutMs,
|
|
39
|
-
run:(request,control)=>
|
|
58
|
+
run:(request,control)=>runReview(request,control,true)},
|
|
40
59
|
finalReview:{authorize:finalAuthority.authorize,timeoutMs,run:(request,control)=>
|
|
41
|
-
(
|
|
60
|
+
runReview(request,control,false)}}:{})}};
|
|
42
61
|
}
|
|
@@ -9,8 +9,9 @@ export function createFixHost({owner,config,runtime='codex',permissions=[],autho
|
|
|
9
9
|
const extra=new Set(permissions);
|
|
10
10
|
const host={async handle(request){
|
|
11
11
|
shape(request,['requestId','operation',...(request.operation==='resume'?['evidenceFiles']:[]),
|
|
12
|
-
...(['abandon_step','abandon_review'].includes(request.operation)&&Object.hasOwn(request,'reason')?['reason']:[]),
|
|
12
|
+
...(['abandon_step','abandon_review','rediagnose'].includes(request.operation)&&Object.hasOwn(request,'reason')?['reason']:[]),
|
|
13
13
|
...(request.operation==='prepare_revision'&&Object.hasOwn(request,'tests')?['tests']:[]),
|
|
14
|
+
...(request.operation==='reconcile_review'?['invocationId']:[]),
|
|
14
15
|
...(request.operation==='recover_final_review'?['invocationId','packageDigest','previousInvocationStopped','reason']:[])]);
|
|
15
16
|
if(config.qaSource&&!['status','cancel','completion_evidence'].includes(request.operation))
|
|
16
17
|
inspectFixQaSource({specsRoot:config.specsRoot,identity:config.identity,configuration:config});
|
|
@@ -23,12 +24,14 @@ export function createFixHost({owner,config,runtime='codex',permissions=[],autho
|
|
|
23
24
|
return {...status,progress:fixProgress(status,config,{finalReviewAllowed:finalAuthority!==null
|
|
24
25
|
&&extra.has('--allow-final-review')&&recoveryAllowed})};
|
|
25
26
|
}
|
|
27
|
+
if(request.operation==='reconcile_review')return owner.reconcileReview({invocationId:request.invocationId});
|
|
26
28
|
if(request.operation==='recover_final_review')return owner.recoverFinalReview({
|
|
27
29
|
authorized:extra.has('--allow-final-review-recovery'),recoveryInvocationId,invocationId:request.invocationId,
|
|
28
30
|
packageDigest:request.packageDigest,previousInvocationStopped:request.previousInvocationStopped,reason:request.reason});
|
|
29
31
|
if(request.operation==='abandon_step')return owner.abandonStep({authorized:extra.has('--allow-abandon'),reason:request.reason});
|
|
30
32
|
// Reviewer-invocation authority stays separate from local step abandonment.
|
|
31
33
|
if(request.operation==='abandon_review')return owner.abandonReview({authorized:extra.has('--allow-abandon-review'),reason:request.reason});
|
|
34
|
+
if(request.operation==='rediagnose')return owner.rediagnose({authorized:extra.has('--allow-rediagnosis'),reason:request.reason});
|
|
32
35
|
if(request.operation==='completion_evidence')return owner.completionEvidence();
|
|
33
36
|
if(request.operation==='finish')return owner.finish({authorized:extra.has('--allow-finish')});
|
|
34
37
|
if(request.operation==='author_tests')return owner.authorTests({authorized:extra.has('--allow-test-author')});
|
|
@@ -30,7 +30,7 @@ export function fixEvidenceNames(identity,configuration){
|
|
|
30
30
|
// 只列这次配置真的会写的文件,免得拦下根本不会发生的冲突。
|
|
31
31
|
if(configuration.redTest&&configuration.redTest.kind!=='visual')
|
|
32
32
|
names.push(`fix-${slug}-a${identity.attempt}-red-output.md`);
|
|
33
|
-
if(configuration.causeReview)names.push(`fix-${slug}-cause-r1.md`);
|
|
33
|
+
if(configuration.causeReview)names.push(`fix-${slug}-cause-r1.md`,`fix-${slug}-cause-r2.md`);
|
|
34
34
|
return names;
|
|
35
35
|
}
|
|
36
36
|
// 名字被占时分两种:审查结论(-r{n}.md / -cause-r{n}.md)是别人签过字的证据,绝不
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// cm-fix's view of the run log: its own rows, in log order. The log only grows;
|
|
2
|
+
// reading it whole under the 1 MiB review-material limit made every fix run fail
|
|
3
|
+
// at completion once a project's 运行日志.jsonl passed 1 MiB (2026-10-07,
|
|
4
|
+
// api-native-reading-fix-story-return). Read it line by line, with the same file
|
|
5
|
+
// guarantees as before; callers still select their own run identity.
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {readStableLogRows} from '../cm-ai/log-rows.mjs';
|
|
9
|
+
import {need} from '../cm-ai/effect-contract.mjs';
|
|
10
|
+
|
|
11
|
+
const fixRows=file=>readStableLogRows(file,row=>row!==null&&typeof row==='object'&&!Array.isArray(row)&&row.workflow==='cm-fix','fix_log_failed');
|
|
12
|
+
export function eventsAt(specsRoot,configuration={}){
|
|
13
|
+
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
14
|
+
if(configuration.archiveMode==='bare'){
|
|
15
|
+
const directory=path.join(specsRoot,'.reviews','host-log-mirror','runs');
|
|
16
|
+
if(!fs.existsSync(directory))return [];
|
|
17
|
+
need(fs.realpathSync(directory)===directory,'fix_log_failed');
|
|
18
|
+
const rows=[];
|
|
19
|
+
for(const month of fs.readdirSync(directory).sort()){
|
|
20
|
+
need(/^\d{4}-\d{2}$/.test(month)&&fs.realpathSync(path.join(directory,month))===path.join(directory,month),'fix_log_failed');
|
|
21
|
+
for(const file of fs.readdirSync(path.join(directory,month)).sort())
|
|
22
|
+
if(file.endsWith('.jsonl'))rows.push(...fixRows(path.join(directory,month,file)));
|
|
23
|
+
}
|
|
24
|
+
return rows;
|
|
25
|
+
}
|
|
26
|
+
const log=path.join(specsRoot,'运行日志.jsonl');
|
|
27
|
+
if(!fs.existsSync(log))return [];
|
|
28
|
+
return fixRows(log);
|
|
29
|
+
}
|
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import {types} from 'node:util';
|
|
6
6
|
import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
|
|
7
|
+
import {eventsAt} from './log-events.mjs';
|
|
7
8
|
import {id,need,validIdentity} from '../cm-ai/effect-contract.mjs';
|
|
8
9
|
import {METRICS_HEADER as header,METRICS_SEPARATOR as separator,hasMetricsHeader} from '../cm-ai/metrics-table.mjs';
|
|
9
10
|
const cell=value=>String(value).replaceAll('|','|').replace(/[\r\n]+/g,' ');
|
|
@@ -43,8 +44,8 @@ export function appendFixMetrics({specsRoot,identity,dossierFile},{assertOwned})
|
|
|
43
44
|
};
|
|
44
45
|
owned();
|
|
45
46
|
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
46
|
-
|
|
47
|
-
const events=
|
|
47
|
+
// Streamed: the log may exceed the 1 MiB review-material limit (see log-events.mjs).
|
|
48
|
+
const events=eventsAt(specsRoot);
|
|
48
49
|
const record=fixMetricsRow({events,identity,dossierFile});
|
|
49
50
|
const [dossier]=readReviewSourceFiles(specsRoot,[`fixes/${dossierFile}`]);
|
|
50
51
|
const completion=events.find(event=>event.event_id===record.completionEventId);
|
|
@@ -33,6 +33,10 @@ export function fixProgress(status,config={},authorization={}){
|
|
|
33
33
|
blocker:null,nextAction:null,requiresUser:false,finished:done,
|
|
34
34
|
evidenceScope:'recorded_history_not_fresh_execution',remainingScope:'current_path_not_future_revisions'};
|
|
35
35
|
if(done){result.remaining=[];return result;}
|
|
36
|
+
if(stage==='rediagnosis_required')return {...result,current:'根因审查要求重新诊断',blocker:stage,
|
|
37
|
+
nextAction:'原 run 使用 rediagnose(--allow-rediagnosis、reason);处理原 findings 后重新独立审查,保留 cause-r1。',requiresUser:true};
|
|
38
|
+
if(stage==='rediagnosis_review_limit_reached')return {...result,current:'第二次根因审查仍未通过',blocker:stage,
|
|
39
|
+
nextAction:'保留两次审查和诊断;交用户判断,不继续重派或重建身份。',requiresUser:true};
|
|
36
40
|
if(stage==='escalated')return {...result,current:'已升级立项,修复未完成',remaining:[],nextAction:null};
|
|
37
41
|
if(stage==='cancelled')return {...result,current:'任务已取消',blocker:'cancelled',nextAction:'保留历史,不自动恢复。',requiresUser:true};
|
|
38
42
|
if(status.executionActive===true)return {...result,current:'当前操作正在执行',nextAction:'等待当前操作结果,不重发或申请续审。'};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Owner journal evidence only. Public requests supply invocationId, never receipts.
|
|
2
|
+
import {digest,json,need,shape} from '../cm-ai/effect-contract.mjs';
|
|
3
|
+
import {readReconciliationReceipt} from '../cm-ai/review-reconciliation.mjs';
|
|
4
|
+
import {inspectProviderReview,inspectProviderCauseReview,inspectProviderReviewReconciliation} from '../cm-ai/provider-review-observation.mjs';
|
|
5
|
+
|
|
6
|
+
export function inspectFixReconciledResult(value,expectation,cause=false){
|
|
7
|
+
const receipt=readReconciliationReceipt(value.reconciliationReceipt);
|
|
8
|
+
const original=value.observation;
|
|
9
|
+
const checked=(cause?inspectProviderCauseReview:inspectProviderReview)(JSON.stringify(original),JSON.stringify(expectation));
|
|
10
|
+
need(checked.observationStatus!=='completed'&&Array.isArray(receipt.events)
|
|
11
|
+
&&receipt.events.length<=64&&receipt.events.length>=original.events.length,'review_reconciliation_evidence_required');
|
|
12
|
+
need(digest(original.events)===digest(receipt.events.slice(0,original.events.length)),'review_reconciliation_binding');
|
|
13
|
+
const observation={...original,events:receipt.events,result:receipt.result};
|
|
14
|
+
const result=inspectProviderReviewReconciliation(JSON.stringify(observation),JSON.stringify(expectation),cause);
|
|
15
|
+
// A failed original call has stopped, but cannot become an approving receipt.
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function fixReviewLedger(records,configuration){
|
|
20
|
+
const receipts=new Map(),applied=new Set(),overlays=new Map();
|
|
21
|
+
for(const row of records){
|
|
22
|
+
if(!/^fix-review-(receipt|reconciled)-[0-9a-f]{24}$/.test(row.id))continue;
|
|
23
|
+
need((configuration.externalModels||configuration.executionPolicy)&&row.kind==='result','fix_history_invalid');
|
|
24
|
+
const p=json(row.payload,1024*1024),isReceipt=row.id.startsWith('fix-review-receipt-');
|
|
25
|
+
shape(p,['prefix','invocationId','registeredDigest','startedDigest','resultDigest',...(isReceipt?['receipt']:['receiptDigest'])]);
|
|
26
|
+
need(/^fix-(?:cause(?:-(?:retry|rediagnosis))?|(?:revision-)?final(?:-(?:retry|recovery(?:-[1-9]\d*)?))?)$/.test(p.prefix),'review_reconciliation_binding');
|
|
27
|
+
need(row.id===`fix-review-${isReceipt?'receipt':'reconciled'}-${digest(p.invocationId).slice(0,24)}`,'review_reconciliation_binding');
|
|
28
|
+
const prior=records.filter(r=>r.seq<row.seq);
|
|
29
|
+
const registration=prior.find(r=>r.id===p.prefix+'-registered'),started=prior.find(r=>r.id===p.prefix+'-started'),result=prior.find(r=>r.id===p.prefix+'-result');
|
|
30
|
+
need(registration&&started&&result&®istration.seq<started.seq&&started.seq<result.seq
|
|
31
|
+
&®istration.payload.request.invocationId===p.invocationId
|
|
32
|
+
&&digest(registration)===p.registeredDigest&&digest(started)===p.startedDigest&&digest(result)===p.resultDigest,'review_reconciliation_binding');
|
|
33
|
+
need(prior.filter(r=>r.seq>result.seq).every(r=>/^fix-host-joined-/.test(r.id)||/^fix-review-(?:receipt|reconciled)-/.test(r.id)),
|
|
34
|
+
'review_reconciliation_unavailable');
|
|
35
|
+
const binding={prefix:p.prefix,invocationId:p.invocationId,registeredDigest:p.registeredDigest,startedDigest:p.startedDigest,resultDigest:p.resultDigest};
|
|
36
|
+
if(isReceipt){
|
|
37
|
+
need(!receipts.has(p.invocationId),'review_reconciliation_duplicate');
|
|
38
|
+
const request=registration.payload.request;
|
|
39
|
+
const hosts=[configuration.hostContextId,...prior.filter(r=>/^fix-host-joined-/.test(r.id)).map(r=>r.payload.hostContextId)];
|
|
40
|
+
const excluded=[...hosts,...configuration.causeReview.excludedThreadIds,request.contextId,
|
|
41
|
+
...prior.filter(r=>/-started$/.test(r.id)&&r.id!==started.id&&r.payload.providerThreadId).map(r=>r.payload.providerThreadId)];
|
|
42
|
+
const inspection=inspectFixReconciledResult({...result.payload,reconciliationReceipt:p.receipt},
|
|
43
|
+
{request,developerThreadId:hosts[0],excludedThreadIds:[...new Set(excluded)]},p.prefix.includes('cause'));
|
|
44
|
+
need(inspection.providerThreadId===started.payload.providerThreadId,'review_reconciliation_binding');
|
|
45
|
+
receipts.set(p.invocationId,{...binding,receipt:p.receipt,receiptDigest:digest(row),inspection,resultRecord:result});
|
|
46
|
+
}else{
|
|
47
|
+
const proof=receipts.get(p.invocationId);
|
|
48
|
+
need(proof&&!applied.has(p.invocationId)&&proof.receiptDigest===p.receiptDigest
|
|
49
|
+
&&digest(binding)===digest(Object.fromEntries(Object.keys(binding).map(k=>[k,proof[k]]))),'review_reconciliation_binding');
|
|
50
|
+
applied.add(p.invocationId);
|
|
51
|
+
if(proof.inspection.observationStatus==='completed')overlays.set(result.id,{...result.payload,reconciliationReceipt:proof.receipt});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {receipts,applied,overlays,pending:[...receipts.values()].filter(p=>!applied.has(p.invocationId))};
|
|
55
|
+
}
|
|
56
|
+
export function reconciledFixResultRecord(records,row){
|
|
57
|
+
if(!row||row.payload.reconciliationReceipt)return row;
|
|
58
|
+
const applied=records.find(r=>r.id.startsWith('fix-review-reconciled-')&&r.payload.prefix+'-result'===row.id);
|
|
59
|
+
if(!applied)return row;
|
|
60
|
+
const receipt=records.find(r=>digest(r)===applied.payload.receiptDigest);
|
|
61
|
+
need(receipt&&digest(row)===applied.payload.resultDigest,'review_reconciliation_binding');
|
|
62
|
+
return receipt.payload.receipt.result.status==='succeeded'
|
|
63
|
+
?{...row,payload:{...row.payload,reconciliationReceipt:receipt.payload.receipt}}:row;
|
|
64
|
+
}
|
|
@@ -16,6 +16,8 @@ import {inspectPrdDesignRiskSelection} from './design-risk.mjs';
|
|
|
16
16
|
import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
|
|
17
17
|
import {prdDraftJson} from './validation-reason.mjs';
|
|
18
18
|
|
|
19
|
+
const initialTaskInstructions=' For FIRST task planning only: combine related low-risk work around one independently verifiable and reversible objective. Retain every AC, original user test, expected result and verification prerequisite; keep AC-to-test-to-task references complete. Same file/component alone is not evidence to combine. Keep high-risk work, unknown-risk work, explicit user requests for independent tasks and unrelated objectives separate; preserve legitimate contract-first tasks and real dependencies. Use requirement/design/context evidence, not keyword risk classification or another model call. No fixed merge ratio or task-count target. Do not repartition an existing draft, revision, restored task list, change or in-flight task. Scope expansion during development requires the existing explicit change and renewed approval. Keep configured developer/reviewer roles and each task independent N4 unchanged.';
|
|
20
|
+
|
|
19
21
|
export function createCmPrdAnalysis({input,runtime,analyze,record,processMaterials,generate,checkContext,restored=null,allowInputDrift=false}){
|
|
20
22
|
need(['codex','claude'].includes(runtime)&&typeof analyze==='function'&&typeof record==='function','prd_host_invalid');
|
|
21
23
|
input=json(input);
|
|
@@ -192,11 +194,12 @@ export function createCmPrdAnalysis({input,runtime,analyze,record,processMateria
|
|
|
192
194
|
revision:draft===null?null:{draft,contextCheck,round:selfCheckRound+1,
|
|
193
195
|
instructions:'Correct findings only within these existing feature names/directories. Do not add, remove or rename features; retain user intent and tests. No review invocation. Two self-check rounds maximum.'},
|
|
194
196
|
reference:path.join(admission.skillDir,'SKILL.md'),testContract:path.join(admission.workflowRoot,'runtime/test-contract.md'),
|
|
195
|
-
instructions:canRevise?
|
|
197
|
+
instructions:(canRevise?
|
|
196
198
|
'Correct the failed whole-draft self-check in the existing draft schema. Keep exactly the same ordered features and file inventory. Requirements/design changes require selfCheckRevisionReason. Return question or blocked if needed. No writes, review dispatch, invented approval or extra rounds.':acceptedDesign!==null?
|
|
197
199
|
'Follow original cm-prd Step 10 and 10.4 on acceptedDesign. Return the existing draft schema with the exact same ordered features and exact requirements.md/design.md bytes supplied there; generate tasks.md and applicable test-cases.json only. Do not regenerate or revise accepted requirements/design, change scope or call a reviewer. Preserve original user cases and unresolved design findings for human review. Ask material questions with {status:question,question}; no invented user decisions. No writes, provider calls, installation, development or approval. Subsequent original self-check and split review remain required.':designOnly?
|
|
198
200
|
'Follow cm-prd Steps 6-9 only, before original Step 9.5 design review. Read required references and actual relevant project context. Preserve user cases and requirements. No tasks or test-contract generation yet, even embedded in another document. Resolve material or human UI baseline decisions with {status:question,question}; never infer consent. Return {status:design,summary,features:[{name:kebab_slug,documents:[{path:requirements.md|design.md,content:string}]}]} with exactly both documents per feature, or {status:blocked,reason}. No writes, provider calls, browser launch, installation, review claims or development. These are unreviewed memory drafts, not authority to generate tasks.':
|
|
199
|
-
'Follow cm-prd Steps 6-10 for in-memory DRAFTS ONLY. Read required references and relevant project context. Resolve material questions and human UI baseline choices before design: return {status:question,question} and wait, never infer consent. No writes, provider calls, browser launch, installation, review claims or development. Return {status:draft,summary,features:[{name:kebab_slug,documents:[{path:requirements.md|design.md|tasks.md|test-cases.json,content:string}],testCasesReason:null|no_observable_behavior|generation_disabled}]} or {status:blocked,reason}. Each feature needs the triad. Apply functional task granularity <=15, AC/Task references, applicable test contract and original user-case intent; generateCases false forbids generated cases only. This draft is unreviewed; original conditional design review, split review, self-check and human approval remain pending.'
|
|
201
|
+
'Follow cm-prd Steps 6-10 for in-memory DRAFTS ONLY. Read required references and relevant project context. Resolve material questions and human UI baseline choices before design: return {status:question,question} and wait, never infer consent. No writes, provider calls, browser launch, installation, review claims or development. Return {status:draft,summary,features:[{name:kebab_slug,documents:[{path:requirements.md|design.md|tasks.md|test-cases.json,content:string}],testCasesReason:null|no_observable_behavior|generation_disabled}]} or {status:blocked,reason}. Each feature needs the triad. Apply functional task granularity <=15, AC/Task references, applicable test contract and original user-case intent; generateCases false forbids generated cases only. This draft is unreviewed; original conditional design review, split review, self-check and human approval remain pending.')
|
|
202
|
+
+(draft===null&&!designOnly?initialTaskInstructions:'')},controller.signal),64*1024);
|
|
200
203
|
need(!controller.signal.aborted,'cancelled');current();
|
|
201
204
|
need(digest(inventory)===digest(prdFeatureInventory(admission.specs)),'prd_feature_inventory_changed');
|
|
202
205
|
if(reply.status==='question'){
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Projection of an already recorded response. No dispatch, verdict edit or retry.
|
|
2
|
+
import {json,digest,need,shape,id} from '../cm-ai/effect-contract.mjs';
|
|
3
|
+
import {inspectPrdReviewResponse} from './review-publication.mjs';
|
|
4
|
+
import {normalizePrdReviewTimestamp} from './review-time.mjs';
|
|
5
|
+
export function readPrdRepairBinding(raw){
|
|
6
|
+
const binding=json(raw,8192);shape(binding,['callId','requestDigest','resultDigest','packageDigest','reason']);
|
|
7
|
+
id(binding.callId);for(const key of ['requestDigest','resultDigest','packageDigest'])
|
|
8
|
+
need(typeof binding[key]==='string'&&/^[a-f0-9]{64}$/.test(binding[key]),'prd_recovery_binding');
|
|
9
|
+
need(typeof binding.reason==='string'&&binding.reason.trim().length>0&&Buffer.byteLength(binding.reason,'utf8')<=1000
|
|
10
|
+
&&!/[\x00-\x1f\u0085\u2028\u2029]/.test(binding.reason),'prd_recovery_evidence_required');
|
|
11
|
+
return binding;
|
|
12
|
+
}
|
|
13
|
+
export function recoverPrdResponse({original,reviewPackage,packageDigest,authorContextId}){
|
|
14
|
+
const response={...json(original,64*1024)},changes=[];
|
|
15
|
+
if(response.reviewer!=='self-degraded'&&Object.hasOwn(response,'degradedReason')&&response.degradedReason===null){
|
|
16
|
+
delete response.degradedReason;changes.push('omit-independent-null-degradedReason');
|
|
17
|
+
}
|
|
18
|
+
const at=normalizePrdReviewTimestamp(response.at);
|
|
19
|
+
if(at!==response.at){response.at=at;changes.push('canonical-exact-timestamp');}
|
|
20
|
+
inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response});
|
|
21
|
+
need(digest(original.result)===digest(response.result),'prd_recovery_verdict_changed');
|
|
22
|
+
return {response,changes};
|
|
23
|
+
}
|
|
@@ -36,7 +36,8 @@ export async function runPrdHostReview({specs,prepared,authorContextId,writeEnab
|
|
|
36
36
|
const paths=(pkg.stage==='design'?['requirements.md','design.md']:['requirements.md','design.md','tasks.md'])
|
|
37
37
|
.map(file=>`${pkg.feature}/${file}`).sort();
|
|
38
38
|
const response=json(await review({package:{...pkg,packageDigest:prepared.packageDigest},examinedPaths:paths,authorContextId,mode,
|
|
39
|
-
instructions:'Use only the authorized current-host review channel. independent requires an actual fresh reviewer context, not the author. self-degraded uses the author and must explain unavailable independence. Verify context identity and forward the original result unchanged. No provider/CLI invocation, installation, external transmission, Git or project writes without separate authority. Return {reviewer,contextId,independent,at,result}, plus degradedReason only for self-degraded. Result follows verdict/packageDigest/examinedPaths/findings/summary. Do not retry or switch mode after this attempt; unavailable/interrupted remains unknown.'
|
|
39
|
+
instructions:'Use only the authorized current-host review channel. independent requires an actual fresh reviewer context, not the author. self-degraded uses the author and must explain unavailable independence. Verify context identity and forward the original result unchanged. No provider/CLI invocation, installation, external transmission, Git or project writes without separate authority. Return {reviewer,contextId,independent,at,result}, plus degradedReason only for self-degraded. Result follows verdict/packageDigest/examinedPaths/findings/summary. Do not retry or switch mode after this attempt; unavailable/interrupted remains unknown.'
|
|
40
|
+
+(pkg.stage==='split'?' In this existing split attempt, assess submitted task boundaries: combined work must share one independently verifiable and reversible objective with every AC, original test and verification prerequisite retained. Check requirement/design/context evidence for high or unknown risk, explicit user independence and unrelated objectives; retain those boundaries and legitimate contract-first dependencies. Do not infer risk from keywords, add a classifier/review call, enforce a merge ratio or repartition already generated tasks for fewer reviews. Do not apply this new grouping guidance retroactively to older drafts, revisions, change plans or in-flight tasks. Report only existing requirement/design failures with concrete consequences; mechanical reference checks alone do not establish semantic risk or user intent. Configured roles and per-task N4 remain unchanged.':'')},signal),64*1024);
|
|
40
41
|
need(!signal.aborted,'cancelled');current();
|
|
41
42
|
validatePrdReviewMode(mode,response);
|
|
42
43
|
const published=publishPrdReview({specs,reviewPackage:pkg,packageDigest:prepared.packageDigest,authorContextId,response});
|
|
@@ -8,21 +8,11 @@ import {reviewResultForPaths} from '../cm-ai/review-runner.mjs';
|
|
|
8
8
|
import {need,shape,json,digest,id} from '../cm-ai/effect-contract.mjs';
|
|
9
9
|
import {needPrd} from './validation-reason.mjs';
|
|
10
10
|
|
|
11
|
-
export function
|
|
12
|
-
if(!inspectOnly)assertPrdBatchActive(specs,[reviewPackage.feature]);
|
|
11
|
+
export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response}){
|
|
13
12
|
reviewPackage=json(reviewPackage,256*1024);response=json(response,64*1024);id(authorContextId);
|
|
14
13
|
need(digest(reviewPackage)===packageDigest&&reviewPackage.workflow==='cm-prd'
|
|
15
14
|
&&['design','split'].includes(reviewPackage.stage),'prd_review_package_invalid');
|
|
16
|
-
|
|
17
|
-
need(match,'prd_review_feature_invalid');
|
|
18
|
-
need(path.isAbsolute(specs)&&fs.realpathSync(specs)===specs,'prd_review_root_invalid');
|
|
19
|
-
const reviews=path.join(specs,'.reviews');
|
|
20
|
-
need(fs.realpathSync(reviews)===reviews&&fs.lstatSync(reviews).isDirectory(),'prd_review_path_invalid');
|
|
21
|
-
const stage=reviewPackage.stage,feature=match[2],prefix=`prd-${feature}-${stage}`;
|
|
22
|
-
const args={stage,feature,pendingSplit,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`)};
|
|
23
|
-
const gate=inspectPrdReview(args);
|
|
24
|
-
need(gate.package_sha256===packageDigest&&['dispatch_unknown','resume_disposition','completed'].includes(gate.outcome),
|
|
25
|
-
'prd_review_unclaimed');
|
|
15
|
+
need(typeof reviewPackage.feature==='string'&&/^[1-9]\d*\.[a-z0-9]+(?:-[a-z0-9]+)*$/.test(reviewPackage.feature),'prd_review_feature_invalid');
|
|
26
16
|
const degraded=response.reviewer==='self-degraded';
|
|
27
17
|
shape(response,['reviewer','contextId','independent','at','result',...(degraded?['degradedReason']:[])]);
|
|
28
18
|
// Native subagents return canonical context identities, not filesystem paths.
|
|
@@ -40,9 +30,29 @@ export function publishPrdReview({specs,reviewPackage,packageDigest,authorContex
|
|
|
40
30
|
needPrd(typeof response.at==='string'&&Number.isFinite(Date.parse(response.at))
|
|
41
31
|
&&new Date(response.at).toISOString()===response.at,'prd_review_timestamp_invalid',
|
|
42
32
|
{field:'response.at',expected:'new Date().toISOString() form, e.g. 2026-09-08T00:00:00.000Z'});
|
|
43
|
-
const files=stage==='design'?['requirements.md','design.md']:['requirements.md','design.md','tasks.md'];
|
|
33
|
+
const files=reviewPackage.stage==='design'?['requirements.md','design.md']:['requirements.md','design.md','tasks.md'];
|
|
44
34
|
const examinedPaths=files.map(file=>`${reviewPackage.feature}/${file}`).sort();
|
|
45
35
|
const result=reviewResultForPaths(response.result,{packageDigest},examinedPaths);
|
|
36
|
+
return {response,result,examinedPaths,degraded};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function publishPrdReview({specs,reviewPackage,packageDigest,authorContextId,response,inspectOnly=false,pendingSplit=null}){
|
|
40
|
+
inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response});
|
|
41
|
+
if(!inspectOnly)assertPrdBatchActive(specs,[reviewPackage.feature]);
|
|
42
|
+
reviewPackage=json(reviewPackage,256*1024);response=json(response,64*1024);id(authorContextId);
|
|
43
|
+
need(digest(reviewPackage)===packageDigest&&reviewPackage.workflow==='cm-prd'
|
|
44
|
+
&&['design','split'].includes(reviewPackage.stage),'prd_review_package_invalid');
|
|
45
|
+
const match=typeof reviewPackage.feature==='string'&&reviewPackage.feature.match(/^([1-9]\d*)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/);
|
|
46
|
+
need(match,'prd_review_feature_invalid');
|
|
47
|
+
need(path.isAbsolute(specs)&&fs.realpathSync(specs)===specs,'prd_review_root_invalid');
|
|
48
|
+
const reviews=path.join(specs,'.reviews');
|
|
49
|
+
need(fs.realpathSync(reviews)===reviews&&fs.lstatSync(reviews).isDirectory(),'prd_review_path_invalid');
|
|
50
|
+
const stage=reviewPackage.stage,feature=match[2],prefix=`prd-${feature}-${stage}`;
|
|
51
|
+
const args={stage,feature,pendingSplit,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`)};
|
|
52
|
+
const gate=inspectPrdReview(args);
|
|
53
|
+
need(gate.package_sha256===packageDigest&&['dispatch_unknown','resume_disposition','completed'].includes(gate.outcome),
|
|
54
|
+
'prd_review_unclaimed');
|
|
55
|
+
const {result,examinedPaths,degraded}=inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response});
|
|
46
56
|
const bytes=Buffer.from(['---',`at: ${response.at}`,`reviewer: ${response.reviewer}`,`independent: ${response.independent}`,
|
|
47
57
|
...(degraded?[`degraded_reason: ${JSON.stringify(response.degradedReason)}`]:[]),`package_sha256: ${packageDigest}`,
|
|
48
58
|
`verdict: ${result.verdict}`,'scope:',...examinedPaths.map(file=>` - ${file}`),'---','',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {needPrd} from './validation-reason.mjs';
|
|
2
|
+
|
|
3
|
+
export function assertPrdReviewTimestamp(value){
|
|
4
|
+
needPrd(typeof value==='string'&&Number.isFinite(Date.parse(value))
|
|
5
|
+
&&new Date(value).toISOString()===value,'prd_review_timestamp_invalid',
|
|
6
|
+
{field:'response.at',expected:'new Date().toISOString() form, e.g. 2026-09-08T00:00:00.000Z'});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Recovery only: explicit timezone, exact calendar, no Date.parse rollover.
|
|
10
|
+
// Only exact millisecond instants are recoverable; never truncate precision or use now.
|
|
11
|
+
export function normalizePrdReviewTimestamp(value){
|
|
12
|
+
const match=typeof value==='string'&&value.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|([+-])(\d{2}):(\d{2}))$/);
|
|
13
|
+
const valid=ok=>needPrd(ok,'prd_review_timestamp_invalid',
|
|
14
|
+
{field:'response.at',expected:'Valid ISO calendar timestamp with explicit Z or +/-HH:mm timezone; 1-9 fractional digits'});
|
|
15
|
+
valid(match);
|
|
16
|
+
valid(match[8]!=='-00:00');
|
|
17
|
+
const [year,month,day,hour,minute,second]=match.slice(1,7).map(Number);
|
|
18
|
+
const offsetHour=Number(match[10]??0),offsetMinute=Number(match[11]??0);
|
|
19
|
+
valid(month>=1&&month<=12&&day>=1&&day<=31&&hour<=23&&minute<=59&&second<=59
|
|
20
|
+
&&offsetHour<=23&&offsetMinute<=59);
|
|
21
|
+
const date=new Date(0);date.setUTCFullYear(year,month-1,day);date.setUTCHours(hour,minute,second,0);
|
|
22
|
+
valid(date.getUTCFullYear()===year&&date.getUTCMonth()===month-1&&date.getUTCDate()===day);
|
|
23
|
+
valid(!(match[7]??'').slice(3).match(/[1-9]/));
|
|
24
|
+
const milliseconds=Number((match[7]??'').padEnd(3,'0').slice(0,3));
|
|
25
|
+
const offset=(offsetHour*60+offsetMinute)*60000*(match[9]==='-'?-1:1);
|
|
26
|
+
const utc=new Date(date.getTime()+milliseconds-offset);
|
|
27
|
+
valid(utc.getUTCFullYear()>=0&&utc.getUTCFullYear()<=9999);
|
|
28
|
+
const canonical=utc.toISOString();assertPrdReviewTimestamp(canonical);return canonical;
|
|
29
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// PRD-local checkpoint and call journal. It never owns review/task approval.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import {randomUUID} from 'node:crypto';
|
|
5
|
-
import {need,json,digest} from '../cm-ai/effect-contract.mjs';
|
|
4
|
+
import {randomUUID,createHash} from 'node:crypto';
|
|
5
|
+
import {need,json,digest,shape} from '../cm-ai/effect-contract.mjs';
|
|
6
|
+
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
7
|
+
import {recoverPrdResponse,readPrdRepairBinding} from './response-recovery.mjs';
|
|
6
8
|
import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
|
|
7
9
|
|
|
8
10
|
export function readPrdSessionFile(root,relative){
|
|
@@ -25,7 +27,7 @@ export function replaceSessionFile(root,relative,before,after){
|
|
|
25
27
|
const d=fs.openSync(dir,'r');try{fs.fsyncSync(d);}finally{fs.closeSync(d);}
|
|
26
28
|
}finally{if(fd!==undefined)fs.closeSync(fd);try{fs.unlinkSync(tmp);}catch(e){if(e.code!=='ENOENT')throw e;}}
|
|
27
29
|
}
|
|
28
|
-
export function openPrdSession({specs,sessionId,identity}){
|
|
30
|
+
export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
29
31
|
need(/^prd-[a-zA-Z0-9-]{1,80}$/.test(sessionId),'prd_session_id_invalid');
|
|
30
32
|
for(const relative of ['.reviews','.reviews/prd-sessions',`.reviews/prd-sessions/${sessionId}`]){
|
|
31
33
|
const dir=path.join(specs,relative);try{fs.mkdirSync(dir,{mode:0o700});}catch(e){if(e.code!=='EEXIST')throw e;}
|
|
@@ -41,13 +43,58 @@ export function openPrdSession({specs,sessionId,identity}){
|
|
|
41
43
|
}
|
|
42
44
|
const lockBytes=JSON.stringify({pid:process.pid,nonce:randomUUID()});
|
|
43
45
|
const fd=fs.openSync(lock,'wx',0o600);try{fs.writeFileSync(fd,lockBytes);fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
|
|
44
|
-
let bytes=read(),state=bytes===null?{version:1,identity,checkpoint:null,active:null,segments:{}
|
|
45
|
-
|
|
46
|
+
let bytes=read(),state=bytes===null?{version:executionPolicy===null?1:2,identity,checkpoint:null,active:null,segments:{},
|
|
47
|
+
...(executionPolicy===null?{}:{executionPolicy:readExecutionPolicy(executionPolicy),responseRepairs:[]})}:JSON.parse(bytes);
|
|
48
|
+
try{need([1,2].includes(state.version)&&digest(state.identity)===digest(identity),'prd_session_identity_changed');
|
|
49
|
+
if(state.version===2){readExecutionPolicy(state.executionPolicy);need(Array.isArray(state.responseRepairs),'prd_recovery_binding');}
|
|
50
|
+
else need(executionPolicy===null,'execution_policy_legacy_run');}
|
|
46
51
|
catch(e){fs.unlinkSync(lock);throw e;}
|
|
47
52
|
let cursor=0;
|
|
48
53
|
const save=()=>{const next=JSON.stringify(state);replaceSessionFile(directory,'state.json',bytes,next);bytes=next;};
|
|
54
|
+
const projected=call=>{
|
|
55
|
+
if(!call.responseRepair)return call.result;
|
|
56
|
+
need(state.version===2&&call.kind==='prd_review'&&digest({kind:call.kind,payload:call.payload})===call.requestDigest,'prd_recovery_binding');
|
|
57
|
+
const record=call.responseRepair;
|
|
58
|
+
shape(record,['version','callId','requestDigest','originalDigest','originalBase64','response','changes','reason']);
|
|
59
|
+
need(record.version===1&&record.callId===call.callId&&record.requestDigest===call.requestDigest
|
|
60
|
+
&&record.originalDigest===digest(call.result)&&record.originalBase64===Buffer.from(JSON.stringify(call.result)).toString('base64'),'prd_recovery_binding');
|
|
61
|
+
const {packageDigest,...reviewPackage}=call.payload.package;
|
|
62
|
+
const expected=recoverPrdResponse({original:call.result,reviewPackage,packageDigest,authorContextId:call.payload.authorContextId});
|
|
63
|
+
need(digest(expected.response)===digest(record.response)&&digest(expected.changes)===digest(record.changes),'prd_recovery_binding');
|
|
64
|
+
return expected.response;
|
|
65
|
+
};
|
|
49
66
|
return {
|
|
50
67
|
get state(){return json(state,12*1024*1024);},
|
|
68
|
+
reviewResponse(call){return projected(call);},
|
|
69
|
+
repairReviewResponse(binding){
|
|
70
|
+
need(state.version===2&&state.executionPolicy.responseRecovery==='mechanical-v1','execution_policy_required');
|
|
71
|
+
binding=readPrdRepairBinding(binding);
|
|
72
|
+
const saved=state.responseRepairs.find(item=>item.originalCall.callId===binding.callId);
|
|
73
|
+
if(saved){
|
|
74
|
+
need(saved.originalOperation.operation==='final_review'&&/^[a-f0-9]{64}$/.test(saved.originalStateSha256),'prd_recovery_binding');
|
|
75
|
+
need(saved.originalCall.requestDigest===binding.requestDigest&&digest(saved.originalCall.result)===binding.resultDigest
|
|
76
|
+
&&saved.originalCall.payload.package.packageDigest===binding.packageDigest,'prd_recovery_binding');
|
|
77
|
+
const response=projected({...saved.originalCall,responseRepair:saved.repair});
|
|
78
|
+
need(saved.originalOperation.mode==='self-degraded'?response.reviewer==='self-degraded':response.reviewer!=='self-degraded','prd_review_mode_changed');
|
|
79
|
+
return json(saved.repair);
|
|
80
|
+
}
|
|
81
|
+
const active=state.active,call=active?.calls.find(c=>c.callId===binding.callId);
|
|
82
|
+
need(active?.request.operation==='final_review'&&active.calls.length===1&&call?.kind==='prd_review'
|
|
83
|
+
&&Object.hasOwn(call,'result')&&call.requestDigest===binding.requestDigest
|
|
84
|
+
&&digest(call.result)===binding.resultDigest&&call.payload.package.packageDigest===binding.packageDigest,'prd_recovery_binding');
|
|
85
|
+
if(call.responseRepair){projected(call);return json(call.responseRepair);}
|
|
86
|
+
const {packageDigest,...reviewPackage}=call.payload.package;
|
|
87
|
+
const recovered=recoverPrdResponse({original:call.result,reviewPackage,packageDigest,authorContextId:call.payload.authorContextId});
|
|
88
|
+
need(active.request.mode==='self-degraded'?recovered.response.reviewer==='self-degraded':recovered.response.reviewer!=='self-degraded','prd_review_mode_changed');
|
|
89
|
+
need(recovered.changes.length>0,'prd_response_already_canonical');
|
|
90
|
+
const originalCall=json(call,1024*1024);
|
|
91
|
+
call.responseRepair={version:1,callId:call.callId,requestDigest:call.requestDigest,originalDigest:digest(call.result),
|
|
92
|
+
originalBase64:Buffer.from(JSON.stringify(call.result)).toString('base64'),...recovered,reason:binding.reason};
|
|
93
|
+
need(state.responseRepairs.length<64,'prd_write_limit');
|
|
94
|
+
state.responseRepairs.push({originalCall,originalOperation:active.request,
|
|
95
|
+
originalStateSha256:createHash('sha256').update(bytes).digest('hex'),repair:call.responseRepair});
|
|
96
|
+
save();return json(call.responseRepair);
|
|
97
|
+
},
|
|
51
98
|
begin(request,before){need(state.active===null,'prd_operation_recovery_required');state.active={request,before,calls:[]};cursor=0;save();},
|
|
52
99
|
replay(){need(state.active!==null,'prd_nothing_to_resume');cursor=0;return json(state.active,12*1024*1024);},
|
|
53
100
|
commit(checkpoint){state.checkpoint=checkpoint;state.active=null;save();},
|
|
@@ -69,7 +116,7 @@ export function openPrdSession({specs,sessionId,identity}){
|
|
|
69
116
|
const active=state.active;
|
|
70
117
|
const previous=state.active.calls[index];
|
|
71
118
|
if(previous){need(previous.requestDigest===digest(input),'prd_replay_inputs_changed');
|
|
72
|
-
need(Object.hasOwn(previous,'result'),'prd_host_result_unknown');return previous
|
|
119
|
+
need(Object.hasOwn(previous,'result'),'prd_host_result_unknown');return projected(previous);}
|
|
73
120
|
need(!state.active.calls.some(call=>!Object.hasOwn(call,'result')),'prd_host_result_unknown');
|
|
74
121
|
const call={callId:randomUUID(),requestDigest:digest(input),...input};state.active.calls.push(call);save();
|
|
75
122
|
const response=await perform({...payload,recovery:{sessionId,callId:call.callId,requestDigest:call.requestDigest}},signal);
|
|
@@ -127,6 +127,37 @@ function validateReview(review,scan){
|
|
|
127
127
|
return {version:1,scanDigest:review.scanDigest,paths};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// Presentation is derived from validated metadata, never raw scanner messages.
|
|
131
|
+
function checkSummary(tools){
|
|
132
|
+
const names={gitleaks:'凭证泄露检查',semgrep:'本地规则代码检查',osv:'离线依赖漏洞检查'};
|
|
133
|
+
const details={
|
|
134
|
+
no_scannable_files:['所选范围没有可扫描文件。','核对所选范围与文件缺口;没有可扫描文件不代表安全检查通过。'],
|
|
135
|
+
tool_missing:['项目外可信工具不可用,检查未运行。','由用户确认项目外可信工具可用后,在同一范围重新检查。'],
|
|
136
|
+
local_rules_required:['未指定已审查的外部本地规则,检查未运行。','准备已审查的外部本地规则文件,并用 --semgrep-rules 显式指定后重跑。'],
|
|
137
|
+
no_supported_lockfile_selected:['所选范围没有支持的依赖锁文件,检查未运行。','确认依赖锁文件是否在所选范围内;无锁文件不能推断无依赖漏洞。'],
|
|
138
|
+
offline_database_required:['未提供外部离线数据库缓存目录,检查未运行。','由用户准备外部离线数据库缓存,并用 --osv-db 显式指定后重跑。'],
|
|
139
|
+
timeout:['检查已尝试,但超时,未得到完整结果。','排查本地工具耗时与执行条件,再在原范围重跑;保留本次超时记录。'],
|
|
140
|
+
execution_failed:['检查已尝试,但执行失败,未得到完整结果。','核对本地工具版本与执行条件,处理失败原因后重跑。'],
|
|
141
|
+
invalid_or_incomplete_report:['检查已尝试,但输出无法验证或不完整。','核对本地工具兼容性和输出完整性,取得可验证结果后重跑。'],
|
|
142
|
+
unscanned_files:['工具已执行,但部分文件未扫描。','核对工具的 unscanned 路径,补齐对应语言或规则覆盖,或逐项人工复核。'],
|
|
143
|
+
offline_database_freshness_and_ecosystem_coverage_unverified:['离线扫描已执行;数据库新旧仍未知,生态覆盖未核验。','人工核验离线数据库新旧和生态覆盖;未核验前保留该缺口,不自动下载数据库。'],
|
|
144
|
+
};
|
|
145
|
+
const attempted=[],notRun=[],nextSteps=[];
|
|
146
|
+
for(const row of tools){
|
|
147
|
+
const execution=row.status==='NOT_RUN'?'未运行':row.status==='ERROR'?'已尝试,未完成':'已完成';
|
|
148
|
+
const fallback=row.status==='NOT_RUN'?['检查未运行,具体原因未记录。','核对该工具的配置和执行条件后重跑。']
|
|
149
|
+
:row.status==='ERROR'?['检查已尝试但未完成,具体原因未记录。','核对该工具的执行条件,取得完整结果后重跑。']
|
|
150
|
+
:row.status==='FINDINGS'?['本轮检查已完成,发现候选问题。','结合相关代码逐项复核候选问题。']
|
|
151
|
+
:['本轮检查已完成,未报告候选问题。',null];
|
|
152
|
+
const [description,action]=details[row.reason]??fallback;
|
|
153
|
+
const item={tool:row.tool,check:names[row.tool],status:row.status,execution,
|
|
154
|
+
version:row.version??'unknown',reason:row.reason,description};
|
|
155
|
+
(row.status==='NOT_RUN'?notRun:attempted).push(item);
|
|
156
|
+
if(action)nextSteps.push({tool:row.tool,action});
|
|
157
|
+
}
|
|
158
|
+
return {attempted,notRun,nextSteps};
|
|
159
|
+
}
|
|
160
|
+
|
|
130
161
|
export function finalize(project,{scanFile,reviewFile}={}){
|
|
131
162
|
project=fs.realpathSync(project);
|
|
132
163
|
const scan=validateScan(readExternal(project,scanFile));
|
|
@@ -152,6 +183,7 @@ export function finalize(project,{scanFile,reviewFile}={}){
|
|
|
152
183
|
const result=scan.result==='BLOCKED'||!unchanged?'BLOCKED':findingsCount?'FINDINGS':!scan.selected.length?'NO_CHANGES':'REVIEWED_PARTIAL';
|
|
153
184
|
const sourceUnchanged=scan.sourceUnchanged&&unchanged;
|
|
154
185
|
const report={...scan,review,gaps,coverage,result,aiReview:'completed',findingsCount,sourceUnchanged,
|
|
186
|
+
checkSummary:checkSummary(scan.tools),
|
|
155
187
|
sourceWindows:{scan:{sourceUnchanged:scan.sourceUnchanged},review:{sourceUnchanged:unchanged,digest:current.digest}}};
|
|
156
188
|
// Resolve/check TMPDIR before creating anything: the output must remain external.
|
|
157
189
|
const tempRoot=fs.realpathSync(os.tmpdir());need(!inside(project,tempRoot),'external_temp_directory_required');
|
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import {inspectRunClosure} from '../../../scripts/cm-log-event.mjs';
|
|
6
6
|
import {need,digest,json} from '../cm-ai/effect-contract.mjs';
|
|
7
|
+
import {readStableLogRows} from '../cm-ai/log-rows.mjs';
|
|
7
8
|
import {inside,canonicalFuture,selectReportDirectory} from './source-snapshot.mjs';
|
|
8
9
|
|
|
9
10
|
export function inspectCmTestRecovery(config,{runId,logFile}){
|
|
@@ -23,10 +24,9 @@ export function inspectCmTestRecovery(config,{runId,logFile}){
|
|
|
23
24
|
const allowed=admission.specs?logFile===path.join(admission.specs,'运行日志.jsonl'):
|
|
24
25
|
inside(path.join(logHome,'runs'),logFile)&&logFile.endsWith('.jsonl');
|
|
25
26
|
need(allowed,'cm_test_log_path_invalid');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const records=lines.map(line=>JSON.parse(line)).filter(event=>event.run_id===runId);
|
|
27
|
+
// Streamed with the same single-link/stable-file checks: a shared project log
|
|
28
|
+
// keeps growing, and only this run's rows matter here (no 32 MiB whole-file cap).
|
|
29
|
+
const records=readStableLogRows(logFile,event=>event?.run_id===runId,'cm_test_log_invalid');
|
|
30
30
|
const starts=records.filter(event=>event.event==='run_start');
|
|
31
31
|
need(starts.length===1&&starts[0].workflow==='cm-test'&&starts[0].project_path===admission.project,
|
|
32
32
|
'cm_test_run_binding_invalid');
|
package/runtime/review.md
CHANGED
|
@@ -105,6 +105,11 @@ PRD artifact 回执先比对原始字节,仅 Markdown 中 `tasks.md` 的任务
|
|
|
105
105
|
proceed only when the reviewer records `approved` and the disagreement is
|
|
106
106
|
preserved in `LESSONS.md`.
|
|
107
107
|
|
|
108
|
+
A concrete human-approved local correction after blocked round two may use the
|
|
109
|
+
one-shot task-gate entrance in `docs/human-correction.md`. It preserves the original
|
|
110
|
+
reports, seals a fresh independent correction review, and does not reopen a host
|
|
111
|
+
journal or reset ordinary attempts. Without explicit human authorization, stop.
|
|
112
|
+
|
|
108
113
|
At any stage, changing reviewed code, tests, or execution instructions invalidates
|
|
109
114
|
approval for the changed content. N5 may record improvement suggestions, not make
|
|
110
115
|
new implementation changes while writing lessons. After mark-done, preserve the
|
package/runtime/task-gates.md
CHANGED
|
@@ -84,6 +84,12 @@ entry and the body must contain findings or an explicit zero-findings result.
|
|
|
84
84
|
implementation files. Round 2 cannot create attempt 3: another blocking result
|
|
85
85
|
becomes `blocked` and requires human resolution under `runtime/review.md`.
|
|
86
86
|
|
|
87
|
+
For an explicitly human-authorized correction after round-two blocked, see
|
|
88
|
+
`docs/human-correction.md`: `prepare-human-correction` and
|
|
89
|
+
`publish-human-correction-review` keep the original four records and bind a separate
|
|
90
|
+
one-shot correction. N4/N5 and locked completion accept its fixed `--correction`
|
|
91
|
+
record; legacy-unbound flags do not weaken correction checks.
|
|
92
|
+
|
|
87
93
|
N5 must let the JavaScript gate validate and update the exact task checkbox while
|
|
88
94
|
the compatibility entry holds the existing platform ownership lock:
|
|
89
95
|
|
|
@@ -30,7 +30,7 @@ CM 支持一个可选的项目根配置文件:`.cm-workflow.yml`、`.cm-workfl
|
|
|
30
30
|
## 运行时声明
|
|
31
31
|
|
|
32
32
|
`runtimes.available` 记录用户自报的可用运行时:`codex`、`claude` 或 `both`。缺省为
|
|
33
|
-
`unknown
|
|
33
|
+
`unknown`(两级均未声明,不做交叉检查)。安装器可选写用户默认,`cm-init` 优先继承且不再询问;`cm-runtime` 默认查看并保留,主动选择后才修改。
|
|
34
34
|
|
|
35
35
|
| 预设 | `runtimes.available` | `roles.coder.adapter` | `roles.reviewer.adapter` |
|
|
36
36
|
| --- | --- | --- | --- |
|
|
@@ -150,6 +150,15 @@ preset: codex-codes
|
|
|
150
150
|
|
|
151
151
|
`cm-runtime show [--project PATH]` 只读;`set <preset> [--project PATH]` 原子改项目;
|
|
152
152
|
`set --user <preset>` 改用户默认;`unset --user` 删除用户默认但不删除项目声明。
|
|
153
|
+
无参数先显示有效配置、来源与模型,默认保留;高级模型入口只提供说明和现有校验方法。
|
|
154
|
+
终端/会话向导和安装器的最终确认均为 `[y/N]`,回车不写;无效配置保留并报告错误。
|
|
155
|
+
`preview <preset> [--project PATH | --user] [--json]` 只读生成候选,复用同一合并和校验逻辑,
|
|
156
|
+
展示范围、目标、字段前后值、项目覆盖和保留模型。`set ... --expect-preview <preview_sha256>`
|
|
157
|
+
核对项目、范围、预设、候选内容及相关输入快照;漂移后必须重新预览确认。两次调用保持相同
|
|
158
|
+
工作目录、语言和运行时环境。用户范围在代码项目目录执行,以核对该项目;不扫描所有项目。
|
|
159
|
+
摘要是配置一致性检查,不是授权凭证;原有显式 `set` 仍按原合同执行。
|
|
160
|
+
模型别名保留不表示更换适配器后仍可用;结构校验不证明 provider 兼容、调用成功或配额。
|
|
161
|
+
`unset --user` 不是通用重置,项目声明仍优先;高级入口不提供任意模型编辑器。
|
|
153
162
|
新建项目配置使用模板,已有配置只改五个字段,其余原文保留。已创建的 run 绑定原配置,切换不改 run。
|
|
154
163
|
`set` 通过 cm-log-event.mjs 的 Python 锁适配器写独立的 `decision/route` 全局日志,
|
|
155
164
|
仅附 preset、source、项目路径;没有 specs 指针或业务任务状态写入。日志失败明确报告配置已保存。
|