Skip to content

refactor(context): define TurnContext value type for phase-boundary handoff (#3510)#3514

Merged
bug-ops merged 1 commit intomainfrom
turncontext-value-type
Apr 27, 2026
Merged

refactor(context): define TurnContext value type for phase-boundary handoff (#3510)#3514
bug-ops merged 1 commit intomainfrom
turncontext-value-type

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 27, 2026

Summary

  • Defines TurnContext in zeph-context — a Send + 'static owned value type carrying per-turn invariants (TurnId, CancellationToken, TimeoutConfig, tool_allowlist) across the loop/compose/persist phase boundary
  • Moves TurnId from zeph-core::agent::turn to zeph-context::turn_context; re-exported from zeph-core for backward compatibility
  • Turn in zeph-core now embeds pub context: TurnContext; id() and cancel_token() getters delegate to it
  • Agent::begin_turn constructs TurnContext from runtime.config.timeouts (Copy) and a fresh CancellationToken
  • Adds SDD spec at specs/049-agent-decomposition/turn-context.md

Closes

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 pass
  • cargo +nightly fmt --check — clean
  • cargo clippy --all-targets --all-features --workspace -- -D warnings — zero errors
  • Compile-time Send + 'static assertion via const _: () = { ... } block
  • 5 new unit tests in turn_context.rs including turn_context_clone_shares_cancel_token

…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
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate dependencies Dependency updates labels Apr 27, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 27, 2026 00:54
@github-actions github-actions Bot added refactor Code refactoring without functional changes size/L Large PR (201-500 lines) labels Apr 27, 2026
@bug-ops bug-ops merged commit 3f099af into main Apr 27, 2026
32 checks passed
@bug-ops bug-ops deleted the turncontext-value-type branch April 27, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(core): define TurnContext value type across loop/compose/persist phases (P2-prereq-3)

1 participant