feat(engine): decode only the columns a query reads, after the gates (P53) #278
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #278"
general
weight: 0.35
abendrothj
What and why
Plan item P53 (
docs/V1_PLAN.md). Closes #247.register_parquet_manydecoded every column of every object into aMemTablebeforesql()planned or gated the query. So a query that the plan gate or the count-column check refused had already decoded the whole dataset into Arrow memory, which is not zeroized, and an accepted query decoded columns it never read. A schema mismatch between objects also came out ofMemTable::try_newasQueryError::Execution, a 400 that blamed the caller's SQL for a storage fault.register_parquet_manyandregister_parquet_declaredkeep their signatures and register a smallTableProvider,ParquetTable, instead of aMemTable. It parses each object's footer from itswiped_copybuffer, without the column statistics (their minimum and maximum are values from the data), and keeps the buffer to decode from. Objects whose columns differ (names, types or nullability, in order) are refused asQueryError::Parquet(ParquetStage::Schema): 502, never 400. The declared schema and row cap (ADR 0012) and the row limit are still checked at registration, from the footers. The query service then zeroizes its own decrypted copies, since the scope keeps its own until it drops.ParquetTable::scandecodes, from every object, only the projected root columns (ParquetRecordBatchReaderBuilder::with_projection(ProjectionMask::roots(..))) into aMemorySourceConfigplan that is dropped with the query. DataFusion callsscanwhile it builds the physical plan from the final logical plan, whichsql()does only after the read-only check, the plan allowlist, the count-column check and the runtime-failure check. So a refused query decodes nothing, and the projection is that of the plan that runs, after any rewrite (P58). The engine copies no plaintext into non-zeroizing memory beyond the decoded Arrow arrays.QUERY_MAX_DECODED_ROWSandQUERY_MAX_DECODED_MIB. Eachsql()call carries its ownDecodeBudgetin its session config. Decoded rows are counted again against the declared row cap and each footer's count.ScanFault) and comes back asQueryError::Parquet,LimitExceededorDeclarationMismatch, neverQueryError::Execution(400).map_query_erroronly gains a comment.docs/ARCHITECTURE.md: the query diagram; "QueryScopememory hygiene", which now says decryption stays whole-object because each object is one HPKE envelope, so projection reduces decode work, not decrypt work; "Resource limits"; "The snapshot as written"; the research diagram.docs/THREAT_MODEL.md: the resource-limit residual's wording on decode limits, and "Unzeroized working memory" now names the Parquet decoder's internal buffers. ADR 0013's decode rows and gated-mode sentence;docs/PROJECT_SCOPE.md; theQueryLimitsdocs;backend/.env.example;CHANGELOG.md(Security).Changes to existing behaviour: objects of one snapshot whose columns differ answer 502 instead of 400. A query over a few columns of a dataset whose whole decoded size passes
QUERY_MAX_DECODED_MIBnow runs, while a query that reads its table twice (a self-join) counts it twice. A byte-limit refusal now comes when the query runs, not at registration.ExecutionStage::Prepareis gone (after the read-only check,sql()builds the DataFrame itself, asexecute_logical_plandid for a query), andParquetStagegainsSchema.For reviewers:
scan, as the issue specifies, not batches streamed fromexecute. Each scan's decoded columns live as long as the query's plan, as theMemTableheld the whole table before.EXPLAINin ungated mode decodes. It builds the physical plan, so its scans decode, within the budget. A scan failure there shows up as aphysical_plan_errorrow holding the fault's fixed message, not as an error. Gated mode refusesEXPLAINat the plan gate.mainis merged in (a80f815, whose tree equalsmain's), not rebased. The branch started from #243's commits before it merged, whichmainnow carries.docs/BENCHMARKS.md, "Still to come"), so no numbers are recorded here. In the wide-table test, the two-column aggregate reads 204 KB of the 4.3 MB its footers report.quackxide-engine/src/,platform-api/src/,docs/THREAT_MODEL.mdanddocs/adr/are owned; AxolDad is an owner of all four.How it was tested
New tests:
quackxide-engine/tests/decode.rs. Its seam is a copy of a dataset with column chunks overwritten and its footer intact, so decoding an overwritten chunk fails:-
a_query_the_gates_refuse_decodes_no_column: over a copy with every chunk overwritten, row egress and a join (plan gate), a missingnandMAX(age) AS n(count-column check), a cast that can fail (ADR 0011) andSETeach get their own refusal, so nothing was decoded. An accepted query that reads columns fails to decode them, andCOUNT(*) AS n, which reads none, answers.-
a_two_column_aggregate_on_the_wide_table_decodes_only_those_columns: onsynth-data's wide table (23 columns, 20,000 rows), an aggregate overregionandi00matches the intact table over a copy whose other 21 columns are overwritten, and reading any other column fails. Withmax_decoded_bytesat exactly those two columns' footer bytes the query passes; one byte less is refused before decoding.-
a_corrupt_data_page_is_a_parquet_failure_not_the_callers_sql: a valid footer and corrupt data pages inage(its dictionary page intact) fail asQueryError::Parquet, gated and ungated; queries over the other columns answer.quackxide-engineunit tests:-
every_scan_of_a_query_counts_toward_the_decode_limits: a self-join is refused one row or one byte under twice the table, the single scan runs twice on one scope, and both scans fit at exactly twice;-
objects_with_unlike_columns_are_refused_as_a_parquet_failure: a renamed column, a nullability change and an extra column;-
the_table_formats_and_keeps_no_values_from_the_data: the table'sDebugand its parsed footer hold no value from the data, and the footer has no column statistics;-
dropping_the_scope_releases_its_tables: after a query, the table, with the engine's copy it holds (zeroized on drop, by type), is released with the scope;-
decode_limits_refuse_a_compressible_dataset_from_its_footer(P52's) now expects the byte refusal from the query, where that check moved.platform-api/tests/query_api.rs:a_stored_object_with_a_corrupt_data_page_is_502(in both modes; intact columns still answer, and a gate refusal is still 422) anda_snapshot_whose_objects_have_unlike_columns_is_502.tests/bypass.rs,tests/disclosure.rs,tests/engine_query.rs,decrypted_objects_zeroize_on_dropanddecryption_failure_midway_fails_closed_and_releases_the_slotpass unchanged, as do P52's limit tests.Checklist
scripts/check.shpasses locally (its secret-scan step was skipped: gitleaks is not installed locally)SECURITY_AUDIT_EVENTcovered byaudit_coverage.rs(no new kind or outcome: these keepengine.query"denied" and "failed")docs/DATA_POLICY.md): test data is generated in the testsCHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made (none was; ADR 0013's decode rows are updated)