substrate-ai 0.20.114 → 0.20.116

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.
@@ -0,0 +1,4 @@
1
+ import { AdapterRegistry } from "./dist-Bc0-6VcX.js";
2
+ import "./adapter-registry-DIcrxjH8.js";
3
+
4
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import { FileKvStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, buildPipelineStatusOutput, createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion } from "../health-DI5inO7P.js";
2
+ import { FileKvStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, buildPipelineStatusOutput, createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion } from "../health-D08AST4P.js";
3
3
  import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
- import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, InMemoryDatabaseAdapter, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createPipelineRun, createStderrLogger, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initWorkGraphSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, swallowDebug, tagRunAsBaseline, updatePipelineRun } from "../dist-CW4d4JMj.js";
6
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createGitWorktreeManager, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-D1MuG0x6.js";
5
+ import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, InMemoryDatabaseAdapter, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createPipelineRun, createStderrLogger, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initWorkGraphSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, swallowDebug, tagRunAsBaseline, updatePipelineRun } from "../dist-Bc0-6VcX.js";
6
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createGitWorktreeManager, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-w5Z0f1pa.js";
7
7
  import "../adapter-registry-DIcrxjH8.js";
8
- import { RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-DwpffChw.js";
9
- import "../errors-Da7Izmsw.js";
8
+ import { RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-BXhbIwv6.js";
9
+ import "../errors-CwQM_6Yk.js";
10
10
  import "../routing-DFxoKHDt.js";
11
11
  import { WorkGraphRepository } from "../work-graph-repository-DZyJv5pV.js";
12
12
  import "../decisions-CzSIEeGP.js";
13
13
  import "../decision-router-DblHY8se.js";
14
- import "../interactive-prompt-Cpke493f.js";
14
+ import "../interactive-prompt-CBPiHLsh.js";
15
15
  import "../recovery-engine-BKGBeBnW.js";
16
16
  import "../version-manager-impl-qFBiO4Eh.js";
17
- import { registerUpgradeCommand } from "../upgrade-W9n0n39E.js";
17
+ import { registerUpgradeCommand } from "../upgrade-BlBDCOfS.js";
18
18
  import { Command } from "commander";
19
19
  import { fileURLToPath } from "url";
20
20
  import { dirname, join, resolve } from "path";
@@ -6890,7 +6890,7 @@ async function runStatusAction(options) {
6890
6890
  logger$15.debug({ err }, "Work graph query failed, continuing without work graph data");
6891
6891
  }
6892
6892
  if (run === void 0) {
6893
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-Bc0Q5hGJ.js");
6893
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-B42A1Xcd.js");
6894
6894
  const substrateDirPath = join(projectRoot, ".substrate");
6895
6895
  const processInfo = inspectProcessTree$1({
6896
6896
  projectRoot,
@@ -7838,7 +7838,7 @@ function defaultSupervisorDeps() {
7838
7838
  if (cached === null) {
7839
7839
  const { AdapterRegistry: AR } = await import(
7840
7840
  /* @vite-ignore */
7841
- "../adapter-registry-Dv83m9Uh.js"
7841
+ "../adapter-registry-B9G8dfn-.js"
7842
7842
  );
7843
7843
  cached = new AR();
7844
7844
  await cached.discoverAndRegister();
@@ -8405,11 +8405,11 @@ async function runSupervisorAction(options, deps = {}) {
8405
8405
  try {
8406
8406
  const { createExperimenter } = await import(
8407
8407
  /* @vite-ignore */
8408
- "../experimenter-Dvo-LfAe.js"
8408
+ "../experimenter-D9yPAcRD.js"
8409
8409
  );
8410
8410
  const { getLatestRun: getLatest } = await import(
8411
8411
  /* @vite-ignore */
8412
- "../decisions-BM12_hm6.js"
8412
+ "../decisions-B4A60aRy.js"
8413
8413
  );
8414
8414
  const expAdapter = createDatabaseAdapter({
8415
8415
  backend: "auto",
@@ -8419,7 +8419,7 @@ async function runSupervisorAction(options, deps = {}) {
8419
8419
  await initSchema(expAdapter);
8420
8420
  const { runRunAction: runPipeline } = await import(
8421
8421
  /* @vite-ignore */
8422
- "../run-9ngj072m.js"
8422
+ "../run-BLOqlAFP.js"
8423
8423
  );
8424
8424
  const runStoryFn = async (opts) => {
8425
8425
  const exitCode = await runPipeline({
@@ -8944,7 +8944,7 @@ async function runMetricsAction(options) {
8944
8944
  const routingConfigPath = join(dbDir, "routing.yml");
8945
8945
  let routingConfig = null;
8946
8946
  if (existsSync$1(routingConfigPath)) try {
8947
- const { loadModelRoutingConfig } = await import("../routing-BiT4IXk2.js");
8947
+ const { loadModelRoutingConfig } = await import("../routing-DFwoxEpT.js");
8948
8948
  routingConfig = loadModelRoutingConfig(routingConfigPath);
8949
8949
  } catch {}
8950
8950
  if (routingConfig === null) routingConfig = {
@@ -13226,8 +13226,8 @@ async function createProgram() {
13226
13226
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
13227
13227
  function checkForUpdatesInBackground(currentVersion) {
13228
13228
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
13229
- import("../upgrade-BciwetMn.js").then(async () => {
13230
- const { createVersionManager } = await import("../version-manager-impl-G82XqDMV.js");
13229
+ import("../upgrade-OE6hMPMW.js").then(async () => {
13230
+ const { createVersionManager } = await import("../version-manager-impl-BRVBwdma.js");
13231
13231
  const vm = createVersionManager();
13232
13232
  const result = await vm.checkForUpdates();
13233
13233
  if (result.updateAvailable) {
@@ -1,4 +1,4 @@
1
- import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-CW4d4JMj.js";
1
+ import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-Bc0-6VcX.js";
2
2
  import "./decisions-CzSIEeGP.js";
3
3
 
4
4
  export { getLatestRun };
@@ -1244,6 +1244,7 @@ var DispatcherImpl = class {
1244
1244
  const worktreePath = workingDirectory ?? process.cwd();
1245
1245
  const resolvedMaxTurns = maxTurns ?? DEFAULT_MAX_TURNS[taskType];
1246
1246
  const capabilities = adapter.getCapabilities();
1247
+ const finalModel = effectiveModel ?? capabilities.defaultModel;
1247
1248
  const effectivePrompt = capabilities.requiresYamlSuffix === true ? prompt + buildYamlOutputSuffix(outputSchema) : prompt;
1248
1249
  const cmd = adapter.buildCommand(effectivePrompt, {
1249
1250
  worktreePath,
@@ -1389,7 +1390,8 @@ var DispatcherImpl = class {
1389
1390
  tokenEstimate: {
1390
1391
  input: inputTokens,
1391
1392
  output: outputTokens
1392
- }
1393
+ },
1394
+ ...finalModel !== void 0 ? { model: finalModel } : {}
1393
1395
  });
1394
1396
  }, timeoutMs);
1395
1397
  proc.on("close", (exitCode) => {
@@ -1452,7 +1454,8 @@ var DispatcherImpl = class {
1452
1454
  tokenEstimate: {
1453
1455
  input: inputTokens,
1454
1456
  output: Math.ceil(stdout.length / CHARS_PER_TOKEN$3)
1455
- }
1457
+ },
1458
+ ...finalModel !== void 0 ? { model: finalModel } : {}
1456
1459
  });
1457
1460
  return;
1458
1461
  }
@@ -1495,7 +1498,8 @@ var DispatcherImpl = class {
1495
1498
  tokenEstimate: {
1496
1499
  input: inputTokens,
1497
1500
  output: Math.ceil(stdout.length / CHARS_PER_TOKEN$3)
1498
- }
1501
+ },
1502
+ ...finalModel !== void 0 ? { model: finalModel } : {}
1499
1503
  });
1500
1504
  } else {
1501
1505
  const stderr = Buffer.concat(stderrChunks).toString("utf-8");
@@ -1524,7 +1528,8 @@ var DispatcherImpl = class {
1524
1528
  tokenEstimate: {
1525
1529
  input: inputTokens,
1526
1530
  output: Math.ceil(combinedOutput.length / CHARS_PER_TOKEN$3)
1527
- }
1531
+ },
1532
+ ...finalModel !== void 0 ? { model: finalModel } : {}
1528
1533
  });
1529
1534
  }
1530
1535
  });
@@ -9677,7 +9682,8 @@ var ClaudeCodeAdapter = class {
9677
9682
  supportsSystemPrompt: true,
9678
9683
  supportsOtlpExport: true,
9679
9684
  requiresYamlSuffix: false,
9680
- defaultMaxReviewCycles: 2
9685
+ defaultMaxReviewCycles: 2,
9686
+ defaultModel: DEFAULT_MODEL$1
9681
9687
  };
9682
9688
  }
9683
9689
  _detectBillingModes(versionOutput) {
@@ -10148,7 +10154,8 @@ var GeminiCLIAdapter = class {
10148
10154
  supportsSystemPrompt: false,
10149
10155
  supportsOtlpExport: false,
10150
10156
  requiresYamlSuffix: true,
10151
- defaultMaxReviewCycles: 3
10157
+ defaultMaxReviewCycles: 3,
10158
+ defaultModel: DEFAULT_MODEL
10152
10159
  };
10153
10160
  }
10154
10161
  _detectBillingModes(versionOutput) {
@@ -11273,4 +11280,4 @@ async function callLLM(params) {
11273
11280
 
11274
11281
  //#endregion
11275
11282
  export { ADVISORY_NOTES, AdapterRegistry, AdtError, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, Categorizer, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, ConsumerAnalyzer, CostTrackerConfigSchema, DEFAULT_CONFIG, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, DoltNotInstalled, DoltQueryError, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, GeminiCLIAdapter, GlobalSettingsSchema, InMemoryDatabaseAdapter, IngestionServer, LEARNING_FINDING, LogTurnAnalyzer, ModelRoutingConfigSchema, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProviderPolicySchema, ProvidersSchema, Recommender, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TASK_TYPE_PHASE_MAP, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryConfigSchema, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, VersionManagerImpl, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, callLLM, checkDoltInstalled, classifyVersionGap, compareRunMetrics, createAmendmentRun, createConfigSystem, createDatabaseAdapter as createDatabaseAdapter$1, createDecision, createExperimenter, createPipelineRun, createRequirement, createStderrLogger, createVersionManager, detectInterfaceChanges, determineVerdict, getActiveDecisions, getAllCostEntriesFiltered, getArtifactByTypeForRun, getArtifactsByRun, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getModelTier, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initWorkGraphSchema, initializeDolt, listRequirements, listRunMetrics, loadModelRoutingConfig, loadParentRunDecisions, registerArtifact, resolvePromptFile, supersedeDecision, swallowDebug, tagRunAsBaseline, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics };
11276
- //# sourceMappingURL=dist-CW4d4JMj.js.map
11283
+ //# sourceMappingURL=dist-Bc0-6VcX.js.map
@@ -1,4 +1,4 @@
1
- import { AdtError } from "./dist-CW4d4JMj.js";
1
+ import { AdtError } from "./dist-Bc0-6VcX.js";
2
2
 
3
3
  //#region src/core/errors.ts
4
4
  /** Error thrown when task configuration is invalid */
@@ -71,4 +71,4 @@ var TaskGraphIncompatibleFormatError = class extends AdtError {
71
71
 
72
72
  //#endregion
73
73
  export { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError };
74
- //# sourceMappingURL=errors-Da7Izmsw.js.map
74
+ //# sourceMappingURL=errors-CwQM_6Yk.js.map
@@ -1,3 +1,3 @@
1
- import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-CW4d4JMj.js";
1
+ import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-Bc0-6VcX.js";
2
2
 
3
3
  export { createExperimenter };
@@ -1,7 +1,7 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-DI5inO7P.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-D08AST4P.js";
2
2
  import "./logger-KeHncl-f.js";
3
- import "./dist-CW4d4JMj.js";
4
- import "./manifest-read-DwpffChw.js";
3
+ import "./dist-Bc0-6VcX.js";
4
+ import "./manifest-read-BXhbIwv6.js";
5
5
  import "./work-graph-repository-DZyJv5pV.js";
6
6
  import "./decisions-CzSIEeGP.js";
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-CW4d4JMj.js";
3
- import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-DwpffChw.js";
2
+ import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-Bc0-6VcX.js";
3
+ import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-BXhbIwv6.js";
4
4
  import { createRequire } from "module";
5
5
  import { dirname, join } from "path";
6
6
  import { existsSync, readFileSync } from "node:fs";
@@ -1000,4 +1000,4 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
1000
1000
 
1001
1001
  //#endregion
1002
1002
  export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, runHealthAction, validateStoryKey };
1003
- //# sourceMappingURL=health-DI5inO7P.js.map
1003
+ //# sourceMappingURL=health-D08AST4P.js.map
@@ -946,6 +946,13 @@ interface AdapterCapabilities {
946
946
  * Overridden by explicit --max-review-cycles CLI flag.
947
947
  */
948
948
  defaultMaxReviewCycles?: number;
949
+ /**
950
+ * The model this adapter dispatches to when no explicit/routed model is given
951
+ * (story 77-4). The dispatcher echoes `effectiveModel ?? defaultModel` on the
952
+ * DispatchResult so primary_model telemetry is populated even for the common
953
+ * adapter-default path. Must match the value the adapter applies in buildCommand.
954
+ */
955
+ defaultModel?: string;
949
956
  }
950
957
  /**
951
958
  * Result returned from an adapter health check.
@@ -1432,4 +1439,4 @@ interface Recommendation {
1432
1439
 
1433
1440
  //#endregion
1434
1441
  export { AdapterDiscoveryResult, AdapterRegistry as AdapterRegistry$1, AdtError as AdtError$1, ClaudeCodeAdapter as ClaudeCodeAdapter$1, CodexCLIAdapter as CodexCLIAdapter$1, ConfigError as ConfigError$1, ConfigIncompatibleFormatError as ConfigIncompatibleFormatError$1, CoreEvents, DatabaseAdapter, DiscoveryReport, GeminiCLIAdapter as GeminiCLIAdapter$1, Recommendation, TypedEventBus };
1435
- //# sourceMappingURL=index-DYzIw89v.d.ts.map
1442
+ //# sourceMappingURL=index-Ce8BVUmL.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdapterDiscoveryResult, AdapterRegistry$1 as AdapterRegistry, AdtError$1 as AdtError, ClaudeCodeAdapter$1 as ClaudeCodeAdapter, CodexCLIAdapter$1 as CodexCLIAdapter, ConfigError$1 as ConfigError, ConfigIncompatibleFormatError$1 as ConfigIncompatibleFormatError, DiscoveryReport, GeminiCLIAdapter$1 as GeminiCLIAdapter, Recommendation, TypedEventBus } from "./index-DYzIw89v.js";
1
+ import { AdapterDiscoveryResult, AdapterRegistry$1 as AdapterRegistry, AdtError$1 as AdtError, ClaudeCodeAdapter$1 as ClaudeCodeAdapter, CodexCLIAdapter$1 as CodexCLIAdapter, ConfigError$1 as ConfigError, ConfigIncompatibleFormatError$1 as ConfigIncompatibleFormatError, DiscoveryReport, GeminiCLIAdapter$1 as GeminiCLIAdapter, Recommendation, TypedEventBus } from "./index-Ce8BVUmL.js";
2
2
  import pino from "pino";
3
3
  import { z } from "zod";
4
4
  import { Readable, Writable } from "node:stream";
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { childLogger, createLogger, logger } from "./logger-KeHncl-f.js";
2
2
  import { assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry } from "./helpers-CElYrONe.js";
3
- import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-CW4d4JMj.js";
3
+ import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-Bc0-6VcX.js";
4
4
  import "./adapter-registry-DIcrxjH8.js";
5
- import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-Da7Izmsw.js";
5
+ import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-CwQM_6Yk.js";
6
6
 
7
7
  //#region src/core/di.ts
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-DwpffChw.js";
2
+ import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-BXhbIwv6.js";
3
3
  import { join } from "node:path";
4
4
  import { mkdir, readFile, writeFile } from "node:fs/promises";
5
5
  import * as readline from "node:readline";
@@ -180,4 +180,4 @@ async function runInteractivePrompt(decisionContext) {
180
180
 
181
181
  //#endregion
182
182
  export { runInteractivePrompt };
183
- //# sourceMappingURL=interactive-prompt-Cpke493f.js.map
183
+ //# sourceMappingURL=interactive-prompt-CBPiHLsh.js.map
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { LEARNING_FINDING, createDecision, getDecisionsByCategory } from "./dist-CW4d4JMj.js";
2
+ import { LEARNING_FINDING, createDecision, getDecisionsByCategory } from "./dist-Bc0-6VcX.js";
3
3
  import * as path$1 from "path";
4
4
  import { join } from "path";
5
5
  import { readFile } from "fs/promises";
@@ -4655,7 +4655,8 @@ const PerStoryStateSchema = z.object({
4655
4655
  z.literal("both"),
4656
4656
  z.string()
4657
4657
  ]).optional(),
4658
- verification_re_run: z.boolean().optional()
4658
+ verification_re_run: z.boolean().optional(),
4659
+ escalation_reason: z.string().optional()
4659
4660
  });
4660
4661
 
4661
4662
  //#endregion
@@ -5845,4 +5846,4 @@ async function resolveRunManifest(dbRoot, runId) {
5845
5846
 
5846
5847
  //#endregion
5847
5848
  export { FindingsInjector, RunManifest, RuntimeProbeListSchema, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, parseRuntimeProbes, readCurrentRunId, renderFindings, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck, runStaleVerificationRecovery };
5848
- //# sourceMappingURL=manifest-read-DwpffChw.js.map
5849
+ //# sourceMappingURL=manifest-read-BXhbIwv6.js.map
@@ -1,6 +1,6 @@
1
1
  import "../../logger-KeHncl-f.js";
2
- import "../../dist-CW4d4JMj.js";
3
- import "../../manifest-read-DwpffChw.js";
4
- import { runInteractivePrompt } from "../../interactive-prompt-Cpke493f.js";
2
+ import "../../dist-Bc0-6VcX.js";
3
+ import "../../manifest-read-BXhbIwv6.js";
4
+ import { runInteractivePrompt } from "../../interactive-prompt-CBPiHLsh.js";
5
5
 
6
6
  export { runInteractivePrompt };
@@ -1,4 +1,4 @@
1
- import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-CW4d4JMj.js";
1
+ import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-Bc0-6VcX.js";
2
2
  import "./routing-DFxoKHDt.js";
3
3
 
4
4
  export { loadModelRoutingConfig };
@@ -1,14 +1,14 @@
1
- import "./health-DI5inO7P.js";
1
+ import "./health-D08AST4P.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
- import "./dist-CW4d4JMj.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-D1MuG0x6.js";
6
- import "./manifest-read-DwpffChw.js";
4
+ import "./dist-Bc0-6VcX.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-w5Z0f1pa.js";
6
+ import "./manifest-read-BXhbIwv6.js";
7
7
  import "./routing-DFxoKHDt.js";
8
8
  import "./work-graph-repository-DZyJv5pV.js";
9
9
  import "./decisions-CzSIEeGP.js";
10
10
  import "./decision-router-DblHY8se.js";
11
- import "./interactive-prompt-Cpke493f.js";
11
+ import "./interactive-prompt-CBPiHLsh.js";
12
12
  import "./recovery-engine-BKGBeBnW.js";
13
13
 
14
14
  export { runRunAction };
@@ -1,11 +1,11 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, validateStoryKey } from "./health-DI5inO7P.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, validateStoryKey } from "./health-D08AST4P.js";
2
2
  import { createLogger } from "./logger-KeHncl-f.js";
3
3
  import { TypedEventBusImpl, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-CElYrONe.js";
4
- import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, classifyVersionGap, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, createStderrLogger, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, swallowDebug, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-CW4d4JMj.js";
5
- import { FindingsInjector, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery } from "./manifest-read-DwpffChw.js";
4
+ import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, classifyVersionGap, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, createStderrLogger, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, swallowDebug, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-Bc0-6VcX.js";
5
+ import { FindingsInjector, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery } from "./manifest-read-BXhbIwv6.js";
6
6
  import { WorkGraphRepository, detectCycles } from "./work-graph-repository-DZyJv5pV.js";
7
7
  import { deriveExitCode, routeDecision } from "./decision-router-DblHY8se.js";
8
- import { runInteractivePrompt } from "./interactive-prompt-Cpke493f.js";
8
+ import { runInteractivePrompt } from "./interactive-prompt-CBPiHLsh.js";
9
9
  import { runRecoveryEngine } from "./recovery-engine-BKGBeBnW.js";
10
10
  import { basename, dirname, extname, join } from "path";
11
11
  import { access, readFile, readdir, stat } from "fs/promises";
@@ -6756,7 +6756,8 @@ async function runCreateStory(deps, params) {
6756
6756
  story_file: parsed.story_file,
6757
6757
  story_key: parsed.story_key,
6758
6758
  story_title: parsed.story_title,
6759
- tokenUsage
6759
+ tokenUsage,
6760
+ ...dispatchResult.model !== void 0 ? { model: dispatchResult.model } : {}
6760
6761
  };
6761
6762
  }
6762
6763
  /**
@@ -8331,7 +8332,8 @@ async function runDevStory(deps, params) {
8331
8332
  ac_failures: parsed.ac_failures,
8332
8333
  files_modified: parsed.files_modified,
8333
8334
  tests: parsed.tests,
8334
- tokenUsage
8335
+ tokenUsage,
8336
+ ...dispatchResult.model !== void 0 ? { model: dispatchResult.model } : {}
8335
8337
  };
8336
8338
  if (parsed.notes !== void 0) successResult.notes = parsed.notes;
8337
8339
  return successResult;
@@ -9100,7 +9102,8 @@ async function runCodeReview(deps, params) {
9100
9102
  issues: parsed.issues,
9101
9103
  issue_list: parsed.issue_list,
9102
9104
  notes: parsed.notes,
9103
- tokenUsage
9105
+ tokenUsage,
9106
+ ...dispatchResult.model !== void 0 ? { model: dispatchResult.model } : {}
9104
9107
  };
9105
9108
  }
9106
9109
  /**
@@ -13370,11 +13373,11 @@ function createImplementationOrchestrator(deps) {
13370
13373
  if (!_phaseStartMs.has(storyKey)) _phaseStartMs.set(storyKey, new Map());
13371
13374
  _phaseStartMs.get(storyKey).set(phase, Date.now());
13372
13375
  }
13373
- function endPhase(storyKey, phase) {
13376
+ function endPhase(storyKey, phase, model) {
13374
13377
  if (!_phaseEndMs.has(storyKey)) _phaseEndMs.set(storyKey, new Map());
13375
13378
  _phaseEndMs.get(storyKey).set(phase, Date.now());
13376
13379
  _completedDispatches++;
13377
- recordDispatchAgent(storyKey, phase, agentId ?? "claude-code");
13380
+ recordDispatchAgent(storyKey, phase, agentId ?? "claude-code", model);
13378
13381
  }
13379
13382
  function incrementDispatches(storyKey) {
13380
13383
  _storyDispatches.set(storyKey, (_storyDispatches.get(storyKey) ?? 0) + 1);
@@ -13388,6 +13391,26 @@ function createImplementationOrchestrator(deps) {
13388
13391
  });
13389
13392
  }
13390
13393
  /**
13394
+ * Story 77-4: derive primary_model for story_metrics from the per-story dispatch
13395
+ * agents. Prefer the model of the primary implementation dispatch (dev-story, then
13396
+ * its retry); otherwise fall back to the most frequent model across all dispatches.
13397
+ * Returns undefined only when no dispatch recorded a model (genuinely unknown).
13398
+ */
13399
+ function derivePrimaryModel(storyKey) {
13400
+ const agents = _storyAgents.get(storyKey) ?? [];
13401
+ const devModel = agents.find((a) => a.phase === "dev-story" && a.model !== void 0)?.model ?? agents.find((a) => a.phase === "dev-story-retry" && a.model !== void 0)?.model;
13402
+ if (devModel !== void 0) return devModel;
13403
+ const counts = new Map();
13404
+ for (const a of agents) if (a.model !== void 0) counts.set(a.model, (counts.get(a.model) ?? 0) + 1);
13405
+ let best;
13406
+ let bestCount = 0;
13407
+ for (const [model, count] of counts) if (count > bestCount) {
13408
+ best = model;
13409
+ bestCount = count;
13410
+ }
13411
+ return best;
13412
+ }
13413
+ /**
13391
13414
  * Initialize `_storyRetryCount` from the run manifest for crash-recovery durability (AC6, Story 53-4).
13392
13415
  * Reads persisted retry_count so that budget gate correctly accounts for prior-session retries.
13393
13416
  * Best-effort: failures result in a starting count of 0 (safe — may allow one extra retry).
@@ -13466,6 +13489,7 @@ function createImplementationOrchestrator(deps) {
13466
13489
  review_cycles: reviewCycles,
13467
13490
  dispatches: _storyDispatches.get(storyKey) ?? 0,
13468
13491
  primary_agent_id: storyAgentId ?? agentId ?? "claude-code",
13492
+ primary_model: derivePrimaryModel(storyKey),
13469
13493
  dispatch_agents_json: _storyAgents.has(storyKey) ? JSON.stringify(_storyAgents.get(storyKey)) : void 0
13470
13494
  });
13471
13495
  try {
@@ -13639,6 +13663,13 @@ function createImplementationOrchestrator(deps) {
13639
13663
  ...payload,
13640
13664
  diagnosis
13641
13665
  });
13666
+ if (runManifest !== null) {
13667
+ const escalationReason = payload.escalationReason ?? payload.lastVerdict;
13668
+ runManifest.patchStoryState(payload.storyKey, { escalation_reason: escalationReason }).catch((err) => logger$27.warn({
13669
+ err,
13670
+ storyKey: payload.storyKey
13671
+ }, "patchStoryState(escalation_reason) failed — pipeline continues"));
13672
+ }
13642
13673
  if (config.pipelineRunId !== void 0) try {
13643
13674
  const diagnosisWithIssues = {
13644
13675
  ...diagnosis,
@@ -14579,6 +14610,7 @@ function createImplementationOrchestrator(deps) {
14579
14610
  const batchFileGroups = [];
14580
14611
  let devStoryWasSuccess = false;
14581
14612
  let devOutputTokenCount;
14613
+ let devStoryModel;
14582
14614
  let storyContentForVerification;
14583
14615
  let devStorySignals;
14584
14616
  const normalizeDevStorySignals = (result) => {
@@ -14697,6 +14729,7 @@ function createImplementationOrchestrator(deps) {
14697
14729
  const batchDurationMs = Date.now() - batchStartMs;
14698
14730
  const batchFilesModified = batchResult.files_modified ?? [];
14699
14731
  mergeDevStorySignals(batchResult);
14732
+ if (batchResult.model !== void 0) devStoryModel = batchResult.model;
14700
14733
  const batchMetrics = {
14701
14734
  batchIndex: batch.batchIndex,
14702
14735
  taskIds: batch.taskIds,
@@ -14769,6 +14802,7 @@ function createImplementationOrchestrator(deps) {
14769
14802
  pipelineRunId: config.pipelineRunId
14770
14803
  });
14771
14804
  devFilesModified = devResult.files_modified ?? [];
14805
+ if (devResult.model !== void 0) devStoryModel = devResult.model;
14772
14806
  devOutputTokenCount = devResult.tokenUsage?.output ?? void 0;
14773
14807
  if (config.pipelineRunId !== void 0 && devResult.tokenUsage !== void 0) Promise.resolve().then(() => addTokenUsage(db, config.pipelineRunId, {
14774
14808
  phase: "dev-story",
@@ -14789,7 +14823,7 @@ function createImplementationOrchestrator(deps) {
14789
14823
  await persistState();
14790
14824
  let checkpointHandled = false;
14791
14825
  if (devResult.result === "failed" && devResult.error?.startsWith("dispatch_timeout")) {
14792
- endPhase(storyKey, "dev-story");
14826
+ endPhase(storyKey, "dev-story", devStoryModel);
14793
14827
  const timeoutFiles = checkGitDiffFiles(effectiveProjectRoot ?? process.cwd());
14794
14828
  if (timeoutFiles.length === 0) {
14795
14829
  logger$27.warn({ storyKey }, "Dev-story timeout with zero modified files — escalating immediately (no checkpoint)");
@@ -14921,7 +14955,20 @@ function createImplementationOrchestrator(deps) {
14921
14955
  storyKey
14922
14956
  });
14923
14957
  const checkpointRetryResult = await checkpointRetryHandle.result;
14924
- endPhase(storyKey, "dev-story-retry");
14958
+ if (checkpointRetryResult.model !== void 0) devStoryModel = checkpointRetryResult.model;
14959
+ endPhase(storyKey, "dev-story-retry", checkpointRetryResult.model);
14960
+ if (runManifest) runManifest.appendRecoveryEntry({
14961
+ story_key: storyKey,
14962
+ attempt_number: _storyDispatches.get(storyKey) ?? 1,
14963
+ strategy: "dev-story-timeout-checkpoint-retry",
14964
+ root_cause: "checkpoint-retry-timeout",
14965
+ outcome: checkpointRetryResult.status === "timeout" ? "escalated" : "retried",
14966
+ cost_usd: 0,
14967
+ timestamp: new Date().toISOString()
14968
+ }).catch((err) => logger$27.warn({
14969
+ err,
14970
+ storyKey
14971
+ }, "appendRecoveryEntry(checkpoint-retry) failed — pipeline continues"));
14925
14972
  eventBus.emit("orchestrator:story-phase-complete", {
14926
14973
  storyKey,
14927
14974
  phase: "IN_DEV",
@@ -14981,7 +15028,7 @@ function createImplementationOrchestrator(deps) {
14981
15028
  }
14982
15029
  } catch (err) {
14983
15030
  const errMsg = err instanceof Error ? err.message : String(err);
14984
- endPhase(storyKey, "dev-story");
15031
+ endPhase(storyKey, "dev-story", devStoryModel);
14985
15032
  updateStory(storyKey, {
14986
15033
  phase: "ESCALATED",
14987
15034
  error: errMsg,
@@ -15040,7 +15087,7 @@ function createImplementationOrchestrator(deps) {
15040
15087
  storyKey,
15041
15088
  reason: "zero-diff-on-complete"
15042
15089
  });
15043
- endPhase(storyKey, "dev-story");
15090
+ endPhase(storyKey, "dev-story", devStoryModel);
15044
15091
  updateStory(storyKey, {
15045
15092
  phase: "ESCALATED",
15046
15093
  error: "zero-diff-on-complete",
@@ -15058,7 +15105,7 @@ function createImplementationOrchestrator(deps) {
15058
15105
  }
15059
15106
  }
15060
15107
  }
15061
- endPhase(storyKey, "dev-story");
15108
+ endPhase(storyKey, "dev-story", devStoryModel);
15062
15109
  let _buildPassed = false;
15063
15110
  {
15064
15111
  let buildVerifyResult = config.skipBuildVerify === true ? { status: "skipped" } : runBuildVerification({
@@ -15410,6 +15457,18 @@ function createImplementationOrchestrator(deps) {
15410
15457
  storyKey,
15411
15458
  pendingProposalsCount: recoveryResult.pendingProposalsCount
15412
15459
  }, "Recovery Engine safety valve: halting entire run due to >= 5 pending proposals");
15460
+ if (runManifest) runManifest.appendRecoveryEntry({
15461
+ story_key: storyKey,
15462
+ attempt_number: finalReviewCycles + 1,
15463
+ strategy: "halt-entire-run",
15464
+ root_cause: recoveryRootCause,
15465
+ outcome: "escalated",
15466
+ cost_usd: 0,
15467
+ timestamp: new Date().toISOString()
15468
+ }).catch((err) => logger$27.warn({
15469
+ err,
15470
+ storyKey
15471
+ }, "appendRecoveryEntry(halt-entire-run) failed — pipeline continues"));
15413
15472
  _budgetExhausted = true;
15414
15473
  } else if (recoveryResult?.action === "retry") {
15415
15474
  logger$27.info({
@@ -15452,7 +15511,20 @@ function createImplementationOrchestrator(deps) {
15452
15511
  const retryVerifSummary = await verificationPipeline.run(retryVerifContext, "A");
15453
15512
  verificationStore.set(storyKey, retryVerifSummary);
15454
15513
  await persistVerificationResult(storyKey, retryVerifSummary, runManifest);
15455
- if (retryVerifSummary.status !== "fail") {
15514
+ const tierARecovered = retryVerifSummary.status !== "fail";
15515
+ if (runManifest) runManifest.appendRecoveryEntry({
15516
+ story_key: storyKey,
15517
+ attempt_number: recoveryResult.attempt,
15518
+ strategy: "tier-a-retry-with-context",
15519
+ root_cause: recoveryRootCause,
15520
+ outcome: tierARecovered ? "recovered" : "retried",
15521
+ cost_usd: 0,
15522
+ timestamp: new Date().toISOString()
15523
+ }).catch((err) => logger$27.warn({
15524
+ err,
15525
+ storyKey
15526
+ }, "appendRecoveryEntry(tier-a) failed — pipeline continues"));
15527
+ if (tierARecovered) {
15456
15528
  logger$27.info({ storyKey }, "Recovery Engine Tier A retry succeeded — story proceeding to COMPLETE");
15457
15529
  shouldFallThroughToComplete = true;
15458
15530
  } else logger$27.warn({ storyKey }, "Recovery Engine Tier A retry still failed — falling through to VERIFICATION_FAILED");
@@ -15464,6 +15536,18 @@ function createImplementationOrchestrator(deps) {
15464
15536
  }
15465
15537
  } else if (recoveryResult?.action === "propose") {
15466
15538
  logger$27.info({ storyKey }, "Recovery Engine Tier B: proposal appended — marking story ESCALATED for operator re-scope");
15539
+ if (runManifest) runManifest.appendRecoveryEntry({
15540
+ story_key: storyKey,
15541
+ attempt_number: finalReviewCycles + 1,
15542
+ strategy: "tier-b-re-scope-proposal",
15543
+ root_cause: recoveryRootCause,
15544
+ outcome: "escalated",
15545
+ cost_usd: 0,
15546
+ timestamp: new Date().toISOString()
15547
+ }).catch((err) => logger$27.warn({
15548
+ err,
15549
+ storyKey
15550
+ }, "appendRecoveryEntry(tier-b) failed — pipeline continues"));
15467
15551
  updateStory(storyKey, {
15468
15552
  phase: "ESCALATED",
15469
15553
  completedAt: new Date().toISOString(),
@@ -15473,7 +15557,8 @@ function createImplementationOrchestrator(deps) {
15473
15557
  storyKey,
15474
15558
  lastVerdict: "recovery-propose",
15475
15559
  reviewCycles: finalReviewCycles,
15476
- issues: failFindings
15560
+ issues: failFindings,
15561
+ escalationReason: recoveryRootCause
15477
15562
  });
15478
15563
  await writeStoryMetricsBestEffort(storyKey, "escalated", finalReviewCycles);
15479
15564
  await persistState();
@@ -15501,6 +15586,18 @@ function createImplementationOrchestrator(deps) {
15501
15586
  storyKey
15502
15587
  }, "Recovery Engine Tier C: interactive prompt failed — escalating anyway");
15503
15588
  });
15589
+ if (runManifest) runManifest.appendRecoveryEntry({
15590
+ story_key: storyKey,
15591
+ attempt_number: finalReviewCycles + 1,
15592
+ strategy: "tier-c-halt",
15593
+ root_cause: recoveryRootCause,
15594
+ outcome: "escalated",
15595
+ cost_usd: 0,
15596
+ timestamp: new Date().toISOString()
15597
+ }).catch((err) => logger$27.warn({
15598
+ err,
15599
+ storyKey
15600
+ }, "appendRecoveryEntry(tier-c) failed — pipeline continues"));
15504
15601
  updateStory(storyKey, {
15505
15602
  phase: "ESCALATED",
15506
15603
  completedAt: new Date().toISOString(),
@@ -15510,7 +15607,8 @@ function createImplementationOrchestrator(deps) {
15510
15607
  storyKey,
15511
15608
  lastVerdict: "recovery-halt",
15512
15609
  reviewCycles: finalReviewCycles,
15513
- issues: failFindings
15610
+ issues: failFindings,
15611
+ escalationReason: recoveryRootCause
15514
15612
  });
15515
15613
  await writeStoryMetricsBestEffort(storyKey, "escalated", finalReviewCycles);
15516
15614
  await persistState();
@@ -47000,7 +47098,7 @@ async function runFullPipeline(options) {
47000
47098
  */
47001
47099
  async function emitPreDispatchVersionAdvisory(currentVersion) {
47002
47100
  if (process.env["SUBSTRATE_NO_UPDATE_CHECK"] === "1") return;
47003
- const { createVersionManager } = await import("./version-manager-impl-G82XqDMV.js");
47101
+ const { createVersionManager } = await import("./version-manager-impl-BRVBwdma.js");
47004
47102
  const vm = createVersionManager();
47005
47103
  const result = await vm.checkForUpdates(true);
47006
47104
  const gap = classifyVersionGap(currentVersion, result.latestVersion);
@@ -47097,4 +47195,4 @@ function registerRunCommand(program, version = "0.0.0", projectRoot = process.cw
47097
47195
 
47098
47196
  //#endregion
47099
47197
  export { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR$1 as GLOBSTAR, GitClient, GrammarLoader, Minimatch$1 as Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createGitWorktreeManager, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape$1 as escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runRunAction, runSolutioningPhase, unescape$1 as unescape, validateStopAfterFromConflict, wireNdjsonEmitter };
47100
- //# sourceMappingURL=run-D1MuG0x6.js.map
47198
+ //# sourceMappingURL=run-w5Z0f1pa.js.map
@@ -1,4 +1,4 @@
1
- import { CoreEvents, DatabaseAdapter, TypedEventBus } from "../../../index-DYzIw89v.js";
1
+ import { CoreEvents, DatabaseAdapter, TypedEventBus } from "../../../index-Ce8BVUmL.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region packages/sdlc/dist/verification/findings.d.ts
@@ -578,6 +578,7 @@ declare const PerStoryStateSchema: z.ZodObject<{
578
578
  }, z.core.$strip>>;
579
579
  probe_author_triggered_by: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"event-driven">, z.ZodLiteral<"state-integrating">, z.ZodLiteral<"both">, z.ZodString]>>;
580
580
  verification_re_run: z.ZodOptional<z.ZodBoolean>;
581
+ escalation_reason: z.ZodOptional<z.ZodString>;
581
582
  }, z.core.$strip>;
582
583
  type PerStoryState = z.infer<typeof PerStoryStateSchema>;
583
584
 
@@ -1,4 +1,4 @@
1
- import { createVersionManager } from "./dist-CW4d4JMj.js";
1
+ import { createVersionManager } from "./dist-Bc0-6VcX.js";
2
2
  import { execSync, spawn } from "child_process";
3
3
  import * as readline from "readline";
4
4
 
@@ -123,4 +123,4 @@ function registerUpgradeCommand(program) {
123
123
 
124
124
  //#endregion
125
125
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
126
- //# sourceMappingURL=upgrade-W9n0n39E.js.map
126
+ //# sourceMappingURL=upgrade-BlBDCOfS.js.map
@@ -1,5 +1,5 @@
1
- import "./dist-CW4d4JMj.js";
1
+ import "./dist-Bc0-6VcX.js";
2
2
  import "./version-manager-impl-qFBiO4Eh.js";
3
- import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-W9n0n39E.js";
3
+ import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-BlBDCOfS.js";
4
4
 
5
5
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
@@ -1,4 +1,4 @@
1
- import { VersionManagerImpl, createVersionManager } from "./dist-CW4d4JMj.js";
1
+ import { VersionManagerImpl, createVersionManager } from "./dist-Bc0-6VcX.js";
2
2
  import "./version-manager-impl-qFBiO4Eh.js";
3
3
 
4
4
  export { createVersionManager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.20.114",
3
+ "version": "0.20.116",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- import { AdapterRegistry } from "./dist-CW4d4JMj.js";
2
- import "./adapter-registry-DIcrxjH8.js";
3
-
4
- export { AdapterRegistry };