From b5ba5040db55b9e9b04132407cb1f143bc87e8ad Mon Sep 17 00:00:00 2001 From: Matthew Jacobs Date: Thu, 19 Nov 2026 14:13:21 -0800 Subject: [PATCH] Verify failed board posts from killed swarm members --- docs/completeness.md | 4 +++ internal/completeness/projection_core.go | 2 ++ internal/completeness/projection_swarm155.go | 29 +++++++++++++++++++ .../completeness/projection_tools155_test.go | 29 +++++++++++++++++++ internal/completeness/schema.go | 2 +- internal/completeness/tools158_test.go | 3 +- 6 files changed, 67 insertions(+), 2 deletions(-) diff --git a/docs/completeness.md b/docs/completeness.md index bd52e52..43b687a 100644 --- a/docs/completeness.md +++ b/docs/completeness.md @@ -1775,6 +1775,10 @@ source counts, and the reader checks the source again before publication. Doctor counts these transcripts separately. Full-source exports and format qualification still require full coverage. +The `boardpost157` rule covers a failed, resultless `post_message` from a killed +swarm member. The stored text argument and tool call must agree, and the short +and full errors must name the same member. The daemon retains the whole step. + The `killall1512` profile verifies the observed single-child `kill_all` result against the child's identity in both persisted result lists. The presented action and both ID strings must match. diff --git a/internal/completeness/projection_core.go b/internal/completeness/projection_core.go index c032b9a..97324b0 100644 --- a/internal/completeness/projection_core.go +++ b/internal/completeness/projection_core.go @@ -996,6 +996,8 @@ func qualifyResultless(step, generic protoreflect.Message) (proto.Message, error } var args []string switch tool { + case "post_message": + return nil, qualifyFailedBoardPost(step, generic) case "swarm": return nil, qualifyFailedSwarm156(step, generic) case "define_subagent": diff --git a/internal/completeness/projection_swarm155.go b/internal/completeness/projection_swarm155.go index 61036a0..69d05b2 100644 --- a/internal/completeness/projection_swarm155.go +++ b/internal/completeness/projection_swarm155.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "strconv" + "strings" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -57,3 +58,31 @@ func qualifySwarm155(step, generic, result protoreflect.Message) error { } return nil } + +// qualifyFailedBoardPost checks the resultless ERROR wrapper from a member +// killed before its post reached the board. The daemon retains it unchanged. +func qualifyFailedBoardPost(step, generic protoreflect.Message) error { + const prefix = "failed to post to the board: member was killed: " + unsupported := errors.New("unsupported failed board post") + if !errorStartsWith(step, prefix) { + return unsupported + } + outer := tool143Get(step, "error").Message() + short := tool143Get(outer, "short_error").String() + quoted := strings.TrimPrefix(short, prefix) + member, err := strconv.Unquote(quoted) + if err != nil || member == "" || strconv.Quote(member) != quoted || tool143Get(outer, "full_error").String() != short { + return unsupported + } + call := tool143Get(tool143Get(step, "metadata").Message(), "tool_call").Message() + if !objectKeysUnique([]byte(tool143Get(call, "arguments_json").String())) { + return unsupported + } + called, ok := calledArguments(step) + text, isString := literalString(called["text"]) + stored, present := genericArg(generic, "text") + if !ok || len(called) != 1 || !isString || text == "" || !present || stored != text || !genericArgsAllowed(generic, "text") { + return unsupported + } + return nil +} diff --git a/internal/completeness/projection_tools155_test.go b/internal/completeness/projection_tools155_test.go index 2f6e401..86e219c 100644 --- a/internal/completeness/projection_tools155_test.go +++ b/internal/completeness/projection_tools155_test.go @@ -287,3 +287,32 @@ func TestTimestampedImageRead155(t *testing.T) { require1216(t, snapshot1216(t, badRaw), badRaw, badShown, Unknown) } } + +func TestFailedBoardPost(t *testing.T) { + const raw = `{"cascadeId":"fixture","steps":[{"type":"CORTEX_STEP_TYPE_GENERIC","status":"CORTEX_STEP_STATUS_ERROR","metadata":{"toolCall":{"name":"post_message","argumentsJson":"{\"text\":\"hello\"}"}},"generic":{"args":{"text":"hello"}},"error":{"shortError":"failed to post to the board: member was killed: \"worker\"","fullError":"failed to post to the board: member was killed: \"worker\""}}]}` + s := snapshot1216(t, raw) + require1216(t, s, raw, raw, Verified) + offline, err := s.OfflineJSON() + if err != nil { + t.Fatal(err) + } + require1216(t, s, raw, string(offline), Verified) + changed := strings.ReplaceAll(raw, "hello", "changed") + require1216(t, s, raw, changed, Incomplete) + for _, m := range [][2]string{ + {"CORTEX_STEP_STATUS_ERROR", "CORTEX_STEP_STATUS_DONE"}, + {"member was killed", "member left"}, + {`\"worker\"`, `\"\"`}, + {`"fullError":"failed`, `"fullError":"unexpected: failed`}, + {`"text":"hello"`, `"text":"other"`}, + {`"args":{`, `"result":{},"args":{`}, + {`"args":{`, `"args":{"extra":"argument",`}, + {`{\"text\":\"hello\"}`, `{\"text\":\"other\",\"text\":\"hello\"}`}, + } { + bad := strings.ReplaceAll(raw, m[0], m[1]) + if bad == raw { + t.Fatal("mutation missed", m) + } + require1216(t, snapshot1216(t, bad), bad, bad, Unknown) + } +} diff --git a/internal/completeness/schema.go b/internal/completeness/schema.go index bbc7a22..fef6c84 100644 --- a/internal/completeness/schema.go +++ b/internal/completeness/schema.go @@ -141,7 +141,7 @@ import ( // policy1510 retains the three PolicyGuardianConfig fields observed in executor metadata. // refs1511 retains the observed agy 1.5.11 render-reference fields. // tools1512 projects the observed skill, file, command, timer and list results. -const Profile = "sqlite-v1-format0-agy-1.3.4-5b93565c5f04-planner50-permission2-prompt23-tools143-permission1-tools144-skill1-history2-ide225-options145-compaction146-skill146-finish147-replay147-failedread146-subagents148-media149-tools149-sendmessage149-files1411-media1410-parentmsgs1410-paths1410-denied1412-cwd1412-unrun1412-config150-skill150-frontmatter150-bgcancel150-readlines150-config152-tools153-tools154-tools155-images155-tools156-retained156-legacychoices156-runtime157-planexecute157-tools158-workflow159-schedule1510-policy1510-refs1511-tools1512-killall1512" +const Profile = "sqlite-v1-format0-agy-1.3.4-5b93565c5f04-planner50-permission2-prompt23-tools143-permission1-tools144-skill1-history2-ide225-options145-compaction146-skill146-finish147-replay147-failedread146-subagents148-media149-tools149-sendmessage149-files1411-media1410-parentmsgs1410-paths1410-denied1412-cwd1412-unrun1412-config150-skill150-frontmatter150-bgcancel150-readlines150-config152-tools153-tools154-tools155-images155-tools156-retained156-legacychoices156-runtime157-planexecute157-tools158-workflow159-schedule1510-policy1510-refs1511-tools1512-killall1512-boardpost157" const maxBytes = 64 << 20 const maxDepth = 100 diff --git a/internal/completeness/tools158_test.go b/internal/completeness/tools158_test.go index 3eb4512..bffc512 100644 --- a/internal/completeness/tools158_test.go +++ b/internal/completeness/tools158_test.go @@ -162,7 +162,8 @@ func TestCurrentProfileInvalidatesPreviousAttestations(t *testing.T) { strings.Split(Profile, "-policy1510")[0], strings.Split(Profile, "-refs1511")[0], strings.Split(Profile, "-tools1512")[0], - strings.TrimSuffix(Profile, "-killall1512"), + strings.Split(Profile, "-killall1512")[0], + strings.TrimSuffix(Profile, "-boardpost157"), } { a.Profile = previous if a.Profile == Profile {