Repository navigation
Commit c0fedf2
authored
feat(telemetry): default-on anonymous telemetry core with a human-only consent boundary (#8300)
* docs(devlog): plan opt-in telemetry and the opencodex.me usage dashboard
Roadmap unit for a six-layer stack: client telemetry core, GUI consent popup, Cloudflare Worker collector, telemetry guide, and the public /dashboard page. Docs only.
* feat(telemetry): add shared wire contract, config schema, and core telemetry engine
* feat(telemetry): add management API routes, CLI commands, and consent prompts
* test(telemetry): add client telemetry test suite and structure ownership
* fix(telemetry): remove state installId leak, harden writes, and preserve declined config on agent import
* docs(devlog): record PR review round 1 decisions for the telemetry stack
* fix(telemetry): apply review round 1 client core, consent, and privacy decisions
* test(telemetry): prove env opt-out days of a long-running proxy are never sent
A proxy started under OCX_TELEMETRY=0 reads the env once and runs no ticks, so it
records ineligibleThroughDay only for its start day. These tests drive the real
background lifecycle with a mocked clock for an opt-out period of several days,
ended by a crash and by a clean stop. They fail on this commit: the first normal
tick sends 2026-11-03, a day the proxy ran opted out.
* fix(telemetry): keep a long-running env opt-out period ineligible until it ends
Observing OCX_TELEMETRY=0 or DO_NOT_TRACK=1 now also persists an
envOptOutActiveSince marker in telemetry-state.json. While it is set no day is
eligible. The opted-out proxy's clean stop, or the first tick that runs without the
opt-out, closes the period: every day through the closing day stays ineligible and
the marker is cleared. A crashed opted-out proxy therefore costs at most the
restart day and never leaks its opt-out days.
SPONSORS.md no longer says opencodex collects no telemetry.
* docs(devlog): plan the env opt-out marker, privacy statement files, and the open SignPath condition
- 000: the no-backfill rule covers env opt-out days and the disclosure day; the
privacy statement changes in layer 2.
- 040: lists every file that carries the published privacy statement (README, seven
translations, both code-signing pages, SPONSORS.md) and says they land in layer 2.
- 060: D2 adds the envOptOutActiveSince marker for a proxy that runs opted out for
days; records SignPath's install-time condition verbatim as an open owner decision
instead of assuming first-run disclosure satisfies it.
* test(telemetry): pin that an unreachable or undeployed collector fails a tick quietly
* test(telemetry): prove zero sends before noticeShownAt across ten undecided days
* fix(telemetry): let ocx telemetry disable create config.json on a fresh install
A decline that arrives before the first start (the Windows installer opt-out, or a
user running ocx telemetry disable first) failed with 'config.json is missing'. A
missing config is now created the way a first start creates it, carrying the
decision; a concurrent first start that wins leaves a file to patch instead.
* docs(devlog): record the owner's SignPath decision (D21) and the Windows installer layer
* fix(telemetry): hold a pre-config decision instead of creating config.json
b4dd934 created a full default config.json when telemetry was declined on a
fresh install, so the next ocx init kept the "existing" config and skipped
provider setup. The Windows installer opt-out and the dashboard's first-run popup
reach the same path; the popup even failed with 503 there.
A decision made before config.json exists is now held as pendingDecision in
telemetry-state.json. withPendingTelemetryDecision applies it wherever consent is
resolved (scheduler ticks, the status route, the CLI prompt) until a decision is
written into the config, which clears it. Tests: disable then init still sees a
missing config, and the decline survives a config created later; a dashboard
PUT on a fresh install returns 200 without writing config.json (503 before).
Also count an id minted after an opt-out as a returning install (everReported),
reuse isTelemetryEnvOptOut in background-lifecycle, and say in the disclosure
that env opt-outs must reach the proxy's own environment.
* docs(telemetry): match the privacy statement and AGENTS_INSTALL to the code
The statement no longer says telemetry can be turned off "at install time in that
prompt"; the Windows installer option arrives in the next layer. AGENTS_INSTALL
says ocx config set/unset telemetry refuse every caller, which is what the code does.
* fix(config): keep a telemetry decision on disk through a live settings save
The CLI and the consent route write telemetry consent to config.json while a proxy
may hold an older in-memory config. A later settings save from that proxy dropped a
decision the snapshot never had, so the install fell back to awaiting-notice and the
user was asked again. saveConfigPreservingClaudeCode now carries the on-disk
telemetry block into the write and adopts it in memory. Failing-first test in
tests/config/telemetry-live-save.test.ts.
* fix(telemetry): keep a running opted-out proxy's days unsent, fail closed on bad state, and stop leaking the scheduler into server start
From the round-2 privacy and code reviews of #8300:
- Two proxies can share one home. An opted-out proxy now records its pid in
envOptOutOwners; a tick without the opt-out ends the period only once no recorded
owner is alive and otherwise extends ineligibleThroughDay to today, and a clean stop
always covers its stop day. Failing-first: the second proxy sent 2026-11-03 while
the first still ran opted out.
- A telemetry-state.json that exists but cannot be read stops sending
(state-unreadable) instead of reading as empty and reopening opt-out days.
- readTelemetryInstallId re-checks the file before trusting its memo, so an id
deleted by another process is never reused or rewritten.
- State code moved to src/telemetry/state.ts; background-lifecycle imports only it,
so the scheduler, aggregation and sender load only when telemetry can run.
- GET /api/telemetry reads consent from disk like the scheduler, and reuses a day's
preview aggregate for 10 minutes because the dashboard panel polls it.
- Removed the migration of a state key no release ever wrote; AGENTS_INSTALL names
tty_required and DO_NOT_TRACK; plan 010/000 wording.
* fix(config,telemetry): carry validated on-disk consent through every whole-config save, and keep an unreadable state file's protection
From the round-3 reviews of #8300 (all P3):
- saveConfig now carries the on-disk telemetry block like the live save does, so a
decline written by another process between a load and a save is never rolled back.
- Both saves carry the block only when it validates; a malformed hand edit is dropped
(as a load drops it) instead of being adopted into the live config, which made
unrelated route validations fail. Shared helper: src/config/telemetry-carry.ts.
- A writer that replaces an unreadable telemetry-state.json starts from 'nothing
through today may be sent', and the status preview reports nothing eligible
while every tick refuses to send.
Failing-first tests in tests/config/telemetry-live-save.test.ts and
tests/usage/usage-telemetry-client.test.ts.
* fix(telemetry): never overwrite an unreadable state file after a send, and never let a stale save accept over an unread config
From the round-4 reviews of #8300 (all P3; the first three reproduced):
- The pre-send recheck reads strictly and refuses when telemetry-state.json has become unreadable;
the bookkeeping writes after a send or a Retry-After leave such a file alone. Before, they rewrote
it from an empty state, and a later tick sent days covered by an env opt-out.
- A whole-config save over a config.json that exists but cannot be read keeps only a snapshot
decline; any other block is dropped, so a stale accept can no longer replace an unread decline.
- A proxy running under an env opt-out records itself again every 6 hours, so a state file rebuilt
after corruption (which forgets envOptOutOwners) learns it again.
- The status snapshot reports stateUnreadable, and ocx telemetry status says sending is paused.
Failing-first tests in tests/usage/usage-telemetry-client.test.ts and tests/config/telemetry-live-save.test.ts.
* docs(privacy): name the per-day install hash in the privacy statement
The payload carries installDayHash (sha256 of the install id and the day), which the dashboard popup lists; the README privacy line (and its seven copies) and the code-signing privacy section now name it too. readme/i18n-manifest.json records the resynced README hash.
* fix(config,telemetry): a save that creates config.json never introduces a telemetry decision
From the final privacy review of #8300:
- [P2] Without config.json, a whole-config save wrote the caller's in-memory telemetry block. A
dashboard accept adopted into a config-less proxy, then "ocx telemetry disable" (held as the
pending decision), then any settings save created config.json with the stale accept, and the
config's decision outranks the pending one, so sending resumed. Without a readable config.json
only a snapshot decline survives now; the held decision or the notice applies.
- [P3] A recorded decision rebuilds an unreadable telemetry-state.json, which otherwise paused
sending for good; the status line says how. Any rebuild keeps every day through the UTC day six
hours from now unsent (TELEMETRY_ENV_OPT_OUT_REFRESH_MS), the window in which a forgotten opted-out
proxy records itself again.
- [P3] The CLI notice names the per-day install hash, release channel and first-report flag, and
the privacy statement (README and its seven copies, code-signing en/tr) lists every field sent.
Failing-first tests in tests/config/telemetry-live-save.test.ts and tests/usage/usage-telemetry-client.test.ts;
the live-save tests now create a config holding a decision the way a person's decision reaches it.
* ci: approve the skill-surface generator change in the release evidence policy
Layer 2 adds the telemetry command root to scripts/generate-ocx-skill-surface.ts, a file dev pins in .github/scripts/release-evidence-policy.json since #8345. Following the procedure in release-evidence.cjs, a new ci v1 entry copies the latest one with only that file's blob updated (git hash-object --no-filters: 750ea21 -> 155e866); older entries stay for historical revisions. node .github/scripts/release-evidence.cjs policy-check passes, and the gates step's release tests pass 68/68.
* fix(telemetry): read consent only from the telemetry block, and fail closed on untrustworthy state
- [P2] resolveTelemetryStatus treated a whole config without a telemetry key as the telemetry
block, so "ocx config set noticeShownAt <date>" (allowed for agents; only telemetry.* is refused)
turned sending on for an undecided install without anyone seeing the notice. Reproduced end to
end with the CLI under CI=1: status went awaiting-notice -> default-on. Consent is now read only
from config.telemetry, and the parameter type no longer accepts a bare block.
- A telemetry-state.json lstat error other than ENOENT, or an opt-out field that is present but
invalid (ineligibleThroughDay, envOptOutActiveSince, envOptOutOwners), marks the file unreadable
instead of reading it as empty.
- The rebuild of an unreadable state file during a decision is best effort, so a decision that is
already saved never ends in an error (a state path that is a directory threw EISDIR).
- The sender refuses redirects, so a report never goes to another host.
Failing-first tests in tests/usage/usage-telemetry-client.test.ts (4 failed before the fix).
* fix(telemetry): keep a held decision out of a newly created config.json
A dashboard accept on a fresh install is held in telemetry-state.json, but
the route also copied it into the running config. After a later
`ocx telemetry disable`, initializePersistedConfigIfMissing (reached by
PUT /api/subagent-models and account selection) wrote that stale accept
into the new config.json, which outranks the held decline.
Creating config.json now runs carryPersistedTelemetry with no file, so only
an in-memory decline survives, and the route no longer adopts a decision it
only held as pending. Recording an opted-out owner also drops dead pids and
stays within the 64 entries a reader accepts.
* fix(telemetry): fail closed on a malformed held decision
A pendingDecision that is present but invalid was silently dropped, so a
damaged held decline could let a notice-only config send under default-on
consent. A held decline with a damaged timestamp now still applies (dated
by noticeShownAt or the file time), and any other malformed held decision
makes telemetry-state.json unreadable, which blocks sending until a
decision rebuilds it.
* docs(structure): map the telemetry consent, carry and lifecycle files to telemetry.md
* ci: retrigger on current dev
* docs(skill): regenerate the surface counts after merging dev1 parent 2bf8ec6 commit c0fedf2
63 files changed
Lines changed: 5397 additions & 38 deletions
File tree
- .github/scripts
- devlog/_plan/261107_telemetry_dashboard
- docs-site/src/content/docs
- reference
- tr/reference
- readme
- scripts
- test-layout
- skills/ocx/references
- src
- cli
- config
- schema
- server
- management
- telemetry
- types
- structure
- tests
- ci-workflows
- cli
- config
- fixtures
- server
- usage
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
209 | 241 | | |
210 | 242 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
55 | 66 | | |
56 | 67 | | |
57 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
| 499 | + | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| |||
0 commit comments