Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,15 @@ jobs:
working-directory: crates/areev-js
run: cargo metadata --locked --format-version 1 > /dev/null

# The #201 parity test drives one capability tool from the binding AND
# from the CLI with the same declaration and grants, so the binary has
# to exist here; without it that leg is skipped with a diagnostic.
- name: Build the areev binary for the CLI parity leg
run: cargo build -p areev --locked
- name: Build the native addon + run smoke test
working-directory: crates/areev-js
env:
AREEV_BIN: ${{ github.workspace }}/target/debug/areev
run: |
npm ci
npx napi build --platform --release -- --locked
Expand Down
38 changes: 29 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,35 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
could not leave the session namespace, so a host recording calls into
per-domain child namespaces (`domain.phone`, `domain.spotify`) had to open a
second handle — which the single-writer registry refuses (`STO-E002`).
- **An empty `tool_env` / `toolEnv` in the bindings now means "clear to the
minimal set", as the CLI's `--tool-env ""` does** (#197). Both bindings
filtered the empty string out before building the policy, so the strictest
request — clear the environment, admit nothing beyond what a command needs
to start — was answered with the loosest posture, inherit everything. A host
wanting the clear-only policy had to name a variable already in the minimal
set just to select it. `None` / `null` keep the inherit default, unchanged.
Pinned in both bindings' tests, on the run executors and the trigger
connector.
- **The credential broker reaches the bindings and `areev serve`** (#201).
A `wasm32-areev-io` tool's `areev::fetch` is answered by the broker, and
the broker was built only from CLI flags — so a host driving runs through
Python or Node, which is what a service does, could persist a capability
tool, pin it, point at the sandbox, and still have every fetch fail. The
parser moved into `areev-run` as `EgressSpec`, the one behind
`--credential`/`--allow-host`/`--tool-egress`/`--credential-ttl`/
`--resolver-env`, and every surface calls it: the same-named parameters on
`run_start`, `run_resume`, `trigger_run` and `trigger_deliver` in both
bindings (`credentials`, `allow_hosts`, `tool_egress`, `credential_ttl_secs`,
`resolver_env`; camelCase in Node) take the flags' spec strings verbatim,
and `$AREEV_RUN_CREDENTIAL`, `$AREEV_RUN_ALLOW_HOST`,
`$AREEV_RUN_TOOL_EGRESS`, `$AREEV_RUN_CREDENTIAL_TTL` and
`$AREEV_RUN_RESOLVER_ENV` are the server-bound spellings for `areev serve`
— and the out-of-band fallbacks for the CLI, like the rest of the family.
The blob door (`{"blob": {"read": true}}`) is wired on the same path, a
refusal from a binding-driven run is journaled exactly as from the CLI
(`403` + `RUN-E022`, an Observation in `agent:harness`), and a parity test
drives one capability tool from Node, Python, the CLI and the MCP server
with one declaration and one set of grants.

### Changed

Expand Down Expand Up @@ -312,15 +341,6 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
`scripts/check_versions.py` asserts, alongside the other detached package
(`areev-js`), and it gained the `--version` flag that makes the pairing
checkable at all.
- **An empty `tool_env` / `toolEnv` in the bindings now means "clear to the
minimal set", as the CLI's `--tool-env ""` does** (#197). Both bindings
filtered the empty string out before building the policy, so the strictest
request — clear the environment, admit nothing beyond what a command needs
to start — was answered with the loosest posture, inherit everything. A host
wanting the clear-only policy had to name a variable already in the minimal
set just to select it. `None` / `null` keep the inherit default, unchanged.
Pinned in both bindings' tests, on the run executors and the trigger
connector.

## [1.7.3] — 2026-09-07

Expand Down
13 changes: 9 additions & 4 deletions crates/areev-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ COMMANDS:
command may itself contain '@'. --resolver-env names the variables
a resolver needs for its OWN authentication ($VAULT_TOKEN,
$AWS_PROFILE): they are withheld from every other subprocess and
re-admitted only for resolvers;
re-admitted only for resolvers. All five also read their
$AREEV_RUN_CREDENTIAL / _ALLOW_HOST / _TOOL_EGRESS /
_CREDENTIAL_TTL / _RESOLVER_ENV variable (the flag wins), which
is how `areev serve` and a heartbeat configure the broker;
--allow-executor pins the content address of a code-carrying tool
(a Definition whose executor_uri names a cas:// blob). Nothing
code-carrying runs unpinned, because the blob travels with the
Expand Down Expand Up @@ -1432,8 +1435,9 @@ fn run() -> Result<(), String> {
// entry in the list above (#100). `Credential::bearer_from_env` registers
// the core seam for every host that reads one; this adds the loop mirror,
// and does it HERE rather than in `build_egress` because the choke point
// runs before any verb arm can spawn.
if let Some(list) = flag(&flags, "credential") {
// runs before any verb arm can spawn. The variable spelling (#201) is
// read here too: a secret named out of band is still a secret.
if let Some(list) = run_stack::flag_or_env(&flags, "credential", areev_run::egress_spec::ENV_CREDENTIAL) {
for pair in list.split(',') {
if let Some((_, spec)) = pair.split_once('=') {
let spec = spec.trim();
Expand Down Expand Up @@ -1475,7 +1479,7 @@ fn run() -> Result<(), String> {
// environment would put it inside every `--tool-cmd` subprocess — the #100
// leak reopened one level up. Withheld from every child here, and
// re-admitted only for resolver spawns (`CredentialSource::spawn_policy`).
if let Some(list) = flag(&flags, "resolver-env") {
if let Some(list) = run_stack::flag_or_env(&flags, "resolver-env", areev_run::egress_spec::ENV_RESOLVER_ENV) {
for var in list.split(',').map(str::trim).filter(|v| !v.is_empty()) {
areev_core::proc::deny_env_var(var);
areev_loop::proc::deny_env_var(var);
Expand Down Expand Up @@ -2559,6 +2563,7 @@ Nothing was written — apply the snippet yourself (or rerun with your own paths
}
let facade = apply_principal(facade, &flags)?;
let mut server = areev_mcp::McpServer::new(facade, None)
.with_memory_path(&db)
.assembly_manifest_sample_rate(assembly_manifest_sample_rate(&flags)?);
if flags.contains_key("no-destructive-ops") {
server = server.allow_destructive_ops(false);
Expand Down
192 changes: 21 additions & 171 deletions crates/areev-cli/src/run_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,185 +57,35 @@ impl HostToolExecutor for NoExecutor {
}
}

/// `--credential name=ENV_VAR`, `--allow-host URL`, `--tool-egress
/// tool:cred+cred:METHOD+METHOD`. Returns None when no egress is configured,
/// which leaves tools exactly as they were.
pub fn build_egress(
flags: &HashMap<String, String>,
) -> Result<Option<areev_run::Broker>, String> {
let (creds, hosts, tools) =
(flag(flags, "credential"), flag(flags, "allow-host"), flag(flags, "tool-egress"));
if creds.is_none() && hosts.is_none() && tools.is_none() {
return Ok(None);
}
// How long a MINTED credential may be reused, and which variables a
// resolver may see (#113). Both are host config and apply to every
// dynamic source this process configures.
let ttl_secs = match flag(flags, "credential-ttl") {
/// `--credential`, `--allow-host`, `--tool-egress`, `--credential-ttl` and
/// `--resolver-env` — or their `$AREEV_RUN_*` variables — as one spec. The
/// parser lives in `areev-run` (#201) so the bindings and `areev serve` read
/// exactly this grammar; a flag wins over its variable, as everywhere here.
pub fn egress_spec(flags: &HashMap<String, String>) -> Result<areev_run::EgressSpec, String> {
let ttl = match flag(flags, "credential-ttl") {
None => None,
Some(v) => Some(
v.trim()
.parse::<u64>()
.map_err(|_| format!("--credential-ttl: expected whole seconds, got {v:?}"))?,
),
};
let resolver_env: Vec<String> = flag(flags, "resolver-env")
.iter()
.flat_map(|v| v.split(','))
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.collect();

let mut credentials = std::collections::BTreeMap::new();
// name -> owning run principal, for `--credential name=VAR@principal` and
// its source-agnostic sibling `--credential name@principal=…`.
let mut owners: Vec<(String, String)> = Vec::new();
for pair in creds.iter().flat_map(|v| v.split(',')) {
let pair = pair.trim();
if pair.is_empty() {
continue;
}
let (lhs, spec) = pair.split_once('=').ok_or_else(|| {
format!(
"--credential: expected name=ENV_VAR[@principal], name[@principal]=cmd:COMMAND, \
or name[@principal]=vault:PATH#FIELD, got {pair:?} — note that a comma \
separates credentials, so a resolver command containing one belongs in a script"
)
})?;
// The principal may be named on the NAME side, which is the only
// unambiguous place for a `cmd:` source: a command can contain '@'
// anywhere, so splitting one on it would bind the credential to a
// principal the operator never wrote (#113).
let (name, name_owner) = match lhs.trim().split_once('@') {
Some((n, p)) if !p.trim().is_empty() => (n.trim(), Some(p.trim().to_string())),
Some(_) => {
return Err(format!(
"--credential {pair:?}: empty principal after '@' — write name=SOURCE for an \
unbound credential, or name@principal=SOURCE to bind one"
))
}
None => (lhs.trim(), None),
};
if name.is_empty() {
return Err(format!("--credential {pair:?}: the credential has no name"));
}
// An env-var value is READ here from a variable the host named — a
// secret on a command line is a secret in shell history and in `ps`.
// A `cmd:`/`vault:` source reads nothing yet; it is minted per TTL
// window at call time, inside the broker.
let (source, spec_owner) = areev_run::CredentialSource::from_spec(spec.trim())?;
let owner = match (name_owner, spec_owner) {
(Some(_), Some(_)) => {
return Err(format!(
"--credential {pair:?}: names a principal on both sides of '=' — pick one"
))
}
(a, b) => a.or(b),
};
let name = name.to_string();
if let Some(o) = owner {
owners.push((name.clone(), o));
}
credentials.insert(name, source.with_resolver_config(ttl_secs, &resolver_env));
areev_run::EgressSpec {
credentials: flag(flags, "credential").filter(|v| !v.trim().is_empty()),
allow_hosts: flag(flags, "allow-host").filter(|v| !v.trim().is_empty()),
tool_egress: flag(flags, "tool-egress").filter(|v| !v.trim().is_empty()),
credential_ttl_secs: ttl,
resolver_env: flag(flags, "resolver-env").filter(|v| !v.trim().is_empty()),
}
let policy = match &hosts {
// Absent means unrestricted, and is reported as such rather than
// silently reading as a policy.
None => areev_run::EgressPolicy::unrestricted(),
Some(list) => {
let entries: Vec<serde_json::Value> = list
.split(',')
.map(str::trim)
.filter(|h| !h.is_empty())
.map(|h| serde_json::json!(h))
.collect();
areev_run::EgressPolicy::from_config(Some(&serde_json::json!({
"int:allowed_outbound_hosts": entries
})))?
}
};
let mut grants = areev_run::EgressGrants::new();
for spec in tools.iter().flat_map(|v| v.split(',')) {
let spec = spec.trim();
if spec.is_empty() {
continue;
}
// A URL anywhere in the spec is an operator writing `cred@https://host`
// for the #112 pairing. Split on ':' that would leave `https` sitting
// in the host position — a pairing that matches nothing while reading
// as a restriction. Caught here, where the whole spec is still intact
// and the message can say what to write instead.
if spec.contains("://") {
return Err(format!(
"--tool-egress {spec:?}: pair a credential with a BARE hostname \
(cred@api.example.com), not a URL — this spec is colon-delimited, so a scheme \
or port would tear it apart; scheme and port are narrowed by --allow-host"
));
}
let mut parts = spec.split(':');
let tool = parts.next().unwrap_or("").trim();
if tool.is_empty() {
return Err(format!(
"--tool-egress: expected tool:cred[@host]+cred[@host]:METHOD+METHOD, got {spec:?}"
));
}
let mut g = areev_run::CallerGrant::new();
for c in parts.next().unwrap_or("").split('+').map(str::trim) {
if c.is_empty() {
continue;
}
// `cred@host` pairs the credential with where it may be sent
// (#112); a bare `cred` keeps the older any-host meaning.
g = match c.split_once('@') {
Some((name, host)) => {
let name = name.trim();
if name.is_empty() {
return Err(format!(
"--tool-egress {spec:?}: {c:?} has no credential name before '@'"
));
}
let host = areev_run::AllowedHost::parse_host_pattern(host, "--tool-egress")?;
g.credential_for(name, vec![host])
}
None => g.credential(c),
};
}
for m in parts.next().unwrap_or("").split('+').map(str::trim) {
if m.is_empty() {
continue;
}
// Validated rather than accepted verbatim: an unrecognized token
// here used to become a method nothing would ever match, so a
// typo — or a port that survived the colon split — produced a
// grant that silently refused every write at runtime.
let upper = m.to_ascii_uppercase();
if !matches!(
upper.as_str(),
"GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE"
) {
// A field of digits is almost always a port that survived the
// colon split (`cred@host:8443`), so say that rather than
// leaving the operator to work back from "8443 is not a method".
let hint = if m.chars().all(|c| c.is_ascii_digit()) {
" — if you meant a port, drop it: a credential↔host pairing \
names the host, and the port is narrowed by --allow-host"
} else {
""
};
return Err(format!(
"--tool-egress {spec:?}: {m:?} is not an HTTP method; accepted: \
GET, HEAD, POST, PUT, PATCH, DELETE{hint}"
));
}
g = g.method(&upper);
}
grants = grants.grant(tool, g);
}
let broker = areev_run::Broker::start(policy, credentials, grants, "RUN-E022")?;
for (name, owner) in owners {
broker.bind_credential_owner(&name, &owner);
}
Ok(Some(broker))
.with_env_fallback()
}

/// The broker [`egress_spec`] describes, or None when it describes none —
/// which leaves tools exactly as they were.
pub fn build_egress(
flags: &HashMap<String, String>,
) -> Result<Option<areev_run::Broker>, String> {
egress_spec(flags)?.build()
}

/// `--executor-timeout`/`$AREEV_RUN_EXECUTOR_TIMEOUT`: the host override for
Expand Down
59 changes: 6 additions & 53 deletions crates/areev-cli/src/trigger_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,59 +176,12 @@ fn evaluator(
// Credentials are named on the command line and READ here, so a value
// never appears in a grain, in shell history, or in the connector's
// environment: `--credential gmail=GMAIL_TOKEN_VAR` names the variable.
//
// An unset variable is refused rather than dropped — the same rule
// `run start` and both bindings already applied. A silently dropped
// credential does not stay silent: it surfaces downstream as an
// unexplained 401 from someone else's API, hours later, on a heartbeat
// nobody is watching. `build_egress` above validated the same list, so
// this cannot reach a different verdict; it is spelled out rather than
// assumed, because the two would drift the first time either moved.
// Resolver settings ride with each dynamic source, exactly as they do on
// the run path — one parse, one meaning, both hosts.
let ttl_secs = match flag(flags, "credential-ttl") {
None => None,
Some(v) => Some(
v.trim()
.parse::<u64>()
.map_err(|_| format!("--credential-ttl: expected whole seconds, got {v:?}"))?,
),
};
let resolver_env: Vec<String> = flag(flags, "resolver-env")
.iter()
.flat_map(|v| v.split(','))
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.collect();
let mut credentials = std::collections::BTreeMap::new();
if let Some(spec) = flag(flags, "credential") {
for pair in spec.split(',') {
let pair = pair.trim();
if pair.is_empty() {
continue;
}
let (lhs, spec) = pair.split_once('=').ok_or_else(|| {
format!(
"--credential: expected name=ENV_VAR[@principal], \
name[@principal]=cmd:COMMAND, or name[@principal]=vault:PATH#FIELD, \
got {pair:?}"
)
})?;
// The `@principal` owner qualifier governs a credential's use in a
// started RUN, and is enforced on that run's broker (built by
// `build_egress` above). This is the connector-poll broker — the
// trigger's own standing egress, not a per-user run — so the owner
// is parsed off and dropped here rather than breaking the read.
// Both spellings are dropped: on the name side (any source) and on
// the value side (the env-var form's own grammar).
let name = lhs.trim().split_once('@').map(|(n, _)| n).unwrap_or(lhs).trim();
let (source, _owner) = areev_run::CredentialSource::from_spec(spec.trim())?;
credentials.insert(
name.to_string(),
source.with_resolver_config(ttl_secs, &resolver_env),
);
}
}
// An unset variable is refused rather than dropped. The `@principal`
// owner governs a credential's use in a started RUN, enforced on that
// run's broker (built by `build_egress` above); this is the connector-poll
// broker — the trigger's own standing egress — so the owner is dropped.
// ONE parser for both (#201), so they cannot reach different verdicts.
let credentials = run_stack::egress_spec(flags)?.unowned_credentials()?;

Ok((
Evaluator {
Expand Down
Loading