diff --git a/docs/reports/leo-working-state-20260709/current-truth-index.md b/docs/reports/leo-working-state-20260709/current-truth-index.md index 92eb5ea..f352052 100644 --- a/docs/reports/leo-working-state-20260709/current-truth-index.md +++ b/docs/reports/leo-working-state-20260709/current-truth-index.md @@ -32,8 +32,12 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c - Mapped production apply packet, not executed in production: `docs/reports/leo-working-state-20260709/production-apply-packet-current.md` - 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` +- Helmer 7 Powers authorized commit SQL, not executed in production: `docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql` +- Helmer 7 Powers delete rollback SQL: `docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql` - Helmer live rollback log: `docs/reports/leo-working-state-20260709/helmer-7powers-live-preflight-rollback-current.log` - Helmer clone commit/delete rollback log: `docs/reports/leo-working-state-20260709/helmer-7powers-clone-commit-delete-rollback-current.log` +- Helmer ledger clone commit/delete rollback log: `docs/reports/leo-working-state-20260709/helmer-7powers-ledger-clone-commit-delete-rollback-current.log` ## GCP @@ -44,12 +48,14 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c - Skill-pack map: `docs/reports/leo-working-state-20260709/leo-db-state-13-skill-pack.svg` - Helmer packet proof: `docs/reports/leo-working-state-20260709/leo-db-state-14-helmer-packet.svg` - Open-ended Cory-style canary map: `docs/reports/leo-working-state-20260709/leo-db-state-15-open-ended-canary.svg` +- Helmer ledger packet proof: `docs/reports/leo-working-state-20260709/leo-db-state-16-helmer-ledger.svg` ## Current Claim Ceiling - VPS Leo Telegram memory, KB audit, and staged-write canaries are live-proven. - VPS Leo open-ended Cory-style triage is live-proven for a read-only vague incident prompt. - A strict canonical `add_edge` apply canary is live-proven. -- Rich approved proposal packets are clone/rehearsal-proven, not production-applied. +- 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 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. diff --git a/docs/reports/leo-working-state-20260709/helmer-7powers-ledger-clone-commit-delete-rollback-current.log b/docs/reports/leo-working-state-20260709/helmer-7powers-ledger-clone-commit-delete-rollback-current.log new file mode 100644 index 0000000..e27d631 --- /dev/null +++ b/docs/reports/leo-working-state-20260709/helmer-7powers-ledger-clone-commit-delete-rollback-current.log @@ -0,0 +1,319 @@ +== production preflight before rollback rehearsal == + id | status | proposal_type | reviewed_by_handle | reviewed_at +--------------------------------------+----------+-----------------+--------------------+------------------------------- + a64df080-8502-42e2-98f4-9bbdecb8da73 | approved | attach_evidence | m3taversal | 2026-06-29 16:32:39.431004+00 +(1 row) + + check_name | id | reason +------------+----+-------- +(0 rows) + + expected_reasoning_tools | expected_claims | expected_sources | expected_claim_edges | expected_claim_evidence +--------------------------+-----------------+------------------+----------------------+------------------------- + 1 | 5 | 13 | 7 | 17 +(1 row) + + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 0 | 0 | 0 | 0 | 0 +(1 row) + +== production rollback-only rehearsal == +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 +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 +ROLLBACK +BEGIN +DO +ROLLBACK +== production preflight after rollback rehearsal == + id | status | proposal_type | reviewed_by_handle | reviewed_at +--------------------------------------+----------+-----------------+--------------------+------------------------------- + a64df080-8502-42e2-98f4-9bbdecb8da73 | approved | attach_evidence | m3taversal | 2026-06-29 16:32:39.431004+00 +(1 row) + + check_name | id | reason +------------+----+-------- +(0 rows) + + expected_reasoning_tools | expected_claims | expected_sources | expected_claim_edges | expected_claim_evidence +--------------------------+-----------------+------------------+----------------------+------------------------- + 1 | 5 | 13 | 7 | 17 +(1 row) + + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 0 | 0 | 0 | 0 | 0 +(1 row) + +== create disposable clone == + set_config +------------ + +(1 row) + +== clone preflight before commit == + id | status | proposal_type | reviewed_by_handle | reviewed_at +--------------------------------------+----------+-----------------+--------------------+------------------------------- + a64df080-8502-42e2-98f4-9bbdecb8da73 | approved | attach_evidence | m3taversal | 2026-06-29 16:32:39.431004+00 +(1 row) + + check_name | id | reason +------------+----+-------- +(0 rows) + + expected_reasoning_tools | expected_claims | expected_sources | expected_claim_edges | expected_claim_evidence +--------------------------+-----------------+------------------+----------------------+------------------------- + 1 | 5 | 13 | 7 | 17 +(1 row) + + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 0 | 0 | 0 | 0 | 0 +(1 row) + +== clone authorized commit rehearsal == +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 +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 +DO +COMMIT +== clone postflight after commit == + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 1 | 5 | 13 | 7 | 17 +(1 row) + + id | agent_id | name | category | description +--------------------------------------+--------------------------------------+-----------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 473ba7b0-ce44-5e77-bc46-ef82a49b6a3e | 11111111-1111-1111-1111-111111111111 | Helmer 7 Powers | strategy_framework | {"approval_change_log": [{"change": "Removed proposed claim #6 / teleo_power_candidate_is_credibility_and_process_not_control from this framework proposal.", "rationale": "It applies 7 Powers downstream to Teleo self-positioning; approving the framework should not accidentally approve Teleo-as-network-economies / Teleo-as-process-power claims."}, {"change": "Added competitive advantage / moats conceptual-neighborhood links for resolution.", "rationale": "7 Powers should sit in the competitive ad +(1 row) + + id | type | confidence | text +--------------------------------------+------------+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 12d2c4aa-1c23-5173-b666-dea903dd7432 | normative | 0.65 | Leo should use 7 Powers after inflection mapping and attractor-state analysis to distinguish builders who merely benefit from a wave from builders who can durably capture and compound value from that wave. + 23927224-0d72-5b37-a600-33c63277f6a9 | structural | 0.8 | Helmer's 7 Powers framework diagnoses durable value capture only when a company has both a material benefit and a barrier that prevents motivated capable competitors from arbitraging that benefit away. + 4701f303-ca9c-5da1-aa48-8cf28189c23c | structural | 0.7 | Power must be analyzed by lifecycle stage because different powers become available in Origination, Take-Off, and Stability, and the window to establish a power can close as market flux resolves. + 6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3 | structural | 0.7 | Network effects create product value but do not become network economies power unless they also prevent competitors from reaching equivalence and let the focal actor capture surplus. + d2b2142b-c2d8-5e33-9a38-14598d94d715 | structural | 0.75 | Counter-positioning is most useful near inflection points because entrants can adopt a superior model while incumbents rationally delay imitation to avoid damaging their existing economics, channels, or identity. +(5 rows) + + id | source_type | excerpt +--------------------------------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + 02b8c5ff-04fb-54e7-b132-e731086f1436 | other | {"excerpt": "Canonical source for the seven powers framework; source of definitions, benefit/barrier logic, Power Progression, and company examples. Full text not ingested in this run; use book/page references if availab + 0c87a244-afa2-5d08-8e79-9cb792aff553 | other | {"body": null, "candidate_review_note": null, "claim_key": "agentic_capital_needs_power_analysis", "edges": [{"edge_type": "supports", "rationale": "7 Powers operationalizes scarcity/value-capture analysis for builder ev + 11fa942d-e81a-5142-965d-3c60714a7dca | other | {"body": null, "candidate_review_note": null, "claim_key": "counter_positioning_is_early_inflection_power", "edges": [{"edge_type": "relates", "rationale": "Counter-positioning exploits path dependence and incumbent comm + 263f423e-c16f-544c-ae5f-3e370e736e12 | other | {"body": null, "candidate_review_note": null, "claim_key": "network_effects_do_not_equal_network_power", "edges": [{"edge_type": "relates", "rationale": "Commercial network effects can be self-enforcing only when they al + 2df4bb44-4853-5455-8049-6dbb8685523b | transcript | {"excerpt": "Chenyi Shi frames platform power through three questions: how economic value is created, how each customer group perceives value as the platform scales, and how competitors are prevented from reaching equiva + 4bd41552-8017-551a-84b5-19b0107c20b5 | article | {"excerpt": "Helmer develops from first principles a practical theory of Strategy rooted in the notion of Power, those conditions which create the potential for persistent differential returns. The synopsis says inventio + 50e0d1ef-322b-5097-afe6-c9aa5ecea5fc | article | {"excerpt": "Episode summary asks what keeps competition away and states Helmer's framework reveals conditions for persistent and durable differential returns.", "metadata": {"source_key": "nfx_podcast_summary", "title": + 5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc | other | {"body": null, "candidate_review_note": null, "claim_key": "seven_powers_requires_benefit_and_barrier", "edges": [{"edge_type": "supports", "rationale": "Benefit/barrier is a precise isolating-mechanism test.", "to_exist + 621bb834-6366-5940-b6c3-c5f82ba35d48 | article | {"excerpt": "Show notes emphasize 'all strategy begins with invention,' transition from startup to pricer with scale economies, competition, brand definition, and sustainable leverage/power.", "metadata": {"source_key": + 6fe15936-d5b9-514e-802f-32a2a06f4a23 | article | {"excerpt": "NFX/Helmer provides concise definitions and examples for the powers: cornered resource (Pixar), scale economies (Netflix), switching costs (SAP), counter-positioning (Twilio/Tesla/Netflix), brand (Apple/Herm + 97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11 | other | {"body": null, "candidate_review_note": null, "claim_key": "power_progression_stage_gates_strategy", "edges": [{"edge_type": "relates", "rationale": "Stage-specific power creation supports strategy-as-design rather than + bc081b04-709f-565a-af0b-95d4ca0589fa | article | {"excerpt": "Hastings describes Helmer's Power Dynamics assessment of Netflix, identifies Counter-Positioning and Power Progression as novel conceptual advances, and says Counter-Positioning explained why incumbents rati + dc1c238c-f835-5641-980a-f0fe53f8dfe5 | transcript | {"excerpt": "Helmer states power has two necessary and sufficient conditions: benefit and barrier. Benefit is a materially better business model; barrier prevents motivated and capable competitors from taking it away. He +(13 rows) + + from_claim | to_claim | edge_type +--------------------------------------+--------------------------------------+----------- + 12d2c4aa-1c23-5173-b666-dea903dd7432 | 2ef388ab-4102-4416-a6e1-ae6ba8ee02fa | supports + 12d2c4aa-1c23-5173-b666-dea903dd7432 | 8f3e773e-4255-47a7-ba8f-61c57a43bebe | supports + 23927224-0d72-5b37-a600-33c63277f6a9 | 2ef388ab-4102-4416-a6e1-ae6ba8ee02fa | relates + 23927224-0d72-5b37-a600-33c63277f6a9 | 8f3e773e-4255-47a7-ba8f-61c57a43bebe | supports + 4701f303-ca9c-5da1-aa48-8cf28189c23c | 25a350e0-ebce-4072-8f2a-48427a727553 | relates + 6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3 | 93d583d9-5394-4e6a-97ca-bcd48796d94a | relates + d2b2142b-c2d8-5e33-9a38-14598d94d715 | be59b559-de8b-4dec-a7be-773188c0e632 | relates +(7 rows) + + claim_id | source_id | role +--------------------------------------+--------------------------------------+------------- + 12d2c4aa-1c23-5173-b666-dea903dd7432 | 0c87a244-afa2-5d08-8e79-9cb792aff553 | illustrates + 12d2c4aa-1c23-5173-b666-dea903dd7432 | 4bd41552-8017-551a-84b5-19b0107c20b5 | grounds + 12d2c4aa-1c23-5173-b666-dea903dd7432 | dc1c238c-f835-5641-980a-f0fe53f8dfe5 | grounds + 23927224-0d72-5b37-a600-33c63277f6a9 | 5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc | illustrates + 23927224-0d72-5b37-a600-33c63277f6a9 | 6fe15936-d5b9-514e-802f-32a2a06f4a23 | grounds + 23927224-0d72-5b37-a600-33c63277f6a9 | dc1c238c-f835-5641-980a-f0fe53f8dfe5 | grounds + 4701f303-ca9c-5da1-aa48-8cf28189c23c | 4bd41552-8017-551a-84b5-19b0107c20b5 | grounds + 4701f303-ca9c-5da1-aa48-8cf28189c23c | 97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11 | illustrates + 4701f303-ca9c-5da1-aa48-8cf28189c23c | bc081b04-709f-565a-af0b-95d4ca0589fa | grounds + 4701f303-ca9c-5da1-aa48-8cf28189c23c | dc1c238c-f835-5641-980a-f0fe53f8dfe5 | grounds + 6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3 | 263f423e-c16f-544c-ae5f-3e370e736e12 | illustrates + 6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3 | 2df4bb44-4853-5455-8049-6dbb8685523b | grounds + 6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3 | 6fe15936-d5b9-514e-802f-32a2a06f4a23 | grounds + d2b2142b-c2d8-5e33-9a38-14598d94d715 | 11fa942d-e81a-5142-965d-3c60714a7dca | illustrates + d2b2142b-c2d8-5e33-9a38-14598d94d715 | 6fe15936-d5b9-514e-802f-32a2a06f4a23 | grounds + d2b2142b-c2d8-5e33-9a38-14598d94d715 | bc081b04-709f-565a-af0b-95d4ca0589fa | grounds + d2b2142b-c2d8-5e33-9a38-14598d94d715 | dc1c238c-f835-5641-980a-f0fe53f8dfe5 | grounds +(17 rows) + + id | superseded_by +----+--------------- +(0 rows) + + id | status | applied_by_handle | applied_at +--------------------------------------+---------+-----------------------+------------------------------- + a64df080-8502-42e2-98f4-9bbdecb8da73 | applied | codex-packet-20260709 | 2026-07-09 21:14:11.331665+00 +(1 row) + +== clone delete rollback including proposal status restore == +BEGIN +DELETE 17 +DELETE 7 +UPDATE 0 +DELETE 13 +DELETE 5 +DELETE 1 +DO +COMMIT +== clone postflight after delete rollback == + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 0 | 0 | 0 | 0 | 0 +(1 row) + + id | agent_id | name | category | description +----+----------+------+----------+------------- +(0 rows) + + id | type | confidence | text +----+------+------------+------ +(0 rows) + + id | source_type | excerpt +----+-------------+--------- +(0 rows) + + from_claim | to_claim | edge_type +------------+----------+----------- +(0 rows) + + claim_id | source_id | role +----------+-----------+------ +(0 rows) + + id | superseded_by +----+--------------- +(0 rows) + + id | status | applied_by_handle | applied_at +--------------------------------------+----------+-------------------+------------ + a64df080-8502-42e2-98f4-9bbdecb8da73 | approved | | +(1 row) + +== production preflight after clone rehearsal == + id | status | proposal_type | reviewed_by_handle | reviewed_at +--------------------------------------+----------+-----------------+--------------------+------------------------------- + a64df080-8502-42e2-98f4-9bbdecb8da73 | approved | attach_evidence | m3taversal | 2026-06-29 16:32:39.431004+00 +(1 row) + + check_name | id | reason +------------+----+-------- +(0 rows) + + expected_reasoning_tools | expected_claims | expected_sources | expected_claim_edges | expected_claim_evidence +--------------------------+-----------------+------------------+----------------------+------------------------- + 1 | 5 | 13 | 7 | 17 +(1 row) + + generated_reasoning_tool_rows | generated_claim_rows | generated_source_rows | generated_edge_rows | generated_evidence_rows +-------------------------------+----------------------+-----------------------+---------------------+------------------------- + 0 | 0 | 0 | 0 | 0 +(1 row) + +== cleanup disposable clone == +0 +== service stability == +3252143 +0 +Thu 2026-07-09 06:59:44 UTC +/home/teleo +teleo +active +running diff --git a/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql new file mode 100644 index 0000000..28797b6 --- /dev/null +++ b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql @@ -0,0 +1,361 @@ +begin; + +set local statement_timeout = '30s'; + +-- rollback-only rehearsal: do not replace ROLLBACK with COMMIT without separate review + +insert into public.reasoning_tools (id, agent_id, name, description, category) +select '473ba7b0-ce44-5e77-bc46-ef82a49b6a3e'::uuid, '11111111-1111-1111-1111-111111111111'::uuid, + 'Helmer 7 Powers', '{"approval_change_log": [{"change": "Removed proposed claim #6 / teleo_power_candidate_is_credibility_and_process_not_control from this framework proposal.", "rationale": "It applies 7 Powers downstream to Teleo self-positioning; approving the framework should not accidentally approve Teleo-as-network-economies / Teleo-as-process-power claims."}, {"change": "Added competitive advantage / moats conceptual-neighborhood links for resolution.", "rationale": "7 Powers should sit in the competitive advantage and moats domain map/theme, not only link to specific scarcity and isolating-mechanism claims."}], "conceptual_neighborhood": {"additional_moat_neighborhood_candidates": [{"claim_id": "ee16149e-5e79-4a1d-9f1a-7a82fe78988c", "edge_type": "relates", "rationale": "Shares moat/competitive-advantage domain map language and can help Leo analyze moat decay under inflections.", "text": "two-phase disruption where distribution moats fall first and creation moats fall second is a universal pattern across entertainment knowledge work and financial services"}, {"claim_id": "4ec557f0-7c6e-4bb5-9c7c-e04468355a93", "edge_type": "illustrates", "rationale": "Domain-specific moat claim that can be reclassified through 7 Powers benefit/barrier analysis.", "text": "Orbital jurisdiction provides data sovereignty advantages that terrestrial compute cannot replicate, creating a unique competitive moat for orbital data centers"}], "must_link_existing_claims": [{"claim_id": "8f3e773e-4255-47a7-ba8f-61c57a43bebe", "edge_type": "supports_or_operationalizes", "rationale": "7 Powers is a concrete taxonomy of isolating mechanisms / moats.", "text": "Competitive advantage must be actively deepened through isolating mechanisms because advantage that is not reinforced erodes"}], "resolution_note": "At apply time, link Helmer 7 Powers into the competitive advantage/moats conceptual neighborhood or domain map if present. The current bridge search did not expose a reasoning_tool/map file directly, but Postgres surfaced moat-themed claims and sources below.", "theme": "competitive advantage and moats"}, "core_test": "A proposed Power is not valid unless it specifies both a material benefit and a barrier that prevents motivated, capable competitors from arbitraging the benefit away.", "deferred_application_examples_removed": 5, "deferred_boundary": "Teleo-specific application/self-positioning examples are not canonicalized in this reasoning_tool row; stage them separately if reopened and approved.", "deferred_neighborhood_candidates_removed": 1, "do_not_use_when": ["The question is primarily moral desirability rather than value capture.", "No actor is trying to capture surplus or sustain a differentiated position.", "The mechanism cannot be specified as both benefit and barrier.", "The analysis would merely label success retrospectively without evidence."], "position_in_leo_strategy_stack": ["Inflection map: what structural waves are breaking open now?", "Attractor-state analysis: where do those waves plausibly lead, and which futures are worth steering toward?", "7 Powers analysis: which actors can capture durable value in those futures, and through what benefit/barrier mechanism?", "Resource-scarcity analysis: which scarce resources must be owned, built, coordinated, or backed?"], "power_lifecycle_map": {"decay_or_transition": {"most_relevant_powers": ["all powers as falsification targets"], "notes": "Use this stage to avoid mistaking legacy scale, brand, or switching costs for durable future power when an inflection changes the basis of competition.", "stage_question": "Which former powers are eroding because the basis of scarcity, technology, regulation, or customer preference has shifted?"}, "origination": {"most_relevant_powers": ["counter-positioning", "cornered resource"], "notes": "The official synopsis says invention comes first and Power Progression asks when Power must be established across Origination, Take-Off, and Stability. Counter-positioning and cornered resources can exist before scale.", "stage_question": "What invention or structural opening exists before the market settles?"}, "stability": {"most_relevant_powers": ["brand", "process power", "deep switching costs", "scale economies"], "notes": "Brand and process power usually require long accumulation. Process power is rare and should not be confused with operational excellence.", "stage_question": "After the market settles, what prevents parity and supports persistent differential returns?"}, "take_off": {"most_relevant_powers": ["network economies", "scale economies", "switching costs", "counter-positioning"], "notes": "In Acquired, Helmer identifies the take-off phase as a period of flux with degrees of freedom where founders and teams must process information in real time. Middle-phase tech powers are commonly network economies, scale economies, and switching costs.", "stage_question": "During flux and rapid growth, which powers can be established before the window closes?"}}, "review_gate": "Rio should review mechanism/value-capture claims. Leo can draft and synthesize, but should not self-merge this framework into canonical identity or strategy.", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "seven_powers": [{"barrier": "A smaller competitor cannot match the leader''s unit economics without reaching comparable volume, which may be impossible once the market settles.", "benefit": "Lower cost per unit, higher margin at equal prices, or ability to price below smaller competitors while preserving economics.", "definition": "Per-unit cost declines as production or usage volume increases, giving the leader a lower cost position or better economics.", "examples": ["Netflix content costs amortized over a larger subscriber base", "Uber local density as scale/density, but not necessarily durable in all geographies", "Costco/Amazon/TSMC as candidates requiring source-specific analysis"], "false_positives": ["large size without cost curve advantage", "temporary subsidy scale", "growth that increases complexity faster than unit cost declines"], "name": "Scale Economies", "signals": ["fixed costs spread across larger base", "declining unit cost with volume", "exclusive/fixed-cost assets amortized across more users", "distribution or density advantages"], "source_keys": ["nfx_7powers_hamilton_lawson", "acquired_7powers_hamilton_helmer"], "typical_stage": "Take-Off to Stability"}, {"barrier": "Competitors face cold-start or cannot replicate the incumbent network''s density/utility quickly enough.", "benefit": "More participants increase value, liquidity, standards adoption, or ecosystem utility.", "definition": "A network''s value to participants increases as participation grows, and the resulting utility/density can prevent competitors from reaching equivalence.", "examples": ["IBM mainframe System/360 network economy in Reed Hastings'' foreword", "platform businesses in Acquired Platforms and Power"], "false_positives": ["network effects that create product-market fit but are shared by multiple competitors", "audience size without participant utility increasing", "community as vibes rather than utility"], "name": "Network Economies", "signals": ["same-side or cross-side network effects", "participant liquidity", "developer or complementor ecosystem", "standards or protocol adoption"], "source_keys": ["7powers_foreword_reed_hastings", "acquired_platforms_power", "nfx_7powers_hamilton_lawson"], "typical_stage": "Take-Off"}, {"barrier": "Incumbent imitation is rationally delayed because it cannibalizes existing profit formula or forces organizational self-harm.", "benefit": "Entrant model creates better customer value or economics under the new conditions.", "definition": "A newcomer adopts a superior business model that incumbents do not mimic because doing so would damage their existing economics, channels, organization, or identity.", "examples": ["Netflix no-late-fee/subscription model vs Blockbuster late fees", "Dell direct vs Compaq retail channel", "Twilio usage-based developer model vs seat/license/telco contracts", "Tesla direct/software model vs dealer/ICE incumbents"], "false_positives": ["incumbents are merely slow, not structurally conflicted", "entrant model is different but not superior", "incumbents can copy without self-harm"], "name": "Counter-Positioning", "signals": ["incumbent delay despite visible entrant traction", "cannibalization or channel conflict", "new model requires different talent/compensation/org structure", "entrant benefits from incumbent denial"], "source_keys": ["acquired_7powers_hamilton_helmer", "7powers_foreword_reed_hastings", "nfx_7powers_hamilton_lawson"], "typical_stage": "Origination to early Take-Off"}, {"barrier": "Competitors must overcome the customer''s migration cost, not merely offer a better product.", "benefit": "Retention and pricing resilience even when alternatives exist.", "definition": "Customers remain because changing providers imposes material cost, risk, training, workflow, data, integration, or coordination burden.", "examples": ["SAP enterprise implementation/custom workflow switching costs", "iPhone switching costs discussed in Acquired Platforms"], "false_positives": ["customer inertia without real switching burden", "temporary lack of alternatives", "dark-pattern lock-in that destroys trust"], "name": "Switching Costs", "signals": ["high retention", "data/workflow/integration lock-in", "training and compliance costs", "multi-user coordination burden", "embedded operations"], "source_keys": ["nfx_7powers_hamilton_lawson", "acquired_platforms_power"], "typical_stage": "Take-Off to Stability"}, {"barrier": "Brand meaning accumulates through repeated fulfilled promises and cannot be bought quickly through awareness spending alone.", "benefit": "Willingness to pay, reduced search cost, trust premium, identity/status attachment, or resilience to feature parity.", "definition": "Durable attribution of higher value to an objectively similar offering because of historic information, trust, identity, or status associated with the seller.", "examples": ["Apple in tech", "Hermès handbags", "Del Monte trust example"], "false_positives": ["awareness without willingness to pay", "short-lived hype", "legacy brand whose meaning is decaying in a new generation"], "name": "Brand", "signals": ["pricing premium", "trust premium", "identity attachment", "resilience despite parity", "lower CAC from reputation"], "source_keys": ["nfx_7powers_hamilton_lawson", "acquired_platforms_power"], "typical_stage": "Stability / Maturity"}, {"barrier": "Competitors cannot obtain the same resource on equal terms; if transferred, the resource would independently benefit another owner.", "benefit": "Exclusive or preferential asset improves economics, quality, capability, or strategic options.", "definition": "Preferential access at attractive terms to a coveted asset that independently enhances value and cannot be equally accessed by competitors.", "examples": ["Pixar''s early creative/director group", "patented pharmaceuticals"], "false_positives": ["valuable resource that is not exclusive", "talent whose value is fully arbitraged by labor markets", "data that competitors can recreate or legally access"], "name": "Cornered Resource", "signals": ["exclusive IP/patent/license", "irreplaceable team or creative group", "proprietary dataset with legal defensibility", "scarce relationship or supply position"], "source_keys": ["nfx_7powers_hamilton_lawson", "acquired_7powers_hamilton_helmer"], "typical_stage": "Origination or any stage if acquired/created"}, {"barrier": "The process is too tacit, complex, opaque, path-dependent, or time-consuming for competitors to replicate quickly.", "benefit": "Persistent operational outperformance, lower cost, or superior quality that moves the profit/impact needle.", "definition": "Embedded organization and activity sets enable lower costs or superior product through tacit, complex, hard-to-copy routines.", "examples": ["Toyota lean production"], "false_positives": ["ordinary operational excellence", "best practices consultants can copy", "temporary execution edge from hiring"], "name": "Process Power", "signals": ["persistent outperformance despite imitation attempts", "tacit routines", "many interlocking practices", "learning curve accumulated over long time"], "source_keys": ["nfx_7powers_hamilton_lawson"], "typical_stage": "Stability / Maturity"}], "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "summary": "A strategic analysis framework for diagnosing durable value capture by identifying the specific benefit/barrier mechanism that lets a company, platform, protocol, or agentic institution earn persistent differential returns after an inflection creates an opportunity.", "use_when": ["Evaluating companies, founders, sectors, platforms, protocols, or agentic institutions for durable value capture.", "Stress-testing whether an inflection-map or attractor-state thesis identifies winners, not just change.", "Distinguishing product-market fit, growth, or cultural momentum from defensible power.", "Assessing whether Teleo should inform, orient, connect, or back a builder because the builder can create and defend scarce value."]}', 'strategy_framework' + where not exists (select 1 from public.reasoning_tools where id = '473ba7b0-ce44-5e77-bc46-ef82a49b6a3e'::uuid); + +insert into public.claims (id, type, text, status, confidence, tags, created_by) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, 'structural', 'Helmer''s 7 Powers framework diagnoses durable value capture only when a company has both a material benefit and a barrier that prevents motivated capable competitors from arbitraging that benefit away.', + 'open', 0.8, array['grand-strategy', 'internet-finance', 'mechanisms']::text[], + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.claims where id = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid); + +insert into public.claims (id, type, text, status, confidence, tags, created_by) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, 'structural', 'Power must be analyzed by lifecycle stage because different powers become available in Origination, Take-Off, and Stability, and the window to establish a power can close as market flux resolves.', + 'open', 0.7, array['grand-strategy', 'mechanisms']::text[], + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.claims where id = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid); + +insert into public.claims (id, type, text, status, confidence, tags, created_by) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'structural', 'Counter-positioning is most useful near inflection points because entrants can adopt a superior model while incumbents rationally delay imitation to avoid damaging their existing economics, channels, or identity.', + 'open', 0.75, array['grand-strategy', 'internet-finance', 'mechanisms']::text[], + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.claims where id = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid); + +insert into public.claims (id, type, text, status, confidence, tags, created_by) +select '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, 'structural', 'Network effects create product value but do not become network economies power unless they also prevent competitors from reaching equivalence and let the focal actor capture surplus.', + 'open', 0.7, array['grand-strategy', 'internet-finance', 'collective-intelligence']::text[], + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.claims where id = '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid); + +insert into public.claims (id, type, text, status, confidence, tags, created_by) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, 'normative', 'Leo should use 7 Powers after inflection mapping and attractor-state analysis to distinguish builders who merely benefit from a wave from builders who can durably capture and compound value from that wave.', + 'open', 0.65, array['grand-strategy', 'living-agents', 'internet-finance']::text[], + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.claims where id = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '02b8c5ff-04fb-54e7-b132-e731086f1436'::uuid, 'other', 'https://www.amazon.com/7-Powers-Foundations-Business-Strategy/dp/0998116319', + null, '{"excerpt": "Canonical source for the seven powers framework; source of definitions, benefit/barrier logic, Power Progression, and company examples. Full text not ingested in this run; use book/page references if available before final canonicalization.", "metadata": {"source_key": "helmer_7powers_book", "title": "7 Powers: The Foundations of Business Strategy"}}', '9d969205f377ffb9c72722616a59770b1a291dc240d5ea00645a44533c490ac3', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '02b8c5ff-04fb-54e7-b132-e731086f1436'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid, 'article', 'https://7powers.com/synopsis/', + null, '{"excerpt": "Helmer develops from first principles a practical theory of Strategy rooted in the notion of Power, those conditions which create the potential for persistent differential returns. The synopsis says invention comes first and Power Progression targets when Power must be established in Origination, Take-Off, or Stability.", "metadata": {"source_key": "7powers_synopsis", "title": "Synopsis – 7 Powers"}}', 'f337a56de1336a9b301eb8c6873d6a8fe012cfd7403105bd117ac2154842e4eb', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid, 'article', 'https://7powers.com/foreword/', + null, '{"excerpt": "Hastings describes Helmer''s Power Dynamics assessment of Netflix, identifies Counter-Positioning and Power Progression as novel conceptual advances, and says Counter-Positioning explained why incumbents rationally failed to adjust.", "metadata": {"source_key": "7powers_foreword_reed_hastings", "title": "Foreword – 7 Powers"}}', '053055a1189e1ceb8f7fb5c6a6c8373f882dcff9eeb9725c6cc7fe1f301bdda8', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, 'transcript', 'https://www.acquired.fm/episodes/7-powers-with-hamilton-helmer', + null, '{"excerpt": "Helmer states power has two necessary and sufficient conditions: benefit and barrier. Benefit is a materially better business model; barrier prevents motivated and capable competitors from taking it away. He calls Seven Powers a careful, hopefully exhaustive articulation of moats.", "metadata": {"source_key": "acquired_7powers_hamilton_helmer", "title": "7 Powers with Hamilton Helmer | Acquired"}}', '81d2f49c5f1b32449f6080c5ecb215fa8641ff309d607fc05b69258ef6588d36', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '2df4bb44-4853-5455-8049-6dbb8685523b'::uuid, 'transcript', 'https://www.acquired.fm/episodes/platforms-and-power-with-hamilton-helmer-and-chenyi-shi', + null, '{"excerpt": "Chenyi Shi frames platform power through three questions: how economic value is created, how each customer group perceives value as the platform scales, and how competitors are prevented from reaching equivalence. Helmer distinguishes network effects from network economies power.", "metadata": {"source_key": "acquired_platforms_power", "title": "Platforms and Power (with Hamilton Helmer and Chenyi Shi) | Acquired"}}', '724f509eaf56e998f96211f61512c225e87a8497904198e610fe38adfdbf7b78', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '2df4bb44-4853-5455-8049-6dbb8685523b'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, 'article', 'https://www.nfx.com/post/seven-powers', + null, '{"excerpt": "NFX/Helmer provides concise definitions and examples for the powers: cornered resource (Pixar), scale economies (Netflix), switching costs (SAP), counter-positioning (Twilio/Tesla/Netflix), brand (Apple/Hermès), process power (Toyota). It also states performance is trailing while power is leading.", "metadata": {"source_key": "nfx_7powers_hamilton_lawson", "title": "The 7 Powers Known to Tesla, Pixar, Netflix, Apple & Twilio"}}', 'db97d016740feae7eec08bb860ec8a06196732b5a1e3543115d74227317afb88', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '50e0d1ef-322b-5097-afe6-c9aa5ecea5fc'::uuid, 'article', 'https://podcast.nfx.com/episodes/hamilton-helmer-jeff-lawson', + null, '{"excerpt": "Episode summary asks what keeps competition away and states Helmer''s framework reveals conditions for persistent and durable differential returns.", "metadata": {"source_key": "nfx_podcast_summary", "title": "The 7 Powers with Hamilton Helmer & Jeff Lawson | The NFX Podcast"}}', '26901a373a644d439c621c3ba2bd472f519cd07922eb647cba823dd957efad32', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '50e0d1ef-322b-5097-afe6-c9aa5ecea5fc'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '621bb834-6366-5940-b6c3-c5f82ba35d48'::uuid, 'article', 'https://www.thetwentyminutevc.com/hamiltonhelmer/', + null, '{"excerpt": "Show notes emphasize ''all strategy begins with invention,'' transition from startup to pricer with scale economies, competition, brand definition, and sustainable leverage/power.", "metadata": {"source_key": "20vc_hamilton_helmer", "title": "20VC: Hamilton Helmer – 7 Powers: The Foundations of Business Strategy"}}', '6ac16b3a372d2e2e5b8d00800282e45ebaa00f451b5f2c5af20bf95583aaa779', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '621bb834-6366-5940-b6c3-c5f82ba35d48'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid, 'other', null, + null, '{"body": null, "candidate_review_note": null, "claim_key": "seven_powers_requires_benefit_and_barrier", "edges": [{"edge_type": "supports", "rationale": "Benefit/barrier is a precise isolating-mechanism test.", "to_existing_claim": "8f3e773e-4255-47a7-ba8f-61c57a43bebe"}, {"edge_type": "relates", "rationale": "Powers explain how scarcity becomes defendable value capture.", "to_existing_claim": "2ef388ab-4102-4416-a6e1-ae6ba8ee02fa"}], "evidence": ["acquired_7powers_hamilton_helmer", "nfx_7powers_hamilton_lawson"], "evidence_tier": null, "headline": null, "needs_research": null, "proposal_id": "a64df080-8502-42e2-98f4-9bbdecb8da73", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "reviewed_by_handle": "m3taversal", "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "text": "Helmer''s 7 Powers framework diagnoses durable value capture only when a company has both a material benefit and a barrier that prevents motivated capable competitors from arbitraging that benefit away."}', '7820f745a7fa092bb27c55efb104011599100b84dfb60e524ab0aff28d94e016', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid, 'other', null, + null, '{"body": null, "candidate_review_note": null, "claim_key": "power_progression_stage_gates_strategy", "edges": [{"edge_type": "relates", "rationale": "Stage-specific power creation supports strategy-as-design rather than static planning.", "to_existing_claim": "25a350e0-ebce-4072-8f2a-48427a727553"}], "evidence": ["7powers_synopsis", "7powers_foreword_reed_hastings", "acquired_7powers_hamilton_helmer"], "evidence_tier": null, "headline": null, "needs_research": null, "proposal_id": "a64df080-8502-42e2-98f4-9bbdecb8da73", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "reviewed_by_handle": "m3taversal", "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "text": "Power must be analyzed by lifecycle stage because different powers become available in Origination, Take-Off, and Stability, and the window to establish a power can close as market flux resolves."}', '241cf2d2bc0c3049a9fe23ed3957c81eaed2778e36d38a823b8ae29bb0b5285b', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '11fa942d-e81a-5142-965d-3c60714a7dca'::uuid, 'other', null, + null, '{"body": null, "candidate_review_note": null, "claim_key": "counter_positioning_is_early_inflection_power", "edges": [{"edge_type": "relates", "rationale": "Counter-positioning exploits path dependence and incumbent commitments.", "to_existing_claim": "be59b559-de8b-4dec-a7be-773188c0e632"}], "evidence": ["acquired_7powers_hamilton_helmer", "7powers_foreword_reed_hastings", "nfx_7powers_hamilton_lawson"], "evidence_tier": null, "headline": null, "needs_research": null, "proposal_id": "a64df080-8502-42e2-98f4-9bbdecb8da73", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "reviewed_by_handle": "m3taversal", "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "text": "Counter-positioning is most useful near inflection points because entrants can adopt a superior model while incumbents rationally delay imitation to avoid damaging their existing economics, channels, or identity."}', '5731229bb29db3069f15d826369ef0d01a377b19c07b9649d1b760abb650249a', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '11fa942d-e81a-5142-965d-3c60714a7dca'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '263f423e-c16f-544c-ae5f-3e370e736e12'::uuid, 'other', null, + null, '{"body": null, "candidate_review_note": null, "claim_key": "network_effects_do_not_equal_network_power", "edges": [{"edge_type": "relates", "rationale": "Commercial network effects can be self-enforcing only when they alter capture/coordination incentives, not merely create participation value.", "to_existing_claim": "93d583d9-5394-4e6a-97ca-bcd48796d94a"}], "evidence": ["acquired_platforms_power", "nfx_7powers_hamilton_lawson"], "evidence_tier": null, "headline": null, "needs_research": null, "proposal_id": "a64df080-8502-42e2-98f4-9bbdecb8da73", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "reviewed_by_handle": "m3taversal", "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "text": "Network effects create product value but do not become network economies power unless they also prevent competitors from reaching equivalence and let the focal actor capture surplus."}', '69f0c902a946a229546293ab5ae101447013c3730b6ba568225f60af6352b7d8', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '263f423e-c16f-544c-ae5f-3e370e736e12'::uuid); + +insert into public.sources (id, source_type, url, storage_path, excerpt, hash, created_by) +select '0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid, 'other', null, + null, '{"body": null, "candidate_review_note": null, "claim_key": "agentic_capital_needs_power_analysis", "edges": [{"edge_type": "supports", "rationale": "7 Powers operationalizes scarcity/value-capture analysis for builder evaluation.", "to_existing_claim": "2ef388ab-4102-4416-a6e1-ae6ba8ee02fa"}, {"edge_type": "supports", "rationale": "Builder evaluation should ask whether the advantage is actively deepening through isolating mechanisms.", "to_existing_claim": "8f3e773e-4255-47a7-ba8f-61c57a43bebe"}], "evidence": ["7powers_synopsis", "acquired_7powers_hamilton_helmer"], "evidence_tier": null, "headline": null, "needs_research": null, "proposal_id": "a64df080-8502-42e2-98f4-9bbdecb8da73", "review_note": "Approved by m3taversal in Telegram after requested changes: claim #6 removed/deferred and competitive advantage/moats neighborhood linkage added. Approved for human resolution/apply; not canonically applied by Leo.", "reviewed_by_handle": "m3taversal", "source_ref": "telegram:m3taversal:2026-06-29:7-powers-approved-with-changes", "text": "Leo should use 7 Powers after inflection mapping and attractor-state analysis to distinguish builders who merely benefit from a wave from builders who can durably capture and compound value from that wave."}', '3dd21b86130e62ebd301b4ae18056ecbffb74606c30696258fcb9cd420ac555e', + '11111111-1111-1111-1111-111111111111'::uuid + where not exists (select 1 from public.sources where id = '0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid, + 'illustrates'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid + and source_id = '5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid + and role = 'illustrates'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid + and source_id = 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid + and source_id = '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid, + 'illustrates'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid + and source_id = '97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid + and role = 'illustrates'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid + and source_id = '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid + and source_id = 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid + and source_id = 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, '11fa942d-e81a-5142-965d-3c60714a7dca'::uuid, + 'illustrates'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid + and source_id = '11fa942d-e81a-5142-965d-3c60714a7dca'::uuid + and role = 'illustrates'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid + and source_id = 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid + and source_id = 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid + and source_id = '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '263f423e-c16f-544c-ae5f-3e370e736e12'::uuid, + 'illustrates'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid + and source_id = '263f423e-c16f-544c-ae5f-3e370e736e12'::uuid + and role = 'illustrates'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '2df4bb44-4853-5455-8049-6dbb8685523b'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid + and source_id = '2df4bb44-4853-5455-8049-6dbb8685523b'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid + and source_id = '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid, + 'illustrates'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid + and source_id = '0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid + and role = 'illustrates'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid + and source_id = '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_evidence (claim_id, source_id, role, weight) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, + 'grounds'::evidence_role, null + where not exists ( + select 1 from public.claim_evidence + where claim_id = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid + and source_id = 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid + and role = 'grounds'::evidence_role); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid, + 'supports'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid + and to_claim = '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid + and edge_type = 'supports'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid, + 'relates'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '23927224-0d72-5b37-a600-33c63277f6a9'::uuid + and to_claim = '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid + and edge_type = 'relates'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '25a350e0-ebce-4072-8f2a-48427a727553'::uuid, + 'relates'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid + and to_claim = '25a350e0-ebce-4072-8f2a-48427a727553'::uuid + and edge_type = 'relates'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'be59b559-de8b-4dec-a7be-773188c0e632'::uuid, + 'relates'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = 'd2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid + and to_claim = 'be59b559-de8b-4dec-a7be-773188c0e632'::uuid + and edge_type = 'relates'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '93d583d9-5394-4e6a-97ca-bcd48796d94a'::uuid, + 'relates'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid + and to_claim = '93d583d9-5394-4e6a-97ca-bcd48796d94a'::uuid + and edge_type = 'relates'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid, + 'supports'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid + and to_claim = '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid + and edge_type = 'supports'::edge_type); + +insert into public.claim_edges (from_claim, to_claim, edge_type, weight) +select '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid, + 'supports'::edge_type, null + where not exists ( + select 1 from public.claim_edges + where from_claim = '12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid + and to_claim = '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid + and edge_type = 'supports'::edge_type); + +commit; + +-- Full-coverage packet ledger update: mark original approved proposal(s) applied only after generated rows exist. +begin; + +do $$ +declare + flipped int; +begin + update kb_stage.kb_proposals + set status = 'applied', + applied_by_handle = 'codex-packet-20260709', + applied_at = now(), + updated_at = now() + where id in (select id from (values + ('a64df080-8502-42e2-98f4-9bbdecb8da73'::uuid) + ) as v(id)) + and status = 'approved'; + + get diagnostics flipped = row_count; + if flipped <> 1 then + raise exception 'rich proposal packet ledger flip affected % row(s), expected 1; original proposals were not all approved', flipped; + end if; +end $$; + +commit; diff --git a/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet-current.md b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet-current.md index 00530da..135be30 100644 --- a/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet-current.md +++ b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet-current.md @@ -1,10 +1,12 @@ -# Helmer 7 Powers Production Apply Packet - 2026-07-09 +# Helmer 7 Powers Production Apply Packet - Ledger-Proven Refresh - 2026-07-09 -Status: packet ready and clone-proven; not executed on production. +Generated UTC: `2026-07-09T21:15:06.276683+00:00` + +Status: full-coverage packet ready and clone-proven; not executed on production. Proposal: - `a64df080-8502-42e2-98f4-9bbdecb8da73` -- Status on production preflight: `approved` +- Production status on preflight: `approved` - Proposal type: `attach_evidence` - Reviewer: `m3taversal` - Reviewed at: `2026-06-29 16:32:39.431004+00` @@ -16,25 +18,35 @@ Generated row contract: - `public.claim_edges`: 7 rows - `public.claim_evidence`: 17 rows +Ledger behavior: +- `marks_original_proposals_applied`: `true` +- `applied_by_handle`: `codex-packet-20260709` +- Remaining blocked fragments: `0` +- Unresolved design decisions: `0` + Important boundary: - The canonical reasoning-tool row is sanitized: Teleo-specific self-positioning/application examples are removed from the reasoning-tool description and counted as deferred. -- The packet does not mark the original `kb_stage.kb_proposals` row as `applied`. +- Because the packet has full coverage for the approved Helmer framework contract and no blocked fragments, the authorized commit SQL now marks the original `kb_stage.kb_proposals` row as `applied` after generated rows are written. +- The mapped internet-finance/Hayek packet still refuses this ledger behavior because it has unresolved non-claim/cross-table fragments. - Production commit SQL exists only for separately authorized execution. It has not been run against production. -Live production rehearsal: +Live production rollback rehearsal: - Preflight found the proposal approved and all required existing target claims present. - Preflight generated-row counts were `0/0/0/0/0` for reasoning tool / claims / sources / edges / evidence. -- Rollback-only apply rehearsal inserted the planned rows inside a transaction and ended with `ROLLBACK`. -- Post-rehearsal production generated-row counts remained `0/0/0/0/0`. +- Rollback-only apply rehearsal inserted the planned rows and executed the proposal-ledger update inside transactions ending with `ROLLBACK`. +- Post-rehearsal production generated-row counts remained `0/0/0/0/0` and proposal status remained `approved`. Disposable clone proof: -- Disposable DB: `teleo_helmer_rehearsal_20260709` +- Disposable DB: `teleo_helmer_ledger_rehearsal_20260709` - Clone commit produced `1` reasoning tool, `5` claims, `13` sources, `7` claim edges, and `17` claim evidence rows. - Clone postflight read back reasoning tool `473ba7b0-ce44-5e77-bc46-ef82a49b6a3e` named `Helmer 7 Powers`. +- Clone postflight read back proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` as `applied` with `applied_by_handle = codex-packet-20260709`. - Delete rollback removed `17` evidence rows, `7` edge rows, `13` source rows, `5` claim rows, and `1` reasoning-tool row. +- Delete rollback restored the proposal ledger to `approved` with blank `applied_by_handle`/`applied_at`. - Clone after delete returned generated-row counts to `0/0/0/0/0`. -- Production after clone remained `0/0/0/0/0`. +- Production after clone remained `0/0/0/0/0` and proposal status remained `approved`. - Disposable clone was dropped; final clone DB count was `0`. +- VPS service stayed active/running with PID `3252143`, restarts `0`. Packet files: - `production-preflight.sql` @@ -43,9 +55,7 @@ Packet files: - `production-postflight.sql` - `production-delete-rollback.sql` - `production-apply-packet.json` -- `production-apply-packet-summary.json` -- `live-preflight-rollback-current.log` -- `clone-commit-delete-rollback-current.log` +- `ledger-clone-commit-delete-rollback-current.log` Claim ceiling: -This proves the approved Helmer 7 Powers framework can be represented and rolled back safely using current canonical tables. It does not prove production has been updated, because production commit was intentionally not executed. +This proves the approved Helmer 7 Powers framework can be represented, applied, ledger-marked, and rolled back safely in a disposable clone using current canonical tables. It does not prove production has been updated, because production commit was intentionally not executed. diff --git a/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet.json b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet.json new file mode 100644 index 0000000..b3638ca --- /dev/null +++ b/docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-packet.json @@ -0,0 +1,41 @@ +{ + "applied_by_handle": "codex-packet-20260709", + "claim_ceiling": "Production apply packet for full covered proposal contract; authorized commit SQL marks original proposal(s) applied after generated rows are written.", + "marks_original_proposals_applied": true, + "packet_version": 1, + "plan_path": "/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/helmer-7powers-20260709/helmer-7powers-creation-plan.json", + "proposal_ids": [ + "a64df080-8502-42e2-98f4-9bbdecb8da73" + ], + "remaining_blocked_fragments": [], + "required_existing_claims": [ + { + "id": "25a350e0-ebce-4072-8f2a-48427a727553", + "reason": "claim_edges.to_claim" + }, + { + "id": "2ef388ab-4102-4416-a6e1-ae6ba8ee02fa", + "reason": "claim_edges.to_claim" + }, + { + "id": "8f3e773e-4255-47a7-ba8f-61c57a43bebe", + "reason": "claim_edges.to_claim" + }, + { + "id": "93d583d9-5394-4e6a-97ca-bcd48796d94a", + "reason": "claim_edges.to_claim" + }, + { + "id": "be59b559-de8b-4dec-a7be-773188c0e632", + "reason": "claim_edges.to_claim" + } + ], + "row_counts": { + "claim_edges": 7, + "claim_evidence": 17, + "claims": 5, + "reasoning_tools": 1, + "sources": 13 + }, + "unresolved_design_decisions": [] +} \ No newline at end of file diff --git a/docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql b/docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql new file mode 100644 index 0000000..8eda234 --- /dev/null +++ b/docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql @@ -0,0 +1,103 @@ +\set ON_ERROR_STOP on +-- Emergency rollback for the mapped generated rows only. +-- Run only before any later production data depends on these generated rows. +begin; + +delete from public.claim_evidence ce +using (values + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid, 'illustrates'::evidence_role), + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, 'grounds'::evidence_role), + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, 'grounds'::evidence_role), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid, 'illustrates'::evidence_role), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid, 'grounds'::evidence_role), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid, 'grounds'::evidence_role), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, 'grounds'::evidence_role), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, '11fa942d-e81a-5142-965d-3c60714a7dca'::uuid, 'illustrates'::evidence_role), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, 'grounds'::evidence_role), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid, 'grounds'::evidence_role), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, 'grounds'::evidence_role), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '263f423e-c16f-544c-ae5f-3e370e736e12'::uuid, 'illustrates'::evidence_role), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '2df4bb44-4853-5455-8049-6dbb8685523b'::uuid, 'grounds'::evidence_role), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid, 'grounds'::evidence_role), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid, 'illustrates'::evidence_role), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '4bd41552-8017-551a-84b5-19b0107c20b5'::uuid, 'grounds'::evidence_role), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, 'dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid, 'grounds'::evidence_role) + ) as v(claim_id, source_id, role) +where ce.claim_id = v.claim_id and ce.source_id = v.source_id and ce.role = v.role; + +delete from public.claim_edges e +using (values + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid, 'supports'::edge_type), + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid, '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid, 'relates'::edge_type), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid, '25a350e0-ebce-4072-8f2a-48427a727553'::uuid, 'relates'::edge_type), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid, 'be59b559-de8b-4dec-a7be-773188c0e632'::uuid, 'relates'::edge_type), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid, '93d583d9-5394-4e6a-97ca-bcd48796d94a'::uuid, 'relates'::edge_type), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '2ef388ab-4102-4416-a6e1-ae6ba8ee02fa'::uuid, 'supports'::edge_type), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid, '8f3e773e-4255-47a7-ba8f-61c57a43bebe'::uuid, 'supports'::edge_type) + ) as v(from_claim, to_claim, edge_type) +where e.from_claim = v.from_claim and e.to_claim = v.to_claim and e.edge_type = v.edge_type; + +update public.claims +set superseded_by = null, + updated_at = now() +where superseded_by in (select id from (values + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid) + ) as v(id)); + +delete from public.sources +where id in (select id from (values + ('02b8c5ff-04fb-54e7-b132-e731086f1436'::uuid), + ('4bd41552-8017-551a-84b5-19b0107c20b5'::uuid), + ('bc081b04-709f-565a-af0b-95d4ca0589fa'::uuid), + ('dc1c238c-f835-5641-980a-f0fe53f8dfe5'::uuid), + ('2df4bb44-4853-5455-8049-6dbb8685523b'::uuid), + ('6fe15936-d5b9-514e-802f-32a2a06f4a23'::uuid), + ('50e0d1ef-322b-5097-afe6-c9aa5ecea5fc'::uuid), + ('621bb834-6366-5940-b6c3-c5f82ba35d48'::uuid), + ('5f9dd7ca-83f8-5ea6-8e00-d9d13003f8fc'::uuid), + ('97c3fc2f-16ae-5507-ad51-b1f4a1bcfb11'::uuid), + ('11fa942d-e81a-5142-965d-3c60714a7dca'::uuid), + ('263f423e-c16f-544c-ae5f-3e370e736e12'::uuid), + ('0c87a244-afa2-5d08-8e79-9cb792aff553'::uuid) + ) as v(id)); + +delete from public.claims +where id in (select id from (values + ('23927224-0d72-5b37-a600-33c63277f6a9'::uuid), + ('4701f303-ca9c-5da1-aa48-8cf28189c23c'::uuid), + ('d2b2142b-c2d8-5e33-9a38-14598d94d715'::uuid), + ('6014c3ea-3ba5-5ed1-bf15-31f6938e3fc3'::uuid), + ('12d2c4aa-1c23-5173-b666-dea903dd7432'::uuid) + ) as v(id)); + +delete from public.reasoning_tools +where id in (select id from (values + ('473ba7b0-ce44-5e77-bc46-ef82a49b6a3e'::uuid) + ) as v(id)); + +do $$ +declare + restored int; +begin + update kb_stage.kb_proposals + set status = 'approved', + applied_by_handle = null, + applied_by_agent_id = null, + applied_at = null, + updated_at = now() + where id in (select id from (values + ('a64df080-8502-42e2-98f4-9bbdecb8da73'::uuid) + ) as v(id)) + and status = 'applied'; + + get diagnostics restored = row_count; + if restored <> 1 then + raise exception 'rich proposal packet ledger rollback restored % row(s), expected 1; original proposals were not all applied', restored; + end if; +end $$; + +commit; diff --git a/docs/reports/leo-working-state-20260709/leo-db-state-16-helmer-ledger.svg b/docs/reports/leo-working-state-20260709/leo-db-state-16-helmer-ledger.svg new file mode 100644 index 0000000..3f76146 --- /dev/null +++ b/docs/reports/leo-working-state-20260709/leo-db-state-16-helmer-ledger.svg @@ -0,0 +1,48 @@ + + + Helmer 7 Powers: Full-Coverage Apply Packet + Rows + proposal ledger are clone-proven. Production remains unchanged until explicit apply authorization. + + + Production Preflight + proposal: approved + generated rows: 0/0/0/0/0 + missing required claims: 0 + + + + + Disposable Clone Commit + reasoning tools / claims / sources + 1 / 5 / 13 + edges / evidence: 7 / 17 + + + + + Proposal Ledger + a64df080 -> applied + applied_by: codex-packet-20260709 + guard: approved row count = 1 + + + Delete Rollback + deleted evidence/edges/sources/claims/tool + restored proposal status to approved + clone rows after rollback: 0/0/0/0/0 + + + Production Stayed Clean + generated rows after rehearsal: 0/0/0/0/0 + proposal status: approved + no production commit executed + + + Guardrail + full coverage only + partial mapped packet refused ledger mark + VPS service active, restarts 0 + + Claim ceiling: production apply still requires explicit authorization; this is clone proof and production rollback-only proof. + + diff --git a/docs/reports/leo-working-state-20260709/working-leo-current-state-20260709.md b/docs/reports/leo-working-state-20260709/working-leo-current-state-20260709.md index 26a342a..cb5c908 100644 --- a/docs/reports/leo-working-state-20260709/working-leo-current-state-20260709.md +++ b/docs/reports/leo-working-state-20260709/working-leo-current-state-20260709.md @@ -1,6 +1,6 @@ # Working Leo Current State - 2026-07-09 -Generated UTC: `2026-07-09T20:32:38Z` +Generated UTC: `2026-07-09T21:15:00Z` ## Current Working Definition @@ -16,6 +16,11 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a - turn 2 reply preserved the correction `approved is not the same as applied` - turn 2 reply reported proposal `00957f6c-9883-4015-95a4-6b09367efb0e` as `applied` - turn 2 reply reported edge `c167933e-d513-4f43-9335-d5d8aeb259f2` exists in `public.claim_edges` and the canonical row exists +- Open-ended Cory-style Telegram canary passed: + - marker `WL-LIVE-TG-CORY-OPEN-20260709` + - Leo inferred the likely failure mode from "agents not working / KB same as last night" without exact proposal IDs + - Leo named `kb_stage.kb_proposals`, gateway/scheduler logs, and canonical `public.*` graph deltas as first checks + - Leo distinguished proposed, approved, and applied without staging or mutating the KB - Telegram-shaped handler canary passed in the same user/cwd context as the live service: - authorized source: `agent:main:telegram:group:-5146042086:9070919` - turn 1 ack passed @@ -34,10 +39,9 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a ## What Is Still Not Proven -- Old Cory-approved proposals are still not directly applyable: +- Old Cory-approved mapped rich proposals are still not fully directly applyable: - `14fa5ecc-ac7a-41c1-807d-a2e85b936617` - `ac036c9d-20a0-4ffe-881f-57d6b7bacf22` - - `a64df080-8502-42e2-98f4-9bbdecb8da73` - `14fa5ecc` normalization is blocked by missing canonical claim/source IDs. The proposal contains approved textual successor candidates, but the exact successor rows A/B/C/D do not already exist as canonical rows. - Current narrow apply worker supports `add_edge`, `attach_evidence`, and `revise_strategy`; it does not create new `public.claims` or `public.sources` rows. Applying `14fa5ecc` as Cory likely expects requires either creating/identifying canonical rows first or explicitly widening the guarded apply contract. - Live approved rich proposal contract preview is now available: @@ -68,13 +72,14 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a - clone post-commit readback showed DB-side `superseded_by` pointers are set by generated `supersedes` edges for `7da4851c...` and `d0000000...` - packet delete rollback now clears those exact `superseded_by` pointers, deletes generated rows, and returns clone generated-row counts to `0/0/0/0` - production generated rows remain `0/0/0/0`; disposable packet clone and temp dump were removed -- Helmer 7 Powers approved proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` is now packet-ready and clone-proven: +- Helmer 7 Powers approved proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` is now full-coverage packet-ready and ledger clone-proven: - generated row contract is `1` reasoning tool, `5` claims, `13` sources, `7` claim_edges, and `17` claim_evidence rows - canonical reasoning-tool description is sanitized so Teleo-specific self-positioning/application examples are deferred rather than canonically approved through the framework proposal - live production preflight confirms the proposal is approved, required existing target claims are present, and generated rows are `0/0/0/0/0` - - live production rollback rehearsal inserted the planned rows inside a transaction and rolled back cleanly - - disposable clone `teleo_helmer_rehearsal_20260709` committed the packet and read back `1/5/13/7/17` - - clone delete rollback returned generated rows to `0/0/0/0/0` + - live production rollback rehearsal inserted the planned rows and proposal-ledger update inside transactions and rolled back cleanly + - disposable clone `teleo_helmer_ledger_rehearsal_20260709` committed the packet and read back `1/5/13/7/17` + - clone postflight read back proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` as `applied` with `applied_by_handle=codex-packet-20260709` + - clone delete rollback returned generated rows to `0/0/0/0/0` and restored the proposal ledger to `approved` - production generated rows remain `0/0/0/0/0`; disposable clone was dropped with final clone count `0` - GCP parity was rechecked and remains blocked on account authentication: - `billy@livingip.xyz` is selected for project `teleo-501523` but token refresh fails non-interactively @@ -96,6 +101,7 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a - Mapped rich proposal creation plan: `outputs/rich-proposal-creation-plan-20260709/rich-proposal-creation-plan-mapped-current.md` - Production apply packet for mapped subset: `outputs/rich-proposal-creation-plan-20260709/production-apply-packet-mapped-20260709/production-apply-packet-current.md` - Helmer 7 Powers apply packet: `outputs/rich-proposal-creation-plan-20260709/helmer-7powers-20260709/production-apply-packet/production-apply-packet-current.md` +- 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` - Execution plan: `outputs/working-leo-execution-plan-20260709/working-leo-execution-plan-current.md` - Cory expected outcomes: `outputs/cory-expected-working-leo-outcomes-20260709.md` - Current live proof image: `outputs/leo-db-state-07-live-proof.svg` @@ -105,6 +111,8 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a - Mapped staging proof image: `outputs/leo-db-state-11-mapped-staging.svg` - Production packet proof image: `outputs/leo-db-state-12-production-packet.svg` - Helmer packet proof image: `outputs/leo-db-state-14-helmer-packet.svg` +- Open-ended Cory-style canary image: `outputs/leo-db-state-15-open-ended-canary.svg` +- Helmer ledger proof image: `outputs/leo-db-state-16-helmer-ledger.svg` - GCP parity blocker: `outputs/gcp-db-parity-current-blocker-20260709.json` ## Next Actions diff --git a/docs/reports/leo-working-state-20260709/working-leo-execution-plan-current.md b/docs/reports/leo-working-state-20260709/working-leo-execution-plan-current.md index 9336622..41279be 100644 --- a/docs/reports/leo-working-state-20260709/working-leo-execution-plan-current.md +++ b/docs/reports/leo-working-state-20260709/working-leo-execution-plan-current.md @@ -1,6 +1,6 @@ # Working Leo Execution Plan - 2026-07-09 -Claim ceiling: VPS Telegram memory/KB audit, Telegram-to-`kb_stage` proposal staging, and strict existing-ID apply are working; rich approved packet row creation is clone-commit proven and now has a production apply packet for the mapped supported subset, but production has not been applied; non-claim target decisions 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 only for its supported subset; non-claim target decisions and GCP parity remain pending. ## WL-EXEC-01 - VPS Telegram-visible memory + KB audit - Status: `done` @@ -50,11 +50,11 @@ Claim ceiling: VPS Telegram memory/KB audit, Telegram-to-`kb_stage` proposal sta ## WL-EXEC-05C - Helmer 7 Powers approved proposal packet - Status: `done_packet_ready_not_executed` -- Result: Generated packet for proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` with 1 reasoning tool, 5 claims, 13 sources, 7 edges, and 17 evidence rows. Live production preflight and rollback rehearsal passed; disposable clone commit/readback produced `1/5/13/7/17`; delete rollback returned clone generated rows to `0/0/0/0/0`; production stayed zero. +- Result: Generated full-coverage packet for proposal `a64df080-8502-42e2-98f4-9bbdecb8da73` with 1 reasoning tool, 5 claims, 13 sources, 7 edges, and 17 evidence rows. Live production preflight and rollback rehearsal passed; disposable clone commit/readback produced `1/5/13/7/17` and marked the proposal `applied`; delete rollback returned clone generated rows to `0/0/0/0/0` and restored the proposal to `approved`; production stayed zero. - Not done condition: Production canonical rows 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/helmer-7powers-20260709/production-apply-packet/production-apply-packet-current.md` - - `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/helmer-7powers-20260709/production-apply-packet/clone-commit-delete-rollback-current.log` + - `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/helmer-7powers-20260709/production-apply-packet/ledger-clone-commit-delete-rollback-current.log` ## WL-EXEC-06 - Reviewed decisions for unsupported rich-packet fragments - Status: `partially_resolved_pending_non_claim_target_decisions` diff --git a/scripts/kb_rich_proposal_apply_packet.py b/scripts/kb_rich_proposal_apply_packet.py index a53b19e..ca5bf76 100644 --- a/scripts/kb_rich_proposal_apply_packet.py +++ b/scripts/kb_rich_proposal_apply_packet.py @@ -12,9 +12,10 @@ proposal creation plan into reproducible SQL files: * postflight SQL: exact generated-row count/readback; * rollback-delete SQL: exact reverse deletes for the generated rows. -The packet intentionally does not mark the original rich proposals as applied. -The mapped subset is partial while non-claim targets remain unresolved; marking -the original proposals applied would overstate DB state. +The packet marks original rich proposals as applied only when explicitly +requested and the plan has no remaining blocked fragments or unresolved design +decisions. Mapped subsets must leave the original proposals approved, because +marking a partial packet applied would overstate DB state. """ from __future__ import annotations @@ -92,6 +93,34 @@ def collect_required_existing_claims(rows: dict[str, list[dict[str, Any]]]) -> l return [{"id": claim_id, "reason": reason} for claim_id, reason in sorted(required.items())] +def collect_blocked_fragments(plans: list[dict[str, Any]]) -> list[dict[str, Any]]: + return [ + fragment + for plan in plans + for fragment in plan.get("blocked_fragments", []) + if isinstance(fragment, dict) + ] + + +def collect_unresolved_design_decisions(plans: list[dict[str, Any]]) -> list[dict[str, Any]]: + return [ + item + for plan in plans + for item in plan.get("unresolved_design_decisions", []) + if isinstance(item, dict) + ] + + +def assert_can_mark_original_proposals_applied(plans: list[dict[str, Any]]) -> None: + blocked = collect_blocked_fragments(plans) + unresolved = collect_unresolved_design_decisions(plans) + if blocked or unresolved: + raise ValueError( + "cannot mark original proposals applied for a partial packet: " + f"{len(blocked)} blocked fragment(s), {len(unresolved)} unresolved design decision(s)" + ) + + def build_generated_counts_sql(rows: dict[str, list[dict[str, Any]]]) -> str: reasoning_tool_ids = [row["id"] for row in rows["reasoning_tools"]] claim_ids = [row["id"] for row in rows["claims"]] @@ -105,6 +134,35 @@ def build_generated_counts_sql(rows: dict[str, list[dict[str, Any]]]) -> str: """ +def build_mark_original_proposals_sql(plans: list[dict[str, Any]], *, commit: bool, applied_by_handle: str) -> str: + proposal_ids = [str(plan.get("proposal_id")) for plan in plans if plan.get("proposal_id")] + if not proposal_ids: + raise ValueError("cannot mark original proposals applied without proposal ids") + terminator = "commit;" if commit else "rollback;" + return f"""begin; + +do $$ +declare + flipped int; +begin + update kb_stage.kb_proposals + set status = 'applied', + applied_by_handle = {creation_plan._sql_literal(applied_by_handle)}, + applied_at = now(), + updated_at = now() + where id in (select id from {_uuid_values(proposal_ids)}) + and status = 'approved'; + + get diagnostics flipped = row_count; + if flipped <> {len(proposal_ids)} then + raise exception 'rich proposal packet ledger flip affected % row(s), expected {len(proposal_ids)}; original proposals were not all approved', flipped; + end if; +end $$; + +{terminator} +""" + + def build_preflight_sql(plans: list[dict[str, Any]], rows: dict[str, list[dict[str, Any]]]) -> str: proposal_ids = [str(plan.get("proposal_id")) for plan in plans if plan.get("proposal_id")] required_claims = collect_required_existing_claims(rows) @@ -148,13 +206,31 @@ select {expected['reasoning_tools']}::int as expected_reasoning_tools, {build_generated_counts_sql(rows)}""" -def build_write_sql(plans: list[dict[str, Any]], *, commit: bool) -> str: +def build_write_sql( + plans: list[dict[str, Any]], + *, + commit: bool, + mark_original_proposals_applied: bool, + applied_by_handle: str, +) -> str: sql = "\n\n".join(plan.get("rollback_rehearsal_sql", "") for plan in plans) terminator = "commit;" if commit else "rollback;" - return sql.replace("rollback;", terminator) + write_sql = sql.replace("rollback;", terminator) + if mark_original_proposals_applied: + write_sql = ( + write_sql.rstrip() + + "\n\n-- Full-coverage packet ledger update: mark original approved proposal(s) applied only after generated rows exist.\n" + + build_mark_original_proposals_sql(plans, commit=commit, applied_by_handle=applied_by_handle) + ) + return write_sql -def build_postflight_sql(rows: dict[str, list[dict[str, Any]]]) -> str: +def build_postflight_sql( + rows: dict[str, list[dict[str, Any]]], + *, + proposal_ids: list[str], + include_original_proposal_readback: bool, +) -> str: reasoning_tool_ids = [row["id"] for row in rows["reasoning_tools"]] claim_ids = [row["id"] for row in rows["claims"]] source_ids = [row["id"] for row in rows["sources"]] @@ -192,10 +268,24 @@ select id::text, superseded_by::text from public.claims where superseded_by in (select id from {_uuid_values(claim_ids)}) order by id; +""" + ( + f""" +select id::text, status, applied_by_handle, applied_at +from kb_stage.kb_proposals +where id in (select id from {_uuid_values(proposal_ids)}) +order by id; """ + if include_original_proposal_readback + else "" + ) -def build_delete_rollback_sql(rows: dict[str, list[dict[str, Any]]]) -> str: +def build_delete_rollback_sql( + rows: dict[str, list[dict[str, Any]]], + *, + proposal_ids: list[str], + restore_original_proposals_approved: bool, +) -> str: reasoning_tool_ids = [row["id"] for row in rows["reasoning_tools"]] claim_ids = [row["id"] for row in rows["claims"]] source_ids = [row["id"] for row in rows["sources"]] @@ -226,42 +316,97 @@ where id in (select id from {_uuid_values(claim_ids)}); delete from public.reasoning_tools where id in (select id from {_uuid_values(reasoning_tool_ids)}); +{build_restore_original_proposals_sql(proposal_ids) if restore_original_proposals_approved else ""} + commit; """ -def build_packet(plan_path: Path, *, emit_commit_sql: bool) -> dict[str, Any]: +def build_restore_original_proposals_sql(proposal_ids: list[str]) -> str: + if not proposal_ids: + return "" + return f"""do $$ +declare + restored int; +begin + update kb_stage.kb_proposals + set status = 'approved', + applied_by_handle = null, + applied_by_agent_id = null, + applied_at = null, + updated_at = now() + where id in (select id from {_uuid_values(proposal_ids)}) + and status = 'applied'; + + get diagnostics restored = row_count; + if restored <> {len(proposal_ids)} then + raise exception 'rich proposal packet ledger rollback restored % row(s), expected {len(proposal_ids)}; original proposals were not all applied', restored; + end if; +end $$;""" + + +def build_packet( + plan_path: Path, + *, + emit_commit_sql: bool, + mark_original_proposals_applied: bool = False, + applied_by_handle: str = "codex-packet", +) -> dict[str, Any]: plans = load_creation_plans(plan_path) + if mark_original_proposals_applied: + assert_can_mark_original_proposals_applied(plans) rows = collect_rows(plans) + proposal_ids = [str(plan.get("proposal_id")) for plan in plans if plan.get("proposal_id")] + remaining_blocked_fragments = collect_blocked_fragments(plans) + unresolved_design_decisions = collect_unresolved_design_decisions(plans) + claim_ceiling = ( + "Production apply packet for full covered proposal contract; authorized commit SQL marks original proposal(s) " + "applied after generated rows are written." + if mark_original_proposals_applied + else ( + "Production apply packet for mapped supported subset only; original rich proposals are not marked applied " + "unless the packet fully covers the approved reasoning-tool/claim/source contract." + ) + ) return { "packet_version": 1, "plan_path": str(plan_path), - "proposal_ids": [plan.get("proposal_id") for plan in plans], - "claim_ceiling": ( - "Production apply packet for mapped supported subset only; original rich proposals are not marked applied " - "unless the packet fully covers the approved reasoning-tool/claim/source contract." - ), + "proposal_ids": proposal_ids, + "claim_ceiling": claim_ceiling, "row_counts": {key: len(value) for key, value in rows.items()}, "required_existing_claims": collect_required_existing_claims(rows), - "remaining_blocked_fragments": [ - fragment - for plan in plans - for fragment in plan.get("blocked_fragments", []) - if isinstance(fragment, dict) - ], - "unresolved_design_decisions": [ - item - for plan in plans - for item in plan.get("unresolved_design_decisions", []) - if isinstance(item, dict) - ], - "marks_original_proposals_applied": False, + "remaining_blocked_fragments": remaining_blocked_fragments, + "unresolved_design_decisions": unresolved_design_decisions, + "marks_original_proposals_applied": mark_original_proposals_applied, + "applied_by_handle": applied_by_handle if mark_original_proposals_applied else None, "sql": { "preflight": build_preflight_sql(plans, rows), - "apply_rollback_rehearsal": build_write_sql(plans, commit=False), - "apply_commit": build_write_sql(plans, commit=True) if emit_commit_sql else None, - "postflight": build_postflight_sql(rows), - "delete_rollback": build_delete_rollback_sql(rows), + "apply_rollback_rehearsal": build_write_sql( + plans, + commit=False, + mark_original_proposals_applied=mark_original_proposals_applied, + applied_by_handle=applied_by_handle, + ), + "apply_commit": ( + build_write_sql( + plans, + commit=True, + mark_original_proposals_applied=mark_original_proposals_applied, + applied_by_handle=applied_by_handle, + ) + if emit_commit_sql + else None + ), + "postflight": build_postflight_sql( + rows, + proposal_ids=proposal_ids, + include_original_proposal_readback=mark_original_proposals_applied, + ), + "delete_rollback": build_delete_rollback_sql( + rows, + proposal_ids=proposal_ids, + restore_original_proposals_approved=mark_original_proposals_applied, + ), }, } @@ -287,12 +432,30 @@ def parse_args(argv: list[str]) -> argparse.Namespace: parser.add_argument("--plan-json", required=True, type=Path, help="mapped rich proposal creation plan JSON") parser.add_argument("--output-dir", type=Path, help="directory to write packet files") parser.add_argument("--emit-commit-sql", action="store_true", help="also write the authorized COMMIT SQL file") + parser.add_argument( + "--mark-original-proposals-applied", + action="store_true", + help="include guarded ledger SQL to mark original approved proposals applied; requires full coverage", + ) + parser.add_argument( + "--applied-by-handle", + default="codex-packet", + help="applied_by_handle value for guarded full-coverage ledger SQL", + ) 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(args.plan_json, emit_commit_sql=args.emit_commit_sql) + try: + packet = build_packet( + args.plan_json, + emit_commit_sql=args.emit_commit_sql, + mark_original_proposals_applied=args.mark_original_proposals_applied, + applied_by_handle=args.applied_by_handle, + ) + except ValueError as exc: + raise SystemExit(str(exc)) from exc 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)) diff --git a/tests/test_kb_rich_proposal_apply_packet.py b/tests/test_kb_rich_proposal_apply_packet.py index 90f54ed..38f459f 100644 --- a/tests/test_kb_rich_proposal_apply_packet.py +++ b/tests/test_kb_rich_proposal_apply_packet.py @@ -6,13 +6,15 @@ import json import sys from pathlib import Path +import pytest + REPO_ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO_ROOT / "scripts")) import kb_rich_proposal_apply_packet as packet # noqa: E402 -def _plan_file(tmp_path: Path) -> Path: +def _plan_file(tmp_path: Path, *, blocked: bool = True) -> Path: plan = { "creation_plans": [ { @@ -52,8 +54,8 @@ def _plan_file(tmp_path: Path) -> Path: } ], }, - "blocked_fragments": [{"kind": "edge", "reasons": ["still blocked"]}], - "unresolved_design_decisions": [{"decision": "non_claim_target"}], + "blocked_fragments": [{"kind": "edge", "reasons": ["still blocked"]}] if blocked else [], + "unresolved_design_decisions": [{"decision": "non_claim_target"}] if blocked else [], } ] } @@ -100,3 +102,31 @@ def test_write_packet_files(tmp_path: Path): summary = json.loads((output_dir / "production-apply-packet.json").read_text()) assert "sql" not in summary assert summary["proposal_ids"] == ["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"] + + +def test_mark_original_proposal_applied_rejects_partial_packet(tmp_path: Path): + with pytest.raises(ValueError, match="partial packet"): + packet.build_packet( + _plan_file(tmp_path, blocked=True), + emit_commit_sql=True, + mark_original_proposals_applied=True, + ) + + +def test_mark_original_proposal_applied_for_full_packet(tmp_path: Path): + result = packet.build_packet( + _plan_file(tmp_path, blocked=False), + emit_commit_sql=True, + mark_original_proposals_applied=True, + applied_by_handle="codex-test", + ) + + assert result["marks_original_proposals_applied"] is True + assert result["applied_by_handle"] == "codex-test" + assert "status = 'applied'" in result["sql"]["apply_commit"] + assert "applied_by_handle = 'codex-test'" in result["sql"]["apply_commit"] + assert "expected 1; original proposals were not all approved" in result["sql"]["apply_commit"] + assert "rollback;" in result["sql"]["apply_rollback_rehearsal"] + assert "from kb_stage.kb_proposals" in result["sql"]["postflight"] + assert "status = 'approved'" in result["sql"]["delete_rollback"] + assert "original proposals were not all applied" in result["sql"]["delete_rollback"]