gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitcd4cb09ccd4cb09cNo review and status error when the model's tools did not run (kunibert#11)Kunibertcd4cb09c/missions/K5-intake.md

5.4 KB

  1. # Mission K5: event intake and job queue (kunibert#5, step 1)
  2. Task (his words, kunibert#1): "basically we want vinzenz now to build a similar tool with gitoria and hybriel."
  3. This step only: Kunibert takes gitoria's signed event POSTs, checks them, answers at once, and keeps one queued review job per PR, worked off one at a time. Gitoria's side is not built yet; you build against its written contract and test with events you sign yourself. No real gitoria calls, no tickets, no posting, no real codex.
  4. ## Read first
  5. - The contract: /media/STORAGE/projects/WorldAPI/gitoria.worldapi.org/docs/apps-api.md (sections 0, 4; skim 5). Items marked [OPEN] may change: keep event names and field access in ONE adapter file.
  6. - /media/STORAGE/projects/kunibert/docs/DESIGN.md (sections 2, 3, 5, 6) and reports/K3-memory.md (state per PR, generation counter; the missing cross-process lock is solved here by having ONE process own all jobs).
  7. - /media/STORAGE/projects/hybriel/docs/HL-PRIMER.md, docs/CODE-ORDER.md; /media/STORAGE/projects/hybriel/COMPONENTS.md section "hl:web — a function route and its request" (req.bytes = raw body, req.headers lowercased) and §7 (project manifest) and §11 (routing); plugins time, fs, crypto (/media/STORAGE/projects/hybriel/projects/homepage/generated/pages/crypto.md).
  8. - HMAC: hl:crypto documents no `hmac` call, but `hkdfExtract(Bytes salt, Bytes ikm)` is exactly HMAC-SHA256(salt, ikm) (RFC 5869 §2.2), so HMAC(secret, body) = hkdfExtract(secret-bytes, req.bytes). Use that and add a DOCS line asking for a named hmacSha256. Compare signatures in constant time if the docs offer a way; otherwise say so in a GAP line.
  9. Copy working shapes from the docs. Not covered → DOCS line; framework gap → GAP line with a minimal repro, no workaround. Hybriel .hl only, no JavaScript/TypeScript, no Python in lib/ or tools/ (Python/curl only for test scripts in scratch).
  10. ## Do not touch
  11. Another worker is changing tools/runner.hl and lib/runner.hl right now. Create only NEW files (e.g. service/ for the web project, lib/intake.hl, lib/gitoria-events.hl, lib/queue.hl). The queue calls the review through ONE function `runJob(job)` in a new file; for now it only records the job it would run (later it calls `review-pr`).
  12. ## Build
  13. 1. **Route** `POST /hook/gitoria` in a Hybriel web service (port from argument/config; tests use a free port in 8840–8859, check `ss -ltn` first). Secret(s) from a file outside the repo (path in config; tests: a file under scratch), keyed by `repo.id` with one default for now.
  14. 2. **Checks**, each with its own HTTP answer and log line (never log the secret or the body of a bad request): signature `X-Push-Signature-256` over the raw bytes (bad/missing → 401); `X-Push-Event` known (unknown → 202 ignored); JSON parse (bad → 400); `X-Push-Delivery` seen before → 200 duplicate, no new job. Delivery ids are kept (with time) in the data dir and pruned after 7 days.
  15. 3. **Answer at once** (well under 10 s); never do git or model work inside the request.
  16. 4. **Queue**: one job per (repo.id, PR number), stored in the data dir so a restart keeps it. A newer event for the same PR updates the queued job instead of adding one (keep newest head by `time`/`pull.head`, merge flags: force, reset, thread updates, pr-comment texts). Mapping from events:
  17. - pull_request opened/reopened/synchronize, review_requested (force) → review job;
  18. - review_comment created, review_thread resolved/unresolved → review job with thread updates;
  19. - pull_comment created: `@kunibert reset` → reset then review; other `@kunibert <text>` → review job with the note; anything else → ignored;
  20. - pull_request closed/merged → drop the queued job, mark the PR closed; ping → log only.
  21. 5. **Worker**: a hl:time timer tick (design note: a task cannot be detached from a request) takes ONE job at a time, oldest first, marks it running, calls `runJob`, removes it on success; on failure keeps it with a retry count and backoff (max 3, then `failed` + operator log line). A job for a PR that is running is not started twice; an event arriving meanwhile queues a follow-up.
  22. 6. A tiny `GET /health` (queue length, running job, last error) without secrets.
  23. ## Proof
  24. A test script in scratch signs bodies with the test secret (openssl/python) and POSTs them to the running service:
  25. - valid opened → 202/200 + job queued; same delivery again → duplicate, no second job;
  26. - wrong signature, missing signature, body changed after signing → 401, no job;
  27. - three synchronize events for PR 1 in a row → still ONE job with the newest head;
  28. - review_comment for PR 1 while queued → merged into that job;
  29. - `@kunibert reset` → job flagged reset; plain conversation comment → ignored;
  30. - closed → queued job dropped;
  31. - tick runs jobs one at a time (show the order and that runJob saw the merged job); runJob failing → retry with backoff, then failed;
  32. - restart the service → queued jobs and seen deliveries survive;
  33. - show a request answer time (ms).
  34. Stop the service at the end (by its PID, never by name pattern).
  35. ## Limits
  36. About 60 tool calls. No sudo, no network outside localhost, no commits, no tickets, no messages to others. Scratch (data, secrets, logs, scripts) only under /media/STORAGE/claude-scratch/kunibert/K5/.
  37. Runtime: /media/STORAGE/projects/hybriel/native/zig-out/bin/hybriel (read HL-PRIMER for how a web project is run).
  38. Report: /media/STORAGE/projects/kunibert/reports/K5-intake.md (files, exact commands, proof output, DOCS/GAP lines, open points). Stop when done or blocked.

Branches

Latest commits

  • cd4cb09cNo review and status error when the model's tools did not run (kunibert#11)Kunibert
  • a6b54efaStatus updatemre
  • 5a72268eRecords: #4-#10 done, #11 started, review package on #1mre
  • 194c7da6Records: real proof greenmre
  • cdfa94a9Records: AppArmor profile for the review sandboxmre
  • c1bf02d8Status: sandbox blockermre
  • 88aaacc5Records: real proof part 2 (posting works, sandbox blocked by AppArmor userns)mre
  • 401df4e8Records: review user logged inmre
  • 6ca681b3Records: login command, status cleanupmre
  • 6b8d763cRecords: review user, device login startedKunibert
  • 07025b99Open the job worktree read-only for the review user before each model runKunibert
  • 2a44bd54Runner CLI: --review-user/--codex-bin/--work-dir work in every modeKunibert
  • 2177f66fReview model runs as its own unix user (reviewUser, codexBin, workDir)Kunibert
  • 35df8306Records: live service on byrodin, real proof part 1Kunibert
  • 7480a98dkunibert.service: SIGTERM stop is a clean exitKunibert
  • 3a8d93f9gitoria client: parse only JSON answers, accept a plain-text errorKunibert
  • c9b48bfeVendor Hybriel plugins; deploy ships bin/ from zig-outKunibert
  • a41ba15fKunibert: event intake, git cache, review runner, posting, linked tickets, deploy filesKunibert