Skip to content

feat(vcs): KG versioning + merge — ADR-042/043, khive-vcs + khive-merge crates, frontend design (#1, #2)#82

Merged
ohdearquant merged 5 commits into
mainfrom
show/unimpl-adr-sweep/khive-versioning-adr
May 20, 2026
Merged

feat(vcs): KG versioning + merge — ADR-042/043, khive-vcs + khive-merge crates, frontend design (#1, #2)#82
ohdearquant merged 5 commits into
mainfrom
show/unimpl-adr-sweep/khive-versioning-adr

Conversation

@ohdearquant
Copy link
Copy Markdown
Owner

Summary

Full KG versioning system: ADR design + Rust implementation + frontend design.

Addresses #1 (KG merge) and #2 (KG versioning).

Phase 1 — ADR Design

ADR-042 (KG Versioning Implementation): SHA-256 canonical hashing, split storage tables (kg_snapshots / kg_snapshot_archives), khive-vcs crate boundary, remote push/pull protocol (fast-forward-only push), format = 'full'/'delta' for future delta migration, FTS5-sync + vector-async checkout.

ADR-043 (KG Merge Algorithm): LCA algorithm (O(D) HashSet walk), diff-to-merge rules for all 12 entity-change + 12 edge-change categories, field-level property merge (per-key analysis, name/kind always conflict, description ours-wins, tags union), MergeConflict enum with 6 variants, last-write-wins strategies.

Phase 2 — Rust Implementation (2 new crates, 40 tests)

crates/khive-vcs/ (8 modules):

  • types.rsSnapshotId, KgSnapshot, KgBranch, RemoteConfig, VcsState
  • hash.rs — deterministic canonical JSON + SHA-256 snapshot hashing
  • snapshot.rscommit(), load_archive(), load_vcs_state()
  • branch.rs — create/list/get/checkout
  • log.rs — history traversal, ancestor_ids()
  • merge_engine.rsMergeEngine trait + NoOpMergeEngine
  • migrations.rs — DDL for VCS tables
  • error.rs — 13 error variants

crates/khive-merge/ (6 modules):

  • diff_local.rs — entity/edge diffing
  • lca.rs — lowest common ancestor via HashSet ancestry walk
  • entity.rs — 12-category entity merge + field-level property merge
  • edge.rs — edge merge + dangling edge validation
  • strategy.rs — ours/theirs/last-write-wins
  • merge.rsthree_way_merge() orchestrator

Phase 3 — Frontend Design

docs/design/kg-versioning-frontend.md: 4 screens (Branch DAG via React Flow + ELK, diff viewer, merge conflict resolution UI, snapshot timeline), TypeScript type mirrors, VcsContext state architecture, accessibility requirements.

Test plan

  • 40 tests pass across both crates
  • cargo clippy — clean
  • cargo fmt --check — clean
  • codex-pr-review

Closes #1, closes #2

Generated with Claude Code

ohdearquant and others added 5 commits May 19, 2026 23:37
…rge algorithm

ADR-042 specifies the khive-vcs crate: SHA-256 content-addressed snapshots,
pointer-style branch model, dirty-flag tracking, FTS5-sync/vector-async checkout,
HTTP remote push/pull protocol, and the delta storage migration path.

ADR-043 specifies the khive-merge crate: three-way merge with LCA ancestry walk,
entity and edge categorization, field-level property merge, structured MergeConflict
enum (NameConflict, KindConflict, PropertyMismatch, ModifyDelete, DanglingEdge),
and MergeStrategy shortcuts (Ours/Theirs/Auto).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… ADR-043)

khive-vcs: SHA-256 content-addressed snapshot hashing (canonical JSON), KgSnapshot
and KgBranch types, commit/branch/checkout/log operations, MergeEngine trait with
NoOpMergeEngine stub, SQL migrations for kg_snapshots/kg_branches/kg_vcs_state.

khive-merge: ThreeWayMergeEngine implementing MergeEngine, LCA ancestry walk (O(D)
HashSet algorithm), entity categorization (12 change categories) with field-level
property/name/kind/tag merge, edge categorization with dangling-edge validation,
Ours/Theirs last-write-wins strategy shortcuts.

40 tests pass. cargo check clean on both crates.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Specifies four UI surfaces for the Next.js 15 + React 19 scaffold (PR #25):
Branch DAG view (React Flow), diff viewer (side-by-side entity/edge changes),
merge conflict resolution UI (structured conflict cards with resolution actions),
and snapshot timeline (virtualized list).

Includes TypeScript type mirroring of Rust VCS types, VcsContext state architecture,
accessibility requirements, and open questions for v0.2.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…t, NaN reject

F1: Make SnapshotId inner field private to enforce invariant.
F2: sort_properties_value now recurses into nested objects and arrays.
F3: NaN/Inf edge weights panic instead of silently mapping to 0.
F8: cargo fmt applied.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ohdearquant ohdearquant merged commit b843f73 into main May 20, 2026
0 of 3 checks passed
@ohdearquant ohdearquant deleted the show/unimpl-adr-sweep/khive-versioning-adr branch May 25, 2026 04:42
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.

KG versioning: snapshots, branches, and remotes KG merge: combine two graph states with conflict detection

1 participant