tickets
All repositories: gitoria
8.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.
Branches
Latest commits
- 54bc5fe1Harden delta relevance, overflow caps and retry verificationmre
- 8d8e2053Document subscription contract and exercise delta deliverymre
- fd23726aAdd subscription delta API and signed wake bridgemre
- c5d28fb5Tickets conductor: S51 startedmre
- fd6ca1e6Tickets conductor: brief 027 waker design, push-test projectmre
- e448e656Tickets conductor: STATUS #51mre
- 1c10857bTickets conductor: P51 eval, brief 027mre
- e725969dTickets conductor: #51 directionmre
- 1b5c63ddTickets conductor: P51 startedmre
- 9f13fbdaTickets conductor: brief 026 prioritymre
- acc477d9Tickets conductor: brief 026 + Vinzenz recommendationsmre
- 9233a734Tickets conductor: brief 026 completemre
- 5da589fdTickets conductor: brief 026 + Gitoria's answermre
- a3cd5329Tickets conductor: tickets#51 opened, brief 026 draftmre
- 6f6e5797Tickets conductor: STATUS wordingmre
- 957de51fTickets conductor: T36 live, #36 review, #50 donemre
- bc2fde32Merge branch 'main' into t36-stylemre
- b7ca093atests: wait for the new row and normalize editor marker spacesmre
- 41da3525Tickets conductor: flake cause, T36 deploy stepmre
- 64c477e6Tickets conductor: deploy waits for Arachnemre