@aibyzero/cm-workflow 0.16.9 → 0.17.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/AGENTS.md +4 -0
- package/CHANGELOG.md +18 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +16 -1
- package/VERSION +1 -1
- package/docs/architecture.md +29 -13
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +104 -85
- package/docs/next-steps.md +11 -0
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +3 -3
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -8
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +13 -69
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +10 -5
- package/runtime/js/cm-ai/control-policy.mjs +112 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +124 -25
- package/runtime/js/cm-ai/durable-runner-state.mjs +32 -126
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +3 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -20
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +41 -8
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +25 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +57 -54
- package/runtime/js/cm-ai/review-package.mjs +16 -4
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- package/runtime/js/cm-ai/task-runner.mjs +41 -101
- package/runtime/js/cm-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- package/runtime/js/cm-prd/summary.mjs +27 -12
- package/runtime/js/cm-refactor/workflow.mjs +1 -1
- package/runtime/js/notify-send.mjs +15 -14
- package/runtime/js/notify.mjs +27 -4
- package/runtime/js/policy-binding-compat.mjs +2 -1
- package/runtime/review.md +61 -7
- package/runtime/task-gates.md +107 -9
- package/scripts/cm-ai-abandon-effect-position.test.mjs +1 -8
- package/scripts/cm-ai-answer-gap-driver.test.mjs +12 -12
- package/scripts/cm-ai-answer-gap-fixture.mjs +1 -8
- package/scripts/cm-ai-batch-drive.mjs +50 -31
- package/scripts/cm-ai-batch-drive.test.mjs +62 -19
- package/scripts/cm-ai-batch-host.mjs +39 -20
- package/scripts/cm-ai-batch-host.test.mjs +83 -47
- package/scripts/cm-ai-batch-run-fixture.mjs +6 -53
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +0 -12
- package/scripts/cm-ai-batch-run.mjs +46 -14
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +192 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +1 -8
- package/scripts/cm-ai-develop-call-timeout.test.mjs +1 -8
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +33 -20
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +3 -3
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +57 -27
- package/scripts/cm-ai-drive.mjs +96 -54
- package/scripts/cm-ai-drive.test.mjs +46 -87
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +6 -10
- package/scripts/cm-ai-host-fixture.mjs +47 -16
- package/scripts/cm-ai-host-protected.test.mjs +35 -33
- package/scripts/cm-ai-host.mjs +103 -93
- package/scripts/cm-ai-host.test.mjs +34 -18
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +4 -7
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +56 -0
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +1 -2
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -3
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +3 -4
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +13 -19
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +35 -128
- package/scripts/cm-ai-run.mjs +78 -24
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +3 -10
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-stream.test.mjs +36 -0
- package/scripts/cm-claude-worker.test.mjs +21 -3
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-external-batch-host.test.mjs +38 -17
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +3 -9
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-review-recovery.test.mjs +1 -1
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +1 -2
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-notify-command.test.mjs +54 -18
- package/scripts/cm-notify-read-drift.test.mjs +69 -4
- package/scripts/cm-notify.mjs +16 -4
- package/scripts/cm-notify.test.mjs +135 -29
- package/scripts/cm-patrol.test.mjs +3 -2
- package/scripts/cm-prd-drive.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +15 -0
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +31 -0
- package/scripts/cm-release-smoke.sh +2 -14
- package/scripts/cm-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +60 -12
- package/skills/cm-ai/references/js-host-recovery.md +95 -47
- package/skills/cm-ai/references/js-host.md +98 -29
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-init/references/js-host.md +1 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +0 -18
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +0 -475
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Immutable archive of
|
|
1
|
+
// Immutable archive of review source declarations, not proof of reviewer identity or execution.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {createHash} from 'node:crypto';
|
|
@@ -10,6 +10,7 @@ import {writeReviewEvidence} from '../cm-ai/review-evidence-file.mjs';
|
|
|
10
10
|
function archiveBytes({project,reviewPackage,review}){
|
|
11
11
|
const {packageDigest,...body}=reviewPackage;
|
|
12
12
|
need(packageDigest===digest(body)&&body.project===project,'review_package_mismatch');
|
|
13
|
+
// Legacy source/channel/independent labels are checked as declarations only.
|
|
13
14
|
need(review.source==='current_host_review_attestation'&&review.packageDigest===packageDigest
|
|
14
15
|
&&review.independent===true&&['codex-subagent','codex-cli','claude-cli'].includes(review.reviewer),
|
|
15
16
|
'init_review_evidence_invalid');
|
|
@@ -18,6 +19,7 @@ function archiveBytes({project,reviewPackage,review}){
|
|
|
18
19
|
const checked=reviewResultForPaths(review.result,reviewPackage,body.examinedPaths);
|
|
19
20
|
need(checked.verdict==='approved','init_review_not_approved');
|
|
20
21
|
need(path.isAbsolute(project)&&fs.realpathSync(project)===project,'unsupported_path');
|
|
22
|
+
// Retain legacy rendered labels to preserve existing archive bytes and recovery.
|
|
21
23
|
const bytes=Buffer.from(['---','workflow: cm-init',`at: ${review.at}`,`reviewer: ${review.reviewer}`,
|
|
22
24
|
'independent: true','verdict: approved',`package_sha256: ${packageDigest}`,'scope:',
|
|
23
25
|
...body.examinedPaths.map(file=>` - ${file}`),'---','',
|
|
@@ -36,7 +36,7 @@ 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
|
|
39
|
+
instructions:'Use only the configured current-host review channel. For independent review, use an actual fresh reviewer context without author history, per runtime/review.md; self-degraded uses the author context and explains why the independent channel is unavailable. Treat reviewer, independent and contextId as source declarations, not proof of reviewer identity or independent execution. Require declaration format and consistency: independent declares true with a contextId different from the declared author; self-degraded declares false with the declared author contextId and a degradedReason. 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
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);
|
|
41
41
|
need(!signal.aborted,'cancelled');current();
|
|
42
42
|
validatePrdReviewMode(mode,response);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Publish
|
|
1
|
+
// Publish unchanged r1 source declarations. They do not prove reviewer identity or execution.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import {assertPrdBatchActive} from './inputs-replaced.mjs';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -15,8 +15,8 @@ export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorCont
|
|
|
15
15
|
need(typeof reviewPackage.feature==='string'&&/^[1-9]\d*\.[a-z0-9]+(?:-[a-z0-9]+)*$/.test(reviewPackage.feature),'prd_review_feature_invalid');
|
|
16
16
|
const degraded=response.reviewer==='self-degraded';
|
|
17
17
|
shape(response,['reviewer','contextId','independent','at','result',...(degraded?['degradedReason']:[])]);
|
|
18
|
-
//
|
|
19
|
-
//
|
|
18
|
+
// Declared subagent context IDs use canonical spelling, not filesystem paths.
|
|
19
|
+
// Validate declaration format and consistency only, not the actual reviewer identity.
|
|
20
20
|
const context=response.contextId;
|
|
21
21
|
need(typeof context==='string'&&context.length<=128&&!/\s/.test(context));
|
|
22
22
|
if(response.reviewer==='codex-subagent'&&context.startsWith('/')){
|
|
@@ -53,6 +53,8 @@ export function publishPrdReview({specs,reviewPackage,packageDigest,authorContex
|
|
|
53
53
|
need(gate.package_sha256===packageDigest&&['dispatch_unknown','resume_disposition','completed'].includes(gate.outcome),
|
|
54
54
|
'prd_review_unclaimed');
|
|
55
55
|
const {result,examinedPaths,degraded}=inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response});
|
|
56
|
+
// Preserve legacy rendered labels for exact archive-byte compatibility.
|
|
57
|
+
// Their attestation wording does not prove reviewer identity or execution.
|
|
56
58
|
const bytes=Buffer.from(['---',`at: ${response.at}`,`reviewer: ${response.reviewer}`,`independent: ${response.independent}`,
|
|
57
59
|
...(degraded?[`degraded_reason: ${JSON.stringify(response.degradedReason)}`]:[]),`package_sha256: ${packageDigest}`,
|
|
58
60
|
`verdict: ${result.verdict}`,'scope:',...examinedPaths.map(file=>` - ${file}`),'---','',
|
|
@@ -46,9 +46,14 @@ export function inspectPrdSummaryEvidence(specs,{currentFeatures}={}){
|
|
|
46
46
|
if(bytes!==null)evidenceFiles.push({path:file,sha256:sha(bytes)});
|
|
47
47
|
}
|
|
48
48
|
const args={stage,feature:slug,evidence:path.join(specs,prefix+'-r1.md'),receipt:path.join(specs,prefix+'-disposition.json')};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
try{
|
|
49
|
+
let findings=null,archiveIssue={},correctionSelfCheck=null,gate;
|
|
50
|
+
// A historical receipt may bind bytes that a later approved revision changed: register it, never block.
|
|
51
|
+
try{gate=inspectPrdReview(args);}
|
|
52
|
+
catch(error){
|
|
53
|
+
if(!historical)throw error;
|
|
54
|
+
gate={stage,feature:slug,outcome:'unavailable'};archiveIssue={archive:'unavailable',reason:error.code??error.message};
|
|
55
|
+
}
|
|
56
|
+
if(gate.outcome!=='unavailable')try{
|
|
52
57
|
if(['resume_disposition','completed'].includes(gate.outcome))findings=inspectPrdFindings({specs,stage,feature:directory});
|
|
53
58
|
if(gate.outcome==='completed'){
|
|
54
59
|
const receipt=JSON.parse(readCmInitSource(specs,prefix+'-disposition.json').toString('utf8'));
|
|
@@ -67,7 +72,7 @@ export function inspectPrdSummaryEvidence(specs,{currentFeatures}={}){
|
|
|
67
72
|
archiveIssue={archive:original!==null&&!/\n```json\n[^\n]+\n```\n$/.test(original.toString('utf8'))?'legacy_format':'unavailable',
|
|
68
73
|
reason:error.message};
|
|
69
74
|
}
|
|
70
|
-
if(historical
|
|
75
|
+
if(historical&&!['completed','unavailable'].includes(gate.outcome)&&(stage==='split'||gate.outcome!=='dispatch_once'))
|
|
71
76
|
archiveIssue={archive:archiveIssue.archive??'receipt_missing',
|
|
72
77
|
reason:[archiveIssue.reason,'prd_summary_receipt_missing'].filter(Boolean).join('; ')};
|
|
73
78
|
reviews[stage]={gate,independent:findings?.independent??null,verdict:findings?.verdict??null,
|
|
@@ -86,14 +91,24 @@ export function inspectPrdSummaryEvidence(specs,{currentFeatures}={}){
|
|
|
86
91
|
cases={total:null,user:null,generated:null,status:'invalid',reason:'test_cases_invalid'};
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const revisionPath=prdSelfCheckRevisionPath(directory);let revision=null;
|
|
95
|
+
try{
|
|
96
|
+
revision=readPrdSelfCheckRevision(specs,directory);
|
|
97
|
+
if(revision!==null){
|
|
98
|
+
const target=revision.features.find(f=>f.directory===directory);
|
|
99
|
+
evidenceFiles.push({path:revisionPath,sha256:sha(readCmInitSource(specs,revisionPath))});
|
|
100
|
+
// The note is about exactly the revision reviewed by this split, including low-risk designs.
|
|
101
|
+
inspectPrdSplitDesign({specs,feature:directory,draftDigest:revision.draftDigest,
|
|
102
|
+
originalSha:target.documents.find(d=>d.path==='design.md').beforeSha256,
|
|
103
|
+
requirementsSha:target.documents.find(d=>d.path==='requirements.md').beforeSha256});
|
|
104
|
+
}
|
|
105
|
+
}catch(error){
|
|
106
|
+
// Same boundary as the review gate above: a historical revision check registers, never blocks.
|
|
107
|
+
if(!historical)throw error;
|
|
108
|
+
const bytes=readCmInitSource(specs,revisionPath);
|
|
109
|
+
if(bytes!==null&&!evidenceFiles.some(item=>item.path===revisionPath))evidenceFiles.push({path:revisionPath,sha256:sha(bytes)});
|
|
110
|
+
reviews.split={...reviews.split,archive:reviews.split.archive??'unavailable',
|
|
111
|
+
reason:[reviews.split.reason,`self_check_revision:${error.code??error.message}`].filter(Boolean).join('; ')};
|
|
97
112
|
}
|
|
98
113
|
features.push({directory,reviews,cases,...(revision?{selfCheckRevision:{reason:revision.reason,round:revision.round,
|
|
99
114
|
changedFiles:revision.features.find(f=>f.directory===directory).changedFiles}}:{}),...(currentFeatures===undefined?{}:{historical})});
|
|
@@ -511,7 +511,7 @@ export function createCmRefactorHost(raw,{call}){
|
|
|
511
511
|
files:changed.map(name=>({path:name,before:context.original[name],after:files[name]})),analysis,retrospective,rulebook,judgeBefore,reports,
|
|
512
512
|
lessons:{path:lessons,before:context.lessons,after:files.__lessons??context.lessons},project,baselineCommands:config.baselineCommands,judgeCommand:config.judgeCommand,
|
|
513
513
|
preTaskDirty:context.baseline.gitState,route:routes.reviewer,
|
|
514
|
-
instructions:'
|
|
514
|
+
instructions:'Use an actual fresh reviewer context without author history per runtime/review.md. Treat reviewer channel and independent as source declarations; validate their format and consistency without treating them as proof of identity or execution. Review ALL diff including tests/Learning/rules/docs/LESSONS and judge coverage. Return {markdown} with original N4 header binding exact handoff SHA, attempt=round, scope, findings. No writes or unapproved provider. Missing channel is blocked, never invent approval.'});
|
|
515
515
|
// The review is validated in full before it becomes immutable evidence, so a
|
|
516
516
|
// reply that fails (missing header, wrong handoff digest, short scope) stays
|
|
517
517
|
// discardable. An already published review is checked as before (old journals).
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
// supported yet: every path exits 2 there (owner/ACL checks of the secret
|
|
8
8
|
// files are not verified on a real Windows machine). Total deadline: 12 s from
|
|
9
9
|
// the moment this script starts executing. A hard timer armed first at entry
|
|
10
|
-
// exits with
|
|
10
|
+
// exits with 5; file reads are asynchronous so that timer can always fire, and the
|
|
11
11
|
// remaining budget is checked before every read, before the request and
|
|
12
12
|
// before every exit 0. This stays inside the plugin's 15 s kill. Secret files are parsed as data
|
|
13
13
|
// (never executed or exported) and their values are never printed or logged.
|
|
14
14
|
// No retry: a timed-out request may already have been delivered.
|
|
15
|
-
// Exit codes: 0 sent; 2 config or secret problem; 3 network failure
|
|
16
|
-
//
|
|
15
|
+
// Exit codes: 0 sent; 2 config or secret problem; 3 network failure;
|
|
16
|
+
// 4 server rejected or odd response; 5 deadline passed; 6 unexpected error.
|
|
17
|
+
// Kept apart so the launcher's notify.log line (exit code only) tells them apart.
|
|
17
18
|
// CM_NOTIFY_DRY_RUN=1: opens no secret file, no network, prints a redacted request.
|
|
18
19
|
// --check: only verifies that the active channel's files parse; sends nothing.
|
|
19
20
|
import fs from 'node:fs';
|
|
@@ -31,7 +32,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
31
32
|
// doing nothing. When run directly the
|
|
32
33
|
// 12 s hard timer is armed next, and on Windows the very next action is the
|
|
33
34
|
// refusal (exit 2), before anything reads a file. The timer is not unref'd:
|
|
34
|
-
// the process ends with
|
|
35
|
+
// the process ends with 5 at the deadline even if some work never settles.
|
|
35
36
|
export const WINDOWS_UNSUPPORTED='/cm:notify 暂不支持 Windows:密钥文件权限核对尚未在 Windows 实机验证';
|
|
36
37
|
export const NODE_UNSUPPORTED='cm-notify: 当前 Node 没有 import.meta.main,不受支持(插件要求 Node 24.14 或更高版本),没有发送';
|
|
37
38
|
export function entryDecision(main,platform){
|
|
@@ -42,13 +43,13 @@ export function entryDecision(main,platform){
|
|
|
42
43
|
const ENTRY_STARTED_AT=performance.now();
|
|
43
44
|
const ENTRY=entryDecision(import.meta.main,process.platform);
|
|
44
45
|
const armHardTimer=(deadlineMs,startedAt)=>setTimeout(()=>{
|
|
45
|
-
try{process.stderr.write(`cm-notify: 整次调用超过 ${Math.ceil(deadlineMs/1000)} 秒,已放弃\n`);}catch{}process.exit(
|
|
46
|
+
try{process.stderr.write(`cm-notify: 整次调用超过 ${Math.ceil(deadlineMs/1000)} 秒,已放弃\n`);}catch{}process.exit(5);
|
|
46
47
|
},Math.max(0,deadlineMs-(performance.now()-startedAt)));
|
|
47
48
|
if(ENTRY==='unsupported_node'){try{process.stderr.write(`${NODE_UNSUPPORTED}\n`);}catch{}process.exit(3);}
|
|
48
49
|
const ENTRY_HARD_TIMER=ENTRY==='run'||ENTRY==='windows'?armHardTimer(12000,ENTRY_STARTED_AT):null;
|
|
49
50
|
if(ENTRY==='windows'){try{process.stderr.write(`cm-notify: ${WINDOWS_UNSUPPORTED}\n`);}catch{}process.exit(2);}
|
|
50
51
|
|
|
51
|
-
export const SEND_EXIT=Object.freeze({ok:0,config:2,network:3,rejected:4});
|
|
52
|
+
export const SEND_EXIT=Object.freeze({ok:0,config:2,network:3,rejected:4,deadline:5,unexpected:6});
|
|
52
53
|
export const DEADLINE_MS=12000;
|
|
53
54
|
const MAX_FILE=64*1024,MAX_RESPONSE=64*1024,MAX_STDIN=64*1024;
|
|
54
55
|
// Largest file the safe read boundary accepts; /cm:notify never writes a bigger notify.json.
|
|
@@ -214,9 +215,9 @@ export function postJson(url,data,{request=https.request,agent,signal}={}){
|
|
|
214
215
|
parts.push(chunk);
|
|
215
216
|
});
|
|
216
217
|
response.on('end',()=>resolve({status:response.statusCode,raw:Buffer.concat(parts)}));
|
|
217
|
-
response.on('error',()=>reject(new SendError(SEND_EXIT.network,'
|
|
218
|
+
response.on('error',()=>reject(new SendError(SEND_EXIT.network,'网络请求失败')));
|
|
218
219
|
});
|
|
219
|
-
req.on('error',()=>reject(new SendError(SEND_EXIT.network,'
|
|
220
|
+
req.on('error',()=>reject(new SendError(SEND_EXIT.network,'网络请求失败')));
|
|
220
221
|
req.end(data);
|
|
221
222
|
});
|
|
222
223
|
}
|
|
@@ -259,7 +260,7 @@ export async function runSender({argv=[],env=process.env,stdin=process.stdin,std
|
|
|
259
260
|
const started=startedAt??clock(),seconds=Math.ceil(deadlineMs/1000);
|
|
260
261
|
const budget=()=>{
|
|
261
262
|
const left=deadlineMs-(clock()-started);
|
|
262
|
-
if(left<=0)throw new SendError(SEND_EXIT.
|
|
263
|
+
if(left<=0)throw new SendError(SEND_EXIT.deadline,`整次调用超过 ${seconds} 秒,已放弃(未发送)`,{deadline:true});
|
|
263
264
|
return left;
|
|
264
265
|
};
|
|
265
266
|
let timer;
|
|
@@ -281,21 +282,21 @@ export async function runSender({argv=[],env=process.env,stdin=process.stdin,std
|
|
|
281
282
|
const code=responseCodeType(raw);
|
|
282
283
|
if(status!==200||!code.ok)throw new SendError(SEND_EXIT.rejected,`推送返回 http=${Number.isSafeInteger(status)?status:'?'} code类型=${code.type}`);
|
|
283
284
|
// Accepted, but too late: report the deadline (it may have been delivered).
|
|
284
|
-
if(deadlineMs-(clock()-started)<=0)throw new SendError(SEND_EXIT.
|
|
285
|
+
if(deadlineMs-(clock()-started)<=0)throw new SendError(SEND_EXIT.deadline,`整次调用超过 ${seconds} 秒,已放弃(可能已送达)`,{deadline:true});
|
|
285
286
|
return SEND_EXIT.ok;
|
|
286
287
|
})();
|
|
287
288
|
try{
|
|
288
289
|
const result=await Promise.race([work.then(code=>({code}),error=>({error})),deadline]);
|
|
289
|
-
if(result==='deadline'){work.catch(()=>{});say(stderr,`cm-notify: 整次调用超过 ${seconds} 秒,已放弃`);return SEND_EXIT.
|
|
290
|
+
if(result==='deadline'){work.catch(()=>{});say(stderr,`cm-notify: 整次调用超过 ${seconds} 秒,已放弃`);return SEND_EXIT.deadline;}
|
|
290
291
|
if(result.error){
|
|
291
292
|
const error=result.error;
|
|
292
293
|
if(error instanceof SendError){
|
|
293
294
|
const prefix=error.exit===SEND_EXIT.config||error.detail.deadline?'':`${channel} `;
|
|
294
295
|
say(stderr,`cm-notify: ${prefix}${error.message}`);return error.exit;
|
|
295
296
|
}
|
|
296
|
-
say(stderr,'cm-notify: 意外错误(详情已隐藏,避免带出密钥)');return SEND_EXIT.
|
|
297
|
+
say(stderr,'cm-notify: 意外错误(详情已隐藏,避免带出密钥)');return SEND_EXIT.unexpected;
|
|
297
298
|
}
|
|
298
|
-
if(result.code===SEND_EXIT.ok&&deadlineMs-(clock()-started)<=0){say(stderr,`cm-notify: 整次调用超过 ${seconds} 秒,已放弃`);return SEND_EXIT.
|
|
299
|
+
if(result.code===SEND_EXIT.ok&&deadlineMs-(clock()-started)<=0){say(stderr,`cm-notify: 整次调用超过 ${seconds} 秒,已放弃`);return SEND_EXIT.deadline;}
|
|
299
300
|
return result.code;
|
|
300
301
|
}finally{clearTimeout(timer);}
|
|
301
302
|
}
|
|
@@ -304,7 +305,7 @@ export async function runSender({argv=[],env=process.env,stdin=process.stdin,std
|
|
|
304
305
|
// entry block above; tests call it with their own start and deadline.
|
|
305
306
|
export function runCli({argv=process.argv.slice(2),deadlineMs=DEADLINE_MS,softDeadlineMs=deadlineMs,startedAt=performance.now(),
|
|
306
307
|
hardTimer=armHardTimer(deadlineMs,startedAt),senderOptions={}}={}){
|
|
307
|
-
const hard=()=>{try{process.stderr.write('cm-notify: 意外错误(详情已隐藏,避免带出密钥)\n');}catch{}process.exit(SEND_EXIT.
|
|
308
|
+
const hard=()=>{try{process.stderr.write('cm-notify: 意外错误(详情已隐藏,避免带出密钥)\n');}catch{}process.exit(SEND_EXIT.unexpected);};
|
|
308
309
|
process.on('uncaughtException',hard);process.on('unhandledRejection',hard);
|
|
309
310
|
return runSender({argv,deadlineMs:softDeadlineMs,startedAt,...senderOptions})
|
|
310
311
|
.then(code=>{clearTimeout(hardTimer);process.exit(code);},hard);
|
package/runtime/js/notify.mjs
CHANGED
|
@@ -17,6 +17,8 @@ export const NOTIFY_LIMITS=Object.freeze({sameKeyMs:6*3600*1000,perMinute:4,perD
|
|
|
17
17
|
commandTimeoutMs:15000,titleChars:60,bodyChars:500,defaultWaitMinutes:10,defaultCheckWaitMinutes:45,
|
|
18
18
|
defaultIdleMinutes:45});
|
|
19
19
|
const LOCK_STALE_MS=30000,LOG_LIMIT=256*1024;
|
|
20
|
+
// Lock and dedup state are tiny JSON files; perDay sends bound the state size.
|
|
21
|
+
const CONTROL_FILE_LIMIT=256*1024;
|
|
20
22
|
const RUNNER=fileURLToPath(new URL('./notify-run.mjs',import.meta.url));
|
|
21
23
|
|
|
22
24
|
export function notifyHome(env=process.env){
|
|
@@ -196,7 +198,28 @@ const keyHash=key=>createHash('sha256').update(key).digest('hex').slice(0,16);
|
|
|
196
198
|
// older than 30 s; the critical section takes milliseconds) is reclaimed only
|
|
197
199
|
// by renaming it to a unique name and confirming it is byte-identical to the
|
|
198
200
|
// stale lock that was judged; anything else is put back and the notice skipped.
|
|
199
|
-
|
|
201
|
+
// Bounded read of a control file we may not own. lstat first: a symlink (even a
|
|
202
|
+
// dangling one, and even where O_NOFOLLOW is 0 as on Windows), a non-regular
|
|
203
|
+
// file or an oversized file never counts as readable. The descriptor is opened
|
|
204
|
+
// without following links and without blocking (a FIFO cannot stall the host),
|
|
205
|
+
// and must be the same inode lstat saw. Returns {missing:true} only for ENOENT;
|
|
206
|
+
// every other trouble returns null, which skips the notice.
|
|
207
|
+
function readBounded(file,limit){
|
|
208
|
+
let before;
|
|
209
|
+
try{before=fs.lstatSync(file);}catch(error){return error.code==='ENOENT'?{missing:true}:null;}
|
|
210
|
+
if(before.isSymbolicLink()||!before.isFile()||before.size>limit)return null;
|
|
211
|
+
let descriptor=null;
|
|
212
|
+
try{
|
|
213
|
+
descriptor=fs.openSync(file,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW|fs.constants.O_NONBLOCK);
|
|
214
|
+
const info=fs.fstatSync(descriptor);
|
|
215
|
+
if(!info.isFile()||info.size>limit||info.dev!==before.dev||info.ino!==before.ino)return null;
|
|
216
|
+
const buffer=Buffer.alloc(info.size);
|
|
217
|
+
let offset=0;while(offset<info.size){const n=fs.readSync(descriptor,buffer,offset,info.size-offset,offset);if(n===0)break;offset+=n;}
|
|
218
|
+
return {text:buffer.subarray(0,offset).toString('utf8')};
|
|
219
|
+
}catch{return null;}
|
|
220
|
+
finally{if(descriptor!==null)try{fs.closeSync(descriptor);}catch{}}
|
|
221
|
+
}
|
|
222
|
+
function readLock(file){const read=readBounded(file,CONTROL_FILE_LIMIT);return read===null||read.missing?null:read.text;}
|
|
200
223
|
function stale(raw){
|
|
201
224
|
let value;try{value=JSON.parse(raw);}catch{return false;}
|
|
202
225
|
if(!Number.isSafeInteger(value?.pid)||!Number.isFinite(value?.at))return false;
|
|
@@ -230,8 +253,8 @@ function reserve(home,hash,now){
|
|
|
230
253
|
const lock=takeLock(lockFile);if(lock===null)return 'state_busy';
|
|
231
254
|
try{
|
|
232
255
|
let state={version:1,keys:{},sends:[]};
|
|
233
|
-
|
|
234
|
-
|
|
256
|
+
const read=readBounded(stateFile,CONTROL_FILE_LIMIT);if(read===null)return 'state_invalid';
|
|
257
|
+
if(!read.missing){try{state=JSON.parse(read.text);}catch{return 'state_invalid';}}
|
|
235
258
|
if(!state||state.version!==1||!state.keys||typeof state.keys!=='object'||Array.isArray(state.keys)
|
|
236
259
|
||!Array.isArray(state.sends)||!state.sends.every(Number.isFinite)
|
|
237
260
|
||!Object.values(state.keys).every(Number.isFinite))return 'state_invalid';
|
|
@@ -381,7 +404,7 @@ const AI_PROGRESS_CODES=new Set(['context_refreshed','context_complete','qa_skip
|
|
|
381
404
|
const AI_STUCK_STATES=new Set(['blocked','unknown','pending_review','cancelled','awaiting_spec_approval']);
|
|
382
405
|
const AI_STUCK_ACTIONS=new Set(['reconcile','abandon_effect','abandon_review','reconcile_review','bootstrap_review_recover',
|
|
383
406
|
'review_evidence','spec_rebind','fix_authorization','fix_dispatch','qa_execution']);
|
|
384
|
-
const AI_STUCK_CODES=new Set(['
|
|
407
|
+
const AI_STUCK_CODES=new Set(['permission_denied','provider_development_authorization_required',
|
|
385
408
|
'qa_decision_required','qa_mandatory_required','qa_triggered','qa_blocked','qa_failed','qa_result_blocked',
|
|
386
409
|
'qa_execution_unknown','correction_review_required','project_qa_not_passed','documentation_sync_blocked',
|
|
387
410
|
'handoff_exists','spec_drift','qa_fix_code_unmatched',
|
|
@@ -34,7 +34,8 @@ export const LEGACY_TEST_POLICIES=Object.freeze([Object.freeze({since:'0b3040e',
|
|
|
34
34
|
// Known versions of the changed documents that may continue a legacy binding.
|
|
35
35
|
export const POLICY_DOC_SUCCESSORS=Object.freeze({
|
|
36
36
|
'skills/cm-init/references/js-host.md':Object.freeze(['d3d6ad0b02ee7d3863302c49a9434b1a9f423e8ab4ff332cd9ad077a0b270fb1',
|
|
37
|
-
'223dd3a4a4172591480bff818bc81216d5554ea1c7c7785619ccab33ee3fd833'
|
|
37
|
+
'223dd3a4a4172591480bff818bc81216d5554ea1c7c7785619ccab33ee3fd833',
|
|
38
|
+
'b218527db47bfa2c995173a0d80e3927e1bb8946c397a2945c3c09e73639af59']),
|
|
38
39
|
'skills/cm-test/references/js-host.md':Object.freeze(['0a6023c9036693a93a17650872b634b33d68eecc2fbece188519e94e31452e8c']),
|
|
39
40
|
});
|
|
40
41
|
// cm-init: files is the current [[relativePath, content|null], ...] policy list.
|
package/runtime/review.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Every implementation task requires an independent review before it can be marked complete. The reviewer must not inherit the author's reasoning narrative.
|
|
4
4
|
|
|
5
|
+
CM 门禁检查来源声明的格式、任务与轮次、材料摘要、当前文件和执行记录的一致性,用于防手滑与过期证据。来源声明不验证审查者身份或实际人工交互;门禁不承诺抵抗拥有完整文件写权限和 shell 能力的会话造假。fresh 上下文、审查结果、检查通过和完成复查仍是正常工作流路径的完成条件。发布、部署、资金及其他范围外动作继续遵守其单独确认要求。
|
|
6
|
+
|
|
5
7
|
N4 accepts only a `ready_for_review` implementation handoff validated through
|
|
6
8
|
`runtime/task-gates.md`. The handoff is author evidence, never an approval. The
|
|
7
9
|
review file owns the disposition that controls whether N3 retries or N5 may mark
|
|
@@ -62,10 +64,18 @@ to erase a valid blocking finding.
|
|
|
62
64
|
|
|
63
65
|
The shared-JS target supports a fresh reviewer on whichever provider is available.
|
|
64
66
|
The shared V3 runner now also accepts Claude-bound normalized review invocations,
|
|
65
|
-
using the same
|
|
67
|
+
using the same request/package binding, registration, reviewer source declarations, replay and completion checks.
|
|
68
|
+
cm-ai uses the `host-review` source channel; cm-fix retains its existing
|
|
69
|
+
`host-authorized` contract. A cm-ai journal with old grant-channel invocations is
|
|
70
|
+
rejected as `runner_invocation`; preserve it and use the original version's
|
|
71
|
+
read-only tools to inspect history. This entry does not replay or migrate those
|
|
72
|
+
invocations.
|
|
66
73
|
Its registered result is published as `claude-cli`, never relabeled as Codex.
|
|
67
74
|
The single-task host connects the Claude worker only with a matching diagnostic and
|
|
68
|
-
|
|
75
|
+
the active control contract: cm-ai advances ordinary review rounds directly within
|
|
76
|
+
the confirmed scope, for both existing and new runs. Requests and receipts bind
|
|
77
|
+
the actual invocation, package and execution records to detect stale or mismatched
|
|
78
|
+
materials. Claude preflight uses a macOS loopback-only sandbox,
|
|
69
79
|
synthetic credentials and a rejecting local sink; it does not obtain a model review.
|
|
70
80
|
The producer permits one empty startup health probe and rejects model requests locally.
|
|
71
81
|
Installed CLI has passed this local request-surface probe. It uses the same bounded temporary
|
|
@@ -73,6 +83,15 @@ directory for CLAUDE_CODE_TMPDIR and stops after the first valid message request
|
|
|
73
83
|
termination is not user cancellation or a successful review; real model review remains unverified.
|
|
74
84
|
Do not handcraft a passing diagnostic or approval to bypass readiness evidence.
|
|
75
85
|
Claude review streams accept `system/api_retry`, `hook_started`, `hook_response` and `commands_changed` only as `onNotice` summaries, sharing a 32-notice limit with `rate_limit_event`; they never enter observation or advance the verdict stage, and unknown system subtypes still fail closed (2026-09-17 dogfood: a transient API retry was misclassified as `unexpected_event`).
|
|
86
|
+
`system/ui_invalidate` is a fixed, body-free notice before or after `init`, as is
|
|
87
|
+
the existing `dev_intent` startup notice. Both bind the session and share the
|
|
88
|
+
same 32 slots; neither initializes a turn nor supplies a verdict. Missing init,
|
|
89
|
+
cross-session messages, unknown subtypes and post-terminal messages still fail.
|
|
90
|
+
The local probe still requires a compliant `/v1/messages` request; startup
|
|
91
|
+
health checks alone cannot pass (Claude Code 2.1.289 startup regression).
|
|
92
|
+
Claude probe model IDs are matched exactly against the outgoing request. Use
|
|
93
|
+
the full model ID when a CLI alias resolves to a different ID; a health response
|
|
94
|
+
or a mismatched model must not be converted into a passing diagnostic.
|
|
76
95
|
`system/thinking_tokens` has a separate 4096-event budget and remains subject to the worker's total 1,000,000-byte output cap; it emits no observation or notice and never advances the verdict stage (2026-09-17 dogfood: an 88-heartbeat review exceeded the former 64-event cap). The 4097th heartbeat fails with `unexpected_event`; output overflow retains `output_limit`.
|
|
77
96
|
|
|
78
97
|
## Review scope
|
|
@@ -105,10 +124,46 @@ PRD artifact 回执先比对原始字节,仅 Markdown 中 `tasks.md` 的任务
|
|
|
105
124
|
proceed only when the reviewer records `approved` and the disagreement is
|
|
106
125
|
preserved in `LESSONS.md`.
|
|
107
126
|
|
|
108
|
-
A concrete
|
|
127
|
+
A concrete local correction after the user confirms its scope may use the
|
|
109
128
|
one-shot task-gate entrance in `docs/human-correction.md`. It preserves the original
|
|
110
|
-
reports,
|
|
111
|
-
|
|
129
|
+
reports, records the correction reason and bound source declaration, seals a fresh
|
|
130
|
+
independent correction review, and does not reopen a host journal or reset ordinary
|
|
131
|
+
attempts. The record reports the supplied decision source; it does not create approval.
|
|
132
|
+
|
|
133
|
+
A separate version-two taskgate protocol, `cm-controlled-correction`, is one-shot
|
|
134
|
+
(`version:2`, `continuation:1`), described in `docs/cm-control-policy-v2.md`.
|
|
135
|
+
It supports only compatibility taskgate tasks without JS ownership. A retained
|
|
136
|
+
JS journal, JS run or unknown ownership evidence blocks the compatibility writer
|
|
137
|
+
and must be rejected before correction preparation. Do not delete that evidence
|
|
138
|
+
or hand-edit ownership to enter this protocol. It
|
|
139
|
+
records the concrete correction decision as provenance-only `operator` or `model`,
|
|
140
|
+
without claiming human authentication or approval. It keeps the original blocked
|
|
141
|
+
round-two report and every blocking finding, including P2, as immutable history.
|
|
142
|
+
Finalize the actual in-scope revision, relevant checks and Learning/handoff first;
|
|
143
|
+
then review the complete revised package through a fresh independent channel.
|
|
144
|
+
Only approved, zero-blocking evidence bound to the correction record, final
|
|
145
|
+
handoff and current implementation can enter the existing N4/N5 completion gate.
|
|
146
|
+
Its v2 correction review body is strict raw JSON with exactly `conclusion`,
|
|
147
|
+
`findings`, and `resolved_findings`. Each finding has exactly `id`, `priority`
|
|
148
|
+
(P0-P3), and nonempty `evidence`; ids are unique across both arrays. Active
|
|
149
|
+
`findings.length` equals the header's `blocking_findings`. Approved requires
|
|
150
|
+
`conclusion: "Zero findings."` and an empty active findings array; other verdicts
|
|
151
|
+
require `"Blocking findings."`. Fixed historical P2 belongs only in
|
|
152
|
+
`resolved_findings`. A zero-findings phrase cannot hide a remaining P2, extra prose
|
|
153
|
+
or a mismatched count. This structured-body rule does not change legacy human
|
|
154
|
+
correction review bodies.
|
|
155
|
+
This slice connects only owner-free compatibility taskgate correction evidence
|
|
156
|
+
and the exact task checkbox. cm-ai v2 single-task and batch round-two runs remain
|
|
157
|
+
formally blocked; no runner-owned correction completion entrance exists. Even
|
|
158
|
+
prepared/published taskgate evidence cannot complete a JS-owned run. No original
|
|
159
|
+
batch restoration, N6/N7/N8 advance or `run_done` follows this compatibility
|
|
160
|
+
protocol. Do not hand-edit journal or batch state to claim workflow completion.
|
|
161
|
+
It is not attempt 3, does not reset a host journal, and cannot coexist with the
|
|
162
|
+
legacy human continuation. Source labels, model output and V3 grants do not expand
|
|
163
|
+
real conversation authorization, code scope, external sends, Git/push, publication,
|
|
164
|
+
deployment or financial permissions. Safety/data-correctness disputes that need
|
|
165
|
+
a human decision still require that decision; unavailable review capacity remains
|
|
166
|
+
pending, never self-approved.
|
|
112
167
|
|
|
113
168
|
At any stage, changing reviewed code, tests, or execution instructions invalidates
|
|
114
169
|
approval for the changed content. N5 may record improvement suggestions, not make
|
|
@@ -145,8 +200,7 @@ verdict 至少为 1。`self-degraded` 必须写 `independent: false` 并增加
|
|
|
145
200
|
`--project-root` 复算;否则文件内容在审查后变化时无法进入 N5。历史恢复显式使用
|
|
146
201
|
`--allow-legacy-unbound` 时不属于内容绑定审查,必须在证据中披露。
|
|
147
202
|
历史 `self-degraded` 可读取和审计,但不得据此授权新完成或补造独立审查。
|
|
148
|
-
|
|
149
|
-
核对真实通道、任务增量及验证证据,不把当前声明门禁当成完整执行凭据机制。
|
|
203
|
+
`reviewer` 与 `independent` 是审查来源声明;`decision_source` 若由相应入口记录,也仅表示决定来源。字段和摘要用于核对本轮材料与执行记录的一致性。主执行者仍按正常工作流取得 fresh 审查、核对任务增量及验证证据。
|
|
150
204
|
|
|
151
205
|
No matching evidence file means review did not happen. File existence alone is
|
|
152
206
|
not approval: the completion node must run the `cm-task-gate.py mark-done` lock
|
package/runtime/task-gates.md
CHANGED
|
@@ -5,6 +5,8 @@ creating a second task-state database. `tasks.md` remains the authoritative
|
|
|
5
5
|
business-task state. Handoffs and review files are content-bound evidence under the
|
|
6
6
|
existing `{SPECS_DIR}/.reviews/` domain.
|
|
7
7
|
|
|
8
|
+
CM 门禁检查来源声明的格式、任务与轮次、材料摘要、当前文件和执行记录的一致性,用于防手滑与过期证据。来源声明不验证审查者身份或实际人工交互;门禁不承诺抵抗拥有完整文件写权限和 shell 能力的会话造假。fresh 上下文、审查结果、检查通过和完成复查仍是正常工作流路径的完成条件。发布、部署、资金及其他范围外动作继续遵守其单独确认要求。
|
|
9
|
+
|
|
8
10
|
## Implementation handoff
|
|
9
11
|
|
|
10
12
|
The active cm-ai Skill passes `--require-learning` to `check-n4` and the existing
|
|
@@ -15,6 +17,42 @@ The flag checks record completeness, not the truth of an agent's statement; inde
|
|
|
15
17
|
review still verifies the actual work. Legacy callers remain compatible without this
|
|
16
18
|
flag, and the persistent runner retains its existing structured Learning checks.
|
|
17
19
|
|
|
20
|
+
Inventory verification is enabled only by the compatibility command-line entry.
|
|
21
|
+
`main()` passes the internal function option `inventory: 'required'` to `check-n4`,
|
|
22
|
+
`check-n5`, `prepare-mark-done`, `verify-mark-done-plan` and `mark-done-locked`.
|
|
23
|
+
Completion preparation and rechecks forward the same selectors to N5, including
|
|
24
|
+
human corrections. This is not a CLI flag. Exported library functions default to
|
|
25
|
+
the original result fields and errors without inventory checks; JS task completion,
|
|
26
|
+
cm-fix and cm-refactor retain their own review-package baselines.
|
|
27
|
+
|
|
28
|
+
Before compatibility N3 edits any file, the main executor captures the task's starting inventory:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
node {CM_WORKFLOW_ROOT}/scripts/cm-task-gate.mjs capture-baseline \
|
|
32
|
+
--project-root {CODE_PROJECT} \
|
|
33
|
+
--reviews-dir {SPECS_DIR}/.reviews \
|
|
34
|
+
--feature {FEATURE_SLUG} --task {T-xxx}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This writes `{feature}-{task}-baseline.json` under the reviews directory. It seals
|
|
38
|
+
identity, canonical-root digest, stable ignore policy, relative file paths, SHA-256,
|
|
39
|
+
byte sizes and executable bits with a whole-record digest; it stores no file bodies.
|
|
40
|
+
The existing review-package scanner excludes dependencies, fixed junk, Git-ignored
|
|
41
|
+
paths and specs. A nested canonical `.reviews` parent is the specs subtree; when
|
|
42
|
+
`.reviews` is at the code root only that directory is excluded. Any other directory
|
|
43
|
+
that merely shares the `.reviews` name is ordinary code and stays in the inventory.
|
|
44
|
+
External specs do not enter the code root.
|
|
45
|
+
The same baseline/current ignore union filters both sides; AGENTS.md remains checked.
|
|
46
|
+
When Git ignore policy is unavailable (as may happen on Windows), scanning falls back to built-in rules; Git-ignored files count as changes and must be listed or handled before the gate can pass.
|
|
47
|
+
Capture refuses beyond 10,000 files or 1 GiB of inventory bytes, names the triggering
|
|
48
|
+
file and writes no partial baseline. Capture cannot prove it preceded an edit;
|
|
49
|
+
executors and independent reviewers must verify that ordering.
|
|
50
|
+
|
|
51
|
+
An existing baseline is never overwritten. If it is wrong, a human must delete
|
|
52
|
+
that file, capture again, and add one `decision` line to the authoritative run log.
|
|
53
|
+
Attempt 2 reuses attempt 1's baseline; changes accumulate from the task start.
|
|
54
|
+
This compatibility command supports one `--project-root`, not `codeProjectPaths`.
|
|
55
|
+
|
|
18
56
|
For attempt 1 or 2, N3 writes:
|
|
19
57
|
|
|
20
58
|
```text
|
|
@@ -36,7 +74,7 @@ portable across macOS, Linux, and Windows.
|
|
|
36
74
|
Before writing a new handoff, hash the exact `changed_files` set:
|
|
37
75
|
|
|
38
76
|
```bash
|
|
39
|
-
|
|
77
|
+
node {CM_WORKFLOW_ROOT}/scripts/cm-task-gate.mjs hash-implementation \
|
|
40
78
|
--project-root {CODE_PROJECT} \
|
|
41
79
|
--file path/one --file path/two
|
|
42
80
|
```
|
|
@@ -48,9 +86,23 @@ symlinks and directories are rejected. Historical unbound handoffs require the
|
|
|
48
86
|
explicit recovery flag `--allow-legacy-unbound` and return `content_bound: false`;
|
|
49
87
|
new work must not use that flag.
|
|
50
88
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
89
|
+
With a baseline, CLI `check-n4` and `check-n5` reconstruct the actual added, modified
|
|
90
|
+
(including executable-bit changes) and deleted paths from the starting inventory
|
|
91
|
+
and current tree. `changed_files` must equal that set. Mismatch lists “改了但没列”
|
|
92
|
+
and “列了但没改”, each capped at 20 paths with `+N more`. Success returns
|
|
93
|
+
`inventory: "verified"` and `inventory_counts: {added, modified, deleted}`.
|
|
94
|
+
Content binding remains mandatory and independent of inventory verification.
|
|
95
|
+
Preexisting dirty content is part of the baseline; concurrent unrelated edits are
|
|
96
|
+
still task-period changes and must be reconciled before review.
|
|
97
|
+
|
|
98
|
+
A missing baseline blocks these CLI entries. Only explicit `--allow-legacy-unbound`
|
|
99
|
+
recovery returns `inventory: "unverified"` and the fixed `inventory_note`:
|
|
100
|
+
“未捕获编辑前基线,不保证清单完整,只保证已列文件的内容绑定”。
|
|
101
|
+
If the legacy handoff also lacks its content digest, `content_bound` remains false;
|
|
102
|
+
the note does not create a missing content binding. The flag cannot bypass a corrupt,
|
|
103
|
+
wrong-task or wrong-root baseline. The unchanged handoff schema carries no baseline
|
|
104
|
+
fields. Before writing the handoff, reconcile the complete file list; after writing,
|
|
105
|
+
run N4 and keep its digest and inventory result for independent review.
|
|
54
106
|
|
|
55
107
|
Validate the evidence before N4:
|
|
56
108
|
|
|
@@ -82,14 +134,58 @@ handoff_sha256: <lowercase SHA-256 returned by check-n4>
|
|
|
82
134
|
entry and the body must contain findings or an explicit zero-findings result.
|
|
83
135
|
`changes_requested` returns to N3 and produces the next attempt. N4 never edits
|
|
84
136
|
implementation files. Round 2 cannot create attempt 3: another blocking result
|
|
85
|
-
becomes `blocked
|
|
137
|
+
becomes `blocked`. Safety/data-correctness disputes still require a real human
|
|
138
|
+
decision under `runtime/review.md`; the separately bounded continuation protocols
|
|
139
|
+
below do not create ordinary attempt 3 or erase blocking findings.
|
|
86
140
|
|
|
87
|
-
For
|
|
141
|
+
For a correction with confirmed scope after round-two blocked, see
|
|
88
142
|
`docs/human-correction.md`: `prepare-human-correction` and
|
|
89
143
|
`publish-human-correction-review` keep the original four records and bind a separate
|
|
90
|
-
one-shot correction
|
|
144
|
+
one-shot correction with its reason and bound decision-source declaration. These
|
|
145
|
+
records do not create approval. N4/N5 and locked completion accept its fixed `--correction`
|
|
91
146
|
record; legacy-unbound flags do not weaken correction checks.
|
|
92
147
|
|
|
148
|
+
A separate version-two compatibility taskgate entrance provides one-shot
|
|
149
|
+
`cm-controlled-correction` evidence
|
|
150
|
+
(`version:2`, `continuation:1`), prepared by `prepare-controlled-correction` and
|
|
151
|
+
sealed by `publish-controlled-correction-review`; see `docs/cm-control-policy-v2.md`.
|
|
152
|
+
It supports only tasks without JS ownership. Retained JS journal/run/unknown
|
|
153
|
+
evidence blocks the compatibility writer and must reject preparation first;
|
|
154
|
+
prepared/published correction evidence cannot bypass that ownership gate.
|
|
155
|
+
`--decision-source operator|model` is provenance only, not authentication or human
|
|
156
|
+
approval. Neither entrance accepts `--human-authorized`; the legacy human protocol
|
|
157
|
+
binds only its reason and source declaration. The two continuations are mutually exclusive.
|
|
158
|
+
Both prepare commands hold the shared `{feature}-{task}-correction-prepare.lock`
|
|
159
|
+
through preparation, with PID/time ownership and fail-fast contention. A peer's
|
|
160
|
+
orphan handoff alone is preserved for bounded preparation recovery; any peer
|
|
161
|
+
record/review/receipt prevents another continuation. Interrupted locks are not
|
|
162
|
+
automatically removed: verify the owner has exited, inspect preparation/sealed
|
|
163
|
+
evidence and coordinate explicitly. An active or unknown owner never authorizes
|
|
164
|
+
lock deletion, retry or automatic crash recovery.
|
|
165
|
+
The gate pins the original r1/r2 handoff/review history, keeps blocked r2 and P2
|
|
166
|
+
findings, and binds the corrected implementation plus finalized Learning/handoff.
|
|
167
|
+
A fresh independent review must cover the complete correction scope, bind
|
|
168
|
+
`correction_sha256` and `handoff_sha256`, and report approved with zero blocking
|
|
169
|
+
findings. The v2 review's strict raw JSON body has exactly `conclusion`, `findings`
|
|
170
|
+
and `resolved_findings`; item keys are exactly `id`, `priority` (P0-P3), and
|
|
171
|
+
`evidence`, with ids unique across both arrays. Active findings count must equal
|
|
172
|
+
`blocking_findings`; approved requires `"Zero findings."` with no active finding,
|
|
173
|
+
while non-approved requires `"Blocking findings."`. Repaired historical P2 is
|
|
174
|
+
recorded only in resolved findings. A zero-findings phrase does not suppress an
|
|
175
|
+
active P2 or extra text; the old human body contract stays unchanged.
|
|
176
|
+
N4/N5 and locked completion consume that sealed evidence through the
|
|
177
|
+
existing fixed `--correction` selector. Drift, missing Learning, duplicate
|
|
178
|
+
continuation or a new blocking finding refuses completion; no manual checkbox,
|
|
179
|
+
third ordinary round, journal reset or extra completion path is introduced.
|
|
180
|
+
This correction slice changes only owner-free compatibility taskgate evidence
|
|
181
|
+
and the exact task checkbox. cm-ai v2 single-task and batch r2 remains formally
|
|
182
|
+
blocked, with no runner-owned correction completion entrance. Compatibility
|
|
183
|
+
`mark-done` cannot finish that JS-owned run, restore its batch, advance N6/N7/N8
|
|
184
|
+
or publish `run_done`. Never delete ownership evidence or hand-edit journal/batch
|
|
185
|
+
state to imply completion.
|
|
186
|
+
The source declaration cannot widen real dialogue authorization or external
|
|
187
|
+
push, publication, deployment and financial permissions.
|
|
188
|
+
|
|
93
189
|
N5 must let the JavaScript gate validate and update the exact task checkbox while
|
|
94
190
|
the compatibility entry holds the existing platform ownership lock:
|
|
95
191
|
|
|
@@ -180,8 +276,10 @@ completion. Missing independent capacity leaves work pending; do not add a skip
|
|
|
180
276
|
flag or treat diagnostic approval as independent. Existing completed tasks are
|
|
181
277
|
not automatically reopened or assigned fabricated review evidence.
|
|
182
278
|
|
|
183
|
-
|
|
184
|
-
|
|
279
|
+
`reviewer`, `independent` and any `decision_source` are source declarations.
|
|
280
|
+
This gate checks their format and binding to the task, materials and execution
|
|
281
|
+
records; it does not authenticate the reviewer or the reported interaction. It
|
|
282
|
+
also does not provide an immutable code snapshot or full crash-recoverable completion. Any post-review change to reviewed code,
|
|
185
283
|
tests, or instructions needs fresh evidence under `runtime/review.md`, including
|
|
186
284
|
changes suggested during N5 lesson recording.
|
|
187
285
|
|
|
@@ -41,14 +41,7 @@ function execution(f,verdict='blocked'){
|
|
|
41
41
|
requestedModel:'fixture',worker:async()=>{fs.writeFileSync(path.join(f.codeProject,'a.mjs'),'written\n');
|
|
42
42
|
return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
43
43
|
retrospective:{status:'no_new_lesson',candidates:[],reason:null}}};}})},
|
|
44
|
-
reviewers:[reviewer],reviewInvocation:{developerThreadId:'author-thread',excludedThreadIds:['control'],
|
|
45
|
-
authorize:(value,{authorizationAt})=>{const body={version:1,kind:'cm-review-dispatch-grant',
|
|
46
|
-
grantId:'grant',adapterId:'codex-review-adapter',invocationId:value.invocationId,
|
|
47
|
-
requestDigest:value.requestDigest,identity:value.identity,reviewerId:'reviewer',
|
|
48
|
-
logicalContextId:value.contextId,packageDigest:value.payload.reviewPackage.packageDigest,
|
|
49
|
-
hostContextId:'control',decisionId:'approved',decision:'approved',issuedAt:authorizationAt,
|
|
50
|
-
expiresAt:authorizationAt+60000};return {...body,grantDigest:digest(body)};}},
|
|
51
|
-
hostDecision:{status:'approved'},check:createHostCheck({cwd:f.codeProject,
|
|
44
|
+
reviewers:[reviewer],reviewInvocation:{developerThreadId:'author-thread',excludedThreadIds:['control']},check:createHostCheck({cwd:f.codeProject,
|
|
52
45
|
commands:[{id:'syntax',command:[process.execPath,'--check','a.mjs']}]})};
|
|
53
46
|
}
|
|
54
47
|
async function start(f,runId,verdict='blocked',options={}){
|