Italiano

4. Resolution rules

Level: behavior. How Squiddy goes from the document you wrote to the answer a single app receives. It is the page to read when a published configuration “does not arrive”. The previous one is Configuration format, the next one is Validation and preview.

What the app declares

At every request the app sends these fields. Squiddy's SDK sends them, with the values chosen by whoever develops the app; in the Tester you write them yourself (page 5).

FieldRequiredWhat it is for in the resolution
appIdyesIdentifies the configuration, together with the coordinates worked out from the API key.
appVersionyesCompared with min/max of every block. Better in the YYYY.MM.DD format.
appTypeyesCompared with appTypes. ios, android, tvos, web, desktop.
appModeyesCompared with appModes. release, debug.
appLanguageyesPicks the localized message of appUpdate / inFoPoint.
appBundleIdyesDoes not take part in the resolution.
customParamsnoA list of free labels: it is the input of rules and of the segments.
entityIdnoA stable identifier of the installation: it decides who enters a percentage rollout.
langFingerprint, configFingerprintnoThe fingerprints received with the previous answer, so as not to download again what has not changed.

Upper and lower case. Squiddy lowercases the fields of the request (and trims their spaces), then compares them letter by letter with what is in the configuration. The document is therefore case-sensitive, the request is not: "appTypes": ["iOS"] never matches, because it will compare iOS with ios. Validation points out this specific case (page 5).

The three exceptions, used exactly as they arrive: entityId, langFingerprint, configFingerprint. For entityId it means that AB-1 and ab-1 are two different installations, which in a percentage rollout can end up one inside and one outside.

The order of resolution

For every request of the app:

  1. api section: the blocks are gone through in order, and the chosen API block is the first one that satisfies all the conditions. If no block satisfies them, the app receives the 5001 error and no answer.
  2. appUpdate section: the last block that matches wins.
  3. inFoPoint section: the last block that matches wins.
  4. The translations are filtered by languagesSupported of the chosen API block.
  5. The answer is put together, with the fingerprints.

The three sections are resolved independently: an appUpdate block does not need any api block to resemble it, and vice versa. The only link is the filter on the languages, which depends on the chosen API block.

api: the first one wins

An api block matches when all six conditions hold:

  1. appVersion ∈ [min, max] (both ends included);
  2. appType is listed in appTypes, or appTypes contains all;
  3. appMode is listed in appModes, or appModes contains all;
  4. rules is satisfied (see below; absent = satisfied);
  5. the app belongs to all the segments called (no segment = satisfied);
  6. the app falls inside the rollout, if there is one (no rollout = satisfied).

The first block that satisfies them all is served, and the search stops there. Hence the right way to write this section: from the most specific to the most general, with the last block acting as a safety net (appTypes: ["all"], appModes: ["all"], min: "0000.00.00", max: "9999.99.99", no rules).

If no block matches, or the chosen block is incomplete (apiVersion is missing, serverMode is missing, or a row of serverSettings is incomplete), the app does not receive a partial answer: it receives the 5001 error. An app that in that case does not use the last configuration saved on the device does not start. That is the reason why the last block of the list should always be a block that matches everybody.

appUpdate and inFoPoint: the last one wins

Here the search does not stop: every block that matches takes the place of the previous one, so the last one of the list wins. It is the opposite of api, and it has to be kept in mind, because no validation can notice that the order is not the one you meant.

In practice: in the api section the specific rule goes before the general one; in appUpdate and inFoPoint it goes after.

Inside the winning block, the message is the row of the requested language; if that language has no row, the row with language: "default". The row is used as it is: a row left empty in the app's language arrives empty (title and text ""), and does not fall back on default; the app still triggers the update or the maintenance, without text. If there are two rows for the same language, the first one wins; if there are two default rows, the last one. If the block has neither the row of the language nor a default row, the request fails with 5001; an empty text, on the other hand, never makes the request fail.

Translations

The langList[0] dictionary is filtered by keeping only the languages listed in languagesSupported of the chosen API block. The languages kept arrive exactly as they are saved: an empty translation {"key": ""} arrives empty, and the app shows an empty text; a key that a language does not have does not arrive in that language, and the SDK falls back on the default language. If the result is empty — languagesSupported absent, or languages the dictionary does not contain — the translations section is simply removed from the answer, together with its fingerprint: it is not an error, it is an app without translations.

Of the filtered translations Squiddy calculates a fingerprint (langFingerprint) and sends it with them. The app keeps it and sends it back at the next request: if the translations have not changed, Squiddy does not send them again but sends back the fingerprint, the same as the one received. So the app tells apart the two cases of an answer without translations: with the fingerprint it means “unchanged, keep yours”; without the fingerprint it means “this configuration has no translations for you”, and those the app keeps are no longer valid. Above it there is a second level, configFingerprint, which covers the whole resolved configuration: when it matches, the app receives a minimal answer with notModified: true and keeps everything it has. The app does not calculate the fingerprints: it keeps them and sends them back. Squiddy's SDK does it by itself.

For whoever writes configurations there is a single consequence, and it has to be said: after a publishing the fingerprints change by themselves, so there is nothing to do to “force” the apps to update. If an app keeps behaving as before, the problem is not the fingerprints.

rules: every set, at least one value per set

rules is a list of sets. Every set has to be satisfied (AND) by at least one of its values present in the request's customParams (OR).

"rules": [
  ["beta-user", "internal"],   // customParams contains "beta-user" OR "internal"
  ["ios-17"]                   // AND contains "ios-17"
]
The app's customParamsDoes it match?
["beta-user", "ios-17"]yes
["internal", "ios-17", "other"]yes
["beta-user"]no — ios-17 is missing
["ios-17"]no — neither of the two of the first set

Two edge cases worth knowing:

The values of the customParams are compared letter by letter: they are labels agreed with whoever develops the app, not a language.

segments: the same audience in several blocks

A segment is a rules with a name. It is defined once in the segments section (page 3) and the blocks call it by name:

"segments": { "beta-testers": [["beta-user", "internal"]] },
"api": [
  { "apiVersion": "4.0", "segments": ["beta-testers"], "…": "…" },
  { "apiVersion": "3.18", "…": "…" }
]

rollout: percentage rollout

An api block can serve only a part of the installations, so that a change goes out a little at a time.

"api": [
  { "apiVersion": "4.0", "rollout": { "percentage": 10, "salt": "api-v4" }, "…": "…" },
  { "apiVersion": "3.18", "…": "…" }        // everybody else keeps receiving this one
]
FieldRequiredMeaning
percentageyesThe percentage of installations that receive the block, from 0 to 100. 0 is a legitimate state: “ready, not started”.
keynoWhat the choice is made on: entity (default) or app.
saltnoA label that makes this rollout independent of the others.

How it is decided. From salt and from the key (the entityId or the appId, see below) Squiddy calculates a number from 0 to 99, always the same for the same pair: the installation's band. The block is served if the band is lower than percentage. There is nothing random and nothing that depends on the time. So:

salt. Two blocks with different salt values choose different audiences: whoever was left out of one rollout is not necessarily left out of all the others. Two blocks with the same salt (even when both lack it) choose the same audience: it is the way to make several blocks move together, with the same people.

key: what the choice is made on.

keyWhat the band is calculated onWhat goes in or stays out
entity (default)the request's entityId, or the appId if the app does not send iteach installation on its own
appthe appIdthe whole app together, all or nothing (the trial of a whole app)

The entityId is chosen by whoever develops the app, not by you. For a rollout to be really gradual, the app has to send an entityId that is:

If the app does not send it, the band is calculated on the appId: the whole app is inside or outside, and a percentage rollout cannot be gradual. It is the first place to look when a 10% rollout turns out to be at 100% or at 0%.