barrel_design_publish (barrel_design v0.1.0)

View Source

Published designs: the node's policy, the statements a database holds, their states, and which one a name follows.

Policy, from barrel_design's env:

  • published => #{accept_dbs => all | [Db], trust => [#{key_id, public_key, names => all | [Name], dbs => all | [SourceDb]}]}: the keys this node accepts statements from, each scoped to names and to source databases, and the receiving databases that accept any. A node also trusts its own publisher key for statements signed for the same database.
  • publisher => #{key_id, private_key => {file, Path} | Bytes, may_sign => #{Db | all => all | [Name]}}: the key this node signs with, and which names it signs for which database.

Statements rank by (version, action), publish < conflict < withdraw at one version. A name follows the maximum of its accepted mark and every trusted, valid statement received so far; two trusted publications of the same version with different manifests make it conflict(N), which only a statement ranked above N clears. A mark never goes down, so a restarted receiver never goes back.

Summary

Functions

What a name should follow, from its catalog record and its trusted statements: keep, {activate, Entry}, {withdraw, Entry}, {conflict, Version} or refuse (an active publication whose provenance the policy no longer accepts).

Whether this node signs name Name for database Db.

The module bytes a publication's attachments carry: all present and matching their names, or what is wrong.

This node's signing key: {ok, KeyId, PrivateKey}.

Every statement of the database, from the live versions of each barrel_design: document, deleted winners included: a live signed version can sit behind a deleted one. Each entry has its state under the policy (trusted still to be ordered, or why it is not). A database that closed meanwhile answers its error.

Whether the policy still accepts what an accepted publication was signed with: checked again from its provenance alone, so it holds after the statement itself is gone.

Types

entry/0

-type entry() :: map().

Functions

decide(Record, Trusted, ProvenanceTrusted)

-spec decide(map(), [entry()], boolean()) -> term().

What a name should follow, from its catalog record and its trusted statements: keep, {activate, Entry}, {withdraw, Entry}, {conflict, Version} or refuse (an active publication whose provenance the policy no longer accepts).

may_sign(Db, Name, Publisher)

-spec may_sign(binary(), binary(), map()) -> boolean().

Whether this node signs name Name for database Db.

module_bytes(Db, _)

-spec module_bytes(binary(), entry()) ->
                      {ok, #{binary() => binary()}} | waiting_for_modules | digest_mismatch.

The module bytes a publication's attachments carry: all present and matching their names, or what is wrong.

policy()

-spec policy() -> map().

signing_key()

-spec signing_key() -> {ok, binary(), binary()} | none.

This node's signing key: {ok, KeyId, PrivateKey}.

statements(Db, Policy)

-spec statements(binary(), map()) -> {ok, [entry()]} | {error, term()}.

Every statement of the database, from the live versions of each barrel_design: document, deleted winners included: a live signed version can sit behind a deleted one. Each entry has its state under the policy (trusted still to be ordered, or why it is not). A database that closed meanwhile answers its error.

trusted_now(Db, _, Policy)

-spec trusted_now(binary(), map(), map()) -> boolean().

Whether the policy still accepts what an accepted publication was signed with: checked again from its provenance alone, so it holds after the statement itself is gone.