(451fb83) Add a discarded status for work that will not be done, and bump to 0.31.0
The flow ended at done, so a ticket that turned out to be a duplicate or obsolete had nowhere to go: it sat in the backlog or was deleted by hand, which destroyed the record and left every relation to it dangling. Discarded is a fifth status with its own directory, keeping the invariant that the filename, the Status field and the directory agree, and keeping done meaning the work landed. Entering it is allowed from any status without -f, because discarding is not a stage of work. Discarded sits last in Status::ALL, which is what makes the rest fall out rather than needing cases: nothing follows it, so a discard clears no stamp and a ticket abandoned from reviewing keeps the journey it made, and every move out is a backward move, so un-discarding needs -f. The two dependency guards now look opposite ways. check_blockers asks what a ticket waits on and gates work moves; check_dependents asks who waits on it and gates the discard, because those plans depended on work about to be declared never-happening. Both skip targets that are themselves terminal. Status::FLOW is the four stages the board draws, so a discarded column on screen stays a136d13's ticket and done stays the last drawn column. Every tree walker keeps using Status::ALL, or a discarded ticket would be unaddressable. util::is_open replaces three spellings of "not done and not discarded", across mv, ls and the campaign standing. The board's blocked mark goes through it as well: that path was only accidentally correct, since a discarded blocker is absent from the FLOW columns, and drawing the column later would have diverged it from what mv allows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
c03f47c52d
commit
5bf0fd1bfe
+82
-18
@@ -1437,7 +1437,7 @@ pub fn parse_tags(content: &str) -> Vec<String> {
|
||||
/// Directly after ID, because that is where `campaign_body` writes it, so a campaign given
|
||||
/// a codename later ends up with the same file as one filed with it. Nothing ever upserts
|
||||
/// it on a ticket, so its place in a ticket's order costs nothing.
|
||||
const METADATA_ORDER: [&str; 12] = [
|
||||
const METADATA_ORDER: [&str; 13] = [
|
||||
"ID",
|
||||
CODENAME_FIELD,
|
||||
"Priority",
|
||||
@@ -1448,6 +1448,7 @@ const METADATA_ORDER: [&str; 12] = [
|
||||
COMMITTED_ON_FIELD,
|
||||
SUBMITTED_ON_FIELD,
|
||||
COMPLETED_ON_FIELD,
|
||||
DISCARDED_ON_FIELD,
|
||||
CAMPAIGN_FIELD,
|
||||
"Status",
|
||||
];
|
||||
@@ -1532,6 +1533,7 @@ fn insert_metadata_field(content: &str, field: &str, value: &str, title: &str) -
|
||||
pub const COMMITTED_ON_FIELD: &str = "Committed On";
|
||||
pub const SUBMITTED_ON_FIELD: &str = "Submitted On";
|
||||
pub const COMPLETED_ON_FIELD: &str = "Completed On";
|
||||
pub const DISCARDED_ON_FIELD: &str = "Discarded On";
|
||||
|
||||
/// Stamp the field of the status being entered and drop the ones after it.
|
||||
///
|
||||
@@ -2196,6 +2198,12 @@ impl RelationIndex {
|
||||
self.tickets.iter().find(|ticket| ticket.uuid == uuid)
|
||||
}
|
||||
|
||||
/// Every ticket the index holds, for a caller asking about the derived direction:
|
||||
/// which tickets point *at* one, which no single `get` can answer.
|
||||
pub fn iter(&self) -> impl Iterator<Item = &RelatedTicket> {
|
||||
self.tickets.iter()
|
||||
}
|
||||
|
||||
/// The relations other tickets hold pointing at `uuid`, as the kind reads from
|
||||
/// this end and the ticket that holds it.
|
||||
///
|
||||
@@ -2288,11 +2296,14 @@ pub const REGRESSION_MARK: &str = "\u{2190}";
|
||||
/// nobody has picked up, orange for work in hand, cyan for work waiting on a reader,
|
||||
/// green for done. Green is the one the priority ramp deliberately leaves out because it
|
||||
/// means a title, and it is safe on a one-cell mark that no title sits behind.
|
||||
const STATUS_MARKS: [(&str, &str, Color); 4] = [
|
||||
const STATUS_MARKS: [(&str, &str, Color); 5] = [
|
||||
("backlog", "\u{25cb}", Color::Grey),
|
||||
("committed", "\u{25d0}", Color::Orange),
|
||||
("reviewing", "\u{25d0}", Color::Cyan),
|
||||
("done", "\u{25cf}", Color::Green),
|
||||
// The full circle of done in the grey of the untouched pile: nothing is left to do,
|
||||
// and it is not an achievement. The pair is what is unique, as with the two halves.
|
||||
("discarded", "\u{25cf}", Color::Grey),
|
||||
];
|
||||
|
||||
/// The mark for a status, or `?` for a target the board no longer holds.
|
||||
@@ -2675,35 +2686,54 @@ pub fn trim_blank_ends(values: &[String]) -> &[String] {
|
||||
/// A status, as clap accepts it and as the directory is named.
|
||||
///
|
||||
/// An enum rather than the string it was, so an unknown status is a usage error at parse
|
||||
/// time with the four listed, the way `priority_level` and `iso_date` refuse a bad level
|
||||
/// time with the five listed, the way `priority_level` and `iso_date` refuse a bad level
|
||||
/// or date. That is the bargain the scalars already take, see AGENTS.md: nothing is
|
||||
/// written, the exit code is 2, and no handler has to check. It also gives every shell
|
||||
/// that completes possible values the four names for free.
|
||||
/// that completes possible values the five names for free.
|
||||
///
|
||||
/// The variants are in flow order, which is the order `mv` reads to decide whether a
|
||||
/// move goes forward, and the order [`status_dirs`] hands the two views.
|
||||
/// The variants are in flow order with `Discarded` last, which is the order `mv` reads
|
||||
/// to decide whether a move goes forward and the order the stamp arrival rule truncates
|
||||
/// by. Discarded sits after done deliberately: entering it clears nothing, so a ticket
|
||||
/// discarded from reviewing keeps the journey it made, and leaving it is always a
|
||||
/// backward move, which is what makes un-discarding need `-f` for free.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
|
||||
pub enum Status {
|
||||
Backlog,
|
||||
Committed,
|
||||
Reviewing,
|
||||
Done,
|
||||
Discarded,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
/// Every status, in flow order. The one list, which [`status_dirs`], `mv` and every
|
||||
/// caller of [`by_status_order`] read rather than spelling the four names again.
|
||||
pub const ALL: [Status; 4] = [
|
||||
/// Every status, in flow order with discarded last. The one list, which
|
||||
/// [`status_dirs`], `mv` and every caller of [`by_status_order`] read rather than
|
||||
/// spelling the five names again.
|
||||
pub const ALL: [Status; 5] = [
|
||||
Status::Backlog,
|
||||
Status::Committed,
|
||||
Status::Reviewing,
|
||||
Status::Done,
|
||||
Status::Discarded,
|
||||
];
|
||||
|
||||
/// The stages work moves through: every status but discarded, which work never
|
||||
/// moves through, it only ends up in.
|
||||
///
|
||||
/// What the board draws its columns from, so done stays the last drawn column and
|
||||
/// hiding it stays a prefix of the list. Showing a discarded column is a136d13's,
|
||||
/// not a side effect of the status existing.
|
||||
pub const FLOW: [Status; 4] = [
|
||||
Status::Backlog,
|
||||
Status::Committed,
|
||||
Status::Reviewing,
|
||||
Status::Done,
|
||||
];
|
||||
|
||||
/// The field `mv` stamps on entering this status, for the three that have one.
|
||||
/// The field `mv` stamps on entering this status, for the four that have one.
|
||||
///
|
||||
/// Derived from the status rather than spelled at the call site, so the mapping is
|
||||
/// in one place and a fifth status either brings its own stamp or explicitly has
|
||||
/// in one place and a new status either brings its own stamp or explicitly has
|
||||
/// none.
|
||||
pub const fn stamp_field(self) -> Option<&'static str> {
|
||||
match self {
|
||||
@@ -2711,6 +2741,7 @@ impl Status {
|
||||
Status::Committed => Some(COMMITTED_ON_FIELD),
|
||||
Status::Reviewing => Some(SUBMITTED_ON_FIELD),
|
||||
Status::Done => Some(COMPLETED_ON_FIELD),
|
||||
Status::Discarded => Some(DISCARDED_ON_FIELD),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2722,6 +2753,7 @@ impl Status {
|
||||
Status::Committed => "committed",
|
||||
Status::Reviewing => "reviewing",
|
||||
Status::Done => "done",
|
||||
Status::Discarded => "discarded",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2734,11 +2766,34 @@ pub fn status_dirs() -> Vec<&'static str> {
|
||||
/// in the summary and leaves it out of the listing, and the board hides its column until
|
||||
/// asked. Named because that rule now has two readers.
|
||||
///
|
||||
/// It is deliberately last in `status_dirs()`. The board leans on that: hiding done drops
|
||||
/// the final column, so the other three keep their indices and the selection only has to
|
||||
/// be handled when it is sitting on done itself.
|
||||
/// It is deliberately last in [`Status::FLOW`], which is what the board draws. The board
|
||||
/// leans on that: hiding done drops the final column, so the other three keep their
|
||||
/// indices and the selection only has to be handled when it is sitting on done itself.
|
||||
pub const DONE: &str = Status::Done.as_str();
|
||||
|
||||
/// Where a ticket that will not be done ends up: the other terminal status, and the
|
||||
/// other one `ls` leaves out of the listing.
|
||||
///
|
||||
/// A discarded ticket counts as finished wherever progress is measured, since nothing is
|
||||
/// left to do, and blocks nothing. What it is not is done: the two directories keep
|
||||
/// "the work landed" and "the work was abandoned" answerable apart.
|
||||
pub const DISCARDED: &str = Status::Discarded.as_str();
|
||||
|
||||
/// Whether a ticket in this status still has something outstanding.
|
||||
///
|
||||
/// The two terminal statuses do not: done landed and discarded never will, so in both
|
||||
/// cases there is nothing left to wait for and nothing left to plan around. One spelling
|
||||
/// for all three readers, because `mv` refuses a move on it, refuses a discard on it and
|
||||
/// the board draws its blocked mark from it, and two views disagreeing about what counts
|
||||
/// as open would be the difference nobody can explain later.
|
||||
///
|
||||
/// Takes the status as a string because that is what the callers hold: the directory a
|
||||
/// ticket was found in, not a parsed [`Status`]. An unrecognised value reads as open,
|
||||
/// which is the safe direction: it surfaces rather than silently satisfying a block.
|
||||
pub fn is_open(status: &str) -> bool {
|
||||
status != DONE && status != DISCARDED
|
||||
}
|
||||
|
||||
/// Lowest and highest level a ticket can carry. 1 is the most urgent, which is
|
||||
/// what the `p1` to `p3` tags this replaced already meant.
|
||||
pub const PRIORITY_RANGE: std::ops::RangeInclusive<u8> = 1..=5;
|
||||
@@ -2867,6 +2922,8 @@ pub struct TicketItem {
|
||||
pub submitted_on: Option<String>,
|
||||
/// The same for done.
|
||||
pub completed_on: Option<String>,
|
||||
/// The same for discarded.
|
||||
pub discarded_on: Option<String>,
|
||||
}
|
||||
|
||||
impl TicketItem {
|
||||
@@ -2882,6 +2939,7 @@ impl TicketItem {
|
||||
Status::Committed => self.committed_on.as_deref(),
|
||||
Status::Reviewing => self.submitted_on.as_deref(),
|
||||
Status::Done => self.completed_on.as_deref(),
|
||||
Status::Discarded => self.discarded_on.as_deref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3076,6 +3134,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
committed_on: parse_stamp(&content, Status::Committed),
|
||||
submitted_on: parse_stamp(&content, Status::Reviewing),
|
||||
completed_on: parse_stamp(&content, Status::Done),
|
||||
discarded_on: parse_stamp(&content, Status::Discarded),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -3104,7 +3163,8 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
|
||||
/// always printed. Past the backlog the question changes: committed asks what has waited
|
||||
/// longest, reviewing what was handed over first, done what just landed. The head of
|
||||
/// every column is therefore what the reader acts on next, which is ascending by entry
|
||||
/// stamp in committed and reviewing and descending in done, the way a changelog reads.
|
||||
/// stamp in committed and reviewing and descending in done and discarded, the way a
|
||||
/// changelog reads.
|
||||
///
|
||||
/// A ticket with no stamp sinks below every stamped one in its column. A missing time is
|
||||
/// unknown, not ancient, and unknown must not claim the head of a queue ahead of a wait
|
||||
@@ -3118,7 +3178,7 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
|
||||
pub fn by_status_order(status: Status, a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
|
||||
let by_stamp = match (a.entry_stamp(status), b.entry_stamp(status)) {
|
||||
(Some(left), Some(right)) => match status {
|
||||
Status::Done => right.cmp(left),
|
||||
Status::Done | Status::Discarded => right.cmp(left),
|
||||
_ => left.cmp(right),
|
||||
},
|
||||
(Some(_), None) => std::cmp::Ordering::Less,
|
||||
@@ -4132,7 +4192,11 @@ mod tests {
|
||||
_ => None,
|
||||
},
|
||||
completed_on: match status {
|
||||
Status::Done => stamp,
|
||||
Status::Done => stamp.clone(),
|
||||
_ => None,
|
||||
},
|
||||
discarded_on: match status {
|
||||
Status::Discarded => stamp,
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
@@ -5190,7 +5254,7 @@ Plain line with **bold** and a [link](http://x.test/a).
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(seen.len(), 4, "{seen:?}");
|
||||
assert_eq!(seen.len(), status_dirs().len(), "{seen:?}");
|
||||
}
|
||||
|
||||
/// An unrecognised value reads as missing rather than as a fifth stage of the flow.
|
||||
|
||||
Reference in New Issue
Block a user