Skip to content

Commit 5b21b4d

Browse files
committed
areev pack: validate, install, export (#178)
A pack is an installable agent: a manifest, the grains it seeds, and the code blobs those grains name. It replaces the installer everyone deploying an agent was otherwise writing -- blobs into the CAS, each `executor_uri` rewritten to the address the bytes turned out to have, grains seeded in dependency order, plan hashes checked -- with one verb, so self-hosters get the same door a managed deployment does. Three properties make it more than a script. References are SYMBOLIC (`blob:<name>`, `grain:<id>`). An address is a measurement of bytes, not something an author can write down: install stores the blob, learns its address, rewrites the Definition, addresses *that*, and rewrites the plan that binds it. Grains are addressed in manifest order and a forward reference is refused rather than guessed at, which is why `grains` is an ordered list and not a set. It also means editing a connector's wasm changes the plan's hash -- the property that makes the next one worth having. `expected_hash` is REFUSED, not warned, with nothing written. A plan installed at a different address than the deployment expects has changed what runs, and everything pointing at the old hash -- triggers above all, which do not follow heads -- is now pointing elsewhere. Install is validate plus a destination. Every grain is built and addressed with NO store at all, since content addressing is a pure function of the serialized grain, so `pack validate` opens no memory, creates no file, and can run in CI on a pull request; a refused pack leaves the memory exactly as it found it (half an agent is worse than none). Export writes either reviewable grain JSON, refusing to write anything it cannot rebuild to the same address, or a bundle plus a manifest of what it must contain. Saved queries and templates travel too, or an installed agent loses the context assembly its triggers name. The pins it prints are exactly the addresses some Definition names as its `executor_uri` -- never the data blobs a pack also carries, since asking an operator to authorize data as executable is asking for the wrong permission. Every agent under `examples/agents/` now ships a `pack/`, EXPORTED from its own freshly seeded memory rather than written by hand, because the grains a pack installs and the grains a seeder writes have to be the same grains and the only way to keep them the same is to derive one from the other. `run-smokes.sh` gained a `pack` lane asserting each installs the plan its language stacks mint. That lane immediately earned itself: `sanctions-screening` stamped its evalset Fact -- the gate Rule E1 pins on the `screen` tool -- with the wall clock, so the tool's hash and therefore the desk's plan hash differed on every seed. Nothing had caught it because the cross-stack comparison needs two stacks and that desk has one. The seeder now pins `created_at` like every other grain it writes, and the desk records a wider `cold_grains` window beside its existing `run_outcome` tuning: its evalset is reference data read by the gate at review time, so "never recalled in 30 days" measures the wrong thing for it -- and retiring an evalset would remove the gate a code revision has to pass. Two hand-written packs land as examples, both keyless and offline and both in CI. `examples/grain-connector/` is #185's acceptance: a polling trigger whose connector is a pinned wasm blob, with no host connector script anywhere, and the `TRG-E012` refusal a host that pinned nothing gets. `examples/blessed-tools/` is #179's: a pack binding the shipped `http.call` blob with declared hosts, one permitted call (200 -- and the stub 401s anything without the exact bearer token, so that is the proof the broker attached a credential the tool never held), one call to an undeclared host refused by the broker with `RUN-E022`, and `areev tool provenance` chaining the blob. Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8 Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
1 parent e867c8d commit 5b21b4d

154 files changed

Lines changed: 143323 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ jobs:
289289
# the hashes). `invoice-to-accounting` ships Python + TypeScript + Rust;
290290
# the other agents are Python, and run-smokes.sh skips a stack an agent
291291
# does not have before it ever consults REQUIRE, so adding a language is
292-
# a wrapper plus an agent file and needs no edit here.
292+
# a wrapper plus an agent file and needs no edit here. Since #178 each
293+
# agent also ships an installable `pack/`, and the pack lane asserts it
294+
# installs that same plan.
293295
# An untested example in the flagship repo is wrong at exactly the
294296
# moment somebody is evaluating, so the promise is a job, not a README
295297
# claim — the SAME entry point a developer runs locally before pushing
@@ -314,15 +316,38 @@ jobs:
314316
maturin develop --release -m crates/areev-py/Cargo.toml
315317
- name: Build the Node binding (napi)
316318
run: cd crates/areev-js && npm ci && npm run build
319+
# The pack lane needs the binary (the language stacks do not). It
320+
# installs each agent's `pack/` into a scratch memory and asserts it
321+
# carries the plan the stacks mint — which is what goes stale when a
322+
# seeder changes and `export-packs.sh` was not re-run.
323+
- name: Build the areev binary (for the pack lane)
324+
run: cargo build -p areev
317325
# Both acts of every agent, in all three stacks, plus the
318-
# cross-language plan-hash comparison. CARGO_TARGET_DIR points the
319-
# detached Rust stack at the cached workspace target so its path deps
320-
# do not recompile from scratch.
321-
- name: Every agent, every language — smoke + improve
326+
# cross-language plan-hash comparison and the pack lane.
327+
# CARGO_TARGET_DIR points the detached Rust stack at the cached
328+
# workspace target so its path deps do not recompile from scratch.
329+
- name: Every agent, every language — smoke + improve + pack
322330
run: |
323331
. .venv/bin/activate
324-
CARGO_TARGET_DIR="$PWD/target" REQUIRE="python typescript rust" \
332+
CARGO_TARGET_DIR="$PWD/target" REQUIRE="python typescript rust pack" \
325333
examples/agents/run-smokes.sh
334+
# The grain-connector example is the keyless proof that a trigger can
335+
# run code that lives in the memory (#185) — pin, sandbox, capability,
336+
# cursor, dedup, run start, with no host connector script. It needs the
337+
# sandbox binary, which no other example does.
338+
- name: Build the sandbox (for the grain-connector example)
339+
run: cargo build --manifest-path areev-sandbox/Cargo.toml
340+
- name: A connector that is a grain, end to end
341+
run: |
342+
AREEV_SANDBOX="$PWD/areev-sandbox/target/debug/areev-sandbox" \
343+
examples/grain-connector/run.sh
344+
# And the other half of the same tier: a pack binding the blessed
345+
# http.call blob, one permitted call and one refused by the broker
346+
# (#179). Loopback only — the "upstream" is a stub in the example.
347+
- name: The blessed http.call blob, permitted and refused
348+
run: |
349+
AREEV_SANDBOX="$PWD/areev-sandbox/target/debug/areev-sandbox" \
350+
examples/blessed-tools/run.sh
326351
327352
tls:
328353
# The non-default native-TLS feature (the recorded rustls exception):
@@ -386,18 +411,35 @@ jobs:
386411
# (it carries wasmi). `cargo test --workspace` never touches it, so it needs
387412
# its own job or a change here can break it silently — the same reason
388413
# areev-js has one.
414+
#
415+
# The blessed tools (areev-tools) ride along: their tests ARE sandbox tests
416+
# (`tests/blessed_tools.rs` runs the committed blobs under the real engine),
417+
# and the manifest check asserts that what dist/blessed.json publishes is the
418+
# address of the file beside it — a pack pins that address, so a drifted
419+
# manifest is a pack pinning bytes nobody reviewed.
389420
sandbox:
390-
name: sandbox (wasm tier C)
421+
name: sandbox (wasm tier C) + blessed tools
391422
runs-on: ubuntu-latest
392423
steps:
393424
- uses: actions/checkout@v7
394425
- uses: dtolnay/rust-toolchain@stable
426+
with:
427+
targets: wasm32-unknown-unknown
395428
- name: build
396429
run: cargo build --manifest-path areev-sandbox/Cargo.toml
397-
- name: test
430+
- name: the published addresses are the addresses of the committed blobs
431+
run: python3 areev-tools/manifest.py --check
432+
- name: test (includes the blessed blobs, run under the real engine)
398433
run: cargo test --manifest-path areev-sandbox/Cargo.toml
399434
- name: clippy
400435
run: cargo clippy --manifest-path areev-sandbox/Cargo.toml --all-targets -- -D warnings
436+
# The SOURCE still has to compile and lint — a blob nobody can rebuild is
437+
# a blob nobody can revise, which is the whole point of putting connector
438+
# code in the memory (#179, #185).
439+
- name: the tool sources still build for wasm32
440+
run: cd areev-tools && cargo build --release --target wasm32-unknown-unknown
441+
- name: clippy (tool sources)
442+
run: cd areev-tools && cargo clippy --release --target wasm32-unknown-unknown -- -D warnings
401443

402444
# The version lives in five places and only one of them is inherited
403445
# (`version.workspace`). maturin reads pyproject.toml, npm reads

‎ARCHITECTURE.md‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,76 @@ field no grain carries is now `CAL-W018` — the same "absence is UNKNOWN, and
19311931
the answer says so" rule the #207 amendment above applies to `WHERE`, applied
19321932
to the grouping path.
19331933

1934+
### A connector is a grain, a pack is how it arrives, and three blobs are shared
1935+
1936+
**Decision (2026-09-09, issues #185/#178/#179):** three changes that only make
1937+
sense together — the code an agent runs, how it is installed, and what it does
1938+
not have to be written from scratch.
1939+
1940+
**A trigger may name its connector by content address** (`connector_tool`,
1941+
#185). Until now the one piece of code most likely to be wrong — cursors,
1942+
pagination, a provider's quirks — was the one piece that lived *outside* the
1943+
memory, as a `--connector-cmd` host script: it did not travel in a bundle,
1944+
`tool provenance` could not chase it, and the loop could not propose a
1945+
`code_revision` against it. A trigger now names a Tool **Definition** (never a
1946+
`cas://` blob directly: the runtime, the limits and the `capabilities`
1947+
declaration live on the Definition, and a second place to write them would be a
1948+
second place for them to disagree), and the evaluator resolves it through
1949+
`areev_run::pin_from_definition` — the same reader `RunManifest::resolve` uses,
1950+
because a connector running under different rules than a node binding the same
1951+
grain would be a second implementation of the pin, and the one that drifts
1952+
silently is the heartbeat nobody watches.
1953+
1954+
The authorization does not travel with the code. `--allow-executor` on the
1955+
evaluating host is what runs it, exactly as on the run path; `TRG-E012` refuses
1956+
by name before a broker starts. `connector` (the name) stays required beside
1957+
it, because the run id is derived from `(trigger, connector, dedup value)` and
1958+
revising the code must not renumber the runs.
1959+
1960+
**A pack is the installable unit** (`areev pack validate|install|export`,
1961+
#178). Everyone deploying an agent was writing the same installer: blobs into
1962+
the CAS, each `executor_uri` rewritten to the address the bytes turned out to
1963+
have, grains seeded in dependency order, plan hashes checked. Two properties
1964+
make it more than a script. References are **symbolic** — `blob:<name>`,
1965+
`grain:<id>` — because an address is a measurement of bytes and not something
1966+
an author can write down, which also means editing a connector's wasm changes
1967+
the plan's hash. And `expected_hash` is **refused, not warned**, with nothing
1968+
written: a plan that installed at a different address than the deployment
1969+
expected has changed what runs, and every trigger pointing at the old hash is
1970+
now pointing elsewhere (triggers do not follow heads). Install is validate plus
1971+
a destination — every grain is built and addressed with no store at all, since
1972+
content addressing is a pure function of the serialized grain — so a CI check
1973+
and a deployment cannot disagree about what a pack contains.
1974+
1975+
**Three blessed `wasm32-areev-io` blobs ship in the repository** (`http.call`,
1976+
`mcp.call`, `a2a.call`, #179), content-addressed, with their addresses
1977+
published in `areev-tools/dist/blessed.json`. The point is not convenience: a
1978+
tool gateway that decides *where a request may go* is code that everyone
1979+
installing it has to trust, and `http.call` makes no such decision — it hands
1980+
the request to the broker and the answer back, verbatim, both ways. Where it
1981+
may go, which method, which credential, which headers are the Definition's
1982+
`capabilities` and the host's grant: data, in the memory, replicated with the
1983+
tool, auditable without reading any code. The gateway becomes configuration.
1984+
Two Definitions may name the same blob with different declarations, which is
1985+
the shape a fleet wants — one address to pin, one blob to review, a per-service
1986+
policy the memory states out loud.
1987+
1988+
They are `no_std`, dependency-free and small (`http.call` is 2.6 KB) because a
1989+
blessed blob is reviewed as bytes; their JSON handling is a *slicer* that
1990+
copies a caller's `arguments` object into the request byte for byte rather than
1991+
a parser that round-trips it. `areev-tools/` is a standalone workspace for the
1992+
same reason `areev-sandbox` and `areev-js` are, and the blobs are tested where
1993+
the engine is: `areev-sandbox/tests/blessed_tools.rs` runs the **committed
1994+
bytes** under real wasmi against a loopback broker stand-in, asserting the
1995+
import gate holds — a tool that declared no network does not get `areev::fetch`
1996+
linked at all.
1997+
1998+
**What this deliberately does not do.** No registry, no resolver, no version
1999+
ranges: a pack names blobs by address and grains by the address they build to,
2000+
and "which pack is installed" is answered by asking the memory what it holds. A
2001+
package manager would put a mutable name in front of an immutable address,
2002+
which is the one thing this data model exists not to do.
2003+
19342004
### Portability and provenance over lock-in
19352005

19362006
Grains are content-addressed, immutable, and hash-linked; the format reserves

‎CHANGELOG.md‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,118 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

99
### Added
1010

11+
- **A trigger can name its connector by content address** (#185). A polling
12+
connector was a host command (`--connector-cmd`), which put the code most
13+
likely to be wrong — cursors, pagination, a provider's quirks — outside the
14+
memory: it did not travel in a bundle, `areev tool provenance` could not
15+
chase it, and the loop could not propose a `code_revision` against it. A
16+
Trigger now carries **`connector_tool`**, a reference to a Tool Definition
17+
whose `executor_uri` is the blob:
18+
19+
```bash
20+
areev trigger add --type polling --workflow <PLAN> --observer gmail \
21+
--connector-tool <DEFINITION> --interval 900 --dedup-key /message_id \
22+
--because "the AP desk watches this mailbox"
23+
24+
areev trigger run --allow-executor <64 hex> --sandbox-cmd areev-sandbox
25+
```
26+
27+
A Definition rather than a `cas://` blob directly, because the runtime, the
28+
limits and the `capabilities` declaration that decides where the code may
29+
reach live on the Definition — a second place to write them would be a second
30+
place for them to disagree. The evaluator reads it through the *same*
31+
`pin_from_definition` `RunManifest::resolve` uses, and dispatches through the
32+
same `CodeExecutor`, so the sandbox argv, the capability registration and the
33+
cleared environment are one implementation rather than a second that drifts
34+
on the surface nobody watches.
35+
36+
**The authorization does not travel with the code.** `--allow-executor` on
37+
the evaluating host is what runs it; without it the poll refuses with the new
38+
**`TRG-E012`**, naming the address to pin, before a broker is started and
39+
before anything is spent. The same code covers a Definition carrying no
40+
`executor_uri`, a declared runtime with no `--sandbox-cmd`, and a
41+
blob-reading module on an evaluator wired no memory locator. `connector` (the
42+
name) stays required beside `connector_tool`: the run id is derived from
43+
`(trigger, connector, dedup value)`, so revising the code must not renumber
44+
the runs. Both bindings take the same pin on `trigger_run`/`trigger_deliver`
45+
(`allow_executor`, `sandbox_cmd`, `executor_cache`, `executor_timeout_secs`),
46+
each reading its `$AREEV_RUN_*` variable, because a heartbeat is a cron line.
47+
`trigger show` now prints the connector and, when it is a grain, says so.
48+
`examples/grain-connector/` runs the whole path keyless and offline.
49+
50+
*Breaking for direct constructors:* `areev_trigger::Evaluator` gained a
51+
`connector_code` field. A host that runs host-command connectors only passes
52+
`None` — and a trigger naming a connector Definition then refuses rather than
53+
falling through to `--connector-cmd`, because a fallback would run a
54+
different program than the declaration names.
55+
56+
- **`areev pack validate | install | export`** (#178) — a pack is an
57+
installable agent: a manifest, the grains it seeds, and the code blobs those
58+
grains name. It replaces the installer everyone was writing (blobs into the
59+
CAS, `executor_uri` rewritten to the address the bytes turned out to have,
60+
grains seeded in order, plan hashes checked) with one verb, and self-hosters
61+
get the same door a managed deployment does.
62+
63+
```bash
64+
areev pack validate ./pack # opens no memory at all
65+
areev pack install ./pack --db agent.db # refuses on a hash mismatch
66+
areev pack export --db agent.db --ns ops --out ./pack
67+
```
68+
69+
References are **symbolic** — `"blob:<name>"` and `"grain:<id>"` — because an
70+
address is a measurement of bytes, not something an author can write down;
71+
install stores the blob, learns its address, rewrites the Definition,
72+
addresses *that*, and rewrites the plan that binds it. `expected_hash` is
73+
**refused, not warned**, with nothing written: a plan installed at a
74+
different address than the deployment expects has changed what runs, and
75+
every trigger pointing at the old hash is now pointing elsewhere. Grains are
76+
built and addressed with no store at all (content addressing is a pure
77+
function of the serialized grain), so `validate` speaks for `install` and can
78+
run in CI on a pull request. Export writes either reviewable grain JSON
79+
(refusing to write anything it cannot rebuild to the same address) or a
80+
bundle plus a manifest of what it must contain. Saved queries and templates
81+
travel too — a pack without them installs a trigger whose `context_query`
82+
names nothing. `docs/pack.md` is the reference; every agent under
83+
`examples/agents/` now ships a `pack/`, and `run-smokes.sh` asserts each one
84+
installs the same plan its language stacks mint.
85+
86+
- **Blessed shared tools: `http.call`, `mcp.call`, `a2a.call`** (#179) — three
87+
`wasm32-areev-io` blobs shipped in this repository with documented content
88+
addresses (`areev-tools/dist/blessed.json`, `docs/blessed-tools.md`). A pack
89+
binds one by address, declares where it may reach, and gets an outbound leg
90+
with no code of its own.
91+
92+
The point is not convenience. A tool gateway that decides *where a request
93+
may go* is code everyone installing it must trust; `http.call` makes no such
94+
decision — it hands the request to the broker and the answer back, verbatim,
95+
in both directions. Where it may go, which method, which credential and which
96+
headers are the Definition's `capabilities` and the host's grant: data, in
97+
the memory, replicated with the tool, auditable without reading any code.
98+
Two Definitions may name the same blob with different declarations, which is
99+
exactly the shape a fleet wants. `mcp.call` and `a2a.call` add one JSON-RPC
100+
envelope and one unwrap, copying the caller's `arguments` **byte for byte**
101+
rather than round-tripping it.
102+
103+
They are `no_std` with no dependencies (`http.call` is 2,598 bytes), built
104+
from `areev-tools/` — a standalone workspace, like `areev-sandbox` — and
105+
tested where the engine is: `areev-sandbox/tests/blessed_tools.rs` runs the
106+
committed bytes under real wasmi against a loopback broker stand-in, and
107+
asserts the import gate holds (a tool that declared no network does not get
108+
`areev::fetch` linked at all). CI checks that every published address is the
109+
address of the file beside it.
110+
111+
- **`examples/agents/sanctions-screening` seeds deterministically.** Its
112+
evalset Fact — the gate Rule E1 pins on the `screen` tool — was stamped with
113+
the wall clock, so the tool's hash, and therefore the desk's plan hash,
114+
differed on every seed. A plan hash that moves cannot be pinned by a pack,
115+
quoted in a README, or pointed at by a trigger, and nothing caught it because
116+
the cross-stack hash comparison needs two stacks and this desk has one. The
117+
seeder now pins `created_at` like every other grain it writes, and the desk
118+
records a wider `cold_grains` window beside its existing `run_outcome`
119+
tuning: its evalset is reference data read by the gate at review time, so
120+
"never recalled in 30 days" measures the wrong thing for it — and retiring
121+
an evalset would remove the gate a code revision has to pass.
122+
11123
- **The benchmark harnesses can run against a Postgres memory** (#200).
12124
`AREEV_BENCH_DB` (or `receipts/run.py --db`) names the memory — a file path
13125
or a `postgres://…?schema=…` DSN, handed to `areev.Areev` verbatim — for the

0 commit comments

Comments
 (0)