1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! The fixed Query statements, one public constant per file (POLY-359).
//!
//! A fixed statement is a contract between the plane that mints a grant for
//! its exact text and the Query service that admits it by lower-hex SHA-256
//! ([`crate::grant::GrantSubject::ControlFleet`]'s `statement_digest`, or a
//! [`crate::grant::GrantSubject::CompositeTrace`] subject's three digests).
//! The text lives here, in the protocol vocabulary crate both planes
//! already depend on, so neither reaches into the other's source tree by a
//! path Cargo cannot see. This module carries no other logic.
//!
//! A one-byte change to a statement is a wire change: the minting plane and
//! the admitting plane must roll together. `crates/query/tests/
//! statement_registry.rs` pins the SHA-256 of every constant, so a byte
//! change fails a test rather than drifting silently.
/// The composite-trace spine read — one source row becomes one response
/// step; admitted by digest only (`composite_trace.sql`).
pub const COMPOSITE_TRACE_SQL: &str = include_str!;
/// The composite-trace memory-actions read
/// (`composite_trace_memory.sql`).
pub const COMPOSITE_TRACE_MEMORY_SQL: &str = include_str!;
/// The composite-trace routine-state read, over the latest published
/// observation of every routine collection (`composite_trace_routines.sql`).
pub const COMPOSITE_TRACE_ROUTINES_SQL: &str =
include_str!;
/// `/api/dashboard`'s per-conversation caller-attribution stats read
/// (`dashboard_attribution.sql`).
pub const DASHBOARD_ATTRIBUTION_SQL: &str = include_str!;
/// `/api/dashboard`'s per-conversation context read — latest turn id,
/// opening message preview, latest summary, edge ids (POLY-392,
/// `dashboard_context.sql`).
pub const DASHBOARD_CONTEXT_SQL: &str = include_str!;
/// `/api/dashboard`'s per-conversation row-set read
/// (`dashboard_conversations.sql`).
pub const DASHBOARD_CONVERSATIONS_SQL: &str =
include_str!;
/// `/api/dashboard`'s cross-conversation persona spend rollup read
/// (`dashboard_spend.sql`).
pub const DASHBOARD_SPEND_SQL: &str = include_str!;
/// `GET /api/usage`'s fleet-wide read: one row per (conversation, raw
/// caller persona id) pair (`fleet_usage.sql`).
pub const FLEET_USAGE_SQL: &str = include_str!;
/// `GET /api/personas/{id}`'s directory read: the current profile,
/// identity, and participation rows for one bound persona
/// (`persona_directory_detail.sql`).
pub const PERSONA_DIRECTORY_DETAIL_SQL: &str =
include_str!;
/// `GET /api/personas`'s directory read: one row per persona id,
/// left-joined to its identity and participation counts
/// (`persona_directory_index.sql`).
pub const PERSONA_DIRECTORY_INDEX_SQL: &str =
include_str!;
/// `GetRoutineFire`'s fire-row read (`routine_fire.sql`).
pub const ROUTINE_FIRE_SQL: &str = include_str!;
/// `ListRoutineGrants`'s fire-count read (`routine_fire_count.sql`).
pub const ROUTINE_FIRE_COUNT_SQL: &str = include_str!;
/// `ListRoutines`'s latest-fire read, LIMIT 1 (`routine_fire_last.sql`).
pub const ROUTINE_FIRE_LAST_SQL: &str = include_str!;
/// `GET /api/conversations/{id}/turns/{turn_id}/fire-outcome`'s read
/// (`routine_fire_outcome.sql`).
pub const ROUTINE_FIRE_OUTCOME_SQL: &str = include_str!;
/// `ListRoutineFires`'s fixed read — the newest page of fires
/// (`routine_fires.sql`).
pub const ROUTINE_FIRES_SQL: &str = include_str!;
/// `GET /api/routines/fires`'s admin read — unfiltered, fleet-wide
/// (`routine_fires_index_admin.sql`).
pub const ROUTINE_FIRES_INDEX_ADMIN_SQL: &str =
include_str!;
/// `GET /api/routines/fires`'s owner-bound read, run once per owned routine
/// (`routine_fires_index_owner.sql`).
pub const ROUTINE_FIRES_INDEX_OWNER_SQL: &str =
include_str!;
/// `GET /api/routines/lifecycle`'s fixed read (`routine_lifecycle.sql`).
pub const ROUTINE_LIFECYCLE_SQL: &str = include_str!;
/// `ListFleetRoutines`'s fixed read: one row per routine
/// (`routine_overview.sql`).
pub const ROUTINE_OVERVIEW_SQL: &str = include_str!;
/// `ListRoutineGrants`'s active-grant read, under the routine-owner
/// conversation grant (`routine_owner_active_grants.sql`).
pub const ROUTINE_OWNER_ACTIVE_GRANTS_SQL: &str =
include_str!;
/// `ListRoutineGrants`'s overview-aggregates read, under the same grant
/// (`routine_owner_approval_aggregates.sql`).
pub const ROUTINE_OWNER_APPROVAL_AGGREGATES_SQL: &str =
include_str!;
/// `GetRoutineFire`'s dispatch read: the turn ids a fire opened
/// (`routine_owner_fire_dispatch.sql`).
pub const ROUTINE_OWNER_FIRE_DISPATCH_SQL: &str =
include_str!;
/// `ListRoutineRefusals`'s read — the newest page of refusals — under the
/// routine-owner conversation grant (`routine_owner_refusals.sql`).
pub const ROUTINE_OWNER_REFUSALS_SQL: &str = include_str!;
/// `ListRoutines`'s stopped-tool read, LIMIT 1
/// (`routine_owner_stopped_tool.sql`).
pub const ROUTINE_OWNER_STOPPED_TOOL_SQL: &str =
include_str!;