facade: optional view-config resolver contract#71
Merged
Conversation
Add an optional wippy.facade:resolver contract.definition that lets an
application override facade requirement values (css_variables, custom_css,
app_title, ...) at request time. When no implementation is bound the config
and CSS-vars handlers fall back to the static ns.requirement defaults, so
behavior is unchanged for existing deployments.
theming_helpers gains resolve_overrides() (structural :implementations()
gate, ambient-actor open, pcall-hardened to {} on any failure) and
requirement() (override string wins over the static default). Both handlers
resolve overrides once per request and route every requirement read through
the override-aware getter.
The endpoints degrade to static on any resolver failure, so unbound and errored are indistinguishable and need no distinguishing; open() fails cleanly when nothing is bound. Removes the implementations() round-trip and the unused logger.
Contributor
Author
|
Updated the branch: dropped the Facade suite runs offline and passes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
wippy.facade:resolvercontract that lets a consuming application override facade requirement values (css_variables,custom_css,app_title,app_icon,theme_mode, …) at request time — driving the view config from runtime state (settings, per-tenant branding) instead of only staticns.requirementdefaults.Fully backward-compatible: no binding ⇒ no behavior change. With nothing bound the config and CSS-vars handlers return exactly the static-requirement output they do today.
The contract
resolver(kind: contract.definition, namespacewippy.facade) with a singleresolvemethod:{}today){ requirement_name -> override value string }. Values use the same format as the static requirement default (JSON-encoded for JSON requirements such ascss_variables); omitted keys fall back to the static default.How the handlers use it
theming_helpersgains two functions:resolve_overrides()— optionally opens a boundwippy.facade:resolverand returns its{name -> value}map, else{}.:implementations()(empty list ⇒ not bound ⇒{}). This is deliberate — the contract-open sentinel is a plainerrors.Newwith noKind, so it surfaces askind=Unknownand can't be distinguished from a real failure by kind. The binding count is the correct signal; no error-string/kind matching.:open()(nowith_actor/with_scope) so the resolver runs as the request's caller.{}= static defaults. An absent resolver is silent; a bound-but-failing one is logged.requirement(name, overrides)— prefers an override string, else the staticwippy.facade:<name>default.config_handlerandcss_vars_handlernow resolve overrides once per request and route every requirement read through the override-aware getter (theget_reqclosure over the resolved overrides). The now-unused directregistryrequire was dropped from both handlers since reads go throughtheming_helpers.theming_helperslibrary entry gains theregistry,contract,loggermodule grants it now needs.Integration note (consuming app)
The upstream handler security policy is left unchanged (
config_read_runtime+content_fs_runtime). A consuming app that wants to actually bind a resolver must grant the config/CSS handlerscontract.get/contract.open/contract.callonwippy.facade:resolver(and its binding), e.g. via an app-side policy added to those handlers. Without that grant,resolve_overrides()simply degrades to{}(static defaults) — it never breaks the endpoints. The default upstream policy is intentionally not weakened.Compatibility
No binding ⇒
resolve_overrides()returns{}⇒ output is byte-identical to today's static-requirement behavior.