|
| 1 | +// @ts-nocheck |
| 2 | +/** |
| 3 | + * Deposit SDIVF pipeline integration (V48 Gate 3 — P0 CI confidence). |
| 4 | + * |
| 5 | + * Under NODE_ENV=test the five phase runtimes are no-ops by default. This suite |
| 6 | + * opts into the real phase runtimes via BITCODE_ENABLE_ASSET_PACK_SDIVF_RUNTIME_IN_TEST |
| 7 | + * and runs the full deposit lens with boundary-mocked LLMs only — never real |
| 8 | + * provider inference. Pins: |
| 9 | + * - Setup → Discovery → Implementation → Validation → Finish all execute |
| 10 | + * - implementation:options is produced on the shared execution |
| 11 | + * - Validation attaches formal absolutes (deterministic measure path) |
| 12 | + * - Finish records the upload-for-review artifact |
| 13 | + * |
| 14 | + * Clone/MCP setup agents that need live VCS are stubbed so the suite stays offline. |
| 15 | + */ |
| 16 | +jest.mock('@bitcode/generic-llms', () => |
| 17 | + require('./support/generic-llms-mock').makeGenericLLMsMock()); |
| 18 | + |
| 19 | +jest.mock('../agents/setup/asset-pack-clone-vcs-repository-agent', () => ({ |
| 20 | + __esModule: true, |
| 21 | + default: jest.fn().mockResolvedValue({ |
| 22 | + success: true, |
| 23 | + repository: { |
| 24 | + owner: 'engineeredsoftware', |
| 25 | + name: 'ENGI', |
| 26 | + fullName: 'engineeredsoftware/ENGI', |
| 27 | + branch: 'main', |
| 28 | + }, |
| 29 | + }), |
| 30 | +})); |
| 31 | + |
| 32 | +jest.mock('../agents/setup/asset-pack-initialize-mcps-tools-agent', () => ({ |
| 33 | + __esModule: true, |
| 34 | + default: jest.fn().mockResolvedValue({ success: true }), |
| 35 | +})); |
| 36 | + |
| 37 | +import { Execution } from '@bitcode/execution-generics'; |
| 38 | +import { |
| 39 | + setBoundaryLLMOutput, |
| 40 | + resetBoundaryLLMOutput, |
| 41 | + resetBoundaryLLMCalls, |
| 42 | +} from './support/generic-llms-mock'; |
| 43 | +import { synthesizeAssetPacksPipeline } from '../index'; |
| 44 | +import { validateDepositSynthesisOptions } from '../asset-packs-synthesis'; |
| 45 | + |
| 46 | +const INVENTORY = { |
| 47 | + paths: ['src/auth/session.ts', 'src/auth/token.ts', 'src/billing/invoice.ts'], |
| 48 | + samples: [ |
| 49 | + { |
| 50 | + path: 'src/auth/session.ts', |
| 51 | + excerpt: 'export function createSession() { return { id: 1 }; }', |
| 52 | + }, |
| 53 | + ], |
| 54 | + totalPathCount: 3, |
| 55 | + excludedPathCount: 0, |
| 56 | +}; |
| 57 | + |
| 58 | +/** One boundary response that satisfies every deposit agent schema (non-strict). */ |
| 59 | +const DEPOSIT_SDIVF_BOUNDARY_OUTPUT = { |
| 60 | + // Setup + discovery:comprehension-shaped agents |
| 61 | + comprehension: { |
| 62 | + summary: 'Auth and billing capabilities with clear module boundaries.', |
| 63 | + obfuscatedPaths: [], |
| 64 | + obfuscatedConcepts: [], |
| 65 | + honorNotes: [], |
| 66 | + capabilities: ['session auth', 'token refresh', 'invoicing'], |
| 67 | + knowledgeAreas: ['authentication', 'billing'], |
| 68 | + notableModules: ['src/auth/session.ts', 'src/billing/invoice.ts'], |
| 69 | + }, |
| 70 | + // Discovery depository-search |
| 71 | + guidance: { |
| 72 | + summary: 'Readers seek reusable auth and billing slices.', |
| 73 | + likelyReadTopics: ['authentication', 'billing'], |
| 74 | + demandAlignment: ['session auth'], |
| 75 | + underservedTopics: ['token refresh patterns'], |
| 76 | + readabilityNotes: ['Keep paths source-safe.'], |
| 77 | + }, |
| 78 | + // Discovery inherent-regurgitation |
| 79 | + regurgitation: { |
| 80 | + summary: 'Known session/token patterns and invoice domain practices.', |
| 81 | + relevantKnowledge: ['JWT refresh rotation', 'idempotent invoicing'], |
| 82 | + patterns: ['capability-slice packaging'], |
| 83 | + references: ['industry auth handbooks'], |
| 84 | + }, |
| 85 | + // Implementation synthesis |
| 86 | + options: [ |
| 87 | + { |
| 88 | + kind: 'capability-slice', |
| 89 | + title: 'Auth session capability slice', |
| 90 | + summary: |
| 91 | + 'A bounded source-safe authentication capability covering session creation and token refresh for reusable deposit supply.', |
| 92 | + coveredSourcePaths: ['src/auth/session.ts', 'src/auth/token.ts'], |
| 93 | + measurements: {}, |
| 94 | + measurementRationale: '', |
| 95 | + confidence: 0.82, |
| 96 | + patch: { |
| 97 | + fileChanges: [ |
| 98 | + { path: 'src/auth/session.ts', op: 'modify' }, |
| 99 | + { path: 'src/auth/token.ts', op: 'create' }, |
| 100 | + ], |
| 101 | + patchSummary: 'Encodes session and token refresh capability as deposit supply.', |
| 102 | + }, |
| 103 | + needinessSignal: { |
| 104 | + demand: 0.7, |
| 105 | + saturation: 0.3, |
| 106 | + rationale: 'Auth knowledge is frequently read across the network.', |
| 107 | + }, |
| 108 | + }, |
| 109 | + ], |
| 110 | + // Deposit validation |
| 111 | + issues: [], |
| 112 | + qualityScore: 0.88, |
| 113 | + coverageGaps: [], |
| 114 | + recommendation: 'complete', |
| 115 | + // ReadyToFinish |
| 116 | + ready: true, |
| 117 | + assessment: { |
| 118 | + productionReady: true, |
| 119 | + qualityLevel: 'good', |
| 120 | + riskLevel: 'low', |
| 121 | + recommendation: 'Finish and upload for depositor review.', |
| 122 | + }, |
| 123 | + criticalIssues: [], |
| 124 | + warnings: [], |
| 125 | + suggestions: [], |
| 126 | + metrics: { |
| 127 | + overallScore: 0.88, |
| 128 | + validationScore: 0.9, |
| 129 | + qualityScore: 0.88, |
| 130 | + readinessScore: 0.9, |
| 131 | + }, |
| 132 | +}; |
| 133 | + |
| 134 | +describe('deposit SDIVF pipeline integration (boundary-mocked LLMs)', () => { |
| 135 | + const previousSdivf = process.env.BITCODE_ENABLE_ASSET_PACK_SDIVF_RUNTIME_IN_TEST; |
| 136 | + const previousInference = process.env.BITCODE_ASSET_PACK_REAL_INFERENCE; |
| 137 | + |
| 138 | + beforeAll(() => { |
| 139 | + process.env.BITCODE_ENABLE_ASSET_PACK_SDIVF_RUNTIME_IN_TEST = '1'; |
| 140 | + // Deterministic absolutes (Tool path); quality volumes stay report-derived. |
| 141 | + delete process.env.BITCODE_ASSET_PACK_REAL_INFERENCE; |
| 142 | + }); |
| 143 | + |
| 144 | + afterAll(() => { |
| 145 | + if (previousSdivf === undefined) { |
| 146 | + delete process.env.BITCODE_ENABLE_ASSET_PACK_SDIVF_RUNTIME_IN_TEST; |
| 147 | + } else { |
| 148 | + process.env.BITCODE_ENABLE_ASSET_PACK_SDIVF_RUNTIME_IN_TEST = previousSdivf; |
| 149 | + } |
| 150 | + if (previousInference === undefined) { |
| 151 | + delete process.env.BITCODE_ASSET_PACK_REAL_INFERENCE; |
| 152 | + } else { |
| 153 | + process.env.BITCODE_ASSET_PACK_REAL_INFERENCE = previousInference; |
| 154 | + } |
| 155 | + }); |
| 156 | + |
| 157 | + beforeEach(() => { |
| 158 | + resetBoundaryLLMOutput(); |
| 159 | + resetBoundaryLLMCalls(); |
| 160 | + setBoundaryLLMOutput(DEPOSIT_SDIVF_BOUNDARY_OUTPUT); |
| 161 | + }); |
| 162 | + |
| 163 | + it( |
| 164 | + 'runs all five deposit SDIVF phases and leaves measured options + finish upload on the shared execution', |
| 165 | + async () => { |
| 166 | + const execution = new Execution('deposit-sdivf-integration'); |
| 167 | + |
| 168 | + await synthesizeAssetPacksPipeline( |
| 169 | + { |
| 170 | + mode: 'deposit', |
| 171 | + synthesizeMode: 'deposit', |
| 172 | + repositoryFullName: 'engineeredsoftware/ENGI', |
| 173 | + sourceBranch: 'main', |
| 174 | + sourceCommit: '31bbc0c5227b6b3aed5d107fd8507d35ec22970a', |
| 175 | + repository: { |
| 176 | + owner: 'engineeredsoftware', |
| 177 | + name: 'ENGI', |
| 178 | + repo: 'ENGI', |
| 179 | + branch: 'main', |
| 180 | + commit: '31bbc0c5227b6b3aed5d107fd8507d35ec22970a', |
| 181 | + fullName: 'engineeredsoftware/ENGI', |
| 182 | + url: 'https://github.com/engineeredsoftware/ENGI', |
| 183 | + }, |
| 184 | + obfuscations: 'Withhold secret signing internals.', |
| 185 | + protectedIpExclusions: [], |
| 186 | + demandContext: ['authentication'], |
| 187 | + inventory: INVENTORY, |
| 188 | + candidateKinds: [ |
| 189 | + 'capability-slice', |
| 190 | + 'implementation-pattern', |
| 191 | + 'proof-operations-slice', |
| 192 | + ], |
| 193 | + }, |
| 194 | + execution, |
| 195 | + ); |
| 196 | + |
| 197 | + const options = |
| 198 | + execution.get('implementation', 'options') ?? |
| 199 | + execution.findUp('implementation', 'options'); |
| 200 | + expect(Array.isArray(options)).toBe(true); |
| 201 | + expect(options.length).toBeGreaterThanOrEqual(1); |
| 202 | + expect(options[0].title).toMatch(/auth/i); |
| 203 | + expect(options[0].patch?.fileChanges?.length).toBeGreaterThan(0); |
| 204 | + |
| 205 | + // Validation measure-agent attaches formal absolutes in place. |
| 206 | + expect(Array.isArray(options[0].absolutes)).toBe(true); |
| 207 | + expect(options[0].absolutes.length).toBeGreaterThan(0); |
| 208 | + expect( |
| 209 | + options[0].absolutes.some((m) => m.measurementKind === 'function-count'), |
| 210 | + ).toBe(true); |
| 211 | + |
| 212 | + // Product projection must accept formal absolutes (no placeholder fallback). |
| 213 | + const validated = validateDepositSynthesisOptions(options, { |
| 214 | + lens: 'deposit', |
| 215 | + inventoryPaths: INVENTORY.paths, |
| 216 | + protectedIpExclusions: [], |
| 217 | + candidateKinds: [ |
| 218 | + 'capability-slice', |
| 219 | + 'implementation-pattern', |
| 220 | + 'proof-operations-slice', |
| 221 | + ], |
| 222 | + }); |
| 223 | + expect(validated.candidates.length).toBeGreaterThanOrEqual(1); |
| 224 | + expect( |
| 225 | + validated.candidates[0].measurements.map((m) => m.measurementKind), |
| 226 | + ).not.toContain('source-coverage'); |
| 227 | + |
| 228 | + const upload = |
| 229 | + execution.get('finish', 'uploadForReview') ?? |
| 230 | + execution.findUp('finish', 'uploadForReview'); |
| 231 | + expect(upload?.success).toBe(true); |
| 232 | + expect(upload?.deliveryMechanism).toBe('bitcode-review-upload'); |
| 233 | + expect(upload?.review?.surface).toBe('/deposits'); |
| 234 | + }, |
| 235 | + 180000, |
| 236 | + ); |
| 237 | +}); |
0 commit comments