The operator, 2026-11-04: logic one module owns lives inside that module as a package of its own, so the take-in step changes no mesh-sdk. TakeIn, its keys and event names, PendingWait and PendingAnswer move to modules/mesh-delivery-indexer/takein (its merges a takein.Merge of its own); Forge whole, with its group fields, ForgeGroupEnd and GroupMerge, moves to modules/mesh-delivery-forge-bridge/forgemsg. Both are nested Go modules that their readers take by replace, as buildrun is. Every importer moves in this commit: the indexer, the bridge, the watchman and the view. Forge's private checks (the repository name, the version) are copied small; mesh-sdk main still holds an unused Forge until its own fold removes it. The indexer, bridge, watchman, view and checker pin mesh-sdk 5a38a12 (origin/main), no feat/take-in commit. The bridge's integration bus now grants the state end-asks that bridge_group_end_again added: without it every test of the package failed on a permissions violation. Test budget: two new test functions (TestForge, TestTakeInEvents) and the two the join added are paid by merging four pairs in internal/bridge; the repository stays at 806 unit tests. Claude-Session: https://claude.ai/code/session_01JG73KG7AfSdh6FP8VrBqCn
83 lines
2.7 KiB
Go
83 lines
2.7 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"path"
|
|
"strings"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg"
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// From R4e the indexer lists a repository's modules from what it holds itself (novox/hq ADR 0501 clause 6, issue 1851):
|
|
// a merged message's manifests name the modules of the merge, and the modules bucket names the modules it wrote before,
|
|
// with their repository and directory. The controller's build records name none of them (ADR 0453 clause 5 keeps only
|
|
// the builder's own input from them until R4g, builds.go).
|
|
|
|
// manifestModule is the module a manifest names itself (its `module`), or "" when it names none or is not JSON. Only the
|
|
// name is read here; the manifest is read whole by the catalogue's parser (inputs.go).
|
|
func manifestModule(raw string) string {
|
|
var m struct {
|
|
Module string `json:"module"`
|
|
}
|
|
if json.Unmarshal([]byte(raw), &m) != nil {
|
|
return ""
|
|
}
|
|
return m.Module
|
|
}
|
|
|
|
// heldModules are the values the modules bucket holds, by key (the module's name). A value that is not a module is left
|
|
// out and said.
|
|
func (ix *Indexer) heldModules(ctx context.Context) (map[string]delivery.Module, error) {
|
|
out := map[string]delivery.Module{}
|
|
if ix.Modules == nil {
|
|
return out, nil
|
|
}
|
|
keys, err := ix.Modules.Keys(ctx)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("listing the modules: %w", err)
|
|
}
|
|
for _, key := range keys {
|
|
value, _, found, err := ix.Modules.Get(ctx, key)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("modules.%s: %w", key, err)
|
|
}
|
|
if !found {
|
|
continue
|
|
}
|
|
m, err := delivery.DecodeModule(value)
|
|
if err != nil {
|
|
ix.logf("modules.%s holds what is not a module, left: %v", key, err)
|
|
continue
|
|
}
|
|
out[key] = m
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// moduleAt is the module whose directory in the repository is dir, as the modules bucket holds it.
|
|
func moduleAt(held map[string]delivery.Module, repository, dir string) (string, bool) {
|
|
want := pathOf(strings.Trim(dir, "/"))
|
|
for name, m := range held {
|
|
if m.Path == want && delivery.SameRepository(m.Repository, repository) {
|
|
return name, true
|
|
}
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
// moduleOfDir is the module of a changed directory of a pull request: the module its manifest in the message names, else
|
|
// the one the modules bucket holds at that directory of the repository, else the directory's last element (the
|
|
// catalogue's rule for nearly every manifest).
|
|
func moduleOfDir(held map[string]delivery.Module, f forgemsg.Forge, dir string) string {
|
|
if name := manifestModule(f.Manifests[dir]); name != "" {
|
|
return name
|
|
}
|
|
if name, ok := moduleAt(held, f.Repository, dir); ok {
|
|
return name
|
|
}
|
|
return path.Base(strings.Trim(dir, "/"))
|
|
}
|