Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"$gcc",
"$msCompile"
],
"detail": "Release build for installation with CPM_USE_LOCAL_PACKAGES enabled for testing installed packages Requires the CMake Tools extension (ms-vscode.cmake-tools) — without it, this task fails to start.",
"detail": "Release build for installation, preferring locally installed dependencies before fetching. Requires the CMake Tools extension (ms-vscode.cmake-tools) — without it, this task fails to start.",
"windows": {
"options": {
"shell": {
Expand Down
72 changes: 9 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,38 @@ cmake_minimum_required(VERSION 3.24)

include(cmake/CPM.cmake)

set(CPP_LIBRARY_VERSION "" CACHE STRING "CEL runtime package version override")

# Fetch cpp-library before project()
CPMAddPackage("gh:stlab/cpp-library@6.0.2")
CPMAddPackage("gh:stlab/cpp-library@6.1.0")
include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)

# Enable dependency tracking before project()
cpp_library_enable_dependency_tracking()

# Now declare project
project(runtime LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)

if(PROJECT_IS_TOP_LEVEL)
include(CTest)
endif()
include(CTest)

# Setup library
cpp_library_setup(
DESCRIPTION "Checked CEL programs, owned values, and reusable execution stacks"
NAMESPACE cel
REQUIRES_CPP_VERSION 20
HEADERS runtime.hpp runtime/layout.hpp runtime/value_type.hpp runtime/value.hpp runtime/record_adapter.hpp runtime/raw_stack.hpp runtime/dyn_segment.hpp runtime/callable.hpp runtime/detail/retirement.hpp runtime/detail/frame.hpp runtime/detail/raw_segment.hpp
SOURCES storage.cpp value_type.cpp value.cpp raw_stack.cpp raw_segment.cpp dyn_segment.cpp callable.cpp
TESTS storage_test.cpp value_test.cpp resource_test.cpp raw_execution_test.cpp segment_test.cpp composite_execution_test.cpp callable_test.cpp executable_retirement_test.cpp native_contract_test.cpp nontrivial_leaf_fail.cpp typed_operand_fail.cpp overloaded_operand_fail.cpp generic_conversion_fail.cpp nondeduced_generic_fail.cpp raw_interface_fail.cpp alignment_interface_fail.cpp program_metadata_fail.cpp
EXAMPLES getting_started.cpp
DOCS_INPUTS README.md docs/build.md docs/get-started.md docs/libraries.md
docs/execution.md docs/reference.dox
DOCS_EXCLUDE_SYMBOLS cel::detail cel::detail::*
DOCS_OPTIONS "USE_MDFILE_AS_MAINPAGE = ${CMAKE_CURRENT_SOURCE_DIR}/README.md"
"EXCLUDE_SYMBOLS = cel::detail cel::detail::*"
"FULL_PATH_NAMES = NO"
"STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}"
"STRIP_FROM_INC_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if(TARGET docs)
# Keeps checkout-relative contract-test links usable in generated documentation.
add_custom_command(TARGET docs POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_BINARY_DIR}/tests"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/examples" "${CMAKE_CURRENT_BINARY_DIR}/examples"
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt")
endif()

if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
configure_file(tests/installed_consumer.cmake.in installed_consumer.cmake @ONLY)
configure_file(tests/source_consumer.cmake.in source_consumer.cmake @ONLY)
add_test(NAME installed_consumer
COMMAND "${CMAKE_COMMAND}" "-DCONFIG=$<CONFIG>"
-P "${CMAKE_CURRENT_BINARY_DIR}/installed_consumer.cmake")
add_test(NAME source_consumer
COMMAND "${CMAKE_COMMAND}" "-DCONFIG=$<CONFIG>"
-P "${CMAKE_CURRENT_BINARY_DIR}/source_consumer.cmake")
set_tests_properties(installed_consumer source_consumer PROPERTIES TIMEOUT 180)
set_tests_properties(executable_retirement_test PROPERTIES TIMEOUT 180)
endif()
if(TARGET storage_test)
target_include_directories(storage_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
endif()
if(TARGET raw_execution_test)
target_include_directories(raw_execution_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_tests_properties(raw_execution_test PROPERTIES TIMEOUT 30)
endif()
if(TARGET value_test)
target_include_directories(value_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
endif()
if(TARGET resource_test)
foreach(test storage_test raw_execution_test value_test resource_test segment_test
callable_test executable_retirement_test composite_execution_test)
target_include_directories(${test} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
endforeach()

find_package(Threads REQUIRED)
target_link_libraries(resource_test PRIVATE Threads::Threads)
target_include_directories(resource_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_tests_properties(resource_test PROPERTIES TIMEOUT 30)
endif()
if(TARGET segment_test)
target_include_directories(segment_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_tests_properties(segment_test PROPERTIES TIMEOUT 30)
endif()
foreach(test callable_test executable_retirement_test)
if(TARGET ${test})
target_include_directories(${test} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
endif()
endforeach()
if(TARGET composite_execution_test)
target_include_directories(composite_execution_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_tests_properties(composite_execution_test PROPERTIES TIMEOUT 30)
endif()
if(TARGET callable_test)
target_include_directories(callable_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set_tests_properties(callable_test PROPERTIES TIMEOUT 30)
endif()
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{
"name": "install",
"displayName": "Install Configuration",
"description": "Release build for installation with CPM_USE_LOCAL_PACKAGES enabled for testing installed packages",
"description": "Release build for installation, preferring locally installed dependencies before fetching",
"binaryDir": "${sourceDir}/build/install",
"generator": "Ninja",
"cacheVariables": {
Expand Down
3 changes: 1 addition & 2 deletions docs/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ same-shape ownership ABIs. Complete compatibility also checks every callable
result's ownership, including callables inside aggregate results, before
checked execution or preparation admits the input. Prepared execution does not
repeat these comparisons. Results may be client leaves, nested aggregates, or
another callable. The installed consumer exercises receipt after builders and
the temporary compiled factory disappear.
another callable.

`value_type::callable(parameters, result)` describes a semantic signature
without ownership operations. Use `bind_runtime_ownership(type)` when checked
Expand Down
6 changes: 3 additions & 3 deletions docs/parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The following entries cover the retained runtime surfaces:
| Dynamic checked construction; preflight before effects; single-result freeze | [segment tests](../tests/segment_test.cpp), “checked signatures reject errors before callback effects” and “dynamic ordered mixed operations freeze reads and literals” | [dyn_segment.rs:757–789][rust-dyn], [prepared_segment.rs:16–75][rust-prepared] | Implemented |
| Static stack effects and declared initial operands | Not part of the client interface | [segment.rs:57–73,90–122,188–239,350–415][rust-typed] | Not retained; clients compile source or use checked dynamic builders |
| Complete identity, layout, and separately checked ownership capabilities | [value tests](../tests/value_test.cpp), including “private callable ownership installation preserves shape and validates operation pairs”; [resource tests](../tests/resource_test.cpp) for shared descriptor DAGs | [value_type.rs:1–9,47–74][rust-types], [prepared_segment.rs:16–75][rust-prepared] | Implemented |
| Code-independent canonical ownership binding for complete immutable type DAGs, including empty callable composites and higher-order result witnesses | [callable tests](../tests/callable_test.cpp): ownership binding, deep/shared DAGs, foreign-operation rejection; [installed consumer](../tests/installed_consumer/main.cpp) | C++ semantic-descriptor/canonical-carrier adaptation; no same-named Rust API claim | Implemented; semantic Fn declarations remain unbound |
| Code-independent canonical ownership binding for complete immutable type DAGs, including empty callable composites and higher-order result witnesses | [callable tests](../tests/callable_test.cpp): ownership binding, deep/shared DAGs, foreign-operation rejection | C++ semantic-descriptor/canonical-carrier adaptation; no same-named Rust API claim | Implemented; semantic Fn declarations remain unbound |
| Recursive independent aggregate copies, native boundary adapters, over-aligned client roots | [segment tests](../tests/segment_test.cpp): “typed composite calls borrow inputs and return disjoint nested results”, “valid over-aligned client root arguments and results are admitted”; [value tests](../tests/value_test.cpp) | [prepared_segment.rs:96–225][rust-prepared] | Implemented; native C++ facades differ |
| Tuple packing at exact origin; source-order ownership transfer | [structural tests](../tests/composite_execution_test.cpp): “nested packing consumes source order and preserves exact owners” | [dyn_segment.rs:792–825][rust-dyn] | Implemented; origin includes logical depth |
| Typed arrays, empty arrays, zero-byte elements, nested owning payloads | [structural tests](../tests/composite_execution_test.cpp) packing and invalid-shape cases; [value tests](../tests/value_test.cpp) | [dyn_segment.rs:852–916][rust-dyn] | Implemented |
Expand All @@ -38,10 +38,10 @@ The following entries cover the retained runtime surfaces:
| Stable source-ordered guarded dynamic invocation across nested stack growth | [callable tests](../tests/callable_test.cpp), nested-growth reread and throwing dynamic-body tests | [dyn_segment.rs:1367–1457][rust-dyn] | Implemented; stable C++ canonical staging |
| Nonallocating stack-independent callable/program retirement; deep literals, lazy bodies, and shared children | [executable retirement tests](../tests/executable_retirement_test.cpp), depth-12000 normal/unwinding and last-owner retirement | C++ ownership contract; no speculative Rust destruction claim | Deep retirement tested; allocation counts are not measured |
| Complete higher-order result ownership before effects or raw binding | [callable tests](../tests/callable_test.cpp): “higher order results reject foreign ownership before checked execution and binding”, independently bound canonical higher-order witnesses | Complete checked ownership contract; foreign C++ ABI fixture has no Rust equivalent | Corrected; prepared execution remains comparison-free |
| Typed/raw preparation; no repeated descriptor comparison; caller-owned raw result retirement | [segment tests](../tests/segment_test.cpp), [installed consumer](../tests/installed_consumer/main.cpp) for public typed execution | [prepared_segment.rs:16–168,228–255][rust-prepared] | Implemented; raw result retirement tested in segment suite |
| Typed/raw preparation; no repeated descriptor comparison; caller-owned raw result retirement | [segment tests](../tests/segment_test.cpp) | [prepared_segment.rs:16–168,228–255][rust-prepared] | Implemented; raw result retirement tested in segment suite |
| Intermediate alignment, prefix totals, zero-byte depth, selected/known-callee peaks | [segment tests](../tests/segment_test.cpp), [structural tests](../tests/composite_execution_test.cpp), [callable tests](../tests/callable_test.cpp) | [raw_segment.rs:117–130][rust-raw] gives alignment/frame metadata | Implemented/tested; published C++ reservation helper is an adaptation, not claimed Rust API parity |
| Exception suffix cleanup, preserved prefixes, construction rollback, partial-owner retirement, reusable stack | [raw execution tests](../tests/raw_execution_test.cpp), [segment tests](../tests/segment_test.cpp), structural/callable callback exceptions and invalid-construction rollback cases | [raw_stack.rs:67–76][rust-stack], [raw_segment.rs:411–433][rust-raw], [dyn_segment.rs:1367–1457][rust-dyn] | Implemented; allocation-failure injection is not tested |
| Installed umbrella, standalone scalar/composite/callable clients, runnable cached example | [installed consumer](../tests/installed_consumer/main.cpp), [example](../examples/getting_started.cpp), `installed_consumer` CTest | C++ packaging adaptation; no Rust package-equivalence claim | Implemented |
| Runnable cached example | [example](../examples/getting_started.cpp) | C++ packaging adaptation; no Rust package-equivalence claim | Implemented |

## Deliberate scope and mechanism adaptations

Expand Down
12 changes: 5 additions & 7 deletions docs/runtime-milestone.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ Independent final port review and remote/platform validation remain pending.

## Reproduce local validation

The pinned cpp-library release is `v6.0.2` at revision
`df18f94c816df6dc4fbab8078e6b57a7d265a2c2`. Its presets, doctest/CTest,
The pinned cpp-library release is `v6.1.0` at revision
`13ff79ac9fbbf575bbab0ab3dee0c752b4501fcc`. Its presets, doctest/CTest,
compile-fail gates, Doxygen, exports, installation, and generated CI remain in
use. The installed-consumer CTest installs the built configuration to an
isolated prefix, rejects leaked source/sibling paths, and compiles two real
clients using only the imported package.
use.

Run Debug and lint checks from the checkout:

Expand Down Expand Up @@ -116,8 +114,8 @@ ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 \
ctest --test-dir build/sanitized --output-on-failure
```

The original milestone's 16 CTests, including six compile-fail gates, the runnable example, and
installed consumption, pass in Debug, Release, supported ASan+UBSan, and
The original milestone's runtime tests, compile-fail gates, and runnable example
pass in Debug, Release, supported ASan+UBSan, and
clang-tidy configurations. Compiler output is warning-free, formatting passes,
and strict Doxygen passes. Explicit owner counters supplement sanitizer
cleanup checks. macOS LeakSanitizer is unsupported and disabled; it is not a
Expand Down
9 changes: 5 additions & 4 deletions include/cel/runtime/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ template <class T>
struct concrete_adapter;
template <class T>
concept nominal_record_adapter = requires(const T& input, const value& encoded) {
{ record_adapter<T>::type() } -> std::same_as<value_type>;
{ record_adapter<T>::to_value(input) } -> std::same_as<value>;
{ record_adapter<T>::from_value(encoded) } -> std::same_as<T>;
{record_adapter<T>::type()}->std::same_as<value_type>;
{record_adapter<T>::to_value(input)}->std::same_as<value>;
{record_adapter<T>::from_value(encoded)}->std::same_as<T>;
};
template <class T>
struct boundary_adapter;
Expand Down Expand Up @@ -573,7 +573,8 @@ struct boundary_adapter {
const auto& expected = adapter_record_type<T>();
auto encoded = record_adapter<T>::to_value(source);
if (!encoded.type().compatible_with(expected))
throw std::invalid_argument("record adapter returned the wrong nominal record type");
throw std::invalid_argument(
"record adapter returned the wrong nominal record type");
return encoded;
} else {
return concrete_adapter<T>::from(source);
Expand Down
46 changes: 0 additions & 46 deletions tests/installed_consumer.cmake.in

This file was deleted.

26 changes: 0 additions & 26 deletions tests/installed_consumer/CMakeLists.txt

This file was deleted.

Loading
Loading