Rocoto Real-time data services

This package supplies the shared product boundary for admitted observations and business facts. The video control room, replay, maintained processing modules, hosted agents and MCP adapters target this boundary. Product architecture describes the whole product; delivery plan tracks integration.

Implemented foundation

The live prototype still uses its commissioned stores until a verified snapshot migration and adapter cutover. Having this package and passing database tests does not establish UI cutover, worker commissioning or production readiness. Accepted observations remain distinct from dataset labels, quarantined model responses and synthetic test records.

Authenticated read integration

GET /api/realtime/sources/{source_id}/assets/{asset_id}/snapshot returns a source projection, optionally at a bounded at_s playhead. GET /api/realtime/replays/{run_id} returns saved replay progress. GET /api/realtime/sources/{source_id}/epochs/{epoch_id}/snapshot reads one registered continuous session; its optional at_s is stream time. Its separate playback descriptor names verified tracker-backed visits, tracker namespace/ID/birth bindings and source artifact mappings, even when no action observation has been admitted. First observed is a camera measurement, not store entry. The descriptor rechecks current camera/visit state on every read and contains source identifiers for the private media resolver; stored interval evidence does not invent trail geometry. The response names the epoch and stream clock, while each chapter retains its real recording asset and local source window. It does not expose the synthetic storage key as a playable asset. This maintained HTTP router uses sup_session, current team membership and source grants; responses are private and uncached. Revocation applies to cached sessions and copied replay data. Identity resolution and the SDK read share one five-second deadline, after the existing supplier authentication dependency. Invalid or out-of-range playheads return a bounded validation error.

Identity import intentionally preserves opaque operator IDs with no invented email association. The supplier-session router resolves a verified email to that durable operator. Its deployment requires host invocation of identity.reconcile_verified_login after platform-owner and supplier verification; an unbound imported principal returns principal_unavailable. The existing email-keyed invite flow must not create a duplicate operator as a substitute.

The native video product has a separate authenticated adapter into these same SDK services. It preserves its existing verified access-code session and exact company/principal IDs, without an email reconciliation or a second login. Its explicit read-authority setting, restricted pool and artifact dependency closure are implemented and tested; source/media commissioning and frontend cutover remain open. The published preview retains its recorded authority.

Historical tracker reports

A retained complete single-recording tracker run can supply selectable visitors through EpochStart.historical_run and migration 0011_realtime_tracker_reports. The host verifies the exact media, original sidecar, execution/EOS log, application configuration, producer and source sample mapping hashes. Its typed snapshot digest seals the complete report. The retained application configuration is explicitly distinguished from a complete effective low-level tracker configuration. The run accepts its exact recording clock and hash; rotation or cross-camera association uses the separate commissioned continuity path.

The store binds each retained hash to the record that carries it: the application configuration to the epoch's configuration hash, the media hash and source sample mapping to the single artifact mapping, the sidecar and snapshot digest to every receipt on that recording, and the EOS log to the closure. One recording keeps one mapping and one tracker epoch. Delivering the same report again, including two deliveries at once or one after closure, returns the retained records. A delivery with any changed sealed value conflicts.

Old KITTI records can mix current and retrospectively emitted tracker boxes. Their visibility stays reported, with a deterministic first-reported identity scoped to the run namespace, sidecar hash, raw tracker ID and first reported frame. One raw tracker ID keeps one report boundary, and the sealed snapshot contains that frame. The visit basis is first_reported; playback exposes first_reported separately from first_observed, including the first frame with empty elapsed history. first_reported is the visit's sealed first reported frame for every delivery order and slicing of its segments. Current source grants, camera/visit retractions and bounded reads apply equally to these records.

Action-to-visit bindings continue to require explicitly observed coverage, and a first_reported visit is refused by its basis alone. Observed items attach to observed visits under the same rule. The historical adapter can register a tracking.reported profile and actual tracker-input receipt while admitting zero action events. Its receipt does not attest a video-reasoning model call; an action event citing it is quarantined.

Migration 0011 widens one check constraint on realtime.track_segment.state. Grants, policies and FORCE RLS keep their 0009 shape, and the revision is declared backward compatible. The previous release starts against the upgraded schema, keeps its own writes valid and rejects historical_run, reported and first_reported records as validation errors. Downgrade is refused so reported history is retained; rollback restores application code.

Frame times come from one canonical clock, reported_frame_s: recording start plus frame index over frame rate, in decimal seconds at 28 significant digits. Hosts use that value for each first reported frame; a differently rounded time is refused. The database fixtures prove 8 frames per second, where every frame time is a finite decimal, and 30 frames per second with a stream offset, where playback returns each retained source interval exactly.

The host audits the original completed run before creating these records. SDK support and database tests establish the storage contract, and import_tracker_run.py is the host command that performs the audit and the import. Importing the published preview's workspace, private media resolution and raw box sidecar delivery are separate commissioned steps. Sparse publisher-frame reconstructions preserve their encoded clock and original sample map, and retain that footage qualification in the source metadata (temporal_sampling, unique_source_frames).

Host import of a retained run

python -m realtime.import_tracker_run imports one retained, complete, single-recording person-tracker run per camera view. It reads a run root in the producer's layout and writes through RealTimeStore, SubjectStore and ContinuityStore only, as rocoto_rt under row security.

cd backend    # or a release's packaged _maintained_backend directory
python -m realtime.import_tracker_run --run-root RUN_ROOT --reference RUN_LABEL \
  --identity SAVED_WORKSPACE_IDENTITY.json --principal OWNER_PRINCIPAL
RUNTIME_DATABASE_URL=... python -m realtime.import_tracker_run --run-root RUN_ROOT \
  --reference RUN_LABEL --identity SAVED_WORKSPACE_IDENTITY.json --principal OWNER_PRINCIPAL \
  --apply --expected-plan-sha256 PLAN_SHA256 --receipt NEW_RECEIPT.json

The first form is the dry run. It opens no database, changes no file and prints the plan: per view its identifiers, sealed hashes, frame, visit and segment counts and each visitor's first reported frame, plus one plan_sha256 over the whole run, the company and the principal. --apply requires that reviewed checksum, the restricted connection in RUNTIME_DATABASE_URL and a new receipt file in an existing folder outside the repository and the run root. --view CLIP selects views; the default is every record of the run manifest. The run label names the retained run inside every evidence reference, so one run keeps one label.

Evidence sits per view under retail-action-nvidia/<clip>/, with retail_prepare_track.py, tracker-template.txt and source-inventory-proof.json at the run root:

Evidence Check Sealed in
clean.mp4 SHA-256 and byte length equal the source inventory historical_run.source_sha256, the mapping, the receipt
app.txt one enabled file source naming this view's clean.mp4, the NVIDIA multi-object tracker enabled, KITTI output into this view's tracker-kitti, file-loop = 0, the recording's frame size configuration_sha256, historical_run.application_config
tracking.log one Received EOS. Exiting line followed by App run successful; tracking_exit 0 in the run receipt historical_run.execution_log, the closure
tracker-kitti/ exactly 00_000_000000.txt onward, one file per frame; each row has 17 columns and class Person; a tracker ID appears once per frame historical_run.tracker_sidecar, every birth identity
source_mapping.json one entry per encoded frame on the encoded clock, each naming its publisher frame historical_run.source_mapping, the mapping's evidence
receipt.json equals its run-manifest record; duration equals frame count over an integer frame rate the epoch's evidence, the camera's provenance
tracks.json equals the sidecar row for row the receipt (retained_run.tracks_sha256)
producer script, template, inventory regular files of the run root historical_run.producer, the receipt's retained_run

Every path is a regular file or directory reached through real directories. A symbolic link below the run root is refused.

The per-frame directory has one canonical digest, rocoto.tracker-kitti-directory.v1: the SHA-256 of a UTF-8 listing whose first line is that schema name, followed by one line per file in ascending byte order of its name, <sha256 of the file bytes> <file name>, each line ending in a line feed. A host reproduces it with standard tools:

cd RUN_ROOT/retail-action-nvidia/CLIP/tracker-kitti
{ printf 'rocoto.tracker-kitti-directory.v1\n'; LC_ALL=C sha256sum -- *; } | sha256sum

Identifiers come from the view alone, so changed bytes meet the retained record of the same name: source and source asset retailaction-<clip> (kind camera, preserved), camera subject <source>-camera, epoch and tracker namespace <source>-tracker-report, mapping <epoch>-m1, receipt <epoch>-r1, profile revision tracking-reported@1 with the single event type tracking.reported, visit <epoch>-v<raw tracker ID> and segment <visit>-s<first frame of its interval>.

Per view the command registers the source, the profile, the camera subject, the epoch with historical_run, exactly one artifact mapping whose evidence equals historical_run.source_mapping, the tracker-input receipt, one first_reported visit per raw tracker ID, one reported segment per run of consecutive reported frames, and the eos closure with the execution log. A visit's boundary is reported_birth_id over the namespace, sidecar digest, tracker ID and first reported frame; its provenance window is that one frame from reported_frame_s. The command admits zero events and registers zero observed items.

Before the first write of a run the command checks the database role, the company binding and the principal's configure and ingest capabilities, then compares every record the run's views already retain with the plan. One differing record refuses the whole run. An identical run returns the retained records and adds no row, and an interrupted run completes on the next apply. A changed byte in an evidence file changes plan_sha256 and the sealed record that carries its hash, so it is refused against the reviewed checksum and again against the retained records. The receipt lists per view the identifiers, hashes, counts, record digests, rows before and after, and the playback read-back. A failure after writing began leaves a receipt with status failed.

On 10 October 2026 the command imported the 40 retained RetailAction views into a disposable database: 40 sources, 40 epochs, 40 closures, 40 mappings, 142 reported segments, 0 other segments, 142 first_reported visits and 0 events. The legacy projection counted the same 142 recording-scoped visits, one per raw tracker ID of each recording. A second apply added no row. That rehearsal used a synthetic company; the published preview's import is its own commissioned step.

python3 tools/test-database.py -q tests/test_realtime_historical_tracker.py tests/test_realtime_import_tracker_run.py runs the storage contract and the importer against a disposable database, including the upgrade from 0010 with existing rows. The importer's fixtures are small synthetic run roots.

Location trackers

Migration 0012_realtime_locations adds eight tables and LocationStore (locations.py) is their only writer, as rocoto_rt under row security. The schema holds 32 realtime tables at this revision. A location's name, address, coordinates and business scope stay in the video preview's own stores; PostgreSQL holds the identity the tracker tables hang from.

Table Holds Written by (capability)
location identity (location_id, collection, business_type), run_seq (what a commit expects), page_seq (the page's revision), through_sequence (the highest event sequence a committed run read), the run policy with its revision, a manual request, back-off and the lease register_location, set_policy (configure); commit, request, claim, finish (process); a tracker change moves both revisions (configure)
location_source the cameras of a location: one source of kind camera per row with its camera_id; a camera belongs to one location bind_source (configure)
location_tracker one tracker: key, Core status, kind, chat, state and its head (the active revision of each part, moved one head_revision at a time) install_trackers, activate (configure)
location_tracker_revision append-only revisions of the parts definition, script and presentation, each with its digest and the conversation that wrote it install_trackers, save_revision (configure)
location_tracker_output the current output of a tracker, updated in place: tile, canvas, periods, period, input, digest, revision commit (process)
location_tracker_output_revision the ledger: one row per published revision with its digest, period, input and a summary of the tile commit (process)
location_record retail records by kind, each identified within its location; a row keeps the basis it was written with (derived, ingested or configured) and draws a higher mark at every write commit for derived rows (process); put_records (ingest for ingested, configure for configured)
location_run the newest 200 runs of a location: trigger, status, times, input stamp, local day, wall time, bounded outputs and errors, and the digest and answer of the run's one commit claim, commit, finish (process)

Rules the database holds, each with the SDK refusing first:

home returns the page keys (core_trackers, core_tracker_canvases, products, currency) with page_seq as revision, and a short unchanged answer for a caller that names the revision home gave it; any other value gets the whole page. claim_events leases the live outbox rows of location cameras, grouped by location, and commit finishes them. input_stamp is a digest of what a run reads: the events of the location's cameras with their bindings, the ingested and configured records, the cameras and the tracker heads. Every write of a record draws a higher mark from one sequence (the trigger mark_location_record), and the stamp carries the count and the sum of marks of the location's input rows, so it moves with each committed write in whatever order the writers began and committed. realtime.location_inputs answers those counts and high-water marks in one call for a principal who reads the location, so a probe can ask every few seconds.

The schedule methods carry the names and return shapes of the preview runner's TrackerRuns: policy, set_policy(expected_revision), request, claim, finish, runs, state and last_run. An expired holder's run closes as interrupted at its lease's end when the next pass takes over, and reads as interrupted from that moment in runs, last_run and state; its holder can still commit and close it while every other pass stays away. finish acts for the holder's token. The unattended runner acts as the company owner; a service actor with realtime:process and a process grant on each camera fits the same policies when one is commissioned.

python3 tools/test-database.py -q tests/test_realtime_locations.py runs the storage contract against a disposable database, including the upgrade from 0011, raw SQL as rocoto_rt with another company's settings and one pass with a plain role owning the tables. On 11 October 2026, at the seeded demo's volume (1,735 events, 7,500 records, nine outputs of about 100 KiB), load took 1.5 s, an unchanged commit 0.15 s and home 0.02 s on the development box; with 300 events load took 0.4 to 0.6 s and input_stamp 0.01 s. The same script after the fenced commit, at 300 events and 7,500 records with the box under shared load (load average above 20 on four CPUs), gave an unchanged commit of 0.35 to 0.66 s, an exact retry of a commit 0.13 s, home 0.04 s, a short unchanged answer 0.01 s, input_stamp under 0.01 s and claim with finish 0.05 s. The Python work of that commit, measured alone, went from 0.026 s to 0.037 s with the commit digest.

Admission

The trusted host resolves company, principal, conversation, exact capabilities and deadline. RealTimeStore rechecks current membership using the restricted database role on every operation. Owners can configure sources/profiles; service workers additionally need explicit source grants. Workers register actual input receipts before submitting canonical events. Admission verifies saved profile/event names, receipt identity and source bounds, and commits each event and its processing outbox row in one transaction. Invalid evidence is retained in a bounded quarantine. Conflicting identities raise a conflict; retries of identical revisions reuse the original event.

Video timestamps preserve their original source window. An anonymized dataset can have a source clock and an unknown UTC capture time. Ingestion time describes the host receiving the data. A connector's effective timestamp describes its business fact. These clocks have separate fields. Processing provenance names each input event revision; a later correction cannot silently change the evidence a processing result claims. A source's record/revision identifiers persist through retries and adjacent worker windows.

Leases use fresh tokens and database time. Expired work can be reclaimed, stale completions fail, and five expired attempts leave a retained failed job. A consumer must make its own effects idempotent using the event and revision; this outbox provides at-least-once work delivery. Replay work uses an explicit separate lane. Derived events preserve that replay lineage; a processing result cannot enter live delivery by discarding its replay context.

Resource limits

Admission serializes the company budget check with the write. Retained usage includes sources, profiles, receipts, admitted events and quarantine across all company sources, including those a particular worker cannot read. The initial allowance is 128 MiB of accounted record bytes and row caps; provider/disk/index overhead is covered by the host's separate operational reserve. Reads apply the byte allowance in SQL before materializing event JSON in the process. These limits require an explicit retention/archival policy before continuous production; exceeding a limit stops admission rather than silently deleting evidence.

Verification

From the repository root:

python3 tools/test-database.py -q tests/test_schema_migrations.py tests/test_realtime_contracts.py tests/test_realtime_provision.py tests/test_realtime_store.py tests/test_realtime_replay.py tests/test_realtime_replay_store.py tests/test_realtime_subjects.py tests/test_realtime_modules.py tests/test_realtime_module_store.py tests/test_realtime_replay_worker.py

The runner creates its own PostgreSQL cluster, applies the reviewed migration chain, supplies the restricted runtime/control roles, runs the tests and removes only that disposable cluster. Fixtures are marked test data and make no provider/model calls. The two host commands have their own files, tests/test_realtime_provision.py and tests/test_realtime_import_tracker_run.py.

The runner's owner role is the container's superuser. The video preview's commissioning rehearsal applies the same chain and both host commands as a plain owner role beside rocoto_rt, the way a host creates them.

The combined schema, foundation, subjects, modules and replay-worker suite passed 166 tests on October 9, 2026. Proofs include transactional failure injection, copied-history revocation, replay restart/concurrent ticks, two separately identified replay loops, pickup/examination/return, empty/replenished stock and recovery after admission before projection. These are disposable-database fixtures, independently of actual model results.

Visits begin with a source asset and may continue across files through a registered tracker epoch, immutable clock mappings and receipt-backed observed segments. The continuous reducer uses the stream clock while preserving each chapter’s original file and local time. Camera-to-camera associations remain a separate commissioning requirement; equal raw tracker IDs are insufficient.

Search documentation

Type to find a guide or section.

↑ ↓ to choose · Enter to open · Esc to close