Skip to content

feat(terminal): add --resolve for MAC targets over ssh (JG-01) - #44

Merged
mobileskyfi merged 2 commits into
mainfrom
feat/terminal-resolve-jg01
Jun 16, 2026
Merged

feat(terminal): add --resolve for MAC targets over ssh (JG-01)#44
mobileskyfi merged 2 commits into
mainfrom
feat/terminal-resolve-jg01

Conversation

@mobileskyfi

@mobileskyfi mobileskyfi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

Adds a real --resolve <none|arp> flag to terminal, closing the JG-01 papercut where a MAC target pinned to --via ssh hit an inherited target/mac-unresolved error that suggested --resolve arp — a flag terminal did not actually parse (so following the tip gave Unknown terminal flag: --resolve).

Behavior (decided in the june-gloom ledger)

A MAC <router> defaults to mac-telnet (addresses the MAC directly — no resolution). Pinning --via ssh asks for the IP-level console, so the MAC must become an IP:

  • CDB-first — a matching CDB record's target IP is used (needs no flag).
  • No silent ARP — with no record and the default --resolve none, errors target/mac-unresolved; the tip leads with --via mac-telnet (reach it over L2, no IP needed), then IP/hostname / CDB record / --resolve arp. centrs never falls back to ARP — or to another transport — on its own (constitution: a pinned --via is never swapped).
  • --resolve arp (or CENTRS_RESOLVE=arp) opts into the host ARP cache; a miss is target/mac-not-in-arp (also tipping L2).

--resolve is a no-op for the mac-telnet default.

How

Reuses the shared resolveMacTarget policy that retrieve/execute already use — terminal just joins it for its IP transport (ssh), with a "terminal" operation that tailors the remediation. No transport-path change.

Tests / verification

  • test/unit/terminal.test.ts — none-path error + L2 tip, mac-telnet ignores --resolve, unknown-value rejection.
  • test/unit/mac.test.tsterminal operation remediation wording (both branches).
  • test/integration/cli-smoke.test.ts — network-free binary-level anchor (JG-01) in the fast gate.
  • README + examples (TS4) updated; the stale "still open" SSH note refreshed.
  • bun run lint ✅ · bun run lint:ci ✅ · bun run test (669 pass) ✅ · bun run build

The ssh-to-IP transport path is unchanged and already CHR-passed (TS1), and the new MAC→IP logic is pure resolution (unit + smoke verified), so this is a lint+test+build papercut with no new CHR run. MATRIX cells stay CHR-passed (additive flag).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added --resolve flag to terminal command for SSH connections to control MAC-to-IP resolution (options: none or arp)
  • Documentation

    • Updated documentation with new MAC target resolution policy section and examples
    • Clarified SSH key selection and console behavior
  • Improvements

    • Enhanced error messages with Layer 2 guidance when MAC resolution fails

A MAC `<router>` pinned to `--via ssh` needs an IP. Wire terminal into the
shared `resolveMacTarget` policy that `retrieve`/`execute` already use:
CDB-first IP lookup, then `target/mac-unresolved` (default `--resolve none`)
or a host-ARP opt-in (`--resolve arp`). terminal's tip leads with the L2
alternative (`--via mac-telnet`, no IP needed); it never resolves via ARP or
swaps transport on its own. The mac-telnet default ignores `--resolve` (the
MAC is the target). Closes the papercut where the inherited error suggested a
`--resolve` flag terminal did not parse.

Adds the `terminal` operation to `unresolvedMacError`, the flag to the CLI
help + parser, unit tests (terminal + mac), a network-free smoke anchor, and
README/examples docs. No transport-path change (ssh-to-IP is already TS1
CHR-passed), so lint+test+build only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 16, 2026 14:32
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@mobileskyfi, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 6 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a2ea5da9-bd32-496e-9588-06009d7371d5

📥 Commits

Reviewing files that changed from the base of the PR and between df170fb and f8f1d06.

📒 Files selected for processing (3)
  • commands/terminal/README.md
  • commands/terminal/examples.md
  • src/resolver/mac.ts
📝 Walkthrough

Walkthrough

Adds a --resolve <none|arp> flag to the terminal command that controls MAC-to-IP resolution when --via ssh is selected. The resolver's resolveMacTarget and unresolvedMacError functions are extended with an operation: "terminal" discriminator that emits L2 (--via mac-telnet) remediation hints on failure. Documentation, unit tests, and a CLI smoke test cover the new paths.

Changes

MAC→IP Resolution via --resolve for terminal --via ssh

Layer / File(s) Summary
MAC resolver: operation discriminator and terminal remediation
src/resolver/mac.ts
resolveMacTarget destructuring adds operation: "terminal"; unresolvedMacError accepts the expanded union; new unresolvedMacRemediation helper centralizes per-operation remediation text, including a --via mac-telnet L2 tip for terminal flows.
TerminalRequest.resolve field and resolveTerminalRequest MAC→IP path
src/terminal.ts
TerminalRequest gains optional resolve?: string; resolveTerminalRequest parses the policy via parseResolvePolicy and conditionally calls resolveMacTarget with operation: "terminal" when the transport is IP-level, passing macResolution into resolveTarget.
--resolve CLI flag definition and argument parsing
src/cli/terminal.ts
terminalCommand option definitions add --resolve <none|arp> with help text; parseTerminalCliArgs switch handles --resolve and stores the value on flags.resolve.
Unit and integration tests
test/unit/mac.test.ts, test/unit/terminal.test.ts, test/integration/cli-smoke.test.ts
Unit tests verify operation: "terminal" remediation for both none and arp policy failures; terminal tests cover ssh unresolved error, mac-telnet ignoring --resolve, and invalid value rejection; smoke test asserts full subprocess error envelope with --via mac-telnet hint.
README and examples documentation
commands/terminal/README.md, commands/terminal/examples.md
README adds a "MAC target over SSH (--resolve)" policy section and refines SSH key/flow narrative. Examples adds TS4 block for MAC target --via ssh failure modes and error codes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • tikoci/centrs#42: Directly extends the same test/integration/cli-smoke.test.ts smoke harness with new network-free subprocess assertions for terminal --via ssh --resolve failures.
  • tikoci/centrs#17: Modifies the same resolveTerminalRequest flow and TerminalRequest contract in src/terminal.ts, focusing on building the interactive host ssh transport that this PR's --resolve logic branches on.
  • tikoci/centrs#15: Introduced the terminal command implementation (src/cli/terminal.ts, src/terminal.ts) that this PR extends with the --resolve flag and MAC→IP wiring.

Poem

🐰 A MAC walked in, said "SSH, please!"
The resolver checked CDB with ease.
No record found — tip L2 instead,
--via mac-telnet is what the rabbit said.
--resolve arp for the brave, none for the strict,
Every error hint perfectly picked! 🗂️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
Title check ✅ Passed The title accurately describes the main feature: adding a --resolve flag to the terminal command for MAC targets over SSH, and includes the work item reference (JG-01).
Description check ✅ Passed The description covers What, Behavior, How, and Tests/verification sections with comprehensive detail. Required template sections (Links, Change type, Notes) are not filled, but the provided narrative adequately documents the change rationale and implementation approach.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/terminal-resolve-jg01

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.

Copilot AI 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.

Pull request overview

Adds proper --resolve <none|arp> support to centrs terminal so a MAC target pinned to the IP transport (--via ssh) can be resolved (CDB-first, optional ARP opt-in) and produces actionable, terminal-specific remediation when it cannot.

Changes:

  • Parse and expose --resolve on the terminal CLI and thread it through terminal request resolution.
  • Reuse shared MAC→IP resolution (resolveMacTarget) for terminal’s IP transport path, with tailored remediation for the terminal operation.
  • Add unit coverage and a network-free CLI smoke test to lock in the JG-01 behavior; update terminal command docs/examples accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/terminal.ts Applies MAC→IP resolution when --via ssh is used with a MAC target and wires the resolved mapping into resolveTarget.
src/resolver/mac.ts Extends shared MAC resolution to support a "terminal" operation variant with terminal-specific remediation text.
src/cli/terminal.ts Adds --resolve <none|arp> flag support and help text for the terminal CLI.
test/unit/terminal.test.ts Verifies default “no silent ARP” behavior, mac-telnet no-op behavior, and unknown --resolve rejection.
test/unit/mac.test.ts Verifies terminal-specific remediation wording for both unresolved and ARP-miss branches.
test/integration/cli-smoke.test.ts Adds a network-free subprocess-level regression test for the JG-01 error + L2 tip behavior.
commands/terminal/README.md Documents --resolve behavior and clarifies the “no silent fallback when --via is pinned” rule for terminal.
commands/terminal/examples.md Adds an executable-spec example (TS4) describing the new --resolve / unresolved behavior and its smoke-test coverage.

@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: 3

🤖 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 `@commands/terminal/examples.md`:
- Around line 127-141: The TS4 example violates the contract for numbered
command examples in examples.md files, which must correspond to integration
assertions verified against real CHR. Currently, TS4 is validated only through
network-free smoke tests and unit tests, not the CHR integration path. Either
add corresponding CHR integration test assertions that validate this example
scenario, or remove the example numbering and move the content to a non-spec
note (e.g., as an unnumbered commentary or reference section) that documents
behavior without claiming executable-spec validation.

In `@commands/terminal/README.md`:
- Around line 47-67: The "MAC target over SSH (`--resolve`)" section (lines
47-67) and the section at lines 91-95 restate constitution-level target
selection and protocol policies that should not be duplicated in the command
README. Replace these detailed policy explanations with a brief summary of
terminal-specific behavior and add a link to docs/CONSTITUTION.md for the
cross-command target selection and resolution rules. At lines 47-67, keep only
the terminal-specific detail about how --via ssh interacts with MAC resolution,
then link to the constitution for the detailed CDB-first, ARP, and silent-swap
policies. At lines 91-95, similarly replace constitution restatement with a
terminal-specific summary and link to docs/CONSTITUTION.md for the full policy
context.

In `@src/resolver/mac.ts`:
- Around line 221-223: The error message returned in the "execute" case (around
line 221-223) contains outdated information stating that "mac-telnet L2 execute
is not yet available," which contradicts the current command capabilities and
misleads users. Update the return statement for the "execute" case to remove the
stale text about L2 execute being unavailable while preserving the valid
remediation suggestions about passing an IP/hostname, adding a CDB record, or
using host ARP resolution.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: c131fc8d-5950-4738-a375-020855577905

📥 Commits

Reviewing files that changed from the base of the PR and between cec184d and df170fb.

📒 Files selected for processing (8)
  • commands/terminal/README.md
  • commands/terminal/examples.md
  • src/cli/terminal.ts
  • src/resolver/mac.ts
  • src/terminal.ts
  • test/integration/cli-smoke.test.ts
  • test/unit/mac.test.ts
  • test/unit/terminal.test.ts

Comment thread commands/terminal/examples.md Outdated
Comment thread commands/terminal/README.md
Comment thread src/resolver/mac.ts Outdated
- src/resolver/mac.ts: drop the stale "mac-telnet L2 execute is not yet
  available" parenthetical — execute/mac-telnet is CHR-passed. DRY the
  remediation into a `macTelnetCapable` helper (retrieve = IP-first;
  execute/terminal = L2-first), applied to both the unresolved and
  not-in-arp branches.
- commands/terminal/README.md: trim the constitution-restating prose (CDB /
  ARP / no-silent-swap policy) to a terminal-specific summary + link to
  CONSTITUTION (Target selection grammar, Protocol selection).
- commands/terminal/examples.md: de-number TS4 → a non-spec behavior note, so
  numbered examples stay the CHR-integration-assertion set (it is verified by
  the network-free smoke tier + unit tests, not real CHR).

Skipped CodeRabbit's "also applies to README 91-95": that SSH-surface table row
is pre-existing and out of scope for this PR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mobileskyfi
mobileskyfi merged commit a1cfe40 into main Jun 16, 2026
9 checks passed
@mobileskyfi
mobileskyfi deleted the feat/terminal-resolve-jg01 branch June 16, 2026 15:44
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