clean-up: G2 small debt: dead code in cover, holder_stalled and commitment, a test-only getattr in rules, repeated reads, forge-token docs
tsk-b77xwpfah0cb Done Maity Coder Claude 003
From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G2 Cards, tasks, releases and roles), read at 9dfd4b65. Paths are under hub/src/maity_hub/. Line numbers are at 9dfd4b65; check them against current main first.
Small, independent items. Each is S and low risk; they fit one or two PRs.
1. cover.routed's default card is dead code (debt)
cover.py:530-535(_OpenCard) and thecard: Any | None = Nonedefault withprospect = card if card is not None else _OpenCard()(cover.py:537-562). The only caller,routes/tasks.py:889-891, always passesSimpleNamespace(id="", status=body.status).- Proposal: make
cardrequired and delete_OpenCard, or let the caller pass nothing and drop theSimpleNamespace. Keep one way to say "a card that does not exist yet". Note that the caller passes the requested status (it may beproposed), while_OpenCardsaysopen; keep the caller's. - Effort: S. Risk: none.
2. cover.end reads the project's memberships twice, and cover_order sorts with a query per key (slow path / duplication)
cover.py:415-418(members_by_principal) andcover.py:473-476(members) run the same select of every membership of the project in one call.cover.py:66and69:sorted(agents, key=lambda m: _handle(conn, m))runs one handle select per agent.- Proposal: read the memberships once in
end. Incover_order, read the handles of the agents in one query (or join them into the membership select at55-59). - Effort: S. Risk: none.
3. holder_stalled: an unused constant and one condition written twice (debt / duplication)
holder_stalled.py:33KINDShas no reader (repo-wide grep).- "Expired and not reported for this expiry" is written in
expire(174-177) and again in_expire_one(193-196). events.py:1072spells the same two kinds inline (row.kind in ("holder_stalled", "claim_expired")).- Proposal: use
holder_stalled.KINDSatevents.py:1072(or deleteKINDS). Move the condition to a module-level_UNREPORTED(now). - Effort: S. Risk: none.
4. commitment.confirmed takes two parameters it never uses (debt)
commitment.py:115-120:projectandagent_idare unused. The body only withdraws the request. Caller:routes/me_session.py:841.- Proposal:
confirmed(conn, credential). - Effort: S. Risk: none.
5. rules._project_role_lines uses getattr only for test stand-ins (debt: a test-only path in product code)
rules.py:224-225:getattr(project, "settings", None), with the comment "a stand-in of a unit test may not" havesettings. A project row always has it.- The stand-ins are written three times, each slightly different:
hub/tests/test_rules_naming.py:14-22,hub/tests/test_rules_review.py:13-23(neither hassettings),hub/tests/test_rules_role_rules.py:26-35(has it). - Proposal: one stand-in builder in the tests (with
settings), used by all three files, and plainproject.settingsinrules.py. - Effort: S. Risk: none.
6. rules.reviews and rules.rule_role compute the same thing (duplication)
rules.py:173-180andrules.py:207-215both computecounts_as(project_roles.base_of(project, role))with the same local imports.- Proposal:
reviewsbecomesrule_role(project, role) == "reviewer", or both call one_reads_as(project, role). - Effort: S. Risk: none.
7. routes/board.py builds the "a redacted note is not edited" error twice (duplication)
routes/board.py:501androutes/board.py:517-519.- Proposal: one
_redacted_note()builder, as_conflictalready is for the other outcome. - Effort: S. Risk: none.
8. GET /me/forge: two connections in a row; PUT …/token's 503 is not in the docs (debt / docs drift)
routes/forge_links.py:120-123opens two connections back to back for two reads.routes/forge_links.py:166:PUT /me/forge/github/tokenanswers503 forge_unavailablewhen the forge does not answer. The error table (docs/api.md:277) givesforge_unavailableonly "while linking a GitHub App installation", and the endpoint's text (docs/api.md:15508-15520) names no 503.- Proposal: one connection. Add the token check to the
forge_unavailablerow and to the endpoint's text. - Effort: S. Risk: none.
Covered elsewhere
routes/restricted.py:149-174(_people: membership id to{kind, id, handle}with the deleted-account rule) is a third copy ofboard/history.members/group_chats.people. Add it to tsk-es10trywfqs7 item 9 rather than file it again.cover.py:27-28_principal(row.agent_id or row.human_id) is one more copy for tsk-es10trywfqs7 item 9 (views.member_id).cover.py:35-44_handle: tsk-ee3z4rakddq9.- Searched: _OpenCard, cover_order, holder_stalled, commitment.confirmed, role_rules, forge_unavailable, redacted note.
Effort sum: 8S (8 points).