Skip to content

fix(kanban): create additive indexes after migrations#28602

Closed
verybigdog wants to merge 1 commit into
NousResearch:mainfrom
verybigdog:fix/kanban-additive-index-migration-all
Closed

fix(kanban): create additive indexes after migrations#28602
verybigdog wants to merge 1 commit into
NousResearch:mainfrom
verybigdog:fix/kanban-additive-index-migration-all

Conversation

@verybigdog

Copy link
Copy Markdown

Summary

Fixes Kanban DB initialization for legacy boards whose existing tasks / task_events tables predate additive columns that now have indexes.

connect() runs SCHEMA_SQL before _migrate_add_optional_columns(). Because CREATE TABLE IF NOT EXISTS does not add missing columns to an existing table, any CREATE INDEX in SCHEMA_SQL that references an additive column can fail before the migration has a chance to add that column.

This moves all currently indexed additive-column indexes out of SCHEMA_SQL and creates them after the additive migration guarantees the columns exist:

  • tasks.tenant / idx_tasks_tenant
  • tasks.idempotency_key / idx_tasks_idempotency
  • tasks.session_id / idx_tasks_session_id
  • task_events.run_id / idx_events_run

Relationship to #28461

This intentionally overlaps with #28461, which fixes the same ordering class for session_id and run_id. This PR covers the broader additive-index set (tenant, idempotency_key, session_id, and run_id) and adds a regression test with a legacy DB missing all four indexed additive columns.

If maintainers prefer #28461 as the landing path, this can be closed or used as supplemental regression coverage / patch guidance.

Test Plan

  • python -m py_compile hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_db_init.py
  • python -m pytest tests/hermes_cli/test_kanban_db_init.py -q -o addopts= --tb=short
  • git diff --check

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have labels May 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing fix for #28464 alongside #28461 and #28597. This PR covers the broader additive-index set (tenant, idempotency_key, session_id, run_id) versus #28461's narrower scope (session_id, run_id only).

@verybigdog

Copy link
Copy Markdown
Author

Thanks for the pointer. Agreed this overlaps with #28461/#28597 around #28464. This draft is intentionally the broader additive-index coverage path: it keeps the migration ordering fix for all optional columns that later indexes may reference (tenant, idempotency_key, session_id, run_id) rather than only the currently failing pair.\n\nHappy to keep this as draft while maintainers choose the preferred direction, close it in favor of another PR if that lands first, or rework it into supplemental regression coverage for the broader optional-index set.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Thanks @verybigdog — closing as duplicate of #28781, which combined all six community PRs that hit this bug on 2026-05-19 into one salvage (merged in 7552e0f). You correctly diagnosed the SCHEMA_SQL-before-migration ordering issue. The salvage extends coverage to all four additive-column indexes (idx_tasks_session_id, idx_tasks_tenant, idx_tasks_idempotency, idx_events_run) and ships a regression test seeding a pre-#16081 + pre-#17805 fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants