feat(runs): add settings merge engine - #7925
Merged
Merged
Conversation
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
…urces Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
davidlin20dev
force-pushed
the
feat/settings-merge
branch
from
August 27, 2026 03:21
87924cf to
928989c
Compare
3 tasks
popojk
reviewed
Aug 27, 2026
popojk
left a comment
Contributor
There was a problem hiding this comment.
mergeString/Int64/Bool/Quantity looks similiar, can we do it in an abstract method? Something like:
type scalarSetting interface {
proto.Message
GetState() settings.SettingState
}
func mergeScalar[T scalarSetting](levels []T, setLevel func(T, settings.ScopeLevel)) T {
var out T
won := -1
for i, s := range levels {
if s.GetState() != settings.SettingState_SETTING_STATE_INHERIT {
won = i
}
}
if won < 0 {
return out // typed nil
}
out = proto.Clone(levels[won]).(T)
setLevel(out, scopeLevelAt(won))
return out
}
popojk
reviewed
Aug 27, 2026
| ) | ||
|
|
||
| // scopeLevelAt maps a position in the level chain to the scope it represents. | ||
| // Callers build the chain broadest first: instance, domain, project. |
Contributor
There was a problem hiding this comment.
nit: should we say org i/o instance?
Suggested change
| // Callers build the chain broadest first: instance, domain, project. | |
| // Callers build the chain broadest first: org, domain, project. |
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Contributor
Author
|
@popojk Thanks for the review. Good call! I just updated it, ready for another look. |
This was referenced Aug 31, 2026
3 tasks
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.
Tracking issue
Related to #7775. This is task 2.2 (merge engine).
Why are the changes needed?
Settings are stored one row per scope, so answering "what applies to this project?" means resolving up to three rows into one document. Nothing does that yet, which is why
GetSettingsstill returnsUnimplementedand why no Phase 3 applier can start.What changes were proposed in this pull request?
Pure resolution functions in
runs/service/settings_merge.go, following the rules in the RFC:INHERITwins, soUNSETat a child level blocks a value set above itUNSETclears everything accumulated above itscope_levelit came frommergeSettingsis the only entry point. The rest are either leaf mergers, which hold the rules, or group mergers, which only regroup fields by level and delegate. Groups that no level configured resolve to nil, so the merged document carries no empty objects.Nothing calls this yet. The
GetSettingshandler is the other half of task 2.5 and comes in a follow-up.One point the RFC leaves open: it says to annotate the winner with its scope level, which is unambiguous for a scalar but not for a map assembled from several levels. Here a merged map records the most specific level that contributed. Per-entry origins remain available from
GetSettingsForEdit.How was this patch tested?
Table tests with no database, since the functions are pure. Every
SettingStateappears at every position in the chain, and the map table covers accumulation, child override,UNSETclearing, and a level belowUNSETrefilling the map. There is also a test that fails if a field is added to theSettingsproto without being handled inmergeSettings.Labels
Check all the applicable boxes
Related PRs
Follows #7841, #7859 and #7881. Stacked on #7900.