Skip to content

Fix audit findings: TUI system messages + history-on-switch, update_name uniqueness, REST version guard, DRY constants - #54

Merged
Aztec03hub merged 1 commit into
mainfrom
worktree-agent-adb72168ae550f90e
Jun 26, 2026
Merged

Fix audit findings: TUI system messages + history-on-switch, update_name uniqueness, REST version guard, DRY constants#54
Aztec03hub merged 1 commit into
mainfrom
worktree-agent-adb72168ae550f90e

Conversation

@Aztec03hub

Copy link
Copy Markdown
Owner

Python-only fixes for a batch of verified audit findings. Web files untouched (concurrent agents own them); deferred-security items (broker auth, read-side authz/membership gating, /api/invite auth model) intentionally out of scope.

Findings fixed

[PY-E HIGH] TUI silently dropped every [system] message. Sender.type excluded "system", so Message.from_mqtt_payload raised ValidationError and _handle_message swallowed every daemon notification. Widened message.ParticipantType to include "system" (the registry's participant.ParticipantType stays claude/human — system is not joinable) and routed system payloads to add_system_message. Audited every consumer of message.ParticipantType: two test helpers that feed registry.join now import the type from participant. Also dropped the dead is_broadcast clause (is_for already covers broadcasts).

[PY-E MED] TUI never fetched server history on channel switch. _resubscribe_conversation now fetches REST history once per conversation (guarded by _fetched_history), independent of the MQTT connection.

[PY-B MED] update_name had no uniqueness check. tool_comms_update_name now refuses a rename onto a name held by a different participant (clear error); case-only self-rename still allowed.

[PY-A LOW] _api_artifacts_get 500 on ?version=abc. Extracted build_artifact_get_route (TestClient-coverable, mirrors the other build_*_route factories) with a 400 guard matching /api/messages.

[PY-A LOW] web opened http://0.0.0.0:PORT under bind-all host. Now uses _web_ui_urls()[0] (localhost), matching doctor/banner behaviour.

[DRY MED] key regex ^[0-9a-f]{8}$ reimplemented at ~7 sites. All routed to canonical participant.KEY_PATTERN.

[DRY MED] system sender key "00000000" hardcoded across files. Promoted to message.SYSTEM_SENDER_KEY; single-sourced in notifier/mcp_tools/mcp_server/cli.

Tests

Added: end-to-end system-message rendering, history-fetch-once-per-conv, update_name collision (+ case-insensitive + self-rename allowed), artifact ?version 400/404/ok, web bind-all->localhost, and DRY single-source guards.

Gates

  • pytest: 1548 passed, 1 skipped (was 1525/1 — +23 tests, no new skips)
  • basedpyright: src 0/0, tests 0/0
  • ruff check + format --check: clean

🤖 Generated with Claude Code

…update_name uniqueness, REST guards, DRY constants

Python-only fixes for a batch of verified audit findings.

- [PY-E HIGH] TUI dropped every daemon-authored [system] message: widen
  message.ParticipantType to include "system" so Sender validates
  daemon-published payloads; _handle_message now routes them to
  add_system_message instead of swallowing them at parse time. Audited every
  consumer of message.ParticipantType — two test helpers feed registry.join
  (participant.ParticipantType, claude/human only) and now import the type
  from participant. Removed the dead is_broadcast clause (is_for already
  covers broadcasts) and the now-reachable branch's pyright-ignore.
- [PY-E MED] TUI never fetched history on channel switch: _resubscribe_conversation
  now fetches REST history once per conversation (guarded by _fetched_history),
  independent of the MQTT connection.
- [PY-B MED] update_name had no uniqueness check: tool_comms_update_name now
  refuses a rename onto a name held by a different participant (clear error);
  case-only self-rename still allowed.
- [PY-A LOW] _api_artifacts_get crashed to 500 on non-numeric ?version:
  extracted build_artifact_get_route with a 400 guard mirroring /api/messages.
- [PY-A LOW] web command opened http://0.0.0.0:PORT under bind-all host: now
  uses _web_ui_urls()[0] (localhost), matching doctor/banner behaviour.
- [DRY MED] key regex ^[0-9a-f]{8}$ reimplemented at ~7 sites: all routed to
  the canonical participant.KEY_PATTERN.
- [DRY MED] system sender key "00000000" hardcoded across files: promoted to
  message.SYSTEM_SENDER_KEY and single-sourced in notifier/mcp_tools/mcp_server/cli.

Tests added: end-to-end system-message rendering, history-fetch-once-per-conv,
update_name collision (+ case-insensitive + self-rename), artifact ?version 400,
web bind-all->localhost, and DRY single-source guards.
@Aztec03hub
Aztec03hub merged commit 61e3d75 into main Jun 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant