Skip to content

feat(a2a): trusted internal networks — call agents across your own instances over a private network without keys (abilityai/trinity-enterprise#838) - #3361

Merged
vybe merged 4 commits into
devfrom
feature/ent838-a2a-trusted-networks
Oct 8, 2026
Merged

vybe merged 4 commits into
devfrom
feature/ent838-a2a-trusted-networks

Conversation

@dolho

@dolho dolho commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Instances on one private network (a tailnet, a VPN) can call each other's agents over it, with no keys and nothing public. Setup is one step on each side after an admin declares the network.

  • Trusted networks (admin and human only): GET/PUT /api/settings/a2a-trusted-networks. Entries are CIDRs, exact hosts or *.domain, plus an optional internal_base_url. Refused by name:

    • the platform's own Docker networks;
    • loopback, link-local (cloud metadata), reserved and multicast ranges;
    • anything broader than /8;
    • a one-label wildcard;
    • any range that holds the gateway of a network the backend is attached to (found in the live test; see below).

    The generic PUT /api/settings/{key} refuses both keys.

  • Outbound: an endpoint on a trusted network may be private/CGNAT and http://. Every other endpoint gets exactly today's refusal. It is re-checked on every call, so a trusted name that resolves outside the declared CIDRs, or onto metadata, loopback or the platform networks, is refused. Pinning is unchanged.

  • Inbound scope: agent_ownership.a2a_scope (public | internal) and a2a_keyless_internal (default on).

    • An internal agent answers only a trusted source, never the public tunnel. To anyone else it is unexposed: card 404, keyed 404, anonymous 401.
    • A trusted caller runs a task with no key, rate-limited per source and per agent, attributed in the new schedule_executions.source_host. tasks/get and tasks/cancel see only that host's tasks.
    • With keyless off, a trusted caller needs a key.
  • Source detection: the TCP peer, or X-Real-IP only from the platform proxy container, resolved by name. An agent on the bridge cannot forge its source. nginx and the Vite dev proxy (now) both overwrite the header. cloudflared's headers mark a request public.

  • Outbound card discovery: the registered endpoint's own card is tried before the origin's. Trinity publishes per-agent cards only, so origin-only discovery meant one Trinity could not reach another's agent at all, public or internal. A registered card URL is fetched as given. Only a 404 falls through. The same-origin and path pins are unchanged.

  • Card and UI: an internal-scope agent's card advertises the internal base URL. The A2A tab gets "Who can reach it", the keyless switch and the URL to register.

  • Open-core: OSS-core enforcement; the scope setter is the entitled enterprise exposure route (trinity-enterprise PR, draft until this lands). Docs describe the mechanism only, with placeholder hostnames.

Live test (local stack, this branch)

The backend was attached to a separate Docker network as a stand-in for a tailnet peer.

Check Result
Trust a /24 holding the backend's gateway 422, names the gateway
Internal card: trusted caller / untrusted caller / Cf-Ray / host 200 (internal URL) / 404 / 404 / 404
Keyless message/send: trusted / untrusted completed / 401
Execution row triggered_by=a2a, source_host=<caller>, no user or key
tasks/get from another trusted host Task not found
Register untrusted http:// private endpoint refused as before
Agent → agent over the internal URL, no key completed; provider run attributed to the calling instance
Keyless switch off trusted caller gets 401

Found and fixed during the live test:

  1. Docker's userland proxy hands a host-forwarded call (a published port, hairpin NAT) to the backend from a bridge gateway. Trusting a range holding that gateway made the host itself a keyless caller. Such a range is refused on write, and such a source is never trusted at runtime.
  2. The card-discovery gap above.

Not testable locally: a real tailnet source (100.x) arriving at the published port. On Linux, traffic on an external interface is DNAT'd with the source kept, but this needs one check between two real instances.

Screenshots of the A2A tab (light and dark): to be attached by the author.

Tests

  • tests/unit/test_ent838_a2a_trusted_networks.py (new, 37): the list guards, outbound trusted path, source rules, the gateway parser and both refusals, and the router (internal unexposed, keyless run plus attribution, task isolation, keyless off, public unchanged), plus storage round-trip.
  • test_736_a2a_outbound_transport.py: discovery order (own card, origin fallback on 404 only, registered card URL); 82 passed.
  • Fakes in 6 A2A suites gain get_a2a_scope (public). test_1028 allowlists the two new routes.
  • Locally: 284 passed across the touched suites. test_736_a2a_outbound_edges::C1b (5) fails identically on dev locally (Python 3.12 ipaddress); CI runs 3.13.
  • Enterprise: tests/test_838_a2a_internal_scope.py (5) plus test_160 give 29 passed.

Fixes abilityai/trinity-enterprise#838

🤖 Generated with Claude Code

…stances over a private network without keys (trinity-enterprise#838)

An admin declares the instance's private networks once
(PUT /api/settings/a2a-trusted-networks: CIDRs, hosts, *.domain).

- Outbound: an endpoint on a trusted network may be private/CGNAT and
  http://; every other endpoint keeps the public-HTTPS rule. Re-checked on
  every call, so a trusted name resolving outside the declared CIDRs, or
  onto metadata/loopback/the platform networks, is refused.
- Inbound: agent_ownership.a2a_scope (public|internal) and
  a2a_keyless_internal. An internal agent answers only a trusted source
  and never the public tunnel; to anyone else it is unexposed. A trusted
  caller runs a task with no key, rate-limited, attributed in the new
  schedule_executions.source_host, and reads only its own tasks.
- The source is the TCP peer, or X-Real-IP only from the platform proxy
  container; cloudflared's headers mark a request public; a gateway of a
  network the backend sits on is never a source and never trustable.
- Outbound discovery tries the registered endpoint's own card before the
  origin's: Trinity publishes per-agent cards only, so one Trinity could
  not discover another's agent at all.
- Internal-scope cards advertise the admin's internal base URL; the A2A
  panel gets the scope choice, the keyless switch and the URL to register.
- Migrations: SQLite a2a_internal_scope, Alembic 0095_a2a_internal_scope.

The scope setter is the entitled enterprise exposure route (private PR).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dolho dolho added the ui PR touches the frontend UI — triggers Playwright e2e tests label Oct 8, 2026
@dolho

dolho commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Pairs with Abilityai/trinity-enterprise#845 (draft): the entitled exposure-route setter for scope and keyless. That PR goes green once this one is on dev.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

⚠️ Alembic head fork if this PR is merged into dev.

dev has advanced since this PR's checks last ran. GitHub recomputes the merge ref when the base moves but does not re-trigger workflows, so a green schema-parity here can describe a base that no longer exists (#2533).

scripts/ci/check_alembic_heads.py against dev + this PR, merged in memory
alembic-heads: FAIL — src/backend/migrations/versions resolves to 2 heads across 97 revision(s); exactly 1 is required.
  • 0095_a2a_internal_scope  (0095_a2a_internal_scope.py)
  • 0095_portal_messages_execution_id  (0095_portal_messages_execution_id.py)

They fork at: 0094_agent_skill_gates  (0094_agent_skill_gates.py)

`alembic upgrade head` is singular and resolves its target BEFORE applying anything,
so this graph applies ZERO revisions — every revision since the fork stops arriving,
not only the one that forked. Fix by chaining the newer revision off the real head,
or — if the forked revision may already be applied somewhere — by adding a merge
revision (`alembic merge -m "…" <head-a> <head-b>`), whose tuple `down_revision`
converges the line from any starting state. See Architectural Invariant #3.
alembic-heads: src/backend/enterprise/backend/migrations/versions — version directory absent (submodule not initialised) — skipped.

Evaluated on the version line only — this PR also conflicts with dev in 2 unrelated file(s), which do not change this verdict but must be resolved before merge:

src/backend/db/migrations.py
tests/registry.json

Fix: rechain this PR's revision off 0095_portal_messages_execution_id (the current dev head), or — if the forked revision may already be applied somewhere — add a merge revision (alembic merge -m "…" 0095_a2a_internal_scope 0095_portal_messages_execution_id), whose tuple down_revision converges the line from any starting state. See Architectural Invariant #3.

Push the fix and schema-parity re-checks it against the merge ref immediately; this comment clears on the next push to dev touching src/backend/migrations/versions/**.

Advisory — this check does not block merge. · head_sha: c2064d990ad5cb14fa0b6f8e5e779ea336e7b3f5 · run

dolho and others added 2 commits October 8, 2026 13:11
Re-chain the A2A scope revision: dev took 0095 with
0095_portal_messages_execution_id off 0094, so this one is now
0096_a2a_internal_scope off it (1 head, parity PASS).
migrations.py and tests/registry.json: keep both, dev's entries first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…caller plainly (#3361 CI)

- build: the hand-rolled radios/checkbox/copy row added 28 raw gray
  classes and the raw-colour ratchet fails on growth. The block now uses
  BaseSelect (scope, with the explanation as its help), BaseToggle (the
  keyless switch — an instant-apply binary, the toggle's stated use) and
  a read-only BaseInput + BaseButton for the URL to register. A2aPanel
  is back at its baseline (104). New mounted spec a2aPanelScope.spec.js.
- CodeQL py/clear-text-logging-sensitive-data: the idempotency scope now
  carries the trusted caller's ADDRESS, held in a variable named
  keyless_source, and the 'key' in the name read as a secret. Renamed to
  trusted_caller; the value is an IP address, never a credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dolho
dolho requested a review from vybe October 8, 2026 10:27
@dolho

dolho commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Evidence: live backend checks, tests, CI

1. Live backend run: 18 / 18 pass

Run against a local stack on this branch. A real tailnet can't exist on one machine, so a separate Docker network stands in for it: the backend is attached to it, and curl containers on it play "a host on our network" (trusted, .50) and "a stranger" (.51). proj-beta is the agent being called; proj-alpha is the caller. The enterprise half is trinity-enterprise#845.

--- setup
  waiting for the backend to see its new network (gateway cache, 60s)…
--- 1. the admin list
  PASS  a range holding the backend's Docker gateway is refused  (422)
  PASS  the platform's own network is refused  (422)
  PASS  the generic settings PUT cannot write the list  (422)
  PASS  a narrow list is accepted  (200)
--- 2. internal scope on proj-beta
  PASS  card, from a trusted host  (200)
  PASS  card advertises the internal URL  (http://172.31.239.2:8000/a2a/proj-beta)
  PASS  card, from a stranger  (404)
  PASS  card, trusted host but via the public tunnel (Cf-Ray)  (404)
  PASS  card, from this machine (public side)  (404)
--- 3. a keyless task
  PASS  a stranger without a key  (401)
  PASS  a trusted host without a key — task completes  (completed)
  PASS  the run is attributed to the caller's address  (a2a|172.31.239.50|None|None)
  PASS  tasks/get by the host that started it  (completed)
  PASS  tasks/get by another trusted host  (Task not found)
--- 4. agent → agent over the internal URL (outbound)
  PASS  an untrusted http:// private endpoint is still refused  (422)
  PASS  the trusted internal endpoint is accepted  (200)
  PASS  proj-alpha calls proj-beta with no key  (completed)
        answer: hello over the internal network
--- 5. keyless off
  PASS  a trusted host now needs a key  (401)

=== 18 passed, 0 failed
--- cleanup
  done

What each section proves:

  • 1, the admin list: the guards hold at the API, including the generic PUT /api/settings/{key} back door.
  • 2, card visibility: an internal agent is unexposed to everyone outside the trusted network. That includes a trusted address arriving through the public tunnel, and the instance's own host.
  • 3, keyless execution:
    • a stranger gets the unexposed 401;
    • a trusted host's task completes, recorded on the row as triggered_by=a2a with source_host set and no user or key;
    • another trusted host cannot read that task.
  • 4, end to end: one agent tasks another over the internal URL with no key, and the answer comes back. The untrusted http:// refusal is unchanged.
  • 5, the switch: with keyless off, a trusted host needs a key.

The script restores everything it changes (list, exposure, endpoint, outbound switch, network); the state was verified after the run.

The script (re-run it on any local stack running this branch)
#!/usr/bin/env bash
# ent#838 backend check — trusted internal networks for A2A, against a LOCAL
# stack (backend :8000 running this branch).
#
# A real tailnet can't be produced locally, so a separate Docker network stands
# in for it: the backend is attached to it, and small curl containers on it
# play "a host on our private network" (trusted) and "a stranger" (untrusted).
#
# What it changes, and puts back at the end (also on failure):
#   trusted-networks list, proj-beta exposure, one outbound endpoint,
#   the outbound A2A switch, the Docker network `ent838-check`.
#
# Usage:  ADMIN_PASSWORD=... ./ent838-backend-check.sh     (or set ENV_FILE to the stack's .env)
set -uo pipefail

API=http://localhost:8000
NET=ent838-check
SUBNET=172.31.239.0/24
BACKEND_IP=172.31.239.2
TRUSTED_IP=172.31.239.50
STRANGER_IP=172.31.239.51
PROVIDER=proj-beta        # the agent being called (gets internal scope)
CALLER=proj-alpha         # the agent that calls it (outbound)
ENV_FILE=${ENV_FILE:-.env}   # the checkout the stack runs from

PW=${ADMIN_PASSWORD:-$(grep '^ADMIN_PASSWORD=' "$ENV_FILE" | cut -d= -f2-)}
T=$(curl -s -X POST "$API/api/token" -d "username=admin&password=$PW" \
    | python3 -c 'import sys,json;print(json.load(sys.stdin)["access_token"])')
H="Authorization: Bearer $T"
J="Content-Type: application/json"
pass=0; fail=0
check() {  # check "<name>" "<expected>" "<actual>"
  if [ "$2" = "$3" ]; then echo "  PASS  $1  ($3)"; pass=$((pass+1));
  else echo "  FAIL  $1  expected [$2] got [$3]"; fail=$((fail+1)); fi
}
peer() {   # peer <ip> <curl args...>  — a host on the test network
  local ip=$1; shift
  docker run --rm --network $NET --ip "$ip" curlimages/curl:latest -s "$@"
}

cleanup() {
  echo "--- cleanup"
  curl -s -X DELETE -H "$H" "$API/api/settings/a2a-endpoints/ent838-check" -o /dev/null
  curl -s -X PUT -H "$H" -H "$J" "$API/api/enterprise/a2a/$PROVIDER/exposure" \
       -d '{"enabled":false,"scope":"public","keyless":true}' -o /dev/null
  curl -s -X POST -H "$H" "$API/api/agents/$PROVIDER/stop" -o /dev/null
  docker exec trinity-backend python -c "
import sqlite3;c=sqlite3.connect('/data/trinity.db')
c.execute(\"delete from system_settings where key in ('a2a_trusted_networks','a2a_internal_base_url')\")
${RESTORE_OUTBOUND:-}
c.commit()" 2>/dev/null
  docker network disconnect $NET trinity-backend 2>/dev/null
  docker network rm $NET >/dev/null 2>&1
  echo "  done"
}
trap cleanup EXIT

echo "--- setup"
WAS_OUTBOUND=$(docker exec trinity-backend python -c "
import sqlite3;c=sqlite3.connect('/data/trinity.db')
r=c.execute(\"select value from system_settings where key='a2a_outbound_enabled'\").fetchone();print(r[0] if r else '')" 2>/dev/null)
if [ -z "$WAS_OUTBOUND" ]; then
  RESTORE_OUTBOUND="c.execute(\"delete from system_settings where key='a2a_outbound_enabled'\")"
else
  RESTORE_OUTBOUND="c.execute(\"update system_settings set value='$WAS_OUTBOUND' where key='a2a_outbound_enabled'\")"
fi
docker network create --subnet $SUBNET $NET >/dev/null
docker network connect --ip $BACKEND_IP $NET trinity-backend
docker pull -q curlimages/curl:latest >/dev/null
curl -s -X POST -H "$H" "$API/api/agents/$PROVIDER/start" -o /dev/null
echo "  waiting for the backend to see its new network (gateway cache, 60s)…"; sleep 61

echo "--- 1. the admin list"
check "a range holding the backend's Docker gateway is refused" 422 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a-trusted-networks" -d "{\"entries\":[\"$SUBNET\"]}")"
check "the platform's own network is refused" 422 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a-trusted-networks" -d '{"entries":["172.28.0.0/16"]}')"
check "the generic settings PUT cannot write the list" 422 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a_trusted_networks" -d '{"value":"[\"0.0.0.0/0\"]"}')"
check "a narrow list is accepted" 200 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a-trusted-networks" \
     -d "{\"entries\":[\"$TRUSTED_IP/32\",\"$BACKEND_IP/32\"],\"internal_base_url\":\"http://$BACKEND_IP:8000\"}")"

echo "--- 2. internal scope on $PROVIDER"
curl -s -X PUT -H "$H" -H "$J" "$API/api/enterprise/a2a/$PROVIDER/exposure" \
     -d '{"enabled":true,"scope":"internal","keyless":true}' -o /dev/null
sleep 20   # agent start + the trusted list's 5s cache
CARD="http://$BACKEND_IP:8000/a2a/$PROVIDER/.well-known/agent-card.json"
check "card, from a trusted host" 200 "$(peer $TRUSTED_IP -o /dev/null -w '%{http_code}' $CARD)"
check "card advertises the internal URL" "http://$BACKEND_IP:8000/a2a/$PROVIDER" \
  "$(peer $TRUSTED_IP $CARD | python3 -c 'import sys,json;print(json.load(sys.stdin).get("url"))')"
check "card, from a stranger" 404 "$(peer $STRANGER_IP -o /dev/null -w '%{http_code}' $CARD)"
check "card, trusted host but via the public tunnel (Cf-Ray)" 404 \
  "$(peer $TRUSTED_IP -o /dev/null -w '%{http_code}' -H 'Cf-Ray: x' $CARD)"
check "card, from this machine (public side)" 404 \
  "$(curl -s -o /dev/null -w '%{http_code}' "$API/a2a/$PROVIDER/.well-known/agent-card.json")"

echo "--- 3. a keyless task"
RPC="http://$BACKEND_IP:8000/a2a/$PROVIDER"
BODY='{"jsonrpc":"2.0","id":1,"method":"message/send","params":{"message":{"role":"user","messageId":"m-838-check-'$RANDOM'","parts":[{"kind":"text","text":"Reply with exactly: internal call received"}]}}}'
check "a stranger without a key" 401 \
  "$(peer $STRANGER_IP -o /dev/null -w '%{http_code}' -X POST -H "$J" -d "$BODY" $RPC)"
OUT=$(peer $TRUSTED_IP -m 180 -X POST -H "$J" -d "$BODY" $RPC)
TASK=$(echo "$OUT" | python3 -c 'import sys,json;print(json.load(sys.stdin)["result"]["id"])' 2>/dev/null)
check "a trusted host without a key — task completes" completed \
  "$(echo "$OUT" | python3 -c 'import sys,json;print(json.load(sys.stdin)["result"]["status"]["state"])' 2>/dev/null)"
check "the run is attributed to the caller's address" "a2a|$TRUSTED_IP|None|None" \
  "$(docker exec trinity-backend python -c "
import sqlite3;c=sqlite3.connect('/data/trinity.db')
r=c.execute(\"select triggered_by,source_host,source_user_id,source_mcp_key_id from schedule_executions where id='$TASK'\").fetchone()
print('|'.join(str(x) for x in r))" 2>/dev/null)"
GET='{"jsonrpc":"2.0","id":2,"method":"tasks/get","params":{"id":"'$TASK'"}}'
check "tasks/get by the host that started it" completed \
  "$(peer $TRUSTED_IP -X POST -H "$J" -d "$GET" $RPC | python3 -c 'import sys,json;print(json.load(sys.stdin)["result"]["status"]["state"])' 2>/dev/null)"
check "tasks/get by another trusted host" "Task not found" \
  "$(docker exec trinity-backend python -c "
import httpx,json;print(httpx.post('$RPC',json=json.loads('''$GET''')).json()['error']['message'])" 2>/dev/null)"

echo "--- 4. agent → agent over the internal URL (outbound)"
curl -s -X PUT -H "$H" -H "$J" "$API/api/settings/a2a_outbound_enabled" -d '{"value":"true"}' -o /dev/null
check "an untrusted http:// private endpoint is still refused" 422 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a-endpoints" \
     -d '{"name":"ent838-untrusted","url":"http://172.31.239.9:8000/a2a/x"}')"
check "the trusted internal endpoint is accepted" 200 \
  "$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$H" -H "$J" "$API/api/settings/a2a-endpoints" \
     -d "{\"name\":\"ent838-check\",\"url\":\"http://$BACKEND_IP:8000/a2a/$PROVIDER\"}")"
CALL=$(curl -s -m 200 -X POST -H "$H" -H "$J" "$API/api/agents/$CALLER/a2a/call" \
  -d '{"endpoint":"ent838-check","message":"Reply with exactly: hello over the internal network","dedup_label":"ent838-check-'$RANDOM'"}')
check "$CALLER calls $PROVIDER with no key" completed \
  "$(echo "$CALL" | python3 -c 'import sys,json;print(json.load(sys.stdin).get("state"))' 2>/dev/null)"
echo "        answer: $(echo "$CALL" | python3 -c 'import sys,json;print(json.load(sys.stdin).get("text"))' 2>/dev/null)"

echo "--- 5. keyless off"
curl -s -X PUT -H "$H" -H "$J" "$API/api/enterprise/a2a/$PROVIDER/exposure" -d '{"enabled":true,"keyless":false}' -o /dev/null
check "a trusted host now needs a key" 401 \
  "$(peer $TRUSTED_IP -o /dev/null -w '%{http_code}' -X POST -H "$J" -d "$BODY" $RPC)"

echo
echo "=== $pass passed, $fail failed"
[ "$fail" -eq 0 ]

2. Found by the live test and fixed in this PR

  1. Docker gateway trap. A host-forwarded call (a published port, hairpin NAT) reaches the backend FROM the gateway of a network the backend is attached to. Trusting a range holding that gateway made the host itself a keyless caller. Such a range is now refused on write (check 1.1), and that source is never trusted at runtime.
  2. Trinity → Trinity card discovery. The outbound client looked for the card only at the origin, and Trinity serves cards per agent. The registered endpoint's own card is now tried first; only a 404 falls through to the origin. Check 4.3 depends on it.

3. Tests

  • tests/unit/test_ent838_a2a_trusted_networks.py: 37 passed.
  • test_736_a2a_outbound_transport.py: 82 passed (discovery order: own card, origin on 404 only, registered card URL).
  • Touched A2A, settings and registry suites after merging dev: 222 passed.
  • src/frontend/tests/unit/a2aPanelScope.spec.js (new, mounted): 6 passed. The raw-colour and loading-gate ratchets pass.
  • Enterprise (trinity-enterprise#845): test_838_a2a_internal_scope.py + test_160_a2a.py, 29 passed.

4. CI fixes since the PR opened

  • alembic-head-watch: dev took 0095 (0095_portal_messages_execution_id). Merged dev and re-chained to 0096_a2a_internal_scope (1 head, parity PASS).
  • build (raw-colour ratchet): the scope controls are now primitives (BaseSelect, BaseToggle, read-only BaseInput + BaseButton). A2aPanel.vue is back at its baseline.
  • CodeQL py/clear-text-logging-sensitive-data: the idempotency scope carries the trusted caller's IP address, held in a variable named keyless_source; the key in the name read as a secret. It is renamed trusted_caller. The value is an address, never a credential.

5. Not covered locally

A real tailnet source (100.x) arriving at the published port. On Linux the external-interface DNAT keeps the source address, but this needs one check between two real instances before relying on keyless trust in production.

Screenshots of the "Who can reach it" controls (light and dark): to be attached by the author.

🤖 Generated with Claude Code

…sted-source helpers past CodeQL's secret heuristic (#3361 CI)

Three CI reds on the PR, none a design change:

- `frozen_dispatch` refused every real dispatch with "unclassified
  execute_task fields ['source_host']" (ent#751 landed on dev after this
  branch forked). The field is caller attribution, the same class as the
  other `source_*` identity fields, so it is FREEZE: an approved replay stays
  attributed to the same host. `test_1482` covers the new column.
- `test_2996` route census: the admin gate is now the first statement of both
  `/api/settings/a2a-trusted-networks` handlers (the belt-and-braces
  `reject_agent_principal` import no longer precedes it).
- CodeQL `py/clear-text-logging-sensitive-data`: its heuristic treats any
  name containing "trusted" as a secret, so `trusted_source()` / the
  `trusted_caller` local tainted the idempotency scope that
  `idempotency_service.begin` logs on a claim failure. The value is a caller
  address, not a secret; renamed to `internal_source` / `caller_source`.
  No behaviour change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr (Lane C + schema). Tier 1 green on 041dec4 after the CI fixes (frozen-dispatch classification for source_host, route-census gate order, CodeQL rename); journey-smoke + e2e green on the PR; Alembic single head on a merge-tree against dev; dev-ci green. Full local unit suite: 16987 passed.

@vybe
vybe merged commit 82b99c3 into dev Oct 8, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui PR touches the frontend UI — triggers Playwright e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants