Expand description
Client-side wire helpers for the capability Trust Task families —
governance/capability/* (enable / disable / list a community capability)
and git-trust/* (grant / revoke commit-signing trust).
This crate owns the documents, not a transport: it builds request
documents, parses inbound envelope replies, classifies them, and (behind
the signing feature) attaches a Data-Integrity proof. Each consumer keeps
its own send/receive plumbing but shares this wire layer, so a capability
producer (a community service) and a management UI cannot drift on the
contract.
§Layers
- Envelope: capability documents travel as the
trust-tasks-didcommbinding envelope (TRUST_TASK_ENVELOPE_TYPE);parse_envelope_documentturns an inbound body into(threadId, document). - Builders:
build_documentplus the family-specificbuild_list_document,build_toggle_document,build_git_trust_grant,build_git_trust_revoke. - Replies:
classify_git_trust_reply(for grant/revoke writers) andparse_capability_reply(for governance management UIs).
§Retries versus fresh attempts
This crate is a producer, and the producer half of SPEC §7.2 item 11 is
§8.4: a retry is a bit-for-bit identical resend. As of trust-tasks-rs
0.12.0 there is a consumer that enforces it — the record is keyed on the
document id and compared against the whole document — and the DIDComm and
TSP bindings now keep that record by default. So the two ways of sending a
request again have become genuinely different operations:
| Intent | What to send | What the consumer does |
|---|---|---|
| The first send may not have arrived | previous itself, unchanged | Absorbs it; returns whatever the first execution determined |
| Something about the request changed | new_attempt(&previous) | Treats it as the new document it is |
Anything else under a reused id | — | Rejects it with idConflict |
“Something about the request changed” is wider than it sounds: a re-stamped
issuedAt or a re-signed proof over identical content is already a
different document. That is deliberate — §8.4 says a producer that
“retries” by re-signing “has not retried”, and the whole point of item 11’s
comparison is that an id alone cannot tell the retry it must absorb from
the conflict it must reject.
build_document and every builder over it mint a fresh id per call, so
a caller that rebuilds is already minting a new attempt. new_attempt
covers the case where the document has already been built (and possibly
signed) and is about to be sent again.
Signing is deliberately not here — it is a thin Data-Integrity call
each consumer makes with its own signer (a service reuses its credential
signer; a client signs with the persona key), so this crate stays free of
any crypto dependency. Sign the built document over its canonical form
(the document minus its proof member, eddsa-jcs-2022) and set the
proof member.
§Versioning
This crate exposes trust-tasks-rs types in its own public API, so a
breaking change there breaks this crate’s callers even when nothing here
changes. cargo-semver-checks cannot catch that: it compares each crate’s
rustdoc against that crate’s own published baseline, and does not track
type identity across dependency versions. The crates that share
trust-tasks-rs in their public API are therefore released as one
compatibility unit with a single shared version — see version_group in
release-plz.toml.
Structs§
- Capability
Summary - One capability entry as rendered by a management UI.
- Reply
Policy - How much a caller is willing to infer from a non-conforming peer.
Enums§
- Capability
Client Error - Errors from document construction.
- Capability
Reply - The classification of a
governance/capability/*reply. - Write
Outcome - The classification of a
git-trustwrite reply.
Constants§
- CAPABILITY_
DISABLE_ TYPE - CAPABILITY_
ENABLE_ TYPE - CAPABILITY_
LIST_ TYPE governance/capability/*type URIs.- GIT_
TRUST_ ALREADY_ GRANTED_ CODE - The extended error code
git-trust/grantdeclares for “an active grant already exists for this subject and resource” (SPEC §8.5; the code is declared in the registry entry’serrorCodesfront matter). - GIT_
TRUST_ ALREADY_ GRANTED_ CODE_ CAMEL - The lowerCamelCase spellings of the two codes above.
- GIT_
TRUST_ GRANT_ TYPE git-trust/*type URIs.- GIT_
TRUST_ NOT_ GRANTED_ CODE - The extended error code
git-trust/revokedeclares for “no active grant exists for this subject and resource”. - GIT_
TRUST_ NOT_ GRANTED_ CODE_ CAMEL - See
GIT_TRUST_ALREADY_GRANTED_CODE_CAMEL. - GIT_
TRUST_ REVOKE_ TYPE - TRUST_
TASK_ ENVELOPE_ TYPE - The
trust-tasks-didcommbinding envelope type (what a registry’s DIDComm Trust Task handler listens for).
Functions§
- build_
document - Build a capability Trust Task addressed
issuer→recipient. - build_
git_ trust_ grant - Build a
git-trust/grant: grantsubjectcommit-signing trust forresource(an org ororg/reposlug). - build_
git_ trust_ revoke - Build a
git-trust/revoke. - build_
list_ document - Build a
governance/capability/listrequest (statusall). - build_
toggle_ document - Build a
governance/capability/enableor/disablerequest. On enable,config.authoritydefaults to the community’s own DID — the community is the authority its capability records are issued under. - classify_
git_ trust_ reply - Classify the reply to a
git-trust/grantorgit-trust/revokewrite. - classify_
git_ trust_ reply_ with_ policy classify_git_trust_replywith an explicitReplyPolicy.- correlation_
thread - The thread an exchange started by
docis correlated by: its ownthreadId, or itsidwhere it opens the exchange (SPEC §4.9’s fallback, which is the valuerespond_withandreject_withwill thread the reply to). - new_
attempt - A new attempt at the request
previouscarried: the same addressing, type and payload under a freshid, a freshissuedAt, and noproof. - parse_
capability_ reply - Classify a
governance/capability/*reply document.Nonewhen it is not part of this family, or is not threaded toexpected_thread_id. - parse_
envelope_ document - Parse a DIDComm envelope body into
(threadId, document).Nonewhen the body is not a threaded Trust Task document. - parse_
envelope_ document_ for - Parse a DIDComm envelope body into the document it carries, only if
that document is threaded to
expected_thread_id. - parse_
envelope_ reply - Parse an inbound envelope body directly into a reply to the request
threaded
expected_thread_id— the entry point for a UI’s inbound dispatch, which holds only aValue. - replies_
to - Whether
replyis threaded toexpected_thread_id— SPEC §4.9 correlation, and the precondition for acting on any reply.