@nathapp/nax 0.67.15 → 0.67.16

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.
Files changed (2) hide show
  1. package/dist/nax.js +121 -12
  2. package/package.json +1 -1
package/dist/nax.js CHANGED
@@ -52720,6 +52720,65 @@ var init_context2 = __esm(() => {
52720
52720
  });
52721
52721
 
52722
52722
  // src/execution/story-orchestrator.ts
52723
+ async function refreshReviewInputForDispatch(opName, input) {
52724
+ if (opName !== "semantic-review" && opName !== "adversarial-review")
52725
+ return input;
52726
+ const i = input;
52727
+ const { _refresh } = i;
52728
+ if (!_refresh || !i.workdir)
52729
+ return input;
52730
+ try {
52731
+ if (opName === "semantic-review") {
52732
+ const { _refresh: _, ...semInput } = input;
52733
+ const fresh2 = await _storyOrchestratorDeps.prepareSemanticReviewInput({
52734
+ workdir: semInput.workdir,
52735
+ projectDir: _refresh.projectDir,
52736
+ storyId: _refresh.storyId,
52737
+ storyGitRef: _refresh.storyGitRef,
52738
+ config: _refresh.config,
52739
+ naxIgnoreIndex: _refresh.naxIgnoreIndex,
52740
+ resolvedTestPatterns: _refresh.resolvedTestPatterns,
52741
+ semanticConfig: semInput.semanticConfig
52742
+ });
52743
+ return {
52744
+ ...semInput,
52745
+ stat: fresh2.stat,
52746
+ diff: fresh2.diff,
52747
+ excludePatterns: fresh2.excludePatterns,
52748
+ storyGitRef: fresh2.effectiveRef ?? semInput.storyGitRef
52749
+ };
52750
+ }
52751
+ const { _refresh: __, ...advInput } = input;
52752
+ const fresh = await _storyOrchestratorDeps.prepareAdversarialReviewInput({
52753
+ workdir: advInput.workdir,
52754
+ projectDir: _refresh.projectDir,
52755
+ storyId: _refresh.storyId,
52756
+ storyGitRef: _refresh.storyGitRef,
52757
+ config: _refresh.config,
52758
+ naxIgnoreIndex: _refresh.naxIgnoreIndex,
52759
+ resolvedTestPatterns: _refresh.resolvedTestPatterns,
52760
+ adversarialConfig: advInput.adversarialConfig
52761
+ });
52762
+ return {
52763
+ ...advInput,
52764
+ stat: fresh.stat,
52765
+ diff: fresh.diff,
52766
+ testInventory: fresh.testInventory,
52767
+ excludePatterns: fresh.excludePatterns,
52768
+ testGlobs: fresh.testGlobs,
52769
+ refExcludePatterns: fresh.refExcludePatterns,
52770
+ storyGitRef: fresh.effectiveRef ?? advInput.storyGitRef
52771
+ };
52772
+ } catch (err) {
52773
+ getSafeLogger()?.warn("story-orchestrator", "review input refresh failed \u2014 dispatching with stale input", {
52774
+ storyId: _refresh.storyId,
52775
+ phase: opName,
52776
+ error: errorMessage(err)
52777
+ });
52778
+ const { _refresh: _stripped, ...fallback } = input;
52779
+ return fallback;
52780
+ }
52781
+ }
52723
52782
  function formatPhaseResultMessage(opName, success2) {
52724
52783
  if (opName === "greenfield-gate") {
52725
52784
  return success2 ? "Greenfield-gate: pre-existing tests detected (not greenfield) \u2014 proceeding with normal TDD" : "Greenfield-gate: no pre-existing tests \u2014 greenfield run, pausing TDD test-writer";
@@ -52995,7 +53054,8 @@ async function runPhase(ctx, slot, phaseCosts, phaseOutputs, isThreeSession = fa
52995
53054
  const opName = slot.op.name;
52996
53055
  const isTddPhase = isThreeSession && TDD_OP_NAMES.has(opName);
52997
53056
  const beforeRef = isTddPhase ? await _storyOrchestratorDeps.captureGitRef(ctx.packageDir) : undefined;
52998
- const dispatchInput = isTddPhase && beforeRef ? { ...slot.input, beforeRef } : slot.input;
53057
+ let dispatchInput = isTddPhase && beforeRef ? { ...slot.input, beforeRef } : slot.input;
53058
+ dispatchInput = await refreshReviewInputForDispatch(opName, dispatchInput);
52999
53059
  if (isTddPhase) {
53000
53060
  logger?.info("tdd", `-> Session: ${opName}`, { storyId: ctx.storyId, role: opName });
53001
53061
  } else if (isThreeSession && opName === "full-suite-gate") {
@@ -53106,7 +53166,15 @@ async function runRectification(ctx, state, phaseCosts, phaseOutputs) {
53106
53166
  await runPhase(ctx, phase.slot, phaseCosts, phaseOutputs);
53107
53167
  if (shouldSkipPhaseForRectification(phase, state, phaseOutputs))
53108
53168
  continue;
53109
- findings.push(...extractPhaseFindings(phaseOutputs[phase.slot.op.name]));
53169
+ const output = phaseOutputs[phase.slot.op.name];
53170
+ findings.push(...extractPhaseFindings(output));
53171
+ if (!phasePassed(phase.slot.op.name, output, ctx.storyId)) {
53172
+ getSafeLogger()?.warn("story-orchestrator", "Short-circuiting revalidation on phase failure", {
53173
+ storyId: ctx.storyId,
53174
+ phase: phase.slot.op.name
53175
+ });
53176
+ break;
53177
+ }
53110
53178
  }
53111
53179
  return rectification.postValidate ? await rectification.postValidate(findings, _validateCtx) : findings;
53112
53180
  }
@@ -53191,6 +53259,32 @@ class ExecutionPlan {
53191
53259
  }
53192
53260
  }
53193
53261
  const rectResult = await runRectification(this.ctx, this.state, phaseCosts, phaseOutputs);
53262
+ if (this.state.rectification && !rectResult.rectificationExhausted) {
53263
+ for (const phase of collectOrderedPhases(this.state)) {
53264
+ const name = phase.slot.op.name;
53265
+ if (name in phaseOutputs && phasePassed(name, phaseOutputs[name], this.ctx.storyId)) {
53266
+ continue;
53267
+ }
53268
+ try {
53269
+ await runPhase(this.ctx, phase.slot, phaseCosts, phaseOutputs, this.isThreeSession);
53270
+ } catch (error48) {
53271
+ logger?.error("story-orchestrator", "Phase threw unexpected error (post-rectification resume)", {
53272
+ storyId: this.ctx.storyId,
53273
+ phase: name,
53274
+ error: errorMessage(error48)
53275
+ });
53276
+ throw error48;
53277
+ }
53278
+ if (!phasePassed(name, phaseOutputs[name], this.ctx.storyId)) {
53279
+ logger?.warn("story-orchestrator", "Terminal phase failure (post-rectification resume \u2014 bypasses rectification)", {
53280
+ storyId: this.ctx.storyId,
53281
+ phase: name,
53282
+ source: "post-rectification-resume"
53283
+ });
53284
+ break;
53285
+ }
53286
+ }
53287
+ }
53194
53288
  const verifierName = this.state.verifier?.slot.op.name;
53195
53289
  const gateName = this.state.fullSuiteGate?.slot.op.name;
53196
53290
  const verifierPassedSsot = verifierName !== undefined && phaseExplicitlyPassed(phaseOutputs[verifierName]);
@@ -53297,11 +53391,14 @@ var init_story_orchestrator = __esm(() => {
53297
53391
  init_logger2();
53298
53392
  init_operations();
53299
53393
  init_call();
53394
+ init_prepare_inputs();
53300
53395
  init_git();
53301
53396
  _storyOrchestratorDeps = {
53302
53397
  callOp,
53303
53398
  runFixCycle,
53304
- captureGitRef
53399
+ captureGitRef,
53400
+ prepareSemanticReviewInput,
53401
+ prepareAdversarialReviewInput
53305
53402
  };
53306
53403
  TDD_OP_NAMES = new Set(["test-writer", "implementer", "verifier"]);
53307
53404
  STRICT_VERDICT_PHASE_NAMES = new Set([
@@ -53601,8 +53698,6 @@ async function assemblePlanInputsFromCtx(ctx) {
53601
53698
  resolvedTestPatterns,
53602
53699
  semanticConfig: ctx.config.review.semantic
53603
53700
  });
53604
- if (prepared.skipReason)
53605
- return;
53606
53701
  return {
53607
53702
  workdir: ctx.workdir,
53608
53703
  story,
@@ -53614,7 +53709,15 @@ async function assemblePlanInputsFromCtx(ctx) {
53614
53709
  excludePatterns: prepared.excludePatterns,
53615
53710
  featureCtxBlock: buildFeatureCtxBlock(ctx, "reviewer-semantic"),
53616
53711
  priorSemanticIterations: ctx.priorSemanticIterations,
53617
- blockingThreshold: ctx.config.review.blockingThreshold
53712
+ blockingThreshold: ctx.config.review.blockingThreshold,
53713
+ _refresh: {
53714
+ projectDir: ctx.projectDir,
53715
+ storyId: story.id,
53716
+ storyGitRef: ctx.storyGitRef,
53717
+ config: ctx.config,
53718
+ naxIgnoreIndex: ctx.naxIgnoreIndex,
53719
+ resolvedTestPatterns
53720
+ }
53618
53721
  };
53619
53722
  })() : undefined;
53620
53723
  const adversarialEnabled = ctx.config.review?.enabled === true && ctx.config.review.checks?.includes("adversarial") && !!ctx.config.review.adversarial;
@@ -53629,8 +53732,6 @@ async function assemblePlanInputsFromCtx(ctx) {
53629
53732
  resolvedTestPatterns,
53630
53733
  adversarialConfig: ctx.config.review.adversarial
53631
53734
  });
53632
- if (prepared.skipReason)
53633
- return;
53634
53735
  return {
53635
53736
  workdir: ctx.workdir,
53636
53737
  story,
@@ -53645,7 +53746,15 @@ async function assemblePlanInputsFromCtx(ctx) {
53645
53746
  refExcludePatterns: prepared.refExcludePatterns,
53646
53747
  featureCtxBlock: buildFeatureCtxBlock(ctx, "reviewer-adversarial"),
53647
53748
  priorAdversarialIterations: ctx.priorAdversarialIterations,
53648
- blockingThreshold: ctx.config.review.blockingThreshold
53749
+ blockingThreshold: ctx.config.review.blockingThreshold,
53750
+ _refresh: {
53751
+ projectDir: ctx.projectDir,
53752
+ storyId: story.id,
53753
+ storyGitRef: ctx.storyGitRef,
53754
+ config: ctx.config,
53755
+ naxIgnoreIndex: ctx.naxIgnoreIndex,
53756
+ resolvedTestPatterns
53757
+ }
53649
53758
  };
53650
53759
  })() : undefined;
53651
53760
  const rectificationInput = ctx.config.execution?.rectification?.enabled === true ? {
@@ -57700,7 +57809,7 @@ var package_default;
57700
57809
  var init_package = __esm(() => {
57701
57810
  package_default = {
57702
57811
  name: "@nathapp/nax",
57703
- version: "0.67.15",
57812
+ version: "0.67.16",
57704
57813
  description: "AI Coding Agent Orchestrator \u2014 loops until done",
57705
57814
  type: "module",
57706
57815
  bin: {
@@ -57795,8 +57904,8 @@ var init_version = __esm(() => {
57795
57904
  NAX_VERSION = package_default.version;
57796
57905
  NAX_COMMIT = (() => {
57797
57906
  try {
57798
- if (/^[0-9a-f]{6,10}$/.test("035dd857"))
57799
- return "035dd857";
57907
+ if (/^[0-9a-f]{6,10}$/.test("215c9e93"))
57908
+ return "215c9e93";
57800
57909
  } catch {}
57801
57910
  try {
57802
57911
  const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nax",
3
- "version": "0.67.15",
3
+ "version": "0.67.16",
4
4
  "description": "AI Coding Agent Orchestrator — loops until done",
5
5
  "type": "module",
6
6
  "bin": {