Repository navigation
Description
Summary
agent_sync_state.git_dir_bytes is declared INTEGER on the PostgreSQL track, but it stores an agent's .git directory size in bytes. PostgreSQL INTEGER is 32-bit (max 2,147,483,647 ≈ 2 GiB), while the git-bloat alert threshold GIT_DIR_ALERT_BYTES defaults to 10 GiB (10,737,418,240) — 5× beyond what the column can hold.
The consequence is worse than a truncated metric: the value is written as part of the agent_sync_state upsert, so on PostgreSQL any agent whose .git exceeds ~2 GiB makes the whole statement raise psycopg2.errors.NumericValueOutOfRange and the sync-health row never lands. The #1595/#1596 bloat detection is therefore inoperable exactly in the regime it exists to detect — the architecture notes record 44 GB / 97%-garbage repos as the motivating incident.
SQLite is unaffected (dynamic typing, 64-bit ints), which is why this only surfaces in the PostgreSQL tier and has been invisible in ordinary local runs.
Context
Found by a full-suite run on dev (691e7dc9). The PostgreSQL tier reported 15 failures, 30 of them NumericValueOutOfRange. Failing test:
tests/unit/test_1595_sync_health_signals.py::TestGitBloatAlerts::test_size_crossing_emits_once[postgres]
It writes GIT_DIR_ALERT_BYTES ± 1 — both far past int32 — and the upsert raises.
Sources:
src/backend/db/tables.py:736—Column("git_dir_bytes", Integer)src/backend/migrations/versions/0019_agent_sync_state_git_dir_bytes.py—ADD COLUMN IF NOT EXISTS git_dir_bytes INTEGERsrc/backend/services/sync_health_service.py:38—GIT_DIR_ALERT_BYTES = int(os.getenv("GIT_DIR_ALERT_BYTES", str(10 * 1024**3)))
Sibling: duration_ms
The same int32 ceiling applies to duration_ms (Integer in schedule_executions, agent_loop_runs, agent_activities, voip_call_logs), which overflows past ~24.8 days of elapsed milliseconds. Nine further PostgreSQL failures in tests/unit/test_1771c_schedules_cas_edges.py hit it, though partly through their own fixed started_at="2026-01-01…" (tracked separately as a calendar-expiring test).
Production reachability for duration_ms is a narrower tail than git_dir_bytes — it needs a running row to survive the 5-minute watchdog for >24.8 days (a long backend outage, then the recovery sweep terminal-writes it) — but it is the same column class and cheap to fix in the same pass.
Acceptance Criteria
-
agent_sync_state.git_dir_bytesisBIGINTon the PostgreSQL track (new Alembic revision) andBigIntegerindb/tables.py - A
.gitsize of 10 GiB+ round-trips through the sync-health upsert on PostgreSQL without raising - The edge-triggered
git_bloatoperator-queue alert fires on PostgreSQL at the 10 GiB threshold, same as on SQLite -
test_1595_sync_health_signals.py::TestGitBloatAlertspasses in thepostgrestier -
duration_msis widened toBIGINT/BigIntegerin the same pass (all four tables), or explicitly deferred with a note saying why - Dual-track parity holds: the SQLite DDL in
db/schema.py/db/tables.pyand the new Alembic revision agree (Invariant Feature/vector log retention #3), andschema-parityCI is green - The Alembic version-line still resolves to exactly one head
Technical Notes
- SQLite needs no data migration — its column is already effectively 64-bit; only the declared type in the shared MetaData and the PG DDL move.
ALTER TABLE … ALTER COLUMN … TYPE BIGINTon PostgreSQL rewrites the table;agent_sync_stateis one row per git-enabled agent, so this is small.schedule_executionsis the large one — size theduration_mshalf accordingly, or split it into its own revision.- Reads coerce agent-supplied ints at the boundary already (the
/health clone_statusconvention), so no read-path change is expected.
Activity
vybe commentedon Aug 17, 2026
/claim
github-actions commentedon Aug 17, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/2240-<short-slug>Fixes #2240vybe commentedon Sep 17, 2026
Release hygiene (v0.9.5 cut): fixed by #2805 (
git_dir_bytes→ BIGINT, Alembic 0063, tracked as #2800) → moving tostatus-in-devso this closes with the v0.9.5 release.