Skip to content

feat(doctor): add Pgserve (canonical backbone) check section - #1605

Merged
namastex888 merged 1 commit into
devfrom
feat/doctor-pgserve-canonical
May 1, 2026
Merged

namastex888 merged 1 commit into
devfrom
feat/doctor-pgserve-canonical

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

Adds a Pgserve (canonical backbone) section to genie doctor, mirroring omni doctor's pgserve-canonical check so operators see the same shared-backbone visibility from both halves of the canonical-stack.

Pgserve (canonical backbone):
  ✓ pgserve binary canonical port 8432
  ✓ pgserve under pm2 online — shared backbone for genie-serve + omni-api on :8432

…or, when something is off:

Pgserve (canonical backbone):
  ! pgserve binary not on PATH (or `pgserve port` failed)
    Install canonical pgserve: bun add -g pgserve@^2.1.0 (then run `pgserve install`...)
  ! pgserve under pm2 binary present but not registered under pm2
    Register canonical pgserve: pgserve install

Probes

  • Binary detection via pgserve port (NOT --version — that flag doesn't exist in pgserve@^2.1.0 and false-negatived in historical doctor implementations; same lesson surfaced in omni doctor --fix on 2026-04-30 → omni#580).
  • Pm2 registration + online status via pgserve status --json.

Severity

Both checks are WARN, never FAIL. Genie can auto-spawn its own daemon as a fallback for fingerprint-routed CLI commands, so a missing canonical pgserve doesn't break local development — it just means genie isn't sharing the backbone with omni and other automagik services on this host.

Live-validated

Tested on this canonical-pgserve-running server: both checks PASS, section renders cleanly, exit-code unchanged.

Pairs with

Mirrors `omni doctor`'s `pgserve-canonical` check on the genie side
so operators see the same shared-backbone visibility from both halves
of the canonical-stack. Surfaces three signals:

  ✓ pgserve binary canonical port 8432
  ✓ pgserve under pm2 online — shared backbone for genie-serve + omni-api

…or, when something is off:

  ! pgserve binary not on PATH (or `pgserve port` failed)
    Install canonical pgserve: bun add -g pgserve@^2.1.0
  ! pgserve under pm2 binary present but not registered under pm2
    Register canonical pgserve: pgserve install

Probes
------
- Binary detection via `pgserve port` (NOT `--version` — that flag
  doesn't exist in pgserve@^2.1.0 and false-negatived in historical
  doctor implementations; same lesson surfaced in `omni doctor --fix`
  on 2026-04-30).
- Pm2 registration + online status via `pgserve status --json`.

Severity
--------
Both checks are WARN, never FAIL. Genie can auto-spawn its own daemon
as a fallback for fingerprint-routed CLI commands, so a missing
canonical pgserve doesn't break local development — it just means
genie isn't sharing the backbone with omni and other automagik
services on this host.

Tests
-----
Live-validated on canonical-pgserve-running host: both checks PASS,
section renders cleanly, exit-code unchanged.
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9100964c-898d-4d3f-a47a-3fb8c48fd5a5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/doctor-pgserve-canonical

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a checkPgserveCanonical function to the doctor command to verify the pgserve binary's presence, its PM2 registration status, and its listening port. The review feedback recommends replacing synchronous execFileSync calls with Bun's asynchronous shell API to prevent blocking the event loop, which aligns with the function's asynchronous implementation.

Comment on lines +736 to +740
const out = execFileSync('pgserve', ['port'], {
encoding: 'utf8',
timeout: 3000,
stdio: ['ignore', 'pipe', 'ignore'],
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The checkPgserveCanonical function is marked as async, but it uses the synchronous execFileSync for probing the binary. For consistency with other async checks in this file (like checkTmux) and to avoid blocking the event loop unnecessarily, consider using Bun's asynchronous shell primitive ($). The use of a hardcoded timeout is acceptable here to prevent performance issues during the probe, as per repository guidelines.

    const out = await $("pgserve port").timeout(3000).quiet().text();
References
  1. It is acceptable to use hardcoded numeric limits (magic numbers) in non-critical fallback logic, especially when they serve as intentional caps to prevent performance issues like excessive I/O.

Comment on lines +767 to +771
const status = execFileSync('pgserve', ['status', '--json'], {
encoding: 'utf8',
timeout: 3000,
stdio: ['ignore', 'pipe', 'ignore'],
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the binary probe above, consider using Bun's asynchronous shell primitive ($) instead of execFileSync to maintain consistency within this async function and the rest of the file's async check logic. The hardcoded timeout is permitted in this context to prevent the process from hanging.

    const status = await $("pgserve status --json").timeout(3000).quiet().text();
References
  1. It is acceptable to use hardcoded numeric limits (magic numbers) in non-critical fallback logic, especially when they serve as intentional caps to prevent performance issues like excessive I/O.

@namastex888
namastex888 merged commit 35b05b4 into dev May 1, 2026
16 checks passed
@automagik-genie
automagik-genie deleted the feat/doctor-pgserve-canonical branch September 25, 2026 04:49
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.

2 participants