KB-60E2

59 — SB-13 Worker-Cursor Rehearsal Results (BEGIN..ROLLBACK, text-generalized watermark proven on int+uuid, entry==exit PASS, 2026-06-01)

4 min read Revision 1
one-roof-governanceimplementation-indexgcossb-13rehearsal-resultsbegin-rollbackgov-worker-cursortype-generalized-watermarkint-and-uuidqueue-heartbeat-reuseexecutor-name-driftRR-8RE-7entry-equals-exitcommit-forbiddenpass2026-06-01

59 — SB-13 Worker-Cursor Rehearsal Results (R-3)

Doc: 59. Role: Live BEGIN..ROLLBACK rehearsal result for SB-13 (governance worker-cursor family; doc 39). Executes doc 48 Prompt 2. Status: REHEARSAL RESULT — PASS. Author-mode BEGIN..ROLLBACK, ZERO COMMIT, no worker started, entry==exit proven. Build NO-GO. Date: 2026-06-01. Entry baseline: doc 57.


59.1 What was rehearsed

  • CREATE TABLE gov_worker_cursor with type-generalized text last_watermark_id (doc 39 §39.4 correction; live watermark types are int birth-id vs uuid outbox-id), (worker_name, source) PK, retry/DLQ counters (events_seen, attempts_written, dead_lettered), phase.
  • 5 worker rows modeled, none started: gov_backfill_sweep, gov_handoff_intake, gov_input_gate, gov_candidate_scan, gov_periodic_full_audit.
  • Type-generalization proof: stored an int-derived watermark (max(birth_registry.id)::text) and a uuid-derived watermark (an event_outbox.id::text) in the same text column with no type error.
  • Reuse queue_heartbeatdrift F-57-1 applied: real columns executor_name/executor_kind (PK executor_name), kind PG_worker, status ok, metadata '{}' (Điều-45 safe-check forbids body/content/secret keys).
  • Keyset predicate tested on an int source (birth_registry, PK index) and a uuid source (event_outbox, PK index) — both return rows, no type error (RR-8 / RE-7).

59.2 Transcript (verbatim)

===R3_SB13_PRE===  pre_cursor= (null) | pre_hb=3 | pre_pending=0 | pre_iuc=1
BEGIN SET SET SET  CREATE TABLE   intx_cursor=gov_worker_cursor
INSERT 0 5   (5 workers)   UPDATE 1  UPDATE 1
===R3_INTX_WATERMARKS_INT_AND_UUID_IN_ONE_TEXT_COL===
    worker_name     |       source       |          last_watermark_id
--------------------+--------------------+--------------------------------------
 gov_backfill_sweep | birth_registry     | 1055575
 gov_handoff_intake | registry_changelog | 00004a74-001f-4ee9-aeee-910f15e790d0
INSERT 0 1   (queue_heartbeat gov_backfill_sweep)
===R3_INTX_HEARTBEAT_PLUS1===  intx_hb=4 | intx_hb_gov=1
===R3_INTX_KEYSET_INT_SOURCE===   id = 1,2,3
===R3_INTX_KEYSET_UUID_SOURCE===  id = 00004a74…, 000064f1…, 0000be62…
ROLLBACK
===R3_SB13_POST===  post_cursor=(null) | post_hb=3 | post_hb_gov=0 | post_pending=0

Separate-session query_pg after ROLLBACK: gov_worker_cursor NULL, queue_heartbeat=3, gov_* heartbeats=0, event_pending=0.

Note: max(birth.id)=1,055,575 exceeds row count 1,042,945 — the id sequence is sparse (gaps), expected; keyset advancement uses id, not row ordinal.

59.3 Entry==Exit

Object Pre In-tx Post (sep. session) Equal?
to_regclass('gov_worker_cursor') NULL gov_worker_cursor NULL
queue_heartbeat count 3 4 3
queue_heartbeat gov_* 0 1 0
event_pending 0 0 0

59.4 Success criteria (all met)

  • gov_worker_cursor created then removed by ROLLBACK; queue_heartbeat governance row removed.
  • last_watermark_id is text; int (1055575) and uuid (00004a74-…) coexist in one column; keyset works on int AND uuid sources (RR-8 / RE-7 satisfied).
  • ✅ 5 worker rows modeled; no worker started; no cron.
  • ✅ Drift F-57-1 (executor_name/kind, Điều-45 metadata safe-check) applied cleanly.
  • os_proposal_approvals still 0; no COMMIT. Entry==Exit proven.

59.5 Verdict

R-3 SB-13 = PASS. The watermark type-generalization (the doc-39 correction over doc-31's "reuse iu_route_worker_cursor 1:1") is proven live. Reuse of queue_heartbeat works under its real column names and Điều-45 metadata safe-check. Build NO-GO.

Back to Knowledge Hub knowledge/dev/reports/architecture/one-roof-governance-technical-addendum-and-implementation-index-2026-06-01/59-sb13-worker-cursor-rehearsal-results.md