Skip to content

ADR-0009: Optional community catalogue — signed SQLite snapshot, moderated queue, artifact-only history

  • Status: Proposed
  • Date: 2026-07-25
  • Supersedes: None
  • Superseded by: None

Extends ADR-0006 (mirror a registry locally rather than query it) and ADR-0008 (what a supplement record contains). Neither changes.

Context

Two kinds of fact are captured by hand today and are identical for every user who owns the same pack:

  • Pill appearance. ADR-0006 established that no appearance columns exist anywhere in the ŠÚKL registry — colour, shape, score and imprint are prose in leaflet section 6, parsed heuristically, and corrected by hand when the parse is wrong. That correction is worth exactly as much to the next person.
  • Supplement composition. ADR-0004 and ADR-0008 established that no registry lists supplements at all: the label is the only source, and every user photographs or pastes the same panel independently.

A shared catalogue would mean nobody re-enters what somebody already captured. The app must stay local-first — AGENTS.md requires that ordinary record access not depend on a network service — so the catalogue is an optional accelerator, never a dependency.

The design difficulty is not storage. It is that three things people loosely call "the data" have opposite exposure requirements:

Must be readable by Must not be readable by
Published catalogue every app instance the casual public
Submission queue the maintainer anyone else
Per-contribution records nobody, ever —

Two further properties are easy to miss and expensive to add later. A catalogue entry is a claim with a lifetime, not a permanent truth: a manufacturer can change a tablet's colour or a supplement's filler while the ŠÚKL code and GTIN stay the same. And the wire format decides whether the app parses megabytes on every launch or opens an indexed file.

Constraints: no budget beyond free tiers; contributors are patients, so requiring a developer account is not acceptable.

Decision

The artifact

  • The snapshot is SQLite, compressed and signed, published alongside a manifest. The app already runs libsql, so a downloaded catalogue is opened as a second database with real indexes rather than parsed into memory. JSON remains an export format, not the wire format.

  • The app resolves a stable manifest URL, never a snapshot URL. The manifest names the current version, its digest, its signature and the minimum app version that can read its schema. Storage can move without shipping a client.

{
  "latestVersion": "2026.07.1",
  "minimumAppVersion": "0.8.0",
  "schemaVersion": 3,
  "snapshotUrl": "…",
  "sha256": "…",
  "signature": "…",
  "publishedAt": "2026-07-25T18:00:00Z"
}
  • Claims carry validity, not just values. Every appearance and composition claim records validFrom / validTo and the market it applies to, so a tablet that changed colour in 2025 does not silently overwrite what the pack looked like before. A catalogue that only stores current values cannot represent the pack a person is actually holding.

The two flows

  • Two flows, two systems. Reads are a whole signed snapshot. Writes are a moderated submission queue. They never share a store.

  • Gate the download, not the query. The app fetches the entire catalogue and answers lookups locally. A per-lookup API is refused: it would tell the server which substance a given device asked about, which is precisely the disclosure the local-first design exists to prevent. Access control, where applied, sits in front of the file — a key exchanged for a short-lived signed URL — so the server learns that a device downloaded version N and nothing else. See Alternatives for the standing argument against gating at all.

  • A submission is validated against a schema that rejects unknown fields. Not a strip-list: a deny-list rots the moment a new local field is added, and the failure is silent. The server accepts an explicitly enumerated shape and refuses everything else.

{
  "schemaVersion": 1,
  "entityType": "supplement_composition",
  "identifier": { "type": "gtin", "value": "…" },
  "market": "SK",
  "proposed": { "brand": "…", "form": "tablet", "ingredients": [] }
}

The grant travels beside the claim rather than inside it — {"licence": "CC-BY-4.0", "contribution": { … }} — because corroboration counts agreement about a pack: two people describing the same tablet must hash alike whatever terms they granted under. Sending posts a batch, {"submissions": [ … ]}, since a challenge token is redeemable once.

Never accepted, in any shape: rawText, label photographs, capture timestamps, barcode scan times, lot numbers, expiry dates, and every field describing use rather than product — schedule, dose times, supply counts, intake log.

  • Git stores the built artifact, never a contribution. Each release is a wholly rebuilt catalogue. Per-contribution rows never enter version control in any form, because history is cloned and permanent: a record later found to be identifying cannot be retracted from forks, and rewriting history does not reach copies already taken.

Publication confidence

  • Evidence sets a confidence level; it does not gate publication uniformly.
Evidence Published as
Official registry or manufacturer document verified
One clear label submission community-sourced
Two or more independent agreeing submissions corroborated
Submissions that conflict withheld, queued for review

The app shows the level and treats "community-sourced" as a prompt to check the pack, not as fact.

  • Appearance requires stronger evidence than composition. A wrong colour or imprint means the wrong tablet is identified, which is the one place in this project where bad data causes physical harm rather than inconvenience. A single uncorroborated appearance claim is not published for a prescription medicine.

  • A corroboration threshold applies only while the contributor population is small enough for an entry's existence to identify someone, and is lifted once it is not. Applied universally it would suppress exactly the long tail where community contribution is most valuable, and its premise is weak anyway: submitting a product does not establish that the submitter takes it — a caregiver, pharmacist or researcher may be scanning someone else's pack.

Licensing

  • The catalogue is published under CC BY 4.0, and a contributor grants under the same terms at the moment of contributing.

A collection of facts is weakly protected at best: Feist v. Rural Telephone (1991) held that facts plus an unoriginal arrangement attract no copyright and rejected "sweat of the brow". What does exist here is the EU sui generis database right (Directive 96/9/EC), which protects substantial investment in obtaining and verifying contents independently of copyright and applies in Slovakia. CC BY 4.0 licenses that right explicitly — 3.0 did not — which is why the version matters and a bare "CC BY" badge is not enough.

  • A software licence is not used. MIT and its relatives are written about "the Software", leave a reuser unable to tell whether the grant covers the schema, the build or the data, and are silent on database rights — so they would fail to convey the one right that clearly exists in the jurisdiction this catalogue is built in.

  • Two grants, recorded separately. Inbound, contributor to project, captured per submission alongside the payload: without it the project cannot lawfully republish what was contributed, and it cannot be obtained afterwards without re-contacting every contributor. Outbound, project to the world, is the catalogue's own terms.

  • The grant is not part of the hashed claim. Corroboration counts independent agreement about a pack; two people describing the same tablet must agree whether or not the terms they granted under ever differ.

Contributor privacy

  • No submitter identity exists. No account, no device identifier, no nonce that survives between submissions. Addresses are needed transiently to rate limit; they are kept only as a salted hash with a short TTL and are never written to a log.

  • Contribution is per item and explicit. A button on the record being contributed, showing the exact payload before it is sent. Not a settings toggle, and never a side effect of saving. Submissions are held locally and sent when the user opens the contribution screen, so transmission does not timestamp the moment a person started taking something.

Batching carries that protection. Random delay on top is optional and is not claimed as a privacy measure — it buys nothing if the endpoint keeps timestamps or stable identifiers, and the protections that do the work are explicit submission, no background upload, no identifier, no analytics on the endpoint, and short retention.

Integrity

  • The snapshot is signed and the public key is pinned in the app. This defends one specific thing: a compromised bucket or CDN silently serving a false catalogue. It does not defend against a compromised build repository, a stolen signing key, a moderator approving bad data, or upstream data that is simply wrong. The private key lives outside the repository as a scoped CI secret; the manifest is signed, not only the database file.

Hosting

Signed snapshots published as release assets to begin with, a small edge function for submissions (services/catalogue-submit), a managed SQL queue behind it, and a private repository for review and build. The release builder (scripts/build-catalogue.mjs) lives with the reader rather than in that repository, so both ends read one schema. Object storage with free egress is a later move, taken when custom domains, staged rollouts, delta files or private pre-release channels are needed — not before, since it is the first component requiring a billing relationship. The manifest indirection makes that move a configuration change.

Alternatives considered

  • Firebase client SDK. Rejected: it mints a persistent installations identifier and reports telemetry from inside a client whose entire claim is that it does not. Firestore reached from the server only is not objectionable; the SDK in the app is.
  • BigQuery as the operational backend. Rejected: an analytics warehouse, not a serving layer — no per-row authorization, priced per scan. It remains a reasonable later choice for analysing catalogue coverage and conflict rates, which is a different job.
  • JSON as the downloadable artifact. Rejected: no indexes, parsed whole on every use, and no migration path between schema versions.
  • Per-lookup authenticated API. Rejected: it would trade the user's query privacy for the dataset's secrecy, which is the wrong way round for this app.
  • Issue tracker as the submission queue. Rejected: it would require every contributor to hold a developer account, publicly associate contributors with entries, and expose contribution timing.
  • Moderation through public pull requests. Rejected: the diff and its timestamp publish when a contribution arrived, and git makes that permanent.
  • A universal corroboration threshold before any publication. Rejected as the default rule — see Publication confidence. Retained as a bounded measure for a small population.
  • MIT, or another software licence, for the data. Rejected — see Licensing. It grants rights over "the Software" and says nothing about database rights.
  • CC0. Rejected: it waives the database right rather than exercising it, so the catalogue could be absorbed wholesale with no obligation even to name where it came from. Maximum adoption, no recourse whatsoever.
  • ODbL. Rejected for now: it gives real teeth against a closed product built on this data, but its share-alike terms reliably deter commercial integration, and integrations are what make a catalogue worth maintaining. Revisit if wholesale copying by a competitor becomes the actual problem rather than the feared one.
  • Publishing the catalogue openly with no download gate. This is the standing counter-proposal and it has not been dismissed on merit. Its argument: a secret embedded in a client is not a secret, so gating buys friction rather than protection while adding infrastructure, an account-like identifier and a billing relationship; and the defensible advantage is not possession of a pill-colour table but data quality, provenance, SK/EU coverage, conflict resolution, update cadence and identifier mapping across ŠÚKL, EMA, GTIN and ATC — none of which is copied by copying a file. Gating is retained here as an explicit owner decision, not because that argument was answered. Revisit before first publication.

Consequences

Bulk extraction is made inconvenient, not prevented. Any key shipped inside a client can be recovered from it. Legal terms, not technical measures, are what give recourse against wholesale copying, and CC BY 4.0 is the recourse chosen: attribution, backed by the database right rather than by a copyright that facts may not carry.

What now blocks first publication is upstream, not the licence. Appearance data is extracted from ŠÚKL leaflets, and no outbound licence can grant redistribution rights the project does not hold: ŠÚKL's own publication terms have to be established before anything derived from those documents is republished. Supplement composition read off a commercial label is a separate question with a separate answer. Neither is resolved here, and neither is answerable by choosing a licence.

The framing above rests on Feist and Directive 96/9/EC, which are settled, but how the database right applies to this particular extraction is not something this document is competent to decide. A real opinion is wanted before publishing — not before building, since the contribution payload records the grant per submission and is unaffected by the answer.

Temporal claims mean the catalogue can hold two appearances for one medicine and must be asked which applies to a given pack. That is more work than overwriting a field, and it is the only way to be correct about a product whose packaging changed. The same gap exists locally today: ADR-0006 stores a hand-corrected appearance per medicine and reuses it for every future record of that medicine, so a manufacturer's change silently invalidates it with no field able to say when it was true. Worth fixing independently of whether this catalogue is built.

Confidence levels must reach the interface. A catalogue that publishes community-sourced appearance without saying so would be worse than one that publishes nothing, because a rendered pill carries more authority than a blank space.

Free-tier terms move and are to be re-checked before implementation rather than trusted from this document. Release hosting in particular is free by absence of a documented limit rather than by explicit allowance, which is not the same guarantee.

Contribution stays optional and per item. A user who never contributes is not degraded — the ŠÚKL mirror, the label parser and the Annex I/II vocabulary all continue to work with no network service at all.

Status note — accepted 2026-07-27

Accepted on the strength of a working implementation, not a plan: the endpoint, the moderation queue, the release builder and the signature verification all exist and were exercised end to end. A release was built, signed, published, downloaded, verified against the pinned key, and a tampered manifest was refused.

Accepting the decision does not resolve what the Consequences section says is unresolved. No catalogue release containing data derived from ŠÚKL leaflets may be published until those publication terms are established. The machinery being ready does not make that question answered, and the empty queue is not evidence that it is.

Two limits of the deployment as accepted:

  • Sending is a single batched request carrying one challenge token, because a Turnstile token is valid once. Per-item posting and a challenge are mutually exclusive; the batch is what reconciles them.
  • The submission endpoint is only as protected as the challenge in front of it. With TURNSTILE_SECRET unset it accepts anything well-formed, rate-limited by salted address hash alone.

Corrected on acceptance. The submission example under The two flows was written before the endpoint existed and named fields the implementation never used — supplement_product, proposedData, sourceEvidence. The built endpoint rejects all three as unexpected keys, so the example documented a payload that would be refused. It has been replaced with the shape actually accepted. The decision it illustrates — an enumerated allowlist rather than a strip-list — is unchanged; only the illustration was wrong.