openvibers/openvibe.examples Commits

Examples: the proofs read Events by cursor only (no seq) (#19)

OP OpenVibers committed 12 Oct 2026 · e3e0fb8785 · 3 files, +13 −12

Events retired per-event seq numbers on 10-11 (cursors only). The production proofs (`openvibe-devpath`, `openvibe-toolsjob`) had been failing daily since then because the copy on the host was still the 10-08 one; it now runs main and both pass (11/11 and 6/6).

This drops the last seq reads from the scripts:
- `developer-path.js` and `tools-job-proof.js` printed "seq undefined"; they now name the event ids.
- `e2e.js` set its pull cursor from `pub.seq - 1` (NaN now); it starts the subscriber at the head before publishing, the way the developer path does.

Tests: developer-path, tools-job-proof, structure.

Changes

ddiff --git a/scripts/developer-path.js b/scripts/developer-path.js
iindex e22e3aa..ca2db98 100644
---- a/scripts/developer-path.js
++++ b/scripts/developer-path.js
@@@ -212,7 +212,7 @@ async function runDeveloperPath({ network = PRODUCTION_NETWORK, services = PRODU
const cursorPath = path.join(dir, 'cursor.json');
const seen = [];
const s = createSubscriber(subscriberConfig({ ...creds(), OV_EVENTS_MODE: 'pull', OV_CURSOR_PATH: cursorPath }), {
-- fetch: fetchImpl, log: { log: () => {}, error: (m) => say(m) }, onEvent: (event, { seq }) => { seen.push({ seq, id: event.event_id }); },
++ fetch: fetchImpl, log: { log: () => {}, error: (m) => say(m) }, onEvent: (event) => { seen.push({ id: event.event_id }); },
});
// Start the subscriber at the head (an opaque cursor), then publish: the pull finds what came after it.
await s.startAtHead();
@@@ -224,7 +224,7 @@ async function runDeveloperPath({ network = PRODUCTION_NETWORK, services = PRODU
const n = await s.pullOnce();
const mine = seen.find((e) => e.id === pub.event_id);
if (!mine) throw new Error(`the published event ${pub.event_id} was not in the pull of ${topics[0]}`);
-- say(`pulled ${topics[0]} with events.app.read: ${n} event(s), found ${mine.id} at seq ${mine.seq}`);
++ say(`pulled ${topics[0]} with events.app.read: ${n} event(s), found ${mine.id}`);
});
await step('export', async () => {
ddiff --git a/scripts/e2e.js b/scripts/e2e.js
iindex 59fe083..086e2cc 100644
---- a/scripts/e2e.js
++++ b/scripts/e2e.js
@@@ -69,7 +69,7 @@ async function main() {
const { createUploader, explain } = require(path.join(ROOT, 'examples/media-uploader/upload'));
const { projectKey } = require('openvibe-sdk/events');
-- const { createSubscriber, createCursorStore, loadConfig: subscriberConfig } = require(path.join(ROOT, 'examples/event-subscriber/subscriber'));
++ const { createSubscriber, loadConfig: subscriberConfig } = require(path.join(ROOT, 'examples/event-subscriber/subscriber'));
const { publishAppEvent, loadConfig: publishConfig } = require(path.join(ROOT, 'examples/event-subscriber/publish'));
const { createJobRunner, loadConfig: jobConfig } = require(path.join(ROOT, 'examples/tool-job/run-job'));
const { loadConfig: mediaConfig } = require(path.join(ROOT, 'examples/media-uploader/upload'));
@@@ -108,21 +108,22 @@ async function main() {
});
await step('event-subscriber: publish to the own topic, then pull it', async () => {
-- const pub = await publishAppEvent(publishConfig(base), { name: 'e2e.ran', subject: { type: 'check', id: 'e2e' }, payload: { at: new Date().toISOString() } });
-- console.log(` published ${pub.event_type} ${pub.event_id} -> seq ${pub.seq}${pub.duplicate ? ' (duplicate)' : ''}`);
const cursorPath = path.join(dir, 'cursor.json');
-- createCursorStore(cursorPath).set('pull', Math.max(0, pub.seq - 1));
const seen = [];
const s = createSubscriber(subscriberConfig({ ...base, OV_EVENTS_MODE: 'pull', OV_CURSOR_PATH: cursorPath }), {
-- log, onEvent: (event, { seq }) => { seen.push({ seq, id: event.event_id, type: event.event_type }); },
++ log, onEvent: (event) => { seen.push({ id: event.event_id, type: event.event_type }); },
});
++ // Start at the head (an opaque cursor), then publish: the pull finds what came after it.
++ await s.startAtHead();
++ const pub = await publishAppEvent(publishConfig(base), { name: 'e2e.ran', subject: { type: 'check', id: 'e2e' }, payload: { at: new Date().toISOString() } });
++ console.log(` published ${pub.event_type} ${pub.event_id}${pub.duplicate ? ' (duplicate)' : ''}`);
const topics = await s.resolveTopics();
if (topics[0] !== `app.${projectKey(env.OV_PROJECT_ID)}.*`) throw new Error(`unexpected topic ${topics[0]}`);
const n = await s.pullOnce();
-- console.log(` pulled ${topics.join(', ')} from seq ${pub.seq - 1}: ${n} event(s), cursor now ${createCursorStore(cursorPath).get('pull')}`);
++ console.log(` pulled ${topics.join(', ')} from the head: ${n} event(s)`);
const mine = seen.find((e) => e.id === pub.event_id);
if (!mine) throw new Error(`the published event ${pub.event_id} was not in the pull`);
-- console.log(` found ${mine.id} at seq ${mine.seq}`);
++ console.log(` found ${mine.id}`);
});
await step('tool-job: img.process convert to WebP', async () => {
ddiff --git a/scripts/tools-job-proof.js b/scripts/tools-job-proof.js
iindex 5b6301c..98645d1 100644
---- a/scripts/tools-job-proof.js
++++ b/scripts/tools-job-proof.js
@@@ -166,8 +166,8 @@ async function runToolsJobProof({ network = PRODUCTION_NETWORK, toolsUrl, client
let moved;
do {
page = await st.events.pull({ topic: 'tools.job.*', after, limit: 200 });
-- for (const { seq, event } of page.events || []) {
-- if (event && event.subject && event.subject.id === st.jobId && EVENT_TYPES.includes(event.event_type)) found.set(event.event_type, seq);
++ for (const { event } of page.events || []) {
++ if (event && event.subject && event.subject.id === st.jobId && EVENT_TYPES.includes(event.event_type)) found.set(event.event_type, event.event_id);
}
moved = Boolean(page.next_cursor) && page.next_cursor !== after;
if (moved) after = page.next_cursor;
@@@ -176,7 +176,7 @@ async function runToolsJobProof({ network = PRODUCTION_NETWORK, toolsUrl, client
if (Date.now() >= deadline) throw new Error(`not in the Events store after ${eventsWaitMs / 1000} s: ${EVENT_TYPES.filter((t) => !found.has(t)).join(', ')}`);
await sleep(pollMs);
}
-- say(EVENT_TYPES.map((t) => `${t} seq ${found.get(t)}`).join(', '));
++ say(EVENT_TYPES.map((t) => `${t} ${found.get(t)}`).join(', '));
});
const ok = steps.every((s) => s.ok);