Files
ARTEX/db/lessons_test.go
BaaRai a8f3c2c328 feat(rsi): evidence-gated lesson library in shadow mode
Extracts candidate lessons from terminal tasks (confirmed, negative,
retest caution), gates them on cue + action + evidence, and makes
extraction idempotent through a per-source evidence key.

ARTEX_RSI_LESSONS selects off / shadow / inject. Shadow logs what would
have been shown; inject appends a code-owned, data-not-instructions block
after the planner and worker system prompts. No prompt mutation and no
adoption: status stays candidate.

Credit: the Library admission rule comes from harness2 (Google Research,
Apache-2.0, arXiv 2610.14224); the gain taxonomy from awesome-rsi
(lobehub).
2026-10-21 14:25:35 +02:00

37 lines
1.2 KiB
Go

package db
import (
"strings"
"testing"
)
func TestRenderLessonsDataNotInstructions(t *testing.T) {
lessons := []Lesson{
{ID: 1, Kind: "positive", Cue: "xss", Action: "Confirmed xss: reflected in search", Support: 2,
Evidence: []string{"finding:10 (status=confirmed severity=high)"}},
{ID: 2, Kind: "negative", Cue: "ssrf", Action: "Do not\nre-report\x00 without new mechanics", Support: 1},
}
block := RenderLessons(lessons, 2000)
if !strings.Contains(block, "not instructions") {
t.Fatalf("missing data-not-instructions header:\n%s", block)
}
if !strings.Contains(block, "[positive, 2 evidence]") || !strings.Contains(block, "[negative, 1 evidence]") {
t.Fatalf("missing kind/support labels:\n%s", block)
}
for _, line := range strings.Split(block, "\n") {
if strings.Contains(line, "\x00") {
t.Fatalf("control character survived: %q", line)
}
}
if !strings.Contains(block, "Do not re-report without new mechanics") {
t.Fatalf("lesson text was not flattened onto one line:\n%s", block)
}
if RenderLessons(nil, 2000) != "" {
t.Fatal("empty lesson set must render empty")
}
capped := RenderLessons(lessons, 120)
if len(capped) > 160 {
t.Fatalf("cap not enforced: %d bytes", len(capped))
}
}