Skip to content

feat(profiles): scope attribution and profile/client/token filters (Spec 108-e) - #1436

Merged
github-actions[bot] merged 10 commits into
mainfrom
108-e-scope-attribution-filters
Sep 30, 2026
Merged

github-actions[bot] merged 10 commits into
mainfrom
108-e-scope-attribution-filters

Conversation

@Dumbris

@Dumbris Dumbris commented Sep 30, 2026

Copy link
Copy Markdown
Member

What this changes

Spec 108-e (specs/108-profiles-v3, tasks T056-T066 plus the new T061a, T061b and T065a). Every activity record and session now says which profile, client and token it ran under, and the grid endpoints filter on those values. It closes FR-029 to FR-033 and the "scope is unverifiable" gap behind audit problems P5 and P6 (acceptance checks 2 and 6).

REST and core

  • Activity records gain profile, profile_source, client_id, client_name, token_name and, for a blocked call, block_reason. The values are those in effect when the call ran and are never rewritten, so reassigning a client later leaves history alone. metadata.profile and metadata.block_reason are still written for one release. A profile_change record now carries the new profile, client id and token name as first-class fields.
  • Sessions persist client_id, token_name, profile and profile_source; a changed resolution is written through once, not on every call.
  • profile, client and token filter /activity, /activity/export, /activity/summary, /activity/usage and /sessions; agent is now an alias of token on all five (naming two different tokens is a 400). client_name filters /activity and /activity/export only and is a 400 on the other three. - selects records with no value. Records written before this change still match through their legacy keys.
  • GET /tools?client= and ?profile= return every tool with profile_tier and access {visible, callable, reason}. callable is computed by the new access chain in internal/server/access_chain.go, which calls the same predicates a real call does; a test dispatches every enforcement-matrix row and requires the verdict to match the outcome. client= is administrator only. A non-administrator profile= view gets only the visible rows plus counts {visible, hidden}, and an unreachable profile answers exactly like an unknown one. GET /servers?profile= limits rows to the profile's servers with visible tool counts.
  • A scoped caller cannot use these filters to learn about other tokens: its filters evaluate a view where another token's records carry no attribution, the identity fields are blanked on those rows (list, detail, JSON and CSV export), and the SSE attribution object is delivered only on the subscriber's own events. The internal token prefix never reaches the wire.
  • /activity/usage under a scope filter is computed from a window-bounded scan of the matching records (the persisted aggregate is unchanged and the unfiltered path stays scan-free); the filters are part of its cache key.
  • GET /status now advertises features.scope_filters: ["profile","client","token"], read from the same list the 109-k gate uses. /tokens and /clients still answer 400 unsupported_scope_filter until 108-f.

CLI

  • activity list|watch|summary|export gain --profile, --client, --token and --client-name; --agent stays as a hidden deprecated alias of --token. summary rejects --client-name with the REST text. activity list shows CLIENT and PROFILE columns, activity show prints client, profile, token and block reason, and CSV export appends the six new columns after parent_id.
  • tools list --client/--profile adds ACCESS and REASON columns; upstream list --profile restricts to the profile's servers (both moved here from 108-g so one PR owns each REST parameter end to end).

Web UI

  • No page change. One fix in the shared composable: the frontend only matched the feature name scope_filters, while the backend lists parameter names, so the hidden profile, client and token parameters could never un-hide against a real backend. It now matches the listed names, and restPages limits what is sent to the endpoints that honour them, so the Clients and Tokens pages send nothing to /clients or /tokens and no page starts receiving a new 400 between this PR and 108-f.

macOS app

  • No change; its scope filter already maps the parameters to the endpoints that honour them.

Spec docs and generated files

Plan decisions applied to tasks, spec, data model, contracts, plan, quickstart and research (D31); oas/swagger.yaml and oas/docs.go regenerated; REST and CLI docs updated. Declared golden changes: none (no MCP tool schema changes; the tool-surface goldens and internal/index are untouched).

Tests added

Storage filters and session filters; attribution stamping for every profile source, blocked calls, sub-calls and no-history-rewrite; session identity persistence; the access chain against real dispatch; REST view-as through the real router with stored tokens; scoped-caller disclosure and SSE tests; usage scan and cache key; the gate lists; CLI flag, alias, watch-filter and view-as tests; a frontend availability test.

Follow-ups

  • Limiter-shed records (EmitActivityToolCallRejected) have no request context and stay unattributed.
  • GET /sessions parses offset but never applies it (pre-existing).
  • The Web Activity list does not yet send client to /activity (the Web wiring is 108-j); land 108-f next.

…s and sessions (Spec 108-e)

Adds first-class attribution fields to activity records (profile,
profile_source, client_id, client_name, token_name, block_reason) and
sessions, the storage filters with the unattributed sentinel and legacy
fallbacks, the emit-time attribution seam, and profile_change fields.
…age and sessions (Spec 108-e)

Fills the scope filter list (profile, client, token), maps agent onto the
token filter, adds client_name on activity and export, evaluates filters
against the owner-redacted view for scoped callers, appends CSV columns,
redacts foreign attribution on records, detail, export and SSE, and serves
usage under a scope filter from a window-bounded scan.
… (Spec 108-e)

Adds the access chain evaluator (internal/server/access_chain.go) whose
callable verdict is pinned against real dispatch, GET /tools?client= and
?profile= with per-row access and profile_tier, counts for non-admin
views, and GET /servers?profile= with visible tool counts.
…le filter on upstream list (Spec 108-e)

Adds --profile, --client, --token and --client-name to activity
list/watch/summary/export with --agent kept as a deprecated alias of
--token, CLIENT and PROFILE columns, attribution lines on activity show,
and --client/--profile on tools list and --profile on upstream list.
…e filters

Updates the Spec 108 tasks, spec, data model, contracts, plan, quickstart
and research (D31), the REST and CLI docs, the generated OpenAPI and the
roadmap. Marks the 108-e tasks done.
…endpoints that honour them (Spec 108-e)

features.scope_filters lists parameter names, but the composable only
matched the feature name, so the parameters never un-hid against a real
backend. The Clients and Tokens pages send nothing to /clients or /tokens
until Spec 108-f.
…ecords from the request context (Spec 108-e)
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: 108-e-scope-attribution-filters

Available Artifacts

  • archive-darwin-amd64 (30 MB)
  • archive-darwin-arm64 (27 MB)
  • archive-linux-amd64 (18 MB)
  • archive-linux-arm64 (16 MB)
  • archive-windows-amd64 (30 MB)
  • archive-windows-arm64 (27 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (25 MB)
  • installer-dmg-darwin-arm64 (22 MB)
  • smart-mcp-proxymcpproxy-goK2G8V9.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 36737330443 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

…ugs (Spec 108-e)

The Activity Sessions view no longer lets the unscoped on-mount /sessions
response overwrite the scoped rows, and a scoped caller no longer reads
another token's legacy metadata.profile (REST) or flat profile (SSE).

@github-actions github-actions Bot 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.

Approved (Model B): Paperclip review verdicts = ACCEPT and qa-gate green at this head SHA. Arming auto-merge; GitHub merges when all required checks pass.

@github-actions
github-actions Bot merged commit d463668 into main Sep 30, 2026
60 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.

2 participants