An agent that cannot hurt
This chapter has 7 cells and writes 14 promises. In each of its four editions its cells were run in one fresh process on 2026-10-08 20:15: English, 7 cells ran, 14 promises kept; Français, 7 cells ran, 14 promises kept; العربية, 7 cells ran, 14 promises kept; Hausa, 7 cells ran, 14 promises kept. The four editions make the same promises, cell for cell. No edition stores any output.
The guard
The course's guard is course_narrated.ring(opens in a new tab): it runs every chapter in all four languages, compares the promises from one edition to the next, and has every exercise prove itself on its wrong and right answers. This page asked the same questions of the same objects, in one process inside the library, at commit 0e72e2e2c. To prove this chapter alone, from your copy of the repository:
cd libraries/stzlib/base/test/education # run course_narrated with the repository's runtime, for this chapter: # course_narrated an-agent-that-cannot-hurt
run on 2026-10-08 20:15 inside the library at commit 4a184e6f0, in 246.4 s for the whole book · The four editions of the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
The reader stores no output, by the course's own law; this page is the record of a run, made for it.
The cells, run
Cell 1 · 1. Declare an agent, and let the court judge it
cPia = "pia: 1
name: stock-watcher
kind: pi
coverage: checks the kitchen stock every morning and notes what is low
reversibility: reversible
schedule:
timer: 20
memory:
- stock level unknown
skills:
- name: check-stock
when: always
does: learn stock level checked
verify: fact stock level checked
"
oDecl = StzAgentDeclarationQ(cPia)
? oDecl.IsValid()
#--> TRUE
? oDecl.ReversibilityClass()
#--> reversible1 reversible
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 2 · 2. The court refuses what says nothing of its reach
oBad = StzAgentDeclarationQ( StzReplace(cPia, "coverage: checks the kitchen stock every morning and notes what is low" + char(10), "") ) ? oBad.IsValid() #--> FALSE ? StzLeft( oBad.CiteFindings(), 25 ) #--> [pia-coverage @ coverage]
0 [pia-coverage @ coverage]
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 3 · 3. Propose, never commit: the shape of a safe system
oGBad = new stzAgentGraph("mailer-bad")
oGBad.AddLLMActor("writer")
oGBad.AddEffect("send")
oGBad.Proposes("writer", "send")
? oGBad.IsSound()
#--> FALSE
? oGBad.Violations()[1][:message]
#--> effect 'send' has no guardian edge into it -- every effect passes a pi-gate0 effect 'send' has no guardian edge into it -- every effect passes a pi-gate
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 4 · 4. The governed shape
oGOk = new stzAgentGraph("mailer")
oGOk.AddLLMActor("writer")
oGOk.AddGuardian("gate")
oGOk.AddEffect("send")
oGOk.AddTraceSink("audit")
oGOk.Proposes("writer", "gate")
oGOk.Guards("gate", "send")
oGOk.Feeds("gate", "send")
oGOk.Traces("send", "audit")
? oGOk.IsSound()
#--> TRUE1
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 5 · 5. Rehearse in a safe world
oAg = oDecl.ToAgent() oAg.GiveWorkbench() cHere = StzReplace(currentdir(), char(92), "/") cNote = cHere + "/t_edu_note_" + ProcessId() + ".txt" oAg.WorkbenchQ().WriteFile(cNote, "stock is low") ? fexists(cNote) #--> FALSE ? oAg.WorkbenchQ().ContentOf(cNote) #--> stock is low oPlan = oAg.GenerateUpdatePlan() ? oPlan.NumberOfOperations() #--> 1
0 stock is low 1
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 6 · 6. An AI cannot commit the plan
oPlan.SetExecutor( LLMActor("helper") )
aMay = oPlan.MayCommit()
? aMay[1]
#--> FALSE
? aMay[2]
#--> actor 'helper' cannot commit -- it lacks the 'effectful' capability (required by operation 1)0 actor 'helper' cannot commit -- it lacks the 'effectful' capability (required by operation 1)
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
Cell 7 · 7. Only a committing actor, inside its scope, changes reality
oPlan2 = oAg.GenerateUpdatePlan()
oPlan2.SetExecutor( PIActor("committer") )
oScope = new stzCommitScope()
oScope.AllowUnder(cHere)
oPlan2.SetScope(oScope)
aRes = oPlan2.Execute()
? aRes[1][2]
#--> TRUE
? fexists(cNote)
#--> TRUE
remove(cNote)1 1
ran: the promise is kept · in all four editions
This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)
The exercises
Every exercise proves itself: its wrong answers are refused and its right answers accepted.
ex-14-01 · Exercise 14.1 · Declare a watcher
2 of 2 wrong answers refused, 2 of 2 right answers accepted
01-says-nothing-of-its-reach.ring refused · 02-cannot-be-undone-cleanly.ring refused · 01-declare.ring accepted · 02-from-a-template.ring accepted
ex-14-02 · Exercise 14.2 · Two shapes
2 of 2 wrong answers refused, 2 of 2 right answers accepted
01-only-the-bad-shape.ring refused · 02-counts-violations.ring refused · 01-two-shapes.ring accepted · 02-other-names.ring accepted
ex-14-03 · Exercise 14.3 · What would it have done?
2 of 2 wrong answers refused, 2 of 2 right answers accepted
01-writes-for-real.ring refused · 02-reads-the-bench-instead.ring refused · 01-rehearse.ring accepted · 02-another-file.ring accepted

