Skip to content

Build durable Pantry committed-state transactions - #114

Open
fproulx-boostsecurity wants to merge 2 commits into
plan/analysis-ingestion-implementationfrom
modernize/analysis-committed-state
Open

Build durable Pantry committed-state transactions#114
fproulx-boostsecurity wants to merge 2 commits into
plan/analysis-ingestion-implementationfrom
modernize/analysis-committed-state

Conversation

@fproulx-boostsecurity

Copy link
Copy Markdown
Contributor

Closes #107

Summary

  • introduce the durable Pantry CommittedState boundary with monotonic revisions and typed granular or committed-state changes
  • persist one validated schema 3.0 snapshot before swapping the stable live Pantry and publishing exactly one observer change
  • route analysis replacement, metadata synchronization, purge, and known-entity writes through the committed boundary
  • replace the legacy five-callback observer and shutdown-time SavePantry paths, and adapt GraphHub batching to the new ChangeSet contract
  • add rollback, cancellation, concurrency, durability, defensive-copy, GraphHub, and large-graph coverage

Stack

This PR is stacked on #113 and targets plan/analysis-ingestion-implementation. It should be reviewed and merged by the maintainers in stack order.

Verification

  • go test -race ./internal/pantry ./internal/kitchen/db ./internal/kitchen
  • make test
  • make lint
  • synthetic benchmark: 1,000 assets about 8.94 ms; 10,000 assets about 85.07 ms

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a persistence-first pantry.CommittedState transaction boundary that commits exactly one durable snapshot per logical write, advances a monotonic Pantry revision, and publishes a single typed ChangeSet to observers. It updates Kitchen write paths (analysis import, purge, known-entity upsert, metadata sync) to route through this committed boundary, upgrades schema to 3.0, and adapts GraphHub to consume the new change stream.

Changes:

  • Added CommittedState with snapshot validation, serialization, atomic persistence, stable live-state replacement, and typed ChangeSet publication.
  • Replaced Pantry mutation-time versioning/observer callbacks with committed revisions, snapshot-based serialization, and defensive-copy semantics for returned graph data.
  • Updated Kitchen handlers, GraphHub, and DB persistence adapter to use the committed snapshot store and revision-based graph versioning (schema 3.0).

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/pantry/observer.go Consolidates observer callbacks into a single OnPantryChange(ChangeSet) notification path.
internal/pantry/graph.go Adds revision tracking, snapshot-based JSON (un)marshal, defensive-copy helpers, and committed writer gate + live replacement.
internal/pantry/graph_test.go Removes legacy observer-behavior tests; keeps graph/property behaviors.
internal/pantry/filter.go Propagates committed revision into derived subgraphs.
internal/pantry/committed_state.go Implements durable committed-state transactions with snapshot diffing + publication contract.
internal/pantry/committed_state_test.go Adds coverage for durability, rollback, cancellation, concurrency, defensive copy, and large-graph scenarios.
internal/kitchen/server.go Removes shutdown-time best-effort Pantry save path.
internal/kitchen/purge.go Routes purge mutations through committed Pantry updates with request context.
internal/kitchen/purge_test.go Verifies purge commits a revision and persists the committed snapshot.
internal/kitchen/handlers.go Adds cached committed-state wiring and replaces SavePantry with committed snapshot persistence.
internal/kitchen/graph.go Switches graph snapshot versioning from Version() to committed Revision().
internal/kitchen/graph_ws.go Updates websocket payload version types from int64 to uint64.
internal/kitchen/graph_hub.go Adapts hub to ChangeSet (granular deltas vs committed-state marker snapshots).
internal/kitchen/graph_hub_test.go Adds tests validating ChangeSet translation and committed-state marker behavior.
internal/kitchen/db/schema_test.go Adds rejection test for schema 2.x with purge guidance messaging.
internal/kitchen/db/pantry.go Replaces SavePantry with PantrySnapshotStore and copies bbolt bytes defensively on load.
internal/kitchen/db/pantry_test.go Adds tests for persisted revision re-open and snapshot-store byte ownership.
internal/kitchen/db/db.go Bumps Kitchen schema to 3.0.
internal/kitchen/committed_pantry_test.go Validates Kitchen routes known-repo writes through committed Pantry and restores revision on restart.
internal/kitchen/analyze.go Commits analysis graph replacement via CommittedState.Replace and commits metadata sync updates via Update.
internal/kitchen/analyze_test.go Updates tests to use committed paths and asserts revision persistence.
internal/kitchen/analyze_perf_test.go Updates perf harness to measure committed import/inventory paths instead of legacy save.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/kitchen/graph_hub.go
Comment thread internal/pantry/graph.go
Comment thread internal/pantry/observer.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comment thread internal/pantry/graph.go
Comment thread internal/pantry/committed_state_test.go
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