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)
| 243 | /// * `hash` - The base32-encoded hash of the provenance graph. |
| 244 | /// * `data` - The raw serialized provenance graph bytes (.provenance format). |
| 245 | pub async fn upload_provenance(&self, hash: &str, data: Bytes) -> RemoteResult<()> { |
| 246 | let url = format!("{}?provenance={}", self.base_url, hash); |
| 247 | debug!("POST provenance: {} ({} bytes)", url, data.len()); |
| 248 | |
| 249 | let response = self |
| 250 | .client |
| 251 | .post(&url) |
| 252 | .header(CONTENT_TYPE, "application/octet-stream") |
| 253 | .body(data) |
| 254 | .send() |
| 255 | .await |
| 256 | .map_err(|e| RemoteError::connection_failed(&url, e))?; |
| 257 | |
| 258 | crate::check_min_version_header(response.headers()); |
| 259 | let status = response.status(); |
| 260 | |
| 261 | match status { |
| 262 | StatusCode::OK => { |
| 263 | debug!("Successfully uploaded provenance graph {}", hash); |
| 264 | Ok(()) |
| 265 | } |
| 266 | StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)), |
| 267 | StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { |
| 268 | let msg = response.text().await.unwrap_or_default(); |
| 269 | Err(RemoteError::auth_failed(&url, msg)) |
| 270 | } |
| 271 | StatusCode::BAD_REQUEST => { |
| 272 | let msg = response.text().await.unwrap_or_default(); |
| 273 | Err(RemoteError::protocol(format!( |
| 274 | "Failed to upload provenance graph: {}", |
| 275 | msg |
| 276 | ))) |
| 277 | } |
| 278 | _ => { |
| 279 | let msg = response.text().await.unwrap_or_default(); |
| 280 | Err(RemoteError::http(status.as_u16(), msg)) |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | // Streaming V3 Protocol — Upload Methods |
| 286 |