@nathapp/nax 0.92.2 → 0.92.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nax.js +447 -88
- package/package.json +2 -2
package/dist/nax.js
CHANGED
|
@@ -30012,11 +30012,39 @@ function roleLine(r) {
|
|
|
30012
30012
|
const cache = reads !== 0 || writes !== 0 ? ` cache r ${count(reads)} w ${count(writes)}` : "";
|
|
30013
30013
|
return ` ${r.role.padEnd(ROLE_WIDTH)} in ${count(r.inputTokens)} out ${count(r.outputTokens)} ${formatCost(r.costUsd)} ${calls}${cache}`;
|
|
30014
30014
|
}
|
|
30015
|
+
function mismatchLines(view, c) {
|
|
30016
|
+
if (!view.verdictMismatches?.length)
|
|
30017
|
+
return [];
|
|
30018
|
+
return [
|
|
30019
|
+
` ${c.gray("Inconsistent review verdicts:")} ${view.verdictMismatches.map((m) => `${m.model} ${m.count}`).join(", ")}`
|
|
30020
|
+
];
|
|
30021
|
+
}
|
|
30022
|
+
function timeoutLines(view, c) {
|
|
30023
|
+
const held = view.stories.filter((s) => s.gateTimeouts?.length);
|
|
30024
|
+
return held.length ? [
|
|
30025
|
+
` ${c.gray("Held on a gate timeout:")} ${held.map((s) => `${s.id} (${s.gateTimeouts?.join(", ")})`).join(", ")}`
|
|
30026
|
+
] : [];
|
|
30027
|
+
}
|
|
30028
|
+
function branchLines(branch, c) {
|
|
30029
|
+
if (!branch)
|
|
30030
|
+
return [];
|
|
30031
|
+
const lines = [
|
|
30032
|
+
` ${c.gray("Branch findings:")} ${branch.found} found, ${branch.fixed} fixed, ${branch.left} left (minors left ${branch.minorsLeft}${branch.fixRounds ? `, fix rounds ${branch.fixRounds}` : ""})`
|
|
30033
|
+
];
|
|
30034
|
+
if (branch.minors) {
|
|
30035
|
+
const m = branch.minors;
|
|
30036
|
+
lines.push(` ${c.gray("Deferred minors:")} ${m.found} found, ${m.promoted} promoted, ${m.fixNow} fix-now, ${m.left} left`);
|
|
30037
|
+
}
|
|
30038
|
+
return lines;
|
|
30039
|
+
}
|
|
30015
30040
|
function formatWorkflowSummary(view, options = {}) {
|
|
30016
30041
|
const c = options.useColor === false ? createNoopChalk() : source_default;
|
|
30017
30042
|
const lines = [];
|
|
30018
30043
|
lines.push(c.bold(c.blue(" WORKFLOW")));
|
|
30019
30044
|
lines.push(` ${c.gray("Duration:")} ${formatDurationSplit(view.storiesDurationMs, view.featureWorkflowDurationMs)}`);
|
|
30045
|
+
if (view.reviewOverlapMs) {
|
|
30046
|
+
lines.push(` ${c.gray("Review overlap with the full suite:")} ${formatDuration(view.reviewOverlapMs)}`);
|
|
30047
|
+
}
|
|
30020
30048
|
if (view.roles.length > 0) {
|
|
30021
30049
|
lines.push(` ${c.gray("Tokens and cost by role:")}`);
|
|
30022
30050
|
lines.push(...view.roles.map(roleLine));
|
|
@@ -30024,10 +30052,9 @@ function formatWorkflowSummary(view, options = {}) {
|
|
|
30024
30052
|
if (view.stories.length > 0) {
|
|
30025
30053
|
lines.push(` ${c.gray("Rounds:")} ${view.stories.map((s) => `${s.id} ${s.rounds}/${s.maxRounds}`).join(", ")}`);
|
|
30026
30054
|
}
|
|
30027
|
-
|
|
30028
|
-
|
|
30029
|
-
|
|
30030
|
-
}
|
|
30055
|
+
lines.push(...timeoutLines(view, c));
|
|
30056
|
+
lines.push(...mismatchLines(view, c));
|
|
30057
|
+
lines.push(...branchLines(view.branch, c));
|
|
30031
30058
|
if (view.branchReviewSkipped) {
|
|
30032
30059
|
const left = view.branchReviewSkipped.minorsLeft;
|
|
30033
30060
|
lines.push(` ${c.gray("Branch findings:")} branch review skipped (minors left ${left})`);
|
|
@@ -34108,7 +34135,8 @@ var init_schemas_workflow = __esm(() => {
|
|
|
34108
34135
|
init_schemas_model();
|
|
34109
34136
|
ExecutionModeSchema = _enum(["pipeline", "workflow"]);
|
|
34110
34137
|
WorkflowReviewConfigSchema = object({
|
|
34111
|
-
coverageRetries: number2().int().min(0).default(3)
|
|
34138
|
+
coverageRetries: number2().int().min(0).default(3),
|
|
34139
|
+
parallelWithSuite: boolean2().default(false)
|
|
34112
34140
|
}).prefault({});
|
|
34113
34141
|
WORKFLOW_REVIEW_DEFAULTS = WorkflowReviewConfigSchema.parse({});
|
|
34114
34142
|
WorkflowItemPublishConfigSchema = object({
|
|
@@ -39272,6 +39300,11 @@ function coerceSmartRunner(val) {
|
|
|
39272
39300
|
return { ...DEFAULT_SMART_RUNNER_CONFIG, enabled: false };
|
|
39273
39301
|
return { ...DEFAULT_SMART_RUNNER_CONFIG, ...val };
|
|
39274
39302
|
}
|
|
39303
|
+
function equalTestCommands(a, b) {
|
|
39304
|
+
if (typeof a === "string")
|
|
39305
|
+
return a === b;
|
|
39306
|
+
return Array.isArray(b) && a.length === b.length && a.every((command, index) => command === b[index]);
|
|
39307
|
+
}
|
|
39275
39308
|
function buildScopedCommand(testFiles, baseCommand, testScopedTemplate) {
|
|
39276
39309
|
if (testScopedTemplate) {
|
|
39277
39310
|
const quotedFiles = testFiles.map((file) => `'${file.replaceAll("'", "'\\''")}'`);
|
|
@@ -39291,12 +39324,10 @@ async function selectScopedTests(input) {
|
|
|
39291
39324
|
thresholdFallback: opts?.thresholdFallback ?? false,
|
|
39292
39325
|
isMonorepoOrchestrator
|
|
39293
39326
|
});
|
|
39294
|
-
const scoped = (files) =>
|
|
39295
|
-
effectiveCommand
|
|
39296
|
-
isFullSuite: false,
|
|
39297
|
-
|
|
39298
|
-
isMonorepoOrchestrator
|
|
39299
|
-
});
|
|
39327
|
+
const scoped = (files) => {
|
|
39328
|
+
const effectiveCommand = buildScopedCommand(files, input.testCommand, input.testScopedTemplate);
|
|
39329
|
+
return equalTestCommands(effectiveCommand, input.testCommand) ? fullSuite() : { effectiveCommand, isFullSuite: false, thresholdFallback: false, isMonorepoOrchestrator };
|
|
39330
|
+
};
|
|
39300
39331
|
if (!smartCfg.enabled || !input.storyGitRef || isMonorepoOrchestrator) {
|
|
39301
39332
|
return { effectiveCommand: input.testCommand, isFullSuite: true, thresholdFallback: false, isMonorepoOrchestrator };
|
|
39302
39333
|
}
|
|
@@ -39896,7 +39927,7 @@ function buildWorkflowImplementPrompt(input) {
|
|
|
39896
39927
|
${e2e}## Report
|
|
39897
39928
|
Write ${input.reportPath} with these sections:
|
|
39898
39929
|
- **What was built**
|
|
39899
|
-
- **TDD evidence**: for each AC, the failing run and the passing run (command and the relevant output lines). If you did not capture the failing run, say so under **Decisions & assumptions**; then evidence that the test exercises the new code path is acceptable. Missing evidence without that note, or a test that asserts nothing, fails review.
|
|
39930
|
+
- **TDD evidence**: for each AC, the test that covers it (file and test name), the failing run and the passing run (command and the relevant output lines). An AC with no test of its own is the most common review finding, and a test that also passes without your change does not cover its AC. If you did not capture the failing run, say so under **Decisions & assumptions**; then evidence that the test exercises the new code path is acceptable. Missing evidence without that note, or a test that asserts nothing, fails review.
|
|
39900
39931
|
- **Files changed**
|
|
39901
39932
|
- **Decisions & assumptions**: every judgment call you made and why.
|
|
39902
39933
|
|
|
@@ -41465,6 +41496,18 @@ var init_progress_commit = __esm(() => {
|
|
|
41465
41496
|
});
|
|
41466
41497
|
|
|
41467
41498
|
// src/prd/secret-shapes.ts
|
|
41499
|
+
function firstProviderKind(value) {
|
|
41500
|
+
for (const { kind, re, acceptMatch } of PROVIDER_PATTERNS) {
|
|
41501
|
+
re.lastIndex = 0;
|
|
41502
|
+
const match = re.exec(value);
|
|
41503
|
+
if (match === null)
|
|
41504
|
+
continue;
|
|
41505
|
+
if (acceptMatch !== undefined && !acceptMatch(match[0]))
|
|
41506
|
+
continue;
|
|
41507
|
+
return kind;
|
|
41508
|
+
}
|
|
41509
|
+
return;
|
|
41510
|
+
}
|
|
41468
41511
|
function findPrdSecretShapes(prd, scope) {
|
|
41469
41512
|
const findings = [];
|
|
41470
41513
|
for (const story of prd.userStories) {
|
|
@@ -41476,16 +41519,31 @@ function findPrdSecretShapes(prd, scope) {
|
|
|
41476
41519
|
...story.acceptanceCriteria.map((value, index) => [`acceptanceCriteria[${index}]`, value])
|
|
41477
41520
|
];
|
|
41478
41521
|
for (const [field, value] of fields) {
|
|
41479
|
-
|
|
41480
|
-
|
|
41522
|
+
const kind = firstProviderKind(value);
|
|
41523
|
+
if (kind !== undefined)
|
|
41524
|
+
findings.push({ storyId: story.id, field, kind });
|
|
41481
41525
|
}
|
|
41482
41526
|
}
|
|
41483
41527
|
return findings;
|
|
41484
41528
|
}
|
|
41485
|
-
var
|
|
41529
|
+
var PROVIDER_SECRET_KINDS, PROVIDER_PATTERNS;
|
|
41486
41530
|
var init_secret_shapes = __esm(() => {
|
|
41487
41531
|
init_internal();
|
|
41488
|
-
|
|
41532
|
+
PROVIDER_SECRET_KINDS = new Set([
|
|
41533
|
+
"openai",
|
|
41534
|
+
"github",
|
|
41535
|
+
"github-pat",
|
|
41536
|
+
"npm",
|
|
41537
|
+
"aws",
|
|
41538
|
+
"gitlab",
|
|
41539
|
+
"google",
|
|
41540
|
+
"stripe",
|
|
41541
|
+
"slack",
|
|
41542
|
+
"telegram",
|
|
41543
|
+
"pem",
|
|
41544
|
+
"jwt"
|
|
41545
|
+
]);
|
|
41546
|
+
PROVIDER_PATTERNS = SECRET_VALUE_PATTERNS.filter(({ kind }) => PROVIDER_SECRET_KINDS.has(kind));
|
|
41489
41547
|
});
|
|
41490
41548
|
|
|
41491
41549
|
// src/prd/spec-drift.ts
|
|
@@ -44938,7 +44996,7 @@ ${memory !== undefined ? `${memory}
|
|
|
44938
44996
|
- Consistency and duplication across stories.
|
|
44939
44997
|
- ${WORKFLOW_DESIGN_DECISIONS_ITEM}
|
|
44940
44998
|
- Storage against contracts: for every field one story persists and another story reads, writes or validates, the column type and width (as the migration declares it, not only the schema) must hold every value the DTOs, acceptance criteria and API contracts accept.
|
|
44941
|
-
- Triage each deferred minor as "fix-now"
|
|
44999
|
+
- Triage each deferred minor: "promote" when it describes wrong behaviour a user or caller can reach (it is then fixed as a blocking finding), "fix-now" when it is a real defect or a breach of a project rule worth fixing before the PR, or "leave" when it is style, comment wording, formatting or duplication that no project rule names (it is listed in the PR body and not fixed). Its "minorTriage" entry is its whole verdict: do not repeat a deferred minor as a finding.
|
|
44942
45000
|
Judge every changed file you read against the checklist below, as well as against the cross-story contracts.
|
|
44943
45001
|
|
|
44944
45002
|
${WORKFLOW_QUALITY_CHECKLIST}
|
|
@@ -44987,13 +45045,19 @@ function buildWorkflowBranchFixPrompt(input) {
|
|
|
44987
45045
|
];
|
|
44988
45046
|
const read = documents.length > 0 ? ` Read ${documents.join(" and ")} for what the feature must do.` : "";
|
|
44989
45047
|
const memory = memorySectionOf(input.memoryIndex);
|
|
45048
|
+
const blocking = input.findings.filter((f) => f.severity !== "minor");
|
|
45049
|
+
const minors = input.findings.filter((f) => f.severity === "minor");
|
|
44990
45050
|
return `You are fixing a feature branch after its whole-branch review. Fix every finding in this pass: a later pass, if any, only re-checks what is still open.${read}
|
|
44991
45051
|
|
|
44992
45052
|
## Findings to fix
|
|
44993
|
-
${renderWorkflowFindings(
|
|
44994
|
-
|
|
45053
|
+
${renderWorkflowFindings(blocking)}
|
|
45054
|
+
${minors.length > 0 ? `
|
|
45055
|
+
## Minor findings to fix after those
|
|
45056
|
+
${renderWorkflowFindings(minors)}
|
|
45057
|
+
` : ""}
|
|
44995
45058
|
## How to work
|
|
44996
|
-
- Fix every finding above. Findings marked minor are
|
|
45059
|
+
- Fix every finding above. Findings marked minor are cleanups the reviewer chose to fix now.
|
|
45060
|
+
- Fix the findings in the first list before the minor ones.
|
|
44997
45061
|
- For a red repo gate, or a story that ended with a red gate: ${GATE_INTEGRITY_RULE}
|
|
44998
45062
|
- Re-run the tests that cover what you changed, and add a test where a finding names a missing one (TDD: see it fail first).
|
|
44999
45063
|
- Before you commit, run the full test command of every package you changed, not only the tests you touched: the final repo gates run every suite, and a fix that breaks an unrelated test there turns the branch red.
|
|
@@ -45006,7 +45070,7 @@ ${memory !== undefined ? `${memory}
|
|
|
45006
45070
|
` : ""}${WORKFLOW_REPLY_CONTRACT}`;
|
|
45007
45071
|
}
|
|
45008
45072
|
var NONE2 = "(none)", listOr = (items, empty) => items.length > 0 ? items.join(", ") : empty, CANNOT_VERIFY_RULE = `Put in "cannotVerify" only what neither nax's gates nor a scoped command can check, such as behaviour that needs a live external service.
|
|
45009
|
-
Say a tool or service is unavailable only together with the command you ran and the error it returned; otherwise say what you did not try.`, CARRY_CANNOT_VERIFY = 'Check each item above that the code or a scoped command can settle. Repeat in your "cannotVerify" every one you still cannot verify: an item you leave out is reported as verified.', STORY_REPORTS_RULE = `A deferred minor or cannot-verify item that says a story's report is missing or unreadable is settled by this list: when the list shows the report, triage that minor "leave" and do not repeat the claim in "cannotVerify".`, REVIEW_JSON = '{"spec": "pass|fail", "quality": "approved|changes", "inspectedFiles": ["path"], "findings": [{"severity": "critical|important|minor", "kind": "spec|quality", "file": "path", "line": 0, "acId": "AC-3", "issue": "what is wrong", "observed": "verbatim excerpt", "suggestion": "how to fix"}], "cannotVerify": ["..."], "minorTriage": [{"id": "M1", "decision": "fix-now|leave"}]}';
|
|
45073
|
+
Say a tool or service is unavailable only together with the command you ran and the error it returned; otherwise say what you did not try.`, CARRY_CANNOT_VERIFY = 'Check each item above that the code or a scoped command can settle. Repeat in your "cannotVerify" every one you still cannot verify: an item you leave out is reported as verified.', STORY_REPORTS_RULE = `A deferred minor or cannot-verify item that says a story's report is missing or unreadable is settled by this list: when the list shows the report, triage that minor "leave" and do not repeat the claim in "cannotVerify".`, REVIEW_JSON = '{"spec": "pass|fail", "quality": "approved|changes", "inspectedFiles": ["path"], "findings": [{"severity": "critical|important|minor", "kind": "spec|quality", "file": "path", "line": 0, "acId": "AC-3", "issue": "what is wrong", "observed": "verbatim excerpt", "suggestion": "how to fix"}], "cannotVerify": ["..."], "minorTriage": [{"id": "M1", "decision": "promote|fix-now|leave"}]}';
|
|
45010
45074
|
var init_workflow_branch_builder = __esm(() => {
|
|
45011
45075
|
init_workflow_implementer_builder();
|
|
45012
45076
|
});
|
|
@@ -45115,14 +45179,17 @@ var init_workflow_re_review_builder = __esm(() => {
|
|
|
45115
45179
|
});
|
|
45116
45180
|
|
|
45117
45181
|
// src/prompts/builders/workflow-story-review-builder.ts
|
|
45118
|
-
function naxCheckedBlock2(gates, e2eGate) {
|
|
45182
|
+
function naxCheckedBlock2(gates, e2eGate, suiteRunning) {
|
|
45119
45183
|
const state = (name) => gates[name] ?? "not run";
|
|
45120
45184
|
const redSuite = gates["full-suite"] === "red" ? `
|
|
45121
45185
|
The full suite is red; nax already records its failures as open findings, so do not repeat them as findings.` : "";
|
|
45122
45186
|
const e2e = e2eGate ? `
|
|
45123
45187
|
nax runs the e2e suite as a repository gate on the host; do not list e2e journeys in cannotVerify.` : "";
|
|
45188
|
+
const suiteState = suiteRunning ? "still running" : state("full-suite");
|
|
45189
|
+
const runningHint = suiteRunning ? `
|
|
45190
|
+
The full suite is still running while you review; nax records its result itself, so do not list it under cannotVerify.` : "";
|
|
45124
45191
|
return `## What nax already checked
|
|
45125
|
-
nax ran these gates on this story before your review: lint ${state("lint")}, typecheck ${state("typecheck")}, scoped tests ${state("scoped")}, full suite ${
|
|
45192
|
+
nax ran these gates on this story before your review: lint ${state("lint")}, typecheck ${state("typecheck")}, scoped tests ${state("scoped")}, full suite ${suiteState}.${runningHint}${redSuite}
|
|
45126
45193
|
Do not list these gates in "cannotVerify": their results are stated here. Once every story is done nax runs the repository gates; nax records whether they ran and what they returned, so do not list the repository gates in "cannotVerify" either.
|
|
45127
45194
|
If you have a shell tool, run this story's own test files with one scoped test command before you give the spec verdict.${e2e}`;
|
|
45128
45195
|
}
|
|
@@ -45139,7 +45206,7 @@ ${input.concerns.map((c) => `- ${c}`).join(`
|
|
|
45139
45206
|
|
|
45140
45207
|
For each acceptance criterion, verify the current code implements it correctly. Use the diff to find the changed paths, not as the only source of truth. Follow each criterion's data and contract to where it is declared or stored (schema, migrations, DTOs, shared types), including code an earlier story created that this diff does not touch: a limit the story accepts must fit the storage and contracts it writes to. Read a file before you flag it.
|
|
45141
45208
|
|
|
45142
|
-
${naxCheckedBlock2(input.gates ?? {}, input.e2eGate === true)}
|
|
45209
|
+
${naxCheckedBlock2(input.gates ?? {}, input.e2eGate === true, input.suiteRunning === true)}
|
|
45143
45210
|
|
|
45144
45211
|
${WORKFLOW_SETTLED_RULINGS_RULE}
|
|
45145
45212
|
|
|
@@ -45151,7 +45218,7 @@ Give two verdicts:
|
|
|
45151
45218
|
- **spec**: "pass" only if every acceptance criterion is implemented and covered by a test that would fail without it. Check the report's TDD evidence: missing evidence for an AC (other than an honest not-captured note), or a test that asserts nothing, is a spec failure. A report that says the failing run was not captured is not a spec failure when the test exercises the new code path. A failing run produced by reverting or stashing the implementation is a finding.
|
|
45152
45219
|
- **quality**: "approved" or "changes" (correctness, error handling, edge cases, conventions of the surrounding code).
|
|
45153
45220
|
|
|
45154
|
-
Severity: "critical" (wrong or unsafe behaviour), "important" (must fix before this story is done), "minor" (worth noting, not blocking). ${CANNOT_VERIFY_RULE2}
|
|
45221
|
+
Severity: "critical" (wrong or unsafe behaviour), "important" (must fix before this story is done), "minor" (worth noting, not blocking). Wrong behaviour a user or caller can reach is critical or important, however small the fix. Every minor you list is handed to one fix pass after all stories are done, so a minor is an improvement worth that pass. Style, comment wording, formatting and duplication are findings only where a project rule or the convention of the surrounding code says so. ${CANNOT_VERIFY_RULE2}
|
|
45155
45222
|
|
|
45156
45223
|
List every file you opened in "inspectedFiles". A critical or important finding about what the code does carries "observed": a verbatim 1-3 line excerpt from the file that proves it; if you cannot quote one, it is minor or belongs in "cannotVerify". A finding about a missing or empty test names the AC and the test file you checked instead.
|
|
45157
45224
|
|
|
@@ -45164,6 +45231,14 @@ function buildWorkflowReviewJsonRetry() {
|
|
|
45164
45231
|
function buildWorkflowReviewJsonRetryCondensed() {
|
|
45165
45232
|
return 'Your reply was cut off. Re-send a shorter version: keep every finding but shorten "issue" and "suggestion" to one sentence each. Only the JSON object.';
|
|
45166
45233
|
}
|
|
45234
|
+
function buildWorkflowVerdictMismatchRetry(mismatch) {
|
|
45235
|
+
const messages = {
|
|
45236
|
+
spec: "You returned spec: fail but no critical or important spec finding. Either name the acceptance criterion that fails as a finding, or change the verdict to pass.",
|
|
45237
|
+
quality: "You returned quality: changes but no critical or important finding. Either name the defect as a finding, or change the verdict to approved."
|
|
45238
|
+
};
|
|
45239
|
+
return [...mismatch.map((kind) => messages[kind]), buildWorkflowReviewJsonRetry()].join(`
|
|
45240
|
+
`);
|
|
45241
|
+
}
|
|
45167
45242
|
var CANNOT_VERIFY_RULE2 = `Put in "cannotVerify" only what neither nax's gates nor a scoped command can check, such as behaviour that needs a live external service.
|
|
45168
45243
|
Say a tool or service is unavailable only together with the command you ran and the error it returned; otherwise say what you did not try.`;
|
|
45169
45244
|
var init_workflow_story_review_builder = __esm(() => {
|
|
@@ -46161,6 +46236,9 @@ function stepSignal(base, ms) {
|
|
|
46161
46236
|
var STEP_TIMEOUT_MARGIN_MS = 60000;
|
|
46162
46237
|
|
|
46163
46238
|
// src/operations/workflow-replies.ts
|
|
46239
|
+
function isBranchQualityFloor(finding) {
|
|
46240
|
+
return Object.hasOwn(finding, QUALITY_FLOOR);
|
|
46241
|
+
}
|
|
46164
46242
|
function isRecord7(v) {
|
|
46165
46243
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
46166
46244
|
}
|
|
@@ -46256,13 +46334,16 @@ function parseStoryReviewReply(output) {
|
|
|
46256
46334
|
if (parsed.quality !== "approved" && parsed.quality !== "changes")
|
|
46257
46335
|
return null;
|
|
46258
46336
|
const findings = drafts(parsed.findings);
|
|
46259
|
-
const
|
|
46260
|
-
|
|
46261
|
-
|
|
46337
|
+
const mismatch = [];
|
|
46338
|
+
if (parsed.spec === "fail" && !findings.some((f) => f.kind === "spec" && f.severity !== "minor"))
|
|
46339
|
+
mismatch.push("spec");
|
|
46340
|
+
if (parsed.quality === "changes" && !findings.some((f) => f.severity !== "minor"))
|
|
46341
|
+
mismatch.push("quality");
|
|
46262
46342
|
return {
|
|
46263
46343
|
spec: parsed.spec,
|
|
46264
46344
|
quality: parsed.quality,
|
|
46265
|
-
findings
|
|
46345
|
+
findings,
|
|
46346
|
+
...mismatch.length ? { mismatch } : {},
|
|
46266
46347
|
cannotVerify: strings2(parsed.cannotVerify),
|
|
46267
46348
|
inspectedFiles: strings2(parsed.inspectedFiles)
|
|
46268
46349
|
};
|
|
@@ -46298,7 +46379,7 @@ function triageOf(parsed) {
|
|
|
46298
46379
|
for (const entry of parsed.minorTriage) {
|
|
46299
46380
|
if (!isRecord7(entry) || typeof entry.id !== "string" || triage.has(entry.id))
|
|
46300
46381
|
continue;
|
|
46301
|
-
if (entry.decision === "fix-now" || entry.decision === "leave")
|
|
46382
|
+
if (entry.decision === "promote" || entry.decision === "fix-now" || entry.decision === "leave")
|
|
46302
46383
|
triage.set(entry.id, entry.decision);
|
|
46303
46384
|
}
|
|
46304
46385
|
return triage;
|
|
@@ -46307,15 +46388,29 @@ function parseBranchReviewReply(output, minorIds) {
|
|
|
46307
46388
|
const verdict = parseStoryReviewReply(output);
|
|
46308
46389
|
if (!verdict)
|
|
46309
46390
|
return null;
|
|
46391
|
+
const { mismatch, ...branchVerdict } = verdict;
|
|
46392
|
+
const findings = [...verdict.findings];
|
|
46393
|
+
if (mismatch?.includes("spec"))
|
|
46394
|
+
findings.push({ kind: "spec", severity: "important", issue: SPEC_FAIL_ISSUE });
|
|
46395
|
+
if (verdict.quality === "changes" && !findings.some((f) => f.severity !== "minor")) {
|
|
46396
|
+
const floor = { kind: "quality", severity: "important", issue: QUALITY_CHANGES_ISSUE };
|
|
46397
|
+
Object.defineProperty(floor, QUALITY_FLOOR, { value: true });
|
|
46398
|
+
findings.push(floor);
|
|
46399
|
+
}
|
|
46310
46400
|
const triage = triageOf(tryParseLLMJson(output));
|
|
46311
|
-
return {
|
|
46401
|
+
return {
|
|
46402
|
+
...branchVerdict,
|
|
46403
|
+
findings,
|
|
46404
|
+
minorTriage: minorIds.map((id) => ({ id, decision: triage.get(id) ?? "leave" }))
|
|
46405
|
+
};
|
|
46312
46406
|
}
|
|
46313
|
-
var WORKFLOW_INTERRUPT_MARKER = "<<nax-workflow-interrupted>>", STATUSES, SEVERITIES, REVIEW_KINDS, NO_VERDICT_NOTE = "(no verdict returned)", SPEC_FAIL_ISSUE = "Story review returned spec: fail without a blocking spec finding. Re-read the brief's acceptance criteria and the TDD-evidence rule, and fix what is missing.", QUALITY_CHANGES_ISSUE = "Story review returned quality: changes without a blocking finding. Re-read the story diff for the quality problem the reviewer saw, and fix it.";
|
|
46407
|
+
var WORKFLOW_INTERRUPT_MARKER = "<<nax-workflow-interrupted>>", STATUSES, SEVERITIES, REVIEW_KINDS, NO_VERDICT_NOTE = "(no verdict returned)", SPEC_FAIL_ISSUE = "Story review returned spec: fail without a blocking spec finding. Re-read the brief's acceptance criteria and the TDD-evidence rule, and fix what is missing.", QUALITY_CHANGES_ISSUE = "Story review returned quality: changes without a blocking finding. Re-read the story diff for the quality problem the reviewer saw, and fix it.", QUALITY_FLOOR;
|
|
46314
46408
|
var init_workflow_replies = __esm(() => {
|
|
46315
46409
|
init_llm_json();
|
|
46316
46410
|
STATUSES = ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"];
|
|
46317
46411
|
SEVERITIES = ["critical", "important", "minor"];
|
|
46318
46412
|
REVIEW_KINDS = ["spec", "quality"];
|
|
46413
|
+
QUALITY_FLOOR = Symbol("branch quality floor");
|
|
46319
46414
|
});
|
|
46320
46415
|
|
|
46321
46416
|
// src/operations/bot-pr-review-reply.ts
|
|
@@ -48339,10 +48434,16 @@ var init_workflow_story_review = __esm(() => {
|
|
|
48339
48434
|
parse: (output) => parseStoryReviewReply(output),
|
|
48340
48435
|
retry: makeParseRetryStrategy({
|
|
48341
48436
|
parse: (output) => parseStoryReviewReply(output),
|
|
48342
|
-
validate: (parsed) => parsed !== null,
|
|
48437
|
+
validate: (parsed) => parsed !== null && typeof parsed === "object" && !("mismatch" in parsed),
|
|
48343
48438
|
reviewerKind: "workflow-story-review",
|
|
48344
48439
|
maxAttempts: 2,
|
|
48345
|
-
prompts: {
|
|
48440
|
+
prompts: {
|
|
48441
|
+
invalid: (output) => {
|
|
48442
|
+
const mismatch = parseStoryReviewReply(output)?.mismatch;
|
|
48443
|
+
return mismatch ? buildWorkflowVerdictMismatchRetry(mismatch) : buildWorkflowReviewJsonRetry();
|
|
48444
|
+
},
|
|
48445
|
+
truncated: buildWorkflowReviewJsonRetryCondensed
|
|
48446
|
+
},
|
|
48346
48447
|
exhaustedFallback: () => null
|
|
48347
48448
|
})
|
|
48348
48449
|
};
|
|
@@ -54702,6 +54803,7 @@ function buildLastRun(runs) {
|
|
|
54702
54803
|
totalStories,
|
|
54703
54804
|
storiesCompleted: last.storiesCompleted,
|
|
54704
54805
|
storiesFailed: last.storiesFailed,
|
|
54806
|
+
storiesGateOpen: last.storiesGateOpen ?? 0,
|
|
54705
54807
|
totalCost,
|
|
54706
54808
|
avgCostPerStory,
|
|
54707
54809
|
stories
|
|
@@ -55321,7 +55423,7 @@ var package_default;
|
|
|
55321
55423
|
var init_package = __esm(() => {
|
|
55322
55424
|
package_default = {
|
|
55323
55425
|
name: "@nathapp/nax",
|
|
55324
|
-
version: "0.92.
|
|
55426
|
+
version: "0.92.3",
|
|
55325
55427
|
description: "AI Coding Agent Orchestrator \u2014 loops until done",
|
|
55326
55428
|
type: "module",
|
|
55327
55429
|
bin: {
|
|
@@ -55407,7 +55509,7 @@ var init_package = __esm(() => {
|
|
|
55407
55509
|
"@agentclientprotocol/sdk": "~1.7.0",
|
|
55408
55510
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
55409
55511
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
55410
|
-
"@nathapp/nax-ai": "0.92.
|
|
55512
|
+
"@nathapp/nax-ai": "0.92.3",
|
|
55411
55513
|
chalk: "^5.6.2",
|
|
55412
55514
|
commander: "^13.1.0",
|
|
55413
55515
|
"highlight.js": "^11.12.0",
|
|
@@ -79502,11 +79604,12 @@ async function collectStoryMetrics(ctx, storyStartTime) {
|
|
|
79502
79604
|
const story = ctx.story;
|
|
79503
79605
|
const routing = ctx.routing;
|
|
79504
79606
|
const agentResult = ctx.agentResult;
|
|
79607
|
+
const gateOpen = ctx.workflowEndState === "complete-gate-open";
|
|
79505
79608
|
const escalationCount = story.escalations?.length || 0;
|
|
79506
79609
|
const priorFailureCount = story.priorFailures?.length || 0;
|
|
79507
79610
|
const attempts = priorFailureCount + Math.max(1, story.attempts || 1);
|
|
79508
79611
|
const finalTier = escalationCount > 0 ? story.escalations[escalationCount - 1].toTier : routing.modelTier;
|
|
79509
|
-
const firstPassSuccess = agentResult?.success === true && escalationCount === 0 && priorFailureCount === 0;
|
|
79612
|
+
const firstPassSuccess = agentResult?.success === true && !gateOpen && escalationCount === 0 && priorFailureCount === 0;
|
|
79510
79613
|
const agentUsed = routing.agent ?? ctx.agentManager?.getDefault() ?? resolveDefaultAgent(ctx.config);
|
|
79511
79614
|
let modelUsed = routing.modelTier;
|
|
79512
79615
|
try {
|
|
@@ -79528,7 +79631,7 @@ async function collectStoryMetrics(ctx, storyStartTime) {
|
|
|
79528
79631
|
agentUsed,
|
|
79529
79632
|
attempts,
|
|
79530
79633
|
finalTier,
|
|
79531
|
-
success: agentResult?.success
|
|
79634
|
+
success: agentResult?.success === true && !gateOpen,
|
|
79532
79635
|
cost: costSnapshot !== undefined ? totalSpendUsd(costSnapshot) : 0,
|
|
79533
79636
|
durationMs: agentResult?.durationMs || 0,
|
|
79534
79637
|
firstPassSuccess,
|
|
@@ -85025,6 +85128,19 @@ async function captureVerifyResult(storyId, writtenByAgent, v2Enabled, result, r
|
|
|
85025
85128
|
});
|
|
85026
85129
|
}
|
|
85027
85130
|
}
|
|
85131
|
+
async function coversSuite(input, ctx, deps, run) {
|
|
85132
|
+
if (!run.isFullSuite)
|
|
85133
|
+
return false;
|
|
85134
|
+
try {
|
|
85135
|
+
return equalTestCommands(run.command, await deps.resolveFullSuiteCommand(ctx.packageView.config, input.workdir, input.packagePrefix));
|
|
85136
|
+
} catch (err) {
|
|
85137
|
+
getLogger2().warn("verify[scoped]", "Could not resolve full suite command \u2014 running suite separately", {
|
|
85138
|
+
storyId: input.storyId,
|
|
85139
|
+
error: errorMessage(err)
|
|
85140
|
+
});
|
|
85141
|
+
return false;
|
|
85142
|
+
}
|
|
85143
|
+
}
|
|
85028
85144
|
var _verifyScopedDeps, verifyScopedOp;
|
|
85029
85145
|
var init_verify_scoped = __esm(() => {
|
|
85030
85146
|
init_internal();
|
|
@@ -85036,6 +85152,10 @@ var init_verify_scoped = __esm(() => {
|
|
|
85036
85152
|
init_test_runners();
|
|
85037
85153
|
init_runners();
|
|
85038
85154
|
_verifyScopedDeps = {
|
|
85155
|
+
resolveFullSuiteCommand: async (config, workdir, packageDir) => {
|
|
85156
|
+
await Promise.resolve().then(() => init_command_resolver());
|
|
85157
|
+
return (await resolveQualityTestCommands(config, workdir, packageDir)).testCommand;
|
|
85158
|
+
},
|
|
85039
85159
|
selectScopedTests,
|
|
85040
85160
|
regression,
|
|
85041
85161
|
parseTestOutput,
|
|
@@ -85070,7 +85190,8 @@ var init_verify_scoped = __esm(() => {
|
|
|
85070
85190
|
findings: [],
|
|
85071
85191
|
durationMs: 0,
|
|
85072
85192
|
passCount: 0,
|
|
85073
|
-
isFullSuite: true
|
|
85193
|
+
isFullSuite: true,
|
|
85194
|
+
coversFullSuite: false
|
|
85074
85195
|
};
|
|
85075
85196
|
}
|
|
85076
85197
|
await maybeRunNewPackageSetup({
|
|
@@ -85105,6 +85226,7 @@ var init_verify_scoped = __esm(() => {
|
|
|
85105
85226
|
durationMs: 0,
|
|
85106
85227
|
passCount: 0,
|
|
85107
85228
|
isFullSuite: true,
|
|
85229
|
+
coversFullSuite: false,
|
|
85108
85230
|
scopeTestFallback: selection.scopeTestFallback
|
|
85109
85231
|
};
|
|
85110
85232
|
}
|
|
@@ -85185,6 +85307,7 @@ var init_verify_scoped = __esm(() => {
|
|
|
85185
85307
|
durationMs,
|
|
85186
85308
|
passCount: parsed.passed,
|
|
85187
85309
|
isFullSuite,
|
|
85310
|
+
coversFullSuite: await coversSuite(input, ctx, deps, { command: effectiveCommand, isFullSuite }),
|
|
85188
85311
|
scopeTestFallback
|
|
85189
85312
|
};
|
|
85190
85313
|
}
|
|
@@ -85203,6 +85326,7 @@ var init_verify_scoped = __esm(() => {
|
|
|
85203
85326
|
durationMs,
|
|
85204
85327
|
passCount: parsed.passed,
|
|
85205
85328
|
isFullSuite,
|
|
85329
|
+
coversFullSuite: false,
|
|
85206
85330
|
scopeTestFallback
|
|
85207
85331
|
};
|
|
85208
85332
|
}
|
|
@@ -85240,6 +85364,7 @@ var init_verify_scoped = __esm(() => {
|
|
|
85240
85364
|
durationMs,
|
|
85241
85365
|
passCount: parsed.passed,
|
|
85242
85366
|
isFullSuite,
|
|
85367
|
+
coversFullSuite: false,
|
|
85243
85368
|
scopeTestFallback
|
|
85244
85369
|
};
|
|
85245
85370
|
}
|
|
@@ -85517,8 +85642,8 @@ var init_version = __esm(() => {
|
|
|
85517
85642
|
NAX_AI_VERSION = CATALOG_VERSION;
|
|
85518
85643
|
NAX_COMMIT = (() => {
|
|
85519
85644
|
try {
|
|
85520
|
-
if (/^[0-9a-f]{6,10}$/.test("
|
|
85521
|
-
return "
|
|
85645
|
+
if (/^[0-9a-f]{6,10}$/.test("7d50765"))
|
|
85646
|
+
return "7d50765";
|
|
85522
85647
|
} catch {}
|
|
85523
85648
|
try {
|
|
85524
85649
|
const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
|
|
@@ -111591,13 +111716,19 @@ function configEvidence(facts) {
|
|
|
111591
111716
|
}
|
|
111592
111717
|
function implementerQuestionDraft(feature, q) {
|
|
111593
111718
|
const facts = q.facts;
|
|
111719
|
+
const timing = q.timing;
|
|
111720
|
+
const isTimeout = q.status === "GATE_TIMEOUT" && timing !== undefined;
|
|
111721
|
+
const limit = timing?.limitSeconds === undefined ? "limit unknown" : `limit ${timing.limitSeconds} s`;
|
|
111594
111722
|
return {
|
|
111595
111723
|
kind: "implementer-question",
|
|
111596
111724
|
feature,
|
|
111597
111725
|
storyId: q.storyId,
|
|
111598
|
-
summary: `The implementer for ${q.storyId} stopped with ${q.status} and needs an answer to continue.`,
|
|
111726
|
+
summary: isTimeout ? `nax stopped the fix loop for ${q.storyId}: the ${timing.gates.join(", ")} gate timed out and another fix round cannot change a slow or hanging command.` : `The implementer for ${q.storyId} stopped with ${q.status} and needs an answer to continue.`,
|
|
111599
111727
|
evidence: [
|
|
111600
|
-
|
|
111728
|
+
isTimeout ? {
|
|
111729
|
+
source: "gate",
|
|
111730
|
+
text: `Gate timeout facts: ${limit}; run-start baseline timed out: ${timing.baselineTimedOut ? "yes" : "no"}; same gate timed out in the previous pass: ${timing.repeated ? "yes" : "no"}`
|
|
111731
|
+
} : { source: "agent-diagnosis", text: q.concerns || "(no concern text)" },
|
|
111601
111732
|
...facts ? configEvidence(facts) : []
|
|
111602
111733
|
],
|
|
111603
111734
|
options: buildMenu({ kind: "implementer-question", configChanges: facts?.candidates })
|
|
@@ -119637,7 +119768,7 @@ async function appendReviewRules(sc, packagePath, paths) {
|
|
|
119637
119768
|
overrideMode: rules?.overrideMode ?? "merge"
|
|
119638
119769
|
});
|
|
119639
119770
|
}
|
|
119640
|
-
async function runStoryReview(sc, concerns, gates = {}) {
|
|
119771
|
+
async function runStoryReview(sc, concerns, gates = {}, options) {
|
|
119641
119772
|
const packagePath = join154(sc.storyDir, "package-0.diff");
|
|
119642
119773
|
const prompt = buildWorkflowStoryReviewPrompt({
|
|
119643
119774
|
briefPath: sc.briefPath,
|
|
@@ -119645,6 +119776,7 @@ async function runStoryReview(sc, concerns, gates = {}) {
|
|
|
119645
119776
|
packagePath,
|
|
119646
119777
|
concerns,
|
|
119647
119778
|
gates,
|
|
119779
|
+
suiteRunning: options?.suiteRunning,
|
|
119648
119780
|
e2eGate: sc.config.quality?.commands?.e2e !== undefined
|
|
119649
119781
|
});
|
|
119650
119782
|
const outcome = await underReviewLimit(sc, async () => {
|
|
@@ -128111,6 +128243,17 @@ var init_publish_item_threads = __esm(() => {
|
|
|
128111
128243
|
});
|
|
128112
128244
|
|
|
128113
128245
|
// src/workflow/re-review-absorb.ts
|
|
128246
|
+
function reReviewStatus(v) {
|
|
128247
|
+
if (!v)
|
|
128248
|
+
return "no verdict";
|
|
128249
|
+
if (v.residual)
|
|
128250
|
+
return "PARTIAL";
|
|
128251
|
+
return v.addressed ? "addressed" : "NOT addressed";
|
|
128252
|
+
}
|
|
128253
|
+
function reReviewSummary(asked, verdict, added) {
|
|
128254
|
+
const per = asked.map((f) => `${f.id} ${reReviewStatus(verdict.verdicts.find((x) => x.id === f.id))}`);
|
|
128255
|
+
return added.length > 0 ? `${per.join(", ")}; new: ${describeFindings(added)}` : per.join(", ");
|
|
128256
|
+
}
|
|
128114
128257
|
function withResidual(finding, residual) {
|
|
128115
128258
|
const { observed: _observed, file, line, suggestion, ...kept } = finding;
|
|
128116
128259
|
const at = {
|
|
@@ -128155,6 +128298,9 @@ function absorbReReviewVerdict(asked, verdict) {
|
|
|
128155
128298
|
}
|
|
128156
128299
|
return { open, newDrafts: verdict.newFindings.filter((draft) => !restates(sites, draft)) };
|
|
128157
128300
|
}
|
|
128301
|
+
var init_re_review_absorb = __esm(() => {
|
|
128302
|
+
init_run_log();
|
|
128303
|
+
});
|
|
128158
128304
|
|
|
128159
128305
|
// src/workflow/restated-minors.ts
|
|
128160
128306
|
function significantWords(text) {
|
|
@@ -128247,8 +128393,11 @@ async function repoGatesStep(env, rec) {
|
|
|
128247
128393
|
}
|
|
128248
128394
|
return { patch: { repoGates: run.summary, gateFindings: findings, nextFindingId } };
|
|
128249
128395
|
}
|
|
128250
|
-
function withQualityFloor(verdict) {
|
|
128251
|
-
const blocking =
|
|
128396
|
+
function withQualityFloor(verdict, promoted) {
|
|
128397
|
+
const blocking = [
|
|
128398
|
+
...verdict.findings.filter((finding) => isBlocking(finding) && !(promoted.length > 0 && isBranchQualityFloor(finding))),
|
|
128399
|
+
...promoted
|
|
128400
|
+
];
|
|
128252
128401
|
if (verdict.quality !== "changes" || blocking.length > 0)
|
|
128253
128402
|
return blocking;
|
|
128254
128403
|
return [{ kind: "quality", severity: "important", issue: QUALITY_CHANGES_ISSUE2 }];
|
|
@@ -128274,10 +128423,15 @@ async function branchReviewStep(env, rec) {
|
|
|
128274
128423
|
const triagedMinors = rec.minors.map((m) => ({ ...m, triage: triage.get(m.id) ?? "leave" }));
|
|
128275
128424
|
const restated = splitRestatedMinors(out.verdict.findings, rec.minors);
|
|
128276
128425
|
await noteRestated(env, restated.dropped);
|
|
128277
|
-
const
|
|
128426
|
+
const promoted = triagedMinors.filter((m) => m.triage === "promote").map((m) => ({
|
|
128427
|
+
kind: "quality",
|
|
128428
|
+
severity: "important",
|
|
128429
|
+
issue: `${m.storyId}: ${m.text}`
|
|
128430
|
+
}));
|
|
128431
|
+
const { findings, nextFindingId } = assign(rec, withQualityFloor(out.verdict, promoted));
|
|
128278
128432
|
const minors = out.verdict.findings.filter((f) => !isBlocking(f));
|
|
128279
128433
|
await env.sink.artifact("branch-review.json", { ...out.verdict, cannotVerify, findings: [...findings, ...minors] });
|
|
128280
|
-
const deferredTriage = rec.minors.length > 0 ? `; deferred minors: ${triagedMinors.filter((m) => m.triage === "fix-now").length} fix-now, ${triagedMinors.filter((m) => m.triage === "leave").length} leave` : "";
|
|
128434
|
+
const deferredTriage = rec.minors.length > 0 ? `; deferred minors: ${promoted.length > 0 ? `${promoted.length} promote, ` : ""}${triagedMinors.filter((m) => m.triage === "fix-now").length} fix-now, ${triagedMinors.filter((m) => m.triage === "leave").length} leave` : "";
|
|
128281
128435
|
log.done(`spec ${out.verdict.spec}, quality ${out.verdict.quality} - ${describeFindings([...findings, ...minors])}${deferredTriage}`);
|
|
128282
128436
|
return {
|
|
128283
128437
|
patch: {
|
|
@@ -128293,7 +128447,7 @@ async function branchReviewStep(env, rec) {
|
|
|
128293
128447
|
}
|
|
128294
128448
|
async function branchFixStep(env, rec) {
|
|
128295
128449
|
const round = fixRoundsOf(rec) + 1;
|
|
128296
|
-
const toFix = isFollowUpRound(rec) ? roundTargets(rec) : [...rec.reviewOpen, ...
|
|
128450
|
+
const toFix = isFollowUpRound(rec) ? roundTargets(rec) : [...rec.reviewOpen, ...rec.gateFindings, ...fixNowMinors(rec)];
|
|
128297
128451
|
if (toFix.length === 0)
|
|
128298
128452
|
return { patch: {}, exit: "nothing-to-fix" };
|
|
128299
128453
|
const max = limitsOf(env).maxBranchFixRounds;
|
|
@@ -128515,6 +128669,7 @@ var isBlocking = (f) => f.severity !== "minor", minorIssues = (drafts) => drafts
|
|
|
128515
128669
|
var init_feature_steps = __esm(() => {
|
|
128516
128670
|
init_internal();
|
|
128517
128671
|
init_logger2();
|
|
128672
|
+
init_operations2();
|
|
128518
128673
|
init_approval();
|
|
128519
128674
|
init_branch_fix_rounds();
|
|
128520
128675
|
init_ci_repair_steps();
|
|
@@ -128522,6 +128677,7 @@ var init_feature_steps = __esm(() => {
|
|
|
128522
128677
|
init_gate_timing();
|
|
128523
128678
|
init_ledger2();
|
|
128524
128679
|
init_publish_item_threads();
|
|
128680
|
+
init_re_review_absorb();
|
|
128525
128681
|
init_repair_review();
|
|
128526
128682
|
init_restated_minors();
|
|
128527
128683
|
init_run_log();
|
|
@@ -129003,6 +129159,16 @@ function rolesOf(result) {
|
|
|
129003
129159
|
].reduce((acc, next) => addRoleTokens(acc, next), {});
|
|
129004
129160
|
return Object.entries(total).map(([role, t]) => ({ role, ...t })).sort((a, b) => a.role.localeCompare(b.role));
|
|
129005
129161
|
}
|
|
129162
|
+
function mismatchesOf(result) {
|
|
129163
|
+
const counts = new Map;
|
|
129164
|
+
for (const story of Object.values(result.stories)) {
|
|
129165
|
+
if (!story.verdictMismatch)
|
|
129166
|
+
continue;
|
|
129167
|
+
const model = story.verdictMismatch.model ?? "unknown";
|
|
129168
|
+
counts.set(model, (counts.get(model) ?? 0) + 1);
|
|
129169
|
+
}
|
|
129170
|
+
return [...counts].map(([model, count]) => ({ model, count })).sort((a, b) => a.model.localeCompare(b.model));
|
|
129171
|
+
}
|
|
129006
129172
|
function minorsLeftOf2(rec) {
|
|
129007
129173
|
return rec.minors.filter((m) => m.triage === "leave").length + rec.newMinors.length;
|
|
129008
129174
|
}
|
|
@@ -129014,6 +129180,14 @@ function branchOf(rec) {
|
|
|
129014
129180
|
fixed: Math.max(0, found - left),
|
|
129015
129181
|
left,
|
|
129016
129182
|
minorsLeft: minorsLeftOf2(rec),
|
|
129183
|
+
...rec.minors.length ? {
|
|
129184
|
+
minors: {
|
|
129185
|
+
found: rec.minors.length,
|
|
129186
|
+
promoted: rec.minors.filter((m) => m.triage === "promote").length,
|
|
129187
|
+
fixNow: rec.minors.filter((m) => m.triage === "fix-now").length,
|
|
129188
|
+
left: rec.minors.filter((m) => m.triage === "leave").length
|
|
129189
|
+
}
|
|
129190
|
+
} : {},
|
|
129017
129191
|
...rec.fixRounds ? { fixRounds: rec.fixRounds } : {}
|
|
129018
129192
|
};
|
|
129019
129193
|
}
|
|
@@ -129046,14 +129220,19 @@ function buildWorkflowRunSummary(result, timing, feature) {
|
|
|
129046
129220
|
const flagged = flaggedOf(rec, feature);
|
|
129047
129221
|
const ciRemaining = ciRemainingOf(rec);
|
|
129048
129222
|
const itemIndexMissing = itemIndexMissingOf(rec, feature);
|
|
129223
|
+
const verdictMismatches = mismatchesOf(result);
|
|
129224
|
+
const reviewOverlapMs = Object.values(result.stories).reduce((total, story) => total + (story.reviewOverlapMs ?? 0), 0);
|
|
129049
129225
|
return {
|
|
129226
|
+
...reviewOverlapMs ? { reviewOverlapMs } : {},
|
|
129227
|
+
...verdictMismatches.length ? { verdictMismatches } : {},
|
|
129050
129228
|
...timing,
|
|
129051
129229
|
roles: rolesOf(result),
|
|
129052
129230
|
stories: Object.values(result.stories).map((s) => ({
|
|
129053
129231
|
id: s.storyId,
|
|
129054
129232
|
rounds: s.round,
|
|
129055
129233
|
maxRounds: s.maxRounds,
|
|
129056
|
-
...s.state ? { state: s.state } : {}
|
|
129234
|
+
...s.state ? { state: s.state } : {},
|
|
129235
|
+
...s.gateTimeouts ? { gateTimeouts: s.gateTimeouts } : {}
|
|
129057
129236
|
})),
|
|
129058
129237
|
...rec?.reviewRan ? { branch: branchOf(rec) } : {},
|
|
129059
129238
|
...rec && !rec.reviewRan ? { branchReviewSkipped: { minorsLeft: minorsLeftOf2(rec) } } : {},
|
|
@@ -129204,10 +129383,13 @@ function combine(entries) {
|
|
|
129204
129383
|
const states = {};
|
|
129205
129384
|
for (const [name, g] of entries)
|
|
129206
129385
|
states[name] = g.state;
|
|
129386
|
+
const timedOut = entries.filter(([, g]) => g.timedOut).map(([name]) => name);
|
|
129207
129387
|
return {
|
|
129388
|
+
...timedOut.length > 0 ? { timedOut } : {},
|
|
129208
129389
|
red: entries.some(([, g]) => g.state === "red"),
|
|
129209
129390
|
states,
|
|
129210
|
-
findings: entries.flatMap(([, g]) => g.findings)
|
|
129391
|
+
findings: entries.flatMap(([, g]) => g.findings),
|
|
129392
|
+
...entries.some(([, g]) => g.suiteCovered) ? { suiteCovered: true } : {}
|
|
129211
129393
|
};
|
|
129212
129394
|
}
|
|
129213
129395
|
async function timedGate(sc, name, run) {
|
|
@@ -129243,11 +129425,17 @@ async function runStoryGates(sc) {
|
|
|
129243
129425
|
sessionScratchDir: sc.sessionScratchDir
|
|
129244
129426
|
});
|
|
129245
129427
|
if (out.status === "passed") {
|
|
129246
|
-
return {
|
|
129428
|
+
return {
|
|
129429
|
+
state: "green",
|
|
129430
|
+
findings: [],
|
|
129431
|
+
...out.coversFullSuite ? { suiteCovered: true } : {},
|
|
129432
|
+
...out.passCount > 0 ? { note: `(${out.passCount} tests)` } : {}
|
|
129433
|
+
};
|
|
129247
129434
|
}
|
|
129248
129435
|
if (out.status === "skipped")
|
|
129249
129436
|
return { state: "skipped", findings: [] };
|
|
129250
|
-
|
|
129437
|
+
const result = out.findings.length > 0 ? { state: "red", findings: toDrafts("scoped", out.findings) } : redWithoutDetail("scoped", `scoped gate ${out.status} with no parsed findings`);
|
|
129438
|
+
return out.status === "timeout" ? { ...result, timedOut: true } : result;
|
|
129251
129439
|
});
|
|
129252
129440
|
return finish2(sc, [lint, typecheck, scoped]);
|
|
129253
129441
|
}
|
|
@@ -129264,10 +129452,11 @@ async function runWorkflowSuiteGate(sc) {
|
|
|
129264
129452
|
if (SUITE_SKIPPED.has(out.status))
|
|
129265
129453
|
return { state: "skipped", findings: [] };
|
|
129266
129454
|
if (out.status === "passed-on-timeout")
|
|
129267
|
-
return redWithoutDetail("full-suite", SUITE_TIMED_OUT_ISSUE);
|
|
129455
|
+
return { ...redWithoutDetail("full-suite", SUITE_TIMED_OUT_ISSUE), timedOut: true };
|
|
129268
129456
|
if (!SUITE_RED.has(out.status))
|
|
129269
129457
|
return { state: "green", findings: [] };
|
|
129270
|
-
|
|
129458
|
+
const result = out.findings.length > 0 ? { state: "red", findings: toDrafts("full-suite", out.findings) } : redWithoutDetail("full-suite", `full suite ${out.status} with no parsed failures`);
|
|
129459
|
+
return out.status === "timeout" ? { ...result, timedOut: true } : result;
|
|
129271
129460
|
});
|
|
129272
129461
|
return finish2(sc, [suite]);
|
|
129273
129462
|
}
|
|
@@ -129515,7 +129704,8 @@ function deriveEndState(input) {
|
|
|
129515
129704
|
return { state: "complete-gate-open", reason: "cost-limit" };
|
|
129516
129705
|
const red = [...redGates(input.gates), ...redGates(input.suite)];
|
|
129517
129706
|
if (red.length > 0 || input.gates?.red || input.suite?.red) {
|
|
129518
|
-
|
|
129707
|
+
const timeout = red.length > 0 && red.every((gate) => input.timedOut?.includes(gate));
|
|
129708
|
+
return { state: "complete-gate-open", reason: `${timeout ? "gate timeout" : "red"}: ${red.join(", ") || "gate"}` };
|
|
129519
129709
|
}
|
|
129520
129710
|
if (input.rulings > 0)
|
|
129521
129711
|
return { state: "complete-with-rulings", reason: `${input.rulings} ruling(s)` };
|
|
@@ -129664,6 +129854,108 @@ var init_report_check = __esm(() => {
|
|
|
129664
129854
|
init_ledger2();
|
|
129665
129855
|
});
|
|
129666
129856
|
|
|
129857
|
+
// src/workflow/suite-review-pass.ts
|
|
129858
|
+
async function runSuiteReviewPass(suite, review, now) {
|
|
129859
|
+
const start = now();
|
|
129860
|
+
let suiteEnd = start;
|
|
129861
|
+
let reviewEnd = start;
|
|
129862
|
+
const suiteTask = Promise.resolve().then(suite).finally(() => {
|
|
129863
|
+
suiteEnd = now();
|
|
129864
|
+
});
|
|
129865
|
+
let marked = false;
|
|
129866
|
+
const markReview = () => {
|
|
129867
|
+
if (!marked) {
|
|
129868
|
+
marked = true;
|
|
129869
|
+
reviewEnd = now();
|
|
129870
|
+
}
|
|
129871
|
+
};
|
|
129872
|
+
const reviewTask = Promise.resolve().then(() => review(markReview)).finally(markReview);
|
|
129873
|
+
const [suiteResult, reviewResult] = await Promise.allSettled([suiteTask, reviewTask]);
|
|
129874
|
+
if (suiteResult.status === "rejected")
|
|
129875
|
+
throw suiteResult.reason;
|
|
129876
|
+
if (reviewResult.status === "rejected")
|
|
129877
|
+
throw reviewResult.reason;
|
|
129878
|
+
return { suite: suiteResult.value, overlap: Math.max(0, Math.min(suiteEnd, reviewEnd) - start) };
|
|
129879
|
+
}
|
|
129880
|
+
|
|
129881
|
+
// src/workflow/timeout-stop.ts
|
|
129882
|
+
function timeoutGates(gates, suite) {
|
|
129883
|
+
return [...new Set([...gates?.timedOut ?? [], ...suite?.timedOut ?? []])];
|
|
129884
|
+
}
|
|
129885
|
+
function gateTimeoutRoute(input) {
|
|
129886
|
+
const gates = [...new Set([...input.current?.timedOut ?? [], ...input.currentSuite?.timedOut ?? []])];
|
|
129887
|
+
if (gates.length === 0)
|
|
129888
|
+
return null;
|
|
129889
|
+
if (input.baselineTimedOut)
|
|
129890
|
+
return { gates, why: "baseline" };
|
|
129891
|
+
const previous = [...input.previous?.timedOut ?? [], ...input.previousSuite?.timedOut ?? []];
|
|
129892
|
+
return gates.some((gate) => previous.includes(gate)) ? { gates, why: "repeated" } : null;
|
|
129893
|
+
}
|
|
129894
|
+
async function readTimeoutFacts(env) {
|
|
129895
|
+
try {
|
|
129896
|
+
return await env.steps.timeoutFacts?.() ?? { baselineTimedOut: false };
|
|
129897
|
+
} catch (err) {
|
|
129898
|
+
getLogger2().warn("workflow", "Timeout facts could not be read", { storyId: env.storyId, error: errorMessage(err) });
|
|
129899
|
+
return { baselineTimedOut: false };
|
|
129900
|
+
}
|
|
129901
|
+
}
|
|
129902
|
+
async function stopOnTimeout(env, input, asked, round) {
|
|
129903
|
+
if (!(input.current?.timedOut?.length || input.currentSuite?.timedOut?.length))
|
|
129904
|
+
return "none";
|
|
129905
|
+
const facts = await readTimeoutFacts(env);
|
|
129906
|
+
const route = gateTimeoutRoute({ ...input, baselineTimedOut: facts.baselineTimedOut });
|
|
129907
|
+
if (!route)
|
|
129908
|
+
return "none";
|
|
129909
|
+
if (asked)
|
|
129910
|
+
return "capped";
|
|
129911
|
+
const previous = [...input.previous?.timedOut ?? [], ...input.previousSuite?.timedOut ?? []];
|
|
129912
|
+
const timing = { ...facts, gates: route.gates, repeated: route.gates.some((gate) => previous.includes(gate)) };
|
|
129913
|
+
const config = route.gates.includes("scoped") && !route.gates.includes("full-suite") ? await configFactsFor(env, ["scoped"]) : undefined;
|
|
129914
|
+
await env.sink.ledger(ledgerText.note(`gate timeout on ${route.gates.join(", ")} (${route.why}): no fix round, asked the advisor`));
|
|
129915
|
+
let answer;
|
|
129916
|
+
try {
|
|
129917
|
+
answer = await env.advisor.answerQuestion({
|
|
129918
|
+
storyId: env.storyId,
|
|
129919
|
+
status: "GATE_TIMEOUT",
|
|
129920
|
+
concerns: "A gate timed out.",
|
|
129921
|
+
timing,
|
|
129922
|
+
...config === undefined ? {} : { facts: config }
|
|
129923
|
+
});
|
|
129924
|
+
} catch (err) {
|
|
129925
|
+
getLogger2().warn("workflow", "Gate timeout advisor failed", { storyId: env.storyId, error: errorMessage(err) });
|
|
129926
|
+
return "capped";
|
|
129927
|
+
}
|
|
129928
|
+
if (typeof answer === "string")
|
|
129929
|
+
await env.sink.ledger(ledgerText.note(`gate timeout advice: ${answer}`));
|
|
129930
|
+
const result = await absorbConfigChange({ env, round, answer });
|
|
129931
|
+
return result.kind === "applied" ? "applied" : "capped";
|
|
129932
|
+
}
|
|
129933
|
+
var init_timeout_stop = __esm(() => {
|
|
129934
|
+
init_internal();
|
|
129935
|
+
init_logger2();
|
|
129936
|
+
init_config_change_absorb();
|
|
129937
|
+
init_ledger2();
|
|
129938
|
+
});
|
|
129939
|
+
|
|
129940
|
+
// src/workflow/verdict-mismatch.ts
|
|
129941
|
+
async function recordVerdictMismatch(env, verdict) {
|
|
129942
|
+
const kinds = verdict.mismatch;
|
|
129943
|
+
if (!kinds?.length)
|
|
129944
|
+
return;
|
|
129945
|
+
for (const kind of new Set(kinds))
|
|
129946
|
+
await env.sink.ledger(ledgerText.note(NOTES[kind]));
|
|
129947
|
+
const model = env.steps.modelFor?.("story-review")?.model;
|
|
129948
|
+
await env.sink.update({ verdictMismatch: { kinds, ...model === undefined ? {} : { model } } });
|
|
129949
|
+
}
|
|
129950
|
+
var NOTES;
|
|
129951
|
+
var init_verdict_mismatch = __esm(() => {
|
|
129952
|
+
init_ledger2();
|
|
129953
|
+
NOTES = {
|
|
129954
|
+
spec: "story review verdict inconsistent: spec fail without a blocking spec finding; findings kept",
|
|
129955
|
+
quality: "story review verdict inconsistent: quality changes without a blocking finding; findings kept"
|
|
129956
|
+
};
|
|
129957
|
+
});
|
|
129958
|
+
|
|
129667
129959
|
// src/workflow/story-steps.ts
|
|
129668
129960
|
class LoopState {
|
|
129669
129961
|
round;
|
|
@@ -129722,6 +130014,7 @@ function initialStoryState(env) {
|
|
|
129722
130014
|
concerns: [],
|
|
129723
130015
|
questions: 0,
|
|
129724
130016
|
suiteThisIteration: false,
|
|
130017
|
+
timeoutAsked: false,
|
|
129725
130018
|
costLimited: false,
|
|
129726
130019
|
firstAfterResume: resume !== null,
|
|
129727
130020
|
open: [],
|
|
@@ -129828,13 +130121,14 @@ function carriesNarrower(open, verdict) {
|
|
|
129828
130121
|
const narrow = new Set(verdict.verdicts.filter((v) => v.narrower === true).map((v) => v.id));
|
|
129829
130122
|
return open.some((f) => narrow.has(f.id));
|
|
129830
130123
|
}
|
|
129831
|
-
async function review(env, s) {
|
|
130124
|
+
async function review(env, s, settled) {
|
|
130125
|
+
const suiteRunning = settled !== undefined;
|
|
129832
130126
|
if (!s.reviewed) {
|
|
129833
130127
|
const step = startStep(env.storyId, "story-review", { model: env.steps.modelFor?.("story-review") });
|
|
129834
|
-
const
|
|
129835
|
-
|
|
129836
|
-
|
|
129837
|
-
});
|
|
130128
|
+
const gates = { ...s.gates?.states, ...suiteRunning ? {} : s.suite?.states };
|
|
130129
|
+
if (suiteRunning)
|
|
130130
|
+
delete gates["full-suite"];
|
|
130131
|
+
const out = suiteRunning ? await env.steps.storyReview(s.concerns, gates, { suiteRunning: true }).finally(settled) : await env.steps.storyReview(s.concerns, { ...gates, ...s.suite?.states });
|
|
129838
130132
|
s.reviewed = true;
|
|
129839
130133
|
if (!out.ran) {
|
|
129840
130134
|
step.done(`skipped (${out.why})`);
|
|
@@ -129842,6 +130136,7 @@ async function review(env, s) {
|
|
|
129842
130136
|
await env.sink.ledger(ledgerText.reviewSkipped(`story review: ${out.why}`), NO_MIRROR2);
|
|
129843
130137
|
return;
|
|
129844
130138
|
}
|
|
130139
|
+
await recordVerdictMismatch(env, out.verdict);
|
|
129845
130140
|
await ledgerCannotVerify(env.sink, out.verdict.cannotVerify);
|
|
129846
130141
|
await deferMinors(env, s, out.verdict.findings);
|
|
129847
130142
|
s.reviewOpen = s.assign(out.verdict.findings.filter(isBlocking2));
|
|
@@ -129874,17 +130169,6 @@ async function review(env, s) {
|
|
|
129874
130169
|
s.advisorRoute = true;
|
|
129875
130170
|
step.done(reReviewSummary(asked, out.verdict, added));
|
|
129876
130171
|
}
|
|
129877
|
-
function reReviewStatus(v) {
|
|
129878
|
-
if (!v)
|
|
129879
|
-
return "no verdict";
|
|
129880
|
-
if (v.residual)
|
|
129881
|
-
return "PARTIAL";
|
|
129882
|
-
return v.addressed ? "addressed" : "NOT addressed";
|
|
129883
|
-
}
|
|
129884
|
-
function reReviewSummary(asked, verdict, added) {
|
|
129885
|
-
const per = asked.map((f) => `${f.id} ${reReviewStatus(verdict.verdicts.find((x) => x.id === f.id))}`);
|
|
129886
|
-
return added.length > 0 ? `${per.join(", ")}; new: ${describeFindings(added)}` : per.join(", ");
|
|
129887
|
-
}
|
|
129888
130172
|
async function deferMinors(env, s, drafts) {
|
|
129889
130173
|
for (const minor of drafts.filter((f) => !isBlocking2(f))) {
|
|
129890
130174
|
s.deferredMinors += 1;
|
|
@@ -129898,8 +130182,22 @@ async function evaluate(env, s) {
|
|
|
129898
130182
|
await env.sink.update({ gates: { ...s.gates.states } });
|
|
129899
130183
|
if (s.gates.red)
|
|
129900
130184
|
return [...s.assign(s.gates.findings), ...s.reviewOpen];
|
|
130185
|
+
if (env.parallelReview && env.resume === null && !s.reviewed && !s.gates.suiteCovered) {
|
|
130186
|
+
s.reportTurnRan = await runReportCheck(env, s, (turn) => implementTurn(env, turn));
|
|
130187
|
+
await env.sink.update({ phase: "suite" });
|
|
130188
|
+
const result = await runSuiteReviewPass(() => env.steps.fullSuite(), (settled) => review(env, s, settled), env.now ?? Date.now);
|
|
130189
|
+
s.suite = result.suite;
|
|
130190
|
+
s.suiteThisIteration = true;
|
|
130191
|
+
await env.sink.update({ reviewOverlapMs: result.overlap });
|
|
130192
|
+
return [...s.suite.red ? s.assign(s.suite.findings) : [], ...s.reviewOpen];
|
|
130193
|
+
}
|
|
129901
130194
|
await env.sink.update({ phase: "suite" });
|
|
129902
|
-
s.
|
|
130195
|
+
if (s.gates.suiteCovered) {
|
|
130196
|
+
s.suite = { red: false, states: { "full-suite": "green" }, findings: [] };
|
|
130197
|
+
await env.sink.ledger(ledgerText.note("full-suite green (scoped gate ran the full-suite command; reused)"));
|
|
130198
|
+
} else {
|
|
130199
|
+
s.suite = await env.steps.fullSuite();
|
|
130200
|
+
}
|
|
129903
130201
|
s.suiteThisIteration = true;
|
|
129904
130202
|
const suiteFindings = s.suite.red ? s.assign(s.suite.findings) : [];
|
|
129905
130203
|
if (s.suite.red && s.round < env.maxFixRounds)
|
|
@@ -129910,13 +130208,15 @@ async function evaluate(env, s) {
|
|
|
129910
130208
|
return [...suiteFindings, ...s.reviewOpen];
|
|
129911
130209
|
}
|
|
129912
130210
|
function redGateNames(s) {
|
|
129913
|
-
const states = { ...s.gates?.states ?? {}, ...s.suite?.states ?? {} };
|
|
130211
|
+
const states = { ...s.gates?.states ?? {}, ...s.suiteThisIteration ? s.suite?.states ?? {} : {} };
|
|
129914
130212
|
return Object.entries(states).filter(([, v]) => v === "red").map(([g]) => g);
|
|
129915
130213
|
}
|
|
129916
130214
|
async function closeLoop(env, s, { state, reason, rulings, unreviewed }) {
|
|
130215
|
+
const gateTimeouts = timeoutGates(s.gates, s.suiteThisIteration ? s.suite : undefined);
|
|
129917
130216
|
await env.sink.update({
|
|
129918
130217
|
state,
|
|
129919
130218
|
reason,
|
|
130219
|
+
...gateTimeouts.length ? { gateTimeouts } : {},
|
|
129920
130220
|
unreviewed,
|
|
129921
130221
|
phase: "closed",
|
|
129922
130222
|
rulings: rulings.length,
|
|
@@ -129959,10 +130259,30 @@ function passExit(open, s, maxFixRounds) {
|
|
|
129959
130259
|
}
|
|
129960
130260
|
async function evaluateStep(env, state) {
|
|
129961
130261
|
const s = new LoopState(state);
|
|
129962
|
-
|
|
129963
|
-
|
|
130262
|
+
let previous = state.gates;
|
|
130263
|
+
let previousSuite = state.suiteThisIteration ? state.suite : undefined;
|
|
130264
|
+
let asked = state.timeoutAsked;
|
|
130265
|
+
let open;
|
|
130266
|
+
let timeout;
|
|
130267
|
+
do {
|
|
130268
|
+
open = [...await evaluate(env, s), ...s.pendingSession];
|
|
130269
|
+
timeout = await stopOnTimeout(env, {
|
|
130270
|
+
previous,
|
|
130271
|
+
previousSuite,
|
|
130272
|
+
current: s.gates,
|
|
130273
|
+
currentSuite: s.suiteThisIteration ? s.suite : undefined
|
|
130274
|
+
}, asked, s.round);
|
|
130275
|
+
if (timeout !== "none")
|
|
130276
|
+
asked = true;
|
|
130277
|
+
if (timeout === "applied") {
|
|
130278
|
+
previous = s.gates;
|
|
130279
|
+
previousSuite = s.suiteThisIteration ? s.suite : undefined;
|
|
130280
|
+
}
|
|
130281
|
+
} while (timeout === "applied");
|
|
129964
130282
|
s.pendingSession = [];
|
|
129965
|
-
|
|
130283
|
+
if (timeout === "capped")
|
|
130284
|
+
s.advisorRoute = true;
|
|
130285
|
+
const blocked = timeout === "none" && await stopOnUnchangedBlock(env, {
|
|
129966
130286
|
round: s.round,
|
|
129967
130287
|
lastTurn: state.lastTurn,
|
|
129968
130288
|
previous,
|
|
@@ -129982,6 +130302,7 @@ async function evaluateStep(env, state) {
|
|
|
129982
130302
|
return {
|
|
129983
130303
|
patch: {
|
|
129984
130304
|
suiteThisIteration: s.suiteThisIteration,
|
|
130305
|
+
timeoutAsked: asked,
|
|
129985
130306
|
gates: s.gates,
|
|
129986
130307
|
suite: s.suite,
|
|
129987
130308
|
nextId: s.nextId,
|
|
@@ -129994,17 +130315,19 @@ async function evaluateStep(env, state) {
|
|
|
129994
130315
|
pendingSession: s.pendingSession,
|
|
129995
130316
|
reportTurnRan: s.reportTurnRan
|
|
129996
130317
|
},
|
|
129997
|
-
exit: passExit(open, s, env.maxFixRounds)
|
|
130318
|
+
exit: timeout === "capped" ? "capped" : passExit(open, s, env.maxFixRounds)
|
|
129998
130319
|
};
|
|
129999
130320
|
}
|
|
130000
130321
|
async function residualStep(env, state) {
|
|
130001
130322
|
const s = new LoopState(state);
|
|
130002
130323
|
await env.sink.update({ phase: "residual" });
|
|
130003
|
-
if (!s.gates?.red && !s.suiteThisIteration)
|
|
130324
|
+
if (!s.gates?.red && !s.suiteThisIteration) {
|
|
130004
130325
|
s.suite = await env.steps.fullSuite();
|
|
130326
|
+
s.suiteThisIteration = true;
|
|
130327
|
+
}
|
|
130005
130328
|
const items = state.open.filter((f) => f.kind !== "gate");
|
|
130006
130329
|
const rulings = await adjudicateResidual(env.advisor, { storyId: env.storyId, items, redGates: redGateNames(s) }, env.sink.ledger, env.aborted);
|
|
130007
|
-
return { patch: { suite: s.suite, rulings } };
|
|
130330
|
+
return { patch: { suite: s.suite, suiteThisIteration: s.suiteThisIteration, rulings } };
|
|
130008
130331
|
}
|
|
130009
130332
|
async function fixStep2(env, state) {
|
|
130010
130333
|
const s = new LoopState(state);
|
|
@@ -130040,7 +130363,13 @@ async function fixStep2(env, state) {
|
|
|
130040
130363
|
}
|
|
130041
130364
|
async function closeStep(env, state) {
|
|
130042
130365
|
const s = new LoopState(state);
|
|
130043
|
-
const end = state.closeAs ?? deriveEndState({
|
|
130366
|
+
const end = state.closeAs ?? deriveEndState({
|
|
130367
|
+
costStop: s.costStop,
|
|
130368
|
+
gates: s.gates,
|
|
130369
|
+
suite: s.suiteThisIteration ? s.suite : undefined,
|
|
130370
|
+
timedOut: timeoutGates(s.gates, s.suiteThisIteration ? s.suite : undefined),
|
|
130371
|
+
rulings: state.rulings.length
|
|
130372
|
+
});
|
|
130044
130373
|
const unreviewed = s.unreviewed || !s.reviewed;
|
|
130045
130374
|
const outcome = await closeLoop(env, s, { ...end, rulings: state.rulings, unreviewed });
|
|
130046
130375
|
return { patch: { outcome } };
|
|
@@ -130069,8 +130398,11 @@ var init_story_steps = __esm(() => {
|
|
|
130069
130398
|
init_interrupt_continue();
|
|
130070
130399
|
init_ledger2();
|
|
130071
130400
|
init_no_work();
|
|
130401
|
+
init_re_review_absorb();
|
|
130072
130402
|
init_report_check();
|
|
130073
130403
|
init_run_log();
|
|
130404
|
+
init_timeout_stop();
|
|
130405
|
+
init_verdict_mismatch();
|
|
130074
130406
|
NO_MIRROR2 = { mirror: false };
|
|
130075
130407
|
});
|
|
130076
130408
|
|
|
@@ -130099,6 +130431,7 @@ var init_story_graph = __esm(() => {
|
|
|
130099
130431
|
kind: "agent",
|
|
130100
130432
|
produces: [
|
|
130101
130433
|
"suiteThisIteration",
|
|
130434
|
+
"timeoutAsked",
|
|
130102
130435
|
"gates",
|
|
130103
130436
|
"suite",
|
|
130104
130437
|
"nextId",
|
|
@@ -130121,7 +130454,7 @@ var init_story_graph = __esm(() => {
|
|
|
130121
130454
|
},
|
|
130122
130455
|
residual: {
|
|
130123
130456
|
kind: "agent",
|
|
130124
|
-
produces: ["suite", "rulings"],
|
|
130457
|
+
produces: ["suite", "suiteThisIteration", "rulings"],
|
|
130125
130458
|
transitions: [{ to: "close" }],
|
|
130126
130459
|
run: residualStep
|
|
130127
130460
|
},
|
|
@@ -130254,9 +130587,16 @@ async function buildStoryEnv(ctx, callCtx) {
|
|
|
130254
130587
|
implement: timed("implement", addTiming, (turn) => toolErrors(turnLabel(turn), () => runImplementerTurn(current, turn))),
|
|
130255
130588
|
gates: timed("gates", addTiming, () => runStoryGates(current)),
|
|
130256
130589
|
fullSuite: timed("full-suite", addTiming, () => runWorkflowSuiteGate(current)),
|
|
130257
|
-
|
|
130590
|
+
timeoutFacts: async () => {
|
|
130591
|
+
const baseline = await _timeoutFactsDeps.readRunBaseline(current.projectDir, current.feature);
|
|
130592
|
+
return {
|
|
130593
|
+
baselineTimedOut: baseline?.kind === "no-baseline" && baseline.reason === "timeout",
|
|
130594
|
+
limitSeconds: _timeoutFactsDeps.resolveFullSuiteTimeoutSeconds(current.config)
|
|
130595
|
+
};
|
|
130596
|
+
},
|
|
130597
|
+
storyReview: timed("story-review", addTiming, (concerns, gates, options) => toolErrors("story-review", async () => {
|
|
130258
130598
|
await refreshBrief(current);
|
|
130259
|
-
return runStoryReview(current, concerns, gates);
|
|
130599
|
+
return runStoryReview(current, concerns, gates, options);
|
|
130260
130600
|
})),
|
|
130261
130601
|
reReview: timed("re-review", addTiming, (round, findings, fixBase) => toolErrors(`re-review r${round}`, async () => {
|
|
130262
130602
|
await refreshBrief(current);
|
|
@@ -130279,6 +130619,7 @@ async function buildStoryEnv(ctx, callCtx) {
|
|
|
130279
130619
|
const env = {
|
|
130280
130620
|
storyId: ctx.story.id,
|
|
130281
130621
|
maxFixRounds: workflow.maxFixRounds,
|
|
130622
|
+
parallelReview: (workflow.review ?? WORKFLOW_REVIEW_DEFAULTS).parallelWithSuite === true,
|
|
130282
130623
|
steps,
|
|
130283
130624
|
advisor: createLiveWorkflowAdvisor({
|
|
130284
130625
|
advisor: _workflowDeps.createAdvisor({
|
|
@@ -130395,13 +130736,16 @@ async function carryOverArtifacts(priorStoryDir, storyDir, storyId) {
|
|
|
130395
130736
|
}
|
|
130396
130737
|
}
|
|
130397
130738
|
}
|
|
130739
|
+
var _timeoutFactsDeps;
|
|
130398
130740
|
var init_stage_env = __esm(() => {
|
|
130399
130741
|
init_internal();
|
|
130400
130742
|
init_config();
|
|
130401
130743
|
init_execution();
|
|
130402
130744
|
init_logger2();
|
|
130745
|
+
init_quality();
|
|
130403
130746
|
init_test_runners();
|
|
130404
130747
|
init_paths6();
|
|
130748
|
+
init_verification();
|
|
130405
130749
|
init_nax_protected_paths();
|
|
130406
130750
|
init_advisor_live();
|
|
130407
130751
|
init_brief();
|
|
@@ -130421,6 +130765,7 @@ var init_stage_env = __esm(() => {
|
|
|
130421
130765
|
init_story_review();
|
|
130422
130766
|
init_tokens();
|
|
130423
130767
|
init_tool_error_outcome();
|
|
130768
|
+
_timeoutFactsDeps = { readRunBaseline, resolveFullSuiteTimeoutSeconds };
|
|
130424
130769
|
});
|
|
130425
130770
|
|
|
130426
130771
|
// src/workflow/stage.ts
|
|
@@ -171161,7 +171506,8 @@ var init_config_descriptions = __esm(() => {
|
|
|
171161
171506
|
"workflow.timeouts.reviewMs": "Timeout for each review phase in milliseconds (default 1800000)",
|
|
171162
171507
|
"workflow.timeouts.ciWaitMs": "Max time to wait for CI in milliseconds (default 1200000)",
|
|
171163
171508
|
"workflow.timeouts.ciPollMs": "Interval between CI status polls in milliseconds (default 30000)",
|
|
171164
|
-
"workflow.review": "
|
|
171509
|
+
"workflow.review": "Review settings: coverageRetries and parallelWithSuite",
|
|
171510
|
+
"workflow.review.parallelWithSuite": "Run story review beside the full suite (default false); use only when suite outputs are gitignored, because the reviewer tree guard can remove non-ignored files changed during review.",
|
|
171165
171511
|
"workflow.review.coverageRetries": "Coverage re-prompts the branch review gets when its reply leaves a required file unread (default 3); this budget is separate from the JSON-shape retry and stops early once a retry covers no more files. 0 disables it",
|
|
171166
171512
|
"workflow.itemPublish": "Pacing of the post-publish item-thread writes, so a publish of many threads stays under the forge's secondary rate limits",
|
|
171167
171513
|
"workflow.itemPublish.writeGapMs": "Milliseconds to wait before every item-thread write except the first of the publish (default 1000, minimum 0); the gap of the first write is not paid",
|
|
@@ -175981,6 +176327,17 @@ function logAgentProfileAssignment(prd, args) {
|
|
|
175981
176327
|
unassigned
|
|
175982
176328
|
});
|
|
175983
176329
|
}
|
|
176330
|
+
function warnOnPrdSecretShapes(prd, scope) {
|
|
176331
|
+
const findings = _persistPrdDeps.findPrdSecretShapes(prd, scope);
|
|
176332
|
+
if (findings.length === 0)
|
|
176333
|
+
return;
|
|
176334
|
+
const kinds = [...new Set(findings.map((hit) => hit.kind))].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
176335
|
+
getLogger2().warn("plan", "PRD story text has secret shapes", {
|
|
176336
|
+
count: findings.length,
|
|
176337
|
+
fields: findings.map((hit) => `${hit.storyId} ${hit.field}`),
|
|
176338
|
+
kinds
|
|
176339
|
+
});
|
|
176340
|
+
}
|
|
175984
176341
|
async function finalizeAndWritePrd(args) {
|
|
175985
176342
|
const repaired = args.scope ? args.prd : applyPlanFidelity(args.prd, args.specContent, args.featureName);
|
|
175986
176343
|
const structured = args.scope === undefined ? enforceSpecStructure(repaired, args.specContent, args.outputPath) : repaired;
|
|
@@ -176012,9 +176369,7 @@ async function finalizeAndWritePrd(args) {
|
|
|
176012
176369
|
const finalized = finalizePrdRouting({ ...canonical, project: args.projectName }, args.agentRouting, args.profileName, args.models, args.defaultAgent, args.scope, args.preserveScopedAgents);
|
|
176013
176370
|
logAgentProfileAssignment(finalized, args);
|
|
176014
176371
|
try {
|
|
176015
|
-
|
|
176016
|
-
getLogger2().warn("plan", "PRD story text has a secret shape", { ...hit });
|
|
176017
|
-
}
|
|
176372
|
+
warnOnPrdSecretShapes(finalized, args.scope);
|
|
176018
176373
|
} catch {
|
|
176019
176374
|
getLogger2().warn("plan", "PRD secret-shape scan could not run");
|
|
176020
176375
|
}
|
|
@@ -177241,10 +177596,12 @@ async function runsShowCommand(options) {
|
|
|
177241
177596
|
status: completeEvent ? "completed" : "in-progress"
|
|
177242
177597
|
});
|
|
177243
177598
|
if (completeEvent) {
|
|
177599
|
+
const storiesGateOpen = completeEvent.data?.storiesGateOpen;
|
|
177244
177600
|
logger.info("cli", "Run Summary", {
|
|
177245
177601
|
totalStories: completeEvent.data?.totalStories,
|
|
177246
177602
|
storiesCompleted: completeEvent.data?.storiesCompleted,
|
|
177247
177603
|
storiesFailed: completeEvent.data?.storiesFailed,
|
|
177604
|
+
...typeof storiesGateOpen === "number" && storiesGateOpen > 0 ? { storiesGateOpen } : {},
|
|
177248
177605
|
totalCost: completeEvent.data?.totalCost,
|
|
177249
177606
|
totalDurationMs: completeEvent.data?.totalDurationMs
|
|
177250
177607
|
});
|
|
@@ -177854,6 +178211,7 @@ async function displayLastRunMetrics(workdir) {
|
|
|
177854
178211
|
return;
|
|
177855
178212
|
}
|
|
177856
178213
|
const { lastRun: reportedLastRun } = toCostReport(runs, { now: () => new Date().toISOString(), project });
|
|
178214
|
+
const storiesGateOpen = reportedLastRun?.storiesGateOpen ?? 0;
|
|
177857
178215
|
logger.info("cli", `Last Run: ${lastRun.feature}`, {
|
|
177858
178216
|
runId: lastRun.runId,
|
|
177859
178217
|
startedAt: lastRun.startedAt,
|
|
@@ -177862,6 +178220,7 @@ async function displayLastRunMetrics(workdir) {
|
|
|
177862
178220
|
totalStories: lastRun.totalStories,
|
|
177863
178221
|
storiesCompleted: lastRun.storiesCompleted,
|
|
177864
178222
|
storiesFailed: lastRun.storiesFailed,
|
|
178223
|
+
...storiesGateOpen > 0 ? { storiesGateOpen } : {},
|
|
177865
178224
|
totalCost: lastRun.totalCost,
|
|
177866
178225
|
...lastRun.errorCostUsd !== undefined ? { errorCostUsd: lastRun.errorCostUsd } : {},
|
|
177867
178226
|
avgCostPerStory: reportedLastRun?.avgCostPerStory ?? 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nax",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.3",
|
|
4
4
|
"description": "AI Coding Agent Orchestrator — loops until done",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@agentclientprotocol/sdk": "~1.7.0",
|
|
87
87
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
88
88
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
89
|
-
"@nathapp/nax-ai": "0.92.
|
|
89
|
+
"@nathapp/nax-ai": "0.92.3",
|
|
90
90
|
"chalk": "^5.6.2",
|
|
91
91
|
"commander": "^13.1.0",
|
|
92
92
|
"highlight.js": "^11.12.0",
|