Repository navigation
fix(election-config): TEST elections carry their Post's permission label (meta#15602) (ovcs) - #4680
Merged
Merged
Conversation
…bel (meta#15602) (ovcs) A TEST election carries the same permission label as its Post, never a separate <LABEL>-TEST. Enrollment binds the voter to the area only. - sequent-core: twin_label copies the official election's label; revert the <LABEL>-TEST admin grant from #4669 (test_label_grants/admin_labels). WASM tgz regenerated. - windmill: package check test_election_label_problems (blocker) and the importer refuse a TEST election whose label is not its Post's; drop the #4649 -TEST import rules and label-holder lookup. - migration: deferred constraint triggers on election and area_contest enforce the rule for Hasura/Admin Portal edits. - tests: core, windmill checks, harvest readiness label check, Keycloak mapper enrolled-voter visibility. Docs: rule and detection query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
Conflicts only in the committed sequent-core WASM tgz and yarn.lock: regenerated with the official nix recipe on the merged sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s message (meta#15602) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edulix
added a commit
that referenced
this pull request
Dec 3, 2026
Restores code that the squash of #4680 (3a08ae0) reverted on `ovcs`. **Cause.** #4680 merged ovcs (335506a) into its branch in feab331. That merge resolution kept the branch's older copies of 49 files, and the squash then applied those older copies to ovcs. The reverted work: - **#4563** tenant reset (the administration tenant's reset keeps or deletes other tenants, Gold, b4 bodies and custom URLs): `tenant_reset/*`, `reset_tenant.rs`, `delete_tenant.rs`, `delete_election_event.rs`, `custom_url.rs`, `cloudflare.rs`, `TenantResetCard*`, translations, devcontainer compose, tests. - **#4682** Statistical Report, bulk Post vote receipts, audit-log hash-chain check: `reports/*`, electoral-log adapters and tests, report templates, Tabs, docs. - **#4683** Voters list default columns: `voterDefaultColumns*`, `ListUsers.tsx`, COMELEC `keycloak.hbs` annotations. #4684–#4687 were not affected; the squash's 3-way merge kept them. **Fix.** - The 49 files are restored byte-for-byte from `3a08ae0^` (cfd675a). None of them carried #4680 changes. - #4680's own changes (label rules, migration, checks, tests, docs) are unchanged. The tree equals cfd675a plus #4680's own commits bac670c and 8af66ee, except the tgz. - The sequent-core WASM tgz files and yarn.lock are regenerated: electoral-log, which this PR restores, is one of the package's inputs. Built with rustc 1.96.0, wasm-bindgen 0.2.128 and wasm-opt 123. **Checks.** - `scripts.dev.wasm --check-package` passes. - `cargo check -p electoral-log -p windmill -p harvest --tests` passes. meta#15602 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Findeton
added a commit
that referenced
this pull request
Dec 3, 2026
…ovcs) (#4703) Parent: sequentech/meta#15602 (follow-up to #4680) ## Failure The `Tests` run on ovcs `3a08ae0d6` (run 47086055592) failed in **Run Windmill tests**. The job is still open at `postgres_ballot_box_seal_chain::a_closed_box_is_sealed_published_verified_and_counted_from_its_seal`: ``` SqlState(E42703) "column t.alias does not exist" where: PL/pgSQL function sequent_backend.check_test_election_post_label() line 14 ``` ## Root cause Migration `1796240000000_election_test_post_label` from #4680 selects `election.alias`. Migration `1772358027729_alias_to_external_id_…` renamed that column to `external_id`. PL/pgSQL resolves column names only at run time, so creating the function succeeds. The deferred constraint triggers then fail at **commit** on every election insert, `permission_label`/`annotations` update, and `area_contest` write. Admin Portal and importer writes hit this too, not only the test. Rollback-only adapter tests never fire the check, so only the commit-path seal-chain test caught it. ## Change - New forward migration `1796250000000_election_test_post_label_external_id` runs `CREATE OR REPLACE FUNCTION` with `alias` replaced by `external_id`. Nothing else changes (verify with word-diff). Environments that already applied `1796240000000` pick up the fix. Down is a no-op. - Regression `windmill/tests/postgres_election_test_post_label.rs` runs the deferred check early (`SET CONSTRAINTS ALL IMMEDIATE`, then rolls back): - a twin with the Post's label passes - a `-TEST`-labelled twin gets `check_violation`, and the message names its `external_id` ## Validation - Static: the migration diff is limited to `alias` → `external_id`. The columns it uses come from existing migrations. - CI: the Windmill tests job, which needs Postgres. Not run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
edulix
added a commit
that referenced
this pull request
Dec 4, 2026
… TEST elections included (meta#15631) (ovcs) (#4721) Parent issue: sequentech/meta#15631 (rc.49 tracker sequentech/meta#15576) ## Context On rc.48, the tenant **Electoral Log** console answered 403 "Election outside the user's permission labels" and showed "No columns" when the Admin left the Election filter empty. The cause was `electoral_log_console.rs` `event_board`, which always called `authorize_election_permission_labels(.., None)`. That check requires the caller's labels to reach every election of the event, even when the page is filtered by one election. On ovcs-server the admin holds BANGKOK, CANBERRA, HONGKONG and MELBOURNE, but event 2ff5dec8 has four TEST elections labelled `<LABEL>-TEST`, so every read was refused. #4677 did not cause it: the console code was unchanged from rc.48. **#4708, already merged on ovcs, fixes this.** - With an Election filter, only that election's label is checked. - A record opened from that page is checked the same way. - Without a filter (the event-wide view), the page still needs every label. The 403 names each election it cannot reach, with its label, and says "Choose an election". - The grid keeps the table's columns when a read fails. #4680 makes TEST elections carry their Post's label, so an admin holding every Post's label can now browse the whole event. ## This PR: a regression test only `an_admin_of_every_post_browses_the_whole_event_with_its_test_elections` (harvest DB route test) rebuilds the rc.48 event's shape: an official election and a TEST twin per Post (`annotations.test_copy_of`, the same label, on the Post's area), with ballots and a record. - An admin labelled with every Post reads records, ballots, voters and the queue event-wide, with no election chosen. - An admin of one Post gets a 403 event-wide. The 403 names the other Post's official and TEST elections, never their own, and asks to choose an election. That admin then reads each of their own Post's elections (official and TEST) alone, and is refused the other Post's TEST election. ## Tests run (arm64, docker: `step-backend-e2e-cargo-packages:local`, postgres:18) - `cargo test -p harvest --lib -- electoral_log_console permission_label_tests`: 26 passed, 0 failed. This covers the new test and #4708's route tests, which its PR could not run locally. - admin-portal `jest src/services/ElectoralLogConsole.test.ts`: 9 passed (#4708's `pageColumns` test). - `rustfmt` with the harvest config on the changed file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parent issue: https://github.com/sequentech/meta/issues/15602 (reopened; rc.49 tracker sequentech/meta#15576)
Rule
A TEST election carries the same permission label as its Post, for example
BANGKOKand notBANGKOK-TEST. Separate TEST labels no longer exist. Enrollment binds a voter to the area/label only and never to a specific election. This supersedes the<LABEL>-TESTlabels from #4649 and the admin grant of them from #4669. The #4669 voter change stays: SQL-dump official voters get noauthorized-election-ids, and their area decides.Root cause
sequent-core/src/election_config/historical.rstwin_label(from 🐞 Configuration: ERT test twins are labelled <LABEL>-TEST (ovcs) #4649) wrote<LABEL>-TESTon every ERT test twin. The Architect build, the historical conversion and the package generator all go through it.build_realm.rstest_label_grants/admin_labelsandbuild_tables.rs(from fix(election-config): Post admins see TEST elections; voter restrictions keep the TEST twin (meta#15602) (ovcs) #4669) only gave<LABEL>-TESTto admins written in a newly built package. The admin on ovcs-server holds only the plain labels, so readiness (harvest/src/routes/readiness.rs:93-116→ensure_elections_permitted) returned 403 "Election outside the user's permission labels".ovcshad fixed this before this PR (origin/ovcs3d6a76eb1ff).Changes
Package generator (sequent-core, WASM-relevant)
twin_label: a twin copies its official election's label, trimmed and atomic. The-TESTrefusal on official labels is gone.<LABEL>-TESTadmin grant (test_label_grants,admin_labels, theadmin_users.csvrewrite and its test).TEST_TWIN_LABEL_SUFFIXis still read, byelection_postand windmillpost_scope, so data imported before this change keeps its Post.nixos/nix:2.28.3).yarn install --frozen-lockfile --ignore-scriptspasses on node:22.Package/import check (
windmill/src/services/import/configuration_package_checks.rs, the #4623 area)test_election_label_problems. A TEST election (annotations.test_copy_of) whose label is not its Post's label is a blocker. The Post's label is the label of the official elections that share an area with it, so<LABEL>-TEST, a missing label and another Post's label are all refused.Importer (
import_election_event.rsprocess_election_event_file)Removed import rules from #4649 that the new check replaces:
reserved_test_twin_labels,test_label_scope_problems,test_label_collision_problems,official_test_labels,official_label_collision_problems,postgres::election::get_label_holders/LabelHolder, andtests/postgres_test_label_collisions.rs. These refused a-TESTlabel on non-TEST elections.test_twin_label_problems(one atomic label) stays.Election create/edit (Hasura and Admin Portal): migration
1796240000000_election_test_post_labelDEFERRABLE INITIALLY DEFERREDconstraint trigger onelection(INSERT, or UPDATE ofpermission_label/annotations) and onarea_contest(INSERT/UPDATE). The check runs at commit, so a multi-row mutation or an import can relabel a whole Post in one go.harvest /create-electionsets no label, so it cannot mismatch.Docs: the election Data reference ("TEST Elections Carry Their Post's Label") explains the rule and gives the detection query.
Enrollment binds only the area (checked, no code change)
authorized-election-ids.windmill/src/services/application.rsonly readsarea-id. Keycloak'sVoterChannels.java:61only reads the attribute.keycloak-extensions/conditional-authenticators/.../AuthorizedElectionsUserAttributeMapper.java:161-213:authorized-election-idswins.area-id→getElectionsByArea, which readssequent_backend_area_contest→contest.election_id(:428-500).area_idand those election ids (windmill/src/postgres/ballot_style.rs:112-150), andsequent-core/src/services/authorization.rs:155-200checks the requested election against the token's list.historical::add_test_twinscopies everyAreaContestslink to the twin's contests, so the Post's area holds both elections. After fix(election-config): Post admins see TEST elections; voter restrictions keep the TEST twin (meta#15602) (ovcs) #4669, SQL-dump official voters carry noauthorized-election-ids.Tests
historical::tests::a_test_twin_carries_its_official_elections_label,an_official_label_is_copied_to_its_twin_as_written, andert_twins_carry_their_posts_label_and_grant_no_administrator_anything. The last builds a full package with an official and a TEST election per Post and asserts that both carry the Post's label.cargo test --lib --features election_config_xlsx,election_config_archive,election_config_templates -- election_config::→ 1731 passed, 0 failed (after merging ovcs23c9bd24f8d).configuration_package_checks_tests:a_test_election_with_its_posts_label_passesa_test_election_with_a_label_of_its_own_is_a_blocker(-TEST, another Post's label, no label)only_a_test_election_is_held_to_its_posts_labelthe_event_archive_check_blocks_a_test_election_labelconfiguration_package_sections_testscargo test --lib -- services::import::configuration_package_checks services::import::configuration_package_sections services::post_scope→ 67 passed, 0 failed.permission_label_tests::readiness_authorizes_a_posts_admin_on_both_events_with_same_label_tests. This is the checkauthorize_eventsruns for each event. An admin holding onlyBANGKOK|CANBERRA|HONGKONG|MELBOURNEis authorized on both 8-election events. The legacy-TESTlabels reproduce the 403. A one-Post holder such as trustee3 is still refused. Result:cargo test --lib -- permission_label_tests→ 8 passed (after merging ovcs).AuthorizedElectionsUserAttributeMapperTest.setClaim_enrolledVoterOfAPostAreaGetsItsOfficialAndTestElections. A voter left only witharea-id(andembassy) by enrollment gets the Post's official and TEST elections. Result:mvn -pl conditional-authenticators -am test -Dtest=AuthorizedElectionsUserAttributeMapperTest(maven:3.9-eclipse-temurin-21) → 9 run, 0 failures.-TEST, relabelling only the official election, or unlabelling the twin is refused with the message above. Relabelling both in one transaction commits. The detection query lists the mismatched pair.Detection query (any server)
It lists every election of an area whose elections carry more than one label. On ovcs-server today it should list the 24 elections (12 official, 12 TEST) of the Post areas in the three events. Areas that legitimately serve several Posts are listed too.
Fixing the existing data on ovcs-server (not run; Eduardo approves)
Tenant
90505c8a-23a9-4cdf-a26b-4e19f6a097d5. A read-only count found-TESTelections in three events, 4 of 8 elections each:2ff5dec8-8b2d-4c1c-ac32-704cf3c44207e56903a1-ff2f-4e40-adf3-56a59ada000c3b66138a-9020-4fa0-8b92-8da4ea564a06The relabel covers the whole tenant: every election whose label ends in
-TESTgets its Post's plain label. Run it inpsqlagainst the Hasura backend database, in one transaction.The same relabel as a Hasura GraphQL mutation (admin secret /
adminrole), for the elections only. Step 3 still needs the SQL.Each alias should report
affected_rows: 3, one per event. If the preview in step 1 shows a-TESTlabel other than these four, add an alias for it.Which side tables can carry
-TEST(the step 3 cleanup covers all of them tenant-wide):keys_ceremony.permission_label: yes. It is the set of the covered elections' labels at creation (keys_ceremony.rsunique_permission_labels).tally_session.permission_label: yes. It is the set of the tallied elections' labels (tally_ceremony.rs:618-646). The ERT event's completed tally covers its TEST elections, so expect it to hold<LABEL>-TEST.applications.permission_label: unlikely. It is the Post label frompost_scope::post_label, which prefers the official<LABEL>when the area has both. It could only be-TESTin an area that holds only TEST elections.signing_request.permission_label: unlikely. It is the Post label fromget_signing_post(signing/guard.rs:306-317), which uses the same rule. The ERT requests HHW3-5Z1E, A98C-VDGH and 7VV9-R6RF already carryBANGKOK.Safe after tally? Yes. Relabelling after the tally changes who can see rows. It changes no stored result, signature, hash or log entry:
results_*tables store no label. Hasura filters them throughelection.permission_label(sequent_backend_results_election.yaml). After the relabel,BANGKOKadmins see the ERT TEST results, which is the intent. Ballot styles and the tally inputs carry no label.template_renderer.rs:1690setspermission_label: None). The PDFs and their signatures are unchanged.BANGKOK), and the label is not signed (migration1796050000000_signing_legacy_post_configuration_labels: "The label is not signed, and no trigger watches it"). Signers are matched withsigns_for(request.permission_label), so the executed requests keep their authorization and signatures.transmission_readiness.rs:242uses it only to name a problem record.tally_sessionandkeys_ceremonyrows that still hold<LABEL>-TESTwould stay hidden from, or fail the label-coverage check for, admins and trustees holding only<LABEL>. Step 3 fixes them in the same transaction.Safe order: run steps 1–4 in one transaction. It can run before or after the upgrade that brings this PR's migration. After the upgrade, the deferred trigger refuses saving a legacy
-TESTelection's label or annotations until it is relabelled. Run the relabel right away either way.After the relabel
<LABEL>-TESTlabel on a user now matches nothing.BANGKOK,CANBERRA,HONGKONG,MELBOURNE). A one-Post user such as trustee3 (BANGKOKonly) still gets 403 there. That is the expected per-Post scoping, so run event-wide actions as an admin who holds all four.Release note
<LABEL>-TESTlabels are no longer generated or granted.1796240000000_election_test_post_labeladds a deferred constraint trigger. Writes to a legacy-TESTelection are refused at commit until the election is relabelled to its Post's label: changing itspermission_labelorannotations, or adding an area link. Other columns (status, dates) are not affected. Existing tenants should run the detection query and the relabel above after upgrading.Not changed
readiness.rs, which another agent owns. Only a test was added, at theensure_elections_permittedlevel.After merge
Bump beyond's step pin so the Architect builds TEST elections with the Post label. Then fix ovcs-server with the SQL above, or re-import the package.
🤖 Generated with Claude Code