Skip to content

feat: trigger DRS prompt generation during LLMO onboarding#1781

Merged
dzehnder merged 15 commits intomainfrom
feat/drs-webhook-integration
Feb 27, 2026
Merged

feat: trigger DRS prompt generation during LLMO onboarding#1781
dzehnder merged 15 commits intomainfrom
feat/drs-webhook-integration

Conversation

@dzehnder
Copy link
Copy Markdown
Contributor

@dzehnder dzehnder commented Feb 5, 2026

Summary

Adds a DRS client to trigger prompt generation jobs during LLMO onboarding (LLMO-2656) and defers llmo-customer-analysis to DRS completion (LLMO-1819).

  • DRS Client (src/support/drs-client.js): HTTP client for submitting prompt generation jobs to DRS

    • Submits jobs with provider prompt_generation_base_url
    • Passes site metadata (site_id, imsOrgId, brand, base_url, region) and source: 'onboarding'
    • Fetches target audience from the site's brand profile, falls back to a default if unavailable
    • Non-blocking: onboarding completes successfully even if DRS submission fails
  • Onboarding Integration (src/controllers/llmo/llmo-onboarding.js): Calls DRS after all critical onboarding steps complete (org/site creation, entitlement, SharePoint, audits). No longer triggers llmo-customer-analysis directly — that is now triggered by the audit-worker when DRS completes.

Full flow

api-service onboarding
  → submit DRS job (source: 'onboarding', site_id, brand, etc.)
  → DRS processes → SNS JOB_COMPLETED (presigned URL)
  → audit-worker: fetch → write JSON + parquet → trigger llmo-customer-analysis

Environment Variables Required

DRS_API_URL=https://drs-api.example.com/api/v1
DRS_API_KEY=<from-ssm>

Related PRs

Test plan

  • Unit tests for DRS client (7 tests)
  • Unit tests for onboarding integration with DRS (3 tests)
  • 100% branch coverage on changed files
  • E2E: onboarding → DRS job created → completes → audit-worker triggers llmo-customer-analysis

🤖 Generated with Claude Code

dzehnder and others added 2 commits February 5, 2026 17:12
…O-2655, LLMO-2656)

- Add DRS webhook receiver endpoint (/hooks/drs/:hookSecret/prompt-generation)
  - Validates JOB_COMPLETED events from DRS
  - Queues llmo-prompt-import messages for async processing
  - Returns 202 Accepted on success

- Add DRS client for submitting prompt generation jobs
  - Integrates with LLMO onboarding flow
  - Submits jobs with webhook callback URL for completion notifications
  - Non-blocking - onboarding continues if DRS submission fails

- Add OpenAPI specs and comprehensive tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add DRS webhook route to route test expectations
- Add processDrsPromptGenerationHook to mock hooks controller
- Add createMockDrsClient helper function
- Add mockDrsClient option to createCommonEsmockDependencies
- Add test for DRS client not configured scenario
- Add test for DRS job submission failure scenario
- Update existing onboarding test to include DRS mock

This improves test coverage for the DRS integration code in
llmo-onboarding.js (lines 1054-1074).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 5, 2026

This PR will trigger a minor release when merged.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

dzehnder and others added 3 commits February 9, 2026 16:03
Change DRS webhook authentication from path-based secret to API key
header authentication for better security and consistency with DRS APIs.

Changes:
- Replace hookAuth with apiKeyAuth for DRS webhook endpoint
- Route changed from /hooks/drs/:hookSecret/... to /hooks/drs/...
- DRS client now sends webhook_api_key in payload for DRS to use
- Update tests for new authentication pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update DRS client tests to use DRS_CALLBACK_API_KEY instead of DRS_WEBHOOK_SECRET
- Update webhook URL expectation to static path (no :hookSecret param)
- Add assertion for webhook_api_key in request body
- Update routes test to reflect static route change

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add test case to cover the fallback branch when context.pathInfo.headers
is undefined, achieving 100% branch coverage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@davidaurelio davidaurelio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions

Comment thread src/controllers/llmo/llmo-onboarding.js Outdated
Comment thread src/support/drs-client.js Outdated
Comment thread src/routes/index.js Outdated
dzehnder and others added 6 commits February 17, 2026 15:53
- Move DRS prompt generation job submission to after all critical
  onboarding steps (site.save, audit triggers) so webhook callbacks
  won't arrive for a partially configured site
- Fix OpenAPI docs to match implementation: DRS webhook uses x-api-key
  header auth, not hookSecret in URL path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflict in test/routes/index.test.js by keeping both new routes
(DRS webhook hook and trial-users email preferences).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reuse existing USER_API_KEY instead of introducing a separate
DRS_CALLBACK_API_KEY secret. No new env vars needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove custom apiKeyAuth wrapper from the DRS webhook endpoint.
Authentication is now handled by the standard authWrapper middleware
(JWT, IMS, API Keys) like all other endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dzehnder dzehnder force-pushed the feat/drs-webhook-integration branch from 740a18d to bf46ebb Compare February 19, 2026 16:20
dzehnder and others added 2 commits February 19, 2026 17:31
Fetch target_audience from the site's brand profile when submitting
DRS prompt generation jobs. Falls back to a default audience string
if the brand profile is not yet available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add getBrandProfile mock to onboarding test to cover both branches:
brand profile available (uses target_audience) and brand profile
unavailable (uses default audience fallback).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dzehnder dzehnder changed the title feat: add DRS webhook integration for LLMO onboarding feat: trigger DRS prompt generation during LLMO onboarding Feb 20, 2026
dzehnder and others added 2 commits February 20, 2026 11:58
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove llmo-customer-analysis from immediate audit triggering during
onboarding. It will now be triggered after the DRS prompt generation
job completes via SNS notification. Add source: 'onboarding' to DRS
job submission and move metadata into parameters for notification flow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dzehnder dzehnder merged commit 7ebc38f into main Feb 27, 2026
24 checks passed
@dzehnder dzehnder deleted the feat/drs-webhook-integration branch February 27, 2026 14:58
dzehnder added a commit that referenced this pull request Feb 27, 2026
… deploy-dev label

The squash merge of #1781 removed llmo-customer-analysis from triggerAudits
(now handled by DRS), but the existing test still asserted it was triggered
via SQS. This caused a cascading failure of 69 tests because the failed
assertion prevented restoreSetTimeout() from executing.

Also reverts the deploy-dev label from 'dzehnder' back to 'latest'.

Made-with: Cursor
dzehnder added a commit that referenced this pull request Feb 27, 2026
… deploy-dev label (#1876)

## Summary

- Removes the stale test assertion that expected
`llmo-customer-analysis` to be triggered via SQS `sendMessage`. PR #1781
moved this trigger to DRS, but the existing test (added by another PR
while #1781 was in development) was preserved during the squash merge,
causing the first test failure. That failure prevented
`restoreSetTimeout()` from running, which cascaded into **69 total test
failures**.
- Reverts the `deploy-dev` script label from `-l dzehnder` back to `-l
latest` (accidentally merged from development).

## Test plan

- [x] Full test suite passes locally (3575 passing, 0 failing, 100%
coverage)

Made with [Cursor](https://cursor.com)
solaris007 pushed a commit that referenced this pull request Feb 27, 2026
# [1.325.0](v1.324.2...v1.325.0) (2026-02-27)

### Bug Fixes

* remove stale llmo-customer-analysis trigger assertion and revert deploy-dev label ([#1876](#1876)) ([2921e30](2921e30)), closes [#1781](#1781) [#1781](#1781)

### Features

* trigger DRS prompt generation during LLMO onboarding ([#1781](#1781)) ([7ebc38f](7ebc38f))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.325.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants