substrate-ai 0.20.53 → 0.20.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorMetrics } from "../health-sQ1X_5_6.js";
2
+ import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics } from "../health-PSnpYDAa.js";
3
3
  import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
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, 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-VcMmfo2w.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, runProbeAuthor, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BxDi30CG.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, runProbeAuthor, runSolutioningPhase, validateStopAfterFromConflict } from "../run-CeaNSnD6.js";
8
8
  import "../errors-CogpxBUg.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
@@ -3667,7 +3667,7 @@ async function runStatusAction(options) {
3667
3667
  logger$13.debug({ err }, "Work graph query failed, continuing without work graph data");
3668
3668
  }
3669
3669
  if (run === void 0) {
3670
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-BQ5dj53s.js");
3670
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-BdsvEnfm.js");
3671
3671
  const substrateDirPath = join(projectRoot, ".substrate");
3672
3672
  const processInfo = inspectProcessTree$1({
3673
3673
  projectRoot,
@@ -5204,7 +5204,7 @@ async function runSupervisorAction(options, deps = {}) {
5204
5204
  await initSchema(expAdapter);
5205
5205
  const { runRunAction: runPipeline } = await import(
5206
5206
  /* @vite-ignore */
5207
- "../run-7s_WEIAe.js"
5207
+ "../run-CkFWtcjl.js"
5208
5208
  );
5209
5209
  const runStoryFn = async (opts) => {
5210
5210
  const exitCode = await runPipeline({
@@ -5558,7 +5558,7 @@ function printFactoryRunTable(runs) {
5558
5558
  }
5559
5559
  }
5560
5560
  async function runMetricsAction(options) {
5561
- const { outputFormat, projectRoot, limit = 10, compare, tagBaseline, analysis, sprint, story, taskType, since, aggregate, efficiency, recommendations, turns, consumers, categories, compareStories, routingRecommendations, run, factory, probeAuthorSummary } = options;
5561
+ const { outputFormat, projectRoot, limit = 10, compare, tagBaseline, analysis, sprint, story, taskType, since, aggregate, efficiency, recommendations, turns, consumers, categories, compareStories, routingRecommendations, run, factory, probeAuthorSummary, probeAuthorClassSummary } = options;
5562
5562
  const telemetryModes = [
5563
5563
  efficiency,
5564
5564
  recommendations,
@@ -5970,6 +5970,7 @@ async function runMetricsAction(options) {
5970
5970
  const verificationRanByStoryRun = new Map();
5971
5971
  const probeAuthorByStoryRun = new Map();
5972
5972
  const findingsByAuthorByStoryRun = new Map();
5973
+ const probeAuthorTriggeredByStoryRun = new Map();
5973
5974
  const uniqueRunIds = Array.from(new Set(storyMetrics.map((sm) => sm.run_id).filter((id) => id !== "")));
5974
5975
  for (const uniqueRunId of uniqueRunIds) try {
5975
5976
  const { manifest } = await resolveRunManifest(dbRoot, uniqueRunId);
@@ -5981,6 +5982,7 @@ async function runMetricsAction(options) {
5981
5982
  verificationRanByStoryRun.set(key, entry.verification_result !== void 0 && entry.verification_result !== null);
5982
5983
  probeAuthorByStoryRun.set(key, rollupProbeAuthorMetrics(entry.verification_result));
5983
5984
  findingsByAuthorByStoryRun.set(key, rollupFindingsByAuthor(entry.verification_result));
5985
+ if (entry.probe_author_triggered_by !== void 0) probeAuthorTriggeredByStoryRun.set(key, entry.probe_author_triggered_by);
5984
5986
  }
5985
5987
  } catch {}
5986
5988
  let factoryRuns = [];
@@ -6019,6 +6021,16 @@ async function runMetricsAction(options) {
6019
6021
  const aggregate$1 = aggregateProbeAuthorMetrics(allMetrics, storyMetricsWithFindings.length);
6020
6022
  jsonPayload.probe_author_summary = aggregate$1;
6021
6023
  }
6024
+ if (probeAuthorClassSummary) {
6025
+ const classSummaryEntries = storyMetricsWithFindings.map((sm) => {
6026
+ const key = `${sm.story_key}:${sm.run_id}`;
6027
+ return {
6028
+ metrics: sm.probe_author,
6029
+ triggered_by: probeAuthorTriggeredByStoryRun.get(key)
6030
+ };
6031
+ });
6032
+ jsonPayload.probe_author_class_summary = rollupProbeAuthorByClass(classSummaryEntries);
6033
+ }
6022
6034
  if (doltMetrics !== void 0) if (aggregate) {
6023
6035
  const aggregateResults = doltMetrics.map((m) => ({
6024
6036
  task_type: m.taskType,
@@ -6124,7 +6136,7 @@ async function runMetricsAction(options) {
6124
6136
  }
6125
6137
  }
6126
6138
  function registerMetricsCommand(program, _version = "0.0.0", projectRoot = process.cwd()) {
6127
- program.command("metrics").description("Show historical pipeline run metrics and cross-run comparison").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--limit <n>", "Number of runs to show (default: 10)", (v) => parseInt(v, 10), 10).option("--compare <run-id-a,run-id-b>", "Compare two runs side-by-side (comma-separated IDs, e.g. abc123,def456)").option("--tag-baseline <run-id>", "Mark a run as the performance baseline").option("--analysis <run-id>", "Read and output the analysis report for the specified run (AC5 of Story 17-3)").option("--sprint <sprint>", "Filter StateStore metrics by sprint (e.g. sprint-1)").option("--story <story-key>", "Filter StateStore metrics by story key (e.g. 26-1)").option("--task-type <type>", "Filter StateStore metrics by task type (e.g. dev-story)").option("--since <iso-date>", "Filter StateStore metrics at or after this ISO timestamp").option("--aggregate", "Aggregate StateStore metrics grouped by task_type").option("--efficiency", "Show telemetry efficiency scores for recent stories").option("--recommendations", "Show all telemetry recommendations across stories").option("--turns <storyKey>", "Show per-turn analysis for a specific story").option("--consumers <storyKey>", "Show consumer stats for a specific story").option("--categories", "Show category stats (optionally scoped by --story <storyKey>)").option("--compare-stories <storyA,storyB>", "Compare efficiency scores of two stories side-by-side (comma-separated keys)").option("--routing-recommendations", "Show routing recommendations derived from phase token breakdown history").option("--run <run-id>", "Show per-iteration score history for a specific factory run").option("--factory", "Show only factory graph run metrics (excludes SDLC runs)").option("--probe-author-summary", "Print cross-run probe-author KPI aggregate (Story 60-15)").action(async (opts) => {
6139
+ program.command("metrics").description("Show historical pipeline run metrics and cross-run comparison").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--limit <n>", "Number of runs to show (default: 10)", (v) => parseInt(v, 10), 10).option("--compare <run-id-a,run-id-b>", "Compare two runs side-by-side (comma-separated IDs, e.g. abc123,def456)").option("--tag-baseline <run-id>", "Mark a run as the performance baseline").option("--analysis <run-id>", "Read and output the analysis report for the specified run (AC5 of Story 17-3)").option("--sprint <sprint>", "Filter StateStore metrics by sprint (e.g. sprint-1)").option("--story <story-key>", "Filter StateStore metrics by story key (e.g. 26-1)").option("--task-type <type>", "Filter StateStore metrics by task type (e.g. dev-story)").option("--since <iso-date>", "Filter StateStore metrics at or after this ISO timestamp").option("--aggregate", "Aggregate StateStore metrics grouped by task_type").option("--efficiency", "Show telemetry efficiency scores for recent stories").option("--recommendations", "Show all telemetry recommendations across stories").option("--turns <storyKey>", "Show per-turn analysis for a specific story").option("--consumers <storyKey>", "Show consumer stats for a specific story").option("--categories", "Show category stats (optionally scoped by --story <storyKey>)").option("--compare-stories <storyA,storyB>", "Compare efficiency scores of two stories side-by-side (comma-separated keys)").option("--routing-recommendations", "Show routing recommendations derived from phase token breakdown history").option("--run <run-id>", "Show per-iteration score history for a specific factory run").option("--factory", "Show only factory graph run metrics (excludes SDLC runs)").option("--probe-author-summary", "Print cross-run probe-author KPI aggregate (Story 60-15)").option("--probe-author-class-summary", "Print cross-run probe-author KPI aggregate broken down by trigger class (Story 65-6)").action(async (opts) => {
6128
6140
  const outputFormat = opts.outputFormat === "json" ? "json" : "human";
6129
6141
  let compareIds;
6130
6142
  if (opts.compare !== void 0) {
@@ -6162,7 +6174,8 @@ function registerMetricsCommand(program, _version = "0.0.0", projectRoot = proce
6162
6174
  ...opts.routingRecommendations !== void 0 && { routingRecommendations: opts.routingRecommendations },
6163
6175
  ...opts.run !== void 0 && { run: opts.run },
6164
6176
  ...opts.factory !== void 0 && { factory: opts.factory },
6165
- ...opts.probeAuthorSummary !== void 0 && { probeAuthorSummary: opts.probeAuthorSummary }
6177
+ ...opts.probeAuthorSummary !== void 0 && { probeAuthorSummary: opts.probeAuthorSummary },
6178
+ ...opts.probeAuthorClassSummary !== void 0 && { probeAuthorClassSummary: opts.probeAuthorClassSummary }
6166
6179
  };
6167
6180
  const exitCode = await runMetricsAction(metricsOpts);
6168
6181
  process.exitCode = exitCode;
@@ -1,4 +1,4 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-sQ1X_5_6.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-PSnpYDAa.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./dist-VcMmfo2w.js";
4
4
  import "./decisions-C0pz9Clx.js";
@@ -5300,7 +5300,13 @@ const PerStoryStateSchema = z.object({
5300
5300
  review_cycles: z.number().int().nonnegative().optional(),
5301
5301
  dispatches: z.number().int().nonnegative().optional(),
5302
5302
  retry_count: z.number().int().nonnegative().optional(),
5303
- dev_story_signals: StoredDevStorySignalsSchema.optional()
5303
+ dev_story_signals: StoredDevStorySignalsSchema.optional(),
5304
+ probe_author_triggered_by: z.union([
5305
+ z.literal("event-driven"),
5306
+ z.literal("state-integrating"),
5307
+ z.literal("both"),
5308
+ z.string()
5309
+ ]).optional()
5304
5310
  });
5305
5311
 
5306
5312
  //#endregion
@@ -6120,6 +6126,37 @@ function aggregateProbeAuthorMetrics(perStory, totalStories) {
6120
6126
  catchRateByConfirmedDefect: authored > 0 ? confirmed / authored : 0
6121
6127
  };
6122
6128
  }
6129
+ /**
6130
+ * Group entries by `triggered_by` class and compute a `ProbeAuthorAggregate`
6131
+ * for each class. Entries without a `triggered_by` field (legacy/pre-65-6)
6132
+ * default to the `'event-driven'` class per the backward-compat rule.
6133
+ *
6134
+ * Story 65-6: powers `substrate metrics --probe-author-class-summary`.
6135
+ *
6136
+ * @param entries - Array of objects carrying a per-story `metrics` rollup and
6137
+ * an optional `triggered_by` class string (from the manifest's
6138
+ * `probe_author_triggered_by` field).
6139
+ * @returns A record keyed by each of the three known trigger classes, each
6140
+ * value being the `aggregateProbeAuthorMetrics` output for that class's
6141
+ * stories. Classes with no stories still appear with zero aggregates.
6142
+ */
6143
+ function rollupProbeAuthorByClass(entries) {
6144
+ const groups = {
6145
+ "event-driven": [],
6146
+ "state-integrating": [],
6147
+ both: []
6148
+ };
6149
+ for (const entry of entries) {
6150
+ const cls = entry.triggered_by ?? "event-driven";
6151
+ const bucket = cls === "state-integrating" ? "state-integrating" : cls === "both" ? "both" : "event-driven";
6152
+ groups[bucket].push(entry.metrics);
6153
+ }
6154
+ return {
6155
+ "event-driven": aggregateProbeAuthorMetrics(groups["event-driven"], groups["event-driven"].length),
6156
+ "state-integrating": aggregateProbeAuthorMetrics(groups["state-integrating"], groups["state-integrating"].length),
6157
+ both: aggregateProbeAuthorMetrics(groups["both"], groups["both"].length)
6158
+ };
6159
+ }
6123
6160
  /** Extract the probe name from a runtime-probe finding's message. The
6124
6161
  * runtime-probe-check formatter writes `probe "<name>"...` as the leading
6125
6162
  * pattern across all category branches (fail/timeout/assertion-fail/
@@ -6874,5 +6911,5 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
6874
6911
  }
6875
6912
 
6876
6913
  //#endregion
6877
- export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, RuntimeProbeListSchema, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN$1 as STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, __commonJS, __require, __toESM, aggregateProbeAuthorMetrics, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, createStateStore, detectCycles, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, renderFindings, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorMetrics, runHealthAction, validateStoryKey };
6878
- //# sourceMappingURL=health-sQ1X_5_6.js.map
6914
+ export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, RuntimeProbeListSchema, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN$1 as STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, __commonJS, __require, __toESM, aggregateProbeAuthorMetrics, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, createStateStore, detectCycles, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, renderFindings, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runHealthAction, validateStoryKey };
6915
+ //# sourceMappingURL=health-PSnpYDAa.js.map
package/dist/index.d.ts CHANGED
@@ -2126,13 +2126,19 @@ interface OrchestratorEvents {
2126
2126
  */
2127
2127
  /** Probe-author dispatch completed for a story (success or skip-after-
2128
2128
  * re-read). Existing event emitted by 60-13's runProbeAuthor; 60-15
2129
- * formalizes the schema as part of the lifecycle event family. */
2129
+ * formalizes the schema as part of the lifecycle event family.
2130
+ * Story 65-6: `triggered_by` discriminates event-driven vs. state-integrating
2131
+ * dispatch class. Absent on legacy events — consumers default to
2132
+ * `'event-driven'` per backward-compat rule. */
2130
2133
  'probe-author:dispatched': {
2131
2134
  storyKey: string;
2132
2135
  runId: string;
2133
2136
  probesAuthoredCount: number;
2134
2137
  dispatchDurationMs: number;
2135
2138
  costUsd: number;
2139
+ /** Story 65-6: trigger-class discriminator. Absent on pre-Phase-3 events;
2140
+ * consumers MUST default to `'event-driven'` when absent. */
2141
+ triggered_by?: string;
2136
2142
  };
2137
2143
  /** Probe-author agent's YAML output successfully parsed. Counts probes
2138
2144
  * authored before any append/idempotency check. */
@@ -1,4 +1,4 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, RuntimeProbeListSchema, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectCycles, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, renderFindings, resolveGraphPath, resolveMainRepoRoot, validateStoryKey } from "./health-sQ1X_5_6.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, FindingsInjector, RunManifest, RuntimeProbeListSchema, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, applyConfigToGraph, buildPipelineStatusOutput, createDatabaseAdapter, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectCycles, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, renderFindings, resolveGraphPath, resolveMainRepoRoot, validateStoryKey } from "./health-PSnpYDAa.js";
2
2
  import { createLogger } from "./logger-KeHncl-f.js";
3
3
  import { TypedEventBusImpl, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-CElYrONe.js";
4
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-VcMmfo2w.js";
@@ -8448,12 +8448,13 @@ const TIMEOUT_RETRY_MULTIPLIER = 1.5;
8448
8448
  */
8449
8449
  async function runProbeAuthor(deps, params) {
8450
8450
  const start = Date.now();
8451
- const { storyKey, storyFilePath, pipelineRunId, sourceAcContent, epicContent, emitEvent, bypassGates } = params;
8451
+ const { storyKey, storyFilePath, pipelineRunId, sourceAcContent, epicContent, emitEvent, bypassGates, stateIntegratingEnabled, triggerClass } = params;
8452
8452
  const tokenUsage = {
8453
8453
  input: 0,
8454
8454
  output: 0
8455
8455
  };
8456
- if (bypassGates !== true && !detectsEventDrivenAC(epicContent) && !detectsStateIntegratingAC(epicContent)) {
8456
+ const stateIntegratingActive = stateIntegratingEnabled !== false;
8457
+ if (bypassGates !== true && !detectsEventDrivenAC(epicContent) && !(stateIntegratingActive && detectsStateIntegratingAC(epicContent))) {
8457
8458
  logger$14.debug({ storyKey }, "probe-author: source AC neither event-driven nor state-integrating — skipping");
8458
8459
  emitEvent?.("probe-author:skipped", {
8459
8460
  storyKey,
@@ -8660,7 +8661,8 @@ async function runProbeAuthor(deps, params) {
8660
8661
  runId: pipelineRunId,
8661
8662
  probesAuthoredCount: 0,
8662
8663
  dispatchDurationMs: dispatchDurationMs$1,
8663
- costUsd: estimateDispatchCost$1(tokenUsage.input, tokenUsage.output)
8664
+ costUsd: estimateDispatchCost$1(tokenUsage.input, tokenUsage.output),
8665
+ triggered_by: triggerClass ?? "event-driven"
8664
8666
  });
8665
8667
  return makeSkippedResult(tokenUsage, start);
8666
8668
  }
@@ -8702,7 +8704,8 @@ async function runProbeAuthor(deps, params) {
8702
8704
  runId: pipelineRunId,
8703
8705
  probesAuthoredCount: probes.length,
8704
8706
  dispatchDurationMs,
8705
- costUsd
8707
+ costUsd,
8708
+ triggered_by: triggerClass ?? "event-driven"
8706
8709
  });
8707
8710
  logger$14.info({
8708
8711
  storyKey,
@@ -13467,7 +13470,15 @@ function createImplementationOrchestrator(deps) {
13467
13470
  const section = extractStorySection(epicFull, storyKey);
13468
13471
  probeAuthorEpicContent = section ?? epicFull;
13469
13472
  } catch {}
13470
- if (detectsEventDrivenAC(probeAuthorEpicContent) || detectsStateIntegratingAC(probeAuthorEpicContent)) {
13473
+ const stateIntegratingEnabled = config.probeAuthorStateIntegrating !== false;
13474
+ const isEventDriven = detectsEventDrivenAC(probeAuthorEpicContent);
13475
+ const isStateIntegrating = stateIntegratingEnabled && detectsStateIntegratingAC(probeAuthorEpicContent);
13476
+ if (isEventDriven || isStateIntegrating) {
13477
+ const triggerClass = isEventDriven && isStateIntegrating ? "both" : isStateIntegrating ? "state-integrating" : "event-driven";
13478
+ if (runManifest !== null && runManifest !== void 0) runManifest.patchStoryState(storyKey, { probe_author_triggered_by: triggerClass }).catch((err) => logger$26.warn({
13479
+ err,
13480
+ storyKey
13481
+ }, "patchStoryState(probe_author_triggered_by) failed — pipeline continues"));
13471
13482
  let artifactHasProbes = false;
13472
13483
  try {
13473
13484
  const artifactContent = readFileSync(storyFilePath, "utf-8");
@@ -13489,6 +13500,8 @@ function createImplementationOrchestrator(deps) {
13489
13500
  pipelineRunId: config.pipelineRunId ?? "",
13490
13501
  sourceAcContent: probeAuthorEpicContent,
13491
13502
  epicContent: probeAuthorEpicContent,
13503
+ stateIntegratingEnabled,
13504
+ triggerClass,
13492
13505
  emitEvent: (name, payload) => {
13493
13506
  eventBus.emit("orchestrator:story-warn", {
13494
13507
  storyKey,
@@ -44004,8 +44017,23 @@ function wireNdjsonEmitter(eventBus, ndjsonEmitter) {
44004
44017
  });
44005
44018
  });
44006
44019
  }
44020
+ /**
44021
+ * Resolve the `probeAuthorStateIntegrating` boolean from CLI flag and env var.
44022
+ *
44023
+ * Precedence: CLI flag (`on`/`off`) > env var `SUBSTRATE_PROBE_AUTHOR_STATE_INTEGRATING`
44024
+ * (`on`/`off`) > default `true`.
44025
+ *
44026
+ * @param cliFlag - The value of `--probe-author-state-integrating` CLI flag, or undefined
44027
+ * @returns `true` when state-integrating dispatch is enabled, `false` when disabled
44028
+ */
44029
+ function resolveProbeAuthorStateIntegrating(cliFlag) {
44030
+ if (cliFlag !== void 0) return cliFlag === "on";
44031
+ const envVal = process.env["SUBSTRATE_PROBE_AUTHOR_STATE_INTEGRATING"];
44032
+ if (envVal !== void 0) return envVal === "on";
44033
+ return true;
44034
+ }
44007
44035
  async function runRunAction(options) {
44008
- const { pack: packName, from: startPhase, stopAfter, concept: conceptArg, conceptFile, stories: storiesArg, concurrency, outputFormat, projectRoot, events: eventsFlag, verbose: verboseFlag, tui: tuiFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, skipVerification, epic: epicNumber, dryRun, maxReviewCycles = 2, engine, agent: agentId, registry: injectedRegistry, haltOn, costCeiling, probeAuthor } = options;
44036
+ const { pack: packName, from: startPhase, stopAfter, concept: conceptArg, conceptFile, stories: storiesArg, concurrency, outputFormat, projectRoot, events: eventsFlag, verbose: verboseFlag, tui: tuiFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, skipVerification, epic: epicNumber, dryRun, maxReviewCycles = 2, engine, agent: agentId, registry: injectedRegistry, haltOn, costCeiling, probeAuthor, probeAuthorStateIntegrating: probeAuthorStateIntegratingFlag } = options;
44009
44037
  const VALID_PROBE_AUTHOR_MODES = [
44010
44038
  "enabled",
44011
44039
  "disabled",
@@ -44017,6 +44045,14 @@ async function runRunAction(options) {
44017
44045
  else process.stderr.write(`Error: ${errorMsg}\n`);
44018
44046
  return 1;
44019
44047
  }
44048
+ const VALID_PROBE_AUTHOR_STATE_INTEGRATING = ["on", "off"];
44049
+ if (probeAuthorStateIntegratingFlag !== void 0 && !VALID_PROBE_AUTHOR_STATE_INTEGRATING.includes(probeAuthorStateIntegratingFlag)) {
44050
+ const errorMsg = `Invalid --probe-author-state-integrating value '${probeAuthorStateIntegratingFlag}'. Valid values: on | off`;
44051
+ if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, errorMsg) + "\n");
44052
+ else process.stderr.write(`Error: ${errorMsg}\n`);
44053
+ return 1;
44054
+ }
44055
+ const resolvedProbeAuthorStateIntegrating = resolveProbeAuthorStateIntegrating(probeAuthorStateIntegratingFlag);
44020
44056
  const VALID_HALT_ON = [
44021
44057
  "all",
44022
44058
  "critical",
@@ -44212,6 +44248,7 @@ async function runRunAction(options) {
44212
44248
  meshProjectId
44213
44249
  } : {},
44214
44250
  ...probeAuthor !== void 0 ? { probeAuthor } : {},
44251
+ probeAuthorStateIntegrating: resolvedProbeAuthorStateIntegrating,
44215
44252
  engineType: resolvedEngine,
44216
44253
  maxReviewCycles: effectiveMaxReviewCycles,
44217
44254
  retryBudget: configRetryBudget ?? 2,
@@ -44750,7 +44787,8 @@ async function runRunAction(options) {
44750
44787
  enableHeartbeat: eventsFlag === true,
44751
44788
  skipPreflight: skipPreflight === true,
44752
44789
  ...skipVerification === true ? { skipVerification: true } : {},
44753
- ...probeAuthor !== void 0 ? { probeAuthorMode: probeAuthor } : {}
44790
+ ...probeAuthor !== void 0 ? { probeAuthorMode: probeAuthor } : {},
44791
+ probeAuthorStateIntegrating: resolvedProbeAuthorStateIntegrating
44754
44792
  },
44755
44793
  projectRoot,
44756
44794
  tokenCeilings,
@@ -44881,7 +44919,7 @@ async function runRunAction(options) {
44881
44919
  }
44882
44920
  }
44883
44921
  async function runFullPipeline(options) {
44884
- const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, projectRoot, events: eventsFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, skipVerification, maxReviewCycles = 2, retryBudget, registry: injectedRegistry, tokenCeilings, stories: explicitStories, telemetryEnabled: fullTelemetryEnabled, telemetryPort: fullTelemetryPort, agentId, meshUrl: fpMeshUrl, meshProjectId: fpMeshProjectId, engineType: fpEngineType, probeAuthor } = options;
44922
+ const { packName, packPath, dbDir, dbPath, startPhase, stopAfter, concept, concurrency, outputFormat, projectRoot, events: eventsFlag, skipUx, research: researchFlag, skipResearch: skipResearchFlag, skipPreflight, skipVerification, maxReviewCycles = 2, retryBudget, registry: injectedRegistry, tokenCeilings, stories: explicitStories, telemetryEnabled: fullTelemetryEnabled, telemetryPort: fullTelemetryPort, agentId, meshUrl: fpMeshUrl, meshProjectId: fpMeshProjectId, engineType: fpEngineType, probeAuthor, probeAuthorStateIntegrating: fpProbeAuthorStateIntegrating } = options;
44885
44923
  if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
44886
44924
  let doltServerFull = null;
44887
44925
  try {
@@ -45183,7 +45221,8 @@ async function runFullPipeline(options) {
45183
45221
  pipelineRunId: runId,
45184
45222
  skipPreflight: skipPreflight === true,
45185
45223
  ...skipVerification === true ? { skipVerification: true } : {},
45186
- ...probeAuthor !== void 0 ? { probeAuthorMode: probeAuthor } : {}
45224
+ ...probeAuthor !== void 0 ? { probeAuthorMode: probeAuthor } : {},
45225
+ ...fpProbeAuthorStateIntegrating !== void 0 ? { probeAuthorStateIntegrating: fpProbeAuthorStateIntegrating } : {}
45187
45226
  },
45188
45227
  projectRoot,
45189
45228
  tokenCeilings,
@@ -45339,7 +45378,7 @@ async function runFullPipeline(options) {
45339
45378
  }
45340
45379
  }
45341
45380
  function registerRunCommand(program, _version = "0.0.0", projectRoot = process.cwd(), registry) {
45342
- program.command("run").description("Run the autonomous pipeline (use --from to start from a specific phase)").option("--pack <name>", "Methodology pack name", "bmad").option("--from <phase>", "Start from this phase: analysis, planning, solutioning, implementation").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--concept <text>", "Inline concept text (required when --from analysis)").option("--concept-file <path>", "Path to a file containing the concept text").option("--stories <keys>", "Comma-separated story keys (e.g., 10-1,10-2)").option("--epic <n>", "Scope story discovery to a single epic number (e.g., 27)", (v) => parseInt(v, 10)).option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--verbose", "Show detailed pino log output").option("--help-agent", "Print a machine-optimized prompt fragment for AI agents and exit").option("--tui", "Show TUI dashboard").option("--skip-ux", "Skip the UX design phase even if enabled in the pack manifest").option("--research", "Enable the research phase even if not set in the pack manifest").option("--skip-research", "Skip the research phase even if enabled in the pack manifest").option("--skip-preflight", "Skip the pre-flight build check (escape hatch for known-broken projects)").option("--skip-verification", "Skip the post-dispatch verification pipeline (Story 51-5)").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).option("--dry-run", "Preview routing and repo-map injection without dispatching (Story 28-9)").option("--engine <type>", "Execution engine: linear (default) or graph").option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").option("--halt-on <severity>", "Halt pipeline on escalation severity: all | critical | none (default: none)", "none").option("--cost-ceiling <amount>", "Maximum cost ceiling in USD (positive number); halts pipeline when exceeded", parseFloat).option("--probe-author <mode>", "probe-author phase mode: enabled | disabled | auto (default: auto = SUBSTRATE_PROBE_AUTHOR_ENABLED env, default true) (Story 60-14)", "auto").action(async (opts) => {
45381
+ program.command("run").description("Run the autonomous pipeline (use --from to start from a specific phase)").option("--pack <name>", "Methodology pack name", "bmad").option("--from <phase>", "Start from this phase: analysis, planning, solutioning, implementation").option("--stop-after <phase>", "Stop pipeline after this phase completes").option("--concept <text>", "Inline concept text (required when --from analysis)").option("--concept-file <path>", "Path to a file containing the concept text").option("--stories <keys>", "Comma-separated story keys (e.g., 10-1,10-2)").option("--epic <n>", "Scope story discovery to a single epic number (e.g., 27)", (v) => parseInt(v, 10)).option("--concurrency <n>", "Maximum parallel conflict groups", (v) => parseInt(v, 10), 3).option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").option("--events", "Emit structured NDJSON events on stdout for programmatic consumption").option("--verbose", "Show detailed pino log output").option("--help-agent", "Print a machine-optimized prompt fragment for AI agents and exit").option("--tui", "Show TUI dashboard").option("--skip-ux", "Skip the UX design phase even if enabled in the pack manifest").option("--research", "Enable the research phase even if not set in the pack manifest").option("--skip-research", "Skip the research phase even if enabled in the pack manifest").option("--skip-preflight", "Skip the pre-flight build check (escape hatch for known-broken projects)").option("--skip-verification", "Skip the post-dispatch verification pipeline (Story 51-5)").option("--max-review-cycles <n>", "Maximum review cycles per story (default: 2)", (v) => parseInt(v, 10), 2).option("--dry-run", "Preview routing and repo-map injection without dispatching (Story 28-9)").option("--engine <type>", "Execution engine: linear (default) or graph").option("--agent <id>", "Agent backend: claude-code (default), codex, or gemini").option("--halt-on <severity>", "Halt pipeline on escalation severity: all | critical | none (default: none)", "none").option("--cost-ceiling <amount>", "Maximum cost ceiling in USD (positive number); halts pipeline when exceeded", parseFloat).option("--probe-author <mode>", "probe-author phase mode: enabled | disabled | auto (default: auto = SUBSTRATE_PROBE_AUTHOR_ENABLED env, default true) (Story 60-14)", "auto").option("--probe-author-state-integrating <value>", "Disable probe-author dispatch for state-integrating ACs (Phase 3). Use to ramp DOWN if catch rate drops below the GREEN threshold. Values: on | off (default: on)").action(async (opts) => {
45343
45382
  if (opts.helpAgent) {
45344
45383
  process.exitCode = await runHelpAgent();
45345
45384
  return;
@@ -45382,12 +45421,13 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
45382
45421
  registry,
45383
45422
  haltOn: opts.haltOn,
45384
45423
  costCeiling: opts.costCeiling,
45385
- probeAuthor: opts.probeAuthor
45424
+ probeAuthor: opts.probeAuthor,
45425
+ probeAuthorStateIntegrating: opts.probeAuthorStateIntegrating
45386
45426
  });
45387
45427
  process.exitCode = exitCode;
45388
45428
  });
45389
45429
  }
45390
45430
 
45391
45431
  //#endregion
45392
- 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, runProbeAuthor, runRunAction, runSolutioningPhase, validateStopAfterFromConflict, wireNdjsonEmitter };
45393
- //# sourceMappingURL=run-BxDi30CG.js.map
45432
+ 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, resolveProbeAuthorStateIntegrating, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runRunAction, runSolutioningPhase, validateStopAfterFromConflict, wireNdjsonEmitter };
45433
+ //# sourceMappingURL=run-CeaNSnD6.js.map
@@ -1,8 +1,8 @@
1
- import "./health-sQ1X_5_6.js";
1
+ import "./health-PSnpYDAa.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
4
  import "./dist-VcMmfo2w.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction, wireNdjsonEmitter } from "./run-BxDi30CG.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-CeaNSnD6.js";
6
6
  import "./routing-CcBOCuC9.js";
7
7
  import "./decisions-C0pz9Clx.js";
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.20.53",
3
+ "version": "0.20.55",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",