krzngon/model_repository_demo
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

model_repository_demo

Reference HTTPS model repository consumed by model_manager_service when it uses the built-in cloud configuration manager and HTTPS downloader.

This document is the server-side contract: it defines the on-device server descriptor, the repository layout, every configuration field, and the rules a model server must follow.


1. On-device server descriptor

The device keeps the server base URL in a read-only file shipped in the image:

  • Device path: /system/etc/cloud_config/mms_cloud_server.json
  • Source file in the component: etc/cloud_config/mms_cloud_server.json
{
  "serverBaseUrl": "https://gitcode.com/api/v5/repos/krzngon/model_repository_demo/raw/"
}
FieldTypeRequiredDescription
serverBaseUrlstringyesBase URL all resources are joined onto. A trailing / is optional and is normalized on the device.

The client derives every URL by simple path joining (exactly one separating /), with no branch/query segment in the base:

<serverBaseUrl>support_models.json
<serverBaseUrl>models/<modelName>/v<major>/version.json
<serverBaseUrl>models/<modelName>/v<major>/<modelName>.zip

For this demo the base is the gitcode raw API and the repository's default branch is served (no ?ref= is appended).

Server requirements

  • All resources must be reachable over HTTPS with anonymous GET (the device sends no auth token for the support list, descriptors, or packages).
  • A successful fetch must return HTTP 200 and the exact file bytes (Content-Type is not relied upon). Redirects are followed (up to 5 hops).
  • URLs must be stable and long-lived. Do not put time-limited signed URLs in serverBaseUrl or version.json.
  • The support list and descriptors must be UTF-8 JSON; packages are binary.

2. Repository layout

support_models.json                              # support list (one file at the root)
README.md
models/
└── <modelName>/
    └── v<major>/
        ├── <modelName>.zip                      # model package
        └── version.json                         # descriptor of the published build
  • <modelName> must be identical everywhere: directory name, ZIP file name, the single member inside the ZIP, and modelName in both JSON files.
  • There is one directory per major version (v1, v2, ...). Each major directory publishes only the latest version of that major. There is no per-minor/patch directory and no history retention requirement on the server.
  • Example: models/ml_face_isface/v1/ carries the latest version of major 1 (v1.2.0); models/ml_face_isface/v2/ carries v2.0.0.

3. support_models.json

Pulled synchronously whenever an update check is triggered, at most once per 24 hours (see §7). Served at <serverBaseUrl>support_models.json.

{
  "modellist": [
    {
      "modelName": "ml_face_isface",
      "enable": true,
      "supportVersions": ["v1.2.0", "v2.0.0"],
      "updateType": "HTTPS"
    },
    {
      "modelName": "ml_face_gesture",
      "enable": false,
      "supportVersions": ["v1.0.0"],
      "updateType": "HTTPS"
    }
  ]
}

Top-level object:

FieldTypeRequiredDescription
modellistarrayyesSupported model entries.

Each entry contains exactly these four fields; no other field is required or consumed:

FieldTypeRequiredDescription
modelNamestringyesUnique model identifier. Non-empty; used for all paths. Entries with an invalid/missing name are skipped.
enableboolyestrue = the model is available and downloadable. false = the model is unavailable and cannot be downloaded.
supportVersionsstring[]yesEvery publishable version as canonical v<major>.<minor>.<patch>. List one latest version per major (e.g. v1.2.0, not v1.0.0/v1.1.0). Malformed version strings are ignored.
updateTypestringyesMust be "HTTPS". Entries with any other value are ignored by the cloud manager.

4. version.json

One descriptor per major directory at <serverBaseUrl>models/<modelName>/v<major>/version.json. It describes the exact build published in that directory.

{
  "modelType": "MSL",
  "versionCode": "v1.2.0",
  "checksum": "173acbe4d2923beb485adda152ea097df7e863b60ff75360e60e0973941128d6",
  "packageSize": 152
}
FieldTypeRequiredDescription
modelTypestringyesModel package type. Currently only "MSL" is accepted; any other value is rejected.
versionCodestringyesExact version of the package, canonical v<major>.<minor>.<patch> (lowercase v, dot-separated decimal numbers).
checksumstringrecommendedWhole-ZIP SHA-256 as a lowercase hex string. The device verifies the downloaded bytes against it; when absent/empty verification is skipped.
packageSizenumberrecommendedZIP size in bytes (non-negative integer).
packageUrlstringnoAbsolute download URL of the package. When absent or empty the device downloads <serverBaseUrl>models/<modelName>/v<major>/<modelName>.zip. Use this only for a stable, anonymous, long-lived URL (never an expiring signature).

Because each major directory holds its latest version, versionCode is the authoritative exact minor/patch (the device re-targets to it at download time).


5. Model package (<modelName>.zip)

  • ZIP containing a single file whose name is exactly <modelName> with no extension (e.g. ml_face_isface, not ml_face_isface.ms).
  • No versionInfo.xml and no XML of any kind; the HTTPS install path does not parse XML.
  • No extra directories or companion files are required.
  • The ZIP is downloaded to a sandbox staging area, checksum-verified, then extracted into the version install directory models/<modelName>/v<major>_<minor>_<patch>/ (dots in the version are replaced with underscores). The staging ZIP is removed afterwards.
  • After installing a new version, only older version directories of the same major are cleaned up — a smaller minor, or a smaller patch at the same minor. Other majors are left intact.

6. Versioning and update rules

  • Canonical format: v<major>.<minor>.<patch> (e.g. v1.2.0). The shorter two-segment spelling v<major>.<minor> is also accepted, with the patch treated as 0. This scheme is entirely separate from any legacy numeric (10-digit) version scheme.
  • A model that is not installed is represented as v0.0.0.
  • Target selection from supportVersions:
    • Not installed (v0.0.0): choose the overall latest version — greatest major, then greatest minor, then greatest patch. Downloading a higher major is allowed.
    • Installed at major N: choose the latest version within major N for update checks. A greater minor in the same major, or a greater patch at the same minor, is an update; the device does not auto-upgrade across majors.
  • The support list used for a check is pulled synchronously at the start of the check (subject to the 24-hour gate); a failed/not-due fetch falls back to the current local list.

7. Refresh, network, and persistence semantics

  • The support list is pulled on first initialization, on Wi-Fi reconnect, and synchronously whenever an update check is triggered — at most once every 24 hours. There is no scheduled periodic auto-refresh.
  • All network access requires Wi-Fi. If Wi-Fi is unavailable, the fetch is skipped/deferred and retried (network event / next trigger).
  • The device generates and maintains a local install_models.json in its sandbox from the merged support list. This file is produced on the device; the server only ever serves support_models.json.
  • The installed version and the last refresh timestamp are kept in device preferences and are preserved across refreshes.
  • A model removed from the server's support list is kept locally (it is not deleted and simply stops receiving updates).
  • enable=false means the model is unavailable and cannot be downloaded (see §3).

8. Hosting / CDN guidance for real packages

  • Prefer serving packages from object storage/CDN with stable anonymous HTTPS links that do not expire.
  • Git LFS signed URLs are typically short-lived (minutes), so they must not be hard-coded. If the platform forces LFS for large artifacts, publish a durable URL through packageUrl instead.
  • Always publish a correct checksum (whole-ZIP SHA-256) so integrity can be verified regardless of the transport.

Note for this demo: the ZIPs are tiny and are committed as regular Git objects (not LFS) on purpose, so the gitcode raw API (.../raw/<path>, default branch) serves them anonymously and stably.


9. Demo inventory

ModelEnabledPublished versionsPackage contents
ml_face_isfacetruev1.2.0 (models/.../v1), v2.0.0 (models/.../v2)single file ml_face_isface
ml_face_gesturefalsev1.0.0 (models/.../v1)single file ml_face_gesture

This set exercises same-major minor/patch updates (v1.0.0 → v1.2.0), cross-major availability (v2.0.0), and the disabled/unavailable model case (ml_face_gesture).