Skip to content

[ADR-035] Import, Export, Remote Resolver, and Sync #333

@ohdearquant

Description

@ohdearquant

Summary

Implement import/export adapters, remote definition validation, hash/prefix resolution behavior, and sync semantics over the VCS/runtime boundaries.

Source ADRs

  • F195 ADR-035 (CRIT): kkernel sync explicitly disables vectors by setting embedding_model: None, then imports entities through raw upsert_entity without FTS/vector reindexing. (from audit-rest/r5/ADR-035.md)
  • F196 ADR-036 (MAJ): Workspace members list khive-vcs and kkernel through crates/Cargo.toml:24, but there is no khive-vcs-adapters member. (from audit-rest/r4/ADR-036.md)
  • F197 ADR-036 (CRIT): The CLI import contract is khive kg import [--overwrite] [--on-conflict <skip (from audit-rest/r4/ADR-036.md)
  • F198 ADR-036 (MAJ): CSV/TSV and JSON adapters exist as TypeScript functions, but CSV comments state mapping files are a future extension and rg found only definitions of adaptCsv/adaptJson in non-test... (from audit-rest/r4/ADR-036.md)
  • F199 ADR-036 (MAJ): runExport treats --format archive as valid and silently falls through to canonical NDJSON for every other non-archive format. (from audit-rest/r4/ADR-036.md)
  • F200 ADR-037 (CRIT): resolve_uuid_async accepts a full UUID, then an 8+ hex prefix via runtime.resolve_prefix, then falls back to name resolution. (from audit-rest/r4/ADR-037.md)
  • F201 ADR-037 (CRIT): run_sync reads only local .khive/kg/entities.ndjson and edges.ndjson, builds a temp SQLite DB, checkpoints WAL, and renames the temp DB over the target. (from audit-rest/r4/ADR-037.md)
  • F202 ADR-037 (MAJ): kkernel sync accepts only --repo, --db, and --namespace. (from audit-rest/r4/ADR-037.md)
  • F203 ADR-037 (MAJ): Current RemoteDef is { name, repo, path, commit }, and validation requires name, repo, path, and commit. (from audit-rest/r4/ADR-037.md)
  • F204 ADR-037 (MAJ): Runtime errors are generic variants such as NotFound(String), InvalidInput(String), and Ambiguous(String). (from audit-rest/r4/ADR-037.md)

Files affected

  • crates/kkernel/src/sync.rs (386 sampled LOC)
  • crates/Cargo.toml (59 sampled LOC)
  • cli/kg/import.ts (864 sampled LOC)
  • cli/lib/importers/csv.ts (294 sampled LOC)
  • cli/kg/export.ts (283 sampled LOC)
  • crates/khive-pack-kg/src/handlers.rs (1216 sampled LOC)
  • crates/kkernel/src/main.rs (167 sampled LOC)
  • cli/lib/schema.ts (198 sampled LOC)
  • crates/khive-runtime/src/error.rs (125 sampled LOC)
  • crates/khive-vcs-adapters/Cargo.toml (new/planned path)
  • crates/khive-vcs-adapters/src/lib.rs (new/planned path)
  • cli/lib/importers/json.ts (218 sampled LOC)
  • cli/lib/importers/types.ts (26 sampled LOC)
  • cli/main.ts (292 sampled LOC)
  • cli/kg/validate.ts (577 sampled LOC)
  • crates/khive-vcs/src/hash.rs (365 sampled LOC)
  • crates/khive-vcs/src/types.rs (365 sampled LOC)
  • crates/khive-vcs/src/error.rs (93 sampled LOC)
  • cli/lib/kernel.ts (142 sampled LOC)

Acceptance criteria

  • All source findings listed above are addressed exactly once in this cluster.
  • Public types, handlers, schema, and docs touched by the affected files agree on the ADR contract.
  • Regression tests cover happy path and edge cases for the changed public APIs or schema behavior.
  • cargo test -p khive-vcs -p kkernel -p khive-pack-kg passes.
  • cargo clippy --workspace -- -D warnings passes.
  • make ci passes.

Dependencies

  • Depends on: #[ADR-001] Entity Kind and Type Contract
  • Depends on: #[ADR-002] Edge Ontology, Lifecycle, and Bulk Link Semantics
  • Depends on: #[ADR-004] Note Kind, Storage, and Curation Operations
  • Depends on: #[ADR-007] Namespace Token and Runtime API Migration
  • Depends on: #[ADR-003] Runtime Backend and Substrate Coordinator
  • Depends on: #[ADR-010] VCS Git-Native Core and Legacy Removal
  • Depends on: #[ADR-017] Pack Verb Registry, Wire Names, and Introspection
  • Depends on: #[ADR-016] Request Execution Modes and Presentation Envelope
  • Depends on: #[ADR-023] Dynamic Pack Loading, Template, and Pack Binary Inclusion
  • Depends on: #[ADR-011] Retrieval, Embed, and Lattice Boundary
  • Depends on: #[ADR-034] kkernel Engine and Admin Commands
  • Depends on: #[ADR-025] Event-Sourced Proposals
  • Blocks: #[ADR-026] Rust Binary npm Packaging

LOC estimate

~470 lines added/130 removed; 17 existing affected file(s) sampled at 5670 current LOC via wc -l, plus 2 new/planned path(s).

Risk notes

  • Same-file dependencies must merge first; dependency list includes the exact overlapping paths.
  • 2 affected path(s) are new/planned and were not present in rg --files --hidden; create them in the owning PR rather than in independent parallel work.
  • Contains CRIT findings; do not defer without owner approval.

Auto-generated by ADR alignment triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    adr-alignmentADR v1 series alignment workadvancedAdvanced layer (ADR-031..046)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions