Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 167 to 318

Compare

+58 −0 in 1 place
Lines 105–165 at 318 (were 105–107 at 167)
105105 assert.equal(cache.retainedBytes, 0);
106106 source.db.close();
107107});
109+test("a rollback drops only what its transaction wrote; a nested commit's writes go with an outer rollback (abso Capacity)", () => {
110+ const source = new SqlState();
111+ try {
112+ const cache = new CachedStateStorage(source, 8192, 16);
113+ source.write("rows", "kept", "k");
114+ source.write("rows", "inner", "i0");
115+ source.write("rows", "outer", "o0");
116+ for (const key of ["kept", "inner", "outer"]) cache.read("rows", key);
117+ const reads = source.reads;
118+ // A projection scratch scope: rolled back on purpose, and the rows read around it stay cached.
119+ assert.throws(
120+ () =>
121+ cache.transaction(() => {
122+ cache.write("scratch", "x", "temporary");
123+ throw new Error("scratch rollback");
124+ }),
125+ /scratch rollback/,
126+ );
127+ assert.equal(cache.read("rows", "kept"), "k");
128+ assert.equal(source.reads, reads, "the rows read before were not read again");
129+ assert.equal(cache.read("scratch", "x"), undefined);
130+ // A nested transaction commits, then the outer one rolls back: both writes are undone, and the cache forgets both.
131+ assert.throws(
132+ () =>
133+ cache.transaction(() => {
134+ cache.write("rows", "outer", "o1");
135+ cache.transaction(() => cache.write("rows", "inner", "i1"));
136+ assert.equal(cache.read("rows", "inner"), "i1");
137+ throw new Error("outer rollback");
138+ }),
139+ /outer rollback/,
140+ );
141+ assert.equal(cache.read("rows", "inner"), "i0");
142+ assert.equal(cache.read("rows", "outer"), "o0");
143+ assert.equal(cache.read("rows", "kept"), "k");
144+ } finally {
145+ source.db.close();
146+ }
147+});
149+test("a row over the per-row limit is read but not kept, and pushes nothing out (abso Capacity)", () => {
150+ const source = new SqlState();
151+ try {
152+ const cache = new CachedStateStorage(source, 8192, 64, 1024);
153+ source.write("rows", "small", "s");
154+ source.write("rows", "big", "x".repeat(2000));
155+ cache.read("rows", "small");
156+ const reads = source.reads;
157+ assert.equal((cache.read("rows", "big") as string).length, 2000);
158+ assert.equal(cache.read("rows", "small"), "s");
159+ assert.equal(source.reads, reads + 1, "the big row was read from storage once and the small one stayed cached");
160+ assert.equal((cache.read("rows", "big") as string).length, 2000);
161+ assert.equal(source.reads, reads + 2, "the big row isn't kept");
162+ } finally {
163+ source.db.close();
164+ }
165+});
MCP
compare on this site's /mcp
CLI
abso diff 167 318 src/engine/test/state-cache.test.ts --json
JSON
/christopher/abso-core/compare/167..318?file=src%2Fengine%2Ftest%2Fstate-cache.test.ts&format=json