From 3cd0ddfe0bfe925e840e57485e4ce1bed9ea0624 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Wed, 2 Sep 2026 13:02:03 -0500 Subject: [PATCH] docs: agent rules scoped to the library Constraints that exist because breaking them produced a wrong result: affect.py holds no tensor, kappa=0 stays a single flag, memory is keyed by stable id, detach does not clear. Records the two occasions a full suite passed against a deliberately broken implementation, and the properties the tests now defend. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01KAWnnPg2qvmLNySamE2k85 --- AGENTS.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 9 ++++++++ 2 files changed, 71 insertions(+) create mode 100644 AGENTS.md create mode 100644 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..b01129e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,62 @@ +# ailed — library rules + +The organism itself: an affective CPPN, a Relational Perceptron, a Gated Relational +Perceptron, and a two-axis affect state. Nothing domain-specific lives here. Experiments +live in the sibling `experiments` repo; the design is `AILED_General_Specification.md` in +the parent directory. + +## What is in here + +| file | responsibility | +|---|---| +| `src/ailed/affect.py` | spec §5. `AffectConfig`, `Affect`, `update`, `decay`. Pure functions over floats. | +| `src/ailed/core.py` | spec §3–§4. `AffectiveCPPN`, `RelationalPerceptron`, `GatedRelationalPerceptron`, `Organism`, `detach_memory`. | + +## Rules + +Each of these exists because breaking it produced a wrong result, not as a style preference. + +- **`affect.py` imports no torch and holds no tensor.** ψ is built from `loss.item()`. If + gradient flowed through it, ψ would quietly become a learned latent and there would be no + oracle for what it means. +- **Autograd only.** No hand-written backward passes. +- **Affect axes are read by name** (`valence`, `arousal`). `Organism.forward` is the single + sanctioned place a `(valence, arousal)` tuple is unpacked positionally, via `Affect.axes`. +- **`kappa = 0` is one flag** that removes the affect term from the gate and changes nothing + else. It is the control every affect claim is measured against, so it must not acquire a + second code path. +- **Memory is keyed by stable entity id.** Entities that appear get fresh zero state; + entities that leave drop out of the returned dict. No unbounded growth. +- **`detach_memory` detaches, it does not clear.** State survives the truncated-BPTT + boundary; only the graph is cut. +- **CPU, small, no configuration nobody asked for.** No device handling, no batching. + +## Tests + +`uv run pytest -q` from this directory. + +**A test that cannot fail is worse than no test.** This has bitten this repo twice: a full +suite passed against an `Organism` that ignored its memory argument entirely, and against a +CPPN whose comment described an initialisation that did not exist. When a test defends a +central property, break the property on purpose and confirm the test fails. Say so in your +report. + +The properties currently defended, which you should not weaken: + +- translation invariance and permutation equivariance of the RP (both structural — `core.py` + never receives raw coordinates, only differences) +- masked aggregation counts unmasked neighbours and cannot produce NaN +- the gate's direction: rising arousal lowers `g` toward the present +- memory is load-bearing: zeroing a survivor's incoming state must change the output +- gradient flows through memory across steps, not merely through the current step + +## Calibration knobs + +`omega` scales the CPPN's sine pre-activation and sets the kernel bandwidth. It wants tuning +against the domain's length scale and is deliberately a named parameter, not a constant. The +first layer keeps PyTorch's default init on purpose — the comment says so, and it says so +because an earlier comment claimed an initialisation that was not there. + +## Conventions + +Python ≥3.11, `uv`, PyTorch, pytest. Commit inside this repo only. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..3fea760 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,9 @@ +# ailed + +The organism itself — affective cppn, relational perceptron, gated relational perceptron, two-axis affect. + +Rules for this repo are in `AGENTS.md` — read it before changing anything. It carries the +constraints that exist because breaking them produced a wrong result, not style preferences. + +The design this implements is `AILED_General_Specification.md`, and the project-wide rules are +in `AGENTS.md`, both in the parent directory alongside the sibling repos.