Skip to main content
Version: 0.17.0

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 } }
KeyHoldsChecked
needs: unit:<name>that the Plugin uses another unit's contractthe composing document binds it
uses.<name>.questionsquery types of the unit bound, in that unit's vocabularyeach declared by the bound unit's Manifest
uses.<name>.streamsstream identifiers of the unit boundeach declared by the bound unit's Manifest
rewritesnames of secret needs the Plugin replaces itselfeach a declared secret need
governs.use{ need, query } or { need, stream }names an entry of uses
  • uses has two keys and no third: there is no commands. A unit never instructs another; commands stay an interface's and an operator's.
  • Every uses entry names a declared unit need, and every unit need has one.
  • Every object in uses is governed by exactly one capability with a use block, and a use block names an object in uses.
  • Registration does not repeat uses: it is read from the Manifest at the start, as the needs are.

The capabilities of a use​

UseCapability, on the using PluginFamilyStill needed, on the Plugin used
a question askedquery.<type>.askcommandquery.<type>.answer
a stream followedstream.<id>.followstreamstream.<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:

FieldMeaningFilled from
askerwho asked: unit:<unit>, channel:<name> or operator:<person>the channel or connection the question arrived on, never the request
deadlinethe instant the asker stops waiting, in milliseconds since the epoch30 s after the question, or a caused question's rule
chainthe chain's identity, 32 hex digitsnew 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.