Skip to content

Allow registry-scoped Atom memo maps - #6888

Open
andrskr wants to merge 2 commits into
Effect-TS:mainfrom
andrskr:trust-me/registry-scoped-atom-memo-map
Open

Allow registry-scoped Atom memo maps#6888
andrskr wants to merge 2 commits into
Effect-TS:mainfrom
andrskr:trust-me/registry-scoped-atom-memo-map

Conversation

@andrskr

@andrskr andrskr commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow Atom.context to accept a concrete Layer.MemoMap or an Atom<Layer.MemoMap>
  • resolve atom-backed memo maps through the active AtomRegistry
  • keep concrete memo maps factory-scoped, preserving the current behavior

Related to #6887.

Why

One Atom runtime can be used by several registries, but its concrete memo map is shared by the whole factory. This means registries can hold different atom values while still sharing runtime layers and Reactivity through the same map.

We hit this with module-level AtomRpc atoms and request-scoped SSR registries. A mutation in one registry also refreshed a reactive query in another registry.

Recreating runtimes and atoms per request avoids the sharing, but gives up stable module-level atoms. Layer.fresh rebuilds more than the ownership boundary requires.

Proposed API

const registryMemoMap = Atom.make(() => Layer.makeMemoMapUnsafe())

const runtime = Atom.context({
  memoMap: registryMemoMap
})

The memo-map atom is resolved through the active registry. A concrete map continues to work as before.

This PR is intentionally a draft. I am not sure an atom is the best public API; an explicit scope option or another composition may be better. The goal is to give #6887 a concrete implementation and proof for discussion.

Proof

  • concrete maps remain shared across registries
  • atom-backed maps share layers inside one registry and isolate different registries
  • each registry finalizes only its own scoped resources
  • a reactive mutation refreshes queries only in its active registry

Validation

  • pnpm lint-fix
  • pnpm lint
  • pnpm test --run packages/effect/test/reactivity/Atom.test.ts
  • pnpm check
  • pnpm exec changeset status --since upstream/main

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Aug 2, 2026
@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 07b67a8

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

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator 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

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.65 KB 6.65 KB 0.00 KB (0.00%)
batching.ts 9.44 KB 9.44 KB 0.00 KB (0.00%)
brand.ts 6.33 KB 6.33 KB 0.00 KB (0.00%)
cache.ts 10.20 KB 10.20 KB 0.00 KB (0.00%)
config.ts 20.34 KB 20.34 KB 0.00 KB (0.00%)
differ.ts 19.95 KB 19.95 KB 0.00 KB (0.00%)
http-client.ts 21.04 KB 21.04 KB 0.00 KB (0.00%)
logger.ts 10.35 KB 10.35 KB 0.00 KB (0.00%)
metric.ts 8.58 KB 8.58 KB 0.00 KB (0.00%)
optic.ts 7.34 KB 7.34 KB 0.00 KB (0.00%)
pubsub.ts 14.49 KB 14.49 KB 0.00 KB (0.00%)
queue.ts 11.15 KB 11.15 KB 0.00 KB (0.00%)
schedule.ts 10.33 KB 10.33 KB 0.00 KB (0.00%)
schema-class.ts 18.88 KB 18.88 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.69 KB 28.69 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.01 KB 25.01 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.01 KB 13.01 KB 0.00 KB (0.00%)
schema-string.ts 10.66 KB 10.66 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.87 KB 14.87 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.67 KB 21.67 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.10 KB 24.10 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.93 KB 18.93 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.74 KB 18.74 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.61 KB 18.61 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.36 KB 22.36 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.28 KB 19.28 KB 0.00 KB (0.00%)
schema.ts 18.14 KB 18.14 KB 0.00 KB (0.00%)
stm.ts 12.13 KB 12.13 KB 0.00 KB (0.00%)
stream.ts 9.38 KB 9.38 KB 0.00 KB (0.00%)

@effect-slopcop effect-slopcop Bot added the bug Something isn't working label Aug 2, 2026
@andrskr
andrskr marked this pull request as ready for review August 4, 2026 14:38
@pullfrog

pullfrog Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

no API key found — this repo is configured to use moonshotai/kimi-k2.7-code, which needs MOONSHOT_API_KEY, but the runner has no key for it.

To fix: add the key as a GitHub Actions secret (referenced from your workflow's env: block) or as a Pullfrog secret in the console — or switch this repo to a different model (free models need no key).

Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Rerun failed job ➔View workflow run | via Pullfrog | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working enhancement New feature or request

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

1 participant