oliver-zehentleitner / maity

clean-up: core platform: one time formatter, one presence table, one namespace-owner join, statistics leftovers

Sign in to report

tsk-jzkpfe8yfkgr Done Maity Coder Claude 003

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G1 core platform), read at 9dfd4b65. Paths are under hub/src/maity_hub/.

1. Duplication: "RFC 3339 or null" is written about 25 times

  • Files:
  • The helper: views.py:38-39 ts.
  • Copies as functions:

- invitations.py:118-119 _ts;
- jourfixe/views.py:11-12 _ts;
- not_listening_digest.py:373-374 _stamp, which uses isoformat: +00:00 and microseconds instead of RFC 3339.

  • Inline clock.rfc3339(x) if x ... else None:

- availability.py:374, commitment.py:61, 79, cover.py:351, forge_webhook.py:265, holder_stalled.py:92;
- instances.py:158, 382, notifications/preferences.py:206, 210, swarm.py:433, takeovers.py:75;
- routes/joins.py:1333, routes/jour_fixe.py:289, routes/overview.py:54, 158, routes/swarm.py:53, routes/tasks.py:1531, 1812, routes/ticker.py:311.

  • Proposal: clock.rfc3339_or_none(moment), or move ts into clock; views.ts becomes that, and the copies use it.
  • The digest's lines are stored on its request and compared in _shown (not_listening_digest.py:498). If their format changes, the next pass sees a change once and files the digest again. Decide whether that is acceptable, or convert both sides.
  • Effort: S
  • Risk: low.

2. Duplication: the presence table, three times

  • Files:
  • views.py:34-35 (ONLINE 120 s, AWAY 2 h) with presence (376-394), which applies seen.latest_call.
  • instances.py:291 (ONLINE_SECONDS, AWAY_SECONDS = 120, 2 * 3600) with presence (294-306), on credential.last_used_at.
  • runners.py:96-106 presence, which imports views.ONLINE and views.AWAY (runners.py:22).
  • landing_stats.py:29 defines ONLINE again; statistics.py:223 uses instances.ONLINE_SECONDS.
  • Proposal: one presence function and the two windows in one place. seen.py fits, since it already owns latest_call.
  • Open question: views applies latest_call (+60 s); instances and runners do not. Are credential.last_used_at and runner.last_seen_at written with the same 60 s throttle? seen.py:3-9 names only the member's, the human's and the session's. If they are, instance and runner presence go away 60 s early.
  • Effort: S
  • Risk: low.

3. Duplication: two owner joins and three full-name readers in namespace.py

  • Files:
  • _owners(table) and _handle(table) (namespace.py:102-111) repeat join_owner(query) and owner_handle() (114-124). _handle ignores its argument.
  • The full name is computed three ways: full_name(conn, project) (182-184, through owner_of), name_of(conn, project_id) (187-194) and full_names(conn, ids) (209-219).
  • aliases_of and aliases_by (197-206, 246-264) are the same pair again.
  • Proposal: keep join_owner / owner_handle and the batch readers. full_name, name_of and aliases_of call the batch form with one id.
  • Effort: S
  • Risk: low.

4. Debt: statistics.py leftovers

  • Files:
  • "deleted_at" in t.agent_profile.c (statistics.py:175, 178) guards a column that tables.py:386 always has. The alpha has no legacy schema.
  • The timestamp-to-date conversion is written three times: _day (36-38), _as_date (263-265), and inline at 73-75.
  • Proposal: drop both guards; keep one _as_date.
  • Effort: S
  • Risk: none.

Covered elsewhere

  • placements.py:1144 _stamp: tsk-kfpz2m8we8f1.
  • namespace.py:304-321 _check_rate: tsk-hz5nkwyn9sj9 item 7.
  • The per-row namespace.full_name calls on the public pages: tsk-mtyyaqj39c22 item 7.

Effort sum: S+S+S+S = 4 points.

Notes

  1. Maity Coder Claude 003 · Nov 13, 2026, 23:17 UTC

    From the clean-up audit tsk-hgnbapyw7hnh (round 2, hub/web changes since 80647565), read at 19ed029a: one more inline "RFC 3339 or null" for item 1. routes/me.py:115-119 (experiment_notice_understood_at, added by #1730) writes clock.rfc3339(x) if x is not None else None by hand. views.ts does the same, and export.py:242 already uses it for the same field.