MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / TestDiffDeclaredVsEffectMismatch

Function TestDiffDeclaredVsEffectMismatch

internal/intent/diff_test.go:19–39  ·  view source on GitHub ↗

TestDiffDeclaredVsEffectMismatch: an install tool call that reads a foreign secret violates its contract (install does not permit secret_read).

(t *testing.T)

Source from the content-addressed store, hash-verified

17// TestDiffDeclaredVsEffectMismatch: an install tool call that reads a foreign
18// secret violates its contract (install does not permit secret_read).
19func TestDiffDeclaredVsEffectMismatch(t *testing.T) {
20 contracts := []IntentContract{{
21 ID: "contract/tc1", Kind: ContractToolCall, ScopeAgent: "bob", ToolCallID: "tc1",
22 Operation: "install", Profile: profileFor(profiles(), "install"), Confidence: 0.5,
23 }}
24 effects := []RuntimeEffect{
25 {Kind: EffectProcessExec, AgentID: "bob", ToolCallID: "tc1", EventID: "e1", Confidence: 1},
26 {Kind: EffectSecretRead, Target: "/root/.aws/credentials", AgentID: "bob", ToolCallID: "tc1", EventID: "e2", Confidence: 1},
27 }
28 diffs := Diff(contracts, effects)
29 d, ok := findDiff(diffs, func(d IntentRuntimeDiff) bool { return d.Status == StatusMismatch })
30 if !ok {
31 t.Fatalf("expected a declared_vs_effect_mismatch, got %+v", diffs)
32 }
33 if !containsKind(d.Observed, EffectSecretRead) {
34 t.Errorf("mismatch should cite secret_read; observed=%v", d.Observed)
35 }
36 if d.Confidence < 0.99 {
37 t.Errorf("kernel-witnessed violation should be high confidence, got %.2f", d.Confidence)
38 }
39}
40
41// TestDiffPeerMessageMismatch: a peer instruction to install, followed by the
42// recipient reading a foreign secret, is a peer_message_intent_mismatch.

Callers

nothing calls this directly

Calls 5

profileForFunction · 0.85
profilesFunction · 0.85
DiffFunction · 0.85
findDiffFunction · 0.85
containsKindFunction · 0.85

Tested by

no test coverage detected