IU Test b–f Command Pack — 02 Test b Domain-Axis Filter Plan
02 — Test b: Domain/Professional Axis Filter Plan (READ-ONLY)
Goal: Given a professional/domain axis value drawn from the Constitution's classification vocabulary, return the exact set of IU pieces carrying that axis tag — DOT-callable, config-driven, automated, evidence-producing. This is a read-only test: zero mutation.
Owner law: Điều 38/39 (IU axis). Mutation: none. Gate: none. Approval: none. Event/queue impact: none. Rollback: N/A (read-only). Readiness: HIGH.
1. Live substrate (verified)
iu_three_axis_envelope(216 rows; 1 per IU):axis_b_tagsjsonb +axis_b_tags_by_sourcejsonb.iu_metadata_tag(536 rows) keyed bytag_key;iu_metadata_tag_registry(36 rows) = the tag vocabulary.- Views:
v_iu_metadata_envelope,v_ui_iu_three_axis_envelope. - Refresh fn:
fn_iu_three_axis_envelope_refresh(+_if_stale,_drift_check); DOTdot_iu_rebuild_metadata_axes. Gateiu_core.three_axis_auto_refresh_enabled=false→ envelopes are manually refreshed; the filter reads them as-is.
2. Input dataset choices
Use the existing live corpus (216 IUs, no new data). Candidate domain-axis values (from live iu_metadata_tag.tag_key distribution):
| Axis-B family | Example values (live counts) |
|---|---|
legal_domain:* |
knowledge_systems (16), governance (5), technology (4) |
topic:* |
knowledge_graph (10), architecture (5), governance (3), dot_trigger (3), workflow (2) |
sectype:* |
technical_spec (25), governance_process (18), principle (11), process (10) |
doc:* |
DIEU-35 (36), DIEU-28 (27), DIEU-32 (23), DIEU-39 (16) |
kind:* |
law_unit (187), design_doc_section (29) |
Primary test value: legal_domain:knowledge_systems (expected 16 matches) — the cleanest "professional/domain axis" example. Secondary: topic:knowledge_graph (10).
3. Filter contract
filter_axis_b(
p_tag_key text, -- e.g. 'legal_domain:knowledge_systems' (required, must exist in registry)
p_lifecycle_status text = NULL, -- optional narrowing (e.g. 'enacted')
p_doc_code text = NULL, -- optional axis-A doc scope (e.g. 'DIEU-37')
p_match_mode text = 'exact' -- 'exact' | 'prefix' (prefix → 'legal_domain:%')
) RETURNS TABLE(unit_id uuid, canonical_address text, axis_a_doc_code text,
axis_a_sort_order int, axis_b_tags jsonb, lifecycle_status text)
- Source of truth =
iu_three_axis_envelope(read) joined toinformation_unitfor address; tag membership validated againstiu_metadata_tag/iu_metadata_tag_registry. - No-hardcode:
p_tag_keymust resolve to a row iniu_metadata_tag_registry; reject unknown keys (do not silently return empty). - Config-driven: result ordering by
axis_a_doc_code, axis_a_sort_order(stable, reconstruct-compatible).
4. Expected output shape
A deterministic, ordered rowset. For legal_domain:knowledge_systems: 16 rows, each with unit_id, canonical_address, axis_a_doc_code, axis_b_tags containing the key. Output is also emitted as a JSON evidence blob for the harness.
5. Needed DOT wrapper
dot_iu_filter_axis_b (read-only, non-mutating) — see deliverable 07. It wraps filter_axis_b(...), writes a dot_iu_command_run audit row (mutating=false), and returns {count, rows, registry_validated:true}. Gap: this command does not exist in the 42-command catalog (catalog has dot_iu_rebuild_metadata_axes = a refresh, not a filter).
6. No-mutation proof
- Function is declared
STABLE, contains onlySELECT; noINSERT/UPDATE/DELETE. - Harness wraps the call in
BEGIN; ... ; ROLLBACK;and asserts table row-count deltas = 0 acrossinformation_unit,iu_three_axis_envelope,iu_metadata_tag,event_outbox. dot_iu_command_run.mutating=falserecorded.
7. Assertions
- Cardinality: count(filter) == count(direct
iu_metadata_tagmembership for the key). Forlegal_domain:knowledge_systems== 16. - Set equality: the unit_id set from the envelope path == the unit_id set from the raw
iu_metadata_tagpath (no envelope drift). If unequal → axis-B envelope is stale → surfacesfn_iu_three_axis_envelope_drift_checkfinding. - Ordering determinism: two consecutive calls return byte-identical ordered output.
- Registry validation: unknown key (e.g.
legal_domain:does_not_exist) → explicit refusal, not empty success. - Zero mutation: all deltas 0 (per §6).
8. Evidence rows
dot_iu_command_runrow (mutating=false, input params, count, duration).- JSON:
{tag_key, match_mode, count, unit_ids[], drift_ok, registry_validated, deltas_zero}. - Stored under the harness run id for KB report attachment.
9. Failure modes
| Mode | Detection | Handling |
|---|---|---|
| Envelope stale (drift) | assertion 2 set-inequality; fn_iu_three_axis_envelope_drift_check |
report drift, do NOT auto-refresh inside read test (refresh is a separate gated op) |
| Unknown tag key | registry validation | refuse with indexed error |
| Empty result for valid key | count==0 but key in registry | PASS with count 0 only if raw path also 0; else FAIL (drift) |
| Non-deterministic order | assertion 3 | add explicit ORDER BY; FAIL until fixed |
10. Exact PASS criteria
PASS iff: assertions 1–5 all hold for at least 2 distinct axis-B families (one legal_domain:*, one topic:*), the DOT wrapper records mutating=false, and zero-mutation deltas confirmed. Otherwise PARTIAL (drift found, documented) or FAIL.
11. Author-ready implementation note
Implement filter_axis_b as a STABLE SQL function + dot_iu_filter_axis_b catalog entry in macro IU_TEST_B_C_READONLY_HARNESS_IMPLEMENTATION_XHIGH (deliverable 10, prompt #1). No gate, no approval. Reuse iu_three_axis_envelope + iu_metadata_tag_registry; do not create a new tag store (live-ready-means-use-not-rewrite). Pair b and c in one harness since both are read-only and share the envelope.