Adding a Registry
Joining a registry to Agri Stack.
A registry joins Agri Stack by becoming a data source of a use case. This needs no code in the Composite: the registry must speak DCI with consent, the department's PM and CM must accept the Composite, 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.
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 the national ID the farmer logged in with, so the registry must hold it on its records, or link its own key to it (
subject_id_fieldsfor an activity register, e.g. the Farmer ID recorded with the farmer's national ID). If the registry is keyed on the 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 (
PARTNER_AGRI_COMPOSITE) is onboarded in the department's PM at install (Exchange Roledepartment), with its key read from the Composite's JWKS URL; the new registry verifies it with the key PM serves.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 — The Composite's scope policy in the department
The department that runs the new registry decides what it releases to the Composite (data-sharing policies). It needs:
A scope policy for the Composite in the department's PM: partner
PARTNER_AGRI_COMPOSITE, data controllerlivestock-registry, with the scopes and purposes of the use cases that read the registry (e.g.livestock-registry.animals,livestock-registry.owner_reference;credit-assessment), the subject identifier types (FAYDA_FAN,FARMER_ID), the signing algorithms, the maximum validity and the fetch type (scope policy for the Composite). Steps: Releasing Registry Data to the Composite.Trust of the Exchange CM as a consent-token issuer, in the department's CM: Exchange Role department in the department's commons-services form (
global.agriStackExchange.role; it trustsagri-stack-exchange-cmpresented byagri-compositeby default). See Exchange consent tokens.
Partners need nothing per registry: a partner with a policy for loan-profile@1 in the Exchange's PM gets the new source with it, as far as its consent grants it (step 6). A new major version (loan-profile@2) needs its own policy per partner in the Exchange's PM.
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: add the new registry under
registriesin the test's configuration and run it. It checks the department's PM serves the Composite's key, adds the Composite's scope policy there for the use case if missing, and 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?