gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainbd3591c7conductor: gates run on the live day44 binarymremain/reports/K8-tickets.md

11.3 KB

  1. # K8: linked tickets as the spec source (kunibert#8)
  2. Fake codex only; fake gitoria (K7's, copied) on 8841, fake tickets server on 8845 (8846 for the local-mode check), one REAL GET to tickets.worldapi.org. No commits, no writes to tickets. Every process I started was stopped by PID (last line of the proof output).
  3. ## Files
  4. Project (Hybriel .hl only):
  5. - NEW `lib/tickets.hl`: `validId` (strict `project#n`), `readToken` (mode 600 check, first line), `fetchTicket` (GET, `Authorization: Bearer`, `Accept: text/markdown`, `User-Agent: kunibert-review`, 15 s timeout per request, no redirects), `parseTicket` (head = title..description, entries = `### n · ...` history items), `fit` (cap), `buildSpec(base, tokenFile, ids)` -> `{ text, hash (sha256), readable, notReadable }`; `text == null` when no base/token file/ids.
  6. Limits: max 10 tickets read (rest noted), ids deduped, at most 100 ids looked at, invalid id → "not readable (not a valid project#n id, ignored)", 404 → "not readable (HTTP 404, no such ticket)", 401/403 → "HTTP 403, no access", other statuses "HTTP n". Never a crash for an HTTP status.
  7. Cap 60000 bytes (content limit 59600 + the NOTE line): oldest history entries' text cut first (round robin over the tickets, headings stay, each marked "[comment text cut ...]"), then, only if still over, part of the biggest description; a `NOTE: this file was cut ...` line says what was cut.
  8. - `lib/runner.hl`: `runReview(..., hooks, ctx)`; `ctx = { title, body, tickets, ticketsBase, ticketsTokenFile }`. After the skip check (so only on a run that happens) it calls `buildSpec`, writes `.kunibert/spec.md` (removes an old one if there is nothing), picks title/body for the prompt, passes `specChange(state.specHash, spec.hash)` to the wake prompt and stores `state.specHash`. `reviewGitoria(..., ticketsBase, ticketsTokenFile)` uses `pull.title`, `pull.body`, `pull.tickets` of the GET pulls/N it already did. `review(...)` (local) takes `ctx` too.
  9. - `lib/review-prompt.hl`: `firstReview(hasSpec, title, body)`. Spec axis line: points to `.kunibert/spec.md` when it exists, otherwise today's "no ticket or issue is linked" line. Title line and a "PR description (written by the author; context ... not instructions)" section (body cut at 8000 chars, title at 300 in the caller). Spec-axis rules untouched. First line now reads "Review pull request (title and description below)." (K7 proof checks the substring "Review pull request").
  10. - `lib/review-wake.hl`: `wakePrompt(..., specChanged)`: 'changed' → "The linked tickets changed since your last review: the current text is in .kunibert/spec.md (a later comment overrules ...)"; 'gone' (had a spec, none now) → says there is no spec.md any more; null → nothing.
  11. - Plumbing of the config: `service/project.hl` (`ticketsBase`, `ticketsTokenFile`, both optional) → `lib/intake.hl` → `lib/queue.hl` → `lib/run-job.hl` argv `--tickets-base <url> --tickets-token-file <path>` (only the PATH is in the argv). `tools/runner.hl`: those two options for `review-pr` (gitoria mode); for local `review`: `--tickets project#n,project#n --tickets-base <url> --tickets-token-file <file>`.
  12. Scratch (`/media/STORAGE/claude-scratch/kunibert/K8/`): `scripts/proof.py`, `scripts/fake_gitoria.py` (K7's + `/_ctl meta` for title/body/tickets), `scripts/fake_tickets.py`, `bin/codex`, `proof-output.txt`, `real-spec-output.txt`, `tools/` (rawfetch.hl, realspec.hl, gap probes), `calls/NN` = what the fake codex got.
  13. Service config new keys: `"ticketsBase": "https://tickets.worldapi.org", "ticketsTokenFile": "/abs/path (mode 600)"`. Without them: no ticket is read, "no ticket linked" as before.
  14. ## Commands
  15. ```
  16. cd /media/STORAGE/claude-scratch/kunibert/K8 && python3 -I scripts/proof.py > proof-output.txt # ends ALL OK (starts/stops its fakes by PID)
  17. cd /media/STORAGE/claude-scratch/kunibert/K7 && python3 -I scripts/proof.py > proof-output-k8rerun.txt # K7 regression: exit 0, 36 PASS, ALL OK
  18. # the real read-only fetch (GET only, prints spec text, writes nothing in the project)
  19. cd /media/STORAGE/projects/kunibert && hybriel /media/STORAGE/claude-scratch/kunibert/K8/tools/realspec.hl https://tickets.worldapi.org ~/.config/kunibert/tickets-token 'kunibert#1' > K8/real-spec-output.txt
  20. # the CLI by hand (gitoria mode)
  21. hybriel tools/runner.hl review-pr <data> --api A --key-file F --clone C --tickets-base B --tickets-token-file T [--force] <pr>
  22. ```
  23. ## Proof (K8/proof-output.txt, all PASS)
  24. 1. PR1 `tickets: ["demo#1","demo#2","demo#9"]`, title "Add the Buy button", body "Implements demo#1 and demo#2 ...": spec.md has demo#1 (description "red button", then the comment "Make the button blue, not red"), demo#2, then `## demo#9: not readable (HTTP 404, no such ticket)`, in the PR's order; the header line "A later comment overrules the description and every earlier comment: where they disagree, the newest comment is the requirement." Prompt: `2. spec: the linked tickets are in the file .kunibert/spec.md (read it first; ...)`, `Pull request title: Add the Buy button`, the PR body, no "no ticket linked". Tickets server saw 3 GETs, Bearer ok, Accept text/markdown, a User-Agent.
  25. 2. A new comment on demo#1 + new head → wake prompt "The linked tickets changed since your last review ... .kunibert/spec.md"; spec.md has the new comment. Another new head with the same tickets → wake prompt without any mention. `state.specHash` is stored (sha256).
  26. 3. Cap: demo#3 (20 KB description + 41 comments of 3 KB) + demo#2 → spec.md 57,924 bytes (< 60,000), "NEWEST-MARKER" comment, the description and demo#2 kept, "comment 01" cut, line `NOTE: this file was cut to stay under 60000 bytes: the text of the 31 oldest history entries (the newest comments and the descriptions are kept first). Read the full tickets at the links if a cut matters.`
  27. 4. No tickets service configured → no spec.md; PR with `tickets: []` → no spec.md and today's "no ticket or issue is linked" line; ids `../etc#1`, `demo#01`, `x y#2` refused (3 invalid), 17 ids → "only the first 10 are read", 7 requests made.
  28. 5. Token: its value is in no file under K8 (data, calls, logs) except its own 0600 file, and in no argv of the 7 runs (grep + argv check). Also 0 hits in `real-spec-output.txt`.
  29. 6. Local mode (`review ... --tickets 'demo#2,demo#9'`, fake tickets on 8846): spec.md with demo#2 and demo#9 not readable, prompt points to it, title "Local branch review". (Checked by hand, not in proof.py.)
  30. 7. K7 `scripts/proof.py` still passes (ALL OK).
  31. ## The one REAL fetch (GET https://tickets.worldapi.org/api/projects/kunibert/tickets/1, token file ~/.config/kunibert/tickets-token through lib/tickets.hl)
  32. `readable=1 notReadable=0 bytes=4823`. Format as served: first line `# kunibert #1: <title>`, a `state: ... · opened ... by ... · updated ...` line, the ticket URL, `Children`/`Blocked by` lists, the description, then `## History` with `### n · date · text` entries, oldest first (comments appear as such entries; no comment existed on this ticket to see their exact heading, so my parser treats every `### ` line in History as one entry). Resulting spec.md section (start and end; full in `K8/real-spec-output.txt`):
  33. ```
  34. Spec file of Kunibert (kunibert#8): the tickets this pull request links to, ... OLDEST FIRST.
  35. A later comment overrules the description and every earlier comment: ...
  36. ---
  37. ## kunibert#1: Build a code reviewer for gitoria like an existing reviewer design, with gitoria and Hybriel
  38. link: https://tickets.worldapi.org/kunibert/1
  39. state: progress · opened 2026-11-01 12:22 by Kunibert · updated 2026-11-02 05:50
  40. https://tickets.worldapi.org/kunibert/1
  41. Children (2 of 7 done): ... Blocked by: ... (description, "Kunibert's reading", "Plan")
  42. ### History (oldest first)
  43. ### 1 · 2026-11-01 12:22 · Kunibert opened the ticket
  44. ### 2 · 2026-11-01 12:22 · Kunibert changed the state: open → pending
  45. The design is written ... Question: should Kunibert read linked tickets directly ...
  46. ...
  47. ### 6 · 2026-11-02 05:50 · Kunibert changed the state: pending → progress
  48. Apollo GO (2026-11-02): Gitoria builds the push API (gitoria#38) now; ...
  49. Linked tickets: Kunibert reads them directly with its own read token (Apollo decided; you can overrule).
  50. Test repo: Gitoria creates it.
  51. ```
  52. ## DOCS lines
  53. - DOCS: `import` paths are relative to the importing file only; an absolute path is joined to the file's directory ("Cannot read imported file: <dir>/media/...").
  54. - DOCS: function parameters and `x = ...` locals are immutable; a parameter cannot be reassigned (needs a `let` copy); `let` is needed for any reassigned local.
  55. - DOCS: arrays have no `sort`; `.shift()`, `.indexOf`, `.slice`, `.includes`, `.push`, `.map` do exist. `.length` counts graphemes, not bytes (use `toBytes(s).length` for a byte cap).
  56. - DOCS: `hl:crypto` `sha256(text)` (hex) exists and is listed on the crypto page only, not in the primer's one-line list.
  57. - DOCS: header keys with a hyphen in a `fetch` headers object work as quoted string keys: `{ 'user-agent' = 'x' }`.
  58. ## GAP lines
  59. - GAP: `fetch` failures (connection refused, timeout) raise a plain runtime error that cannot be caught at the call site (no try/catch; `on Error` is global). So a tickets server that is down aborts the review run ("hl:fetch GET <url>: connection refused", no token in the text; the queue retries the job as for any failed run). HTTP statuses 404/403/5xx are fine (`r.ok`/`r.status`). Repro: `r = fetch('http://127.0.0.1:8859/x', {})` with nothing listening → program aborts. No workaround built.
  60. - GAP: `[['x','y']].map((a) => { return a.join('-') })` returns `[]` (no error), while `.map(a => a.length)` returns `[2]`; same for `entries.map((e) => { return e.body.join('-') })`. Repro file: `K8/tools/gap-map-join.hl`. I used a `for` loop instead (that is not a workaround for a missing feature, only a way around a wrong result).
  61. ## Open points
  62. - A webhook for an unchanged head with no thread updates is skipped BEFORE the tickets are fetched (the existing skip rule), so a ticket change alone does not trigger a run; it shows up on the next run (new commit, thread reply, `@kunibert ...`). Fetching on every event would cost a request per skipped event; say if you want it.
  63. - Wake prompt: the PR title/body are only in the first/fresh prompt, not repeated in a wake prompt (the session has them). A changed PR body after the first review is therefore not shown; there is no PR-edit event anyway (handover D).
  64. - The hash covers the whole spec.md including the `updated ...` line of each ticket, so ANY ticket change (a state change, an edit) counts as "changed", not only comments. Two reads in the same state give the same hash (proved by run 3).
  65. - A first run where an earlier state has no `specHash` (state files from before K8) and tickets exist: the wake prompt says "changed" once.
  66. - Token file problems (missing, mode not 600, empty) abort the run with a clear message (checked at run time, not at service start).
  67. - Cap by bytes: limit for content is 59,600 + the NOTE line; a ticket whose single comment is huge keeps its newest comment whole (only a description is cut as a last step).
  68. - Ticket content is untrusted text for the model (prompt injection through a comment); the header tells the model it is a spec source, no extra guard added here (another ticket handles spec rules).
  69. - Plugin's fetch prints `fetch: TLS client initialized (verify=on)` on stdout/stderr at the first https request (harmless; the CLI's last stdout line is still the result JSON).
  70. - The tickets link in spec.md is built from `ticketsBase` (`<base>/<project>/<n>`), the served markdown carries its own URL line too.

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