Skip to main content

Module migrate_state

Module migrate_state 

Source
Expand description

The one-time fold of .status sidecars into committed frontmatter state: keys (design: ticket-state-frontmatter, rule 4) — kranz ticket migrate-state.

fold_sidecar_states walks .kranz/tickets/ and, for every ticket whose gitignored .status sidecar records the terminal pipeline state done, folds that verdict into the committed .md as state: done (carrying the sidecar note into state-note:) via Ticket::write_lifecycle — the one write path that also refreshes the sidecar cache. Dry-run by default: the same function with apply: false reports what it WOULD do without writing a byte, so the operator reviews the fold before applying it.

Three classes of ticket are never rewritten:

  • a ticket whose .md is DIRTY in git (uncommitted modification, or untracked): an in-flight editor or agent may have the file open, and rewriting it is the house-rule violation this command exists once to perform — the skip is reported by name so the operator can fold the ticket after that work lands. The dirty check is fail-closed: no git, no fold.
  • a ticket that already carries a state: key — this is what makes a re-run idempotent (the frontmatter is the source of truth; the fold only fills ABSENT keys, it never overwrites an operator’s verdict);
  • a ticket with no sidecar, or whose sidecar holds a non-terminal PIPELINE state (drafting/review/queued/failed/…): the frontmatter domain has no value for pipeline states — they stay sidecar-owned by design, and a fresh-clone re-read of an in-flight ticket as NEW is the same behavior the pipeline always had.

Structs§

MigrationReport
The fold plan (dry-run) or record (applied) over one repo’s tickets.

Enums§

FoldAction
One ticket’s fold decision.

Functions§

fold_sidecar_states
Plan (and with apply: true, perform) the fold of terminal .status sidecars into frontmatter state: keys. See the module docs for the skip rules. Fail-closed on the git dirty-check: when uncommitted edits cannot be detected, NOTHING is planned or written — the check is the only thing standing between the fold and an in-flight edit.