This project is not covered by Drupal’s security advisory policy.
Election Archive is a companion module for the Election 3.x framework that manages the long-term cold-storage lifecycle of formal ballots and high-turnout organisational elections.
In large or recurring elections, the election_vote SQL table can grow to millions of rows. Election Archive prevents database bloat by verifying vote hash chains, exporting a self-contained audit package to remote Flysystem storage (such as Amazon S3 / S3 Glacier, Google Cloud Storage, or local archive storage), and only then purging active vote rows in bounded chunks.
Features
- Automated Retention Lifecycle: Configure per-Election-Type retention periods so closed or certified elections are automatically discovered on cron and queued for archiving without duplicates.
- Verify-Before-Purge Safety: Verifies each question's sequential SHA-256 vote hash chain (
H0..Hn) before export (enabled by default; aborts immediately if tampering or a broken chain is detected) and confirms remote archive persistence before deleting activeelection_voterecords. - Remote Storage via Flysystem: Supports any configured Flysystem stream wrapper (e.g.,
s3://archive,gcs://ballots, or a dedicated local scheme) with configurable path prefixes. - Batched & Chunked Processing: Uses Drupal's Batch and Queue APIs with a configurable chunk size (default 500 votes per chunk) to archive and purge large elections without memory spikes or timeouts.
- Clean Active vs. Archived Separation: Separates archived elections into a dedicated Archived Elections view (
/election/archived) with artifact manifest inspection and controlled downloads. - Granular Permissions: Dedicated permissions for configuring archive settings (
administer election archive settings), triggering archiving (archive election entities), and viewing/downloading archived artifacts (access archived election artifacts).
Generated Audit Artifacts
To support independent scrutineers and organisational record-keeping after active vote records are purged, each archived election generates a manifest and three sealed artifact types:
| Artifact | Format | Purpose |
|---|---|---|
| Ballot Tally Data | .blt |
Standard BLT ballot format export for STV and preferential elections, allowing scrutineers to independently re-run counts in external engines (such as Election Condorcet / Condorcet PHP or OpenSTV). |
| Vote Ledger | .json |
Sequential export of every vote's sequence number, single-use token digest, decoupled ballot payload, weight, timestamp, previous hash, and SHA-256 vote hash for verifying hash-chain continuity against witnessed chain heads. |
| Official Result | .pdf |
Human-readable snapshot of the election_result tally and certification metadata with an optional embedded cryptographic signature seal (SHA-256, SHA-384, or SHA-512). |
Requirements
- Drupal:
^11 || ^12 - PHP:
^8.3 - Modules: Election (
^3.0) and Flysystem (^3.0) - Recommended adapter:
league/flysystem-aws-s3-v3(or another Flysystem v3 adapter for off-server cold storage)
Installation
composer require drupal/election_archive drush en election_archive
Configuration
- Configure your target Flysystem scheme in
settings.php(for example, ans3://archivestream wrapper). - Visit Administration > Election > Settings > Archiving (
/admin/election/settings/archive) to set the Flysystem destination prefix, export/purge batch size, hash-chain verification toggle, and PDF sealing options. - Configure retention periods on your Election Types for automated cron-based archiving, or manually archive a closed/certified election at
/election/{election}/archive.
Related Projects
- Election (required core framework, 3.x branch)
- Election Condorcet (STV, IRV, and Condorcet calculation methods)
- Flysystem (required remote filesystem abstraction)
Project information
- Project categories: Import and export
- Ecosystem: Election
- Created by dwkitchen on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
