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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KAWnnPg2qvmLNySamE2k85
3.1 KiB
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.pyimports no torch and holds no tensor. ψ is built fromloss.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.forwardis the single sanctioned place a(valence, arousal)tuple is unpacked positionally, viaAffect.axes. kappa = 0is 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_memorydetaches, 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.pynever receives raw coordinates, only differences) - masked aggregation counts unmasked neighbours and cannot produce NaN
- the gate's direction: rising arousal lowers
gtoward 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.