aitododocs Coming soonAutonomous delivery

Doctor and the index

Markdown

tkt doctor finds what is wrong in a store and points at tkt index rebuild where needed.

Guideabout 6 min3 commands
On this page

tkt doctor#

Checks every file of the store and never stops at the first problem (tkt lint judges one ticket). Exit 0 clean, 1 info, 2 warning, 3 error, 4 could not run (no store; stdout stays empty even with --json); --strict makes warnings 3, info never escalates. A broken file is a finding (ERR_FILE_PARSE, 3), reported once. --fix-index rebuilds the index (The index); the codes: the doctor table.

Details7 items
  • Run it after every merge (After a merge). A broken file is never also a dangling ref or drift; --fix-index rebuilds a drifted, missing or unreadable index.

  • Times: the store keeps every event as a UTC timestamp, to the second (2026-11-10T12:00:00+00:00): createdAt, updatedAt, closedAt, a doc's or gotcha's timestamp, a decision's decidedAt, a release's shippedAt. Days stay days: targetDate, a decision's date, --shipped-at. An old local-offset time stays readable and becomes UTC the next time the item changes; --fix-times converts them all in one run to the same moment in UTC, leaves the days and prints what it changed. It never runs by itself.

  • Mentions naming nothing: DANGLING_MENTION (doc://, gotcha://), DANGLING_DECISION (decision://D9 or bare D9), with a did-you-mean as in the bundle.

  • Anchoring (info, never in the exit code): docs and gotchas that build on no decision; the list: tkt review --unanchored.

  • Report lines, never findings: counter: store or counter: git: <path> (parallel worktrees); in git merge drivers: installed / not installed / <view> not covered, hint tkt git install (merge drivers).

  • tkt doctor groups the findings per file (severity, code, field, message, hint:), then the counts; a clean store prints ✓ store is healthy. --json: {ok, counts, findings[], index, counter, mergeDrivers}; ok only on exit 0.

  • Anchoring lines: one EDGE_COVERAGE per edge declared for coverage (coverage: decisions without affects 31 of 353 (9 %), open items only); UNANCHORED (critical gotchas counted apart), ORPHANED (no appliesTo and nothing refers to it), UNTOUCHED_UNANCHORED (unanchored and unchanged for untouchedDays, 90). tkt review --unanchored [--older 90d] --json: {unanchored[], olderDays}, each ref, kind, title, buildsOn, stress, orphan, changedAt, days; the age is the timestamp, else the last git commit.

The index#

The SQLite index .aitodo/index.db is derived from the Markdown files: the file always wins; it is gitignored and safe to delete. Every CLI write keeps it in sync, and search, graph, tree reconcile on read (hand edits, git checkout, deleted files), so a rebuild is rarely needed.

tkt index rebuild
a full rebuild in one transaction, only after bulk external changes or corruption; a file it cannot index (ERR_FILE_PARSE, or ERR_INDEX_REBUILD for a duplicate prefix or ULID) leaves the old index, exit 1. It is also the full re-check: after a write outside tkt (an editor, a merge, a new tkt) line 1 is WARN N open review(s) with → tkt review; --quiet prints only that line, and only when one is open (the tkt git install hook runs it).
tkt index status
the counts, the last rebuild, the path; it does not reconcile.
Details4 items
  • The first write into a store without index.db builds it. An index failure never fails the write: the .md is saved and stderr says index not updated (…).

  • tkt doctor: ERR_INDEX_DRIFT (info: a stale row, a row without file, a file without row), ERR_INDEX_CORRUPT. --fix-index rebuilds, also a missing index (without it doctor never creates index.db); a failed rebuild is an ERR_INDEX_REBUILD error and the old index stays.

  • tkt index status fields: ticket_count, group_count, last_rebuild_at (null until a full rebuild), db_path.

  • tkt index rebuild --json (and POST /v1/index:rebuild): the counts and openReviews, the tkt review --json items.

Commands on this page#

Generated from the registry: src/aitodo/api/selfdoc_entries/maint.py · maint.doctor, maint.indexv0.1.298