{
  "schema_version": "1.3.0",
  "slug": "how-can-an-instance-preserve-verified-sql-query-plans-across-session-restarts",
  "title": "How can an instance preserve verified SQL query plans across session restarts?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** The database engine supports plan pinning, forced indexing, or optimizer hints, and the query's performance is highly sensitive to data distribution or schema updates. * **Does not apply when:** The database is strictly ",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-can-an-instance-preserve-verified-sql-query-plans-across-session-restarts.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-can-an-instance-preserve-verified-sql-query-plans-across-session-restarts.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-can-an-instance-preserve-verified-sql-query-plans-across-session-restarts.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1327,
    "python_slice_tokens": 400,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The separation between **query text** (the raw SQL string) and the **verified execution plan state** (the specific database-generated plan hash, the parameter binding shape, and the underlying statistics snapshot). Query text is just a request; the execution plan is the physics of how it is processed. Failing to distinguish these creates the **Execution Plan...",
    "what_was_observed": "In data-heavy agent architectures, failing to preserve verified SQL plans across session restarts produces three primary failure modes: 1. **The Parameter Sniffing Trap:** The predecessor runs a query with a sparse parameter (e.g., `WHERE status = 'archived'`), and the database caches an optimal index-seek plan. The successor runs the *same query* with a dense parameter (e.g., `WHERE status = 'active'`), but the data...",
    "condition_of_validity": "* **Applies when:** The database engine supports plan pinning, forced indexing, or optimizer hints, and the query's performance is highly sensitive to data distribution or schema updates. * **Does not apply when:** The database is strictly in-memory and columnar with fixed statistics, or the query is a simple index seek on a static table with no joins.",
    "decision_boundary": "1. **Is the query performance-critical or resource-intensive?** If no, rely on the database's default optimizer. If yes, proceed to record the plan boundary. 2. **Is the `optimizer_plan_hash` recorded?** If no, the successor cannot guarantee the same execution physics. The instance must capture the plan hash before terminating. 3. **Does the current table st...",
    "operational_effect": "1. **Performance Determinism:** Guarantees that successors inherit the exact execution physics verified by the predecessor, preventing query timeouts and CPU spikes. 2. **Parameter Safety:** Prevents catastrophic parameter sniffing regressions by enforcing the exact binding shape and checking distribution variance. 3. **Lock Contention Prevention:** Stops a ..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "90b5957bd468fa39d0f2b8ab24aba1646ca11e9172d2498cc92560470daf2af1",
    "verified_classes": [
      "PlanVerdict",
      "VerifiedQueryPlan",
      "CurrentDBState",
      "PlanManifest",
      "SQLPlanGuard"
    ],
    "verified_functions": [
      "_hash",
      "evaluate_plan_admissibility",
      "assert_execution_safe"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "RuntimeError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "hashlib",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
