34b8b94223
- Runner-owned findings ledger per run: stages report a # findings section (new items and F<n> status changes); stable IDs, persisted (run_loop_state), in RunDetail.findings, findings.md, memory.md, inspect. - type=findings gate stage routes open/clear on the ledger mechanically. - retry --extra-visits N [--stage KEY] continues an exhausted loop; limits on_exhausted=decide parks the run on accept/continue/abort. - Essential memory cap 20 KB, task never truncated, handoff and open findings ahead of the outcome ledger. - Lint rejects limits.on outcomes on forward edges; warns on ineffective limits and resume_session. - A resumed retry carries the failed visit's output.md and private/ under previous-attempt/. - resume_session=true resumes a Claude stage's previous session on loop visits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/findings"
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
)
|
|
|
|
// inspectFindingsOpenCap bounds the open findings the compact summary lists;
|
|
// --json carries the whole ledger with every status change.
|
|
const inspectFindingsOpenCap = 20
|
|
|
|
// inspectFindings is the compact summary's findings section: counts per
|
|
// status, then the open findings (most severe first) and the closed ones by
|
|
// ID. Empty when the run has no ledger.
|
|
func inspectFindings(d *protocol.RunDetail) string {
|
|
if len(d.Findings) == 0 {
|
|
return ""
|
|
}
|
|
counts := findings.Counts(d.Findings)
|
|
var b strings.Builder
|
|
fmt.Fprintf(&b, "\nfindings: %d open, %d fixed, %d dismissed, %d settled\n", counts[protocol.FindingOpen], counts[protocol.FindingFixed], counts[protocol.FindingDismissed], counts[protocol.FindingSettled])
|
|
shown := 0
|
|
for _, severity := range append(append([]string(nil), findings.Severities...), "") {
|
|
for _, item := range d.Findings {
|
|
if item.Status != protocol.FindingOpen || (severity != "" && item.Severity != severity) || (severity == "" && findings.SeverityRank(item.Severity) >= 0) {
|
|
continue
|
|
}
|
|
if shown == inspectFindingsOpenCap {
|
|
fmt.Fprintf(&b, " … %d more open (--json)\n", counts[protocol.FindingOpen]-shown)
|
|
shown++
|
|
}
|
|
if shown > inspectFindingsOpenCap {
|
|
continue
|
|
}
|
|
shown++
|
|
b.WriteString(" " + findingLine(item) + "\n")
|
|
}
|
|
}
|
|
for _, status := range []string{protocol.FindingFixed, protocol.FindingDismissed, protocol.FindingSettled} {
|
|
var ids []string
|
|
for _, item := range d.Findings {
|
|
if item.Status == status {
|
|
ids = append(ids, item.ID)
|
|
}
|
|
}
|
|
if len(ids) > 0 {
|
|
fmt.Fprintf(&b, " %s: %s\n", status, strings.Join(ids, ", "))
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
func findingLine(item protocol.Finding) string {
|
|
line := fmt.Sprintf("%s %s · %s · %s", item.ID, item.Status, item.Severity, item.Origin)
|
|
if item.Location != "" {
|
|
line += " · " + item.Location
|
|
}
|
|
line += " — " + item.Summary
|
|
if item.Reason != "" {
|
|
line += " (" + item.Reason + ")"
|
|
}
|
|
return line
|
|
}
|