feat(diff): structural schema diff + migration SQL - #465
Conversation
OpenCode Review Overview
Pull request overviewOpenCode reviewed the current-head bounded evidence and found no blocking issues. FindingsNo blocking findings. SummaryApproval 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.
Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Backend (12 files)"]
S1 --> I1["API and service runtime"]
I1 --> R1["Review risk: Backend (12 files)"]
R1 --> V1["backend tests"]
|
Split out of the adhesive-piper foundation as an independent PR against main. Name-keyed diff (oid-independent) via diff/schema_diff.py; GET /api/snapshots/{uuid}/diff?against=... (SnapshotDiffOut, IDOR-safe). Migration SQL via ddl/migration.py reusing the diff indexer + ddl/export type-mapping; GET /api/snapshots/{uuid}/migration.sql?against=...&dialect=... emits CREATE/ALTER/DROP + FK, destructive/PK as review comments. +16 tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
Stacked on #465 (diff) since it reuses diff/schema_diff._index_snapshot; auto-retargets to main when #465 merges. Labels every change safe/warning/destructive (drop=data loss; type change/SET NOT NULL/new FK=lock or fail; add nullable/drop FK=safe), summary has_destructive/has_blocking, dangerous-first. GET /api/snapshots/{uuid}/migration-safety?against=... IDOR-safe. +5 tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
Stacked on #465; auto-retargets to main when it merges. GET /migration.sql?against=...&direction=down emits the rollback (target->base) using the SAME generator with endpoints swapped, so up and down are always exact mirrors — CREATE in up is DROP in down, ADD COLUMN in up is DROP COLUMN in down. Completes up+down change management. +2 tests (mirror + identity). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
The generator (correctly) emits DROP TABLE IF EXISTS; the assertion missed IF EXISTS. Test-only fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
3e01d17 to
d4ef5c7
Compare
|
🔀 Rebased onto Conflicts (both in the import/declaration blocks, resolved by keeping BOTH sides):
The IDOR-safe authorization (independent Verification: net diff vs 🤖 Rebase performed by Claude Opus 4.8. |
There was a problem hiding this comment.
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/app/api/snapshots.py, backend/app/ddl/migration.py, backend/app/ddl/migration_safety.py, backend/app/diff/init.py, backend/app/diff/schema_diff.py, and 7 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/app/api/snapshots.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 PR introduces structural schema diff and migration SQL functionality with comprehensive tests and coverage.
- Head SHA:
dc44afaefd9a1cfd32e3d6d82361ed0c489676f4 - Workflow run: 29098613855
- Workflow attempt: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Backend (12 files)"]
S1 --> I1["API and service runtime"]
I1 --> R1["Review risk: Backend (12 files)"]
R1 --> V1["backend tests"]
* feat(ci): schema-drift deploy gate (recipe + script) P0 roadmap item. docs/ci-drift-check.md documents gating deploys on 'schema matches the approved baseline' via GET /diff?against= (has_changes) with exit-code semantics, plus a ready-made scripts/ci/check_schema_drift.sh (0 = no drift, 1 = drift + prints summary & reconciling migration.sql, 2 = missing/unauthorized) and a GitHub Actions example. Script syntax + JSON extraction paths verified. Depends only on the diff/migration endpoints (#465). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd * fix(ci): make schema drift gate failures explicit --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Independent PR against
main(split out of #440). Now also contains the merged stack: #468 (migration-safety risk classification) and #484 (down-migrationdirection=down).diff/schema_diff.py, oid-independent):GET /diff?against=ddl/migration.py):GET /migration.sql?against=&dialect=&direction=up|down— up and rollback are exact mirrorsGET /migration-safety?against=— safe/warning/destructive per change,has_destructive/has_blockingIDOR-safe. backend +23 tests; mypy clean.
🤖 Generated with Claude Code