Skip to content

Fast-path host status through the daemon#302

Merged
TraderSamwise merged 2 commits into
masterfrom
chore/core-sidecar-next-27
Jul 4, 2026
Merged

Fast-path host status through the daemon#302
TraderSamwise merged 2 commits into
masterfrom
chore/core-sidecar-next-27

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a daemon-owned /core/host-status-text route with text and JSON output parity
  • route installed aimux host status [--json] through the daemon without launching Node on healthy installs
  • move host-status rendering into shared core text helpers and update the command ownership inventory/test

Verification

  • yarn typecheck
  • yarn lint
  • yarn vitest run
  • yarn build

Summary by CodeRabbit

  • New Features

    • Added fast-path support for aimux host status in both plain text and --json output.
    • Host status now includes clearer project-aware status details when available.
  • Bug Fixes

    • Improved routing so host status requests can be served directly without falling back to a slower path in supported cases.
    • Added validation for project-aware status requests to return a clear error when required context is missing.

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 4, 2026 1:05pm

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a /core/host-status-text daemon route with a shared CoreHostStatusTextPayload type and renderCoreHostStatusLines renderer, wires it into src/core-cli.ts and src/daemon.ts, adds a shim fast path in installed-aimux-shim.sh, and updates classification tests and documentation.

Changes

Host status text route

Layer / File(s) Summary
Route contract and rendering helper
src/core-command-contract.ts, src/core-text.ts
Adds hostStatusText route constant, CoreHostStatusTextPayload type, coreProjectServicePid helper, and exported renderCoreHostStatusLines function.
CLI delegation
src/core-cli.ts
Removes local coreProjectServicePid and delegates runHostStatus text output to the shared renderCoreHostStatusLines.
Daemon endpoint and project resolution
src/daemon.ts, src/daemon.test.ts
Adds hostStatusPayload, resolveProjectRoot, findProjectForRoot helpers and a GET handler for the new route requiring a project query, plus tests for text/JSON responses and missing-query error.
Installed shim fast path
scripts/installed-aimux-shim.sh, src/installed-shim.test.ts
Adds aimux_curl_project_text_route helper and a host status/--json dispatch branch; tests cover fast-path serving and fallback to Node launcher on stale daemon health.
Command classification and docs
src/core-command-ownership.test.ts, docs/command-ownership-inventory.md
Reclassifies host status/--json as shim-fast-path with shimNeedle values, adjusts count and backlog expectations, and updates the ownership inventory tables.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Shim as installed-aimux-shim.sh
  participant Daemon as daemon.ts
  participant Paths as ensureProjectPaths
  participant Renderer as renderCoreHostStatusLines

  Shim->>Daemon: GET /core/host-status-text?project=<root>
  Daemon->>Paths: ensureProjectPaths(project)
  Daemon->>Daemon: hostStatusPayload()
  Daemon->>Renderer: renderCoreHostStatusLines(payload, knownProject)
  Renderer-->>Daemon: status lines
  Daemon-->>Shim: text or JSON response
Loading

Possibly related PRs

  • TraderSamwise/aimux#285: Both PRs touch the host status implementation in src/core-cli.ts, with this PR refactoring that path to use the new renderCoreHostStatusLines//core/host-status-text contract.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main change: routing host status through the daemon for a fast path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/core-sidecar-next-27

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (4)
src/daemon.ts (2)

680-689: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Route handler wired correctly; confirm build step.

The handler correctly validates the required project param, ensures paths, and delegates rendering to the shared helper — consistent with daemon.test.ts expectations. Since this is a daemon runtime behavior change, ensure yarn build is run to refresh dist/ prior to release.

As per coding guidelines, "For aimux runtime or CLI behavior changes, run yarn build to update dist/; source-level validation with yarn vitest and yarn typecheck is not enough."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/daemon.ts` around lines 680 - 689, The host status route in daemon.ts is
already wired correctly, so no code change is needed in the GET handler for
CORE_API_ROUTES.hostStatusText; instead, make sure to run yarn build so the
updated daemon runtime behavior is reflected in dist/ before release. Keep the
existing validation flow in the route handler (project check,
ensureProjectPaths, hostStatusPayload, renderCoreHostStatusLines) unchanged and
ensure the built artifacts are refreshed.

Source: Coding guidelines


309-315: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the project-root helper

resolveProjectRoot duplicates the same findMainRepo + fallback logic used in src/core-cli.ts and src/main.ts; extract a shared helper so daemon and CLI behavior stay aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/daemon.ts` around lines 309 - 315, The resolveProjectRoot method in
Daemon duplicates the same findMainRepo-with-fallback logic used elsewhere, so
extract that behavior into a shared helper and update Daemon, core-cli, and main
to call it. Keep the helper responsible for trying findMainRepo and returning
the original cwd on failure, and reference resolveProjectRoot plus the existing
findMainRepo usage sites when wiring the shared implementation.
src/core-cli.ts (1)

7-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

CLI delegation looks correct.

Payload shape at lines 59-67 matches CoreHostStatusTextPayload exactly, and delegating to the shared renderCoreHostStatusLines removes the duplicated pid-extraction helper. Since this changes aimux host status CLI runtime behavior, remember to run yarn build to refresh dist/ — source-level yarn vitest/yarn typecheck alone won't update the published CLI artifact.

As per coding guidelines, "For aimux runtime or CLI behavior changes, run yarn build to update dist/; source-level validation with yarn vitest and yarn typecheck is not enough."

Also applies to: 49-49, 54-74

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core-cli.ts` at line 7, The CLI delegation in core-cli.ts looks correct,
but because this changes aimux host status runtime behavior and affects the
published CLI artifact, make sure to run yarn build so dist/ is regenerated;
symbolically, this applies around renderCoreHostStatusLines and the
CoreHostStatusTextPayload handling, and source-only checks like yarn vitest or
yarn typecheck are not enough.

Source: Coding guidelines

src/installed-shim.test.ts (1)

280-291: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a fallback test for host status --json with stale health.

Only the plain host status fallback path is tested. The --json branch has separate dispatch logic (line 114 in the shim) and should get equivalent fallback coverage.

✅ Suggested additional test
+  it("falls back to the Node launcher for host status --json when daemon health is stale", () => {
+    const fixture = makeFixture();
+    writeFileSync(fixture.healthFile, `${health("old-build", 321)}\n`);
+    writeFileSync(fixture.textRouteFile, '{"projectRoot":"/repo"}\n');
+    writeFileSync(fixture.daemonInfoPath, `${JSON.stringify({ pid: 321, port: 45678 })}\n`);
+
+    const result = fixture.run(["host", "status", "--json"], { NODE_EXIT: "34" });
+
+    expect(result.status).toBe(34);
+    expect(readFileSync(fixture.nodeLog, "utf8")).toBe(
+      `${fixture.aimuxRoot}/dist/launcher-bin.js host status --json\n`,
+    );
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/installed-shim.test.ts` around lines 280 - 291, Add a fallback test in
installed-shim.test that covers host status --json when daemon health is stale,
since only the plain host status path is currently verified. Reuse the same
stale-health fixture setup in makeFixture and the same launcher fallback
assertions, but invoke fixture.run with host status --json so the separate
dispatch in the shim is covered. Keep the expectation that the Node launcher is
used by checking the nodeLog path and exit status, similar to the existing host
status test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/core-cli.ts`:
- Line 7: The CLI delegation in core-cli.ts looks correct, but because this
changes aimux host status runtime behavior and affects the published CLI
artifact, make sure to run yarn build so dist/ is regenerated; symbolically,
this applies around renderCoreHostStatusLines and the CoreHostStatusTextPayload
handling, and source-only checks like yarn vitest or yarn typecheck are not
enough.

In `@src/daemon.ts`:
- Around line 680-689: The host status route in daemon.ts is already wired
correctly, so no code change is needed in the GET handler for
CORE_API_ROUTES.hostStatusText; instead, make sure to run yarn build so the
updated daemon runtime behavior is reflected in dist/ before release. Keep the
existing validation flow in the route handler (project check,
ensureProjectPaths, hostStatusPayload, renderCoreHostStatusLines) unchanged and
ensure the built artifacts are refreshed.
- Around line 309-315: The resolveProjectRoot method in Daemon duplicates the
same findMainRepo-with-fallback logic used elsewhere, so extract that behavior
into a shared helper and update Daemon, core-cli, and main to call it. Keep the
helper responsible for trying findMainRepo and returning the original cwd on
failure, and reference resolveProjectRoot plus the existing findMainRepo usage
sites when wiring the shared implementation.

In `@src/installed-shim.test.ts`:
- Around line 280-291: Add a fallback test in installed-shim.test that covers
host status --json when daemon health is stale, since only the plain host status
path is currently verified. Reuse the same stale-health fixture setup in
makeFixture and the same launcher fallback assertions, but invoke fixture.run
with host status --json so the separate dispatch in the shim is covered. Keep
the expectation that the Node launcher is used by checking the nodeLog path and
exit status, similar to the existing host status test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66a5d1fd-5bef-437e-8456-7fc38d8bfb81

📥 Commits

Reviewing files that changed from the base of the PR and between f6ee581 and cfc3155.

📒 Files selected for processing (9)
  • docs/command-ownership-inventory.md
  • scripts/installed-aimux-shim.sh
  • src/core-cli.ts
  • src/core-command-contract.ts
  • src/core-command-ownership.test.ts
  • src/core-text.ts
  • src/daemon.test.ts
  • src/daemon.ts
  • src/installed-shim.test.ts

@TraderSamwise
TraderSamwise merged commit 09c517a into master Jul 4, 2026
3 checks passed
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