Architecture overview
This page is published from the ml repository. Edit on GitHub View source
This page covers how the synthaea_ml package is organized: which subpackage does what, which
way imports may point, and how data moves from an agent capture to a model version in the
registry. For the exact feature definitions see features.md; for the trainers
see training.md.
What the pipeline produces
The agent scores events with Isolation Forest models exported to ONNX. This repository builds those models and everything that justifies shipping one:
| Output | Where | Consumed by |
|---|---|---|
model.onnx | registry/<model>/<version>/ | The agent's ml crate, through onnxruntime |
model_metadata.json | next to the model | The agent's scorer: conformal threshold and per-feature bounds |
model_record.json | next to the model | verify_onnx and the robustness gate: dataset hashes, robustness cards, scenario replays, hyperparameters |
card.md | next to the model | Reviewers: purpose, data, metrics, limitations |
| Golden fixtures | tests/fixtures/ and the agent's crates/ml/tests/fixtures/ | The parity tests on both sides |
| Calibration reports | reports/calibration/ | The likelihood-ratio constants of the agent's correlator |
The models are grouped in tiers by what they score:
| Tier | Scores | Features | Trainer |
|---|---|---|---|
| T0 | One command line | 9 command-line features | train_linux, train_windows |
| T1 | One process incarnation | 9 command-line + 8 correlation = 17 | train_behavior |
| T2 | One pid's correlator window | 8 correlation features | train_correlation |
| Site | One command line, per tenant | 9 command-line, or 9 + 2 rarity | train_site_model, train_site_rarity |
T3 (fleet rarity and per-site baselines) runs on the control plane. This repository holds the rarity feature definition and the per-site trainers that consume a site corpus exported from it, not the fleet service itself.
Package map
| Subpackage | Responsibility |
|---|---|
data/ | Reading agent captures and baselines (jsonl, wire, canonical), building datasets (capture_to_baseline, aggregate_correlation, behavior_dataset, common_set), the dataset manifest, and the process trees a capture's ancestry rebuilds |
features/ | Feature extractors, each the reference for a Rust twin in the agent |
calibration/ | Conformal thresholds and feature bounds (calibrate_conformal); empirical likelihood ratios (calibrate_llr) |
training/ | The shared configuration and pipeline steps, and one entry point per trainer |
evaluation/ | Scenario replay, robustness with its mutators and gate, the lineage-gain measurement, and an ONNX model adapter |
cases/ | The case labeller for the T2 scorer (ml#3): which scenario, if any, produced each case agent replay wrote |
registry/ | The version directory layout, the record types, its codec, dataset binding and provenance checks |
export/ | verify_onnx, the runtime and provenance check of registry models |
| Top level | hashing (the one SHA-256 helper), siblings (where the sibling checkouts are), cli_logging |
Dependency direction
The package is layered so that what ships, and what verifies what ships, never depends on a training script:
flowchart BT base["hashing, siblings, cli_logging"] data["data"] --> base features["features"] <--> data registry["registry"] --> data & base calibration["calibration"] --> registry & data & features evaluation["evaluation"] --> calibration & registry & data & features evaluation -.->|config only| config["training.config"] cases["cases"] --> evaluation & data & base training["training (entry points)"] --> evaluation & calibration & registry & data & features export["export"] --> registry & features & base
dataandfeaturesuse each other:features.t1reads the canonical command line fromdata.canonical, anddata.common_setbuildsfeatures.raritysnapshots. Neither imports anything above them.- The record types live in
registry.records;calibrationre-exportsConformalCalibrationandFeatureBoundsfrom there, so the registry owns its schema. - Shared values that several layers need live below the trainers: the sanity samples in
features/sanity_samples.py, the hyperparameters and thresholds intraining/config.py. tests/test_import_direction.pyenforces the two rules that matter most: importingexport.verify_onnxloads nosynthaea_ml.trainingmodule, and importingevaluation.t1_lineage_gainloads notraining.train_*script (it may readtraining.config).
From capture to registry
flowchart LR A["agent capture-events<br/>events.jsonl"] --> B1[capture_to_baseline] A --> B2[aggregate_correlation] A --> B3["events.jsonl kept as is"] B1 --> D1["baseline.jsonl<br/>+ manifest.json"] B2 --> D2["correlation_train.jsonl<br/>+ manifest.json"] B3 --> D3["events.jsonl<br/>+ manifest.json"] D1 --> T0[train_linux / train_windows] D2 --> T2[train_correlation] D3 --> T1[train_behavior] SC["site corpus export"] --> TS[train_site_model / train_site_rarity] D1 --> TS T0 & T1 & T2 & TS --> R["registry/model/version/<br/>model.onnx, model_metadata.json,<br/>model_record.json"] R --> V[verify_onnx] R --> G[robustness_cli verify]
- The agent records events with
agent capture-eventson a host doing normal work. The scenarios repository provides the benign and malicious capture workloads. Raw captures are kept outside this repository. - A dataset builder turns the capture into the samples file of one dataset shape, and
synthaea-ml-manifest writerecords its provenance and SHA-256 next to it (datasets.md). - A trainer verifies every manifest it is given, extracts features, holds out a calibration split, fits the forest, sets the conformal threshold, exports ONNX, optionally runs the robustness evaluation, and writes the model record (training.md).
verify_onnxloads every registry model under onnxruntime and re-verifies the hashes its record binds;robustness_cli verifyholds its robustness cards to the gate (registry.md, evaluation.md).- A model reaches the agent as content, separate from the agent binary. The agent reads
model.onnxandmodel_metadata.jsonfrom a registry-shaped directory and degrades to "no ML evidence" when a model is missing or invalid.
Parity with the agent
Every feature vector is defined twice: in synthaea_ml/features/ and in the agent's
crates/ml. A model trained on Python vectors scores correctly on the endpoint only if Rust
builds the same vector from the same event, so each extractor is pinned by a golden file that
both test suites read. The same holds for the canonical command-line form, the ONNX inference
path and score attribution. features.md lists each seam and
testing.md its fixture.
Known gaps
- None of the committed registry models meets the ship criteria. The two T0 models predate the model record and serve as verification inputs (registry.md).
- No entry point writes scenario replays into a model record yet;
run_replayexists as a library function (evaluation.md). - No T1 or T2 model has been trained on a committed dataset. The T2 trainer still accepts a deprecated no-argument mode that reads and writes inside the package (training.md).
- The rarity feature has a Rust extractor, but no agent scorer loads an 11-feature model yet (features.md).