8000 fix(huddl)!: keep a recurring series within its own group by mwoods79 · Pull Request #724 · huddlz-hq/huddlz · GitHub
[go: up one dir, main page]

Skip to content

fix(huddl)!: keep a recurring series within its own group - #724

Merged
mwoods79 merged 28 commits into
mainfrom
t3/secure-series-membership
Dec 1, 2026
Merged

mwoods79 merged 28 commits into
mainfrom
t3/secure-series-membership

Conversation

@mwoods79
@mwoods79 mwoods79 commented Nov 30, 2026 •
Copy link
Copy Markdown
Contributor

Summary

A recurring series belongs to the group that started it. New series require a group. For existing series, the migration matches a retained generation job to the starting huddl’s creation snapshot. When the evidence identifies one surviving group, the migration stores it. When the evidence is missing or conflicts, the series keeps its links and every linked huddl reads as a one-off.

Organizer pages, the sitemap, announcements, generation and whole-series edits use the stored group. JSON:API and GraphQL no longer accept a series id as a public huddl input.

Evidence

  • Before: a series could follow a huddl into another group. After: a huddl outside the stored home appears as a one-off. Its organizer can edit it individually, and its attendees receive an ordinary update.
  • Before: a queued series update could outlive access to one of its dates or its group. After: email delivery checks every date named in the queued payload. If all are accessible, current membership decides the wording, attachments and email preference. An unavailable target appears as “Huddl update” in the inbox with no details or link.
  • Before: a queued announcement for a detached date could appear as “New series” after all retries failed. After: Recent Posts records “When published” for that one-off.
  • Populated migration: 50,022 huddlz, 20 series and 22 attendance rows. Up, repeated up, down and final up took 85.0, 47.3, 25.1 and 85.3 ms respectively, including commit. Nineteen homes were established. Both owner queries identified the same unknown series and its two carriers. Attendance, all other huddl fields, and the settled homes and links matched after the cycle.

Merge Danger

Door: one-way

Blast Radius: Data

Up clears links to a series outside its proven home. Down drops every stored home. Cleared links stay cleared. A later up can recover only homes whose generation job and founding snapshot still exist. This includes series whose last huddl has been deleted.

The migration scans creation history and retained generation jobs, updates links, indexes the stored group and validates foreign keys. These operations take table locks. Deleting a group removes its stored series. A huddl detached from a series retains its RSVPs, waitlist, cover and schedule.

Before deployment, this query lists series whose homes the migration cannot establish. Their huddlz stop recurring until the homes can be independently confirmed.

WITH origins AS (
  SELECT v.changes->>'huddl_template_id' AS series_id,
         min(v.changes->>'group_id')::uuid AS group_id
  FROM huddlz_versions v
  WHERE v.version_action_type = 'create'
    AND v.changes->>'huddl_template_id' IS NOT NULL
    AND EXISTS (
      SELECT 1 FROM oban_jobs j
      WHERE j.worker = 'Huddlz.Communities.Workers.RegenerateRecurringSeries'
        AND j.args->>'huddl_id' = v.version_source_id::text
    )
  GROUP BY v.changes->>'huddl_template_id'
  HAVING count(DISTINCT v.changes->>'group_id') = 1
)
SELECT t.id, count(h.id) AS carriers
FROM huddl_templates t
LEFT JOIN origins o ON o.series_id = t.id::text
LEFT JOIN groups g ON g.id = o.group_id
LEFT JOIN huddlz h ON h.huddl_template_id = t.id
WHERE g.id IS NULL
GROUP BY t.id ORDER BY t.id;

After deployment, this query lists series still awaiting confirmation and their carrier counts.

SELECT t.id, count(h.id) AS carriers
FROM huddl_templates t
LEFT JOIN huddlz h ON h.huddl_template_id = t.id
WHERE t.group_id IS NULL
GROUP BY t.id ORDER BY t.id;

Which series a huddl belongs to is set by the series code alone: when a
recurring huddl is created and when its dates are generated. Creating or
updating a huddl no longer takes a series as input, on any interface.

Editing a whole series reads only the edited huddl's own group, so the
edit stays inside that group whatever series the huddl carries.

BREAKING CHANGE: the API no longer accepts huddl_template_id when
creating or updating a huddl.
A series has no group of its own, so a huddl that already carries another
group's series could still rewrite that series' schedule with a whole-series
edit, even though the other group's huddlz were out of reach.

- a whole-series edit is refused while the series has huddlz in another group
- the generation worker skips such a series
- series announcements are deduplicated within the huddl's group
- the regression test now checks the series' own schedule
Scope each HuddlTemplate to a single owning group and filter Huddl's
belongs_to :huddl_template relationship to group_id == parent(group_id).

- Backfill huddl_templates.group_id, detach any huddl carrying another
  group's series as a one-off, and remove unreferenced empty templates
- Authorize HuddlTemplate reads directly against its owning group
- Validate internally passed series_template_id belongs to the huddl's group
- Scope virtual time-zone lookup to the huddl's own group
- Remove cross-group series guards now enforced by the relationship filter
…ership

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
The migration picked a series' group by counting the huddlz that carry it.
The only way a series came to span groups was a huddl being attached to
another group's series, so the count let the attached huddlz outvote the
series they joined and turn its own dates into one-offs.

The audit history records the first huddl being created with its series.
That huddl's group is now the home. The count remains for a series with no
such record. A series whose group is gone is removed, and a huddl that
carried it becomes a one-off like any other detached huddl.

- Run the migration in a test against rows as they could stand before it:
  the home it picks, what a detached huddl keeps, and a second run
The edit form and the organizer's huddlz list decided whether a huddl
recurs from the id on its row, then read the schedule from the series. A
huddl's series is read through its own group, so a row naming a series its
group does not have has none, and the pages now treat it as the one-off it
is instead of failing on the missing schedule.

- Cover the organizer's list, the edit form and the copy notice for a
  huddl whose row names another group's series
Rewrite the series-and-group tests around the rule itself: a series
belongs to the group of the huddl that started it, and a huddl whose row
names another group's series has none. They now also cover the series
announcement, the series' own edits leaving such a huddl alone, and who
reads a private group's series.

- Read a series by its group's members; the owner is one of them
- Put the whole-series change back as it is on main: the group check it
  was restructured around is gone
- Drop the whole-series test this file duplicates
- Define a recurring series in the glossary
Neither the series' update nor the huddl's accepts a group, so the two
cannot drift apart after they are written. Say so in a test.
…ership

* origin/main:
  fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
The relationship filter looks redundant next to the rule that a series
and its huddlz share a group. Record that it is the read-side half of that
rule, which no database constraint backs.
…ership

* origin/main:
  fix(auth): bind administrator viewing credentials to the browser session (#736)
The migration read the earliest creation record naming a series as proof
of where the series started. Where a series' own huddlz predate the audit
history and a later huddl in another group was created into it, that
record was the later huddl's, and the series went to the wrong group.

A record now settles the home only when it is the creation of the series'
first huddl, the earliest added of the huddlz carrying it. Otherwise the
group holding most of the series' huddlz takes it; groups level on that
go by whose huddl was added first, then by group id. A huddl whose own
record shows it was created outside the series joined it afterwards, and
is neither its first huddl nor counted.

- Cover the partial history, a tie, later huddlz created into a series
  and an older huddl attached to one
The release command migrates before the new servers take traffic, and the
migration made a series' group required by the column. Servers still
running the release before start series without a group, so every series
started during a rollout failed on them.

The column is now optional and the rule lives in the application: the
series' create action requires a group, and nothing else writes one.

A series an old server starts in that window has no group, and until it
has one no huddl reads it; its dates would never be generated if a new
server picked up the job. Reading any series now first gives each such
series its home, by the migration's rule, and removes one none of whose
own huddlz is left.

- Cover a series started without a group: its home on first read, its
  dates being generated, a huddl of another group naming it, and removal
Three readers still took a huddl for part of a series whenever its row
named one. A row can name a series its group does not have: one written
before the two were kept together, or by a server of the release before
while this one rolls out. That huddl is a one-off, but:

- publishing it planned a series announcement, and a second such huddl in
  the group lost its own to the once-per-series rule
- its delete dialog spoke of other occurrences
- the sitemap left it out beyond the recurring window

All three now ask whether the huddl is in a series of its own group: a new
in_series calculation over the group-scoped relationship, the relationship
itself where the announcement is planned, and the same join in the
sitemap's SQL. The read of a series' later huddlz and the once-per-series
check ask it of every huddl they match as well, so neither can take a
one-off naming the series for one of its dates.

- Build the migration test's huddlz before the schema is rolled back:
  creating one now reads its series
A series whose own group was gone still passed to another group when one
of that group's huddlz had been created into it: with the series' own
huddlz deleted, that huddl was the earliest left and its creation record
was read as the series' start.

The start is now the earliest creation record naming the series, whether
or not that huddl still exists, and it counts only when no huddl carrying
the series without a record was added before it. Its group is the home;
if that group is gone the series has none and is removed. A series whose
huddlz are all gone stays with the group that started it.

The rule for a series written without a group during a rollout is the
same text, so it changes with it. One statement cannot both update and
delete a row, so each home is worked out first and only series that get
one are updated.
…ership

* origin/main:
  fix(groups): authorize membership changes against their roster (#739)
…ting

The home pick read the audit history and deleted series, and a series
written without a group was repaired by a write on whatever read came
first. Both were too clever:

- the migration deleted a series that still had dates, and a roll back
  and forward moved an already-settled home
- a valid series started by a server of the release before read as a
  one-off until something repaired it
- reading one group's huddl wrote another group's series, and failed
  outright in a read-only transaction

A series' home is now the group of the earliest-created huddl that carries
it, ties broken by the huddl's id. The huddl that starts a series is
created with it and its later dates after it in the same group, so that
is the group it started in. No audit history, and nothing is deleted.

- Migration: store that group, then make a one-off of each huddl in any
  other group. A series no huddl carries is left alone, without a home.
  The earliest huddl is never detached, so up, up again, and down then up
  all pick the same home.
- HuddlTemplate.home_group_id is the stored group, or the same rule in SQL
  for a series stored without one. The huddl's series, in_series, the
  later-dates read, the read policy, the sitemap and the checks on
  generated dates all compare a huddl's group with it. A series written
  without a group is its first huddl's group's for every reader at once.
- HuddlTemplate.Homes and its preparation are gone. Reads never write.
- Index huddlz by series and creation order: it finds the earliest huddl,
  and serves the later-dates read and the series' foreign key.
Two readers of such a series were only reached indirectly: the time zone
a huddl takes from its series when it moves online, and the text of the
series announcement once it is delivered. Cover both, and check after
the page and sitemap reads that nothing was stored on the series.
* origin/main:
  fix(auth): have open pages follow a change of access (#735)
* origin/main:
  fix(auth): revoke reset links when the email address changes (#732)
  fix(notifications): notify only people who can open the huddl (#731)
  fix(groups): hold a group's slug to one rule whenever it is set (#742)
  fix(huddl): copy only huddlz the actor can organize (#723)
@mwoods79
mwoods79 merged commit a634df3 into main Dec 1, 2026
5 checks passed
@mwoods79
mwoods79 deleted the t3/secure-series-membership branch December 1, 2026 21:21
mwoods79 added a commit that referenced this pull request Dec 1, 2026
…recipients

* origin/main:
  fix(huddl)!: keep a recurring series within its own group (#724)
  fix(social): send huddl details as literal text (#737)
  fix(auth)!: require a sign-in to manage API keys (#733)
mwoods79 added a commit that referenced this pull request Dec 1, 2026
…eaders

* origin/main:
  fix(photos): follow the current organizer role for huddl photos (#746)
  fix(api): keep restricted fields out of sorting and filtering (#744)
  fix(huddl)!: keep a recurring series within its own group (#724)
mwoods79 added a commit that referenced this pull request Dec 1, 2026
* origin/main:
  fix(admin): limit what viewing as someone can do (#749)
  fix(groups): bind invitations only to accounts with a confirmed address (#728)
  fix(photos): follow the current organizer role for huddl photos (#746)
  fix(api): keep restricted fields out of sorting and filtering (#744)
  fix(huddl)!: keep a recurring series within its own group (#724)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0