oliver-zehentleitner / maity

clean-up: G5 jour fixe: the hub's card opening twice, the series upgrade still in every sweep, and slow reads

Sign in to report

tsk-rxxpbpvsbe4h Open

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G5 Jour fixe, ticker, swarm, Keep the Why and memory), read at 9dfd4b65. Line numbers are at that SHA. Paths are under hub/src/maity_hub/.

1. Opening a card on the hub's behalf is written twice (duplication)

  • Files: jourfixe/triage.py:324-379 (open_card, an adopted proposal) and setup_cards.py:190-230 (inside create, the setup cards).
  • What is wrong: both insert the card row, build task_view, pick the CREATED fields, write history.created, emit task_created with the same payload (without body) and stamp the history. A change to what a created card announces must be made twice.
  • Proposal: one open_card_by_hub(conn, project, fields, created_by, actor, fg) in the cards domain module that tsk-dwrtrhdgzezs step 2 creates; both call it.
  • Effort: S. Risk: low (the task_created payload is pinned by tests).

2. A one-time upgrade still runs every 30 seconds (leftover compatibility path)

  • Files: jourfixe/moderators.py:312-336 (file_missing), called from every schedule pass (jourfixe/rounds.py:667; the worker runs every 30 s, jourfixe/worker.py:18). _file_by_hub (moderators.py:121-172) and the branch of _file that calls it (:118) exist only for it. jourfixe/views.py:138-148 (series_fields) falls back to topic "How we work" and circle "all" for a round whose config predates series.
  • What is wrong: file_missing files the owner consents of the pending grants that the series upgrade left behind (§20.1, docs/api.md:24219-24237). No other path makes a pending grant without an owner request (moderators.grant files it at once), so after the first pass on each hub it finds nothing, yet it runs a join over the project's grants every 30 s per project. The alpha keeps no compatibility layers.
  • Proposal: once every hub has run the upgrade, remove file_missing, _file_by_hub, the hub branch of _file, the fallbacks in series_fields, and the runtime sentence of §20.1 ("the hub files the consent request of every pending grant that has none, at the latest a minute after it starts").
  • Effort: S. Risk: low, given the precondition.

3. redaction._card_of reads every jour-fixe card in the hub (slow path)

  • Files: jourfixe/redaction.py:83-94; called by redact_proposal (:225), which statement_redacted (:244-272) runs for every proposal drawn from a redacted statement.
  • What is wrong: it selects every card with jour_fixe set, in every project, and matches round and proposal in Python. The card of a decided adoption is already in proposal["task_id"]; the card that triage.settle (jourfixe/triage.py:488-509) opens on a later adopt is never written back.
  • Proposal: write task_id back in triage.settle and read it in _card_of; at the least filter by project_id and the two JSON keys in SQL.
  • Effort: S. Risk: low.

4. Per-row queries in the series' choices, the overview and the sweep (slow path)

  • Files: choices.recipients (jourfixe/choices.py:121-132) calls reads_rounds per row, which reads owner_agents and series.moderators again each time; choices.shown (:178-204) adds _member_row and opted_out per own agent; choices.tokens (:156-175) adds circle.reads_member and rounds.wake_now (two queries) per recipient. routes/jour_fixe.overview (:275-303) runs choices.shown for every series (up to 10) on each load of the jour fixe page, and series.grants twice per series (series.sight, series.view). moderators.end_gone (jourfixe/moderators.py:339-377) calls _owner once per grant on every 30-second pass; its owner = _owner(conn, member) if member.agent_id else member.human_id repeats the human case _owner already handles.
  • Proposal: read the owner's agents and the moderators once per series and pass them in; one join on agent_profile for the owners in end_gone.
  • Effort: S. Risk: low.

Order

  • Item 1 after tsk-dwrtrhdgzezs step 2, which creates the module it belongs in.

Open question

  • Item 2: has every hub (prod and any self-hosted one) run the series upgrade, so the runtime part may go?

Covered elsewhere

  • The request insert in _file_by_hub (jourfixe/moderators.py:137) is one more copy of the insert that tsk-bvw5mk2dbwkp item 1 collects (it lists triage.py:280 but not this one); it goes away with item 2, or joins that helper.
  • The routes.tasks imports in triage.open_card and setup_cards: tsk-dwrtrhdgzezs.
  • Searched: open_card, setup_cards, file_missing, upgrade, _card_of.

Effort sum: 4S, about 4 points.