substrate-ai 0.19.44 → 0.19.46
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.
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DrZiqv4h.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-sNh9XQ6V.js";
|
|
@@ -8,7 +8,7 @@ import { EventEmitter } from "node:events";
|
|
|
8
8
|
import yaml from "js-yaml";
|
|
9
9
|
import * as actualFS from "node:fs";
|
|
10
10
|
import { accessSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, unlinkSync, unwatchFile, watchFile, writeFileSync } from "node:fs";
|
|
11
|
-
import { exec, execFile, execSync, spawn } from "node:child_process";
|
|
11
|
+
import { exec, execFile, execFileSync, execSync, spawn } from "node:child_process";
|
|
12
12
|
import path, { basename as basename$1, dirname as dirname$1, extname as extname$1, isAbsolute, join as join$1, posix, resolve as resolve$1, win32 } from "node:path";
|
|
13
13
|
import { tmpdir } from "node:os";
|
|
14
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -2119,6 +2119,106 @@ async function runHelpAgent() {
|
|
|
2119
2119
|
return 0;
|
|
2120
2120
|
}
|
|
2121
2121
|
|
|
2122
|
+
//#endregion
|
|
2123
|
+
//#region src/persistence/dolt-server.ts
|
|
2124
|
+
const logger$23 = createLogger("dolt-server");
|
|
2125
|
+
/**
|
|
2126
|
+
* Start a dolt sql-server for the given project, if Dolt is available and no
|
|
2127
|
+
* server is already running (socket already exists).
|
|
2128
|
+
*
|
|
2129
|
+
* Returns a handle to stop the server, or null if:
|
|
2130
|
+
* - Dolt is not on PATH
|
|
2131
|
+
* - The .substrate/state directory doesn't contain a Dolt repo
|
|
2132
|
+
* - A socket already exists (external server already running)
|
|
2133
|
+
* - The server failed to start within the timeout
|
|
2134
|
+
*/
|
|
2135
|
+
async function startDoltServer(projectRoot) {
|
|
2136
|
+
const stateDir = join$1(projectRoot, ".substrate", "state");
|
|
2137
|
+
const socketPath = join$1(stateDir, ".dolt", "dolt.sock");
|
|
2138
|
+
if (!existsSync(join$1(stateDir, ".dolt"))) return null;
|
|
2139
|
+
try {
|
|
2140
|
+
await access$1(socketPath);
|
|
2141
|
+
logger$23.debug("Dolt socket already exists at %s — using existing server", socketPath);
|
|
2142
|
+
return null;
|
|
2143
|
+
} catch {}
|
|
2144
|
+
try {
|
|
2145
|
+
execFileSync("dolt", ["version"], {
|
|
2146
|
+
cwd: stateDir,
|
|
2147
|
+
stdio: "pipe"
|
|
2148
|
+
});
|
|
2149
|
+
} catch {
|
|
2150
|
+
logger$23.debug("dolt binary not on PATH — cannot start server");
|
|
2151
|
+
return null;
|
|
2152
|
+
}
|
|
2153
|
+
logger$23.debug("Starting dolt sql-server at %s", socketPath);
|
|
2154
|
+
let proc$1;
|
|
2155
|
+
try {
|
|
2156
|
+
proc$1 = spawn("dolt", [
|
|
2157
|
+
"sql-server",
|
|
2158
|
+
"--socket",
|
|
2159
|
+
socketPath,
|
|
2160
|
+
"--port",
|
|
2161
|
+
"0",
|
|
2162
|
+
"--max-connections",
|
|
2163
|
+
"10"
|
|
2164
|
+
], {
|
|
2165
|
+
cwd: stateDir,
|
|
2166
|
+
stdio: [
|
|
2167
|
+
"ignore",
|
|
2168
|
+
"pipe",
|
|
2169
|
+
"pipe"
|
|
2170
|
+
],
|
|
2171
|
+
detached: false
|
|
2172
|
+
});
|
|
2173
|
+
} catch (err) {
|
|
2174
|
+
logger$23.debug("Failed to spawn dolt sql-server: %s", err instanceof Error ? err.message : String(err));
|
|
2175
|
+
return null;
|
|
2176
|
+
}
|
|
2177
|
+
let failed = false;
|
|
2178
|
+
proc$1.on("error", (err) => {
|
|
2179
|
+
logger$23.debug("dolt sql-server error: %s", err.message);
|
|
2180
|
+
failed = true;
|
|
2181
|
+
});
|
|
2182
|
+
proc$1.on("exit", (code) => {
|
|
2183
|
+
if (code !== null && code !== 0) logger$23.debug("dolt sql-server exited with code %d", code);
|
|
2184
|
+
});
|
|
2185
|
+
proc$1.stderr?.on("data", (chunk) => {
|
|
2186
|
+
const line = chunk.toString().trim();
|
|
2187
|
+
if (line) logger$23.debug("dolt-server: %s", line);
|
|
2188
|
+
});
|
|
2189
|
+
const deadline = Date.now() + 5e3;
|
|
2190
|
+
while (Date.now() < deadline && !failed) try {
|
|
2191
|
+
await access$1(socketPath);
|
|
2192
|
+
const pid = proc$1.pid ?? 0;
|
|
2193
|
+
logger$23.info("Auto-started dolt sql-server (pid=%d, socket=%s)", pid, socketPath);
|
|
2194
|
+
let stopped = false;
|
|
2195
|
+
return {
|
|
2196
|
+
pid,
|
|
2197
|
+
socketPath,
|
|
2198
|
+
stop: () => {
|
|
2199
|
+
if (stopped) return;
|
|
2200
|
+
stopped = true;
|
|
2201
|
+
logger$23.debug("Stopping dolt sql-server (pid=%d)", pid);
|
|
2202
|
+
proc$1.kill("SIGTERM");
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
} catch {
|
|
2206
|
+
await new Promise((resolve$6) => setTimeout(resolve$6, 100));
|
|
2207
|
+
}
|
|
2208
|
+
logger$23.debug("dolt sql-server did not start within 5s — killing");
|
|
2209
|
+
proc$1.kill("SIGTERM");
|
|
2210
|
+
return null;
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* Register cleanup handlers to stop the Dolt server on process exit/signals.
|
|
2214
|
+
*/
|
|
2215
|
+
function registerServerCleanup(handle) {
|
|
2216
|
+
const cleanup = () => handle.stop();
|
|
2217
|
+
process.on("exit", cleanup);
|
|
2218
|
+
process.on("SIGTERM", cleanup);
|
|
2219
|
+
process.on("SIGINT", cleanup);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2122
2222
|
//#endregion
|
|
2123
2223
|
//#region src/modules/context-compiler/token-counter.ts
|
|
2124
2224
|
/**
|
|
@@ -2429,8 +2529,8 @@ var GrammarLoader = class {
|
|
|
2429
2529
|
_extensionMap;
|
|
2430
2530
|
_cache = new Map();
|
|
2431
2531
|
_unavailable = false;
|
|
2432
|
-
constructor(logger$
|
|
2433
|
-
this._logger = logger$
|
|
2532
|
+
constructor(logger$24) {
|
|
2533
|
+
this._logger = logger$24;
|
|
2434
2534
|
this._extensionMap = new Map([
|
|
2435
2535
|
[".ts", "tree-sitter-typescript/typescript"],
|
|
2436
2536
|
[".tsx", "tree-sitter-typescript/tsx"],
|
|
@@ -2516,9 +2616,9 @@ const ERR_REPO_MAP_GIT_FAILED = "ERR_REPO_MAP_GIT_FAILED";
|
|
|
2516
2616
|
var SymbolParser = class {
|
|
2517
2617
|
_grammarLoader;
|
|
2518
2618
|
_logger;
|
|
2519
|
-
constructor(grammarLoader, logger$
|
|
2619
|
+
constructor(grammarLoader, logger$24) {
|
|
2520
2620
|
this._grammarLoader = grammarLoader;
|
|
2521
|
-
this._logger = logger$
|
|
2621
|
+
this._logger = logger$24;
|
|
2522
2622
|
}
|
|
2523
2623
|
async parseFile(filePath) {
|
|
2524
2624
|
const ext$1 = extname$1(filePath);
|
|
@@ -2663,9 +2763,9 @@ async function computeFileHash(filePath) {
|
|
|
2663
2763
|
var DoltSymbolRepository = class {
|
|
2664
2764
|
_client;
|
|
2665
2765
|
_logger;
|
|
2666
|
-
constructor(client, logger$
|
|
2766
|
+
constructor(client, logger$24) {
|
|
2667
2767
|
this._client = client;
|
|
2668
|
-
this._logger = logger$
|
|
2768
|
+
this._logger = logger$24;
|
|
2669
2769
|
}
|
|
2670
2770
|
/**
|
|
2671
2771
|
* Atomically replace all symbols for filePath.
|
|
@@ -2871,11 +2971,11 @@ var RepoMapStorage = class {
|
|
|
2871
2971
|
_metaRepo;
|
|
2872
2972
|
_gitClient;
|
|
2873
2973
|
_logger;
|
|
2874
|
-
constructor(symbolRepo, metaRepo, gitClient, logger$
|
|
2974
|
+
constructor(symbolRepo, metaRepo, gitClient, logger$24) {
|
|
2875
2975
|
this._symbolRepo = symbolRepo;
|
|
2876
2976
|
this._metaRepo = metaRepo;
|
|
2877
2977
|
this._gitClient = gitClient;
|
|
2878
|
-
this._logger = logger$
|
|
2978
|
+
this._logger = logger$24;
|
|
2879
2979
|
}
|
|
2880
2980
|
/**
|
|
2881
2981
|
* Returns true if the file's current content hash differs from the stored hash.
|
|
@@ -2992,8 +3092,8 @@ function runGit(args, cwd) {
|
|
|
2992
3092
|
*/
|
|
2993
3093
|
var GitClient = class {
|
|
2994
3094
|
_logger;
|
|
2995
|
-
constructor(logger$
|
|
2996
|
-
this._logger = logger$
|
|
3095
|
+
constructor(logger$24) {
|
|
3096
|
+
this._logger = logger$24;
|
|
2997
3097
|
}
|
|
2998
3098
|
/**
|
|
2999
3099
|
* Returns the current HEAD commit SHA.
|
|
@@ -4349,9 +4449,9 @@ var RepoMapQueryEngine = class {
|
|
|
4349
4449
|
repo;
|
|
4350
4450
|
logger;
|
|
4351
4451
|
telemetry;
|
|
4352
|
-
constructor(repo, logger$
|
|
4452
|
+
constructor(repo, logger$24, telemetry) {
|
|
4353
4453
|
this.repo = repo;
|
|
4354
|
-
this.logger = logger$
|
|
4454
|
+
this.logger = logger$24;
|
|
4355
4455
|
this.telemetry = telemetry;
|
|
4356
4456
|
}
|
|
4357
4457
|
async query(q) {
|
|
@@ -4571,9 +4671,9 @@ var RepoMapFormatter = class {
|
|
|
4571
4671
|
var RepoMapTelemetry = class {
|
|
4572
4672
|
_telemetry;
|
|
4573
4673
|
_logger;
|
|
4574
|
-
constructor(telemetry, logger$
|
|
4674
|
+
constructor(telemetry, logger$24) {
|
|
4575
4675
|
this._telemetry = telemetry;
|
|
4576
|
-
this._logger = logger$
|
|
4676
|
+
this._logger = logger$24;
|
|
4577
4677
|
}
|
|
4578
4678
|
/**
|
|
4579
4679
|
* Emit a `repo_map.query` span.
|
|
@@ -4598,9 +4698,9 @@ var RepoMapTelemetry = class {
|
|
|
4598
4698
|
var RepoMapModule = class {
|
|
4599
4699
|
_metaRepo;
|
|
4600
4700
|
_logger;
|
|
4601
|
-
constructor(metaRepo, logger$
|
|
4701
|
+
constructor(metaRepo, logger$24) {
|
|
4602
4702
|
this._metaRepo = metaRepo;
|
|
4603
|
-
this._logger = logger$
|
|
4703
|
+
this._logger = logger$24;
|
|
4604
4704
|
}
|
|
4605
4705
|
/**
|
|
4606
4706
|
* Check whether the stored repo-map is stale relative to the current HEAD commit.
|
|
@@ -4644,9 +4744,9 @@ var RepoMapModule = class {
|
|
|
4644
4744
|
var RepoMapInjector = class {
|
|
4645
4745
|
_queryEngine;
|
|
4646
4746
|
_logger;
|
|
4647
|
-
constructor(queryEngine, logger$
|
|
4747
|
+
constructor(queryEngine, logger$24) {
|
|
4648
4748
|
this._queryEngine = queryEngine;
|
|
4649
|
-
this._logger = logger$
|
|
4749
|
+
this._logger = logger$24;
|
|
4650
4750
|
}
|
|
4651
4751
|
/**
|
|
4652
4752
|
* Build repo-map context by extracting file references from the story content,
|
|
@@ -11504,7 +11604,7 @@ function checkProfileStaleness(projectRoot) {
|
|
|
11504
11604
|
*/
|
|
11505
11605
|
function createImplementationOrchestrator(deps) {
|
|
11506
11606
|
const { db, pack, contextCompiler, dispatcher, eventBus, config, projectRoot, tokenCeilings, stateStore, telemetryPersistence, ingestionServer, repoMapInjector, maxRepoMapTokens, agentId, runManifest = null } = deps;
|
|
11507
|
-
const logger$
|
|
11607
|
+
const logger$24 = createLogger("implementation-orchestrator");
|
|
11508
11608
|
const telemetryAdvisor = db !== void 0 ? createTelemetryAdvisor({ db }) : void 0;
|
|
11509
11609
|
const wgRepo = new WorkGraphRepository(db);
|
|
11510
11610
|
const _wgInProgressWritten = new Set();
|
|
@@ -11581,7 +11681,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11581
11681
|
const existingCount = storyState?.retry_count ?? 0;
|
|
11582
11682
|
_storyRetryCount.set(storyKey, existingCount);
|
|
11583
11683
|
} catch (err) {
|
|
11584
|
-
logger$
|
|
11684
|
+
logger$24.warn({
|
|
11585
11685
|
err,
|
|
11586
11686
|
storyKey
|
|
11587
11687
|
}, "initRetryCount: failed to read manifest — starting at 0");
|
|
@@ -11595,7 +11695,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11595
11695
|
const current = _storyRetryCount.get(storyKey) ?? 0;
|
|
11596
11696
|
const next = current + 1;
|
|
11597
11697
|
_storyRetryCount.set(storyKey, next);
|
|
11598
|
-
if (runManifest !== null && runManifest !== void 0) runManifest.patchStoryState(storyKey, { retry_count: next }).catch((err) => logger$
|
|
11698
|
+
if (runManifest !== null && runManifest !== void 0) runManifest.patchStoryState(storyKey, { retry_count: next }).catch((err) => logger$24.warn({
|
|
11599
11699
|
err,
|
|
11600
11700
|
storyKey
|
|
11601
11701
|
}, "patchStoryState(retry_count) failed — pipeline continues"));
|
|
@@ -11608,7 +11708,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11608
11708
|
const nowMs = Date.now();
|
|
11609
11709
|
for (const [phase, startMs] of starts) {
|
|
11610
11710
|
const endMs = ends?.get(phase);
|
|
11611
|
-
if (endMs === void 0) logger$
|
|
11711
|
+
if (endMs === void 0) logger$24.warn({
|
|
11612
11712
|
storyKey,
|
|
11613
11713
|
phase
|
|
11614
11714
|
}, "Phase has no end time — story may have errored mid-phase. Duration capped to now() and may be inflated.");
|
|
@@ -11625,7 +11725,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11625
11725
|
const wallClockSeconds = startedAt ? Math.round((new Date(completedAt).getTime() - new Date(startedAt).getTime()) / 1e3) : 0;
|
|
11626
11726
|
const wallClockMs = startedAt ? new Date(completedAt).getTime() - new Date(startedAt).getTime() : 0;
|
|
11627
11727
|
const tokenAgg = await aggregateTokenUsageForStory(db, config.pipelineRunId, storyKey);
|
|
11628
|
-
if (runManifest !== null) runManifest.patchStoryState(storyKey, { cost_usd: tokenAgg.cost }).catch((err) => logger$
|
|
11728
|
+
if (runManifest !== null) runManifest.patchStoryState(storyKey, { cost_usd: tokenAgg.cost }).catch((err) => logger$24.warn({
|
|
11629
11729
|
err,
|
|
11630
11730
|
storyKey
|
|
11631
11731
|
}, "patchStoryState(cost_usd) failed — pipeline continues"));
|
|
@@ -11661,7 +11761,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11661
11761
|
recordedAt: completedAt,
|
|
11662
11762
|
timestamp: completedAt
|
|
11663
11763
|
}).catch((storeErr) => {
|
|
11664
|
-
logger$
|
|
11764
|
+
logger$24.warn({
|
|
11665
11765
|
err: storeErr,
|
|
11666
11766
|
storyKey
|
|
11667
11767
|
}, "Failed to record metric to StateStore (best-effort)");
|
|
@@ -11683,7 +11783,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11683
11783
|
rationale: `Story ${storyKey} completed with result=${result} in ${wallClockSeconds}s. Tokens: ${tokenAgg.input}+${tokenAgg.output}. Review cycles: ${reviewCycles}.`
|
|
11684
11784
|
});
|
|
11685
11785
|
} catch (decisionErr) {
|
|
11686
|
-
logger$
|
|
11786
|
+
logger$24.warn({
|
|
11687
11787
|
err: decisionErr,
|
|
11688
11788
|
storyKey
|
|
11689
11789
|
}, "Failed to write story-metrics decision (best-effort)");
|
|
@@ -11762,7 +11862,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11762
11862
|
const LOW_OUTPUT_TOKEN_THRESHOLD = 100;
|
|
11763
11863
|
const unverified = tokenAgg.output < LOW_OUTPUT_TOKEN_THRESHOLD;
|
|
11764
11864
|
if (unverified) {
|
|
11765
|
-
logger$
|
|
11865
|
+
logger$24.warn({
|
|
11766
11866
|
storyKey,
|
|
11767
11867
|
outputTokens: tokenAgg.output,
|
|
11768
11868
|
threshold: LOW_OUTPUT_TOKEN_THRESHOLD
|
|
@@ -11786,13 +11886,13 @@ function createImplementationOrchestrator(deps) {
|
|
|
11786
11886
|
...unverified ? { unverified: true } : {}
|
|
11787
11887
|
});
|
|
11788
11888
|
} catch (emitErr) {
|
|
11789
|
-
logger$
|
|
11889
|
+
logger$24.warn({
|
|
11790
11890
|
err: emitErr,
|
|
11791
11891
|
storyKey
|
|
11792
11892
|
}, "Failed to emit story:metrics event (best-effort)");
|
|
11793
11893
|
}
|
|
11794
11894
|
} catch (err) {
|
|
11795
|
-
logger$
|
|
11895
|
+
logger$24.warn({
|
|
11796
11896
|
err,
|
|
11797
11897
|
storyKey
|
|
11798
11898
|
}, "Failed to write story metrics (best-effort)");
|
|
@@ -11821,7 +11921,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11821
11921
|
rationale: `Story ${storyKey} ${outcome} after ${reviewCycles} review cycle(s).`
|
|
11822
11922
|
});
|
|
11823
11923
|
} catch (err) {
|
|
11824
|
-
logger$
|
|
11924
|
+
logger$24.warn({
|
|
11825
11925
|
err,
|
|
11826
11926
|
storyKey
|
|
11827
11927
|
}, "Failed to write story-outcome decision (best-effort)");
|
|
@@ -11859,7 +11959,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11859
11959
|
rationale: `Escalation diagnosis for ${payload.storyKey}: ${diagnosis.recommendedAction} — ${diagnosis.rationale}`
|
|
11860
11960
|
});
|
|
11861
11961
|
} catch (err) {
|
|
11862
|
-
logger$
|
|
11962
|
+
logger$24.warn({
|
|
11863
11963
|
err,
|
|
11864
11964
|
storyKey: payload.storyKey
|
|
11865
11965
|
}, "Failed to persist escalation diagnosis (best-effort)");
|
|
@@ -11909,7 +12009,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11909
12009
|
const existing = _stories.get(storyKey);
|
|
11910
12010
|
if (existing !== void 0) {
|
|
11911
12011
|
Object.assign(existing, updates);
|
|
11912
|
-
persistStoryState(storyKey, existing).catch((err) => logger$
|
|
12012
|
+
persistStoryState(storyKey, existing).catch((err) => logger$24.warn({
|
|
11913
12013
|
err,
|
|
11914
12014
|
storyKey
|
|
11915
12015
|
}, "StateStore write failed after updateStory"));
|
|
@@ -11918,12 +12018,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
11918
12018
|
storyKey,
|
|
11919
12019
|
conflict: err
|
|
11920
12020
|
});
|
|
11921
|
-
else logger$
|
|
12021
|
+
else logger$24.warn({
|
|
11922
12022
|
err,
|
|
11923
12023
|
storyKey
|
|
11924
12024
|
}, "mergeStory failed");
|
|
11925
12025
|
});
|
|
11926
|
-
else if (updates.phase === "ESCALATED" || updates.phase === "VERIFICATION_FAILED") stateStore?.rollbackStory(storyKey).catch((err) => logger$
|
|
12026
|
+
else if (updates.phase === "ESCALATED" || updates.phase === "VERIFICATION_FAILED") stateStore?.rollbackStory(storyKey).catch((err) => logger$24.warn({
|
|
11927
12027
|
err,
|
|
11928
12028
|
storyKey
|
|
11929
12029
|
}, "rollbackStory failed — branch may persist"));
|
|
@@ -11935,7 +12035,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11935
12035
|
...updates
|
|
11936
12036
|
};
|
|
11937
12037
|
const opts = targetStatus === "complete" || targetStatus === "escalated" ? { completedAt: fullUpdated.completedAt } : void 0;
|
|
11938
|
-
wgRepo.updateStoryStatus(storyKey, targetStatus, opts).catch((err) => logger$
|
|
12038
|
+
wgRepo.updateStoryStatus(storyKey, targetStatus, opts).catch((err) => logger$24.warn({
|
|
11939
12039
|
err,
|
|
11940
12040
|
storyKey
|
|
11941
12041
|
}, "wg_stories status update failed (best-effort)"));
|
|
@@ -11951,7 +12051,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11951
12051
|
status: "dispatched",
|
|
11952
12052
|
phase: String(updates.phase),
|
|
11953
12053
|
started_at: fullUpdated.startedAt ?? new Date().toISOString()
|
|
11954
|
-
}).catch((err) => logger$
|
|
12054
|
+
}).catch((err) => logger$24.warn({
|
|
11955
12055
|
err,
|
|
11956
12056
|
storyKey
|
|
11957
12057
|
}, "patchStoryState(dispatched) failed — pipeline continues"));
|
|
@@ -11963,7 +12063,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11963
12063
|
completed_at: fullUpdated.completedAt ?? new Date().toISOString(),
|
|
11964
12064
|
review_cycles: fullUpdated.reviewCycles ?? 0,
|
|
11965
12065
|
dispatches: _storyDispatches.get(storyKey) ?? 0
|
|
11966
|
-
}).catch((err) => logger$
|
|
12066
|
+
}).catch((err) => logger$24.warn({
|
|
11967
12067
|
err,
|
|
11968
12068
|
storyKey
|
|
11969
12069
|
}, `patchStoryState(${manifestStatus}) failed — pipeline continues`));
|
|
@@ -11993,7 +12093,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
11993
12093
|
};
|
|
11994
12094
|
await stateStore.setStoryState(storyKey, record);
|
|
11995
12095
|
} catch (err) {
|
|
11996
|
-
logger$
|
|
12096
|
+
logger$24.warn({
|
|
11997
12097
|
err,
|
|
11998
12098
|
storyKey
|
|
11999
12099
|
}, "StateStore.setStoryState failed (best-effort)");
|
|
@@ -12009,7 +12109,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12009
12109
|
token_usage_json: serialized
|
|
12010
12110
|
});
|
|
12011
12111
|
} catch (err) {
|
|
12012
|
-
logger$
|
|
12112
|
+
logger$24.warn({ err }, "Failed to persist orchestrator state");
|
|
12013
12113
|
}
|
|
12014
12114
|
}
|
|
12015
12115
|
function recordProgress() {
|
|
@@ -12035,7 +12135,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12035
12135
|
queuedDispatches: queued
|
|
12036
12136
|
});
|
|
12037
12137
|
if (config.pipelineRunId !== void 0) updatePipelineRun(db, config.pipelineRunId, { current_phase: "implementation" }).catch((err) => {
|
|
12038
|
-
logger$
|
|
12138
|
+
logger$24.debug({ err }, "Heartbeat: failed to touch updated_at (non-fatal)");
|
|
12039
12139
|
});
|
|
12040
12140
|
const elapsed = Date.now() - _lastProgressTs;
|
|
12041
12141
|
let childPids = [];
|
|
@@ -12057,7 +12157,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12057
12157
|
}
|
|
12058
12158
|
if (childActive) {
|
|
12059
12159
|
_lastProgressTs = Date.now();
|
|
12060
|
-
logger$
|
|
12160
|
+
logger$24.debug({
|
|
12061
12161
|
storyKey: key,
|
|
12062
12162
|
phase: s$1.phase,
|
|
12063
12163
|
childPids
|
|
@@ -12066,7 +12166,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12066
12166
|
}
|
|
12067
12167
|
_stalledStories.add(key);
|
|
12068
12168
|
_storiesWithStall.add(key);
|
|
12069
|
-
logger$
|
|
12169
|
+
logger$24.warn({
|
|
12070
12170
|
storyKey: key,
|
|
12071
12171
|
phase: s$1.phase,
|
|
12072
12172
|
elapsedMs: elapsed,
|
|
@@ -12111,7 +12211,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12111
12211
|
for (let attempt = 0; attempt < MEMORY_PRESSURE_BACKOFF_MS.length; attempt++) {
|
|
12112
12212
|
const memState = dispatcher.getMemoryState();
|
|
12113
12213
|
if (!memState.isPressured) return true;
|
|
12114
|
-
logger$
|
|
12214
|
+
logger$24.warn({
|
|
12115
12215
|
storyKey,
|
|
12116
12216
|
freeMB: memState.freeMB,
|
|
12117
12217
|
thresholdMB: memState.thresholdMB,
|
|
@@ -12131,12 +12231,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
12131
12231
|
* exhausted retries the story is ESCALATED.
|
|
12132
12232
|
*/
|
|
12133
12233
|
async function processStory(storyKey, storyOptions) {
|
|
12134
|
-
logger$
|
|
12234
|
+
logger$24.info({ storyKey }, "Processing story");
|
|
12135
12235
|
await initRetryCount(storyKey);
|
|
12136
12236
|
{
|
|
12137
12237
|
const memoryOk = await checkMemoryPressure(storyKey);
|
|
12138
12238
|
if (!memoryOk) {
|
|
12139
|
-
logger$
|
|
12239
|
+
logger$24.warn({ storyKey }, "Memory pressure exhausted — escalating story without dispatch");
|
|
12140
12240
|
const memPressureState = {
|
|
12141
12241
|
phase: "ESCALATED",
|
|
12142
12242
|
reviewCycles: 0,
|
|
@@ -12145,7 +12245,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12145
12245
|
completedAt: new Date().toISOString()
|
|
12146
12246
|
};
|
|
12147
12247
|
_stories.set(storyKey, memPressureState);
|
|
12148
|
-
persistStoryState(storyKey, memPressureState).catch((err) => logger$
|
|
12248
|
+
persistStoryState(storyKey, memPressureState).catch((err) => logger$24.warn({
|
|
12149
12249
|
err,
|
|
12150
12250
|
storyKey
|
|
12151
12251
|
}, "StateStore write failed after memory-pressure escalation"));
|
|
@@ -12162,7 +12262,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12162
12262
|
}
|
|
12163
12263
|
await waitIfPaused();
|
|
12164
12264
|
if (_state !== "RUNNING") return;
|
|
12165
|
-
stateStore?.branchForStory(storyKey).catch((err) => logger$
|
|
12265
|
+
stateStore?.branchForStory(storyKey).catch((err) => logger$24.warn({
|
|
12166
12266
|
err,
|
|
12167
12267
|
storyKey
|
|
12168
12268
|
}, "branchForStory failed — continuing without branch isolation"));
|
|
@@ -12179,14 +12279,14 @@ function createImplementationOrchestrator(deps) {
|
|
|
12179
12279
|
if (match$1) {
|
|
12180
12280
|
const candidatePath = join$1(artifactsDir, match$1);
|
|
12181
12281
|
const validation = await isValidStoryFile(candidatePath);
|
|
12182
|
-
if (!validation.valid) logger$
|
|
12282
|
+
if (!validation.valid) logger$24.warn({
|
|
12183
12283
|
storyKey,
|
|
12184
12284
|
storyFilePath: candidatePath,
|
|
12185
12285
|
reason: validation.reason
|
|
12186
12286
|
}, `Existing story file for ${storyKey} is invalid (${validation.reason}) — re-creating`);
|
|
12187
12287
|
else {
|
|
12188
12288
|
storyFilePath = candidatePath;
|
|
12189
|
-
logger$
|
|
12289
|
+
logger$24.info({
|
|
12190
12290
|
storyKey,
|
|
12191
12291
|
storyFilePath
|
|
12192
12292
|
}, "Found existing story file — skipping create-story");
|
|
@@ -12205,7 +12305,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12205
12305
|
}
|
|
12206
12306
|
} catch {}
|
|
12207
12307
|
if (storyFilePath === void 0 && projectRoot && isImplicitlyCovered(storyKey, projectRoot)) {
|
|
12208
|
-
logger$
|
|
12308
|
+
logger$24.info({ storyKey }, `Story ${storyKey} appears implicitly covered — all expected new files already exist. Skipping create-story.`);
|
|
12209
12309
|
endPhase(storyKey, "create-story");
|
|
12210
12310
|
eventBus.emit("orchestrator:story-phase-complete", {
|
|
12211
12311
|
storyKey,
|
|
@@ -12255,7 +12355,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12255
12355
|
metadata: JSON.stringify({ storyKey })
|
|
12256
12356
|
});
|
|
12257
12357
|
} catch (tokenErr) {
|
|
12258
|
-
logger$
|
|
12358
|
+
logger$24.warn({
|
|
12259
12359
|
storyKey,
|
|
12260
12360
|
err: tokenErr
|
|
12261
12361
|
}, "Failed to record create-story token usage");
|
|
@@ -12264,7 +12364,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12264
12364
|
if (createResult.result === "failed") {
|
|
12265
12365
|
const errMsg = createResult.error ?? "create-story failed";
|
|
12266
12366
|
const stderrSnippet = errMsg.includes("--- stderr ---") ? errMsg.slice(errMsg.indexOf("--- stderr ---") + 15, errMsg.indexOf("--- stderr ---") + 515) : errMsg.slice(0, 500);
|
|
12267
|
-
logger$
|
|
12367
|
+
logger$24.error({
|
|
12268
12368
|
storyKey,
|
|
12269
12369
|
stderrSnippet
|
|
12270
12370
|
}, `Create-story failed: ${stderrSnippet.split("\n")[0]}`);
|
|
@@ -12317,7 +12417,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12317
12417
|
const overlap = computeTitleOverlap(expectedTitle, createResult.story_title);
|
|
12318
12418
|
if (overlap < TITLE_OVERLAP_WARNING_THRESHOLD) {
|
|
12319
12419
|
const msg = `Story title mismatch: expected "${expectedTitle}" but got "${createResult.story_title}" (word overlap: ${Math.round(overlap * 100)}%). This may indicate the create-story agent received truncated context.`;
|
|
12320
|
-
logger$
|
|
12420
|
+
logger$24.warn({
|
|
12321
12421
|
storyKey,
|
|
12322
12422
|
expectedTitle,
|
|
12323
12423
|
generatedTitle: createResult.story_title,
|
|
@@ -12327,7 +12427,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12327
12427
|
storyKey,
|
|
12328
12428
|
msg
|
|
12329
12429
|
});
|
|
12330
|
-
} else logger$
|
|
12430
|
+
} else logger$24.debug({
|
|
12331
12431
|
storyKey,
|
|
12332
12432
|
expectedTitle,
|
|
12333
12433
|
generatedTitle: createResult.story_title,
|
|
@@ -12336,7 +12436,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12336
12436
|
}
|
|
12337
12437
|
}
|
|
12338
12438
|
} catch (titleValidationErr) {
|
|
12339
|
-
logger$
|
|
12439
|
+
logger$24.debug({
|
|
12340
12440
|
storyKey,
|
|
12341
12441
|
err: titleValidationErr
|
|
12342
12442
|
}, "Story title validation skipped due to error");
|
|
@@ -12384,14 +12484,14 @@ function createImplementationOrchestrator(deps) {
|
|
|
12384
12484
|
...contract.transport !== void 0 ? { transport: contract.transport } : {}
|
|
12385
12485
|
})
|
|
12386
12486
|
});
|
|
12387
|
-
logger$
|
|
12487
|
+
logger$24.info({
|
|
12388
12488
|
storyKey,
|
|
12389
12489
|
contractCount: contracts.length,
|
|
12390
12490
|
contracts
|
|
12391
12491
|
}, "Stored interface contract declarations");
|
|
12392
12492
|
}
|
|
12393
12493
|
} catch (err) {
|
|
12394
|
-
logger$
|
|
12494
|
+
logger$24.warn({
|
|
12395
12495
|
storyKey,
|
|
12396
12496
|
error: err instanceof Error ? err.message : String(err)
|
|
12397
12497
|
}, "Failed to parse interface contracts — continuing without contract declarations");
|
|
@@ -12420,10 +12520,10 @@ function createImplementationOrchestrator(deps) {
|
|
|
12420
12520
|
});
|
|
12421
12521
|
testPlanPhaseResult = testPlanResult.result;
|
|
12422
12522
|
testPlanTokenUsage = testPlanResult.tokenUsage;
|
|
12423
|
-
if (testPlanResult.result === "success") logger$
|
|
12424
|
-
else logger$
|
|
12523
|
+
if (testPlanResult.result === "success") logger$24.info({ storyKey }, "Test plan generated successfully");
|
|
12524
|
+
else logger$24.warn({ storyKey }, "Test planning returned failed result — proceeding to dev-story without test plan");
|
|
12425
12525
|
} catch (err) {
|
|
12426
|
-
logger$
|
|
12526
|
+
logger$24.warn({
|
|
12427
12527
|
storyKey,
|
|
12428
12528
|
err
|
|
12429
12529
|
}, "Test planning failed — proceeding to dev-story without test plan");
|
|
@@ -12439,7 +12539,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12439
12539
|
metadata: JSON.stringify({ storyKey })
|
|
12440
12540
|
});
|
|
12441
12541
|
} catch (tokenErr) {
|
|
12442
|
-
logger$
|
|
12542
|
+
logger$24.warn({
|
|
12443
12543
|
storyKey,
|
|
12444
12544
|
err: tokenErr
|
|
12445
12545
|
}, "Failed to record test-plan token usage");
|
|
@@ -12476,7 +12576,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12476
12576
|
try {
|
|
12477
12577
|
storyContentForAnalysis = await readFile$1(storyFilePath ?? "", "utf-8");
|
|
12478
12578
|
} catch (err) {
|
|
12479
|
-
logger$
|
|
12579
|
+
logger$24.error({
|
|
12480
12580
|
storyKey,
|
|
12481
12581
|
storyFilePath,
|
|
12482
12582
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -12484,7 +12584,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12484
12584
|
}
|
|
12485
12585
|
const analysis = analyzeStoryComplexity(storyContentForAnalysis);
|
|
12486
12586
|
const batches = planTaskBatches(analysis);
|
|
12487
|
-
logger$
|
|
12587
|
+
logger$24.info({
|
|
12488
12588
|
storyKey,
|
|
12489
12589
|
estimatedScope: analysis.estimatedScope,
|
|
12490
12590
|
batchCount: batches.length,
|
|
@@ -12502,7 +12602,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12502
12602
|
if (_state !== "RUNNING") break;
|
|
12503
12603
|
const taskScope = batch.taskIds.map((id, i) => `T${id}: ${batch.taskTitles[i] ?? ""}`).join("\n");
|
|
12504
12604
|
const priorFiles = allFilesModified.size > 0 ? Array.from(allFilesModified) : void 0;
|
|
12505
|
-
logger$
|
|
12605
|
+
logger$24.info({
|
|
12506
12606
|
storyKey,
|
|
12507
12607
|
batchIndex: batch.batchIndex,
|
|
12508
12608
|
taskCount: batch.taskIds.length
|
|
@@ -12533,7 +12633,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12533
12633
|
});
|
|
12534
12634
|
} catch (batchErr) {
|
|
12535
12635
|
const errMsg = batchErr instanceof Error ? batchErr.message : String(batchErr);
|
|
12536
|
-
logger$
|
|
12636
|
+
logger$24.warn({
|
|
12537
12637
|
storyKey,
|
|
12538
12638
|
batchIndex: batch.batchIndex,
|
|
12539
12639
|
error: errMsg
|
|
@@ -12553,7 +12653,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12553
12653
|
filesModified: batchFilesModified,
|
|
12554
12654
|
result: batchResult.result === "success" ? "success" : "failed"
|
|
12555
12655
|
};
|
|
12556
|
-
logger$
|
|
12656
|
+
logger$24.info(batchMetrics, "Batch dev-story metrics");
|
|
12557
12657
|
for (const f$1 of batchFilesModified) allFilesModified.add(f$1);
|
|
12558
12658
|
if (batchFilesModified.length > 0) batchFileGroups.push({
|
|
12559
12659
|
batchIndex: batch.batchIndex,
|
|
@@ -12575,14 +12675,14 @@ function createImplementationOrchestrator(deps) {
|
|
|
12575
12675
|
})
|
|
12576
12676
|
});
|
|
12577
12677
|
} catch (tokenErr) {
|
|
12578
|
-
logger$
|
|
12678
|
+
logger$24.warn({
|
|
12579
12679
|
storyKey,
|
|
12580
12680
|
batchIndex: batch.batchIndex,
|
|
12581
12681
|
err: tokenErr
|
|
12582
12682
|
}, "Failed to record batch token usage");
|
|
12583
12683
|
}
|
|
12584
12684
|
if (batchResult.tokenUsage?.output !== void 0) devOutputTokenCount = (devOutputTokenCount ?? 0) + batchResult.tokenUsage.output;
|
|
12585
|
-
if (batchResult.result === "failed") logger$
|
|
12685
|
+
if (batchResult.result === "failed") logger$24.warn({
|
|
12586
12686
|
storyKey,
|
|
12587
12687
|
batchIndex: batch.batchIndex,
|
|
12588
12688
|
error: batchResult.error
|
|
@@ -12628,7 +12728,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12628
12728
|
metadata: JSON.stringify({ storyKey })
|
|
12629
12729
|
});
|
|
12630
12730
|
} catch (tokenErr) {
|
|
12631
|
-
logger$
|
|
12731
|
+
logger$24.warn({
|
|
12632
12732
|
storyKey,
|
|
12633
12733
|
err: tokenErr
|
|
12634
12734
|
}, "Failed to record dev-story token usage");
|
|
@@ -12644,7 +12744,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12644
12744
|
endPhase(storyKey, "dev-story");
|
|
12645
12745
|
const timeoutFiles = checkGitDiffFiles(projectRoot ?? process.cwd());
|
|
12646
12746
|
if (timeoutFiles.length === 0) {
|
|
12647
|
-
logger$
|
|
12747
|
+
logger$24.warn({ storyKey }, "Dev-story timeout with zero modified files — escalating immediately (no checkpoint)");
|
|
12648
12748
|
updateStory(storyKey, {
|
|
12649
12749
|
phase: "ESCALATED",
|
|
12650
12750
|
error: "timeout-no-files",
|
|
@@ -12660,7 +12760,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12660
12760
|
await persistState();
|
|
12661
12761
|
return;
|
|
12662
12762
|
}
|
|
12663
|
-
logger$
|
|
12763
|
+
logger$24.info({
|
|
12664
12764
|
storyKey,
|
|
12665
12765
|
filesCount: timeoutFiles.length
|
|
12666
12766
|
}, "Dev-story timeout with partial files — capturing checkpoint");
|
|
@@ -12677,7 +12777,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12677
12777
|
]
|
|
12678
12778
|
}).trim();
|
|
12679
12779
|
} catch (diffErr) {
|
|
12680
|
-
logger$
|
|
12780
|
+
logger$24.warn({
|
|
12681
12781
|
storyKey,
|
|
12682
12782
|
error: diffErr instanceof Error ? diffErr.message : String(diffErr)
|
|
12683
12783
|
}, "Failed to capture git diff for checkpoint — proceeding with empty diff");
|
|
@@ -12704,7 +12804,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12704
12804
|
recordedAt: new Date().toISOString(),
|
|
12705
12805
|
sprint: config.sprint
|
|
12706
12806
|
}).catch((storeErr) => {
|
|
12707
|
-
logger$
|
|
12807
|
+
logger$24.warn({
|
|
12708
12808
|
err: storeErr,
|
|
12709
12809
|
storyKey
|
|
12710
12810
|
}, "Failed to record timeout metric to StateStore (best-effort)");
|
|
@@ -12763,9 +12863,9 @@ function createImplementationOrchestrator(deps) {
|
|
|
12763
12863
|
checkpointRetryPrompt = assembled.prompt;
|
|
12764
12864
|
} catch {
|
|
12765
12865
|
checkpointRetryPrompt = `Continue story ${storyKey} from checkpoint. Your prior attempt timed out. Do not redo completed work.`;
|
|
12766
|
-
logger$
|
|
12866
|
+
logger$24.warn({ storyKey }, "Failed to assemble checkpoint retry prompt — using fallback");
|
|
12767
12867
|
}
|
|
12768
|
-
logger$
|
|
12868
|
+
logger$24.info({
|
|
12769
12869
|
storyKey,
|
|
12770
12870
|
filesCount: checkpointData.filesModified.length
|
|
12771
12871
|
}, "Dispatching checkpoint retry for timed-out story");
|
|
@@ -12794,7 +12894,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12794
12894
|
} : void 0 }
|
|
12795
12895
|
});
|
|
12796
12896
|
if (checkpointRetryResult.status === "timeout") {
|
|
12797
|
-
logger$
|
|
12897
|
+
logger$24.warn({ storyKey }, "Checkpoint retry dispatch timed out — escalating story");
|
|
12798
12898
|
updateStory(storyKey, {
|
|
12799
12899
|
phase: "ESCALATED",
|
|
12800
12900
|
error: "checkpoint-retry-timeout",
|
|
@@ -12813,7 +12913,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12813
12913
|
const retryParsed = checkpointRetryResult.parsed;
|
|
12814
12914
|
devFilesModified = retryParsed?.files_modified ?? checkGitDiffFiles(projectRoot ?? process.cwd());
|
|
12815
12915
|
if (checkpointRetryResult.status === "completed" && retryParsed?.result === "success") devStoryWasSuccess = true;
|
|
12816
|
-
else logger$
|
|
12916
|
+
else logger$24.warn({
|
|
12817
12917
|
storyKey,
|
|
12818
12918
|
status: checkpointRetryResult.status
|
|
12819
12919
|
}, "Checkpoint retry completed with failure — proceeding to code review");
|
|
@@ -12821,13 +12921,13 @@ function createImplementationOrchestrator(deps) {
|
|
|
12821
12921
|
}
|
|
12822
12922
|
if (!checkpointHandled) if (devResult.result === "success") devStoryWasSuccess = true;
|
|
12823
12923
|
else {
|
|
12824
|
-
logger$
|
|
12924
|
+
logger$24.warn({
|
|
12825
12925
|
storyKey,
|
|
12826
12926
|
error: devResult.error,
|
|
12827
12927
|
filesModified: devFilesModified.length
|
|
12828
12928
|
}, "Dev-story reported failure, proceeding to code review");
|
|
12829
12929
|
if (!devResult.error?.startsWith("dispatch_timeout")) {
|
|
12830
|
-
logger$
|
|
12930
|
+
logger$24.warn({
|
|
12831
12931
|
storyKey,
|
|
12832
12932
|
error: devResult.error
|
|
12833
12933
|
}, "Agent process failure (non-timeout) — story will proceed to code review with partial work");
|
|
@@ -12874,12 +12974,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
12874
12974
|
}).trim();
|
|
12875
12975
|
hasNewCommits = currentHead !== baselineHeadSha;
|
|
12876
12976
|
} catch {}
|
|
12877
|
-
if (hasNewCommits) logger$
|
|
12977
|
+
if (hasNewCommits) logger$24.info({
|
|
12878
12978
|
storyKey,
|
|
12879
12979
|
baselineHeadSha
|
|
12880
12980
|
}, "Working tree clean but new commits detected since dispatch — skipping zero-diff escalation");
|
|
12881
12981
|
else {
|
|
12882
|
-
logger$
|
|
12982
|
+
logger$24.warn({ storyKey }, "Zero-diff detected after COMPLETE dev-story — no file changes and no new commits");
|
|
12883
12983
|
eventBus.emit("orchestrator:zero-diff-escalation", {
|
|
12884
12984
|
storyKey,
|
|
12885
12985
|
reason: "zero-diff-on-complete"
|
|
@@ -12929,10 +13029,10 @@ function createImplementationOrchestrator(deps) {
|
|
|
12929
13029
|
"pipe"
|
|
12930
13030
|
]
|
|
12931
13031
|
});
|
|
12932
|
-
logger$
|
|
13032
|
+
logger$24.info({ storyKey }, "Secondary typecheck (tsc --noEmit) passed");
|
|
12933
13033
|
} catch (tscErr) {
|
|
12934
13034
|
const tscOutput = tscErr instanceof Error && "stdout" in tscErr ? String(tscErr.stdout ?? "").slice(0, 2e3) : "";
|
|
12935
|
-
logger$
|
|
13035
|
+
logger$24.warn({
|
|
12936
13036
|
storyKey,
|
|
12937
13037
|
tscOutput
|
|
12938
13038
|
}, "Secondary typecheck (tsc --noEmit) failed — treating as build failure");
|
|
@@ -12947,7 +13047,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12947
13047
|
if (buildVerifyResult.status === "passed") {
|
|
12948
13048
|
_buildPassed = true;
|
|
12949
13049
|
eventBus.emit("story:build-verification-passed", { storyKey });
|
|
12950
|
-
logger$
|
|
13050
|
+
logger$24.info({ storyKey }, "Build verification passed");
|
|
12951
13051
|
} else if (buildVerifyResult.status === "failed" || buildVerifyResult.status === "timeout") {
|
|
12952
13052
|
const truncatedOutput = (buildVerifyResult.output ?? "").slice(0, 2e3);
|
|
12953
13053
|
const reason = buildVerifyResult.reason ?? "build-verification-failed";
|
|
@@ -12956,7 +13056,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12956
13056
|
const resolvedRoot = projectRoot ?? process.cwd();
|
|
12957
13057
|
const hasChanges = detectPackageChanges(_packageSnapshot, resolvedRoot);
|
|
12958
13058
|
if (hasChanges) {
|
|
12959
|
-
logger$
|
|
13059
|
+
logger$24.warn({ storyKey }, "Package files changed since snapshot — restoring to prevent cascade");
|
|
12960
13060
|
const restoreResult = restorePackageSnapshot(_packageSnapshot, { projectRoot: resolvedRoot });
|
|
12961
13061
|
if (restoreResult.restored) {
|
|
12962
13062
|
const retryAfterRestore = runBuildVerification({
|
|
@@ -12969,11 +13069,11 @@ function createImplementationOrchestrator(deps) {
|
|
|
12969
13069
|
retryPassed = true;
|
|
12970
13070
|
_buildPassed = true;
|
|
12971
13071
|
eventBus.emit("story:build-verification-passed", { storyKey });
|
|
12972
|
-
logger$
|
|
13072
|
+
logger$24.warn({
|
|
12973
13073
|
storyKey,
|
|
12974
13074
|
filesRestored: restoreResult.filesRestored
|
|
12975
13075
|
}, "Build passed after package snapshot restore — cross-story pollution detected and cleaned");
|
|
12976
|
-
} else logger$
|
|
13076
|
+
} else logger$24.warn({
|
|
12977
13077
|
storyKey,
|
|
12978
13078
|
filesRestored: restoreResult.filesRestored
|
|
12979
13079
|
}, "Build still fails after snapshot restore — story has its own build errors");
|
|
@@ -12985,7 +13085,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12985
13085
|
if (missingPkgMatch && buildVerifyResult.status !== "timeout") {
|
|
12986
13086
|
const missingPkg = missingPkgMatch[1].replace(/^(@[^/]+\/[^/]+)\/.*$/, "$1").replace(/^([^@][^/]*)\/.*$/, "$1");
|
|
12987
13087
|
const resolvedRoot = projectRoot ?? process.cwd();
|
|
12988
|
-
logger$
|
|
13088
|
+
logger$24.warn({
|
|
12989
13089
|
storyKey,
|
|
12990
13090
|
missingPkg
|
|
12991
13091
|
}, "Build-fix retry: detected missing npm package — attempting npm install");
|
|
@@ -12996,7 +13096,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
12996
13096
|
encoding: "utf-8",
|
|
12997
13097
|
stdio: "pipe"
|
|
12998
13098
|
});
|
|
12999
|
-
logger$
|
|
13099
|
+
logger$24.warn({
|
|
13000
13100
|
storyKey,
|
|
13001
13101
|
missingPkg
|
|
13002
13102
|
}, "Build-fix retry: npm install succeeded — retrying build verification");
|
|
@@ -13010,18 +13110,18 @@ function createImplementationOrchestrator(deps) {
|
|
|
13010
13110
|
retryPassed = true;
|
|
13011
13111
|
_buildPassed = true;
|
|
13012
13112
|
eventBus.emit("story:build-verification-passed", { storyKey });
|
|
13013
|
-
logger$
|
|
13113
|
+
logger$24.warn({
|
|
13014
13114
|
storyKey,
|
|
13015
13115
|
missingPkg
|
|
13016
13116
|
}, "Build-fix retry: build verification passed after installing missing package");
|
|
13017
|
-
} else logger$
|
|
13117
|
+
} else logger$24.warn({
|
|
13018
13118
|
storyKey,
|
|
13019
13119
|
missingPkg,
|
|
13020
13120
|
retryStatus: retryResult.status
|
|
13021
13121
|
}, "Build-fix retry: build still fails after installing missing package — escalating");
|
|
13022
13122
|
} catch (installErr) {
|
|
13023
13123
|
const installMsg = installErr instanceof Error ? installErr.message : String(installErr);
|
|
13024
|
-
logger$
|
|
13124
|
+
logger$24.warn({
|
|
13025
13125
|
storyKey,
|
|
13026
13126
|
missingPkg,
|
|
13027
13127
|
error: installMsg
|
|
@@ -13031,7 +13131,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13031
13131
|
if (!retryPassed) {
|
|
13032
13132
|
let buildFixPassed = false;
|
|
13033
13133
|
if (buildVerifyResult.status === "failed" && storyFilePath !== void 0) try {
|
|
13034
|
-
logger$
|
|
13134
|
+
logger$24.info({ storyKey }, "Dispatching build-fix agent");
|
|
13035
13135
|
startPhase(storyKey, "build-fix");
|
|
13036
13136
|
const storyContent = await readFile$1(storyFilePath, "utf-8");
|
|
13037
13137
|
let buildFixTemplate;
|
|
@@ -13068,11 +13168,11 @@ function createImplementationOrchestrator(deps) {
|
|
|
13068
13168
|
buildFixPassed = true;
|
|
13069
13169
|
_buildPassed = true;
|
|
13070
13170
|
eventBus.emit("story:build-verification-passed", { storyKey });
|
|
13071
|
-
logger$
|
|
13072
|
-
} else logger$
|
|
13171
|
+
logger$24.info({ storyKey }, "Build passed after build-fix dispatch");
|
|
13172
|
+
} else logger$24.warn({ storyKey }, "Build still fails after build-fix dispatch — escalating");
|
|
13073
13173
|
} catch (fixErr) {
|
|
13074
13174
|
const fixMsg = fixErr instanceof Error ? fixErr.message : String(fixErr);
|
|
13075
|
-
logger$
|
|
13175
|
+
logger$24.warn({
|
|
13076
13176
|
storyKey,
|
|
13077
13177
|
error: fixMsg
|
|
13078
13178
|
}, "Build-fix dispatch failed — escalating");
|
|
@@ -13083,7 +13183,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13083
13183
|
exitCode: buildVerifyResult.exitCode ?? 1,
|
|
13084
13184
|
output: truncatedOutput
|
|
13085
13185
|
});
|
|
13086
|
-
logger$
|
|
13186
|
+
logger$24.warn({
|
|
13087
13187
|
storyKey,
|
|
13088
13188
|
reason,
|
|
13089
13189
|
exitCode: buildVerifyResult.exitCode
|
|
@@ -13115,7 +13215,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13115
13215
|
storyKey
|
|
13116
13216
|
});
|
|
13117
13217
|
if (icResult.potentiallyAffectedTests.length > 0) {
|
|
13118
|
-
logger$
|
|
13218
|
+
logger$24.warn({
|
|
13119
13219
|
storyKey,
|
|
13120
13220
|
modifiedInterfaces: icResult.modifiedInterfaces,
|
|
13121
13221
|
potentiallyAffectedTests: icResult.potentiallyAffectedTests
|
|
@@ -13196,7 +13296,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13196
13296
|
"NEEDS_MAJOR_REWORK": 2
|
|
13197
13297
|
};
|
|
13198
13298
|
for (const group of batchFileGroups) {
|
|
13199
|
-
logger$
|
|
13299
|
+
logger$24.info({
|
|
13200
13300
|
storyKey,
|
|
13201
13301
|
batchIndex: group.batchIndex,
|
|
13202
13302
|
fileCount: group.files.length
|
|
@@ -13240,7 +13340,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13240
13340
|
rawOutput: lastRawOutput,
|
|
13241
13341
|
tokenUsage: aggregateTokens
|
|
13242
13342
|
};
|
|
13243
|
-
logger$
|
|
13343
|
+
logger$24.info({
|
|
13244
13344
|
storyKey,
|
|
13245
13345
|
batchCount: batchFileGroups.length,
|
|
13246
13346
|
verdict: worstVerdict,
|
|
@@ -13283,7 +13383,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13283
13383
|
})
|
|
13284
13384
|
});
|
|
13285
13385
|
} catch (tokenErr) {
|
|
13286
|
-
logger$
|
|
13386
|
+
logger$24.warn({
|
|
13287
13387
|
storyKey,
|
|
13288
13388
|
err: tokenErr
|
|
13289
13389
|
}, "Failed to record code-review token usage");
|
|
@@ -13291,7 +13391,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13291
13391
|
const isPhantomReview = reviewResult.dispatchFailed === true || reviewResult.verdict !== "SHIP_IT" && reviewResult.verdict !== "LGTM_WITH_NOTES" && (reviewResult.issue_list === void 0 || reviewResult.issue_list.length === 0) && reviewResult.error !== void 0;
|
|
13292
13392
|
if (isPhantomReview && !timeoutRetried) {
|
|
13293
13393
|
timeoutRetried = true;
|
|
13294
|
-
logger$
|
|
13394
|
+
logger$24.warn({
|
|
13295
13395
|
storyKey,
|
|
13296
13396
|
reviewCycles,
|
|
13297
13397
|
error: reviewResult.error
|
|
@@ -13299,7 +13399,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13299
13399
|
continue;
|
|
13300
13400
|
}
|
|
13301
13401
|
if (isPhantomReview && timeoutRetried) {
|
|
13302
|
-
logger$
|
|
13402
|
+
logger$24.warn({
|
|
13303
13403
|
storyKey,
|
|
13304
13404
|
reviewCycles,
|
|
13305
13405
|
error: reviewResult.error
|
|
@@ -13323,7 +13423,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13323
13423
|
verdict = reviewResult.verdict;
|
|
13324
13424
|
issueList = reviewResult.issue_list ?? [];
|
|
13325
13425
|
if (verdict === "NEEDS_MAJOR_REWORK" && reviewCycles > 0 && previousIssueList.length > 0 && issueList.length < previousIssueList.length) {
|
|
13326
|
-
logger$
|
|
13426
|
+
logger$24.info({
|
|
13327
13427
|
storyKey,
|
|
13328
13428
|
originalVerdict: verdict,
|
|
13329
13429
|
issuesBefore: previousIssueList.length,
|
|
@@ -13359,7 +13459,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13359
13459
|
if (_decomposition !== void 0) parts.push(`decomposed: ${_decomposition.batchCount} batches`);
|
|
13360
13460
|
parts.push(`${fileCount} files`);
|
|
13361
13461
|
parts.push(`${totalTokensK} tokens`);
|
|
13362
|
-
logger$
|
|
13462
|
+
logger$24.info({
|
|
13363
13463
|
storyKey,
|
|
13364
13464
|
verdict,
|
|
13365
13465
|
agentVerdict: reviewResult.agentVerdict
|
|
@@ -13405,7 +13505,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13405
13505
|
phase: "VERIFICATION_FAILED",
|
|
13406
13506
|
completedAt: new Date().toISOString()
|
|
13407
13507
|
});
|
|
13408
|
-
persistStoryState(storyKey, _stories.get(storyKey)).catch((err) => logger$
|
|
13508
|
+
persistStoryState(storyKey, _stories.get(storyKey)).catch((err) => logger$24.warn({
|
|
13409
13509
|
err,
|
|
13410
13510
|
storyKey
|
|
13411
13511
|
}, "StateStore write failed after verification-failed"));
|
|
@@ -13438,9 +13538,9 @@ function createImplementationOrchestrator(deps) {
|
|
|
13438
13538
|
}),
|
|
13439
13539
|
rationale: `Advisory notes from LGTM_WITH_NOTES review of ${storyKey}`
|
|
13440
13540
|
});
|
|
13441
|
-
logger$
|
|
13541
|
+
logger$24.info({ storyKey }, "Advisory notes persisted to decision store");
|
|
13442
13542
|
} catch (advisoryErr) {
|
|
13443
|
-
logger$
|
|
13543
|
+
logger$24.warn({
|
|
13444
13544
|
storyKey,
|
|
13445
13545
|
error: advisoryErr instanceof Error ? advisoryErr.message : String(advisoryErr)
|
|
13446
13546
|
}, "Failed to persist advisory notes (best-effort)");
|
|
@@ -13448,27 +13548,27 @@ function createImplementationOrchestrator(deps) {
|
|
|
13448
13548
|
if (telemetryPersistence !== void 0) try {
|
|
13449
13549
|
const turns = await telemetryPersistence.getTurnAnalysis(storyKey);
|
|
13450
13550
|
if (turns.length > 0) {
|
|
13451
|
-
const scorer = new EfficiencyScorer(logger$
|
|
13551
|
+
const scorer = new EfficiencyScorer(logger$24);
|
|
13452
13552
|
const effScore = scorer.score(storyKey, turns);
|
|
13453
13553
|
await telemetryPersistence.storeEfficiencyScore(effScore);
|
|
13454
|
-
logger$
|
|
13554
|
+
logger$24.info({
|
|
13455
13555
|
storyKey,
|
|
13456
13556
|
compositeScore: effScore.compositeScore,
|
|
13457
13557
|
modelCount: effScore.perModelBreakdown.length
|
|
13458
13558
|
}, "Efficiency score computed and persisted");
|
|
13459
|
-
} else logger$
|
|
13559
|
+
} else logger$24.debug({ storyKey }, "No turn analysis data available — skipping efficiency scoring");
|
|
13460
13560
|
} catch (effErr) {
|
|
13461
|
-
logger$
|
|
13561
|
+
logger$24.warn({
|
|
13462
13562
|
storyKey,
|
|
13463
13563
|
error: effErr instanceof Error ? effErr.message : String(effErr)
|
|
13464
13564
|
}, "Efficiency scoring failed — story verdict unchanged");
|
|
13465
13565
|
}
|
|
13466
13566
|
if (telemetryPersistence !== void 0) try {
|
|
13467
13567
|
const turns = await telemetryPersistence.getTurnAnalysis(storyKey);
|
|
13468
|
-
if (turns.length === 0) logger$
|
|
13568
|
+
if (turns.length === 0) logger$24.debug({ storyKey }, "No turn analysis data for telemetry categorization — skipping");
|
|
13469
13569
|
else {
|
|
13470
|
-
const categorizer = new Categorizer(logger$
|
|
13471
|
-
const consumerAnalyzer = new ConsumerAnalyzer(categorizer, logger$
|
|
13570
|
+
const categorizer = new Categorizer(logger$24);
|
|
13571
|
+
const consumerAnalyzer = new ConsumerAnalyzer(categorizer, logger$24);
|
|
13472
13572
|
const categoryStats = categorizer.computeCategoryStatsFromTurns(turns);
|
|
13473
13573
|
const consumerStats = consumerAnalyzer.analyzeFromTurns(turns);
|
|
13474
13574
|
await telemetryPersistence.storeCategoryStats(storyKey, categoryStats);
|
|
@@ -13476,7 +13576,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13476
13576
|
const growingCount = categoryStats.filter((c) => c.trend === "growing").length;
|
|
13477
13577
|
const topCategory = categoryStats[0]?.category ?? "none";
|
|
13478
13578
|
const topConsumer = consumerStats[0]?.consumerKey ?? "none";
|
|
13479
|
-
logger$
|
|
13579
|
+
logger$24.info({
|
|
13480
13580
|
storyKey,
|
|
13481
13581
|
topCategory,
|
|
13482
13582
|
topConsumer,
|
|
@@ -13484,7 +13584,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13484
13584
|
}, "Semantic categorization and consumer analysis complete");
|
|
13485
13585
|
}
|
|
13486
13586
|
} catch (catErr) {
|
|
13487
|
-
logger$
|
|
13587
|
+
logger$24.warn({
|
|
13488
13588
|
storyKey,
|
|
13489
13589
|
error: catErr instanceof Error ? catErr.message : String(catErr)
|
|
13490
13590
|
}, "Semantic categorization failed — story verdict unchanged");
|
|
@@ -13506,7 +13606,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13506
13606
|
filesModified: devFilesModified,
|
|
13507
13607
|
workingDirectory: projectRoot
|
|
13508
13608
|
});
|
|
13509
|
-
logger$
|
|
13609
|
+
logger$24.debug({
|
|
13510
13610
|
storyKey,
|
|
13511
13611
|
expansion_priority: expansionResult.expansion_priority,
|
|
13512
13612
|
coverage_gaps: expansionResult.coverage_gaps.length
|
|
@@ -13519,7 +13619,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13519
13619
|
value: JSON.stringify(expansionResult)
|
|
13520
13620
|
});
|
|
13521
13621
|
} catch (expansionErr) {
|
|
13522
|
-
logger$
|
|
13622
|
+
logger$24.warn({
|
|
13523
13623
|
storyKey,
|
|
13524
13624
|
error: expansionErr instanceof Error ? expansionErr.message : String(expansionErr)
|
|
13525
13625
|
}, "Test expansion failed — story verdict unchanged");
|
|
@@ -13546,7 +13646,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13546
13646
|
await persistState();
|
|
13547
13647
|
return;
|
|
13548
13648
|
}
|
|
13549
|
-
logger$
|
|
13649
|
+
logger$24.info({
|
|
13550
13650
|
storyKey,
|
|
13551
13651
|
reviewCycles: finalReviewCycles,
|
|
13552
13652
|
issueCount: issueList.length
|
|
@@ -13606,7 +13706,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13606
13706
|
fixPrompt = assembled.prompt;
|
|
13607
13707
|
} catch {
|
|
13608
13708
|
fixPrompt = `Fix story ${storyKey}: verdict=${verdict}, minor fixes needed`;
|
|
13609
|
-
logger$
|
|
13709
|
+
logger$24.warn({ storyKey }, "Failed to assemble auto-approve fix prompt, using fallback");
|
|
13610
13710
|
}
|
|
13611
13711
|
const handle = dispatcher.dispatch({
|
|
13612
13712
|
prompt: fixPrompt,
|
|
@@ -13627,9 +13727,9 @@ function createImplementationOrchestrator(deps) {
|
|
|
13627
13727
|
output: fixResult.tokenEstimate.output
|
|
13628
13728
|
} : void 0 }
|
|
13629
13729
|
});
|
|
13630
|
-
if (fixResult.status === "timeout") logger$
|
|
13730
|
+
if (fixResult.status === "timeout") logger$24.warn({ storyKey }, "Auto-approve fix timed out — approving anyway (issues were minor)");
|
|
13631
13731
|
} catch (err) {
|
|
13632
|
-
logger$
|
|
13732
|
+
logger$24.warn({
|
|
13633
13733
|
storyKey,
|
|
13634
13734
|
err
|
|
13635
13735
|
}, "Auto-approve fix dispatch failed — approving anyway (issues were minor)");
|
|
@@ -13668,7 +13768,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13668
13768
|
outcome: "retried",
|
|
13669
13769
|
cost_usd: 0,
|
|
13670
13770
|
timestamp: new Date().toISOString()
|
|
13671
|
-
}).catch((err) => logger$
|
|
13771
|
+
}).catch((err) => logger$24.warn({
|
|
13672
13772
|
err,
|
|
13673
13773
|
storyKey
|
|
13674
13774
|
}, "appendRecoveryEntry failed — pipeline continues"));
|
|
@@ -13797,7 +13897,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13797
13897
|
fixPrompt = assembled.prompt;
|
|
13798
13898
|
} catch {
|
|
13799
13899
|
fixPrompt = `Fix story ${storyKey}: verdict=${verdict}, taskType=${taskType}`;
|
|
13800
|
-
logger$
|
|
13900
|
+
logger$24.warn({
|
|
13801
13901
|
storyKey,
|
|
13802
13902
|
taskType
|
|
13803
13903
|
}, "Failed to assemble fix prompt, using fallback");
|
|
@@ -13834,7 +13934,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13834
13934
|
} : void 0 }
|
|
13835
13935
|
});
|
|
13836
13936
|
if (fixResult.status === "timeout") {
|
|
13837
|
-
logger$
|
|
13937
|
+
logger$24.warn({
|
|
13838
13938
|
storyKey,
|
|
13839
13939
|
taskType
|
|
13840
13940
|
}, "Fix dispatch timed out — escalating story");
|
|
@@ -13856,7 +13956,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13856
13956
|
}
|
|
13857
13957
|
if (fixResult.status === "failed") {
|
|
13858
13958
|
if (isMajorRework) {
|
|
13859
|
-
logger$
|
|
13959
|
+
logger$24.warn({
|
|
13860
13960
|
storyKey,
|
|
13861
13961
|
exitCode: fixResult.exitCode
|
|
13862
13962
|
}, "Major rework dispatch failed — escalating story");
|
|
@@ -13876,14 +13976,14 @@ function createImplementationOrchestrator(deps) {
|
|
|
13876
13976
|
await persistState();
|
|
13877
13977
|
return;
|
|
13878
13978
|
}
|
|
13879
|
-
logger$
|
|
13979
|
+
logger$24.warn({
|
|
13880
13980
|
storyKey,
|
|
13881
13981
|
taskType,
|
|
13882
13982
|
exitCode: fixResult.exitCode
|
|
13883
13983
|
}, "Fix dispatch failed");
|
|
13884
13984
|
}
|
|
13885
13985
|
} catch (err) {
|
|
13886
|
-
logger$
|
|
13986
|
+
logger$24.warn({
|
|
13887
13987
|
storyKey,
|
|
13888
13988
|
taskType,
|
|
13889
13989
|
err
|
|
@@ -13934,7 +14034,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13934
14034
|
...haltOn !== "none" ? { severity: "critical" } : {}
|
|
13935
14035
|
});
|
|
13936
14036
|
_budgetExhausted = true;
|
|
13937
|
-
logger$
|
|
14037
|
+
logger$24.warn({
|
|
13938
14038
|
skipped: allSkipped.length,
|
|
13939
14039
|
cumulative: result.cumulative,
|
|
13940
14040
|
ceiling: result.ceiling
|
|
@@ -13970,7 +14070,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
13970
14070
|
}
|
|
13971
14071
|
}
|
|
13972
14072
|
} catch (err) {
|
|
13973
|
-
logger$
|
|
14073
|
+
logger$24.debug({ err }, "Cost ceiling check failed — proceeding without enforcement");
|
|
13974
14074
|
}
|
|
13975
14075
|
let optimizationDirectives;
|
|
13976
14076
|
if (telemetryAdvisor !== void 0 && completedStoryKeys.length > 0) try {
|
|
@@ -13978,13 +14078,13 @@ function createImplementationOrchestrator(deps) {
|
|
|
13978
14078
|
const directives = telemetryAdvisor.formatOptimizationDirectives(recs);
|
|
13979
14079
|
if (directives.length > 0) {
|
|
13980
14080
|
optimizationDirectives = directives;
|
|
13981
|
-
logger$
|
|
14081
|
+
logger$24.debug({
|
|
13982
14082
|
storyKey,
|
|
13983
14083
|
directiveCount: recs.filter((r) => r.severity !== "info").length
|
|
13984
14084
|
}, "Optimization directives ready for dispatch");
|
|
13985
14085
|
}
|
|
13986
14086
|
} catch (err) {
|
|
13987
|
-
logger$
|
|
14087
|
+
logger$24.debug({
|
|
13988
14088
|
err,
|
|
13989
14089
|
storyKey
|
|
13990
14090
|
}, "Failed to fetch optimization directives — proceeding without");
|
|
@@ -14023,11 +14123,11 @@ function createImplementationOrchestrator(deps) {
|
|
|
14023
14123
|
}
|
|
14024
14124
|
async function run(storyKeys) {
|
|
14025
14125
|
if (_state === "RUNNING" || _state === "PAUSED") {
|
|
14026
|
-
logger$
|
|
14126
|
+
logger$24.warn({ state: _state }, "run() called while orchestrator is already running or paused — ignoring");
|
|
14027
14127
|
return getStatus();
|
|
14028
14128
|
}
|
|
14029
14129
|
if (_state === "COMPLETE") {
|
|
14030
|
-
logger$
|
|
14130
|
+
logger$24.warn({ state: _state }, "run() called on a COMPLETE orchestrator — ignoring");
|
|
14031
14131
|
return getStatus();
|
|
14032
14132
|
}
|
|
14033
14133
|
_state = "RUNNING";
|
|
@@ -14051,7 +14151,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14051
14151
|
const seedStart = Date.now();
|
|
14052
14152
|
const seedResult = await seedMethodologyContext(db, projectRoot);
|
|
14053
14153
|
_startupTimings.seedMethodologyMs = Date.now() - seedStart;
|
|
14054
|
-
if (seedResult.decisionsCreated > 0) logger$
|
|
14154
|
+
if (seedResult.decisionsCreated > 0) logger$24.info({
|
|
14055
14155
|
decisionsCreated: seedResult.decisionsCreated,
|
|
14056
14156
|
skippedCategories: seedResult.skippedCategories,
|
|
14057
14157
|
durationMs: _startupTimings.seedMethodologyMs
|
|
@@ -14061,12 +14161,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
14061
14161
|
const ingestStart = Date.now();
|
|
14062
14162
|
try {
|
|
14063
14163
|
const ingestResult = await autoIngestEpicsDependencies(db, projectRoot);
|
|
14064
|
-
if (ingestResult.storiesIngested > 0 || ingestResult.dependenciesIngested > 0) logger$
|
|
14164
|
+
if (ingestResult.storiesIngested > 0 || ingestResult.dependenciesIngested > 0) logger$24.info({
|
|
14065
14165
|
...ingestResult,
|
|
14066
14166
|
durationMs: Date.now() - ingestStart
|
|
14067
14167
|
}, "Auto-ingested stories and dependencies from epics document");
|
|
14068
14168
|
} catch (err) {
|
|
14069
|
-
logger$
|
|
14169
|
+
logger$24.debug({ err }, "Auto-ingest from epics document skipped — work graph may be unavailable");
|
|
14070
14170
|
}
|
|
14071
14171
|
}
|
|
14072
14172
|
try {
|
|
@@ -14076,7 +14176,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14076
14176
|
_startupTimings.stateStoreInitMs = Date.now() - stateStoreInitStart;
|
|
14077
14177
|
for (const key of storyKeys) {
|
|
14078
14178
|
const pendingState = _stories.get(key);
|
|
14079
|
-
if (pendingState !== void 0) persistStoryState(key, pendingState).catch((err) => logger$
|
|
14179
|
+
if (pendingState !== void 0) persistStoryState(key, pendingState).catch((err) => logger$24.warn({
|
|
14080
14180
|
err,
|
|
14081
14181
|
storyKey: key
|
|
14082
14182
|
}, "StateStore write failed during PENDING init"));
|
|
@@ -14087,12 +14187,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
14087
14187
|
_startupTimings.queryStoriesMs = Date.now() - queryStoriesStart;
|
|
14088
14188
|
for (const record of existingRecords) _stateStoreCache.set(record.storyKey, record);
|
|
14089
14189
|
} catch (err) {
|
|
14090
|
-
logger$
|
|
14190
|
+
logger$24.warn({ err }, "StateStore.queryStories() failed during init — status merge will be empty (best-effort)");
|
|
14091
14191
|
}
|
|
14092
14192
|
}
|
|
14093
14193
|
if (ingestionServer !== void 0) {
|
|
14094
14194
|
if (telemetryPersistence !== void 0) try {
|
|
14095
|
-
const pipelineLogger = logger$
|
|
14195
|
+
const pipelineLogger = logger$24;
|
|
14096
14196
|
const telemetryPipeline = new TelemetryPipeline({
|
|
14097
14197
|
normalizer: new TelemetryNormalizer(pipelineLogger),
|
|
14098
14198
|
turnAnalyzer: new TurnAnalyzer(pipelineLogger),
|
|
@@ -14104,14 +14204,14 @@ function createImplementationOrchestrator(deps) {
|
|
|
14104
14204
|
persistence: telemetryPersistence
|
|
14105
14205
|
});
|
|
14106
14206
|
ingestionServer.setPipeline(telemetryPipeline);
|
|
14107
|
-
logger$
|
|
14207
|
+
logger$24.info("TelemetryPipeline wired to IngestionServer");
|
|
14108
14208
|
} catch (pipelineErr) {
|
|
14109
|
-
logger$
|
|
14209
|
+
logger$24.warn({ err: pipelineErr }, "Failed to create TelemetryPipeline — continuing without analysis pipeline");
|
|
14110
14210
|
}
|
|
14111
|
-
await ingestionServer.start().catch((err) => logger$
|
|
14211
|
+
await ingestionServer.start().catch((err) => logger$24.warn({ err }, "IngestionServer.start() failed — continuing without telemetry (best-effort)"));
|
|
14112
14212
|
try {
|
|
14113
14213
|
_otlpEndpoint = ingestionServer.getOtlpEnvVars().OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
14114
|
-
logger$
|
|
14214
|
+
logger$24.info({ otlpEndpoint: _otlpEndpoint }, "OTLP telemetry ingestion active");
|
|
14115
14215
|
} catch {}
|
|
14116
14216
|
}
|
|
14117
14217
|
let contractDeclarations = [];
|
|
@@ -14151,12 +14251,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
14151
14251
|
const conflictDetectStart = Date.now();
|
|
14152
14252
|
const { batches, edges: contractEdges } = detectConflictGroupsWithContracts(storyKeys, { moduleMap: pack.manifest.conflictGroups }, contractDeclarations);
|
|
14153
14253
|
_startupTimings.conflictDetectMs = Date.now() - conflictDetectStart;
|
|
14154
|
-
if (contractEdges.length > 0) logger$
|
|
14254
|
+
if (contractEdges.length > 0) logger$24.info({
|
|
14155
14255
|
contractEdges,
|
|
14156
14256
|
edgeCount: contractEdges.length
|
|
14157
14257
|
}, "Contract dependency edges detected — applying contract-aware dispatch ordering");
|
|
14158
|
-
wgRepo.addContractDependencies(contractEdges).catch((err) => logger$
|
|
14159
|
-
logger$
|
|
14258
|
+
wgRepo.addContractDependencies(contractEdges).catch((err) => logger$24.warn({ err }, "contract dep persistence failed (best-effort)"));
|
|
14259
|
+
logger$24.info({
|
|
14160
14260
|
storyCount: storyKeys.length,
|
|
14161
14261
|
groupCount: batches.reduce((sum, b) => sum + b.length, 0),
|
|
14162
14262
|
batchCount: batches.length,
|
|
@@ -14166,7 +14266,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14166
14266
|
groups: batch.map((g) => g.join(","))
|
|
14167
14267
|
}))
|
|
14168
14268
|
}, "Orchestrator starting");
|
|
14169
|
-
logger$
|
|
14269
|
+
logger$24.info({
|
|
14170
14270
|
storyCount: storyKeys.length,
|
|
14171
14271
|
conflictGroups: batches.length,
|
|
14172
14272
|
maxConcurrency: config.maxConcurrency
|
|
@@ -14187,7 +14287,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14187
14287
|
exitCode,
|
|
14188
14288
|
output: truncatedOutput
|
|
14189
14289
|
});
|
|
14190
|
-
logger$
|
|
14290
|
+
logger$24.error({
|
|
14191
14291
|
exitCode,
|
|
14192
14292
|
reason: preFlightResult.reason
|
|
14193
14293
|
}, "Pre-flight build check failed — aborting pipeline before any story dispatch");
|
|
@@ -14196,19 +14296,19 @@ function createImplementationOrchestrator(deps) {
|
|
|
14196
14296
|
await persistState();
|
|
14197
14297
|
return getStatus();
|
|
14198
14298
|
}
|
|
14199
|
-
if (preFlightResult.status !== "skipped") logger$
|
|
14299
|
+
if (preFlightResult.status !== "skipped") logger$24.info("Pre-flight build check passed");
|
|
14200
14300
|
}
|
|
14201
|
-
logger$
|
|
14301
|
+
logger$24.info(_startupTimings, "Orchestrator startup timings (ms)");
|
|
14202
14302
|
const totalGroups = batches.reduce((sum, b) => sum + b.length, 0);
|
|
14203
14303
|
const actualConcurrency = Math.min(config.maxConcurrency, totalGroups);
|
|
14204
14304
|
if (actualConcurrency > 1 && projectRoot !== void 0) try {
|
|
14205
14305
|
_packageSnapshot = capturePackageSnapshot({ projectRoot });
|
|
14206
|
-
logger$
|
|
14306
|
+
logger$24.info({
|
|
14207
14307
|
fileCount: _packageSnapshot.files.size,
|
|
14208
14308
|
installCommand: _packageSnapshot.installCommand
|
|
14209
14309
|
}, "Package snapshot captured for concurrent story protection");
|
|
14210
14310
|
} catch (snapErr) {
|
|
14211
|
-
logger$
|
|
14311
|
+
logger$24.warn({ err: snapErr }, "Failed to capture package snapshot — continuing without protection");
|
|
14212
14312
|
}
|
|
14213
14313
|
try {
|
|
14214
14314
|
for (const batchGroups of batches) await runWithConcurrency(batchGroups, config.maxConcurrency);
|
|
@@ -14217,7 +14317,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14217
14317
|
_state = "FAILED";
|
|
14218
14318
|
_completedAt = new Date().toISOString();
|
|
14219
14319
|
await persistState();
|
|
14220
|
-
logger$
|
|
14320
|
+
logger$24.error({ err }, "Orchestrator failed with unhandled error");
|
|
14221
14321
|
return getStatus();
|
|
14222
14322
|
}
|
|
14223
14323
|
stopHeartbeat();
|
|
@@ -14227,7 +14327,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14227
14327
|
const totalDeclarations = contractDeclarations.length;
|
|
14228
14328
|
const currentSprintDeclarations = contractDeclarations.filter((d) => storyKeys.includes(d.storyKey));
|
|
14229
14329
|
const stalePruned = totalDeclarations - currentSprintDeclarations.length;
|
|
14230
|
-
if (stalePruned > 0) logger$
|
|
14330
|
+
if (stalePruned > 0) logger$24.info({
|
|
14231
14331
|
stalePruned,
|
|
14232
14332
|
remaining: currentSprintDeclarations.length
|
|
14233
14333
|
}, "Pruned stale contract declarations from previous epics");
|
|
@@ -14241,11 +14341,11 @@ function createImplementationOrchestrator(deps) {
|
|
|
14241
14341
|
contractName: mismatch.contractName,
|
|
14242
14342
|
mismatchDescription: mismatch.mismatchDescription
|
|
14243
14343
|
});
|
|
14244
|
-
logger$
|
|
14344
|
+
logger$24.warn({
|
|
14245
14345
|
mismatchCount: mismatches.length,
|
|
14246
14346
|
mismatches
|
|
14247
14347
|
}, "Post-sprint contract verification found mismatches — manual review required");
|
|
14248
|
-
} else if (currentSprintDeclarations.length > 0) logger$
|
|
14348
|
+
} else if (currentSprintDeclarations.length > 0) logger$24.info("Post-sprint contract verification passed — all declared contracts satisfied");
|
|
14249
14349
|
eventBus.emit("pipeline:contract-verification-summary", {
|
|
14250
14350
|
verified: currentSprintDeclarations.length,
|
|
14251
14351
|
stalePruned,
|
|
@@ -14280,12 +14380,12 @@ function createImplementationOrchestrator(deps) {
|
|
|
14280
14380
|
});
|
|
14281
14381
|
await stateStore.setContractVerification(sk, records);
|
|
14282
14382
|
}
|
|
14283
|
-
logger$
|
|
14383
|
+
logger$24.info({ storyCount: contractsByStory.size }, "Contract verification results persisted to StateStore");
|
|
14284
14384
|
} catch (persistErr) {
|
|
14285
|
-
logger$
|
|
14385
|
+
logger$24.warn({ err: persistErr }, "Failed to persist contract verification results to StateStore");
|
|
14286
14386
|
}
|
|
14287
14387
|
} catch (err) {
|
|
14288
|
-
logger$
|
|
14388
|
+
logger$24.error({ err }, "Post-sprint contract verification threw an error — skipping");
|
|
14289
14389
|
}
|
|
14290
14390
|
if (projectRoot !== void 0) try {
|
|
14291
14391
|
const indicators = checkProfileStaleness(projectRoot);
|
|
@@ -14295,10 +14395,10 @@ function createImplementationOrchestrator(deps) {
|
|
|
14295
14395
|
message,
|
|
14296
14396
|
indicators
|
|
14297
14397
|
});
|
|
14298
|
-
logger$
|
|
14398
|
+
logger$24.warn({ indicators }, message);
|
|
14299
14399
|
}
|
|
14300
14400
|
} catch (err) {
|
|
14301
|
-
logger$
|
|
14401
|
+
logger$24.debug({ err }, "Profile staleness check failed (best-effort)");
|
|
14302
14402
|
}
|
|
14303
14403
|
let completed = 0;
|
|
14304
14404
|
let escalated = 0;
|
|
@@ -14316,8 +14416,8 @@ function createImplementationOrchestrator(deps) {
|
|
|
14316
14416
|
await persistState();
|
|
14317
14417
|
return getStatus();
|
|
14318
14418
|
} finally {
|
|
14319
|
-
if (stateStore !== void 0) await stateStore.close().catch((err) => logger$
|
|
14320
|
-
if (ingestionServer !== void 0) await ingestionServer.stop().catch((err) => logger$
|
|
14419
|
+
if (stateStore !== void 0) await stateStore.close().catch((err) => logger$24.warn({ err }, "StateStore.close() failed (best-effort)"));
|
|
14420
|
+
if (ingestionServer !== void 0) await ingestionServer.stop().catch((err) => logger$24.warn({ err }, "IngestionServer.stop() failed (best-effort)"));
|
|
14321
14421
|
}
|
|
14322
14422
|
}
|
|
14323
14423
|
function pause() {
|
|
@@ -14326,7 +14426,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14326
14426
|
_pauseGate = createPauseGate();
|
|
14327
14427
|
_state = "PAUSED";
|
|
14328
14428
|
eventBus.emit("orchestrator:paused", {});
|
|
14329
|
-
logger$
|
|
14429
|
+
logger$24.info("Orchestrator paused");
|
|
14330
14430
|
}
|
|
14331
14431
|
function resume() {
|
|
14332
14432
|
if (_state !== "PAUSED") return;
|
|
@@ -14337,7 +14437,7 @@ function createImplementationOrchestrator(deps) {
|
|
|
14337
14437
|
}
|
|
14338
14438
|
_state = "RUNNING";
|
|
14339
14439
|
eventBus.emit("orchestrator:resumed", {});
|
|
14340
|
-
logger$
|
|
14440
|
+
logger$24.info("Orchestrator resumed");
|
|
14341
14441
|
}
|
|
14342
14442
|
return {
|
|
14343
14443
|
run,
|
|
@@ -18478,16 +18578,129 @@ async function loadEscalationDiagnoses(adapter, runId) {
|
|
|
18478
18578
|
}
|
|
18479
18579
|
return results;
|
|
18480
18580
|
}
|
|
18581
|
+
async function buildRunReportFromManifest(runId, runsDir, adapter, opts) {
|
|
18582
|
+
try {
|
|
18583
|
+
const manifest = RunManifest.open(runId, runsDir);
|
|
18584
|
+
const data = await manifest.read();
|
|
18585
|
+
if (!data?.per_story_state || Object.keys(data.per_story_state).length === 0) {
|
|
18586
|
+
logger$2.warn({ runId }, "RunManifest has no per_story_state — cannot build RunReport");
|
|
18587
|
+
return null;
|
|
18588
|
+
}
|
|
18589
|
+
const MANIFEST_RESULT_MAP = {
|
|
18590
|
+
"complete": "SHIP_IT",
|
|
18591
|
+
"escalated": "ESCALATED",
|
|
18592
|
+
"failed": "FAILED",
|
|
18593
|
+
"verification-failed": "FAILED",
|
|
18594
|
+
"gated": "FAILED"
|
|
18595
|
+
};
|
|
18596
|
+
const stories = [];
|
|
18597
|
+
let totalInputTokens = 0;
|
|
18598
|
+
let totalOutputTokens = 0;
|
|
18599
|
+
let totalCostUsd = 0;
|
|
18600
|
+
let totalReviewCycles = 0;
|
|
18601
|
+
let totalDispatches = 0;
|
|
18602
|
+
let storiesSucceeded = 0;
|
|
18603
|
+
let storiesFailed = 0;
|
|
18604
|
+
let storiesEscalated = 0;
|
|
18605
|
+
const storyKeys = Object.keys(data.per_story_state);
|
|
18606
|
+
const escalationDiagnoses = await loadEscalationDiagnoses(adapter, runId);
|
|
18607
|
+
for (const [storyKey, state] of Object.entries(data.per_story_state)) {
|
|
18608
|
+
const result = MANIFEST_RESULT_MAP[state.status] ?? state.status.toUpperCase();
|
|
18609
|
+
let wallClockSeconds$1 = 0;
|
|
18610
|
+
if (state.started_at && state.completed_at) wallClockSeconds$1 = Math.round((new Date(state.completed_at).getTime() - new Date(state.started_at).getTime()) / 1e3);
|
|
18611
|
+
const costUsd = state.cost_usd ?? 0;
|
|
18612
|
+
const reviewCycles = state.review_cycles ?? 0;
|
|
18613
|
+
const dispatches = state.dispatches ?? 0;
|
|
18614
|
+
totalCostUsd += costUsd;
|
|
18615
|
+
totalReviewCycles += reviewCycles;
|
|
18616
|
+
totalDispatches += dispatches;
|
|
18617
|
+
if (result === "SHIP_IT" || result === "LGTM_WITH_NOTES" || result === "NEEDS_MINOR_FIXES") storiesSucceeded++;
|
|
18618
|
+
else if (result === "ESCALATED") storiesEscalated++;
|
|
18619
|
+
else storiesFailed++;
|
|
18620
|
+
const vr = state.verification_result ? {
|
|
18621
|
+
status: state.verification_result.status ?? "pass",
|
|
18622
|
+
checks: (state.verification_result.checks ?? []).map((c) => ({
|
|
18623
|
+
checkName: c.checkName,
|
|
18624
|
+
status: c.status,
|
|
18625
|
+
...c.details !== void 0 && { details: c.details },
|
|
18626
|
+
...c.duration_ms !== void 0 && { durationMs: c.duration_ms }
|
|
18627
|
+
}))
|
|
18628
|
+
} : void 0;
|
|
18629
|
+
const escalation = escalationDiagnoses[storyKey];
|
|
18630
|
+
stories.push({
|
|
18631
|
+
storyKey,
|
|
18632
|
+
result,
|
|
18633
|
+
wallClockSeconds: wallClockSeconds$1,
|
|
18634
|
+
...state.started_at && { startedAt: state.started_at },
|
|
18635
|
+
...state.completed_at && { completedAt: state.completed_at },
|
|
18636
|
+
inputTokens: 0,
|
|
18637
|
+
outputTokens: 0,
|
|
18638
|
+
costUsd,
|
|
18639
|
+
reviewCycles,
|
|
18640
|
+
dispatches,
|
|
18641
|
+
...escalation !== void 0 && {
|
|
18642
|
+
escalationReason: escalation.reason,
|
|
18643
|
+
...escalation.issues.length > 0 && { escalationIssues: escalation.issues }
|
|
18644
|
+
},
|
|
18645
|
+
...vr !== void 0 && {
|
|
18646
|
+
verificationStatus: vr.status,
|
|
18647
|
+
verificationChecks: vr.checks
|
|
18648
|
+
}
|
|
18649
|
+
});
|
|
18650
|
+
}
|
|
18651
|
+
const escalationFindings = Object.values(escalationDiagnoses).map((d) => d.finding);
|
|
18652
|
+
let wallClockSeconds = 0;
|
|
18653
|
+
if (data.created_at && data.updated_at) wallClockSeconds = Math.round((new Date(data.updated_at).getTime() - new Date(data.created_at).getTime()) / 1e3);
|
|
18654
|
+
const rawStatus = data.run_status ?? "completed";
|
|
18655
|
+
const status = rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "partial";
|
|
18656
|
+
const projectId = opts.projectId ?? (opts.projectRoot ? basename$1(opts.projectRoot) : "unknown");
|
|
18657
|
+
logger$2.info({
|
|
18658
|
+
runId,
|
|
18659
|
+
storyCount: stories.length
|
|
18660
|
+
}, "Built RunReport from manifest fallback");
|
|
18661
|
+
return {
|
|
18662
|
+
runId,
|
|
18663
|
+
projectId,
|
|
18664
|
+
substrateVersion: opts.substrateVersion ?? getSubstrateVersion(),
|
|
18665
|
+
timestamp: data.updated_at ?? new Date().toISOString(),
|
|
18666
|
+
...data.created_at && { startedAt: data.created_at },
|
|
18667
|
+
...data.updated_at && { completedAt: data.updated_at },
|
|
18668
|
+
status,
|
|
18669
|
+
wallClockSeconds,
|
|
18670
|
+
totalInputTokens,
|
|
18671
|
+
totalOutputTokens,
|
|
18672
|
+
totalCostUsd,
|
|
18673
|
+
storiesAttempted: stories.length,
|
|
18674
|
+
storiesSucceeded,
|
|
18675
|
+
storiesFailed,
|
|
18676
|
+
storiesEscalated,
|
|
18677
|
+
totalReviewCycles,
|
|
18678
|
+
totalDispatches,
|
|
18679
|
+
restarts: data.restart_count ?? 0,
|
|
18680
|
+
stories,
|
|
18681
|
+
...escalationFindings.length > 0 && { escalationFindings },
|
|
18682
|
+
agentBackend: opts.agentBackend ?? "claude-code",
|
|
18683
|
+
engineType: opts.engineType ?? "linear",
|
|
18684
|
+
concurrency: opts.concurrency ?? 3
|
|
18685
|
+
};
|
|
18686
|
+
} catch (err) {
|
|
18687
|
+
logger$2.warn({
|
|
18688
|
+
runId,
|
|
18689
|
+
err
|
|
18690
|
+
}, "Failed to build RunReport from manifest fallback");
|
|
18691
|
+
return null;
|
|
18692
|
+
}
|
|
18693
|
+
}
|
|
18481
18694
|
async function buildRunReport(adapter, runId, opts) {
|
|
18482
18695
|
const runMetrics = await getRunMetrics(adapter, runId);
|
|
18696
|
+
const storyMetrics = runMetrics ? await getStoryMetricsForRun(adapter, runId) : [];
|
|
18697
|
+
const dbDir = opts.projectRoot ? join$1(opts.projectRoot, ".substrate") : ".substrate";
|
|
18698
|
+
const runsDir = join$1(dbDir, "runs");
|
|
18483
18699
|
if (!runMetrics) {
|
|
18484
|
-
logger$2.warn({ runId }, "No run_metrics
|
|
18485
|
-
return
|
|
18700
|
+
logger$2.warn({ runId }, "No run_metrics in Dolt — falling back to RunManifest");
|
|
18701
|
+
return buildRunReportFromManifest(runId, runsDir, adapter, opts);
|
|
18486
18702
|
}
|
|
18487
|
-
const storyMetrics = await getStoryMetricsForRun(adapter, runId);
|
|
18488
18703
|
const storyKeys = storyMetrics.map((s$1) => s$1.story_key);
|
|
18489
|
-
const dbDir = opts.projectRoot ? join$1(opts.projectRoot, ".substrate") : ".substrate";
|
|
18490
|
-
const runsDir = join$1(dbDir, "runs");
|
|
18491
18704
|
const verificationResults = await loadVerificationResults(runId, runsDir);
|
|
18492
18705
|
const efficiencyScores = await loadEfficiencyScores(adapter, storyKeys);
|
|
18493
18706
|
const contractVerification = await loadContractVerification(adapter, runId);
|
|
@@ -31273,16 +31486,16 @@ var require_ajv = __commonJS({ "node_modules/ajv/lib/ajv.js"(exports, module) {
|
|
|
31273
31486
|
return metaOpts;
|
|
31274
31487
|
}
|
|
31275
31488
|
function setLogger(self) {
|
|
31276
|
-
var logger$
|
|
31277
|
-
if (logger$
|
|
31489
|
+
var logger$24 = self._opts.logger;
|
|
31490
|
+
if (logger$24 === false) self.logger = {
|
|
31278
31491
|
log: noop,
|
|
31279
31492
|
warn: noop,
|
|
31280
31493
|
error: noop
|
|
31281
31494
|
};
|
|
31282
31495
|
else {
|
|
31283
|
-
if (logger$
|
|
31284
|
-
if (!(typeof logger$
|
|
31285
|
-
self.logger = logger$
|
|
31496
|
+
if (logger$24 === void 0) logger$24 = console;
|
|
31497
|
+
if (!(typeof logger$24 == "object" && logger$24.log && logger$24.warn && logger$24.error)) throw new Error("logger must implement log, warn and error methods");
|
|
31498
|
+
self.logger = logger$24;
|
|
31286
31499
|
}
|
|
31287
31500
|
}
|
|
31288
31501
|
function noop() {}
|
|
@@ -41638,6 +41851,11 @@ async function runRunAction(options) {
|
|
|
41638
41851
|
});
|
|
41639
41852
|
let storyKeys = [...parsedStoryKeys];
|
|
41640
41853
|
if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
|
|
41854
|
+
let doltServer = null;
|
|
41855
|
+
try {
|
|
41856
|
+
doltServer = await startDoltServer(projectRoot);
|
|
41857
|
+
if (doltServer) registerServerCleanup(doltServer);
|
|
41858
|
+
} catch {}
|
|
41641
41859
|
const adapter = createDatabaseAdapter({
|
|
41642
41860
|
backend: "auto",
|
|
41643
41861
|
basePath: projectRoot
|
|
@@ -42291,11 +42509,17 @@ async function runRunAction(options) {
|
|
|
42291
42509
|
try {
|
|
42292
42510
|
await adapter.close();
|
|
42293
42511
|
} catch {}
|
|
42512
|
+
doltServer?.stop();
|
|
42294
42513
|
}
|
|
42295
42514
|
}
|
|
42296
42515
|
async function runFullPipeline(options) {
|
|
42297
42516
|
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 } = options;
|
|
42298
42517
|
if (!existsSync$1(dbDir)) mkdirSync$1(dbDir, { recursive: true });
|
|
42518
|
+
let doltServerFull = null;
|
|
42519
|
+
try {
|
|
42520
|
+
doltServerFull = await startDoltServer(projectRoot);
|
|
42521
|
+
if (doltServerFull) registerServerCleanup(doltServerFull);
|
|
42522
|
+
} catch {}
|
|
42299
42523
|
const adapter = createDatabaseAdapter({
|
|
42300
42524
|
backend: "auto",
|
|
42301
42525
|
basePath: projectRoot
|
|
@@ -42743,6 +42967,7 @@ async function runFullPipeline(options) {
|
|
|
42743
42967
|
try {
|
|
42744
42968
|
await adapter.close();
|
|
42745
42969
|
} catch {}
|
|
42970
|
+
doltServerFull?.stop();
|
|
42746
42971
|
}
|
|
42747
42972
|
}
|
|
42748
42973
|
function registerRunCommand(program, _version = "0.0.0", projectRoot = process.cwd(), registry) {
|
|
@@ -42796,4 +43021,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
|
|
|
42796
43021
|
|
|
42797
43022
|
//#endregion
|
|
42798
43023
|
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 };
|
|
42799
|
-
//# sourceMappingURL=run-
|
|
43024
|
+
//# sourceMappingURL=run-DI5SzKf5.js.map
|