KB-8773

GPT Final Review — Gate A Production DDL Prompt v0.5

3 min read Revision 1
gptfinal-reviewgate-aproduction-ddlpromptp9s186

GPT Final Review — Gate A Production DDL Prompt v0.5

Date: 2026-04-28

Verdict

CONDITIONAL PASS for KB archival and finalization.

The v0.5 prompt is architecturally sound and incorporates the required production-safety controls. Before persisting as canonical KB and before any execution dispatch, apply the small editorial/command-safety fixes below.

Required final edits

  1. Fix title/header mismatch:

    • Current heading says Design v0.4 while status says DRAFT v0.5.
    • Change heading to Gate A — Production DDL Execution Prompt Design v0.5.
  2. Make expected-no-match grep commands non-fatal under strict shell:

    • In §1.4, grep commands are expected to return exit code 1 when there are zero matches.
    • If an agent runs under set -e, this can abort before classification.
    • Use || true or explicit if grep ...; then ... else ... fi pattern.

Suggested pattern:

grep -nE 'INSERT[[:space:]]+INTO' production_ddl_candidate.sql || true
grep -nE '^[[:space:]]*COPY[[:space:]]' production_ddl_candidate.sql || true
grep -nE '^[[:space:]]*UPDATE[[:space:]]' production_ddl_candidate.sql || true
grep -nE '^[[:space:]]*DELETE[[:space:]]' production_ddl_candidate.sql || true
grep -nE '^[[:space:]]*TRUNCATE[[:space:]]' production_ddl_candidate.sql || true
  1. Clarify that production DDL candidate generation is still pre-execution preparation, not Gate A success itself.
    • This prevents agent from reporting PASS before actual DDL and post-checks.

Accepted controls

  • VPS-only execution context.
  • Controlled transform instead of blind sed.
  • Robust scaffold removal.
  • DML expected = 0 with escalation on any unexpected match.
  • pipefail and psql exit capture.
  • Separate execution-error vs post-COMMIT failure rollback paths.
  • Trigger guard repaired-function check includes public.trigger_guard_alerts.
  • No-overwrite action log policy.
  • Gate A only; no Gate B/C/G8B/G11/P9.

Governance check

Rule Result Finding
Hiến pháp / Zero Trust PASS after final edits Evidence-based and fails closed.
Đ32 PASS Explicit DDL gate.
Đ33 PASS Production schema mutation is scoped and rollback-governed.
Đ35 PASS Governed AI/User path preserved.
Đ24 PASS No labels/entity_labels mutation.
Đ39 PASS AI drafts; User GO required before execution.

Direction

Opus should apply the three final edits, persist the finalized v0.5 to KB, then STOP. Do not dispatch execution until User explicitly authorizes Gate A execution.