You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`CompileResult.Source` is an immutable freeze of input messages (before pipeline mutations). `CompileResult.Introduced` captures pre-transform baselines for payload-born IDs (registered post-deferred, before hooks/patches). Use `DerivePersistenceProjection` for checkpoint persistence instead of parsing `Transformations`.
95
+
`CompileResult.Source` is an immutable freeze of normalized input messages (before pipeline mutations). `CompileResult.NormalizedSnapshot` and `CompileResult.Writeback` expose durable ID normalization and checkpoint writeback intent. `CompileResult.Introduced` captures pre-transform baselines for payload-born IDs (registered post-deferred, before hooks/patches). Use `DerivePersistenceProjection` for checkpoint persistence instead of parsing `Transformations`.
Observer telemetry (`WithObserver`, `WithBudgetObserver`) behaves the same on `Compile` and `CompileSnapshot`.
117
133
118
-
## Views (non-mutating render)
134
+
## Named Compile Targets
119
135
120
-
Built-in views render all segments (system → history → tools → memory):
136
+
Use compile targets when a classifier, router, evaluator, or secondary provider needs a projection from the same normalized snapshot, current turn, artifacts, transforms, and budgeted history:
`CompileProjection` includes rendered `Text`, typed `Messages`, transform records, participating artifact IDs, frozen `Source` (normalized request before pipeline mutations), and `InputSnapshot` (the compiled snapshot used as the target input). A target `View` is a built-in rendered view and is mutually exclusive with `SourceSegment`, `Budget`, and `Formatter`; use segment targets when target-local budget or formatting is required.
152
+
153
+
## Views (non-mutating render)
154
+
155
+
`Render` / `RenderView` remain available for read-only snapshot inspection. They do not run the compile pipeline, do not apply transform hooks, and do not see `CurrentTurn`.
156
+
157
+
Built-in views render all stored segments (system → history → tools → memory):
`Render` / `RenderView` never mutate the input snapshot. They do **not** apply transform hooks — use `Engine.Compile()` when you need redaction or truncation before sending to an LLM.
142
-
143
-
Built-in view names (`llm_xml`, `flat_classifier`) are resolved before the custom registry; `WithNamedView("llm_xml", …)` does not override the built-in formatter. Custom views join segment messages as plain text (not LLMXML).
165
+
For classifier/router/evaluator projections, prefer named compile targets. `RenderView` is for already-materialized snapshot inspection and legacy callers.
Patches and `Pending` are compile-only. `DerivePersistenceProjection` excludes evicted/truncated messages and returns Source originals for formatted messages. If `Pending` alone exceeds `TokenLimit`, compile returns `ErrPendingExceedsBudget`.
250
272
251
-
## Ephemeral patches
273
+
## Current Turn and Identity
274
+
275
+
Use `CurrentTurn` for active input that needs different provider-facing and checkpoint-facing representations:
`MessageSelector.Position`: zero value is `PositionFirst`; an unrecognized value defaults to `PositionLast`. Pre-budget patches apply to non-history segments; post-budget patches apply to history (including merged `Pending`).
292
+
`CurrentTurnPersistRaw` stores the original input, `CurrentTurnPersistPromptSafe` stores the prompt-safe representation, and `CurrentTurnPersistNone` skips current-turn checkpoint persistence. When `RequireDurableIdentity` is true, missing message IDs require an explicit `IdentityPolicy`; otherwise compile fails with `ErrMissingIdentityPolicy`.
293
+
294
+
## Low-Level Ephemeral Patches
295
+
296
+
Prefer `CurrentTurn` for prompt-only current-turn redaction. `WithEphemeralPatch` remains a low-level escape hatch for compile-only replacement of already-addressable messages in internal pipelines. It is not the durable current-turn contract.
297
+
298
+
Pre-budget patches apply to non-history segments; post-budget patches apply to history.
267
299
268
300
## Segment formatters
269
301
@@ -308,7 +340,7 @@ engine := contexty.NewEngine(
308
340
309
341
Tool-call turns are truncated atomically by default (`KeepTurnAtomicity` defaults to `true`). Setting `KeepTurnAtomicity` to `false` enables fast-path index truncation at the strategy level; `BudgetPipeline` still repairs orphan tool pairs via `enforceToolPairAtomicity`.
310
342
311
-
When using a custom `Summarizer`, return a summary with a **new**`Message.ID`. Reusing a truncated message ID prevents the summary from appearing in `DerivePersistenceProjection`.
343
+
When using a custom `Summarizer`, do not reuse a truncated message ID for the summary. In durable compile flows, leave the summary ID empty and let `IdentityPolicy` assign it.
312
344
313
345
**Canonical tool-turn layout** for atomic truncation: `RoleAssistant` with `ToolCallPart`(s), then `RoleTool` message(s) with matching `ToolResultPart.ToolCallID`. Use `ToolRoundFromMessages` / `ToolRound.Validate` for first-class validation. `ToolTurnUsesCanonicalLayout` remains a lightweight layout predicate.
314
346
@@ -335,7 +367,33 @@ _ = result
335
367
_ = err
336
368
```
337
369
338
-
Turn-bound retrieval artifacts are visible only when `CompileRequest.TurnID` matches `BoundTurnID`. Ownership is `OwnerRef`, a typed `SourceRef` owned by the host application. Ephemeral artifacts and `ArtifactPersistenceSkip` are omitted from checkpoints; `ArtifactPersistenceStore` forces checkpoint persistence.
370
+
Turn-bound retrieval artifacts are visible only when `CompileRequest.TurnID` matches `BoundTurnID`. Ownership is `OwnerRef`, a typed `SourceRef` owned by the host application. Ephemeral artifacts and `ArtifactPersistenceSkip` are omitted from checkpoints; `ArtifactPersistenceStore` forces checkpoint persistence. For artifacts, `PolicyReplaceByOrigin` replaces stale artifacts with the same kind/type plus owner/source refs even when the new artifact uses a different `ID`.
371
+
372
+
Use typed artifact codecs when the host needs structured values to round-trip without manually packing domain data into a raw payload container:
0 commit comments