Skip to content

feat: run the proposed action in the automatic onboarding worker (CM-1841) - #4918

Merged
ulemons merged 3 commits into
mainfrom
feat/CM-1841-onboarder-proposed-actions
Oct 13, 2026
Merged

ulemons merged 3 commits into
mainfrom
feat/CM-1841-onboarder-proposed-actions

Conversation

@ulemons

@ulemons ulemons commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

PR 7 of the onboarding-core plan (CM-1841). The automatic onboarding worker now runs the proposedAction the evaluation worker stored on the projectCatalog row instead of always creating a non-LF segment.

  • create_segment (and null, rows routed before the classification columns existed): unchanged, onboardProject creates the non-LF segment under lf-oss-index and its GitHub integration.
  • create_integration / update_integration: the worker resolves the CDP segment from pccProjectId (createCdpSegmentLookup) and calls the new connectRepoToSegment, which queries the segment's github-nango integration and either creates it or adds the repo to it.
  • human_review: never onboarded, the row ends in error with an explicit reason. Same for a missing pccProjectId, no / duplicate CDP segments, or a legacy github (v1) integration on the segment.

Why one connectRepoToSegment instead of two functions

The plan listed createIntegrationOnSegment and updateNangoIntegration. Two things in the backend made a single live-state function safer:

  • POST /github-nango-connect with integrationId replaces settings.orgs and mapUnifiedRepositories soft-deletes every repo of the integration that is missing from the mapping (backend/src/services/integrationService.ts). The library therefore reads the existing integration (/integration/query, which hydrates orgs[].repos from the repositories table) and sends back the existing orgs and repos merged with the new one (mergeGithubOrgSettings). The backend is untouched: the UI relies on the replace semantics.
  • createOrUpdate reuses an existing integration of the same platform on the segment, so a blind "create" on a segment that already has one would have replaced it. Deciding create vs update from the live state also covers two rows of the same project in one run (first creates, second updates).

Not in scope

/crowd onboard-project, Force onboarding and the public onboarding API keep calling onboardProject as before.

Test plan

  • onboarder.test.ts: org merge, payload mapping, connectRepoToSegment create / update / error paths
  • proposedAction.test.ts: dispatch per proposedAction, every error branch
  • pnpm lint --deny-warnings, pnpm format, pnpm tsc-check
  • Staging: a review row approved for an LF project with an existing nango integration keeps its other repos after the run

🤖 Generated with Claude Code

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

cursor Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes automatic onboarding and GitHub Nango integration payloads for LF projects; incorrect mapping merge or locking could alter or drop connected repos on shared integrations.

Overview
The automatic onboarding worker now executes each catalog row’s proposedAction instead of always calling onboardProject. create_segment / null still create a non-LF segment and integration; create_integration / update_integration resolve the CDP segment from pccProjectId and call the new connectRepoToSegment, which creates or updates the segment’s github-nango integration from live API state. human_review and invalid LF cases (missing PCC id, no/duplicate segment, legacy github-v1) return explicit errors without onboarding.

connectRepoToSegment merges org/repo settings and re-sends existing repo→segment mappings on update so backend replace/soft-delete semantics do not drop sibling repos or subprojects. LF integration/update paths run inside a transaction with lockProjectCatalogOnboardingTarget (Postgres advisory lock on the PCC project) to serialize concurrent scheduled vs bot onboarding on the same segment.

Reviewed by Cursor Bugbot for commit 8db0d04. 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.

🟡 Changes recommended

Concurrent onboarding workflows can overwrite integration repository mappings and soft-delete a newly added repository.

1 open finding
What changed in this PR

Runs evaluated proposedAction values during automatic onboarding and connects repositories to existing LF segments when appropriate.

Changes:

  • Dispatches onboarding based on the proposed action.
  • Adds GitHub integration creation/update support with repository merging.
  • Adds unit coverage for dispatch and integration behavior.
File Description
services/​libs/​project-onboarding/​src/​types.ts Adds segment and GitHub integration types.
services/​libs/​project-onboarding/​src/​onboarder.ts Adds repository-to-segment integration logic.
services/​libs/​project-onboarding/​src/​onboarder.test.ts Tests integration payloads and merging.
services/​apps/​automatic_onboarding_worker/​src/​activities/​proposedAction.ts Dispatches proposed onboarding actions.
services/​apps/​automatic_onboarding_worker/​src/​activities/​proposedAction.test.ts Tests action dispatch and errors.
services/​apps/​automatic_onboarding_worker/​src/​activities/​activities.ts Integrates action dispatch into onboarding.

🧠 Review effort: Balanced


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

Comment on lines +479 to +485
try {
const integration = await queryGithubIntegration(segmentId, config.apiUrl, config.apiToken)
const input = { owner, repo, repoUrl, segmentId }
if (integration) {
await addRepoToGithubIntegration(input, integration, config)
} else {
await createGithubIntegration(input, config)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0045aca. Configure here.

Comment thread services/libs/project-onboarding/src/onboarder.ts
Comment thread services/libs/project-onboarding/src/onboarder.ts
Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:30
@ulemons

ulemons commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Review fixes in 04b6de5:

  • Concurrent onboarding can lose repositories (onboarder.ts): rows with create_integration / update_integration now run inside a writer transaction holding pg_advisory_xact_lock keyed by pccProjectId (lockProjectCatalogOnboardingTarget, same pattern as lockProjectDocReadiness), so the scheduled and the bot-started onboardProjects workflows serialize the read-modify-write of the same segment's integration. Worker-side fix, no backend change: the github-nango-connect contract stays as is.
  • Mixed-case repo URLs get dropped (onboarder.ts): parseGithubUrl returns the canonical lowercase url from canonicalizeRepoUrl and both connectRepoToSegment and onboardProject store that form, so the owner derived by the hydration (split_part(url, '/', -2)) matches org.name.

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.

🟢 Approval recommended

The implementation matches the stated behavior and includes focused coverage for its critical paths.

1 open finding

🧠 Review effort: Balanced

…1841)

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

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons
ulemons force-pushed the feat/CM-1841-onboarder-proposed-actions branch from 04b6de5 to e9e4071 Compare October 12, 2026 17:49
Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:49

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.

🟡 Changes recommended

Existing repositories can be incorrectly remapped to one segment when updating a multi-subproject integration.

2 open findings

🧠 Review effort: Balanced

Comment thread services/libs/project-onboarding/src/onboarder.ts
…thub integration (CM-1841)

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons

ulemons commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the mapping comment: addRepoToGithubIntegration now reads the current repo→segment mapping from GET /integration/:id/repositories and only the new repo is assigned to the target segment; existing repos keep their own (sub)project segment. Covered by tests in onboarder.test.ts.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:06

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.

🔵 Needs a closer look

Cross-service mapping replacement and concurrency behavior still requires the planned staging verification.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

@ulemons
ulemons merged commit 2c23ab9 into main Oct 13, 2026
14 checks passed
@ulemons
ulemons deleted the feat/CM-1841-onboarder-proposed-actions branch October 13, 2026 07:16
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