diff --git a/ROADMAP.md b/ROADMAP.md index 0c1f21f46..ef8984899 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1261,7 +1261,7 @@ graph LR | MCP protocol upgrade to 2026-07-28 revision | In progress | P1 | 40/81 (49%) | [058-mcp-2026-upgrade](./specs/058-mcp-2026-upgrade/) | | | Spec 108 profiles v3: scoped profiles, client binding, scope-aware observability | In progress | P1 | 194/195 (99%) | [108-profiles-v3](./specs/108-profiles-v3/) | | | Spec 109 navigation, scope filters and cross-surface UX consistency | In progress | P1 | 257/258 (100%) | [109-ux-navigation-consistency](./specs/109-ux-navigation-consistency/) | | -| Spec 124 work sessions and the failure timeline | In progress | P1 | 0/74 (0%) | [124-session-failure-timeline](./specs/124-session-failure-timeline/) | | +| Spec 124 work sessions and the failure timeline | In progress | P1 | 40/74 (54%) | [124-session-failure-timeline](./specs/124-session-failure-timeline/) | | | Spec 125 Skills over MCP: catalog, approval gate, read-only agent tools | In progress | P1 | 51/51 (100%) | [125-skills-over-mcp](./specs/125-skills-over-mcp/) | | | Planning/docs truth automation | In progress | P2 | — | | | | Discovery-quality eval harness (Spec 065 second half) | In progress | P3 | — | [065-evaluation-foundation](./specs/065-evaluation-foundation/) | | @@ -1438,7 +1438,7 @@ Legend: `shipped` ≥95% checked · `in-flight` 1–94% · `drafted` 0% · `—` | [120-scan-structural-gate](./specs/120-scan-structural-gate/) | — | — | | [122-scanner-skillspector-checks](./specs/122-scanner-skillspector-checks/) | `shipped` | 31/31 (100%) | | [123-oauth-token-encryption](./specs/123-oauth-token-encryption/) | `drafted` | 0/56 (0%) | -| [124-session-failure-timeline](./specs/124-session-failure-timeline/) | `drafted` | 0/74 (0%) | +| [124-session-failure-timeline](./specs/124-session-failure-timeline/) | `in-flight` | 40/74 (54%) | | [125-skills-over-mcp](./specs/125-skills-over-mcp/) | `shipped` | 51/51 (100%) | | [127-profile-argument-rules](./specs/127-profile-argument-rules/) | — | — | | [128-server-list-outcomes](./specs/128-server-list-outcomes/) | — | — | diff --git a/specs/124-session-failure-timeline/tasks.md b/specs/124-session-failure-timeline/tasks.md index 6439dbaae..d13f06d33 100644 --- a/specs/124-session-failure-timeline/tasks.md +++ b/specs/124-session-failure-timeline/tasks.md @@ -22,33 +22,33 @@ ### Tests first -- [ ] T010 [P] [US1] `internal/storage/attempt_role_test.go`: table for `attemptRole`: `tool_call` success, error, `blocked`, `rejected`; mirror `internal_tool_call` named `call_tool_*` (not counted); other `internal_tool_call`; blocked `policy_decision` sole (counted, block) and with `Companion` (not counted); warning `policy_decision` (not counted); any counted row with error class `proxy_policy` is a block -- [ ] T011 [US1] `internal/server/attempt_invariant_test.go`: drive every site that emits a blocking decision, a rejection or a refusal through its real handler and assert exactly one counted row per attempt, with attempt, failure and block counts separately. Sites: `mcp_routing.go:544-625` and `:744-745`, `mcp.go:3167` and `:3768-3769`, `mcp_code_execution.go:106` and `:1145` with `:1112`, replay `server.go:4533-4543`, `output_sanitisation.go:113`, strict and warn output-schema validation (`mcp.go:8809`), a limiter shed, a refused sandbox child (`mcp_code_execution.go:1293-1299`), builtin management refusals (`mcp.go:4652-4691`) -- [ ] T012 [P] [US1] `internal/runtime/concurrency_rejections_test.go`: several shed children of one REST call get distinct request ids, and a child's rejection row carries the id its completion row would have carried +- [x] T010 [P] [US1] `internal/storage/attempt_role_test.go`: table for `attemptRole`: `tool_call` success, error, `blocked`, `rejected`; mirror `internal_tool_call` named `call_tool_*` (not counted); other `internal_tool_call`; blocked `policy_decision` sole (counted, block) and with `Companion` (not counted); warning `policy_decision` (not counted); any counted row with error class `proxy_policy` is a block +- [x] T011 [US1] `internal/server/attempt_invariant_test.go`: drive every site that emits a blocking decision, a rejection or a refusal through its real handler and assert exactly one counted row per attempt, with attempt, failure and block counts separately. Sites: `mcp_routing.go:544-625` and `:744-745`, `mcp.go:3167` and `:3768-3769`, `mcp_code_execution.go:106` and `:1145` with `:1112`, replay `server.go:4533-4543`, `output_sanitisation.go:113`, strict and warn output-schema validation (`mcp.go:8809`), a limiter shed, a refused sandbox child (`mcp_code_execution.go:1293-1299`), builtin management refusals (`mcp.go:4652-4691`) +- [x] T012 [P] [US1] `internal/runtime/concurrency_rejections_test.go`: several shed children of one REST call get distinct request ids, and a child's rejection row carries the id its completion row would have carried ### Implementation -- [ ] T013 [US1] `internal/storage/activity_models.go`: add `Companion bool`, `BodiesRemoved bool`, `RunName string` to `ActivityRecord` (all `omitempty`); new `internal/storage/attempt_role.go` with `attemptRole(record)` (makes T010 pass) -- [ ] T014 [US1] `internal/server/mcp.go` (`emitActivityPolicyDecision` funnel, `:1180`), `internal/runtime/event_bus.go` (`emitActivityPolicyDecision`): add the companion argument; every call site passes it explicitly per plan D2 "Which blocking decisions have a companion" -- [ ] T015 [US1] `internal/server/mcp.go:4652-4691`: builtin management refusals note the `proxy_policy` outcome (`callerr.NoteOutcome`), as the sanitisation path does -- [ ] T016 [US1] `internal/reqcontext` (attempt id key), `internal/server/mcp.go` and `internal/server/mcp_code_execution.go:897-900` (set it where the request id is minted), `internal/runtime/concurrency_rejections.go:53-57` (read it, fall back to the transport id) (makes T011, T012 pass) +- [x] T013 [US1] `internal/storage/activity_models.go`: add `Companion bool`, `BodiesRemoved bool`, `RunName string` to `ActivityRecord` (all `omitempty`); new `internal/storage/attempt_role.go` with `attemptRole(record)` (makes T010 pass) +- [x] T014 [US1] `internal/server/mcp.go` (`emitActivityPolicyDecision` funnel, `:1180`), `internal/runtime/event_bus.go` (`emitActivityPolicyDecision`): add the companion argument; every call site passes it explicitly per plan D2 "Which blocking decisions have a companion" +- [x] T015 [US1] `internal/server/mcp.go:4652-4691`: builtin management refusals note the `proxy_policy` outcome (`callerr.NoteOutcome`), as the sanitisation path does +- [x] T016 [US1] `internal/reqcontext` (attempt id key), `internal/server/mcp.go` and `internal/server/mcp_code_execution.go:897-900` (set it where the request id is minted), `internal/runtime/concurrency_rejections.go:53-57` (read it, fall back to the transport id) (makes T011, T012 pass) ## Phase 3: work session per request (plan D1; FR-001..009, FR-019) ### Tests first -- [ ] T020 [P] [US2] `internal/runtime/worksession_test.go`, injected `now`: the principal carries the token prefix for agent tokens and for client credentials; a client credential rotated inside the idle window gets a new session; run name is its own key field after the principal and never joins two principals; `Touch(id)` moves the idle clock and reinstates a reaped entry; the 1,001st named session of a principal in one day ignores its name -- [ ] T021 [P] [US2] `internal/auth/agent_token_test.go` and `internal/storage/client_credentials_test.go`: during a staged client rotation a pending-hash match builds an auth context whose `TokenPrefix` is `PendingPrefix`; the stored record is unchanged; after finalization the prefix is the same value -- [ ] T022 [US2] `internal/server/worksession_resolution_test.go`: resolution for the four surfaces (legacy MCP connection, modern MCP request, REST with each `X-MCPProxy-Client` surface, CLI); two tokens on one legacy connection get two sessions; old and pending secret during a staged rotation get two sessions and the pending one keeps its session after finalization; `code_execution` sub-calls inherit the parent's session (FR-005); a legacy connection keeps the id it had (FR-006); no connection record is written for a modern request (Spec 058 US3) +- [x] T020 [P] [US2] `internal/runtime/worksession_test.go`, injected `now`: the principal carries the token prefix for agent tokens and for client credentials; a client credential rotated inside the idle window gets a new session; run name is its own key field after the principal and never joins two principals; `Touch(id)` moves the idle clock and reinstates a reaped entry; the 1,001st named session of a principal in one day ignores its name +- [x] T021 [P] [US2] `internal/auth/agent_token_test.go` and `internal/storage/client_credentials_test.go`: during a staged client rotation a pending-hash match builds an auth context whose `TokenPrefix` is `PendingPrefix`; the stored record is unchanged; after finalization the prefix is the same value +- [x] T022 [US2] `internal/server/worksession_resolution_test.go`: resolution for the four surfaces (legacy MCP connection, modern MCP request, REST with each `X-MCPProxy-Client` surface, CLI); two tokens on one legacy connection get two sessions; old and pending secret during a staged rotation get two sessions and the pending one keeps its session after finalization; `code_execution` sub-calls inherit the parent's session (FR-005); a legacy connection keeps the id it had (FR-006); no connection record is written for a modern request (Spec 058 US3) - [ ] T023 [P] [US2] `internal/server/run_header_test.go`: `X-MCPProxy-Run` accepted at 1 to 128 printable characters on REST and MCP over HTTP; an invalid value does not fail the call and is logged once per principal per process (FR-004); the header never reaches an upstream ### Implementation -- [ ] T024 [US2] `internal/runtime/worksession.go`: `WorkSessionIdentity` gains the run name field; `Touch`; named-session count per principal per day (makes T020 pass) -- [ ] T025 [US2] `internal/storage/agent_tokens.go:1024-1032`, `internal/auth/agent_token.go:307-314`: validation reports which hash matched; the auth context for a pending match carries `PendingPrefix`. List every reader of `AuthContext.TokenPrefix` in the PR description and check each against the new value (makes T021 pass) -- [ ] T026 [US2] `internal/server/workspace.go` (`principalFromContext` with generation), `internal/server/session_store.go` (per-principal map in `SessionInfo` replacing the single cached id), new `internal/server/worksession_resolve.go` (builds the identity from the request context on every recorded attempt) -- [ ] T027 [US2] `internal/server/mcp_activity_attribution.go`, `internal/runtime/activity_attribution.go`: `WorkSessionID`, `UserID` and `RunName` on the attribution, filled at the emit site; `internal/runtime/activity_service.go`: every row builder copies them (`:566-587`, `:716`, `:779-796`, `:1017`, `:1115`) and falls back to `resolveWorkSession(sessionID)` when the attribution is empty -- [ ] T028 [US2] `internal/httpapi/middleware.go` and the MCP HTTP entry: read and validate `X-MCPProxy-Run` in one place, store it on the request context; confirm it is absent from the upstream forwarding allow-list; invert T001 (makes T022, T023 pass) +- [x] T024 [US2] `internal/runtime/worksession.go`: `WorkSessionIdentity` gains the run name field; `Touch`; named-session count per principal per day (makes T020 pass) +- [x] T025 [US2] `internal/storage/agent_tokens.go:1024-1032`, `internal/auth/agent_token.go:307-314`: validation reports which hash matched; the auth context for a pending match carries `PendingPrefix`. List every reader of `AuthContext.TokenPrefix` in the PR description and check each against the new value (makes T021 pass) +- [x] T026 [US2] `internal/server/workspace.go` (`principalFromContext` with generation), `internal/server/session_store.go` (per-principal map in `SessionInfo` replacing the single cached id), new `internal/server/worksession_resolve.go` (builds the identity from the request context on every recorded attempt) +- [x] T027 [US2] `internal/server/mcp_activity_attribution.go`, `internal/runtime/activity_attribution.go`: `WorkSessionID`, `UserID` and `RunName` on the attribution, filled at the emit site; `internal/runtime/activity_service.go`: every row builder copies them (`:566-587`, `:716`, `:779-796`, `:1017`, `:1115`) and falls back to `resolveWorkSession(sessionID)` when the attribution is empty +- [x] T028 [US2] `internal/httpapi/middleware.go` and the MCP HTTP entry: read and validate `X-MCPProxy-Run` in one place, store it on the request context; confirm it is absent from the upstream forwarding allow-list; invert T001 (makes T022, T023 pass) ## Phase 4: storage, summaries, backfill (plan D3, Data Model; FR-010..018, FR-049) @@ -60,10 +60,10 @@ ### Implementation -- [ ] T033 [US1] `internal/storage/work_sessions.go` (new): buckets `work_sessions`, `work_session_rows`, `upstream_events_by_server`; summary and partition types per plan Data Model; `internal/storage/activity.go` (`SaveActivity`, `:55`): index entry and summary update in the same transaction (makes T030 pass) -- [ ] T034 [US3] `internal/storage/work_session_backfill.go` (new): batches of 1,000 keys per transaction, role pairing with a five-second window carried across batches, metadata marker; started from `internal/runtime` as a goroutine joined in `Runtime.Close` (makes T031 pass) +- [x] T033 [US1] `internal/storage/work_sessions.go` (new): buckets `work_sessions`, `work_session_rows`, `upstream_events_by_server`; summary and partition types per plan Data Model; `internal/storage/activity.go` (`SaveActivity`, `:55`): index entry and summary update in the same transaction (makes T030 pass) +- [x] T034 [US3] `internal/storage/work_session_backfill.go` (new): batches of 1,000 keys per transaction, role pairing with a five-second window carried across batches, metadata marker; started from `internal/runtime` as a goroutine joined in `Runtime.Close` (makes T031 pass) - [ ] T035 [US3] `internal/storage/work_session_repair.go` (new): startup walk of distinct work-session ids in the index (one seek per session); `internal/runtime`: at start, a summary with no end gets its last activity time as its end; the cleanup pass and shutdown set `ended_at` once the idle window has closed (FR-015) (makes T032 pass) -- [ ] T036 [US3] `internal/storage/manager.go:1607`: `sessionRetentionLimit = 100` no longer applies to work-session summaries (FR-030); the connection-session store keeps its own limit +- [x] T036 [US3] `internal/storage/manager.go:1607`: `sessionRetentionLimit = 100` no longer applies to work-session summaries (FR-030); the connection-session store keeps its own limit ## Phase 5: retention and pruning (plan D4; FR-030..039, FR-070) @@ -71,15 +71,15 @@ - [ ] T040 [P] [US3] `internal/storage/activity_prune_test.go`, small caps: session window deletes summaries and index entries and keeps rows (FR-036); the age cap removes index entries, sets `truncated_start`, lowers only stored counters; size pass order 3a bodies (every non-body field kept, `BodiesRemoved` set, progress key honoured), 3b rows outside the window, 3c whole sessions oldest last-activity first, 3d trim of the last session; at most 1,000 rows per transaction; the activity bucket and the three new buckets together end at or below the byte budget - [ ] T041 [P] [US3] `internal/runtime/activity_retention_test.go`: the shortfall record holds time, cause (`age_cap`, `record_cap`, `size_cap`) and the start of the oldest complete session; it is cleared only when the last in-window removal is older than the window, not by a quiet pass -- [ ] T042 [P] [US3] `internal/config/effective_bounds_test.go`: `session_retention_days` default 7 through its `Effective*` reader; `activity_max_records` default 400,000; an explicit `100000` in the file is kept -- [ ] T043 [P] [US3] `frontend/tests/unit/settings-session-retention.spec.ts`: the field loads, edits and saves beside its siblings +- [x] T042 [P] [US3] `internal/config/effective_bounds_test.go`: `session_retention_days` default 7 through its `Effective*` reader; `activity_max_records` default 400,000; an explicit `100000` in the file is kept +- [x] T043 [P] [US3] `frontend/tests/unit/settings-session-retention.spec.ts`: the field loads, edits and saves beside its siblings ### Implementation -- [ ] T044 [US3] `internal/storage/activity.go` (`:419-528`): session-aware prune functions per plan D4 steps 1 to 3d (makes T040 pass) -- [ ] T045 [US3] `internal/runtime/activity_service.go` (`runRetentionLoop`, `:339-407`): call order, shortfall metadata record, accessor for the doctor section (makes T041 pass) -- [ ] T046 [US3] `internal/config/config.go`, `internal/config/effective_bounds.go`: the new field at all five wiring points (struct, defaults, load, save, effective reader) and the changed default (makes T042 pass) -- [ ] T047 [US3] `frontend/src/views/settings/fields.ts:585-587`: `session_retention_days`, number, minimum 1, restart required (makes T043 pass) +- [x] T044 [US3] `internal/storage/activity.go` (`:419-528`): session-aware prune functions per plan D4 steps 1 to 3d (makes T040 pass) +- [x] T045 [US3] `internal/runtime/activity_service.go` (`runRetentionLoop`, `:339-407`): call order, shortfall metadata record, accessor for the doctor section (makes T041 pass) +- [x] T046 [US3] `internal/config/config.go`, `internal/config/effective_bounds.go`: the new field at all five wiring points (struct, defaults, load, save, effective reader) and the changed default (makes T042 pass) +- [x] T047 [US3] `frontend/src/views/settings/fields.ts:585-587`: `session_retention_days`, number, minimum 1, restart required (makes T043 pass) ## Phase 6: upstream events (plan D5; FR-020..025) @@ -87,43 +87,43 @@ - [ ] T050 [US1] `internal/upstream/types/transition_capture_test.go`: every state mutation appends a record under the lock with old state, new state, time and a copy of the last error; one goroutine delivers them in mutation order; a full queue merges the oldest unsent records of one kind and always delivers the final Ready; run with `-race` - [ ] T051 [US1] `internal/runtime/upstream_event_source_test.go`: kill a stdio fixture, refuse a connection, expire an OAuth login; record the states and `MCPX_*` codes the observer receives. Correct the kind table in plan D5 from this output before T056 -- [ ] T052 [P] [US1] `internal/oauth/refresh_coordinator_test.go`: the audit observer reports once per executed failed refresh: transient reactive and proactive failures report; several waiters on one flight give one report; a cancelled caller, a latched terminal outcome, a cooldown and a retired instance (`dialgate.IsRetired`) give none -- [ ] T053 [P] [US1] `internal/oauth/refresh_manager_test.go`: one per-server notification number taken under the lock for every schedule install and every accepted failure; the token-saved and failure events carry it +- [x] T052 [P] [US1] `internal/oauth/refresh_coordinator_test.go`: the audit observer reports once per executed failed refresh: transient reactive and proactive failures report; several waiters on one flight give one report; a cancelled caller, a latched terminal outcome, a cooldown and a retired instance (`dialgate.IsRetired`) give none +- [x] T053 [P] [US1] `internal/oauth/refresh_manager_test.go`: one per-server notification number taken under the lock for every schedule install and every accepted failure; the token-saved and failure events carry it - [ ] T054 [P] [US1] `internal/runtime/upstream_event_collapser_test.go`, injected clock: repeats within one minute rewrite one row with a count and first and last times; 120 rows per server per hour, then merge into the latest row of that kind; collapse per owner, never across owners; SC-007 storm of one failure per second for 24 hours gives at most 2,880 rows; one open `login_required` per server and owner; a stale failure does not open the mark and a stale save does not clear it; a failure delivered before the save that installed its schedule leaves the mark open; a successful login clears it - [ ] T055 [P] [US5] `internal/httpapi/activity_event_owner_test.go` (`-tags server` for the two-user cases): a foreign user's credential event is absent from the activity list, summary, export and SSE frames, and its detail takes the ordinary not-found exit; counts and paging are computed after the predicate ### Implementation -- [ ] T056 [US1] `internal/upstream/types/types.go`: transition queue and drain goroutine, existing `onStateChange` untouched; `internal/upstream` manager: one observer registration point (makes T050 pass) -- [ ] T057 [US1] `internal/oauth/refresh_coordinator.go` (`flight`, after `req.Refresh`, `:385-386`, past the retired check `:420-424`): audit observer; `internal/oauth/refresh_manager.go`: notification counter, new token-saved event, number returned by `failScheduleIfCurrent` (makes T052, T053 pass) -- [ ] T058 [US1] `internal/runtime/events.go`, `internal/runtime/lifecycle.go`: register the observer at start, classify with `diagnostics.Classify`, publish the new bus event without blocking; `internal/runtime/activity_service.go`: write `upstream_event` rows with the captured time, code and `diagnostics.Get(code).UserMessage` only (FR-021), the owner user id in the server edition, the collapser, and the `upstream_events_by_server` entry (makes T051, T054 pass) -- [ ] T059 [US1] Register the type everywhere a type is listed: storage type constants, `ACTIVITY_TYPE_LABELS` in `frontend/src/utils/activity.ts`, `activitySystemTypes` in `cmd/mcpproxy/activity_cmd.go:394-401`, and whatever the backend/frontend label-parity test reads; the System view shows and filters the rows (FR-024) -- [ ] T060 [US5] `internal/storage/activity_models.go` (`ActivityFilter`): predicate "not an owned upstream event, or the caller is an administrator or its owner"; `internal/httpapi/activity.go` (`applyActivityScope` `:161-169`, detail `:303-310`, export) and the activity SSE path call it (makes T055 pass) +- [x] T056 [US1] `internal/upstream/types/types.go`: transition queue and drain goroutine, existing `onStateChange` untouched; `internal/upstream` manager: one observer registration point (makes T050 pass) +- [x] T057 [US1] `internal/oauth/refresh_coordinator.go` (`flight`, after `req.Refresh`, `:385-386`, past the retired check `:420-424`): audit observer; `internal/oauth/refresh_manager.go`: notification counter, new token-saved event, number returned by `failScheduleIfCurrent` (makes T052, T053 pass) +- [x] T058 [US1] `internal/runtime/events.go`, `internal/runtime/lifecycle.go`: register the observer at start, classify with `diagnostics.Classify`, publish the new bus event without blocking; `internal/runtime/activity_service.go`: write `upstream_event` rows with the captured time, code and `diagnostics.Get(code).UserMessage` only (FR-021), the owner user id in the server edition, the collapser, and the `upstream_events_by_server` entry (makes T051, T054 pass) +- [x] T059 [US1] Register the type everywhere a type is listed: storage type constants, `ACTIVITY_TYPE_LABELS` in `frontend/src/utils/activity.ts`, `activitySystemTypes` in `cmd/mcpproxy/activity_cmd.go:394-401`, and whatever the backend/frontend label-parity test reads; the System view shows and filters the rows (FR-024) +- [x] T060 [US5] `internal/storage/activity_models.go` (`ActivityFilter`): predicate "not an owned upstream event, or the caller is an administrator or its owner"; `internal/httpapi/activity.go` (`applyActivityScope` `:161-169`, detail `:303-310`, export) and the activity SSE path call it (makes T055 pass) ## Phase 7: read doors (plan D6; FR-040..049) ### Tests first - [ ] T070 [P] [US5] `internal/httpapi/work_sessions_authz_test.go`: authorization table for the three doors with admin, two agent tokens, a pinned token and, under `-tags server`, two users; a foreign id and a missing id give the same not found; activity on a hidden server changes nothing a scoped caller reads (start, end, status, counts, failure facts, sort order); connection count, profile and the truncated-start marker are omitted for a scoped caller; a scoped token sees a shared upstream event of a server in reach -- [ ] T071 [P] [US1] `internal/httpapi/work_sessions_test.go`: list filters `failed`, `include_blocked`, `token`, `client`, `profile`, `run`, `error_class`, `since`, `until`, sort by `last_failure` and `last_activity`, `limit` at most 100; timeline `at=first_failure|failure:|row:|end` with `before` and `after` at most 250 and default 20; current failure index and total over stored failures in reach; with pruned failures the response gives the lifetime count and says earlier failures are no longer stored; bodies omitted unless `include_bodies`; upstream events merged in time order inside the span (SC-005) -- [ ] T072 [P] [US5] `internal/httpapi/scope_route_table_guard_test.go`: the three routes classified `scopeFiltered` in `getRouteScopes`; `/api/v1/sessions` stays admin-only (FR-045) -- [ ] T073 [P] [US1] `internal/storage/work_sessions_bench_test.go`: list of 1,000 summaries and one timeline page of a 50,000-row session, each against logs of two sizes; the cost does not follow the log size (SC-006) +- [x] T071 [P] [US1] `internal/httpapi/work_sessions_test.go`: list filters `failed`, `include_blocked`, `token`, `client`, `profile`, `run`, `error_class`, `since`, `until`, sort by `last_failure` and `last_activity`, `limit` at most 100; timeline `at=first_failure|failure:|row:|end` with `before` and `after` at most 250 and default 20; current failure index and total over stored failures in reach; with pruned failures the response gives the lifetime count and says earlier failures are no longer stored; bodies omitted unless `include_bodies`; upstream events merged in time order inside the span (SC-005) +- [x] T072 [P] [US5] `internal/httpapi/scope_route_table_guard_test.go`: the three routes classified `scopeFiltered` in `getRouteScopes`; `/api/v1/sessions` stays admin-only (FR-045) +- [x] T073 [P] [US1] `internal/storage/work_sessions_bench_test.go`: list of 1,000 summaries and one timeline page of a 50,000-row session, each against logs of two sizes; the cost does not follow the log size (SC-006) ### Implementation -- [ ] T074 [US1] `internal/storage/work_sessions.go`: list all summaries, timeline page by index range, failure navigation over index keys, event range join per server +- [x] T074 [US1] `internal/storage/work_sessions.go`: list all summaries, timeline page by index range, failure navigation over index keys, event range join per server - [ ] T075 [US5] `internal/httpapi/work_sessions_scope.go` (new): summary projection for the caller and the row-ownership predicate (agent: name and prefix; server user: stored `UserID`), event rows by their own rule -- [ ] T076 [US1] `internal/httpapi/work_sessions.go` (new) and route registration in `internal/httpapi/server.go`: `GET /api/v1/work-sessions`, `/work-sessions/{id}`, `/work-sessions/{id}/timeline`; `internal/contracts` types; `redactForeignIdentity` on loaded rows (makes T070 to T072 pass) +- [x] T076 [US1] `internal/httpapi/work_sessions.go` (new) and route registration in `internal/httpapi/server.go`: `GET /api/v1/work-sessions`, `/work-sessions/{id}`, `/work-sessions/{id}/timeline`; `internal/contracts` types; `redactForeignIdentity` on loaded rows (makes T070 to T072 pass) - [ ] T077 [US1] `make swagger`: regenerate `oas/swagger.yaml` and `oas/docs.go` (FR-047) ## Phase 8: doctor (plan D7; FR-035) -- [ ] T080 [P] [US3] Test first, `internal/management/diagnostics_test.go` and `cmd/mcpproxy/doctor_cmd_test.go`: `ActivityRetention` section with window, shortfall flag, cause, start of the oldest complete session and the settings to raise; one runtime warning line on a shortfall; printed on the all-clear and the issues path; a scoped caller gets no section -- [ ] T081 [US3] `internal/contracts` (`ActivityRetentionReport`), `internal/management/diagnostics.go` (beside `oauth_token_storage`, `:295-308`), `cmd/mcpproxy/doctor_cmd.go`, regenerate swagger (makes T080 pass) +- [x] T080 [P] [US3] Test first, `internal/management/diagnostics_test.go` and `cmd/mcpproxy/doctor_cmd_test.go`: `ActivityRetention` section with window, shortfall flag, cause, start of the oldest complete session and the settings to raise; one runtime warning line on a shortfall; printed on the all-clear and the issues path; a scoped caller gets no section +- [x] T081 [US3] `internal/contracts` (`ActivityRetentionReport`), `internal/management/diagnostics.go` (beside `oauth_token_storage`, `:295-308`), `cmd/mcpproxy/doctor_cmd.go`, regenerate swagger (makes T080 pass) ## Phase 9: PR-1 end to end and docs -- [ ] T090 [US1] `scripts/test-api-e2e.sh`: the morning-after scenario of User Story 1 through REST: an agent token makes calls over REST with `X-MCPProxy-Run`, one fails, the list shows the session as failed and the timeline opens at the failure with the rows before it +- [x] T090 [US1] `scripts/test-api-e2e.sh`: the morning-after scenario of User Story 1 through REST: an agent token makes calls over REST with `X-MCPProxy-Run`, one fails, the list shows the session as failed and the timeline opens at the failure with the rows before it - [ ] T091 [P] [US1] Docs: `docs/features/activity-log.md` (work sessions, upstream events, retention order, shortfall), `docs/api/rest-api.md` (three doors, the header), `docs/configuration.md` (`session_retention_days`, the new `activity_max_records` default), `docs/features/agent-tokens.md` (one token per agent, run name, FR-007) - [ ] T092 [P] `CLAUDE.md` "Recent Changes": one entry for PR-1, written by hand - [ ] T093 Playwright sweep per `docs/development/web-ui-verification.md` (this PR touches `frontend/src/`) @@ -171,7 +171,7 @@ - [ ] T120 `go test -race ./internal/...` and the server-tag run from `CLAUDE.md` (with its `-skip` regex) - [ ] T121 `./scripts/test-api-e2e.sh` - [ ] T122 `/opt/homebrew/bin/golangci-lint run --config .github/.golangci.yml ./...` and the same with `--build-tags server` -- [ ] T123 `scripts/check-upstream-write-sites.sh` and, when the frontend changed, `npm test -- --run` in `frontend/` +- [x] T123 `scripts/check-upstream-write-sites.sh` and, when the frontend changed, `npm test -- --run` in `frontend/` - [ ] T124 Cross-model review with opencode `github-copilot/gpt-6.1-sol`, chunked by file, round cap per `CLAUDE.md` ## Dependencies