@exaudeus/workrail 3.9.1 → 3.10.0

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.
package/README.md CHANGED
@@ -175,7 +175,7 @@ The agent will find the workflow, start at step 1, and proceed systematically.
175
175
  | `coding-task-workflow-agentic` | Feature development with notes-first durability and audit loops |
176
176
  | `bug-investigation-agentic` | Systematic debugging with evidence-based analysis |
177
177
  | `mr-review-workflow-agentic` | Code review with parallel reviewer families |
178
- | `exploration-workflow` | Understanding an unfamiliar codebase |
178
+ | `wr.discovery` | Upstream exploration, framing, and design synthesis |
179
179
  | `document-creation-workflow` | Technical documentation with structure |
180
180
 
181
181
  Workflows adapt to complexity - simple tasks get fast-tracked, complex tasks get full rigor.
@@ -11,6 +11,24 @@ const FEATURE_DEFINITIONS = [
11
11
  ],
12
12
  ],
13
13
  },
14
+ {
15
+ id: 'wr.features.capabilities',
16
+ constraints: [
17
+ 'Do not assume optional capabilities are available just because this workflow can use them.',
18
+ 'If delegation, web access, or another optional capability matters here, verify it through a real probe or attempt before relying on it.',
19
+ 'If a capability is unavailable, degrade explicitly instead of silently acting as if it existed.',
20
+ ],
21
+ procedure: [
22
+ 'When an optional capability would materially affect the quality of this step, decide whether using it is worth it here.',
23
+ 'If you take a capability-dependent path, record the observation or attempt that justified it.',
24
+ 'If you skip delegation or another optional capability, keep going yourself and record why the fallback path is sufficient.',
25
+ ],
26
+ verify: [
27
+ 'No capability-dependent path was taken without an explicit observation, probe, or attempted use.',
28
+ 'If a capability was unavailable or skipped, the fallback path and its limitation were made explicit.',
29
+ 'The main agent still owns synthesis and final judgment.',
30
+ ],
31
+ },
14
32
  {
15
33
  id: 'wr.features.subagent_guidance',
16
34
  constraints: [
@@ -14,8 +14,8 @@
14
14
  "bytes": 740
15
15
  },
16
16
  "application/services/compiler/feature-registry.js": {
17
- "sha256": "350bc4b849426ed5c8ba64801b13ad47130ec7084d1ee693eed065bf158f10ab",
18
- "bytes": 2239
17
+ "sha256": "ee7efd8b3594e2f02a2ecc6fe024ed9fb96ba0f8b5f1683d0c63c6196eab20e2",
18
+ "bytes": 3436
19
19
  },
20
20
  "application/services/compiler/prompt-blocks.d.ts": {
21
21
  "sha256": "2f40fd7599bd351584505152e9916fdea60891833d22c774c8ac9955f01ccf66",
@@ -946,8 +946,8 @@
946
946
  "bytes": 68013
947
947
  },
948
948
  "mcp/output-schemas.js": {
949
- "sha256": "f390f2c853580c63dbaa204354dd2199f282e47c0bcd162d2accf3ab27d7ec04",
950
- "bytes": 15326
949
+ "sha256": "d8e73b9f2722193eac8f68887a11644752efb35d341775dd18296f51cc1de26f",
950
+ "bytes": 15428
951
951
  },
952
952
  "mcp/render-envelope.d.ts": {
953
953
  "sha256": "22e83e1aba52968a7136cf289125a217b5f462a5a66a1eebe4669006e3326fdb",
@@ -1446,12 +1446,12 @@
1446
1446
  "bytes": 447
1447
1447
  },
1448
1448
  "v2/durable-core/constants.d.ts": {
1449
- "sha256": "2cdc1fe66cb2024e17977e024c73b9bb50845b70c9ac3925c2635e843a94f7f8",
1450
- "bytes": 3699
1449
+ "sha256": "60311085ea51d86307877bd952623effcafeddf935fbe0f2cde8a21a165dd932",
1450
+ "bytes": 3754
1451
1451
  },
1452
1452
  "v2/durable-core/constants.js": {
1453
- "sha256": "29372d3e7f868b5c40d6270a1f39477a680524688e73b03613305fafef4a9553",
1454
- "bytes": 3558
1453
+ "sha256": "41e0aabd3754c79c9453c8496128610b1bd4a328cf7f55c4f0a8d7bc527c94a2",
1454
+ "bytes": 3642
1455
1455
  },
1456
1456
  "v2/durable-core/domain/ack-advance-append-plan.d.ts": {
1457
1457
  "sha256": "2e802606656a0c1938192e5533aa46c74bc42789b5c315c79f6de4850017b30e",
@@ -1594,8 +1594,8 @@
1594
1594
  "bytes": 1175
1595
1595
  },
1596
1596
  "v2/durable-core/domain/prompt-renderer.js": {
1597
- "sha256": "2ac48cd9cdcecd19bec6bec710e6f45437f68a62df6fac60ce3eff1cdb821b32",
1598
- "bytes": 18266
1597
+ "sha256": "f3e7cc34b753c082ee310e88839948e225ab10f13cedae1d35b2bd64869eb848",
1598
+ "bytes": 17166
1599
1599
  },
1600
1600
  "v2/durable-core/domain/reason-model.d.ts": {
1601
1601
  "sha256": "650fcb2d9969a4e6123cccbd4913f4d57aeab21a19bb907aa1e11f95e5a95089",
@@ -1621,6 +1621,14 @@
1621
1621
  "sha256": "cc53453a1617b9adc526f7d3f49a40b1491bbe63dbaff98ddc187e1f8f6d125f",
1622
1622
  "bytes": 1454
1623
1623
  },
1624
+ "v2/durable-core/domain/retrieval-contract.d.ts": {
1625
+ "sha256": "9d130876a9584ab24fcb65e145958404d5636ff96ee1c5a02a2f64b219d5eda4",
1626
+ "bytes": 4747
1627
+ },
1628
+ "v2/durable-core/domain/retrieval-contract.js": {
1629
+ "sha256": "083a2e7d9fbbf4865f3960ad232774fd416b226919c3c39ea36e8ca3102df0cf",
1630
+ "bytes": 12217
1631
+ },
1624
1632
  "v2/durable-core/domain/risk-policy-guardrails.d.ts": {
1625
1633
  "sha256": "4720f9fe6e6ae68d7f989b31070d73661eb96652109dac7d30961e7937ff55e5",
1626
1634
  "bytes": 637
@@ -2430,12 +2438,12 @@
2430
2438
  "bytes": 732
2431
2439
  },
2432
2440
  "v2/projections/resume-ranking.d.ts": {
2433
- "sha256": "b1d9e7d6fb3e59ced42f7c2e5fd9d8f9a18308aa6f4411a8aabf5dc174aa8dad",
2434
- "bytes": 3960
2441
+ "sha256": "3ac0db8e9d154eff9fba21c40eedaf981ea844d3f536f2b69b3840af8653b8f1",
2442
+ "bytes": 4033
2435
2443
  },
2436
2444
  "v2/projections/resume-ranking.js": {
2437
- "sha256": "1b256c992ded9ec52150b229799716d118ca2a3659a0cc523e727cde2ebf7b0c",
2438
- "bytes": 13660
2445
+ "sha256": "5f1ee9888446caa23653543fc8cae69ac4398e73232d71bac3d16722c9cd2158",
2446
+ "bytes": 13596
2439
2447
  },
2440
2448
  "v2/projections/run-context.d.ts": {
2441
2449
  "sha256": "a4d57470a435ac9860f60b3244d1b828853995027cd510d8da42762d21b2a687",
@@ -5,6 +5,7 @@ exports.toPendingStep = toPendingStep;
5
5
  const zod_1 = require("zod");
6
6
  const state_js_1 = require("../domain/execution/state.js");
7
7
  const token_patterns_js_1 = require("../v2/durable-core/tokens/token-patterns.js");
8
+ const constants_js_1 = require("../v2/durable-core/constants.js");
8
9
  const JsonPrimitiveSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]);
9
10
  exports.JsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([JsonPrimitiveSchema, zod_1.z.array(exports.JsonValueSchema), zod_1.z.record(exports.JsonValueSchema)]));
10
11
  exports.WorkflowSummarySchema = zod_1.z.object({
@@ -264,7 +265,7 @@ exports.V2ResumeSessionOutputSchema = zod_1.z.object({
264
265
  sessionTitle: zod_1.z.string().nullable().describe('Human-readable task/session title derived from persisted workflow context or early recap text.'),
265
266
  gitBranch: zod_1.z.string().nullable().describe('Git branch associated with the session, if available.'),
266
267
  resumeToken: zod_1.z.string().regex(token_patterns_js_1.STATE_TOKEN_PATTERN, 'Invalid resumeToken format'),
267
- snippet: zod_1.z.string().max(1024),
268
+ snippet: zod_1.z.string().max(constants_js_1.MAX_RESUME_PREVIEW_BYTES),
268
269
  confidence: zod_1.z.enum(['strong', 'medium', 'weak']).describe('Coarse confidence band for how likely this candidate is the intended session.'),
269
270
  matchExplanation: zod_1.z.string().min(1).describe('Short natural-language explanation of why this candidate ranked here.'),
270
271
  pendingStepId: zod_1.z.string().nullable().describe('The current pending step ID (e.g. "phase-3-implement") if the workflow is in progress. ' +
@@ -15,7 +15,8 @@ export declare const MAX_OBSERVATION_SHORT_STRING_LENGTH = 80;
15
15
  export declare const SESSION_LOCK_RETRY_AFTER_MS = 1000;
16
16
  export declare const DEFAULT_RETRY_AFTER_MS = 1000;
17
17
  export declare const TRUNCATION_MARKER = "\n\n[TRUNCATED]";
18
- export declare const RECOVERY_BUDGET_BYTES = 12288;
18
+ export declare const RECOVERY_BUDGET_BYTES: number;
19
+ export declare const MAX_RESUME_PREVIEW_BYTES: number;
19
20
  export declare const SHA256_DIGEST_PATTERN: RegExp;
20
21
  export declare const DELIMITER_SAFE_ID_PATTERN: RegExp;
21
22
  export declare const EVENT_KIND: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUTONOMY_MODE = exports.ADVANCE_INTENT = exports.MANIFEST_KIND = exports.EDGE_CAUSE = exports.ADVANCE_OUTCOME = exports.ENGINE_STATE = exports.EDGE_KIND = exports.PAYLOAD_KIND = exports.OUTPUT_CHANNEL = exports.EVENT_KIND = exports.DELIMITER_SAFE_ID_PATTERN = exports.SHA256_DIGEST_PATTERN = exports.RECOVERY_BUDGET_BYTES = exports.TRUNCATION_MARKER = exports.DEFAULT_RETRY_AFTER_MS = exports.SESSION_LOCK_RETRY_AFTER_MS = exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = exports.MAX_CONTEXT_DEPTH = exports.MAX_CONTEXT_BYTES = exports.MAX_VALIDATION_SUGGESTIONS_BYTES = exports.MAX_VALIDATION_ISSUES_BYTES = exports.MAX_VALIDATION_SUGGESTION_ITEM_BYTES = exports.MAX_VALIDATION_ISSUE_ITEM_BYTES = exports.MAX_OUTPUT_NOTES_MARKDOWN_BYTES = exports.MAX_DECISION_TRACE_TOTAL_BYTES = exports.MAX_DECISION_TRACE_ENTRY_SUMMARY_BYTES = exports.MAX_DECISION_TRACE_ENTRIES = exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = exports.MAX_BLOCKER_MESSAGE_BYTES = exports.MAX_BLOCKERS = void 0;
3
+ exports.AUTONOMY_MODE = exports.ADVANCE_INTENT = exports.MANIFEST_KIND = exports.EDGE_CAUSE = exports.ADVANCE_OUTCOME = exports.ENGINE_STATE = exports.EDGE_KIND = exports.PAYLOAD_KIND = exports.OUTPUT_CHANNEL = exports.EVENT_KIND = exports.DELIMITER_SAFE_ID_PATTERN = exports.SHA256_DIGEST_PATTERN = exports.MAX_RESUME_PREVIEW_BYTES = exports.RECOVERY_BUDGET_BYTES = exports.TRUNCATION_MARKER = exports.DEFAULT_RETRY_AFTER_MS = exports.SESSION_LOCK_RETRY_AFTER_MS = exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = exports.MAX_CONTEXT_DEPTH = exports.MAX_CONTEXT_BYTES = exports.MAX_VALIDATION_SUGGESTIONS_BYTES = exports.MAX_VALIDATION_ISSUES_BYTES = exports.MAX_VALIDATION_SUGGESTION_ITEM_BYTES = exports.MAX_VALIDATION_ISSUE_ITEM_BYTES = exports.MAX_OUTPUT_NOTES_MARKDOWN_BYTES = exports.MAX_DECISION_TRACE_TOTAL_BYTES = exports.MAX_DECISION_TRACE_ENTRY_SUMMARY_BYTES = exports.MAX_DECISION_TRACE_ENTRIES = exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = exports.MAX_BLOCKER_MESSAGE_BYTES = exports.MAX_BLOCKERS = void 0;
4
4
  exports.MAX_BLOCKERS = 10;
5
5
  exports.MAX_BLOCKER_MESSAGE_BYTES = 512;
6
6
  exports.MAX_BLOCKER_SUGGESTED_FIX_BYTES = 1024;
@@ -18,7 +18,8 @@ exports.MAX_OBSERVATION_SHORT_STRING_LENGTH = 80;
18
18
  exports.SESSION_LOCK_RETRY_AFTER_MS = 1000;
19
19
  exports.DEFAULT_RETRY_AFTER_MS = 1000;
20
20
  exports.TRUNCATION_MARKER = '\n\n[TRUNCATED]';
21
- exports.RECOVERY_BUDGET_BYTES = 12288;
21
+ exports.RECOVERY_BUDGET_BYTES = 24 * 1024;
22
+ exports.MAX_RESUME_PREVIEW_BYTES = 2 * 1024;
22
23
  exports.SHA256_DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
23
24
  exports.DELIMITER_SAFE_ID_PATTERN = /^[a-z0-9_-]+$/;
24
25
  exports.EVENT_KIND = {
@@ -15,11 +15,13 @@ const index_js_2 = require("../schemas/artifacts/index.js");
15
15
  const run_context_js_1 = require("../../projections/run-context.js");
16
16
  const condition_evaluator_js_1 = require("../../../utils/condition-evaluator.js");
17
17
  const context_template_resolver_js_1 = require("./context-template-resolver.js");
18
- function buildNonTipSections(args) {
19
- const sections = [];
18
+ const retrieval_contract_js_1 = require("./retrieval-contract.js");
19
+ function buildNonTipSegments(args) {
20
+ const segments = [];
20
21
  const childSummary = (0, recap_recovery_js_1.buildChildSummary)({ nodeId: args.nodeId, dag: args.run });
21
- if (childSummary) {
22
- sections.push(`### Branch Summary\n${childSummary}`);
22
+ const childSummarySegment = (0, retrieval_contract_js_1.createBranchSummarySegment)(childSummary);
23
+ if (childSummarySegment) {
24
+ segments.push(childSummarySegment);
23
25
  }
24
26
  if (args.run.preferredTipNodeId && args.run.preferredTipNodeId !== String(args.nodeId)) {
25
27
  const downstreamRes = (0, recap_recovery_js_1.collectDownstreamRecap)({
@@ -29,12 +31,15 @@ function buildNonTipSections(args) {
29
31
  outputs: args.outputs,
30
32
  });
31
33
  if (downstreamRes.isOk() && downstreamRes.value.length > 0) {
32
- sections.push(`### Downstream Recap (Preferred Branch)\n${downstreamRes.value.join('\n\n')}`);
34
+ const downstreamSegment = (0, retrieval_contract_js_1.createDownstreamRecapSegment)(downstreamRes.value.join('\n\n'));
35
+ if (downstreamSegment) {
36
+ segments.push(downstreamSegment);
37
+ }
33
38
  }
34
39
  }
35
- return sections;
40
+ return segments;
36
41
  }
37
- function buildAncestrySections(args) {
42
+ function buildAncestrySegments(args) {
38
43
  const ancestryRes = (0, recap_recovery_js_1.collectAncestryRecap)({
39
44
  nodeId: args.nodeId,
40
45
  dag: args.run,
@@ -42,11 +47,12 @@ function buildAncestrySections(args) {
42
47
  includeCurrentNode: false,
43
48
  });
44
49
  if (ancestryRes.isOk() && ancestryRes.value.length > 0) {
45
- return [`### Ancestry Recap\n${ancestryRes.value.join('\n\n')}`];
50
+ const ancestrySegment = (0, retrieval_contract_js_1.createAncestryRecapSegment)(ancestryRes.value.join('\n\n'));
51
+ return ancestrySegment ? [ancestrySegment] : [];
46
52
  }
47
53
  return [];
48
54
  }
49
- function buildFunctionDefsSections(args) {
55
+ function buildFunctionDefsSegments(args) {
50
56
  const funcsRes = (0, function_definition_expander_js_1.expandFunctionDefinitions)({
51
57
  workflow: args.workflow,
52
58
  stepId: args.stepId,
@@ -55,7 +61,8 @@ function buildFunctionDefsSections(args) {
55
61
  });
56
62
  if (funcsRes.isOk() && funcsRes.value.length > 0) {
57
63
  const formatted = funcsRes.value.map(function_definition_expander_js_1.formatFunctionDef).join('\n\n');
58
- return [`### Function Definitions\n\`\`\`\n${formatted}\n\`\`\``];
64
+ const functionDefinitionsSegment = (0, retrieval_contract_js_1.createFunctionDefinitionsSegment)(`\`\`\`\n${formatted}\n\`\`\``);
65
+ return functionDefinitionsSegment ? [functionDefinitionsSegment] : [];
59
66
  }
60
67
  return [];
61
68
  }
@@ -65,12 +72,12 @@ function hasPriorNotesInRun(args) {
65
72
  e.data.outputChannel === constants_js_1.OUTPUT_CHANNEL.RECAP &&
66
73
  e.data.payload.payloadKind === constants_js_1.PAYLOAD_KIND.NOTES);
67
74
  }
68
- function buildRecoverySections(args) {
75
+ function buildRecoverySegments(args) {
69
76
  const isTip = args.run.tipNodeIds.includes(String(args.nodeId));
70
77
  return [
71
- ...(isTip ? [] : buildNonTipSections({ nodeId: args.nodeId, run: args.run, outputs: args.outputs })),
72
- ...buildAncestrySections({ nodeId: args.nodeId, run: args.run, outputs: args.outputs }),
73
- ...buildFunctionDefsSections({
78
+ ...(isTip ? [] : buildNonTipSegments({ nodeId: args.nodeId, run: args.run, outputs: args.outputs })),
79
+ ...buildAncestrySegments({ nodeId: args.nodeId, run: args.run, outputs: args.outputs }),
80
+ ...buildFunctionDefsSegments({
74
81
  workflow: args.workflow,
75
82
  stepId: args.stepId,
76
83
  loopPath: args.loopPath,
@@ -78,52 +85,6 @@ function buildRecoverySections(args) {
78
85
  }),
79
86
  ];
80
87
  }
81
- function trimToUtf8Boundary(bytes) {
82
- const n = bytes.length;
83
- if (n === 0)
84
- return bytes;
85
- let cont = 0;
86
- for (let i = n - 1; i >= 0 && i >= n - 4; i--) {
87
- const b = bytes[i];
88
- if ((b & 192) === 128) {
89
- cont++;
90
- }
91
- else {
92
- break;
93
- }
94
- }
95
- if (cont === 0)
96
- return bytes;
97
- const leadByteIndex = n - cont - 1;
98
- if (leadByteIndex < 0) {
99
- return new Uint8Array(0);
100
- }
101
- const leadByte = bytes[leadByteIndex];
102
- const expectedLen = (leadByte & 128) === 0 ? 1 :
103
- (leadByte & 224) === 192 ? 2 :
104
- (leadByte & 240) === 224 ? 3 :
105
- (leadByte & 248) === 240 ? 4 :
106
- 0;
107
- const actualLen = cont + 1;
108
- if (expectedLen === 0 || expectedLen !== actualLen) {
109
- return bytes.subarray(0, leadByteIndex);
110
- }
111
- return bytes;
112
- }
113
- function applyPromptBudget(combinedPrompt) {
114
- const encoder = new TextEncoder();
115
- const promptBytes = encoder.encode(combinedPrompt);
116
- if (promptBytes.length <= constants_js_1.RECOVERY_BUDGET_BYTES) {
117
- return combinedPrompt;
118
- }
119
- const markerText = constants_js_1.TRUNCATION_MARKER;
120
- const omissionNote = `\nOmitted recovery content due to budget constraints.`;
121
- const suffixBytes = encoder.encode(markerText + omissionNote);
122
- const maxContentBytes = constants_js_1.RECOVERY_BUDGET_BYTES - suffixBytes.length;
123
- const truncatedBytes = trimToUtf8Boundary(promptBytes.subarray(0, maxContentBytes));
124
- const decoder = new TextDecoder('utf-8');
125
- return decoder.decode(truncatedBytes) + markerText + omissionNote;
126
- }
127
88
  function resolveParentLoopStep(workflow, stepId) {
128
89
  for (const step of workflow.definition.steps) {
129
90
  if ((0, workflow_js_1.isLoopStepDefinition)(step) && Array.isArray(step.body)) {
@@ -352,9 +313,8 @@ function renderPendingPrompt(args) {
352
313
  });
353
314
  }
354
315
  const { run, outputs } = projectionsRes.value;
355
- const sections = buildRecoverySections({
316
+ const segments = buildRecoverySegments({
356
317
  nodeId: args.nodeId,
357
- dag: run,
358
318
  run,
359
319
  outputs,
360
320
  workflow: args.workflow,
@@ -362,12 +322,14 @@ function renderPendingPrompt(args) {
362
322
  loopPath: args.loopPath,
363
323
  functionReferences,
364
324
  });
365
- if (sections.length === 0) {
325
+ if (segments.length === 0) {
366
326
  return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, agentRole, requireConfirmation });
367
327
  }
368
328
  const recoveryHeader = cleanResponseFormat ? 'Your previous work:' : '## Recovery Context';
369
- const recoveryText = `${recoveryHeader}\n\n${sections.join('\n\n')}`;
370
- const combinedPrompt = `${enhancedPrompt}\n\n${recoveryText}`;
371
- const finalPrompt = applyPromptBudget(combinedPrompt);
329
+ const recoveryText = (0, retrieval_contract_js_1.renderBudgetedRehydrateRecovery)({
330
+ header: recoveryHeader,
331
+ segments,
332
+ }).text;
333
+ const finalPrompt = `${enhancedPrompt}\n\n${recoveryText}`;
372
334
  return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: finalPrompt, agentRole, requireConfirmation });
373
335
  }
@@ -0,0 +1,105 @@
1
+ export type RetrievalPackSurface = 'rehydrate';
2
+ export type ResumePreviewSurface = 'resume_preview';
3
+ export type RetrievalPackTier = 'structural_context' | 'durable_recap' | 'reference_material';
4
+ export type ResumePreviewTier = 'identity_context' | 'durable_recap';
5
+ export interface RetrievalPackTierDefinition {
6
+ readonly tier: RetrievalPackTier;
7
+ readonly purpose: string;
8
+ readonly priority: number;
9
+ readonly retention: 'core' | 'tail';
10
+ }
11
+ export interface ResumePreviewTierDefinition {
12
+ readonly tier: ResumePreviewTier;
13
+ readonly purpose: string;
14
+ readonly priority: number;
15
+ readonly maxBytes: number;
16
+ }
17
+ export interface RetrievalPackTruncationPolicy {
18
+ readonly mode: 'drop_lower_tiers_then_global_utf8_trim';
19
+ readonly budgetScope: 'shared_recovery_prompt';
20
+ readonly antiReconstructionRule: 'select_order_and_compress_explicit_facts_only';
21
+ }
22
+ export interface RetrievalPackContract {
23
+ readonly surface: RetrievalPackSurface;
24
+ readonly tiers: readonly RetrievalPackTierDefinition[];
25
+ readonly truncation: RetrievalPackTruncationPolicy;
26
+ }
27
+ export interface ResumePreviewContract {
28
+ readonly surface: ResumePreviewSurface;
29
+ readonly tiers: readonly ResumePreviewTierDefinition[];
30
+ readonly budgetBytes: number;
31
+ }
32
+ export interface BranchSummarySegment {
33
+ readonly kind: 'branch_summary';
34
+ readonly tier: 'structural_context';
35
+ readonly source: 'deterministic_structure';
36
+ readonly title: 'Branch Summary';
37
+ readonly body: string;
38
+ }
39
+ export interface DownstreamRecapSegment {
40
+ readonly kind: 'downstream_recap';
41
+ readonly tier: 'structural_context';
42
+ readonly source: 'explicit_durable_fact';
43
+ readonly title: 'Downstream Recap (Preferred Branch)';
44
+ readonly body: string;
45
+ }
46
+ export interface AncestryRecapSegment {
47
+ readonly kind: 'ancestry_recap';
48
+ readonly tier: 'durable_recap';
49
+ readonly source: 'explicit_durable_fact';
50
+ readonly title: 'Ancestry Recap';
51
+ readonly body: string;
52
+ }
53
+ export interface FunctionDefinitionsSegment {
54
+ readonly kind: 'function_definitions';
55
+ readonly tier: 'reference_material';
56
+ readonly source: 'workflow_definition';
57
+ readonly title: 'Function Definitions';
58
+ readonly body: string;
59
+ }
60
+ export type RetrievalPackSegment = BranchSummarySegment | DownstreamRecapSegment | AncestryRecapSegment | FunctionDefinitionsSegment;
61
+ export interface RetrievalPackRenderResult {
62
+ readonly text: string;
63
+ readonly includedTiers: readonly RetrievalPackTier[];
64
+ readonly omittedTierCount: number;
65
+ readonly truncatedWithinTier: boolean;
66
+ }
67
+ export interface SessionTitlePreviewSegment {
68
+ readonly kind: 'session_title_preview';
69
+ readonly tier: 'identity_context';
70
+ readonly source: 'persisted_context';
71
+ readonly body: string;
72
+ }
73
+ export interface RecapPreviewSegment {
74
+ readonly kind: 'recap_preview';
75
+ readonly tier: 'durable_recap';
76
+ readonly source: 'explicit_durable_fact';
77
+ readonly body: string;
78
+ }
79
+ export type ResumePreviewSegment = SessionTitlePreviewSegment | RecapPreviewSegment;
80
+ export type ResumePreviewText = string & {
81
+ readonly __brand: 'ResumePreviewText';
82
+ };
83
+ export interface ResumePreviewRenderResult {
84
+ readonly text: ResumePreviewText;
85
+ readonly includedTiers: readonly ResumePreviewTier[];
86
+ }
87
+ export declare const REHYDRATE_RETRIEVAL_CONTRACT: RetrievalPackContract;
88
+ export declare const RESUME_PREVIEW_CONTRACT: ResumePreviewContract;
89
+ export declare function createBranchSummarySegment(body: string): BranchSummarySegment | null;
90
+ export declare function createDownstreamRecapSegment(body: string): DownstreamRecapSegment | null;
91
+ export declare function createAncestryRecapSegment(body: string): AncestryRecapSegment | null;
92
+ export declare function createFunctionDefinitionsSegment(body: string): FunctionDefinitionsSegment | null;
93
+ export declare function createSessionTitlePreviewSegment(body: string): SessionTitlePreviewSegment | null;
94
+ export declare function createRecapPreviewSegment(body: string): RecapPreviewSegment | null;
95
+ export declare function compareRetrievalPackSegments(a: RetrievalPackSegment, b: RetrievalPackSegment): number;
96
+ export declare function orderRetrievalPackSegments(segments: readonly RetrievalPackSegment[]): readonly RetrievalPackSegment[];
97
+ export declare function renderRetrievalPackSections(segments: readonly RetrievalPackSegment[]): readonly string[];
98
+ export declare function renderBudgetedResumePreview(args: {
99
+ readonly segments: readonly ResumePreviewSegment[];
100
+ readonly focusTerms?: readonly string[];
101
+ }): ResumePreviewRenderResult;
102
+ export declare function renderBudgetedRehydrateRecovery(args: {
103
+ readonly header: string;
104
+ readonly segments: readonly RetrievalPackSegment[];
105
+ }): RetrievalPackRenderResult;