oliver-zehentleitner / maity
clean-up: G5 jour fixe: the hub's card opening twice, the series upgrade still in every sweep, and slow reads
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) andsetup_cards.py:190-230(insidecreate, the setup cards). - What is wrong: both insert the card row, build
task_view, pick theCREATEDfields, writehistory.created, emittask_createdwith the same payload (withoutbody) 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_createdpayload 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_filethat 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 whoseconfigpredates series. - What is wrong:
file_missingfiles 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.grantfiles 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 inseries_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 byredact_proposal(:225), whichstatement_redacted(:244-272) runs for every proposal drawn from a redacted statement. - What is wrong: it selects every card with
jour_fixeset, in every project, and matches round and proposal in Python. The card of a decided adoption is already inproposal["task_id"]; the card thattriage.settle(jourfixe/triage.py:488-509) opens on a lateradoptis never written back. - Proposal: write
task_idback intriage.settleand read it in_card_of; at the least filter byproject_idand 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) callsreads_roundsper row, which readsowner_agentsandseries.moderatorsagain each time;choices.shown(:178-204) adds_member_rowandopted_outper own agent;choices.tokens(:156-175) addscircle.reads_memberandrounds.wake_now(two queries) per recipient.routes/jour_fixe.overview(:275-303) runschoices.shownfor every series (up to 10) on each load of the jour fixe page, andseries.grantstwice per series (series.sight,series.view).moderators.end_gone(jourfixe/moderators.py:339-377) calls_owneronce per grant on every 30-second pass; itsowner = _owner(conn, member) if member.agent_id else member.human_idrepeats the human case_owneralready handles. - Proposal: read the owner's agents and the moderators once per series and pass them in; one join on
agent_profilefor the owners inend_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 liststriage.py:280but not this one); it goes away with item 2, or joins that helper. - The
routes.tasksimports intriage.open_cardandsetup_cards: tsk-dwrtrhdgzezs. - Searched: open_card, setup_cards, file_missing, upgrade, _card_of.
Effort sum: 4S, about 4 points.