refactor: converge duplicated subsystems and document architecture seams #206

Merged
David merged 2 commits from feat/pms-198-converge-subsystems into main 2026-06-13 17:40:33 +02:00
Owner

Converge the cheap-to-merge structural seams onto a single canonical implementation and record an explicit owner/decision for the seams too large to merge in one change (PMS-198).

Error type: migrate the infisical client/bootstrap/dev modules from the parallel CoreError to the canonical AppError, then delete src/error.rs (and its pub mod error;), removing the dead IntoResponse.

Auth extractor: add a RequireSuperAdmin role extractor (allowed roles = super_admin only) and use it for the four super-admin-only tenant routes (list/create/suspend/activate), replacing hand-rolled if user.role != SuperAdmin blocks. The genuinely-mixed handlers (super-admin OR same-tenant) keep their explicit guard.

build.rs: extract the duplicated git-hash/describe/build-date capture into a new build-metadata workspace crate; the root build.rs and crates/google-oauth-flow/build.rs now both call build_metadata::emit(git_dir).

Worker lifecycle: migrate the raw tokio::spawn(run_forever(..)) DispatcherWorker and RmmSyncWorker onto the shared Scheduler Job trait; they are registered alongside the existing jobs at their former cadences (5s, 60s).

Settings: upsert_tenant_setting now delegates to put_setting, the single canonical INSERT ... ON CONFLICT for tenant_settings.

RMM: list_device_mappings builds the optional connection_id filter dynamically via QueryBuilder instead of duplicating the whole COUNT+SELECT in an if/else.

CI: add scripts/check-migration-prefixes.nu plus a just check-migrations recipe and a check.yml step that fails when two migrations share a numeric prefix.

Docs: add dev-docs/architecture-seams.md recording the dual-auth and dual-billing ownership rules and the canonical-store decisions for the subscription-state (mokosh_auth.subscriptions canonical, no cross-schema FK) and dual-users (mokosh_auth.users canonical, public.users frozen) divergences.

#PMS-198

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Converge the cheap-to-merge structural seams onto a single canonical implementation and record an explicit owner/decision for the seams too large to merge in one change (PMS-198). Error type: migrate the infisical client/bootstrap/dev modules from the parallel `CoreError` to the canonical `AppError`, then delete `src/error.rs` (and its `pub mod error;`), removing the dead `IntoResponse`. Auth extractor: add a `RequireSuperAdmin` role extractor (allowed roles = super_admin only) and use it for the four super-admin-only tenant routes (list/create/suspend/activate), replacing hand-rolled `if user.role != SuperAdmin` blocks. The genuinely-mixed handlers (super-admin OR same-tenant) keep their explicit guard. build.rs: extract the duplicated git-hash/describe/build-date capture into a new `build-metadata` workspace crate; the root `build.rs` and `crates/google-oauth-flow/build.rs` now both call `build_metadata::emit(git_dir)`. Worker lifecycle: migrate the raw `tokio::spawn(run_forever(..))` `DispatcherWorker` and `RmmSyncWorker` onto the shared Scheduler `Job` trait; they are registered alongside the existing jobs at their former cadences (5s, 60s). Settings: `upsert_tenant_setting` now delegates to `put_setting`, the single canonical `INSERT ... ON CONFLICT` for `tenant_settings`. RMM: `list_device_mappings` builds the optional `connection_id` filter dynamically via `QueryBuilder` instead of duplicating the whole COUNT+SELECT in an if/else. CI: add `scripts/check-migration-prefixes.nu` plus a `just check-migrations` recipe and a check.yml step that fails when two migrations share a numeric prefix. Docs: add `dev-docs/architecture-seams.md` recording the dual-auth and dual-billing ownership rules and the canonical-store decisions for the subscription-state (`mokosh_auth.subscriptions` canonical, no cross-schema FK) and dual-users (`mokosh_auth.users` canonical, `public.users` frozen) divergences. #PMS-198 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
refactor: converge duplicated subsystems and document architecture seams
Some checks failed
E2E / Playwright against staging (pull_request) Failing after 33s
Check / fmt + clippy + compile + tests (pull_request) Successful in 2m40s
Build OCI container / Build and push mokosh-api image (push) Successful in 3m54s
031682419f
Converge the cheap-to-merge structural seams onto a single canonical implementation and record an explicit owner/decision for the seams too large to merge in one change (PMS-198).

Error type: migrate the infisical client/bootstrap/dev modules from the parallel `CoreError` to the canonical `AppError`, then delete `src/error.rs` (and its `pub mod error;`), removing the dead `IntoResponse`.

Auth extractor: add a `RequireSuperAdmin` role extractor (allowed roles = super_admin only) and use it for the four super-admin-only tenant routes (list/create/suspend/activate), replacing hand-rolled `if user.role != SuperAdmin` blocks. The genuinely-mixed handlers (super-admin OR same-tenant) keep their explicit guard.

build.rs: extract the duplicated git-hash/describe/build-date capture into a new `build-metadata` workspace crate; the root `build.rs` and `crates/google-oauth-flow/build.rs` now both call `build_metadata::emit(git_dir)`.

Worker lifecycle: migrate the raw `tokio::spawn(run_forever(..))` `DispatcherWorker` and `RmmSyncWorker` onto the shared Scheduler `Job` trait; they are registered alongside the existing jobs at their former cadences (5s, 60s).

Settings: `upsert_tenant_setting` now delegates to `put_setting`, the single canonical `INSERT ... ON CONFLICT` for `tenant_settings`.

RMM: `list_device_mappings` builds the optional `connection_id` filter dynamically via `QueryBuilder` instead of duplicating the whole COUNT+SELECT in an if/else.

CI: add `scripts/check-migration-prefixes.nu` plus a `just check-migrations` recipe and a check.yml step that fails when two migrations share a numeric prefix.

Docs: add `dev-docs/architecture-seams.md` recording the dual-auth and dual-billing ownership rules and the canonical-store decisions for the subscription-state (`mokosh_auth.subscriptions` canonical, no cross-schema FK) and dual-users (`mokosh_auth.users` canonical, `public.users` frozen) divergences.

#PMS-198

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merge branch 'main' into feat/pms-198-converge-subsystems
Some checks failed
Create release / Create release from merged PR (pull_request) Has been skipped
E2E / Playwright against staging (pull_request) Failing after 1m9s
Check / fmt + clippy + compile + tests (pull_request) Failing after 5m44s
f8029eb950
David merged commit 3b508c1fc8 into main 2026-06-13 17:40:33 +02:00
David deleted branch feat/pms-198-converge-subsystems 2026-06-13 17:40:33 +02: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
psa-systems/mokosh-server!206
No description provided.