Add std/net IPAM helpers and explicit reachability probes#113
Merged
Conversation
Contributor
Greptile SummaryThis PR adds the first
Confidence Score: 5/5This looks safe to merge.
Reviews (14): Last reviewed commit: "refactor: simplify std net reachability ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR introduces the first phase of a new std/net standard-library module, adding deterministic IPv4/IPv6 IPAM helpers plus a ping(host, opts?) reachability probe with a default unprivileged TCP fallback, and wires the module through runtime registration, typechecker signatures, docs, and examples.
Changes:
- Add
src/stdlib/net.rsimplementing IP/CIDR helpers (ip_parse,subnet_contains,subnet_overlaps,subnet_split,subnet_supernet,subnet_summarize,ip_range_to_cidrs) andping()(TCP-based Phase 1). - Register
std/netin the stdlib module registry and in the typechecker module-signature map. - Add integration/typechecker tests, a runnable example, and refresh generated docs + design/AI guide documentation; bump version to
0.4.10.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/type_checker_tests.rs | Adds lint/typechecker coverage for std/net signature acceptance/rejection. |
| tests/std_net_tests.rs | Adds integration tests exercising std/net runtime behavior (IPAM fields + ping policy). |
| src/typechecker.rs | Registers std/net function signatures for lint/typechecking. |
| src/stdlib/net.rs | Implements the std/net module (IPAM helpers + TCP-based ping + policy checks). |
| src/stdlib/mod.rs | Registers std/net in the runtime stdlib module map. |
| examples/std_net_ipam.tnt | Adds a runnable example showcasing IPAM helpers. |
| docs/SYNTAX_REFERENCE.md | Updates generated “Last updated” version marker to v0.4.10. |
| docs/STDLIB_REFERENCE.md | Adds generated std/net API reference section. |
| docs/RUNTIME_REFERENCE.md | Updates generated “Last updated” version marker to v0.4.10. |
| docs/IAL_REFERENCE.md | Updates generated “Last updated” version marker to v0.4.10. |
| docs/AI_AGENT_GUIDE.md | Documents std/net usage and private-target opt-in guidance. |
| design-docs/README.md | Adds entries for DD-046/DD-047 in the design-doc index. |
| design-docs/dd-047-std-netmon.md | Adds a new draft design doc for a future std/netmon module. |
| design-docs/dd-046-std-net.md | Updates/expands the std/net design doc to reflect Phase 1 implementation. |
| Cargo.toml | Bumps crate version to 0.4.10. |
| Cargo.lock | Updates locked crate version to 0.4.10. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
std/netPhase 1 with IPv4/IPv6 IPAM helpers:ip_parse,subnet_contains,subnet_overlaps,subnet_split,subnet_supernet,subnet_summarize, andip_range_to_cidrs.ping(host, opts?)protocol-honest: Phase 1 returns a clear ICMP-unavailableErr(String)instead of silently switching to TCP.tcp_connect(host, port, opts?)for one chosen TCP port, returningconnected, latency/attempt summaries, andOk(... connected: false ...)for ordinary refused/timeout outcomes.reachable(host, opts?)for high-level reachability fallback, requiring caller-providedtcp_portsand reportingmethod: "tcp"plusfallback_from: "icmp"instead of calling TCP “ping.”std/netin the stdlib/typechecker, generate stdlib docs, update the AI guide/design doc, and keep the runnable IPAM example.Safety / behavior notes
ping()and no random default ports.NTNT_NET_ALLOW_PRIVATE=1or existing private-IP env) plus per-callallow_private: true.tcp_connect()treats refused/timeout/closed ports as data (Ok(map { "connected": false, ... })), while invalid input, resolver/system failure, or policy denial remainErr(String).Verification
cargo fmt -- --checkgit diff --checkcargo build --profile dev-releasecargo testcargo test --test std_net_tests -- --nocapturecargo test --lib stdlib::net::tests -- --nocapture./target/dev-release/ntnt docs --generate./target/dev-release/ntnt validate examples/./target/dev-release/ntnt lint examples/(0 errors; existing suggestions/warnings only)tcp_connect/reachableimports pass and badtcp_connect(..., "443")is rejected asexpected Int, got StringDesign status
ping()+ explicittcp_connect()+reachable().