Make connection direction structural, remove EdgeDirection enum#31
Conversation
- Arrow is now derived from source→target ordering, never stored - Two-way relationships are two separate Connections, not a BIDIRECTIONAL flag - Removed EdgeDirection enum, direction field, and related UI controls - Introduced "Port" terminology for input/output connection points - Added ADR-0009 documenting the decision and its consequences - Updated CONTEXT.md with structural direction rules and new Port term - Generated Prisma files removed from git (regenerated on install)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughRemoves stored EdgeDirection end-to-end: direction is now structural (sourceId → targetId). Docs, Prisma schema, Zod inputs, service, React Flow canvas, edge UI, validation helper, and tests updated to persist only label and enforce topology via canConnect. ChangesEdge Direction Structural Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/server/architecture/edge.service.ts (1)
103-110: ⚡ Quick winAdd a regression test for the
label: undefinedno-op contract.This doc now defines
label: undefinedas “leave unchanged”; please add an explicit test to lock that behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server/architecture/edge.service.ts` around lines 103 - 110, Add a regression test that verifies the Edge service method which edits a Connection's label (the method that loads an Edge by id, resolves its Project and calls access.assertCanWrite) treats label: undefined as a no-op and leaves the stored label unchanged while label: null clears it; implement the test by (1) creating an Edge/Connection with a known label, (2) invoking the service's update/edit method with the same Edge id and payload { label: undefined } and asserting the label remains the same, and (3) invoking it with { label: null } and asserting the label is cleared, mock or stub access.assertCanWrite as needed and use the same service method used in production to ensure the behavior is locked in.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 192-193: The README currently states that `generated/prisma` is
"committed to git" which conflicts with the PR's changes to `.gitignore` and
`CLAUDE.md`; update the README text mentioning `generated/prisma` (and any
related sentence on Line 81) to reflect the new policy (e.g., "regenerated and
git-ignored" or remove the claim that it's committed) so the docs match the
`.gitignore` and `CLAUDE.md` change.
In `@src/app/p/`[slug]/_canvas/connection-edge.tsx:
- Line 59: The label editor and updateEdge logic in connection-edge.tsx
currently rely only on optimistic state (const d: ConnectionEdgeData = data ?? {
label: null }) which allows read-only viewers to open edits; wrap the edit
affordances and mutation calls with the existing CanEditContext
(useContext(CanEditContext) or the project's CanEdit hook) so that label editor
UI (around the label open handlers at lines ~75-77) is only rendered/triggered
when canEdit is true, and also guard the updateEdge mutation and rollback/toast
paths (around lines ~134-158) by checking canEdit before dispatching mutations
or showing rollbacks. Ensure you reference and use the same CanEditContext
symbol used elsewhere in the app to prevent viewers from seeing or executing
edit actions.
---
Nitpick comments:
In `@src/server/architecture/edge.service.ts`:
- Around line 103-110: Add a regression test that verifies the Edge service
method which edits a Connection's label (the method that loads an Edge by id,
resolves its Project and calls access.assertCanWrite) treats label: undefined as
a no-op and leaves the stored label unchanged while label: null clears it;
implement the test by (1) creating an Edge/Connection with a known label, (2)
invoking the service's update/edit method with the same Edge id and payload {
label: undefined } and asserting the label remains the same, and (3) invoking it
with { label: null } and asserting the label is cleared, mock or stub
access.assertCanWrite as needed and use the same service method used in
production to ensure the behavior is locked in.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 745170d9-60c2-4d47-8a97-8c7d98d39f70
⛔ Files ignored due to path filters (16)
generated/prisma/browser.tsis excluded by!**/generated/**generated/prisma/client.tsis excluded by!**/generated/**generated/prisma/commonInputTypes.tsis excluded by!**/generated/**generated/prisma/enums.tsis excluded by!**/generated/**generated/prisma/internal/class.tsis excluded by!**/generated/**generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**generated/prisma/models.tsis excluded by!**/generated/**generated/prisma/models/Account.tsis excluded by!**/generated/**generated/prisma/models/Edge.tsis excluded by!**/generated/**generated/prisma/models/Node.tsis excluded by!**/generated/**generated/prisma/models/Post.tsis excluded by!**/generated/**generated/prisma/models/Project.tsis excluded by!**/generated/**generated/prisma/models/Session.tsis excluded by!**/generated/**generated/prisma/models/User.tsis excluded by!**/generated/**generated/prisma/models/VerificationToken.tsis excluded by!**/generated/**
📒 Files selected for processing (17)
.gitignoreCLAUDE.mdCONTEXT.mdREADME.mddocs/adr/0005-edge-scope-and-service-enforced-invariants.mddocs/adr/0009-connection-direction-is-structural.mdprisma/schema.prismasrc/app/p/[slug]/_canvas/canvas.tsxsrc/app/p/[slug]/_canvas/component-node.tsxsrc/app/p/[slug]/_canvas/connection-edge.tsxsrc/lib/connection-rules.test.tssrc/lib/connection-rules.tssrc/lib/schemas.tssrc/server/api/routers/architecture.tssrc/server/architecture/__tests__/edge.service.test.tssrc/server/architecture/edge.service.tssrc/test/global-setup.ts
- Gate connection label editing to non-owners, mirroring component rename/delete permissions - Clarify README: Prisma client is git-ignored and regenerated on install - Add test locking in undefined (no-op) vs null (clear) contract for edge labels
Summary
EdgeDirectionenum (NONE/FORWARD/BIDIRECTIONAL) from schema — direction is no longer a stored fielddirectionfield from Edge model,connectNodesInput/updateEdgeInput, service-layer parity guard, and client Zod schemacanConnecthelper in~/lib/connection-rules.tsfor pure topology validation (no self-links, no duplicates)connectionMode(enforce source→target pairing) and callcanConnectin React Flow'sisValidConnectioncallback/generated/as git-ignored (regenerated on install, not committed)Testing
pnpm check— eslint, type-check, and parity guards passpnpm dev— start app and verify:canConnectSummary by CodeRabbit
New Features
Refactor
Documentation