lore-server: Implement the thin-client ContentDiff RPC (2-way)#138
Open
bclarke123 wants to merge 1 commit into
Open
lore-server: Implement the thin-client ContentDiff RPC (2-way)#138bclarke123 wants to merge 1 commit into
bclarke123 wants to merge 1 commit into
Conversation
Signed-off-by: Ben Clarke <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hi, and thank you to everybody who has contributed to Lore!
lore.thin_client.v1.ThinClientService.ContentDiffhas been a stub returningUnimplementedsince the thin-client service was introduced, while itsrequest/response contract is fully specified in
thin_client.proto. This PRimplements the 2-way mode of that documented contract.
Motivation: the thin-client service exists so web UIs and SDKs don't have to
reimplement fragment reassembly and codecs. Today a thin client can learn
that a file changed (
RevisionDiff) but not what changed. Showing adiff requires reassembling both sides client-side, including codecs that
are only practically available server-side. I hit this building a web UI
over Lore; commit/diff views were impossible against a stock server.
No proto changes. This implements the shipped contract as documented:
header-first stream,
binary/truncatedshort-circuit flags,context_lines,max_diff_size, whitespace options, and empty-addressadd/delete semantics.
Changes
lore-server/src/grpc/thinclient/v1/content_diff.rs(new): the handler.Reads both sides by CAS address, classifies text vs binary with
infer_is_diffable_by_slice, produces the unified diff, and streamsheader + UTF-8-safe 64 KiB text chunks. Inputs larger than 16 MiB are
not reassembled: a ranged read of the leading 8 KiB still classifies
them (binary sets
binary: true; text setstruncated: true).lore-server/src/grpc/thinclient/v1/service.rs+mod.rs: replace theUnimplementedstub with the handler; module registration.lore-revision/src/file/diff.rs:build_unified_patchbecomespub(one line + doc comment). The handler deliberately reuses the client
diff pipeline rather than reimplementing it, so server-side diffs are
byte-identical to client-side diffs, including the
whitespace-normalisation-with-original-text behaviour and encoding
handling.
Decisions that deserve reviewer eyes
DiffChange.content_from/content_tocarry the CAS hash without the context half, so the handler builds
hash-only addresses and opts these reads out of
LOCAL_ISOLATION(
no_isolation()) to allow the store'sMatchHashfallback. Access isnot widened: reads stay scoped to the caller's authorized partition,
and the content hash proves the bytes. If you'd rather
DiffChangecarry full
Addresses, that's a wire change I deliberately did notmake here and would be happy to follow up on.
address_baseset isrejected with
Unimplementedand a clear message). Nothing calls ityet, and wiring
merge3_textdeserves its own focused PR.Test plan
test_store_createpattern): modify/add/deleteroundtrips with line-stat and text assertions; binary short-circuit;
max_diff_sizetruncation (stats survive, chunks withheld); >16 MiBbinary input classified via prefix sniff. Test blobs are written with a
non-default context so the hash-only
MatchHashpath is exercised, andone over-cap case covers the ranged prefix read.
cargo test -p lore-server: 755 pass (753 pre-existing + 2 new).cargo test -p lore-revision: unchanged, all pass.cargo clippy -p lore-server -p lore-revision --all-targets -- -D warnings --no-deps: clean.cargo +nightly fmt --all: applied.render, binary files short-circuit, adds/deletes and oversized files
behave per the contract.