Skip to content

feat(licensing): merge live WCP license into FeatureFlags, refreshed pre-register - #5537

Draft
adrians5j wants to merge 3 commits into
adrian/di-native-handler-runtimefrom
adrian/licensing-feature-flags
Draft

feat(licensing): merge live WCP license into FeatureFlags, refreshed pre-register#5537
adrians5j wants to merge 3 commits into
adrian/di-native-handler-runtimefrom
adrian/licensing-feature-flags

Conversation

@adrians5j

Copy link
Copy Markdown
Member

What (Phase 3 — licensing tracer)

Makes register-time feature-flag gating valid by loading the WCP license before the per-request register phase and folding it into FeatureFlags, so api-* read only flags — never WcpContext.

Stacked on #5532 (the DI-native handler / ChildContainerFactory seam). Base = adrian/di-native-handler-runtime. Merge that first.

Changes

  • loadWcpLicense — single-flight (coalesce concurrent WCP fetches — no two at once, the self-hosted concern) + a sync getCachedWcpLicense().
  • WcpLicenseRefreshDecorator (api-event-handler-core) — a ChildContainerFactory pre-register decorator: await loadWcpLicense() before the child's register phase. Wired via a new app hook on createLambdaHandler / createServerHandler, registered by both createWebinyApiHandler (aws + server). This is the pre-child-container lifecycle hook the whole redesign was built around.
  • FeatureFlagsWithLicenseDecorator (api-core) — FeatureFlags.get() now returns the effective flags (userFlag && license.canUseX()). Runtime counterpart of @webiny/project's build-time GetFeatureFlagsWithLicense.
  • AssetDeliveryFeature (api-file-manager) — private-files gate now reads FeatureFlags.get().isPrivateFilesEnabled() (register-time, license-merged) instead of WcpContext.canUsePrivateFiles().

Why it's correct now (was the #5523 bug)

Register runs per-request in the child; the license is refreshed pre-register (module cache), so FeatureFlags.get() at register time is fresh. A license change takes effect on the next request (5-min TTL) — no redeploy — because the child re-registers each request.

Not in this slice (follow-ups)

  • Kill WcpLicenseInitializer + the RequestInitializer abstraction (pairs with WcpContext deletion once all canUse* sites migrate).
  • Add the featureFlags gql query (admin) + a merge unit test.
  • Migrate remaining WcpContext sites (Phase 4).

Verification

  • Builds green: api-core, event-handler-aws/server, api-event-handler-core/aws/server, api-file-manager.
  • Tests: api-core 171 pass, api-file-manager 33 pass (private-files gate exercised with a full license → gate opens). Full-license test seeds already populate the module cache the same way the pre-register decorator does in prod.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga

…pre-register

Phase 3 (tracer) of the licensing/feature-flags redesign. Makes register-time
feature-flag gating valid by loading the WCP license BEFORE the per-request
register phase, and folding it into FeatureFlags so api-* read only flags.

- loadWcpLicense: add single-flight (coalesce concurrent WCP fetches) + a sync
  getCachedWcpLicense() read.
- WcpLicenseRefreshDecorator (api-event-handler-core): a ChildContainerFactory
  pre-register decorator that awaits loadWcpLicense() before the child's register
  phase. Wired via the new `app` hook on createLambdaHandler/createServerHandler,
  registered by both createWebinyApiHandler (aws + server).
- FeatureFlagsWithLicenseDecorator (api-core): FeatureFlags.get() now returns the
  EFFECTIVE flags (userFlag && license.canUseX()) — the runtime counterpart of
  @webiny/project's build-time GetFeatureFlagsWithLicense.
- api-file-manager AssetDeliveryFeature: private-files gate now reads
  FeatureFlags.get().isPrivateFilesEnabled() (register-time, license-merged)
  instead of WcpContext.canUsePrivateFiles().

WcpLicenseInitializer / WcpContext stay for the not-yet-migrated canUse* sites;
RequestInitializer removal + the featureFlags gql query are follow slices.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga
@adrians5j adrians5j added the evh-cleanups event-handler DI/transport-agnostic cleanups label Aug 3, 2026
adrians5j and others added 2 commits August 4, 2026 12:36
…terApiHandlerApp

The pre-register license-refresh 'app' hook was duplicated in both
createWebinyApiHandler (aws + server). Extract to registerApiHandlerApp in
api-event-handler-core (sibling of registerApiRequestStack) — both handlers now
pass 'app: registerApiHandlerApp'. WcpLicenseRefreshDecorator becomes internal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga
…hook)

Drop the ChildContainerFactory app-decorator + registerApiHandlerApp helper —
they forced both createWebinyApiHandler (aws + server) to wire `app:`. Instead
`registerApiRequestStack` (the shared request stack both hosting types already
call) does `await loadWcpLicense()` before any feature registers, so the license
is fresh for register()-time flag checks with zero per-handler wiring.

The `app` prop on createLambdaHandler/createServerHandler/HandlerApp stays for
future transport-specific decoration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evh-cleanups event-handler DI/transport-agnostic cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant