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
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Analytics (cookieless) or nothing.
## Reference points

The plan is `docs/PROJECT_PLAN.md`. The ecosystem's repos (spine,
storage-core, authorization-core, audit, webhooks, sessions, rate-limit,
support-desk, mail, identity, logger-adapters) are the source of truth for
everything the site says about them.
storage-core, storage-blobs, cache-core, authorization-core, audit, webhooks,
sessions, rate-limit, support-desk, mail, identity, billing-core, flags-core,
logger-adapters) are the source of truth for everything the site says about
them.
6 changes: 3 additions & 3 deletions docs/catalog/SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ CompositionCatalog
Structured flags (not free text) so `plan_composition` can stay rule-based:

`accounts`, `passkeys`, `email_codes`, `sessions`, `authorization`, `storage`,
`storage_blobs`, `audit`, `mail_transactional`, `rate_limit_durable`,
`rate_limit_memory`, `webhooks_inbound`, `support_queue`, `health`, `logging`,
`events_in_process`, `cloudflare`, `azure`, `static_host`.
`storage_blobs`, `cache`, `flags`, `billing`, `audit`, `mail_transactional`,
`rate_limit_durable`, `rate_limit_memory`, `webhooks_inbound`, `support_queue`,
`health`, `logging`, `events_in_process`, `cloudflare`, `azure`, `static_host`.

## TypeScript source

Expand Down
17 changes: 16 additions & 1 deletion evals/assembly-eval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ const EVAL_NPM: Record<string, string | null> = {
'@pegma/webhooks': '0.1.0',
'@pegma/sessions': '0.1.0',
'@pegma/mail': '0.1.0',
'@pegma/billing-core': null,
'@pegma/billing-core': '0.1.1',
'@pegma/billing-stripe': '0.1.1',
'@pegma/cache-core': '0.1.1',
'@pegma/cache-conformance': '0.1.1',
'@pegma/cache-redis': '0.1.1',
'@pegma/cache-azure-redis': '0.1.1',
'@pegma/cache-elasticache': '0.1.1',
'@pegma/cache-upstash-redis': '0.1.1',
'@pegma/flags-contracts': '0.1.1',
'@pegma/flags-core': '0.1.1',
'@pegma/flags-static': '0.1.1',
'@pegma/flags-azure-appconfig': '0.1.1',
'@pegma/flags-aws-appconfig': '0.1.1',
'@pegma/flags-cloudflare-flagship': '0.1.1',
'@pegma/flags-flagd': '0.1.1',
'@pegma/flags-launchdarkly': '0.1.1',
'@pegma/identity': '0.1.0',
'@pegma/rate-limit': '0.1.0',
'@pegma/logger-tee': '0.1.1',
Expand Down
31 changes: 22 additions & 9 deletions public/llms.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Pegma

> An MIT-licensed family of composable backend components — storage,
> authorization, identity, audit, webhooks, sessions, rate limiting, billing, mail,
> a support desk —
> authorization, identity, audit, webhooks, sessions, rate limiting, cache, flags,
> billing, mail, a support desk —
> designed to be assembled and maintained by AI agents. Early 0.x: some
> packages published, none stable. npm scope: @pegma. GitHub: pegma-dev.

Expand Down Expand Up @@ -34,6 +34,12 @@ reference environment.
conditional deletes, bounded authoritative scans, single-partition
transactions, and a conformance suite adapters must pass against a real
backend. Published as 0.4.0.
- [Cache Core](https://github.com/pegma-dev/cache-core):
@pegma/cache-core, @pegma/cache-conformance, @pegma/cache-redis,
@pegma/cache-azure-redis, @pegma/cache-elasticache,
@pegma/cache-upstash-redis — a cache port and adapters: namespaced keys,
cache-aside getOrCompute, clock-driven TTL, conformance suite. Published
as 0.1.1; 0.x API remains unstable. Optional — not a store.
- [Authorization Core](https://github.com/pegma-dev/authorization-core):
@pegma/authorization-* (contracts, core, policy, auth0, stripe, storage,
tokens, identity) — provider-neutral roles, entitlements, permissions,
Expand All @@ -59,18 +65,25 @@ reference environment.
remains unstable.
- [Rate Limit](https://github.com/pegma-dev/rate-limit): @pegma/rate-limit —
an honest in-memory tier and a durable fail-closed tier. Published as 0.1.0.
- [Flags Core](https://github.com/pegma-dev/flags-core):
@pegma/flags-contracts, @pegma/flags-core, @pegma/flags-static,
@pegma/flags-azure-appconfig, @pegma/flags-aws-appconfig,
@pegma/flags-cloudflare-flagship, @pegma/flags-flagd,
@pegma/flags-launchdarkly — a flag port and adapters: typed schema,
evaluation context, honest reasons, no authoring UI. Published as 0.1.1;
0.x API remains unstable. Optional.
- [Identity](https://github.com/pegma-dev/identity): @pegma/identity —
first-party identity: passkeys-first, email-code fallback, NO passwords
(a refusal, not a phase); user records in the host's own storage. Published
as 0.1.0 and composed by this site's Cloudflare Worker.
- [Billing Core](https://github.com/pegma-dev/billing-core):
@pegma/billing-core — a provider-agnostic subscription ledger maintained
correctly under out-of-order webhook delivery: event-arbitration guard
(watermark + snapshot freshness bound + lifecycle-rank tie-breaking),
drift-repairing reconciliation, declared sticky/first-wins invariants,
single-opportunity checkout reservation. Never sees card data or raw
payloads. Planned; extraction from the reference application scheduled
deliberately.
@pegma/billing-core, @pegma/billing-stripe — a provider-agnostic
subscription ledger maintained correctly under out-of-order webhook
delivery: event-arbitration guard (watermark + snapshot freshness bound +
lifecycle-rank tie-breaking), drift-repairing reconciliation, declared
sticky/first-wins invariants, single-opportunity checkout reservation.
Never sees card data or raw payloads. Not a payment processor. Published
as 0.1.1; 0.x API remains unstable. Optional.
- [Mail](https://github.com/pegma-dev/mail): @pegma/mail — transactional
mail: provider ports and an outbox pattern that owns NO store (jobs
commit in the caller's transaction, the audit precedent). Published as
Expand Down
125 changes: 125 additions & 0 deletions src/data/catalog-enrichment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,48 @@ export const COMPONENT_ENRICHMENT: Readonly<Record<string, ComponentEnrichment>>
// Distinct from record `storage` so generic storage plans do not pull R2/Blob.
capabilityTags: ['storage_blobs', 'cloudflare', 'azure'],
},
'cache-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires', note: 'Injected Clock and Logger' },
],
adapters: [
{
id: 'memory',
packageName: '@pegma/cache-core',
host: 'memory',
when: 'Tests and local sketches; not a durability claim',
},
{
id: 'redis',
packageName: '@pegma/cache-redis',
host: 'other',
when: 'Generic Redis (ioredis) behind the cache port',
},
{
id: 'azure-redis',
packageName: '@pegma/cache-azure-redis',
host: 'azure',
when: 'Azure Cache for Redis; thin composition of cache-redis',
},
{
id: 'elasticache',
packageName: '@pegma/cache-elasticache',
host: 'other',
when: 'Amazon ElastiCache; thin composition of cache-redis',
},
{
id: 'upstash-redis',
packageName: '@pegma/cache-upstash-redis',
host: 'other',
when: 'Upstash Redis REST client behind the same port',
},
],
hostMustProvide: [
'Chosen adapter binding (Redis URL, Azure cache, ElastiCache, Upstash, or memory)',
'Explicit fail-open vs fail-closed policy — fail-open computes, it does not accumulate',
],
capabilityTags: ['cache', 'azure'],
},
'authorization-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
Expand Down Expand Up @@ -176,6 +218,40 @@ export const COMPONENT_ENRICHMENT: Readonly<Record<string, ComponentEnrichment>>
],
capabilityTags: ['mail_transactional'],
},
'billing-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'requires',
note: 'Ledger collections over an injected Store',
},
{
componentId: 'webhooks',
kind: 'composes_with',
note: 'Receipt dedup; this ledger owns ordering, not delivery identity',
},
{
componentId: 'authorization-core',
kind: 'composes_with',
note: 'What a subscription grants is Authorization Core; this is what it is',
},
],
adapters: [
{
id: 'stripe',
packageName: '@pegma/billing-stripe',
host: 'other',
when: 'Stripe event and subscription snapshot translation; host verifies signatures',
},
],
hostMustProvide: [
'Storage binding for the ledger',
'Provider checkout/portal flows — this package is not a payment processor',
'Webhook authenticity (signature verification stays with the host)',
],
capabilityTags: ['billing'],
},
identity: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
Expand Down Expand Up @@ -225,6 +301,55 @@ export const COMPONENT_ENRICHMENT: Readonly<Record<string, ComponentEnrichment>>
],
capabilityTags: ['rate_limit_durable', 'rate_limit_memory'],
},
'flags-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires', note: 'Injected Clock and Logger' },
],
adapters: [
{
id: 'static',
packageName: '@pegma/flags-static',
host: 'memory',
when: 'Tests and local development; in-memory map, not a control plane',
},
{
id: 'azure-appconfig',
packageName: '@pegma/flags-azure-appconfig',
host: 'azure',
when: 'Azure App Configuration; adapter translates, does not evaluate targeting rules',
},
{
id: 'aws-appconfig',
packageName: '@pegma/flags-aws-appconfig',
host: 'other',
when: 'AWS AppConfig; already-evaluated values only',
},
{
id: 'cloudflare-flagship',
packageName: '@pegma/flags-cloudflare-flagship',
host: 'cloudflare',
when: 'Cloudflare Flagship; already-evaluated *Details results',
},
{
id: 'flagd',
packageName: '@pegma/flags-flagd',
host: 'other',
when: 'flagd / OpenFeature detail translation',
},
{
id: 'launchdarkly',
packageName: '@pegma/flags-launchdarkly',
host: 'other',
when: 'LaunchDarkly adapter; no vendor SDK in application code',
},
],
hostMustProvide: [
'A constructed client at the composition root — no ambient getClient()',
'EvaluationContext (targeting key; optional principal, tenant, environment)',
'Chosen provider adapter; the provider owns targeting rules',
],
capabilityTags: ['flags', 'cloudflare', 'azure'],
},
'logger-adapters': {
dependencies: [
{ componentId: 'spine', kind: 'requires', note: 'Implements Spine Logger' },
Expand Down
3 changes: 3 additions & 0 deletions src/data/catalog-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const CAPABILITY_TAGS = new Set<CapabilityTag>([
'authorization',
'storage',
'storage_blobs',
'cache',
'flags',
'billing',
'audit',
'mail_transactional',
'rate_limit_durable',
Expand Down
3 changes: 3 additions & 0 deletions src/data/catalog-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export type CapabilityTag =
| 'storage'
/** Opaque object/blob bytes (storage-blobs); distinct from record storage. */
| 'storage_blobs'
| 'cache'
| 'flags'
| 'billing'
| 'audit'
| 'mail_transactional'
| 'rate_limit_durable'
Expand Down
109 changes: 108 additions & 1 deletion src/data/compile-catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
compileCompositionCatalog,
} from './compile-catalog';
import { CATALOG_SCHEMA_VERSION } from './catalog-schema';
import { components } from './components';
import { components, SNAPSHOT_DATE } from './components';
import { RECIPE_BACKLOG } from './recipe-backlog';

const FIXED_AT = '2026-07-29T00:00:00.000Z';
Expand All @@ -31,6 +31,41 @@ function compile(npm: Record<string, string | null>) {
}

describe('compileCompositionCatalog', () => {
it('lists sixteen registry components including published cache, flags, and billing', () => {
expect(SNAPSHOT_DATE).toBe('2026-08-15');
expect(components).toHaveLength(16);
const byRepo = Object.fromEntries(components.map((c) => [c.repo, c]));
expect(byRepo['cache-core']?.status).toBe('published');
expect(byRepo['cache-core']?.packages).toEqual([
'@pegma/cache-core',
'@pegma/cache-conformance',
'@pegma/cache-redis',
'@pegma/cache-azure-redis',
'@pegma/cache-elasticache',
'@pegma/cache-upstash-redis',
]);
expect(byRepo['flags-core']?.status).toBe('published');
expect(byRepo['flags-core']?.packages).toEqual([
'@pegma/flags-contracts',
'@pegma/flags-core',
'@pegma/flags-static',
'@pegma/flags-azure-appconfig',
'@pegma/flags-aws-appconfig',
'@pegma/flags-cloudflare-flagship',
'@pegma/flags-flagd',
'@pegma/flags-launchdarkly',
]);
expect(byRepo['billing-core']?.status).toBe('published');
expect(byRepo['billing-core']?.packages).toEqual([
'@pegma/billing-core',
'@pegma/billing-stripe',
]);
expect(byRepo['billing-core']?.now).toMatch(/0\.1\.1/);
expect(byRepo['billing-core']?.now).not.toMatch(/unpublished|nothing extracted|planned/i);
expect(byRepo['cache-core']?.now).not.toMatch(/unpublished/i);
expect(byRepo['flags-core']?.now).not.toMatch(/unpublished/i);
});

it('emits schema 0.1.0 with one entry per registry component', async () => {
clearNpmVersionCache();
const catalog = await compile({
Expand Down Expand Up @@ -138,4 +173,76 @@ describe('compileCompositionCatalog', () => {
);
expect(storage.capabilityTags).toContain('storage');
});

it('keeps a fetched unpublished Stage paragraph instead of forcing the snapshot', async () => {
clearNpmVersionCache();
const cacheStage =
'Phase 5 — Upstash Redis adapter, in-tree, unpublished. Packages are 0.1.1 and not published.';
const flagsStage =
'Phase 3 vendor adapters implemented in-tree; unpublished. Public API unstable (0.x).';
const billingStage =
'Phase 4 — Stripe adapter in-tree. Nothing is published. (0.1.1, unpublished.)';
const catalog = await compileCompositionCatalog({
generatedAt: FIXED_AT,
stageByRepo: {
...NO_STAGES,
'cache-core': cacheStage,
'flags-core': flagsStage,
'billing-core': billingStage,
},
npmLookup: fakeNpm({
'@pegma/cache-core': '0.1.1',
'@pegma/cache-conformance': '0.1.1',
'@pegma/cache-redis': '0.1.1',
'@pegma/cache-azure-redis': '0.1.1',
'@pegma/cache-elasticache': '0.1.1',
'@pegma/cache-upstash-redis': '0.1.1',
'@pegma/flags-contracts': '0.1.1',
'@pegma/flags-core': '0.1.1',
'@pegma/flags-static': '0.1.1',
'@pegma/flags-azure-appconfig': '0.1.1',
'@pegma/flags-aws-appconfig': '0.1.1',
'@pegma/flags-cloudflare-flagship': '0.1.1',
'@pegma/flags-flagd': '0.1.1',
'@pegma/flags-launchdarkly': '0.1.1',
'@pegma/billing-core': '0.1.1',
'@pegma/billing-stripe': '0.1.1',
}),
});

expect(catalog.snapshotDate).toBe('2026-08-15');
expect(catalog.components).toHaveLength(16);

const cache = catalog.components.find((c) => c.id === 'cache-core')!;
const flags = catalog.components.find((c) => c.id === 'flags-core')!;
const billing = catalog.components.find((c) => c.id === 'billing-core')!;

expect(cache.stage).toBe(cacheStage);
expect(flags.stage).toBe(flagsStage);
expect(billing.stage).toBe(billingStage);
expect(cache.status).toBe('in_development');
expect(flags.status).toBe('in_development');
expect(billing.status).toBe('in_development');
expect(billing.publishUsability).toBe('usable');
expect(billing.packages.map((p) => p.name)).toEqual([
'@pegma/billing-core',
'@pegma/billing-stripe',
]);
expect(billing.capabilityTags).toContain('billing');
expect(cache.adapters.map((a) => a.id)).toEqual(
expect.arrayContaining(['memory', 'redis', 'azure-redis', 'elasticache', 'upstash-redis']),
);
expect(cache.capabilityTags).toContain('cache');
expect(flags.adapters.map((a) => a.id)).toEqual(
expect.arrayContaining([
'static',
'azure-appconfig',
'aws-appconfig',
'cloudflare-flagship',
'flagd',
'launchdarkly',
]),
);
expect(flags.capabilityTags).toContain('flags');
});
});
Loading