Skip to content

Add remote Settings and control API (1.2.0) - #22

Merged
sdas92 merged 20 commits into
daslearning-org:developfrom
japperJ:feat/remote-settings-api
Nov 27, 2026
Merged

sdas92 merged 20 commits into
daslearning-org:developfrom
japperJ:feat/remote-settings-api

Conversation

@japperJ

@japperJ japperJ commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Expose Settings and control over the existing bearer-authenticated FastAPI server, add named API keys with scopes, make Webhook retry policy live Settings, and keep the on-device UI in step with remote writes.

New surface: GET /api/health, GET /api/status, GET/PUT /api/settings, POST /api/webhook/test, POST /api/server/restart, and GET/POST/DELETE /api/keys. POST /sms/ is unchanged.

Evidence

  • 185 tests pass: python -m unittest discover -s tests -p "test_*.py".
  • Android 1.2.0 smoke on SM-G991B: health 200; Settings read/write; key lifecycle; Restart 202 then health 200 with request.json ending server=start and changing restart_id values; Webhook test 200 with signature (502 scrubbed when the saved target timed out).
  • OpenAPI request bodies for PUT /api/settings and POST /api/keys; strict types; extra fields rejected.
  • buildozer android debug succeeds; the 1.2.0 APK installs and runs.
  • README, docs/remote-api.md, ADR 0002 and GLOSSARY.md updated. No new runtime dependency; httpx is test-only.

Merge Danger

Door: two-way for the code; one-way for existing installs because keys.json v1 -> v2 and the new Settings revision are persisted.

Blast Radius: auth, Settings, and Webhook delivery.

  • v1 keys get both scopes once by design.
  • request.json carries a restart_id so a stale intent cannot suppress a later Restart.
  • PUT /api/settings replaces the writable subset; clients should send the Revision they read.

japperJ and others added 19 commits November 26, 2026 22:48
Describe the API contract, cross-process config ownership, restart orchestration, and key migration; record ADR 0002 and add glossary terms for Settings, Revision, Scope, API key, and Restart.
Add POST /api/webhook/test, which sends a test Webhook to a candidate target and secret without changing live Settings. The call is offloaded from the event loop, never follows redirects, and scrubs URL parts from errors. Covered against a local HTTP receiver.
Read Webhook timeout, maximum attempts, backoff, and Outbox capacity from the live Settings on each Delivery attempt and at enqueue. Missing or invalid values fall back to today's constants, a malformed Settings file cannot crash the dispatcher, and explicit constructor overrides still win.
Add regression coverage for remote Webhook and retry changes surviving a stale local save, and for invalid stale forms leaving Settings unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bump the app version and changelog to 1.2.0, document the remote Settings and control API in the README, and refresh version references.
Move both text fields out of MDListItem's trailing slot into full-width rows so long Webhook targets are editable on Android.
Remove unused key adapters, share the health uptime calculation, rename the dispatcher override helper, reuse the default Webhook shape on reset, and refresh the remote API docs. Drop the no-op release-workflow comment edits.
Write resp.json atomically, give Restart intents an id so a later request is not suppressed, stop persisting a v1 key migration on launch, use only the documented key owner marker, document next-launch boot semantics, and replace private restart state in tests with a clock patch.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Webhook URL validation accepts missing hostnames and invalid ports, allowing enabled forwarding to fail and discard queued SMS after retries are exhausted.

7 open issues
What changed in this PR

Adds remote Settings and control to OpenSMS’s existing bearer-authenticated FastAPI server for version 1.2.0, alongside scoped API keys and live Webhook retry settings.

Changes:

  • Adds Settings, health, status, Webhook test, Restart, and key-management endpoints.
  • Introduces shared persistence services and updates the on-device UI to preserve remote changes.
  • Expands automated tests, adds Linux test CI, and documents the API and migration behavior.
File Description
README.md Documents remote API usage, scopes, and network precautions.
GLOSSARY.md Defines Settings, Revision, Scope, API key, and Restart.
docs/​webhook/​receiver_test.md Updates the example User-Agent version.
docs/​remote-api.md Specifies API contracts, persistence, and operational behavior.
docs/​adr/​0002-remote-settings-and-control-api.md Records remote-control architecture and tradeoffs.
docs/​adr/​0001-inbound-sms-webhook.md Documents live retry and capacity settings.
CHANGELOG.md Adds the 1.2.0 release notes.
app/​tests/​test_webhook.py Tests live retry settings and credentialed-target rejection.
app/​tests/​test_settings_local_save.py Tests local merges, validation, and remote-change preservation.
app/​tests/​test_key_svc.py Tests key persistence, migration, and concurrent mutations.
app/​tests/​test_control_svc.py Tests Restart intents, normalization, and port resolution.
app/​tests/​api_test_case.py Adds isolated HTTP test setup and key helpers.
app/​services/​webhookSvc.py Applies live retry settings and target credential handling.
app/​services/​settingsSvc.py Adds shared Settings validation, revisions, and atomic persistence.
app/​services/​postApi.py Adds remote endpoints, scoped authentication, and runtime reporting.
app/​services/​netSvc.py Allows status reporting to distinguish network discovery failures.
app/​services/​keySvc.py Implements named keys, migration, scopes, and locked persistence.
app/​services/​controlSvc.py Implements atomic control intents and effective-port resolution.
app/​services/​config.py Bumps the application version to 1.2.0.
app/​services/​appSvc.py Handles Restart intents and provides live runtime status.
app/​screens/​settings.py Updates key-rotation wording and Webhook input layout.
app/​requirements-dev.txt Adds test-only HTTP client dependency.
app/​openSmsCli.py Clarifies phone-key replacement prompts.
app/​main.py Merges local Settings edits and refreshes persisted values.
.github/​workflows/​tests.yml Adds Linux unit-test automation.

Review effort: Balanced

Comment thread app/services/webhookSvc.py Resolved
Comment thread app/main.py Resolved
Comment thread app/main.py Resolved
Comment thread app/services/appSvc.py Resolved
Comment thread app/services/postApi.py Resolved
Comment thread app/services/postApi.py Resolved
Comment thread app/services/postApi.py Resolved
Reject Webhook targets without a hostname or with an invalid port; capture the Settings error message before scheduling the toast; keep unsaved port edits on a Webhook-only save; publish the bound port so the UI refreshes after a Restart; fall back to the live server port for restart_required; normalize the Webhook-test timeout; reject Restart when no consumer is registered.
@sdas92
sdas92 merged commit 12d8fd3 into daslearning-org:develop Nov 27, 2026
1 check passed
@japperJ
japperJ deleted the feat/remote-settings-api branch December 2, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants