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

Port Jay Moran's demo: actions/demo, refs/demo and moveRefLeased's caller, demo routes #16745

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An app can now pin one commit as its demo. It runs at --demo with a copy of production's data, and clearing it takes the environment down. I did not run bun test on the whole suite or bun scripts/design-lint.ts (no src/web/ change).

Notes

opened this

An app can now pin one commit as its demo. It runs at <slug>--demo with a copy of production's data, and clearing it takes the environment down. I did not run bun test on the whole suite or bun scripts/design-lint.ts (no src/web/ change). I ran tsc, gate --fix and the demo, contract/OpenAPI, activity and hook tests, which pass. I didn't use keep_plan or estimate.

What's in it

  • Jay's src/actions/demo.ts is taken whole from incoming/jay-main (ebc0adc), with setDemo and clearDemo. They are the caller of moveRefLeased and exactRefOid from git/branches.ts.
  • The ref refs/demo is the whole state, and no ref means no demo. Only a verified person who can write can pin or clear it; an agent can't, and a mirrored repository refuses. A push to refs/demo is refused in http/hook.ts.
  • PUT and DELETE /api/v1/repos/{owner}/{name}/demo are added in http/api/app.ts, with OpenAPI rows and a demo → apps tag alias. The app.demo event reads as "pinned/cleared the demo" in the activity feed.
  • The demo is now a fourth environment name, demo:
    • It is wired into apps/data.ts, apps/proxy.ts (host <slug>--demo), apps/tty.ts (ssh <slug>--demo) and actions/apps.ts.
    • It also touches actions/env_words.ts and apps/runtime_sleep.ts. A demo is a writer's choice, so it skips the preview-approval wait.
    • apps/runtime.ts rebuilds it from the ref when the forge restarts. As in Jay's design, it comes back asleep on boot.
    • core/apps.ts now reserves demo as a slug, so <theirs>--demo can never name an app.
  • test/apps-demo.test.ts is Jay's, with one change: its fixed-delay polling now uses test/helpers/poll.ts because the fixed-wait gate refused it. It covers:
    • host and login parsing;
    • a reader being refused;
    • a non-commit being refused;
    • a mirror being refused;
    • pin, deploy and the copy of production's data;
    • a push being refused;
    • rebuild on restart;
    • clear.

What I left out

  • actions/pin_demos.ts, DELETE …/builds/{label}/demo and the showcase and display side. That is #9053, and it depends on displays.
  • Jay's scripts/rewrite-demo-trailers.ts.
  • No new function was written, so there was nothing for similar.ts to compare; Jay's was ported.

To try it On an app with a commit <sha>, run PUT /api/v1/repos/<owner>/<name>/demo with {"sha":"<sha>"}. It answers 202 with the deploy run. Open <slug>--demo, then DELETE the same path to clear it. Or run bun test test/apps-demo.test.ts.

Review:

[{"go":"PUT /api/v1/repos/<owner>/<app>/demo {\"sha\":\"<commit>\"}","look":"202 with { sha, run }; <slug>--demo serves that commit with production's data","expect":"a reader gets 403; a non-commit gets 422 not_a_commit"},
 {"go":"git push origin <sha>:refs/demo","look":"the push output","expect":"refused: refs/demo is reserved"},
 {"go":"DELETE /api/v1/repos/<owner>/<app>/demo","look":"<slug>--demo","expect":"404 once cleared"}]

Co-authored-by: Jay Moran <[email protected]>

🤖 Generated with Claude Code

Closes #9196

6 earlier comments
commented

An app can now pin one commit as its demo. It runs at <slug>--demo with a copy of production's data, and clearing it takes the environment down. I did not run bun test on the whole suite or bun scripts/design-lint.ts (no src/web/ change). I ran tsc, gate --fix and the demo, contract/OpenAPI, activity and hook tests, which pass. I didn't use keep_plan or estimate.

What's in it

  • Jay's src/actions/demo.ts is taken whole from incoming/jay-main (ebc0adc), with setDemo and clearDemo. They are the caller of moveRefLeased and exactRefOid from git/branches.ts.
  • The ref refs/demo is the whole state, and no ref means no demo. Only a verified person who can write can pin or clear it; an agent can't, and a mirrored repository refuses. A push to refs/demo is refused in http/hook.ts.
  • PUT and DELETE /api/v1/repos/{owner}/{name}/demo are added in http/api/app.ts, with OpenAPI rows and a demo → apps tag alias. The app.demo event reads as "pinned/cleared the demo" in the activity feed.
  • The demo is now a fourth environment name, demo:
    • It is wired into apps/data.ts, apps/proxy.ts (host <slug>--demo), apps/tty.ts (ssh <slug>--demo) and actions/apps.ts.
    • It also touches actions/env_words.ts and apps/runtime_sleep.ts. A demo is a writer's choice, so it skips the preview-approval wait.
    • apps/runtime.ts rebuilds it from the ref when the forge restarts. As in Jay's design, it comes back asleep on boot.
    • core/apps.ts now reserves demo as a slug, so <theirs>--demo can never name an app.
  • test/apps-demo.test.ts is Jay's, with one change: its fixed-delay polling now uses test/helpers/poll.ts because the fixed-wait gate refused it. It covers:
    • host and login parsing;
    • a reader being refused;
    • a non-commit being refused;
    • a mirror being refused;
    • pin, deploy and the copy of production's data;
    • a push being refused;
    • rebuild on restart;
    • clear.

What I left out

  • actions/pin_demos.ts, DELETE …/builds/{label}/demo and the showcase and display side. That is #9053, and it depends on displays.
  • Jay's scripts/rewrite-demo-trailers.ts.
  • No new function was written, so there was nothing for similar.ts to compare; Jay's was ported.

To try it On an app with a commit <sha>, run PUT /api/v1/repos/<owner>/<name>/demo with {"sha":"<sha>"}. It answers 202 with the deploy run. Open <slug>--demo, then DELETE the same path to clear it. Or run bun test test/apps-demo.test.ts.

Review:

[{"go":"PUT /api/v1/repos/<owner>/<app>/demo {\"sha\":\"<commit>\"}","look":"202 with { sha, run }; <slug>--demo serves that commit with production's data","expect":"a reader gets 403; a non-commit gets 422 not_a_commit"},
 {"go":"git push origin <sha>:refs/demo","look":"the push output","expect":"refused: refs/demo is reserved"},
 {"go":"DELETE /api/v1/repos/<owner>/<app>/demo","look":"<slug>--demo","expect":"404 once cleared"}]

Co-authored-by: Jay Moran <[email protected]>

🤖 Generated with Claude Code

commented

This pull ports Jay Moran's demo wiring. PUT /api/v1/repos/<owner>/<name>/demo with {"sha":"<commit>"} pins a commit as an app's demo, and <slug>--demo then serves it. DELETE clears the pin.

The gate refused the last push on two rules, and a new commit fixes both. That commit changes no code. Its message carries a Direction: line naming issue #9196, taken from the branch name, and a No door: line. I ran bun scripts/gate.ts locally and it passes with no refusal. I did not rerun tsc or the tests, since nothing in the code changed.

  • No terminal screen or how-to: The demo pin is an API-only operator action, so I added no src/tui/screens/ entry and no docs/features/ page.
  • Similarity notes remain: The gate still lists three "one implementation?" notes, none of which block the push. They compare pinner and setDemo in src/actions/demo.ts with existing builds and preview code, and the test's git helper with the one in test/onboarding.test.ts. I did not merge them.

To try it, pin a commit with the PUT above on an app, then open <slug>--demo.

🤖 Generated with Claude Code

commented

This pull ports Jay Moran's demo wiring. PUT /api/v1/repos/<owner>/<name>/demo with {"sha":"<commit>"} pins a commit as an app's demo, and <slug>--demo then serves it. DELETE clears the pin.

The last check failed one test. The demo block I added to reconcileApp pushed src/apps/runtime.ts to 604 lines, over the 600-line cap in test/apps-runtime-split.test.ts. I compacted that block and the method signature, which brings the file to 595 lines. The behaviour is unchanged: a demo ref adds the demo environment, deploys it, and settles it asleep on boot.

The split test and test/apps-demo.test.ts pass, and tsc --noEmit and the gate are clean. The gate rewrapped runtime.ts, and that rewrap is in the commit. The gate's three "one implementation?" similarity notes are still there. They don't block the push, and I left them.

To try it, pin a commit with the PUT above, then open <slug>--demo.

🤖 Generated with Claude Code

commented

This pull ports Jay Moran's demo wiring. PUT /api/v1/repos/<owner>/<name>/demo with {"sha":"<commit>"} pins a commit as an app's demo, and <slug>--demo then serves it. DELETE clears the pin. The three items from sentinel's review are done, except that I couldn't confirm the slug check on production.

  • Terminal door: src/tui/screens/demo.ts adds a palette command "owner/name — Demo" for any app's repository. It calls setDemo and clearDemo, so it has the same gate as the API: a verified person who writes the repository, no agent, no mirrored repository.
    • p pins the tip of the default branch. x clears the demo after a confirm.
    • The screen reads refs/demo itself, so it shows a pin made through the API. Pinning an arbitrary commit stays API-only, because the screen has no input prompt.
    • test/demo-screen.test.ts covers the palette entry, a reader and a guest being refused, and a writer's pin landing on the ref the API reads. For clearing it only checks that x leaves the ref in place until the confirm is answered. A confirmed clear isn't tested.
  • How-to: docs/features/demo.md covers the screen, the API, the refusals and the reserved slug.
  • Contract: both rows now declare refuses: [401, 403, 404, 422].
  • Reserved slug demo: it is refused only when an app is created, so an existing row named demo would be untouched, but its demo--demo host would clash with the demo environment. I couldn't read production's apps from the sandbox, so I haven't confirmed that none exists. A person should run that check before merge. docs/features/demo.md also states this.

The tests I ran pass: the new screen test, test/apps-demo.test.ts, the runtime-split test, test/schedules-doors.test.ts, the contract and door tests. tsc --noEmit and bun scripts/gate.ts are clean, apart from three "one implementation?" similarity notes that were already there and don't block. scripts/fast.ts named 3,783 test files for this diff, because the screen is imported by workspace.ts, so I ran only these targeted tests.

To try it, open the app's repository, run the Demo command from the palette and press p, then open <slug>--demo.

🤖 Generated with Claude Code

commented

I fixed the gate refusal and pushed it as 7484b4af1. I haven't seen the forge's check run on that push yet.

The fix: test/demo-screen.test.ts cast its key events with { key: "p" } as never. It now builds real KeyEvent records through a small press(key) helper. That is what the "a test builds the real input, not as never" rule asked for.

What I ran:

  • The demo screen test passes, 4 of 4.
  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts no longer reports any rule failures.

Left alone: the gate's other output is advisory notes, not failures. It says four helpers resemble existing ones: pinner, setDemo, demoCommands and the test's make. It also says five files have comment lines over 100 columns. I didn't merge or rewrap any of those in this pull.

To try it: run bun test test/demo-screen.test.ts.

commented

I fixed two of the three failing tests and pushed the result as a5c6820fc. The third, the /llms.txt byte budget, still fails here, and the check already found it red on main too.

  • NOT_YET_DESCRIBED: this test came from main, which had moved 20 commits. I merged main into the branch, and the test passes now with no further change.
  • Declared refusals: the demo PUT and DELETE routes declared a 422 that the contract probe never sees. The probe calls nobody/nobody and gets 404 every time. They now declare 401, 403 and 404, and the 422 is described in each route's detail text. I also shortened the summaries and details of both routes.
  • /llms.txt budget: the admin view is 99,232 bytes against a limit of 99,200. Shortening my routes' text did not change that size, so the overage doesn't come from the demo routes, though I didn't pin down where it does come from. The forge's check ran the same file on main at e78d344 and got the same red, so it isn't counted against this pull. I did not raise the budget.

The OpenAPI tests, the type check and the gate pass here. The forge's full check will rerun on this push.

commented

This ports Jay Moran's demo pin. It adds actions/demo.ts with setDemo/clearDemo behind one pinner gate: a verified person who can write the repository, never an agent, never on a mirror. It also adds the refs/demo ref, which moveRefLeased moves after checking the oid is a commit. The hook refuses pushes to refs/demo. The rest is the PUT/DELETE …/demo routes, the terminal screen src/tui/screens/demo.ts that goes through the same actions, and the how-to docs/features/demo.md.

This push answers the review on the terminal's clear:

  • The confirmed clear is tested. test/demo-screen.test.ts now captures the confirm screen that x pushes and answers it by key (right, enter):
    • A writer who chooses Clear gets "Demo cleared." and refs/demo is gone.
    • A reader (bob) who chooses Clear gets the forbidden words and the pin stays.
    • Cancel leaves the pin and shows no toast.
  • The tests fail without the code. With the onChoose call to clearDemo deleted, the writer and reader tests both fail.
  • Readers can see the pin, and the how-to says so. docs/features/demo.md now states that anyone who can read the repository sees the pinned commit and the demo's address, including on the terminal screen.

bun test test/demo-screen.test.ts passes (6 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --explain has no failing rule. It leaves two notes. One is about long comment lines in files this pull doesn't touch, which the nightly rewrap handles. The other says pinner resembles writerOf in actions/builds.ts. I kept them separate: pinner also refuses unverified users and mirrors, which writerOf doesn't.

[{"go":"/trevato/forge/pulls/16745/files","look":"test/demo-screen.test.ts, the clearing block","expect":"three tests: Cancel leaves the pin, a reader's Clear is refused with the forbidden words, a writer's Clear removes refs/demo"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs