Worked Examples
Developer reference for cross-provider search — Unified Discovery
Examine proposed cross-provider search contracts for query translation, provider adapters, normalized metadata, authorization, deduplication, and reproducible result ranking.
Application: Unified Discovery
Cross-application area: Platform Core / Library / Research / Workspace / Research Lab / Site Intelligence
Classification: Developer Reference / Cross-Provider Search
Audience: Backend engineers, API developers, search engineers, data engineers, security reviewers, DevOps engineers, and scientific software maintainers
Technical level: Advanced
Reference environment: Python 3.10 or later; standard library for synthetic contract examples
Relevant specifications: RFC 9110, RFC 9111, RFC 9457, W3C DCAT 3, W3C PROV-O, OpenAPI 3.1, and FAIR Guiding Principles
Primary outputs: Versioned discovery contracts, provider provenance, query execution records, typed failures, deduplicated result groups, authorization evidence, persistence receipts, and implementation acceptance records
Estimated reading time: 22–30 minutes, excluding practical exercises
1. Service responsibility and architectural scope
Unified Discovery is intended to search and compare topic matches across permitted scientific data catalogs, scholarly indexes, institutional repositories, and other authorized source services.
Its engineering responsibility is to provide a consistent research-discovery interface without concealing differences in provider identity, search behavior, metadata, rights, and source versions.
The service should:
- Execute searches only against explicitly configured and permitted providers.
- Preserve exact provider-specific query parameters.
- Record actual search execution dates and retrieval timestamps.
- Retain provider-local identifiers and authoritative persistent identifiers.
- Normalize supported metadata without overwriting source evidence.
- Report incomplete results and provider failures explicitly.
- Deduplicate cautiously while preserving original occurrences.
- Enforce project, tenant, and provider permissions.
- Prevent unsafe outbound requests and credential exposure.
- Support governed persistence and authorized handoff to Library or Research.
Primary contract acceptance: Every retained result must be traceable to the provider that returned it and the search execution date of that provider request.
That requirement applies to individual results, combined results, cached representations, saved searches, and downstream research objects.
2. Define ownership before implementation
A cross-provider search may involve multiple services with different sources of authority.
| Component | Intended responsibility | Authority requirement |
|---|---|---|
| Unified Discovery API | Validate and coordinate search requests | Search operation and response contract |
| Provider adapter | Translate queries and parse provider responses | Provider-specific behavior |
| Provider registry | Identify enabled providers and permitted configurations | Approved provider configuration |
| Platform Core | Authenticate users and services, enforce tenant and project authorization | Trusted identity and access policy |
| Library | Maintain governed source identities and saved records | Authoritative source and rights references |
| Research | Associate discovery evidence with research questions and projects | Research object ownership and provenance |
| Workspace | Manage project ownership and governed workflows | Project and organization context |
| Observability infrastructure | Record nonsecret operational traces and metrics | Approved telemetry and retention controls |
These are proposed boundaries, not verified repository ownership.
Before implementing a connector, inspect existing source repositories to determine which service actually owns the relevant identity, authorization, persistence, and publication contracts.
Do not create a second authoritative owner for the same research object merely to simplify the discovery service.
3. Proposed request lifecycle
Authenticated research request
|
v
Request validation
|
v
Trusted authorization check
|
v
Provider selection
|
v
Query translation
|
+-------+-------+
| | |
v v v
Adapter A Adapter B Adapter C
| | |
+-------+-------+
|
v
Response normalization
|
v
Provider provenance binding
|
v
Deduplication and grouping
|
v
Completeness and rights review
|
v
Governed API response
|
+-- Authorized saved search
|
+-- Library source reference
|
+-- Research evidence reference
The request lifecycle must remain bounded even when one or more providers are slow, unavailable, or return incomplete data.
Provider execution failures should not erase valid evidence returned by other providers, but a partially completed search must not be represented as comprehensive.
4. Proposed API request contract
The following JSON illustrates a possible versioned request payload.
Contract status: Proposed. No corresponding production endpoint is asserted.
{
"schema_version": "discovery-search-v1",
"project_id": "project-017",
"query": {
"text": "enhanced rock weathering agricultural soils",
"language": "en",
"date_from": "2020-01-01",
"date_to": "2026-11-15"
},
"providers": [
"catalog-A",
"catalog-B"
],
"options": {
"max_results_per_provider": 50,
"include_provenance": true,
"deduplication": "persistent-identifier",
"allow_partial_results": true
}
}
The server must derive the authenticated actor, authorized tenant, and permitted project scope from trusted context.
Do not trust client-provided organization IDs, provider permissions, or role labels as authoritative.
Validate maximum query length, number of requested providers, pagination budgets, date ranges, supported languages, and allowed result limits.
5. Define provider adapter contracts
Each provider adapter should expose a predictable interface while preserving provider-specific behavior.
| Operation | Input | Output or failure |
|---|---|---|
| Validate configuration | Trusted provider settings | Valid configuration or typed rejection |
| Translate query | Normalized research query | Exact provider query and translation version |
| Execute request | Authorized query and bounded transport context | Provider response or typed transport failure |
| Parse response | Provider representation | Provider-local records and metadata |
| Normalize metadata | Provider-local records | Versioned normalized records with source references |
| Report completeness | Pagination and provider status | Complete, partial, or failed outcome |
| Record provenance | Provider and execution context | Search event and original source identifiers |
A provider adapter should not decide whether the resulting scientific evidence is valid or whether a research conclusion is justified.
Those decisions require separate scientific and governance processes.
6. Preserve exact provider query execution
A normalized user query is not necessarily identical to the request sent upstream.
For each provider, record:
- Provider identifier.
- Connector version.
- Query translation version.
- Exact executed query or a protected durable reference to it.
- Applied filters and date ranges.
- Pagination parameters.
- Execution start timestamp.
- Completion timestamp or failure time.
- Response status and completeness.
- Sanitized correlation identifier.
The precise submitted query may contain private research terms. Do not expose it in public logs or diagnostic responses unless the relevant disclosure is authorized.
For scientific reproducibility, the authorized research record should retain sufficient detail to reconstruct the executed strategy.
7. Define a provider execution record
Illustrative provider execution metadata:
{
"schema_version": "provider-execution-v1",
"execution_id": "execution-017-A",
"provider_id": "catalog-A",
"connector_revision": "adapter-v1",
"query_revision": "query-A-v1",
"searched_at": "2026-11-15T12:00:00Z",
"completed_at": "2026-11-15T12:00:02Z",
"result_count": 23,
"records_returned": 23,
"pagination_complete": true,
"response_classification": "complete",
"provenance_status": "recorded"
}
This is illustrative metadata. The timestamps, counts, and identifiers are synthetic.
Use real, timezone-aware timestamps in deployed software.
A provider response retrieved from cache must retain its original provider execution provenance. Cache insertion or revalidation time must not be substituted for the actual provider search date.
8. Define normalized result identity
A normalized result should preserve both local and external identities.
{
"schema_version": "discovery-result-v1",
"result_id": "result-017",
"source": {
"provider_id": "catalog-A",
"provider_record_id": "record-A-017",
"persistent_identifier": "10.example/record017",
"resource_type": "journal-article",
"source_revision": null
},
"metadata": {
"title": "Synthetic research record",
"publication_date": "2025-06-01",
"observation_period": null
},
"provenance": {
"execution_id": "execution-017-A",
"searched_at": "2026-11-15T12:00:00Z",
"connector_revision": "adapter-v1",
"normalizer_revision": "normalizer-v1"
},
"governance": {
"rights_status": "unverified",
"visibility": "private"
}
}
Do not fabricate persistent identifiers for records that lack them.
Do not overwrite provider-local source identifiers when two providers return the same scholarly object.
9. Separate source identity from normalized identity
Cross-provider result aggregation may identify the same work in multiple catalogs.
For example:
Catalog A: A-017
|
+-- Persistent ID X
|
v
Identity group G1
^
|
+-- Persistent ID X
|
Catalog B: B-044
The identity group must retain both provider occurrences.
Distinct versions, editions, datasets, distributions, and related publications must not be merged solely because their titles are similar.
Persistent identifiers should be normalized and checked according to the relevant identifier scheme rather than treated as arbitrary interchangeable strings.
Where identity cannot be established confidently, preserve separate records and mark the relationship unresolved.
10. Define schema normalization requirements
Different providers may represent the same concept using different fields or metadata models.
Normalization must distinguish:
- Directly copied source values.
- Parsed or transformed values.
- Derived or inferred metadata.
- Missing or unknown values.
- Provider-specific values without a supported common equivalent.
For every material transformation, record the applicable mapping or normalizer version.
Preserve source date precision. If a catalog provides only a publication year, do not silently create an exact publication day.
W3C DCAT 3 provides a vocabulary for catalogs, datasets, distributions, and related metadata.
11. Define search completeness and partial results
Provider execution outcomes should be typed explicitly.
| State | Meaning | Required handling |
|---|---|---|
| COMPLETE | Configured search and pagination completed | Return records with execution provenance |
| PARTIAL | Some records retrieved but required work incomplete | Retain partial status and limitations |
| FAILED | Search could not produce an acceptable provider result | Return typed failure without fabricating records |
| DENIED | Provider or user authorization prohibits operation | Do not bypass access controls |
| CANCELLED | Execution stopped before completion | Record cancellation and completed work |
| NOT_CONFIGURED | Provider is unavailable in the active registry | Report configuration limitation |
Partial results may be useful for exploratory research, but they must remain explicitly labeled.
Do not report a provider’s search as complete when pagination terminated early or rate limits prevented required retrieval.
12. Bound provider execution
Cross-provider search should have explicit resource limits.
Apply limits to:
- Number of providers per request.
- Maximum results per provider.
- Pagination depth.
- Total request duration.
- Per-provider connection and read timeouts.
- Retry attempts and backoff.
- Concurrent provider requests.
- Response size.
- Memory and processing budgets.
Respect provider rate limits and applicable Retry-After guidance.
Cancellation should stop unnecessary work without corrupting previously accepted search evidence.
Implementations must distinguish cancelling a read-only search from rolling back an already committed persistence operation.
13. Prevent unsafe outbound requests
Provider adapters make outbound network requests and can introduce server-side request forgery risks if destinations are controlled by untrusted input.
Production controls should include:
- A trusted allowlist of approved provider origins.
- HTTPS requirements where applicable.
- Rejection of unapproved schemes and destinations.
- Protection against private, loopback, link-local, and metadata-service targets.
- DNS resolution and connection-target validation.
- Explicit redirect policy, with revalidation of every permitted redirect destination.
- No automatic forwarding of credentials to another origin.
- Bounded response sizes and timeouts.
- Safe handling of provider-supplied resource links.
Do not let a search request specify an arbitrary upstream URL that the backend fetches with privileged credentials.
Validating only a URL’s textual hostname is not sufficient protection against all DNS and connection-level attacks.
14. Enforce authorization and tenant isolation
Provider search permissions may vary by user, organization, project, service identity, and resource.
At minimum, distinguish:
- Permission to invoke the discovery operation.
- Permission to use the selected provider.
- Permission to retrieve particular records or content classes.
- Permission to save results.
- Permission to transfer saved records into Library or Research.
- Permission to publicly disclose metadata or source content.
Do not store or reuse privileged provider responses across unrelated tenants without an authorization design that explicitly permits the reuse.
Cache keys must account for relevant representation and security differences. Where HTTP caching is involved, comply with RFC 9111 and applicable authorization and Vary handling.
A successful upstream HTTP response does not establish that the platform may retain or redistribute the content.
15. Define caching and freshness responsibilities
Search results can become stale even when the cache is operating correctly.
Distinguish:
- Original provider search execution time.
- Response retrieval time.
- Cache insertion time.
- Cache validation time.
- Source publication or modification time.
- Scientific observation time.
Cache hits must preserve the original search provenance and disclose the relevant cache status.
Do not relabel an old cached search as newly executed simply because it was served to a user today.
A search refresh may create a new execution record and a new result snapshot rather than rewriting the historical search record.
16. Define deduplication behavior
Deduplication should retain original occurrences and produce a separate identity grouping.
Suggested requirements:
- Preserve every provider-local record identity.
- Retain source-specific provenance and search dates.
- Record the matching rule and its version.
- Avoid destructive merging of distinct scientific versions.
- Flag identifier conflicts and uncertain matches.
- Maintain relationships between merged display groups and original records.
- Allow authorized review or correction of identity-group decisions.
For a group that combines provider records, do not choose one provider’s search date as if it applied to all occurrences.
The combined result should preserve the separate execution dates associated with each provider.
17. Define error classes and API responses
Use typed application errors rather than returning generic success or failure messages.
| Code | Meaning | Expected treatment |
|---|---|---|
| INVALID_SEARCH_REQUEST | Malformed or unsupported request | Reject without provider execution |
| PROJECT_NOT_FOUND | Authorized project cannot be resolved | Return a controlled object-resolution failure |
| SEARCH_NOT_AUTHORIZED | Caller lacks operation authority | Deny without exposing restricted details |
| PROVIDER_NOT_ALLOWED | Provider outside permitted registry or scope | Do not execute upstream request |
| UNSAFE_PROVIDER_DESTINATION | Request target violates outbound network policy | Block request |
| PROVIDER_RATE_LIMITED | Upstream quota reached | Apply bounded, authorized retry behavior |
| PROVIDER_TIMEOUT | Upstream operation exceeded its limit | Record partial or failed provider status |
| PROVIDER_SCHEMA_MISMATCH | Response cannot be parsed under supported contract | Preserve diagnostic context and fail appropriately |
| SEARCH_DATE_MISSING | Required execution provenance absent | Hold affected result |
| SOURCE_IDENTITY_MISSING | Provider-local record identity absent | Hold or reject affected result |
| RIGHTS_UNVERIFIED | Required reuse permission unresolved | Restrict affected operation |
| PAGINATION_INCOMPLETE | Required provider pages not retrieved | Report partial completion |
| PERSISTENCE_CONFLICT | Saved-search revision differs from expected state | Reconcile authoritative stored revision |
These are proposed identifiers, not confirmed production error codes.
RFC 9457 describes a standard representation for HTTP API problem details. Use the actual service contract to map domain failures to HTTP semantics.
18. Keep diagnostics secure and useful
Observability should help developers identify the failing provider, execution, and transformation without exposing protected research or secrets.
Useful sanitized fields include:
- Trace or correlation identifier.
- Provider identifier.
- Adapter revision.
- Search execution identifier.
- Failure classification.
- Elapsed duration.
- Retry count.
- Result and pagination counts.
- Parser or schema version.
- Cache classification.
- Authorization decision category.
Avoid logging raw credentials, unrestricted full-text content, privileged provider tokens, or confidential research queries into broadly accessible telemetry.
Logging and audit retention must follow the approved data governance policy.
19. Define persistence and idempotency
Searching an external provider and saving research results are distinct operations.
A read-only query may be repeated under applicable provider rules. Saving a search, importing a source, or creating a Research object changes state and requires different controls.
For persistent operations, consider:
- Stable command identifiers.
- Expected object revisions.
- Documented idempotency behavior.
- Transactional or compensating recovery procedures.
- Durable audit events.
- Duplicate import detection.
- Safe handling of concurrent updates.
If a persistence request times out, determine whether the previous attempt committed before retrying.
Do not generate a new saved source or research object simply because the client did not receive an acknowledgment.
20. Define Library and Research handoff contracts
Saved discovery evidence should remain traceable after moving to another application.
A proposed handoff record should preserve:
- Original provider and source IDs.
- Search execution identifier and date.
- Executed provider query reference.
- Normalized metadata and transformation revision.
- Source publication and observation timestamps where available.
- Rights and allowed processing scope.
- Project and tenant ownership.
- Deduplication identity-group relationships.
- Source content revision or checksum when permitted and available.
Library and Research should independently enforce their actual authorization and persistence contracts.
A search result being visible in Unified Discovery does not establish that it has been saved or accepted as a governed research object.
21. Prepare the Python reference implementation
The following example implements a limited, dependency-free contract validator for synthetic provider searches and normalized results.
It checks:
- Valid provider execution identities.
- Timezone-aware UTC search timestamps.
- Required executed query references.
- Provider completion status.
- Result-to-execution provenance.
- Provider-local source identifiers.
- Trusted tenant alignment within the synthetic records.
- Rights eligibility.
- Duplicate record occurrences.
- Retention of distinct provider occurrences.
It does not perform network requests, authenticate users, or implement full search infrastructure.
22. Set up the reference environment
mkdir unified-discovery-contracts
cd unified-discovery-contracts
python3 -m venv .venv
source .venv/bin/activate
python --version
Create:
discovery_contract.py
test_discovery_contract.py
The code uses Python’s standard library.
23. Implement the reference contract validator
Save as discovery_contract.py.
from dataclasses import dataclass
from datetime import datetime, timezone
from collections import defaultdict
import json
VALID_STATES = frozenset({
"COMPLETE",
"PARTIAL",
"FAILED"
})
@dataclass(frozen=True)
class SearchExecution:
execution_id: str
provider_id: str
query: str
searched_at: datetime | None
state: str
connector_revision: str
tenant_id: str
@dataclass(frozen=True)
class SearchResult:
execution_id: str
provider_id: str
provider_record_id: str
persistent_id: str | None
title: str
tenant_id: str
rights_eligible: bool
def is_utc(value):
return (
value is not None
and value.tzinfo is not None
and value.utcoffset() is not None
and value.utcoffset().total_seconds() == 0
)
def validate(executions, results, *, tenant_id):
errors = []
warnings = []
execution_map = {}
original_keys = set()
identities = defaultdict(list)
for item in executions:
if (
not item.execution_id
or item.execution_id in execution_map
):
errors.append("INVALID_EXECUTION_ID")
else:
execution_map[item.execution_id] = item
if not item.provider_id:
errors.append("PROVIDER_ID_MISSING")
if item.tenant_id != tenant_id:
errors.append("TENANT_MISMATCH")
if not item.query.strip():
errors.append("QUERY_MISSING")
if not is_utc(item.searched_at):
errors.append("SEARCH_DATE_MISSING")
if item.state not in VALID_STATES:
errors.append("INVALID_PROVIDER_STATE")
elif item.state != "COMPLETE":
warnings.append("PROVIDER_INCOMPLETE")
if not item.connector_revision.strip():
errors.append("CONNECTOR_REVISION_MISSING")
for result in results:
execution = execution_map.get(
result.execution_id
)
if execution is None:
errors.append("UNKNOWN_EXECUTION")
elif execution.provider_id != result.provider_id:
errors.append("PROVIDER_PROVENANCE_MISMATCH")
if result.tenant_id != tenant_id:
errors.append("TENANT_MISMATCH")
if not result.provider_record_id:
errors.append("SOURCE_ID_MISSING")
continue
key = (
result.provider_id,
result.provider_record_id
)
if key in original_keys:
errors.append("DUPLICATE_PROVIDER_OCCURRENCE")
original_keys.add(key)
if not result.rights_eligible:
errors.append("RIGHTS_UNVERIFIED")
if not result.title.strip():
warnings.append("TITLE_MISSING")
# Simplified identity grouping.
# Production matching requires scheme-aware
# identifier validation and version handling.
if result.persistent_id:
identity = (
"persistent",
result.persistent_id.strip().lower()
)
else:
identity = (
"provider",
result.provider_id,
result.provider_record_id
)
identities[identity].append(key)
duplicate_groups = [
sorted(group)
for group in identities.values()
if len(group) > 1
]
if errors:
status = "REJECTED"
elif warnings:
status = "PARTIAL_OR_REVIEW_REQUIRED"
else:
status = "SYNTHETIC_CONTRACT_PASS"
return {
"status": status,
"errors": sorted(set(errors)),
"warnings": sorted(set(warnings)),
"execution_count": len(executions),
"result_count": len(results),
"identity_group_count": len(identities),
"duplicate_groups": duplicate_groups,
"real_authorization": "NOT_TESTED",
"provider_network_execution": "NOT_TESTED",
"scientific_relevance": "NOT_TESTED"
}
SEARCHES = (
SearchExecution(
"exec-A",
"catalog-A",
'"enhanced rock weathering" AND soil',
datetime(
2026, 11, 15, 12,
tzinfo=timezone.utc
),
"COMPLETE",
"adapter-v1",
"tenant-1"
),
SearchExecution(
"exec-B",
"catalog-B",
'"rock weathering" AND agriculture',
datetime(
2026, 11, 15, 13,
tzinfo=timezone.utc
),
"COMPLETE",
"adapter-v1",
"tenant-1"
)
)
RESULTS = (
SearchResult(
"exec-A", "catalog-A", "A-1",
"10.example/abc", "Study A",
"tenant-1", True
),
SearchResult(
"exec-A", "catalog-A", "A-2",
"10.example/def", "Study B",
"tenant-1", True
),
SearchResult(
"exec-B", "catalog-B", "B-1",
"10.example/abc", "Study A",
"tenant-1", True
)
)
if __name__ == "__main__":
print(
json.dumps(
validate(
SEARCHES,
RESULTS,
tenant_id="tenant-1"
),
indent=2
)
)
The validator requires every result to reference a known provider execution and checks that the provider identity is consistent with that execution.
The duplicate grouping retains both provider occurrences rather than discarding the original records.
Limitations: The example assumes that execution and result objects are trusted fixture data. It does not independently establish real tenant authority, parse provider schemas, validate DOIs, enforce outbound URL security, perform HTTP caching, or persist a governed search record.
24. Execute the reference validator
python discovery_contract.py
The expected synthetic response is:
{
"status": "SYNTHETIC_CONTRACT_PASS",
"errors": [],
"warnings": [],
"execution_count": 2,
"result_count": 3,
"identity_group_count": 2,
"duplicate_groups": [
[
["catalog-A", "A-1"],
["catalog-B", "B-1"]
]
],
"real_authorization": "NOT_TESTED",
"provider_network_execution": "NOT_TESTED",
"scientific_relevance": "NOT_TESTED"
}
The result demonstrates internal fixture consistency only.
It does not show that any real provider search occurred or that the search results are scientifically relevant.
25. Implement negative and regression tests
Save as test_discovery_contract.py.
from dataclasses import replace
from datetime import datetime
import unittest
from discovery_contract import (
SEARCHES,
RESULTS,
validate
)
class DiscoveryContractTests(unittest.TestCase):
def assess(
self,
executions=SEARCHES,
results=RESULTS,
tenant_id="tenant-1"
):
return validate(
executions,
results,
tenant_id=tenant_id
)
def check(
self,
code,
executions=SEARCHES,
results=RESULTS,
field="errors"
):
self.assertIn(
code,
self.assess(
executions,
results
)[field]
)
def test_valid_fixture(self):
self.assertEqual(
self.assess()["status"],
"SYNTHETIC_CONTRACT_PASS"
)
def test_original_occurrences_preserved(self):
self.assertEqual(
self.assess()["result_count"],
3
)
def test_duplicate_group(self):
self.assertEqual(
len(self.assess()["duplicate_groups"]),
1
)
def test_missing_search_date(self):
self.check(
"SEARCH_DATE_MISSING",
executions=(
replace(
SEARCHES[0],
searched_at=None
),
SEARCHES[1]
)
)
def test_naive_timestamp(self):
self.check(
"SEARCH_DATE_MISSING",
executions=(
replace(
SEARCHES[0],
searched_at=datetime(
2026, 11, 15, 12
)
),
SEARCHES[1]
)
)
def test_query_missing(self):
self.check(
"QUERY_MISSING",
executions=(
replace(SEARCHES[0], query=""),
SEARCHES[1]
)
)
def test_unknown_execution(self):
self.check(
"UNKNOWN_EXECUTION",
results=(
replace(
RESULTS[0],
execution_id="unknown"
),
) + RESULTS[1:]
)
def test_provider_mismatch(self):
self.check(
"PROVIDER_PROVENANCE_MISMATCH",
results=(
replace(
RESULTS[0],
provider_id="catalog-B"
),
) + RESULTS[1:]
)
def test_tenant_mismatch(self):
self.check(
"TENANT_MISMATCH",
results=(
replace(
RESULTS[0],
tenant_id="other-tenant"
),
) + RESULTS[1:]
)
def test_missing_source_id(self):
self.check(
"SOURCE_ID_MISSING",
results=(
replace(
RESULTS[0],
provider_record_id=""
),
) + RESULTS[1:]
)
def test_unverified_rights(self):
self.check(
"RIGHTS_UNVERIFIED",
results=(
replace(
RESULTS[0],
rights_eligible=False
),
) + RESULTS[1:]
)
def test_partial_provider(self):
self.check(
"PROVIDER_INCOMPLETE",
executions=(
replace(
SEARCHES[0],
state="PARTIAL"
),
SEARCHES[1]
),
field="warnings"
)
def test_failed_provider(self):
self.check(
"PROVIDER_INCOMPLETE",
executions=(
replace(
SEARCHES[0],
state="FAILED"
),
SEARCHES[1]
),
field="warnings"
)
def test_duplicate_occurrence(self):
self.check(
"DUPLICATE_PROVIDER_OCCURRENCE",
results=RESULTS + (RESULTS[0],)
)
def test_missing_connector_revision(self):
self.check(
"CONNECTOR_REVISION_MISSING",
executions=(
replace(
SEARCHES[0],
connector_revision=""
),
SEARCHES[1]
)
)
def test_deterministic(self):
self.assertEqual(
self.assess(),
self.assess()
)
if __name__ == "__main__":
unittest.main()
26. Execute and interpret the regression suite
python -m unittest -v test_discovery_contract.py
The reference suite defines sixteen synthetic tests.
Coverage includes:
- Valid provider and result records.
- Preservation of original provider occurrences.
- Cross-provider duplicate grouping.
- Missing or invalid search timestamps.
- Missing executed queries.
- Unknown provider executions.
- Provider provenance mismatches.
- Tenant mismatches.
- Missing source identifiers.
- Unverified rights.
- Partial and failed provider states.
- Duplicate provider occurrences.
- Missing connector versions.
- Deterministic validation.
These are reference tests supplied for local reproduction, not asserted production or staging execution results.
They must be supplemented by authenticated integration, actual provider behavior, outbound-request security, persistent storage, concurrency, cache, and recovery tests.
27. Required contract and security test matrix
| Test | Expected outcome | Evidence |
|---|---|---|
| Valid authorized search | Provider-specific results with complete provenance | Authenticated integration test |
| Unknown project | Controlled object-resolution failure | API negative test |
| Revoked authorization | Access denied, including cached results where applicable | Revocation test |
| Wrong tenant | No unauthorized source or search disclosure | Cross-owner negative test |
| Provider not permitted | No upstream request performed | Provider authorization test |
| Missing provenance | Affected result rejected or held | Schema and provenance test |
| Stale schema revision | Typed incompatibility or documented migration | Contract compatibility test |
| Partial provider response | Explicit partial outcome | Pagination failure test |
| Rate limit | Bounded retry or explicit failure | 429 and Retry-After test |
| Unsafe redirect | Unapproved target blocked; credentials protected | Transport security test |
| Private network destination | Outbound request denied | SSRF negative test |
| Malformed provider payload | Typed parser failure without invented results | Schema negative test |
| Duplicate result identity | Original occurrences retained | Deduplication regression |
| Cache reuse | Original provider search provenance preserved | Cache integration test |
| Cancelled search | Bounded cancellation and correct partial-state record | Cancellation test |
| Duplicate save request | No unintended duplicate governed objects | Idempotency test |
| Library import | Source and rights relationships preserved | Import and read-back test |
| Research handoff | Correct project and provenance references | Receiver acceptance test |
| Public API response | No protected query, source, or credential exposure | Public-boundary negative test |
| Database restore | Accepted records and provenance reconciled | Isolated restore test |
The test suite must run against the actual supported implementation contracts.
Unit tests alone are insufficient to establish service-level security and operational acceptance.
28. Migration and backward-compatibility requirements
Schema changes should not silently destroy historical search provenance.
For every migration, determine:
- The current authoritative schema version.
- The target schema version.
- Which fields are added, changed, or deprecated.
- How historical provider and execution identities are preserved.
- How missing historical timestamps are represented.
- Whether normalized records require reprocessing.
- How caches and search indexes are invalidated or rebuilt.
- Whether downstream Library and Research readers remain compatible.
- How backup, restore, and rollback will be tested.
Do not populate missing historical search dates with migration execution times and present them as original searches.
Mark unavailable historical provenance explicitly.
Test migration and restore against isolated databases and synthetic research identities before production changes.
29. Define deployment and release gates
A cross-provider discovery release should have evidence for:
- Approved provider configurations.
- Versioned request, response, and error contracts.
- Trusted identity and tenant authorization.
- Outbound network and redirect security.
- Correct provider-specific query execution.
- Search timestamps and source provenance.
- Schema normalization and deduplication.
- Partial-result and pagination handling.
- Rights-aware caching and persistence.
- Safe cancellation, retries, and bounded resource usage.
- Library and Research handoff compatibility.
- Executed integration and security tests.
- Verified backup and recovery procedures.
- Authenticated staging acceptance.
- Explicit production deployment and rollback decisions.
A green interface status or successful HTTP request is insufficient evidence of all release gates.
Record any unsupported provider or disabled capability as an explicit limitation.
30. Prepare a developer acceptance receipt
The following JSON illustrates the expected evidence structure.
{
"schema_version": "example-1.0",
"workflow": "cross_provider_search_developer_acceptance",
"classification": "proposed",
"implementation": {
"repository": null,
"commit": null,
"api_contract_revision": null,
"provider_registry_revision": null,
"deployed_build": null
},
"providers": [],
"acceptance": {
"request_contract": "not_tested",
"response_contract": "not_tested",
"provider_configuration": "not_tested",
"query_translation": "not_tested",
"search_date_provenance": "not_tested",
"source_identity": "not_tested",
"normalization": "not_tested",
"deduplication": "not_tested",
"pagination": "not_tested",
"partial_failures": "not_tested",
"provider_authentication": "not_tested",
"tenant_isolation": "not_tested",
"rights_enforcement": "not_tested",
"ssrf_protection": "not_tested",
"redirect_protection": "not_tested",
"cache_provenance": "not_tested",
"idempotency": "not_tested",
"library_persistence": "not_tested",
"research_handoff": "not_tested",
"public_boundary": "not_tested",
"migration": "not_tested",
"backup_restore": "not_tested",
"staging_acceptance": "not_tested",
"production_runtime": "not_tested"
},
"production_release_decision": "NO_GO"
}
This is a proposed acceptance receipt, not a verified system artifact.
For actual implementation acceptance, replace placeholders with source-derived references, executable test evidence, trusted security findings, deployment identities, and recovery receipts.
31. Required implementation anchors
Before labeling this reference production verified, attach:
| Anchor | Required evidence |
|---|---|
| Owning repository | Exact repository, branch, and commit |
| Service implementation | Source paths for request handling and orchestration |
| Provider adapters | Actual adapter modules and supported provider configurations |
| Schema contracts | Versioned request, result, provenance, and failure schemas |
| Identity integration | Trusted authentication and authorization implementation |
| Storage contract | Actual saved-search, source, and execution persistence paths |
| Outbound security | Provider allowlist, redirect, DNS, and network-policy tests |
| Deduplication | Actual matching implementation and regression results |
| Cache behavior | HTTP and application cache implementation and validation tests |
| Downstream handoffs | Actual Library and Research import contracts |
| CI | Executed tests and results tied to source revision |
| Staging | Authenticated requests and synthetic acceptance evidence |
| Database migration | Applied revision, compatibility checks, and rollback plan |
| Recovery | Backup, restore, and reconciliation evidence |
| Production | Deployed build identity and explicit release approval |
If an anchor cannot be verified, record it as Not Tested, Blocked, or Not Applicable with justification.
Do not substitute a planning document, UI mockup, or successful synthetic unit test for an implementation anchor.
32. Developer troubleshooting and escalation
Escalate a cross-provider implementation issue when:
- Search results lose provider provenance or actual search dates.
- Tenant-specific or restricted records cross authorization boundaries.
- A provider adapter sends requests to unapproved destinations.
- Redirect handling exposes credentials.
- Provider failures are silently represented as complete searches.
- Normalization changes material scientific metadata incorrectly.
- Deduplication merges distinct research objects.
- Historical search events are overwritten during refresh.
- A saved search cannot be reconciled after restore.
- Library or Research receives source records without authoritative provenance.
- Public APIs reveal private search terms or protected source metadata.
Preserve sanitized incident evidence and the last accepted state.
Contain affected access, caching, or persistence behavior where necessary. Reproduce the defect with synthetic records in an isolated environment, identify the responsible component, and rerun relevant contract, integration, and security tests.
Do not expose credentials, confidential queries, private manuscripts, or restricted provider payloads in public issue reports.
33. Technical and developer references
- Fielding, R., Nottingham, M. and Reschke, J. (2022). HTTP Semantics. RFC 9110. Available at: https://www.rfc-editor.org/rfc/rfc9110.html.
- Fielding, R., Nottingham, M. and Reschke, J. (2022). HTTP Caching. RFC 9111. Available at: https://www.rfc-editor.org/rfc/rfc9111.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.
- OpenAPI Initiative. OpenAPI Specification, Version 3.1. Available at: OpenAPI 3.1 specification.
- OWASP Foundation. Server-Side Request Forgery Prevention Cheat Sheet. Available at: OWASP SSRF guidance.
- World Wide Web Consortium (W3C) (2024). Data Catalog Vocabulary (DCAT) — Version 3. Available at: https://www.w3.org/TR/vocab-dcat-3/.
- World Wide Web Consortium (W3C) (2013). PROV-O: The PROV Ontology. Available at: https://www.w3.org/TR/prov-o/.
- Wilkinson, M.D. et al. (2016). ‘The FAIR Guiding Principles for scientific data management and stewardship’, Scientific Data, 3, 160018. Available at: https://doi.org/10.1038/sdata.2016.18.
- Rethlefsen, M.L. et al. (2021). ‘PRISMA-S: an extension to the PRISMA Statement for Reporting Literature Searches in Systematic Reviews’, Systematic Reviews, 10, 39. Available at: https://doi.org/10.1186/s13643-020-01542-z.
- Python Software Foundation. datetime — Basic Date and Time Types. Available at: Python datetime documentation.
- Python Software Foundation. unittest — Unit Testing Framework. Available at: Python unittest documentation.
34. Completion and production-verification record
| Field | Required record |
|---|---|
| Implementation owner | Confirmed service and responsible component team |
| Source revision | Exact repository, branch, and commit |
| API contract | Actual request, response, and error schema versions |
| Provider registry | Enabled and authorized provider configurations |
| Query execution | Exact provider-specific query and execution reference |
| Search dates | Real provider search timestamps |
| Source identity | Provider-local and persistent identifiers |
| Normalization | Transformation contracts and implementation revision |
| Deduplication | Source occurrence retention and identity-group tests |
| Completeness | Pagination, partial results, and failures classified |
| Authorization | Trusted user, service, project, and provider controls |
| Outbound security | Allowlist, redirect, DNS, and SSRF evidence |
| Cache provenance | Correct original search date and refresh history |
| Persistence | Authoritative saved search and source read-back |
| Idempotency | Repeated state-changing requests handled safely |
| Library handoff | Saved source and rights identity preserved |
| Research handoff | Research object provenance and ownership verified |
| Public boundary | No restricted research or credentials exposed |
| CI acceptance | Executed tests tied to the exact implementation revision |
| Staging acceptance | Authenticated and isolated integration evidence |
| Migration | Applied schema revision and historical-data reconciliation |
| Recovery | Backup, restore, and rollback evidence |
| Production identity | Deployed build, configuration, and release decision |
| Outstanding limitations | Blocked providers, incomplete controls, and unverified capabilities |
Developer completion criterion: Cross-provider search is technically accepted when authorized queries execute against explicitly permitted providers; every retained result preserves its provider and original search execution date; source identities and normalization history remain traceable; partial responses and deduplication are handled correctly; provider, tenant, and outbound network boundaries are enforced; and governed persistence and downstream handoffs retain the required provenance. Acceptance must be supported by source-specific implementation anchors, executed integration and security tests, and verified operational recovery.
Scientific limitation: Correct implementation of cross-provider search does not establish that returned scientific records are relevant, complete, independent, or scientifically reliable. Research-specific assessment remains necessary to determine source quality, methodological adequacy, bias, uncertainty, and suitability for the intended inference.
Current implementation status: Proposed service ownership, API and provider adapter contracts, provenance requirements, query and result schemas, authorization, outbound network security, caching, deduplication, typed failures, partial-response handling, persistence, migration, synthetic Python validator, sixteen reference regression tests, and production acceptance requirements documented. No specific Sustainable Catalyst Unified Discovery endpoint, provider connector, search service, Library persistence route, Research handoff, or deployed authentication integration is certified without exact repository and source anchors, executed authenticated integration tests, security review, staging evidence, and operational release acceptance.
