fix: construct repo AT-URI and map field names for knot refUpdate events
Author: Aaron Steven White
Commit
f35b904c19febec00370191b4b28b47ca665a5abParent: 3f1947a700
Structural diff unavailable
These commits were pushed via plain git push, so no pre-parsed
schemas are available. Install git-remote-cospan and re-push via panproto:// to
see scope-level changes, breaking change detection, and semantic diffs.
brew install panproto/tap/git-remote-cospan1 file changed +19 -2
@@ -132,14 +132,31 @@ async fn consume_knot(state: &Arc<AppState>, url: &str) -> anyhow::Result<()> {
132132 .and_then(|v| v.as_str()) 133133 .unwrap_or(""); 134134 135- // Build a Jetstream-compatible event for the consumer pipeline 135+ // Knot events have repoDid/repoName directly, but the morphism expects 136+ // a repo AT-URI field. Construct it and add field mappings. 137+ let mut enriched_record = record.cloned().unwrap_or(serde_json::Value::Null); 138+ if let Some(obj) = enriched_record.as_object_mut() { 139+ // Construct repo AT-URI from repoDid + repoName for the morphism 140+ let repo_did = obj.get("repoDid").and_then(|v| v.as_str()).unwrap_or(""); 141+ let repo_name = obj.get("repoName").and_then(|v| v.as_str()).unwrap_or(""); 142+ if !repo_did.is_empty() && !repo_name.is_empty() { 143+ obj.insert("repo".to_string(), 144+ serde_json::Value::String(format!("at://{repo_did}/sh.tangled.repo/{repo_name}"))); 145+ } 146+ // Map newSha → newTarget, oldSha → oldTarget for the Cospan schema 147+ if let Some(v) = obj.remove("newSha") { obj.insert("newTarget".to_string(), v); } 148+ if let Some(v) = obj.remove("oldSha") { obj.insert("oldTarget".to_string(), v); } 149+ // Map ref field name 150+ if let Some(v) = obj.remove("ref") { obj.insert("refName".to_string(), v); } 151+ } 152+ 136153 let compat_event = serde_json::json!({ 137154 "did": did, 138155 "commit": { 139156 "collection": nsid, 140157 "operation": "create", 141158 "rkey": rkey, 142- "record": record, 159+ "record": enriched_record, 143160 } 144161 }); 145162