test_reputation_update_success IndexError: agents table missing 'embedding' column #258

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

Finding

The test_reputation_update_success ledger test raises an IndexError when reading the embedding field from the agents table during a reputation update.

Root cause: The Agent model has an embedding field, but the initial migration (0001) that creates the agents table does not include an embedding column, and no subsequent migration adds it. This is a schema drift regression — the model and the database schema are out of sync.

Kanban card

This finding originated from post-deploy probe kanban card t_15f9a08d (mesh-seed #45 fix verification).

Steps to Reproduce

  1. Run the ledger test suite: test_reputation_update_success
  2. Observe IndexError when the test tries to read embedding from the agents table row
  3. Check the agents table schema (migration 0001) — no embedding column exists
  4. Check the Agent model definition — embedding field is defined but no migration adds it

Expected Behavior

The agents table should have an embedding column matching the Agent model definition, and test_reputation_update_success should pass.

Actual Behavior

IndexError at runtime because the column doesn't exist in the database schema.

## Finding The `test_reputation_update_success` ledger test raises an `IndexError` when reading the `embedding` field from the agents table during a reputation update. **Root cause**: The `Agent` model has an `embedding` field, but the initial migration (0001) that creates the `agents` table does **not** include an `embedding` column, and no subsequent migration adds it. This is a schema drift regression — the model and the database schema are out of sync. ## Kanban card This finding originated from post-deploy probe kanban card `t_15f9a08d` (mesh-seed #45 fix verification). ## Steps to Reproduce 1. Run the ledger test suite: `test_reputation_update_success` 2. Observe `IndexError` when the test tries to read `embedding` from the agents table row 3. Check the agents table schema (migration 0001) — no `embedding` column exists 4. Check the `Agent` model definition — `embedding` field is defined but no migration adds it ## Expected Behavior The `agents` table should have an `embedding` column matching the `Agent` model definition, and `test_reputation_update_success` should pass. ## Actual Behavior `IndexError` at runtime because the column doesn't exist in the database schema.
Author
Owner

Reopened by kanban QA card t_50a34bdb.

The bug is still present on master HEAD (commit 92521ce9). The test tests/unit/test_ledger.py::TestReputation::test_reputation_update_success still fails with the exact IndexError from the issue title:

substrate/ledger/core.py:4506: in __getitem__
    embedding=row["embedding"],
              ^^^^^^^^^^^^^^^^
E   IndexError: No item with that key

The agents table schema in substrate/ledger/migrations.py:157-169 does not include an embedding column, and git log --all --grep=#258 returns zero commits. The fixit card t_2d5cb56b was auto-resolved by janitor after 121h of preflight-lint-failed block, but no fix commit ever landed. The issue was closed without a PR or commit; reopening to restore accurate state.

Reopened by kanban QA card t_50a34bdb. The bug is still present on master HEAD (commit 92521ce9). The test `tests/unit/test_ledger.py::TestReputation::test_reputation_update_success` still fails with the exact IndexError from the issue title: ``` substrate/ledger/core.py:4506: in __getitem__ embedding=row["embedding"], ^^^^^^^^^^^^^^^^ E IndexError: No item with that key ``` The `agents` table schema in `substrate/ledger/migrations.py:157-169` does not include an `embedding` column, and `git log --all --grep=#258` returns zero commits. The fixit card t_2d5cb56b was auto-resolved by janitor after 121h of preflight-lint-failed block, but no fix commit ever landed. The issue was closed without a PR or commit; reopening to restore accurate state.
Author
Owner

Reopened by QA — false-close detection.

The fix for this issue never landed on master. The agents table in substrate/ledger/migrations.py:157-169 does not include an embedding column, but the Agent model (models.py:24) has embedding: str = "" and AgentView.__getitem__ (core.py:4506) reads row["embedding"], causing the IndexError.

Test still fails on master HEAD (92521ce):

pytest tests/unit/test_ledger.py -k test_reputation_update_success
IndexError: No item with that key

Fix needed: Add migration 0002 with ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '[]' to substrate/ledger/migrations.py.

**Reopened by QA — false-close detection.** The fix for this issue never landed on master. The `agents` table in `substrate/ledger/migrations.py:157-169` does not include an `embedding` column, but the `Agent` model (models.py:24) has `embedding: str = ""` and `AgentView.__getitem__` (core.py:4506) reads `row["embedding"]`, causing the IndexError. Test still fails on master HEAD (92521ce): ``` pytest tests/unit/test_ledger.py -k test_reputation_update_success IndexError: No item with that key ``` **Fix needed:** Add migration 0002 with `ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '[]'` to `substrate/ledger/migrations.py`.
Author
Owner

Fix landed in PR #267 (commit 3e49e41). Migration 0002 adds ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT . All 23 ledger tests pass, ruff lint clean.

Fix landed in PR #267 (commit 3e49e41). Migration 0002 adds ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT . All 23 ledger tests pass, ruff lint clean.
Author
Owner

QA verification (2026-08-04): Bug confirmed on master, fix in PR #267 (commit 3e49e41) not merged. Reopening for PR merge.

QA verification (2026-08-04): Bug confirmed on master, fix in PR #267 (commit 3e49e41) not merged. Reopening for PR merge.
Author
Owner

QA Verification — 2026-08-04

Bug confirmed on master HEAD (92521ce):

tests/unit/test_ledger.py::TestReputation::test_reputation_update_success FAILED
substrate/ledger/core.py:4506: IndexError: No item with that key

Fix verified on branch fix/mesh-seed-258-embedding-column (PR #267, commit 3e49e41):

tests/unit/test_ledger.py: 23/23 passed
ruff check: clean

Migration 0002 adds ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT ''; — matches the Agent model definition and resolves the AgentView.__getitem__ IndexError.

Status: Fix is correct and complete. PR #267 is open, awaiting merge.

## QA Verification — 2026-08-04 **Bug confirmed on master HEAD (92521ce):** ``` tests/unit/test_ledger.py::TestReputation::test_reputation_update_success FAILED substrate/ledger/core.py:4506: IndexError: No item with that key ``` **Fix verified on branch `fix/mesh-seed-258-embedding-column` (PR #267, commit 3e49e41):** ``` tests/unit/test_ledger.py: 23/23 passed ruff check: clean ``` Migration 0002 adds `ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '';` — matches the `Agent` model definition and resolves the `AgentView.__getitem__` IndexError. **Status:** Fix is correct and complete. PR #267 is open, awaiting merge.
Mark closed this issue 2026-08-04 20:59:51 +00:00
Author
Owner

QA Verification — 2026-08-04

Bug confirmed on master (92521ce):

tests/unit/test_ledger.py::TestReputation::test_reputation_update_success FAILED
substrate/ledger/core.py:4506: IndexError: No item with that key

Fix verified on fix/mesh-seed-258-embedding-column (PR #267, commit 3e49e41):

  • Migration 0002: ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '';
  • All 23 ledger tests pass on fix branch
  • PR #267 merged to master (commit 18946b0)

Post-merge verification on master:

  • Test passes on clean master
  • Issue closed.
## QA Verification — 2026-08-04 **Bug confirmed on master (92521ce):** ``` tests/unit/test_ledger.py::TestReputation::test_reputation_update_success FAILED substrate/ledger/core.py:4506: IndexError: No item with that key ``` **Fix verified on `fix/mesh-seed-258-embedding-column` (PR #267, commit 3e49e41):** - Migration 0002: `ALTER TABLE agents ADD COLUMN embedding TEXT DEFAULT '';` - All 23 ledger tests pass on fix branch - PR #267 merged to master (commit 18946b0) **Post-merge verification on master:** - Test passes on clean master - Issue closed.
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#258
No description provided.