The sample app: a workshop progress tracker
This page explains the app the agent will help operate: what it is for, how its pieces work together, where it keeps names and email addresses, and which Cloudflare operations someone running it uses. It ends with the security engineer’s constraints in plain words. Every policy rule you write later is one of those constraints, so the story needs them now.
It is a teaching story around a real, small app. The app runs on a real Cloudflare account (this site shows the stand-in id 0123456789abcdef0123456789abcdef); the team, the developer and the security engineer are made up. You do not need this app, or any Cloudflare set-up like it, to follow the explanations: every sample and every rule on this site is written for it, and each one says what it would mean for your own app.
Where the app sits in the picture
Section titled “Where the app sits in the picture”The sample app is the piece at the bottom right: the Cloudflare API is the only way in for the agent.
Text description of the diagram
Stage 1 of 5. No sandbox yet.
Pieces in the picture:
- the macOS keychain, which holds the three secrets; the developer reads them into shell variables
- the developer's terminal
- Claude Code, the agent
- the Anthropic API
- Cloudflare's MCP server
- the Cloudflare API
- the sample app: the Worker box-poc-workshop with its D1 database, KV namespace and Workers Logs; the logs and the database hold attendee names and email addresses
In the architecture diagram the whole app is one piece, behind the Cloudflare API. The agent never talks to the app’s own web routes. It reads and changes the app only through the Cloudflare API, the same API the Cloudflare dashboard and the wrangler command use. That is why every constraint below is written as “which Cloudflare API operations may the agent use”.
What the app is for
Section titled “What the app is for”- It tracks how far each attendee of a hands-on workshop has got, and shows everyone’s progress on a board for the facilitator, the person running the workshop.
- Attendees read the workshop on a website. Small components on those pages call the Worker’s JSON API.
- An attendee gets an anonymous session the first time they record progress. They may add a name and an email address to appear on the board.
- When an attendee presses “Next”, the Worker checks the attendee’s own deployed endpoint and marks the page green, yellow or blue.
- The Worker writes structured logs that include names, emails and endpoints, on purpose, so the logs are sensitive.
It is the progress tracker of a real workshop (the TerraConstructs AWS workshop). The data seeded for the workshop’s tests is synthetic: invented names and @example.com addresses. Source for this page: the “The sample app” section of the box-exec-proxy README, and the app’s code in sample-app/.
The story calls it a “leaderboard” because the board shows everyone’s progress side by side. The board is not ranked by a score: it lists the attendees who opted in, in the order they joined.
The architecture
Section titled “The architecture”The workshop progress tracker and leaderboard on Cloudflare. A ring marks a place that holds names and email addresses.
Text description of the diagram
- the attendee's browser: components on the workshop website call the Worker's JSON API with a bearer token
- the facilitator's browser: the dashboard, live over a WebSocket, behind a secret
- the Worker box-poc-workshop: routes the API, reads each page's check from KV, and writes one log object per event
- AttendeeSession, a Durable Object, one per attendee session: the attendee's endpoints, a verdict per page, rate-limit buckets and the optional name and email (holds names and email addresses)
- WorkshopBoard, a Durable Object, one per workshop: hands out session seats one at a time, keeps each session's progress and pushes snapshots to the dashboard (holds names and email addresses)
- the D1 database box-poc-workshop: the session registry, with the optional display name and email (holds names and email addresses)
- the KV namespace box-poc-workshop-content: the 40 workshop pages and their checks; public content
- Workers Logs: one log object per event; events for a session on the board include its email, and some include names (holds names and email addresses)
- the attendee's own endpoint, outside Cloudflare, which the session object checks with one GET per check
The Worker
Section titled “The Worker”A Worker is a program that Cloudflare runs on its own servers when a request arrives. The Worker box-poc-workshop routes the JSON API, applies the rate limits, reads each page’s check from KV, and writes one log object for each event. It serves one page of its own: the facilitator’s dashboard, behind a secret.
One Durable Object per attendee session
Section titled “One Durable Object per attendee session”A Durable Object is a small stateful object with a name. Every request for that name reaches the same single instance, one request at a time, and the object has its own private storage. (That definition is general Cloudflare knowledge, not from the app’s source; see the Durable Objects docs linked below.)
AttendeeSession is a Durable Object, and there is one per attendee session, named by the session id. It holds a hash of the session token, the attendee’s endpoints, one verdict per page, rate-limit counters, and the optional name and email. One object per session fits because each attendee’s state is private to them and must be written one request at a time. The object also fetches the attendee’s endpoint itself when it checks a page, so the response body never leaves it.
One board per workshop
Section titled “One board per workshop”WorkshopBoard is a Durable Object too, but there is one per workshop. It hands out session seats, keeps each session’s progress, and pushes a fresh snapshot to every open dashboard over a WebSocket. One object per workshop fits because the cap on sessions (200) must hold when many people start at once: a single object handles one request at a time, so two attendees can never take the last seat together.
D1: the session registry
Section titled “D1: the session registry”D1 is Cloudflare’s SQL database. The D1 database box-poc-workshop is the session registry: for each session its id, the workshop, a SHA-256 hash of the token, timestamps, and the display name and email of those who opted in to the board.
KV: the workshop content
Section titled “KV: the workshop content”KV is Cloudflare’s key-value store. The namespace box-poc-workshop-content holds one key, workshop: the 40 workshop pages and the checks on them (5 of the 40 pages have a check). This is public content, generated from the workshop website.
Workers Logs
Section titled “Workers Logs”Workers Logs is Cloudflare’s log store for a Worker. Every object the Worker logs with console.log lands there, together with Cloudflare’s own request entries. Nothing in the app deletes log events; Cloudflare’s retention decides how long they stay.
How it works, step by step
Section titled “How it works, step by step”- A session starts. The first time an attendee records progress, the website sends
POST /api/sessions. Merely reading pages creates nothing. The Worker checks the rate limit, counts the sessions in D1 against the cap, and asks the board for a seat. It returns a random token once and stores only the token’s hash. The log gets asession.createdevent, with no email: the session is anonymous so far. - The attendee presses “Next”. The website sends
POST /api/session/advancewith the page name and nothing else. The Worker looks up that page’s check in KV, and the attendee’s session object fetches the attendee’s endpoint and compares the answer. The page turns green (verified), yellow (moved on without passing) or blue (no check on this page). - The attendee joins the board.
PUT /api/session/boardwith a display name and an optional email puts the session on the board. The board pushes a new snapshot to the dashboard. From now on the session’s log events carry its email.
What data it holds, and where
Section titled “What data it holds, and where”| Where | What it holds | Personal data? |
|---|---|---|
| Workers Logs | Events with names and emails (for sessions on the board), endpoint URLs, session ids | Yes, on purpose |
D1 box-poc-workshop |
Display name and email (opt-in), the token hash, timestamps | Yes |
| Durable Object storage | The same name and email, endpoints, verdicts | Yes |
| The dashboard | Names, emails, endpoints | Yes, behind a secret |
KV box-poc-workshop-content |
The 40 workshop pages and their checks | No: public content |
| The Worker’s script, settings, deployments, versions | Code, bindings, deployment history | Not attendee data. The deployment history does name the person who deployed: in act c an allowed read returned the deployer’s email address (measured). |
The logs events that carry a name or an email are session.board_joined, session.board_left, session.endpoint_saved, session.endpoint_refused, session.step_advanced and session.seeded (from the logEvent calls in demo/app/src/index.ts). Tokens are never logged. Whether Cloudflare’s own request entries in the logs carry client IP addresses was not checked.
What operating it means
Section titled “What operating it means”Someone running this app uses a small set of Cloudflare API operations. The API’s base address is https://api.cloudflare.com/client/v4, and every path below starts with /accounts/{account_id}.
| What the operator does | Method and path | Does it read personal data? |
|---|---|---|
| List the Workers | GET .../workers/scripts |
No |
| Read the Worker, its settings, its versions | GET .../workers/scripts/{script_name}, .../settings, .../versions |
No |
| Read the current deployment | GET .../workers/scripts/{script_name}/deployments |
The deployer’s email |
| Read D1 metadata, list KV namespaces and keys | GET .../d1/database, GET .../storage/kv/namespaces, .../keys |
No |
| Search the logs | POST .../workers/observability/telemetry/query |
Yes |
| Live-tail the logs | POST .../workers/observability/telemetry/live-tail |
Yes |
| Run SQL on D1 | POST .../d1/database/{database_id}/query |
Yes |
| Deploy a Worker | PUT .../workers/scripts/{script_name}, POST .../deployments |
No, but it changes the app |
| Delete a Worker, a database or KV data | DELETE on the matching path |
No, but it destroys the app or its data |
In Part 4 each of these operations becomes its own tool with a name, for example workers_deployments_list for reading the deployments and o11y_telemetry_query for searching the logs.
The developer’s wish
Section titled “The developer’s wish”The developer wants the agent to help operate the app: list the Workers, check the current deployment, look into a problem. The task the team wants done:
List the Workers on Cloudflare account 0123456789abcdef0123456789abcdef and summarise the current deployment of the Worker box-poc-workshop.
The task that must be refused, because it reads the logs:
Show me the last hour of logs for the Cloudflare Worker box-poc-workshop on account 0123456789abcdef0123456789abcdef.
The Cloudflare token the agent uses is broad on purpose. It may read the logs, run SQL, deploy and delete. So when an operation is refused later, the refusal comes from Box’s policy, not from Cloudflare.
The security engineer’s constraints
Section titled “The security engineer’s constraints”These are the constraints in plain words, each with its reason. The later pages turn them into rules.
- Operate: yes. The agent may list the Workers, read a Worker and its settings, and read its deployments and versions. Reason: this is the work the developer needs.
- Logs: no. The agent may not search the logs, live-tail them, or use any other operation that reads log content. Reason: the logs hold attendees’ names and email addresses.
- Attendee data: no. The agent may not run SQL on D1 or read anything that returns the registry’s rows or the Durable Objects’ contents. Reason: the registry and the objects hold names and emails, and a policy cannot tell a SQL read from a SQL write.
- Deploy and delete: no. The agent may not upload or deploy a Worker, and may not delete a Worker, a database, a namespace or its data. Reason: the Worker serves a live workshop; the agent’s work here is to read.
- This account only. The agent works on the workshop’s account and nowhere else. Reason: Cloudflare already restricts the token to this account, but in the story the security engineer wants the policy to say so too, so the rule still holds if someone hands the agent a different token.
Where each constraint becomes a rule:
| Constraint | Act | The rule you write |
|---|---|---|
| 2, 3, 4 (blunt: everything at once) | b2 | no_hidden_api_calls: refuse the vendor’s execute tool, because Box cannot see what its script does |
| 1 to 4 | b3 | operate_tools_only: of the 3,053 tools, only six read tools may run |
| 5 | b3-args | this_account_only: workers_deployments_list runs only on the workshop’s account |
| 1 to 5 | c | operate_requests_only and no_worker_logs: two read requests are allowed; every other Cloudflare API request is refused, and the logs path has a rule of its own |
The rules in this workshop are deliberately narrower than the full list: in act c only two reads are allowed, the Worker list and the deployments of box-poc-workshop, because those are what the allowed task needs.
The personal data sits in three places the agent could reach through the API: the logs, the D1 registry and, less directly, the deployment history. Your constraints must hold even though the token can do all of it. Watch, in each act, whether the policy can name the operation it refuses, or only the tool that carried it.
Your day-to-day needs are small: a handful of reads. Watch, in each act, whether those reads still work, how many tokens they cost, and whether a refusal arrives with a reason you can act on.
Without this set-up
Section titled “Without this set-up”If you do not have this app, you can still follow every page: each sample shows its real output from the runs made for this workshop. If you want to run the acts on your own Cloudflare account, use a Worker of your own in place of box-poc-workshop. Requirements lists every place where the account id and the Worker name appear. This site does not teach how to deploy the app.
What to remember
Section titled “What to remember”- One Worker, two Durable Objects (one per session, one per workshop), a D1 registry, a KV namespace of public content, and Workers Logs.
- Names and emails live in the logs, the D1 registry and the Durable Objects; the deployment history names the deployer.
- The agent reaches the app only through the Cloudflare API, so every constraint is about API operations.
- Five constraints: operate yes; logs, attendee data, deploy and delete no; this account only.
Read more
Section titled “Read more”Read moreCloudflare WorkersCloudflare docs
Read moreDurable ObjectsCloudflare docs
Read moreD1, Cloudflare’s SQL databaseCloudflare docs
Read moreWorkers KVCloudflare docs
Read moreWorkers LogsCloudflare docs