oliver-zehentleitner / maity
clean-up: web fixture hub: proxy-aware permission checks, word lists synced by a check, one paging helper
tsk-808exssdj9wt Open
From the web clean-up audit, area 17 (tsk-hgnbapyw7hnh), read at 80647565 (findings sent to lotse, seq 125537). Line numbers are from 80647565, so re-check them on current main. Everything here is in the fixture hub (file:// only, web/context/fixtures.md), so there is no production risk. Every fixture route still has a hub route.
#59 Fixture hub: about 30 permission checks skip the proxy rule and have drifted from the hub (duplication/drift).
- api.js:532 governing excludes the proxy. :533 tasksAdmin and :694-697 membersAdmin are the same thing.
- About 28 inline owner/admin trust checks skip governing: lines 271, 467, 1429, 1676, 2156, 2161, 2210, 3286, 3673, 3680, 3695, 3722, 3734, 3755, 3980, 4044, 4398, 4709, 4725, 5283, 5322, 5460, 5470, 5506, 5512, 5519, 5619 and 5736.
- In the hub a proxy gets no governance scopes (scopes.py _granted, in_admin_team). For example, placements need members:admin (routes/placements.py:106, 279), but the fixture placement checks at api.js:271 and 3286 let a proxy with trust admin through.
- Proposal: one scopeIn(slug, scope, who) on a small copy of the role-to-scope table of the hub, replacing tasksAdmin, membersAdmin, jfAdmin and every inline check.
- Effort M. Risk medium for fixtures and smoke, none for production.
#60 Fixture hub: hand-copied hub word lists have drifted, and no check keeps them in sync (drift/design).
- ORG_RESERVED (api.js:1317-1321):
- It cites "DASHBOARD_WORDS in hub/src/maity_hub/namespace.py", which no longer exists. The real list is paths.RESERVED_FIRST (hub paths.py:17-24).
- It has "p" and "s", which the hub does not reserve.
- It lacks api, assets, badge, explore, for, health, impressum, imprint, inbox, mail, privacy and terms.
- app.js:101-103 OWN_WORDS already matches RESERVED_FIRST and is exported as M.reservedFirst (app.js:107).
- ROUTE_WORDS (api.js:243-245, used at 3547 and 3651):
- It has contracts, group-chats and releases, which no route uses.
- It lacks the hub floor words me, repository and roles (namespace.py:70-76) and PROJECT_VIEWS (paths.py:53-58).
- So the fixture accepts a slug "team" that the hub refuses.
- In sync today but unchecked: HUB_ROLES and AGENT_ROLES (743-747), the BUILTIN_ROLES scopes (361-434), and MAINTENANCE_OPEN (1961) against middleware.py:115-119. Only STEP_UP_ROUTES is checked (web/tools/check.py:1680-1684).
- Proposal:
- Use M.reservedFirst.
- Rebuild ROUTE_WORDS from the hub floor plus PROJECT_VIEWS.
- Extend check.py to parse these lists from the hub and compare them with the copies in JS.
- Effort S-M. Risk low.
#61 Fixture hub: pagination written per route, and the chat-messages route has drifted from the hub (duplication/drift).
- pageLimit (api.js:1566-1572) is used only by pageBands. About 12 routes parse limit and cursor themselves without validation: 2280-2281, 2404/2433, 2485-2486, 3262-3263, 4120, 4176/4196, 4590, 4758/4784, 5687 and 5791.
- The hub has one GET .../conversations/{id}/messages, but the fixture has two diverging handlers: group (5682-5713) and direct (5788-5810).
- The direct handler defaults to limit 200 (api.js:5791), where the hub default is 50 (conversations.py:53, 857).
- On "before", the group handler returns the last seq as cursor, where the hub returns 0 (conversations.py:886).
- On an empty page, the group handler returns cursor null and can still set earlier (5699-5700), where the hub returns start and earlier as null (conversations.py:894, 903-908).
- Proposal: one pageArgs(query, path, {def: 50}) for every list route, and one messages handler (GET and POST, 5714/5811) with a direct/group adapter.
- Effort M. Risk low-medium: smoke cases on chat paging.
#62 api.js: small copies (duplication).
- registrationMailReady (210) and signInMailReady (1862) are identical.
- A local mineIn at 2287 returns the role and matches by full_name, while the outer mineIn (529) returns the membership and matches by slug. The same name is used for two things.
- The activity lambda is written three times (1652, 5528, 5537).
- projectAfter and acrossAfter (1589-1604) share their first four lines.
- Proposal: keep one of each, and rename the local mineIn to roleIn.
- Effort S. Risk low.
Order: if the split of the fixture hub out of api.js (sibling card) goes first, this card follows the moved file.