Appearance
ADR-2497: Dual-Layer Gates for Source and Public Bundles
- Status: Accepted
- Date: 2026-11-20
- Authors: @fderuiter
- Deciders: @fderuiter
- Requirements: PRD-SYS-001 (de-identification and security compliance gates), HIPAA Safe Harbor (45 CFR §164.514(b)(2))
- Extends: ADR-2386, ADR-2532, ADR-2549, ADR-2550
1. Context & Problem Statement
Cadence Clinical publishes three static web artifacts to GitHub Pages (ADR-2550): the VitePress developer and regulatory documentation portal (docs/.vitepress/dist), the co-hosted Mock Service Worker (MSW) Staff Workbench demo (apps/web/dist, staged at /demo/), and the co-hosted Participant Portal demo (apps/subject-portal/dist, staged at /subject-portal/). Previously, compliance and security scanning left correlated blind spots across both source and built outputs:
- Source DEID exclusions (
DeidComplianceService):docs/,stores/, and staged root portal documents (README.md,ARCHITECTURE.md,AGENTS.md,CONTEXT.md,CONTRIBUTING.md,SECURITY.md,SUPPORT.md,LICENSE) were excluded fromcheck deid(tracked in ADR-2386), allowing unreviewed emails, synthetic-looking national identifiers, and third-party media URLs (images.unsplash.com,img.shields.io) to enter published portal inputs. - Source secret scanner exclusions (
SecretScanner) and baseline blind spots:.vuetemplates andscripts/(includingscripts/build-docs.js) were excluded fromSecretScanner,.secrets.baselineexcludeddist/, andscripts/build-docs.jsmutatedprocess.envwith compliance signing keys (AUDIT_LOG_SECRET_KEY,INBOUND_EMAIL_HMAC_SECRET,GATEWAY_SECRET_KEY) across the entire VitePress compilation process. - Unverified public build outputs and missing browser CSP: Comments such as
deid-ignoreorpragma: allowlistapply to source lines, not compiled bundles, and Vite/VitePress builds previously lacked a post-build verifier or same-originContent-Security-Policymeta directives before SLSA provenance attestation and GitHub Pages artifact upload.
2. Decision Drivers & Constraints
- Zero PHI/PII or secret leakage in public Pages artifacts: Every file shipped in
docs/.vitepress/dist(including/demo/and/subject-portal/),apps/web/dist, andapps/subject-portal/distmust be verified after compilation with zero comment exemptions. - Snapshot integrity (ADR-2532): Vendored standards (
docs/CDISC/,docs/NCI/) and GxP qualification runs and snapshots (docs/SDLC/runs/,Requirements_Traceability_Matrix.md,IQ_OQ_PQ_Execution_Report.md) must remain untouched on feature branches. - Least-privilege build environments: Compliance traceability secrets must never be visible to VitePress or frontend asset bundlers.
- Offline/same-origin portal execution: Static portal and demo pages must enforce a strict
Content-Security-Policywithout breaking VitePress local search or same-origin MSW service workers.
3. Options Considered
Option 1: Source-Only Scanning
- Overview: Expand
DeidComplianceServiceandSecretScannerover source files only, relying on pre-commit and source CI gates. - Pros:
- ✅ Fast execution with no build prerequisite.
- Cons:
- ❌ Cannot catch build-time environment interpolation, bundler plugin injections,
deid-ignorepragmas hiding data shipped to public HTML/JS, or missing CSP headers in compiled HTML.
- ❌ Cannot catch build-time environment interpolation, bundler plugin injections,
Option 2: Post-Build Bundle Scanning Only
- Overview: Leave source scanners unchanged and scan only
docs/.vitepress/dist,apps/web/dist, andapps/subject-portal/distin CI. - Pros:
- ✅ Inspects exact published bytes.
- Cons:
- ❌ Shifts feedback late in CI rather than catching violations in
cadence check --pre-commitanddotnet-quality.
- ❌ Shifts feedback late in CI rather than catching violations in
Option 3: Dual-Layer Source and Zero-Exemption Public Bundle Gates (Selected)
- Overview: Harden Layer 1 source gates (
deid,security,clean-secrets), isolatescripts/build-docs.jsandscripts/stage-portal-demos.jschild-process environments, inject same-origin CSP meta headers into VitePress, staff demo, and participant demo entrypoints, and enforce a Layer 2 zero-exemptionpublic-bundlequality gate before artifact upload and SLSA attestation. - Pros:
- ✅ Immediate source feedback on authored
docs/, root docs,.vue,stores/, andscripts/while protecting vendored standards and GxP snapshots. - ✅ Zero-exemption verification of exact compiled
docs/.vitepress/dist,apps/web/dist, andapps/subject-portal/distoutputs before Pages publication or provenance signing. - ✅ Browser-enforced defense in depth via same-origin
Content-Security-Policyheaders with SHA-256 hashes for VitePress bootstrap scripts.
- ✅ Immediate source feedback on authored
- Cons:
- ❌
public-bundlerequires compiled bundles and therefore runs indocs-buildanddeploy-docs.yml(PreCommitMode.Skippedin pre-commit).
- ❌
4. Decision Outcome
- Chosen Option: Option 3 — Dual-Layer Source and Zero-Exemption Public Bundle Gates.
- Justification: Combining source-level guardrails with a fail-closed, zero-exemption post-build verifier and browser CSP headers eliminates single-point bypasses across authoring, build-time environment handling, and GitHub Pages publication.
5. Consequences & Trade-offs
- Positive Impact:
- Authored
docs/, root portal Markdown/license files,.vuecomponents, andstores/are continuously scanned bycheck deidwith strict synthetic email domain validation (@cadence.clinical,@cadence-clinical.com,@ccrsoft.com,@cadence.example,.invalid, plus the nine canonicalADR-2549demo persona@example.comaddresses), allowing.deid-baseline.txtto drop allssn_national_id,urls, andemailentries. SecretScannerinspects.vueandscripts/for private keys, AWS/GCP/Azure credentials, GitHub/Slack/Stripe tokens, and hardcoded compliance secrets, and.secrets.baselineno longer excludesdist/.scripts/build-docs.jsscopes ephemeral signing keys strictly to its pre-build CLI verification subprocesses (check openapi,check schema-doc,check markdown,check rtm) without mutatingprocess.envor settingRTM_DRAFT, and passes a minimal non-secret variable allowlist tovitepress build docsandscripts/stage-portal-demos.js.PublicBundleValidatorService(check public-bundle/validate-public-bundle) blocks publication if national IDs, unapproved emails, secrets, external assets, executable localhost URLs, or missing/permissive CSP headers appear in built outputs across all three bundles and staged subpaths.
- Authored
- Negative Impact / Technical Debt:
check public-bundlerequirespnpm --filter ui build,pnpm docs:build, andpnpm docs:stage-demosto have run first.
- Mitigation Strategy:
public-bundleis markedPreCommitMode.Skippedin.githooks/pre-commit, excluded indotnet-quality, and executed deterministically inci.yml(docs-build) anddeploy-docs.ymlprior to checksum generation,actions/upload-pages-artifact, andactions/attest-build-provenance.
6. Implementation & Verification
- Affected Repositories / Services:
packages/tooling_core,packages/cli,scripts/build-docs.js,scripts/stage-portal-demos.js,docs/.vitepress/config.mjs,apps/web,apps/subject-portal,.github/workflows/ci.yml,.github/workflows/deploy-docs.yml. - Verification Plan: Unit suites in
Cadence.UnitTests(DeidComplianceServiceTests,SecretScannerTests,PublicBundleValidatorServiceTests,QualityGateRegistryTests,LocalCiPlanTests), PostgreSQL 18 integration and browser-to-database verification (Cadence.IntegrationTests,Cadence.E2ETests), frontend Vitest and Playwright E2E accessibility suites (subject-portalandweb --project=accessibility), Native AOT CLI publish, fullpnpm docs:build+pnpm docs:stage-demos+cadence check public-bundle, and headless Chromium CSP verification across all co-hosted portal routes.