Skip to content

refactor: brand the request id - #675

Open
jakedipity wants to merge 2 commits into
nightlyfrom
jakedipity/request-id-newtype
Open

jakedipity wants to merge 2 commits into
nightlyfrom
jakedipity/request-id-newtype

Conversation

@jakedipity

Copy link
Copy Markdown
Collaborator

RequestId becomes a newtype over String instead of a type alias, so a bare string can no longer stand in for a request id. It threads through SSE routing, the tool-event broker, MCP cancellation, HITL approval gates, the session store, and the scratchpad's per-request directory.

The brokers and the cancellation registry key their maps by RequestId rather than String. In mcp/client.rs, rmcp's own RequestId is imported as McpRequestId, so the HTTP request id and the MCP protocol request id are no longer the same type in signatures that take both.

The webhook payload and stored approval records keep their bare-string shape, which serde(transparent) guarantees and a record test now pins.

@jakedipity
jakedipity requested a review from a team as a code owner September 9, 2026 20:11
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown

Greptile Summary

The PR replaces bare request-ID strings with a dedicated RequestId newtype while preserving existing serialized record and webhook shapes.

  • Threads the branded identifier through streaming, orchestration, HITL, MCP cancellation, brokers, session storage, and scratchpad paths.
  • Keys request-scoped registries and brokers by RequestId.
  • Aliases rmcp’s protocol identifier as McpRequestId where both identifier domains appear.
  • Adds coverage pinning the persisted request ID to a bare JSON string.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/aura/src/config.rs Defines the branded request identifier and its transparent string representation.
crates/aura/src/mcp/client.rs Separates Aura request identifiers from rmcp protocol request identifiers in MCP operations.
crates/aura/src/request_cancellation.rs Migrates cancellation-registry keys and APIs from strings to RequestId.
crates/aura/src/tool_event_broker.rs Migrates request-scoped tool-event broker keys and calls to the branded identifier.
crates/aura/src/session_store/record.rs Stores RequestId directly and pins its enduring bare-string JSON contract with a focused test.
crates/aura-web-server/src/streaming/handlers.rs Threads the branded request identifier through the web server’s streaming request lifecycle.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    HTTP[HTTP / A2A request] --> RID[RequestId newtype]
    RID --> STREAM[Streaming and SSE routing]
    RID --> HITL[HITL approval gates]
    RID --> BROKERS[Progress and tool-event brokers]
    RID --> CANCEL[Request and MCP cancellation]
    RID --> STORE[Session and approval storage]
    RID --> SCRATCH[Per-request scratchpad]
    STORE -->|serde transparent| JSON[Bare-string persisted shape]
Loading

Reviews (4): Last reviewed commit: "refactor: brand the request id" | Re-trigger Greptile

Comment thread crates/aura/src/session_store/record.rs Outdated
@jakedipity
jakedipity force-pushed the jakedipity/agent-event-schema branch from 14cb706 to 0de55be Compare September 9, 2026 20:27
@jakedipity
jakedipity force-pushed the jakedipity/request-id-newtype branch from d7cdb5a to 7d9cf2a Compare September 9, 2026 20:28
dhable
dhable previously approved these changes Sep 9, 2026
@jakedipity
jakedipity force-pushed the jakedipity/agent-event-schema branch 3 times, most recently from 0a897b9 to d3df8a6 Compare September 10, 2026 17:14
@jakedipity
jakedipity force-pushed the jakedipity/request-id-newtype branch from 7d9cf2a to 4827e82 Compare September 10, 2026 18:11
Adds aura_events::agent, the event vocabulary a running agent emits,
and aura::agent_events, which republishes it onto the request-scoped
brokers so consumers are unaffected. A differential test asserts both
paths produce identical SSE.

The schema is typed with domain value types rather than bare primitives:
ToolCallId, ToolName, TokenCount, TokenUsage, and Progress. The
tool_event_broker's ToolCallId/ToolName aliases resolve to the newtypes,
so publish_tool_requested and publish_tool_start no longer take
interchangeable strings positionally, publish_tool_usage takes one
TokenUsage instead of three bare u64s, and ProgressNotification carries
the current/total pair as a single value that owns percent(). Scratchpad
token counts move from usize to u64 with every other count.

No producer emits the schema yet; agent_events_enabled reads
AURA_AGENT_EVENTS and is the seam producers will gate on.

Ref: #618
Signed-off-by: Jacob Hull <jacob@planethull.com>
@jakedipity
jakedipity force-pushed the jakedipity/agent-event-schema branch from d3df8a6 to daccaa7 Compare September 10, 2026 18:15
RequestId becomes a newtype over String instead of a type alias, so a
bare string can no longer stand in for a request id. It threads through
SSE routing, the tool-event broker, MCP cancellation, HITL approval
gates, the session store, and the scratchpad's per-request directory.

The brokers and the cancellation registry key their maps by RequestId
rather than String. In mcp/client.rs, rmcp's own RequestId is imported
as McpRequestId, so the HTTP request id and the MCP protocol request id
are no longer the same type in signatures that take both.

The webhook payload and stored approval records keep their bare-string
shape, which serde(transparent) guarantees and a record test now pins.

Signed-off-by: Jacob Hull <jacob@planethull.com>
@jakedipity
jakedipity force-pushed the jakedipity/request-id-newtype branch from 4827e82 to b78a932 Compare September 10, 2026 18:31
@jakedipity
jakedipity force-pushed the jakedipity/agent-event-schema branch from daccaa7 to 55faa90 Compare September 10, 2026 21:24
@jakedipity jakedipity closed this Sep 11, 2026
@jakedipity jakedipity reopened this Sep 11, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 11, 2026

@Shearerbeard Shearerbeard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only feedback here is that lib.rs is to general - if were starting to consolidate code around building our domain types and events lets just call it domain

Shearerbeard
Shearerbeard previously approved these changes Sep 16, 2026

@Shearerbeard Shearerbeard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good - as we progress we might have to better module classify identifiers a cross application concerns (like RequestId) vs agent specific new types like AgentId. There are probably a few cross cutting concerns to belong in a root domain vs a specific one. Also a good place to start looking for duplicated construction and validation code if it exists (I don't see that here - just the kind of thing I like to think ahead on when designing by types)

@jakedipity
jakedipity force-pushed the jakedipity/agent-event-schema branch 2 times, most recently from 30b2685 to 8c3a670 Compare September 17, 2026 19:07
Base automatically changed from jakedipity/agent-event-schema to nightly September 17, 2026 19:55
@jakedipity
jakedipity dismissed stale reviews from Shearerbeard and dhable September 17, 2026 19:55

The base branch was changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants