smriti/backend/tests/integration
Himanshu Dongre 2a6614bd80 Add fork, compare, restore CLI commands and fix compare correctness
Round 2 of the agent handoff dogfood showed that every multi-branch
operation required reaching past the CLI into curl: fork had no CLI
command, `smriti checkpoint create` always spawned a fresh session with
no way to attach to a forked one, and the compare endpoint returned
useless output (common_ancestor_commit_id was missing from the response,
and shared-set matching was exact-string so two agents phrasing the
same commitment differently showed zero overlap).

This ships the full CLI surface for multi-branch workflows plus the
backend fixes that make compare actually useful:

  smriti fork <checkpoint-id> [--branch <name>]
  smriti restore <checkpoint-id>
  smriti compare <checkpoint-a> <checkpoint-b>
  smriti checkpoint create <space> --session <session-id>

The compare endpoint now walks parent chains to compute a lowest
common ancestor (bounded to 1000 steps with a cycle guard) and returns
it on CheckpointDiff as an optional uuid. Shared-set matching uses a
lightweight lowercase + punctuation-strip + whitespace-collapse
normalization for keying, but returns the original A-side strings so
the output stays readable. Four new compare tests cover direct and
two-step LCA, null LCA for unrelated checkpoints, and normalized
shared-set matching. Existing compare tests still pass unchanged
because their data ("Use Redis" vs "Use Postgres") is distinct at any
sensible normalization level.

`smriti restore <checkpoint>` is a pure read — it renders any
checkpoint as a continuation brief matching `smriti state <space>`
shape. `smriti fork` derives the space from the checkpoint so the
user does not have to pass it separately. `--session` on checkpoint
create is purely additive: when absent, the existing auto-session
behavior is unchanged.

147/147 backend tests pass (143 pre-existing + 4 new).
2026-04-11 17:50:03 +05:30
..
__init__.py Initial public release 2026-03-22 13:48:50 +05:30
conftest.py Initial public release 2026-03-22 13:48:50 +05:30
test_api_v2_git.py Initial public release 2026-03-22 13:48:50 +05:30
test_api_v4_chat.py Initial public release 2026-03-22 13:48:50 +05:30
test_api_v5_lineage.py Add fork, compare, restore CLI commands and fix compare correctness 2026-04-11 17:50:03 +05:30
test_delete_endpoints.py Add delete endpoints for spaces, checkpoints, and sessions 2026-04-11 17:25:36 +05:30