@llm-dev-ops/agentics-cli 2.7.41 → 2.8.0

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 (195) hide show
  1. package/agents/analytics-hub/consensus/consensus.md +47 -0
  2. package/agents/analytics-hub/recommendation/recommendation.md +47 -0
  3. package/agents/auto-optimizer/model-select/model-select.md +49 -0
  4. package/agents/auto-optimizer/self-optimize/self-optimize.md +44 -0
  5. package/agents/auto-optimizer/token/token.md +50 -0
  6. package/agents/benchmark-exchange/publish/publish.md +29 -0
  7. package/agents/config-manager/validate/validate.md +40 -0
  8. package/agents/connector-hub/auth-identity/auth-identity.md +29 -0
  9. package/agents/connector-hub/database-query/database-query.md +29 -0
  10. package/agents/connector-hub/erp-surface/erp-surface.md +29 -0
  11. package/agents/connector-hub/event-normalize/event-normalize.md +29 -0
  12. package/agents/connector-hub/webhook-ingest/webhook-ingest.md +29 -0
  13. package/agents/copilot/clarifier/clarifier.md +47 -0
  14. package/agents/copilot/config/config.md +37 -0
  15. package/agents/copilot/decomposer/decomposer.md +46 -0
  16. package/agents/copilot/intent/intent.md +43 -0
  17. package/agents/copilot/meta-reasoner/meta-reasoner.md +43 -0
  18. package/agents/copilot/planner/planner.md +47 -0
  19. package/agents/copilot/reflection/reflection.md +40 -0
  20. package/agents/costops/attribution/attribution.md +39 -0
  21. package/agents/costops/budget/budget.md +40 -0
  22. package/agents/costops/forecast/forecast.md +40 -0
  23. package/agents/costops/roi/roi.md +37 -0
  24. package/agents/costops/tradeoff/tradeoff.md +39 -0
  25. package/agents/data-vault/access-control/access-control.md +46 -0
  26. package/agents/data-vault/anonymize/anonymize.md +54 -0
  27. package/agents/edge/caching/caching.md +46 -0
  28. package/agents/edge/circuit-breaker/circuit-breaker.md +44 -0
  29. package/agents/edge/execution-guard/execution-guard.md +41 -0
  30. package/agents/edge/failover/failover.md +45 -0
  31. package/agents/edge/tool-invoke/tool-invoke.md +44 -0
  32. package/agents/forge/api-translation/api-translation.md +29 -0
  33. package/agents/forge/cli/cli.md +29 -0
  34. package/agents/forge/sdk/sdk.md +29 -0
  35. package/agents/forge/version-compat/version-compat.md +29 -0
  36. package/agents/governance-dashboard/audit/audit.md +39 -0
  37. package/agents/governance-dashboard/impact/impact.md +37 -0
  38. package/agents/governance-dashboard/oversight/oversight.md +41 -0
  39. package/agents/incident-manager/escalation/escalation.md +45 -0
  40. package/agents/incident-manager/hitl/hitl.md +46 -0
  41. package/agents/incident-manager/post-mortem/post-mortem.md +52 -0
  42. package/agents/inference-gateway/route/route.md +29 -0
  43. package/agents/latency-lens/cold-start/cold-start.md +29 -0
  44. package/agents/latency-lens/latency/latency.md +29 -0
  45. package/agents/marketplace/deprecation/deprecation.md +29 -0
  46. package/agents/marketplace/package/package.md +29 -0
  47. package/agents/memory-graph/conversation/conversation.md +37 -0
  48. package/agents/memory-graph/decisions/decisions.md +45 -0
  49. package/agents/memory-graph/knowledge-graph/knowledge-graph.md +46 -0
  50. package/agents/memory-graph/lineage/lineage.md +37 -0
  51. package/agents/memory-graph/patterns/patterns.md +45 -0
  52. package/agents/memory-graph/retrieval/retrieval.md +43 -0
  53. package/agents/observatory/failures/failures.md +29 -0
  54. package/agents/observatory/health-check/health-check.md +29 -0
  55. package/agents/observatory/post-mortem/post-mortem.md +29 -0
  56. package/agents/observatory/slo/slo.md +29 -0
  57. package/agents/observatory/telemetry/telemetry.md +29 -0
  58. package/agents/observatory/usage-patterns/usage-patterns.md +29 -0
  59. package/agents/observatory/visualization/visualization.md +29 -0
  60. package/agents/orchestrator/dependencies/dependencies.md +40 -0
  61. package/agents/orchestrator/parallel/parallel.md +43 -0
  62. package/agents/orchestrator/retry/retry.md +45 -0
  63. package/agents/orchestrator/scheduler/scheduler.md +44 -0
  64. package/agents/orchestrator/state-machine/state-machine.md +53 -0
  65. package/agents/orchestrator/swarm/swarm.md +44 -0
  66. package/agents/orchestrator/workflow/workflow.md +48 -0
  67. package/agents/platform/decision/decision.md +40 -0
  68. package/agents/platform/decision-memo/decision-memo.md +69 -0
  69. package/agents/platform/executive-summary/executive-summary.md +44 -0
  70. package/agents/platform/risk-score/risk-score.md +50 -0
  71. package/agents/policy-engine/approval/approval.md +40 -0
  72. package/agents/policy-engine/constraints/constraints.md +38 -0
  73. package/agents/policy-engine/enforce/enforce.md +39 -0
  74. package/agents/registry/bootstrap/bootstrap.md +29 -0
  75. package/agents/registry/index/index.md +29 -0
  76. package/agents/registry/reputation/reputation.md +29 -0
  77. package/agents/research-lab/hypothesis/hypothesis.md +50 -0
  78. package/agents/research-lab/metrics/metrics.md +50 -0
  79. package/agents/schema-registry/validate/validate.md +37 -0
  80. package/agents/sentinel/alert/alert.md +29 -0
  81. package/agents/sentinel/anomaly/anomaly.md +29 -0
  82. package/agents/sentinel/correlation/correlation.md +29 -0
  83. package/agents/sentinel/drift/drift.md +29 -0
  84. package/agents/sentinel/rca/rca.md +29 -0
  85. package/agents/shield/abuse/abuse.md +29 -0
  86. package/agents/shield/credential-exposure/credential-exposure.md +29 -0
  87. package/agents/shield/moderation/moderation.md +29 -0
  88. package/agents/shield/pii/pii.md +29 -0
  89. package/agents/shield/prompt-injection/prompt-injection.md +29 -0
  90. package/agents/shield/redaction/redaction.md +29 -0
  91. package/agents/shield/safety-boundary/safety-boundary.md +29 -0
  92. package/agents/shield/secrets/secrets.md +29 -0
  93. package/agents/shield/toxicity/toxicity.md +29 -0
  94. package/agents/simulator/scenario/scenario.md +53 -0
  95. package/agents/simulator/what-if/what-if.md +52 -0
  96. package/agents/test-bench/adversarial/adversarial.md +33 -0
  97. package/agents/test-bench/benchmark/benchmark.md +34 -0
  98. package/agents/test-bench/bias/bias.md +33 -0
  99. package/agents/test-bench/compare/compare.md +33 -0
  100. package/agents/test-bench/consistency/consistency.md +33 -0
  101. package/agents/test-bench/faithfulness/faithfulness.md +34 -0
  102. package/agents/test-bench/golden-dataset/golden-dataset.md +33 -0
  103. package/agents/test-bench/hallucination/hallucination.md +34 -0
  104. package/agents/test-bench/prompt-sensitivity/prompt-sensitivity.md +33 -0
  105. package/agents/test-bench/quality/quality.md +33 -0
  106. package/agents/test-bench/red-team/red-team.md +33 -0
  107. package/agents/test-bench/regression/regression.md +33 -0
  108. package/agents/test-bench/stress/stress.md +34 -0
  109. package/agents/test-bench/synthetic-data/synthetic-data.md +35 -0
  110. package/dist/agents/agent-prompts.d.ts +77 -0
  111. package/dist/agents/agent-prompts.d.ts.map +1 -0
  112. package/dist/agents/agent-prompts.js +230 -0
  113. package/dist/agents/agent-prompts.js.map +1 -0
  114. package/dist/agents/repo-agent-runner.d.ts +1 -0
  115. package/dist/agents/repo-agent-runner.d.ts.map +1 -1
  116. package/dist/agents/repo-agent-runner.js +67 -35
  117. package/dist/agents/repo-agent-runner.js.map +1 -1
  118. package/dist/cli/index.js +22 -0
  119. package/dist/cli/index.js.map +1 -1
  120. package/dist/commands/agents.d.ts +19 -0
  121. package/dist/commands/agents.d.ts.map +1 -1
  122. package/dist/commands/agents.js +344 -144
  123. package/dist/commands/agents.js.map +1 -1
  124. package/dist/pipeline/auto-chain.d.ts.map +1 -1
  125. package/dist/pipeline/auto-chain.js +18 -7
  126. package/dist/pipeline/auto-chain.js.map +1 -1
  127. package/dist/pipeline/fleet-dispatch-bounds.d.ts +115 -0
  128. package/dist/pipeline/fleet-dispatch-bounds.d.ts.map +1 -0
  129. package/dist/pipeline/fleet-dispatch-bounds.js +190 -0
  130. package/dist/pipeline/fleet-dispatch-bounds.js.map +1 -0
  131. package/dist/pipeline/output-validator.d.ts +7 -2
  132. package/dist/pipeline/output-validator.d.ts.map +1 -1
  133. package/dist/pipeline/output-validator.js +61 -4
  134. package/dist/pipeline/output-validator.js.map +1 -1
  135. package/dist/pipeline/phase2/phases/adr-generator.d.ts.map +1 -1
  136. package/dist/pipeline/phase2/phases/adr-generator.js +6 -5
  137. package/dist/pipeline/phase2/phases/adr-generator.js.map +1 -1
  138. package/dist/pipeline/phase3/phases/domain-codegen.d.ts.map +1 -1
  139. package/dist/pipeline/phase3/phases/domain-codegen.js +8 -2
  140. package/dist/pipeline/phase3/phases/domain-codegen.js.map +1 -1
  141. package/dist/pipeline/phase4/phases/schema-generator.js +3 -3
  142. package/dist/pipeline/phase4/phases/schema-generator.js.map +1 -1
  143. package/dist/pipeline/phase7/coherence-gate.d.ts.map +1 -1
  144. package/dist/pipeline/phase7/coherence-gate.js +8 -24
  145. package/dist/pipeline/phase7/coherence-gate.js.map +1 -1
  146. package/dist/pipeline/phase7/coordinator.d.ts +34 -0
  147. package/dist/pipeline/phase7/coordinator.d.ts.map +1 -1
  148. package/dist/pipeline/phase7/coordinator.js +131 -71
  149. package/dist/pipeline/phase7/coordinator.js.map +1 -1
  150. package/dist/pipeline/phase7/field-mappers.d.ts +43 -0
  151. package/dist/pipeline/phase7/field-mappers.d.ts.map +1 -0
  152. package/dist/pipeline/phase7/field-mappers.js +278 -0
  153. package/dist/pipeline/phase7/field-mappers.js.map +1 -0
  154. package/dist/pipeline/phase7/field-writer.d.ts +53 -0
  155. package/dist/pipeline/phase7/field-writer.d.ts.map +1 -0
  156. package/dist/pipeline/phase7/field-writer.js +178 -0
  157. package/dist/pipeline/phase7/field-writer.js.map +1 -0
  158. package/dist/pipeline/phase7/writer-agent.d.ts +83 -0
  159. package/dist/pipeline/phase7/writer-agent.d.ts.map +1 -0
  160. package/dist/pipeline/phase7/writer-agent.js +174 -0
  161. package/dist/pipeline/phase7/writer-agent.js.map +1 -0
  162. package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
  163. package/dist/pipeline/ruflo-phase-executor.js +49 -23
  164. package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
  165. package/dist/pipeline/swarm-orchestrator.d.ts +3 -41
  166. package/dist/pipeline/swarm-orchestrator.d.ts.map +1 -1
  167. package/dist/pipeline/swarm-orchestrator.js +9 -75
  168. package/dist/pipeline/swarm-orchestrator.js.map +1 -1
  169. package/dist/synthesis/fcv-coherence.d.ts +24 -0
  170. package/dist/synthesis/fcv-coherence.d.ts.map +1 -0
  171. package/dist/synthesis/fcv-coherence.js +36 -0
  172. package/dist/synthesis/fcv-coherence.js.map +1 -0
  173. package/dist/synthesis/financial-claim-extractor.d.ts +8 -0
  174. package/dist/synthesis/financial-claim-extractor.d.ts.map +1 -1
  175. package/dist/synthesis/financial-claim-extractor.js +74 -1
  176. package/dist/synthesis/financial-claim-extractor.js.map +1 -1
  177. package/dist/synthesis/financial-consistency-rules.d.ts.map +1 -1
  178. package/dist/synthesis/financial-consistency-rules.js +21 -12
  179. package/dist/synthesis/financial-consistency-rules.js.map +1 -1
  180. package/dist/synthesis/financial-consistency-runner.d.ts +12 -0
  181. package/dist/synthesis/financial-consistency-runner.d.ts.map +1 -1
  182. package/dist/synthesis/financial-consistency-runner.js +25 -3
  183. package/dist/synthesis/financial-consistency-runner.js.map +1 -1
  184. package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
  185. package/dist/synthesis/simulation-artifact-generator.js +5 -0
  186. package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
  187. package/dist/synthesis/simulation-renderers.d.ts +2 -0
  188. package/dist/synthesis/simulation-renderers.d.ts.map +1 -1
  189. package/dist/synthesis/simulation-renderers.js +8 -8
  190. package/dist/synthesis/simulation-renderers.js.map +1 -1
  191. package/dist/synthesis/unit-economics-loader.d.ts +7 -0
  192. package/dist/synthesis/unit-economics-loader.d.ts.map +1 -1
  193. package/dist/synthesis/unit-economics-loader.js +11 -2
  194. package/dist/synthesis/unit-economics-loader.js.map +1 -1
  195. package/package.json +8 -7
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Fleet dispatch bounds — shared timeout / circuit-breaker primitives.
3
+ *
4
+ * ADR-PIPELINE-108: the Phase 1 full-fleet dispatch (109 agents) and the
5
+ * Phase 2–6 phase fanouts must share ONE bounding discipline:
6
+ * - a per-agent timeout so no single agent can stall the batch, and
7
+ * - a per-fanout cloud circuit breaker so a dead backend short-circuits
8
+ * the remaining cloud calls instead of each eating its full timeout.
9
+ *
10
+ * These primitives previously lived inside `swarm-orchestrator.ts`, but
11
+ * `swarm-orchestrator.ts` imports `executeAgentsInvokeCommand` from
12
+ * `commands/agents.ts`. Having `agents.ts` import the breaker back from the
13
+ * orchestrator would create an import cycle, so the shared pieces live here
14
+ * in a leaf module that neither imports from. `swarm-orchestrator.ts`
15
+ * re-exports `CloudCircuitBreaker` / `CloudBreakerState` for back-compat
16
+ * (existing tests import them from there).
17
+ */
18
+ /** Default consecutive cloud-failure threshold before the breaker trips. */
19
+ export declare const DEFAULT_CLOUD_BREAKER_THRESHOLD = 3;
20
+ /** State exposed by `CloudCircuitBreaker.state()`. */
21
+ export interface CloudBreakerState {
22
+ readonly tripped: boolean;
23
+ readonly after_n_timeouts: number;
24
+ readonly agents: ReadonlyArray<string>;
25
+ }
26
+ /**
27
+ * Per-fanout circuit breaker that trips after N consecutive cloud-tier
28
+ * failures and short-circuits remaining cloud invocations. Local-tier
29
+ * successes do not reset the streak; they bypass the breaker.
30
+ *
31
+ * Cloud-tier successes DO reset the streak — if even one cloud call works,
32
+ * we trust the cloud is alive again. This matches the originating-run
33
+ * failure mode where an entire backend fleet was down at once.
34
+ *
35
+ * Resets per fanout. Exported for unit tests.
36
+ */
37
+ export declare class CloudCircuitBreaker {
38
+ private consecutiveCloudFailures;
39
+ private trippedFlag;
40
+ private trippedAfterN;
41
+ private readonly trippedAgents;
42
+ private readonly threshold;
43
+ constructor(threshold?: number);
44
+ /**
45
+ * Record an invocation outcome. `tier` is the tier the call was dispatched
46
+ * on. `failed=true` AND `tier='cloud'` increments the consecutive-failure
47
+ * counter; a cloud success resets it.
48
+ */
49
+ record(failed: boolean, tier: 'cloud' | 'local' | 'unknown', agentLabel: string): void;
50
+ /** Returns true once the breaker has tripped. */
51
+ shouldSkip(): boolean;
52
+ /** Snapshot of the breaker state for status.json / gate-decision-log. */
53
+ state(): CloudBreakerState;
54
+ }
55
+ /**
56
+ * Resolve the cloud-breaker threshold from env (`AGENTICS_CLOUD_BREAKER_THRESHOLD`).
57
+ * Falls back to the default constant.
58
+ */
59
+ export declare function resolveCloudBreakerThreshold(): number;
60
+ /** Default per-agent invocation timeout for the Phase 1 fleet (matches the
61
+ * Phase 2–6 path's 30s). Env override: `AGENTICS_FLEET_AGENT_TIMEOUT_MS`. */
62
+ export declare const DEFAULT_FLEET_AGENT_TIMEOUT_MS = 30000;
63
+ /** Default fleet-wide deadline. Larger than a phase fanout (the fleet is
64
+ * ~109 agents). Env override: `AGENTICS_FLEET_TIMEOUT_MS`. */
65
+ export declare const DEFAULT_FLEET_TIMEOUT_MS = 60000;
66
+ /** Per-agent timeout for the fleet (D1). */
67
+ export declare function resolveFleetAgentTimeoutMs(): number;
68
+ /** Fleet-wide deadline (D2). */
69
+ export declare function resolveFleetTimeoutMs(): number;
70
+ /** The effective bounds, for recording into manifest.json (D5). */
71
+ export interface FleetDispatchConfig {
72
+ readonly agent_timeout_ms: number;
73
+ readonly fleet_timeout_ms: number;
74
+ readonly cloud_breaker_threshold: number;
75
+ }
76
+ export declare function resolveFleetDispatchConfig(): FleetDispatchConfig;
77
+ export type AgentTier = 'repo' | 'cloud';
78
+ /**
79
+ * Pure tier-selection logic (kept in this leaf module so it is unit-testable
80
+ * without importing the repo-agent-runner, which uses import.meta and breaks
81
+ * jest). `forced` is the raw `AGENTICS_AGENT_TIER` value.
82
+ *
83
+ * - `forced==='cloud'` → cloud
84
+ * - `forced==='repo'` → repo if a repo mapping exists, else cloud
85
+ * - default (`auto`) → repo only when repo mode is on AND a repo mapping
86
+ * exists AND source is actually cached (the D2 gate); else cloud.
87
+ */
88
+ export declare function decideAgentTier(opts: {
89
+ forced?: string | undefined;
90
+ hasRepo: boolean;
91
+ repoMode: boolean;
92
+ sourceCached: boolean;
93
+ }): AgentTier;
94
+ /** Sentinel returned by {@link withAgentTimeout} when the deadline wins. */
95
+ export declare const AGENT_TIMED_OUT: unique symbol;
96
+ /**
97
+ * Race a promise against a timeout. Resolves to {@link AGENT_TIMED_OUT} when
98
+ * the deadline fires first. The underlying promise is NOT cancelled (Node has
99
+ * no cancellation), but the caller stops waiting on it — the key property the
100
+ * Phase 1 fleet needs so one slow agent cannot stall the batch.
101
+ *
102
+ * The timer is cleared on settle so it never keeps the event loop alive.
103
+ */
104
+ export declare function withAgentTimeout<T>(promise: Promise<T>, ms: number): Promise<T | typeof AGENT_TIMED_OUT>;
105
+ /** Sentinel returned by {@link raceFleetDeadline} when the fleet deadline wins. */
106
+ export declare const FLEET_TIMED_OUT: "TIMEOUT";
107
+ /**
108
+ * ADR-PIPELINE-108 D2: race the whole agent batch against a wall-clock fleet
109
+ * deadline. Returns the settled batch if it finishes first, else
110
+ * {@link FLEET_TIMED_OUT}. The deadline timer is cleared on settle so a normal
111
+ * (non-timeout) completion never leaves a dangling timer holding the event loop
112
+ * open — important for long-lived (daemon/server) callers.
113
+ */
114
+ export declare function raceFleetDeadline<T>(batch: Promise<T>, ms: number): Promise<T | typeof FLEET_TIMED_OUT>;
115
+ //# sourceMappingURL=fleet-dispatch-bounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-dispatch-bounds.d.ts","sourceRoot":"","sources":["../../src/pipeline/fleet-dispatch-bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,4EAA4E;AAC5E,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,wBAAwB,CAAK;IACrC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO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M,GACT,OAAO,CAAC,CAAC,GAAG,OAAO,eAAe,CAAC,CAUrC;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAG,SAAkB,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EACjB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,CAAC,GAAG,OAAO,eAAe,CAAC,CAUrC"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Fleet dispatch bounds — shared timeout / circuit-breaker primitives.
3
+ *
4
+ * ADR-PIPELINE-108: the Phase 1 full-fleet dispatch (109 agents) and the
5
+ * Phase 2–6 phase fanouts must share ONE bounding discipline:
6
+ * - a per-agent timeout so no single agent can stall the batch, and
7
+ * - a per-fanout cloud circuit breaker so a dead backend short-circuits
8
+ * the remaining cloud calls instead of each eating its full timeout.
9
+ *
10
+ * These primitives previously lived inside `swarm-orchestrator.ts`, but
11
+ * `swarm-orchestrator.ts` imports `executeAgentsInvokeCommand` from
12
+ * `commands/agents.ts`. Having `agents.ts` import the breaker back from the
13
+ * orchestrator would create an import cycle, so the shared pieces live here
14
+ * in a leaf module that neither imports from. `swarm-orchestrator.ts`
15
+ * re-exports `CloudCircuitBreaker` / `CloudBreakerState` for back-compat
16
+ * (existing tests import them from there).
17
+ */
18
+ // ============================================================================
19
+ // Cloud circuit breaker (ADR-094 D7, generalised by ADR-108)
20
+ // ============================================================================
21
+ /** Default consecutive cloud-failure threshold before the breaker trips. */
22
+ export const DEFAULT_CLOUD_BREAKER_THRESHOLD = 3;
23
+ /**
24
+ * Per-fanout circuit breaker that trips after N consecutive cloud-tier
25
+ * failures and short-circuits remaining cloud invocations. Local-tier
26
+ * successes do not reset the streak; they bypass the breaker.
27
+ *
28
+ * Cloud-tier successes DO reset the streak — if even one cloud call works,
29
+ * we trust the cloud is alive again. This matches the originating-run
30
+ * failure mode where an entire backend fleet was down at once.
31
+ *
32
+ * Resets per fanout. Exported for unit tests.
33
+ */
34
+ export class CloudCircuitBreaker {
35
+ consecutiveCloudFailures = 0;
36
+ trippedFlag = false;
37
+ trippedAfterN = 0;
38
+ trippedAgents = [];
39
+ threshold;
40
+ constructor(threshold = DEFAULT_CLOUD_BREAKER_THRESHOLD) {
41
+ this.threshold = Math.max(1, threshold);
42
+ }
43
+ /**
44
+ * Record an invocation outcome. `tier` is the tier the call was dispatched
45
+ * on. `failed=true` AND `tier='cloud'` increments the consecutive-failure
46
+ * counter; a cloud success resets it.
47
+ */
48
+ record(failed, tier, agentLabel) {
49
+ if (this.trippedFlag)
50
+ return; // already tripped — record-only mode
51
+ if (tier === 'cloud') {
52
+ if (failed) {
53
+ this.consecutiveCloudFailures++;
54
+ this.trippedAgents.push(agentLabel);
55
+ if (this.consecutiveCloudFailures >= this.threshold) {
56
+ this.trippedFlag = true;
57
+ this.trippedAfterN = this.consecutiveCloudFailures;
58
+ process.stderr.write(`[BREAKER] cloud breaker tripped after ${this.trippedAfterN} timeouts (${this.trippedAgents.slice(0, 5).join(', ')}${this.trippedAgents.length > 5 ? ', …' : ''})\n`);
59
+ }
60
+ }
61
+ else {
62
+ // Cloud success — clear the streak. Cloud is alive.
63
+ this.consecutiveCloudFailures = 0;
64
+ }
65
+ }
66
+ // local-tier outcomes don't move the breaker state.
67
+ }
68
+ /** Returns true once the breaker has tripped. */
69
+ shouldSkip() { return this.trippedFlag; }
70
+ /** Snapshot of the breaker state for status.json / gate-decision-log. */
71
+ state() {
72
+ return {
73
+ tripped: this.trippedFlag,
74
+ after_n_timeouts: this.trippedAfterN,
75
+ agents: [...this.trippedAgents],
76
+ };
77
+ }
78
+ }
79
+ /**
80
+ * Resolve the cloud-breaker threshold from env (`AGENTICS_CLOUD_BREAKER_THRESHOLD`).
81
+ * Falls back to the default constant.
82
+ */
83
+ export function resolveCloudBreakerThreshold() {
84
+ const env = process.env['AGENTICS_CLOUD_BREAKER_THRESHOLD'];
85
+ if (env) {
86
+ const parsed = parseInt(env, 10);
87
+ if (!Number.isNaN(parsed) && parsed >= 1)
88
+ return parsed;
89
+ }
90
+ return DEFAULT_CLOUD_BREAKER_THRESHOLD;
91
+ }
92
+ // ============================================================================
93
+ // Per-agent + fleet timeouts (ADR-108 D1, D2, D5)
94
+ // ============================================================================
95
+ /** Default per-agent invocation timeout for the Phase 1 fleet (matches the
96
+ * Phase 2–6 path's 30s). Env override: `AGENTICS_FLEET_AGENT_TIMEOUT_MS`. */
97
+ export const DEFAULT_FLEET_AGENT_TIMEOUT_MS = 30_000;
98
+ /** Default fleet-wide deadline. Larger than a phase fanout (the fleet is
99
+ * ~109 agents). Env override: `AGENTICS_FLEET_TIMEOUT_MS`. */
100
+ export const DEFAULT_FLEET_TIMEOUT_MS = 60_000;
101
+ function resolvePositiveIntEnv(name, fallback) {
102
+ const env = process.env[name];
103
+ if (env) {
104
+ const parsed = parseInt(env, 10);
105
+ if (!Number.isNaN(parsed) && parsed >= 1)
106
+ return parsed;
107
+ }
108
+ return fallback;
109
+ }
110
+ /** Per-agent timeout for the fleet (D1). */
111
+ export function resolveFleetAgentTimeoutMs() {
112
+ return resolvePositiveIntEnv('AGENTICS_FLEET_AGENT_TIMEOUT_MS', DEFAULT_FLEET_AGENT_TIMEOUT_MS);
113
+ }
114
+ /** Fleet-wide deadline (D2). */
115
+ export function resolveFleetTimeoutMs() {
116
+ return resolvePositiveIntEnv('AGENTICS_FLEET_TIMEOUT_MS', DEFAULT_FLEET_TIMEOUT_MS);
117
+ }
118
+ export function resolveFleetDispatchConfig() {
119
+ return {
120
+ agent_timeout_ms: resolveFleetAgentTimeoutMs(),
121
+ fleet_timeout_ms: resolveFleetTimeoutMs(),
122
+ cloud_breaker_threshold: resolveCloudBreakerThreshold(),
123
+ };
124
+ }
125
+ /**
126
+ * Pure tier-selection logic (kept in this leaf module so it is unit-testable
127
+ * without importing the repo-agent-runner, which uses import.meta and breaks
128
+ * jest). `forced` is the raw `AGENTICS_AGENT_TIER` value.
129
+ *
130
+ * - `forced==='cloud'` → cloud
131
+ * - `forced==='repo'` → repo if a repo mapping exists, else cloud
132
+ * - default (`auto`) → repo only when repo mode is on AND a repo mapping
133
+ * exists AND source is actually cached (the D2 gate); else cloud.
134
+ */
135
+ export function decideAgentTier(opts) {
136
+ const forced = (opts.forced ?? '').toLowerCase();
137
+ if (forced === 'cloud')
138
+ return 'cloud';
139
+ if (forced === 'repo')
140
+ return opts.hasRepo ? 'repo' : 'cloud';
141
+ if (opts.repoMode && opts.hasRepo && opts.sourceCached)
142
+ return 'repo';
143
+ return 'cloud';
144
+ }
145
+ /** Sentinel returned by {@link withAgentTimeout} when the deadline wins. */
146
+ export const AGENT_TIMED_OUT = Symbol('agent-timed-out');
147
+ /**
148
+ * Race a promise against a timeout. Resolves to {@link AGENT_TIMED_OUT} when
149
+ * the deadline fires first. The underlying promise is NOT cancelled (Node has
150
+ * no cancellation), but the caller stops waiting on it — the key property the
151
+ * Phase 1 fleet needs so one slow agent cannot stall the batch.
152
+ *
153
+ * The timer is cleared on settle so it never keeps the event loop alive.
154
+ */
155
+ export async function withAgentTimeout(promise, ms) {
156
+ let timer;
157
+ const timeout = new Promise((resolve) => {
158
+ timer = setTimeout(() => resolve(AGENT_TIMED_OUT), ms);
159
+ });
160
+ try {
161
+ return await Promise.race([promise, timeout]);
162
+ }
163
+ finally {
164
+ if (timer)
165
+ clearTimeout(timer);
166
+ }
167
+ }
168
+ /** Sentinel returned by {@link raceFleetDeadline} when the fleet deadline wins. */
169
+ export const FLEET_TIMED_OUT = 'TIMEOUT';
170
+ /**
171
+ * ADR-PIPELINE-108 D2: race the whole agent batch against a wall-clock fleet
172
+ * deadline. Returns the settled batch if it finishes first, else
173
+ * {@link FLEET_TIMED_OUT}. The deadline timer is cleared on settle so a normal
174
+ * (non-timeout) completion never leaves a dangling timer holding the event loop
175
+ * open — important for long-lived (daemon/server) callers.
176
+ */
177
+ export async function raceFleetDeadline(batch, ms) {
178
+ let timer;
179
+ const deadline = new Promise((resolve) => {
180
+ timer = setTimeout(() => resolve(FLEET_TIMED_OUT), ms);
181
+ });
182
+ try {
183
+ return await Promise.race([batch, deadline]);
184
+ }
185
+ finally {
186
+ if (timer)
187
+ clearTimeout(timer);
188
+ }
189
+ }
190
+ //# sourceMappingURL=fleet-dispatch-bounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-dispatch-bounds.js","sourceRoot":"","sources":["../../src/pipeline/fleet-dispatch-bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,+EAA+E;AAC/E,6DAA6D;AAC7D,+EAA+E;AAE/E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AASjD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAmB;IACtB,wBAAwB,GAAG,CAAC,CAAC;IAC7B,WAAW,GAAG,KAAK,CAAC;IACpB,aAAa,GAAG,CAAC,CAAC;IACT,aAAa,GAAa,EAAE,CAAC;IAC7B,SAAS,CAAS;IAEnC,YAAY,SAAS,GAAG,+BAA+B;QACrD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAe,EAAE,IAAmC,EAAE,UAAkB;QAC7E,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,qCAAqC;QACnE,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACpC,IAAI,IAAI,CAAC,wBAAwB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;oBACpD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;oBACxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,wBAAwB,CAAC;oBACnD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C,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAmB,EACnB,EAAU;IAEV,IAAI,KAAgD,CAAC;IACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,EAAE;QAC9D,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,MAAM,eAAe,GAAG,SAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAiB,EACjB,EAAU;IAEV,IAAI,KAAgD,CAAC;IACrD,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,EAAE;QAC/D,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -26,8 +26,13 @@ export declare function validateSparc(filePath: string): StructuralCheckResult;
26
26
  */
27
27
  export declare function validateAdrDir(adrDir: string): StructuralCheckResult[];
28
28
  /**
29
- * Verify the implementation-prompts directory has numbered prompts in the
30
- * impl-NNN-*.md form. Counts the prompts and reports zero or too-few cases.
29
+ * Verify the implementation-prompts directory. Accepts EITHER:
30
+ * - the consolidated single-file format (ADR-PIPELINE-104): one
31
+ * `implementation-prompts.md` with ≥ minPrompts `## Implement ADR-`
32
+ * sections; OR
33
+ * - the legacy multi-file format (ADR-PIPELINE-101): ≥ minPrompts files
34
+ * matching `impl-NNN-*.md` (for any local fallback paths that still
35
+ * emit this shape).
31
36
  */
32
37
  export declare function validateImplementationPrompts(promptsDir: string, minPrompts?: number): StructuralCheckResult;
33
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"output-validator.d.ts","sourceRoot":"","sources":["../../src/pipeline/output-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,KAAK,GAAG,wBAAwB,CAAC;CACnE;AAcD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAoBrE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAuCtE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,SAAI,GACb,qBAAqB,CAkCvB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,UAAU,EAAE,MAAM,GACjB,MAAM,CAUR"}
1
+ {"version":3,"file":"output-validator.d.ts","sourceRoot":"","sources":["../../src/pipeline/output-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,KAAK,GAAG,wBAAwB,CAAC;CACnE;AAcD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAoBrE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAuCtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,GACd,qBAAqB,CAuFvB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,UAAU,EAAE,MAAM,GACjB,MAAM,CAUR"}
@@ -94,10 +94,15 @@ export function validateAdrDir(adrDir) {
94
94
  });
95
95
  }
96
96
  /**
97
- * Verify the implementation-prompts directory has numbered prompts in the
98
- * impl-NNN-*.md form. Counts the prompts and reports zero or too-few cases.
97
+ * Verify the implementation-prompts directory. Accepts EITHER:
98
+ * - the consolidated single-file format (ADR-PIPELINE-104): one
99
+ * `implementation-prompts.md` with ≥ minPrompts `## Implement ADR-`
100
+ * sections; OR
101
+ * - the legacy multi-file format (ADR-PIPELINE-101): ≥ minPrompts files
102
+ * matching `impl-NNN-*.md` (for any local fallback paths that still
103
+ * emit this shape).
99
104
  */
100
- export function validateImplementationPrompts(promptsDir, minPrompts = 5) {
105
+ export function validateImplementationPrompts(promptsDir, minPrompts = 10) {
101
106
  if (!fs.existsSync(promptsDir)) {
102
107
  return {
103
108
  ok: false,
@@ -106,6 +111,48 @@ export function validateImplementationPrompts(promptsDir, minPrompts = 5) {
106
111
  artifactKind: 'implementation-prompts',
107
112
  };
108
113
  }
114
+ // ── consolidated single-file path ─────────────────────────────────────
115
+ const consolidatedPath = path.join(promptsDir, 'implementation-prompts.md');
116
+ if (fs.existsSync(consolidatedPath)) {
117
+ let content;
118
+ try {
119
+ content = fs.readFileSync(consolidatedPath, 'utf-8');
120
+ }
121
+ catch (err) {
122
+ return {
123
+ ok: false,
124
+ missing: [`unreadable: ${err instanceof Error ? err.message : String(err)}`],
125
+ filePath: consolidatedPath,
126
+ artifactKind: 'implementation-prompts',
127
+ };
128
+ }
129
+ const sectionRe = /^##\s+Implement\s+ADR-/gim;
130
+ const matches = content.match(sectionRe) ?? [];
131
+ const failureSectionRe = /^##\s+Implement\s+ADR-FAIL-/im;
132
+ if (failureSectionRe.test(content)) {
133
+ return {
134
+ ok: false,
135
+ missing: ['implementation-prompts.md contains an "Implement ADR-FAIL-…" section — ADR-FAIL stubs must be filtered out'],
136
+ filePath: consolidatedPath,
137
+ artifactKind: 'implementation-prompts',
138
+ };
139
+ }
140
+ if (matches.length < minPrompts) {
141
+ return {
142
+ ok: false,
143
+ missing: [`consolidated implementation-prompts.md has ${matches.length} sections (expected at least ${minPrompts})`],
144
+ filePath: consolidatedPath,
145
+ artifactKind: 'implementation-prompts',
146
+ };
147
+ }
148
+ return {
149
+ ok: true,
150
+ missing: [],
151
+ filePath: consolidatedPath,
152
+ artifactKind: 'implementation-prompts',
153
+ };
154
+ }
155
+ // ── legacy multi-file path ────────────────────────────────────────────
109
156
  let files;
110
157
  try {
111
158
  files = fs.readdirSync(promptsDir).filter((f) => /^impl-\d+-.+\.md$/.test(f));
@@ -121,11 +168,21 @@ export function validateImplementationPrompts(promptsDir, minPrompts = 5) {
121
168
  if (files.length < minPrompts) {
122
169
  return {
123
170
  ok: false,
124
- missing: [`expected at least ${minPrompts} prompts, found ${files.length}`],
171
+ missing: [`expected at least ${minPrompts} prompts (consolidated implementation-prompts.md OR impl-NNN-*.md files), found ${files.length}`],
125
172
  filePath: promptsDir,
126
173
  artifactKind: 'implementation-prompts',
127
174
  };
128
175
  }
176
+ // Reject any legacy impl-NNN file whose title contains "adr-failed".
177
+ const failureFile = files.find((f) => /adr-failed|adr-fail/i.test(f));
178
+ if (failureFile) {
179
+ return {
180
+ ok: false,
181
+ missing: [`legacy impl prompts include a failure-stub file: ${failureFile} — ADR-FAIL stubs must be filtered upstream`],
182
+ filePath: path.join(promptsDir, failureFile),
183
+ artifactKind: 'implementation-prompts',
184
+ };
185
+ }
129
186
  return {
130
187
  ok: true,
131
188
  missing: [],
@@ -1 +1 @@
1
- {"version":3,"file":"output-validator.js","sourceRoot":"","sources":["../../src/pipeline/output-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,sDAAsD;AACtD,MAAM,oBAAoB,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,iBAAiB,CAAU,CAAC;AAEvF,6EAA6E;AAC7E,MAAM,cAAc,GAAG;IACrB,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,kDAAkD,EAAE;IAClF,EAAE,KAAK,EAAE,YAAY,EAAK,EAAE,EAAE,+CAA+C,EAAE;IAC/E,EAAE,KAAK,EAAE,cAAc,EAAG,EAAE,EAAE,iDAAiD,EAAE;IACjF,EAAE,KAAK,EAAE,YAAY,EAAK,EAAE,EAAE,+CAA+C,EAAE;IAC/E,EAAE,KAAK,EAAE,YAAY,EAAK,EAAE,EAAE,+CAA+C,EAAE;CACvE,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;IACrF,CAAC;IACD,IAAI,OAAe,CAAC;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+B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4GAA4G,CAAC,CAAC;IACnI,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"adr-generator.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/phase2/phases/adr-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAGf,eAAe,EAChB,MAAM,aAAa,CAAC;AAmIrB;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA4BpI;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBnF;AAipBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,eAAe,CAwFlB;AAiGD,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8IrF"}
1
+ {"version":3,"file":"adr-generator.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/phase2/phases/adr-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAGf,eAAe,EAChB,MAAM,aAAa,CAAC;AAmIrB;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA4BpI;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBnF;AAmpBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,eAAe,CAwFlB;AAiGD,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8IrF"}
@@ -201,7 +201,7 @@ async function tryGenerateLLMADRs(sparc, dossier, query, phase2Dir = '') {
201
201
  try {
202
202
  const claudeBin = resolveClaudeBin();
203
203
  if (!claudeBin) {
204
- process.stderr.write('[adr-generator] claude binary not found — cannot generate LLM ADRs\n');
204
+ process.stderr.write('[CANNED FALLBACK] [adr-generator] claude binary not found on PATH falling back to ADR-FAIL-001 stub. Set AGENTICS_CLAUDE_BIN or install Claude Code.\n');
205
205
  return null;
206
206
  }
207
207
  const delimiter = newDocBreakDelimiter();
@@ -209,10 +209,11 @@ async function tryGenerateLLMADRs(sparc, dossier, query, phase2Dir = '') {
209
209
  const model = process.env['AGENTICS_CLAUDE_MODEL'] || 'claude-sonnet-4-20250514';
210
210
  const timeoutMs = parseAdrTimeoutMs();
211
211
  const startMs = Date.now();
212
+ process.stderr.write(`[adr-generator] starting claude --print: model=${model}, timeout=${Math.round(timeoutMs / 1000)}s, prompt=${prompt.length} chars\n`);
212
213
  const result = await runStreamedClaudePrint(claudeBin, prompt, model, timeoutMs, phase2Dir);
213
214
  if (!result.ok) {
214
- process.stderr.write(`[adr-generator] Claude --print stream failed: ${result.reason} ` +
215
- `(received ${result.stdoutBytes} bytes over ${result.elapsedMs}ms)\n`);
215
+ process.stderr.write(`[CANNED FALLBACK] [adr-generator] Claude --print stream failed: ${result.reason} ` +
216
+ `(received ${result.stdoutBytes} bytes over ${result.elapsedMs}ms) — will salvage partial output if ≥1KB, otherwise emit ADR-FAIL-001 stub\n`);
216
217
  // ADR-PIPELINE-100 §D3: streamed output is preserved on timeout/kill, so
217
218
  // we still try to parse what came back — if the LLM finished the first
218
219
  // few ADRs before the cap, those are usable.
@@ -227,7 +228,7 @@ async function tryGenerateLLMADRs(sparc, dossier, query, phase2Dir = '') {
227
228
  }
228
229
  const adrs = parseMarkdownADRs(result.stdout, delimiter, dossier);
229
230
  if (!adrs || adrs.length === 0) {
230
- process.stderr.write('[adr-generator] Claude --print returned no parseable markdown ADRs\n');
231
+ process.stderr.write(`[CANNED FALLBACK] [adr-generator] Claude --print returned ${result.stdoutBytes} bytes but parseMarkdownADRs extracted 0 ADRs — delimiter "${delimiter.slice(0, 40)}…" not found or markdown malformed. Falling back to ADR-FAIL-001 stub.\n`);
231
232
  return null;
232
233
  }
233
234
  const durationMs = Date.now() - startMs;
@@ -236,7 +237,7 @@ async function tryGenerateLLMADRs(sparc, dossier, query, phase2Dir = '') {
236
237
  return adrs;
237
238
  }
238
239
  catch (err) {
239
- process.stderr.write(`[adr-generator] LLM ADR generation failed: ${err instanceof Error ? err.message : String(err)}\n`);
240
+ process.stderr.write(`[CANNED FALLBACK] [adr-generator] LLM ADR generation threw: ${err instanceof Error ? err.message : String(err)} — emitting ADR-FAIL-001 stub. Stack: ${err instanceof Error && err.stack ? err.stack.split('\n').slice(0, 3).join(' | ') : 'n/a'}\n`);
240
241
  return null;
241
242
  }
242
243
  }