@promptdriven/runtime-client 1.1.1 → 1.1.3

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.
@@ -1,7 +1,20 @@
1
- // Generated from prompts/cli/runtime-binding-plan.prompt.md (sha256: 667d9ad0ad59e95258aac6c32665398d28642416fc95d7132d7349eba65abd60).
1
+ // Generated from prompts/cli/runtime-binding-plan.prompt.md (sha256: f198da66d04fa0e22f48fdd4d438ed5a6349bd6a63121fcb0e6d785adddec6c2).
2
2
 
3
3
  const rows = value => Array.isArray(value) ? value : [];
4
- const stepSimulation = (base, overrides) => {
4
+ const PROMPT_SIM_ACTIONS = new Set(['fake.prompt', 'http.prompt', 'port.prompt']);
5
+ const normalizePortName = name => typeof name === 'string' ? name.replaceAll('-', '_') : '';
6
+ const promptStem = path => {
7
+ if (typeof path !== 'string') return '';
8
+ const base = path.slice(path.lastIndexOf('/') + 1);
9
+ return base.endsWith('.prompt.md') ? base.slice(0, -'.prompt.md'.length) : base;
10
+ };
11
+ const promptTargetOf = binding => {
12
+ if (!binding || typeof binding !== 'object' || Array.isArray(binding)) return null;
13
+ if (typeof binding.target === 'string' && binding.target.endsWith('.prompt.md')) return binding.target;
14
+ if (typeof binding.prompt_path === 'string' && binding.prompt_path.endsWith('.prompt.md')) return binding.prompt_path;
15
+ return null;
16
+ };
17
+ export function stepSimulation(base, overrides) {
5
18
  const result = { ...(base ?? {}) };
6
19
  if (Array.isArray(overrides)) {
7
20
  for (const row of overrides) {
@@ -13,6 +26,63 @@ const stepSimulation = (base, overrides) => {
13
26
  Object.assign(result, overrides);
14
27
  }
15
28
  return result;
29
+ }
30
+ export function simulationGraph(simulation) {
31
+ const promptTargets = [];
32
+ const promptTargetSet = new Set();
33
+ const mockedKeys = new Set();
34
+ const normalizedMockedKeys = new Set();
35
+ const mockedResources = new Set();
36
+ const normalizedMockedResources = new Set();
37
+ for (const [key, binding] of Object.entries(simulation ?? {})) {
38
+ if (!binding || typeof binding !== 'object' || Array.isArray(binding)) continue;
39
+ const target = promptTargetOf(binding);
40
+ const dot = key.lastIndexOf('.');
41
+ const resource = dot > 0 ? key.slice(0, dot) : '';
42
+ const op = dot > 0 ? key.slice(dot + 1) : '';
43
+ if (target || PROMPT_SIM_ACTIONS.has(binding.action)) {
44
+ if (target && !promptTargetSet.has(target)) {
45
+ promptTargetSet.add(target);
46
+ promptTargets.push(target);
47
+ }
48
+ }
49
+ mockedKeys.add(key);
50
+ if (resource) {
51
+ normalizedMockedKeys.add(`${normalizePortName(resource)}.${op}`);
52
+ mockedResources.add(resource);
53
+ normalizedMockedResources.add(normalizePortName(resource));
54
+ }
55
+ }
56
+ return { promptTargets, promptTargetSet, mockedKeys, normalizedMockedKeys, mockedResources, normalizedMockedResources };
57
+ }
58
+ export function isMockedPortCall(call, sim) {
59
+ if (!call || typeof call.target !== 'string' || !sim) return false;
60
+ if (sim.promptTargetSet?.has(call.target)) return false;
61
+ const op = typeof call.operation === 'string' ? call.operation : '';
62
+ const targetOp = typeof call.target_operation === 'string' ? call.target_operation : '';
63
+ const stem = promptStem(call.target);
64
+ const normOp = normalizePortName(op);
65
+ const normStem = normalizePortName(stem);
66
+ if (op && sim.mockedKeys.has(op)) return true;
67
+ if (op && targetOp && (sim.mockedKeys.has(`${op}.${targetOp}`) || sim.normalizedMockedKeys.has(`${normOp}.${targetOp}`))) return true;
68
+ if (stem && targetOp && (sim.mockedKeys.has(`${stem}.${targetOp}`) || sim.normalizedMockedKeys.has(`${normStem}.${targetOp}`))) return true;
69
+ if (!targetOp) {
70
+ if (op && (sim.mockedResources.has(op) || sim.normalizedMockedResources.has(normOp))) return true;
71
+ if (stem && (sim.mockedResources.has(stem) || sim.normalizedMockedResources.has(normStem))) return true;
72
+ }
73
+ return false;
74
+ }
75
+ const isPlainProsePlan = (test, prompts, dependencyPaths, plainProse) => {
76
+ if (typeof plainProse === 'boolean') return plainProse;
77
+ const relevant = new Set(rows(dependencyPaths).filter(path => typeof path === 'string'));
78
+ for (const step of rows(test?.doc?.steps)) {
79
+ if (typeof step?.entry_path === 'string') relevant.add(step.entry_path);
80
+ const sim = simulationGraph(stepSimulation(test?.doc?.simulation, step?.simulation_overrides));
81
+ for (const target of sim.promptTargets) relevant.add(target);
82
+ }
83
+ const candidates = relevant.size ? [...relevant].map(path => prompts.get(path)).filter(Boolean) : [...prompts.values()];
84
+ const executable = candidates.filter(iface => iface?.kind !== 'native-only');
85
+ return executable.length > 0 && executable.every(iface => iface?.plain_prose === true);
16
86
  };
17
87
  const selectedResources = (iface, operation) => {
18
88
  const entries = rows(iface?.entries), selected = entries.filter(entry => entry?.operation === operation);
@@ -32,7 +102,7 @@ const boundaryNote = (notes, reason) => {
32
102
  : `boundary not applied: ${reason === 'unsupported-line-ends' ? 'unsupported line ends' : reason}; full dependency closure is required`});
33
103
  return null;
34
104
  };
35
- export function runtimeBoundary(storyPath, text, {notes=[]}={}) {
105
+ export function runtimeBoundary(storyPath, text, {notes=[], plainProse=false}={}) {
36
106
  // Scope removal needs unambiguous line boundaries throughout the Story.
37
107
  // Do not normalize unsupported separators into apparent top-level authority.
38
108
  if (/\r(?!\n)|[\v\f\u001c-\u001e\u0085\u2028\u2029]/u.test(text)) {
@@ -42,7 +112,11 @@ export function runtimeBoundary(storyPath, text, {notes=[]}={}) {
42
112
  // Admission is deliberately stricter than Markdown discovery. Count even
43
113
  // unsupported/example markers so uncertain declarations never yield a subset.
44
114
  const markers = lines.flatMap((line,index)=>/[`~]{3,}[ \t]*pdd-boundary\b/.test(line) ? [index] : []);
45
- if (!markers.length) return boundaryNote(notes,/runtime boundary/i.test(text) ? 'legacy-syntax' : 'missing-block');
115
+ if (!markers.length) {
116
+ if (/runtime boundary/i.test(text)) return boundaryNote(notes,'legacy-syntax');
117
+ if (plainProse) return null;
118
+ return boundaryNote(notes,'missing-block');
119
+ }
46
120
  if (markers.length !== 1) return boundaryNote(notes,'duplicate-blocks');
47
121
  const start = markers[0];
48
122
  let fence = null, uncertain = false;
@@ -67,15 +141,38 @@ export function runtimeBoundary(storyPath, text, {notes=[]}={}) {
67
141
  return [...new Set(paths)].sort();
68
142
  }
69
143
 
70
- export function buildBindingPlan({test, storyText, prompts, dependencyPaths=[], boundaryState}) {
144
+ export function buildBindingPlan({test, storyText, prompts, dependencyPaths=[], boundaryState, plainProse}) {
145
+ const isPlainProse = isPlainProsePlan(test, prompts, dependencyPaths, plainProse);
71
146
  const notes=[];
72
- const boundary = boundaryState ? boundaryState.boundary : runtimeBoundary(test.storyPath,storyText,{notes});
73
- if (boundaryState) notes.push(...boundaryState.notes);
147
+ const boundary = boundaryState ? boundaryState.boundary : runtimeBoundary(test.storyPath,storyText,{notes, plainProse: isPlainProse});
148
+ if (boundaryState) {
149
+ for (const note of rows(boundaryState.notes)) {
150
+ if (boundary === null && isPlainProse && note?.code === 'boundary-not-applied' && note?.reason === 'missing-block') continue;
151
+ notes.push(note);
152
+ }
153
+ }
154
+ const useStepMinimal = boundary === null && isPlainProse && !notes.some(note => note.code === 'boundary-not-applied');
74
155
  const steps = [], edges = [], problems = [];
75
156
  const allowed = path => boundary === null || boundary.includes(path);
157
+ const entriesByOp = new Map();
158
+ for (const [candidate, iface] of prompts) {
159
+ for (const entry of rows(iface?.entries)) {
160
+ if (!entry || typeof entry.operation !== 'string') continue;
161
+ let list = entriesByOp.get(entry.operation);
162
+ if (!list) { list = []; entriesByOp.set(entry.operation, list); }
163
+ list.push(candidate);
164
+ }
165
+ }
76
166
  for (const step of rows(test.doc?.steps)) {
77
167
  if (!step || typeof step.entry_path !== 'string') continue;
78
- const closure = new Set(), pending = [step.entry_path, ...(boundary ?? dependencyPaths)];
168
+ const simulation = stepSimulation(test.doc.simulation, step.simulation_overrides);
169
+ const sim = useStepMinimal ? simulationGraph(simulation) : null;
170
+ const closure = new Set();
171
+ const pending = boundary !== null
172
+ ? [step.entry_path, ...boundary]
173
+ : useStepMinimal
174
+ ? [step.entry_path, ...sim.promptTargets]
175
+ : [step.entry_path, ...dependencyPaths];
79
176
  for (let index = 0; index < pending.length; index++) {
80
177
  const path = pending[index];
81
178
  if (closure.has(path)) continue;
@@ -83,10 +180,14 @@ export function buildBindingPlan({test, storyText, prompts, dependencyPaths=[],
83
180
  if (!allowed(path)) { problems.push({step_id:step.step_id,prompt_path:path,code:'out-of-boundary'}); continue; }
84
181
  const iface = prompts.get(path);
85
182
  if (!iface) { problems.push({step_id:step.step_id,prompt_path:path,code:'interface-unavailable'}); continue; }
86
- for (const call of rows(iface.calls)) if (typeof call?.target==='string') pending.push(call.target);
183
+ for (const call of rows(iface.calls)) {
184
+ if (typeof call?.target !== 'string') continue;
185
+ if (boundary !== null && call.from_dependencies === true) continue;
186
+ if (useStepMinimal && call.target !== step.entry_path && isMockedPortCall(call, sim)) continue;
187
+ pending.push(call.target);
188
+ }
87
189
  }
88
190
  steps.push({step_id:step.step_id,closure:[...closure].sort()});
89
- const simulation = stepSimulation(test.doc.simulation, step.simulation_overrides);
90
191
  const otherEntryCall = [...closure].some(path => rows(prompts.get(path)?.calls).some(call =>
91
192
  call?.target === step.entry_path && call.target_operation !== step.operation));
92
193
  const active = otherEntryCall ? null : selectedResources(prompts.get(step.entry_path), step.operation);
@@ -102,10 +203,8 @@ export function buildBindingPlan({test, storyText, prompts, dependencyPaths=[],
102
203
  : !binding || typeof binding !== 'object' || binding.action === 'fixture.lookup' && (!Array.isArray(binding.cases) || !binding.cases.length) ? 'invalid-fixture' : 'selected';
103
204
  candidates.push({kind:'simulation',name,cause});
104
205
  }
105
- for (const [candidate,iface] of prompts) for (const entry of rows(iface?.entries)) {
106
- if (!entry) continue;
107
- if (entry.operation !== operation.name) continue;
108
- candidates.push({kind:'prompt',name:`${candidate}#${entry.operation}`,
206
+ for (const candidate of entriesByOp.get(operation.name) ?? []) {
207
+ candidates.push({kind:'prompt',name:`${candidate}#${operation.name}`,
109
208
  cause:!allowed(candidate)?'out-of-boundary':!closure.has(candidate)?'not-in-dependency-closure':'wrong-name'});
110
209
  }
111
210
  const internal = ['key-value','collection','blob','sql','compute'].includes(resource.kind);
@@ -122,7 +221,9 @@ export function buildBindingPlan({test, storyText, prompts, dependencyPaths=[],
122
221
  }
123
222
 
124
223
  export function bindingPlanLines(plan) {
125
- return [`Bindings: ${plan.test}; boundary: ${plan.boundary?.join(', ') ?? 'full dependency closure'}`,
224
+ const scope = plan.boundary?.join(', ')
225
+ ?? (plan.notes?.some(note => note.code === 'boundary-not-applied') ? 'full dependency closure' : 'step-minimal closure');
226
+ return [`Bindings: ${plan.test}; boundary: ${scope}`,
126
227
  ...plan.edges.map(edge=>`${edge.step_id}: ${edge.prompt_path}: ${edge.key}: ${edge.state}; considered: ${edge.candidates.map(candidate=>`${candidate.kind} ${candidate.name} (${candidate.cause})`).join(', ') || 'none'}${edge.repair ? `; repair: ${edge.repair}` : ''}`),
127
228
  ...(plan.notes ?? []).map(note=>`${note.code}: ${note.message}`),
128
229
  ...plan.problems.map(problem=>`${problem.step_id}: ${problem.prompt_path}: ${problem.code}; repair: correct the declared boundary or Runtime call target.`)];
@@ -1,4 +1,4 @@
1
- // Generated from prompts/cli/runtime-bindings.prompt.md (sha256: cfbb0656bad59b35043dfcc88ad843a90f907a05da99980046d9085514891d85).
1
+ // Generated from prompts/cli/runtime-bindings.prompt.md (sha256: 5431647b69a555975055800dd36c374050ac0f8cfc84419fd72f3248e48038e9).
2
2
  import {loadRuntimeWorkspace,allowsRuntimePath} from './runtime-workspace.mjs';
3
3
  import { lstatSync } from 'node:fs';
4
4
  import { join } from 'node:path';
@@ -33,14 +33,18 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
33
33
  if (!keys(inventory, ['schema_version', 'modules']) || inventory.schema_version !== 'pdd.bindings.v1' || !Array.isArray(inventory.modules)) fail('inventory', 'expected schema_version pdd.bindings.v1 and modules array only');
34
34
  if (inventory.modules.length > 1000) fail('inventory', 'exceeds 1000 module declarations');
35
35
  const stories = new Set(found.stories.map(s => s.path)), chosen = new Set(selected.map(t => t.storyPath)), seen = new Set(), modules = [];
36
- const reached = new Set(), context = new Set(), visited = new Set();
36
+ const reached = new Set(), context = new Set(), visited = new Set(), promptCache = new Map();
37
+ const getPrompt = path => {
38
+ if (!promptCache.has(path)) promptCache.set(path, readPrompt(root, found.visible, path, workspace));
39
+ return promptCache.get(path);
40
+ };
37
41
  const queue = selected.flatMap(t => (Array.isArray(t.doc?.steps) ? t.doc.steps : []).map(s => ({path:s?.entry_path, executable:true})));
38
42
  while (queue.length) {
39
43
  const {path,executable} = queue.shift(), identity = `${executable ? 'call' : 'context'}:${path}`;
40
44
  if (typeof path !== 'string' || visited.has(identity)) continue;
41
45
  visited.add(identity);
42
46
  (executable ? reached : context).add(path);
43
- const prompt = readPrompt(root, found.visible, path, workspace);
47
+ const prompt = getPrompt(path);
44
48
  for (const call of Array.isArray(prompt?.interface?.calls) ? prompt.interface.calls : []) if (typeof call?.target === 'string') queue.push({path:call.target,executable});
45
49
  for (const target of promptMarkdownTargets(prompt.text, path, found.visible)) queue.push({path:target,executable:false});
46
50
  }
@@ -58,7 +62,7 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
58
62
  else for (const key of ['reason', 'port_attempt']) if (typeof item[key] !== 'string' || !item[key].trim()) fail(path, `${key} must be nonblank`);
59
63
  if (!itemStories.some(story => chosen.has(story))) continue;
60
64
  if (bound) {
61
- const prompt = readPrompt(root, found.visible, item.prompt, workspace);
65
+ const prompt = getPrompt(item.prompt);
62
66
  const nativeProblem = (prompt.frontmatter || prompt?.interface?.kind === 'native-only') ? promptRefusal(prompt, 'interface') : null;
63
67
  if (nativeProblem) fail(path, nativeProblem.message);
64
68
  if (!prompt.error && prompt?.interface?.kind === 'native-only' && typeof prompt.interface.reason === 'string' && prompt.interface.reason.trim()) {
@@ -66,11 +70,10 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
66
70
  continue;
67
71
  }
68
72
  const lazyMissing = allowMissingInterfaces && prompt.error === 'interface-missing';
69
- if ((lazyMissing && reached.has(item.prompt)) || (!reached.has(item.prompt) && context.has(item.prompt) && prompt.error === 'interface-missing')) {
70
- const pending = reached.has(item.prompt);
73
+ if (!reached.has(item.prompt) && context.has(item.prompt) && prompt.error === 'interface-missing') {
71
74
  modules.push({path:item.module,state:'unbound',prompt:item.prompt,
72
- reason:pending ? 'Runtime interface pending' : 'Context-only module contract',
73
- port_attempt:pending ? 'lazy interface synthesis pending' : 'no executable Runtime call'});
75
+ reason:'Context-only module contract',
76
+ port_attempt:'no executable Runtime call'});
74
77
  continue;
75
78
  }
76
79
  if (!reached.has(item.prompt) || (!lazyMissing && (prompt.error || !Array.isArray(prompt?.interface?.entries) || !prompt.interface.entries.length || prompt.interface.entries.some(entry => !entry || typeof entry.operation !== 'string' || !entry.operation.trim() || !object(entry.input_schema) || !object(entry.result_schema))))) fail(path, `${item.prompt} must be reached and have an executable Runtime interface`);
@@ -1,7 +1,7 @@
1
1
  // Generated from prompts/cli/runtime-check-plan.prompt.md (sha256: 081b45f925041a79c1e7ecf6b9b36ff3c4b10166ae0faecccfc138c2c0904780).
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { isAbsolute, posix } from 'node:path';
4
- import { captureSource, readPrompt, sourceFilePort, analyzeStepCallCost, hasSimulationBindings, LAZY_INTERFACE_SYNTHESIS_CALLS } from './runtime-preflight.mjs';
4
+ import { captureSource, captureStoryClosures, readPrompt, sourceFilePort, analyzeStepCallCost, hasSimulationBindings, LAZY_INTERFACE_SYNTHESIS_CALLS } from './runtime-preflight.mjs';
5
5
  import { resultOutcome } from './runtime-outcome.mjs';
6
6
  import { allowsRuntimePath, loadRuntimeWorkspace } from './runtime-workspace.mjs';
7
7
 
@@ -142,6 +142,12 @@ export function buildCheckPlan({ root, found, selected, rows = [], full, base =
142
142
  groups.get(key).push(test);
143
143
  }
144
144
  const capture = ports.capture ?? ((r, opts) => captureSource(r, opts, ports));
145
+ const hasSelectionPorts = typeof ports.isStoryPath === 'function'
146
+ && typeof ports.hasAcceptance === 'function'
147
+ && typeof ports.matchTests === 'function'
148
+ && typeof ports.orphanSummary === 'function';
149
+ const isBuiltInCapture = (!ports.capture || ports.capture === captureSource || ports.capture.isDefaultCapture === true)
150
+ && (!ports.capture || hasSelectionPorts);
145
151
  let footprints = new Map();
146
152
  const targets = new Map();
147
153
  const rememberTargets = captured => {
@@ -149,20 +155,40 @@ export function buildCheckPlan({ root, found, selected, rows = [], full, base =
149
155
  return captured;
150
156
  };
151
157
  const captureExtra = allowMissingInterfaces ? { allowMissingInterfaces: true } : {};
152
- try {
153
- const captured = rememberTargets(capture(root,{tests:selected.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra}));
154
- footprints = new Map((captured.stories ?? []).map(story=>[story.story_path,story]));
155
- } catch (error) { if (error?.unboundPort) throw error; /* Keep a broken Story from hiding other Stories' closures. */ }
156
- const classified = [...groups].map(([story_path, tests]) => {
157
- let closure = [], unavailable = false;
158
- const footprint = footprints.get(story_path);
158
+ let classified;
159
+ if (isBuiltInCapture) {
160
+ const batched = captureStoryClosures(root, {
161
+ groups: [...groups].map(([story_path, tests]) => ({ story_path, tests: tests.map(test => test.path) })),
162
+ workspace,
163
+ excludeFixtureProjects: full,
164
+ ...captureExtra,
165
+ }, ports);
166
+ for (const [k, v] of batched.targets) targets.set(k, v);
167
+ classified = [...groups].map(([story_path, tests]) => {
168
+ const entry = batched.closures.get(story_path);
169
+ return {
170
+ story_path,
171
+ tests,
172
+ closure: entry && !entry.unavailable ? sorted(entry.closure) : [],
173
+ unavailable: !entry || entry.unavailable === true,
174
+ };
175
+ });
176
+ } else {
159
177
  try {
160
- if (footprint?.unavailable) unavailable = true;
161
- else closure = sorted((footprint?.files ?? rememberTargets(capture(root, {tests:tests.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra})).files).map(file=>file.path));
162
- }
163
- catch (error) { if (error?.unboundPort) throw error; unavailable = true; }
164
- return {story_path,tests,closure,unavailable};
165
- });
178
+ const captured = rememberTargets(capture(root,{tests:selected.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra}));
179
+ footprints = new Map((captured.stories ?? []).map(story=>[story.story_path,story]));
180
+ } catch (error) { if (error?.unboundPort) throw error; /* Keep a broken Story from hiding other Stories' closures. */ }
181
+ classified = [...groups].map(([story_path, tests]) => {
182
+ let closure = [], unavailable = false;
183
+ const footprint = footprints.get(story_path);
184
+ try {
185
+ if (footprint?.unavailable) unavailable = true;
186
+ else closure = sorted((footprint?.files ?? rememberTargets(capture(root, {tests:tests.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra})).files).map(file=>file.path));
187
+ }
188
+ catch (error) { if (error?.unboundPort) throw error; unavailable = true; }
189
+ return {story_path,tests,closure,unavailable};
190
+ });
191
+ }
166
192
  let conservative = '';
167
193
  if (affected && changed?.length) {
168
194
  if (changed.some(path=>['pdd-source.json','pdd-workspace.json','pdd-bindings.json'].includes(path)))
@@ -380,14 +406,18 @@ export function checkPlanLines(plan) {
380
406
  const callsLine = disabled
381
407
  ? ` Interpreter calls: about ${plan.calls.estimated ?? 'unknown'}; at most ${plan.calls.maximum ?? 'unknown'} (restart replacement disabled${capNote}); at most ${plan.calls.check_requests} Check requests; lint: 0 model calls.`
382
408
  : ` Interpreter calls: about ${plan.calls.estimated ?? 'unknown'}; at most ${plan.calls.maximum ?? 'unknown'} including one restart replacement per test${capNote}; at most ${plan.calls.check_requests} Check requests; lint: 0 model calls.`;
383
- const policyLines = policy ? [(() => {
409
+ const policyLines = policy ? (() => {
384
410
  const caps = policy.per_request_max_calls?.length ? policy.per_request_max_calls.join(', ') : 'none';
385
411
  const ceiling = policy.max_total_calls != null ? `${policy.max_total_calls} (--max-total-calls)` : 'unbounded';
386
412
  const replacement = disabled ? 'disabled' : 'at most 1 per test on confirmed service-restarted';
387
413
  const prior = policy.unresolved_reservations;
388
414
  const priorText = prior?.count ? `${prior.count} (${prior.reserved_calls} calls reserved${prior.batches?.length ? ` in ${prior.batches.join(', ')}` : ''})` : '0';
389
- return ` Call policy: per-request cap ${caps}; invocation ceiling ${ceiling}; restart replacement ${replacement}; unresolved prior reservations ${priorText} (logical interpreter call limits; not dollar, token or provider-attempt guarantees).`;
390
- })()] : [];
415
+ const lines = [` Call policy: per-request cap ${caps}; invocation ceiling ${ceiling}; restart replacement ${replacement}; unresolved prior reservations ${priorText} (logical interpreter call limits; not dollar, token or provider-attempt guarantees).`];
416
+ if (prior?.count && prior.batches?.length) {
417
+ lines.push(` To reconcile finished prior batches: pdd test --reconcile ${prior.batches[0]} (or pdd test --reconcile-stale).`);
418
+ }
419
+ return lines;
420
+ })() : [];
391
421
  return ['Check plan:', ...plan.stories.flatMap(story=>[
392
422
  ` ${story.role}: ${story.story_path} (${story.tests.join(', ')}); ${story.reason}`,
393
423
  ` dependency closure: ${story.dependency_closure.join(', ') || 'unavailable'}`]),