3.1 The FFI contract
Read this before adding an FFI entry point or changing a binding’s native mapping. It covers the C ABI conventions, the known hazards and the JNA bridge from Java to Rust.
Tempo’s Java binding uses JNA (Java Native Access) to call Rust-compiled native code.
JNA loads the native library at runtime and maps Java method signatures to C symbols,
so no JNI header files are required. The Python binding (ctypes,
python/tempo/_native.py) and the C++ binding (runtime dlopen /
LoadLibrary in cpp/src/Native.cpp) use the same C ABI. The wasm crate links
tempo-core directly and exports its browser API through wasm-bindgen, so it
shares the planner but not the native shared-library loading path.
Java-to-C mapping
JNA defines the Java-to-C mapping without a separately maintained JNI glue layer.
TempoNative holds the interface mapping and TempoNativeFast directly maps the
supported per-tick auto calls with Native.register. Both use the same
loaded library. Construction and other cold calls remain on the interface
mapping. The auto tick’s Java output buffers use owned JNA Memory arguments and
native-order NIO views. Pointer and array overloads are available, and both bind
the same C symbols and use the same buffer sizes, wire layouts and native
signatures.
Measure boundary changes through real public callers, including marshalling, allocation and event delivery, and compare complete calls. Desktop timings do not establish robot-loop latency bounds.
See the JNA project for the library reference.
Native library loading
JNA detects the host platform itself (Platform.RESOURCE_PREFIX) and searches the
classpath under that prefix for a bundled native:
- Windows x64:
win32-x86-64/tempo_core.dll - Linux x64:
linux-x86-64/libtempo_core.so - macOS x64/arm64:
darwin-universal/libtempo_core.dylib, one universal dylib thatNativeLoader.resourcePrefixmaps both of JNA’s macOS prefixes to - roboRIO (Linux ARM soft-float):
linux-armel/libtempo_core.so - SystemCore (Linux AArch64):
linux-aarch64/libtempo_core.so
The available prefixes depend on the artifacts built and packaged. A build packages the selected season’s robot native and requires it (wpilib-years.md).
NativeLoader in com.tempo.internal applies this order to both mappings:
- An explicit
jna.library.pathdirectory containing the platform’s library. - The matching JAR resource, staged privately ahead of ambient system libraries.
- The bare library name through the system loader.
NativeLoader.ensureLoaded() moves initialization earlier and reports failures
as TempoLoadException, including the platform and attempted paths. First access
through either mapping applies the same policy without a prior explicit call.
Authoring queries
tempo_authoring_query_v1(pack, bytes, length) accepts UTF-8 JSON for cold
configuration and route preparation. length is u32 and the optional pack is
borrowed for the call. Success returns an owned, NUL-terminated UTF-8 JSON
string, and the caller copies it and calls tempo_authoring_free_v1 exactly
once. A null result means malformed input or a caught panic, with the reason in
tempo_last_error. Freeing null is harmless.
The op field selects route, headings, spans, bounds, cross,
connector, drive, latency, speed, angular, angularCaps,
effectiveAngular, radius, or limits. Route checks return a problems array containing
code and message for each refusal. The language field selects java
(the default), python, or cpp message templates. Java and Python send bounds
coordinates as strings to retain their native numeric spelling, and connector
queries carry the display coordinates separately in startText.
tests/fixtures/api/authoringRefusals.json pins each code’s exception type in
each binding. Bindings throw the first problem in the returned order: route
structure, each leg’s drivetrain and crossings in leg order, then start and
fixed-target bounds (x before y). Freeze repeats bounds checks with the loaded
pack, including coordinates authored before configuration.
Heading queries resolve authored keyframes, Rotation Locks, and dynamic aim
carry. Connector queries inherit the route configuration and first-leg limits,
set both boundary velocities to zero, and construct one leg from the live pose
to the next route’s entry. Hooks and their identities remain host-owned.
Drive queries take geared WPILib motor constants and the physical 12 V speed,
and the returned torque and warning code share one calibration calculation. The
torque (netTorque) is the torque from rest, and torqueFade and
voltageTorqueSlope give the torque at speed that a route config’s
driveAcceleration sums.
The same boundary derives feedforward lead, speed presets, default angular
caps and limits-above-FULL warnings, and answers the ceilings a route’s
commands are bounded by (commandCeilings: velocity, acceleration, centripetal
acceleration, turn rate and angular acceleration from simple physics, null
without a drive model). Motor adapters supply WPILib constants
and wheel-group parameters, and scheduler and console operations stay in the
binding.
The wasm authoring_query export uses the same core implementation without a
pack handle. The editor initializes its main-thread wasm instance before
loading stores that derive drive limits or route headings.
Rotation Lock route field
The tempo.sequencing-route/v1 segment reads the optional boolean
noNarrowTurns, and the routed WASM target no_narrow_turns, as the input
that turns on the narrow-span hold scheduler for a whole leg. No binding and
no editor writes it, but the hold-scheduler fixtures
(tests/fixtures/planning/narrowTurns/, lookahead-replay.json) and the WASM
parity corpus do. A non-boolean switch is rejected.
The optional segment array rotationLocks holds Rotation Lock and Key
markers, {"at": fraction, "kind": "lock" | "key"}, in authored order, and the
routed WASM target’s matching field is rotation_locks. A fraction outside
[0, 1], a kind other than lock or key, or an object field other than at
and kind is rejected. Like noNarrowTurns, the markers are carried in the
route JSON without a C struct field or a separate function argument, and their warnings reach the console and the logging consumers
through the runtime’s existing channels.
Accepted narrow-turn exceptions stay on the core trajectory. The auto runtime
prints a warning naming the leg through its existing console channel, so Java,
Python and C++ need no additional ABI call. WASM’s PreviewPlan.take_warnings()
transfers the matching strings with the preview receipt, and the editor retains
them through worker decoding and plan-cache reuse.
Free-heading route field
The tempo.sequencing-route/v1 segment’s rotation object reads the
optional boolean freeHeading, and the routed WASM target the optional
boolean free_heading. When it is set the waypoint names no heading and the
core chooses one (architecture). A
non-boolean value is rejected and a missing field is false. Like
rotationLocks, it is carried in the route JSON without a C struct field. The standalone replanner’s C struct carries no
such field and plans a hold.
Known hazards
Bool hazard
JNA maps Java boolean to a 4-byte integer but Rust bool is 1 byte, so
those returns are declared as byte and converted with value != 0.
The declaration in TempoNative.java is:
byte tempo_replanner_is_complete(Pointer replannerPtr, double now_s);u32 length hazard
Length-related failures in tempo_load_pack can indicate a mismatched integer
width. The roboRIO is a 32-bit ARM processor, so usize is 4 bytes there but
8 on x64, and a TOML byte length passed as long (Java) / size_t (C)
can disagree across platforms. Buffer lengths use the ABI’s fixed-width u32
and Java int representation. Validate Java counts and checked element-to-byte
multiplication before allocation or FFI, because a matching field width alone
does not prove the caller owns the advertised output capacity.
TempoNative.java declares Pointer tempo_load_pack(byte[] toml, int tomlLen).
Struct alignment hazard
Corrupt CReplanSettings or CReplannerConfig fields can indicate a layout mismatch.
Rust’s #[repr(C)] uses the target’s C alignment rules. On supported targets,
a bool followed by an f64 carries 7 bytes of padding, and C++ code compiled with
#pragma pack(1) removes that padding and breaks the layout. Never use #pragma pack(1)
with Tempo’s C structs. The Java Structure classes in com.tempo.internal (CPose2d,
CChassisSpeeds, CReplannerConfig, and the rest of the C* twins) match the Rust layout
exactly, padding included, and on the C++ side the static_asserts in
cpp/include/tempo/detail/Native.h pin the same layouts at compile time.
catch_unwind at every entry point
Fallible tempo_* entry points catch Rust panics with
catch_unwind(AssertUnwindSafe(...)) because an uncaught panic at an
extern "C" boundary can abort the process. The handler returns the entry
point’s failure sentinel and sets the thread-local error string.
Read tempo_last_error() after a failure and copy its UTF-8 text before the
next FFI call on that thread. Panic handling does not validate dangling handles
or undersized buffers, so callers must satisfy each entry point’s safety contract.
Pack lifetime and Arc refcounting
tempo_load_pack returns an Arc<GamePack> leaked via Arc::into_raw, and this gives the Java GamePack object an owning reference.
tempo_replanner_new receives the pack pointer and calls Arc::increment_strong_count to take its own clone. The Java pack handle and the Replanner’s pack handle are independent, so freeing the Java GamePack (calling tempo_free_pack) does not affect any existing Replanner.
Java GamePack -> Arc<GamePack> (strong count = 1)
Replanner #1 -> Arc<GamePack> (strong count = 2)
Replanner #2 -> Arc<GamePack> (strong count = 3)
tempo_free_pack() -> strong count = 2 (Replanner still alive)
Replanner #1 free -> strong count = 1
Replanner #2 free -> strong count = 0 -> GamePack droppedCustom-control reference readers
The custom-control reference readers return a seven-double buffer:
[x, y, heading, vx, vy, omega, revision]. Coordinates and velocities are field-relative and
heading includes active overrides. Revision is a u32 counter represented exactly as f64
and changes on installed plans and clock rebases. Status 0 forbids custom output,
1 permits it, 2 clamps translation, 3 carries no reference and has the binding send the
command the tick returned (a stop of the core’s own within the leg’s limits, as for a
stranded robot), and -1 reports invalid inputs or a panic. A reference
is available only for the most recent accepted compute timestamp, and the auto reader
also requires the driving phase. Bindings must honor the status after filters run.
The tick’s status block and the helper threads
tempo_auto_tick_status ticks the runtime and returns its query results in one
call, and tempo_auto_status reads the same block after a notification. The block has
27 doubles (TEMPO_AUTO_STATUS_LEN): phase, segment, replan statistics, skipped
and missed counts, wedged state, clocks, reference pose, target, target heading,
plan keys, hold state, and the last tick’s XY and correctly rounded distance to
the current target. Older callers can still request a prefix. Hosts use the
distance only for that XY, and a status refresh after a notification recomputes
it against the current target. ffi.rs defines each slot.
Phase codes are 0 NOT_STARTED, 1 PRE_BLOCKING, 2 DRIVING, 3 POST_BLOCKING,
4 WAITING, 5 DONE, 6 CANCELLED and 7 HANDED_OFF. Fired kinds are 0 runDuring
(the route segment’s runDuring list, which recorded traces carry), 1 trigger,
2 fail case, 3 arriveWith and 4 WindowEnd, which ends the timed trigger at that
index interrupted. While a runtime reports HANDED_OFF the
binding runs the leg’s arriveWith command inside its route command and sends
the drivetrain nothing, and tempo_auto_notify_handoff_done reports the command’s
end, which the core counts as the leg arriving. A binding that sees the phase
leave HANDED_OFF without that call (give-up, endWhen, cancel) ends the command
interrupted.
tempo_auto_set_measured_motion_v1(auto, vx_mps, vy_mps, omega_rad_s) records the
robot’s measured robot-relative motion, returning 0, or -1 for a null handle. A
non-finite component is ignored. The route’s first command, and the first after an
arriveWith hand-off, steps from the recorded motion within the leg’s limits instead
of from rest. Bindings call it just before a tick when the drivetrain reports speeds.
tempo_measured_lag_forget_v1() forgets the drivetrain lags the routes of the process
measured and share, the drive’s and the steering’s. Every config read by
tempo_config_new_v1 whose route block says followerLatencyEstimated shares that one
pair, whichever handle it was read into. A binding calls it as it applies a config, so the
lags last from one applied config to the next. A config’s measured.steeringLagS reaches
the runtime as followerSteeringLatencyS where the drivetrain is a swerve and the route
block says followerLatencyCalibrated, which a binding writes where it took the latency
from the measured lag. A route block that says both that and followerLatencyEstimated, or
that names followerSteeringLatencyS itself, is refused.
tempo_auto_await_start_reset_v1(auto, before_x_m, before_y_m, before_heading_rad)
tells the runtime the host has just reset odometry to tempo_auto_runtime_start_pose,
having read before from the pose getter just before the reset (in the tick frame, NaN
when there was no pose). It returns 1 when applied, 0 once the runtime has ticked, or -1
for a null or poisoned handle. Until a tick’s pose stands within 0.15 m and 10 degrees of
the start, or has moved farther than that from before, each tick is taken as one
without a pose, so the robot rests and no leg starts while the auto clock and
matchTime moments run. After 0.5 s from the first tick with no such pose, the route
drives from the poses the host reports and logs a poseReset warning
(AutoRuntime::await_start_reset).
tempo_auto_record_output_v1(auto, now_s, vx_mps, vy_mps, omega_rad_s) replaces the
latest tick’s sent-command record with the host controller or filter’s final
robot-relative output. It applies no limits. The timestamp must match the
latest route command and all components must be finite, and an invalid call
returns -1 with an error. A valid call returns 0 and updates both the output limiter and
the follower’s command history. Suggestions for a host controller keep separate
slew history, and native commands and braking use the recorded output.
This operation does not advance the route.
tempo_brake_output_v1(now_s, heading_rad, motion, limits, history, out) brakes
while the next route’s runtime builds. The arrays contain 3 measured robot-relative
speeds, 5 limits (linear acceleration, angular acceleration, mecanum strafe
efficiency, mecanum turn radius, differential track width), 10 history values, and
3 output speeds. Zero wheel parameters disable that wheel model. Initialize
history to NaNs. Its two records store [time, field vx, field vy, omega, heading]
and the caller retains that history across waiting ticks. Repeated timestamps replace
the latest output without taking an extra acceleration step. A non-finite clock
or heading clears history and writes zero.
Bindings cache one block per runtime and invalidate it after a tick or notification
that changes state. Plan polylines need publishing only when their keys change.
tempo_auto_status rejects a null handle with -1 and an error string, and
tempo_auto_phase returns CANCELLED for a null handle.
tempo_auto_tick_status writes status only on a nonnegative return. A -2 return
requires another call with fresh host answers and -1 reports failure.
Both status entry points set the error slot whenever they return -1. A read moves no
sequencer state, so a panic inside tempo_auto_status leaves the handle usable. A panic
while tempo_auto_tick_status writes the block after its tick keeps the tick’s -1
contract. The speeds the tick wrote are zeroed, the error slot names the panic, and the
handle is poisoned, so every later tick returns -1 with zeroed speeds until the host frees
it. The bindings treat that return as a refused tick.
A binding’s helper threads run in two classes, as the core’s planning workers do.
tempo_run_beside_the_loop puts the calling thread under SCHED_BATCH at nice 0 on
Linux (nothing elsewhere), the class of the core’s urgent worker. Nice 0’s weight gives it
a fair share beside a loop at normal priority, and a batch thread never preempts a running
loop as it wakes. A binding calls it first on the helper that builds a route a loop is about
to start. tempo_run_below_the_loop puts it under SCHED_BATCH at nice 19, the
class of the core’s background workers, and a binding calls it first on the helpers
that build ahead of a run, close what a run left behind and print console lines. A thread inherits the scheduling of the
thread that starts it, which may be a loop raised to real-time priority, and neither call
ever raises a thread’s priority, which robot code lacks the privilege to do.
The wasm crate exports none of these because a browser page has no host loop to keep short and it reads the planner through its own exports.
Route flow
Five functions inside the ROUTE-FLOW additive block let a Setlist join carry
speed (see wrappers.md). All take a
tempo_auto_new handle, return -1 with the error slot set on a null handle or
buffer, a poisoned runtime or a panic, and work in the runtime frame.
tempo_auto_flow_into_v1(auto, request, length): UTF-8 JSON withfraction,next(the next route’s route JSON) andconnector(theconnectorauthoring query’sconstraints,freeHeading,differential,trackM), and optionallycompareHeadingandtolerance([translation_m, rotation_rad]), the join test’s inputs as the binding takes them. When they are absent the core reads them from the two routes. Only before the auto starts. Returns 1 when the route now ends moving, 0 at rest.tempo_auto_flow_in_v1(auto, vx_mps, vy_mps, omega_rad_s): the field-frame motion the route before left. Only before the auto starts. Returns 1 when the route flows in.tempo_auto_expect_entry_v1(auto, state[6]): x, y, heading, vx, vy, omega of the planned handover. It plans the first leg ahead, and again only when the handover has moved. Returns 0 when not asked (started, junctions still negotiating, or a non-finite value).tempo_auto_planned_exit_v1(auto, out[8]): the flowing route’s planned handover in the same layout, then the last leg’s moving handover distance (m) and 1 where the route flows into the next route itself or 0 where into a drive to its start. Returns 0 with nothing written while there is no such plan.tempo_auto_flowed_out_v1(auto, out[5]): the last command’s vx, vy, omega, the last leg’s moving handover distance (m), and 1 where the route flowed into the next route itself or 0 where into a drive to its start, once the route ended moving. Returns 0 otherwise.
Route configuration
The ROUTE-CONFIG additive block lets a binding hand the core a robot
configuration and an authored route once each, and build every runtime, Setlist
connecting drive and flow from the two handles with no JSON on the way. A binding
writes the configuration blob once per config value and the authored route once per
frozen definition or Setlist occurrence.
tempo_config_new_v1(json, len)readstempo.route-config/v1(drive_model::ResolvedConfig: the route settings block, the robot’s eight limits, its stated angular caps, the drivetrain, the drive model, wheel offsets, outline, frame and bumpers, track width, terrain caps and the optional measured limits). A speed level the drive model cannot give does not refuse the blob but refuses where it is read.tempo_config_free_v1releases it.tempo_config_speed_v1(config, level, out[8])andtempo_config_angular_v1(config, out[2])write a speed level’s limits and the angular caps routes run under, and return 0, or 1 with theargumentrefusal’s text in the error slot.tempo_config_same_route_v1(a, b)is 1 when every route resolves the same under both.tempo_route_new_v1(json, len)readstempo.authored-route/v1(auto_runtime::RouteTemplate), which is a sequencing route without itsconfigblock, withpreplanAheadandlanguageat the top, a leg’sconstraintseither limits or{"level": n}, a differential leg’s track width and a crossing’s cap left to the configuration.tempo_route_free_v1releases it.tempo_auto_new_v2(pack, config, route, alliance, planning_mode, plan_wait_s, problem_code)builds the runtimetempo_auto_newbuilds from the route the pair resolves to.tempo_route_json_v1(route, config, buf, capacity)writes that sequencing route and returns its length, for fingerprints, adoption checks and tests.tempo_route_connector_v1(next, config, pack, start[3], radius_m, free_heading, leg[12], problem_code)makes a Setlist’s drive from the robot’s pose to routenext’s start as a route handle. It is theconnectorauthoring query’s one leg at the configuration’s Speed.FULL, innext’s origin alliance, zones and look-ahead, with no start bias. With a pack, a start more thanradius_moff the field refuses first with code 7, and Java and Python then ask theconnectorquery for the message in their own numeric spelling.legreceives the leg’s target, eight limits, start heading and arrival heading (NaN where it arrives on none).tempo_auto_flow_into_v2(auto, next, config, fraction, free_heading, compare_heading, translation_m, rotation_rad, problem_code)istempo_auto_flow_into_v1with the next route as a handle pair.nextresolves underconfigand the configuration’s Speed.FULL is read before anything else, as a binding writing the request reads them. NaN tolerances read the routes’ own.
problem_code is 0 for a refusal the core makes, else the authoring refusal’s place in
tests/fixtures/api/authoringRefusals.json types from 1 (missing_start,
empty_route, missing_track_width, state, argument, pack), which picks the
binding’s exception type, and 7 is a connecting drive’s start off the field. Both handles
follow the pack’s ownership: Arc::into_raw, immutable, Send + Sync, freed on any
thread, and every runtime or route made from them keeps its own count.
Calibration
The CALIBRATION additive block runs calibration::Calibration from a binding.
tempo_calibration_new_v1(json, len) reads tempo.calibration-settings/v1 and
tempo_calibration_free_v1 releases it. tempo_calibration_tick_v1(calibration, t_s, pose[3], measured[3] or null, wheels or null, wheel_count, out[3]) writes the
robot-relative command and returns 0 running, 1 finished, 2 stopped. A NaN in
measured reports no speed for that loop. tempo_calibration_stop_v1 stops a run
with a reason (disable, interruption). tempo_calibration_text_v1(calibration, what, language, buf, capacity) writes the result JSON (what 0), the report
with its config line in Java, Python or C++ (what 1, language 0 to 2), or
the running routine’s name (what 2). tempo_calibration_merged_v1 writes the
result with an earlier saved result’s readings kept where this run took none,
which is what the bindings save. tempo_calibration_saved_v1(calibration, saved, why, len) records whether the binding wrote that result to the saved file, with
the reason where it could not. The report says “Saved to” only after a write
that succeeded and names the failure otherwise. tempo_config_measured_warning_v1(config, buf, capacity) writes the configuration’s measured-limit warning, or nothing. Text
calls return the full length and write only when it fits.
Logging items
A route’s runtime reports what the bindings’ TempoLogging consumers asked for and
nothing else. tempo_auto_set_log_mask takes one bit per item, in the order of
tests/fixtures/api/logging.json, and the mask starts clear. The core acts on the bits of
the items it computes (planned pose, target, error, planned speeds, replans, give-ups,
rotation events, arrivals, warnings, timing) and ignores the rest, which the bindings
produce themselves (pose, speeds, path, connects, commands, state, zones, pre-plan).
tempo_auto_log_v1 writes the per-tick frame at the time it is given, computed when
read and only for the bits set, then drains the event queue, oldest first. The queue
holds 64 events and reserves its storage when an event bit is first set, so a push never
allocates, and events past its capacity are dropped and counted in frame slot 20. A
warning too long for the caller’s whole text buffer is cut, at a character boundary, to
fit, so it never holds the queue. A warning’s text is the one allocation, made only when a
warning arises with its bit set, and the console line is printed either way. Events the
caller’s buffers have no room for stay queued, and frame slot 0 counts them. tempo_auto_log_zones_v1 is a query, read when the leg changes.
The function comments in ffi.rs define every slot and code.
ABI layout checks
ffi.rs groups exports with BEGIN/END TEMPO <NAME> ADDITIVE BOUNDARY
markers. Its native records must match the Java, Python and C++ declarations.
Coordinated layout checks are described in
pins-and-surfaces.md.
Starting the planning workers
The core’s planning workers are started once per process and take the
scheduling of the thread that starts them. A worker may lower its priority
but cannot raise it without a privilege robot code lacks, so an urgent
worker started from a thread at nice 19 stays at 19 and the plans a leg
waits for starve under load. tempo_pool_start_v1 starts the workers from
the calling thread and returns how many run, and later calls start nothing.
Each binding calls it on the robot program’s main thread as Tempo
initializes, before any helper thread is created or lowered. A pool not
started that way starts on the first plan or bake a thread asks for, from
that thread, and an urgent worker that starts above nice 0 prints one
[Tempo] line naming the cause. tempo_pool_urgent_nice_v1 returns the
highest nice value among the live urgent workers (i32::MIN while none
runs, or where no nice value is read), so each binding’s tests can check
where its initialization left the worker.
Test-only exports
These exports exist for test suites, are all #[doc(hidden)], and are never
called by packaged runtime code:
tempo_test_plan_gate_v1holds the planning jobs the calling thread submits to the worker pool, so a suite can receive a plan on a chosen tick: op 0 closes the thread’s gate, 1 counts held jobs whose results have not been delivered, 2 opens it and returns once every held result has been delivered to its ticket, 3 removes it. A gate is the calling thread’s own and never holds another thread’s jobs. Held jobs wait in the gate without occupying a worker. Removing the gate or ending its thread submits those jobs to the pool. An unknown op or a panic returnsu32::MAXand setstempo_last_error. The C++ binding declares it in itsdetailsymbol table for its test suite, and the Java and Python test suites call it directly (TestPlanGate,test_robot_planning.py). No binding’s public API reaches it, and nothing in the library closes a gate.tempo_test_sampled_follower_new_v1,_tick_v1and_free_v1run Tempo’s trajectory follower along a recorded reference with no planner, replanner or auto runtime around it, so a benchmark gives Tempo’s follower and others the same reference on the same clock. Construction readscountsix-double states and six gains. It returns null, and a tick returns 0 and writes nothing, with the reason intempo_last_error, on a null or misaligned pointer, a count of zero or one whose byte size overflows, an invalid recording or gain, or a panic. The follower benchmark intests/robot/java_sim(FollowerBench) declares them in its own JNA interface and fails on a refused recording or tick. No binding declares them, and no binding’s public API reaches them.
Adding a new FFI function
- Add the function to
ffi.rswith#[no_mangle]andextern "C", beside its related exports. - Wrap in
catch_unwind. - Use fixed-width lengths and byte-sized status/Boolean fields. Preserve the
exact existing declarations when extending an ABI. Older entry points also
use Rust/C++
bool, mapped to Javabyte. - Add the corresponding method to
TempoNative.java(JNA interface). - Add a Java wrapper in the appropriate public class.
- Port the binding to Python (
python/tempo/_native.py) and C++ (cpp/src/Native.cpp+cpp/include/tempo/detail/Native.h). Update wasm exports where the operation applies to browser planning or preview, or record why that surface is unaffected. - Write a test that exercises it through the C boundary.
The test in ffi.rs should use unsafe directly and verify round-trip correctness before the Java wrapper is written.
For performance changes, retain the caller’s ownership and failure contracts. JNA writes by-value arguments automatically, but raw-pointer calls still need explicit synchronization. Reused lookahead storage must remain bounded and public results must own their data. A known-empty event queue may skip a native drain only while errors, notifications, cancellation and callback reentry preserve that knowledge. Exercise those seams through the public binding as well as C.