feat(reports): add reports migration and storage implementation#2500
Open
viniciusventura29 wants to merge 3 commits intomainfrom
Open
feat(reports): add reports migration and storage implementation#2500viniciusventura29 wants to merge 3 commits intomainfrom
viniciusventura29 wants to merge 3 commits intomainfrom
Conversation
- Introduced a new migration to create the `reports` table for storing automated reports, including fields for organization ID, title, category, status, summary, and lifecycle status. - Implemented `KyselyReportsStorage` for handling CRUD operations on reports, including listing, retrieving, upserting, and updating lifecycle status. - Added tools for managing reports, including listing, retrieving, updating status, and upserting reports, integrated with the existing reports binding. - Updated context and types to support the new reports functionality across the application.
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
Release OptionsShould a new version be published when this PR is merged? React with an emoji to vote on the release type:
Current version: Deployment
|
Contributor
There was a problem hiding this comment.
2 issues found across 21 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/mesh/migrations/035-reports.ts">
<violation number="1" location="apps/mesh/migrations/035-reports.ts:23">
P2: `lifecycle_status` is nullable, so rows can end up with NULL and skip the intended lifecycle state. If this column should always represent a report state, enforce `notNull()` along with the default.</violation>
</file>
<file name="packages/bindings/src/well-known/reports.ts">
<violation number="1" location="packages/bindings/src/well-known/reports.ts:331">
P2: Use ReportLifecycleStatusSchema for REPORTS_UPSERT output to keep lifecycleStatus validation consistent with the rest of the reports binding; the current z.string() allows invalid lifecycle status values.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Added `reports` property to mock context in multiple test files to ensure consistency in testing. - Updated `generate-id.ts` to include a new prefix for reports. - Modified `ReportsStorage` interface and `KyselyReportsStorage` implementation to exclude `id` from the upsert data type. - Refactored `ReportSection` type to use bindings from `@decocms/bindings` and adjusted `tags` type in `ReportTable` for better data handling.
- Updated the `lifecycle_status` column in the reports migration to be non-nullable with a default value of "unread". - Adjusted the `KyselyReportsStorage` implementation to ensure `lifecycle_status` defaults to "unread" if not provided. - Modified the `ReportTable` interface to reflect the non-nullable type for `lifecycle_status`. - Updated the reports schema in bindings to use the correct type for `lifecycleStatus`.
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.
What is this contribution about?
Adds a Reports system to Mesh — a first-class way for agents, CI pipelines, and external services to publish structured reports (performance audits, security scans, ranking summaries, etc.) that appear in an inbox-style UI inside the Mesh admin panel.
The implementation includes:
reportstable with org-scoped storage, lifecycle status (unread/read/dismissed), and JSON sectionsKyselyReportsStorage— CRUD operations (list, get, upsert, updateLifecycleStatus)REPORTS_LIST,REPORTS_GET,REPORTS_UPDATE_STATUS,REPORTS_UPSERT— exposed via the management MCP (/mcp/self) and selectable in any Virtual MCPREPORTS_BINDINGin@decocms/bindings— any external MCP that implementsREPORTS_LIST+REPORTS_GETis automatically detected as reports-compatible by the UI pluginPassthroughClientnow detects stale tool caches — if anyselected_toolsare missing from the DB cache, it falls back to a live fetch instead of returning an empty listScreenshots/Demonstration
How to Test
REPORTS_UPSERTwith a title, category, status, summary, and at least one sectionunreadstylinglifecycleStatusshould auto-update toreaddismissed)Testing the cache fix:
REPORTS_LIST/REPORTS_GETfrom theMesh MCPconnectiontools/liston the Virtual MCP URL — all 4 report tools should appear even if the connection's DB cache predates this PRMigration Notes
This PR adds a new Kysely migration (
035-reports.ts). Run before starting the server:No Better Auth migrations required. No breaking changes to existing connections or Virtual MCPs.
Review Checklist
Summary by cubic
Adds first-class reports storage and tools so plugins and agents can publish and read automated reports via the Reports binding. Includes a DB migration, MCP tools, context wiring, and UI updates (Mesh MCP by default, tool search, smarter virtual MCP caching).
New Features
Migration
Written for commit 5309b79. Summary will update on new commits.