Skip to content

artifacts/artifact_types.hpp

Namespaces

Name
sgns
sgns::sgprocessing
Artifact and manifest binary serialization.

Classes

Name
struct sgns::sgprocessing::Artifact

Types

Name
enum class uint8_t TerminalState

Functions

Name
void ComputeArtifactIdentity(Artifact & artifact, const uint8_t * rawBytes, size_t byteCount)
bool AddChunkHash(Artifact & artifact, const uint8_t hash[SHA256_HASH_SIZE])

Attributes

Name
constexpr size_t SHA256_HASH_SIZE
SHA-256 digest size in bytes.
constexpr size_t MAX_RESOURCE_NAME
Max bytes for resource/pass/binding name strings (D-06)
constexpr size_t MAX_MEDIA_TYPE
Max bytes for media type string (D-06)

Types Documentation

enum TerminalState

Enumerator Value Description
Success 0 Normal completion — all outputs valid.
Cancelled 1 Cancellation token triggered (07 D-01/D-05)
Timeout 2 Deadline expired (07 D-02/D-09)
BudgetExceeded 3 Output byte budget exceeded (07 D-08/EXEC-03)
Error 4 All other failures (D-15: no error string in manifest)

Terminal execution outcome for the manifest (D-15). Explicit uint8_t underlying type — maps directly to a single byte in the binary serialized manifest layout.

Functions Documentation

function ComputeArtifactIdentity

inline void ComputeArtifactIdentity(
    Artifact & artifact,
    const uint8_t * rawBytes,
    size_t byteCount
)

Compute artifact identity from raw bytes (D-01, D-03). Delegates to sgprocmanagersha::sha256 for the actual hash. Fills both contentHash and artifactId in-place.

function AddChunkHash

inline bool AddChunkHash(
    Artifact & artifact,
    const uint8_t hash[SHA256_HASH_SIZE]
)

Return: true on success, false if chunkHashCount >= 1024 (overflow guard).

Add a chunk hash to the artifact's chunk hash list (D-08).

Attributes Documentation

variable SHA256_HASH_SIZE

static constexpr size_t SHA256_HASH_SIZE = 32;

SHA-256 digest size in bytes.

variable MAX_RESOURCE_NAME

static constexpr size_t MAX_RESOURCE_NAME = 256;

Max bytes for resource/pass/binding name strings (D-06)

variable MAX_MEDIA_TYPE

static constexpr size_t MAX_MEDIA_TYPE = 128;

Max bytes for media type string (D-06)

Source code

#ifndef SGPROCMGR_ARTIFACT_TYPES_HPP
#define SGPROCMGR_ARTIFACT_TYPES_HPP

#include <cstdint>
#include <cstring>
#include "util/sha256.hpp"

namespace sgns::sgprocessing
{

    // Fixed-size constants shared between Artifact and ExecutionManifest.
    static constexpr size_t SHA256_HASH_SIZE  = 32;   
    static constexpr size_t MAX_RESOURCE_NAME = 256;  
    static constexpr size_t MAX_MEDIA_TYPE    = 128;  

    enum class TerminalState : uint8_t
    {
        Success        = 0,  
        Cancelled      = 1,  
        Timeout        = 2,  
        BudgetExceeded = 3,  
        Error          = 4   
    };

    struct Artifact
    {
        // ── Artifact identity (ARTF-01) ────────────────────────────────

        char    resourceName[MAX_RESOURCE_NAME];    
        uint8_t artifactId[SHA256_HASH_SIZE];       
        char    passId[MAX_RESOURCE_NAME];          
        char    outputBinding[MAX_RESOURCE_NAME];   

        // ── Artifact format metadata (ARTF-02) ─────────────────────────

        char     dataType[64];   
        char     format[64];     
        uint32_t width  = 0;     
        uint32_t height = 0;     
        uint32_t depth  = 0;     
        uint64_t byteSize = 0;   
        char     mediaType[MAX_MEDIA_TYPE];  

        // ── Artifact hashes (ARTF-03, D-07, D-08, D-09) ───────────────

        uint8_t  contentHash[SHA256_HASH_SIZE];              
        uint32_t chunkHashCount = 0;                          
        uint8_t  chunkHashes[1024][SHA256_HASH_SIZE] = {};   
    };

    // ── Free-standing helpers (namespace scope, inline — avoid header bloat) ──

    inline void ComputeArtifactIdentity( Artifact &artifact, const uint8_t *rawBytes, size_t byteCount )
    {
        auto hash = sgns::sgprocmanagersha::sha256( rawBytes, byteCount );
        std::memcpy( artifact.contentHash, hash.data(), SHA256_HASH_SIZE );
        std::memcpy( artifact.artifactId, hash.data(), SHA256_HASH_SIZE );
    }

    inline bool AddChunkHash( Artifact &artifact, const uint8_t hash[SHA256_HASH_SIZE] )
    {
        if ( artifact.chunkHashCount >= 1024 )
        {
            return false;
        }
        std::memcpy( artifact.chunkHashes[artifact.chunkHashCount], hash, SHA256_HASH_SIZE );
        ++artifact.chunkHashCount;
        return true;
    }

}  // namespace sgns::sgprocessing

#endif  // SGPROCMGR_ARTIFACT_TYPES_HPP

Updated on 2026-09-17 at 06:29:15 +0000