Skip to content

feat: FileStore, Store interface, config file, and content hashing#1

Merged
lbsa71 merged 1 commit intomainfrom
feat/file-store-and-config
Jan 31, 2026
Merged

feat: FileStore, Store interface, config file, and content hashing#1
lbsa71 merged 1 commit intomainfrom
feat/file-store-and-config

Conversation

@rookdaemon
Copy link
Collaborator

Changes

1. Store Interface

Extracted a Store interface in types.ts that both GranuleStore (in-memory) and FileStore implement. Updated Orchestrator and server.ts to accept Store instead of concrete GranuleStore.

2. FileStore (persistent backend)

New src/file-store.ts — drop-in replacement that persists to a JSON file on every mutation. Uses atomic writes (temp file + rename) to avoid corruption. Loads existing state on construction. Default path: .granules-state.json.

3. Config file support

.granules.json in cwd is loaded automatically. Supports store, stateFile, port, maxWorkers. CLI flags (--store, --state-file, --port, --max-workers) override config. No config = same behavior as before.

4. Spec SHA watermarking

Added contentHash (SHA-256) field to Granule type, computed on creation. Added updateGranuleContent method to update content and recompute hash.

5. Tests

Comprehensive tests for FileStore: persistence, reload, atomic writes, contentHash computation. All 90 tests pass.

…t hashing

- Extract Store interface in types.ts for both in-memory and persistent stores
- Add FileStore (file-backed store with atomic writes via temp+rename)
- Add .granules.json config file support with CLI flag overrides
- Add contentHash (SHA-256) field to Granule type, computed on creation
- Add updateGranuleContent method to Store interface
- Update Orchestrator and server to accept Store interface
- Add comprehensive tests for FileStore and contentHash
@rookdaemon rookdaemon requested a review from lbsa71 January 31, 2026 14:12
@lbsa71 lbsa71 merged commit ff6d331 into main Jan 31, 2026
2 checks passed
@lbsa71 lbsa71 deleted the feat/file-store-and-config branch January 31, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants