feat(cli): list proposed tuning strategies
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
e868266de6
commit
8466f47ceb
3 files changed
+161
No files matched your search
@@ -184,6 +184,57 @@ func latestRun(db *sql.DB) (storedRun, error) {
|
||||
return r, err
|
||||
}
|
||||
|
||||
func proposedStrategies(db *sql.DB) (string, error) {
|
||||
rows, err := db.Query(`SELECT id, finished_at, args,
|
||||
(SELECT count(*) FROM protocol_results WHERE run_id = tune_runs.id
|
||||
AND protocol IN ('tls12', 'tls13') AND passes_ok = 3 AND passes_total = 3)
|
||||
FROM tune_runs WHERE state = 'PROPOSED' AND target = 'youtube.com' ORDER BY id DESC`)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer rows.Close()
|
||||
var text strings.Builder
|
||||
for rows.Next() {
|
||||
var id int64
|
||||
var finished, args string
|
||||
var results int
|
||||
if err := rows.Scan(&id, &finished, &args, &results); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if results != 2 {
|
||||
return "", fmt.Errorf("proposed run %d has incomplete protocol evidence", id)
|
||||
}
|
||||
fmt.Fprintf(&text, "Run %d; finished %s; youtube.com frontend only; PROPOSED, NOT ACTIVE\nArgs: %s\nRecorded combined check evidence: TLS1.2 3/3; TLS1.3 3/3.\n", id, finished, args)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if text.Len() == 0 {
|
||||
text.WriteString("No recorded strategies for youtube.com.\n")
|
||||
}
|
||||
text.WriteString("No configuration applied. Throughput, GGC and production health: NOT CHECKED by this command.\n")
|
||||
return text.String(), nil
|
||||
}
|
||||
|
||||
func strategiesYoutube(stdout, stderr io.Writer) int {
|
||||
db, err := openStore(databasePath())
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "error: strategies youtube database:", err)
|
||||
return 1
|
||||
}
|
||||
defer db.Close()
|
||||
text, err := proposedStrategies(db)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "error: strategies youtube database:", err)
|
||||
return 1
|
||||
}
|
||||
if _, err := fmt.Fprint(stdout, text); err != nil {
|
||||
fmt.Fprintln(stderr, "error: cannot write strategies:", err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func status(stdout, stderr io.Writer) int {
|
||||
db, err := openStore(databasePath())
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user