← Back to Pull requests

feat(frontend): seal and upload steward datasets in the browser (P40) #280

Closed
unknown closed this pull request without merging on Nov 24, 2026 18:48 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 12:01 UTC
Author

What and why

Plan item P40 (docs/V1_PLAN.md). Part of #221: the browser half of the steward upload (ADR 0012). The issue stays open for sign-in (P32), as the maintainer's note on #221 says, and for the hybrid suite (#186) and #175's enrollment check.

  • Stored datasets and the picker. The research portal's stewardship panel lists the datasets the steward holds, from GET /api/v1/datasets (id, object count, ciphertext size, suite, write time), on every load. The publish form picks from them instead of taking a free-text slug.

  • The footer, in a worker of its own. lib/datasets/footer.worker.ts reads only the file's tail (Blob.slice: the trailer, then a footer of at most 16 MiB), decodes it with hyparquet's Thrift decoder, and declares each column's name and type family by the rules of the enclave's Parquet reader, the embedded Arrow schema included (parquet-rs apply_hint). Column statistics are never decoded. It refuses a file the enclave could not read or declare; the form also refuses a schema unlike the dataset's recorded one and a file whose sealed object would exceed the limit, all before anything is sealed. The form says in one line that column names and types are stored in plaintext.

  • The seal, in the crypto worker. A new uploadDataset operation uses the device's existing key and never creates one, refuses unless the tenant's enrolled key is that key, binds the session's tid, draws the object id and the version, seals the object and the manifest (HPK1 until #186), zeroes its copy of the plaintext and sends the body. A 401 or 403 is shown clearly.

  • The listing gives what the browser checks against. GET /api/v1/datasets now gives each upload's declared row_cap and schema from its record (null for a connector's dataset or an unreadable record), and dataset_max_bytes. Both were already visible to the operator (ADR 0012); #246 left the schema out to follow its issue's field list and noted that #221 would need it. snapshot::recorded_suite is now read_record.

  • ADR 0014 (reserved in #221) records the reader (hyparquet 1.33.1, MIT, no dependencies, pinned exactly; only its Thrift decoder is imported), where it runs, the rules it follows, the listing fields and the seal.

  • Benchmark. docs/BENCHMARKS.md records the upload timed at the 64 MiB limit in a real browser: about 0.6 s of browser work on an Apple M4 once the wasm module is loaded, about 90 % of it the seal, so the 64 MiB default stands. It is a recorded manual run because the upload needs a running API, which the browser job does not start; the seal joins the regression run through #255. @AxolDad, the proposed target is there (footer read within 100 ms, upload within 3 s once the module is loaded, network excluded); please confirm or adjust it.

  • The data guard. scripts/check.sh kept only data files whose path contains /fixtures/, so it refused the Parquet vectors in the repository's top-level fixtures/ (CI's first run on this PR). It now accepts a fixtures/ directory at any depth, checked against the tracked vectors and look-alike paths such as notfixtures/ and fixtures-old/, which it still refuses. scripts/ is code-owned.
  • How it was tested

  • Shared Parquet vectors (fixtures/parquet/, 28 synthetic files): quackxide-engine/tests/parquet_schema_vectors.rs writes them and runs the enclave's own register_parquet_declared on every file the browser declares; footer.test.ts checks the browser against the same schema-vectors.json. They cover every type family, legacy converted types and INT96, the embedded Arrow schema's refinements (Date64 and Timestamp(Second) stored as INT64, a binary named a string, the last entry winning), nested, repeated, binary, Float16, time, duration, interval, null, UUID and ENUM columns, malformed, renamed and extra-field embedded schemas, duplicate, long and control-character names, 513 columns, and no rows.

  • Cross-implementation upload: fixtures/envelope/hpk1-browser-upload.json is a body sealed by the browser's own upload code; a_browser_sealed_upload_opens_in_the_enclave (dataset_upload_api.rs) stores it through the route and queries it, so both envelopes open with the backend's open path and the declaration matches in the enclave.

  • Footer reader (footer.test.ts, arrowSchema.test.ts): not Parquet, encrypted, a footer longer than the file or than the 16 MiB cap, truncated and non-Thrift footers, 22 footers parquet-rs would not read, row counts, name limits, tail-only reads, and property tests on arbitrary bytes.

  • Upload operation (datasetUpload.test.ts, worker.test.ts, protocol.test.ts): the body round-trips through the real wasm seal, the version and info bindings, the plaintext copy is zeroed, each refusal comes before sealing (no session, a non-canonical tid, no key, no enrolled key, another enrolled key, a rejected session on the key check, a file over the limit), the API's 401, 403, 404, 409, 413, 422 and 503 are shown clearly, and no key is ever created.

  • Components (DatasetUploadForm.test.tsx, PublishForm.test.tsx, ResearchPortal.test.tsx): the real footer reader under jsdom for the malformed cases, labels and role="alert", the schema mismatch, the upload through the crypto worker under the portal's token and the reload after it, and a failed listing.

  • Listing (dataset_upload_api.rs, snapshot.rs): the declared row cap and schema for uploads, null for connectors and unreadable records, and the configured dataset_max_bytes.

  • In the app: with the API in development and the dev server, an upload was stored and listed, a CSV and a file with other columns were refused, the picker offered the dataset, and the benchmark above ran.

  • footer.browser.test.ts runs the footer worker in real browsers. It did not run locally (no Playwright browsers here); CI's browser job runs it.
  • Checklist

  • scripts/check.sh passes locally

  • Every new refusal has a negative test

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs (n/a: the new refusals are in the browser; the routes' events are unchanged)

  • Fails closed on missing configuration, key material, or attestation (no key, or an enrolled key that is not this browser's, refuses the upload)

  • No new cryptographic primitives; suites stay behind their type aliases

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made (ADR 0014)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: abendrothj Review duration: 4727m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #280"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%