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

Function dispatch_turn_event

atomic-cli/src/commands/rpc.rs:7784–7816  ·  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

7782/// (D4 start-or-retry). There is no unreachable fallback path anymore —
7783/// a failure is a real failure and surfaces to the caller.
7784pub fn dispatch_turn_event(
7785 root: &Path,
7786 event: &atomic_agent::event::TurnEvent,
7787 agent_id: &str,
7788 agent_display: &str,
7789 agent_identity: Option<String>,
7790 hook_context: &atomic_agent::hook_log::HookContext,
7791) -> CliResult<crate::commands::agent::receive::ReceiveResult> {
7792 let Some(session) = Service::open_root(root)? else {
7793 return Err(CliError::InvalidArgument {
7794 message: format!("'{}' is not an Atomic repository", root.display()),
7795 });
7796 };
7797 let response = session.dispatch_turn_event(pb::DispatchTurnEventRequest {
7798 repository: Some(session.reference.clone()),
7799 meta: request_meta(),
7800 agent_id: agent_id.to_string(),
7801 agent_display_name: Some(agent_display.to_string()),
7802 agent_identity,
7803 event: Some(turn_event_body(event, hook_context)),
7804 })?;
7805 Ok(crate::commands::agent::receive::ReceiveResult {
7806 session_id: response.session_id,
7807 recorded: response.recorded,
7808 change_hash: response.change_hash.as_ref().map(|hash| {
7809 let bytes: [u8; 32] = hash.value.clone().try_into().unwrap_or([0; 32]);
7810 Merkle(bytes).to_base32()
7811 }),
7812 view: response.view,
7813 files: response.files,
7814 warnings: response.warnings,
7815 })
7816}
7817
7818fn turn_event_body(
7819 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