The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
test(sandbox): make the mutation self-test capable of failing
shukieshah688da2ee7d6a
diff --git a/beacon-sandbox/cmd/beacon-sandbox/mutation_meta_test.go b/beacon-sandbox/cmd/beacon-sandbox/mutation_meta_test.goindex 87548455..08e9b246 100644--- a/beacon-sandbox/cmd/beacon-sandbox/mutation_meta_test.go+++ b/beacon-sandbox/cmd/beacon-sandbox/mutation_meta_test.go@@ -3,19 +3,47 @@ package mainimport "testing"// The meta mutations must turn a clean removal into a failure, or they prove nothing.+//+// Each mode is checked against the one key it targets, rather than against a compound condition over+// several. The compound version could not fail: it read a key the fixture never seeded, so the+// expression was false whatever the mutation did, and a mutation that changed nothing would still+// have passed. A self-test that cannot fail is the exact thing these mutations exist to rule out, so+// getting it wrong here is worse than getting it wrong anywhere else in the tool.func TestMetaMutationsInvertARecordedRemoval(t *testing.T) {- for _, mode := range []string{"leave-service", "drop-retained-log"} {- meta := map[string]string{- "uninstall_ran": "true",- "uninstall_service_gone": "true",- "uninstall_config_retained": "true",- }- if !applyMetaMutation(meta, mode) {- t.Fatalf("%s was not recognised as a meta mutation", mode)- }- if meta["uninstall_service_gone"] == "true" && meta["uninstall_log_retained"] == "true" {- t.Fatalf("%s changed nothing", mode)- }+ cases := []struct {+ mode string+ key string+ }{+ {mode: "leave-service", key: "uninstall_service_gone"},+ {mode: "drop-retained-log", key: "uninstall_log_retained"},+ }+ for _, tc := range cases {+ t.Run(tc.mode, func(t *testing.T) {+ meta := map[string]string{+ "uninstall_ran": "true",+ "uninstall_service_gone": "true",+ "uninstall_log_retained": "true",+ }+ if !applyMetaMutation(meta, tc.mode) {+ t.Fatalf("%s was not recognised as a meta mutation", tc.mode)+ }+ if meta[tc.key] != "false" {+ t.Fatalf("%s left %s as %q; the observation it is supposed to invert is unchanged, "++ "so the self-test would report a passing check that was never exercised",+ tc.mode, tc.key, meta[tc.key])+ }+ // Only the one observation. A mutation that damaged several would produce a cascade of+ // findings, and the self-test could no longer say which check it had exercised.+ for _, other := range cases {+ if other.key == tc.key {+ continue+ }+ if meta[other.key] != "true" {+ t.Fatalf("%s also changed %s to %q; each mutation must invert exactly one observation",+ tc.mode, other.key, meta[other.key])+ }+ }+ })}}