Define the Task data model #66

Closed
opened 2026-09-07 20:37:17 +01:00 by liamjd · 0 comments
Owner

Part of milestone #5. The generic base that every task type extends. Pure data plus abstract hooks, so it is headless-testable and serialisable, following the same record-is-the-truth pattern as Building.

Design:

  • Abstract Task extends Entity (RefCounted), with @abstract hooks the way Entity itself is declared
  • Fields: id (manager-assigned, never reused), priority (int, higher first), created_seq (creation order), status, parent, children, target_cell: Vector2i (where a pawn must stand to work it), required_role (for specialisation, see the later issue), assignee (pawn id or -1), work_remaining
  • Status enum: PENDING, CLAIMED, IN_PROGRESS, BLOCKED, COMPLETE, CANCELLED
  • Abstract hooks: can_start(ctx) -> bool (resources, reachability), work(ctx, ticks) -> void, on_complete(ctx), on_cancel(ctx)
  • ctx is a small context object handing the task what it may touch (Buildings registry, later resources) rather than tasks reaching for autoloads

AC:

  • Task cannot be instantiated directly; a stub subclass in the test suite can
  • Status transitions are validated (e.g. COMPLETE cannot go back to PENDING) and an invalid transition pushes an error
  • Unit tests for the transition table using a stub task

Adding a new task type must require only a new subclass, no changes to the manager.

Part of milestone #5. The generic base that every task type extends. Pure data plus abstract hooks, so it is headless-testable and serialisable, following the same record-is-the-truth pattern as `Building`. Design: - Abstract `Task extends Entity` (RefCounted), with `@abstract` hooks the way `Entity` itself is declared - Fields: `id` (manager-assigned, never reused), `priority` (int, higher first), `created_seq` (creation order), `status`, `parent`, `children`, `target_cell: Vector2i` (where a pawn must stand to work it), `required_role` (for specialisation, see the later issue), `assignee` (pawn id or -1), `work_remaining` - `Status` enum: PENDING, CLAIMED, IN_PROGRESS, BLOCKED, COMPLETE, CANCELLED - Abstract hooks: `can_start(ctx) -> bool` (resources, reachability), `work(ctx, ticks) -> void`, `on_complete(ctx)`, `on_cancel(ctx)` - `ctx` is a small context object handing the task what it may touch (Buildings registry, later resources) rather than tasks reaching for autoloads AC: - Task cannot be instantiated directly; a stub subclass in the test suite can - Status transitions are validated (e.g. COMPLETE cannot go back to PENDING) and an invalid transition pushes an error - Unit tests for the transition table using a stub task Adding a new task type must require only a new subclass, no changes to the manager.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#66
No description provided.