Skip to main content

Module event

Module event 

Source
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:

  1. Never #[derive(Serialize)] over an existing state type. codewhale_state::Thread carries git_sha, git_branch, git_origin_url, cwd, and path. 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.
  2. Bump SCHEMA_VERSION on any field add, remove, or retype, and never reuse a number. The golden snapshot test fails until you do.
  3. 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.
TurnWall
Per-session histogram of turn wall-clock time.

Enums§

Arch
CPU family.
ColdStartBucket
Cold-start time, bucketed, in milliseconds.
DurationBucket
How long a session lasted, bucketed. Half-open intervals, in seconds.
Event
One telemetry event.
ExitClass
How the process ended.
InstallKind
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::OS reports other rather than shipping a novel string.
SessionSource
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.json pins what v1 was.

Functions§

is_known_provider_id
Whether value is a provider id this build knows.
is_reduced_panic_site
Whether value is in the output space of crate::reduce_panic_site: the literal <dep>, or crates/…​.rs:<line>:<column> over the allowlist charset.
is_release_version_string
Whether value is a release version this schema may carry.