Skip to content

Security lesson 2: The identity tree

Follow every agent to the person who answers for it, read what the forge records of each birth and stop, and cut off a whole line at once.

Time: 25 minutes. Track: security and compliance. Before this: security lesson 1, and agent lesson 1 for the client.

By the end of this lesson you will be able to:

  • say who answers for any agent, and how the forge knows;
  • read what a compliance report says of births, stops and sign-ins;
  • cut off an agent and everything it started, in one step.

Every agent has a line

The forge has no shared bot accounts. Every agent is born from the person or agent that starts it, with its own key and no more access than its parent, so every actor is a tree’s node whose root is a person. An actor’s line is that path: the actor, each actor it was born from, and the person at the end, who answers for it. A receipt names an actor by its line, so a landing says not only which agent wrote it but who started that agent, and who answers for both. See People and agents, and FORGE-RECEIPTS.md for the record’s form.

Start a forge, and write the MCP client from agent lesson 1:

$ af-server --dev
...
$ source ~/af-dev/dev/env
$ cat > ~/agent-session <<'END'
> #!/bin/bash
> # A minimal MCP client. It runs `af ... mcp DIR`, the options after DIR going to af, and makes
> # the session's calls from stdin one at a time, as an agent does: `NAME ARGUMENTS` calls a tool
> # and prints its answer; `! COMMAND` runs a command between calls.
> coproc MCP { af "${@:2}" mcp "$1"; }
> say() { printf '%s\n' "$1" >&"${MCP[1]}"; }
> say '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"agent-session","version":"1"}}}'
> read -r _ <&"${MCP[0]}"
> say '{"jsonrpc":"2.0","method":"notifications/initialized"}'
> id=0
> while IFS= read -r step; do
>   case "$step" in
>     '! '*) eval "${step#! }" ;;
>     ?*) id=$((id + 1)); name=${step%% *}
>         say "{\"jsonrpc\":\"2.0\",\"id\":$id,\"method\":\"tools/call\",\"params\":{\"name\":\"$name\",\"arguments\":${step#* }}}"
>         read -r reply <&"${MCP[0]}"
>         case "$reply" in
>           *'"structuredContent":'*) reply=${reply#*\"structuredContent\":}; reply=${reply%,\"isError\":*} ;;
>           *'"error":'*) reply=${reply#*\"error\":}; reply=${reply%\}} ;;
>         esac
>         printf '%s -> %s\n' "$name" "$reply" ;;
>   esac
> done
> END
$ chmod +x ~/agent-session

A tree of three

You start a builder agent for a ticket. Started from your sign-in, its parent is you:

$ af --credential ~/builder.key key
2f8512ad17f1f47d7b795f9cfcab0ebbc46666a429fb780e86b2437f99b538cb
$ ~/agent-session ~/me <<END | tee ~/builder.birth
> start_agent {"public_key":"$(af --credential ~/builder.key key --public)","program":"builder","version":"2.1","model":"example-model","instructions":"Build the feature in the ticket.","purpose":"builds the login page","task":"LOGIN-12"}
> END
start_agent -> {"agent":"704a24acc17033eb43bbb5888372c9b4937dc9f11bff86e7941f649c5490e230","expires_ms":1795680286331}
$ export BUILDER=$(sed -n 's/.*"agent":"\([0-9a-f]*\)".*/\1/p' ~/builder.birth)

The builder starts a tester of its own, for the same ticket, limited to tests. The tester’s line is the tester, the builder, and you:

$ af --credential ~/tester.key key
b21a2925ce807f10e896bf090da85e1021470dfb1edacf5899c67ede91932c3e
$ ~/agent-session ~/builder --credential ~/builder.key --actor $BUILDER <<END | tee ~/tester.birth
> start_agent {"public_key":"$(af --credential ~/tester.key key --public)","program":"tester","version":"0.9","model":"example-model","instructions":"Write tests for the login page.","purpose":"tests the login page","task":"LOGIN-12","folders":["tests"]}
> END
start_agent -> {"agent":"451857c7fb84a71fd71cf1c3f7477cf602a423bda8dd8ee99ce548920c243505","expires_ms":1795680286331}
$ export TESTER=$(sed -n 's/.*"agent":"\([0-9a-f]*\)".*/\1/p' ~/tester.birth)

The tester lands a change. Its landing’s receipt names the tester as the writer by its whole line, each agent with the program, version and model it reported at its birth, and the place of its birth record in the log:

$ ~/agent-session ~/tester --credential ~/tester.key --actor $TESTER <<'END'
> open_workspace {"patterns":["**"]}
> start_change {"description":"Test the login page","author_name":"tester","author_email":"tester@example.com"}
> ! mkdir -p ~/tester/files/tests && printf 'test login\n' > ~/tester/files/tests/login.txt
> submit {}
> wait {}
> END
open_workspace -> {"directory":"/home/you/tester/files","landing":null,"patterns":["**"],"written":0}
start_change -> {"change":"rmklokpynwkmkkwzkqswwvwsmtmrqkmt","commit":"208ca023c34e2524fdd8f240909c4859d241a80af8600c3934f0d7748e0724da"}
submit -> {"commit":"48241dd738c18e7192475216e9bfcd04ab198f49810cb3d5691c92f84238d699","edits":1}
wait -> {"commit":"48241dd738c18e7192475216e9bfcd04ab198f49810cb3d5691c92f84238d699","detail":"the change is on main","event":"landed"}

What the record says

A report’s identity area is built from the sign-ins, births and stops in the period. ISO 27001 assesses it, under A.5.15 and A.8.5:

$ af report iso27001 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/before
wrote /home/you/before/iso27001-report.json and /home/you/before/iso27001-report.html; the report's receipt is entry 5 of the log
$ grep -o '[0-9]* agents born[^"\\]*' ~/before/iso27001-report.json | sort -u
2 agents born, each from a person or an agent, each line ending at a person; 0 stopped.

Every exception is listed with its time and its place in the log, for anyone to look up; here each is shown up to those, since the place depends on what else the log took first. Two concern who did what: your own sign-in, since a development forge signs you in with no second factor, and the tester’s landing, which no check gated, since this forge has no runner. The others concern the log itself, and lesson 1 covers reading them:

$ grep -o 'Exception: [^"]*\(signed in\|landed as\)[^"]*' ~/before/iso27001-report.json \
> | sed 's/ ([^()]*receipt log)\.$//' | sort -u
Exception: change rmklokpynwkmkkwzkqswwvwsmtmrqkmt landed as 48241dd738c18e7192475216e9bfcd04ab198f49810cb3d5691c92f84238d699: no check gated it
Exception: dev@localhost signed in, on a local development server (af-server --dev), with no second factor

Cut off a line

Stopping an actor stops everything below it, at once and in one record: nothing an agent started can outlive it. You stop the builder:

$ af stop $BUILDER --reason "LOGIN-12 is done"
stop reference 732bda8a9df4eda9602bb4f1b4607cfa8c3810ad6e98b83b8684037bb9f625dc
stopped 704a24acc17033eb43bbb5888372c9b4937dc9f11bff86e7941f649c5490e230
stopped 451857c7fb84a71fd71cf1c3f7477cf602a423bda8dd8ee99ce548920c243505
$ af --credential ~/tester.key --actor $TESTER status
Error: Unauthenticated: 451857c7fb84a71fd71cf1c3f7477cf602a423bda8dd8ee99ce548920c243505 is not a live actor
[1]

The report now counts what the stop cut off: the builder, and the tester below it. It counts actors, not stop records: one stop ends its actor’s whole line, and the births in the log show who was below the builder when it stopped:

$ af report iso27001 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/after
wrote /home/you/after/iso27001-report.json and /home/you/after/iso27001-report.html; the report's receipt is entry 7 of the log
$ grep -o '[0-9]* agents born[^"\\]*' ~/after/iso27001-report.json | sort -u
2 agents born, each from a person or an agent, each line ending at a person; 2 stopped.

Exercises

  1. NIST SP 800-53 assesses identity under IA-2. Produce its report, and find the same count.

    $ af report nist-800-53 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/nist
    wrote /home/you/nist/nist-800-53-report.json and /home/you/nist/nist-800-53-report.html; the report's receipt is entry 8 of the log
    $ grep -o '[0-9]* agents born[^"\\]*' ~/nist/nist-800-53-report.json | sort -u
    2 agents born, each from a person or an agent, each line ending at a person; 2 stopped.
  2. The builder is stopped. Can it still act, with its key and its ID?

    $ af --credential ~/builder.key --actor $BUILDER status
    Error: Unauthenticated: 704a24acc17033eb43bbb5888372c9b4937dc9f11bff86e7941f649c5490e230 is not a live actor
    [1]

Check your understanding

Who answers for the tester’s landing?

You do. The tester’s line runs through the builder to your sign-in, and so to you: every line ends at a person.

Why does the report count two stopped, when you stopped one agent?

One stop record names the builder, and a stop ends everything below its actor. The report reads the tester’s birth from the builder, earlier in the log, and so counts the tester as cut off too. It counts actors stopped, not records.

Why is your sign-in an exception?

A development forge signs you in itself, with no identity provider and no second factor. A production forge signs people in through its provider, and a report says for each sign-in how the second factor was shown.

Next

Security lesson 3: Verifying a receipt checks a release’s provenance with the organization’s keys and the log alone. What the forge records explains receipts and the log.

Type to search…

↑↓ navigate↵ selectEsc close