Skip to content

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

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

xf gong1686eed192a0
diff --git a/cubepi/checkpointer/mysql/alembic_helpers.py b/cubepi/checkpointer/mysql/alembic_helpers.py
index 31e2967..ef33894 100644
--- a/cubepi/checkpointer/mysql/alembic_helpers.py
+++ b/cubepi/checkpointer/mysql/alembic_helpers.py
@@ -38,10 +38,11 @@ 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)."""
- # 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"
+ # VARCHAR(64) accommodates UUIDs (36) and prefixed-UUID conventions.
+ # Hosts needing longer run_ids should subclass MySQLCheckpointer and
+ # override the column rather than have cubepi pay the TEXT cost
+ # globally.
+ return "ALTER TABLE cubepi_threads ADD COLUMN run_id VARCHAR(64) NULL"
def write_schema_version_op() -> str:
diff --git a/cubepi/checkpointer/mysql/models.py b/cubepi/checkpointer/mysql/models.py
index 9393b9e..2fc3462 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, TEXT, VARCHAR
+from sqlalchemy.dialects.mysql import JSON, LONGBLOB, VARCHAR
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
EXPECTED_SCHEMA_VERSION = 3
@@ -50,12 +50,13 @@ 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.
+ # VARCHAR(64) accommodates UUIDs (36), prefixed UUIDs (e.g. "run_<uuid>"),
+ # and typical opaque ids. Hosts that need longer identifiers should
+ # subclass MySQLCheckpointer and override the column type — cubepi
+ # doesn't pay the TEXT-column cost for everyone to accommodate a
+ # minority case.
run_id: Mapped[str | None] = mapped_column(
- TEXT(),
+ VARCHAR(64),
nullable=True,
)
created_at: Mapped[_dt.datetime] = mapped_column(