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

Absorb: fire a feature's schedule #9916

Parked opened this
Closed without merging

The forge now fires an absorbed feature's schedule. The earlier pull #9892 failed one test, and this push fixes that test. The gate, tsc and the feature tests pass here.

Notes

stopped parked by the crew deploy 58d109f

opened this

The forge now fires an absorbed feature's schedule. The earlier pull #9892 failed one test, and this push fixes that test. The gate, tsc and the feature tests pass here. I did not run the full suite or boot the forge to fire a real app. The knock is tested against a stub runtime and a stub fetch, plus one real local server.

What changed

  • Declaration: a feature in forge.json may carry "schedule": { "path": "/run", "hour": "runHourUtc", "days": "runDays" }. hour names an int setting (0–23). days is optional and names a days setting; without it the knock is daily. The parser rejects a bad path or setting name and names the field.
  • Knock: src/apps/schedule.ts looks every minute. For each absorbed app with a running production, it POSTs to the app's own loopback port in the scheduled UTC hour, with a 30 second limit.
    • Once per hour: the slot is claimed in a new table, app_feature_fire, before the call. A restart does not knock twice, and a failed knock is not retried in that hour.
    • Headers: the request carries a signed x-forge-identity with role schedule, and x-forge-schedule holds the slot.
    • Previews: a preview's forge never knocks.
  • Where it shows: the settings page, GET /api/v1/features/:slug and the features MCP tool (with a slug) all carry a schedule sentence. It gives the declared schedule and what the last knock got. No new MCP tool was added, so the test/mcp-size.test.ts ceilings are untouched.
  • Docs: docs/features/absorb.md describes the schedule.

The red check on #9892

  • What failed: one test, the timer-wiring test in test/feature-schedule.test.ts, failed in the forge's check. It passes here, so I can't confirm the cause.
  • Most likely cause: the test did not pass an explicit env, so it read the process environment. In the check that environment can look like a preview, and a preview starts no timer.
  • Fix: it now passes env: {}, polls up to 10s in 10ms steps, and has a 30s timeout.
  • Other changes: none to the source in this push, and I merged the current main.

Left out

  • There is no "fire now". To see a real fire, set the hour setting to the current UTC hour.
  • The terminal screen shows no schedule.
  • A UTC hour the forge was down for is not made up.

Try it: absorb an app whose forge.json declares a schedule, then set its hour setting to the current UTC hour. Within a minute the app gets POST <path>, and /settings/features/<slug> reports the status.

Closes #9883

Show 2 earlier items

7 earlier comments · 1 event
commented

The failing check test, "the timer is wired", is now deterministic. I couldn't reproduce the failure here, so the fix targets the most likely cause. After the change, test/feature-schedule.test.ts and bun x tsc --noEmit both pass here. I did not run the other gate and design checks, and I have not seen the forge's check on the new push.

Cause (my best guess): the test set runHourUtc from the real clock's hour, and the timer then fired on the real Date.now(). A loaded check run that crossed an hour boundary between those two points would never match the slot, so the timer would never fire and the 10-second wait would run out. The check log didn't show which of these happened.

Change:

  • startFeatureSchedule in src/apps/schedule.ts takes an optional now clock. The default is still Date.now, so production behaviour is unchanged.
  • The test passes a fixed clock (2027-01-05 13:00 UTC) with the hour setting at 13, so the real hour can no longer interfere.

Not done: I made no other changes to the schedule logic.

Try it: bun test test/feature-schedule.test.ts

commented

I merged main into the branch and pushed it. There was one conflict, in docs/features/absorb.md, and it is resolved.

  • The conflict: the sentence listing what absorb does not yet do. This branch had dropped the schedule (#9883) from it, because it now fires schedules. main had dropped the feed items (#9884). I kept both removals, so it now says only that the forge does not yet keep secret settings (#9886).
  • Checks: bun x tsc --noEmit and bun scripts/gate.ts ran clean (the gate printed nothing). test/feature-schedule.test.ts and test/features.test.ts pass, 53 tests in all. I did not run the full suite; the forge's check does that on this push.
commented

The schedule timer test no longer waits on a real timer, and I pushed that. I could not reproduce either failure here, so I have not confirmed the cause. bun x tsc --noEmit and the gate are clean, and test/feature-schedule.test.ts passes (15 tests), but the forge's check has not yet run on this push.

  • Schedule timer test: it failed the same way, in about 0.2 ms, in two separate check runs, even after I made its clock deterministic. A failure that fast suggests the wait loop never got a real timer to wait on, so I stopped relying on one. startFeatureSchedule now takes an optional every argument, a function that sets up the repeating tick. The default is still the one-minute setInterval, so production behaviour is unchanged. The test passes its own and calls the tick directly. It still checks that the tick fires the app's /run and that a preview starts no timer.
  • a head that moved since the page was read is stale: this is in test/finish-conflicts-refusals.test.ts, which this pull does not touch. It passed three times in a row here, so it looks like a flake under load and I made no change to it. If it fails again on this push, it needs its own look.
commented

I merged main into the branch and pushed it. There were two conflicts, both resolved, and the checks below pass. bun x tsc --noEmit and the gate ran clean, and test/feature-schedule.test.ts plus test/features.test.ts pass (54 tests). I did not run the full suite; the forge's check does that on this push.

  • src/core/features.ts: I kept both sides. This branch adds the schedule helpers (claimFire, recordFire, lastFire, fireSays). main adds clearFeatureSettings for cleared secrets. Both ended on the same closing brace, so I gave each its own.
  • docs/features/absorb.md: the "Not done yet" section listed only the schedule (#9883) on one side and secret settings (#9886) on the other. With the schedule firing here and secrets now kept on main, nothing was left in it, so I removed the section.
Changes requested — before the latest push

Changes requested. The schedule logic is sound, but it fails four items on the list.

  1. Both doors: there is no terminal screen in src/tui/. The pull says so itself ("The terminal screen shows no schedule"), but what the settings page shows, the terminal must show too. Add the schedule sentence to a src/tui/ screen with its entry where AGENTS.md says, and test it.
  2. Direction: the owner says pipeline first (#6534, #6611, #5276, #3316, #6217, #6428, #1242, #1073), before any feature. This is an Absorb feature. If it is not one of those issues, say in the pull why it goes first. Otherwise hold it.
  3. Clean: the test/crew-week.test.ts change (forgetStagger()) has nothing to do with the schedule. Split it into its own pull or drop it.
  4. Security: the proxy drops only x-forge-identity and x-forge-signature (IDENTITY_HEADERS), not x-forge-schedule. A visitor can send that header, and the docs imply the proxy cleans the forge's headers. Strip it too, with a test, or say in the docs that an app must trust the slot only together with a verified schedule identity.

Design: the settings-page change is one <p class="muted small"> in the existing tokens. It adds no card or box, no extra accent and nothing that needs JavaScript, so no design finding. The preview answers 200. A preview's forge never knocks, so I could not see a real fire there.

commented

Three of juniper's four items are fixed and pushed. Item 2, the pipeline-first ordering, is not: the pull does not say why this goes first, and I did not hold it back. gate.ts, design-lint and tsc are clean, and the schedule, features, features-tui and apps-identity tests pass. I did not run the full suite, and the check runs it on the push.

What changed

  • Terminal (item 1): the feature settings screen in src/tui/screens/featureswitch.ts now has a header line, Schedule: POST /run at the hour in runHourUtc, daily; …. It comes from the same schedule string the page uses. It needs no new palette entry, because the screen is reached through the existing Features entry. A test in test/features-tui.test.ts covers it.
  • Page and sentence: the loose paragraph is now a "Schedule" row in the dl beside the provenance facts. I rewrote the sentence as one line, POST /run at the hour in <setting>, daily; last 2026-11-30 13:00 UTC, answered 204. "Not retried" now appears once, and only when the call failed.
  • Proxy (item 4): x-forge-schedule is now in IDENTITY_HEADERS, so the proxy strips it. test/apps-identity.test.ts sends a forged copy and asserts the app sees none. docs/features/absorb.md says so.
  • Unrelated change (item 3): test/crew-week.test.ts is reverted to main's version.

Direction (item 2): the pull is an Absorb feature and is not one of the listed pipeline issues, and I have no reason that it should go first. A person should decide whether to hold it.

Left out:

  • A preview never fires, so I haven't seen a real knock end to end. The integration test with a listening server covers the call.
  • The bets.* files differ from main in the diff, and I left them as they were.

Try it: absorb an app whose forge.json has "schedule": {"path": "/run", "hour": "runHourUtc"}. Settings › Features › that app shows the Schedule row, and the terminal's Features › Enter shows the same text.

🤖 Generated with Claude Code

commented

I pushed a change to test/build-cart.test.ts, but I'm not certain it fixes the failure. I never saw the failing assertion. The check log only names the test.

  • What I found: the test passes on its own, and it passed in 6 repeated runs here. It doesn't touch anything this pull changed. The pull never touched test/build-cart.test.ts.
  • My best guess: the earlier test in that file starts a background capture of a repository that isn't an app, and waits a fixed 50 ms for it to record "failed". On a loaded shard that failure can land late and overwrite the "done" state the next test creates.
  • The fix: that test now polls until the "failed" state appears, up to about 5 seconds, instead of sleeping 50 ms. It passes here, and tsc is clean.
  • If it comes back: the cause was something else. The next failure log should then show the assertion that broke.

The pull's description from my last message is unchanged.

commented

The check failed on a test I can't tie to this pull, and I changed nothing, so there is nothing new to push.

  • Reproduction: asking again over HTTP > a writer queues a check and gets the run is in test/pull-check-again.test.ts. It passed 8 of 8 when I ran it alone. It passed again in six more runs alongside test/feature-schedule.test.ts.
  • No link to this pull: the pull's diff touches no file that test depends on (src/checks/again.ts, src/checks/service.ts, the checks route in src/http/api.ts). The scheduling, feature, proxy, bets and TUI changes sit elsewhere.
  • Likely cause: I'm guessing this is a flake under load. The log shows the failure in 4.5 ms, so the request probably got a non-202 answer (for example "no check declared") before the checks service was ready. The same log shows another shard killed after 23 s, which fits a loaded machine. I couldn't see the actual status code.
  • Failure unseen: the log tail has the failing line but not the assertion output, so I couldn't confirm the cause.

I didn't edit the test or src/checks/ on a guess. To re-run the check, push an empty commit, or rerun the check on the forge. If the failure comes back, send me the assertion message (the status it got instead of 202) and I'll fix the cause.

commented

Parked by the crew: the check stayed red through 2 automatic tries: asking again over HTTP > a writer queues a check and gets the run

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs