Commit Graph

145 Commits

Author SHA1 Message Date
Pi Agent
2953997e28 feat: implement path allowlist enforcement layer (issue #56)
Add enforcement layer 4 that verifies file-system paths in tool
parameters against agent type path allowlist glob patterns. Includes
logical path canonicalization to prevent directory traversal attacks.
Uses glob-match crate for pattern matching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:12:11 +01:00
fc892c59bb Merge pull request 'feat: implement lineage constraint enforcement (#55)' (#153) from feature/issue-55-lineage-constraint into main 2026-03-10 16:08:50 +01:00
Pi Agent
253926c898 feat: implement lineage constraint enforcement layer (issue #55)
Add enforcement layer 3 that verifies agent lineage chains to prevent
privilege escalation through agent spawning. Checks that each parent
in the chain has permission to spawn its child and that spawn depth
limits are respected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:08:28 +01:00
90f08dcdc7 Merge pull request 'feat: enforcement layer 2 — agent type manifest check (#54)' (#152) from feature/issue-54-agent-manifest-check into main 2026-03-10 16:04:56 +01:00
Pi Agent
bfce35ed22 feat: implement enforcement layer 2 — agent type manifest check (issue #54)
Add agent_manifest enforcement layer that verifies the requested tool
is in the calling agent type's allowed tool list from the manifest.
Denies with clear reason if no manifest found or tool not permitted.
7 tests covering allowed/denied tools, cross-type checks, unknown
agents, empty tools list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:04:43 +01:00
b3f5fe2576 Merge pull request 'feat: enforcement layer 1 — session override check (#53)' (#151) from feature/issue-53-session-override-check into main 2026-03-10 16:02:58 +01:00
Pi Agent
f2fedbf013 feat: implement enforcement layer 1 — session override check (issue #53)
Add session override enforcement layer that checks OverrideLevel from
SessionContext: ALL bypasses all enforcement, RELAX grants tools but
preserves lineage checks, NONE/UNSPECIFIED applies full manifest
enforcement. Returns typed SessionOverrideResult enum for downstream
layers. 8 tests covering all override levels and edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:02:33 +01:00
11d7bab132 Merge pull request 'feat: implement Agent Type Manifest loader (#52)' (#150) from feature/issue-52-manifest-loader into main 2026-03-10 15:59:59 +01:00
Pi Agent
c5ceb98a92 feat: implement Agent Type Manifest loader (issue #52)
Add ManifestStore that loads TOML agent type manifests from a directory.
Each manifest defines allowed tools, path allowlists, network egress
policies, lineage constraints (can_spawn), and max spawn depth.
Includes validation, reload support, and lookup by ID or name.

14 manifest tests + 8 existing = 22 total, clippy clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:59:34 +01:00
b9064bfe98 Merge pull request 'feat: scaffold Tool Broker Rust project (#51)' (#149) from feature/issue-51-scaffold-tool-broker into main 2026-03-10 15:56:21 +01:00
Pi Agent
09b516ec3e feat: scaffold Tool Broker Rust project (issue #51)
Create the Tool Broker service skeleton as a Cargo workspace member:
- Tonic gRPC server with DiscoverTools, ExecuteTool, ValidateCall stubs
- TOML config loading (host, port, manifest_dir, audit/secrets addrs)
- Server-streaming support for ExecuteTool via ReceiverStream
- 8 tests (5 config, 3 service stub) passing, clippy clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:55:53 +01:00
986584b759 Merge pull request 'test: integration tests for Search Service (#50)' (#148) from feature/issue-50-search-integration-tests into main 2026-03-10 15:51:33 +01:00
Pi Agent
cd75318f45 test: add integration tests for Search Service (issue #50)
8 integration tests wiring real service components with mocked external
services (SearXNG via aioresponses, Model Gateway/Audit via mock gRPC
servers). Tests cover: full pipeline with all fields populated, clean
text extraction, summarization, unreachable URL handling, audit logging,
SearXNG unavailability, result ordering, and Model Gateway fallback.

Total: 71 tests passing across the Search Service.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:51:13 +01:00
2a16c98597 Merge pull request 'feat: implement Search gRPC endpoint (#49)' (#147) from feature/issue-49-search-endpoint into main 2026-03-10 15:48:30 +01:00
Pi Agent
6ecc8b8f38 feat: implement Search gRPC endpoint with full pipeline (issue #49)
Wire the Search RPC handler to orchestrate the full search pipeline:
SearXNG query → content extraction → Model Gateway summarization.
Supports configurable pipeline stages (extraction/summarization can
be disabled), audit logging via Audit Service, and graceful degradation
at each stage. 14 tests covering full pipeline, partial pipelines,
validation, error handling, and audit logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:48:11 +01:00
578a5e9651 Merge pull request 'feat: implement summarization step via Model Gateway (#48)' (#146) from feature/issue-48-summarization into main 2026-03-10 15:41:35 +01:00
Pi Agent
c2bc87a8f5 feat: implement summarization step via Model Gateway (issue #48)
Add Summarizer class that calls Model Gateway Inference gRPC endpoint
to produce query-relevant summaries of web page content. Includes
parallel summarization, configurable max length, and graceful
degradation (falls back to truncated raw content if gateway unavailable).

13 tests covering success, params, truncation, degradation, parallel,
concurrency limits, empty list, and prompt template verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:41:08 +01:00
d23260f2b9 Merge pull request 'feat: implement readability-lxml extraction pipeline (#47)' (#145) from feature/issue-47-readability-extractor into main 2026-03-10 15:34:59 +01:00
Pi Agent
7d91c5638a feat: implement readability-lxml extraction pipeline (issue #47)
- PageExtractor: async HTTP fetcher with timeout, user-agent, redirect handling
- readability-lxml integration for main content extraction
- HTML-to-text conversion preserving headings and list structure
- Content length truncation (configurable max_content_length)
- Parallel fetching via asyncio.gather with semaphore concurrency limit
- Error handling for unreachable/blocked URLs
- 14 unit tests with aioresponses mocking, 36 total tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:34:42 +01:00
a578fa3c5b Merge pull request 'feat: implement SearXNG query client + snippet filter (#46)' (#144) from feature/issue-46-searxng-client into main 2026-03-10 15:31:34 +01:00
Pi Agent
c1aff33eb1 feat: implement SearXNG query client with snippet filter (issue #46)
- SearXNGClient: async HTTP client wrapping SearXNG JSON API
- Query param construction (categories, engines, language)
- Response parsing: extract title, URL, snippet, engine, score
- URL-based deduplication keeping highest-scoring entry
- HTML tag stripping and entity decoding for clean text
- Configurable max_results with per-call override
- 14 unit tests with aioresponses mocking
- Added aiohttp and aioresponses dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:31:18 +01:00
014e2f2d04 Merge pull request 'feat: scaffold Search Service Python project (#45)' (#143) from feature/issue-45-scaffold-search-service into main 2026-03-10 15:25:56 +01:00
Pi Agent
e0e870e388 feat: scaffold Search Service Python project (issue #45)
- Python project at services/search/ with pyproject.toml (setuptools)
- gRPC server boilerplate using grpc.aio with graceful shutdown
- YAML-based config loading (host, port, searxng_url, model_gateway_addr, audit_addr)
- SearchServiceServicer stub (returns Unimplemented)
- 8 config unit tests passing
- Fixed gen/python protobuf dependency to >=7.34 (matching gencode version)
- Added .venv and *.egg-info to .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:25:39 +01:00
b0b98d5b1c Merge pull request 'feat: set up SearXNG Docker container (#44)' (#142) from feature/issue-44-searxng-docker into main 2026-03-10 15:18:40 +01:00
Pi Agent
92214cdb4d feat: set up SearXNG Docker container for Search Service (issue #44)
- SearXNG settings.yml with curated search engines for development:
  Google, DuckDuckGo, Bing, Brave, Wikipedia, GitHub, StackOverflow,
  crates.io, PyPI, docs.rs
- JSON API enabled for programmatic access by Search Service
- Rate limiter config (limiter.toml) with permissive internal settings
- Docker Compose snippet for standalone testing (port 8888)
- Pinned image version, healthcheck, minimal capabilities (cap_drop ALL)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:18:27 +01:00
09053a8af9 Merge pull request 'feat: integration tests for Model Gateway (#43)' (#141) from feature/issue-43-model-gateway-integration-tests into main 2026-03-10 15:15:21 +01:00
Pi Agent
124b1241e9 feat: add integration tests for Model Gateway (issue #43)
- 13 integration tests covering all gRPC endpoints:
  Inference (success, routing simple/complex, model hint, invalid params, 404)
  StreamInference (success with token collection, error midstream)
  GenerateEmbedding (success, model override, invalid params)
  Audit logging (inference and embedding)
- Uses wiremock to mock Ollama HTTP API
- Uses mock AuditService gRPC server to verify audit log entries
- Full setup helpers for test isolation (random ports, per-test servers)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:15:08 +01:00
80c272bd56 Merge pull request 'feat: implement Inference + GenerateEmbedding endpoints (#42)' (#140) from feature/issue-42-inference-embedding-endpoints into main 2026-03-10 15:09:23 +01:00
Pi Agent
a4042183d9 chore: mark issue #42 as COMPLETED
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:09:03 +01:00
Pi Agent
6940c6a254 feat: implement Inference and GenerateEmbedding gRPC endpoints (issue #42)
- Inference: validates request, routes model via ModelRouter, calls
  Ollama generate(), returns text + finish_reason + tokens_used
- GenerateEmbedding: validates request, resolves embedding model,
  calls Ollama embed(), returns embedding vector + dimensions
- Both endpoints use audit logging (best-effort) and consistent
  error mapping via ollama_err_to_status()
- Added 7 validation unit tests, removed 2 stale unimplemented tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:07:06 +01:00
Pi Agent
120f5e5bd1 chore: mark issue #41 as COMPLETED
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:12:45 +01:00
042baff0ff Merge pull request 'feat: implement StreamInference gRPC endpoint (#41)' (#139) from feature/issue-41-stream-inference into main 2026-03-10 14:10:54 +01:00
Pi Agent
c60bd15523 feat: implement StreamInference gRPC endpoint (issue #41)
- Replace StreamInference stub with full server-streaming implementation
- Route requests through ModelRouter based on TaskComplexity/model_hint
- Bridge Ollama NDJSON stream to gRPC ReceiverStream via mpsc channel
- Add params_to_options() helper mapping InferenceParams to GenerateOptions
- Add ollama_err_to_status() for consistent Ollama error mapping
- Request validation (params, context, session_id, prompt)
- Best-effort audit logging before stream starts
- Log token counts from final Ollama chunk via tracing
- 69 tests passing (4 params_to_options, 4 validation, 61 existing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:10:38 +01:00
Pi Agent
dcd2752fde docs: mark issue #40 as COMPLETED in implementation plans
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:05:38 +01:00
457c086696 Merge pull request 'feat: implement model routing logic (#40)' (#138) from feature/issue-40-model-routing into main 2026-03-10 14:05:08 +01:00
Pi Agent
8620a88f0a feat: implement model routing logic and audit logging (issue #40)
- Add ModelRouter with resolve_model() and resolve_embedding_model()
  mapping TaskComplexity to configured models with alias expansion
- Add model_hint field to InferenceParams proto for explicit model override
- Add audit_log_inference() helper (best-effort, SHA-256 hash)
- Add with_audit_client() builder on ModelGatewayServiceImpl
- Connect AuditServiceClient in main.rs when audit_addr is configured
- 63 tests passing (12 routing, 3 service integration, 48 existing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:04:46 +01:00
Pi Agent
0dd9dcd876 docs: mark issue #39 as COMPLETED in implementation plans
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:57:40 +01:00
43978aa211 Merge pull request 'feat: implement Ollama HTTP client (#39)' (#137) from feature/issue-39-ollama-http-client into main 2026-03-10 13:57:11 +01:00
Pi Agent
a38ea1db51 feat: implement Ollama HTTP client for Model Gateway (issue #39)
Add async HTTP client wrapping the Ollama REST API with:
- OllamaClient with generate, generate_stream, chat, embed, list_models, is_healthy
- NDJSON streaming parser for /api/generate streaming responses
- Serde types for all Ollama API endpoints
- OllamaError enum with Http, Api, Deserialization, StreamIncomplete variants
- OllamaClientConfig for timeout and connection pool settings
- Integration into ModelGatewayServiceImpl (constructor now returns Result)
- 48 tests (types serde, wiremock HTTP mocks, error handling, config)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:56:53 +01:00
Pi Agent
0c55de22f2 docs: mark issue #38 as COMPLETED in implementation plans
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:43:50 +01:00
f0d2ab99d3 Merge pull request 'feat: scaffold Model Gateway Rust project (#38)' (#136) from feature/issue-38-scaffold-model-gateway into main 2026-03-10 13:43:22 +01:00
Pi Agent
c22719e9cf feat: scaffold Model Gateway Rust project (issue #38)
Add workspace member services/model-gateway with:
- Config loading (TOML) with model routing, Ollama URL, audit addr
- ModelGatewayServiceImpl with IsModelReady endpoint and 3 unimplemented stubs
- Tonic gRPC server entry point with tracing and graceful shutdown
- 15 unit tests covering config and service

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:42:57 +01:00
38d3dd3953 Merge pull request 'test: add integration tests for Memory Service (#37)' (#135) from feature/issue-37-memory-integration-tests into main 2026-03-10 13:30:33 +01:00
Pi Agent
640871e554 test: add integration tests for Memory Service (issue #37)
Add 16 integration tests exercising the full gRPC flow through a real
tonic server with mock Model Gateway and mock Audit Service:

- WriteMemory: stores entry, generates embeddings, verifies DB contents
- QueryMemory: returns streamed results, verifies cache hit on repeat
- GetCorrelated: by memory_id, explicit IDs, and session context
- Provenance: external sanitization, clean external, internal trusted
- RevokeMemory: verifies revocation in provenance table
- Audit logging: verifies write (action 4) and read (action 3) entries
- End-to-end lifecycle: write -> query -> correlate -> audit verify

Also fix clippy warnings for redundant ..Default::default() in tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:30:10 +01:00
6417fe693f Merge pull request 'feat: implement GetCorrelated gRPC endpoint (#36)' (#134) from feature/issue-36-get-correlated-endpoint into main 2026-03-10 12:07:48 +01:00
Pi Agent
ee5bfee2c2 feat: implement GetCorrelated gRPC endpoint (issue #36)
Replace the GetCorrelated stub with a full implementation supporting three
lookup modes: by memory_id (correlation table), by explicit correlating_ids,
and by session context (provenance table). Results are merged and deduplicated.

- Create db/read.rs with correlation, session, memory, tag, and correlation
  loading helpers using parameterized queries and build_id_list for safety
- Add audit_log_read helper for best-effort read audit logging (action 3)
- Return MemoryEntry with descriptions only (empty corpus per proto doc),
  populated provenance_metadata, tags, and correlating_ids
- Relax validation: accept empty memory_id when correlating_ids is provided
- Add 10 DB-level tests and 12 service-level tests (246 total passing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:07:23 +01:00
Pi Agent
ac2cb6e90b docs: mark QueryMemory endpoint as completed (issue #35)
QueryMemory was incrementally implemented across issues #30 (staged
retrieval), #31 (extraction), and #32 (semantic cache). No new code
needed — all acceptance criteria already satisfied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 10:55:49 +01:00
e09be59727 Merge pull request 'feat: implement WriteMemory gRPC endpoint (#34)' (#133) from feature/issue-34-write-memory-endpoint into main 2026-03-10 10:55:00 +01:00
Pi Agent
f9bb5adf94 feat: implement WriteMemory gRPC endpoint (issue #34)
Full write pipeline: validate request, assign/generate memory ID,
determine provenance and trust level, sanitize external content,
generate embeddings via Model Gateway, store all data atomically
in DuckDB (memory + tags + correlations + embeddings + provenance +
derivation links), invalidate semantic cache, and audit-log the
write via Audit Service (best-effort).

- New db/write.rs: transactional write helper with rollback
- Audit client integration following Secrets Service pattern
- Remove #[allow(dead_code)] from provenance_config and sanitizer
- 15 new tests (7 db/write, 8 service-level)
- All 226 tests pass, clippy clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 10:54:38 +01:00
f314ed59bd Merge pull request 'fix: resolve tech debt from issue #33 review (#126)' (#132) from feature/issue-126-tech-debt-33-review into main 2026-03-10 10:37:07 +01:00