gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfb9e7554fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemrefb9e7554/missions/W43-events.md

5.7 KB

  1. # W43 — gitoria sends signed events to connected apps (gitoria#43, part of the push API #38)
  2. TASK (his words, unchanged): "gitorias first job is to evaluate how to make a push api where external apps can register to interact with gitoria. first use case being a code reviewer." Build GO by Apollo 2026-11-02. This part: https://tickets.worldapi.org/gitoria.worldapi.org/43
  3. W43, PORTS = 8720–8729 (the conductor's gate run may hold them until ~07:00: check `ss -ltn`, wait if busy), branch w43-events from main 1997e77
  4. (has #40 lib/pullsync.hl: syncPulls returns CHANGES, pullObject builds the contract's pull JSON, /__git/pushed covers ssh pushes; and #41 lib/apps.hl: apps table with hookUrl + secret, pingAfterConnect hook point).
  5. #42 (tokens, auth helper appOfRequest) is being built in parallel and is NOT on main: the routes GET {api}/deliveries and POST …/redeliver wait for it — build the store and a function redeliver(appId, deliveryId) now, not the routes.
  6. ## Scope (contract docs/apps-api.md v1.2 §4)
  7. 1. raiseEvent(repo, event, action, extra, senderId): one delivery row per connected app of the repo (never to the app that caused it: extra may name it), body built ONCE at raise time (the common body: event, action, delivery uuid, time, repo{id,full,private,api,clone}, app{id,name}, sender{id,name}|null, + extra), stored as the exact bytes that are signed and sent. Generic: #44/#45 will call it for review_requested, review_comment, pull_comment, review_thread.
  8. 2. Wire it now: every change of syncPulls (HTTPS push, ssh push via /__git/pushed after, Merge button) → pull_request opened/reopened/synchronize{before,after,forced}/closed/merged{mergeCommit} with pull = pullObject. ping at connect (pingAfterConnect, both ways A and B) and a "Send ping" button per app in Settings → Apps.
  9. 3. Deliveries table {id (uuid), app, repo, event, action, body, tries, nextAt, status pending|delivered|failed, lastCode, created, updated}. Raising only writes rows: a push or a page action must never wait for a receiver.
  10. 4. Sender: an hl:time timer (`every`, plugins/time/server.hl) in the server that takes due rows: POST hookUrl, headers exactly as contract §4 (Content-Type, User-Agent gitoria, X-Push-Event, X-Push-Delivery = the row's uuid, X-Push-Signature-256 = 'sha256=' + hex HMAC-SHA256(key = the secret's 64 hex characters as ASCII bytes, message = the raw body bytes)). HMAC: hl:crypto hkdfExtract(salt, ikm) IS HMAC-SHA256(salt, ikm) (RFC 5869 §2.2) — prove it with the RFC 4231 test case 2 vector and a cross-check against `openssl dgst -sha256 -hmac` in your gate. fetch: timeout 10 s, maxRedirects 0, 2xx = delivered. Retry 1 min, 5 min, 30 min, 2 h, 6 h, then failed. Re-check urlAllowed at send time. Update the app's lastDelivery/lastStatus (shown in Settings → Apps).
  11. 5. Two processes share the storage during a deploy (deploy.sh: the standby): a row must be sent by only ONE of them — claim it (e.g. a claimedBy/claimedUntil field written before the POST, compare-and-set as the table allows) and explain why it holds. Retention: delete rows older than 7 days, at most 200 per app.
  12. 6. Tests: tests/events.mjs in GATES with a tiny local receiver (node http on a port of yours, allowed through GITORIA_APP_HOSTS in the test env): opened via HTTPS push, synchronize with forced, merged via the Merge button, closed by deleting the branch, ping; signature verified by the receiver; receiver down → retry happens (short retry steps via a test-only env), duplicate delivery id same on retry; no delivery to another repo's app; push answer time not slowed by a receiver that hangs.
  13. ## Read first
  14. - /media/STORAGE/projects/WorldAPI/worldapi-conductor/archive/2026-10-31/WORKER-RULES.md (all) and RULINGS.md in the same folder.
  15. - /media/STORAGE/projects/hybriel/docs/HL-PRIMER.md, /media/STORAGE/projects/hybriel/docs/CODE-ORDER.md,
  16. /media/STORAGE/projects/hybriel/COMPONENTS.md "hl:web — a function route and its request", "§11 — Routing", "§9 — Data", and for any
  17. View change "§1", "§4 — Styles", "§12 — Composition" (List/Conditional rendering). Plugin READMEs you use (mpackdb, crypto, fetch, proc, time).
  18. Copy a working shape from the docs or from gitoria's own code. A framework gap: write a DOCS/GAP line in the report with a tiny repro; no workaround, no hand-written JavaScript.
  19. - THE CONTRACT: docs/apps-api.md v1 (fixed; anything you cannot build as written → report, do not change the contract).
  20. - Evaluation: reports/E38-push-api-eval.md (sections 1–6) and reports/E38b-konrad-needs.md. App: README.md, project.hl, lib/pulls.hl, lib/transport.hl, lib/tokens.hl, lib/tickets.hl (connect flow), lib/repos.hl.
  21. ## Rules
  22. - Work in a git worktree of /media/STORAGE/projects/WorldAPI/gitoria.worldapi.org (base main 1997e77), everything under /media/STORAGE/claude-scratch/gitoria/W43/ (REPORT.md there). Never touch live (byrodin), his repos or live data; test data only in your own temp storage.
  23. - Hybriel stays on the vendored set (do not re-vendor).
  24. - Ports: only PORTS (check `ss -ltn` first).
  25. - Secrets: keys/tokens stored as sha256 only (like lib/tokens.hl); the signing secret is server-readable but never sent to a page or a log.
  26. - Commits: small, plain subjects, no self-attribution, on your branch only. Do not push, do not deploy, do not write to tickets.
  27. - Gates (LC_ALL=C), 0 failed at the end: node theme/check-theme.mjs ., node tests/browser.mjs, and every gate in deploy.sh's GATES list. Add your own gate file tests/<name>.mjs for this ticket and add it to GATES. A flake: rerun once, report it.
  28. - Budget: ~60 requests / 150k context. If the work is bigger, finish a clean part, commit, and report what remains. STOP after the report.
  29. ## Report (REPORT.md, short)
  30. What was built (files, commits), how you tested (commands + results), contract points covered and not, DOCS/GAP lines, open risks.

Branches

Latest commits

  • fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemre
  • f7198131gitoria#45: tests/pr-page.mjs gatemre
  • 483141d0gitoria#45: Settings shows the Apps heading only to the ownermre
  • e2eff8f6gitoria#45: the PR page /pulls/N with reviews, threads, verdicts, conversation, comment, reply, resolve and Review againmre
  • 7a602839gitoria#45: raiseEvent can send to one app only; people's comments, replies and resolving in reviews.hlmre
  • 0a46bf7dgitoria#47: apps API contract v1.3 (status read route, statuses + required on the pull)mre
  • 3373f7c3gitoria#38: push API contract v1.2.1, reviews, worker briefs and logmre
  • 34143d2cgitoria#46: closing brace of appComments lost in the mergemre
  • 54927c9cgitoria#46: PR statuses and required checks before merge (merge w46-status)mre
  • 187e1871gitoria#46: badges without decorative bordersmre
  • 6b022798gitoria#46: tests/status.mjs in GATESmre
  • c6162f00gitoria#46: status badges on /pulls, Required before merge in Settingsmre
  • e5a0b64egitoria#46: PUT statuses/<sha>, required contexts block the merge on the servermre
  • 26a140e3gitoria#44: reviews, inline threads, replies, conversation for apps (merge w44-reviews)mre
  • 888dbf87gitoria#44: unknown API paths answer the contract's JSON 404 and sit above the page routesmre
  • ea587d90gitoria#44: reviews with inline threads, replies, resolve and the PR conversation for apps (lib/reviews.hl, tests/reviews.mjs)mre
  • 49533a50gitoria#43: signed events to connected apps (merge w43-events)mre
  • 1a1e87d5gitoria#43: the sender never writes the apps row; Settings shows the newest deliverymre
  • cd442066gitoria#43: app-auth unit test reads the apps table from its new filemre
  • 5dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre