Skip to content

Flat file: check a NIP and account against a day's file #322

Open

Description

@milten89

Follow-up of #220 (ADR-0024); the store comes from #319.

Scope

  • Parse the JSON (source-generated System.Text.Json, streaming: the file is about 502 MB) into the store Flat file: storage and lookup ADR #319 decides.
  • The hash chain (liczbaTransformacji rounds of SHA-512 over date + NIP + NRB, lowercase hex) and the mask fallback for virtual accounts, as the facts below describe; a NIP-only check.
  • The result: active, exempt or not on the list, with the file's date; inputs validated with src/Identifiers and masked in telemetry (ADR-0003).
  • Tests: the ministry's test data (with the sample's date defect handled and documented), mask cases, and a performance check of the chain in .NET.

Done when

  • A check returns the documented status for the test data, masks included.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementprovider:flat-fileprovider:white-list

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions