Pular para o conteúdo principal

Pipeline Graph v2

Pipeline Graph v2 is the next pipeline contract for Toposync. It keeps the public graph acyclic, but makes the operational parts of a topology explicit: node identity, edge identity, traffic class, queue policy, backpressure, lifecycle preservation, and debug sampling.

This page documents the schema boundary. The compiler accepts v2 graphs, but only queue.max_items, queue.drop_policy, traffic.modality, and lifecycle OPEN/CLOSE preservation are runtime-enforced today. The remaining edge fields are reserved contract fields until their runtime enforcement lands.

Principles​

  • The backend compiler remains the source of truth.
  • The user-facing graph is a DAG. Feedback loops are only internal runtime mechanics for known operators such as demand gates or future flow limiters.
  • Edges are operational objects, not visual lines.
  • Backpressure is part of the graph contract.
  • Fan-in must use an explicit operator instead of multiple upstream edges into the same input port.
  • OPEN and CLOSE lifecycle packets must stay protected from lossy update compaction.

Configuration errors​

Invalid operator configuration returns HTTP 400. The existing detail string remains available to clients. When schema validation identifies individual fields, the response also includes validation_errors: an array with node_id, operator_id, loc, type and msg. The loc array contains field names and collection indexes, so clients do not need to parse the human-readable message. Form and JSON editing use the same compiler.

Structured entries omit Pydantic's input, ctx and documentation URL. This does not change the legacy detail message. Errors without field-level schema information, such as an unknown operator, retain their existing response without validation_errors.

Graph shape​

{
"schema_version": 2,
"uid": "graph_front_yard",
"revision": 1,
"nodes": [],
"edges": [],
"subgraphs": [],
"resources": {},
"limits": {},
"layout": {},
"meta": {}
}

uid is stable runtime identity. Reordering JSON arrays, renaming labels, or moving nodes on the canvas should not change it.

Node shape​

{
"uid": "node_detect_01",
"id": "detect",
"operator": "vision.detect",
"config": {},
"state": {},
"ui": {
"label": "Detect people and vehicles"
}
}

id can remain human-readable. uid is the durable identity that future runtime state, metrics, and layout references should use.

Edge shape​

{
"uid": "edge_motion_detect_01",
"from": { "node": "motion", "port": "out" },
"to": { "node": "detect", "port": "in" },
"traffic": {
"modality": "video.frame",
"semantic_class": "frame",
"continuous": true,
"loss_tolerance": "lossy_updates_only"
},
"queue": {
"max_items": 1,
"max_artifact_bytes": 134217728,
"max_age_ms": 1000,
"drop_policy": "latest_only",
"key_policy": "none",
"key_path": ""
},
"backpressure": {
"mode": "pause_upstream",
"warn_at_utilization": 0.7,
"critical_at_utilization": 0.9,
"propagate_pressure": true
},
"lifecycle": {
"preserve_open": true,
"preserve_close": true,
"compact_updates": true
},
"debug": {
"sample_headers": true,
"retain_last": 10,
"retain_artifact_refs": true,
"retain_artifact_data": false
}
}

v2 moves the legacy root edge fields into queue:

{
"queue": {
"max_items": 1,
"drop_policy": "latest_only"
}
}

Do not use root-level maxsize or drop_policy in v2 edges.

First runtime targets​

The first useful v2 topology is a shared perception branch:

camera.source
-> camera.motion_gate
-> internal flow limiter
-> vision.detect
-> category routes
-> person stopped branch
-> vehicle stopped branch

The important part is not the canvas. It is that the shared edge into vision.detect has a visible queue policy and backpressure behavior before the expensive model runs.

Spatial histories across cadence limits​

Tracking events accumulate mapped observations before their update interval. Grouping keeps independent member histories before its own interval; the core throttle operators carry those snapshots through notification cadence limits. Existing recipes receive this behavior without extra nodes, capture, inference, image storage, or changed intervals. The notification's representative group pin remains distinct from the individual trajectories.

payload.spatial_history version 1 contains trails keyed by subject_id. Each point carries finite x, z, media ts, composition_id, and a provenance scope. A gap_before starts a new segment after missing mapping or changed capture, calibration, composition, or category. Duplicate and older observations within a scope are ignored. CLOSE carries the last observations without treating its delivery time or unrelated image as new evidence, and releases runtime state.

Histories retain at most 512 points per subject, 2048 per occurrence, and 64 subjects. Limiters hold at most 128 stream histories. Limits preserve the first and most recent points, expose truncated, and mark discarded intervals as gaps. This is bounded in-memory evidence, not a frame journal: an abrupt restart can lose unpublished history. Old notifications retain their original simple trail. Two-dimensional overlays expose independent trails; three-dimensional overlays may expose evidence bounds for selection framing. Updates do not override manual navigation. These contracts do not certify physical mapping accuracy or detection coverage.

Mapping gaps retain bounded failure reasons even when mapping recovers before the next published update. Notification streams use a combined 512 KiB budget: temporary images are omitted first, with image_transport_byte_limit; if durable metadata itself exceeds the budget, a resync requests the complete notification over HTTP. Stored trajectories are not shortened to fit a live message. Resizing an untouched selection refits its evidence; manual navigation remains in control.