gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainfe209ffeMerge branch 'w56-owner-members' into mainGitoriamain/reports/W44-REPORT.md

8.6 KB

  1. # W44 report — reviews, inline threads and comments for apps (gitoria#44)
  2. Branch `w44-reviews` (worktree `/media/STORAGE/claude-scratch/gitoria/W44/wt`), from main 49533a5. Not pushed, not deployed, no ticket written. Contract docs/apps-api.md v1.2.1 §5, §6 was not changed.
  3. ## Built
  4. Commits (plain subjects, no attribution), two:
  5. 1. `ea587d9` reviews with inline threads, replies, resolve and the PR conversation for apps (lib/reviews.hl, tests/reviews.mjs; also deploy.sh GATES)
  6. 2. `888dbf8` unknown API paths answer the contract's JSON 404 and sit above the page routes (also the README section and the tests/browser.mjs assertion)
  7. Files: `lib/reviews.hl` (central logic and the three tables), `lib/reviews-helpers.hl` (answer shapes, paging, sorting, the diff's commentable lines, ms timestamps), `lib/api.hl` (7 thin wrappers `appPulls appPull appReviews appThreads appReply appResolve appComments`), `lib/api-helpers.hl` (`answerOf`, `jsonOfRequest`: 413 over 1 MB, 400 invalid_json), `project.hl` (each route once via `apiPatterns`, so on `/api/…`, `/api/<repo>/…` and `/<repo>/api/…`), `deploy.sh` (GATES + `tests/reviews.mjs`), `tests/reviews.mjs`, `tests/reviews-seed.hl`, `tests/reviews-probe.hl`, README section. Every route starts with `appOfRequest`.
  8. Store (mpackdb, keyed by repo id + PR number, never the slug): `reviews.db` {id, rid, key, number, app, head, verdict, body, created ms}, `threads.db` {…, path, line, head, resolved, seq (= seq of its first comment, the list order), created}, `comments.db` {id, rid, key, number, seq, thread|null, author {type,id,name}, body, created ms}.
  9. Routes done: GET pulls (state open|all, cursor, limit; newest number first), GET pulls/N (pullObject), POST + GET pulls/N/reviews, GET pulls/N/threads, POST threads/:id/replies, POST threads/:id/resolve, GET + POST pulls/N/comments.
  10. - Review: head = current or any earlier head (`headsOf`), else 409 stale_head (nothing stored; a text that is no sha also gives 409, a missing head or a number gives 422). Line check against `git diff -M -U3 <merge-base(current target tip, head)> <head>`, new side, added or context lines, new-side path after a rename. Any bad line → whole review 422 `invalid` with `details [{index,path,line,reason}]`; max 100 comments (101 → 422). Threads on an earlier head: `outdated` is computed as `thread.head != current head`, so they are outdated at once and the old ones turn outdated when the PR moves.
  11. - `reason`: `line_not_in_diff` (path is in the diff, line is not on a hunk's new side) or `no_such_file` (path is not a new-side path of the diff: unknown, deleted, unchanged file, or the OLD name of a rename).
  12. - Bodies ≤ 65,536 chars (65,536 stored, 65,537 → 422), request over 1 MB → 413 too_large. Another app's thread, another PR's thread, another repo, unknown id → 404.
  13. - Current-verdict helper `currentVerdict(repoId, number, appId)` in lib/reviews.hl: the app's latest approve or request_changes (a `comment` review does not clear request_changes); only when it has none of those, its latest comment review; null without a review. Tested by `tests/reviews-probe.hl`.
  14. - **seq and a deploy swap**: seq is a per-repo counter that grows strictly. One process counts in memory (seeded from the highest seq in the table). The number is claimed with `mkdir storage/mpackdb/seq/<repo id>/<n>` (atomic across processes, like the delivery claims in events.hl); the loser takes the next number. So two processes writing during the swap never hand out the same number, and each process's own numbers grow. Limit: a number claimed first can be written to the table a moment after a higher one from the other process, so an app that reads exactly in that window can pass the lower one by (watermark gap). One empty folder stays per comment. Gate proves 6 alternating posts on two processes → 6 different, growing numbers.
  15. - The two additions from Kunibert's live test:
  16. (a) `notFoundApi` now answers `{"error":{"code":"not_found","message":"no such endpoint","details":null}}` (404, application/json). The old body was asserted in tests/browser.mjs (regex on "no such endpoint"); it now checks JSON content type and `error.code`.
  17. (b) Cause of the HTML page live: `/api/pulls` also fits the organization page route `/:orepo/pulls` (orepo = `api`); no API route `/api/pulls` existed on live, and the `/api/*` fallback was the LAST route, so the page route won. Fix: `/api/*` and `/:orepo/api/*` (JSON 404) now stand above the page routes, after all listed API routes. `api` is a reserved name for repos and organizations, so no page is lost. Also fixed for unlisted `/api/tickets`, `/api/code`, `/api/releases`, `/api/settings`… which answered HTML before. Proof on the old order (my pulls routes but old fallback order): 7 of the new checks fail (`/api/tickets`, `/api/code`, `/api/releases` → 200 HTML; the others give the old body); with the fix all pass. Gate checks: Content-Type application/json and a JSON body for GET `/api/pulls?state=open`, `/api/pulls/1`, `/orgrepo/api/pulls?state=open`, `/api/orgrepo/pulls?state=open`; page routes `/pulls` and `/orgrepo/pulls` still HTML.
  18. ## Tests (LC_ALL=C, ports 8720–8729; HL_PORT_BASE=8525 so the browser tier's debug block is 8725–8734, the same shape deploy-init uses; each gate with its own port variables set into 8720–8724)
  19. `node tests/reviews.mjs` → 98 passed, 0 failed (real git over HTTP, own storage, own server, a restart and a second server process): auth 401/404 (foreign app, foreign repo), pulls list/paging/state/cursor errors, pull object, line kinds (context, added, hunk edges, renamed path, new file), 6 refusal reasons in one review with nothing stored, malformed comments, 409, 422s, 65,536/65,537, 100/101 comments, 413, 400 invalid_json, earlier-head review (outdated at once, line check on that head's diff), 113 threads paged by 40 in seq order, own-only views for a second app, replies, resolve and reopen, 404s for Beta/Gamma/wrong PR/unknown thread, conversation both apps, paging, seq order over threads and conversation and PRs, per-repo seq (other repo starts at 1), restart, second process, current verdict, org address both spellings, JSON content types, unknown API paths.
  20. All gates in deploy.sh's GATES, run twice in order (before and after the (a)/(b) change; last run): signin-return 3/0, check-theme 73 files 0 problems, browser 266/0, security 82/0, private 158/0, ident-access-gitoria 30/0, apps 95/0, pull-numbers 48/0, pull-ssh 20/0, app-token 42/0, reviews 98/0, events 52/0. 0 failed, no flake. (The runner printed "port 8720 busy" before apps and pull-ssh: a socket of the gate before it; nothing of mine listens afterwards.)
  21. ## Not covered / open
  22. - Rate limits and the 429 (contract §6, #47). `PUT /statuses`, deliveries routes untouched (#46 / #43). No UI and no events (#45). No Chrome/lisbeth proof: this ticket has no UI.
  23. - Review body is stored on the review only; it has no seq and is not a conversation comment.
  24. - Shape errors (missing/wrong type) use 422 `invalid` with `details [{index?, field, reason}]` (an extension to the two documented reasons). A path git quotes (control characters in the name) is not commentable (`no_such_file`). A merged PR whose head is already in the target has an empty diff: every inline comment is refused.
  25. - `GET pulls` runs ~3 git calls per PR on the page (limit 100 → slow on big repos).
  26. - Cursors: pulls = number, threads/comments = seq, reviews = `<ms>_<id>`. A bad cursor → 422.
  27. - The review/threads/comments writes are not one transaction: a crash in the middle of a 100-comment review leaves the review and some threads.
  28. ## DOCS / GAP
  29. - DOCS: HL-PRIMER (whole), CODE-ORDER, COMPONENTS "hl:web — a function route and its request", mpackdb README. Not needed: §11/§9/§1/§4/§12 (no View here). Questions the docs did not answer: none blocking.
  30. - GAP (as in appExchange, unchanged): `JSON.parse` of broken JSON is a located error that ends the request (500); there is no safe parse. Repro: `printf '{"head":"x",}' | curl -XPOST -H 'Authorization: Bearer gat_…' --data-binary @- {api}/pulls/1/reviews` → 500 instead of 400. Only bodies that do not start with `{` and end with `}` get 400 invalid_json.
  31. - GAP (small): `hl:time` `timestamp(ms)` has no milliseconds, so the ms timestamp is built by hand (`isoMs` in reviews-helpers.hl).
  32. - Clarity: `'\\'` in a string literal (backslash) is unclear (the primer says `\` only masks the delimiter), so I compare `charCodeAt(0) == 92`.
  33. ## Cleanup
  34. Processes started by me: only gate servers/browsers, all ended with their gates; `pgrep` shows no process of mine, no Chrome with a cwd under my scratch dir; no tunnel, no lisbeth tab. The `bin` symlink in the worktree is excluded through `.git/info/exclude` (not committed).
  35. Requests: about 50.

Branches

Latest commits

  • fe209ffeMerge branch 'w56-owner-members' into mainGitoria
  • fa0754c8|||PR repository owner transfer and members API (#55)mre
  • 8862e537Merge branch 'w55-rename-org' into mainGitoria
  • 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
  • 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
  • 499f25f2Review fixes for the Settings organization move (#53)mre
  • ed3b922b|||PR move a repository into an organization in Settings (#53)mre
  • 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
  • 9f7ce8d8Preserve rename compatibility and live page titlesmre
  • c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
  • ce08920dMerge branch 'w52c-header-phone' into mainGitoria
  • 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
  • e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
  • c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
  • 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
  • 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
  • 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
  • 155861f6Merge branch 'w52-person-approval' into mainGitoria
  • b5435de8|||PR person approvals: second Kunibert round (#52)mre
  • 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre