Engineering policy #
Camlet uses plain, typed, explicit OCaml. Domain logic is pure, effects enter through narrow adapters, dependencies point inward, and automation must preserve clarity rather than manufacture abstractions.
Hard rules #
- Keep domain and application code independent from network, filesystem, process, keyring, and terminal APIs.
- Represent DIDs, AT URIs, repository DIDs, record keys, Git refs, origins, and secrets with abstract types.
- Use exhaustive matches for domain states. Do not erase unknown protocol states to make decoding succeed.
- Use typed errors at trust boundaries. Do not use exceptions as ordinary control flow.
- Never execute through a shell. External tools receive an executable and an argv vector.
- Never send credentials across origins or preserve authorization headers across redirects.
- Never print, serialize, or include secrets in diagnostic values.
- Command logic returns domain results; presentation modules own human and machine rendering.
- Machine output has a versioned schema and stable exit-code behavior.
- No use of
Obj.magicor unsafe deserialization in production code. - Every accepted integration advances one canonical history. Mirrors receive the exact resulting commit.
Interfaces and modules #
Use .mli files for domain abstractions, application ports, adapters, and other architectural boundaries.
Implementation-only helpers inside a wrapped library do not require ceremonial interfaces. Prefer small
modules and ordinary functions; introduce functors only when they enforce a real capability boundary or
make deterministic testing materially easier.
Ports live next to the application code that consumes them. Concrete adapters depend inward on those ports.
The camlet executable is the composition root and is the only layer that assembles concrete effects.
Compiler and tooling policy #
The compiler, Dune, formatter, and libraries are pinned by flake.lock. camlet.opam.locked records the
corresponding OPAM resolution. Compiler warnings are reviewed as a versioned policy. Do not use
-warn-error @a: OCaml's letter groups can gain warnings during compiler upgrades and unexpectedly break
production builds.
The root dune file records the numeric warning policy for the pinned toolchain. The @ markers make only that
explicit set fatal. Review it deliberately when upgrading the compiler or Dune; do not scatter warning
suppressions through individual library stanzas.
Formatting is enforced by ocamlformat. Semgrep supplements the compiler for a small number of structural
security rules; every repository rule needs positive and negative fixtures before it becomes a required gate.
A custom typed linter is justified only after repeated defects demonstrate that compiler, Dune boundaries,
tests, and Semgrep cannot express a valuable rule.
Required local checks #
Run nix develop -c scripts/check before proposing a change. It builds all targets, verifies formatting and
lint aliases, checks unused libraries, executes tests, and runs the repository Semgrep policy.
Human review remains responsible for #
- whether a module has one coherent responsibility;
- whether an abstraction makes the system easier to change;
- whether errors preserve enough operational context without leaking data;
- whether a protocol assumption is supported by current evidence;
- whether a change expands the trusted computing base;
- whether an interoperability action can create divergent canonical histories.