Agent Interface Contract¶
Assertions¶
AIF-001 - One immutable registry owns every agent operation¶
Contract: Every MCP transport MUST derive tool names, schemas, effects, and handlers from one ordered immutable registry and invoke handlers through one validating executor. Every registered tool MUST declare a known read, write, or destructive effect and use only the supported JSON Schema subset. HTTP adapters MUST NOT maintain a second operation list or bypass schema validation and failure classification.
Evidence:
test_registry_is_ordered_exact_and_deeply_immutable-tests/unit/test_tool_registry.py::test_registry_is_ordered_exact_and_deeply_immutabletest_registry_rejects_duplicates_bad_effects_and_unsupported_schemas-tests/unit/test_tool_registry.py::test_registry_rejects_duplicates_bad_effects_and_unsupported_schemastest_registry_builds_every_tool_with_effects_matching_their_names-tests/unit/test_tool_registry.py::test_registry_builds_every_tool_with_effects_matching_their_namestest_effect_is_centralized-tests/unit/test_tool_registry.py::test_effect_is_centralizedtest_executor_validates_and_preserves_domain_errors-tests/unit/test_tool_registry.py::test_executor_validates_and_preserves_domain_errorstest_lifecycle_and_transport_contract-tests/integration/test_mcp_server.py::McpHttpTest::test_lifecycle_and_transport_contracttest_owner_crud_refresh_restart_and_revoke-tests/oauth/e2e/test_oauth_flow.py::test_owner_crud_refresh_restart_and_revoke
AIF-002 - MCP follows its advertised HTTP and stdio lifecycles¶
Contract: mcp serve MUST expose MCP Streamable HTTP on loopback /mcp by
default. mcp stdio MUST exchange one JSON-RPC message per line over
stdin/stdout, write no non-protocol content to stdout, open no MCP, health, or
readiness listener, require no bearer credential for those absent interfaces, and stop cleanly at stdin EOF. Both transports MUST negotiate only supported protocol versions,
implement initialize/initialized, tools/list, and tools/call, and return both
text content and structuredContent. The server MUST advertise both transports
through CLI capabilities and MUST NOT require a Markdown workspace.
Evidence:
test_lifecycle_and_transport_contract-tests/integration/test_mcp_server.py::McpHttpTest::test_lifecycle_and_transport_contracttest_lifecycle_tools_live_call_and_protocol_errors-tests/integration/test_mcp_stdio.py::McpStdioCliTest::test_lifecycle_tools_live_call_and_protocol_errorstest_stdio_has_no_http_listener_or_interface_bearer_options-tests/integration/test_mcp_stdio.py::McpStdioCliTest::test_stdio_has_no_http_listener_or_interface_bearer_optionstest_serve_remains_the_network_listener_mode-tests/integration/test_mcp_stdio.py::McpStdioCliTest::test_serve_remains_the_network_listener_modetest_capabilities_advertise_mcp-tests/integration/test_mcp_server.py::McpCliSafetyTest::test_capabilities_advertise_mcptest_stdio_process_reads_running_joplin-tests_live/test_mcp_stdio_live.py::LiveMcpStdioTest::test_stdio_process_reads_running_joplin
AIF-003 - MCP exposes complete Joplin object workflows¶
Contract: MCP MUST support validated note, notebook, tag, and resource
read/write workflows, relationship traversal, search, trash/restore for notes
and notebooks, and permanent deletion only where Joplin has no trash API.
Binary content MUST enter and leave as bounded base64 data, never a server-side
path. Explicit create operations MUST compare their normalized natural
identity before mutation, including matching trashed objects, and MUST return a
non-retryable *_ALREADY_EXISTS error with every existing ID and the matching
update tool rather than create or silently reuse a duplicate. Create preflight
and mutation MUST be serialized within one bridge process.
Evidence:
test_note_crud_metadata_tags_and_search-tests/integration/test_mcp_server.py::McpHttpTest::test_note_crud_metadata_tags_and_searchtest_notebook_crud_nesting_notes_trash_and_restore-tests/integration/test_mcp_server.py::McpHttpTest::test_notebook_crud_nesting_notes_trash_and_restoretest_tag_crud_listing_and_note_relations-tests/integration/test_mcp_server.py::McpHttpTest::test_tag_crud_listing_and_note_relationstest_resource_crud_content_and_note_relations-tests/integration/test_mcp_server.py::McpHttpTest::test_resource_crud_content_and_note_relationstest_create_note_from_html_and_with_binary_attachments-tests/integration/test_mcp_server.py::McpHttpTest::test_create_note_from_html_and_with_binary_attachmentstest_create_tools_reject_existing_object_identities-tests/integration/test_mcp_server.py::McpHttpTest::test_create_tools_reject_existing_object_identitiestest_notebook_title_resolves_only_one_root_destination-tests/integration/test_mcp_server.py::McpHttpTest::test_notebook_title_resolves_only_one_root_destinationtest_concurrent_note_create_allows_exactly_one_object-tests/integration/test_mcp_server.py::McpHttpTest::test_concurrent_note_create_allows_exactly_one_objecttest_create_rejects_matching_trashed_note_and_notebook-tests/integration/test_mcp_server.py::McpHttpTest::test_create_rejects_matching_trashed_note_and_notebooktest_02_explicit_creates_reject_existing_natural_identities-tests_live/test_mcp_live.py::LiveMcpTest::test_02_explicit_creates_reject_existing_natural_identities
AIF-004 - Invalid operations fail before side effects¶
Contract: Tool definitions and instances MUST pass the supported JSON Schema subset before handler execution. Unknown objects, invalid content, unsupported combinations, and Joplin failures MUST return structured stable domain errors rather than transport crashes or partial writes.
Evidence:
test_schema_definition_and_instance_validation-tests/unit/test_tool_registry.py::test_schema_definition_and_instance_validationtest_entity_and_content_validation_errors_are_structured-tests/integration/test_mcp_server.py::McpHttpTest::test_entity_and_content_validation_errors_are_structuredtest_schema_validation_precedes_side_effects-tests/integration/test_mcp_server.py::McpHttpTest::test_schema_validation_precedes_side_effects
AIF-005 - Joplin outages do not terminate the bridge¶
Contract: Binding the agent listener MUST NOT require Joplin availability. Each call MAY perform a bounded availability wait and retry reads. An outage MUST return a retryable structured tool error and later calls MUST recover. Writes MUST be sent once after preflight; ambiguous outcomes MUST be non-retryable and exposed for operator inspection.
Evidence:
test_joplin_outage_is_retryable_tool_error_and_server_recovers-tests/integration/test_mcp_server.py::McpHttpTest::test_joplin_outage_is_retryable_tool_error_and_server_recoverstest_executor_classifies_expected_failures-tests/unit/test_tool_registry.py::test_executor_classifies_expected_failures
AIF-008 - Public transports enforce bounded resource use¶
Contract: MCP MUST bound request size, decoded resource size, JSON nesting, active handlers, and stalled connections, and MUST reject an oversized request or resource before any side effect.
Evidence:
test_pre_auth_connection_count_is_bounded-tests/integration/test_mcp_server.py::McpHttpTest::test_pre_auth_connection_count_is_boundedtest_request_and_decoded_resource_sizes_are_bounded-tests/integration/test_mcp_server.py::McpHttpTest::test_request_and_decoded_resource_sizes_are_boundedtest_json_nesting_limit_is_independent_of_parser_recursion_behavior-tests/unit/test_json_safety.py::test_json_nesting_limit_is_independent_of_parser_recursion_behavior
AIF-009 - Standard GitHub OAuth shares one listener and tool executor¶
Contract: The standard package and native executable MUST include the
GitHub OAuth runtime. mcp serve --github-oauth MUST enable
/oauth/mcp and OAuth endpoints on the existing listener and port, preserving
legacy MCP authentication. OAuth tools MUST use the common registry,
dispatcher, executor and Joplin service with the same schemas, annotations and
structured results. Concurrent creates across all interfaces MUST retain the
existing duplicate prevention. The OAuth transport MUST remain stateless and
MUST NOT require a second service or listener.
Evidence:
test_owner_crud_refresh_restart_and_revoke-tests/oauth/e2e/test_oauth_flow.py::test_owner_crud_refresh_restart_and_revoketest_mixed_interface_create_race_and_credential_isolation-tests/oauth/e2e/test_oauth_flow.py::test_mixed_interface_create_race_and_credential_isolationtest_oauth_metadata_and_challenge_on_one_real_listener-tests/oauth/integration/test_socket_bounds.py::test_oauth_metadata_and_challenge_on_one_real_listenersmoke-standalone-make smoke-standalone
AIF-010 - OAuth rejection and execution remain bounded¶
Contract: OAuth MUST deny anonymous requests with a protected-resource
metadata challenge. One process MUST bound accepted sockets before headers,
incoming request deadlines, public flow bodies/rate, execution capacity and
state. Authentication and framing rejection MUST precede tool side effects.
Cancelling a request MUST NOT replay a mutation or release its execution slot
before the underlying work finishes. Late worker failures after cancellation
MUST NOT leak private exception details into asyncio logs. Temporary GitHub
identity and token-endpoint failures, including rate limits, MUST
fail closed with 503 and a safe Retry-After while legacy credentials remain
independent. Invalid grants MUST NOT be treated as a temporary GitHub outage.
Each established client MUST have its own token-endpoint budget, so anonymous
token requests or another client cannot block its refresh.
Evidence:
test_incomplete_request_deadline-tests/oauth/integration/test_socket_bounds.py::test_incomplete_request_deadlinetest_admission_includes_connections_without_headers-tests/oauth/integration/test_socket_bounds.py::test_admission_includes_connections_without_headerstest_ambiguous_http_framing_never_reaches_an_interface-tests/oauth/integration/test_socket_bounds.py::test_ambiguous_http_framing_never_reaches_an_interfacetest_request_cancellation_does_not_free_a_running_mutation_slot-tests/oauth/unit/test_execution.py::test_request_cancellation_does_not_free_a_running_mutation_slottest_cancelled_request_retrieves_late_worker_failure_without_logging_private_data-tests/oauth/unit/test_execution.py::test_cancelled_request_retrieves_late_worker_failure_without_logging_private_datatest_token_endpoint_outage_does_not_issue_or_replay_tokens-tests/oauth/e2e/test_oauth_security.py::test_token_endpoint_outage_does_not_issue_or_replay_tokenstest_github_outage_fails_closed_without_interrupting_legacy-tests/oauth/e2e/test_oauth_flow.py::test_github_outage_fails_closed_without_interrupting_legacytest_anonymous_token_flood_does_not_block_established_refresh-tests/oauth/e2e/test_oauth_security.py::test_anonymous_token_flood_does_not_block_established_refreshtest_established_clients_have_separate_token_budgets-tests/oauth/integration/test_provider_flow.py::test_established_clients_have_separate_token_budgets