1414jest . mock ( '@bitcode/generic-llms' , ( ) =>
1515 require ( './support/generic-llms-mock' ) . makeGenericLLMsMock ( ) ) ;
1616
17- import { registerDiscoveryAgents } from '../phases/discovery' ;
17+ import {
18+ registerDiscoveryAgents ,
19+ DISCOVERY_COMPREHEND_CODEBASE ,
20+ DISCOVERY_INHERENT_REGURGITATION ,
21+ DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ,
22+ DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ,
23+ } from '../phases/discovery' ;
1824import { registerImplementationAgents } from '../phases/implementation' ;
1925import { registerValidationAgentsForType } from '../phases/validation' ;
2026import { registerFinishAgentsForType } from '../phases/finish' ;
@@ -33,6 +39,7 @@ import {
3339
3440import depositCodebaseComprehensionAgent from '../agents/discovery/deposit-codebase-comprehension-agent' ;
3541import depositDepositorySearchAgent from '../agents/discovery/deposit-depository-search-agent' ;
42+ import readDepositorySearchForNeedFitsAgent from '../agents/discovery/read-depository-search-for-need-fits-agent' ;
3643import depositInherentRegurgitationAgent from '../agents/discovery/deposit-inherent-regurgitation-agent' ;
3744import depositAssetPackSynthesisAgent from '../agents/implementation/deposit-asset-pack-synthesis-agent' ;
3845import readAssetPackSynthesisAgent from '../agents/implementation/read-asset-pack-synthesis-agent' ;
@@ -66,39 +73,50 @@ async function resolveEntry(entry: any) {
6673}
6774
6875describe ( 'per-mode agent rosters (conditional runtime registries)' , ( ) => {
69- it ( 'deposit discovery registers exactly the three deposit agents ' , async ( ) => {
76+ it ( 'deposit discovery registers wave-1 agents + deposit-relevants search ' , async ( ) => {
7077 const registry = fakeRegistry ( ) ;
7178 registerDiscoveryAgents ( registry , 'deposit' ) ;
7279
7380 expect ( Array . from ( registry . entries . keys ( ) ) ) . toEqual ( [
74- 'discovery:comprehend-codebase' ,
75- 'discovery:search-depository' ,
76- 'discovery:inherent-regurgitation' ,
81+ DISCOVERY_COMPREHEND_CODEBASE ,
82+ DISCOVERY_INHERENT_REGURGITATION ,
83+ DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ,
7784 ] ) ;
78- expect ( await resolveEntry ( registry . entries . get ( 'discovery:comprehend-codebase' ) ) ) . toBe (
85+ expect ( await resolveEntry ( registry . entries . get ( DISCOVERY_COMPREHEND_CODEBASE ) ) ) . toBe (
7986 depositCodebaseComprehensionAgent ,
8087 ) ;
81- expect ( await resolveEntry ( registry . entries . get ( 'discovery:search-depository' ) ) ) . toBe (
82- depositDepositorySearchAgent ,
83- ) ;
84- expect ( await resolveEntry ( registry . entries . get ( 'discovery:inherent-regurgitation' ) ) ) . toBe (
88+ expect (
89+ await resolveEntry ( registry . entries . get ( DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ) ) ,
90+ ) . toBe ( depositDepositorySearchAgent ) ;
91+ expect ( await resolveEntry ( registry . entries . get ( DISCOVERY_INHERENT_REGURGITATION ) ) ) . toBe (
8592 depositInherentRegurgitationAgent ,
8693 ) ;
8794 } ) ;
8895
89- it . each ( [ [ 'read' ] , [ undefined ] , [ 'deposit' ] ] ) (
90- 'discovery (mode=%s) always registers the product three-agent roster' ,
91- ( mode ) => {
92- const registry = fakeRegistry ( ) ;
93- registerDiscoveryAgents ( registry , mode ) ;
96+ it ( 'read discovery registers wave-1 agents + read-need-fits search' , async ( ) => {
97+ const registry = fakeRegistry ( ) ;
98+ registerDiscoveryAgents ( registry , 'read' ) ;
9499
95- expect ( Array . from ( registry . entries . keys ( ) ) ) . toEqual ( [
96- 'discovery:comprehend-codebase' ,
97- 'discovery:search-depository' ,
98- 'discovery:inherent-regurgitation' ,
99- ] ) ;
100- } ,
101- ) ;
100+ expect ( Array . from ( registry . entries . keys ( ) ) ) . toEqual ( [
101+ DISCOVERY_COMPREHEND_CODEBASE ,
102+ DISCOVERY_INHERENT_REGURGITATION ,
103+ DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ,
104+ ] ) ;
105+ expect (
106+ await resolveEntry ( registry . entries . get ( DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ) ) ,
107+ ) . toBe ( readDepositorySearchForNeedFitsAgent ) ;
108+ } ) ;
109+
110+ it ( 'default (non-read) discovery registers deposit-relevants search' , ( ) => {
111+ const registry = fakeRegistry ( ) ;
112+ registerDiscoveryAgents ( registry , undefined ) ;
113+ expect ( Array . from ( registry . entries . keys ( ) ) ) . toContain (
114+ DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ,
115+ ) ;
116+ expect ( Array . from ( registry . entries . keys ( ) ) ) . not . toContain (
117+ DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ,
118+ ) ;
119+ } ) ;
102120
103121 it ( 'implementation registers deposit-named vs read synthesis keys by mode' , async ( ) => {
104122 const depositKey = 'implementation:deposit-asset-pack-synthesis' ;
@@ -220,9 +238,14 @@ function harness(keys: string[]) {
220238}
221239
222240const DEPOSIT_DISCOVERY_KEYS = [
223- 'discovery:comprehend-codebase' ,
224- 'discovery:search-depository' ,
225- 'discovery:inherent-regurgitation' ,
241+ DISCOVERY_COMPREHEND_CODEBASE ,
242+ DISCOVERY_INHERENT_REGURGITATION ,
243+ DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ,
244+ ] ;
245+ const READ_DISCOVERY_KEYS = [
246+ DISCOVERY_COMPREHEND_CODEBASE ,
247+ DISCOVERY_INHERENT_REGURGITATION ,
248+ DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ,
226249] ;
227250const DEPOSIT_IMPLEMENTATION_KEY = 'implementation:deposit-asset-pack-synthesis' ;
228251const DEPOSIT_VALIDATION_KEY =
@@ -241,23 +264,30 @@ const READ_FINISH_KEYS = [
241264] ;
242265
243266describe ( 'product phase delegators execute the roster (execution-tree walk)' , ( ) => {
244- it ( 'deposit discovery runs comprehend-codebase ∥ search-depository ∥ inherent-regurgitation ' , async ( ) => {
267+ it ( 'deposit discovery: parallel( comprehend, regurgitation) then deposit-relevants search ' , async ( ) => {
245268 const { calls, root } = harness ( DEPOSIT_DISCOVERY_KEYS ) ;
246269 const phaseExec = root . child ( 'seq-2' ) ;
247270
248271 await depositDiscoveryPhase ( { seed : true } , phaseExec ) ;
249272
250- // Parallel — assert set equality, not order.
251- expect ( new Set ( calls ) ) . toEqual ( new Set ( DEPOSIT_DISCOVERY_KEYS ) ) ;
252273 expect ( calls ) . toHaveLength ( 3 ) ;
274+ // Wave 1 (either order) then wave 2 search last.
275+ expect ( new Set ( calls . slice ( 0 , 2 ) ) ) . toEqual (
276+ new Set ( [ DISCOVERY_COMPREHEND_CODEBASE , DISCOVERY_INHERENT_REGURGITATION ] ) ,
277+ ) ;
278+ expect ( calls [ 2 ] ) . toBe ( DISCOVERY_SEARCH_DEPOSITORY_FOR_DEPOSIT_RELEVANTS ) ;
253279 } ) ;
254280
255- it ( 'read discovery reuses the three deposit discovery agent keys in parallel ' , async ( ) => {
256- const { calls, root } = harness ( DEPOSIT_DISCOVERY_KEYS ) ;
281+ it ( 'read discovery: parallel(comprehend, regurgitation) then read-need-fits search ' , async ( ) => {
282+ const { calls, root } = harness ( READ_DISCOVERY_KEYS ) ;
257283
258284 await readDiscoveryPhase ( { seed : true } , root . child ( 'seq-2' ) ) ;
259285
260- expect ( new Set ( calls ) ) . toEqual ( new Set ( DEPOSIT_DISCOVERY_KEYS ) ) ;
286+ expect ( calls ) . toHaveLength ( 3 ) ;
287+ expect ( new Set ( calls . slice ( 0 , 2 ) ) ) . toEqual (
288+ new Set ( [ DISCOVERY_COMPREHEND_CODEBASE , DISCOVERY_INHERENT_REGURGITATION ] ) ,
289+ ) ;
290+ expect ( calls [ 2 ] ) . toBe ( DISCOVERY_SEARCH_DEPOSITORY_FOR_READ_NEED_FITS ) ;
261291 } ) ;
262292
263293 it ( 'deposit implementation resolves deposit-asset-pack-synthesis' , async ( ) => {
0 commit comments