Worked Examples
Developer reference for research collaboration exports — Workspace
Developer reference for research collaboration exports — Workspace Application: Workspace Status: Useful first draft, not a production-verified procedure. Proposed or audited service responsibility Support the following capability
Application: Workspace
Related applications: Platform Core, Library, Research, Workbench, Research Hub, Reporting Studio
Classification: Developer Reference / Research Collaboration / Export Governance
Audience: Backend developers, research software engineers, security reviewers, project owners, and data stewards
Technical level: Advanced intermediate
Estimated reading time: 22–28 minutes (excluding implementation and test execution)
Reference contracts: sc-collaboration-export-api-example/1 and sc-collaboration-package-example/1 (synthetic only)
Primary acceptance: An authorized recipient receives only artifacts approved for a specific organization, project, and accepted revision, with verified file integrity and complete declared provenance; unrelated or restricted material is excluded, and authorization is rechecked on retrieval.
1. Goal and service responsibility
A collaboration export is a governed transfer of a specified scientific result and its reproducibility evidence, not an unrestricted copy of a Workspace. The intended capability is to share approved materials while preserving source identity, exact revision, documented method, data rights, file integrity, independent interpretability, and audit context.
Expected result: The consumer can verify what was exported, why, from which accepted project state, and which permitted relationships connect the files. An export must not silently broaden access to unpublished data, another organization’s objects, or subsequent revisions.
Design rules: resolve identity from a trusted authentication system; read approval and project state from authoritative stores; use an allowlist of included artifacts; avoid unrestricted URLs and client-supplied approvals; fail closed on unresolved provenance, stale revisions, or missing rights; keep publication authority separate from export creation.
2. Requirements and reproducible evidence
To run the local demonstration you need Python 3.11 or newer (standard library only) and macOS Terminal or a Linux shell. Git and GitHub CLI are optional. No server credentials, network connection, Docker image, production dataset, or cloud infrastructure is needed.
The companion archive contains collab_contract.py (synthetic service model), cli.py (package generation and verification), tests/test_contract.py (37 positive and negative cases), contracts/proposed-openapi.yaml (unimplemented API design), contracts/proposed-postgres.sql (unimplemented storage sketch), an example JSON request, and a GitHub Actions workflow. Keep actual research inputs out of this sample repository.
Required evidence for a real Workspace implementation includes exact repository URL, commit SHA, owning service, migration and authorization contracts, trusted approval receipt, CI job URL, staging image digest, request/response captures (redacted), and signed-off backup/restore and publication gates. Those deployment anchors are not supplied here.
3. Authoritative ownership and trust boundaries
| Concern | Recommended owner and control | What must not be assumed |
|---|---|---|
| Identity and organization membership | Platform Core or the authoritative identity provider: authenticated subject, roles and scopes, tenant membership, expiration | Client-provided user ID, request header, or self-asserted role grants authority |
| Project acceptance | Workspace: project ownership, authoritative accepted revision and approval state | Latest draft or a green UI badge is an accepted revision |
| Research inputs and file rights | Library and owning artifact service: source IDs, restrictions, license, confidentiality, retention | Discoverable means redistributable |
| Scientific relationships | Research/Workbench: method IDs, parent data, computation snapshots, evidence graph | Hash equality establishes scientific correctness |
| Delivery and withdrawal | Dedicated Workspace export domain: staging, package manifest, recipient grant, retrieval rechecks, cancellation | Deleting a download link revokes already-downloaded copies |
| Public release | Separately authorized Research Hub publication workflow | A private collaboration export is a public publication approval |
The table is a proposed separation of responsibility, not a verified deployment map. Inspect service ownership and schemas before implementation.
4. Actors, scope, and threat model
Model at least four actors: a permitted project owner/export creator, an explicitly granted recipient, a reviewer/approver distinct where required by policy, and an unauthorized actor from the same or another organization. Model the assets as immutable revision-bound objects, each with classification and rights metadata.
Threats include broken object-level authorization, cross-tenant IDs in a valid-looking path, recipient grants revoked after export creation, stale approvals, silent substitution of a newer model run, unsafe path handling and symlinks, extra files in the output, partial package publication, insecure redirects, replayed requests with changed payload, and confidential metadata in an error or audit event. OWASP identifies broken object-level authorization as a core API risk; tenant IDs in the URL are not proof of authorization.
5. Proposed versioned API surface — not a live endpoint
The following routes are design candidates represented in contracts/proposed-openapi.yaml. The host api.example.invalid is intentionally non-routable; do not treat these paths as available on research-api.sustainablecatalyst.com or any other deployed service.
| Method and proposed path suffix | Purpose | Important check |
|---|---|---|
POST /collaboration-exports |
Create an export for the exact selected revision | Current approval, actor role, recipient right, schema, idempotency |
GET /collaboration-exports/{export_id} |
Retrieve minimal export status | Reauthorize on every read; redact private details |
GET /collaboration-exports/{export_id}/manifest |
Download the scope-bound manifest | Current grant and approval, precise revision and metadata access |
POST /collaboration-exports/{export_id}/cancellation |
Disable subsequent access and record event | Creator/policy authority, idempotent cancellation and audit |
Actual route prefixes, asynchronous behavior, content negotiation, schema choice, and cross-service transport should come from repository inspection and integration review. A download endpoint, if required, must additionally use short-lived, scope-bound tokens and safe storage redirects.
6. Proposed create-request schema and validation
Use explicit, bounded fields; reject unknown fields rather than accepting a client-supplied approved=true, role, private download URL, or target filesystem path. The asset_ids list is an allowlist, not permission to enumerate arbitrary files. The request body below is a synthetic fixture and carries no authenticated principal; a real principal must come from trusted middleware.
{
"schema_version": "sc-collaboration-export-api-example/1",
"organization_id": "org-demo",
"project_id": "project-erw-demo",
"revision_id": "revision-07",
"recipient_id": "recipient-demo",
"asset_ids": ["protocol", "result"]
}
Require 1–100 unique asset IDs in the example, canonical identifiers, an exact accepted revision match, an active server-side approval, a recipient granted for this project and purpose, and an allowed, complete provenance subgraph. Do not echo confidential project existence across organizations; use a consistent 404 response where appropriate.
7. Example receipt, statuses, and typed failures
Return a compact receipt rather than file content, credentials, unrestricted object-storage location, personal details, or raw reviewer notes. Example fields:
{
"export_id": "exp-illustrative-only",
"status": "ready",
"revision_id": "revision-07",
"approval_ref": "approval-synthetic-17",
"manifest_schema": "sc-collaboration-package-example/1"
}
Use typed, stable failure codes mapped to appropriate HTTP status semantics. A possible mapping is 400 for a malformed idempotency key, 401 for missing authentication, 403 for an unauthorized operation or revoked grant, 404 for invisible or nonexistent objects, 409 for a stale revision or changed-payload retry, 410 for a cancelled export, and 422 for malformed asset or schema content. These mappings require a documented disclosure policy; they are not evidence of existing endpoints.
{
"type": "https://example.invalid/problems/stale-revision",
"title": "Export request conflicts with accepted revision",
"status": 409,
"code": "STALE_REVISION"
}
RFC 9110 defines HTTP status semantics; RFC 9457 supplies a standard problem-details envelope. Never include private dataset names, tokens, stack traces, or tenant diagnostics in public error bodies.
8. Manifest, file identity, and provenance contract
The local package consists of manifest.json and a payload/ tree. Each included asset records its canonical relative path, byte count, SHA-256 hash, source reference, method version, and parent source references. The package binds these to organization, project, revision, and approval reference. Inspect generated output from the runnable example; do not assume this schema conforms to RO-Crate or BagIt without the additional required metadata and layout.
{
"schema_version": "sc-collaboration-package-example/1",
"organization_id": "org-demo",
"project_id": "project-erw-demo",
"revision_id": "revision-07",
"approval_ref": "approval-synthetic-17",
"assets": [
{
"path": "methods/protocol.txt",
"size_bytes": 33,
"sha256": "<computed 64-character digest>",
"source_ref": "source-protocol-v1",
"method_version": "method-v1",
"derived_from": []
}
]
}
The digest placeholder above is explanatory; the companion generates actual checksums at runtime. Hashes detect changes to bytes, not unauthorized producer substitution, source authenticity, correct scientific interpretation, or lawful redistribution. For producer authentication, use a separately verified signature or attestation with institutional key policy. PROV-O terms such as prov:wasDerivedFrom and prov:wasGeneratedBy help express provenance relationships; RO-Crate provides an interoperable research-object metadata model.
9. Reference authorization algorithm
Before creating or retrieving an export, a real service should execute these checks within a trustworthy consistency boundary:
- Resolve the authenticated principal and active organization membership from a trusted issuer/session, not request JSON or fixture headers.
- Authorize the requested operation at the organization, project, and object level; apply deny-by-default behavior.
- Read authoritative Workspace accepted revision, approval state, reviewer authority, and any withdrawal/correction state.
- Resolve the recipient against current grant policy; account for expiry and revocation.
- Resolve each asset and its source license/reuse classification; reject anything outside the approved set.
- Validate the complete declared provenance closure, schema version, checksums, file/path limits, and exclusion rules.
- Stage output privately, then publish a durable immutable record and audit event; never expose partial packages.
- Recheck rights, approval and grant at each later manifest or download request.
The in-memory Service.create() and Service.get() implement only a synthetic approximation of these checks. They do not validate cryptographic identity or concurrent database mutations.
10. Idempotency, concurrency, and uncertain writes
A retry after timeout must not create a second export, widen scope, or overwrite a prior export. Key replay should be scoped by organization, project, actor and idempotency key; compare a canonical request fingerprint. Identical retries may return the existing receipt, while changed requests using the same key should receive a conflict.
# Extracted pattern from the synthetic reference, shortened for explanation:
identity = (organization_id, project_id, actor_id, idempotency_key)
fingerprint = sha256(canonical_request_bytes).hexdigest()
if identity in prior_requests:
old_fingerprint, prior_export_id = prior_requests[identity]
if old_fingerprint != fingerprint:
raise ContractError(409, 'IDEMPOTENCY_CONFLICT')
return reauthorize_and_read(prior_export_id)
This snippet illustrates the policy; reauthorize_and_read() is a conceptual integration boundary, not an executable function in the sample. The actual example uses Service.get(). In production, use a database uniqueness constraint with transactional updates and document key retention/expiry. The IETF Idempotency-Key proposal remains an Internet-Draft as of November 2026; follow the exact revision selected for implementation rather than describing it as a final RFC.
11. Export state machine and partial failure
Suggested durable states: pending → staging → ready, with terminal failed, cancelled, or revoked as policy dictates. A ready state should exist only after all expected objects and manifest checksums match the accepted snapshot, with a recorded approval and delivery grant. A completed package must not be reused after the approval or recipient entitlement is revoked.
On partial failures, clean up inaccessible staging objects and keep the previous accepted revision intact. Avoid blind retries of non-idempotent writes; reconcile the authoritative request record before resuming. For distributed services, use a durable outbox or equivalent to connect state transitions with audit/delivery events. A package copied to an external collaborator cannot be remotely erased simply by revoking an internal URL.
12. Storage, database, and migration sketch
The companion includes contracts/proposed-postgres.sql, showing an illustrative collaboration_export_requests_example table and transactional-outbox table. These are not database migrations and deliberately omit foreign keys to unknown production tables. Do not apply the SQL to live systems.
-- Illustrative uniqueness constraint, not an executed migration:
UNIQUE (organization_id, project_id, actor_id, idempotency_key)
-- Retain: accepted_revision_id, approval_id,
-- request_fingerprint_sha256, manifest_sha256, state.
Implement permission-filtered queries with strong tenant isolation, persistent immutable manifest references, bounded retention and deletion procedures, access-controlled object storage, separate encryption keys/issuer configuration, and a restore-suppression mechanism where privacy rights require it. Test migration forward/backward behavior on disposable databases using synthetic data, including old idempotency keys and cancelled exports.
13. Audit events, confidentiality, and safe logging
Minimum event types should include request accepted/rejected, approval revalidated, package staged, package published, recipient retrieval, grant revoked, cancellation, retry resolved, retention expiry, and restore suppression. Include stable event ID, tenant/project/export IDs, actor, action, revision, policy decision, time and relevant hashes. Keep raw file contents, unrestricted source identifiers, bearer tokens, full user information and confidential notes out of ordinary logs.
Audit logs support investigation and chain-of-custody interpretation but do not prove the scientific findings correct. The companion explicitly tests that its audit events do not contain the fixture’s private content or idempotency key. Production audit access, append-only guarantees, integrity protection, retention and alerting are outside this demo.
14. macOS Terminal: execute the reference
Download and extract the companion ZIP into an empty working directory. Open Terminal in that directory; the following commands run without network access and do not contact Sustainable Catalyst servers.
cd ~/Downloads/sc_workspace_collab_export_developer_reference
python3 --version # Python 3.11 or newer
python3 -m unittest discover -s tests -v
python3 cli.py demo --out out/synthetic-export
python3 cli.py verify --package out/synthetic-export \
--org org-demo --project project-erw-demo --revision revision-07
python3 -m json.tool out/synthetic-export/manifest.json
shasum -a 256 out/synthetic-export/payload/results/result.csv
If you extracted the ZIP elsewhere, change the cd path accordingly. The expected demo includes two files and excludes restricted/private.csv. The output directory must not already exist; remove only the generated synthetic out/ directory before rerunning.
15. Linux Terminal: reproduce and inspect
Run the same commands on Linux (Ubuntu or another system with Python 3.11+), using sha256sum for file inspection. No sudo is needed for the tests or demo.
cd ~/Downloads/sc_workspace_collab_export_developer_reference
python3 --version
python3 -m unittest discover -s tests -v
python3 cli.py demo --out out/synthetic-export
python3 cli.py verify --package out/synthetic-export
sha256sum out/synthetic-export/payload/results/result.csv
find out/synthetic-export -maxdepth 4 -type f -print
For a deliberate negative check, copy the generated package and alter only the copied synthetic result. A failed verification is the correct result:
cp -R out/synthetic-export out/tampered-export
printf '\nunauthorized,9,count\n' >> \
out/tampered-export/payload/results/result.csv
python3 cli.py verify --package out/tampered-export
# Expected: nonzero exit, SIZE_MISMATCH or HASH_MISMATCH
Use this failure test only on synthetic outputs. A successful checksum and manifest inspection still does not establish that the source dataset or scientific conclusion is valid.
16. GitHub repository and automated CI
Version the reference code and synthetic fixtures, not confidential project exports. The included workflow runs Python 3.11, 3.12, and 3.13 on GitHub-hosted Linux runners, limits GITHUB_TOKEN to contents: read, exercises unit tests, builds a synthetic package, and verifies it. Actual GitHub-hosted results have not been observed for this deliverable.
# Optional: start a new PRIVATE example repository, from the extracted folder
cd ~/Downloads/sc_workspace_collab_export_developer_reference
git init
git add .
git commit -m "Add synthetic collaboration export contract reference"
# Only if you want a new repository and have GitHub CLI configured:
# gh auth login
# gh repo create sc-workspace-collab-export-example --private --source=. --push
# After pushing: gh run list
See GitHub Actions workflow syntax and the GitHub CLI repository creation manual. Pin third-party actions to reviewed immutable SHAs where organizational security policy requires it. Keep CI secrets and production credentials absent from this synthetic workflow.
17. Positive and negative contract test matrix
| Test | Expected behavior | Reference evidence |
|---|---|---|
| Approved export | Two selected synthetic artifacts included; restricted fixture excluded | test_success_scoped_export_only |
| Idempotent replay | Same request/key returns same export; changed payload conflicts | test_idempotent_retry_same_request_returns_same_export, test_idempotency_key_changed_payload_conflicts |
| Cross-organization / wrong project | Unauthorized scope yields no export or disclosed content | test_wrong_tenant_denied_before_lookup, test_wrong_project_denied |
| Unapproved or restricted file | Fail before staging; no leakage | test_unapproved_private_asset_denied, test_approved_but_restricted_asset_denied |
| Stale revision / approval | Conflict or denial | test_stale_revision_denied, test_pending_approval_denied |
| Revoked recipient or approval on read | Previously created export becomes inaccessible through service | test_access_revoked_after_creation_denied, test_approval_revoked_after_creation_denied |
| Missing provenance, invalid path | Reject incomplete ancestry, traversal and invalid identifiers | test_missing_provenance_parent_denied, test_path_traversal_denied |
| Checksum / extra content / symlink | Receiver rejects modified or unmanifested contents | test_package_modified_bytes_denied, test_package_extra_file_denied, test_package_symlink_denied |
| Cancellation, audit minimization | Cancel revokes future reads; logs omit secrets and payloads | test_cancel_invalidates_recipient_and_retry, test_audit_has_no_payload_or_secrets |
All 37 tests passed locally, including checks not listed individually in this table. There is no evidence here of HTTP integration testing, cryptographic authentication, a production database, repository deployment, a CI receipt, or external scientific review.
18. Security controls not supplied by the synthetic example
The reference intentionally omits real user authentication and should never be deployed as a web service. Production requirements include server-validated tokens and tenant-bound scopes; object-level authorization on every read/write; grant expiry; download URL signing and revocation limits; object-store size quotas and malware screening where applicable; rate limits; anti-SSRF controls for any external source retrieval; request body bounds; secrets redaction; signed manifest/attestation; time synchronization; retention and privacy procedures; and versioned incident response.
A checksum is not an attestation: it establishes consistency between bytes and a trusted manifest only when that manifest itself is authenticated. Similarly, a correct provenance graph can connect the wrong scientific sources or support a false inference. Human scientific and rights review remain separate.
19. Troubleshooting and common failure modes
| Symptom | Likely cause | Developer action |
|---|---|---|
UNSUPPORTED_SCHEMA |
Client/server contract mismatch | Check precise version and publish compatibility policy; do not silently coerce unknown fields |
STALE_REVISION |
Accepted project revision changed | Re-read authoritative revision, obtain current permission/approval; do not promote drafts implicitly |
IDEMPOTENCY_CONFLICT |
Same key reused with different body | Compare canonical fingerprint and original receipt, never overwrite the previous operation |
ASSET_NOT_APPROVED |
Requested object not in approved scope | Inspect policy and authoritative grant; do not widen permissions automatically |
MISSING_PROVENANCE_PARENT |
Derived result lacks approved source/method parent | Include permitted parent or record a carefully controlled external reference policy |
HASH_MISMATCH / SIZE_MISMATCH |
Byte substitution or truncated transfer | Quarantine package, compare immutable source hash; do not mark verified |
| Wrong product or permission metadata | Stale classification/tenant mapping | Inspect authoritative metadata and mapping migration; never infer rights from labels |
| Request timed out | Unknown commit outcome | Fetch by idempotency key from authoritative store; resume only after reconciliation |
| CI works but staging fails | Identity, database, storage or release differences | Collect exact staging image digest and isolated logs; block production cutover until boundary verified |
20. Migration, restore, and revocation acceptance
Before schema migration, export an encrypted off-host backup under an approved policy, test restore to an isolated disposable database, capture checksums, and verify that old idempotency keys and request state remain stable. A production release must define reversal of new code/migrations without reviving cancelled access, expired grants, or previously erased data. Recovery should preserve accepted revision and audit relationships while retaining redactions and suppression decisions across restore.
Run negative restore checks on synthetic fixture identities: a cancelled export remains unusable after restoration; a previously revoked recipient cannot read an existing manifest; no newly exposed objects appear; the latest accepted project revision remains bound; an interrupted staging job is detected and reconciled. Neither restore nor migration testing is executed by the local companion.
21. Scientific interoperability and external recipients
Distinguish integrity (bytes and declared metadata are unchanged), provenance (lineage is traceable), reproducibility (methods and inputs permit meaningful repeat work), rights (use/redistribution is authorized), and scientific validity (claims and inference are adequately supported). Passing one is not sufficient evidence for the others.
Consider RO-Crate for portable structured research-object metadata, PROV-O for explicit entity/activity/agent relationships, and BagIt (RFC 8493) for archival file packaging and checksum manifests. The local example implements a custom teaching format and must not be labeled conformant to those standards without a separate compatibility and validation exercise. Choose and pin interoperability profiles explicitly.
22. Required implementation and release anchors
| Required anchor | Minimum acceptable evidence | Current status |
|---|---|---|
| Repository ownership | Real organization/repo, commit, file path and code owner | Not inspected in this reference |
| UI/API contract | Deployed route or UI action, generated schema, authentication/authorization logic | Proposed OpenAPI only |
| Persistence and recovery | Actual migration, constraints, restore test and rollback plan | Illustrative SQL only |
| Integration behavior | Recorded tenant/rights/recipient tests using isolated staging infrastructure | Not verified |
| CI and reproducibility | GitHub check URL, commit SHA, dependency lock/SBOM as relevant, immutable receipt | 37 local tests; CI example not run |
| Scientific and editorial review | Source/method reconciliation, uncertainties, limitations, reviewer decision | Not independently certified |
| Deployment decision | Approved change, backup and recovery gates, production verification/rollback receipt | NO-GO pending evidence |
23. Acceptance criteria and evidence record
Accept a production implementation only when the precise accepted project revision is exportable by a permitted actor to a permitted recipient; selected assets are complete and unmodified; unapproved files and private object metadata are absent; every parent link is resolvable within the authorized export policy; retries are stable; unauthorized requests fail without information leakage; cancellation/revocation stops future access; audit and retention survive a tested restore; and documented scientific, rights and publication decisions apply to the exported revision.
Executed local evidence: Python 3.13.5, Linux, python -m unittest discover -s tests -v → 37/37 passed; python cli.py demo --out out/synthetic-export → 2 synthetic artifacts built; python cli.py verify --package out/synthetic-export → 2 artifacts verified. These results are reproducible commands rather than an institutional acceptance receipt. Tests do not exercise the actual Sustainable Catalyst Workspace stack.
Release classification: REFERENCE_ONLY. Production readiness requires separate, traceable approval. Never issue a PASS for unexecuted macOS, CI, staging, tenant integration, backup, or scientific review checks.
24. Technical references
- World Wide Web Consortium (2013). PROV-O: The PROV Ontology. https://www.w3.org/TR/prov-o/.
- RO-Crate Community. RO-Crate Metadata Specification 1.1. https://www.researchobject.org/ro-crate/specification/1.1/.
- Kunze, J. et al. (2018). The BagIt File Packaging Format (V1.0), RFC 8493. https://www.rfc-editor.org/rfc/rfc8493.html.
- Fielding, R., Nottingham, M. and Reschke, J. (2022). HTTP Semantics, RFC 9110. https://www.rfc-editor.org/rfc/rfc9110.html.
- Nottingham, M., Wilde, E. and Dalal, S. (2023). Problem Details for HTTP APIs, RFC 9457. https://www.rfc-editor.org/rfc/rfc9457.html.
- IETF HTTPAPI Working Group (2026). The Idempotency-Key HTTP Header Field, Internet-Draft, draft-ietf-httpapi-idempotency-key-header-08 (not a finalized RFC). https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-idempotency-key-header-08.
- OWASP (2023). API Security Top 10: Broken Object Level Authorization. https://api-security.owasp.org/editions/2023/en/0xa1-broken-object-level-authorization/.
- National Institute of Standards and Technology (2020; updated). Security and Privacy Controls for Information Systems and Organizations, SP 800-53 Rev. 5. https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final.
- National Institute of Standards and Technology (2022). Secure Software Development Framework, SP 800-218 v1.1. https://csrc.nist.gov/pubs/sp/800/218/final.
- GitHub. Workflow syntax for GitHub Actions. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax.
- GitHub CLI. gh repo create. https://cli.github.com/manual/gh_repo_create.
- Python Software Foundation. unittest — Unit testing framework and hashlib — Secure hashes and message digests. unittest; hashlib.
- Wilkinson, M.D. et al. (2016). ‘The FAIR Guiding Principles for scientific data management and stewardship’, Scientific Data 3, 160018. https://doi.org/10.1038/sdata.2016.18.
25. Completion and verification record
The developer reference is complete as a proposed, locally tested contract foundation. It specifies service boundaries, scope and authority checks, immutable revision and provenance references, typed failures, idempotent retries, transactional storage considerations, recipient revocation, audit minimization, test expectations, GitHub CI, and independent receiver verification.
Current limitation: The companion demonstrates these properties in a deterministic synthetic environment with in-memory identity, approval, and storage models. It does not confirm any deployed Workspace export service, live API, third-party rights integration, production security control, post-recovery state, scientific validity, or publication authorization. Attach exact implementation and release evidence before elevating this article to “production verified.”
