Worked Examples
Developer reference for discovery-to-library ingestion — Unified Discovery
Examine ingestion contracts for provider identifiers, normalized metadata, source rights, duplicate handling, persistence, audit events, and project access boundaries.
Application: Unified Discovery
Integration boundary: Unified Discovery → Library
Reference classification: Developer Reference / Integration Contracts / Research Source Ingestion
Audience: Backend engineers, application architects, integration developers, QA engineers, data stewards, and technical reviewers
Technical level: Advanced
Reference technologies: REST-style APIs, JSON, Python 3, PostgreSQL-style transactional semantics, and provenance metadata
Relevant specifications: HTTP Semantics (RFC 9110), Problem Details for HTTP APIs (RFC 9457), W3C PROV-O, and OWASP API Security guidance
Primary outputs: Versioned ingestion contract, ownership map, authorization design, source-resolution requirements, idempotency rules, failure taxonomy, reproducible tests, and release acceptance evidence
Estimated reading time: 17–22 minutes; 40–55 minutes including the reference tests
1. Service responsibility
The discovery-to-Library ingestion capability transfers a selected research source from a discovery result into a persistent Library record while preserving source identity, metadata, rights, provenance, and version relationships.
The integration must distinguish between:
- A discovery result returned by an external or internal provider.
- The authoritative source represented by that result.
- The ingestion operation and its authorization context.
- The locally persisted Library record.
- The research project or workspace associated with that record.
- Any later analysis, scientific review, or publication.
Primary technical acceptance condition: The imported Library record retains a verifiable reference to the original provider source and selected revision, and the original provider reference remains resolvable under the applicable provider contract.
Persisting a URL string alone does not satisfy the resolution requirement.
The integration must also prevent unauthorized cross-tenant access, unapproved content transfer, source revision substitution, duplicate writes, and silent promotion of draft materials into reviewed or public states.
2. Establish implementation ownership
Before changing code, identify the actual component responsible for each operation.
| Responsibility | Likely logical owner | Required verification |
|---|---|---|
| Provider search and retrieval | Unified Discovery | Actual provider registry and adapter code |
| Provider reference normalization | Discovery integration boundary | Source schema and normalization rules |
| Trusted identity and tenant claims | Platform Core or the deployed identity service | Issuer, authentication middleware, token validation |
| Source rights evaluation | Library governance or designated rights service | Policy ownership and enforcement code |
| Library record identity | Library | Actual primary keys and uniqueness constraints |
| Library persistence | Library | Database schema, migrations, transactions |
| Source provenance relationships | Library or shared provenance component | Implemented data model and link semantics |
| Ingestion orchestration | Verified integration service | Actual request handler and workflow state |
| Project ownership | Workspace or trusted ownership service | Authoritative project-to-owner mapping |
| Scientific review | Research governance workflow | Actual reviewer and approval controls |
| Public release | Research or publication service | Separate publish authorization and release gate |
These are architectural hypotheses, not verified implementation locations.
Where a single deployed service owns several responsibilities, document that fact rather than inventing artificial service boundaries.
Do not assign authoritative Library identity or publication status to the discovery frontend merely because the frontend initiates the operation.
3. Define the trust boundary
Discovery results originate from potentially external providers and should be treated as untrusted input until validated.
External provider
|
| Untrusted metadata and identifiers
v
Discovery adapter
|
| Normalized source candidate
v
Trusted ingestion boundary
|
+-- Authentication and tenant validation
|
+-- Source identity verification
|
+-- Rights and operation authorization
|
+-- Revision and schema checks
|
+-- Idempotency reconciliation
|
v
Library transactional persistence
|
+-- Library identity
+-- Source reference
+-- Provenance activity
+-- Audit record
|
v
Private draft Library artifact
The client must not be permitted to declare itself authorized through a request-body flag.
Instead, the backend should obtain the authenticated principal and relevant tenant or project claims from trusted authorization infrastructure.
Provider metadata may inform the rights decision but must not independently grant the user permissions that the trusted system has not established.
4. Define the ingestion modes
The integration should distinguish three conceptual ingestion modes.
| Mode | Stored material | Required gate |
|---|---|---|
| reference_only | Authorized provider identity and minimal reference metadata | Reference and metadata-use permission |
| metadata_only | Permitted descriptive metadata and provenance | Metadata retention rights |
| content | Permitted source content plus metadata and provenance | Affirmative content acquisition and storage authorization |
Not every provider supports every mode.
A content URL should not be treated as permission to download, persist, redistribute, or publish the referenced content.
The reference implementation below intentionally supports only metadata-only ingestion.
5. Proposed versioned ingestion request
Use an explicitly versioned contract so that source normalization, validation, and persistence behavior can evolve without silently changing existing consumers.
Illustrative endpoint only:
POST /api/example/v1/library/ingestions
This path is not a claim about an existing Sustainable Catalyst route.
5.1 Proposed request body
{
"schema_version": "1.0",
"project_id": "synthetic-project",
"ingestion_mode": "metadata_only",
"source": {
"provider_id": "synthetic-provider",
"provider_record_id": "record-017",
"source_revision": "v1",
"canonical_reference": "https://example.org/datasets/record-017"
},
"expected_source_revision": "v1",
"idempotency_key": "synthetic-request-001"
}
All identifiers and URLs are illustrative.
The request should not include trusted organization identity, authorization status, reviewer approval, or public visibility as client-authoritative values.
The backend must derive these from verified identity, ownership, and policy state.
5.2 Proposed field requirements
| Field | Type | Validation |
|---|---|---|
| schema_version | String | Supported contract version |
| project_id | Identifier | Exists and belongs to authorized tenant |
| ingestion_mode | Enum | Supported mode and rights policy |
| provider_id | Identifier | Registered and enabled provider |
| provider_record_id | String | Valid under provider-specific rules |
| source_revision | String | Resolvable or explicitly supported version semantics |
| canonical_reference | URI | Matches verified provider source identity |
| expected_source_revision | String | Matches the intended source version |
| idempotency_key | Opaque string | Scoped, bounded, and protected against conflicting reuse |
For content-bearing import, separate content acquisition and checksum fields may be needed. Their existence and semantics must be established from the actual implementation.
6. Proposed successful response contract
A successful ingestion response should identify the created or existing Library record and preserve its source reference.
{
"schema_version": "1.0",
"operation_id": "synthetic-operation-001",
"outcome": "created",
"library_record": {
"id": "lib-synthetic-001",
"revision": "1",
"visibility": "private",
"review_status": "draft",
"content_stored": false
},
"source_reference": {
"provider_id": "synthetic-provider",
"provider_record_id": "record-017",
"source_revision": "v1",
"canonical_reference": "https://example.org/datasets/record-017",
"resolution_status": "verified_in_synthetic_fixture"
},
"provenance": {
"ingestion_activity_id": "synthetic-activity-001"
},
"publication_approved": false
}
The response should not present synthetic resolution, a stored source link, or an HTTP success code as proof of actual external provider resolution.
Where creation is asynchronous, the API should return an operation or job state rather than falsely implying that all persistence and verification steps have completed.
7. Establish a typed failure contract
Failures should be structured and specific enough for safe operator action.
| Code | Meaning | Recovery |
|---|---|---|
| AUTH_REQUIRED | Trusted authentication missing | Use supported sign-in or service identity |
| ACCESS_DENIED | Source or project operation not permitted | Review authorization; do not retry with altered identifiers |
| SOURCE_NOT_FOUND | Provider source unresolved | Verify provider and source reference |
| SOURCE_IDENTITY_MISMATCH | Returned source differs from requested identity | Reject and investigate mapping |
| SOURCE_REVISION_CONFLICT | Version differs from expected revision | Preserve original version and resolve conflict |
| RIGHTS_NOT_GRANTED | Requested handling lacks permission | Reject or use a separately approved mode |
| SCHEMA_INVALID | Required fields missing or incompatible | Correct contract or normalization |
| IDEMPOTENCY_CONFLICT | Same key reused for different operation | Investigate; do not overwrite existing result |
| DEPENDENCY_UNAVAILABLE | Provider, identity, or storage dependency failed | Bounded safe retry after state inspection |
| UNSAFE_SOURCE_REFERENCE | Reference violates approved resolver policy | Reject; never follow untrusted destination blindly |
| PERSISTENCE_FAILURE | Database or storage operation incomplete | Reconcile transaction or job status |
| PROVENANCE_FAILURE | Required lineage or audit relationship missing | Do not mark ingestion accepted |
RFC 9457 provides a standardized representation for machine-readable HTTP API problem details.
Illustrative error payload:
{
"type": "https://example.org/problems/source-revision-conflict",
"title": "Source revision conflict",
"status": 409,
"detail": "The selected source revision no longer matches the requested revision.",
"code": "SOURCE_REVISION_CONFLICT",
"trace_id": "synthetic-trace-001"
}
The actual mapping of errors to HTTP statuses must be defined by the deployed API.
Do not return provider credentials, protected source content, raw internal exceptions, or secret-bearing request parameters in error bodies.
8. Design safe provider resolution
The original provider reference must remain resolvable, but source resolution creates a security boundary.
Never implement provider resolution by fetching arbitrary URLs supplied by untrusted clients.
An unsafe design might resemble:
Client supplies arbitrary URL
|
v
Backend fetches URL without restriction
This can expose internal services, cloud metadata endpoints, or private network resources through server-side request forgery.
A safer design should use:
- A registered provider adapter.
- Provider-specific identifier validation.
- Approved external destinations.
- Network and DNS controls.
- Restrictions on private, loopback, and link-local destinations.
- Redirect validation at every destination change.
- Connection and response-size limits.
- Timeouts and bounded retries.
- Content-type and payload validation.
- Authorization checks independent of URL accessibility.
HTTPS syntax validation alone is insufficient protection against SSRF.
Follow the OWASP Server-Side Request Forgery Prevention Cheat Sheet and adapt its recommendations to the deployed networking environment.
8.1 Provider resolution contract
resolve(
registered_provider_id,
provider_record_id,
expected_revision
)
Returns:
authoritative provider identity
record identity
revision
canonical reference
permitted metadata
rights metadata
verified retrieval evidence
The resolver must not silently substitute a newer revision or unrelated canonical reference.
Where the provider no longer supports a historical revision, the system should preserve the original reference and record the resolution limitation.
9. Define the persistence boundary
Metadata-only ingestion typically requires several related records or fields.
A proposed relational implementation may include:
- Library record identity.
- Provider source reference.
- Source revision and canonical identifier.
- Normalized metadata.
- Rights decision and permission scope.
- Provenance activity.
- Idempotency receipt.
- Audit event.
These should form a coherent committed result.
A failure must not leave a Library record marked complete when required provenance or rights evidence was not committed.
For database-local operations, use transactions and relevant uniqueness constraints.
For operations spanning a database and external object storage, use an explicit staged workflow with reconciliation or compensating actions. Do not assume a single database transaction can atomically commit external storage writes.
10. Proposed transactional state machine
REQUESTED
|
v
VALIDATING
|
+--> REJECTED
|
v
AUTHORIZED
|
v
SOURCE_RESOLVED
|
+--> BLOCKED
|
v
RIGHTS_VERIFIED
|
v
PERSISTING
|
+--> RECOVERY_REQUIRED
|
v
COMMITTED
|
v
RECONCILED
|
v
ACCEPTED_PRIVATE_DRAFT
Not every implementation needs each state persisted. The actual state model should reflect its transaction and recovery boundaries.
Import acceptance does not imply scientific review or publication approval.
If an operation is canceled after commit, the system must not pretend that the committed record was never created. Use the deployed revision, retirement, or compensating-operation policy.
11. Implement idempotency correctly
Idempotency prevents ambiguous retries from producing unintended duplicate effects.
A robust idempotency contract should distinguish:
- A repeated request with the same key and identical operation.
- A repeated key with a changed request payload.
- A legitimate new source revision.
- A different tenant using the same opaque key.
- An operation whose original result is still pending.
- A request that may have committed before the client connection failed.
Recommended logical uniqueness scope:
tenant identity
+
idempotency key
Bind the key to a canonical request fingerprint.
For an exact retry, return the original operation outcome or current operation state.
For a conflicting request using the same key, reject it rather than overwrite an unrelated record.
A production implementation should enforce atomic key reservation and result persistence through appropriate database constraints and transaction logic. An in-memory dictionary is not a concurrency-safe substitute.
RFC 9110 cautions against automatic retries of non-idempotent requests unless the client has evidence that retrying is safe.
12. Define audit and provenance events
Audit events should support incident reconstruction without exposing confidential data.
| Event | Meaning | Recommended fields |
|---|---|---|
| ingest.requested | Operation initiated | Operation ID, tenant, actor reference, source identity |
| ingest.authorized | Access decision completed | Policy version, permitted action, decision |
| source.resolved | Provider source identity checked | Provider, record, revision, resolution outcome |
| rights.evaluated | Requested storage and processing assessed | Rights basis, permitted mode, decision |
| ingest.committed | Library persistence committed | Record ID, revision, transaction reference |
| ingest.replayed | Existing idempotent outcome returned | Operation ID and request fingerprint |
| ingest.rejected | Operation denied or invalid | Typed reason and sanitized trace ID |
| ingest.recovery_required | Partial failure requires reconciliation | Last durable state and recovery reference |
W3C PROV-O distinguishes entities, activities, and agents. Its model can be used to represent the relationship between a provider source, ingestion activity, and generated Library record.
Audit events and provenance records have overlapping but different purposes. Audit records document operational actions and decisions; provenance captures meaningful source and derivation relationships.
13. Reference implementation: isolated contract model
The following Python example demonstrates the central contract using only synthetic data.
It does not implement a web server, database, provider network adapter, or production authentication.
13.1 Prepare the environment
mkdir discovery-library-contract
cd discovery-library-contract
python3 -m venv .venv
source .venv/bin/activate
python --version
Save as ingestion_contract.py.
from dataclasses import dataclass
from hashlib import sha256
import json
class IngestError(Exception):
def __init__(self, code):
super().__init__(code)
self.code = code
@dataclass(frozen=True)
class Principal:
principal_id: str
tenant_id: str
project_ids: frozenset[str]
@dataclass(frozen=True)
class Source:
provider_id: str
record_id: str
revision: str
canonical_reference: str
title: str
rights: str
metadata_allowed: bool
@dataclass(frozen=True)
class Request:
project_id: str
provider_id: str
record_id: str
expected_revision: str
mode: str
idempotency_key: str
SOURCE = Source(
provider_id="synthetic-provider",
record_id="record-017",
revision="v1",
canonical_reference=(
"https://example.org/datasets/record-017"
),
title="Synthetic Research Dataset",
rights="synthetic-metadata-only",
metadata_allowed=True
)
PRINCIPAL = Principal(
principal_id="synthetic-owner",
tenant_id="synthetic-tenant",
project_ids=frozenset({
"synthetic-project"
})
)
REQUEST = Request(
project_id="synthetic-project",
provider_id="synthetic-provider",
record_id="record-017",
expected_revision="v1",
mode="metadata_only",
idempotency_key="request-001"
)
class FixtureResolver:
def __init__(self, sources):
self.sources = {
(s.provider_id, s.record_id): s
for s in sources
}
def resolve(self, provider_id, record_id):
return self.sources.get(
(provider_id, record_id)
)
def canonical_request(request):
payload = {
"project_id": request.project_id,
"provider_id": request.provider_id,
"record_id": request.record_id,
"expected_revision": (
request.expected_revision
),
"mode": request.mode
}
return json.dumps(
payload,
sort_keys=True,
separators=(",", ":")
)
def request_fingerprint(request):
return sha256(
canonical_request(request).encode(
"utf-8"
)
).hexdigest()
def source_key(tenant_id, source):
return (
tenant_id,
source.provider_id,
source.record_id,
source.revision
)
class FixtureLibrary:
def __init__(self, resolver):
self.resolver = resolver
self.records = {}
self.idempotency = {}
self.audit = []
def ingest(self, principal, request):
if (
not principal.principal_id
or not principal.tenant_id
):
raise IngestError("AUTH_REQUIRED")
if request.project_id not in (
principal.project_ids
):
raise IngestError("ACCESS_DENIED")
if (
not request.idempotency_key
or not request.provider_id
or not request.record_id
or not request.expected_revision
):
raise IngestError("SCHEMA_INVALID")
if request.mode != "metadata_only":
raise IngestError(
"UNSUPPORTED_INGESTION_MODE"
)
scope = (
principal.tenant_id,
request.idempotency_key
)
fingerprint = request_fingerprint(
request
)
if scope in self.idempotency:
saved = self.idempotency[scope]
if saved["fingerprint"] != (
fingerprint
):
raise IngestError(
"IDEMPOTENCY_CONFLICT"
)
return {
"outcome": "existing",
"record": saved["record"]
}
source = self.resolver.resolve(
request.provider_id,
request.record_id
)
if source is None:
raise IngestError(
"SOURCE_NOT_FOUND"
)
if (
source.provider_id
!= request.provider_id
or source.record_id
!= request.record_id
):
raise IngestError(
"SOURCE_IDENTITY_MISMATCH"
)
if source.revision != (
request.expected_revision
):
raise IngestError(
"SOURCE_REVISION_CONFLICT"
)
if not source.metadata_allowed:
raise IngestError(
"RIGHTS_NOT_GRANTED"
)
key = source_key(
principal.tenant_id,
source
)
if key in self.records:
record = self.records[key]
outcome = "existing"
else:
identity = json.dumps(
list(key),
separators=(",", ":")
)
library_id = "lib-" + sha256(
identity.encode("utf-8")
).hexdigest()[:20]
record = {
"library_id": library_id,
"tenant_id": principal.tenant_id,
"project_id": request.project_id,
"source": {
"provider_id": source.provider_id,
"record_id": source.record_id,
"revision": source.revision,
"canonical_reference": (
source.canonical_reference
),
"title": source.title,
"rights": source.rights
},
"ingestion_mode": "metadata_only",
"content_stored": False,
"visibility": "private",
"review_status": "draft",
"publication_approved": False
}
self.records[key] = record
outcome = "created"
self.idempotency[scope] = {
"fingerprint": fingerprint,
"record": record
}
self.audit.append({
"event": "ingest.committed",
"tenant_id": principal.tenant_id,
"library_id": record["library_id"],
"source_revision": source.revision
})
return {
"outcome": outcome,
"record": record
}
def reconcile(source, result):
record = result["record"]
stored = record["source"]
if (
stored["provider_id"]
!= source.provider_id
or stored["record_id"]
!= source.record_id
or stored["revision"]
!= source.revision
or stored["canonical_reference"]
!= source.canonical_reference
or stored["title"]
!= source.title
):
raise IngestError(
"SOURCE_IDENTITY_MISMATCH"
)
if (
record["visibility"] != "private"
or record["review_status"] != "draft"
or record["publication_approved"]
):
raise IngestError(
"UNAPPROVED_PUBLICATION_STATE"
)
return True
def main():
library = FixtureLibrary(
FixtureResolver([SOURCE])
)
first = library.ingest(
PRINCIPAL,
REQUEST
)
replay = library.ingest(
PRINCIPAL,
REQUEST
)
assert first["outcome"] == "created"
assert replay["outcome"] == "existing"
assert reconcile(SOURCE, first)
print(json.dumps({
"classification": "synthetic",
"first_operation": first["outcome"],
"replay": replay["outcome"],
"source_reconciliation": "PASS",
"library_record": first["record"],
"audit_events": library.audit,
"real_provider_resolution": "NOT_TESTED",
"database_persistence": "NOT_TESTED",
"cross_owner_api_security": "NOT_TESTED",
"production_acceptance": "NOT_TESTED"
}, indent=2))
if __name__ == "__main__":
main()
This fixture illustrates source identity preservation, revision comparison, tenant-scoped idempotency-key reuse, metadata rights checks, and private draft state.
It does not enforce real network security, concurrent transactions, robust identifier validation, durable storage, trusted authentication, or complete source rights governance.
Its project scope and idempotency rules are simplified. A production implementation must also define whether a source record can belong to multiple projects and how project associations are created or reused.
14. Execute the synthetic contract model
python ingestion_contract.py
Expected high-level results:
First operation: created
Repeated operation: existing
Source reconciliation: PASS
Visibility: private
Review status: draft
Publication approved: false
Real provider resolution: NOT_TESTED
Database persistence: NOT_TESTED
Production acceptance: NOT_TESTED
These are expected fixture outcomes, not deployed system observations.
Restarting the program resets its in-memory state. Production persistence and restart behavior require separate tests against the actual storage implementation.
15. Implement contract and negative tests
Save as test_ingestion_contract.py.
from dataclasses import replace
import copy
import unittest
from ingestion_contract import (
FixtureLibrary,
FixtureResolver,
IngestError,
PRINCIPAL,
REQUEST,
SOURCE,
reconcile
)
class IngestionContractTests(
unittest.TestCase
):
def setUp(self):
self.library = FixtureLibrary(
FixtureResolver([SOURCE])
)
def assert_error(self, code, action):
with self.assertRaises(
IngestError
) as caught:
action()
self.assertEqual(
caught.exception.code,
code
)
def test_create(self):
result = self.library.ingest(
PRINCIPAL, REQUEST
)
self.assertEqual(
result["outcome"], "created"
)
def test_exact_replay(self):
self.library.ingest(
PRINCIPAL, REQUEST
)
replay = self.library.ingest(
PRINCIPAL, REQUEST
)
self.assertEqual(
replay["outcome"], "existing"
)
def test_conflicting_key(self):
self.library.ingest(
PRINCIPAL, REQUEST
)
changed = replace(
REQUEST,
expected_revision="v2"
)
self.assert_error(
"IDEMPOTENCY_CONFLICT",
lambda: self.library.ingest(
PRINCIPAL, changed
)
)
def test_wrong_project(self):
other = replace(
REQUEST,
project_id="unowned-project"
)
self.assert_error(
"ACCESS_DENIED",
lambda: self.library.ingest(
PRINCIPAL, other
)
)
def test_missing_source(self):
other = replace(
REQUEST,
record_id="missing"
)
self.assert_error(
"SOURCE_NOT_FOUND",
lambda: self.library.ingest(
PRINCIPAL, other
)
)
def test_revision_conflict(self):
other = replace(
REQUEST,
expected_revision="v2"
)
self.assert_error(
"SOURCE_REVISION_CONFLICT",
lambda: self.library.ingest(
PRINCIPAL, other
)
)
def test_rights_denied(self):
denied = replace(
SOURCE,
metadata_allowed=False
)
library = FixtureLibrary(
FixtureResolver([denied])
)
self.assert_error(
"RIGHTS_NOT_GRANTED",
lambda: library.ingest(
PRINCIPAL, REQUEST
)
)
def test_content_not_supported(self):
other = replace(
REQUEST,
mode="content"
)
self.assert_error(
"UNSUPPORTED_INGESTION_MODE",
lambda: self.library.ingest(
PRINCIPAL, other
)
)
def test_source_reconciliation(self):
result = self.library.ingest(
PRINCIPAL, REQUEST
)
self.assertTrue(
reconcile(SOURCE, result)
)
def test_tampered_reference(self):
result = copy.deepcopy(
self.library.ingest(
PRINCIPAL, REQUEST
)
)
result["record"]["source"][
"canonical_reference"
] = "https://example.org/other"
self.assert_error(
"SOURCE_IDENTITY_MISMATCH",
lambda: reconcile(
SOURCE, result
)
)
def test_private_draft(self):
result = self.library.ingest(
PRINCIPAL, REQUEST
)
record = result["record"]
self.assertEqual(
record["visibility"], "private"
)
self.assertEqual(
record["review_status"], "draft"
)
self.assertFalse(
record["publication_approved"]
)
def test_unapproved_publication_rejected(self):
result = copy.deepcopy(
self.library.ingest(
PRINCIPAL, REQUEST
)
)
result["record"][
"publication_approved"
] = True
self.assert_error(
"UNAPPROVED_PUBLICATION_STATE",
lambda: reconcile(
SOURCE, result
)
)
def test_missing_idempotency_key(self):
other = replace(
REQUEST,
idempotency_key=""
)
self.assert_error(
"SCHEMA_INVALID",
lambda: self.library.ingest(
PRINCIPAL, other
)
)
def test_tenant_key_scoped(self):
other_principal = replace(
PRINCIPAL,
tenant_id="synthetic-tenant-2"
)
first = self.library.ingest(
PRINCIPAL, REQUEST
)
second = self.library.ingest(
other_principal, REQUEST
)
self.assertNotEqual(
first["record"]["library_id"],
second["record"]["library_id"]
)
def test_audit_event(self):
self.library.ingest(
PRINCIPAL, REQUEST
)
self.assertEqual(
self.library.audit[0]["event"],
"ingest.committed"
)
if __name__ == "__main__":
unittest.main()
Run:
python -m unittest -v test_ingestion_contract.py
The reference suite defines fifteen tests covering creation, retry behavior, idempotency conflicts, project scope, missing records, revisions, metadata rights, unsupported operations, provenance reconciliation, publication-state protection, and basic tenant partitioning.
The cross-tenant test verifies deterministic separation within the fixture. It is not proof of actual API authorization or storage isolation.
16. Required integration and security test matrix
Unit tests alone cannot certify this integration. Additional tests must exercise the real trust and persistence boundaries.
| Case | Expected behavior | Test environment |
|---|---|---|
| Authorized metadata import | Correct source and private Library record persisted | Isolated integration staging |
| Original provider reference | Resolves to matching authoritative identity and intended revision | Approved provider test environment |
| Missing source | Typed rejection without a phantom Library record | Integration staging |
| Wrong tenant | Access denied with no protected metadata disclosure | Two synthetic tenant identities |
| Revoked permission | Subsequent protected reads and writes denied | Trusted identity integration |
| Missing rights | Requested import denied or held for review | Rights-policy fixture |
| Stale source revision | Conflict reported; accepted revision preserved | Versioned provider fixture |
| Incomplete payload | Schema validation failure | Contract tests |
| Duplicate identical request | Existing operation returned; no duplicate effect | Concurrent integration tests |
| Same key, changed request | Idempotency conflict | Concurrent integration tests |
| Unsafe redirect | Disallowed destination never contacted | Isolated network security fixture |
| Private address resolution | Blocked by resolver policy | Isolated SSRF tests |
| Provider timeout | Safe pending or failed state; no false commit | Fault-injection staging |
| Database failure before commit | Atomic rollback or documented recovery state | Disposable database |
| Failure after content upload | Orphaned content reconciled under storage policy | Disposable object storage |
| Private content in public response | Protected fields absent | API security tests |
| Migration and rollback | Schema and source references remain consistent | Restorable staging snapshot |
| Session persistence | Authorized owner retrieves the same Library record | Authenticated browser tests |
| Publication boundary | Ingested record remains draft until separate approval | State-transition tests |
Use synthetic test identities and disposable storage for destructive or adversarial tests.
Do not test unsafe redirects or SSRF behavior against arbitrary public endpoints or production infrastructure.
17. Database constraints and migration planning
Where a relational database is used, confirm the actual schema before drafting migrations.
Relevant constraints may include:
- Unique Library record primary key.
- Tenant-scoped provider source identity and revision.
- Tenant-scoped idempotency key.
- Foreign keys to valid project or ownership mappings where supported.
- Required non-null source identity fields.
- Validated ingestion mode and review-state values.
- Durable provenance and audit references.
- Appropriate indexes for source lookup and idempotency reconciliation.
Do not assume a global uniqueness constraint on provider record ID is correct. Provider identifiers may only be unique within their provider’s namespace.
Before applying a migration, inspect existing duplicates, historical source records, rights information, and version relationships.
17.1 Migration acceptance
A migration should demonstrate:
- Baseline database revision recorded.
- Existing data backed up under approved recovery controls.
- New constraints evaluated against real data patterns.
- Migration executed on a disposable or authorized staging database.
- Backward compatibility assessed for existing consumers.
- Source references and tenant boundaries preserved.
- Rollback or forward-recovery procedure tested.
- Production deployment separately authorized.
Not all database migrations are safely reversible. When rollback is unsafe, document a forward-recovery strategy and operational decision gate.
18. Failure recovery and reconciliation
Partial failures require explicit handling.
| Failure point | Safe handling |
|---|---|
| Before authorization | Reject without source mutation |
| During provider resolution | Record failure; do not fabricate source identity |
| After rights denial | Reject import; preserve minimal authorized audit evidence |
| Before database commit | Rollback applicable local transaction |
| Commit succeeded, response lost | Resolve operation by idempotency key before retry |
| Content stored, metadata commit failed | Reconcile or quarantine object under approved policy |
| Provenance write failed | Do not mark artifact accepted without required relationship |
| Source changed after ingestion | Preserve imported revision and record version relationship |
| Publication attempted too early | Reject until required rights and review gates pass |
Do not automatically delete a historical source or published dependency merely because a newer source revision is available.
Recovery must respect retention, legal hold, research reproducibility, and source-rights requirements.
19. Observability and diagnostic evidence
Operational traces should permit reconciliation of a failed ingestion without exposing protected source material.
Useful fields include:
- Operation ID and sanitized trace ID.
- Authenticated tenant and role reference.
- Provider and source identity.
- Requested source revision.
- Ingestion mode.
- Rights-policy outcome.
- Provider resolution outcome.
- Database commit or operation state.
- Idempotency replay or conflict decision.
- Library record identity when committed.
- Typed failure code.
- Runtime component and code revision.
A log entry showing successful execution is not a substitute for verifying the persisted Library record and its provenance.
Do not log authorization tokens, provider secrets, raw confidential documents, or unfiltered source payloads.
20. Proposed evidence receipt
An implementation acceptance receipt should identify exactly what was tested and against which version.
{
"schema_version": "example-1.0",
"capability": "discovery_to_library_ingestion",
"classification": "synthetic_reference",
"implementation": {
"owning_repository": null,
"commit": null,
"source_path": null,
"api_schema": null,
"database_migration": null
},
"test_environment": {
"isolation": "not_verified",
"database": "not_connected",
"real_provider_used": false,
"synthetic_identity_used": true
},
"contract": {
"version": "1.0",
"mode": "metadata_only"
},
"acceptance": {
"source_identity": "not_tested",
"real_provider_resolution": "not_tested",
"rights_enforcement": "not_tested",
"trusted_authorization": "not_tested",
"idempotency_under_concurrency": "not_tested",
"database_persistence": "not_tested",
"cross_tenant_isolation": "not_tested",
"unsafe_redirect_protection": "not_tested",
"provenance": "not_tested",
"migration_recovery": "not_tested",
"browser_acceptance": "not_tested"
},
"publication_approval": false,
"release_decision": "NO_GO"
}
All unresolved values must remain explicitly unverified until supported by real implementation evidence.
Do not turn a passing synthetic unit-test report into a production acceptance receipt by copying or editing its status fields.
21. Sustainable Catalyst integration boundaries
The discovery-to-Library capability intersects with several intended research-platform components.
| Application | Intended role |
|---|---|
| Unified Discovery | Locate provider sources and preserve selection and source context |
| Library | Own governed source records, metadata, content storage, identity, rights, and provenance |
| Platform Core | Supply trusted identity, tenant, and relevant authorization controls |
| Workspace | Manage project ownership, source use, and governance relationships |
| Workbench | Consume authorized versioned artifacts for reproducible analysis |
| Research Lab | Evaluate evidence quality, methods, and scientific limitations |
| Site Intelligence | Preserve geospatial and acquisition metadata for spatial sources |
| Decision Studio | Use accepted evidence in model and scenario workflows |
| Research | Publish reviewed outputs with appropriate source and provenance relationships |
The actual deployed ownership of these responsibilities must be verified rather than inferred from the application names.
22. Required repository and runtime audit
Before calling this developer reference implementation-verified, inspect:
- Actual Unified Discovery repository and commit.
- Actual Library repository and commit.
- Relevant Platform Core and Workspace ownership contracts.
- Provider adapter and source-resolution code paths.
- Actual request and response schemas.
- Trusted authentication and authorization middleware.
- Rights-policy enforcement.
- Library storage and database models.
- Idempotency constraints and transaction behavior.
- Provenance and audit-event schema.
- Current migrations and production database revision.
- API error codes and retry semantics.
- Executed unit and integration tests.
- Real provider-reference resolution.
- Cross-tenant denial tests.
- Authenticated browser or client acceptance.
- Staging deployment and rollback evidence.
- Unresolved security, operational, and scientific risks.
Document each finding with the exact source path, revision, execution receipt, and actual observed behavior.
When a named operation or field differs from this proposed contract, update the documentation to match verified implementation rather than forcing the software to conform to an unapproved example.
23. Release decision matrix
| Gate | Evidence required | Without evidence |
|---|---|---|
| Implementation ownership | Exact repositories, commits, and code paths | NO-GO |
| Schema compatibility | Executed contract tests and migration review | NO-GO |
| Trusted identity | Authenticated tenant and project authorization tests | NO-GO |
| Source resolution | Actual original provider reference verified | NO-GO |
| Rights compliance | Approved policy and negative tests | NO-GO |
| Idempotency | Replay, conflicting request, and concurrent tests | NO-GO |
| Persistence | Transaction, restart, and retrieval acceptance | NO-GO |
| Provenance | Correct source-to-Library relationship verified | NO-GO |
| Security | Cross-tenant, SSRF, redirect, and data-exposure tests | NO-GO |
| Recovery | Backup, rollback or forward recovery, and partial-failure tests | NO-GO |
| Runtime acceptance | Actual deployed API and browser evidence | NO-GO |
| Scientific publication | Separate scientific, editorial, and rights approval | Not approved for public release |
The decision must reflect the actual capability and release scope. A metadata-only staging acceptance does not certify full-content production ingestion.
24. Developer completion checklist
Before marking this capability complete, confirm:
- The authoritative owner of Library record identity has been verified.
- The provider adapter and original source resolution are implemented and tested.
- Trusted server-side identity and project authorization are enforced.
- Rights are checked independently of source accessibility.
- Supported ingestion modes are explicit.
- Required metadata, source revision, and provenance are preserved.
- Client-supplied URLs cannot bypass resolver restrictions.
- Duplicate and conflicting requests follow documented idempotency semantics.
- Required database and storage operations have tested failure handling.
- Private draft status cannot silently become public approval.
- Cross-owner access and data-disclosure tests pass.
- Actual provider, persistence, and browser acceptance receipts are available.
- Migrations and recovery procedures have been reviewed.
- Documentation references the real code, contracts, and supported release.
25. Technical references
- Fielding, R., Nottingham, M. and Reschke, J. (2022). HTTP Semantics. RFC 9110. Available at: https://www.rfc-editor.org/rfc/rfc9110.html.
- Nottingham, M., Wilde, E. and Dalal, S. (2023). Problem Details for HTTP APIs. RFC 9457. Available at: https://www.rfc-editor.org/rfc/rfc9457.html.
- World Wide Web Consortium (W3C) (2013). PROV-O: The PROV Ontology. W3C Recommendation. Available at: https://www.w3.org/TR/prov-o/.
- World Wide Web Consortium (W3C) (2013). PROV-DM: The PROV Data Model. Available at: https://www.w3.org/TR/prov-dm/.
- OWASP Foundation (n.d.). Server-Side Request Forgery Prevention Cheat Sheet. Available at: OWASP Cheat Sheet Series.
- OWASP Foundation (2023). API Security Top 10. Available at: OWASP API Security Project.
- DataCite Metadata Working Group (n.d.). DataCite Metadata Schema. Available at: DataCite Metadata Schema.
- Python Software Foundation (n.d.). unittest — Unit Testing Framework. Available at: Python documentation.
- PostgreSQL Global Development Group (n.d.). Transaction Isolation. Available at: PostgreSQL documentation.
26. Implementation verification record
| Field | Required evidence |
|---|---|
| Capability owner | Actual service, repository, and commit |
| Entry point | Real API route or integration function |
| Contract revision | Actual request, response, and error schemas |
| Identity integration | Trusted authentication and tenant authorization tests |
| Provider integration | Original source-resolution evidence |
| Rights | Approved rights policy and executed tests |
| Library identity | Primary key and source uniqueness behavior |
| Database migration | Revision, execution evidence, and recovery plan |
| Idempotency | Replay, conflict, concurrency, and retry receipts |
| Provenance | Stored source-to-Library lineage evidence |
| Audit events | Sanitized operational event records |
| Security | Tenant isolation, source resolution, and export tests |
| Persistence | Database, restart, and retrieval verification |
| Failure recovery | Rollback or forward-recovery acceptance |
| Staging | Exact deployed image or build and test environment |
| Browser/client acceptance | Actual authenticated interaction evidence |
| Scientific approval | Separate assessment where required |
| Production decision | GO or NO-GO with reviewer and date |
| Outstanding limitations | Unresolved implementation, security, or governance issues |
Technical completion criterion: Discovery-to-Library ingestion is implementation-verified only when the correct authorized source and revision can be resolved, permitted metadata or content is committed to the appropriate Library identity, idempotent retries and failures are handled safely, provenance remains intact, tenant boundaries hold, and the actual deployed integration passes its documented acceptance gates.
Scientific limitation: A successfully imported Library record is not evidence that the original source is scientifically valid or appropriate for a particular research claim. Scientific appraisal, analytical verification, and publication approval remain separate responsibilities.
Current implementation status: Proposed ownership boundaries, versioned request and response contracts, typed failures, source-resolution safeguards, idempotency requirements, audit and provenance design, synthetic reference code, negative-test definitions, and release gates documented. No specific Sustainable Catalyst Unified Discovery-to-Library API, database migration, provider resolver, or production deployment is certified by this article.
