Skip to main content
← Back to list
01Issue
BugClosedSwamp CLIPublic
AssigneesNone

Relationships

#2366 s3/gcs datastore: directory dirty paths map to the wrong index shard, so 3+ segment model types re-upload their whole history on every write

Opened by stack72 · 9/22/2026

Found while triaging swamp-club#2353. Extension-side (@swamp/s3-datastore and @swamp/gcs-datastore; the code is identical in s3_cache_sync.ts and gcs_cache_sync.ts).

Problem

partitionKeyFromPath derives an index shard key from the segment count of a path. File paths map consistently, but a directory relPath lands on the wrong shard: the segment count of a directory cannot be told apart from a file's, and model types of different depths put the model id at different depths.

  • A data-name directory for a 3+ segment type (for example data/@test/aws/ec2//) maps to data--@test--aws, which is not a real partition. Version files live in data--@test--aws--ec2-- and latest markers in data--@test--aws--ec2.
  • Core signals the data-name directory on every data write (save, append, allocateVersion), because the version is not allocated yet at notify time.
  • assembleDirtyShardsOnly therefore loads an empty index, the scoped walk stats the directory, and fileNeedsPush returns true for every file, since there is no index entry.

Evidence (localstack, swamp 20260922, s3-datastore 2026.09.22.2)

A @test/aws/ec2 model writing one resource per run pushed 11, 16, 22, 28, then 34 files per run. Version 1's LastModified changed on every run. A command/shell control stayed flat at 13 per run: 2-segment types only re-upload latest each time. The same happens for the delete-all fallback in core, which still sends a data-name directory when version enumeration fails.

Fix

A directory relPath must load every partition that can hold entries under it: any partition whose key is a double-dash prefix of the path, or has the path as a double-dash prefix. This widens the directory-walk delete check (index entries under the directory with no local file), which has never fired for 3+ segment types, so it needs its own tests.

Removals no longer depend on this mapping once the swamp-club#2353 core change lands, because core then sends file-level paths. Writes still do.

02Bog Flow
✓OPEN○TRIAGED○IN PROGRESS◉CLOSED

Closed

9/22/2026, 9:23:56 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.