Skip to content

Primitive event bus, local PostOffice delivery, and the engines' actuator endpoints - #87

Merged
acn-ericlaw merged 8 commits into
mainfrom
feature/primitive-event-bus
Aug 23, 2026
Merged

acn-ericlaw merged 8 commits into
mainfrom
feature/primitive-event-bus

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Contributor

What

Three features that complete the wrapper as a deployable polyglot function host —
lock-step twin of the mercury-python PR:

  1. Primitive in-process event bus (bus.ts) — the single dispatch pipeline: a
    per-route FIFO mailbox consumed by instances worker loops (the preload parameter
    becomes faithful). Two operations only: deliver (RPC, ttl-bounded → the standard
    408 envelope, with a dead-work skip) and publish (drop-n-forget, 202-shape ack).
    The HTTP host and the local side of PostOffice are thin ingress adapters over it.
  2. Local PostOffice delivery — PostOffice without an endpoint delivers through the
    application's own bus (engine semantics): isPrivate functions are callable in-app
    while the wire keeps its 403; headers pass verbatim; trace context chains through
    local calls; the reply envelope shape is identical to the remote path.
  3. Actuator endpoints (actuator.ts) — GET /info, /info/routes, /env,
    /health, /livenessprobe on the Event API port, mirroring the Java
    ActuatorServices shapes as ported to Rust. Health check functions are normal
    registered functions speaking the engines' type=info / type=health interface
    contract, listed in mandatory.health.dependencies / optional.health.dependencies
    and called through the event bus; /health answers UP (200) / DOWN (400) and feeds
    /livenessprobe.

Supporting: log.format now carries the engines' three presentations — text (default),
json (pretty-printed) and compact (single-line JSONL); a sample
examples/resources/application.yml demonstrates the resources convention (the demo now
runs with plain node dist/src/cli.js examples/demo-app.mjs); version single-sourced in
version.ts.

Why

  • The instances and isPrivate parameters must be faithful, not decorative — with
    the bus, worker assignment is real and private functions are reachable in-app through
    PostOffice, exactly like an engine po call.
  • Deliberately minimalist (ratified design): no spill tier and no queue cap —
    back-pressure belongs to the tier that owns recovery, the engines' flows and graphs; a
    leaf host fails fast by deadline. Node-specific lifecycle ruling: an in-flight RPC's
    deadline timer is deliberately referenced — pending work holds the process open, at
    most until its deadline — while an idle bus holds no handles.
  • Wrapper apps deploy as Kubernetes PODs, so they need the engines' operational
    surface — one probe wiring and one dashboard shape across Java, Rust, Python and
    Node.js apps, with the same health-function contract developers know from the engines.

Verification

  • 48/48 (tsc + node --test): 8 bus pins (FIFO order, instances=2 concurrency, local
    408 + dead-work skip, private reachability, trace chain), 10 actuator pins (all five
    shapes, liveness-follows-health round trip, optional-failure-never-downs, engine
    elapsed-time/origin format vectors).
  • Live wire proof: hosted hello.chain calls the private demo.suffix.helper through
    the bus; direct wire call to the private route → 403.
  • Live actuator drive via the sample yml: all five endpoints engine-shaped; /health UP
    with the full demo.health dependency entry; -Dlog.format=compact emits JSONL.

Co-Authored-By: Claude Code noreply@anthropic.com

🤖 Generated with Claude Code

acn-ericlaw and others added 8 commits August 22, 2026 19:46
Lock-step with mercury-python (ratified design, Eric 2026-08-23): every
invocation reaches a function the same way - a per-route FIFO mailbox
consumed by 'instances' worker loops (the parameter becomes faithful; the
semaphore is gone). The HTTP host and the local side of PostOffice are thin
ingress adapters over the bus.

- bus.ts (internal): deliver (RPC, ttl-bounded -> 408; dead-work skip for
  queued calls whose caller already timed out) and publish (drop-n-forget,
  202-shape ack). Worker owns the invocation pipeline: per-delivery trace
  context, AppException -> portable error envelope, execTime, error logging
  for un-replied publishes. An in-flight RPC's deadline timer is deliberately
  referenced (pending work holds the process open, at most until its
  deadline); an idle bus holds no handles.
- PostOffice without an endpoint = local ingress with the engines' semantics:
  private routes callable in-app (the wire keeps its 403), headers verbatim,
  reply envelope identical to the remote path; unregistered route -> 404
  envelope. With an endpoint: unchanged wire client.
- No spill tier, no queue cap (ratified): back-pressure belongs to the tier
  that owns recovery - the engines' flows and graphs.
- Demo gains the local-composition pair (public hello.chain -> private
  demo.suffix.helper); README documents local calls, faithful private and
  the workflow boundary; scope statement amended.

Pins: test/bus.test.ts - the same eight as the python twin (local RPC
public+private, unregistered 404, FIFO order, instances=2 concurrency peak,
local 408 + dead-work skip proven, trace chained caller -> entry -> private
helper, local send ack). The existing host suite now exercises the bus path.

Gates: tests 39/39 (tsc + node:test).

Co-Authored-By: Claude Code <noreply@anthropic.com>
Preemptive mirror of the python fixes: the 'absent = drop-n-forget' comment
reworded (it parsed as commented-out code), and execute is static (uses
nothing from the instance).

Gates: tests 39/39.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Twin of the python fix: the entry handler's local 'po' shadowed the test's
outer 'po' - renamed innerPo.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…netes

GET /info, /info/routes, /env, /health, /livenessprobe on the Event API
host, mirroring the Java ActuatorServices shapes as ported to Rust.
Health-check functions are normal registered functions speaking the
engines' type=info / type=health contract, listed in
mandatory/optional.health.dependencies and called through the event bus;
/livenessprobe follows the most recent /health outcome (400 when down,
engine parity). VERSION moved to version.ts (single TS-side source).

Co-Authored-By: Claude Code <noreply@anthropic.com>
…st assert

Co-Authored-By: Claude Code <noreply@anthropic.com>
…or the demo

log.format now carries the engines' three presentations: text (default),
json (pretty-printed, matching the engine's pretty serializer) and
compact (single-line JSONL for log aggregators). The demo app gains
examples/resources/application.yml - the engines' resources convention,
auto-loaded next to the app file - wiring the demo.health dependency and
demonstrating the well-known keys. README quick start teaches the -D
override syntax instead of --port.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@acn-ericlaw
acn-ericlaw merged commit fa7b2bf into main Aug 23, 2026
2 checks passed
@acn-ericlaw
acn-ericlaw deleted the feature/primitive-event-bus branch August 23, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant