Add Rio strategy context packet
Some checks are pending
CI / lint-and-test (push) Waiting to run

- Create guarded Rio strategy nodes and anchors after the mapped base packet
- Prove clone apply and rollback while production rows and Leo runtime stay unchanged
- Retain packet docs, state image, and focused tests for future apply review

`docs/reports/leo-working-state-20260709/current-truth-index.md`
`docs/reports/leo-working-state-20260709/leo-db-state-23-rio-strategy-context.svg`
`docs/reports/leo-working-state-20260709/rio-strategy-apply-authorized-commit.sql`
`docs/reports/leo-working-state-20260709/rio-strategy-apply-rollback-rehearsal.sql`
`docs/reports/leo-working-state-20260709/rio-strategy-clone-rehearsal-current.log`
`docs/reports/leo-working-state-20260709/rio-strategy-context-current.md`
`docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql`
`docs/reports/leo-working-state-20260709/rio-strategy-packet.json`
`docs/reports/leo-working-state-20260709/rio-strategy-postflight.sql`
`docs/reports/leo-working-state-20260709/rio-strategy-preflight.sql`
`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_rio_strategy_context_packet.py`
`tests/test_kb_rio_strategy_context_packet.py`
This commit is contained in:
twentyOne2x 2026-07-10 00:11:23 +02:00
parent ae00beeb3b
commit b508a1106b
14 changed files with 1468 additions and 6 deletions

View file

@ -37,6 +37,11 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Cross-surface authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/cross-surface-apply-authorized-commit.sql`
- Cross-surface delete rollback SQL: `docs/reports/leo-working-state-20260709/cross-surface-delete-rollback.sql`
- Cross-surface clone commit/delete rollback log: `docs/reports/leo-working-state-20260709/cross-surface-clone-rehearsal-current.log`
- Rio strategy-context companion packet, not executed in production: `docs/reports/leo-working-state-20260709/rio-strategy-context-current.md`
- Rio strategy-context packet JSON: `docs/reports/leo-working-state-20260709/rio-strategy-packet.json`
- 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`
- 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`
@ -62,6 +67,7 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Cross-surface strategy anchor proof: `docs/reports/leo-working-state-20260709/leo-db-state-20-cross-surface-anchor.svg`
- 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`
- 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`
@ -74,9 +80,10 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
- Helmer 7 Powers is full-coverage packet and ledger clone-proven, not production-applied.
- 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.
- 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, concept-map, and Rio strategy targets remain explicitly deferred because current schema has no safe direct write path for them.
- Governance-gate and concept-map targets remain explicitly deferred because current schema has no safe direct write path for them.
- 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,76 @@
<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 23 - Rio strategy context packet</title>
<desc id="desc">Diagram of the clone-proven Rio strategy context packet and its relationship to mapped claims and shared roots.</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 23: Rio Strategy Context Packet</text>
<text x="56" y="88" font-family="Arial, sans-serif" font-size="15" fill="#475569">Clone-proven companion packet for proposal 14fa5ecc. Production remains untouched.</text>
<rect x="56" y="126" width="340" height="230" 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 Packet</text>
<text x="78" y="190" font-family="Arial, sans-serif" font-size="15" fill="#334155">public.claims</text>
<text x="78" y="218" font-family="Arial, sans-serif" font-size="14" fill="#475569">Claim A: 004195cc... steering</text>
<text x="78" y="246" font-family="Arial, sans-serif" font-size="14" fill="#475569">Claim C: 67003e10... structural advantages</text>
<text x="78" y="274" font-family="Arial, sans-serif" font-size="14" fill="#475569">Claim D: e6ce4e36... mechanism not telos</text>
<text x="78" y="314" font-family="Arial, sans-serif" font-size="14" fill="#475569">Prerequisite: production-apply-packet-mapped</text>
<rect x="470" y="126" width="358" height="230" rx="8" fill="#ecfeff" stroke="#0891b2" stroke-width="2"/>
<text x="492" y="158" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#155e75">Rio Strategy Nodes</text>
<text x="492" y="194" font-family="Arial, sans-serif" font-size="15" fill="#164e63">public.strategy_nodes</text>
<rect x="492" y="214" width="312" height="48" rx="6" fill="#ffffff" stroke="#67e8f9"/>
<text x="508" y="244" font-family="Arial, sans-serif" font-size="14" fill="#0f172a">Rio capital deployment layer</text>
<rect x="492" y="282" width="312" height="48" rx="6" fill="#ffffff" stroke="#67e8f9"/>
<text x="508" y="312" font-family="Arial, sans-serif" font-size="14" fill="#0f172a">Rio internet-finance capital product</text>
<rect x="900" y="126" width="324" height="230" 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">Shared Root</text>
<text x="922" y="194" font-family="Arial, sans-serif" font-size="15" fill="#9a3412">public.shared_root</text>
<rect x="922" y="214" width="276" height="74" rx="6" fill="#ffffff" stroke="#fdba74"/>
<text x="938" y="244" font-family="Arial, sans-serif" font-size="14" fill="#0f172a">Back</text>
<text x="938" y="268" font-family="Arial, sans-serif" font-size="13" fill="#475569">resource builders; capital gated by review</text>
<line x1="396" y1="218" x2="470" y2="238" stroke="#2563eb" stroke-width="3" marker-end="url(#arrow)"/>
<text x="402" y="205" font-family="Arial, sans-serif" font-size="13" fill="#1d4ed8">justified_by Claim A</text>
<line x1="396" y1="246" x2="470" y2="306" stroke="#2563eb" stroke-width="3" marker-end="url(#arrow)"/>
<text x="402" y="280" font-family="Arial, sans-serif" font-size="13" fill="#1d4ed8">justified_by Claim C</text>
<line x1="396" y1="274" x2="470" y2="326" stroke="#2563eb" stroke-width="3" marker-end="url(#arrow)"/>
<text x="402" y="330" font-family="Arial, sans-serif" font-size="13" fill="#1d4ed8">Claim D constrains product</text>
<line x1="804" y1="238" x2="922" y2="248" stroke="#ea580c" stroke-width="3" marker-end="url(#arrow-orange)"/>
<text x="824" y="228" font-family="Arial, sans-serif" font-size="13" fill="#c2410c">serves Back</text>
<line x1="648" y1="282" x2="648" y2="262" stroke="#0f766e" stroke-width="3" marker-end="url(#arrow-teal)"/>
<text x="666" y="276" font-family="Arial, sans-serif" font-size="13" fill="#0f766e">product serves layer</text>
<rect x="56" y="418" width="360" height="212" rx="8" fill="#fef2f2" stroke="#ef4444" stroke-width="2"/>
<text x="78" y="450" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#991b1b">Still Deferred</text>
<text x="78" y="486" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">governance_gate:quality-gate</text>
<text x="78" y="516" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">governance_gate:evidence-bar</text>
<text x="78" y="546" font-family="Arial, sans-serif" font-size="14" fill="#7f1d1d">concept_map:distributed_market_intelligence</text>
<text x="78" y="590" font-family="Arial, sans-serif" font-size="13" fill="#475569">Reason: no safe first-class edge table in live schema.</text>
<rect x="470" y="418" width="358" height="212" rx="8" fill="#f0fdf4" stroke="#16a34a" stroke-width="2"/>
<text x="492" y="450" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#166534">Disposable Clone Proof</text>
<text x="492" y="486" font-family="Arial, sans-serif" font-size="14" fill="#14532d">Clone DB: teleo_rio_strategy_rehearsal_20260710</text>
<text x="492" y="516" font-family="Arial, sans-serif" font-size="14" fill="#14532d">After apply: base claims 7, Rio nodes 2, anchors 5</text>
<text x="492" y="546" font-family="Arial, sans-serif" font-size="14" fill="#14532d">After rollback: base claims 0, Rio nodes 0, anchors 0</text>
<text x="492" y="590" font-family="Arial, sans-serif" font-size="13" fill="#475569">Production generated rows stayed 0/0/0.</text>
<rect x="900" y="418" width="324" height="212" rx="8" fill="#eef2ff" stroke="#4f46e5" stroke-width="2"/>
<text x="922" y="450" font-family="Arial, sans-serif" font-size="18" font-weight="700" fill="#3730a3">Runtime Boundary</text>
<text x="922" y="486" font-family="Arial, sans-serif" font-size="14" fill="#312e81">No production commit executed.</text>
<text x="922" y="516" font-family="Arial, sans-serif" font-size="14" fill="#312e81">No live VPS Leo behavior changed.</text>
<text x="922" y="546" font-family="Arial, sans-serif" font-size="14" fill="#312e81">leoclean-gateway active, NRestarts=0.</text>
<text x="922" y="590" font-family="Arial, sans-serif" font-size="13" fill="#475569">Packet is ready for separate apply authorization.</text>
<text x="56" y="702" font-family="Arial, sans-serif" font-size="14" fill="#475569">Canonical tables named in packet: public.strategy_nodes, public.strategy_node_anchors, public.claims, public.shared_root. Staging/proposals remain in kb_stage.kb_proposals.</text>
<defs>
<marker id="arrow" 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>
<marker id="arrow-teal" markerWidth="10" markerHeight="10" refX="7" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L8,3 z" fill="#0f766e"/>
</marker>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -0,0 +1,84 @@
\set ON_ERROR_STOP on
begin;
do $$
declare
inserted_nodes int;
inserted_anchors int;
begin
if not exists (
select 1 from public.agents where id = '22222222-2222-2222-2222-222222222222'::uuid and handle = 'rio'
) then
raise exception 'Rio strategy packet requires rio agent % to exist', '22222222-2222-2222-2222-222222222222';
end if;
if (
select count(*) from public.claims where id in (select id from (values
('004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid),
('67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid),
('e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid)
) as v(id))
) <> 3 then
raise exception 'Rio strategy packet requires mapped base claims A/C/D to exist before strategy context insert';
end if;
if not exists (select 1 from public.shared_root where id = '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid) then
raise exception 'Rio strategy packet requires Back shared root % to exist', '6248818e-fe16-4d3b-8008-ef9752b80632';
end if;
if exists (select 1 from public.strategy_nodes where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id))) then
raise exception 'Rio strategy packet generated strategy node id already exists';
end if;
if exists (select 1 from public.strategy_node_anchors where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id))) then
raise exception 'Rio strategy packet generated strategy anchor id already exists';
end if;
if exists (
select 1
from public.strategy_nodes
where agent_id = '22222222-2222-2222-2222-222222222222'::uuid
and title in (
'Rio capital deployment layer',
'Rio internet-finance capital product'
)
) then
raise exception 'Rio strategy packet refuses to create duplicate exact Rio strategy title';
end if;
insert into public.strategy_nodes
(id, agent_id, node_type, title, body, rank, status, horizon, measure, source_ref, metadata)
values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, '22222222-2222-2222-2222-222222222222'::uuid, 'policy', 'Rio capital deployment layer', 'Rio treats capital allocation as a civilizational steering layer: resources should back builders through review-gated, market-aware mechanisms that serve Teleo''s Back function.', 1, 'active', 'current strategy context', 'Capital-deployment analysis can name the claim evidence, review boundary, and Back shared root it serves before recommending resource allocation.', 'mapped-rich-proposal-14fa5ecc:rio-capital-deployment-layer', '{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer", "capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors"]}'::jsonb),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, '22222222-2222-2222-2222-222222222222'::uuid, 'objective', 'Rio internet-finance capital product', 'Rio may evaluate internet-finance mechanisms as capital-product candidates, but only as instrumental mechanisms. The product must stay subordinate to Teleo''s capital-allocation telos and cannot become the telos itself.', 2, 'active', 'current strategy context', 'Any internet-finance product thesis states its structural advantages, its mechanism-not-telos boundary, and how it serves the capital deployment layer.', 'mapped-rich-proposal-14fa5ecc:rio-active-strategy-v1-internet-finance-capital-product', '{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product", "internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product"]}'::jsonb);
get diagnostics inserted_nodes = row_count;
if inserted_nodes <> 2 then
raise exception 'Rio strategy packet inserted % strategy node row(s), expected 2', inserted_nodes;
end if;
insert into public.strategy_node_anchors
(id, from_node_id, anchor_role, to_node_id, to_shared_root_id, belief_id, claim_id, source_id, weight, note)
values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid, '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, '004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid, null::uuid, 0.85, 'Mapped proposal 14fa5ecc: Claim A justifies the Rio capital deployment layer because capital allocation steers which futures receive resources.'),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid, '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, 'serves', null::uuid, '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid, null::uuid, null::uuid, null::uuid, 0.8, 'Maps the fund-build / better-attractors fragment to the existing Back shared root instead of forcing it into public.claim_edges.'),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, '67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid, null::uuid, 0.7, 'Mapped proposal 14fa5ecc: the internet-finance capital product is justified by the structural-advantages claim, not by the old compressed claim.'),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, 'e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid, null::uuid, 0.85, 'Represents the proposal''s constrains fragment within the current anchor-role enum: internet finance is a candidate mechanism, not Teleo''s telos.'),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'serves', '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, null::uuid, null::uuid, null::uuid, null::uuid, 0.75, 'The internet-finance product objective serves Rio''s capital deployment layer rather than standing as a standalone telos.');
get diagnostics inserted_anchors = row_count;
if inserted_anchors <> 5 then
raise exception 'Rio strategy packet inserted % strategy anchor row(s), expected 5', inserted_anchors;
end if;
end $$;
commit;

View file

@ -0,0 +1,84 @@
\set ON_ERROR_STOP on
begin;
do $$
declare
inserted_nodes int;
inserted_anchors int;
begin
if not exists (
select 1 from public.agents where id = '22222222-2222-2222-2222-222222222222'::uuid and handle = 'rio'
) then
raise exception 'Rio strategy packet requires rio agent % to exist', '22222222-2222-2222-2222-222222222222';
end if;
if (
select count(*) from public.claims where id in (select id from (values
('004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid),
('67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid),
('e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid)
) as v(id))
) <> 3 then
raise exception 'Rio strategy packet requires mapped base claims A/C/D to exist before strategy context insert';
end if;
if not exists (select 1 from public.shared_root where id = '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid) then
raise exception 'Rio strategy packet requires Back shared root % to exist', '6248818e-fe16-4d3b-8008-ef9752b80632';
end if;
if exists (select 1 from public.strategy_nodes where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id))) then
raise exception 'Rio strategy packet generated strategy node id already exists';
end if;
if exists (select 1 from public.strategy_node_anchors where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id))) then
raise exception 'Rio strategy packet generated strategy anchor id already exists';
end if;
if exists (
select 1
from public.strategy_nodes
where agent_id = '22222222-2222-2222-2222-222222222222'::uuid
and title in (
'Rio capital deployment layer',
'Rio internet-finance capital product'
)
) then
raise exception 'Rio strategy packet refuses to create duplicate exact Rio strategy title';
end if;
insert into public.strategy_nodes
(id, agent_id, node_type, title, body, rank, status, horizon, measure, source_ref, metadata)
values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, '22222222-2222-2222-2222-222222222222'::uuid, 'policy', 'Rio capital deployment layer', 'Rio treats capital allocation as a civilizational steering layer: resources should back builders through review-gated, market-aware mechanisms that serve Teleo''s Back function.', 1, 'active', 'current strategy context', 'Capital-deployment analysis can name the claim evidence, review boundary, and Back shared root it serves before recommending resource allocation.', 'mapped-rich-proposal-14fa5ecc:rio-capital-deployment-layer', '{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer", "capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors"]}'::jsonb),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, '22222222-2222-2222-2222-222222222222'::uuid, 'objective', 'Rio internet-finance capital product', 'Rio may evaluate internet-finance mechanisms as capital-product candidates, but only as instrumental mechanisms. The product must stay subordinate to Teleo''s capital-allocation telos and cannot become the telos itself.', 2, 'active', 'current strategy context', 'Any internet-finance product thesis states its structural advantages, its mechanism-not-telos boundary, and how it serves the capital deployment layer.', 'mapped-rich-proposal-14fa5ecc:rio-active-strategy-v1-internet-finance-capital-product', '{"base_packet_required_first": "production-apply-packet-mapped-20260709", "proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product", "internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product"]}'::jsonb);
get diagnostics inserted_nodes = row_count;
if inserted_nodes <> 2 then
raise exception 'Rio strategy packet inserted % strategy node row(s), expected 2', inserted_nodes;
end if;
insert into public.strategy_node_anchors
(id, from_node_id, anchor_role, to_node_id, to_shared_root_id, belief_id, claim_id, source_id, weight, note)
values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid, '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, '004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid, null::uuid, 0.85, 'Mapped proposal 14fa5ecc: Claim A justifies the Rio capital deployment layer because capital allocation steers which futures receive resources.'),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid, '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, 'serves', null::uuid, '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid, null::uuid, null::uuid, null::uuid, 0.8, 'Maps the fund-build / better-attractors fragment to the existing Back shared root instead of forcing it into public.claim_edges.'),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, '67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid, null::uuid, 0.7, 'Mapped proposal 14fa5ecc: the internet-finance capital product is justified by the structural-advantages claim, not by the old compressed claim.'),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'justified_by', null::uuid, null::uuid, null::uuid, 'e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid, null::uuid, 0.85, 'Represents the proposal''s constrains fragment within the current anchor-role enum: internet finance is a candidate mechanism, not Teleo''s telos.'),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid, '063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid, 'serves', '4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid, null::uuid, null::uuid, null::uuid, null::uuid, 0.75, 'The internet-finance product objective serves Rio''s capital deployment layer rather than standing as a standalone telos.');
get diagnostics inserted_anchors = row_count;
if inserted_anchors <> 5 then
raise exception 'Rio strategy packet inserted % strategy anchor row(s), expected 5', inserted_anchors;
end if;
end $$;
rollback;

View file

@ -0,0 +1,189 @@
=== service before ===
MainPID=3252143
NRestarts=0
ActiveState=active
SubState=running
=== production generated counts before ===
prod_base_claims | prod_rio_nodes | prod_rio_anchors
------------------+----------------+------------------
0 | 0 | 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_rio_nodes | clone_rio_anchors
-------------------+-----------------+-------------------
7 | 0 | 0
(1 row)
=== clone rio preflight after base apply ===
check_name | id | handle | kind
------------+--------------------------------------+--------+---------
rio_agent | 22222222-2222-2222-2222-222222222222 | rio | persona
(1 row)
check_name | id | status | text
---------------------+--------------------------------------+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------
required_base_claim | 004195cc-ab62-526c-90fb-51cb0f826ec0 | open | Capital allocation is a form of civilizational steering because it determines which futures receive resources.
required_base_claim | 67003e10-e1ee-5905-8b51-1b0cb263ec11 | open | Internet finance has structural advantages over traditional finance and is likely to become an increasingly important capital-allocation mechanism.
required_base_claim | e6ce4e36-15d2-53bc-8b74-dda0efc095c1 | open | Internet finance is not Teleos telos; it is a candidate mechanism for pursuing the telos.
(3 rows)
check_name | id | title | body
------------------+--------------------------------------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
back_shared_root | 6248818e-fe16-4d3b-8008-ef9752b80632 | Back | Back — resource the builders: advise, co-build, and at the deepest rung invest through [[agentic capital]] gated by [[decision markets]] so no individual controls the call. The collective is a credible public intelligenc
(1 row)
check_name | id | agent_id | title | status
------------+----+----------+-------+--------
(0 rows)
generated_strategy_node_rows | generated_strategy_anchor_rows
------------------------------+--------------------------------
0 | 0
(1 row)
check_name | id | name | criteria | evidence_bar
-----------------------------------+--------------------------------------+--------------+------------------------------------------------------------------------------------------------------------+-------------------------------------
governance_gate_known_not_written | 45695897-2a9c-4279-ac25-e59f166dec6a | evidence-bar | likely needs empirical data; experimental = coherent argument, limited validation; speculative = untested. | likely > experimental > speculative
governance_gate_known_not_written | fa88e31b-6fca-4801-bf72-f5db81950a11 | quality-gate | Specific enough to disagree with; evidence traceable; not a duplicate; right domain reviewers. |
(2 rows)
=== clone apply rio packet ===
BEGIN
DO
COMMIT
=== clone rio postflight after rio apply ===
generated_strategy_node_rows | generated_strategy_anchor_rows
------------------------------+--------------------------------
2 | 5
(1 row)
id | agent_id | node_type | title | rank | status | source_ref | metadata
--------------------------------------+--------------------------------------+-----------+--------------------------------------+------+--------+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4f3e3d77-50fa-520a-8c8b-5a4269d94a9b | 22222222-2222-2222-2222-222222222222 | policy | Rio capital deployment layer | 1 | active | mapped-rich-proposal-14fa5ecc:rio-capital-deployment-layer | {"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer", "capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors"], "base_packet_required_first": "production-apply-packet-mapped-20260709"}
063528a6-a07c-5c14-abdf-dc12a0b10fcf | 22222222-2222-2222-2222-222222222222 | objective | Rio internet-finance capital product | 2 | active | mapped-rich-proposal-14fa5ecc:rio-active-strategy-v1-internet-finance-capital-product | {"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617", "source_fragments": ["internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product", "internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product"], "base_packet_required_first": "production-apply-packet-mapped-20260709"}
(2 rows)
id | from_node_id | anchor_role | to_node_id | to_shared_root_id | claim_id | weight | note
--------------------------------------+--------------------------------------+--------------+--------------------------------------+--------------------------------------+--------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------
33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c | 063528a6-a07c-5c14-abdf-dc12a0b10fcf | justified_by | | | e6ce4e36-15d2-53bc-8b74-dda0efc095c1 | 0.85 | Represents the proposal's constrains fragment within the current anchor-role enum: internet finance is a candidate mechanism, not Teleo's telos.
d18eaa71-d458-53cc-baac-e5306a1779e2 | 063528a6-a07c-5c14-abdf-dc12a0b10fcf | justified_by | | | 67003e10-e1ee-5905-8b51-1b0cb263ec11 | 0.7 | Mapped proposal 14fa5ecc: the internet-finance capital product is justified by the structural-advantages claim, not by the old compressed claim.
3b2a8908-120d-59a5-bbd5-d2711a123aa3 | 063528a6-a07c-5c14-abdf-dc12a0b10fcf | serves | 4f3e3d77-50fa-520a-8c8b-5a4269d94a9b | | | 0.75 | The internet-finance product objective serves Rio's capital deployment layer rather than standing as a standalone telos.
3a0e2228-a74f-5971-b467-fb527ccdfb37 | 4f3e3d77-50fa-520a-8c8b-5a4269d94a9b | justified_by | | | 004195cc-ab62-526c-90fb-51cb0f826ec0 | 0.85 | Mapped proposal 14fa5ecc: Claim A justifies the Rio capital deployment layer because capital allocation steers which futures receive resources.
3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96 | 4f3e3d77-50fa-520a-8c8b-5a4269d94a9b | serves | | 6248818e-fe16-4d3b-8008-ef9752b80632 | | 0.8 | Maps the fund-build / better-attractors fragment to the existing Back shared root instead of forcing it into public.claim_edges.
(5 rows)
id | status | text
--------------------------------------+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------
004195cc-ab62-526c-90fb-51cb0f826ec0 | open | Capital allocation is a form of civilizational steering because it determines which futures receive resources.
67003e10-e1ee-5905-8b51-1b0cb263ec11 | open | Internet finance has structural advantages over traditional finance and is likely to become an increasingly important capital-allocation mechanism.
e6ce4e36-15d2-53bc-8b74-dda0efc095c1 | open | Internet finance is not Teleos telos; it is a candidate mechanism for pursuing the telos.
(3 rows)
id | title | body
--------------------------------------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6248818e-fe16-4d3b-8008-ef9752b80632 | Back | Back — resource the builders: advise, co-build, and at the deepest rung invest through [[agentic capital]] gated by [[decision markets]] so no individual controls the call. The collective is a credible public intelligenc
(1 row)
=== clone generated counts after rio apply ===
clone_base_claims | clone_rio_nodes | clone_rio_anchors
-------------------+-----------------+-------------------
7 | 2 | 5
(1 row)
=== clone delete rollback rio packet ===
BEGIN
DO
COMMIT
=== clone delete rollback mapped base packet ===
BEGIN
DELETE 17
DELETE 11
UPDATE 2
DELETE 15
DELETE 7
COMMIT
=== clone generated counts after rollbacks ===
clone_base_claims | clone_rio_nodes | clone_rio_anchors
-------------------+-----------------+-------------------
0 | 0 | 0
(1 row)
=== production generated counts after clone proof ===
prod_base_claims | prod_rio_nodes | prod_rio_anchors
------------------+----------------+------------------
0 | 0 | 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,72 @@
# Rio Strategy Context Packet - 2026-07-10
Generated UTC: `2026-07-10`
## Verdict
Clone-proven, not production-applied.
The mapped rich proposal packet handles canonical claim/source/evidence/claim-edge rows. The cross-surface packet handles the active Leo policy anchor to Claim D. This Rio companion packet handles the remaining Rio strategy-context fragments from proposal `14fa5ecc-ac7a-41c1-807d-a2e85b936617` by creating Rio strategy rows only after the mapped base packet exists.
## Safe Writes
- `public.strategy_nodes`: 2 rows
- `4f3e3d77-50fa-520a-8c8b-5a4269d94a9b`: `Rio capital deployment layer`
- `063528a6-a07c-5c14-abdf-dc12a0b10fcf`: `Rio internet-finance capital product`
- `public.strategy_node_anchors`: 5 rows
- capital layer justified by Claim A `004195cc-ab62-526c-90fb-51cb0f826ec0`
- capital layer serves Back shared root `6248818e-fe16-4d3b-8008-ef9752b80632`
- internet-finance product justified by Claim C `67003e10-e1ee-5905-8b51-1b0cb263ec11`
- internet-finance product justified by Claim D `e6ce4e36-15d2-53bc-8b74-dda0efc095c1`
- internet-finance product serves the capital deployment layer
## Clone Proof
Disposable database: `teleo_rio_strategy_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` claims, `15` sources, `11` claim edges, `17` claim evidence rows.
3. Ran Rio preflight:
- Rio agent row existed.
- base claims A/C/D existed.
- Back shared root existed.
- no exact Rio strategy title already existed.
- generated Rio rows were `0/0`.
4. Ran Rio authorized commit SQL in the clone.
5. Postflight read back `2` strategy nodes and `5` strategy anchors.
6. Ran Rio delete rollback.
7. Ran mapped base packet delete rollback.
8. Clone returned to `0` base claims, `0` Rio strategy nodes, and `0` Rio strategy anchors.
9. Production stayed unchanged: `0` base claims, `0` Rio strategy nodes, and `0` Rio strategy anchors.
10. 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`
## Explicit Deferrals
These approved fragments are still not safely writable through the current schema:
- `governance_gate:quality-gate`: row exists, but there is no claim-to-governance-gate edge/anchor table.
- `governance_gate:evidence-bar`: row exists, but there is no claim-to-governance-gate edge/anchor table.
- `concept_map:distributed_market_intelligence`: no first-class concept-map table exists.
## Evidence
- Packet JSON: `docs/reports/leo-working-state-20260709/rio-strategy-packet.json`
- Authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/rio-strategy-apply-authorized-commit.sql`
- Delete rollback SQL: `docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql`
- Clone rehearsal log: `docs/reports/leo-working-state-20260709/rio-strategy-clone-rehearsal-current.log`
- State image: `docs/reports/leo-working-state-20260709/leo-db-state-23-rio-strategy-context.svg`
## Claim Ceiling
This proves the Rio strategy-context companion write is schema-compatible, reversible, and safe 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,37 @@
\set ON_ERROR_STOP on
-- Emergency rollback for Rio strategy-context generated rows only.
-- Run only before later production data depends on these generated rows.
begin;
do $$
declare
deleted_anchors int;
deleted_nodes int;
begin
delete from public.strategy_node_anchors
where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id));
get diagnostics deleted_anchors = row_count;
if deleted_anchors <> 5 then
raise exception 'Rio strategy rollback deleted % strategy anchor row(s), expected 5', deleted_anchors;
end if;
delete from public.strategy_nodes
where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id));
get diagnostics deleted_nodes = row_count;
if deleted_nodes <> 2 then
raise exception 'Rio strategy rollback deleted % strategy node row(s), expected 2', deleted_nodes;
end if;
end $$;
commit;

View file

@ -0,0 +1,142 @@
{
"base_packet_required_first": "production-apply-packet-mapped-20260709",
"generated_counts": {
"strategy_node_anchors": 5,
"strategy_nodes": 2
},
"known_non_writable_targets": [
{
"existing_row_id": "fa88e31b-6fca-4801-bf72-f5db81950a11",
"reason": "Governance gate exists, but current schema has no claim-to-governance-gate edge/anchor table.",
"target": "governance_gate:quality-gate"
},
{
"existing_row_id": "45695897-2a9c-4279-ac25-e59f166dec6a",
"reason": "Governance gate exists, but current schema has no claim-to-governance-gate edge/anchor table.",
"target": "governance_gate:evidence-bar"
},
{
"existing_row_id": null,
"reason": "No first-class concept-map table exists in the current live schema.",
"target": "concept_map:distributed_market_intelligence"
}
],
"packet_version": 1,
"production_apply_status": "not_executed",
"purpose": "Companion packet for mapped rich proposal Rio strategy context.",
"represented_fragments": [
"capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer",
"capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors",
"internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos serves teleo telos through product -> capital layer -> Back shared root"
],
"required_existing_rows": {
"public.agents": [
"22222222-2222-2222-2222-222222222222"
],
"public.claims": [
"004195cc-ab62-526c-90fb-51cb0f826ec0",
"67003e10-e1ee-5905-8b51-1b0cb263ec11",
"e6ce4e36-15d2-53bc-8b74-dda0efc095c1"
],
"public.shared_root": [
"6248818e-fe16-4d3b-8008-ef9752b80632"
]
},
"safe_writes": [
{
"operation": "insert",
"rows": [
{
"agent_id": "22222222-2222-2222-2222-222222222222",
"body": "Rio treats capital allocation as a civilizational steering layer: resources should back builders through review-gated, market-aware mechanisms that serve Teleo's Back function.",
"horizon": "current strategy context",
"id": "4f3e3d77-50fa-520a-8c8b-5a4269d94a9b",
"measure": "Capital-deployment analysis can name the claim evidence, review boundary, and Back shared root it serves before recommending resource allocation.",
"metadata": {
"base_packet_required_first": "production-apply-packet-mapped-20260709",
"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617",
"source_fragments": [
"capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer",
"capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors"
]
},
"node_type": "policy",
"rank": 1,
"source_ref": "mapped-rich-proposal-14fa5ecc:rio-capital-deployment-layer",
"status": "active",
"title": "Rio capital deployment layer"
},
{
"agent_id": "22222222-2222-2222-2222-222222222222",
"body": "Rio may evaluate internet-finance mechanisms as capital-product candidates, but only as instrumental mechanisms. The product must stay subordinate to Teleo's capital-allocation telos and cannot become the telos itself.",
"horizon": "current strategy context",
"id": "063528a6-a07c-5c14-abdf-dc12a0b10fcf",
"measure": "Any internet-finance product thesis states its structural advantages, its mechanism-not-telos boundary, and how it serves the capital deployment layer.",
"metadata": {
"base_packet_required_first": "production-apply-packet-mapped-20260709",
"proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617",
"source_fragments": [
"internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product"
]
},
"node_type": "objective",
"rank": 2,
"source_ref": "mapped-rich-proposal-14fa5ecc:rio-active-strategy-v1-internet-finance-capital-product",
"status": "active",
"title": "Rio internet-finance capital product"
}
],
"table": "public.strategy_nodes"
},
{
"operation": "insert",
"rows": [
{
"anchor_role": "justified_by",
"claim_id": "004195cc-ab62-526c-90fb-51cb0f826ec0",
"from_node_id": "4f3e3d77-50fa-520a-8c8b-5a4269d94a9b",
"id": "3a0e2228-a74f-5971-b467-fb527ccdfb37",
"note": "Mapped proposal 14fa5ecc: Claim A justifies the Rio capital deployment layer because capital allocation steers which futures receive resources.",
"weight": 0.85
},
{
"anchor_role": "serves",
"from_node_id": "4f3e3d77-50fa-520a-8c8b-5a4269d94a9b",
"id": "3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96",
"note": "Maps the fund-build / better-attractors fragment to the existing Back shared root instead of forcing it into public.claim_edges.",
"to_shared_root_id": "6248818e-fe16-4d3b-8008-ef9752b80632",
"weight": 0.8
},
{
"anchor_role": "justified_by",
"claim_id": "67003e10-e1ee-5905-8b51-1b0cb263ec11",
"from_node_id": "063528a6-a07c-5c14-abdf-dc12a0b10fcf",
"id": "d18eaa71-d458-53cc-baac-e5306a1779e2",
"note": "Mapped proposal 14fa5ecc: the internet-finance capital product is justified by the structural-advantages claim, not by the old compressed claim.",
"weight": 0.7
},
{
"anchor_role": "justified_by",
"claim_id": "e6ce4e36-15d2-53bc-8b74-dda0efc095c1",
"from_node_id": "063528a6-a07c-5c14-abdf-dc12a0b10fcf",
"id": "33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c",
"note": "Represents the proposal's constrains fragment within the current anchor-role enum: internet finance is a candidate mechanism, not Teleo's telos.",
"weight": 0.85
},
{
"anchor_role": "serves",
"from_node_id": "063528a6-a07c-5c14-abdf-dc12a0b10fcf",
"id": "3b2a8908-120d-59a5-bbd5-d2711a123aa3",
"note": "The internet-finance product objective serves Rio's capital deployment layer rather than standing as a standalone telos.",
"to_node_id": "4f3e3d77-50fa-520a-8c8b-5a4269d94a9b",
"weight": 0.75
}
],
"table": "public.strategy_node_anchors"
}
],
"source_proposal_id": "14fa5ecc-ac7a-41c1-807d-a2e85b936617"
}

View file

@ -0,0 +1,62 @@
\set ON_ERROR_STOP on
-- Rio strategy-context companion postflight row-level readback.
select
(select count(*) from public.strategy_nodes where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id))) as generated_strategy_node_rows,
(select count(*) from public.strategy_node_anchors where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id))) as generated_strategy_anchor_rows;
select id::text,
agent_id::text,
node_type,
title,
rank,
status,
source_ref,
metadata::text
from public.strategy_nodes
where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id))
order by rank, title;
select id::text,
from_node_id::text,
anchor_role,
to_node_id::text,
to_shared_root_id::text,
claim_id::text,
weight,
left(note, 260) as note
from public.strategy_node_anchors
where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id))
order by from_node_id, anchor_role, id;
select id::text, status, left(text, 220) as text
from public.claims
where id in (select id from (values
('004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid),
('67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid),
('e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid)
) as v(id))
order by id;
select id::text, title, left(body, 220) as body
from public.shared_root
where id = '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid;

View file

@ -0,0 +1,66 @@
\set ON_ERROR_STOP on
-- Rio strategy-context companion preflight. Read-only.
-- Run after the mapped rich proposal packet has been applied.
select 'rio_agent' as check_name, id::text, handle, kind
from public.agents
where id = '22222222-2222-2222-2222-222222222222'::uuid;
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
('004195cc-ab62-526c-90fb-51cb0f826ec0'::uuid),
('67003e10-e1ee-5905-8b51-1b0cb263ec11'::uuid),
('e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid)
) as v(id))
order by c.id;
select 'back_shared_root' as check_name,
id::text,
title,
left(body, 220) as body
from public.shared_root
where id = '6248818e-fe16-4d3b-8008-ef9752b80632'::uuid;
select 'existing_exact_rio_strategy_title' as check_name,
id::text,
agent_id::text,
title,
status
from public.strategy_nodes
where agent_id = '22222222-2222-2222-2222-222222222222'::uuid
and title in (
'Rio capital deployment layer',
'Rio internet-finance capital product'
)
order by title;
-- Must be 0/0 before authorized apply.
select
(select count(*) from public.strategy_nodes where id in (select id from (values
('4f3e3d77-50fa-520a-8c8b-5a4269d94a9b'::uuid),
('063528a6-a07c-5c14-abdf-dc12a0b10fcf'::uuid)
) as v(id))) as generated_strategy_node_rows,
(select count(*) from public.strategy_node_anchors where id in (select id from (values
('3a0e2228-a74f-5971-b467-fb527ccdfb37'::uuid),
('3f7a9f84-eb2e-5d94-9ca4-afc3bad47f96'::uuid),
('d18eaa71-d458-53cc-baac-e5306a1779e2'::uuid),
('33d9eb08-c9c2-5e2d-a9a7-3d7f1b5f0f0c'::uuid),
('3b2a8908-120d-59a5-bbd5-d2711a123aa3'::uuid)
) as v(id))) as generated_strategy_anchor_rows;
select 'governance_gate_known_not_written' 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

@ -87,6 +87,12 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- disposable DB `teleo_cross_surface_rehearsal_20260709` applied the mapped base packet first (`7` claims, `15` sources, `11` edges, `17` evidence rows)
- companion packet then updated anchor `47f128a0-36c5-4b60-97d4-48c32fa48bc7` from old claim `d0000000-0000-0000-0000-000000000005` to Claim D `e6ce4e36-15d2-53bc-8b74-dda0efc095c1` at weight `0.85`
- cross-surface rollback restored the old anchor, base rollback returned generated rows to `0/0/0/0`, production stayed unchanged, temp files were removed, and service remained active with `MainPID=3252143`, `NRestarts=0`
- Rio strategy-context companion packet is now clone-proven:
- packet creates `2` Rio strategy nodes and `5` strategy anchors after the mapped base packet creates claims A/C/D
- disposable DB `teleo_rio_strategy_rehearsal_20260710` applied the mapped base packet first (`7` claims)
- 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`
- 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
@ -116,6 +122,8 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- Helmer 7 Powers ledger proof log: `outputs/rich-proposal-creation-plan-20260709/helmer-7powers-20260709/production-apply-packet/ledger-clone-commit-delete-rollback-current.log`
- Cross-surface strategy anchor packet: `outputs/rich-proposal-creation-plan-20260709/cross-surface-resolution-20260709/cross-surface-packet.json`
- 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`
- 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`
@ -133,11 +141,12 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
- Leoclean DB/workspace image: `outputs/leo-db-state-18-db-vs-workspace.svg`
- 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`
- 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: Rio strategy context, governance gates, and concept-map storage. The active policy-to-Claim-D strategy anchor is clone-proven but not production-applied.
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.
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, and the strategy-anchor companion write is clone-proven but not production-applied. Governance, concept-map, Rio, 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, 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.
## WL-EXEC-01 - VPS Telegram-visible memory + KB audit
- Status: `done`
@ -64,10 +64,18 @@ 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/cross-surface-resolution-20260709/cross-surface-packet.json`
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/cross-surface-resolution-20260709/cross-surface-clone-rehearsal-current.log`
## WL-EXEC-05E - Rio strategy-context companion packet
- Status: `done_packet_ready_not_executed`
- Result: Generated a companion packet for mapped proposal `14fa5ecc` that creates two Rio strategy nodes (`Rio capital deployment layer`, `Rio internet-finance capital product`) and five row-level anchors after the mapped base packet creates claims A/C/D. Disposable clone commit/readback passed: base rows were `7`, Rio strategy nodes were `2`, Rio anchors were `5`; Rio rollback plus base rollback returned clone counts to `0/0/0`; production stayed unchanged; temp files and clone were removed.
- Not done condition: Production canonical strategy rows remain unapplied until explicit production apply authorization and base mapped packet application.
- Evidence:
- `/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-packet.json`
- `/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_non_claim_target_decisions`
- Result: Edge-type mappings, one canonical capital-allocation target, and the active policy-to-Claim-D strategy anchor are clone-proven. Remaining blockers are explicit non-claim/cross-table targets: Rio strategy context, governance gates, and concept-map storage.
- Next action: Create a separate reviewed governance/concept-map/Rio storage lane before any canonical production apply of those 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.
- 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`

View file

@ -0,0 +1,532 @@
#!/usr/bin/env python3
"""Generate a Rio strategy-context companion packet for mapped KB proposals.
The mapped rich proposal packet creates the canonical claim/source/evidence and
claim-edge rows. Some remaining approved fragments target Rio strategy context,
not claim graph rows. This packet handles that surface by creating two Rio
strategy nodes and exact anchors after the mapped base packet has created the
required successor claims.
Governance-gate and concept-map fragments remain explicit deferrals because the
current live schema has no safe direct edge table for those targets.
"""
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
PROPOSAL_ID = "14fa5ecc-ac7a-41c1-807d-a2e85b936617"
BASE_PACKET_REQUIRED_FIRST = "production-apply-packet-mapped-20260709"
RIO_AGENT_ID = "22222222-2222-2222-2222-222222222222"
BACK_SHARED_ROOT_ID = "6248818e-fe16-4d3b-8008-ef9752b80632"
CLAIM_A_ID = "004195cc-ab62-526c-90fb-51cb0f826ec0"
CLAIM_C_ID = "67003e10-e1ee-5905-8b51-1b0cb263ec11"
CLAIM_D_ID = "e6ce4e36-15d2-53bc-8b74-dda0efc095c1"
QUALITY_GATE_ID = "fa88e31b-6fca-4801-bf72-f5db81950a11"
EVIDENCE_BAR_ID = "45695897-2a9c-4279-ac25-e59f166dec6a"
ID_NAMESPACE = uuid.uuid5(uuid.NAMESPACE_URL, "teleo:working-leo:rio-strategy-context")
def stable_id(key: str) -> str:
return str(uuid.uuid5(ID_NAMESPACE, key))
CAPITAL_LAYER_NODE_ID = stable_id("strategy-node:rio-capital-deployment-layer")
INTERNET_FINANCE_PRODUCT_NODE_ID = stable_id("strategy-node:rio-internet-finance-capital-product")
CAPITAL_JUSTIFIED_BY_CLAIM_A_ANCHOR_ID = stable_id("anchor:capital-layer:justified-by:claim-a")
CAPITAL_SERVES_BACK_ANCHOR_ID = stable_id("anchor:capital-layer:serves:back-shared-root")
PRODUCT_JUSTIFIED_BY_CLAIM_C_ANCHOR_ID = stable_id("anchor:internet-finance-product:justified-by:claim-c")
PRODUCT_JUSTIFIED_BY_CLAIM_D_ANCHOR_ID = stable_id("anchor:internet-finance-product:justified-by:claim-d")
PRODUCT_SERVES_CAPITAL_LAYER_ANCHOR_ID = stable_id("anchor:internet-finance-product:serves:capital-layer")
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 strategy_nodes() -> list[dict[str, Any]]:
return [
{
"id": CAPITAL_LAYER_NODE_ID,
"agent_id": RIO_AGENT_ID,
"node_type": "policy",
"title": "Rio capital deployment layer",
"body": (
"Rio treats capital allocation as a civilizational steering layer: resources should back "
"builders through review-gated, market-aware mechanisms that serve Teleo's Back function."
),
"rank": 1,
"status": "active",
"horizon": "current strategy context",
"measure": (
"Capital-deployment analysis can name the claim evidence, review boundary, and Back shared "
"root it serves before recommending resource allocation."
),
"source_ref": "mapped-rich-proposal-14fa5ecc:rio-capital-deployment-layer",
"metadata": {
"base_packet_required_first": BASE_PACKET_REQUIRED_FIRST,
"proposal_id": PROPOSAL_ID,
"source_fragments": [
"capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer",
"capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors",
],
},
},
{
"id": INTERNET_FINANCE_PRODUCT_NODE_ID,
"agent_id": RIO_AGENT_ID,
"node_type": "objective",
"title": "Rio internet-finance capital product",
"body": (
"Rio may evaluate internet-finance mechanisms as capital-product candidates, but only as "
"instrumental mechanisms. The product must stay subordinate to Teleo's capital-allocation "
"telos and cannot become the telos itself."
),
"rank": 2,
"status": "active",
"horizon": "current strategy context",
"measure": (
"Any internet-finance product thesis states its structural advantages, its mechanism-not-telos "
"boundary, and how it serves the capital deployment layer."
),
"source_ref": "mapped-rich-proposal-14fa5ecc:rio-active-strategy-v1-internet-finance-capital-product",
"metadata": {
"base_packet_required_first": BASE_PACKET_REQUIRED_FIRST,
"proposal_id": PROPOSAL_ID,
"source_fragments": [
"internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product",
],
},
},
]
def strategy_anchors() -> list[dict[str, Any]]:
return [
{
"id": CAPITAL_JUSTIFIED_BY_CLAIM_A_ANCHOR_ID,
"from_node_id": CAPITAL_LAYER_NODE_ID,
"anchor_role": "justified_by",
"claim_id": CLAIM_A_ID,
"weight": 0.85,
"note": (
"Mapped proposal 14fa5ecc: Claim A justifies the Rio capital deployment layer because "
"capital allocation steers which futures receive resources."
),
},
{
"id": CAPITAL_SERVES_BACK_ANCHOR_ID,
"from_node_id": CAPITAL_LAYER_NODE_ID,
"anchor_role": "serves",
"to_shared_root_id": BACK_SHARED_ROOT_ID,
"weight": 0.80,
"note": (
"Maps the fund-build / better-attractors fragment to the existing Back shared root instead "
"of forcing it into public.claim_edges."
),
},
{
"id": PRODUCT_JUSTIFIED_BY_CLAIM_C_ANCHOR_ID,
"from_node_id": INTERNET_FINANCE_PRODUCT_NODE_ID,
"anchor_role": "justified_by",
"claim_id": CLAIM_C_ID,
"weight": 0.70,
"note": (
"Mapped proposal 14fa5ecc: the internet-finance capital product is justified by the "
"structural-advantages claim, not by the old compressed claim."
),
},
{
"id": PRODUCT_JUSTIFIED_BY_CLAIM_D_ANCHOR_ID,
"from_node_id": INTERNET_FINANCE_PRODUCT_NODE_ID,
"anchor_role": "justified_by",
"claim_id": CLAIM_D_ID,
"weight": 0.85,
"note": (
"Represents the proposal's constrains fragment within the current anchor-role enum: "
"internet finance is a candidate mechanism, not Teleo's telos."
),
},
{
"id": PRODUCT_SERVES_CAPITAL_LAYER_ANCHOR_ID,
"from_node_id": INTERNET_FINANCE_PRODUCT_NODE_ID,
"anchor_role": "serves",
"to_node_id": CAPITAL_LAYER_NODE_ID,
"weight": 0.75,
"note": (
"The internet-finance product objective serves Rio's capital deployment layer rather than "
"standing as a standalone telos."
),
},
]
def _node_insert_values() -> str:
rows = []
for row in strategy_nodes():
rows.append(
"("
f"{_sql_literal(row['id'])}::uuid, "
f"{_sql_literal(row['agent_id'])}::uuid, "
f"{_sql_literal(row['node_type'])}, "
f"{_sql_literal(row['title'])}, "
f"{_sql_literal(row['body'])}, "
f"{row['rank']}, "
f"{_sql_literal(row['status'])}, "
f"{_sql_literal(row['horizon'])}, "
f"{_sql_literal(row['measure'])}, "
f"{_sql_literal(row['source_ref'])}, "
f"{_jsonb(row['metadata'])}"
")"
)
return ",\n ".join(rows)
def _anchor_insert_values() -> str:
rows = []
for row in strategy_anchors():
rows.append(
"("
f"{_sql_literal(row['id'])}::uuid, "
f"{_sql_literal(row['from_node_id'])}::uuid, "
f"{_sql_literal(row['anchor_role'])}, "
f"{_sql_literal(row.get('to_node_id'))}::uuid, "
f"{_sql_literal(row.get('to_shared_root_id'))}::uuid, "
f"{_sql_literal(row.get('belief_id'))}::uuid, "
f"{_sql_literal(row.get('claim_id'))}::uuid, "
f"{_sql_literal(row.get('source_id'))}::uuid, "
f"{row['weight']}, "
f"{_sql_literal(row['note'])}"
")"
)
return ",\n ".join(rows)
def build_generated_counts_sql() -> str:
node_ids = [row["id"] for row in strategy_nodes()]
anchor_ids = [row["id"] for row in strategy_anchors()]
return f"""select
(select count(*) from public.strategy_nodes where id in (select id from {_uuid_values(node_ids)})) as generated_strategy_node_rows,
(select count(*) from public.strategy_node_anchors where id in (select id from {_uuid_values(anchor_ids)})) as generated_strategy_anchor_rows;
"""
def build_preflight_sql() -> str:
required_claim_ids = [CLAIM_A_ID, CLAIM_C_ID, CLAIM_D_ID]
node_titles = ",\n ".join(_sql_literal(row["title"]) for row in strategy_nodes())
return f"""\\set ON_ERROR_STOP on
-- Rio strategy-context companion preflight. Read-only.
-- Run after the mapped rich proposal packet has been applied.
select 'rio_agent' as check_name, id::text, handle, kind
from public.agents
where id = {_sql_literal(RIO_AGENT_ID)}::uuid;
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 'back_shared_root' as check_name,
id::text,
title,
left(body, 220) as body
from public.shared_root
where id = {_sql_literal(BACK_SHARED_ROOT_ID)}::uuid;
select 'existing_exact_rio_strategy_title' as check_name,
id::text,
agent_id::text,
title,
status
from public.strategy_nodes
where agent_id = {_sql_literal(RIO_AGENT_ID)}::uuid
and title in (
{node_titles}
)
order by title;
-- Must be 0/0 before authorized apply.
{build_generated_counts_sql()}
select 'governance_gate_known_not_written' 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([QUALITY_GATE_ID, EVIDENCE_BAR_ID])})
order by name;
"""
def build_apply_sql(*, commit: bool) -> str:
terminator = "commit;" if commit else "rollback;"
required_claim_ids = [CLAIM_A_ID, CLAIM_C_ID, CLAIM_D_ID]
node_ids = [row["id"] for row in strategy_nodes()]
anchor_ids = [row["id"] for row in strategy_anchors()]
node_titles = ",\n ".join(_sql_literal(row["title"]) for row in strategy_nodes())
return f"""\\set ON_ERROR_STOP on
begin;
do $$
declare
inserted_nodes int;
inserted_anchors int;
begin
if not exists (
select 1 from public.agents where id = {_sql_literal(RIO_AGENT_ID)}::uuid and handle = 'rio'
) then
raise exception 'Rio strategy packet requires rio agent % to exist', {_sql_literal(RIO_AGENT_ID)};
end if;
if (
select count(*) from public.claims where id in (select id from {_uuid_values(required_claim_ids)})
) <> {len(required_claim_ids)} then
raise exception 'Rio strategy packet requires mapped base claims A/C/D to exist before strategy context insert';
end if;
if not exists (select 1 from public.shared_root where id = {_sql_literal(BACK_SHARED_ROOT_ID)}::uuid) then
raise exception 'Rio strategy packet requires Back shared root % to exist', {_sql_literal(BACK_SHARED_ROOT_ID)};
end if;
if exists (select 1 from public.strategy_nodes where id in (select id from {_uuid_values(node_ids)})) then
raise exception 'Rio strategy packet generated strategy node id already exists';
end if;
if exists (select 1 from public.strategy_node_anchors where id in (select id from {_uuid_values(anchor_ids)})) then
raise exception 'Rio strategy packet generated strategy anchor id already exists';
end if;
if exists (
select 1
from public.strategy_nodes
where agent_id = {_sql_literal(RIO_AGENT_ID)}::uuid
and title in (
{node_titles}
)
) then
raise exception 'Rio strategy packet refuses to create duplicate exact Rio strategy title';
end if;
insert into public.strategy_nodes
(id, agent_id, node_type, title, body, rank, status, horizon, measure, source_ref, metadata)
values
{_node_insert_values()};
get diagnostics inserted_nodes = row_count;
if inserted_nodes <> {len(node_ids)} then
raise exception 'Rio strategy packet inserted % strategy node row(s), expected {len(node_ids)}', inserted_nodes;
end if;
insert into public.strategy_node_anchors
(id, from_node_id, anchor_role, to_node_id, to_shared_root_id, belief_id, claim_id, source_id, weight, note)
values
{_anchor_insert_values()};
get diagnostics inserted_anchors = row_count;
if inserted_anchors <> {len(anchor_ids)} then
raise exception 'Rio strategy packet inserted % strategy anchor row(s), expected {len(anchor_ids)}', inserted_anchors;
end if;
end $$;
{terminator}
"""
def build_postflight_sql() -> str:
node_ids = [row["id"] for row in strategy_nodes()]
anchor_ids = [row["id"] for row in strategy_anchors()]
return f"""\\set ON_ERROR_STOP on
-- Rio strategy-context companion postflight row-level readback.
{build_generated_counts_sql()}
select id::text,
agent_id::text,
node_type,
title,
rank,
status,
source_ref,
metadata::text
from public.strategy_nodes
where id in (select id from {_uuid_values(node_ids)})
order by rank, title;
select id::text,
from_node_id::text,
anchor_role,
to_node_id::text,
to_shared_root_id::text,
claim_id::text,
weight,
left(note, 260) as note
from public.strategy_node_anchors
where id in (select id from {_uuid_values(anchor_ids)})
order by from_node_id, anchor_role, id;
select id::text, status, left(text, 220) as text
from public.claims
where id in (select id from {_uuid_values([CLAIM_A_ID, CLAIM_C_ID, CLAIM_D_ID])})
order by id;
select id::text, title, left(body, 220) as body
from public.shared_root
where id = {_sql_literal(BACK_SHARED_ROOT_ID)}::uuid;
"""
def build_delete_rollback_sql() -> str:
node_ids = [row["id"] for row in strategy_nodes()]
anchor_ids = [row["id"] for row in strategy_anchors()]
return f"""\\set ON_ERROR_STOP on
-- Emergency rollback for Rio strategy-context generated rows only.
-- Run only before later production data depends on these generated rows.
begin;
do $$
declare
deleted_anchors int;
deleted_nodes int;
begin
delete from public.strategy_node_anchors
where id in (select id from {_uuid_values(anchor_ids)});
get diagnostics deleted_anchors = row_count;
if deleted_anchors <> {len(anchor_ids)} then
raise exception 'Rio strategy rollback deleted % strategy anchor row(s), expected {len(anchor_ids)}', deleted_anchors;
end if;
delete from public.strategy_nodes
where id in (select id from {_uuid_values(node_ids)});
get diagnostics deleted_nodes = row_count;
if deleted_nodes <> {len(node_ids)} then
raise exception 'Rio strategy rollback deleted % strategy node row(s), expected {len(node_ids)}', deleted_nodes;
end if;
end $$;
commit;
"""
def build_packet() -> dict[str, Any]:
return {
"packet_version": 1,
"purpose": "Companion packet for mapped rich proposal Rio strategy context.",
"production_apply_status": "not_executed",
"base_packet_required_first": BASE_PACKET_REQUIRED_FIRST,
"source_proposal_id": PROPOSAL_ID,
"generated_counts": {
"strategy_nodes": len(strategy_nodes()),
"strategy_node_anchors": len(strategy_anchors()),
},
"safe_writes": [
{
"table": "public.strategy_nodes",
"operation": "insert",
"rows": strategy_nodes(),
},
{
"table": "public.strategy_node_anchors",
"operation": "insert",
"rows": strategy_anchors(),
},
],
"required_existing_rows": {
"public.agents": [RIO_AGENT_ID],
"public.claims": [CLAIM_A_ID, CLAIM_C_ID, CLAIM_D_ID],
"public.shared_root": [BACK_SHARED_ROOT_ID],
},
"represented_fragments": [
"capital_allocation_is_civilizational_steering supports rio:capital-deployment-layer",
"capital_allocation_is_civilizational_steering relates teleo telos / fund-build paths toward better attractors",
"internet_finance_structural_advantages_capital_allocation relates rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos constrains rio:active strategy v1 / internet-finance capital product",
"internet_finance_is_mechanism_not_telos serves teleo telos through product -> capital layer -> Back shared root",
],
"known_non_writable_targets": [
{
"target": "governance_gate:quality-gate",
"existing_row_id": QUALITY_GATE_ID,
"reason": "Governance gate exists, but current schema has no claim-to-governance-gate edge/anchor table.",
},
{
"target": "governance_gate:evidence-bar",
"existing_row_id": EVIDENCE_BAR_ID,
"reason": "Governance gate exists, but current schema has no claim-to-governance-gate edge/anchor table.",
},
{
"target": "concept_map:distributed_market_intelligence",
"existing_row_id": None,
"reason": "No first-class concept-map table exists in the current live schema.",
},
],
"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 / "rio-strategy-preflight.sql").write_text(sql["preflight"], encoding="utf-8")
(output_dir / "rio-strategy-apply-rollback-rehearsal.sql").write_text(
sql["apply_rollback_rehearsal"], encoding="utf-8"
)
(output_dir / "rio-strategy-apply-authorized-commit.sql").write_text(sql["apply_commit"], encoding="utf-8")
(output_dir / "rio-strategy-postflight.sql").write_text(sql["postflight"], encoding="utf-8")
(output_dir / "rio-strategy-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 / "rio-strategy-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,94 @@
"""Tests for scripts/kb_rio_strategy_context_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_rio_strategy_context_packet as packet # noqa: E402
def test_stable_ids_are_deterministic():
assert packet.stable_id("strategy-node:rio-capital-deployment-layer") == packet.CAPITAL_LAYER_NODE_ID
assert (
packet.stable_id("strategy-node:rio-internet-finance-capital-product")
== packet.INTERNET_FINANCE_PRODUCT_NODE_ID
)
assert packet.CAPITAL_LAYER_NODE_ID != packet.INTERNET_FINANCE_PRODUCT_NODE_ID
def test_packet_declares_rio_nodes_and_anchors_only():
result = packet.build_packet()
assert result["base_packet_required_first"] == "production-apply-packet-mapped-20260709"
assert result["production_apply_status"] == "not_executed"
assert result["generated_counts"] == {"strategy_node_anchors": 5, "strategy_nodes": 2}
assert result["required_existing_rows"] == {
"public.agents": [packet.RIO_AGENT_ID],
"public.claims": [packet.CLAIM_A_ID, packet.CLAIM_C_ID, packet.CLAIM_D_ID],
"public.shared_root": [packet.BACK_SHARED_ROOT_ID],
}
writes = {item["table"]: item for item in result["safe_writes"]}
assert set(writes) == {"public.strategy_node_anchors", "public.strategy_nodes"}
assert len(writes["public.strategy_nodes"]["rows"]) == 2
assert len(writes["public.strategy_node_anchors"]["rows"]) == 5
targets = {item["target"]: item for item in result["known_non_writable_targets"]}
assert targets["governance_gate:quality-gate"]["existing_row_id"] == packet.QUALITY_GATE_ID
assert targets["governance_gate:evidence-bar"]["existing_row_id"] == packet.EVIDENCE_BAR_ID
assert targets["concept_map:distributed_market_intelligence"]["existing_row_id"] is None
def test_anchor_contract_represents_rio_strategy_fragments():
anchors = {row["id"]: row for row in packet.strategy_anchors()}
assert anchors[packet.CAPITAL_JUSTIFIED_BY_CLAIM_A_ANCHOR_ID]["claim_id"] == packet.CLAIM_A_ID
assert anchors[packet.CAPITAL_SERVES_BACK_ANCHOR_ID]["to_shared_root_id"] == packet.BACK_SHARED_ROOT_ID
assert anchors[packet.PRODUCT_JUSTIFIED_BY_CLAIM_C_ANCHOR_ID]["claim_id"] == packet.CLAIM_C_ID
assert anchors[packet.PRODUCT_JUSTIFIED_BY_CLAIM_D_ANCHOR_ID]["claim_id"] == packet.CLAIM_D_ID
assert anchors[packet.PRODUCT_SERVES_CAPITAL_LAYER_ANCHOR_ID]["to_node_id"] == packet.CAPITAL_LAYER_NODE_ID
assert all(row["anchor_role"] in {"justified_by", "serves"} for row in anchors.values())
def test_apply_sql_is_guarded_on_base_rows_duplicates_and_counts():
sql = packet.build_packet()["sql"]["apply_commit"]
assert "requires mapped base claims A/C/D" in sql
assert f"id = '{packet.RIO_AGENT_ID}'::uuid and handle = 'rio'" in sql
assert f"where id = '{packet.BACK_SHARED_ROOT_ID}'::uuid" in sql
assert "generated strategy node id already exists" in sql
assert "generated strategy anchor id already exists" in sql
assert "duplicate exact Rio strategy title" in sql
assert "expected 2" in sql
assert "expected 5" in sql
assert sql.strip().endswith("commit;")
def test_rollback_sql_deletes_anchors_before_nodes_and_guards_counts():
sql = packet.build_packet()["sql"]["delete_rollback"]
anchor_delete = sql.index("delete from public.strategy_node_anchors")
node_delete = sql.index("delete from public.strategy_nodes")
assert anchor_delete < node_delete
assert "expected 5" in sql
assert "expected 2" in sql
assert sql.strip().endswith("commit;")
def test_write_packet_files(tmp_path: Path):
result = packet.build_packet()
packet.write_packet_files(result, tmp_path)
expected = {
"rio-strategy-apply-authorized-commit.sql",
"rio-strategy-apply-rollback-rehearsal.sql",
"rio-strategy-delete-rollback.sql",
"rio-strategy-packet.json",
"rio-strategy-postflight.sql",
"rio-strategy-preflight.sql",
}
assert {path.name for path in tmp_path.iterdir()} == expected
summary = json.loads((tmp_path / "rio-strategy-packet.json").read_text())
assert "sql" not in summary
assert summary["production_apply_status"] == "not_executed"
assert summary["generated_counts"]["strategy_nodes"] == 2