Full-depth rename per the approved plan; the 'claw' product vocabulary (claws, /claws routes, clawId, Claw Chat) stays — it is now the brand. - Display brand: Clawmates (manifest, titles, hero, login/rail logo 'clawmates'); default host app.clawmates.work; registry ghcr.io/clawmates - Crates tc-* -> cm-* (16 crates + all imports); binaries clawmates-server/broker/bundler; images clawmates/*; env prefix CLAWMATES_* (+ CM_TEST_DATABASE_URL / CM_LIVE_LLM); config clawmates.toml; helm chart deploy/helm/clawmates with clawmates-* resources; db names clawmates*; sockets /run/clawmates; cookie cm_session; kind cluster clawmates-test; seccomp node profile clawmates-agent-profile.json - All 9 Playwright brand assertions updated in lockstep; historical spec document left untouched as the only remaining 'TeamClaw' - Local env migrated: dev pg clawmates-dev-pg/clawmates_dev, shared test server clawmates-test-pg, kind cluster recreated with image + profile, compose images rebuilt under clawmates/* Verified end to end: 161 Rust + 68 frontend tests, 29 Playwright journeys, 4 live kind tests, helm/install/LOC/placeholder gates, and the clean-room install rehearsal serving the clawmates login page from a signed bundle of the rebuilt images. Co-Authored-By: Claude Fable 5 <[email protected]>
62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
use sqlx::PgPool;
|
|
use uuid::Uuid;
|
|
|
|
use crate::DbError;
|
|
|
|
/// One persisted gateway event (§13): the journal the SSE stream and
|
|
/// reconnect replay both read from.
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct RunEvent {
|
|
pub run_id: Uuid,
|
|
pub seq: i64,
|
|
pub event_type: String,
|
|
pub payload: serde_json::Value,
|
|
}
|
|
|
|
/// Persists an event. Called BEFORE the event is emitted to any client so
|
|
/// the journal is always at least as complete as what observers saw.
|
|
pub async fn append(
|
|
pool: &PgPool,
|
|
run_id: Uuid,
|
|
seq: i64,
|
|
event_type: &str,
|
|
payload: serde_json::Value,
|
|
) -> Result<(), DbError> {
|
|
sqlx::query!(
|
|
"INSERT INTO run_events (run_id, seq, event_type, payload)
|
|
VALUES ($1, $2, $3, $4)",
|
|
run_id,
|
|
seq,
|
|
event_type,
|
|
payload,
|
|
)
|
|
.execute(pool)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Events after a client's `resumeFrom` offset, in order.
|
|
pub async fn list_after(
|
|
pool: &PgPool,
|
|
run_id: Uuid,
|
|
after_seq: i64,
|
|
) -> Result<Vec<RunEvent>, DbError> {
|
|
let rows = sqlx::query!(
|
|
"SELECT run_id, seq, event_type, payload
|
|
FROM run_events WHERE run_id = $1 AND seq > $2 ORDER BY seq",
|
|
run_id,
|
|
after_seq,
|
|
)
|
|
.fetch_all(pool)
|
|
.await?;
|
|
Ok(rows
|
|
.into_iter()
|
|
.map(|row| RunEvent {
|
|
run_id: row.run_id,
|
|
seq: row.seq,
|
|
event_type: row.event_type,
|
|
payload: row.payload,
|
|
})
|
|
.collect())
|
|
}
|