Skip to content

feat(op): the broker's client interface: Exec and Post by account, the console and events streams, commands by run id, and its test double - #1140

Merged
David-Noble-at-work merged 5 commits into
developfrom
feature/1129-broker-client-interface
Oct 23, 2026
Merged

David-Noble-at-work merged 5 commits into
developfrom
feature/1129-broker-client-interface

Conversation

@David-Noble-at-work

@David-Noble-at-work David-Noble-at-work commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lane 1 of schedule #1127: the broker's client interface, 2.7's wire with no wire, fixed in iteration 1 and never moved.

  • op.Broker, pkg/op/broker.go: Exec and Post by account, answering with an exec id or the named Refusal a caller errors.As; Cancel; Console and Events as per-run subscriptions, a channel and a cancel each, one seq per run per stream; Command and Status by run id. ExecRequest is 6.2 § 7's request with 2.7's routing, argv or script, never a string; Stdin is the word auto_confirm or {"bytes"}; PostRequest is the posted unit plan.logon dispatches, ruled on the interface now.
  • The console frames, pkg/op/broker_console.go: narration, output, control as strings, one payload each, Data() rendering the SSE data: field. broker_test.go pins the request and frame JSON to 2.7 § Message reference and § The wire, in detail, byte for byte, so iteration 2's facade carries them unchanged.
  • op.RecordingBroker, pkg/op/broker_double.go: the test double in a non-test file; records every call, delivers what a test enqueues with the per-run seq, refuses an account on request. Every package above the interface tests against it without a broker.
  • 2.7's status companion records the interface as landed; the plan docs/plans/task/1129-broker-client-interface.md is complete. Nothing behind the interface is built here: that is The in-process stub: the caller's account through pkg/process, root through one sudo -n behind the interface #1130 and The console stream never drops a frame: a slow subscriber receives every one, late, and the child is never blocked on it #1131.

Test plan

  • make check passes: the quality gate and every test, after the four lint findings its first run reported were fixed
  • Twelve tests in pkg/op: the JSON pins, validation, the refusal, the double's order, seq, cancel and drop

Resolves #1129.

Written with AI assistance.

Signed-off-by: David Noble [email protected]
Assisted-by: Claude Code

Time

Marker UTC Elapsed
opened (first commit) 2026-10-22T21:06:39Z —
submitted (PR opened) 2026-10-23T00:24:46Z 3.3 h after opened
merged 2026-10-23T00:44:38Z 0.3 h after submitted; 3.6 h in all

Computed by the algorithm of noblefactor-ops#188 at merge.

…ncel, Console and Events per run, Command and Status by run id (#1129)

pkg/op/broker.go is 2.7's wire with no wire: the Broker interface, ExecRequest and PostRequest with the wire's JSON
tags, Stdin as the word auto_confirm or {"bytes"}, Script, and Refusal, the named policy failure a caller errors.As.
pkg/op/broker_console.go is the console stream's frame: narration, output and control as strings, one payload each,
Data() rendering the SSE data field, and the three constructors. broker_test.go pins the request and frame JSON to
2.7 § Message reference and § The wire, in detail, byte for byte.
…, delivers what a test enqueues with the per-run seq (#1129)

A non-test file, so every package above the interface tests against it without a broker. Deliver and Emit stamp the
run's console and events seq and fan out as the control plane does, a full subscriber missing a frame rather than
blocking; Refuse makes an account fail with its Refusal; SetStatus makes a run known to Command and Status. Its test
proves the order, the seq per run and per stream, the cancel, the refusal and the unknown run.
@David-Noble-at-work
David-Noble-at-work merged commit 51bea7d into develop Oct 23, 2026
21 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the feature/1129-broker-client-interface branch October 23, 2026 00:44
David-Noble-at-work added a commit that referenced this pull request Oct 23, 2026
… through one sudo -n, the platform and the shell provider through it (#1143)

## Summary

Lane 2 of schedule #1127: the broker in the app's process, behind the interface #1140 landed.

- **`op.InProcessBroker`**, `pkg/op/broker_stub.go`: a `Broker` that forks commands from the app's process. The caller's account runs through `pkg/process`, the direct path of 2.7, kept; root runs through one `sudo -n`, the only place the word now exists in `pkg`, retired in iteration 3; any other account is a named `Refusal`; `Post` is refused until the logon lane. Frames reach the console as the child speaks, through `process.Runner.Stream`, the relay with callbacks; `Cancel` kills the child; `Track` is the run registry `Command` and `Status` answer from. `op.Run` is the synchronous collect every provider needs. The runtime environment carries a `Broker`, the in-process one by default.
- **`pkg/platform`** takes a `CommandRunner` through its spec; `New` hands it to every leaf and the service manager through the `commander` they embed. Seventy call sites say `root` or `caller` where a boolean said sudo; `runCommand` and `helpers_unix.go` are deleted; `grep -rn sudo pkg/platform` finds nothing. `LocalRunner` is the default for a platform built outside a runtime environment, the caller alone. `op.PlatformRunner` is the broker's adapter the environment builds its detected platform with.
- **The shell provider** runs through the broker, a caller script of dialect `sh`, never a string to `-c`. The pkg and service providers change nothing and now run through the broker by way of their platform.
- 6.2 § 10's interim row names the broker; 2.7's status companion says it landed. The plan `docs/plans/task/1130-in-process-stub.md` is `active`: Phase 6 after the merge is `make install` and a `writ deploy` from an unprivileged shell on Media-Server.

Two things to judge: every manager command now narrates its audit line, `$ brew info foo`, through the process runner, where the old runner printed nothing; and frames are live from this lane, which leaves #1131 the never-dropping spool and the event sink.

## Test plan

- [x] `make check` passes: the quality gate and every test, on the committed tree
- [x] 25 new tests across `pkg/op`, `pkg/platform` and the shell provider: the three accounts, the script tier with an injection attempt that arrives as text, stdin, env and cwd, auto-confirm, dry-run, cancel, a launch failure, the adapter's fold into `platform.Result`, the leaves' accounts on refresh, the shell provider's request shape and refusal

For #1130, which closes when Phase 6 converges the machine.

Written with AI assistance.

Signed-off-by: David Noble <[email protected]>
Assisted-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The broker's client interface: exec by account, the console stream, commands by run id

1 participant