feat: durable refresh runs from a source to a staging target (auth M6c)
A refresh captures a new dump of the relation's source, then restores exactly that snapshot onto the relation's target through the existing restore path. - refresh_runs in SQLite, one active run per target, per-requester idempotency keys, a cap on concurrent runs and a TTL that only applies until the restore starts overwriting - the run and its capture job are created in one transaction; the run follows its own capture job, never the latest snapshot, and pins that snapshot until it ends - the restore is queued and linked in one guarded transaction; every step is safe to repeat after a crash; a background driver only reads the database - authorize_apply re-checks, in the transaction that allows the overwrite, that the relation is still usable, the requester is still active, the authorising grant still exists, the deadline has not passed and the target is not the source; otherwise the restore is cancelled, the run is blocked and the agent gets 409. Administrator restores are untouched - POST/GET/DELETE /api/v1/refresh-runs: confirmation names source, target and version; non-administrators never see the snapshot id, the requester or the database identity - audit refresh.* per run Tests drive the agent through the real Outpost endpoints and cover revocation at every stage; the access matrix gains a RunRow kind. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,8 @@ pub enum AuditAction {
|
||||
RelationDeactivate,
|
||||
RelationGrantCreate,
|
||||
RelationGrantDelete,
|
||||
/// One of the refresh run's states or steps; the name is the audit action (`refresh.completed`, ...).
|
||||
RefreshEvent(&'static str),
|
||||
}
|
||||
|
||||
impl AuditAction {
|
||||
@@ -75,6 +77,7 @@ impl AuditAction {
|
||||
Self::RelationDeactivate => "relation.deactivate",
|
||||
Self::RelationGrantCreate => "relation.grant_create",
|
||||
Self::RelationGrantDelete => "relation.grant_delete",
|
||||
Self::RefreshEvent(name) => name,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +111,7 @@ pub enum AuditResource {
|
||||
Snapshot(Uuid),
|
||||
Relation(Uuid),
|
||||
RestoreTarget(Uuid),
|
||||
RefreshRun(Uuid),
|
||||
}
|
||||
|
||||
impl AuditResource {
|
||||
@@ -123,6 +127,7 @@ impl AuditResource {
|
||||
Self::Snapshot(id) => ("snapshot", Some(id.to_string())),
|
||||
Self::Relation(id) => ("relation", Some(id.to_string())),
|
||||
Self::RestoreTarget(id) => ("restore_target", Some(id.to_string())),
|
||||
Self::RefreshRun(id) => ("refresh_run", Some(id.to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user