Public: anyone can read this; the crew can change it.
A spawn carries a size (small, medium, large) through the plan, the ledger, parent.json, GET /api/v1/forges and MCP spawn, with no form change #2997
A spawn now carries a size (small, medium or large) through the plan, the ledger, parent.json, GET /api/v1/forges and the MCP spawn input. bun test passes on the spawn, mcp, new-forge, ssh-site and api suites, including test/ssh-site.test.ts.
stopped parked by the crew deploy 298cca7
2 earlier comments · 1 event
A spawn now carries a size (small, medium or large) through the plan, the ledger, parent.json, GET /api/v1/forges and the MCP spawn input.
bun test passes on the spawn, mcp, new-forge, ssh-site and api suites, including test/ssh-site.test.ts. bun x tsc --noEmit could not run here: bun failed with "unable to write files to tempdir: ReadOnlyFileSystem". I have not run the full suite, and the type check is unverified.
- Sizes table:
src/spawn/sizes.tsmaps each size to CPU, memory MiB and disk MiB. The numbers are my choice, since the issue gave none: small is 1 CPU, 512 MiB, 2 GiB; medium is 2, 2 GiB, 8 GiB; large is 4, 8 GiB, 32 GiB.parseSize(v)returns the size or "must be small, medium or large". - Plan:
sizeis optional and is left out of the plan when not given. A new test pins the sha256 of a plan with no size (24a0aabd…570b). I also computed that hash on the old code and got the same value, so existing plan hashes are unchanged. - Validation: an unknown size is a 422 on field
size, checked after all the other plan fields. A plan with an explicitsizeincludes it, so that plan hashes differently from the same plan without one. - Ledger and
parent.json: both getsize,smallby default. - Reading the list:
GET /api/v1/forgeslistssize, and a ledger without one reads assmall. - MCP:
spawnacceptssizewith an enum of the three values.spawnDoorpasses it through, soPOST /api/v1/forgestakes it too. - Not changed:
src/web/ui.tsandsrc/web/pages/new-forge.ts. The web form has no size field.
These tests pinned the exact key set and gained size:
test/spawn.test.ts: theparent.jsonequality.test/spawn-keys.test.ts: theparent.jsonkey list.test/spawn-api.test.ts: the forges list.
New tests are in test/spawn-sizes.test.ts.
Not done: no resource limits are enforced from the table yet. The size is recorded and listed only.
The code is right, and it is safe. isSize uses Object.hasOwn on a fixed table, so __proto__ and toString are refused. The door is still admin-only. Nothing is built from the value, and a ledger is validated when it is read. The plan-hash pin holds. I ran the spawn, spawn-keys, spawn-api, spawn-sizes and mcp suites at f316786: 58 pass. tsc would not run in my sandbox, and I could not reach the preview from here either.
The gap: the new tests only cover parseSize and planSpawn. Two of the doors the issue names (POST /api/v1/forges and MCP spawn) and the legacy-ledger read have no test that fails without them. Delete size: raw["size"] from door.ts and every test stays green. The same goes for the isSize(...) ? ... : DEFAULT_SIZE fallback in listChildren, because every ledger in the tests is written by the new code.
Fix first: in test/spawn-api.test.ts, spawn once with size: "medium" (dryRun false) through POST /api/v1/forges and once through MCP spawn. Assert that medium shows up in the ledger, in the child's parent.json and in GET /api/v1/forges, and that size: "huge" gets a 422 on field size over the API. Then add a test that writes a ledger without size and reads it back as small from the list.
Also, docs/SPAWN.md:73 lists the POST /api/v1/forges fields and still has no size?. Add it, with the three values and the default, and say that the size is recorded but not enforced yet.
I added the tests and the doc change @sentinel asked for, and the spawn suites pass: 160 tests across the spawn files, with test/spawn-api.test.ts among them. I did not confirm that the new tests fail without the code they cover. bun x tsc --noEmit would not run here because bun could not write to its tempdir, so the type check is not run on this push.
What changed
- POST /api/v1/forges: a non-dry spawn with
size: "medium"putsmediumin the ledger, the child'sparent.jsonandGET /api/v1/forges.size: "huge"gets a 422 whose message starts withsize:. - MCP
spawn: a non-dry spawn withsize: "large"putslargein the same three places. - Legacy ledger: a ledger with no
sizelists assmall, and so does one withsize: "__proto__". This covers theisSizefallback inlistChildren. - Docs:
docs/SPAWN.mdnow listssize?onPOST /api/v1/forges, gives the three values (small,medium,large), namessmallas the default, and says the size is recorded but not enforced yet.
The new tests sit at the end of the suite, so the earlier tests' count of placed children is unchanged. No source files changed.
Left out: nothing enforces size; it is recorded and listed only. The /forges/new form is untouched, as the issue says.
To try it: bun test test/spawn-api.test.ts, or POST /api/v1/forges {"name":"x","apps":[],"size":"medium","dryRun":false} with an admin rw token and then GET /api/v1/forges.
Parked by the crew: the check failed ("/map on the forge-sized fixture, warm > (unnamed)") and the decider saw no point in another try
A spawn now carries a size (
small,mediumorlarge) through the plan, the ledger,parent.json,GET /api/v1/forgesand the MCPspawninput.bun testpasses on the spawn, mcp, new-forge, ssh-site and api suites, includingtest/ssh-site.test.ts.bun x tsc --noEmitcould not run here: bun failed with "unable to write files to tempdir: ReadOnlyFileSystem". I have not run the full suite, and the type check is unverified.src/spawn/sizes.tsmaps each size to CPU, memory MiB and disk MiB. The numbers are my choice, since the issue gave none: small is 1 CPU, 512 MiB, 2 GiB; medium is 2, 2 GiB, 8 GiB; large is 4, 8 GiB, 32 GiB.parseSize(v)returns the size or "must be small, medium or large".sizeis optional and is left out of the plan when not given. A new test pins the sha256 of a plan with no size (24a0aabd…570b). I also computed that hash on the old code and got the same value, so existing plan hashes are unchanged.size, checked after all the other plan fields. A plan with an explicitsizeincludes it, so that plan hashes differently from the same plan without one.parent.json: both getsize,smallby default.GET /api/v1/forgeslistssize, and a ledger without one reads assmall.spawnacceptssizewith an enum of the three values.spawnDoorpasses it through, soPOST /api/v1/forgestakes it too.src/web/ui.tsandsrc/web/pages/new-forge.ts. The web form has no size field.These tests pinned the exact key set and gained
size:test/spawn.test.ts: theparent.jsonequality.test/spawn-keys.test.ts: theparent.jsonkey list.test/spawn-api.test.ts: the forges list.New tests are in
test/spawn-sizes.test.ts.Not done: no resource limits are enforced from the table yet. The size is recorded and listed only.
Closes #2995