feat(grading): support in-memory PGlite backend for grading endpoints - #19
Conversation
There was a problem hiding this comment.
Pull request overview
Enables the SQL assessment service grading endpoints to run end-to-end against an in-process PGlite database by routing query execution through a shared pgliteInstances registry and a backend-agnostic RowQueryFn, rather than requiring a TypeORM DataSource (external Postgres).
Changes:
- Introduces
RowQueryFn+makePGliteRowQueryFnand refactors grading comparators/services to execute queries via this backend-agnostic function. - Updates
GradingControllerto resolve either Postgres or PGlite connections and to use a unifiedcleanuphook (no-op for shared PGlite). - Adds unit/integration tests and extends the smoke test script to cover grading endpoints on PGlite; removes the deprecated
GRADING_PGLITE_NOT_SUPPORTEDmessage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| services/sql-assessment-service/src/shared/utils/database-utils.ts | Adds RowQueryFn abstraction plus makePGliteRowQueryFn and PGlite key generation. |
| services/sql-assessment-service/src/grading/result-set-comparator.ts | Refactors result-set comparison/executability checks to use RowQueryFn and normalizes DB error extraction. |
| services/sql-assessment-service/src/grading/query-grading-service.ts | Threads RowQueryFn through the grading pipeline instead of a DataSource. |
| services/sql-assessment-service/src/grading/comparators/execution-plan-comparator.ts | Refactors EXPLAIN plan retrieval to execute via RowQueryFn. |
| services/sql-assessment-service/src/grading/grading-controller.ts | Adds PGlite backend resolution, shared-instance handling, and unified cleanup across endpoints. |
| services/sql-assessment-service/src/shared/i18n/messages.ts | Removes GRADING_PGLITE_NOT_SUPPORTED message key and translations. |
| services/sql-assessment-service/test/shared/pglite-row-query-fn.test.ts | Adds unit tests for PGlite RowQueryFn shape invariants and comparator integration. |
| services/sql-assessment-service/test/grading/pglite-grading-controller.test.ts | Adds integration tests for grading + compare endpoints backed by PGlite. |
| services/sql-assessment-service/scripts/smoke-test.sh | Adds smoke coverage for grading endpoints on PGlite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plc-dev
left a comment
There was a problem hiding this comment.
Other than the type issue I would say this is fine to merge. So not necessarily a change request, rather a request to confirm the types are synced and only if they are not synced, a change to synchronize the types is required.
Grading endpoints previously rejected PGlite connections with a 400
GRADING_PGLITE_NOT_SUPPORTED because the comparators were hard-wired to
a TypeORM DataSource. Route PGlite connections through the shared
pgliteInstances registry so /grade and /compare/* run end-to-end without
an external PostgreSQL server.