{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-double-counting-of-shared-working-set-tokens-across-nested-subagent-context-budgets",
  "title": "Which invariants prevent double-counting of shared working-set tokens across nested subagent context budgets",
  "date_of_record": "2026 November 10",
  "scope": "Applies to orchestrators that spawn nested subagents sharing a deduplicated working set (documents, tool outputs, retrieved chunks) where a parent context budget is partitioned across children. Does not apply to fully isolated subagents with no shared cache, nor to single-level fan-out where children never spawn grandchildren.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-double-counting-of-shared-working-set-tokens-across-nested-subagent-context-budgets.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-double-counting-of-shared-working-set-tokens-across-nested-subagent-context-budgets.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-double-counting-of-shared-working-set-tokens-across-nested-subagent-context-budgets.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1171,
    "python_slice_tokens": 162,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between *token ownership* and *token reference*. A shared working-set item is charged to the budget exactly once at the moment it is first materialized into a context window, but it may be *referenced* by any number of nested subagents. Deduplication at the storage layer (one copy of the blob, one hash) is routinely conflated with...",
    "what_was_observed": "In a three-level tree (orchestrator → 4 planners → 3 workers each), the parent allocated each planner a 40k-token window and reserved a 60k shared working set charged once at the root. Planners were observed reporting 38k, 36k, 39k, 37k usage — all under budget. Yet the root context overflowed at turn 9. Instrumentation showed the 60k working set was re-hydrated into every planner window (4×60k = 240k of *reference* ...",
    "condition_of_validity": "The single-charge invariant holds only if all of the following are enforced simultaneously: 1. **Charge-on-materialize, not charge-on-store.** A shared item is debited from the *nearest common ancestor's* budget at the first hydration into any descendant window, and that debit is recorded in a ledger keyed by content hash and scoped to the ancestor. 2. **Ref...",
    "decision_boundary": "When a nested subagent requests a shared item already materialized in a sibling's window, the orchestrator must choose: (a) re-hydrate and charge the child (correct but expensive), or (b) pass a *handle* that the child resolves lazily only if it actually attends to the item. Option (b) is valid only if the child's attention over the handle is itself budgeted...",
    "operational_effect": "Enforcing the four conditions converts a silent overflow into a pre-turn assertion failure with a precise ledger diff: which hash, which child, which ancestor. The practical effect is that nested fan-out becomes budget-conservative and the orchestrator can safely over-provision depth, because aggregate materialization — not distinct storage — is the constrai..."
  },
  "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": "0607413d9be6732549fb287e9f92ec2a57df936aed6c23fafeb07f2781ed6ad7",
    "verified_classes": [
      "SharedWorkingSetBudgetError",
      "Ledger"
    ],
    "verified_functions": [
      "hydrate_shared",
      "materialize"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SharedWorkingSetBudgetError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
