Documentation
¶
Overview ¶
Package trace correlates recent git commits with PM plan tasks using an AI provider. It walks git log, sends commit messages + task list to the provider, and returns a structured mapping of commit→task with confidence levels.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt constructs the AI prompt for commit→task mapping.
func WriteTraceJSON ¶
WriteTraceJSON persists the trace map to .cloop/trace.json.
The write is atomic: data is staged in a sibling .tmp file, fsynced, chmod'd, then renamed into place. Without this, a crash mid-write or ENOSPC would leave trace.json corrupted, which would silently break `cloop status` (which calls LastLinkedCommit on every invocation) and any tooling that loads the commit→task mapping.
Types ¶
type Confidence ¶
type Confidence string
Confidence is the AI-rated match quality for a commit→task pairing.
const ( ConfidenceHigh Confidence = "high" ConfidenceMedium Confidence = "medium" ConfidenceLow Confidence = "low" ConfidenceNone Confidence = "none" )
type TraceEntry ¶
type TraceEntry struct {
Hash string `json:"hash"`
Subject string `json:"subject"`
MatchedTaskID int `json:"matched_task_id"` // 0 = no match
MatchedTaskTitle string `json:"matched_task_title"` // empty = no match
Confidence Confidence `json:"confidence"`
}
TraceEntry links a single commit to a task (or indicates no match).
func LastLinkedCommit ¶
func LastLinkedCommit(workDir string) *TraceEntry
LastLinkedCommit returns the most recent commit entry that was matched to a task, or nil if none found. Used by `cloop status`.
type TraceMap ¶
type TraceMap struct {
GeneratedAt time.Time `json:"generated_at"`
Entries []TraceEntry `json:"entries"`
}
TraceMap is the complete mapping for a run.
func LoadTraceJSON ¶
LoadTraceJSON reads the persisted trace map from .cloop/trace.json. Returns nil without error when the file does not exist.
On parse failure (zero-byte file from a torn pre-atomicfile write, schema drift, manual edit gone wrong) the corrupt trace.json is quarantined aside as trace.json.corrupt-<unix> and (nil, nil) is returned. The trace map is a derived index of commit→task links; `cloop status`, LastLinkedCommit, and similar callers all already handle the "no trace data yet" case, so returning empty is strictly better than refusing every status query until the user manually deletes the corrupt file.