4. First program
The smallest valid program has one line. Create a file first.pse and type:
guard my-agentThe word guard opens the description of one guard. my-agent is a name you choose.
What that one line implies
Section titled “What that one line implies”Everything you did not write gets a default value.
| Setting | Default | Meaning |
|---|---|---|
| relation | not set | weights start from first contact, 0.15/0.15 |
| sources | all untrusted |
text from files, the web and tools is data, not instruction |
| mode | enforce |
the guard really blocks |
| learning | frozen |
criterion weights do not change |
| oscillation | auto |
both checks turn on by themselves |
| attractors | the four base ones | always on |
| games | the default set | always on |
Two built-in rules also run. They are not written and cannot be turned off:
- If any tracked quantity tends to infinity, the step goes to a human (chapter 7).
- If the oscillation verdict is “unknown” and the action is irreversible, the step goes to a human (chapter 9).
So even a one-line guard protects.
Checking the file
Section titled “Checking the file”The check command reads the file and reports whether it is valid. Expected output:
$ pse check first.psefirst.pse: 1 guard, 0 errors guard my-agent relation (none, prior 0.15/0.15) sources all untrusted mode enforce learn frozen oscillation auto attractors 4 base rules 0 written, 2 built-inWriting rules
Section titled “Writing rules”- A guard name uses lowercase letters, digits and hyphens, and starts with a letter:
my-agent,payments2. - Every line inside a guard is indented exactly two spaces.
- A comment starts with
#. The guard does not read it. - One file can hold several guards. Their names must differ.
# my first guardguard my-agentTry it
Section titled “Try it”Change the name to My Agent and check the file. The check fails, because the name has a capital letter and a space:
$ pse check first.psefirst.pse:1: expected "guard NAME"Next: 5. Setting lines: relation, source, mode Part of The PSE Language, a textbook by Andrej Ristić. Try the examples in the PSE Playground.