Sky Yoo

Agent infrastructure · 2026 · completed

Escapement

A cloud-resident agent that keeps a Zettelkasten on schedule — and never writes in it.

Escapement — main view
ESCAPEMENT · MAIN VIEW

An escapement is the part of a clock that refuses. The mainspring would unwind itself in seconds; the escapement stands in the way and lets one tooth past at a time, which is what turns stored energy into an evenly divided day. This is that part, for a Zettelkasten — a Cloudflare Worker keeping four appointments against a vault that lives on GitHub, so no laptop has to be awake for any of it. Thoughts and todos arrive from a phone over Discord; once a week they come back as one page, sorted and verbatim, with three questions underneath. There is no model in it, and it cannot write a note, which is the point.

The instrument

Escapement — The week comes back as zettels, todos, and three questions
PLATE I — THE WEEK COMES BACK AS ZETTELS, TODOS, AND THREE QUESTIONS

The week comes back as zettels, todos, and three questions

Thoughts and todos are captured the same way, from a phone, into the same daily inbox — a todo just carries a tag after its timestamp. At Saturday midnight the week is filed verbatim into one review entry: zettels first, then todos as checkboxes, then three standing questions — what's noise, what's for you, what's logistics. The day and time sit after each item as a faded label, because the split that matters is what a thought is, not which day it arrived.

Five questions at 7pm, answered one at a time

What you're grateful for today; one "unrealistic" long-term dream you're concretely chasing, and how; one closer-term dream, and how; how you're cultivating genuine relationships; and how you lived your values today — or, if you didn't, how you'll improve tomorrow. Each is its own slash command, answered in any order. Answers collect in a draft that never reaches the journal half-finished, and the fifth one writes the entry.

Escapement — Four jobs, one cron expression, no DST in the config
PLATE III — FOUR JOBS, ONE CRON EXPRESSION, NO DST IN THE CONFIG

Four jobs, one cron expression, no DST in the config

Cloudflare cron is UTC-only, so each job used to be registered twice — once at its CDT hour, once at its CST hour — with the handler discarding the wrong half. That costs an expression per job against a free-plan cap of five. Now a single expression ticks every 15 minutes and the handler matches the local wall clock within ±7 minutes: a tolerance under half the spacing, so a late fire still counts and no two jobs can claim the same tick. Daylight saving stopped being represented in the config at all.

Escapement — Three writers, one repo, one guard
PLATE IV — THREE WRITERS, ONE REPO, ONE GUARD

Three writers, one repo, one guard

A Worker, a Mac, and a Windows box all commit to the same vault. Only one of them runs `git add -A`, and one evening it staged 26 deletions against a working tree that was quietly missing files. The guard sits at exactly that point — trip it and the sync stalls loudly instead of losing work quietly.

Escapement — No model in the loop
PLATE V — NO MODEL IN THE LOOP

No model in the loop

It started with Claude reading the vault back every night. The commentary went first, then the model entirely: a review written by something else trains you to read instead of think. Now every word the Worker files is yours, copied verbatim, and the one layer that matters — the slipbox — is written by hand, always.

The movement

The engineering underneath

An escapement doesn't drive the clock. It stands in the way of a wheel that would otherwise spin itself out in seconds, and lets exactly one tooth past at a time.

The gate is a wall clock, not a cron field

The Worker wakes ninety-six times a day and does nothing on ninety-two of them. One expression ticks every fifteen minutes; the handler converts to local time and compares against minutes-of-day with a ±7 window. The tolerance has to stay under half the tick spacing — wide enough to absorb a trigger that fires a minute or two late, narrow enough that two jobs on adjacent ticks can never both match and let the if/else silently drop the second.

index.ts
/** Cron. Wakes every 15 minutes; gates on local wall clock. */
async scheduled(_ctrl: ScheduledController, env: Env, ctx: ExecutionContext) {
  const { minutes, weekday } = localParts(env);

  const near = (h: string, m: string) =>
    Math.abs(minutes - (Number(h) * 60 + Number(m))) <= 7;

  if (weekday === env.ZETTELS_WEEKDAY && near(env.ZETTELS_HOUR, env.ZETTELS_MINUTE)) {
    ctx.waitUntil(rollUpZettels(env, localDate(env)).then(/* notice */));
  } else if (weekday === env.REFLECT_WEEKDAY && near(env.REFLECT_HOUR, env.REFLECT_MINUTE)) {
    ctx.waitUntil(dc.send(env.DISCORD_WEBHOOK_LEARNING, REFLECT_NUDGE));
  } else if (near(env.GRATITUDE_HOUR, env.GRATITUDE_MINUTE)) {
    ctx.waitUntil(dc.send(env.DISCORD_WEBHOOK_LEARNING, GRATITUDE_NUDGE));
  } else if (near(env.VALUE_HOUR, env.VALUE_MINUTE)) {
    ctx.waitUntil(sendValueReminder(env));
  }
  // Otherwise this tick isn't a job time — do nothing. Most of them aren't.
}

One tag after the timestamp is the whole taxonomy

A zettel is stamped `[HH:MM]`; a todo is stamped `[HH:MM] todo`. On Saturday the inbox is split at every stamp, so a capture runs to the next one and a multi-paragraph thought stays whole. No classifier, no folders, no second inbox — the capture command already said what the thing was.

zettels.ts
const STAMP = /^\[(\d{2}:\d{2})\]( todo)?[ \t]*$/;

for (const line of file.split("\n")) {
  const m = line.match(STAMP);
  if (m) {
    flush();
    cur = { time: m[1], todo: !!m[2], lines: [] };
  } else if (cur) {
    cur.lines.push(line);
  }
}

Commit the review before archiving the inbox

The roll-up writes the review entry first and moves inbox files to the archive only after that commit lands. If the write throws, nothing moves, so nothing can reach the archive without having been rolled up. A rerun checks for the week's heading and never files it twice.

The whole vault arrives in a single request

Reading seventy-odd files one call at a time would spend most of the Worker's subrequest budget on a single job. Pulling the repo tarball and unpacking it in memory costs one fetch, and the cost stays at one as the vault grows.

vault.ts
export async function readVault(env: Env): Promise<Vault> {
  const res = await fetch(
    `${API}/repos/${env.GITHUB_REPO}/tarball/${env.GITHUB_BRANCH}`,
    { headers: headers(env) },
  );
  if (!res.ok) throw new Error(`tarball ${res.status}: ${await res.text()}`);

  const gunzipped = res.body!.pipeThrough(new DecompressionStream("gzip"));
  return untar(new Uint8Array(await new Response(gunzipped).arrayBuffer()));
}

A tar path longer than 100 bytes is stored in two places

GitHub emits ustar, which splits any path past 100 bytes across a `prefix` field at offset 345 and the `name` field at offset 0. A reader that trusts `name` alone doesn't fail — it silently truncates, and the files that vanish are the deeply nested ones.

vault.ts
const prefix = str(pos + 345, 155);
const name = str(pos, 100);
const full = paxPath ?? (prefix ? `${prefix}/${name}` : name);
const size = parseInt(str(pos + 124, 12) || "0", 8);
const type = String.fromCharCode(buf[pos + 156]);
Specification
Runtime
Cloudflare Worker · ~1,100 lines of TypeScript
Source of truth
GitHub — every local clone is a cache
Interface
Discord — /zettel, /todo, /reflect, and one command per gratitude question inbound; a channel webhook outbound
Models
None — removed in November 2026; everything is filed verbatim
Vault read
One request — repo tarball, gunzipped and untarred inside the Worker
Schedule
Four jobs on one 15-minute tick, matched against the local wall clock
Running cost
Free tier — no API tokens
Source
Public — every credential is a Workers secret, never in the repo