Skip to content

Add a sort_weight to tasks for operator-controlled ordering - #370

Merged
tildesrc merged 5 commits into
mainfrom
panopticon/add-task-sort-weight
Aug 12, 2026
Merged

Add a sort_weight to tasks for operator-controlled ordering#370
tildesrc merged 5 commits into
mainfrom
panopticon/add-task-sort-weight

Conversation

@tildesrc

@tildesrc tildesrc commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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

  • Model (core/models.py) — sort_weight: int = 0 on the Task dataclass.
  • Store (store_sqlalchemy.py) — non-null sort_weight column (server_default="0"), threaded through to_domain/from_domain/_update_task, plus an Alembic migration that backfills existing rows to 0.
  • Service (service.py) — set_sort_weight (a plain recorded-fact write, leaving state/turn/blocked untouched), and an optional sort_weight argument on create_task/create_task_as.
  • REST (api.py) — field on TaskOut/TaskSummaryOut, SortWeightIn, PUT /tasks/{id}/sort-weight, and sort_weight on CreateTaskIn (POST /tasks).
  • MCP (mcp.py) — set_sort_weight tool, and a sort_weight parameter on create_task.
  • Client (client.py) — matching set_sort_weight and create_task support.

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.

Panopticon Agent and others added 5 commits August 12, 2026 15:14
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
tildesrc marked this pull request as ready for review August 12, 2026 20:14
@tildesrc
tildesrc merged commit a30fc55 into main Aug 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant