P7B Cổng 2 Execution Split: C2A + C2B
P7B Cổng 2 — Execution Split: C2A + C2B
Status: READY — NOT TO RUN UNTIL USER APPROVES Parent: P7B-sandbox-execution-prompt-c2-v0-2.md Phiên: S182 | Design doc: P7B v0.3 OFFICIAL
Tại sao chia 2?
Thay vì 1 prompt dài, chia thành 2 có checkpoint người:
C2A: Dựng kệ (preflight + schema + tables)
→ STOP → User verify PF-4 (Directus không thấy kệ mới)
→ User confirm OK
→ C2B: Xếp hàng (seed + verify)
User kiểm tay Directus visibility trước khi đổ data. PF-4 fail → DROP ngay.
C2A — Preflight + Schema Create
⚠️ NOT TO RUN UNTIL USER APPROVES ⚠️
Mục tiêu
Pre-flight PF-0→PF-6. Nếu PASS → tạo sandbox_tac + 8 tables + 3 functions + 2 triggers. KHÔNG seed. KHÔNG đụng production.
Ràng buộc
DDL CHỈ sandbox_tac. KHÔNG public.* read/write. KHÔNG Directus collection. KHÔNG CREATE EXTENSION tự ý. KHÔNG dot_tools. Lỗi → DROP CASCADE.
Việc cần làm
Step 1: Pre-flight PF-0→PF-6
source /opt/incomex/.env
SANDBOX_USER="${PG_USER_DIRECTUS:-workflow_admin}"
# PF-1: pgcrypto
docker exec postgres psql -U "$SANDBOX_USER" -d directus \
-c "SELECT extname FROM pg_extension WHERE extname='pgcrypto'"
# PF-2: CREATE SCHEMA privilege
docker exec postgres psql -U "$SANDBOX_USER" -d directus \
-c "SELECT has_database_privilege('$SANDBOX_USER','directus','CREATE')"
# PF-3: PG version
docker exec postgres psql -U "$SANDBOX_USER" -d directus -c "SELECT version()"
# PF-5: Production clean
docker exec postgres psql -U "$SANDBOX_USER" -d directus \
-c "SELECT count(*) FROM pg_catalog.pg_tables WHERE schemaname='public' AND tablename LIKE '%logical_unit%'"
# PF-6: .env
ls -la /opt/incomex/.env
Bất kỳ FAIL → STOP, báo User, KHÔNG DDL.
Step 2: Create Schema + Tables
DDL từ P7B §6.2. Thứ tự: schema → vocab tables → core tables + indexes → functions → triggers.
Step 3: Quick verify
docker exec postgres psql -U "$SANDBOX_USER" -d directus \
-c "SELECT count(*) FROM pg_catalog.pg_tables WHERE schemaname='sandbox_tac'"
# Expect: 8
Step 4: STOP — User verify PF-4
Báo User kiểm Directus Admin UI → Data Model → không có sandbox_tac tables.
PF-4 FAIL → DROP SCHEMA sandbox_tac CASCADE → ABORT. PF-4 PASS → User approve C2B.
Output
reports/p7b-c2a-preflight-schema-log-YYYY-MM-DD.md
Rollback
DROP SCHEMA IF EXISTS sandbox_tac CASCADE;
C2B — Seed + Verify
⚠️ ONLY RUN AFTER: C2A PASS + User PF-4 PASS + User approves C2B ⚠️
Mục tiêu
Seed 76 units + 3 publications. Checkers. Round-trip. Report. KHÔNG đụng production.
Tài liệu KB
P7B v0.3, C1A, P5, 3 source docs (HOWTO, C1A, P5)
Việc cần làm
Step 1: Verify C2A completed
Schema sandbox_tac exists? 8 tables? Nếu không → ABORT.
Step 2: Seed vocabulary
11 section_type_vocab (heading body_required=FALSE) + 1 publication_type_vocab.
Step 3: Seed logical_unit (76)
ROOTs (3, RETURNING id) → depth-1 (~38) → depth-2 (~35). Address→UUID lookup.
Step 4: Seed unit_version (76)
Body = actual source content. 5 structural nodes body=NULL. Trigger auto-hash.
Step 5: Seed publication (3) + publication_member (76)
pilot-v0, proposed, design_note.
Step 6: Verify
-- Row counts: 76/76/3/76
-- Duplicate address: 0
-- Parent doc_code: 0
-- Orphan: 0
-- PM consistency: 0
-- Hash non-NULL: 76/76
-- Hash consistent: 0 mismatches
-- Length flags: normal ~64, soft ~7
-- Round-trip: 3/3 docs
-- Code blocks P5: 10/10
-- Production unchanged: 0
Step 7: Report
reports/p7b-sandbox-execution-log-YYYY-MM-DD.md — PASS/FAIL per P7B §12.2.
Rollback
DROP SCHEMA IF EXISTS sandbox_tac CASCADE;
DOT Registration
Default Option B (action log). Nếu Đ33 yêu cầu → STOP hỏi User.
P7B Cổng 2 Split | C2A + C2B | S182 | 2026-04-26 | Opus 4.6 NOT TO RUN UNTIL USER APPROVES