Home / Docs / Systems Engineering & ADRs

Systems engineering

Systems Engineering, Interfaces & ADRs

Production engineering starts before the first line of code. Define the system boundary, write down hard invariants, map failure modes, and record every major choice in a 1-page Architecture Decision Record.

The six engineering questions before building

Before selecting a framework, database, or model, answer six concrete questions in plain text. If any answer is vague, stop and clarify before coding:

  • WHO uses the system, operates it, or is affected by a wrong output?
  • WHAT decision or workflow does it support, and what are the hard constraints (latency, cost, privacy, accuracy)?
  • WHERE does it run (cloud, on-premises, air-gapped, browser client) and where does its data live?
  • WHEN is an output valid, stale, or out of scope?
  • WHY is this architecture justified over a simpler baseline?
  • HOW will we test, observe, and prove that it still works after every change?

Interfaces and invariants beat ad-hoc glue

Most early-career projects fail at the seams between components: a CSV column changes type, an API returns null, or an LLM omits a required field. Treat every boundary as an explicit contract:

  • Data contracts: Enforce typed schemas (Pydantic / JSON Schema for APIs, W3C SHACL for RDF graphs).
  • Hard invariants: State conditions that must never be violated (e.g., "no writeback executes without a passing validation report and caller role check").
  • Explicit abstention: Define what the system returns when evidence is missing or confidence is below threshold.

A minimal 1-page ADR template

Keep Architecture Decision Records (ADRs) in docs/adr/0001-decision-title.md right beside the code so future teammates — and your future self — know why a choice was made:

# ADR-0001: Use SQLite / D1 + SHACL Gate Instead of Unstructured Prompt Memory
- Status: Accepted (2026-12-04)
- Context: Need deterministic state and auditable writes for multi-step workflows.
- Decision: Store structured records in SQLite/RDF and validate all writes via SHACL.
- Alternatives Considered: Pure vector store (rejected: weak multi-hop & constraint checks).
- Consequences: Upfront schema effort; gains reproducible tests and zero silent drift.
- Verification: `pytest` regression suite + CI schema check on every pull request.

Write a failure-mode table before launch

Failure Mode Detection Signal Deterministic Mitigation
Schema drift on upstream input Validation error rate spike Quarantine non-conforming rows; fail loud instead of coercing silently
Model hallucination or sycophancy Citation / rubric eval drop Require verbatim source spans; abstain when evidence is absent
Unbounded tool or API write Policy gate rejection log Least-privilege read-only default; human approval on state mutations

Related docs