Repository navigation
feat: add data access for per-subproject Octolens integrations - #4977
Conversation
Add find-or-create helpers for per-subproject Octolens integrations (restoring a soft-deleted row when its keywords return) and for the segment-less anchor integration, both serialized on an advisory lock. Add cross-integration listing and deactivation of keyword mappings and soft-deletion of subproject integrations left without active mappings. upsertSyncUnits accepts insert-only emitEnabled and initialDelaySeconds; existing callers keep the old defaults. Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
Octolens integrations are created by workers per subproject, so the not-connected list and count no longer offer octolens for every other subproject. The status count now joins segments like the list query, so the segment-less anchor integration is not counted as done. Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
…ns-integration-dal Signed-off-by: Uroš Marolt <uros@marolt.me>
…ns-integration-dal Signed-off-by: Uroš Marolt <uros@marolt.me>
PR SummaryMedium Risk Overview
Tests cover guards, global integration queries, sync unit upserts, and Octolens DAL behavior. Reviewed by Cursor Bugbot for commit 692c8d9. Bugbot is set up for automated code reviews on this repo. Configure here. |
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
There was a problem hiding this comment.
🟡 Changes recommended
Subproject reconciliation can deactivate anchor mappings, and the claimed watermark-preservation guarantee needs clarification or implementation.
2 open findings
What changed in this PR
Adds data-access support for per-subproject Octolens integrations and a shared polling anchor, ahead of the discovery and poll migration.
Changes:
- Adds integration lifecycle and keyword reconciliation helpers.
- Adds insert-only sync-unit emission and scheduling options.
- Adjusts global integration views and adds database tests.
| File | Description |
|---|---|
| services/libs/types/src/enums/platforms.ts | Defines auto-managed platforms. |
| services/libs/data-access-layer/src/octolens/index.ts | Adds lifecycle and reconciliation helpers. |
| services/libs/data-access-layer/src/octolens/index.test.ts | Tests integration and mapping behavior. |
| services/libs/data-access-layer/src/integrations/index.ts | Adjusts global lists and counts. |
| services/libs/data-access-layer/src/integrations/globalIntegrations.test.ts | Tests global-view exclusions. |
| services/libs/data-access-layer/src/connectors/types.ts | Adds insert-only configuration fields. |
| services/libs/data-access-layer/src/connectors/syncUnits.ts | Applies emission and scheduling options. |
| services/libs/data-access-layer/src/connectors/syncUnits.test.ts | Tests defaults and rerun behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ions Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
integrations.platform is nullable; the auto-managed exclusions now treat a NULL platform as not auto-managed, as main does. Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
…ns-integration-dal Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>
…ns-integration-dal Signed-off-by: Uroš Marolt <uros@marolt.me>
Refs linuxfoundation/lfx-cdp-insights-ops#748 Signed-off-by: Uroš Marolt <uros@marolt.me>


Summary
Adds the data access for running Octolens as one integration per mapped subproject, plus one integration with no segment that owns the shared mention poll. The discovery and poll code switch over in follow-up PRs. Also keeps these automatically managed integrations out of the global integrations views, and makes it impossible to create, change or delete them through the generic integration API.
Changes
findOrCreateOctolensSubprojectIntegration(qx, segmentId)andfindOrCreateOctolensAnchorIntegration(qx)(the one withsegmentId IS NULL) share one path returning{ id, created, restored }: return the live row, throw if more than one is live, otherwise restore the most recently updated soft-deleted row, otherwise insert. They serialize onpg_advisory_xact_lock(hashtextextended('octolensIntegration', 0)), sinceintegrationshas no unique key on (platform, segmentId).listActiveOctolensKeywordMappings,deactivateOctolensKeywordMappingsNotSeenAcross(parameterizedunnestof the seen pairs; an empty set is a no-op) andsoftDeleteOctolensSubprojectIntegrationsWithoutActiveMappings. All of them, and the subproject find-or-create, only consider integrations with a segment that don't own an active sync unit, so the poll's integration is never listed, reconciled, soft-deleted or reused for a subproject. The soft-delete must run after the same discovery run's mapping writes and never concurrently with another run; this is noted on the function.upsertSyncUnitsaccepts optionalemitEnabledandinitialDelaySeconds, applied on insert only. Existing callers (GitHub seed, Nango mirror) keep their current defaults, and the conflict update is unchanged (a supplied watermark still replaces the stored one).AUTO_MANAGED_INTEGRATION_PLATFORMS(Octolens): the global not-connected list and count no longer offer Octolens for every subproject that doesn't have it.fetchGlobalIntegrationsStatusCountkeeps its query and only excludes the segment-less Octolens integration. Both filters are NULL-safe, so integrations with a NULL platform behave as before.POST,PUTandDELETE /integrationendpoints return 400 for Octolens integrations, including switching an existing integration's platform to Octolens. IDs are normalized (braces, missing hyphens, case) before the check. Other platforms are unaffected.services/libs/common(one i18n key).Type of change
Related issue
Refs linuxfoundation/lfx-cdp-insights-ops#748