Skip to content

feat(status): expose controller per-tick cost in host status - #403

Merged
kyle-sexton merged 2 commits into
mainfrom
feat/391-controller-tick-cost
Sep 27, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
feat/391-controller-tick-cost

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

No related issue: partial work on #391 (asks 2 and 3); the issue stays open for the dynamic concurrency cap.

Summary

host status now reports the controller's own cost, so idle and per-tick CPU can be watched without external sampling (#391 ask 3, #328 suggestion 4). The README also documents the existing contention guard for interactive dev hosts (#391 ask 2). Ask 1 was confirmed on the issue: v0.1.27 idles at about 0.05 core.

Fix

  • ObservedState gains controller.lastTickDurationSeconds (previous reconcile tick's wall time, measured in Reconciler.Step's defer) and controller.processCpuSeconds (cumulative process CPU: GetProcessTimes on Windows, Getrusage elsewhere).
  • Both the closing observed-state write and every poll-cadence checkpoint (pollCheckpoint) fill the field through one controllerCost() helper, so the value never drops to zero mid-tick.
  • Human status prints Controller cost: last tick 0.250s, process CPU 12.5s; --json carries it under observed.controller.
  • README: tick duration includes the listener long poll, so processCpuSeconds deltas are the cost measure. The resources section recommends setting maximumConcurrentWorkers below the sum of pool maxCapacity and/or lowering worker.cpus on interactive hosts, since cpuBlockPercent reacts to sustained host-wide CPU, not interactive latency. No new config field or schema change.

Verification

  • go build ./..., go test -race ./..., golangci-lint run ./... (0 issues, also with GOOS=windows on the controller package), and CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath ./cmd/... all pass.
  • New tests: TestReconcilerPublishesPreviousTickCost (second Step persists nonzero previous-tick duration and CPU), TestPollCheckpointPersistsControllerCost (cadence checkpoint keeps the value), and TestStatusJSONExposesStableBusyWorkContract extended for the JSON keys and the human line.
  • Old releases ignore the new observed.json key (LoadObserved ignores unknown fields); ObservedState does not cross the strict control transport.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01GZgRs2crE1YQ1TT4kftix1

kyle-sexton and others added 2 commits September 27, 2026 18:23
Persist the previous reconcile tick's wall duration and the controller
process's cumulative CPU seconds in observed state under
observed.controller, shown by host status --json and as a Controller
cost line in human output. Document the fields and recommend capping
maximumConcurrentWorkers or worker CPUs on interactive dev hosts.

Refs #391

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZgRs2crE1YQ1TT4kftix1
pollCheckpoint built observed state without the controller cost, so
every serving and cadence checkpoint stored zeros. Share one
controllerCost helper between it and the step's closing write, and note
that tick duration includes the listener long poll.

Refs #391

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZgRs2crE1YQ1TT4kftix1
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T22:30:17.083740Z fd2057a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd2057a0f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/model/model.go Resolved
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

PR body contract — issue linkage

This PR body conforms to the issue-linkage contract. Nothing to do.

@kyle-sexton
kyle-sexton merged commit 860dffe into main Sep 27, 2026
2 checks passed
@kyle-sexton
kyle-sexton deleted the feat/391-controller-tick-cost branch September 27, 2026 22:45
kyle-sexton added a commit that referenced this pull request Sep 27, 2026
…dows (#408)

No related issue: fixes main's Windows go-quality lane broken by #403.

## Summary

`TestReconcilerPublishesPreviousTickCost` failed on main's Windows
go-quality lane (run 36356368154): `LastTickDurationSeconds:0`. A fast
fake Step measures 0 on Windows' coarse wall clock, so the test's
nonzero assertions were timing-dependent. #403's own PR run passed the
Windows lane by chance.

## Fix

- Both controller cost tests now run inside `synctest.Test` with a
`slowResources` monitor that sleeps 1s per sample. The bubble clock
advances only on that sleep, so Step's measured duration is
deterministic and the test asserts the persisted previous-tick value is
at least 1s.
- Process CPU (`GetProcessTimes`, ~15.6 ms granularity) is asserted
non-decreasing across Steps / non-negative, not nonzero.
- Production code is unchanged.

## Verification

- Native Windows: cross-compiled test binary run via WSL interop,
`-test.run 'ControllerCost|PreviousTickCost' -test.count 20`: 40/40
PASS.
- `go build ./...`, `go test -race ./...`, `golangci-lint run ./...`
(v2.13.2, 0 issues), `CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build
-trimpath ./cmd/...` all pass.

## Related

- #403

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01GZgRs2crE1YQ1TT4kftix1

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant