Repository navigation
feat: record how each pull request review ran #36
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,84 @@ | ||
| import { v } from "convex/values"; | ||
| import type { ReviewTraceEvent } from "./workflow"; | ||
|
|
||
| // How long a review run's per-step trace is kept for quality checks. | ||
| export const REVIEW_TRACE_RETENTION_MS = 30 * 24 * 60 * 60 * 1_000; | ||
| // Bounds one record to a few hundred KB even for multibyte text, so a trim | ||
| // batch stays well inside a transaction's read limit. | ||
| const MAX_TRACE_STEPS = 16; | ||
| const MAX_STEP_ENTRIES = 15; | ||
| const MAX_TITLE_LENGTH = 160; | ||
| const MAX_PATH_LENGTH = 200; | ||
|
|
||
| export const reviewTraceStepValidator = v.object({ | ||
| step: v.string(), | ||
| proposed: v.optional( | ||
| v.array( | ||
| v.object({ | ||
| path: v.string(), | ||
| priority: v.string(), | ||
| confidence: v.number(), | ||
| title: v.string(), | ||
| }), | ||
| ), | ||
| ), | ||
| kept: v.optional(v.array(v.string())), | ||
| discarded: v.optional(v.array(v.string())), | ||
| }); | ||
|
|
||
| export type ReviewTraceStep = typeof reviewTraceStepValidator.type; | ||
|
|
||
| // Cut by code point so a surrogate pair is never split. | ||
|
hyochan marked this conversation as resolved.
Resolved
|
||
| const text = (value: unknown, limit: number) => | ||
| typeof value === "string" ? Array.from(value).slice(0, limit).join("") : ""; | ||
|
|
||
| /** A bounded copy of what each review step proposed and kept. */ | ||
| export function summarizeReviewTrace(events: ReviewTraceEvent[]): { | ||
| trace: ReviewTraceStep[]; | ||
| steps: number; | ||
| candidates: number; | ||
| discarded: number; | ||
| } { | ||
| let candidates = 0; | ||
| let discarded = 0; | ||
| const trace: ReviewTraceStep[] = []; | ||
| for (const event of events) { | ||
| if (event.stage === "proposed") { | ||
| candidates += event.candidates.length; | ||
| trace.push({ | ||
| step: text(event.step, MAX_PATH_LENGTH), | ||
| proposed: event.candidates.slice(0, MAX_STEP_ENTRIES).map((c) => ({ | ||
| path: text(c.path, MAX_PATH_LENGTH), | ||
| priority: text(c.priority, 8), | ||
| confidence: | ||
| typeof c.confidence === "number" && Number.isFinite(c.confidence) | ||
| ? c.confidence | ||
| : 0, | ||
| title: text(c.title, MAX_TITLE_LENGTH), | ||
| })), | ||
| }); | ||
| } else { | ||
| discarded += event.discarded.length; | ||
| trace.push({ | ||
| step: text(event.step, MAX_PATH_LENGTH), | ||
| kept: event.kept | ||
| .slice(0, MAX_STEP_ENTRIES) | ||
| .map((t) => text(t, MAX_TITLE_LENGTH)), | ||
| discarded: event.discarded | ||
| .slice(0, MAX_STEP_ENTRIES) | ||
| .map((t) => text(t, MAX_TITLE_LENGTH)), | ||
| }); | ||
| } | ||
| } | ||
| const half = MAX_TRACE_STEPS / 2; | ||
| return { | ||
| // The first steps and the last, where the final verification is. | ||
|
hyochan marked this conversation as resolved.
Resolved
|
||
| trace: | ||
| trace.length > MAX_TRACE_STEPS | ||
| ? [...trace.slice(0, half), ...trace.slice(-half)] | ||
| : trace, | ||
| steps: events.filter((e) => e.stage === "proposed").length, | ||
| candidates, | ||
| discarded, | ||
| }; | ||
| } | ||
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.