Skip to main content

redact_private

Function redact_private 

Source
pub fn redact_private(v: &mut Value)
Expand description

Hides what a private command (CommandSpec::private) carries from a reader that does not read private data, wherever it sits in v: a debug-bridge answer, a snapshot, a wait’s event.

The journal keeps a private command’s events whole, marked "private": true in their data (command.dispatched, command.done, command.failed), and the commands collector marks its runs the same way in history; this is the redaction at read time, per reader. So a reader allowed private data (the user, the application, an agent whose grant shows it) still reads a queued command’s result from its command.done, as egui-pop-agent-mcp does, and one that is not reads REDACTED instead:

  • an event (seq, name, data) whose data says private: true: its args, result and error become REDACTED;
  • a run (id, origin, result) that says private: true: its args become REDACTED, and so does its result’s value or error ({"Ok": "<private>"}, {"Err": "<private>"}).

The rest is left as it is: a command’s declaration (private, args as a schema) is not data and is not touched.

use egui_pop_api::host::{REDACTED, redact_private};
use serde_json::json;

let mut events = json!([
    { "seq": 1, "name": "command.done", "source": "user", "cause": null,
      "data": { "command": "library.folder", "result": "/home/me", "private": true } },
    { "seq": 2, "name": "command.done", "source": "user", "cause": null,
      "data": { "command": "view.zoom", "result": 2 } },
]);
redact_private(&mut events);
assert_eq!(events[0]["data"]["result"], REDACTED);
assert_eq!(events[1]["data"]["result"], 2);