42 lines
1.9 KiB
Go
42 lines
1.9 KiB
Go
package cardsvc
|
|
|
|
import (
|
|
core "agent-system-core"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestTaskVisibilityHidesAllDerivedTextOnSourceRevocation(t *testing.T) {
|
|
st, svc, _ := openTest(t)
|
|
data := []byte("private input")
|
|
art := core.Artifact{Owner: "o", ProjectID: "p", Name: "private name"}
|
|
if e := st.CreateArtifact(&art, data); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
sum := sha256.Sum256(data)
|
|
src := core.TaskSourceRef{ID: "s", ArtifactID: art.ID, ContentHash: hex.EncodeToString(sum[:]), Label: art.Name, Quote: string(data)}
|
|
c := core.ActivityCard{ID: "ct", ProjectID: "p", ConversationID: "c", Title: "private title", Kind: core.CardKindProgress}
|
|
c.Task = &core.TaskSnapshot{SchemaVersion: 1, TaskID: "t", AttemptID: "a", CardID: c.ID, ProjectID: "p", ConversationID: "c", OwnerInstanceID: "i", Revision: 1, StreamScope: "conversation:c", ExecutionState: "queued", OutcomeCompleteness: "none", DeliveryState: "pending", Title: c.Title, Focus: "private focus", Coverage: "private coverage", Remaining: "private remaining", NextStep: "private advice", Conclusion: "private conclusion", Inputs: []core.TaskSourceRef{src}, Findings: []core.TaskFinding{{ID: "f", Revision: 1, Status: "active", Kind: "material_record", Text: "private finding", Sources: []core.TaskSourceRef{src}}}}
|
|
if _, e := svc.CreateTask("o", c, ""); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
if e := st.UpdateArtifactContent("o", art.ID, []byte("updated")); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
changed := svc.VisibleTaskCard("o", c)
|
|
if changed.Task.Findings[0].Status != "superseded" || changed.Task.Findings[0].Sources[0].Availability != "changed" {
|
|
t.Fatal("old evidence masquerades as current")
|
|
}
|
|
if e := st.DeleteArtifact("o", art.ID); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
hidden := svc.VisibleTaskCard("o", c)
|
|
raw, _ := json.Marshal(hidden)
|
|
if strings.Contains(string(raw), "private") {
|
|
t.Fatal("derived information leaked", string(raw))
|
|
}
|
|
}
|