kunibert
All repositories: gitoria
5.4 KB
# Mission K5: event intake and job queue (kunibert#5, step 1)Task (his words, kunibert#1): "basically we want [the consultant] now to build a similar tool with gitoria and hybriel."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.## Read first- 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.- /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).- /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).- 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.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).## Do not touchAnother 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`).## Build1. **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.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.3. **Answer at once** (well under 10 s); never do git or model work inside the request.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:- pull_request opened/reopened/synchronize, review_requested (force) → review job;- review_comment created, review_thread resolved/unresolved → review job with thread updates;- pull_comment created: `@kunibert reset` → reset then review; other `@kunibert <text>` → review job with the note; anything else → ignored;- pull_request closed/merged → drop the queued job, mark the PR closed; ping → log only.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.6. A tiny `GET /health` (queue length, running job, last error) without secrets.## ProofA test script in scratch signs bodies with the test secret (openssl/python) and POSTs them to the running service:- valid opened → 202/200 + job queued; same delivery again → duplicate, no second job;- wrong signature, missing signature, body changed after signing → 401, no job;- three synchronize events for PR 1 in a row → still ONE job with the newest head;- review_comment for PR 1 while queued → merged into that job;- `@kunibert reset` → job flagged reset; plain conversation comment → ignored;- closed → queued job dropped;- tick runs jobs one at a time (show the order and that runJob saw the merged job); runJob failing → retry with backoff, then failed;- restart the service → queued jobs and seen deliveries survive;- show a request answer time (ms).Stop the service at the end (by its PID, never by name pattern).## LimitsAbout 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/.Runtime: /media/STORAGE/projects/hybriel/native/zig-out/bin/hybriel (read HL-PRIMER for how a web project is run).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