Worked Examples
Developer reference for workspace recovery — Workspace
Examine Workspace recovery data contracts and reference validators for snapshot integrity, accepted-record preservation, audit continuity, scientific lineage, and authorization boundaries.
Application: Sustainable Catalyst Workspace
Article type: Developer reference
Component: Workspace scientific recovery reference validation
Source revision: 81984e335e471a8938fad8b61676e430a89cecac (PR #68 merge commit)
Evidence: Public, commit-pinned Python source and synthetic regression tests
Supported Workspace product version: Not established by this reference package
Last verified deployed version: Not established
Estimated reading time: 18–22 minutes, excluding terminal execution
1. Goal
Validate that a recovered Workspace project retains accepted research artifacts, their audit history, and the scientific relationships required to interpret published or reviewed results. This reference serves developers implementing, testing, or reviewing recovery logic after session loss, interrupted requests, partial application failure, or a controlled restore.
Primary invariant: Recovery must not silently lose accepted records. For scientific artifacts, continuity also requires preserving their source versions, method versions, output identities, evidence classifications, review states, and declared visibility.
2. Requirements
- Git, Python 3 with standard-library
unittest, and network access to the public GitHub repository. - A disposable local checkout; no production credentials, account cookies, real research datasets, or database volumes are necessary.
- Permission to read the public repository. Commit or publication rights are not required to reproduce the tests.
- For an actual staging recovery rehearsal: independently authorized operator access, an isolated data restore target, authenticated user-to-project authorization, and a release-specific runbook.
3. Verified source-code anchors
The links below point to the exact merged revision, not a moving branch. They were verified against the public repository.
- Validation package directory at the merge commit
- README and verification boundaries
- Snapshot and audit-history validator
- 19 snapshot regression tests
- Scientific-continuity validator
- 20 scientific-continuity tests
- Archived test result included in the source package
- Merged PR #68: code and review context
Interpret the evidence correctly: An archived test log and a user-reported Mac run both show 39 passing reference tests. The pinned source and test definitions are inspectable; a new execution is needed to establish results on another environment or later code revision. A merge is not a production acceptance receipt.
4. Reference contract: immutable snapshot model
recovery_validation.py defines frozen Python dataclasses, rather than a deployed JSON or HTTP API. The core objects are:
| Type | Fields | Purpose |
|---|---|---|
Snapshot |
project_id, tenant_id, captured_at, artifacts, events |
One project/tenant recovery checkpoint |
Artifact |
artifact_id, revision, status, digest |
Artifact identity and version |
Event |
event_id, artifact_id, revision, parent_revision, actor_id, occurred_at, kind |
Linear artifact-level change record |
ScientificLink |
Artifact/revision; source ID/revision; method ID/revision; output ID/digest; evidence class; review state; visibility | Declared scientific lineage of an output |
Allowed artifact statuses are draft, reviewed, accepted, and published. Allowed evidence classes are observed, modeled, and derived. These enumerations constrain the synthetic objects; they do not attest to the authority or validity of submitted labels.
5. Core validation functions
| Function | What it establishes | What it does not establish |
|---|---|---|
verify_snapshot(snapshot, tenant_id) |
Basic scope, timestamp, digest syntax, unique IDs, sequential revision events, acceptance/publishing event requirements | Real tenant authorization, signed actors, historical completeness external to supplied snapshot |
compare_recovery(before, after, tenant_id) |
No loss of accepted/published artifacts; no accepted revision regression; digest preservation when revision is unchanged; original event IDs remain present | Independent validity of newer revisions, byte-equivalent underlying files, database rollback safety |
validate_links(snapshot, links) |
Referenced artifact revision, required source/method/output identifiers, valid digest syntax and classification; rejects unreviewed/unpublished links labeled public | Source availability, independently computed results, actual permissions or review signatures |
verify_scientific_recovery(before, after, before_links, after_links, tenant_id) |
Combines snapshot comparison with exact preservation of accepted/published scientific links | Live application recovery, cross-service persistence, scientific reproducibility |
Subtle but important: compare_recovery intentionally allows a higher revision; the same-revision digest check does not alone validate the scientific meaning or authorization of that new revision. The scientific-link validator currently allows an empty link collection when no registered claims are supplied. A production policy must separately require lineage for artifact classes that mandate it.
6. Procedure: reproduce the tests from Mac Terminal
These commands read a public GitHub repository and execute only its reference unit tests. They do not access a Workspace account or production services. They also avoid overwriting an existing local development checkout.
# Use a fresh, disposable directory
mkdir -p ~/Development/Sustainable-Catalyst/recovery-evidence
cd ~/Development/Sustainable-Catalyst/recovery-evidence
# Clone the public repository only if no checkout exists
if [ ! -d sustainable-catalyst-workspace/.git ]; then
git clone https://github.com/Content-Catalyst-LLC/sustainable-catalyst-workspace.git
fi
cd sustainable-catalyst-workspace
# Pin precisely the merged evidence revision
# Use detached HEAD so existing branches remain untouched
git fetch origin 81984e335e471a8938fad8b61676e430a89cecac
git switch --detach 81984e335e471a8938fad8b61676e430a89cecac
git rev-parse HEAD
python3 --version
# Run all tests, preserving both output and failure status
cd scientific_validation/workspace_recovery
set -o pipefail
python3 -m unittest -v \
test_recovery_validation \
test_scientific_recovery \
2>&1 | tee test-results-local.txt
Expected reference result: Ran 39 tests followed by OK. The command records an environment-specific execution log named test-results-local.txt, which is not automatically published to GitHub. If tests fail, retain the error output and Python version rather than editing evidence to match the expected result.
7. Terminal: inspect the exact source and verification record
# From the cloned repository root:
cd ~/Development/Sustainable-Catalyst/recovery-evidence/sustainable-catalyst-workspace
git show --stat --oneline 81984e335e471a8938fad8b61676e430a89cecac
sed -n '1,180p' scientific_validation/workspace_recovery/README.md
grep -n '^def \|^class ' \
scientific_validation/workspace_recovery/recovery_validation.py \
scientific_validation/workspace_recovery/scientific_recovery.py
# Optional: inspect the merged pull request using GitHub CLI
gh pr view 68 --repo Content-Catalyst-LLC/sustainable-catalyst-workspace --web
8. Reproduce a negative case without application credentials
The sample below creates a valid synthetic accepted artifact with one acceptance event, then simulates a recovered snapshot that has lost that artifact. The expected exception is accepted_artifact_missing.
from recovery_validation import (
Artifact, Event, Snapshot, RecoveryError,
compare_recovery,
)
stamp = "2026-11-16T12:00:00+00:00"
a = Artifact("figure-001", 1, "accepted", "a" * 64)
e = Event("event-001", "figure-001", 1, None,
"synthetic-reviewer", stamp, "accept")
before = Snapshot("project-demo", "tenant-demo", stamp, (a,), (e,))
after = Snapshot("project-demo", "tenant-demo", stamp, (), ())
try:
compare_recovery(before, after, "tenant-demo")
except RecoveryError as exc:
assert str(exc) == "accepted_artifact_missing"
print("PASS: missing accepted artifact rejected")
else:
raise AssertionError("Expected rejected recovery")
Save as demo_missing_accepted.py in the validation directory and run python3 demo_missing_accepted.py. This is a standalone illustration based on the verified function signatures; unlike the 39 repository tests, this particular example is not presented as independently executed acceptance evidence.
9. Test matrix and acceptance criteria
| Test scenario | Expected result | Evidence level |
|---|---|---|
| Unchanged valid snapshot | Validation succeeds | Covered by repository tests |
| Accepted artifact missing after recovery | Reject recovery | Covered by repository tests |
| Accepted digest altered at same revision | Reject recovery | Covered by repository tests |
| Required audit event missing | Reject recovery | Covered by repository tests |
| Wrong tenant identifier in snapshot | Reject recovery | Reference validation only; not authentication |
| Accepted output’s source/method revision changed | Reject scientific discontinuity | Covered by repository tests |
| Unreviewed or unpublished link marked public | Reject link | Untrusted synthetic status labels |
| Expired/revoked real user session; cross-owner access | Fail closed | Requires authenticated staging |
| Database restore with actual accepted records | No silent loss, verified rollback | Requires isolated restore rehearsal |
| Independent recomputation of scientific output bytes | Recomputed evidence matches declared tolerance and provenance | Not implemented by reference validator |
10. Proposed integration boundary: do not infer deployed endpoints
These Python dataclasses are not an HTTP request schema, database migration, web UI contract, or authorization mechanism. Before exposing recovery in Workspace, inspect the actual owning services for project identity, authoritative session validation, database transactions, immutable revisions, object storage, and publication state. Define a versioned service contract only after mapping it to source code and deployed migrations.
A production recovery operation should require: authenticated requester, server-derived tenant/project authority, target checkpoint ID, compare-and-swap revision or equivalent concurrency guard, a unique operation key, bounded transactional steps, audit outcome, and an explicit failure strategy. Return distinct typed errors for forbidden scope, missing checkpoint, stale base revision, corrupted artifact bytes, failed dependency, and incomplete restoration. These are design requirements, not names of existing Workspace endpoints.
11. Idempotency, partial failure, and restore safety
A timeout does not prove a recovery write failed. Before retrying, query an authoritative operation record where available; otherwise stop and escalate. Never repeatedly run migration or restore commands against production on the assumption that they are idempotent. A safe implementation stages restored objects, verifies byte-level digests and revision graphs, and changes the active pointer only after acceptance. Preserve an independently restorable backup and an immutable pre-restore receipt.
12. Scientific interpretation and provenance
Recovery correctness is not equivalent to scientific correctness. A retained digest string is not proof that file bytes were independently rehashed; a recorded source revision is not proof that the source is still accessible; a synthetic reviewed label is not a signed scientific approval. For accepted claims, an independent reviewer should inspect source transformations, analytical assumptions, environmental dependencies, uncertainty, and numerical replay where applicable. Trace a result from output through method and source to its governing review decision.
13. Authorization and disclosure
Never use a user-submitted tenant identifier as proof of identity. Resolve authority server-side; test denial across projects and organizations, revoked sessions, malformed requests, and unauthorized access to backup or audit evidence. Public Knowledge Base issues and CI artifacts must use synthetic data. Do not publish real user identifiers, private research outputs, session tokens, database snapshots, service credentials, or internal recovery endpoints.
14. Audit and operational evidence
For each authorized recovery attempt, record the change request, actor or service identity, approved project scope, source checkpoint, exact source and restored revisions, observed integrity checks, operation status, sanitized error code, and review decision. Keep timestamps timezone-aware. Audit evidence must be stored in a protected, durable system; a terminal log alone is not an immutable audit trail.
15. Troubleshooting
Symptoms
Tests fail to import; the wrong repository directory is active; the pinned commit cannot be checked out; or a restored project appears to lack accepted artifacts, historical revisions, or scientific links.
Cause
Common local causes are running Python outside scientific_validation/workspace_recovery, using a different source revision, or omitting an expected test file. In integration, possible causes include stale snapshots, incomplete restore steps, broken source-method lineage, missing audit events, invalid authorization, and storage or service failures. The reference package alone cannot identify a production root cause.
Resolution
- Run
pwd,git rev-parse HEAD, andls scientific_validation/workspace_recoveryfrom the repository root. - Use the pinned commit and execute the exact
unittestcommand in Section 6. - Preserve the full failing test name and error code; compare pre-failure and recovered snapshot inputs in a synthetic fixture.
- If an actual restore is implicated, suspend unsafe writes and follow the approved staging recovery procedure; do not fabricate missing audit events or bypass publication approvals.
- Escalate with a sanitized reproducer and evidence, never private data or secrets.
16. Release verification checklist
- Source: Exact Git SHA and owned code paths recorded.
- Reference tests: Local and/or CI executions with Python version, full output, and failure status recorded.
- Schema: Real recovery contract, database migrations, rollback and compatibility verified against deployed source.
- Security: Authenticated staging confirms server-derived project scope, revocation, tenant isolation, and least-privilege restore roles.
- Persistence: Isolated restore preserves accepted records and audit events, including actual file-digest verification.
- Scientific acceptance: Source/method/output lineage and required independent re-execution or review verified.
- Publication: Recovery does not promote a draft or a synthetic review label to public approval.
- Operations: Immutable backup, stop conditions, restore receipt, and bounded rollback confirmed.
17. Verification record
| Field | Recorded result |
|---|---|
| Source repository | Content-Catalyst-LLC/sustainable-catalyst-workspace (public) |
| Source merge | PR #68, merged |
| Evidence commit | 81984e335e471a8938fad8b61676e430a89cecac |
| Reference suites | 19 snapshot + 20 scientific-continuity tests |
| Recorded local result | 39/39 passed in user-provided Mac Terminal output |
| CI result for this exact commit | Not established in this article |
| Authenticated staging acceptance | Not established |
| Production recovery acceptance | Not established |
18. Related documentation and technical references
- SC-RELEASE-01: production recovery and identity release gates — release readiness context, not proof of closure.
- W3C PROV-O — provenance representation.
- RFC 9457 — HTTP API problem details, should a real API be implemented.
- Python unittest documentation — local execution and test discovery.
- GitHub permanent links — cite immutable source revisions.
Developer acceptance statement: The merged reference package supplies inspectable source and 39 locally passing synthetic tests for recovery continuity. It supports implementation planning and regression design but does not authorize claims that Workspace recovery, database restore, identity enforcement, or scientific review are production-verified.
