substrate-ai 0.21.3 → 0.21.4

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,17 +1,17 @@
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-Dnzblihr.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-BUl3y64N.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, createGitWorktreeManager, 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-CpnLJuVw.js";
6
6
  import "../adapter-registry-DXLMTmfD.js";
7
- import { JOURNEY_DEFERRALS_PATH, JOURNEY_REGISTRY_PATH, RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, loadJourneyRegistryFromFile, loadJourneyRegistryFromTrustedTree, parseJourneyDeferrals, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-B3gE46DX.js";
8
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-ZxFHQyE_.js";
7
+ import { ACCEPTANCE_CONTRACT_PROFILE_PATH, JOURNEY_DEFERRALS_PATH, JOURNEY_REGISTRY_PATH, RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, loadAcceptanceContractFromTrustedTree, loadJourneyRegistryFromFile, loadJourneyRegistryFromTrustedTree, parseAcceptanceContract, parseJourneyDeferrals, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-DZDlSq_s.js";
8
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-nSb1TD3o.js";
9
9
  import "../errors-8tVEwG6v.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-BAPpON_C.js";
14
- import "../interactive-prompt-BM5RaXYG.js";
14
+ import "../interactive-prompt-C4Is1QDB.js";
15
15
  import "../recovery-engine-BKGBeBnW.js";
16
16
  import "../version-manager-impl-qFBiO4Eh.js";
17
17
  import { registerUpgradeCommand } from "../upgrade-BUSzXgnd.js";
@@ -7130,7 +7130,7 @@ async function runStatusAction(options) {
7130
7130
  logger$15.debug({ err }, "Work graph query failed, continuing without work graph data");
7131
7131
  }
7132
7132
  if (run === void 0) {
7133
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-bhMCTYDO.js");
7133
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-DklP4Se9.js");
7134
7134
  const substrateDirPath = join(projectRoot, ".substrate");
7135
7135
  const processInfo = inspectProcessTree$1({
7136
7136
  projectRoot,
@@ -8659,7 +8659,7 @@ async function runSupervisorAction(options, deps = {}) {
8659
8659
  await initSchema(expAdapter);
8660
8660
  const { runRunAction: runPipeline } = await import(
8661
8661
  /* @vite-ignore */
8662
- "../run-ChZFveqv.js"
8662
+ "../run-CMXmzqoy.js"
8663
8663
  );
8664
8664
  const runStoryFn = async (opts) => {
8665
8665
  const exitCode = await runPipeline({
@@ -13474,15 +13474,33 @@ function registerAcceptanceCommand(program, version) {
13474
13474
  const projectRoot = process.cwd();
13475
13475
  const source = opts.ref !== void 0 ? `committed @ ${opts.ref}` : "working tree";
13476
13476
  const result = opts.ref !== void 0 ? await loadJourneyRegistryFromTrustedTree(projectRoot, opts.ref) : await loadJourneyRegistryFromFile(projectRoot);
13477
+ let contract;
13478
+ if (opts.ref !== void 0) contract = await loadAcceptanceContractFromTrustedTree(projectRoot, opts.ref);
13479
+ else try {
13480
+ const profileContent = await readFile$1(join$1(projectRoot, ACCEPTANCE_CONTRACT_PROFILE_PATH), "utf-8");
13481
+ contract = parseAcceptanceContract(profileContent);
13482
+ } catch {
13483
+ contract = { status: "absent" };
13484
+ }
13477
13485
  if (opts.outputFormat === "json") {
13478
13486
  const output = buildJsonOutput("substrate acceptance validate", {
13479
13487
  source,
13480
- ...result
13488
+ ...result,
13489
+ contract: { status: contract.status }
13481
13490
  }, version);
13482
13491
  process.stdout.write(JSON.stringify(output, null, 2) + "\n");
13483
13492
  process.exit(result.status === "ok" ? ACCEPTANCE_EXIT_SUCCESS : ACCEPTANCE_EXIT_ERROR);
13484
13493
  }
13485
- process.exit(renderHuman(result, source));
13494
+ const exitCode = renderHuman(result, source);
13495
+ if (contract.status === "ok") {
13496
+ const surfaces = Object.keys(contract.contract.surfaces).join(", ");
13497
+ process.stdout.write(`contract: OK — surfaces declared: ${surfaces}\n`);
13498
+ } else if (contract.status === "invalid") {
13499
+ process.stdout.write(`contract: INVALID (${ACCEPTANCE_CONTRACT_PROFILE_PATH} acceptance: block):\n`);
13500
+ for (const issue of contract.issues) process.stdout.write(` ${issue.path}: ${issue.message}\n`);
13501
+ } else if (contract.status === "absent") process.stdout.write(`contract: ABSENT — no acceptance: block in ${ACCEPTANCE_CONTRACT_PROFILE_PATH}. Claimed journeys can never be walked (acceptance-unrunnable in blocking mode).
13502
+ `);
13503
+ process.exit(exitCode);
13486
13504
  });
13487
13505
  acceptanceCmd.command("defer <journeyId>").description("Record an operator deferral for a journey — the coverage audit reports it `deferred` instead of unclaimed/unwalked. Writes to the working tree; COMMIT the file for the audit (trusted tree) to honor it.").requiredOption("--reason <text>", "why this journey is deferred (the operator ack is the point)").action(async (journeyId, opts) => {
13488
13506
  const projectRoot = process.cwd();
@@ -1,6 +1,6 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
2
  import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-CpnLJuVw.js";
3
- import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-B3gE46DX.js";
3
+ import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-DZDlSq_s.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-Dnzblihr.js.map
1003
+ //# sourceMappingURL=health-BUl3y64N.js.map
@@ -1,7 +1,7 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-Dnzblihr.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-BUl3y64N.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./dist-CpnLJuVw.js";
4
- import "./manifest-read-B3gE46DX.js";
4
+ import "./manifest-read-DZDlSq_s.js";
5
5
  import "./work-graph-repository-DZyJv5pV.js";
6
6
  import "./decisions-CzSIEeGP.js";
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-B3gE46DX.js";
2
+ import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-DZDlSq_s.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-BM5RaXYG.js.map
183
+ //# sourceMappingURL=interactive-prompt-C4Is1QDB.js.map
@@ -8,9 +8,10 @@ import { YAMLException, load } from "js-yaml";
8
8
  import { existsSync, promises, readFileSync, readdirSync, statSync } from "node:fs";
9
9
  import { execSync, spawn } from "node:child_process";
10
10
  import * as path$2 from "node:path";
11
- import { basename as basename$1, delimiter, dirname as dirname$1, join as join$1, resolve as resolve$1 } from "node:path";
11
+ import { basename as basename$1, delimiter, dirname as dirname$1, join as join$1, relative, resolve as resolve$1 } from "node:path";
12
+ import { createHash } from "node:crypto";
12
13
  import { z } from "zod";
13
- import { mkdir as mkdir$1, open, readFile as readFile$1, unlink as unlink$1, writeFile as writeFile$1 } from "node:fs/promises";
14
+ import { mkdir as mkdir$1, open, readFile as readFile$1, readdir as readdir$1, unlink as unlink$1, writeFile as writeFile$1 } from "node:fs/promises";
14
15
  import * as fs from "fs";
15
16
  import { createRequire } from "node:module";
16
17
  import { fileURLToPath } from "node:url";
@@ -5181,6 +5182,61 @@ function parseJourneyDeferrals(yamlContent) {
5181
5182
  };
5182
5183
  }
5183
5184
 
5185
+ //#endregion
5186
+ //#region packages/sdlc/dist/acceptance/contract.js
5187
+ /** The acceptance contract lives inside the project profile. */
5188
+ const ACCEPTANCE_CONTRACT_PROFILE_PATH = ".substrate/project-profile.yaml";
5189
+ const RenderSurfaceSchema = z.object({ render: z.string().min(1) }).strict();
5190
+ const WebSurfaceSchema = z.object({
5191
+ serve: z.string().min(1),
5192
+ ready: z.string().optional()
5193
+ }).strict();
5194
+ const AcceptanceContractSchema = z.object({
5195
+ fixtures: z.string().optional(),
5196
+ surfaces: z.object({
5197
+ email: RenderSurfaceSchema.optional(),
5198
+ cli: RenderSurfaceSchema.optional(),
5199
+ file: RenderSurfaceSchema.optional(),
5200
+ web: WebSurfaceSchema.optional()
5201
+ }).strict()
5202
+ }).strict();
5203
+ /**
5204
+ * Extract + validate the `acceptance:` block from project-profile YAML
5205
+ * content. `absent` when the profile has no block (legal — the coverage
5206
+ * audit escalates registry-present+contract-absent as acceptance-unrunnable
5207
+ * in blocking mode; pure accounting still works without one).
5208
+ */
5209
+ function parseAcceptanceContract(profileYamlContent) {
5210
+ let doc;
5211
+ try {
5212
+ doc = load(profileYamlContent);
5213
+ } catch (err) {
5214
+ const message = err instanceof YAMLException ? err.message : String(err);
5215
+ return {
5216
+ status: "invalid",
5217
+ issues: [{
5218
+ path: "(root)",
5219
+ message: `malformed profile YAML: ${message}`
5220
+ }]
5221
+ };
5222
+ }
5223
+ if (doc === null || doc === void 0 || typeof doc !== "object") return { status: "absent" };
5224
+ const block = doc["acceptance"];
5225
+ if (block === void 0 || block === null) return { status: "absent" };
5226
+ const result = AcceptanceContractSchema.safeParse(block);
5227
+ if (!result.success) return {
5228
+ status: "invalid",
5229
+ issues: result.error.issues.map((issue) => ({
5230
+ path: issue.path.length > 0 ? `acceptance.${issue.path.map(String).join(".")}` : "acceptance",
5231
+ message: issue.message
5232
+ }))
5233
+ };
5234
+ return {
5235
+ status: "ok",
5236
+ contract: result.data
5237
+ };
5238
+ }
5239
+
5184
5240
  //#endregion
5185
5241
  //#region packages/sdlc/dist/acceptance/loader.js
5186
5242
  /** stderr shapes that mean "the path is not in the tree at this ref" (absent, not an error). */
@@ -5286,6 +5342,26 @@ async function loadJourneyDeferralsFromTrustedTree(repoRoot, ref = "HEAD") {
5286
5342
  };
5287
5343
  }
5288
5344
  /**
5345
+ * Load the acceptance contract (the `acceptance:` block of the project
5346
+ * profile) from the trusted tree at `ref` (A1.1). Same H7 posture as the
5347
+ * registry: the agent-writable worktree copy of the profile is never read.
5348
+ */
5349
+ async function loadAcceptanceContractFromTrustedTree(repoRoot, ref = "HEAD") {
5350
+ const result = await runGitShow(repoRoot, ref, ACCEPTANCE_CONTRACT_PROFILE_PATH);
5351
+ if (result.spawnError !== void 0) return {
5352
+ status: "error",
5353
+ message: `git show could not be spawned: ${result.spawnError}`
5354
+ };
5355
+ if (result.code !== 0) {
5356
+ if (GIT_SHOW_ABSENT_PATTERNS.some((p) => p.test(result.stderr))) return { status: "absent" };
5357
+ return {
5358
+ status: "error",
5359
+ message: `git show ${ref}:${ACCEPTANCE_CONTRACT_PROFILE_PATH} failed (exit ${String(result.code)}): ${result.stderr.trim()}`
5360
+ };
5361
+ }
5362
+ return parseAcceptanceContract(result.stdout);
5363
+ }
5364
+ /**
5289
5365
  * Filesystem read for OPERATOR LINT ONLY (`substrate acceptance validate`).
5290
5366
  * Gate/judge code paths must use `loadJourneyRegistryFromTrustedTree`.
5291
5367
  */
@@ -6746,5 +6822,5 @@ async function resolveRunManifest(dbRoot, runId) {
6746
6822
  }
6747
6823
 
6748
6824
  //#endregion
6749
- export { FindingsInjector, JOURNEY_DEFERRALS_PATH, JOURNEY_REGISTRY_PATH, RunManifest, RuntimeProbeListSchema, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, applyConfigToGraph, computeJourneyCoverage, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, loadJourneyDeferralsFromTrustedTree, loadJourneyRegistryFromFile, loadJourneyRegistryFromTrustedTree, parseJourneyDeferrals, parseRuntimeProbes, parseStoryFrontmatter, readCurrentRunId, renderFindings, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck, runStaleVerificationRecovery, summarizeCoverage };
6750
- //# sourceMappingURL=manifest-read-B3gE46DX.js.map
6825
+ export { ACCEPTANCE_CONTRACT_PROFILE_PATH, FindingsInjector, JOURNEY_DEFERRALS_PATH, JOURNEY_REGISTRY_PATH, RunManifest, RuntimeProbeListSchema, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, applyConfigToGraph, computeJourneyCoverage, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, loadAcceptanceContractFromTrustedTree, loadJourneyDeferralsFromTrustedTree, loadJourneyRegistryFromFile, loadJourneyRegistryFromTrustedTree, parseAcceptanceContract, parseJourneyDeferrals, parseRuntimeProbes, parseStoryFrontmatter, readCurrentRunId, renderFindings, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck, runStaleVerificationRecovery, summarizeCoverage };
6826
+ //# sourceMappingURL=manifest-read-DZDlSq_s.js.map
@@ -1,6 +1,6 @@
1
1
  import "../../logger-KeHncl-f.js";
2
2
  import "../../dist-CpnLJuVw.js";
3
- import "../../manifest-read-B3gE46DX.js";
4
- import { runInteractivePrompt } from "../../interactive-prompt-BM5RaXYG.js";
3
+ import "../../manifest-read-DZDlSq_s.js";
4
+ import { runInteractivePrompt } from "../../interactive-prompt-C4Is1QDB.js";
5
5
 
6
6
  export { runInteractivePrompt };
@@ -1,14 +1,14 @@
1
- import "./health-Dnzblihr.js";
1
+ import "./health-BUl3y64N.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
4
  import "./dist-CpnLJuVw.js";
5
- import "./manifest-read-B3gE46DX.js";
6
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-ZxFHQyE_.js";
5
+ import "./manifest-read-DZDlSq_s.js";
6
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-nSb1TD3o.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-BAPpON_C.js";
11
- import "./interactive-prompt-BM5RaXYG.js";
11
+ import "./interactive-prompt-C4Is1QDB.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-Dnzblihr.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-BUl3y64N.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, BRANCH_PREFIX, CLAUDE_AUTH_FAILURE_HINT, CODEX_SANDBOX_BLOCK_HINT, 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, createGitWorktreeManager, createPipelineRun, createRequirement, detectClaudeAuthFailure, detectCodexSandboxBlock, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, swallowDebug, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-CpnLJuVw.js";
5
- import { FindingsInjector, JOURNEY_DEFERRALS_PATH, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, computeJourneyCoverage, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, loadJourneyDeferralsFromTrustedTree, loadJourneyRegistryFromTrustedTree, parseRuntimeProbes, parseStoryFrontmatter, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery, summarizeCoverage } from "./manifest-read-B3gE46DX.js";
5
+ import { ACCEPTANCE_CONTRACT_PROFILE_PATH, FindingsInjector, JOURNEY_DEFERRALS_PATH, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, computeJourneyCoverage, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, loadAcceptanceContractFromTrustedTree, loadJourneyDeferralsFromTrustedTree, loadJourneyRegistryFromTrustedTree, parseRuntimeProbes, parseStoryFrontmatter, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery, summarizeCoverage } from "./manifest-read-DZDlSq_s.js";
6
6
  import { WorkGraphRepository, detectCycles } from "./work-graph-repository-DZyJv5pV.js";
7
7
  import { deriveExitCode, routeDecision } from "./decision-router-BAPpON_C.js";
8
- import { runInteractivePrompt } from "./interactive-prompt-BM5RaXYG.js";
8
+ import { runInteractivePrompt } from "./interactive-prompt-C4Is1QDB.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";
@@ -983,7 +983,7 @@ const PIPELINE_EVENT_METADATA = [
983
983
  {
984
984
  name: "reason",
985
985
  type: "string",
986
- description: "Escalation reason. Common values: review-cycles-exhausted (default review-loop max hit); create-story-no-file (create-story phase did not write a story artifact); dev-story-no-commit (substrate auto-commit found no committable changes — agent produced nothing or all changes were outside the worktree); dev-story-commit-failed (substrate auto-commit failed — typically a pre-commit hook rejected the commit; stderr captured in issues); merge-to-main-error (unexpected error in the merge-to-main phase); merge-conflict-detected (story branch could not be merged due to conflicts); parent-tree-dirtied-by-run (uncommitted parent changes intersect the story diff — merge refused, H3.3); ff-only-merge-not-possible (base moved and merge_strategy is ff-only — set finalization.merge_strategy: three-way or integrate manually, H3.3); epic-gate-failed (finalization.epic_gate_command exited non-zero before the last story of an epic integrated, H3.4); story-file-missing (story artifact gone from working tree AND branch HEAD — check wip/feat commits on the story branch, H5.5); undisclosed-files-in-merge (a committed implementation file was never in the dev agent's files_modified, so no review cycle inspected it — inspect the branch, then re-dispatch with accurate files_modified or merge manually, H7); journey-unclaimed (acceptance.mode: blocking — a registered journey has NO story claiming it at epic close; wire it or defer via `substrate acceptance defer`, A0.3); journey-unwalked (acceptance.mode: blocking — a claimed journey was never walked by the acceptance gate at epic close, A0.3). v0.20.87+."
986
+ description: "Escalation reason. Common values: review-cycles-exhausted (default review-loop max hit); create-story-no-file (create-story phase did not write a story artifact); dev-story-no-commit (substrate auto-commit found no committable changes — agent produced nothing or all changes were outside the worktree); dev-story-commit-failed (substrate auto-commit failed — typically a pre-commit hook rejected the commit; stderr captured in issues); merge-to-main-error (unexpected error in the merge-to-main phase); merge-conflict-detected (story branch could not be merged due to conflicts); parent-tree-dirtied-by-run (uncommitted parent changes intersect the story diff — merge refused, H3.3); ff-only-merge-not-possible (base moved and merge_strategy is ff-only — set finalization.merge_strategy: three-way or integrate manually, H3.3); epic-gate-failed (finalization.epic_gate_command exited non-zero before the last story of an epic integrated, H3.4); story-file-missing (story artifact gone from working tree AND branch HEAD — check wip/feat commits on the story branch, H5.5); undisclosed-files-in-merge (a committed implementation file was never in the dev agent's files_modified, so no review cycle inspected it — inspect the branch, then re-dispatch with accurate files_modified or merge manually, H7); journey-unclaimed (acceptance.mode: blocking — a registered journey has NO story claiming it at epic close; wire it or defer via `substrate acceptance defer`, A0.3); journey-unwalked (acceptance.mode: blocking — a claimed journey was never walked by the acceptance gate at epic close, A0.3); acceptance-unrunnable (acceptance.mode: blocking — a journey registry exists but the committed acceptance contract/registry is absent or invalid, so claimed journeys can never be walked; declare an acceptance: block in the project profile, A1.1). v0.20.87+."
987
987
  },
988
988
  {
989
989
  name: "cycles",
@@ -13957,10 +13957,19 @@ function createImplementationOrchestrator(deps) {
13957
13957
  if (mode === "off" || projectRoot === void 0) return void 0;
13958
13958
  const registryLoad = await loadJourneyRegistryFromTrustedTree(projectRoot);
13959
13959
  if (registryLoad.status === "absent") return void 0;
13960
+ if (registryLoad.status === "invalid") return {
13961
+ entries: [],
13962
+ unrunnable: "journey registry is INVALID: " + registryLoad.issues.map((i) => `${i.path}: ${i.message}`).join("; ") + " — fix it (substrate acceptance validate) or the audit cannot run"
13963
+ };
13960
13964
  if (registryLoad.status !== "ok") {
13961
- logger$27.warn({ detail: registryLoad.status === "invalid" ? registryLoad.issues : registryLoad.message }, "A0.3: journey registry unreadable/invalid — coverage audit skipped (loud escalation for this is A1 acceptance-unrunnable scope)");
13965
+ logger$27.warn({ detail: registryLoad.message }, "A0.3: journey registry read failed — coverage audit skipped (environmental)");
13962
13966
  return void 0;
13963
13967
  }
13968
+ let unrunnable;
13969
+ const contractLoad = await loadAcceptanceContractFromTrustedTree(projectRoot);
13970
+ if (contractLoad.status === "absent") unrunnable = `journey registry exists but the committed project profile has no acceptance: contract block (${ACCEPTANCE_CONTRACT_PROFILE_PATH}) — claimed journeys can never be walked. Declare render commands per surface.`;
13971
+ else if (contractLoad.status === "invalid") unrunnable = "acceptance: contract block is INVALID: " + contractLoad.issues.map((i) => `${i.path}: ${i.message}`).join("; ");
13972
+ else if (contractLoad.status === "error") logger$27.warn({ detail: contractLoad.message }, "A1.1: acceptance contract read failed (environmental) — treating as absent for this audit");
13964
13973
  const deferralsLoad = await loadJourneyDeferralsFromTrustedTree(projectRoot);
13965
13974
  if (deferralsLoad.status !== "ok") logger$27.warn({ detail: deferralsLoad.status === "invalid" ? deferralsLoad.issues : deferralsLoad.message }, `A0.3: ${JOURNEY_DEFERRALS_PATH} unreadable/invalid — treating as no deferrals`);
13966
13975
  const deferredJourneyIds = deferralsLoad.status === "ok" ? deferralsLoad.deferrals.map((d) => d.journey) : [];
@@ -13983,8 +13992,12 @@ function createImplementationOrchestrator(deps) {
13983
13992
  entries,
13984
13993
  summary: summarizeCoverage(entries)
13985
13994
  });
13995
+ if (unrunnable !== void 0) logger$27.warn({ scope: scopeLabel }, `A1.1: acceptance gate unrunnable — ${unrunnable}`);
13986
13996
  if (opts?.persist === true && runManifest !== null) await runManifest.update({ journeys: entries }).catch((err) => logger$27.warn({ err }, "A0.3: manifest journeys ledger write failed — pipeline continues"));
13987
- return entries;
13997
+ return unrunnable !== void 0 ? {
13998
+ entries,
13999
+ unrunnable
14000
+ } : { entries };
13988
14001
  }
13989
14002
  function getStallThresholdMs(phase) {
13990
14003
  return phase === "IN_DEV" ? DEV_STORY_STALL_THRESHOLD_MS : DEFAULT_STALL_THRESHOLD_MS;
@@ -16379,17 +16392,19 @@ function createImplementationOrchestrator(deps) {
16379
16392
  const isLastOfEpicA = [..._stories.entries()].filter(([key]) => key !== storyKey && epicOfA(key) === epicIdA).every(([, st]) => TERMINAL_A.includes(st.phase));
16380
16393
  const epicNum = Number(epicIdA);
16381
16394
  if (isLastOfEpicA && Number.isInteger(epicNum)) {
16382
- const entries = await auditJourneyCoverage({ epic: epicNum });
16383
- const violations = (entries ?? []).filter((e) => e.state === "unclaimed" || e.state === "unwalked");
16384
- if (violations.length > 0) {
16395
+ const audit = await auditJourneyCoverage({ epic: epicNum });
16396
+ const violations = (audit?.entries ?? []).filter((e) => e.state === "unclaimed" || e.state === "unwalked");
16397
+ if (violations.length > 0 || audit?.unrunnable !== void 0) {
16385
16398
  const issueLines = violations.map((v) => `journey ${v.journeyId} [${v.criticality}] "${v.title}" is ${v.state}` + (v.ownerStories.length > 0 ? ` (claimed by ${v.ownerStories.join(", ")} but never walked)` : " — NO story claims it"));
16399
+ if (audit?.unrunnable !== void 0) issueLines.push(audit.unrunnable);
16386
16400
  if (acceptanceModeCfg === "blocking") {
16387
- const verdict = violations.some((v) => v.state === "unclaimed") ? "journey-unclaimed" : "journey-unwalked";
16401
+ const verdict = violations.some((v) => v.state === "unclaimed") ? "journey-unclaimed" : audit?.unrunnable !== void 0 ? "acceptance-unrunnable" : "journey-unwalked";
16388
16402
  logger$27.error({
16389
16403
  storyKey,
16390
16404
  epicId: epicIdA,
16405
+ verdict,
16391
16406
  journeys: violations.map((v) => v.journeyId)
16392
- }, "A0.3: journey coverage violation at epic close — blocking finalization; branch preserved");
16407
+ }, "A0.3/A1.1: journey coverage violation at epic close — blocking finalization; branch preserved");
16393
16408
  updateStory(storyKey, {
16394
16409
  phase: "ESCALATED",
16395
16410
  error: verdict,
@@ -48303,4 +48318,4 @@ function registerRunCommand(program, version = "0.0.0", projectRoot = process.cw
48303
48318
 
48304
48319
  //#endregion
48305
48320
  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, 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 };
48306
- //# sourceMappingURL=run-ZxFHQyE_.js.map
48321
+ //# sourceMappingURL=run-nSb1TD3o.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.21.3",
3
+ "version": "0.21.4",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",