Repository navigation
feat(telemetry): track SDK version traits and upgrade posthog-node to v6 - #1616
Conversation
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
|
✅ Security review complete — 3 findings could not be placed on this diff and were posted as a comment below, in 8 min. Add the |
abb0e64 to
34c4a16
Compare
…n_found, and sdk_version_pin
|
✅ Security review complete — 2 findings posted as a review, in 7 min. Add the |
| analytics.setTag('sdk_skills', resolvedIds.join(',')); | ||
| } | ||
| analytics.setTag('sdk_non_default_major', nonDefaultIds.length > 0); | ||
| analytics.wizardCapture('sdk skills resolved', { |
There was a problem hiding this comment.
The new sdk skills resolved event and the sdk_skills / sdk_non_default_major run tags send manifest-derived SDK data without checking discovery consent or --no-telemetry, unlike the same PR's report.ts path.
privacy-consent (not a security vulnerability) (confidence 5/5)
Details
installTraitSkills (called from linear.ts:101 and orchestrator-runner.ts:942) now does three things whatever the run's sharing consent. It emits wizard: sdk skills resolved with unmatched_sdks. It sets the run tag sdk_skills. It sets the run tag sdk_non_default_major. unmatched_sdks is the posthogSdks match key (traits/registry.ts posthogSdks.detect), which lists each PostHog SDK the project's manifests declare, as <ecosystem>:<pkg>@<major>. That is a local discovery result. setTag puts both tags into this.tags, so they ride on every later capture, every exception and the setup wizard finished event.
Nothing in this path checks consent. matchKeys comes from toMatchKeys(getTraits(...)) (run-program.ts:672), and declaredSdks is gated only by the wizard-versioned-sdk-skills flag. The repo treats this class of data as consent-gated everywhere else. tags.ts says discovery-derived tags "leave the machine under the same consent as the discovery report". reportableDetections withholds posthog_sdk_detected unless sharing is granted. This same PR puts the matching has_existing_sdk / sdk_version_found / posthog sdks detected data behind noTelemetry and mayReportDiscovery in report.ts:57,63. program-session.ts documents --no-telemetry as "nothing about the run leaves the machine, whatever the consent".
This is not a security hole. The values are closed-schema: package names from an allowlist plus a major version, sent to PostHog's own analytics project. The old per-skill sdk trait skill resolved event already sent matched skill ids without a consent check. This diff widens that to declared SDKs that match no skill, and to run-wide tags on every later event.
Impact — A user picks "Don't share tools" on the intro (declineSharing sets DiscoveryConsent.Declined), or passes --no-telemetry, with wizard-versioned-sdk-skills on. The run still sends, for example, unmatched_sdks: ["pypi:posthog@2"], and stamps sdk_skills / sdk_non_default_major onto every later event. The user explicitly opted out of sharing this discovery data.
Fix — Gate the event and the tags on maySendDiscovery(session). For example, callers pass a reportDiscovery: boolean (or a tagDiscovery-style deferred setter) into installTraitSkills:
if (reportDiscovery && (declaredSdks.length > 0 || matched.length > 0)) {
// setTag + wizardCapture as now
}Or route the tags through tagDiscovery(session, setFrameworkContext, {...}), so they apply only once sharing is granted, as the report.ts half of this PR does.
Agent-driven security review. Not visible from the repo: whether wizard-versioned-sdk-skills is rolled out to interactive users who decline sharing. The code path is traced end to end.
There was a problem hiding this comment.
Already fixed in e4fcfb07. installTraitSkills now defaults reportTelemetry to false and guards setTag and wizardCapture behind it, while linear.ts and orchestrator-runner.ts pass maySendDiscovery(session()).
| versions.add(`${sdkId}@${majorPart}.${minorPart}`); | ||
| if (EXACT_PIN_SPEC.test(spec)) { | ||
| pinKinds.add('exact'); | ||
| } else if (intersects(range, `>=${majorNum + 1}.0.0`)) { |
There was a problem hiding this comment.
An SDK version range can make discovery telemetry abort the wizard
non-security-availability (confidence 4/5)
Details
summarizePosthogSdks constructs a new range by adding one to the parsed major without guarding overflow or catching parser exceptions. For >=9007199254740991.0.0, declaredRange and declaredFloor (utils/semver.ts:58-83) return a valid range and floor, but this line constructs >=9007199254740992.0.0; intersects throws TypeError: Invalid major version. A concrete source is gem 'posthog-ruby', '>= 9007199254740991.0.0' in Gemfile, accepted by manifests/rubygems.ts:2-10 and retained by walk.ts:251-264.
Impact — a repository author can make a normal sharing-enabled wizard run fail through best-effort telemetry. reportDiscovery calls this synchronously at report.ts:65, before its credential/report guards, without isolating a summarization failure; its callers include the intro's Continue action (tui/store.ts:550-556) and program setup (run-program.ts:403). This is a local reliability issue, limited to runs on that repository; no credential theft or shared-service denial of service is demonstrated.
Fix — handle the maximum major before constructing the next-major comparator, and make version summarization fail softly per entry when any semver operation throws. Treat an unsupported spec as unversioned rather than failing setup, and add this boundary case as a regression test.
Agent-driven security review. The exception was reproduced using the actual changed functions with installed semver 7.8.5; the lockfile's semver 7.7.1 is not installed in this checkout.
There was a problem hiding this comment.
Already fixed in e4fcfb07. summarizePosthogSdks now checks Number.isSafeInteger(nextMajor) and catches per-entry semver failures as unversioned, reportDiscovery isolates summary errors, and posthog-sdks.test.ts covers Number.MAX_SAFE_INTEGER.
johncwaters
left a comment
There was a problem hiding this comment.
Verdict: APPROVE WITH NITS
See inline comments.
Automated review by Glimmervoid. Not written by a human
| }; | ||
|
|
||
| const EXACT_PIN_SPEC = | ||
| /^(?:(?:==|=)\s?v?\d+(?:\.\d+){1,2}|v?\d+\.\d+\.\d+)(?:[-+.a-zA-Z0-9]+)?$/; |
There was a problem hiding this comment.
[code/logic] MEDIUM
EXACT_PIN_SPEC counts any bare x.y.z as exact, and summarizePosthogSdks() applies it without checking manifest.ecosystem. Cargo reads a bare version as caret, so posthog-rs = "0.3.5" means ^0.3.5 and should land as major_range. Right now every Rust project reports sdk_version_pin: exact, which skews the pin-style numbers this PR exists to collect.
Suggest skipping the bare-version branch when the ecosystem is cargo (only =0.3.5 is exact there) and adding a Cargo "0.3.5" case to posthog-sdks.test.ts. The current exact cases are all npm or PyPI.
Automated review by Glimmervoid. Not written by a human
There was a problem hiding this comment.
Fixed in 99ecdfd2. isExactPin skips bare x.y.z matching when manifest.ecosystem === 'cargo', so Cargo bare versions classify as major_range while =x.y.z stays exact. Added both cases to posthog-sdks.test.ts.
| const versions = new Set<string>(); | ||
| const pinKinds = new Set<Exclude<SdkVersionPin, 'mixed'>>(); | ||
|
|
||
| for (const manifest of manifests) { |
There was a problem hiding this comment.
[architecture/twin-logic] MEDIUM
Open question more than a bug. summarizePosthogSdks() repeats the package filter, the declaredRange/declaredFloor parse and the major split from posthogSdkVersions(), and the two already disagree: line 88 filters to VERSIONED_ECOSYSTEMS (Hex left out, per the comment at line 71) while this loop takes every manifest. The scope differs too: summarizeRunSdks in report.ts reads every manifest under runProject/, and the registry reads manifestsOf(session, projectPath).
So a Hex posthog dep shows up in sdk_version_found and detected_sdk_count but never in sdk_skills or unmatched_sdks. If the plan is to join the discovery tags against the skill tags in insights, they won't line up. If the split is intended, ignore this. If not, one parser that returns every detected SDK with a versioned flag and its pin kind could feed both, or sdk_version_found could come from the same DeclaredSdk[] that registry.ts builds.
Automated review by Glimmervoid. Not written by a human
There was a problem hiding this comment.
The split is intentional, so leaving the code as is. summarizePosthogSdks captures discovery telemetry across all ecosystems (including RubyGems, Composer, Hex, and unversioned specs) and sub-manifests under runProject (matching toolsUnder), whereas posthogSdkVersions is scoped to VERSIONED_ECOSYSTEMS and the single project directory for skill resolution.
Problem
Telemetry doesn't track which PostHog SDK versions, pin styles, or versioned skills runs hit, and the repo is still on
posthog-nodev5.Changes
src/services/project-discovery/traits/sdks.ts(summarizePosthogSdks()) without leaking local paths, patch versions, or raw specs, and emit oneposthog sdks detectedevent plus run tags (has_existing_sdk,detected_sdk_count,sdk_version_found,sdk_version_pin) per session insrc/services/project-discovery/report.ts(reportDiscovery()) behindmayReportDiscoveryand!noTelemetry.sdk trait skill resolvedevents with onesdk skills resolvedsummary event andsdk_skills/sdk_non_default_majorrun tags insrc/agent/runner/shared/trait-skills.ts.posthog-nodefrom^5.45.2to^6.0.5(latest release past pnpm's 7-dayminimumReleaseAge), updatesrc/shared/utils/analytics.tsfor v6 and route'error'events tologToFile()so warnings don't break TUI or headless output, and attach an'error'listener beforeshutdown()insrc/tui/tools/mcp/services/seed-events.tssoseedDemoEvents()still rejects on failed sends.Test plan
npx tsc -b --forcepasses.posthog-sdks.test.ts,report.test.ts, andtrait-skills.test.ts.pnpm build(includestest:smokeandtest:warlock) passes.eslintandprettier --checkpass on all changed files.