kunibert
All repositories: gitoria
5.9 KB
# Mission K6: posting to gitoria (kunibert#6, step 4)Task (his words, kunibert#1): "basically we want vinzenz now to build a similar tool with gitoria and hybriel."This step only: after a review run, Kunibert writes the result back to the PR through gitoria's back-channel and reads thread updates from it. Gitoria's API is not live yet; build against its written contract and test against a small FAKE gitoria you run locally. No real gitoria, no tickets, no real codex.## Read first- The contract v1: /media/STORAGE/projects/WorldAPI/gitoria.worldapi.org/docs/apps-api.md (sections 0, 2, 3, 5, 6 and the changelog). [OPEN] names: keep them in ONE place.- /media/STORAGE/projects/kunibert/docs/konrad-handover/3-output-schema.md (comment format: badges, "N new, M still open" headers, "Not on changed lines", thread keys) and 1-design-and-lessons.md ("failures go to the operator, never as a PR comment").- /media/STORAGE/projects/kunibert/docs/DESIGN.md sections 3, 7; reports/K2-runner.md, K3-memory.md, K4-gitcache.md (what exists: `review-pr`, lib/gitcache.hl, lib/review-memory.hl threads T<n> and watermarks).- /media/STORAGE/projects/hybriel/docs/HL-PRIMER.md, docs/CODE-ORDER.md; hl:fetch (plugins/fetch, its doc page under /media/STORAGE/projects/hybriel/projects/homepage/generated/pages/), hl:fs, hl:crypto.Copy working shapes from the docs. Not covered → DOCS line; framework gap → GAP line with a minimal repro, no workaround. Hybriel .hl only in lib/ and tools/ (Python allowed only for the fake server and test scripts in scratch).## Do not touchAnother worker is building service/, lib/intake.hl, lib/queue.hl, lib/gitoria-events.hl (event intake). Don't edit those. You may change lib/runner.hl, tools/runner.hl, lib/review-memory.hl, and add new lib files (e.g. lib/gitoria-api.hl, lib/review-post.hl).## Build1. **Client** lib/gitoria-api.hl: `{api}` comes from config, never built. App key from a key file (mode 600, path argument; tests: scratch). Token via `POST {api}/apps/token`, cached in memory/data until shortly before `expires`; on 401 fetch a new token once and retry. 429 → wait Retry-After (capped) and retry; other errors → structured error. Never log the key, the token or Authorization headers. The token also feeds lib/gitcache.hl's fetch (pass the token, not a file, or write it to a 600 temp file that is removed: your choice, say which).2. **review-pr against gitoria**: `tools/runner.hl review-pr <data> --api <url> --key-file <f> <pr-number>`: `GET pulls/N` gives clone URL? (no: clone comes from the event's repo.clone; take it as an argument `--clone <url>` too) target, head, mergeBase; then fetch (step 2 code), threads from `GET pulls/N/threads` (all pages) replace the local --threads file: new comments = `seq` above the stored watermark (switch the watermark from comment id to `comment.seq`), resolved flips; keep the old local mode working.3. **Status**: `PUT statuses/<head>` context `kunibert`: `pending` at start; at the end `success` (approve/comment) or `failure` (request_changes); `error` when the run failed (summary short, no stack, no secrets; full error to stderr / operator log).4. **Review**: one `POST pulls/N/reviews` with head, verdict, body and inline comments in Konrad's format (badge, severity, axis, title, then body; header counts "N new, M still open" per axis; findings off the diff under "Not on changed lines"). Before sending, check each inline line against the local `git diff -M -U3 <merge-base> <head>` (new-side lines inside hunks, new-side path) and move misses to the body. If gitoria still answers 422 with details, move those comments to the body and send once more. 409 stale_head → do not post, status untouched, return `{"skipped":"stale_head"}` (a newer event will come). Max 100 inline; the rest into the body. Body ≤ 20,000 chars (truncate with a note).5. **Thread ids**: store gitoria's thread id for each new T<n> from the review answer (match by index/path/line). Replies from the model (`replies` in schema.json: key, body, resolve) → `POST threads/:id/replies`, and resolve:true → `POST threads/:id/resolve {"resolved":true}`.6. Skips (same head, nothing new) post nothing.## Proof (fake codex only; saved outputs in /media/STORAGE/claude-scratch/kunibert/K2, K3, K4)A fake gitoria in scratch (Python http.server on 127.0.0.1, port in 8840–8859, check `ss -ltn`) implementing the v1 routes you use, keeping every request in a log, with switches to answer 401 once, 429 once, 422 for one line, 409. It serves the git refs from a local bare repo (the fetch may use file:// in the test; say so).- First run → status pending, then one review with the inline comment on the right path/line, then status failure (request_changes); state has gitoria's thread id for T1.- Fake adds a human reply (seq above watermark) and a new commit; second run → the reply reached the prompt, the model's reply + resolve were posted to that thread id, status success.- A finding on a line outside the diff → in the body, not inline. A forced 422 → resend without that comment, it shows in the body.- 409 stale_head → nothing posted, skipped. 401 once → new token, success. 429 → waits and retries.- Fake codex failing → status `error`, no PR comment.- Grep the fake's log and all Kunibert logs/outputs: the key and token values never appear outside the Authorization header the fake received.- K4's proof.py still passes (run it: python3 -I /media/STORAGE/claude-scratch/kunibert/K4/proof.py).Stop the fake server at the end by its PID.## LimitsAbout 60 tool calls. No real codex, no sudo, no network outside localhost, no commits, no tickets, no messages to others. Scratch only under /media/STORAGE/claude-scratch/kunibert/K6/.Runtime: /media/STORAGE/projects/hybriel/native/zig-out/bin/hybriel, launched from /media/STORAGE/projects/kunibert.Report: /media/STORAGE/projects/kunibert/reports/K6-posting.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