Skip to content

fix(T11563): drizzle-conduit migration applies cleanly on fresh cleo.db (attachments collision)#912

Merged
kryptobaseddev merged 2 commits into
mainfrom
task/T11563-conduit-migfix
Jun 1, 2026
Merged

fix(T11563): drizzle-conduit migration applies cleanly on fresh cleo.db (attachments collision)#912
kryptobaseddev merged 2 commits into
mainfrom
task/T11563-conduit-migfix

Conversation

@kryptobaseddev
Copy link
Copy Markdown
Owner

Root cause (P1 — clean-build conduit/agent crash)

E6-L3 (#900) routed the conduit domain into the consolidated project cleo.db. That DB already contains the docs-domain bare attachments table (id, sha256, attachment_json, ...). The conduit forward migration's CREATE TABLE IF NOT EXISTS attachments (conduit shape: slug, conversation_id, content BLOB, ...) therefore silently no-opped against the docs table, and the next statement —

CREATE INDEX IF NOT EXISTS attachments_conversation_idx ON attachments(conversation_id);

— crashed with no such column: conversation_id (the docs attachments table has no conversation_id). This broke cleo agent list (E_LIST: DrizzleError: Failed to run the query) and every cleo conduit * command on a fresh build.

The per-leaf unit test passed because ensureConduitDb ran against an isolated tmp cleo.db where the docs attachments table was never created — the full CLI creates it first. The migration's own "disjoint physical names" comment was wrong: attachments is the only conduit bare name that collides (with the tasks/docs domain).

Fix (root-cause, no integrity weakening)

Prefix the four conduit attachment-family tables/indexes/FK refs with conduit_ so they are physically disjoint from the docs attachments table — matching the consolidated cleo-project/conduit.ts schema and the exodus rename-map target (attachmentsconduit_attachments):

  • migration.sql + conduit-schema.ts: rename attachments/attachment_versions/attachment_approvals/attachment_contributors (+ their indexes, unique constraints, FK references) to conduit_*.
  • migrate-signaldock-to-conduit.ts: PROJECT_TIER_TABLES is now {src, dest} pairs; copyTableRows accepts a destTableName so the legacy bare source names map to the prefixed destination names (latent cascade bug for pre-T310 installs).
  • conduit-sqlite.test.ts: EXPECTED_LEGACY_TABLES updated to the prefixed names.

Verification

  • Fresh XDG_DATA_HOME: cleo agent list{success:true, data:[]} (was E_LIST); cleo conduit status reaches the app layer (E_CONDUIT: no agent credential — expected business response, not a migration crash).
  • Migration replay proves the conduit migration now applies cleanly alongside a pre-existing docs attachments table; conduit_attachments_conversation_idx lands on conversation_id.
  • @cleocode/core conduit suite (181 tests) + full @cleocode/runtime (120) green; the only core-suite failures are the pre-existing worktree-napi env failures (confirmed identical on clean origin/main).
  • cleo check arch 5/5; lint-migrations --fail-on=error exit 0.

Closes T11563.

🤖 Generated with Claude Code

kryptobaseddev and others added 2 commits June 1, 2026 10:38
…db (attachments_conversation_idx) — clean-build conduit/agent commands

Root cause: E6-L3 (#900) routed the conduit domain into the consolidated
project cleo.db, where the docs-domain bare `attachments` table already lives.
The conduit forward migration's `CREATE TABLE IF NOT EXISTS attachments`
silently no-opped against the docs table, then
`CREATE INDEX attachments_conversation_idx ON attachments(conversation_id)`
crashed with "no such column: conversation_id" — breaking `cleo agent list`
and every `cleo conduit *` command on a fresh build. The migration's own
"disjoint physical names" assumption was wrong: `attachments` collided with
the tasks/docs domain.

Fix: prefix the four conduit attachment-family tables/indexes/FKs with
`conduit_` (conduit_attachments, conduit_attachment_versions,
conduit_attachment_approvals, conduit_attachment_contributors) so they are
physically disjoint from the docs `attachments` table — matching the
consolidated cleo-project schema and the exodus rename-map target. The
signaldock→conduit one-shot migration now maps legacy bare source names to
the prefixed destination names (copyTableRows gains a destTableName param).

- migration.sql + conduit-schema.ts: rename the 4 attachment-family tables,
  their indexes, unique constraints, and FK references to conduit_* names
- migrate-signaldock-to-conduit.ts: PROJECT_TIER_TABLES is now {src,dest}
  pairs; copyTableRows accepts a destTableName
- conduit-sqlite.test.ts: EXPECTED_LEGACY_TABLES updated to the prefixed names

Verified: fresh-XDG_DATA_HOME `cleo agent list` + `cleo conduit status` run
clean; conduit migration applies alongside a pre-existing docs `attachments`
table; @cleocode/core conduit suite (181) + @cleocode/runtime (120) green;
cleo check arch 5/5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kryptobaseddev kryptobaseddev merged commit b8cd28b into main Jun 1, 2026
68 checks passed
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