Skip to content

feat(cli): standardize and harden Hive interface - #32

Merged
thenotoriousllama merged 5 commits into
mainfrom
legion/prd-003-cli-standard-hive
Jul 13, 2026
Merged

feat(cli): standardize and harden Hive interface#32
thenotoriousllama merged 5 commits into
mainfrom
legion/prd-003-cli-standard-hive

Conversation

@thenotoriousllama

@thenotoriousllama thenotoriousllama commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adopt the shared Apiary CLI interface for Hive, including the standard lifecycle, installation, registration, status, logs, version, help, and telemetry commands.
  • Add Hive-specific branding and the Legion Code Inc. x Activeloop credit.
  • Harden service migration, daemon ownership checks, registry writes, log handling, JSON output, and update rollback behavior.
  • Add packed-artifact conformance, migration documentation, changeset, security review, and independent QA evidence.

Why

Hive was the weakest CLI in the Apiary fleet and still used a divergent command surface. This brings Hive to the PRD-003 standard while retaining its product-specific daemon behavior and preparing the same pattern for the remaining CLIs.

Dogfood evidence

  • Installed @legioncodeinc/hive 0.11.1 globally on Windows.
  • Reconciled the scheduled task to the service-daemon action.
  • Terminated stale daemon PID 104964 and verified the live health endpoint reports 0.11.1.
  • Identity-revalidated restart replaced PID 110864 with healthy PID 116892.
  • Verified Hive-specific service log tailing.

Validation

  • npm test: 97 files, 834 tests passed
  • npm run typecheck
  • npm run build
  • npm run test:packed-cli
  • npm audit --audit-level=high: 0 vulnerabilities
  • git diff --check
  • Security: PASS with no open Critical, High, or Medium findings
  • QA: clean PASS with zero Critical, Warning, or Suggestion findings

Summary by CodeRabbit

  • New Features
    • Released Hive CLI contract (v0.12.0) with standardized verbs/global options, JSON-first help/version, and consistent status, logs, and telemetry.
    • Improved lifecycle/service management, bounded health verification, safer daemon stop/restart, and an approved-channel updater with rollback health checks.
  • CI
    • Added post-build “packed CLI conformance” verification on Linux/macOS/Windows.
  • Documentation
    • Expanded README CLI guidance, added migration notes, and rewrote the operational runbook.
  • Tests / Quality
    • Added/updated CLI contract, observability, updater, registry locking (fail-closed), process identity, daemon wrapper, and service template coverage (plus increased test timeout).

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Hive adopts a standardized CLI with foreground daemon execution, service lifecycle commands, observability and update flows, hardened service and registry handling, expanded tests, packed-CLI verification, and updated operational documentation.

Changes

Hive CLI adoption

Layer / File(s) Summary
CLI contract and conformance
README.md, CHANGELOG.md, src/cli-interface.ts, src/cli.ts, scripts/verify-packed-cli.mjs, package.json, tests/cli-interface.test.ts
Defines canonical commands, JSON envelopes, exit codes, help/version behavior, deprecated aliases, foreground daemon usage, and packed-package conformance checks.
Observability and update runtime
src/cli-commands.ts, src/cli-observability.ts, src/cli-update.ts, tests/cli-commands.test.ts, tests/cli-observability.test.ts, tests/cli-update.test.ts
Adds status, telemetry, logs, daemon, restart, bounded stop, and approved-version update/rollback flows with tests.
Service daemon and lifecycle convergence
src/service/*, src/process-identity.ts, src/shared/apiary-root.ts, tests/service/*, tests/process-identity.test.ts
Routes installed services through service-daemon, adds platform start commands, validates daemon identity, protects service/log files, and consolidates service logging.
Registry concurrency and fail-closed persistence
src/install/registry.ts, tests/install/registry.test.ts
Adds locked registry transactions, strict validation, stale-lock handling, atomic writes, and permission checks.
Validation, CI, and QA evidence
.github/workflows/*, library/qa/*, tests/daemon/installer/funnel-telemetry.test.ts, tests/dashboard/use-swr.test.tsx, vitest.config.ts
Adds packed-CLI CI verification, checkout action updates, QA/security reports, test isolation updates, and a ten-second test timeout.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant HiveCLI
  participant ServiceManager
  participant ServiceDaemon
  participant HiveDaemon
  Operator->>HiveCLI: hive start or hive restart
  HiveCLI->>ServiceManager: start installed service
  ServiceManager->>ServiceDaemon: invoke service-daemon
  ServiceDaemon->>HiveDaemon: spawn node cli.js daemon
  HiveDaemon-->>HiveCLI: health becomes available
  HiveCLI-->>Operator: lifecycle result
Loading

Poem

A rabbit hops through commands bright,
daemon hums softly through the night.
Logs are safe, and locks align,
JSON answers stay in line.
Tests pack the CLI with cheer—
Hoppy release, version 0.12.0 here!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.07% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately captures the PR’s main change: standardizing and hardening the Hive CLI interface.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch legion/prd-003-cli-standard-hive

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

@thenotoriousllama
thenotoriousllama marked this pull request as ready for review July 13, 2026 09:03
@thenotoriousllama

Copy link
Copy Markdown
Contributor Author

Approved Release

@thenotoriousllama

Copy link
Copy Markdown
Contributor Author

✅ Approved — applying the minor bump. The release-gate check will go green; it publishes on merge.

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

Actionable comments posted: 6

🤖 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.

Inline comments:
In `@CHANGELOG.md`:
- Around line 3-21: Consolidate the stale “Unreleased — PRD-003 CLI interface
adoption” section into the existing v0.12.0 changelog entry. Remove the
duplicate Unreleased heading and preserve its detailed migration bullets and
operator guidance under v0.12.0, without retaining redundant summary text.

In `@library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md`:
- Line 3: Replace the machine-specific absolute path in the Plan document
reference with the repository-relative path or a redacted logical path, removing
the local username while preserving the referenced PRD location.
- Line 6: Update the evidence metadata in the QA document to record the exact
audited commit SHA instead of only the dirty branch state. Clearly label whether
the results are based on local-only working-tree evidence or a release revision,
and preserve that distinction in the report.

In `@library/qa/security/2026-07-13-prd-003-hive-cli-adoption-security-audit.md`:
- Line 9: Update the CVE catalog statement in the audit to use a catalog
refreshed for the July 13, 2026 assessment, or replace “current” with the exact
coverage window and explicitly state the limitation.
- Line 13: Make the QA and security reports reflect one final, commit-consistent
post-security test run: in
library/qa/security/2026-07-13-prd-003-hive-cli-adoption-security-audit.md at
lines 13 and 73-76, remove the stale-report wording and update the full-suite
count and timeout disposition; in
library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md at lines 11 and
102, record a post-security PASS and match the security audit’s test-run
metadata and count.

In `@src/install/registry.ts`:
- Around line 254-277: Move the initial registry existence check from before
withRegistryLock into its callback so deleteHiveEntryAtPath always acquires the
lock before deciding the entry is absent. Preserve the ENOENT false result and
existing deletion flow, while allowing a concurrent registration to complete
before the absence check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55fe32dc-cc48-4415-b14d-ff72c975745c

📥 Commits

Reviewing files that changed from the base of the PR and between be980c6 and b63d530.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (37)
  • .github/workflows/ci.yaml
  • CHANGELOG.md
  • README.md
  • library/knowledge/private/operations/cli-and-runbook.md
  • library/knowledge/private/operations/prd-003-cli-migration.md
  • library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md
  • library/qa/security/2026-07-13-prd-003-hive-cli-adoption-security-audit.md
  • package.json
  • scripts/verify-packed-cli.mjs
  • src/cli-commands.ts
  • src/cli-interface.ts
  • src/cli-observability.ts
  • src/cli-update.ts
  • src/cli.ts
  • src/install/registry.ts
  • src/process-identity.ts
  • src/service/commands.ts
  • src/service/daemon-wrapper.ts
  • src/service/index.ts
  • src/service/templates.ts
  • src/shared/apiary-root.ts
  • src/terminal-safety.ts
  • tests/cli-commands.test.ts
  • tests/cli-interface.test.ts
  • tests/cli-observability.test.ts
  • tests/cli-update.test.ts
  • tests/daemon/installer/funnel-telemetry.test.ts
  • tests/dashboard/use-swr.test.tsx
  • tests/install/registry.test.ts
  • tests/process-identity.test.ts
  • tests/service/commands.test.ts
  • tests/service/daemon-wrapper.test.ts
  • tests/service/helpers.ts
  • tests/service/service-module.test.ts
  • tests/service/templates.test.ts
  • tests/shared/apiary-root.test.ts
  • vitest.config.ts

Comment thread CHANGELOG.md
Comment thread library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md Outdated
Comment thread library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md Outdated
Comment thread library/qa/security/2026-07-13-prd-003-hive-cli-adoption-security-audit.md Outdated
Comment thread library/qa/security/2026-07-13-prd-003-hive-cli-adoption-security-audit.md Outdated
Comment thread src/install/registry.ts

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md`:
- Line 108: Update the npm audit result entry to state “0 high-or-higher
vulnerabilities,” matching the --audit-level=high scope, or replace it with the
complete audit output if the result is intended to cover all severity levels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d5cdcd16-607e-4fce-8695-87c927d14b56

📥 Commits

Reviewing files that changed from the base of the PR and between 2c74ee1 and 6041e62.

📒 Files selected for processing (5)
  • .github/workflows/ci.yaml
  • .github/workflows/release-gate.yaml
  • .github/workflows/release.yaml
  • .github/workflows/tag-on-merge.yaml
  • library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yaml

Comment thread library/qa/quality/2026-07-13-prd-003-hive-cli-adoption-qa.md
@thenotoriousllama
thenotoriousllama merged commit ba39754 into main Jul 13, 2026
7 checks passed
@thenotoriousllama
thenotoriousllama deleted the legion/prd-003-cli-standard-hive branch July 13, 2026 09:32
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.

2 participants