Skip to content
Registry StackDocsv0.48.0

Export a lookup for Evidence

View as Markdown

Base Registry Engine (BReg) exports an explicitly selected compiled lookup as a reviewed Source contract. Import merges that Source, its selector profiles, and named preparation and extraction Functions into an existing normalised EvidenceProject. Evidence owns the AssertionDefinitions those facts answer, caller grants, minimum disclosure, signing, and deployment configuration. Live acquisition uses BReg’s ordinary HTTP lookup API.

This is an optional authoring path. Evidence’s existing OpenAPI authoring, custom HTTP adapters, and SQLite sources remain usable without an export, import manifest, or named connection.

Start with an authored registry whose selected access profile already grants the lookup and the readable fields you intend to expose. The exporter reads the compiled model, including locked modules and derived SQL assets. It does not change the registry or create an access permission.

Terminal window
mkdir exports
bregctl generate evidence-source ./registry \
--access-profile evidence-source --record-type record \
--selector by-code --selector by-registration-number \
--fields status --source-id registry-status --connection registry \
--output ./exports/registry-status

The generated Adapter pack declares the exact authentication kind its endpoint binding must use. A direct export defaults to static-authorization; select --authentication oauth2-private-key-jwt when the reviewed Evidence target uses that flow. Under oauth2-private-key-jwt the Evidence target states clientAssertionAudience: the authorization server’s issuer identifier, exactly as its metadata publishes it, which the client assertion carries as its only audience (RFC 10070 section 4). It has no default. Changing the selection changes the pack version and export provenance, so an import or update cannot treat different authentication-contract bytes as the same immutable pack.

Repeat --selector to offer alternatives in the same source. Each request chooses exactly one profile and makes one lookup, with no fallback search. Use another export with another --source-id when the selected facts, authority, or intended maintenance boundary differ. Several AssertionDefinitions can reuse one Source without exporting it again.

--fields names logical BReg fields, as does --record-type. The compiler resolves API property aliases, so a registration-number field can become the registrationNumber property on the wire while keeping its logical name in Evidence selectors and facts.

Two optional inputs shape what the generated lookup does with the returned record. Both name fields that are already in --fields, and without them the generated files are unchanged.

  • --require-value FIELD=VALUE lists the values a fact field may hold. Repeat the flag to allow several values for one field. A record whose value is not listed answers no match, the same answer as a record whose fact is missing. A caller receives the same answer for a refused record and an unknown one. Only the Evidence audit record of a single request and the evidence_source_lookups_total metric record the difference (no-match versus unresolved). A request batch audits both items as not available, and the metric still counts them apart. The check runs in the generated lookup, never in derived logic. It runs after the identity check and before any fact is returned. Use it as defence in depth beside the access profile’s row boundary. For example, a person register can refuse inactive people even if a deployment’s token claim is widened by mistake. The value is read according to the field’s type. A boolean takes true or false, and an int64 takes a whole number. A vocabulary field takes a code of the vocabulary. A string takes text within the field’s length bounds, and a text field takes text within its maximum length. A date takes a calendar date as YYYY-MM-DD. A uuid or reference field takes a lowercase hyphenated uuid, the spelling a record is read back in. No value may hold a control character, and other field types cannot carry a required value. The pack version binds each value as the lookup compares it, so 7 and 007 for an int64 are the same rule.
  • --optional-fields A,B names facts that a record may leave empty. A null value does not cause a no-match. The fact is left out of the answer, and the generated fact schema does not list it as required. A key that is absent from the response is still a protocol error, because it means the projection or the read grant lost the field. Use it when a record can legitimately have no value, such as a person with no recorded residence area.

The command refuses a required value that does not fit the field’s type, or that names a field that is not an exported fact. It also refuses an empty value list, and a field that is both required to hold a value and optional. The generated lookup script spells out every required value, and Evidence reads a script file of at most 64 KiB. The command refuses required values that would make the script larger, as a few long text values can. Both inputs are part of the pack version, so changing either one produces a new pack version. A selector field that is also listed in --fields becomes a required fact. A fixture or record that leaves it out then fails. Keep selector fields out of --fields unless you want them returned.

For each selected alternative, the generated request uses the fixed lookup route, method, and access profile. It asks for the selected facts plus only that alternative’s identity fields, and those identity fields must already be readable. The command reports additional identity fields and generated profile names, and it refuses insufficient authority with a diagnostic.

The output directory must be new. Generate the next version into another directory so that you can compare and review it before changing an Evidence project.

Start with the maintained composition inputs

Section titled “Start with the maintained composition inputs”

The default bregctl init writes the minimal contact directory. It deliberately supplies no Evidence lookup grant, source client, or unique business key. The composition inputs shipped with the BReg product (in the repository at your release tag) include an explicit BReg registry with code and registration-number selectors and a lookup-only evidence-source profile. Its readable status is separate from its private label.

The complete offline-starter in those inputs is an independent normalised EvidenceProject. Initialise a new editable project, then check its 13 synthetic SQLite cases without starting a registry or service:

Terminal window
evidencectl init ./evidence --starter /path/to/offline-starter --profile local
evidencectl check ./evidence
evidencectl test ./evidence --target ./evidence/local-target.yaml

Its evidence.yaml owns Sources, selector profiles, named Functions, and AssertionDefinitions. local-target.yaml binds local resources, and dev-authority.yaml supplies complete disposable caller authority. The tracked inputs contain secret references, and initialisation creates owner-only local keys.

After exporting your selected BReg lookup, import it into that existing project:

Terminal window
evidencectl source import ./exports/registry-status --project ./evidence

Import creates no assertion meaning or caller grant. Merge the maintained starter/definitions.yaml.fragment Functions and AssertionDefinitions into the existing evidence.yaml, and copy its functions/ and fixtures/ files. The fragment is ordinary authoring input, not a complete project or an init --starter template. Keep the independent SQLite definition and the imported Source declarations. The resulting project has three definitions and two Sources, with 35 synthetic fixture cases across the complete composition.

Generate a fresh complete local target after adding definitions:

Terminal window
evidencectl target new ./configured-target --local --project ./evidence

Review its separate caller grants and add the named registry connection to configured-target/target.yaml. Then check, test, and package that exact target:

Terminal window
evidencectl check ./evidence --target ./configured-target
evidencectl test ./evidence --target ./configured-target
evidencectl package ./evidence --target ./configured-target --output ./candidate

Packaging writes an immutable bundle/ and a separate target handoff; it deploys neither product. Recorded-source fixtures establish bounded calculation, identity checks, and refusals. They do not establish live HTTP authorisation, signing, or retained-session operation.

You can use an existing authored registry before it has an Evidence lookup or client. Generate the export with bregctl generate evidence-source, then add it with evidencectl source import as shown above. The import supplies no AssertionDefinition or Evidence caller grant. A lower-level bregctl dev export-client copies an explicit retained client pair and grants no authority. Maintain an already imported Source through source diff and source update, rather than attaching it again under conflicting choices. The development command reference covers preparing a dedicated source client on a retained session.

The export records a logical connection name, registry in this example. The Evidence operator supplies its fixed base URL, authentication, and optional TLS trust profile in the normalised target’s connections map. Credentials remain logical secret references resolved by that deployment. A BReg package or metadata response never supplies Evidence caller authority.

When the exported Record type declares accessLog, the source opts into forwarding the Evidence requester’s verified identity and purpose. The Evidence connection’s verified OAuth client ID must also appear in that Record type’s accessLog.trustedIntermediaries; otherwise BReg refuses the forwarded request. Forwarded attribution does not grant Record authority. Give subjects a log of reads of their Record describes the log.

Use the existing authentication mode appropriate for the source. A named connection shares its HTTP pool, admission limit, and OAuth token state across the sources that explicitly reference it within one Evidence process. Separate names keep separate resource owners. Existing inline source configuration remains available.

The exporter intentionally refuses a verified-claim lookup. Such a lookup uses claims of the source workload’s token, which do not identify the Evidence caller. Select a reviewed request lookup when the caller’s authorised selector values must identify the Record.

The generated extraction adapter uses Evidence’s optional extract(response, selectors, context) form. It checks the returned selected identity’s scalar type and exact value before returning matched facts. A missing, wrongly typed, or mismatched identity fails as a source protocol error. No AssertionDefinition can skip that check by replacing its derive Function.

Only the explicit fact fields enter the fact set. A fact keeps the field’s declared pattern in both generated schemas, and a decimal fact states its declared precision and scale as a pattern. A selector field’s pattern stays out of the pack, because the identity check already requires the returned value to equal the caller’s input. Every pattern the schemas carry is part of the pack version. The export refuses a pattern with a construct that PostgreSQL and Evidence read differently, rather than carry it with another meaning. It refuses . outside brackets, because only PostgreSQL lets it match a line break, and a string or text value can hold one. It also refuses the \w and \s classes, which are Unicode in PostgreSQL and ASCII in Evidence. The same goes for \b, \x, POSIX classes such as [[:alpha:]], PostgreSQL’s own anchors, and embedded options such as (?i). It refuses an escaped backslash followed by c and a letter, because Evidence reads that backslash as the start of a control character. It also refuses any pattern Evidence cannot compile, such as a lookbehind whose length varies. Spell the characters out instead, for example [A-Za-z], or [^\n] for any character but a line break. An absent or null required fact produces no match and cannot become an authoritative negative answer. BReg recognises a genuine unresolved lookup only by its exact declared Problem Details status, type, and code. Other HTTP failures remain failures.

Selectors support bounded nonempty strings, dates, booleans, and UUID or reference fields using Evidence’s uuid type. UUID facts carry JSON Schema format: uuid. Both require exactly 36 ASCII characters in the hyphenated 8-4-4-4-12 lowercase hexadecimal form, the spelling BReg itself returns. The adapter refuses uppercase and other same-length malformed values before source access or signing. Composite profiles must fit Evidence’s aggregate selector bound. String maxima allow four UTF-8 bytes per BReg character. The adapter never normalises identity values, so use the spelling the provider returns. Vocabulary facts retain their enum; vocabulary selectors require a reviewed codelist artifact, so this exporter refuses them with adapter guidance.

BReg’s unrestricted int64 selector range exceeds Evidence’s exact safe-integer selector range, so the exporter refuses it instead of silently narrowing its advertised identity contract. It refuses a string selector field that accepts the empty value, an explicit or defaulted minimumLength of 0, for the same reason. Declare a minimumLength of at least 1, or maintain a reviewed custom adapter. Use a bounded string selector or maintain a reviewed custom adapter for unsupported shapes. Bounded scalar facts are supported; structured and spatial facts require a custom adapter. Evidence reads a schema file of at most 256 KiB. The export refuses a pack whose generated schema is larger, as many long vocabulary facts can make it.

Terminal window
evidencectl source import ./exports/registry-status --project ./evidence
evidencectl source diff ./exports/registry-status-next --project ./evidence
evidencectl source update ./exports/registry-status-next --project ./evidence

The optional source export contract in the Evidence authoring projects reference (in the repository at your release tag) defines checksums, explicit customisation resolutions, shared artifact ownership, and interrupted-update recovery. Imported files remain ordinary authored files. Use evidencectl source detach registry-status ./evidence to retain them under your own maintenance.

The consumed behaviorRevision covers selected fields, selectors, authority, and reached derived behaviour. A reached derived SQL file is fingerprinted as one implementation, together with its referenced source schemas and row visibility. An unused derived computation or unrelated field on a simple stored-field lookup does not change that consumed identity. The complete registryRevision is separate export provenance.

Changing a Record’s values does not require another export, but changing consumed lookup behaviour does. Build and test the Evidence candidate against the exact provider candidate before a coordinated deployment. The export is an offline contract, not a request-time attestation of the currently running provider. Independently evolving providers require a paused, coordinated cutover when their consumed meaning changes.

A governed Rhai Action can acquire verified assertions before finalising its writes. Actions and Proposals covers that Action plan and Evidence path. The farmer landholding example project in the repository shows preprocessing, early refusal, conditional disclosure, and exact offline mocks. Imported client contracts define the signed processing ceiling, and operator configuration supplies fixed endpoints, credentials, and trust. This is distinct from the lookup export described on this page, and it does not grant BReg authority over Evidence source access or signing.