Bug Description
When the kanban schema gains a new indexed column (e.g., session_id in the tasks table), the CREATE INDEX IF NOT EXISTS statement inside SCHEMA_SQL references the new column — but on existing databases, that column doesn't exist yet. SQLite throws OperationalError: no such column: session_id during conn.executescript(SCHEMA_SQL) at connect() line 1012, before _migrate_add_optional_columns() (line 1013) gets a chance to add the column.
The migration code at line 1168-1180 is correct — it adds the column AND the index. But it's dead code because executescript(SCHEMA_SQL) already crashed.
Steps to Reproduce
- Run a kanban board on an older hermes-agent version (e.g., May 13 build)
hermes update to a build that added session_id to the kanban schema
- The kanban dispatcher fails every tick with
sqlite3.OperationalError: no such column: session_id
Expected Behavior
Existing databases migrate cleanly. The _migrate_add_optional_columns() function should handle the column + index addition without SCHEMA_SQL tripping over it first.
Root Cause
hermes_cli/kanban_db.py line 868 inside SCHEMA_SQL:
CREATE INDEX IF NOT EXISTS idx_tasks_session_id ON tasks(session_id);
IF NOT EXISTS only skips if the index exists — it still validates the column reference. On an existing DB without session_id, this fails before the migration code runs.
Proposed Fix
Remove the CREATE INDEX idx_tasks_session_id from SCHEMA_SQL (line 868). The migration function _migrate_add_optional_columns() at lines 1168-1180 already adds both the column and the index correctly:
if "session_id" not in cols:
_add_column_if_missing(conn, "tasks", "session_id", "session_id TEXT")
conn.execute(
"CREATE INDEX IF NOT EXISTS idx_tasks_session_id "
"ON tasks(session_id)"
)
This is consistent with how run_id on task_events is handled (lines 1182-1190) — the index lives only in the migration function, not in SCHEMA_SQL.
Manual Workaround (for affected users)
sqlite3 ~/.hermes/kanban.db "ALTER TABLE tasks ADD COLUMN session_id TEXT; CREATE INDEX IF NOT EXISTS idx_tasks_session_id ON tasks(session_id);"
Environment
- macOS 26.3.1
- hermes-agent updated May 19, 2026 (306 + 82 commits)
- SQLite via Python 3.11.14
Bug Description
When the kanban schema gains a new indexed column (e.g.,
session_idin thetaskstable), theCREATE INDEX IF NOT EXISTSstatement insideSCHEMA_SQLreferences the new column — but on existing databases, that column doesn't exist yet. SQLite throwsOperationalError: no such column: session_idduringconn.executescript(SCHEMA_SQL)atconnect()line 1012, before_migrate_add_optional_columns()(line 1013) gets a chance to add the column.The migration code at line 1168-1180 is correct — it adds the column AND the index. But it's dead code because
executescript(SCHEMA_SQL)already crashed.Steps to Reproduce
hermes updateto a build that addedsession_idto the kanban schemasqlite3.OperationalError: no such column: session_idExpected Behavior
Existing databases migrate cleanly. The
_migrate_add_optional_columns()function should handle the column + index addition without SCHEMA_SQL tripping over it first.Root Cause
hermes_cli/kanban_db.pyline 868 insideSCHEMA_SQL:IF NOT EXISTSonly skips if the index exists — it still validates the column reference. On an existing DB withoutsession_id, this fails before the migration code runs.Proposed Fix
Remove the
CREATE INDEX idx_tasks_session_idfromSCHEMA_SQL(line 868). The migration function_migrate_add_optional_columns()at lines 1168-1180 already adds both the column and the index correctly:This is consistent with how
run_idontask_eventsis handled (lines 1182-1190) — the index lives only in the migration function, not in SCHEMA_SQL.Manual Workaround (for affected users)
Environment