O-8: a foundation part's sender keeps its send sequence and ages its sent store from it

Builds: design 47 G §330, §410, §59

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 10:51:06 +01:00
parent 126053388e
commit 91ad895c83
2 changed files with 99 additions and 0 deletions
+29
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"strings"
"testing"
"time"
)
// ADR 0666 §16: a reply or an event over the per-message limit carries the name of an object, and the receiver reads it
@@ -66,3 +67,31 @@ func TestABundleReadsASentObjectThroughTheRuntime(t *testing.T) {
t.Fatalf("the bundle answered %v", out)
}
}
// Design 47 G §410, §330: a foundation part's sender keeps the sequence of its sends in its old state section
// `sent-log` and deletes the sent objects past 7 days at a later send, at most 20 a send.
func TestAFoundationPartsSentStoreAgesFromItsSendLog(t *testing.T) {
m := newMemory()
clock := time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC)
s := Sender{Objects: memObjects{m}, Store: "m_sent-objects", Log: m, Node: "n1", Now: func() time.Time { return clock }}
var first string
for i := 0; i < 25; i++ {
sent, err := s.Send("reply."+string(rune('a'+i)), bytes.Repeat([]byte{byte('a' + i)}, 2<<20))
if err != nil {
t.Fatal(err)
}
if ref, _ := ReadRef(sent); i == 0 {
first = ref.Object
}
}
if len(m.objects) != 25 {
t.Fatalf("%d objects within 7 days, want 25", len(m.objects))
}
clock = clock.Add(SentMaxAge + time.Hour)
if _, err := s.Send("reply.late", bytes.Repeat([]byte("z"), 2<<20)); err != nil {
t.Fatal(err)
}
if _, kept := m.objects[first]; kept || len(m.objects) != 6 {
t.Fatalf("after a late send %d objects remain (the first kept: %v), want 6", len(m.objects), kept)
}
}