Skip to content

feat: split cache deletion into swap and update job types - #222

Closed
razbroc wants to merge 1 commit into
alphafrom
feat/cache-deletion-job-types
Closed

feat: split cache deletion into swap and update job types#222
razbroc wants to merge 1 commit into
alphafrom
feat/cache-deletion-job-types

Conversation

@razbroc

@razbroc razbroc commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What

Replaces DeletionJobTypes.Delete_Cache with two job types:

Swap_Delete_Cache: 'Swap_Delete_Cache'
Update_Delete_Cache: 'Update_Delete_Cache'

DeletionTaskTypes.CacheDeletion: 'cache-deletion' is unchanged and is used by both.

Why

Cache invalidation after a layer swap and after an in-place update are different operations carrying different task parameters:

job type task type task params meaning
Swap_Delete_Cache cache-deletion redisDeleteStoredResourcesParamsSchema (prefix) the whole cache is stale — wipe the prefix
Update_Delete_Cache cache-deletion redisTilesDeletionParamsSchema (prefix + ranges) only some tiles are stale — invalidate those ranges

Workers resolve a strategy from the pair `${jobType}-${taskType}` (see cleaner's dependencyRegistration.ts). A single Delete_Cache job type collapses both cases onto one token, so one strategy would have to sniff the parameter shape at runtime and branch — giving up the compile-time dispatch the pair design exists to provide. Two job types give two tokens, each resolving to its own strategy.

Splitting at the job level rather than adding a second task type is deliberate: the distinction reflects the upstream event (a swap happened vs. an update happened), which is known when the job is created. Encoding it in the task type would push that choice down a layer.

Also

  • TSDoc on each new job type naming the params schema its pair resolves to. Pair-dispatch is invisible from this repo, so it's the one thing a reader can't infer from the constants.
  • Restores the trailing /* eslint-enable @typescript-eslint/naming-convention */.
  • Adds CONTEXT.md — a glossary pinning layer deletion / cache deletion / artifacts deletion / tiles deletion, and source type vs storage provider. These are close enough to be confusable and weren't written down anywhere.

No job-params schemas were added. The entire swap/update difference lives in the task params, so a swapDeleteCacheJobParamsSchema would be an empty object today — worse than no schema, since consumers would validate against it and get false confidence.

Companion work needed in cleaner

Not caused by this PR, but it ships alongside changes already on alpha that break cleaner:

  • tilesPathtilesRelativePath and sourceProviderstorageProvider; TilesDeletionStrategy reads both (3 sites).
  • TilesDeletionParams moved from types/core to types/deletion (still exported from the root barrel).
  • cleaner has no Redis storage provider yet — the new REDIS branch in both param unions will surface as a compile error in resolveStorageProvider until one is added.

Verification

npm run lint and tsc --project tsconfig.build.json --noEmit both pass. No tests added — the repo has no tests over constants.

Replaces the single Delete_Cache job type with Swap_Delete_Cache and
Update_Delete_Cache. Cache invalidation after a layer swap and after an
in-place update are different operations with different task parameters:
a swap invalidates the whole key prefix, an update invalidates specific
tile ranges.

Workers resolve strategies by the (jobType, taskType) pair, so a single
Delete_Cache job type collapsed both cases onto one token and forced the
strategy to discriminate on the parameter shape at runtime. Two job types
give two tokens and let each resolve to its own strategy.

The cache-deletion task type is unchanged and used by both.

Adds CONTEXT.md, a glossary for the deletion and storage vocabulary.
@razbroc razbroc closed this Aug 10, 2026
@github-actions

Copy link
Copy Markdown

Hi it is me, your friendly bot helper! 👋
I've packed this commit for you 😊
You can install it like this:

{
  "dependencies": {
      "@map-colonies/raster-shared": "https://ghatmpstorage.blob.core.windows.net/npm-packages/raster-shared-20df345e2a1bfd26c0f2ce306882501f88c34777.tgz"
  }
}

The link will expire in a week ⌛

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