MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / printIntentDiffs

Function printIntentDiffs

internal/cli/intent_cmd.go:67–95  ·  view source on GitHub ↗
(cmd *cobra.Command, db *sql.DB, runID string)

Source from the content-addressed store, hash-verified

65}
66
67func 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}

Callers 1

intentDiffCmdFunction · 0.85

Calls 3

shortFunction · 0.85
FlushMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected