Architecture and dependency direction
/agent-evolution is the only management interface.
What to implement
A complete integration normally includes:- Convert the evolvable capability into an immutable, validated, declarative Artifact.
- Implement
EvolutionTargetProviderand declare the Target’s risk level and supported stages. - Resolve and pin the Capability Execution Plan at the beginning of every domain Execution.
- Write a dedicated Evolution Outbox record inside the business transaction.
- Ingest Learning Events asynchronously through Managed Queue.
- Report Shadow and Canary runtime observations.
- Implement installation, activation, and rollback without directly modifying the Active Pointer.
1. Design an Evolution Target
A Target should represent one decision capability that can be versioned, evaluated, and rolled back independently. Do not define the entire plugin as one Target, and do not create a Target for every business record. Common boundaries include:
The Target’s
capabilities must reflect the real implementation. For example, a Target that only collects events must set Candidate, Replay, and release capabilities to false. A Replay-only Target must not expose releaseProvider.
2. Implement the Provider
Import stable contracts from@xpert-ai/contracts and the Provider decorator from @xpert-ai/plugin-sdk:
candidateForm uses i18n text. The platform uses this descriptor to generate a domain-neutral Change Set form without interpreting the values.
Provider responsibilities by stage
3. Design an immutable Artifact
Store Candidate Artifacts in a separate version store, not in production business tables. A recommended manifest contains:EvolutionArtifactRef:
- The same input produces the same
buildInputsHash. - Artifact content maps one-to-one to its hash and cannot be overwritten after release.
- The URI must not contain a temporary file path or state local to the current Pod.
- Provider and dependency versions must be recorded in the Candidate and Capability Version.
- Any modification to the original Candidate creates a new Candidate.
4. Register the Provider
Add the Provider to the server-side plugin module’sproviders. Xpert discovers it through @EvolutionTargetProviderStrategy() metadata:
5. Resolve and pin the execution version closure
At the beginning of a domain Execution, obtain the Evolution Runtime from the runtime capability registry:subjectKey is a stable domain subject identifier, such as a Case ID, order ID, or document ID. Evolution Core only uses it for deterministic assignment and audit; it does not understand its business semantics.
Persist the complete execution plan, or at least:
bundleIdandbundleHash- Each Target’s
versionId, Artifact Hash, and Channel deploymentIdand selection reason- Shadow Bundle and Shadow Assignment
manualTestOverrideId, when present
6. Execute Production, Shadow, and Canary at runtime
Readassignments to determine the primary execution version:
production: Use the current production version.canary: The subject was deterministically assigned to the Candidate, so Candidate output may become the primary result.manual_test_override: A non-production administrator created a one-time Candidate assignment. It still executes as Canary and carries an audit marker.
shadowAssignments, run the Shadow Candidate with the same input, but always:
- Discard Candidate business output and side effects.
- Never write to production business tables.
- Record Production and Candidate metrics separately.
- Associate both executions with the same
executionIdandsubjectKey.
deploymentId + subjectKey.
7. Capture Learning Events through an Outbox
A Learning Event must originate from a committed business fact. Use this flow:targetId, scope, capability version bundle, and subject reference. predictionSummary and finalOutcomeSummary should be presentable structured summaries. Do not display an arbitrary object by applying JSON.stringify() to it.
8. Deliver events through Managed Queue
Plugin background tasks must use the platform Managed Queue. Do not create a plugin-private BullMQ or Redis connection. Include tenant, organization, and a stable Job ID when enqueueing:deliver() should read the Outbox within the same tenant and organization scope, call ingestLearningEvent(), and mark the record as delivered only after success. Repeated execution must be safely deduplicated using the event idempotencyKey.
9. Report runtime observations
After a primary or Shadow execution completes, report aggregatable runtime metrics:10. Implement release operations
install(), activate(), and rollback() must be idempotent and return a ReleaseProviderReceipt.
Recommended semantics:
install(): Validate the Artifact hash and Schema, write to immutable plugin version storage, and make the version loadable.activate(): Confirm that the version is installed and allow the domain runtime to read it; do not switch the platform Active Pointer directly.rollback(): Restore Provider-side availability of the previous stable version; do not delete the failed version or audit information.
11. SDK version compatibility
In the repository source, Evolution contracts are exported by@xpert-ai/contracts, while Provider decorators and runtime capabilities are exported by @xpert-ai/plugin-sdk. If the published packages used by your plugin do not yet contain these exports:
- Create one clearly named compatibility file, such as
evolution-sdk.compat.ts. - Define only the minimum types and tokens currently required in that file.
- Make all other business code import from the compatibility file; do not scatter duplicate definitions across the plugin.
- Annotate the official package version that will replace the compatibility layer.
- After upgrading, change the compatibility file to official re-exports, then delete the mocked types.
12. Security and governance checklist
Before release, confirm that:- Every query and unique key includes the tenant, and an organization-scoped Target also includes the organization.
- The Target’s declared
supportedScopesmatch its real access boundary. - Confidential Learning Events are redacted before ingestion.
- Candidate Builder accepts only declared fields and rejects unknown keys, path traversal, and executable code.
- Artifact Hash, Schema Version, and Provider Version are validated.
- Replay and Shadow produce no business side effects.
- The Agent has no tools for approval, release, traffic expansion, production activation, or proactive rollback.
- Every background task uses Managed Queue and its handler does not depend on HTTP Request Context.
- User-visible text uses i18n, and the server returns stable error codes or localizable messages.
13. Test checklist
Cover at least the following tests.Provider contract
- The same input produces the same Artifact Hash and
buildInputsHash. - Invalid Change Sets, Schemas, dependencies, and hashes are rejected.
install(),activate(), androllback()are idempotent.- Undeclared capabilities do not appear in Target actions.
Runtime
- The version closure is resolved only once in the same Execution.
- Canary assignment is stable for the same
deploymentId + subjectKey. - Shadow output does not change production results or business tables.
- A one-time administrator test assignment is consumed once and carries an audit marker in the plan.
- After rollback, new requests use the previous stable version while historical executions still reference their original versions.
Event pipeline
- A rolled-back business transaction leaves no Outbox event.
- Delivery can be retried after a Dispatcher crash.
- Duplicate delivery does not create duplicate Learning Events.
- Cross-tenant and cross-organization events are rejected.
- Confidential but unredacted events are rejected.
Release governance
- A Candidate cannot directly affect Production.
- A Release Package cannot be created before evaluation and approval pass.
- Installing a version does not change the Active Pointer.
- Shadow, Canary, and production gates use the frozen policy.
- A severe error triggers pause, and a CAS conflict prevents activation or rollback.
ORG-001, CASE-001, and AUTO-MOTOR-001. Do not commit real customer or project names to the repository.
14. Local deployment and acceptance
After completing build and tests according to the plugin development workflow, refresh the plugin through the platform’s local plugin deployment flow:- The plugin Target can be synchronized in Agent Evolution.
- A business review creates a real Learning Event through Outbox and Managed Queue.
- Candidate construction does not modify production business tables or the production Artifact.
- Golden Replay compares Production and Candidate against the same Snapshot.
- The production Active Pointer remains unchanged after installation.
- Shadow has no business side effects, and Canary uses the runtime assignment result.
- New requests resolve to the new Production Capability Version only after all gates and human governance have completed.