Drop the keeper's and config's take-over verbs with the controller's sources
mesh-sdk drops compare, take-over and hand-back from the keeper's and config's seats (ADR 0590): there is no controller to compare with or hand back to. mesh-conditions loses those verbs, its take-over key and asks; mesh-config reads its own sources always and pull-declares is gone; and mesh-hand-acts no longer names the controller's log (issue 1126). Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -136,59 +136,15 @@ type PullDeclaresAnswer struct {
|
||||
Unsaid []string `json:"unsaid,omitempty"`
|
||||
}
|
||||
|
||||
// PullDeclares keeps what a pull request's head declares, from the controller alone, and judges again the values
|
||||
// held for it: a value whose key is declared the same (by digest) and still passes is kept at the new head; any
|
||||
// other is dropped, recorded and raised, and must be proposed again (ADR 0502 clause 6).
|
||||
func (c *Config) PullDeclares(call Call) (*PullDeclaresAnswer, error) {
|
||||
if call.Caller != ControllerCaller {
|
||||
return nil, fmt.Errorf("pull-declares is the controller's: it reads a pull request's manifests and tells "+
|
||||
"mesh-config what the head declares; %s is not the controller", call.Caller)
|
||||
}
|
||||
if sw, err := c.source(); err != nil {
|
||||
return nil, err
|
||||
} else if sw.Source == SourceIndexer {
|
||||
return nil, errors.New("pull-declares is refused: since the take-over mesh-config reads a pull request's config " +
|
||||
"declarations from the indexer's config-candidates (novox/hq ADR 0565 §4)")
|
||||
}
|
||||
if _, _, _, err := parsePull(call.Pull); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
head := strings.TrimSpace(call.Head)
|
||||
if head == "" {
|
||||
return nil, errors.New("name the head the declarations are read at")
|
||||
}
|
||||
raw, err := json.Marshal(call.Declares)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the declarations cannot be read: %v", err)
|
||||
}
|
||||
declares := map[string]map[string]Declaration{}
|
||||
if call.Declares != nil {
|
||||
if err := json.Unmarshal(raw, &declares); err != nil {
|
||||
return nil, fmt.Errorf("declares is the modules' declarations, a key to a declaration for each module: %v", err)
|
||||
}
|
||||
}
|
||||
for m, keys := range declares {
|
||||
if !nodeOrModule.MatchString(m) {
|
||||
return nil, fmt.Errorf("%q is not a module's name", m)
|
||||
}
|
||||
for k, d := range keys {
|
||||
if !keyName.MatchString(k) {
|
||||
return nil, fmt.Errorf("%q is not a config key", k)
|
||||
}
|
||||
if !d.HasDefault() {
|
||||
d.Default = nil
|
||||
}
|
||||
keys[k] = d
|
||||
}
|
||||
}
|
||||
pull := strings.TrimSpace(call.Pull)
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return c.declarePull(pull, head, declares)
|
||||
// PullDeclares is gone: a pull request's config declarations are read from the indexer's config-candidates
|
||||
// (takeCandidates), and the controller that told them is not placed (novox/hq ADR 0565 §4, ADR 0590).
|
||||
func (c *Config) PullDeclares(Call) (*PullDeclaresAnswer, error) {
|
||||
return nil, errors.New("pull-declares is gone: mesh-config reads a pull request's config declarations from the " +
|
||||
"indexer's config-candidates (novox/hq ADR 0565 §4, ADR 0590)")
|
||||
}
|
||||
|
||||
// declarePull keeps what a pull request's head declares and judges again the values held for it; from the
|
||||
// controller's pull-declares, or after the take-over from the indexer's config candidates. The caller holds the lock.
|
||||
// declarePull keeps what a pull request's head declares and judges again the values held for it, from the indexer's
|
||||
// config candidates. The caller holds the lock.
|
||||
func (c *Config) declarePull(pull, head string, declares map[string]map[string]Declaration) (*PullDeclaresAnswer, error) {
|
||||
if err := c.Store.Put(PullsState, pullKey(pull), PullDecl{Pull: pull, Head: head, Declares: declares,
|
||||
At: c.now()}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user