GCAP-SPEC-FUNCTION-DESCRIPTOR-0001 implementation. Mirrors connector runtime pattern exactly. FunctionPlugin — trigger_events, handle(), descriptor(), knative_manifest() FunctionRegistry — trigger_index for event-driven routing FunctionRuntime — invoke() + dispatch() with Chronicle lineage governed_function decorator — SDK surface for function authors BillingProcessor — GSAP_CR_RECEIVED → billable event with Chronicle CID EchoFunction — dev/test API: /functions/ catalogue, invoke, dispatch, manifest, health 8 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
854 B
Python
26 lines
854 B
Python
"""EchoFunction — minimal governed function example."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from gsap_broker.functions.base import FunctionContext, FunctionPlugin, FunctionResult
|
|
|
|
|
|
class EchoFunction(FunctionPlugin):
|
|
function_id = "echo-function"
|
|
corpus_entry_cid = "sha256:" + "e" * 64
|
|
capability_mask = 1 # READ
|
|
trigger_events = ["CONNECTOR_INVOKED"]
|
|
accord_template = ""
|
|
gsap_required = False
|
|
chronicle_enabled = True
|
|
max_duration_seconds = 5
|
|
display_name = "Echo Function"
|
|
description = "Returns event data unchanged — used for integration testing."
|
|
version = "0.1.0"
|
|
|
|
async def handle(self, event: dict[str, Any], context: FunctionContext) -> FunctionResult:
|
|
return FunctionResult(success=True, data=event)
|
|
|
|
def health_check(self) -> bool:
|
|
return True
|