Upload a provenance graph to the remote server. Provenance graphs are content-addressed DAGs that capture the causal decision chain of an AI agent session. They are stored separately from changes and don't modify the content graph. # Arguments `hash` - The base32-encoded hash of the provenance graph. `data` - The raw serialized provenance graph bytes (.provenance format).
(&self, hash: &str, data: Bytes)
| 377 | /// * `hash` - The base32-encoded hash of the provenance graph. |
| 378 | /// * `data` - The raw serialized provenance graph bytes (.provenance format). |
| 379 | pub async fn upload_provenance(&self, hash: &str, data: Bytes) -> RemoteResult<()> { |
| 380 | let url = format!("{}?provenance={}", self.base_url, hash); |
| 381 | debug!("POST provenance: {} ({} bytes)", url, data.len()); |
| 382 | |
| 383 | let response = self |
| 384 | .client |
| 385 | .post(&url) |
| 386 | .header(CONTENT_TYPE, "application/octet-stream") |
| 387 | .body(data) |
| 388 | .send() |
| 389 | .await |
| 390 | .map_err(|e| RemoteError::connection_failed(&url, e))?; |
| 391 | |
| 392 | crate::check_min_version_header(response.headers()); |
| 393 | let status = response.status(); |
| 394 | |
| 395 | match status { |
| 396 | StatusCode::OK => { |
| 397 | debug!("Successfully uploaded provenance graph {}", hash); |
| 398 | Ok(()) |
| 399 | } |
| 400 | StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)), |
| 401 | StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { |
| 402 | let msg = response.text().await.unwrap_or_default(); |
| 403 | Err(RemoteError::auth_failed(&url, msg)) |
| 404 | } |
| 405 | StatusCode::BAD_REQUEST => { |
| 406 | let msg = response.text().await.unwrap_or_default(); |
| 407 | Err(RemoteError::protocol(format!( |
| 408 | "Failed to upload provenance graph: {}", |
| 409 | msg |
| 410 | ))) |
| 411 | } |
| 412 | _ => { |
| 413 | let msg = response.text().await.unwrap_or_default(); |
| 414 | Err(RemoteError::http(status.as_u16(), msg)) |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | // Streaming V3 Protocol — Upload Methods |
| 420 |