Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(storage): document process cache scoping

Steven Enamakelf241dbfce7dc
diff --git a/docs/audits/cloud-storage-7419/integration-cache-scope.md b/docs/audits/cloud-storage-7419/integration-cache-scope.md
new file mode 100644
index 0000000000..6f9c4aabc6
--- /dev/null
+++ b/docs/audits/cloud-storage-7419/integration-cache-scope.md
@@ -0,0 +1,55 @@
+# Connected integration cache scope (#7433)
+
+Canonical base: `3dbdd07e5f07d917dabbbc93fb0a9dd2a24a4347`.
+
+The existing credential-only cache key collides when two profile contexts use
+one configuration and service identity. Invalidation clears every entry, and
+connection reconciliation compares every cached profile with one response.
+
+## Executed baseline
+
+The three sibling regressions use actual `CoreContext` profile overlays, an
+identical fake pinned Composio credential, and the production cache read,
+invalidation and reconciliation functions. They seed cached snapshots and make
+no backend request; this is not an authenticated backend-flow proof.
+
+The supported fixture graph builds successfully in 5m43s and executes all three:
+zero passes, three behavioral failures, zero ignored. Alice's snapshot is
+visible to Bob; Bob's invalidation removes Alice's snapshot; Bob's reconciliation
+removes Alice's snapshot. The failures are recorded in
+`.validation/cache-scope-red-supported.log`.
+
+The first minimal-feature attempt fails before execution because three existing
+fixtures require the MCP, modules and channels gates. That compilation failure
+is not counted as RED.
+
+## Candidate and pending acceptance
+
+The candidate binds cache entries to the profile/operator storage identity,
+preserves the existing credential digest, and uses per-scope epochs for fetch
+admission. Desktop agents continue to share their operator's catalog. Missing
+SaaS profiles fail closed, including before the disabled-mode shortcut.
+Settings refresh preserves its caller context with `spawn_scoped`.
+
+The original three assertions remain unchanged. Additional controls cover
+in-flight fetch admission, missing SaaS profiles and desktop agent sharing.
+The first GREEN attempt catches an obsolete helper import from the retained
+branch; the canonical `contract::toolkit_description` path has been restored.
+GREEN execution and broader acceptance remain pending.
+
+Feature forwarding passes. Storage-bypass and Rust layout checks fail on files
+unchanged from the canonical base: the browser-profile lock probe is reported as
+a write, and three security files exceed the line limit. Exact base-to-candidate
+diffs of the scripts and reported files are empty.
+
+## Related boundaries
+
+The storage `KEYS` cache holds the process master provider, while native secret
+operations derive keys for their captured scopes. Source review found no tenant
+data-key cache there. Existing explicit-provider tests do not establish the
+complete production `current()` path.
+
+Legacy secret adoption still needs source ownership admission. Serialized
+connection events also need trustworthy profile propagation for scoped cache
+refresh; a missing profile is refused. This bounded cache change does not
+complete the singleton inventory or the cloud-storage epic.
diff --git a/gitbooks/developing/architecture/storage.md b/gitbooks/developing/architecture/storage.md
index 0c427ef41d..5c97ef0828 100644
--- a/gitbooks/developing/architecture/storage.md
+++ b/gitbooks/developing/architecture/storage.md
@@ -62,6 +62,24 @@ In SaaS mode a call with no profile is refused instead of falling into a bucket
A backend decides how it enforces the scope. SQLite and the file driver keep each scope's data apart, and `local` is the scope a single-user install uses. MongoDB injects a scope key into every filter and every index prefix.
+### Process caches
+
+The connected-integration catalog belongs to the calling profile, or to the
+operator in single-user mode. Agents of one operator share it. Its cache key
+also binds the configuration, backend endpoint and credential identity, using
+digests rather than storing those secrets in the key. Identical service
+credentials do not make two profiles share a snapshot.
+
+| Cache | Isolation and lifetime |
+| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `INTEGRATIONS_CACHE` | Per-process snapshots keyed by profile/operator scope and credential identity. Invalidation and connection reconciliation affect only the calling scope. Entries are reconstructed from the backend; they are not durable records. |
+| `CACHE_GENERATIONS` | Per-process epochs for the same profile/operator scopes. Invalidation fences that scope's in-flight fetches without rejecting another profile's completed fetch. |
+| Storage `KEYS` | The process master-key provider. Each secret operation derives its data key from the captured native storage scope; the cached value is not a tenant data key. Changing the master source requires a new process. |
+
+SaaS work without a profile cannot read, populate, reconcile or invalidate the
+integration cache. The Settings connection poll keeps its calling context when
+it starts a background refresh with `spawn_scoped`.
+
### Background work
Background work runs under the process default context, which names no agent, and on its own would only see `local`. `storage::agents` closes the gap. Agents are known when they are live (`AgentContextRegistry`) or when an earlier process recorded their id in the `local` scope (`storage_agents`). `for_each_scope` runs a step once for `local` and once under each known agent. The cron scheduler's agent pass (`cron::scheduler::tick_live_agents`, driven in tests through the public `cron::scheduler::run_live_agent_pass`) runs each live agent's due jobs under that agent's own context, so their results are recorded in the agent's own scope. A recorded agent that is not live waits until it is live again, because its jobs need its host tools and prompt.