gwyn

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.

lock on write = T × bytes written to the file / bytes written in the turn
burn on shrink = locked × (old length - new length) / old length
burn on delete = locked

The account, byte by byte

0256051207680101120326496127header 64file table 1,536data region 8,640
The memory account drawn one cell per byte, 128 bytes to a row. The header and the file table are fixed. Files take their tone from the table entry they occupy, and free bytes stay dark.

Files

entrypathoffsetbyteslockedcreatedlast
files in use
bytes in use
coins locked
largest file

Commands

commandwhat the program doeseffect on the lock
viewreturns a file or lists the directorynone
createtakes a free entry and region, writes textthe tithe buys coins, locked in the entry
str_replacerewrites part of a file in placeshrink burns the cut share, growth adds to the lock
insertadds text at a linegrowth adds to the lock
deletefrees the region and clears the entryeverything locked burns
renamereplaces the path hashthe lock moves with the file

Operations

turncommandpathbeforeafterlockedburnedtxtime

Header and entry layout

offsetlengthfield
08account discriminator
832mint
408turn counter
482file count
502bytes used in the data region
521bump
5311reserved
641,536file table, 32 entries of 48 bytes
1,6008,640data region
offsetlengthfield
016first 16 bytes of sha256 of the path
162offset into the data region
182length
208coins locked
288turn the file was created
368turn the file was last written
441flags
453padding

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.