gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain5d144817Merge branch 'records-t40' into mainTicketsmain/missions/027-push-subscriptions-build.md

10.2 KB

  1. # 027 — Build: ticket delta + push subscriptions (tickets#51)
  2. TASK (his words, unchanged): "we will also change the information you get to a delta like we have in conductor-hub as
  3. vinzenz the conductors should get their ticket updates directly as a push from tickets via a similar subscriber as gitoria
  4. builds it now. you don't need to know every detail of all projects its enough if you keep the overview." ('you' = Apollo)
  5. and "do the tickets delta and push subscription first to get it away from you" and "implement it as you see fit i will ask
  6. details tomorrow". Ticket: https://tickets.worldapi.org/tickets.worldapi.org/51 (do not write to it).
  7. ## Read first
  8. - /media/STORAGE/projects/WorldAPI/worldapi-conductor/archive/2026-10-31/WORKER-RULES.md (all).
  9. - /media/STORAGE/projects/hybriel/docs/HL-PRIMER.md, /media/STORAGE/projects/hybriel/docs/CODE-ORDER.md; the plugin READMEs
  10. you use (plugins/fetch, plugins/time, plugins/crypto). Copy a working shape from the docs and from lib/stream.hl /
  11. lib/connections.hl; DOCS line in the report.
  12. - The evaluation: /media/STORAGE/claude-scratch/tickets/P51/REPORT.md (facts about /api/events, stream rows, HC /api/wake,
  13. Apollo's subscriber). Its option C with a separate public receiver is NOT what is built (see design).
  14. - README "API", "Event stream for programs (ticket #26)", "Test"; lib/stream.hl, lib/tickets.hl, lib/api.hl, project.hl.
  15. - HyperConductor API: /media/STORAGE/projects/hyper-conductor/README.md "API" (POST /api/wake {project,text},
  16. POST /api/chats/<id>/messages {text}).
  17. ## Design (NOT HIS: Apollo's direction 2026-11-01 + Tickets' simplification; Apollo decides changes)
  18. 1. Subscription (new table): id, owner (tickets user id), projects (list of project ids, or all), label, cursor (= last delivered stream row id), wakePending flag, created.
  19. Created by POST /api/subscriptions with a tickets token: for yourself (owner = token user), or for another user if
  20. you are admin of EVERY listed project. "all projects" only for yourself. GET /api/subscriptions (own + those you
  21. administer), POST /api/subscriptions/:id/remove. Baseline:
  22. cursor = current stream high-water at creation (no history flood).
  23. 2. The delta is COMPUTED from the existing numbered stream rows (lib/stream.hl) after the cursor; no second journal:
  24. - only the subscription's projects; never events whose actor is the owner (stable user id, not display name);
  25. - merged per ticket: first → last state, created, title/summary edited, assignee old → new, N comments (+ the last
  26. comment's first 200 chars), links; one line per ticket;
  27. - relevance marks per line: assigned (to owner, now or before), own (owner created it), mention (owner's name/handle
  28. in a comment/summary text of this delta — document the exact rule);
  29. - JSON {subscription, from, upTo, tickets:[{project, number, ref, subject, href, changes:{…}, relevance:[…], actors,
  30. lastAt}], more} and a text rendering (Accept: text/markdown) capped at 4 KB: relevant tickets first, at the cap one
  31. summary line "… and N more tickets in P1 (a), P2 (b)" (Vinzenz: summarise, never a second digest).
  32. - GET /api/subscriptions/:id/delta (owner's token only) returns it AND marks it delivered (cursor = upTo,
  33. wakePending = false), as Apollo ruled. `?peek=1` returns without marking.
  34. 3. Wake (Apollo's decision 2026-11-01, replaces the earlier draft): tickets holds NO HyperConductor tokens (it faces the
  35. internet; those tokens control whole instances). After each stream write (never blocking the write: async
  36. fetchStart), every matching subscription whose wakePending is false and that has a non-own matching event gets
  37. wakePending = true and ONE content-free wake: POST to ONE configured waker URL (TICKETS_WAKER_URL, e.g.
  38. http://127.0.0.1:<port> on byrodin; container network_mode host) with body {subscription: <id>, at, delivery: <uuid>}
  39. and header X-WorldAPI-Signature-256: sha256=<hex HMAC-SHA256(TICKETS_WAKER_SECRET, raw body)> (prove the HMAC with a
  40. known-answer test; P51 notes crypto's hkdfExtract = HMAC-SHA256). No further wakes until the subscriber fetches.
  41. Failed wake (non-2xx/timeout 10 s): retry after 1, 5, 30, 120 min, then mark failed (visible in GET
  42. /api/subscriptions); on server start re-wake every subscription with pending undelivered changes. The standby swap
  43. must not double-send (document how). Unset TICKETS_WAKER_URL = no wakes (deltas still work).
  44. 4. The waker: a small separate service in the tickets repo, tools/waker/ (language: Hybriel if the docs give a working
  45. shape for an HTTP server + outgoing fetch + HMAC; else a short Python 3 stdlib script like Apollo's
  46. byrodin:/CONTAINERS/APOLLO/tools/ticket-push/subscriber.py, which it replaces — say which and why), with its own test.
  47. It listens on 127.0.0.1 only, checks the signature (constant-time) and de-duplicates on delivery, maps the
  48. subscription id → {instance, wakeProject} or {instance, chat} from its own config file, and calls that instance's
  49. POST /api/wake {project, text} or POST /api/chats/<chat>/messages {text} with the token it holds. The text is
  50. self-explanatory: "tickets: new changes for you. Read them: curl -s -A <you> -H 'Authorization: Bearer <your tickets
  51. token>' -H 'Accept: text/markdown' https://tickets.worldapi.org/api/subscriptions/<id>/delta". Answers 2xx only after
  52. the HC call succeeded (so tickets retries otherwise). Config: env file with TICKETS_WAKER_SECRET, instance URLs and
  53. token FILE paths (tokens root-only on byrodin; Apollo installs it as a systemd service and puts in the tokens himself —
  54. write INSTALL steps in tools/waker/README.md). Never log tokens or the secret.
  55. The subscription's wake target is stored by the waker's config, not by tickets: tickets only knows subscription ids.
  56. 5. Unchanged: /api/events (fields, cursor, filters), the Markdown views, cookies, the connect flow. Additive only.
  57. No gitoria-style signed POST to outside apps in this build (later, shared with gitoria).
  58. ## Tests (gates)
  59. - New tests/subscriptions.mjs against a local fake waker (records wakes, checks the signature): create/list/remove + rights (other user 403,
  60. non-admin for another user 403, baseline (no old events); own events never wake or show; one
  61. wake per pending episode, none until fetch, wake again after fetch + new event; merge per ticket (open → review → done
  62. = one line); relevance marks; wrong/missing signature refused by the real waker (its own test, with a fake HC); 4 KB cap + summary line; peek does not mark; fake waker down → retries → failed, restart
  63. re-wakes; JSON + Markdown shapes. Each new check must fail on old code where meaningful (no route = fail).
  64. - Existing gates 0 failed: node tests/browser.mjs, tests/events.mjs (legacy stream unchanged), tests/security.mjs,
  65. tests/connect.mjs, node theme/check-theme.mjs . (2 day35 flakes were fixed in b7ca093).
  66. - README: new section "Subscriptions (ticket #51)" for conductors (how to subscribe, read, what a wake looks like).
  67. ## Path to live and live proof
  68. - STOP after gates and REPORT; the conductor reviews the diff. Then on his word: deploy with
  69. /media/STORAGE/projects/WorldAPI/worldapi-conductor/deploy-init.sh tickets (backup on /media/STORAGE; rc=0, 0 FAILED,
  70. curl loop 0 × 5xx, push after rc=0, main = origin/main), the conductor puts TICKETS_WAKER_URL/SECRET into the live .env; Apollo installs the waker.
  71. - Live proof (test data only in project push-test: Tickets admin, Jukebox edit member; made 2026-11-01): a subscription
  72. owned by Jukebox on push-test (created by Tickets as its admin), waker mapping → loreana, wakeProject jukebox; a ticket event there by another user →
  73. the parked chat wakes with the wake text (session_read shows it) → its delta fetch returns that ticket, marks
  74. delivered, a second fetch is empty. Then remove the subscription.
  75. ## Environment
  76. - Worktree + all files under /media/STORAGE/claude-scratch/tickets/S51/ (REPORT.md there). Branch s51-subscriptions from main.
  77. - Ports 8740–8759 (check ss first). Stop and list every process you started. No attribution lines in commits.
  78. - Model Sol (codex|gpt-6.1-sol), Sol at most 3 % of the Codex week (hard cap set by the conductor). Cap ~70 requests.
  79. ## Report
  80. Commits, design deviations (with reasons), gate numbers old vs new, test list, DOCS line, processes, open points.
  81. ## CHANGE 2026-11-01 (Apollo's decision; his idea, verbatim: "maybe we should create a basic push protocol that can directly
  82. ## be attached to a hycon session? so no external services are needed? you can decide yourself.") — REPLACES design 3 + 4
  83. - NO waker service: drop tools/waker (keep any work on it out of the branch/deploy). Each subscription pushes straight to a
  84. HyperConductor chat.
  85. - Push protocol (HyperConductor side, Hermes builds it): POST <instance>/api/push/<chatId>, JSON body {source, delivery, text}
  86. (text ≤ 500 chars); headers X-Push-Delivery: <uuid> (same on a retry) and X-Push-Signature-256: sha256=<hex
  87. HMAC-SHA256(secret, raw body)>. Answers: 202 accepted; 401 bad signature / no secret; 404 unknown chat; 409 duplicate
  88. delivery id (treat as delivered); 429 more than 1 push per 10 s per chat (retry later). The secret is per chat, made in
  89. HyperConductor, shown once.
  90. - tickets: a subscription stores {pushUrl, secret} (set at creation, by the owner/admin as before). The secret is never
  91. shown again, never logged, never in any GET/Markdown answer (encrypted at rest if the crypto plugin gives a working shape;
  92. otherwise say so). source = "tickets", text = the fetch command (≤ 500 chars). Retries, wakePending, restart re-wake,
  93. no double send in the standby swap: as planned. Unset pushUrl = no push (deltas still work).
  94. - NOT HIS (Tickets, security): tickets faces the internet and would POST to a user-given URL. pushUrl must start with one
  95. of the base URLs in TICKETS_PUSH_ALLOWED (env, comma list, e.g. http://100.77.141.84:8100,http://127.0.0.1:45010) and
  96. have the path /api/push/<chatId> (chatId [0-9-]+); otherwise 400. No redirects followed, timeout 10 s.
  97. - tests/subscriptions.mjs: the fake HC implements exactly this endpoint (checks signature, 409 on a repeated delivery,
  98. 429 rate) and records pushes. Add: not-allowed pushUrl 400; secret never appears in any answer.
  99. - Live proof waits for Hermes' endpoint; deploy tickets anyway when the gates are green (after my review).

Branches

Latest commits

  • 5d144817Merge branch 'records-t40' into mainTickets
  • 44ee6f06|||PR records: #43 #45 livemre
  • b8fdeee9Merge branch 'p39-routes' into mainTickets
  • a0187a0a|||PR Remove redundant route-order loopmre
  • 369e4b9cMerge branch 'k40-lists' into mainTickets
  • 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
  • 610d8e8aMerge branch 'records-t39' into mainTickets
  • 32bcdf24|||PR records: GO P39 K40mre
  • 4123c6d1Merge branch 'records-t38' into mainTickets
  • cd3641a1|||PR records: day72 deploy live, tickets closedmre
  • 7d44d852Merge branch 'records-t37' into mainTickets
  • 926f7061|||PR records: merges, D36 deploymre
  • bf58534eMerge branch 'l33-final' into mainTickets
  • 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
  • 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
  • 5822cb3aMerge branch 'o34-clean' into mainTickets
  • 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
  • 14cf96b4Merge branch 'records-t36' into mainTickets
  • 07749fa1|||PR records: day72 + #40 mergedmre
  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre