LAYER 02 · Learn the composition grammar

Context: the plugin collaboration surface

Service discovery, event dispatch, dependency checks, and effect ownership meet in one scope

15 min2 source anchorsupstream@47f9438
ctx.service + ctx.on + ctx.effect
The question this chapter resolves

Is Context a convenient global variable, or the system's boundary object?

Build intuition

Context is a scoped campus pass: it determines which facilities you can discover, which broadcasts you can hear, where you may install equipment, and what must be removed when you leave.

MECHANISM

Mechanism

Plugins discover declared services from ctx rather than importing concrete implementations; missing dependencies surface during composition.

Child contexts inherit visible parent capabilities while owning independent effects and event scope, which enables agent-local capability worlds.

Step 1 of 4

Create context

Parent, realm, and config determine initial visibility.

INVARIANTS

What extensions must preserve

  • A Context reference carries scope semantics
  • Duplicate services fail by contract instead of silently overwriting
  • A disposed Context must reject new registrations
FAILURE MODES

The tempting wrong turns

  • ×Reducing ctx to dependency injection and ignoring events/lifecycle
  • ×Caching agent-scoped services at module scope
  • ×Instantiating providers directly around ctx
VERIFY IN SOURCE

Do not trust the conclusion—verify it

These anchors are pinned to official deepseek-harness@47f9438; account for later breaking changes when reading current upstream.

KNOWLEDGE CHECK

Pause for ten seconds before revealing

Why register agent-local tools on agent.ctx rather than root ctx?

Why the next chapter follows

Context can be safely recomposed because effects and fibers own side effects and asynchronous lifetimes.

Learn DeepSeek Harness

An independent learning project. Explanations derive from source; upstream remains authoritative.