Keep site jobs across restarts, meter Claude spend, harden admin routes
- internal/jobs replaces explain.Jobs: one registry for every kind of background job, with records in DATA_DIR/jobs. A job's draft is written before its commit, so a failed commit can be saved again (POST /jobs/<kind>/<key>/save) and a restart mid-commit resumes it, without paying Claude twice. - Graceful shutdown: SIGTERM stops new jobs and waits SHUTDOWN_GRACE for running ones while still serving the pages that poll them. - internal/usage records every Claude call's tokens and estimated cost in DATA_DIR/usage.jsonl; CLAUDE_MONTHLY_BUDGET refuses new jobs (429) once a month reaches it. The stats page shows the admin the spend. - auth.SameOrigin refuses cross-origin writes to admin routes. - The LeetCode importer runs the clone's script without the server's secrets in its environment. - A sync that leaves HEAD where it was skips the re-index. - docs_test.go checks README's route table against the routes, and the CLI page against the root README's commands. - The repo is going private: Gitea links on the site are admin-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
// there a small input that breaks it.
|
||||
//
|
||||
// The code is a draft, so unlike an explanation or a review nothing is
|
||||
// committed. The answer is kept in memory with the source it judged
|
||||
// (explain.Jobs.StartWith), and the page anchors each issue to its line in
|
||||
// committed. The answer is kept as the job's result with the source it judged
|
||||
// (a jobs.Kind with no save), and the page anchors each issue to its line in
|
||||
// the editor.
|
||||
//
|
||||
// Claude is given the saved tests' verdicts from the runner along with the
|
||||
@@ -285,7 +285,7 @@ func capped(s string, n int) string {
|
||||
// Generate asks Claude and returns the evaluation.
|
||||
func Generate(ctx context.Context, a explain.Asker, in Input, now time.Time) (*Evaluation, error) {
|
||||
var r Result
|
||||
err := a.JSON(ctx, claude.Request{System: System, User: Prompt(in), Schema: Schema, MaxTokens: maxTokens}, &r)
|
||||
err := a.JSON(ctx, claude.Request{Tag: "evaluate", System: System, User: Prompt(in), Schema: Schema, MaxTokens: maxTokens}, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user