Skip to main content

Contracts

Builder-level validation rules and reports. More...

Classes Index

structValidationContext

Context passed to contracts during validation. More...

classContract

A single validation rule applied to a NodeGroup. More...

classContractRegistry

Holds a set of Contracts and runs them to produce a ValidationReport. More...

structContractPortSpec

Per-port contract: the shape/type/segment requirements for one input or output. More...

structContractFieldSpec

Per-field contract: where the field value comes from and the override policy. More...

structNodeContractDefinition

Bundle of port and field specs that fully describes a Node's contract. More...

structValidationIssue

A single reported issue from a Contract. More...

classValidationReport

Report produced by running a ContractRegistry. More...

Enumerations Index

enum classMemoryContract { ... }

How a Node (or Session) wants buffer memory to be sourced/handed back. More...

enum classCapsMemory { ... }

Memory class to advertise in GStreamer caps. More...

enum classContractFieldSource { ... }

Where the value of a contract field originates. More...

enum classContractOverridePolicy { ... }

Whether the Builder may override a contract field at build time. More...

enum classValidationSeverity { ... }

Severity level for validation issues. More...

Functions Index

std::shared_ptr< Contract >NonEmptyPipeline ()

Ensures NodeGroup is not empty. More...

std::shared_ptr< Contract >NoNullNodes ()

Ensures there are no null node pointers in the NodeGroup. More...

std::shared_ptr< Contract >SinkLastForRun (std::string sink_kind="Output")

Ensures the configured sink kind exists and is last when ctx.mode == Run. More...

std::shared_ptr< Contract >RtspRequiresSource (std::string source_kind="StillImageInput")

Ensures an RTSP source node exists when ctx.mode == Rtsp. More...

ContractRegistryDefaultRegistry ()

Reasonable default set of builder-level contracts. More...

Description

Builder-level validation rules and reports.

Enumerations

CapsMemory

enum class simaai::neat::CapsMemory
strong

Memory class to advertise in GStreamer caps.

Enumeration values
AnyDon't constrain memory class in caps (= 0)
SystemMemoryForce caps to advertise memory:SystemMemory

Any means "don't constrain in caps"; SystemMemory forces the caps to carry memory:SystemMemory so upstream/downstream negotiation picks CPU-mappable buffers.

Definition at line 54 of file ContractTypes.h.

54enum class CapsMemory {
55 Any = 0,
57};

ContractFieldSource

enum class simaai::neat::ContractFieldSource
strong

Where the value of a contract field originates.

Enumeration values
FixedValue is hard-coded in the contract definition
BuilderOptionValue comes from a builder-level option/argument
ModelOnlyValue is supplied by the model file (e.g., MPK manifest)
InputOnlyValue is determined by external input only
UpstreamOnlyValue is derived from the upstream Node's output spec
GraphOwnedValue is owned by the enclosing Graph (cross-Node)

Used by the Builder to decide whether a field is fully bound at definition time, supplied by a builder option, derived from upstream caps, baked into a model file, or owned by the Graph as a whole.

Definition at line 31 of file NodeContractDefinition.h.

ContractOverridePolicy

enum class simaai::neat::ContractOverridePolicy
strong

Whether the Builder may override a contract field at build time.

Enumeration values
ForbiddenField cannot be overridden; attempts are validation errors
BuilderOnlyBuilder code may override; user-facing API may not

Definition at line 44 of file NodeContractDefinition.h.

47};

MemoryContract

enum class simaai::neat::MemoryContract
strong

How a Node (or Session) wants buffer memory to be sourced/handed back.

Enumeration values
RequireSystemMemoryMappableMust be CPU-mappable (typically SystemMemory); violations are hard errors (= 0)
PreferDeviceZeroCopyPrefer device/zero-copy; runner may avoid forcing SystemMemory but still reports mismatches
AllowEitherButReportAllow either; if non-mappable, return empty payload with explicit reason + location

Drives the runner's behavior at output time and contributes to caps negotiation: requiring CPU-mappable memory forces a (potentially copying) conversion, while PreferDeviceZeroCopy lets the runner keep device memory whenever possible.

Definition at line 30 of file ContractTypes.h.

ValidationSeverity

enum class simaai::neat::ValidationSeverity
strong

Severity level for validation issues.

Enumeration values
InfoInformational only; never blocks a run (= 0)
WarningSoft contract violation; pipeline may still run
ErrorHard contract violation; pipeline must not run

Definition at line 29 of file ValidationReport.h.

30 Info = 0,
31 Warning,
32 Error,
33};

Functions

DefaultRegistry()

ContractRegistry simaai::neat::validators::DefaultRegistry ()
inline

Reasonable default set of builder-level contracts.

Bundles NonEmptyPipeline, NoNullNodes, SinkLastForRun, and RtspRequiresSource into a fresh registry. Keep this purely structural (no GStreamer); domain-specific contracts should be added on top.

Returns

New ContractRegistry populated with the default contracts.

Definition at line 217 of file Validators.h.

219 reg.add(NonEmptyPipeline());
220 reg.add(NoNullNodes());
221 reg.add(SinkLastForRun());
223 return reg;
224}

NonEmptyPipeline()

std::shared_ptr< Contract > simaai::neat::validators::NonEmptyPipeline ()
inline

Ensures NodeGroup is not empty.

Issues EMPTY_PIPELINE error when validated against an empty NodeGroup.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 43 of file Validators.h.

43inline std::shared_ptr<Contract> NonEmptyPipeline() {
44 class C final : public Contract {
45 public:
46 std::string id() const override {
47 return "NonEmptyPipeline";
48 }
49 std::string description() const override {
50 return "Pipeline must contain at least one node.";
51 }
52
53 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
54 ValidationReport& r) const override {
55 (void)ctx;
56 if (nodes.empty()) {
57 r.add_error(id(), "EMPTY_PIPELINE", "No nodes were added to the pipeline.");
58 }
59 }
60 };
61 return std::make_shared<C>();
62}

NoNullNodes()

std::shared_ptr< Contract > simaai::neat::validators::NoNullNodes ()
inline

Ensures there are no null node pointers in the NodeGroup.

Issues a NULL_NODE error per offending index.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 72 of file Validators.h.

72inline std::shared_ptr<Contract> NoNullNodes() {
73 class C final : public Contract {
74 public:
75 std::string id() const override {
76 return "NoNullNodes";
77 }
78 std::string description() const override {
79 return "All nodes must be non-null shared_ptr.";
80 }
81
82 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
83 ValidationReport& r) const override {
84 (void)ctx;
85 const auto& v = nodes.nodes();
86 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
87 if (!v[static_cast<std::size_t>(i)]) {
88 r.add_error(id(), "NULL_NODE", "Null node pointer in NodeGroup.", i);
89 }
90 }
91 }
92 };
93 return std::make_shared<C>();
94}

RtspRequiresSource()

std::shared_ptr< Contract > simaai::neat::validators::RtspRequiresSource (std::string source_kind="StillImageInput")
inline

Ensures an RTSP source node exists when ctx.mode == Rtsp.

Builder-level: we only check presence of StillImageInput (or another configured kind). Issues RTSP_SOURCE_MISSING if no Node of the expected kind is found in the NodeGroup.

Parameters
source_kind

The Node kind expected to act as the RTSP source.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 165 of file Validators.h.

165inline std::shared_ptr<Contract> RtspRequiresSource(std::string source_kind = "StillImageInput") {
166 class C final : public Contract {
167 public:
168 explicit C(std::string k) : src_kind_(std::move(k)) {}
169 std::string id() const override {
170 return "RtspRequiresSource";
171 }
172 std::string description() const override {
173 return "RTSP mode requires a server-side source node (e.g., StillImageInput).";
174 }
175
176 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
177 ValidationReport& r) const override {
178 if (ctx.mode != ValidationContext::Mode::Rtsp)
179 return;
180
181 const auto& v = nodes.nodes();
182 bool found = false;
183 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
184 const auto& n = v[static_cast<std::size_t>(i)];
185 if (n && n->kind() == src_kind_) {
186 found = true;
187 break;
188 }
189 }
190
191 if (!found) {
192 r.add_error(id(), "RTSP_SOURCE_MISSING",
193 "RTSP mode requires a node of kind \"" + src_kind_ + "\".", -1, src_kind_, "");
194 }
195 }
196
197 private:
198 std::string src_kind_;
199 };
200 return std::make_shared<C>(std::move(source_kind));
201}

SinkLastForRun()

std::shared_ptr< Contract > simaai::neat::validators::SinkLastForRun (std::string sink_kind="Output")
inline

Ensures the configured sink kind exists and is last when ctx.mode == Run.

This is the builder-level version of the "sink last" contract described in the architecture. Issues SINK_NOT_LAST if the last Node isn't of the expected kind, and MULTIPLE_SINKS if a sink-kind Node is found earlier in the chain.

Parameters
sink_kind

The Node kind expected as the terminal (default "Output").

Returns

Shared pointer to a fresh Contract instance.

Definition at line 108 of file Validators.h.

108inline std::shared_ptr<Contract> SinkLastForRun(std::string sink_kind = "Output") {
109 class C final : public Contract {
110 public:
111 explicit C(std::string kind) : sink_kind_(std::move(kind)) {}
112 std::string id() const override {
113 return "SinkLastForRun";
114 }
115 std::string description() const override {
116 return "When running, the pipeline must end with the terminal appsink node.";
117 }
118
119 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
120 ValidationReport& r) const override {
121 if (ctx.mode != ValidationContext::Mode::Run)
122 return;
123 const auto& v = nodes.nodes();
124 if (v.empty())
125 return;
126
127 int last_idx = static_cast<int>(v.size()) - 1;
128 const auto& last = v.back();
129 const std::string last_kind = last ? last->kind() : "";
130
131 // Require sink kind last.
132 if (!last || last_kind != sink_kind_) {
133 r.add_error(id(), "SINK_NOT_LAST", "Last node must be " + sink_kind_ + " for run().",
134 last_idx, last_kind, last ? last->user_label() : "");
135 }
136
137 // Disallow additional sinks earlier (best-effort sanity).
138 for (int i = 0; i < last_idx; ++i) {
139 const auto& n = v[static_cast<std::size_t>(i)];
140 if (n && n->kind() == sink_kind_) {
141 r.add_error(id(), "MULTIPLE_SINKS",
142 "Found " + sink_kind_ + " before the end of the pipeline.", i, n->kind(),
143 n->user_label());
144 }
145 }
146 }
147
148 private:
149 std::string sink_kind_;
150 };
151 return std::make_shared<C>(std::move(sink_kind));
152}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.