Expand description
Code-mode wiring: bridges [code_mode] config blocks into pmcp-code-mode’s
validation pipeline + HMAC token machinery, with policy / executor /
validation types re-exported verbatim (NO duplicate impl per RESEARCH
§“Anti-Patterns” #2).
§R1 split (per CODE_MODE_API_NOTES.md Section 6)
validation_pipeline_from_configbuilds aValidationPipelinefrom a parsedcrate::config::ServerConfig. This is the entry point Shape A / Shape C consumers reach for — no per-server Rust glue needed.code_mode_tools_from_executorcomposes a caller-suppliedCodeExecutor(Plan 08 wires this intopmcp::ServerBuilderviacode_mode_from_config).register_code_mode_toolsis the tolerant builder-extension entry point: a no-op when[code_mode]is absent, an R9 enforcement gate when present.
§Security invariants (R6 + R9)
- R6 — toolkit-owned secret type.
token_secretresolution flows throughcrate::secrets::SecretValue(feature-independent) and converts toTokenSecretviaFromonly at the HMAC boundary. This keeps--no-default-featuresstable. - R9 — inline-secret rejection. A
[code_mode] token_secret = "raw"literal is REJECTED at validation/resolve time unless the operator explicitly setsallow_inline_token_secret_for_dev = true. Default-deny; warnings are not protection.
Structs§
- Approval
Token - Approval token that authorizes code execution.
- Authorization
Decision - Authorization decision from policy evaluation.
- AvpClient
- AVP client for Code Mode policy evaluation.
- AvpConfig
- Configuration for the AVP client.
- AvpPolicy
Evaluator - AVP-based policy evaluator implementing the
PolicyEvaluatortrait. - Code
Mode Config - Configuration for Code Mode.
- Execution
Config - Configuration for execution.
- Hmac
Token Generator - HMAC-based token generator for MVP.
- Http
Code Executor - Low-level HTTP executor bridging the toolkit’s outbound
HttpAuthProviderto pmcp-code-mode’sHttpExecutortrait. - JsCode
Executor - Adapter bridging [
HttpExecutor] toCodeExecutorfor JavaScript/OpenAPI servers (Pattern B: JS+HTTP). - Noop
Policy Evaluator - Always-allow policy evaluator for testing and local development ONLY.
- SqlCode
Executor CodeExecutoradapter bridging the toolkit’s single-methodSqlConnectorto the code-modevalidate_code/execute_codeflow.- Token
Secret - Zeroizing wrapper for HMAC token secrets.
- Validation
Context - Context for validation (user, session, schema).
- Validation
Pipeline - The validation pipeline that orchestrates all validation stages.
Enums§
- Execution
Error - Errors that can occur during execution.
- Validation
Flavor - Which validation surface the generalized code-mode wiring drives (OAPI-10 /
D-02 / Gemini review: a compile-time enum, NOT a stringly-typed
&str, so a flavor typo is impossible).
Traits§
- Code
Executor - High-level trait for executing validated code.
- Http
Executor - Trait for making HTTP requests during execution.
- Policy
Evaluator - Trait for policy evaluation backends.
- Token
Generator - Trait for token generators.
Functions§
- assemble_
code_ mode_ prompt - TKIT-10: assemble the code-mode bootstrap prompt body from a connector’s
SqlConnector::schema_text+ curated[[database.tables]]descriptions. - assemble_
code_ mode_ prompt_ with_ schema - File-based counterpart to
assemble_code_mode_prompt— assemble the code-mode prompt body from a--schemafile’s text WITHOUT any live connector introspection (Plan 85-02 Task 3 / D-04 / D-05). - build_
code_ mode_ prompt - Alias for
assemble_code_mode_promptsatisfying CONN-04’s literal naming. - canonicalize_
code - Canonicalize code for consistent hashing.
- code_
mode_ http_ tools_ from_ executor - Register
validate_code+execute_codeonbuilderfor the OpenAPI per-request Code-Mode path (Plan 90-10 / OAPI-03 / OAPI-05). - code_
mode_ tools_ from_ executor - Register
validate_code+execute_codeonbuilder, driven by the[code_mode]block, a caller-suppliedCodeExecutor, and aValidationFlavor(OAPI-10 / D-02). - compute_
context_ hash - Compute a context hash from schema and permissions.
- hash_
code - Compute the SHA-256 hash of canonicalized code.
- register_
code_ mode_ tools - Tolerant builder-extension entry point for
[code_mode]config — the CONNECTORLESS, validation-only / no-tool path. - request_
executor_ from_ extra - Derive a per-request
HttpCodeExecutorfrom apmcp::RequestHandlerExtraby threading the captured inbound MCP client token (Plan 90-10 / OAPI-03 / OAPI-05). - validation_
pipeline_ from_ config - Build a
ValidationPipelinefrom aServerConfig’s[code_mode]block.