Skip to content

feat(hub): a filter on an upstream tool's result before the agent reads it (ADR-0069) - #505

Merged
7schmiede merged 1 commit into
mainfrom
feat/upstream-filter
Nov 10, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/upstream-filter

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

Agents read tickets through devstack's upstreams, and a ticket's description often holds the personal data of the people it is about. The only place to redact it before an agent reads it is between the upstream and the agent: in the hub. This adds a filter on an upstream tool's result: the hub runs a local command (such as veilq mark -, veilq ADR-0024) on fields of the result and hands the agent the command's text; when the command answers with write, the hub stores it back through the same upstream (save_issue), so the next read finds veilq's marker.

  • crates/devstack-hub/src/filters.rs: the filter, its check, paths (description, issues[*].description), running the command (exit 0 or 1 with {text, write?}, 30 s, its own process tree), applying it to a CallToolResult (text content parsed as JSON and structuredContent alike).
  • upstreams.rs: [[filter]] in upstreams.toml, run in call(), so it holds for every harness behind devstack mcp and for DEVSTACK_NO_HUB; write-backs; upstreams/filters.log (never content); removing an upstream removes its filters.
  • Routes GET/PUT /hub/upstreams/filters, POST /hub/upstreams/filters/test.
  • Dashboard: Filters on results on the MCP upstreams page, with a veilq-for-Linear preset and a field to try a filter on a text.
  • ADR-0069 addendum 2026-11-10, docs/dashboard-api.md, the devstack skill.

Review card

Approved by the owner in the conversation on 2026-11-10: all six points.

# Category Point Beats Reversing costs
1 trust The hub may replace part of an upstream tool's result with the output of a local command before devstack mcp gets it (amends ADR-0069, which left rewriting content out of scope). If wrong: a filter misconfigured to pass content through looks like protection. Asking the agent to run veilq itself (it has read the content by then) Medium: an addendum; filters users configured
2 trust Filters are configured per user only, on the user's upstream or an accepted pool upstream in upstreams.toml and the MCP upstreams page, never by a pool or a stack file: a filter runs a command, and a pool runs no command on a member's machine (ADR-0094). A pool handing out filters Low: a pool could offer one for acceptance later
3 contract A filter names the tool, one or more paths into the result's JSON (the text content parsed as JSON, and structuredContent alike; [*] steps through arrays) and the command. The command gets the field's string on stdin and answers JSON with text (required) and write (optional); exit 0 or 1 count as an answer. A veilq-specific switch Medium: the format has users
4 contract Optional write-back: a tool of the same upstream and its arguments, built from the call's arguments and the command's write (save_issue, {id: "$args.id", description: "$write"}), only for a path without [*]; the hub calls it with the user's login. Writing back from list results (needs each item's id) Low: additive
5 concept Fail closed: the command missing, failing (another exit code, a timeout), or answering without text, or a result that is not JSON where a filter applies, turns the tool call into an error; the raw content is never returned. An absent path means nothing to filter. A failed write-back still returns the filtered text and is logged. Passing the raw result on an error Low
6 concept Images behind URLs and keeping an agent away from other connectors to the tracker are out of scope; comments can be filtered by the same format, only not written back. Doing everything at once Low: additive

Decided while building (in the addendum): the command gets the hub's environment; every content item must be text holding JSON (an image or resource fails the call); an upstream's error result is handed on; the write-back runs before the hub answers (not in the background as first planned: simpler, one round trip per ticket); its tool need not be in the allowlist.

Checked

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test -p devstack-hub (158, 7 new, among them an end-to-end test through a fake upstream with write-back and fail-closed), cargo test -p devstack --test hub, cargo test -p devstack-skills; ui: typecheck, npm test, npm run build.
  • Against the real veilq 0.1.0 (Windows) on a synthetic body: exit 1, text/write as expected, name and phone number replaced in the filtered result.
  • The dashboard section in a lane against the mock hub (edit, try).
  • Not tried against a real Linear workspace (the write-back would change a real ticket).

Closes #502

🤖 Generated with Claude Code

…ds it (ADR-0069)

The hub runs a local command (such as `veilq mark -`) on fields of an
upstream tool's result before `devstack mcp` gets it, and stores the
command's `write` back through a tool of the same upstream. Filters are
the user's alone (`[[filter]]` in `upstreams.toml`, the MCP upstreams
page); they fail closed: no answer from the command fails the call.

Closes #502

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit 3cb46cc into main Nov 10, 2026
@7schmiede
7schmiede deleted the feat/upstream-filter branch November 10, 2026 15:55
@7schmiede 7schmiede mentioned this pull request Nov 10, 2026
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.

Upstream tools: run a result through a local filter (veilq mark) before the agent reads it

1 participant