fix(apply): microsecond-precision LWW + sidecar bump regression test#85
Merged
Conversation
…changed tracked key The apply library updates feed.meta.json whenever an object-form payload carries metadata for a tracked key that survives the LWW gate, even if the canonical value matches on-disk. This is the path that lets apl-feed config sync heal a stuck future timestamp by re-sending the server tuple with the existing value. Pinning the behavior makes the contract explicit so that local webconfig writes can rely on it: webconfig must omit unchanged tracked keys from the payload, otherwise every form save would push fresh edited_at stamps and clobber legitimate concurrent edits under LWW.
iso_now now stamps with microsecond fractional and the normalize helper for LWW compare pads/truncates incoming and on-disk stamps to a fixed-width microsecond form. Without this, two writes to the same tracked key inside one wall-clock-second produced equal post-normalize strings and the strictly-newer LWW rule silently dropped the second one. Matches the server-side merge precision (Python datetime.isoformat()) so symmetric same-second tie semantics hold across the round trip. The existing fractional-second test changes from skip to apply; new tests cover the explicit same-second ordering scenarios and the bare-on-disk pad-for-compare path. The bare-string default-stamp regex in test_feed_env_apply.bats and test_apl_feed_mlat.bats now permits the optional fractional segment.
The LWW normalize pads or truncates incoming and on-disk stamps to microsecond precision. Accepting more than 6 fractional digits at the wire would silently collapse strictly-newer ordering for nanosecond-precision writers, so the schema check in apl-feed apply and the strict regex in feed-env-apply.sh now reject inputs with more than 6 fractional digits.
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.
Two fixes in scripts/lib/feed-env-apply.sh that together pin the metadata contract image-webconfig's DEV-383 work depends on.
iso_now now stamps with microsecond fractional and the normalize helper for LWW compare pads or truncates incoming and on-disk stamps to a fixed-width microsecond form. Without this, two writes to the same tracked key inside one wall-clock-second produced equal post-normalize strings and the strictly-newer LWW rule silently dropped the second one. Matches the server-side merge precision (Python datetime.isoformat()) so same-second tie semantics behave symmetrically across the round trip.
Adds a regression test pinning that an object-form apply payload bumps the feed.meta.json sidecar even when the canonical value matches the on-disk value. This is the path apl-feed config sync uses to heal stuck future timestamps, and image-webconfig now relies on the contrapositive — explicit metadata is load-bearing, so local-writer callers must omit it for unchanged tracked keys.
Addresses DEV-383.