Adding a Data Source
Adding a registry as a data source of a Composite use case, step by step: registry prerequisites, Partner Management, Consent Manager, the Composite's configuration, the partner's consent, and testing
A use case's data sources are registries. Adding one needs no code in the Composite: the registry must speak DCI with consent, PM and CM must know about it, and the Composite gets a URL and a new sources[] entry. This guide uses a Livestock Registry (controller livestock-registry) added to loan-profile as an optional source.
Overview
Exchange CM and department CM
CM administrators, operator (setup script)
Step 1 — Registry prerequisites
The registry must answer the Composite exactly as it answers a partner:
DCI synchronous search at
POST /dci/registry/sync/searchon its partner API, for the record type the use case needs. Every OpenG2P registry built on the registry platform has it (Partner APIs).Signature validation against PM on (
global.partnerSignatureValidationEnabled, the default), with the PM key backend (global.registryCryptoBackend: partner-mgmt) andglobal.partnerManagementApiUrlpointing at PM. It then accepts the Composite's signature (PARTNER_AGRI_COMPOSITE).Consent enforcement on (
global.consentEnforcementEnabled, the default), withglobal.consentManagerUrl, andglobal.consentDataControllerset to the registry's controller ID: herelivestock-registry(it defaults toglobal.registryVariant). The registry sends it to CM/validate, so CM evaluates only this registry's grant. See Consent-aware data sharing.Subject identifiers that pass the consent subject check. The registry rejects a search whose subject is not the consent's subject. The consent's subject is what the partner sent (a national ID or a farmer ID), so the registry must hold that identifier on its records, or link its own key to it (
subject_id_fieldsfor an activity register, e.g. a farmer ID recorded with the farmer's national ID). If the registry is keyed on something else (e.g. a farmer ID only), the source must depend on a source that returns that key, and the registry must be able to link it to the consent's subject.A data scope catalogue. Consents name the registry's data scopes,
<controller>.<name>(e.g.livestock-registry.animals,livestock-registry.owner_reference): by default one per register section, plus any named scopes the extension ships inmeta_data/data-scopes/. The registry publishes them atPOST /partner/data_scopes(signed) and filters each record to the consented fields before rendering it. If another source depends on a value from this registry's record, one scope must carry it.
Step 2 — Identities in Partner Management
The Composite is already a PM partner (
PARTNER_AGRI_COMPOSITE); the new registry verifies it with the key PM serves. Nothing to add.The registry, if you want the Composite to verify the registry's response signatures: onboard the registry in PM under its DCI ID (e.g.
livestock-registry→PARTNER_LIVESTOCK_REGISTRY) with its signing key, and setpartnerIdin step 4. Optional.
See the PM API reference.
Step 3 — Bindings and policies in the Consent Manager
There are two Consent Managers to set up (consent):
The department CM (the one the new registry validates with) checks the Composite's consent tokens. It needs:
a binding and policy for the Composite (audience
agri-composite, controllerlivestock-registry,partner_mgmt_idPARTNER_AGRI_COMPOSITE) with the scopes and purposes of the use cases that read the registry.scripts/setup_exchange.pycreates it from the published use cases (step 7);trust of the Exchange CM as a consent-token issuer: Exchange Role department in the department's commons-services form (
global.agriStackExchange.role; it trustsagri-stack-exchange-cmpresented byagri-compositeby default). The setup script checks it and stops if it is missing. See Exchange consent tokens.
The Exchange CM checks the partner's consent. For each partner that will receive the new data, the CM administrator of the Exchange creates a binding of the partner to the new controller and a policy for it (Partner policy binding & approval):
audience
the partner's ID, e.g. bank-a
controller_id
livestock-registry
partner_mgmt_id
PARTNER_BANK_A
with a policy listing the scopes the department allows (e.g. livestock-registry.animals, livestock-registry.owner_reference), the purpose (credit-assessment), the subject identifier types (FAYDA_FAN, FARMER_ID), the signing algorithms, the maximum validity and the fetch type. If AWE approval is switched on in that CM (it is off by default), a new or wider policy waits for it.
Step 4 — Register the endpoint in the Composite
Add the registry's DCI search URL under its controller ID, in the Composite's Helm values (Rancher Edit YAML):
The chart passes this to the service as AGRI_COMPOSITE_REGISTRIES; the upgrade rolls the pods. Add the registry before any use case names it: a use case whose sources name a controller with no endpoint fails to load.
Step 5 — Add the source to the use case
Add a sources[] entry to the use case (in composite.useCases.loan-profile), with its query template, dependencies, requirement and timeouts, and map its records into the output:
depends_on: leave it out if the registry can be searched by the partner's subject directly (then it is called in the first level, in parallel with the farmer). Keep it if the query needs another source's result.requirement:optionalfor data that is useful but not essential;mandatoryonly if the use case is meaningless without it (a failure or missing grant then fails the whole request).scopesandoptional_scopes: scope IDs from the registry's catalogue. The consent must grant every one ofscopes(else a mandatory source fails the request, an optional one is reporteddeniedand not called);optional_scopesit may leave out. They are listed per registry in the describe endpoint'sconsent_scopes, and in Exchange mode they are therequested_scopesthe consent tokens are limited to. See data scopes.Timeouts:
timeout_msandretriesper source; check thatexecution.overall_timeout_msstill covers the slowest path. Inloan-profileit is 25000 ms, for two levels of 10000 ms;herddepends on the farmer, so it runs in the second level with the crop sources and adds no level.Version: adding an optional source and new output fields is backward compatible: bump the minor version (
1.1.0). A change that breaks the response (renamed or removed fields) needs a new major.The template is rendered with sample input when the file loads; a template that doesn't render valid JSON stops the file from loading (the previous version keeps serving). The rules are in query templates.
Step 6 — Partners add a grant
A partner's consent must carry a grant for the new controller, naming scope IDs from the new registry's catalogue (at least the source's scopes), to get the new data. A consent held in the Consent Manager (consent_id) needs the grant too, so a new consent is recorded. Example, for loan-profile with a livestock source:
Partners whose consent lacks the new grant:
optional
It is reported denied (detail: "the consent has no grant for livestock-registry") and not called; the rest of the response is unchanged
mandatory
The request fails before any registry is called: 403 consent_grant_missing
So add a new source as optional unless every partner can be asked to update its consent first. The describe endpoint's consent_grants_needed lists the new controller once the use case reloads.
Step 7 — Test
Describe:
GET /composite/v1/use-cases/loan-profileshould list the new source, itsdepends_on, the new output fields andlivestock-registryinconsent_grants_needed. If it doesn't, check the Composite's logs for a load error.End to end: rerun the Exchange setup with
--registry <controller>=<namespace>for the new registry: it adds the Composite's key to that department's PM and a binding and policy with the use cases' scopes to its CM. Then test with the partner test, which builds the consent from the use case'sconsent_scopes.Check the statuses: with a grant and a matching record the new source is
ok; without a recordno_record; without a grantdenied; with the registry downunavailable, while the rest of the response still comes back.
Last updated
Was this helpful?