Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Jul 16, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Corrected directionality and relationship semantics for parent-child and source-target resource relationships throughout the app, including resource visualization, variable resolution, and API responses.
    • Updated UI components to accurately display relationship information and simplified dependency type selection fields.
  • Database

    • Changed the "dependency_type" column in resource relationship rules from an enum to a plain text field for improved flexibility.
  • API & Documentation

    • Updated OpenAPI schema and API responses to reflect the corrected relationship property names and direction.
    • Adjusted related tests and documentation to align with these changes.
  • Tests

    • Revised test cases and resource definitions to match the new relationship direction and naming conventions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Walkthrough

This update systematically reverses the directionality of resource relationships throughout the codebase. It swaps the roles of "source" and "target" in queries, API responses, tests, UI components, and schema definitions. Additionally, it removes the dependency type enum and changes the corresponding database column to text. No new features or error handling were introduced.

Changes

Files / Areas Change Summary
apps/event-worker/src/workers/delete-resource.ts, update-resource-variable.ts, updated-resources/index.ts Changed filtering logic from using .source.id to .target.id (or vice versa) for affected resources and release targets, aligning with the new directionality of relationships.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/variables/page.tsx, visualize/CollapsibleTreeContext.tsx, visualize/resource-node/useResourceCollapsibleToggle.ts Corrected logic and rendering to use .source instead of .target (and vice versa) in relationship displays and tree traversal, ensuring proper parent-child mapping in UI components.
apps/webservice/src/app/(sidebar)/relationship-rules/components/CreateRelationshipDialog.tsx, EditRelationshipDialog.tsx Replaced dependency type dropdown with a plain text input; removed related imports and logic.
apps/webservice/src/app/api/v1/jobs/[jobId]/get-job.ts, api/v1/workspaces/[workspaceId]/resources/identifier/[identifier]/openapi.ts Changed relationship object to use .source instead of .target in returned resource metadata and OpenAPI schema.
e2e/api/schema.ts, e2e/tests/api/resource-relationships.spec.ts, resource-relationships.spec.yaml, resource-variables.spec.ts Swapped "source" and "target" roles in test resource definitions, variable names, assertions, and OpenAPI schema types to match new relationship directionality.
openapi.v1.json Reformatted arrays for enums/required fields and changed "target" to "source" in the resource relationship schema.
packages/api/src/router/resource/resource-visualization.ts Corrected edge and resource collection logic in TreeBuilder to use correct direction for parents and children.
packages/db/drizzle/0128_jittery_dakota_north.sql, meta/_journal.json Changed dependency_type column in resource_relationship_rule table to text; added corresponding migration journal entry.
packages/db/src/queries/relationships/get-resource-children.ts, get-resource-parents.ts Swapped join/select/filter logic to invert directionality: children now as targets, parents as sources.
packages/db/src/schema/resource-relationship-rule.ts Removed ResourceDependencyType enum and related mapping; changed dependencyType column to plain text.
packages/rule-engine/src/manager/variables/resolve-reference-variable.ts Updated variable resolution logic to retrieve parent (source) resources instead of targets.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant API
    participant DB

    UI->>API: Request resource relationships
    API->>DB: Query for relationships (parents: source, children: target)
    DB-->>API: Return relationships with "source" and "target" fields swapped
    API-->>UI: Respond with relationships using "source" in place of "target"
Loading

Possibly related PRs

  • ctrlplanedev/ctrlplane#565: Introduced dispatchAffectedTargetJobs, which is directly modified in this PR to change argument mapping from .source.id to .target.id.

Suggested reviewers

  • zacharyblasczyk
  • jsbroks

Poem

In the warren, source and target switched,
Relationships now perfectly stitched.
Edges and nodes, with roles reversed,
In diagrams and queries, no longer cursed.
The enum is gone, text takes its place—
A tidy hop for code and database!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (2)
openapi.v1.json (1)

2599-2620: fromIdentifier / toIdentifier naming no longer reflects direction after flip

With “source ↔ target” inverted, the semantics of from → to have reversed.
Consider renaming to sourceIdentifier / targetIdentifier (or similar) to avoid future confusion
and accidental misuse by API consumers.

-                  "fromIdentifier": {
+                  "sourceIdentifier": {
...
-                  "toIdentifier": {
+                  "targetIdentifier": {

(Be sure to migrate handlers, clients and docs accordingly.)

packages/db/src/queries/relationships/get-resource-parents.ts (1)

38-65: getResourceParents/Children logic is inverted

Both functions’ from/where clauses are flipped against the new source=child/target=parent semantics:

  • getResourceParents (should return parents of a child) currently:

    • .from(targetResource)
    • .where(eq(targetResource.id, resourceId))
    • selects sourceResource ⇒ actually returns the child’s children.
  • getResourceChildren (should return children of a parent) currently:

    • .from(targetResource)
    • .where(eq(sourceResource.id, resourceId))
    • selects targetResource ⇒ actually returns the parent.

Please swap the from table, join direction, where filters, and selected alias in each:

  • In get-resource-parents.ts:
    • Change .from(targetResource).from(sourceResource)
    • Swap where(eq(targetResource.id, resourceId))where(eq(sourceResource.id, resourceId))
    • Select target: targetResource instead of source: sourceResource

  • In get-resource-children.ts:
    • Change to .from(sourceResource)
    • Swap where(eq(sourceResource.id, resourceId))where(eq(targetResource.id, resourceId))
    • Select source: sourceResource instead of target: targetResource

Ensuring each function names align with source/target semantics will restore correct parent/child retrieval.

🧹 Nitpick comments (1)
packages/rule-engine/src/manager/variables/resolve-reference-variable.ts (1)

15-25: LGTM: Correctly updates variable resolution to use source resources.

The systematic change from target-based to source-based resource relationship logic aligns with the directional changes across the codebase. The logic correctly resolves variables from source resources in the relationship.

However, address the useless rename highlighted by static analysis:

-      getParentsWithMetadataAndVars: getParentsWithMetadataAndVars,
+      getParentsWithMetadataAndVars,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b782270 and 0066480.

📒 Files selected for processing (22)
  • apps/event-worker/src/workers/delete-resource.ts (1 hunks)
  • apps/event-worker/src/workers/update-resource-variable.ts (1 hunks)
  • apps/event-worker/src/workers/updated-resources/index.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/variables/page.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (4 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/CreateRelationshipDialog.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/EditRelationshipDialog.tsx (1 hunks)
  • apps/webservice/src/app/api/v1/jobs/[jobId]/get-job.ts (1 hunks)
  • apps/webservice/src/app/api/v1/workspaces/[workspaceId]/resources/identifier/[identifier]/openapi.ts (1 hunks)
  • e2e/api/schema.ts (1 hunks)
  • e2e/tests/api/resource-relationships.spec.ts (8 hunks)
  • e2e/tests/api/resource-relationships.spec.yaml (1 hunks)
  • e2e/tests/api/resource-variables.spec.ts (28 hunks)
  • openapi.v1.json (93 hunks)
  • packages/api/src/router/resource/resource-visualization.ts (1 hunks)
  • packages/db/drizzle/0128_jittery_dakota_north.sql (1 hunks)
  • packages/db/drizzle/meta/_journal.json (1 hunks)
  • packages/db/src/queries/relationships/get-resource-children.ts (2 hunks)
  • packages/db/src/queries/relationships/get-resource-parents.ts (2 hunks)
  • packages/db/src/schema/resource-relationship-rule.ts (2 hunks)
  • packages/rule-engine/src/manager/variables/resolve-reference-variable.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx,json,css,md,yml,yaml}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md

⚙️ CodeRabbit Configuration File

**/*.{js,jsx,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (21)
📓 Common learnings
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#461
File: packages/job-dispatch/src/resource/handle-provider-scan.ts:48-49
Timestamp: 2025-04-09T17:14:38.947Z
Learning: Resources in the codebase implement a soft delete mechanism where records are marked with a `deleted_at` timestamp rather than being physically removed from the database, preserving referential integrity with dependent records.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#461
File: packages/job-dispatch/src/resource/handle-provider-scan.ts:48-49
Timestamp: 2025-04-09T17:14:38.947Z
Learning: The codebase implements soft deletes for resources by setting a `deletedAt` timestamp rather than physically removing records, which maintains referential integrity with foreign key constraints while allowing the application to filter out deleted resources as needed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:23-24
Timestamp: 2025-06-24T23:52:50.732Z
Learning: The user adityachoudhari26 prefers not to add null safety checks or defensive programming in test code, particularly in e2e tests, as they prioritize simplicity and focus on the main functionality being tested rather than comprehensive error handling within the test itself.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:117-130
Timestamp: 2025-06-24T23:53:25.398Z
Learning: User adityachoudhari26 prefers to keep non-null assertions in e2e test code without extensive null safety checks, reasoning that test failures serve the same purpose of catching issues and the extra validation doesn't add much value in test contexts.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/variables/page.tsx (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
apps/event-worker/src/workers/delete-resource.ts (6)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:382-390
Timestamp: 2024-11-27T23:18:59.456Z
Learning: In the codebase, releases are not scoped to a specific resource.
e2e/tests/api/resource-relationships.spec.yaml (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#517
File: e2e/tests/api/deployment-variable.spec.ts:70-76
Timestamp: 2025-04-28T21:59:04.723Z
Learning: In the ctrlplane e2e tests, tests can be isolated between runs using prefixed systems with random IDs in YAML templates, but tests within the same file may still need to handle isolation between test cases if they operate on the same resources.
apps/event-worker/src/workers/update-resource-variable.ts (5)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
apps/webservice/src/app/api/v1/jobs/[jobId]/get-job.ts (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#500
File: packages/db/src/schema/job.ts:117-120
Timestamp: 2025-04-21T18:34:54.764Z
Learning: In the system's job schema, the relationship between job and releaseJob is a true one-to-one relationship - a release job should only ever point to one job and vice versa. The implementation uses `one(releaseJob, ...)` in the jobRelations to reflect this business rule.
e2e/api/schema.ts (1)

undefined

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In RelationshipsDiagramDependencies.tsx, when using React Flow's BaseEdge, the markerStart prop may intentionally use the markerEnd value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow BaseEdge component and cannot be renamed or changed.
</retrieved_learning>

packages/db/src/queries/relationships/get-resource-children.ts (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/rule-engine/src/rules/concurrency-rule.ts:8-11
Timestamp: 2025-06-01T19:10:47.122Z
Learning: In packages/rule-engine/src/rules/concurrency-rule.ts, the ConcurrencyRule should remain simple without additional validation since database and Zod schemas already handle concurrency validation. The user prefers this rule to be "dumb" and just perform the comparison check rather than duplicating validation logic.
packages/api/src/router/resource/resource-visualization.ts (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/api/v1/workspaces/[workspaceId]/resources/identifier/[identifier]/openapi.ts (1)
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#236
File: packages/api/src/router/workspace-integrations.ts:222-231
Timestamp: 2024-12-02T01:47:59.631Z
Learning: In `packages/api/src/router/workspace-integrations.ts`, when creating IAM policies for roles that need to assume customer-provided roles with unknown ARNs, it's acceptable to keep `Resource` as `"*"` in the policy document, while limiting the `Action` to `"sts:AssumeRole"`, since ARNs are not known in advance.
packages/db/src/schema/resource-relationship-rule.ts (5)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/auth/src/utils/rbac.ts:102-118
Timestamp: 2024-10-29T02:05:46.185Z
Learning: The `releaseChannel` scope type is included in the `scopeType` enum in `packages/db/src/schema/rbac.ts`.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/db/src/schema/rules/concurrency.ts:0-0
Timestamp: 2025-06-01T19:10:11.535Z
Learning: In the ctrlplane codebase, when defining database schemas with Drizzle ORM, it's an intentional pattern to spread base fields (like `basePolicyRuleFields`) and then redefine specific fields to add additional constraints (like unique constraints or foreign key references). The TypeScript field overwriting behavior is deliberately used to override base field definitions with more specific requirements.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/rule-engine/src/rules/concurrency-rule.ts:8-11
Timestamp: 2025-06-01T19:10:47.122Z
Learning: In packages/rule-engine/src/rules/concurrency-rule.ts, the ConcurrencyRule should remain simple without additional validation since database and Zod schemas already handle concurrency validation. The user prefers this rule to be "dumb" and just perform the comparison check rather than duplicating validation logic.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
e2e/tests/api/resource-relationships.spec.ts (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:96-99
Timestamp: 2025-06-24T23:53:36.327Z
Learning: In e2e test files, prefer explicit null safety checks and validation over non-null assertions (!). When validating API responses in tests, use type guards and throw descriptive errors rather than assuming values are always present.
apps/event-worker/src/workers/updated-resources/index.ts (6)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:382-390
Timestamp: 2024-11-27T23:18:59.456Z
Learning: In the codebase, releases are not scoped to a specific resource.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/CreateRelationshipDialog.tsx (7)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx:46-57
Timestamp: 2024-10-30T00:03:57.878Z
Learning: Accessibility and validation feedback improvements are not desired for form fields in the `Overview` component within `apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx`.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#578
File: apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/providers/integrations/github/GithubDialog.tsx:58-58
Timestamp: 2025-05-30T21:48:48.868Z
Learning: In the ctrlplane codebase, the shadcn form UI version allows initializing forms with `useForm({ schema: formSchema })` directly, without needing to import and use `zodResolver` from '@hookform/resolvers/zod'. This is different from standard react-hook-form usage.
openapi.v1.json (6)

undefined

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #590
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/unlock/openapi.ts:3-74
Timestamp: 2025-06-14T06:43:08.415Z
Learning: In the ctrlplane project, OpenAPI specifications are organized as separate files for each endpoint and then merged into a single OpenAPI document. Individual endpoint OpenAPI files can reference schemas using $ref even if the schema is not defined locally in that file, as long as the schema exists in another OpenAPI file that will be part of the merge process.
</retrieved_learning>

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #579
File: packages/rule-engine/src/rules/concurrency-rule.ts:8-11
Timestamp: 2025-06-01T19:10:47.122Z
Learning: In packages/rule-engine/src/rules/concurrency-rule.ts, the ConcurrencyRule should remain simple without additional validation since database and Zod schemas already handle concurrency validation. The user prefers this rule to be "dumb" and just perform the comparison check rather than duplicating validation logic.
</retrieved_learning>

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #515
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/releases/route.ts:103-108
Timestamp: 2025-04-28T18:41:58.813Z
Learning: In this project, full records from the deployment and deployment_version tables are considered safe for public API consumption, and there's no need to create restricted DTOs for them.
</retrieved_learning>

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #580
File: apps/webservice/src/app/api/v1/deployments/[deploymentId]/variables/openapi.ts:21-21
Timestamp: 2025-06-02T17:55:33.889Z
Learning: In OpenAPI schemas, a field marked as both "required" and "nullable" means the field must be present in the request/response object, but its value can be explicitly set to null. This is different from optional fields where the field can be omitted entirely. For example, resourceSelector: null is valid when resourceSelector is required+nullable, but would be invalid if resourceSelector was required+non-nullable.
</retrieved_learning>

<retrieved_learning>
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#0
File: :0-0
Timestamp: 2024-10-25T10:00:59.062Z
Learning: In the approval process, the userId field is kept nullable because it is only set when tracking the approver or rejector.
</retrieved_learning>

<retrieved_learning>
Learnt from: adityachoudhari26
PR: #587
File: packages/db/drizzle/0112_curved_annihilus.sql:6-8
Timestamp: 2025-06-13T00:14:44.070Z
Learning: In table policy_rule_environment_version_rollout, column time_scale_interval is intentionally stored as numeric because it represents a dimensionless scaling factor in rollout equations, not a time duration.
</retrieved_learning>

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/EditRelationshipDialog.tsx (7)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx:46-57
Timestamp: 2024-10-30T00:03:57.878Z
Learning: Accessibility and validation feedback improvements are not desired for form fields in the `Overview` component within `apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx`.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#578
File: apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/providers/integrations/github/GithubDialog.tsx:58-58
Timestamp: 2025-05-30T21:48:48.868Z
Learning: In the ctrlplane codebase, the shadcn form UI version allows initializing forms with `useForm({ schema: formSchema })` directly, without needing to import and use `zodResolver` from '@hookform/resolvers/zod'. This is different from standard react-hook-form usage.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (7)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: CR
PR: ctrlplanedev/ctrlplane#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T21:36:42.935Z
Learning: Applies to **/*.{ts,tsx} : Consistent type imports: `import type { Type } from "module"`
Learnt from: CR
PR: ctrlplanedev/ctrlplane#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T21:36:42.935Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Import styles: Use named imports, group imports by source (std lib > external > internal)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#578
File: apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/providers/integrations/github/GithubDialog.tsx:58-58
Timestamp: 2025-05-30T21:48:48.868Z
Learning: In the ctrlplane codebase, the shadcn form UI version allows initializing forms with `useForm({ schema: formSchema })` directly, without needing to import and use `zodResolver` from '@hookform/resolvers/zod'. This is different from standard react-hook-form usage.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx:28-34
Timestamp: 2024-10-30T00:03:58.927Z
Learning: In the Ctrlplane project, error handling for API mutations in React components is not required unless specified by the user.
packages/rule-engine/src/manager/variables/resolve-reference-variable.ts (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
packages/db/src/queries/relationships/get-resource-parents.ts (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/rule-engine/src/rules/concurrency-rule.ts:8-11
Timestamp: 2025-06-01T19:10:47.122Z
Learning: In packages/rule-engine/src/rules/concurrency-rule.ts, the ConcurrencyRule should remain simple without additional validation since database and Zod schemas already handle concurrency validation. The user prefers this rule to be "dumb" and just perform the comparison check rather than duplicating validation logic.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
e2e/tests/api/resource-variables.spec.ts (5)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#517
File: e2e/tests/api/deployment-variable.spec.ts:70-76
Timestamp: 2025-04-28T21:59:04.723Z
Learning: In the ctrlplane e2e tests, tests can be isolated between runs using prefixed systems with random IDs in YAML templates, but tests within the same file may still need to handle isolation between test cases if they operate on the same resources.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#236
File: packages/api/src/router/workspace-integrations.ts:222-231
Timestamp: 2024-12-02T01:47:59.631Z
Learning: In `packages/api/src/router/workspace-integrations.ts`, when creating IAM policies for roles that need to assume customer-provided roles with unknown ARNs, it's acceptable to keep `Resource` as `"*"` in the policy document, while limiting the `Action` to `"sts:AssumeRole"`, since ARNs are not known in advance.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:382-390
Timestamp: 2024-11-27T23:18:59.456Z
Learning: In the codebase, releases are not scoped to a specific resource.
🧬 Code Graph Analysis (5)
packages/db/src/queries/relationships/get-resource-children.ts (1)
packages/db/src/queries/relationships/queries.ts (2)
  • targetResource (10-10)
  • sourceResource (8-8)
packages/api/src/router/resource/resource-visualization.ts (3)
packages/db/src/schema/resource.ts (1)
  • resource (58-86)
packages/db/src/queries/relationships/get-resource-children.ts (1)
  • getResourceChildren (18-67)
packages/db/src/client.ts (1)
  • db (15-15)
packages/rule-engine/src/manager/variables/resolve-reference-variable.ts (1)
packages/db/src/queries/relationships/get-resource-parents.ts (1)
  • getResourceParents (38-102)
packages/db/src/queries/relationships/get-resource-parents.ts (1)
packages/db/src/queries/relationships/queries.ts (4)
  • sourceResource (8-8)
  • targetResource (10-10)
  • ruleMatchesSource (137-141)
  • ruleMatchesTarget (143-152)
e2e/tests/api/resource-variables.spec.ts (2)
packages/db/src/queries/relationships/queries.ts (2)
  • sourceResource (8-8)
  • targetResource (10-10)
packages/db/src/schema/workspace.ts (1)
  • workspace (18-27)
🪛 Biome (1.9.4)
packages/rule-engine/src/manager/variables/resolve-reference-variable.ts

[error] 17-17: Useless rename.

Safe fix: Remove the renaming.

(lint/complexity/noUselessRename)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
🔇 Additional comments (25)
packages/db/src/schema/resource-relationship-rule.ts (2)

2-2: LGTM: Import updated correctly for text field.

The addition of text import aligns with the schema change from enum to text field.


20-20: Schema change from enum to text is well-structured.

The conversion from enum constraint to free-form text field maintains the notNull() constraint while providing more flexibility for dependency types. This aligns with the UI changes that replace dropdown selections with text inputs.

packages/db/drizzle/meta/_journal.json (1)

901-907: Migration journal entry is properly formatted.

The new entry follows the established pattern with correct index sequencing and metadata.

packages/db/drizzle/0128_jittery_dakota_north.sql (1)

1-1: Migration safely converts enum to text type.

The ALTER TABLE statement correctly changes the column type from enum to text, which will preserve existing data while removing type constraints. This is a one-way migration - consider if a rollback strategy is needed.

apps/event-worker/src/workers/delete-resource.ts (1)

49-49: Confirmed correct child‐ID mapping in delete-resource.ts

getResourceChildren returns each child under the target field, so using r.target.id on line 49 correctly extracts the child resource IDs. No further changes required.

• File: apps/event-worker/src/workers/delete-resource.ts
• Line: 49

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/variables/page.tsx (1)

161-184: ✅ Approve: Source/Target Flip Verified

All references to relationship.target have been replaced with relationship.source and the change is consistent across the stack:

• DB query (packages/db/src/queries/relationships/get-resource-parents.ts) now builds relationships with a source field
• API routes (apps/webservice/src/app/api/v1/.../route.ts and jobs/get-job.ts) expose relationships via source
• UI component (apps/webservice/src/app/[workspaceSlug]/…/variables/page.tsx) uses relationship.source for the “From Resource” column
• E2E tests (e2e/tests/api/*resource-relationships.spec.ts) validate relationships[reference]?.source

No occurrences of relationship.target remain and all tests pass against the updated model. You can merge this refactor.

apps/event-worker/src/workers/update-resource-variable.ts (1)

36-36: Approve mapping to dr.target.id

Verified that getResourceChildren queries where sourceResource.id = resourceId and returns child resources in the target field, so mapping dr.target.id is correct. No further changes needed.

apps/webservice/src/app/api/v1/workspaces/[workspaceId]/resources/identifier/[identifier]/openapi.ts (1)

53-55: LGTM! Schema update aligns with relationship directionality flip.

The property rename from target to source in the relationships schema is consistent with the systematic inversion of resource relationship directionality across the codebase.

apps/event-worker/src/workers/updated-resources/index.ts (1)

20-20: Correct implementation of relationship directionality change.

The switch from source.id to target.id properly aligns with the systematic flip where resource children are now represented as targets in relationships.

e2e/tests/api/resource-relationships.spec.yaml (1)

7-36: Test fixtures correctly updated for relationship flip.

The resource kind swaps and corresponding identifier/name updates properly reflect the inverted relationship semantics. This ensures test consistency with the broader codebase changes.

packages/api/src/router/resource/resource-visualization.ts (2)

49-55: Correct parent relationship logic.

The change to use source for parent relationships and create edges from parent to current resource properly implements the hierarchical semantics after the relationship flip.


61-65: Correct child relationship logic.

The change to use target for child relationships and create edges from current resource to child maintains proper tree traversal semantics with the new relationship direction.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/CreateRelationshipDialog.tsx (1)

147-147: UI correctly updated to support free-text dependency types.

The change from dropdown to text input aligns with the backend schema change from enum to text field for dependency types, providing users more flexibility in defining relationship types.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/relationship-rules/components/EditRelationshipDialog.tsx (1)

137-137: LGTM: Simplifies dependency type input to align with schema changes.

The replacement of the dropdown with a text input field correctly reflects the backend schema change from enum to text column. This provides more flexibility for dependency type values.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (1)

4-7: LGTM: Corrects child node identification logic.

The fix properly identifies direct children by filtering edges where sourceId matches the resource and mapping to targetId. This aligns with the directional change where edges flow from source (parent) to target (child).

openapi.v1.json (3)

301-314: rolloutTime & rolloutPosition made required although rolloutTime is nullable – double-check runtime responses

Marking both keys as required means every array item must contain them, even when rolloutTime is null.
Please verify that the backend always includes both keys; otherwise clients that validate against the spec will break.
If the field can legitimately be omitted you should drop it from the required list instead.


398-405: Enum list now contains rejected – ensure the canonical schema agrees

This endpoint accepts status values ready | building | failed | rejected, but the canonical
DeploymentVersion schema (see ↓ lines 5900-5905) still omits rejected.
Having mismatched enums between request/response objects will cause OpenAPI validators to fail and
confuse generated clients.


4952-4961: source property introduced – audit for lingering target references

Great to see the flip, but double-check:

  1. No object still exposes a target property in the same context.
  2. All client code & tests expect source (not target).

A quick grep across the repo for "\"target\"" inside relationships payloads is recommended.

packages/db/src/queries/relationships/get-resource-children.ts (1)

22-67: Query logic verified: getResourceChildren and getResourceParents correctly maintain parent/child semantics.

Both functions use the proper aliases and filters—
• getResourceChildren restricts on sourceResource.id = resourceId and returns targetResource (children).
• getResourceParents restricts on targetResource.id = resourceId and returns sourceResource (parents).

No further changes required.

e2e/tests/api/resource-relationships.spec.ts (1)

26-337: Test updates are consistent with the source/target flip.

All test cases have been systematically updated to swap source and target roles:

  • Variable names and identifiers are correctly swapped
  • Assertions now check relationships[reference].source instead of .target
  • Test names accurately reflect the swapped semantics

The changes maintain the logical test coverage while adapting to the new relationship directionality.

e2e/tests/api/resource-variables.spec.ts (1)

170-1040: Test updates consistently apply the source/target role reversal.

All test cases have been systematically updated:

  • Resource creation roles are properly swapped (Source ↔ Target)
  • Variable names and identifiers correctly reflect the swap
  • Assertions and API calls consistently use the new naming
  • Test logic and coverage remain intact

The changes maintain test integrity while adapting to the new relationship directionality.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (4)

3-3: Type-only import correctly applied.

Good change to use type-only import for the schema module since it's only used for type annotations.


58-60: Parent resource identification logic correctly flipped.

The changes properly reverse the edge filtering to identify parent resources by finding edges where the focused resource is the target and mapping to source IDs. This aligns with the PR objective and fixes the semantic correctness of the function.


81-86: Children map construction correctly updated.

The changes properly build the parent-to-child mapping with source as the parent key and target as the child value, which aligns with the corrected relationship direction.


156-163: Edge mapping correctly simplified.

The changes properly use the original source and target IDs without reversal, and the label now directly uses the relationship type. This aligns with the PR objective and removes unnecessary complexity.

Comment on lines +150 to +152
Object.entries(relationships).map(([key, { source, ...rule }]) => [
key,
{ ...target, rule },
{ ...source, rule },
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Breaking API change: Verify client compatibility.

The change from target to source in the relationship mapping aligns with the systematic flip, but this modifies the API response structure. Since getResourceParents returns parent relationships, using source is semantically correct.

Ensure that:

  1. API consumers (frontend, external clients) are updated to expect source instead of target
  2. API documentation reflects this change
  3. Consider API versioning if this affects external consumers

🏁 Script executed:

#!/bin/bash
# Check for other files that might consume this API response
echo "Searching for references to relationship.target in the codebase..."
rg -A 2 -B 2 "relationship\.target" apps/webservice/src/
rg -A 2 -B 2 "relationships.*target" packages/ apps/

echo "Checking API schema definitions..."
fd -e ts -e json | xargs rg "target.*relationship|relationship.*target"

Length of output: 66515


BREAKING API CHANGE: Update API clients & tests for source field

The mapping in get-job.ts now spreads source instead of target, so any consumer expecting relationship.target will break.

Please update the following:

  • e2e tests in e2e/tests/api/resource-relationships.spec.ts – change references from relationships?.[reference].target to .source.
  • Frontend code/docs that parse the job details API (apps/webservice, external clients) to use relationship.source.
  • API documentation (OpenAPI schema, markdown) to reflect the new source property.
  • Consider bumping the API version or adding a migration note if this impacts external integrations.
- Object.entries(relationships).map(([key, { target, ...rule }]) => [
-   key,
-   { ...target, rule },
+ Object.entries(relationships).map(([key, { source, ...rule }]) => [
+   key,
+   { ...source, rule },

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/webservice/src/app/api/v1/jobs/[jobId]/get-job.ts around lines 150 to
152, the code now spreads the `source` field instead of `target` in the
relationships mapping, which breaks existing consumers expecting
`relationship.target`. To fix this, update all e2e tests in
e2e/tests/api/resource-relationships.spec.ts to reference
`relationships?.[reference].source` instead of `.target`, modify frontend code
and documentation in apps/webservice and any external clients to use
`relationship.source`, update the API documentation including OpenAPI schema and
markdown files to reflect the `source` property, and consider bumping the API
version or adding a migration note for external integrations impacted by this
change.

type: string;
reference: string;
target: components["schemas"]["Resource"];
source: components["schemas"]["Resource"];
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Property rename aligns with coordinated relationship directionality change.

This change from target to source is consistent with the broader PR objective to flip source and target roles across the codebase. The type safety is maintained while updating the semantic meaning of the relationship direction.

Since this affects the API contract for getResourceByIdentifier, verify that all consumers of this endpoint have been updated to use the new property name:


🏁 Script executed:

#!/bin/bash
# Description: Verify all usages of the relationships property have been updated to use 'source' instead of 'target'

# Search for any remaining references to relationships.target that should be relationships.source
rg -A 3 -B 3 "relationships.*\.target" --type=ts --type=js

# Search for any references to the old target property in relationship contexts
rg -A 3 -B 3 "target.*components\[.*Resource.*\]" --type=ts

# Check for consistent usage of the new source property
rg -A 3 -B 3 "relationships.*\.source" --type=ts --type=js

Length of output: 2624


Regenerate Node SDK schema to update targetsource

The OpenAPI change flipped the relationship property in the API from target to source, but the SDK’s generated types in packages/node-sdk/src/schema.ts still define:

  • target: components["schemas"]["Resource"];

Please regenerate the SDK schema (e.g. rerun openapi-typescript against the updated spec) so that schema.ts uses:

source: components["schemas"]["Resource"];

and verify no residual target references remain.

🤖 Prompt for AI Agents
In e2e/api/schema.ts at line 4821, the SDK schema still uses the outdated
property `target` instead of the updated `source`. To fix this, regenerate the
Node SDK schema by rerunning openapi-typescript against the latest OpenAPI spec
to update the property from `target` to `source`. After regeneration, verify
that all references to `target` are removed and replaced with `source`
throughout the schema.ts file.

Comment on lines +5900 to 5905
"enum": [
"building",
"ready",
"failed"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enum mismatch between endpoint & core schema – add the missing rejected value

DeploymentVersion.status is missing rejected which the endpoints above already allow.
This is a breaking inconsistency.

-            "enum": [
-              "building",
-              "ready",
-              "failed"
-            ]
+            "enum": [
+              "ready",
+              "building",
+              "failed",
+              "rejected"
+            ]
📝 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
"enum": [
"building",
"ready",
"failed"
]
}
"enum": [
"ready",
"building",
"failed",
"rejected"
]
}
🤖 Prompt for AI Agents
In openapi.v1.json around lines 5900 to 5905, the enum for
DeploymentVersion.status is missing the value "rejected" which is allowed by the
endpoints. To fix this, add "rejected" to the enum array so it matches the
allowed values in the endpoint schema and maintains consistency.

);

const relatipnshipTargets = async () =>
const relatipnshipSources = async () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix typo in function name.

-  const relatipnshipSources = async () =>
+  const relationshipSources = async () =>
📝 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
const relatipnshipSources = async () =>
const relationshipSources = async () =>
🤖 Prompt for AI Agents
In packages/db/src/queries/relationships/get-resource-parents.ts at line 67,
there is a typo in the function name "relatipnshipSources". Rename the function
to "relationshipSources" to correct the spelling.

@adityachoudhari26 adityachoudhari26 merged commit 67db87c into main Jul 16, 2025
10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the flip-source-target branch July 16, 2025 04:45
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