Skip to content

refactor: move the onboarding request classifier to project-onboarding (CM-1841) - #4883

Merged
ulemons merged 3 commits into
mainfrom
feat/CM-1841-extract-request-classifier
Oct 2, 2026
Merged

ulemons merged 3 commits into
mainfrom
feat/CM-1841-extract-request-classifier

Conversation

@ulemons

@ulemons ulemons commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Moves the reusable core of the classifier from the discovery worker to @crowd/project-onboarding so the backend Slack bot can use it: classifyOnboardingRequest(text, deps) returning {resolution, node, trace}, the trace/log-entry module and the CDP segment lookup.
  • The wiring that needs the DB, Bedrock and Snowflake (withRequestClassifierDeps) lives in project-onboarding/src/requestClassifierDeps.ts and is imported by subpath, not through the index, so the other importers of the lib do not pick up the heavy dependencies.
  • The worker keeps only the row, skip-reason and alert wiring.
  • No behavior change.

Notes

  • project-onboarding now depends on common_services, data-access-layer, logging, snowflake and types (package.json, tsconfig references). No dependency cycle: none of them imports the lib.
  • The discovery worker no longer declares common_services, snowflake and types, which moved with the code.
  • pnpm-lock.yaml is consistent with pnpm install --lockfile-only and --frozen-lockfile.

Test plan

  • vitest (worker and lib), tsc -b for the worker and automatic_onboarding_worker, pnpm lint --deny-warnings, pnpm format, check-tsconfig-references.sh

Copilot AI balanced review requested due to automatic review settings October 2, 2026 11:03
@cursor

cursor Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Structural refactor with tests and unchanged worker-facing behavior; dependency edges shift but no auth or data-mutation logic changes.

Overview
Moves onboarding request classification into @crowd/project-onboarding so the Slack bot and other services can reuse the same parse → resolve → trace flow without living in the discovery worker.

The lib now exposes classifyOnboardingRequest (resolution, classification node, trace), classificationTrace helpers, and IRequestClassificationDeps. Infrastructure wiring (Bedrock LLM, Snowflake PCC lookup, CDP segment lookup) is in requestClassifierDeps as withRequestClassifierDeps, imported via @crowd/project-onboarding/src/requestClassifierDeps so the package main export does not pull in common_services, Snowflake, etc.

automatic_projects_discovery_worker drops the inlined trace/deps modules and direct deps on common_services, snowflake, and types; it keeps catalog-row handling, skip reasons, Slack alerts, and calls the shared classifier. project-onboarding gains those workspace dependencies and tsconfig references. classifyRequest.test.ts adds unit coverage for the moved orchestration; existing trace tests stay on the lib.

Reviewed by Cursor Bugbot for commit 352d4df. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Remove stale worker dependencies and regenerate the manually edited lockfile before merging.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Moves reusable onboarding classification logic into @crowd/project-onboarding, enabling additional consumers while retaining worker-specific orchestration.

Changes:

  • Extracts classification, tracing, and CDP lookup logic into the shared library.
  • Moves dependency wiring behind a subpath import.
  • Updates discovery-worker imports and dependencies.
File Description
services/​libs/​project-onboarding/​tsconfig.json Adds required project references.
services/​libs/​project-onboarding/​src/​requestClassifierDeps.ts Provides infrastructure dependency wiring.
services/​libs/​project-onboarding/​src/​index.ts Exports classifier and tracing APIs.
services/​libs/​project-onboarding/​src/​classifyRequest.ts Implements the reusable classifier.
services/​libs/​project-onboarding/​src/​classificationTrace.ts Moves classification tracing into the library.
services/​libs/​project-onboarding/​src/​classificationTrace.test.ts Relocates tracing tests.
services/​libs/​project-onboarding/​src/​cdpSegmentLookup.ts Moves CDP segment lookup wiring.
services/​libs/​project-onboarding/​package.json Adds classifier infrastructure dependencies.
services/​apps/​automatic_projects_discovery_worker/​src/​bin/​classify-onboarding-cases.ts Uses shared dependency wiring.
services/​apps/​automatic_projects_discovery_worker/​src/​bin/​classificationCases.ts Imports the shared node type.
services/​apps/​automatic_projects_discovery_worker/​src/​activities/​requestClassification.ts Delegates classification to the library.
services/​apps/​automatic_projects_discovery_worker/​src/​activities/​requestClassification.test.ts Updates shared type imports.
services/​apps/​automatic_projects_discovery_worker/​src/​activities/​activities.ts Uses shared classifier utilities.
pnpm-lock.yaml Records new workspace dependencies.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pnpm-lock.yaml
Comment on lines +7 to +11
"@crowd/common_services": "workspace:*",
"@crowd/data-access-layer": "workspace:*",
"@crowd/logging": "workspace:*",
"@crowd/snowflake": "workspace:*",
"@crowd/types": "workspace:*"
@ulemons ulemons self-assigned this Oct 2, 2026
@ulemons
ulemons force-pushed the feat/CM-1841-classification-cases-script branch 2 times, most recently from bf5e214 to c8a8b84 Compare October 2, 2026 12:34
Base automatically changed from feat/CM-1841-classification-cases-script to main October 2, 2026 12:43
…g (CM-1841)

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
…boarding (CM-1841)

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons
ulemons force-pushed the feat/CM-1841-extract-request-classifier branch from 388dca8 to a97359b Compare October 2, 2026 12:51
Copilot AI balanced review requested due to automatic review settings October 2, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new public classifier contract lacks direct tests for its returned node and populated trace.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment on lines +53 to +56
export async function classifyOnboardingRequest(
requestText: string,
deps: IRequestClassificationDeps,
): Promise<IRequestClassification> {
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The extraction preserves existing behavior, updates dependency metadata consistently, and includes focused regression coverage.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
Resolved since last review (1)
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@ulemons
ulemons merged commit 2094dc5 into main Oct 2, 2026
17 checks passed
@ulemons
ulemons deleted the feat/CM-1841-extract-request-classifier branch October 2, 2026 13:27
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