Repository navigation
fix(platform): keep appended task ranks short - #4594
Merged
Merged
Conversation
yannickmonney
added this pull request to the merge queue
Oct 9, 2026
yannickmonney
removed this pull request from the merge queue due to a manual request
Oct 9, 2026
yannickmonney
force-pushed
the
fix/task-rank-growth
branch
from
October 9, 2026 03:01
3810079 to
c5930bf
Compare
yannickmonney
enabled auto-merge
October 9, 2026 03:06
yannickmonney
force-pushed
the
fix/task-rank-growth
branch
from
October 9, 2026 04:29
c5930bf to
0a98c51
Compare
Appending to a column took the midpoint between the last key and the end of the alphabet, which reaches z within a few steps and then adds a digit: one digit every five or six appends. A project with 44,000 tasks in Backlog carried ranks up to 7,319 characters, in every row, every entry of the (project, status, rank) index and every board read, and a B-tree entry may not grow past about 2.7 KB once compression stops helping. Appends now count up within the key's length and extend only past an all-z key, by a block as long as the key: a million appends stay within 16 characters, and counted keys interleave with every key already stored.
The board, the subtask list and the board read sorted ranks with localeCompare, so a browser whose collation joins a letter pair (Hungarian zs, Croatian lj, Danish aa, Czech ch) ordered a column differently from the server and computed drops from the wrong neighbours; counted ranks contain every pair. One comparator now orders ranks the way rankBetween and the index do. A long legacy all-z key is extended by at most 8 digits instead of doubling.
yannickmonney
force-pushed
the
fix/task-rank-growth
branch
from
October 9, 2026 04:46
0a98c51 to
be311a5
Compare
tale-review-bot
pushed a commit
that referenced
this pull request
Oct 30, 2026
Until #4594 an append took the midpoint towards the alphabet's end, so a column's keys grew a digit every six appends: a load run's board reached 7,319 characters after 44k appends. #4594 counts appends within a key's length, so such a column kept handing out keys that long. Migration 0220, a TypeScript data migration, gives every task of a board that holds a rank over 64 characters (LONG_RANK_LENGTH) a short rank, in the order the board stands: by rank in code-unit order across all of its columns, archived tasks and subtasks, with ties parted by id. The keys come from the rank module's new spacedRanks(): evenly spaced, all of one length (44k tasks get 4 digits), none ending in 0 or all z. Each board's rows are locked before its order is read, the ranks are written 5,000 rows at a time, updated_at_ms is left alone, and each rewritten board gets one org-wide task hint. A board whose ranks are all at most 64 characters is untouched, and a second run finds nothing to do. rank.test.ts pins spacedRanks (order, spacing, length, and drops before, between and after its keys); data-migrations.test.ts pins 0220's decision table and admits rank.ts as a pure rule; checkTaskShortRanks proves the migration on real Postgres with a board holding 7,319-character ranks. Closes #4713 Task: TALE-122
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
Until #4594 an append took the midpoint towards the alphabet's end, so a column's keys grew a digit every six appends: a load run's board reached 7,319 characters after 44k appends. #4594 counts appends within a key's length, so such a column kept handing out keys that long. Migration 0220, a TypeScript data migration, gives every task of a board that holds a rank over 64 characters (LONG_RANK_LENGTH) a short rank, in the order the board stands: by rank in code-unit order across all of its columns, archived tasks and subtasks, with ties parted by id. The keys come from the rank module's new spacedRanks(): evenly spaced, all of one length (44k tasks get 4 digits), none ending in 0 or all z. Each board's rows are locked before its order is read, the ranks are written 5,000 rows at a time, updated_at_ms is left alone, and each rewritten board gets one org-wide task hint. A board whose ranks are all at most 64 characters is untouched, and a second run finds nothing to do. rank.test.ts pins spacedRanks (order, spacing, length, and drops before, between and after its keys); data-migrations.test.ts pins 0220's decision table and admits rank.ts as a pure rule; checkTaskShortRanks proves the migration on real Postgres with a board holding 7,319-character ranks. Closes #4713 Task: TALE-122
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
Until #4594 an append took the midpoint towards the alphabet's end, so a column's keys grew a digit every six appends: a load run's board reached 7,319 characters after 44k appends. #4594 counts appends within a key's length, so such a column kept handing out keys that long. Migration 0220, a TypeScript data migration, gives every task of a board that holds a rank over 64 characters (LONG_RANK_LENGTH) a short rank, in the order the board stands: by rank in code-unit order across all of its columns, archived tasks and subtasks, with ties parted by id. The keys come from the rank module's new spacedRanks(): evenly spaced, all of one length (44k tasks get 4 digits), none ending in 0 or all z. Each board's rows are locked before its order is read, the ranks are written 5,000 rows at a time, updated_at_ms is left alone, and each rewritten board gets one org-wide task hint. A board whose ranks are all at most 64 characters is untouched, and a second run finds nothing to do. rank.test.ts pins spacedRanks (order, spacing, length, and drops before, between and after its keys); data-migrations.test.ts pins 0220's decision table and admits rank.ts as a pure rule; checkTaskShortRanks proves the migration on real Postgres with a board holding 7,319-character ranks. Closes #4713 Task: TALE-122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Task ranks grew by one character every five or six appends to a column. The load harness (#4589) found this: after a task burst, the
Backlogcolumn of one project held 44,000 tasks with ranks up to 7,319 characters (3,658 on average).Every row carries its rank, and so does every entry of the
(project_id, status, rank)index and every board read. A B-tree entry may not exceed about 2.7 KB once compression stops helping. Task creation also slowed down run after run as the column grew.Cause: an append to the end of a column took the midpoint between the last key and the end of the base-36 alphabet. That reaches
zwithin a few steps, after which every further append adds a digit. Appends are the hot path: every created task, every status change and every drop at the bottom of a column.Fix:
rankBetween(last, undefined)now counts. It increments the key as a base-36 number of the same length, carrying to the left, with the last digit running 1–z so no key ends in0(the between-insert relies on that). Only an all-zkey is extended, and then by a block as long as the key itself.Rank order (review finding): counted keys run through every letter pair, and the board (
use-task-board-dnd.ts), the subtask list (subtasks.ts) and the server's board read sorted ranks withlocaleCompare. A browser whose collation treats a pair as one letter — Hungarianzs, Croatianlj, Danish/Norwegianaa, Czech/Slovakch— would order a column differently from the server and compute drops from the wrong neighbours. Ranks are now compared by code unit everywhere (lib/shared/task-rank-order.ts), the orderrankBetweenand the(project_id, status, rank)index use (the database collation isen_US.utf8, code-unit order for[0-9a-z]). A long legacy all-zkey is extended by at most 8 digits instead of doubling.Testing
New tests in
rank.test.ts(16 tests in the file):0;iz→j1,a0z→a11,z→zi,zz→zzi1,zzzz→zzzzi001);The task, core/tasks, projects and REST suites pass: 1,351 tests.
Follow-up (not in this PR)
Shortening ranks already stored in very large columns would be a data migration that renumbers a column while keeping its order. It's optional now that those keys no longer grow.