Skip to content

Commit a148cb0

Browse files
committed
dashboard/dashapi: AI patching jobs
1 parent 0ccd0bb commit a148cb0

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

dashboard/app/ai.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright 2025 syzkaller project authors. All rights reserved.
2+
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3+
4+
package main
5+
6+
import (
7+
"context"
8+
"encoding/json"
9+
"fmt"
10+
"io"
11+
12+
"github.com/google/syzkaller/dashboard/dashapi"
13+
)
14+
15+
/*
16+
import (
17+
"bytes"
18+
"compress/gzip"
19+
"context"
20+
"crypto/subtle"
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"io"
25+
"math/rand"
26+
"net/http"
27+
"net/mail"
28+
"net/url"
29+
"reflect"
30+
"regexp"
31+
"sort"
32+
"strings"
33+
"time"
34+
"unicode/utf8"
35+
36+
"github.com/google/syzkaller/dashboard/dashapi"
37+
"github.com/google/syzkaller/pkg/asset"
38+
"github.com/google/syzkaller/pkg/auth"
39+
"github.com/google/syzkaller/pkg/coveragedb"
40+
"github.com/google/syzkaller/pkg/debugtracer"
41+
"github.com/google/syzkaller/pkg/email"
42+
"github.com/google/syzkaller/pkg/gcs"
43+
"github.com/google/syzkaller/pkg/hash"
44+
"github.com/google/syzkaller/pkg/subsystem"
45+
"github.com/google/syzkaller/sys/targets"
46+
"github.com/google/uuid"
47+
"google.golang.org/appengine/v2"
48+
db "google.golang.org/appengine/v2/datastore"
49+
"google.golang.org/appengine/v2/log"
50+
aemail "google.golang.org/appengine/v2/mail"
51+
"google.golang.org/appengine/v2/user"
52+
)
53+
*/
54+
55+
func apiAIJobPoll(c context.Context, payload io.Reader) (interface{}, error) {
56+
req := new(dashapi.AIJobPollReq)
57+
if err := json.NewDecoder(payload).Decode(req); err != nil {
58+
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
59+
}
60+
resp := &dashapi.AIJobPollResp{}
61+
return resp, nil
62+
}
63+
64+
func apiAIJobDone(c context.Context, payload io.Reader) (interface{}, error) {
65+
req := new(dashapi.AIJobDoneReq)
66+
if err := json.NewDecoder(payload).Decode(req); err != nil {
67+
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
68+
}
69+
return nil, nil
70+
}
71+
72+
func apiAIJournal(c context.Context, payload io.Reader) (interface{}, error) {
73+
req := new(dashapi.AIJournalReq)
74+
if err := json.NewDecoder(payload).Decode(req); err != nil {
75+
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
76+
}
77+
return nil, nil
78+
}

dashboard/app/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ var apiHandlers = map[string]APIHandler{
6060
"save_discussion": apiSaveDiscussion,
6161
"create_upload_url": apiCreateUploadURL,
6262
"send_email": apiSendEmail,
63+
"ai_job_poll": apiAIJobPoll,
64+
"ai_job_done": apiAIJobDone,
65+
"ai_journal": apiAIJournal,
6366
"save_coverage": gcsPayloadHandler(apiSaveCoverage),
6467
"upload_build": nsHandler(apiUploadBuild),
6568
"builder_poll": nsHandler(apiBuilderPoll),

dashboard/dashapi/dashapi.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"reflect"
1818
"time"
1919

20+
"github.com/google/syzkaller/pkg/aflow/journal"
2021
"github.com/google/syzkaller/pkg/auth"
2122
)
2223

@@ -988,6 +989,70 @@ type JobInfo struct {
988989
OnMergeBase bool
989990
}
990991

992+
type AIJobPollReq struct {
993+
Namespaces []string
994+
Workflows []AIWorkflow
995+
}
996+
997+
type AIWorkflow struct {
998+
Type AIWorkflowType
999+
Name string
1000+
}
1001+
1002+
type AIWorkflowType string
1003+
1004+
const (
1005+
AIPatching AIWorkflowType = "patching"
1006+
)
1007+
1008+
type AIJobPollResp struct {
1009+
ID string
1010+
Workflow AIWorkflow
1011+
Patching *AIPatchingJob
1012+
}
1013+
1014+
type AIJobDoneReq struct {
1015+
ID string
1016+
Error string
1017+
Patching *AIPatchingResult
1018+
}
1019+
1020+
type AIPatchingJob struct {
1021+
ReproOpts string
1022+
ReproSyz string
1023+
ReproC string
1024+
KernelConfig string
1025+
SyzkallerCommit string
1026+
}
1027+
1028+
type AIPatchingResult struct {
1029+
PatchDescription string
1030+
PatchDiff string
1031+
}
1032+
1033+
type AIJournalReq struct {
1034+
JobID string
1035+
Event journal.Event
1036+
//!!! what to do with retried/duplicated entries
1037+
//!!! Attempt int?
1038+
}
1039+
1040+
func (dash *Dashboard) AIJobPoll(req *AIJobPollReq) (*AIJobPollResp, error) {
1041+
resp := new(AIJobPollResp)
1042+
if err := dash.Query("ai_job_poll", req, resp); err != nil {
1043+
return nil, err
1044+
}
1045+
return resp, nil
1046+
}
1047+
1048+
func (dash *Dashboard) AIJobDone(req *AIJobDoneReq) error {
1049+
return dash.Query("ai_job_done", req, nil)
1050+
}
1051+
1052+
func (dash *Dashboard) AIJournal(req *AIJournalReq) error {
1053+
return dash.Query("ai_journal", req, nil)
1054+
}
1055+
9911056
func (dash *Dashboard) Query(method string, req, reply interface{}) error {
9921057
if dash.logger != nil {
9931058
dash.logger("API(%v): %#v", method, req)

0 commit comments

Comments
 (0)