(f460853) Let the flow timestamps accumulate, and bump to 0.22.0

a6023e2 made the three stamps mutually exclusive: entering a status wrote
its field and leaving removed it, so a finished ticket carried exactly one
of the three and the journey behind it was invisible. A reader asking when
this was filed, when it was picked up, when it went out for review and when
it finished got one answer and three absences, and nothing could tell that
committed had ever happened.

So the removal rule is replaced by an accumulation rule. `mv` stamps the
target's field on entry, re-entering restamps, and arriving anywhere removes
the fields of every status *after* the target. That is one arrival rule off
the flow order `Status::ALL` already holds, not a case per move, and it is
also what a forward skip under `-f` wants: backlog straight to done stamps
`Completed On` alone and leaves the stages it jumped unwritten rather than
fabricated. A backward move truncates the journey at the target, so done
back to reviewing drops `Completed On` and keeps the two before it, and
anything back to backlog drops all three.

Presence therefore changes meaning. A field no longer says the ticket sits
in that status now, it says the ticket got that far and has not been sent
back past it. `Status` is what says where it is.

This is still not d4ce964's history log. These answer how far and when,
once per stage; every status change, every owner and every tag along the way
is the log's job.

The placement a6023e2 chose already holds: the three sit directly after
`Created At` in `METADATA_ORDER`, so a ticket that has walked the whole flow
reads as one block of four timestamps in flow order ahead of Campaign and
Status. Nothing but `mv` writes them, pinned by a test over `add`, `set`,
`append` and `chown`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-23 12:49:15 +02:00
co-authored by Claude Opus 5
parent 95426e87be
commit eae411ab50
5 changed files with 178 additions and 39 deletions
+72 -23
View File
@@ -1364,28 +1364,38 @@ pub const COMMITTED_ON_FIELD: &str = "Committed On";
pub const SUBMITTED_ON_FIELD: &str = "Submitted On";
pub const COMPLETED_ON_FIELD: &str = "Completed On";
/// Stamp the field of the status being entered and drop the other two.
/// Stamp the field of the status being entered and drop the ones after it.
///
/// A stamp is present exactly while the ticket sits in its status, so the three are
/// mutually exclusive: entering writes one, leaving removes it, and re-entering
/// restamps rather than keeping the first value. That is what keeps a ticket moved
/// backward under `-f` from carrying a `Completed On` for work it has undone, and it is
/// the line between these fields and d4ce964's history log. Metadata carries current
/// state, which is why `Status` is a field at all; the trail of how the ticket got here
/// belongs to the log, and a stamp left behind would be a second copy of that job.
/// The stamps accumulate down the flow rather than being mutually exclusive, so a
/// ticket that has walked the whole way carries `Created At`, `Committed On`,
/// `Submitted On` and `Completed On` side by side and the journey behind it is legible.
/// Presence therefore means the ticket got that far and has not been sent back past it,
/// not that it is sitting there now; `Status` is what says where it is.
///
/// One arrival rule covers both directions. A backward move truncates the journey at
/// the target, so `done` back to `reviewing` drops `Completed On` and keeps the two
/// before it, and anything back to `backlog` drops all three. A forward skip under `-f`
/// has nothing after it to clear, so `backlog` straight to `done` stamps `Completed On`
/// alone and leaves the stages it jumped over unwritten rather than fabricated.
/// Re-entering restamps rather than keeping the earlier value.
///
/// This is still not d4ce964's history log. These fields answer how far and when, once
/// per stage; every status change, every owner and every tag along the way is the log's
/// job and must not be grown here. `backlog` has no stamp, `Created At` answers for it.
///
/// The time comes in as a string rather than being read here, so the caller stamps the
/// same moment it reports and a test can pin the value.
pub fn set_status_stamp(content: &str, target: Status, now: &str, title: &str) -> Result<String> {
let mut content = content.to_string();
// Every status but the target, so a skipping move under `-f` clears the stamps of
// the stages it jumped over as well as the one it left.
for status in Status::ALL {
if status == target {
continue;
}
// Every status after the target, off the flow order `Status::ALL` already holds
// rather than a case per move, so arrival alone decides what is cleared and a
// backward move and a skip are the same rule.
for status in Status::ALL
.iter()
.skip_while(|status| **status != target)
.skip(1)
{
let Some(field) = status.stamp_field() else {
continue;
};
@@ -3403,10 +3413,10 @@ mod tests {
assert!(error.to_string().contains("Campaign"), "{error}");
}
/// The one stamp the target status carries, and nothing of the others: the fields
/// are current state, not a record of every stage the ticket has been through.
/// The stamp of the status being entered, added to what the ticket already carries:
/// the fields accumulate down the flow, so the stages behind it stay readable.
#[test]
fn entering_a_status_stamps_its_field_and_clears_the_rest() {
fn entering_a_status_stamps_its_field_and_keeps_the_ones_before_it() {
let content = with_metadata(
"- **ID**: abc\n- **Committed On**: 2026-08-01 09:00:00\n- **Status**: committed\n",
);
@@ -3415,25 +3425,64 @@ mod tests {
set_status_stamp(&content, Status::Reviewing, "2026-08-22 10:11:12", "T").unwrap();
assert!(updated.contains("- **Submitted On**: 2026-08-22 10:11:12"), "{updated}");
assert!(!updated.contains("**Committed On**"), "{updated}");
assert!(updated.contains("- **Committed On**: 2026-08-01 09:00:00"), "{updated}");
}
/// Backlog has no stamp of its own, so a backward move under `-f` leaves the ticket
/// carrying none rather than a Completed On for work it has undone.
/// Arrival truncates the journey at the target, so the stage the ticket has been
/// sent back out of is dropped and the ones it still got through are not.
#[test]
fn arriving_removes_the_stamps_of_the_statuses_after_the_target() {
let content = with_metadata(
"- **ID**: abc\n\
- **Committed On**: 2026-08-01 09:00:00\n\
- **Submitted On**: 2026-08-02 09:00:00\n\
- **Completed On**: 2026-08-03 09:00:00\n\
- **Status**: done\n",
);
let updated =
set_status_stamp(&content, Status::Reviewing, "2026-08-22 10:11:12", "T").unwrap();
assert!(!updated.contains("**Completed On**"), "{updated}");
assert!(updated.contains("- **Committed On**: 2026-08-01 09:00:00"), "{updated}");
assert!(updated.contains("- **Submitted On**: 2026-08-22 10:11:12"), "{updated}");
}
/// Backlog has no stamp of its own and every status follows it, so a ticket forced
/// all the way back carries none of the three rather than a trail it has undone.
#[test]
fn moving_back_to_backlog_leaves_no_stamp_behind() {
let content = with_metadata(
"- **ID**: abc\n- **Completed On**: 2026-08-01 09:00:00\n- **Status**: done\n",
"- **ID**: abc\n\
- **Committed On**: 2026-08-01 09:00:00\n\
- **Submitted On**: 2026-08-02 09:00:00\n\
- **Completed On**: 2026-08-03 09:00:00\n\
- **Status**: done\n",
);
let updated =
set_status_stamp(&content, Status::Backlog, "2026-08-22 10:11:12", "T").unwrap();
assert!(!updated.contains("**Completed On**"), "{updated}");
for field in [COMMITTED_ON_FIELD, SUBMITTED_ON_FIELD, COMPLETED_ON_FIELD] {
assert!(!updated.contains(&format!("**{}**", field)), "{updated}");
}
assert!(!updated.contains("2026-08-22 10:11:12"), "{updated}");
assert!(updated.contains("- **ID**: abc\n- **Status**: done\n"), "{updated}");
}
/// A skip stamps the target and nothing else. The stages it jumped over are left
/// unwritten rather than given a time the ticket never spent there.
#[test]
fn a_forward_skip_stamps_only_the_status_it_lands_in() {
let content = with_metadata("- **ID**: abc\n- **Status**: backlog\n");
let updated = set_status_stamp(&content, Status::Done, "2026-08-22 10:11:12", "T").unwrap();
assert!(updated.contains("- **Completed On**: 2026-08-22 10:11:12"), "{updated}");
assert!(!updated.contains("**Committed On**"), "{updated}");
assert!(!updated.contains("**Submitted On**"), "{updated}");
}
/// Re-entry is the time of the move that brought it back, not the first one.
#[test]
fn re_entering_a_status_restamps_rather_than_keeping_the_earlier_value() {