Cut provisioning round-trips: merge working+drafts, add PriorHash cac…#73
Merged
Conversation
…he, embed post-op state
Every provisioning transaction over LoRa pays fixed framing + encryption
+ Link overhead that dominates the actual payload. The webconsole
previously needed 2-3 transactions per user action:
Save = SetState + GetState refresh; Commit = Commit + GetInfo + GetState
refresh; PanelOpen = GetState[working] + GetState[drafts] with a
client-side diff to figure out which fields were drafted. This rework
collapses each flow to a single transaction plus a cache-hit
short-circuit for unchanged state.
- GET_CAPABILITIES returns a namespace map with per-ns schema hashes
(was a bare id array); GET_SCHEMA gains NamespaceFilter. Enables
lazy per-namespace schema loading with content-addressed caching.
- GET_STATE gains Draft (merge drafts into the working response),
PriorHash (server responds { Unchanged: true } on cache hit), and
Hash. Body is now { Values, Drafts?, Hash } instead of the raw
ns->fields map.
- SET_STATE wraps the state map in { State, IncludeState? }; with
IncludeState the response carries PostOpValues + PostOpDrafts +
PostOpHash so Save refreshes in one round-trip.
- COMMIT uses a { NamespaceFilter?, IncludeState? } map (was a bare
array); with IncludeState the response carries PostOpValues +
PostOpHash so Commit refreshes in one round-trip.
Two latent bugs addressed: the "phantom draft from live-metric drift"
that the old double-fetch pattern had to work around client-side
(current_rssi and friends sampled differently between the two calls),
and a Key-namespace collision (Applied=1 vs Values=1) that would have
produced duplicate-key maps in the new commit response — fixed by
giving post-op state distinct slots (PostOpValues=4, PostOpDrafts=5,
PostOpHash=6).
Extract pack_ns_values / pack_ns_drafts helpers so op_get_state,
op_set_state, and op_commit emit byte-identical Values/Drafts sub-maps
— that lets SetState's PostOpHash prime the GetState PriorHash cache.
71/71 provisioning tests pass. Docs: rewrite provisioning_client_guide.md
for the new wire; update provisioning_integration_guide.md
(SCHEMA_VERSION=2, Void field type, schema_hash accessor); CHANGELOG
gains an entry per new mechanism plus migration notes for the wire-
format breaks.
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.
…he, embed post-op state
Every provisioning transaction over LoRa pays fixed framing + encryption
Two latent bugs addressed: the "phantom draft from live-metric drift" that the old double-fetch pattern had to work around client-side (current_rssi and friends sampled differently between the two calls), and a Key-namespace collision (Applied=1 vs Values=1) that would have produced duplicate-key maps in the new commit response — fixed by giving post-op state distinct slots (PostOpValues=4, PostOpDrafts=5, PostOpHash=6).
Extract pack_ns_values / pack_ns_drafts helpers so op_get_state, op_set_state, and op_commit emit byte-identical Values/Drafts sub-maps — that lets SetState's PostOpHash prime the GetState PriorHash cache.
71/71 provisioning tests pass. Docs: rewrite provisioning_client_guide.md for the new wire; update provisioning_integration_guide.md (SCHEMA_VERSION=2, Void field type, schema_hash accessor); CHANGELOG gains an entry per new mechanism plus migration notes for the wire- format breaks.