Skip to content

fix(activity): histogram≙log parity, status-aware tray grouping, code-exec sub-call transparency - #1016

Merged
Dumbris merged 9 commits into
mainfrom
fix/activity-transparency
Aug 21, 2026
Merged

Dumbris merged 9 commits into
mainfrom
fix/activity-transparency

Conversation

@Dumbris

@Dumbris Dumbris commented Aug 21, 2026

Copy link
Copy Markdown
Member

Fixes three user-reported activity-log defects (tray screenshot triage, 2026-08-21).

1. Tray histogram didn't correspond to the call log

  • Population parity: the usage timeline counted only upstream `tool_call` records while the glance shows internal calls (`retrieve_tools`, `describe_tool`, `code_execution`, …) and blocked policy decisions. The timeline now admits all three; `call_tool_` variant echoes are excluded everywhere (every one pairs with a canonical record sharing its request_id — the stale "failed call_tool_ have no paired tool_call" carve-out in `ExcludeCallToolSuccess` is removed, killing duplicate error rows in the list too).
  • Stale snapshot drift: on startup the usage aggregate loaded its last 30s-flush snapshot and never reconciled — after an unclean shutdown the histogram permanently disagreed with the list. It now replays activity records newer than the snapshot stamp.
  • Live header lag: the tray's SSE live-increment rule (`countsTowardUsageTimeline`) now mirrors the widened aggregate rule case-for-case.
  • Bonus: `/activity/summary` computed its counters over at most the newest 50 records; now streams the full period.

2. OK and errored calls collapsed into one tray run

`GlanceRun.Key` gains a status class — consecutive success and error calls to the same tool split into separate runs, so a red "×N" never counts successes. Spec 090 FR-002/FR-004 amended; `worstStatus` collapsed to `status` (runs are homogeneous now).

3. code_execution sub-calls invisible in the activity log (transparency principle)

  • Every sandbox `call_tool` now emits a first-class `tool_call` activity record with a fresh request_id and `parent_id` = the parent code_execution's request_id (also fixed: `options.ExecutionID` was always "" — pass-by-value bug).
  • `parent_id`: new `ActivityRecord` field + list/export filter + swagger + SSE passthrough.
  • Web UI: parent badge (`🧩 code_execution`) and child badge (`↳ via code_execution`); drawer gains "View sub-calls (N)" / "View parent call" — navigation verified both directions in Chrome against live records.
  • CLI: `activity list/export --parent-id`, `└` child markers in the table, `[child of …]` in watch, hints in `activity show`, docs workflow section.
  • Tray: children appear as normal Recent rows and count in the histogram; `parent_id` decoded.

QA (all against real local MCP calls — everything server, isolated instance)

  • MCP: direct ok/error calls + code_execution with 3 ok + 1 failing sub-call → parent + 4 children with correct statuses/linkage; histogram bucket matched the log record-for-record (15 calls/6 errors, then 8/2 on a second instance).
  • kill -9 between flushes → restart: no lost or double-counted bars.
  • Web UI (Chrome): badges, both drawer navigations, filter chip.
  • CLI: list/show/export/--parent-id/child markers verified live.
  • macOS tray (mcpproxy-ui-test, dev-swapped bundle): 2ok+2err+1ok on one tool renders as three runs (was one red ×5); header "13 calls" exactly matches records including live code-exec traffic.
  • Suites: `go test` (storage/httpapi/runtime/server/cmd) green, golangci-lint v2 0 issues, frontend 618 vitest green + vue-tsc, Swift 406 glance/model tests green, `test-api-e2e.sh` 65/65.

Known follow-ups (deliberate non-changes)

  • Rejected concurrency sheds stay OUT of the timeline (explicit spec 093 assertion) but ARE glance rows — needs a product call.
  • Tray glance may merge a code-exec child with an adjacent direct call to the same tool into one ×N run (same server/tool/status); provenance is one click away in the Web UI.
  • `activity watch` shows failed `call_tool_*` SSE events (stream isn't dedup-filtered).

🤖 Generated with Claude Code

Dumbris and others added 2 commits August 21, 2026 15:20
…-exec sub-call transparency

- Histogram now counts internal tool calls (retrieve_tools/describe_tool/code_execution/…)
  and blocked policy decisions, matching the tray glance population; call_tool_* variant
  echoes excluded everywhere (list + histogram) since every one pairs with a canonical record
- Usage aggregate replays activity records newer than the persisted snapshot on startup
  (no more permanent drift after unclean shutdown); internal calls now reach the live aggregate
- /activity/summary computes over the full period, not the newest 50 records
- code_execution: ExecutionID pass-by-value bug fixed; every sandbox sub-call now emits a
  first-class tool_call activity record with fresh request_id + parent_id linkage
- parent_id: new ActivityRecord field, list/export filter, swagger, SSE passthrough
- Web UI: parent/child badges, View sub-calls / View parent navigation in Activity drawer
- CLI: activity list/export --parent-id, child markers in table+watch, show hints, docs
- Tray: run grouping key now includes status class — ok and errored calls never merge;
  spec 090 FR-002/FR-004 amended; parent_id decoded

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…der count

countsTowardUsageTimeline still counted only tool_call records, so internal
calls (code_execution, retrieve_tools) and blocked policy decisions moved the
bars at the next poll but not the header — the header lagged the rows by up to
30s. Now mirrors UsageAggregate.Apply case-for-case (internal non-call_tool_*
count, rejected tool_call sheds and call_tool_* echoes stay out, blocked and
rejected policy decisions count).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 862f3d2
Status: ✅  Deploy successful!
Preview URL: https://837edecb.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-activity-transparency.mcpproxy-docs.pages.dev

View logs

@codecov-commenter

codecov-commenter commented Aug 21, 2026 •

Copy link
Copy Markdown

Dumbris and others added 3 commits August 21, 2026 18:34
…lance-set parity, sandbox shed/refusal records

Opencode cross-review of #1016 surfaced four genuine defects:
- Snapshots built under the old admission rule (no internal calls) were
  carried forward after upgrade; aggregates now stamp an AdmissionVersion and
  a mismatched snapshot is rebuilt from a full activity scan (decode clears
  the constructor default so legacy snapshots can't masquerade as current;
  clone() now carries the stamp).
- Successful management built-ins (upstream_servers, quarantine_security, …)
  entered the timeline but are not glance rows; admission now counts internal
  successes only for retrieve_tools/describe_tool/code_execution, failures
  always. Swift live-count mirror updated in lockstep.
- A concurrency shed inside a sandbox sub-call was double-recorded: the
  limiter's origin-independent observer already emits the canonical rejected
  record, so emitSubCallActivity now skips limiter sheds.
- A sandbox policy refusal was recorded as an executed error call; it is now
  status=blocked, and blocked tool_calls route like blocked policy decisions
  (Blocked counter + failed timeline bar, no Calls/latency/bytes).

Known accepted trade-offs (documented in code): the catch-up replay's strict
timestamp bound can miss a record whose Apply lagged its Save across a crash
(the alternative is permanent double-counting), and startup rejected-shed
recording is synchronous by design.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s, narrow the sandbox shed skip

- Management built-ins (upstream_servers, quarantine_security) are hidden
  from the glance whatever their status (GlanceSelection rule 1), so their
  failures must not bar either; Go admission and the Swift live-count mirror
  now exclude them entirely (non-management internal failures still count).
- emitSubCallActivity skipped every limiter error, but only queue_full/
  queue_timeout sheds get the canonical rejected record from the admission
  observer — a server_unavailable refusal lost its only activity record.
  The skip (shedHasCanonicalRecord, unit-tested) is now reason-scoped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ange

Round-3 review: the round-2 admission narrowing (management built-ins out)
changed which records count, so snapshots stamped 2 must rebuild too.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/activity-transparency

Available Artifacts

  • archive-darwin-amd64 (29 MB)
  • archive-darwin-arm64 (26 MB)
  • archive-linux-amd64 (17 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (29 MB)
  • archive-windows-arm64 (25 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (23 MB)
  • installer-dmg-darwin-arm64 (20 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 32505815696 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

Dumbris and others added 4 commits August 21, 2026 19:27
… window

User feedback on #1016: the native Activity window had no way to walk from a
code_execution to its sub-calls or back, and the code argument rendered as an
escaped one-line JSON string.

- Detail panel: 'View sub-calls' on code_execution parents filters the list
  by parent_id (with a dismissable chip); sub-call records show 'View parent
  call', which restores the list and selects the parent (fetched by
  request_id and pinned if it scrolled past the page).
- List rows: sub-calls carry an arrow marker in the Details column.
- Detail panel: the code argument renders as a Code section (language badge,
  monospace); one-line agent scripts are broken at statement boundaries —
  never inside string literals or parens (formatScriptForDisplay, unit-tested).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…b-call filter

- loadActivities now publishes only the newest in-flight fetch (monotonic
  ticket), so a slow unfiltered load can't overwrite the sub-call view.
- Entering the sub-call view drops the parent's selection so clearing the
  chip doesn't silently reopen its detail panel.
- formatScriptForDisplay documents its display-only limits (regex literals,
  nested template substitutions); Copy always yields the verbatim script.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Docs audit findings (PR #1016): drop the stale 'failed call_tool_* are always
shown' claims (all call_tool_* records are hidden by default now — every
dispatch has a paired canonical record), add the parent_id query param to the
REST + feature docs, document code_execution sub-call records and their
parent/child navigation, and note sub-call activity logging in the
code-execution security model.

Spec audit: no normative amendments needed — spec 096 FR-010 (sub-calls
recorded in activity logging) is fulfilled by this PR, spec 090 was amended
in-branch, spec 093's rejected-shed exclusion is preserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…contract

Spec audit for PR #1016: two normative statements were made stale by this PR.
Spec 024's note claimed failed call_tool_* records are the sole witness of a
failed dispatch (they are paired now, and hidden by default); spec 069's usage
contract said the timeline excludes blocked attempts (it now mirrors the
glance population). Both amended with superseded notes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Dumbris
Dumbris merged commit 3bfc1b1 into main Aug 21, 2026
41 checks passed
Dumbris added a commit that referenced this pull request Aug 22, 2026
…1023)

The status-bar menu had grown long enough to scroll, which is the opposite
of a glance, and the glance itself spent a row on an internal primitive.

Menu length (3 rows back):
- Drop the grey, disabled "N quarantined server(s)" line — Needs Attention
  already carries that fact, and actionably.
- Drop "Report an Issue…" — the tracker is still reachable through the
  GitHub link in the About panel's credits.
- Move "Add Server..." into the Servers submenu as its first item (Cmd+N
  still matches; performKeyEquivalent recurses into submenus). It stays at
  the top level only when there are no servers and therefore no submenu to
  hold it, so adding the first server is never unreachable.

code_execution is an internal primitive, not a call the user made. Since
its sub-calls became tool_call records of their own (#1016), they show the
REAL work — "jira:get_issue ×3" — where the wrapper row said only
"code_execution", naming no server and no tool. A SUCCESSFUL wrapper now
rows in neither the tray glance nor the shared usage timeline; a FAILED one
still does, through rule 3's failure branch, because a script that died
before dispatch has no children to speak for it.

Kept in lockstep: GlanceSelection.glanceInternalTools (Swift),
AppState.countsTowardUsageTimeline (follows the same set), and
runtime.glanceInternalTools (Go). usageAdmissionVersion 3 → 4 so snapshots
counted under the old rule are rebuilt instead of carried forward. The Web
UI activity list still shows code_execution parents — it is the drill-down
home for a script — so the parity test now models the glance as the list
filter plus the glance's own narrowing rather than equating the two.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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