-
Notifications
You must be signed in to change notification settings - Fork 738
feat(server): add read-only findings dashboard #679
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
Merged
kmbroai
merged 11 commits into
dev/kyleb/findings-review-checkpoints
from
dev/kyleb/findings-dashboard
Aug 27, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9db0aa8
feat(server): add read-only findings dashboard
kmbroai 06ad589
fix(dashboard): show workflows first
kmbroai 9dd11b2
refactor(dashboard): simplify rendering and reuse workflow storage
kmbroai b88ac31
fix(dashboard): preserve filters and completed result semantics
kmbroai 31844ac
fix(dashboard): retain published repository identities in search
kmbroai b5adf18
fix(dashboard): include deep scan activity in freshness
kmbroai ffe2663
refactor(dashboard): use native selects and remove dropdown machinery
kmbroai 060cd37
refactor(dashboard): show only stored findings and groups
kmbroai 744c990
Merge updated review checkpoints into findings dashboard
kmbroai ab4d356
Merge branch 'dev/kyleb/findings-review-checkpoints' into dev/kyleb/f…
kmbroai 692daa4
fix(plugin): support isolated dashboard helper execution
kmbroai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| """Read-only dashboard projections for stored findings and duplicate groups.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| import sqlite3 | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | ||
| from workbench_findings import list_dedupe_groups | ||
|
|
||
|
|
||
| FINDING_RECORDS = """ | ||
| SELECT findings.id, json_extract(details_json, '$.title') AS title, | ||
| COALESCE(repositories.ids, '[]') AS repositoryIds, | ||
| json_extract(details_json, '$.severity.level') AS severity, | ||
| findings.created_at AS createdAt, findings.updated_at AS updatedAt | ||
| FROM findings LEFT JOIN ( | ||
| SELECT finding_id, json_group_array(repository_id) AS ids | ||
| FROM finding_repositories GROUP BY finding_id | ||
| ) AS repositories ON repositories.finding_id = findings.id | ||
| WHERE details_json IS NOT NULL | ||
| """ | ||
|
|
||
| GROUP_RECORDS = """ | ||
| SELECT groups.id, groups.id AS title, | ||
| (SELECT json_group_array(DISTINCT repository_id) | ||
| FROM finding_dedupe_group_members AS members | ||
| JOIN finding_repositories ON finding_repositories.finding_id = members.finding_id | ||
| WHERE members.group_id = groups.id) AS repositoryIds, | ||
| groups.created_at AS createdAt, groups.created_at AS updatedAt, | ||
| (SELECT COUNT(*) FROM finding_dedupe_group_members WHERE group_id = groups.id) AS memberCount | ||
| FROM finding_dedupe_groups AS groups | ||
| """ | ||
|
|
||
| RECORDS = { | ||
| "findings": FINDING_RECORDS, | ||
| "groups": GROUP_RECORDS, | ||
| } | ||
|
|
||
|
|
||
| def item(row: sqlite3.Row) -> dict[str, Any]: | ||
| result = dict(row) | ||
| result["repositoryIds"] = json.loads(result["repositoryIds"]) | ||
| return result | ||
|
|
||
|
|
||
| def detail(connection: sqlite3.Connection, view: str, selected: dict[str, Any]) -> dict[str, Any]: | ||
| result: dict[str, Any] = {"item": selected} | ||
| selected_id = selected["id"] | ||
| if view == "findings": | ||
| result["finding"] = json.loads(connection.execute( | ||
| "SELECT details_json FROM findings WHERE id = ?", (selected_id,), | ||
| ).fetchone()[0]) | ||
| result["groups"] = list_dedupe_groups(connection, selected_id)["groups"] | ||
| else: | ||
| result["group"] = { | ||
| "groupId": selected_id, "createdAt": selected["createdAt"], | ||
| "findingIds": [r[0] for r in connection.execute( | ||
| "SELECT finding_id FROM finding_dedupe_group_members WHERE group_id = ? ORDER BY finding_id", | ||
| (selected_id,), | ||
| )], | ||
| } | ||
| return result | ||
|
|
||
|
|
||
| def dashboard(connection: sqlite3.Connection, query: dict[str, Any]) -> dict[str, Any]: | ||
| """One snapshot, no artifact reads, model calls, or writes.""" | ||
| view = query["view"] | ||
| records = RECORDS[view] | ||
| clauses: list[str] = [] | ||
| values: list[Any] = [] | ||
| if query.get("query"): | ||
| connection.create_function("casefold", 1, str.casefold, deterministic=True) | ||
| columns = ["id", "title", "repositoryIds"] | ||
| clauses.append("(" + " OR ".join(f"instr(casefold(COALESCE({c}, '')), casefold(?)) > 0" for c in columns) + ")") | ||
| values.extend([query["query"]] * len(columns)) | ||
| if query.get("repository"): | ||
| clauses.append("EXISTS (SELECT 1 FROM json_each(repositoryIds) WHERE value = ?)") | ||
| values.append(query["repository"]) | ||
| where = " WHERE " + " AND ".join(clauses) if clauses else "" | ||
| order = "createdAt DESC, id" if query["sort"] == "newest" else "updatedAt DESC, id" | ||
| connection.execute("BEGIN") | ||
| with connection: | ||
| repositories = connection.execute(""" | ||
| SELECT DISTINCT repository_id AS id, repository_id AS label | ||
| FROM finding_repositories ORDER BY repository_id | ||
| """).fetchall() | ||
| total = connection.execute(f"SELECT COUNT(*) FROM ({records}) {where}", values).fetchone()[0] | ||
| rows = connection.execute( | ||
| f"SELECT * FROM ({records}) {where} ORDER BY {order} LIMIT ? OFFSET ?", | ||
| (*values, query["limit"], query["offset"]), | ||
| ).fetchall() | ||
| selected = connection.execute( | ||
| f"SELECT * FROM ({records}) WHERE id = ?", (query["id"],), | ||
| ).fetchone() if query.get("id") else None | ||
| next_offset = query["offset"] + len(rows) | ||
| return { | ||
| "overview": { | ||
| "findings": connection.execute("SELECT COUNT(*) FROM findings WHERE details_json IS NOT NULL").fetchone()[0], | ||
| "groups": connection.execute("SELECT COUNT(*) FROM finding_dedupe_groups").fetchone()[0], | ||
| }, | ||
| "repositories": [dict(row) for row in repositories], | ||
| "items": [item(row) for row in rows], "total": total, | ||
| "limit": query["limit"], "offset": query["offset"], | ||
| "nextOffset": next_offset if next_offset < total else None, | ||
| "detail": detail(connection, view, item(selected)) if selected is not None else None, | ||
| } | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| argparse.ArgumentParser(description=__doc__).parse_args() | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Avoid materializing every repository association on each dashboard refresh
This projection groups the entire
finding_repositoriestable byfinding_id, but its existing primary-key index starts withrepository_id; SQLite consequently scans the full table and builds a temporary grouping index. The count, page, and detail queries can repeat that work, and every open dashboard polls again every five seconds, so latency grows with the whole shared database rather than the visible page. Add an appropriatefinding_id-leading index and restructure the projection so refreshes do not repeatedly materialize unrelated findings.