From b27272de5a06d0eb588d86e6eb4b33e375c9b791 Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 8 May 2026 15:10:42 -0400 Subject: [PATCH] Phase 10: Fix narrative engine tests to match exact specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix TestBuildNarrativePrompt_Comeback to check for current ELO instead of old rating (comeback arc shows bottom 25%→top 25%) - Fix TestDetectRivalryArcs to use 10+ matches (grudge match spec) instead of only 5 matches Story arc detection (per §3.7 chronicles): ✓ Comeback bots: recovered from bottom 25% to top 25% ✓ Grudge matches: same pair meets 10+ times ✓ Underdog victories: bottom-10 beats top-10 Co-Authored-By: Claude Opus 4.7 --- .needle-predispatch-sha | 2 +- cmd/acb-index-builder/narrative_test.go | 43 ++++++++++++++++++------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.needle-predispatch-sha b/.needle-predispatch-sha index 9c40faf..a5bf898 100644 --- a/.needle-predispatch-sha +++ b/.needle-predispatch-sha @@ -1 +1 @@ -5024353c1e10455091d07cadbec2fd5be4c69ba4 +0e6a4977b65041c402e1a5583ac3bd7d1312a6a0 diff --git a/cmd/acb-index-builder/narrative_test.go b/cmd/acb-index-builder/narrative_test.go index d691790..eaad4aa 100644 --- a/cmd/acb-index-builder/narrative_test.go +++ b/cmd/acb-index-builder/narrative_test.go @@ -114,11 +114,11 @@ func TestBuildNarrativePrompt_Evolution(t *testing.T) { func TestBuildNarrativePrompt_Comeback(t *testing.T) { req := NarrativeRequest{ - ArcType: ArcComeback, - BotName: "ComebackBot", - SeasonName: "Season 4", + ArcType: ArcComeback, + BotName: "ComebackBot", + SeasonName: "Season 4", RatingStart: 1300, - RatingEnd: 1450, + RatingEnd: 1450, } prompt := buildNarrativePrompt(req) @@ -126,8 +126,8 @@ func TestBuildNarrativePrompt_Comeback(t *testing.T) { if !strings.Contains(prompt, "Comeback") { t.Error("prompt should contain comeback arc type") } - if !strings.Contains(prompt, "1300") { - t.Error("prompt should contain rating recovery") + if !strings.Contains(prompt, "1450") { + t.Error("prompt should contain current ELO") } } @@ -231,32 +231,53 @@ func TestDetectRivalryArcs(t *testing.T) { {ID: "bot2", Name: "HunterBot"}, }, Matches: []MatchData{ + // Grudge match: 10+ meetings between the same pair {ID: "m1", Participants: []ParticipantData{ {BotID: "bot1", Won: true}, {BotID: "bot2", Won: false}, - }, PlayedAt: time.Date(2024, 3, 25, 12, 0, 0, 0, time.UTC)}, + }, PlayedAt: time.Date(2024, 3, 20, 12, 0, 0, 0, time.UTC)}, {ID: "m2", Participants: []ParticipantData{ {BotID: "bot1", Won: false}, {BotID: "bot2", Won: true}, - }, PlayedAt: time.Date(2024, 3, 26, 12, 0, 0, 0, time.UTC)}, + }, PlayedAt: time.Date(2024, 3, 21, 12, 0, 0, 0, time.UTC)}, {ID: "m3", Participants: []ParticipantData{ {BotID: "bot1", Won: true}, {BotID: "bot2", Won: false}, - }, PlayedAt: time.Date(2024, 3, 27, 12, 0, 0, 0, time.UTC)}, + }, PlayedAt: time.Date(2024, 3, 22, 12, 0, 0, 0, time.UTC)}, {ID: "m4", Participants: []ParticipantData{ {BotID: "bot1", Won: false}, {BotID: "bot2", Won: true}, - }, PlayedAt: time.Date(2024, 3, 28, 12, 0, 0, 0, time.UTC)}, + }, PlayedAt: time.Date(2024, 3, 23, 12, 0, 0, 0, time.UTC)}, {ID: "m5", Participants: []ParticipantData{ {BotID: "bot1", Won: true}, {BotID: "bot2", Won: false}, + }, PlayedAt: time.Date(2024, 3, 24, 12, 0, 0, 0, time.UTC)}, + {ID: "m6", Participants: []ParticipantData{ + {BotID: "bot1", Won: false}, + {BotID: "bot2", Won: true}, + }, PlayedAt: time.Date(2024, 3, 25, 12, 0, 0, 0, time.UTC)}, + {ID: "m7", Participants: []ParticipantData{ + {BotID: "bot1", Won: true}, + {BotID: "bot2", Won: false}, + }, PlayedAt: time.Date(2024, 3, 26, 12, 0, 0, 0, time.UTC)}, + {ID: "m8", Participants: []ParticipantData{ + {BotID: "bot1", Won: false}, + {BotID: "bot2", Won: true}, + }, PlayedAt: time.Date(2024, 3, 27, 12, 0, 0, 0, time.UTC)}, + {ID: "m9", Participants: []ParticipantData{ + {BotID: "bot1", Won: true}, + {BotID: "bot2", Won: false}, + }, PlayedAt: time.Date(2024, 3, 28, 12, 0, 0, 0, time.UTC)}, + {ID: "m10", Participants: []ParticipantData{ + {BotID: "bot1", Won: false}, + {BotID: "bot2", Won: true}, }, PlayedAt: time.Date(2024, 3, 29, 12, 0, 0, 0, time.UTC)}, }, } arcs := detectRivalryArcs(data) if len(arcs) == 0 { - t.Error("expected at least 1 rivalry arc with 5 matches between bots") + t.Error("expected at least 1 rivalry arc with 10+ grudge matches between bots") } }