Skip to content

long running tasks todolist data

sherry-wiki edited this page Nov 17, 2026 · 5 revisions

📦 TodoList Data Layer — Plans, Boulder, Ledger & registry.db

Sherry Wiki · English · 中文 · 日本語 · 한국어

← Back to index

Part of TodoList: the session-scoped data stores behind the planning layer — plan files, boulder state, the evidence ledger, and the registry.db schema.


Data Layer

Plan Files (workspace/sessions/<session_id>/plans/*.md)

Checkbox-format Markdown defining the complete HTN decomposition. Plans are session-scoped: clearing a session deletes that session's plans (the whole workspace/sessions/<session_id>/ tree is removed). A plan reference resolves through config.path.resolve_plan_path to the session tree or an explicit repo-relative path; no external orchestration directory participates.

# <Plan Name>

## Goal

<detailed goal: plan name, path, terminal state, delivery mode, verification>

## Context

<project background, constraints, known info>

## TODOs

### Wave 0: <Wave description>

- [ ] [WHERE] [HOW] to [WHY] - expect [RESULT]
  - Recommended task executor category: quick
  - Verification: <exact command + assertion>
  - Files in scope: <path1, path2>

### Wave 1: <Wave description> (depends on Wave 0)

- [ ] [WHERE] [HOW] to [WHY] - expect [RESULT]
  - Depends on: Wave 0
  - Verification: <exact command + assertion>

## Final Verification Wave

- [ ] Run full test suite + typecheck + lint
- [ ] Manual QA: <exact command, exact observable, exact assertion>
- [ ] Cleanup receipts: <list of resources to tear down>

Boulder State (src/data/boulder.json)

Persistent work state:

{
  "schema_version": 2,
  "active_work_id": "<work-id>",
  "works": {
    "<work-id>": {
      "work_id": "<work-id>",
      "active_plan": "workspace/sessions/<session_id>/plans/<plan-name>.md",
      "plan_name": "<plan-name>",
      "session_ids": ["sherry:<session_id>"],
      "status": "active",
      "worktree_path": null,
      "created_at": "2026-09-07T00:00:00Z"
    }
  }
}

Evidence Ledger (src/data/registry.db (evidence_events table))

SQLite table evidence_events (WAL): the shared verification audit trail. Rows are INSERTed and never UPDATEd; retention deletes old rows. It is written by agent/tools/pub_base/evidence_recorder.py and read by agent/tools/taskflow/evidence_collector.py; the producers, row schemas, the derived-staleness rule, the summary format, retention and the gates that consume it are documented in Evidence Ledger.

registry.db — Session-Level TODO Storage

CREATE TABLE IF NOT EXISTS todos (
    session_id   TEXT    NOT NULL,
    content      TEXT    NOT NULL,
    status       TEXT    NOT NULL DEFAULT 'pending',
    priority     TEXT    NOT NULL DEFAULT 'medium',
    position     INTEGER NOT NULL,
    category     TEXT    NOT NULL DEFAULT 'quick',
    delegation   TEXT    NOT NULL DEFAULT 'self',
    subagent_id  TEXT    DEFAULT NULL,
    plan_ref     TEXT    DEFAULT NULL,
    flow_id      TEXT    DEFAULT NULL,
    step_id      TEXT    DEFAULT NULL,
    created_at   TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    todo_id      INTEGER NOT NULL,
    PRIMARY KEY (session_id, position)
);
Field Description
plan_ref Linked plan file path — session-scoped workspace/sessions/<session_id>/plans/*.md
flow_id Linked TaskFlow flow id (DAG owned by TaskFlow)
step_id Linked TaskFlow step id (e.g. step-2), for re-reading DAG status
todo_id Stable per-session identity shown as #N; local patch/remove/reattach address it. position is display order only

Design boundary: registry.db does not hold depends_on / DAG state / step status. The dependency graph, blocked/ready/dispatched/done and unlock logic are all provided by TaskFlow. The todo only points to the corresponding flow step via flow_id/step_id; DAG status is re-read via taskflow_inspect(action="summary", flow_id).

CRUD interface:

async def replace_all(session_id: str, todos: list[dict]) -> None:
    """Full replacement: DELETE + INSERT (transactional)"""

async def get_todos(session_id: str) -> list[dict]:
    """Read sorted by position"""

def get_todos_sync(session_id: str) -> list[dict]:
    """Sync path for system prompt injection (no event loop)"""

async def get_todos_by_flow(session_id: str, flow_id: str) -> list[dict]:
    """Read todos linked to a TaskFlow flow (map DAG status back to UI)"""

async def add_todo(session_id, todo, *, after_todo_id=None) -> dict | None:
    """Append, or insert after the stable todo_id anchor"""

async def patch_todo_by_id(session_id, todo_id, **fields) -> dict | None:
    """Patch one row; flow_id/step_id/plan_ref stay untouched"""

async def remove_todo_by_id(session_id, todo_id) -> dict | None:
    """Delete one row by stable id"""

Clone this wiki locally