Skip to content

๐Ÿ›ก๏ธ Sentinel: [๊ธฐ๋Šฅ ํ–ฅ์ƒ] ERD ์—”์ง€๋‹ˆ์–ด๋ง ๋„๊ตฌ ๊ธฐ๋Šฅ ํ™•์žฅ ๋ฐ ์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ ๊ฒ€์ฆ ์ถ”๊ฐ€#295

Open
seonghobae wants to merge 2 commits into
developmentalfrom
sentinel-erd-features-17449793604625455777

Conversation

@seonghobae

Copy link
Copy Markdown

๐Ÿšจ ์‹ฌ๊ฐ๋„: ํ–ฅ์ƒ

๐Ÿ’ก ์ทจ์•ฝ์  ๋ฐ ๊ฐœ์„  ์‚ฌํ•ญ:

๊ธฐ์กด ERD ๋„๊ตฌ์—๋Š” ํ…Œ์ด๋ธ”, ์ปฌ๋Ÿผ, ์™ธ๋ž˜ ํ‚ค๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ๊ธฐ๋Šฅ์ด ์—†์—ˆ์œผ๋ฉฐ, ์‹œ๊ฐํ™”๋ฅผ ์œ„ํ•œ Mermaid ํ˜•ํƒœ์˜ ์ถœ๋ ฅ ๊ธฐ๋Šฅ๋„ ๋ถ€์žฌํ–ˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ์ œ๊ฑฐ ๊ธฐ๋Šฅ ๋ถ€์žฌ ์‹œ ๋ชจ๋ธ์„ ์žฌ์ƒ์„ฑํ•ด์•ผ ํ•˜๋Š” ๋ถˆํŽธํ•จ๊ณผ ํ•จ๊ป˜, ์ฐธ์กฐ ์ค‘์ธ ์—”ํ‹ฐํ‹ฐ๊ฐ€ ๋ถˆ์™„์ „ํ•œ ์ƒํƒœ๋กœ ์‚ญ์ œ๋˜๋Š” '์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ ์œ„๋ฐ˜' ์ƒํƒœ๊ฐ€ ๋ฐœ์ƒํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๐ŸŽฏ ์˜ํ–ฅ:

์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ์ด ํ™•๋ณด๋˜์ง€ ์•Š์œผ๋ฉด ๋„๋ฉ”์ธ ์„ค๊ณ„ ์‹œ ๋ฐ์ดํ„ฐ ๋ถˆ์ผ์น˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด๋Š” ํ›„์† DDL ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰ ์‹œ ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๋‚˜ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ณด์•ˆ์ƒ ์•…์šฉ ๊ฐ€๋Šฅํ•œ ์—ฃ์ง€ ์ผ€์ด์Šค๋ฅผ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ”ง ํ•ด๊ฒฐ ๋ฐฉ์•ˆ:

  • removeTable, removeColumn, removeForeignKey ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
  • ๋‹ค๋ฅธ ์—”ํ‹ฐํ‹ฐ์—์„œ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ํ…Œ์ด๋ธ”์ด๋‚˜ ์ปฌ๋Ÿผ์„ ์‚ญ์ œํ•˜๋ ค๊ณ  ํ•  ๋•Œ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” ๋ฐฉ์–ด์  ๊ฒ€์ฆ ๋กœ์ง(Defensive Validation) ์ ์šฉ
  • generateMermaid ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ์‹œ๊ฐํ™” ๊ธฐ๋Šฅ ์ง€์›

โœ… ๊ฒ€์ฆ ๋ฐฉ๋ฒ•:

  • 100% ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ ๋‹ฌ์„ฑ (pnpm coverage:erd)
  • CI ํŒŒ์ดํ”„๋ผ์ธ์˜ ๋ชจ๋“  ํ…Œ์ŠคํŠธ์™€ ๋ฆฐํŒ… ๊ฒ€์‚ฌ ํ†ต๊ณผ ์™„๋ฃŒ

PR created automatically by Jules for task 17449793604625455777 started by @seonghobae

@google-labs-jules

Copy link
Copy Markdown

๐Ÿ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a ๐Ÿ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 21, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Expands the in-memory ERD modeling utility (ERDModel) used in @argos/web to support schema element deletion (tables/columns/foreign keys), enforce referential-integrity constraints during deletion, and generate Mermaid ER diagram output for visualization.

Changes:

  • Added removeTable, removeColumn, and removeForeignKey with defensive referential-integrity checks.
  • Added generateMermaid() to emit Mermaid erDiagram output including PK/FK annotations and relationships.
  • Added Vitest coverage for removal operations and Mermaid generation; documented the security/learning note in .jules/sentinel.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
packages/web/src/lib/erd.ts Adds removal APIs with integrity checks and Mermaid diagram generation.
packages/web/src/lib/erd.test.ts Adds unit tests covering removals and Mermaid output formatting.
.jules/sentinel.md Records a sentinel entry about referential-integrity validation for ERD deletions.

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +86 to +90
removeTable(name: string): void {
const table = this.tables.get(name)
if (!table) {
throw new Error(`Table '${name}' does not exist.`)
}
Comment on lines +91 to +98
// Cannot remove if referenced by another table
for (const t of this.tables.values()) {
for (const fk of t.foreignKeys) {
if (fk.referenceTable === name) {
throw new Error(`Cannot remove table '${name}' because it is referenced by '${t.name}'.`)
}
}
}
Comment on lines +102 to +106
removeColumn(tableName: string, columnName: string): void {
const table = this.tables.get(tableName)
if (!table) {
throw new Error(`Table '${tableName}' does not exist.`)
}
Comment on lines +129 to +133
removeForeignKey(tableName: string, columnName: string, referenceTable: string, referenceColumn: string): void {
const table = this.tables.get(tableName)
if (!table) {
throw new Error(`Table '${tableName}' does not exist.`)
}
// Add relationships
for (const table of this.tables.values()) {
for (const fk of table.foreignKeys) {
mermaid += ` ${table.name} ||--o{ ${fk.referenceTable} : "${fk.columnName} references ${fk.referenceColumn}"\n`
SERIAL id PK
INTEGER user_id FK
}
posts ||--o{ users : "user_id references id"`
Copilot AI review requested due to automatic review settings July 21, 2026 22:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (3)

packages/web/src/lib/erd.ts:96

  • removeTable is intended to block deletion when another table references the target, but the current scan also includes the table being removed. This makes it impossible to remove a table that has a self-referential foreign key (e.g., hierarchical tables), even though deleting the table would remove those FKs as well.
    // Cannot remove if referenced by another table
    for (const t of this.tables.values()) {
      for (const fk of t.foreignKeys) {
        if (fk.referenceTable === name) {
          throw new Error(`Cannot remove table '${name}' because it is referenced by '${t.name}'.`)
        }

packages/web/src/lib/erd.ts:164

  • generateMermaid currently emits relationships as ${table.name} ||--o{ ${fk.referenceTable}, but generateDDL defines the FK as FOREIGN KEY (...) REFERENCES referenceTable(...) (i.e., the referenceTable is the parent / "one" side). The Mermaid relationship direction is reversed relative to the FK semantics.
    // Add relationships
    for (const table of this.tables.values()) {
      for (const fk of table.foreignKeys) {
        mermaid += `  ${table.name} ||--o{ ${fk.referenceTable} : "${fk.columnName} references ${fk.referenceColumn}"\n`
      }

packages/web/src/lib/erd.test.ts:285

  • The Mermaid relationship assertion expects posts ||--o{ users, but the FK semantics in this test are posts.user_id referencing users.id, so the ||--o{ one-to-many direction should be users ||--o{ posts (users has many posts). Update the expected string to match the corrected Mermaid output.
      const mermaid = model.generateMermaid()
      const expected = `erDiagram
  users {
    SERIAL id PK
    VARCHAR(255) name
  }
  posts {
    SERIAL id PK
    INTEGER user_id FK
  }
  posts ||--o{ users : "user_id references id"`
      expect(mermaid).toBe(expected)

Comment thread package.json
Comment on lines +23 to +28
"hono": "4.12.27",
"js-yaml": "4.3.0",
"@hono/node-server": "^2.0.5",
"body-parser": "^2.3.0",
"brace-expansion": "^2.0.1",
"fast-uri": "^3.1.3"
Comment thread package.json
Comment on lines +25 to +28
"@hono/node-server": "^2.0.5",
"body-parser": "^2.3.0",
"brace-expansion": "^2.0.1",
"fast-uri": "^3.1.3"
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