@llm-dev-ops/agentics-cli 2.1.5 → 2.4.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 (96) hide show
  1. package/dist/pipeline/auto-chain.d.ts +190 -0
  2. package/dist/pipeline/auto-chain.d.ts.map +1 -1
  3. package/dist/pipeline/auto-chain.js +1571 -72
  4. package/dist/pipeline/auto-chain.js.map +1 -1
  5. package/dist/pipeline/phase2/phases/prompt-generator.d.ts.map +1 -1
  6. package/dist/pipeline/phase2/phases/prompt-generator.js +205 -12
  7. package/dist/pipeline/phase2/phases/prompt-generator.js.map +1 -1
  8. package/dist/pipeline/phase2/schemas.d.ts +10 -10
  9. package/dist/pipeline/phase4/phases/http-server-generator.d.ts +12 -0
  10. package/dist/pipeline/phase4/phases/http-server-generator.d.ts.map +1 -1
  11. package/dist/pipeline/phase4/phases/http-server-generator.js +92 -25
  12. package/dist/pipeline/phase4/phases/http-server-generator.js.map +1 -1
  13. package/dist/pipeline/phase4-5-pre-render/financial-model.d.ts +51 -0
  14. package/dist/pipeline/phase4-5-pre-render/financial-model.d.ts.map +1 -0
  15. package/dist/pipeline/phase4-5-pre-render/financial-model.js +118 -0
  16. package/dist/pipeline/phase4-5-pre-render/financial-model.js.map +1 -0
  17. package/dist/pipeline/phase4-5-pre-render/post-render-reconciler.d.ts +53 -0
  18. package/dist/pipeline/phase4-5-pre-render/post-render-reconciler.d.ts.map +1 -0
  19. package/dist/pipeline/phase4-5-pre-render/post-render-reconciler.js +130 -0
  20. package/dist/pipeline/phase4-5-pre-render/post-render-reconciler.js.map +1 -0
  21. package/dist/pipeline/phase4-5-pre-render/pre-render-coordinator.d.ts +47 -0
  22. package/dist/pipeline/phase4-5-pre-render/pre-render-coordinator.d.ts.map +1 -0
  23. package/dist/pipeline/phase4-5-pre-render/pre-render-coordinator.js +105 -0
  24. package/dist/pipeline/phase4-5-pre-render/pre-render-coordinator.js.map +1 -0
  25. package/dist/pipeline/phase4-5-pre-render/sector-baselines.d.ts +42 -0
  26. package/dist/pipeline/phase4-5-pre-render/sector-baselines.d.ts.map +1 -0
  27. package/dist/pipeline/phase4-5-pre-render/sector-baselines.js +117 -0
  28. package/dist/pipeline/phase4-5-pre-render/sector-baselines.js.map +1 -0
  29. package/dist/pipeline/phase5-build/phase5-build-coordinator.d.ts.map +1 -1
  30. package/dist/pipeline/phase5-build/phase5-build-coordinator.js +44 -0
  31. package/dist/pipeline/phase5-build/phase5-build-coordinator.js.map +1 -1
  32. package/dist/pipeline/phase5-build/phases/post-generation-validator.d.ts +75 -0
  33. package/dist/pipeline/phase5-build/phases/post-generation-validator.d.ts.map +1 -0
  34. package/dist/pipeline/phase5-build/phases/post-generation-validator.js +1068 -0
  35. package/dist/pipeline/phase5-build/phases/post-generation-validator.js.map +1 -0
  36. package/dist/pipeline/phase5-build/types.d.ts +1 -1
  37. package/dist/pipeline/phase5-build/types.d.ts.map +1 -1
  38. package/dist/pipeline/types.d.ts +87 -0
  39. package/dist/pipeline/types.d.ts.map +1 -1
  40. package/dist/pipeline/types.js +51 -1
  41. package/dist/pipeline/types.js.map +1 -1
  42. package/dist/synthesis/consensus-svg.d.ts +19 -0
  43. package/dist/synthesis/consensus-svg.d.ts.map +1 -0
  44. package/dist/synthesis/consensus-svg.js +95 -0
  45. package/dist/synthesis/consensus-svg.js.map +1 -0
  46. package/dist/synthesis/consensus-tiers.d.ts +99 -0
  47. package/dist/synthesis/consensus-tiers.d.ts.map +1 -0
  48. package/dist/synthesis/consensus-tiers.js +285 -0
  49. package/dist/synthesis/consensus-tiers.js.map +1 -0
  50. package/dist/synthesis/domain-labor-classifier.d.ts +101 -0
  51. package/dist/synthesis/domain-labor-classifier.d.ts.map +1 -0
  52. package/dist/synthesis/domain-labor-classifier.js +312 -0
  53. package/dist/synthesis/domain-labor-classifier.js.map +1 -0
  54. package/dist/synthesis/domain-unit-registry.d.ts +59 -0
  55. package/dist/synthesis/domain-unit-registry.d.ts.map +1 -0
  56. package/dist/synthesis/domain-unit-registry.js +320 -0
  57. package/dist/synthesis/domain-unit-registry.js.map +1 -0
  58. package/dist/synthesis/financial-claim-extractor.d.ts +72 -0
  59. package/dist/synthesis/financial-claim-extractor.d.ts.map +1 -0
  60. package/dist/synthesis/financial-claim-extractor.js +382 -0
  61. package/dist/synthesis/financial-claim-extractor.js.map +1 -0
  62. package/dist/synthesis/financial-consistency-rules.d.ts +70 -0
  63. package/dist/synthesis/financial-consistency-rules.d.ts.map +1 -0
  64. package/dist/synthesis/financial-consistency-rules.js +483 -0
  65. package/dist/synthesis/financial-consistency-rules.js.map +1 -0
  66. package/dist/synthesis/financial-consistency-runner.d.ts +73 -0
  67. package/dist/synthesis/financial-consistency-runner.d.ts.map +1 -0
  68. package/dist/synthesis/financial-consistency-runner.js +131 -0
  69. package/dist/synthesis/financial-consistency-runner.js.map +1 -0
  70. package/dist/synthesis/forbidden-spin-phrases.d.ts +32 -0
  71. package/dist/synthesis/forbidden-spin-phrases.d.ts.map +1 -0
  72. package/dist/synthesis/forbidden-spin-phrases.js +84 -0
  73. package/dist/synthesis/forbidden-spin-phrases.js.map +1 -0
  74. package/dist/synthesis/phase-gate-thresholds.d.ts +30 -0
  75. package/dist/synthesis/phase-gate-thresholds.d.ts.map +1 -0
  76. package/dist/synthesis/phase-gate-thresholds.js +34 -0
  77. package/dist/synthesis/phase-gate-thresholds.js.map +1 -0
  78. package/dist/synthesis/prompts/index.d.ts.map +1 -1
  79. package/dist/synthesis/prompts/index.js +22 -0
  80. package/dist/synthesis/prompts/index.js.map +1 -1
  81. package/dist/synthesis/roadmap-dates.d.ts +72 -0
  82. package/dist/synthesis/roadmap-dates.d.ts.map +1 -0
  83. package/dist/synthesis/roadmap-dates.js +203 -0
  84. package/dist/synthesis/roadmap-dates.js.map +1 -0
  85. package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
  86. package/dist/synthesis/simulation-artifact-generator.js +135 -1
  87. package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
  88. package/dist/synthesis/simulation-renderers.d.ts +105 -2
  89. package/dist/synthesis/simulation-renderers.d.ts.map +1 -1
  90. package/dist/synthesis/simulation-renderers.js +1192 -123
  91. package/dist/synthesis/simulation-renderers.js.map +1 -1
  92. package/dist/synthesis/unit-economics-loader.d.ts +71 -0
  93. package/dist/synthesis/unit-economics-loader.d.ts.map +1 -0
  94. package/dist/synthesis/unit-economics-loader.js +200 -0
  95. package/dist/synthesis/unit-economics-loader.js.map +1 -0
  96. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"financial-model.js","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/financial-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,cAAc,GAGf,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAgC/B,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACH;IAA7C,YAAY,OAAe,EAAkB,OAAO,oBAAoB;QACtE,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QADc,SAAI,GAAJ,IAAI,CAAuB;QAEtE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAA8B;IAE9B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC;IAC5C,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,cAAc,CAAC,MA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AC;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;QAClG,MAAM,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAAC;IACxC,CAAC;IACD,qEAAqE;IACrE,qEAAqE;IACrE,IAAI,MAAM,KAAK,kBAAkB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3D,kEAAkE;QAClE,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB;IAC9F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §5 — Post-Render Reconciliation.
3
+ *
4
+ * After the coding agent generates the prototype and its demo runs, the
5
+ * real demo calls `writeUnitEconomics()` and overwrites
6
+ * `<runDir>/unit-economics.json` with `source='prototype'` carrying
7
+ * measured (not predicted) numbers.
8
+ *
9
+ * This reconciler reads BOTH manifests from the same run (the preview
10
+ * remains in `<runDir>/unit-economics.preview.json` after the pre-render
11
+ * pass), computes the drift, and emits:
12
+ *
13
+ * - `<runDir>/reconciliation.report.json` — structured drift report
14
+ * - a drift warning header that can be prepended to executive docs
15
+ * when drift > 25% on the headline savings number
16
+ *
17
+ * The reconciler is strictly informational — it never blocks the pipeline.
18
+ */
19
+ export interface ReconciliationInput {
20
+ readonly runDir: string;
21
+ readonly runId: string;
22
+ }
23
+ export interface ReconciliationReport {
24
+ readonly run_id: string;
25
+ readonly generated_at: string;
26
+ readonly status: 'aligned' | 'drift' | 'missing-preview' | 'missing-prototype';
27
+ readonly drift_pct: number | null;
28
+ readonly tolerance_pct: number;
29
+ readonly preview: {
30
+ readonly annual_measured_savings_usd: number;
31
+ readonly annual_extrapolated_savings_usd: number;
32
+ } | null;
33
+ readonly prototype: {
34
+ readonly annual_measured_savings_usd: number;
35
+ readonly annual_extrapolated_savings_usd: number;
36
+ } | null;
37
+ readonly message: string;
38
+ }
39
+ export type ReconciliationOutcome = {
40
+ readonly status: 'wrote';
41
+ readonly reportPath: string;
42
+ readonly report: ReconciliationReport;
43
+ } | {
44
+ readonly status: 'skipped';
45
+ readonly reason: string;
46
+ };
47
+ export declare function executeReconciliation(input: ReconciliationInput): ReconciliationOutcome;
48
+ /**
49
+ * Produce a markdown warning header for inclusion at the top of affected
50
+ * executive documents. Returns null when no warning is needed.
51
+ */
52
+ export declare function formatDriftWarning(report: ReconciliationReport): string | null;
53
+ //# sourceMappingURL=post-render-reconciler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-render-reconciler.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/post-render-reconciler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;QAC7C,QAAQ,CAAC,+BAA+B,EAAE,MAAM,CAAC;KAClD,GAAG,IAAI,CAAC;IACT,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;QAC7C,QAAQ,CAAC,+BAA+B,EAAE,MAAM,CAAC;KAClD,GAAG,IAAI,CAAC;IACT,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAChG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAI5D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,qBAAqB,CAwBvF;AAsFD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAO9E"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §5 — Post-Render Reconciliation.
3
+ *
4
+ * After the coding agent generates the prototype and its demo runs, the
5
+ * real demo calls `writeUnitEconomics()` and overwrites
6
+ * `<runDir>/unit-economics.json` with `source='prototype'` carrying
7
+ * measured (not predicted) numbers.
8
+ *
9
+ * This reconciler reads BOTH manifests from the same run (the preview
10
+ * remains in `<runDir>/unit-economics.preview.json` after the pre-render
11
+ * pass), computes the drift, and emits:
12
+ *
13
+ * - `<runDir>/reconciliation.report.json` — structured drift report
14
+ * - a drift warning header that can be prepended to executive docs
15
+ * when drift > 25% on the headline savings number
16
+ *
17
+ * The reconciler is strictly informational — it never blocks the pipeline.
18
+ */
19
+ import * as fs from 'node:fs';
20
+ import * as path from 'node:path';
21
+ import { readManifestIfExists } from './pre-render-coordinator.js';
22
+ const DEFAULT_TOLERANCE_PCT = 25;
23
+ export function executeReconciliation(input) {
24
+ const previewPath = path.join(input.runDir, 'unit-economics.preview.json');
25
+ const manifestPath = path.join(input.runDir, 'unit-economics.json');
26
+ const preview = readManifestIfExists(previewPath);
27
+ const manifest = readManifestIfExists(manifestPath);
28
+ const report = buildReport({
29
+ runId: input.runId,
30
+ preview,
31
+ prototype: manifest && manifest.source === 'prototype' ? manifest : null,
32
+ });
33
+ try {
34
+ fs.mkdirSync(input.runDir, { recursive: true });
35
+ const reportPath = path.join(input.runDir, 'reconciliation.report.json');
36
+ fs.writeFileSync(reportPath, JSON.stringify(report, null, 2) + '\n', 'utf-8');
37
+ return { status: 'wrote', reportPath, report };
38
+ }
39
+ catch (err) {
40
+ return {
41
+ status: 'skipped',
42
+ reason: err instanceof Error ? err.message : String(err),
43
+ };
44
+ }
45
+ }
46
+ function buildReport(inputs) {
47
+ const now = new Date().toISOString();
48
+ if (!inputs.preview && !inputs.prototype) {
49
+ return {
50
+ run_id: inputs.runId,
51
+ generated_at: now,
52
+ status: 'missing-preview',
53
+ drift_pct: null,
54
+ tolerance_pct: DEFAULT_TOLERANCE_PCT,
55
+ preview: null,
56
+ prototype: null,
57
+ message: 'Neither a preview nor a prototype manifest was found — pipeline likely skipped the pre-render pass.',
58
+ };
59
+ }
60
+ if (!inputs.preview) {
61
+ return {
62
+ run_id: inputs.runId,
63
+ generated_at: now,
64
+ status: 'missing-preview',
65
+ drift_pct: null,
66
+ tolerance_pct: DEFAULT_TOLERANCE_PCT,
67
+ preview: null,
68
+ prototype: inputs.prototype
69
+ ? {
70
+ annual_measured_savings_usd: inputs.prototype.annual_measured_savings_usd,
71
+ annual_extrapolated_savings_usd: inputs.prototype.annual_extrapolated_savings_usd,
72
+ }
73
+ : null,
74
+ message: 'Prototype manifest found but no pre-render preview to compare against. Reconciliation skipped.',
75
+ };
76
+ }
77
+ if (!inputs.prototype) {
78
+ return {
79
+ run_id: inputs.runId,
80
+ generated_at: now,
81
+ status: 'missing-prototype',
82
+ drift_pct: null,
83
+ tolerance_pct: DEFAULT_TOLERANCE_PCT,
84
+ preview: {
85
+ annual_measured_savings_usd: inputs.preview.annual_measured_savings_usd,
86
+ annual_extrapolated_savings_usd: inputs.preview.annual_extrapolated_savings_usd,
87
+ },
88
+ prototype: null,
89
+ message: 'Preview manifest present but prototype demo did not produce a prototype-sourced manifest. Executive documents are operating on pre-render numbers only.',
90
+ };
91
+ }
92
+ const previewUsd = inputs.preview.annual_extrapolated_savings_usd;
93
+ const prototypeUsd = inputs.prototype.annual_extrapolated_savings_usd;
94
+ const base = Math.max(1, Math.max(previewUsd, prototypeUsd));
95
+ const driftPct = Math.round((Math.abs(previewUsd - prototypeUsd) / base) * 1000) / 10;
96
+ const status = driftPct > DEFAULT_TOLERANCE_PCT ? 'drift' : 'aligned';
97
+ const message = status === 'drift'
98
+ ? `Preview $${previewUsd.toLocaleString()} vs. prototype $${prototypeUsd.toLocaleString()} drifted ${driftPct.toFixed(1)}% (tolerance ±${DEFAULT_TOLERANCE_PCT}%). Executive documents were rendered from the preview — consider regenerating them from the prototype manifest.`
99
+ : `Preview and prototype manifests agree within ±${DEFAULT_TOLERANCE_PCT}%. Executive documents are consistent with measured prototype output.`;
100
+ return {
101
+ run_id: inputs.runId,
102
+ generated_at: now,
103
+ status,
104
+ drift_pct: driftPct,
105
+ tolerance_pct: DEFAULT_TOLERANCE_PCT,
106
+ preview: {
107
+ annual_measured_savings_usd: inputs.preview.annual_measured_savings_usd,
108
+ annual_extrapolated_savings_usd: inputs.preview.annual_extrapolated_savings_usd,
109
+ },
110
+ prototype: {
111
+ annual_measured_savings_usd: inputs.prototype.annual_measured_savings_usd,
112
+ annual_extrapolated_savings_usd: inputs.prototype.annual_extrapolated_savings_usd,
113
+ },
114
+ message,
115
+ };
116
+ }
117
+ /**
118
+ * Produce a markdown warning header for inclusion at the top of affected
119
+ * executive documents. Returns null when no warning is needed.
120
+ */
121
+ export function formatDriftWarning(report) {
122
+ if (report.status !== 'drift')
123
+ return null;
124
+ return [
125
+ '> ⚠️ **Preview/prototype drift** — ' + report.message,
126
+ '> See `reconciliation.report.json` for the full breakdown.',
127
+ '',
128
+ ].join('\n');
129
+ }
130
+ //# sourceMappingURL=post-render-reconciler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-render-reconciler.js","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/post-render-reconciler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AA4BnE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,UAAU,qBAAqB,CAAC,KAA0B;IAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAyB,WAAW,CAAC;QAC/C,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO;QACP,SAAS,EAAE,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;KACzE,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;QACzE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAA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EAAE,GAAG;QACjB,MAAM;QACN,SAAS,EAAE,QAAQ;QACnB,aAAa,EAAE,qBAAqB;QACpC,OAAO,EAAE;YACP,2BAA2B,EAAE,MAAM,CAAC,OAAO,CAAC,2BAA2B;YACvE,+BAA+B,EAAE,MAAM,CAAC,OAAO,CAAC,+BAA+B;SAChF;QACD,SAAS,EAAE;YACT,2BAA2B,EAAE,MAAM,CAAC,SAAS,CAAC,2BAA2B;YACzE,+BAA+B,EAAE,MAAM,CAAC,SAAS,CAAC,+BAA+B;SAClF;QACD,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA4B;IAC7D,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO;QACL,qCAAqC,GAAG,MAAM,CAAC,OAAO;QACtD,4DAA4D;QAC5D,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §1 — Pre-Render Analysis Pass coordinator.
3
+ *
4
+ * Orchestrates:
5
+ * 1. Classify sector from query + domain analysis
6
+ * 2. Compute bottom-up unit economics via `computePreRenderUnitEconomics`
7
+ * 3. Write `<runDir>/unit-economics.json` with `source='prototype-preview'`
8
+ *
9
+ * Runs BEFORE `renderExecutiveSummary`, `renderDecisionMemo`, and
10
+ * `renderFinancialAnalysis` so the ADR-066 tier-1 manifest path fires on
11
+ * every run.
12
+ *
13
+ * The module is purely additive: if it fails (unknown sector, I/O error,
14
+ * schema validation) the renderers fall back to ADR-066 tier-3 heuristic +
15
+ * mandatory warning banner — which is the exact behavior before this ADR.
16
+ * Never blocks the pipeline.
17
+ */
18
+ import type { DomainAnalysis } from '../../synthesis/simulation-renderers.js';
19
+ import { type UnitEconomics } from '../types.js';
20
+ import { type PreRenderFinancialOutput } from './financial-model.js';
21
+ export interface PreRenderInput {
22
+ readonly runDir: string;
23
+ readonly runId: string;
24
+ readonly query: string;
25
+ /** Scenario artifact (already built in simulation-artifact-generator). */
26
+ readonly scenarioArtifact?: Record<string, unknown> | null;
27
+ /** Domain analysis from ADR-PIPELINE-041 enrichment. */
28
+ readonly domainAnalysis?: DomainAnalysis | null;
29
+ }
30
+ export type PreRenderOutcome = {
31
+ readonly status: 'emitted';
32
+ readonly manifestPath: string;
33
+ readonly manifest: UnitEconomics;
34
+ readonly metrics: PreRenderFinancialOutput['metrics'];
35
+ } | {
36
+ readonly status: 'skipped';
37
+ readonly reason: 'unknown-sector' | 'schema-rejected' | 'io-error' | 'existing-prototype-manifest';
38
+ readonly detail?: string;
39
+ };
40
+ /**
41
+ * Run the pre-render pass. Never throws. Returns an `emitted` result on
42
+ * success or a `skipped` result with a reason when the pass can't produce
43
+ * a preview manifest.
44
+ */
45
+ export declare function executePreRender(input: PreRenderInput): PreRenderOutcome;
46
+ export declare function readManifestIfExists(manifestPath: string): UnitEconomics | null;
47
+ //# sourceMappingURL=pre-render-coordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-render-coordinator.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/pre-render-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,wDAAwD;IACxD,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;CACvD,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,UAAU,GAAG,6BAA6B,CAAC;IACnG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB,CAwDxE;AAeD,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAS/E"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §1 — Pre-Render Analysis Pass coordinator.
3
+ *
4
+ * Orchestrates:
5
+ * 1. Classify sector from query + domain analysis
6
+ * 2. Compute bottom-up unit economics via `computePreRenderUnitEconomics`
7
+ * 3. Write `<runDir>/unit-economics.json` with `source='prototype-preview'`
8
+ *
9
+ * Runs BEFORE `renderExecutiveSummary`, `renderDecisionMemo`, and
10
+ * `renderFinancialAnalysis` so the ADR-066 tier-1 manifest path fires on
11
+ * every run.
12
+ *
13
+ * The module is purely additive: if it fails (unknown sector, I/O error,
14
+ * schema validation) the renderers fall back to ADR-066 tier-3 heuristic +
15
+ * mandatory warning banner — which is the exact behavior before this ADR.
16
+ * Never blocks the pipeline.
17
+ */
18
+ import * as fs from 'node:fs';
19
+ import * as path from 'node:path';
20
+ import { UnitEconomicsSchema } from '../types.js';
21
+ import { computePreRenderUnitEconomics, } from './financial-model.js';
22
+ /**
23
+ * Run the pre-render pass. Never throws. Returns an `emitted` result on
24
+ * success or a `skipped` result with a reason when the pass can't produce
25
+ * a preview manifest.
26
+ */
27
+ export function executePreRender(input) {
28
+ const manifestPath = path.join(input.runDir, 'unit-economics.json');
29
+ // If a prototype-sourced manifest already exists at this path (e.g. the
30
+ // user re-ran the pipeline and an earlier prototype demo landed a real
31
+ // manifest in the same runDir), leave it alone. Pre-render never
32
+ // overwrites a real prototype manifest.
33
+ if (existingPrototypeManifest(manifestPath)) {
34
+ return {
35
+ status: 'skipped',
36
+ reason: 'existing-prototype-manifest',
37
+ detail: 'A prototype-sourced unit-economics.json already exists; pre-render left it untouched.',
38
+ };
39
+ }
40
+ const sectorHint = input.domainAnalysis?.domain ?? null;
41
+ const financial = computePreRenderUnitEconomics({
42
+ runId: input.runId,
43
+ query: input.query,
44
+ sectorHint,
45
+ });
46
+ if (!financial) {
47
+ return {
48
+ status: 'skipped',
49
+ reason: 'unknown-sector',
50
+ detail: 'classifySector returned "unknown" — no ADR-066 registry entry.',
51
+ };
52
+ }
53
+ const parsed = UnitEconomicsSchema.safeParse(financial.manifest);
54
+ if (!parsed.success) {
55
+ return {
56
+ status: 'skipped',
57
+ reason: 'schema-rejected',
58
+ detail: parsed.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('; '),
59
+ };
60
+ }
61
+ try {
62
+ fs.mkdirSync(input.runDir, { recursive: true });
63
+ fs.writeFileSync(manifestPath, JSON.stringify(parsed.data, null, 2) + '\n', 'utf-8');
64
+ }
65
+ catch (err) {
66
+ return {
67
+ status: 'skipped',
68
+ reason: 'io-error',
69
+ detail: err instanceof Error ? err.message : String(err),
70
+ };
71
+ }
72
+ return {
73
+ status: 'emitted',
74
+ manifestPath,
75
+ manifest: parsed.data,
76
+ metrics: financial.metrics,
77
+ };
78
+ }
79
+ function existingPrototypeManifest(manifestPath) {
80
+ if (!fs.existsSync(manifestPath))
81
+ return false;
82
+ try {
83
+ const raw = fs.readFileSync(manifestPath, 'utf-8');
84
+ const parsed = JSON.parse(raw);
85
+ return parsed['source'] === 'prototype';
86
+ }
87
+ catch {
88
+ // Corrupt file — pre-render will overwrite it
89
+ return false;
90
+ }
91
+ }
92
+ // Exported for tests + reconciler module.
93
+ export function readManifestIfExists(manifestPath) {
94
+ if (!fs.existsSync(manifestPath))
95
+ return null;
96
+ try {
97
+ const raw = fs.readFileSync(manifestPath, 'utf-8');
98
+ const parsed = UnitEconomicsSchema.safeParse(JSON.parse(raw));
99
+ return parsed.success ? parsed.data : null;
100
+ }
101
+ catch {
102
+ return null;
103
+ }
104
+ }
105
+ //# sourceMappingURL=pre-render-coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-render-coordinator.js","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/pre-render-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,6BAA6B,GAE9B,MAAM,sBAAsB,CAAC;AAyB9B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAEpE,wEAAwE;IACxE,uEAAuE;IACvE,iEAAiE;IACjE,wCAAwC;IACxC,IAAI,yBAAyB,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5C,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,6BAA6B;YACrC,MAAM,EAAE,uFAAuF;SAChG,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,EAAE,MAAM,IAAI,IAAI,CAAC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AM,EAAE,SAAS;QACjB,YAAY;QACZ,QAAQ,EAAE,MAAM,CAAC,IAAI;QACrB,OAAO,EAAE,SAAS,CAAC,OAAO;KAC3B,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,YAAoB;IACrD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC;QAC1D,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,8CAA8C;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §6: Sector baseline waste / unit-cost / achievable-reduction
3
+ * table. Consumed by the pre-render financial model to produce an initial
4
+ * `unit-economics.json` BEFORE the prototype runs, so the ADR-066 tier-1
5
+ * renderer path fires on the executive summary / decision memo / financial
6
+ * analysis instead of falling to the per-employee heuristic.
7
+ *
8
+ * Numbers are conservative industry rules-of-thumb. The prototype is expected
9
+ * to produce a more accurate manifest when its demo runs, and the ADR-072 §5
10
+ * reconciler emits a warning on any drift >25%.
11
+ *
12
+ * Every entry must correspond to an entry in the ADR-066 sector registry
13
+ * (`src/synthesis/domain-unit-registry.ts`). The integration test in
14
+ * `tests/unit/pipeline/pre-render/sector-baselines-072.test.ts` enforces the
15
+ * lockstep invariant.
16
+ */
17
+ import type { Sector } from '../../synthesis/domain-unit-registry.js';
18
+ export interface SectorBaseline {
19
+ /** Sector key — must match the ADR-066 registry. */
20
+ readonly sector: Exclude<Sector, 'unknown'>;
21
+ /** Human-readable label for the operational unit. */
22
+ readonly unitLabel: string;
23
+ /** Savings key (must match the registry's unitSavingsKey). */
24
+ readonly unitSavingsKey: string;
25
+ /** USD saved per operational unit per year, at baseline achievable reduction. */
26
+ readonly usdPerUnitPerYear: number;
27
+ /** Baseline waste rate (0..1) — what fraction of the unit cost is wasted today. */
28
+ readonly baselineWasteRate: number;
29
+ /** Achievable reduction (0..1) — what fraction of the waste can reasonably be eliminated. */
30
+ readonly achievableReduction: number;
31
+ /** Methodology string displayed in the rendered financial analysis. */
32
+ readonly methodology: string;
33
+ /** Short description of the unit cost basis (rooms × occupancy, etc.). */
34
+ readonly unitCostBasis: string;
35
+ }
36
+ /**
37
+ * ADR-PIPELINE-072 §6 — baseline table. Conservative industry rules-of-thumb.
38
+ * The prototype's measured numbers will overwrite these during the real demo.
39
+ */
40
+ export declare const SECTOR_BASELINES: readonly SectorBaseline[];
41
+ export declare function getSectorBaseline(sector: Sector): SectorBaseline | null;
42
+ //# sourceMappingURL=sector-baselines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sector-baselines.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/sector-baselines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,iFAAiF;IACjF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,mFAAmF;IACnF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,6FAA6F;IAC7F,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EA2FrD,CAAC;AAMF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAEvE"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * ADR-PIPELINE-072 §6: Sector baseline waste / unit-cost / achievable-reduction
3
+ * table. Consumed by the pre-render financial model to produce an initial
4
+ * `unit-economics.json` BEFORE the prototype runs, so the ADR-066 tier-1
5
+ * renderer path fires on the executive summary / decision memo / financial
6
+ * analysis instead of falling to the per-employee heuristic.
7
+ *
8
+ * Numbers are conservative industry rules-of-thumb. The prototype is expected
9
+ * to produce a more accurate manifest when its demo runs, and the ADR-072 §5
10
+ * reconciler emits a warning on any drift >25%.
11
+ *
12
+ * Every entry must correspond to an entry in the ADR-066 sector registry
13
+ * (`src/synthesis/domain-unit-registry.ts`). The integration test in
14
+ * `tests/unit/pipeline/pre-render/sector-baselines-072.test.ts` enforces the
15
+ * lockstep invariant.
16
+ */
17
+ /**
18
+ * ADR-PIPELINE-072 §6 — baseline table. Conservative industry rules-of-thumb.
19
+ * The prototype's measured numbers will overwrite these during the real demo.
20
+ */
21
+ export const SECTOR_BASELINES = [
22
+ {
23
+ sector: 'hospitality',
24
+ unitLabel: 'occupied room night',
25
+ unitSavingsKey: 'usd_per_orn',
26
+ usdPerUnitPerYear: 0.82,
27
+ baselineWasteRate: 0.32,
28
+ achievableReduction: 0.18,
29
+ methodology: 'rooms × occupancy × $/occupied-room-night linen + water reduction',
30
+ unitCostBasis: '0.32 kg linen/orn × $2.10/kg laundry',
31
+ },
32
+ {
33
+ sector: 'airline-catering',
34
+ unitLabel: 'meal loaded',
35
+ unitSavingsKey: 'usd_per_meal_loaded',
36
+ usdPerUnitPerYear: 0.92,
37
+ baselineWasteRate: 0.18,
38
+ achievableReduction: 0.22,
39
+ methodology: 'meals × flights × 365 × $/meal-loaded waste reduction',
40
+ unitCostBasis: '0.18 kg/meal × $4.20/meal loaded (loaded-to-consumed gap)',
41
+ },
42
+ {
43
+ sector: 'commercial-real-estate',
44
+ unitLabel: 'square foot-year',
45
+ unitSavingsKey: 'usd_per_sqft_year',
46
+ usdPerUnitPerYear: 0.25,
47
+ baselineWasteRate: 0.20,
48
+ achievableReduction: 0.15,
49
+ methodology: 'sqft × $/sqft-year energy + HVAC reduction',
50
+ unitCostBasis: '12 kWh/sqft-year × $0.14/kWh',
51
+ },
52
+ {
53
+ sector: 'fleet',
54
+ unitLabel: 'vehicle-mile',
55
+ unitSavingsKey: 'usd_per_vehicle_mile',
56
+ usdPerUnitPerYear: 0.28,
57
+ baselineWasteRate: 0.20,
58
+ achievableReduction: 0.12,
59
+ methodology: 'fleet × miles × $/mile fuel + maintenance reduction',
60
+ unitCostBasis: '0.65 gal/vehicle-mile × $3.80/gal',
61
+ },
62
+ {
63
+ sector: 'retail',
64
+ unitLabel: 'store-year',
65
+ unitSavingsKey: 'usd_per_transaction',
66
+ usdPerUnitPerYear: 14250,
67
+ baselineWasteRate: 0.30,
68
+ achievableReduction: 0.15,
69
+ methodology: 'stores × $95K/yr energy × achievable reduction',
70
+ unitCostBasis: '$95K/store/yr energy × 15% reduction ceiling',
71
+ },
72
+ {
73
+ sector: 'manufacturing',
74
+ unitLabel: 'unit produced',
75
+ unitSavingsKey: 'usd_per_unit_produced',
76
+ usdPerUnitPerYear: 0.85,
77
+ baselineWasteRate: 0.023,
78
+ achievableReduction: 0.25,
79
+ methodology: 'throughput × $/unit scrap reduction',
80
+ unitCostBasis: '2.3% scrap rate × $/unit',
81
+ },
82
+ {
83
+ sector: 'healthcare',
84
+ unitLabel: 'patient-day',
85
+ unitSavingsKey: 'usd_per_patient_day',
86
+ usdPerUnitPerYear: 0.22,
87
+ baselineWasteRate: 0.18,
88
+ achievableReduction: 0.20,
89
+ methodology: 'census × $/patient-day disposal + material reduction',
90
+ unitCostBasis: '0.8 kg waste/patient-day × $1.40/kg disposal',
91
+ },
92
+ {
93
+ sector: 'data-center',
94
+ unitLabel: 'kilowatt-hour',
95
+ unitSavingsKey: 'usd_per_kwh',
96
+ usdPerUnitPerYear: 0.018,
97
+ baselineWasteRate: 0.23,
98
+ achievableReduction: 0.18,
99
+ methodology: 'load × 8760 × $/kWh PUE optimization',
100
+ unitCostBasis: 'PUE 1.6 → 1.3 opportunity × $0.08/kWh',
101
+ },
102
+ {
103
+ sector: 'call-center',
104
+ unitLabel: 'contact minute',
105
+ unitSavingsKey: 'usd_per_contact_minute',
106
+ usdPerUnitPerYear: 0.09,
107
+ baselineWasteRate: 0.12,
108
+ achievableReduction: 0.14,
109
+ methodology: 'agents × shifts × $/contact-minute overstaffing reduction',
110
+ unitCostBasis: '12% overstaffing × $38/hr loaded',
111
+ },
112
+ ];
113
+ const BASELINE_BY_SECTOR = new Map(SECTOR_BASELINES.map(b => [b.sector, b]));
114
+ export function getSectorBaseline(sector) {
115
+ return BASELINE_BY_SECTOR.get(sector) ?? null;
116
+ }
117
+ //# sourceMappingURL=sector-baselines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sector-baselines.js","sourceRoot":"","sources":["../../../src/pipeline/phase4-5-pre-render/sector-baselines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuBH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD;QACE,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,qBAAqB;QAChC,cAAc,EAAE,aAAa;QAC7B,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,mEAAmE;QAChF,aAAa,EAAE,sCAAsC;KACtD;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,SAAS,EAAE,aAAa;QACxB,cAAc,EAAE,qBAAqB;QACrC,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,uDAAuD;QACpE,aAAa,EAAE,2DAA2D;KAC3E;IACD;QACE,MAAM,EAAE,wBAAwB;QAChC,SAAS,EAAE,kBAAkB;QAC7B,cAAc,EAAE,mBAAmB;QACnC,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,4CAA4C;QACzD,aAAa,EAAE,8BAA8B;KAC9C;IACD;QACE,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,cAAc;QACzB,cAAc,EAAE,sBAAsB;QACtC,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,qDAAqD;QAClE,aAAa,EAAE,mCAAmC;KACnD;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,cAAc,EAAE,qBAAqB;QACrC,iBAAiB,EAAE,KAAK;QACxB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,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,"file":"phase5-build-coordinator.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase5-build/phase5-build-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAgD,MAAM,YAAY,CAAC;AAsE9H,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,yBAAyB,CAAC,CAuSpC"}
1
+ {"version":3,"file":"phase5-build-coordinator.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase5-build/phase5-build-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAgD,MAAM,YAAY,CAAC;AAwE9H,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,yBAAyB,CAAC,CAkVpC"}
@@ -20,6 +20,7 @@ import { writePhase5BuildManifest } from './manifest-writer.js';
20
20
  import { inferIntegrations } from './phases/integration-inferrer.js';
21
21
  import { injectIntegrations } from './phases/integration-injector.js';
22
22
  import { generateFrontend } from './phases/frontend-generator.js';
23
+ import { executePostGenerationValidator } from './phases/post-generation-validator.js';
23
24
  const DIR_MODE = 0o700;
24
25
  /**
25
26
  * Recursively copy a directory tree.
@@ -73,6 +74,7 @@ const STAGES = [
73
74
  { id: 'integration-injection', label: 'Integration Injection' },
74
75
  { id: 'deployable-service', label: 'Deployable Service Generation' },
75
76
  { id: 'frontend-generation', label: 'Frontend Generation (Ruflo Swarm)' },
77
+ { id: 'post-generation-validation', label: 'Post-Generation Code Validation (ADR-PIPELINE-065)' },
76
78
  ];
77
79
  export async function executePhase5BuildPipeline(context) {
78
80
  const pipelineStart = Date.now();
@@ -324,6 +326,48 @@ export async function executePhase5BuildPipeline(context) {
324
326
  console.error(` Stage "${STAGES[5].label}" failed (non-blocking). Continuing pipeline.`);
325
327
  }
326
328
  console.error('');
329
+ // Stage 7: Post-Generation Code Validation (ADR-PIPELINE-065)
330
+ console.error(` >> [7/${STAGES.length}] ${STAGES[6].label}`);
331
+ const postgenSpan = createSpan('phase5-build-pipeline', 'post-generation-validation', {}, rootSpan.spanId);
332
+ const postgenStart = Date.now();
333
+ try {
334
+ const { stageOutput } = executePostGenerationValidator(context);
335
+ completedStages.push({
336
+ stage: 'post-generation-validation',
337
+ status: stageOutput.status,
338
+ timing: stageOutput.timing,
339
+ artifacts: stageOutput.artifacts,
340
+ summary: stageOutput.summary,
341
+ });
342
+ const finalPostgenSpan = endSpan(postgenSpan, stageOutput.status === 'completed' ? 'ok' : 'error', {
343
+ errorCount: stageOutput.data.errorCount,
344
+ warnCount: stageOutput.data.warnCount,
345
+ score: stageOutput.data.score,
346
+ });
347
+ emitSpan(finalPostgenSpan);
348
+ context.telemetrySpans.push(finalPostgenSpan);
349
+ console.error(stageOutput.summary);
350
+ if (stageOutput.status === 'failed') {
351
+ // Strict mode only: block the pipeline when AGENTICS_STRICT_POSTGEN=true
352
+ if (process.env['AGENTICS_STRICT_POSTGEN'] === 'true') {
353
+ writeSpans(context.telemetrySpans, context.phase5Dir);
354
+ return buildFailResult(context, completedStages, pipelineStart);
355
+ }
356
+ // Otherwise advisory — the validator already logged findings
357
+ console.error(` Stage "${STAGES[6].label}" reported errors (non-blocking; set AGENTICS_STRICT_POSTGEN=true to enforce).`);
358
+ }
359
+ }
360
+ catch (err) {
361
+ const errMsg = err instanceof Error ? err.message : String(err);
362
+ completedStages.push({ stage: 'post-generation-validation', status: 'failed', timing: Date.now() - postgenStart, artifacts: [], summary: ` ERROR: ${errMsg}` });
363
+ const failSpan = endSpan(postgenSpan, 'error');
364
+ context.telemetrySpans.push(failSpan);
365
+ // Post-generation validation is non-blocking on internal errors — we never
366
+ // want a validator bug to block the pipeline. Strict mode only applies to
367
+ // actual rule violations, not to validator crashes.
368
+ console.error(` Stage "${STAGES[6].label}" failed (non-blocking). Continuing pipeline.`);
369
+ }
370
+ console.error('');
327
371
  // Write manifest
328
372
  console.error(' Writing phase5-manifest.json...');
329
373
  const implLang = codegenResult?.manifest.implementation_language ?? 'typescript';