KB-5127

GPT Review — 23-P3C4 Policy + Agent Context Prompt rev3

7 min read Revision 1
gpt-reviewpack-23p3c4rev4-requiredpolicy-switchcontext-packnotification-design

GPT Review — 23-P3C4 Policy + Agent Context Prompt rev3

Date: 2026-05-07
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed: knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3c4-iu-policy-and-agent-context-prompt.md rev3

Verdict

Rev3 is close, but do not dispatch yet. Rev4 required.

Opus applied the requested fixes in the right direction. However, one prior blocker remains unresolved in the actual prompt: context pack upload is still not enforced as a PASS/FAIL gate. There is also one rollback edge case and one notification-roadmap requirement from the User that should be recorded now, while implementation remains deferred to P3D.

Accepted rev3 fixes

  • Rollback block was added.
  • T2 robustly checks UV count and min/max version_seq=1.
  • T3 extracts guidance and next_action.
  • T6 requires comment_added and count +1.
  • Context pack includes stable actor guidance.
  • Context pack no longer contains raw rollback SQL.
  • The prompt now states context upload must be verified.

Required rev4 fixes

P1 — BLOCKER: context upload gate must fail if not verified

Rev3 initializes:

CONTEXT_UPLOAD="NOT_RUN"

Then final only prints a warning when CONTEXT_UPLOAD != PASS, but still allows phase_status=PASS:

echo "WARN: context pack upload not verified yet..."

This does not satisfy the requirement. Context pack creation is one of P3C4’s objectives.

Patch final logic:

  • If preflight/tests pass but context upload/verification is not PASS, final phase must be FAIL.
  • Report context_upload=FAIL_NOT_VERIFIED or equivalent.

Because the shell cannot itself call Agent Data, make the execution sequence explicit:

  1. Run SQL/tests.
  2. If tests PASS, Agent uses Agent Data createDocument(upsert=true) to create/update:
    • knowledge/dev/laws/dieu44-trien-khai/context-packs/iu-agent-front-door-context.md
  3. Agent verifies by reading the document back.
  4. Only then report context_upload=PASS and phase_status=PASS.

If the Agent cannot verify, the report must be FAIL even if DB tests pass.

P2 — Rollback condition must include PHASE_STATUS=FAIL after a switch

Rev3 rollback only runs when:

POLICY_ACTION=UPDATED_AUTO_APPLY_TO_REQUIRE_REVIEW && TEST_FAIL != 0

Patch rollback condition to also cover PHASE_STATUS=FAIL after the switch:

if [ "$POLICY_ACTION" = "UPDATED_AUTO_APPLY_TO_REQUIRE_REVIEW" ] && \
   { [ "$TEST_FAIL" != "0" ] || [ "$PHASE_STATUS" = "FAIL" ]; }; then
  ... rollback ...
fi

If the switch failed with zero rows, there may be nothing to rollback; in that case report the exact policy value and rollback status. If policy is already require_review and tests fail, do not rollback to auto_apply.

P3 — Final cleanup_on_test_fail wording should be precise

Rev3 says:

cleanup_on_test_fail=rollback_policy_then_report

Patch to report one of:

cleanup_on_test_fail=rollback_policy_only_if_this_pack_changed_policy
rollback_status=NOT_RUN
rollback_status=PASS_POLICY_RESTORED_AUTO_APPLY
rollback_status=NOT_RUN_ALREADY_SWITCHED
rollback_status=CRITICAL_ROLLBACK_FAILED

This avoids implying test rows are cleaned. Pilot rows are intentionally retained.

P4 — Add P3D notification/read-state design commitment now, implementation later

User’s new requirement is accepted and should be recorded in P3C4 report/context as deferred design, not implemented in P3C4.

Add report/context lines:

notification_design=PG_NATIVE_EVENT_OUTBOX_WITH_PER_ACTOR_READ_STATE
notification_implementation=DEFERRED_P3D

Add one short section to the context pack:

Thông báo / inbox hiện chưa bật. P3D sẽ tạo danh sách riêng cho comment mới và update/apply mới. Mỗi reviewer/actor sẽ có trạng thái đã xem riêng, nên GPT xem rồi không làm mất trạng thái của Opus. Trước P3D, dùng report/draft/comment trực tiếp khi được giao.

Do not implement notification tables/triggers in P3C4.

P5 — Create a P3D design anchor note now

Create a short KB design note:

knowledge/dev/laws/dieu44-trien-khai/design/23-p3d-notification-outbox-read-state-design-anchor.md

Content should capture the User’s operational requirement:

  • separate lightweight notification/event lists, not the general activity log;
  • PG-first/PG-native/PG-driven;
  • likely PG triggers on comment insert, draft create, apply/update;
  • separate comment events and official update/apply events;
  • per-actor read/review state, not global read flag;
  • query pattern: reviewer sees unread items for that reviewer;
  • marking reviewed/seen hides items only for that actor;
  • GPT and Opus read states must not overwrite each other;
  • Hermes/reviewer automation will consume this later;
  • implementation deferred to P3D.

This design anchor prevents the requirement from being lost, while keeping P3C4 scope clean.

Directive to Opus

Patch P3C4 prompt to rev4 with P1–P5.

Path:

knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3c4-iu-policy-and-agent-context-prompt.md

Also create the P3D design anchor note:

knowledge/dev/laws/dieu44-trien-khai/design/23-p3d-notification-outbox-read-state-design-anchor.md

Do not dispatch after patch. Return for GPT/User final review.

Hard boundaries remain

  • No dispatch.
  • No function changes.
  • No table DDL.
  • No trigger/gateway changes.
  • No vector mutation.
  • No notification implementation in P3C4.
  • No cleanup/pilot deletion.
  • Only one dot_config key may change.
  • Rollback may only restore that same key to previous value if this pack changed it and tests fail.
  • No raw rollback instructions in context pack.

Notification design guidance for later P3D

The User’s target model is correct:

  • A dedicated “system issue/message list” for IU work.
  • New comment, new draft, and official apply/update create lightweight notification events.
  • Update events and comment events should be distinct lists or distinct event types, not mixed with general activity logs.
  • Reviewers such as GPT/Opus should query unread work for themselves.
  • Read/seen state must be per actor, not global.
  • When GPT marks an item reviewed, it disappears for GPT but not for Opus unless Opus also marked it.
  • PG triggers/functions should do the event creation as much as possible.
  • External code should be minimized; automation can consume PG queues later.

Summary

P3C4 rev3 is close. Rev4 should enforce context-pack upload verification, close the rollback edge case, and record the PG-native notification/read-state design requirement as a P3D anchor without implementing it now.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-23-p3c4-policy-context-prompt-rev3-2026-05-07.md