oliver-zehentleitner / maity

clean-up: G5 jour fixe: rules written twice across jourfixe/ (round load, jour_fixe_state, who reads, keepers, answer readers, open-request check)

Sign in to report

tsk-m8g17gh00mzh 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/.

jourfixe/ is 13 modules and 4.1k lines. Each module grew its own copy of a few small rules. None of these items changes behaviour.

1. Loading a round by id: seven copies (duplication)

  • Files: three identical _reload at jourfixe/exchange.py:54-55, jourfixe/triage.py:37-38, jourfixe/redaction.py:36-37; inline at jourfixe/rounds.py:482, routes/jour_fixe.py:183, :717, :759.
  • Proposal: rounds.load(conn, round_id), used by all seven.
  • Effort: S. Risk: none.

2. The jour_fixe_state 409 is built in five places (duplication)

  • Files: jourfixe/exchange.py:45-46 (_state), jourfixe/triage.py:41-42 (the same with step: None), jourfixe/answers.py:74-76 and :171-173 (the same message twice), routes/jour_fixe.py:624-626.
  • Proposal: one state_error(round_row, message, step=None) next to answers.refused; the route's circle_owner_gone passes its own details.
  • Effort: S. Risk: none.

3. "Who reads a round" twice, and "is this the owner's agent" four ways (duplication)

  • Files: circle.reads (jourfixe/circle.py:55-62) and circle.reads_member (:65-73) are one rule, once for a caller and once for a membership row. The owner-agent test is written as circle._owns (:48-52, one query), as series._agent_owner(...) == circle_owner (jourfixe/series.py:94-100, used at :131), as membership in the list circle.owner_agents (jourfixe/choices.py:47, :100), and as its own owner map in rounds._in_circle (jourfixe/rounds.py:273-292).
  • What is wrong: these are access rules (§20.1, §20.7). Four spellings of one test can drift apart.
  • Proposal: reads calls reads_member(conn, round_row, mine.row); one circle.owns(conn, human_id, agent_id) for the single test, owner_agents for the list.
  • Effort: S. Risk: low (access rules; the circle tests cover them).

4. The keepers are computed twice (duplication)

  • Files: series._human_admins and series.keeper_tokens (jourfixe/series.py:175-191) and choices._keepers (jourfixe/choices.py:107-118) both implement §20.1's "the circle_owner, else the humans with project:admin", one as tokens, one as rows.
  • Proposal: series.keepers(conn, series) returns the rows; keeper_tokens and choices use it.
  • Effort: S. Risk: low.

5. The answer readers' admin team is spelled out in SQL beside its helper (rule written twice)

  • Files: redaction._answer_readers (jourfixe/redaction.py:275-299) selects trust in (owner, admin) and role != "proxy", and its docstring says it follows scopes.in_admin_team. answers.answer_reader (jourfixe/answers.py:123-131) calls in_admin_team.
  • Proposal: select the active human memberships and keep those for which in_admin_team(trust, role) holds, so a change of the rule reaches both.
  • Effort: S. Risk: low.

6. "Is this consent request still open" four times (duplication)

  • Files: moderators.withdraw_requests (jourfixe/moderators.py:186-201), moderators._open (:204-208), the loop in moderators.settle (:411-416), and routes/jour_fixe._replay_grant (:251-256). Each selects request.status and compares it with open.
  • Proposal: all use _open, made public for the route.
  • Effort: S. Risk: none.

7. The request summary and the card body are one text built twice (duplication)

  • Files: triage._file_request (jourfixe/triage.py:277-278) and triage.card_body (:382-384) both write "From the jour fixe of <day> (round <id>)." under the reason.
  • What is wrong: redaction.redact_proposal compares a card's body with card_body(...) to tell whether a person edited it, so the builders must stay identical.
  • Proposal: _file_request calls card_body.
  • Effort: S. Risk: none.

8. A post carries kind beside step, with the same value (naming / docs)

  • Files: jourfixe/exchange.py:365 ("step": step["kind"]) and :367 ("kind": step["kind"]). §20.7 (docs/api.md:24753) shows only step, and nothing in hub, cli or web reads a post's kind.
  • Proposal: stop writing kind (and drop it in views.post so old rows read the same), or document it.
  • Effort: S. Risk: low (the round view's shape; pinned by tests).

Covered elsewhere

  • The jourfixe/* imports from routes.requests and routes.tasks: tsk-dwrtrhdgzezs.
  • The hand-written request insert at jourfixe/triage.py:280: tsk-bvw5mk2dbwkp item 1.
  • task_updated at jourfixe/redaction.py:140: tsk-wfmyqaye48m7 item 1.
  • The chat payload copy at jourfixe/exchange.py:139: tsk-qa39qay2gbps. The boundary/sides cost at exchange.py:155,161: tsk-sb4pc3190w20.
  • rounds._handles: tsk-ee3z4rakddq9. The agent-to-owner lookups (series._agent_owner, circle._owns, moderators._owner): tsk-9tj3p6ca30m6 (item 3 here is about the four ways of the owner-agent test, not the query).
  • The inline project_closed refusal at rounds.py:337: tsk-p3a14j8p1rg9.
  • Searched: jourfixe, _reload, jour_fixe_state, reads_member, _keepers, _answer_readers.

Effort sum: 8S, about 8 points.