KB-41C9

GPT Review — 18b-P2 DOT-119 Script Rewrite Prompt rev3

5 min read Revision 1
gpt-reviewdot-119p2script-rewriterev4-requiredanti-hardcode

GPT Review — 18b-P2 DOT-119 Script Rewrite Prompt rev3

Date: 2026-05-05 Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI Reviewed:

  • knowledge/dev/laws/dieu44-trien-khai/design/dot119-v2-script-content.sh rev2 / Rev 3 content
  • knowledge/dev/laws/dieu44-trien-khai/prompts/18b-p2-dot119-script-rewrite-prompt.md rev4 / Rev 3 content

Verdict

Rev3 fixes the hardcoded function-hash blocker, but is not approved for dispatch. Rev4 required.

Good fixes:

  • KNOWN_V2_FN_HASH removed.
  • Synthetic strategy now uses capability check instead of fixed implementation hash.
  • Function hash remains audit/no-clobber evidence only.
  • Smoke test includes no-hardcode-hash check.

However, rev3 introduced/left several execution risks.

Required rev4 patches

B1 — Prompt must be self-contained

The rev3 prompt says:

“Xem rev 2 prompt cho full SQL”

This is not acceptable for a runtime mutation prompt. Claude Code should not have to mentally merge rev2 + rev3. Rev4 must include the full P2 prompt: all preflight SQL, sample-selection SQL, install commands, smoke commands, report requirements, and hard boundaries.

B2 — Remove placeholder grep in smoke test #13

Rev3 still has:

grep -cF '...' "$DOT119"

This is a placeholder. Replace with exact no-clobber check, for example:

grep -cF 'CREATE OR REPLACE FUNCTION fn_birth_registry_auto' "$DOT119"

Expected: 0.

B3 — Capability check should recognize JSONB/id fallback patterns

Current script checks id reference with:

grep -qE '\.id\b|NEW\.id'

This may fail if the installed function reads id through JSONB, e.g.:

to_jsonb(NEW)->>'id'

Rev4 should accept common safe patterns:

  • NEW.id
  • .id
  • to_jsonb(NEW)->>'id'
  • to_jsonb(NEW) ->> 'id'

The goal is capability detection, not formatting brittleness.

B4 — Add explicit function existence check for helper function

For legacy_id_single_colon, script should verify fn_birth_registry_auto_id exists before building trigger SQL.

Example:

SELECT to_regprocedure('fn_birth_registry_auto_id()') IS NOT NULL;

If absent, exit 11 or 13 with clear message.

B5 — Make psql error handling strict

run_pg should use -v ON_ERROR_STOP=1 so SQL errors do not get swallowed in unexpected ways:

docker exec -i "$PG_CONTAINER" psql -v ON_ERROR_STOP=1 -U "$PG_USER" -d "$PG_DB" -t -A -q "$@"

B6 — Add temp-file integrity check

Prompt should require:

  • md5 of KB script source if available;
  • md5 of temp file after writing;
  • md5 of installed file after mv;
  • all included in report.

If KB md5 is not preknown, report temp/installed md5 at minimum.

B7 — Clarify --help behavior

Current script exits 1 for explicit --help. This is acceptable if documented, but better to make:

  • no args → exit 1;
  • --help → exit 0.

Not mandatory, but if unchanged, prompt smoke test should state explicit --help exit 1 is intended.

B8 — Partial report on any STOP

Rev3 says report, but mutation prompts should repeat:

Any STOP before or after install must upload partial report with all outputs collected so far.

Hardcode assessment

Rev3 removes the hardcoded hash. Good.

But rev3 prompt still contains a placeholder ('...') and a non-self-contained reference to rev2. Those are operational hardcoding/ambiguity risks. Rev4 must be fully explicit.

Directive to Opus/Ocus

Patch both files:

  1. knowledge/dev/laws/dieu44-trien-khai/design/dot119-v2-script-content.sh
  2. knowledge/dev/laws/dieu44-trien-khai/prompts/18b-p2-dot119-script-rewrite-prompt.md

Rev4 requirements:

  1. Make prompt self-contained; do not say “see rev2 prompt”.
  2. Replace smoke test placeholder grep with exact grep command.
  3. Expand synthetic fallback capability check to accept JSONB id extraction patterns.
  4. Verify fn_birth_registry_auto_id() exists before using legacy_id_single_colon.
  5. Add -v ON_ERROR_STOP=1 to run_pg.
  6. Add temp/installed script md5 integrity reporting.
  7. Clarify/help behavior or adjust explicit --help to exit 0.
  8. Restate partial-report-on-any-STOP.

Do not dispatch yet.

Hard boundaries remain:

  • no fn_birth_registry_auto edit;
  • no IU trigger install;
  • no IU rows;
  • no Pack 2B;
  • no seed/DDL changes.
Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-18b-p2-dot119-script-rewrite-prompt-rev3-2026-05-05.md