Skip to content

refactor(cli): isolate daemon port presentation - #203020

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/daemon-status-port-rendering-owner
Nov 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/daemon-status-port-rendering-owner

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #202943

What Problem This Solves

The daemon status printer loads its collector to access port-formatting helpers.

User Impact

Port output, sanitization, RPC suppression and listener order stay unchanged.

Why This Change Was Made

One CLI presentation leaf owns both helpers and private address normalization. The printer imports it directly. Real output cases replace fake gather helpers, and their one obsolete mock-baseline entry is removed.

Evidence

At signed head 9b9a36315dd2580c2efcdecb4aee4a43930afd2d:

  • 97 cases passed across the printer, collector and status orchestrator; one unchanged Windows-only case was skipped on Darwin.
  • Core and CLI-test types, five-file typed lint and the check-only mock-export ratchet passed.
  • A fresh-process real printer import passed with the collector unavailable; the direct collector negative control was denied. Both children and fixture cleanup joined.
  • Normal hooks, formatting and full committed-range review passed with no actionable findings.
  • The scoped CLI build passed; its emitted daemon graph contains both moved helpers and private address normalization, with no missing literal internal imports.

Native preparation and exact-head CI passed, including security-fast and package-boundary checks. Hosted build-artifacts was skipped. No full distribution, UI or SDK build or performance claim is made.

@vincentkoc vincentkoc self-assigned this Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR moves daemon port formatting out of status collection and replaces mocked formatting with real printer-output assertions.

Example: Port 18789 has duplicate loopback listener records and an IPv6 listener.

  • Before: The collector supplies formatting helpers that print “Listening: 127.0.0.1:18789, [::1]:18789”.
  • After: A presentation module supplies the same output without a runtime import of the collector.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Source supports behavioral equivalence, but an unnecessary module remains and executable validation is pending.
Proof confidence 🦪 silver shellfish (2/6) This behavior-preserving, maintainer-authored refactor requires no shipped-entry-point demonstration; its supplied output tests, typing, and build validation remain unrun.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: Maintainer-authored direction removes presentation’s runtime dependency on collection and improves output coverage without changing product behavior.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-authored PR addresses a real ownership cleanup, but introduces an unnecessary presentation module.

Priority: P3
Reviewed head: 9b9a36315dd2580c2efcdecb4aee4a43930afd2d

Before merge

  • Keep sole-consumer port helpers private to the printer (P2) - Both exports have exactly one production consumer, status.print.ts, which already owns human status presentation. The linked issue explicitly identifies private printer functions as the complete fix and rejects a separate formatting module for this reason. The new file adds an exported boundary without explaining why the existing owner cannot hold these functions, contrary to the repository’s smallest-complete-fix guidance. Move these implementations and private normalization into status.print.ts and remove this module; the collector dependency and fake test exports can still be removed.
  • Complete next step - The author should complete focused printer, collector, and orchestrator tests, core typing, the mock-export guard, and a build before marking this draft ready.

Findings

  • [P2] Keep sole-consumer port helpers private to the printer — src/cli/daemon-cli/status.port-format.ts:1-5
Agent review details

How this fits together

Gateway status collects service, port, and RPC facts, then passes them to the CLI printer for human-readable or JSON output.

flowchart LR
  A[Gateway status command] --> B[Status collector]
  B --> C[Gathered facts]
  C --> D[Status printer]
  D --> E[Port formatting]
  E --> F[Terminal output]
  D --> G[JSON output]
Loading

Technical review

Best possible solution:

Make the existing printer privately own port presentation, preserving the moved logic and real output assertions.

Do we have a high-confidence way to reproduce the issue?

Source confirms the runtime collector dependency on main; this refactor claims no user-visible bug, and no target code was executed.

Is this the best way to solve the issue?

The dependency removal is sound, but private functions in the existing printer achieve it without another module or exported interface.

Full review comments:

  • [P2] Keep sole-consumer port helpers private to the printer — src/cli/daemon-cli/status.port-format.ts:1-5
    Both exports have exactly one production consumer, status.print.ts, which already owns human status presentation. The linked issue explicitly identifies private printer functions as the complete fix and rejects a separate formatting module for this reason. The new file adds an exported boundary without explaining why the existing owner cannot hold these functions, contrary to the repository’s smallest-complete-fix guidance. Move these implementations and private normalization into status.print.ts and remove this module; the collector dependency and fake test exports can still be removed.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against df2faf7d476c.

Provenance checked

  • Port diagnostic formatting and listener normalization keeps the original intent (bcbfb35: The earliest observed split commit carried these helpers; later projection cleanup preserved suppression and deduplication. Historical content searches could not establish an earlier introduction.)
  • Terminal sanitization keeps the original intent (fix(cli): prevent terminal controls in report values #185927: Escape untrusted report values while retaining intentional terminal layout and styling.)
  • DaemonStatus type ownership keeps the original intent (refactor(cli): derive daemon status contract from gatherer #148108: Derive the contract from the sole gatherer while preserving compatibility overlays; the PR retains type-only imports.)
  • Printer mock and export baseline keeps the original intent (8db6fcc: The existing test mocked collector presentation exports; this PR replaces that bypass with real output checks and removes exactly its obsolete baseline tuple.)

Testing

Proof path: none.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/daemon-cli/status.print.test.ts src/cli/daemon-cli/status.gather.test.ts src/cli/daemon-cli/status.test.ts --maxWorkers=1
  • pnpm tsgo:core
  • pnpm tsgo:core:test
  • pnpm check:test-mock-exports
  • pnpm build

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7aa1757 adds src/cli/daemon-cli/status.gather.ts:301 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7aa175749c93; files: src/cli/daemon-cli/status.gather.ts)
  • Vincent Koc: Raw commit 831f03b adds src/cli/daemon-cli/status.gather.ts:316 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 831f03b8140f; files: src/cli/daemon-cli/status.gather.ts)
  • Dallin Romney: Raw commit 452a638 adds src/cli/daemon-cli/status.gather.ts:642 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 452a6387b0a3; files: src/cli/daemon-cli/status.gather.ts)

PR surface

Source -3, Tests +24, Other -1. Total +20 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 44 47 -3
Tests 1 29 5 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 6 73 53 +20

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P3: This is internal ownership and test cleanup with no intended output change or reported user-facing malfunction.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is internal ownership and test cleanup with no intended output change or reported user-facing malfunction.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 21, 2026, 4:24 AM ET / 09:24 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 21, 2026 10:20
@vincentkoc
vincentkoc merged commit 1d8fa0c into main Nov 21, 2026
238 checks passed
@vincentkoc
vincentkoc deleted the refactor/daemon-status-port-rendering-owner branch November 21, 2026 10:53
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 21, 2026
…3044

* origin/main:
  refactor(test): remove duplicate token startup wait case (#203087)
  fix: keep Plugin SDK declarations within the build limit
  fix(ci): remove unused hook type exports (#203074)
  fix(test): exercise the sign-in callback path guard (#203075)
  refactor(tts): separate caption eligibility from text helpers (#203068)
  test: reuse worker preload options (#203058)
  refactor(test): share Bun native-policy test launcher (#203064)
  fix(cron): a chat-created automation's failure notice reaches that chat (#203056)
  refactor(test): remove duplicate claw origin rejection case (#203067)
  refactor(channels): move chunk-mode lookup to streaming readers (#203047)
  refactor: separate skill queries from workspace discovery (#203045)
  fix: resume new chat turns in retained tasks after a restart
  refactor: separate usage pricing preparation from formatting (#203043)
  fix: avoid repeated filesystem probes before agent turns (#203057)
  perf(agents): preserve sealed history during endpoint compaction (#203037)
  fix(test): give deferred identity fixtures read scope (#203053)
  refactor(test): remove redundant channel catalog facade (#203052)
  refactor(cli): isolate daemon port presentation (#203020)
  refactor(cron): isolate CLI input parsing (#203031)
vincentkoc added a commit that referenced this pull request Nov 21, 2026
* feat: open shared sessions in their source Control UI

* feat: open shared sessions in their source Control UI

OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  fix(ci): decouple boundary fixture from timing inventory (#203026)
  fix(ci): shard capable compatibility UI targets (#203042)
  perf(agents): restore selected subagent payloads once (#203039)
  fix: keep standalone context from completing QA tool steps
  perf(sessions): reuse sealed ownership for context projections (#203040)
  refactor(hooks): separate event predicates from hook registry (#203017)
  fix(ci): align update export audits with their consumers (#203030)
  fix: keep cold baseline checks within the existing heap limit

* fix(session-share): accept the runtime config snapshot in the source link resolver

The stored-session link resolver took a mutable config, so the plugin's readonly
runtime snapshot failed production and test typechecks. Accept the snapshot type.

Document the real Open original setup: allow the link command on the receiver
Gateway, set the source Control UI origin, reinstall the source node with all
three commands, then approve the widened surface. Move the section ahead of
Security boundary and add a troubleshooting entry.

Assert through the Gateway catalog list that a provider-supplied link survives
streamed and final rows, and drop the menu unit test the browser fixture covers.

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  refactor(test): remove duplicate token startup wait case (#203087)
  fix: keep Plugin SDK declarations within the build limit
  fix(ci): remove unused hook type exports (#203074)
  fix(test): exercise the sign-in callback path guard (#203075)
  refactor(tts): separate caption eligibility from text helpers (#203068)
  test: reuse worker preload options (#203058)
  refactor(test): share Bun native-policy test launcher (#203064)
  fix(cron): a chat-created automation's failure notice reaches that chat (#203056)
  refactor(test): remove duplicate claw origin rejection case (#203067)
  refactor(channels): move chunk-mode lookup to streaming readers (#203047)
  refactor: separate skill queries from workspace discovery (#203045)
  fix: resume new chat turns in retained tasks after a restart
  refactor: separate usage pricing preparation from formatting (#203043)
  fix: avoid repeated filesystem probes before agent turns (#203057)
  perf(agents): preserve sealed history during endpoint compaction (#203037)
  fix(test): give deferred identity fixtures read scope (#203053)
  refactor(test): remove redundant channel catalog facade (#203052)
  refactor(cli): isolate daemon port presentation (#203020)
  refactor(cron): isolate CLI input parsing (#203031)

* chore(plugin-sdk): record the approved session-discussion surface growth

Open original adds two exports to openclaw/plugin-sdk/session-discussion: the
stored-session Control UI path resolver and the session path parser. Raise the
public export and callable budgets by two for them.

Use neutral fixtures for the rejected-origin and rejected-query URL tests so the
fixtures do not resemble credentials; the same rejections are covered.

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
* feat: open shared sessions in their source Control UI

* feat: open shared sessions in their source Control UI

OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  fix(ci): decouple boundary fixture from timing inventory (openclaw#203026)
  fix(ci): shard capable compatibility UI targets (openclaw#203042)
  perf(agents): restore selected subagent payloads once (openclaw#203039)
  fix: keep standalone context from completing QA tool steps
  perf(sessions): reuse sealed ownership for context projections (openclaw#203040)
  refactor(hooks): separate event predicates from hook registry (openclaw#203017)
  fix(ci): align update export audits with their consumers (openclaw#203030)
  fix: keep cold baseline checks within the existing heap limit

* fix(session-share): accept the runtime config snapshot in the source link resolver

The stored-session link resolver took a mutable config, so the plugin's readonly
runtime snapshot failed production and test typechecks. Accept the snapshot type.

Document the real Open original setup: allow the link command on the receiver
Gateway, set the source Control UI origin, reinstall the source node with all
three commands, then approve the widened surface. Move the section ahead of
Security boundary and add a troubleshooting entry.

Assert through the Gateway catalog list that a provider-supplied link survives
streamed and final rows, and drop the menu unit test the browser fixture covers.

* Merge remote-tracking branch 'origin/main' into land/open-original-203044

* origin/main:
  refactor(test): remove duplicate token startup wait case (openclaw#203087)
  fix: keep Plugin SDK declarations within the build limit
  fix(ci): remove unused hook type exports (openclaw#203074)
  fix(test): exercise the sign-in callback path guard (openclaw#203075)
  refactor(tts): separate caption eligibility from text helpers (openclaw#203068)
  test: reuse worker preload options (openclaw#203058)
  refactor(test): share Bun native-policy test launcher (openclaw#203064)
  fix(cron): a chat-created automation's failure notice reaches that chat (openclaw#203056)
  refactor(test): remove duplicate claw origin rejection case (openclaw#203067)
  refactor(channels): move chunk-mode lookup to streaming readers (openclaw#203047)
  refactor: separate skill queries from workspace discovery (openclaw#203045)
  fix: resume new chat turns in retained tasks after a restart
  refactor: separate usage pricing preparation from formatting (openclaw#203043)
  fix: avoid repeated filesystem probes before agent turns (openclaw#203057)
  perf(agents): preserve sealed history during endpoint compaction (openclaw#203037)
  fix(test): give deferred identity fixtures read scope (openclaw#203053)
  refactor(test): remove redundant channel catalog facade (openclaw#203052)
  refactor(cli): isolate daemon port presentation (openclaw#203020)
  refactor(cron): isolate CLI input parsing (openclaw#203031)

* chore(plugin-sdk): record the approved session-discussion surface growth

Open original adds two exports to openclaw/plugin-sdk/session-discussion: the
stored-session Control UI path resolver and the session path parser. Raise the
public export and callable budgets by two for them.

Use neutral fixtures for the rejected-origin and rejected-query URL tests so the
fixtures do not resemble credentials; the same rejections are covered.

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Keep daemon port rendering with the status printer

1 participant