Files
summercms/.planning/phases/19.7-generic-mcp-module/19.7-05-PLAN.md
2026-10-22 14:57:52 +02:00

41 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, estimate, must_haves
phase plan type wave depends_on files_modified autonomous requirements estimate must_haves
19.7-generic-mcp-module 05 execute 5
19.7-04
scripts/check-phase19.7.sh
modules/pier/helpers_test.go
modules/pier/catalog_test.go
modules/pier/dispatch_test.go
modules/pier/guard_rules_test.go
modules/pier/tools_list_test.go
modules/pier/sessions_test.go
modules/pier/fanout_test.go
modules/bouncer/dispatch_test.go
modules/cabana/dispatch_marker_test.go
modules/cabana/account_contributions_test.go
modules/cabana/record_action_prompt_test.go
modules/surf/streaming_test.go
modules/surf/pier_mount_test.go
modules/wristband/mcp_scopes_test.go
admin/tests/account/AccountContributions.test.ts
admin/tests/form/RecordActionsPrompt.test.ts
../sm-demo-app/plugins/golem15/user/backend_link_test.go
../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_test.go
../sm-demo-app/plugins/golem15/user/mcp_guard_test.go
../sm-oauthserver-plugin/mcp_verifier_test.go
../sm-oauthserver-plugin/mcp_consent_test.go
../sm-journal-plugin/mcp_test.go
../sm-demo-app/mcp_e2e_test.go
.planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md
.planning/phases/19.7-generic-mcp-module/deferred-items.md
.planning/todos/pending/2026-10-17-plugin-registered-frontend-permissions.md
.planning/todos/pending/2026-10-17-frontend-backend-account-link.md
.planning/todos/done/2026-10-17-plugin-registered-frontend-permissions.md
.planning/todos/done/2026-10-17-frontend-backend-account-link.md
true
SC-1
SC-2
SC-3
SC-4
D-05
D-08
D-17
D-20
D-21
D-22
D-25
D-26
D-27
D-31
D-36
tokens raw_tokens tasks confidence
90000 90000 4 low
truths artifacts key_links
Every behaviour row of 19.7-VALIDATION.md has a named test that the phase gate requires by name, and the gate refuses a skipped, zero-match or missing run (D-31 unit tests last; SC-1..SC-4)
scripts/check-phase19.7.sh --all passes on a Docker host: framework, the three plugins with their additive-export checks, the consumers at their bumped pins, the admin build and OpenAPI, the docs, and the marker rule that only modules/pier calls the bouncer dispatch setter (D-17, D-31)
The security review covers the link proof, the dispatch marker, session binding, the scope ceilings and superuser reach against every threat of plans 01-04 with file, line and pinning test; gaps are fixed in their own commits and the superuser verdict is recorded (D-05, D-17, D-22, D-25, D-20/D-21)
The demo end-to-end test proves that removing the link or revoking the grant removes the backend tools and that a read-only grant hides write tools (SC-4, D-08, D-20, D-26)
path provides contains
scripts/check-phase19.7.sh the fail-closed multi-repo phase gate --self-test
path provides contains
modules/pier/helpers_test.go fake guard provider, fake verifier, two-instance miniredis harness, bearer-injecting SDK client miniredis
path provides contains
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md the per-threat evidence table T-19.7-01
path provides contains
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md the phase security contract with threats_open threats_open
path provides contains
.planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md the filled per-task verification map nyquist_compliant: true
from to via pattern
scripts/check-phase19.7.sh modules/pier/tools_list_test.go the go stage's required-name list includes TestToolsList TestToolsList
from to via pattern
scripts/check-phase19.7.sh modules/bouncer/dispatch.go the marker stage greps for callers of the setter outside modules/pier and tests marker
from to via pattern
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md 19.7-0{1,2,3,4}-PLAN.md threat registers one row per T-19.7-NN with implementation and test references T-19.7-
The phase's last plan, by project rule: unit tests for every behaviour row of `19.7-VALIDATION.md` across the framework, the three plugins and the demo; the pier test helpers VALIDATION lists as Wave 0; the additive-API checks for sm-user-plugin, sm-journal-plugin and sm-oauthserver-plugin; the fail-closed multi-repo gate `scripts/check-phase19.7.sh` (modelled on `check-phase19.4.sh` and `check-phase19.6.1.sh`) with a `marker` stage for D-17; and the security review of threats T-19.7-01..T-19.7-41 and T-19.7-SC from plans 01-04, written as `19.7-SECURITY.md` and `19.7-SECURITY-REVIEW.md` in the 19.4 shape. Earlier plans carried smoke tests; this plan turns them into the named tests the gate requires and adds the matrices they left out.

Planner decisions recorded here:

  • P-21 (gate shape): stages self-test, go, plugins, consumers, docker, admin, docs, marker; --all runs them in that order with docker last and NOT RUN when no daemon answers (a failure with PHASE197_REQUIRE_DOCKER=1). Environment overrides PHASE197_ROOT, USER_PLUGIN (default $ROOT/../sm-demo-app/plugins/golem15/user), OAUTHSERVER_PLUGIN ($ROOT/../sm-oauthserver-plugin), JOURNAL_PLUGIN ($ROOT/../sm-journal-plugin), DEMO_APP ($ROOT/../sm-demo-app), FONOTEKA ($ROOT/../fonoteka.go), BM_APP ($ROOT/../sm-bm-app), additive bases PHASE197_USER_BASE=930b158, PHASE197_OAS_BASE=d31f8e7, PHASE197_JOURNAL_BASE=ffa2c8f.
  • P-22 (security review output): two files as in 19.4: 19.7-SECURITY.md (frontmatter with threats_open, trust boundaries, register, accepted risks) and 19.7-SECURITY-REVIEW.md (method, gaps fixed with commits, the evidence table). ASVS L1; high threats block until verified or fixed.
  • P-23 (superuser reach, D-22 and T-19.7-34): the review decides between "accepted as designed with audit and ceiling" and "add mcp.refuse_superuser_backend (default false)". If it adds the switch, that is a framework fix(pier) commit plus README and docs, and the needed patch tag is recorded in deferred-items for the user's go-ahead (no tag or push happens in this plan without a dynamic blocking-human checkpoint).

Purpose: SC-4's "security review" and "unit tests are the last plan" become true; /msd-verify-work has one green gate to run. Output: named tests in six repositories, the gate script, the filled validation map, the two security documents, and any fix commits the review needed.

<execution_context> @/.claude/msd-core/workflows/execute-plan.md @/.claude/msd-core/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md @.planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md @.planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md @.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md @.planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md @.planning/phases/19.7-generic-mcp-module/19.7-03-SUMMARY.md @.planning/phases/19.7-generic-mcp-module/19.7-04-SUMMARY.md @.planning/phases/19.4-oidc-provider-on-wristband/19.4-SECURITY.md @.planning/phases/19.4-oidc-provider-on-wristband/19.4-SECURITY-REVIEW.md @CLAUDE.md

<project_rules>

  • Tests only, plus the gate, the validation map and the security documents; a production fix found by a test or the review goes in its own fix(<module or plugin>) commit in the owning repository (as 19.6.1-03 did), never mixed with a test commit.
  • No t.Parallel on Postgres tests; unique seeded rows and cleanup; Docker suites skip under -short and the user plugin runs with GOWORK=off.
  • Gate scripts list every required test by name and refuse skipped, zero-match or missing runs (REQUIRE_TESTS + go test -json detector copied from check-phase19.4.sh; vitest detector from check-phase19.6.1.sh).
  • Stage by explicit path; no co-author tags; planning docs (VALIDATION, SECURITY, deferred-items) in their own commits; no push or tag in this plan (a needed re-tag is recorded and raised as a blocking-human checkpoint). </project_rules>
Task 1: Tracer: the gate script runs its self-test and go stage end to end against the first required framework tests, built on the pier test helpers scripts/check-phase19.7.sh, modules/pier/helpers_test.go, modules/pier/tools_list_test.go, modules/bouncer/dispatch_test.go, modules/cabana/dispatch_marker_test.go - scripts/check-phase19.4.sh (header, env overrides, REQUIRE_TESTS and the go -json detector `detect_go`, the additive `removed_exports` check at 385-480, `docker_gate`, `--self-test`, `--all`) and scripts/check-phase19.6.1.sh (admin stage with the vitest detector, docs stage, the required-name arrays, `PHASE1961_*`) - modules/pier/tracer_smoke_test.go, sessions_smoke_test.go, stateless_smoke_test.go (plan 02: the fakes and harness pieces to lift into helpers_test.go) - modules/surf/dispatch_smoke_test.go, modules/cabana/dispatch_smoke_test.go, modules/bouncer/dispatch_smoke_test.go (plan 01) - modules/cabana/administrators_harness_test.go (screensEnv on Postgres for the cabana marker test's Postgres part) - .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md (the behaviour → test map and the Wave 0 list) - .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Validation Architecture" and Security Domain rows "Forged dispatch marker", "Frontend marker accepted by a backend guard" `modules/pier/helpers_test.go` (package pier, Wave 0): `fakeGuard` (configurable name, token-guarded middleware names, requirement parser, an `allow func(subject, req, perms) bool` and a dispatch principal builder), `fakeVerifier` (map token → `pact.MCPGrant`, `MCPResource`), `fakeLinkResolver`, `fakePersonalResolver`, `newInstance(t, store Store, plugins...)` returning an `httptest.Server` whose handler is a surf router with pier mounted (through the in-test Host adapter plan 02 used), `twoInstances(t)` sharing one `miniredis` (`newRedisStore` on `redis.NewClient` pointed at it), `sdkClient(t, baseURL, bearer, protocolVersion)` returning a connected `*mcp.ClientSession` with a bearer-injecting RoundTripper and optional `ToolListChangedHandler` channel, and `fireSubjectChanged(app, guard, id, kind)`. Move the plan-02 smokes onto these helpers without changing what they assert.
First required tests: `modules/pier/tools_list_test.go` `TestToolsList` (SC-3, D-20, D-23): per-principal lists for two identities on one instance differ; a read-only grant lists only ReadOnlyHint tools; a tool whose guard has no subject is absent; `tools/call` of an unlisted tool answers a JSON-RPC error and the route handler is never reached (counter); the union of both guards' tools for an identity with both subjects. `modules/bouncer/dispatch_test.go` `TestDispatchMarker` (D-17): `Registry.Middleware` honours a marker listing the guard name and ignores one that does not; a request with forged headers and cookies is authenticated by the guard, not the marker; a nil principal is ignored. `modules/cabana/dispatch_marker_test.go` `TestDispatchMarker` (same name, package cabana; Postgres through `newScreensEnv`): `ResolveBackend` with a backend marker returns the principal and a frontend marker is refused; through the assembled admin handler a request to an admin route with a marker in the context but no bearer is still 401 (the HTTP path never carries a marker); the Journal-shaped case: a plugin route that calls `ResolveBackend` inside its handler sees the dispatched principal.

`scripts/check-phase19.7.sh` (P-21): header comment listing the stages, `set -euo pipefail`, `unset FORCE_COLOR; export NO_COLOR=1`, the env overrides, the required-name arrays (`GO_TESTS` for -short framework tests across `./modules/pier ./modules/surf ./modules/bouncer ./modules/cabana ./modules/wristband ./modules/pact`, `DOCKER_TESTS`, `USER_TESTS`, `OAS_TESTS`, `JOURNAL_TESTS`, `DEMO_TESTS`, `ADMIN_FILES`), the detectors copied from 19.4/19.6.1 (`detect_go` on `go test -json`, the vitest detector), `run_go` (go vet ./..., go test -count=1 -short ./..., go -C examples/hello test, `go build -tags summercms_mcp ./...`, the hello binary without the SDK, then `GO_TESTS` by name), the `marker` stage (every non-test .go file under modules/ outside modules/pier and modules/bouncer calling the bouncer dispatch setter fails the stage; `go list -deps ./modules/pact` must not list the SDK, jsonschema-go or modules/bouncer), `--self-test` proving the detectors on planted output and the docker NOT RUN rule, and stubs for `plugins`, `consumers`, `docker`, `admin`, `docs` that Task 3 fills (a stub prints `TODO stage <name>` and exits 1 so `--all` cannot pass before Task 3). In this task `GO_TESTS` lists `TestToolsList`, `TestDispatchMarker` (bouncer and cabana -short parts), `TestPierTracerSmoke`, `TestPierSessionsSmoke`, `TestPierStatelessSmoke`, `TestDispatchSmoke`, `TestStreamingRouteSmoke`, `TestPierMountSmoke`, `TestMCPScopesSmoke`, `TestAccountContributionsSmoke`, `TestRecordActionPromptSmoke`; Task 2 appends the rest.
bash scripts/check-phase19.7.sh --self-test && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --marker non-zero exit, or a stage line printing FAIL, "refuse:" or "missing-named" - `test -x scripts/check-phase19.7.sh` and `grep -c "self-test\|--all\|REQUIRE_TESTS\|PHASE197_REQUIRE_DOCKER" scripts/check-phase19.7.sh` prints at least 4 - `grep -c "TestToolsList\|TestDispatchMarker" scripts/check-phase19.7.sh` prints at least 2 - `grep -c "func TestToolsList(" modules/pier/tools_list_test.go` prints 1 and `grep -c "miniredis" modules/pier/helpers_test.go` prints at least 1 - `grep -c "func TestDispatchMarker(" modules/bouncer/dispatch_test.go modules/cabana/dispatch_marker_test.go` prints 1 per file - `bash scripts/check-phase19.7.sh --self-test` prints PASS for every planted detector case and exits 0 - `bash scripts/check-phase19.7.sh --go` exits 0 and `bash scripts/check-phase19.7.sh --all` exits non-zero while the Task 3 stubs remain (printed as `TODO stage`) The gate exists with proven detectors and a green go stage over the pier helpers, TestToolsList and the two TestDispatchMarker tests; the remaining stages are explicit stubs. Task 2: Framework unit tests for every VALIDATION row: catalog, dispatch, guard rules, sessions, fan-out, streaming, mount, scopes, account contributions, prompted actions; the SPA tests modules/pier/catalog_test.go, modules/pier/dispatch_test.go, modules/pier/guard_rules_test.go, modules/pier/sessions_test.go, modules/pier/fanout_test.go, modules/surf/streaming_test.go, modules/surf/pier_mount_test.go, modules/wristband/mcp_scopes_test.go, modules/cabana/account_contributions_test.go, modules/cabana/record_action_prompt_test.go, admin/tests/account/AccountContributions.test.ts, admin/tests/form/RecordActionsPrompt.test.ts, scripts/check-phase19.7.sh - TestCatalog: `acme.blog` → prefix `blog_`; two plugins with the same short code fail boot naming both; a name over 128 chars or with a dash fails; duplicate name within a plugin fails; a tool bound to an unregistered route fails naming method and path; a route without a token guard and no Guard fails (D-15) while the same route with `Guard: "backend"` compiles; an Input that is not a struct fails; a `path:"x"` tag without a `{x}` segment fails; a GET tool with a body-only field fails; annotations: GET → readOnly+idempotent, PUT → idempotent, DELETE → destructive, override `ReadOnly: ptr(false)` wins; prompt names prefixed and checked against tool names. - TestDispatch: path and query fields fill the URL, the body is the raw JSON minus those keys (a field the agent omitted is absent from the body, Pitfall 6); `{id: "a/b"}` for a single segment is refused before dispatch; Authorization and Cookie set on the outer request never reach the inner handler; RemoteAddr, X-Forwarded-For and Accept-Language are copied; a 422 from the route becomes `isError true` with the exact body as text and as structuredContent; a 2xx array is wrapped as `{"data": [...]}`; a result over `mcp.max_result_bytes` is an isError with the fixed text; the per-call timeout cancels a hanging handler. - TestGuardRules: `MCPRequirements` union with tool Permissions (D-16); `MCPTokenGuarded` false hides the route from binding without Guard; the built-in backend guard's `MCPAllows` with a scoped principal uses `ScopeLimitFor` per method. - TestSessions: binding mismatch 403; DELETE then 404 on both instances; rehydration on the second instance serves a call; TTL expiry (miniredis FastForward) → 404 and the client re-initialises; `max_per_binding` → 429; the memory store passes the same cases on one instance. - TestFanOut: permissions event → list_changed on the other instance and the removed tool is gone from the next list; link event → backend tools appear/disappear; revoked and deleted events end the session (404) and evict the stateless server; the 5 s link cache is bypassed by the link event. - TestStreamingRoute (surf): the smoke's cases plus: a stream route keeps throttle, CORS profile headers and recordPattern; a buffered route's Flush remains a no-op. - TestPierMount (surf): disabled → identical Routes(); enabled without tag → error naming `summercms_mcp`; (tagged build only) enabled → `/mcp` routes present with the stream flag and the PRM routes present; path collision with a plugin route → error naming the owner. - TestMCPScopes (wristband): default server refuses `backend`; a server listing it accepts `read backend`, lists it in metadata; `openid` stays refused on the MCP flavour. - TestAccountContributions (cabana): boot refusals (duplicate across plugins, non-identifier, nil Run, empty label); list filtering by Permissions and Applies; the action runs inside a transaction (TxFromContext present); 409 when Applies flips; interactiveOnly 403 for `g15_`; `/account*` and `/auth/me` payloads byte-identical to a recorded fixture from before the phase (compare against `git show 51d088a:modules/cabana/admin_openapi.go` types or a stored JSON fixture). - TestRecordActionPrompt (cabana): prompt localized in the show payload; value trimmed and length-capped; non-string payload 422; action without Prompt still refuses payload; `RecordAction` wrapper passes an empty Value. - Vitest: AccountContributions.test.ts (full: empty, two sections, URL action opens a new tab and renders the link, 403 and 409 toasts, refetch) and RecordActionsPrompt.test.ts (input rendering, disabled confirm until typed, maxlength attribute, posted body, Enter confirms, 422 toast text). - The plan 01 and 02 smoke tests and the helpers from Task 1 (extend, do not duplicate the fakes) - modules/pier/*.go (the behaviour under test), modules/cabana/account_contributions.go, modules/cabana/actions.go, modules/surf/streaming.go, modules/wristband/authorize.go - admin/tests/views/AccountView.test.ts and admin/tests/form/PreviewView.test.ts (test helpers and mocking patterns), admin/tests/helpers.ts - .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md per-task map (the exact test names the rows expect) Write the tests listed in the behavior block with exactly the VALIDATION names (`TestCatalog`, `TestDispatch`, `TestGuardRules`, `TestSessions`, `TestFanOut`, `TestStreamingRoute`, `TestPierMount`, `TestMCPScopes`, `TestAccountContributions`, `TestRecordActionPrompt`); sub-tests carry the case names. Run each new test red-first where the behaviour is not yet pinned (most will pass at once because plans 01-02 built the behaviour; when one fails because the code is wrong, fix the code in a separate `fix()` commit before the test commit and record it in the SUMMARY as 19.6.1-03 did). Append every name to `GO_TESTS` in the gate (surf, wristband, cabana and pier packages) and the two vitest files to `ADMIN_FILES`; fill the `admin` stage now (typecheck, the vitest run with the required files, `scripts/check-admin-openapi.sh --check`, `scripts/check-admin-dist.sh`). Keep the smoke tests of plans 01-02 in place (they stay required too). go vet ./... && go test -count=1 -short ./modules/pier/... ./modules/surf/... ./modules/bouncer/... ./modules/cabana/... ./modules/wristband/... ./modules/pact/... && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --admin non-zero exit, "FAIL" in the output, or a gate line printing FAIL, "refuse:" or "missing-named" - `grep -c "func Test\(Catalog\|Dispatch\|GuardRules\|Sessions\|FanOut\)(" modules/pier/*_test.go` prints 5 and `grep -c "func TestStreamingRoute(\|func TestPierMount(" modules/surf/*_test.go` prints 2 and `grep -c "func TestMCPScopes(" modules/wristband/mcp_scopes_test.go` prints 1 and `grep -c "func TestAccountContributions(\|func TestRecordActionPrompt(" modules/cabana/*_test.go` prints 2 - `grep -c "TestCatalog\|TestDispatch\b\|TestGuardRules\|TestSessions\|TestFanOut\|TestStreamingRoute\|TestPierMount\|TestMCPScopes\|TestAccountContributions\|TestRecordActionPrompt" scripts/check-phase19.7.sh` prints at least 10 - `grep -c "AccountContributions.test.ts\|RecordActionsPrompt.test.ts" scripts/check-phase19.7.sh` prints 2 and `grep -c "TODO stage admin" scripts/check-phase19.7.sh` prints 0 - `npm --prefix admin run test 2>&1 | grep -E 'Test Files +[0-9]+ passed' | grep -qv failed` - Every production fix named in the SUMMARY has its own commit whose subject starts with `fix(` (`git log --oneline --grep '^fix(' 51d088a..HEAD` lists each of them and no test commit touches a non-test .go file) Every framework row of the validation map has its named test, the gate requires each one, and the admin stage is live. Task 3: Plugin and demo tests, additive-export checks, consumers stage, docker and docs stages, and the filled validation map ../sm-demo-app/plugins/golem15/user/backend_link_test.go, ../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_test.go, ../sm-demo-app/plugins/golem15/user/mcp_guard_test.go, ../sm-oauthserver-plugin/mcp_verifier_test.go, ../sm-oauthserver-plugin/mcp_consent_test.go, ../sm-journal-plugin/mcp_test.go, ../sm-demo-app/mcp_e2e_test.go, scripts/check-phase19.7.sh, .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md - TestBackendLink (user plugin, Postgres): request one-shot (second confirm 404), expiry (clock past `expires_at` → 404), fresh-iat rule (iat before created_at → 409 stale_session; equal or after → 200), 1:1 uniqueness on both sides (409 already_linked), admin `SetLink` records `linked_by` and fires `BackendLinkedEvent` and both subject events (test listeners), `RemoveLink` fires the unlinked events, `LinkedBackendUser` is false for a deactivated admin and for a soft-deleted admin, user deletion and deactivation remove the link and fire `deleted`, the show route exposes only login, name and expires_at. - TestFrontendPermissionCatalog (Postgres): plugin codes after seeded rows in both editors, seeded wins on duplicate, a second plugin's duplicate of the first is dropped, saving a group with a plugin code persists it and `UserPermissionGrants` returns it (the route middleware would honour it). - TestUserMCPGuard (Postgres): the smoke's cases plus: Requirements errors on an unknown `user.` middleware name; a soft-deleted user → Allows false; `MCPResolvePersonalToken` stamps `last_used_at`; the dispatch credential satisfies `Scope("read")` middleware when the subject has read and is refused for `write`. - TestMCPTokenVerifier (oauthserver, Postgres): the smoke's cases plus: the `last_used_at` debounce window; `MCPResource` equals config; a token whose user was deactivated after minting is refused. - TestMCPConsent (oauthserver, Postgres): the smoke's cases plus: submitted scopes outside the request are dropped; `scopes: []` on allow → 422 no_grantable_scopes; a replayed decide is 404; the show body has `Cache-Control: no-store, private`. - TestJournalMCP (journal, -short): declarations compile against the plugin's routes; input structs' json keys ⊆ the keys Store/Update read (reflect over the struct and compare to a list extracted from posts_helpers.go constants or a literal list kept next to the test); the prompt renders with and without `tone`; `optionalBackendPrincipal` marker and no-bearer cases. - TestMCPEndToEnd (demo, tagged, Postgres) extension: unlink → the SDK client's `ToolListChangedHandler` fires and the next list has no `journal_` tool; revoking the grant (`DELETE /oauth/authorizations/{client_id}` as the user, or the store's revoke) → the next call is 401 and the session is gone; a `read`-only grant with a link lists `journal_list_posts` but not `journal_create_post`; `allow_personal_tokens` false → a `usr_` token is 401 at /mcp. - The plan 03 and 04 smoke tests (lift their seeds into shared test helpers in each repo rather than duplicating) - scripts/check-phase19.4.sh 385-480 (the additive `removed_exports` check and its self-test) and 500-570 (docker_gate, NOT RUN rules) - ../sm-demo-app/internal/demotest/postgres.go, ../sm-demo-app/mcp_e2e_test.go, ../sm-oauthserver-plugin/controllers/authorizations.go (revoke path) - .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md (every row's Automated Command column must match the final names and commands) Write the tests of the behavior block with the VALIDATION names (`TestBackendLink`, `TestFrontendPermissionCatalog`, `TestUserMCPGuard`, `TestMCPTokenVerifier`, `TestMCPConsent`, `TestJournalMCP`, `TestMCPEndToEnd`), fixes in their own `fix(` commits in the owning repo. Fill the gate stages: `plugins` (user plugin with `GOWORK=off`: vet, test -short, `USER_TESTS` -short names if any, then the additive check against `PHASE197_USER_BASE`; oauthserver and journal likewise against their bases, with `JOURNAL_TESTS` -short including `TestJournalMCP`); `consumers` (for `$FONOTEKA`, `$BM_APP` and `$DEMO_APP`: `go build ./... && go test -count=1 -short ./...`; the demo additionally `go build -tags summercms_mcp ./...`; also `scripts/check-pins.sh` in the demo if it validates pins); `docker` (required names: cabana `TestDispatchMarker` Postgres parts, user `TestBackendLink TestFrontendPermissionCatalog TestUserMCPGuard TestBackendLinkSmoke TestBackendLinkAdminSmoke`, oauthserver `TestMCPTokenVerifier TestMCPConsent TestMCPTokenVerifierSmoke TestMCPConsentSmoke`, demo `TestMCPEndToEnd` with `-tags summercms_mcp`); `docs` (TestDocsTree, `summer docs:build --check`, the decision note names both modules and `govulncheck`, STACK rows present, no file under `modules/` or `docs/` and no test file of this phase names a consuming application — reuse the 19.6.1 name list and add `modules/pier`); update `--all` and the self-test for the new detectors (an additive self-test per plugin). Then update `19.7-VALIDATION.md`: every row's Automated Command set to the final command, File Exists ✅, Status ✅ green after running the gate; tick the four Wave 0 items; set `wave_0_complete: true` and `nyquist_compliant: true` in the frontmatter; the Sampling Rate "Before /msd-verify-work" line names `bash scripts/check-phase19.7.sh --all`. bash scripts/check-phase19.7.sh --all non-zero exit, a stage printing FAIL, "refuse:" or "missing-named", or `NOT RUN docker` when a Docker daemon is reachable (run on a Docker host so every stage is PASS) - `grep -c "func TestBackendLink(\|func TestFrontendPermissionCatalog(\|func TestUserMCPGuard(" ../sm-demo-app/plugins/golem15/user/*_test.go` prints 3; `grep -c "func TestMCPTokenVerifier(\|func TestMCPConsent(" ../sm-oauthserver-plugin/*_test.go` prints 2; `grep -c "func TestJournalMCP(" ../sm-journal-plugin/mcp_test.go` prints 1; `grep -c "ToolListChangedHandler" ../sm-demo-app/mcp_e2e_test.go` prints at least 1 - `grep -c "TODO stage" scripts/check-phase19.7.sh` prints 0 and `grep -c "PHASE197_USER_BASE\|PHASE197_OAS_BASE\|PHASE197_JOURNAL_BASE" scripts/check-phase19.7.sh` prints at least 3 - `bash scripts/check-phase19.7.sh --plugins` prints `additive:` lines for the user, oauthserver and journal plugins and exits 0 - `bash scripts/check-phase19.7.sh --all` exits 0 on a Docker host with PASS for self-test, go, plugins, consumers, admin, docs, marker and docker - `grep -c "nyquist_compliant: true" .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md` prints 1 and `grep -c "⬜ pending\|❌ W0" .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md` prints 0 Every plugin and demo row has its named test, the three plugins pass the additive-export check, the consumers build at their pins, the whole gate is green, and the validation map is filled and compliant. Task 4: Security review of T-19.7-01..41 and T-19.7-SC: link proof, dispatch marker, session binding, scope ceilings and superuser reach .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md, .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md, .planning/phases/19.7-generic-mcp-module/deferred-items.md, .planning/todos/pending/2026-10-17-plugin-registered-frontend-permissions.md, .planning/todos/pending/2026-10-17-frontend-backend-account-link.md, .planning/todos/done/2026-10-17-plugin-registered-frontend-permissions.md, .planning/todos/done/2026-10-17-frontend-backend-account-link.md - .planning/phases/19.4-oidc-provider-on-wristband/19.4-SECURITY.md and 19.4-SECURITY-REVIEW.md (the two formats, the Method section, the gaps-fixed table, the evidence table columns) - The `` blocks of 19.7-01-PLAN.md, 19.7-02-PLAN.md, 19.7-03-PLAN.md and 19.7-04-PLAN.md (T-19.7-01..38 and T-19.7-SC) and this plan's (T-19.7-39..41) - .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Security Domain" (ASVS categories, the known threat patterns and standard mitigations) - 19.7-CONTEXT.md D-05, D-17, D-20, D-21, D-22, D-25, D-31 (the five review subjects the roadmap names) - modules/pier/*.go, modules/bouncer/dispatch.go, modules/cabana/token_guard.go and token_resolver.go, the user plugin's classes/backend_links.go and classes/mcp_guard.go, the oauthserver's classes/mcp_verifier.go and controllers/mcp_consent_api.go For each threat: read the implementing code and record file and line; find the pinning test (from Tasks 1-3 or the plans' smokes); where the code is right but no test pins it, add the test in the owning repo as its own commit; where the code is wrong, fix it in its own `fix(` commit and re-run the gate. Cross-cutting sweeps the review must perform and record: (1) link proof — no code path other than `ConfirmLinkRequest` and `SetLink` writes `golem15_user_backend_links`, `SetLink` is reachable only from the permission-guarded record action, and the confirm compares `iat`; (2) marker — the only non-test caller of the bouncer dispatch setter is `modules/pier/dispatch.go` (the gate's marker stage), no header or query is read for it, `ResolveBackend` refuses a frontend marker, the inner request has no Authorization or Cookie; (3) session binding — binding compared on every stateful request, DELETE and revocation propagate through the store, rehydration never trusts stored identity; (4) scope ceilings — `read` hides non-read-only tools, `backend` without a link yields no backend subject, consent drops `backend` without a link, personal tokens carry their own scopes and are off by default; (5) superuser reach (P-23) — weigh the optional `mcp.refuse_superuser_backend` switch and record the verdict with reasons; implementing it is a `fix(pier)` plus README and docs, and the patch tag it needs goes to deferred-items for the user's go-ahead (raise a blocking-human checkpoint before any tag or push); (6) logs — no token, argument or body in any pier, verifier or link log line; (7) no-store on every consent and link response that carries a code or token. Write `19.7-SECURITY-REVIEW.md` (Method, Gaps fixed with commit table, Threat register with Mitigation as built / Implementation / Test / Status, Cross-cutting findings, Accepted risks with reasons, Residual items) and `19.7-SECURITY.md` (frontmatter `phase: "19.7"`, `slug`, `status: verified`, `threats_open: 0`, `asvs_level: 1`, `created`; Trust Boundaries, Threat register summary, Accepted risks, Audit trail). Add any residual operational item (the deploy, Redis on rome, the superuser switch tag if adopted) to deferred-items.md.
Close the two folded todos in this task's planning-docs commit (D-01; CLAUDE.md rule 4): `git mv .planning/todos/pending/2026-10-17-plugin-registered-frontend-permissions.md .planning/todos/done/` and `git mv .planning/todos/pending/2026-10-17-frontend-backend-account-link.md .planning/todos/done/` (the closed directory is `.planning/todos/done/`, per `.planning/todos/README.md`), then end each file with a `## Closed <date>` note naming what shipped and where: for the first, the `pact.HasFrontendPermissions` capability (plan 01) and the user plugin's catalog in the permission editors (plan 03); for the second, the `golem15_user_backend_links` table, the proof round-trip, the published link resolver and the Administrators-screen set/remove actions (plan 03), each with the sm-user-plugin version from plan 03's SUMMARY. The g15office side — moving tasks `hmguritm` and `tqyvnzxx` into the phase's milestone task `dcnv4mha` with the one-line comment, and the phase-advance comment — is not done by the executor: the orchestrator's phase-completion step owns it (CLAUDE.md rule 4, `.planning/G15OFFICE.md`); record the two todo task IDs and the phase task ID in the SUMMARY so that step has them.
test -f .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md && test -f .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md && grep -q "threats_open: 0" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md && for n in $(seq -w 1 41); do grep -q "T-19.7-$n" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md || { echo "missing T-19.7-$n"; exit 1; }; done && grep -q "T-19.7-SC" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md && test -f .planning/todos/done/2026-10-17-plugin-registered-frontend-permissions.md && test -f .planning/todos/done/2026-10-17-frontend-backend-account-link.md && ! test -e .planning/todos/pending/2026-10-17-plugin-registered-frontend-permissions.md && ! test -e .planning/todos/pending/2026-10-17-frontend-backend-account-link.md && bash scripts/check-phase19.7.sh --all non-zero exit, a "missing T-19.7-NN" line, a folded todo still under todos/pending/ or absent under todos/done/, or a gate stage printing FAIL - Every id T-19.7-01 through T-19.7-41 and T-19.7-SC appears in 19.7-SECURITY-REVIEW.md with an Implementation cell naming a file and line and a Test cell naming a test, and a Status of verified, fixed in commit , or accepted with a reason - `grep -c "superuser" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md` prints at least 2 (the D-22 verdict is written down) - `grep -c "threats_open: 0" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md` prints 1 and `grep -c "^status: verified" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md` prints 1 - Every fix or added test pin named in the Gaps-fixed table is a commit that exists (`git -C cat-file -t ` prints commit) - `bash scripts/check-phase19.7.sh --all` is green after the review's commits - `grep -c "^## Closed" .planning/todos/done/2026-10-17-plugin-registered-frontend-permissions.md .planning/todos/done/2026-10-17-frontend-backend-account-link.md` prints 1 per file, neither file exists under `.planning/todos/pending/`, and the SUMMARY names g15office `hmguritm`, `tqyvnzxx` and `dcnv4mha` as the tasks the orchestrator updates at phase completion Every threat of the phase is verified, fixed or accepted with evidence; the security contract reports no open threat; the gate is green after the review; the two folded todos are closed under todos/done/ with the g15office update left to the orchestrator's phase-completion step.

<artifacts_this_phase_produces>

Artifacts this plan produces

Gate: scripts/check-phase19.7.sh (stages self-test, go, plugins, consumers, docker, admin, docs, marker; env PHASE197_*, USER_PLUGIN, OAUTHSERVER_PLUGIN, JOURNAL_PLUGIN, DEMO_APP, FONOTEKA, BM_APP) Framework tests: modules/pier/helpers_test.go (fakeGuard, fakeVerifier, fakeLinkResolver, fakePersonalResolver, newInstance, twoInstances, sdkClient), TestToolsList, TestCatalog, TestDispatch, TestGuardRules, TestSessions, TestFanOut (pier); TestDispatchMarker (bouncer and cabana); TestStreamingRoute, TestPierMount (surf); TestMCPScopes (wristband); TestAccountContributions, TestRecordActionPrompt (cabana); vitest admin/tests/account/AccountContributions.test.ts, admin/tests/form/RecordActionsPrompt.test.ts Plugin and demo tests: TestBackendLink, TestFrontendPermissionCatalog, TestUserMCPGuard (sm-user-plugin); TestMCPTokenVerifier, TestMCPConsent (sm-oauthserver-plugin); TestJournalMCP (sm-journal-plugin); TestMCPEndToEnd extended (sm-demo-app, tagged) Documents: 19.7-VALIDATION.md filled (nyquist_compliant: true), 19.7-SECURITY.md, 19.7-SECURITY-REVIEW.md, deferred-items.md; the two folded todos moved to .planning/todos/done/ with their ## Closed notes Possible fixes: fix( commits in the owning repositories; the optional mcp.refuse_superuser_backend key if the review adopts it (recorded with its tag need) </artifacts_this_phase_produces>

<threat_model>

Trust Boundaries

Boundary Description
gate script to six repositories the script decides the phase verdict from test output across repos
review to production code the review may change code; every change is a visible commit

STRIDE Threat Register

Threat ID Category Component Severity Disposition Mitigation Plan
T-19.7-39 Repudiation a green gate that measured nothing high mitigate Every required test is listed by name; the detectors refuse skipped, zero-match, "no tests to run" and missing names and are proven by --self-test on planted output; docker is NOT RUN only without a daemon and a failure with PHASE197_REQUIRE_DOCKER=1
T-19.7-40 Tampering the marker rule eroding over time medium mitigate The marker stage fails when any non-test file outside modules/pier and modules/bouncer calls the dispatch setter, and when pact grows a dependency on the SDK, jsonschema-go or bouncer
T-19.7-41 Information Disclosure test fixtures leaking real credentials low mitigate Tests mint their own tokens and codes against throwaway Postgres databases and miniredis; no fixture carries a production token; the docs stage's name check keeps consuming applications out of framework test files
</threat_model>
- `bash scripts/check-phase19.7.sh --all` on a Docker host: PASS for every stage, no NOT RUN - `19.7-VALIDATION.md`: every row ✅ green, Wave 0 ticked, `nyquist_compliant: true` - `19.7-SECURITY.md` reports `threats_open: 0`; `19.7-SECURITY-REVIEW.md` covers T-19.7-01..41 and T-19.7-SC - The 19.6.1 gate still passes: `bash scripts/check-phase19.6.1.sh --all`

<success_criteria>

  • Unit tests are the last plan and every VALIDATION behaviour row is pinned by a required, named test
  • The multi-repo gate is fail-closed and green; the three core plugins are proven additive against their pre-phase commits; fonoteka.go and sm-bm-app build and pass at the bumped pins (D-31)
  • The security review's verdicts are written down with evidence; any fix is its own commit; no tag or push happened without a go-ahead </success_criteria>
Create `.planning/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md` when done (planning docs in their own commit).