From f95a411b0ac7d5f347c602308df1123dc1aecd5f Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:09:07 +0800 Subject: [PATCH] fix: record self-limiting hook snapshot --- .../2026-07-04-hook-snapshot-matrix.md | 2 +- .../hook-cc-posttool-block/input.json | 2 +- .../hook-cc-posttool-block/session.jsonl | 253 ++++++++++++------ .../stdout.golden.jsonl | 83 +++++- .../workspace/hooks.json | 2 +- .../workspace/posttool-once.sh | 7 + 6 files changed, 259 insertions(+), 90 deletions(-) create mode 100644 examples/acp-agent/tests/snapshots/hook-cc-posttool-block/workspace/posttool-once.sh diff --git a/docs/rfc/implemented/testing/2026-07-04-hook-snapshot-matrix.md b/docs/rfc/implemented/testing/2026-07-04-hook-snapshot-matrix.md index 1b3e70eb13..0327662d3d 100644 --- a/docs/rfc/implemented/testing/2026-07-04-hook-snapshot-matrix.md +++ b/docs/rfc/implemented/testing/2026-07-04-hook-snapshot-matrix.md @@ -29,7 +29,7 @@ Thirteen scenarios under `examples/acp-agent/tests/snapshots/`, naming `hook-&2; exit 2" } + { "type": "command", "command": "sh posttool-once.sh" } ] } ] diff --git a/examples/acp-agent/tests/snapshots/hook-cc-posttool-block/workspace/posttool-once.sh b/examples/acp-agent/tests/snapshots/hook-cc-posttool-block/workspace/posttool-once.sh new file mode 100644 index 0000000000..2acc98bb58 --- /dev/null +++ b/examples/acp-agent/tests/snapshots/hook-cc-posttool-block/workspace/posttool-once.sh @@ -0,0 +1,7 @@ +#!/bin/sh +if test -e .posttool-blocked; then + exit 0 +fi +: > .posttool-blocked +printf '%s\n' 'tool output rejected by policy: retry once' >&2 +exit 2