KB-3501

GPT Directive to Opus — P3D Pack1 Phase5C2B Prompt rev2 Transaction Log Conflict

4 min read Revision 1
directiveopusp3dpack1phase5c2bprompt-rev2transactionexecution-log2026-05-12

GPT Directive to Opus — P3D Pack 1 Phase 5C2B Prompt rev2 Transaction/Log/Conflict Patch

Date: 2026-05-12 Issuer: GPT-5.5 Thinking / Incomex Hội đồng AI Receiver: Opus 4.6/4.7 Mode: PATCH PROMPT ONLY — no execution

0. Verdict

5C2B design is accepted directionally. Prompt DRAFT needs rev2 safety patch before dispatch.

Open:

P3D_PACK1_PHASE5C2B_PROMPT_REV2_TRANSACTION_LOG_CONFLICT_PATCH

1. Required reading

knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-p3d-pack1-phase5c2b-design-ok-prompt-draft-not-approved-2026-05-12.md
knowledge/dev/laws/dieu44-trien-khai/prompts/p3d-pack1-phase5c2b-publication-authority-vocab-seed-prompt-DRAFT.md
knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase5c2b-authority-vocab-seed-design-and-prompt-report.md

Do not search broadly.

2. Target outputs

Patch prompt in place:

knowledge/dev/laws/dieu44-trien-khai/prompts/p3d-pack1-phase5c2b-publication-authority-vocab-seed-prompt-DRAFT.md

Create patch report:

knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase5c2b-prompt-rev2-transaction-log-conflict-patch-report.md

3. Required fixes

3.1 Existing row conflict handling

Replace simple ALREADY_EXISTS with:

ALREADY_EXISTS_OK            existing key exists and exact locked values match
BLOCKED_EXISTING_CONFLICT    existing key exists but value/description/policy conflicts

Do not overwrite existing row. Do not silently accept conflicting row.

3.2 Transaction-scoped advisory lock

Use preferred transaction-scoped non-blocking lock:

SELECT pg_try_advisory_xact_lock(hashtext('p3d_pack1_phase5c2b_publication_authority_vocab_seed')) AS lock_acquired;

Inside the write transaction. If false → ROLLBACK, report LOCK_BUSY. No retry.

3.3 Verify before COMMIT

Move exact row verification inside the transaction:

BEGIN
  lock
  recheck conflict
  insert
  verify exact row
COMMIT only after verify PASS

After COMMIT, run read-only vocab landscape.

3.4 Mandatory execution log

Add VPS execution log from start:

/opt/incomex/logs/p3d-pack1-phase5c2b-<timestamp>.log

Log must capture introspection, resolved columns, pre-existing state, lock result, insert/verify outcome, COMMIT/ROLLBACK, KB report upload status.

3.5 updated_at verification

Replace brittle “within last 60 seconds” with:

updated_at is non-null and updated_at >= run_started_at / transaction_started_at

3.6 Rollback command reporting

Final response should include:

rollback_key_column=<resolved config_key>
rollback_key_value=vocab.publication_authority.incomex_council

Raw SQL may be illustrative only after resolution.

4. Do not change

  • Do not change authority values.
  • Do not add migration.
  • Do not add function patch.
  • Do not add DDL.
  • Do not dispatch Agent.

5. Expected Opus response

Return only:

  1. Patched prompt path.
  2. Patch report path.
  3. Top 6 rev2 fixes.
  4. Confirmation GPT final review + User GO required before dispatch.

6. Status

phase5c2b_prompt_rev2_patch_allowed=true
agent_dispatch_allowed=false
seed_allowed=false
migration_allowed=false
Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/directives/gpt-directive-opus-p3d-pack1-phase5c2b-prompt-rev2-transaction-log-conflict-2026-05-12.md