fix(agentsview): skip schema DDL for compatible pg push#888
Conversation
- Use read-only schema checks before DDL. - Skip schema and index maintenance for compatible PostgreSQL schemas. - Fall back to EnsureSchema() when the schema is missing or incompatible. - Add unit coverage for the new path. Closes kenn-io#887 Signed-off-by: Martin Wimpress <code@wimpress.io>
roborev: Combined Review (
|
The compatible-schema fast path returned before EnsureSchema, so it skipped the non-DDL data repairs that keep is_automated and token coverage flags correct on existing rows. Run those repairs on the fast path while still skipping the index and column DDL that blocks pg serve reads (kenn-io#887). The repairs issue only row-level writes and stay gated by schemaDone, so they run at most once per push process. Signed-off-by: Martin Wimpress <code@wimpress.io>
roborev: Combined Review (
|
The compatible-schema fast path skipped EnsureSchema based on CheckSchemaCompat, which never probes model_pricing and treats cursor_usage_events as optional. Push queries model_pricing and writes cursor_usage_events, so an older schema missing those tables passed the probe and then failed the push instead of migrating. Gate the fast path on pushSchemaCurrent, which also requires both push-written tables, and fall back to EnsureSchema when either is absent. Signed-off-by: Martin Wimpress <code@wimpress.io>
roborev: Combined Review (
|
bulkInsertCursorUsageEvents dedups via a targetless ON CONFLICT DO NOTHING, which only suppresses duplicates when the partial unique index idx_cursor_usage_events_dedup exists. The compatible-schema fast path checked tables but not that index, so a schema missing it would silently duplicate cursor usage rows on repeated pushes. Gate pushSchemaCurrent on the index too and fall back to EnsureSchema when it is absent. Signed-off-by: Martin Wimpress <code@wimpress.io>
roborev: Combined Review (
|
CheckSchemaCompat gates both pg serve read-only startup and the push fast path, but it probed sync_metadata and sessions.owner_marker, which only push uses. A read-only serve role or legacy schema that was fine for reads then failed compatibility at startup. Move those two probes into a new checkPushSchemaCompat that pushSchemaCurrent runs, leaving CheckSchemaCompat limited to read-path schema Signed-off-by: Martin Wimpress <code@wimpress.io>
roborev: Combined Review (
|
|
thank you! |
Closes #887