MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / dispatch_turn_event

Function dispatch_turn_event

atomic-cli/src/commands/rpc.rs:7696–7728  ·  view source on GitHub ↗

Dispatch one typed TurnEvent through the service area — the SAME handler both transports serve: local runs libatomic's `ProvenanceImpl::dispatch_turn_event` in this process (the orchestrator with the in-process journal core), reactor dispatches over the socket (D4 start-or-retry). There is no unreachable fallback path anymore — a failure is a real failure and surfaces to the caller.

(
    root: &Path,
    event: &atomic_agent::event::TurnEvent,
    agent_id: &str,
    agent_display: &str,
    agent_identity: Option<String>,
    hook_context: &atomic_agent::hook_log::HookContext,

Source from the content-addressed store, hash-verified

7694/// (D4 start-or-retry). There is no unreachable fallback path anymore —
7695/// a failure is a real failure and surfaces to the caller.
7696pub fn dispatch_turn_event(
7697 root: &Path,
7698 event: &atomic_agent::event::TurnEvent,
7699 agent_id: &str,
7700 agent_display: &str,
7701 agent_identity: Option<String>,
7702 hook_context: &atomic_agent::hook_log::HookContext,
7703) -> CliResult<crate::commands::agent::receive::ReceiveResult> {
7704 let Some(session) = Service::open_root(root)? else {
7705 return Err(CliError::InvalidArgument {
7706 message: format!("'{}' is not an Atomic repository", root.display()),
7707 });
7708 };
7709 let response = session.dispatch_turn_event(pb::DispatchTurnEventRequest {
7710 repository: Some(session.reference.clone()),
7711 meta: request_meta(),
7712 agent_id: agent_id.to_string(),
7713 agent_display_name: Some(agent_display.to_string()),
7714 agent_identity,
7715 event: Some(turn_event_body(event, hook_context)),
7716 })?;
7717 Ok(crate::commands::agent::receive::ReceiveResult {
7718 session_id: response.session_id,
7719 recorded: response.recorded,
7720 change_hash: response.change_hash.as_ref().map(|hash| {
7721 let bytes: [u8; 32] = hash.value.clone().try_into().unwrap_or([0; 32]);
7722 Merkle(bytes).to_base32()
7723 }),
7724 view: response.view,
7725 files: response.files,
7726 warnings: response.warnings,
7727 })
7728}
7729
7730fn turn_event_body(
7731 event: &atomic_agent::event::TurnEvent,

Callers 1

runMethod · 0.85

Calls 7

turn_event_bodyFunction · 0.85
MerkleClass · 0.85
as_refMethod · 0.80
request_metaFunction · 0.70
dispatch_turn_eventMethod · 0.45
cloneMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected