Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

The Livestock Registry is planned, not built. Its record type, scopes and query below are illustrative; use the real ones of the registry you add.

Step 1 — Registry prerequisites

The registry must answer the Composite exactly as it answers a partner:

  • DCI synchronous search at POST /dci/registry/sync/search on 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) and global.partnerManagementApiUrl pointing at PM. It then accepts the Composite's signature (PARTNER_AGRI_COMPOSITE).

  • Consent enforcement on (global.consentEnforcementEnabled, the default), with global.consentManagerUrl, and global.consentDataController set to the registry's controller ID: here livestock-registry (it defaults to global.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_fields for 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 in meta_data/data-scopes/. The registry publishes them at POST /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 Role department), 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 set partnerId in 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 controller livestock-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 trusts agri-stack-exchange-cm presented by agri-composite by 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: optional for data that is useful but not essential; mandatory only if the use case is meaningless without it (a failure or missing grant then fails the whole request).

  • scopes and optional_scopes: scope IDs from the registry's catalogue. The consent must grant every one of scopes (else a mandatory source fails the request, an optional one is reported denied and not called); optional_scopes it may leave out. They are listed per registry in the describe endpoint's consent_scopes, and in Exchange mode they are the requested_scopes the consent tokens are limited to. See data scopes.

  • Timeouts: timeout_ms and retries per source; check that execution.overall_timeout_ms still covers the slowest path. In loan-profile it is 25000 ms, for two levels of 10000 ms; herd depends 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:

The new source is
Without a 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-profile should list the new source, its depends_on, the new output fields and livestock-registry in consent_grants_needed. If it doesn't, check the Composite's logs for a load error.

  • End to end: add the new registry under registries in 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's consent_scopes.

  • Check the statuses: with a grant and a matching record the new source is ok; without a record no_record; without a grant denied; with the registry down unavailable, while the rest of the response still comes back.

Last updated

Was this helpful?