Skip to content

feat(task-manager): durable task system with append-only event history#132

Merged
codeaholicguy merged 5 commits into
mainfrom
feature-task-system
Jul 2, 2026
Merged

feat(task-manager): durable task system with append-only event history#132
codeaholicguy merged 5 commits into
mainfrom
feature-task-system

Conversation

@codeaholicguy

@codeaholicguy codeaholicguy commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Introduces @ai-devkit/task-manager as an optional AI DevKit plugin for durable development/debug tasks. A task has a stable raw UUID id and captures artifacts, evidence, progress, blockers, lifecycle phase, actor attribution when supplied by the caller, branch/worktree/PR links, and an append-only event history.

The core ai-devkit CLI no longer imports or registers the task command. Users opt in by installing/enabling the package as a plugin:

ai-devkit plugin add @ai-devkit/task-manager

Once enabled, the plugin contributes ai-devkit task .... Without the plugin, the core CLI avoids the extra task-manager dependency and command/context surface.

What's included

  • New package @ai-devkit/task-manager:
    • TaskService public API for create/list/show/update/phase/status/progress/next/blocker/evidence/artifact/assign/note/event/close flows.
    • Concrete TaskRepository SQLite persistence over tasks and task_events.
    • Shared database modules with WAL, busy_timeout, migrations, and default path ~/.ai-devkit/tasks.db.
    • Public Task/TaskEvent shapes and the closed set of task.* event type strings.
  • Optional plugin command:
    • package.json declares aiDevkit.commands for task.
    • packages/task-manager/src/command.ts registers task subcommands on the host-provided plugin command.
    • Project .ai-devkit.json tasks.path is resolved by the plugin command; --db-path remains the explicit override.
  • Core CLI cleanup:
    • Removed built-in task command registration.
    • Removed CLI dependency on @ai-devkit/task-manager.
    • Removed host-side task DB config helper/tests.
  • Docs and README updated to describe the optional plugin install path.

Storage layout

SQLite database: ~/.ai-devkit/tasks.db by default.

  • tasks: one row per task snapshot, with full Task JSON plus indexed query columns.
  • task_events: append-only event history, one row per event.

The snapshot remains authoritative for reads; events preserve the audit trail.

Key decisions

  • Task manager is opt-in via the plugin system to avoid extra dependency, command, token, and context overhead for users who do not need it.
  • Actor metadata is explicit: skills/API callers pass opts.actor, CLI users pass --agent, --agent-type, --pid, or --session; omitted actors are stored as null.
  • One task per feature; phase is a single advancing field.
  • Snapshot + append-only events, not pure event sourcing.
  • Artifacts are references only; file contents are not copied into storage.
  • Raw UUIDv4 strings for task, event, blocker, evidence, and artifact ids.
  • Task DB resolution uses explicit --db-path, then project .ai-devkit.json tasks.path, then ~/.ai-devkit/tasks.db.

Validation

Command Result
npm run lint via commit hook Passed, exit 0. Existing warnings only; none in task-manager.
npm test via commit hook Passed, exit 0. 72 CLI test files, 871 CLI tests; task-manager 7 test files, 110 tests.
npx nx test task-manager Passed, exit 0. 7 test files, 110 tests.
npx nx build task-manager Passed, exit 0.
npx nx lint task-manager Passed, exit 0.
npx ai-devkit@latest lint --feature task-system Passed, exit 0.

Tests

  • packages/task-manager/tests/unit/{ids,errors}.test.ts
  • packages/task-manager/tests/integration/{task.repository,service,add-event-coverage}.test.ts
  • packages/task-manager/tests/command.test.ts
  • packages/task-manager/tests/plugin-package.test.ts

Risks / limitations (MVP)

  • Single-user local SQLite database; no networked multi-user sync.
  • Snapshot is authoritative; event-sourced replay is deferred.
  • No project management features: boards, milestones, hierarchies, permissions, or accounts.

Not for merge until review is complete.

codeaholicguy added a commit that referenced this pull request Jul 1, 2026
)

Add a guarded integration test proving the real TaskService (shipped on
feature-task-system) satisfies the tracing ITaskService port end-to-end, with
NO mapping-logic divergence. Round-trips every semantic (ensureFeatureTask,
phase/progress/nextStep/blocker/evidence/attribution/note/custom/close) through
the real service + file-backed store and asserts the exact contract event-type
strings + persisted snapshot.

- tests/integration.task-manager.test.ts: skips cleanly (1 passed | 5 skipped)
  when @ai-devkit/task-manager is not resolvable, so standalone CI is green
  before #132 merges; auto-activates once #132 lands. Both states verified.
- .eslintrc.json: add package lint config (mirrors @ai-devkit/agent-manager).
- README/implementation/testing: mark wiring SHIPPED; note the real TaskService
  is assignable to the port via method bivariance (no port change needed).

Validation (fresh, real package resolvable): tsc --noEmit exit 0; vitest run
44 passed (38 unit + 6 real integration) exit 0; build exit 0; eslint 0 errors.
Standalone (package absent): 39 passed | 5 skipped, exit 0.
@codeaholicguy codeaholicguy force-pushed the feature-task-system branch 7 times, most recently from b57e285 to f0203cd Compare July 2, 2026 09:18
…UUID ids

Introduce @ai-devkit/task-manager as the durable unit for development/debug
work. A task has a stable id and encapsulates artifacts, evidence, progress,
blockers, lifecycle phase, agent attribution, branch/worktree/PR links, and an
append-only event history.

Structure (mirrors @ai-devkit/memory):
  src/
    task.types.ts      # public types: Actor, Task, TaskEvent, payloads
    task.errors.ts     # TaskError hierarchy + isTaskEventType guard
    task.ids.ts        # raw UUIDv4 id generators (crypto.randomUUID)
    actor-resolver.ts  # resolveCurrentActor (env + process)
    task.repository.ts # TaskRepository — task/event persistence (SQLite)
    task.service.ts    # TaskService (public consume-only surface)
    database/          # connection.ts (getDatabase/closeDatabase singleton,
                       #   WAL, busy_timeout), schema.ts, migrations/
    index.ts

Persistence:
- SQLite at ~/.ai-devkit/tasks.db via better-sqlite3, mirroring @ai-devkit/memory:
  process-wide getDatabase() singleton, versioned migrations via user_version,
  SQL assets copied to dist by the build; tests reset with closeDatabase().
- TaskRepository owns the task/event SQL. A tasks table holds snapshots (full
  Task JSON + indexed columns); a task_events table is the append-only history.
- No SPI / swappable-backend abstraction: TaskRepository is the single concrete
  persistence class.

IDs: raw UUIDv4 (crypto.randomUUID()) stored as TEXT — globally unique, no
prefix, suffix, or collision checks. Generated in the service layer (like memory).

CLI: ai-devkit task create/list/show/update/phase/status/progress/next/blocker/
evidence/artifact/assign/note/event/close, with --json and attribution.

Tests: 890 passing repo-wide; task-manager coverage 90% stmt / 79% branch.

Public API: Task/TaskEvent shapes, TaskService methods, CLI commands, and the 14
task.* event types are stable. The only format change vs the prior draft is that
ids are now raw UUIDs (no task_/evt_ prefix); the persistence class is named
TaskRepository (concrete, in task.repository.ts).
@codeaholicguy codeaholicguy force-pushed the feature-task-system branch from 94104f4 to 8d1d63f Compare July 2, 2026 11:35
@codeaholicguy codeaholicguy merged commit fbf4bf7 into main Jul 2, 2026
7 checks passed
@codeaholicguy codeaholicguy deleted the feature-task-system branch July 2, 2026 12:00
codeaholicguy added a commit that referenced this pull request Jul 2, 2026
)

Add a guarded integration test proving the real TaskService (shipped on
feature-task-system) satisfies the tracing ITaskService port end-to-end, with
NO mapping-logic divergence. Round-trips every semantic (ensureFeatureTask,
phase/progress/nextStep/blocker/evidence/attribution/note/custom/close) through
the real service + file-backed store and asserts the exact contract event-type
strings + persisted snapshot.

- tests/integration.task-manager.test.ts: skips cleanly (1 passed | 5 skipped)
  when @ai-devkit/task-manager is not resolvable, so standalone CI is green
  before #132 merges; auto-activates once #132 lands. Both states verified.
- .eslintrc.json: add package lint config (mirrors @ai-devkit/agent-manager).
- README/implementation/testing: mark wiring SHIPPED; note the real TaskService
  is assignable to the port via method bivariance (no port change needed).

Validation (fresh, real package resolvable): tsc --noEmit exit 0; vitest run
44 passed (38 unit + 6 real integration) exit 0; build exit 0; eslint 0 errors.
Standalone (package absent): 39 passed | 5 skipped, exit 0.
codeaholicguy added a commit that referenced this pull request Jul 2, 2026
…ogress tracking (#131)

* feat(task-tracer): add tracing layer mapping lifecycle progress to the Task contract

Introduce packages/task-tracer, a port-based (dependency inversion) tracing
layer that maps dev-lifecycle / structured-debug progress semantics onto the
LOCKED Task contract from feature-task-system. Task is the durable unit;
tracing = task progress/events — no separate session-trace model, no task
storage duplication.

- contract.ts: async ITaskService port mirroring the locked TaskService API
  (Task/TaskEvent/Actor/TaskEventType) verbatim; consume-only.
- TaskTracer: one method per semantic; each calls exactly one service mutator
  (phase/progress/nextStep/blocker/evidence/attribution/note/custom/close).
- in-memory.ts: faithful InMemoryTaskService test double (not shipped storage).
- status.ts: readStatus digest with staleness for orchestrator routing.
- cli-argv.ts: pure argv builders for the upstream `ai-devkit task` CLI.
- 38 vitest unit tests across contract conformance, mapping, status, argv.

Validation (fresh): tsc --noEmit exit 0; vitest run 38 passed exit 0;
swc + declarations build exit 0.

Wires into @ai-devkit/task-manager (TaskService) with zero mapping changes
when that package ships.

* test(task-tracer): wire port to shipped @ai-devkit/task-manager (PR #132)

Add a guarded integration test proving the real TaskService (shipped on
feature-task-system) satisfies the tracing ITaskService port end-to-end, with
NO mapping-logic divergence. Round-trips every semantic (ensureFeatureTask,
phase/progress/nextStep/blocker/evidence/attribution/note/custom/close) through
the real service + file-backed store and asserts the exact contract event-type
strings + persisted snapshot.

- tests/integration.task-manager.test.ts: skips cleanly (1 passed | 5 skipped)
  when @ai-devkit/task-manager is not resolvable, so standalone CI is green
  before #132 merges; auto-activates once #132 lands. Both states verified.
- .eslintrc.json: add package lint config (mirrors @ai-devkit/agent-manager).
- README/implementation/testing: mark wiring SHIPPED; note the real TaskService
  is assignable to the port via method bivariance (no port change needed).

Validation (fresh, real package resolvable): tsc --noEmit exit 0; vitest run
44 passed (38 unit + 6 real integration) exit 0; build exit 0; eslint 0 errors.
Standalone (package absent): 39 passed | 5 skipped, exit 0.

* refactor(task-tracer): simplify pass — drop unused ActorResolver, fix docs

Analysis-first simplification of PR #131. No semantics or contract changes.

- Remove src/ActorResolver.ts (+ exports): 0 internal callers, 0 tests, 0
  consumers. It duplicated the TaskService's env-resolution and was trivially
  replaceable by an Actor literal. Cheapest to remove pre-merge (v0.1.0, no
  consumers). README/design/implementation/planning updated; callers pass an
  explicit Actor directly.
- TaskTracer.ts: fix ValidationInput.passed docstring ("defaults to true" was
  false — field is required, no default).
- integration.task-manager.test.ts: drop tautology "integration guard" test
  (asserted `mod === null || mod !== null`, always true). vitest reports the
  skipped suite cleanly without it.

Kept (considered, justified): contract.ts port (decouples from optional peer;
ITaskService is task-tracer's own), InMemoryTaskService (fast hermetic no-IO
unit tests + public export).

Validation (fresh): tsc --noEmit exit 0; eslint 0 errors; build exit 0.
Standalone (task-manager absent): 38 passed | 5 skipped, exit 0.
Real package resolvable: 43 passed (38 unit + 5 real integration), exit 0.

* feat(skill): add task skill for CLI-driven lifecycle/debug progress tracing

Replace the packages/task-tracer package + contract/port docs with a focused
skill/docs integration — the same pattern as the memory skill. The integration
surface is the ai-devkit task CLI; no TypeScript abstraction layer.

- skills/task/SKILL.md: canonical ai-devkit task CLI calls for dev-lifecycle /
  verify / structured-debug progress (phase, progress, next, blocker add/resolve,
  evidence, artifact, attribution, show/list). Feature key resolves positionally
  as <id>, so agents do no task-id bookkeeping. Token-efficient, emit-at-checkpoints.
- skills/task/agents/openai.yaml: skill interface metadata.
- constants.ts: register 'task' in BUILTIN_SKILL_NAMES so init/skill add --built-in
  install it.
- .ai-devkit.json: install the task skill in this project.

Removes packages/task-tracer (port, contract, in-memory double, CLI argv
builders, all tests) and the contract/port-oriented feature docs added earlier
on this branch — they net to zero vs main.

Two reviewer-provided canonical examples were adapted to match the SHIPPED CLI
(verified by running each command against a throwaway store):
- '--workflow' is not a CLI flag (unknown option); feature key + phase carry the
  workflow — omitted.
- 'progress <id> "text"' silently drops the text (progress.text stays null); the
  skill uses '--text'.

Validation (fresh): npm run lint exit 0 (5 projects); npm run test exit 0
(870 passed, 5 projects); SKILL.md frontmatter + openai.yaml parse via the CLI's
own skill parsers (validateSkillName, extractSkillDescription).

* docs(skills): add optional task tracing guidance

* docs(skills): keep agent management focused

* docs(skills): simplify task tracing guidance

* docs(skills): allow npx task fallback
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