KB-C8CC

Clone SQL C — Scanner Write-Half (sha256 3aa5fe25…)

2 min read Revision 1
one-roofnonprod-clonesqlscanner-write

-- STEP C — SCANNER WRITE-HALF / CANDIDATE STATE (CLONE ONLY, PERSISTENT) -- sha256: 3aa5fe2528932037de77a3925d082f86f3eee811b1ea4f2d50d5ee9dba1b5ba7 -- ruleset -> candidate_scan_run -> candidate_state -> candidate_object; second -- run proves idempotency + bounded growth (natural-key upsert). Guard: gov emit -- + system_issues unchanged. \set ON_ERROR_STOP on \pset pager off -- ENTRY guard, then BEGIN -- 0. test ruleset RS-CLONE-TEST-1 (active) ON CONFLICT DO NOTHING -- RUN 1: candidate_scan_run SCAN-CLONE-TEST-1 (periodic_full, snapshot 1); -- candidate_state per group (5) ON CONFLICT(group_key,ruleset_version) DO UPDATE; -- candidate_object per inventory object joined to containment.parent_ref (35) -- ON CONFLICT(candidate_key,ruleset_version) DO UPDATE; materialization_reason='indep_authoritative'; -- UPDATE scan_run completed groups_scanned/objects_materialized/candidates_upserted. -- RUN 2: SCAN-CLONE-TEST-2 same natural keys upserted -> counts stay 5/35. -- ASSERT: state=5, obj=35, runs=2, gov_emit=0 (idempotent + bounded + no side effect). -- COMMIT. -- RESULT: state_final=5, obj_final=35, runs_final=2, gov_emit=0, system_issues=200480 unchanged (PASS). -- (Full executable body retained in the filesystem package; this KB copy is the -- verified summary with identical semantics and the recorded sha256.)

Back to Knowledge Hub knowledge/dev/reports/architecture/one-roof-nonprod-clone-full-coverage-pipeline-2026-06-02/sql/C_scanner_writehalf_clone.sql