3.0 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| core/operation-context-registry | Implement OperationContext, OperationRegistry, and OperationSpec | completed |
|
moderate | medium | component | implementation |
Description
Implement the call protocol's core types: OperationContext, OperationSpec, OperationRegistry, ResponseEnvelope, and CallError in alknet_core::call, per call-protocol.md and ADR-033.
This is the foundation for the OperationEnv composition mechanism. Phase 1 ships with local dispatch only — the registry maps operation paths to handler functions. irpc and remote dispatch are contracted in the spec but not built yet.
Key additions:
OperationSpecstruct: name, namespace, op_type (Query/Mutation/Subscription), input_schema, output_schema, access_controlOperationTypeenum: Query, Mutation, SubscriptionAccessControlstruct: required_scopes, required_scopes_any, resource_type, resource_actionOperationContextstruct: request_id, parent_request_id, identity, metadata, env (OperationEnv), trustedOperationRegistrystruct: maps paths to(OperationSpec, handler)pairs, supports registration and lookupResponseEnvelopestruct: request_id, result (Result<Value, CallError>)CallErrorstruct: code, message, retryable- Handler signature:
fn(input: Value, context: OperationContext) -> ResponseEnvelope(or async)
Important: OperationEnv is defined here but only with local dispatch in Phase 1. The env field on OperationContext allows handlers to compose operations by calling context.env.invoke(namespace, op, input). In Phase 1, this always resolves to a direct function call through the registry.
Acceptance Criteria
OperationSpec,OperationType,AccessControldefined incrates/alknet-core/src/call/spec.rsOperationContextdefined incrates/alknet-core/src/call/context.rswith all fields per call-protocol.mdResponseEnvelopeandCallErrordefined incrates/alknet-core/src/call/response.rsOperationRegistrydefined incrates/alknet-core/src/call/registry.rswithregister(),lookup(),invoke()methodsOperationEnvdefined withlocal()constructor andinvoke(namespace, op, input)method for local dispatch only- Handler signature is clear (sync or async, Value in, ResponseEnvelope out)
- Namespace-based routing:
/head/auth/verify→ namespace "auth", op "verify" - Unit tests: register and invoke an operation, verify ResponseEnvelope result
- Unit tests: AccessControl checks against Identity.scopes and Identity.resources
- Module re-exported from
crates/alknet-core/src/lib.rs
References
- docs/architecture/call-protocol.md — OperationSpec, OperationRegistry, OperationContext, ResponseEnvelope
- docs/architecture/decisions/033-operationenv-irpc-call-protocol.md — ADR-033, OperationEnv composition model
- docs/architecture/services.md — OperationContext fields
Notes
To be filled by implementation agent
Summary
To be filled on completion