From 9b6fa93add048de7eff3f5ca59799cfa690960e0 Mon Sep 17 00:00:00 2001 From: Tom Howard Date: Sat, 22 Aug 2026 14:55:52 +1000 Subject: [PATCH] fix(risk-scorer): normalize Codex agent targets --- .changeset/normalize-codex-risk-targets.md | 5 +++++ packages/risk-scorer/hooks/codex-agent-completion.mjs | 3 ++- packages/risk-scorer/hooks/test/codex-agent-completion.bats | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/normalize-codex-risk-targets.md diff --git a/.changeset/normalize-codex-risk-targets.md b/.changeset/normalize-codex-risk-targets.md new file mode 100644 index 00000000..09c53b82 --- /dev/null +++ b/.changeset/normalize-codex-risk-targets.md @@ -0,0 +1,5 @@ +--- +"@windyroad/risk-scorer": patch +--- + +Recognize relative Codex completion targets for canonically named risk agents. diff --git a/packages/risk-scorer/hooks/codex-agent-completion.mjs b/packages/risk-scorer/hooks/codex-agent-completion.mjs index 40dd2fbb..7ef9ed88 100644 --- a/packages/risk-scorer/hooks/codex-agent-completion.mjs +++ b/packages/risk-scorer/hooks/codex-agent-completion.mjs @@ -65,7 +65,8 @@ function diagnoseSubagentStop(input, outcome, reason) { } function statePath(input, target, suffix = "") { - return join(riskDir(input.session_id), `codex-agent-${Buffer.from(target).toString("base64url")}${suffix}`); + const normalized = target.startsWith("/root/") ? target.slice("/root/".length) : target; + return join(riskDir(input.session_id), `codex-agent-${Buffer.from(normalized).toString("base64url")}${suffix}`); } function clearTarget(input, target) { diff --git a/packages/risk-scorer/hooks/test/codex-agent-completion.bats b/packages/risk-scorer/hooks/test/codex-agent-completion.bats index 7f6988b3..d48f176d 100644 --- a/packages/risk-scorer/hooks/test/codex-agent-completion.bats +++ b/packages/risk-scorer/hooks/test/codex-agent-completion.bats @@ -70,7 +70,7 @@ current_pipeline_close_input() { direct_pipeline_interrupt_input() { printf '{"session_id":"%s","cwd":"%s","tool_name":"interrupt_agent","tool_input":{"target":"%s"},"tool_response":{"previous_status":{"completed":"RISK_SCORES: commit=4 push=4 release=4\\nRISK_CWD: %s"}}}' \ - "$SESSION" "$OTHER_REPO" "$TARGET" "$PIPELINE_REPO" + "$SESSION" "$OTHER_REPO" "${TARGET#/root/}" "$PIPELINE_REPO" } current_empty_wait_input() {