KB-54A4

GPT Final Review — P10B-1C-PF D32 SQL Inspection Prompt

2 min read Revision 1
s188p10bp10b-1c-pfd32sql-inspectionfinal-reviewauthorized-with-patches

GPT Final Review — P10B-1C-PF D32 SQL Inspection Prompt

Date: 2026-04-29

Verdict

PASS with 4 small precision patches.

The prompt is correctly read-only and addresses the remaining assumptions before production mutation. It should be dispatched after the four patches below are applied.

Required patches

P1 — Replace brittle INSERT count grep with parser-based count

The current grep/awk method may miss INSERTs inside multiline DO blocks or count comments. Agent must use a small parser/script that ignores SQL comments and counts INSERT INTO <table> targets case-insensitively.

Expected target counts:

  • tac_publication: 1
  • tac_logical_unit: 23
  • tac_unit_version: 23
  • tac_publication_member: 23

Any other INSERT target = FAIL.

P2 — Destructive command scan must ignore comments and generated strings

Current grep may false-positive on comments or explanatory strings. Agent should scan SQL after stripping line comments and block comments. Allowed: CREATE TEMP / CREATE TEMPORARY only. Disallowed in insert-candidate.sql: ALTER, DROP, TRUNCATE, UPDATE, DELETE, non-temp CREATE.

P3 — Sample mapping must include actual line numbers and enough context

For ROOT, S1, and S2-P1, report:

  • SQL line range;
  • source JSON fields used;
  • target table columns;
  • parent_id resolution path;
  • UV description/body mapping;
  • PM linkage method.

grep -A5 alone is not sufficient if INSERT spans more than 5 lines.

P4 — Explicitly preserve no-execution rule

Add: Do not run psql -f any SQL file. Do not run EXPLAIN. Do not run BEGIN/ROLLBACK tests. File inspection only.

Direction

Patch prompt with P1–P4, then dispatch Agent. No need for another Opus rewrite cycle unless patch introduces new scope.

Status

  • P10B-1C-PF prompt: approved after precision patches.
  • Next: Agent read-only SQL inspection.
  • P10B-1C execute remains blocked until PF report PASS.