feat(erd): add entity-relationship diagram type (#115) - #183
akyourowngames wants to merge 5 commits into
Conversation
prashantpiyush1111
left a comment
There was a problem hiding this comment.
I reviewed the current PR diff and changed files. The ERD implementation itself is substantial and the PR is marked mergeable, but I found one blocking scope/repository-hygiene issue: New Text Document.txt is an unrelated file containing a GitHub/fork instruction. It is not part of the ERD feature and should not be committed to the repository. Please remove it and re-run the relevant checks before merge.
tt-a1i
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Changes Requested
Thanks for taking on a substantial and valuable addition. A typed ERD fits the project direction, but the current head has correctness and distribution blockers that need to be resolved before merge.
Blocking findings
-
The generated ERD SVG is not well-formed XML. In
archify/renderers/erd/render-erd.mjs:607,data-node-kindandfocusNodeAttrs(...)are concatenated without whitespace. Runningnode --test test/generated-artifact-xml.test.mjsfails onarchify/examples/billing.erd.htmlwith39:86: no whitespace between attributes. -
Foreign-key validation fails open. At lines 447-455, an attribute with
role: "foreign"and noreferencesvalue is accepted because validation only runs whenreferencesalready exists. A direct render probe exits 0 and writes an artifact. Please require a valid reference whenever the role isforeign, and add a regression test for the missing-reference case. -
Orphan validation fails open when there are no relationships. Lines 474-485 wrap the entire orphan check in
if (connections.length > 0). Settingrelationships: []therefore accepts every non-standalone entity and renders successfully. The orphan rule should also apply to the zero-relationship case, with a committed regression test. -
The installed package and the Issue #115 acceptance surface are incomplete.
archify.zipcontains no ERD schema, renderer, or example, and its CLI still lists only the original five types. Issue #115 also states that guide routing should learn ERD and repository evidence should reuse the existing--repo-rootgates; the PR explicitly defers both. Please complete these surfaces in this PR, rebuild the canonical ZIP, and run package smoke tests. -
Remove the unrelated
New Text Document.txt. It contains only a fork instruction and is not part of the ERD feature.
After these fixes, please run the full required suite and attach the current CI/package evidence. The feature itself is worth continuing; this review is about making the typed, fail-closed, distributed contract match what the PR and issue promise.
|
@tt-a1i on it!! |
tt-a1i
left a comment
There was a problem hiding this comment.
Additional exact-head review at b32c99a. The previous XML/FK/orphan/package/scope findings were rerun and still apply; this adds newly isolated failures rather than repeating those requests.
[P1] Populate the centers required by the shared router (archify/renderers/erd/render-erd.mjs:86). Entity rectangles contain x/y/width/height but never compute cx/cy after positioning. Shared anchor/default-side helpers require those fields. All six relationships in the official billing fixture emit undefined/NaN coordinates. Reproduced with node archify/bin/archify.mjs validate erd archify/examples/billing.erd.json --json: exit1, artifact/finite-svg. A two-entity probe likewise renders an unusable M undefined 152 L undefined 152. Add finite-coordinate and public validate/deliver regressions, not only marker/golden string checks.
[P2] Do not discard explicit positions when another entity omits its position (:90 onward). With standalone A at[400,300] and B lacking pos, entities.every(pos) chooses auto-grid for all entities and moves A to[40,40]. This silently overrides authored geometry and contradicts the typed/manual-layout contract. Preserve authored positions or reject missing required geometry; do not rewrite all nodes.
ERD tests12/12 and golden checks pass while reproducing broken geometry; the separate XML test still fails. Source-generated validators pass. These passes are explicitly not a correct final-artifact acceptance. No edits or merge.
Implements a new sixth typed diagram `erd` rendering entities, attributes, primary/foreign keys, and relationship cardinality as self-contained HTML with deterministic SVG, following the existing architecture/dataflow pattern. - schemas/erd.schema.json: entity kinds (transactional/reference/event/ junction/external), attributes with role (primary/foreign/attribute), FK `references` to entity.attribute, relationship cardinality.from/to. - generated validator via scripts/generate-validators.mjs (diagramTypes +erd). - renderers/erd/render-erd.mjs: fail-closed semantic validation (cardinality on both ends, FK resolves to real entity+attribute, at most one PK, no duplicate attribute names, no orphan unless standalone, enforced_by resolves) plus legible crow's-foot markers that do not rely on color alone. - CLI + preview wiring (bin/archify.mjs, bin/preview.mjs, shared/cli.mjs, shared/i18n.mjs), SKILL.md type router + authoring invariant. - examples/billing.erd.json + golden billing.erd.html, regression tests. Co-Authored-By: Claude Code <noreply@anthropic.com>
…ence gates, remove stray file
…ctor-safe evidence gate, scoped label fix
b32c99a to
987667c
Compare
|
@tt-a1i all findings from both reviews are addressed in the rebased head ( Review 1 (Aug 29)
Review 2 (Aug 31)
Two judgment calls to flag
Residual notes (not blockers from my side)
Requesting re-review. Happy to split anything you would rather see separated. |
|
Warning Review limit reachedNext included review available in 38 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (19)
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 |
tt-a1i
left a comment
There was a problem hiding this comment.
I compared this head (987667c76fe6c9e85a597b18befe00d6bc0652d0) with #399 (fecaa6091b1e620e1263d2d1226c5bff53a5787c) against issue #115. This PR's 16 focused ERD tests pass; #399's 10 focused tests also pass. Those passes do not settle the schema contract.
Recommended consolidation: use #183 as the integration base because it already implements the issue's repository evidence, explicit cardinality requirement, standalone escape and enforcement-reference vocabulary with less shared-router churn. Reuse #399's useful typed-cardinality/marker and obstacle-routing fixtures instead of shipping two schemas. The shared architecture router is already extracted in current dev (#266), and repository evidence now has a common per-type mapping (#389); integrate those existing seams rather than restoring the old versions.
P2 reproduced blocker: changing the first billing relationship's cardinality.to to banana still makes public validate erd --json exit 0 / ok:true. The schema accepts any nonempty string and crowMarker() falls back to a one marker. Constrain cardinality to a documented, typed set and derive markers from that set; reject unrecognized values with source-specific diagnostics. Existing names such as cardinality.from/to can stay — a second field layout is not necessary to get strict semantics.
Required contract clarification: the current per-attribute primary counter rejects a two-column identity as “2 primary keys”. I reproduced this by marking a second users attribute primary. One composite identity and two unrelated primary identities are not the same assertion. Define whether this first slice represents a grouped composite identity or explicitly does not support it; do not imply that all data models with composite keys are invalid. This is a representational limit to settle before publishing schema v1, not a request for automatic database introspection.
Next owner: #183 author leads the consolidated current-dev revision, retaining authored positions and prior XML/FK/orphan fixes. Add the cardinality negative and chosen composite-identity contract tests, verify obstruction routing using the canonical router, then provide current-revision source-evidence, browser crow's-foot/attribute readability, export and isolated-package evidence plus green CI. The previous fixed defects are not being reasserted; the invalid-cardinality reproduction is new. #399 remains available for attribution and useful source/tests until a replacement is actually accepted. Neither PR is ready to merge; main remains untouched.
Summary
Implements #115: a sixth typed diagram
erdfor entity-relationship maps (entities, attributes, primary/foreign keys, relationship cardinality) as self-contained HTML with deterministic SVG, following the existing renderer pattern.Rebased onto current
main(was CONFLICTING, now MERGEABLE). All findings from both owner reviews addressed (details in reply below).User problem /-linked issue
Closes #115. The five existing types cannot state data shape (cardinality, keys, constraints).
What changed
archify/schemas/erd.schema.json: entity kinds, attribute roles, FKreferences, both-end cardinality,repository+sources[]evidence shape (1–3 items, same bound as architecture).archify/renderers/erd/render-erd.mjs: fail-closed validation (cardinality both ends, FK must reference realentity.attribute, at most one PK, no duplicate attribute names, orphan incl. zero-relationship case,enforced_byresolves), cx/cy centres always in sync, per-entity authored-pos preservation, crow's-foot markers.guiderouting: newdata-modelrecipe (archify/recipes/scenarios.mjs, en+zh, proofbilling).--repo-rootevidence gates:repository-evidence.mjsgeneralized to per-type surfaces (components/entities); CLI gate extended (inline list sodoctorstill runs from incomplete installs); help text updated.SKILL.mdtype router + authoring invariant;bin/archify.mjs,bin/preview.mjs,shared/cli.mjs,shared/i18n.mjslisterd.archify/examples/billing.erd.json(+HTML in botharchify/examples/andexamples/).archify.ziprebuilt with Node 22 (includes ERD surface; package smoke-tested outside repo).Deliberately not changed
labelPointfor all types and regressed the architectureweb-appgolden, so it was reverted. The ERD billing fixture instead carries explicitlabelDx/labelDyon theviarelationship (ERD-scoped fix).Compatibility / migration
Purely additive: new type keyword, schema, renderer, recipe, examples. Existing five schemas, validators, artifacts, and viewer contract untouched (architecture golden passes unchanged).
Failure behavior / rollback
Invalid ERD fails non-zero with machine-readable diagnostics;
deliverpreserves previous output on failure. Rollback: revert the 5 commits.Tests and final-artifact evidence
node --test test/erd.test.mjs16/16 (new: FK-without-references fails closed, orphan-with-relationships:[]fails closed, finite-coordinate render check, authored-pos preservation).test/guide.test.mjs(12 recipes incl.data-model, en+zh routing),generated-artifact-xml3/3,test/golden.mjsall checks passed,check:validators/check:brand-marks/check:release-identityexit 0.test/cli.test.mjs40/41,test/repository-evidence.test.mjs8/9 in parallel run; the 2 remaining failures are Windows-only preview-server lifecycle issues (SIGTERMkill semantics, 20s port contention) that pass in isolation and also fail on unmodifiedupstream/maincode paths untouched by this PR.deliver erd billing --quality showcase: 9/9 checks, 0 errors, 0 warnings (spec sha2569601b04b…, artifact55b9da75…, 705101 bytes).visual-check: pass with real Chrome, 0 diagnostics (perceptual review still pending a human).archify.zipoutside repo renders + validates billing and routes guide→data-model(high confidence).Regenerated files
archify/examples/billing.erd.html,examples/billing.erd.html,archify/renderers/shared/generated-validators.mjs,archify.zip.