Repository navigation
Add whole-repository source review with Opus, Grok, and Astra #165
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
Open
benkruger
wants to merge
23
commits into
dsifry:main
Choose a base branch
from
benkruger:whole-repo-source-review
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
77baa94
feat(source-review): review a checkout's first-party source with Opus…
benkruger bf3e621
feat(source-review): restyle the review page
benkruger b1ea929
feat(source-review): make Grok finish, number prompt lines, redesign …
benkruger a3b8288
feat(source-review): --path reviews a sample of the real checkout
benkruger 0b05fa4
feat(source-review): run every model with the same review setup
benkruger 0600426
perf(source-review): run Grok at medium reasoning effort
benkruger 6eba389
feat(source-review): run Opus at medium effort to match Grok
benkruger 6775da0
fix(source-review): isolate model calls and reject incomplete reviews
benkruger 08ce3cf
docs: archive Grok experiments and record unfinished checkpoint
benkruger dc6b86b
docs: bound Grok parity work without weakening accuracy
benkruger fbfcf4c
docs: make Grok parity decisions autonomous and finite
benkruger a4701da
docs: record bounded Grok campaign failures and stop
benkruger 12c1d09
docs: record isolated verification and smaller-context diagnostics
benkruger ebe3025
docs: record runtime-fact recovery and correct prior recall score
benkruger e936e76
docs: record five-option Grok parity trials
benkruger 57c824b
docs: save branch summary for the PR body
benkruger 7bedc84
docs: record full Opus and Grok comparison review
benkruger 2818b9c
chore: remove experiment and review paperwork from source-review PR
benkruger e2d0d2b
Merge upstream main and preserve source-review dispatch
benkruger 6e30470
fix: address source-review correctness and resource handling
benkruger 77535e0
fix: preserve cancellation and exact filename handling
benkruger 84f6a87
Add simple source-review wrapper and README guide
benkruger e8c6560
Require explicit model and repo flags in source-review wrapper
benkruger 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| cd "$(dirname "$0")/.." | ||
| exec make cover | ||
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,48 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| printf 'Usage: %s --model <grok|opus|astra> --repo <path>\n' "$0" | ||
| } | ||
|
|
||
| model="" | ||
| repo="" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --model|--repo) | ||
| if [[ $# -lt 2 || -z "$2" || "$2" == --* ]]; then | ||
| printf 'Missing value for %s\n' "$1" >&2 | ||
| usage >&2 | ||
| exit 2 | ||
| fi | ||
| case "$1" in | ||
| --model) model="$2" ;; | ||
| --repo) repo="$2" ;; | ||
| esac | ||
| shift 2 | ||
| ;; | ||
| --help|-h) usage; exit 0 ;; | ||
| *) printf 'Unknown argument: %s\n' "$1" >&2; usage >&2; exit 2 ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "$model" || -z "$repo" ]]; then | ||
| printf 'Both --model and --repo are required\n' >&2 | ||
| usage >&2 | ||
| exit 2 | ||
| fi | ||
| case "$model" in | ||
| grok|opus|astra) ;; | ||
| *) printf 'Unknown model: %s\n' "$model" >&2; usage >&2; exit 2 ;; | ||
| esac | ||
|
|
||
| # Resolve the caller's repo before moving into the metareview checkout to build. | ||
| repo="$(cd -- "$repo" && pwd -P)" | ||
| root="$(cd -- "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" | ||
| cd -- "$root" | ||
| go build -o bin/metareview ./cmd/metareview | ||
|
|
||
| # Each run gets its own reports, outside the repository being reviewed. | ||
| output="$(mktemp -d "/tmp/metareview-${model}-XXXXXX")" | ||
| printf 'Reports: %s\n' "$output" >&2 | ||
| exec "$root/bin/metareview" source-review --model "$model" --output "$output" "$repo" |
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,89 @@ | ||
| package sourcereview | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func gitEnv() []string { | ||
| return append(os.Environ(), | ||
| "GIT_CONFIG_GLOBAL=/dev/null", | ||
| "GIT_CONFIG_SYSTEM=/dev/null", | ||
| "GIT_AUTHOR_NAME=Test", | ||
| "GIT_AUTHOR_EMAIL=t@example.com", | ||
| "GIT_COMMITTER_NAME=Test", | ||
| "GIT_COMMITTER_EMAIL=t@example.com", | ||
| ) | ||
| } | ||
|
|
||
| func gitRun(t *testing.T, root string, args ...string) { | ||
| t.Helper() | ||
| cmd := exec.Command("git", args...) | ||
| cmd.Dir = root | ||
| cmd.Env = gitEnv() | ||
| out, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| t.Fatalf("git %s: %v\n%s", strings.Join(args, " "), err, out) | ||
| } | ||
| } | ||
|
|
||
| func newRepoBytes(t *testing.T, files map[string][]byte) (root, commit string) { | ||
| t.Helper() | ||
| root = t.TempDir() | ||
| gitRun(t, root, "init", "-b", "main") | ||
| gitRun(t, root, "config", "user.email", "t@example.com") | ||
| gitRun(t, root, "config", "user.name", "Test") | ||
| for p, body := range files { | ||
| abs := filepath.Join(root, filepath.FromSlash(p)) | ||
| if err := os.MkdirAll(filepath.Dir(abs), 0o755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(abs, body, 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
| gitRun(t, root, "add", "-A") | ||
| gitRun(t, root, "commit", "-m", "fixture") | ||
| cmd := exec.Command("git", "rev-parse", "HEAD") | ||
| cmd.Dir = root | ||
| cmd.Env = gitEnv() | ||
| out, err := cmd.Output() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| return root, strings.TrimSpace(string(out)) | ||
| } | ||
|
|
||
| func specFiles() map[string][]byte { | ||
| return map[string][]byte{ | ||
| "pkg/app.go": []byte("package pkg\n\nfunc App() int { return 1 }\n"), | ||
| "pkg/note.go": []byte("DO NOT EDIT\npackage pkg\n\nfunc Note() string { return \"n\" }\n"), | ||
| "pkg/app_test.go": []byte("package pkg\n\nfunc TestApp(t *testing.T) {}\n"), | ||
| "vendor/lib.go": []byte("package vendor\n\nfunc Lib() {}\n// DROPME-vendor\n"), | ||
| "go.sum": []byte("example.com/mod v1.0.0 h1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\n"), | ||
| "pkg/gen.go": []byte("// Code generated by fixture. DO NOT EDIT.\npackage pkg\n\nfunc Gen() {}\n"), | ||
| "pkg/blob.dat": {0xff, 0xfe, 0x00, 0x01}, | ||
| "README.md": []byte("# Demo\n\nDROPME-readme\n"), | ||
| "config.yaml": []byte("name: demo\nDROPME-config\n"), | ||
| } | ||
| } | ||
|
|
||
| func droppedOnlyFiles() map[string][]byte { | ||
| all := specFiles() | ||
| delete(all, "pkg/app.go") | ||
| delete(all, "pkg/note.go") | ||
| return all | ||
| } | ||
|
|
||
| var specDropped = []string{ | ||
| "README.md", | ||
| "config.yaml", | ||
| "go.sum", | ||
| "pkg/app_test.go", | ||
| "pkg/blob.dat", | ||
| "pkg/gen.go", | ||
| "vendor/lib.go", | ||
| } |
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,126 @@ | ||
| package sourcereview | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "errors" | ||
| "fmt" | ||
| "os/exec" | ||
| "strconv" | ||
| "strings" | ||
| ) | ||
|
|
||
| // GitFunc runs git with optional stdin and returns stdout. A nil GitFunc means realGit. | ||
| type GitFunc func(root string, args []string, stdin []byte) ([]byte, error) | ||
|
|
||
| // gitBin is the git executable. Tests point it at a missing name to cover a failed start. | ||
| var gitBin = "git" | ||
|
|
||
| func realGit(root string, args []string, stdin []byte) ([]byte, error) { | ||
| cmd := exec.Command(gitBin, append([]string{"-C", root}, args...)...) | ||
| if stdin != nil { | ||
| cmd.Stdin = bytes.NewReader(stdin) | ||
| } | ||
| out, err := cmd.Output() | ||
| if err != nil { | ||
| var ee *exec.ExitError | ||
| if errors.As(err, &ee) { | ||
| return nil, fmt.Errorf("git %s: %s", strings.Join(args, " "), bytes.TrimSpace(ee.Stderr)) | ||
| } | ||
| return nil, err | ||
| } | ||
| return out, nil | ||
| } | ||
|
|
||
| func resolveTop(root string, git GitFunc) (string, error) { | ||
| out, err := git(root, []string{"rev-parse", "--show-toplevel"}, nil) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return strings.TrimSpace(string(out)), nil | ||
| } | ||
|
|
||
| type treeBlob struct { | ||
| path string | ||
| id string | ||
| } | ||
|
|
||
| // parseTree reads `git ls-tree -r -z` records, preserving arbitrary filenames | ||
| // and the object IDs used to read this exact snapshot. | ||
| func parseTree(out []byte) ([]treeBlob, error) { | ||
| var blobs []treeBlob | ||
| rest := out | ||
| for len(rest) > 0 { | ||
| rec, next, _ := bytes.Cut(rest, []byte{0}) | ||
| rest = next | ||
| if len(rec) == 0 { | ||
| continue | ||
| } | ||
| tab := bytes.IndexByte(rec, '\t') | ||
| if tab < 0 { | ||
| return nil, fmt.Errorf("bad ls-tree record") | ||
| } | ||
| fields := strings.Fields(string(rec[:tab])) | ||
| if len(fields) < 3 { | ||
| return nil, fmt.Errorf("bad ls-tree meta") | ||
| } | ||
| if fields[1] != "blob" { | ||
| continue | ||
| } | ||
| p := string(rec[tab+1:]) | ||
| if p == "" { | ||
| continue | ||
| } | ||
| blobs = append(blobs, treeBlob{path: p, id: fields[2]}) | ||
| } | ||
| return blobs, nil | ||
| } | ||
|
|
||
| func readBlobs(root string, blobs []treeBlob, git GitFunc) (map[string][]byte, error) { | ||
| if len(blobs) == 0 { | ||
| return map[string][]byte{}, nil | ||
| } | ||
| var stdin bytes.Buffer | ||
| paths := make([]string, 0, len(blobs)) | ||
| for _, b := range blobs { | ||
| // Object IDs avoid line-delimited filenames and any later HEAD lookup. | ||
| fmt.Fprintln(&stdin, b.id) | ||
| paths = append(paths, b.path) | ||
| } | ||
| out, err := git(root, []string{"cat-file", "--batch"}, stdin.Bytes()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return parseBatch(out, paths) | ||
| } | ||
|
|
||
| func parseBatch(out []byte, paths []string) (map[string][]byte, error) { | ||
| files := make(map[string][]byte, len(paths)) | ||
| rest := out | ||
| for _, p := range paths { | ||
| nl := bytes.IndexByte(rest, '\n') | ||
| if nl < 0 { | ||
| return nil, fmt.Errorf("short cat-file header for %s", p) | ||
| } | ||
| header := string(rest[:nl]) | ||
| rest = rest[nl+1:] | ||
| parts := strings.Split(header, " ") | ||
| if len(parts) < 3 || parts[1] != "blob" { | ||
| return nil, fmt.Errorf("cat-file %s: %s", p, header) | ||
| } | ||
| size, err := strconv.Atoi(parts[2]) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("cat-file %s: %w", p, err) | ||
| } | ||
| if size < 0 || len(rest) < size+1 { | ||
| return nil, fmt.Errorf("short cat-file blob %s", p) | ||
| } | ||
| if rest[size] != '\n' { | ||
| return nil, fmt.Errorf("cat-file %s: missing trailing newline", p) | ||
| } | ||
| body := make([]byte, size) | ||
| copy(body, rest[:size]) | ||
| files[p] = body | ||
| rest = rest[size+1:] | ||
| } | ||
| return files, nil | ||
| } |
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.
📐 Maintainability & Code Quality | 🔵 Trivial
🔎 Supported by static analysis
🏁 Script executed:
Repository: dsifry/metareview
Length of output: 492
🏁 Script executed:
Repository: dsifry/metareview
Length of output: 45549
🏁 Script executed:
Repository: dsifry/metareview
Length of output: 261
Run the
task-donegate before closing this change.The repository guidance requires this gate after each small implementation chunk. Resolve any blockers before treating
bin/cias complete.🤖 Prompt for AI Agents
Source: Coding guidelines