Schema drift: embedding column missing from agents table causes test failures #260

Closed
opened 2026-07-22 18:32:48 +00:00 by Mark · 6 comments
Owner

Finding from post-deploy probe (kanban task t_672a7f51)

Two test failures discovered in mesh-seed tests, both stemming from the same root cause:

  1. test_ledger.py::TestReputation::test_reputation_update_success — embedding column missing from agents table schema
  2. test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column — same root cause

Root cause: The Agent model reads row["embedding"] but the CREATE TABLE agents migration does not include the embedding column. This is schema drift between the model definition and the database migration.

Actual behavior: Both tests fail because the embedding column does not exist in the table schema.

Expected behavior: The agents table migration should include the embedding column so the model can read it and the tests pass.

Reproduction steps:

  1. Set up a fresh database using the existing migrations
  2. Run pytest tests/test_ledger.py -k test_reputation_update_success
  3. Observe failure: KeyError: "embedding" (or similar column-not-found error)
  4. Run pytest tests/test_embedding_ledger.py -k test_agents_table_has_embedding_column
  5. Observe failure with same root cause

Suggested fix: Add the missing embedding column to the CREATE TABLE agents migration.

Kanban card: t_672a7f51

**Finding from post-deploy probe (kanban task t_672a7f51)** Two test failures discovered in mesh-seed tests, both stemming from the same root cause: 1. `test_ledger.py::TestReputation::test_reputation_update_success` — `embedding` column missing from agents table schema 2. `test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column` — same root cause **Root cause:** The `Agent` model reads `row["embedding"]` but the `CREATE TABLE agents` migration does not include the `embedding` column. This is schema drift between the model definition and the database migration. **Actual behavior:** Both tests fail because the `embedding` column does not exist in the table schema. **Expected behavior:** The `agents` table migration should include the `embedding` column so the model can read it and the tests pass. **Reproduction steps:** 1. Set up a fresh database using the existing migrations 2. Run `pytest tests/test_ledger.py -k test_reputation_update_success` 3. Observe failure: `KeyError: "embedding"` (or similar column-not-found error) 4. Run `pytest tests/test_embedding_ledger.py -k test_agents_table_has_embedding_column` 5. Observe failure with same root cause **Suggested fix:** Add the missing `embedding` column to the `CREATE TABLE agents` migration. **Kanban card:** t_672a7f51
Mark closed this issue 2026-08-04 04:34:56 +00:00
Author
Owner

QA verification failed: the fixit run did not land a commit or PR for #260. On current origin/master, ./.venv/bin/pytest -q tests/unit/test_ledger.py::TestReputation::test_reputation_update_success tests/unit/test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column collects 2 tests and both fail: AgentView raises IndexError: No item with that key for row["embedding"], and the fresh-schema test confirms embedding is absent from agents. Reopening for an actual implementation and verification.

QA verification failed: the fixit run did not land a commit or PR for #260. On current origin/master, `./.venv/bin/pytest -q tests/unit/test_ledger.py::TestReputation::test_reputation_update_success tests/unit/test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column` collects 2 tests and both fail: AgentView raises `IndexError: No item with that key` for `row["embedding"]`, and the fresh-schema test confirms `embedding` is absent from `agents`. Reopening for an actual implementation and verification.
Mark reopened this issue 2026-08-04 05:21:40 +00:00
Mark closed this issue 2026-08-04 14:30:22 +00:00
Author
Owner

QA verification on current origin/master (92521ce) fails: the fixit card did not land a commit. ./.venv/bin/pytest -q tests/unit/test_ledger.py::TestReputation::test_reputation_update_success tests/unit/test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column collects 2 tests and both fail. AgentView raises IndexError: No item with that key at row["embedding"]; the fresh-schema test confirms embedding is absent from agents. Reopening for an actual implementation and verification.

QA verification on current origin/master (92521ce) fails: the fixit card did not land a commit. `./.venv/bin/pytest -q tests/unit/test_ledger.py::TestReputation::test_reputation_update_success tests/unit/test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column` collects 2 tests and both fail. AgentView raises `IndexError: No item with that key` at `row["embedding"]`; the fresh-schema test confirms `embedding` is absent from `agents`. Reopening for an actual implementation and verification.
Mark reopened this issue 2026-08-04 15:36:37 +00:00
Author
Owner

QA Verification (2026-08-04)

Bug confirmed on master. Both affected tests fail:

  • test_agents_table_has_embedding_column: assert embedding in columns FAILS
  • test_reputation_update_success: IndexError on row[embedding]

Fix verified in PR #267 (commit 3e49e412):

  • Adds migration add_embedding_to_agents: ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT ''
  • Both tests PASS on the PR branch
  • Full ledger/embedding test suite (49 tests) passes with no regressions

PR #267 is still open and not merged. Once merged, the tests will pass on master.

## QA Verification (2026-08-04) **Bug confirmed on master.** Both affected tests fail: - test_agents_table_has_embedding_column: assert embedding in columns FAILS - test_reputation_update_success: IndexError on row[embedding] **Fix verified in PR #267** (commit 3e49e412): - Adds migration add_embedding_to_agents: ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '' - Both tests PASS on the PR branch - Full ledger/embedding test suite (49 tests) passes with no regressions **PR #267 is still open and not merged.** Once merged, the tests will pass on master.
Author
Owner

QA PASS (2026-08-04)

Fix confirmed via PR #267 (commit 3e49e41, merged as 18946b0). Both affected tests now pass on current origin/master:

  • test_reputation_update_success: PASSED
  • test_agents_table_has_embedding_column: PASSED

Root cause: migration 0002 adds embedding column to agents table. PR #267 (fix for #258) addressed the same root cause and merged into master.

Full unit test suite has 2 pre-existing collection errors (unrelated import issues in test_secret_rotation.py and test_retention.py) -- not related to this fix.

Closing as fixed by #267.

## QA PASS (2026-08-04) Fix confirmed via PR #267 (commit 3e49e41, merged as 18946b0). Both affected tests now pass on current origin/master: - test_reputation_update_success: PASSED - test_agents_table_has_embedding_column: PASSED Root cause: migration 0002 adds embedding column to agents table. PR #267 (fix for #258) addressed the same root cause and merged into master. Full unit test suite has 2 pre-existing collection errors (unrelated import issues in test_secret_rotation.py and test_retention.py) -- not related to this fix. Closing as fixed by #267.
Mark closed this issue 2026-08-04 21:08:49 +00:00
Author
Owner

Re-opened: false-positive close confirmed. Issue was closed but no fix commit exists on master. Re-adding triage-approved to route back through the pipeline.

Re-opened: false-positive close confirmed. Issue was closed but no fix commit exists on master. Re-adding triage-approved to route back through the pipeline.
Author
Owner

QA PASS (2026-08-08, kanban t_f8c449a0): fix verified on clean origin/master (3dd9456).
The 2026-08-08 reopen was a false positive: fix commit IS on master. PR #267 (fix #258: add migration 0002 to add embedding column to agents table) merged as 18946b07ac (commit 3e49e412c0); migration add_embedding_to_agents present in substrate/ledger/migrations.py (version 0002, ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '').
Test verification: test_ledger.py::TestReputation::test_reputation_update_success PASS, test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column PASS; full ledger/embedding unit suite 97 passed. Closing.

QA PASS (2026-08-08, kanban t_f8c449a0): fix verified on clean origin/master (3dd9456). The 2026-08-08 reopen was a false positive: fix commit IS on master. PR #267 (fix #258: add migration 0002 to add embedding column to agents table) merged as 18946b07ac85 (commit 3e49e412c09f); migration `add_embedding_to_agents` present in substrate/ledger/migrations.py (version 0002, ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT ''). Test verification: `test_ledger.py::TestReputation::test_reputation_update_success` PASS, `test_embedding_ledger.py::TestLedgerEmbeddingSchema::test_agents_table_has_embedding_column` PASS; full ledger/embedding unit suite 97 passed. Closing.
Mark 2026-08-08 09:19:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/mesh-seed#260
No description provided.