Skip to content

feat(persistence): saved diagram views + table annotations - #467

Merged
seonghobae merged 10 commits into
mainfrom
feat/entities-on-main
Jul 11, 2026
Merged

feat(persistence): saved diagram views + table annotations#467
seonghobae merged 10 commits into
mainfrom
feat/entities-on-main

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Independent PR against main (split out of #440). Now also contains the merged stack: #469 (data dictionary export) and #485 (API keys).

  • Saved diagram views + table annotations (alembic 0004_merge_heads00050006, editor-gated, IDOR-safe)
  • GET /data-dictionary.md — Markdown data dictionary merged with annotations (living documentation)
  • API keys (/api/api-keys, Bearer pgerd_… in get_current_user): SHA-256 hash only, secret shown once, auditable revocation, uniform 404; migration 0007_api_key verified on real Postgres; also fixes the latent 0003_revoked_token down_revision bug that breaks alembic upgrade head on fresh DBs
    backend tests incl. IDOR/editor gates; mypy clean.

🤖 Generated with Claude Code

Comment thread backend/tests/test_api_keys.py Fixed
Comment thread backend/app/auth.py Fixed
@opencode-agent
opencode-agent Bot disabled auto-merge July 7, 2026 12:11
seonghobae and others added 5 commits July 8, 2026 11:11
Split out of the adhesive-piper foundation as an independent PR against main. Two persisted entities sharing the alembic chain (0004_merge_heads resolves main's two 0003 heads -> 0005_diagram_view -> 0006_table_annotation), models.py, and router registration. /api/diagram-views (save/load ERD canvas layouts) and /api/annotations (per-table notes), both editor-gated + IDOR-safe uniform 404. +8 tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
…hare

down_revision='0002' references a nonexistent revision (actual id 0002_auth_share); alembic upgrade head fails with KeyError '0002' on a fresh DB. Latent on main; surfaces once this PR's 0004_merge_heads chain is walked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
Stacked on #467 (needs TableAnnotation); auto-retargets to main when #467 merges. GET /api/snapshots/{uuid}/data-dictionary.md renders a dialect-agnostic Markdown data dictionary (schema sections, columns table, FKs, indexes, view labels) merged with the project's table annotations. IDOR-safe. Frontend download button follows once the frontend foundation lands. +tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
P2 roadmap item — API-first platform access. Bearer pgerd_* keys accepted by get_current_user alongside OIDC (non-invasive branch). Secrets never stored: SHA-256 hash only, plaintext returned exactly once at creation, key_prefix for recognition, revocation is an auditable timestamp (idempotent). /api/api-keys: POST create, GET list (metadata only), DELETE revoke (uniform 404 for other users' keys). Also carries the 0003_revoked_token down_revision fix ('0002' -> '0002_auth_share') without which alembic upgrade head breaks on a fresh DB. Migration 0007 verified against real Postgres. +5 tests; backend suite 236; mypy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
Addresses github-code-quality r3531583397 (unused 'patch') and CodeQL r3531597887: the hashed value is a server-generated 256-bit random token, not a password — a slow KDF adds nothing and a deterministic digest is required for the unique-indexed lookup (same scheme GitHub uses for PATs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
@seonghobae
seonghobae force-pushed the feat/entities-on-main branch from 7aeebd9 to dfe029d Compare July 8, 2026 02:22
@seonghobae

Copy link
Copy Markdown
Collaborator Author

🤖 Rebased onto main and resolved merge conflicts.

What happened: the previous branch tip was a botched merge commit that resolved conflicts by discarding the entire feature — the pushed tree was byte-identical to main, so all of the saved-diagram-views / table-annotations / data-dictionary / API-keys work had been lost. I reconstructed the branch by replaying the actual feature commits onto the current main (174b0f4).

Conflicts resolved (all clean unions, no feature or base change dropped):

  • backend/app/schemas.py — kept base's WideTablesOut + NamingLintOut alongside the PR's DiagramView*, TableAnnotation*, and ApiKey* schemas.
  • backend/app/api/snapshots.py — unioned imports/endpoints so wide-tables, naming-lint, and the new data-dictionary.md export all coexist.

Base work preserved: the Sentinel [CRITICAL] AES→HKDF fix (#479), wide-table detection (#477), naming-convention lint (#473), and dependency bumps were all detected as already-upstream and retained — no security remediation was dropped. The PR's API-key auth path is purely additive (SHA-256 over a 256-bit server token, documented as intentional; not a password hash).

Verified: all changed Python compiles; every changed module imports and the FastAPI app assembles; alembic heads resolves to a single head (0007_api_key, via the 0004_merge_heads bridge); tests/test_data_dictionary.py passes (4/4). DB-backed API tests were not run (require a live database).

Net diff = the 18 intended feature files, nothing else.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

CodeQL py/weak-sensitive-data-hashing (high) flagged hash_api_key using a bare
SHA-256 digest on token material. The token is a server-generated 256-bit
random value (not a password), so a slow KDF is unwarranted and a deterministic
digest is required for the unique-indexed O(1) lookup. Switch to HMAC-SHA-256
keyed with settings.app_secret: the server secret acts as a pepper so a
database-only disclosure of key_hash cannot be reversed or matched against
precomputed tables without also compromising the application secret. Output
stays a deterministic 64-char hex, so the indexed lookup is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RTAMs4bpSZS77Xe3RQjv9P
Comment thread backend/app/auth.py Fixed
@opencode-agent

opencode-agent Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 3ff55b7e527e317103fc5edca84e5ae0164fa5e8
  • Workflow run: 29123208848
  • Workflow attempt: 1
  • Gate result: APPROVE (approval step)

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Approval sufficiency: bounded evidence supplied affirmative approval evidence for changed files, coverage/docstring posture, risk surfaces, and current-head verification; approval is not based merely on the absence of known blockers.
Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including backend/alembic/versions/0003_revoked_token.py, backend/alembic/versions/0004_merge_heads.py, backend/alembic/versions/0005_diagram_view.py, backend/alembic/versions/0006_table_annotation.py, backend/alembic/versions/0007_api_key.py, and 13 more.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence reports supported repository test suites passed.
Docstring coverage: coverage execution evidence reports configured repository docstring gates passed or docstring coverage was advisory.
DAG: CodeGraph/source-backed behavior map connects backend/alembic/versions/0003_revoked_token.py to the affected review, runtime, or workflow path and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, current-head workflow evidence, and, where numeric, scientific, statistical, or literature-backed claims are affected, original-paper/formula evidence and parameter-recovery expectations were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions, object naming, and reserved-word safety for schema/API/config/code surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, test, setup, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: connected user, operator, API, CLI, documentation, review-comment, status-check, rendering, and workflow-reader behavior was checked for contradictions against code, docs, and tests in bounded evidence.
Visual/DOM: Playwright visual, DOM locator, ARIA snapshot, console, and responsive evidence were checked when a web UI surface was present; for non-web surfaces, API/CLI/log/docs/workflow interaction evidence was reviewed instead.
Accessibility/i18n: accessibility, localization, and human-readable text surfaces were checked where UI, CLI, API message, docs, logs, or review text changed.
Supply-chain/license: dependency, package, model, container, and external-tool changes were checked in bounded evidence.
Packaging: package, build, test, lint, and security contracts were checked in bounded evidence.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: The changes introduce well-documented and tested features for saved diagram views and table annotations, with proper security or data integrity considerations.
  • Head SHA: 3ff55b7e527e317103fc5edca84e5ae0164fa5e8
  • Workflow run: 29123208848
  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Backend (18 files)"]
  S1 --> I1["API and service runtime"]
  I1 --> R1["Review risk: Backend (18 files)"]
  R1 --> V1["backend tests"]
Loading

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Approval sufficiency: bounded evidence supplied affirmative approval evidence for changed files, coverage/docstring posture, risk surfaces, and current-head verification; approval is not based merely on the absence of known blockers.
Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including backend/alembic/versions/0003_revoked_token.py, backend/alembic/versions/0004_merge_heads.py, backend/alembic/versions/0005_diagram_view.py, backend/alembic/versions/0006_table_annotation.py, backend/alembic/versions/0007_api_key.py, and 13 more.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence reports supported repository test suites passed.
Docstring coverage: coverage execution evidence reports configured repository docstring gates passed or docstring coverage was advisory.
DAG: CodeGraph/source-backed behavior map connects backend/alembic/versions/0003_revoked_token.py to the affected review, runtime, or workflow path and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, current-head workflow evidence, and, where numeric, scientific, statistical, or literature-backed claims are affected, original-paper/formula evidence and parameter-recovery expectations were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions, object naming, and reserved-word safety for schema/API/config/code surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, test, setup, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: connected user, operator, API, CLI, documentation, review-comment, status-check, rendering, and workflow-reader behavior was checked for contradictions against code, docs, and tests in bounded evidence.
Visual/DOM: Playwright visual, DOM locator, ARIA snapshot, console, and responsive evidence were checked when a web UI surface was present; for non-web surfaces, API/CLI/log/docs/workflow interaction evidence was reviewed instead.
Accessibility/i18n: accessibility, localization, and human-readable text surfaces were checked where UI, CLI, API message, docs, logs, or review text changed.
Supply-chain/license: dependency, package, model, container, and external-tool changes were checked in bounded evidence.
Packaging: package, build, test, lint, and security contracts were checked in bounded evidence.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: The changes introduce well-documented and tested features for saved diagram views and table annotations, with proper security or data integrity considerations.
  • Head SHA: 3ff55b7e527e317103fc5edca84e5ae0164fa5e8
  • Workflow run: 29123208848
  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Backend (18 files)"]
  S1 --> I1["API and service runtime"]
  I1 --> R1["Review risk: Backend (18 files)"]
  R1 --> V1["backend tests"]
Loading

@seonghobae
seonghobae enabled auto-merge July 10, 2026 22:20
@seonghobae
seonghobae merged commit 816238d into main Jul 11, 2026
28 checks passed
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