> **Plain-language companion:** [v0.54.0.md](v0.54.0.md) ## v0.54.0 — DVM Engine Hardening **Status: Released.** Derived from [ROADMAP.md](../ROADMAP.md) and [plans/PLAN_OVERALL_ASSESSMENT_11.md](../plans/PLAN_OVERALL_ASSESSMENT_11.md). > **Release Theme** > Harden the DVM engine against pathological queries, OOM conditions, and > slow catalog lookups. Seven targeted correctness and performance improvements > with no user-visible API surface changes. --- ### Correctness | ID | Title | Effort | Priority | |-----|-------|--------|----------| | C-7 | diff_node() depth limit: enforce max_parse_depth GUC, return DiffDepthExceeded | 0.5d | HIGH | | C-4 | ST source frontier validation in generate_delta_query() | 0.5d | HIGH | ### Resilience | ID | Title | Effort | Priority | |-----|-------|--------|----------| | R-7 | DiffContext CTE cap: max_diff_ctes GUC, return DiffCteCountExceeded | 0.5d | HIGH | ### Performance | ID | Title | Effort | Priority | |-----|-------|--------|----------| | P-4 | Snapshot fingerprint two-level cache (pointer identity + structural hash) | 0.5d | MEDIUM | | P-5 | Expr::to_sql() visitor pattern — write directly into pre-allocated buffer | 0.5d | MEDIUM | | P-6 | View-inlining relkind cache — batch catalog lookups per rewrite pass | 0.5d | MEDIUM | ### Scalability | ID | Title | Effort | Priority | |-----|-------|--------|----------| | S-1 | O(V+E) diamond detection using precomputed ancestor sets | 0.5d | MEDIUM | --- ### Recommended Implementation Order | Phase | Items | Description | |-------|-------|-------------| | Phase 1 | C-7, R-7 | Safety guards — depth limit and CTE cap | | Phase 2 | C-4 | Correctness — frontier validation | | Phase 3 | P-4, P-5, P-6 | Performance — caches and visitor pattern | | Phase 4 | S-1 | Scalability — O(V+E) diamond detection | --- ### Implementation Status | ID | Title | Status | |-----|-------|--------| | C-7 | diff_node() recursion depth limit | ✅ Done | | R-7 | DiffContext CTE count cap (OOM guard) | ✅ Done | | C-4 | ST source frontier validation | ✅ Done | | P-4 | Snapshot fingerprint two-level cache | ✅ Done | | P-5 | Expr::to_sql() visitor pattern | ✅ Done | | P-6 | View-inlining relkind cache | ✅ Done | | S-1 | O(V+E) diamond detection | ✅ Done | --- ### Files Changed | File | Change | |------|--------| | `src/error.rs` | Added `DiffDepthExceeded(usize)`, `DiffCteCountExceeded(usize)`, `StSourceFrontierMissing(i64)` | | `src/config.rs` | Added `PGS_MAX_DIFF_CTES` GUC and `pg_trickle_max_diff_ctes()` accessor | | `src/dvm/diff.rs` | Added depth tracking, CTE cap, snapshot fingerprint cache to `DiffContext` | | `src/dvm/mod.rs` | Added ST source frontier validation in `generate_delta_query()` | | `src/dvm/parser/types.rs` | `Expr::to_sql_into()` visitor method, `to_sql()` delegates to it | | `src/dvm/parser/rewrites.rs` | Relkind cache threaded through `rewrite_views_inline_once()` call chain | | `src/dag.rs` | `compute_all_ancestors()` O(V+E) helper, `detect_diamonds()` uses it | | `src/api/mod.rs` | Added match arms for three new error variants in `raise_error_with_context()` | --- ### Exit Criteria - [x] All items ✅ Done - [x] `just test-unit` passes (2197 tests, 0 failed) - [x] `just lint` exits 0 with zero warnings - [x] CHANGELOG.md entry written - [x] ROADMAP.md v0.54.0 row marked ✅ Released