A capability is a rewrite rule
Misha's iterate mind is a git repository of code, and what its agents may do is exactly what that code has given a name.
An agent with the keys to everything is the nightmare everyone is worried about. Here an agent can call nothing that has not been named, and naming a new power is a single event.
An agent on iterate does things by running small scripts against itx, the mind's API: itx.repos, itx.fetch, itx.agents. On 29 October we added a service of our own, a daily magazine with an editor agent, and wanted agents to call it the same way: await itx.news.latest().
No SDK had to be published for that. A capability is one rewrite rule.
Default deny
Every itx expression an agent evaluates is checked against the mind's rewrite rules. If no rule matches, the call is refused, and the error names the expression:
no rewrite rule matches "itx.news.latest()"
That is the safety property. An agent can do only what the mind has said it can do, and an unknown expression fails with an error instead of doing something unexpected.
Pointing a name at a worker
A rule maps a match to a target expression. For our own services the target is a worker module in the config repo, loaded from whichever commit is published:
const description =
"Magazine. latest() reads the edition; request() queues research; " +
"publish(edition, expectedLatestId) validates and rejects stale writes.";
if ((await itx.rewriteRules.get("itx.news"))?.description !== description) {
await itx.append({
type: "events.iterate.com/itx/rewrite-rule-configured",
payload: {
match: "itx.news",
target: ["itx", "workers", ["get", { mainModule: "news.ts", source: ["itx", ["cd", "/"], "config"] }]],
description,
},
});
}
This runs in the init hook, which the platform triggers after every publication of the config. Comparing the description makes it idempotent: the rule is reconfigured only when its text has changed, so a publication with no change appends nothing.
The module is the API
news.ts at the repo root is an ordinary entrypoint class, and its public methods are the capability. Each method opens the smallest itx scope it needs, does its work, and returns plain data, not handles:
export default class News extends IterateConfigEntrypoint {
async latest() {
using itx = this.getItx();
return (await currentEdition(itx)).edition;
}
async publish(input: unknown, expectedLatestId: string) {
const draft = editionSchema.parse(input); // validate before touching anything
using itx = this.getItx();
const { edition: previous, tip } = await currentEdition(itx);
if (previous.id !== expectedLatestId) throw new Error("Edition changed: read latest() first");
// ...commit the new edition on top of `tip`
}
}
The method boundary is the right place for the rules that should hold whichever agent calls it. Input is parsed against a schema before anything happens. publish takes the id of the edition the caller last read and refuses to write if that edition is no longer current, so two editors working at once can't silently overwrite each other. request() appends an event with an hourly idempotency key, so repeated requests within an hour combine into one research run. Callers don't have to know any of this.
The description is the documentation
Agents find out what a capability does from its description, so the description is the agent's API reference. Writing it taught us two things.
It has a hard limit of 500 characters. The first version was longer, and the platform rejected it at the init hook, so after the first publication the capability and the daily editor were not set up. The fix, made the same night, cut the text down and added a test that installs the capability against a fake itx and checks the payload:
it("installs a capability description within the platform limit", async () => {
const append = vi.fn();
await installNews({ ...fakeItx, rewriteRules: { get: async () => null }, append });
expect(append.mock.calls[0][0].payload.description.length).toBeLessThanOrEqual(500);
});
The description should state the shape of every call and then point to the longer instructions for everything else. This one tells a publishing agent to read the editor's instructions and the edition schema first. A rule is a signpost, not a manual. A description that tries to be the manual runs into the limit, as this one did.
The same trick, inside out
Rules can also intercept existing capabilities. The wrapper that screenshots instruction diffs on commit is a rule per repo whose match is that repo's native commitFiles. Its target is our worker, with the original arguments passed through in place of @:
{
match: `itx.repos.get("/repos/example").commitFiles`,
target: `itx.workers.get({ mainModule: "instruction-diffs.ts", ... }).commitFiles("/repos/example", @)`,
}
The agent keeps writing commitFiles as before. The rule decides what that call means. Adding a capability and changing an existing one are the same operation: one event that says "this expression now goes there", applied idempotently each time the config is published.