feat(api): add the steward dataset upload route (P38) #210
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
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 #210"
general
weight: 0.35
abendrothj
What and why
Steward dataset upload: plan item P38 (
docs/V1_PLAN.md), the "Upload" step of the dataset lifecycle indocs/PROJECT_SCOPE.md, towards definition-of-done item 1. Until now, research datasets could arrive only through connector syncs. With this change a steward uploads one from the browser, and a granted researcher queries it through the same grant, budget and disclosure gates.PUT /api/v1/datasets/{dataset}stores Parquet that the steward's browser sealed (steward-upload-v1|{tenant}|{dataset}|{object}), together with the snapshot manifest the browser also sealed. They become the dataset's new ADR 0003 snapshot: the object, then a plaintext record, then the manifest as the commit, then pruning of everything the new snapshot does not list. The tenant comes only from the token, and the route needs no query service. The body format and its parser are inplatform_connectors::upload.upload_prefix, which no connector may use. Grants, listings, requests and SQL work unchanged (FROM upload_cohorts).infobinding of its dataset's kind. The record is read before any key is released, and must name a suite this build reads. An upload's Parquet must match its declared schema and row cap, or the query fails withQueryError::DeclarationMismatch(502).publish_listingrefuses a dataset the steward does not hold, meaning one with no committed snapshot. It returns 404 and emits aresearch.catalogdenial. The "holds" check is one shared function (platform_connectors::snapshot::holds) for P39 to reuse. Since #204 the check is inResearchService::publish_listing, soResearchService::newandfrom_configtake the app's vault.DATASET_MAX_MIBdefaults to 64 and accepts 1 to 512; a value out of range refuses startup. The default is a placeholder until P34 and P40 measure the browser upload.upload_bodytarget, added to the weekly matrix.keys/{version}/reserved for ADR 0004's wrapped data keys; who chooses each id and who seals what; why the declared schema is plaintext; the size limit; and the "holds" rule.Changes to existing behaviour:
For reviewers:
mainnow has 0009 to 0011 and no open branch uses 0012. Renumber it if you reserve numbers differently.platform-crypto/src/lib.rs(publiccheck_envelope_frame, plusEnvelopeSuite::id,from_idandmin_frame_bytes) and.github/workflows/fuzz.yml.docs/PROJECT_SCOPE.md.snapshot.rs, and #228 also changes theEnvelopeSuitehelpers this uses and the simulated TEE script'sHPK1check. Whichever lands second reconciles them.- the dataset listing route (P39);
- browser sealing and the upload form (P40);
- deleting a dataset (P42);
- query resource limits (P52);
- whether a declaration mismatch costs research budget (P54). Today it does, because the charge comes before decryption.
How it was tested
New tests:
platform-api/tests/dataset_upload_api.rs(14 tests):- an upload is stored as ciphertext and is queryable;
- 401 with no token, and with a
preauthorrefreshtoken;- 422 for malformed bodies: empty, not an upload, truncated, object cut to 20 bytes, unknown suite;
- 413 for an object over the dataset limit, and for a body over the request limit;
- 422 for a declared schema unlike the recorded one;
- 409 for a stale version or a retried body, and 422 for a version an hour ahead of the server clock;
- 404 outside the
upload_namespace, and 400 for an invalid dataset id;- a re-upload replaces the snapshot: one manifest, one record and one object remain, and counts are not doubled;
- a partial upload is never visible: when the manifest write fails the route returns 503, queries still read the previous snapshot, and the next upload prunes the leftovers;
- a retry at the same version replaces an attempt that stopped before its manifest if it declares the same record. A body declaring another row cap gets 409 and leaves the stored record. The matching retry commits and prunes both earlier objects, and sending the version again gets 409;
- 503 with
Retry-Afterwhen a storageputorlistfails;- tenant isolation: the same dataset name under two tenants, and a body sealed for one tenant, stored under another, never opens (502);
- data unlike its declared schema or row cap is refused in the enclave (502);
- a manifest that lists a missing object fails closed (502).
research_api.rs: upload through the route, grant, then the researcher's aggregate query succeeds with the small cohort suppressed.catalog_api.rs: publishing is refused (404) before any upload, for a connector with no data, and for another tenant; it succeeds after an upload.audit_coverage.rs:- upload
ok,committedandpruned, including a leftover object at the committed version (uncommitted_objects);- upload denials:
bad_magic,stale_version,not_upload_dataset;- the refused publish;
- no declared column name in the audit stream;
- connector commit and prune keep their
connector=detail.envelope_vectors.rs: the committed wrong-magic and truncated-frame vectors are refused by the route (422).token_types.rs: the upload route is added toROUTES.query_api.rs: superseded records are pruned, and a snapshot without its record, or with a record naming a suite this build cannot read, fails closed (502).pipeline_e2e.rs: stored-file counts include the record, and a connector snapshot's record holds only its suite.-
platform-core: namespace kinds, version write times, schema validation;-
platform-crypto: the frame check, including a 20-byteHPK1prefix, and suite ids;-
platform-config:DATASET_MAX_MIBbounds;-
platform-storage: record paths, parsing and refusals;-
quackxide-engine: declared schema and row-cap mismatches, an error that names no column, and type families;-
platform-connectors: a table of body-parser refusals, the size-limit boundary, commit order, re-upload, a same-version retry that keeps the failed attempt's record and prunes its object, a version another write committed first (409), a version another write recorded differently (409 before the manifest, its record kept), a stored record that is never replaced, with only an equal one going through (write_record), stale and too-far-ahead versions, schema mismatch, an unreadable record, namespace refusals, record pruning, and property tests.scripts/check.shpasses locally, run with the Node version in.nvmrc.Not covered:
upload_bodyfuzz target compiles (CI's fuzz-build check) but was not run locally, because there is no nightly toolchain orcargo-fuzzhere. It runs weekly in CI.prune_failedevent is emitted but not asserted inaudit_coverage.rs.platform-connectors(an_unreadable_record_fails_closed), not through the route.put_if_absentthe drive manifests rely on.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsdocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made