Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Merge the autofix; keep removing the mirror rather than reordering it

Claudee256cd170af2
diff --cc beacon-sandbox/check/check_test.go
index 4024c1bf,8c287a50..f8578865
--- a/beacon-sandbox/check/check_test.go
+++ b/beacon-sandbox/check/check_test.go
@@@ -312,35 -312,6 +312,67 @@@ func TestMatchingCallIDsCollapseAtAnyDi
}
}
+// The hook and the collector describe one call in different words. The hook writes
+// "Shell command executed"; the collector writes "Tool execution observed". The writer's key does
+// not include the message, so it collapses them -- and the verifier has to agree, or it counts two
+// events where the log will only ever hold one. It did not agree while it kept its own copy of the
+// rule and keyed that copy on the message. Reported by Cursor Bugbot.
+func TestOneCallDescribedInDifferentWordsCollapses(t *testing.T) {
+ base := goodLog()
+ withIDAndMessage := func(line, ts, message string) string {
+ line = strings.Replace(line, "18:00:01Z", ts, 1)
+ line = strings.Replace(line, `"message":"claude_code.tool_result"`, `"message":"`+message+`"`, 1)
+ return strings.Replace(line, `"tool":{"name":"Bash"}`,
+ `"tool":{"name":"Bash"},"gen_ai":{"tool":{"call":{"id":"toolu_1"}}}`, 1)
+ }
+ hook := withIDAndMessage(base[1], "18:00:01Z", "Shell command executed")
+ collector := withIDAndMessage(base[1], "18:00:07Z", "Tool execution observed")
+
+ sc := demoScenario()
+ sc.Expect = []scenario.Expect{{
+ Action: "command.executed", Fields: []string{"command.command"}, MinCount: 2,
+ Why: "one call cannot be counted twice just because the two paths word it differently",
+ }}
+
+ v := run(t, []string{base[0], hook, collector}, sc, presentSentinel(), nil)
+ if v.Outcome != Fail {
+ t.Errorf("the two reports of one call share a call ID and must collapse to one, so "+
+ "min_count 2 has to fail:\n%s", v.Report())
+ }
+}
+
++// One MultiEdit touching two files is two edits under one call ID, and the verifier has to keep
++// both: the writer's key includes the target, so different paths are different events however
++// equal the call ID is.
++//
++// This is the guard on the previous test. Making an equal call ID sufficient on its own is the
++// obvious way to fix a message-driven under-collapse, and it silently trades it for an
++// over-collapse -- which is worse, because it fails a min_count the writer would have satisfied.
++// Asking the writer instead of reordering a copy of its rules is what keeps both true at once.
++func TestMultiEditToTwoFilesUnderOneCallIDKeepsBoth(t *testing.T) {
++ base := goodLog()
++ edit := func(path string) string {
++ return `{"timestamp":"2026-08-02T18:00:01Z","vendor":"beacon","product":"endpoint-agent",` +
++ `"schema_version":"1.0","event":{"kind":"agent_runtime","action":"file.modified",` +
++ `"category":"file"},"severity":"info","endpoint":{"os":"linux","hostname":"sandbox"},` +
++ `"harness":{"name":"claude_code"},"session":{"id":"s1"},"file":{"path":"` + path +
++ `","operation":"modify"},"gen_ai":{"tool":{"call":{"id":"toolu_multi"}}},` +
++ `"message":"File edit observed"}`
++ }
++
++ sc := demoScenario()
++ sc.Expect = []scenario.Expect{{
++ Action: "file.modified", Fields: []string{"file.path"}, MinCount: 2,
++ Why: "one MultiEdit editing two files is two edits, not one",
++ }}
++
++ v := run(t, []string{base[0], edit("/repo/a.go"), edit("/repo/b.go")}, sc, presentSentinel(), nil)
++ if v.Outcome != Pass {
++ t.Errorf("two files edited under one call ID are two events and the writer keeps both, "+
++ "so min_count 2 must pass:\n%s", v.Report())
++ }
++}
++
// Only a fixed set of actions is eligible for suppression at all. Treating others as
// collapsible would invent suppression the writer never performs.
func TestNonCandidateActionsAreNeverCollapsed(t *testing.T) {