B2: on every branch-moved of a watched branch, and at its start for every watched branch's head, the bridge reads the head through the seat git's verb branch, as a kept call that waits on the holder's return while the branch is watched, and writes one head-moved (repository, branch, head, before the head held in its state heads, start) on its stream forge; a head equal to the one held writes nothing. It reads no pull request, no tree, no file and no protection: the merged and pushed messages, their inputs and the state inputs, the call of git.pull, the finding branch-unprotected with its held finding writer, and the ten-second redelivery go. A move whose head cannot be read is left unacknowledged for the bus to deliver again. B3: the pull-message path (Convert, the open pull requests at start and reconnect, the forge-delete message), the groups (internal/groups' group part, forge.group.merged, end-asks, bridge_groups, bridge_group_end_again), bridge_merged_message with the forge-made reader, the checker's owed and the merge act of a switched key (with the switch's bookkeeping read) go, with their consumes, invokes, states and requires. The gate's owed path stays (H-A-71), its catch-up from the gate's verb groups gone with that verb. The two meet in main.go and the package compiles only with both, as it did not since B1. The unit suites pass; the whole test (integration) is rewritten in B4. Builds: design 47 H §739, §764 (the forge bridge; the branch protection); lead answers H-A-23, H-A-27, H-A-48, H-A-71 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
53 lines
2.0 KiB
Go
53 lines
2.0 KiB
Go
package bridge
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
|
|
git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git"
|
|
)
|
|
|
|
// Caller calls a seat's verb by its manifest key (`seat:<seat>.<verb>`) with a JSON body and returns its answer: the
|
|
// bridge's process calls through the bus as its own principal, its tools bundle through the runtime (stdio.Ask).
|
|
type Caller func(ctx context.Context, key string, body any) (json.RawMessage, error)
|
|
|
|
// GitKey is the manifest key of a verb of the seat `git` (novox/hq design 47 *The seat `git`*): the bridge reaches the
|
|
// forge through the seat alone and names no module that holds it.
|
|
func GitKey(verb string) string { return "seat:" + git.Seat + "." + verb }
|
|
|
|
// askGit calls one verb of the seat `git` and decodes its answer into A. An answer the contract cannot type, or one
|
|
// that says an error, is the call's error: a failed read is never read as none (design 47 *A failed read answers an
|
|
// error*).
|
|
func askGit[A any](ctx context.Context, call Caller, verb string, in any) (A, error) {
|
|
var a A
|
|
raw, err := call(ctx, GitKey(verb), in)
|
|
if err != nil {
|
|
return a, fmt.Errorf("the seat git did not answer %s: %w", verb, err)
|
|
}
|
|
if err := json.Unmarshal(raw, &a); err != nil {
|
|
return a, fmt.Errorf("the seat git's answer of %s is not its contract's: %w", verb, err)
|
|
}
|
|
var said struct {
|
|
Error string `json:"error"`
|
|
}
|
|
_ = json.Unmarshal(raw, &said)
|
|
if said.Error != "" {
|
|
return a, fmt.Errorf("the seat git refused %s: %s", verb, said.Error)
|
|
}
|
|
return a, nil
|
|
}
|
|
|
|
// repository is `<owner>/<name>`, as the seat names a repository.
|
|
func repository(owner, repo string) string { return owner + "/" + repo }
|
|
|
|
// splitRepository is a `<owner>/<name>` cut in two, refusing anything else.
|
|
func splitRepository(repository string) (string, string, error) {
|
|
owner, name, ok := strings.Cut(strings.TrimSpace(repository), "/")
|
|
if !ok || owner == "" || name == "" || strings.Contains(name, "/") {
|
|
return "", "", fmt.Errorf("repository %q is not <owner>/<name>", repository)
|
|
}
|
|
return owner, name, nil
|
|
}
|