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