Task Management (Stack)
Manages a LIFO task stack with push, push_next, push_last, pop, promote, reorder, remove, soft-delete, and description editing operations. Data is persisted to the user's home directory.
Requirements
- The system MUST persist active tasks and soft-deleted tasks to a file in the user's home directory.
- The system MUST use atomic writes to prevent data corruption.
- The system MUST store each task with the following fields:
text,created_at,started_at,last_current,duration,description, and optionallydeleted_at. - Active (non-deleted) tasks MUST be listed first in the file, followed by soft-deleted tasks appended at the end.
- The
pushoperation MUST insert a new task at position 0, setcreated_atandstarted_atto the current time, setlast_currentto the current time, and end the current stint of the previous top task. - The
push_nextoperation MUST insert a new task at position 1 (immediately after the current task) without making it current. If no tasks exist, it MUST behave likepush. - The
push_lastoperation MUST insert a new task at the bottom of the active list. If no tasks exist, it MUST mark the new task as current. - The
popoperation MUST remove the task at position 0, record itsdeleted_attimestamp, end its current stint, move it to the deleted history, and mark the new top task as current. - The
removeoperation MUST soft-delete the task at the given index, recordingdeleted_atand ending its stint if it was at position 0. If the removed task was at position 0, the new top task MUST be marked current. - The
promoteoperation MUST move the task at the given index to position 0 and mark it as current. - The
reorderoperation MUST move a task from one index to another, correctly managing stint transitions when tasks enter or leave position 0. - The
update_textoperation MUST update the text of the task at the given index in place. Empty or whitespace-only text MUST be rejected (no change applied). - The
update_descriptionoperation MUST update the description of the task at the given index in place. - The system MUST track cumulative active duration per task via the
durationfield, accumulating elapsed time whenever a task leaves position 0. - The
live_durationcomputation MUST return the storeddurationplus the elapsed time sincelast_currentfor the task currently at position 0. - The system MUST automatically migrate the legacy data file format to the current format on first load, preserving the original as a backup.
- The system SHOULD backfill
durationfor legacy entries that lack it by usinglast_current - started_atas the cumulative active duration. - The system MAY support
format_timestampwith adaptive precision (year, month, day, hour, minute) based on proximity to the current time. - The system MAY support
format_durationwith two-unit human-readable output (e.g.2h 05m,3d 04h).