Skip to content

Refactor: migrate connection-manager to credentials and intelligence to discovery - #121

Merged
pramodnarayana merged 8 commits into
developmentfrom
refactor/arch-credentials-discovery
Apr 8, 2026
Merged

pramodnarayana merged 8 commits into
developmentfrom
refactor/arch-credentials-discovery

Conversation

@pramodnarayana

@pramodnarayana pramodnarayana commented Apr 8, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Fixed OAuth/connect flow to use the connection-manager endpoint.
  • Documentation

    • Added a high-priority technical debt entry describing planned AI, credentials, and integration reorganization.
  • Refactor

    • Reorganized trigger/discovery and credentials surfaces for clearer boundaries and renamed the universal trigger API.
  • New Features

    • Added an optimization hint registry with an optional pluggable resolver to improve discovery performance.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Reorganizes package boundaries and exports: renames/moves connector symbols into @nexiom/credentials and adds @nexiom/piece-framework/discovery; renames UniversalTrigger types; introduces an optimization registry with a pluggable ConnectionHintResolver; updates many import paths, package.json exports, an OAuth redirect path, docs, and a technical-debt entry.

Changes

Cohort / File(s) Summary
Technical debt doc
TECHNICAL_DEBT.md
Added high-priority "AI Orchestrator & MCP Architecture Refactoring"; renumbered priority sections and completed-items numbering; header adjustments and EOF formatting.
Workspace dependency updates
apps/api/package.json, apps/worker/package.json, engine/application/pieces/.../package.json, engine/platform/core/package.json
Replaced @nexiom/connectors workspace dependencies with @nexiom/credentials.
Credentials package surface
engine/platform/credentials/package.json, engine/platform/credentials/src/index.ts
Renamed package to @nexiom/credentials; removed ./intelligence export subpath; updated package docs/comment.
Piece-framework discovery export
engine/platform/piece-framework/package.json, engine/platform/piece-framework/src/discovery/index.ts
Added @nexiom/piece-framework/discovery export and re-export now points at ./universal-trigger.js.
Discovery API/type renames
engine/platform/piece-framework/src/discovery/interfaces.ts, .../universal-trigger.ts, .../universal-trigger.spec.ts
Renamed UniversalEngineConfig → UniversalTriggerConfig and UniversalTriggerEngine → UniversalTrigger; updated signatures, internal helpers, and tests.
Optimization registry & resolver
engine/platform/piece-framework/src/discovery/optimization-registry.ts
Added OPTIMIZATION_REGISTRY, hint types (ObjectHint, AppHints, etc.), defineHints, a pluggable ConnectionHintResolver, setOptimizationResolver/clearOptimizationResolver, and OptimizationService.getHint with resolver overlay and debug-on-failure.
Credentials imports across code/tests
apps/api/src/modules/.../*.ts, apps/worker/src/modules/.../*.ts, engine/application/pieces/..., *.spec.ts
Switched imports (TokenManagerService, EncryptionService, OAuthCredentialBlob, AppCredentialError, OAuthRefreshClient, etc.) from @nexiom/connectors to @nexiom/credentials or to @nexiom/piece-framework/discovery where applicable; no behavioral changes.
Pieces discovery usages
engine/application/pieces/salesforce/..., engine/application/pieces/quickbooks/...
Repointed discovery/intelligence imports to @nexiom/piece-framework/discovery; updated adapters/triggers to use UniversalTrigger.
Connections endpoint & client hook
apps/web/src/modules/connections/hooks/useConnections.ts, apps/web/src/modules/connections/api/connections.api.ts, apps/api/src/modules/connections/...
Changed OAuth redirect path to /connection-manager/{provider} (was /connectors/{provider}); minor EOF formatting changes.
Docs/comments & small formatting
engine/platform/piece-framework/src/piece.ts, packages/infra-adapters/.../local-crypto.adapter.ts, apps/web/src/modules/stitches/api/metadata.api.ts
Updated inline documentation references and small EOF/newline formatting edits.

Sequence Diagram(s)

sequenceDiagram
    participant Trigger as UniversalTrigger
    participant OptSvc as OptimizationService
    participant Registry as StaticRegistry
    participant Resolver as ConnectionHintResolver

    Trigger->>OptSvc: getHint(appName, objectName, connectionId?)
    OptSvc->>Registry: read static hint for appName/objectName
    Registry-->>OptSvc: static ObjectHint
    OptSvc->>Resolver: if connectionId && resolver set, invoke resolver(appName, objectName, connectionId)
    Resolver-->>OptSvc: resolver hint or undefined
    OptSvc->>OptSvc: merge(staticHint, resolverHint if present)
    OptSvc-->>Trigger: return merged ObjectHint
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through exports and nudged a few files,

Moved credentials, triggers, and sorted the piles,
A resolver now whispers hints into the night,
Static and custom merge tidy and bright,
I twitch my nose and celebrate refactor delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main refactoring work: migrating the connection-manager package to credentials and intelligence functionality to discovery, which aligns with the primary changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/arch-credentials-discovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/src/modules/connections/connectors.service.ts (1)

33-36: ⚠️ Potential issue | 🟡 Minor

Stale type-alias comment references old package.

Line 35 still says the alias comes from the connectors package, but it now comes from credentials. Please update the comment to prevent confusion.

Suggested doc fix
 /**
  * Encrypted value blob stored in app_connection.value.
- * Aliased from the connectors package so all callers share a single source of truth.
+ * Aliased from the credentials package so all callers share a single source of truth.
  */
 export type ConnectionValueBlob = OAuthCredentialBlob;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api/src/modules/connections/connectors.service.ts` around lines 33 - 36,
Update the doc comment above the Encrypted value blob declaration in
connectors.service.ts to reflect the correct source package: replace the stale
reference to "connectors" with "credentials" so it reads that the alias is from
the credentials package and that callers share a single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/src/modules/connections/api/connections.api.ts`:
- Around line 46-52: Update the frontend endpoint paths in
apps/web/src/modules/connections/api/connections.api.ts so they match the
backend controller namespace: replace any apiClient.get/post calls using
"/connection-manager/..." with "/connectors/..." (e.g. update the call inside
listActiveConnections and the other apiClient.* calls that fetch providers,
active connections, and related resources) so the routes align with the backend
`@Controller`('connectors') endpoints.

In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 4-11: Add a reset function to avoid test pollution by clearing the
module-scoped resolver: implement and export clearOptimizationResolver() which
sets the customResolver (the module variable) back to null; keep the existing
setOptimizationResolver(resolver: ConnectionHintResolver) and
ConnectionHintResolver type unchanged so tests can set and then call
clearOptimizationResolver() to restore default state.

In `@engine/platform/piece-framework/src/discovery/universal-trigger.ts`:
- Line 5: The logger instance uses app: 'universal-engine' which is inconsistent
with the renamed class UniversalTrigger; update the IgtLogger instantiation (the
log variable created with new IgtLogger) to use app: 'universal-trigger' so
logs/filters align with the class name (change the app field value in the
IgtLogger call where log is created).

In `@engine/platform/piece-framework/src/piece.ts`:
- Around line 20-25: The header comment incorrectly says the polling types are
defined in packages/connection-manager; update the comment to state they are
defined in this piece-framework module (engine/platform/piece-framework) and
used by piece.poll() and the SchedulerWorker, and mention the actual types
defined here (PollWindow, PollRecord, PollPage, StreamDescriptor, etc.) so the
comment accurately reflects the current location and purpose of these types.

In `@TECHNICAL_DEBT.md`:
- Around line 9-15: There are duplicate "### 1." headings in TECHNICAL_DEBT.md
(e.g., the "AI Orchestrator & MCP Architecture Refactoring" section and the
later "### 1." at line ~28); update the markdown headings to use a consistent,
incremental numbering scheme (e.g., 1., 2., 3.) or convert to auto-numbered
lists so each high-priority item is uniquely numbered — locate headings by their
text like "AI Orchestrator & MCP Architecture Refactoring" and the subsequent
"### 1." entries and rename them sequentially to restore clear navigation.

---

Outside diff comments:
In `@apps/api/src/modules/connections/connectors.service.ts`:
- Around line 33-36: Update the doc comment above the Encrypted value blob
declaration in connectors.service.ts to reflect the correct source package:
replace the stale reference to "connectors" with "credentials" so it reads that
the alias is from the credentials package and that callers share a single source
of truth.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7bddd4b0-d0ce-4b68-a46a-676583a1afad

📥 Commits

Reviewing files that changed from the base of the PR and between 92d2dab and c827b7f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (57)
  • TECHNICAL_DEBT.md
  • apps/api/package.json
  • apps/api/src/modules/ai/_services/orchestrator.service.spec.ts
  • apps/api/src/modules/ai/_services/orchestrator.service.ts
  • apps/api/src/modules/connections/connections.module.ts
  • apps/api/src/modules/connections/connections/connectors.controller.spec.ts
  • apps/api/src/modules/connections/connections/connectors.controller.ts
  • apps/api/src/modules/connections/connections/token-refresh.service.spec.ts
  • apps/api/src/modules/connections/connections/token-refresh.service.ts
  • apps/api/src/modules/connections/connectors.service.spec.ts
  • apps/api/src/modules/connections/connectors.service.ts
  • apps/api/src/modules/metadata/metadata-discovery.service.spec.ts
  • apps/api/src/modules/metadata/metadata-discovery.service.ts
  • apps/api/src/modules/scheduler/poll-sync-runner.spec.ts
  • apps/api/src/modules/scheduler/poll-sync-runner.ts
  • apps/api/src/modules/scheduler/scheduler.module.ts
  • apps/api/src/modules/stitches/stitches.module.ts
  • apps/web/src/modules/connections/api/connections.api.ts
  • apps/web/src/modules/connections/hooks/useConnections.ts
  • apps/web/src/modules/stitches/api/metadata.api.ts
  • apps/worker/package.json
  • apps/worker/src/modules/pipeline/delivery.service.spec.ts
  • apps/worker/src/modules/pipeline/delivery.service.ts
  • engine/application/pieces/quickbooks/package.json
  • engine/application/pieces/quickbooks/src/triggers/quickbooks-polling.helper.ts
  • engine/application/pieces/quickbooks/src/triggers/universal-trigger.ts
  • engine/application/pieces/salesforce/package.json
  • engine/application/pieces/salesforce/src/lib/discovery/index.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-bulk.adapter.spec.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-bulk.adapter.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-discovery.adapter.spec.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-discovery.adapter.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-query.adapter.spec.ts
  • engine/application/pieces/salesforce/src/lib/discovery/salesforce-query.adapter.ts
  • engine/application/pieces/salesforce/src/lib/trigger/universal-trigger.ts
  • engine/platform/core/package.json
  • engine/platform/credentials/package.json
  • engine/platform/credentials/src/crypto/encryption.interface.ts
  • engine/platform/credentials/src/crypto/encryption.service.spec.ts
  • engine/platform/credentials/src/crypto/encryption.service.ts
  • engine/platform/credentials/src/http-client/host-http-client.spec.ts
  • engine/platform/credentials/src/http-client/host-http-client.ts
  • engine/platform/credentials/src/index.ts
  • engine/platform/credentials/src/oauth/token-manager.service.ts
  • engine/platform/credentials/tsconfig.json
  • engine/platform/credentials/tsconfig.spec.json
  • engine/platform/credentials/vitest.config.ts
  • engine/platform/piece-framework/package.json
  • engine/platform/piece-framework/src/discovery/igt-logger.ts
  • engine/platform/piece-framework/src/discovery/index.ts
  • engine/platform/piece-framework/src/discovery/interfaces.ts
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts
  • engine/platform/piece-framework/src/discovery/smart-cursor-selector.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.spec.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.ts
  • engine/platform/piece-framework/src/piece.ts
  • packages/infra-adapters/src/adapters/local-crypto.adapter.ts

Comment thread apps/web/src/modules/connections/api/connections.api.ts Outdated
Comment thread engine/platform/piece-framework/src/discovery/universal-trigger.ts Outdated
Comment thread engine/platform/piece-framework/src/piece.ts
Comment thread TECHNICAL_DEBT.md
@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 5 file(s) based on 5 unresolved review comments.

Files modified:

  • TECHNICAL_DEBT.md
  • apps/web/src/modules/connections/api/connections.api.ts
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.ts
  • engine/platform/piece-framework/src/piece.ts

Commit: e974ca3c43b131f391e1ab069293601a48d49b26

The changes have been pushed to the refactor/arch-credentials-discovery branch.

Time taken: 5m 44s

Fixed 5 file(s) based on 5 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
engine/platform/piece-framework/src/discovery/optimization-registry.ts (1)

74-76: ⚠️ Potential issue | 🟡 Minor

JSDoc is outdated after the DB-to-resolver migration.

The comment still references "DB-backed profile cache" but the implementation now uses a pluggable ConnectionHintResolver. Update to reflect the current behavior.

📝 Proposed fix
-     * `@param` connectionId - Optional app_connection.id. When provided, queries the DB-backed
-     *                       profile cache (scoped per-connection for custom object support).
-     *                       When absent, falls straight through to the static registry.
+     * `@param` connectionId - Optional connection identifier. When provided and a custom resolver
+     *                       is registered, calls the resolver for per-connection hints.
+     *                       When absent (or no resolver set), falls back to the static registry.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`
around lines 74 - 76, Update the outdated JSDoc for the connectionId parameter
to reflect the new DB-to-resolver design: replace references to the "DB-backed
profile cache" with the pluggable ConnectionHintResolver and explain that when a
connectionId is provided the registry consults the ConnectionHintResolver
(scoped per-connection for custom object support) and when absent it falls back
to the static registry; ensure you mention the ConnectionHintResolver symbol and
the connectionId parameter name in the comment near the optimization registry
functions/classes so readers know the current behavior.
engine/platform/piece-framework/src/discovery/universal-trigger.ts (1)

218-218: 🧹 Nitpick | 🔵 Trivial

Remove unnecessary as any cast.

The config parameter is already typed as UniversalTriggerConfig<any>, which includes objectName, hint, queryAdapter, bulkAdapter, and executeStandardQuery. The cast is redundant and reduces type safety.

♻️ Proposed fix
-        const { objectName, hint, queryAdapter, bulkAdapter, executeStandardQuery } = config as any;
+        const { objectName, hint, queryAdapter, bulkAdapter, executeStandardQuery } = config;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/platform/piece-framework/src/discovery/universal-trigger.ts` at line
218, Remove the unnecessary "as any" cast on the destructuring of config in
universal-trigger.ts: use the existing strongly-typed parameter
(UniversalTriggerConfig<any>) directly when extracting objectName, hint,
queryAdapter, bulkAdapter, and executeStandardQuery (i.e., replace "const { ...
} = config as any" with "const { ... } = config") so you retain type safety and
let TypeScript validate those properties on the config parameter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 84-86: The variable name dbHint is misleading because its value
comes from customResolver; rename dbHint to resolverHint (or customHint)
everywhere in the function where customResolver(appName, objectName,
connectionId) is awaited and merged with staticHint, updating the declaration,
the await assignment, the conditional (e.g., if (resolverHint &&
Object.keys(resolverHint).length > 0)), and the returned merged object (return {
...staticHint, ...resolverHint }) to keep naming consistent with customResolver.
- Line 3: The constant VALID_EXECUTION_PATHS is declared but unused; remove the
declaration "VALID_EXECUTION_PATHS" from optimization-registry.ts to eliminate
dead code (or alternatively, if you intended runtime checks for ExecutionPath
values, implement and call a validator that references VALID_EXECUTION_PATHS
where ExecutionPath strings are parsed/validated such as in any factory or
deserialization function that accepts ExecutionPath). Ensure any imports or
references to ExecutionPath remain valid after removal.

In `@engine/platform/piece-framework/src/discovery/universal-trigger.ts`:
- Line 298: The file ends with a closing brace '}' but lacks a trailing newline;
open universal-trigger.ts, add a single newline character at the end of the file
(after the final '}') so the file terminates with '\n', save and commit the
change to satisfy POSIX/EditorConfig conventions.

In `@TECHNICAL_DEBT.md`:
- Line 459: Add a single trailing newline at the end of TECHNICAL_DEBT.md so the
file ends with exactly one newline character (fixing markdownlint MD047); update
the file's EOF to include the newline, save/commit the change, and re-run
linting to confirm the warning is resolved.

---

Outside diff comments:
In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 74-76: Update the outdated JSDoc for the connectionId parameter to
reflect the new DB-to-resolver design: replace references to the "DB-backed
profile cache" with the pluggable ConnectionHintResolver and explain that when a
connectionId is provided the registry consults the ConnectionHintResolver
(scoped per-connection for custom object support) and when absent it falls back
to the static registry; ensure you mention the ConnectionHintResolver symbol and
the connectionId parameter name in the comment near the optimization registry
functions/classes so readers know the current behavior.

In `@engine/platform/piece-framework/src/discovery/universal-trigger.ts`:
- Line 218: Remove the unnecessary "as any" cast on the destructuring of config
in universal-trigger.ts: use the existing strongly-typed parameter
(UniversalTriggerConfig<any>) directly when extracting objectName, hint,
queryAdapter, bulkAdapter, and executeStandardQuery (i.e., replace "const { ...
} = config as any" with "const { ... } = config") so you retain type safety and
let TypeScript validate those properties on the config parameter.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a52f9bfc-46b2-409a-9207-5607d8a9843c

📥 Commits

Reviewing files that changed from the base of the PR and between c827b7f and e974ca3.

📒 Files selected for processing (5)
  • TECHNICAL_DEBT.md
  • apps/web/src/modules/connections/api/connections.api.ts
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.ts
  • engine/platform/piece-framework/src/piece.ts

Comment thread engine/platform/piece-framework/src/discovery/optimization-registry.ts Outdated
Comment thread engine/platform/piece-framework/src/discovery/optimization-registry.ts Outdated
}
}
}
} No newline at end of file

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.

🧹 Nitpick | 🔵 Trivial

Add trailing newline at end of file.

The file should end with a newline character per standard conventions.

📝 Proposed fix
 }
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/platform/piece-framework/src/discovery/universal-trigger.ts` at line
298, The file ends with a closing brace '}' but lacks a trailing newline; open
universal-trigger.ts, add a single newline character at the end of the file
(after the final '}') so the file terminates with '\n', save and commit the
change to satisfy POSIX/EditorConfig conventions.

Comment thread TECHNICAL_DEBT.md

1. **API Modernization**: Proposed: delete `ProviderRegistryService` and update `connectors.controller.ts` and `connectors.service.ts` to use `PieceAuth` definitions from `PieceRegistryService` for mapping `tokenUrl`, `authUrl`, and `clientId` dynamically.
2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically.
2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically. No newline at end of file

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.

⚠️ Potential issue | 🟡 Minor

Add trailing newline at end of file.

Static analysis (markdownlint MD047) indicates the file should end with a single newline character.

📝 Proposed fix
-2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically.
+2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically.
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically.
2. **Frontend Simplification**: Proposed: remove hardcoded `env` in `DynamicAuthForm.tsx` and `oauth-state.service.ts`; render environment via `uiSchema`/`vendorParams` so any custom field flows through generically.
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 459-459: Files should end with a single newline character

(MD047, single-trailing-newline)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@TECHNICAL_DEBT.md` at line 459, Add a single trailing newline at the end of
TECHNICAL_DEBT.md so the file ends with exactly one newline character (fixing
markdownlint MD047); update the file's EOF to include the newline, save/commit
the change, and re-run linting to confirm the warning is resolved.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 3 file(s) based on 4 unresolved review comments.

Files modified:

  • TECHNICAL_DEBT.md
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.ts

Commit: 23fdd57f51dfa6dfdbe1d420b9a8aad0079d5cb1

The changes have been pushed to the refactor/arch-credentials-discovery branch.

Time taken: 4m 6s

Fixed 3 file(s) based on 4 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
engine/platform/piece-framework/src/discovery/optimization-registry.ts (1)

73-75: ⚠️ Potential issue | 🟡 Minor

Update stale JSDoc comment.

The documentation still references "queries the DB-backed profile cache" but the implementation now uses the pluggable customResolver. Update the comment to accurately describe the current behavior.

📝 Proposed fix
     /**
      * Look up execution hints for a specific object.
      *
      * `@param` appName      - Canonical app name (used for static OPTIMIZATION_REGISTRY fallback).
      * `@param` objectName   - Vendor object name e.g. 'rtms__Load__c'.
-     * `@param` connectionId - Optional app_connection.id. When provided, queries the DB-backed
-     *                       profile cache (scoped per-connection for custom object support).
-     *                       When absent, falls straight through to the static registry.
+     * `@param` connectionId - Optional app_connection.id. When provided, invokes the custom
+     *                       resolver (if set) for connection-scoped hints.
+     *                       When absent or no resolver is set, falls through to the static registry.
      */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`
around lines 73 - 75, Update the stale JSDoc for the connectionId param in
OptimizationRegistry (in optimization-registry.ts) to reflect that when
connectionId is provided the registry will consult the pluggable customResolver
(not a DB-backed profile cache) to resolve per-connection/custom-object
profiles, and when absent it falls back to the static registry; specifically
edit the JSDoc for the connectionId parameter near the OptimizationRegistry
methods (or class) to mention customResolver and per-connection scoping instead
of "DB-backed profile cache".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 73-75: Update the stale JSDoc for the connectionId param in
OptimizationRegistry (in optimization-registry.ts) to reflect that when
connectionId is provided the registry will consult the pluggable customResolver
(not a DB-backed profile cache) to resolve per-connection/custom-object
profiles, and when absent it falls back to the static registry; specifically
edit the JSDoc for the connectionId parameter near the OptimizationRegistry
methods (or class) to mention customResolver and per-connection scoping instead
of "DB-backed profile cache".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d340cf39-3c5c-4033-b080-0ebff19b2aee

📥 Commits

Reviewing files that changed from the base of the PR and between e974ca3 and 23fdd57.

📒 Files selected for processing (1)
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 63-65: defineHints currently overwrites entire ObjectHint entries
for an app instead of merging fields; change defineHints to preserve existing
per-object defaults by merging each object key: for each object name in hints,
merge the existing OPTIMIZATION_REGISTRY[appName][objectName] with the new
hints[objectName] (e.g., spread existing then spread new) so partial overrides
(like updating bulkThreshold) don't drop cursorPrecedence/requiredFields; ensure
you initialize OPTIMIZATION_REGISTRY[appName] = {} when missing and update
OPTIMIZATION_REGISTRY[appName] with the merged per-object entries.
- Around line 77-97: getHint currently returns references to registry-owned
objects (staticHint and merged resolverHint), so callers can mutate
module-scoped defaults; update getHint (and the merge path) to return a
defensive copy: create a new ObjectHint object when returning (for both the
static-only return and the {...staticHint, ...resolverHint} case) and clone any
array-valued properties that should be isolated (e.g., requiredFields, autoJoin,
cursorPrecedence) so the returned hint contains new arrays rather than
references to those stored in OPTIMIZATION_REGISTRY or resolverHint; ensure you
handle undefined staticHint/resolverHint gracefully by only cloning existing
arrays.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b5cfc329-77d5-457b-a277-43f1f376dddc

📥 Commits

Reviewing files that changed from the base of the PR and between 23fdd57 and f395512.

📒 Files selected for processing (3)
  • apps/api/src/modules/connections/connectors.service.ts
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts
  • engine/platform/piece-framework/src/discovery/universal-trigger.ts

Comment thread engine/platform/piece-framework/src/discovery/optimization-registry.ts Outdated
@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 2 unresolved review comments.

Files modified:

  • engine/platform/piece-framework/src/discovery/optimization-registry.ts

Commit: bff33f1646c112870dafcf63186adb0228a82def

The changes have been pushed to the refactor/arch-credentials-discovery branch.

Time taken: 4m 24s

Fixed 1 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@engine/platform/piece-framework/src/discovery/optimization-registry.ts`:
- Around line 69-74: The incoming hints are being stored by reference which
allows external mutation to change module-wide defaults; extract the private
cloneHint method into a module-level function named cloneHint and replace all
internal usages (including the places where getHint(), defineHints(), and the
previous private cloneHint were called) so that defineHints() clones both the
incoming hints and the existing OPTIMIZATION_REGISTRY[appName][objectName]
before merging, and update the other call sites (the previous private cloneHint
callers around the code that currently invokes cloning) to use the new
module-level cloneHint so arrays like cursorPrecedence, autoJoin, and
requiredFields are deeply copied prior to storage.
- Around line 36-61: OPTIMIZATION_REGISTRY and per-app hint buckets are plain
objects and allow prototype pollution via defineHints(); change the registry and
any per-app bucket creation to use null-prototype maps (Object.create(null))
instead of object literals so inherited keys can't be abused, and update
defineHints() to create a null-prototype bucket for
OPTIMIZATION_REGISTRY[appName] (and any similar write sites) rather than
assigning a plain {}; keep getHint()/AppHints usage compatible but ensure any
existence checks don't rely on prototype inheritance (use hasOwnProperty on the
null-prototype map or explicit undefined checks).
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7881e441-f742-40bb-bfc0-490cfc669801

📥 Commits

Reviewing files that changed from the base of the PR and between f395512 and bff33f1.

📒 Files selected for processing (1)
  • engine/platform/piece-framework/src/discovery/optimization-registry.ts

Comment thread engine/platform/piece-framework/src/discovery/optimization-registry.ts Outdated
@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 2 unresolved review comments.

Files modified:

  • engine/platform/piece-framework/src/discovery/optimization-registry.ts

Commit: 4bb4a4a1a39d1a5887f8e958ce70e7ac89ae06c0

The changes have been pushed to the refactor/arch-credentials-discovery branch.

Time taken: 3m 57s

coderabbitai Bot and others added 2 commits April 8, 2026 11:46
Fixed 1 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@pramodnarayana
pramodnarayana merged commit bd5050e into development Apr 8, 2026
2 of 3 checks passed
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.

1 participant