Skip to content

feat(behavior): the endpoint layer makes behavior commands - #845

Merged
retr0h merged 1 commit into
mainfrom
feat/behavior-commands-from-endpoints
Nov 18, 2026
Merged

retr0h merged 1 commit into
mainfrom
feat/behavior-commands-from-endpoints

Conversation

@retr0h

@retr0h retr0h commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Step 3 of #826, the last: a behavior's commands come from its endpoint group and run on the endpoint command runtime. The behavior's own Build, Call, Run and Attach are deleted.

  • Shared writers: the endpoint generator's command writer moved to internal/controller/endpoint/gen/commandgen, next to routegen; their shared helpers are in gen/genutil. The behavior generator writes each group's gen/cli.go with it. The endpoint generator's own output is unchanged.
  • Endpoint DSL, general additions: .Example(flags, doc) (a # doc line above the example), CommandNotes(text), and Group.CommandPath(): a group attaches under the fixed segments of its prefix, so sysctl is under next node. A field with a default is not a required flag; a map field is a key=value flag; a secret field says so in its help.
  • --target is the flag of the request's hostname field (default _all), on each command instead of a global flag of next node.
  • Rendering: the endpoint command runtime gives a renderer the trace ID of its call (command.TraceID()); each behavior method renders with the behavior's result table (command.Print).
  • Tests: the generated CLI tests build their expected request with the endpoint Build from each example's input; commandtest fakes the endpoint Caller.
  • The second generation step is renamed internal/behavior/gen/group: it writes each behavior's spec, routes, decoders and commands.

Proof: the --help of each sysctl command, saved from main before the change, is identical except that --target moved from Global Flags to Flags (same text and default). sysctl's generated API and CLI tests pass; both scaffold checks and the generate check pass; lint is clean; the touched runtime packages are at 100%.

The file writer and the spec writer that both generators still repeat go into shared packages in the next PR.

Specs: osapi-io/specs#355

🤖 Generated with Claude Code

Step 3 of #826. A behavior's commands come from its endpoint group, as
an endpoint's do, and run on the endpoint command runtime. The
behavior's own Build, Call, Run and Attach go.

- the endpoint generator's command writer moves to
  internal/controller/endpoint/gen/commandgen, beside routegen, with
  their shared helpers in gen/genutil; the behavior generator writes
  each group's gen/cli.go with it
- the endpoint DSL gains an example's doc (.Example(flags, doc)),
  CommandNotes, and Group.CommandPath: a group attaches under the
  fixed segments of its prefix, such as next node
- a field with a default is not a required flag; a map field is a
  key=value flag; a secret field says so in its help
- --target is the flag of the request's hostname field, default _all,
  on each command instead of a global flag of next node
- the endpoint command runtime gives a renderer the trace ID of its
  call; each behavior method renders with the behavior's result table
- the generated CLI tests build their expected request with the
  endpoint runtime's Build, from each example's input
- the second generation step is internal/behavior/gen/group: it writes
  each behavior's spec, routes, decoders and commands

The help of each sysctl command is the same as before, but for
--target, which moved from the global flags to the command's flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@             Coverage Diff             @@
##              main      #845     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          550       548      -2     
  Lines        30173     36538   +6365     
===========================================
+ Hits         30173     36538   +6365     
Files with missing lines Coverage Δ
internal/behavior/command/behavior.go 100.00% <100.00%> (ø)
...ternal/behavior/command/commandtest/commandtest.go 100.00% <100.00%> (ø)
internal/behavior/command/docs.go 100.00% <100.00%> (ø)
internal/controller/endpoint/command/command.go 100.00% <100.00%> (ø)
internal/controller/endpoint/endpoint.go 100.00% <100.00%> (ø)

... and 539 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f69dbd4...bf20cfe. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@retr0h
retr0h merged commit abdcf11 into main Nov 18, 2026
12 checks passed
@retr0h
retr0h deleted the feat/behavior-commands-from-endpoints branch November 18, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant