@tea-agent/loop-agent 0.27.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/application/task-lifecycle/observe.js +5 -0
- package/dist/application/task-lifecycle/plan-transitions.js +7 -2
- package/dist/cli/program.js +1 -1
- package/dist/commands/client-recovery.js +439 -20
- package/dist/commands/init.js +42 -6
- package/dist/executors/dag-pi-executor.js +143 -38
- package/dist/executors/pi-playwright-cli-tool.js +955 -0
- package/dist/executors/pi-sdk-executor.js +56 -0
- package/dist/executors/playwright-cli-launcher.js +63 -0
- package/dist/executors/shell-executor.js +128 -0
- package/dist/shared/playwright-cli-command-policy.js +41 -0
- package/dist/worker/observability/read-model.js +66 -8
- package/dist/worker/observe/static/dag-model.js +85 -13
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +4 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +13 -13
- package/dist/workflows/dag/frontend-test-case-checklist.js +201 -8
- package/dist/workflows/dag/frontend-test-result-contract.js +52 -3
- package/dist/workflows/dag/init-hybrid.js +116 -30
- package/dist/workflows/dag/lifecycle.js +33 -2
- package/dist/workflows/dag/node-execution.js +11 -5
- package/dist/workflows/dag/output-protocol.js +25 -83
- package/dist/workflows/dag/report.js +9 -2
- package/dist/workflows/dag/rerun-run.js +62 -3
- package/dist/workflows/dag/run-store.js +6 -1
- package/dist/workflows/dag/runner.js +15 -3
- package/dist/workflows/dag/types.js +27 -0
- package/dist/workflows/dag/validate.js +121 -1
- package/docs/architecture/runtime-boundaries.md +13 -11
- package/docs/init-surface.manifest.json +6 -2
- package/docs/templates/README.md +9 -1
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +14 -7
- package/docs/templates/frontend-test-dag.json +55 -15
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +7 -9
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +1 -1
- package/harness.json +1 -1
- package/package.json +1 -1
- package/skills/loop-agent/SKILL.md +1 -1
- package/skills/loop-agent/references/command-reference.md +18 -6
- package/skills/playwright-cli/SKILL.md +69 -402
- package/skills/playwright-cli/references/tracing.md +3 -137
- package/skills/playwright-cli/references/video-recording.md +3 -141
- package/skills/playwright-cli-case-generator/SKILL.md +53 -46
|
@@ -734,15 +734,16 @@ function resolveImplementPaths(taskConfig, options = {}) {
|
|
|
734
734
|
return normalized === "docs" || normalized.startsWith("docs/");
|
|
735
735
|
});
|
|
736
736
|
if (repoRoot && mayNeedDocIndex) {
|
|
737
|
-
const
|
|
737
|
+
const closure = mergeDocumentIndexCompanions({
|
|
738
738
|
repoRoot,
|
|
739
739
|
paths: allowed,
|
|
740
740
|
forbiddenPaths: forbidden,
|
|
741
741
|
});
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
742
|
+
const explicitAllowedPaths = new Set(allowed.map((entry) => entry.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "")));
|
|
743
|
+
const missingCompanions = closure.companions.filter((companion) => !explicitAllowedPaths.has(companion));
|
|
744
|
+
if (missingCompanions.length > 0) {
|
|
745
|
+
throw new Error(`document-index-closure: catalog companion paths must be explicitly authorized in task allowedPaths: ${missingCompanions.map((companion) => `"${companion}"`).join(", ")}. Add each missing path with task advance --allowed-path <path>; required command(s): ${missingCompanions.map((companion) => `task advance --allowed-path ${companion}`).join("; ")}`);
|
|
746
|
+
}
|
|
746
747
|
}
|
|
747
748
|
return {
|
|
748
749
|
allowedPaths: allowed,
|
|
@@ -1688,6 +1689,7 @@ export function buildStandardHybridDagFromTask(sources) {
|
|
|
1688
1689
|
writeSet: implementPaths.writeSet,
|
|
1689
1690
|
allowedPaths: implementPaths.allowedPaths,
|
|
1690
1691
|
forbiddenPaths,
|
|
1692
|
+
writerOutcomePolicy: { type: "implementation-outcome-v1" },
|
|
1691
1693
|
subtask_prompt: [
|
|
1692
1694
|
"Implement the approved plan with minimal focused changes.",
|
|
1693
1695
|
"Stay within writeSet. Do not write root artifacts/** unless artifacts paths are explicitly declared in writeSet.",
|
|
@@ -3755,9 +3757,48 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
3755
3757
|
assertValidDagSpec(spec);
|
|
3756
3758
|
return spec;
|
|
3757
3759
|
}
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3760
|
+
/**
|
|
3761
|
+
* Resolve the browser origin only from controller-owned task source bytes.
|
|
3762
|
+
* Model-authored RAG/case/evidence files are intentionally excluded.
|
|
3763
|
+
*/
|
|
3764
|
+
export function resolveControllerFrontendBaseUrl(sources) {
|
|
3765
|
+
const candidates = (sources.referenceDocuments ?? [])
|
|
3766
|
+
.filter((document) => /(?:^|[\\/])config\.md$/i.test(document.path))
|
|
3767
|
+
.map((document) => ({
|
|
3768
|
+
markdown: document.markdown,
|
|
3769
|
+
source: toDagSourcePath(sources, document.path),
|
|
3770
|
+
}));
|
|
3771
|
+
let rawBaseUrl = "http://localhost:5173";
|
|
3772
|
+
let baseUrlSource = "default-localhost-5173";
|
|
3773
|
+
for (const candidate of candidates) {
|
|
3774
|
+
const match = candidate.markdown.match(/(?:frontend[_-]?base[_-]?url|base[_-]?url|base[- ]url)\s*[:=]\s*["'`]?((?:https?):\/\/[^\s"'`<>]+)/i);
|
|
3775
|
+
if (!match?.[1]) {
|
|
3776
|
+
if (/(?:frontend[_-]?base[_-]?url|base[_-]?url|base[- ]url)\s*[:=]/i.test(candidate.markdown)) {
|
|
3777
|
+
throw new Error(`frontend-test controller baseUrl is invalid (${candidate.source})`);
|
|
3778
|
+
}
|
|
3779
|
+
continue;
|
|
3780
|
+
}
|
|
3781
|
+
rawBaseUrl = match[1].replace(/[)\]},.;]+$/, "");
|
|
3782
|
+
baseUrlSource = candidate.source;
|
|
3783
|
+
break;
|
|
3784
|
+
}
|
|
3785
|
+
let parsed;
|
|
3786
|
+
try {
|
|
3787
|
+
parsed = new URL(rawBaseUrl);
|
|
3788
|
+
}
|
|
3789
|
+
catch {
|
|
3790
|
+
throw new Error(`frontend-test controller baseUrl is invalid (${baseUrlSource})`);
|
|
3791
|
+
}
|
|
3792
|
+
if ((parsed.protocol !== "http:" && parsed.protocol !== "https:") ||
|
|
3793
|
+
parsed.username ||
|
|
3794
|
+
parsed.password ||
|
|
3795
|
+
parsed.search ||
|
|
3796
|
+
parsed.hash ||
|
|
3797
|
+
/(?:^|\.)(?:www\.)?[^.]*(?:prod|production)/i.test(parsed.hostname)) {
|
|
3798
|
+
throw new Error(`frontend-test controller baseUrl is unsafe (${baseUrlSource})`);
|
|
3799
|
+
}
|
|
3800
|
+
return { baseUrl: parsed.toString(), baseUrlSource };
|
|
3801
|
+
}
|
|
3761
3802
|
function buildFrontendTestHybridDag(sources) {
|
|
3762
3803
|
const rawFrontendTest = sources.taskConfig.frontendTest;
|
|
3763
3804
|
const config = {
|
|
@@ -3780,7 +3821,14 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3780
3821
|
throw new Error('frontend-test requires task.json allowedPaths to include "testcase/frontend/**" (or an explicit containing glob).');
|
|
3781
3822
|
}
|
|
3782
3823
|
const forbidden = commonForbiddenPaths(sources);
|
|
3824
|
+
const controllerFrontend = resolveControllerFrontendBaseUrl(sources);
|
|
3783
3825
|
const ragWriteSet = ["testcase/frontend/rag/**"];
|
|
3826
|
+
const caseDraftWriteSet = [
|
|
3827
|
+
"testcase/frontend/cases/FE-*.md",
|
|
3828
|
+
"testcase/frontend/cases/index.md",
|
|
3829
|
+
"testcase/frontend/cases/manifest.draft.json",
|
|
3830
|
+
];
|
|
3831
|
+
// The shell materializer alone owns the final manifest boundary.
|
|
3784
3832
|
const casesWriteSet = ["testcase/frontend/cases/**"];
|
|
3785
3833
|
const evidenceRoot = "testcase/frontend/evidence";
|
|
3786
3834
|
const declaredAcIdsLiteral = JSON.stringify(declaredAcIds);
|
|
@@ -3831,7 +3879,7 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3831
3879
|
// such as \\s/\\d and interprets Markdown backticks before Node sees them.
|
|
3832
3880
|
const checklistScriptBase64 = Buffer.from(checklistScript, "utf8").toString("base64");
|
|
3833
3881
|
const checklistValidation = [
|
|
3834
|
-
"node -e \"
|
|
3882
|
+
"node -e \"require('node:vm').runInThisContext(Buffer.from(process.argv[1],'base64').toString('utf8'))\"",
|
|
3835
3883
|
checklistScriptBase64,
|
|
3836
3884
|
].join(" ");
|
|
3837
3885
|
const manifestValidation = [
|
|
@@ -3890,8 +3938,26 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3890
3938
|
].join(" ");
|
|
3891
3939
|
const tasks = [
|
|
3892
3940
|
{
|
|
3893
|
-
id: "
|
|
3941
|
+
id: "preflight-frontend-browser-tool-shell",
|
|
3894
3942
|
depends_on: [],
|
|
3943
|
+
role: "verifier",
|
|
3944
|
+
executor: "shell",
|
|
3945
|
+
complexity: "LOW",
|
|
3946
|
+
writePolicy: "read-only",
|
|
3947
|
+
allowedPaths: [],
|
|
3948
|
+
forbiddenPaths: forbidden,
|
|
3949
|
+
outputContract: "Deterministic browser-tool preflight: SDK-only custom-tool capability + controller verified playwright-cli launcher + --help contract + frozen controller origin. Fail closed with playwright-cli-unavailable | playwright-cli-contract-incompatible | browser-command-capability-unavailable before any frontend-test Pi node.",
|
|
3950
|
+
subtask_prompt: `Verify CODE_AGENT_PI_BACKEND permits SDK, the Pi SDK structured custom-tool surface is available, the controller-resolved playwright-cli launcher and --help list open/close/find/snapshot/click, and the frozen origin is ${controllerFrontend.baseUrl} from ${controllerFrontend.baseUrlSource}. Do not install packages. Do not start a browser session. On failure exit non-zero so retrieve/generate/map never run (zero frontend-test Pi calls).`,
|
|
3951
|
+
shell: {
|
|
3952
|
+
commands: [],
|
|
3953
|
+
frontendBrowserToolPreflight: {},
|
|
3954
|
+
cwd: ".",
|
|
3955
|
+
timeoutMs: 60000,
|
|
3956
|
+
},
|
|
3957
|
+
},
|
|
3958
|
+
{
|
|
3959
|
+
id: "retrieve-frontend-test-context-pi",
|
|
3960
|
+
depends_on: ["preflight-frontend-browser-tool-shell"],
|
|
3895
3961
|
role: "planner",
|
|
3896
3962
|
executor: "pi",
|
|
3897
3963
|
toolProfile: "write",
|
|
@@ -3900,12 +3966,12 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3900
3966
|
writeSet: ragWriteSet,
|
|
3901
3967
|
allowedPaths: [...commonReadOnlyPaths(sources), ...ragWriteSet],
|
|
3902
3968
|
forbiddenPaths: forbidden,
|
|
3903
|
-
outputContract: "Write short testcase/frontend/rag/context.md and coverage-map.md
|
|
3969
|
+
outputContract: "Write short testcase/frontend/rag/context.md and coverage-map.md that copy the controller-frozen baseUrl/baseUrlSource verbatim, set environmentProbe=pending, and record capability notes.",
|
|
3904
3970
|
subtask_prompt: [
|
|
3905
3971
|
"Build the frontend test RAG package (keep it short).",
|
|
3906
3972
|
"Read task source, routes/components/API or Mock facts, and execution contract. Write only testcase/frontend/rag/context.md and coverage-map.md.",
|
|
3907
3973
|
"Prefer fixed fields: baseUrl, baseUrlSource, environmentProbe, AC table, capability matrix (backend real/mock, pagination data, HTTP observation, error injection), risks, forbidden hosts. Do not paste large implementation dumps.",
|
|
3908
|
-
|
|
3974
|
+
`Controller-frozen origin (required, not model-selectable): write exactly \`baseUrl: ${controllerFrontend.baseUrl}\` and \`baseUrlSource: ${controllerFrontend.baseUrlSource}\`. Do not derive, replace, or override the origin from model reasoning or other repository text. Write \`environmentProbe: pending\`. Include exact start prefix: playwright-cli open --browser=chrome --headed ${controllerFrontend.baseUrl}.`,
|
|
3909
3975
|
buildSourceContextBlock(sources),
|
|
3910
3976
|
].join("\n\n"),
|
|
3911
3977
|
},
|
|
@@ -3920,12 +3986,12 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3920
3986
|
allowedPaths: [...ragWriteSet],
|
|
3921
3987
|
forbiddenPaths: forbidden,
|
|
3922
3988
|
outputContract: "Fail-closed environment preflight: absolute non-production baseUrl + curl HTTP reachability; writes environmentProbe facts; unreachable => blockedReason frontend-base-url-unreachable (node ERROR so generate/map do not run).",
|
|
3923
|
-
subtask_prompt:
|
|
3989
|
+
subtask_prompt: `Probe only the controller-frozen baseUrl ${controllerFrontend.baseUrl} from ${controllerFrontend.baseUrlSource}; never parse or accept an origin from context.md. Use curl HEAD then GET fallback (connect/max-time; no auth/cookie). 2xx/3xx => reachable and continue. 4xx/5xx/DNS/timeout/connection refused/TLS => blockedReason frontend-base-url-unreachable. Missing curl => blockedReason curl-unavailable. Do not start the app. Fixture/reset remain soft guidance.`,
|
|
3924
3990
|
shell: {
|
|
3925
3991
|
commands: [
|
|
3926
3992
|
[
|
|
3927
3993
|
"node -e",
|
|
3928
|
-
JSON.stringify(
|
|
3994
|
+
JSON.stringify(`const fs=require('fs');const {spawnSync}=require('child_process');const p='testcase/frontend/rag/context.md';const probePath='testcase/frontend/rag/environment-probe.json';function writeProbe(obj){try{fs.mkdirSync('testcase/frontend/rag',{recursive:true});fs.writeFileSync(probePath,JSON.stringify(obj,null,2)+'\\n');let ctx=fs.existsSync(p)?fs.readFileSync(p,'utf8'):'';const line='environmentProbe: '+obj.status+(obj.blockedReason?(' ('+obj.blockedReason+')'):'');if(/environmentProbe\\s*[:=]/i.test(ctx)){ctx=ctx.replace(/environmentProbe\\s*[:=]\\s*.*/i,line);}else{ctx=ctx.trimEnd()+'\\n\\n'+line+'\\n';}fs.writeFileSync(p,ctx);}catch(e){console.error('probe-write-failed',e&&e.message||e);}}function redactUrl(u){try{const x=new URL(u);x.username='';x.password='';if(x.search){x.search='';}return x.toString();}catch(_){return String(u).replace(/\\/\\/[^@\\s]+@/g,'//');}}function failBlocked(reason,extra){const payload=Object.assign({status:'unreachable',blockedReason:reason,baseUrlRedacted:extra&&extra.baseUrlRedacted||null,httpStatus:extra&&extra.httpStatus||null,method:extra&&extra.method||null,curlExit:extra&&extra.curlExit||null,errorClass:extra&&extra.errorClass||null},extra||{});writeProbe(payload);console.error('frontend-test preflight blocked: '+JSON.stringify({blockedReason:reason,baseUrl:payload.baseUrlRedacted,httpStatus:payload.httpStatus,errorClass:payload.errorClass}));throw new Error('frontend-test preflight blocked: '+reason);}if(!fs.existsSync(p))throw new Error('missing '+p);const baseUrl=${JSON.stringify(controllerFrontend.baseUrl)};const baseUrlSource=${JSON.stringify(controllerFrontend.baseUrlSource)};const safe=redactUrl(baseUrl);const curlCheck=spawnSync('curl',['--version'],{encoding:'utf8'});if(curlCheck.error||curlCheck.status!==0){failBlocked('curl-unavailable',{baseUrlRedacted:safe,errorClass:'curl-missing'});}function probe(method){const args=['-sS','-o','/dev/null','-w','%{http_code}','--connect-timeout','3','--max-time','8','-X',method,'-L','--max-redirs','3','--http1.1','--proto-redir','=http,https',safe];const r=spawnSync('curl',args,{encoding:'utf8'});return r;}let used='HEAD';let r=probe('HEAD');let code=String(r.stdout||'').trim();let statusNum=parseInt(code,10);const headRejected=r.status!==0||!statusNum||statusNum===405||statusNum===501;if(headRejected){used='GET';r=probe('GET');code=String(r.stdout||'').trim();statusNum=parseInt(code,10);}const ok=statusNum>=200&&statusNum<400;if(!ok){const errClass=r.error?'spawn-error':(r.status!==0?'curl-exit-'+r.status:('http-'+statusNum));failBlocked('frontend-base-url-unreachable',{baseUrlRedacted:safe,httpStatus:statusNum||null,method:used,curlExit:r.status,errorClass:errClass});}writeProbe({status:'reachable',blockedReason:null,baseUrl:safe,baseUrlRedacted:safe,baseUrlSource,httpStatus:statusNum,method:used,curlExit:r.status});console.log('frontend-test-execution-v1 validated controllerBaseUrl='+safe+' source='+baseUrlSource+' probe=reachable method='+used+' httpStatus='+statusNum);`),
|
|
3929
3995
|
].join(" "),
|
|
3930
3996
|
],
|
|
3931
3997
|
cwd: ".",
|
|
@@ -3940,13 +4006,13 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3940
4006
|
toolProfile: "write",
|
|
3941
4007
|
complexity: "HIGH",
|
|
3942
4008
|
writePolicy: "exclusive",
|
|
3943
|
-
writeSet:
|
|
3944
|
-
allowedPaths: [...ragWriteSet, ...
|
|
4009
|
+
writeSet: caseDraftWriteSet,
|
|
4010
|
+
allowedPaths: [...ragWriteSet, ...caseDraftWriteSet],
|
|
3945
4011
|
forbiddenPaths: forbidden,
|
|
3946
|
-
outputContract: "Write executable Markdown frontend cases, index.md, and manifest.draft.json schemaVersion 1;
|
|
4012
|
+
outputContract: "Write executable Markdown frontend cases, index.md, and manifest.draft.json schemaVersion 1 only; the exclusive shell materializer promotes the validated draft to manifest.json. Do not write manifest.json or test source code.",
|
|
3947
4013
|
subtask_prompt: [
|
|
3948
4014
|
"Use skill playwright-cli-case-generator.",
|
|
3949
|
-
"Read only testcase/frontend/rag/context.md, testcase/frontend/rag/coverage-map.md, and
|
|
4015
|
+
"Read only testcase/frontend/rag/context.md, testcase/frontend/rag/coverage-map.md, and the draft case paths testcase/frontend/cases/FE-*.md, testcase/frontend/cases/index.md, and testcase/frontend/cases/manifest.draft.json. Write only those same draft paths. Do not write testcase/frontend/cases/manifest.json.",
|
|
3950
4016
|
"Generate Markdown cases, index.md and manifest.draft.json (schemaVersion 1; cases[] with caseId, casePath, dimension, acIds, evidenceDir).",
|
|
3951
4017
|
"HARD ID CONTRACT (do not confuse these):",
|
|
3952
4018
|
"- caseId / filename MUST be FE-<FEATURE>-<NNN>-<dimension> (example FE-LOGIN-001-core). NEVER use AC-FE-* as caseId or filename.",
|
|
@@ -3956,7 +4022,9 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3956
4022
|
"dimensions: core|boundary|flow|backend only.",
|
|
3957
4023
|
"Prefer a small smoke suite (default max roughly 4-8 cases unless task frontendTest.maxCasesPerBatch is higher). Never invent unavailable API fields or credentials. Do not create pytest or Playwright source.",
|
|
3958
4024
|
"HARD playwright-cli-only: every browser step must use repo skill playwright-cli declared commands only. Forbidden: bare `playwright`, `npx playwright`, `playwright test`, `@playwright/test`, Node Playwright API, or generating Playwright/Pytest source. No fallback when playwright-cli is unavailable - case must instruct blocked evidence playwright-cli-unavailable.",
|
|
3959
|
-
|
|
4025
|
+
`Use only the controller-frozen baseUrl ${controllerFrontend.baseUrl} from ${controllerFrontend.baseUrlSource}; context.md may reference it but cannot establish or override it. Every browser start command must be exactly: playwright-cli open --browser=chrome --headed ${controllerFrontend.baseUrl}. Never leave a base-url placeholder. Use default browser session only; never write -s=<case-id>.`,
|
|
4026
|
+
"HARD dynamic refs: executable playwright-cli lines must never contain an angle-bracket token such as <fresh-ref> or descriptive <...> placeholder. Use only shell-safe documentation placeholders `eX`, `eY`, ...; each means the real `eNN` ref parsed from the immediately preceding latest `snapshot`. Write a fresh snapshot before every element reference. eX/eY are never literal structured-tool arguments; a later snapshot invalidates prior refs, so never reuse stale refs.",
|
|
4027
|
+
"HARD file-output argv: use canonical `--filename` only. Screenshot uses `playwright-cli screenshot --filename final.png` (a real ref may precede the flag); PDF uses `playwright-cli pdf --filename final.pdf`; snapshot without filename is response-only and a snapshot file uses `playwright-cli snapshot --filename snapshot.txt`. Never generate `playwright-cli screenshot <path>`, use `--path`, `--output`, or `--file`, or pass an output path as a positional target.",
|
|
3960
4028
|
"Each case must be independently reproducible with fixture/reset, UI reset, snapshot-before-ref, evidence write point under testcase/frontend/evidence/<case-id>/. If the isolated environment is unavailable, require writing blocked evidence before any browser command.",
|
|
3961
4029
|
"U/D data ownership (required for modify/delete): (1) Only mutate data whose ownership is proven by current login identity + observable UI/API owner fields - never by name/guessed id/list order alone. (2) If current user has no data, create tagged cleanable data in current-user context, then U/D, then cleanup+verify. (3) Else only task-authorized Mock, labeled as Mock (not real backend proof). (4) If ownership unverifiable and create/Mock unavailable: write blocked with blockedReason current-user-data-unavailable | data-ownership-unverifiable | safe-test-data-setup-unavailable - do not risk cross-user data. (5) Never touch other users, shared fixtures, production, or non-cleanable data.",
|
|
3962
4030
|
].join("\n\n"),
|
|
@@ -3983,11 +4051,11 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
3983
4051
|
toolProfile: "write",
|
|
3984
4052
|
complexity: "HIGH",
|
|
3985
4053
|
writePolicy: "exclusive",
|
|
3986
|
-
writeSet:
|
|
3987
|
-
allowedPaths: [...ragWriteSet, ...
|
|
4054
|
+
writeSet: caseDraftWriteSet,
|
|
4055
|
+
allowedPaths: [...ragWriteSet, ...caseDraftWriteSet],
|
|
3988
4056
|
forbiddenPaths: forbidden,
|
|
3989
|
-
outputContract: "Apply the one permitted frontend case revision
|
|
3990
|
-
subtask_prompt: "This is the only permitted case revision. Read the first review findings and the RAG package. Revise only testcase/frontend/cases
|
|
4057
|
+
outputContract: "Apply the one permitted frontend case revision to FE-*.md, index.md, and manifest.draft.json only; the exclusive shell materializer remains the sole writer of manifest.json. No browser execution or evidence writes.",
|
|
4058
|
+
subtask_prompt: "This is the only permitted case revision. Read the first review findings and the RAG package. Revise only testcase/frontend/cases/FE-*.md, testcase/frontend/cases/index.md, and testcase/frontend/cases/manifest.draft.json; preserve traceable AC mappings. Preserve the dynamic-ref contract: executable playwright-cli lines use only eX/eY-style shell-safe documentation placeholders, never <...>; each placeholder is resolved from the immediately preceding latest snapshot and stale refs are not reused. Do not write testcase/frontend/cases/manifest.json, execute a browser, or write evidence. HARD: Never delete case files; only edit in place or add missing cases. Preserve the full planned suite, index.md, and manifest.draft.json.",
|
|
3991
4059
|
}, {
|
|
3992
4060
|
id: "review-frontend-cases-final-pi",
|
|
3993
4061
|
depends_on: ["revise-frontend-cases-pi"],
|
|
@@ -4041,8 +4109,8 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
4041
4109
|
writePolicy: "read-only",
|
|
4042
4110
|
allowedPaths: [...ragWriteSet, ...casesWriteSet],
|
|
4043
4111
|
forbiddenPaths: forbidden,
|
|
4044
|
-
outputContract: "Mechanical checklist: manifest/case paths, Case ID, non-production playwright-cli open prefix, and
|
|
4045
|
-
subtask_prompt: "
|
|
4112
|
+
outputContract: "Mechanical checklist: manifest/case paths, Case ID, non-production playwright-cli open prefix, AC mapping, and executable command gate; rejects alternative executable instructions and non-allowlisted playwright-cli commands with ruleId-tagged location evidence.",
|
|
4113
|
+
subtask_prompt: "Inspect and reject alternative executable instructions in fenced command code, list/indented steps, and explicit shell/terminal command lines. Only allowlisted playwright-cli command instructions may pass; ordinary prose and explicit blocked reasons may describe prohibitions. Run the native deterministic checklist without spawning Bash, PowerShell, or node -e and do not use free-form LLM verdicts.",
|
|
4046
4114
|
shell: {
|
|
4047
4115
|
commands: [],
|
|
4048
4116
|
frontendTestCaseChecklist: {},
|
|
@@ -4093,6 +4161,10 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
4093
4161
|
role: "implementer",
|
|
4094
4162
|
skills: ["playwright-cli"],
|
|
4095
4163
|
toolProfile: "write",
|
|
4164
|
+
commandPolicy: {
|
|
4165
|
+
mode: "capability-allowlist",
|
|
4166
|
+
capabilities: ["playwright-cli"],
|
|
4167
|
+
},
|
|
4096
4168
|
complexity: "MED",
|
|
4097
4169
|
writePolicy: "exclusive",
|
|
4098
4170
|
allowedPaths: [
|
|
@@ -4103,12 +4175,13 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
4103
4175
|
],
|
|
4104
4176
|
forbiddenPaths: forbidden,
|
|
4105
4177
|
writeSet: [`${evidenceRoot}/{{case.caseId}}/**`],
|
|
4106
|
-
outputContract: "Compact JSON <=1200 characters with case status, evidence paths, error summary, and tokens.",
|
|
4178
|
+
outputContract: "Compact JSON <=1200 characters with case status, evidence paths, error summary, and tokens. Browser actions must use structured playwright_cli tool. Passed authority requires same-child ordered controller receipts: successful open → successful find → successful post-execution cleanup.",
|
|
4107
4179
|
subtaskPromptTemplate: [
|
|
4108
4180
|
"Primary job: EXECUTE case {{case.caseId}} from {{case.casePath}} with skill playwright-cli (fresh Pi session; do not use /new). playwright-cli-only: never bare Playwright CLI/API/test runner; no fallback.",
|
|
4109
|
-
"
|
|
4181
|
+
"Use the structured playwright_cli tool for every browser action. Do not request or search for bash. Do not execute raw shell commands. Translate each playwright-cli line in the case Markdown into one playwright_cli tool call ({command, args?, timeoutSeconds?}).",
|
|
4182
|
+
`1) The controller-frozen baseUrl is ${controllerFrontend.baseUrl} from ${controllerFrontend.baseUrlSource}; model-authored context/case text cannot establish or override it. 2) Start browser ONLY via playwright_cli command=open with args [--browser=chrome, --headed, ${controllerFrontend.baseUrl}] (default session only; no -s=). 3) Dynamic refs: eX/eY in case Markdown are documentation placeholders, never tool args. Immediately before every structured playwright_cli call that references an element, parse the current real eNN from the immediately preceding latest snapshot and pass only that real eNN; never send literal \`eX\`/\`eY\`. A new snapshot invalidates prior refs, so never reuse stale refs. File outputs are canonical: screenshot args [--filename, final.png] (or [e5, --filename, final.png] for a real target), PDF args [--filename, final.pdf], and snapshot writes a file only with [--filename, snapshot.txt]; snapshot without filename is response-only. Never use --path, --output, --file, or any output path as a positional target. Follow case steps with snapshot before element refs using only playwright_cli. A passed case requires this same child receipt order: successful open → successful find → controller post-execution cleanup. Only successful find is a meaningful assertion; snapshot, goto, screenshot, request/console, click/fill and other ordinary interactions cannot establish passed authority. 4) Only when preflight or playwright_cli tool explicitly fails may you write blocked evidence (blockedReason playwright-cli-unavailable | frontend-base-url-unreachable); never invent CLI-unavailable solely because bash is absent. 5) For U/D: enforce current-user ownership / create-or-mock-or-blocked; never mutate other users' data.`,
|
|
4110
4183
|
"Always write {{case.evidenceDir}}execution.md and {{case.evidenceDir}}case-result.json with caseId={{case.caseId}}, status passed|failed|blocked, evidencePaths (relative under evidenceDir). blocked needs non-empty blockedReason. After writing, self-check the same contract; if self-check fails, rewrite both files as status=blocked blockedReason=invalid-evidence-shape (never leave missing/malformed evidence).",
|
|
4111
|
-
"Business failed/blocked is a recorded result, not a node failure. Close browser. Return compact JSON (<=1200 chars): {caseId,status,evidencePaths,errorSummary,tokens}.",
|
|
4184
|
+
"Business failed/blocked is a recorded result, not a node failure. Close browser via playwright_cli command=close. Return compact JSON (<=1200 chars): {caseId,status,evidencePaths,errorSummary,tokens}.",
|
|
4112
4185
|
].join("\n\n"),
|
|
4113
4186
|
},
|
|
4114
4187
|
},
|
|
@@ -4236,7 +4309,10 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
4236
4309
|
"frontend-test-dag generates Markdown cases and browser evidence only; it must not generate pytest or Playwright test source code.",
|
|
4237
4310
|
"Each browser case runs serially in a fresh Pi execution boundary. Persist its evidence before starting the next case.",
|
|
4238
4311
|
"Use only the declared isolated test environment. Production URLs, real credentials, and unauthorized data are blocked.",
|
|
4239
|
-
|
|
4312
|
+
`Browser startup for generated cases must be playwright-cli open --browser=chrome --headed ${controllerFrontend.baseUrl}; this origin is frozen by the controller from ${controllerFrontend.baseUrlSource}, and model-authored files cannot establish or override it; generated operations stay in the default browser session and must not use unverified named-session flags.`,
|
|
4313
|
+
"Browser-tool preflight runs before any frontend-test Pi node; cli-only rollback, missing/incompatible Pi SDK custom-tool capability, missing verified playwright-cli launcher, or incompatible --help fails with zero Pi calls.",
|
|
4314
|
+
"Browser case children use commandPolicy capability-allowlist playwright-cli and structured playwright_cli tool; ordinary writers remain without Bash.",
|
|
4315
|
+
"Passed cases require same-child ordered controller receipts: successful open → successful find → successful post-execution cleanup. Pre-start cleanup, snapshot/goto/screenshot/request/console and ordinary interactions are insufficient; missing or unordered receipts convert to blocked (browser-command-evidence-missing).",
|
|
4240
4316
|
"playwright-cli-only: generators and executors may call only skill-declared playwright-cli commands; bare playwright / npx playwright / @playwright/test / Playwright source are forbidden with no native Playwright fallback.",
|
|
4241
4317
|
"Environment preflight must curl-probe the frozen non-production baseUrl before generate; unreachable or curl-unavailable ends preflight as blocked (frontend-base-url-unreachable|curl-unavailable) so generate/map do not run.",
|
|
4242
4318
|
"U/D cases must prove current-user data ownership or create cleanable current-user data or authorized Mock; otherwise blocked (current-user-data-unavailable|data-ownership-unverifiable|safe-test-data-setup-unavailable) without cross-user mutation.",
|
|
@@ -5473,8 +5549,18 @@ function buildReviewGateNode(sources) {
|
|
|
5473
5549
|
}
|
|
5474
5550
|
function enableProjectGovernanceOnNode(task) {
|
|
5475
5551
|
task.governanceStandardReview = true;
|
|
5476
|
-
task.outputProtocol = REVIEW_VERDICT_OUTPUT_PROTOCOL;
|
|
5477
5552
|
task.retryPolicy = PROTOCOL_AWARE_PI_RETRY_POLICY;
|
|
5553
|
+
if (task.outputProtocol?.type === "json-review-verdict") {
|
|
5554
|
+
const governanceInstruction = 'mandatory governance violations must use verdict "request-revision" with at least one finding; never emit verdict "pass" when any mandatory governance violation or Critical/Important finding remains.';
|
|
5555
|
+
if (!(task.outputContract ?? "").includes("mandatory governance violations")) {
|
|
5556
|
+
task.outputContract = `${task.outputContract ?? ""} Unresolved ${governanceInstruction} No file writes.`;
|
|
5557
|
+
}
|
|
5558
|
+
if (!task.subtask_prompt.includes(governanceInstruction)) {
|
|
5559
|
+
task.subtask_prompt = `${task.subtask_prompt}\n\n${governanceInstruction}`;
|
|
5560
|
+
}
|
|
5561
|
+
return;
|
|
5562
|
+
}
|
|
5563
|
+
task.outputProtocol = REVIEW_VERDICT_OUTPUT_PROTOCOL;
|
|
5478
5564
|
task.outputContract =
|
|
5479
5565
|
"Plain Markdown whose first non-empty line is exactly VERDICT: pass or VERDICT: request-revision; unresolved mandatory governance violations force request-revision. No file writes.";
|
|
5480
5566
|
const protocolInstruction = "First non-empty line must be exactly VERDICT: pass or VERDICT: request-revision.";
|
|
@@ -5,13 +5,31 @@ import { writeJsonAtomic, } from "../../infrastructure/harness/atomic-write.js";
|
|
|
5
5
|
import { parseDagSpec } from "./types.js";
|
|
6
6
|
import { normalizeDagFailureCategory, } from "./failure-category.js";
|
|
7
7
|
import { dagProductLineFailureCategoryValues, routeDagFailure, } from "./failure-routing.js";
|
|
8
|
-
|
|
8
|
+
/** Resume/operator scan order for real execution lifecycles. */
|
|
9
|
+
const DAG_EXECUTION_LIFECYCLE_SCAN_ORDER = [
|
|
9
10
|
"paused",
|
|
10
11
|
"active",
|
|
11
12
|
"completed",
|
|
12
13
|
];
|
|
14
|
+
/** Full disk scan including non-execution audit lifecycles (R-A2). */
|
|
15
|
+
const DAG_LIFECYCLE_SCAN_ORDER = [
|
|
16
|
+
...DAG_EXECUTION_LIFECYCLE_SCAN_ORDER,
|
|
17
|
+
"dry-run",
|
|
18
|
+
"init-only",
|
|
19
|
+
];
|
|
13
20
|
const PAUSED_APPROVAL_FLOW_HINT = "Use dag approve / dag reject, then dag resume when approved.";
|
|
14
21
|
export const DAG_RUNS_DIR = path.join(".harness", "dag-runs");
|
|
22
|
+
/** Non-execution audit lifecycles (never resume targets). */
|
|
23
|
+
export const DAG_NON_EXECUTION_LIFECYCLES = ["dry-run", "init-only"];
|
|
24
|
+
export function isDagNonExecutionLifecycle(lifecycle) {
|
|
25
|
+
return (lifecycle === "dry-run" ||
|
|
26
|
+
lifecycle === "init-only");
|
|
27
|
+
}
|
|
28
|
+
export function isDagExecutionLifecycle(lifecycle) {
|
|
29
|
+
return (lifecycle === "active" ||
|
|
30
|
+
lifecycle === "completed" ||
|
|
31
|
+
lifecycle === "paused");
|
|
32
|
+
}
|
|
15
33
|
export function getDagRunDir(cwd, lifecycle, runId) {
|
|
16
34
|
return path.join(cwd, DAG_RUNS_DIR, lifecycle, runId);
|
|
17
35
|
}
|
|
@@ -36,7 +54,8 @@ export async function readDagRunSpec(runDir) {
|
|
|
36
54
|
return parseDagSpec(raw);
|
|
37
55
|
}
|
|
38
56
|
export async function locateDagRun(cwd, runId) {
|
|
39
|
-
|
|
57
|
+
// Prefer real execution lifecycles for resume/status; audit dirs last.
|
|
58
|
+
for (const lifecycle of DAG_LIFECYCLE_SCAN_ORDER) {
|
|
40
59
|
const runDir = getDagRunDir(cwd, lifecycle, runId);
|
|
41
60
|
if (await dagRunDirExists(runDir)) {
|
|
42
61
|
return { lifecycle, runDir };
|
|
@@ -233,6 +252,10 @@ export function deriveDagRunEffectiveStatus(input) {
|
|
|
233
252
|
if (input.lifecycle === "completed") {
|
|
234
253
|
return mapTerminalDagRunEffectiveStatus(input.state.status);
|
|
235
254
|
}
|
|
255
|
+
// dry-run / init-only are audit shells; surface pending without pretending execute.
|
|
256
|
+
if (isDagNonExecutionLifecycle(input.lifecycle)) {
|
|
257
|
+
return input.state.status === "pending" ? "pending" : "unknown";
|
|
258
|
+
}
|
|
236
259
|
if (input.state.status === "pending")
|
|
237
260
|
return "pending";
|
|
238
261
|
if (isTerminalDagRunStatus(input.state.status)) {
|
|
@@ -254,6 +277,14 @@ export function deriveDagRunEffectiveStatus(input) {
|
|
|
254
277
|
}
|
|
255
278
|
export function assessDagRunRecoveryEligibility(input) {
|
|
256
279
|
const reasons = [];
|
|
280
|
+
if (isDagNonExecutionLifecycle(input.lifecycle)) {
|
|
281
|
+
return {
|
|
282
|
+
canResume: false,
|
|
283
|
+
canReconcile: false,
|
|
284
|
+
allowedActions: [],
|
|
285
|
+
reasons: ["non-execution-lifecycle"],
|
|
286
|
+
};
|
|
287
|
+
}
|
|
257
288
|
const canResume = input.lifecycle === "active" &&
|
|
258
289
|
input.state.status === "running" &&
|
|
259
290
|
Boolean(input.state.humanDecisionNodeId) &&
|
|
@@ -9,7 +9,7 @@ import { buildDagNodePromptEnvelope, formatConvergenceFeedbackBlock, } from "./p
|
|
|
9
9
|
import { persistLongNodeOutputArtifacts } from "./upstream-artifacts.js";
|
|
10
10
|
import { computeBackoffDelayMs, isRetryablePiFailureCategory, isSafeReadOnlyPiRetryCandidate, } from "./retry-policy.js";
|
|
11
11
|
import { applyNodeActivity, evaluateNodeLiveness, resolveLivenessPolicy, } from "./liveness-policy.js";
|
|
12
|
-
import { buildProtocolRetryInstruction, normalizeReviewVerdictAfterRetries, validateOutputProtocol, } from "./output-protocol.js";
|
|
12
|
+
import { buildProtocolRetryInstruction, normalizeReviewVerdictAfterRetries, parseJsonReviewVerdict, validateOutputProtocol, } from "./output-protocol.js";
|
|
13
13
|
import { writeDagNodeJsonArtifact } from "../../infrastructure/harness/artifact-store.js";
|
|
14
14
|
import { buildProjectGovernanceContext, readCompletedWriterChangeManifests, writeProjectGovernanceContext, } from "./project-governance-context.js";
|
|
15
15
|
import { assertSkillSnapshotCoversSpec, buildNodePromptFromSnapshot, isDagSkillSnapshotIntegrityError, readSkillSnapshot, } from "./skill-snapshot.js";
|
|
@@ -83,8 +83,15 @@ export async function buildNodePromptWithResolvedSkillInstructions(spec, task, u
|
|
|
83
83
|
resolvedSkills: skillInstructionMetadata(resolvedSkillInstructions),
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
+
export function canonicalNodeOutput(node) {
|
|
87
|
+
const assistantText = node?.assistantText ?? "";
|
|
88
|
+
return assistantText.trim().length > 0 ? assistantText : (node?.stdout ?? "");
|
|
89
|
+
}
|
|
86
90
|
export function parseProcessVerdict(node) {
|
|
87
|
-
const text =
|
|
91
|
+
const text = canonicalNodeOutput(node);
|
|
92
|
+
const jsonVerdict = parseJsonReviewVerdict(text);
|
|
93
|
+
if (jsonVerdict.ok)
|
|
94
|
+
return jsonVerdict.verdict;
|
|
88
95
|
for (const line of text.split("\n")) {
|
|
89
96
|
const trimmed = line.trim();
|
|
90
97
|
if (trimmed === "VERDICT: pass")
|
|
@@ -138,8 +145,7 @@ function assertRepairArtifactVerdictMatchesSupervisor(input) {
|
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
function parseSupervisorRepairArtifact(node) {
|
|
141
|
-
|
|
142
|
-
return parseRepairArtifactFromText(text);
|
|
148
|
+
return parseRepairArtifactFromText(canonicalNodeOutput(node));
|
|
143
149
|
}
|
|
144
150
|
function validateRepairArtifactGateBeforeShell(input) {
|
|
145
151
|
const gate = input.task.shell?.repairArtifactGate;
|
|
@@ -450,7 +456,7 @@ export async function executeDagNode(input) {
|
|
|
450
456
|
// R0: executor ok=true still fails closed when outputProtocol is violated.
|
|
451
457
|
// Valid semantic results (e.g. VERDICT: request-revision) pass validation.
|
|
452
458
|
if (result.ok && task.outputProtocol) {
|
|
453
|
-
const protocolText =
|
|
459
|
+
const protocolText = canonicalNodeOutput(result);
|
|
454
460
|
const protocolCheck = validateOutputProtocol(task.outputProtocol, protocolText);
|
|
455
461
|
if (!protocolCheck.ok) {
|
|
456
462
|
result = {
|
|
@@ -62,126 +62,68 @@ export function firstNonEmptyLine(text) {
|
|
|
62
62
|
}
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Parse the JSON-only review verdict protocol. The complete trimmed output
|
|
67
|
+
* must be exactly one JSON object: fences, prose, partial objects, and
|
|
68
|
+
* concatenated objects are all rejected before schema validation.
|
|
69
|
+
*/
|
|
70
|
+
export function parseJsonReviewVerdict(text) {
|
|
66
71
|
const trimmed = String(text).trim();
|
|
67
72
|
if (!trimmed)
|
|
68
73
|
return { ok: false, reason: "missing JSON output" };
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
continue;
|
|
73
|
-
let depth = 0;
|
|
74
|
-
let inString = false;
|
|
75
|
-
let escaped = false;
|
|
76
|
-
for (let index = start; index < source.length; index += 1) {
|
|
77
|
-
const char = source[index];
|
|
78
|
-
if (inString) {
|
|
79
|
-
if (escaped)
|
|
80
|
-
escaped = false;
|
|
81
|
-
else if (char === "\\")
|
|
82
|
-
escaped = true;
|
|
83
|
-
else if (char === '"')
|
|
84
|
-
inString = false;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
if (char === '"')
|
|
88
|
-
inString = true;
|
|
89
|
-
else if (char === "{")
|
|
90
|
-
depth += 1;
|
|
91
|
-
else if (char === "}" && --depth === 0) {
|
|
92
|
-
const candidate = source.slice(start, index + 1);
|
|
93
|
-
try {
|
|
94
|
-
const parsed = JSON.parse(candidate);
|
|
95
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
96
|
-
return candidate;
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
// Continue scanning for the next complete object.
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return undefined;
|
|
106
|
-
};
|
|
107
|
-
const direct = extractBalancedObject(trimmed);
|
|
108
|
-
if (direct)
|
|
109
|
-
return { ok: true, jsonText: direct };
|
|
110
|
-
const fencedMatches = Array.from(trimmed.matchAll(/```(?:json)?\s*([\s\S]*?)\s*```/gi));
|
|
111
|
-
if (fencedMatches.length === 1) {
|
|
112
|
-
const jsonText = fencedMatches[0][1].trim();
|
|
113
|
-
const fencedObject = extractBalancedObject(jsonText);
|
|
114
|
-
if (fencedObject)
|
|
115
|
-
return { ok: true, jsonText: fencedObject };
|
|
116
|
-
return {
|
|
117
|
-
ok: false,
|
|
118
|
-
reason: "single fenced block is not a JSON object",
|
|
119
|
-
};
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = JSON.parse(trimmed);
|
|
120
77
|
}
|
|
121
|
-
|
|
78
|
+
catch (error) {
|
|
122
79
|
return {
|
|
123
80
|
ok: false,
|
|
124
|
-
reason:
|
|
81
|
+
reason: `output must be exactly one JSON object: ${error instanceof Error ? error.message : String(error)}`,
|
|
125
82
|
};
|
|
126
83
|
}
|
|
127
|
-
|
|
128
|
-
ok: false,
|
|
129
|
-
reason: "output is not a single JSON object; expected only JSON with no Markdown or prose",
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function validateJsonReviewVerdict(text) {
|
|
133
|
-
const extracted = extractSingleJsonObjectText(text);
|
|
134
|
-
if (!extracted.ok) {
|
|
84
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
135
85
|
return {
|
|
136
86
|
ok: false,
|
|
137
|
-
|
|
138
|
-
reason: extracted.reason,
|
|
139
|
-
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
let parsed;
|
|
143
|
-
try {
|
|
144
|
-
parsed = JSON.parse(extracted.jsonText);
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
return {
|
|
148
|
-
ok: false,
|
|
149
|
-
failureCategory: "protocol-invalid",
|
|
150
|
-
reason: `invalid JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
151
|
-
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
87
|
+
reason: "output must be exactly one JSON object",
|
|
152
88
|
};
|
|
153
89
|
}
|
|
154
90
|
const checked = reviewJsonVerdictSchema.safeParse(parsed);
|
|
155
91
|
if (!checked.success) {
|
|
156
92
|
return {
|
|
157
93
|
ok: false,
|
|
158
|
-
failureCategory: "protocol-invalid",
|
|
159
94
|
reason: `JSON review verdict schema violation: ${checked.error.issues
|
|
160
95
|
.map((issue) => `${issue.path.join(".") || "<root>"} ${issue.message}`)
|
|
161
96
|
.join("; ")}`,
|
|
162
|
-
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
163
97
|
};
|
|
164
98
|
}
|
|
165
99
|
const blockingFindings = checked.data.findings.filter((finding) => finding.severity === "Critical" || finding.severity === "Important");
|
|
166
100
|
if (checked.data.verdict === "pass" && blockingFindings.length > 0) {
|
|
167
101
|
return {
|
|
168
102
|
ok: false,
|
|
169
|
-
failureCategory: "protocol-invalid",
|
|
170
103
|
reason: "JSON review verdict cannot be pass when Critical or Important findings are present",
|
|
171
|
-
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
172
104
|
};
|
|
173
105
|
}
|
|
174
106
|
if (checked.data.verdict === "request-revision" &&
|
|
175
107
|
checked.data.findings.length === 0) {
|
|
176
108
|
return {
|
|
177
109
|
ok: false,
|
|
178
|
-
failureCategory: "protocol-invalid",
|
|
179
110
|
reason: "JSON review verdict request-revision requires at least one finding",
|
|
180
|
-
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
181
111
|
};
|
|
182
112
|
}
|
|
183
113
|
return { ok: true, verdict: checked.data.verdict };
|
|
184
114
|
}
|
|
115
|
+
function validateJsonReviewVerdict(text) {
|
|
116
|
+
const parsed = parseJsonReviewVerdict(text);
|
|
117
|
+
if (!parsed.ok) {
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
failureCategory: "protocol-invalid",
|
|
121
|
+
reason: parsed.reason,
|
|
122
|
+
firstNonEmptyLine: firstNonEmptyLine(text),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return { ok: true, verdict: parsed.verdict };
|
|
126
|
+
}
|
|
185
127
|
/**
|
|
186
128
|
* Validate node output against an explicit outputProtocol.
|
|
187
129
|
* Pure function — does not mutate run facts.
|
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { resolveCliPath } from "../../shared/path-refs.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { repairArtifactSchema } from "./repair-artifact.js";
|
|
7
|
-
import { dagRunDirExists, getDagRunDir, locateDagRun, readDagRunSpec, readDagRunState, } from "./lifecycle.js";
|
|
7
|
+
import { dagRunDirExists, getDagRunDir, isDagExecutionLifecycle, locateDagRun, readDagRunSpec, readDagRunState, } from "./lifecycle.js";
|
|
8
8
|
export const DAG_CLOSEOUT_DRAFT_DISCLAIMER = "> **Advisory only.** Derived from completed run facts. Canonical source remains `dag report --json` and `.harness/dag-runs/completed/<run-id>/`. Do not treat this draft as authoritative.";
|
|
9
9
|
import { dagNormalizedFailureCategorySchema, normalizeDagFailureCategory, } from "./failure-category.js";
|
|
10
10
|
import { dagProductLineFailureCategoryValues, routeDagFailure, } from "./failure-routing.js";
|
|
@@ -659,7 +659,14 @@ async function locateRunForReport(repoRoot, runId, filter) {
|
|
|
659
659
|
if (!located) {
|
|
660
660
|
throw new Error(`dag run not found: ${runId}`);
|
|
661
661
|
}
|
|
662
|
-
|
|
662
|
+
if (!isDagExecutionLifecycle(located.lifecycle)) {
|
|
663
|
+
throw new Error(`dag run not found: ${runId}`);
|
|
664
|
+
}
|
|
665
|
+
return {
|
|
666
|
+
lifecycle: located.lifecycle,
|
|
667
|
+
runDir: located.runDir,
|
|
668
|
+
runId,
|
|
669
|
+
};
|
|
663
670
|
}
|
|
664
671
|
const runDir = getDagRunDir(repoRoot, filter, runId);
|
|
665
672
|
if (!(await dagRunDirExists(runDir))) {
|