Skip to content

Flat file: storage and lookup ADR #319

Open

Description

@milten89

Follow-up of #220 (ADR-0024), which left storage out of scope.

Scope

Decide in an ADR (/adr) how OpenUrzednik.MF.WhiteList.FlatFile keeps a day's data and looks a hash up:

  • The built-in stores, compared on rebuild time, memory, disk and lookup cost: an in-memory sorted array of 64-byte hashes (about 236 MB), a sorted binary file or a folder per hash prefix on disk, and whether a database (SQLite through Microsoft.Data.Sqlite: a native library per platform, AOT, a new dependency) belongs in its own variant package.
  • The extension point for other stores (other databases, key-value caches such as Redis): its public interface, frozen once released (ADR-0011), and where implementations live (separate packages under ADR-0016's variant rule).
  • Every day's hashes change completely (the date is part of each one), so a store is rebuilt daily, not updated: how a store swaps days, how many days it keeps (for proof of a past check, after the ministry deletes archives after 30 days), and whether the app can keep the archive itself.
  • The cost per check: one chain of 5,000 SHA-512 rounds (3.8 ms in Python), up to 24 chains with masks; measure it in .NET.

Done when

  • An accepted ADR decides the stores, the extension point and the daily rebuild; the lookup and storage work is in issues.

Context for the implementing agent

Where this fits. #220 decided the 7z reader of the planned OpenUrzednik.MF.WhiteList.FlatFile package (ADR-0024: SharpCompress, read API only, at least 0.50.9, a seekable temporary file, bounded input, a 7z case in the AOT smoke app). The package is a variant of OpenUrzednik.MF.WhiteList (ADR-0016, ADR-0023) and reuses its transport-neutral models. The work is split into: #319 (storage and lookup ADR) → #320 (skeleton) → #321 (download and integrity) → #322 (lookup) → #323 (docs). Each waits for the issues in its blockedBy.

Read first. CLAUDE.md, ADR-0024, ADR-0023 and the specification below. Start only when Status is Ready and blockedBy lists no open issue; set Status In progress. One issue per PR into develop, Closes #<n>, the reviewer agent before the PR, CodeQL alerts after it.

Flat-file facts (specification of 30.09.2026, checked 2026-11-20 on the archive 20261120.7z):

  • URL https://wykazpodatnikowvat.mf.gov.pl/plikplaski/YYYYMMDD.7z, one archive every calendar day (generated about 22:10 Warsaw time the evening before), kept 30 days; downloads "may be limited" (blocked until midnight), no published thresholds; the host is behind Imperva.
  • The archive: about 249 MB, one solid LZMA2 block (32 MB dictionary), an LZMA-packed header, two entries: YYYYMMDD.json (about 502 MB) and YYYYMMDD.json.sha512sum (<hex> *YYYYMMDD.json). No checksum or signature outside the archive.
  • The JSON: naglowek (dataGenerowaniaDanych "YYYYMMDD", liczbaTransformacji "5000" as a string, schemat), skrotyPodatnikowCzynnych (3,341,992 hashes) and skrotyPodatnikowZwolnionych (348,169), each sorted, 128-character lowercase hex, no duplicates; maski (1,508 masks of 26 characters, 944 banks, at most 23 per bank).
  • The hash: s = date + NIP (10 digits) + NRB (26 digits, no separators) (or without the account for a NIP-only check); repeat N times s = lowercase_hex(SHA512(UTF8(s))). Verified against the ministry's test data (17 pairs), but the published sample's header date is wrong: its hashes match 20191121, not 20260907.
  • Masks: positions 3–10 are the bank's digits in clear, Y positions are copied from the account, X positions (check digits included) stay X. When the plain hash isn't found, hash the masked account of every mask whose bank digits match, and look again; only then is the account not on the list.
  • Legal: art. 117ba of the Tax Ordinance ties liability to the list on the day the transfer is ordered; no official text gives a flat-file check the weight of the API's requestId.

Activity

  1. added
    documentation
    on Nov 20, 2026
  2. moved this from Triage to Ready in OpenUrzednik.NETon Nov 20, 2026
  3. added
    provider:white-list
    provider:flat-file
    on Nov 20, 2026
  4. added this to the 1.1.0 milestone on Nov 21, 2026
  5. moved this from Ready to In progress in OpenUrzednik.NETon Nov 22, 2026
  6. modified the milestones: 1.1.0, 1.2.0 on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationprovider:flat-fileprovider:white-list

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions