Skip to content
Documentation
1.0.0-beta.10 · latest

Static events

Source e69e4b6f1381 · Published v1.0.0-beta.10

This mixed Node project keeps HTTP and event entries in separate planes. Two schema-bound Pulse.on registrations accept canonical event frames and use the one-way ctx.emit effect. The harness proves exact outbound acceptance; it does not claim delivery or invoke a matching local handler.

import { Pulse } from '@pulse-compute/pulse'
type DeviceReading = Readonly<{
deviceId: string
temperatureC: number
}>
const app = new Pulse({ auto: true })
app.get('/health', async (ctx) => ctx.text('ok'))
app.on<DeviceReading>('device.reading', { schema: 'events.DeviceReading' }, async (ctx) => {
const reading = ctx.event.payload
ctx.log.info('device reading accepted')
await ctx.emit('device.reading.accepted', {
schema: 'events.DeviceReadingAccepted',
payload: { deviceId: reading.deviceId, accepted: true },
})
})
app.on('system.tick', { schema: null }, async (ctx) => {
ctx.log.info('system tick accepted')
await ctx.emit('system.heartbeat', { schema: null })
})
export default app
import { defineConfig } from '@pulse-compute/pulse'
export default defineConfig((_scope) => ({
pulse: {
entry: 'src/index.ts',
schema: 'src/schemas.ts',
tests: 'tests/pulse.harness.ts',
defaultProfile: 'node-native',
strict: true,
},
'node-native': {
host: 'node',
target: 'native',
outDir: 'dist-node-native',
dev: { host: '127.0.0.1', port: 8787, networkFetch: false },
},
'node-javascript': {
host: 'node',
target: 'javascript',
outDir: 'dist-node-javascript',
dev: { host: '127.0.0.1', port: 8787, networkFetch: false },
},
}))
import { defineSchemaRegistry, schema } from '@pulse-compute/pulse/schema'
export interface DeviceReading {
deviceId: string
temperatureC: number
}
export interface DeviceReadingAccepted {
deviceId: string
accepted: boolean
}
export default defineSchemaRegistry({
schemas: {
'events.DeviceReading': schema<DeviceReading>(),
'events.DeviceReadingAccepted': schema<DeviceReadingAccepted>(),
},
})

Generated from the executable test harness below; these are tested requests or event frames, not an exhaustive application specification. Expected errors and emitted events are included; fixtures and provider setup remain in the harness.

RequestExpected response
http health remains separate
GET /health
{"status":200,"text":"ok"}
schema event emits an accepted frame
Event: {"version":"pulse.event-frame.v1","type":"device.reading","schemaId":"events.DeviceReading","payload":{"deviceId":"sensor-7","temperatureC":21}}
{"status":"completed","emitted":[{"version":"pulse.event-frame.v1","type":"device.reading.accepted","schemaId":"events.DeviceReadingAccepted","payload":{"accepted":true,"deviceId":"sensor-7"}}]}
no-payload event emits a no-payload frame
Event: {"version":"pulse.event-frame.v1","type":"system.tick","schemaId":null}
{"status":"completed","emitted":[{"version":"pulse.event-frame.v1","type":"system.heartbeat","schemaId":null}]}

The selected profile is node-native; this checked excerpt identifies its target, provider and recognized capabilities. Paths, hashes and additional inspection fields are omitted.

Terminal window
npm run inspect -- --json
{
"status": "ok",
"project": {
"target": "native"
},
"provider": {
"id": "node"
},
"compiler": {
"capabilities": [
"event.emit",
"logging",
"response.text"
]
}
}

Check this project and its local toolchain before execution. This selected result is verified by the documentation gate; another machine may report different prerequisite checks.

Terminal window
npm run doctor -- --json
{
"status": "passed",
"summary": {
"warnings": 0,
"failed": 0
}
}

Build once into a separate directory, then replay the retained artifact without running or rebuilding the application. This checked excerpt accounts for registered handlers in the build evidence; it is not runtime request coverage.

Terminal window
npm run build -- --out .pulse-docs-build
npm exec -- pulse report --artifact .pulse-docs-build/pulse-build.json --json
{
"kind": "pulse.application-report",
"reportVersion": 1,
"analytics": {
"coverage": {
"handlers": {
"expected": 3,
"observed": 3,
"reason": null,
"status": "complete"
}
}
}
}

Optional offline HTML uses the same retained evidence:

Terminal window
npm exec -- pulse report --artifact .pulse-docs-build/pulse-build.json --html

Review reports before sharing. Missing, stale or incompatible evidence is an error; timings, paths and hashes are not presented as stable output.

Interactive report captured from this example at source e69e4b6f1381. Build evidence describes this captured build, not a runtime guarantee.

Open full report · Capture provenance

Terminal window
pulse doctor
pulse inspect
pulse test
pulse dev
pulse build

pulse test executes both HTTP and event cases on the selected Node target. pulse dev serves only the HTTP portion; Pulse does not expose a public event listener or injection command.

The documented result below is executed by the documentation gate.

Terminal window
pulse test --json
{
"status": "passed",
"provider": "node",
"summary": {
"total": 3,
"passed": 3,
"failed": 0
},
"cases": [
{
"name": "http health remains separate",
"status": "passed",
"response": {
"status": 200
}
},
{
"name": "schema event emits an accepted frame",
"status": "passed",
"kind": "event",
"emittedFrameCount": 1
}
]
}
export default { cases: [
{
name: 'http health remains separate',
request: { method: 'GET', path: '/health' },
expect: { status: 200, text: 'ok' },
},
{
name: 'schema event emits an accepted frame',
kind: 'event',
event: {
type: 'device.reading',
schema: 'events.DeviceReading',
payload: { deviceId: 'sensor-7', temperatureC: 21 },
},
expect: {
status: 'completed',
emitted: [{
type: 'device.reading.accepted',
schema: 'events.DeviceReadingAccepted',
payload: { deviceId: 'sensor-7', accepted: true },
}],
},
},
{
name: 'no-payload event emits a no-payload frame',
kind: 'event',
event: { type: 'system.tick', schema: null },
expect: {
status: 'completed',
emitted: [{ type: 'system.heartbeat', schema: null }],
},
},
] }

See Static events and outbound emission for the frame, queue, target, diagnostic, and Native-extension contracts.

For build settings, see Native build optimization.

ArtifactDefault build
Portable guest canonical-native.wasm31.7 KiB (32,458 bytes)

The executable documentation gate rebuilds and measures the default artifact. Measured with Node 24.18.0 and lockfile-pinned AssemblyScript 0.28.18. These are uncompressed on-disk sizes, not transfer sizes or platform limits.