KB-2BF7

Codex review — Kế hoạch nháp UI v0 / Sửa rẻ

4 min read Revision 1
current-statecodex-reviewsua-renhap-uipg-firstdot2026-07-06

Codex review — Kế hoạch nháp UI v0 / Sửa rẻ

Date: 2026-07-06
Agent: Codex
Scope: Review only. No DB write, no DDL, no Nuxt edit. Production checks were read-only SELECT/GET, except no mutation DOT was executed.
Verdict: HOLD

One-line reason: GĐ1 is feasible and worth doing, but the plan cannot run as written because seed JS files are not present/verified, the proposed PK shape is risky for existing table molds, and the required custom writable PG-table DOT/rollback is not already available.

Report local: knowledge/current-state/reports/ui-v0-plan-field-review-2026-07-06.md. Report canonical review path: knowledge/dev/laws-new/kestra/sua-re/nhap-ui/codex-review-ke-hoach-nhap-ui-v0-rev2.md.

Key conclusions:

  • Production PG is directus on PostgreSQL 16.13.
  • Proposed tables sua_re_khai_niem_nhap and sua_re_ui_khai_niem_nhap do not exist yet.
  • table_registry has 28 rows; 2 rows still use view_sql/view_name for report snapshots (tbl_report_home, tbl_report_pg).
  • /reports, /reports/report-pg, /reports/report-loai returned HTTP 200.
  • dot-verify-loai-report ended with DOT_VERIFIED: PASS.
  • Existing species include catalog, collection, page, table_ui, task, workflow, workflow_step, and SPE-NVS; do not create a new workflow species.
  • species_collection_map lacks a composite unique guard and already has duplicate pivot_result/pivot_results = 2, so idempotency must be DOT/readback enforced.
  • Seed files concept-ledger.js, ui-contracts.js, verify-contracts.js were not found locally and not retrieved from KB search; the claimed 13/30 migration is not verified.
  • Production has reusable molds not present in local checkout: dot-report-publish, dot-list-publish, dot-collection-track-readonly, dot-verify-loai-report.

Minimal new DOTs required for PG-only GĐ1:

  1. dot-sua-re-nhap-ui-v0-ensure — Cấp B: create/ensure the two draft tables, constraints, indexes, timestamps, and allowlisted rollback.
  2. dot-sua-re-nhap-ui-v0-import — Cấp B: import seed/scans idempotently and enforce current-scan flow.
  3. dot-sua-re-nhap-ui-v0-verify — Cấp A: read-only verification paired to both DOT-Bs; prints row counts, distinct dedupe counts, match-status counts, current-scan invariant output, and sample rows.

Reuse in GĐ2 only after GĐ1 passes:

  • dot-collection-track-readonly for existing PG tables that need Directus read-only serving.
  • dot-list-publish for live /reports/report-* list pages.
  • dot-report-publish only for v_report_* snapshot reports.
  • dot-species-map only after species choice; recommended concept catalog = catalog, usage ledger = defer or catalog, not workflow, not table_ui unless it is truly table UI config.

Recommended schema correction:

  • Use id bigserial primary key in both tables for Directus/SharedDirectusTable compatibility.
  • Use concept_key text unique instead of concept_id varchar PK.
  • Use item_key text unique for idempotent usage import.
  • Rename loai to concept_kind to avoid confusion with entity_species.
  • Keep purpose NOT NULL CHECK (length(trim(purpose)) >= 15) and dedupe_key NOT NULL.
  • Keep no scan table in v0 only if DOT import transaction verifies that each ui_id has at most one current scan_id; otherwise add a scan table.

Final verdict: HOLD execution as written. PASS_TO_GD1 only after the seed source is frozen and the minimal DOT-A/B pair exists.