Generated with the help of an LLM.
Summary
Hi @pjcdawkins,
I think it was the Election module that I first got in touch with you about all those years ago!
I have been working on an election requirement and have already built and tested the complete 3.0.x implementation locally (along with companion modules) and would like to contribute and maintain it under drupal/election rather than fragmenting the ecosystem with a duplicate namespace.
Starting a new dedicated 3.0.x branch allows us to leave 2.0.x-dev untouched for anyone referencing the earlier Drupal 8/9 port while introducing a fully re-engineered, test-covered architecture ready for production statutory and organisational balloting.
Proposed `3.0.x` Architecture & Key Features
Modern Drupal Platform Support:
- Compatible with Drupal
^10.3 || ^11 || ^12and PHP>=8.3. - Strict typing (
declare(strict_types=1)), constructor property promotion / DI, and native PHP 8 attributes (#[ElectionMethod]).
Strict Parent–Child Entity Hierarchy (drupal/child_entity:^2.1):
- Clean, fieldable, revisionable entities with parent-enforced access, forms, and nested routing across
election,election_question,election_candidate(supporting multi-position candidacy),election_constituency,election_elector(decoupled from Drupal user accounts),election_vote, andelection_result.
Tamper-evident & Anonymity (election_vote):
election_voteentities are append-only, tamper-evident (preSave()mutation guards +AccessResult::forbidden()on update/delete for all roles including UID 1), and strictly anonymous (uid = 0with no database foreign keys linking votes toelection_electororusers).- Sequential per-question
SHA-256 hash chain($H_n = \text{SHA-256}(\text{canonical}(V_n), \text{sequence}_n, \text{token\_hash}_n, H_{n-1})$) backed by a compositeUNIQUE (election_question, sequence)database constraint and per-question lock serialization to prevent chain forks. - Streaming (
O(1)memory) hash-chain verification and standard.blt(Ballot) export for independent third-party verification.
High-Concurrency Queueing & Single-Use Token State Machine:
- Atomic single-use token lifecycle (
requested -> issued -> locked -> consumed | voided) preventing double-voting and race conditions during ballot spikes. - Decouples HTTP ballot submission from sequential chain writes using Drupal's Queue API (
election_vote_ingest), plus first-class optional integration withdrupal/advancedqueue(duplicate token fingerprinting, transient lock-failure retries, automatic token voiding on retry exhaustion/DLQ, and Redis/RabbitMQ broker backends).
Audit Trail & Independent Scrutineer Dashboard (`election_result`):
- Stores a Master Result Hash binding the verified vote chain head, vote count, and canonical tally data.
- Dedicated read-only Independent Scrutineer Dashboard (
/election/{election}/scrutineer) for hash-chain checks,.bltexport, voided-token re-issuance, and official result certification.
Extensible `#[ElectionMethod]` Plugin System & Companion Ecosystem:
- Core ships with
election:plurality`(FPTP) andelection:paper_ballot(manual count entry with audit hash). - Companion modules designed to sit alongside
drupal/election: ^3.0: election_condorcet(PHP `>=8.4`, `julien-boudry/condorcet: ^5.0`): Scottish STV, ERS97 STV, IRV, Plurality, and Condorcet counting methods with cross-position candidate redistribution.election_archive: Retention policies per `ElectionType`, Flysystem cold-storage export (`.blt`, verified JSON vote ledger, sealed PDF result snapshots, SHA-256 `manifest.json`), and verify-before-purge SQL vote cleanup.
Proposed Next Steps
- Confirm whether you are open to adding me as a maintainer / transferring maintainership of `drupal/election`.
- Open a `3.0.x` development branch (leaving `2.0.x-dev` undisturbed) and push the initial `3.0.x` codebase via merge request / git for review and green GitLab CI pipelines.
- Publish an alpha/beta release (`3.0.0-alpha1`) for community review, followed by a stable, security-advisory-covered `3.0.0` release.
Issue fork election-3640296
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
liam morland2.0.x is empty so you might as well use it.
Is there a reason to not use
votingapi?If it is being created now, the minimum should be Drupal 11. The minimum PHP version should match Drupal core, which would be PHP 8.3 for Drupal 11.
Comment #3
dwkitchen commented`votingapi` is great for ratings, upvotes, and informal polls, so it definitely makes sense to ask whether we could build on top of it instead of rolling our own vote entity.
The main reason I went with a dedicated `election_vote` entity is that `votingapi` and statutory/formal elections have pretty different goals. So trying to use `votingapi` ends up working against how it's designed:
votingapistoresuser_idandvote_source(like the voter's IP address) directly on the vote record so it can stop duplicate votes or let someone change their mind. For a secret ballot, we really don't want any link between a voter and their cast ballot in the vote table. Instead,election_votekeeps eligibility and double-vote checks in a separate single-use token table, while the saved vote itself is strictly anonymous (uid = 0, no elector ID or IP).votingapiexpects votes to be editable or deletable. For formal elections, once a ballot is cast it needs to be append-only and tamper-evident.election_votelocks down edits/deletes completely and chains each vote to the previous one with a SHA-256 hash and sequence number so an independent scrutineer can verify nothing was altered in the database.votingapiis built around a single numeric score (value) per target entity with aggregate totals like sums and averages. Preferential ballots need a full ordered ranking (e.g. 1st > 2nd > 3rd, or formal abstentions) stored and hashed together as one atomic ballot—which also makes exporting standard.bltfiles for third-party verification much cleaner.election_voteseparates locking a voter's token and pushing the ballot to a queue (Drupal core Queue oradvancedqueuewith Redis/RabbitMQ) from the worker that appends votes to the hash chain, and ties the final tally to a certifiedelection_result.So
votingapiis still the much better fit for likes, star ratings, or casual polls.electionis purpose-built for secret, auditable ballots without having to work aroundvotingapi's schema and mutability model.There was a 2.0.x version written and the merge request is still open - https://git.drupalcode.org/issue/election-3019446/-/tree/3019446-d9-election-maxwellkeeble
While it was never committed into the main repo - there is a 2.0.x version out there - so this should be a 3.0.x branch.
For the main module PHP 8.3 is the requirement, it is only
election_condorcetthat requires PHP 8.4.Comment #4
pjcdawkins commentedLiam, you've been stewarding the 1.x version over 10 years. I think David's offer is valuable and I'd add him as a maintainer, if you are OK with that? I've been working away from the Drupal world but worked with David some years ago and would always vouch for him (and his contributions look evident on his d.o profile).
I have some thoughts on the plan:
* The new version should keep enough configurability so that existing users can 'upgrade' to 3.x and preserve the same process that they had before, maybe not exactly the same and it doesn't need to have an automatic migration process, but the disruption should be minimized. "Feature parity", I suppose? The proposed extensibility and companion modules appear to be aiming in that direction.
* Remember some institutions' electoral processes are weird but not unreasonable, for example, some have rules that allow multiple votes per user, and/or, weight one user's votes higher than another's. And then some use STV (in several flavours), some FPTP, some run referendums, etc.
* I think "Immutability" would be an overstatement, as is "anonymity", or, they should be qualified - as in, someone with enough database access could break both. A classic problem with any electronic voting. Someone asked me to prove an election had or had not been tampered with, I had to point out that any proof is limited.
* Some parts I just haven't understood yet, though I wouldn't block it for that reason. For example, I'm not sure how an elector would be decoupled from a Drupal user account in practice.
* "Statutory" is probably an overstatement too and should be left to the user to decide.
* Drupal 11 as a minimum makes sense.
* .blt isn't related to the British Library of Tapes :)
Comment #5
liam morlandI'm OK with David's offer.
Comment #6
dwkitchen commented@liam-moreland I have just noticed the connection; the original inspiration that brought me back to this module was running elections for my local Scout District Trustee Board in the UK!