Repository navigation
feat: send one final telemetry_opted_out event when telemetry is disabled - #1501
ralphstodomingo wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
ce45123 to
0b96db6
Compare
Codex review logStacked on #1500; review the last commit only. Review runs against these claims. Report only a reproducible trace that violates a numbered claim; instances of the disclosed residuals are not findings. A round with no claim violation ends review. Claims
Residuals
|
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. This PR is stacked on #1500: review only the last commit (the opt-out marker), not the identity change beneath it. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| const explicit = process.env.APPLICATIONINSIGHTS_CONNECTION_STRING | ||
| const cfg = parseConnectionString(explicit ?? DEFAULT_CONNECTION_STRING) | ||
| if (!cfg) return | ||
| machineId = id |
There was a problem hiding this comment.
WARNING: Mutating module-level machineId across await TelemetryIdentity.cached() leaks or resets machineId on concurrent init() cycles
recordOptOut() is fired without await (void recordOptOut(...)), so a shutdown() followed by a new init() in the same process (such as across session loops or in test suites) can run concurrently with an in-flight recordOptOut() paused at await TelemetryIdentity.cached() (line 2179). During that window, the new doInit() shares the mutated machineId, and when recordOptOut() resumes at lines 2184–2185 (or in catch at lines 2201–2202), it overwrites machineId = "" and identity = undefined, clobbering the active session's state. Resolve const cachedIdentity = await TelemetryIdentity.cached() before mutating module state so machineId and identity are only set and restored synchronously around toAppInsightsEnvelopes(...).
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| * that never sent telemetry has nothing to mark. */ | ||
| export function readMachineId(): string | undefined { | ||
| try { | ||
| const raw = fs.readFileSync(path.join(dir(), "machine-id"), "utf8").trim() |
There was a problem hiding this comment.
WARNING: readMachineId() uses unbounded readFileSync instead of lstatSync and size-capped reading like getOrCreateMachineId()
In src/altimate/util/machine-id.ts, reading ~/.altimate/machine-id explicitly checks lstatSync(idPath).isFile() and caps reads at 512 bytes via a file descriptor to avoid following symlinks or slurping multi-MB files into memory before regex validation. Here, fs.readFileSync(path.join(dir(), "machine-id"), "utf8") follows symlinks and reads the entire file into memory unrestricted.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
There was a problem hiding this comment.
Fixed in 3032626: readMachineId() now uses readExistingMachineId() from util/machine-id.ts (lstat regular-file check, 512-byte cap, UUID validation), with a test for a corrupt or oversized file.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous Review Summaries (4 snapshots, latest commit ddff5b3)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ddff5b3)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous review (commit d40c562)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous review (commit 6e425e4)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous review (commit 0b96db6)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Reviewed by gemini-4-argon · Input: 85.3K · Output: 1.9K · Cached: 279.8K Review guidance: REVIEW.md from base branch |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b96db6fbc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
0b96db6 to
6e425e4
Compare
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. Round 2: the pushes since round 1 fence the send on a lifecycle generation (the P2 trace), build the envelope from local values, and make the machine-id read bounded; this PR is stacked on #1500, review only the commits above it. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
d40c562 to
ddff5b3
Compare
…bled A machine that has sent telemetry before sends the opt-out once (machine id, version, how it was set, cached user id and tenant) and nothing after; a marker next to the machine id keeps it to once and is cleared when telemetry is re-enabled. Closes #1499 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
… state alone readExistingMachineId() shares the regular-file, size-cap and UUID checks of the minting read; the envelope builder takes the machine id and identity as arguments so recordOptOut() never mutates module state an enabled init may use. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
…utdown The send carries the lifecycle it started in; shutdown() bumps it, so a task still pending when telemetry is re-enabled neither posts nor recreates the marker. Marker removal is best effort, and the suite drops the force flag. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
ddff5b3 to
c858470
Compare
Closes #1499
Stacked on #1500 (user id and tenant on events); review this one after it, or read only the last commit.
What
When telemetry is disabled, a machine that has sent telemetry before sends exactly one final
telemetry_opted_outevent, and then nothing until telemetry is turned back on.telemetry/opt-out.ts: the marker file~/.altimate/telemetry-opted-outnext to the machine id, and a read of the machine id that never mints one.telemetry/index.ts:recordOptOut(source)runs from both disabled branches of init (envfor the environment variables,configfortelemetry.disabled). It stops at once when the marker exists or no machine id exists, applies the same sink rules as a normal init (test runners never reach the production sink), uses the identity cached by an earlier signed-in run without any request, posts one envelope with a 3 s cap, and writes the marker only once the ingest endpoint accepted it, so an offline launch tries again next time. The event carriesmachine_id,cli_version,opt_out_source, anduser_idandtenantwhen they were cached. A normal init clears the marker.track().Why
Telemetry is on by default and can be turned off. An opted-out machine goes silent, which on the dashboards is indistinguishable from a client that stopped emitting, so missing events get investigated as bugs. With the opt-out as the last event, the dashboards can state the opt-out count and attribute the silence that follows. Opt-outs set before the first launch produce no event; the dashboard states that remainder as unknowable.
Verification
bun test test/altimate/telemetry/opt-out.test.ts: 4 tests. The final event and its properties against a stubbed ingest endpoint, with the identity taken from the cache and no request to resolve it; nothing sent afterwards and nothing on a later init; no event and no marker without a machine id; the marker only after a 2xx (a 500 leaves it for the next launch); a normal init removes the marker.tsgo --noEmitclean; oxlint and prettier clean on the new files.Review log (claims and residuals Codex reviews against): #1501 (comment)
🤖 Generated with Claude Code
https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
Summary by cubic
Sends one final
telemetry_opted_outevent when telemetry is disabled, so dashboards can distinguish opted-out machines from clients that stopped emitting. Closes #1499.telemetry-opted-outmarker file next to the machine id.Written for commit c858470. Summary will update on new commits.