carlos / platform Public

Logs protection filter test: a match older than a full cap of ordinary records on the same box

The two-box test would still pass if the filter ran after each box's collect
cap but before the merge. This one puts the match and the cap's worth of
ordinary edge records on one box, through the data door and the follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 09367dea730e6c3d600c6bcbf4672e0f1dcb77d9 parent 66c324f
1 file changed, +26 −0
  • internal/console/protectionview_test.go +26 −0
diff --git a/internal/console/protectionview_test.go b/internal/console/protectionview_test.go
index 231d656a0..c181620f5 100644
--- a/internal/console/protectionview_test.go
+++ b/internal/console/protectionview_test.go
@@ -374,6 +374,32 @@ func TestLogsProtectionFilterBeforeCap(t *testing.T) {
}
}
+// The same, with the match and the ordinary records on ONE box. The cap is
+// per box, so a filter applied after it (but before the boxes merge) would
+// pass the two-box test above and still lose the match here: its chunk comes
+// first, and the cap's trim takes the box's oldest record.
+func TestLogsProtectionFilterBeforeCapOneBox(t *testing.T) {
+ if testing.Short() {
+ t.Skip("writes a full collect cap of records")
+ }
+ fx, c := ptFixture(t)
+ start := time.Now().UTC().Add(-30 * time.Minute)
+ ptLogRecords(t, fx, "box-a", []applog.Record{ptEdgeRecord(start, 1, "block", "hard.secrets.env", "/.env")})
+ bulk := make([]applog.Record, logsCollectCap+1)
+ for i := range bulk {
+ bulk[i] = ptEdgeRecord(start.Add(time.Second+time.Duration(i)*time.Millisecond), uint64(10+i), "", "", fmt.Sprintf("/p%d", i))
+ }
+ ptLogRecords(t, fx, "box-a", bulk)
+
+ if got := ptMsgs(ptLogsData(t, fx, c, "stream=edge&protection=1&since=1h").Lines); len(got) != 1 || !strings.Contains(got[0], "hard.secrets.env") {
+ t.Errorf("data door = %q, want the one match", got)
+ }
+ before := applog.EncodeCursor(applog.Record{TS: start.Add(-time.Minute), Box: "box-a", Seq: 0})
+ if got := ptMsgs(ptLogsData(t, fx, c, "stream=edge&protection=1&since=1h&cursor="+url.QueryEscape(before)).Lines); len(got) != 1 || !strings.Contains(got[0], "hard.secrets.env") {
+ t.Errorf("follow = %q, want the one match", got)
+ }
+}
+
func TestProtectionLogsLinkStart(t *testing.T) {
now := time.Date(2026, 11, 5, 13, 0, 0, 0, time.UTC)
for days, want := range map[int]string{7: "2026-10-30T00:00:00Z", 30: "2026-10-29T13:00:00Z"} {