Review recorded explanations of a solution on the site
Test and publish the site / test (push) Successful in 2m4s
Test and publish the site / publish (push) Successful in 1m44s

The admin can upload a recording of themselves explaining a problem's
solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and
get interview-style feedback, committed as reviews/<id>.md so every
attempt is kept.

Claude can't take audio, so the recording is transcribed first by an
OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY,
with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler
words and when complexity first comes up are measured from the word
timestamps and given to Claude with the timestamped transcript, the
statement and optionally the code. The reply covers the verdict, scores
in five areas, the approach and its complexity, missed edge cases,
delivery and what to work on.

Recordings are kept for playback in an S3 bucket (Garage) when the
S3_* settings are given, and are thrown away otherwise. Reviews are
admin-only. The job runs in the background like Explain, and the
statement fetch and save-error handling are now shared between the two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 01:56:55 +01:00
co-authored by Claude Opus 5.5
parent 33027429c5
commit 63608f130c
25 changed files with 2381 additions and 54 deletions
+41 -20
View File
@@ -124,16 +124,9 @@ func (s *Server) explain(in explain.Input, link string) error {
ctx, cancel := context.WithTimeout(context.Background(), explainTimeout)
defer cancel()
// No statement saved: fetch it, and save it alongside the explanation
// so the next one does not need the judge.
fetched := ""
if strings.TrimSpace(in.Statement) == "" {
md, err := s.fetcher().Fetch(ctx, link)
if err != nil {
log.Printf("[explain] %s: fetching %s: %v", in.Name, link, err)
return fmt.Errorf("could not fetch the statement (%v); paste it into the editor", err)
}
in.Statement, fetched = md, md
fetched, err := s.ensureStatement(ctx, "explain", in.Name, &in.Statement, link)
if err != nil {
return err
}
md, err := explain.Generate(ctx, s.Claude, in, time.Now())
@@ -154,17 +147,45 @@ func (s *Server) explain(in explain.Input, link string) error {
return err
}
pdir := filepath.Join(dir, status, name)
if fetched != "" {
// Only if it is still missing: the admin may have pasted one
// while Claude was working.
if _, err := os.Stat(filepath.Join(pdir, "problem.md")); os.IsNotExist(err) {
if err := writeOrRemove(filepath.Join(pdir, "problem.md"), fetched); err != nil {
return err
}
}
if err := saveFetched(pdir, fetched); err != nil {
return err
}
return writeOrRemove(filepath.Join(pdir, "explain.md"), md)
})
return jobSaveError("explain", name, "the explanation was written but could not be saved to git", err)
}
// ensureStatement fetches the statement when none is saved, so a job can
// run on a problem that only has a link. It returns what it fetched, for
// saveFetched to keep alongside the job's result so the next job does not
// need the judge. tag is the log prefix.
func (s *Server) ensureStatement(ctx context.Context, tag, name string, statement *string, link string) (string, error) {
if strings.TrimSpace(*statement) != "" {
return "", nil
}
md, err := s.fetcher().Fetch(ctx, link)
if err != nil {
log.Printf("[%s] %s: fetching %s: %v", tag, name, link, err)
return "", fmt.Errorf("could not fetch the statement (%v); paste it into the editor", err)
}
*statement = md
return md, nil
}
// saveFetched writes a statement ensureStatement fetched, but only if it is
// still missing: the admin may have pasted one while Claude was working.
func saveFetched(pdir, fetched string) error {
if fetched == "" {
return nil
}
if _, err := os.Stat(filepath.Join(pdir, "problem.md")); os.IsNotExist(err) {
return writeOrRemove(filepath.Join(pdir, "problem.md"), fetched)
}
return nil
}
// jobSaveError turns a job's Mutate error into a message for the admin.
func jobSaveError(tag, name, unsaved string, err error) error {
var re *requestError
switch {
case err == nil:
@@ -174,8 +195,8 @@ func (s *Server) explain(in explain.Input, link string) error {
case errors.Is(err, repo.ErrRejected):
return errors.New("the repository changed while saving; try again")
default:
log.Printf("[explain] %s: saving: %v", name, err)
return errors.New("the explanation was written but could not be saved to git")
log.Printf("[%s] %s: saving: %v", tag, name, err)
return errors.New(unsaved)
}
}