Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@

---

## 📚🔀🛡️ feat(docs+mcp+hitl): docs for agents on every surface, an MCP resource bridge, and strict task-level toolApprovals (2026-08-11)

**Repo:** EDDI (`feat/agent-docs-and-hitl-strict`, branched from `main` @ 8dda2dab5). Four items, driven by the EDDI-Manager Platform Operator work (write-by-default + llmstore writes behind the Manager's gate-guard) and a critical rethink of each before building.

**1. `list_docs`/`read_docs` MCP tools (`McpDocTools`).** `docs/mcp-server.md` has documented `toolsWhitelist: ["read_docs", "list_docs"]` — tools that did not exist; anyone copying the example got a silently tool-less server (a whitelist that matches nothing exposes nothing). The two tools now exist, delegating to the same `DocsService` as REST and the `eddi://docs/*` resources, with the REST role enumeration mirrored via a new `McpToolUtils.requireAnyRole` (EDDI has no role hierarchy, so any-of-five must be spelled out). Rationale for tools *alongside* resources: agentic MCP clients — EDDI's own `McpToolProviderManager` included — consume `tools/list` and never call `resources/read`, so resources alone reach desktop clients and no agent.

**2. `eddi.docs.enabled` (default `true`).** One switch in `DocsService` turns every docs surface off together (REST list/read, MCP resources, MCP tools) — previously the only "off" was pointing `eddi.docs.path` at a nonexistent directory, which reads as a misconfiguration in every diagnostic. A policy deserves a switch, not a hack. Honest verdict from the rethink: low value, ~15 lines, kept because the cost is near-zero. Field initialized `= true` so plain-constructed instances (unit tests) match the CDI default.

**3. MCP resource bridge (`exposeResources` on mcpcalls configs).** Opt-in per config: synthesizes `<name>_list_resources` and `<name>_read_resource` tools so an agent can reach ANY MCP server's resources — the protocol half tool-consuming agents otherwise never see. Design decisions from the rethink: construction is purely local (executors dial lazily through the shared credential-keyed client cache, so an unreachable server costs an error tool *result*, not a discovery failure); deliberately NOT subject to `toolsWhitelist` (that filter governs server-advertised names; this feature has its own opt-in, and a pre-existing whitelist must not silently disable it — nor may a server occupy the synthesized names); text capped at 64K chars, binary described rather than base64-dumped; same static-config rejections as `discoverTools`, surfaced as `INVALID_CONFIGURATION` failures.

**4. Strict task-level `toolApprovals` (`eddi.hitl.tool.task-approvals.mode`, default `strict`).** The load-bearing one. A per-task `toolApprovals` used to FULLY REPLACE the agent-level gate (`task.getToolApprovals() != null ? task : agent`, duplicated in `LlmTask` + `ToolLoopResumer`) — so `requireApproval: []` buried in an llmstore document was a complete, reviewed-as-ordinary-config bypass. Under `strict`, a task block can only STRENGTHEN the agent gate; `replace` keeps the legacy wholesale override for designs that deliberately loosen one task.
The merge semantics came out of the critical pass, and one instinct died there: **exempt lists must NOT be string-intersected.** A task exempting a strict *subset* of the agent's patterns (`http.get:conversations*` vs `http.get:*`) shares no strings with it — intersection would silently gate every read. Since exempt beats require (`ToolApprovalGate` P1) and any-match suffices (P2), the sound per-field rules are: `requireApproval` = union (string-level union IS semantically exact for an any-match OR; neutralizes the `[]` bypass since `[] ∪ agent = agent`); `exempt` = agent's verbatim, task's ignored (a task-added exemption is precisely the ungating vector); `timeoutPolicy` = task's, but task `AUTO_APPROVE` demoted to `WAIT_INDEFINITELY` unless the agent itself grants it (generalizing the existing inherited-AUTO_APPROVE demotion); `maxAutoApprovalsPerTurn` = min; rules = task rules first with `AUTO_APPROVE` demoted, then agent rules; cosmetics = task-first. Both resolution sites now share `TaskToolApprovalsResolver` (mode via `ConfigProvider`, precedented in `AgentOrchestrator`/`DeploymentContextCondition`, since `ToolLoopResumer` is not a CDI bean). `LlmStore` warns at save time about task `exempt`/`AUTO_APPROVE` that strict mode will not honour — visibility, not rejection, so stored configs never brick and `replace` mode still honours them.
`LlmTaskCoverageTest.toolApprovals_taskOverrideUsed` deliberately updated: it pinned the replace semantics (`assertSame(override, effective)`); it now pins the strict merge threaded to the orchestrator, with the full contract (replace mode included) in `TaskToolApprovalsResolverTest` (16 tests).
**Second critical pass caught one more loosening vector:** an unset agent-level `maxAutoApprovalsPerTurn` is not "no cap" — the runtime resolves it to `DEFAULT_MAX_AUTO_APPROVALS_PER_TURN` (2) — so a naive `min(null-as-absent, task)` let a task state 10 and raise the effective budget. Today the fixed `carried >= 2` no-progress hard threshold happens to bound the damage, but the resolver's "budget may only shrink" contract must not depend on a distant guard staying fixed. The default constant moved to `ToolApprovalsConfig` (single source; `ConversationHitlService` aliases it) and the strict merge clamps a stated task value to `min(task, agent ?? default)`.

**Downstream (EDDI-Manager):** strict-by-default is what lets the Manager's `gate-guard.ts` eventually relax from "refuse any llmstore write carrying `toolApprovals`" to allowing it — the field would no longer be able to weaken anything. Not relaxed yet; the Manager guard stays until this ships.

**Tests:** 76 in the touched areas green (16 resolver, 7 McpDocTools, 5 bridge, 5 RestDocs unchanged, 43 LlmTask coverage). Mass `Unable to establish loopback connection` errors in `A2AToolProviderManager*`/`Embedding*` tests are the documented sandbox socket limitation (AGENTS.md §Build & Test), not regressions — CI is the source of truth there.

**Docs:** `mcp-server.md` (tool count 74→76, new "Docs Tools" section, `exposeResources` row), `hitl.md` (precedence row rewritten for the two modes), `application.properties` (both new properties documented inline).
---

## 📖 docs(vault): document allowedAgents enforcement, and correct the javadoc that denies it (2026-08-11)

**Repo:** EDDI (`docs/vault-grant-enforcement`)
Expand Down Expand Up @@ -721,7 +743,7 @@ First of the three pre-feature defects from `planning/group-collaboration-NEXT.m

- **`LlmConfiguration.Task` gains `inputPricePer1M`/`outputPricePer1M`** — same names and nullable semantics as the cascade fields (null = unpriced, contributes $0), so nothing changes for anyone not setting prices. Config-driven per Golden Rule 1: no hardcoded provider price table — it would be wrong within weeks.
- **The pricing arithmetic now lives once, in `TokenPricing.cost()`.** `CascadingModelExecutor.computeCost` (step→cascade price resolution) and `LlmTask.accumulateAuditEvidence` (task-level prices for plain calls) both delegate — the formula cannot drift between paths (§4.7 unification rule).
- **Precedence is explicit, not accidental:** `accumulateAuditEvidence` discriminates on the presence of the `cascadeCostUsd` metadata key, which the cascade branch always writes. A cascade run is priced by its steps alone; task-level prices apply only to non-cascade calls — cascade steps may target entirely different models, so inheriting the task price would price the wrong model. (This matches the precedence concern pre-filed in `docs/superpowers/specs/2026-07-21-manager-coverage-backend-design.md`.) Pinned by a test with deliberately absurd task prices on a cascade turn.
- **Precedence is explicit, not accidental:** `accumulateAuditEvidence` discriminates on the presence of the `cascadeCostUsd` metadata key, which the cascade branch always writes. A cascade run is priced by its steps alone; task-level prices apply only to non-cascade calls — cascade steps may target entirely different models, so inheriting the task price would price the wrong model. (This matches the precedence concern pre-filed in `planning/manager-coverage-backend-design.md`.) Pinned by a test with deliberately absurd task prices on a cascade turn.
- **Validation:** negative task-level prices fail deployment (`CascadeConfigValidator`, same new-field hard-error rationale as cascade pricing; the validator now also runs its task-level block for cascade-less tasks).
- **`GroupCostLedger`'s "Known gap (V1)" Javadoc** rewritten — the gap is closed; `totalCost` remains a lower bound only for members whose configs carry no prices.

Expand Down Expand Up @@ -4163,7 +4185,7 @@ Backlog item **D9**, part 3 of 3 — documentation only, no behaviour change.
**Decision: keep the method, document the gap loudly — do not delete it, and do not wire it here.**

- *Not deleted*, because removing it would take away the seam without taking away the gap: `checkCostBudget` stays wired, `ITenantQuotaStore.tryAddCost` stays on the interface, all three stores implement it, and it is now covered by `TenantQuotaStoreParityTest`. A reader would be left with a half-system and no marker.
- *Not wired*, because there is nothing meaningful to meter yet. Built-in tool executions are priced at $0.00, and there is no token-cost metering for LLM turns at all — wiring today would add write load and record zeros. The candidate call sites are the `ChatResponse`-holding seams tracked as C5 in `docs/superpowers/specs/2026-07-21-manager-coverage-backend-design.md`, whose own notes named the Mongo E11000 (fixed in part 1 of this item) as its blocker. That blocker is now gone.
- *Not wired*, because there is nothing meaningful to meter yet. Built-in tool executions are priced at $0.00, and there is no token-cost metering for LLM turns at all — wiring today would add write load and record zeros. The candidate call sites are the `ChatResponse`-holding seams tracked as C5 in `planning/manager-coverage-backend-design.md`, whose own notes named the Mongo E11000 (fixed in part 1 of this item) as its blocker. That blocker is now gone.

Both `recordCost` and `checkCostBudget` carry javadoc saying this outright, including the two things that must land first.

Expand Down
4 changes: 2 additions & 2 deletions docs/hitl.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ The gate lives in the tool-execution loop (`AgentOrchestrator`), so it is **fail
`toolApprovals` has two homes, both optional:

- **Agent-level default** — `AgentConfiguration.hitlConfig.toolApprovals` (applies to every LLM task in the agent).
- **Per-task override** — `LlmConfiguration.task[n].toolApprovals` (a langchain task). This is a **full replace**, not a merge: if a task defines `toolApprovals`, its block is used verbatim and the agent-level block is ignored for that task.
- **Per-task override** — `LlmConfiguration.task[n].toolApprovals` (a langchain task). How it combines with the agent-level block is decided by `eddi.hitl.tool.task-approvals.mode`: under the default **`strict`** the task block can only *strengthen* the agent gate (patterns are united, task-level `exempt` is ignored, task-level `AUTO_APPROVE` is demoted); under **`replace`** it is a full replace and the agent-level block is ignored for that task — the pre-6.3.0 behavior. See [Precedence](#precedence) for the per-field rules.

```json
{
Expand Down Expand Up @@ -312,7 +312,7 @@ Patterns are matched by `ToolApprovalPatterns` / `ToolApprovalGate`:

| Rule | Behavior |
|------|----------|
| **Task replaces agent** | A per-task `toolApprovals` is a **full replace** of the agent-level block — no field-level merge. |
| **Task combines with agent per `eddi.hitl.tool.task-approvals.mode`** | **`strict` (default):** the task block can only STRENGTHEN the agent gate — `requireApproval` is the union of both lists, task-level `exempt` entries are ignored (exempt beats require, so a task-added exemption is precisely the ungating vector), task-level `AUTO_APPROVE` (scalar or rule) is demoted to `WAIT_INDEFINITELY` unless the agent-level policy itself grants it, and `maxAutoApprovalsPerTurn` takes the minimum. **`replace` (legacy):** a present task block is a full replace of the agent-level block — the pre-6.3.0 behavior, for designs that deliberately loosen one task. See `TaskToolApprovalsResolver`. |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
| **Exempt beats require** | If a call matches any `exempt` pattern, it runs — even if it also matches `requireApproval`. |
| **Absent/empty `requireApproval` = gate off** | No `requireApproval` patterns → the gate is fully inactive; every call runs. |
| **Any match suffices** | A call is gated if it matches *any* `requireApproval` pattern (and no `exempt` pattern). |
Expand Down
14 changes: 12 additions & 2 deletions docs/mcp-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EDDI uses **Streamable HTTP** transport, served by the Quarkus MCP Server extens
| --------------------------- | ------------------------------------- |
| `http://localhost:7070/mcp` | MCP server endpoint (default + admin) |

## Available Tools (74)
## Available Tools (76)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

### Conversation Tools (11)

Expand Down Expand Up @@ -101,6 +101,15 @@ EDDI uses **Streamable HTTP** transport, served by the Quarkus MCP Server extens

See [Group Conversations](group-conversations.md) for full style details, custom phases, and nested groups.

### Docs Tools (2)

Read EDDI's own documentation over MCP **tools** — the counterpart to the `eddi://docs/*` **resources** below, and the pair the `toolsWhitelist: ["read_docs", "list_docs"]` example further down consumes. Tools and resources serve different clients: agentic MCP clients (EDDI's own included) consume `tools/list` and never call `resources/read`, so before these existed EDDI's docs were readable by a desktop client and not by any agent consuming EDDI's MCP server. Role set mirrors the REST docs endpoints exactly (any of the five roles). Both delegate to `DocsService`, so `eddi.docs.enabled=false` switches this surface off together with REST and the resources.

| Tool | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------- |
| `list_docs` | List the documentation pages this deployment serves (one name per line, no `.md` suffix). Read this first — the runtime set is smaller than the repository's |
| `read_docs` | Read one page as markdown by name, e.g. `architecture`. Distinguishes an invalid name from an absent page |

### HITL Tools (9)

Resolve Human-in-the-Loop approval gates over MCP — the counterpart to the REST HITL endpoints, at parity for both the regular (1:1) and group surfaces. Authorization mirrors REST exactly (per-conversation owner / `eddi-admin` / `eddi-approver` via the shared `HitlAccessGuard`); decisions are attributed server-side as `mcp:<principal>`. Mutating tools honour the `eddi.mcp.hitl.mutations.enabled` kill-switch and return structured errors (`errorCode` ∈ `NOT_FOUND | WRONG_STATE | FORBIDDEN | DISABLED | BAD_REQUEST`).
Expand Down Expand Up @@ -584,7 +593,7 @@ eddi.docs.path=docs

EDDI uses a **whitelist-based `ToolFilter`** (`McpToolFilter.java`) to control which tools are exposed via MCP.

**Why?** EDDI's langchain4j integration registers internal agent tools (calculator, datetime, websearch, etc.) that are meant ONLY for agent pipeline execution — not for external MCP clients. The `ToolFilter` SPI only sees a tool's *name* (not its declaring class or annotation type), so the whitelist is by name. It currently exposes all 74 intended tools — conversation, admin/resource/schedule/channel, setup, group, **HITL approvals** (`McpHitlTools`), **persistent user memory** (`McpMemoryTools`), and **GDPR/CCPA** (`McpGdprTools`).
**Why?** EDDI's langchain4j integration registers internal agent tools (calculator, datetime, websearch, etc.) that are meant ONLY for agent pipeline execution — not for external MCP clients. The `ToolFilter` SPI only sees a tool's *name* (not its declaring class or annotation type), so the whitelist is by name. It currently exposes all 76 intended tools — conversation, admin/resource/schedule/channel, setup, group, **HITL approvals** (`McpHitlTools`), **persistent user memory** (`McpMemoryTools`), **GDPR/CCPA** (`McpGdprTools`), and **docs** (`McpDocTools`).

To add a new MCP tool: add its name to the `MCP_TOOLS` set in `McpToolFilter.java`. A quarkus-MCP `@Tool` has no other invocation path, so a tool that is *not* whitelisted is unreachable dead code. `McpToolFilterTest.test_allMcpToolMethods_areWhitelisted()` auto-discovers every `@Tool` in the `engine.mcp` package and fails the build if any is missing from the whitelist — so forgetting this step is caught by CI.

Expand Down Expand Up @@ -675,6 +684,7 @@ External MCP servers are configured as **`mcpcalls` workflow extensions** — a
| `toolsWhitelist` | string[] | No | — | If non-empty, only these tool names are exposed (names as returned by the server's `tools/list`) |
| `toolsBlacklist` | string[] | No | — | Tool names to exclude. Applied *after* the whitelist |
| `mcpCalls` | object[] | No | — | Deterministic, action-triggered tool bindings (see *Pipeline mode* below). Omit for agent-mode-only servers |
| `exposeResources` | boolean | No | `false` | Opt-in bridge for the server's MCP **resources**: synthesizes `<name>_list_resources` and `<name>_read_resource` tools so the agent can list and read them (text capped at 64K chars, binary described, not returned). Independent of the whitelist/blacklist, which govern server-advertised names |

#### How `create_api_agent` builds a write tool's body

Expand Down
Loading
Loading