Meshpocalypse Semantic
    Preparing search index...

    Function allocateSubBudget

    • Allocate a child sub-budget from a parent budget.

      Creates a new TokenBudget linked to the parent via mesh:allocates / mesh:parentBudget. Emits a PROV-O allocation activity (prov:wasDerivedFrom + prov:Activity) capturing the full allocation provenance chain for audit.

      The SPARQL UPDATE is atomic: if the parent budget lacks sufficient remaining tokens (maxTokens - spentTokens < maxTokens requested) the UPDATE is a no-op and BudgetInsufficientError is thrown.

      Parameters

      • parentBudgetId: string

        The budget to allocate from (IRI key — must pass SAFE_IRI_KEY_RE)

      • taskId: string

        Task identifier for the child budget (must pass SAFE_IRI_KEY_RE)

      • maxTokens: number

        Maximum tokens for the child budget (positive integer)

      • allocatedByAgentId: string

        The agent performing the allocation (must pass SAFE_IRI_KEY_RE)

      • config: AiGatewayConfig

        Gateway configuration

      Returns Promise<string>

      The new child budget ID (IRI key string)

      If parent has insufficient remaining tokens

      If the parent budget does not exist

      If any input fails IRI or integer validation