Skip to content

fix(core): bound durable media usage projection work - #2422

Merged
khoinguyenpham04 merged 2 commits into
mainfrom
feature/media-usage-projection-admission
Aug 12, 2026
Merged

khoinguyenpham04 merged 2 commits into
mainfrom
feature/media-usage-projection-admission

Conversation

@khoinguyenpham04

@khoinguyenpham04 khoinguyenpham04 commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Bounds one durable Media Usage projection job before it mutates the index.

  • preflights the complete entry projection against an evidence-backed limit of 12 occurrence mutations and 512 KiB of variable projection data;
  • preserves exact oversized projections as generation-stable no-ops;
  • bounds removal of absent source generations with an indexed prefix probe;
  • stops in-process conflict retries after any non-zero reservation;
  • records an already-oversized changed projection as a visible terminal resource failure without changing V1 synchronous refresh or repair;
  • adds repeatable SQLite and real D1/workerd cost evidence.

Follow-up to #2394.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (not applicable: no admin UI or user-visible strings)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: not applicable; this bounds the already-merged incremental indexing system

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenAI Codex (GPT-5)

Screenshots / test output

No visual changes.

  • pnpm typecheck
  • pnpm lint
  • pnpm --filter emdash build
  • focused Media Usage suite: 32 files, 414 passed, 1 skipped
  • Core suite on macOS: 432 files, 5,461 passed, 4 skipped; excluded one pre-existing /var versus /private/var path-alias assertion
  • pnpm --filter emdash test:workerd: real D1/workerd boundary passes
  • approved D1 boundary: 40 queries, 66 rows read, 122 rows written, 39 maximum binds, 1,253 maximum SQL bytes
  • pnpm query-counts: SQLite query counts and query text unchanged
  • pnpm exec changeset status

PostgreSQL parity tests were not run because EMDASH_TEST_PG is not configured locally.


Try this PR

Open a fresh playground →

A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.

Tracks feature/media-usage-projection-admission. Updated automatically when the playground redeploys.

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6af474b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 6af474b Aug 11 2026, 06:26 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 6af474b Aug 11 2026, 06:26 PM

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 1,570 lines across 18 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 6af474b Aug 11 2026, 06:28 PM

@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@khoinguyenpham04
khoinguyenpham04 marked this pull request as ready for review August 11, 2026 18:29
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Aug 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2422

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2422

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2422

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2422

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2422

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2422

emdash

npm i https://pkg.pr.new/emdash@2422

create-emdash

npm i https://pkg.pr.new/create-emdash@2422

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2422

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2422

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2422

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2422

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2422

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2422

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2422

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2422

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2422

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2422

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2422

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2422

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2422

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2422

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2422

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2422

commit: 6af474b

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a focused, well-scoped bug fix that bounds durable Media Usage projection work before it mutates the index. The approach is sound: add admission control to the durable work path, keep the synchronous V1 refresh path unchanged, preserve exact unchanged oversized projections as no-ops, and defer or fail oversized work cleanly. The implementation follows the existing generation-guarded write patterns and EmDash conventions.

I read the full diff, the changed source files, and the test fixtures. I checked for:

  • SQL safety in the new deletion-measurement query (parameterized, no raw identifier interpolation).
  • Correctness of the admission cost model and budget mutation semantics.
  • Behavior at the occurrence and byte boundaries.
  • Whether hasReservedMutation correctly stops in-process conflict retries after a reservation.
  • Whether the V1 synchronous refresh path remains unbounded.
  • Whether new queries hit content tables without locale filters (they don't; the changes are against media-usage system tables and the existing content-row lookup is unchanged).
  • Whether the return-type change of buildMediaUsageProjectionFingerprint is fully handled (only content-snapshots.ts and tests call it).
  • Whether tests cover the new behaviors: admission planner, terminal failures, no-op preservation, oversized cleanup, legacy path, and D1/workerd boundary.

I found no logic bugs, security issues, regressions, or AGENTS.md violations. The changeset is present and appropriate. This looks ready to merge as-is.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Aug 11, 2026

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@khoinguyenpham04
khoinguyenpham04 merged commit e28963b into main Aug 12, 2026
53 checks passed
@khoinguyenpham04
khoinguyenpham04 deleted the feature/media-usage-projection-admission branch August 12, 2026 09:39
@emdashbot emdashbot Bot mentioned this pull request Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants