Skip to content
LITHOEN

Evidence platform and governance

Document

Threat model: public/private boundary

Repository path
docs/architecture/THREAT_MODEL.md
Size · SHA-256
4.6 KB · a517515e882495c02cc4e29d2450008bed40e54592dff4a02237c407f848eb84

What we protect

The INTERNAL / RESTRICTED / CONFIDENTIAL record stores — working research, proprietary methodology, exploration hypotheses, and (later) prospectivity intelligence and partner data. The threat considered here is accidental disclosure through the public build, the most likely failure mode in a single-team repository. (Repository access control, secrets management and infrastructure hardening are host-level concerns; the repo is private and holds no production secrets in Phase 0.)

Failure modes considered

  1. A developer imports the corpus (or another full-scope module) into public web code.
  2. A record is misclassified (a RESTRICTED record marked PUBLIC, or moved into a public directory).
  3. A public record quietly references non-public material (a published claim citing internal evidence), causing partial leakage or broken public provenance.
  4. Rendered output leaks bytes even though source-level checks passed (bundler surprises, RSC payloads, source maps).
  5. Secrets in environment variables reaching the client bundle.

Defence layers (independent; any one alone catches most of the above)

# Layer Mechanism Failure mode covered
1 Package boundary apps/web declares only sanctioned dependencies; pnpm isolated linking means undeclared packages do not resolve 1
2 Static import gate scripts/check-boundaries.ts (runs in pnpm lint + CI) scans apps/web source for forbidden package imports, deep imports, and non-public path strings; ESLint no-restricted-imports mirrors it in-editor 1
3 Load scope @lithoen/projection loads with scope: 'public', which never opens non-public directories; notes are additionally unloadable in public scope 2 (partially), 4
4 Classification-by-directory every record declares a classification AND inherits one from its directory; the loader fails on disagreement 2
5 Projection guards assertPubliclyRenderable throws — failing the build — on any attempt to project a record that is not PUBLIC + PUBLISHED; DTOs are allow-list constructions, never spreads 2, 3
6 Public-chain rule validators require a published public claim's entire evidence/source chain, a public relation's two ends, and an article's cited claims to be PUBLIC + PUBLISHED 3
7 Post-build canary scan every non-public seed record carries a synthetic canary string; scripts/scan-public-output.ts scans every build output byte for canaries, browser-facing output for links into non-public stores (ADR-0065; mentions were forbidden before), every output file for byte copies and fingerprints of the held-back research files, and browser-facing output for personal identifiers 4
8 Note schema the Note record type structurally refuses classification: PUBLIC — working notes cannot be published by misclassification at all 2

Secrets (5): Phase 0 ships no secrets and no .env files; .env* is gitignored. When secrets arrive, only NEXT_PUBLIC_* variables reach the client by Next.js design, and the canary scan pattern extends naturally to secret markers.

Proven, not asserted

tests/boundaries.test.ts and tests/mutation-gates.test.ts demonstrate RED behaviour for controlled violations of layers 2, 4, 6 and 7 (forbidden import, misclassification, broken public chain, canary in output) and GREEN behaviour for the clean tree. Do not weaken these tests; extend them when adding new stores or classifications.

Residual risks (accepted for Phase 0)

  • A determined insider can of course exfiltrate a private repo; this model addresses accident, not malice.
  • Prose in PUBLIC records could paraphrase restricted knowledge. That is an editorial-review concern; PUBLICATION_POLICY.md places it in human review, not tooling.
  • The canary set only proves the pipeline for records that carry canaries. Convention: every new non-public store gets a canary exemplar when created.

ADR-0065 — the research record is public

Since 2026-11-14 the project's own working research (data/internal, docs, research/) is published at /research through @lithoen/projection, as research records rather than canon. What stays non-public is the held-back remainder: the canary fixtures, the RESTRICTED store, files with personal data, third-party publication and dataset copies, and derived geometry bytes. The threat this section adds is a held-back file reaching the output; layer 7 now recognises each one by checksum and by a content fingerprint, and the rules that decide the remainder live in packages/corpus/src/research.ts, tested in tests/research-publication.test.ts.