Consolidate duplicated persistence primitives, manifest validation, and multi-pass restore checks

Open
#207 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
backend, databases

Research direction

Start by reading the named persistence, workspace, authority, promotion, and trajectory review files, then trace the existing shared helpers and validation call paths. The scope spans 12 files and several overlapping restore and validation flows, so map their contracts before changing them. Done means the listed primitives are consolidated without changing schemas, APIs, or error contracts, all specified test suites pass, and air format --check . passes.

Written by the indexing model from the issue text.

Description

Problem

Persistence, promotion, authority, and trajectory-review layers (~21,800 lines across 12 files) carry heavy duplicated boilerplate: R/promotion-persistence.R re-implements primitives from R/product-persistence.R, STORM and Co-STORM manifest validators duplicate ~150 lines of unreachable post-validation checks, Co-STORM bundle resume parses and restores the workspace twice, and digest/nullable/schema-field/Deputy-status helpers are copy-pasted across files.

Scope

  1. Unify R/promotion-persistence.R onto R/product-persistence.R
    • Delegate tempest_promotion_file_checksum(), tempest_promotion_write_json() / _read_json(), tempest_promotion_symlink(), tempest_promotion_install(), and regular-file assertions to shared helpers in R/product-persistence.R.
  2. Consolidate shared bundle writers and manifest inventory validation in R/product-persistence.R
    • Extract shared tempest_persistence_bundle_write_json() / _write_text() replacing identical pairs in R/storm-persistence.R:52–86 and R/costorm-persistence.R:1457–1494.
    • Extract shared bundle inventory + checksum validation helper, eliminating ~150 lines of unreachable checks already enforced by tempest_persistence_require_regular_bundle_files() and tempest_persistence_manifest_checksums() in tempest_storm_bundle_validate_manifest() (R/storm-persistence.R:513–728) and tempest_session_bundle_validate_manifest() (R/costorm-persistence.R:1972–2246).
  3. Eliminate redundant multi-pass validation and workspace restore
    • Share a single parsed-snapshot validation path between tempest_costorm_bundle_validate_product() (R/costorm-persistence.R:2249–2416) and tempest_session_restore_internal() (L1109–1449) to eliminate ~150 lines of duplicated validation and double ResearchWorkspace restoration during tempest_session_resume().
    • Remove redundant inner schema/record checks in R/research-workspace-persistence.R (tempest_research_workspace_restore_schema vs require_current_schema, redundant else branch in exact_records, redundant pre-check in validate_claim_record) and factor the 6 repeated collection-restore loops in tempest_research_workspace_restore() (L751–1150) into a helper.
    • Deduplicate pre-authority validation passes in R/storm-persistence.R where tempest_product_authority_validate() already enforces the same invariants (preserving exact error classes and messages).
  4. Consolidate shared digest, nullable, schema-field, and Deputy-lineage helpers
    • Unify tempest_promotion_digest() (R/promotion-types.R:24–33) and tempest_trajectory_digest() (R/trajectory-review.R:202–204) onto a shared R/product-hash.R helper.
    • Unify verbatim identical tempest_promotion_nullable() (R/promotion-types.R:35–43) and tempest_trajectory_nullable() (R/trajectory-review.R:206–214) in R/product-validation.R.
    • Reuse tempest_resource_record_fields(), tempest_evidence_span_record_fields(), and a shared tempest_claim_support_record_fields() in R/promotion-types.R:141–188 and R/research-workspace-persistence.R:333–341.
    • Share the 12-element Deputy terminal-status vector and delegation parent-matching helper between R/product-authority.R and R/trajectory-review.R.

Acceptance Criteria

  • Persistence, promotion, workspace, and trajectory-review layers share the consolidated primitives above without changing on-disk schemas, public APIs, or error classes/contracts.
  • All persistence, promotion, authority, and trajectory-review test suites pass with zero regressions.
  • air format --check . passes.
Dominant language
R
Stars
1
Forks
0
Avg merge
19h 6m
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JamesHWade/tempest

All issues in JamesHWade/tempest

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.