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 || ^12 and 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, and election_result.

Tamper-evident & Anonymity (election_vote):

  • election_vote entities are append-only, tamper-evident (preSave() mutation guards + AccessResult::forbidden() on update/delete for all roles including UID 1), and strictly anonymous (uid = 0 with no database foreign keys linking votes to election_elector or users).
  • 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 composite UNIQUE (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 with drupal/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, .blt export, voided-token re-issuance, and official result certification.

Extensible `#[ElectionMethod]` Plugin System & Companion Ecosystem:

  • Core ships with election:plurality`(FPTP) and election: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

  1. Confirm whether you are open to adding me as a maintainer / transferring maintainership of `drupal/election`.
  2. 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.
  3. 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

Command icon 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

dwkitchen created an issue. See original summary.

liam morland’s picture

Title: 3.0.x branch (Drupal 10.3 / 11 / 12) and maintainer offer » 2.0.x branch (Drupal 10.3 / 11 / 12) and maintainer offer

2.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.

dwkitchen’s picture

Title: 2.0.x branch (Drupal 10.3 / 11 / 12) and maintainer offer » 3.0.x branch (Drupal 10.3 / 11 / 12) and maintainer offer

`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:

  • Secret ballots vs. tracking who voted: votingapi stores user_id and vote_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_vote keeps 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).
  • Immutability & audit trail: votingapi expects votes to be editable or deletable. For formal elections, once a ballot is cast it needs to be append-only and tamper-evident. election_vote locks 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.
  • Ranked ballots (STV / IRV / Condorcet): votingapi is 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 .blt files for third-party verification much cleaner.
  • Queueing under election-day load: Rather than writing and recalculating tallies synchronously on submit, election_vote separates locking a voter's token and pushing the ballot to a queue (Drupal core Queue or advancedqueue with Redis/RabbitMQ) from the worker that appends votes to the hash chain, and ties the final tally to a certified election_result.

So votingapi is still the much better fit for likes, star ratings, or casual polls. election is purpose-built for secret, auditable ballots without having to work around votingapi'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_condorcet that requires PHP 8.4.

pjcdawkins’s picture

Liam, 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 :)

liam morland’s picture

I'm OK with David's offer.

dwkitchen’s picture

Issue summary: View changes

@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!

  • I will look at providing an upgrade path, but d.o is only reporting 28 installs ATM
  • I'll create a FR for the multi/weighted votes for future investigation. All the STV variants are covered by https://github.com/julien-boudry/Condorcet
  • I've got my AI assistant to tone down the immutable language, tamper-evident is a better description. It would be possible for someone with the right access to rebuild the chain. I have looked at some options and will create a further FR that might help solve this.
  • The OG post didn't mention Decoupled User Authentication, which is part of this. Again someone with full access could reconcile timestamps from the vote consumption and vote cast tables to identify the elector.
  • I'll drop the 10.3 support
  • AI can still hallucinate! - I even gave it a README to write the post with.