Skip to content

CR4: cron-starter becomes an Orun baseline - #5

Merged
ruehowl merged 2 commits into
mainfrom
claude/blissful-ptolemy-c5ajf8
Oct 15, 2026
Merged

ruehowl merged 2 commits into
mainfrom
claude/blissful-ptolemy-c5ajf8

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

CR4 (task CR-5). This turns the repository into an Orun baseline. It is a card (blueprint.yaml) plus a build document (repo-blueprint.yaml) that take a new product from nothing to live on stage and prod in one landing, using cirrus-baseline v22's shape. It is ported from kv-redis-starter (sourceplane/kv-redis-starter#5) and adapted for a Worker with a scheduled handler. The Workers Free plan is enough.

What was added

  • Two phases. 01-product places every module, brands it and lands it as one PR. Its post hooks run retouch → git-init → stage → rebrand → orun-workspace → work-tree strip → promotion/dev-lanes defer → restage → rebrand-verify → lockfile → orun.repo/ensure → link → reconcile CLOUDFLARE_API_TOKEN (workers-deploy) and CLOUDFLARE_ACCOUNT_ID (account-id) → orun.pr/land. Its await watches the merge sha, checks WIRING_CLOUDFLARE_KV exists on stage and prod, and probes both URLs. 02-docs is hook-only: it restores the deferrals, renders the deployment record and lands it.

  • KV is applied before the Worker deploys. apps/web declares dependsOn: cloudflare-kv with mode: enforced, plus modeRules that make it advisory on github-pull-request. In the product's own orun plan --trigger github-push-main, the KV applies run at lane level 0. Each web deploy runs at level 1 and waits only on its own environment's apply.

  • One Cron Trigger per Worker (second commit). Cloudflare counts triggers per account, and Free allows 5. The Worker now registers only * * * * *, so a product uses 2 triggers. The scheduled handler checks the seven schedules in lib/crons.ts against the trigger's scheduledTime, in UTC:

    • 1m every minute
    • 10m when minute % 10 == 0
    • 1h at minute 0
    • 12h at 00:00 and 12:00
    • 1d at 00:00
    • 1w at 00:00 on Sunday, the template's 0 0 * * 0
    • 1mo at 00:00 on the 1st

    Each due schedule runs /api/cron/<interval> through the OpenNext fetch handler, as before. A failing route doesn't stop the others, and the invocation then fails, naming each failure. The page and /api/data/<interval> are unchanged.

  • The cron path survives a staged build. The handler is in the committed entry worker.ts, and the trigger is in the template the build re-renders. Both are asserted on the config the lane's own build writes.

  • The smoke checks that a cron run happened. It reads /api/data/1m and requires a fetchedAt from the last ten minutes. Before, it only grepped / for the heading text.

  • Latent bugs fixed, as in KR:

    • wrangler.jsonc was git-ignored, but verify-app-structure checks for it before the build. It is now committed as the fixture render, and Checks diffs it.
    • The dev lane had no wiring document. It now renders from the fixture (--fixture … --fixture-envs dev).
    • packages/.gitkeep was missing, which made orun plan fail.
  • Other changes:

    • Identity seam apps/web/lib/site.ts.
    • The Open Graph image is absolute, built from the request's origin (getServerSideProps), so no SITE_URL is needed.
    • <title> and the description are rendered by _app's own <Head>. The @vercel/examples-ui layout's <Head> never reaches the server render.
    • .wrangler/ is excluded from lint.
    • stack-tectonic is pinned at 0.19.0 and the lanes run orun v2.78.4.
    • checks.yml runs on PRs only.
    • The ci.yml gate is now ws_CHANGE_ME.
    • Task contracts are keyed.
    • The KV root's leftover Cirrus prose is replaced.
  • Factory pieces copied from KR: .baseline/, tooling/{rebrand,bootstrap}, hooks/render-deployment-docs.sh, ai/context/, docs/phases/, BOOTSTRAP.md, testing/, baseline.yml and tag.yml.

How it was verified (at head f5cbe21)

Check Result
orun new --status at v2.58.11, v2.78.4 and 2.79.0 01-product places 72 files; 02-docs is hook-only
orun validate, orun work check clean
manifest, phases, coverage, rebrand, retouch, bootstrap-defer, wire green
leak (v2.58.11, v2.79.0) green
placement (v2.78.4, v2.79.0) green: both phases offline. The product's own push-to-main plan has KV at level 0 and web at level 1. Nothing waits on a PR, and the 02-docs merge plans 0 jobs. The product keeps exactly one * * * * * trigger. --resume is a no-op
e2e (v2.79.0, v2.78.4) green (details below)
repo checks: install, wire:fixture (no diff), typecheck, lint (0 warnings), test (34), build green
terraform validate on infra/terraform/cloudflare-kv green

What the e2e does:

  1. Runs the Checks sequence on the landed product.
  2. Runs the stage lane's verify-app-structure, build-app, verify-build-output and deploy-dry-run in the staged job tree, with a stage wiring document.
  3. Starts wrangler dev --test-scheduled. Before any trigger fires, the component's own smoke fails.
  4. Fires /__scheduled?cron=*+*+*+*+*, which runs 1m.
  5. Fires the trigger at 8 crafted scheduled times through wrangler's local trigger route (/cdn-cgi/local/scheduled?cron=…&time=…), because /__scheduled always uses the current time. At each time, exactly the due schedules run and every other record stays unchanged. This includes 1w on a Sunday but not a Monday, and 1mo on the 1st.
  6. Reads every record back. The smoke then passes.
  7. Checks every route.

Not verified here:

  • A live bootstrap: repo creation, link, minted token, a real terraform apply, a real deploy that registers the trigger, the trigger firing on Cloudflare's clock, and the probes.
  • The first deploy's smoke depends on the new trigger firing within the ~4.5 min retry budget. Cloudflare allows up to 15 min for a trigger to propagate; the watch's lane resumes cover the gap (risk CR-J).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk

The repository is now a baseline: blueprint.yaml (the console card) and
repo-blueprint.yaml (the build) take a new product from nothing to live on
stage and prod in TWO phases, cirrus-baseline v22's one-landing shape:

- 01-product places every module (root files, CI, tooling, the KV root,
  the Worker with its page, API routes and Cron Triggers, its tests),
  retouches, brands, re-tenants, strips the work tree, defers prod's
  promotion gate and dev's push lanes, lands it as one pull request after
  reconciling CLOUDFLARE_API_TOKEN (workers-deploy: Workers Scripts and KV
  Storage) and CLOUDFLARE_ACCOUNT_ID, then watches the convergence, checks
  WIRING_CLOUDFLARE_KV exists on stage and prod, and probes both URLs.
- 02-docs is hook-only: restores the two deferrals, renders the
  deployment record (with each environment's last recorded cron run),
  lands it.

Infra before app: apps/web depends on cloudflare-kv with mode: enforced
on github-push-main and advisory on pull requests. The product's own
push-to-main plan puts the KV applies at lane level 0 and each web deploy
at level 1, waiting on its own environment's apply alone.

The cron path: the scheduled handler lives in the committed custom entry
worker.ts (OpenNext's fetch + scheduled) and the seven triggers in the
template the build re-renders, so both survive a lane's build in the
staged job tree. The deploy's smoke now proves the cron's effect: it
reads /api/data/1m and requires a fetchedAt from the last ten minutes, a
run the every-minute trigger recorded through the scheduled handler (the
composition retries it ~4.5 min; the watch resumes failed lanes; risk
CR-J). The card, BOOTSTRAP and the product's docs say the account needs
Workers Paid (14 triggers; Free allows 5 per account).

Fixed on the way, latent since CR1 because no Orun lane had run:
- wrangler.jsonc is committed as the fixture render; the composition's
  verify-app-structure checks it exists BEFORE the build.
- dev, which no root applies to, renders the fixture
  (live.mjs --fixture --fixture-envs dev).
- the page's <title> and description go through _app's own <Head>:
  @vercel/examples-ui's layout <Head> does not reach the server render.
Also: packages/ (a required discovery root), stack-tectonic 0.19.0, the
orun lane pin v2.78.4, checks.yml on pull requests only, the ci.yml
ws_CHANGE_ME gate, the lib/site.ts identity seam, the Open Graph image
absolute on the request's origin (getServerSideProps; no SITE_URL),
.wrangler/ out of lint, keyed task contracts, the KV root's Cirrus prose.

Tests (testing/, baseline.yml): manifest, phases, coverage, rebrand,
retouch, bootstrap-defer, wire, leak, placement (both phases offline, the
product's own plans, the cron entry and triggers kept) and e2e (the stage
lane's steps incl. verify-app-structure in the staged job tree with a
stage wiring document; wrangler dev --test-scheduled; the component's own
smoke refused before any trigger fired; all seven expressions fired
through /__scheduled and each record read back; the smoke then passes;
every route).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk
Cloudflare counts Cron Triggers per ACCOUNT, five on Workers Free, and the
platform cannot check a plan before it deploys: seven triggers per Worker,
fourteen per product, made a Free account refuse the first deploy. The
Worker now registers ONE trigger, `* * * * *` (TRIGGER in lib/crons.ts, the
only entry in triggers.crons), two per product, inside Free's five.

The scheduled handler evaluates the seven schedules in lib/crons.ts (the
template's vercel.json expressions, verbatim, and still the ones the page
shows) against the trigger's scheduledTime in UTC, with a small five-field
matcher: 1m every minute, 10m when minute % 10 == 0, 1h at minute 0, 12h at
00:00 and 12:00, 1d at 00:00, 1w at 00:00 on Sunday (`0 0 * * 0`), 1mo at
00:00 on the 1st. Each due schedule runs /api/cron/<interval> through the
OpenNext fetch handler, as before, one after another; a failing route does
not stop the rest, and the invocation then fails naming each. The page and
/api/data/<interval> are unchanged; the smoke still reads /api/data/1m.

Tests: the matcher and the dispatcher at crafted times (34 unit tests); the
placement tier asserts the one trigger in the product's template and
committed render; the e2e fires /__scheduled?cron=*+*+*+*+* on the clock
and the trigger at eight crafted scheduled times through wrangler's local
trigger route (/cdn-cgi/local/scheduled?cron=…&time=…; /__scheduled always
stamps the present), asserting exactly the due schedules ran and the rest
stayed, then reads every record back. "Workers Paid" is gone from the card,
BOOTSTRAP and the product's docs; risk CR-B resolved, CR-N added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk
@ruehowl
ruehowl marked this pull request as ready for review October 15, 2026 20:12
@ruehowl
ruehowl merged commit 2281bab into main Oct 15, 2026
6 checks passed
ruehowl added a commit that referenced this pull request Oct 21, 2026
…text pack (#6)

* CR5: the cirrus standard — no kiox, generated component docs, the context pack

- Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran
  the kiox pin (v2.15.0); every workflow pins orun through orun-action.
- Generate docs/{overview,architecture,runbook}.md for every component
  from what it declares (tooling/catalog/gen-component-docs.py), and fail
  Baseline CI when they drift (--check).
- Add ai/context/{current,decisions,open-risks}.md (this repository's own;
  nothing places them).
- Close out CR4 (shipped in #5, tagged baseline-v1) and record CR5 (CR-6).
- Make the docs say what CR4 built: the epic README's summary and the
  status file's "Vercel Cron → Cron Triggers" describe one every-minute
  trigger dispatching the seven schedules (no seven triggers, no
  intervalFor); "Versions" no longer calls apps/web/README.md upstream's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Regenerate component docs: prettier-padded tables, accurate wording

The generator now lays tables out the way prettier does (an app whose lint
is `prettier --check` accepts the pages as written), lists the WIRING_*
failure only for Workers that take wiring, and no longer claims a package
holds no credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Component docs: list optional and per-environment secrets

The generator now reads `optionalSecretEnv` (listed as "(optional)") and
secrets declared per environment under `subscribe.environments[]`, so a
page no longer leaves out a secret its component declares. Its tables are
laid out as prettier lays them out, the WIRING_* failure is listed only
for Workers that take wiring, and a package is no longer said to hold no
credentials. Every starter now carries the identical generator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

---------

Co-authored-by: Claude <noreply@anthropic.com>
ruehowl added a commit that referenced this pull request Oct 21, 2026
* CR5: the cirrus standard — no kiox, generated component docs, the context pack

- Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran
  the kiox pin (v2.15.0); every workflow pins orun through orun-action.
- Generate docs/{overview,architecture,runbook}.md for every component
  from what it declares (tooling/catalog/gen-component-docs.py), and fail
  Baseline CI when they drift (--check).
- Add ai/context/{current,decisions,open-risks}.md (this repository's own;
  nothing places them).
- Close out CR4 (shipped in #5, tagged baseline-v1) and record CR5 (CR-6).
- Make the docs say what CR4 built: the epic README's summary and the
  status file's "Vercel Cron → Cron Triggers" describe one every-minute
  trigger dispatching the seven schedules (no seven triggers, no
  intervalFor); "Versions" no longer calls apps/web/README.md upstream's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Regenerate component docs: prettier-padded tables, accurate wording

The generator now lays tables out the way prettier does (an app whose lint
is `prettier --check` accepts the pages as written), lists the WIRING_*
failure only for Workers that take wiring, and no longer claims a package
holds no credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Component docs: list optional and per-environment secrets

The generator now reads `optionalSecretEnv` (listed as "(optional)") and
secrets declared per environment under `subscribe.environments[]`, so a
page no longer leaves out a secret its component declares. Its tables are
laid out as prettier lays them out, the WIRING_* failure is listed only
for Workers that take wiring, and a package is no longer said to hold no
credentials. Every starter now carries the identical generator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* CR5: read the workers.dev subdomain from the Cloudflare connection

- blueprint.yaml: the subdomain input declares
  `from: connection.cloudflare.workersSubdomain`; the console fills it from
  the connection the build is bound to (the one CLOUDFLARE_ACCOUNT_ID and
  the deploy tokens mint from) and renders no field for it
- testing/manifest.test.sh: cirrus-baseline's check, byte for byte — a
  `connection.<provider>.<fact>` source is accepted only when
  spec.requires.integrations lists the provider (mutation-checked)
- repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: a hand-run
  build still passes --set subdomain
- records: CR-7 joins CR5; status, plan, epic index, current.md and
  decisions.md say CR5 ships as baseline-v2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

---------

Co-authored-by: Claude <noreply@anthropic.com>
ruehowl added a commit that referenced this pull request Oct 22, 2026
* CR5: the cirrus standard — no kiox, generated component docs, the context pack

- Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran
  the kiox pin (v2.15.0); every workflow pins orun through orun-action.
- Generate docs/{overview,architecture,runbook}.md for every component
  from what it declares (tooling/catalog/gen-component-docs.py), and fail
  Baseline CI when they drift (--check).
- Add ai/context/{current,decisions,open-risks}.md (this repository's own;
  nothing places them).
- Close out CR4 (shipped in #5, tagged baseline-v1) and record CR5 (CR-6).
- Make the docs say what CR4 built: the epic README's summary and the
  status file's "Vercel Cron → Cron Triggers" describe one every-minute
  trigger dispatching the seven schedules (no seven triggers, no
  intervalFor); "Versions" no longer calls apps/web/README.md upstream's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Regenerate component docs: prettier-padded tables, accurate wording

The generator now lays tables out the way prettier does (an app whose lint
is `prettier --check` accepts the pages as written), lists the WIRING_*
failure only for Workers that take wiring, and no longer claims a package
holds no credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* Component docs: list optional and per-environment secrets

The generator now reads `optionalSecretEnv` (listed as "(optional)") and
secrets declared per environment under `subscribe.environments[]`, so a
page no longer leaves out a secret its component declares. Its tables are
laid out as prettier lays them out, the WIRING_* failure is listed only
for Workers that take wiring, and a package is no longer said to hold no
credentials. Every starter now carries the identical generator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* CR5: read the workers.dev subdomain from the Cloudflare connection

- blueprint.yaml: the subdomain input declares
  `from: connection.cloudflare.workersSubdomain`; the console fills it from
  the connection the build is bound to (the one CLOUDFLARE_ACCOUNT_ID and
  the deploy tokens mint from) and renders no field for it
- testing/manifest.test.sh: cirrus-baseline's check, byte for byte — a
  `connection.<provider>.<fact>` source is accepted only when
  spec.requires.integrations lists the provider (mutation-checked)
- repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: a hand-run
  build still passes --set subdomain
- records: CR-7 joins CR5; status, plan, epic index, current.md and
  decisions.md say CR5 ships as baseline-v2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

* CR6: the console asks for no domain — the domain is set later

The site goes live on workers.dev from its first deploy and nothing in the
build needs a domain — the page builds its absolute links from the request
it answers, and the Cron Triggers need no hostname — so the console's
Product step no longer asks for one. The logic that uses a domain stays
where it is, waiting for one.

- blueprint.yaml: no productdomain input
- repo-blueprint.yaml: productdomain is optional, default empty
- rebrand.mjs: productdomain no longer required; empty brands the reserved
  placeholder <reponame>.example.com (RFC 2606) where the domain goes
  (BASE_DOMAIN), so setting it later is replacing one string
- the product README and ai/context/operations.md say how to set it
- testing/fixtures/acme.json carries no domain; rebrand.test.sh pins the
  placeholder; baseline.yml's blueprint read sets no domain
- records: CR6 / CR-8, tagged baseline-v3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants