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

API routes the Apple app lacks: the arcade's games, an app's log, pausing a runner #18075

opened this in answer to

Merged 9h 28m ago, live in production

The three routes the Apple app asked for now exist, are in openapi.json and are tested. Typecheck, the gate and the targeted suites I ran (827 tests across the openapi, contract, feature-doc, boot-lazy and TUI-runners files) are green. I did not run the full suite; the forge runs it on this push.

Notes

opened this

The three routes the Apple app asked for now exist, are in openapi.json and are tested. Typecheck, the gate and the targeted suites I ran (827 tests across the openapi, contract, feature-doc, boot-lazy and TUI-runners files) are green. I did not run the full suite; the forge runs it on this push.

What changed

  • GET /api/v1/arcade/games is public, like the arcade host.
    • It lists the same games and builds as the host's games.json, plus play_url on each build (the host's address and the build's file).
    • The answer is { host, items, next_cursor: null }. With no Arcade display it is empty (and host is null where apps don't run) instead of the host's 404.
    • The code is in src/arcade/games_list.ts and src/http/api/arcade.ts. I added arcade under the builds tag in src/contract/tags.ts and a mark file src/http/marks/api-v1-arcade.json.
  • GET /api/v1/repos/{owner}/{name}/app/{env}/log is for people who may write the repository.
    • It answers the last 200 lines as text/plain, with x-log-truncated: 1 when earlier lines were cut. The lines are masked as the run log is.
    • It reads the deploy run that serves the environment (src/actions/app_log.ts). An environment that never ran answers an empty body.
    • A reader gets 403, a signed-out caller 401, a bad environment name 422 no_such_env, and an unseen repository 404.
  • POST /api/v1/admin/runners/{id}/pause sits beside resume and revoke.
    • The runner's paused text reads paused by <admin>, and a runner.paused event is written.
    • It answers 422 for local (the forge's own local-N), revoked and paused.
    • The terminal's Runners screen gets a p key that calls the same action.

What I chose not to do

  • No per-app scale, and nothing built on PUT /api/v1/admin/capacity/{key}.
  • No follow or SSE stream on the app log; a client asks again.
  • No new terminal screens for the arcade list or the app log. The commit says No door: with the reason: the Display screen already shows the shelf's Launch address, and the feed already tails run logs. Only pause was a missing action, so it got the key.
  • bun scripts/gate.ts notes that pause is 0.64 similar to resume in src/actions/runners.ts. I kept them apart because their refusals differ.

Reused: readRunLogTail, requireWriter, shelfOf, arcadeHome and arcadeDisplay, and the runner's existing pauseRunner.

Try

  • curl $FORGE_URL/api/v1/arcade/games
  • curl -H "authorization: Bearer <writer token>" $FORGE_URL/api/v1/repos/<owner>/<name>/app/production/log
  • curl -X POST -H "authorization: Bearer <admin token>" $FORGE_URL/api/v1/admin/runners/<id>/pause
  • In the terminal, open Runners, move to a runner, press p, then u to resume.

Tests and docs: test/app-log-api.test.ts covers the log and pause, test/arcade-host.test.ts covers the games list against games.json, and test/tui-runners.test.ts covers the p key. How-tos are added to docs/features/runners.md, arcade-carts.md and log-reader.md.

Closes #18038

2 earlier comments
commented

The three routes the Apple app asked for now exist, are in openapi.json and are tested. Typecheck, the gate and the targeted suites I ran (827 tests across the openapi, contract, feature-doc, boot-lazy and TUI-runners files) are green. I did not run the full suite; the forge runs it on this push.

What changed

  • GET /api/v1/arcade/games is public, like the arcade host.
    • It lists the same games and builds as the host's games.json, plus play_url on each build (the host's address and the build's file).
    • The answer is { host, items, next_cursor: null }. With no Arcade display it is empty (and host is null where apps don't run) instead of the host's 404.
    • The code is in src/arcade/games_list.ts and src/http/api/arcade.ts. I added arcade under the builds tag in src/contract/tags.ts and a mark file src/http/marks/api-v1-arcade.json.
  • GET /api/v1/repos/{owner}/{name}/app/{env}/log is for people who may write the repository.
    • It answers the last 200 lines as text/plain, with x-log-truncated: 1 when earlier lines were cut. The lines are masked as the run log is.
    • It reads the deploy run that serves the environment (src/actions/app_log.ts). An environment that never ran answers an empty body.
    • A reader gets 403, a signed-out caller 401, a bad environment name 422 no_such_env, and an unseen repository 404.
  • POST /api/v1/admin/runners/{id}/pause sits beside resume and revoke.
    • The runner's paused text reads paused by <admin>, and a runner.paused event is written.
    • It answers 422 for local (the forge's own local-N), revoked and paused.
    • The terminal's Runners screen gets a p key that calls the same action.

What I chose not to do

  • No per-app scale, and nothing built on PUT /api/v1/admin/capacity/{key}.
  • No follow or SSE stream on the app log; a client asks again.
  • No new terminal screens for the arcade list or the app log. The commit says No door: with the reason: the Display screen already shows the shelf's Launch address, and the feed already tails run logs. Only pause was a missing action, so it got the key.
  • bun scripts/gate.ts notes that pause is 0.64 similar to resume in src/actions/runners.ts. I kept them apart because their refusals differ.

Reused: readRunLogTail, requireWriter, shelfOf, arcadeHome and arcadeDisplay, and the runner's existing pauseRunner.

Try

  • curl $FORGE_URL/api/v1/arcade/games
  • curl -H "authorization: Bearer <writer token>" $FORGE_URL/api/v1/repos/<owner>/<name>/app/production/log
  • curl -X POST -H "authorization: Bearer <admin token>" $FORGE_URL/api/v1/admin/runners/<id>/pause
  • In the terminal, open Runners, move to a runner, press p, then u to resume.

Tests and docs: test/app-log-api.test.ts covers the log and pause, test/arcade-host.test.ts covers the games list against games.json, and test/tui-runners.test.ts covers the p key. How-tos are added to docs/features/runners.md, arcade-carts.md and log-reader.md.

commented

The failing check is fixed and pushed. I ran test/pages-budget.test.ts locally and it passes (4 tests). I did not run the full suite, tsc or the gate.

The new /api/v1/repos/:owner/:name/app/:env/log route has no page-budget fixture, and the budget test requires every such route to be listed in test/budgets/unfixtured/. I added api-v1-repos-owner-name-app-env-log.json there, copied from the existing entry for the sibling …/app/:env/open route. It gives the same reason: no fixture holds the id this route needs.

Nothing else changed. The commit carries No door: because it touches only a test file list.

commented

The second check failure is fixed and pushed. I re-ran test/route-timing-coverage.test.ts locally and all 4 tests pass. I didn't run the full suite, tsc or the gate.

GET /api/v1/arcade/games answers 200 without a session phase. I added it to the UNTIMED allowlist in test/route-timing-coverage.test.ts, with the reason that it's a plain read with no page to phase. I chose the allowlist over adding timing phases to the route; that is the call to question if you'd rather the route report phases. The commit says No door: because only a test file changed.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs