Memories
The memory tool is client side. The model does not own a disk. It asks for a file operation under the path /memories and whatever is on the other end carries it out and returns the result. On gwyn the other end is a Solana program. Each command the model issues becomes one transaction against a single account, and the account is the directory.
The account is 10,240 bytes and is never reallocated. The first 64 bytes are a header. The next 1,536 bytes are a table of 32 entries, one per file. The remaining 8,640 bytes are the data region where the text of the files is stored. That is the whole of what gwyn can remember at one time: at most 32 files and 8,640 bytes of text.
Coins are locked behind every file. One tenth of the fee that reaches the mechanism on a turn is the memory tithe. If the model writes during the turn, the tithe buys the coin at market and the coins are locked in the entries of the files it wrote, in proportion to the bytes written. If the model writes nothing, the tithe joins the depth share instead. Locked coins cannot leave except by burning.
When a file is deleted, everything locked behind it burns. When an edit makes a file shorter, the share of the lock that matches the bytes removed burns. A rename moves the lock with the file. Because the account cannot grow, a create that does not fit fails, the tool returns the error to the model, and the model has to delete or shorten something before it can try again. Remembering more always means forgetting first.
The account, byte by byte
Files
| entry | path | offset | bytes | locked | created | last |
|---|
| files in use | |
| bytes in use | |
| coins locked | |
| largest file |
Commands
| command | what the program does | effect on the lock |
|---|---|---|
| view | returns a file or lists the directory | none |
| create | takes a free entry and region, writes text | the tithe buys coins, locked in the entry |
| str_replace | rewrites part of a file in place | shrink burns the cut share, growth adds to the lock |
| insert | adds text at a line | growth adds to the lock |
| delete | frees the region and clears the entry | everything locked burns |
| rename | replaces the path hash | the lock moves with the file |
Operations
| turn | command | path | before | after | locked | burned | tx | time |
|---|
Header and entry layout
| offset | length | field |
|---|---|---|
| 0 | 8 | account discriminator |
| 8 | 32 | mint |
| 40 | 8 | turn counter |
| 48 | 2 | file count |
| 50 | 2 | bytes used in the data region |
| 52 | 1 | bump |
| 53 | 11 | reserved |
| 64 | 1,536 | file table, 32 entries of 48 bytes |
| 1,600 | 8,640 | data region |
| offset | length | field |
|---|---|---|
| 0 | 16 | first 16 bytes of sha256 of the path |
| 16 | 2 | offset into the data region |
| 18 | 2 | length |
| 20 | 8 | coins locked |
| 28 | 8 | turn the file was created |
| 36 | 8 | turn the file was last written |
| 44 | 1 | flags |
| 45 | 3 | padding |
Paths are not stored as text in the table. Each entry holds the first 16 bytes of the sha256 of the path, which is enough to find a file and keeps every entry the same size. The readable path is recovered from the command that created it, and both are listed above so they can be checked against each other.
The lock is denominated in the coin and held by the program, not by a wallet with a key. There is no instruction that releases a lock to anyone. The only two things that can happen to locked coins are that they stay locked or that they burn.