A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
contract.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef A11_FLOW_CONTRACT_H_
16#define A11_FLOW_CONTRACT_H_
17
18#include <string>
19#include <string_view>
20
21#include <absl/status/status.h>
22#include <absl/status/statusor.h>
23#include <absl/types/span.h>
24
25#include "a11/flow/limits.h"
26#include "a11/flow/plan.h"
27
28namespace a11::flow {
31 const PortPlan* absl_nonnull input;
32 const PortPlan* absl_nonnull output;
33};
34
35absl::StatusOr<PipelinePorts> SelectPipelinePorts(
36 const FlowPlan& flow, absl::Span<const std::string> supplied = {});
37
39absl::StatusOr<const PortPlan*> SelectPipelineStarterOutput(
40 const FlowPlan& flow, absl::Span<const std::string> supplied);
41
43std::vector<std::string_view> FieldTypeNames(const FieldPlan& field);
45void MarkBinaryTypes(std::vector<DtoPlan>& types,
46 CompilationBudget* absl_nullable budget = nullptr);
48enum class Refinement { kYes, kNo, kUnknown };
50std::string CanonicalPayloadType(std::string_view type);
52Refinement RefinesType(std::string_view actual, std::string_view expected,
53 const Program& program);
55absl::Status MergeContract(FlowPlan& effective, const FlowPlan& contribution,
56 const Program& program);
58absl::Status CheckImplementation(const FlowPlan& actual,
59 const FlowPlan& declared,
60 const Program& program);
62std::string HeaderBytes(const syntax::Constant& constant);
63} // namespace a11::flow
64#endif // A11_FLOW_CONTRACT_H_
One cooperative deadline and work counter for a compilation request.
Definition limits.h:36
std::string type
The type and what follows it: string required, list[a11.Chunk] stream.
Definition format.cc:52
bool field
Whether this line declares a struct field.
Definition format.cc:56
CompilationBudget budget
Definition lsp.cc:289
Definition catalogue.cc:29
absl::Status MergeContract(FlowPlan &effective, const FlowPlan &other, const Program &program)
Conjoin compatible interfaces without changing executable identity.
Definition contract.cc:575
std::string HeaderBytes(const syntax::Constant &v)
Encode a constant using the native action-header textual convention.
Definition contract.cc:562
absl::Status CheckImplementation(const FlowPlan &actual, const FlowPlan &declared, const Program &program)
Validate the actual implementation against every declared obligation.
Definition contract.cc:719
void MarkBinaryTypes(std::vector< DtoPlan > &types, CompilationBudget *budget)
Definition contract.cc:509
std::vector< std::string_view > FieldTypeNames(const FieldPlan &field)
Every type named by a field, including nested container parameters.
Definition contract.cc:492
Refinement
Whether available metadata proves payload refinement.
Definition contract.h:48
Refinement RefinesType(std::string_view actual, std::string_view expected, const Program &program)
Compare payload types using native aliases and document shapes.
Definition contract.cc:556
absl::StatusOr< PipelinePorts > SelectPipelinePorts(const FlowPlan &flow, absl::Span< const std::string > supplied)
Definition contract.cc:58
absl::StatusOr< const PortPlan * > SelectPipelineStarterOutput(const FlowPlan &flow, absl::Span< const std::string > supplied)
The unique output of a call with every input supplied explicitly.
Definition contract.cc:72
std::string CanonicalPayloadType(std::string_view type)
Canonical payload spelling for alias and generic equality.
Definition contract.cc:552
One compiled flow: what a caller sees, and what the runtime will do.
Definition plan.h:157
The unique unsupplied input and unique output of a whole-stream invocation.
Definition contract.h:30
const PortPlan *absl_nonnull output
Definition contract.h:32
const PortPlan *absl_nonnull input
Definition contract.h:31
One declared port of a flow, resolved.
Definition plan.h:37