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)
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
_reloadatjourfixe/exchange.py:54-55,jourfixe/triage.py:37-38,jourfixe/redaction.py:36-37; inline atjourfixe/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 withstep: None),jourfixe/answers.py:74-76and:171-173(the same message twice),routes/jour_fixe.py:624-626. - Proposal: one
state_error(round_row, message, step=None)next toanswers.refused; the route'scircle_owner_gonepasses 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) andcircle.reads_member(:65-73) are one rule, once for a caller and once for a membership row. The owner-agent test is written ascircle._owns(:48-52, one query), asseries._agent_owner(...) == circle_owner(jourfixe/series.py:94-100, used at:131), as membership in the listcircle.owner_agents(jourfixe/choices.py:47,:100), and as its own owner map inrounds._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:
readscallsreads_member(conn, round_row, mine.row); onecircle.owns(conn, human_id, agent_id)for the single test,owner_agentsfor the list. - Effort: S. Risk: low (access rules; the circle tests cover them).
4. The keepers are computed twice (duplication)
- Files:
series._human_adminsandseries.keeper_tokens(jourfixe/series.py:175-191) andchoices._keepers(jourfixe/choices.py:107-118) both implement §20.1's "thecircle_owner, else the humans withproject:admin", one as tokens, one as rows. - Proposal:
series.keepers(conn, series)returns the rows;keeper_tokensandchoicesuse 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) selectstrust in (owner, admin)androle != "proxy", and its docstring says it followsscopes.in_admin_team.answers.answer_reader(jourfixe/answers.py:123-131) callsin_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 inmoderators.settle(:411-416), androutes/jour_fixe._replay_grant(:251-256). Each selectsrequest.statusand compares it withopen. - 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) andtriage.card_body(:382-384) both write "From the jour fixe of <day> (round <id>)." under the reason. - What is wrong:
redaction.redact_proposalcompares a card's body withcard_body(...)to tell whether a person edited it, so the builders must stay identical. - Proposal:
_file_requestcallscard_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 onlystep, and nothing in hub, cli or web reads a post'skind. - Proposal: stop writing
kind(and drop it inviews.postso 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 fromroutes.requestsandroutes.tasks: tsk-dwrtrhdgzezs. - The hand-written request insert at
jourfixe/triage.py:280: tsk-bvw5mk2dbwkp item 1. task_updatedatjourfixe/redaction.py:140: tsk-wfmyqaye48m7 item 1.- The chat payload copy at
jourfixe/exchange.py:139: tsk-qa39qay2gbps. Theboundary/sidescost atexchange.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_closedrefusal atrounds.py:337: tsk-p3a14j8p1rg9. - Searched: jourfixe, _reload, jour_fixe_state, reads_member, _keepers, _answer_readers.
Effort sum: 8S, about 8 points.