/* Copyright (c) 2026 Juhapekka Piiroinen * All Rights Reserved. * AmoosedWeb project: https://amoosed.com * * DESIGN DRAFT ONLY. No amwc1_ binary exports these declarations. * This header is not installed or a compatibility baseline. */ #ifndef AMOOSEDWEB_COMPILER1_DRAFT_H #define AMOOSEDWEB_COMPILER1_DRAFT_H #include #if defined(_WIN32) # define AMWC1_CALL __cdecl # if defined(AMWC1_C_BUILD) # define AMWC1_API __declspec(dllexport) # else # define AMWC1_API __declspec(dllimport) # endif #else # define AMWC1_CALL # define AMWC1_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif #define AMWC1_ABI_MINOR 0u #define AMWC1_CAP_BUILD_SITE UINT64_C(0x0001) #define AMWC1_CAP_VERIFY_SITE UINT64_C(0x0002) #define AMWC1_CAP_EXTERNAL_INDEX UINT64_C(0x0004) #define AMWC1_CAP_MEMBER_CONTENT UINT64_C(0x0008) #define AMWC1_CAP_OPERATION_CANCEL UINT64_C(0x0010) #define AMWC1_CAP_BUILD_PROGRESS UINT64_C(0x0020) #define AMWC1_BUILD_SITE_VERIFIED 1u #define AMWC1_BUILD_CREDENTIALS_PUBLISHED 2u #define AMWC1_BUILD_SITE_STAGED 3u /* Provisional compiler-specific status numbers. Unknown nonzero values fail. */ #define AMWC1_STATUS_OK 0 #define AMWC1_STATUS_INVALID_ARGUMENT 1 #define AMWC1_STATUS_INVALID_STATE 2 #define AMWC1_STATUS_BAD_FORMAT 3 #define AMWC1_STATUS_AUTHENTICATION_FAILED 4 #define AMWC1_STATUS_VERIFICATION_FAILED 5 #define AMWC1_STATUS_INPUT_ERROR 6 #define AMWC1_STATUS_OUTPUT_ERROR 7 #define AMWC1_STATUS_ALREADY_EXISTS 8 #define AMWC1_STATUS_UNSUPPORTED 9 #define AMWC1_STATUS_CANCELLED 10 #define AMWC1_STATUS_INTERNAL_ERROR 11 typedef struct amwc1_operation amwc1_operation; /* Proposal: build-thread notification, configured before dispatch. Context * remains caller-owned until the build returns. A callback may cancel its * operation but must not release it or re-enter a build with it. */ typedef void (AMWC1_CALL *amwc1_build_progress)(uint32_t phase, void* context); /* The major is encoded in the symbol name. On failure outputs are zero. * Capability bits report compiled support, not project configuration. */ AMWC1_API int32_t AMWC1_CALL amwc1_query( uint32_t* out_minor, uint64_t* out_capabilities); /* Create before dispatching synchronous work. A second thread may cancel; * release only after the worker returns. Each operation is single-use. */ AMWC1_API int32_t AMWC1_CALL amwc1_operation_prepare(amwc1_operation** out); AMWC1_API int32_t AMWC1_CALL amwc1_operation_set_build_progress( amwc1_operation* operation, amwc1_build_progress callback, void* context); AMWC1_API void AMWC1_CALL amwc1_operation_cancel(amwc1_operation* operation); AMWC1_API void AMWC1_CALL amwc1_operation_release(amwc1_operation* operation); /* All paths are absolute, strict UTF-8, length-delimited, and caller-owned. * Paths and key buffers remain valid until the synchronous call returns. * The project contains authored site/, app/, document.json and bundle.json. * The runtime directory contains a verified matching site-owned runtime. * The site destination must not exist. Credentials for an external-index * edition go only to a distinct private destination that must not exist. * A member or index key is either NULL/zero or exactly 32 raw bytes. * Build stages output and publishes only after its site verification passes. * On failure/cancellation it removes its own staging and publishes neither * the site nor credentials. Never log key bytes or protected content. */ AMWC1_API int32_t AMWC1_CALL amwc1_build_site( amwc1_operation* operation, const char* project_root_utf8, uint64_t project_root_length, const char* runtime_root_utf8, uint64_t runtime_root_length, const char* site_output_utf8, uint64_t site_output_length, const char* private_output_utf8, uint64_t private_output_length, const uint8_t* member_key, uint64_t member_key_length, const uint8_t* index_key, uint64_t index_key_length, char* error, uint64_t error_capacity); /* Verify every indexed resource in a local site. For an external index, * credential contains AMWKEY1 or packed ICO bytes, not a path. An absent * credential or member key is NULL/zero. The verifier never writes to SITE. * On failure *out_resources is zero; on success it reports the number of * verified indexed resources. A successful result says only that the supplied * local bytes and keys agree; publisher identity and remote host behavior are * separate checks. */ AMWC1_API int32_t AMWC1_CALL amwc1_verify_site( amwc1_operation* operation, const char* site_root_utf8, uint64_t site_root_length, const uint8_t* credential, uint64_t credential_length, const uint8_t* member_key, uint64_t member_key_length, uint64_t* out_resources, char* error, uint64_t error_capacity); #ifdef __cplusplus } #endif #endif