Skip to content
Documentation

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:

OutputWhereConsumed by
model.onnxregistry/<model>/<version>/The agent's ml crate, through onnxruntime
model_metadata.jsonnext to the modelThe agent's scorer: conformal threshold and per-feature bounds
model_record.jsonnext to the modelverify_onnx and the robustness gate: dataset hashes, robustness cards, scenario replays, hyperparameters
card.mdnext to the modelReviewers: purpose, data, metrics, limitations
Golden fixturestests/fixtures/ and the agent's crates/ml/tests/fixtures/The parity tests on both sides
Calibration reportsreports/calibration/The likelihood-ratio constants of the agent's correlator

The models are grouped in tiers by what they score:

TierScoresFeaturesTrainer
T0One command line9 command-line featurestrain_linux, train_windows
T1One process incarnation9 command-line + 8 correlation = 17train_behavior
T2One pid's correlator window8 correlation featurestrain_correlation
SiteOne command line, per tenant9 command-line, or 9 + 2 raritytrain_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

SubpackageResponsibility
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 levelhashing (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
  • data and features use each other: features.t1 reads the canonical command line from data.canonical, and data.common_set builds features.rarity snapshots. Neither imports anything above them.
  • The record types live in registry.records; calibration re-exports ConformalCalibration and FeatureBounds from 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 in training/config.py.
  • tests/test_import_direction.py enforces the two rules that matter most: importing export.verify_onnx loads no synthaea_ml.training module, and importing evaluation.t1_lineage_gain loads no training.train_* script (it may read training.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]
  1. The agent records events with agent capture-events on a host doing normal work. The scenarios repository provides the benign and malicious capture workloads. Raw captures are kept outside this repository.
  2. A dataset builder turns the capture into the samples file of one dataset shape, and synthaea-ml-manifest write records its provenance and SHA-256 next to it (datasets.md).
  3. 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).
  4. verify_onnx loads every registry model under onnxruntime and re-verifies the hashes its record binds; robustness_cli verify holds its robustness cards to the gate (registry.md, evaluation.md).
  5. A model reaches the agent as content, separate from the agent binary. The agent reads model.onnx and model_metadata.json from 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_replay exists 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).