Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
echo "── $t"
bash "testing/$t.test.sh"
done
# Every component's docs/{overview,architecture,runbook}.md is generated
# from what the component declares (its manifest, Worker config,
# Terraform, migrations, package scripts). A pull request that changes
# one of those facts without regenerating the pages fails here.
- name: Component docs match their manifests
run: python3 tooling/catalog/gen-component-docs.py --check

# Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS.
#
Expand Down
43 changes: 43 additions & 0 deletions ai/context/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# cron-starter — where this repository stands

The entry page for anyone (or any agent) picking this repository up. It is
this repository's own state and does not ship to a product built from it; the
two pages that do are [operations.md](operations.md) and
[deployment.md](deployment.md).

## What it is

Vercel's Cron Jobs example on Cloudflare Workers + Static Assets through
`@opennextjs/cloudflare`: one every-minute Cron Trigger per Worker whose
`scheduled` handler runs the template's seven schedules as the requests Vercel
used to make, the records in a Workers KV namespace. Packaged as an Orun
baseline: `orun new --blueprint repo-blueprint.yaml` builds a new product in
its own repository and takes it to live on stage and prod in one landing
(`01-product`) — the KV namespace applied before the Worker that binds it,
the deploy's smoke reading a run the trigger recorded — then records what
went live (`02-docs`).

## Release

| | |
|---|---|
| Latest tag | `baseline-v1` (CR4, [#5](https://github.com/sourceplane/cron-starter/pull/5)) |
| On `main` since | CR5 — the cirrus standard (no kiox, generated component docs, this context pack) |
| Proven live | No. Everything short of the platform is proven offline in Baseline CI, the trigger fired by hand at crafted times; the token minted, a real KV apply, a real deploy registering its trigger and the trigger firing on Cloudflare's clock are still to come (risk CR-K) |

## Where to read

| Question | Page |
|---|---|
| What shipped, and every departure from upstream | `specs/epics/cron-starter/IMPLEMENTATION-STATUS.md` |
| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/cron-starter/design.md` |
| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/cron-starter/risks-and-open-questions.md` |
| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` |
| What each component is | `apps/web/docs/`, `infra/terraform/cloudflare-kv/docs/`, `tests/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) |

## Next

1. Bootstrap one product from the next tag against a workspace and record
its timings, including how long the first trigger took to fire (closes
CR-K).
2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin CR5.
20 changes: 20 additions & 0 deletions ai/context/decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# cron-starter — decisions

The choices that shape this repository, one line each, with where the full
reasoning lives. Superseded decisions stay listed, marked, so the history
reads in order.

| # | Decision | Why | Source |
|---|---|---|---|
| 1 | OpenNext on Workers + Static Assets, the static-assets incremental cache | The template is a Next.js pages-router app; its API routes run inside the Worker unchanged | `specs/epics/cron-starter/design.md` §2 |
| 2 | One Worker: a custom entry (`worker.ts`) re-exports the generated fetch handler and adds `scheduled`, which calls the route in-process with a synthetic request | A second cron Worker would be another deployable and another render for a dozen-line handler | design.md §7 |
| 3 | `lib/kv.ts` mirrors `@vercel/kv`'s `set`/`get` over the `KV` binding | The routes change only their import | design.md §2 |
| 4 | ONE Cron Trigger per Worker (`* * * * *`); the handler runs every schedule in `lib/crons.ts` due at the trigger's `scheduledTime`. Supersedes CR1–CR3's seven triggers per Worker | Cloudflare caps Cron Triggers per account (five on Workers Free), and the platform cannot check a plan before a deploy | risks CR-B, CR-N |
| 5 | `wrangler.jsonc` is rendered per environment from the KV root's wiring document, and committed as the fixture render; `dev` renders the fixture | The deploy lane checks the file exists before it builds; no root applies to `dev` | risks CR-H, CR-I, design.md §4 |
| 6 | The deploy's smoke reads `/api/data/1m` for a run from the last ten minutes | It proves the trigger and the binding; a first deploy is covered by the landing's resumes | risk CR-J |
| 7 | One landing (`01-product`) then the record (`02-docs`); the plan applies the namespace before the Worker (`dependsOn: cloudflare-kv`, enforced on `main`, advisory on a pull request) | A landing has a fixed cost; the plan, not the phases, carries deploy order (cirrus-baseline since `baseline-v22`) | design.md §8 |
| 8 | The page's name and source link are one seam (`lib/site.ts`); the Open Graph image is absolute on the request's own origin | The rename rewrites one file; no configured site URL | IMPLEMENTATION-STATUS (CR4) |
| 9 | The cron route stays public, as upstream | Upstream sets no `CRON_SECRET`; the guard's shape is documented | risk CR-A |
| 10 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME`; `checks.yml` runs on pull requests only | A bootstrap cannot set a repository variable (replaced the `ORUN_CI` gate); the convergence watch takes the newest run on the merge sha from any workflow | IMPLEMENTATION-STATUS (CR4) |
| 11 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install is refused by Next 16's Turbopack | IMPLEMENTATION-STATUS (CR4), `intent.yaml` |
| 12 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox. Component docs are generated from the manifests and checked in CI | `kiox.yaml` pinned a version nothing ran; a hand-written copy of the dependency graph and bindings drifts silently | IMPLEMENTATION-STATUS (CR5), `tooling/catalog/gen-component-docs.py` |
16 changes: 16 additions & 0 deletions ai/context/open-risks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# cron-starter — open risks

What is not yet proven or not yet decided. The full write-up of every risk,
including the accepted and resolved ones, is
`specs/epics/cron-starter/risks-and-open-questions.md`; this page lists only
what is still live, so it should be short.

| ID | Risk | State | What closes it |
|---|---|---|---|
| CR-K | No live bootstrap yet: the repository created and linked, the token minted, a real `terraform apply`, a real `wrangler deploy` registering its trigger, the trigger firing on Cloudflare's clock and the probes are all unproven | OPEN | One bootstrap from a tag against a workspace |

Accepted, and worth knowing before you change them: CR-A (the cron route is
public, as upstream), CR-C (KV is eventually consistent), CR-D (Hacker News
at request time), CR-J (the first deploy's smoke waits on the trigger), CR-L
(the bootstrap floor plans every edge enforced), CR-M (a custom domain is the
owner's step), CR-N (seven schedules on one trigger).
31 changes: 31 additions & 0 deletions apps/web/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# web — architecture

Built by the turbo pipeline from `apps/web` and deployed with wrangler.

| | |
| ------------------- | ----------------------------------------------- |
| Worker config | `apps/web/wrangler.template.jsonc` |
| Entry | `worker.ts` |
| Compatibility date | `2026-10-01` |
| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` |

## Bindings

| Binding | Kind | Source |
| -------- | -------------------- | -------------------------------- |
| `KV` | Workers KV namespace | `app_kv_id` from `cloudflare-kv` |
| `ASSETS` | Static assets | `.open-next/assets` |

Identifiers marked _from_ a component are filled in at deploy time from
that component's published outputs for the environment being deployed.

## Scheduled triggers

- `* * * * *`

## Wiring

Resolved at deploy time from secrets the infrastructure lanes publish (names only):

- `WIRING_CLOUDFLARE_KV_PROD`
- `WIRING_CLOUDFLARE_KV_STAGE`
20 changes: 20 additions & 0 deletions apps/web/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# web

The cron example (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, with Cron Triggers driving its API routes, per environment)

A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane.

| | |
| ------------ | ------------------------------------------------------------------------------------------------------------------ |
| Type | `cloudflare-workers-assets-turbo` |
| Source | `apps/web` |
| Package | `@app/web` |
| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` |

## Depends on

- **cloudflare-kv** — Provisions the Cloudflare KV namespace the app binds (stage and prod)

## Depended on by

- (none)
40 changes: 40 additions & 0 deletions apps/web/docs/runbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# web — runbook

## How it runs

Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`.
CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;
the plan orders a component after everything it depends on.

## Local commands

```bash
pnpm --filter @app/web dev
pnpm --filter @app/web build
pnpm --filter @app/web typecheck
pnpm --filter @app/web lint
pnpm --filter @app/web preview
```

## Verify

After a deploy the lane runs this smoke against the environment it
deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:

```bash
body=$(curl -sf "${DEPLOYED_URL}/api/data/1m") && at=$(printf '%s' "${body}" | grep -Eo '"fetchedAt":[0-9]{13}' | grep -Eo '[0-9]{13}') && [ $(( $(date +%s) - at / 1000 )) -lt 600 ]
```

## Rollback

Revert the commit on `main`. The next convergence applies the previous desired
state; nothing was changed out of band, so there is nothing else to undo.

## Common failures

- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream
has not applied for this environment yet. Within one convergence the plan
runs it first; on its own, re-run that lane.
- **The smoke fails right after a first deploy**: a new workers.dev route can
answer 4xx for a few seconds and the lane retries. A failure that persists
is a regression in the deployed code.
29 changes: 29 additions & 0 deletions infra/terraform/cloudflare-kv/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# cloudflare-kv — architecture

A `terraform` root at `infra/terraform/cloudflare-kv/terraform`.

- **State** lives in the Orun Cloud HTTP state backend — no local state and
no state bucket to manage.
- **Credentials are brokered per run** from the workspace's provider
connections and resolved by name; none is stored in this repository.
- **Adoption** (`adopt.tf`): when state is empty but the resource already
exists, plan-time import adopts it instead of failing.

## Resources

- `cloudflare_workers_kv_namespace.app_kv`

## Published outputs

Written as job-output secrets on each environment after an apply; deploy
lanes downstream resolve them by name.

| Secret | Terraform output |
| ---------------------- | ---------------- |
| `WIRING_CLOUDFLARE_KV` | `wiring` |

## Resolved at run time (names only)

- `CLOUDFLARE_ACCOUNT_ID`
- `CLOUDFLARE_API_TOKEN`
- `TF_VAR_cloudflare_account_id`
19 changes: 19 additions & 0 deletions infra/terraform/cloudflare-kv/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# cloudflare-kv

Provisions the Cloudflare KV namespace the app binds (stage and prod)

Terraform-managed infrastructure, planned and applied per environment by its CI lane.

| | |
| ------------ | ---------------------------------------------------------------------------------------------------- |
| Type | `terraform` |
| Source | `infra/terraform/cloudflare-kv` |
| Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` |

## Depends on

- (none)

## Depended on by

- **web** — The cron example (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, with Cron Triggers driving its API routes, per environment)
20 changes: 20 additions & 0 deletions infra/terraform/cloudflare-kv/docs/runbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# cloudflare-kv — runbook

## How it runs

Pull requests plan it; a merge to `main` applies it to `stage`, `prod`.
CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;
the plan orders a component after everything it depends on.

## Rollback

Revert the commit on `main`. The next convergence applies the previous desired
state; nothing was changed out of band, so there is nothing else to undo.

## Common failures

- **Provider authentication fails**: the workspace's provider connection is
missing or revoked. Reconnect it in the console; credentials are brokered
from it per run.
- **"Already exists" on a first apply**: state is empty but the resource is
not. `adopt.tf` imports it at plan time; if it still fails, the resource was renamed outside Terraform.
11 changes: 0 additions & 11 deletions kiox.lock

This file was deleted.

6 changes: 0 additions & 6 deletions kiox.yaml

This file was deleted.

12 changes: 1 addition & 11 deletions repo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,6 @@ modules:
source: baseline
from: turbo.json
to: turbo.json
- name: root-kiox
mode: copy
source: baseline
from: kiox.yaml
to: kiox.yaml
- name: root-kiox-lock
mode: copy
source: baseline
from: kiox.lock
to: kiox.lock
- name: root-gitignore
mode: copy
source: baseline
Expand Down Expand Up @@ -409,7 +399,7 @@ phases:
await: "One convergence is deploying the product: the KV namespace first, then the Worker built with its id, on stage and prod side by side, each smoke waiting for the every-minute trigger to record a run. The Next.js build is the long pole; nothing is stuck."
done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, its Cron Trigger recording runs. That took {{ .meta.elapsed }}."
failed: "The product did not come up. The failing lane above names the component — the KV apply, or the Worker's build, deploy or smoke — and a provider error is in its log; whatever deployed is still there."
modules: [ai-deployment, ai-operations, cloudflare-kv, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-kiox, root-kiox-lock, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
modules: [ai-deployment, ai-operations, cloudflare-kv, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
# THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every
# phase lands a pull request that files under its task, and the platform
# learns of a PR only through the GitHub App installation on the account
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`cron-starter/`](./cron-starter/) | **CR** | ✅ Shipped | Vercel's Cron Jobs example, equivalent in code and function, on Cloudflare Workers with Cron Triggers driving the same API routes and Workers KV holding the timestamps — and an Orun baseline that instantiates it in one landing (CR4) |
| [`cron-starter/`](./cron-starter/) | **CR** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Cron Jobs example, equivalent in code and function, on Cloudflare Workers with Cron Triggers driving the same API routes and Workers KV holding the timestamps — and an Orun baseline that instantiates it in one landing (CR4) |

As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
Loading
Loading