Builds a store seeded from the given config path. A load failure is fatal: it throws to abort portal startup rather than seeding a synthetic empty config, so a transient read error can never be served as real state or persisted over the user's real config on the next save.
Absolute path to config.json.
Returns the live config with secrets masked for transport.
Masked copy safe to send to the browser.
Returns the unmasked live config (server-side use only).
The current in-memory config.
Runs the offline validation report against a candidate config with its
round-tripped masked secrets restored and the same shaping the save path
applies (shapeForValidation — target coercion plus empty-artifact
pruning), so the live "Validate" preview judges the real secret values and
the exact shaped config a save would persist (e.g. a masked Telegram
botToken is not reported as a format error it does not actually have, and an
empty notification channel is not flagged as a missing URL). This is an
offline health report, not the full save gate: it does not run the
boot-credential or portal-auth checks collectGateErrors adds, so a
green preview is necessary but not sufficient for a successful save.
Candidate config from the portal UI (secrets may be masked).
The per-check offline validation report.
Shapes and gates the incoming config via shapeAndGate. Anything that
fails there is invalid client input (HTTP 400); the try/catch only relabels
unexpected shaping throws as failures, while write/I/O faults are deferred to
commit so they surface as server errors (HTTP 500).
Replacement config from the portal UI.
The validated config ready to commit, or a 400-class failure.
Writes an already-prepared config and replaces the in-memory copy. Runs outside prepare's try/catch so an unexpected write failure surfaces as a server error (HTTP 500) rather than being relabeled as invalid client input.
Validated config from prepare.
Procedure success, or the writer's failure.
Deletes the staged files a save killed mid-way left beside the config.
How many were removed, or why the directory could not be read.
Loads, masks, validates, and persists the portal-managed config.