Skip to content

feat(harness-state): persist content-addressed harness state bundles - #62

Closed
Issacboy123 wants to merge 3 commits into
mainfrom
feat/persist-harness-state
Closed

Issacboy123 wants to merge 3 commits into
mainfrom
feat/persist-harness-state

Conversation

@Issacboy123

@Issacboy123 Issacboy123 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Diffex needs a stable representation for evolvable harness configuration before consumers or evolution workflows can operate on it. This PR adds a private harness-state package that persists the system prompt as a validated portable directory bundle, identifies its exact content with derived SHA-256 metadata, and provides the canonical clean-default state.

Reasoning

Keeping the schema and persistence contract in a dedicated private package gives future consumers one runtime-validated ownership boundary without coupling storage to the coding agent. A content hash identifies and verifies the stored prompt without introducing a numerical schema version that does not represent the harness content. The algorithm-prefixed digest leaves the metadata self-describing, while the strict two-file layout, sibling staging, and final rename keep bundles inspectable and prevent normal saves from exposing partial destinations.

Changes

  • Added the private @diffexai/diffex-harness-state ESM workspace package with strict TypeBox schemas and inferred readonly state and manifest types.
  • Added SHA-256 manifest metadata derived from the exact EVOLVE.md bytes, with automatic generation during saves and verification during loads.
  • Added bundle loading that enforces an exact direct-file layout, fatal BOM-free UTF-8, strict manifest validation, and verbatim system-prompt preservation.
  • Added non-overwriting bundle saves through an owned sibling staging directory, canonical content-hash manifest serialization, a second destination check, final rename, and best-effort staging cleanup on failure.
  • Added a checked-in clean-default bundle and routed default loading through the same validation path as external bundles.
  • Added package documentation and root build, offline-build, type-check path, and lockfile integration without adding publication or runtime-consumer integration.
  • Added focused coverage for schemas, content-hash integrity, default bytes, round trips, invalid encodings and manifests, filesystem layouts, overwrite refusal, cleanup, and partial-destination prevention.

Testing

  • node ../../node_modules/vitest/dist/cli.js --run test/harness-state.test.ts
  • npm run check

@Issacboy123 Issacboy123 added the enhancement New feature or request label Aug 15, 2026
@Issacboy123 Issacboy123 self-assigned this Aug 15, 2026
@Issacboy123
Issacboy123 requested a review from Pepps233 August 15, 2026 23:29
@Issacboy123 Issacboy123 changed the title feat(harness-state): persist version 1 harness state bundles feat(harness-state): persist content-addressed harness state bundles Aug 15, 2026
@Issacboy123
Issacboy123 marked this pull request as ready for review August 15, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant