Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8b6ec79
Phase 0: OrtJson_* opaque-handle DOM API and shared status plumbing
jambayk Jun 9, 2026
2ee17de
Phase 1: new schema parser and read-only inspection API
jambayk Jun 9, 2026
e910688
model_package: Phase 2 — shared asset hashing
jambayk Jun 9, 2026
b3be725
model_package: Phase 3 — authoring (mutation) API
jambayk Jun 9, 2026
aae80e2
model_package: Phase 4 — commit, vacuum, validate
jambayk Jun 9, 2026
8a95940
model_package: Phase 5 — ORT cutover to new public C API
jambayk Jun 9, 2026
ffe9f7f
model_package: flat POD info tree + cleanup pass
jambayk Jun 9, 2026
9c63f63
model_package: drop eager variant_directory existence check
Jun 9, 2026
5550651
model_package: tighten variant_directory rule + rename Vacuum to Prune
Jun 9, 2026
0eb400d
model_package: Prune sweeps tracked orphan variant/component dirs
jambayk Jun 9, 2026
c084b56
session: route model_package external_data through folder hint via mm…
jambayk Jun 9, 2026
158cde4
model_package: tighten comments, update Prune docstring
jambayk Jun 9, 2026
0ef2d89
session: replace shared_files bookkeeping with dedicated external_dat…
jambayk Jun 9, 2026
700c77f
model_package: add ModelPackage_ResolveStringRef and route ORT execut…
jambayk Jun 9, 2026
3a5cec5
session: avoid null deref in CreateSessionForModelPackage when option…
jambayk Jun 9, 2026
2c8b4d6
session: drop variant.json fallback in model_package context
jambayk Jun 9, 2026
f3aeb70
session: propagate errors from ModelPackage_GetVariantEpName
jambayk Jun 9, 2026
4caebb0
model_package: pre-resolve external executor_info at Open / PostMutate
jambayk Jun 9, 2026
4f4ba66
model_package: extract DefaultSharedAssetDirName / SharedAssetUriFrom…
jambayk Jun 9, 2026
9c695e0
model_package: skip RefreshSharedAssets in PostMutate for executor_in…
jambayk Jun 9, 2026
c0f91e7
model_package: bypass prune grace window for in-session tracked orphans
jambayk Jun 9, 2026
8c2a1fe
model_package: refuse commit when AddSharedAsset is not paired with u…
jambayk Jun 9, 2026
0931a8d
model_package: cover dest_root commit rehash with explicit test
jambayk Jun 10, 2026
a7b3b33
model_package: drop the OrtJson public ABI surface
jambayk Jun 10, 2026
19daa36
model_package: clarify CreateSession C-API doc re: captured session o…
jambayk Jun 10, 2026
2ff508d
model_package: rename ModelExecutorInfoEntry::ns to namespace_key
jambayk Jun 10, 2026
f3f8e96
model_package: narrow AddSharedAsset out_uri lifetime contract
jambayk Jun 10, 2026
3f42d66
model_package: rewrite library README to match the current C API
jambayk Jun 10, 2026
a5e55ab
model_package: skip creating empty shared_assets/ on dest_root commit
jambayk Jun 10, 2026
34f4bb3
model_package: document schemas and ORT integration
jambayk Jun 10, 2026
174c80e
model_package/README: clarify external-component path forms
jambayk Jun 10, 2026
e756d57
model_package: drop uses_assets; auto-discover shared assets at Open
jambayk Jun 10, 2026
eeddf9a
Merge remote-tracking branch 'origin/main' into jambayk/model-package…
jambayk Jun 10, 2026
e9af69a
model_package: expose OrtModelPackageApi as experimental C API
jambayk Jun 10, 2026
096d901
lint
jambayk Jun 10, 2026
30d5401
model_package: drop cross-repo references in docs and examples
jambayk Jun 10, 2026
657cbac
test_model_package: drop CxxWrappers tests for removed wrapper types
jambayk Jun 10, 2026
eef8d8c
model_package: guard POSIX-only includes for Windows builds
jambayk Jun 10, 2026
ff94e46
model_package: use unsigned long long for 64-bit random suffix
jambayk Jun 10, 2026
be7d52d
Merge remote-tracking branch 'origin/main' into jambayk/model-package…
jambayk Jun 11, 2026
77fc502
Add ModelPackage_ResolveStringRef to the experimental model package API
jambayk Jun 23, 2026
c7d99d5
Address model package review feedback on path confinement and ABI
jambayk Jun 23, 2026
d9c1bf9
Merge remote-tracking branch 'origin/main' into jambayk/model-package…
jambayk Jun 23, 2026
d820c35
Version the model package schema as major.minor and expose collection…
jambayk Jun 23, 2026
8a453d9
Expose model package collections as plain arrays
jambayk Jun 23, 2026
a03e6d3
Document model package source distribution and schema versioning
jambayk Jun 23, 2026
ac08437
Explain how a major schema bump maps onto the structs
jambayk Jun 23, 2026
07c4f1d
Address model package review feedback on path confinement and docs
jambayk Jun 23, 2026
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
8 changes: 3 additions & 5 deletions cmake/onnxruntime_session.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ file(GLOB onnxruntime_session_srcs CONFIGURE_DEPENDS

# Standalone model package library (parsing/inspection with no ORT dependency).
# Compiled as a static library and linked into onnxruntime_session.
# NOTE: ORT intentionally uses the library's internal C++ types directly (model_package::ParsePackage,
# model_package_internal.h) rather than going through its public C API (ModelPackage_*). This avoids
# double-wrapping (ORT C API -> standalone C API -> C++ internals). The public C API exists for
# external consumers (GenAI, FL) who link against the standalone library independently.
# ORT uses the standalone library's public C API (model_package.h) and translates
# the C handles into ORT-internal C++ types inside core/session/model_package/.
set(MODEL_PACKAGE_LIB_DIR "${REPO_ROOT}/model_package")
if(NOT onnxruntime_MINIMAL_BUILD)
set(MODEL_PACKAGE_BUILD_SHARED OFF CACHE BOOL "" FORCE)
Expand Down Expand Up @@ -59,7 +57,7 @@ onnxruntime_add_include_to_target(onnxruntime_session onnxruntime_common onnxrun
target_link_libraries(onnxruntime_session PRIVATE onnxruntime_lora)
if(TARGET model_package)
target_link_libraries(onnxruntime_session PRIVATE model_package)
target_include_directories(onnxruntime_session PRIVATE ${MODEL_PACKAGE_LIB_DIR}/include ${MODEL_PACKAGE_LIB_DIR}/src)
target_include_directories(onnxruntime_session PRIVATE ${MODEL_PACKAGE_LIB_DIR}/include)
endif()
if(onnxruntime_ENABLE_INSTRUMENT)
target_compile_definitions(onnxruntime_session PUBLIC ONNXRUNTIME_ENABLE_INSTRUMENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ORT_EXPERIMENTAL_API(28, OrtStatusPtr, OrtApi_ExperimentalApiTest, _Out_ int64_t
// - OrtModelPackageApi_ModelPackage_GetVariantCount
// - OrtModelPackageApi_ModelPackage_GetVariantNames
// - OrtModelPackageApi_ModelPackage_GetVariantEpName
// - OrtModelPackageApi_ModelPackage_ResolveStringRef
// 4) Select a component and resolve variant:
// - OrtModelPackageApi_SelectComponent
// 5) Query selected variant info (optional):
Expand Down Expand Up @@ -212,6 +213,33 @@ ORT_EXPERIMENTAL_API(28, OrtStatusPtr, OrtModelPackageApi_ModelPackage_GetVarian
_In_ const char* variant_name,
_Outptr_result_maybenull_ const char** out_ep)

/** \brief Resolve a path reference declared inside the package against the model_package rules.
*
* Handles the path forms a package may use:
* - "sha256:<hex>" or "sha256:<hex>/<tail>": a content-addressed shared asset. Resolves to
* the asset's on-disk directory (honoring manifest shared_assets overrides), optionally
* joined with the confined tail. Errors if the asset is not declared/discovered.
* - any other value: a relative path resolved against `base_dir` (or the package root when
* `base_dir` is NULL), with portable-layout confinement (no absolute paths, no "..").
*
* When `must_exist` is non-zero the resolved path must exist on disk. `out_path` is owned by
* `ctx` and remains valid until the next call to this function on the same context.
*
* \param[in] ctx The package context returned by OrtModelPackageApi_CreateModelPackageContext.
* \param[in] base_dir Base directory for relative inputs. May be NULL to use the package root.
* \param[in] input The path reference to resolve.
* \param[in] must_exist Non-zero to require that the resolved path exists on disk.
* \param[out] out_path Receives the resolved path string.
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*/
ORT_EXPERIMENTAL_API(28, OrtStatusPtr, OrtModelPackageApi_ModelPackage_ResolveStringRef,
_In_ const OrtModelPackageContext* ctx,
_In_opt_ const char* base_dir,
_In_ const char* input,
_In_ int must_exist,
_Outptr_ const char** out_path)

/** \brief Select a component model and return an opaque component instance.
*
* The variant selection is also performed during this call based on the component
Expand Down
50 changes: 47 additions & 3 deletions model_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ endif()
# ─────────────────────────────────────────────────────────────────────────────

set(MODEL_PACKAGE_SOURCES
src/api.cc
src/parser.cc
src/asset_hasher.cc
src/authoring.cc
src/commit_prune_validate.cc
src/manifest_parser.cc
src/model_package_impl.cc
src/path_resolver.cc
src/sha256.cc
)

if(MODEL_PACKAGE_BUILD_SHARED)
Expand Down Expand Up @@ -91,6 +96,45 @@ install(TARGETS model_package
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES include/model_package_api.h
install(FILES include/model_package_api.h include/model_package.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# ─────────────────────────────────────────────────────────────────────────────
# Tests
# ─────────────────────────────────────────────────────────────────────────────

if(MODEL_PACKAGE_BUILD_TESTS)
enable_testing()
add_executable(test_inspection tests/test_inspection.cc)
target_link_libraries(test_inspection PRIVATE model_package nlohmann_json::nlohmann_json)
target_include_directories(test_inspection PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_test(NAME inspection COMMAND test_inspection)

add_executable(test_asset_hashing tests/test_asset_hashing.cc)
target_link_libraries(test_asset_hashing PRIVATE model_package nlohmann_json::nlohmann_json)
target_include_directories(test_asset_hashing PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_test(NAME asset_hashing COMMAND test_asset_hashing)

add_executable(test_authoring tests/test_authoring.cc)
target_link_libraries(test_authoring PRIVATE model_package nlohmann_json::nlohmann_json)
target_include_directories(test_authoring PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_test(NAME authoring COMMAND test_authoring)

add_executable(test_commit tests/test_commit.cc)
target_link_libraries(test_commit PRIVATE model_package nlohmann_json::nlohmann_json)
target_include_directories(test_commit PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_test(NAME commit COMMAND test_commit)
endif()
Loading
Loading