KB-52A7 rev 2

P3D Pack 1 Phase 5C2A — Read-Only Publication Authority Ref Probe (rev2)

7 min read Revision 2
p3dpack1phase5c2aproberev2readonlyintrospection-firstpublication-authority-ref

P3D Pack 1 Phase 5C2A — Read-Only Publication Authority Ref Probe (rev2)

Mode: READ-ONLY — zero writes, zero mutation Rev2: introspection-first; no assumed column names Purpose: Discover live evidence for publication_authority_ref value needed by 5C2 DB: VPS PostgreSQL (postgres container, db=directus, schema=public) Report to: knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase5c2a-publication-authority-ref-probe-report.md


HARD BOUNDARIES

No INSERT. No UPDATE. No DELETE. No DDL. No seed. No migration. No function patch. No nested Agent.


EXECUTION ORDER

PHASE 1 — Schema introspection (information_schema only)
PHASE 2 — Concept → column resolution
PHASE 3 — Evidence queries (resolved columns only)
PHASE 4 — Function source analysis (bounded output)

PHASE 1 — Schema introspection

Q1 — dot_config schema

SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_schema='public' AND table_name='dot_config'
ORDER BY ordinal_position;

Q2 — tac_publication schema

SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_schema='public' AND table_name='tac_publication'
ORDER BY ordinal_position;

Q3 — information_unit schema (identity_profile column check)

SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_schema='public' AND table_name='information_unit'
ORDER BY ordinal_position;

PHASE 2 — Concept → column resolution

From Phase 1 results, resolve each concept. Use ONLY column_names returned by Q1/Q2/Q3.

Resolution rules

0 matches → FIELD_ABSENT
1 match   → RESOLVED
>1 matches → AMBIGUOUS_FIELD

dot_config concepts

Concept Candidates Resolution
config_key key, config_key, name, setting
config_value value, config_value, setting_value

tac_publication concepts

Concept Candidates Resolution
tac_pub_pk id, uuid
tac_pub_doc_code doc_code, code, document_code
tac_pub_publication_type publication_type, type, doc_type

tac_publication authority-like candidates

For ALL columns returned by Q2, flag any that match authority/issuer/owner semantics:

Candidate pattern Match if column_name contains Match reason
authority authority, auth direct authority
issuer issuer, issued_by issuing body
owner owner, owned_by ownership
approver approved_by, approver approval authority
enactor enacted_by, enactor enactment authority
council council, committee governance body

Report ALL matches with match_reason and candidate_not_approved. If 0 matches → tac_pub_authority_like = FIELD_ABSENT.

information_unit concepts

Concept Candidates Resolution
iu_pk id, uuid
iu_identity_profile identity_profile, profile, metadata

PHASE 3 — Evidence queries (resolved columns only)

All queries use <concept> placeholders. Replace with Phase 2 resolved column. If concept not RESOLVED → skip query, report UNKNOWN.

Q4 — Existing publication_authority vocab

SELECT * FROM dot_config
WHERE <config_key> LIKE 'vocab.publication_authority.%'
ORDER BY <config_key>;

Report: row count + all rows. If 0 → no authority vocab exists.

SELECT * FROM dot_config
WHERE <config_key> LIKE 'vocab.publication_type.%'
   OR <config_key> LIKE 'vocab.publication_authority.%'
ORDER BY <config_key>;

Report: shows existing vocab patterns.

Q6 — DIEU-35 publication row (all columns)

SELECT * FROM tac_publication
WHERE <tac_pub_doc_code> = 'DIEU-35';

DIEU-35 is a scope constant. Report: all column values. Highlight authority-like columns from Phase 2 resolution.

Q7 — All 3 TAC publications

SELECT * FROM tac_publication ORDER BY <tac_pub_pk>;

Report: full dump. Identify any authority-like values across publications.

Q8 — Existing IU identity_profile samples

If iu_identity_profile RESOLVED:

SELECT <iu_pk>, <iu_identity_profile>
FROM information_unit
WHERE <iu_identity_profile> IS NOT NULL
LIMIT 5;

Report: actual JSON structure. Does publication_authority_ref key exist? What value?

Q9 — All distinct identity_profile keys

If iu_identity_profile RESOLVED:

SELECT DISTINCT jsonb_object_keys(<iu_identity_profile>) AS key
FROM information_unit
WHERE <iu_identity_profile> IS NOT NULL
ORDER BY key;

Report: list of all keys currently in use.

If concept not RESOLVED → UNKNOWN.


PHASE 4 — Function source analysis (bounded output)

Q10 — fn_iu_birth_gate_layer1 source

SELECT pg_get_functiondef(oid)
FROM pg_proc
WHERE proname = 'fn_iu_birth_gate_layer1';

From source, report ONLY these boolean flags:

checks_authority_key_presence        = true | false | UNKNOWN
checks_authority_value_non_null      = true | false | UNKNOWN
validates_authority_against_vocab    = true | false | UNKNOWN
authority_vocab_pattern_used         = <exact pattern if true> | N/A

Do NOT interpret beyond these flags. Do NOT recommend a value.

Q11 — fn_iu_create source (identity_profile section)

SELECT pg_get_functiondef(oid)
FROM pg_proc
WHERE proname = 'fn_iu_create';

From source, report ONLY:

sets_authority_ref_from_input        = true | false | UNKNOWN
sets_authority_ref_from_lookup       = true | false | UNKNOWN
requires_prebuilt_identity_profile   = true | false | UNKNOWN
authority_ref_source_if_set          = <parameter name or lookup pattern> | N/A

REPORT FORMAT

Save to: knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase5c2a-publication-authority-ref-probe-report.md

Sections: A (schemas), B (concept resolution), C (vocab evidence), D (TAC evidence), E (IU identity_profile), F (function analysis), G (summary).

Status block:

phase5c2a_probe_status=PASS|PARTIAL|BLOCKED
no_mutation_performed=true
concept_resolution_complete=true|false
publication_authority_vocab_exists=true|false|UNKNOWN
tac_pub_authority_like_columns=<list or FIELD_ABSENT>
existing_iu_has_authority_ref_key=true|false|UNKNOWN
birth_gate_checks_authority_key_presence=true|false|UNKNOWN
birth_gate_validates_authority_against_vocab=true|false|UNKNOWN
fn_iu_create_sets_authority_ref=true|false|UNKNOWN
recommended_authority_ref_source=<vocab_key|tac_column|fn_iu_create_handles|needs_seed|UNKNOWN>
next_recommended_action=GPT/User decides authority ref source from probe evidence

Agent does NOT decide authority value. All candidates candidate_not_approved.


Phase 5C2A Probe rev2 | Introspection-first | No assumed columns | Bounded function analysis | 2026-05-11

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/p3d-pack1-phase5c2a-readonly-publication-authority-ref-probe-prompt.md