Phụ lục triển khai Điều 38 — Text as Code (Index)
Folder: knowledge/dev/laws/dieu38-trien-khai/
Trạng thái: Legal ✅ | Design ✅ | Schema ✅ | Checker ✅ | Pilot ✅ | Sandbox ✅ | P8 v0.4 ✅ | E-R3/E4/E5/E7/E6 ✅ | G6 PASS | Gate A PASS | Gate B PASS | Gate C PASS | G8B-RP PASS | G8B-Token: pending | G11: pending | P9 Gate: 10/12 + G8B-RP | Tiếp: G8B-Token → G11
Rule đọc: HOW-TO-READ.md trước.
Production state (sau G8B-RP — S186)
PG objects trong public schema:
| Category |
Count |
Detail |
| tac_* tables |
14 |
8 vocab/config seeded (61 rows), 6 core/member empty |
| fn_tac_* functions |
7 |
6 new (SECURITY DEFINER, search_path locked) + 1 whitelist (E-R3) |
| trg_tac_* triggers |
6 |
Attached to 4 tables |
| FK constraints |
17 |
|
| UNIQUE constraints |
5 |
|
| CHECK constraints |
19 |
|
| Indexes |
41 |
23 explicit + 18 implicit PK/UNIQUE |
Directus objects:
| Category |
Count |
Detail |
| Collections |
14 |
All 14 tac_* registered, API-readable |
| Roles |
2 |
tac-agent, tac-admin |
| Policies |
2 |
tac-agent-policy (CRU+R), tac-admin-policy (full CRUD) |
| Access bindings |
2 |
agent→agent-policy, admin→admin-policy |
| Permission rows |
84 |
28 agent + 56 admin, full matrix verified |
| Tokens |
0 |
Deferred — G8B-Token gate |
Other production artifacts (S183):
taxonomy_facets: FAC-07 (8), FAC-08 (9), FAC-09 (10)
dot_tools: 19 DOT-TAC-* (ids 971–989)
Trigger guard:
fn_evt_trigger_guard_drop() FIXED (both DBs) — object_identity + COALESCE + schema-qualified + search_path locked
S186 Production Gates — Deliverables
| Gate |
Status |
Action Log |
| Gate A — DDL |
✅ PASS |
reports/p9-gate-a-production-ddl-execution-log-2026-04-28.md |
| Trigger Guard Fix |
✅ PASS |
reports/p9-trigger-guard-drop-repair-log-2026-04-28-run2.md |
| Gate B — Collections |
✅ PASS |
reports/p9-gate-b-directus-collection-registration-log-2026-04-28-run2.md |
| Gate C — Seed |
✅ PASS |
reports/p9-gate-c-seed-log-2026-04-28.md |
| G8B-RP |
✅ PASS |
reports/p9-g8b-directus-roles-permissions-log-2026-04-29.md + reports/p9-g8b-rp-readonly-reverify-2026-04-29.md |
| G8B-Token |
⏳ Pending |
Token provisioning deferred |
| Full G8 |
⏳ Pending |
RP done, token pending |
| G11 |
⏳ Pending |
User final approval — last gate |
Prompt designs (canonical KB):
| Prompt |
Path |
Rev |
| Gate A |
P9-gate-a-production-ddl-execution-prompt.md |
v0.5 FINAL |
| Gate A Errata |
P9-gate-a-errata.md |
rev 1 |
| G8A Design |
P9-G8A-directus-roles-readiness-design.md |
v0.3 |
| G8B-RP |
P9-G8B-RP-directus-roles-permissions-execution-prompt-v0-2.md |
rev 2 (API discovery) |
| Gate Design (A/B/C) |
P9-production-ddl-collection-gate-design.md |
v0.2 |
Incidents (resolved):
| Incident |
Resolution |
| Gate A stale CHECK=115 |
Rollback blocked by trigger guard bug → objects preserved → Q1-Q8 PASS |
| Trigger guard DROP NULL crash |
Fixed both DBs (S186) |
| Gate B run1 token env var |
DIRECTUS_ADMIN_TOKEN proven (S186) |
| Trigger guard run1 execution role |
workflow_admin proven (S186) |
| G8B-RP enforce_tfa |
Agent adapted run2 (S186) |
| G8B-RP Codex disconnect |
Re-verify PASS (S186) |
S184 G6 — Tất cả deliverables FINAL
| File |
Path |
Status |
| Package design |
P9-G6-dry-run-package.md |
v0.2 PASS |
| Execution prompt |
P9-G6-execution-prompt.md |
OFFICIAL v0.2 |
| Precedence/errata |
P9-G6-precedence-errata.md |
OFFICIAL |
| Seed manifest |
seed-manifest-g6-expected.json |
rev 2 |
| Seed files (8) |
seed-g6/seed-tac-*.sql |
61 rows total |
P9 Gate Progress
| Gate |
Status |
Resolved by |
| G1 P8 OFFICIAL |
✅ |
P8 v0.4 |
| G2 Đ24 facets |
✅ |
E5 FAC-07/08/09 |
| G3 entity_code |
✅ |
E-E3 P8 §5.2 |
| G4 DOTs registered |
✅ |
E7 19 DOTs |
| G5 register adapter |
✅ |
E7 v0.2 |
| G6 Migration dry-run |
✅ |
Run #4 PASS |
| G7 system_issues |
✅ |
E-R3 wrapper |
| G9 Backup |
✅ |
P8 §8.3 |
| G10 TRIGGER-GUARD |
✅ |
P8 §8.4 |
| G12 BOM defer |
✅ |
P8 §7 |
| G8 Directus roles |
⏳ |
G8B-RP PASS, token pending |
| G11 User approval |
⏳ |
Last gate |
Tham khảo (handoffs)
tham-khao/handoff-s185-g8a-gate-design.md — S185 → S186
tham-khao/handoff-s183-e-r3-e7-e6.md — S183 → S184
Index. S186. 2026-04-29. G8B-RP PASS. P9 Gate 10/12 + G8B-RP. Next: G8B-Token → G11.