Skip to main content

Module ticket_notes

Module ticket_notes 

Source
Expand description

Ticket discussion notes — .kranz/tickets/<slug>.notes.jsonl (D-BW-3, adopted from beads’ flat {author, text, created_at} comment model).

One JSON object per line — {ts, author, text} — appended only: there is no edit or delete, mirroring the event log’s honesty posture. Notes are the ticket-scoped “why” channel the frontmatter (structured) and body (authored once) cannot carry; they are COMMITTED artifacts (same class as the ticket .md itself — see AGENTS.md’s tracked-vs-runtime list), not gitignored runtime state.

Durability follows the crate::event_log idiom: open O_APPEND (creating on first append), one write_all of the full line, flush, fsync. Appends are clock-stamped at write time; file order IS chronological order, so reads never re-sort.

Structs§

TicketNote
One note on a ticket. Field order is the on-disk key order (ts, author, text); additive-only like every persisted shape here.

Constants§

MAX_DRAFT_NOTES
How many notes draft_context folds into the drafter’s seed — the most recent N, so a long discussion cannot blow up the prompt.

Functions§

append_note
Append one note to a ticket’s discussion, creating the sidecar on first append. author is supplied by the caller (the CLI resolves KRANZ_NOTE_AUTHORoperator); text is trimmed, scrubbed (the file is committed — the same posture as text the engine writes into ticket bodies), and must not be empty. Returns the stored note.
draft_context
The markdown section crate::draft::drive_draft appends to the drafter’s seed: the most recent MAX_DRAFT_NOTES notes as bullets, with an omission marker when older ones were capped. None when the ticket has no notes (the seed is then exactly the folded ticket, as before).
read_notes
Read every note in file order (== chronological order, oldest first). A missing sidecar is the normal “no notes yet” case and reads as empty. A malformed line is an EngineError::Config naming the file and line — notes are a committed, tool-maintained record, so corruption is surfaced for repair rather than silently skipped.