Evidence platform and governance
Lithoen Architecture
- Repository path
- docs/architecture/ARCHITECTURE.md
- Size · SHA-256
- 6.6 KB · 393e3003b7d30d1cf58f6372b5f380be15bc56efe8c1bacf37a4f58ad35fcec7
Purpose
Phase 0 establishes a scientific core that can grow for a decade — from a trusted Earth science platform into a proprietary geological knowledge and intelligence system — without replacing its foundation. The design optimises for that trajectory, not for visible feature count: strong data model, simple execution.
The architectural law
SOURCES → EVIDENCE → CLAIMS → ENTITIES → RELATIONSHIPS → KNOWLEDGE → MODELS → INTELLIGENCE → DECISIONS
Every important decision must be traceable to evidence. Concretely:
- A Source is one citable retrieval of a work (tier, license, retrieval date, checksum).
- Evidence is one locatable statement inside one source. It is the pivot that makes "where exactly does the source say that?" machine-answerable.
- A Claim cites evidence, declares an epistemic status, and is the canonical unit of Lithoen knowledge. Claims are superseded, never edited into new meanings.
- Entities and Relations form the knowledge graph. Attributes classify; claims assert.
- Articles are presentation surfaces citing claims. They are never canonical.
- A SpatialRepresentation is one published opinion about where an entity is, with its own role, boundary certainty, epistemic status, provenance and transformation history. Geometry is a record, not a field: an entity may have several, and where two disagree Lithoen keeps both (ADR-0022). A GeospatialDataset answers the question a Source does not — may Lithoen extract geometry from this, transform it, and republish the result?
- Models, intelligence and decisions are later phases; the record types and classifications they will need (RESTRICTED intelligence built on PUBLIC/INTERNAL science) exist now.
Layering
┌───────────────────────────────┐
│ apps/web │ public presentation
└──────────────┬────────────────┘
│ (the ONLY data path)
┌──────────────▼────────────────┐
│ @lithoen/projection │ public-scope loading,
│ guards + allow-listed DTOs │ publishability enforcement
└──────────────┬────────────────┘
┌──────────────▼────────────────┐
validators ──────► @lithoen/corpus │ fs loading, parsing,
(rules over the │ loader + CorpusIndex graph │ graph index; full scope
full corpus) └──────────────┬────────────────┘ only outside the web app
┌──────────────▼────────────────┐
│ @lithoen/schemas │ Zod contracts per record
└──────────────┬────────────────┘
┌──────────────┬───────────┴──────┬──────────────────┐
▼ ▼ ▼ ▼
@lithoen/domain @lithoen/scientific-units @lithoen/geospatial @lithoen/citations
(vocabularies) (units + dimensions) (point/bbox/ref) (formatting)
Dependency direction is strictly downward. apps/web may additionally import domain,
citations, scientific-units and geospatial (pure vocabulary/utility layers), but never
corpus, validators or schemas — enforced by three mechanisms (see THREAT_MODEL.md).
Why these packages and no others
Each package exists because two or more consumers need it or because it is a hard boundary:
- domain — the semantic contract (vocabularies, taxonomies, predicate registry). Used by everything, including the public UI, which renders the same definitions the validators enforce. Zero dependencies.
- scientific-units / geospatial — substantive, testable models used by schemas, validators and projection. Deliberately small.
- schemas — runtime validation (Zod) + inferred types for all record kinds.
- citations — one deterministic citation renderer shared by web and validators, so a citation can never render differently in two places.
- corpus — the only code that touches the filesystem record stores; public vs full scope is decided here, so "public builds never even open non-public files" is a property of one module.
- projection — the public boundary. Explicit allow-list DTO construction; throwing guards on classification and publication state.
- validators — pure rules over the loaded corpus; every rule is exercised by mutation tests that prove it can fail.
Deliberately not created in Phase 0: packages/ui (a component library with a single
consumer is premature — components live in apps/web/src/components until a second surface
exists), packages/knowledge-graph (the graph index is ~100 lines inside corpus; extracting
it would be an empty layer today).
Record stores
One JSON file per record; the filename equals the id slug; the directory implies the classification and the loader rejects disagreement. JSON (not TS modules) keeps the corpus machine-readable by any tool; deterministic loading + Zod parsing recovers full type safety.
Route taxonomy (public site)
/entities/:slug— one flat, permanent namespace for all entity types. Type-specific hub pages (e.g./volcanoes) can be added later as curated collections without moving entity URLs./articles/:domain/:slug— articles namespaced by content domain (theARTICLE_DOMAINSvocabulary), stable as domains grow./sources/:slug— the public source registry./methods,/about— trust surfaces./methodsrenders the domain vocabulary itself.
All pages are statically generated at build time (dynamicParams = false); the site is a
pure artifact of the repository state.
Validation topology
pnpm verify = format → lint (+ import-boundary gate) → typecheck → corpus validation
(schemas + 10 rule families over the FULL corpus) → tests (contracts, integrity, boundary,
mutation gates) → production build → post-build canary/leakage scan.
Every gate is deterministic: same tree in, same verdict out.