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

A pinned deploy writes its DNS record as soon as the machine has an address,… #16524

Merged opened this in answer to

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

Merged

The forge now watches its own pinned forges after a deploy, an Update, a Roll back or a new claim link, so nobody has to press Check. I ran test/pinned.test.ts and test/feature.test.ts (329 pass), the cloud and migration tests, and the type check; the forge's full check hasn't run yet.

Notes

shipped production is serving it deploy d5add18

opened this

The forge now watches its own pinned forges after a deploy, an Update, a Roll back or a new claim link, so nobody has to press Check. I ran test/pinned*.test.ts and test/feature*.test.ts (329 pass), the cloud and migration tests, and the type check; the forge's full check hasn't run yet.

  • The watch: every 5 seconds, for at most 5 minutes, it reads the machine's address while there is none and writes the DNS record as soon as there is one. It keeps going until the forge answers over HTTPS. Each step's time is stored (new pinned_watch table) and raised as a pinned.watch event. The loop is in src/actions/pinned_watch.ts. It is held in memory, one loop per forge, taken in the forge's own turn so it never runs beside an Update or claim.
  • Restart: main.ts calls resumePinnedWatches at boot, which starts the watch again for every row that is neither answered nor given up. The watch only starts once main.ts arms it, so other tests of a deploy start no timers.
  • Deploy answer: with a Cloudflare account that allows writes, it now says the forge writes the record as soon as the machine has an address and nobody needs to press Check. Without one, it says to create the record by hand.
  • Past the bound: the forge gives up once, raising one pinned.waiting_long event (which already reaches admins). The row on /pinned and the terminal's Check line show what is missing and what to try: no address, no record written, or no answer over HTTPS.
  • Tests: test/pinned-watch.test.ts has three cases:
    • The address appears on the third read; the record is written and the answer heard, with no Check call.
    • A restart in the middle resumes the wait.
    • A wait past its bound says so exactly once.
  • Reused: readAddress, writeDns, hear and oneChange from pinned.ts as they were. I did not run scripts/similar.ts.
  • Not done: scripts/fast.ts named 2,375 test files, so I ran the pinned, cloud, migration and feature-doc tests by hand instead. I did not touch src/cloud/machine.ts. There is no per-row history of attempts, only the latest wait's times. The terminal shows the stuck sentence only after Check, not on its own.
  • Look: this has no before/after look; the page gains one sentence only when a wait has run out.

To try it, deploy a pinned forge with the base domain set and a Cloudflare account that allows writes, then wait without pressing Check. The record should appear within about 5 seconds of the machine getting an address.

[{"go":"/pinned","look":"a deployed forge's DNS record row","expect":"says the forge reads the address itself, with no 'Check reads' text"},{"go":"/pinned","look":"a forge that never answered for 5 minutes","expect":"a status sentence saying what is missing and what to try"}]

Closes #16372

5 earlier comments · 1 event
commented

The forge now watches its own pinned forges after a deploy, an Update, a Roll back or a new claim link, so nobody has to press Check. I ran test/pinned*.test.ts and test/feature*.test.ts (329 pass), the cloud and migration tests, and the type check; the forge's full check hasn't run yet.

  • The watch: every 5 seconds, for at most 5 minutes, it reads the machine's address while there is none and writes the DNS record as soon as there is one. It keeps going until the forge answers over HTTPS. Each step's time is stored (new pinned_watch table) and raised as a pinned.watch event. The loop is in src/actions/pinned_watch.ts. It is held in memory, one loop per forge, taken in the forge's own turn so it never runs beside an Update or claim.
  • Restart: main.ts calls resumePinnedWatches at boot, which starts the watch again for every row that is neither answered nor given up. The watch only starts once main.ts arms it, so other tests of a deploy start no timers.
  • Deploy answer: with a Cloudflare account that allows writes, it now says the forge writes the record as soon as the machine has an address and nobody needs to press Check. Without one, it says to create the record by hand.
  • Past the bound: the forge gives up once, raising one pinned.waiting_long event (which already reaches admins). The row on /pinned and the terminal's Check line show what is missing and what to try: no address, no record written, or no answer over HTTPS.
  • Tests: test/pinned-watch.test.ts has three cases:
    • The address appears on the third read; the record is written and the answer heard, with no Check call.
    • A restart in the middle resumes the wait.
    • A wait past its bound says so exactly once.
  • Reused: readAddress, writeDns, hear and oneChange from pinned.ts as they were. I did not run scripts/similar.ts.
  • Not done: scripts/fast.ts named 2,375 test files, so I ran the pinned, cloud, migration and feature-doc tests by hand instead. I did not touch src/cloud/machine.ts. There is no per-row history of attempts, only the latest wait's times. The terminal shows the stuck sentence only after Check, not on its own.
  • Look: this has no before/after look; the page gains one sentence only when a wait has run out.

To try it, deploy a pinned forge with the base domain set and a Cloudflare account that allows writes, then wait without pressing Check. The record should appear within about 5 seconds of the machine getting an address.

[{"go":"/pinned","look":"a deployed forge's DNS record row","expect":"says the forge reads the address itself, with no 'Check reads' text"},{"go":"/pinned","look":"a forge that never answered for 5 minutes","expect":"a status sentence saying what is missing and what to try"}]
commented

The forge now waits on a pinned forge by itself: it reads the address, writes the DNS record and hears the answer without anyone pressing Check (#16372). The last push fixes the failed "both doors" gate, and I have not seen the forge's verdict on it yet.

  • Gate: I added a commit line No door: … saying the watch has no door of its own. It runs in the background and shows on the existing /pinned page and its terminal screen, which this pull already changes, and docs/features/pinned-forge.md is updated too.
  • Local gate: bun scripts/gate.ts still printed the "both doors" refusal here, after the No door commit, so the forge's rerun is the real test. Its refusal text asks for a commit message line, which is what I added.
  • Checks: bun x tsc --noEmit is clean, and test/pinned-watch.test.ts passes (3 tests). I did not run the rest of the suite; the forge runs it on the push.
  • Long comments: bun scripts/gate.ts --fix changed nothing. The gate still reports one over-long comment line in each of src/actions/pinned.ts, src/tui/screens/pinned.ts and src/web/pages/pinned.ts, and says the nightly rewrap handles them on main.
  • Left out: I did not add a separate terminal screen for the watch itself.

To try it, pin a forge and open /pinned, or use the pinned screen in the terminal. The steps (address, DNS, answered, gave up) should appear on their own without pressing Check.

commented

I fixed the three failures that came from my change and pushed. The fourth, the 2,000-render heap test, I didn't touch. It doesn't exercise this code, and the watch is off unless main.ts arms it. I haven't seen the forge's check run on this push yet.

  • Hollow and dead-code tests: stopWatches was exported from src/actions/pinned_watch.ts but nothing in src/ called it; only my test did. It is now WATCH.stop(app), a member of the existing WATCH object, so there is no unreached export.
  • Timer test: the watch's sleep timer in src/actions/pinned_watch.ts is now wrapped in during("pinned-watch", …), as the other background timers are.

tsc is clean here. test/pinned-watch.test.ts, test/hollow.test.ts, test/unused-exports.test.ts and test/timers-named.test.ts all pass (42 tests).

I couldn't reproduce the heap-growth test in the time I had. If it stays red on the forge's rerun, it may be flaky under load or a real leak, and it will need its own look.

commented

The failing check was the job-slices test that requires every job passed to during in src/ to be timed or listed in UNTIMED. I've fixed it and pushed.

The pinned watch's sleep timer (pinned-watch in src/actions/pinned_watch.ts) was in neither place. I added it to UNTIMED in test/job-slices.test.ts with the reason. It's a one-shot timer that only resolves the sleep between looks at a pinned deploy, with no work of its own. test/pinned-watch.test.ts drives the watch with a short sleep.

test/job-slices.test.ts, test/pinned-watch.test.ts, test/route-timing-coverage.test.ts and bun x tsc --noEmit all pass.

I did not run bun scripts/gate.ts --fix to rewrap comments. It only noted three files with comment lines over 100 columns (src/actions/pinned.ts, src/tui/screens/pinned.ts, src/web/pages/pinned.ts) and said the nightly rewrap handles them on main.

No app code changed, only the test's list of untimed jobs.

commented

I merged main into the branch and pushed. The one conflict was in src/tui/screens/pinned.ts, in the c key handler.

  • Resolution: main's new f key, which files the forge in its cloud project, now sits next to my c handler. The c handler still shows checkWords plus the stuck advice from the watch.
  • Checks: tsc is clean, and the pinned tests (222) pass here, including test/pinned-watch.test.ts. bun scripts/fast.ts exited 2 because the diff touches scripts/gate.ts and is too broad to name tests, so I ran only the pinned tests rather than the full suite. The forge runs the full check on this push.
  • Gate: bun scripts/gate.ts --fix changed nothing. It printed a note that checkPinned and deployPinned in src/actions/pinned.ts look like one implementation, and the same note about long comment lines in two files. I did not act on either.
Changes requested — before the latest push

The watch does what #16372 asks and its three tests are real. Four things to fix in one round:

  1. A stale 'stuck' sentence never clears (first fix). stuck shows while gaveUpAt is set and answeredAt is empty, but only the watch loop ever sets answeredAt, and the loop has ended once it gave up. If the person fixes DNS and presses Check, the forge answers and goes running, yet /pinned keeps saying 'does not answer over HTTPS' for ever. Fix: when Check (checkAs) hears the forge answer, mark answeredAt (or compute stuck as empty whenever the forge answers or state is running), and add a test: give up, then Check with answers on, then the view's stuck is empty.
  2. Both doors. The web row shows the stuck sentence on its own, but the terminal shows it only after pressing c. A person in the terminal must see it on the forge's row or detail like the page does. Render p.stuck in src/tui/screens/pinned.ts where the row is drawn, and add a test.
  3. Tests for what the page and the answer say. Nothing tests that /pinned renders the role=status sentence when stuck (and not otherwise), nor the claimWords branch with no Cloudflare write account ('by hand once Check reads its address'). Add both. Also test/pinned-watch.test.ts imports from ../src/actions/pinned.ts twice; merge them.
  4. Design (principles 1 and 8). The stuck sentence is a three-clause paragraph that repeats what the DNS record row already says. Keep it to one plain sentence naming the missing thing and the one action, per docs/WRITING.md, and put it with the DNS record dl row rather than as a loose <p> under the list. The preview shows no row in the stuck state, so I could not see it working; the test in 3 should cover it.

Security, README (untouched) and feature doc (updated) are fine.

commented

A pinned deploy now writes its DNS record as soon as the machine has an address, and the forge waits for the answer without anyone pressing Check. This round addresses the four review points.

What changed

  • Stale "stuck" sentence: checkAs now marks answeredAt when Check hears the forge answer. The stuck sentence is empty from then on. The test gives up, runs Check with answers on, and checks that stuck is empty on the view, the page and the terminal.
  • Both doors: the terminal row in src/tui/screens/pinned.ts now shows p.stuck, as the page does. A test draws the screen and looks for it.
  • Tests:
    • /pinned renders <span role="status"> when stuck and omits it otherwise.
    • claimWords with no write account says "by hand once Check reads its address", and not "nobody needs to press Check".
    • The two imports from ../src/actions/pinned.ts in test/pinned-watch.test.ts are merged into one.
  • Design:
    • Each stuck sentence is now one plain sentence naming what is missing and the one action. For example: "<name> does not answer over HTTPS: make its record DNS only, then press Check."
    • It sits inside the "DNS record" row of the dl as a role=status span. The loose <p> is gone.
    • A test asserts the sentence is a single sentence. I did not rerun the preview in the stuck state, so the row's rendering is covered only by that test.

Checked

  • tsc --noEmit, design-lint and gate --fix are clean.
  • The 20 pinned-* test files pass (224 tests).

Left out

  • I did not add a cancel or retry control to the watch. Check is still the only manual step.
  • I did not run the full suite. The forge runs it on push.

To try

  • Deploy a pinned forge whose address never appears. After 5 minutes /pinned and the terminal row both show the sentence, and Check clears it once the forge answers.
Approved

All four earlier asks are met in the diff since 24e406ece. I opened the preview: /pinned answers 303 to /signin with the security headers set, so the signed-in row was not visible to me; I read it from the source and tests.

  • Stale stuck sentence: checkAs now marks answeredAt when Check hears the forge, and a test shows the sentence cleared on the view, the page and the terminal.
  • Both doors: the terminal row shows p.stuck, and a test draws it.
  • Tests: the role="status" span and the claimWords no-write-account wording are both covered.
  • Design: the stuck sentence is one plain sentence inside the DNS record dl row, with no loose card or paragraph.

Next, in order:

  1. Non-blocking: stuck clears only on answeredAt. If Check reads the address but the forge still does not answer, the row keeps saying "no address after 5 minutes". Derive the words from the current address and DNS state when the row is drawn.
  2. Non-blocking: the web row states the stuck sentence but gives no button for Check. Add a post-form Check button beside it so the advice can be acted on from the page.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs