feat(wizard): add --detect-only headless detection mode - #1056
feat(wizard): add --detect-only headless detection mode#1056ablaszkiewicz wants to merge 2 commits into
Conversation
…to PostHog
Runs the agentic source-maps detection headlessly (doctor-style: auth, scan,
POST, exit — never enters the TUI or agent runner) and upserts the report to
/api/projects/{id}/wizard/repository_detections/. Built for the cloud wizard
run so a connected repository can be scanned in the background; also works
locally with --api-key. Failures (agent error, timeout) are recorded to the
same endpoint so the app can present them.
Hidden flag, unstable contract — same policy as the headless flag.
🧙 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
Results will be posted here when complete. |
One kind identifier flows end to end: POST /api/wizard/detection
{project_id, repository, kind} creates a task and starts the dedicated
detect-repository Temporal workflow, which provisions a sandbox, clones
the repository, and runs the wizard detection program the kind selects
(WIZARD_DETECTION_PROGRAMS registry; error-tracking-source-maps runs
upload-source-maps --detect-only). The wizard posts its report to the
new POST-only repository_detections upsert endpoint under the same
kind, using its cloud-run OAuth token (the wizard_session scope its
grant already carries), so no scope or ceiling changes anywhere.
RepositoryDetection is a generic store: one row per (team, repository,
kind), one typed report serializer shared by all kinds, error variant
for failed runs. The workflow is a sibling of process-task reusing its
activities with none of the agent machinery: no agent server, no PR,
no CI loop, sandbox cleanup guaranteed in finally.
Verified end to end locally: cloud runs against posthog/hedgebox and
posthog/error-tracking-examples completed and stored reports; the
error path stores its failure under the same key.
Wizard side: PostHog/wizard#1056 (must release to npm first).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
One kind identifier flows end to end: POST /api/wizard/detection
{project_id, repository, kind} creates a task and starts the dedicated
detect-repository Temporal workflow, which provisions a sandbox, clones
the repository, and runs the wizard detection program the kind selects
(WIZARD_DETECTION_PROGRAMS registry; error-tracking-source-maps runs
upload-source-maps --detect-only). The wizard posts its report to the
new POST-only repository_detections upsert endpoint under the same
kind, using its cloud-run OAuth token (the wizard_session scope its
grant already carries), so no scope or ceiling changes anywhere.
RepositoryDetection is a generic store: one row per (team, repository,
kind), one typed report serializer shared by all kinds, error variant
for failed runs. The workflow is a sibling of process-task reusing its
activities with none of the agent machinery: no agent server, no PR,
no CI loop, sandbox cleanup guaranteed in finally.
Verified end to end locally: cloud runs against posthog/hedgebox and
posthog/error-tracking-examples completed and stored reports; the
error path stores its failure under the same key.
Wizard side: PostHog/wizard#1056 (must release to npm first).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦔 ReviewHog reviewed this pull requestFound 0 must fix, 2 should fix, 1 consider. Published 3 findings (view the review). |
|
ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
- Dispatch runDetectOnly through runCommandHandler so pre-try/catch throws exit cleanly instead of becoming unhandled rejections - Retry the detection POST (3 attempts, 30s per-attempt timeout, capped backoff) on network errors, 429, and 5xx; fail fast on other 4xx — the upsert is idempotent and guards a 5-minute scan - Reconcile the entry-point docstring with the actual exit-code contract: 0 only on a saved successful detection Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Any reason to not make it a command on its own? Is the detection data specific to sourcemap uploads ? |
|
@hpouillot yes. The detection data is specific to our program. We have a generic |
| } | ||
|
|
||
| /** Best-effort: record the failure server-side so the app can show it. */ | ||
| async function recordFailure( |
There was a problem hiding this comment.
why not capture the exception inside this method instead ?
| }); | ||
| getUI().log.success( | ||
| `Detection saved: ${report.projects.length} project${ | ||
| report.projects.length === 1 ? '' : 's' |
There was a problem hiding this comment.
don't we have pluralize ?
|
@ablaszkiewicz @hpouillot you read my mind. I had a
This way when we see there's a gap in analytics, we can even write scouts to fill gaps An idea I had. I would make it its own command entirely ;) and make it that you can do posthog detect --source-map or smthing (maybe should be by product name) Think about it. This is just me nudging you, please prioritize as you see fit |
|
@gewenyu99 I agree that sounds good but I don't feel that I am the right person to come up with a new standard. I am lacking knowledge about wizard and cloud runs and how this plays together so I feel like I just wouldn't design this well. My wizard knowledge is very narrow and very focused just on our program. I am happy to be a part of discussion tho and happy to migrate our ET detection to that once some standard is established. |
This is a part of a bigger change:
Adds
--detect-onlycommand variant for uploading source maps. This runs only the detection and posts results back to posthog via scoped endpoint,