---
library: "bootstrap"
slug: "ContextSwitch"
name: "ContextSwitch"
ref: "ContextSwitch#aa92"
hash: "sema:ContextSwitch#mh:SHA-256:aa928020743949b151e03433b563540eaf1bb56dad262297d2907bd0473931e2"
type: "Protocols"
layer: "Society"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/ContextSwitch"
---

# ContextSwitch

Explicit, scoped protocol-mode toggle with enter/revert boundaries

Society · Protocols

## Mechanism

[Agent](https://semahash.org/vocabularies/bootstrap/patterns/Agent.md)s explicitly signal a change in [Context](https://semahash.org/vocabularies/bootstrap/patterns/Context.md) (protocol [Mode](https://semahash.org/vocabularies/bootstrap/patterns/Mode.md)), and all subsequent messages are interpreted under the new ruleset until a 'Revert' signal is sent. The new context pushes onto a stack; Revert pops it. Unlike an ambient [Mode](https://semahash.org/vocabularies/bootstrap/patterns/Mode.md) change (which applies to the whole agent), ContextSwitch is scoped to a specific conversation or channel and carries explicit enter/exit boundaries.

## Invariants

- The switch is signalled explicitly; it is never inferred from content.
- Revert pops the most recent switch, not an arbitrary one.
- Scoped to one conversation or channel, unlike an ambient [Mode](https://semahash.org/vocabularies/bootstrap/patterns/Mode.md) change.

## Failure modes

- Unbalanced stack: a switch is never reverted, so the ruleset outlives the exchange it was for.
- Scope leak: messages outside the switched channel are interpreted under the new ruleset.

## Where this came from

—

## Builds on

- [Context](https://semahash.org/vocabularies/bootstrap/patterns/Context.md) (accepts)
- [Mode](https://semahash.org/vocabularies/bootstrap/patterns/Mode.md) (references)
- [Agent](https://semahash.org/vocabularies/bootstrap/patterns/Agent.md) (references)

## Used by

- [WorkerMode](https://semahash.org/vocabularies/bootstrap/patterns/WorkerMode.md) (references)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: ContextSwitch#aa92
- Hash: sema:ContextSwitch#mh:SHA-256:aa928020743949b151e03433b563540eaf1bb56dad262297d2907bd0473931e2

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/ContextSwitch
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/ContextSwitch.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
