Skip to content

fix: normalize debate wake tool response envelopes - #19

Merged
RMANOV merged 1 commit into
mainfrom
agent/routing-normalization-20261003
Oct 3, 2026
Merged

RMANOV merged 1 commit into
mainfrom
agent/routing-normalization-20261003

Conversation

@RMANOV

@RMANOV RMANOV commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Normalize recognized tool-response envelopes conservatively, preserving authoritative identity and rejecting conflicting, error, or over-bound wrapper structures.
  • Prefer explicitly present canonical responses and keep missing-response diagnostics limited to allowlisted shape information.
  • Add focused normalization, privacy, and real dry-run integration regressions; existing wake authority and dispatch behavior remain unchanged.

Verification

  • Focused normalization and existing wake regression: 51 passed.
  • Wider vehicle/protocol regressions on the same source: 30 passed.
  • This change modifies only hooks/debate_wake.py and adds tests/test_debate_wake_payload_normalization.py.
  • Existing pull-request CI will provide full Python 3.11 pytest, Ruff, and MCP registry-smoke verification. Full CI results are pending; no runtime or live-data parity claim is made.

Copilot AI balanced review requested due to automatic review settings October 3, 2026 20:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T20:32:14.280194Z 8e74ebf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RMANOV
RMANOV merged commit d6fa803 into main Oct 3, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The change reworks fail-closed security/privacy-sensitive hook parsing with many subtle branches, so final human review is warranted despite no blocking defects found.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR hardens the debate_post_with_recipients PostToolUse wake hook so that it resolves the canonical tool-response identity (msg_id/topic_id/schema_version) conservatively across the many wrapper shapes MCP/Claude hooks can emit. The previous _unwrap_tool_response greedily returned the first dict containing msg_id/schema_version, which could pick a stale or error-wrapped candidate. The new _normalize_tool_response traverses all recognized wrapper branches, fails closed on isError, conflicting identities, non-scalar identity fields, and over-sized/over-deep structures, and selects the most complete original candidate. It also tightens diagnostics so missing-response logging only emits allowlisted shape sketches (no unknown keys/values or raw tool names), and adds a non-object payload guard in _run_hook.

Changes:

  • Replace greedy unwrapping with a bounded, fail-closed _normalize_tool_response plus alias-aware _extract_tool_response.
  • Add privacy-preserving _describe_shape for missing_tool_response logging and stop logging raw payload keys / exception strings / full tool names.
  • Add comprehensive regression tests covering wrappers, legacy aliases, conflict/error/bounds rejection, privacy, fail-closed payloads, and a real DAO dry-run integration path.
File Description
hooks/​debate_wake.py Adds bounded fail-closed envelope normalization, allowlisted shape logging, and a non-object payload guard in _run_hook.
tests/​test_debate_wake_payload_normalization.py New tests for normalization, privacy diagnostics, fail-closed handling, and an end-to-end stdin→resolver→dry-run DAO regression.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hooks/debate_wake.py
return out
if "tool_response" in hook_payload:
return _normalize_tool_response(hook_payload["tool_response"])
aliases = [hook_payload[key] for key in _HOOK_RESPONSE_KEYS[1:] if key in hook_payload]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants