Add completions: ip netns - #313
Conversation
Covers the full ip/ipnetns.c action set: list/show/lst, add, attach, set, delete/del, identify, pids, exec, monitor, and list-id, plus help. Existing namespace-name positions reuse the existing "netns" generator (ip netns list); a new "processes" generator (ps -eo pid,comm) backs the PID positions in attach/identify, since those accept any running process, not just namespace-linked ones. New-name positions (add, attach's NAME) are left without a generator. Verified against iproute2's ip/ipnetns.c and man/man8/ip-netns.8.in (iproute2/iproute2 main branch). Co-Authored-By: Warp Agent <agent@warp.dev>
Warp's completer only ever suggests dash-prefixed strings for `options` entries (short_hand_flag_suggestions() requires a leading '-'), so bare keywords like 'target-nsid' and 'nsid' were completely unreachable. Subcommand matching has no dash requirement, so these now live under 'subcommands' instead, matching the same fix applied to ip rule/tunnel/xfrm/monitor in #311. Co-Authored-By: Warp Agent <agent@warp.dev>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds ip netns command completions, including namespace management subcommands and a new processes generator for PID arguments. The Rust parser is covered by focused unit tests, and the added comments align with the surrounding code's explanatory style.
Concerns
- No blocking correctness, security, comment-quality, test-quality, or spec-drift concerns found in the attached diff.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
Reviewed post-merge, having adopted this for warp#9765 / APP-3982. The grammar, aliases, argument arity and generator wiring all check out against upstream One residual gap: the new Responding as wilson: Open session · View factory task |
Part 1 - defects confirmed live on main: - ip ntable: add missing 'ntbl' alias (upstream ip/ip.c maps both ntable and ntbl to do_ipntable; lookup is exact so ntbl reached nothing). Review flagged on #321. - ip tcpmetrics: add missing 'addr' alias to the address selector on show, delete, and flush (tcp_metrics.c accepts addr and address interchangeably). Review flagged on #323. - ip tuntap delete: remove user/group (do_del() passes null user/gid pointers to parse_args, which silently skips those branches) and add pi/one_queue/vnet_hdr/multi_queue, which parse_args does accept on delete. Review flagged on #313 and #321. - ip tunnel change: add seq/iseq/oseq/csum/icsum/ocsum, mirroring 'tunnel add' (iptunnel.c's parse_args accepts these for both add and change). Review flagged on #310/#311. Part 2 - salvaged from PR #322 (factory/ip-remaining-subcommands-v2), verified against upstream before porting: - ip nexthop add|replace group: nest the resilient-group grammar (type with buckets/idle_timer/unbalanced_timer, plus fdb) under 'group', matching 'ip nexthop add id N group G type resilient buckets B' from ip-nexthop(8) and ipnexthop.c. Left the existing top-level type/hw_stats siblings untouched. - ip mrule save / ip mrule restore: ip/iprule.c's do_iprule (compiled for RTNL_FAMILY_IPMR to back ip mrule) supports flush/save/restore identically to ip rule. - ip macsec add|set rx sci: nest on/off/sa (with the same pn/xpn/ salt/ssci/key/on/off options already modeled on the sibling top-level sa) under sci, matching 'ip macsec add DEV rx SCI sa {0..3} ...' from ip-macsec(8). ip macsec del rx sci: nest sa (AN only). Left the existing port/address/sa siblings untouched. Rejected from #322: the macsec offload value suggestions (mac/off/phy) are already present on main via #321's args array, so nothing to port there. Co-Authored-By: Warp Agent <agent@warp.dev>
## Description Updates `warp-command-signatures` from `fe352669` to `77c4a9a7`. This is the bump that actually delivers the `ip` completions work to users. Before it, every `ip` subcommand in the pinned spec was a bare leaf with no nested actions, options, or argument completions; after it, all 29 are filled in. ### Merged PRs - Add git read-tree completions (warpdotdev/command-signatures#296) - Add completions: ip rule, tunnel, xfrm, monitor (warpdotdev/command-signatures#310) - Fix ip rule/tunnel/xfrm/monitor completions: model bare keywords as subcommands (warpdotdev/command-signatures#311) - Add completions: ip neighbour (neigh) (warpdotdev/command-signatures#312) - Add completions: ip netns (warpdotdev/command-signatures#313) - Add completion spec: ip address (addr, a) (warpdotdev/command-signatures#315) - Add completion spec: ip route (warpdotdev/command-signatures#317) - Add completions: ip link (warpdotdev/command-signatures#318) - Add the neighbor (US spelling) alias to the ip neigh spec (warpdotdev/command-signatures#320) - Add completions for remaining ip subcommands (warpdotdev/command-signatures#321) - Fix ip neighbour completions: add 'neighbor' alias and full rt_protos vocabulary (warpdotdev/command-signatures#323) - Fix ip address completions: alias addr/a, local/dev keywords, nowhere scope, negated flags, accurate save (warpdotdev/command-signatures#324) - ip: fix macsec rx SCI chaining, ntable/tcp_metrics aliases, tuntap delete flags (warpdotdev/command-signatures#325) - ip tunnel: add interface generator to 'tunnel show NAME' (warpdotdev/command-signatures#326) - ip: add remaining nexthop/mrule/tunnel gaps, fix tunnel-show generator regression from #326 (warpdotdev/command-signatures#327) ### Worth knowing for review Two behaviors of this client's completer shaped the spec, and are worth being aware of when reading it: - Bare non-dash keywords must be modeled as `subcommands`, not `options`. `short_hand_flag_suggestions()` in `crates/warp_completer/src/completer/engine/flag/v2.rs` returns empty for any non-dash token, and only emits names satisfying `is_short_hand_flag_name()` or `is_long_hand_flag_name()`, both of which require a leading `-`. iproute2's grammar is almost entirely bare keywords, so an early version of this work was silently invisible until #311 remodeled it. - Only the first bare keyword after a verb completes. `deepest_matching_subcommand_signature()` in `crates/warp_completer/src/signatures/v2/lookup.rs` returns the matched subcommand alone, so its siblings stop being candidates — `ip rule add iif eth0 from <Tab>` offers nothing. That is an engine limitation rather than a spec one, tracked separately in #15048. It is not a regression: before this work none of these keywords completed at all. ## Linked Issue Delivers #9764, #9765, #9766, #9767, #9768, #9769. Follow-ups tracked in #15046 (IPv6 tunnel modes) and #15048 (chained-keyword completion). - [x] The linked issue is labeled `ready-to-implement`. - [x] Where appropriate, screenshots or a short video of the implementation are included below. ## Testing - [ ] I have manually tested my changes locally with `./script/run` This change is a dependency rev bump: two lines in `Cargo.toml` and `Cargo.lock`, no source changes. `cargo metadata` resolves cleanly against the new rev. The completions themselves were verified end to end against a locally built client earlier in this work, by pointing `warp-command-signatures` at a local checkout and exercising the dropdown. That is what caught the modeling bug fixed by #311. Evidence, including the before/after comparison on one build with only the spec crate swapped, is attached to warpdotdev/command-signatures#311. Being explicit about the gap: I did not run a full local `./script/run` or `cargo clippy` for this bump. The sandbox this was prepared in has 3 GB of RAM and the OOM killer terminates rustc partway through compiling the `warp` crate. Since the diff is a dependency rev with no source changes, CI is the meaningful gate here — but a reviewer who wants a local sanity check should run one before merging. ### Screenshots / Videos Completions dropdown verification is on warpdotdev/command-signatures#311. ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode CHANGELOG-IMPROVEMENT: Added completions for `ip` — `address`, `link`, `route`, `neighbour`, `netns`, `rule`, `tunnel`, `xfrm`, `monitor` and the remaining subcommands — plus `git read-tree`. CHANGELOG-BUG-FIX: Fixed `ip` completions not appearing for iproute2's bare keyword arguments, along with missing `ip addr`/`ip a`/`ip neighbor` aliases and several suggestions that iproute2 rejects. Co-authored-by: Oz <oz-agent@warp.dev> Co-authored-by: Warp Agent <agent@warp.dev>
Summary
Adds nested completions for
ip netns(issue warpdotdev/warp#9765, Linear APP-3982): manage network namespaces (list, add, delete, exec, etc.).Stacked on #310 (
Add completions: ip rule, tunnel, xfrm, monitor), which has already merged intomain. This PR is based onmain(which now includes #310's work, including thenetwork_interfacesgenerator) since #310's feature branch was deleted after merge. No changes were made to anything #310 added.Update: a later verification pass found that Warp's completer never suggests bare (non-dash) keywords modeled as
optionsentries — onlysubcommandsentries are matched without a dash requirement. This is being fixed forip rule/tunnel/xfrm/monitorin #311. Mynetnssubtree had one instance of the same bug (list-id'starget-nsid/nsidkeywords), which is now fixed here to usesubcommandsinstead ofoptions, matching #311's pattern.Changes
command-signatures/json/ip.json: fills in thenetnssubcommand with its full action set from upstreamip/ipnetns.c'sdo_netns()dispatch:list/show/lst,add,attach,set,del/delete,identify,pids,exec,monitor,list-id(with itstarget-nsid/nsidkeywords modeled assubcommands, notoptions, since they're bare keywords), andhelp.command-signatures/src/generators/ip.rs: adds a newprocessesgenerator (parsesps -eo pid,comm) for thePIDpositions inattachandidentify, since those accept the PID of any running process on the system, not one already tied to a namespace. Includes unit tests.del/delete NAME,set NAME,pids NAME,exec [NAME]) reuse the pre-existingnetnsgenerator (ip netns list), which was already wired up for the global-n/-netnsoption. New-name positions (add NAME,attach's firstNAMEarg) intentionally have no generator, since they expect a name that doesn't exist yet.Sources verified
ip/ipnetns.candman/man8/ip-netns.8.infrom iproute2/iproute2 (mainbranch), specifically theusage()string anddo_netns()dispatch table, which enumerate the full action set including the easy-to-forget ones (exec,pids,identify,set,attach,monitor,list-id).del/deletedual-alias convention already established forip rulein this repo (upstream'smatches()does prefix matching, sodelis technically accepted as an abbreviation ofdelete, same as forip rule).Deliberately left out
netnsactions are recent additions;list-id,attach, andidentifyhave all been present for many releases.add/attach's new-name positions, since they must not already exist.ip netns list-id target-nsid 12 nsid <Tab>won't complete — this is a spec-independent engine constraint, not something fixable here.Verification
npm run format:check— passes.cargo fmt --check— passes.cargo clippy --all-targets -- -D warnings— passes, no warnings.cargo test --workspace— all 137 tests pass, including the 4 newparse_processesunit tests, plus the repo's invariant tests (everygeneratorNameexists, all specs deserialize, no unquoted newlines in generator commands).ps -eo pid,commoutput format assumed by the new generator matches this sandbox'sps.netns/processesgenerators. Noting this honestly per the task instructions — screenshots are being captured separately.