Skip to content

chore(deps): add @posthog/warlock >:)#597

Open
sarahxsanders wants to merge 7 commits into
mainfrom
yara-improvements
Open

chore(deps): add @posthog/warlock >:)#597
sarahxsanders wants to merge 7 commits into
mainfrom
yara-improvements

Conversation

@sarahxsanders

@sarahxsanders sarahxsanders commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

time 2 replace the hand rolled scanner with @posthog/warlock >:)

changes

  • warlock is now the L2 engine, replacing hand-rolled scanner src/lib/yara-scanner.ts and its 798-line test file
  • src/lib/yara-hooks.ts now consumes @posthog/warlock directly. rules are owned by warlock, the wizard owns the policy (how a match maps to block / revert / terminate)
  • warlock comes from npm (0.2.2, pinned exact). It's excluded from the 7-day minimumReleaseAge policy since it published 2026-06-09; the exclusion in pnpm-workspace.yaml can be dropped after 2026-06-16 (i've set a reminder for myself)
  • for triage, src/lib/agent/triage-provider.ts builds a Haiku 4.5 provider from the wizard's existing PostHog gateway auth and threads it into the hooks. Flagged matches run through warlock's triageMatches() to drop false positives before the hook acts
  • chunked scanning instead of truncation: content over 100KB used to be silently cut at the cap (a padding bypass). It's now scanned in overlapping 100KB chunks for full coverage and each flagged chunk is triaged against its own content, so triage always sees the evidence and is never skipped
  • new telemetry for alerting: yara triage overruled fires when triage drops a flagged match (rule/severity/category only. the free-text triage reason can quote scanned content and never leaves the machine), and yara scan chunked fires when oversized content shows up. Both should be rare; spikes are worth a look so I'll subscribe to alerts
  • doc-path posthog_pii suppression now runs before triage, so we don't pay an LLM round trip for matches we're about to discard
  • real session termination: when the scanner hits a terminal violation the PostToolUse hook aborts the agent (same mechanism [ABORT] uses). runAgent returns YARA_VIOLATION and the runner shows "Security violation detected." Previously the hook returned a stopReason field the SDK ignores, so "aborted" was a log label, not a behavior
  • with real termination in place, the old output-text sniffing (checkYaraViolation, plus the YARA needles in main's new AgentOutputSignals) is deleted – it could false-positive a whole run as a security violation when the agent merely mentioned a blocked command in chat. yaraViolationReason from the hooks' onTerminate is the single source of truth
  • the jest mock for warlock now has a compile-time drift guard asserting it matches the real package's types. It paid for itself immediately: warlock 0.2.2 added a required matchedStrings field to ScanMatch that the mock didn't have

testing

  • pnpm build clean
  • pnpm test — 737 / 737 passing (includes new tests for chunking, overruled-triage telemetry, and suppression-before-triage)
  • pnpm fix — 0 lint errors
  • End-to-end against a poisoned test app (planted prompt injection in src/main.js) – verified Haiku triage runs, false positives drop, true positives keep, run terminates with Agent error: YARA_VIOLATION, UI shows "Security violation detected"
  • pnpm install resolves warlock from the public npm registry – no GitHub auth, no install-time build
  • Reviewer manual test: drop a PII-flagged capture call into a Write or Edit and confirm the agent gets a revert nudge

sarahxsanders and others added 2 commits June 8, 2026 09:34
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ation

Swap the legacy regex security scanner (yara-scanner.ts) for the
@posthog/warlock YARA-X engine. Flagged matches go through an LLM
triage pass (claude-haiku-4-5-20251001) via triage-provider.ts to
drop false positives before the hook acts.

Critical terminal violations now actually stop the run: the
PostToolUse hook calls onYaraTerminate, which aborts the query's
AbortController -- the same mechanism [ABORT] uses. runAgent returns
YARA_VIOLATION and the runner surfaces "Security violation detected."
Previously the hook returned a stopReason field the SDK ignores, so
"aborted" was a label, not a behavior.

Also restores the "keep PostHog data capture at its defaults" agent
commandment as L0 protection for autocapture / session recording /
opt_out_capturing -- the old scanner's posthog_config rules don't have
a warlock equivalent (those are product-specific concerns; tracked in
wizard #592 + context-mill #173).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

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 error-tracking-upload-source-maps
  • /wizard-ci misc
  • /wizard-ci revenue

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 error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

sarahxsanders and others added 2 commits June 8, 2026 09:46
The restored commandment is a wizard-side band-aid; product-specific
guidance like this belongs in context-mill, not in commandments.ts.
TODO references context-mill#175 for the migration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sarahxsanders sarahxsanders marked this pull request as ready for review June 12, 2026 14:15
sarahxsanders and others added 2 commits June 12, 2026 14:33
…emetry

- chore(deps): swap @posthog/warlock from the private git pin to npm 0.2.2
  (published 2026-06-09); drop the install-time build allowance and the
  TODO(warlock-npm) checklist; exclude warlock from minimumReleaseAge until
  2026-06-16
- replace the 100KB scan truncation with overlapping 100KB chunks: full
  coverage with no silent bypass, and every flagged chunk is triaged against
  its own content so triage is never skipped
- emit 'yara triage overruled' and 'yara scan chunked' telemetry (rule
  metadata only — the free-text triage reason stays local) so overrule and
  oversized-content patterns are alertable
- run wizard-doc posthog_pii suppression before triage, saving an LLM round
  trip for matches that would be discarded anyway
- delete checkYaraViolation output-text sniffing; yaraViolationReason from
  onTerminate is the single source of truth
- add a compile-time drift guard to the warlock mock — it immediately caught
  0.2.2's new required ScanMatch.matchedStrings field, now reflected

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n deletion

Conflict resolution: main's #516 introduced the bounded AgentOutputSignals
parser, including a signals-based checkYaraViolation. This branch deletes
output-text YARA sniffing entirely (yaraViolationReason from onTerminate is
the single source of truth), so the resolution keeps the deletion and adopts
signals for the API-error paths. Also removes the now-dead hasYaraViolation
and YARA needles from output-signals, with a comment explaining why YARA is
deliberately not an output signal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants