Skip to content

feat: v3 dependency swap — reduce maintenance surface by ~40%#1

Merged
machinelearnear merged 14 commits intomainfrom
feature/v3-dependency-swap-refactor
Mar 11, 2026
Merged

feat: v3 dependency swap — reduce maintenance surface by ~40%#1
machinelearnear merged 14 commits intomainfrom
feature/v3-dependency-swap-refactor

Conversation

@machinelearnear
Copy link
Copy Markdown
Contributor

Summary

  • Replace custom implementations with community deps: instructor (structured outputs), mem0 (memory), logfire (observability), fastmcp (MCP tool servers)
  • Add human feedback loop: schema, API endpoint, Temporal workflow, lesson extraction activities — corrections from compliance reviewers feed back into Santos planning
  • Upgrade injection guard: MCP-era patterns (ChatML, [INST], system role), tool result sanitization wired into ToolHandler, tool schema pinning (rug pull prevention with removed-tool detection)
  • Add domain plugin protocol: domain.toml manifests + DomainRegistry — new domains require zero changes to core
  • Add eval infrastructure: promptfoo config + CI workflow triggered on prompt/agent/domain changes
  • Wire compaction API: CompactionClient.compact() integrated into ToolHandler loop with threshold-based triggering

Stats

  • 13 commits, 45 files changed, +5,079 / -1,452 lines
  • 62 new tests (1164 → 1226), 0 failures
  • 4 new dependencies: instructor, mem0ai, logfire, fastmcp

Test plan

  • All 1226 tests pass (uv run pytest tests/ --ignore=tests/test_export)
  • Cache-critical prompt ordering tests pass
  • Injection guard tests pass (including new MCP-era patterns)
  • mem0 import guarded — no cascading failures without dep
  • Tool result sanitization wired into ToolHandler (not dead code)
  • Schema pinning detects added, changed, and removed tools
  • Feedback endpoint requires auth
  • Integration test with real Temporal cluster
  • Verify compaction model availability on Vertex AI

🤖 Generated with Claude Code

machinelearnear and others added 14 commits March 11, 2026 11:45
Set up operativo quality regression testing with promptfoo: config for
DCE compliant/non-compliant/injection test cases, golden_cases directory
for PDF fixtures, and GitHub Actions workflow triggered on prompt/agent/
domain changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add detection for system role injection, ChatML format, [INST] format,
and assistant role confusion patterns. These cover newer prompt injection
vectors seen in MCP tool ecosystems.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add async compact() method that calls anthropic_client.messages.create()
with a compaction system prompt preserving compliance verdicts, citations,
document facts, tool results, and the operativo plan. Returns summary
message + last 10 recent messages as CompactionResult.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add create_instructor_client() factory that wraps AsyncAnthropicVertex
with instructor for structured output extraction. Mark AnthropicClient
as deprecated in favor of the new factory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Scans tool outputs before they re-enter agent context, redacting
results that contain injection patterns (ignore previous, new
instructions, system prompt probing, exfiltration, base64 decode).
Prevents MCP tool-result injection attacks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add domain.toml declarative manifests for all three domains and a
DomainRegistry that discovers and loads them at startup using stdlib
tomllib. Each manifest captures models, MCP server, Temporal queue,
memory collection, injection guard, and operational limits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ToolSchemaRegistry snapshots SHA-256 hashes of MCP tool schemas at
startup and verifies them before each operativo. Detects schema changes
and newly appeared tools that could indicate a compromised tool server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add optional compaction_client and anthropic_raw_client params to
ToolHandler.__init__(). Before each LLM call in run_loop(), check if
compaction is needed and compact messages when threshold is exceeded.
Fully backward-compatible — compaction only runs when both clients
are provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wraps mem0 (self-hosted, pgvector) as a memory layer with domain
isolation enforced via user_id namespacing ({domain}:{operativo_id}).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add logfire configuration as a single entry point for OpenTelemetry-native
distributed tracing. Integrate into the FastAPI gateway with send_to_logfire
disabled by default for safe local/test usage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expose DCE and IDP tools as MCP servers via FastMCP, and add an
MCPExecutor class for Lamponne to call tools through the MCP protocol.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and activities

Add the feedback processing pipeline for human-in-the-loop learning:
- OperativoFeedback and ExtractedLesson dataclasses in core/feedback.py
- FeedbackRequest/FeedbackResponse Pydantic models in gateway/feedback.py
- POST /operativos/{id}/feedback stub endpoint in gateway app
- FeedbackProcessingWorkflow for Temporal-orchestrated lesson extraction
- extract_lesson and store_lesson activity stubs
- 9 tests covering schema, API, workflow input, and activities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Guard mem0 import in memory/__init__.py to prevent cascading failures
- Wire sanitize_tool_result() into ToolHandler.run_loop() (was dead code)
- Add auth check to feedback endpoint (security gap)
- Fix datetime.utcnow() deprecation → datetime.now(UTC)
- Detect removed tools in ToolSchemaRegistry.verify() (rug pull gap)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove 92 unused imports (F401), fix string annotation references
in factory.py (F821), move os import to top of base.py (E402),
and reorder Dockerfile COPY before pip install so hatchling can
find the agent_harness package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@machinelearnear machinelearnear merged commit 02a8d7f into main Mar 11, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant