Repository navigation
feat: capture OpenShell request receipts for CLI model calls - #1780
Conversation
Signed-off-by: Alex Fournier <[email protected]>
Signed-off-by: Alex Fournier <[email protected]>
|
No actionable comments were generated in the recent review. WalkthroughManaged gateway and worker response paths now observe eligible OpenShell request receipts. The change adds request-ID validation and event recording, integration tests for receipt behavior, and gateway reference updates. ChangesOpenShell request receipts
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Gateway as forward_upstream_request
participant Upstream
participant Observer as openshell_receipts::observe
participant Continuation as Middleware continuation context
Gateway->>Upstream: Forward managed request
Upstream-->>Gateway: Response headers and status
Gateway->>Observer: Observe response headers and status
Observer->>Continuation: Emit receipt event when eligible
Merge Risk:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1780 +/- ##
==========================================
+ Coverage 94.11% 94.13% +0.02%
==========================================
Files 538 539 +1
Lines 170359 171528 +1169
Branches 173 173
==========================================
+ Hits 160320 161460 +1140
- Misses 10038 10067 +29
Partials 1 1
... and 15 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Signed-off-by: Alex Fournier <[email protected]>
Overview
Connect a CLI model call in Relay to the OpenShell security records for the same HTTP request, without a harness-specific adapter.
In a Codex/Claude-style CLI deployment, Relay records the model call while OpenShell separately records its enforcement decisions. If a request fails, the Relay trace alone does not identify the corresponding OpenShell records. This PR captures the request ID OpenShell returns and records it under the correct Relay model call, so operators can match the two.
Details
x-openshell-request-id.openshell.request.receiptmark under the owning model call. Its payload contains onlyrequest_idandhttp_status.metadata.correlation_uidin OpenShell's OCSF records. For example, this lets someone investigating a failed model call find what OpenShell allowed, changed or blocked.The header is captured before reading the body, including on HTTP errors. The receipt remains available if the body subsequently fails or is cancelled. Missing, malformed or duplicate headers produce no mark and leave response handling unchanged.
The OCSF records stay in OpenShell. This adds a request-ID join, not automatic trace stitching or OCSF ingestion into Relay. The header is an unverified correlation hint, not proof of authorization, upstream execution or completed delivery.
Scope:
full/openinferencetrace projections retain marks;gen_aiomits them.A separate prerequisite commit corrects an existing one-line test import on main (
nemo_relay::loggingtonemo_relay_logging), with no production change.Validation: pre-commit checks passed, including Clippy and workspace checks.
just test-rustpassed: 6,922 tests, four existing skips, retries disabled. No new live OpenShell run was performed on this refreshed source.Where should the reviewer start?
Start with
crates/cli/src/openshell_receipts.rsfor header validation and mark creation. Then check the response hooks ingateway/mod.rsanddaemon/worker/managed.rs. The daemon context binding keeps each receipt attached to its own model call, including under concurrency.Tests cover receipt ownership and payload, HTTP errors, real stream truncation, absent headers, and unchanged daemon trace-header handling. Header-validation edge cases are kept in the compact parser test.
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit