fix(agent): aggregate the PostgreSQL grounding column read per table (B52) - #537
Open
koraysrn wants to merge 2 commits into
Open
fix(agent): aggregate the PostgreSQL grounding column read per table (B52)#537koraysrn wants to merge 2 commits into
koraysrn wants to merge 2 commits into
Conversation
…(B52) The composed column capture projected one row per column, so a stock image's own wide catalog exceeded maxResultRows: 200 and the run grounded with no inventory on TimescaleDB, Cloudberry and AlloyDB Omni. Aggregate the columns per table so the projection is one row per object, symmetric with SQLite, and parse the aggregated array in buildPostgresTables. Live-verified on the compat images: TimescaleDB 385→46 rows, Cloudberry 479→67, AlloyDB Omni 542→70 (69 as a least-privilege role).
B52's backlog entry was deleted when the fix landed; the new B76 entry and the compat table still cited it. Reword so no citation outlives its entry, and update the TimescaleDB/Cloudberry/AlloyDB compat rows to the post-fix behaviour.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The composed PostgreSQL grounding capture (
composePostgresCatalog()) projected one row per column. AgainstmaxResultRows: 200, a stock image's own wide catalog refused the read before the user created anything — measured on TimescaleDB, Cloudberry and AlloyDB Omni and recorded as B52.This change aggregates the columns per table with
json_agg(json_build_object(...) ORDER BY ordinal_position)+GROUP BY table_schema, table_name, so the projection is one row per object, symmetric with the SQLite side.buildPostgresTables()now parses the aggregatedcolumnsarray through a newparsePostgresColumns()that accepts both thepg-parsed array and a JSON-string transport form, and returns an empty list for malformed values rather than losing the snapshot.Why
On those images the agent was unusable out of the box: the grounding capture was refused and every plan run answered ungrounded.
Live verification (compat profile)
latest-pg17All under the 200-row budget, and the user's tables are named in every capture. Column order is preserved (
id→customer_id→total), and the privilege model is unchanged — a least-privilege role aggregates exactly what it is allowed to see.Notes
maxResultBytes, 256 KB) remains the payload backstop; an extreme single-table column count would be refused by bytes rather than rows. Documented oncomposePostgresCatalog.ai.*/google_db_advisor_*views beside its 2 user tables) — not a privilege leak, but grounding noise to address separately.docs/BACKLOG.mdanddocs/AGENT.md; thecompatibility.tscaveats for the three servers updated to match.Verification
bun run typecheck— passbun run lint— 0 errorsbun run knip— passbun run build— passcomposed-sql.test.ts(79),context-snapshot.test.ts(98, incl. wide-catalog simulation + malformed/string/wide-table robustness),backlog-structure.test.ts(93),compatibility.test.ts,plan-grounding.test.ts,types.test.ts.