Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

fix(checkpointer): use TEXT for MySQL cubepi_threads.run_id

xf gong4509919c4a12
diff --git a/cubepi/checkpointer/mysql/alembic_helpers.py b/cubepi/checkpointer/mysql/alembic_helpers.py
index b18ea9b..31e2967 100644
--- a/cubepi/checkpointer/mysql/alembic_helpers.py
+++ b/cubepi/checkpointer/mysql/alembic_helpers.py
@@ -38,7 +38,10 @@ def add_run_id_column_op() -> str:
alembic migration if idempotence is required. Hosts must also bump
`cubepi_schema_version` via write_schema_version_op() (EXPECTED_SCHEMA_VERSION
is now 3)."""
- return "ALTER TABLE cubepi_threads ADD COLUMN run_id VARCHAR(64) NULL"
+ # TEXT (unbounded) matches the Postgres/SQLite TEXT column type and
+ # avoids silent truncation / strict-mode failure when a host supplies
+ # a run_id longer than 64 chars (e.g. opaque UUIDs with prefixes).
+ return "ALTER TABLE cubepi_threads ADD COLUMN run_id TEXT NULL"
def write_schema_version_op() -> str:
diff --git a/cubepi/checkpointer/mysql/models.py b/cubepi/checkpointer/mysql/models.py
index eab9e5c..9393b9e 100644
--- a/cubepi/checkpointer/mysql/models.py
+++ b/cubepi/checkpointer/mysql/models.py
@@ -13,7 +13,7 @@ import datetime as _dt
from typing import Any
import sqlalchemy as sa
-from sqlalchemy.dialects.mysql import JSON, LONGBLOB, VARCHAR
+from sqlalchemy.dialects.mysql import JSON, LONGBLOB, TEXT, VARCHAR
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
EXPECTED_SCHEMA_VERSION = 3
@@ -50,8 +50,12 @@ class CubepiThread(CubepiBase):
)
# v3: host-side run identifier persisted alongside pending_request. See
# the parallel docstring on cubepi/checkpointer/postgres/models.py.
+ # TEXT (unbounded) keeps parity with Postgres/SQLite — hosts may use
+ # opaque ids longer than 64 chars; a length cap here would silently
+ # break recovery under strict mode or truncate it in non-strict mode.
+ # run_id is not indexed so MySQL's TEXT-indexing restrictions don't bite.
run_id: Mapped[str | None] = mapped_column(
- VARCHAR(64),
+ TEXT(),
nullable=True,
)
created_at: Mapped[_dt.datetime] = mapped_column(