fix(T11563): drizzle-conduit migration applies cleanly on fresh cleo.db (attachments collision)#912
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bareattachmentstable (id, sha256, attachment_json, ...). The conduit forward migration'sCREATE TABLE IF NOT EXISTS attachments(conduit shape:slug, conversation_id, content BLOB, ...) therefore silently no-opped against the docs table, and the next statement —— crashed with
no such column: conversation_id(the docsattachmentstable has noconversation_id). This brokecleo agent list(E_LIST: DrizzleError: Failed to run the query) and everycleo conduit *command on a fresh build.The per-leaf unit test passed because
ensureConduitDbran against an isolated tmpcleo.dbwhere the docsattachmentstable was never created — the full CLI creates it first. The migration's own "disjoint physical names" comment was wrong:attachmentsis 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 docsattachmentstable — matching the consolidatedcleo-project/conduit.tsschema and the exodus rename-map target (attachments→conduit_attachments):migration.sql+conduit-schema.ts: renameattachments/attachment_versions/attachment_approvals/attachment_contributors(+ their indexes, unique constraints, FK references) toconduit_*.migrate-signaldock-to-conduit.ts:PROJECT_TIER_TABLESis now{src, dest}pairs;copyTableRowsaccepts adestTableNameso the legacy bare source names map to the prefixed destination names (latent cascade bug for pre-T310 installs).conduit-sqlite.test.ts:EXPECTED_LEGACY_TABLESupdated to the prefixed names.Verification
XDG_DATA_HOME:cleo agent list→{success:true, data:[]}(wasE_LIST);cleo conduit statusreaches the app layer (E_CONDUIT: no agent credential— expected business response, not a migration crash).attachmentstable;conduit_attachments_conversation_idxlands onconversation_id.@cleocode/coreconduit suite (181 tests) + full@cleocode/runtime(120) green; the only core-suite failures are the pre-existing worktree-napi env failures (confirmed identical on cleanorigin/main).cleo check arch5/5;lint-migrations --fail-on=errorexit 0.Closes T11563.
🤖 Generated with Claude Code