ADR-0233: Native function catalogue and explicit iteration
Status
Proposed
Context
#1176 requires reusable transformations without a published wrapper Flow for every simple operation, and one-to-many JSON Artifact expansion before final output publication. The maintainer confirms these surfaces are unreleased and does not require compatibility adapters or migrations.
Decision
FunctionKind owns an immutable versioned definition schema and a product execution mechanism. Only native execution is implemented. TransformationFunction references an exact kind and registered native implementation. Its immutable versions retain kind UID/contract and native descriptor evidence. Publication and admission pin function identity/version/digest; execution rechecks current authorization, enablement and implementation evidence. New versions do not rewrite earlier ones.
Agentstration.Functions.Abstractions is an independent, packageable .NET contract library with no product, Flow, Web, persistence or dependency-injection dependency. Native functions expose an exact descriptor, a single JSON business input/output and cancellation. A technical invocation identity can be injected for replay-safe Artifact identities. Builtins register explicitly. Unknown or duplicate implementations fail. Custom DLL loading, scripts and AEP engines are deferred. Future DLLs may contribute native functions, not new kinds; kind execution remains product-owned.
The transform step selects a function or maps JSON. It does not own a process region. Source composition entries select a Function or a published Flow. For functions whose object input declares value, the incoming value supplies that field and saved literal parameters supply the remaining fields; callers cannot override value. Other single-input functions receive the incoming value directly. Calls compile into ordinary governed internal Tool steps, preserving existing authority/Worker execution, errors, cancellation and diagnostics. No author-managed wrapper Flow is created. Function value structure is checked at composition; actual bounds and schemas remain enforced at invocation.
foreach owns generic iteration; foreachArtifacts replaces artifactTransform and owns Artifact access and capture. Both use ADR-0215 process/return regions and ordinary implicit child runs, bounded concurrency, ordered results, cancellation and provenance. Generic iteration passes one array element; optional explicit partitioning belongs to foreach. Empty generic iteration returns an empty array. Existing internal Artifact processing capabilities remain scoped to their exact input/attempt.
artifact.explode explicitly selects array items or object values with RFC 6901 JSON Pointer. It consumes an exact Artifact manifest, or an explicit {content: ...} value inside a content-processing branch, and returns an inline manifest. It is distinct from selecting a JSON value with json.select. There is no additional one/many capture switch. Object keys are sorted ordinally and retained as provenance; duplicate keys, missing paths, wrong types, empty publication sets, limits and mismatching item schemas fail explicitly.
At a Knowledge binding, only that binding's inputs are transformed. At postAggregate, all gathered projection results are transformed. Both use the same simple Function/Flow editor and mixed ordered sequence. A retained acquisition is already stored before its Knowledge transformations. Direct acquisition and its function/process results remain in the existing transient handoff; only final Snapshot publication creates retained output. A foreachArtifacts process may return an inline manifest: all child contents are validated and prepared before registration. Result manifests flatten the prepared children, with exact input and invocation lineage. The current Knowledge publication bound remains 100 Artifacts and 64 KiB per document; expansion does not lift acquisition or transfer limits.
Consequences
Adding a compiled native function requires a descriptor, implementation and registration, without changes to execution or Designer dispatch. Functions and kinds use existing scoped resources, generic Discover/Use grants, APIs and Bootstrap handlers for user declarations. The standard native kind and five functions are provisioned automatically at Instance scope by the existing platform startup/workspace provisioning path. They use ResourceGovernance.Core("functions.native"), builtIn provenance and the established builtin annotation. Reconciliation preserves identities and immutable versions; reserved user-owned names are never adopted. Tenant Discover/Use grants include descendant Workspaces. These standard resources require no declarative file profile, including with file Bootstrap disabled. Initialization target 8 seeds the initial native catalogue and the current Knowledge contracts. All builtin resource and implementation versions introduced by this feature start at 1.0.0. Descriptions are resource presentation metadata and do not change pinned implementation contracts. The Console identifies builtin definitions and prevents manual mutation. Resource UI metadata remains separate from immutable implementation contracts.
This decision supersedes ADR-0213's step name and ADR-0215's placement of generic partition processing inside transform. Their scoped access, direct lifecycle and causal execution invariants remain in force. No distributed transaction is promised: storage/catalog failure during finalization can leave retained orphan outputs under existing cleanup rules. An incomplete or failed projection does not activate a Snapshot.
The deferred reusable browser scenario is #1177, gated on explicit implemented-UX validation and implementation merge. Existing regressions, deterministic functional lanes and implementation smoke checks remain part of #1176.
The standard DataSource orchestration accepts any JSON result after transformation, including arrays and scalars selected by json.select. Its initial 1.0.0 contract carries unconstrained JSON boundaries for the acquired business response and transformation results, while the acquisition request remains an object envelope. The accepted dataset pins the Operation output schema separately, so acquisition validates raw provider output before transformation and final storage validates the transformed result. Dynamic native outputs and free-form native parameters are checked against their function contracts at runtime. A selected JSON array remains one stored JSON content; this does not add multi-Artifact DataSource acquisition. Composition failures expose a safe reason code in ProblemDetails and the Console.
Schema-valued native arguments declare x-agentstration-schema-binding on their input-schema property. artifact.explode 1.0.0 uses an optional SchemaBinding for itemSchema. Source save and Flow publication resolve these literal bindings through the existing Schema resolver, with owner namespace, consumer Use authorization, supported JSON Schema dialect and validator limits. Resolution belongs to the platform, not the standalone native SDK. Ordinary Transform stores declarations outside its executable mapping. Accepted per-call snapshots are separate from function resource versions and caller-authored arguments; raw resource saves cannot inject accepted evidence. Runtime uses server-owned snapshots, supplies resolved inline definitions to handlers, and preserves shared Schema evidence on validated children without registry lookup. No binding means no business item schema, with technical validation unchanged. This feature is unreleased and the installation will be reseeded: obsolete intermediate contracts and compatibility implementations are not retained. Normal immutable publication rules still apply after seeding. The existing deferred UX child #1177 also covers optional/inline/shared function schema selection and publication.