Troubleshooting

Troubleshoot persistent saved state — Workspace

Diagnose Workspace persistent-state failures involving lost edits, stale revisions, access restrictions, incomplete saves, and data-integrity errors. Includes safe recovery procedures, GitHub workflows, and reproducible macOS/Linux tests.

ProductSustainable Catalyst Platform CoreUpdatedNovember 19, 2026Reading time24 minutes

Application: Workspace
Article type: Troubleshooting and developer operations
Scope: Persistent project state, revisions, durability, authorization, integrity, and safe recovery
Verification: Synthetic local Python/SQLite reference; 47 unit tests and 20 negative scenarios executed on Linux (Python 3.13.5); GitHub-hosted and deployed Workspace checks not executed
Estimated reading time: 18–22 minutes
Companion: SC-KB-PERSIST-STATE-01, offline code and evidence archive

Primary acceptance: A fresh, appropriately authorized session must retrieve the same committed project revision and content, while an unauthorized principal cannot inspect or modify it. The comparison must be against a recognized committed revision—not an unconfirmed autosave, in-memory browser view, stale search index, or another collaborator’s working copy.

1. What persistent saved state must establish

Workspace research state includes document edits, research objects, source references, selected method and input versions, figures, computational outputs, editorial actions, and associated project metadata. Persistence means that an accepted state survives the relevant process or session boundary, remains scoped to the correct organization and project, and can be retrieved with its identity and revision intact. A successful 200 OK response or “Saved” banner alone is insufficient evidence.

Differentiate local draft (browser memory), pending write (request accepted but not yet committed), committed revision (durably stored according to documented storage guarantees), and approved/public revision (separate governance decision). Persistence never implies publication or scientific validation.

2. Minimum incident record and safe first response

Before attempting recovery, record a UTC timestamp, environment, sanitized trace/correlation ID, actor role, organization and project IDs (use anonymized references in public tickets), expected revision, observed revision, operation, result code, and whether the original session remains open. Capture the last known accepted revision and the full local error context in a restricted incident store.

  • Stop writes if revision history, scope, or integrity is uncertain.
  • Do not repeatedly click Save when the request may have committed despite a timeout.
  • Do not clear browser storage until you have determined whether it contains unsynchronized drafts.
  • Never publish a draft merely to make the record visible.

3. Symptom-to-cause diagnosis matrix

Symptom Most useful checks Safer response
Changes vanish after reload Commit receipt; server revision; session identity; browser-only draft Preserve draft, fetch authoritative revision, compare before retry
Save says success but another session sees older data Primary/replica consistency; cache age; read routing; ETag Read from authoritative path; invalidate only documented cache keys
409 conflict or 412 precondition failure Current revision vs expected revision/ETag Reload and reconcile; never overwrite unreviewed changes
403 or concealed 404 Authenticated identity; tenant/project grant; revocation Correct authorization through approved process; do not broaden access
Duplicate edits after retry Idempotency receipt; request fingerprint; commit status Replay only documented idempotent request or reconcile first
Missing figures, sources, or outputs Artifact IDs; checksums; parent revision; storage rights Quarantine incomplete state; do not silently substitute files
State cannot be parsed after deployment Schema/migration version; client/server release compatibility Read-only mode; migration review and tested rollback path
Partial history / hash mismatch Snapshot vs revision log; transaction boundary; backup health Halt mutation; preserve evidence; compare guarded recovery candidates
Database or dependent service unavailable Health, DNS/TLS where applicable, storage capacity, locks, timeouts Classify transient vs permanent failure; avoid blind write retries

4. Confirm the exact ownership and identity boundary

Identify the authoritative persistence owner before debugging the UI. Separate client autosave, Workspace service, authentication service, Library/object storage, audit subsystem, search/index read models, and publication service. Each can return different freshness or authorization answers. Do not infer a live endpoint or database table from this example.

For every read or write, verify server-side organization_id, project_id, actor identity, effective permission, and object revision. Ownership must be checked on each operation, not solely when creating the project or opening the editor. A wrong-tenant object should return a safe denial rather than revealing its existence, metadata, or prior revision.

5. Check revision consistency before modifying anything

A reliable diagnostic compares four properties: organization/project identity, committed revision, canonical content digest, and provenance/audit linkage. In the synthetic package, revisions begin at 1, each write requires the expected previous revision, and the project snapshot is checked against the append-only-by-contract revision log.

Conceptual invariant:

saved_scope == requested_scope
AND loaded_revision == accepted_revision
AND sha256(canonical_json(loaded_state)) == accepted_state_sha256
AND verified_audit_chain == accepted_audit_chain

The stored SHA-256 is a byte-integrity signal. It does not prove the research result is true, that the actor was entitled to make the claim, or that a privileged adversary could not rewrite the entire database.

6. macOS prerequisites and setup

Run the demonstration on your own Mac, not on the production WordPress or Research servers. Python 3.11 or later is supported by the example; no third-party dependencies are needed.

# macOS Terminal
python3 --version
git --version
# Optional GitHub CLI, only if installed:
gh --version

# After downloading and extracting the developer ZIP:
cd sc_workspace_persistent_state_troubleshooting
python3 -m unittest discover -s tests -v
python3 failure_matrix.py

If the python3 command is missing, install a supported Python distribution using your organization’s approved package-management process. The test environment does not require Docker, root privileges, or any Workspace account.

7. Linux prerequisites and setup

On Linux use the same Python commands. The SQLite driver is included with typical CPython installations; check both modules directly before interpreting a missing module as a Workspace error.

# Linux Terminal
python3 --version
python3 -c 'import sqlite3,hashlib,json; print("stdlib dependencies OK")'

cd sc_workspace_persistent_state_troubleshooting
python3 -m unittest discover -s tests -v
python3 failure_matrix.py

Do not run this sample as a production service or point it at a production database. The code deliberately uses an in-memory policy fixture, not actual institutional authentication.

8. Understand the synthetic project and permission fixtures

The package contains fixtures/state-v1.json, fixtures/state-v2.json, and fixtures/access.json. The state contains a synthetic title, synthetic notes, and artifact IDs with illustrative SHA-256 strings. Its grants include a writer, a read-only reviewer, an unrelated tenant, and a revoked identity. No actual Wexford observations or private workspace records are included.

The example strictly accepts only title, notes, and artifacts[]. Fields such as access_token, undocumented flags, and nested arbitrary properties are rejected rather than silently saved or echoed back. In production, fields should be derived from a real versioned schema and property-level permissions.

9. Reproduce a successful save to durable local storage

Create a fresh local SQLite database and commit the first synthetic revision. This is a stand-in for a Workspace save operation, not a request to a Sustainable Catalyst endpoint.

mkdir -p out
python3 state_cli.py seed   --db out/state.sqlite   --org org-demo --project project-erw-demo   --actor researcher-one --access fixtures/access.json   --fixture fixtures/state-v1.json   --expected 0 --key initial-create

Expected: the response reports revision: 1, a 64-character state_sha256, and replayed: false. Each write uses a transaction that either commits project snapshot, revision history, and idempotency receipt together or rolls them back.

10. Prove persistence in a fresh process and different authorized role

Close the initiating command. The next command launches a separate Python process, opens the database again, and reads as a different authorized principal.

python3 state_cli.py read   --db out/state.sqlite   --org org-demo --project project-erw-demo   --actor reviewer-two --access fixtures/access.json

Acceptance: the loaded project state, revision, and checksum match the committed record. A live Workspace acceptance test should additionally involve a genuinely new browser session or authenticated process and confirm the authoritative server read—not merely reuse the same browser cache, local storage, or sticky process.

11. Apply a second revision using optimistic concurrency

Write a second synthetic revision with --expected 1. The expected revision is a guard against overwriting a collaborator’s intervening changes.

python3 state_cli.py save   --db out/state.sqlite   --org org-demo --project project-erw-demo   --actor researcher-one --access fixtures/access.json   --fixture fixtures/state-v2.json   --expected 1 --key revision-two

python3 state_cli.py verify   --db out/state.sqlite   --org org-demo --project project-erw-demo

Expected: the project advances to revision 2 and the audit chain verifies. If the revision is no longer current, treat the attempted write as a conflict requiring reconciliation, not an instruction to force the old state back into place.

12. Reproduce and resolve a stale revision conflict

Deliberately try to save against the already superseded revision 1 using a new idempotency key.

python3 state_cli.py save   --db out/state.sqlite   --org org-demo --project project-erw-demo   --actor researcher-one --access fixtures/access.json   --fixture fixtures/state-v1.json   --expected 1 --key deliberately-stale

# Expected nonzero exit and a STALE_REVISION error.
# Verify that revision 2 remains unchanged:
python3 state_cli.py diagnose   --db out/state.sqlite   --org org-demo --project project-erw-demo

The CLI returns a synthetic 409 STALE_REVISION. In a real HTTP service using If-Match properly, 412 Precondition Failed is a typical mapping under RFC 9110. The exact live Workspace behavior must be established from its implemented contract.

13. Test idempotent retries after ambiguous network failures

When a request times out after the service commits, the client may not know whether the save occurred. A bounded idempotency key permits the service to identify a repeated request. The test implementation stores a fingerprint of actor, scope, expected revision, and payload; a replay with the same key and same request returns the original receipt without creating another revision. Reusing the key for different content fails with IDEMPOTENCY_CONFLICT.

Do not automatically retry a non-idempotent operation when the service does not document its deduplication period, key scope, and recovery guarantees. Confirm commit status first.

14. Diagnose unauthorized, revoked, and wrong-tenant access

Use the synthetic access fixture to confirm that read permission does not grant write permission, revoked actors are refused, and a principal from another organization cannot access the project simply by guessing its ID.

# Expected: denied with a sanitized NOT_FOUND_OR_DENIED response.
python3 state_cli.py read   --db out/state.sqlite   --org org-demo --project project-erw-demo   --actor outsider --access fixtures/access.json

# Check the full authorization matrix:
python3 failure_matrix.py

In production, an identity provider, server-side grants, session validation, and audited authorization decisions must replace the fixture. Never loosen rights to “fix” a not-found response until the correct identity and object ownership are established.

15. Identify incomplete or corrupt saved state

Read the current state, all preceding revisions, and the recorded content digests. The reference verifier checks sequential revisions, each prior hash-chain link, the revision JSON checksum, and current snapshot alignment with the most recent history entry. It reports integrity failures rather than presenting an inconsistent state as healthy.

python3 state_cli.py verify   --db out/state.sqlite   --org org-demo --project project-erw-demo

python3 state_cli.py diagnose   --db out/state.sqlite   --org org-demo --project project-erw-demo

A checksum failure warrants preserving a forensic copy and disabling further mutation. Do not recompute the checksum over altered bytes and call that a repair; compare the last accepted artifact with a trusted restore point and investigate what changed.

16. Check stale cache, search index, and read replicas separately

A correct database write can coexist with an outdated screen. Record the cache or read-model revision independently of the authoritative project record; verify whether each response came from a primary, read replica, search index, API gateway, or client cache. Where available, compare an ETag or revision field and inspect documented cache directives.

Only invalidate cache entries that are explicitly safe to purge, and only after confirming the authoritative data are intact. Never use a public search result as proof that a private draft has been published or that an internal state has disappeared.

17. Handle partial dependency failures and transactions

Consider a save that updates a project row but fails to append the audit event, or a revision that references an artifact not yet committed to Library storage. A proper design must establish which operations share a transaction and how out-of-transaction resources are recovered. The synthetic SQLite model groups its project snapshot, history entry, and idempotency receipt in one BEGIN IMMEDIATE transaction. A test injects an audit-insert failure and confirms rollback.

Production limitation: a database transaction cannot atomically commit an independent object store, search engine, or remote workflow without additional coordination. Use documented outbox, reconciliation, or compensating mechanisms; do not invent an untracked repair record.

18. Create a backup without replacing the accepted state

Before recovery, obtain a point-in-time, access-controlled backup and record its hash and retention context. The local example uses Python SQLite’s online backup facility and refuses to overwrite an existing destination:

python3 state_cli.py backup   --db out/state.sqlite   --out out/state-backup.sqlite

python3 state_cli.py restore-review   --db out/state.sqlite   --backup out/state-backup.sqlite   --org org-demo --project project-erw-demo

Expected: live_database_modified: false and decision: MANUAL_APPROVAL_REQUIRED. This is an inspection workflow; there is deliberately no automatic destructive restore command. Production recovery also requires a tested off-host backup, restore permissions, retention and encryption policies, and an accountable owner decision.

19. Check schema versions and migrations

When an older client cannot read a new state structure, record the source format version, migration revision, minimum compatible client version, and any lossy conversion. Do not deserialize an unknown schema and silently drop fields. The local example checks SQLite’s user_version and fails closed on unsupported versions.

A real migration acceptance test should save a representative draft under the previous release, migrate a copied environment, reopen in a new session, compare content and provenance, test rollback, and verify that private records have not become public through a schema default.

20. Separate scientific provenance from system persistence

Persistent state can preserve references to source files, computational notebooks, figures, and claim-bearing outputs. It cannot establish that a source is valid, that a calculation is correct, or that a research interpretation was independently reviewed. Preserve explicit input revision IDs, artifact byte hashes, methods, units, and derivation links where relevant. The example’s artifact hashes are illustrative strings, not checksums verified against real files.

Use scientific validation and publication approval as separate evidence gates. A restored draft must not acquire “approved” or “published” status merely because its storage integrity passes.

21. Example HTTP error contract and safe retries

The following is a proposed design sketch only, not a discovered Workspace route. A deployed API might expose project state with conditional requests and structured errors:

GET /api/v1/organizations/{org}/projects/{project}/state

PUT /api/v1/organizations/{org}/projects/{project}/state
If-Match: "revision-2"
Idempotency-Key: unique-operation-key
Content-Type: application/json

Map a missing or inaccessible scoped object to a non-disclosing result, malformed input to a validation error, stale conditional updates to a precondition failure, a reused idempotency key with changed payload to a conflict, and persistence or schema outage to a controlled service error. RFC 9457 provides a structured format for HTTP problem details, but responses must not reveal private titles, tokens, database queries, or object contents.

22. GitHub workflow and continuous integration

The ZIP includes .github/workflows/state-tests.yml. It runs the same positive and negative tests under Python 3.11 and 3.13 on Ubuntu with read-only repository permissions. A GitHub-hosted run has not been executed for this artifact. To inspect the workflow and include the synthetic-only example in a repository you control:

# In a new, explicitly designated synthetic example repository:
git init
git status
git add .
git diff --cached --stat
git commit -m "docs: add synthetic Workspace persistence diagnostics"
# With a connected repo, after a PR is opened:
gh pr checks
gh run list --limit 5

Review what will be committed. Do not push out/, real research drafts, database exports, environment files, authentication material, or sensitive logs. A GitHub Actions pass on synthetic fixtures still does not prove deployed Workspace behavior.

23. Required positive and negative acceptance tests

Case Expected result Evidence to retain
Save revision 1; new process reads it Same scope, revision, digest and body Save receipt + fresh-process read
Writer saves revision 2 Monotonic revision and linked history Audit and checksum receipt
Two writers submit from revision 1 Only first accepted; second reconciles Stale-write rejection without overwrite
Repeat identical operation No duplicate revision Idempotent replay receipt
Repeat key with changed request Explicit conflict Error code and unchanged state
Other tenant, read-only actor, revoked grant Access refused; no private content leaked Sanitized denial tests
Corrupt current snapshot or past revision Integrity failure, writes halted Verification report, restricted incident copy
Simulate audit-write failure Complete transaction rollback Failure injection and state comparison
Backup and restore review Current state unchanged; manual approval required Backup integrity and difference report
Client/server version mismatch Unsupported schema refused Release and migration reference

24. Executed local evidence and reproducibility

The provided standalone package was run using Linux and Python 3.13.5. Results: 47/47 unit tests passed, 20/20 injected failure scenarios rejected as expected, and the synthetic save/read/update/verify/backup/restore-review command sequence completed. Evidence files are included under evidence/ in the ZIP.

To reproduce the tests independently, extract the archive to a new directory, confirm the expected files and Python version, run both test commands, then compare evidence/unit-tests.txt and evidence/failure-matrix.txt with your new output. No network access or application credentials are needed for the local reference.

Not performed: macOS runtime test, hosted GitHub Actions, direct deployment inspection, production persistence tests, independent security assessment, and scientific review. Do not reinterpret local test success as an operational release approval.

25. Escalation and controlled recovery decision

If the safe tests fail, provide the component owner with a sanitized incident bundle: project/organization aliases, actor role, expected and observed revisions, affected operation, UTC timestamps, redacted trace IDs, code and release identifiers, observed integrity status, whether a confirmed backup exists, and the smallest synthetic reproduction. Specify if writes have been frozen and whether privacy or publication boundaries may have been crossed.

Restore only from a verified backup, on an authorized isolated environment, after a responsible reviewer approves the rollback scope and after confirming no newer accepted research state will be destroyed. Reconcile downstream artifacts and audit histories; document the recovery as a distinct event.

26. Production verification checklist

  1. Identify the actual Workspace service and code owner from its deployed release manifest.
  2. Link exact repository, commit SHA, schema/migration revision, and relevant line-level source locations.
  3. Record authenticated save/read endpoints and actual error semantics (or explicitly document non-HTTP transports).
  4. Verify new-session reads against the authoritative store using controlled synthetic identities.
  5. Test cross-organization denials, revoked grants, stale concurrent saves, idempotency, and audit rollback on staging.
  6. Check restore from an independently protected off-host backup and confirm scientific artifact relationships.
  7. Verify caches, read replicas, search indexes, and publication state remain consistent with accepted revisions.
  8. Attach CI artifacts, operational trace references, rights/processor approval, and reviewer acceptance before removing this notice.

27. Technical references

  1. SQLite, Transactions and PRAGMA integrity checking. Database transaction and integrity semantics.
  2. Python Software Foundation, sqlite3 — DB-API 2.0 interface and unittest. Embedded persistence, online backup, and reproducible tests.
  3. IETF, RFC 9110 — HTTP Semantics. Conditional requests and precondition failures.
  4. IETF, RFC 9457 — Problem Details for HTTP APIs. Typed, machine-readable error envelopes.
  5. OWASP, API1:2023 — Broken Object Level Authorization and API3:2023 — Broken Object Property Level Authorization. Scope- and field-level access risks.
  6. GitHub, Building and testing Python and Workflow syntax. CI configuration and permissions.
  7. W3C, PROV-O: The PROV Ontology. Vocabulary for recording research provenance separately from storage status.

Use and limits: The executable material is an original synthetic diagnostic reference, not a supported production API. Preserve project-specific legal rights, retention rules, scientific review, and platform release gates when adapting it. Last editorial revision: November 2026.

Scroll to Top