Storage / DB

Storage / DB
Source snapshot: 9b4f8a3 (2026-09-23); retained QMail clone, including M7.
Working = implemented in this snapshot, not a new runtime/test certification.
Partial = an identified implementation/exposure gap; obsolete = retained compatibility only.
Entry points and static functions are selected navigation anchors; full lexical index: function-index.txt.
Used by / Tests list selected source references (including callback registration), not a proven dynamic call graph.
Tests were inspected, not executed; use tools/test.ps1 with isolated scratch data.
Old paths come from docs/path-map.txt; absent mappings denote additions after the move.

Mail database and contacts

Purpose
Store messages, attachments, folders, drafts, payment metadata and contacts in SQLite.
Files
src/mail/qmail_db.c src/mail/qmail_contacts.c
Old paths
vendor/core/src/qmail/qmail_db.c -> src/mail/qmail_db.c vendor/core/src/qmail/qmail_contacts.c -> src/mail/qmail_contacts.c
Public header
include/qmail/qmail_contacts.h include/qmail/qmail_db.h
Entry points
src/mail/qmail_db.c:576 :: qmail_db_open_data_dir() src/mail/qmail_contacts.c:64 :: qmail_base32_encode()
Important static functions
src/mail/qmail_db.c:385 :: read_contact_row() src/mail/qmail_db.c:423 :: read_email_row() src/mail/qmail_contacts.c:137 :: qmail_address_parse_core() src/mail/qmail_contacts.c:45 :: is_all_digits()
Owns
Mail DB creation and transactional units migrations; separate stores own their own tables.
Used by
src/app/desktop_api.c src/app/desktop_api_more.c src/coin/qmail_locker_pool.c src/coin/qmail_locker_pool_partial.c src/mail/qmail_beacon.c src/mail/qmail_endpoint.c src/mail/qmail_parent_send.c src/mail/qmail_payment_claim.c
Side effects
Database opens may create/migrate tables; writes persist records. Data compatibility probe is read-only. Archive adapters write admitted files.
Tests
tests/unit/desktop_api_test.c tests/unit/mail_ops_test.c tests/unit/mail_query_test.c tests/unit/coin/qmail_db_migration_test.c tests/unit/coin/qmail_funding_runtime_test.c tests/unit/coin/qmail_locker_pool_limbo_test.c tests/unit/mail/qmail_address_format_test.c tests/unit/mail/qmail_attachment_path_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Data compatibility probe

Purpose
Inspect an existing Client_Data database and WAL for startup compatibility.
Files
src/app/data_compat.c
Old paths
src/desktop_api/data_compat.c -> src/app/data_compat.c
Public header
include/qmail/data_compat.h
Entry points
src/app/data_compat.c:51 :: qmail_data_compat_inspect()
Important static functions
src/app/data_compat.c:11 :: directory_exists() src/app/data_compat.c:23 :: file_exists()
Owns
Read-only compatibility decision before desktop startup.
Used by
No external C symbol reference identified; see target/script membership and integration notes.
Side effects
Reads existing database/WAL metadata to report compatibility; does not migrate the database.
Tests
tests/unit/data_compat_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working

Hosting observations

Purpose
Record observed uptime over a fixed rolling 30 days with initially zero history.
Files
src/server/hosting_uptime.c
Old paths
src/gui/hosting_uptime.c -> src/server/hosting_uptime.c
Public header
include/qmail/hosting_uptime.h
Entry points
src/server/hosting_uptime.c:21 :: qmail_hosting_uptime_sample()
Important static functions
src/server/hosting_uptime.c:8 :: sql() src/server/hosting_uptime.c:9 :: bits()
Owns
hosting_uptime_state/minutes tables and derived uptime percentage.
Used by
src/server/hosting_adapter.c
Side effects
Creates/updates observation tables and ages out history to derive uptime.
Tests
tests/integ/hosting_uptime_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working; No manual uptime input; observation gaps are handled conservatively.

Compression and archive adapters

Purpose
Wrap compression and validate/extract component ZIP contents.
Files
src/mail/qmail_compress.c src/update/archive.c
Old paths
vendor/core/src/qmail/qmail_compress.c -> src/mail/qmail_compress.c
Public header
include/qmail/component.h include/qmail/qmail_compress.h
Entry points
src/mail/qmail_compress.c:40 :: qmail_compression_mode_from_string() src/update/archive.c:13 :: qm_archive_admit()
Important static functions
src/mail/qmail_compress.c:49 :: ext_is_precompressed() src/mail/qmail_compress.c:68 :: deflate_stream() src/update/archive.c:37 :: inspect_bytes()
Owns
QMail compression and archive validation rules; third-party implementation is deps/miniz (not indexed).
Used by
src/mail/qmail_receive.c src/update/component.c src/mail/sdk/qmail_sdk.c src/mail/service/qmail_service.c
Side effects
Database opens may create/migrate tables; writes persist records. Data compatibility probe is read-only. Archive adapters write admitted files.
Tests
tests/update/archive_check.c tests/update/component_test.c tests/unit/mail/qmail_cbdf_compression_test.c tests/unit/mail/qmail_compress_test.c
Platforms
Windows; POSIX branches/dependencies where present. Linux/macOS runtime unverified in M13.
Status
working