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).
| Field | Required | What it is for in the resolution |
|---|---|---|
appId | yes | Identifies the configuration, together with the coordinates worked out from the API key. |
appVersion | yes | Compared with min/max of every block. Better in the YYYY.MM.DD format. |
appType | yes | Compared with appTypes. ios, android, tvos, web, desktop. |
appMode | yes | Compared with appModes. release, debug. |
appLanguage | yes | Picks the localized message of appUpdate / inFoPoint. |
appBundleId | yes | Does not take part in the resolution. |
customParams | no | A list of free labels: it is the input of rules and of the segments. |
entityId | no | A stable identifier of the installation: it decides who enters a percentage rollout. |
langFingerprint, configFingerprint | no | The 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:
apisection: 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 the5001error and no answer.appUpdatesection: the last block that matches wins.inFoPointsection: the last block that matches wins.- The translations are filtered by
languagesSupportedof the chosen API block. - 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:
appVersion∈ [min,max] (both ends included);appTypeis listed inappTypes, orappTypescontainsall;appModeis listed inappModes, orappModescontainsall;rulesis satisfied (see below; absent = satisfied);- the app belongs to all the
segmentscalled (no segment = satisfied); - 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 customParams | Does 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:
"rules": [](or an absent field) is satisfied by everybody: no filter;"rules": [[]]— an empty set — is satisfied by nobody, and makes the block dead. It is refused at publishing, because it is almost always a typing mistake.
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", "…": "…" }
]
- A segment can only narrow. It holds together with version, type, mode,
rulesandrollout, never as an alternative. Whoever is outside the segment does not “lose” the configuration: they simply move on to the next block. That is why the general block goes right after it. - Several segments hold all together:
"segments": ["beta-testers", "eu-region"]reaches only whoever is in both. - The advantage is sharing. Two blocks that call the same segment change together when you edit it. Two copies of the same rules do not: that is exactly what they stop doing as soon as someone updates only one of the two.
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
]
| Field | Required | Meaning |
|---|---|---|
percentage | yes | The percentage of installations that receive the block, from 0 to 100. 0 is a legitimate state: “ready, not started”. |
key | no | What the choice is made on: entity (default) or app. |
salt | no | A 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:
- the same installation always receives the same answer, today as tomorrow, even after an update of Squiddy;
- raising the percentage takes nobody out of those who were already inside: the band does not change, it is not a new draw.
10 → 25 → 50 → 100therefore widens the audience without ever narrowing it; - lowering it to
0stops the rollout without deleting the block; - the Tester repeats exactly the same calculation, so “what will this user receive” is a question with a certain answer (page 5).
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.
key | What the band is calculated on | What goes in or stays out |
|---|---|---|
entity (default) | the request's entityId, or the appId if the app does not send it | each installation on its own |
app | the appId | the 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:
- stable forever — generated once (a random UUID at the first start is enough), stored and reused at every request, even after an update of the app. A value that changes changes the band, and the app enters and leaves the rollout between two requests;
- identical byte for byte — it is neither trimmed nor lowercased;
- opaque — it is never returned or compared with the configuration: better a random id per installation than a piece of personal data.
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%.