Skip to content

Commit 7166f5a

Browse files
authored
Pin every terminal status the board reads in the kanban suite (#2090)
Fixes #2088 Written-by: Dev-3 Owner: Dev-3 Reviewer: Birfy Claim-Id: 43b662f1ccbe42cdaa7cecd4225ac2f8 Branch: dev/3-kanban-terminal-statuses Base: fca35af Tip SHA: fa76ec7 ## What happens today `finishedAt` in `core/src/client/kanban.js` stamps a Done card from the first entry in `task.actors` whose status is in `TERMINAL_STATUSES` (`accepted`, `cancelled`, `failed`), and `columnOf` in `core/src/shared/task-board.js` maps those same three statuses to Done. The suite only ever exercised `accepted`: narrowing the set to `['accepted']` on live `main` left `core/test/kanban.test.js` at **21 tests / 21 pass / 0 fail**, three runs identical. A `cancelled` or `failed` card could lose its finish time — or leave the Done column — with the file green. ## The change Two files, **+98 / −0**, the mirror byte-identical to the source test. No implementation change: the behaviour is correct today, this pins it. - `core/test/kanban.test.js` (+49): four characterization cases. - `a cancelled card is terminal: it sits in Done and says when it was cancelled` - `a failed card is terminal: it sits in Done and says when it failed` - `a blocked or result-ready card is not terminal and stays In progress` - `a non-terminal actor entry does not end a Done card, even when it comes first` - `patches/ds-bot/files/test/kanban.test.js` (+49): what `generate` writes. No source, doc or changelog change: nothing user-visible changes. ## Red first On base `fca35af6`, sources unchanged except `TERMINAL_STATUSES` narrowed to `['accepted']`: - original 21 cases only → **21 / 21 / 0, exit 0**, three runs identical — the gap: the set can lose two statuses silently. - with the four new cases → **25 / 23 / 2**, three runs identical. The two red cases are #22 (`a cancelled card is terminal…`) and #23 (`a failed card is terminal…`), each failing `'1 min' !== '2 h'` (the stamp fell back to `updatedAt`). - set restored, new cases present → **25 / 25 / 0**, three runs identical. Seven mutations, each applied alone on `fca35af6` and reverted to 25/25 before the next: | mutation | result | case that bites | | --- | --- | --- | | `cancelled` out of `TERMINAL_STATUSES` | 25 / 24 / 1 | #22 `a cancelled card is terminal…` | | `failed` out of `TERMINAL_STATUSES` | 25 / 24 / 1 | #23 `a failed card is terminal…` | | `cancelled` out of `COLUMN_OF` | 25 / 24 / 1 | #22 (`a cancelled card is drawn in Done`) | | `failed` out of `COLUMN_OF` | 25 / 24 / 1 | #23 (`a failed card is drawn in Done`) | | `blocked` added to `TERMINAL_STATUSES` | 25 / 24 / 1 | #25 `a non-terminal actor entry does not end…` | | `result-ready` mapped to Done | 25 / 24 / 1 | #24 `a blocked or result-ready card is not terminal…` | | `claimed` added to `TERMINAL_STATUSES` | 25 / 24 / 1 | #25 `a non-terminal actor entry does not end…` | ## Verified `TZ=UTC ARCH_DOCS_BASE=fca35af6f29a npm run verify` → **exit 0**: core **2561**, social 541, tree 127, timeline 135, workflow 336, `.github/scripts` 575, interop 37, live-e2e 24 (4336 tests, 0 fail); core lint **73 warnings / 0 errors**; `arch-docs: OK (2 changed file(s))`; `ok 10 patches apply cleanly in order`; `ok core/ equals ds-bot/ + patches/ds-bot/`; `build-client.mjs --check` green. `generate` ran twice and the second run left `git status --porcelain` empty. ## Which tree the checks ran on One commit, single parent. Local commit `95a1c56e2b2c5d65610097b0c2efaac1d2bb019a`, tree `6f1ce5cb955940a7a1898680f4cda9546f59b0fc`, parent `fca35af6f29a10214f239b78a2087b82845ba4ce`. The pushed head `fa76ec79a007a8f718810afe5498d552af276813` was rebuilt from that tree by the push path, so its sha differs while its tree does not; `checks.at` names the pushed tip, which is what CI reads. ## Not run The smoke test (nothing under `core/index.js` or `core/src/host/` changed) and the packaged Desktop install path. ## Checkpoint <!-- flybot:checkpoint --> ```json { "pr": 2090, "claim": "Dev-3", "issue": 2088, "summary": "`finishedAt` stamps a Done card from the first terminal entry in `actors` and `columnOf` maps accepted, cancelled and failed to Done, but the suite only exercised `accepted`: narrowing the set to `['accepted']` left all 21 cases green. Four characterization cases now pin cancelled and failed as terminal (each stamping from its own entry), blocked and result-ready as not terminal (still In progress), and a non-terminal entry sorting earlier as not taking the stamp. Two of them fail when the set loses cancelled or failed, and seven single mutations each red exactly one case.", "files": [ "core/test/kanban.test.js", "patches/ds-bot/files/test/kanban.test.js" ], "checks": { "ran": "TZ=UTC ARCH_DOCS_BASE=fca35af6f29a npm run verify (core 2561, 0 fail); node --test core/test/kanban.test.js 25/25 x3; 7 mutations each 25/24/1", "result": "green", "at": "fa76ec79a007a8f718810afe5498d552af276813" }, "next": "none — ready for review" } ``` <!-- /flybot:checkpoint -->
1 parent c00fc87 commit 7166f5a

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

‎core/test/kanban.test.js‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,52 @@ test('a room board Done card says when it finished too', () => {
711711
const board = boardWith({ kind: 'group', roomId: 'war' }, [], [editedAfterFinish('task-done666666', { ownerBotId: 'a' })])
712712
assert.equal(whenOf(board.column('done'), 'task-done666666'), '2 h')
713713
})
714+
715+
// F: `cancelled` and `failed` are terminal too. #2077 wrote the set (`TERMINAL_STATUSES` in
716+
// `kanban.js`) and `COLUMN_OF` (`src/shared/task-board.js`) maps all three terminal statuses to
717+
// Done, but nothing asserted either, so removing `cancelled`/`failed` from the set left this file
718+
// green. A card that ended either way sits in Done and its stamp is the entry that ended it, never
719+
// the plain edit `updatedAt` names.
720+
test('a cancelled card is terminal: it sits in Done and says when it was cancelled', () => {
721+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [editedAfterFinish('task-cancel777777', {}, 'cancelled')])
722+
const done = board.column('done')
723+
assert.notEqual(cardIn(done, 'task-cancel777777'), undefined, 'a cancelled card is drawn in Done')
724+
assert.equal(whenOf(done, 'task-cancel777777'), '2 h')
725+
})
726+
727+
test('a failed card is terminal: it sits in Done and says when it failed', () => {
728+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [editedAfterFinish('task-failed888888', {}, 'failed')])
729+
const done = board.column('done')
730+
assert.notEqual(cardIn(done, 'task-failed888888'), undefined, 'a failed card is drawn in Done')
731+
assert.equal(whenOf(done, 'task-failed888888'), '2 h')
732+
})
733+
734+
// G: the other statuses are not terminal. `blocked` waits on a person and `result-ready` on its
735+
// requester (`task-board.js`), so both stay In progress and neither ends the card's history.
736+
test('a blocked or result-ready card is not terminal and stays In progress', () => {
737+
const waiting = task('task-block999999', 'blocked', { title: 'Waiting on a person', ownerBotId: 's', progress: 20, updatedAt: 2 })
738+
const ready = task('task-readyaaaaaa', 'result-ready', { title: 'Waiting on the result', ownerBotId: 's', progress: 80, updatedAt: 3 })
739+
const board = boardWith({ kind: 'bot', botId: 's' }, [waiting, ready], [])
740+
const idsIn = column => byClass(board.column(column), 'bt-board-card').map(node => node.props['data-task'])
741+
assert.deepEqual(idsIn('in-progress'), ['task-readyaaaaaa', 'task-block999999'])
742+
assert.deepEqual(idsIn('done'), [])
743+
assert.deepEqual(idsIn('not-started'), [])
744+
})
745+
746+
// H: a non-terminal actor entry ahead of the terminal one does not win the stamp, even when it is
747+
// the first entry. Adding `open`, `claimed`, `working`, `blocked` or `result-ready` to
748+
// `TERMINAL_STATUSES` would stamp the card with the moment it entered that state instead.
749+
test('a non-terminal actor entry does not end a Done card, even when it comes first', () => {
750+
const actors = [
751+
{ status: 'claimed', at: Date.now() - 300 * MINUTE },
752+
{ status: 'working', at: Date.now() - 270 * MINUTE },
753+
{ status: 'blocked', at: Date.now() - 240 * MINUTE },
754+
{ status: 'result-ready', at: Date.now() - 180 * MINUTE },
755+
{ status: 'accepted', at: Date.now() - 125 * MINUTE },
756+
{ status: 'accepted', at: Date.now() - MINUTE, by: 'updated' },
757+
]
758+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [
759+
task('task-done999999', 'accepted', { title: 'Finished after a block', ownerBotId: 's', progress: 100, updatedAt: Date.now() - MINUTE, actors }),
760+
])
761+
assert.equal(whenOf(board.column('done'), 'task-done999999'), '2 h')
762+
})

‎patches/ds-bot/files/test/kanban.test.js‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,52 @@ test('a room board Done card says when it finished too', () => {
711711
const board = boardWith({ kind: 'group', roomId: 'war' }, [], [editedAfterFinish('task-done666666', { ownerBotId: 'a' })])
712712
assert.equal(whenOf(board.column('done'), 'task-done666666'), '2 h')
713713
})
714+
715+
// F: `cancelled` and `failed` are terminal too. #2077 wrote the set (`TERMINAL_STATUSES` in
716+
// `kanban.js`) and `COLUMN_OF` (`src/shared/task-board.js`) maps all three terminal statuses to
717+
// Done, but nothing asserted either, so removing `cancelled`/`failed` from the set left this file
718+
// green. A card that ended either way sits in Done and its stamp is the entry that ended it, never
719+
// the plain edit `updatedAt` names.
720+
test('a cancelled card is terminal: it sits in Done and says when it was cancelled', () => {
721+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [editedAfterFinish('task-cancel777777', {}, 'cancelled')])
722+
const done = board.column('done')
723+
assert.notEqual(cardIn(done, 'task-cancel777777'), undefined, 'a cancelled card is drawn in Done')
724+
assert.equal(whenOf(done, 'task-cancel777777'), '2 h')
725+
})
726+
727+
test('a failed card is terminal: it sits in Done and says when it failed', () => {
728+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [editedAfterFinish('task-failed888888', {}, 'failed')])
729+
const done = board.column('done')
730+
assert.notEqual(cardIn(done, 'task-failed888888'), undefined, 'a failed card is drawn in Done')
731+
assert.equal(whenOf(done, 'task-failed888888'), '2 h')
732+
})
733+
734+
// G: the other statuses are not terminal. `blocked` waits on a person and `result-ready` on its
735+
// requester (`task-board.js`), so both stay In progress and neither ends the card's history.
736+
test('a blocked or result-ready card is not terminal and stays In progress', () => {
737+
const waiting = task('task-block999999', 'blocked', { title: 'Waiting on a person', ownerBotId: 's', progress: 20, updatedAt: 2 })
738+
const ready = task('task-readyaaaaaa', 'result-ready', { title: 'Waiting on the result', ownerBotId: 's', progress: 80, updatedAt: 3 })
739+
const board = boardWith({ kind: 'bot', botId: 's' }, [waiting, ready], [])
740+
const idsIn = column => byClass(board.column(column), 'bt-board-card').map(node => node.props['data-task'])
741+
assert.deepEqual(idsIn('in-progress'), ['task-readyaaaaaa', 'task-block999999'])
742+
assert.deepEqual(idsIn('done'), [])
743+
assert.deepEqual(idsIn('not-started'), [])
744+
})
745+
746+
// H: a non-terminal actor entry ahead of the terminal one does not win the stamp, even when it is
747+
// the first entry. Adding `open`, `claimed`, `working`, `blocked` or `result-ready` to
748+
// `TERMINAL_STATUSES` would stamp the card with the moment it entered that state instead.
749+
test('a non-terminal actor entry does not end a Done card, even when it comes first', () => {
750+
const actors = [
751+
{ status: 'claimed', at: Date.now() - 300 * MINUTE },
752+
{ status: 'working', at: Date.now() - 270 * MINUTE },
753+
{ status: 'blocked', at: Date.now() - 240 * MINUTE },
754+
{ status: 'result-ready', at: Date.now() - 180 * MINUTE },
755+
{ status: 'accepted', at: Date.now() - 125 * MINUTE },
756+
{ status: 'accepted', at: Date.now() - MINUTE, by: 'updated' },
757+
]
758+
const board = boardWith({ kind: 'bot', botId: 's' }, [], [
759+
task('task-done999999', 'accepted', { title: 'Finished after a block', ownerBotId: 's', progress: 100, updatedAt: Date.now() - MINUTE, actors }),
760+
])
761+
assert.equal(whenOf(board.column('done'), 'task-done999999'), '2 h')
762+
})

0 commit comments

Comments
 (0)