Add a sort_weight to tasks for operator-controlled ordering - #370
Merged
Conversation
Give every task an integer sort_weight (default 0) that participates in the
dashboard sort with priority above the last-updated timestamp but below
state/turn: within a section and turn, a higher weight sorts first, ties
falling back to the timestamp. At the default 0 ordering is unchanged.
Settable via REST (PUT /tasks/{id}/sort-weight) and MCP (set_sort_weight),
threaded through the domain model, ORM row, and TaskService, with an Alembic
migration backfilling existing rows to 0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Thread an optional sort_weight (default 0) through the creation path so a task can start with a non-default dashboard priority instead of only being set afterward: the create_task/create_task_as service methods, the REST POST /tasks body (CreateTaskIn), the MCP create_task tool, and the client. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ort-weight # Conflicts: # src/panopticon/client.py # src/panopticon/taskservice/mcp.py
tildesrc
marked this pull request as ready for review
August 12, 2026 20:14
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
Give every task an integer
sort_weight(default 0) that participates in the dashboard sort with priority above the last-updated timestamp but below state/turn. Within a section (state) and turn, a higher weight sorts first; ties fall back to the timestamp. At the default 0, ordering is byte-for-byte unchanged.The weight is settable through REST and MCP, and can be seeded at task creation. See the plan artifact (
plan.md).Where it sits in the sort
The dashboard sort key (
terminal/dashboard.py_make_sort_key) goes from(section, turn, ts, id)→(section, turn, -sort_weight, ts, id)— negated so a higher weight rises first, slotted between turn and the timestamp.Changes
core/models.py) —sort_weight: int = 0on theTaskdataclass.store_sqlalchemy.py) — non-nullsort_weightcolumn (server_default="0"), threaded throughto_domain/from_domain/_update_task, plus an Alembic migration that backfills existing rows to 0.service.py) —set_sort_weight(a plain recorded-fact write, leaving state/turn/blocked untouched), and an optionalsort_weightargument oncreate_task/create_task_as.api.py) — field onTaskOut/TaskSummaryOut,SortWeightIn,PUT /tasks/{id}/sort-weight, andsort_weightonCreateTaskIn(POST /tasks).mcp.py) —set_sort_weighttool, and asort_weightparameter oncreate_task.client.py) — matchingset_sort_weightandcreate_tasksupport.Tests
Service, MCP, REST, and store round-trip coverage for the field (default 0, set/reset, persistence, and creation-time seeding), plus dashboard sort-key tests proving weight outranks the timestamp, ties fall back to it, and it never overrides state/turn. The migration drift guard stays green.