codetether_agent/session/tasks/event/goal_source.rs
1//! Goal provenance categories.
2//!
3//! This module defines the trust category attached to a session goal when it is
4//! written to the append-only task log. The category records where the goal came
5//! from, allowing recovery, governance, and debugging code to distinguish goals
6//! grounded in raw transcript evidence from goals inferred through weaker or
7//! lossy sources.
8//!
9//! The enum is serialized as `snake_case` so goal provenance remains stable and
10//! readable in persisted JSONL task logs.
11
12use serde::{Deserialize, Serialize};
13
14/// Provenance category for a declared session goal.
15///
16/// `GoalSourceKind` describes the evidence source used to create a session
17/// objective. Consumers should treat variants as a rough trust hierarchy:
18/// direct raw-turn or user-provided goals are stronger than summarized recall,
19/// memory-derived, or inferred goals.
20///
21/// The default is [`GoalSourceKind::Inferred`], which is intentionally the
22/// weakest category. This keeps older log entries and omitted provenance fields
23/// safe by marking them as unverified rather than pretending they came from a
24/// canonical user turn.
25#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(rename_all = "snake_case")]
27pub enum GoalSourceKind {
28 /// The goal was anchored to a raw transcript turn.
29 ///
30 /// Use this when the objective is derived directly from canonical session
31 /// history, such as a specific user message returned by `context_browse`.
32 RawTurn,
33
34 /// The goal was explicitly provided by the user.
35 ///
36 /// This is appropriate for direct goal-setting interfaces such as a TUI
37 /// `/goal set ...` command or a user request that intentionally declares the
38 /// current objective.
39 UserProvided,
40
41 /// The goal was derived from summarized session recall.
42 ///
43 /// Recall summaries are useful for recovery but may omit, blend, or
44 /// mis-rank details from raw history. Consumers should verify this kind
45 /// against transcript turns before treating it as authoritative.
46 RecallSummary,
47
48 /// The goal was derived from curated durable memory.
49 ///
50 /// Memory can preserve important decisions across sessions, but it may be
51 /// stale or broader than the current conversation. Consumers should consider
52 /// memory scope and timestamp before using it as a hard constraint.
53 Memory,
54
55 /// The goal was inferred without stronger provenance.
56 ///
57 /// This is the fallback for missing provenance and should be treated as
58 /// low-confidence until confirmed by the user or anchored to raw transcript
59 /// evidence.
60 #[default]
61 Inferred,
62}