Skip to content

Keep the memory store in S3 instead of the Actions cache - #6

Merged
joshuanapoli merged 1 commit into
mainfrom
s3-store
Nov 12, 2026
Merged

joshuanapoli merged 1 commit into
mainfrom
s3-store

Conversation

@joshuanapoli

Copy link
Copy Markdown
Member

Why

The Actions cache can't hold a store that every run shares:

  • Cache entries are scoped to the ref that saved them. In CVector-Energy/ui, every memory entry saved so far came from a PR Review Response run on a pull request, so the weekly Skill Refinement run on main and every other pull request were unable to restore it.
  • Eviction. The repository's cache is at its 20 GB limit, almost all of it Supabase images, so an entry nobody reads for about a day is evicted.

What changes

  • New required inputs bucket and role-to-assume, plus optional aws-region (default us-east-1). The store is kept under <owner>/<repo>/memory/.
  • The action assumes the role itself, using the job's OIDC token (id-token: write), and never exports the credentials, so the agent step does not inherit them.
  • The save writes back only what this run changed compared with what it restored, so concurrent runs don't clobber each other:
    • It uploads files this run added or changed, and leaves files it never touched alone.
    • It deletes files this run deleted, unless another run has rewritten them since.
    • It merges MEMORY.md line by line when two runs both changed it.
    • It saves nothing if the store directory is gone. Claude Code 2.1.219 was seen removing an empty memory/ folder mid-session, and syncing a missing folder would delete every memory.
  • @actions/cache is replaced by @aws-sdk/client-s3 and @aws-sdk/client-sts (3.1147.0). The snapshot input and all outputs are unchanged.

This is a breaking change, so it should be released as v0.2.0. The bucket and role for CVector-Energy/ui come from that repository's dev terraform stacks.

Testing

  • npm test: 20 tests pass. New tests cover the save plan (uploads, deletes, concurrent edits and deletions, index merges), the line-wise MEMORY.md merge, local hashing, and the path-escape guard.
  • npm run build: dist/ is regenerated.
  • Not yet run against S3. That needs the bucket and role from the ui PR to be applied first.

🤖 Generated with Claude Code

A cache entry saved by a pull request run is visible only to that pull request, so a scheduled job on the default branch, and every other pull request, never saw what an agent learned. The cache also evicts whatever has not been read lately once it fills, which in CVector-Energy/ui happens within a day.

The store now lives under <owner>/<repo>/memory/ in a bucket the caller names, reached through a role assumed with the job's OIDC token inside the action, so the agent does not inherit the credentials. The save writes back only what the run changed relative to what it restored, skips a deletion another run has since overtaken, merges MEMORY.md line by line when two runs both edited it, and saves nothing when the store directory is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshuanapoli
joshuanapoli requested a review from alok27a November 11, 2026 16:44
@joshuanapoli
joshuanapoli merged commit bf38ca4 into main Nov 12, 2026
3 checks passed
@joshuanapoli
joshuanapoli deleted the s3-store branch November 12, 2026 13:55
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.

1 participant