Skip to content
Registry StackDocsv0.48.0

Optional source exports

View as Markdown

Source import is an optional authoring convenience for providers which publish complete fixed-source artifacts. Existing authored sources and the OpenAPI authoring workflow need no manifest, import state, or migration.

An export carries ordinary source and selector files plus the Adapter pack that the source binds. It does not contain assertion meaning, caller grants, credentials, installation hooks, or executable setup commands. Import reads local files only. It never contacts the provider, runs external setup commands, creates authority, or starts a service. Target validation may execute reviewed bounded Adapter pack scripts against local synthetic fixtures through the ordinary Registry Evidence evaluator.

The maintained source recipes distribute ordinary exports for DHIS2 Tracker and OpenCRVS event search. Each recipe carries its supported technical contract, exact artifact checksums and a separate synthetic fixture-validation project. That project supplies example assertion meaning and local target bindings. Those files are not imported into an institution’s project.

The export directory contains source-export.json:

{
"apiVersion": "id.registrystack.org/formats/breg/evidence-source-export/v1alpha1",
"kind": "BRegEvidenceSourceExport",
"sourceId": "registry-status",
"provenance": {
"producer": "institution-source-exporter",
"revision": "reviewed-provider-revision"
},
"artifacts": [
{
"path": "sources/registry-status.yaml",
"digest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}
]
}

The digest above is illustrative. Each actual digest is sha256: followed by the lowercase 64-character SHA-256 checksum of that file’s exact UTF-8 bytes. The manifest opens with its apiVersion and kind, and is read by the shared configuration reader: a refusal names its code, position, and fix. A manifest written with formatVersion or an artifact sha256 is refused with config.removed-key, naming the member that replaces it. The manifest and artifact entries are closed objects; unknown fields are refused. The manifest is at most 1 MiB and inventories 1 to 256 artifacts, each at most 1 MiB and at most 16 MiB together. provenance is a map of 1 to 32 nonempty printable string pairs, with keys up to 64 bytes and values up to 2048 bytes. Provenance is attribution and review context, never proof of provider authority.

One export inventories exactly sources/<sourceId>.yaml, the Adapter pack the source binds, and one selectors/<selectorId>.yaml file for each selector profile the source inputs use. The pack lives under adapter-packs/<packId>/: its pack.yaml plus every file the pack pins, each digest-checked against the pack. An artifact outside that closure is refused. Pack files are limited to scripts/*.rhai, schemas/*.json, and protocols/*.json, one subdirectory deep. Source and selector files use .yaml and must contain mapping objects. Each carries the apiVersion and kind header of its format. Names are bounded lowercase authoring names. Paths cannot be absolute, contain . or .. components, backslashes, or symbolic links. Files must be regular files with one hard link. The ordinary authoring compiler remains the authority for usable document names, types, references, and pack contracts.

Import normalizes those transport files for the existing evidence.yaml. Sources and selector profiles stay in that project, and the pack files are copied unchanged under adapter-packs/. The importer adds no Function. Comparison reports use normalized artifact identities: source-fragments/<sourceId>.json, selector-fragments/<selectorId>.json, and the adapter-packs/<packId>/... paths. The fragment identities describe project entries. They are not separate authored files. Response and fact schemas are part of the Source fragment. Use the exact normalized identities in the report when resolving a conflict, rather than the original export paths.

The sourceId and all artifact paths are stable identities. They must not contain an export directory name, provider revision, or content checksum. Moving an export directory does not change its identity. Reordering its manifest inventory has no effect. A shared artifact uses exactly the same path and bytes in every export which owns it. A conflicting definition is never silently renamed. Producers namespace source-specific artifacts by the source ID and shared artifacts by a stable, unambiguous technical identity.

A provider’s optional consumed-behavior identity belongs in the source’s ordinary behaviorRevision: sha256:<64 lowercase hexadecimal characters> property. A manifest provenance change alone is not a runtime definition revision. The authoring compiler and runtime own dependency closure and actual definition revision computation.

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

Pass several export directories together when changing a shared artifact. The complete candidate set must agree with every installed owner of that artifact. Passing only one of two owners with changed shared bytes reports both owners and refuses application until their definitions agree.

Comparison uses three separate inputs for each normalized artifact identity:

  1. The previously imported upstream content after normalization.
  2. Current project entries or pack file bytes, including local changes or deletion.
  3. The next upstream content after normalization.

If upstream is unchanged, current customization is preserved. If current bytes still match the previous upstream, an upstream change is safe to propose. If current bytes already match the next upstream, that result is accepted. A different local edit and upstream change require an explicit resolution. No program is automatically merged. Existing unowned destinations also require an explicit choice, even if their bytes are identical.

The report lists additions, changes, deletions, unchanged/customized/retained artifacts, previous and next owners, content checksums, conflicts, provenance changes, and structurally affected definition names. Checksums identify normalized artifact content, not deployment revisions. An optional --target asks the normal compiler/build path to compare actual definition revisions under that complete target. Without it, the report contains structural impact only. Structural validation checks the complete source artifact graph and any existing definitions without requiring a target, local credentials, or a first definition. It includes each existing derivation’s fact reads, so a next fact schema that no longer declares a fact a derivation reads fails structural validation with evidence.project.derivation-fact-undeclared (CONFIG.md). The report identifies its validation kind explicitly. Target validation runs the ordinary compiled-bundle and fixture checks. If the current project cannot yet compile with that target, as before an initial source import, previousValidation.status is unavailable; the report carries only actual next revisions and supplies no invented previous revision.

Diff does not change authored files or the imported baseline. A temporary candidate contains only ordinary authored files and is removed when the command finishes. The original export directories retain the next generated files for review. It copies no secret directory, target, access state, local requests, audit history, or running-service state. Candidates are bounded to 4096 authored files, 64 MiB total, and 16 directory levels.

Write an explicit resolution file and supply it to diff or update. A resolution file is a closed JSON document of kind EvidenceSourceResolution; for editor validation, map the conventional names source-resolutions.json and *.resolutions.json to the shipped source-resolution schema. A file written with formatVersion is refused with config.removed-key:

{
"apiVersion": "id.registrystack.org/formats/evidence/source-resolution/v1alpha1",
"kind": "EvidenceSourceResolution",
"artifacts": {
"adapter-packs/registry-status/pack.yaml": {"type": "keep"},
"source-fragments/registry-status.json": {"type": "adopt"},
"adapter-packs/registry-status/scripts/lookup.rhai": {
"type": "file",
"path": "reviewed/lookup.rhai"
}
}
}
Terminal window
evidencectl source diff ./exports/registry-status-next --project ./evidence \
--resolutions ./source-resolutions.json
evidencectl source update ./exports/registry-status-next --project ./evidence \
--resolutions ./source-resolutions.json

keep retains the current authored bytes or deliberate absence. adopt accepts the next generated bytes or deletion. file accepts the exact bounded local file named, resolving relative paths from the resolution file’s directory. The full candidate graph is validated again after resolution. All choices advance the upstream baseline separately from the exact accepted local bytes, so a kept customization remains visible on the next upstream change.

Obsolete files are deleted only when previously owned, unchanged or explicitly adopted for deletion, and no other owner or authored reference needs them. A conservative exact-reference check retains a file still named elsewhere. It does not rewrite the referencing document. A local edit is never silently deleted. Unrelated authored artifacts are preserved byte for byte.

To take over maintenance of an imported source:

Terminal window
evidencectl source detach registry-status ./evidence

Detachment keeps every file, upstream provenance, and the accepted authored snapshot. Later updates of that source ID are refused; continue maintaining its ordinary files, or publish a distinct source ID. Shared artifacts still used by the detached source require explicit review before another import changes them. Detaching is idempotent.

Local transaction and interrupted recovery

Section titled “Local transaction and interrupted recovery”

Import and build acquire the same operating-system file lock, keyed by the canonical project directory. The lock lives in an owner-private temporary directory, so ordinary builds do not need a writable project or an import setup step. Concurrent operations fail with an actionable retry message.

Only accepted imports create .evidence/source-imports/state.json. It records each upstream manifest and exact bytes, accepted local content, retained obsolete artifacts, and detached provenance. No source record or credential belongs there. Keep this state with the authoring project if future updates must retain their three-way comparison history.

Before application, the tool validates the complete candidate and rechecks the entire authored snapshot plus baseline against what was compared. A changed file requires a fresh comparison. Under the lock it durably writes a bounded rollback journal, replaces complete files atomically, and advances the baseline last. Removing the journal commits the complete state. Directory and file writes are synchronized. This is a local filesystem transaction, not a runtime deployment, service, database, or workflow engine.

An interrupted transaction leaves the journal. The next import or build acquires the lock and restores its complete prior state before reading authored files. Recovery checks all journal entries before changing any file. The project and .evidence directories must be owned and not writable by other users; the import state directory must be owned mode 0700, and its journal and baseline must be owned regular mode 0600 files. These checks apply before replay and do not impose a new project permission requirement when no journal exists. If an independent edit matches neither the recorded before nor after bytes, recovery stops and names only the artifact path. Preserve that edit, restore the recorded before or after content, then retry. The journal remains available for recovery; unrelated or conflicting content is never overwritten.

Editors and other tools do not take this lock. Content preconditions detect their edits before application. A running Registry Evidence process continues to serve its previously built immutable bundle throughout authoring updates.