TestDiffDeclaredVsEffectMismatch: an install tool call that reads a foreign secret violates its contract (install does not permit secret_read).
(t *testing.T)
| 17 | // TestDiffDeclaredVsEffectMismatch: an install tool call that reads a foreign |
| 18 | // secret violates its contract (install does not permit secret_read). |
| 19 | func 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. |
nothing calls this directly
no test coverage detected