Repository navigation
Description
Summary
agent_sync_state.git_dir_bytes is declared as a plain Integer for the PostgreSQL backend (src/backend/db/tables.py and Alembic revision 0019_agent_sync_state_git_dir_bytes, which adds INTEGER). On PostgreSQL that is a 32-bit column, so any agent whose workspace .git exceeds 2,147,483,647 bytes (2 GiB) makes the sync-state upsert fail with psycopg2.errors.NumericValueOutOfRange: integer out of range. SQLite is unaffected (its INTEGER is 64-bit), which is why the default backend never shows it.
Context
Found during the 2026-09-14 pre-release run of dev (eb41896, 0.9.5-rc3) by running the unit tier against a disposable PostgreSQL. tests/unit/test_1596_git_sync_observability.py writes 44 GiB and both of its [postgres] legs fail:
TestGitBloatAlerts.test_size_crossing_emits_once[postgres]TestGitDirBytesRoundTrip.test_upsert_and_read_git_dir_bytes[postgres]
The defect has been present since the column was added on 2026-07-14 (#1596). CI never sees it: the schema-parity PostgreSQL tier runs only -m requires_postgres, and this test's Postgres leg comes from the db_backend parametrization in tests/db_harness.py, which is not marked. The whole point of git_dir_bytes is to observe bloat (#1596), so the values it exists to record are exactly the ones that overflow.
Acceptance Criteria
-
git_dir_bytesis a 64-bit integer on PostgreSQL:BigIntegerinsrc/backend/db/tables.py, and a new Alembic revision that runsALTER TABLE agent_sync_state ALTER COLUMN git_dir_bytes TYPE BIGINT(dual-track, Invariant Fix git pushing bug #9: the SQLite migration entry is a recorded no-op since SQLite INTEGER is already 64-bit;src/backend/db/schema.pyDDL stays consistent). -
tests/unit/test_1596_git_sync_observability.pypasses on both backends withTEST_POSTGRES_URLset. - The Alembic single-head guard (
scripts/ci/check_alembic_heads.py) still reports one head. - Either the affected tests are marked
requires_postgresso theschema-parityPostgreSQL tier runs them, or the tier's selection is widened, so this class cannot regress silently again.
Technical Notes
- Related: bug: git-sync agent workspaces grow unboundedly — auto-committed data churn bloats .git (44GB observed on one agent) #1596 (column origin), feat(db): adopt Alembic for PostgreSQL migrations (retire SQLite-only bespoke runner) #1183 / Invariant Fix git pushing bug #9 (dual-track migrations), bug: watchdog cannot close an execution stale >24.8 days — fabricated duration_ms overflows PostgreSQL INTEGER, and the sweep then fails every cycle forever #2434 (the PostgreSQL pytest tier and its
-m requires_postgresselection). - Audit the other
Integerbyte-count columns intables.pyfor the same class while here (anything that stores sizes in bytes should beBigIntegeron PG).
Activity
fix(db): #2800 rebuild refuses to drop a column it does not name
docs(learnings): #2800 — Integer is int4 on PostgreSQL; growth column…
fix(db): #2800 rides dev's Alembic head, and the SQLite track carries…
fix(db): coerce every agent_sync_state integer at its own column's ce…
fix(db): agent_sync_state ints are bounded at their own column's ceil…