gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainbd3591c7conductor: gates run on the live day44 binarymremain/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 [the consultant] 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

  • bd3591c7conductor: gates run on the live day44 binarymre
  • 47f747a7records: jukebox #9 fix livemre
  • 0a3169fdMerge branch 'vendored-size' into mainKunibert
  • e447bb09Vendored size fix: keep renames with an app side whole; type the filter parameter (L10)mre
  • 99ccc742Vendored size fix: no renames in the app diff, filter the resumed delta toomre
  • 1a52e100|||PR Diff size limit counts only app files when vendored paths are setmre
  • 50a1867estatus: jukebox #9mre
  • c57484e6log: jukebox #9 diff sizemre
  • 795a20carecords: guard fix live (PR 8)mre
  • 6981d96fMerge branch 'fresh-on-nocmd' into mainKunibert
  • 37c47840runner: one shared prompt for both fresh-session fallbacks (L16)mre
  • f945d2e1|||PR runner: a resumed run with no command on a new head gets one fresh session instead of a tool errormre
  • 10b2a49estatus: PR 314, guard fix proposedmre
  • e73995a3log: hycon PR 314 approved after fresh reviewmre
  • f60427falog: hycon PR 314 false tool errormre
  • 481974f7log: Hermes accepts PR 259 findingmre
  • bb0976acrecords: hycon PR 259 design findingmre
  • 5c637c24records: hycon PR 259 false tool errormre
  • a344c406log: routger 132 reviewedmre
  • 56e70dcbrecords: review time limit 1800 s (routger 132)mre