feat(platform): structured platform registry + /api/v1/platforms; update server reads registry [#367] #826

Merged
jmiller merged 1 commits from feature/platform-registry into dev 2026-07-19 02:48:56 +00:00
Owner

Summary

Turns the flat admin [metadata] PLATFORM_OPTIONS key list into a structured platform registry where each platform key carries capability attributes, and exposes it so CI / the update server / mokocli can read platform behavior from config instead of hardcoding it.

Not built/deployed — requires forge rebuild + redeploy; review signatures. Companion to the CI/mokocli rewiring (separate).

Storage choice

New [metadata] PLATFORM_REGISTRY key in app.ini: either an inline JSON array of platform objects, or a path to a JSON file (e.g. custom/platforms.json, relative paths resolved against CustomPath). Parsed in modules/setting. No DB table — idiomatic (mirrors existing app.ini + file-path config patterns), and the registry is non-secret capability config only (never credentials/tokens/keys). A built-in DEFAULT registry (joomla, dolibarr, go, npm, mcp, generic) keeps behavior unchanged when unconfigured, and reconciles with the existing PLATFORM_OPTIONS key list.

Schema (PlatformDef)

key, label, aliases, family, artifact(bool), update_generator, feed_format, template_repo, manifest_based(bool), publish_target, detect_globs. Everything defaults off family=generic.

New endpoints

  • GET /api/v1/platforms — whole registry (list of capability objects). This is what CI/mokocli read.
  • GET /api/v1/platforms/{key} — one platform (404 if not registered).

Wired into the public-accessible misc API group (same visibility as /settings, /licenses).

Update server rewiring (minimal / additive)

Added services/updateserver/registry.go with GeneratorForPlatform, FeedFormatForPlatform, ContentTypeForPlatform, PlatformServesGenerator — registry lookups that replace the hardcoded per-platform generator/feed decisions. Handler bodies in routers/web/repo/updateserver.go were left untouched to avoid conflicting with PR #825.

Overlap with PR #825 (feature/updateserver-npm-mcp, open, not merged)

PR #825 concurrently modifies routers/web/repo/updateserver.go and adds models/updateserver/platform.go (platform constants + ResolvePlatform + IsFeedlessPlatform). To stay compatible and avoid a heavy conflict, this PR is deliberately additive and does not edit those files' handler bodies. The helpers here are drop-in replacements for the per-platform gating and can be adopted once #825 lands (e.g. if !PlatformServesGenerator(platform, "joomla")). No file conflicts expected: this PR only adds services/updateserver/registry.go in that package.

Admin UI

Read-only resolved-registry table added to Admin -> Metadata; the textarea still edits the flat key list. Capability attributes are edited via app.ini [metadata] PLATFORM_REGISTRY for now (structured editor deferred as too invasive).

Scope guard

Does not touch models/repo/repo_manifest.go or the per-repo apiMetadata struct (owned by a separate PR). Registry is a separate endpoint, not embedded in /metadata.

Build/format status

No Go toolchain in this environment — unbuilt, go vet not run, not gofmt'd by tool. Files written to gofmt conventions; signatures matched against existing handlers (ctx.PathParam, ctx.APIErrorNotFound, ctx.JSON; misc handler pattern; swagger response wrappers).

Files

  • modules/setting/platform_registry.go (new) — PlatformDef, registry, default registry, loader
  • modules/setting/metadata.go — call loadPlatformRegistryFrom
  • modules/structs/miscellaneous.goPlatform API struct
  • routers/api/v1/misc/platforms.go (new) — ListPlatforms / GetPlatform
  • routers/api/v1/swagger/misc.goPlatform / PlatformList responses
  • routers/api/v1/api.go — routes
  • routers/web/admin/metadata.go + templates/admin/metadata.tmpl — read-only registry table
  • services/updateserver/registry.go (new) — registry-driven dispatch helpers
  • custom/conf/app.example.ini — documented [metadata] section

https://claude.ai/code/session_015UauDPfYC8S2mdUhoSK8zQ

## Summary Turns the flat admin `[metadata] PLATFORM_OPTIONS` key list into a **structured platform registry** where each platform key carries capability attributes, and exposes it so CI / the update server / mokocli can read platform behavior from config instead of hardcoding it. **Not built/deployed — requires forge rebuild + redeploy; review signatures.** Companion to the CI/mokocli rewiring (separate). ## Storage choice New `[metadata] PLATFORM_REGISTRY` key in `app.ini`: either an **inline JSON array** of platform objects, or a **path to a JSON file** (e.g. `custom/platforms.json`, relative paths resolved against `CustomPath`). Parsed in `modules/setting`. No DB table — idiomatic (mirrors existing `app.ini` + file-path config patterns), and the registry is **non-secret capability config only** (never credentials/tokens/keys). A built-in **DEFAULT registry** (joomla, dolibarr, go, npm, mcp, generic) keeps behavior unchanged when unconfigured, and reconciles with the existing `PLATFORM_OPTIONS` key list. ## Schema (`PlatformDef`) `key, label, aliases, family, artifact(bool), update_generator, feed_format, template_repo, manifest_based(bool), publish_target, detect_globs`. Everything defaults off `family=generic`. ## New endpoints - `GET /api/v1/platforms` — whole registry (list of capability objects). **This is what CI/mokocli read.** - `GET /api/v1/platforms/{key}` — one platform (404 if not registered). Wired into the public-accessible misc API group (same visibility as `/settings`, `/licenses`). ## Update server rewiring (minimal / additive) Added `services/updateserver/registry.go` with `GeneratorForPlatform`, `FeedFormatForPlatform`, `ContentTypeForPlatform`, `PlatformServesGenerator` — registry lookups that replace the hardcoded per-platform generator/feed decisions. **Handler bodies in `routers/web/repo/updateserver.go` were left untouched** to avoid conflicting with PR #825. ### Overlap with PR #825 (`feature/updateserver-npm-mcp`, open, not merged) PR #825 concurrently modifies `routers/web/repo/updateserver.go` and adds `models/updateserver/platform.go` (platform constants + `ResolvePlatform` + `IsFeedlessPlatform`). To stay compatible and avoid a heavy conflict, this PR is **deliberately additive** and does **not** edit those files' handler bodies. The helpers here are drop-in replacements for the per-platform gating and can be adopted once #825 lands (e.g. `if !PlatformServesGenerator(platform, "joomla")`). No file conflicts expected: this PR only adds `services/updateserver/registry.go` in that package. ## Admin UI Read-only resolved-registry table added to Admin -> Metadata; the textarea still edits the flat key list. Capability attributes are edited via `app.ini [metadata] PLATFORM_REGISTRY` for now (structured editor deferred as too invasive). ## Scope guard Does **not** touch `models/repo/repo_manifest.go` or the per-repo `apiMetadata` struct (owned by a separate PR). Registry is a **separate endpoint**, not embedded in `/metadata`. ## Build/format status No Go toolchain in this environment — **unbuilt, `go vet` not run, not gofmt'd by tool**. Files written to gofmt conventions; signatures matched against existing handlers (`ctx.PathParam`, `ctx.APIErrorNotFound`, `ctx.JSON`; `misc` handler pattern; swagger response wrappers). ## Files - `modules/setting/platform_registry.go` (new) — `PlatformDef`, registry, default registry, loader - `modules/setting/metadata.go` — call `loadPlatformRegistryFrom` - `modules/structs/miscellaneous.go` — `Platform` API struct - `routers/api/v1/misc/platforms.go` (new) — `ListPlatforms` / `GetPlatform` - `routers/api/v1/swagger/misc.go` — `Platform` / `PlatformList` responses - `routers/api/v1/api.go` — routes - `routers/web/admin/metadata.go` + `templates/admin/metadata.tmpl` — read-only registry table - `services/updateserver/registry.go` (new) — registry-driven dispatch helpers - `custom/conf/app.example.ini` — documented `[metadata]` section https://claude.ai/code/session_015UauDPfYC8S2mdUhoSK8zQ
jmiller added 1 commit 2026-07-19 02:30:33 +00:00
feat(platform): structured platform registry + /api/v1/platforms; update server reads registry [#367]
Universal: Auto Version Bump / Version Bump (push) Successful in 23s
Universal: PR Check / Branch Policy (pull_request) Successful in 2s
Universal: PR Check / Require Docs Update (pull_request) Has been skipped
Universal: PR Check / Wiki Update Reminder (pull_request) Has been skipped
Generic: Project CI / Lint & Validate (pull_request) Successful in 33s
Universal: PR Check / Validate PR (pull_request) Successful in 8s
Generic: Project CI / Tests (pull_request) Successful in 27s
Universal: PR Check / Secret Scan (pull_request) Successful in 50s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
38aa4de412
Turn the flat admin [metadata] PLATFORM_OPTIONS key list into a structured
platform registry where each key carries capability attributes (family,
artifact, update_generator, feed_format, template_repo, manifest_based,
publish_target, detect_globs, aliases), and expose it so CI / the update
server / mokocli can read platform behavior from config instead of hardcoding.

Storage: new [metadata] PLATFORM_REGISTRY key in app.ini — inline JSON array
or a path to a JSON file (e.g. custom/platforms.json), parsed in
modules/setting. No DB table (idiomatic: mirrors existing app.ini + file-path
config patterns; non-secret capability config only). Built-in DEFAULT registry
(joomla, dolibarr, go, npm, mcp, generic) keeps behavior unchanged when
unconfigured, and reconciles with PLATFORM_OPTIONS.

API: GET /api/v1/platforms (whole registry) and GET /api/v1/platforms/{key}
(one), wired into the public misc group.

Update server: additive registry-driven helpers in services/updateserver
(GeneratorForPlatform / FeedFormatForPlatform / ContentTypeForPlatform /
PlatformServesGenerator) that replace hardcoded per-platform generator/feed
decisions with registry lookups. Handler bodies left untouched to avoid
conflicting with PR #825 (feature/updateserver-npm-mcp), which is concurrently
rewiring routers/web/repo/updateserver.go and adding
models/updateserver/platform.go; helpers are drop-in for adoption once #825
lands.

Admin UI: read-only resolved-registry table added to Admin -> Metadata; the
textarea still edits the flat key list. Capabilities edited via config for now.

Does NOT touch models/repo/repo_manifest.go or the per-repo apiMetadata struct
(owned by a separate PR).

Authored-by: Moko Consulting
jmiller merged commit 74fc2d3101 into dev 2026-07-19 02:48:56 +00:00
jmiller deleted branch feature/platform-registry 2026-07-19 02:48:57 +00:00
Sign in to join this conversation.