Skip to content

DRAFT: v0.1.0 #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 139 commits into
base: main
Choose a base branch
from
Open

DRAFT: v0.1.0 #1020

wants to merge 139 commits into from

Conversation

kzndotsh
Copy link
Contributor

@kzndotsh kzndotsh commented Aug 10, 2025

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. If this change fixes any issues please put "Fixes #XX" in the description. Please also ensure to add the appropriate labels to the PR.

Guidelines

  • My code follows the style guidelines of this project (formatted with Ruff)

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation if needed

  • My changes generate no new warnings

  • I have tested this change

  • Any dependent changes have been merged and published in downstream modules

  • I have added all appropriate labels to this PR

  • I have followed all of these guidelines.

How Has This Been Tested? (if applicable)

Please describe how you tested your code. e.g describe what commands you ran, what arguments, and any config stuff (if applicable)

Screenshots (if applicable)

Please add screenshots to help explain your changes.

Additional Information

Please add any other information that is important to this PR.

Summary by Sourcery

Migrate project from Poetry to Uv (Hatch) as the dependency and build tool, restructure code under src/, introduce a dependency injection container with BaseCog for service resolution, centralize Sentry integration via a new SentryManager, and overhaul tracing/error handling instrumentation. Update CLI commands, Docker configurations, CI workflows, documentation, and tests to use Uv, add unit/integration/e2e test markers with isolation, and bump version to v0.1.0.

New Features:

  • Add a ServiceContainer and ServiceRegistry for dependency injection with IBotService, IConfigService, and IDatabaseService protocols
  • Introduce SentryManager to centralize Sentry SDK initialization, event capturing, before‐send filtering, and performance tracing
  • Implement BaseCog to automatically inject services into cogs

Enhancements:

  • Migrate build system and dependency management from Poetry to Uv (Hatchling) and update pyproject.toml accordingly
  • Reorganize code layout under src/tux with separate core, services, shared, modules, and custom_modules packages
  • Replace manual Sentry calls and inline spans with decorators and context managers for automatic command and span instrumentation

Build:

  • Switch build backend to Hatchling, add uv.lock, and configure project scripts for Uv CLI

CI:

  • Update GitHub workflows to install and use Uv, adjust cache keys, and replace Poetry commands with Uv equivalents

Documentation:

  • Revise README, CONTRIBUTING, docs content, and Docker guides to reference Uv instead of Poetry
  • Update test documentation to include unit/integration/e2e markers, network blocking, and deterministic environment setup

Tests:

  • Enhance pytest configuration with --run-integration, --run-e2e, and --allow-network flags
  • Block outbound network by default for unit tests and better isolate filesystem using tmp_path

Chores:

  • Bump project version to 0.1.0 across pyproject.toml and metadata files

Mendy and others added 30 commits July 22, 2025 19:45
…w audit files

- Updated  to include  and  directories.
- Modified  to exclude  from checks.
- Added multiple new audit files for comprehensive analysis and documentation of the codebase.
- Introduced core modules for dependency injection including ServiceContainer, BaseCog, and service interfaces.
- Added concrete service implementations for database, bot, and configuration services.
- Established a centralized ServiceRegistry for service configuration and management.
- Enhanced BaseCog to support automatic service injection while maintaining backward compatibility.
- Added ContainerInitializationError for handling container setup failures.
- Implemented _setup_container method to initialize and validate the dependency injection container.
- Introduced _validate_container and _raise_container_validation_error methods for improved error handling.
- Updated setup_hook and _setup_callback to include container status in Sentry context.
- Implemented _cleanup_container method to manage container lifecycle during shutdown.
- Added DatabaseControllerSingleton class to manage a single instance of DatabaseController.
- Introduced get_db_controller function to retrieve the database controller instance.
- Updated fetch_guild_config function to use the singleton instance for fetching guild configuration.
- Updated multiple command classes to inherit from BaseCog instead of commands.Cog.
- Adjusted constructor calls to utilize super() for proper initialization.
- This change enhances consistency and leverages the new dependency injection framework.
- Introduced a new script to validate the completeness of the dependency injection migration.
- The script analyzes cog files for BaseCog inheritance and direct instantiations of DatabaseController.
- Provides output in various formats (json, table, summary) and allows exporting results to a JSON file.
- Enhances the ability to measure migration success metrics and identify issues in the codebase.
- Introduced unit tests for the Config, Setup, Level, Levels, ModerationCogBase, InfluxLogger, LevelsService, Starboard, SnippetsBaseCog, AFK, Poll, RemindMe, SelfTimeout, and core components.
- Each test suite verifies cog initialization, database service fallback, and specific functionality to ensure proper behavior with dependency injection.
- Enhanced test coverage for the core dependency injection framework and service implementations.
… Tux bot

- Introduced new test fixtures for mocking database, bot, and configuration services to facilitate unit testing.
- Added example unit tests demonstrating how to test cogs with dependency injection, covering command execution and service interactions.
- Enhanced test coverage for the dependency injection framework, ensuring proper functionality and error handling in various scenarios.
…stem in Tux bot

- Introduced a new test module for integration testing of the dependency injection system, covering bot startup, service registration, and cog loading.
- Implemented tests to verify container initialization, service resolution, and error handling in various scenarios.
- Enhanced test coverage for end-to-end functionality, ensuring proper interaction between services and cogs.
- Included performance tests to measure startup time and service resolution efficiency, ensuring no degradation in performance.
- Added comments to the conftest.py file to clarify the purpose of the dependency injection fixtures.
- Improved code readability and maintainability for future development.
- Introduced new modules and services to improve the functionality and organization of the Tux bot.
- Added comprehensive documentation for new features and modules, including dependency injection and service management.
- Implemented various utility functions and classes to streamline bot operations and enhance maintainability.
- Updated existing files to reflect changes in the project structure and ensure compatibility with new modules.
- Enhanced test coverage with new unit and integration tests for the added features, ensuring robust functionality.
- Removed the unused FrameType import to clean up the code.
- Added a blank line for improved readability in the setup_signals method.
Instrument only meaningful controller methods (span op=db.controller.*). Route query spans via start_span in base; pass op_name to avoid duplicates. Lazy import tracing via importlib to prevent cycles.
Replace direct Sentry calls with capture_span_exception/set_span_attributes; use enhanced_span for grouped ops; standardize telemetry.
Expose shared bot protocol in core for extension management; swap hot_reload to use it and deprecate local BotProtocol.
cursoragent and others added 30 commits August 18, 2025 22:09
…support; make downgrade idempotent; wire non-dev startup to alembic upgrade; remove create_all paths
…te smoke test and optional Postgres integration test
- Remove Prisma dependency from pyproject.toml
- Archive prisma/schema directory to .prisma-archive/
- Replace Prisma CLI commands with Alembic equivalents
- Update Docker files to remove Prisma client generation
- Update all documentation to use SQLModel/Alembic terminology
- Fix CI workflow shellcheck warning
- Update GitHub Actions to remove generate-prisma parameter
- Replace database setup instructions from 'db push' to 'db upgrade'

This completes the migration from Prisma to SQLModel + Alembic for
database management, providing a more modern Python-native approach
with improved type safety and development experience.
The 'tables' file is deleted as it is empty and not used in the project. Removing unused files helps in maintaining a clean and organized codebase.
…istency

Use the `BaseModel.update_by_id` method for updating AFK entries,
simplifying the code and ensuring consistency with other update
operations. This change reduces redundancy and potential errors
by leveraging existing methods.

fix(database): correct type annotations and remove redundant code

Remove unnecessary type checking imports and correct type annotations
for SQLAlchemy fields. This improves code readability and ensures
consistency across the codebase. The changes also include setting
timezone information in `sa_column_kwargs` for datetime fields,
ensuring proper handling of timezones.

style(database): simplify list comprehension and remove type ignores

Simplify the list comprehension in `get_cases_by_options` method
to improve readability. Remove unnecessary type ignores, as they
are no longer needed with the updated type annotations. This
enhances code clarity and maintainability.
- Changed from include to packages in hatch configuration
- Fixed module resolution for CLI entry point
- Resolves ModuleNotFoundError when running 'uv run tux'
style: update import statements and comments for clarity

fix: handle potential None values in CacheService methods

The datetime fields in the database models no longer specify timezone
information, simplifying the schema and reducing potential issues with
timezone handling. Import statements and comments are updated for
clarity and consistency, improving code readability. The CacheService
methods are refactored to handle potential None values more gracefully,
ensuring robustness when Redis is not available. Additionally, unused
files related to the SQLModel refactor are removed to clean up the
repository.
…for configuration

feat(database): add support for environment-based database URL and timezone configuration

feat(database): implement reset-migrations command for clean migration baseline

fix(database): use database-side current timestamp for expiration checks

refactor(bot): adjust setup order for container and database initialization

The alembic.ini file is removed to centralize configuration in pyproject.toml, simplifying project setup. The database URL is now set via environment variables, enhancing flexibility. A new reset-migrations command is added to streamline migration management, allowing for a clean baseline. Expiration checks now use database-side timestamps to avoid timezone issues. The bot setup order is adjusted for better initialization flow.
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.

3 participants