-
Notifications
You must be signed in to change notification settings - Fork 11
fix: flip source and target #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis 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
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"
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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/toIdentifiernaming no longer reflects direction after flipWith “source ↔ target” inverted, the semantics of from → to have reversed.
Consider renaming tosourceIdentifier/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 invertedBoth functions’
from/whereclauses 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
fromtable, join direction,wherefilters, and selected alias in each:
In
get-resource-parents.ts:
• Change.from(targetResource)→.from(sourceResource)
• Swapwhere(eq(targetResource.id, resourceId))→where(eq(sourceResource.id, resourceId))
• Selecttarget: targetResourceinstead ofsource: sourceResourceIn
get-resource-children.ts:
• Change to.from(sourceResource)
• Swapwhere(eq(sourceResource.id, resourceId))→where(eq(targetResource.id, resourceId))
• Selectsource: sourceResourceinstead oftarget: targetResourceEnsuring 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
📒 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
textimport 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
getResourceChildrenreturns each child under thetargetfield, so usingr.target.idon line 49 correctly extracts the child resource IDs. No further changes required.• File: apps/event-worker/src/workers/delete-resource.ts
• Line: 49apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/variables/page.tsx (1)
161-184: ✅ Approve: Source/Target Flip VerifiedAll references to
relationship.targethave been replaced withrelationship.sourceand the change is consistent across the stack:• DB query (packages/db/src/queries/relationships/get-resource-parents.ts) now builds relationships with a
sourcefield
• API routes (apps/webservice/src/app/api/v1/.../route.ts and jobs/get-job.ts) exposerelationshipsviasource
• UI component (apps/webservice/src/app/[workspaceSlug]/…/variables/page.tsx) usesrelationship.sourcefor the “From Resource” column
• E2E tests (e2e/tests/api/*resource-relationships.spec.ts) validaterelationships[reference]?.sourceNo occurrences of
relationship.targetremain 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 todr.target.idVerified that
getResourceChildrenqueries wheresourceResource.id = resourceIdand returns child resources in thetargetfield, so mappingdr.target.idis 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
targettosourcein 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.idtotarget.idproperly 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
sourcefor 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
targetfor 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
sourceIdmatches the resource and mapping totargetId. This aligns with the directional change where edges flow from source (parent) to target (child).openapi.v1.json (3)
301-314:rolloutTime&rolloutPositionmade required althoughrolloutTimeis nullable – double-check runtime responsesMarking both keys as required means every array item must contain them, even when
rolloutTimeisnull.
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 therequiredlist instead.
398-405: Enum list now containsrejected– ensure the canonical schema agreesThis endpoint accepts
statusvaluesready | building | failed | rejected, but the canonical
DeploymentVersionschema (see ↓ lines 5900-5905) still omitsrejected.
Having mismatched enums between request/response objects will cause OpenAPI validators to fail and
confuse generated clients.
4952-4961:sourceproperty introduced – audit for lingeringtargetreferencesGreat to see the flip, but double-check:
- No object still exposes a
targetproperty in the same context.- All client code & tests expect
source(nottarget).A quick grep across the repo for
"\"target\""insiderelationshipspayloads 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 onsourceResource.id = resourceIdand returnstargetResource(children).
• getResourceParents restricts ontargetResource.id = resourceIdand returnssourceResource(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].sourceinstead 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.
| Object.entries(relationships).map(([key, { source, ...rule }]) => [ | ||
| key, | ||
| { ...target, rule }, | ||
| { ...source, rule }, |
There was a problem hiding this comment.
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:
- API consumers (frontend, external clients) are updated to expect
sourceinstead oftarget - API documentation reflects this change
- 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 fromrelationships?.[reference].targetto.source. - Frontend code/docs that parse the job details API (
apps/webservice, external clients) to userelationship.source. - API documentation (OpenAPI schema, markdown) to reflect the new
sourceproperty. - 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"]; |
There was a problem hiding this comment.
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=jsLength of output: 2624
Regenerate Node SDK schema to update target → source
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.
| "enum": [ | ||
| "building", | ||
| "ready", | ||
| "failed" | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| "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 () => |
There was a problem hiding this comment.
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.
| 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.
Summary by CodeRabbit
Bug Fixes
Database
API & Documentation
Tests