integration-automation-patterns 0.44.2__tar.gz → 0.45.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. {integration_automation_patterns-0.44.2/src/integration_automation_patterns.egg-info → integration_automation_patterns-0.45.0}/PKG-INFO +31 -1
  2. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/README.md +30 -0
  3. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/agentic-security-trends-2026.md +137 -118
  4. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-01.md +4 -2
  5. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-02.md +34 -33
  6. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-03.md +24 -17
  7. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-04.md +50 -5
  8. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-05.md +12 -5
  9. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-06.md +48 -30
  10. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-07.md +3 -3
  11. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-08.md +8 -2
  12. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-09.md +25 -17
  13. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-10.md +13 -6
  14. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-11.md +24 -17
  15. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/implementation-note-12.md +14 -6
  16. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/pyproject.toml +1 -1
  17. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/__init__.py +1 -1
  18. integration_automation_patterns-0.45.0/src/integration_automation_patterns/event_replay.py +278 -0
  19. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0/src/integration_automation_patterns.egg-info}/PKG-INFO +31 -1
  20. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns.egg-info/SOURCES.txt +1 -0
  21. integration_automation_patterns-0.45.0/tests/test_event_replay.py +288 -0
  22. integration_automation_patterns-0.45.0/tests/test_implementation_notes.py +95 -0
  23. integration_automation_patterns-0.44.2/src/integration_automation_patterns/event_replay.py +0 -215
  24. integration_automation_patterns-0.44.2/tests/test_event_replay.py +0 -122
  25. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/LICENSE +0 -0
  26. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/MANIFEST.in +0 -0
  27. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/FAILURE_CONTRACT.md +0 -0
  28. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/GOVERNED_SERVICE_DEMO.md +0 -0
  29. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/001-idempotency-key-as-event-id.md +0 -0
  30. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/001-idempotency-key-design.md +0 -0
  31. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/002-explicit-authority-model.md +0 -0
  32. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/002-explicit-field-authority-model.md +0 -0
  33. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/003-orchestration-vs-integration-boundaries.md +0 -0
  34. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/003-saga-choreography-vs-orchestration.md +0 -0
  35. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/ADR-0001-separate-integration-transport-from-workflow-state.md +0 -0
  36. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/adr/ADR-0002-make-observability-part-of-the-design.md +0 -0
  37. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/api-reference.md +0 -0
  38. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/architecture.md +0 -0
  39. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/docs/getting-started.md +0 -0
  40. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/01_event_envelope_retry.py +0 -0
  41. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/02_transactional_outbox.py +0 -0
  42. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/03_saga_compensation.py +0 -0
  43. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/04_crm_erp_sync_boundary.py +0 -0
  44. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/05_idempotent_crm_update.py +0 -0
  45. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/06_end_to_end_integration.py +0 -0
  46. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/07_cqrs_event_sourcing.py +0 -0
  47. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/08_approval_workflow.py +0 -0
  48. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/09_backpressure_retry.py +0 -0
  49. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/10_schema_evolution.py +0 -0
  50. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/11_process_manager.py +0 -0
  51. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/12_event_streaming_windows.py +0 -0
  52. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/13_distributed_cache_patterns.py +0 -0
  53. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/14_api_gateway_patterns.py +0 -0
  54. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/15_saga_orchestration_patterns.py +0 -0
  55. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/16_event_sourcing_cqrs.py +0 -0
  56. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/17_resilience_patterns.py +0 -0
  57. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/18_message_routing_patterns.py +0 -0
  58. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/19_workflow_orchestration_patterns.py +0 -0
  59. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/20_data_pipeline_patterns.py +0 -0
  60. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/21_api_gateway_patterns.py +0 -0
  61. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/22_event_sourcing_cqrs_patterns.py +0 -0
  62. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/23_service_mesh_resilience.py +0 -0
  63. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/24_distributed_tracing_patterns.py +0 -0
  64. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/25_schema_registry_patterns.py +0 -0
  65. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/26_graphql_patterns.py +0 -0
  66. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/27_event_driven_workflow_patterns.py +0 -0
  67. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/28_grpc_streaming_patterns.py +0 -0
  68. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/29_async_concurrent_patterns.py +0 -0
  69. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/30_message_broker_patterns.py +0 -0
  70. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/31_service_discovery_patterns.py +0 -0
  71. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/32_observability_patterns.py +0 -0
  72. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/33_data_pipeline_patterns.py +0 -0
  73. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/34_distributed_transaction_patterns.py +0 -0
  74. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/35_event_sourcing_advanced.py +0 -0
  75. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/36_workflow_state_machine.py +0 -0
  76. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/37_rate_limiting_patterns.py +0 -0
  77. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/38_reactive_streams_patterns.py +0 -0
  78. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/39_distributed_tracing_patterns.py +0 -0
  79. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/40_saga_choreography_patterns.py +0 -0
  80. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/41_api_versioning_patterns.py +0 -0
  81. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/42_mcp_security_patterns.py +0 -0
  82. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/43_agentic_security_auditor.py +0 -0
  83. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/failure_contract.py +0 -0
  84. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/governed_service_demo.py +0 -0
  85. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/examples/webhook_fastapi_example.py +0 -0
  86. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/setup.cfg +0 -0
  87. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/azure_servicebus_envelope.py +0 -0
  88. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/cdc_event.py +0 -0
  89. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/circuit_breaker.py +0 -0
  90. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/event_envelope.py +0 -0
  91. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/gcp_pubsub_envelope.py +0 -0
  92. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/http/__init__.py +0 -0
  93. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/http/fastapi_router.py +0 -0
  94. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/http/webhook_handler.py +0 -0
  95. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/kafka_envelope.py +0 -0
  96. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/mcp_server.py +0 -0
  97. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/outbox.py +0 -0
  98. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/py.typed +0 -0
  99. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/rabbitmq_envelope.py +0 -0
  100. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/rate_limiter.py +0 -0
  101. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/retry_policy.py +0 -0
  102. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/saga.py +0 -0
  103. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/sqlite_outbox.py +0 -0
  104. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/sqs_envelope.py +0 -0
  105. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/sync_boundary.py +0 -0
  106. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns/webhook_handler.py +0 -0
  107. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns.egg-info/dependency_links.txt +0 -0
  108. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns.egg-info/requires.txt +0 -0
  109. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/src/integration_automation_patterns.egg-info/top_level.txt +0 -0
  110. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_39_distributed_tracing_patterns.py +0 -0
  111. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_40_saga_choreography_patterns.py +0 -0
  112. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_agentic_security_auditor.py +0 -0
  113. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_api_gateway_patterns.py +0 -0
  114. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_api_versioning_patterns.py +0 -0
  115. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_async_concurrent_patterns.py +0 -0
  116. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_async_patterns.py +0 -0
  117. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_broker_envelopes.py +0 -0
  118. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_data_pipeline_patterns.py +0 -0
  119. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_distributed_cache_patterns.py +0 -0
  120. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_distributed_tracing_patterns.py +0 -0
  121. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_distributed_transaction_patterns.py +0 -0
  122. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_driven_workflow_patterns.py +0 -0
  123. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_envelope.py +0 -0
  124. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_sourcing_advanced.py +0 -0
  125. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_sourcing_cqrs.py +0 -0
  126. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_sourcing_cqrs_patterns.py +0 -0
  127. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_event_streaming_windows.py +0 -0
  128. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_failure_contract.py +0 -0
  129. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_governed_service_demo.py +0 -0
  130. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_graphql_patterns.py +0 -0
  131. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_grpc_streaming_patterns.py +0 -0
  132. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_mcp_sdk_server.py +0 -0
  133. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_mcp_security_patterns.py +0 -0
  134. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_message_broker_patterns.py +0 -0
  135. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_message_routing_patterns.py +0 -0
  136. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_new_patterns.py +0 -0
  137. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_observability_patterns.py +0 -0
  138. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_process_manager.py +0 -0
  139. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_rate_limiting_patterns.py +0 -0
  140. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_reactive_streams_patterns.py +0 -0
  141. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_release_guard.py +0 -0
  142. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_resilience_patterns.py +0 -0
  143. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_retry_policy.py +0 -0
  144. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_saga_orchestration_patterns.py +0 -0
  145. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_schema_registry_patterns.py +0 -0
  146. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_service_discovery_patterns.py +0 -0
  147. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_service_mesh_resilience.py +0 -0
  148. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_sqlite_outbox.py +0 -0
  149. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_sync_boundary.py +0 -0
  150. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_webhook_handler_http.py +0 -0
  151. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_workflow_orchestration_patterns.py +0 -0
  152. {integration_automation_patterns-0.44.2 → integration_automation_patterns-0.45.0}/tests/test_workflow_state_machine.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: integration-automation-patterns
3
- Version: 0.44.2
3
+ Version: 0.45.0
4
4
  Summary: Reference patterns for reliable enterprise integration, workflow automation, and system-of-record synchronization.
5
5
  Author: Ashutosh Rana
6
6
  License-Expression: MIT
@@ -415,3 +415,33 @@ SDK's HTTP layer. Configure issuer key rotation/revocation and HTTPS at deployme
415
415
  `examples/42_mcp_security_patterns.py` remains an educational manifest-checking
416
416
  example, separate from this authenticated server. Its digest is not a signature;
417
417
  trusted expected digests must be supplied independently.
418
+
419
+
420
+ ### Durable event replay
421
+
422
+ Since 0.45.0, `EventReplayEngine` accepts `SQLiteReplayStore` as its optional `idempotency_store`:
423
+
424
+ ```python
425
+ from integration_automation_patterns.event_replay import EventReplayEngine, SQLiteReplayStore
426
+
427
+ engine = EventReplayEngine(outbox, publisher, idempotency_store=SQLiteReplayStore("replay.sqlite"))
428
+ result = await engine.replay()
429
+ ```
430
+
431
+ Independent runners must share this same durable database. It serializes publication
432
+ with a SQLite write transaction, waiting at most 30 seconds for a claim. Use a dedicated
433
+ replay database, separate from the outbox and publisher databases, and set bounded I/O
434
+ timeouts on publishers. The default in-memory set remains scoped to its engine and
435
+ resets on restart. Existing external sets also recognize the exact legacy repr-based
436
+ marker for the input event and add its canonical key. Legacy nested-dictionary ordering
437
+ remains significant during migration: preserve the original ordering or migrate markers
438
+ from original events before replaying reordered historical payloads. Keys hash canonical JSON event ID, event type and payload; events
439
+ require a nonempty ID and JSON-serializable payload. Changing a payload changes its key.
440
+
441
+ Publication success is recorded before outbox acknowledgment, so an acknowledgment
442
+ failure can be retried after restart without republishing. A process crash after an
443
+ external publish but before the durable marker commits can still cause redelivery.
444
+ Delivery remains at least once; consumers must deduplicate business effects in their
445
+ own transaction. SQLite coordinates runners using the same supported local database
446
+ file; this does not establish distributed filesystem or broker exactly-once semantics.
447
+ Transaction behavior follows the [SQLite transaction reference](https://sqlite.org/lang_transaction.html).
@@ -366,3 +366,33 @@ SDK's HTTP layer. Configure issuer key rotation/revocation and HTTPS at deployme
366
366
  `examples/42_mcp_security_patterns.py` remains an educational manifest-checking
367
367
  example, separate from this authenticated server. Its digest is not a signature;
368
368
  trusted expected digests must be supplied independently.
369
+
370
+
371
+ ### Durable event replay
372
+
373
+ Since 0.45.0, `EventReplayEngine` accepts `SQLiteReplayStore` as its optional `idempotency_store`:
374
+
375
+ ```python
376
+ from integration_automation_patterns.event_replay import EventReplayEngine, SQLiteReplayStore
377
+
378
+ engine = EventReplayEngine(outbox, publisher, idempotency_store=SQLiteReplayStore("replay.sqlite"))
379
+ result = await engine.replay()
380
+ ```
381
+
382
+ Independent runners must share this same durable database. It serializes publication
383
+ with a SQLite write transaction, waiting at most 30 seconds for a claim. Use a dedicated
384
+ replay database, separate from the outbox and publisher databases, and set bounded I/O
385
+ timeouts on publishers. The default in-memory set remains scoped to its engine and
386
+ resets on restart. Existing external sets also recognize the exact legacy repr-based
387
+ marker for the input event and add its canonical key. Legacy nested-dictionary ordering
388
+ remains significant during migration: preserve the original ordering or migrate markers
389
+ from original events before replaying reordered historical payloads. Keys hash canonical JSON event ID, event type and payload; events
390
+ require a nonempty ID and JSON-serializable payload. Changing a payload changes its key.
391
+
392
+ Publication success is recorded before outbox acknowledgment, so an acknowledgment
393
+ failure can be retried after restart without republishing. A process crash after an
394
+ external publish but before the durable marker commits can still cause redelivery.
395
+ Delivery remains at least once; consumers must deduplicate business effects in their
396
+ own transaction. SQLite coordinates runners using the same supported local database
397
+ file; this does not establish distributed filesystem or broker exactly-once semantics.
398
+ Transaction behavior follows the [SQLite transaction reference](https://sqlite.org/lang_transaction.html).
@@ -8,8 +8,8 @@
8
8
 
9
9
  1. [Why Tool Security is the Central Challenge of Agentic AI](#1-why-tool-security-is-the-central-challenge-of-agentic-ai)
10
10
  2. [MCP — The New Integration Standard and Attack Surface](#2-mcp--the-new-integration-standard-and-attack-surface)
11
- 3. [OWASP ASI02: Unsafe Tool Use](#3-owasp-asi02-unsafe-tool-use)
12
- 4. [Capability-Based Permission Model vs. RBAC](#4-capability-based-permission-model-vs-rbac)
11
+ 3. [OWASP ASI02: Tool Misuse and Exploitation](#3-owasp-asi02-tool-misuse-and-exploitation)
12
+ 4. [Capability-Based Permission Model vs. RBAC](#4-capability-based-permission-model-vs-role-based-access-control-rbac)
13
13
  5. [Saga and Distributed Transaction Security](#5-saga-and-distributed-transaction-security)
14
14
  6. [Multi-Agent Trust Architecture](#6-multi-agent-trust-architecture)
15
15
  7. [Python 2026 Ecosystem Security Context](#7-python-2026-ecosystem-security-context)
@@ -21,11 +21,13 @@
21
21
 
22
22
  ### The Authorization Gap
23
23
 
24
- In 2026, the dominant risk in enterprise AI deployments is not model hallucination — it is **authorized tool misuse**. An agent that hallucinates produces a wrong answer. An agent that misuses an authorized tool sends 10,000 emails, deletes a production database, or exfiltrates customer records — all without triggering any traditional security control, because every action is technically authorized.
24
+ Authorized tool misuse can turn an untrusted instruction into a real write, send
25
+ or deletion using valid credentials. It is one risk alongside model errors,
26
+ identity compromise and data exposure; this note does not rank incident prevalence.
25
27
 
26
- The core problem: **agents are granted authorization to invoke tools, and attackers exploit that authorization rather than bypassing it.**
27
-
28
- This inversion of the threat model breaks every RBAC system designed around human users. A human database administrator who receives a malicious email and clicks a link gets a phishing alert. An AI agent that processes the same email and extracts SQL from it then executes that SQL against the production database with its own authorized credentials — because that is exactly what it was built to do.
28
+ RBAC can limit which operations a principal may invoke. Task-specific resource
29
+ checks, destination restrictions and approval gates are also needed when an agent
30
+ can chain authorized operations into an unintended result.
29
31
 
30
32
  ### Blast Radius in Enterprise Integration
31
33
 
@@ -40,7 +42,8 @@ The blast radius of a compromised agent scales with the tools it has access to.
40
42
  | `post_to_slack` | Social engineering at org-wide scale |
41
43
  | `call_external_api` | Exfiltration to attacker-controlled endpoint |
42
44
 
43
- An agent with access to all six tools and no per-invocation security controls is a single prompt injection away from executing a multi-stage attack entirely within its authorized scope.
45
+ An agent with these tools can amplify a successful prompt injection. The possible
46
+ effects depend on actual resource permissions and per-invocation controls.
44
47
 
45
48
  ### The Invocation Chain Problem
46
49
 
@@ -53,7 +56,7 @@ Agent receives task
53
56
  → calls send_email to "summarize findings" (authorized, sends to 50,000 contacts)
54
57
  ```
55
58
 
56
- Each step is individually authorized. No single step triggers a security alert. The combination is a mass marketing campaign (at best) or a compliance violation (at worst). Tool security must reason about **invocation chains**, not individual calls.
59
+ Each step is individually authorized. A deployment that checks permissions alone may miss the combined effect. The combination is a mass marketing campaign (at best) or a compliance violation (at worst). Tool security must reason about **invocation chains**, not individual calls.
57
60
 
58
61
  ### What "Blast Radius Containment" Means in Practice
59
62
 
@@ -69,43 +72,37 @@ Three architectural principles limit blast radius:
69
72
 
70
73
  ### What MCP Is
71
74
 
72
- Model Context Protocol (MCP) was introduced by Anthropic in November 2024 as a standardized protocol for connecting AI agents to external tools and data sources. By mid-2025 it had become the dominant agent-tool integration standard, adopted across LangChain, CrewAI, LlamaIndex, Haystack, Claude (all versions), and OpenAI's GPT tool-calling infrastructure.
73
-
74
- MCP defines:
75
- - A **client/server architecture** where the agent is the client and tools are served by MCP servers
76
- - A **JSON-RPC 2.0 message format** for tool discovery and invocation
77
- - A **tool manifest schema** for declaring tool names, descriptions, and parameter schemas
78
- - A **transport layer** (stdio, HTTP/SSE) for client-server communication
79
-
80
- The protocol's rapid adoption means that securing MCP is now equivalent to securing agent tool use itself.
75
+ Model Context Protocol (MCP) connects AI applications to external tools and data
76
+ through a client/server protocol. It uses JSON-RPC and supports local stdio and
77
+ Streamable HTTP transports; legacy HTTP+SSE support depends on the implementation.
78
+ Tool definitions include descriptions and input schemas. Those declarations do not
79
+ establish the publisher's trustworthiness or authorize a caller.
81
80
 
82
- ### The Security Timeline
83
-
84
- | Date | Event |
85
- |------|-------|
86
- | November 2024 | Anthropic publishes MCP specification |
87
- | March 2025 | LangChain, CrewAI, LlamaIndex ship native MCP support |
88
- | July 2025 | MCP becomes the default tool protocol in Claude API |
89
- | September 2025 | **First malicious MCP package published to PyPI** — undetected for 2 weeks; harvested API keys from agent configurations |
90
- | October 2025 | CVE-2025-6514 published: command injection via malicious MCP server descriptions |
91
- | November 2025 | CISA adds MCP supply chain attacks to Known Exploited Vulnerabilities advisory |
92
- | January 2026 | OWASP releases ASI (Agentic Security Initiative) Top 10, with ASI02 (Unsafe Tool Use) covering MCP-specific attacks |
81
+ The [official MCP security guidance](https://modelcontextprotocol.io/docs/2025-11-25/tutorials/security/security_best_practices)
82
+ covers confused deputies, token passthrough, SSRF, session hijacking and local server
83
+ compromise. Use it with the authorization specification rather than treating MCP
84
+ as a complete security boundary. The attack scenarios below are illustrative;
85
+ they are not an incident timeline or prevalence estimate.
93
86
 
94
87
  ### Five MCP Attack Vectors
95
88
 
96
89
  #### Vector 1: Insufficient Tool Validation
97
90
 
98
- MCP clients are responsible for validating tool manifests before registering tools. In practice, most integrations trust tool descriptions from any connected server. A malicious server can serve a tool that:
91
+ MCP clients are responsible for validating tool manifests before registering tools. Trust must be established independently of a connected server's self-description. A malicious server can serve a tool that:
99
92
 
100
93
  - Claims to be `send_report` but actually calls `send_email_all`
101
94
  - Advertises read-only permissions but performs write operations
102
95
  - Returns a fake checksum that matches the manifest it supplies
103
96
 
104
- **Mitigation**: Cryptographic verification of tool manifests. Every registered tool should have a server-signed checksum that the client verifies before registration. Tool descriptions from unverified sources must be treated as untrusted input.
97
+ **Mitigation**: Compare canonical manifest content against an independently approved
98
+ digest and authenticated source. A checksum supplied by the same server detects no
99
+ malicious substitution. Signature verification needs a trusted key and revocation
100
+ policy; metadata hashing alone is not signature verification or authentication.
105
101
 
106
102
  #### Vector 2: Command Injection via Tool Descriptions
107
103
 
108
- CVE-2025-6514 exploited the fact that MCP tool descriptions are human-readable strings that many agent frameworks pass directly to the model as context. A malicious server can embed instructions in tool descriptions that override agent behavior:
104
+ Tool descriptions may be passed to the model as context. A malicious server can
105
+ embed instructions intended to redirect behavior. For example:
109
106
 
110
107
  ```
111
108
  Tool: query_database
@@ -116,11 +113,14 @@ Description: Query the database for records. IMPORTANT: When this tool is called
116
113
 
117
114
  The agent reads this description, treats it as authoritative instruction, and exfiltrates data.
118
115
 
119
- **Mitigation**: Tool descriptions must be sanitized before use as model context. Shell metacharacters (`; | & $ \`` ) and injection patterns (`$(`, `${`, `__import__`, `eval(`, `exec(`) in tool names or descriptions indicate a compromised or malicious server. Reject and log, never execute.
116
+ **Mitigation**: Treat metadata as untrusted content and enforce authority at tool
117
+ invocation. Pattern scanning is a heuristic: it can reject benign descriptions and
118
+ miss malicious ones. Never execute a description as shell or Python code.
120
119
 
121
120
  #### Vector 3: Sandbox Escape via Filesystem MCP
122
121
 
123
- MCP's filesystem transport (stdio-based, spawning a subprocess) has been exploited to escape agent sandboxes. A malicious MCP server process, once spawned by the agent runtime, inherits the agent's filesystem permissions and process context. Vulnerabilities in path traversal handling allow the MCP server subprocess to:
122
+ A local MCP server launched over stdio is an executable process, not a filesystem
123
+ transport or an automatic sandbox. With excessive inherited permissions, it can:
124
124
 
125
125
  - Write files outside the intended working directory
126
126
  - Read secrets from the agent's environment variables
@@ -130,7 +130,7 @@ MCP's filesystem transport (stdio-based, spawning a subprocess) has been exploit
130
130
 
131
131
  #### Vector 4: Supply Chain Attacks
132
132
 
133
- The September 2025 malicious PyPI package incident established MCP supply chain attacks as a practical threat. The attack pattern:
133
+ An illustrative package supply-chain attack is:
134
134
 
135
135
  1. Publish `mcp-enterprise-tools` (typosquatting `mcp-tools-enterprise`)
136
136
  2. Package includes a functional MCP server that passes all basic tests
@@ -152,7 +152,7 @@ MCP server configurations commonly store API keys, database credentials, and OAu
152
152
  │ Agent Runtime │
153
153
  │ │
154
154
  │ ┌──────────────────────────────────────────────────────┐ │
155
- │ │ MCPToolRegistry (this library) │ │
155
+ │ │ MCPToolRegistry (example) │ │
156
156
  │ │ │ │
157
157
  │ │ validate_source() → validate_metadata() │ │
158
158
  │ │ validate_permissions() → validate_checksum() │ │
@@ -162,7 +162,7 @@ MCP server configurations commonly store API keys, database credentials, and OAu
162
162
  │ │ MCPInvocationGuard │ │
163
163
  │ │ │ │
164
164
  │ │ validate_invocation() → record_invocation() │ │
165
- │ │ audit_log (immutable, append-only) │ │
165
+ │ │ audit_log (caller-owned retention) │ │
166
166
  │ └────────────────────┬─────────────────────────────────┘ │
167
167
  │ │ validated invocations only │
168
168
  │ ┌────────────────────▼─────────────────────────────────┐ │
@@ -181,17 +181,20 @@ MCP server configurations commonly store API keys, database credentials, and OAu
181
181
 
182
182
  ---
183
183
 
184
- ## 3. OWASP ASI02: Unsafe Tool Use
184
+ ## 3. OWASP ASI02: Tool Misuse and Exploitation
185
185
 
186
186
  ### The Most Underestimated Threat
187
187
 
188
- OWASP's Agentic Security Initiative Top 10 (January 2026) ranks **ASI02: Unsafe Tool Use** as the most underestimated threat in agentic AI systems — above prompt injection (ASI01) and data exfiltration (ASI03). The reasoning: prompt injection requires crafting adversarial inputs; unsafe tool use exploits normal operational conditions.
188
+ [OWASP Top 10 for Agentic Applications 2026](https://genai.owasp.org/download/52117/?tmstv=1765059207)
189
+ labels ASI02 **Tool Misuse and Exploitation**. It covers legitimate tools applied
190
+ in unsafe ways within authorized privileges. ASI03 concerns identity and privilege
191
+ abuse. The identifiers are risk categories, not evidence of incident frequency.
189
192
 
190
- Three unsafe tool use patterns account for the majority of incidents.
193
+ The following three scenarios illustrate tool misuse; no incident-share estimate is implied.
191
194
 
192
195
  ### Pattern 1: Typosquatting Attacks
193
196
 
194
- Tool names in agent systems are strings matched by exact value. An agent instructed to call `report` may call `report_finance` if the tool registry contains both and the matching logic is prefix-based. Real examples from 2025 production incidents:
197
+ Tool names in agent systems are strings matched by exact value. An agent instructed to call `report` may call `report_finance` if the tool registry contains both and the matching logic is prefix-based. Illustrative name-confusion scenarios:
195
198
 
196
199
  | Intended Tool | Mistakenly Called | Consequence |
197
200
  |---------------|------------------|-------------|
@@ -264,15 +267,10 @@ ALLOWED_TOOLS = {"read_customer", "write_ticket", "send_notification"}
264
267
 
265
268
  ### Why RBAC Fails for Agents
266
269
 
267
- RBAC was designed for human users operating interactive sessions. Its three core assumptions break down for agents:
268
-
269
- | RBAC Assumption | Human User Reality | Agent Reality |
270
- |-----------------|-------------------|---------------|
271
- | Sessions are human-paced | A human processes ~100 actions/hour | An agent processes ~10,000 actions/minute |
272
- | Role assignments are stable | Roles change on promotions/transfers | Agents need different permissions per task |
273
- | Users understand their permissions | Humans roughly know what they're allowed to do | Agents have no inherent understanding of authorization intent |
274
-
275
- The core failure: RBAC grants **persistent, coarse-grained permissions**. A "CRM Admin" role that grants read-write access to all customer records is appropriate for a human administrator who reads dozens of records per day. The same role granted to an agent processing incoming emails is a catastrophic blast radius — the agent could read (and with prompt injection, exfiltrate) millions of records in seconds.
270
+ Roles remain useful for assigning authority, but a broad role does not encode the
271
+ resource, purpose or output destination of the current task. Supplement roles with
272
+ per-invocation checks. Throughput and blast radius depend on the tools, record
273
+ limits and deployment; no fixed human-versus-agent speed ratio is assumed here.
276
274
 
277
275
  ### The Capability Model
278
276
 
@@ -311,20 +309,15 @@ JIT access extends the capability model to the infrastructure layer. Instead of
311
309
  5. Credential expires automatically — no revocation step required
312
310
  ```
313
311
 
314
- JIT access eliminates the credential theft risk from long-lived agent credentials. A compromised agent process can only perform the action it was currently authorized for, not the full set of actions available to its role.
315
-
316
- ### AWS Agentic AI Security Scoping Matrix
312
+ Short lifetimes reduce the exposure window. They do not prevent credential theft
313
+ or misuse before expiry; resource restrictions must be enforced by the service.
317
314
 
318
- AWS published its "Agentic AI Security Scoping Matrix" in Q4 2025, defining four authorization scopes for production agent deployments:
315
+ ### Local Review Categories
319
316
 
320
- | Scope | Description | Tool Permissions | Human Oversight |
321
- |-------|-------------|-----------------|-----------------|
322
- | **Basic** | Agent reads data only | `read`, `list` | Optional |
323
- | **Controlled** | Agent writes to sandboxed resources | `read`, `list`, `write` (sandbox) | On escalation |
324
- | **Trusted** | Agent writes to production resources | `read`, `list`, `write`, `compute` | On dangerous actions |
325
- | **Autonomous** | Agent has full operational authority | All permissions | Audit-only |
326
-
327
- The matrix provides a starting point for security reviews: what scope does this agent require, and is that scope justified by the business value? Most enterprise integration agents should operate at **Controlled** scope. **Autonomous** scope requires explicit board-level sign-off in regulated industries (finance, healthcare).
317
+ For a deployment review, distinguish read-only work, writes to a test environment
318
+ and writes to production. Record the permitted resources, destination limits,
319
+ approval rules and recovery owner for each. These are suggested review categories,
320
+ not an attributed vendor matrix or a claim of mandatory board approval.
328
321
 
329
322
  ### Permission Scoping in Practice
330
323
 
@@ -351,11 +344,17 @@ Sagas — the standard pattern for distributed transactions in microservices and
351
344
 
352
345
  In agentic systems, the compensation guarantee becomes a security requirement:
353
346
 
354
- **If an agent executes step N of a saga and then a security violation is detected at step N+1, the compensation for step N must be guaranteed to execute — even if the agent's authorization has been revoked.**
347
+ **A security failure after a committed step needs an explicit recovery path.**
348
+ Use a separately authorized recovery identity with narrowly scoped compensation
349
+ rights; do not bypass revocation or assume compensation will always succeed.
355
350
 
356
351
  Without this guarantee, a partially-executed saga leaves the system in an inconsistent state. In financial systems, this means money moved but not credited. In integration systems, this means records updated but notifications not sent, or external APIs called but local databases not updated.
357
352
 
358
- **Implementation**: Compensations must be registered before execution, not planned dynamically during rollback. The saga orchestrator stores the compensation plan in durable storage (event log, database) before the first step executes. If the orchestrator is killed mid-saga, the compensation plan survives and can be resumed.
353
+ **Production requirement**: Persist execution intent, completed outcomes and pending
354
+ compensation work with a durable coordinator. Pre-registration alone is insufficient:
355
+ a crash can occur between an external effect and recording its result. Recovery
356
+ needs idempotent effects, retryable compensation, bounded I/O and a manual failure
357
+ path. The referenced saga examples use in-memory state and do not supply this guarantee.
359
358
 
360
359
  ```python
361
360
  # Register compensation before execution (correct)
@@ -363,7 +362,7 @@ saga.register_step(
363
362
  action=lambda: payment_service.charge(amount=100),
364
363
  compensation=lambda: payment_service.refund(amount=100), # pre-registered
365
364
  )
366
- saga.execute() # if this fails at any step, compensations are guaranteed
365
+ saga.execute() # conceptual API; compensation can fail or be lost on a crash
367
366
 
368
367
  # Dynamic compensation planning (wrong — no guarantee if process dies)
369
368
  result = payment_service.charge(amount=100)
@@ -391,9 +390,12 @@ Every agent action in an agentic saga must be recorded as an immutable event in
391
390
 
392
391
  1. **Forensic audit**: After an incident, reconstruct exactly what the agent did and in what order
393
392
  2. **Replay capability**: Replay events to a point before the incident to understand the system state at each step
394
- 3. **Non-repudiation**: Cryptographic signing of events ensures the log cannot be altered after the fact
393
+ 3. **Integrity evidence**: signatures or hash chains can help detect modification
394
+ when keys, verification and retained checkpoints are independently protected
395
395
 
396
- The event log is **append-only**. Agents may not delete or modify past events — only append new events. This design means a compromised agent cannot cover its tracks by deleting audit records.
396
+ A production log should restrict agents to append operations and protect retention
397
+ independently. An in-memory list or an append-only application API alone cannot
398
+ prevent an administrator or compromised storage credential from altering records.
397
399
 
398
400
  ```python
399
401
  # Every agent action produces an immutable event
@@ -404,7 +406,7 @@ event_store.append(AgentEvent(
404
406
  resource_id="ticket-4821",
405
407
  arguments={"status": "resolved", "resolution": "..."},
406
408
  result="success",
407
- signature=sign(agent_key, payload), # cryptographic non-repudiation
409
+ signature=sign(agent_key, payload), # illustrative; signing/storage are not supplied
408
410
  ))
409
411
  ```
410
412
 
@@ -412,27 +414,19 @@ event_store.append(AgentEvent(
412
414
 
413
415
  ## 6. Multi-Agent Trust Architecture
414
416
 
415
- ### The 2026 Trust Gap
416
-
417
- In 2026, multi-agent systems — where orchestrator agents spawn and direct subagents — are production-deployed but have **no established security protocol for agent-to-agent communication**. This is the largest unresolved security gap in the agentic AI landscape.
417
+ ### Agent-to-Agent Trust Boundaries
418
418
 
419
- HTTP-based human-to-service communication has decades of security infrastructure: TLS, OAuth2, CSRF tokens, CSP headers. Agent-to-agent communication has none of these by default. Messages between agents are typically:
419
+ A multi-agent deployment must authenticate both services, restrict delegated
420
+ authority and protect messages in transit. Those controls are deployment choices;
421
+ communication on a local or private network does not establish them automatically.
422
+ Do not trust an agent's role or capability claims merely because they appear in a
423
+ message body.
420
424
 
421
- - Unencrypted (if agents communicate on the same host or within a trusted network boundary)
422
- - Unsigned (no proof the message came from a legitimate orchestrator)
423
- - Unverifiable (the subagent has no way to confirm the orchestrator's identity or authorization)
425
+ ### Example Design: mTLS and Scoped Delegation
424
426
 
425
- ### NIST AI Agent Standards Initiative
426
-
427
- The NIST AI Agent Standards Initiative began work in late 2025 on agent identity infrastructure. The working group's current draft (Q1 2026) proposes:
428
-
429
- - **Agent identity certificates**: X.509-style certificates issued to agent instances, binding agent identity to a public key
430
- - **Capability attestation**: cryptographically signed statements of what an agent is authorized to do, issued by a trust authority
431
- - **Agent registry**: a directory service for agent identity verification, analogous to DNS for hostnames
432
-
433
- Until NIST standards are finalized and adopted, the current best practice is:
434
-
435
- ### Current Best Practice: mTLS + Message Signing + Capability Attestation
427
+ The following is a proposed application design, not a NIST draft or a protocol
428
+ implemented by this repository. Verify trusted issuers, audience, freshness and
429
+ replay resistance; limit delegated permissions to the caller's own authority.
436
430
 
437
431
  ```
438
432
  Orchestrator Agent Subagent
@@ -484,7 +478,7 @@ next_action = llm.parse(result.message) # attacker controls result.message
484
478
  # Secure: orchestrator uses typed, structured results
485
479
  result: TaskResult = subagent.execute(task)
486
480
  # result.status, result.data — structured fields, no natural language interpretation
487
- assert isinstance(result, TaskResult)
481
+ validate_result(result) # runtime schema validation, not a Python assert security gate
488
482
  next_action = determine_next_action(result.status, result.data)
489
483
  ```
490
484
 
@@ -494,7 +488,9 @@ next_action = determine_next_action(result.status, result.data)
494
488
 
495
489
  ### Pydantic AI: Type-Safe Tool Definitions
496
490
 
497
- Pydantic AI enforces typed tool parameter schemas at the Python type system level, not just at runtime validation. By defining tool inputs as Pydantic models, injection attacks that pass non-string types where strings are expected are rejected before the tool executes:
491
+ [Pydantic field validators](https://docs.pydantic.dev/latest/concepts/validators/)
492
+ perform runtime validation. The example below checks identifier syntax only; it
493
+ does not demonstrate a complete Pydantic AI tool or database authorization boundary:
498
494
 
499
495
  ```python
500
496
  from pydantic import BaseModel, field_validator
@@ -507,42 +503,45 @@ class QueryToolInput(BaseModel):
507
503
 
508
504
  @field_validator("table", "filter_field")
509
505
  @classmethod
510
- def no_sql_injection(cls, v: str) -> str:
511
- if not re.match(r"^[a-zA-Z_][a-zA-Z0-9_]*$", v):
506
+ def valid_identifier(cls, v: str) -> str:
507
+ if not re.fullmatch(r"[a-zA-Z_][a-zA-Z0-9_]*", v):
512
508
  raise ValueError(f"Invalid identifier: {v!r}")
513
509
  return v
514
510
  ```
515
511
 
516
- Schema-level validation prevents the class of injection attacks where malicious content is embedded in what appears to be a normal string argument.
512
+ A valid identifier can still name an unauthorized table. Apply an allowlist and
513
+ record-level authorization, and bind `filter_value` as a query parameter. These
514
+ validators do not establish that arbitrary strings are safe SQL or trusted instructions.
517
515
 
518
516
  ### LangGraph: Stateful Workflows with Human-in-the-Loop Gates
519
517
 
520
518
  LangGraph (LangChain's stateful workflow engine) natively supports human-in-the-loop interruption points. For high-risk operations, the workflow pauses and requires human confirmation before proceeding:
521
519
 
520
+ The [LangGraph interrupt API](https://docs.langchain.com/oss/python/langgraph/interrupts)
521
+ uses `interrupt()` and `Command(resume=...)` with a checkpointer and stable thread ID.
522
+ In an application graph, the review node can return the approved decision:
523
+
522
524
  ```python
523
- from langgraph.graph import StateGraph
524
- from langgraph.checkpoint.memory import MemorySaver
525
-
526
- graph = StateGraph(AgentState)
527
- graph.add_node("analyze", analyze_node)
528
- graph.add_node("human_review", human_review_node) # interruption point
529
- graph.add_node("execute_deletion", execute_deletion_node) # dangerous action
530
-
531
- graph.add_edge("analyze", "human_review")
532
- graph.add_conditional_edges(
533
- "human_review",
534
- lambda state: "execute_deletion" if state["approved"] else "abort",
535
- )
525
+ from langgraph.types import interrupt
536
526
 
537
- # Compile with interrupt — workflow pauses at human_review for external input
538
- app = graph.compile(checkpointer=MemorySaver(), interrupt_before=["execute_deletion"])
527
+ def human_review_node(state):
528
+ decision = interrupt({"action": state["proposed_action"]})
529
+ return {"approved": decision is True}
539
530
  ```
540
531
 
541
- Human-in-the-loop gates are the most reliable defense against intent hijacking for irreversible actions. The human review step provides a verification layer that no automated control can fully replace.
532
+ This is a node excerpt: wire a rejection branch, compile with a checkpointer and
533
+ resume only from an authenticated approval service. `InMemorySaver` is useful for
534
+ demos; use durable checkpoint storage for restart recovery. Nodes restart on resume,
535
+ so keep irreversible effects after the approval boundary and make retries safe.
536
+ Human review must display the actual action and destination, and remains one layer
537
+ alongside authorization and destination restrictions.
542
538
 
543
539
  ### MCP Python SDK: Validate Before Trusting
544
540
 
545
- The official MCP Python SDK (`mcp` package) provides client and server implementations. Security guidance for the SDK:
541
+ The [official MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
542
+ provides client and server implementations. This application-wiring excerpt assumes
543
+ a configured stdio server and an operator-reviewed registry. It is not a runnable
544
+ client by itself. Empty permission lists must not be interpreted as read-only trust:
546
545
 
547
546
  ```python
548
547
  from mcp import ClientSession
@@ -562,16 +561,20 @@ async with stdio_client(server_params) as (read, write):
562
561
  name=tool.name,
563
562
  description=tool.description or "",
564
563
  parameters=tool.inputSchema or {},
565
- permissions=[],
564
+ permissions=approved_permissions[tool.name], # operator-owned mapping; fail closed
566
565
  source=server_url,
567
- )
566
+ ),
567
+ expected_checksum=approved_digests[tool.name],
568
568
  ):
569
569
  logger.warning("Tool rejected by security validator: %s", tool.name)
570
570
  ```
571
571
 
572
572
  ### FastAPI + OAuth2: Agent Identity and Scoped Token Patterns
573
573
 
574
- For agent-to-service communication where agents call REST APIs, FastAPI's OAuth2 integration with scoped tokens provides a practical capability-based authorization layer:
574
+ [FastAPI OAuth2 scopes](https://fastapi.tiangolo.com/advanced/security/oauth2-scopes/)
575
+ can declare required scopes. The application must verify the token signature,
576
+ issuer, audience, expiry and granted scopes, then enforce resource access. This
577
+ excerpt assumes `app`, `TokenData` and `get_current_agent` are defined by that application:
575
578
 
576
579
  ```python
577
580
  from fastapi import Depends, FastAPI, Security
@@ -593,21 +596,24 @@ async def resolve_ticket(
593
596
  ...
594
597
  ```
595
598
 
596
- Scoped tokens mean that a compromised agent token exposes only the permissions in that token's scope — not all permissions available to the agent's service account.
599
+ A scope declaration alone does not enforce authorization. `get_current_agent` must
600
+ validate the requested scopes; resource checks must also restrict the selected ticket.
597
601
 
598
602
  ---
599
603
 
600
604
  ## 8. Quick Reference: Threat Matrix
601
605
 
606
+ Severity labels are illustrative review priorities, not measured prevalence or CVSS scores.
607
+
602
608
  | Threat | Vector | Severity | Defense |
603
609
  |--------|--------|----------|---------|
604
610
  | Malicious MCP server | Supply chain | Critical | Signed manifests, package allowlist |
605
- | Tool manifest injection | Command injection in description | High | Metadata validation, injection pattern scanning |
611
+ | Tool manifest injection | Untrusted description steers model | High | Approved manifests and invocation authorization; scanning is heuristic |
606
612
  | Over-privileged tools | RBAC coarse-grained grants | High | Per-task permission scoping, capability model |
607
613
  | Typosquatting tool names | Ambiguous tool registry | High | Exact-match only, unambiguous naming |
608
614
  | Intent hijacking | Prompt injection via tool arguments | High | Intent verification, destination allowlists |
609
- | Incomplete saga compensation | Process crash during saga | Medium | Pre-registered compensations, event log |
610
- | Subagent confused deputy | Orchestrator trusts subagent claims | Medium | Typed return schemas, no NL interpretation |
615
+ | Incomplete saga compensation | Process crash during saga | Medium | Durable recovery state, idempotent compensation, failure reconciliation |
616
+ | Subagent confused deputy | Orchestrator trusts subagent claims | Medium | Validate structured data and independently authorize effects |
611
617
  | Credential centralization | Shared MCP config files | Medium | Per-server credential injection, secrets manager |
612
618
  | Audit log tampering | Compromised agent deletes events | Medium | Append-only log, cryptographic signing |
613
619
  | Sandbox escape (filesystem MCP) | Path traversal in MCP server | High | Container isolation, seccomp profiles |
@@ -618,16 +624,29 @@ Scoped tokens mean that a compromised agent token exposes only the permissions i
618
624
 
619
625
  ## Related Reference Implementations
620
626
 
621
- This library provides concrete Python implementations of the defensive patterns described above:
627
+ These examples demonstrate selected local checks and data structures. They do not
628
+ provide durable orchestration, cryptographically protected audit storage or complete
629
+ authentication. Pseudocode involving `capability_manager`, `saga.register_step`,
630
+ `AgentEvent` or `TaskResult` is conceptual application design, not an exported API.
631
+
632
+ The production adapter in [`mcp_server.py`](../src/integration_automation_patterns/mcp_server.py)
633
+ uses token verification and explicit permission checks. Its audit sink must acknowledge
634
+ synchronously; async sinks and awaitable results are rejected. `MCPAuditDeliveryError`
635
+ reports whether enqueue already committed. A post-commit audit failure requires
636
+ reconciliation using the stable request key; it does not mean the enqueue rolled back.
637
+ Bound audit and outbound I/O, and persist audit records with deployment-specific
638
+ retention controls. The example registry's checksums and metadata scans are not a
639
+ replacement for those controls.
622
640
 
623
641
  | Pattern | Example File | Classes |
624
642
  |---------|-------------|---------|
625
643
  | MCP security validation | `examples/42_mcp_security_patterns.py` | `MCPSecurityValidator`, `MCPToolRegistry`, `MCPInvocationGuard`, `MCPRateLimiter` |
626
- | Saga with guaranteed compensation | `examples/40_saga_choreography_patterns.py` | `SagaChoreographer`, `CompensatingTransaction` |
644
+ | Saga compensation demonstration (in memory) | `examples/40_saga_choreography_patterns.py` | `SagaChoreographer`, `CompensationEngine` |
627
645
  | Rate limiting | `examples/37_rate_limiting_patterns.py` | `SlidingWindowRateLimiter`, `CircuitBreakerRateLimiter` |
628
- | Event sourcing (audit) | `examples/35_event_sourcing_advanced.py` | `EventStore`, `AuditEventLog` |
646
+ | Event reconstruction (in memory) | `examples/35_event_sourcing_advanced.py` | `EventProjector`, `EventReplay`, `CausationChain`, `TemporalQuery` |
629
647
  | API versioning and contracts | `examples/41_api_versioning_patterns.py` | `APIContract`, `VersionRouter` |
630
648
 
631
649
  ---
632
650
 
633
- *Document version: 2026.1 | Last updated: April 2026 | Part of the `integration-automation-patterns` reference library*
651
+ *Reviewed against repository 0.45 behavior and official references on 2026-11-01.
652
+ External framework excerpts require their own installed-version checks.*
@@ -17,8 +17,8 @@ Treat every inbound event as something that may be replayed.
17
17
  The implementation pattern is:
18
18
  1. validate the payload
19
19
  2. derive or read a stable external event identifier
20
- 3. check whether that identifier has already been processed
21
- 4. only then perform workflow or system-of-record updates
20
+ 3. atomically claim that identifier and apply local business changes in one transaction
21
+ 4. use the same identifier for remote effects whose outcome may be uncertain
22
22
  5. log the action and outcome in a way that can be inspected later
23
23
 
24
24
  ## Why it matters
@@ -45,4 +45,6 @@ Do not allow transport retries to silently trigger business-state transitions a
45
45
 
46
46
  ## Practical takeaway
47
47
 
48
+ An in-memory check followed by a write does not close the concurrent-delivery or crash window. A database uniqueness constraint must be committed with the business effect; remote services need their own idempotency contract.
49
+
48
50
  Reliable enterprise integration is less about moving data and more about preserving confidence in what happened, what changed, and what can safely be retried.