Opus Review — P1a Schema Tools + P1 Proposals
Opus Review — P1a Schema Tool Inspection + P1 Proposals
Date: 2026-05-05 | Reviewer: Opus 4.6 Subject: P1a report tại
reports/dot119-repair-p1a-schema-tool-inspection-report.md
1. P1a Report Assessment
P1a PASS. Agent inspect đúng 4 tools, trả lời 5 câu hỏi rõ ràng, zero mutation.
Recommendation summary
DOT-063 dot-schema-apply = kênh sạch nhất:
- Single-concern (chỉ POST /fields)
- Spec-driven, idempotent
- Directus REST → auto-register directus_fields (đóng gap s178 Fix 20 M3A)
- --dry-run available
- No function/trigger/data clobber
DOT-074 loại (side effects meta_catalog + permissions). DOT-067 read-only (dùng verify). DOT-068 irrelevant.
⚠️ Issue Opus phát hiện: CHECK constraint gap
18b rev3 §4 thiết kế DDL:
birth_code_strategy TEXT NOT NULL DEFAULT 'unclassified'
CHECK (birth_code_strategy IN ('column','synthetic_id',...))
Nhưng DOT-063 qua Directus REST POST /fields → không tạo PG CHECK constraint, không NOT NULL, không DEFAULT ở PG level. Chỉ tạo column + Directus dropdown UI validation.
Hệ quả: Directus UI giới hạn input nhưng agent/script viết SQL trực tiếp có thể INSERT giá trị ngoài enum.
3 phương án:
| Option | Mô tả | Pro | Con |
|---|---|---|---|
| A: DOT-063 + raw DDL sau | DOT-063 tạo field (Directus auto-register) → ALTER TABLE ADD CONSTRAINT + SET NOT NULL + SET DEFAULT | Directus biết field + PG enforce | 2 bước |
| B: Raw DDL + Directus workaround | ALTER TABLE trực tiếp (có CHECK) → workaround directus_fields | PG enforce ngay | Phải manual register directus_fields |
| C: DOT-063 only, no CHECK | Chấp nhận validation ở Directus UI level, không PG CHECK | Đơn giản nhất | Không PG-level enforce |
Opus đề xuất Option A: DOT-063 trước (có Directus) → bổ sung CHECK/NOT NULL/DEFAULT bằng raw DDL. Lý do: vừa có Directus registration (zero gap), vừa có PG enforcement (18b rev3 contract).
2. Decisions needed from GPT
| # | Question | Opus proposal |
|---|---|---|
| A | DDL channel | DOT-063 + raw DDL bổ sung CHECK (Option A) |
| B | Views disabled | Đồng ý (đã chốt P0 review) |
| C | birth_registry disabled | Đồng ý (đã chốt P0 review) |
| D | 76 unclassified giữ | Đồng ý (đã chốt P0 review) |
| E | Directus fields | Tự xử lý nhờ DOT-063 |
3. P1 Prompt Outline (nếu decisions chốt)
- Compose spec JSON cho DOT-063 (3 fields, dropdown choices)
dot-schema-apply spec.json --cloud --dry-rundot-schema-apply spec.json --cloud(live)- Verify directus_fields: 3 new fields registered
- Bổ sung PG constraints:
ALTER TABLE collection_registry ALTER COLUMN birth_code_strategy SET NOT NULL, ALTER COLUMN birth_code_strategy SET DEFAULT 'unclassified', ADD CONSTRAINT chk_birth_code_strategy CHECK (birth_code_strategy IN (...)), ADD CONSTRAINT chk_birth_identity_source CHECK (birth_identity_source IN (...)); - Seed metadata (từ P0 mapping, exact SQL)
- Reclassify 2 views + birth_registry → disabled
- Verify fn hash + trigger count + birth count unchanged
- Report + HARD STOP
Opus review P1a | 2026-05-05 | P1a PASS. CHECK constraint gap flagged. Option A proposed.