Skip to main content

Quark Trace — ML traceability and audit trail library. Part of the Quark suite.

Project description

Quark Trace

A Python library for ML traceability. Provides structured logging of machine learning project metadata, experiment history, and audit trails across interchangeable storage backends.

Designed to integrate with federated learning frameworks and other distributed ML pipelines.


Status

Active development. Core modules — FactSheet, TraceLog, Project, and the JSON storage backend — are implemented.


Architecture

user-defined YAML file
        |
        v
Pydantic schema (validation)
        |
        v
FactSheet (identity + amendment trail)
        |
        v
Project (unified entry point)
        |
        v
TraceLog (append-only trace records)
        |
        v
StorageBackend (interchangeable: JSON, SQL, IPFS, Blockchain)

The library is organized around three layers:

  • Identity layerFactSheet defines the static project identity, loaded from YAML and validated by Pydantic. Supports controlled amendments with a full version trail.
  • Trace layerTraceLog maintains an append-only log of discrete lifecycle events. Each call to project.log() produces one immutable TraceRecord.
  • Storage layerStorageBackend is an abstract interface. All persistence is delegated to a backend. No component is coupled to a specific storage mechanism.

Module Structure

quark_trace/
    project.py                  # Unified entry point
    fact_sheet/
        __init__.py
        schema.py               # Pydantic validation models
        fact_sheet.py           # FactSheet class
        loader.py               # YAML -> Pydantic -> FactSheet
    trace/
        __init__.py
        record.py               # TraceRecord — single immutable entry
        trace_log.py            # TraceLog — append-only log
        backends/
            __init__.py
            base.py             # Abstract StorageBackend
            json_backend.py     # File system backend (JSONL + JSON)

Components

Project

The single object the consuming framework interacts with. Binds a FactSheet and a TraceLog under one interface.

from quark_trace.project import Project
from quark_trace.trace.backends.json_backend import JsonBackend

# First run — loads YAML, persists fact sheet, starts trace log
project = Project.load(
    fact_sheet_path="fact_sheet.yaml",
    backend=JsonBackend(path="logs/")
)

# Resume an existing project without re-loading the YAML
project = Project.resume(
    project_id="fl-project-001",
    backend=JsonBackend(path="logs/")
)

Logging

All trace logging goes through a single method on Project:

project.log(stage="experiment_start", rounds=10, clients=5)
project.log(stage="client_round", round=1, client_id="client_03", loss=0.21)
project.log(stage="aggregation_round", round=1, aggregated_loss=0.19)
project.log(stage="experiment_end", final_loss=0.11, duration_seconds=342)

Retrieving History

records = project.history()

FactSheet

Defines and tracks the static identity of an ML project. Loaded from a user-defined YAML file. Supports controlled amendments with a full version trail.

YAML template:

project_id: "my-project-001"   # optional — auto-assigned if omitted

purpose: "Detect fraudulent transactions in real-time"
domain: "Financial Services"
ml_type: "supervised"

algorithm:
  - name: "XGBoost"
    variant: "XGBClassifier"

input:
  - name: "transaction_features"
    type: "tabular"
    description: "Normalized transaction records"

output:
  - name: "fraud_label"
    type: "label"
    description: "Binary fraud classification"

performance_metrics:
  - "accuracy"
  - "precision"
  - "recall"
  - "f1"

bias:
  type: "historical"
  affected_group: "low-income demographics"
  severity: "medium"
  notes: "Training data reflects prior biased approval patterns"

stakeholders:
  - name: "Jane Doe"
    role: "ML Engineer"
    contact: "jane@example.com"

Schema:

Field Type Description
sheet_id str Unique identifier for the fact sheet
project_id str Parent project identifier
version int Increments on each amendment
created_at str ISO-8601 timestamp of initial creation
amended_at str ISO-8601 timestamp of last amendment
amendment_log list Full history of all amendments
purpose str Description of the project's objective
domain str Application domain
ml_type str supervised, unsupervised, semi-supervised, self-supervised, reinforcement
algorithm list[dict] Algorithm name and optional variant
input list[dict] Input modalities and types
output list[dict] Output types and descriptions
performance_metrics list[str] Metric names tracked in this project
bias dict Structured bias declaration with type, affected group, severity, and notes
stakeholders list[dict] Named stakeholders, roles, and contacts

TraceRecord

A single immutable trace entry. Frozen at the object level — no field can be modified after creation.

Field Type Description
record_id str Unique identifier for this record
project_id str Parent project identifier
stage str Lifecycle stage label
timestamp str ISO-8601 UTC timestamp
payload dict Arbitrary stage-specific data

Storage Backends

All backends implement the StorageBackend abstract interface:

Method Description
save(record) Persist a single trace record
load_all(project_id) Retrieve all trace records for a project
save_fact_sheet(fact_sheet) Persist the fact sheet for a project
load_fact_sheet(project_id) Retrieve the fact sheet for a project

JSON Backend stores data as two files per project:

File Format Description
{project_id}.jsonl Newline-delimited JSON Append-only trace records
{project_id}.fact.json JSON Fact sheet

Design Principles

  • The Project object is the single interface for consuming frameworks. Internal components are not exposed.
  • Storage backends are interchangeable. Switching from JSON to SQL or IPFS requires no changes to Project, FactSheet, or TraceLog.
  • The fact sheet is written once and amended with a version trail — never silently overwritten.
  • Trace records are strictly append-only and immutable at the object level.
  • All structures are JSON-serializable by design.
  • YAML is the primary interface for fact sheet definition. Direct construction is not the intended path.

Roadmap

  • FactSheet class with amendment trail
  • Pydantic validation schema
  • YAML loader
  • TraceRecord — immutable trace entry
  • TraceLog — append-only log
  • StorageBackend abstract interface
  • JsonBackend — file system implementation
  • Project — unified entry point
  • SqlBackend
  • IpfsBackend
  • BlockchainBackend
  • Stage schema validation layer
  • Query and filtering API for trace history

License

To be defined.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quark_trace-0.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quark_trace-0.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file quark_trace-0.1.0.tar.gz.

File metadata

  • Download URL: quark_trace-0.1.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quark_trace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0d62a880af4085d27afbc1ee258559e7b91d66ecdc13fdac12d6312604e5190
MD5 c4e14d1240b580a219010e03c82e5e7f
BLAKE2b-256 fc0e26e5da0ceaa2958d350ba335f015d719afcfe953f4af3f093cc7826e813c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quark_trace-0.1.0.tar.gz:

Publisher: publish.yml on Annotated-Thought/quark-trace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quark_trace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: quark_trace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quark_trace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33ed22ae5f16f118b5681b8540de9684890c5bc90574bc0fcf1cfbcf0f0d6ba3
MD5 23b4bf6a91faed8cfae958dc0b1ceb1b
BLAKE2b-256 f43051b9d94ce73713137f05dcef50da5d218d8468a781a2645f27f5038b2146

See more details on using hashes here.

Provenance

The following attestation bundles were made for quark_trace-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Annotated-Thought/quark-trace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page