Skip to content

Orb P0 S2a: tinyagentos/agent_avatars.py (move avatar slug + dir out of routes/auth.py, add avatar_hash) - #3517

Merged
jaylfc merged 1 commit into
devfrom
exec/tsk-aa5qck
Oct 5, 2026
Merged

jaylfc merged 1 commit into
devfrom
exec/tsk-aa5qck

Conversation

@jaylfc

@jaylfc jaylfc commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

CARD TITLE (intent, not commit subject): Orb P0 S2a: tinyagentos/agent_avatars.py (move avatar slug + dir out of routes/auth.py, add avatar_hash)

Autonomous build of board card tsk-aa5qck.

tsk-aa5qck: extract avatar slug + dir into agent_avatars module

RED-FIRST proof:

==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_agent_avatars.py _________________
ImportError while importing test module '/tmp/exec-tsk-aa5qck/tests/test_agent_avatars.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback (most recent call last):
  File "/home/jay/.local/share/uv/python/cpython-3.14.7-linux-x86_64-gnu/lib/python3.14/importlib/__init__.py", line 88, in _gcd_import
    module = _bootstrap._gcd_import(name, package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_agent_avatars.py:9: in <module>
    from tinyagentos.agent_avatars import avatar_hash, avatar_source_path
E   ModuleNotFoundError: No module named 'tinyagentos.agent_avatars'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.32s

Green after fix:

==================================== 4 passed in 0.24s ====================================

Demo mode and lock-widgets tests also green:

==================================== 17 passed in 22.48s ====================================
...
........................................................................ [ 60%]
...............................................                          [100%]
119 passed in 43.90s

Docs-Reviewed: module extraction only, no route or user-facing behavior change, docs/agent-coordination.md not affected

Files:
changelog.d/tsk-aa5qck-agent-avatars-module.md | 3 ++
tests/test_agent_avatars.py | 45 ++++++++++++++++++++++++++
tinyagentos/agent_avatars.py | 38 ++++++++++++++++++++++
tinyagentos/routes/auth.py | 25 +-------------
4 files changed, 87 insertions(+), 24 deletions(-)

In-house review (pre-PR)

in-house-review: PASS (openrouter/inclusionai/ling-3.1-flash)

reviewer output

VERDICT: PASS

  • NIT: tests/test_agent_avatars.py:5 from pathlib import Path is unused (tmp_path already is a Path); import pytest (line 7) is also unused.
  • NIT: tinyagentos/routes/auth.py:9607 the #: doc-comment describing LOCK_AVATAR_DIR's purpose/overridability was dropped in the move instead of being carried into agent_avatars.py (the two definitions themselves were moved intact per the card).
  • NIT: tinyagentos/routes/auth.py:9607 three blank lines remain between lock_widgets and the @router.get("/lock-avatar/{slug}") decorator after the removal (cosmetic only).

Verified against card: both definitions moved unchanged with docstring intact; import swapped in at top-level imports of auth.py so all existing uses (incl. from tinyagentos.routes.auth import _avatar_slug) still resolve via re-export, leaving exactly one slug rule; avatar_source_path reads the module global LOCK_AVATAR_DIR at call time (monkeypatchable as tests do) and returns None when no file; avatar_hash returns first 16 hex chars of sha256 or None; module deps are only os/hashlib/pathlib; no route added; all four required test cases present and capable of failing (RED ModuleNotFoundError on origin/dev, then green); changelog file has one bullet under ### Changed; no em dashes or AI attribution in the diff.

In-house-Review: PASS model=openrouter/inclusionai/ling-3.1-flash head=ad0f4522e needs-lead=0

Summary by CodeRabbit

  • New Features
    • Added avatar file lookup and change detection, allowing the app to identify available agent avatars and recognize when their image content changes.
  • Refactor
    • Consolidated avatar handling for consistent agent-name matching across the app.

Lead note: _avatar_slug moved verbatim to tinyagentos/agent_avatars.py and is re-imported into routes/auth.py (one slug rule, not a removal).
Removes-Intentionally: tinyagentos/routes/auth.py:_avatar_slug

RED-FIRST proof:

```text
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_agent_avatars.py _________________
ImportError while importing test module '/tmp/exec-tsk-aa5qck/tests/test_agent_avatars.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback (most recent call last):
  File "/home/jay/.local/share/uv/python/cpython-3.14.7-linux-x86_64-gnu/lib/python3.14/importlib/__init__.py", line 88, in _gcd_import
    module = _bootstrap._gcd_import(name, package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_agent_avatars.py:9: in <module>
    from tinyagentos.agent_avatars import avatar_hash, avatar_source_path
E   ModuleNotFoundError: No module named 'tinyagentos.agent_avatars'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.32s
```

Green after fix:

```text
==================================== 4 passed in 0.24s ====================================
```

Demo mode and lock-widgets tests also green:

```text
==================================== 17 passed in 22.48s ====================================
...
........................................................................ [ 60%]
...............................................                          [100%]
119 passed in 43.90s
```

Docs-Reviewed: module extraction only, no route or user-facing behavior change, docs/agent-coordination.md not affected
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: jaylfc/taOS/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a289f894-8642-4c26-8903-36d65c89b602
📥 Commits

Reviewing files that changed from the base of the PR and between 8cc491c and ad0f452.

📒 Files selected for processing (4)
  • changelog.d/tsk-aa5qck-agent-avatars-module.md
  • tests/test_agent_avatars.py
  • tinyagentos/agent_avatars.py
  • tinyagentos/routes/auth.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Avatar directory and slug logic moved from the auth route into a dedicated module. The module adds helpers that return an installed avatar path and its truncated SHA-256 hash. Tests cover lookup, hashing, and slug-helper agreement.

Changes

Avatar helper module

Layer / File(s) Summary
Avatar helpers and route integration
tinyagentos/agent_avatars.py, tinyagentos/routes/auth.py, tests/test_agent_avatars.py, changelog.d/tsk-aa5qck-agent-avatars-module.md
The new module defines the avatar directory, slug generation, source-path lookup, and file hashing. The auth route imports the directory and slug helpers. Tests cover missing and existing files, hash values and changes, and route-module slug agreement. The changelog records the move and added helpers.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to ad0f4

No actionable merge-blocking risk is evident in the supplied change context.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to ad0f4

The existing avatar access checks and directory configuration are preserved. The new helpers currently have only test callers, so this change does not introduce a new externally reachable file operation or materially broaden filesystem access.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — No expansion of current externally reachable filesystem authority was identified. Avatar serving continues through the existing route using the same configured directory and service process permissions; the new read helpers have only test callers.

Trust Boundaries and Controls

  • observed — The request boundary remains in the authentication route: it checks the existing console-origin predicate before validating the requested slug and reading bytes. The new module is an in-process utility and does not independently authorize callers.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (2 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the avatar module extraction and the addition of avatar_hash. It is specific and related to the main changes.
Full details: Docstring Coverage

Explanation

Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (2 skipped: 1 unsupported, 1 too large.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

import os
from pathlib import Path

LOCK_AVATAR_DIR = os.environ.get("TAOS_LOCK_AVATAR_DIR", "/var/lib/taos/lock-avatars")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Missing docstring for LOCK_AVATAR_DIR

The #: Sphinx-style docstring that explained its purpose and overridability was dropped when the definitions were moved from auth.py. This constant is environment-overridable and its documentation should travel with it.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

path = avatar_source_path(name)
if path is None:
return None
return hashlib.sha256(path.read_bytes()).hexdigest()[:16]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Unhandled OSError in avatar_hash

path.read_bytes() can raise OSError (e.g., FileNotFoundError) if the file is deleted between avatar_source_path's is_file() check and the read. The original lock_avatar route in auth.py handled this with try/except OSError.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
tinyagentos/agent_avatars.py 7 Missing docstring for LOCK_AVATAR_DIR
tinyagentos/agent_avatars.py 38 Unhandled OSError in avatar_hash
Files Reviewed (4 files)
  • changelog.d/tsk-aa5qck-agent-avatars-module.md
  • tests/test_agent_avatars.py
  • tinyagentos/agent_avatars.py - 2 issues
  • tinyagentos/routes/auth.py

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash:free · Input: 46.4K · Output: 15.1K · Cached: 389.8K

@jaylfc

jaylfc commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Lead review at head against card tsk-aa5qck: APPROVE. Both definitions moved verbatim, auth.py re-imports them (one slug rule), avatar_source_path/avatar_hash match the card, red shown (ModuleNotFoundError) then green, lock-widgets + demo suites green.
deleted-symbols-gate: false positive on a MOVE; lead added Removes-Intentionally: tinyagentos/routes/auth.py:_avatar_slug to the body (the edited trigger re-runs the gate).
Bot adjudication (non-blocking, folded into a follow-up): kilo dropped #: comment on LOCK_AVATAR_DIR (valid nit); kilo OSError race in avatar_hash between is_file() and read_bytes() (valid, low impact: a deleted avatar between the two calls raises instead of returning None). NIT: auth.py binds LOCK_AVATAR_DIR by value, so a monkeypatch of one module does not reach the other; production reads one env var.
auth.py path: merge waits for Jay.

@jaylfc
jaylfc merged commit f29e23a into dev Oct 5, 2026
63 of 68 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