Skip to main content

forge_workspace/mcp/
deleted.rs

1//! The record-echo envelope the delete-shaped tool results answer with.
2
3/// The result a delete or unsubscribe answers with: the status word plus
4/// the record as it stood just before removal, so the caller can name what
5/// the call touched. A family with more to say adds its own keys beside
6/// these (`tasks__delete` adds `descendants_removed`).
7pub(crate) fn removed_record(removed: &serde_json::Value) -> serde_json::Value {
8    serde_json::json!({ "status": "deleted", "removed": removed })
9}
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    /// The envelope is a contract every adopting family shares: the status
16    /// word a reader matches and the key the record sits under. Pinned
17    /// once here so the families cannot drift apart on it.
18    #[test]
19    fn the_envelope_names_the_status_and_the_removed_record() {
20        let envelope = removed_record(&serde_json::json!({ "id": "x" }));
21        assert_eq!(envelope["status"], "deleted");
22        assert_eq!(envelope["removed"]["id"], "x");
23    }
24}