diff --git a/.planning/STATE.md b/.planning/STATE.md
index 4d3f2a02..b44246db 100644
--- a/.planning/STATE.md
+++ b/.planning/STATE.md
@@ -5,10 +5,10 @@ current_phase: 30
current_phase_name: Płytarium cutover
status: planning
stopped_at: Phase 35 complete, ready to plan Phase 30
-last_updated: "2026-11-16T09:05:22.965Z"
-last_activity: 2026-11-16
-last_activity_desc: Phase 35 complete (UAT 14/14), transitioned to Phase 30
-state_head: 0c24e0e656c7bbb218e97abeeb8b1ccc43bbc97b
+last_updated: "2026-11-18T14:50:07.827Z"
+last_activity: 2026-11-18
+last_activity_desc: "Completed quick task 261118-lbt: per-app plugin instances, closable limiter store, one router build"
+state_head: 38f7f3a77757cd456601cd5e31e0a29b7338612c
progress:
total_phases: 52
completed_phases: 37
@@ -33,7 +33,7 @@ See: .planning/PROJECT.md (updated 2026-10-22)
Phase: 30 — Płytarium cutover
Plan: Not started
Status: Ready to plan
-Last activity: 2026-11-16 — Phase 35 complete (UAT 14/14), transitioned to Phase 30
+Last activity: 2026-11-18 — Completed quick task 261118-lbt: per-app plugin instances, closable limiter store, one router build
Progress: [████████░░] 77%
@@ -1272,6 +1272,7 @@ Recent decisions affecting current work:
| 261114-p5m | Fix CR-02 residual: quoted end tags in raw-text elements bypass the postcard scheme check | 2026-11-14 | f1f284a0 | [261114-p5m-fix-cr-02-residual-quoted-end-tags-in-ra](./quick/261114-p5m-fix-cr-02-residual-quoted-end-tags-in-ra/) |
| 261114-p5n | Style the user and paymentgateway plugin mail layouts like the postcard default layout | 2026-11-14 | 4ef3aa1f | [261114-p5n-style-the-user-and-paymentgateway-plugin](./quick/261114-p5n-style-the-user-and-paymentgateway-plugin/) |
| 261115-cha | Let a mail template use another plugin's layout by full code (G-35-9) | 2026-11-15 | b8487b02 | [261115-cha-let-a-mail-template-use-another-plugin-s](./quick/261115-cha-let-a-mail-template-use-another-plugin-s/) |
+| 261118-lbt | Per-app plugin instances, closable limiter store, one router build | 2026-11-18 | 38f7f3a7 | [261118-lbt-per-app-plugin-instances-closable-limite](./quick/261118-lbt-per-app-plugin-instances-closable-limite/) |
## Deferred Items
diff --git a/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-PLAN.md b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-PLAN.md
new file mode 100644
index 00000000..9014be3a
--- /dev/null
+++ b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-PLAN.md
@@ -0,0 +1,292 @@
+---
+phase: quick-261118-lbt
+plan: 01
+type: execute
+wave: 1
+depends_on: []
+files_modified:
+ - modules/party/registry.go
+ - modules/party/instances_test.go
+ - modules/party/README.md
+ - docs/plugins/registration.md
+ - docs/architecture/application-lifecycle.md
+ - modules/surf/limiter_store.go
+ - modules/surf/router.go
+ - modules/surf/serve.go
+ - modules/surf/routelist_command.go
+ - modules/surf/close_test.go
+ - modules/surf/assemble_router_test.go
+ - modules/surf/assemble_router_mcp_test.go
+ - modules/surf/example_test.go
+ - modules/surf/pier_on.go
+ - modules/surf/README.md
+ - modules/pier/pier.go
+ - modules/pier/README.md
+ - docs/services/rate-limiting.md
+ - docs/services/routing.md
+ - docs/plugins/testing.md
+ - .planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/deferred-items.md
+autonomous: true
+requirements:
+ - QUICK-261118-lbt
+
+estimate:
+ tokens: 110000
+ raw_tokens: 110000
+ tasks: 3
+ confidence: low
+
+must_haves:
+ truths:
+ - "Two applications activated through the public party.Activate in one process, from the same registered plugin set, each get their own instance of every pointer-to-struct plugin: the app a plugin stores in Register/Boot is that application's, a capability method reads its own application's config, constant fields from the registered literal (such as id) carry over, and the value passed to party.Register is never handed to any application. Activating the two apps from two goroutines passes under -race"
+ - "A non-pointer (value) plugin and a pointer to a non-struct type are used as is on every application, exactly as today"
+ - "party.RegisterFactory(id, fn) calls fn once per Activate, so each application gets the plugin fn returns; a nil fn is ignored like party.Register(nil); a nil result or a plugin whose ID differs from id fails Activate with an error naming the id (and the returned ID); every existing activate() test in modules/party/registry_test.go passes unchanged"
+ - "surf.MemoryStore.Close stops the sweep goroutine: a second Close returns nil, Close on a nil store or a store built with sweep <= 0 returns nil, and Attempt keeps counting after Close"
+ - "surf.Router.Close releases only what the router itself created (the fallback MemoryStore of BuildRouter, the MCP endpoint reaper the router mounted) and never a surf.Store published on the app; it is idempotent and nil-safe; BuildRouter and AssembleRouter close it on every error return; serve closes the router and installCooler's fallback MemoryStore on shutdown, route:list closes its router; building 20 routers raises runtime.NumGoroutine by at least 20 and closing them brings it back to the baseline (+2) within 2 seconds"
+ - "surf.AssembleRouter(app, plugins) returns (*surf.Router, http.Handler, error) from a single build: Routes, AdminPrefix and the served handler come from the same router, and an mcp.enabled app (summercms_mcp build) gets its route table, admin prefix and handler without a second pier publish; surf.Assemble keeps its signature and is implemented on top of AssembleRouter"
+ - "No plugin needs a change: no exported identifier is removed and no existing interface gains a method (party.Plugin, surf.Store and every pact interface are unchanged), go.mod/go.sum are unchanged, examples/hello passes, and scripts/check-phase35.sh --consumers (sm-user-plugin, sm-paymentgateway-plugin against this checkout) and PHASE35_BASE_TAG=v0.6.5 scripts/check-phase35.sh --additive pass"
+ - "modules/party, modules/surf and modules/pier READMEs plus docs/plugins/registration.md, docs/architecture/application-lifecycle.md, docs/services/rate-limiting.md, docs/services/routing.md and docs/plugins/testing.md describe per-application instances (per-app state on the struct, never in package variables), party.RegisterFactory, MemoryStore/Router Close and AssembleRouter, in the same commit as the code; go test ./cmd/summer -run TestDocsTree and go run ./cmd/summer docs:build --check pass"
+ artifacts:
+ - path: modules/party/registry.go
+ provides: "registration entries with a pristine copy taken at Register time, RegisterFactory, and a snapshot that returns fresh per-Activate instances (reflect shallow copy) or a factory error; activate() unchanged"
+ - path: modules/party/instances_test.go
+ provides: "withRegistry swap helper, TestActivatePerAppInstances (two apps, own config, constant fields, original untouched, value and non-struct pointer used as is, parallel activation) and TestRegisterFactory (per-Activate calls, nil fn, nil result, ID mismatch)"
+ - path: modules/surf/limiter_store.go
+ provides: "MemoryStore.Close (sync.Once over stop), unexported done channel closed when the sweep loop returns"
+ - path: modules/surf/router.go
+ provides: "Router.Close with owned closers (LIFO, errors.Join, sync.Once), BuildRouter registers the fallback store it created and closes the router on error, AssembleRouter, Assemble on top of it"
+ - path: modules/surf/serve.go
+ provides: "serve builds with AssembleRouter, defers Router.Close and closes installCooler's fallback MemoryStore"
+ - path: modules/surf/pier_on.go
+ provides: "after pier.Mount succeeds the router owns the mounted *pier.Pier's Close"
+ - path: modules/pier/pier.go
+ provides: "Pier.Close stops the session reaper and the Redis warm-up Mount started; stopReap comment updated"
+ - path: modules/surf/close_test.go
+ provides: "TestMemoryStoreClose, TestRouterCloseOwnedStore, TestRouterCloseKeepsPublishedStore, TestRouterCloseReleasesGoroutines"
+ - path: modules/surf/assemble_router_test.go
+ provides: "TestAssembleRouterOneBuild (untagged) and ExampleAssembleRouter lives in example_test.go"
+ - path: modules/surf/assemble_router_mcp_test.go
+ provides: "//go:build summercms_mcp: TestAssembleRouterMCPOneBuild and TestRouterCloseStopsPierReaper"
+ - path: .planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/deferred-items.md
+ provides: "findings of the process-wide state audit (activation path, lagoon encryption keys, diary, warn-once caches) and what was deferred"
+ key_links:
+ - from: "party.Activate"
+ to: "party.activate"
+ via: "snapshot() now returns fresh instances (and an error from a bad factory); activate's signature and semantics are unchanged"
+ pattern: "snapshot\\(\\)"
+ - from: "surf.BuildRouter fallback branch"
+ to: "Router.Close"
+ via: "r.own(store.Close) only when no surf.Store is published on the app"
+ pattern: "NewMemoryStore\\(2 \\* time.Minute\\)"
+ - from: "pier_on.go mountPier"
+ to: "pier.Pier.Close"
+ via: "app.Lookup[*pier.Pier]() after a successful pier.Mount, then r.own(p.Close)"
+ pattern: "pier.Mount"
+ - from: "surf.ServeCommand"
+ to: "surf.AssembleRouter + Router.Close"
+ via: "one build, deferred Close; installCooler's fallback store closed on exit"
+ pattern: "AssembleRouter\\("
+---
+
+
+Fix three framework issues a downstream application reported (its notes file: /media/nvme/dev/pxpx/sm-servers-app/.planning/notes/2026-11-18-upstream-test-isolation-and-limiter-leak.md) so an application can boot several applications in one test process and run full-boot tests with t.Parallel(), with no change to any existing plugin.
+
+1. party: plugin instances are process-wide today. `Register` appends the pointer a plugin passes from init (registry.go:35) and `Activate` hands the same pointers to every application (snapshot(), registry.go:44), so a second application rebinds the first one's plugins (`p.app = app` in Register/Boot). LOCKED decision (explore session with the user): the public Activate path gives EVERY application, including the first, a fresh shallow copy of each pointer-to-struct plugin. The copy comes from a pristine copy taken at Register time, so writes in Register/Boot go to a per-app struct and constant literal fields carry over. Non-pointer value plugins are used as is. `party.RegisterFactory(id, fn)` is the escape hatch for plugins whose init sets up shared maps or pointers. The internal `activate()` that registry_test.go drives with its own instances keeps its semantics. Planner evidence: every `party.Register` call in the framework, the apps and the sibling sm-*-plugin repos passes a fresh literal (84x `&Plugin{}`, value types such as `acmeServers{}`, a few with constant fields such as `&graderPlugin{id: "acme.gradersone"}`). None registers a variable it reads later, no sibling plugin keeps a package-level `*backpack.App`, and commands read instances through `app.Lookup[party.Activated]()`.
+2. surf: `NewMemoryStore` (limiter_store.go:32) starts a sweep goroutine nothing stops; `BuildRouter` (router.go:565) and `installCooler` (serve.go:237) create one per build. Add `MemoryStore.Close` and make the router own and close what it created.
+3. surf: a harness that needs both the route table (BuildRouter) and the handler (Assemble) builds twice; with mcp.enabled, pier publishes `*pier.Pier` once per app (pier.go:140), so the second build fails. Add one-build `AssembleRouter`, keep `Assemble`'s signature. The MCP endpoint's reaper goroutine (pier.go:145) is the same leak as item 2 for MCP apps, so the router that mounted pier also stops it on Close (small; planner-verified: the memory session store starts no other long-lived goroutine).
+
+Purpose: an application's test suite stops being serial on boot cost, and its test binaries stop accumulating ticker goroutines. Core plugins are used in many projects, so this is strictly additive.
+
+Output: three code+docs commits (party; surf Close; surf AssembleRouter + pier Close) and deferred-items.md with the process-wide-state audit. Planner's choices (discretion): the name `AssembleRouter`, a pointer to a non-struct type used as is, factories called for every registration on each Activate, and errors.Join for Router.Close.
+
+
+
+@~/.claude/msd-core/workflows/execute-plan.md
+@~/.claude/msd-core/templates/summary.md
+
+
+
+@CLAUDE.md
+@.planning/STATE.md
+@/media/nvme/dev/pxpx/sm-servers-app/.planning/notes/2026-11-18-upstream-test-isolation-and-limiter-leak.md
+@modules/party/registry.go
+@modules/party/README.md
+@modules/surf/limiter_store.go
+@modules/surf/README.md
+
+Interfaces and line anchors (planner read them at HEAD 4d3b1e9f; read each once, do not re-derive):
+- party (registry.go): package vars `mu sync.Mutex`, `plugins []Plugin` (:28-31); `func Register(p Plugin)` (:35, nil is a no-op); `func snapshot() []Plugin` (:44), the only reader of `plugins`; `func Activate(app *backpack.App, ids []string) ([]Plugin, error)` (:54) calls `activate(snapshot(), app, ids)`; `func activate(registered []Plugin, app, ids)` (:61) builds byID over ALL registered plugins (duplicate-ID detection), then Register/phrasebook/postcard/signpost/Boot for the selected ones. Do not change activate.
+- party tests: registry_test.go is package party and drives activate() directly; its configPlugin test (:60) shows how to build an app with config: write `app.yaml` into t.TempDir(), `compass.Load(dir)`, `backpack.New(cfg)`. `app.yaml` with `name: one` is readable as `app.Config.String("app.name")`. No party test calls t.Parallel.
+- surf (limiter_store.go): `type MemoryStore struct { mu; entries; sweep; stop chan struct{} }`; `NewMemoryStore(sweep)` starts `go s.loop()` only when sweep > 0; loop returns on `<-s.stop`. `surf.Store` is the interface `Attempt(key, max, decay)`. Do NOT add Close to `surf.Store` (that would break every external Store implementation).
+- surf (router.go): `type Router struct` (:63); `New(origins)` (:105); `func (r *Router) compile() (http.Handler, error)` (:394); `Assemble` (:537) = BuildRouter + compile; `BuildRouter` (:547): store lookup `app.Lookup[Store]()` (:559) else `NewMemoryStore(2 * time.Minute)` (:565), limiter at `r.limiter` (`r.limiter.store` is the store, used by store_lookup_test.go); cabana.Activate, then the mountPier hook (:660-ish), compileHandlers, addCORSPreflights. `mountPier` var (:60) is set by pier_on.go (build tag summercms_mcp) and nil in pier_off.go.
+- surf (routetable.go): `(*Router).AdminPrefix() (string, bool)`, `Routes() []RouteInfo`, `Handler(method, pattern) (http.Handler, bool)`; the name Handler is taken, so the one-build API is a function, not a method.
+- surf (serve.go): Run does `BuildRouter` then `r.compile()` (:85-92) after `installCooler` (:230): with `h.RateLimitRedis()` it wraps `NewMemoryStore(2 * time.Minute)` in `h.RateLimitStore(...)` and publishes that wrapper as `surf.Store` and `cooler.Attempter` (cabana's test-send limit uses it). The fallback is created by serve, not published by a third party, so serve closes it.
+- surf (routelist_command.go:44): `r, err := BuildRouter(app, plugins)` then reads `r.Routes()`.
+- surf tests (package surf, no t.Parallel anywhere): `transportApp(t, env, files map[string]string)`, `transportBodyLimits`, `assemblePlugin{id, path, use}` and `countingStore` (store_lookup_test.go), `dispatchPlugin{}` and the tagged path of `TestPierMount` (pier_mount_test.go: files with `http.yaml`, `app.yaml` "name: mount-test\nurl: http://acme.test\n" and `mcp.yaml` "enabled: true\n"); `BlogPlugin` and `ExampleAssemble`/`ExampleBuildRouter` (example_test.go:132/175).
+- pier (pier.go): `stopReap context.CancelFunc` (:63-67, comment says backpack has no shutdown hook yet); Mount publishes `*Pier` (:140), then starts `go p.sessions.reap(reapCtx, ...)` and, for a Redis store, `go ls.warm(reapCtx)`. export_test.go:65 has a test-only `StopReaper()`; leave it.
+- backpack.App has no shutdown hook (planner checked); this plan adds none. Router.Close is the minimal owner.
+- Docs tooling: `go run ./cmd/summer docs:build --check` (identifiers, links, src= snippets), `go run ./cmd/summer docs:sync` (refreshes src= copies), `go test ./cmd/summer -run TestDocsTree`. Every Go code block in docs/ must be an src= copy of an Example function.
+
+
+
+
+
+ Task 1: Every application gets its own plugin instances (party), with RegisterFactory
+ modules/party/registry.go, modules/party/instances_test.go, modules/party/README.md, docs/plugins/registration.md, docs/architecture/application-lifecycle.md, .planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/deferred-items.md
+
+ - Two apps (configs app.name "one" and "two") activated through the public Activate from one registered `&scopedPlugin{id: "acme.scoped", label: "fixed"}`: each app's Activated holds a distinct *scopedPlugin, each instance's stored app is its own app, a capability method returns "one" and "two" respectively, label "fixed" carried over to both, Register and Boot each ran once per instance, and the original pointer passed to Register still has a nil app and zero boot count
+ - The same two activations run from two goroutines at once pass under -race (subtest)
+ - A registered value plugin (`valuePlugin{id: "acme.value"}`) appears unchanged (==) on both apps; a pointer to a non-struct type (`type countPlugin int`, registered as new(countPlugin)) is the same pointer on both apps
+ - RegisterFactory("acme.made", fn) with fn returning `&scopedPlugin{id: "acme.made"}`: fn ran exactly twice after two Activates and the instances differ; RegisterFactory("acme.none", nil) leaves the registry length unchanged; a factory returning nil fails Activate with an error containing `factory for "acme.nil" returned nil`; a factory returning ID "acme.other" for "acme.wrong" fails with an error naming both IDs
+ - Every existing test in registry_test.go, info_test.go and the examples passes unchanged
+
+
+RED first: write modules/party/instances_test.go (package party) for the behaviours above. Add a `withRegistry(t)` helper that takes mu, saves the package registry, empties it and restores it in t.Cleanup. Use test-only plugin types that have fields; a zero-size struct can share one address across allocations. Run the tests and see them fail (RegisterFactory is undefined and instances are shared).
+
+GREEN in registry.go, per the locked decision:
+- Replace `plugins []Plugin` with a slice of unexported registration entries. Each entry holds either a pristine plugin plus a copyable flag, or a factory id plus a `func() Plugin`.
+- `Register(p)`: keep the nil no-op. When reflect.ValueOf(p) is a non-nil pointer whose Elem kind is Struct, store a pristine copy: reflect.New(elem type), then .Elem().Set(the registered value's Elem()). This copies unexported fields too, because only the whole struct is set. Mark the entry copyable and never hand the pristine value out. Anything else (value types, pointers to non-structs, typed nil pointers) is stored and used as is.
+- Add `func RegisterFactory(id string, fn func() Plugin)`. A nil fn is a no-op. Doc comment: fn is called on every Activate, for plugins whose init builds maps or pointers that must not be shared between applications.
+- Change `snapshot()` to return ([]Plugin, error). Copy the entries under mu and release the lock before calling any factory. For each entry, in registration order: a copyable entry gives a fresh reflect.New copy of the pristine value; a factory entry gives fn(); an as-is entry gives the stored plugin. Factory failures are `party: factory for %q returned nil` and `party: factory for %q returned plugin %q`. Every registration produces its instance on each call, even when the manifest does not select it, so activate's duplicate-ID check sees the same set as today.
+- `Activate` returns the snapshot error, otherwise calls activate(instances, app, ids) unchanged.
+- Update the comments on Register, Activate and Activated. The rule is that a plugin keeps per-application state on its struct, never in package variables. A constant field set in the literal is copied shallowly, so a map or pointer set there is shared by every application; use RegisterFactory for those.
+
+Docs in the same commit (CLAUDE.md documentation rules):
+- modules/party/README.md: Overview and Features say each application gets its own instances. Add a short "Per-application instances" paragraph to Usage that states the rule and mentions party.RegisterFactory. API table: update the party.Register and party.Activate rows and add a party.RegisterFactory row. Add `reflect` to the Dependencies standard library list.
+- docs/plugins/registration.md, section "The plugin type": add a paragraph with the same rule and the factory escape hatch. Use prose only, because a new Go block would need an src= Example.
+- docs/architecture/application-lifecycle.md line ~40 ("Nothing in it is process-global, so two applications in one test do not share state"): add that party.Activate gives each application its own plugin instances, so plugin state is not shared either.
+
+Process-wide state audit (record findings; fix nothing here): write deferred-items.md in the quick directory. Check and record these:
+- phrasebook.Activate, postcard.Activate, postcard.BootPlugin and signpost.Activate publish app-scoped values. Their package vars are read-only (embedded FS, regexps, sync.Once-cached static brand CSS and preview sample).
+- cabana `missingHashes` (auth.go:536) and lagoon `droppedKeys` (fill.go:26) are per-cost and warn-once caches, safe to share.
+- DEFERRED: lagoon column-encryption keys are package-level (`currentKeys`, encrypted.go:111, set by lagoon.PublishEncryptionKeys from OpenFromApp). Two applications with different keys in one process share the last one installed. The fix is not small, because Encrypted Scan/Value have no app handle.
+- diary: check whether logging configuration is process-wide and record the result.
+- pier: per-app publish, handled by Tasks 2 and 3.
+deferred-items.md is a planning doc: do not stage it in the code commit.
+
+Commit by explicit paths, without Co-Authored-By (user rule): `feat(party): give every application its own plugin instances (quick-261118-lbt)`. Do not touch examples/hello/plugins.gen.go (another session's edit), .planning/state.json or G15OFFICE.md.
+
+
+ cd /media/nvme/dev/golem15/summercms.io/summercms/summercms.go && go vet ./modules/party/... && go test -short -count=1 ./modules/party/... && go test -race -short -count=1 ./modules/party/... && test "$(go test -short -count=1 -v ./modules/party -run 'TestActivatePerAppInstances|TestRegisterFactory' | grep -cE -- '--- PASS: Test(ActivatePerAppInstances|RegisterFactory) ')" -ge 2 && (cd examples/hello && go test -short -count=1 ./...) && go test -count=1 ./cmd/summer -run TestDocsTree && go run ./cmd/summer docs:build --check && grep -q 'party.RegisterFactory' modules/party/README.md && grep -q 'party.RegisterFactory' docs/plugins/registration.md && test -s .planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/deferred-items.md && git diff --quiet -- go.mod go.sum
+
+ Two apps booted through party.Activate in one process no longer share plugin structs; RegisterFactory exists and is tested; activate() and its tests are unchanged; examples/hello (several Activates per process) passes; docs and README are in the code commit; deferred-items.md records the audit.
+
+
+
+ Task 2: The router closes the rate-limit store it created (MemoryStore.Close, Router.Close)
+ modules/surf/limiter_store.go, modules/surf/router.go, modules/surf/serve.go, modules/surf/routelist_command.go, modules/surf/close_test.go, modules/surf/README.md, docs/services/rate-limiting.md
+
+ - TestMemoryStoreClose: NewMemoryStore(time.Millisecond).Close() returns nil and the sweep loop exits (unexported done channel closes within 2s); a second Close returns nil; Close on a nil *MemoryStore, on NewMemoryStore(0) and on a zero-value MemoryStore{} returns nil without panicking; Attempt still admits and counts after Close
+ - TestRouterCloseOwnedStore: BuildRouter(nil, nil) and BuildRouter(transportApp(...), nil) fall back to a *MemoryStore; after r.Close() its done channel is closed; a second r.Close() returns nil; (*Router)(nil).Close() and New(nil).Close() return nil
+ - TestRouterCloseKeepsPublishedStore: a NewMemoryStore(time.Millisecond) published as surf.Store on the app is used by BuildRouter, and after r.Close() its done channel is NOT closed (the test closes it in t.Cleanup)
+ - TestRouterCloseReleasesGoroutines: baseline runtime.NumGoroutine(); building 20 routers with BuildRouter(nil, nil) raises it by at least 20; closing all 20 brings it back to at most baseline+2 within 2s (poll every 10ms)
+ - Existing surf tests (store_lookup_test.go, serve_lifecycle_test.go, transport and pier mount tests) pass unchanged, untagged and with -tags summercms_mcp
+
+
+RED: write modules/surf/close_test.go (package surf) for the behaviours above. It may read r.limiter.store and the store's unexported done channel. Use no new dependency: goleak is not in the decided stack, so poll runtime.NumGoroutine. Run it and see it fail.
+
+GREEN:
+- limiter_store.go: add `closeOnce sync.Once` and `done chan struct{}` to MemoryStore. NewMemoryStore creates done. With sweep > 0, loop closes done when it returns (defer). With sweep <= 0, done is closed at once, because there is no goroutine. Add `func (s *MemoryStore) Close() error`. It is nil-safe, does nothing when stop is nil (zero value), closes stop through closeOnce and always returns nil. Doc comment: Close stops the background sweep only; Attempt keeps working (expiry is lazy), so a handler serving after Close is safe.
+- router.go: add unexported fields `closers []func() error`, `closeOnce sync.Once` and `closeErr error` to Router. Add unexported `func (r *Router) own(fn func() error)`, which appends. Add exported `func (r *Router) Close() error`. It is nil-safe, runs the closers once in reverse registration order and returns errors.Join of their errors; later calls return the same result. Doc comment: Close releases only what the router created itself, never a surf.Store or anything else published on the app; the compiled handler keeps serving after Close.
+- In BuildRouter, call `r.own(store.Close)` only in the fallback branch that calls NewMemoryStore. Split the body after `r := New(...)` into an unexported helper, so that every error return after the store exists closes the router: BuildRouter calls the helper and, on error, calls r.Close() and returns nil plus the error.
+- serve.go: right after BuildRouter succeeds, `defer r.Close()`; this also covers a failing compile. Change installCooler to also return the fallback *MemoryStore it created (nil when Redis is off). Close that store on installCooler's own error returns after creating it. serve defers its Close next to `defer coolerHandle.Close()`; Close is nil-safe.
+- routelist_command.go: `defer r.Close()` after BuildRouter succeeds.
+- Do not add Close to the surf.Store interface. Do not change cooler.
+
+Docs in the same commit:
+- modules/surf/README.md: in the rate-limiting Features bullet, say that the router owns and closes the fallback MemoryStore. API table: add rows for surf.MemoryStore (in-process Store; Close stops its sweep) and surf.Router.Close. Testing section: one line on the close tests.
+- docs/services/rate-limiting.md line ~61, where route:list and surf.Assemble use the memory store: add that surf.Router.Close stops that store's background sweep and that a published store is never closed by the router.
+
+Commit by explicit paths, without Co-Authored-By: `fix(surf): close the rate-limit store a router created (quick-261118-lbt)`.
+
+
+ cd /media/nvme/dev/golem15/summercms.io/summercms/summercms.go && go vet ./modules/surf/... && go vet -tags summercms_mcp ./modules/surf/... && go test -short -count=1 ./modules/surf/... && go test -short -count=1 -tags summercms_mcp ./modules/surf/... && test "$(go test -short -count=1 -v ./modules/surf -run 'TestMemoryStoreClose|TestRouterClose' | grep -cE -- '--- PASS: Test(MemoryStoreClose|RouterClose(OwnedStore|KeepsPublishedStore|ReleasesGoroutines)) ')" -ge 4 && go test -count=1 ./cmd/summer -run TestDocsTree && go run ./cmd/summer docs:build --check && grep -q 'surf.Router.Close' modules/surf/README.md && grep -q 'surf.Router.Close' docs/services/rate-limiting.md && git diff --quiet -- go.mod go.sum
+
+ MemoryStore.Close and Router.Close exist and are tested. BuildRouter, serve (router and Redis fallback) and route:list release the stores they created, and a published store is never closed. The goroutine count returns to baseline after closing 20 routers, and the README and rate-limiting docs are in the code commit.
+
+
+
+ Task 3: One build for router and handler (AssembleRouter); the router also stops the MCP endpoint it mounted
+ modules/surf/router.go, modules/surf/serve.go, modules/surf/pier_on.go, modules/pier/pier.go, modules/surf/assemble_router_test.go, modules/surf/assemble_router_mcp_test.go, modules/surf/example_test.go, modules/surf/README.md, modules/pier/README.md, docs/services/routing.md, docs/plugins/testing.md
+
+ - TestAssembleRouterOneBuild (untagged): AssembleRouter(app, []party.Plugin{assemblePlugin{id: "golem15.demo", path: "/ping", use: []string{"throttle:2,1"}}}) returns a router whose Routes() lists GET /api/ping and a handler that answers 200, 200, 429, so the handler and the router share one limiter and store; r.Close() closes that store (done channel); with a bad plugin (an unknown middleware name) it returns a nil router and an error, and its fallback store is closed (goroutine count back to baseline)
+ - Assemble still returns (http.Handler, error) and every existing Assemble test passes
+ - ExampleAssembleRouter (example_test.go) prints the route count and one request's status through the returned handler, with an // Output: block
+ - TestAssembleRouterMCPOneBuild (//go:build summercms_mcp): one AssembleRouter call on an mcp.enabled app (the files TestPierMount's tagged path uses, dispatchPlugin{}) succeeds; Routes() includes POST/GET/DELETE at /mcp; AdminPrefix() is readable from the same router; app.Lookup[*pier.Pier]() is set
+ - TestRouterCloseStopsPierReaper (tagged): building 5 mcp.enabled routers through AssembleRouter, each on its own app, raises runtime.NumGoroutine by at least 5; closing them returns it to at most baseline+2 within 2s; pier.Pier.Close is nil-safe and a second call returns nil
+
+
+RED: write modules/surf/assemble_router_test.go (untagged) and modules/surf/assemble_router_mcp_test.go (first line `//go:build summercms_mcp`, package surf) for the behaviours above. Run the untagged suite and the -tags summercms_mcp suite and see the new tests fail.
+
+GREEN:
+- router.go: add `func AssembleRouter(app *backpack.App, plugins []party.Plugin) (*Router, http.Handler, error)`. It calls BuildRouter once, then r.compile(). On a compile error it calls r.Close() and returns nil, nil and the error. Doc comment: one build gives both the route table (Routes, AdminPrefix, Handler) and the handler serve uses; MCP publishes its endpoint once per app, so a caller needing both must not build twice; the caller owns the router and calls Close when the app stops. Reimplement `Assemble` as AssembleRouter that drops the router, keeping its exact signature. Its comment says the dropped router's fallback store is never closed, so code that builds many routers (tests) uses AssembleRouter and Close. Update the BuildRouter comment to point at AssembleRouter.
+- serve.go: replace the BuildRouter + r.compile() pair with AssembleRouter and keep `defer r.Close()` right after it succeeds.
+- modules/pier/pier.go: add exported `func (p *Pier) Close() error`. It is nil-safe, calls stopReap when it is set (a CancelFunc, so repeated calls are fine) and returns nil. Doc comment: it stops the session reaper and the Redis store warm-up Mount started; it does not end connected sessions, which serve's HTTP drain handles. Rewrite the stopReap field comment: the router that mounted the endpoint calls Close; backpack still has no shutdown hook.
+- pier_on.go: in the mountPier closure, after pier.Mount returns nil, call app.Lookup[*pier.Pier](). If found and non-nil, call r.own(p.Close). An error later in BuildRouter then also stops the reaper through Task 2's close-on-error path. Leave the test-only StopReaper in export_test.go.
+- example_test.go: add ExampleAssembleRouter. Mirror ExampleAssemble's setup: backpack.New(nil), &BlogPlugin{}, plugin.Register(app). Defer r.Close() and print len(r.Routes()) and one GET /api/blog/posts/7 status and body. Fill // Output: from the actual run.
+
+Docs in the same commit:
+- modules/surf/README.md: change the Usage line ~118 ("tests can call surf.Assemble") to recommend surf.AssembleRouter plus defer r.Close() in tests. Add a surf.AssembleRouter row to the API table. Update the surf.Assemble row (implemented on AssembleRouter; the router is not returned, so it cannot be closed).
+- modules/pier/README.md: add a pier.Pier.Close row and mention it in the pier.Pier row.
+- docs/services/routing.md, section "Testing and listing routes": add a paragraph and a `go src=modules/surf/example_test.go#ExampleAssembleRouter` block, then run `go run ./cmd/summer docs:sync` to fill it.
+- docs/plugins/testing.md, section "Unit tests without a database": recommend surf.AssembleRouter (route table and handler from one build, defer r.Close()). Add that full-boot tests may call t.Parallel(), because party.Activate gives each application its own plugin instances, provided plugins keep per-app state on their struct. Add one caveat sentence: column-encryption keys are process-wide; the last lagoon.PublishEncryptionKeys wins.
+
+Commit by explicit paths, without Co-Authored-By: `feat(surf): AssembleRouter builds the router and handler once; the router stops the MCP endpoint it mounted (quick-261118-lbt)`.
+
+Then run the non-breaking gates in . If scripts/check-phase35.sh --consumers refuses only because a sibling plugin's working tree is dirty from another session, leave the sibling as it is. Record the refusal in the SUMMARY with the per-plugin commands the script prints, and run those by hand under the scratch modfile it describes.
+
+
+ cd /media/nvme/dev/golem15/summercms.io/summercms/summercms.go && go vet ./... && go vet -tags summercms_mcp ./modules/surf/... ./modules/pier/... && go test -short -count=1 ./... && go test -short -count=1 -tags summercms_mcp ./modules/surf/... ./modules/pier/... && test "$(go test -short -count=1 -v -tags summercms_mcp ./modules/surf -run 'TestAssembleRouter|TestRouterCloseStopsPierReaper|ExampleAssembleRouter' | grep -cE -- '--- PASS: (TestAssembleRouterOneBuild|TestAssembleRouterMCPOneBuild|TestRouterCloseStopsPierReaper|ExampleAssembleRouter) ')" -ge 4 && (cd examples/hello && go test -short -count=1 ./...) && go test -count=1 ./cmd/summer -run 'TestDocsTree|TestCommandsDocumented' && go run ./cmd/summer docs:build --check && grep -q 'surf.AssembleRouter' modules/surf/README.md && grep -q 'surf.AssembleRouter' docs/plugins/testing.md && grep -q 'ExampleAssembleRouter' docs/services/routing.md && grep -q 'pier.Pier.Close' modules/pier/README.md && git diff --quiet -- go.mod go.sum && PHASE35_BASE_TAG=v0.6.5 scripts/check-phase35.sh --additive && scripts/check-phase35.sh --consumers
+
+ A harness gets the route table, admin prefix and handler from one AssembleRouter call, including with MCP enabled. Assemble is unchanged for callers, serve uses AssembleRouter with a deferred Close, and closing an MCP router stops pier's reaper. The API is additive only, and the consumer plugins pass against this checkout. Docs and READMEs are in the code commit.
+
+
+
+
+
+## Trust Boundaries
+
+| Boundary | Description |
+|----------|-------------|
+| plugin registration (init) -> per-application activation | Compiled-in plugin values are copied per application; a wrong copy lets one application's plugin read another's config and database |
+| router -> resources published on the app | A router must release only what it built; a published store (cooler's Redis store, also cabana's Attempter) belongs to its publisher |
+| framework change -> consuming plugins and apps | Core plugins on older framework versions boot through these paths; a behaviour change breaks their start-up |
+
+## STRIDE Threat Register
+
+| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
+|-----------|----------|-----------|----------|-------------|-----------------|
+| T-lbt-01 | Information disclosure | party.Activate instance sharing | high | mitigate | Fresh reflect copy per Activate from a pristine value nobody else holds; TestActivatePerAppInstances asserts own app/config per instance, the untouched original and parallel activation under -race |
+| T-lbt-02 | Denial of service (breaking change) | party.Register copy semantics | high | mitigate | Planner grep: every Register call passes a fresh literal and no plugin keeps a package-level app; shallow copy keeps constant fields; value and non-struct pointer plugins used as is; RegisterFactory escape hatch; examples/hello, the full -short suite, check-phase35 --consumers and --additive (no removed export, no interface method added) |
+| T-lbt-03 | Denial of service | MemoryStore sweep and pier reaper goroutines | medium | mitigate | MemoryStore.Close, Router.Close owning the fallback store and the mounted Pier.Close, close-on-error in BuildRouter/AssembleRouter, serve/route:list defers; goroutine-count tests untagged and tagged |
+| T-lbt-04 | Tampering | Router.Close vs a published surf.Store | medium | mitigate | own() is called only in the NewMemoryStore fallback branch; TestRouterCloseKeepsPublishedStore asserts a published store keeps sweeping; installCooler's fallback is closed by serve, its creator |
+| T-lbt-05 | Denial of service | requests served after Close | low | mitigate | Close stops only background work; Attempt works after Close (TestMemoryStoreClose); the compiled handler keeps serving |
+| T-lbt-06 | Information disclosure | lagoon column-encryption keys (process-wide) | low | accept | Out of the activation path and not small; recorded in deferred-items.md and in docs/plugins/testing.md (last PublishEncryptionKeys wins); test apps normally share one key |
+| T-lbt-SC | Tampering | Go module installs | low | accept | No dependency added (goleak deliberately not used); gate git diff --quiet -- go.mod go.sum |
+
+
+
+- go vet ./... (untagged) and go vet -tags summercms_mcp ./modules/surf/... ./modules/pier/... are clean; go test -short ./... is green; the tagged surf/pier -short suites are green; go test -race -short ./modules/party/... is green.
+- New tests pass by name: TestActivatePerAppInstances, TestRegisterFactory, TestMemoryStoreClose, TestRouterCloseOwnedStore, TestRouterCloseKeepsPublishedStore, TestRouterCloseReleasesGoroutines, TestAssembleRouterOneBuild, ExampleAssembleRouter, and with the tag TestAssembleRouterMCPOneBuild and TestRouterCloseStopsPierReaper.
+- cd examples/hello && go test -short ./... passes (several Activates in one process).
+- go test ./cmd/summer -run 'TestDocsTree|TestCommandsDocumented' and go run ./cmd/summer docs:build --check pass.
+- PHASE35_BASE_TAG=v0.6.5 scripts/check-phase35.sh --additive passes; scripts/check-phase35.sh --consumers passes, or its dirty-sibling refusal is recorded with hand-run results.
+- With Docker available, go test ./... (no -short) passes; if the socket is denied, rerun through sudo -u golem; otherwise record NOT RUN.
+- git diff --quiet -- go.mod go.sum; no tag, no push.
+
+
+
+- A downstream test binary can boot several applications concurrently: each has its own plugin structs, the routers it builds can be closed, and no ticker goroutines pile up.
+- A harness builds one router per test and reads routes, the admin prefix and the handler from it, MCP included.
+- Existing plugins and apps compile and behave identically, with no plugin repository change; the API surface only gains identifiers.
+- READMEs and docs ship in each code commit; deferred-items.md lists the process-wide state that remains.
+
+
+
diff --git a/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-SUMMARY.md b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-SUMMARY.md
new file mode 100644
index 00000000..7bd2b6ed
--- /dev/null
+++ b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-SUMMARY.md
@@ -0,0 +1,128 @@
+---
+phase: quick-261118-lbt
+plan: 01
+subsystem: party, surf, pier
+tags: [plugins, test-isolation, rate-limiting, goroutine-leak, mcp]
+status: complete
+requires: []
+provides:
+ - party.RegisterFactory
+ - per-application plugin instances in party.Activate
+ - surf.MemoryStore.Close
+ - surf.Router.Close
+ - surf.AssembleRouter
+ - pier.Pier.Close
+affects: [every application booting through party.Activate, surf serve and route:list, MCP-enabled apps]
+tech-stack:
+ added: []
+ patterns:
+ - "reflect shallow copy of a pristine plugin value per Activate"
+ - "router owns and closes (LIFO, errors.Join, sync.Once) only what it created"
+key-files:
+ created:
+ - modules/party/instances_test.go
+ - modules/surf/close_test.go
+ - modules/surf/assemble_router_test.go
+ - modules/surf/assemble_router_mcp_test.go
+ modified:
+ - modules/party/registry.go
+ - modules/party/README.md
+ - modules/surf/limiter_store.go
+ - modules/surf/router.go
+ - modules/surf/serve.go
+ - modules/surf/routelist_command.go
+ - modules/surf/pier_on.go
+ - modules/surf/example_test.go
+ - modules/surf/store_lookup_test.go
+ - modules/surf/README.md
+ - modules/pier/pier.go
+ - modules/pier/README.md
+ - docs/plugins/registration.md
+ - docs/architecture/application-lifecycle.md
+ - docs/services/rate-limiting.md
+ - docs/services/routing.md
+ - docs/plugins/testing.md
+decisions:
+ - "party.Activate gives every application (the first included) a fresh shallow copy of each pointer-to-struct plugin, copied from a pristine value taken at Register time; value plugins and pointers to non-struct types are used as is"
+ - "party.RegisterFactory(id, fn) calls fn once per Activate for every factory registration, selected or not, so the duplicate-ID check sees the same set as before"
+ - "surf.Router.Close releases only what the router created (fallback MemoryStore, mounted pier.Pier); a surf.Store published on the app is never closed by it; surf.Store gains no method"
+ - "surf.AssembleRouter is a function returning (*Router, http.Handler, error); surf.Assemble keeps its signature on top of it"
+metrics:
+ duration: ~45min
+ completed: 2026-11-18
+actuals:
+ tokens: 16600
+ tasks: 3
+ commits: 3
+plan_head_before: 4d3b1e9f62965c328ea354713269c86886608bf9
+plan_head_after: 38f7f3a7
+---
+
+# Quick 261118-lbt: per-application plugin instances, closable limiter store, one-build AssembleRouter
+
+party.Activate now hands every application its own reflect-copied plugin structs (plus a party.RegisterFactory escape hatch), routers close the in-process rate-limit store and the MCP reaper they created, and surf.AssembleRouter returns route table and handler from one build.
+
+## Commits
+
+| Task | Commit | Message |
+|------|--------|---------|
+| 1 | ea1befdd | feat(party): give every application its own plugin instances (quick-261118-lbt) |
+| 2 | d9e21ad0 | fix(surf): close the rate-limit store a router created (quick-261118-lbt) |
+| 3 | 38f7f3a7 | feat(surf): AssembleRouter builds the router and handler once; the router stops the MCP endpoint it mounted (quick-261118-lbt) |
+
+## Rule for plugin authors (verbatim from the party README)
+
+> Each application gets its own plugin instances: `party.Activate` gives every application a fresh shallow copy of the struct passed to `party.Register`, and the registered value itself is never handed out. A plugin keeps per-application state on its struct, never in package variables. Fields set in the registered literal carry over to every copy, so a map or pointer set there is shared by all applications; a plugin whose `init` builds maps or pointers registers a constructor with `party.RegisterFactory` instead, which runs once per `party.Activate`. A plugin that is not a pointer to a struct is used as is.
+
+## What was built
+
+- **party** (`modules/party/registry.go`): the registry holds `registration` entries (pristine copy + copyable flag, as-is plugin, or factory). `snapshot()` now returns `([]Plugin, error)`, copying entries under the lock and calling factories outside it. `Activate` returns the factory error, otherwise calls the unchanged `activate()`. Factory errors: `party: factory for %q returned nil` and `party: factory for %q returned plugin %q`.
+- **surf Close** (`limiter_store.go`, `router.go`, `serve.go`, `routelist_command.go`): `MemoryStore.Close` (sync.Once over stop, `done` closed when the loop returns, or at once without a sweep). `Router.own` / `Router.Close` (reverse order, errors.Join, once). BuildRouter's body moved into `(*Router).build`; `BuildRouter` closes the router on any error. The fallback store is owned only in the `NewMemoryStore` branch. serve defers `r.Close()` and closes `installCooler`'s fallback store (installCooler now also returns it); route:list defers `r.Close()`.
+- **AssembleRouter + pier Close** (`router.go`, `serve.go`, `pier_on.go`, `pier.go`): `AssembleRouter` = BuildRouter + compile, closing on a compile error. `Assemble` is AssembleRouter without the router. serve uses AssembleRouter. `pier.Pier.Close` calls `stopReap`; `pier_on.go` makes the router own the mounted `*pier.Pier`'s Close after a successful `pier.Mount`. `ExampleAssembleRouter` added and synced into `docs/services/routing.md`.
+
+## Verification results
+
+- `go vet ./...`: clean. `go vet -tags summercms_mcp ./modules/surf/... ./modules/pier/...`: clean.
+- `go test -short -count=1 ./...`: all packages ok.
+- `go test -short -count=1 -tags summercms_mcp ./modules/surf/... ./modules/pier/...`: ok.
+- `go test -race -short -count=1 ./modules/party/... ./modules/surf/...`: ok.
+- New tests pass by name: TestActivatePerAppInstances (incl. parallel subtest), TestRegisterFactory, TestMemoryStoreClose, TestRouterCloseOwnedStore, TestRouterCloseKeepsPublishedStore, TestRouterCloseReleasesGoroutines, TestAssembleRouterOneBuild, ExampleAssembleRouter; tagged TestAssembleRouterMCPOneBuild, TestRouterCloseStopsPierReaper.
+- `cd examples/hello && go test -short -count=1 ./...`: ok.
+- `go test ./cmd/summer -run 'TestDocsTree|TestCommandsDocumented'`: ok. `go run ./cmd/summer docs:build --check`: no problems found.
+- `PHASE35_BASE_TAG=v0.6.5 scripts/check-phase35.sh --additive`: passed (party +1, pier +1, surf +3 exported lines, nothing removed).
+- `scripts/check-phase35.sh --consumers`: passed (sm-user-plugin and sm-paymentgateway-plugin vet and tests against this checkout; both siblings clean before and after).
+- Full Docker run `go test -count=1 ./...` (Docker socket available, no sudo needed): exit 0, every package ok.
+- `git diff --quiet -- go.mod go.sum`: unchanged. No tag, no push.
+
+## Deviations from Plan
+
+### Auto-fixed Issues
+
+**1. [Rule 3 - Blocking] Updated the three internal `installCooler` test callers**
+- **Found during:** Task 2
+- **Issue:** The plan changes `installCooler` to also return the fallback MemoryStore; `modules/surf/store_lookup_test.go` called it with two return values (3 call sites), so the package did not compile.
+- **Fix:** The callers take the third value and close the fallback store in their existing t.Cleanup. No assertion changed.
+- **Files modified:** modules/surf/store_lookup_test.go
+- **Commit:** d9e21ad0
+
+**2. Deferred-items file name**
+- The plan names `deferred-items.md`; the orchestrator's constraints name `261118-lbt-deferred-items.md`. Written as `261118-lbt-deferred-items.md` and not committed (orchestrator handles the docs commit).
+
+Otherwise the plan was executed as written.
+
+## Known Stubs
+
+None.
+
+## Threat Flags
+
+None: no new endpoint, auth path or schema change. The threat register's mitigations (T-lbt-01..05) are implemented and covered by the tests listed above.
+
+## Follow-up
+
+- The downstream app can drop its throwaway MCP boot and its double router build by switching its test harness to surf.AssembleRouter plus Router.Close, and can enable t.Parallel() for full-boot tests once it requires the framework version that ships this (column-encryption keys stay process-wide, see deferred-items.md).
+
+## Self-Check: PASSED
+
+- Created files exist: modules/party/instances_test.go, modules/surf/close_test.go, modules/surf/assemble_router_test.go, modules/surf/assemble_router_mcp_test.go, 261118-lbt-deferred-items.md.
+- Commits exist: ea1befdd, d9e21ad0, 38f7f3a7.
diff --git a/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-deferred-items.md b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-deferred-items.md
new file mode 100644
index 00000000..ed2f2b72
--- /dev/null
+++ b/.planning/quick/261118-lbt-per-app-plugin-instances-closable-limite/261118-lbt-deferred-items.md
@@ -0,0 +1,35 @@
+# Quick 261118-lbt: process-wide state audit and deferred items
+
+Audit of the state shared between applications in one process, done with Task 1 (per-application plugin instances). Nothing here was changed by this quick task except where noted.
+
+## Activation path (safe)
+
+- `phrasebook.Activate`, `postcard.Activate`, `postcard.BootPlugin` and `signpost.Activate` publish app-scoped values (translator, mailer, template registry, menu item type registry) on the `backpack.App`. Their package variables are read-only or derive only from static inputs:
+ - phrasebook: embedded `systemLangFS`/`backendLangFS`, the CLDR tables `cldrNames`/`cldrOrder`, compiled regexps `pipeExact`/`pipeRange`, and `bundleCache`/`categoryCache` (`sync.Map` keyed by locale, holding locale plural data, not application translations).
+ - postcard: compiled regexps, the sanitiser attribute tables, embedded layout/partial sources, `goldmark` renderers, the `sync.Once`-cached static brand CSS template (`brandCSSOnce`) and preview sample message (`sampleOnce`), and `Migrations`.
+ - signpost: no package-level mutable state.
+- `party`: since this task, `party.Activate` hands each application a fresh shallow copy of every pointer-to-struct plugin (or a `party.RegisterFactory` result). A map or pointer set in a registered literal is still shared; that is documented and the factory is the escape hatch.
+
+## Warn-once and per-cost caches (safe to share)
+
+- cabana `missingHashes` (`modules/cabana/auth.go:536`): the unknown-login bcrypt hash per cost, a timing-equaliser value with no application data.
+- lagoon `droppedKeys` (`modules/lagoon/fill.go:26`): warn-once set for dropped fill keys; sharing it only means a second application logs the same warning once less.
+
+## Logging (diary): process-wide by design, recorded
+
+- `diary` keeps its installed setup in package state (`current atomic.Pointer[state]`, `verbosity`, `saved` default logger) and `diary.Setup`/`diary.Bootstrap` call `slog.SetDefault`. The last application to run `diary.Setup` decides channels and levels for every `diary.For` logger in the process. For several applications in one test binary this means shared log output, not shared data; tests restore the process default logger with `diary.Reset` in t.Cleanup. Not changed; a per-app logger would be a design change.
+
+## DEFERRED: lagoon column-encryption keys are process-wide
+
+- `currentKeys` (`modules/lagoon/encrypted.go:111`) is set by `lagoon.PublishEncryptionKeys` (called from `OpenFromApp`). Two applications with different keys in one process share the last one installed, so one application can encrypt with or fail to decrypt under the other's key.
+- Not fixed here: `Encrypted`'s `Scan`/`Value` (database/sql interfaces) have no application handle, so a fix needs the key carried through the GORM statement context or a per-connection serializer. Not small.
+- Mitigation for now: documented in `docs/plugins/testing.md` (the last `lagoon.PublishEncryptionKeys` wins); test applications normally share one key.
+
+## pier (MCP endpoint)
+
+- `pier.Mount` publishes `*pier.Pier` once per application and starts the session reaper (and, with Redis, a warm-up goroutine). Handled by Tasks 2 and 3: the router that mounted the endpoint owns `pier.Pier.Close`, and `surf.AssembleRouter` lets a harness read the route table and serve from one build.
+
+## Out of scope, found during execution
+
+- `gofmt -l modules` lists `modules/cabana/mail_routes.go` and `modules/postcard/store_postgres_test.go`, both committed before this task and untouched by it. Not fixed here (another session's area; cabana is shared).
+- `surf.Assemble` still drops its router, so its fallback store keeps sweeping for the life of the process. Kept for signature compatibility; documented, and callers that build many routers move to `surf.AssembleRouter` plus `surf.Router.Close`.