npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pegma/scheduler

v0.1.0

Published

Durable coordination for host-triggered recurring Pegma work.

Readme

@pegma/scheduler

Durable coordination for host-triggered recurring work.

[!IMPORTANT] This package is under active development and is not published or usable in production yet. Version 0.0.0 is a repository-development placeholder, not an advertised release.

Phase 2 provides the durable runner: claim, bounded leases, scheduled and manual invocation, fenced checkpoint advancement, safe run state, and keyed inspection. The host still owns the wakeup.

import { fixedClock, noopLogger } from "@pegma/spine";
import { createMemoryStore } from "@pegma/storage-core";
import { createScheduler, defineScheduledTasks } from "@pegma/scheduler";

const tasks = defineScheduledTasks({
  "support.mail.send": async ({ checkpoint }) => {
    const page = await mailWorker.runSendPage({
      limit: 50,
      ...(checkpoint === undefined ? {} : { cursor: checkpoint }),
    });
    return { nextCheckpoint: page.nextCursor };
  },
});

const scheduler = createScheduler({
  store: createMemoryStore(),
  clock: fixedClock("2026-07-31T12:00:00.000Z"),
  logger: noopLogger,
  instanceId: "retiregolden-support",
  workerId: "worker-1",
  tasks,
});

await scheduler.runScheduled("support.mail.send", {
  scheduledFor: "2026-07-31T12:00:00.000Z",
  invocationId: "invocation-1",
});

Contracts

  • Task names are explicit static identifiers registered at the composition root.
  • A string checkpoint advances one scan cycle, null closes it, and omission leaves it unchanged.
  • Scheduled occurrences are suppressed when scheduledFor is not strictly newer than the last accepted scheduled occurrence.
  • Manual runs bypass occurrence suppression but share the same task lease.
  • Execution is at-least-once: a crash after a side effect and before fenced completion can repeat work. Domain operations must be idempotent.
  • handler_timeout returns outcome: "failed" while leaving the durable row running with its lease intact, because the timeout cannot abort the handler. Other workers still see a live lease until expiry.
  • Handler summary values are logged only; they are not durable inspection state in 0.1.
  • Default lease is 30 seconds; the maximum accepted lease is 24 hours. The handler timeout defaults to the lease minus one second of completion headroom when the lease is longer than one second; shorter leases default to the full claim budget. After claim I/O the runner re-samples the clock and runs the handler only when more than one second of lease remains, capping the timeout to remaining lease minus that headroom.

See the repository architecture, consumer evidence, testing matrix, and project plan.