Skip to content

Add optional cacheControl to put and bump to 0.2.0 - #11

Merged
FlyOverCoderKY merged 2 commits into
mainfrom
claude/busy-chatelet-a0aa73
Jul 30, 2026
Merged

FlyOverCoderKY merged 2 commits into
mainfrom
claude/busy-chatelet-a0aa73

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Why

The Exsimplify migration surfaced a real consumer need the port could not express: the .NET host stored product images with Cache-Control: public, max-age=31536000, immutable for public CDN-ish serving, and the Pegma port had to drop the header (recorded as a feedback candidate in Exsimplify's docs/Pegma-Migration-Plan.md, Phase 5).

Scope decision

Weighed against the package's refusals: Cache-Control at write time is native object state on every first-class backend — Azure blobHTTPHeaders.blobCacheControl, S3 CacheControl, R2 CacheControl via the S3-compatible API — served with the bytes on read. That makes it an honest intersection, in the same family as contentType, unlike signed URLs and lifecycle rules, which remain out of the port. A broader allowlisted response-headers object was considered and rejected: Content-Disposition and friends are host response policy at serve time, and only cacheControl has a demonstrated consumer need. The decision is documented in the package README ("Cache-control" section).

What changed

  • Port (@pegma/storage-blobs): PutOptions.cacheControl?: string, validated like content-type (printable ASCII, no surrounding whitespace, MAX_CACHE_CONTROL_BYTES = 256, no default). BlobObjectInfo.cacheControl: string | undefined returned by head/get; a replacing put without one clears it. Exported assertValidCacheControl. Memory store round-trips it.
  • Conformance: four new cases — verbatim round-trip, undefined when omitted, replace-clears, and rejection of illegal values.
  • Adapters: azure-blob (blobCacheControl on upload, read from properties/download), s3 and r2 (CacheControl on PutObjectCommand, read from Head/Get). Empty-string responses normalize to undefined (Azurite reports cleared cache-control as "").
  • Release: all four packages to 0.2.0 (port surface grew → minor per repo convention), adapter deps exact-pinned to 0.2.0, lockfile refreshed, README/plan version references updated.

Verification

npm run format:check, npm run check, and npm test all green — 240 tests including the new cases against Azurite (Azure) and LocalStack (S3, R2), 16 new case runs total.

🤖 Generated with Claude Code

Consumers migrating hosts that serve stored images publicly need to keep a
Cache-Control header with the object (first recorded need: Exsimplify product
image uploads storing "public, max-age=31536000, immutable"). Every
first-class backend keeps Cache-Control as native object state served with
the bytes — Azure blobHTTPHeaders.blobCacheControl, S3 and R2 CacheControl —
so it is an honest intersection, unlike signed URLs or lifecycle rules,
which stay out of the port.

PutOptions gains an optional cacheControl validated like content-type
(printable ASCII, no surrounding whitespace, 256-byte cap, no default);
BlobObjectInfo returns it from head/get, undefined when a put omitted it,
and a replacing put without one clears it. Conformance covers round-trip,
absent-by-default, replace-clears, and rejection across the memory store
and all three adapters. Minor bump to 0.2.0 since the port surface grew.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 16:15
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f82ec0d7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Ready to approve

The port extension is consistently implemented across the port, conformance suite, and all first-class adapters with clear validation and documented semantics.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Extends the @pegma/storage-blobs port to allow storing an object-level Cache-Control value at write time (and returning it from head/get), with matching conformance coverage and adapter support across Azure Blob, S3, and R2; also bumps the published package versions to 0.2.0.

Changes:

  • Add PutOptions.cacheControl?: string, BlobObjectInfo.cacheControl: string | undefined, MAX_CACHE_CONTROL_BYTES, and assertValidCacheControl to the port (including memory-store round-trip).
  • Add conformance cases for cache-control round-trip, omission semantics, replace-clears semantics, and validation rejection.
  • Wire cache-control through Azure/S3/R2 adapters and bump all package versions/dependencies to 0.2.0 (plus doc/version reference updates).
File summaries
File Description
README.md Update published version references to 0.2.0.
packages/storage-s3/src/index.ts Pass cacheControl through put/head/get and normalize empty-string responses to undefined.
packages/storage-s3/README.md Update version reference to 0.2.0.
packages/storage-s3/package.json Bump package and port dependency to 0.2.0.
packages/storage-cloudflare-r2/src/index.ts Pass cacheControl through put/head/get and normalize empty-string responses to undefined.
packages/storage-cloudflare-r2/README.md Update version reference to 0.2.0.
packages/storage-cloudflare-r2/package.json Bump package and port dependency to 0.2.0.
packages/storage-blobs/src/index.ts Add cache-control to the port types, validation, and memory store persistence.
packages/storage-blobs/src/conformance.ts Add conformance coverage for cache-control behavior and validation.
packages/storage-blobs/README.md Document cacheControl usage and bump install/version references to 0.2.0.
packages/storage-blobs/package.json Bump package version to 0.2.0.
packages/storage-azure-blob/src/index.ts Pass cacheControl via Azure blob HTTP headers and return it from head/get; normalize empty-string to undefined.
packages/storage-azure-blob/README.md Update version reference to 0.2.0.
packages/storage-azure-blob/package.json Bump package and port dependency to 0.2.0.
package-lock.json Align lockfile package versions and internal dependency pins to 0.2.0.
docs/PROJECT_PLAN.md Update status/version references and note the new cache-control capability.
Review details
  • Files reviewed: 15/16 changed files
  • Comments generated: 0
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Adapters read head and get through different provider calls, so the
replace-clears case must pin both consumer-visible paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@FlyOverCoderKY
FlyOverCoderKY merged commit 436a30d into main Jul 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants