Skip to content

fix(self-driving): scope the detected-tools scan to self-driving and filter it - #1028

Merged
gewenyu99 merged 1 commit into
tom/self-driving-detected-sourcesfrom
posthog-code/self-driving-detected-tools-scoped
Jul 29, 2026
Merged

fix(self-driving): scope the detected-tools scan to self-driving and filter it#1028
gewenyu99 merged 1 commit into
tom/self-driving-detected-sourcesfrom
posthog-code/self-driving-detected-tools-scoped

Conversation

@gewenyu99

Copy link
Copy Markdown
Collaborator

Problem

Stacked on #1022 — review fixes, not a rework. Two defects in it:

The scan writes a key another program reads. #1022 stashes the result under the warehouse program's shared DETECTED_WAREHOUSE_SOURCES_KEY. posthog-integration reads that key to build its prompt (warehouseReportInstruction), and prepareRunSession shallow-copies frameworkContext into the composed integrate-run sub-session — so every self-driving run that installs PostHog first silently gained a paragraph in the integration agent's prompt telling it to add a data-warehouse item to the setup report. That makes #1022 not inert. (Its outro is safe: a composed run returns before buildOutroData.)

The list isn't filtered. The scanner matches the whole warehouse catalog, so a routine repo led the issue-tracker ask with Postgres (matched on DATABASE_URL, which the registry itself flags as a deliberate over-match), Stripe and OpenAI — the wall of irrelevant options the ask was meant to lose.

Why

The point of #1022 is that the ask should open with tools the user actually uses. Promoting a database and an LLM vendor to the top of an issue-tracker prompt works against that, and a scan that rewrites a neighbouring program's prompt is a coupling that will surprise whoever debugs the integration flow next.

Changes

  • Self-driving gets its own SELF_DRIVING_DETECTED_TOOLS_KEY + accessor. Nothing else reads it, so the blast radius is exactly the self-driving prompt.
  • Filter to the kinds the inbox connects — exactly the ones feat(self-driving): prioritise codebase-detected tools in the connected-tools ask #1022's description enumerates, no guesses added. Under-inclusion is the safe direction: a kind left out is merely not promoted, and the skill still offers the tool. A guard test fails CI if one of them leaves the source registry.
  • Tag the detected count on every scan, including zero and the error path, so telemetry can distinguish "found nothing" from "never ran".
  • A note on prepareRunSession so the next person composing a program sees the inheritance rule before hitting it.

Not touched: the run-object → closure re-indent, and the prompt block's wording. Ordering and labels stay in the context-mill skill.

Test plan

pnpm build && pnpm test && pnpm fix — 1668 tests pass, 0 lint errors. New/updated tests: the filter drops pg/stripe and keeps Sentry; the existing stash test now asserts what production wrote instead of hand-mirroring a value onto the session; a drift test pins the allowlist to the source registry.

Not run end-to-end against a live self-driving run.

Notes for review

  • Two review points from feat(self-driving): prioritise codebase-detected tools in the connected-tools ask #1022 are not code and are left as comments there: fix(tui): scroll long picker lists so they don't overflow the viewport #978 ("scroll long picker lists so they don't overflow the viewport", already on main) fixed the terminal overflow its Problem section cites, so what's left is choice overload, not rendering; and "safe to land in either order" doesn't hold while STEP 5's prompt text names buckets the current skill doesn't define.
  • I originally flagged source_type: in the prompt as a mislabel. That was wrongkind is documented as the PostHog source_type and self-driving's tools really are created as warehouse sources. No change made.
  • The allowlist is a shadow copy of the registry: a new inbox-connectable kind added there won't be promoted until it's added here too, and no test catches that direction. If it bites, the fix is a field on SourceDetector, not a third copy. Worth reconciling against the skill's actual catalogue by someone who can read it.

Created with PostHog Code

…filter it

The connected-tools scan was stashed under the warehouse program's shared
`DETECTED_WAREHOUSE_SOURCES_KEY`. The integration program reads that key to
build its prompt, and the integrate-run phase inherits a shallow copy of
frameworkContext, so every self-driving run that installs PostHog first also
rewrote the integration agent's prompt. Give self-driving its own key and
accessor; nothing else reads it.

The scan also returned matches from the whole warehouse catalog, so a routine
repo led the issue-tracker ask with Postgres (matched on `DATABASE_URL`),
Stripe and OpenAI. Filter to the kinds the inbox connects, and tag the
detected count on every scan — including zero — so telemetry can tell "found
nothing" from "never ran".

Generated-By: PostHog Code
Task-Id: df870021-4bdf-465b-ba4f-d486c37b97d3
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

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

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

@gewenyu99
gewenyu99 marked this pull request as ready for review July 29, 2026 17:25
@gewenyu99
gewenyu99 requested review from a team as code owners July 29, 2026 17:25
@gewenyu99
gewenyu99 merged commit 9ac7981 into tom/self-driving-detected-sources Jul 29, 2026
14 checks passed
@gewenyu99
gewenyu99 deleted the posthog-code/self-driving-detected-tools-scoped branch July 29, 2026 17:25
@gewenyu99
gewenyu99 restored the posthog-code/self-driving-detected-tools-scoped branch July 29, 2026 17:31
gewenyu99 added a commit that referenced this pull request Jul 29, 2026
…e the leak test

Two follow-ups to #1028, found by running the flow and reading the skill
the ask actually comes from.

The promoted-tools list was hand-written from a PR description rather than
computed, so it was wrong both ways. Recomputed as the intersection of the
options step 5 offers and the kinds this repo can detect: adds Shortcut,
Honeybadger, Raygun, Kustomer, Plain, Canny, Productboard, Snyk and
GoogleSearchConsole, all offered and all detectable, so all previously
dropped on the floor; removes Intercom, which the ask never lists, so
promoting it pointed the agent at a source it cannot create.

The regression test guarding the frameworkContext fix is also missing from
this branch — #1028 was merged at its first commit, so the test pushed
afterwards was orphaned. Restored verbatim, and re-verified it fails when
the shared-key write is reintroduced.

Generated-By: PostHog Code
Task-Id: df870021-4bdf-465b-ba4f-d486c37b97d3
gewenyu99 added a commit that referenced this pull request Jul 29, 2026
Seven multi-line comment blocks from #1028 and #1031 collapsed to a single
line each. Net -71 lines, no behaviour change.

The rationale that was in them belongs in the PR descriptions, which already
carry it: why the key is self-driving's own rather than the warehouse
program's, how the promoted list was computed, and why the count tag fires at
zero and at -1.

Generated-By: PostHog Code
Task-Id: df870021-4bdf-465b-ba4f-d486c37b97d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant