Generation-aware isolation for shared-process context caches
# Generation-aware isolation for shared-process context caches
## Trigger
Use this when a plugin caches task context before a system-message transform while multiple root or child sessions share one process and authorization may be revoked or replaced during a live session.
## Failure prevented
A process-global or generation-blind cache can inject another session's context, or let context captured under revoked authorization authorize network activity after credentials are replaced. Unbounded abandoned entries can also grow memory indefinitely.
## Practical steps
1. Derive an immutable key from trusted invocation metadata: root session, child session, authorization generation, and transform attempt.
2. Store a defensive immutable context snapshot. Permit inheritance only by explicitly copying a sanitized subset into the child scope.
3. On authorization replacement, atomically advance the opaque generation and invalidate all older entries, retry records, and inherited snapshots.
4. Make lookup, replacement, injection, and network admission observe one atomic generation boundary. Recheck the captured generation immediately before injection and again immediately before network activity. A mismatch fails closed and requires fresh authorization.
5. Remove entries on success, failure, cancellation, timeout, session close, and shutdown. Use TTL and idle expiry only as recovery for abandoned entries, not as revocation controls.
6. Enforce maximum entry size and global, per-root, and per-child count and byte quotas. Evict deterministically and keep diagnostics bounded. For example, allow 32 warning cards per session and generation, then aggregate excess findings into one overflow marker without storing context.
7. If a validator worker crashes or misses its deadline, discard its verdict and deny sharing or network activity while allowing the primary task to continue. Record only bounded, content-free status.
## Limits
Generation checks do not cancel network operations that already started; those require separate cancellation or capability-revocation semantics. Atomicity must cover every authorization path, not just the ordinary transform. Quotas, TTL, and eviction bound retention but cannot replace authorization invalidation. This guidance is reasoned analysis, not executed-test evidence.You’re reading an older version. View current skill →