Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional per-user insights mode to the Aegis stack by introducing a Project tenancy model, project-scoped migrations/templates, and new project CRUD APIs. It fits into the existing insights service by extending service-option parsing and generation so stacks can choose between shared insights and project-isolated insights.
Changes:
- Add
insights[per_user]parsing, Copier/template context wiring, and a context-sensitive insights migration shape. - Introduce per-user insights models/services/APIs, including project CRUD, encryption helpers, and project-scoped collector/query behavior.
- Expand tests for per-user migrations, stack generation, project APIs, encryption, and collector/service behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/core/test_migration_spec.py |
Updates legacy migration-key expectations for folded insights migration specs. |
tests/core/test_migration_generator.py |
Adds coverage for shared/per-user insights migration shapes and FK ondelete rendering. |
tests/cli/test_stack_generation.py |
Adds stack-generation coverage for insights[per_user]. |
tests/cli/conftest.py |
Registers a per-user insights project template fixture. |
copier.yml |
Adds the insights_per_user Copier question/flag. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/test_encryption.py.jinja |
Adds tests for the new symmetric encryption helper. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_query_service.py |
Adapts query-service tests for project-scoped metrics/events. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_project_service.py.jinja |
Adds CRUD/encryption tests for ProjectService. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_insights_collectors.py |
Updates collector base tests to seed/pass projects. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_insight_service.py |
Adapts insight-service tests for project-aware event creation and seeding. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_goal_service.py.jinja |
Updates goal-service tests to use project_id instead of slug scoping. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_service.py |
Adjusts collector-service tests for project-bound collection. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_reddit.py |
Updates Reddit collector tests for project-backed config. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_pypi.py |
Updates PyPI collector tests for per-project package config. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_plausible.py |
Updates Plausible collector tests for per-project credentials. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_github_traffic.py |
Updates GitHub traffic collector tests for project-backed repo/token config. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_github_stars.py |
Updates GitHub stars collector tests for project-backed repo/token config. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/test_collector_github_events.py |
Updates GitHub events collector tests for project-backed repo config. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/services/_collector_fixtures.py |
Adds shared helpers for seeding collector projects in tests. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/api/test_insights_projects_endpoints.py.jinja |
Adds API tests for project CRUD and project-scoped bulk insights. |
aegis/templates/copier-aegis-project/{{ project_slug }}/tests/api/test_insights_endpoints.py |
Updates shared insights endpoint tests for optional project seeding. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/query_service.py |
Adds optional project_id scoping to bulk insights queries. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/project_service.py.jinja |
Adds project CRUD and credential encryption/decryption logic. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/project_schemas.py.jinja |
Adds request/response schemas for the project API. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/models.py.jinja |
Introduces Project and project-scoped insights/goal/event schema changes. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/jobs.py.jinja |
Makes scheduled collectors iterate over configured projects in per-user mode. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/insight_service.py.jinja |
Adds optional project stamping for user-created events. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/goal_service.py.jinja |
Switches goals from slug-scoped to project_id-scoped CRUD. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/goal_schemas.py.jinja |
Updates goal API schemas for project-scoped URLs/body shapes. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/event_service.py.jinja |
Adds project scoping to user-event CRUD service behavior. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/event_schemas.py.jinja |
Re-gates event schemas for per-user/project-scoped mode. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/deps.py.jinja |
Adds project ownership/dependency helpers for insights APIs. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/reddit.py.jinja |
Scopes Reddit dedup/event writes by project. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/pypi.py.jinja |
Reads PyPI config from bound project when present. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/plausible.py.jinja |
Reads Plausible config from bound project when present. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/github_traffic.py.jinja |
Reads GitHub traffic config from bound project when present. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/github_stars.py.jinja |
Adds project-backed config and project-scoped dedup/event logic. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/github_events.py.jinja |
Adds project-backed config and project-scoped dedup queries. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collectors/base.py.jinja |
Makes collector base class optionally project-bound and stamps project_id. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collector_service.py.jinja |
Makes collector orchestration project-aware and invalidates per-project caches. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/core/encryption.py |
Adds Fernet-based encryption helper for project credentials. |
aegis/templates/copier-aegis-project/{{ project_slug }}/app/components/backend/api/insights.py.jinja |
Adds project CRUD routes and project-scoped bulk insights endpoint. |
aegis/core/template_generator.py |
Propagates insights_per_user into template context generation. |
aegis/core/services.py |
Reworks insights service options/migrations to support per_user. |
aegis/core/migration_generator.py |
Adds context-sensitive insights migration building plus FK/index/drop rendering features. |
aegis/core/manual_updater.py |
Stops rendering non-.jinja template files through Jinja. |
aegis/core/insights_service_parser.py |
Extends insights option parsing to include per_user. |
aegis/core/copier_manager.py |
Passes insights_per_user into Copier and migration generation context. |
aegis/constants.py |
Adds the INSIGHTS_PER_USER answer key. |
Comments suppressed due to low confidence (1)
aegis/templates/copier-aegis-project/{{ project_slug }}/app/services/insights/collector_service.py.jinja:88
- Per-user mode makes
insight_metric.project_idnon-null, but this service still supportsproject=Noneas a supposed fallback. Existing entry points likeapp/cli/insights.pycallCollectorService(session)without a project, so any manualinsights collect ...run in a per-user stack will now fail on the first metric insert becauseBaseCollector.upsert_metric()writesproject_id=None.
def __init__(
self,
db: AsyncSession,
{% if insights_per_user -%}
project: Project | None = None,
{%- endif %}
) -> None:
self.db = db
{% if insights_per_user -%}
self.project = project
{%- endif %}
{% if insights_per_user -%}
@property
def project_id(self) -> int | None:
"""Convenience accessor mirroring ``BaseCollector.project_id``."""
return self.project.id if self.project is not None else None
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.