Public: anyone can read this; the crew can change it.

A game box stores spark profiles in the forge: POST /post gives a Location, reads need the box's game grants #18146

opened this

Merged 8h 19m ago, live in production

A game box now stores the spark profiles its servers post, and a forge session with a grant on the box reads them back (#18137). The new tests and the tui and unused-exports tests pass, as do tsc and the doors, route-marks and migrations checks I ran. I did not run the whole suite.

Notes

opened this

A game box now stores the spark profiles its servers post, and a forge session with a grant on the box reads them back (#18137). The new tests and the tui and unused-exports tests pass, as do tsc and the doors, route-marks and migrations checks I ran. I did not run the whole suite. I did not run test/module-state.test.ts (the no-process-state rule). The new code adds no module-level collection.

  • Upload: POST /games/@spark/<secret>/post takes a gzipped protobuf with Content-Type: application/x-spark-*. It answers 201 with Location: <key> and no body. A wrong secret gets 403. A body over 8 MiB gets 413, and anything that isn't gzip or isn't a spark type gets 400.
  • Secret: the box owner makes the upload address on /games/<box> under Profiles, or with u on the terminal screen. It is shown once, only its hash is kept, it only allows writes, and a new one ends the old.
  • Read: GET /games/@spark/<secret>/<key> returns the bytes and type to a session with any grant on the box (seesBox; forge admins included). It answers 403 to everyone else, including someone holding only the secret. I added no grant table.
  • Settings: profiles are kept 14 days and each box keeps its newest 50. The 8 MiB cap is BODY_CAPS.gameSpark. Each setting has its reason beside it in src/games/spark.ts.
  • Doors: the box page lists stored profiles, and its link opens one without the secret. The terminal has the same list in a new screen, src/tui/screens/game_spark.ts, opened with p on the box screen. The how-to is docs/features/game-spark.md.
  • Reused: secret, sha256, readBounded, seesBox, boxOf and flashTo, with the secret-link pattern from the client pack.

Not done:

  • The forge doesn't decode or render a profile; spark's own viewer reads it.
  • The gzip check looks at the magic bytes only.
  • Profiles are stored in sqlite blobs under FORGE_APP_DATA.
  • No before/after look: the commit says No look: and the test covers the block.
  • bun scripts/gate.ts --fix still prints a similarity note that newSparkSecret resembles issueStatusToken in src/core/outsider_status.ts. I left it as it is.

Try it: as a box owner open /games/<box>, make an upload address under Profiles, then curl -X POST -H 'content-type: application/x-spark-sampler' --data-binary @profile.gz <address>post. The profile then shows in the list.

Tests: bun test test/game-spark.test.ts covers the post, the read with a grant, the refusals, the 403 for a wrong secret and the pruning. test/tui-games.test.ts gained the terminal screen.

🤖 Generated with Claude Code

Closes #18137

2 earlier comments
commented

A game box now stores the spark profiles its servers post, and a forge session with a grant on the box reads them back (#18137). The new tests and the tui and unused-exports tests pass, as do tsc and the doors, route-marks and migrations checks I ran. I did not run the whole suite. I did not run test/module-state.test.ts (the no-process-state rule). The new code adds no module-level collection.

  • Upload: POST /games/@spark/<secret>/post takes a gzipped protobuf with Content-Type: application/x-spark-*. It answers 201 with Location: <key> and no body. A wrong secret gets 403. A body over 8 MiB gets 413, and anything that isn't gzip or isn't a spark type gets 400.
  • Secret: the box owner makes the upload address on /games/<box> under Profiles, or with u on the terminal screen. It is shown once, only its hash is kept, it only allows writes, and a new one ends the old.
  • Read: GET /games/@spark/<secret>/<key> returns the bytes and type to a session with any grant on the box (seesBox; forge admins included). It answers 403 to everyone else, including someone holding only the secret. I added no grant table.
  • Settings: profiles are kept 14 days and each box keeps its newest 50. The 8 MiB cap is BODY_CAPS.gameSpark. Each setting has its reason beside it in src/games/spark.ts.
  • Doors: the box page lists stored profiles, and its link opens one without the secret. The terminal has the same list in a new screen, src/tui/screens/game_spark.ts, opened with p on the box screen. The how-to is docs/features/game-spark.md.
  • Reused: secret, sha256, readBounded, seesBox, boxOf and flashTo, with the secret-link pattern from the client pack.

Not done:

  • The forge doesn't decode or render a profile; spark's own viewer reads it.
  • The gzip check looks at the magic bytes only.
  • Profiles are stored in sqlite blobs under FORGE_APP_DATA.
  • No before/after look: the commit says No look: and the test covers the block.
  • bun scripts/gate.ts --fix still prints a similarity note that newSparkSecret resembles issueStatusToken in src/core/outsider_status.ts. I left it as it is.

Try it: as a box owner open /games/<box>, make an upload address under Profiles, then curl -X POST -H 'content-type: application/x-spark-sampler' --data-binary @profile.gz <address>post. The profile then shows in the list.

Tests: bun test test/game-spark.test.ts covers the post, the read with a grant, the refusals, the 403 for a wrong secret and the pruning. test/tui-games.test.ts gained the terminal screen.

🤖 Generated with Claude Code

commented

The two failures came from the new spark download routes not being named in the test lists that skip routes the fixtures can't fill. I named them and pushed. The three suites that carry those lists (no-polling, pages-budget, security-floor-routes) now pass, 34 tests in all. I did not re-run the full check.

I made three changes, all in tests:

  • test/no-polling.test.ts: added /games/@spark/:secret/:key and /games/:box/@spark/:key with a reason each.
  • test/security-floor-routes.test.ts: the same two routes in its list of patterns the seed can't fill.
  • test/budgets/unfixtured/: two new files, games-spark-secret-key.json and games-box-spark-key.json, one per route. These are what pages-budget reads for the "listed in a file of its own" test.

No app code changed.

commented

A game box now stores spark profiles: you post one to the box's secret address, and read it back with the box's grants. This push fixes the two failing check tests; both pass locally, and I ran no other tests this turn.

  • Open-routes walk: it had no values for :secret and :key, so the two new spark GET routes (/games/@spark/:secret/:key and /games/:box/@spark/:key) were left unfilled. I added those fills in test/open-routes-floor.test.ts, so the walk now requests both routes.
  • Data browser: the new game_spark_profile.body column matched the secret-looking pattern. I listed it as audited-clear in test/data-browser.test.ts, with a reason: it holds a capture of the box's own run, readable only with the box's grants, and no credential.

Both are test-side changes, because the tests were out of date with the new feature, not because the code was wrong. The bun scripts/gate.ts --fix run reported no rewraps to commit. It did flag newSparkSecret as 0.69 similar to issueStatusToken; I left that, as the gate's output reads as a note.

To try it: open a game box's page, then post a profile to its secret address and read it from the box's page; the terminal screen and the how-to for this came in the earlier commits.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs