Repository navigation
Give the S3 sync plan a domain model with named rules - #4902
Merged
Merged
Conversation
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4902/ |
This was referenced Nov 18, 2026
The plan's numbers become a SyncPlanCounts record whose three rules replace the checks inside DocsSyncPlanValidator, and the planner's classification of files moves into the pure SyncPlanner.Compute. The verdict, the log lines and the plan file stay the same. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AutoTest runs every rule over generated legal plans and proves each rule can fire. A second generator adds partial listings, empty builds, negative, zero and huge counts and NaN or infinite thresholds, and checks that no rule, ratio or threshold throws. It found no defect: the rules behave as main's validator does, including a NaN threshold that never rejects a plan. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Mpdreamz
force-pushed
the
split/15-sync-plan
branch
from
November 27, 2026 11:25
5685b76 to
d5f0362
Compare
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A negative source file count passes as on main, where only zero is rejected. The validator logs each finding with its old template and its Ratio and Threshold arguments. The planner reads a remote ETag only when it compares an included local file, with no second index of the bucket. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The scenario headings used the platform line ending, so the transcript test failed on Windows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
The S3 sync plan's validity checks become named rules on a domain record, and the planner's file classification becomes a pure function. The deploy verdict, its log lines and the plan JSON stay the same.
Affects: Internals only
Stack: 15 of 16 in the split of #4530, on top of the foundation #4888.
Why
DocsSyncPlanValidatorholds the deploy safety rules (complete listing, non-empty build, delete ratio against a size-dependent threshold) as nestedifstatements next to the logging.AwsS3SyncPlanStrategymixes the S3 and file system calls with the add, update, skip and delete decision. Neither can be tested without the other.What
Rules in the domain
SyncPlanCounts(inElastic.Documentation.Sync) holds what the checks read: the listing flag, source and remote file counts and the delete count. It owns the threshold logic (the user value or 0.2, at least 0.8 up to 100 remote files, at least 0.5 up to 1,000, 0 for an empty bucket).SyncPlanCountsConstraintsdeclares the three error rules.Validator
DocsSyncPlanValidator.Validate(SyncPlan)reads the findings of the rules throughCheck. It keeps the old order: an incomplete listing or an empty build stops at its own message, otherwise the threshold reason is logged and a delete ratio over the threshold is an error. Messages, results and log calls are unchanged: each finding keeps its old message template and, for the delete ratio, theRatioandThresholdarguments.SyncPlan.Countsis the new[JsonIgnore]view; the wire format is untouched.Deployingnow referencesConfiguration, which opens its internals toDeployingforCheck.Planner
SyncPlanner.Computeclassifies local files and remote keys into add, update, skip and delete.AwsS3SyncPlanStrategylists, hashes and calls it. ETags are still computed only for files that are also remote, and a remote ETag is read (and its quotes trimmed) only when an included local file is compared with it; the listing is used as it is. The add, update and skip lists now follow file order. They used to follow the order a concurrent bag returned, which was nondeterministic, so no stable behaviour changes. No exception is turned into a finding: the rules run throughCheck, which does not catch.Tests
Rule and threshold tests, and CsCheck laws for the planner (the four lists partition the inputs, planning after applying is empty, deletes are remote-only and not excluded, listing order does not matter) and for the threshold and verdict.
Deferred behaviour changes
total_sync_requestsmust be add + update + delete (P36 in Model the domain as typed records with named, tested rules #4530, a warning that fires for every plan that has skipped files).SyncPlanLoader: reading a plan file through a loader that reports a malformed plan as a diagnostic.Applystill throws on malformed JSON, as before.SyncPlan.Deserialize) staying internal, andRetainedPathshaving an internal setter.total_source_files: main rejects only zero, so a negative count still passes the file check (the rule is!= 0). A stricter rule is a later change.Verify
No verified snapshot changed. Golden site build compare skipped: deploy tooling only, no site build path changes.
🤖 Generated with Claude Code
Found by generated data
Nothing: no rule, ratio or threshold throws on hostile counts. One observation, identical to main: a NaN threshold never rejects a plan (pinned by
ANanThreshold_NeverRejectsADeletion).