Expand description
The wire schema. This module is the whole of what may leave the machine.
Every field below is an integer, a boolean, or a closed enum string,
except exactly three bounded strings: app_version, git_sha, and
panic_site. Each of those three has a written rule and a test pinning the
rule. There is no free-form string type here and no open-keyed map, which is
what makes “aggregates and events, never content” a property the compiler
and the test suite can enforce rather than a promise.
Bounded is not the same as built bounded. These types are also a
deserialization target: flush reads buffer.jsonl back off disk and
hands the lines to serde, which will fill site, previous_version, and
providers with any string the file contains. Anything running as the user
can append to that file, $CODEWHALE_HOME is a predictable path, and this
product executes model-authored shell commands. Event::is_bounded is
therefore checked on the drain path, and it is the reason the guarantee
above survives contact with the filesystem.
Three standing rules for anyone extending this file:
- Never
#[derive(Serialize)]over an existing state type.codewhale_state::Threadcarriesgit_sha,git_branch,git_origin_url,cwd, andpath. A payload builder that accepts one and derives breaches the red lines in a single line. Every struct here is built from scratch with explicit fields. - Bump
SCHEMA_VERSIONon any field add, remove, or retype, and never reuse a number. The golden snapshot test fails until you do. - A new string field needs a clause in
Event::is_bounded, not just a doc comment naming its rule. A rule only the constructor honours is a rule the drain path does not have.
Structs§
- Batch
- The POST body. One per flush.
- Counters
- Feature-use counts for one session.
- Errors
- Error counts for one session.
- Turn
Wall - Per-session histogram of turn wall-clock time.
Enums§
- Arch
- CPU family.
- Cold
Start Bucket - Cold-start time, bucketed, in milliseconds.
- Duration
Bucket - How long a session lasted, bucketed. Half-open intervals, in seconds.
- Event
- One telemetry event.
- Exit
Class - How the process ended.
- Install
Kind - Whether this binary is newly installed, upgraded, or downgraded.
- Libc
- C runtime the binary was compiled against.
- Os
- Operating system family. A closed whitelist, so an unrecognised
std::env::consts::OSreportsotherrather than shipping a novel string. - Session
Source - How a session was started.
- Surface
- Which product surface produced a batch.
Constants§
- SCHEMA_
VERSION - Wire schema version. Bumped on any field add, remove, or retype; never
reused.
crates/telemetry/tests/golden/v1.jsonpins what v1 was.
Functions§
- is_
known_ provider_ id - Whether
valueis a provider id this build knows. - is_
reduced_ panic_ site - Whether
valueis in the output space ofcrate::reduce_panic_site: the literal<dep>, orcrates/….rs:<line>:<column>over the allowlist charset. - is_
release_ version_ string - Whether
valueis a release version this schema may carry.