How treqs/roar works
1. What this repo is
Roar is a provenance and artifact-registration system for ML/data workflows. Its core architectural unit is a content-addressed DAG of sessions, jobs, and artifacts stored locally, with optional publication to GLaaS and cloud storage.
2. Top-level layering
The Python package is organized as a layered system: roar/cli handles user commands, roar/application contains use-case orchestration, roar/core defines shared domain models and interfaces, roar/db owns persistence, and roar/integrations wraps external systems. roar/presenters is the output/rendering layer for terminal and TUI views.
3. Local state and persistence
The local source of truth is a SQLite database under .roar/roar.db, initialized by roar init. The DB stores artifact hashes, job records, sessions, labels, collections, and a hash cache, which are then queried by commands like dag, show, status, diff, log, and lineage.
4. Run/observe pipeline
roar run is the main capture path: it launches a command, observes file I/O and execution metadata, and records the resulting job plus inputs/outputs into the local session graph. The runtime layer (roar/execution/runtime) handles bootstrap, injection, tracing lifecycle, signal handling, and backend selection.
5. Native tracing subsystem
Observation is implemented by separate Rust tracer binaries, not by Python alone. The Rust workspace contains multiple backend families: eBPF, preload, and ptrace tracers, plus a proxy service and helper crates; the Python package stages these binaries into roar/bin for runtime discovery.
6. Backend selection and host execution
The architecture treats tracing as pluggable infrastructure. roar/backends/ray, roar/backends/osmo, and roar/backends/local adapt Roar to different execution environments, while the runtime and backend config determine how jobs are submitted, attached, or proxied.
7. Publishing and registration flow
roar register and roar put turn local lineage into a GLaaS registration package, optionally uploading artifacts to cloud storage. The publish application layer assembles lineage, source resolution, job metadata, labels, and visibility/auth context before calling the GLaaS client and storage backends.
8. Artifact acquisition and reproducibility
roar get downloads artifacts from S3/GCS/HF/HTTP sources and records them as source nodes in the local DAG. roar reproduce uses lineage lookup plus environment setup and pipeline execution helpers to reconstruct the steps required to rebuild a target artifact or full session.
9. Query and visualization boundary
Read-only commands are separated from mutation/publish commands. Query services build DAGs, diffs, labels, and lineage views from the DB and current session state, while presenters render those structures in console output or the TUI screens.
10. External integrations
The repo integrates with Git for commit/branch capture and repository context, with cloud/object stores for artifact transfer, with GLaaS for global lineage publication, and with telemetry for coarse usage counters. These integrations are isolated behind dedicated adapters so core lineage logic stays environment-agnostic.
11. Auth, scope, and labels
Authentication and publication scope are first-class boundaries: auth/login manage GLaaS identity, scope determines where lineage is published, and label manages local metadata that can later be synchronized. This keeps user identity and project ownership separate from the provenance graph itself.
12. Build and packaging boundary
The project is a Python package plus Rust workspace, with GitHub Actions building and publishing wheels that include native binaries. Editable/source installs need the Rust artifacts built separately, which is why the repo includes staging scripts and binary-copy actions.
13. What to diagram
The most important diagram is a left-to-right flow from CLI command → application service → core model/repository → DB and integrations → optional publish/download/reproduce endpoints, with the Rust tracer/runtime path drawn underneath run. A second boundary should show the local system versus external services: filesystem, Git, cloud storage, telemetry, and GLaaS.
Main entry points: runtime Runtime · publish/service.py Publish service · db SQLite DB · run/service.py Run service
Components 30
CLI
User commands and entrypoints
- CLI entry · Command registration and top-level CLI wiring
roar/cli/command_registry.py - Run cmd · Launches and captures a command execution
roar/cli/commands/run.py - Query cmds · Read-only DAG, status, show, diff, lineage, and log commands
roar/cli/commands/dag.py - Publish cmds · register, put, scope, auth, login, and related publishing commands
roar/cli/commands/register.py
Application
Use-case orchestration layer
- Run service · Orchestrates capture, bootstrap, and session recording
roar/application/run/service.py - Query service · Builds DAGs, diffs, status, show, and lineage views from local state
roar/application/query/dag.py - Get service · Resolves and downloads remote artifacts into local DAG state
roar/application/get/service.py - Publish service · Prepares registration packages and publishes lineage to GLaaS
roar/application/publish/service.py - Reproduce svc · Looks up lineage and reconstructs execution environment and steps
roar/application/reproduce/service.py - Workflow svc · Generates or coordinates workflow definitions and execution plans
roar/application/workflow/service.py
Core
Domain models and interfaces
- Domain core · Shared models, interfaces, validation, and provenance concepts
roar/core
Persistence
SQLite storage and repositories
- SQLite DB · Database context, schema, and repository layer under .roar/roar.db
roar/db
Execution
Run-time capture and reproduction
- Runtime · Injection, tracing lifecycle, bootstrap, signals, and backend selection
roar/execution/runtime - Provenance · Collects file, process, package, and dataset metadata during runs
roar/execution/provenance/service.py - Rebuild path · Environment setup and pipeline execution helpers for reproduction
roar/execution/reproduction/pipeline_executor.py
Integrations
Adapters to external systems
- Git adapter · Repository context, commit, branch, and readiness discovery
roar/integrations/git/context.py - Storage · Cloud and memory storage backends for upload and download
roar/integrations/storage/publish.py - GLaaS client · Auth, transport, and registration client for publication
roar/integrations/glaas/client.py
Views
Console and TUI rendering
- Presenters · Console rendering, DAG formatting, diffs, and run reports
roar/presenters/dag_renderer.py - TUI · Interactive terminal screens and widgets
roar/tui/app.py
Rust
Native tracers and helper services
- Tracer runtime · Native runtime support and discovery for tracer binaries
rust/crates/tracer-runtime/src/lib.rs - eBPF tracer · eBPF probe and userspace daemon for syscall/file observation
rust/tracers/ebpf/userspace/src/main.rs - Preload tracer · LD_PRELOAD-based interposition tracer and helpers
rust/tracers/preload/src/main.rs - Ptrace tracer · Ptrace-based tracer backend
rust/tracers/ptrace/src/main.rs - Proxy svc · Native proxy service for forwarding and S3 relay
rust/services/proxy/src/main.rs
Other components
- Filesystem · Local working tree, session graph, and captured artifacts
- Git host · Repository metadata and remote origins
- Cloud storage · S3, GCS, and Hugging Face artifact sources and sinks
- GLaaS · Global lineage registration and lookup service
- Telemetry · Usage and product telemetry destination
Connections 36
- CLI entry → Run cmd: dispatches · Registers and routes commands
- CLI entry → Query cmds: dispatches · Routes query subcommands
- CLI entry → Publish cmds: dispatches · Routes auth and publish subcommands
- Run cmd → Run service: calls · Invokes the run orchestration
- Query cmds → Query service: calls · Invokes read-only query services
- Publish cmds → Publish service: calls · Invokes registration and put flows
- Run service → Runtime: bootstraps · Starts injected runtime and tracer lifecycle
- Runtime → Tracer runtime: loads · Selects and launches native tracing runtime
- Runtime → eBPF tracer: selects · Uses eBPF backend when available
- Runtime → Preload tracer: selects · Uses preload backend when available
- Runtime → Ptrace tracer: selects · Uses ptrace backend when available
- Runtime → Provenance: feeds · Passes tracing events into provenance capture
- Provenance → SQLite DB: records · Stores jobs, sessions, artifacts, and hashes locally
- Run service → SQLite DB: reads/writes · Updates local session graph and job records
- Query service → SQLite DB: reads · Builds DAG, diff, status, and lineage views
- Get service → Storage: downloads · Pulls artifacts from remote object/document sources
- Get service → SQLite DB: records · Registers downloaded artifacts as source nodes
- Publish service → GLaaS client: publishes · Sends registration packages and lineage payloads
- Publish service → Storage: uploads · Optionally stages artifacts to cloud storage
- Publish service → Git adapter: uses · Captures commit, branch, and remote context
- Reproduce svc → Query service: looks up · Reuses lineage and DAG query results
- Reproduce svc → Rebuild path: drives · Runs environment setup and execution reconstruction
- Workflow svc → Domain core: models · Builds workflow requests and results against core contracts
- Presenters → Query service: renders · Converts query results to terminal output
- Presenters → SQLite DB: formats · Consumes stored DAG and diff structures
- TUI → Presenters: uses · Interactive screens reuse presenter formatting and data
- Publish service → Domain core: maps · Assembles domain models, labels, and registration DTOs
- Run service → Domain core: depends on · Uses shared provenance and run domain contracts
- SQLite DB → Domain core: implements · Repository and service interfaces are defined in core
- GLaaS client → GLaaS: connects · Publishes to the external GLaaS service
- Storage → Cloud storage: connects · Uploads and downloads from cloud/object stores
- Git adapter → Git host: connects · Reads repository metadata from Git
- Presenters → Filesystem: reads · Displays local DAG and run state
- Runtime → Filesystem: observes · Captures file I/O and execution effects
- Proxy svc → Cloud storage: relays · Forwards traffic and S3 access for proxy modes
- Publish service → Telemetry: reports · May emit coarse usage telemetry during publish flows