-
Notifications
You must be signed in to change notification settings - Fork 752
feat: checkpoint dedupe reviews and replay group writes #674
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 12 commits into
dev/kyleb/findings-workflow-state
from
dev/kyleb/findings-review-checkpoints
Aug 27, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2d2aa0a
feat: checkpoint dedupe reviews and replay group writes
kmbroai b472607
fix: keep workflow source snapshots within the checkout
kmbroai 26c233d
Merge workflow metadata columns into checkpoint branch
kmbroai 6e07268
fix: migrate dedupe checkpoint bindings to SQLite columns
kmbroai 799cd03
refactor(test): translate checkpoint smoke assertions to TypeScript
kmbroai 846d0b0
Merge updated workflow parent into checkpoint branch
kmbroai 1020c5b
test: retain required canonical ID in translated checkpoint checks
kmbroai c590689
Merge provisional endpoint cleanup into checkpoint branch
kmbroai 7ccf7d8
Merge branch 'dev/kyleb/findings-workflow-state' into dev/kyleb/findi…
kmbroai f98d611
Merge branch 'dev/kyleb/findings-workflow-state' into dev/kyleb/findi…
kmbroai 18052bb
test: align checkpoint contracts with the updated findings stack
kmbroai ab27774
feat(server): add read-only findings dashboard (#679)
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.