Skip to content

Commit 1230645

Browse files
committed
fix: always normalize journal day number (agent might output wrong day)
1 parent 531688a commit 1230645

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

internal/evolution/git_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ func TestPersistJournalEntry_ZeroDay(t *testing.T) {
408408
e.persistJournalEntry(entry, "0")
409409

410410
data, _ := os.ReadFile(filepath.Join(dir, "docs/JOURNAL.md"))
411-
// day 0 means don't replace, so Day 99 should remain
412-
if !strings.Contains(string(data), "Day 99") {
413-
t.Errorf("should keep original day when day='0', got:\n%s", string(data))
411+
// day 0 should normalize agent's wrong day to Day 0
412+
if !strings.Contains(string(data), "## Day 0") {
413+
t.Errorf("should normalize to Day 0, got:\n%s", string(data))
414414
}
415415
}
416416

internal/evolution/phases_communicate.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ func (e *Engine) persistJournalEntry(journalEntry string, day string) {
119119
}
120120

121121
extracted = strings.TrimSpace(extracted)
122-
if dayNum > 0 {
123-
dayPattern := regexp.MustCompile(`^(#+)\s*Day\s*\d+`)
124-
extracted = dayPattern.ReplaceAllString(extracted, fmt.Sprintf("## Day %d", dayNum))
125-
}
122+
// Always normalize day number — agent might output wrong day
123+
dayPattern := regexp.MustCompile(`^(#+)\s*Day\s*\d+`)
124+
extracted = dayPattern.ReplaceAllString(extracted, fmt.Sprintf("## Day %d", dayNum))
126125

127126
journalPath := filepath.Join(e.repoPath, "docs/JOURNAL.md")
128127
_ = os.MkdirAll(filepath.Dir(journalPath), 0o755)

0 commit comments

Comments
 (0)