[docs] Legatus: CLAUDE.md, design (docs/01), protocol v1 (docs/02), README, MPL-2.0 licence, pre-commit hook
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# CLAUDE.md — Legatus
|
||||
|
||||
Legatus is Fabrica Domi's agent: one small Rust binary per OS, installed with one copied command. Two roles Fabrica
|
||||
toggles: *build here* and *deploy here*. It connects outbound only, to the Fabrica server, over mTLS (its client
|
||||
certificate from domi-pki, the root in Custos). Nothing unsigned runs: before it touches anything it checks the
|
||||
release's signature against the team's release key. MPL-2.0. Read docs/01_legatus.md (design) and
|
||||
docs/02_protocol.md (the wire protocol Fabrica implements) first.
|
||||
|
||||
## Layout
|
||||
crates/protocol legatus-protocol: PURE. Enrollment codes and their single use, messages (enroll, hello, job,
|
||||
report, renew), the job replay guard, the agent registry (which certificate is current), the
|
||||
release manifest and its signature check. No I/O, no clock: the caller passes `now`.
|
||||
crates/linux legatus-linux: the Linux (systemd) target: versioned release dirs, atomic symlink switch,
|
||||
systemd restart, health check, auto rollback. Unix only.
|
||||
crates/agent legatus (the binary): state dir, the HTTPS/mTLS client (rustls, root pinned from the
|
||||
enrollment code), enroll, the job loop, the deploy pipeline (download, verify, unpack, backend).
|
||||
install/ the one-line installer (install.sh) Fabrica serves.
|
||||
tests/linux the container integration test of the Linux target (real systemd).
|
||||
|
||||
## Commands
|
||||
cargo test --workspace # quote test counts per crate; an exit code alone is not green
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
tests/linux/run.sh # Linux target against real systemd in a container (needs Docker/Podman)
|
||||
On Mark's PC: CARGO_HOME=F:\C-Drive-Migration\future-caches\cargo, CARGO_TARGET_DIR=D:\cargo-target\legatus.
|
||||
The Linux backend's own tests run on Linux only (`cfg(target_os = "linux")`).
|
||||
One-time per clone: git config core.hooksPath .githooks (self-test: bash .githooks/test-pre-commit.sh)
|
||||
|
||||
## Rules
|
||||
- Everything from the network is hostile: messages, jobs, manifests, signatures, artifacts (tar entries), certificates.
|
||||
Typed `Result`, size limits, no `unwrap()`/`expect()`/`panic!` outside tests (clippy denies them).
|
||||
- Nothing unsigned runs: the signature is checked before any byte of an artifact is unpacked; a refusal is reported.
|
||||
- Outbound only. Legatus never listens on a port.
|
||||
- The protocol crate stays pure; transport, files and processes live in `agent` and `linux`.
|
||||
- Tests first where the risk is: enrollment, certificates, signatures, the job guard, tar unpacking, switch and rollback.
|
||||
- Secrets (the agent key, enrollment codes) never in logs, files in git, or error messages. The key file is 0600.
|
||||
- Commits: `[<crate>] <Feature>: <one line>`. No AI attribution, no trailers, ever.
|
||||
- Never in git: target/, binaries, private keys, files over 5 MB (the pre-commit hook enforces it).
|
||||
- $GITEA_TOKEN is never echoed or written anywhere.
|
||||
- Workflow: branch → Gitea PR via API → short adversarial self-review in the PR body → merge --no-ff → push →
|
||||
`git rev-parse HEAD origin/main`.
|
||||
- Disks on Mark's PC: nothing on C:. Build output on D:\cargo-target, containers on D:.
|
||||
- The README says "Built, tested and signed by Fabrica Domi" only once Fabrica really builds, tests and signs it.
|
||||
Reference in New Issue
Block a user