Add governance concept schema packet
Some checks are pending
CI / lint-and-test (push) Waiting to run

- Create guarded schema and links for governance gates and concept maps
- Prove clone apply and rollback while production schema stays unchanged
- Retain packet docs, state image, and focused tests for apply review

`docs/reports/leo-working-state-20260709/current-truth-index.md`
`docs/reports/leo-working-state-20260709/governance-concept-apply-authorized-commit.sql`
`docs/reports/leo-working-state-20260709/governance-concept-apply-rollback-rehearsal.sql`
`docs/reports/leo-working-state-20260709/governance-concept-clone-rehearsal-current.log`
`docs/reports/leo-working-state-20260709/governance-concept-current.md`
`docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql`
`docs/reports/leo-working-state-20260709/governance-concept-packet.json`
`docs/reports/leo-working-state-20260709/governance-concept-postflight.sql`
`docs/reports/leo-working-state-20260709/governance-concept-preflight.sql`
`docs/reports/leo-working-state-20260709/leo-db-state-24-governance-concept-schema.svg`
`docs/reports/leo-working-state-20260709/working-leo-current-state-20260709.md`
`docs/reports/leo-working-state-20260709/working-leo-execution-plan-current.md`
`scripts/kb_governance_concept_packet.py`
`tests/test_kb_governance_concept_packet.py`
This commit is contained in:
twentyOne2x 2026-07-10 00:17:38 +02:00
parent b508a1106b
commit 394a14660d
14 changed files with 1403 additions and 7 deletions

View file

@ -42,6 +42,11 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Rio strategy-context authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/rio-strategy-apply-authorized-commit.sql`
- Rio strategy-context delete rollback SQL: `docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql`
- Rio strategy-context clone commit/delete rollback log: `docs/reports/leo-working-state-20260709/rio-strategy-clone-rehearsal-current.log`
- Governance/concept-map schema companion packet, not executed in production: `docs/reports/leo-working-state-20260709/governance-concept-current.md`
- Governance/concept-map packet JSON: `docs/reports/leo-working-state-20260709/governance-concept-packet.json`
- Governance/concept-map authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/governance-concept-apply-authorized-commit.sql`
- Governance/concept-map delete rollback SQL: `docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql`
- Governance/concept-map clone commit/delete rollback log: `docs/reports/leo-working-state-20260709/governance-concept-clone-rehearsal-current.log`
- Helmer 7 Powers proposal plan: `docs/reports/leo-working-state-20260709/helmer-7powers-creation-plan.json`
- Helmer 7 Powers apply packet, not executed in production: `docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet-current.md`
- Helmer 7 Powers apply packet JSON: `docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet.json`
@ -68,6 +73,7 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Forgejo/load/agent update loop map: `docs/reports/leo-working-state-20260709/leo-db-state-21-forgejo-load-agent-loop.svg`
- Identity render / decision matrix / document artifact map: `docs/reports/leo-working-state-20260709/leo-db-state-22-identity-render-matrix-artifacts.svg`
- Rio strategy context packet proof: `docs/reports/leo-working-state-20260709/leo-db-state-23-rio-strategy-context.svg`
- Governance/concept-map schema packet proof: `docs/reports/leo-working-state-20260709/leo-db-state-24-governance-concept-schema.svg`
- DB loading diagram SVG: `docs/reports/leo-working-state-20260709/leo-db-loading-diagram-20260709T214741Z.svg`
- DB loading diagram Mermaid source: `docs/reports/leo-working-state-20260709/leo-db-loading-diagram-20260709T214741Z.mmd`
@ -81,9 +87,10 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Mapped rich approved proposal packet is clone/rehearsal-proven for the supported subset, not production-applied.
- The strategy-anchor companion write for mapped rich proposal `14fa5ecc` is clone-proven and reversible, not production-applied.
- The Rio strategy-context companion write for mapped rich proposal `14fa5ecc` is clone-proven and reversible: after the mapped base packet exists, it creates `2` Rio strategy nodes and `5` strategy anchors in a disposable clone; production stayed unchanged.
- The governance/concept-map schema companion write is clone-proven and reversible: after the mapped base packet exists, it creates minimal concept-map and claim-to-governance link tables, then inserts `1` concept map, `1` concept link, and `2` governance links in a disposable clone; production stayed unchanged.
- DB-first identity rendering is now documented from the July 9 PDFs plus VPS readback: canonical identity rows feed rendered `SOUL.md`, direct SOUL edits are not canonical DB updates, and no active renderer/timer/hook is proven in the current VPS readback.
- The decision-matrix approval schema is still a target design on the current VPS: `kb_stage.matrix_voters`, `kb_stage.proposal_votes`, and `kb_stage.proposal_decisions` were not present in live schema readback.
- Pending/approved document proposals are real `kb_stage.kb_proposals` rows with `source_ref`s, but inspected `source_ref`s did not directly match `public.sources`; they still need review/apply mapping into canonical sources/evidence/edges.
- Governance-gate and concept-map targets remain explicitly deferred because current schema has no safe direct write path for them.
- Governance-gate and concept-map targets are now schema-packet-proven, but not production-applied; the live VPS production schema still has no generated governance/concept tables.
- The live VPS runtime behavior should not be changed while the DB apply path is stabilized.
- GCP parity remains blocked by account auth/access facts until a fresh readback proves otherwise.

View file

@ -0,0 +1,128 @@
\set ON_ERROR_STOP on
begin;
create table if not exists public.concept_maps (
id uuid primary key default gen_random_uuid(),
key text not null unique,
title text not null,
body text not null,
status text not null default 'active' check (status = any (array['draft'::text, 'active'::text, 'retired'::text])),
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table if not exists public.claim_concept_map_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
concept_map_id uuid not null references public.concept_maps(id) on delete cascade,
relation text not null check (relation = any (array['derives_from'::text, 'supports'::text, 'contextualizes'::text, 'contains'::text, 'requires'::text, 'relates'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, concept_map_id, relation)
);
create table if not exists public.claim_governance_gate_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
governance_gate_id uuid not null references public.governance_gates(id) on delete cascade,
relation text not null check (relation = any (array['supports'::text, 'requires'::text, 'constrains'::text, 'documents'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, governance_gate_id, relation)
);
create index if not exists claim_concept_map_links_claim
on public.claim_concept_map_links (claim_id, relation);
create index if not exists claim_concept_map_links_map
on public.claim_concept_map_links (concept_map_id, relation);
create index if not exists claim_governance_gate_links_claim
on public.claim_governance_gate_links (claim_id, relation);
create index if not exists claim_governance_gate_links_gate
on public.claim_governance_gate_links (governance_gate_id, relation);
do $$
declare
inserted_concept_maps int;
inserted_concept_links int;
inserted_governance_links int;
begin
if (
select count(*) from public.claims where id in (select id from (values
('d009dfc4-9755-58a7-affb-80e3e842a775'::uuid),
('9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid)
) as v(id))
) <> 2 then
raise exception 'governance/concept packet requires mapped base claims to exist before inserts';
end if;
if (
select count(*) from public.governance_gates where id in (select id from (values
('fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid),
('45695897-2a9c-4279-ac25-e59f166dec6a'::uuid)
) as v(id))
) <> 2 then
raise exception 'governance/concept packet requires quality/evidence governance gates to exist';
end if;
if exists (select 1 from public.concept_maps where id = 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid or key = 'distributed_market_intelligence') then
raise exception 'governance/concept packet generated concept map already exists';
end if;
if exists (select 1 from public.claim_concept_map_links where id = 'af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid) then
raise exception 'governance/concept packet generated concept link already exists';
end if;
if exists (
select 1 from public.claim_governance_gate_links
where id in (select id from (values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid)
) as v(id))
) then
raise exception 'governance/concept packet generated governance link already exists';
end if;
insert into public.concept_maps (id, key, title, body, status, source_ref, metadata)
values (
'f013126c-0937-5bc8-b021-9697e59057d0'::uuid,
'distributed_market_intelligence',
'Distributed market intelligence',
'A concept map for how capital allocation depends on distributed knowledge, incentives, liquidity, feedback loops, and market signals rather than a single central planner.',
'active',
'mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence',
'{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragment": "capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence"}'::jsonb
);
get diagnostics inserted_concept_maps = row_count;
if inserted_concept_maps <> 1 then
raise exception 'governance/concept packet inserted % concept map row(s), expected 1', inserted_concept_maps;
end if;
insert into public.claim_concept_map_links
(id, claim_id, concept_map_id, relation, weight, rationale, source_ref, metadata)
values
('af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid, 'd009dfc4-9755-58a7-affb-80e3e842a775'::uuid, 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid, 'derives_from', 0.75, 'Mapped proposal 14fa5ecc: the capital-allocation distributed-knowledge claim draws from the distributed market intelligence concept map.', 'mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence', '{"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617"}'::jsonb);
get diagnostics inserted_concept_links = row_count;
if inserted_concept_links <> 1 then
raise exception 'governance/concept packet inserted % concept link row(s), expected 1', inserted_concept_links;
end if;
insert into public.claim_governance_gate_links
(id, claim_id, governance_gate_id, relation, weight, rationale, source_ref, metadata)
values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid, '9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid, 'fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid, 'supports', 0.85, 'Specific enough to disagree with requires more than a compressed headline for ambiguous claims.', 'mapped-rich-proposal-ac036c9d:governance_gate:quality-gate', '{"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"}'::jsonb),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid, '9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid, '45695897-2a9c-4279-ac25-e59f166dec6a'::uuid, 'supports', 0.85, 'Bodies can state the true evidence tier and scope limits.', 'mapped-rich-proposal-ac036c9d:governance_gate:evidence-bar', '{"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"}'::jsonb);
get diagnostics inserted_governance_links = row_count;
if inserted_governance_links <> 2 then
raise exception 'governance/concept packet inserted % governance link row(s), expected 2', inserted_governance_links;
end if;
end $$;
commit;

View file

@ -0,0 +1,128 @@
\set ON_ERROR_STOP on
begin;
create table if not exists public.concept_maps (
id uuid primary key default gen_random_uuid(),
key text not null unique,
title text not null,
body text not null,
status text not null default 'active' check (status = any (array['draft'::text, 'active'::text, 'retired'::text])),
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table if not exists public.claim_concept_map_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
concept_map_id uuid not null references public.concept_maps(id) on delete cascade,
relation text not null check (relation = any (array['derives_from'::text, 'supports'::text, 'contextualizes'::text, 'contains'::text, 'requires'::text, 'relates'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, concept_map_id, relation)
);
create table if not exists public.claim_governance_gate_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
governance_gate_id uuid not null references public.governance_gates(id) on delete cascade,
relation text not null check (relation = any (array['supports'::text, 'requires'::text, 'constrains'::text, 'documents'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, governance_gate_id, relation)
);
create index if not exists claim_concept_map_links_claim
on public.claim_concept_map_links (claim_id, relation);
create index if not exists claim_concept_map_links_map
on public.claim_concept_map_links (concept_map_id, relation);
create index if not exists claim_governance_gate_links_claim
on public.claim_governance_gate_links (claim_id, relation);
create index if not exists claim_governance_gate_links_gate
on public.claim_governance_gate_links (governance_gate_id, relation);
do $$
declare
inserted_concept_maps int;
inserted_concept_links int;
inserted_governance_links int;
begin
if (
select count(*) from public.claims where id in (select id from (values
('d009dfc4-9755-58a7-affb-80e3e842a775'::uuid),
('9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid)
) as v(id))
) <> 2 then
raise exception 'governance/concept packet requires mapped base claims to exist before inserts';
end if;
if (
select count(*) from public.governance_gates where id in (select id from (values
('fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid),
('45695897-2a9c-4279-ac25-e59f166dec6a'::uuid)
) as v(id))
) <> 2 then
raise exception 'governance/concept packet requires quality/evidence governance gates to exist';
end if;
if exists (select 1 from public.concept_maps where id = 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid or key = 'distributed_market_intelligence') then
raise exception 'governance/concept packet generated concept map already exists';
end if;
if exists (select 1 from public.claim_concept_map_links where id = 'af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid) then
raise exception 'governance/concept packet generated concept link already exists';
end if;
if exists (
select 1 from public.claim_governance_gate_links
where id in (select id from (values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid)
) as v(id))
) then
raise exception 'governance/concept packet generated governance link already exists';
end if;
insert into public.concept_maps (id, key, title, body, status, source_ref, metadata)
values (
'f013126c-0937-5bc8-b021-9697e59057d0'::uuid,
'distributed_market_intelligence',
'Distributed market intelligence',
'A concept map for how capital allocation depends on distributed knowledge, incentives, liquidity, feedback loops, and market signals rather than a single central planner.',
'active',
'mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence',
'{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragment": "capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence"}'::jsonb
);
get diagnostics inserted_concept_maps = row_count;
if inserted_concept_maps <> 1 then
raise exception 'governance/concept packet inserted % concept map row(s), expected 1', inserted_concept_maps;
end if;
insert into public.claim_concept_map_links
(id, claim_id, concept_map_id, relation, weight, rationale, source_ref, metadata)
values
('af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid, 'd009dfc4-9755-58a7-affb-80e3e842a775'::uuid, 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid, 'derives_from', 0.75, 'Mapped proposal 14fa5ecc: the capital-allocation distributed-knowledge claim draws from the distributed market intelligence concept map.', 'mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence', '{"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617"}'::jsonb);
get diagnostics inserted_concept_links = row_count;
if inserted_concept_links <> 1 then
raise exception 'governance/concept packet inserted % concept link row(s), expected 1', inserted_concept_links;
end if;
insert into public.claim_governance_gate_links
(id, claim_id, governance_gate_id, relation, weight, rationale, source_ref, metadata)
values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid, '9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid, 'fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid, 'supports', 0.85, 'Specific enough to disagree with requires more than a compressed headline for ambiguous claims.', 'mapped-rich-proposal-ac036c9d:governance_gate:quality-gate', '{"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"}'::jsonb),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid, '9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid, '45695897-2a9c-4279-ac25-e59f166dec6a'::uuid, 'supports', 0.85, 'Bodies can state the true evidence tier and scope limits.', 'mapped-rich-proposal-ac036c9d:governance_gate:evidence-bar', '{"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"}'::jsonb);
get diagnostics inserted_governance_links = row_count;
if inserted_governance_links <> 2 then
raise exception 'governance/concept packet inserted % governance link row(s), expected 2', inserted_governance_links;
end if;
end $$;
rollback;

View file

@ -0,0 +1,181 @@
=== service before ===
MainPID=3252143
NRestarts=0
ActiveState=active
SubState=running
=== production schema/counts before ===
prod_concept_maps | prod_claim_concept_map_links | prod_claim_governance_gate_links | prod_base_claims
-------------------+------------------------------+----------------------------------+------------------
| | | 0
(1 row)
=== create disposable clone ===
=== clone apply mapped base packet ===
BEGIN
SET
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
COMMIT
BEGIN
SET
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
COMMIT
=== clone base generated counts after base apply ===
clone_base_claims | clone_concept_maps | clone_claim_concept_map_links | clone_claim_governance_gate_links
-------------------+--------------------+-------------------------------+-----------------------------------
7 | | |
(1 row)
=== clone governance/concept preflight after base apply ===
check_name | name | regclass
--------------+------------------------------------+----------
schema_table | public.concept_maps |
schema_table | public.claim_concept_map_links |
schema_table | public.claim_governance_gate_links |
(3 rows)
check_name | id | status | text
---------------------+--------------------------------------+--------+-------------------------------------------------------------------------------------------------
required_base_claim | 9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0 | open | KB claim nodes need explanatory bodies, not only one-sentence headlines.
required_base_claim | d009dfc4-9755-58a7-affb-80e3e842a775 | open | Capital allocation depends on distributed knowledge, incentives, liquidity, and feedback loops.
(2 rows)
check_name | id | name | criteria | evidence_bar
--------------------------+--------------------------------------+--------------+------------------------------------------------------------------------------------------------------------+-------------------------------------
required_governance_gate | 45695897-2a9c-4279-ac25-e59f166dec6a | evidence-bar | likely needs empirical data; experimental = coherent argument, limited validation; speculative = untested. | likely > experimental > speculative
required_governance_gate | fa88e31b-6fca-4801-bf72-f5db81950a11 | quality-gate | Specific enough to disagree with; evidence traceable; not a duplicate; right domain reviewers. |
(2 rows)
=== clone apply governance/concept packet ===
BEGIN
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
DO
COMMIT
=== clone governance/concept postflight after apply ===
generated_concept_map_rows | generated_concept_link_rows | generated_governance_link_rows
----------------------------+-----------------------------+--------------------------------
1 | 1 | 2
(1 row)
id | key | title | status | source_ref | metadata
--------------------------------------+---------------------------------+---------------------------------+--------+---------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
f013126c-0937-5bc8-b021-9697e59057d0 | distributed_market_intelligence | Distributed market intelligence | active | mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence | {"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragment": "capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence", "base_packet_required_first": "production-apply-packet-mapped-20260709"}
(1 row)
id | claim_id | concept_map_id | relation | weight | rationale | source_ref
--------------------------------------+--------------------------------------+--------------------------------------+--------------+--------+------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------
af4ce1b9-db03-5bde-a21b-0e16ca0f48b8 | d009dfc4-9755-58a7-affb-80e3e842a775 | f013126c-0937-5bc8-b021-9697e59057d0 | derives_from | 0.75 | Mapped proposal 14fa5ecc: the capital-allocation distributed-knowledge claim draws from the distributed market intelligence concept map. | mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence
(1 row)
id | claim_id | governance_gate_id | relation | weight | rationale | source_ref
--------------------------------------+--------------------------------------+--------------------------------------+----------+--------+-------------------------------------------------------------------------------------------------+------------------------------------------------------------
af04a87e-c1da-57e9-b11c-60d79daa5648 | 9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0 | 45695897-2a9c-4279-ac25-e59f166dec6a | supports | 0.85 | Bodies can state the true evidence tier and scope limits. | mapped-rich-proposal-ac036c9d:governance_gate:evidence-bar
1f81e105-af5e-5db8-a7be-08cc6cc4e13a | 9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0 | fa88e31b-6fca-4801-bf72-f5db81950a11 | supports | 0.85 | Specific enough to disagree with requires more than a compressed headline for ambiguous claims. | mapped-rich-proposal-ac036c9d:governance_gate:quality-gate
(2 rows)
=== clone generated counts after governance/concept apply ===
clone_base_claims | clone_concept_maps | clone_concept_links | clone_governance_links
-------------------+--------------------+---------------------+------------------------
7 | 1 | 1 | 2
(1 row)
=== clone delete rollback governance/concept packet ===
BEGIN
DELETE 2
DELETE 1
DELETE 1
DO
COMMIT
=== clone schema readback after governance/concept rollback ===
clone_concept_maps | clone_claim_concept_map_links | clone_claim_governance_gate_links
--------------------+-------------------------------+-----------------------------------
| |
(1 row)
=== clone delete rollback mapped base packet ===
BEGIN
DELETE 17
DELETE 11
UPDATE 2
DELETE 15
DELETE 7
COMMIT
=== clone generated counts after all rollbacks ===
clone_base_claims | clone_concept_maps | clone_claim_concept_map_links | clone_claim_governance_gate_links
-------------------+--------------------+-------------------------------+-----------------------------------
0 | | |
(1 row)
=== production schema/counts after clone proof ===
prod_concept_maps | prod_claim_concept_map_links | prod_claim_governance_gate_links | prod_base_claims
-------------------+------------------------------+----------------------------------+------------------
| | | 0
(1 row)
=== cleanup disposable clone and temp files ===
=== cleanup readback ===
disposable_db_exists
----------------------
0
(1 row)
host_tmp_removed=yes
container_tmp_removed=yes
=== service after ===
MainPID=3252143
NRestarts=0
ActiveState=active
SubState=running

View file

@ -0,0 +1,67 @@
# Governance And Concept Map Packet - 2026-07-10
Generated UTC: `2026-07-10`
## Verdict
Clone-proven, not production-applied.
The live VPS schema had `public.governance_gates` but no canonical table linking claims to those gates, and no first-class concept-map table. This packet creates the minimal schema needed for the final non-claim fragments from the mapped rich proposals, then inserts exact row-level links after the mapped base packet exists.
## Schema Created In Clone
- `public.concept_maps`
- `public.claim_concept_map_links`
- `public.claim_governance_gate_links`
## Safe Writes
- `public.concept_maps`: 1 row
- `f013126c-0937-5bc8-b021-9697e59057d0`: `distributed_market_intelligence`
- `public.claim_concept_map_links`: 1 row
- Claim `d009dfc4-9755-58a7-affb-80e3e842a775` derives from concept map `f013126c-0937-5bc8-b021-9697e59057d0`
- `public.claim_governance_gate_links`: 2 rows
- Claim `9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0` supports quality gate `fa88e31b-6fca-4801-bf72-f5db81950a11`
- Claim `9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0` supports evidence bar `45695897-2a9c-4279-ac25-e59f166dec6a`
## Clone Proof
Disposable database: `teleo_governance_concept_rehearsal_20260710`
Sequence:
1. Created a disposable clone from live `teleo` using `pg_dump | psql`.
2. Applied the mapped base packet in the clone: `7` generated claims.
3. Ran governance/concept preflight:
- schema tables did not already exist.
- required base claims existed.
- required governance gates existed.
4. Ran governance/concept authorized commit SQL in the clone.
5. Postflight read back `1` concept map, `1` concept link, and `2` governance-gate links.
6. Ran governance/concept delete rollback.
7. Rollback removed generated rows and dropped the generated schema tables because they were empty.
8. Ran mapped base packet delete rollback.
9. Clone returned to `0` base claims and no generated governance/concept tables.
10. Production stayed unchanged: no generated governance/concept tables and `0` base generated claims.
11. Dropped the disposable DB and removed host/container temp files.
Cleanup readback:
- `disposable_db_exists`: `0`
- host tmp removed: yes
- container tmp removed: yes
- `leoclean-gateway.service`: `active`
- `MainPID`: `3252143`
- `NRestarts`: `0`
## Evidence
- Packet JSON: `docs/reports/leo-working-state-20260709/governance-concept-packet.json`
- Authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/governance-concept-apply-authorized-commit.sql`
- Delete rollback SQL: `docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql`
- Clone rehearsal log: `docs/reports/leo-working-state-20260709/governance-concept-clone-rehearsal-current.log`
- State image: `docs/reports/leo-working-state-20260709/leo-db-state-24-governance-concept-schema.svg`
## Claim Ceiling
This proves the remaining governance-gate and concept-map fragments are representable with a minimal schema packet and reversible in a disposable clone after the mapped base packet exists. It does not prove production has been updated, because production commit was intentionally not executed.

View file

@ -0,0 +1,36 @@
\set ON_ERROR_STOP on
-- Emergency rollback for governance/concept generated rows only.
-- Drops generated schema only when the generated tables are empty after row delete.
begin;
delete from public.claim_governance_gate_links
where id in (select id from (values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid)
) as v(id));
delete from public.claim_concept_map_links
where id = 'af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid;
delete from public.concept_maps
where id = 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid;
do $$
begin
if to_regclass('public.claim_governance_gate_links') is not null
and not exists (select 1 from public.claim_governance_gate_links) then
drop table public.claim_governance_gate_links;
end if;
if to_regclass('public.claim_concept_map_links') is not null
and not exists (select 1 from public.claim_concept_map_links) then
drop table public.claim_concept_map_links;
end if;
if to_regclass('public.concept_maps') is not null
and not exists (select 1 from public.concept_maps) then
drop table public.concept_maps;
end if;
end $$;
commit;

View file

@ -0,0 +1,100 @@
{
"base_packet_required_first": "production-apply-packet-mapped-20260709",
"generated_counts": {
"claim_concept_map_links": 1,
"claim_governance_gate_links": 2,
"concept_maps": 1
},
"packet_version": 1,
"production_apply_status": "not_executed",
"purpose": "Companion packet for mapped rich proposal governance-gate and concept-map targets.",
"represented_fragments": [
"capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence",
"claim_nodes_need_bodies supports governance_gate:quality-gate",
"claim_nodes_need_bodies supports governance_gate:evidence-bar"
],
"required_existing_rows": {
"public.claims": [
"d009dfc4-9755-58a7-affb-80e3e842a775",
"9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0"
],
"public.governance_gates": [
"fa88e31b-6fca-4801-bf72-f5db81950a11",
"45695897-2a9c-4279-ac25-e59f166dec6a"
]
},
"safe_writes": [
{
"operation": "insert",
"rows": [
{
"body": "A concept map for how capital allocation depends on distributed knowledge, incentives, liquidity, feedback loops, and market signals rather than a single central planner.",
"id": "f013126c-0937-5bc8-b021-9697e59057d0",
"key": "distributed_market_intelligence",
"metadata": {
"base_packet_required_first": "production-apply-packet-mapped-20260709",
"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617",
"source_fragment": "capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence"
},
"source_ref": "mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence",
"status": "active",
"title": "Distributed market intelligence"
}
],
"table": "public.concept_maps"
},
{
"operation": "insert",
"rows": [
{
"claim_id": "d009dfc4-9755-58a7-affb-80e3e842a775",
"concept_map_id": "f013126c-0937-5bc8-b021-9697e59057d0",
"id": "af4ce1b9-db03-5bde-a21b-0e16ca0f48b8",
"metadata": {
"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617"
},
"rationale": "Mapped proposal 14fa5ecc: the capital-allocation distributed-knowledge claim draws from the distributed market intelligence concept map.",
"relation": "derives_from",
"source_ref": "mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence",
"weight": 0.75
}
],
"table": "public.claim_concept_map_links"
},
{
"operation": "insert",
"rows": [
{
"claim_id": "9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0",
"governance_gate_id": "fa88e31b-6fca-4801-bf72-f5db81950a11",
"id": "1f81e105-af5e-5db8-a7be-08cc6cc4e13a",
"metadata": {
"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"
},
"rationale": "Specific enough to disagree with requires more than a compressed headline for ambiguous claims.",
"relation": "supports",
"source_ref": "mapped-rich-proposal-ac036c9d:governance_gate:quality-gate",
"weight": 0.85
},
{
"claim_id": "9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0",
"governance_gate_id": "45695897-2a9c-4279-ac25-e59f166dec6a",
"id": "af04a87e-c1da-57e9-b11c-60d79daa5648",
"metadata": {
"proposal_id": "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"
},
"rationale": "Bodies can state the true evidence tier and scope limits.",
"relation": "supports",
"source_ref": "mapped-rich-proposal-ac036c9d:governance_gate:evidence-bar",
"weight": 0.85
}
],
"table": "public.claim_governance_gate_links"
}
],
"schema_writes": [
"public.concept_maps",
"public.claim_concept_map_links",
"public.claim_governance_gate_links"
]
}

View file

@ -0,0 +1,39 @@
\set ON_ERROR_STOP on
-- Governance/concept companion postflight row-level readback.
select
(select count(*) from public.concept_maps where id = 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid) as generated_concept_map_rows,
(select count(*) from public.claim_concept_map_links where id = 'af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid) as generated_concept_link_rows,
(select count(*) from public.claim_governance_gate_links where id in (select id from (values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid)
) as v(id))) as generated_governance_link_rows;
select id::text, key, title, status, source_ref, metadata::text
from public.concept_maps
where id = 'f013126c-0937-5bc8-b021-9697e59057d0'::uuid;
select id::text,
claim_id::text,
concept_map_id::text,
relation,
weight,
left(rationale, 220) as rationale,
source_ref
from public.claim_concept_map_links
where id = 'af4ce1b9-db03-5bde-a21b-0e16ca0f48b8'::uuid;
select id::text,
claim_id::text,
governance_gate_id::text,
relation,
weight,
left(rationale, 220) as rationale,
source_ref
from public.claim_governance_gate_links
where id in (select id from (values
('1f81e105-af5e-5db8-a7be-08cc6cc4e13a'::uuid),
('af04a87e-c1da-57e9-b11c-60d79daa5648'::uuid)
) as v(id))
order by governance_gate_id;

View file

@ -0,0 +1,33 @@
\set ON_ERROR_STOP on
-- Governance/concept companion preflight. Read-only.
-- Run after the mapped rich proposal packet has been applied.
select 'schema_table' as check_name, name, to_regclass(name) as regclass
from (values
('public.concept_maps'),
('public.claim_concept_map_links'),
('public.claim_governance_gate_links')
) as v(name);
select 'required_base_claim' as check_name,
c.id::text,
c.status,
left(c.text, 220) as text
from public.claims c
where c.id in (select id from (values
('d009dfc4-9755-58a7-affb-80e3e842a775'::uuid),
('9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0'::uuid)
) as v(id))
order by c.id;
select 'required_governance_gate' as check_name,
id::text,
name,
left(criteria, 180) as criteria,
left(evidence_bar, 180) as evidence_bar
from public.governance_gates
where id in (select id from (values
('fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid),
('45695897-2a9c-4279-ac25-e59f166dec6a'::uuid)
) as v(id))
order by name;

View file

@ -0,0 +1,64 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="760" viewBox="0 0 1280 760" role="img" aria-labelledby="title desc">
<title id="title">Working Leo DB State 24 - Governance and concept map schema packet</title>
<desc id="desc">Diagram of the clone-proven governance gate and concept map schema packet.</desc>
<rect width="1280" height="760" fill="#f8fafc"/>
<text x="56" y="58" font-family="Arial, sans-serif" font-size="30" font-weight="700" fill="#0f172a">Working Leo DB State 24: Governance + Concept Map Packet</text>
<text x="56" y="88" font-family="Arial, sans-serif" font-size="15" fill="#475569">Minimal schema packet for the final non-claim fragments. Clone-proven; production untouched.</text>
<rect x="56" y="126" width="322" height="220" rx="8" fill="#ffffff" stroke="#94a3b8" stroke-width="2"/>
<text x="78" y="158" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#0f172a">Base Mapped Claims</text>
<text x="78" y="194" font-family="Arial, sans-serif" font-size="14" fill="#334155">public.claims</text>
<text x="78" y="226" font-family="Arial, sans-serif" font-size="13" fill="#475569">d009dfc4... distributed knowledge</text>
<text x="78" y="258" font-family="Arial, sans-serif" font-size="13" fill="#475569">9bcf7e6b... claim nodes need bodies</text>
<text x="78" y="306" font-family="Arial, sans-serif" font-size="13" fill="#475569">Prerequisite: mapped base packet creates rows first.</text>
<rect x="464" y="126" width="360" height="220" rx="8" fill="#ecfeff" stroke="#0891b2" stroke-width="2"/>
<text x="486" y="158" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#155e75">New Concept Schema</text>
<text x="486" y="194" font-family="Arial, sans-serif" font-size="14" fill="#164e63">public.concept_maps</text>
<text x="486" y="226" font-family="Arial, sans-serif" font-size="13" fill="#475569">distributed_market_intelligence</text>
<text x="486" y="266" font-family="Arial, sans-serif" font-size="14" fill="#164e63">public.claim_concept_map_links</text>
<text x="486" y="298" font-family="Arial, sans-serif" font-size="13" fill="#475569">claim derives_from concept map</text>
<rect x="900" y="126" width="324" height="220" rx="8" fill="#fff7ed" stroke="#f97316" stroke-width="2"/>
<text x="922" y="158" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#9a3412">New Governance Links</text>
<text x="922" y="194" font-family="Arial, sans-serif" font-size="14" fill="#9a3412">public.claim_governance_gate_links</text>
<text x="922" y="226" font-family="Arial, sans-serif" font-size="13" fill="#475569">claim supports quality-gate</text>
<text x="922" y="258" font-family="Arial, sans-serif" font-size="13" fill="#475569">claim supports evidence-bar</text>
<text x="922" y="306" font-family="Arial, sans-serif" font-size="13" fill="#475569">public.governance_gates already existed.</text>
<line x1="378" y1="226" x2="464" y2="226" stroke="#2563eb" stroke-width="3" marker-end="url(#arrow-blue)"/>
<text x="392" y="210" font-family="Arial, sans-serif" font-size="13" fill="#1d4ed8">derives_from</text>
<line x1="378" y1="258" x2="900" y2="242" stroke="#ea580c" stroke-width="3" marker-end="url(#arrow-orange)"/>
<text x="600" y="240" font-family="Arial, sans-serif" font-size="13" fill="#c2410c">supports gates</text>
<rect x="56" y="420" width="360" height="196" rx="8" fill="#f0fdf4" stroke="#16a34a" stroke-width="2"/>
<text x="78" y="452" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#166534">Disposable Clone Proof</text>
<text x="78" y="488" font-family="Arial, sans-serif" font-size="14" fill="#14532d">Clone DB: teleo_governance_concept_rehearsal_20260710</text>
<text x="78" y="518" font-family="Arial, sans-serif" font-size="14" fill="#14532d">After apply: concept maps 1, concept links 1, gate links 2</text>
<text x="78" y="548" font-family="Arial, sans-serif" font-size="14" fill="#14532d">After rollback: generated tables absent, base claims 0</text>
<text x="78" y="588" font-family="Arial, sans-serif" font-size="13" fill="#475569">Production schema stayed unchanged.</text>
<rect x="464" y="420" width="360" height="196" rx="8" fill="#eef2ff" stroke="#4f46e5" stroke-width="2"/>
<text x="486" y="452" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#3730a3">Apply Boundary</text>
<text x="486" y="488" font-family="Arial, sans-serif" font-size="14" fill="#312e81">No production commit executed.</text>
<text x="486" y="518" font-family="Arial, sans-serif" font-size="14" fill="#312e81">No live VPS Leo runtime changed.</text>
<text x="486" y="548" font-family="Arial, sans-serif" font-size="14" fill="#312e81">leoclean-gateway active, NRestarts=0.</text>
<text x="486" y="588" font-family="Arial, sans-serif" font-size="13" fill="#475569">Ready for separate schema/apply review.</text>
<rect x="900" y="420" width="324" height="196" rx="8" fill="#fef2f2" stroke="#ef4444" stroke-width="2"/>
<text x="922" y="452" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#991b1b">Still Not Live</text>
<text x="922" y="488" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">Tables do not exist in production yet.</text>
<text x="922" y="518" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">Generated canonical rows remain unapplied.</text>
<text x="922" y="548" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">GCP parity remains separate.</text>
<text x="56" y="700" font-family="Arial, sans-serif" font-size="14" fill="#475569">This packet resolves the schema shape for governance-gate and concept-map fragments without forcing them into public.claim_edges.</text>
<defs>
<marker id="arrow-blue" markerWidth="10" markerHeight="10" refX="7" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L8,3 z" fill="#2563eb"/>
</marker>
<marker id="arrow-orange" markerWidth="10" markerHeight="10" refX="7" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L8,3 z" fill="#ea580c"/>
</marker>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 6 KiB

View file

@ -93,6 +93,12 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- Rio packet then inserted `Rio capital deployment layer` and `Rio internet-finance capital product`
- anchors connect Claim A to the capital layer, Claim C and Claim D to the product, the product to the capital layer, and the capital layer to the Back shared root
- Rio rollback deleted the `5` anchors and `2` nodes; base rollback returned generated base claims to `0`; production stayed unchanged at `0/0/0`; temp files and clone were removed; service remained active with `MainPID=3252143`, `NRestarts=0`
- Governance/concept-map schema companion packet is now clone-proven:
- live schema had `public.governance_gates` but no claim-to-governance link table, and no first-class concept-map table
- packet creates minimal `public.concept_maps`, `public.claim_concept_map_links`, and `public.claim_governance_gate_links` tables in-transaction
- disposable DB `teleo_governance_concept_rehearsal_20260710` applied the mapped base packet first (`7` claims)
- governance/concept packet then inserted `1` concept map, `1` claim-concept link, and `2` claim-governance links
- rollback deleted generated rows and dropped the generated tables because they were empty; base rollback returned generated base claims to `0`; production stayed unchanged with no generated tables; temp files and clone were removed; service remained active with `MainPID=3252143`, `NRestarts=0`
- VPS/Hermes/DB identity and document-linking map is now documented:
- the supplied July 9 master/build and database-reference PDFs confirm the intended architecture is DB-first identity: canonical Postgres identity graph rows render to `SOUL.md`, and evidence depth remains on demand through `teleo-kb`
- direct `SOUL.md` edits are profile/runtime artifact edits, not canonical DB updates; they can drift or be overwritten unless represented in canonical rows first
@ -124,6 +130,8 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- Cross-surface strategy anchor clone proof log: `outputs/rich-proposal-creation-plan-20260709/cross-surface-resolution-20260709/cross-surface-clone-rehearsal-current.log`
- Rio strategy-context packet: `outputs/rich-proposal-creation-plan-20260709/rio-strategy-context-20260710/rio-strategy-packet.json`
- Rio strategy-context clone proof log: `outputs/rich-proposal-creation-plan-20260709/rio-strategy-context-20260710/rio-strategy-clone-rehearsal-current.log`
- Governance/concept-map packet: `outputs/rich-proposal-creation-plan-20260709/governance-concept-20260710/governance-concept-packet.json`
- Governance/concept-map clone proof log: `outputs/rich-proposal-creation-plan-20260709/governance-concept-20260710/governance-concept-clone-rehearsal-current.log`
- VPS/Hermes/DB mapping: `outputs/vps-hermes-db-mapping-20260709.md`
- Identity render / decision matrix / document artifact image: `outputs/leo-db-state-22-identity-render-matrix-artifacts.svg`
- Execution plan: `outputs/working-leo-execution-plan-20260709/working-leo-execution-plan-current.md`
@ -142,11 +150,12 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- Claim/body/metadata schema image: `outputs/leo-db-state-19-claims-body-metadata.svg`
- Cross-surface strategy anchor proof image: `outputs/leo-db-state-20-cross-surface-anchor.svg`
- Rio strategy context proof image: `outputs/leo-db-state-23-rio-strategy-context.svg`
- Governance/concept-map schema proof image: `outputs/leo-db-state-24-governance-concept-schema.svg`
- GCP parity blocker: `outputs/gcp-db-parity-current-blocker-20260709.json`
## Next Actions
1. Keep the live Telegram canary as the top-level regression proof for Cory-working memory + KB audit.
2. Do not auto-apply old freeform approvals.
3. Resolve the remaining non-claim target decisions: governance gates and concept-map storage. The active policy-to-Claim-D strategy anchor and Rio strategy context are clone-proven but not production-applied.
3. Do not run production apply without explicit authorization. The mapped base, cross-surface anchor, Rio strategy, and governance/concept packets are clone-proven but not production-applied.
4. Keep VPS Leo runtime behavior unchanged while the DB apply path is stabilized.

View file

@ -1,6 +1,6 @@
# Working Leo Execution Plan - 2026-07-09
Claim ceiling: VPS Telegram memory/KB audit, open-ended Cory-style triage, Telegram-to-`kb_stage` proposal staging, and strict existing-ID apply are working. Helmer 7 Powers is full-coverage packet and ledger clone-proven, but not production-applied. The mapped rich packet is clone-proven for its supported subset, the strategy-anchor companion write is clone-proven, and the Rio strategy-context companion write is clone-proven; none are production-applied. Governance-gate storage, concept-map storage, and GCP parity remain pending.
Claim ceiling: VPS Telegram memory/KB audit, open-ended Cory-style triage, Telegram-to-`kb_stage` proposal staging, and strict existing-ID apply are working. Helmer 7 Powers is full-coverage packet and ledger clone-proven, but not production-applied. The mapped rich packet is clone-proven for its supported subset, the strategy-anchor companion write is clone-proven, the Rio strategy-context companion write is clone-proven, and the governance/concept-map schema companion write is clone-proven; none are production-applied. GCP parity remains pending.
## WL-EXEC-01 - VPS Telegram-visible memory + KB audit
- Status: `done`
@ -73,12 +73,13 @@ Claim ceiling: VPS Telegram memory/KB audit, open-ended Cory-style triage, Teleg
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/rio-strategy-context-20260710/rio-strategy-clone-rehearsal-current.log`
## WL-EXEC-06 - Reviewed decisions for unsupported rich-packet fragments
- Status: `partially_resolved_pending_governance_and_concept_map_decisions`
- Result: Edge-type mappings, one canonical capital-allocation target, the active policy-to-Claim-D strategy anchor, and Rio strategy context are clone-proven. Remaining blockers are explicit non-claim/cross-table targets: governance gates and concept-map storage.
- Next action: Create a separate reviewed governance/concept-map storage lane before any canonical production apply of those fragments, or explicitly defer them from the production apply contract.
- Not done condition: No production apply until these decisions are resolved.
- Status: `done_packet_ready_not_executed`
- Result: Edge-type mappings, one canonical capital-allocation target, the active policy-to-Claim-D strategy anchor, Rio strategy context, and governance/concept-map storage are clone-proven. The governance/concept-map packet creates minimal tables and row-level links in a disposable clone, then rollback removes the rows and drops the generated tables.
- Next action: If production apply is authorized, apply packets in dependency order in a maintenance window: mapped base packet, cross-surface anchor packet, Rio strategy packet, governance/concept schema packet, then postflight readback.
- Not done condition: Production canonical rows/schema remain unapplied until explicit production apply authorization.
- Evidence:
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/rich-proposal-creation-plan-mapped-current.md`
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/governance-concept-20260710/governance-concept-clone-rehearsal-current.log`
## WL-EXEC-07 - Leo-in-the-loop staging from Telegram
- Status: `done_for_guarded_kb_stage_canary`

View file

@ -0,0 +1,499 @@
#!/usr/bin/env python3
"""Generate a governance/concept-map companion packet for mapped KB proposals.
The current live schema has governance gate rows but no canonical table linking
claims to those gates, and it has no first-class concept-map table. This packet
creates the minimal schema needed for the remaining mapped proposal fragments,
then inserts exact row-level links after the mapped base packet has created the
required claim rows.
The packet builder is not an executor. Production apply remains a separate
authorization boundary.
"""
from __future__ import annotations
import argparse
import json
import sys
import uuid
from pathlib import Path
from typing import Any
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
from kb_rich_proposal_creation_plan import _sql_literal # noqa: E402
BASE_PACKET_REQUIRED_FIRST = "production-apply-packet-mapped-20260709"
PROPOSAL_CONCEPT_ID = "14fa5ecc-ac7a-41c1-807d-a2e85b936617"
PROPOSAL_GOVERNANCE_ID = "ac036c9d-20a0-4ffe-881f-57d6b7bacf22"
CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID = "d009dfc4-9755-58a7-affb-80e3e842a775"
CLAIM_NODES_NEED_BODIES_ID = "9bcf7e6b-4e98-52b1-91ef-96cfc15e3df0"
QUALITY_GATE_ID = "fa88e31b-6fca-4801-bf72-f5db81950a11"
EVIDENCE_BAR_ID = "45695897-2a9c-4279-ac25-e59f166dec6a"
CONCEPT_MAP_KEY = "distributed_market_intelligence"
ID_NAMESPACE = uuid.uuid5(uuid.NAMESPACE_URL, "teleo:working-leo:governance-concept-packet")
def stable_id(key: str) -> str:
return str(uuid.uuid5(ID_NAMESPACE, key))
CONCEPT_MAP_ID = stable_id("concept-map:distributed-market-intelligence")
CONCEPT_LINK_ID = stable_id("claim-concept-map-link:capital-allocation-distributed-knowledge")
QUALITY_GATE_LINK_ID = stable_id("claim-governance-link:claim-bodies:quality-gate")
EVIDENCE_BAR_LINK_ID = stable_id("claim-governance-link:claim-bodies:evidence-bar")
def _uuid_values(values: list[str], *, column_name: str = "id") -> str:
rows = ",\n ".join(f"('{value}'::uuid)" for value in values)
return f"(values\n {rows}\n ) as v({column_name})"
def _jsonb(value: Any) -> str:
return _sql_literal(json.dumps(value, sort_keys=True)) + "::jsonb"
def concept_map_row() -> dict[str, Any]:
return {
"id": CONCEPT_MAP_ID,
"key": CONCEPT_MAP_KEY,
"title": "Distributed market intelligence",
"body": (
"A concept map for how capital allocation depends on distributed knowledge, incentives, "
"liquidity, feedback loops, and market signals rather than a single central planner."
),
"status": "active",
"source_ref": "mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence",
"metadata": {
"base_packet_required_first": BASE_PACKET_REQUIRED_FIRST,
"proposal_id": PROPOSAL_CONCEPT_ID,
"source_fragment": (
"capital_allocation_depends_on_distributed_market_intelligence draws_from "
"concept_map:distributed_market_intelligence"
),
},
}
def concept_links() -> list[dict[str, Any]]:
return [
{
"id": CONCEPT_LINK_ID,
"claim_id": CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID,
"concept_map_id": CONCEPT_MAP_ID,
"relation": "derives_from",
"weight": 0.75,
"rationale": (
"Mapped proposal 14fa5ecc: the capital-allocation distributed-knowledge claim draws "
"from the distributed market intelligence concept map."
),
"source_ref": "mapped-rich-proposal-14fa5ecc:concept_map:distributed_market_intelligence",
"metadata": {"proposal_id": PROPOSAL_CONCEPT_ID},
}
]
def governance_links() -> list[dict[str, Any]]:
return [
{
"id": QUALITY_GATE_LINK_ID,
"claim_id": CLAIM_NODES_NEED_BODIES_ID,
"governance_gate_id": QUALITY_GATE_ID,
"relation": "supports",
"weight": 0.85,
"rationale": (
"Specific enough to disagree with requires more than a compressed headline for ambiguous claims."
),
"source_ref": "mapped-rich-proposal-ac036c9d:governance_gate:quality-gate",
"metadata": {"proposal_id": PROPOSAL_GOVERNANCE_ID},
},
{
"id": EVIDENCE_BAR_LINK_ID,
"claim_id": CLAIM_NODES_NEED_BODIES_ID,
"governance_gate_id": EVIDENCE_BAR_ID,
"relation": "supports",
"weight": 0.85,
"rationale": "Bodies can state the true evidence tier and scope limits.",
"source_ref": "mapped-rich-proposal-ac036c9d:governance_gate:evidence-bar",
"metadata": {"proposal_id": PROPOSAL_GOVERNANCE_ID},
},
]
def build_schema_sql() -> str:
return """create table if not exists public.concept_maps (
id uuid primary key default gen_random_uuid(),
key text not null unique,
title text not null,
body text not null,
status text not null default 'active' check (status = any (array['draft'::text, 'active'::text, 'retired'::text])),
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table if not exists public.claim_concept_map_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
concept_map_id uuid not null references public.concept_maps(id) on delete cascade,
relation text not null check (relation = any (array['derives_from'::text, 'supports'::text, 'contextualizes'::text, 'contains'::text, 'requires'::text, 'relates'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, concept_map_id, relation)
);
create table if not exists public.claim_governance_gate_links (
id uuid primary key default gen_random_uuid(),
claim_id uuid not null references public.claims(id) on delete cascade,
governance_gate_id uuid not null references public.governance_gates(id) on delete cascade,
relation text not null check (relation = any (array['supports'::text, 'requires'::text, 'constrains'::text, 'documents'::text])),
weight numeric check (weight >= 0 and weight <= 1),
rationale text not null,
source_ref text,
metadata jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
unique (claim_id, governance_gate_id, relation)
);
create index if not exists claim_concept_map_links_claim
on public.claim_concept_map_links (claim_id, relation);
create index if not exists claim_concept_map_links_map
on public.claim_concept_map_links (concept_map_id, relation);
create index if not exists claim_governance_gate_links_claim
on public.claim_governance_gate_links (claim_id, relation);
create index if not exists claim_governance_gate_links_gate
on public.claim_governance_gate_links (governance_gate_id, relation);"""
def build_generated_counts_sql() -> str:
return f"""select
(select count(*) from public.concept_maps where id = {_sql_literal(CONCEPT_MAP_ID)}::uuid) as generated_concept_map_rows,
(select count(*) from public.claim_concept_map_links where id = {_sql_literal(CONCEPT_LINK_ID)}::uuid) as generated_concept_link_rows,
(select count(*) from public.claim_governance_gate_links where id in (select id from {_uuid_values([QUALITY_GATE_LINK_ID, EVIDENCE_BAR_LINK_ID])})) as generated_governance_link_rows;
"""
def _concept_map_insert_sql() -> str:
row = concept_map_row()
return f"""insert into public.concept_maps (id, key, title, body, status, source_ref, metadata)
values (
{_sql_literal(row['id'])}::uuid,
{_sql_literal(row['key'])},
{_sql_literal(row['title'])},
{_sql_literal(row['body'])},
{_sql_literal(row['status'])},
{_sql_literal(row['source_ref'])},
{_jsonb(row['metadata'])}
);"""
def _concept_link_insert_values() -> str:
rows = []
for row in concept_links():
rows.append(
"("
f"{_sql_literal(row['id'])}::uuid, "
f"{_sql_literal(row['claim_id'])}::uuid, "
f"{_sql_literal(row['concept_map_id'])}::uuid, "
f"{_sql_literal(row['relation'])}, "
f"{row['weight']}, "
f"{_sql_literal(row['rationale'])}, "
f"{_sql_literal(row['source_ref'])}, "
f"{_jsonb(row['metadata'])}"
")"
)
return ",\n ".join(rows)
def _governance_link_insert_values() -> str:
rows = []
for row in governance_links():
rows.append(
"("
f"{_sql_literal(row['id'])}::uuid, "
f"{_sql_literal(row['claim_id'])}::uuid, "
f"{_sql_literal(row['governance_gate_id'])}::uuid, "
f"{_sql_literal(row['relation'])}, "
f"{row['weight']}, "
f"{_sql_literal(row['rationale'])}, "
f"{_sql_literal(row['source_ref'])}, "
f"{_jsonb(row['metadata'])}"
")"
)
return ",\n ".join(rows)
def build_preflight_sql() -> str:
required_claim_ids = [CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID, CLAIM_NODES_NEED_BODIES_ID]
required_gate_ids = [QUALITY_GATE_ID, EVIDENCE_BAR_ID]
return f"""\\set ON_ERROR_STOP on
-- Governance/concept companion preflight. Read-only.
-- Run after the mapped rich proposal packet has been applied.
select 'schema_table' as check_name, name, to_regclass(name) as regclass
from (values
('public.concept_maps'),
('public.claim_concept_map_links'),
('public.claim_governance_gate_links')
) as v(name);
select 'required_base_claim' as check_name,
c.id::text,
c.status,
left(c.text, 220) as text
from public.claims c
where c.id in (select id from {_uuid_values(required_claim_ids)})
order by c.id;
select 'required_governance_gate' as check_name,
id::text,
name,
left(criteria, 180) as criteria,
left(evidence_bar, 180) as evidence_bar
from public.governance_gates
where id in (select id from {_uuid_values(required_gate_ids)})
order by name;
"""
def build_apply_sql(*, commit: bool) -> str:
terminator = "commit;" if commit else "rollback;"
required_claim_ids = [CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID, CLAIM_NODES_NEED_BODIES_ID]
required_gate_ids = [QUALITY_GATE_ID, EVIDENCE_BAR_ID]
return f"""\\set ON_ERROR_STOP on
begin;
{build_schema_sql()}
do $$
declare
inserted_concept_maps int;
inserted_concept_links int;
inserted_governance_links int;
begin
if (
select count(*) from public.claims where id in (select id from {_uuid_values(required_claim_ids)})
) <> {len(required_claim_ids)} then
raise exception 'governance/concept packet requires mapped base claims to exist before inserts';
end if;
if (
select count(*) from public.governance_gates where id in (select id from {_uuid_values(required_gate_ids)})
) <> {len(required_gate_ids)} then
raise exception 'governance/concept packet requires quality/evidence governance gates to exist';
end if;
if exists (select 1 from public.concept_maps where id = {_sql_literal(CONCEPT_MAP_ID)}::uuid or key = {_sql_literal(CONCEPT_MAP_KEY)}) then
raise exception 'governance/concept packet generated concept map already exists';
end if;
if exists (select 1 from public.claim_concept_map_links where id = {_sql_literal(CONCEPT_LINK_ID)}::uuid) then
raise exception 'governance/concept packet generated concept link already exists';
end if;
if exists (
select 1 from public.claim_governance_gate_links
where id in (select id from {_uuid_values([QUALITY_GATE_LINK_ID, EVIDENCE_BAR_LINK_ID])})
) then
raise exception 'governance/concept packet generated governance link already exists';
end if;
{_concept_map_insert_sql()}
get diagnostics inserted_concept_maps = row_count;
if inserted_concept_maps <> 1 then
raise exception 'governance/concept packet inserted % concept map row(s), expected 1', inserted_concept_maps;
end if;
insert into public.claim_concept_map_links
(id, claim_id, concept_map_id, relation, weight, rationale, source_ref, metadata)
values
{_concept_link_insert_values()};
get diagnostics inserted_concept_links = row_count;
if inserted_concept_links <> {len(concept_links())} then
raise exception 'governance/concept packet inserted % concept link row(s), expected {len(concept_links())}', inserted_concept_links;
end if;
insert into public.claim_governance_gate_links
(id, claim_id, governance_gate_id, relation, weight, rationale, source_ref, metadata)
values
{_governance_link_insert_values()};
get diagnostics inserted_governance_links = row_count;
if inserted_governance_links <> {len(governance_links())} then
raise exception 'governance/concept packet inserted % governance link row(s), expected {len(governance_links())}', inserted_governance_links;
end if;
end $$;
{terminator}
"""
def build_postflight_sql() -> str:
return f"""\\set ON_ERROR_STOP on
-- Governance/concept companion postflight row-level readback.
{build_generated_counts_sql()}
select id::text, key, title, status, source_ref, metadata::text
from public.concept_maps
where id = {_sql_literal(CONCEPT_MAP_ID)}::uuid;
select id::text,
claim_id::text,
concept_map_id::text,
relation,
weight,
left(rationale, 220) as rationale,
source_ref
from public.claim_concept_map_links
where id = {_sql_literal(CONCEPT_LINK_ID)}::uuid;
select id::text,
claim_id::text,
governance_gate_id::text,
relation,
weight,
left(rationale, 220) as rationale,
source_ref
from public.claim_governance_gate_links
where id in (select id from {_uuid_values([QUALITY_GATE_LINK_ID, EVIDENCE_BAR_LINK_ID])})
order by governance_gate_id;
"""
def build_delete_rollback_sql() -> str:
return f"""\\set ON_ERROR_STOP on
-- Emergency rollback for governance/concept generated rows only.
-- Drops generated schema only when the generated tables are empty after row delete.
begin;
delete from public.claim_governance_gate_links
where id in (select id from {_uuid_values([QUALITY_GATE_LINK_ID, EVIDENCE_BAR_LINK_ID])});
delete from public.claim_concept_map_links
where id = {_sql_literal(CONCEPT_LINK_ID)}::uuid;
delete from public.concept_maps
where id = {_sql_literal(CONCEPT_MAP_ID)}::uuid;
do $$
begin
if to_regclass('public.claim_governance_gate_links') is not null
and not exists (select 1 from public.claim_governance_gate_links) then
drop table public.claim_governance_gate_links;
end if;
if to_regclass('public.claim_concept_map_links') is not null
and not exists (select 1 from public.claim_concept_map_links) then
drop table public.claim_concept_map_links;
end if;
if to_regclass('public.concept_maps') is not null
and not exists (select 1 from public.concept_maps) then
drop table public.concept_maps;
end if;
end $$;
commit;
"""
def build_packet() -> dict[str, Any]:
return {
"packet_version": 1,
"purpose": "Companion packet for mapped rich proposal governance-gate and concept-map targets.",
"production_apply_status": "not_executed",
"base_packet_required_first": BASE_PACKET_REQUIRED_FIRST,
"schema_writes": [
"public.concept_maps",
"public.claim_concept_map_links",
"public.claim_governance_gate_links",
],
"generated_counts": {
"concept_maps": 1,
"claim_concept_map_links": len(concept_links()),
"claim_governance_gate_links": len(governance_links()),
},
"required_existing_rows": {
"public.claims": [
CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID,
CLAIM_NODES_NEED_BODIES_ID,
],
"public.governance_gates": [QUALITY_GATE_ID, EVIDENCE_BAR_ID],
},
"safe_writes": [
{
"table": "public.concept_maps",
"operation": "insert",
"rows": [concept_map_row()],
},
{
"table": "public.claim_concept_map_links",
"operation": "insert",
"rows": concept_links(),
},
{
"table": "public.claim_governance_gate_links",
"operation": "insert",
"rows": governance_links(),
},
],
"represented_fragments": [
"capital_allocation_depends_on_distributed_market_intelligence draws_from concept_map:distributed_market_intelligence",
"claim_nodes_need_bodies supports governance_gate:quality-gate",
"claim_nodes_need_bodies supports governance_gate:evidence-bar",
],
"sql": {
"preflight": build_preflight_sql(),
"apply_rollback_rehearsal": build_apply_sql(commit=False),
"apply_commit": build_apply_sql(commit=True),
"postflight": build_postflight_sql(),
"delete_rollback": build_delete_rollback_sql(),
},
}
def write_packet_files(packet: dict[str, Any], output_dir: Path) -> None:
output_dir.mkdir(parents=True, exist_ok=True)
sql = packet["sql"]
(output_dir / "governance-concept-preflight.sql").write_text(sql["preflight"], encoding="utf-8")
(output_dir / "governance-concept-apply-rollback-rehearsal.sql").write_text(
sql["apply_rollback_rehearsal"], encoding="utf-8"
)
(output_dir / "governance-concept-apply-authorized-commit.sql").write_text(
sql["apply_commit"], encoding="utf-8"
)
(output_dir / "governance-concept-postflight.sql").write_text(sql["postflight"], encoding="utf-8")
(output_dir / "governance-concept-delete-rollback.sql").write_text(sql["delete_rollback"], encoding="utf-8")
summary = {key: value for key, value in packet.items() if key != "sql"}
(output_dir / "governance-concept-packet.json").write_text(
json.dumps(summary, indent=2, sort_keys=True) + "\n", encoding="utf-8"
)
def parse_args(argv: list[str]) -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output-dir", type=Path, help="directory to write packet files")
return parser.parse_args(argv)
def main(argv: list[str] | None = None) -> int:
args = parse_args(sys.argv[1:] if argv is None else argv)
packet = build_packet()
if args.output_dir:
write_packet_files(packet, args.output_dir)
print(json.dumps({key: value for key, value in packet.items() if key != "sql"}, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,104 @@
"""Tests for scripts/kb_governance_concept_packet.py."""
from __future__ import annotations
import json
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import kb_governance_concept_packet as packet # noqa: E402
def test_packet_declares_minimal_schema_and_generated_rows():
result = packet.build_packet()
assert result["base_packet_required_first"] == "production-apply-packet-mapped-20260709"
assert result["production_apply_status"] == "not_executed"
assert result["schema_writes"] == [
"public.concept_maps",
"public.claim_concept_map_links",
"public.claim_governance_gate_links",
]
assert result["generated_counts"] == {
"claim_concept_map_links": 1,
"claim_governance_gate_links": 2,
"concept_maps": 1,
}
assert result["required_existing_rows"] == {
"public.claims": [
packet.CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID,
packet.CLAIM_NODES_NEED_BODIES_ID,
],
"public.governance_gates": [packet.QUALITY_GATE_ID, packet.EVIDENCE_BAR_ID],
}
def test_concept_map_row_and_links_represent_remaining_fragments():
concept = packet.concept_map_row()
assert concept["id"] == packet.CONCEPT_MAP_ID
assert concept["key"] == "distributed_market_intelligence"
assert concept["metadata"]["proposal_id"] == packet.PROPOSAL_CONCEPT_ID
concept_link = packet.concept_links()[0]
assert concept_link["claim_id"] == packet.CLAIM_DISTRIBUTED_MARKET_INTELLIGENCE_ID
assert concept_link["concept_map_id"] == packet.CONCEPT_MAP_ID
assert concept_link["relation"] == "derives_from"
gate_links = {row["governance_gate_id"]: row for row in packet.governance_links()}
assert gate_links[packet.QUALITY_GATE_ID]["claim_id"] == packet.CLAIM_NODES_NEED_BODIES_ID
assert gate_links[packet.EVIDENCE_BAR_ID]["claim_id"] == packet.CLAIM_NODES_NEED_BODIES_ID
assert {row["relation"] for row in gate_links.values()} == {"supports"}
def test_schema_sql_creates_first_class_tables_without_runtime_changes():
sql = packet.build_schema_sql()
assert "create table if not exists public.concept_maps" in sql
assert "create table if not exists public.claim_concept_map_links" in sql
assert "create table if not exists public.claim_governance_gate_links" in sql
assert "references public.claims(id) on delete cascade" in sql
assert "references public.governance_gates(id) on delete cascade" in sql
assert "references public.concept_maps(id) on delete cascade" in sql
def test_apply_sql_is_guarded_and_commit_or_rollback_specific():
commit_sql = packet.build_packet()["sql"]["apply_commit"]
rollback_sql = packet.build_packet()["sql"]["apply_rollback_rehearsal"]
assert "requires mapped base claims" in commit_sql
assert "requires quality/evidence governance gates" in commit_sql
assert "generated concept map already exists" in commit_sql
assert "expected 1" in commit_sql
assert "expected 2" in commit_sql
assert commit_sql.strip().endswith("commit;")
assert rollback_sql.strip().endswith("rollback;")
def test_delete_rollback_drops_schema_only_after_generated_rows_deleted():
sql = packet.build_packet()["sql"]["delete_rollback"]
concept_link_delete = sql.index("delete from public.claim_concept_map_links")
concept_delete = sql.index("delete from public.concept_maps")
drop_link = sql.index("drop table public.claim_concept_map_links")
drop_concept = sql.index("drop table public.concept_maps")
assert concept_link_delete < concept_delete < drop_concept
assert concept_link_delete < drop_link
assert "and not exists (select 1 from public.claim_governance_gate_links)" in sql
assert "and not exists (select 1 from public.claim_concept_map_links)" in sql
assert "and not exists (select 1 from public.concept_maps)" in sql
def test_write_packet_files(tmp_path: Path):
result = packet.build_packet()
packet.write_packet_files(result, tmp_path)
expected = {
"governance-concept-apply-authorized-commit.sql",
"governance-concept-apply-rollback-rehearsal.sql",
"governance-concept-delete-rollback.sql",
"governance-concept-packet.json",
"governance-concept-postflight.sql",
"governance-concept-preflight.sql",
}
assert {path.name for path in tmp_path.iterdir()} == expected
summary = json.loads((tmp_path / "governance-concept-packet.json").read_text())
assert "sql" not in summary
assert summary["generated_counts"]["claim_governance_gate_links"] == 2