Extract guardian transcript selection into guardian-context (#45417)

## What changed

Move full/delta transcript selection into the shared `TranscriptMode::select` API and use it when building guardian prompts. Export `TranscriptCursor`, `TranscriptMode`, and `TranscriptSelection` from `codex-guardian-context`.

Preserve full-transcript fallback when the history version changes or the saved cursor exceeds the collected entry count. Select entries before profile retention, preserving their numbering and returning a proposed cursor that counts all collected entries. Hosts remain responsible for committing and invalidating cursors.

## Testing

Add a regression test verifying that sliding-window retention preserves the collected-entry cursor and that an appended entry is selected and numbered correctly in the next delta.

GitOrigin-RevId: a2192c08e23c18302b0105ba47aeb2780eb4a015
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-14 12:52:16 +00:00
1 parent 99cda7a9a5
commit b3e0c49dfb
4 files changed
+142 -48

No files matched your search

+6 -2
View File
@@ -4,8 +4,8 @@
//! without section composition.
//! Contributor failures abort collection without returning partial context.
//! Sections preserve source-specific evidence and share prompt framing, while
//! profiles retain the consumer-specific transcript policy. Hosts own full/delta
//! cursors, compaction and request lifecycles.
//! profiles retain the consumer-specific transcript policy. Shared full/delta selection
//! proposes cursors; hosts own their admission, compaction and request lifecycles.
//! Registered contributors declare their scope once and are collected only for
//! matching context consumers. History and collection settings are borrowed for
//! each request so the default registry can be reused without retaining state.
@@ -52,6 +52,7 @@ pub use enforcement::HistoryTruncation;
pub(crate) use enforcement::Retention;
mod budget;
mod composition;
mod cursor;
pub use budget::DEFAULT_MAX_INPUT_TOKENS;
pub use budget::REQUEST_TOKENS_BOUNDARIES;
pub use budget::REQUEST_TOKENS_METRIC;
@@ -61,6 +62,9 @@ pub use budget::SECTION_COST_METRIC;
pub use budget::SectionCost;
pub use budget::effective_input_token_limit;
pub use budget::estimate_input_tokens;
pub use cursor::TranscriptCursor;
pub use cursor::TranscriptMode;
pub use cursor::TranscriptSelection;
mod profile;
pub use composition::CollectedContext;
pub use composition::ComposedContext;