Skip to content

Commit 83b3130

Browse files
V48 Gate 3: PromptPart/Prompt sanity-check — fix prompts index export mismatch + verify synthesis prompt build-up
Chunk F (sanity-check all PromptPart + Prompt implementations for instruction correctness given the full registry build-up + formatting correctness): - prompts/src/index.{ts,d.ts}: the four PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_* re-exports were spelled ASSETPACK (no underscore), naming members that do not exist — a latent TS2724 surfaced whenever a package imports the prompts index. Corrected to the real ASSET_PACK names (the six AssetPack comprehension/clone tools already import them directly under the correct name; no consumer used the wrong spelling). - asset-packs-synthesis-pipeline.ts: extracted buildSynthesisPromptLayers — the six layered system PromptParts (pipeline identity -> source-safety -> phase lens-role -> agent catalog -> agent rules -> step shape) as a pure, exported, ordered factory the measure step applies via setSpecificExecution. - New asset-packs-synthesis-pipeline.test.ts proves the registry build-up + hierarchical formatting: every layer registers under a valid ExecutionPrompt path and the real hierarchicalFormatter renders each layer's instruction content into the system prompt, lens-correctly (deposit demand-alignment vs read need-fit). 3/3 green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 38690c9 commit 83b3130

4 files changed

Lines changed: 129 additions & 18 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { ExecutionPrompt } from '@bitcode/execution-generics/prompts/ExecutionPrompt';
2+
import { hierarchicalFormatter } from '@bitcode/prompts/formatters';
3+
import type { PromptPart } from '@bitcode/prompts/parts/PromptPart';
4+
5+
import { buildSynthesisPromptLayers } from '../asset-packs-synthesis-pipeline';
6+
import { measurementCatalogForLens, type AssetPacksSynthesisLens } from '../asset-packs-synthesis';
7+
8+
// Satisfy the ExecutionPrompt root requirements exactly as AgentExecution does
9+
// at runtime (generic_system + specific_execution set to a blank PromptPart).
10+
const BLANK = ' ' as PromptPart;
11+
12+
/**
13+
* Gate 3 chunk F — sanity-check that the synthesis PromptParts compose
14+
* correctly through the real registry build-up: each layer registers under a
15+
* valid ExecutionPrompt path and the hierarchical formatter renders every
16+
* layer's instruction content into the system prompt, lens-correctly.
17+
*/
18+
describe('AssetPacksSynthesis formal prompt build-up (Gate 3 chunk F)', () => {
19+
function render(lens: AssetPacksSynthesisLens): string {
20+
const prompt = new ExecutionPrompt();
21+
prompt.set('generic_system', BLANK);
22+
prompt.set('specific_execution', BLANK);
23+
const catalog = measurementCatalogForLens(lens);
24+
for (const { path, part } of buildSynthesisPromptLayers(
25+
lens,
26+
catalog,
27+
['capability-slice', 'implementation-pattern'],
28+
4,
29+
)) {
30+
prompt.setSpecificExecution(path, part);
31+
}
32+
return prompt.format(hierarchicalFormatter);
33+
}
34+
35+
it('registers six hierarchical layers under valid execution-prompt paths', () => {
36+
const layers = buildSynthesisPromptLayers(
37+
'deposit',
38+
measurementCatalogForLens('deposit'),
39+
['capability-slice'],
40+
4,
41+
);
42+
expect(layers.map((layer) => layer.path)).toEqual([
43+
'pipeline:asset-packs-synthesis:identity',
44+
'pipeline:asset-packs-synthesis:source-safety',
45+
'phase:deposit:role',
46+
'agent:measure:catalog',
47+
'agent:measure:rules',
48+
'step:candidate:shape',
49+
]);
50+
// Every part is non-empty and accepted by the ExecutionPrompt path hierarchy.
51+
const prompt = new ExecutionPrompt();
52+
for (const { path, part } of layers) {
53+
expect(part.trim().length).toBeGreaterThan(0);
54+
expect(() => prompt.setSpecificExecution(path, part)).not.toThrow();
55+
}
56+
});
57+
58+
it('composes every deposit layer into the formatted system prompt', () => {
59+
const rendered = render('deposit');
60+
expect(rendered).toContain('single Bitcode synthesis and measurement pipeline'); // identity
61+
expect(rendered).toContain('Source-safety law'); // source-safety
62+
expect(rendered).toContain('Lens: deposit'); // phase lens-role
63+
expect(rendered).toContain('source-coverage'); // agent catalog
64+
expect(rendered).toContain('demand-alignment');
65+
expect(rendered).toContain('DISTINCT candidates'); // agent rules
66+
expect(rendered).toContain('"options"'); // step candidate-shape contract
67+
expect(rendered).toContain('capability-slice'); // allowed kinds threaded into rules
68+
});
69+
70+
it('carries the lens through the phase role and measurement catalog', () => {
71+
const deposit = render('deposit');
72+
const read = render('read');
73+
expect(deposit).toContain('Lens: deposit');
74+
expect(read).toContain('Lens: read');
75+
// Read catalog adds the Need-relative measurement; deposit uses demand-alignment.
76+
expect(read).toContain('need-fit');
77+
expect(deposit).not.toContain('need-fit');
78+
expect(deposit).toContain('demand-alignment');
79+
});
80+
});

packages/pipelines/asset-pack/src/asset-packs-synthesis-pipeline.ts

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,37 @@ function buildShapePart(catalog: AssetPackMeasurementSpec[], maxCandidates: numb
103103
);
104104
}
105105

106+
export interface SynthesisPromptLayer {
107+
/** setSpecificExecution path under the agent's ExecutionPrompt. */
108+
path: string;
109+
part: PromptPart;
110+
}
111+
112+
/**
113+
* The layered synthesis system prompt, in hierarchical order:
114+
* pipeline identity → pipeline source-safety → phase lens-role →
115+
* agent measurement-catalog → agent rules → step candidate-shape.
116+
* Registered on the AgentExecution.prompt via setSpecificExecution and composed
117+
* upwards by buildHierarchicalPrompt / hierarchicalFormatter. Pure + exported so
118+
* the registry build-up and formatting correctness are unit-tested (Gate 3
119+
* chunk F: PromptPart/Prompt sanity-check).
120+
*/
121+
export function buildSynthesisPromptLayers(
122+
lens: AssetPacksSynthesisLens,
123+
catalog: AssetPackMeasurementSpec[],
124+
candidateKinds: string[],
125+
maxCandidates: number,
126+
): SynthesisPromptLayer[] {
127+
return [
128+
{ path: 'pipeline:asset-packs-synthesis:identity', part: PIPELINE_IDENTITY },
129+
{ path: 'pipeline:asset-packs-synthesis:source-safety', part: PIPELINE_SOURCE_SAFETY },
130+
{ path: `phase:${lens}:role`, part: LENS_ROLE[lens] },
131+
{ path: 'agent:measure:catalog', part: buildCatalogPart(catalog) },
132+
{ path: 'agent:measure:rules', part: buildRulesPart(candidateKinds, maxCandidates) },
133+
{ path: 'step:candidate:shape', part: buildShapePart(catalog, maxCandidates) },
134+
];
135+
}
136+
106137
// ---- Formal source-inventory Tool ------------------------------------------
107138

108139
type InventoryToolArgs = {
@@ -228,19 +259,19 @@ export async function synthesizeAssetPackCandidatesFormal(
228259
}
229260
} catch {}
230261

231-
// Layered system prompt parts on the AgentExecution.prompt (compose upwards).
262+
// Layered system prompt parts on the AgentExecution.prompt — composed
263+
// upwards by buildHierarchicalPrompt. Built by the pure, tested factory.
232264
try {
233265
const p = (agentExec as any).prompt;
234266
if (p?.setSpecificExecution) {
235-
p.setSpecificExecution('pipeline:asset-packs-synthesis:identity', PIPELINE_IDENTITY);
236-
p.setSpecificExecution('pipeline:asset-packs-synthesis:source-safety', PIPELINE_SOURCE_SAFETY);
237-
p.setSpecificExecution(`phase:${request.lens}:role`, LENS_ROLE[request.lens]);
238-
p.setSpecificExecution('agent:measure:catalog', buildCatalogPart(catalog));
239-
p.setSpecificExecution(
240-
'agent:measure:rules',
241-
buildRulesPart(request.candidateKinds, request.maxCandidates),
242-
);
243-
p.setSpecificExecution('step:candidate:shape', buildShapePart(catalog, request.maxCandidates));
267+
for (const layer of buildSynthesisPromptLayers(
268+
request.lens,
269+
catalog,
270+
request.candidateKinds,
271+
request.maxCandidates,
272+
)) {
273+
p.setSpecificExecution(layer.path, layer.part);
274+
}
244275
}
245276
} catch {}
246277

packages/prompts/src/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_REFINE_OPTIMIZATION } from './raw_p
8888
export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_REFINE_ASSESSMENT } from './raw_promptparts/specific/promptpart_specific_agent_applyfile_refine_assessment';
8989
export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_RETRY_STRATEGY } from './raw_promptparts/specific/promptpart_specific_agent_applyfile_retry_strategy';
9090
export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_RETRY_ERRORHANDLING } from './raw_promptparts/specific/promptpart_specific_agent_applyfile_retry_errorhandling';
91-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_METADATA_PIPELINE } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_pipeline';
92-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_METADATA_PHASE_SETUP } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_phase_setup';
93-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_PURPOSE_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_purpose_addendum';
94-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_CAPABILITIES_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_capabilities_addendum';
91+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_METADATA_PIPELINE } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_pipeline';
92+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_METADATA_PHASE_SETUP } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_phase_setup';
93+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_PURPOSE_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_purpose_addendum';
94+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_CAPABILITIES_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_capabilities_addendum';
9595
export { PROMPTPART_SPECIFIC_AGENT_ASSETPACKPIPELINE_CLONEVCSREPOSITORY_SYSTEM_IDENTITY } from './raw_promptparts/specific/promptpart_specific_agent_assetpackpipeline_clonevcsrepository_system_identity';
9696
export { PROMPTPART_SPECIFIC_AGENT_ASSETPACKPIPELINE_CLONEVCSREPOSITORY_SYSTEM_PURPOSE } from './raw_promptparts/specific/promptpart_specific_agent_assetpackpipeline_clonevcsrepository_system_purpose';
9797
export { PROMPTPART_SPECIFIC_AGENT_ASSETPACKPIPELINE_CLONEVCSREPOSITORY_SYSTEM_CONSTRAINTS } from './raw_promptparts/specific/promptpart_specific_agent_assetpackpipeline_clonevcsrepository_system_constraints';

packages/prompts/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_RETRY_STRATEGY } from './raw_prompt
147147
export { PROMPTPART_SPECIFIC_AGENT_APPLYFILE_RETRY_ERRORHANDLING } from './raw_promptparts/specific/promptpart_specific_agent_applyfile_retry_errorhandling';
148148

149149
// AssetPack Tool PromptParts (Repository Setup additions)
150-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_METADATA_PIPELINE } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_pipeline';
151-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_METADATA_PHASE_SETUP } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_phase_setup';
152-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_PURPOSE_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_purpose_addendum';
153-
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSETPACK_CAPABILITIES_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_capabilities_addendum';
150+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_METADATA_PIPELINE } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_pipeline';
151+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_METADATA_PHASE_SETUP } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_metadata_phase_setup';
152+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_PURPOSE_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_purpose_addendum';
153+
export { PROMPTPART_SPECIFIC_TOOL_REPOSITORYSETUP_ASSET_PACK_CAPABILITIES_ADDENDUM } from './raw_promptparts/specific/promptpart_specific_tool_repositorysetup_assetpack_capabilities_addendum';
154154

155155
// AssetPack Agent PromptParts (Clone VCS Repository)
156156
export { PROMPTPART_SPECIFIC_AGENT_ASSETPACKPIPELINE_CLONEVCSREPOSITORY_SYSTEM_IDENTITY } from './raw_promptparts/specific/promptpart_specific_agent_assetpackpipeline_clonevcsrepository_system_identity';

0 commit comments

Comments
 (0)