Add Leo authorized apply session plan
Some checks are pending
CI / lint-and-test (push) Waiting to run
Some checks are pending
CI / lint-and-test (push) Waiting to run
This commit is contained in:
parent
17d0f1f71a
commit
4662254899
7 changed files with 894 additions and 3 deletions
|
|
@ -76,6 +76,8 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
|
||||||
- Working Leo authorized-apply readiness verifier JSON: `docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.json`
|
- Working Leo authorized-apply readiness verifier JSON: `docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.json`
|
||||||
- Working Leo authorized apply operator runbook, not executed: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
- Working Leo authorized apply operator runbook, not executed: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
||||||
- Working Leo authorized apply operator runbook JSON: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.json`
|
- Working Leo authorized apply operator runbook JSON: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.json`
|
||||||
|
- Working Leo authorized apply session plan, not executed: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-session-plan-current.md`
|
||||||
|
- Working Leo authorized apply session plan JSON: `docs/reports/leo-working-state-20260709/working-leo-authorized-apply-session-plan-current.json`
|
||||||
- Working Leo live production preflight baseline, read-only: `docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
- Working Leo live production preflight baseline, read-only: `docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
||||||
- Working Leo live production preflight baseline JSON: `docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.json`
|
- Working Leo live production preflight baseline JSON: `docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.json`
|
||||||
- Working Leo production apply receipt template, not executed: `docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-template-current.md`
|
- Working Leo production apply receipt template, not executed: `docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-template-current.md`
|
||||||
|
|
@ -128,6 +130,7 @@ Use this file before making status claims. Prefer fresh VPS/GCP readbacks when c
|
||||||
- The full integrated packet set is now clone-proven in production dependency order: mapped base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers applied together in `teleo_integrated_rehearsal_20260710`, then rolled back in reverse order; production stayed unchanged and the disposable clone/temp files were removed.
|
- The full integrated packet set is now clone-proven in production dependency order: mapped base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers applied together in `teleo_integrated_rehearsal_20260710`, then rolled back in reverse order; production stayed unchanged and the disposable clone/temp files were removed.
|
||||||
- The authorized-apply readiness verifier now passes: packet files exist and hash, apply/rollback order matches the manifest, expected counts match, clone apply/rollback markers are ordered, clone cleanup is proven, service stayed stable, and `production_apply_executed=false`.
|
- The authorized-apply readiness verifier now passes: packet files exist and hash, apply/rollback order matches the manifest, expected counts match, clone apply/rollback markers are ordered, clone cleanup is proven, service stayed stable, and `production_apply_executed=false`.
|
||||||
- The authorized apply operator runbook is generated and ready-not-executed: it gives preflight/apply/postflight/rollback command templates in manifest order, requires `TELEO_DATABASE_URL`, and now also includes a post-apply regression command bundle plus required production-apply receipt fields and an offline receipt validator. It still does not authorize or execute production SQL.
|
- The authorized apply operator runbook is generated and ready-not-executed: it gives preflight/apply/postflight/rollback command templates in manifest order, requires `TELEO_DATABASE_URL`, and now also includes a post-apply regression command bundle plus required production-apply receipt fields and an offline receipt validator. It still does not authorize or execute production SQL.
|
||||||
|
- The authorized apply session plan is generated and ready-not-executed: it maps concrete output log paths for pre-apply validation, preflight, apply, postflight, post-apply regression, service readback, cleanup readback, receipt validation, and rollback. Apply and rollback steps require explicit authorization; non-apply steps are marked non-mutating.
|
||||||
- The live production preflight baseline now passes through the read-only collector: `5/5` preflight files executed on the VPS with `begin transaction read only`, `mutates_production_db=false`, `applies_production_packet=false`, and `production_apply_executed=false`. Current production still has generated base rows `0/0/0/0`, Helmer rows `0/0/0/0/0`, no generated governance/concept tables, and dependent Rio/cross-surface/governance base rows absent before any apply, as expected.
|
- The live production preflight baseline now passes through the read-only collector: `5/5` preflight files executed on the VPS with `begin transaction read only`, `mutates_production_db=false`, `applies_production_packet=false`, and `production_apply_executed=false`. Current production still has generated base rows `0/0/0/0`, Helmer rows `0/0/0/0/0`, no generated governance/concept tables, and dependent Rio/cross-surface/governance base rows absent before any apply, as expected.
|
||||||
- The production apply receipt template is generated but intentionally invalid as a final receipt: `production_apply_executed=false`, `valid_production_receipt=false`, and it names the fields that must only be filled after authorized apply execution (`explicit_authorization_record`, `operator_identity`, `apply_output_paths`, `postflight_output_paths`, `actual_after_apply_counts`, `telegram_or_handler_regression_paths`, `service_readback`, `cleanup_readback`).
|
- The production apply receipt template is generated but intentionally invalid as a final receipt: `production_apply_executed=false`, `valid_production_receipt=false`, and it names the fields that must only be filled after authorized apply execution (`explicit_authorization_record`, `operator_identity`, `apply_output_paths`, `postflight_output_paths`, `actual_after_apply_counts`, `telegram_or_handler_regression_paths`, `service_readback`, `cleanup_readback`).
|
||||||
- The production-apply receipt validator currently reports `missing_receipt`, which is correct because no production apply has been authorized or executed.
|
- The production-apply receipt validator currently reports `missing_receipt`, which is correct because no production apply has been authorized or executed.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,398 @@
|
||||||
|
{
|
||||||
|
"all_apply_steps_require_authorization": true,
|
||||||
|
"all_rollback_steps_require_authorization": true,
|
||||||
|
"apply_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/production-apply-authorized-commit.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-apply-mapped-rich-base.log",
|
||||||
|
"id": "apply:mapped-rich-base",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-apply-mapped-rich-base.log",
|
||||||
|
"packet_id": "mapped-rich-base",
|
||||||
|
"phase": "apply",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/production-apply-authorized-commit.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/cross-surface-apply-authorized-commit.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-apply-cross-surface-anchor.log",
|
||||||
|
"id": "apply:cross-surface-anchor",
|
||||||
|
"index": 2,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-apply-cross-surface-anchor.log",
|
||||||
|
"packet_id": "cross-surface-anchor",
|
||||||
|
"phase": "apply",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/cross-surface-apply-authorized-commit.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/rio-strategy-apply-authorized-commit.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-apply-rio-strategy-context.log",
|
||||||
|
"id": "apply:rio-strategy-context",
|
||||||
|
"index": 3,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-apply-rio-strategy-context.log",
|
||||||
|
"packet_id": "rio-strategy-context",
|
||||||
|
"phase": "apply",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/rio-strategy-apply-authorized-commit.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/governance-concept-apply-authorized-commit.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-apply-governance-concept-schema.log",
|
||||||
|
"id": "apply:governance-concept-schema",
|
||||||
|
"index": 4,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-apply-governance-concept-schema.log",
|
||||||
|
"packet_id": "governance-concept-schema",
|
||||||
|
"phase": "apply",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/governance-concept-apply-authorized-commit.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-apply-helmer-7powers.log",
|
||||||
|
"id": "apply:helmer-7powers",
|
||||||
|
"index": 5,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-apply-helmer-7powers.log",
|
||||||
|
"packet_id": "helmer-7powers",
|
||||||
|
"phase": "apply",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/helmer-7powers-production-apply-authorized-commit.sql"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authorization_boundary": "Do not run apply commands unless the operator explicitly authorizes production DB apply for the integrated Working Leo packet set in dependency order.",
|
||||||
|
"authorization_required_before_apply_steps": true,
|
||||||
|
"claim_ceiling": "This is an apply-session plan only. It does not execute SQL, does not authorize production apply, and does not prove canonical rows were changed.",
|
||||||
|
"cleanup_readback_step": {
|
||||||
|
"command": "docker exec -i teleo-pg psql -U postgres -d teleo -At -q -c \"select datname from pg_database where datname ~ '(rehearsal|clone|staging)' order by datname\" | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-cleanup-readback.log",
|
||||||
|
"id": "cleanup_readback",
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-cleanup-readback.log",
|
||||||
|
"phase": "post_apply_cleanup_readback",
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
"expected_after_apply_counts": {
|
||||||
|
"claim_concept_map_links": 1,
|
||||||
|
"claim_edges": 18,
|
||||||
|
"claim_evidence": 34,
|
||||||
|
"claim_governance_gate_links": 2,
|
||||||
|
"claims": 12,
|
||||||
|
"concept_maps": 1,
|
||||||
|
"cross_surface_anchor_updates": 1,
|
||||||
|
"helmer_ledger_rows_marked_applied": 1,
|
||||||
|
"reasoning_tools": 1,
|
||||||
|
"rio_strategy_anchors": 5,
|
||||||
|
"rio_strategy_nodes": 2,
|
||||||
|
"sources": 28
|
||||||
|
},
|
||||||
|
"generated_at_utc": "2026-07-10T01:49:46.485415+00:00",
|
||||||
|
"mode": "authorized_apply_session_plan_not_executed",
|
||||||
|
"non_apply_steps_do_not_mutate_db": true,
|
||||||
|
"output_dir": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts",
|
||||||
|
"post_apply_regression_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && .venv/bin/python scripts/run_leo_direct_claim_handler_suite.py | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-01-direct_claim_handler_suite.log",
|
||||||
|
"expected_artifact": "docs/reports/leo-working-state-20260709/telegram-handler-direct-claim-suite-current.json",
|
||||||
|
"id": "direct_claim_handler_suite",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-01-direct_claim_handler_suite.log",
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"posts_to_telegram": false,
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && .venv/bin/python scripts/working_leo_open_ended_benchmark.py --results-json docs/reports/leo-working-state-20260709/telegram-handler-direct-claim-suite-current.json --include-direct-claim-followups --out docs/reports/leo-working-state-20260709/telegram-handler-direct-claim-suite-score-current.json --markdown-out docs/reports/leo-working-state-20260709/telegram-handler-direct-claim-suite-score-current.md | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-02-direct_claim_strict_score.log",
|
||||||
|
"expected_artifact": "docs/reports/leo-working-state-20260709/telegram-handler-direct-claim-suite-score-current.md",
|
||||||
|
"id": "direct_claim_strict_score",
|
||||||
|
"index": 2,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-02-direct_claim_strict_score.log",
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"posts_to_telegram": false,
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && .venv/bin/python -m pytest tests/test_working_leo_open_ended_benchmark.py tests/test_hermes_leoclean_skill_surfaces.py tests/test_build_working_leo_authorized_apply_runbook.py -q | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-03-focused_local_regression_tests.log",
|
||||||
|
"expected_artifact": "terminal pytest output",
|
||||||
|
"id": "focused_local_regression_tests",
|
||||||
|
"index": 3,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-03-focused_local_regression_tests.log",
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"posts_to_telegram": false,
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && systemctl show leoclean-gateway.service -p ActiveState -p SubState -p MainPID -p NRestarts -p ExecMainStartTimestamp --no-pager | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-04-gateway_service_readback.log",
|
||||||
|
"expected_artifact": "retained service readback with ActiveState=active and NRestarts reviewed",
|
||||||
|
"id": "gateway_service_readback",
|
||||||
|
"index": 4,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-04-gateway_service_readback.log",
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"posts_to_telegram": false,
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && .venv/bin/python scripts/validate_working_leo_production_receipt.py --receipt docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-current.json | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-05-production_receipt_validator.log",
|
||||||
|
"expected_artifact": "docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-validation-current.md",
|
||||||
|
"id": "production_receipt_validator",
|
||||||
|
"index": 5,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-05-production_receipt_validator.log",
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"posts_to_telegram": false,
|
||||||
|
"requires_authorization": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"postflight_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/production-postflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-postflight-mapped-rich-base.log",
|
||||||
|
"id": "postflight:mapped-rich-base",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-postflight-mapped-rich-base.log",
|
||||||
|
"packet_id": "mapped-rich-base",
|
||||||
|
"phase": "postflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/production-postflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/cross-surface-postflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-postflight-cross-surface-anchor.log",
|
||||||
|
"id": "postflight:cross-surface-anchor",
|
||||||
|
"index": 2,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-postflight-cross-surface-anchor.log",
|
||||||
|
"packet_id": "cross-surface-anchor",
|
||||||
|
"phase": "postflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/cross-surface-postflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/rio-strategy-postflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-postflight-rio-strategy-context.log",
|
||||||
|
"id": "postflight:rio-strategy-context",
|
||||||
|
"index": 3,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-postflight-rio-strategy-context.log",
|
||||||
|
"packet_id": "rio-strategy-context",
|
||||||
|
"phase": "postflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/rio-strategy-postflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/governance-concept-postflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-postflight-governance-concept-schema.log",
|
||||||
|
"id": "postflight:governance-concept-schema",
|
||||||
|
"index": 4,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-postflight-governance-concept-schema.log",
|
||||||
|
"packet_id": "governance-concept-schema",
|
||||||
|
"phase": "postflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/governance-concept-postflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/helmer-7powers-production-postflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-postflight-helmer-7powers.log",
|
||||||
|
"id": "postflight:helmer-7powers",
|
||||||
|
"index": 5,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-postflight-helmer-7powers.log",
|
||||||
|
"packet_id": "helmer-7powers",
|
||||||
|
"phase": "postflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/helmer-7powers-production-postflight.sql"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pre_apply_validation_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && .venv/bin/python scripts/collect_working_leo_production_preflight.py --execute --transport ssh --out docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.json --markdown-out docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/pre-apply-validation-01-readonly_production_preflight_collector.log",
|
||||||
|
"expected_artifact": "docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md",
|
||||||
|
"id": "readonly_production_preflight_collector",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/pre-apply-validation-01-readonly_production_preflight_collector.log",
|
||||||
|
"phase": "pre_apply_validation",
|
||||||
|
"requires_authorization": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preflight_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/production-preflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-preflight-mapped-rich-base.log",
|
||||||
|
"id": "preflight:mapped-rich-base",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-preflight-mapped-rich-base.log",
|
||||||
|
"packet_id": "mapped-rich-base",
|
||||||
|
"phase": "preflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/production-preflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/cross-surface-preflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-preflight-cross-surface-anchor.log",
|
||||||
|
"id": "preflight:cross-surface-anchor",
|
||||||
|
"index": 2,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-preflight-cross-surface-anchor.log",
|
||||||
|
"packet_id": "cross-surface-anchor",
|
||||||
|
"phase": "preflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/cross-surface-preflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/rio-strategy-preflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-preflight-rio-strategy-context.log",
|
||||||
|
"id": "preflight:rio-strategy-context",
|
||||||
|
"index": 3,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-preflight-rio-strategy-context.log",
|
||||||
|
"packet_id": "rio-strategy-context",
|
||||||
|
"phase": "preflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/rio-strategy-preflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/governance-concept-preflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-preflight-governance-concept-schema.log",
|
||||||
|
"id": "preflight:governance-concept-schema",
|
||||||
|
"index": 4,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-preflight-governance-concept-schema.log",
|
||||||
|
"packet_id": "governance-concept-schema",
|
||||||
|
"phase": "preflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/governance-concept-preflight.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/helmer-7powers-production-preflight.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-preflight-helmer-7powers.log",
|
||||||
|
"id": "preflight:helmer-7powers",
|
||||||
|
"index": 5,
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-preflight-helmer-7powers.log",
|
||||||
|
"packet_id": "helmer-7powers",
|
||||||
|
"phase": "preflight",
|
||||||
|
"requires_authorization": false,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/helmer-7powers-production-preflight.sql"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"production_apply_executed": false,
|
||||||
|
"receipt_field_sources_after_execution": {
|
||||||
|
"apply_output_paths": [
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-apply-mapped-rich-base.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-apply-cross-surface-anchor.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-apply-rio-strategy-context.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-apply-governance-concept-schema.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-apply-helmer-7powers.log"
|
||||||
|
],
|
||||||
|
"cleanup_readback": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-cleanup-readback.log",
|
||||||
|
"postflight_output_paths": [
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-postflight-mapped-rich-base.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-postflight-cross-surface-anchor.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-postflight-rio-strategy-context.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-postflight-governance-concept-schema.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-postflight-helmer-7powers.log"
|
||||||
|
],
|
||||||
|
"preflight_output_paths": [
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-preflight-mapped-rich-base.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-preflight-cross-surface-anchor.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-preflight-rio-strategy-context.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-preflight-governance-concept-schema.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-preflight-helmer-7powers.log"
|
||||||
|
],
|
||||||
|
"rollback_packet_paths": [
|
||||||
|
"docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql",
|
||||||
|
"docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql",
|
||||||
|
"docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql",
|
||||||
|
"docs/reports/leo-working-state-20260709/cross-surface-delete-rollback.sql",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-delete-rollback.sql"
|
||||||
|
],
|
||||||
|
"service_readback": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-service-readback.log",
|
||||||
|
"telegram_or_handler_regression_paths": [
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-01-direct_claim_handler_suite.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-02-direct_claim_strict_score.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-03-focused_local_regression_tests.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-04-gateway_service_readback.log",
|
||||||
|
"docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-05-production_receipt_validator.log"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"receipt_template_must_fill_after_authorized_apply": [
|
||||||
|
"explicit_authorization_record",
|
||||||
|
"operator_identity",
|
||||||
|
"apply_output_paths",
|
||||||
|
"postflight_output_paths",
|
||||||
|
"actual_after_apply_counts",
|
||||||
|
"telegram_or_handler_regression_paths",
|
||||||
|
"service_readback",
|
||||||
|
"cleanup_readback"
|
||||||
|
],
|
||||||
|
"receipt_template_path": "docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-template-current.json",
|
||||||
|
"receipt_validation_step": {
|
||||||
|
"command": ".venv/bin/python scripts/validate_working_leo_production_receipt.py --receipt docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-current.json | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/receipt-validation.log",
|
||||||
|
"id": "receipt_validation",
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/receipt-validation.log",
|
||||||
|
"phase": "receipt_validation",
|
||||||
|
"requires_authorization": false
|
||||||
|
},
|
||||||
|
"rollback_steps": [
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-rollback-helmer-7powers.log",
|
||||||
|
"id": "rollback:helmer-7powers",
|
||||||
|
"index": 1,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-rollback-helmer-7powers.log",
|
||||||
|
"packet_id": "helmer-7powers",
|
||||||
|
"phase": "rollback",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-rollback-governance-concept-schema.log",
|
||||||
|
"id": "rollback:governance-concept-schema",
|
||||||
|
"index": 2,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-rollback-governance-concept-schema.log",
|
||||||
|
"packet_id": "governance-concept-schema",
|
||||||
|
"phase": "rollback",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-rollback-rio-strategy-context.log",
|
||||||
|
"id": "rollback:rio-strategy-context",
|
||||||
|
"index": 3,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-rollback-rio-strategy-context.log",
|
||||||
|
"packet_id": "rio-strategy-context",
|
||||||
|
"phase": "rollback",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/cross-surface-delete-rollback.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-rollback-cross-surface-anchor.log",
|
||||||
|
"id": "rollback:cross-surface-anchor",
|
||||||
|
"index": 4,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-rollback-cross-surface-anchor.log",
|
||||||
|
"packet_id": "cross-surface-anchor",
|
||||||
|
"phase": "rollback",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/cross-surface-delete-rollback.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mkdir -p docs/reports/leo-working-state-20260709/production-apply-session-artifacts && psql \"$TELEO_DATABASE_URL\" -v ON_ERROR_STOP=1 -f docs/reports/leo-working-state-20260709/production-delete-rollback.sql | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-rollback-mapped-rich-base.log",
|
||||||
|
"id": "rollback:mapped-rich-base",
|
||||||
|
"index": 5,
|
||||||
|
"mutates_production_db": true,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-rollback-mapped-rich-base.log",
|
||||||
|
"packet_id": "mapped-rich-base",
|
||||||
|
"phase": "rollback",
|
||||||
|
"requires_authorization": true,
|
||||||
|
"source_sql": "docs/reports/leo-working-state-20260709/production-delete-rollback.sql"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"runbook_path": "docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.json",
|
||||||
|
"service_readback_step": {
|
||||||
|
"command": "systemctl show leoclean-gateway.service -p ActiveState -p SubState -p MainPID -p NRestarts -p ExecMainStartTimestamp --no-pager | tee docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-service-readback.log",
|
||||||
|
"id": "service_readback",
|
||||||
|
"mutates_production_db": false,
|
||||||
|
"output_path": "docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-service-readback.log",
|
||||||
|
"phase": "post_apply_service_readback",
|
||||||
|
"requires_authorization": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
# Working Leo Authorized Apply Session Plan
|
||||||
|
|
||||||
|
Generated UTC: `2026-07-10T01:49:46.485415+00:00`
|
||||||
|
Mode: `authorized_apply_session_plan_not_executed`
|
||||||
|
Production apply executed: `False`
|
||||||
|
All apply steps require authorization: `True`
|
||||||
|
All rollback steps require authorization: `True`
|
||||||
|
Non-apply steps do not mutate DB: `True`
|
||||||
|
|
||||||
|
## Authorization Boundary
|
||||||
|
|
||||||
|
Do not run apply commands unless the operator explicitly authorizes production DB apply for the integrated Working Leo packet set in dependency order.
|
||||||
|
|
||||||
|
## Pre-Apply Validation
|
||||||
|
|
||||||
|
- `readonly_production_preflight_collector` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/pre-apply-validation-01-readonly_production_preflight_collector.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
## Preflight
|
||||||
|
|
||||||
|
- `preflight:mapped-rich-base` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-preflight-mapped-rich-base.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `preflight:cross-surface-anchor` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-preflight-cross-surface-anchor.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `preflight:rio-strategy-context` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-preflight-rio-strategy-context.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `preflight:governance-concept-schema` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-preflight-governance-concept-schema.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `preflight:helmer-7powers` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-preflight-helmer-7powers.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
## Apply
|
||||||
|
|
||||||
|
- `apply:mapped-rich-base` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-apply-mapped-rich-base.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `apply:cross-surface-anchor` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-apply-cross-surface-anchor.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `apply:rio-strategy-context` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-apply-rio-strategy-context.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `apply:governance-concept-schema` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-apply-governance-concept-schema.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `apply:helmer-7powers` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-apply-helmer-7powers.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
## Postflight
|
||||||
|
|
||||||
|
- `postflight:mapped-rich-base` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-postflight-mapped-rich-base.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `postflight:cross-surface-anchor` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-postflight-cross-surface-anchor.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `postflight:rio-strategy-context` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-postflight-rio-strategy-context.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `postflight:governance-concept-schema` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-postflight-governance-concept-schema.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `postflight:helmer-7powers` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-postflight-helmer-7powers.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
## Post-Apply Regression
|
||||||
|
|
||||||
|
- `direct_claim_handler_suite` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-01-direct_claim_handler_suite.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `direct_claim_strict_score` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-02-direct_claim_strict_score.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `focused_local_regression_tests` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-03-focused_local_regression_tests.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `gateway_service_readback` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-04-gateway_service_readback.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
- `production_receipt_validator` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-05-production_receipt_validator.log`
|
||||||
|
- mutates production DB: `False`
|
||||||
|
- requires authorization: `False`
|
||||||
|
## Rollback
|
||||||
|
|
||||||
|
- `rollback:helmer-7powers` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-rollback-helmer-7powers.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `rollback:governance-concept-schema` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-rollback-governance-concept-schema.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `rollback:rio-strategy-context` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-rollback-rio-strategy-context.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `rollback:cross-surface-anchor` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-rollback-cross-surface-anchor.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
- `rollback:mapped-rich-base` -> `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-rollback-mapped-rich-base.log`
|
||||||
|
- mutates production DB: `True`
|
||||||
|
- requires authorization: `True`
|
||||||
|
## Receipt Field Sources After Execution
|
||||||
|
|
||||||
|
- `preflight_output_paths`: `['docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-preflight-mapped-rich-base.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-preflight-cross-surface-anchor.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-preflight-rio-strategy-context.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-preflight-governance-concept-schema.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-preflight-helmer-7powers.log']`
|
||||||
|
- `apply_output_paths`: `['docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-apply-mapped-rich-base.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-apply-cross-surface-anchor.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-apply-rio-strategy-context.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-apply-governance-concept-schema.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-apply-helmer-7powers.log']`
|
||||||
|
- `postflight_output_paths`: `['docs/reports/leo-working-state-20260709/production-apply-session-artifacts/01-postflight-mapped-rich-base.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/02-postflight-cross-surface-anchor.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/03-postflight-rio-strategy-context.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/04-postflight-governance-concept-schema.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/05-postflight-helmer-7powers.log']`
|
||||||
|
- `telegram_or_handler_regression_paths`: `['docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-01-direct_claim_handler_suite.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-02-direct_claim_strict_score.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-03-focused_local_regression_tests.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-04-gateway_service_readback.log', 'docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-regression-05-production_receipt_validator.log']`
|
||||||
|
- `service_readback`: `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-service-readback.log`
|
||||||
|
- `cleanup_readback`: `docs/reports/leo-working-state-20260709/production-apply-session-artifacts/post-apply-cleanup-readback.log`
|
||||||
|
- `rollback_packet_paths`: `['docs/reports/leo-working-state-20260709/helmer-7powers-production-delete-rollback.sql', 'docs/reports/leo-working-state-20260709/governance-concept-delete-rollback.sql', 'docs/reports/leo-working-state-20260709/rio-strategy-delete-rollback.sql', 'docs/reports/leo-working-state-20260709/cross-surface-delete-rollback.sql', 'docs/reports/leo-working-state-20260709/production-delete-rollback.sql']`
|
||||||
|
|
||||||
|
## Claim Ceiling
|
||||||
|
|
||||||
|
This is an apply-session plan only. It does not execute SQL, does not authorize production apply, and does not prove canonical rows were changed.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Working Leo Current State - 2026-07-09
|
# Working Leo Current State - 2026-07-09
|
||||||
|
|
||||||
Generated UTC: `2026-07-10T01:46:00Z`
|
Generated UTC: `2026-07-10T01:51:09Z`
|
||||||
|
|
||||||
## Current Working Definition
|
## Current Working Definition
|
||||||
|
|
||||||
|
|
@ -142,6 +142,12 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
|
||||||
- production apply receipt schema now requires explicit authorization record, operator identity, git SHA, preflight/apply/postflight output paths, expected-vs-actual counts, regression paths, service readback, cleanup readback, rollback packet paths, and residual risks
|
- production apply receipt schema now requires explicit authorization record, operator identity, git SHA, preflight/apply/postflight output paths, expected-vs-actual counts, regression paths, service readback, cleanup readback, rollback packet paths, and residual risks
|
||||||
- offline receipt validator is installed and currently reports `missing_receipt`, as expected before any authorized production apply
|
- offline receipt validator is installed and currently reports `missing_receipt`, as expected before any authorized production apply
|
||||||
- generator does not connect to Postgres or run SQL; production apply still requires explicit authorization
|
- generator does not connect to Postgres or run SQL; production apply still requires explicit authorization
|
||||||
|
- Authorized apply session plan is now retained:
|
||||||
|
- `mode=authorized_apply_session_plan_not_executed`
|
||||||
|
- `production_apply_executed=false`
|
||||||
|
- planned output paths exist for pre-apply validation, preflight, apply, postflight, post-apply regression, service readback, cleanup readback, receipt validation, and rollback logs
|
||||||
|
- all apply steps and all rollback steps require explicit authorization
|
||||||
|
- non-apply steps are marked non-mutating, so the plan can be used to audit an apply window without itself changing production
|
||||||
- Live production preflight baseline is now retained:
|
- Live production preflight baseline is now retained:
|
||||||
- the collector ran on the VPS with `--transport local-docker`, `execute_requested=true`, `mutates_production_db=false`, `applies_production_packet=false`, `production_apply_executed=false`, and `readonly_transaction_wrapper=true`
|
- the collector ran on the VPS with `--transport local-docker`, `execute_requested=true`, `mutates_production_db=false`, `applies_production_packet=false`, `production_apply_executed=false`, and `readonly_transaction_wrapper=true`
|
||||||
- `5/5` preflight SQL files returned `ok=True`
|
- `5/5` preflight SQL files returned `ok=True`
|
||||||
|
|
@ -200,6 +206,7 @@ A working Leo, for Cory/m3taversal's current expectation, is a Telegram-facing a
|
||||||
- Integrated clone proof log: `outputs/rich-proposal-creation-plan-20260709/integrated-20260710/working-leo-integrated-clone-rehearsal-current.log`
|
- Integrated clone proof log: `outputs/rich-proposal-creation-plan-20260709/integrated-20260710/working-leo-integrated-clone-rehearsal-current.log`
|
||||||
- Authorized-apply readiness verifier: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.md`
|
- Authorized-apply readiness verifier: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.md`
|
||||||
- Authorized apply operator runbook: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
- Authorized apply operator runbook: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
||||||
|
- Authorized apply session plan: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-session-plan-current.md`
|
||||||
- Live production preflight baseline: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
- Live production preflight baseline: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
||||||
- Production apply receipt template: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-template-current.md`
|
- Production apply receipt template: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-template-current.md`
|
||||||
- Production apply receipt validation: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-validation-current.md`
|
- Production apply receipt validation: `work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-validation-current.md`
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Working Leo Execution Plan - 2026-07-09
|
# Working Leo Execution Plan - 2026-07-09
|
||||||
|
|
||||||
Claim ceiling: VPS Telegram memory/KB audit, full live-safe open-ended Telegram suite, full mixed-evidence Cory-style outcome/direct-claim sandbox benchmark, live VPS GatewayRunner no-context direct-claim suite, Telegram-to-`kb_stage` proposal staging, and strict existing-ID apply are working. The live VPS handler suite for exact `DC-01` through `DC-06` prompts strict-scores `6/6` after the latest VPS deploy and scorer refresh, with no Telegram post, no live profile write, no production DB apply, unchanged DB counts, temp profile cleanup, and unchanged gateway service state during the harness. The full prepared DB packet set is integrated-clone-proven in dependency order: mapped rich base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers. A read-only live production preflight baseline now passes `5/5`, and an authorized apply operator runbook is generated, but none of those packets are production-applied. GCP parity remains pending.
|
Claim ceiling: VPS Telegram memory/KB audit, full live-safe open-ended Telegram suite, full mixed-evidence Cory-style outcome/direct-claim sandbox benchmark, live VPS GatewayRunner no-context direct-claim suite, Telegram-to-`kb_stage` proposal staging, and strict existing-ID apply are working. The live VPS handler suite for exact `DC-01` through `DC-06` prompts strict-scores `6/6` after the latest VPS deploy and scorer refresh, with no Telegram post, no live profile write, no production DB apply, unchanged DB counts, temp profile cleanup, and unchanged gateway service state during the harness. The full prepared DB packet set is integrated-clone-proven in dependency order: mapped rich base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers. A read-only live production preflight baseline now passes `5/5`, an authorized apply operator runbook is generated, and an authorized apply session plan now maps every apply-window output path with authorization gates, but none of those packets are production-applied. GCP parity remains pending.
|
||||||
|
|
||||||
## WL-EXEC-01 - VPS Telegram-visible memory + KB audit
|
## WL-EXEC-01 - VPS Telegram-visible memory + KB audit
|
||||||
- Status: `done`
|
- Status: `done`
|
||||||
|
|
@ -96,7 +96,7 @@ Claim ceiling: VPS Telegram memory/KB audit, full live-safe open-ended Telegram
|
||||||
|
|
||||||
## WL-EXEC-06B - Integrated production-order packet rehearsal
|
## WL-EXEC-06B - Integrated production-order packet rehearsal
|
||||||
- Status: `done_integrated_clone_ready_not_executed`
|
- Status: `done_integrated_clone_ready_not_executed`
|
||||||
- Result: Applied the full prepared packet set in one disposable clone in dependency order: mapped base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers. Expected integrated footprint was `12` claims, `28` sources, `18` claim edges, `34` claim evidence rows, `1` reasoning tool, `2` Rio strategy nodes, `5` Rio strategy anchors, `1` concept map, `1` concept link, `2` governance links, one Helmer ledger row marked applied, and one cross-surface anchor update. Reverse rollback restored all generated rows/schema to zero/absent, restored the cross-surface anchor to the old claim, restored the Helmer ledger to `approved`, dropped the disposable DB, removed temp files, and left production unchanged. The apply-readiness verifier now passes over the retained manifest/files/logs with `ready_for_authorized_production_apply_packet=true`, `production_apply_executed=false`, and `production_apply_authorization_present=false`. The authorized apply runbook now emits preflight/apply/postflight/rollback command templates in manifest order, a read-only pre-apply production baseline collector, a post-apply regression command bundle, a required production-apply receipt schema, and an offline receipt validator with `status=ready_not_executed`. The live production preflight baseline ran through `begin transaction read only` and passed `5/5` with no production apply executed.
|
- Result: Applied the full prepared packet set in one disposable clone in dependency order: mapped base, cross-surface anchor, Rio strategy context, governance/concept schema, and Helmer 7 Powers. Expected integrated footprint was `12` claims, `28` sources, `18` claim edges, `34` claim evidence rows, `1` reasoning tool, `2` Rio strategy nodes, `5` Rio strategy anchors, `1` concept map, `1` concept link, `2` governance links, one Helmer ledger row marked applied, and one cross-surface anchor update. Reverse rollback restored all generated rows/schema to zero/absent, restored the cross-surface anchor to the old claim, restored the Helmer ledger to `approved`, dropped the disposable DB, removed temp files, and left production unchanged. The apply-readiness verifier now passes over the retained manifest/files/logs with `ready_for_authorized_production_apply_packet=true`, `production_apply_executed=false`, and `production_apply_authorization_present=false`. The authorized apply runbook now emits preflight/apply/postflight/rollback command templates in manifest order, a read-only pre-apply production baseline collector, a post-apply regression command bundle, a required production-apply receipt schema, and an offline receipt validator with `status=ready_not_executed`. The authorized apply session plan maps concrete output paths for pre-apply validation, preflight, apply, postflight, post-apply regression, service readback, cleanup readback, receipt validation, and rollback; apply and rollback steps require explicit authorization, non-apply steps are non-mutating, and `production_apply_executed=false`. The live production preflight baseline ran through `begin transaction read only` and passed `5/5` with no production apply executed.
|
||||||
- Next action: If production apply is explicitly authorized, use the generated runbook order, run every postflight SQL file, run the post-apply regression bundle, retain the production receipt, and then rerun any user-visible Telegram canary needed for the demo/meeting tier.
|
- Next action: If production apply is explicitly authorized, use the generated runbook order, run every postflight SQL file, run the post-apply regression bundle, retain the production receipt, and then rerun any user-visible Telegram canary needed for the demo/meeting tier.
|
||||||
- Not done condition: Production canonical rows/schema remain unapplied until explicit production apply authorization.
|
- Not done condition: Production canonical rows/schema remain unapplied until explicit production apply authorization.
|
||||||
- Evidence:
|
- Evidence:
|
||||||
|
|
@ -104,6 +104,7 @@ Claim ceiling: VPS Telegram memory/KB audit, full live-safe open-ended Telegram
|
||||||
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/integrated-20260710/working-leo-integrated-clone-rehearsal-current.log`
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/outputs/rich-proposal-creation-plan-20260709/integrated-20260710/working-leo-integrated-clone-rehearsal-current.log`
|
||||||
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.md`
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-apply-readiness-current.md`
|
||||||
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-runbook-current.md`
|
||||||
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-authorized-apply-session-plan-current.md`
|
||||||
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-preflight-current.md`
|
||||||
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-validation-current.md`
|
- `/Users/user/Documents/Codex/2026-07-09/019f34eb-d297-72d0-b7e2-b222d5515ab9-load/work/teleo-infra-main/docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-validation-current.md`
|
||||||
|
|
||||||
|
|
|
||||||
279
scripts/build_working_leo_authorized_apply_session_plan.py
Normal file
279
scripts/build_working_leo_authorized_apply_session_plan.py
Normal file
|
|
@ -0,0 +1,279 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Build a guarded Working Leo authorized-apply session plan.
|
||||||
|
|
||||||
|
This is not an executor. It converts the authorized apply runbook into an
|
||||||
|
operator session plan with output paths for every preflight, apply, postflight,
|
||||||
|
regression, service readback, cleanup readback, and receipt-validation step.
|
||||||
|
The goal is to make an authorized apply window auditable before it starts.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
REPORT_DIR = Path("docs/reports/leo-working-state-20260709")
|
||||||
|
DEFAULT_RUNBOOK = REPORT_DIR / "working-leo-authorized-apply-runbook-current.json"
|
||||||
|
DEFAULT_RECEIPT_TEMPLATE = REPORT_DIR / "working-leo-production-apply-receipt-template-current.json"
|
||||||
|
DEFAULT_OUT = REPORT_DIR / "working-leo-authorized-apply-session-plan-current.json"
|
||||||
|
DEFAULT_MARKDOWN_OUT = REPORT_DIR / "working-leo-authorized-apply-session-plan-current.md"
|
||||||
|
DEFAULT_OUTPUT_DIR = REPORT_DIR / "production-apply-session-artifacts"
|
||||||
|
|
||||||
|
|
||||||
|
def _load_json(path: Path) -> dict[str, Any]:
|
||||||
|
return json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
def _command_with_output(base_command: str, output_path: Path) -> str:
|
||||||
|
return f"mkdir -p {output_path.parent} && {base_command} | tee {output_path}"
|
||||||
|
|
||||||
|
|
||||||
|
def _phase_steps(runbook: dict[str, Any], phase_key: str, output_dir: Path) -> list[dict[str, Any]]:
|
||||||
|
steps: list[dict[str, Any]] = []
|
||||||
|
for index, entry in enumerate(runbook["phases"][phase_key], start=1):
|
||||||
|
packet_id = entry["packet_id"]
|
||||||
|
phase = entry["phase"]
|
||||||
|
output_path = output_dir / f"{index:02d}-{phase}-{packet_id}.log"
|
||||||
|
steps.append(
|
||||||
|
{
|
||||||
|
"index": index,
|
||||||
|
"id": f"{phase}:{packet_id}",
|
||||||
|
"phase": phase,
|
||||||
|
"packet_id": packet_id,
|
||||||
|
"source_sql": entry["path"],
|
||||||
|
"output_path": str(output_path),
|
||||||
|
"command": _command_with_output(entry["command_template"], output_path),
|
||||||
|
"mutates_production_db": phase in {"apply", "rollback"},
|
||||||
|
"requires_authorization": phase in {"apply", "rollback"},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return steps
|
||||||
|
|
||||||
|
|
||||||
|
def _pre_apply_steps(runbook: dict[str, Any], output_dir: Path) -> list[dict[str, Any]]:
|
||||||
|
steps: list[dict[str, Any]] = []
|
||||||
|
for index, command in enumerate(runbook.get("pre_apply_validation_commands", []), start=1):
|
||||||
|
output_path = output_dir / f"pre-apply-validation-{index:02d}-{command['id']}.log"
|
||||||
|
steps.append(
|
||||||
|
{
|
||||||
|
"index": index,
|
||||||
|
"id": command["id"],
|
||||||
|
"phase": "pre_apply_validation",
|
||||||
|
"output_path": str(output_path),
|
||||||
|
"command": _command_with_output(command["command_template"], output_path),
|
||||||
|
"expected_artifact": command["expected_artifact"],
|
||||||
|
"mutates_production_db": bool(command.get("mutates_production_db")),
|
||||||
|
"requires_authorization": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return steps
|
||||||
|
|
||||||
|
|
||||||
|
def _post_apply_steps(runbook: dict[str, Any], output_dir: Path) -> list[dict[str, Any]]:
|
||||||
|
steps: list[dict[str, Any]] = []
|
||||||
|
for index, command in enumerate(runbook.get("post_apply_regression_commands", []), start=1):
|
||||||
|
output_path = output_dir / f"post-apply-regression-{index:02d}-{command['id']}.log"
|
||||||
|
steps.append(
|
||||||
|
{
|
||||||
|
"index": index,
|
||||||
|
"id": command["id"],
|
||||||
|
"phase": "post_apply_regression",
|
||||||
|
"output_path": str(output_path),
|
||||||
|
"command": _command_with_output(command["command_template"], output_path),
|
||||||
|
"expected_artifact": command["expected_artifact"],
|
||||||
|
"mutates_production_db": bool(command.get("mutates_production_db")),
|
||||||
|
"posts_to_telegram": bool(command.get("posts_to_telegram")),
|
||||||
|
"requires_authorization": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return steps
|
||||||
|
|
||||||
|
|
||||||
|
def _receipt_fields_from_plan(plan: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
apply_outputs = [step["output_path"] for step in plan["apply_steps"]]
|
||||||
|
postflight_outputs = [step["output_path"] for step in plan["postflight_steps"]]
|
||||||
|
regression_outputs = [step["output_path"] for step in plan["post_apply_regression_steps"]]
|
||||||
|
return {
|
||||||
|
"preflight_output_paths": [step["output_path"] for step in plan["preflight_steps"]],
|
||||||
|
"apply_output_paths": apply_outputs,
|
||||||
|
"postflight_output_paths": postflight_outputs,
|
||||||
|
"telegram_or_handler_regression_paths": regression_outputs,
|
||||||
|
"service_readback": plan["service_readback_step"]["output_path"],
|
||||||
|
"cleanup_readback": plan["cleanup_readback_step"]["output_path"],
|
||||||
|
"rollback_packet_paths": [step["source_sql"] for step in plan["rollback_steps"]],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def build_plan(
|
||||||
|
*,
|
||||||
|
runbook_path: Path = DEFAULT_RUNBOOK,
|
||||||
|
receipt_template_path: Path = DEFAULT_RECEIPT_TEMPLATE,
|
||||||
|
output_dir: Path = DEFAULT_OUTPUT_DIR,
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
runbook = _load_json(runbook_path)
|
||||||
|
receipt_template = _load_json(receipt_template_path)
|
||||||
|
|
||||||
|
pre_apply = _pre_apply_steps(runbook, output_dir)
|
||||||
|
preflight = _phase_steps(runbook, "preflight_order", output_dir)
|
||||||
|
apply = _phase_steps(runbook, "apply_order", output_dir)
|
||||||
|
postflight = _phase_steps(runbook, "postflight_order", output_dir)
|
||||||
|
rollback = _phase_steps(runbook, "rollback_order", output_dir)
|
||||||
|
post_apply = _post_apply_steps(runbook, output_dir)
|
||||||
|
service_readback = {
|
||||||
|
"id": "service_readback",
|
||||||
|
"phase": "post_apply_service_readback",
|
||||||
|
"output_path": str(output_dir / "post-apply-service-readback.log"),
|
||||||
|
"command": (
|
||||||
|
"systemctl show leoclean-gateway.service "
|
||||||
|
"-p ActiveState -p SubState -p MainPID -p NRestarts -p ExecMainStartTimestamp --no-pager "
|
||||||
|
f"| tee {output_dir / 'post-apply-service-readback.log'}"
|
||||||
|
),
|
||||||
|
"mutates_production_db": False,
|
||||||
|
"requires_authorization": False,
|
||||||
|
}
|
||||||
|
cleanup_readback = {
|
||||||
|
"id": "cleanup_readback",
|
||||||
|
"phase": "post_apply_cleanup_readback",
|
||||||
|
"output_path": str(output_dir / "post-apply-cleanup-readback.log"),
|
||||||
|
"command": (
|
||||||
|
"docker exec -i teleo-pg psql -U postgres -d teleo -At -q "
|
||||||
|
"-c \"select datname from pg_database where datname ~ '(rehearsal|clone|staging)' order by datname\" "
|
||||||
|
f"| tee {output_dir / 'post-apply-cleanup-readback.log'}"
|
||||||
|
),
|
||||||
|
"mutates_production_db": False,
|
||||||
|
"requires_authorization": False,
|
||||||
|
}
|
||||||
|
receipt_validation = {
|
||||||
|
"id": "receipt_validation",
|
||||||
|
"phase": "receipt_validation",
|
||||||
|
"output_path": str(output_dir / "receipt-validation.log"),
|
||||||
|
"command": (
|
||||||
|
".venv/bin/python scripts/validate_working_leo_production_receipt.py "
|
||||||
|
"--receipt docs/reports/leo-working-state-20260709/working-leo-production-apply-receipt-current.json "
|
||||||
|
f"| tee {output_dir / 'receipt-validation.log'}"
|
||||||
|
),
|
||||||
|
"mutates_production_db": False,
|
||||||
|
"requires_authorization": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
plan: dict[str, Any] = {
|
||||||
|
"generated_at_utc": datetime.now(timezone.utc).isoformat(),
|
||||||
|
"mode": "authorized_apply_session_plan_not_executed",
|
||||||
|
"runbook_path": str(runbook_path),
|
||||||
|
"receipt_template_path": str(receipt_template_path),
|
||||||
|
"output_dir": str(output_dir),
|
||||||
|
"production_apply_executed": False,
|
||||||
|
"authorization_required_before_apply_steps": True,
|
||||||
|
"authorization_boundary": runbook["required_authorization_boundary"],
|
||||||
|
"expected_after_apply_counts": runbook["expected_after_apply_counts"],
|
||||||
|
"pre_apply_validation_steps": pre_apply,
|
||||||
|
"preflight_steps": preflight,
|
||||||
|
"apply_steps": apply,
|
||||||
|
"postflight_steps": postflight,
|
||||||
|
"post_apply_regression_steps": post_apply,
|
||||||
|
"service_readback_step": service_readback,
|
||||||
|
"cleanup_readback_step": cleanup_readback,
|
||||||
|
"receipt_validation_step": receipt_validation,
|
||||||
|
"rollback_steps": rollback,
|
||||||
|
"receipt_template_must_fill_after_authorized_apply": receipt_template[
|
||||||
|
"must_fill_after_authorized_apply"
|
||||||
|
],
|
||||||
|
"claim_ceiling": (
|
||||||
|
"This is an apply-session plan only. It does not execute SQL, does not authorize production apply, "
|
||||||
|
"and does not prove canonical rows were changed."
|
||||||
|
),
|
||||||
|
}
|
||||||
|
plan["receipt_field_sources_after_execution"] = _receipt_fields_from_plan(plan)
|
||||||
|
plan["all_apply_steps_require_authorization"] = all(step["requires_authorization"] for step in apply)
|
||||||
|
plan["all_rollback_steps_require_authorization"] = all(step["requires_authorization"] for step in rollback)
|
||||||
|
plan["non_apply_steps_do_not_mutate_db"] = all(
|
||||||
|
not step.get("mutates_production_db")
|
||||||
|
for group in (pre_apply, preflight, postflight, post_apply, [service_readback, cleanup_readback, receipt_validation])
|
||||||
|
for step in group
|
||||||
|
)
|
||||||
|
return plan
|
||||||
|
|
||||||
|
|
||||||
|
def write_json(path: Path, data: dict[str, Any]) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def write_markdown(path: Path, data: dict[str, Any]) -> None:
|
||||||
|
lines = [
|
||||||
|
"# Working Leo Authorized Apply Session Plan",
|
||||||
|
"",
|
||||||
|
f"Generated UTC: `{data['generated_at_utc']}`",
|
||||||
|
f"Mode: `{data['mode']}`",
|
||||||
|
f"Production apply executed: `{data['production_apply_executed']}`",
|
||||||
|
f"All apply steps require authorization: `{data['all_apply_steps_require_authorization']}`",
|
||||||
|
f"All rollback steps require authorization: `{data['all_rollback_steps_require_authorization']}`",
|
||||||
|
f"Non-apply steps do not mutate DB: `{data['non_apply_steps_do_not_mutate_db']}`",
|
||||||
|
"",
|
||||||
|
"## Authorization Boundary",
|
||||||
|
"",
|
||||||
|
data["authorization_boundary"],
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
for title, key in [
|
||||||
|
("Pre-Apply Validation", "pre_apply_validation_steps"),
|
||||||
|
("Preflight", "preflight_steps"),
|
||||||
|
("Apply", "apply_steps"),
|
||||||
|
("Postflight", "postflight_steps"),
|
||||||
|
("Post-Apply Regression", "post_apply_regression_steps"),
|
||||||
|
("Rollback", "rollback_steps"),
|
||||||
|
]:
|
||||||
|
lines.extend([f"## {title}", ""])
|
||||||
|
for step in data[key]:
|
||||||
|
lines.append(f"- `{step['id']}` -> `{step['output_path']}`")
|
||||||
|
lines.append(f" - mutates production DB: `{step.get('mutates_production_db', False)}`")
|
||||||
|
lines.append(f" - requires authorization: `{step.get('requires_authorization', False)}`")
|
||||||
|
lines.extend(["## Receipt Field Sources After Execution", ""])
|
||||||
|
for field, value in data["receipt_field_sources_after_execution"].items():
|
||||||
|
lines.append(f"- `{field}`: `{value}`")
|
||||||
|
lines.extend(["", "## Claim Ceiling", "", data["claim_ceiling"], ""])
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text("\n".join(lines), encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--runbook", type=Path, default=DEFAULT_RUNBOOK)
|
||||||
|
parser.add_argument("--receipt-template", type=Path, default=DEFAULT_RECEIPT_TEMPLATE)
|
||||||
|
parser.add_argument("--output-dir", type=Path, default=DEFAULT_OUTPUT_DIR)
|
||||||
|
parser.add_argument("--out", type=Path, default=DEFAULT_OUT)
|
||||||
|
parser.add_argument("--markdown-out", type=Path, default=DEFAULT_MARKDOWN_OUT)
|
||||||
|
return parser.parse_args(argv)
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str] | None = None) -> int:
|
||||||
|
args = parse_args(argv)
|
||||||
|
data = build_plan(
|
||||||
|
runbook_path=args.runbook,
|
||||||
|
receipt_template_path=args.receipt_template,
|
||||||
|
output_dir=args.output_dir,
|
||||||
|
)
|
||||||
|
write_json(args.out, data)
|
||||||
|
write_markdown(args.markdown_out, data)
|
||||||
|
print(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"out": str(args.out),
|
||||||
|
"markdown_out": str(args.markdown_out),
|
||||||
|
"production_apply_executed": data["production_apply_executed"],
|
||||||
|
"all_apply_steps_require_authorization": data["all_apply_steps_require_authorization"],
|
||||||
|
"all_rollback_steps_require_authorization": data["all_rollback_steps_require_authorization"],
|
||||||
|
"non_apply_steps_do_not_mutate_db": data["non_apply_steps_do_not_mutate_db"],
|
||||||
|
},
|
||||||
|
indent=2,
|
||||||
|
sort_keys=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main())
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
"""Tests for scripts/build_working_leo_authorized_apply_session_plan.py."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
|
import build_working_leo_authorized_apply_session_plan as session_plan # noqa: E402
|
||||||
|
import working_leo_integrated_packet as integrated_packet # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
|
def test_session_plan_preserves_packet_order_and_not_executed_boundary():
|
||||||
|
plan = session_plan.build_plan()
|
||||||
|
apply_ids = [step["packet_id"] for step in plan["apply_steps"]]
|
||||||
|
rollback_ids = [step["packet_id"] for step in plan["rollback_steps"]]
|
||||||
|
|
||||||
|
assert plan["mode"] == "authorized_apply_session_plan_not_executed"
|
||||||
|
assert plan["production_apply_executed"] is False
|
||||||
|
assert apply_ids == [packet["id"] for packet in integrated_packet.PACKETS]
|
||||||
|
assert rollback_ids == list(reversed(apply_ids))
|
||||||
|
assert "does not execute SQL" in plan["claim_ceiling"]
|
||||||
|
assert "does not authorize production apply" in plan["claim_ceiling"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_session_plan_marks_only_apply_and_rollback_as_mutating_and_authorized():
|
||||||
|
plan = session_plan.build_plan()
|
||||||
|
|
||||||
|
assert plan["all_apply_steps_require_authorization"] is True
|
||||||
|
assert plan["all_rollback_steps_require_authorization"] is True
|
||||||
|
assert plan["non_apply_steps_do_not_mutate_db"] is True
|
||||||
|
assert all(step["mutates_production_db"] is True for step in plan["apply_steps"])
|
||||||
|
assert all(step["requires_authorization"] is True for step in plan["apply_steps"])
|
||||||
|
assert all(step["mutates_production_db"] is True for step in plan["rollback_steps"])
|
||||||
|
assert all(step["requires_authorization"] is True for step in plan["rollback_steps"])
|
||||||
|
for group_name in (
|
||||||
|
"pre_apply_validation_steps",
|
||||||
|
"preflight_steps",
|
||||||
|
"postflight_steps",
|
||||||
|
"post_apply_regression_steps",
|
||||||
|
):
|
||||||
|
assert all(step["mutates_production_db"] is False for step in plan[group_name])
|
||||||
|
assert all(step["requires_authorization"] is False for step in plan[group_name])
|
||||||
|
|
||||||
|
|
||||||
|
def test_session_plan_outputs_every_receipt_path_source():
|
||||||
|
plan = session_plan.build_plan()
|
||||||
|
sources = plan["receipt_field_sources_after_execution"]
|
||||||
|
|
||||||
|
assert len(sources["preflight_output_paths"]) == 5
|
||||||
|
assert len(sources["apply_output_paths"]) == 5
|
||||||
|
assert len(sources["postflight_output_paths"]) == 5
|
||||||
|
assert len(sources["telegram_or_handler_regression_paths"]) == 5
|
||||||
|
assert sources["service_readback"].endswith("post-apply-service-readback.log")
|
||||||
|
assert sources["cleanup_readback"].endswith("post-apply-cleanup-readback.log")
|
||||||
|
assert len(sources["rollback_packet_paths"]) == 5
|
||||||
|
|
||||||
|
|
||||||
|
def test_session_plan_commands_capture_outputs():
|
||||||
|
plan = session_plan.build_plan(output_dir=Path("/tmp/leo-session"))
|
||||||
|
|
||||||
|
all_steps = (
|
||||||
|
plan["pre_apply_validation_steps"]
|
||||||
|
+ plan["preflight_steps"]
|
||||||
|
+ plan["apply_steps"]
|
||||||
|
+ plan["postflight_steps"]
|
||||||
|
+ plan["post_apply_regression_steps"]
|
||||||
|
+ plan["rollback_steps"]
|
||||||
|
+ [plan["service_readback_step"], plan["cleanup_readback_step"], plan["receipt_validation_step"]]
|
||||||
|
)
|
||||||
|
assert all("tee " in step["command"] for step in all_steps)
|
||||||
|
assert all(step["output_path"].startswith("/tmp/leo-session") for step in all_steps)
|
||||||
|
|
||||||
|
|
||||||
|
def test_markdown_preserves_authorization_boundary(tmp_path: Path):
|
||||||
|
plan = session_plan.build_plan()
|
||||||
|
out = tmp_path / "session-plan.md"
|
||||||
|
|
||||||
|
session_plan.write_markdown(out, plan)
|
||||||
|
|
||||||
|
text = out.read_text()
|
||||||
|
assert "Production apply executed: `False`" in text
|
||||||
|
assert "All apply steps require authorization: `True`" in text
|
||||||
|
assert "All rollback steps require authorization: `True`" in text
|
||||||
|
assert "Do not run apply commands unless" in text
|
||||||
Loading…
Reference in a new issue