Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions crates/tracedecay-contracts/src/request_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ impl GlobalRequestSurface {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GlobalOpaqueIdentityKind {
DashboardPayloadGcPreview,
ExplorerRun,
GitIndexPreview,
MemoryOperation,
}
Expand All @@ -75,7 +74,6 @@ impl GlobalOpaqueIdentityKind {
const fn prefix(self) -> &'static str {
match self {
Self::DashboardPayloadGcPreview => "payload-gc",
Self::ExplorerRun => "explorer-run",
Self::GitIndexPreview => "preview",
Self::MemoryOperation => "generated",
}
Expand Down
74 changes: 73 additions & 1 deletion crates/tracedecay-dashboard-api/src/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ async fn unavailable_savings_is_an_enveloped_unknown_read() {
}

#[test]
fn a_selected_project_answers_feedback_and_work_reads_and_nothing_else_by_post() {
fn a_selected_project_answers_application_reads_without_mutations() {
assert!(is_selected_project_event_delivery_ack(
&Method::POST,
"events/delivery-ack"
Expand Down Expand Up @@ -1696,3 +1696,75 @@ fn a_selected_project_answers_feedback_and_work_reads_and_nothing_else_by_post()
}
}
}

#[tokio::test]
async fn foreign_project_explorer_stream_is_refused() {
use std::sync::atomic::AtomicUsize;

struct CountedSessions(Arc<AtomicUsize>);
impl DashboardLcmReadPortV1 for CountedSessions {
fn read(
&self,
_control: DashboardHttpRequestControlV1,
_project_id: Option<&str>,
_request: DashboardLcmReadRequestV1,
) -> DashboardLcmReadFutureV1<'_> {
self.0.fetch_add(1, Ordering::SeqCst);
Box::pin(async {
DashboardLcmReadOutcomeV1::NotReady {
state: crate::DashboardLcmReadStateV1::Unavailable,
reason: "source is not mounted".to_owned(),
}
})
}
}

let mut fixture = DashboardStateFixture::open("project.dashboard-explorer-gateway").await;
let reads = Arc::new(AtomicUsize::new(0));
fixture.state.lcm_read_authority = Some(Arc::new(CountedSessions(Arc::clone(&reads))));
let app = router_with_active_application(fixture.state, None, Router::new());
let body = json!({ "query": "fixture", "limit": 1, "offset": 0 }).to_string();
let request = |project: &str| {
Request::builder()
.method(Method::POST)
.uri(format!("/api/projects/{project}/explorer/queries"))
.header(header::CONTENT_TYPE, "application/json")
.extension(DashboardHttpRequestControlV1::test_fixture(
"explorer-gateway",
))
.body(Body::from(body.clone()))
.expect("explorer POST")
};
let foreign = app
.clone()
.oneshot(request("project.dashboard-foreign"))
.await
.expect("gateway");
assert_eq!(foreign.status(), StatusCode::OK);
let payload = axum::body::to_bytes(foreign.into_body(), 1 << 20)
.await
.expect("refusal");
assert!(!String::from_utf8_lossy(&payload).contains("data:"));
let denial: Value = serde_json::from_slice(&payload).expect("typed registry denial");
assert_eq!(denial["domain_state"], "unknown");
assert_eq!(
reads.load(Ordering::SeqCst),
0,
"foreign scope never reads active sessions"
);

let admitted = app
.oneshot(request("project.dashboard-explorer-gateway"))
.await
.expect("active project route");
assert_eq!(admitted.status(), StatusCode::OK);
let frames = axum::body::to_bytes(admitted.into_body(), 1 << 20)
.await
.expect("SSE body");
assert!(String::from_utf8_lossy(&frames).contains("\"kind\":\"source\""));
assert_eq!(
reads.load(Ordering::SeqCst),
1,
"positive control reaches source read"
);
}
4 changes: 2 additions & 2 deletions crates/tracedecay-dashboard-api/src/contract_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use super::automation_skills_api::AutomationSkillsPayloadV1;
use super::code_read_api::RevisionPairUnionLayoutV1;
use super::delivery_api::{DeliveryInboxV1, DeliveryOverviewV1};
use super::doctor_findings_api::DoctorFindingsPayloadV1;
use super::explorer_api::{ExplorerQueryRunV1, ExplorerReadContextV1, ExplorerSessionSizeV1};
use super::explorer_api::{ExplorerQueryEventV1, ExplorerReadContextV1, ExplorerSessionSizeV1};
use super::graph_service::{
GraphNeighborsPayloadV1, GraphNodePayloadV1, GraphOverviewPayloadV1, GraphPathPayloadV1,
GraphSearchPayloadV1, GraphSubgraphPayloadV1,
Expand Down Expand Up @@ -96,7 +96,7 @@ struct DashboardContractCatalogV1 {
storage_telemetry: StorageTelemetryPayloadV1,
doctor_findings: DoctorFindingsPayloadV1,
remote_operational_status: RemoteOperationalStatusPayloadV1,
explorer_query_run: ExplorerQueryRunV1,
explorer_query_event: ExplorerQueryEventV1,
explorer_session_size: DashboardEnvelopeV1<Option<ExplorerSessionSizeV1>>,
explorer_read_context: DashboardEnvelopeV1<Option<ExplorerReadContextV1>>,
projects: DashboardEnvelopeV1<ProjectsPayloadV1>,
Expand Down
Loading
Loading