Using another unit
A Plugin may use another unit's contract: ask its questions and follow its streams. It declares that it needs a unit, and what it uses of it, in its Manifest; the application binds the need to one of its Plugin units; an operator grants the use; and the Core gives the Plugin a channel of its own on which it is that unit's client. The plugin surface itself does not change: no family is added, nothing travels on the using unit's Session for it, and control is still started by the Core alone.
What a Plugin declares
needs:
- unit:accounts
- secret:refresh
uses:
accounts:
questions: [ oauth.token, oauth.accounts ]
streams: [ oauth.status ]
rewrites: [ refresh ]
capabilities:
- name: query.oauth.token.ask
governs: { use: { need: accounts, query: oauth.token } }
- name: query.oauth.accounts.ask
governs: { use: { need: accounts, query: oauth.accounts } }
- name: stream.oauth.status.follow
governs: { use: { need: accounts, stream: oauth.status } }
| Key | Holds | Checked |
|---|---|---|
needs: unit:<name> | that the Plugin uses another unit's contract | the composing document binds it |
uses.<name>.questions | query types of the unit bound, in that unit's vocabulary | each declared by the bound unit's Manifest |
uses.<name>.streams | stream identifiers of the unit bound | each declared by the bound unit's Manifest |
rewrites | names of secret needs the Plugin replaces itself | each a declared secret need |
governs.use | { need, query } or { need, stream } | names an entry of uses |
useshas two keys and no third: there is nocommands. A unit never instructs another; commands stay an interface's and an operator's.- Every
usesentry names a declaredunitneed, and everyunitneed has one. - Every object in
usesis governed by exactly one capability with auseblock, and auseblock names an object inuses. - Registration does not repeat
uses: it is read from the Manifest at the start, as the needs are.
The capabilities of a use
| Use | Capability, on the using Plugin | Family | Still needed, on the Plugin used |
|---|---|---|---|
| a question asked | query.<type>.ask | command | query.<type>.answer |
| a stream followed | stream.<id>.follow | stream | stream.<id>.publish |
A use adds no family: an ask is in the command family as an answer is, a follow in the stream family as
a publish is (capabilities). The names follow that pattern and are the author's, as
every capability name is: the Manifest declares the mapping and nothing derives it. An operator grants a
use with the verb that grants any capability, yoke plugin grant. Both grants are checked on every use:
the using Plugin's, and the used Plugin's own.
Authority is not passed along a chain. A unit that uses one that uses a third is granted nothing of the third: each link is granted on its own.
What the unit is handed
The address of a channel per unit need, in the argument it declared — ${bind.<name>}, substituted at
launch as a device's path and a secret's file are. Nothing else: not the name of the unit bound, not its
Manifest, not the Registry. The using unit speaks to that channel with its family's
interface library, and the channel's opening shows the one unit it
may address (a need's channel).
The three fields of a question
Every question the Core delivers to a unit carries three fields the Core fills, whoever asked and on whichever surface:
| Field | Meaning | Filled from |
|---|---|---|
asker | who asked: unit:<unit>, channel:<name> or operator:<person> | the channel or connection the question arrived on, never the request |
deadline | the instant the asker stops waiting, in milliseconds since the epoch | 30 s after the question, or a caused question's rule |
chain | the chain's identity, 32 hex digits | new for a question with no cause; the cause's otherwise |
The unit reads them and states none of them. An answer is correlated to the question as before and
carries none of the three. A unit that gives different things to different askers decides it from asker,
which no request can forge.
A unit asking on a need's channel while it answers a question names that question's identifier as the
cause, and the Core derives the inner question's chain and deadline from it. An inner failure is the
using unit's to translate: it is handed the refusal or the timeout it met, and what it answers its own
asker is its own contract.