← Back to Pull requests

test: upload the dataset as the steward in the simulated TEE run #248

Closed
unknown closed this pull request without merging on Nov 19, 2026 11:22 UTC
View on GitHub
unknown unknown commented on Nov 14, 2026 11:50 UTC
Author

What and why

Closes #240 (part of #183).

scripts/test-simulated-tee.sh seeded the steward's data at enclave-api startup, because an upload body is sealed by the browser's envelope module, which the script cannot run. So the steward upload route (ADR 0012), the v1 data path, had no end-to-end check, and neither did the approval retry after a revoke (#166).

  • seal-upload, a dev-only binary (required-features = ["dev"]), plays the steward's browser. It seals a seeded synth-data cohort and the snapshot manifest listing it to the steward's public key, under the bindings the browser uses (steward-upload-v1 for the object, tenant-snapshot-manifest-v1 for the manifest). It declares the cohort's schema and row count in the header and writes the body to stdout. It holds no private key and sends nothing. It runs as its own image and compose service with no network, under the tools profile, so up never starts it.

  • The sealing code is platform_api::dev::seal_upload (and seal_cohort_upload for the cohort). The API tests' common::sealed_upload now calls it, so the tests and the tool seal the same way.

  • The script:

  • - starts enclave-api with an empty vault (the compose file no longer passes DEMO_TENANT_*), uploads the body through PUT /api/v1/datasets/upload_cohort, publishes the dataset and runs the research lifecycle on it;
    - checks that an upload is refused without a token (401), outside the upload namespace (404) and at a stale version (409: the same body sent again);
    - checks that approving the request again after the revoke is refused (404), and that the researcher's next query is still refused (403);
    - requires the vault to hold exactly three files, at the version and object id in the steward's header: the upload's object and manifest as HPK1 envelopes, and its record, which must hold exactly the version, row cap and schema in the header, plus the suite. Any other file fails the check, whatever tenant it belongs to. It runs the check after the upload and again as the last stage, after every query, and finds no Parquet magic bytes anywhere;
    - drops its "Not covered yet" list.
  • CI's dev-only binary checks on the release build now include seal-upload.
  • Notes for review

  • This PR targets #246's branch (StewDataListRoute) and merges after #246 and #243, so the diff shows only this work: 1f125eb, and the review fixes in 5a7a496 and 8c3bcf2.

  • #228 (HPK2) is due to merge first. This PR then adapts: seal-upload passes a SuitePolicy to TenantPublicKey::from_raw, the tests' TenantKeypair::generate takes a suite, and the script enrolls a framed HPK2 key and expects HPK2 in the upload's suite, the record and the envelope check (at least 1140 bytes).

  • The vault check refuses connector-style records, since nothing in this stack writes them anymore. With seeding removed, the connector-sync sealing path (maybe_seed_demo_fixture in wiring.rs) no longer runs end to end; whether to keep that coverage is a maintainer decision. The function itself is untouched; it is outside this issue's "Where".
  • How it was tested

  • scripts/check.sh passes locally (secret scan skipped: gitleaks is not installed locally).

  • New: the_seal_upload_tools_cohort_is_stored_and_queryable in dataset_upload_api.rs uploads the exact body seal-upload writes (k = 5). The stored record holds the five declared columns and a row cap of 46, and the enclave query releases 7 groups and suppresses 2, so the declared schema matches what the enclave reads.

  • New: seal-upload's unit tests accept a tenant, key and upload_ dataset (with the default and an explicit k). They refuse a connector dataset, a malformed dataset id, a bad public key, a bad tenant id, an unknown flag, a flag without a value and a missing dataset.

  • The existing upload tests now seal through the shared code and pass unchanged.

  • The script: Docker isn't installed on my machine, so I ran it end to end against the locally built dev binaries through a stand-in for docker compose (each service's compose environment, on loopback). All 9 stages passed:

  • - upload: 401, 404 and 409 refusals, and the upload itself;
    - vault, after the upload and again after the queries: exactly the upload's 2 HPK1 envelopes and its record, which holds exactly what the header declared, and no Parquet magic bytes;
    - research: 403 before a grant; the aggregate keeps celiac (2 rows) and gout (3) and suppresses lupus (1); 422 for a row-level query; 429 on a spent budget; 404 for the approval retry and 403 after it;
    - tamper: 503 for each tampered token, then 200.

    CI's simulated TEE end to end job runs it on real Docker. On 8c3bcf2 it passed all 9 stages with the same results, which also covers the new image, docker compose run of a profile-only service, and the binary body over Docker's stdout.

  • I ran the vault check against a hand-built vault holding exactly the upload, which it accepts, and 15 tampered copies, which it refuses. The tampered copies have an extra file under control/, an extra file under another tenant, an extra envelope, a second snapshot version, a symlink, a missing record, a missing manifest, or nothing at all. Others have a record with an extra field, another suite, another row cap or invalid JSON, an envelope with another magic or too few bytes, or Parquet magic bytes inside an envelope.
  • Checklist

  • scripts/check.sh passes locally (its secret-scan step was skipped: gitleaks is not installed locally)

  • Every new refusal has a negative test (the API is unchanged; seal-upload's argument refusals are tested, though not its refusal to write the binary body to a terminal)

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs (none: the API is unchanged, and the script checks refusals that are already audited)

  • Fails closed on missing configuration, key material, or attestation (seal-upload refuses to run without a tenant, key and upload dataset; the script stops at the first unexpected status)

  • No new cryptographic primitives; suites stay behind their type aliases (seal-upload seals with the existing hpke_seal_to_tenant)

  • Synthetic or public data only (docs/DATA_POLICY.md): the upload is synth-data's seeded cohort

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

  • Architectural decision recorded in docs/adr/ if one was made (none: a dev-only tool and test coverage under ADR 0012)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: abendrothj Review duration: 7172m
    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
    0.52
    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
    Real PR Conversation Timeline
    1 comments
    "Review active on #248"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%