cu29-export
Copper log export helpers and Python-facing log readers.
This crate is for offline analysis of .copper logs. That distinction matters:
using Python here is fine because it does not put Python on the runtime hot path.
If you want to run task logic in Python, that is a different feature entirely:
see
cu-python-task.
What This Crate Provides
- the
run_cli::<P>()logreader entrypoint used by Copper examples and templates - structured log export helpers
- CopperList export helpers
- profile-guided scheduling from a recorded run
- optional Python bindings for iterating logs without going through JSON first
Payload descriptions come from the native recipes saved by the application at startup. One static catalog shares its schema graph across compiled missions. Application metadata supplies configuration and mission names; each data section selects its run and numeric mission slot map.
Standalone catalog tools
Build cu29-logextract with self-describing-logs, or use the workspace helper:
The catalog supplies payload descriptions and both Compact/Flat metadata layouts.
The standalone reader needs the recorded slabs and catalog. catalog shows slot,
schema and storage-unit information, with Catppuccin Mocha colors controlled by
--color auto|always|never. RON/JSON output contains the complete catalog graph and
canonical config. Record output supports a streamed JSON array, JSONL and escaped
CSV. Machine output stays clean; diagnostics use stderr.
Deep fsck requires a catalog and decodes every captured payload to exact section exhaustion. Invalid/truncated records return an error with their recorded location. Plain standalone fsck checks structure and common streams and reports the number and compressed and decompressed sizes of embedded catalogs. Compressed size includes the compression integrity footer; decompressed size is the encoded catalog body before compression. Deep validation adds decoded CopperList and captured-payload counts and encoded payload bytes. A table lists every captured task and message type, sorted by total bytes, with counts, share of payload storage, mean size, and size range. Payload sizes count native payload bytes, excluding CopperList metadata.
App logreaders retain typed defaults; extract-copperlists --decoder catalog selects
the standalone decoder when built with self-describing-logs. Read the
self-describing log contract for output shapes,
bounds and Rust APIs. Try just in examples/cu_self_describing_logs.
Profile-Guided Scheduling
The typed logreader also turns a representative run into ranked, exact CuPlan
candidates:
See Profile-Guided Scheduling for the contract, generated artifacts, compile-time application step, and measured comparison workflow.
Selecting a Recorded Run
A unified log can contain multiple recorded runs after a mission change or an appended restart. Section contexts identify each construction, including runs whose startup lifecycle records have rolled out. Its CopperList IDs and clock can start over independently of the previous run.
Use the application's logreader binary to list the runs and select one:
Indices are zero-based and follow the first retained section of each run. They are distinct
from the recorded instance_id, which can repeat across process restarts.
list-runs reads lifecycle metadata without decoding application payloads.
It shows the mission, application, runtime instance ID, start time, and whether
ShutdownCompleted was recorded.
Single-run logs select their run automatically. Logs from standalone
writers use construction ID zero and are treated as one implicit run.
Multi-run logs require --run for extraction, fsck, statistics, and MCAP
export. The selection includes sections carrying that construction ID and shared
static metadata. Startup timestamps remain unknown when lifecycle records have
rolled out.
The selected run supplies the recorded configuration used by logging codecs.
Statistics also default to that configuration and its recorded mission; --config
and --mission provide explicit overrides. Without a recorded configuration,
statistics use copperconfig.ron. Use a logreader and string index built for the
application version that produced the selected run.
fsck checks CopperList IDs within the selected run, reports decoding errors,
and returns an error for repeated or decreasing IDs and an unclean final log close.
An ID reset at the next Instantiated belongs to that next run.
Python Support
Python support lives behind the python feature and is not supported on macOS in
this workspace.
Python provides these offline reading paths:
1. Generic structured log reading
libcu29_export can expose:
struct_log_iterator_bare(...)struct_log_iterator_unified(...)runtime_lifecycle_iterator_unified(...)
This is useful when you want Python to inspect Copper's structured text logs or runtime lifecycle records.
The example script at
examples/cu_standalone_structlog/readlog.py
shows the basic import pattern.
2. App-specific typed CopperList reading
CopperLists are application-specific, so a Python module that reads them must know the generated tuple type for that application.
The intended pattern is:
- call
gen_cumsgs!("copperconfig.ron")in the application - expose a small
#[pymodule]wrapper in that app - call
copperlist_iterator_unified_typed_py::<YourGeneratedType>(...)
See
examples/cu_flight_controller/src/python_module.rs
and
examples/cu_flight_controller/python/print_gnss_from_log.py
for the reference implementation.
3. Catalog-based Python reading
Enable python and self-describing-logs for complete offline dictionaries:
=
The catalog contains every compiled mission's slot map and is shared by all
recorded runs. The CopperList iterator selects a run and its mission's slot map.
Integers keep their full precision, and corrupt records raise IOError. The Rust
equivalents are catalog::read_value_decode_catalog and
catalog::copperlist_values_reader.
Feature Flags
self-describing-logs: standalone catalog reader,cu29-logextract, and deep fsckpython: Rust-side helpers for embedding/exposing Python log readerspython-extension-module: only for building the Python extension itselfmcap: MCAP export support
Recommendation
Use Python here for post-processing, data mining, notebooks, and analysis scripts. That is a reasonable workflow.
Do not confuse that with putting Python inside a Copper control loop. Offline export and runtime Python tasks have very different tradeoffs.