fix: extend valid phases and return empty slice for missing session
Add "retrospective" to validPhases so non-TDD skills pass Validate().
Return []Entry{} instead of nil in session.Read when no file exists,
so JSON serialisation produces [] rather than null.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,12 @@ type Result struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var validStatuses = map[string]bool{"pass": true, "fail": true, "error": true}
|
var validStatuses = map[string]bool{"pass": true, "fail": true, "error": true}
|
||||||
var validPhases = map[string]bool{"red": true, "green": true, "refactor": true}
|
var validPhases = map[string]bool{
|
||||||
|
"red": true,
|
||||||
|
"green": true,
|
||||||
|
"refactor": true,
|
||||||
|
"retrospective": true,
|
||||||
|
}
|
||||||
|
|
||||||
func (r Result) Validate() error {
|
func (r Result) Validate() error {
|
||||||
var errs []string
|
var errs []string
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func Read(sessionsDir, sessionID string) ([]Entry, error) {
|
|||||||
path := filepath.Join(sessionsDir, sessionID+".jsonl")
|
path := filepath.Join(sessionsDir, sessionID+".jsonl")
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
return nil, nil
|
return []Entry{}, nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("open session log: %w", err)
|
return nil, fmt.Errorf("open session log: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user