Worked Examples
Validate scientifically persistent saved state — Workspace
Persistent saved state must preserve project identity, revisions, and research evidence across authorized sessions. This validation protocol examines retrieval integrity, source continuity, revision conflicts, and recovery without treating successful storage as proof of scientific validity.
Application: Workspace
Component: Persistent Saved State / Project Versioning / Local-First Synchronization
Article type: Scientific and institutional validation protocol
Source baseline: 04f28743751634ed0bc64a5028290b4d29119400 (November 20, 2026)
Supported deployed version: Not verified
Independent scientific review: Not performed
Estimated reading time: 17 minutes
Purpose. A persistence claim is testable only when an authorized reviewer can recover the same project identity, revision, underlying research objects, and evidence relationships from a genuinely new session. A successful save response is one observation; it is not proof of durable recovery, scientific reproducibility, or permission to publish.
1. Goal
Test the primary assertion: a fresh session retrieves the same authorized project state. Record the exact authority being tested, the project, the principal, the observation time, and the intended claim. Distinguish local browser reload, authenticated backend retrieval, cross-device continuity, and recovery after infrastructure failure: they have different failure conditions.
Precondition: owned project P at accepted revision r
Save(P, r) -> server receipt R
GET(P) as newly authenticated owner -> project P' at revision r
GET(P) as unrelated principal -> no private project disclosure
Repeat a stale write from revision r-1 -> conflict; P unchanged
Required: ID(P') = ID(P)
revision(P') = r
projectFingerprint(P') = projectFingerprint(P)
canonicalObjects(P') = canonicalObjects(P)
parent/research artifact links remain resolvable
publication state is not silently promoted
Interpret fingerprint comparisons carefully. Workspace exposes both fingerprint (saved package) and projectFingerprint (project document). These are different values. Comparing identical server-reported fingerprints is useful but does not independently prove that the underlying bytes or scientific results are correct.
2. Requirements
- Approved testing scope, an isolated staging environment, and two synthetic principals: the project owner and a non-owner.
- The exact deployed commit, configuration and migration state. A GitHub commit identifies inspected code, not the deployed runtime.
- A synthetic project with at least one research question, notebook, dataset or artifact, and a private publication draft, each identified by stable IDs.
- Before/after project metadata, project document or a verified private digest, linked-object inventories and a read-only history observation.
- Saved receipt, operation ID, revision precondition and independent fresh-session authentication evidence. Redact session tokens, cookies, service-bearer credentials and personal data.
- A documented retention and recovery policy for backups, historical revisions and exported copies. Do not run destructive restore or synchronization experiments against live research records.
3. Identify the authority for each saved object
| Persistence boundary | What is authoritative | Required independent observation |
|---|---|---|
| Browser-local Workspace | localStorage['sc_workspace']; separate verified-save, journal, recovery and last-known-good metadata |
Reload in the same browser profile; inspect the readable state and integrity warning. This does not prove availability in a new device or clean browser profile. |
| Manual backend backup | Owner-scoped PostgreSQL project copy, stored through POST /v1/projects with the cloud-backup schema |
A newly authenticated owner performs GET /v1/projects/{project_id}; verify the returned package independently. |
| Revisioned backend sync | Backend project head and durable sync receipt; conditional mutation through POST /v1/sync/envelopes |
Reauthenticate; retrieve revision and fingerprint, inspect receipt, reject a stale write and confirm current head is unchanged. |
| Notebooks and artifacts | Separate owner-scoped notebook and artifact records, not necessarily stored inside the project payload | Retrieve each relevant notebook/artifact at its own authority and verify project binding and digest. |
| Private Research publication | Specialized publication and editorial records, not merely a locally saved project status | Confirm outputs remain private unless separate publication authorization and evidence exist. |
Workspace is local-first in its browser experience, while its backend sync protocol identifies PostgreSQL as authoritative for an accepted synchronized head. Neither statement means that signing in automatically uploads a local draft. See Workspace persistence runtime, SOURCE_BACKEND_SYNC and Backend revisioned project repository.
4. Define the scientific object and its invariants
Before the save, write a small, explicit inventory. Record the canonical project ID and research question, the observed data scope, source version or acquisition time, dataset rights, units, notebook/method version, artifact hashes, and any figure or decision derived from those inputs. Preserve the distinction between a relationship recorded in software and the scientific inference drawn from it.
| Invariant | Evidence to retain | Failure that matters |
|---|---|---|
| Stable identity | Owner scope, project ID, object IDs | Same title but different project or owner |
| Exact accepted version | Project revision and projectFingerprint |
Fresh read returns an older or divergent head |
| Scientific context | Research question, methods, units, assumptions, exclusions | Objects survive but their interpretation or metadata changes |
| Source provenance | Source IDs, file SHA-256, acquisition/version labels, rights evidence | Data are replaced, relinked or used without permission |
| Derivative lineage | Notebook ID, input IDs, processing version, figure/output IDs | Notebook/figure exists but inputs cannot be resolved |
| Publication boundary | Private/draft status and distinct editorial approval records | Save or restore silently changes public visibility |
A project whose objects have correct IDs but whose units changed from t C/ha to t CO₂/ha is not scientifically equivalent. Structural equality, scientific equivalence, and analytical correctness require different checks.
5. Procedure — establish the pre-save baseline
- Create a disposable project and a small synthetic dataset. Record
projectId, authenticated owner scope,revision,storageMode, and both returned fingerprints. - Export or privately snapshot the canonical project document. Keep its exact object IDs, research question, data units and derivation references. Do not publish confidential source bytes.
- Inventory notebooks, uploaded artifacts and private drafts from their respective owner-scoped APIs. Save the independently computed SHA-256 of the synthetic source file.
- Record a known older project revision to test historical retrieval without overwriting the current head.
- Choose one reversible change (for example a synthetic note) and retain the expected resulting revision. Do not make publication state a side effect of this test.
Only the backend’s projectFingerprint should be compared with another backend projectFingerprint. For an independently controlled file, hash the actual file bytes with SHA-256 and record the hash separately.
6. Procedure — save and obtain a receipt
Use the actual release’s authenticated save path. For a revisioned project, the source declares POST /v1/projects with sc-workspace-sync-push/1.0, and a separate local-first envelope route POST /v1/sync/envelopes. Neither requires accepting automatic semantic merges.
{
"schema": "sc-workspace-sync-envelope/1.0",
"envelopeId": "synthetic-envelope-04",
"operationId": "synthetic-operation-04",
"deviceId": "synthetic-device-01",
"objectKind": "project",
"objectId": "synthetic-persistence-study",
"baseRevision": 3,
"baseFingerprint": "<actual synthetic server head fingerprint>",
"mutation": {
"action": "put",
"title": "Synthetic persistence study",
"document": {
"schema": "sc-workspace-project/20.0",
"id": "synthetic-persistence-study",
"title": "Synthetic persistence study",
"objects": []
}
}
}
The JSON is a shape example for isolated staging, not a verified deployable request; replace the placeholder only after reading the current synthetic server head, and provide a project document conforming to the active validator. Never copy a real operation token, bearer credential or private project payload into the article. After a successful write retain receipt.status, receipt.operationId, serverRevision, canonicalFingerprint and the returned project metadata.
For retries after an unobserved response, use the same envelope and operation identifiers. A new identifier can create a distinct operation. The source returns replayed: true when it resolves a previously recorded matching operation.
7. Procedure — independently rehydrate the saved state
- Close the test client or clear its authenticated session using the approved test harness. Create a separate client and authenticate the same owner again.
- Disable client caches for the test, or prove the request reached the backend rather than a stale browser view.
- Call
GET /v1/projects/{project_id}. The source returns a backend project metadata item and storedpackage; examine the nested project document rather than assuming the metadata item contains it. - Match project ID, accepted revision,
projectFingerprint, storage mode and exact object content against the saved baseline. Compare full project content under a deterministic, documented canonicalization rule; do not confuse backend metadata equality with a new cryptographic proof. - Separately call
GET /v1/notebooks/{notebook_id}, check its project ID, revision and notebook fingerprint, and retrieve any relevant artifact and private output from their proper stores. - Confirm all source links resolve under the owner’s authorization and the publication state is still private. Record the time and request/response status without including secrets or protected data in public evidence.
Acceptance is not met if the content is only found in the original browser’s local storage, or if a signed-in account returns a different project head. The complete cross-device claim requires an independently configured device or browser context with its own authenticated network session.
8. Test owner isolation and failed authentication
Repeat the same project read with a separate, unrelated synthetic owner and then without authentication. The project route raises HTTP 404 for a record absent from the current owner scope; an unauthenticated request is expected to be denied by the configured identity layer (typically 401). Record the actual status and validate that the response body contains no project content, raw source data, or private identifiers.
Do not claim tenant isolation from the client UI hiding a project. Execute the negative check at the authenticated backend boundary, and distinguish an unexpected 403 policy rejection from a missing-owned-record 404. A synthetic metadata fixture can describe these expected results but cannot produce real authorization evidence.
9. Test a stale revision and confirm non-mutation
Capture the current head at revision r; intentionally submit a synthetic sync change with baseRevision = r-1 (or a wrong base fingerprint). The current local-first protocol records a conflict and returns HTTP 409 with a conflict.reason of base-revision-mismatch or base-fingerprint-mismatch. Then re-read the accepted head independently.
before = GET owned project head (revision r, fingerprint f)
response = POST stale envelope (baseRevision r - 1)
assert response.httpStatus == 409
assert response.conflict.reason == "base-revision-mismatch"
after = GET owned project head
assert after.revision == r
assert after.projectFingerprint == f
# No automatic merge and no overwrite of the accepted research document
A 409 response by itself is insufficient: verify non-mutation of the canonical head and that no unrelated notebook, artifact, or publication state changed. Preserve the conflict receipt as a diagnostic; do not promote it to evidence that the original scientific result was correct.
10. Verify historical versions without rewriting the present
The backend exposes GET /v1/projects/{project_id}/revisions and GET /v1/projects/{project_id}/revisions/{revision}. Retrieve a known older revision in a read-only operation, compare its timestamp and fingerprint, and then read the current head once more. The older package must remain distinguishable from the accepted current revision.
Browser-local restore points follow a separate model: the documented version-history workflow clones the previous project with remapped IDs instead of overwriting the active project. Do not treat this copy-based local restore as equivalent to server-side point-in-time recovery or an infrastructure backup restore.
11. Verify scientific provenance after retrieval
For each scientific claim being carried forward, verify the identity and permission of its inputs. A defensible chain includes source material → versioned dataset → analysis/notebook and method → figure or report → human-reviewed inference. Record missing or intentionally excluded objects rather than silently substituting later files with similar names.
For an independently controlled synthetic source:
from hashlib import sha256
from pathlib import Path
source = Path("synthetic-dataset.csv")
expected = "<SHA-256 recorded before save>"
actual = sha256(source.read_bytes()).hexdigest()
assert actual == expected, "Source bytes differ from the baseline"
# This verifies only those bytes, not dataset rights or methodology.
Check numerical units, sample intervals, missing-data handling, model inputs, software and method versions, and known uncertainty. The same saved notebook may re-execute differently if dependencies, random seeds or external datasets change. Report that as a reproducibility or methodological discrepancy, not necessarily a persistence failure.
12. Record institutional and publication boundaries
Saving a draft cannot substitute for a scientific review or an editorial authorization. Document authorship, review roles, rights clearance, provenance, intended audience, excluded material, and the exact publication object. The private/public state belongs to its specialist source of authority, not a guessed field in a generic project save response.
If a restore reintroduces a withdrawn draft, changes approved source references, or causes a private output to appear public, halt further mutation. Preserve the before/after evidence and escalate through the authorized publication process. Do not attempt to repair the state by editing database rows or local-storage keys manually.
13. Run the offline evidence checker
The accompanying package provides validate_persistence_evidence.py, a small synthetic dataset, a synthetic saved-state observation, and a second-session read-back fixture. Its JSON evidence schema sc-kb-persistence-scientific-evidence/1.0 is an article test format, not a Workspace API contract.
cd sc-persistent-state-scientific-validation
python validate_persistence_evidence.py synthetic-evidence.json
python -m unittest -v test_validate_persistence_evidence
The checker verifies project IDs, accepted revisions, supplied fingerprints, read-back equality, claimed fresh-session conditions, owner-denial observations, a stale-write non-mutation claim, notebook and artifact links, synthetic file SHA-256 and private publication state. It cannot independently authenticate the test principals, confirm backend responses, replay a PostgreSQL restore, or judge the research. A passing result is synthetic-structural-pass-only.
14. Symptoms
| Observation | Meaning to investigate | Do not infer |
|---|---|---|
| Local change survives reload but not new browser/device | Local-only save or unenrolled account sync | Data loss from an authenticated server record without checking it |
| Save returns 200, fresh GET returns older revision | Wrong project/owner, stale cache, read-model delay, or another storage path | Durable recovery succeeded |
| HTTP 409 on sync | Revision/fingerprint mismatch or manual-backup overwrite protection | Permission to force-replace the accepted head |
| Project present, notebook absent | Different object authority or incomplete notebook persistence | Project save necessarily includes all notebook bytes |
| Correct IDs, altered SHA-256 or units | Source or transformation drift | Scientific equivalence |
| Old draft appears public | Potential unauthorized editorial state transition | Save status is publication approval |
15. Cause
Group failures by authority and time: (a) browser-only save never enrolled for backend persistence, (b) wrong authenticated owner or wrong project ID, (c) stale or conflicted revision, (d) package/document fingerprint confusion, (e) interrupted response retried with a new idempotency identifier, (f) notebook/artifact stored separately, (g) storage corruption or unchecked recovery candidate, and (h) publication or scientific metadata altered outside the project-store transaction.
Do not use a general server error to assert a single cause. A persistence failure and a science-method failure can coexist.
16. Troubleshooting
- Identify the authority. Is the disputed state in browser storage, an explicit account backup, a synchronized backend head, or a separate notebook/artifact/publication store?
- Confirm the exact owner. Read the backend with an authenticated test principal; never use a user-supplied
ownerScopefield as authentication evidence. - Compare immutable identifiers. Project ID, revision, expected operation ID, authoritative fingerprint, object IDs, source digest and method version.
- Classify the response. Record HTTP status, typed error, receipt, nonsecret trace identifier and the effect on the current head.
- Check interrupted operations. Inspect the existing receipt before choosing a retry; preserve the same operation IDs when retrying one unobserved request.
- Inspect dependencies. Check notebooks, datasets, figures and publication records at their independent sources.
- Preserve evidence. Export a protected recovery candidate before any controlled restore. Stop destructive changes when the current or last-known-good version is ambiguous.
17. Resolution
For a local-only draft, explicitly create an authorized account backup or enroll in sync, then verify through a fresh session. For a backend revision conflict, reconcile the competing heads and preserve divergent research in separate copies; do not silently apply last-write-wins. For a corrupted browser payload, use the documented integrity export and quarantine workflow; a recorded fingerprint drift does not authorize automatic overwrite. For an incorrectly linked notebook or figure, fix the relationship in its authoritative component with a reviewed, revisioned action and preserve the former state.
Infrastructure restore needs a separate rehearsed runbook with independent backups, controlled migrations, rollback, object-store reconciliation and institutional authorization. No offline checker can certify that the deployed database or storage system can be recovered.
18. Verification
Run all acceptance tests against an isolated staging build matching the intended deployment. The minimum evidence set is:
| Test | Pass condition | Failure condition |
|---|---|---|
| V-01 Owner fresh session | Reauthenticated owner reads same project ID, accepted revision, project fingerprint and project document | Missing, stale, wrong owner or altered content |
| V-02 Foreign principal | Non-owner cannot retrieve private project or content | HTTP 200 or sensitive data disclosure |
| V-03 No authentication | Request denied by configured security layer with no content leak | Unauthorized read accepted |
| V-04 Stale sync | HTTP 409; accepted head remains byte-/fingerprint-consistent | Silent overwrite or semantic merge |
| V-05 History | Older version retrieved read-only; head unchanged | History read unexpectedly mutates current state |
| V-06 Scientific links | Notebook, data, figure/source references retain the same owner/project association, versions and digests | Broken links or unrecorded changes |
| V-07 Publication boundary | Draft stays private without distinct editorial authorization | Unauthorized visibility or release-state change |
| V-08 Recovery | Authorized restore independently revalidated after a rehearsed failure | Unproven restore, unreconciled attachments or leaked private evidence |
Decision vocabulary: PASS requires real evidence for every test claimed; FAIL indicates a demonstrated violation; INCOMPLETE means missing or ambiguous evidence. Record whether scientific replication and external review occurred separately. Do not convert an offline structural fixture into a live production PASS.
19. Acceptance criteria and evidence register
For a publication-quality technical claim retain, in the private verification record: inspected commit, actual deployed image/release digest, database migration IDs, exact synthetic principal and project IDs, operation and receipt identifiers, timestamps, request/response status, before/after revision and hashes, controlled artifact digests, negative-case outcomes, backup/restore evidence, reviewer identity and signoff, and open exclusions. Store secrets and unpublished content in restricted systems; the Knowledge Base should expose only a sanitized receipt and conclusions.
The test result must state the scoped conclusion. Example: “In staging build X, an owner-scoped project at revision 4 was retrieved from an independently authenticated session with unchanged project fingerprint; foreign-owner and stale-write requests were denied. Scientific claims and disaster recovery were not independently verified.” Do not publish that sentence as an observed result until X and its evidence actually exist.
20. Scientific interpretation
Durability of a digital record is necessary for reproducible research but does not establish that the research is true. A preserved carbon-stock estimate can remain wrong because of field design, unit conversion, model assumptions, instrument bias or unrecorded exclusions. Independently inspect the methods, rerun the computations with fixed inputs and dependencies, reconcile uncertainty and conduct appropriate scientific review.
Separately evaluate rights, consent and confidentiality: correct technical retrieval can still be an inappropriate disclosure. Preserve a clear boundary between machine-verifiable state, institutional authorization and human scientific judgment.
21. Source and release boundaries
The inspected code is a source baseline, not evidence of production availability. Relevant source-verified behavior includes owner-scoped project GETs, revisioned writes, a local-first sync receipt and conflict protocol, local verified-save recovery, and separate notebook storage. Revalidate these paths after any deploy, migration, identity-provider change, schema change, sync behavior change or restoration exercise. Feature names and storage routes shown here may differ from the public WordPress interface and must not be treated as a guarantee of access in every release.
22. Technical references
- Workspace persistence runtime — canonical browser persistence runtime.
- Canonical state and persistence boundary — canonical persistence-state boundary.
- Persistence corruption and recovery — persistence corruption, quarantine and recovery.
- Workspace backend API routes — authenticated project, notebook, sync and revision routes.
- Backend revisioned project repository — backend project store and revision repository.
- Local-first sync implementation — local-first sync envelope, replay and conflict behavior.
- Backend project and sync request schemas — project and sync request validation contracts.
- Accounts and cloud persistence foundation — accounts and explicit cloud backup flow.
- Cross-device conflict-safe recovery — conflict-safe recovery and manual synchronization.
- Project version history and restore points — browser-local historical restore points.
- Repository sync regression tests — repository-local sync tests; not executed as part of this article.
Evidence status: Source reviewed; 42 offline synthetic checker tests executed separately; runtime staging, deployment parity, independent recovery and scientific acceptance remain unverified. The article’s companion checker is not part of the product API.
