Preserve plugin attribution across command approvals (#35029)

## What changed

- Add optional `plugin_id` and `script_path` fields to execution approval and guardian assessment events.
- Propagate validated plugin attribution through delegated approvals, guardian-reviewed command items, app-server notifications, thread history, and rollout traces.
- Preserve attribution on both started and completed command items, including declined commands.

## Testing

- Extend core, app-server, thread-history, and rollout-trace tests to cover plugin attribution propagation and serialization.

GitOrigin-RevId: 723684d010cab04142918d7a95e06ed95d008da1
This commit is contained in:
Kyle Brown
2026-07-23 23:13:59 +00:00
committed by copyberry
parent 091e4a5d7c
commit 9fc4e5a7aa
23 changed files with 363 additions and 75 deletions
+16 -4
View File
@@ -152,6 +152,10 @@ impl Serialize for ToolRuntimePayload<'_> {
struct ExecCommandBeginTracePayload<'a> {
call_id: &'a str,
#[serde(skip_serializing_if = "Option::is_none")]
plugin_id: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
script_path: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
process_id: Option<&'a str>,
turn_id: &'a str,
started_at_ms: i64,
@@ -167,8 +171,8 @@ impl<'a> From<&'a ExecCommandBeginEvent> for ExecCommandBeginTracePayload<'a> {
fn from(event: &'a ExecCommandBeginEvent) -> Self {
let ExecCommandBeginEvent {
call_id,
plugin_id: _,
script_path: _,
plugin_id,
script_path,
process_id,
turn_id,
started_at_ms,
@@ -180,6 +184,8 @@ impl<'a> From<&'a ExecCommandBeginEvent> for ExecCommandBeginTracePayload<'a> {
} = event;
Self {
call_id,
plugin_id: plugin_id.as_deref(),
script_path: script_path.as_deref(),
process_id: process_id.as_deref(),
turn_id,
started_at_ms: *started_at_ms,
@@ -200,6 +206,10 @@ impl<'a> From<&'a ExecCommandBeginEvent> for ExecCommandBeginTracePayload<'a> {
struct ExecCommandEndTracePayload<'a> {
call_id: &'a str,
#[serde(skip_serializing_if = "Option::is_none")]
plugin_id: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
script_path: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
process_id: Option<&'a str>,
turn_id: &'a str,
completed_at_ms: i64,
@@ -222,8 +232,8 @@ impl<'a> From<&'a ExecCommandEndEvent> for ExecCommandEndTracePayload<'a> {
fn from(event: &'a ExecCommandEndEvent) -> Self {
let ExecCommandEndEvent {
call_id,
plugin_id: _,
script_path: _,
plugin_id,
script_path,
process_id,
turn_id,
completed_at_ms,
@@ -242,6 +252,8 @@ impl<'a> From<&'a ExecCommandEndEvent> for ExecCommandEndTracePayload<'a> {
} = event;
Self {
call_id,
plugin_id: plugin_id.as_deref(),
script_path: script_path.as_deref(),
process_id: process_id.as_deref(),
turn_id,
completed_at_ms: *completed_at_ms,
@@ -56,8 +56,8 @@ fn exec_command_trace_payloads_use_inferred_native_cwd() -> anyhow::Result<()> {
// Windows and POSIX paths on every platform.
let begin = EventMsg::ExecCommandBegin(ExecCommandBeginEvent {
call_id: "call-begin".to_string(),
plugin_id: None,
script_path: None,
plugin_id: Some("sample@openai-curated".to_string()),
script_path: Some("scripts/run.py".to_string()),
process_id: Some("process-1".to_string()),
turn_id: "turn-1".to_string(),
started_at_ms: 1234,
@@ -69,8 +69,8 @@ fn exec_command_trace_payloads_use_inferred_native_cwd() -> anyhow::Result<()> {
});
let end = EventMsg::ExecCommandEnd(ExecCommandEndEvent {
call_id: "call-end".to_string(),
plugin_id: None,
script_path: None,
plugin_id: Some("sample@openai-curated".to_string()),
script_path: Some("scripts/run.py".to_string()),
process_id: None,
turn_id: "turn-1".to_string(),
completed_at_ms: 2345,
@@ -96,6 +96,8 @@ fn exec_command_trace_payloads_use_inferred_native_cwd() -> anyhow::Result<()> {
serde_json::to_value(payload)?,
json!({
"call_id": "call-begin",
"plugin_id": "sample@openai-curated",
"script_path": "scripts/run.py",
"process_id": "process-1",
"turn_id": "turn-1",
"started_at_ms": 1234,
@@ -113,6 +115,8 @@ fn exec_command_trace_payloads_use_inferred_native_cwd() -> anyhow::Result<()> {
serde_json::to_value(payload)?,
json!({
"call_id": "call-end",
"plugin_id": "sample@openai-curated",
"script_path": "scripts/run.py",
"turn_id": "turn-1",
"completed_at_ms": 2345,
"command": ["pwd"],