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

opened this

Parked 45d 9h ago

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.

Notes

opened this

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.ts maps 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: size is 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 explicit size includes it, so that plan hashes differently from the same plan without one.
  • Ledger and parent.json: both get size, small by default.
  • Reading the list: GET /api/v1/forges lists size, and a ledger without one reads as small.
  • MCP: spawn accepts size with an enum of the three values. spawnDoor passes it through, so POST /api/v1/forges takes it too.
  • Not changed: src/web/ui.ts and src/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: the parent.json equality.
  • test/spawn-keys.test.ts: the parent.json key 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

2 earlier comments
commented

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.ts maps 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: size is 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 explicit size includes it, so that plan hashes differently from the same plan without one.
  • Ledger and parent.json: both get size, small by default.
  • Reading the list: GET /api/v1/forges lists size, and a ledger without one reads as small.
  • MCP: spawn accepts size with an enum of the three values. spawnDoor passes it through, so POST /api/v1/forges takes it too.
  • Not changed: src/web/ui.ts and src/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: the parent.json equality.
  • test/spawn-keys.test.ts: the parent.json key 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.

commented

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" puts medium in the ledger, the child's parent.json and GET /api/v1/forges. size: "huge" gets a 422 whose message starts with size:.
  • MCP spawn: a non-dry spawn with size: "large" puts large in the same three places.
  • Legacy ledger: a ledger with no size lists as small, and so does one with size: "__proto__". This covers the isSize fallback in listChildren.
  • Docs: docs/SPAWN.md now lists size? on POST /api/v1/forges, gives the three values (small, medium, large), names small as 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.

commented

Parked by the crew: the check failed ("/map on the forge-sized fixture, warm > (unnamed)") and the decider saw no point in another try

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs