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)
| 346 | /// * `hash` - The base32-encoded hash of the provenance graph. |
| 347 | /// * `data` - The raw serialized provenance graph bytes (.provenance format). |
| 348 | pub async fn upload_provenance(&self, hash: &str, data: Bytes) -> RemoteResult<()> { |
| 349 | let url = format!("{}?provenance={}", self.base_url, hash); |
| 350 | debug!("POST provenance: {} ({} bytes)", url, data.len()); |
| 351 | |
| 352 | let response = self |
| 353 | .client |
| 354 | .post(&url) |
| 355 | .header(CONTENT_TYPE, "application/octet-stream") |
| 356 | .body(data) |
| 357 | .send() |
| 358 | .await |
| 359 | .map_err(|e| RemoteError::connection_failed(&url, e))?; |
| 360 | |
| 361 | crate::check_min_version_header(response.headers()); |
| 362 | let status = response.status(); |
| 363 | |
| 364 | match status { |
| 365 | StatusCode::OK => { |
| 366 | debug!("Successfully uploaded provenance graph {}", hash); |
| 367 | Ok(()) |
| 368 | } |
| 369 | StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)), |
| 370 | StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { |
| 371 | let msg = response.text().await.unwrap_or_default(); |
| 372 | Err(RemoteError::auth_failed(&url, msg)) |
| 373 | } |
| 374 | StatusCode::BAD_REQUEST => { |
| 375 | let msg = response.text().await.unwrap_or_default(); |
| 376 | Err(RemoteError::protocol(format!( |
| 377 | "Failed to upload provenance graph: {}", |
| 378 | msg |
| 379 | ))) |
| 380 | } |
| 381 | _ => { |
| 382 | let msg = response.text().await.unwrap_or_default(); |
| 383 | Err(RemoteError::http(status.as_u16(), msg)) |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // Streaming V3 Protocol — Upload Methods |
| 389 |