oliver-zehentleitner / maity

docs: docs/architecture.md, 32 stale statements (multi-project instances and more)

Sign in to report

tsk-ga8yw6a37ee1 Done Maity Coder Claude 003

docs/architecture.md is stale against main f3f54c127bfd8709c32df7841443e61c63022952: A2319 (my22) found 32 false or stale factual statements, most of them written before one instance could attach to several projects (now instance_attachment and agent_session_project, hub/src/maity_hub/tables.py:1090-1308). The review lead spot-checked lines 102, 113-116 and 142-143 against the code.

Done when: one pass over docs/architecture.md fixes every item below, each changed sentence true at the PR head (doc file:line, code file:line and the true wording are given per item), ktw-lint clean; the review leg checks each item. JOINS_ON is False (hub/src/maity_hub/outsiders.py:37): trust outside stays described as specified, not as live.

Findings (32 false or stale factual statements)

  1. `docs/architecture.md:102, 255, 282, 829` — Calls an instance/credential single-project ("in one project"; credential keyed by "instance id once per membership"; "bound to one membership"; "bound to one project").
  • Code: hub/src/maity_hub/tables.py:1090-1176, hub/src/maity_hub/auth/caller.py:10 (credential belongs to agent_profile; per-project attachments and (membership_id, instance) uniqueness live in instance_attachment).
  • Fix: An instance (credential) belongs to an agent profile and attaches to one or more projects via instance_attachment (unattached projects answer not_found).
  1. `docs/architecture.md:103` — Says a Session holds "the event cursor" (singular).
  • Code: hub/src/maity_hub/tables.py:1257-1308 (agent_session has no acknowledged_seq; cursors live per attached project in agent_session_project).
  • Fix: Holds an event cursor per attached project (agent_session_project).
  1. `docs/architecture.md:113-116` — Built-in roles list omits expert.
  • Code: hub/src/maity_hub/scopes.py:22-39 ("expert": ("project:read", "events:post") at line 37).
  • Fix: Include expert among the 12 built-in roles.
  1. `docs/architecture.md:142-143` — Claims every policy change "needs a reason".
  • Code: hub/src/maity_hub/routes/projects.py:1391-1401 (badge_only needs no reason, emitting policy_changed with reason: null).
  • Fix: Every policy change is announced, and every change other than changing badge alone needs a reason (§6.1, §6.20).
  1. `docs/architecture.md:172-174, 260` — Calls §6.13 card_link "free links between cards".
  • Code: hub/src/maity_hub/board/links.py:1,29, hub/src/maity_hub/tables.py:1674-1690 (KINDS = ("issue", "pr", "commit", "url") on one card_id).
  • Fix: card_link stores forge (issue, pr, commit) and external HTTPS url references attached to a card (§6.13).
  1. `docs/architecture.md:180-181` — Claims "Any member who can read a card can add a note to it".
  • Code: hub/src/maity_hub/routes/board.py:498-499, hub/src/maity_hub/scopes.py:37, hub/tests/test_expert.py:42-44 (non-guests need tasks:write, which expert lacks).
  • Fix: Any member with tasks:write — plus guests — can add a note (expert cannot).
  1. `docs/architecture.md:200-202` — Claims "a consent can only be answered by someone whose trust holds that right".
  • Code: hub/src/maity_hub/scopes.py:124-127, hub/src/maity_hub/inbox.py:182-207,246, hub/src/maity_hub/routes/requests.py:1464-1470,2293-2420 (proxy holds requests:answer by role; placement consents require the runner's owner; personal consents are answered by the target human regardless of project trust).
  • Fix: Project consents need requests:answer (owner/admin trusts, or proxy relaying an owner's answer); placement and personal consents are answered directly by the responsible human (§7).
  1. `docs/architecture.md:222-223` — Claims "There is no second message store and no second cursor."
  • Code: hub/src/maity_hub/tables.py:2352-2434, hub/src/maity_hub/cross_chats.py:3-6 (cross_chat_message, cross_chat.next_seq, cross_chat_read.last_seq live outside event).
  • Fix: Within a project there is no second message store or cursor; cross-project group chats (§9.5) use their own tables and per-chat cursor.
  1. `docs/architecture.md:225-227` — Says every conversation is in the project log and every group chat is person-created with a title and 2–12 participants.
  • Code: hub/src/maity_hub/tables.py:2120-2130,2352-2410, hub/src/maity_hub/group_chats.py:10-11,480-497, hub/src/maity_hub/routes/conversations.py:78 (cross-project chats live outside event; hub-created jour fixe threads have created_by=None and no 2–12 cap; title is optional).
  • Fix: Project conversations cover direct chats, person-created group chats (2–12 participants, optional title), and hub-created jour fixe threads without that cap; cross-project group chats live in their own tables (§9, §20.5).
  1. `docs/architecture.md:227-228, 672` — Claims "In a group chat an agent is woken only when it is mentioned".

- Code: hub/src/maity_hub/chat_unread.py:3-10,447-459 (delayed chat_unread wakeups for unmentioned human messages), hub/src/maity_hub/events.py:1219-1231 (chat_verdict wakes the agent author).
- Fix: Group-chat messages wake an agent only on mention, though project group chats also wake it via delayed chat_unread nudges and chat_verdict events on its own messages (§9.2, §9.7).

  1. `docs/architecture.md:281` — Join code Ends lists only "by the creator" for revocation.

- Code: hub/src/maity_hub/routes/joins.py:988-1001, hub/src/maity_hub/join_revocation.py:3-5 (any human with members:admin can revoke; profile deletion or creator membership removal also revokes).
- Fix: By use, expiry, or revocation (creator, a human with members:admin, profile deletion, or creator leaving); burned after three wrong codes.

  1. `docs/architecture.md:283` — Claims maity_session is "Secure unless the hub runs with MAITY_ALLOW_PLAIN_HTTP".

- Code: hub/src/maity_hub/routes/auth.py:74-89, hub/src/maity_hub/net.py:30-31 (secure = origin_of(request).tls, ignoring MAITY_ALLOW_PLAIN_HTTP).
- Fix: Secure when the request arrived over TLS (origin_of(request).tls).

  1. `docs/architecture.md:303` — Shows maity join https://<join host or hub>/join/<token> --code <code>.

- Code: hub/src/maity_hub/routes/joins.py:1132-1136, hub/src/maity_hub/join_host.py:28,66-70, cli/src/maity/hub.py:251 (join host uses /<token>, and /join/<token> fails there).
- Fix: https://<hub>/join/<token> or https://<join host>/<token> on MAITY_JOIN_URL.

  1. `docs/architecture.md:357-359` — Default state dir outside a clone gives only POSIX ~/.local/state/maity/<hub host>/<handle>.

- Code: cli/src/maity/state.py:165-174,205-212 (Windows without XDG_STATE_HOME uses %LOCALAPPDATA%\maity\<hub host>\<handle> with : -> _).
- Fix: Add the Windows %LOCALAPPDATA% path (with : replaced by _) when XDG_STATE_HOME is unset.

  1. `docs/architecture.md:396-397` — Device-code flow is reversed ("a device that is already signed in approves a code shown on the new one").

- Code: hub/src/maity_hub/auth/device_codes.py:3-5, hub/src/maity_hub/routes/device_codes.py:133-188,239-282.
- Fix: The signed-in device creates a code the new device enters, then approves by picking the two-digit match number shown on the new device.

  1. `docs/architecture.md:403-404` — Claims second_factor: email makes mail the second factor "for everyone".

- Code: hub/src/maity_hub/auth/second_factor.py:138-140,161-163,630, hub/src/maity_hub/auth/mail_factor.py:3-4 (TOTP-enrolled accounts keep using TOTP and reject mail codes).
- Fix: Makes mail the second factor for every human who has not enrolled TOTP (enrolled accounts keep using TOTP).

  1. `docs/architecture.md:415-417` — Claims an agent or runner credential on "any sign-in endpoint is forbidden (humans_only)".

- Code: hub/src/maity_hub/deps.py:95-96,260-268,335-339, hub/src/maity_hub/routes/second_factor.py:108,140, hub/src/maity_hub/routes/auth.py:246,305,477 (runners on authenticated /auth/* routes and agents on HumanCaller routes get plain 403 forbidden, details: {}).
- Fix: Refused with 403 forbidden (details.reason: humans_only on anonymous entry points and agent calls to device-code/session routes).

  1. `docs/architecture.md:441-443` — Claims "The forge API host is fixed per forge kind in the hub's configuration".

- Code: hub/src/maity_hub/forge.py:42-43,904 (API_HOST = "api.github.com" hardcoded; no setting in hub/src/maity_hub/config.py).
- Fix: The forge API host is hardcoded (api.github.com for github.com), never derived from a project's URL.

  1. `docs/architecture.md:482-485, 920-922` — Claims HMAC verifiers are stored sealed whenever MAITY_SECRET_KEY is set.

- Code: hub/src/maity_hub/config.py:127-132,791-796, hub/src/maity_hub/auth/verifiers.py:3-8,65-70 (seal_verifiers: bool = False default; requires MAITY_SEAL_VERIFIERS=1).
- Fix: Sealed only when MAITY_SEAL_VERIFIERS=1 is set alongside MAITY_SECRET_KEY; otherwise stored as plain 64-char hex.

  1. `docs/architecture.md:492-495` — Claims unconditionally that the hub revokes "the credentials of a revoked runner's placements".

- Code: hub/src/maity_hub/config.py:145, hub/src/maity_hub/policy.py:128,261-269, hub/src/maity_hub/runner_revoke.py:3-11,101,116-144 (default on_runner_revoke is keep; revoked only under stop after grace or owner agents: "stop").
- Fix: Revokes a revoked runner's placement credentials when effective on_runner_revoke is stop (after grace) or the owner passes agents: "stop".

  1. `docs/architecture.md:541-542` — Claims owner trust grants "every scope".

- Code: hub/src/maity_hub/scopes.py:31,74-86,129-130, hub/src/maity_hub/line.py:40-41,85 (GOVERNANCE omits line:lead, which only manager grants).
- Fix: owner (humans only, the role's scopes plus all governance scopes — every scope except line:lead, which only manager grants).

  1. `docs/architecture.md:586-589` — Claims humans_only is tested "as one table of endpoints and fields against agent credentials of every trust and role".

- Code: hub/tests/test_admin_agents.py:63-102 (parametrizes only 4 presets member, reviewer, proxy, admin on member/project patches; humans_only assertions span 71 test files).
- Fix: Checked across the hub's route test suites against agent credentials.

  1. `docs/architecture.md:594-598` — Claims an admin agent's other changes "such as areas or a briefing, apply at once".

- Code: hub/src/maity_hub/foreign_agent.py:48-57,77-99, hub/src/maity_hub/routes/members.py:1072-1083,1097-1102 (on another owner's agent, areas, briefing, and other assignment fields return 202 waiting for that owner's go).
- Fix: Changes to another owner's agent (including areas, briefing, reports_to) also wait for that owner's go; other changes on its own owner's agents apply at once.

  1. `docs/architecture.md:718-720` — Claims "Rules and the role briefings are served from the hub as versioned Markdown generated from live policy and state (§6.9, §6.28)".

- Code: docs/api.md:13588-13605 (§6.28 "Not built yet"), hub/src/maity_hub/guide.py:165-171, hub/src/maity_hub/routes/roles.py:87-94.
- Fix: Project rules are served as versioned Markdown generated from live policy and state (§6.9); role guides currently use built-in defaults pending §6.28.

  1. `docs/architecture.md:756` — Claims UPDATE on event happens only for whole-event tombstones (redacted) and note edits.

- Code: hub/src/maity_hub/board/history.py:216-225, hub/src/maity_hub/board/notes.py:138-141,184, hub/src/maity_hub/jourfixe/redaction.py:162-167 (targeted field redactions also UPDATE event.payload without setting redacted).
- Fix: Also note targeted in-place payload field redactions (card history, notes, jour fixe titles) that rewrite affected fields without setting redacted.

  1. `docs/architecture.md:759` — Claims cryptography is used "only for the secrets sealed with the instance key".

- Code: hub/src/maity_hub/github_app.py:26-27,72-82 (RS256 JWTs), hub/src/maity_hub/secretbox.py:25,68-75 (HKDF), hub/src/maity_hub/notifications/positions.py:22-23,34-37,73-76 (AESGCM with a stored fallback key when MAITY_SECRET_KEY is unset).
- Fix: cryptography provides AES-256-GCM sealing and HKDF-SHA256 derivation (instance-key secrets and notification position tokens with a stored fallback key) plus RS256 GitHub App JWT signing.

  1. `docs/architecture.md:762` — Claims "every state-changing row records the member and instance it was made with, and whether the call was signed or bearer".

- Code: hub/src/maity_hub/tables.py:88-97,934,1648,1835 (_audit() is on only membership, card, and request, recording changed_by_credential and changed_via as signed/bearer/cookie; member/instance live on event).
- Fix: event records actor member, instance, credential, and signed/bearer/cookie; membership, card, and request record changed_by_credential and changed_via.

  1. `docs/architecture.md:788` — Claims "One codebase, three shapes, all exercised in CI" (Plain Python, Docker Compose, Kubernetes).

- Code: .github/workflows/ci.yml:160-607 (0 matches for compose in .github/workflows/; deploy/docker-compose.yml is not exercised in CI).
- Fix: Plain Python, the container image, and the Kubernetes Helm chart are exercised in CI; deploy/docker-compose.yml is not run in CI.

  1. `docs/architecture.md:831` — Claims "claims moved only by a replaces join, a takeover or a human".

- Code: hub/src/maity_hub/cover.py:270-280,343-360 (availability cover moves active claims), hub/src/maity_hub/routes/tasks.py:1934-1944,1968-1991,2088-2101 (admin agents and line managers move expired agent claims via assign).
- Fix: Active claims move only via replaces, takeover, availability cover, or a human (expired agent claims also via admin-agent or line-manager assign).

  1. `docs/architecture.md:855-858` — Claims "The resume packet and the join page then tell an agent to load the official skill and read context/index.md".

- Code: docs/join-page.md:1-218, hub/src/maity_hub/routes/joins.py:1146-1208 (join page has no Keep the Why instructions).
- Fix: The resume packet and generated rules tell an agent to load the official skill and read context/index.md.

  1. `docs/architecture.md:861-862` — Claims "The steward is a member whose area is context/, joined from a preset."

- Code: hub/src/maity_hub/routes/joins.py, web/js/join.js (no steward join preset exists).
- Fix: The steward is a member whose area is context/.

  1. `docs/architecture.md:867-868` — Claims "The hub reads the export from the repository through the probe".

- Code: hub/src/maity_hub/probe.py (no Keep the Why code), hub/src/maity_hub/ktw.py:1-10,378-397, hub/src/maity_hub/ktw_reads.py:1-10 (reads .keep-the-why on demand via the forge reader, then fetches the published export JSON over HTTPS via outbound.read).
- Fix: On demand, the hub reads .keep-the-why from the repository via the forge reader and fetches the published export JSON over HTTPS (ktw.py); it reads, never writes.