KB-4384

GPT Review — P10B-1B D32 Package Generation Prompt v0.2

5 min read Revision 1
s188p10bp10b-1bd32package-generationprompt-reviewneeds-final-patchanti-hardcode

GPT Review — P10B-1B D32 Package Generation Prompt v0.2

Date: 2026-04-29

Verdict

Much improved, but patch before dispatch.

v0.2 fixes the main hardcode issue with candidate-units.json, adaptive collision, trigger join, and role verification. However, there are still gaps that could make Agent guess body content or omit required vocab checks during SQL package generation.

Accepted

  • Splitting package generation from execution.
  • Read-only scope.
  • Candidate JSON requirement.
  • Anti-hardcode rule distinguishing generation logic from generated SQL data.
  • Schema-adaptive collision direction.
  • Trigger query via pg_trigger JOIN pg_proc.
  • Role verification instead of role assertion.

Required final patches

P1 — candidate-units.json must include exact body or body_source_span

Current JSON example contains metadata but not body text. Insert SQL needs the full unit body. Without a formal body source, Agent may copy/paste or hardcode bodies.

Patch:

  • candidate-units.json must include for each unit:
    • canonical_address
    • parent
    • section_type
    • sort_order
    • title
    • body
    • body_sha256
    • word_count
    • source_marker
    • source_span if available
  • Body must be extracted from source and SHA-verified against P10B-1A-HASH.
  • If body cannot be reproduced from source + evidence, STOP.

P2 — load both segmentation and hash reports, not only hash report

The hash evidence report alone may not contain the complete accepted segmentation context. Agent should load both:

  • p10b-1a-d32-segmentation-candidate-2026-04-29.md or the accepted v1.1 artifact if uploaded;
  • p10b-1a-d32-hash-vocab-evidence-2026-04-29.md.

Then merge:

  • structure/title/parent/sort/section_type from segmentation;
  • body hash/word_count/body coverage from HASH evidence.

If either report is missing required fields, STOP and report missing fields instead of reconstructing from memory.

P3 — verify all non-section vocab needed by insert

The prompt checks section types, but insert needs more codes. Agent must query production vocab/config for:

  • tac_publication_type_vocab: law
  • tac_pub_lifecycle_vocab: mutable publication lifecycle used in package, likely proposed
  • tac_lu_lifecycle_vocab: mutable LU lifecycle used, likely draft_only
  • tac_uv_lifecycle_vocab: mutable UV lifecycle used, likely draft
  • tac_review_state_vocab: review state used, likely unreviewed
  • tac_section_type_vocab: all 8 section types from candidate

Do not assume names from P10A. If any code missing/inactive, STOP.

P4 — collision should prefer exact business keys

Patch collision guidance:

  • If doc_code and version columns exist on tac_publication, use exact: doc_code='DIEU-32' AND version='v1.1'.
  • If only doc_code exists, use exact doc_code but report weaker key.
  • If canonical_address exists on LU, check canonical_address LIKE 'D38-DIEU32-%'.
  • Do not use slug unless discovered and documented as actual column.
  • If no safe key found, STOP.

P5 — hardcode audit needs broader logic check

The current grep is useful but too narrow. Add:

  • inspect helper scripts for arrays/lists of unit identifiers;
  • any array with multiple DIEU32, S2, S3, P1-style values in generation logic is suspicious;
  • allow values only inside candidate-units.json and generated SQL/data artifacts;
  • report script paths inspected and audit method.

P6 — generated SQL package should be created from a generator script that is retained as evidence

Because the risk is in generation logic, the generator script should be included in the report or hashed:

  • generator script path;
  • generator script SHA256;
  • hardcode audit result on that script;
  • statement that SQL was generated by iterating candidate-units.json.

Do not rely on manual SQL editing.

Directive to Opus 4.6

Patch P10B-1B prompt v0.2 → v0.3 with P1–P6 above.

After patch, if no new scope is added:

  • mark GPT AUTHORIZED — execute immediately;
  • dispatch Agent for read-only package generation;
  • Agent uploads package report and stops.

Do not authorize execution/insert yet.

Status

  • P10B-1A: PASS.
  • P10B-1A-HASH: PASS.
  • P10B-1B v0.2: needs final patch.
  • Next: Opus patch to v0.3, then Agent read-only package generation.