Compare commits

..
3 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 cbc20848f6 (1845355) Order each status column by its entry stamp, and bump to 0.23.0
Every view read its rows out of `collect_ticket_items`, which sorts by
`by_priority_then_title` because it sees one directory and no status. That
is the right order for the backlog, where priority is the clock. Past the
backlog the question changes: committed asks what has waited longest,
reviewing what was handed over first, done what just landed. All four
columns answering the first question is why a finished p5 sat above the p1
nobody had read yet.

So each column takes its own order, through one `by_status_order` keyed on
the `Status` rather than four comparators at four call sites. Backlog
delegates to the comparator it already used. Committed sorts by
`Committed On` ascending and reviewing by `Submitted On` ascending, so the
longest wait is at the head where the reader picks next from; done sorts by
`Completed On` descending, newest first, the way a changelog reads.
Ascending twice and once descending is one rule said three ways: the head of
every column is what the reader acts on next.

A ticket carrying no stamp sinks below every stamped one in its column and
falls back to priority then title among its own kind, as do equal stamps --
`mv` writes whole seconds, so a tie is real. A missing time is unknown, not
ancient, and unknown must not claim the head of a queue ahead of a wait
somebody can point at. Reading absence as the epoch would have come free
from the comparison and put every ticket filed before f460853 first.

The comparison is a string comparison. `%Y-%m-%d %H:%M:%S` is lexicographic
in chronological order, the property `Due` already relies on, so nothing
parses a date at sort time. The stamps are read on the pass
`collect_ticket_items` already makes over each file, the rule `criteria` and
`tags` already hold, and never per comparison.

Both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`
take it, which is why those loops walk `Status::ALL` rather than
`status_dirs()`: the directory name does not say which stamp governs it. The
merge tab keeps priority then title outright and is pinned there -- it spans
statuses, so no single stamp governs it. `cmd_tags` is left alone; it counts
into a `BTreeMap` and never reads an order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 12:58:34 +02:00
Ansho ReiandClaude Opus 5 eae411ab50 (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>
2026-08-23 12:49:15 +02:00
Ansho ReiandClaude Opus 5 95426e87be (d637288) Guard an existing codename behind --force, and bump to 0.21.1
`campaign set --codename` replaced whatever was there. Once a campaign has
a codename it is referred to by it -- on every card in the campaign, at the
command line, and in somebody's shell history -- so changing it silently is
the mistake `install-skill --force` exists to prevent.

So it is refused, and the refusal names both words and the flag rather than
leaving it to be found. Checked before any edit is applied, like
`SetArgs::contested`, so a call also carrying `--title` writes neither
field rather than half of what was asked for.

Setting the codename a campaign already carries stays a no-op rather than
becoming a refusal: `--force` is about overwriting a *different* word, and
there is nothing to overwrite. That is the division `install::Outcome`
already draws between `Unchanged` and `Refused`.

`--force` guards the codename alone. A campaign always has a title, so
guarding that would mean the flag was always required, which is a tax
rather than a guard.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 12:28:40 +02:00
14 changed files with 967 additions and 81 deletions
+4 -2
View File
@@ -22,7 +22,8 @@
- Filenames: `<uuid_v4>_<slug>.md`
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Campaign`, `Status`. The last four are the ones no ticket is born with: `add` writes none of them, so they are inserted on demand, against `METADATA_ORDER`, which is also what keeps `Status` last
- The three stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they are mutually exclusive: entering a status writes its field, leaving removes it, re-entering restamps. So a ticket carries at most one, the one for the status it is sitting in, and a backward move under `-f` leaves no stale `Completed On` behind. They are current state, like `Status` itself; the trail of how the ticket got there is d4ce964's job and must not be grown here. `backlog` has no stamp, `Created At` already answers for it
- The three stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they **accumulate**: entering a status writes its field, re-entering restamps, and arriving anywhere removes the fields of every status *after* the target. One arrival rule keyed off `Status::ALL`, not a case per move, which is why a backward move truncates the journey at the target (`done` back to `reviewing` drops `Completed On`, anything back to `backlog` drops all three) and a forward skip under `-f` stamps only where it lands rather than fabricating the stages it jumped. A ticket that walks the whole flow ends with `Created At`, `Committed On`, `Submitted On` and `Completed On` side by side, so presence means *got this far and has not been sent back past it*, not *is here now* — `Status` is what says where it is. Still not d4ce964's history log: these answer how far and when, once per stage, and every change along the way is the log's. `backlog` has no stamp, `Created At` already answers for it
- **Each status column is ordered by its own entry stamp, through `by_status_order`.** Priority is the clock in the backlog and that column keeps priority then title; past it the question changes, so committed sorts by `Committed On` ascending, reviewing by `Submitted On` ascending, and done by `Completed On` descending. Said once: the head of every column is what the reader acts on next. An unstamped ticket sinks below every stamped one in its column, because a missing time is unknown rather than ancient and unknown must not claim the head of a queue; equal stamps and both-unstamped fall through to `by_priority_then_title`. One function keyed on the `Status`, taken by both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`, which is why those loops walk `Status::ALL` rather than `status_dirs()`. The stamps are read in `collect_ticket_items`' existing pass, the rule `criteria` and `tags` already hold, and compared as strings: `%Y-%m-%d %H:%M:%S` is lexicographic in chronological order, the property `Due` already relies on, so nothing parses a date at sort time
- Format: `**Field Name**: value`
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
- A **campaign** file carries `ID`, `Codename`, `Owner` and `Created At`, in that order, and no `Status`. `Codename` sits directly under the ID because that is what it is, a second way to say which campaign this is; it is written by `campaign add --codename` alone and is `_Not set_` when the flag was not given. It is not in `METADATA_ORDER`, which is the anchor list for the *upsert* on a ticket, and nothing upserts a campaign
@@ -179,6 +180,7 @@ and this file is for what someone changing worklane's own code needs.
- **The TUI got a card label and a frame, not a campaign tab.** 61879a4 decided it. A tab would have had to answer what its columns are, and a campaign groups *across* the flow rather than within one status, so the honest answer is the four statuses filtered — which is a filter on the board it already has rather than a fifth tab. So: a label on the card, a frame above the columns while one is selected, and `c` for the picker. The cost the earlier decision balked at, a campaigns read per reload, is paid once per project in `columns_of` and is what names the label; see The Board View
- **A campaign is named by its codename on the board, and by its short id when it has none.** The uuid does not fit on a card and the title is a sentence, which is the gap `Codename` fills. `campaign_label` builds it in one place, as a `Cell`, so the CLI paints it and the board makes a span of it; the mark is `CAMPAIGN_MARK`, `~`, beside `#` for a tag
- **`campaign set` is the only writer of a filed campaign's fields, and it carries the two scalars.** d637288 decided it: a `set` rather than a flag on something narrower, because the file has more than one editable thing and the moment somebody wants to fix a typo in a title there would be a second command to design. `--title`, which renames the file the way `set --title` does, and `--codename`. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
- **Replacing a codename the campaign already has needs `--force`.** Once a campaign has one it is referred to by it: it is on every card in the campaign, it is what resolves the campaign at the command line, and it is in somebody's shell history. Changing it silently is the mistake `install-skill --force` exists to prevent, so it is refused and the refusal names both words and the flag rather than leaving it to be found. Checked before any edit is applied, like `SetArgs::contested`, so a call also carrying `--title` writes neither field. Setting the codename a campaign already carries stays a **no-op, not a refusal** — `--force` is about overwriting a *different* word, which is the same division `install::Outcome` draws between `Unchanged` and `Refused`. `--force` guards the codename alone: a campaign always has a title, so guarding that would mean the flag was always required
- **No `campaign set --description`, and that is the line, not an oversight.** `set` and `append` are a pair for a prose section: a way to replace a description with no way to add a paragraph is half of it. The two scalars have no append form at all, which is the same line `append` already draws for a ticket. `campaign_set_offers_no_description_and_no_owner` pins it. No `--owner` either, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign; and no `--clear`, because a wrong codename is replaced rather than emptied and `Clearable` is `SetArgs`'s, its variants being a ticket's fields
- **The codename is written through `set_or_insert_metadata_field`, not `set_metadata_field`.** Every campaign filed before the field existed has no such line, and those are exactly the campaigns the command is for, which is the same reasoning that puts `assign` on the upsert. **`Codename` is therefore in `METADATA_ORDER`, directly after ID**, so an inserted one lands where `campaign_body` writes it and a campaign given a codename later is the same file as one filed with it. Nothing upserts it on a ticket, so its place in a ticket's order costs nothing
- **One write path for tickets and campaigns.** `save_entry` is the body, `save_ticket` and `save_campaign` are the named wrappers, and `write_then_replace` and `find_entry_file` take the noun as a `&str` so a failure says "campaign" where it is one. A campaign file is a ticket file in every way that matters here, `<uuid>_<slug>.md` in a directory, and the rename happens only after the write has landed. Every message puts the noun mid-sentence so there is no capital to case
@@ -308,7 +310,7 @@ and this file is for what someone changing worklane's own code needs.
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `show_done` stays on the board because it is a preference about the flow rather than about a project
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. That comparator is exported for this and is the one `collect_ticket_items` uses, so the two orders cannot drift
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. It keeps priority then title where every other column takes `by_status_order`: the merge spans statuses, so no single entry stamp governs it
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.21.0"
version = "0.23.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.21.0"
version = "0.23.0"
edition = "2024"
[dependencies]
+1 -1
View File
@@ -19,7 +19,7 @@ Worklane is a local Kanban flow for agentic software development.
| `worklane uncheck <ticket> [criteria...]` | Unticks acceptance criteria, addressed the same way |
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
| `worklane campaign add` | Files a campaign in `.worklane/campaigns/` with `--title`, `--description`, `--codename` and `--owner`. A campaign has no status: its state is derived, open until every member is done. `--codename` is one word to call it by, `v1` or `beaver`, which is what the board draws on every card in it and what every command that takes a campaign will also resolve it by |
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
| `worklane campaign ls` | Lists the campaigns as their short id, their codename, their title and how many members are done. `--ids` prints one per line as the id, a tab and the title, unstyled, for a script or a completion |
| `worklane campaign show <campaign>` | Shows a campaign and its members grouped by status, done included, since what is finished against what is left is the question a campaign asks |
| `worklane assign <campaign> <ticket>` | Puts a ticket in a campaign, the only command that writes the Campaign field. Campaign first and ticket second, after `chown`. A ticket is in at most one, so assigning one that already belongs somewhere moves it |
+4 -1
View File
@@ -160,7 +160,7 @@ fields; a goal is a campaign.
worklane campaign ls
worklane campaign show v1
worklane campaign add --title "..." --codename v1 --description "..."
worklane campaign set v1 --codename beaver # or --title, on one already filed
worklane campaign set v1 --title "..." # or --codename, on one already filed
worklane assign v1 1b78a24
```
@@ -183,6 +183,9 @@ tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
line, and a campaign filed without one is drawn by its short id, which says nothing. A
campaign already on the board that has no codename is worth pointing out for the same
reason a near-duplicate tag is, and `campaign set` is how it gets one without refiling.
- **Do not propose renaming a codename a campaign already has.** It is what the campaign is
called on every card in it and at the command line, so changing it is churn dressed as
grooming. `campaign set` refuses it without `--force` for that reason.
Proposing a campaign means naming the goal, the members, and what is deliberately left
out of it. The last part is what makes it a goal rather than a pile.
+3 -1
View File
@@ -222,7 +222,9 @@ sentence, and it is the shortest thing that addresses the campaign at the comman
Optional: a campaign without one is drawn and listed by its short id instead, which
resolves but says nothing. `campaign set <campaign> --codename <word>` gives one to a
campaign that is already filed, which is what every campaign filed before the field
existed needs.
existed needs. **Replacing a codename it already has needs `--force`**: that word is how
the campaign is referred to on the board and at the command line, so changing it is a
decision rather than a correction. Setting the one it already has is a no-op either way.
`campaign set` is the only way to change a campaign after it is filed, and it reaches the
title and the codename only. There is no way to edit a campaign's description or its owner
+12 -9
View File
@@ -201,20 +201,23 @@ pub fn resolved_for(content: &str, worklane_dir: &Path, colored: bool) -> Result
pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec<TicketItem>)>> {
let mut grouped = Vec::new();
for status in status_dirs() {
let status_path = worklane_dir.join(status);
// Over `Status::ALL` rather than the names, so each group can be put in its own
// column's order: a campaign's committed list answers what has waited longest for
// the same reason the board's column does.
for status in Status::ALL {
let status_path = worklane_dir.join(status.as_str());
let items = match status_path.exists() {
true => collect_ticket_items(&status_path)?,
false => Vec::new(),
};
grouped.push((
status,
items
.into_iter()
.filter(|item| item.campaign.as_deref() == Some(uuid))
.collect(),
));
let mut members: Vec<TicketItem> = items
.into_iter()
.filter(|item| item.campaign.as_deref() == Some(uuid))
.collect();
members.sort_by(|a, b| by_status_order(status, a, b));
grouped.push((status.as_str(), members));
}
Ok(grouped)
+18 -1
View File
@@ -337,6 +337,13 @@ pub enum CampaignCommand {
/// variants are a ticket's fields, so reusing it here would put a ticket's enum on a
/// campaign and inventing a second one is a decision worth making on purpose.
///
/// `--force` guards the codename and nothing else. A campaign that already has one is
/// referred to by it: it is on every card in the campaign, it is what resolves it at the
/// command line, and it is very likely in somebody's shell history. Replacing that silently
/// is the same mistake overwriting an edited skill document would be, which is what
/// `install-skill --force` exists for. A title needs no guard, since a campaign always has
/// one and replacing it is the whole point of the flag.
///
/// The group makes at least one field mandatory, so a bare `worklane campaign set <c>` is a
/// usage error rather than a silent no-op, exactly as it is for [`SetArgs`].
#[derive(clap::Args)]
@@ -357,9 +364,19 @@ pub struct CampaignSetArgs {
/// Replace the codename, a single word to call the campaign by
///
/// The same parser `campaign add --codename` takes, so a codename is one thing however
/// it was written.
/// it was written. Replacing one a campaign already has needs `--force`
#[arg(short, long, value_parser = codename)]
pub codename: Option<String>,
/// Replace a codename the campaign already has
///
/// Without it, `--codename` on a campaign that already has one is refused and nothing
/// is written. The codename is how a campaign is referred to once it has one, on every
/// card in it and at the command line, so changing it is a decision rather than a
/// correction. Setting the codename a campaign already carries is a no-op either way,
/// not a refusal: there is nothing to overwrite
#[arg(short, long)]
pub force: bool,
}
/// What a campaign holds: a title, a description and an owner.
+53 -17
View File
@@ -63,8 +63,10 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
}
if let Some(status) = args.status {
let status = status.as_str();
let status_path = worklane_dir.join(status);
// The `Status` is kept alongside its name: the directory is joined from the
// name, and the order the column prints in is keyed on the status itself.
let name = status.as_str();
let status_path = worklane_dir.join(name);
if !status_path.exists() {
// The status itself is clap's to reject now, so reaching here means the
// board is missing a directory it should have rather than that the name was
@@ -72,19 +74,20 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
// alone.
return Err(anyhow!(
"No '{}' directory in {}. Every board has all four; creating it is enough.",
status,
name,
worklane_dir.display()
));
}
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
let mut items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
items.sort_by(|a, b| by_status_order(status, a, b));
if items.is_empty() {
println!("No tickets in '{}' status.", status);
println!("No tickets in '{}' status.", name);
return Ok(());
}
println!("Tickets in '{}' status:\n", status);
println!("Tickets in '{}' status:\n", name);
display_ticket_items(&items);
} else {
// List all statuses with their ticket counts
@@ -101,23 +104,27 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
println!(" [{}] {} {}", status.to_uppercase(), count, label);
}
// Show all tickets except done grouped by status
for status in &statuses {
if *status == DONE {
// Show all tickets except done grouped by status. Over `Status::ALL` rather
// than the names, because each column is ordered by its own entry stamp and the
// comparator is keyed on the status, not on the directory it was read from.
for status in Status::ALL {
if status.as_str() == DONE {
continue;
}
let status_path = worklane_dir.join(status);
let status_path = worklane_dir.join(status.as_str());
if !status_path.exists() || !fs::metadata(&status_path)?.is_dir() {
continue;
}
let items = match collect_ticket_items(&status_path) {
let mut items = match collect_ticket_items(&status_path) {
Ok(items) => filtered(items, priority_filter, uuid, tag),
Err(_) => continue,
};
items.sort_by(|a, b| by_status_order(status, a, b));
if items.is_empty() {
continue;
}
let status_header = color_text(&format!("[{}]", status.to_uppercase()), Color::Orange);
let status_header =
color_text(&format!("[{}]", status.as_str().to_uppercase()), Color::Orange);
println!("\n{}", status_header);
display_ticket_items(&items);
}
@@ -150,16 +157,20 @@ fn list_ids(
worklane_dir: &Path,
) -> Result<()> {
let statuses = match status {
Some(status) => vec![status.as_str()],
None => status_dirs(),
Some(status) => vec![status],
None => Status::ALL.to_vec(),
};
for status in statuses {
let status_path = worklane_dir.join(status);
let status_path = worklane_dir.join(status.as_str());
if !status_path.exists() {
continue;
}
for item in filtered(collect_ticket_items(&status_path)?, level, campaign, tag) {
// The same order the listing prints, so a completion and the board agree on
// which ticket is at the head of a column.
let mut items = filtered(collect_ticket_items(&status_path)?, level, campaign, tag);
items.sort_by(|a, b| by_status_order(status, a, b));
for item in items {
println!("{}\t{}", item.id, item.title);
}
}
@@ -1242,13 +1253,38 @@ pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
/// `set_or_insert_metadata_field`, the upsert `assign` already uses for the Campaign field
/// on a ticket, for the same reason.
///
/// **Replacing a codename the campaign already has needs `--force`.** Once a campaign has
/// one it is referred to by it: it is on every card in the campaign, it is what resolves the
/// campaign at the command line, and changing it out from under that is the same mistake
/// overwriting an edited skill document would be. So it is refused, and the refusal names
/// both words and the flag, the way `install-skill` names `--force` rather than leaving it
/// to be found.
///
/// Checked before any edit is applied, like `SetArgs::contested`, so a call that also
/// carries `--title` writes neither field rather than half of what was asked for.
///
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
/// codename a campaign already carries writes nothing.
/// codename a campaign already carries writes nothing. That is a no-op and not a refusal:
/// `--force` is about overwriting a *different* word, and there is nothing to overwrite.
pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
let worklane_dir = find_worklane_dir(start)?;
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
let title = campaign.title.clone();
let overwrite = match (&args.codename, &campaign.codename) {
(Some(wanted), Some(held)) if wanted != held => Some((held, wanted)),
_ => None,
};
if let Some((held, wanted)) = overwrite.filter(|_| !args.force) {
return Err(anyhow!(
"Campaign '{}' is already codenamed '{}', so nothing was written. \
Pass --force to replace it with '{}'",
title,
held,
wanted
));
}
let mut content = campaign.content.clone();
let mut changed: Vec<&str> = Vec::new();
+97 -3
View File
@@ -1157,12 +1157,14 @@ fn span_of(cell: Cell) -> Span<'static> {
fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex) {
let campaigns = CampaignIndex::load(worklane_dir).unwrap_or_default();
let mut columns: Vec<Column> = status_dirs()
// Over `Status::ALL` rather than the names: each column is ordered by its own entry
// stamp, so the build needs the status itself and not just the directory to read.
let mut columns: Vec<Column> = Status::ALL
.into_iter()
.map(|status| {
// An absent or unreadable directory is an empty column, not a missing one:
// the four statuses are the shape of the board.
let cards = collect_ticket_items(worklane_dir.join(status))
let mut cards: Vec<Card> = collect_ticket_items(worklane_dir.join(status.as_str()))
.unwrap_or_default()
.into_iter()
.map(|ticket| Card {
@@ -1172,7 +1174,8 @@ fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex) {
blocked: false,
})
.collect();
Column { status, cards }
cards.sort_by(|a, b| by_status_order(status, &a.ticket, &b.ticket));
Column { status: status.as_str(), cards }
})
.collect();
@@ -4530,6 +4533,97 @@ mod tests {
assert!(top.contains("backlog (1)"), "{top}");
}
/// The titles of one column, top to bottom, which is the order the reader acts on.
fn column_titles(board: &Board, at: usize) -> Vec<String> {
board.current().columns[at]
.cards
.iter()
.map(|card| card.ticket.title.clone())
.collect()
}
/// Each column is ordered by its own entry stamp, not by priority: committed is the
/// longest wait first, done is what just landed first. Every ticket here is a p2, so
/// the stamp is doing all of the work.
#[test]
fn a_column_is_ordered_by_the_stamp_the_ticket_entered_it_with() {
let dir = board_dir();
let stamp = |field: &str, at: &str| format!("- **{field}**: 2026-08-0{at} 09:00:00\n");
write_ticket(
&dir,
"committed",
"11111111-0000-4000-8000-000000000000",
"Waited",
&stamp("Committed On", "1"),
);
write_ticket(
&dir,
"committed",
"22222222-0000-4000-8000-000000000000",
"Fresh",
&stamp("Committed On", "3"),
);
write_ticket(
&dir,
"done",
"33333333-0000-4000-8000-000000000000",
"Older",
&stamp("Completed On", "1"),
);
write_ticket(
&dir,
"done",
"44444444-0000-4000-8000-000000000000",
"Newer",
&stamp("Completed On", "3"),
);
let board = boards(&[("only", &dir)]);
assert_eq!(column_titles(&board, 1), ["Waited", "Fresh"]);
assert_eq!(column_titles(&board, 3), ["Newer", "Older"]);
}
/// The merge spans statuses, so no single stamp governs it and it keeps priority then
/// title. Pinned on done, where the column order and the merge order disagree: the
/// board would put the newest first and the merge puts the p1 first.
#[test]
fn the_merge_keeps_priority_then_title_where_a_column_would_use_the_stamp() {
let (first, second) = (board_dir(), board_dir());
let card = |dir: &Path, uuid: &str, title: &str, level: u8, day: u8| {
let path = write_ticket(dir, "done", uuid, title, "");
let body = std::fs::read_to_string(&path)
.unwrap()
.replace("- **Priority**: 2", &format!("- **Priority**: {level}"))
.replace(
"- **Status**: done\n",
&format!("- **Completed On**: 2026-08-0{day} 09:00:00\n- **Status**: done\n"),
);
std::fs::write(&path, body).unwrap();
};
// Both on one board, so that board's own column can be read for the other
// order. The urgent one finished first, so stamp and priority disagree.
card(&first, "11111111-0000-4000-8000-000000000000", "Urgent", 1, 1);
card(&first, "22222222-0000-4000-8000-000000000000", "Later", 5, 3);
// A second board, which is what makes the merge tab exist at all.
card(&second, "33333333-0000-4000-8000-000000000000", "Other", 3, 2);
let mut board = boards(&[("alpha", &first), ("beta", &second)]);
assert_eq!(
column_titles(&board, 3),
["Urgent", "Other", "Later"],
"the merge sorted by stamp"
);
// The board the cards came from orders that column by the stamp, so the two
// really are two orders rather than one that happens to agree.
board.select_tab(1, SCREEN);
assert_eq!(column_titles(&board, 3), ["Later", "Urgent"]);
}
/// A tab per project, plus the merge, and the merge is where the view opens: it is
/// the reason to monitor several boards at once.
#[test]
+321 -28
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;
};
@@ -2496,8 +2506,8 @@ pub enum Status {
}
impl Status {
/// Every status, in flow order. The one list, which [`status_dirs`] and `mv` both
/// read rather than spelling the four names again.
/// 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] = [
Status::Backlog,
Status::Committed,
@@ -2653,6 +2663,48 @@ pub struct TicketItem {
/// The file this came from. The listing ignores it; the TUI opens it for the
/// detail view rather than resolving the ticket a second time.
pub path: std::path::PathBuf,
/// The time `mv` stamped on entering committed, or `None` for a ticket that has
/// never got that far.
///
/// Read here for the reason `criteria` is, and it is what its column is ordered by:
/// a comparator that read the file would re-read every ticket on every comparison,
/// where this pass reads each one once.
pub committed_on: Option<String>,
/// The same for reviewing.
pub submitted_on: Option<String>,
/// The same for done.
pub completed_on: Option<String>,
}
impl TicketItem {
/// The stamp the ticket entered a status with, which is what that column sorts on.
///
/// A slot per status rather than a lookup by field name, so a fifth status carrying
/// a stamp is a compile error here the way it is in [`Status::stamp_field`].
/// Backlog has none: nothing stamps it, and `Created At` is not an entry time, so
/// every ticket in that column answers `None` and the whole order is the fallback.
fn entry_stamp(&self, status: Status) -> Option<&str> {
match status {
Status::Backlog => None,
Status::Committed => self.committed_on.as_deref(),
Status::Reviewing => self.submitted_on.as_deref(),
Status::Done => self.completed_on.as_deref(),
}
}
}
/// The stamp a ticket carries for a status, or `None` for one it has not reached.
///
/// The field name comes off [`Status::stamp_field`], so what is read here cannot drift
/// from what `mv` writes. An absent field reads as `_Not set_` like every other, and a
/// stamp is machine-written so that spelling never appears as a value; both count as no
/// stamp rather than as a time.
fn parse_stamp(content: &str, status: Status) -> Option<String> {
let value = parse_ticket_field(content, status.stamp_field()?);
match is_unknown_value(&value) {
true => None,
false => Some(value),
}
}
/// The date part of a due value, for a view with only a corner to spend on it.
@@ -2814,6 +2866,9 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
uuid: parse_ticket_field(&content, "ID"),
blockers,
path: e.path(),
committed_on: parse_stamp(&content, Status::Committed),
submitted_on: parse_stamp(&content, Status::Reviewing),
completed_on: parse_stamp(&content, Status::Done),
})
})
.collect();
@@ -2822,11 +2877,13 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
Ok(items)
}
/// The order a status column is read in: priority first, title as the tiebreak.
/// The order the backlog is read in, and the tiebreak every other column falls back to:
/// priority first, title second.
///
/// Named and exported because the board's All tab merges several boards' columns into
/// one and has to land in the order the listing uses. A merge sorted a second way
/// would put a p1 below a p5 depending on which project it came from.
/// one and has to land in one order. A merge sorted a second way would put a p1 below a
/// p5 depending on which project it came from, and the merge spans statuses, so no
/// single stamp governs it.
pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
a.priority
.rank()
@@ -2834,6 +2891,39 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
.then_with(|| a.title.to_lowercase().cmp(&b.title.to_lowercase()))
}
/// The order one status column is read in, keyed on the status.
///
/// Priority is the clock in the backlog, and that column keeps exactly the order it has
/// 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.
///
/// 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
/// somebody can point at. Reading absence as the epoch would come free from the string
/// comparison and put every legacy ticket first on data nothing verified.
///
/// The comparison is a string comparison. The stamp format is `%Y-%m-%d %H:%M:%S`, where
/// lexicographic order is chronological order, the same property `Due` already relies
/// on, so there is no date parsing at sort time. Equal stamps happen, `mv` writes whole
/// seconds, and they fall through to priority and title like everything else.
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),
_ => left.cmp(right),
},
(Some(_), None) => std::cmp::Ordering::Less,
(None, Some(_)) => std::cmp::Ordering::Greater,
// Both unstamped, which is every ticket in the backlog: the fallback is the
// whole order there rather than a tiebreak.
(None, None) => std::cmp::Ordering::Equal,
};
by_stamp.then_with(|| by_priority_then_title(a, b))
}
#[cfg(test)]
mod tests {
use super::*;
@@ -3403,10 +3493,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 +3505,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() {
@@ -3472,6 +3601,170 @@ mod tests {
);
}
/// A listed ticket with only the fields the column order reads: its title, its
/// priority and the stamp for the status being sorted.
fn listed(title: &str, level: u8, status: Status, stamp: Option<&str>) -> TicketItem {
let stamp = stamp.map(|value| value.to_string());
TicketItem {
title: title.to_string(),
owner: NOT_SET.to_string(),
due: NOT_SET.to_string(),
id: "0000000".to_string(),
created: String::new(),
priority: Priority::Level(level),
criteria: None,
campaign: None,
tags: Vec::new(),
uuid: NOT_SET.to_string(),
blockers: Vec::new(),
path: std::path::PathBuf::new(),
committed_on: match status {
Status::Committed => stamp.clone(),
_ => None,
},
submitted_on: match status {
Status::Reviewing => stamp.clone(),
_ => None,
},
completed_on: match status {
Status::Done => stamp,
_ => None,
},
}
}
/// Sorted the way the column is read, titles out, so a case reads as the order it
/// asserts rather than as a pair of comparisons.
fn ordered(status: Status, mut items: Vec<TicketItem>) -> Vec<String> {
items.sort_by(|a, b| by_status_order(status, a, b));
items.into_iter().map(|item| item.title).collect()
}
/// The backlog is the one column priority still governs, and it prints exactly what
/// it always has: the stamps a ticket carries from an earlier trip through the flow
/// do not reach it, because backlog has no stamp of its own to sort on.
#[test]
fn the_backlog_keeps_priority_then_title() {
let items = vec![
listed("zebra", 5, Status::Backlog, None),
listed("alpha", 1, Status::Backlog, None),
listed("beta", 1, Status::Backlog, None),
];
assert_eq!(ordered(Status::Backlog, items), ["alpha", "beta", "zebra"]);
}
/// Committed and reviewing are queues: the head is what has waited longest, which is
/// where the reader picks next from.
#[test]
fn committed_and_reviewing_list_the_oldest_stamp_first() {
for status in [Status::Committed, Status::Reviewing] {
let items = vec![
listed("newest", 1, status, Some("2026-08-03 09:00:00")),
listed("oldest", 5, status, Some("2026-08-01 09:00:00")),
listed("middle", 1, status, Some("2026-08-02 09:00:00")),
];
assert_eq!(ordered(status, items), ["oldest", "middle", "newest"], "{status:?}");
}
}
/// Done reads like a changelog: what just landed is at the top, and priority no
/// longer decides anything about finished work.
#[test]
fn done_lists_the_newest_stamp_first() {
let items = vec![
listed("first", 1, Status::Done, Some("2026-08-01 09:00:00")),
listed("last", 5, Status::Done, Some("2026-08-03 09:00:00")),
listed("middle", 1, Status::Done, Some("2026-08-02 09:00:00")),
];
assert_eq!(ordered(Status::Done, items), ["last", "middle", "first"]);
}
/// A missing stamp is unknown, not ancient. Reading absence as the epoch would come
/// free from the string comparison and hand the head of the queue to every legacy
/// ticket, so it sinks instead, in both directions.
#[test]
fn a_ticket_with_no_stamp_sorts_below_every_stamped_one() {
for status in [Status::Committed, Status::Reviewing, Status::Done] {
let items = vec![
listed("unstamped", 1, status, None),
listed("stamped", 5, status, Some("2026-08-01 09:00:00")),
];
assert_eq!(ordered(status, items), ["stamped", "unstamped"], "{status:?}");
}
}
/// `mv` writes whole seconds, so two moves in the same second is a real tie rather
/// than a hypothetical one, and it falls through to the order the backlog uses.
#[test]
fn equal_stamps_fall_back_to_priority_then_title() {
let same = Some("2026-08-01 09:00:00");
let items = vec![
listed("zebra", 1, Status::Committed, same),
listed("beta", 3, Status::Committed, same),
listed("alpha", 3, Status::Committed, same),
];
assert_eq!(ordered(Status::Committed, items), ["zebra", "alpha", "beta"]);
}
/// Two unstamped tickets in one column are ordered among themselves the way the
/// backlog is, rather than left in whatever order the directory handed them back.
#[test]
fn unstamped_tickets_are_ordered_among_themselves_by_priority_then_title() {
let items = vec![
listed("zebra", 1, Status::Done, None),
listed("beta", 3, Status::Done, None),
listed("alpha", 3, Status::Done, None),
];
assert_eq!(ordered(Status::Done, items), ["zebra", "alpha", "beta"]);
}
/// The stamps come off the pass that builds the listing, not off a second read at
/// comparison time, which is what makes an ordered column cost one read per file.
#[test]
fn collect_ticket_items_reads_the_stamps_the_order_sorts_on() {
let dir = std::env::temp_dir().join(format!("worklane-stamps-{}", uuid::Uuid::new_v4()));
fs::create_dir_all(&dir).unwrap();
fs::write(
dir.join("aaaa_walked.md"),
"# Walked\n\n## Metadata\n\n\
- **ID**: aaaa\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",
)
.unwrap();
fs::write(
dir.join("bbbb_fresh.md"),
"# Fresh\n\n## Metadata\n\n- **ID**: bbbb\n- **Status**: backlog\n",
)
.unwrap();
let items = collect_ticket_items(&dir).unwrap();
let walked = items.iter().find(|item| item.title == "Walked").unwrap();
assert_eq!(walked.committed_on.as_deref(), Some("2026-08-01 09:00:00"));
assert_eq!(walked.submitted_on.as_deref(), Some("2026-08-02 09:00:00"));
assert_eq!(walked.completed_on.as_deref(), Some("2026-08-03 09:00:00"));
// Absent reads as no stamp rather than as the `_Not set_` every other field
// falls back to, so the order sinks it instead of comparing that text.
let fresh = items.iter().find(|item| item.title == "Fresh").unwrap();
assert_eq!(fresh.committed_on, None);
assert_eq!(fresh.submitted_on, None);
assert_eq!(fresh.completed_on, None);
fs::remove_dir_all(&dir).unwrap();
}
/// Removal is scoped to the section for the same reason the write is: a description
/// quoting a field marker is prose, and rewriting it would corrupt the ticket text
/// while leaving the real field in place.
+150
View File
@@ -13,6 +13,8 @@ const CAMP_B: &str = "bb22cc33-44dd-4ee5-8ff6-001122334455";
const MEMBER: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
const OTHER: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
const LONER: &str = "f1f2f3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f";
/// A second done member, for the one test that needs two in one column to see an order.
const LATE: &str = "a9a8a7a6-5b4c-4d3e-8f2a-1b0c9d8e7f60";
fn setup_worklane(temp: &TempDir) -> PathBuf {
let worklane = temp.child(".worklane");
@@ -507,6 +509,37 @@ fn campaign_show_prints_the_body_and_the_members_grouped_by_status() {
assert!(!shown.contains("The loner"), "{shown}");
}
/// The members of a status are listed in that status's own order, not in the board-wide
/// one: a campaign's done list answers what just landed, for the same reason the board's
/// column does. Every fixture is a p3, so the stamp is doing all of the work.
#[test]
fn campaign_show_lists_each_status_in_its_own_order() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let stamp = |uuid: &str, day: &str| {
let path = find(&worklane, uuid);
let body = fs::read_to_string(&path).unwrap().replace(
"- **Status**: done\n",
&format!("- **Completed On**: 2026-08-0{day} 09:00:00\n- **Status**: done\n"),
);
fs::write(&path, body).unwrap();
};
// A second done member, finished after the one the fixture writes.
create_ticket(&worklane, "done", "The late member", LATE);
stamp(OTHER, "1");
stamp(LATE, "3");
run(&temp, &["assign", "v1 release", OTHER]);
run(&temp, &["assign", "v1 release", LATE]);
let shown = stdout(&run(&temp, &["campaign", "show", "aa11"]));
let at = |needle: &str| shown.find(needle).unwrap_or_else(|| panic!("{needle}: {shown}"));
assert!(at("The late member") < at("The other member"), "{shown}");
}
#[test]
fn ls_campaign_lists_only_that_campaigns_members() {
let temp = TempDir::new().unwrap();
@@ -1113,3 +1146,120 @@ fn campaign_set_offers_no_description_and_no_owner() {
assert!(!help.contains("--owner"), "{help}");
assert!(!help.contains("--clear"), "{help}");
}
/// A codename is how a campaign is referred to once it has one: on every card in it and at
/// the command line. Replacing that silently is the mistake `install-skill --force` exists
/// to prevent, so it is refused and the refusal names the flag.
#[test]
fn an_existing_codename_is_not_replaced_without_force() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let before = campaign_file(&worklane, CAMP_A);
let out = run(&temp, &["campaign", "set", "v1", "-c", "beaver"]);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
let said = stderr(&out);
// Both words and the flag, so the message says what is there, what was asked for and
// how to get it.
assert!(said.contains("already codenamed 'v1'"), "{said}");
assert!(said.contains("'beaver'"), "{said}");
assert!(said.contains("--force"), "{said}");
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written anyway");
}
#[test]
fn force_replaces_an_existing_codename() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let out = run(&temp, &["campaign", "set", "v1", "-c", "beaver", "--force"]);
assert!(out.status.success(), "{}", stderr(&out));
let content = campaign_file(&worklane, CAMP_A);
assert!(content.contains("- **Codename**: beaver"), "{content}");
// The line is replaced, not added beside the old one. Asserted on the field rather
// than on the word, since the campaign's title is "v1 release" and holds it too.
assert!(!content.contains("- **Codename**: v1"), "the old line survived: {content}");
assert_eq!(content.matches("**Codename**").count(), 1, "two codenames: {content}");
}
/// The guard is about overwriting a *different* word. A campaign with no codename has
/// nothing to overwrite, so `--force` is not the price of the first one.
#[test]
fn the_first_codename_needs_no_force() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
assert!(
!campaign_file(&worklane, CAMP_A).contains("Codename"),
"the fixture changed"
);
let out = run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(campaign_file(&worklane, CAMP_A).contains("- **Codename**: v1"));
}
/// And setting the one it already has stays a no-op rather than becoming a refusal: there
/// is nothing to overwrite, which is the same answer `install-skill` gives an identical
/// document.
#[test]
fn setting_the_same_codename_again_is_a_no_op_not_a_refusal() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let out = run(&temp, &["campaign", "set", "v1", "-c", "v1"]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
assert!(campaign_file(&worklane, CAMP_A).contains("- **Codename**: v1"));
}
/// Refused before any edit is applied, like `SetArgs::contested`, so a call carrying both
/// fields writes neither rather than half of what was asked for.
#[test]
fn a_refused_codename_takes_the_title_down_with_it() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let before = campaign_file(&worklane, CAMP_A);
let out = run(
&temp,
&[
"campaign",
"set",
"v1",
"-t",
"Renamed anyway",
"-c",
"beaver",
],
);
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the title went through");
let names = campaigns(&worklane);
assert!(
!names.iter().any(|name| name.contains("renamed-anyway")),
"renamed: {names:?}"
);
}
/// The title needs no guard, since a campaign always has one and replacing it is what the
/// flag is for. `--force` is the codename's alone.
#[test]
fn the_title_is_replaced_without_force() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
let out = run(&temp, &["campaign", "set", "v1", "--title", "First public release"]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(campaign_file(&worklane, CAMP_A).starts_with("# First public release\n"));
}
+199 -3
View File
@@ -677,9 +677,9 @@ fn ls_names_the_four_statuses_when_given_another() {
}
}
/// The listing reads the fields it prints and nothing else, so the stamps `mv` writes
/// do not reach it. Pinned against a ticket carrying one, since a listing that started
/// showing them would change the output every board and completion script parses.
/// The listing reads the stamps to order the column by them, and prints none of them.
/// Pinned against a ticket carrying one, since a listing that started showing them would
/// change the output every board and completion script parses.
#[test]
fn ls_output_is_unchanged_by_a_status_stamp() {
let temp = TempDir::new().unwrap();
@@ -707,3 +707,199 @@ fn ls_output_is_unchanged_by_a_status_stamp() {
assert_eq!(after, before);
assert!(!after.contains("Committed On"), "{after}");
}
/// A ticket in a status with the entry stamp that status is ordered by, or none.
///
/// The field is derived from the status rather than passed, so a case says which column
/// it is about and cannot name the wrong stamp for it.
fn create_stamped_ticket(
worklane_dir: &std::path::Path,
status: &str,
title: &str,
uuid: &str,
priority: &str,
stamp: Option<&str>,
) {
let field = match status {
"committed" => "Committed On",
"reviewing" => "Submitted On",
"done" => "Completed On",
other => panic!("{other} has no entry stamp"),
};
let line = match stamp {
Some(value) => format!("- **{field}**: {value}\n"),
None => String::new(),
};
let body = format!(
"# {title}\n\n## Metadata\n\n- **ID**: {uuid}\n- **Priority**: {priority}\n\
- **Tags**: test\n- **Due**: _Not set_\n- **Owner**: alice\n{line}\
- **Status**: {status}\n"
);
fs::write(
worklane_dir
.join(status)
.join(format!("{uuid}_{}.md", slug(title))),
body,
)
.unwrap();
}
fn positions(stdout: &str, titles: [&str; 3]) -> Vec<usize> {
titles
.iter()
.map(|title| {
stdout
.find(title)
.unwrap_or_else(|| panic!("{title} missing from {stdout}"))
})
.collect()
}
/// Committed and reviewing are queues, and the head is what has waited longest: that is
/// what the reader picks next from. Priority no longer decides it, which is why the
/// oldest here is the least urgent of the three.
#[test]
fn ls_orders_committed_and_reviewing_by_the_oldest_entry_stamp() {
for status in ["committed", "reviewing"] {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("aaaa000{n}-0000-0000-0000-000000000001");
create_stamped_ticket(
&worklane,
status,
"Newest",
&at(1),
"1",
Some("2026-08-03 09:00:00"),
);
create_stamped_ticket(
&worklane,
status,
"Oldest",
&at(2),
"5",
Some("2026-08-01 09:00:00"),
);
create_stamped_ticket(
&worklane,
status,
"Middle",
&at(3),
"1",
Some("2026-08-02 09:00:00"),
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", status]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Oldest", "Middle", "Newest"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{status}: {stdout}");
// The overview lists the same columns, so it has to agree with the narrowed
// listing rather than falling back to priority for the same tickets.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("ls");
let overview = get_stdout(&mut cmd);
let seen = positions(&overview, ["Oldest", "Middle", "Newest"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{status} overview: {overview}");
}
}
/// Done reads like a changelog: what just landed is at the top. The p1 that finished
/// first is at the bottom, which is the whole point of the column not being priority.
#[test]
fn ls_orders_done_by_the_newest_entry_stamp() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("bbbb000{n}-0000-0000-0000-000000000001");
create_stamped_ticket(&worklane, "done", "First", &at(1), "1", Some("2026-08-01 09:00:00"));
create_stamped_ticket(&worklane, "done", "Last", &at(2), "5", Some("2026-08-03 09:00:00"));
create_stamped_ticket(&worklane, "done", "Middle", &at(3), "1", Some("2026-08-02 09:00:00"));
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "done"]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Last", "Middle", "First"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
/// A missing stamp is unknown, not ancient, so it sinks below every stamped ticket
/// rather than claiming the head of the queue. Every ticket on a board older than the
/// stamps is one of these.
#[test]
fn ls_sinks_an_unstamped_ticket_below_the_stamped_ones() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("cccc000{n}-0000-0000-0000-000000000001");
create_stamped_ticket(&worklane, "committed", "Unstamped", &at(1), "1", None);
create_stamped_ticket(
&worklane,
"committed",
"Waited",
&at(2),
"5",
Some("2026-08-01 09:00:00"),
);
create_stamped_ticket(
&worklane,
"committed",
"Fresh",
&at(3),
"5",
Some("2026-08-09 09:00:00"),
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "committed"]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Waited", "Fresh", "Unstamped"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
/// The two listings are one order. A completion offering candidates in a different
/// order than the board prints them would make the head of a column mean two things.
#[test]
fn ls_ids_prints_the_same_order_the_listing_does() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("dddd000{n}-0000-0000-0000-000000000001");
create_stamped_ticket(
&worklane,
"reviewing",
"Newest",
&at(1),
"1",
Some("2026-08-03 09:00:00"),
);
create_stamped_ticket(
&worklane,
"reviewing",
"Oldest",
&at(2),
"5",
Some("2026-08-01 09:00:00"),
);
create_stamped_ticket(&worklane, "reviewing", "Unstamped", &at(3), "1", None);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "reviewing", "--ids"]);
let ids = get_stdout(&mut cmd);
let titles: Vec<&str> = ids.lines().filter_map(|line| line.split('\t').nth(1)).collect();
assert_eq!(titles, ["Oldest", "Newest", "Unstamped"], "{ids:?}");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "reviewing"]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Oldest", "Newest", "Unstamped"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
+103 -13
View File
@@ -923,35 +923,89 @@ fn ticket_at(worklane: &Path, status: &str, filename: &str) -> String {
fs::read_to_string(worklane.join(status).join(filename)).unwrap()
}
/// One field per status, written with the time of the move, and only the current one:
/// the stamps are where the ticket is now, not the trail of how it got there.
/// One field per status, written with the time of the move and added to the ones
/// already there: walking the flow leaves the whole journey on the ticket.
#[test]
fn mv_stamps_the_field_of_the_status_it_enters() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
for (status, stamp, cleared) in [
("committed", "Committed On", "Submitted On"),
("reviewing", "Submitted On", "Committed On"),
("done", "Completed On", "Submitted On"),
// The fixture predates Created At as well as the stamps, and the four reading as
// one block is the point, so it is seeded rather than asserted around.
let path = worklane.join("backlog").join(&filename);
let seeded = fs::read_to_string(&path)
.unwrap()
.replace("- **Status**:", "- **Created At**: 2026-08-01 09:00:00\n- **Status**:");
fs::write(&path, seeded).unwrap();
let mut carried: Vec<&str> = Vec::new();
for (status, stamp) in [
("committed", "Committed On"),
("reviewing", "Submitted On"),
("done", "Completed On"),
] {
let out = move_ticket(&temp, "cccc3333", status, false);
assert!(out.status.success(), "{:?}", out);
carried.push(stamp);
let content = ticket_at(&worklane, status, &filename);
let value = field(&content, stamp)
.unwrap_or_else(|| panic!("no {stamp} after moving to {status}: {content}"));
assert!(is_timestamp(&value), "{stamp} reads '{value}'");
assert_eq!(field(&content, cleared), None, "{content}");
for stamp in &carried {
let value = field(&content, stamp)
.unwrap_or_else(|| panic!("no {stamp} after moving to {status}: {content}"));
assert!(is_timestamp(&value), "{stamp} reads '{value}'");
}
}
// The four side by side and in flow order, which is what a reader asking when this
// was filed, picked up, handed over and finished gets one answer each from.
let content = ticket_at(&worklane, "done", &filename);
let block: Vec<&str> = content
.lines()
.filter_map(|line| line.strip_prefix("- **"))
.filter_map(|line| line.split("**:").next())
.skip_while(|name| *name != "Created At")
.collect();
assert_eq!(
block,
[
"Created At",
"Committed On",
"Submitted On",
"Completed On",
"Status"
],
"{content}"
);
}
/// Backlog has no stamp of its own, so a ticket forced back to it carries none at all
/// rather than a Completed On for work that has been undone.
/// Arrival clears what comes after it and nothing before, so a ticket sent back out of
/// done keeps the stages it did get through.
#[test]
fn mv_removes_the_stamp_of_the_status_it_leaves() {
fn mv_removes_the_stamps_of_the_statuses_after_the_one_it_enters() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
for status in ["committed", "reviewing", "done"] {
move_ticket(&temp, "cccc3333", status, false);
}
move_ticket(&temp, "cccc3333", "reviewing", true);
let content = ticket_at(&worklane, "reviewing", &filename);
assert_eq!(field(&content, "Completed On"), None, "{content}");
assert!(field(&content, "Committed On").is_some(), "{content}");
assert!(field(&content, "Submitted On").is_some(), "{content}");
}
/// Backlog has no stamp of its own and every status follows it, so a ticket forced back
/// to it carries none at all rather than a Completed On for work that has been undone.
#[test]
fn mv_back_to_backlog_removes_all_three_stamps() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
@@ -968,6 +1022,42 @@ fn mv_removes_the_stamp_of_the_status_it_leaves() {
}
}
/// A skip stamps where it lands and leaves the stages it jumped unwritten: an absent
/// field says the ticket never got that far, and inventing one would say it did.
#[test]
fn mv_skipping_forward_stamps_only_the_target() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let filename = stamped_ticket(&worklane, "backlog");
move_ticket(&temp, "cccc3333", "done", true);
let content = ticket_at(&worklane, "done", &filename);
assert!(field(&content, "Completed On").is_some(), "{content}");
assert_eq!(field(&content, "Committed On"), None, "{content}");
assert_eq!(field(&content, "Submitted On"), None, "{content}");
}
/// The three are `mv`'s alone. Nothing that edits a ticket by hand offers a way to
/// write one or take one away, so a stamp is always the record of a real move. Pinned
/// so the omission stays a decision rather than becoming an oversight somebody fills in.
#[test]
fn no_other_command_can_write_or_clear_a_stamp() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
for command in ["add", "set", "append", "chown"] {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args([command, "--help"]);
let out = cmd.assert().get_output().clone();
let help = String::from_utf8_lossy(&out.stdout).to_lowercase();
for flag in ["committed-on", "submitted-on", "completed-on", "stamp"] {
assert!(!help.contains(flag), "{command} --help names {flag}: {help}");
}
}
}
/// Re-entry is the time of the move that brought the ticket back, not the first one.
#[test]
fn mv_restamps_a_status_the_ticket_is_re_entering() {