Skip to content

Commit 427e82c

Browse files
V48 (implementation-only): Align deposit SDIVF prompts to sourceCheckoutCatalog and A/B/C ready-to-finish
Rewrite Setup/Discovery/Implementation/Validation PTRR identities and step parts to the accepted deposit algorithm: sourceCheckoutCatalog (not inventory), AssetPack as patch + measurements + metadata (host attaches absolutes), Validation as single A/B/C ready-to-finish gate, no lens/Fits Finding framing. Update prompt contracts and related agent tests; fix jest mapper for doc-comment-generics.
1 parent 2690c03 commit 427e82c

17 files changed

Lines changed: 344 additions & 214 deletions

packages/asset-packs-pipelines/domain/jest.config.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ module.exports = {
6868
'^@bitcode/generic-tools/use-computer/(.*)$': '<rootDir>/../../generic-tools/use-computer/src/$1',
6969
'^@bitcode/registry$': '<rootDir>/../../registry/src/index.ts',
7070
'^@bitcode/registry/(.*)$': '<rootDir>/../../registry/src/$1',
71-
'^@bitcode/doc-comment-generics$': '<rootDir>/../../doc-comment/src/index.ts',
72-
'^@bitcode/doc-comment-generics/(.*)$': '<rootDir>/../../doc-comment/src/$1',
71+
'^@bitcode/doc-comment-generics$': '<rootDir>/../../doc-comment-generics/src/index.ts',
72+
'^@bitcode/doc-comment-generics/(.*)$': '<rootDir>/../../doc-comment-generics/src/$1',
7373
'^@bitcode/btd/(.*)$': '<rootDir>/../../btd/src/$1.ts',
7474
'^@bitcode/btd$': '<rootDir>/../../btd/src/index.ts',
7575
},

packages/asset-packs-pipelines/domain/src/__tests__/deposit-agent-prompt-contracts.test.ts

Lines changed: 85 additions & 51 deletions
Large diffs are not rendered by default.

packages/asset-packs-pipelines/domain/src/__tests__/deposit-agent-store-contract.test.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,17 @@ describe('deposit agent context/store contract', () => {
198198
discoveryExec,
199199
);
200200
expect(result.success).toBe(true);
201-
expect(result.guidance).toEqual(guidance);
201+
// Host may enrich with searchQueries / tool underservedTopics; core fields preserved.
202+
expect(result.guidance.summary).toBe(guidance.summary);
203+
expect(result.guidance.likelyReadTopics).toEqual(guidance.likelyReadTopics);
204+
expect(result.guidance.underservedTopics).toEqual(
205+
expect.arrayContaining(['token refresh']),
206+
);
202207
// Stored on the SHARED execution (cross-phase law).
203-
expect(shared.get('discovery', 'depositorySearch')).toEqual(guidance);
204-
expect(shared.child('seq-2').findUp('discovery', 'depositorySearch')).toEqual(guidance);
208+
expect(shared.get('discovery', 'depositorySearch').summary).toBe(guidance.summary);
209+
expect(shared.child('seq-2').findUp('discovery', 'depositorySearch').summary).toBe(
210+
guidance.summary,
211+
);
205212
}, 60000);
206213

207214
it('inherent regurgitation stores discovery:inherentRegurgitation (the key the synthesis agent reads)', async () => {
@@ -259,25 +266,42 @@ describe('deposit agent context/store contract', () => {
259266

260267
expect(result.success).toBe(true);
261268
expect(result.semanticKind).toBe('asset-pack-written-asset');
262-
expect(result.options).toEqual(options);
263-
expect(result.summary).toBe('Synthesized 2 measured deposit AssetPack patch(es).');
269+
// AssetPack = patch + measurements + metadata: host attaches absolutes after PTRR.
270+
expect(result.options).toHaveLength(2);
271+
for (const opt of result.options) {
272+
expect(opt).toMatchObject({
273+
kind: expect.any(String),
274+
title: expect.any(String),
275+
patch: expect.objectContaining({
276+
fileChanges: expect.any(Array),
277+
patchSummary: expect.any(String),
278+
}),
279+
});
280+
expect(Array.isArray(opt.absolutes)).toBe(true);
281+
expect(opt.absolutes.length).toBeGreaterThan(0);
282+
}
283+
expect(result.summary).toBe(
284+
'Synthesized 2 measured deposit AssetPack(s) (patch + measurements + metadata).',
285+
);
264286
expect(result.assetPack).toEqual({ repository: REPOSITORY });
265287

266288
// implementation:options — the store the /deposits route's completion read
267289
// and the deposit validation agent consume; implementation:assetPacks — the
268290
// SAME array. Stored on the SHARED execution (cross-phase law): the route
269291
// holds the root, so its `execution.get('implementation','options')`
270292
// completion read (route.ts) resolves DIRECTLY.
271-
expect(shared.get('implementation', 'options')).toEqual(options);
272-
expect(shared.get('implementation', 'assetPacks')).toEqual(options);
293+
expect(shared.get('implementation', 'options')).toBe(result.options);
294+
expect(shared.get('implementation', 'assetPacks')).toBe(result.options);
273295
expect(shared.get('implementation', 'options')).toBe(shared.get('implementation', 'assetPacks'));
274296
// implementation:assetPack + implementation:summary — the stores Finish reads,
275297
// resolvable from the Finish sibling via the upward walk.
276298
expect(shared.get('implementation', 'assetPack')).toEqual({ repository: REPOSITORY });
277299
expect(shared.get('implementation', 'summary')).toBe(
278-
'Synthesized 2 measured deposit AssetPack patch(es).',
300+
'Synthesized 2 measured deposit AssetPack(s) (patch + measurements + metadata).',
301+
);
302+
expect(shared.child('seq-3').child('seq-0').findUp('implementation', 'options')).toBe(
303+
result.options,
279304
);
280-
expect(shared.child('seq-3').child('seq-0').findUp('implementation', 'options')).toEqual(options);
281305
}, 60000);
282306

283307
it('threads cross-phase stores written on the SHARED parent into the synthesis generation context (F20 law)', async () => {

packages/asset-packs-pipelines/domain/src/__tests__/deposit-asset-pack-synthesis-agent.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ describe('runDepositAssetPackSynthesisAgent (boundary-mocked PTRR)', () => {
7474

7575
expect(out.success).toBe(true);
7676
expect(out.semanticKind).toBe('asset-pack-written-asset');
77-
expect(out.summary).toBe('Synthesized 2 measured deposit AssetPack patch(es).');
77+
expect(out.summary).toBe(
78+
'Synthesized 2 measured deposit AssetPack(s) (patch + measurements + metadata).',
79+
);
7880
expect(Array.isArray(out.options)).toBe(true);
7981
expect(out.options.length).toBeGreaterThanOrEqual(1);
8082
expect(out.options.length).toBeLessThanOrEqual(4);
@@ -123,7 +125,7 @@ describe('runDepositAssetPackSynthesisAgent (boundary-mocked PTRR)', () => {
123125
expect(assetPacks).toBe(options); // the SAME array under both keys
124126
expect(exec.get('implementation', 'assetPack')).toEqual(out.assetPack);
125127
expect(exec.get('implementation', 'summary')).toBe(
126-
'Synthesized 2 measured deposit AssetPack patch(es).',
128+
'Synthesized 2 measured deposit AssetPack(s) (patch + measurements + metadata).',
127129
);
128130
}, 120000);
129131

packages/asset-packs-pipelines/domain/src/__tests__/deposit-ready-to-finish-agent.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/**
22
* @jest-environment node
3+
*
4+
* Lightweight unit tests for the single deposit Validation ready-to-finish gate.
5+
* Heavy PTRR / measure / catalog graph is mocked so A/B/C merge logic is isolated.
36
*/
47
jest.mock('../agents/validation/agent-measure-absolutes', () => ({
58
measureAssetPackAbsolutes: jest.fn(async () => [
@@ -15,6 +18,13 @@ jest.mock('../agents/validation/agent-measure-absolutes', () => ({
1518
]),
1619
}));
1720

21+
jest.mock('../asset-packs-synthesis', () => ({
22+
ASSET_PACK_ABSOLUTES_CATALOG: [
23+
{ measurementKind: 'function-count', label: 'Functions', weight: 0.12 },
24+
],
25+
projectInventoryForPrompt: (catalog: unknown) => catalog,
26+
}));
27+
1828
jest.mock('@bitcode/agent-generics', () => ({
1929
factoryPTRRAgent: () =>
2030
async function mockPtrr() {

packages/asset-packs-pipelines/domain/src/__tests__/deposit-setup-discovery-agents.test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ describe('deposit Discovery lens agents (boundary-mocked PTRR)', () => {
178178
const out = await runDepositDepositorySearchAgent(DEPOSIT_INPUT, exec);
179179

180180
expect(out.success).toBe(true);
181-
expect(out.guidance).toEqual(MOCK_DEPOSITORY_GUIDANCE);
182-
expect(out.guidance.underservedTopics).toEqual(['idempotent invoice replay']);
181+
// Host enriches guidance with searchQueries and may merge tool underservedTopics.
182+
expect(out.guidance.summary).toBe(MOCK_DEPOSITORY_GUIDANCE.summary);
183+
expect(out.guidance.likelyReadTopics).toEqual(MOCK_DEPOSITORY_GUIDANCE.likelyReadTopics);
184+
expect(out.guidance.underservedTopics).toEqual(
185+
expect.arrayContaining(['idempotent invoice replay']),
186+
);
187+
expect(Array.isArray(out.guidance.searchQueries)).toBe(true);
188+
expect(out.guidance.searchQueries!.length).toBeGreaterThan(0);
183189
expectNoEnvelopeLeak(out);
184-
expect(exec.get('discovery', 'depositorySearch')).toEqual(MOCK_DEPOSITORY_GUIDANCE);
190+
expect(exec.get('discovery', 'depositorySearch').summary).toBe(MOCK_DEPOSITORY_GUIDANCE.summary);
185191
}, 30000);
186192

187193
it('inherent-regurgitation: typed regurgitation result + discovery:inherentRegurgitation store', async () => {
@@ -196,15 +202,17 @@ describe('deposit Discovery lens agents (boundary-mocked PTRR)', () => {
196202
expect(exec.get('discovery', 'inherentRegurgitation')).toEqual(MOCK_REGURGITATION);
197203
}, 30000);
198204

199-
it('a minimal model response ({summary} only) satisfies the lens schemas without a retry storm', async () => {
205+
it('a minimal model response ({summary} only) satisfies the guidance schema without a retry storm', async () => {
200206
setBoundaryLLMOutput({ guidance: { summary: 'Minimal demand guidance.' } });
201207
const exec = new Execution('discovery-node');
202208

203209
const out = await runDepositDepositorySearchAgent(DEPOSIT_INPUT, exec);
204210

205211
// One required string; every array dimension is optional — the schema is
206-
// satisfiable by the leanest well-formed model response.
207-
expect(out.guidance).toEqual({ summary: 'Minimal demand guidance.' });
212+
// satisfiable by the leanest well-formed model response. Host still attaches
213+
// searchQueries for the Depository search tool.
214+
expect(out.guidance.summary).toBe('Minimal demand guidance.');
215+
expect(Array.isArray(out.guidance.searchQueries)).toBe(true);
208216
// No schema-driven retry storm: a straight PTRR run is 4 steps x 3 failsafes
209217
// x 3 generations = 36 LLM calls; stay comfortably at/below that baseline.
210218
expect(getBoundaryLLMCalls().length).toBeGreaterThan(0);
@@ -246,7 +254,10 @@ describe('deposit Discovery lens agents (boundary-mocked PTRR)', () => {
246254
setBoundaryLLMOutput({ guidance: MOCK_DEPOSITORY_GUIDANCE });
247255
const exec = new Execution('shared-node');
248256
await runDepositDepositorySearchAgent(DEPOSIT_INPUT, exec);
249-
expect(exec.get('discovery', 'depositorySearch')).toEqual(MOCK_DEPOSITORY_GUIDANCE);
257+
expect(exec.get('discovery', 'depositorySearch').summary).toBe(MOCK_DEPOSITORY_GUIDANCE.summary);
258+
expect(exec.get('discovery', 'depositorySearch').underservedTopics).toEqual(
259+
expect.arrayContaining(['idempotent invoice replay']),
260+
);
250261

251262
// ...and the Implementation agent, reading the same node, threads that
252263
// guidance (summary + underservedTopics) into its synthesis prompt.
@@ -321,13 +332,15 @@ describe('discovery conditional runtime registry roster', () => {
321332
};
322333
}
323334

324-
it('deposit mode registers exactly the three deposit lenses and never touches the read roster', () => {
335+
it('deposit mode registers the three Discovery agents (native keys + stable aliases), not the read roster', () => {
325336
const registry = recordingRegistry();
326337
registerDiscoveryAgents(registry, 'deposit');
327338
expect([...registry.registrations.keys()].sort()).toEqual([
328339
'discovery:codebase-comprehension',
340+
'discovery:comprehend-codebase',
329341
'discovery:depository-search',
330342
'discovery:inherent-regurgitation',
343+
'discovery:search-depository',
331344
]);
332345
});
333346

packages/asset-packs-pipelines/domain/src/agents/discovery/deposit-codebase-comprehension-agent.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ const REQUIREMENTS = part(
9090
);
9191

9292
const PLAN = part(
93-
'Plan: combine measurements, LSP signals, file-tree structure, and key file reads to ' +
94-
'map capability, structure, and synthesis opportunities.',
93+
'Plan: combine absolute measurements, LSP signals, file-tree structure, and key file ' +
94+
'reads from the sourceCheckoutCatalog to map capability, structure, and synthesis opportunities.',
9595
);
9696
const TRY = part(
97-
'Try: synthesize the codebase knowledge map using measurements + LSP + tree + key files.',
97+
'Try: synthesize the codebase knowledge map — capabilities, knowledge areas, notable ' +
98+
'modules, measurementInsights, structureInsights — from measurements + LSP + tree + key files.',
9899
);
99100
const REFINE = part(
100-
'Refine: ensure the map is source-safe, grounded in provided evidence, and useful for pack synthesis.',
101+
'Refine: ensure the map is source-safe, grounded in provided sourceCheckoutCatalog evidence, and useful for pack synthesis.',
101102
);
102103
const RETRY = part(
103-
'Retry: return a minimal source-safe map grounded in path list and measurements rather than failing.',
104+
'Retry: return a minimal source-safe knowledge map grounded in path list and measurements rather than failing comprehension.',
104105
);
105106

106107
function createPrompt(): Prompt {

packages/asset-packs-pipelines/domain/src/agents/discovery/deposit-depository-search-agent.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ const DepositorySearchOutputSchema = z.object({
4444
export type DepositReadDemandGuidance = z.infer<typeof ReadDemandGuidanceSchema>;
4545

4646
const IDENTITY = part(
47-
'You are the SynthesizeAssetPacks discovery agent searching the Bitcode Depository ' +
47+
'You are the SynthesizeAssetPacks Discovery agent that searches the Bitcode Depository ' +
4848
'for settled AssetPack supply relevant to this deposit synthesis run. Build search ' +
49-
'queries from the source checkout catalog, obfuscations, measurements, and demand ' +
50-
'context so synthesized packs have high likelihood of future demand. Be source-safe.',
49+
'queries from the sourceCheckoutCatalog, obfuscations, checkout measurements, and ' +
50+
'demand context so synthesized packs have high likelihood of future demand. Be source-safe.',
5151
);
5252

5353
const REQUIREMENTS = part(
@@ -60,13 +60,15 @@ const REQUIREMENTS = part(
6060
);
6161

6262
const PLAN = part(
63-
'Plan: from source paths, measurements, obfuscations, and demand context, synthesize ' +
64-
'Depository search queries that will retrieve AssetPacks relevant to high-demand synthesis.',
63+
'Plan: from sourceCheckoutCatalog paths, measurements, obfuscations, and demand context, ' +
64+
'synthesize Depository search queries that retrieve AssetPacks relevant to high-demand synthesis.',
6565
);
6666
const TRY = part(
6767
'Try: produce demand guidance and the searchQueries list the Depository search tool will run.',
6868
);
69-
const REFINE = part('Refine: ensure queries and guidance are grounded, demand-aligned, and source-safe.');
69+
const REFINE = part(
70+
'Refine: ensure queries and guidance are grounded in sourceCheckoutCatalog evidence, demand-aligned, and source-safe.',
71+
);
7072
const RETRY = part('Retry: return minimal demand guidance and broad searchQueries rather than failing.');
7173

7274
function createPrompt(): Prompt {

packages/asset-packs-pipelines/domain/src/agents/discovery/deposit-inherent-regurgitation-agent.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export type DepositInherentRegurgitation = z.infer<typeof InherentKnowledgeSchem
3333
const IDENTITY = part(
3434
'You are the SynthesizeAssetPacks Discovery agent that contributes model-inherent ' +
3535
'knowledge for deposit AssetPack synthesis. From your training data, return patterns, ' +
36-
'best practices, and domain knowledge useful for this repository. Source-safe: never ' +
37-
'quote the repository’s raw source or secrets.',
36+
'best practices, and domain knowledge useful for this repository (grounded by ' +
37+
'sourceCheckoutCatalog path context for relevance only). Source-safe: never quote ' +
38+
'the repository’s raw source or secrets.',
3839
);
3940

4041
const REQUIREMENTS = part(
@@ -43,10 +44,16 @@ const REQUIREMENTS = part(
4344
'general and source-safe. Return ONLY {"regurgitation": {...}}.',
4445
);
4546

46-
const PLAN = part('Plan: identify trained knowledge relevant to this repository domain.');
47-
const TRY = part('Try: regurgitate relevant knowledge, patterns, best practices, and references.');
48-
const REFINE = part('Refine: ensure knowledge is relevant, generally-known, and source-safe.');
49-
const RETRY = part('Retry: return minimal relevant knowledge rather than failing.');
47+
const PLAN = part(
48+
'Plan: identify which of your trained knowledge is relevant to this repository domain.',
49+
);
50+
const TRY = part(
51+
'Try: regurgitate relevant knowledge, well-known patterns, best practices, and references.',
52+
);
53+
const REFINE = part(
54+
'Refine: ensure the knowledge is relevant, generally-known, and source-safe.',
55+
);
56+
const RETRY = part('Retry: return minimal relevant knowledge rather than failing the regurgitation.');
5057

5158
function createPrompt(): Prompt {
5259
const prompt = new Prompt();

packages/asset-packs-pipelines/domain/src/agents/implementation/deposit-asset-pack-synthesis-agent.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Deposit-mode AssetPack synthesis agent (V48 Gate 3).
33
*
4-
* The deposit lens of the SynthesizeAssetPacks Implementation phase: synthesize
5-
* reviewable AssetPacks from the DEPOSITOR's repository. Each AssetPack is a
6-
* completely synthesized artifact = MEASURED PATCH (patch + measurements +
7-
* metadata). Schema and prompts live in co-located siblings; this file owns
8-
* the PTRR factory agent, patch-write materialization, and cross-phase stores.
4+
* Implementation phase of SynthesizeDepositAssetPacks: synthesize reviewable
5+
* AssetPacks from the depositor Host checkout. Each AssetPack is
6+
* patch + measurements + metadata. Schema and prompts are co-located siblings;
7+
* this file owns the PTRR factory agent, patch-write materialization, absolute
8+
* measurement attachment, and cross-phase stores.
99
*
1010
* Default export (run factory path) and `DepositAssetPackSynthesisAgent` remain
1111
* stable for phase registration and tests.
@@ -34,7 +34,7 @@ const depositPrompt = createDepositSynthesisPrompt();
3434
export const DepositAssetPackSynthesisAgent = factoryPTRRAgent<any, DepositSynthesisOptions>({
3535
name: 'DepositAssetPackSynthesisAgent',
3636
description:
37-
'Synthesizes reviewable, source-safe, measured AssetPack candidate options from the depositor repository source (deposit lens).',
37+
'Synthesizes reviewable AssetPacks (patch + measurements + metadata) from the depositor Host sourceCheckoutCatalog.',
3838
outputSchema: depositCandidateSetSchema,
3939
tools: [],
4040
prompt: depositPrompt,

0 commit comments

Comments
 (0)