KB-1246

S178-Fix30 H11b Scope Fix

3 min read Revision 1
S178-Fix30H11bdescription-governanceh11b_exclude_speciesproduction-verify

S178-Fix30 H11b Scope Fix

Date: 2026-04-23 Host: contabo DB: directus / Postgres container postgres Scope: Đ3 §2.5 — bản ghi vận hành không nằm trong H11b enrichment scope.

1. Config key đã seed

Migration file:

/opt/incomex/migrations/s178_fix30_h11b_scope_fix.sql

SQL applied:

INSERT INTO dot_config (key, value, description)
VALUES (
  'h11b_exclude_species',
  '["system_issue"]',
  'JSON array species_code loại trừ khỏi H11b enrichment scope (Đ3 §2.5). Bản ghi vận hành không cần mô tả chi tiết.'
)
ON CONFLICT (key) DO NOTHING;

Production verify:

         key          |      value       
----------------------+------------------
 h11b_exclude_species | ["system_issue"]
(1 row)

2. Query cũ vs mới

Query cũ không filter operational species:

 h11b_old 
----------
     1412
(1 row)

Query mới đọc dot_config.h11b_exclude_species:

 h11b_new 
----------
      364
(1 row)

Chênh lệch:

1412 - 364 = 1048

Breakdown theo species trước filter:

 species_code  | count 
---------------+-------
 system_issue  |  1041
 collection    |   147
 catalog       |   130
 page          |    37
 species       |    23
 dot_tool      |    10
 workflow_step |     8
               |     7
 agent         |     6
 task          |     3
(10 rows)

Ghi chú: phần chênh chính là system_issue=1041, đúng mục tiêu loại bản ghi vận hành. 7 row species_code NULL cũng không vào kết quả mới do semantics của v.species_code NOT IN (...) trong query được yêu cầu; kết quả 364 vẫn nằm trong kỳ vọng ~370.

3. KB file .sql đã update

File:

knowledge/current-state/queries/h11b-description-detail-missing.sql

Revision mới:

revision: 2

Nội dung hiện tại:

SELECT count(*) AS h11b_total
FROM v_entity_full_classification v
WHERE v.governance_role = 'governed'
  AND v.description IS NOT NULL
  AND btrim(v.description) <> ''
  AND (v.description_provenance = 'PROV-DOT' OR v.description_provenance IS NULL)
  AND v.species_code NOT IN (
    SELECT jsonb_array_elements_text(COALESCE(
      (SELECT value::jsonb FROM dot_config WHERE key = 'h11b_exclude_species'),
      '[]'::jsonb
    ))
  )

Search verify:

search_knowledge("h11b_exclude_species H11b Description Detail Missing Query species_code NOT IN") returned knowledge/current-state/queries/h11b-description-detail-missing.sql

Kết luận

H11b scope đã chuyển từ toàn bộ governed PROV-DOT/NULL sang enrichment scope đúng theo Đ3 §2.5: loại operational-record species qua dot_config.h11b_exclude_species, không hardcode trong query ngoài key config.