Documentation
¶
Overview ¶
Package dispatch is the `m` busybox's sibling-binary dispatcher (spec §2.2, tracker [N12]). `m` keeps its native subcommands (fmt/lint/lsp/test/coverage/ watch) and forwards the rest to standalone sibling binaries — keeping each sibling's own SBOM and release cadence (a small attestable family, ADR §5) rather than one mixed-dep blob. Two dispatch shapes are supported:
- flat: one `m` verb maps to the sibling command of the same name (`m pull` → `irissync pull`).
- group: one `m` verb forwards the remaining args verbatim to the sibling (`m kids decompose x.KID` → `kids-vc decompose x.KID`).
Discovery, exit-code forwarding, and schema aggregation are all deterministic (the §3.3 ladder) so agents and CI compose `m` exactly as they compose the siblings directly.
Index ¶
- Variables
- func Aggregate(ctx context.Context, doc clikit.SchemaDoc) clikit.SchemaDoc
- func Resolve(binary string) (string, error)
- func Run(ctx context.Context, spec Spec, globals, args []string, stdin io.Reader, ...) (int, error)
- func SiblingSchema(ctx context.Context, binary string) (clikit.SchemaDoc, error)
- func Verbs() []string
- type Spec
Constants ¶
This section is empty.
Variables ¶
var Registry = []Spec{ {Verb: "list", Binary: "irissync"}, {Verb: "pull", Binary: "irissync"}, {Verb: "status", Binary: "irissync"}, {Verb: "verify", Binary: "irissync"}, {Verb: "push", Binary: "irissync"}, {Verb: "kids", Binary: "kids-vc", Group: true}, }
Registry is the active dispatch table.
Extension point (the deferred 2.2 `m meta` hook, tracker [N14]): to front vista-meta as `m meta …`, append a flat-or-group Spec here once that binary exists — e.g. {Verb: "meta", Binary: "vista-meta", Group: true}. No other change is needed: discovery, forwarding, and `m schema` aggregation all key off this slice. Likewise for `m mcp` → m-dev-tools-mcp (5.2). Nothing is wired for either today, by design.
Functions ¶
func Aggregate ¶
Aggregate merges each available sibling's sub-schema into doc so an agent sees one tree (spec §2.2). For each registered namespace it execs `<binary> schema`, then grafts the sibling's commands in place of the native stub: a flat verb keeps its top-level path; a group's subcommands attach under [verb …]. A sibling that can't be resolved (e.g. the CI schema-contract runs with no siblings present) or whose schema can't be read is left as its stub, so the output is always valid JSON and every namespace stays discoverable.
func Resolve ¶
Resolve locates a sibling binary: the M_<NAME>_BIN override first, then alongside the running `m`, then $PATH. A miss is a deterministic error, never a panic or a raw exec failure.
func Run ¶
func Run(ctx context.Context, spec Spec, globals, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)
Run resolves spec.Binary and execs it, forwarding the resolved global flags, the sibling subcommand (for a flat verb), and the user's args, with the child inheriting the given stdio. It returns the child's exit code faithfully, or a deterministic *clikit.Error when the binary can't be resolved or spawned.
func SiblingSchema ¶
SiblingSchema resolves a binary and returns its reflected schema.
Types ¶
type Spec ¶
type Spec struct {
// Verb is the `m` subcommand token (e.g. "pull", "kids").
Verb string
// Binary is the sibling executable name (e.g. "irissync", "kids-vc").
Binary string
// Group is false for a flat verb (the verb is the sibling subcommand) and
// true for a group (the forwarded args carry the sibling subcommand).
Group bool
}
Spec describes one dispatched sibling namespace.