@llm-dev-ops/agentics-cli 2.7.0 → 2.7.2

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.
Files changed (64) hide show
  1. package/dist/cli/index.js +30 -0
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/pipeline/auto-chain.d.ts +196 -2
  4. package/dist/pipeline/auto-chain.d.ts.map +1 -1
  5. package/dist/pipeline/auto-chain.js +1920 -884
  6. package/dist/pipeline/auto-chain.js.map +1 -1
  7. package/dist/pipeline/enterprise/agent-error-capture.d.ts +76 -0
  8. package/dist/pipeline/enterprise/agent-error-capture.d.ts.map +1 -0
  9. package/dist/pipeline/enterprise/agent-error-capture.js +141 -0
  10. package/dist/pipeline/enterprise/agent-error-capture.js.map +1 -0
  11. package/dist/pipeline/enterprise/artifact-renderers.d.ts +30 -0
  12. package/dist/pipeline/enterprise/artifact-renderers.d.ts.map +1 -1
  13. package/dist/pipeline/enterprise/artifact-renderers.js +129 -1
  14. package/dist/pipeline/enterprise/artifact-renderers.js.map +1 -1
  15. package/dist/pipeline/enterprise/pass-executor.d.ts.map +1 -1
  16. package/dist/pipeline/enterprise/pass-executor.js +52 -0
  17. package/dist/pipeline/enterprise/pass-executor.js.map +1 -1
  18. package/dist/pipeline/enterprise/pipeline-orchestrator.d.ts.map +1 -1
  19. package/dist/pipeline/enterprise/pipeline-orchestrator.js +15 -0
  20. package/dist/pipeline/enterprise/pipeline-orchestrator.js.map +1 -1
  21. package/dist/pipeline/enterprise/types.d.ts +21 -0
  22. package/dist/pipeline/enterprise/types.d.ts.map +1 -1
  23. package/dist/pipeline/gate/feature-flags.d.ts +30 -0
  24. package/dist/pipeline/gate/feature-flags.d.ts.map +1 -0
  25. package/dist/pipeline/gate/feature-flags.js +37 -0
  26. package/dist/pipeline/gate/feature-flags.js.map +1 -0
  27. package/dist/pipeline/gate/phase-dependency-gate.d.ts +179 -0
  28. package/dist/pipeline/gate/phase-dependency-gate.d.ts.map +1 -0
  29. package/dist/pipeline/gate/phase-dependency-gate.js +571 -0
  30. package/dist/pipeline/gate/phase-dependency-gate.js.map +1 -0
  31. package/dist/pipeline/local-fallback/phase1-consensus-reader.d.ts +33 -0
  32. package/dist/pipeline/local-fallback/phase1-consensus-reader.d.ts.map +1 -0
  33. package/dist/pipeline/local-fallback/phase1-consensus-reader.js +99 -0
  34. package/dist/pipeline/local-fallback/phase1-consensus-reader.js.map +1 -0
  35. package/dist/pipeline/local-fallback/phase3-local-fallback.d.ts +26 -0
  36. package/dist/pipeline/local-fallback/phase3-local-fallback.d.ts.map +1 -0
  37. package/dist/pipeline/local-fallback/phase3-local-fallback.js +127 -0
  38. package/dist/pipeline/local-fallback/phase3-local-fallback.js.map +1 -0
  39. package/dist/pipeline/local-fallback/phase4-local-fallback.d.ts +21 -0
  40. package/dist/pipeline/local-fallback/phase4-local-fallback.d.ts.map +1 -0
  41. package/dist/pipeline/local-fallback/phase4-local-fallback.js +240 -0
  42. package/dist/pipeline/local-fallback/phase4-local-fallback.js.map +1 -0
  43. package/dist/pipeline/local-fallback/phase5a-local-fallback.d.ts +28 -0
  44. package/dist/pipeline/local-fallback/phase5a-local-fallback.d.ts.map +1 -0
  45. package/dist/pipeline/local-fallback/phase5a-local-fallback.js +166 -0
  46. package/dist/pipeline/local-fallback/phase5a-local-fallback.js.map +1 -0
  47. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.d.ts.map +1 -1
  48. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js +280 -40
  49. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js.map +1 -1
  50. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.d.ts.map +1 -1
  51. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js +363 -87
  52. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js.map +1 -1
  53. package/dist/pipeline/phases/prompt-generator.d.ts.map +1 -1
  54. package/dist/pipeline/phases/prompt-generator.js +303 -6
  55. package/dist/pipeline/phases/prompt-generator.js.map +1 -1
  56. package/dist/pipeline/ruflo-phase-executor.d.ts +104 -1
  57. package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
  58. package/dist/pipeline/ruflo-phase-executor.js +406 -4
  59. package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
  60. package/dist/pipeline/swarm-orchestrator.d.ts +47 -0
  61. package/dist/pipeline/swarm-orchestrator.d.ts.map +1 -1
  62. package/dist/pipeline/swarm-orchestrator.js +130 -3
  63. package/dist/pipeline/swarm-orchestrator.js.map +1 -1
  64. package/package.json +1 -1
@@ -0,0 +1,571 @@
1
+ /**
2
+ * ADR-PIPELINE-093 — Phase Dependency Gate.
3
+ *
4
+ * Shared helper that verifies a phase's required inputs exist, are non-stub,
5
+ * and meet a minimum size before the phase coordinator runs. On a miss the
6
+ * gate invokes the ADR-091 primary executor (`runPrimaryPhaseExecution`)
7
+ * once per missing upstream phase (capped by `maxRetriesPerInput`, default 1)
8
+ * and re-checks.
9
+ *
10
+ * The gate is side-effect-minimal: it only reads `runDir`, logs to stderr
11
+ * with the `[GATE]` prefix, and forwards Ruflo invocations to the injected
12
+ * executor. Mapping of required-input → owning upstream phase is static
13
+ * (`INPUT_OWNER_MAP`) and colocated with the dependency table
14
+ * (`PHASE_DEPENDENCIES`).
15
+ */
16
+ import * as fs from 'node:fs';
17
+ import * as path from 'node:path';
18
+ import { runPrimaryPhaseExecution as runPrimaryPhaseExecutionImpl, } from '../ruflo-phase-executor.js';
19
+ /**
20
+ * ADR-PIPELINE-094 Decision 5 — maps gate `PhaseId` to the per-phase output
21
+ * directory under `runDir`. Used to write `gate-decision-log.json` to the
22
+ * canonical location the auto-chain coordinator writes its other artifacts
23
+ * to. Phase 5a/5b compose into the parent `phase5/` tree but get their own
24
+ * subdir so the log file does not collide.
25
+ */
26
+ export const PHASE_DIRNAME = {
27
+ phase2: 'phase2',
28
+ 'phase3-sparc': 'phase3',
29
+ 'phase4-adrs-ddd': 'phase4',
30
+ 'phase5a-prompts': 'phase5a',
31
+ 'phase5b-scaffold': 'phase5b',
32
+ };
33
+ // ============================================================================
34
+ // Static dependency table (ADR-PIPELINE-093 Decision Rule 1)
35
+ // ============================================================================
36
+ const MIN_BYTES_DEFAULT = 100;
37
+ /** Per-phase required/optional inputs, hard-coded from the ADR DAG table. */
38
+ export const PHASE_DEPENDENCIES = {
39
+ phase2: {
40
+ phaseId: 'phase2',
41
+ required: [
42
+ { kind: 'file', paths: ['phase1/manifest.json'] },
43
+ { kind: 'file', paths: ['phase1/executive-summary.md'] },
44
+ ],
45
+ optional: [
46
+ 'phase1/scenario.json',
47
+ 'phase1/decision-memo.md',
48
+ 'phase1/risk-assessment.json',
49
+ ],
50
+ },
51
+ 'phase3-sparc': {
52
+ phaseId: 'phase3-sparc',
53
+ required: [
54
+ { kind: 'file', paths: ['phase1/manifest.json'] },
55
+ { kind: 'file', paths: ['phase2/research-dossier.json'] },
56
+ ],
57
+ optional: [
58
+ 'phase1/roadmap.json',
59
+ 'phase2/hypotheses.json',
60
+ 'diligence-artifacts/sparc-*',
61
+ ],
62
+ },
63
+ 'phase4-adrs-ddd': {
64
+ phaseId: 'phase4-adrs-ddd',
65
+ required: [
66
+ { kind: 'file', paths: ['phase1/manifest.json'] },
67
+ {
68
+ kind: 'any-of',
69
+ paths: [
70
+ 'phase3/sparc/specification.md',
71
+ 'engineering/sparc-specification.md',
72
+ ],
73
+ },
74
+ ],
75
+ optional: [
76
+ 'phase2/research-dossier.json',
77
+ 'diligence-artifacts/adr-generation',
78
+ ],
79
+ },
80
+ 'phase5a-prompts': {
81
+ phaseId: 'phase5a-prompts',
82
+ required: [
83
+ {
84
+ kind: 'any-of',
85
+ paths: [
86
+ 'phase3/sparc/specification.md',
87
+ 'engineering/sparc-specification.md',
88
+ // ADR-PIPELINE-094 Decision 2 — Phase-1 fallback: when no SPARC chain
89
+ // exists, the prompt generator runs off Phase-1 simulator consensus.
90
+ 'phase1/decision-memo.md',
91
+ ],
92
+ },
93
+ {
94
+ kind: 'any-of',
95
+ paths: [
96
+ 'phase4/adrs/*.md',
97
+ 'phase4/ddd/bounded-contexts.json',
98
+ 'engineering/architecture-decisions.md',
99
+ // ADR-PIPELINE-094 Decision 2 — Phase-1 fallback: scenario.json and
100
+ // decision-memo.md from Phase 1 are the always-present consensus
101
+ // outputs we can always degrade to.
102
+ 'phase1/decision-memo.md',
103
+ 'phase1/scenario.json',
104
+ ],
105
+ },
106
+ ],
107
+ optional: [],
108
+ },
109
+ 'phase5b-scaffold': {
110
+ phaseId: 'phase5b-scaffold',
111
+ required: [
112
+ { kind: 'file', paths: ['phase1/manifest.json'] },
113
+ // ADR-PIPELINE-094 Decision 3 — Phase 5b hard-blocks on the Phase 5a
114
+ // execution plan. Without a concrete unit-of-work the build phase has
115
+ // nothing to do and previously fanned out ~76 cloud agents that all
116
+ // timed out. minBytes:50 keeps the threshold below MIN_BYTES_DEFAULT
117
+ // because a minimal valid execution-plan.json with one entry is small.
118
+ { kind: 'file', paths: ['phase5a/execution-plan.json'], minBytes: 50 },
119
+ ],
120
+ optional: ['phase4/adrs/*.md'],
121
+ },
122
+ };
123
+ // ============================================================================
124
+ // Input → owning-upstream-phase map (ADR-PIPELINE-093)
125
+ // ============================================================================
126
+ /**
127
+ * Maps a required-input path (relative to runDir) onto the upstream phase
128
+ * that produces it. Used by the gate to decide which phase's Ruflo primary
129
+ * executor to invoke when an input is missing. Keyed by path prefix; the
130
+ * longest matching prefix wins.
131
+ */
132
+ export const INPUT_OWNER_MAP = {
133
+ 'phase1/': 'phase2', // phase1 is the entry; phase2 is the earliest "producable" upstream we can invoke
134
+ 'phase2/': 'phase2',
135
+ 'phase3/sparc/': 'phase3-sparc',
136
+ 'engineering/sparc-specification.md': 'phase3-sparc',
137
+ 'phase4/adrs/': 'phase4-adrs-ddd',
138
+ 'phase4/ddd/': 'phase4-adrs-ddd',
139
+ 'phase4/': 'phase4-adrs-ddd',
140
+ 'engineering/architecture-decisions.md': 'phase4-adrs-ddd',
141
+ 'engineering/domain-model.md': 'phase4-adrs-ddd',
142
+ 'phase4/prompts/': 'phase5a-prompts',
143
+ 'phase5a/': 'phase5a-prompts',
144
+ };
145
+ /**
146
+ * Upstream phases supported by `runPrimaryPhaseExecution`. Phase 1 is the
147
+ * pipeline entry and is never re-invoked by the gate — a missing phase1 file
148
+ * is surfaced as a hard block. Phase 2 maps to the phase2 coordinator, which
149
+ * is wired separately by auto-chain; the gate passes the string through.
150
+ */
151
+ const INVOKABLE_UPSTREAM = new Set([
152
+ 'phase2',
153
+ 'phase3-sparc',
154
+ 'phase4-adrs-ddd',
155
+ 'phase5a-prompts',
156
+ ]);
157
+ // ============================================================================
158
+ // Public helpers
159
+ // ============================================================================
160
+ /**
161
+ * Returns `false` iff the content is a JSON error-stub sentinel — a JSON
162
+ * object whose only top-level keys are `error` and/or `message`. Non-JSON
163
+ * content always returns `true`. Empty strings also return `true`
164
+ * (size-gating is the caller's job; the stub check is purely about shape).
165
+ */
166
+ export function isNotErrorStub(content) {
167
+ const trimmed = content.trim();
168
+ if (trimmed.length === 0)
169
+ return true;
170
+ if (!trimmed.startsWith('{'))
171
+ return true;
172
+ let parsed;
173
+ try {
174
+ parsed = JSON.parse(trimmed);
175
+ }
176
+ catch {
177
+ return true;
178
+ }
179
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
180
+ return true;
181
+ }
182
+ const keys = Object.keys(parsed);
183
+ if (keys.length === 0)
184
+ return true;
185
+ const onlyErrorOrMessage = keys.every((k) => k === 'error' || k === 'message');
186
+ return !onlyErrorOrMessage;
187
+ }
188
+ /**
189
+ * Inspects per-phase gate results and returns a BlockedPhase entry for
190
+ * every phase whose gate failed and still has missing inputs after retry.
191
+ * Used by auto-chain to populate `status.json.blocked_phases`.
192
+ */
193
+ export function determineBlockedPhases(results) {
194
+ const blocked = [];
195
+ for (const r of results) {
196
+ if (!r.gateResult.ok && r.gateResult.stillMissing.length > 0) {
197
+ blocked.push({ phase: r.phaseId, missing: r.gateResult.stillMissing });
198
+ }
199
+ }
200
+ return blocked;
201
+ }
202
+ // ============================================================================
203
+ // Core gate algorithm
204
+ // ============================================================================
205
+ /**
206
+ * Verifies `phaseId`'s declared required inputs on disk. On a miss, invokes
207
+ * the ADR-091 primary executor for each owning upstream phase (capped at
208
+ * `maxRetriesPerInput`) and re-checks. Returns a `GateResult` describing the
209
+ * outcome. Never throws.
210
+ */
211
+ export async function gatePhaseInputs(phaseId, opts) {
212
+ const tStart = Date.now();
213
+ const dep = PHASE_DEPENDENCIES[phaseId];
214
+ const maxRetries = opts.maxRetriesPerInput ?? 1;
215
+ const runPrimary = opts.runPrimaryPhaseExecution ?? runPrimaryPhaseExecutionImpl;
216
+ const traceId = opts.dossier.traceId ?? 'unknown';
217
+ // ADR-094 Decision 5 — accumulate the rich invocation log for
218
+ // gate-decision-log.json. Ruflo invocations get one entry per attempt with
219
+ // tier and reason, even when the attempt succeeded.
220
+ const rufloLog = [];
221
+ const finalize = (verdict, initialChecks, finalChecks, stillMissing) => {
222
+ // Prefer the second pass when Ruflo was invoked — it reflects the gate's
223
+ // final decision. Otherwise the first pass is the only check we did.
224
+ const checked = finalChecks.length > 0 ? finalChecks : initialChecks;
225
+ writeGateDecisionLog(opts.runDir, {
226
+ phaseId,
227
+ trace_id: traceId,
228
+ timestamp: new Date().toISOString(),
229
+ checked_inputs: checked,
230
+ ruflo_invoked: rufloLog,
231
+ verdict,
232
+ still_missing: stillMissing,
233
+ decision_ms: Date.now() - tStart,
234
+ });
235
+ };
236
+ // First pass — collect failures and per-input details.
237
+ const firstPass = collectMissingPathsWithDetail(opts.runDir, dep.required);
238
+ if (firstPass.missing.length === 0) {
239
+ finalize('ok', firstPass.checked, [], []);
240
+ return { ok: true, missing: [], ruflo_invoked: [], stillMissing: [] };
241
+ }
242
+ // Determine which upstream phases own the failed inputs.
243
+ const upstreamPhases = new Set();
244
+ for (const failedPath of firstPass.missing) {
245
+ const owner = resolveOwner(failedPath);
246
+ if (owner !== null && INVOKABLE_UPSTREAM.has(owner) && owner !== phaseId) {
247
+ upstreamPhases.add(owner);
248
+ }
249
+ }
250
+ const invoked = [];
251
+ const invocationCounts = new Map();
252
+ // Invoke the primary executor for each upstream phase (capped).
253
+ for (const upstream of upstreamPhases) {
254
+ const count = invocationCounts.get(upstream) ?? 0;
255
+ if (count >= maxRetries)
256
+ continue;
257
+ invocationCounts.set(upstream, count + 1);
258
+ invoked.push(upstream);
259
+ const missingForOwner = firstPass.missing.filter((p) => resolveOwner(p) === upstream);
260
+ for (const p of missingForOwner) {
261
+ process.stderr.write(`[GATE] ${phaseId}: missing ${p} — invoking Ruflo (${upstream})\n`);
262
+ }
263
+ try {
264
+ const result = await runPrimary(upstream, opts.dossier, opts.context);
265
+ rufloLog.push({
266
+ phase: upstream,
267
+ tier: String(result.executionTier ?? 'unknown'),
268
+ reason: String(result.reason ?? (result.success ? 'ok' : 'unknown')),
269
+ });
270
+ if (result.executionTier === 'unavailable') {
271
+ process.stderr.write(`[GATE] ${phaseId}: Ruflo unavailable (${upstream}) — reason=${result.reason ?? 'unknown'}\n`);
272
+ }
273
+ }
274
+ catch (err) {
275
+ const msg = err.message;
276
+ rufloLog.push({ phase: upstream, tier: 'error', reason: msg });
277
+ process.stderr.write(`[GATE] ${phaseId}: Ruflo threw for ${upstream} — ${msg}\n`);
278
+ }
279
+ }
280
+ // Re-check after all Ruflo invocations have (had a chance to) run.
281
+ const secondPass = collectMissingPathsWithDetail(opts.runDir, dep.required);
282
+ if (secondPass.missing.length === 0) {
283
+ process.stderr.write(`[GATE] ${phaseId}: recovered via Ruflo\n`);
284
+ finalize('ok', firstPass.checked, secondPass.checked, []);
285
+ return {
286
+ ok: true,
287
+ missing: firstPass.missing,
288
+ ruflo_invoked: invoked,
289
+ stillMissing: [],
290
+ };
291
+ }
292
+ process.stderr.write(`[GATE] ${phaseId}: still blocked — ${secondPass.missing.join(', ')}\n`);
293
+ finalize('blocked', firstPass.checked, secondPass.checked, secondPass.missing);
294
+ return {
295
+ ok: false,
296
+ missing: firstPass.missing,
297
+ ruflo_invoked: invoked,
298
+ stillMissing: secondPass.missing,
299
+ };
300
+ }
301
+ // ============================================================================
302
+ // Path-reality resolution (ADR-PIPELINE-094 Decision 1)
303
+ // ============================================================================
304
+ /**
305
+ * Resolves a logical phase path (as declared in `PHASE_DEPENDENCIES`) to one
306
+ * or more absolute candidate paths under `runDir`, in priority order.
307
+ *
308
+ * Phase 1 writes its outputs flat to `<runDir>/<file>` (see
309
+ * `swarm-orchestrator.ts:1831,2222,2229,2249,2252`), but the gate's
310
+ * dependency table refers to them with a `phase1/` prefix for dependency-DAG
311
+ * clarity. Pre-094 the gate joined the relative path to `runDir` literally
312
+ * and looked at `<runDir>/phase1/<file>`, which never exists in production —
313
+ * the false-negative cascade documented in the originating run.
314
+ *
315
+ * Resolution rules:
316
+ * - `phase1/X` → first try `<runDir>/X` (production, flat layout); if the
317
+ * caller's existence check fails there, fall through to
318
+ * `<runDir>/phase1/X` (test fixtures and any future subdir layout).
319
+ * - All other prefixes resolve unchanged: `<runDir>/<relPath>`.
320
+ *
321
+ * Returns at least one candidate. Callers iterate in order and accept the
322
+ * first candidate that satisfies their predicate.
323
+ *
324
+ * Exported for unit tests and for any future code that needs to resolve a
325
+ * declared dependency path to its physical location. This is the SINGLE place
326
+ * the logical→physical mapping lives.
327
+ */
328
+ export function resolvePhasePath(runDir, relPath) {
329
+ const phase1Match = /^phase1\/(.+)$/.exec(relPath);
330
+ if (phase1Match) {
331
+ const tail = phase1Match[1];
332
+ return [
333
+ path.join(runDir, tail), // flat layout (production default)
334
+ path.join(runDir, 'phase1', tail), // subdir layout (legacy / fixtures)
335
+ ];
336
+ }
337
+ return [path.join(runDir, relPath)];
338
+ }
339
+ // ============================================================================
340
+ // Internal helpers
341
+ // ============================================================================
342
+ /** First 512 bytes is enough to spot JSON error-stub shape. */
343
+ const STUB_SCAN_BYTES = 512;
344
+ /**
345
+ * Returns both the list of missing logical paths AND a per-input check log
346
+ * suitable for `gate-decision-log.json` (ADR-094 Decision 5). Callers that
347
+ * only need the verdict use `result.missing`; callers that emit the
348
+ * decision log consume `result.checked`.
349
+ */
350
+ function collectMissingPathsWithDetail(runDir, required) {
351
+ const missing = [];
352
+ const checked = [];
353
+ for (const req of required) {
354
+ const minBytes = req.minBytes ?? MIN_BYTES_DEFAULT;
355
+ if (req.kind === 'file') {
356
+ // ALL paths must satisfy the criteria.
357
+ for (const p of req.paths) {
358
+ const detail = inspectPath(runDir, p, minBytes);
359
+ checked.push(detail);
360
+ if (!detail.satisfies)
361
+ missing.push(p);
362
+ }
363
+ }
364
+ else {
365
+ // any-of: at least ONE path must satisfy.
366
+ const details = req.paths.map((p) => inspectPath(runDir, p, minBytes));
367
+ checked.push(...details);
368
+ const anyOk = details.some((d) => d.satisfies);
369
+ if (!anyOk) {
370
+ // Report the full any-of set so the caller can map each candidate
371
+ // back to its owning upstream phase via `INPUT_OWNER_MAP`.
372
+ for (const p of req.paths)
373
+ missing.push(p);
374
+ }
375
+ }
376
+ }
377
+ return { missing, checked };
378
+ }
379
+ /**
380
+ * ADR-PIPELINE-094 Decision 5 — populated single-path inspection for the log.
381
+ * Returns the FIRST satisfying candidate's metadata; if none satisfy, returns
382
+ * the metadata of the first candidate (the production-default path) so the
383
+ * log surfaces the resolved path the user expects to see in their layout.
384
+ */
385
+ function inspectPath(runDir, relPath, minBytes) {
386
+ if (relPath.endsWith('/*.md') || relPath.endsWith('/*')) {
387
+ // Glob form: detail collapses to "did the glob match anything".
388
+ return {
389
+ logical_path: relPath,
390
+ resolved_path: path.join(runDir, relPath),
391
+ exists: false, // not strictly meaningful for globs; we only report satisfies
392
+ size_bytes: 0,
393
+ is_error_stub: false,
394
+ satisfies: dirGlobSatisfies(runDir, relPath, minBytes),
395
+ };
396
+ }
397
+ const candidates = resolvePhasePath(runDir, relPath);
398
+ // Prefer the first candidate that satisfies; otherwise return detail for
399
+ // the first candidate (the production-default location).
400
+ let firstFound = null;
401
+ for (const abs of candidates) {
402
+ const detail = inspectFile(abs, minBytes, relPath);
403
+ if (detail.satisfies)
404
+ return detail;
405
+ if (firstFound === null)
406
+ firstFound = detail;
407
+ }
408
+ return firstFound;
409
+ }
410
+ function inspectFile(abs, minBytes, logicalPath) {
411
+ let stat = null;
412
+ try {
413
+ stat = fs.statSync(abs);
414
+ }
415
+ catch {
416
+ return {
417
+ logical_path: logicalPath,
418
+ resolved_path: abs,
419
+ exists: false,
420
+ size_bytes: 0,
421
+ is_error_stub: false,
422
+ satisfies: false,
423
+ };
424
+ }
425
+ if (!stat.isFile()) {
426
+ return {
427
+ logical_path: logicalPath,
428
+ resolved_path: abs,
429
+ exists: true,
430
+ size_bytes: stat.size,
431
+ is_error_stub: false,
432
+ satisfies: false,
433
+ };
434
+ }
435
+ if (stat.size < minBytes) {
436
+ return {
437
+ logical_path: logicalPath,
438
+ resolved_path: abs,
439
+ exists: true,
440
+ size_bytes: stat.size,
441
+ is_error_stub: false,
442
+ satisfies: false,
443
+ };
444
+ }
445
+ let contentSlice = '';
446
+ try {
447
+ const fd = fs.openSync(abs, 'r');
448
+ try {
449
+ const buf = Buffer.alloc(Math.min(STUB_SCAN_BYTES, stat.size));
450
+ fs.readSync(fd, buf, 0, buf.length, 0);
451
+ contentSlice = buf.toString('utf8');
452
+ }
453
+ finally {
454
+ fs.closeSync(fd);
455
+ }
456
+ }
457
+ catch {
458
+ return {
459
+ logical_path: logicalPath,
460
+ resolved_path: abs,
461
+ exists: true,
462
+ size_bytes: stat.size,
463
+ is_error_stub: false,
464
+ satisfies: false,
465
+ };
466
+ }
467
+ const stub = !isNotErrorStub(contentSlice);
468
+ return {
469
+ logical_path: logicalPath,
470
+ resolved_path: abs,
471
+ exists: true,
472
+ size_bytes: stat.size,
473
+ is_error_stub: stub,
474
+ satisfies: !stub,
475
+ };
476
+ }
477
+ function fileSatisfies(abs, minBytes) {
478
+ let stat;
479
+ try {
480
+ stat = fs.statSync(abs);
481
+ }
482
+ catch {
483
+ return false;
484
+ }
485
+ if (!stat.isFile())
486
+ return false;
487
+ if (stat.size < minBytes)
488
+ return false;
489
+ // Read up to the stub-scan window for the error-stub shape check.
490
+ let contentSlice = '';
491
+ try {
492
+ const fd = fs.openSync(abs, 'r');
493
+ try {
494
+ const buf = Buffer.alloc(Math.min(STUB_SCAN_BYTES, stat.size));
495
+ fs.readSync(fd, buf, 0, buf.length, 0);
496
+ contentSlice = buf.toString('utf8');
497
+ }
498
+ finally {
499
+ fs.closeSync(fd);
500
+ }
501
+ }
502
+ catch {
503
+ return false;
504
+ }
505
+ return isNotErrorStub(contentSlice);
506
+ }
507
+ function dirGlobSatisfies(runDir, relPath, minBytes) {
508
+ // Support `<dir>/*.ext` and `<dir>/*`. Anything more exotic is rejected.
509
+ const dirRel = relPath.replace(/\/\*(\.[a-zA-Z0-9]+)?$/, '');
510
+ const extMatch = relPath.match(/\/\*(\.[a-zA-Z0-9]+)$/);
511
+ const ext = extMatch?.[1];
512
+ // ADR-094 Decision 1: route directory resolution through resolvePhasePath
513
+ // so any phase-prefix layout aliasing applies to globs too. For phase1/*
514
+ // patterns the candidates are `<runDir>/<tail>` and `<runDir>/phase1/<tail>`;
515
+ // for other prefixes there's only one candidate.
516
+ for (const dirAbs of resolvePhasePath(runDir, dirRel)) {
517
+ let entries;
518
+ try {
519
+ entries = fs.readdirSync(dirAbs);
520
+ }
521
+ catch {
522
+ continue;
523
+ }
524
+ const candidates = ext ? entries.filter((e) => e.endsWith(ext)) : entries;
525
+ if (candidates.some((e) => fileSatisfies(path.join(dirAbs, e), minBytes))) {
526
+ return true;
527
+ }
528
+ }
529
+ return false;
530
+ }
531
+ // ============================================================================
532
+ // Gate decision log writer (ADR-PIPELINE-094 Decision 5)
533
+ // ============================================================================
534
+ /**
535
+ * Writes `<runDir>/<phaseDirname>/gate-decision-log.json` for the given
536
+ * decision. Best-effort: never throws; on filesystem error, logs to stderr
537
+ * and returns. The text `[GATE]` log lines continue alongside this for
538
+ * human readability — the JSON is the machine-readable surface.
539
+ *
540
+ * Exported for unit tests. Production callers go through `gatePhaseInputs`
541
+ * which invokes this internally after computing its verdict.
542
+ */
543
+ export function writeGateDecisionLog(runDir, log) {
544
+ try {
545
+ const dirname = PHASE_DIRNAME[log.phaseId];
546
+ const phaseDir = path.join(runDir, dirname);
547
+ fs.mkdirSync(phaseDir, { recursive: true });
548
+ const target = path.join(phaseDir, 'gate-decision-log.json');
549
+ // Pretty-print for human grep-ability in log dumps; the file is small.
550
+ fs.writeFileSync(target, JSON.stringify(log, null, 2) + '\n', 'utf8');
551
+ }
552
+ catch (err) {
553
+ process.stderr.write(`[GATE] ${log.phaseId}: failed to write gate-decision-log.json — ${err.message}\n`);
554
+ }
555
+ }
556
+ /** Returns the owning PhaseId for the given relative path, or null. */
557
+ function resolveOwner(relPath) {
558
+ // Longest matching prefix wins.
559
+ let bestKey = '';
560
+ let bestOwner = null;
561
+ for (const [key, owner] of Object.entries(INPUT_OWNER_MAP)) {
562
+ if (relPath === key || relPath.startsWith(key)) {
563
+ if (key.length > bestKey.length) {
564
+ bestKey = key;
565
+ bestOwner = owner;
566
+ }
567
+ }
568
+ }
569
+ return bestOwner;
570
+ }
571
+ //# sourceMappingURL=phase-dependency-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase-dependency-gate.js","sourceRoot":"","sources":["../../../src/pipeline/gate/phase-dependency-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,wBAAwB,IAAI,4BAA4B,GAKzD,MAAM,4BAA4B,CAAC;AA2GpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsC;IAC9D,MAAM,EAAE,QAAQ;IAChB,cAAc,EAAE,QAAQ;IACxB,iBAAiB,EAAE,QAAQ;IAC3B,iBAAiB,EAAE,SAAS;IAC5B,kBAAkB,EAAE,SAA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SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * ADR-PIPELINE-094 Decision 8 — Phase-1 consensus reader for local fallback
3
+ * generators. Reads Phase-1 simulator outputs (which Phase 1 writes flat to
4
+ * `<runDir>/`) and exposes them as a typed, normalized shape.
5
+ *
6
+ * Consumed by the phase3/4/5a local fallback generators. Resilient to
7
+ * partial Phase-1 output: any file may be missing; missing fields are left
8
+ * undefined and the caller decides what to synthesize from what's present.
9
+ *
10
+ * Honours both layouts:
11
+ * - flat (production): <runDir>/manifest.json
12
+ * - subdir (test fixture): <runDir>/phase1/manifest.json
13
+ */
14
+ /** Normalized snapshot of Phase-1 simulator consensus. All fields are optional. */
15
+ export interface Phase1Consensus {
16
+ readonly runDir: string;
17
+ readonly manifest?: Record<string, unknown>;
18
+ readonly executiveSummary?: string;
19
+ readonly decisionMemo?: string;
20
+ readonly riskAssessment?: Record<string, unknown>;
21
+ readonly scenario?: Record<string, unknown>;
22
+ readonly architectureDecisions?: string;
23
+ readonly projectLanguage?: string;
24
+ }
25
+ /**
26
+ * Read Phase-1 outputs from `runDir`. Tries flat layout first (production),
27
+ * then subdir (legacy/test). Returns `undefined` only when nothing
28
+ * Phase-1-shaped exists; otherwise populates whichever fields were found.
29
+ */
30
+ export declare function readPhase1Consensus(runDir: string): Phase1Consensus | undefined;
31
+ /** Extract the user-facing scenario query from a Phase-1 consensus. */
32
+ export declare function extractScenarioQuery(c: Phase1Consensus): string;
33
+ //# sourceMappingURL=phase1-consensus-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase1-consensus-reader.d.ts","sourceRoot":"","sources":["../../../src/pipeline/local-fallback/phase1-consensus-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAkE/E;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAW/D"}