UAT: SkillService uses timezone-naive datetime.now() for created_at/updated_at timestamps — violates UTC timestamp standard #3735

Open
opened 2026-04-05 22:22:30 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/skill-service-utc-timestamps
  • Commit Message: fix(skill-service): replace timezone-naive datetime.now() with UTC-aware timestamps
  • Milestone: Backlog
  • Parent Epic: #3374

Background and Context

SkillService in src/cleveragents/application/services/skill_service.py uses datetime.now() (timezone-naive) for created_at and updated_at timestamps, violating the project's standard of using timezone-aware UTC datetimes. This was discovered during UAT code-level analysis.

Current Behavior

In add_skill() (line ~80):

now = datetime.now()  # ← timezone-naive!

In _load_from_db() (line ~100):

now = datetime.now()  # ← timezone-naive!
self._created_at[skill.name] = now
self._updated_at[skill.name] = now

Additionally, _load_from_db() uses datetime.now() as a placeholder for the actual DB timestamps, meaning the loaded timestamps don't reflect when the skill was actually created/updated in the database.

Expected Behavior (from spec)

All timestamps must be timezone-aware UTC datetimes. The project standard (as enforced in other services) requires datetime.now(timezone.utc) or datetime.utcnow().replace(tzinfo=timezone.utc).

Impact

  • Timezone-naive datetimes cause comparison failures when mixed with timezone-aware datetimes
  • Timestamps loaded from DB are wrong (they reflect load time, not creation time)
  • Inconsistent with the project's UTC timestamp standard (already flagged in repositories.py)

What Was Tested

Code-level analysis of src/cleveragents/application/services/skill_service.py.

Code Location

src/cleveragents/application/services/skill_service.pyadd_skill() and _load_from_db() methods

Subtasks

  • Replace datetime.now() with datetime.now(timezone.utc) in add_skill()
  • Fix _load_from_db() to use actual DB timestamps instead of datetime.now()
  • Add from datetime import timezone import
  • Add Behave tests verifying timezone-aware timestamps

Definition of Done

  • All timestamps are timezone-aware UTC
  • DB-loaded timestamps reflect actual creation/update times
  • nox -e typecheck passes
  • nox -e unit_tests passes
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/skill-service-utc-timestamps` - **Commit Message**: `fix(skill-service): replace timezone-naive datetime.now() with UTC-aware timestamps` - **Milestone**: Backlog - **Parent Epic**: #3374 ## Background and Context `SkillService` in `src/cleveragents/application/services/skill_service.py` uses `datetime.now()` (timezone-naive) for `created_at` and `updated_at` timestamps, violating the project's standard of using timezone-aware UTC datetimes. This was discovered during UAT code-level analysis. ## Current Behavior In `add_skill()` (line ~80): ```python now = datetime.now() # ← timezone-naive! ``` In `_load_from_db()` (line ~100): ```python now = datetime.now() # ← timezone-naive! self._created_at[skill.name] = now self._updated_at[skill.name] = now ``` Additionally, `_load_from_db()` uses `datetime.now()` as a placeholder for the actual DB timestamps, meaning the loaded timestamps don't reflect when the skill was actually created/updated in the database. ## Expected Behavior (from spec) All timestamps must be timezone-aware UTC datetimes. The project standard (as enforced in other services) requires `datetime.now(timezone.utc)` or `datetime.utcnow().replace(tzinfo=timezone.utc)`. ## Impact - Timezone-naive datetimes cause comparison failures when mixed with timezone-aware datetimes - Timestamps loaded from DB are wrong (they reflect load time, not creation time) - Inconsistent with the project's UTC timestamp standard (already flagged in repositories.py) ## What Was Tested Code-level analysis of `src/cleveragents/application/services/skill_service.py`. ## Code Location `src/cleveragents/application/services/skill_service.py` — `add_skill()` and `_load_from_db()` methods ## Subtasks - [ ] Replace `datetime.now()` with `datetime.now(timezone.utc)` in `add_skill()` - [ ] Fix `_load_from_db()` to use actual DB timestamps instead of `datetime.now()` - [ ] Add `from datetime import timezone` import - [ ] Add Behave tests verifying timezone-aware timestamps ## Definition of Done - [ ] All timestamps are timezone-aware UTC - [ ] DB-loaded timestamps reflect actual creation/update times - [ ] `nox -e typecheck` passes - [ ] `nox -e unit_tests` passes - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#3735
No description provided.