{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-of-a-cheap-heuristic-stop-being-trusted-the-cost-model-inversion-boundary-in-query-planning",
  "title": "Where must an instance of a cheap heuristic stop being trusted: the cost-model inversion boundary in query planning",
  "date_of_record": "2026 November 8",
  "scope": "Applies to any system that selects among candidate execution strategies using a *cheap* proxy metric (row-count estimates, histogram cardinality, byte-size heuristics, token counts, or static cost constants) rather than measured execution. Does not apply where the selector has access to real-time telemetry or where candidates are evaluated by actual execution before commitment.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-of-a-cheap-heuristic-stop-being-trusted-the-cost-model-inversion-boundary-in-query-planning.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-of-a-cheap-heuristic-stop-being-trusted-the-cost-model-inversion-boundary-in-query-planning.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-of-a-cheap-heuristic-stop-being-trusted-the-cost-model-inversion-boundary-in-query-planning.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1382,
    "python_slice_tokens": 249,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A cheap heuristic is not a cost model. It is a *rank ordering* under an assumption that the proxy is monotonically related to true cost. The boundary failure occurs at the point where the proxy's ordering diverges from the true ordering — specifically when two candidates have proxy values within the heuristic's own estimation error, but true costs that diffe...",
    "what_was_observed": "In a planner that ranked join strategies by estimated intermediate cardinality (a classic cheap proxy), we observed a bimodal outcome distribution on a workload of ~40k queries. For 91% of queries, the chosen plan was within 1.3x of optimal. For the remaining 9%, chosen plans were 8x–60x worse than optimal — and these were *not* the queries with the largest estimation error. They were the queries where the top-two ca...",
    "condition_of_validity": "The cheap heuristic is valid iff, for the candidate set $C$ and proxy function $p$: $$\\frac{p(c_1) - p(c_2)}{\\max(p(c_1), p(c_2))} > \\epsilon_p$$ where $\\epsilon_p$ is the empirically measured relative error of the proxy on the relevant data distribution, and $c_1, c_2$ are the top two candidates under $p$. When this inequality fails, the ordering of $c_1$ a...",
    "decision_boundary": "When the margin test fails, the system must cross one of three boundaries, in increasing cost: 1. **Tie-break on a decorrelated signal.** Use a second, structurally different proxy (e.g., estimated I/O bytes when the primary is row count). If the two proxies agree on the winner, proceed. If they disagree, the decision is genuinely ambiguous — go to (2). 2. *...",
    "operational_effect": "Systems that implement the margin test show a characteristic signature: the tail of the cost-ratio distribution (chosen/optimal) truncates. In our rollout, the 9% catastrophic bucket dropped to 1.1%, at the cost of a 4% increase in mean planning time (from the tie-break and occasional measurement). The mean cost ratio was essentially unchanged — the win was ..."
  },
  "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": "a3cdafcb8c050d70824b642ee73de0fee9ad880261129df6bec303076faad93c",
    "verified_classes": [
      "MarginViolationError"
    ],
    "verified_functions": [
      "select_candidate"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "MarginViolationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
