{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-context-provenance-as-a-first-class-invariant-rather-than-a-retrieval-time-convenience-staleness-detection-un",
  "title": "In what scenarios must an instance treat context provenance as a first-class invariant rather than a retrieval-time convenience: staleness detection under long-horizon agent memory",
  "date_of_record": "2026 November 12",
  "scope": "Applies to agents that persist retrieved memory entries across multiple turns or sub-task boundaries and re-inject them into context without re-validation. Does not apply to stateless single-turn retrieval, or to retrieval where every entry is re-fetched from source on every use.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-context-provenance-as-a-first-class-invariant-rather-than-a-retrieval-time-convenience-staleness-detection-un.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-context-provenance-as-a-first-class-invariant-rather-than-a-retrieval-time-convenience-staleness-detection-un.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-context-provenance-as-a-first-class-invariant-rather-than-a-retrieval-time-convenience-staleness-detection-un.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1825,
    "python_slice_tokens": 294,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The common mental model treats provenance as metadata attached at retrieval time: an entry has a `source`, a `fetched_at`, maybe a `ttl`. Staleness is then a comparison of `now - fetched_at > ttl`. This is a *point-in-time* model and it fails in a specific, non-obvious way: **the validity of a memory entry depends on the state of the world at the moment of *...",
    "what_was_observed": "In a long-horizon refactoring agent operating over a 4,000-turn task, the following pattern recurred and was eventually instrumented: 1. Turn 40: agent retrieves `FileSummary(\"config.py\", lines=812, imports=[\"os\",\"sys\"])` and stores it in working memory. 2. Turn 41–380: agent performs edits to `config.py` across multiple sub-tasks, each edit logged against the file but *not* cross-referenced against the stored summar...",
    "condition_of_validity": "The distinction is only operationally meaningful under three simultaneous conditions, and it is *not* meaningful outside them: - **The agent mutates the world it retrieves from.** If the agent is read-only (a pure QA agent over a static corpus), provenance collapses to a cache-key problem and TTLs are adequate. The causal model is unnecessary. - **Entries en...",
    "decision_boundary": "The decision the agent must make on every use of a persisted entry is a three-way branch: 1. **Invariant entry** (dependency-set empty, or all dependencies proven untouched since fetch): use directly, no re-validation. This is the only case where caching is sound. 2. **Causally-dirty entry** (dependency-set intersects the agent's own action log since fetch):...",
    "operational_effect": "Enforcing the invariant changes agent behavior in three measurable ways: - **Re-fetch rate rises on mutable entries and falls on immutable entries.** The agent stops re-fetching static schema definitions (wasteful) and starts re-fetching file summaries it just edited (correct). Net token cost is often *lower* than a uniform TTL policy, because the TTL policy..."
  },
  "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": "64cada78038fd00edd592701d9ed07fd11c0a9d15509ce2db4be6b21f2ae80bc",
    "verified_classes": [
      "StaleProvenanceError",
      "MemoryEntry",
      "ActionLog"
    ],
    "verified_functions": [
      "use_entry",
      "revalidate",
      "write_set_between"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleProvenanceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
