feat(host): add IP-literal blocking TCP resource endpoint (P5)

- resource.open("tcp", ip:port, ["read","write"]) with exact IP grants,
  project mode only, 5s connect/read/write timeouts; no DNS/TLS/UDP/server
  sockets (ADR-0034).
- Add TCP stream storage/dispatch in the resource table; CLI --allow-net IP;
  pure/strict preflight rejects the grant and the language endpoint.
- Host loopback echo/grant/DNS/strict tests and a .mq.md CLI echo test.
- Update specs, status, architecture, README, changelog and evidence.

Gate: fmt, clippy -D warnings, 426 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 23:05:06 +08:00
1 parent 1d87f98539
commit 00bdcad1ff
15 files changed
+435 -4

No files matched your search

+7
View File
@@ -22,6 +22,8 @@ pub struct SandboxSettings {
pub allow_read: Vec<String>,
/// Write grants.
pub allow_write: Vec<String>,
/// Network grants (IP literals, ADR-0034).
pub allow_net: Vec<String>,
/// Foreign execution grant.
pub allow_foreign: bool,
/// Plugin grants.
@@ -70,6 +72,7 @@ impl SandboxSettings {
pub fn strict_preflight(&self) -> Result<(), String> {
let requested = self.allow_foreign
|| !self.allow_read.is_empty()
|| !self.allow_net.is_empty()
|| !self.allow_write.is_empty()
|| !self.allow_plugin.is_empty()
|| !self.plugins.is_empty()
@@ -94,6 +97,7 @@ impl SandboxSettings {
match mode {
SandboxMode::Pure => {
if !self.allow_read.is_empty()
|| !self.allow_net.is_empty()
|| !self.allow_write.is_empty()
|| self.allow_foreign
|| !self.allow_plugin.is_empty()
@@ -112,6 +116,9 @@ impl SandboxSettings {
for pattern in &self.allow_write {
capabilities = capabilities.allow_write(pattern.clone());
}
for host in &self.allow_net {
capabilities = capabilities.allow_net(host.clone());
}
if self.allow_foreign {
capabilities = capabilities.allow_foreign();
}