Files
tazlin 69324c1c3e feat(styles): add the style contract module and columns
- A style can carry two optional declarations. A parameter policy sets which of a request's params are kept when the style is applied: `none` keeps the style's params and ignores the request's, `listed` takes only the params the policy lists, `all` takes any of them. Template fields declare the placeholders the style's prompt accepts beyond `{p}`, each with a description and whether a request has to supply it.
- A policy's `ceilings` is a map from param to the largest value a request may set. It limits the request's value only; the style's own params are not checked against it, and a value above a ceiling is rejected rather than clamped, because clamping would change the cost of a request silently. A ceiling on a param the current mode does not let a request set is accepted and has no effect, except for `n`, which always comes from the request and is capped under every mode.
- `StyleContractVocabulary` holds, for one style type, the params a policy may make overridable and the params it may cap, with the range each ceiling may take. It is passed to `StyleParameterPolicy` through the pydantic validation context, so `horde/classes/base/style_contract.py` does not import the API layer and a stored policy can be loaded without one. Text styles cap `max_length`, `max_context_length` and `n`; image styles cap `width`, `height`, `steps` and `n`.
- `styles.parameter_policy` and `styles.template_fields` are nullable JSON columns, so a style that declares neither behaves exactly as before. `sql_statements/5.1.13.txt` adds them by hand; a nullable column with no default is a catalogue-only change and can be applied before the code that reads it is deployed.
- Seven return codes are added to `KNOWN_RC` and `README_return_codes.md` for the rejections the endpoints and the request path raise.
- No endpoint reads the columns yet.
2026-10-03 00:57:55 -04:00

4 lines
95 B
Plaintext

SPDX-FileCopyrightText: Tazlin <tazlin@haidra.net>
SPDX-License-Identifier: AGPL-3.0-or-later