| 1 | package completion |
| 2 | |
| 3 | import "strings" |
| 4 | |
| 5 | // AttentionInput is the content-free summary both frontends use to decide |
| 6 | // whether a turn should interrupt the user. |
| 7 | type AttentionInput struct { |
| 8 | Verdict string |
| 9 | ChecksFailed int |
| 10 | GapKinds []string |
| 11 | Floor string |
| 12 | RequiredSuppressed bool |
| 13 | } |
| 14 | |
| 15 | // NeedsAttention reports a user-facing quality interrupt. Scratch writes, |
| 16 | // unreviewed workspace files on the standard floor, and unavailable review |
| 17 | // do not qualify. |
| 18 | func NeedsAttention(in AttentionInput) bool { |
| 19 | if strings.EqualFold(strings.TrimSpace(in.Verdict), "blocked") || in.ChecksFailed > 0 || in.RequiredSuppressed { |
| 20 | return true |
| 21 | } |
| 22 | kinds := make(map[string]bool, len(in.GapKinds)) |
| 23 | for _, kind := range in.GapKinds { |
| 24 | kinds[strings.ToLower(strings.TrimSpace(kind))] = true |
| 25 | } |
| 26 | if kinds["unbacked_claim"] || kinds["failed_verification"] { |
| 27 | return true |
| 28 | } |
| 29 | if strings.EqualFold(strings.TrimSpace(in.Floor), "delivery") { |
| 30 | return kinds["unverified_change"] || kinds["missing_check"] || kinds["stale_verification"] || kinds["unproven_criterion"] |
| 31 | } |
| 32 | return false |
| 33 | } |
| 34 |