push-puqrvooxwpxw #3

Merged
eric merged 20 commits from push-puqrvooxwpxw into main 2026-11-11 08:29:21 +01:00
Owner
No description provided.
eric added 20 commits 2026-11-11 08:28:21 +01:00
Introduce a new `webui` feature that provides a web-based interface for viewing and editing configuration settings. This includes the core `Config` struct updates to expose internal state, a new `page` module for defining configuration schemas, and a full `webui` implementation using Axum with HTML rendering and CSS styling.

- Add `webui` crate-kit dependency and update version to 0.1.12
- Expose `Config::overrides` and `Config::lock` as `pub(crate)` in `src/config.rs`
- Introduce `src/introspect.rs` with `Source` enum and methods for determining value origins (`default_of`, `source_of`) and applying changes (`set_values`, `reset`)
- Add `src/page/mod.rs` defining `Kind`, `Mode`, `Apply`, `Setting`, `ConfigPage`, and `ConfigPages` structs for schema definition
- Implement `src/page/view.rs` with `SettingView` and `PageView` structs and rendering logic to filter hidden settings
- Add `src/webui/mod.rs` with `WebUi` struct and Axum router handling `/` and `/{id}` routes
- Add `src/webui/render.rs` for HTML generation including escaping, row construction, and page indexing
- Add `src/webui/style.css` with dark mode styling for configuration elements
- Move `src/config_tests.rs` to `src/tests/config.rs` without content changes
- Add comprehensive test suites for introspection, page validation, rendering logic, and web UI endpoints
Refactor configuration system to enforce strict key declarations and explicit defaults. Move `Kind` and related helpers from `page/mod.rs` to a new `src/key.rs` module, and update `Setting` to derive defaults from declared keys. Replace the previous implicit YAML defaults with explicit `DefaultValue` types and add validation logic in `src/declared.rs`.

- Move `Kind`, `bool`, and `bool_with` from `src/page/mod.rs` to new `src/key.rs`, which also defines `Key` struct and `DefaultValue` enum.
- Update `Setting` in `src/page/mod.rs` to include a `default` field derived from declared keys, adding `new` and `legacy` constructors.
- Modify `introspect.rs` to support optional defaults in `source_of` and clarify that `Value::Null` removes keys, reverting them to declared defaults.
- Add `src/declared.rs` with `read_value`, `read_text`, etc., enforcing type checks and returning errors for invalid values instead of silent defaults.
- Update tests in `src/page/tests/view.rs` and `src/webui/tests/webui.rs` to use new `Key` constants and verify declared default behavior.
- Adjust web UI rendering (`src/webui/render.rs`) and routing to use updated imports and configuration structures.
Decouple configuration keys from their UI representation by introducing a `Widget` enum in `src/page/mod.rs` and moving slider/words logic there. Add a `ConfigKeys` registry in `src/registry.rs` to validate all configuration values at startup, ensuring errors are reported collectively with specific key paths.

- Move `slider` and `words` constructors from `src/key.rs` to `src/page/mod.rs`, where they now configure the `Widget` field of `Setting` rather than defining the key type itself.
- Introduce `Widget` enum (`Auto`, `Text`, `Number`, `Slider`, `Toggle`) in `src/page/mod.rs` with a `resolved_widget` method to determine the concrete UI element based on kind and explicit settings.
- Add `ConfigKeys` struct in `src/registry.rs` to hold declared keys, providing methods for validation (`validate`), conflict detection (`conflicts`), and iteration (`iter`, `len`).
- Update `src/declared.rs` with new write methods (`write_value`, `write_text`, `write_integer`) and a `managed_dir_of` helper to resolve and create directories based on key paths.
- Modify `src/config.rs` to expose `resolve_and_create_dir` as `pub(crate)` for use by the registry and declared keys.
- Update `src/page/view.rs` and `src/webui/render.rs` to use the resolved `widget` field for rendering, replacing previous logic that relied solely on `Kind`.
- Add tests in `src/tests/registry.rs` to verify configuration validation, including error reporting for invalid values, duplicate paths, and key-section conflicts.
- Update existing tests in `src/page/tests/page.rs`, `src/tests/declared.rs`, and webui test files to reflect the new widget-based settings and registry validation behavior.
Introduce a `unit` field to configuration keys to support displaying units
(e.g., "jours") alongside values. This change updates the `Key` struct,
propagates the field through `Setting` and `SettingView`, and integrates
unit display into the web UI rendering logic.

- Add `unit: &'static str` field to `src/key.rs::Key` and a new `unit()`
  builder method to set it.
- Update `src/page/mod.rs::Setting` variants (`new`, `legacy`) to include
  the `unit` field, carrying over the key's unit.
- Add `unit` field to `src/page/view.rs::SettingView` and pass it through
  the `view` implementation.
- Implement `with_unit` helper in `src/webui/render.rs` to format values
  with optional units, updating `value_cell` and `row` logic for file
  sources.
- Add test `a_unit_is_part_of_the_key_and_reaches_the_page_setting` in
  `src/tests/declared.rs` to verify unit propagation (e.g., "jours" for TTL).
- Add test `the_unit_follows_the_value_the_default_and_the_slider` in
  `src/webui/tests/render.rs` to verify UI display of units.
- Update documentation in `AGENTS.md` and `Blackboard/evolution_pmoconfig.md`
  to reflect the new `unit` capability and key structure changes.
Replace machine-bound key derivation with a random 32-byte key stored in
`secret.key`, ensuring passwords are encrypted on write and decrypted on
read. This removes the `dirs` dependency and adds `getrandom`.

- Update dependencies in Cargo.toml and AGENTS.md: remove `dirs`, add `getrandom`
- Refactor src/encryption.rs: replace `derive_key` with `key_from_material` using
  random bytes; update `encrypt_password`/`decrypt_password` to use the new key
  derivation; move test helpers to src/tests/encryption.rs
- Update documentation in README.md and Blackboard/evolution_pmoconfig.md: clarify
  that keys are per-installation, not machine-bound; note that old passwords may
  be unrecoverable if `secret.key` is lost
Introduce a new `Secret` configuration type that behaves like text but is never exposed in views or serialized output. Update validation logic to use `check_key` for stricter type checking and modify `read_value` to return `NotFound` for missing keys with defaults. Add support for optional text values that return `None` when null or missing, ensuring proper handling of unset states across the application.

- Add `Secret` kind to `src/key.rs` and `Widget` in `src/page/mod.rs`, including constructors `optional_text` and `secret`.
- Implement `check_key` in `src/declared.rs` to validate written values against type/bounds without falling back to defaults.
- Update `read_value` in `src/declared.rs` to return `NotFound` for missing keys with defaults, and add `read_optional_text` for optional text handling.
- Modify `validate` in `src/registry.rs` to use `check_key` instead of `read_value` for error reporting.
- Update `SettingView` and `view` in `src/page/view.rs` to handle `Secret` kinds, ensuring values are never carried by the view and tracking `set` state.
- Add styles for `.secret` classes in `src/webui/style.css` and update `value_cell` in `src/webui/render.rs` to hide secret values.
- Add tests for optional keys, secret validation, and view rendering in `src/tests/declared.rs`, `src/page/tests/view.rs`, and `src/webui/tests/render.rs`.
Replace the `api` feature and its associated REST endpoints with a new `webui` feature that provides HTML pages for reading and editing configuration. This shift removes the JSON-based API in favor of form-based interactions, introducing validation checks before writing values and enforcing an all-or-nothing write policy.

- Delete `src/api.rs` and `src/openapi.rs`, removing REST endpoints (`get_full_config`, `update_config_value`) and OpenAPI documentation generation.
- Introduce `src/webui/` module with `mod.rs` for routing, `render.rs` for HTML rendering (including `Notice` enum for success/refusal feedback), `form.rs` for input cells, and `save.rs` for change planning.
- Update `Config` in `src/config.rs` to use `OnceLock` for keys and enforce validation via `check_write` in `set_value`.
- Implement `declare` and `check_write` in `src/registry.rs` to validate configuration keys and ensure values conform to declared constraints before writing.
- Enforce all-or-nothing semantics in `src/introspect.rs`'s `set_values`, rejecting the entire batch if any single value is invalid.
- Update `Cargo.toml` and `Cargo.lock` to replace `utoipa` with `axum` dependencies and switch features from `api` to `webui`.
- Add comprehensive tests in `src/webui/tests/` for form submission, secret encryption, read-only fields, and refusal handling.
Introduce a new `Action` system allowing configuration pages to trigger specific behaviors (e.g., "Save and test connection") via dedicated buttons. This includes adding the `Action` struct, updating the UI to render action buttons, and handling outcomes asynchronously without page redirection.

- Add `src/page/action.rs` defining `Action` and `ActionOutcome` structs with handlers, along with factory methods and trait implementations for equality and formatting.
- Update `ConfigPage` in `src/page/mod.rs` to include an `actions` vector and provide an `action` method for registration, ensuring unique IDs.
- Extend `PageView` in `src/page/view.rs` to carry the `actions` list into the view layer.
- Modify `submit` in `src/webui/mod.rs` to detect action fields, execute the corresponding handler if valid, and render the resulting view with the outcome.
- Update `render.rs` to display action buttons instead of a single save button, handle `Notice::Acted` states, and allow editing sections containing actions.
- Add CSS styles in `src/webui/style.css` for action buttons and help text using flex layout.
- Add documentation in `Blackboard/ToThinkAbout/edition_web_configuration.md` detailing the actions phase, handler behavior, and cache token limitations.
- Update tests in `src/webui/tests/action.rs` to verify button rendering, successful execution, error handling, and refusal logic for invalid forms or unknown actions.
Introduce a new `Collection` type and associated UI components to allow users to manage sets of entries (such as devices) within configuration pages. This includes backend logic for traversing configuration values, frontend rendering of entry tables, and the ability to remove specific entries atomically during form submission.

- Add `src/entries.rs` with `Entry` struct and `collect` helper to traverse config mappings
- Add `src/page/collection.rs` defining `Collection`, `Field`, `Display` enum, and constructors
- Add `src/page/collection_view.rs` with `CollectionView`, `EntryView`, and view generation logic
- Update `src/page/mod.rs` to expose collection modules and add `collections` field to `ConfigPage`
- Update `src/page/view.rs` to include `collections` in `PageView` and populate them in `view#2`
- Add `src/webui/collection.rs` for rendering entry tables and handling removal buttons
- Modify `src/webui/mod.rs` to track removed entries in `Saved` struct and handle removal logic
- Update `src/webui/render.rs` to display removal notices and conditionally show save button
- Add tests in `src/tests/entries.rs`, `src/page/tests/collection_view.rs`, and `src/webui/tests/collection.rs`
- Update `Blackboard/ToThinkAbout/edition_web_configuration.md` with collection configuration details
Update configuration reading logic to coerce string values like '8080' into
integers when the schema expects an integer. This ensures that numeric
values written as text are interpreted correctly without being treated as
modifications if they match the default, while keeping write operations
strict.

- Add `Key::coerce` method in `src/key.rs` to handle coercion of `Value::String`
  to `i64` for integer keys, returning the original value if parsing fails.
- Update `read_value` and `check_key` in `src/declared.rs` to use `key.kind.coerce`
  before validation, ensuring type safety and proper error mapping.
- Modify `view` in `src/page/view.rs` to coerce retrieved values and correctly
  determine source status, preventing false positives for modifications when
  text integers match default numeric values.
- Add tests `a_numeric_text_equal_to_the_default_is_not_a_modification` and
  `an_integer_written_as_numeric_text_reads_as_the_integer` to verify the
  new coercion behavior and error handling.
- Update documentation in `Blackboard/ToThinkAbout/edition_web_configuration.md`
  to reflect tolerant reading of integer text and strict write validation.
Introduce a `RestartHook` to allow applications to handle system restarts
based on configuration changes. This includes new web UI endpoints for
confirming and executing restarts, along with documentation updates.

- Add `src/page/restart.rs` defining the `RestartHook` struct with warning
  messages and trigger execution capabilities.
- Extend `ConfigPages` in `src/page/mod.rs` to support an optional restart
  hook and reserve the "restart" page ID.
- Implement restart handling in `src/webui/mod.rs` with `/restart` routes,
  a `started` field for configuration storage, and updated rendering logic.
- Add `src/webui/restart.rs` containing `Started`, `pending`, `banner`,
  `confirm_page`, and `restarting_page` functions for UI generation.
- Update `src/webui/render.rs` to display restart banners and links when
  pending changes exist.
- Add documentation in `Blackboard/ToThinkAbout/edition_web_configuration.md`
  detailing the restart mechanism, server page variables, and SSO behavior.
- Include tests in `src/webui/tests/restart.rs` verifying hook execution,
  UI presence, and reserved ID constraints.
Update `edition_web_configuration.md` to reflect that `/config` pages are no longer served on the WAN port by default. Clarify session access rules with and without SSO enabled, including Android Bearer token whitelisting.

- Update configuration file documentation regarding `/config` page serving
- Reflect change in `host.wan_expose_config` default to false for macOS environments
Replace the previous pending-string approach with a dedicated `restart::State` struct to manage restart requirements and warnings. This change introduces a "Save and restart" button for settings marked as `RestartRequired` and ensures the server hook is respected before triggering a restart. The `pmoserver` hook now correctly reacts to cancellation signals, and `main` clears the database before execution.

- Refactor `src/webui/mod.rs` to use `ui.restart_state()` in `index`, `restart_confirm`, `submit`, and `unknown_page`, replacing the old `pending` logic
- Update `src/webui/render.rs` to expect `Option<&super::restart::State>` in `PageView` and `index`, using `super::restart::banner` for rendering restart warnings and buttons
- Modify `src/webui/restart.rs` to define a new `State` struct with `pending` and `warning` fields, updating `banner` and `confirm_page` to use this state instead of raw hooks
- Add tests in `src/webui/tests/restart.rs` for POST handling, save-and-restart behavior, refusal when no host hook exists, and validation of restart fields
Refactor boolean settings rendering to use a toggle switch by default, allowing explicit checkboxes via `Widget::Checkbox`. Update CSS for new toggle/switch elements and adjust server restart logic.

- Add `checkbox` definition in `src/page/mod.rs` to construct `Widget::Checkbox`
- Implement `bool_cell` in `src/webui/form.rs` to render toggles or checkboxes based on widget type
- Update `display` in `src/webui/render.rs` to return "oui"/"non" for checkboxes
- Add CSS styles for `.toggle` and `.switch-input` in `src/webui/style.css`
- Update tests in `src/webui/tests/webui.rs` to verify switch/checkbox behavior
- Modify `edition_web_configuration.md` to reflect new UI elements and restart logic
Introduce a `path` field to `ConfigPage` and `PageView` to support
hierarchical organization of configuration pages. Implement a new `tree`
module in the web UI to render nested index structures, replacing manual
HTML generation with a recursive rendering approach. Add corresponding
tests to verify page addressing and grouping behavior.

- Update `ConfigPage` in `src/page/mod.rs` to include `path` and `shared`
  fields, adding an `at` method for setting the path and updating the
  `new#2` constructor defaults.
- Modify `PageView` in `src/page/view.rs` to store and pass the new
  `path` field during construction.
- Add `src/webui/tree.rs` containing a `Node` struct with `of` and `render`
  methods to build and display hierarchical page indices.
- Update `src/webui/render.rs` to use the new tree rendering logic in the
  `index` function, replacing manual `<li>` generation.
- Add `src/webui/tests/tree.rs` with tests `the_index_groups_pages_under_their_path`
  and `a_page_keeps_its_address_and_shows_where_it_is_filed` to validate
  the new indexing behavior.
Update page configuration logic to support merging settings and collections when multiple pages share the same ID, provided they are filed under different paths. This replaces the previous strict refusal of duplicate IDs with a more flexible merging strategy while ensuring path uniqueness.

- Refactor `ConfigPage::with` in `src/page/mod.rs` to merge settings/collections for matching IDs and assert distinct paths/actions
- Update panic conditions in `src/page/mod.rs` to reflect reserved restart status or layered path conflicts instead of simple ID duplication
- Replace test `two_pages_with_the_same_id_are_refused` with `two_pages_with_the_same_id_merge` and `pages_with_the_same_id_filed_under_different_paths_are_refused` in `src/page/tests/page.rs`
- Add test for panic when a page is placed in two locations (`sous deux chemins`) in `src/page/tests/page.rs`
- Reorganize module declarations in `src/webui/tests/mod.rs` by removing and re-adding `mod webui;`
- Update assertion in `a_page_keeps_its_address_and_shows_where_it_is_filed` in `src/webui/tests/tree.rs` to verify specific HTML navigation structure
Introduce a new `Float` key type with optional min/max bounds, enabling
runtime validation of floating-point configuration values. Add `read_secret`,
`write_float`, and `read_float` functions to handle specific data types,
including encryption for secrets and locale-aware parsing for floats (comma/point).
Update the web UI form rendering and save logic to support these new types,
and remove `Eq` derives from configuration structs to reflect mutability.

- Add `Float` type definition in `src/key.rs` with bounds checking via `within_float`.
- Implement `read_secret`, `write_float`, and `read_float` in `src/declared.rs`.
- Update `src/page/mod.rs` to map `Kind::Float` to `Widget::Number` and remove `Eq` derives.
- Modify `src/webui/form.rs` to render float inputs with min/max attributes.
- Update `src/webui/save.rs` to parse floats using comma/point and validate bounds.
- Add tests for float reading/writing, secret handling, and integer-to-float casting.
Introduce a new `Info` type and associated UI components to allow displaying
read-only system state or discovered information alongside standard settings.
This feature enables pages to report non-configurable data that merges across
pages sharing the same ID, rendered as distinct rows in the web interface.

- Add `src/page/info.rs` containing `Info` struct (label, help, group, value)
  and `InfoView`, with methods for construction, retrieval, and formatting.
- Update `ConfigPage` in `src/page/mod.rs` to include an `infos` vector and
  modify `new#2` and `with#2` to initialize and merge information lists.
- Extend `PageView` in `src/page/view.rs` with an `infos` field and update
  the view logic to render information lines derived from the stored info.
- Modify `src/webui/render.rs` to introduce a `Line` enum (`Setting`/`Info`)
  and an `info_row` function, separating info rendering from standard settings.
- Update `src/lib.rs` to export `Info` and `InfoView` from the page module.
- Add tests in `src/page/tests/page.rs` verifying info computation and merging.
- Add test in `src/webui/tests/render.rs` ensuring info is rendered read-only,
  escaped, and without a setting badge in the web UI output.
Remove the `default_yaml` parameter from `AppSpec::new`, eliminating the legacy mechanism for defining configuration defaults via a central YAML file. Defaults are now application-specific, defined by the crate owning the key or imposed via `AppSpec::with_defaults`. This simplifies the API and clarifies that defaults come from declarations rather than a global config file.

- Remove `default_yaml` field and `with_default_yaml` method from `AppSpec` in `src/spec.rs`.
- Update `Config::load` to start with an empty configuration, merging only with `config.yaml` if present.
- Add `effective_default` logic to determine defaults based on declaration or `AppSpec::with_defaults`.
- Remove `Setting::legacy` and `Config::default_of`, replacing them with direct default handling in `Setting` and `introspect.rs`.
- Add support for `Kind::List` in `src/key.rs`, including validation, coercion, and serialization.
- Update all test suites to use simplified `AppSpec::new(prefix)` calls without empty string arguments.
- Add tests for list handling in `src/tests/declared.rs` and `src/webui/tests/save.rs`.
- Update documentation in `AGENTS.md`, `README.md`, and `Blackboard/evolution_pmoconfig.md` to reflect the new configuration model.
feat: add editable collections and inter-setting checks to config system
Some checks failed
Release / release (push) Failing after 1m32s
a1842ba6ed
Introduce support for editable configuration collections with validation,
switching API snapshots to compressed `.json.gz` format, and adding checks
between settings that prevent invalid batches. Update version to 0.3.0.

- Add `src/page/check.rs` with `Check` struct for validating configurations
- Add `src/page/collection.rs` with `EditField` and `Collection` structs for editable data
- Add `src/page/collection_view.rs` with `InputView` and `EditColumn` for UI representation
- Modify `src/page/mod.rs` to add `checks` field and `check` method to `ConfigPage`
- Add `src/webui/form.rs` with `entry_input` function for generating HTML inputs
- Modify `src/webui/collection.rs` to render editable columns and input fields
- Modify `src/webui/mod.rs` to add `refusal_path` for handling validation errors
- Modify `src/webui/render.rs` to display forms when collections have edit columns
- Modify `src/webui/save.rs` to handle collection edits and null value removals
- Add `src/webui/tests/collection_edit.rs` with tests for editing and validation
- Add `api/0.3.0.json.gz` as the new compressed API snapshot
- Delete `api/0.1.0.json`, `api/0.1.1.json`, and `api/0.2.0.json` (moved to .gz)
- Update `.crate-kit/VERSION` from 0.1.12 to 0.1.13
- Update `.crate-kit/crate.mk` comment for `api-snapshot` to reflect `.json.gz` format
- Modify `.crate-kit/scripts/api-level.sh` to use `.json.gz` baseline for checks
- Modify `.crate-kit/scripts/api-snapshot.sh` to output compressed `.json.gz` files
- Modify `.crate-kit/scripts/common.sh` `latest_snapshot` to search for `.json.gz`
- Update `Cargo.toml` and `Cargo.lock` version to 0.3.0, edition to 2024, rust-version to 1.85
- Add `src/introspect.rs` `file_value` method for retrieving raw file values
- Modify `src/lib.rs` to export new types like `Check`, `EditColumn`, `InputView`
- Modify `src/tree.rs` `set` to remove empty sections when setting null values
eric merged commit 2d570e5be8 into main 2026-11-11 08:29:21 +01:00
eric deleted branch push-puqrvooxwpxw 2026-11-11 08:29:25 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pmo/pmoconfig!3
No description provided.