substrate-ai 0.19.41 → 0.19.43

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-sNh9XQ6V.js";
2
+ import "./adapter-registry-DXLMTmfD.js";
3
+
4
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest } from "../health-DMu0MJ-N.js";
2
+ import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest } from "../health-BbsWlD8o.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, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-BUcEqXA1.js";
5
+ import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-sNh9XQ6V.js";
6
6
  import "../adapter-registry-DXLMTmfD.js";
7
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-CoWvgK5U.js";
8
- import "../errors-BZnrgeyp.js";
7
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-kiI4y78c.js";
8
+ import "../errors-RupuC-ES.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
11
11
  import "../version-manager-impl-BmOWu8ml.js";
12
- import { registerUpgradeCommand } from "../upgrade-CABZfjn_.js";
12
+ import { registerUpgradeCommand } from "../upgrade-DfbgFpt7.js";
13
13
  import { Command } from "commander";
14
14
  import { fileURLToPath } from "url";
15
15
  import { dirname, join, resolve } from "path";
@@ -3307,7 +3307,7 @@ async function runStatusAction(options) {
3307
3307
  logger$12.debug({ err }, "Work graph query failed, continuing without work graph data");
3308
3308
  }
3309
3309
  if (run === void 0) {
3310
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-CINTkPJp.js");
3310
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-Cpjwxo7a.js");
3311
3311
  const substrateDirPath = join(projectRoot, ".substrate");
3312
3312
  const processInfo = inspectProcessTree$1({
3313
3313
  projectRoot,
@@ -4252,7 +4252,7 @@ function defaultSupervisorDeps() {
4252
4252
  if (cached === null) {
4253
4253
  const { AdapterRegistry: AR } = await import(
4254
4254
  /* @vite-ignore */
4255
- "../adapter-registry-l9wysBOr.js"
4255
+ "../adapter-registry-YfMckfe6.js"
4256
4256
  );
4257
4257
  cached = new AR();
4258
4258
  await cached.discoverAndRegister();
@@ -4819,11 +4819,11 @@ async function runSupervisorAction(options, deps = {}) {
4819
4819
  try {
4820
4820
  const { createExperimenter } = await import(
4821
4821
  /* @vite-ignore */
4822
- "../experimenter-DivOnzd-.js"
4822
+ "../experimenter-DNoVGyRd.js"
4823
4823
  );
4824
4824
  const { getLatestRun: getLatest } = await import(
4825
4825
  /* @vite-ignore */
4826
- "../decisions-Cy3hK4HO.js"
4826
+ "../decisions-CTif_DoZ.js"
4827
4827
  );
4828
4828
  const expAdapter = createDatabaseAdapter({
4829
4829
  backend: "auto",
@@ -4833,7 +4833,7 @@ async function runSupervisorAction(options, deps = {}) {
4833
4833
  await initSchema(expAdapter);
4834
4834
  const { runRunAction: runPipeline } = await import(
4835
4835
  /* @vite-ignore */
4836
- "../run-zR11kEEW.js"
4836
+ "../run-BzRTI2mg.js"
4837
4837
  );
4838
4838
  const runStoryFn = async (opts) => {
4839
4839
  const exitCode = await runPipeline({
@@ -5365,7 +5365,7 @@ async function runMetricsAction(options) {
5365
5365
  const routingConfigPath = join(dbDir, "routing.yml");
5366
5366
  let routingConfig = null;
5367
5367
  if (existsSync$1(routingConfigPath)) try {
5368
- const { loadModelRoutingConfig } = await import("../routing-CfkRvmSE.js");
5368
+ const { loadModelRoutingConfig } = await import("../routing-D1lKFBAo.js");
5369
5369
  routingConfig = loadModelRoutingConfig(routingConfigPath);
5370
5370
  } catch {}
5371
5371
  if (routingConfig === null) routingConfig = {
@@ -8620,8 +8620,8 @@ async function createProgram() {
8620
8620
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
8621
8621
  function checkForUpdatesInBackground(currentVersion) {
8622
8622
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
8623
- import("../upgrade-B5faf8E9.js").then(async () => {
8624
- const { createVersionManager } = await import("../version-manager-impl-C-lKxyO_.js");
8623
+ import("../upgrade-WEaQNIwC.js").then(async () => {
8624
+ const { createVersionManager } = await import("../version-manager-impl-Cd47GP0x.js");
8625
8625
  const vm = createVersionManager();
8626
8626
  const result = await vm.checkForUpdates();
8627
8627
  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-BUcEqXA1.js";
1
+ import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-sNh9XQ6V.js";
2
2
  import "./decisions-C0pz9Clx.js";
3
3
 
4
4
  export { getLatestRun };
@@ -1498,7 +1498,7 @@ function isSyncAdapter(adapter) {
1498
1498
  * Uses a duck-typed DoltClientLike interface to avoid cross-package imports.
1499
1499
  * All SQL operations are delegated to the client, which connects via mysql2
1500
1500
  * unix socket (primary) or dolt CLI (fallback).
1501
- * Transactions use explicit BEGIN / COMMIT / ROLLBACK statements.
1501
+ * Transactions delegate atomicity enforcement to DoltClientLike.transact().
1502
1502
  */
1503
1503
  var DoltDatabaseAdapter = class {
1504
1504
  backendType = "dolt";
@@ -1531,21 +1531,32 @@ var DoltDatabaseAdapter = class {
1531
1531
  /**
1532
1532
  * Execute a function within an explicit SQL transaction.
1533
1533
  *
1534
- * Issues `BEGIN` before the function and `COMMIT` on success or
1535
- * `ROLLBACK` on error. Works in both mysql2 pool mode (where
1536
- * transactions are natively supported) and CLI mode (where Dolt
1537
- * supports multi-statement sessions via CALL DOLT_CHECKOUT).
1534
+ * Delegates atomicity enforcement to `DoltClientLike.transact()`:
1535
+ * - Pool mode: acquires a dedicated connection, issues BEGIN/COMMIT on that
1536
+ * connection, preventing query scatter across the pool.
1537
+ * - CLI mode: collects all SQL statements and executes them as a single
1538
+ * `dolt sql -q "BEGIN; ...; COMMIT"` invocation.
1539
+ *
1540
+ * The `fn` callback receives a transaction-scoped `DatabaseAdapter` whose
1541
+ * `query()` and `exec()` are bound to the connection-bound query lambda.
1542
+ * Nested `transaction()` calls on the scoped adapter are pass-through
1543
+ * (no nested BEGIN).
1538
1544
  */
1539
1545
  async transaction(fn) {
1540
- await this._client.query("BEGIN", void 0);
1541
- try {
1542
- const result = await fn(this);
1543
- await this._client.query("COMMIT", void 0);
1544
- return result;
1545
- } catch (err) {
1546
- await this._client.query("ROLLBACK", void 0);
1547
- throw err;
1548
- }
1546
+ return this._client.transact(async (txQuery) => {
1547
+ const self = this;
1548
+ const txAdapter = {
1549
+ backendType: this.backendType,
1550
+ query: txQuery,
1551
+ exec: async (sql) => {
1552
+ await txQuery(sql, void 0);
1553
+ },
1554
+ transaction: async (innerFn) => innerFn(txAdapter),
1555
+ close: async () => {},
1556
+ queryReadyStories: () => self.queryReadyStories()
1557
+ };
1558
+ return fn(txAdapter);
1559
+ });
1549
1560
  }
1550
1561
  /**
1551
1562
  * Close the underlying DoltClient connection pool.
@@ -4502,6 +4513,73 @@ var DoltClient = class {
4502
4513
  if (this._useCliMode) return this._queryCli(sql, params, branch);
4503
4514
  return this._queryPool(sql, params, branch);
4504
4515
  }
4516
+ /**
4517
+ * Execute a function within an explicit SQL transaction, enforcing
4518
+ * atomicity in both pool mode and CLI mode.
4519
+ *
4520
+ * Pool mode: acquires a dedicated connection from the pool, executes
4521
+ * BEGIN/COMMIT on that connection, and passes a connection-bound query
4522
+ * lambda to `fn`. Connection is released in a `finally` block.
4523
+ *
4524
+ * CLI mode: collects all SQL statements issued within `fn()` via a
4525
+ * statement-collecting query lambda (returns [] immediately), then
4526
+ * executes the combined batch as a single `dolt sql -q "BEGIN; ...; COMMIT"`
4527
+ * invocation via `_withCliLock()`. This ensures atomicity for pure-write
4528
+ * transactions. NOTE: read-then-write patterns within `fn()` are not
4529
+ * supported in CLI mode — SELECT queries always return [] in the collector.
4530
+ * See Dev Notes in story 53-14 for documented call-site exceptions.
4531
+ */
4532
+ async transact(fn) {
4533
+ if (!this._connected) await this.connect();
4534
+ if (!this._useCliMode) {
4535
+ const conn = await this._pool.getConnection();
4536
+ try {
4537
+ await conn.execute("BEGIN");
4538
+ const txQuery = async (sql, params) => {
4539
+ try {
4540
+ const [rows] = await conn.execute(sql, params);
4541
+ return rows;
4542
+ } catch (err) {
4543
+ throw new DoltQueryError(sql, err instanceof Error ? err.message : String(err));
4544
+ }
4545
+ };
4546
+ const result = await fn(txQuery);
4547
+ await conn.execute("COMMIT");
4548
+ return result;
4549
+ } catch (err) {
4550
+ try {
4551
+ await conn.execute("ROLLBACK");
4552
+ } catch {}
4553
+ throw err;
4554
+ } finally {
4555
+ conn.release();
4556
+ }
4557
+ } else {
4558
+ const statements = [];
4559
+ const txQuery = async (sql, params) => {
4560
+ statements.push(this._resolveParams(sql, params));
4561
+ return [];
4562
+ };
4563
+ const result = await fn(txQuery);
4564
+ if (statements.length > 0) {
4565
+ const batchSql = `BEGIN; ${statements.join("; ")}; COMMIT`;
4566
+ await this._withCliLock(async () => {
4567
+ try {
4568
+ await runExecFile("dolt", [
4569
+ "sql",
4570
+ "-q",
4571
+ batchSql,
4572
+ "--result-format",
4573
+ "json"
4574
+ ], { cwd: this.repoPath });
4575
+ } catch (err) {
4576
+ throw new DoltQueryError(batchSql, err instanceof Error ? err.message : String(err));
4577
+ }
4578
+ });
4579
+ }
4580
+ return result;
4581
+ }
4582
+ }
4505
4583
  async _queryPool(sql, params, branch) {
4506
4584
  try {
4507
4585
  if (branch !== void 0 && branch !== "main") {
@@ -4535,18 +4613,23 @@ var DoltClient = class {
4535
4613
  });
4536
4614
  return prev.then(fn).finally(() => release());
4537
4615
  }
4616
+ /**
4617
+ * Substitute `?` placeholders in a SQL string with properly escaped literal
4618
+ * values from the `params` array. Used by both `_queryCli` and the CLI
4619
+ * `transact` path to produce a fully-resolved SQL string for shell execution.
4620
+ */
4621
+ _resolveParams(sql, params) {
4622
+ if (!params || params.length === 0) return sql;
4623
+ let i = 0;
4624
+ return sql.replace(/\?/g, () => {
4625
+ const val = params[i++];
4626
+ if (val === null || val === void 0) return "NULL";
4627
+ if (typeof val === "number") return String(val);
4628
+ return `'${String(val).replace(/'/g, "''")}'`;
4629
+ });
4630
+ }
4538
4631
  async _queryCli(sql, params, branch) {
4539
- let resolvedSql = sql;
4540
- if (params && params.length > 0) {
4541
- let i = 0;
4542
- resolvedSql = sql.replace(/\?/g, () => {
4543
- const val = params[i++];
4544
- if (val === null || val === void 0) return "NULL";
4545
- if (typeof val === "number") return String(val);
4546
- return `'${String(val).replace(/'/g, "''")}'`;
4547
- });
4548
- }
4549
- const finalSql = resolvedSql;
4632
+ const finalSql = this._resolveParams(sql, params);
4550
4633
  return this._withCliLock(async () => {
4551
4634
  try {
4552
4635
  const branchPrefix = branch ? `CALL DOLT_CHECKOUT('${branch.replace(/'/g, "''")}'); ` : "";
@@ -10808,4 +10891,4 @@ async function callLLM(params) {
10808
10891
 
10809
10892
  //#endregion
10810
10893
  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, 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, compareRunMetrics, createAmendmentRun, createConfigSystem, createDatabaseAdapter as createDatabaseAdapter$1, createDecision, createDoltClient, createExperimenter, createPipelineRun, createRequirement, 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, initializeDolt, listRequirements, listRunMetrics, loadModelRoutingConfig, loadParentRunDecisions, registerArtifact, resolvePromptFile, supersedeDecision, tagRunAsBaseline, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics };
10811
- //# sourceMappingURL=dist-BUcEqXA1.js.map
10894
+ //# sourceMappingURL=dist-sNh9XQ6V.js.map
@@ -1,4 +1,4 @@
1
- import { AdtError } from "./dist-BUcEqXA1.js";
1
+ import { AdtError } from "./dist-sNh9XQ6V.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-BZnrgeyp.js.map
74
+ //# sourceMappingURL=errors-RupuC-ES.js.map
@@ -1,3 +1,3 @@
1
- import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-BUcEqXA1.js";
1
+ import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-sNh9XQ6V.js";
2
2
 
3
3
  export { createExperimenter };
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { DoltClient, DoltQueryError, LEARNING_FINDING, createDatabaseAdapter$1 as createDatabaseAdapter, createDecision, getDecisionsByCategory, getLatestRun, getPipelineRunById, initSchema } from "./dist-BUcEqXA1.js";
2
+ import { DoltClient, DoltQueryError, LEARNING_FINDING, createDatabaseAdapter$1 as createDatabaseAdapter, createDecision, getDecisionsByCategory, getLatestRun, getPipelineRunById, initSchema } from "./dist-sNh9XQ6V.js";
3
3
  import { createRequire } from "module";
4
4
  import { dirname, join } from "path";
5
5
  import { readFile } from "fs/promises";
@@ -4253,4 +4253,4 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
4253
4253
 
4254
4254
  //#endregion
4255
4255
  export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN$1 as STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, createStateStore, detectCycles, extractTargetFilesFromStoryContent, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, runHealthAction, validateStoryKey };
4256
- //# sourceMappingURL=health-DMu0MJ-N.js.map
4256
+ //# sourceMappingURL=health-BbsWlD8o.js.map
@@ -1,6 +1,6 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-DMu0MJ-N.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-BbsWlD8o.js";
2
2
  import "./logger-KeHncl-f.js";
3
- import "./dist-BUcEqXA1.js";
3
+ import "./dist-sNh9XQ6V.js";
4
4
  import "./decisions-C0pz9Clx.js";
5
5
 
6
6
  export { inspectProcessTree };
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-BUcEqXA1.js";
3
+ import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-sNh9XQ6V.js";
4
4
  import "./adapter-registry-DXLMTmfD.js";
5
- import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-BZnrgeyp.js";
5
+ import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-RupuC-ES.js";
6
6
 
7
7
  //#region src/core/di.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-BUcEqXA1.js";
1
+ import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-sNh9XQ6V.js";
2
2
  import "./routing-CcBOCuC9.js";
3
3
 
4
4
  export { loadModelRoutingConfig };
@@ -1,8 +1,8 @@
1
- import "./health-DMu0MJ-N.js";
1
+ import "./health-BbsWlD8o.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
- import "./dist-BUcEqXA1.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction, wireNdjsonEmitter } from "./run-CoWvgK5U.js";
4
+ import "./dist-sNh9XQ6V.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction, wireNdjsonEmitter } from "./run-kiI4y78c.js";
6
6
  import "./routing-CcBOCuC9.js";
7
7
  import "./decisions-C0pz9Clx.js";
8
8
 
@@ -1,7 +1,7 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectCycles, extractTargetFilesFromStoryContent, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveGraphPath, resolveMainRepoRoot, validateStoryKey } from "./health-DMu0MJ-N.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectCycles, extractTargetFilesFromStoryContent, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveGraphPath, resolveMainRepoRoot, validateStoryKey } from "./health-BbsWlD8o.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, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-BUcEqXA1.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, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-sNh9XQ6V.js";
5
5
  import { basename, dirname, extname, join } from "path";
6
6
  import { access, readFile, readdir, stat } from "fs/promises";
7
7
  import { EventEmitter } from "node:events";
@@ -18448,6 +18448,36 @@ async function loadContractVerification(adapter, runId) {
18448
18448
  return void 0;
18449
18449
  }
18450
18450
  }
18451
+ async function loadEscalationDiagnoses(adapter, runId) {
18452
+ const results = {};
18453
+ try {
18454
+ const rows = await adapter.query(`SELECT key, value FROM decisions WHERE pipeline_run_id = ? AND category = 'escalation-diagnosis'`, [runId]);
18455
+ for (const row of rows) try {
18456
+ const parsed = JSON.parse(row.value);
18457
+ const storyKey = row.key.split(":")[0] ?? "unknown";
18458
+ const issueDescriptions = (parsed.issues ?? []).map((i) => i.description ? `[${i.severity ?? "unknown"}] ${i.description}` : "").filter(Boolean);
18459
+ results[storyKey] = {
18460
+ finding: {
18461
+ storyKey,
18462
+ ...parsed.totalIssues !== void 0 && { totalIssues: parsed.totalIssues },
18463
+ ...parsed.blockerCount !== void 0 && { blockerCount: parsed.blockerCount },
18464
+ ...parsed.majorCount !== void 0 && { majorCount: parsed.majorCount },
18465
+ ...parsed.minorCount !== void 0 && { minorCount: parsed.minorCount },
18466
+ ...parsed.issueDistribution && { issueDistribution: parsed.issueDistribution },
18467
+ ...parsed.severityProfile && { severityProfile: parsed.severityProfile },
18468
+ ...parsed.affectedFiles && parsed.affectedFiles.length > 0 && { affectedFiles: parsed.affectedFiles },
18469
+ ...parsed.recommendedAction && { recommendedAction: parsed.recommendedAction },
18470
+ ...parsed.rationale && { rationale: parsed.rationale }
18471
+ },
18472
+ reason: parsed.recommendedAction ?? "unknown",
18473
+ issues: issueDescriptions
18474
+ };
18475
+ } catch {}
18476
+ } catch {
18477
+ logger$2.debug("Could not query escalation-diagnosis decisions — skipping");
18478
+ }
18479
+ return results;
18480
+ }
18451
18481
  async function buildRunReport(adapter, runId, opts) {
18452
18482
  const runMetrics = await getRunMetrics(adapter, runId);
18453
18483
  if (!runMetrics) {
@@ -18461,6 +18491,7 @@ async function buildRunReport(adapter, runId, opts) {
18461
18491
  const verificationResults = await loadVerificationResults(runId, runsDir);
18462
18492
  const efficiencyScores = await loadEfficiencyScores(adapter, storyKeys);
18463
18493
  const contractVerification = await loadContractVerification(adapter, runId);
18494
+ const escalationDiagnoses = await loadEscalationDiagnoses(adapter, runId);
18464
18495
  const warnings = [];
18465
18496
  try {
18466
18497
  const warnRows = await adapter.query(`SELECT key, value FROM decisions WHERE pipeline_run_id = ? AND category = 'INTERFACE_WARNING'`, [runId]);
@@ -18509,16 +18540,23 @@ async function buildRunReport(adapter, runId, opts) {
18509
18540
  } catch {}
18510
18541
  const vr = verificationResults[s$1.story_key];
18511
18542
  const qualityScore = efficiencyScores[s$1.story_key];
18543
+ const escalation = escalationDiagnoses[s$1.story_key];
18512
18544
  return {
18513
18545
  storyKey: s$1.story_key,
18514
18546
  result: normalizeResult(s$1.result),
18515
18547
  wallClockSeconds: s$1.wall_clock_seconds,
18548
+ ...s$1.started_at && { startedAt: s$1.started_at },
18549
+ ...s$1.completed_at && { completedAt: s$1.completed_at },
18516
18550
  inputTokens: s$1.input_tokens,
18517
18551
  outputTokens: s$1.output_tokens,
18518
18552
  costUsd: s$1.cost_usd,
18519
18553
  reviewCycles: s$1.review_cycles,
18520
18554
  dispatches: s$1.dispatches,
18521
18555
  ...phaseDurations !== void 0 && { phaseDurations },
18556
+ ...escalation !== void 0 && {
18557
+ escalationReason: escalation.reason,
18558
+ ...escalation.issues.length > 0 && { escalationIssues: escalation.issues }
18559
+ },
18522
18560
  ...vr !== void 0 && {
18523
18561
  verificationStatus: vr.status,
18524
18562
  verificationChecks: vr.checks
@@ -18540,11 +18578,15 @@ async function buildRunReport(adapter, runId, opts) {
18540
18578
  const rawStatus = runMetrics.status.toLowerCase();
18541
18579
  const status = rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "partial";
18542
18580
  const projectId = opts.projectId ?? (opts.projectRoot ? basename$1(opts.projectRoot) : "unknown");
18581
+ const escalationFindings = Object.values(escalationDiagnoses).map((d) => d.finding);
18582
+ const timestamp = runMetrics.completed_at ?? new Date().toISOString();
18543
18583
  return {
18544
18584
  runId,
18545
18585
  projectId,
18546
18586
  substrateVersion: opts.substrateVersion ?? getSubstrateVersion(),
18547
- timestamp: new Date().toISOString(),
18587
+ timestamp,
18588
+ ...runMetrics.started_at && { startedAt: runMetrics.started_at },
18589
+ ...runMetrics.completed_at && { completedAt: runMetrics.completed_at },
18548
18590
  status,
18549
18591
  wallClockSeconds: runMetrics.wall_clock_seconds,
18550
18592
  totalInputTokens: runMetrics.total_input_tokens,
@@ -18558,12 +18600,14 @@ async function buildRunReport(adapter, runId, opts) {
18558
18600
  totalDispatches: runMetrics.total_dispatches,
18559
18601
  restarts: runMetrics.restarts,
18560
18602
  stories,
18603
+ ...escalationFindings.length > 0 && { escalationFindings },
18561
18604
  ...contractVerification !== void 0 && { contractVerification },
18562
18605
  ...warnings.length > 0 && { warnings },
18563
18606
  ...avgEfficiencyScore !== void 0 && { efficiencyScore: avgEfficiencyScore },
18564
18607
  agentBackend: opts.agentBackend ?? "claude-code",
18565
18608
  engineType: opts.engineType ?? "linear",
18566
- concurrency: opts.concurrency ?? runMetrics.concurrency_setting
18609
+ concurrency: opts.concurrency ?? runMetrics.concurrency_setting,
18610
+ ...runMetrics.max_concurrent_actual !== void 0 && runMetrics.max_concurrent_actual !== null && { maxConcurrentActual: runMetrics.max_concurrent_actual }
18567
18611
  };
18568
18612
  }
18569
18613
  /**
@@ -42750,4 +42794,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
42750
42794
 
42751
42795
  //#endregion
42752
42796
  export { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveMaxReviewCycles, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict, wireNdjsonEmitter };
42753
- //# sourceMappingURL=run-CoWvgK5U.js.map
42797
+ //# sourceMappingURL=run-kiI4y78c.js.map
@@ -1,4 +1,4 @@
1
- import { createVersionManager } from "./dist-BUcEqXA1.js";
1
+ import { createVersionManager } from "./dist-sNh9XQ6V.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-CABZfjn_.js.map
126
+ //# sourceMappingURL=upgrade-DfbgFpt7.js.map
@@ -1,5 +1,5 @@
1
- import "./dist-BUcEqXA1.js";
1
+ import "./dist-sNh9XQ6V.js";
2
2
  import "./version-manager-impl-BmOWu8ml.js";
3
- import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-CABZfjn_.js";
3
+ import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-DfbgFpt7.js";
4
4
 
5
5
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
@@ -1,4 +1,4 @@
1
- import { VersionManagerImpl, createVersionManager } from "./dist-BUcEqXA1.js";
1
+ import { VersionManagerImpl, createVersionManager } from "./dist-sNh9XQ6V.js";
2
2
  import "./version-manager-impl-BmOWu8ml.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.19.41",
3
+ "version": "0.19.43",
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-BUcEqXA1.js";
2
- import "./adapter-registry-DXLMTmfD.js";
3
-
4
- export { AdapterRegistry };