refactor(context): define TurnContext value type for phase-boundary handoff (#3510)#3514
Merged
refactor(context): define TurnContext value type for phase-boundary handoff (#3510)#3514
Conversation
…andoff (#3510) Move TurnId from zeph-core to zeph-context and introduce TurnContext — a Send + 'static owned value type that bundles per-turn invariants (id, cancel token, timeout config, tool allowlist) needed by every agent phase. TurnContext is designed to cross crate boundaries in Phase 2 of the Agent decomposition (#3498) without requiring Arc<Mutex<Agent>>. Turn in zeph-core now embeds TurnContext; begin_turn constructs it from runtime config. - Add zeph-context::turn_context module with TurnId and TurnContext - Move TurnId from zeph-core::agent::turn; re-export for backward compat - Turn embeds pub context: TurnContext, getters delegate id()/cancel_token() - begin_turn constructs TurnContext from runtime.config.timeouts + fresh token - tool_allowlist: None scaffold with TODO(#3498) for Phase 2 wiring - Compile-time Send + 'static assert via const block - TurnId::next uses saturating_add to avoid debug/release divergence - SDD spec at specs/049-agent-decomposition/turn-context.md Closes #3510
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TurnContextinzeph-context— aSend + 'staticowned value type carrying per-turn invariants (TurnId,CancellationToken,TimeoutConfig,tool_allowlist) across theloop/compose/persistphase boundaryTurnIdfromzeph-core::agent::turntozeph-context::turn_context; re-exported fromzeph-corefor backward compatibilityTurninzeph-corenow embedspub context: TurnContext;id()andcancel_token()getters delegate to itAgent::begin_turnconstructsTurnContextfromruntime.config.timeouts(Copy) and a freshCancellationTokenspecs/049-agent-decomposition/turn-context.mdCloses
Closes #3510 — P2-prereq-3 for Agent god-object decomposition Phase 2 (#3498)
Test plan
cargo nextest run --config-file .github/nextest.toml -p zeph-context -p zeph-core --lib— 1465 tests passcargo +nightly fmt --check— cleancargo clippy --all-targets --all-features --workspace -- -D warnings— zero errorsSend + 'staticassertion viaconst _: () = { ... }blockturn_context.rsincludingturn_context_clone_shares_cancel_token