(cmd *cobra.Command, db *sql.DB, runID string)
| 65 | } |
| 66 | |
| 67 | func printIntentDiffs(cmd *cobra.Command, db *sql.DB, runID string) error { |
| 68 | rows, err := db.Query(`SELECT status, finding, contract_kind, operation, agent_id, round(confidence,2), mismatch_reason |
| 69 | FROM intent_diffs WHERE run_id = ? ORDER BY |
| 70 | CASE status WHEN 'refused_but_runtime_happened' THEN 0 WHEN 'declared_vs_effect_mismatch' THEN 1 |
| 71 | WHEN 'intent_coverage_gap' THEN 2 ELSE 3 END`, runID) |
| 72 | if err != nil { |
| 73 | return err |
| 74 | } |
| 75 | defer rows.Close() |
| 76 | w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0) |
| 77 | fmt.Fprintln(w, "STATUS\tFINDING\tKIND\tOP\tAGENT\tCONF\tREASON") |
| 78 | any := false |
| 79 | for rows.Next() { |
| 80 | var status, finding, kind, op, agent, reason string |
| 81 | var conf float64 |
| 82 | if err := rows.Scan(&status, &finding, &kind, &op, &agent, &conf, &reason); err != nil { |
| 83 | return err |
| 84 | } |
| 85 | any = true |
| 86 | if finding == "" { |
| 87 | finding = "-" |
| 88 | } |
| 89 | fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%.2f\t%s\n", status, finding, kind, op, short(agent), conf, reason) |
| 90 | } |
| 91 | if !any { |
| 92 | fmt.Fprintln(w, "(no diffs)") |
| 93 | } |
| 94 | return w.Flush() |
| 95 | } |
no test coverage detected