Compare commits
317 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9094bf9ad9 | |||
| 06a144e19f | |||
| 23238ccd47 | |||
| 3f52b1ab49 | |||
| 415a09333b | |||
| 876f0f09f2 | |||
| 9e29d6ff9b | |||
| 63d05e8acb | |||
| 2cea3127cc | |||
| 8416f10849 | |||
| 200c664a4b | |||
| 41d145dde1 | |||
| f5931d5698 | |||
| 3938ebbddd | |||
| 1173f35f80 | |||
| 88fbfb7b39 | |||
| 0db030598e | |||
| bd23a82f22 | |||
| a7df0caaa3 | |||
| 14979e7009 | |||
| df2a0753c7 | |||
| 2cc3c1728b | |||
| 69d5a24fa8 | |||
| 2ac8663fe7 | |||
| 126c0866fc | |||
| b8aa5d881c | |||
| 7c4dbb1252 | |||
| adf5cccc4a | |||
| 6472f2861e | |||
| 9fe489084c | |||
| 175e469587 | |||
| 0e187cfb6a | |||
| 1583651783 | |||
| 468af06c86 | |||
| d660cd05fa | |||
| 5471b66b8f | |||
| 676ca539aa | |||
| 2b7174d406 | |||
| 1259f5bd1d | |||
| 32141f803a | |||
| 8b4817fa0a | |||
| cffa49642c | |||
| f098ffdbf9 | |||
| a9a7f58eed | |||
| 15b0d0d148 | |||
| 8c961f5fb5 | |||
| 2b300ec03d | |||
| 49502e8ccb | |||
| 7353e08c36 | |||
| 20d02d722a | |||
| 9247761c94 | |||
| f96d7d4b4a | |||
| 8800137d16 | |||
| 99889f0bcf | |||
| 930d91a3c1 | |||
| 1d3fa32616 | |||
| 9e3fcebb42 | |||
| 785902c612 | |||
| ff62906301 | |||
| 753fb5969a | |||
| 1b0421de81 | |||
| bcbf1aa184 | |||
| 9ae326908f | |||
| fa1af69376 | |||
| e7423bd21f | |||
| 4bb22a85dd | |||
| 0819442634 | |||
| 9868838fe3 | |||
| 641befc933 | |||
| 5d7e3caaea | |||
| 748574c7cb | |||
| e3c0de24a6 | |||
| 62bcecf704 | |||
| e0cf189ad8 | |||
| 54d770740c | |||
| d661e1de95 | |||
| 28b6b55f29 | |||
| d5aed6bb14 | |||
| bc8f9540a9 | |||
| 1769e15fbd | |||
| 3cc5de056f | |||
| 680d4021e4 | |||
| a70dbb6ff0 | |||
| ac0599e78d | |||
| 4925dddd40 | |||
| 07f4632dc2 | |||
| 12b60d0194 | |||
| 692beb5538 | |||
| ea4680eebe | |||
| 531e7abae7 | |||
| e9785f71de | |||
| 947009a62d | |||
| e95277a210 | |||
| d3b1636ac7 | |||
| 4002beafb6 | |||
| 5a6461123c | |||
| 5d78f53ddc | |||
| eb21d1f6e9 | |||
| 33920ed558 | |||
| 07c4e7f59e | |||
| 24d9d2a401 | |||
| ecc34bc35a | |||
| 9a76c7ec1c | |||
| c5fee4c63a | |||
| 723c27e352 | |||
| 7fd23f0642 | |||
| 6bc7b5cb20 | |||
| 07e32b5be8 | |||
| 223f87e0f1 | |||
| 49a3df68c8 | |||
| 505b8991ee | |||
| 691459174a | |||
| eb9a62a5ec | |||
| b8e7ba9d4f | |||
| 1038034078 | |||
| 4c20459d03 | |||
| 85a137df24 | |||
| 94ee2cee03 | |||
| 33c40ff483 | |||
| 1fe553e344 | |||
| 4d5a09ae62 | |||
| f824d9354c | |||
| c37c6ce50f | |||
| 0b0cae5b53 | |||
| 34dce1ca78 | |||
| 89b85f58d5 | |||
| 4d7eb9dcfb | |||
| 81342f1d9b | |||
| 633d45082e | |||
| a5ce43f211 | |||
| 3afe9fa19c | |||
| eea04b171e | |||
| 034aa19904 | |||
| c0ce07ecb7 | |||
| afc7510d1b | |||
| 58408aaa83 | |||
| 38e028fbe6 | |||
| 99f5ed4dfb | |||
| 2fdda99c08 | |||
| 788d4a49fa | |||
| 928731db4d | |||
| e7630e6762 | |||
| f604e6de64 | |||
| cccf4025ea | |||
| f53668a3e8 | |||
| d6a1297a5f | |||
| 883ac5133c | |||
| e1f489058c | |||
| a636933299 | |||
| 33faa44e53 | |||
| 946fb2d3ea | |||
| 7f43e0eff0 | |||
| c2d486bf0e | |||
| ccf77b9103 | |||
| fda46466c7 | |||
| 0aa48ae6c4 | |||
| 05d7e9351a | |||
|
|
bccf06d960 | ||
|
|
fdf7efdd5c | ||
|
|
1e5d9d4f88 | ||
|
|
5aeea304d0 | ||
|
|
d6c7fd5a27 | ||
|
|
88559d5731 | ||
|
|
44835e4c6b | ||
|
|
24cf6cd931 | ||
|
|
0ec00f7f69 | ||
|
|
9eedfbbb29 | ||
|
|
c14238b94b | ||
|
|
60a86677f2 | ||
|
|
6ca9e1706d | ||
|
|
95f177b1e0 | ||
|
|
211cec11b0 | ||
|
|
104db9959f | ||
|
|
240457291f | ||
|
|
c1c0c77ddc | ||
|
|
2bf9dca603 | ||
|
|
d18d8f0dc2 | ||
|
|
d763e92650 | ||
|
|
2527498d03 | ||
|
|
cee58c0f65 | ||
|
|
fef1cbbbbd | ||
|
|
5563df7e68 | ||
|
|
d9d2acae88 | ||
|
|
4730e37742 | ||
|
|
0b8e027b81 | ||
|
|
d621ef1b41 | ||
|
|
a94bdc199d | ||
|
|
f14eae96dd | ||
|
|
1111828e8a | ||
|
|
c29d2289d0 | ||
|
|
3bbbe6c11e | ||
|
|
c49983d3f8 | ||
|
|
905111ba72 | ||
|
|
81266de77d | ||
|
|
9550fe0a9f | ||
|
|
29ba9a28cb | ||
|
|
7c43820afe | ||
|
|
d96c726d6c | ||
|
|
5c35f83b9d | ||
|
|
607658599f | ||
|
|
d039350729 | ||
|
|
e2759d668f | ||
|
|
eadd58414d | ||
|
|
a26ee2b72d | ||
|
|
e5dd4579a8 | ||
|
|
894a3d572f | ||
|
|
d1a15a6f5f | ||
|
|
a9e3f2434d | ||
|
|
cd90be9de3 | ||
|
|
6a1974c0d2 | ||
|
|
ec69f547b8 | ||
|
|
e9ebf93d36 | ||
|
|
c309a1abe9 | ||
|
|
575a110378 | ||
|
|
54ff7bd665 | ||
|
|
b8bf71c5dd | ||
|
|
98a95c9c92 | ||
|
|
b70abe48e6 | ||
|
|
3ebd78373c | ||
|
|
76694c7cb9 | ||
|
|
3026cf61fb | ||
|
|
cb33c497be | ||
|
|
604fee757e | ||
|
|
058738efdf | ||
|
|
66bb96eebd | ||
|
|
101cad0365 | ||
|
|
49accf675e | ||
|
|
1aff96f58a | ||
|
|
8c6c0a3654 | ||
|
|
806e87c510 | ||
|
|
cfdbaf0e47 | ||
|
|
3ea82a1543 | ||
|
|
3746675c72 | ||
|
|
fab99e0a00 | ||
|
|
9a5f27e86c | ||
|
|
9f14cf603c | ||
|
|
6887abf575 | ||
|
|
5c15dea569 | ||
|
|
1bd91a4522 | ||
|
|
a74a218cd9 | ||
|
|
3653422572 | ||
|
|
b28800ad39 | ||
|
|
0a5945d681 | ||
|
|
19c6a65575 | ||
|
|
49ffb395c0 | ||
|
|
2f496f6200 | ||
|
|
43d0f4622c | ||
|
|
587f9ddf2f | ||
|
|
ed7da85f46 | ||
|
|
1e3b006c5d | ||
|
|
007c68bab2 | ||
|
|
51e1a1ea6e | ||
|
|
d47d6182f0 | ||
|
|
14baafb27c | ||
|
|
ba0501c274 | ||
|
|
51d088a3b2 | ||
|
|
80bb5aee3d | ||
|
|
85476fa3fe | ||
|
|
834ef98572 | ||
|
|
a97743a39f | ||
|
|
d7dc2a385a | ||
|
|
6bd2506db6 | ||
|
|
e62086084b | ||
|
|
ffc0a94afe | ||
|
|
cb460b6000 | ||
|
|
068adaabf9 | ||
|
|
422bd1e01f | ||
|
|
eadc7810be | ||
|
|
cfebbacc3d | ||
|
|
d6a6e7ac60 | ||
|
|
d5da300e24 | ||
|
|
a4cfd628ce | ||
|
|
1a68cc5280 | ||
|
|
8f3d625943 | ||
|
|
7842aca7f5 | ||
|
|
4c61a180d0 | ||
|
|
085179b676 | ||
|
|
1a56294d9b | ||
|
|
83240706b2 | ||
|
|
b684bb7d8d | ||
|
|
461cb21b3e | ||
|
|
536ea8c1bf | ||
|
|
1aaa8a444c | ||
|
|
47db9666dd | ||
|
|
7091d09699 | ||
|
|
705f94d9e5 | ||
|
|
e2525d4956 | ||
|
|
3a772fabb1 | ||
|
|
653307de0c | ||
|
|
530b02af9c | ||
|
|
88401737c9 | ||
|
|
7340241f22 | ||
|
|
88ec4df2b3 | ||
|
|
ee5b8844bf | ||
|
|
1e9927fa4b | ||
|
|
6267edb7c5 | ||
|
|
eaeb2347c0 | ||
|
|
4141cd916f | ||
|
|
b1fba7e24c | ||
|
|
139f5e3942 | ||
|
|
f5e9ee508b | ||
|
|
a48afbd11e | ||
|
|
0691d26f1f | ||
|
|
57a849d114 | ||
|
|
17c722da46 | ||
|
|
707372bf65 | ||
|
|
fce232d7c3 | ||
|
|
1ac75ad59a | ||
|
|
48e13f9b57 | ||
|
|
7c1509581b | ||
|
|
a28957f7d0 | ||
|
|
36e2240891 | ||
|
|
9516a2b36f | ||
|
|
9563bc836a | ||
|
|
28ad561481 | ||
|
|
0ebed687a0 | ||
|
|
349e2f810b |
@@ -47,5 +47,8 @@ A new phase, inserted or added, gets its task when it is added to `ROADMAP.md`.
|
||||
| 14.1 | v0j5lwvq | 31 | hgol7otp |
|
||||
| | | 19.4.1 | g02hcroj |
|
||||
| | | 19.6.1 | hioyvbxa |
|
||||
| | | 19.8 | t9k2efpy |
|
||||
| | | 32 | 8gldeain |
|
||||
| | | 33 | ebilbgte |
|
||||
|
||||
Backlog phase 999.1 (newsletter) has no task until it is promoted into the roadmap.
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"timestamp": "2026-10-20T09:20:51.976Z",
|
||||
"phase": "19.4.1",
|
||||
"phase_name": "Early public demo on demo.summercms.io (INSERTED)",
|
||||
"phase_dir": ".planning/phases/19.4.1-early-public-demo-on-demo-summercms-io",
|
||||
"plan": 1,
|
||||
"task": 4,
|
||||
"total_tasks": 4,
|
||||
"status": "paused",
|
||||
"completed_tasks": [
|
||||
{"id": 1, "name": "Tracer: English deck from ROADMAP.md shown in bm's viewer", "status": "done", "commit": "b80aaaf, 7a4a6b0, 4514159 (sm-demo-app)"},
|
||||
{"id": 2, "name": "Whole deck in EN and PL: roadmap, features, migration, pxpx, MCP future", "status": "done", "commit": "680fd82 (sm-demo-app)"},
|
||||
{"id": 3, "name": "OIDC provider screenshots, no duplicate images on re-seed", "status": "done", "commit": "37ee65e (sm-demo-app)"}
|
||||
],
|
||||
"remaining_tasks": [
|
||||
{"id": 4, "name": "checkpoint:human-verify — user reviews the EN/PL deck for the 2026-10-21 presentation", "status": "awaiting_user"}
|
||||
],
|
||||
"blockers": [
|
||||
{"description": "Plan 19.4.1-01 Task 4 is a blocking human-verify checkpoint", "type": "human_action", "workaround": "none — user must approve or list slide changes"}
|
||||
],
|
||||
"async_jobs": [],
|
||||
"human_actions_pending": [
|
||||
{"action": "Review both decks (30 slides each) and reply 'approved' or list slide changes (slide number, language, new text)", "context": "Deck is the user's main presentation on 2026-10-21", "blocking": true},
|
||||
{"action": "Decide whether the continuation agent should add a PRESENT_HOST env var to sm-demo-app/scripts/dev.sh (bind present servers to 0.0.0.0 for 10.8.3.4)", "context": "Currently done via an untracked scratchpad copy of dev.sh", "blocking": false},
|
||||
{"action": "Optionally report how the speaker view (/moje-prezentacje/roadmap) behaved without Centrifugo", "context": "Executor could not log in (visitor password lives in .env, which the secret guard blocks)", "blocking": false}
|
||||
],
|
||||
"decisions": [
|
||||
{"decision": "Phase runs sequentially on main tree (workflow.use_worktrees=false); code commits go to sibling repos, planning commits to summercms.go", "rationale": "Plans target ../sm-demo-app and other siblings", "phase": "19.4.1"},
|
||||
{"decision": "Present servers bound to 0.0.0.0 via a scratchpad copy of dev.sh rather than editing dev.sh", "rationale": "Avoid uncommitted edits in a file the continuation agent will touch", "phase": "19.4.1"}
|
||||
],
|
||||
"uncommitted_files": [
|
||||
" M .planning/STATE.md",
|
||||
" M .planning/state.json",
|
||||
"?? .msd/",
|
||||
"?? .planning/phases/19.4.1-early-public-demo-on-demo-summercms-io/.gitkeep"
|
||||
],
|
||||
"next_action": "/msd-execute-phase 19.4.1 → it finds 19.4.1-01 without SUMMARY but with commits (safe_resume_gate); choose to continue at Task 4 by spawning a continuation msd-executor with the user's deck response, then write 19.4.1-01-SUMMARY.md including deviations 1-9 from .continue-here.md",
|
||||
"context_notes": "sm-demo-app is clean; 5 plan commits after 1439b3a, unpushed. No SUMMARY yet. STATE.md/state.json modifications are from state.begin-phase (and possibly other sessions) — leave alone, do not commit them with the handoff."
|
||||
}
|
||||
@@ -67,6 +67,10 @@ Validated in Phase 19.5: Social login
|
||||
|
||||
- [x] The new sm-sociallogin-plugin signs users in with Google, GitHub, Microsoft and Facebook through PHP's `/oauth/{provider}` paths, with a provider registry other plugins extend, the SPA one-time-code handoff, the pending-registration branch and linking through a one-time link ticket; a verified email auto-links only onto an account that proved its address (`users.email_verified_at` in sm-user-plugin, a deliberate divergence from PHP); `scripts/check-phase19.5.sh` is the fail-closed gate (UAT and security 2026-10-21). The email-proof fix (sm-user-plugin v0.1.5, sm-sociallogin-plugin v0.1.2) is released with the 19.8 release
|
||||
|
||||
Validated in Phase 19.6.1: Backend Administrators screen
|
||||
|
||||
- [x] Backend admin users and roles are managed in the admin SPA (Settings → System), WinterCMS-style, with `backend.manage_users` / `backend.manage_roles`, server-side privilege rules (superuser-only flag, ceilings, self-edit, outranking, last-superuser lock) and a generic record-action seam; `scripts/check-phase19.6.1.sh` is the fail-closed gate (UAT 26/26 and security 33/33 closed, 2026-10-22)
|
||||
|
||||
### Active
|
||||
|
||||
Framework kernel
|
||||
@@ -95,7 +99,7 @@ Background and integrations
|
||||
|
||||
Admin
|
||||
|
||||
- [ ] Backend admin users with roles, separate from frontend users, as in WinterCMS
|
||||
- (backend admin users and roles — moved to Validated in Phase 19.6.1)
|
||||
- [ ] `fields.yaml` and `columns.yaml` parsed (goccy/go-yaml) into a JSON form and list schema served per controller, with the field types Płytarium actually uses (text, textarea, checkbox, switch, dropdown with model-method options, relation with nameFrom/emptyOption) plus layout hints (span, tabs, context, attributes), and a first-class relation-manager schema replacing the one `partial` field
|
||||
- [ ] A minimal Vue 3 + TypeScript admin SPA that renders those schemas as lists and forms for the five Płytarium controllers (Albums, Artists, Collections, Genres, Styles), with types generated from the API's OpenAPI document
|
||||
|
||||
@@ -187,6 +191,7 @@ Validated in Phase 18.1: Payment Gateway Subscriptions
|
||||
| A soft (optional) plugin dependency still requires the provider module in `go.mod`; only `Requires()` omits it | A typed `Lookup` needs the package that declares the interface; optional means "skipped at Boot when absent", not "not compiled in" (`docs/plugins/extending.md`) | ✓ Good (Phase 19.1 UAT override, 2026-10-18) |
|
||||
| OIDC on wristband with golang-jwt v5, not zitadel/oidc (Phase 19.4, `notes/2026-10-19-oidc-on-wristband-golang-jwt.md`) | wristband already owned the OAuth flows and PHP-compatible encoding; zitadel's own storage and routing would fight both. go-oidc and x/oauth2 are test-only, for relying-party interop | ✓ Good (Phase 19.4 UAT, 2026-10-20) |
|
||||
| PHP OIDC parity is recorded at the WavePath cutover, not in Phase 19.4 (D-14 amended) | The harness ships and replays Go-side; recording needs the live PHP site, and WavePath's provider must not move until the replay is green | — Pending (todo `2026-10-19-record-php-oidc-parity-against-wavepath`) |
|
||||
| Administrators and Roles live in cabana as an internal pseudo-plugin; privilege rules run in the save transaction; contributed Administrators Runs are wrapped with `guardOutranked` | WinterCMS screens were missing and 19.7 needs the record-action seam; a delegated editor must not outrank the target or capture a code-declared role | ✓ Good (Phase 19.6.1 UAT 26/26, 2026-10-22) |
|
||||
|
||||
## Evolution
|
||||
|
||||
@@ -206,4 +211,4 @@ This document evolves at phase transitions and milestone boundaries.
|
||||
4. Update Context with current state
|
||||
|
||||
---
|
||||
*Last updated: 2026-10-21 after Phase 19.5 completion*
|
||||
*Last updated: 2026-10-22 after Phase 19.6.1 completion*
|
||||
|
||||
@@ -41,7 +41,7 @@ Decimal phases appear between their surrounding integers in numeric order.
|
||||
- [ ] **Phase 19.4.1: Early public demo on demo.summercms.io** - sm-demo-app with today's shared plugins on rome: open registration, guided tour, journal, bm's presentation system, quizzes, payments; backend by request
|
||||
- [x] **Phase 19.5: Social login in sm-user-plugin** - Google and Facebook login with the SPA one-time-code handoff (completed 2026-10-21)
|
||||
- [ ] **Phase 19.6: Two-factor auth and device flow in sm-user-plugin** - TOTP, WebAuthn, email and recovery codes, trusted devices, device authorization
|
||||
- [ ] **Phase 19.6.1: Backend Administrators screen** - Admins and roles CRUD in cabana, WinterCMS-style, with server-side privilege rules
|
||||
- [x] **Phase 19.6.1: Backend Administrators screen** - Admins and roles CRUD in cabana, WinterCMS-style, with server-side privilege rules (completed 2026-10-22)
|
||||
- [ ] **Phase 19.7: Generic MCP module** - Opt-in MCP endpoint, plugin-declared tools filtered by permissions, one connector per person via OAuth and a verified account link
|
||||
- [ ] **Phase 19.8: Console commands overhaul** - `diary` logging module, Artisan-grade global flags, help and `list` in `bonfire`, sweep of every command
|
||||
- [ ] **Phase 20: Demo instance with every shared plugin** - Add the chat family (chat, channels, video calls, chatbots, forum, herald, friends) to the live demo from Phase 19.4.1
|
||||
@@ -1396,20 +1396,20 @@ Plans:
|
||||
3. Device authorization (`devices/initiate`, `devices/status/{token}`, `devices/authorize`, and the device list and revoke) works on the `DeviceAuthSession` model.
|
||||
4. The models TwoFactorMethod, TwoFactorChallenge, TwoFactorRecoveryCode, TrustedDevice, WebAuthnCredential and DeviceAuthSession and their migrations are ported. The phase gets a security review. The new code has unit tests, delivered in the phase's last plan.
|
||||
|
||||
**Plans:** 4 plans
|
||||
**Plans:** 4/4 plans executed
|
||||
|
||||
Plans:
|
||||
**Wave 1**
|
||||
- [ ] 19.6-01-PLAN.md — Foundations: decision note for pquerna/otp, go-webauthn and boombuler/barcode, sm-user-plugin seams (login gates in Login with the restore after the gate, login and password-changed events, reset-2FA slot and permission), device authorization flow with the JTI followed through refresh, human package check (wave 1)
|
||||
- [x] 19.6-01-PLAN.md — Foundations: decision note for pquerna/otp, go-webauthn and boombuler/barcode, sm-user-plugin seams (login gates in Login with the restore after the gate, login and password-changed events, reset-2FA slot and permission), device authorization flow with the JTI followed through refresh, human package check (wave 1)
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [ ] 19.6-02-PLAN.md — New repo sm-mfa-plugin: TOTP tracer through the challenge, recovery and email codes with the D-18 hardening, trusted devices, settings screen, revocation on password change, admin reset service (wave 2)
|
||||
- [x] 19.6-02-PLAN.md — New repo sm-mfa-plugin: TOTP tracer through the challenge, recovery and email codes with the D-18 hardening, trusted devices, settings screen, revocation on password change, admin reset service (wave 2)
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [ ] 19.6-03-PLAN.md — WebAuthn second factor and passwordless passkeys, social sign-in through the gate, demo 2FA screens in vue-demo-app, release go-ahead and publishing in D-17 order, adoption in sm-demo-app and sm-bm-app, fonoteka.go pointer and guard tests (wave 3)
|
||||
- [x] 19.6-03-PLAN.md — WebAuthn second factor and passwordless passkeys, social sign-in through the gate, demo 2FA screens in vue-demo-app, release go-ahead and publishing in D-17 order, adoption in sm-demo-app and sm-bm-app, fonoteka.go pointer and guard tests (wave 3)
|
||||
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [ ] 19.6-04-PLAN.md — Unit tests for every decision, login-path invariant, PHP security test map, security review with the explicit D-14 section, scripts/check-phase19.6.sh, gated release of post-release fixes (wave 4)
|
||||
- [x] 19.6-04-PLAN.md — Unit tests for every decision, login-path invariant, PHP security test map, security review with the explicit D-14 section, scripts/check-phase19.6.sh, gated release of post-release fixes (wave 4)
|
||||
|
||||
### Phase 19.6.1: Backend Administrators screen (INSERTED)
|
||||
|
||||
@@ -1423,17 +1423,22 @@ Plans:
|
||||
2. Privilege rules hold on the server: only a superuser can create, edit or grant superuser; an admin cannot raise their own role or permissions; the last active superuser cannot be deactivated, demoted or deleted.
|
||||
3. The record-action seam on the Administrators list is usable by plugins (19.7's link action), and unit tests cover the privilege rules.
|
||||
|
||||
**Plans:** 3 plans
|
||||
**Plans:** 5/5 plans complete
|
||||
|
||||
Plans:
|
||||
- [x] 19.6.1-05-PLAN.md
|
||||
|
||||
**Wave 1**
|
||||
- [ ] 19.6.1-01-PLAN.md — server side: the pact action-extension seam, the internal summercms.cabana pseudo-plugin with the Administrators and Roles screens, every privilege rule in the save transaction (superuser hiding, ceilings, self-edit, outranking, last-superuser lock, revocation), lang keys and docs
|
||||
- [x] 19.6.1-01-PLAN.md — server side: the pact action-extension seam, the internal summercms.cabana pseudo-plugin with the Administrators and Roles screens, every privilege rule in the save transaction (superuser hiding, ceilings, self-edit, outranking, last-superuser lock, revocation), lang keys and docs
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [ ] 19.6.1-02-PLAN.md — SPA support (D-21): per-record locked permission values and the field `trigger`, regenerated OpenAPI and schema.d.ts, rebuilt modules/boardwalk/dist
|
||||
- [x] 19.6.1-02-PLAN.md — SPA support (D-21): per-record locked permission values and the field `trigger`, regenerated OpenAPI and schema.d.ts, rebuilt modules/boardwalk/dist
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [ ] 19.6.1-03-PLAN.md — unit, Postgres and SPA tests for every rule (incl. the held-lock last-superuser race), the seam and D-21, plus the check-phase19.6.1.sh gate
|
||||
- [x] 19.6.1-03-PLAN.md — unit, Postgres and SPA tests for every rule (incl. the held-lock last-superuser race), the seam and D-21, plus the check-phase19.6.1.sh gate
|
||||
|
||||
**Wave 4** *(gap closure)*
|
||||
- [x] 19.6.1-04-PLAN.md — close CR-01 (role-code capture onto code-declared grants) and WR-03 (wrap contributed Administrators actions with guardOutranked)
|
||||
|
||||
### Phase 19.7: Generic MCP module (INSERTED)
|
||||
|
||||
@@ -1449,10 +1454,37 @@ Plans:
|
||||
3. `tools/list` lists only the tools the session's principals may call (frontend permissions through the merged group/user permissions, backend permissions and token scope through cabana), and a call runs through the route's own middleware.
|
||||
4. An editor signs in once through `wristband` OAuth as a frontend user; with a verified link to a backend user, backend-guarded tools such as Journal's run as that admin, and removing the link or the grant removes them. The phase gets a security review; the MCP SDK dependency has a decision note before code lands; unit tests are the last plan.
|
||||
|
||||
**Plans:** 0 plans
|
||||
**Plans:** 9/9 plans executed
|
||||
|
||||
Plans:
|
||||
- [ ] TBD (run /msd-plan-phase 19.7 to break down)
|
||||
**Wave 1**
|
||||
- [x] 19.7-01-PLAN.md — Framework seams: bouncer dispatch marker, surf handler lookup and streaming routes, tagged pier mount hook, SDK-free pact MCP contracts, My account contribution seam, prompted record action, wristband scope set
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [x] 19.7-02-PLAN.md — The `pier` module behind `summercms_mcp` (go-sdk, hybrid stateful/stateless, Redis sessions, fan-out, PRM) and the framework release carrying 19.6.1 + 19.7-01/02
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [x] 19.7-03-PLAN.md — sm-user-plugin: verified account link, Administrators-screen link actions, plugin frontend permission codes, the `user` MCP guard and `user_me` tool, plugin release and app pointer bumps
|
||||
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [x] 19.7-04-PLAN.md — sm-oauthserver-plugin `backend` scope, `oas_at_` verifier and MCP consent JSON; Journal tools; vue-demo-app `/connect` and `/link-admin`; sm-demo-app wiring, e2e and deploy notes; plugin releases
|
||||
|
||||
**Wave 5** *(blocked on Wave 4 completion)*
|
||||
- [x] 19.7-05-PLAN.md — Unit tests across six repos, `scripts/check-phase19.7.sh`, the filled validation map and the security review
|
||||
|
||||
Gap closure (`19.7-REVIEW.md` findings, escalations E-1 and E-2; `19.7-GAP-INPUTS.md`). No tag, push or deploy until verification; then framework v0.5.0, the plugin tags, the app bumps.
|
||||
|
||||
**Gap wave 1**
|
||||
- [x] 19.7-06-PLAN.md — pier hardening (lane A): session reaper, atomic per-binding reservation, no global lock across guard I/O, identity widening, Redis fan-out for stateless instances, listen re-check, path-value rules, fixed error text, prompt write ceiling
|
||||
|
||||
**Gap wave 2** *(blocked on 19.7-06: shared pier and pact files)*
|
||||
- [x] 19.7-07-PLAN.md — Framework auth and admin (lane B): `auth_time` claim, `pact.HasFrontendTokenScopes` seam (E-2), token-specific revoke events, client address on the resolve path, My account URL and section isolation, hotkey fixes, OpenAPI and dist
|
||||
|
||||
**Gap wave 3** *(blocked on 19.7-06 and 19.7-07)*
|
||||
- [x] 19.7-08-PLAN.md — Plugins and demo (lane C): link proof on `auth_time` with the code in the fragment, grant revocation on ban/reset and link changes, member token scopes (E-2), organisation logo (E-1), Journal prompt ceiling, nginx MCP body cap
|
||||
|
||||
**Gap wave 4** *(blocked on 19.7-06, 19.7-07 and 19.7-08)*
|
||||
- [x] 19.7-09-PLAN.md — Unit tests for every fix and both escalations, the extended gate (workspace check, unreleased-pin policy), validation rows, the corrected security review, deferred items
|
||||
|
||||
### Phase 19.8: Console commands overhaul (INSERTED)
|
||||
|
||||
@@ -1470,7 +1502,7 @@ Plans:
|
||||
4. A sweep of all existing commands (framework modules and shared plugins) checks them against an Artisan feature checklist and fixes the gaps found, without changing command logic or breaking existing names and flags. The checklist covers confirmation with `--force` on destructive actions, `--pretend`/dry-run where it applies, progress bars and tables for bulk work, and `--json` output for scripting. Long-running commands such as `serve` and `queue:work` print a startup summary of what booted (environment, plugins, database and migrations state, queues, scheduler, mail, cache and realtime drivers, URLs) and report what they did on shutdown. One-shot commands end with a result line and a meaningful exit code.
|
||||
5. The `diary` and `bonfire` READMEs, the docs console and logging pages, the summercms.io landing site and its roadmap presentation reflect the new console. The new code has unit tests, delivered in the phase's last plan.
|
||||
|
||||
**Plans:** 5/6 plans executed
|
||||
**Plans:** 6/6 plans executed
|
||||
|
||||
Plans:
|
||||
**Wave 1**
|
||||
@@ -1485,7 +1517,7 @@ Plans:
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [x] 19.8-04-PLAN.md — unit and golden tests for all new code, `scripts/check-phase19.8.sh` gate across repos, post-release fixes go-ahead
|
||||
- [x] 19.8-05-PLAN.md — gap closure: fixes for the code review's critical and warning findings (live-view output order, summer delegates' exit codes and terminal, Ctrl+C cursor, dev shutdown grace, diary file retry, escape stripping, migration sets), each with a pinning test
|
||||
- [ ] 19.8-06-PLAN.md — gap closure: v0.4.2 release go-ahead, tag and changelog, demo roadmap sync, full gate
|
||||
- [x] 19.8-06-PLAN.md — gap closure: v0.4.2 release go-ahead, tag and changelog, demo roadmap sync, full gate
|
||||
|
||||
### Phase 20: Demo instance with every shared plugin
|
||||
|
||||
@@ -1541,6 +1573,137 @@ Plans:
|
||||
Plans:
|
||||
- [ ] TBD (run /msd-plan-phase 31 to break down)
|
||||
|
||||
### Phase 32: SEO foundation
|
||||
|
||||
**Goal:** As a site editor on any SummerCMS application, I want per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, so that every site ships correct, editable SEO without per-site work. The framework gains only generic seams; the SEO code lives in a new shared plugin. This covers:
|
||||
- three framework seams that name nothing SEO-specific: cross-plugin admin form extensions with `Before`/`After` field and tab placement, cabana record events, signpost content descriptors;
|
||||
- `sm-seo-plugin` (Golem15.SEO): the SEO tab on registered content types, global SEO settings with per-type templates, per-URL rules;
|
||||
- title, meta description, canonical, meta robots and `X-Robots-Tag`, Open Graph and Twitter Card;
|
||||
- 301/302/410 redirects, the 404 log, URL normalisation and strict URLs;
|
||||
- the robots.txt editor, AI bot switches, verification files;
|
||||
- MCP tools for all of it, with batch dry-run, CSV import/export and history with undo.
|
||||
|
||||
**Mode:** mvp
|
||||
**Depends on:** Phase 17 (signpost, sitemap plugin), Phase 19.7 (pier MCP)
|
||||
**Repos:** `summercms.go` (pact, cabana, signpost seams; framework release tag at the end), new `sm-seo-plugin`, `sm-journal-plugin` (signpost descriptors), the apps that mount the plugin
|
||||
**Requirements**: TBD
|
||||
**Success Criteria** (what must be TRUE):
|
||||
|
||||
1. A plugin can add a field between two fields of another plugin's admin form (A, B plus C after A renders A, C, B), and add a tab between two existing tabs; unknown anchors, duplicate names and anchor cycles stop the boot with a clear error.
|
||||
2. Journal posts, categories and tags show the SEO tab without importing `sm-seo-plugin`, and the frontend gets the effective SEO of any URL with the precedence URL rule > record > global > derived.
|
||||
3. Changing a record's slug creates a 301 and flattens existing chains; redirect loops are refused from the admin, MCP and imports.
|
||||
4. Every SEO operation in the admin is available as an MCP tool, and a batch change can be previewed with dry-run and undone from history.
|
||||
5. The framework release with the seams is tagged, and the new code has unit tests, delivered in the phase's last plan.
|
||||
|
||||
**Plans:** 6/6 plans executed
|
||||
|
||||
Plans:
|
||||
**Wave 1**
|
||||
- [x] 32-01-PLAN.md — D-91 cross-plugin admin form extensions (pact types, cabana placement and save/show wiring, docs, SPA backstop)
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [x] 32-02-PLAN.md — D-92 record events and D-93 content descriptors; Journal descriptors, journal-tag, API event emission, translated slugs
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [x] 32-03-PLAN.md — sm-seo-plugin core: SEO tab, URL rules, settings with per-type tabs, resolver, history, generate job, elements E1-E3/E7
|
||||
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [x] 32-04-PLAN.md — redirects and address-change 301, 404 log, normalisation, strict URLs, robots.txt with AI bots, verification files
|
||||
|
||||
**Wave 5** *(blocked on Wave 4 completion)*
|
||||
- [x] 32-05-PLAN.md — /_seo/api/v1 management API and MCP tools, batch dry-run, undo, CSV, demo mount proof, check-phase32.sh
|
||||
|
||||
**Wave 6** *(blocked on Wave 5 completion)*
|
||||
- [x] 32-06-PLAN.md — unit tests, additive and compat proof, framework patch release, plugin tags, demo mount, changelog
|
||||
|
||||
### Phase 32.1: MCP OAuth for plugin apps: declared scopes, MCP subject on context, per-client MCP consent (INSERTED)
|
||||
|
||||
**Goal:** As an application whose plugins declare their own member token scopes, I want an agent connected to `/mcp` over OAuth to get the same tools, attribution and revocation as one using a personal token, so that OAuth sign-in can be switched on in production. A consuming app's agent-access work found three gaps (its D-36, D-37 and D-38); all three are additive and ship as patch releases of the framework (0.5.x) and `sm-oauthserver-plugin`.
|
||||
**Requirements**: TBD
|
||||
**Depends on:** Phase 19.4 (OIDC provider on wristband), Phase 19.7 (generic MCP module)
|
||||
**Plans:** 4/5 plans executed
|
||||
|
||||
**Success Criteria** (what must be TRUE):
|
||||
1. Scopes a plugin declares through `pact.HasFrontendTokenScopes` can be requested, consented to and granted over MCP OAuth: the wristband metadata and authorize allow-list and pier's protected-resource scopes include them, so a tool route behind `user.scope:<declared>` lists and runs for an OAuth agent granted that scope. Today the list is fixed to `read`, `write`, `ai`, `offline_access` (and `backend`).
|
||||
2. A route run by an MCP tool call can read the MCP subject (guard, user, client ID, token id) from its request context through an accessor, so an application records the OAuth client of a write; a personal-token call's credential keeps carrying the token id (sm-user-plugin v0.1.14).
|
||||
3. `sm-oauthserver-plugin` records a consent for MCP grants, so the existing per-client revoke ends one agent's grant and its MCP sessions without touching the user's other agents.
|
||||
4. Module READMEs and `docs/` pages describe the three changes; the framework and `sm-oauthserver-plugin` get patch tags.
|
||||
|
||||
Plans:
|
||||
**Wave 1**
|
||||
- [x] 32.1-01-PLAN.md — Framework seam: catalog, MCPCall, one advertised scope list
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [x] 32.1-02-PLAN.md — sm-user-plugin from v0.1.14: publish the catalog and Implies for OAuth subjects
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [x] 32.1-03-PLAN.md — sm-oauthserver-plugin: consent replace, revoke, backfill
|
||||
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [x] 32.1-04-PLAN.md — vue-oauth-layer /connect checkboxes
|
||||
|
||||
**Wave 5** *(blocked on Wave 4 completion)*
|
||||
- [ ] 32.1-05-PLAN.md — Unit tests, then the release checkpoint
|
||||
|
||||
### Phase 33: SEO output, audit and content
|
||||
|
||||
**Goal:** As a site editor and as an SEO specialist auditing a SummerCMS site, I want the rendered sites to emit complete SEO output (sitemaps, structured data, pagination, hreflang, headings, breadcrumbs) from the CMS, and an audit that finds the remaining problems, so that sites are indexed correctly and issues can be fixed through MCP. Decisions are in `.planning/phases/32-seo-foundation/32-CONTEXT.md`. This covers:
|
||||
- the `sm-sitemap-plugin` rewrite to a sitemap index split by type (breaking, D-32), image/News/IndexNow options, the HTML sitemap;
|
||||
- the page registry in `sm-seo-plugin`;
|
||||
- JSON-LD `@graph` per page type, pagination, hreflang in head and sitemaps;
|
||||
- heading rules (no H1 in content), breadcrumbs;
|
||||
- a shared Nuxt SEO layer, with the SSR build guard and the layers and apps moved onto it;
|
||||
- the crawler and issue report;
|
||||
- internal linking, auto-links and the orphan report;
|
||||
- media SEO (alt, file names, formats).
|
||||
|
||||
**Mode:** mvp
|
||||
**Planning:** exception to the lean-planning rule approved by Jakub on 2026-10-25: about 12–15 smaller plans instead of a few large ones.
|
||||
**Depends on:** Phase 32
|
||||
**Repos:** `sm-sitemap-plugin`, `sm-seo-plugin`, `sm-journal-plugin`, `sm-faq-plugin`, the Nuxt layers (new SEO layer, journal, menu, FAQ), the apps (grzybyfunkcjonalne migrates its sitemap in the same delivery)
|
||||
**Requirements**: TBD
|
||||
**Success Criteria** (what must be TRUE):
|
||||
|
||||
1. Every site serves a sitemap index with per-type files of a configurable size, stable numbering and real `lastmod`, consistent with noindex and robots.txt, and grzybyfunkcjonalne.pl runs on the new format.
|
||||
2. Indexable pages render server-side with head tags, one JSON-LD `@graph`, hreflang and breadcrumbs from the CMS, and a build fails when an indexable route has `ssr: false`.
|
||||
3. The crawler reports SEO issues per URL, and each issue can be fixed through MCP.
|
||||
4. The new code has unit tests, delivered in the phase's last plan.
|
||||
|
||||
**Plans:** 14 plans
|
||||
|
||||
Plans:
|
||||
**Wave 1**
|
||||
- [ ] 33-01-PLAN.md — framework: additive content descriptor fields and per-request field options, check-phase33.sh, v0.5.2 release log (no tag)
|
||||
- [ ] 33-07-PLAN.md — vue-seo-layer (new repository): CMS head and one JSON-LD graph, redirect/410 enforcement, root files, 404 report, shared purge route
|
||||
|
||||
**Wave 2** *(blocked on Wave 1 completion)*
|
||||
- [ ] 33-02-PLAN.md — sm-journal-plugin: per-site H1 setting on every write path, editor J1–J4, descriptor facts, journal-author type, MCP tools
|
||||
- [ ] 33-03-PLAN.md — sm-sitemap-plugin: sitemap index with per-type files, slot table, real lastmod, hreflang, filter contract (breaking, D-32)
|
||||
- [ ] 33-08-PLAN.md — vue-seo-layer: SSR build guard, noindex routes, route report, drift check, breadcrumbs, pagination, HTML sitemap
|
||||
|
||||
**Wave 3** *(blocked on Wave 2 completion)*
|
||||
- [ ] 33-04-PLAN.md — sm-sitemap-plugin: image and News sitemaps, IndexNow, HTML-sitemap API, MCP tools
|
||||
- [ ] 33-09-PLAN.md — journal, menu and FAQ layers on the SEO layer: headings in both H1 modes, one link per card, body links, breadcrumbs, pagination, related posts
|
||||
|
||||
**Wave 4** *(blocked on Wave 3 completion)*
|
||||
- [ ] 33-05-PLAN.md — sm-seo-plugin I: sitemap filter, page registry with route report, site endpoint, llms.txt, Links settings, purge after writes
|
||||
|
||||
**Wave 5** *(blocked on Wave 4 completion)*
|
||||
- [ ] 33-06-PLAN.md — sm-seo-plugin II: JSON-LD @graph, publisher, schema fields (E8/E9), breadcrumbs, hreflang, pagination; chromedp and webp legitimacy checkpoint
|
||||
|
||||
**Wave 6** *(blocked on Wave 5 completion)*
|
||||
- [ ] 33-10-PLAN.md — sm-seo-plugin: crawler with optional rendered comparison (chromedp), issue report with fix routes, Site audit and Crawls, MCP tools
|
||||
|
||||
**Wave 7** *(blocked on Wave 6 completion)*
|
||||
- [ ] 33-11-PLAN.md — internal linking and media: auto-links, link suggestions (E10), WebP variants with srcset
|
||||
|
||||
**Wave 8** *(blocked on Wave 7 completion)*
|
||||
- [ ] 33-12-PLAN.md — apps I: demo end to end on local links, summercms.io patches, sm-bm-app noindex (D-72)
|
||||
- [ ] 33-13-PLAN.md — grzybyfunkcjonalne.pl on the new sitemap format and the SEO layer; uat deploy by decision
|
||||
|
||||
**Wave 9** *(blocked on Wave 8 completion)*
|
||||
- [ ] 33-14-PLAN.md — unit tests, check-phase33.sh --all, release tags in order, app re-pins, changelog post
|
||||
|
||||
## Progress
|
||||
|
||||
**Execution Order:**
|
||||
@@ -1587,13 +1750,15 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 →
|
||||
| 19.4. OIDC provider on wristband | 4/4 | Complete | 2026-10-20 |
|
||||
| 19.4.1. Early public demo on demo.summercms.io | 5/5 | In Progress| |
|
||||
| 19.5. Social login in sm-user-plugin | 5/5 | Complete | 2026-10-21 |
|
||||
| 19.6. Two-factor auth and device flow in sm-user-plugin | 0/TBD | Not started | - |
|
||||
| 19.6.1. Backend Administrators screen (INSERTED) | 0/TBD | Not started | - |
|
||||
| 19.7. Generic MCP module | 0/TBD | Not started | - |
|
||||
| 19.8. Console commands overhaul (INSERTED) | 5/6 | In Progress| |
|
||||
| 19.6. Two-factor auth and device flow in sm-user-plugin | 4/4 | In Progress| |
|
||||
| 19.6.1. Backend Administrators screen (INSERTED) | 5/5 | Complete | 2026-10-22 |
|
||||
| 19.7. Generic MCP module | 9/9 | In Progress| |
|
||||
| 19.8. Console commands overhaul (INSERTED) | 6/6 | In Progress| |
|
||||
| 20. Demo instance with every shared plugin | 0/TBD | Not started | - |
|
||||
| 30. Płytarium cutover | 0/TBD | Not started | - |
|
||||
| 31. Chat polish against WavePath clients | 0/TBD | Not started | - |
|
||||
| 32. SEO foundation | 6/6 | In Progress| |
|
||||
| 33. SEO output, audit and content | 0/14 | Planned | - |
|
||||
|
||||
## Backlog
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
---
|
||||
msd_state_version: "1.0"
|
||||
milestone: v1.0
|
||||
current_phase: 19.4.1
|
||||
current_phase_name: Early public demo on demo.summercms.io
|
||||
status: Ready for verification — 6/6 plans executed, UAT in progress (19.3-UAT.md)
|
||||
stopped_at: Phase 19.4.1 context gathered
|
||||
last_updated: "2026-10-20T01:33:22.399Z"
|
||||
last_activity: 2026-10-20
|
||||
last_activity_desc: "Completed quick task 261020-42e: branded HTML error pages for browsers"
|
||||
state_head: 2b5f0b2c92e0bc38070c7f4a8870f64e2c430bb8
|
||||
current_phase: "19.7"
|
||||
current_phase_name: Generic MCP module (INSERTED)
|
||||
status: verifying
|
||||
stopped_at: Phase 32 context gathered
|
||||
last_updated: "2026-10-25T21:26:24.117Z"
|
||||
last_activity: 2026-10-23
|
||||
last_activity_desc: "Completed 19.7-08: plugin gap closure, E-1 logo, E-2 member token scopes; paused before 19.7-09"
|
||||
state_head: 9a76c7ec1c0c17e93e00086231af78648eb40c43
|
||||
progress:
|
||||
total_phases: 43
|
||||
completed_phases: 35
|
||||
total_plans: 217
|
||||
completed_plans: 208
|
||||
total_phases: 47
|
||||
completed_phases: 37
|
||||
total_plans: 242
|
||||
completed_plans: 238
|
||||
gsd_state_version: "1.0"
|
||||
milestone_name: milestone
|
||||
---
|
||||
@@ -22,25 +22,25 @@ milestone_name: milestone
|
||||
|
||||
## Project Reference
|
||||
|
||||
See: .planning/PROJECT.md (updated 2026-10-12)
|
||||
See: .planning/PROJECT.md (updated 2026-10-22)
|
||||
|
||||
**Core value:** An existing WinterCMS-shaped app can be ported plugin by plugin to a single Go binary without its frontend noticing: the PHP version's API contract is the acceptance test.
|
||||
**Current focus:** Phase 19.3 — Framework transport and infrastructure for WavePath (UAT in progress)
|
||||
**Current focus:** Phase 19.7 — Generic MCP module (INSERTED)
|
||||
|
||||
## Current Position
|
||||
|
||||
Phase: 19.4.1 (Early public demo on demo.summercms.io) — READY TO EXECUTE
|
||||
Plan: 6 of 6
|
||||
Status: Ready for verification — 6/6 plans executed, UAT in progress (19.3-UAT.md)
|
||||
Last activity: 2026-10-20 - Completed quick task 261020-42e: branded HTML error pages for browsers
|
||||
Phase: 19.7 (Generic MCP module (INSERTED)) — EXECUTING
|
||||
Plan: 5 of 5
|
||||
Status: Phase complete — ready for verification
|
||||
Last activity: 2026-10-23 — Phase 19.7 execution started
|
||||
|
||||
Progress: [████████░░] 83%
|
||||
Progress: [████████░░] 82%
|
||||
|
||||
## Performance Metrics
|
||||
|
||||
**Velocity:**
|
||||
|
||||
- Total plans completed: 105
|
||||
- Total plans completed: 115
|
||||
- Average duration: 21 min
|
||||
- Total execution time: 104 min
|
||||
|
||||
@@ -66,6 +66,8 @@ Progress: [████████░░] 83%
|
||||
| 19 | 7 | - | - |
|
||||
| 19.1 | 6 | - | - |
|
||||
| 19.4 | 4 | - | - |
|
||||
| 19.5 | 5 | - | - |
|
||||
| 19.6.1 | 5 | - | - |
|
||||
|
||||
**Recent Trend:**
|
||||
|
||||
@@ -263,6 +265,19 @@ Progress: [████████░░] 83%
|
||||
| Phase 19.4 P02 | 50min | 5 tasks | 54 files |
|
||||
| Phase 19.4 P03 | 71 min | 7 tasks | 61 files |
|
||||
| Phase 19.4 P04 | 65 min | 5 tasks | 42 files |
|
||||
| Phase 19.4.1 P01 | 70min | 4 tasks | 24 files |
|
||||
| Phase 19.4.1 P02 | ~2h45m | 7 tasks | 43 files |
|
||||
| Phase 19.4.1 P03 | ~1h50m | 8 tasks | 58 files |
|
||||
| Phase 19.4.1 P04 | 2h25m | 7 tasks | 85 files |
|
||||
| Phase 19.4.1 P05 | 70min | 7 tasks | 46 files |
|
||||
| Phase 19.8 P01 | 30 min | 3 tasks | 86 files |
|
||||
| Phase 19.8 P02 | 28 min | 3 tasks | 38 files |
|
||||
| Phase 19.8 P03 | 3h 3m (segment B) | 8 tasks | 120 files |
|
||||
| Phase 19.8 P05 | 40min | 7 tasks | 33 files |
|
||||
| Phase 19.6.1 P04 | 18 min | 3 tasks | 10 files |
|
||||
| Phase 19.6.1 P05 | 4 min | 2 tasks | 7 files |
|
||||
| Phase 19.7 P01 | 52 min | 5 tasks | 64 files |
|
||||
| Phase 19.7 P02 | 38 min | 4 tasks | 36 files |
|
||||
|
||||
## Accumulated Context
|
||||
|
||||
@@ -297,6 +312,11 @@ Progress: [████████░░] 83%
|
||||
- Phase 19.7 inserted after Phase 19.6: Generic MCP module: opt-in endpoint, plugin-declared tools, one connector per person (from /msd-explore 2026-10-17)
|
||||
- Phase 20 reordered: Roadmap reordered (/msd-explore 2026-10-18): new Phase 20 Demo instance with every shared plugin; Płytarium cutover moved 20 → 30; Chat polish against WavePath clients moved 19.2 → 31; 21–29 added as their goals firm up
|
||||
- Phase 19.4.1 inserted after Phase 19.4: Early public demo on demo.summercms.io: today's 16 shared plugins on rome, demo accounts, journal/presentations/quizzes/OIDC pages, backend by request; Phase 20 narrows to the chat family (URGENT)
|
||||
- Phase 32 added: Console commands overhaul: diary logging module, bonfire global flags and Artisan-grade help, sweep of all commands, tests
|
||||
- Phase 19.6.1 inserted after Phase 19.6: Backend Administrators screen: admins and roles CRUD in cabana (gap found while planning 19.7: no screen to manage backend users or set the frontend link) (URGENT)
|
||||
- Phase 32 added: SEO foundation: per-record and global SEO, structured data per page type, sitemap boost and HTML sitemap, pagination, redirects, robots.txt, canonical, meta robots, social tags, headings, hreflang, noindex policy, SSR for headless frontends
|
||||
- Phase 32 edited: narrowed to framework seams and sm-seo-plugin core (split decided 2026-10-25)
|
||||
- Phase 33 added: SEO output, audit and content; large phase, lean-planning exception
|
||||
|
||||
### Decisions
|
||||
|
||||
@@ -893,6 +913,47 @@ Recent decisions affecting current work:
|
||||
- [Phase 19.4]: Phase gate stages split by Docker need; the application's unrelated admin route test stays outside the gate (deferred-items)
|
||||
- [Phase 19.4]: PHP method map: 171 methods, 146 ported, 25 adapted with reasons, none not-applicable
|
||||
- [Phase 19.4]: Parity NOT RUN points to the WavePath cutover todo and does not hold the verdict (D-14 amended); PHASE194_REQUIRE_PARITY=1 fails
|
||||
- [Phase 19.4.1]: Roadmap decks use the new summer deck theme (summercms.io look: navy, sun yellow, Roboto), chosen at the deck review; fonts vendored from the summercms.io build in sm-bm-app, no new npm dependency
|
||||
- [Phase 19.4.1]: golem15.presentations gets summer as an additive theme option; plan 04 must port summer.css and accept summer in the demo deck API
|
||||
- [Phase 19.4.1]: Admin public at https://demo.summercms.io/smbackend, login required, /backend 404 (user, 2026-10-20). Replaces the phase goal's and D-04's 'admin backend stays private'. Plans 03-05 recheck: plan 03 CTA/contact form wording, CONTEXT deployment note, threat row T-19.4.1-06 (new mitigation: login required, credentials on request, 5/min login throttle per real IP via Cloudflare real-IP, then 429), seeded FAQ 'The admin is private on this demo' (seed.go and the live row). — The user asked for the admin at the Task 7 review of the first live release; the throttle was checked live behind Cloudflare.
|
||||
- [Phase 19.4.1]: The 'Want to see the backend? Contact Golem15' CTA stays a contact CTA and does not link to /smbackend (user, 2026-10-20). The admin URL is public, its credentials are not; Golem15 hands them out on request. Plan 03's contact form (D-04) still applies; only its wording and the threat model change. — Resolves the open question raised by the /smbackend decision.
|
||||
- [Phase 19.4.1]: Plugin release tags for the demo: paymentgateway v0.1.0; sitemap, menu, faq, oauthserver v0.1.0; pgsub v0.1.2 and pgstripe v0.1.2 re-tagged on paymentgateway v0.1.0; translate v0.1.2 and presentations v0.1.1. sm-demo-app go.mod requires tags only (summercms v0.3.0), no replace; release builds use GOWORK=off. — D-03; tags confirmed with git ls-remote after each push.
|
||||
- [Phase 19.4.1]: 19.4.1-03: tags sm-user-plugin v0.1.3 (7b9faa3) and sm-journal-plugin v0.2.1 (fe1bbc2); sm-demo-app requires both, other apps' pins untouched; Phase 19.5 takes the next free sm-user-plugin tag
|
||||
- [Phase 19.4.1]: 19.4.1-03: Turnstile is opt-in in the core user plugin (golem15.user.turnstile, empty default adds nothing, open|closed on /login and /register only, invalid value fails boot); the demo sets closed
|
||||
- [Phase 19.4.1]: 19.4.1-04: the demo runs its own Centrifugo v6.5.1 on rome (127.0.0.1:8010, /usr/local/bin/centrifugo, supervisor summercms-demo-centrifugo) with its own secrets; nothing shared with bm (D-17). Assumption A3 held: static_headers under channel.proxy.subscribe.http is accepted.
|
||||
- [Phase 19.4.1]: 19.4.1-04: logged in, the home page's Presentations card and a header link go to My presentations (/presentations); logged out the card goes straight to the deck of the language. SSR reads the session cookie, so server and hydrated links agree.
|
||||
- [Phase 19.4.1]: 19.4.1-04: on a computer the remote opens in a 390x844 named popup (speaker view Open remote, My presentations Remote); opened without noopener to detect blocking, opener cut at once; blocked popups fall back to a tab; phones open it in place. No QR code exists (would need an approved package).
|
||||
- [Phase 19.4.1]: 19.4.1-04: the demo deck API refuses edits to a published deck (403), keeping the seeded roadmap decks intact.
|
||||
- [Phase 19.4.1]: Phase 19.4.1 database tests boot the whole demo on a fresh database cloned from a migrated template per plugin list (internal/demotest, one postgres:15 container per test binary)
|
||||
- [Phase 19.4.1]: bm's frontend library tests run byte-identical in vue-demo-app under vitest 3.2.7; aliases map bm's @/api, @/deck and ../../deck/ layout
|
||||
- [Phase 19.4.1]: sm-demo-app scripts/check-all.sh is the phase gate: every suite, the release build, pin/deploy/smoke checks, local browser checks when the stack is up, and check-live
|
||||
- [Phase 19.8]: Charm v2 stack on charm.land paths (decision note 2026-10-21-console-charm-stack.md); plan 19.8-01 installed lipgloss v2.0.6 and colorprofile v0.4.3 only
|
||||
- [Phase 19.8]: diary owns the process logger: config/log.yaml channels (console, stderr, daily, stack, null), per-component levels, sunscreen on every leaf, daily files on by default (storage/logs, 14 days)
|
||||
- [Phase 19.8]: wristband and bouncer now import diary for their log lines, amending their dependency-free leaf status (confirmed by the user 2026-10-21: diary is the one allowed framework import, and wristband is required to use it)
|
||||
- [Phase 19.8]: 19.8-02: bonfire.NewRoot sends the error block to stderr when its output is os.Stdout; Output.Error keeps its stream, so no command output moves
|
||||
- [Phase 19.8]: 19.8-02: bonfire.Execute resets persistent flags per run and routes a call without a command word (globals, -h, --help) to the Artisan list; fang runs without version, man page and completions
|
||||
- [Phase 19.8]: 19.8-02: --no-ansi on an interactive terminal uses the plain line prompts (no huh, no selector); -n and -q return prompt defaults; ConfirmProceed never asks off an interactive terminal
|
||||
- [Phase 19.8]: 19.8-02: one live view at a time; output and diary log lines printed while it runs go above it via bonfire.PrintAbove (Program.Send, safe after the program ends)
|
||||
- [Phase 19.8]: 19.8-02: builtin list and help carry Long and Examples so the framework CheckDocs test in plan 3 covers them
|
||||
- [Phase 19.8]: 19.8-03: SummerCMS v0.4.0 tagged at 99b6df4 and pushed with its changelog post; commits other sessions made during the run stay local
|
||||
- [Phase 19.8]: 19.8-03: the ten plugins applications mount got patch tags (user v0.1.6, journal v0.2.2, pgstripe v0.1.3, the rest v0.1.1) because sm-demo-app refuses pseudo-version pins
|
||||
- [Phase 19.8]: 19.8-03: chat and forum require sm-user-plugin v0.1.2 (classes.DeletingEvent); plugins log through a package-level pluginLog = diary.For(code)
|
||||
- [Phase 19.8]: 19.8-05: CR-01 prints above live views by sending tea.Println messages straight to the program queue under liveMu; unregister/finish/wait as one locked, deferred step
|
||||
- [Phase 19.8]: 19.8-05: WR-01 handled inside runLive (relay SIGINT/SIGTERM while a view runs, Kill, re-raise); generated main unchanged
|
||||
- [Phase 19.8]: 19.8-05: CR-02 uses the additive bonfire.WithExitCode carrier; CR-03 delegates get os.Stdout/os.Stderr on a terminal, stderr kept apart otherwise
|
||||
- [Phase 19.8]: 19.8-05: dev.ShutdownGrace (15s) shared by summer dev and delegates; daily files retry after a minute or on a new date; replaced daily writers are retired
|
||||
- [Phase 19.8]: 19.8-05: bonfire.Sanitize (additive) replaces diary's sanitizer; Migrate iterates migrationSets
|
||||
- [Phase 19.6.1]: Roles create and update refuse any new code that rolePermissions attaches grants to, including when the editor is a superuser — D-16 stricter reading from the gap contract: a role never becomes a code-declared system role through the Roles screen
|
||||
- [Phase 19.6.1]: cabana wraps contributed Administrators Runs; guardOutranked stays unexported and contributors do not own the check — D-19 gap contract: wrap in cabana so a contribution to summercms.cabana.users cannot skip outranking
|
||||
- [Phase 19.6.1]: Persist picked relation labels on the form via FORM_REMEMBER_LABEL; keep the one-panel FormGrid (do not v-show inactive tabs) — UAT G-19.6.1-T2 is labeling only; v-show of inactive tabs would change trigger hide-tab, ML locale reset, and field mount cost
|
||||
- [Phase 19.6.1]: Administrators and Roles are cabana screens behind backend.manage_users / backend.manage_roles with no default role grant; privilege rules run in the save tx; last-superuser uses pg_advisory_xact_lock; contributed Administrators Runs are wrapped with guardOutranked.
|
||||
- [Phase 19.7]: 19.7-01: planner decisions P-01..P-04 implemented: bouncer.Dispatch context-only marker honoured by Registry.Middleware and cabana.ResolveBackend; account contributions as pact.HasAccountContributions; prompted record actions post payload as a JSON string; pact MCP types carry the principal as any and stay SDK-free
|
||||
- [Phase 19.7]: 19.7-01: wristband authorize allow-list is exactly Options.ScopesSupported (empty keeps the PHP default); surf stream routes recover with an opaque 500 only before the first byte; account contribution Run runs without a transaction only when no database is published
|
||||
- [Phase 19.7]: Framework release is v0.5.0 (19.7-02 Task 5), carrying 19.6.1, 19.7 plans 01-02 and a set of 7 msd-quick patches; tag only after all 7 are committed — User decision 2026-10-22: minor bump for the new pier module and pact capabilities; hold the tag until the quick patches land
|
||||
- [Phase 19.7]: v0.5.0 is tagged only when phase 19.7 is fully complete (plans 01-05 and phase verification); supersedes the earlier 19.7-02 Task 5 entry. Plan 02 closes without a tag; no intermediate framework tag for 19.7 work — User decision 2026-10-23: a minor version marks the finished MCP phase, not a partial one
|
||||
- [Phase 19.7]: Once the user confirms all in-flight msd-quick tasks are finished: release the framework as the next v0.4.x patch (carrying the quick patches and 19.7 work so far) and tag the held user-plugin fixes; plugins may be tagged mid-phase. Framework v0.5.0 stays reserved for full MCP usability at phase 19.7 completion — User decision 2026-10-23: plugins can be tagged now, framework 0.5 means the MCP phase is finished; wait for the user's word that the last quick agent is done
|
||||
- [Phase 19.7]: 19.7-02: pier serves 2025-11-25 clients through its own session router over StreamableServerTransport (Redis-shared sessions, D-25) and 2026-07-28 clients through the SDK stateless handler; plan 02 closed without a tag, pier ships opt-in in v0.4.4 (summercms_mcp tag plus mcp.enabled, default off)
|
||||
- [Phase 19.7]: Released framework v0.4.4 (e2759d6, changelog id 39) and sm-user-plugin v0.1.9 (3828a65; requires v0.4.3); sm-demo-app bumped to user v0.1.9 locally (a25444e, unpushed). Other apps not bumped yet — User go-ahead 2026-10-23 after all quick tasks finished; all release gates green at e2759d6
|
||||
|
||||
### Pending Todos
|
||||
|
||||
@@ -903,22 +964,31 @@ Recent decisions affecting current work:
|
||||
- [unknown] [sm-user-plugin / cabana] Verified link between a frontend user and a backend user — [todo file](.planning/todos/pending/2026-10-17-frontend-backend-account-link.md)
|
||||
- [unknown] [sm-user-plugin / pact] Plugins register their frontend permission codes in Go — [todo file](.planning/todos/pending/2026-10-17-plugin-registered-frontend-permissions.md)
|
||||
- [2026-10-19] [sm-oauthserver-plugin] Record PHP OIDC parity against WavePath before the OIDC cutover — [todo file](.planning/todos/pending/2026-10-19-record-php-oidc-parity-against-wavepath.md)
|
||||
- [2026-10-20] [consumers] Move grzybyfunkcjonalne to NUXT_CACHE_PURGE_TOKEN and the new layers before the NUXT_SITE_CACHE_* names are dropped — [todo file](.planning/todos/pending/2026-10-20-rename-site-cache-purge-env-in-consumers.md)
|
||||
- [2026-10-21] [framework] Quiet plugin boot logs on console commands like --help — [todo file](.planning/todos/pending/2026-10-21-quiet-plugin-boot-logs-on-console-commands.md) — Needs TBD. Options, possibly combined:.
|
||||
- [2026-10-22] [framework] Console review info findings (IN-01..IN-13) and the delegate signal exit code — [todo file](.planning/todos/pending/2026-10-22-console-review-info-findings.md)
|
||||
- [2026-10-22] [sm-user-plugin] User login ignores is_activated — [todo file](.planning/todos/pending/2026-10-22-user-login-ignores-is-activated.md)
|
||||
- [2026-10-22] [sm-user-plugin] User login lockout and same-second cutoff — [todo file](.planning/todos/pending/2026-10-22-user-login-lockout-and-same-second-cutoff.md)
|
||||
- [2026-10-22] [sm-user-plugin] User login opt-in session cookie — [todo file](.planning/todos/pending/2026-10-22-user-login-opt-in-session-cookie.md)
|
||||
- [2026-10-22] [sm-user-plugin] User logout blacklist missing under serve — [todo file](.planning/todos/pending/2026-10-22-user-logout-blacklist-missing-under-serve.md)
|
||||
- [2026-10-22] [user-plugin] User plugin logout leaves the session cookie valid for up to 60 minutes — [todo file](.planning/todos/pending/2026-10-22-user-logout-cookie-stays-valid.md)
|
||||
- [2026-10-22] [sm-user-plugin] User password routes 404 switch — [todo file](.planning/todos/pending/2026-10-22-user-password-routes-404-switch.md)
|
||||
- [2026-10-22] [sm-user-plugin] User session routes ignore the cookie — [todo file](.planning/todos/pending/2026-10-22-user-session-routes-ignore-cookie.md)
|
||||
- [unknown] [cabana / admin] Audit-log admin action runs with the admin id (toolbar actions) — [todo file](.planning/todos/pending/admin-action-audit-log.md)
|
||||
- [unknown] [summercms.go bonfire] Reject duplicate console command names in bonfire.NewRoot — [todo file](.planning/todos/pending/bonfire-duplicate-command-names.md)
|
||||
- [unknown] [sm-faq-plugin] Port the FAQ plugin as sm-faq-plugin so FAQs become editable — [todo file](.planning/todos/pending/faq-plugin-port.md)
|
||||
- [2026-10-09] [plugins] Expose author subtitle, description and avatar on the Journal author API — [todo file](.planning/todos/pending/journal-author-profile-fields.md)
|
||||
- [unknown] [summercms.go lagoon] lagoon README registers an after-commit GORM callback that can sort after the flush — [todo file](.planning/todos/pending/lagoon-readme-after-commit-callback-order.md)
|
||||
- [unknown] [sm-user-plugin mail] Port MailBlocker and the block-mail checkbox with the mailing work — [todo file](.planning/todos/pending/mailblocker-with-mailing.md)
|
||||
- [unknown] [sm-menu-plugin] Port the menu plugin as sm-menu-plugin so blog menus become editable — [todo file](.planning/todos/pending/menu-plugin-port.md)
|
||||
- [2026-10-21] [sm-user-plugin] Let password-less social accounts set a first password through change-password — [todo file](.planning/todos/pending/oauth-password-bootstrap-change-password.md)
|
||||
- [unknown] [summercms.go/modules/*/README.md, internal/docsite] Convert module README Go code blocks to compiled src= references — [todo file](.planning/todos/pending/readme-go-fences-src.md)
|
||||
- [unknown] [../fonoteka.go/README.md] Refresh fonoteka.go README — short status plus migrate/serve/login — [todo file](.planning/todos/pending/refresh-fonoteka-readme.md)
|
||||
- [unknown] [cabana] Show the administrators holding a role on the Roles screen — [todo file](.planning/todos/pending/roles-screen-holders-list.md)
|
||||
- [unknown] [summercms.go internal/build] make:admin-controller output does not boot and names the model after the controller — [todo file](.planning/todos/pending/scaffold-admin-controller-incomplete.md)
|
||||
- [unknown] [summercms.go internal/build] Scaffolded files carry a DO NOT EDIT header, and make:command cannot reach the application — [todo file](.planning/todos/pending/scaffold-generated-header-and-command-deps.md)
|
||||
- [unknown] [summercms.go internal/build] make:model and make:migration in the same second produce migrations that run out of order — [todo file](.planning/todos/pending/scaffold-same-second-migration-order.md)
|
||||
- [2026-10-12] [framework] Purge the Nuxt site cache on menu and FAQ admin saves (framework-level purge service) — [todo file](.planning/todos/pending/site-cache-purge-for-menu-and-faq.md)
|
||||
- [unknown] [sm-sitemap-plugin] Port the sitemap plugin 1:1 as sm-sitemap-plugin for the next blog project — [todo file](.planning/todos/pending/sitemap-plugin-port.md)
|
||||
- [unknown] [sm-sitemap-plugin] Sitemap - replace the browser XSLT view before Chromium drops XSLT — [todo file](.planning/todos/pending/sitemap-xslt-browser-deprecation.md)
|
||||
- [unknown] [sm-user-plugin] Let the sm-user-plugin console commands open their own database — [todo file](.planning/todos/pending/user-plugin-commands-open-database.md)
|
||||
|
||||
### Blockers/Concerns
|
||||
|
||||
@@ -979,6 +1049,16 @@ Recent decisions affecting current work:
|
||||
| 261019-hgw | Translate hook ValidationError phrase keys in the request locale | 2026-10-19 | ce8d7ef | [261019-hgw-translate-hook-validationerror-phrase-ke](./quick/261019-hgw-translate-hook-validationerror-phrase-ke/) |
|
||||
| 261020-13e | Admin image previews of public files fall back to the authenticated thumb route | 2026-10-19 | 1ab7db4 | [261020-13e-admin-file-upload-widget-image-preview-a](./quick/261020-13e-admin-file-upload-widget-image-preview-a/) |
|
||||
| 261020-42e | branded HTML error pages for browsers | 2026-10-20 | a34c251 | [261020-42e-branded-html-error-pages-for-browsers-un](./quick/261020-42e-branded-html-error-pages-for-browsers-un/) |
|
||||
| 261020-sdt | Rotate the site-cache purge token and rename the layer variable (demo + summercms.io) | 2026-10-20 | 4270d05 | [261020-sdt-rotate-the-purge-token-and-rename-the-la](./quick/261020-sdt-rotate-the-purge-token-and-rename-the-la/) |
|
||||
| 261022-4z8 | Fix the open 19.8 re-review findings (WR-09..WR-14, IN-14, IN-15) | 2026-10-22 | b1fba7e | [261022-4z8-fix-the-open-19-8-re-review-findings-wr-](./quick/261022-4z8-fix-the-open-19-8-re-review-findings-wr-/) |
|
||||
| 261022-k9k | Admin keyboard shortcuts: Ctrl+S, Ctrl+Enter, Ctrl+Shift+S (Create and new), / search, Esc, ? help | 2026-10-22 | 604fee7 | [261022-k9k-keyboard-shortcuts-in-the-admin-spa-ctrl](./quick/261022-k9k-keyboard-shortcuts-in-the-admin-spa-ctrl/) |
|
||||
| 261022-tb4 | Password /login refuses a not-activated account while require_activation is on (sm-user-plugin 15ff979, unreleased: hold until the escalation batch lands) | 2026-10-22 | 15ff979 (sm-user-plugin) | [261022-tb4-password-login-must-refuse-is-activated-](./quick/261022-tb4-password-login-must-refuse-is-activated-/) |
|
||||
| 261022-tto | User plugin /fetch, /refresh, /update, /change-password accept token/auth_token session cookies (sm-user-plugin 8e4b863, ships v0.5.0) | 2026-10-22 | 8e4b863 (sm-user-plugin) | [261022-tto-fetch-refresh-update-change-password-mus](./quick/261022-tto-fetch-refresh-update-change-password-mus/) |
|
||||
| 261022-usi | User plugin jwt blacklist and GORM hooks wired via lagoon.OnDatabase so logout revokes under serve; jwt guard uses SessionCookieNames (sm-user-plugin 4bf44fc, ships v0.5.0) | 2026-10-22 | 4bf44fc (sm-user-plugin) | [261022-usi-user-plugin-jwt-blacklist-and-hooks-wire](./quick/261022-usi-user-plugin-jwt-blacklist-and-hooks-wire/) |
|
||||
| 261022-vfz | User plugin /login throttle keyed on surf.ClientIP (trusted proxies); reset-password and admin password set stamp tokens_valid_after in whole seconds (sm-user-plugin b6f8055, a484d0e, ships v0.5.0; verified) | 2026-10-22 | b6f8055, a484d0e (sm-user-plugin) | [261022-vfz-user-plugin-login-throttle-via-surf-clie](./quick/261022-vfz-user-plugin-login-throttle-via-surf-clie/) |
|
||||
| 261022-wah | User plugin opt-in golem15.user.jwt.token_cookie (default off) sets the HttpOnly auth.cookie session cookie on /login, /register and /activate-by-code instead of the body token; a /refresh carried by the auth.cookie cookie rewrites it (sm-user-plugin 846087d, 8bdf2c7, ships v0.5.0; verified) | 2026-10-22 | 846087d, 8bdf2c7 (sm-user-plugin) | [261022-wah-opt-in-httponly-session-cookie-on-user-p](./quick/261022-wah-opt-in-httponly-session-cookie-on-user-p/) |
|
||||
| 261022-x7a | User plugin golem15.user.password.public_routes (default true): false leaves POST /login, /forgot-password and /reset-password unregistered so they 404 like unknown paths; /register and the rest unchanged (sm-user-plugin 3828a65, ships v0.5.0; verified) | 2026-10-22 | e5dd457 | [261022-x7a-user-plugin-golem15-user-password-public](./quick/261022-x7a-user-plugin-golem15-user-password-public/) |
|
||||
| 55 | fix(cabana): backend subject events reach pier as *pact.MCPSubjectChanged after commit | 2026-10-23 | 7c43820 | — |
|
||||
|
||||
## Deferred Items
|
||||
|
||||
@@ -990,6 +1070,6 @@ Items acknowledged and carried forward from previous milestone close:
|
||||
|
||||
## Session Continuity
|
||||
|
||||
Last session: 2026-10-20T00:18:01.483Z
|
||||
Stopped at: Phase 19.4.1 context gathered
|
||||
Resume file: .planning/phases/19.4.1-early-public-demo-on-demo-summercms-io/19.4.1-CONTEXT.md
|
||||
Last session: 2026-10-24T14:47:37.432Z
|
||||
Stopped at: Phase 32 context gathered
|
||||
Resume file: .planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
schema_version: 1
|
||||
open_count: 16
|
||||
open_count: 20
|
||||
waived_count: 0
|
||||
fixed_count: 7
|
||||
total_count: 23
|
||||
last_updated: 2026-10-18T13:42:55.096Z
|
||||
total_count: 27
|
||||
last_updated: 2026-10-22T14:44:56.679Z
|
||||
---
|
||||
|
||||
# Broken Windows Ledger
|
||||
@@ -38,6 +38,10 @@ last_updated: 2026-10-18T13:42:55.096Z
|
||||
| 21 | 16.2 | unrun-verify | .planning/phases/16.2-plugin-provided-field-types-and-the-blog-editor-formwidget/16.2-06-PLAN.md | | sm-journal-plugin: 16.2-06 TestCategoriesAdminBlogEditor (categories_admin_editor_test.go) and the rewritten three-stage TestPostsAdminResaveKeepsHTML compile under go vet but need a Docker host; run bash scripts/check-phase16.2.sh postgres | open | | 2026-10-10T14:17:06.621Z | |
|
||||
| 22 | 19.1 | deviation | sm-forum-plugin/go.mod | | go.mod lists bluemonday and goldmark as // indirect via breakwater; no direct require | open | | 2026-10-18T13:42:54.900Z | |
|
||||
| 23 | 19.1 | deviation | classes/lifecycle.go | | Task 4 methods besides DeleteContext live in classes/lifecycle.go | open | | 2026-10-18T13:42:55.096Z | |
|
||||
| 24 | 19.7 | deviation | modules/cabana | | 19.7-01: capabilities_test field-count assertion updated 2->3 for AdminRecordActionInput.Value | open | | 2026-10-22T14:44:56.001Z | |
|
||||
| 25 | 19.7 | deviation | modules/cabana | | 19.7-01: admin route inventories (phase09Routes, tokenRouteClasses, CSRF walk 35, phase10 want list, conformCases) extended for the two account contribution routes | open | | 2026-10-22T14:44:56.218Z | |
|
||||
| 26 | 19.7 | deviation | modules/cabana | | 19.7-01: TestRecordActionPromptRun added on Postgres to prove Run receives the trimmed prompt value | open | | 2026-10-22T14:44:56.449Z | |
|
||||
| 27 | 19.7 | unrun-verify | scripts/check-phase19.6.1.sh | | 19.7-01: check-phase19.6.1.sh --all stopped by the host (memory pressure) after the cabana and surf Postgres suites passed; re-run on the Docker host | open | | 2026-10-22T14:44:56.679Z | |
|
||||
|
||||
````json
|
||||
[
|
||||
@@ -339,6 +343,58 @@ last_updated: 2026-10-18T13:42:55.096Z
|
||||
"recorded_at": "2026-10-18T13:42:55.096Z",
|
||||
"resolved_at": null,
|
||||
"milestone": "v1.0"
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"kind": "deviation",
|
||||
"phase": "19.7",
|
||||
"file": "modules/cabana",
|
||||
"line": null,
|
||||
"description": "19.7-01: capabilities_test field-count assertion updated 2->3 for AdminRecordActionInput.Value",
|
||||
"status": "open",
|
||||
"reason": "",
|
||||
"recorded_at": "2026-10-22T14:44:56.001Z",
|
||||
"resolved_at": null,
|
||||
"milestone": "v1.0"
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"kind": "deviation",
|
||||
"phase": "19.7",
|
||||
"file": "modules/cabana",
|
||||
"line": null,
|
||||
"description": "19.7-01: admin route inventories (phase09Routes, tokenRouteClasses, CSRF walk 35, phase10 want list, conformCases) extended for the two account contribution routes",
|
||||
"status": "open",
|
||||
"reason": "",
|
||||
"recorded_at": "2026-10-22T14:44:56.218Z",
|
||||
"resolved_at": null,
|
||||
"milestone": "v1.0"
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"kind": "deviation",
|
||||
"phase": "19.7",
|
||||
"file": "modules/cabana",
|
||||
"line": null,
|
||||
"description": "19.7-01: TestRecordActionPromptRun added on Postgres to prove Run receives the trimmed prompt value",
|
||||
"status": "open",
|
||||
"reason": "",
|
||||
"recorded_at": "2026-10-22T14:44:56.449Z",
|
||||
"resolved_at": null,
|
||||
"milestone": "v1.0"
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"kind": "unrun-verify",
|
||||
"phase": "19.7",
|
||||
"file": "scripts/check-phase19.6.1.sh",
|
||||
"line": null,
|
||||
"description": "19.7-01: check-phase19.6.1.sh --all stopped by the host (memory pressure) after the cabana and surf Postgres suites passed; re-run on the Docker host",
|
||||
"status": "open",
|
||||
"reason": "",
|
||||
"recorded_at": "2026-10-22T14:44:56.679Z",
|
||||
"resolved_at": null,
|
||||
"milestone": "v1.0"
|
||||
}
|
||||
]
|
||||
````
|
||||
|
||||
81
.planning/debug/user-logout-session-stays-valid.md
Normal file
81
.planning/debug/user-logout-session-stays-valid.md
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
status: awaiting_human_verify
|
||||
trigger: "User plugin logout: auth cookies not invalidated at once; requests keep authenticating ~60 min until token expiry (todo 2026-10-22-user-logout-cookie-stays-valid)"
|
||||
created: 2026-10-22T00:00:00Z
|
||||
updated: 2026-10-22T00:00:00Z
|
||||
---
|
||||
|
||||
## Current Focus
|
||||
|
||||
bug_class: Bohrbug (deterministic)
|
||||
reasoning_checkpoint:
|
||||
hypothesis: "Logout reads only the bearer header (cookie sessions get 401, nothing revoked, cookie kept, jwt guard accepts the cookie until exp = 60 min), never writes a forget cookie, and blacklists the jti only until the access exp (so /refresh revives a logged-out token after exp + sweep)"
|
||||
confirming_evidence:
|
||||
- "probe: cookie-only logout 401, then GET /tokens with the cookie 200"
|
||||
- "probe: jwt_blacklist.expires_at == exp; after the sweep, /refresh of the logged-out token 200"
|
||||
- "bearer logout already refuses the bearer at once (guard checks blacklist) - so server-side check exists; the gap is what logout revokes and for how long"
|
||||
falsification_test: "if cookie-only logout after the fix still leaves GET /tokens 200, or /refresh after the sweep still 200, hypothesis/fix wrong"
|
||||
fix_rationale: "read the token exactly as the jwt guard does, revoke it (and any other session token the request carries) until the refresh window closes, accept an expired-but-refreshable token like cabana does, and expire the session cookies with auth.cookie attributes"
|
||||
blind_spots: "demo frontend never calls /logout (app-side, not fixable here); auth_token cookie is frontend-owned, its real attributes unknown (forget uses auth.cookie path/domain)"
|
||||
candidate_causes:
|
||||
- "code: Logout bearer-only extraction + exp-only blacklist expiry"
|
||||
- "config: blacklist store not published (no DB) -> no revocation; ruled out, Boot publishes PostgresBlacklist when *sql.DB/*gorm.DB exist and bearer logout works"
|
||||
- "environment/frontend: demo frontend logout only clears its own cookie and never calls /logout"
|
||||
and_gate: "no for the cookie case (extraction alone suffices); the refresh revival is an independent second defect"
|
||||
next_action: human verification in a real app (cookie-only logout, then a jwt.auth request with the old cookie must be 401); after confirmation archive to resolved/ and add the KB entry
|
||||
|
||||
## Symptoms
|
||||
|
||||
expected: after POST /_user/api/v1/logout the old token/cookie is refused (401) on the next request, and the cookies are cleared
|
||||
actual: requests keep authenticating for about 60 minutes, until the token expires
|
||||
errors: none
|
||||
reproduction: login, logout, repeat an authenticated request with the old cookie or token
|
||||
started: reported 2026-10-22
|
||||
|
||||
## Eliminated
|
||||
|
||||
## Evidence
|
||||
|
||||
- timestamp: 2026-10-22
|
||||
checked: bouncer jwtGuard.Authenticate (summercms.go modules/bouncer/jwt.go)
|
||||
found: access JWTs are checked for HS256 signature, exp, audience, the subject user (GormUsers.FindByID), the jti blacklist (BlacklistStore) and users.tokens_valid_after; token taken from bearer first, then cookies "token", "auth_token" (plugin.go Boot)
|
||||
implication: server-side revocation exists (jwt_blacklist); a blacklisted jti is refused on the next request
|
||||
- timestamp: 2026-10-22
|
||||
checked: controllers.Logout (api_controller.go)
|
||||
found: reads bearerToken(r) only (Authorization header); no cookie fallback; never writes a Set-Cookie; blacklists with Add(jti, exp, now) i.e. storage expiry = access exp
|
||||
implication: cookie-only logout => 401, nothing revoked, cookie kept; blacklist row is dropped after exp although the refresh window (20160 min) is still open
|
||||
- timestamp: 2026-10-22
|
||||
checked: sociallogin writeSession (token_cookie: true) and bouncer.CookieConfig.TokenCookie
|
||||
found: sets httpOnly `token` cookie (auth.cookie.* name/path/domain/samesite, Max-Age = refresh_ttl) and leaves token out of the body, so the browser cannot send a bearer header
|
||||
implication: such a frontend can only log out with the cookie => H1 path
|
||||
- timestamp: 2026-10-22
|
||||
checked: bouncer.refreshAudience comment and blacklist storage expiry
|
||||
found: Refresh stores the old jti until max(exp, iat+refreshTTL)+1min precisely so "a logged-out token cannot be refreshed again"; Logout does not
|
||||
implication: H2 plausible
|
||||
- timestamp: 2026-10-22
|
||||
checked: PHP ApiController::logout + AuthManager::logout(true)
|
||||
found: token from Bearer or jwt_token param; JWTAuth::invalidate(forceForever=true) => blacklisted forever; body {"message":"Logged out"}
|
||||
implication: Go logout should keep the jti blocked at least for the refresh window
|
||||
|
||||
- timestamp: 2026-10-22
|
||||
checked: cabana admin logout (summercms.go modules/cabana/auth.go logout)
|
||||
found: framework reference: always expires the cookie, reads bearer then cookie, VerifyRefreshableClaimsAudience, blacklists until max(exp, iat+refreshTTL)+1min
|
||||
implication: the plugin's logout lags the framework's own pattern
|
||||
- timestamp: 2026-10-22
|
||||
checked: Docker probe through the assembled router (newAdminEnv), pre-fix
|
||||
found: (A) cookie-only POST /logout -> 401 {"error":true,"message":"Unauthorized"}, no Set-Cookie; GET /tokens (jwt.auth) with the same cookie afterwards -> 200; token exp-iat = 1h0m0s. (B) bearer logout -> 200 and the bearer is refused at once (401), but jwt_blacklist.expires_at == token exp; the sweep after exp deletes the row and POST /refresh with the logged-out token -> 200 with a fresh token
|
||||
implication: H1 and H2 CONFIRMED. New test logout_test.go fails 7/8 subtests pre-fix (bearer passes)
|
||||
|
||||
## Resolution
|
||||
|
||||
root_cause: "controllers.Logout read the token only from the Authorization bearer header, although the jwt guard (and RequestUser) also accept the token/auth_token cookies: a cookie-carried session (e.g. the httpOnly token cookie sociallogin token_cookie sets) got 401 at /logout, nothing was blacklisted and no cookie was cleared, so the cookie kept authenticating jwt.auth routes until exp (golem15.user.jwt.ttl, 60 min). Logout also never wrote a forget cookie; and it (and EndRequestSession) kept the jwt_blacklist row only until the access exp, so after the sweep /refresh revived a logged-out token for the rest of the 20160-min refresh window."
|
||||
fix: "classes.EndSession (new export): revokes every session JWT the request carries (bearer, token, auth_token) that verifies - unexpired, or user-audience within its refresh window - until max(exp, iat+refresh_ttl)+1m; always writes the auth.cookie forget cookie plus forgets for other carried session cookies with the same attributes; returns the guard-order subject. Logout uses it (responses unchanged: 200 Logged out / 401 Unauthorized / 500); EndRequestSession is now its best-effort wrapper."
|
||||
verification:
|
||||
target_test: { result: pass, test: "logout_test.go TestLogoutEndsTheSession (10 subtests); TestEndRequestSession updated" }
|
||||
mutation_check: { result: pass, reason_if_skipped: "no Stryker for Go - manual mutants", mutant_killed: "7/7 (expiry-at-exp, bearer-only, no-forget, no-refreshable-verify, primary-only revoke, config-cookie-only forget, no legacy fallback)" }
|
||||
no_op_deletion: { result: pass, deletion_justified_by_rca: true }
|
||||
adjacent_tests: { result: pass, suites_run: ["sm-user-plugin go test ./... (Docker, all ok)", "sm-demo-app workspace: oauthserver + sociallogin go test (only TestClientRegistry/verify_secret and TestPHPMethodMap fail: they read ../summercms.go and ../fonoteka.go paths that exist only in the plugins' own repo layout; unrelated to the change)"] }
|
||||
revert_and_reconfirm: { result: pass, bug_returned_on_revert: true, fixed_on_reapply: true }
|
||||
guardrail_verdict: accepted
|
||||
commit: 358ee5d (sm-user-plugin, unpushed)
|
||||
files_changed: [classes/session_user.go, controllers/api_controller.go, session_user_test.go, logout_test.go, README.md]
|
||||
46
.planning/notes/2026-10-21-mfa-otp-webauthn.md
Normal file
46
.planning/notes/2026-10-21-mfa-otp-webauthn.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Decision: second factors use pquerna/otp, go-webauthn and boombuler/barcode, in sm-mfa-plugin only
|
||||
|
||||
**Date:** 2026-10-21
|
||||
**Status:** Accepted
|
||||
**Context:** Phase 19.6 (two-factor auth and device flow, D-01, D-04, D-06, D-08, D-14), 19.6-RESEARCH.md Q1, Q2, Q3 and Package Legitimacy Audit
|
||||
|
||||
## Decision
|
||||
|
||||
The second factors (TOTP, WebAuthn, email codes, recovery codes, trusted devices) live in the new shared plugin `sm-mfa-plugin`, which requires `sm-user-plugin` (D-01). Three third-party modules carry the protocol work; everything else is the standard library and the framework.
|
||||
|
||||
- **`github.com/pquerna/otp` pinned at v1.5.0.** Published 2024-12-31, Apache-2.0. Packages `totp` and `hotp` only. Issuer is the application name, the account is the user's email, the validation window is plus or minus one step, SHA1, 6 digits, 30 s period (the Google Authenticator defaults PHP used). Replay protection is done per counter with `hotp` (RESEARCH Pitfall 5).
|
||||
- **`github.com/go-webauthn/webauthn` pinned at v0.18.2.** Published 2026-09-19, BSD-3-Clause. Packages `webauthn` and `protocol` only. Attestation `none`, timeout 60 s, user verification `preferred` for second-factor use and `required` for passkeys (D-14). Ceremony state stays server-side.
|
||||
- **`github.com/boombuler/barcode` pinned at v1.1.0 (package `qr` only) for the TOTP QR code.** MIT. It is already a requirement of pquerna/otp (for `Key.Image()`), so it adds no module and no maintainer. sm-mfa-plugin writes the SVG itself (a small serializer emitting one `<path>` for the dark modules, `width="200" height="200"` with a `viewBox`, as PHP's Bacon `RendererStyle(200)` did), so PHP's TOTP setup contract `{secret, qr_code_svg, qr_code_url}` stays. The round trip was proven during research: a TOTP URL encoded at level M was read back byte for byte by an independent decoder (RESEARCH Q2, Assumption A1).
|
||||
- **Slow hash for recovery and email codes: bcrypt** through `bouncer.HashPassword` / `bouncer.CheckPassword` at `golem15.user.password.bcrypt_cost`, exactly as the user plugin hashes passwords (D-06). No argon2: it would add `golang.org/x/crypto/argon2` usage the framework does not have. Ten compares at cost 10 measured 631 ms (RESEARCH Q3).
|
||||
|
||||
## Measurements (RESEARCH Q1)
|
||||
|
||||
- **Binary size: +2,269,184 bytes (+2.16 MiB)** on a stripped build of the demo application (`-trimpath -ldflags="-s -w"`): 51,802,375 to 54,071,559 bytes, with TOTP generate and validate, QR encode, and the WebAuthn registration, login and passkey-login paths driven by a probe.
|
||||
- **Nine newly linked modules** (`go version -m` diff): `github.com/boombuler/barcode` v1.1.0, `github.com/fxamacker/cbor/v2` v2.9.4, `github.com/go-webauthn/webauthn` v0.18.2, `github.com/go-webauthn/x` v0.3.1, `github.com/google/go-tpm` v0.9.8, `github.com/philhofer/fwd` v1.2.0, `github.com/pquerna/otp` v1.5.0, `github.com/tinylib/msgp` v1.6.4, `github.com/x448/float16` v0.8.4.
|
||||
- **One version bump in consuming graphs:** minimal version selection moves `github.com/go-viper/mapstructure/v2` from v2.4.0 to v2.5.0 in the module graph of applications that mount the plugin. `golang-jwt/jwt/v5` v5.3.1, `google/uuid` v1.6.0 and `golang.org/x/crypto` v0.57.0 are already at go-webauthn's versions.
|
||||
- **Vulnerabilities:** `govulncheck` v1.9.0 reports no reachable vulnerability. The only module-level advisory, GO-2026-5932 (`golang.org/x/crypto/openpgp`, unmaintained), sits in a package nothing imports.
|
||||
- go-webauthn's go.mod lists the archived YAML v3 module as an indirect, test-only requirement outside the import graph. Plugin code never imports it (CLAUDE.md: `goccy/go-yaml` only).
|
||||
|
||||
## Deviation from PHP recorded here (D-08)
|
||||
|
||||
WebAuthn requests and responses use go-webauthn's standard base64url shapes (`PublicKeyCredentialCreationOptions`, `PublicKeyCredentialRequestOptions` and the attestation and assertion JSON that `navigator.credentials` and `@simplewebauthn/browser` produce), not PHP's lbuchs plain-base64 layout. The paths and outer keys stay PHP's. This is acceptable because no client implements the PHP layout yet. PHP stored PEM public keys while go-webauthn verifies COSE keys, so the Phase 30 Winter import must convert or drop WebAuthn rows.
|
||||
|
||||
## Rejected alternatives
|
||||
|
||||
- **`github.com/piglig/go-qr` v1.1.0** (native `ToSVGBytes`). 67 stars, one maintainer, and a new module for what boombuler already provides through pquerna/otp's graph.
|
||||
- **argon2id for codes.** Not what the user plugin uses for passwords; D-06 asks to match it.
|
||||
- **A hand-written TOTP or WebAuthn implementation.** Protocol and security code goes to a maintained library with a decision note (project preference).
|
||||
|
||||
## Related dependencies
|
||||
|
||||
- `golang.org/x/crypto`, `github.com/golang-jwt/jwt/v5` and `github.com/google/uuid` are already in the framework and application graphs at the versions go-webauthn needs.
|
||||
|
||||
## Package legitimacy
|
||||
|
||||
The package-legitimacy seam cannot check Go modules (as in 19.4 and 19.5), so all three are [ASSUMED] for legitimacy and gated by a blocking human check (plan 19.6-01 Task 5) before any `go get`. Signals gathered by hand: pquerna/otp v1.5.0 on proxy.golang.org (2,963 stars, Apache-2.0); go-webauthn/webauthn v0.18.2 (1,351 stars, BSD-3-Clause, pushed 2026-10-20); boombuler/barcode v1.1.0 (published 2025-07-22, 1,563 stars, MIT).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Only `sm-mfa-plugin`'s go.mod requires the three modules. `sm-user-plugin`, the framework and fonoteka.go require none, and applications without the plugin link none of the nine modules (D-01).
|
||||
- go-webauthn is pre-1.0 and the research is valid until 2026-11-20. After that date the executor re-checks the pin with `go list -m -json github.com/go-webauthn/webauthn@latest` before installing.
|
||||
- Installation, only after the human check: `go get github.com/pquerna/otp@v1.5.0 github.com/go-webauthn/webauthn@v0.18.2 github.com/boombuler/barcode@v1.1.0` inside `sm-mfa-plugin`, then `go mod tidy`.
|
||||
107
.planning/notes/2026-10-22-external-user-plugin-escalations.md
Normal file
107
.planning/notes/2026-10-22-external-user-plugin-escalations.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
title: External user-plugin escalations
|
||||
date: 2026-10-22
|
||||
context: /msd-explore of an external app's "escalate to summercms devs" list. Six /msd-quick tasks; send this reply when they are all done.
|
||||
g15office: bhoyg8z4
|
||||
---
|
||||
|
||||
# External user-plugin escalations
|
||||
|
||||
Reviewed 2026-10-22. The list is `golem15.user` (sm-user-plugin), not cabana admin auth. Phase 19.6 (2FA) is not mid-flight.
|
||||
|
||||
**Released (2026-10-23):** sm-user-plugin **v0.1.9** carries all six quicks and still requires SummerCMS v0.4.3, so the external app needs no framework upgrade for these fixes. The earlier hold for a v0.5.0 wave is withdrawn: v0.5.0 is reserved for the finished MCP phase (19.7), and the framework's own next patch is v0.4.4, which is not needed for anything below. The reply is ready to send.
|
||||
|
||||
**Do not run the six quicks in parallel on one working tree.** They share `sm-user-plugin` (`api_controller.go`, `plugin.go`, `routes.go`, README). Sequential fresh sessions.
|
||||
|
||||
## Tracker
|
||||
|
||||
| # | Their label | Verdict | Quick / todo | g15office | Status | Shipped |
|
||||
|---|---|---|---|---|---|---|
|
||||
| 1 | G2 login ignores `is_activated` | Fix | [261022-tb4](../quick/261022-tb4-password-login-must-refuse-is-activated-/) · [todo](../todos/done/2026-10-22-user-login-ignores-is-activated.md) | 3r4or1ex | released | `15ff979` → user v0.1.9 |
|
||||
| 2 | G3 cookie-only 401 | Fix remaining four; logout already done | [261022-tto](../quick/261022-tto-fetch-refresh-update-change-password-mus/) · [todo](../todos/done/2026-10-22-user-session-routes-ignore-cookie.md) | kkknstxl | released | `8e4b863` → user v0.1.9 |
|
||||
| 3 | G4 logout blacklist under `serve` | Fix | [261022-usi](../quick/261022-usi-user-plugin-jwt-blacklist-and-hooks-wire/) · [todo](../todos/done/2026-10-22-user-logout-blacklist-missing-under-serve.md) | ud0gficu | released | `4bf44fc` → user v0.1.9 |
|
||||
| 4 | G6 `/update` email without proof | Decline | — | — | declined | n/a |
|
||||
| 5 | G7 Users form has no role field | Decline | — | — | declined | n/a |
|
||||
| 6 | G8 API token guard ignores `tokens_valid_after` | Decline | — | — | declined | n/a |
|
||||
| 7 | Cookie option on `/login` | Feature | [261022-wah](../quick/261022-wah-opt-in-httponly-session-cookie-on-user-p/) · [todo](../todos/done/2026-10-22-user-login-opt-in-session-cookie.md) | strnsccy | released | `846087d`, `8bdf2c7` → user v0.1.9 |
|
||||
| 8 | Password-routes 404 switch | Feature | [261022-x7a](../quick/261022-x7a-user-plugin-golem15-user-password-public/) · [todo](../todos/done/2026-10-22-user-password-routes-404-switch.md) | h7yrafgd | released | `3828a65` → user v0.1.9 |
|
||||
| 9 | Lockout keyed on `RemoteAddr` | Fix | [261022-vfz](../quick/261022-vfz-user-plugin-login-throttle-via-surf-clie/) · [todo](../todos/done/2026-10-22-user-login-lockout-and-same-second-cutoff.md) | sniewiif | released | `b6f8055` → user v0.1.9 |
|
||||
| 10 | Same-second token refusal | Fix | [261022-vfz](../quick/261022-vfz-user-plugin-login-throttle-via-surf-clie/) · [todo](../todos/done/2026-10-22-user-login-lockout-and-same-second-cutoff.md) | sniewiif | released | `a484d0e` → user v0.1.9 |
|
||||
|
||||
Status values: `open` · `done` · `declined`. Shipped: plugin commit → sm-user-plugin tag.
|
||||
|
||||
## Six invocations (fresh session each, sequential)
|
||||
|
||||
```
|
||||
/msd-quick --validate Password /login must refuse is_activated=false when golem15.user.activation.require_activation is true (default), same opaque invalid-login body as a bad password. Do not change deleted_at restore-on-login. See .planning/todos/pending/2026-10-22-user-login-ignores-is-activated.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
|
||||
/msd-quick --validate /fetch /refresh /update /change-password must accept the token/auth_token cookies the same way jwt.auth and EndSession already do. Logout is already fixed. See .planning/todos/pending/2026-10-22-user-session-routes-ignore-cookie.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
|
||||
/msd-quick --discuss --validate Under serve, user-plugin Boot runs before lagoon.Publish so the jwt blacklist is never wired and logout does not revoke. Wire BlacklistStore and RegisterHooks through lagoon.OnDatabase; test Activate-then-Publish. When re-registering the jwt guard, pass classes.SessionCookieNames() instead of the hardcoded token/auth_token names (G3 leftover). See .planning/todos/pending/2026-10-22-user-logout-blacklist-missing-under-serve.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
|
||||
/msd-quick --validate User-plugin /login throttle must use surf.ClientIP (trusted proxies), not RemoteAddr. Leave exported RemoteIP as the RemoteAddr helper. Remaining tokens_valid_after writers (reset-password, admin password set) must Truncate(time.Second) like RevokeUserAccess; leave change-password and bouncer's comparison alone. See .planning/todos/pending/2026-10-22-user-login-lockout-and-same-second-cutoff.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
|
||||
/msd-quick --discuss --validate Opt-in HttpOnly session cookie on user-plugin POST /login: golem15.user.jwt.token_cookie (default off), attributes from auth.cookie via bouncer.LoadCookieConfig, omit body token when the cookie is set (sociallogin writeSession). Cookie-carried POST /refresh must rotate that cookie (G3 left body-only); bearer-only refresh stays body-only. SameSite=Lax, no CSRF. Base a484d0e. See .planning/todos/pending/2026-10-22-user-login-opt-in-session-cookie.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
|
||||
/msd-quick --validate User-plugin golem15.user.password.public_routes (default true). When false, do not register POST /login /forgot-password /reset-password so they 404 like unknown paths. Leave /register and the rest. No framework wrap, no custom 404. Base 8bdf2c7. See .planning/todos/pending/2026-10-22-user-password-routes-404-switch.md and .planning/notes/2026-10-22-external-user-plugin-escalations.md
|
||||
```
|
||||
|
||||
Suggested order if you care about risk: G4 (serve blacklist), then G3, G2, 9+10, then the two features. All six are done locally; item 8 (password-routes 404) was the last. Do not overlap on the same plugin files. Released in sm-user-plugin v0.1.9.
|
||||
|
||||
## Verdicts (kept for the sessions)
|
||||
|
||||
- **G2.** `require_activation` is documented and `/register` honors it; `/login` does not. Deactivation (`deleted_at`) stays reversible.
|
||||
- **G3.** Done locally (`8e4b863`). Cookie extractors are `classes.SessionToken` / `SessionCookieNames`. Item 7 (`846087d`) made a `/refresh` carried by the `auth.cookie` cookie rewrite it; bearer- and `auth_token`-carried refreshes stay body-only. CSRF was not added (SameSite=Lax + current-password on change-password).
|
||||
- **G4.** Done locally (`4bf44fc`). Lazy `appBlacklist` + `lagoon.OnDatabase` for hooks, Postgres store and sweep. Guard uses `SessionCookieNames()`.
|
||||
- **G6.** D-27: email change clears `email_verified_at` and does not write a new proof. A confirm-the-new-inbox flow would be a later feature.
|
||||
- **G7.** Stock form omission was a 12.1 decision. Stale `organisation_role` is already cleared (`ClearOnChange`, v0.1.8). Apps extend the form.
|
||||
- **G8.** Personal tokens die via `revoked_at`. `RevokeUserAccess` already sets that on deactivate/ban. Do not teach the API-token guard a JWT cutoff. Password reset killing API tokens would be a separate, explicit revoke.
|
||||
- **7.** Done locally (`846087d`, `8bdf2c7`). `846087d`: a `/refresh` carried by the `auth.cookie` cookie (`token` by default, no bearer) rewrites it and answers `{}`, whatever `token_cookie` says; bearer and other-cookie refreshes stay body-only; refusals write no cookie. `8bdf2c7`: `golem15.user.jwt.token_cookie` (default off) makes /login, /register (auto sign-in) and /activate-by-code set the HttpOnly `auth.cookie` cookie via `bouncer.LoadCookieConfig` and omit body `token`; off keeps today's bodies. SameSite=Lax, no CSRF; API tokens untouched.
|
||||
- **8.** Done locally (`3828a65`). Plugin config; no framework wrap. `golem15.user.password.public_routes` (default true); false leaves `POST /login`, `/forgot-password` and `/reset-password` unregistered, so they get the router's own 404 like any unknown path (a `GET` too, no 405); no custom handler, no `pact`/`surf` change. `/register` stays (`allow_registration` gates it, `golem15.user.turnstile` still guards it), and so do `/activate*`, `/fetch`, `/refresh`, `/logout`, `/change-password` and `/tokens`. Read when the routes are built (a restart applies it); a value other than true or false fails boot.
|
||||
- **9.** Done locally (`b6f8055`). /login keys the throttle on surf.ClientIP with http.trusted_proxies (the /register expression); RemoteIP stays the RemoteAddr helper; without trusted proxies X-Forwarded-For is ignored.
|
||||
- **10.** Done locally (`a484d0e`). /reset-password and the admin password set truncate the cutoff to whole seconds like RevokeUserAccess; change-password and bouncer unchanged.
|
||||
|
||||
## Reply to send
|
||||
|
||||
Ready to send as-is (all items filled, released in sm-user-plugin v0.1.9).
|
||||
|
||||
```
|
||||
Thanks for the escalation list. We reviewed the current golem15.user plugin (and the framework boot order). Here is what we shipped, what is already true, and what we are not changing. The fixes and the two new options are in sm-user-plugin v0.1.9, which still requires SummerCMS v0.4.3: bump the plugin, no framework upgrade is needed.
|
||||
|
||||
G2 — login ignores is_activated
|
||||
Agreed. require_activation defaults to true and /register already withholds a token in admin mode; /login did not check is_activated. That is not the same as deactivation (deleted_at), which stays self-service: a later password login still restores the account.
|
||||
Ships in sm-user-plugin v0.1.9 (15ff979): with require_activation on (the default), /login answers an account that is not activated with the same opaque invalid-login response as a bad password (counted as a failed attempt); deactivation stays self-service. /activate still serves a not-activated session so the mailed-code flow works.
|
||||
|
||||
G3 — some routes ignore the cookie
|
||||
Partly already fixed, rest agreed. POST /logout already accepts the token/auth_token cookies (and blacklists every JWT the request carries). GET /fetch, POST /refresh, POST /update and POST /change-password still required the Authorization header.
|
||||
Ships in sm-user-plugin v0.1.9 (8e4b863): GET /fetch, POST /refresh, POST /update and POST /change-password (and the other signed-in routes: /activate, /marketing-consent, /avatar, /avatar/remove) read the session token like jwt.auth: the Authorization header first, then the token and auth_token cookies. A /refresh carried by the session cookie named in auth.cookie (token by default) rewrites that cookie with the rotated token and answers {} (see "Cookie on /login" below). A /refresh carried by the Authorization header, or by the auth_token cookie, returns the rotated token in the body and writes no cookie; the previous token is revoked, so store the new one yourself.
|
||||
|
||||
G4 — logout does not blacklist under serve
|
||||
Agreed. Plugin Boot runs before serve publishes the database, so the in-process blacklist store was never wired in production (the jwt_blacklist table exists; nothing wrote to it). Tests hid this because they publish the DB before Boot.
|
||||
Ships in sm-user-plugin v0.1.9 (4bf44fc): the plugin installs its jwt_blacklist store, the blacklist sweep and its GORM hooks when serve publishes the database, and the jwt guard reads that store on every request. Logout under serve now writes the jti to jwt_blacklist, and the next request with that token (jwt.auth routes, /fetch, /refresh) answers 401. A regression test boots in serve order (plugins first, database second). The jwt guard also takes its cookie names from the same list as the session routes (token, auth_token).
|
||||
|
||||
G6 — /update changes email without proof
|
||||
As designed, not a bug. A new address clears email_verified_at and stays unproven until the owner completes an activation code or a reset-password. We are not adding a “confirm the new inbox before the change sticks” flow in this round. Say if you need that as a later feature.
|
||||
|
||||
G7 — stock Users form has no role field
|
||||
As designed. organisation_role is intentionally off the stock form (an app extends the form). v0.1.8 already clears organisation_role when the organisation changes (members manager and the Users form). No further stock-form change.
|
||||
|
||||
G8 — API token guard ignores tokens_valid_after
|
||||
As designed. Personal API tokens are revoked through revoked_at, not the JWT cutoff. Deactivate and ban already revoke those rows (RevokeUserAccess). A password reset is not supposed to kill API tokens; if you want that, say so and we will revoke the rows, not mix the two mechanisms.
|
||||
|
||||
Cookie on /login
|
||||
Agreed as an opt-in. Sociallogin already has token_cookie for OAuth complete; password /login now has the same kind of flag (default off, so body-token clients stay unchanged).
|
||||
Ships in sm-user-plugin v0.1.9 (846087d and 8bdf2c7): set golem15.user.jwt.token_cookie: true (default false) and POST /login, POST /register (when it signs the new account in) and POST /activate-by-code set the HttpOnly session cookie with the auth.cookie attributes (bouncer.LoadCookieConfig: name token, path /, SameSite=Lax, Secure from app.url, Max-Age the refresh window) and leave token out of the body; user (and message) stay. A POST /refresh carried by that cookie rewrites it with the rotated token and answers {}; a bearer refresh is unchanged. With the key off, /login, /register and /activate-by-code return the body token as before; the /refresh cookie rewrite applies either way, because it follows the cookie the refresh arrived with, not this key. That is a change for a client that refreshes with only the token cookie and no Authorization header: it now gets {} and a rewritten cookie instead of the token in the body. SameSite stays Lax and there is no CSRF token. Keep auth.cookie.name at token or auth_token, the cookies the session routes read.
|
||||
|
||||
Password-routes switch
|
||||
Agreed, in the user plugin, not as a framework “wrap another plugin’s routes” seam. A config key stops registering /login, /forgot-password and /reset-password so they 404.
|
||||
Ships in sm-user-plugin v0.1.9 (3828a65): set golem15.user.password.public_routes: false (default true; SUMMER_GOLEM15__USER__PASSWORD__PUBLIC_ROUTES=false in the environment) and POST /login, POST /forgot-password and POST /reset-password are not registered, so they answer the same 404 as any unknown path, whatever the method. POST /register stays (allow_registration still decides whether it takes accounts, and golem15.user.turnstile still guards it), as do /activate, /activate-by-code, /fetch, /refresh, /logout, /update, /change-password and /tokens. With the key true or unset nothing changes. The key is read when the routes are built, so a change needs a restart; a value other than true or false stops boot with an error naming the key.
|
||||
|
||||
Login lockout keyed on RemoteAddr
|
||||
Agreed. /login used RemoteAddr; /register already uses the trusted-proxy client address. Behind a reverse proxy five failures locked everyone.
|
||||
Ships in sm-user-plugin v0.1.9 (b6f8055): /login counts failed logins per account and client address, and the client address is now the one /register and the user-api rate limit use: behind a proxy listed in http.trusted_proxies, the X-Forwarded-For client; otherwise the connection address. An X-Forwarded-For header from an address not in http.trusted_proxies is ignored, so it cannot dodge or move a lockout. List your nginx/Caddy address in http.trusted_proxies; without it every visitor still counts as the proxy.
|
||||
|
||||
Same-second token refusal
|
||||
Agreed. JWT iat is whole seconds; some tokens_valid_after writers stamped sub-second time. RevokeUserAccess already truncates. Reset-password and the admin password set now do too.
|
||||
Ships in sm-user-plugin v0.1.9 (a484d0e): POST /reset-password and an administrator's password set on the Users form stamp tokens_valid_after with the current whole second, as deactivate and ban already do, so a token minted in the same second as the reset (the login right after it) is accepted and every token from an earlier second is still refused. As with deactivate and ban, a token issued earlier within that same second also stays valid, because iat has no finer resolution. /change-password and the guard's comparison are unchanged.
|
||||
```
|
||||
50
.planning/notes/2026-10-22-mcp-go-sdk.md
Normal file
50
.planning/notes/2026-10-22-mcp-go-sdk.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Decision: the MCP endpoint uses the official Go SDK behind a build tag
|
||||
|
||||
**Date:** 2026-10-22
|
||||
**Status:** Accepted
|
||||
**Context:** Phase 19.7 (generic MCP module, D-24, D-25, D-32, D-33), 19.7-RESEARCH.md § "Standard Stack", § "Package Legitimacy Audit", § "Architecture Patterns" (Pattern 8), plan 19.7-02 Task 1 (human legitimacy check, approved 2026-10-22)
|
||||
|
||||
## Decision
|
||||
|
||||
The framework module `pier` serves the MCP streamable HTTP endpoint on the official Go SDK and reflects tool schemas with the schema library the SDK itself uses.
|
||||
|
||||
- **`github.com/modelcontextprotocol/go-sdk` pinned at v1.8.0.** Published 2026-09-04, the newest tag (`@latest` resolves to v1.8.0 on proxy.golang.org, 2026-10-22). Origin `https://github.com/modelcontextprotocol/go-sdk`, commit `3f3b699b2b67e1ed033a63d6651671dab53c2d32`, sum `h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4=`. Licence: MIT transitioning to Apache-2.0 (new code Apache-2.0, older contributions MIT until relicensed; documentation CC-BY-4.0). `go 1.25.0` in its go.mod, so no toolchain change. Packages imported: `mcp` (server, sessions, streamable transport, test client), `auth` (bearer middleware, protected resource metadata handler), `oauthex` (the RFC 9728 metadata type), `jsonrpc` (error codes).
|
||||
- **`github.com/google/jsonschema-go` pinned at v0.4.3.** Published 2026-04-17, the newest tag. Origin `https://github.com/google/jsonschema-go`, commit `8c4ab4f02ef64dcea5502e47a6113e8292944087`, sum `h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=`. Licence MIT. Package imported: `jsonschema` (`ForType` reflection of a tool's input struct, `Resolve` and `Validate` of every call's arguments).
|
||||
- **Only `modules/pier` imports either module**, plus the tagged `modules/surf/pier_on.go` that imports `pier`. `pact` stays free of both (its `TestPactStaysSDKFree` runs `go list -deps`), so a plugin declaring tools compiles with and without the module.
|
||||
- **Linked only with the `summercms_mcp` build tag (D-33).** `summer.yaml` `build.tags: [summercms_mcp]` passes it to `go build`, as `summercms_s3` does for the S3 driver. Without the tag `surf.mountPier` stays nil, `go version -m` of the binary lists no `modelcontextprotocol` module, and `mcp.enabled: true` fails boot naming the tag. With the tag the `mcp.enabled` flag still defaults to off (D-30).
|
||||
- **The SDK keeps stateful sessions only in process memory**, in `StreamableHTTPHandler.sessions`, with no pluggable store and a 404 for an unknown `Mcp-Session-Id`. D-25 (sessions shared across instances through Redis) is therefore built as pier's own session router over the exported `StreamableServerTransport{SessionID}` and `Server.Connect(ctx, t, &ServerSessionOptions{State})`: the JSON-serialisable `ServerSessionState` is stored in Redis and a session is rehydrated on whichever instance receives the next request. The SDK still owns JSON-RPC framing, SSE, protocol negotiation and `list_changed` debouncing; pier bypasses only the private session map. The 2026-07-28 protocol, which the SDK serves only through `StreamableHTTPOptions.Stateless`, gets the SDK's stateless handler next to the stateful router (D-32).
|
||||
|
||||
## Measurements
|
||||
|
||||
- **New modules in the graph** (measured with `go list -m all` on a scratch module importing `mcp`, `auth`, `oauthex` and `jsonschema`): `github.com/modelcontextprotocol/go-sdk v1.8.0`, `github.com/google/jsonschema-go v0.4.3`, `github.com/segmentio/asm v1.1.3`, `github.com/segmentio/encoding v0.5.4`, `github.com/yosida95/uritemplate/v3 v3.0.2`, `golang.org/x/oauth2 v0.35.0`, `golang.org/x/time v0.15.0`. `golang.org/x/sync` and `golang.org/x/sys` stay at the framework's newer v0.23.0 and v0.48.0 under minimal version selection. `github.com/golang-jwt/jwt/v5`, `golang.org/x/tools`, `github.com/google/go-cmp` and `cloud.google.com/go/compute/metadata` appear in the SDK's go.mod but are not linked by these packages; the framework already requires jwt/v5 and go-cmp at its own versions.
|
||||
- **Binary size: +2.9 MiB stripped** on a program importing `mcp`, `auth` and `jsonschema` next to a bare `net/http` program (8,835,335 vs 5,832,967 bytes, 19.7-RESEARCH.md). The scratch probe above with `oauthex` added builds to 7,782,663 bytes stripped. An application that already links `x/sys`, `x/oauth2` and `x/time` grows by less. The tag keeps every untagged binary at its current size.
|
||||
- **Vulnerabilities:** `govulncheck` v1.9.0 (`go run golang.org/x/vuln/cmd/govulncheck@latest ./...` over the scratch module, 2026-10-22): "No vulnerabilities found" in the code and in the imported packages. One module-level finding, GO-2026-5024 (`golang.org/x/sys/windows` `NewNTUnicodeString`, Windows only, fixed in x/sys v0.44.0), concerns the SDK's own minimum x/sys v0.41.0; the framework requires x/sys v0.48.0, above the fix, and no imported package calls the symbol. After the import lands, the same command runs as `go run golang.org/x/vuln/cmd/govulncheck@latest ./modules/pier/...` from the framework root.
|
||||
|
||||
## Maintenance risk
|
||||
|
||||
The SDK is maintained by the Model Context Protocol organisation together with the Go team, releases monthly, and tracks the specification closely (v1.8.0 supports 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05). The risk is churn, not abandonment: the `allowsessionsinstateless` compatibility knob is announced to go in v1.9.0, and the stateful `initialize` handshake is deprecated by the 2026-07-28 specification. pier contains both: plugins compile against `pact` only, the SDK types never appear in a plugin-facing signature, and the session router is about 300 lines over four exported SDK calls (`NewServer`, `Connect`, `StreamableServerTransport.ServeHTTP`, `NewStreamableHTTPHandler`). Re-check `@latest` before bumping; research's validity note dates the SDK audit at 2026-10-21.
|
||||
|
||||
## Rejected alternatives
|
||||
|
||||
- **`github.com/mark3labs/mcp-go`.** Not considered: D-24 locks the official SDK, which is the only one that follows the specification's monthly moves and ships the test client pier's smoke tests use.
|
||||
- **The SDK's `StreamableHTTPHandler` as the whole server.** Its session map is in-memory and unexported; two instances behind one load balancer would answer 404 for each other's sessions. The own router keeps D-25 and reuses every other SDK layer.
|
||||
- **A hand-written streamable HTTP transport.** JSON-RPC batching rules per protocol version, SSE priming events, `Last-Event-ID` resumption, header validation and version negotiation are specification edge cases the SDK already handles and tests.
|
||||
- **Always linking pier.** +2.9 MiB on every application for a feature most do not enable; the tag pattern already exists (`summercms_s3`).
|
||||
|
||||
## Related dependencies
|
||||
|
||||
- **`github.com/redis/go-redis/v9` v9.23.0** (already required, 19.3 `cooler`): session records, sliding TTL and pub/sub fan-out; `github.com/alicebob/miniredis/v2` v2.40.0 (already required) backs the Docker-free session tests.
|
||||
- **`golang.org/x/oauth2`**: new to the framework's graph through the SDK's `auth` package; already approved in 19.4 for the workspace (`sm-oauthserver-plugin` tests) and in 19.5 (`goth`).
|
||||
|
||||
## Package legitimacy
|
||||
|
||||
The package-legitimacy seam checks npm, PyPI and crates only, so both modules were [ASSUMED] in research and gated by a blocking human check (plan 19.7-02 Task 1) before any `go get`. The human approved exactly `github.com/modelcontextprotocol/go-sdk@v1.8.0` and `github.com/google/jsonschema-go@v0.4.3` on 2026-10-22, with the proxy origins, commits, sums and licences listed above gathered beforehand. The transitive modules listed under Measurements are covered by the same check.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The framework `go.mod` gains `github.com/modelcontextprotocol/go-sdk v1.8.0` and `github.com/google/jsonschema-go v0.4.3` as direct requirements, added in the commit after this note (D-24: the note and the STACK.md row precede the import).
|
||||
- `grep -rl modelcontextprotocol/go-sdk modules --include=*.go` must list only `modules/pier/*` and `modules/surf/pier_on.go`; the phase gate (plan 05) asserts it, together with "only `modules/pier` calls `bouncer.WithDispatch` outside tests".
|
||||
- `examples/hello` and every application built without the tag carry no MCP code; `go version -m` of such a binary is the proof.
|
||||
- Applications that enable MCP add `summercms_mcp` to `summer.yaml` `build.tags` and set `mcp.enabled: true`; the `mcp.*` keys are documented in `modules/pier/README.md` and `docs/services/mcp.md`.
|
||||
|
||||
Released in v0.4.4 (2026-10-23), opt-in behind the `summercms_mcp` build tag and `mcp.enabled`; the full MCP feature ships as v0.5.0 at phase 19.7 completion.
|
||||
51
.planning/notes/2026-10-23-frontend-token-scopes.md
Normal file
51
.planning/notes/2026-10-23-frontend-token-scopes.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Decision: member token scopes use a separate pact capability
|
||||
|
||||
**Date:** 2026-10-23
|
||||
**Status:** Accepted
|
||||
**Context:** Phase 19.7 gap closure, escalation E-2 (`19.7-GAP-INPUTS.md`), planner decision P-30 in plan 19.7-07 Task 2
|
||||
|
||||
## Context
|
||||
|
||||
sm-servers-app escalated E-2: member personal API tokens (`usr_`), which the user plugin issues, can only carry the fixed scopes `read`, `write` and `ai`. A plugin cannot declare its own, so a narrow agent token (`servers:read`, `servers:write`) falls back to the generic `write`, and every application sharing the token table gives the same scope a different meaning.
|
||||
|
||||
What was asked:
|
||||
|
||||
- the user plugin builds its allowed scope list from the built-ins plus plugin-declared scopes, validates names the way cabana does (pattern, no duplicates, no clash with the built-ins) and fails boot on a bad one;
|
||||
- minting, checking (`middleware.Scope`, `APIToken.HasScope`) and listing accept the declared scopes with no special casing;
|
||||
- a discovery endpoint or helper returns the scopes with name, translated label and description.
|
||||
|
||||
What was not asked for:
|
||||
|
||||
- a mint-time hook refusing a scope by the member's role;
|
||||
- any change to backend `g15_` tokens or the cabana token catalog;
|
||||
- any change to `tokens_valid_after` handling.
|
||||
|
||||
The escalation left one design point open: reuse `pact.TokenScope`, or a twin for the frontend catalog.
|
||||
|
||||
## Options
|
||||
|
||||
1. **Reuse `pact.HasTokenScopes`.** The user plugin reads the same capability cabana reads.
|
||||
2. **An audience field on `pact.TokenScope`** (`Audience: "backend" | "frontend"`), with each catalog skipping the other audience's entries.
|
||||
3. **A separate capability**, `pact.FrontendTokenScope{Name, Label, Description}` and `pact.HasFrontendTokenScopes{ FrontendTokenScopes() []FrontendTokenScope }`, mirroring the existing `pact.Permission` / `pact.FrontendPermission` pair.
|
||||
|
||||
## Decision and reasons
|
||||
|
||||
Option 3, a separate capability. pact also gains `pact.ValidTokenScopeName(name string) bool`, carrying cabana's existing pattern `^[a-z][a-z0-9_-]*(:[a-z][a-z0-9_-]*)?$`, so both catalogs validate names identically.
|
||||
|
||||
1. **The escalation asks for no change to the `g15_` catalog.** Reusing `HasTokenScopes` would show every member scope in the admin's token catalog and every admin scope in the member list. The two token kinds belong to different principals (an administrator against cabana permissions, a member against frontend routes); one list cannot describe both.
|
||||
2. **The admin type's fields do not apply to a member token.** `pact.TokenScope` carries `Permissions` (cabana permission patterns) and `Methods` (an HTTP method filter). A member route's `user.scope:<name>` middleware alone decides what a member scope allows. cabana's boot validation also requires both fields to be non-empty and the patterns to match registered permissions, so a member scope could not even be declared through it.
|
||||
3. **An audience field leaves fields meaningless for one audience.** `Permissions` and `Methods` would be dead for `frontend`, cabana would have to skip entries silently, and a typo in the audience would move a scope between catalogs without an error.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The user plugin (sm-user-plugin, plan 19.7-08 Task 3) compiles `HasFrontendTokenScopes` from the active plugins, validates each name with `pact.ValidTokenScopeName`, refuses duplicates and clashes with `read`, `write` and `ai`, and fails boot on a bad scope. It owns minting, checking, listing and the discovery endpoint.
|
||||
- The framework never reads `HasFrontendTokenScopes`; cabana's `g15_` catalog is unchanged in behaviour and in every error message (it now calls `pact.ValidTokenScopeName` instead of its own copy of the pattern).
|
||||
- `pact.ValidTokenScopeName` is the single name rule; a future change to the pattern changes both catalogs together.
|
||||
- Reversibility is costly: `pact.FrontendTokenScope`, `pact.HasFrontendTokenScopes` and `pact.ValidTokenScopeName` are published framework API, so a reshape needs a deprecation cycle.
|
||||
|
||||
## Related
|
||||
|
||||
- `.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md`, section "E-2"
|
||||
- `.planning/phases/19.7-generic-mcp-module/19.7-07-PLAN.md`, P-30 and Task 2
|
||||
- `.planning/phases/19.7-generic-mcp-module/19.7-08-PLAN.md`, Task 3 (the user plugin side)
|
||||
- `modules/pact/capabilities.go`, `modules/cabana/token_scopes.go`
|
||||
33
.planning/notes/2026-10-27-robots-txt-grobotstxt.md
Normal file
33
.planning/notes/2026-10-27-robots-txt-grobotstxt.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Decision: the robots.txt tester uses grobotstxt
|
||||
|
||||
**Date:** 2026-10-27
|
||||
**Status:** Accepted
|
||||
**Context:** Phase 32 (SEO foundation, D-22, D-24, D-99), 32-RESEARCH.md Standard Stack and Package Legitimacy Audit, plan 32-04 Task 4
|
||||
|
||||
## Decision
|
||||
|
||||
The robots.txt tester of `sm-seo-plugin` (element E5, widget action `robots_test`) and the check that warns when robots.txt blocks a noindex address (D-24) match URLs with `github.com/jimsmart/grobotstxt`.
|
||||
|
||||
- **`github.com/jimsmart/grobotstxt` pinned at v1.0.3.** Published 2022-03-16 (proxy.golang.org), Apache-2.0, origin `github.com/jimsmart/grobotstxt` at tag `v1.0.3`. It is the newest tag.
|
||||
- **Why this library.** It is a function-for-function Go port of Google's C++ robots.txt parser and matcher (`google/robotstxt`), so the tester answers what Googlebot does:
|
||||
- the longest matching rule wins, and `Allow` wins a tie with `Disallow`;
|
||||
- `*` matches any run of characters and `$` anchors the end;
|
||||
- user-agent groups are chosen as Google chooses them (the most specific group, else `*`);
|
||||
- `RobotsMatcher.MatchingLine()` gives the line number of the deciding rule (0 when no rule matched), which E5 shows to the editor.
|
||||
- **What the plugin calls:** `NewRobotsMatcher()`, `(*RobotsMatcher).AgentAllowed(robotsBody, userAgent, uri)` and `MatchingLine()`. Nothing else, and only in `sm-seo-plugin/classes/robots.go`.
|
||||
- **Plugin-only.** Only `sm-seo-plugin` requires it. The framework `go.mod` does not, and `grep jimsmart/grobotstxt go.mod` in summercms.go stays empty.
|
||||
- **Imported packages:** the library imports the standard library only (`go list -deps` on a scratch module lists `github.com/jimsmart/grobotstxt` as its single non-stdlib package). Its go.mod requires ginkgo and gomega for its own tests; they reach a consumer's go.sum and are never compiled into a binary.
|
||||
|
||||
## Rejected alternatives
|
||||
|
||||
- **`github.com/temoto/robotstxt` v1.1.2** (2021, MIT). Older, with its own parser, no matching-line API, and no documented Google longest-match semantics.
|
||||
- **A hand-written RFC 9309 matcher** (about 200 lines). Standard library first and no stale dependency, but protocol code the project prefers to take from a maintained library, and Google's behaviour has edge cases the port already covers. RFC 9309 is frozen (2022), so a 2022 release of a faithful port is not a staleness risk in practice.
|
||||
|
||||
## Package legitimacy
|
||||
|
||||
The package-legitimacy seam cannot check Go modules, so grobotstxt was gated by a blocking human check (plan 32-03 Task 4) and approved by Jakub before any `go get`. The orchestrator verified that v1.0.3 resolves through proxy.golang.org; the licence file in the module is Apache-2.0.
|
||||
|
||||
## Consequences
|
||||
|
||||
- `sm-seo-plugin/go.mod` requires `github.com/jimsmart/grobotstxt v1.0.3`; applications that mount the plugin get it through the plugin.
|
||||
- If the library ever needs replacing, the tester's answer shape (allowed or blocked, the line and its text, blocked by a bot switch) is the plugin's own, so only `classes/robots.go` changes.
|
||||
@@ -0,0 +1,131 @@
|
||||
---
|
||||
phase: "16.2"
|
||||
slug: "plugin-provided-field-types-and-the-blog-editor-formwidget"
|
||||
status: verified
|
||||
# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate)
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: "2026-10-28"
|
||||
---
|
||||
|
||||
# Phase 16.2 — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail.
|
||||
|
||||
Paths are relative to the meta repo (`summercms.go/`, `sm-journal-plugin/`, `vue-journal-layer/`, `sm-grzybyfunkcjonalne-app/`). Code was checked at each repo's HEAD; for code that later moved (the site-cache purger now lives in `summercms.go/modules/cooler`), the 16.2 release commit `5eea57f` was checked too.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| admin browser → cabana admin API | Save bodies, upload bodies and field-type requests (cookie or Bearer session) | field values in every locale, uploaded files |
|
||||
| plugin Go code → cabana | Decode, Load, ListValue and Upload run inside cabana's handlers and save transaction | decoded values, plugin errors and notices |
|
||||
| plugin element JS → admin SPA DOM | The element runs in the admin origin under CSP `script-src 'self'` | `value` property, plain attributes, `summer-upload` events |
|
||||
| stored post HTML → admin editor DOM | Imported or previously saved HTML is parsed into the editor | untrusted HTML |
|
||||
| admin save body → Journal Decode | Every locale's content value crosses here through cabana | HTML to sanitize |
|
||||
| editor upload → media bucket | User files become public URLs under `/storage/app/uploads/public` | image bytes, object keys |
|
||||
| Journal API `content_html` → site `v-html` | Stored HTML becomes page markup | HTML, embed placeholders |
|
||||
| site page → youtube-nocookie.com | The visitor's browser loads a third-party frame | referrer, visitor IP |
|
||||
| Go host → Nuxt (loopback HTTP) | Journal calls the layer purge route with a bearer token | purge token, slug |
|
||||
| internet → nginx → Nuxt | Visitors reach Nuxt with GET/HEAD only; nginx adds forwarding headers | requests, X-Forwarded-For |
|
||||
| npm registry → plugin build | `@tiptap/*` packages enter the committed bundle | third-party code |
|
||||
| executor → git origin / UAT server | Tags and pushes read by other repos; release runs next to the live Winter site | tags, binaries, `.env` secrets (server only) |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|----------|-------------|------------|--------|
|
||||
| T-16.2-01 | Spoofing | compileFieldTypes alias registry | high | mitigate | `summercms.go/modules/cabana/field_type.go:106` refuses core aliases, `:166-171` refuses a cross-plugin alias naming both owners, `:172` checkWidgetTag (prefix check `extension.go:346`) | closed |
|
||||
| T-16.2-02 | Tampering (stored XSS) | decodePluginFields | high | mitigate | `crud.go:830-852` runs it inside the save transaction; `field_type.go:465/489/511` decode host value and every locale; only skip is the served-value match `:539-541`, which writes nothing | closed |
|
||||
| T-16.2-03 | Elevation of Privilege | fieldUpload route | high | mitigate | `http.go:452` requireAjax; `field_type_upload.go:35` protect (guard and permissions `http.go:1216-1225`), `:49/:142-160` field/context check and 404 without Upload, `:124` loadRecord scope; `auth.go:253` SameSite=Strict | closed |
|
||||
| T-16.2-04 | Denial of Service | fieldUpload body | medium | mitigate | `field_type_upload.go:69` MaxBytesReader on `upload_bytes`, `:85/:168-177` exactly one part, `:200-204` 413 | closed |
|
||||
| T-16.2-05 | Information Disclosure | PluginField / element | high | mitigate | `admin/src/components/form/fields/PluginField.vue:63-65,76-84` value and plain attributes only, upload via SPA `api.POST` `:133`; test `admin/tests/form/PluginField.test.ts:103` | closed |
|
||||
| T-16.2-06 | Tampering | typeOptions to element | low | mitigate | `PluginField.vue:44,81` JSON attribute string; no `v-html` | closed |
|
||||
| T-16.2-07 | Information Disclosure | plugin errors | medium | mitigate | `field_type.go:669-686` only `*pact.FormFieldError` → 422; `:690-693` and `:727-729` opaque 500 | closed |
|
||||
| T-16.2-08 | Tampering | untouched skip | low | accept | See AR-16.2-01 | closed |
|
||||
| T-16.2-33 | Tampering (admin XSS) / DoS | save notices | medium | mitigate | `admin/src/components/form/FormField.vue:86`, `ui/Toast.vue:34` text interpolation only; `field_type.go:40-42,799,811` 10 notices per field/locale, 500 runes; test `FormField.test.ts:50` | closed |
|
||||
| T-16.2-09 | Elevation of Privilege (admin XSS) | rawHtml node view | high | mitigate | `sm-journal-plugin/assets/src/blogeditor/extensions.ts:301,315` textContent; parse in inert document `:270-273`; test `tests/blogeditor/smoke.test.ts:135` | closed |
|
||||
| T-16.2-10 | Tampering (stored XSS) | Source tab and pasted HTML | high | mitigate | `classes/blog_editor.go:164` SanitizeHTMLReport on every locale; admin `FormView.vue:478` adopts the stored value; layer `PostBody.vue:13` sanitizes again | closed |
|
||||
| T-16.2-11 | Tampering | link mark | medium | mitigate | `extensions.ts:42-63` isPolicyUrl (control chars removed first), `:545`; `element.ts:465,570`; tests `smoke.test.ts:417-424` | closed |
|
||||
| T-16.2-12 | Elevation of Privilege | bundle under admin CSP | medium | mitigate | no `eval(`/`new Function(` in `assets/dist/blogeditor.js`; `element.ts:202` `injectCSS: false`; CSS scoped under `golem15-journal-blogeditor` | closed |
|
||||
| T-16.2-13 | Information Disclosure | uploads | high | mitigate | `element.ts:559` dispatches `summer-upload {id, file}` only; no fetch, XHR, cookie or storage access in `assets/src/blogeditor` | closed |
|
||||
| T-16.2-14 | Tampering (stored XSS) | decodeBlogHTML (posts, categories) | high | mitigate | `blog_editor.go:154-166`; `models/post/fields.yaml:19`, `models/category/fields.yaml:28`; tests `posts_admin_smoke_test.go:360`, `categories_admin_editor_test.go:56` | closed |
|
||||
| T-16.2-31 | Tampering (stored XSS) | newHTMLPolicy editor-output extension | high | mitigate | `classes/format_html.go:63-72`, exactly four AllowAttrs added since `c60abc6`; 16.1 policy tests unchanged; `editor_policy_test.go:68` | closed |
|
||||
| T-16.2-34 | Denial of Service | SanitizeHTMLReport and removal notices | low | mitigate | `format_html.go:105` (`maxRemovalNames = 10`), `:145-153`; cabana cap (T-16.2-33) | closed |
|
||||
| T-16.2-15 | Tampering / Elevation | uploadBlogImage | high | mitigate | `media_store.go:89-93` allowlist without svg, `:20,98-104` 10240 KiB cap; `blog_editor.go:365-375` DetectContentType; staging vhost `:89` nosniff | closed |
|
||||
| T-16.2-16 | Tampering | upload keys | medium | mitigate | `blog_editor.go:129-147` folder check at boot, `:397-426` safeUploadName; `media_store.go:155,193-224` never overwrites | closed |
|
||||
| T-16.2-17 | Repudiation / contract | public posts and media routes | medium | mitigate | `controllers/api/posts_helpers.go`, `posts.go`, `routes.go` unchanged `c60abc6..5eea57f`; `api/media.go:43-63` keeps body and errors | closed |
|
||||
| T-16.2-18 | Information Disclosure | content_html companion writes | low | mitigate | `controllers/posts.go:216-224,271-308` written locales only, in the transaction | closed |
|
||||
| T-16.2-19 | Tampering (iframe injection) | expandEmbeds | high | mitigate | `vue-journal-layer/app/utils/embeds.ts:41` exact regex, `:51` provider allowlist, `:53` id pattern, `:29` fixed host | closed |
|
||||
| T-16.2-20 | Elevation of Privilege | sanitize-then-expand order | high | mitigate | `Journal/PostBody.vue:13`, `CategoryHeader.vue:11` `expandEmbeds(sanitizeJournalHtml(...))`, no other caller; gate `check-phase16.2.sh:123` | closed |
|
||||
| T-16.2-32 | Tampering (policy drift) | htmlGate.ts mirror | high | mitigate | `app/utils/htmlGate.ts:68-71,122-127`, only these rules since `294a8d8`; corpus copies identical (`cmp`) | closed |
|
||||
| T-16.2-21 | Information Disclosure (visitor privacy) | YouTube frame | low | mitigate | `embeds.ts:29,57-58` nocookie host, lazy, strict-origin-when-cross-origin; staging vhost `:93` frame-src (report-only; server install pending, WINDOWS 19) | closed |
|
||||
| T-16.2-22 | Tampering / Repudiation | layer tag and pushes | medium | mitigate | v0.2.0 annotated (`042b65d → 759e684`); `scripts/check-git-install.sh`; 04-SUMMARY records `check-git-install: ok` and pushed heads | closed |
|
||||
| T-16.2-23 | Tampering (false-green release) | release gate | medium | mitigate | 05-SUMMARY `release-gate-ok`, Docker-only suites listed, human reply "release v0.1.18" | closed |
|
||||
| T-16.2-24 | Tampering / Repudiation | annotated tag and pushes | high | mitigate | v0.1.18 annotated (`04dc5bd → f1d8a75`), contains plan 01 head `4adb48a`; binary sha256 matched; heads on origin | closed |
|
||||
| T-16.2-25 | Information Disclosure | credentials | high | mitigate | `sm-grzybyfunkcjonalne-app/DEPLOY.md:74` no `.env` rsync; no env file tracked; `.gitignore:5`; 05-SUMMARY no auth gates | closed |
|
||||
| T-16.2-26 | Tampering | UAT database and Winter site | medium | mitigate | 05-SUMMARY: SELECT-only checks, `.prev` rollback copies kept | closed |
|
||||
| T-16.2-35 | Tampering | UAT strip check | low | mitigate | Strip verified (05-SUMMARY edit-ok); test post `uat-16-2-blog-editor` (id 105) deleted by the user on 2026-10-28 | closed |
|
||||
| T-16.2-27 | Elevation of Privilege | sudo on the server | low | accept | See AR-16.2-02 | closed |
|
||||
| T-16.2-28 | Tampering | test isolation | low | mitigate | `sm-journal-plugin/vite.config.ts:38`; memblob, testcontainers; no ssh, curl or child_process in tests | closed |
|
||||
| T-16.2-29 | Repudiation (false green) | phase gate | medium | mitigate | `summercms.go/scripts/check-phase16.2.sh:143-270` detectors, `:376-450` self-test, `:570-586` NOT RUN and `PHASE162_REQUIRE_POSTGRES` | closed |
|
||||
| T-16.2-30 | Tampering (security regression) | strip, policy, permission tests | medium | mitigate | `check-phase16.2.sh:64-130` named tests, `:479-482` 16.1 policy tests pinned to `c60abc6`, `:502` corpus `cmp` | closed |
|
||||
| T-16.2-36 | Spoofing / DoS | layer purge route | medium | mitigate | `server/api/__journal__/cache/purge.post.ts:25-30`; `app/utils/siteCache.ts:39` 32-char minimum, `:40` proxied → 404, `:43` timingSafeEqual over sha256; staging vhost `:236-239` `limit_except`; 07-SUMMARY purge-ok `200 83 403 401` | closed |
|
||||
| T-16.2-37 | Information Disclosure | purge token | high | mitigate | log-capture tests `5eea57f:classes/site_cache_test.go:158-162`, now `modules/cooler/sitecache_test.go:257`; `DEPLOY.md:86,210-213` urandom/printf, `-H @-`; only `token-match` crossed ssh. See Follow-ups for a later leak path | closed |
|
||||
| T-16.2-38 | Tampering (stale content) | purge ordering | medium | mitigate | lagoon.AfterCommit `5eea57f:classes/site_cache.go:181`, now `cooler/sitecache.go:306`; tests `site_cache_admin_test.go:162,240` | closed |
|
||||
| T-16.2-39 | Denial of Service | admin save path | low | mitigate | 2 s WithTimeout(WithoutCancel) `cooler/sitecache.go:32,159`; tests `site_cache_admin_test.go:319,349` | closed |
|
||||
| T-16.2-40 | Information Disclosure | purge URL misconfiguration | medium | mitigate | `cooler/sitecache.go:82-109` (was `site_cache.go:57-84`): both-or-neither, no userinfo or fragment, http only to loopback, 32-char token | closed |
|
||||
| T-16.2-41 | Tampering (log injection) | layer purge log line | low | mitigate | `siteCache.ts:83` strips control chars, `:14` 200-char slug cap | closed |
|
||||
| T-16.2-42 | Tampering (cache poisoning) | Nitro route cache | medium | mitigate | `nuxt.config.ts:77` `cache: false`; `purge.post.ts:18` no-store; `testing/purge-check.mjs:175-184` | closed |
|
||||
| T-16.2-43 | Denial of Service | full route-cache purge | low | accept | See AR-16.2-03 | closed |
|
||||
| T-16.2-44 | Repudiation (false-green gate) | phase gate | medium | mitigate | `check-phase16.2.sh:72,88,93,557,565`; VALIDATION 07-T3 green with `PHASE162_REQUIRE_POSTGRES=1` | closed |
|
||||
| T-16.2-45 | Tampering / Repudiation | tags and pushes | high | mitigate | v0.1.20 (`ad7981f → aba063f`), layer v0.3.0 (`c09e0d0 → 25e9bfe`) match 07-SUMMARY; heads on origin; sha256 matched; site lockfile `3a920c7` resolves to `25e9bfe` | closed |
|
||||
| T-16.2-46 | Tampering | UAT database and Winter site | medium | mitigate | 07-SUMMARY: read-only snapshots, human-only data changes, deploy-ok `.prev` rollback checks | closed |
|
||||
| T-16.2-SC | Tampering | packages (all seven plans) | high | mitigate | 01, 03, 06: no dependency file changes; 02: exact `@tiptap/*` pins 3.31.4, committed lockfile, `scripts/check-dist.sh` rebuild diff, human "packages approved"; 04, 07: layer version bump and pin only, `node:crypto` only; 05: `build.sh:53` `--frozen-lockfile` | closed |
|
||||
|
||||
*Status: open · closed · open — below high threshold (non-blocking)*
|
||||
*Severity: critical > high > medium > low — only open threats at or above workflow.security_block_on count toward threats_open*
|
||||
*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
| Risk ID | Threat Ref | Rationale | Accepted By | Date |
|
||||
|---------|------------|-----------|-------------|------|
|
||||
| AR-16.2-01 | T-16.2-08 | Submitting the served value only skips the write; the skip cannot store anything Decode did not already accept (`field_type.go:539-541`) | plan 16.2-01 threat model; reconfirmed by audit | 2026-10-28 |
|
||||
| AR-16.2-02 | T-16.2-27 | Server sudo is limited to `nginx -t`, nginx reload and supervisorctl (`DEPLOY.md:34`); the release used supervisorctl only | plan 16.2-05 threat model; reconfirmed by audit | 2026-10-28 |
|
||||
| AR-16.2-03 | T-16.2-43 | Only authenticated loopback callers can purge; admin saves are rare; each page re-renders once from the local API | plan 16.2-07 threat model; reconfirmed by audit | 2026-10-28 |
|
||||
|
||||
*Accepted risks do not resurface in future audit runs.*
|
||||
|
||||
---
|
||||
|
||||
## Follow-ups (outside the 16.2 register)
|
||||
|
||||
- **Purge token likely exposed on UAT (later regression, not 16.2 code).** The site app pins vue-journal-layer v0.4.0, which brings `@nuxtjs/seo` / nuxt-site-config; that copies every `NUXT_SITE_*` variable into page payloads, and `sm-grzybyfunkcjonalne-app/DEPLOY.md:86` names the token `NUXT_SITE_CACHE_PURGE_TOKEN`. Fixed in the layer at v0.6.0 (`e0cc871`). Not checked on the live server. Action: bump the pin to ≥ v0.6.0, rename to `NUXT_CACHE_PURGE_TOKEN`, rotate the token.
|
||||
- **Surface added after planning, no threat ID:** Blog Editor preview pane (empty-sandbox `srcdoc` iframe with CSP meta, `sm-journal-plugin/assets/src/blogeditor/preview.ts:6-14,190`, accepted in UAT test 5); admin "View site" link (`admin/src/components/shell/AppShell.vue:80-81`, `noopener noreferrer`); visitor X-Forwarded-For forwarded to Go on cached renders (`vue-journal-layer/server/plugins/journal-client-address.ts`, commit `03a90e9`).
|
||||
- **Housekeeping:** WINDOWS entry 19 still needs the staging vhost install (frame-src); the test-post part is done. 16.2-VALIDATION rows 07-T4..T6 still read pending although 07-SUMMARY records them as passed.
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| 2026-10-28 | 47 | 47 | 0 | msd-security-auditor (retroactive, State B); T-16.2-35 closed after the user deleted UAT post 105 |
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [x] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [x] Accepted risks documented in Accepted Risks Log
|
||||
- [x] `threats_open: 0` confirmed
|
||||
- [x] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** verified 2026-10-28
|
||||
87
.planning/phases/19-chat-and-chatchannels/19-SECURITY.md
Normal file
87
.planning/phases/19-chat-and-chatchannels/19-SECURITY.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
phase: "19"
|
||||
slug: "chat-and-chatchannels"
|
||||
status: verified
|
||||
# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate)
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: "2026-10-28"
|
||||
---
|
||||
|
||||
# Phase 19 — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail.
|
||||
|
||||
Implementation lives in the sibling repos `sm-chat-plugin` and `sm-chatchannels-plugin`; the user-namespace authorizer and `user.Deleting` event are in `sm-user-plugin` v0.1.2. Paths below are relative to the meta repo.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| client → /_chat/api/v1, /_chatchannels/api/v1 | untrusted JSON, ids and multipart files cross jwt.auth | message bodies, attachment bytes, conversation ids |
|
||||
| ChatService write → Postgres | authenticated actor ids become conversation and message rows | user-authored content |
|
||||
| ChatService → lighthouse / Centrifugo | realtime payloads cross to subscribers | event payloads (ids only) |
|
||||
| Authorizer → subscribe | client-chosen channel string trusted only after participant check | channel names |
|
||||
| download handler → blob store | private system_files bytes leave only after a participation check | private attachments |
|
||||
| DM start → other users | unsolicited conversation creation | conversation rows |
|
||||
| ChannelService → resolver | host-installed access policy; default deny-all | context access decisions |
|
||||
| mention body → users.handle | untrusted @tokens become mention rows | user ids |
|
||||
| user delete → chat/channel tables | GDPR cascade must not leave prefs/members or wipe others' rows | personal data |
|
||||
| golden files / check-phase19.sh → CI | recorded PHP payloads and sibling paths become the acceptance oracle | test oracle |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|----------|-------------|------------|--------|
|
||||
| T-19-01 | Information disclosure | api/download.go, message GET | high | mitigate | `sm-chat-plugin/api/download.go` collapses missing/unauthorized to `writeNotFound`; `AttachmentForDownload` checks `CanView`; `TestAttachmentDownload` (http_tracer_test.go:340) | closed |
|
||||
| T-19-02 | Elevation of privilege | api/dm.go | medium | mitigate | `chat-dm` bucket Max 10 / minute (routes.go:69); `TestDMThrottle` in PG_CHAT_TESTS | closed |
|
||||
| T-19-03 | Tampering | classes/attachment_policy.go | high | mitigate | `MaxAttachments = 5`, `MaxAttachmentBytes`, `BannedExts` svg/html/xml + banned MIME list; `TestAttachmentPolicy` | closed |
|
||||
| T-19-04 | Information disclosure | lighthouse Bind payload | high | mitigate | ids-only broadcast payload; `TestChatTracer` (tracer_test.go:17) and golden_test.go fail if a publication contains `content` | closed |
|
||||
| T-19-05 | Elevation of privilege | classes/authorizer.go | high | mitigate | parses `chat:conversation:{id}` (one optional presence: prefix), `Denied("not a participant")`, capabilities `["prs"]`, checked per subscribe | closed |
|
||||
| T-19-06 | Elevation of privilege | classes/mention_parser.go | high | mitigate | `ResolveMentionedParticipantIDs` joins `golem15_chat_participants` for the conversation and excludes `senderID` (channel_service.go:1158) | closed |
|
||||
| T-19-07 | Information disclosure | user.Deleting → SeverUserFromContext | high | mitigate | `FireDeletingEvent` fires inside the delete tx (sm-user-plugin controllers/users_admin_controller.go:525); chatchannels `onUserDeleting` → `SeverUserFromContext`; `TestDeletingCascade` | closed |
|
||||
| T-19-08 | Denial of service | classes/search_indexer.go | medium | mitigate | index/deindex errors logged at Warn, never returned (fail-open); `TestSearchIndexer` | closed |
|
||||
| T-19-09 | Elevation of privilege | api/attachments.go pending field | high | mitigate | `PendingField(actorID)` = `chat-pending-{actorID}`; claiming another actor's pending row refused (classes/attachments.go:22) | closed |
|
||||
| T-19-10 | Elevation of privilege | user namespace authorizer | high | mitigate | sm-user-plugin `AuthorizeUser` allows only `user:{id}` for that user, rejects double presence/extra segments; `RegisterUserAuthorizer` skips if registered; `TestUserAuthorizer` in check-phase19.sh | closed |
|
||||
| T-19-11 | Denial of service | mention regex | medium | mitigate | RE2 `@([A-Za-z0-9_.-]{2,255})`, bounded, no nested quantifiers (mention_parser.go:8) | closed |
|
||||
| T-19-12 | Elevation of privilege | DenyAll + Boot Warn | medium | mitigate | `DenyAll` returns false for both methods; boot.go:64 Warns while resolver is deny-all | closed |
|
||||
| T-19-13 | Information disclosure | TestGoldenEvents | high | mitigate | golden_test.go:241 fails when a publication payload contains key `content` | closed |
|
||||
| T-19-14 | Elevation of privilege | mention resolve | high | mitigate | participant-only handle match (same query as T-19-06); `TestHandleMention` (sm-chatchannels-plugin http_tracer_test.go:37) | closed |
|
||||
| T-19-15 | Elevation of privilege | classes/service.go canSend | high | mitigate | `canSend` returns `isParticipant` only (service.go:304); `ErrNotParticipant` mapped to 404 (api/errors.go:57); `TestGapClosureSmoke`, `TestTeammateDMWriteIDOR` | closed |
|
||||
| T-19-16 | Tampering | user.Deleting → created_by CASCADE | high | mitigate | chat `onUserDeleting` → `ReassignCreatedBy` in the Deleting tx (boot.go:187, service.go:115); baseline CASCADE untouched | closed |
|
||||
| T-19-17 | Elevation of privilege | TestTeammateDMWriteIDOR + PG_CHAT_TESTS | high | mitigate | listed in `PG_CHAT_TESTS` and in the self-test required tokens of scripts/check-phase19.sh | closed |
|
||||
| T-19-18 | Tampering | TestDeletingCascade creator path | high | mitigate | test fires Deleting then `Unscoped` deletes Alice (http_tracer_test.go:301); `TestDeletingCascade` in `PG_CHATCHANNELS_TESTS` | closed |
|
||||
| T-19-SC | Tampering | go.mod requires, scripts/check-phase19.sh | high | mitigate | plugin direct requires (gormigrate, pgx, testcontainers, gocloud.dev, gorm) are the framework's pinned versions plus Golem15 modules; gate installs no packages and `--self-test` plants failures | closed |
|
||||
|
||||
*Status: open · closed · open — below high threshold (non-blocking)*
|
||||
*Severity: critical > high > medium > low — only open threats at or above workflow.security_block_on count toward threats_open*
|
||||
*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
No accepted risks.
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| 2026-10-28 | 19 | 19 | 0 | /msd-secure-phase (orchestrator, ASVS L1 grep verification) |
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [x] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [x] Accepted risks documented in Accepted Risks Log
|
||||
- [x] `threats_open: 0` confirmed
|
||||
- [x] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** verified 2026-10-28
|
||||
@@ -0,0 +1,290 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
plan: 01
|
||||
subsystem: auth
|
||||
tags: [sm-user-plugin, login-gate, device-flow, jwt, jti, blacklist, 2fa, gormigrate]
|
||||
|
||||
requires:
|
||||
- phase: 19.4
|
||||
provides: sm-user-plugin v0.1.x as its own repository (core plugin contract, additive changes only)
|
||||
- phase: 19.5
|
||||
provides: user API login/refresh/logout and the bouncer JWT blacklist
|
||||
provides:
|
||||
- D-04 decision note for pquerna/otp v1.5.0, go-webauthn/webauthn v0.18.2, boombuler/barcode v1.1.0 (human package check passed)
|
||||
- Login-gate registry (classes.LoginGates) consulted by password Login before restore and mint
|
||||
- classes.LoginEvent fired once per successful password login
|
||||
- Password-change hook through (*classes.AccessRevokedEvent).PasswordChanged()
|
||||
- Reset-2FA admin slot (permission golem15.users.reset_two_factor, record action reset_two_factor, classes.TwoFactorAdmin service)
|
||||
- Device authorization by QR or short code (5 routes, golem15_user_device_auth_sessions table)
|
||||
- Device list and revoke, with the device jti handed over on refresh
|
||||
affects: [19.6-02, 19.6-03, 19.6-04, sm-mfa-plugin, sm-sociallogin-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 27169 # chars/4 over added lines: sm-user-plugin 50da92c..3b22134 (101994 chars) + summercms.go ecc34bc..24d9d2a (6683 chars)
|
||||
tasks: 5
|
||||
commits: 1 # MEASURED in summercms.go: git rev-list --count ecc34bc..24d9d2a; sm-user-plugin measured separately: git rev-list --count 50da92c..3b22134 = 5
|
||||
plan_head_before: ecc34bc35a653fee7241255e055d09b20f1f09b5
|
||||
plan_head_after: 24d9d2a
|
||||
sm_user_plugin_head_before: 50da92c
|
||||
sm_user_plugin_head_after: 3b22134
|
||||
|
||||
tech-stack:
|
||||
added: [] # the three libraries are decided and approved, not installed; plan 02 installs them in sm-mfa-plugin only
|
||||
patterns:
|
||||
- "Login-gate registry: a service published in Register that first-factor paths consult before minting"
|
||||
- "Guarded single-row UPDATE for one-time state transitions (pending->confirmed, confirmed->used)"
|
||||
- "Optional service lookup decides whether an admin record action Applies"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- .planning/notes/2026-10-21-mfa-otp-webauthn.md
|
||||
- ../fonoteka.go/plugins/golem15/user/classes/login_gate.go
|
||||
- ../fonoteka.go/plugins/golem15/user/classes/two_factor_admin.go
|
||||
- ../fonoteka.go/plugins/golem15/user/classes/device_auth.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/login_gates.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/devices.go
|
||||
- ../fonoteka.go/plugins/golem15/user/models/device_auth_session.go
|
||||
- ../fonoteka.go/plugins/golem15/user/updates/202610260001_create_device_auth_sessions.go
|
||||
- ../fonoteka.go/plugins/golem15/user/login_gate_smoke_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/password_changed_smoke_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/reset_two_factor_smoke_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/device_flow_smoke_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/device_revoke_smoke_test.go
|
||||
modified:
|
||||
- .planning/research/STACK.md
|
||||
- ../fonoteka.go/plugins/golem15/user/classes/events.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/api_controller.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/registration.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- ../fonoteka.go/plugins/golem15/user/controllers/users/config_form.yaml
|
||||
- ../fonoteka.go/plugins/golem15/user/admin_permissions.go
|
||||
- ../fonoteka.go/plugins/golem15/user/plugin.go
|
||||
- ../fonoteka.go/plugins/golem15/user/routes.go
|
||||
- ../fonoteka.go/plugins/golem15/user/config/config.yaml
|
||||
- ../fonoteka.go/plugins/golem15/user/lang/en/lang.yaml
|
||||
- ../fonoteka.go/plugins/golem15/user/lang/pl/lang.yaml
|
||||
- ../fonoteka.go/plugins/golem15/user/README.md
|
||||
|
||||
key-decisions:
|
||||
- "D-07 reuses classes.AccessRevokedEvent (already fired in-transaction at all three password-write sites) plus (*AccessRevokedEvent).PasswordChanged(); no PasswordChangedEvent type exists. Plan 02 listens on *classes.AccessRevokedEvent and filters with ev.PasswordChanged()."
|
||||
- "Device-session migration ID is 202610260001_create_device_auth_sessions so it sorts after the existing 202610220001 (the planned 202610210002 would have sorted before it)."
|
||||
- "Device auth_url reuses golem15.user.frontend_url / classes.FrontendURL; the only new config keys are golem15.user.device_auth.auth_url and golem15.user.device_auth.ttl_minutes."
|
||||
- "Task 5 package check approved by the user: plan 02 may install pquerna/otp v1.5.0, go-webauthn/webauthn v0.18.2 and boombuler/barcode v1.1.0 in sm-mfa-plugin."
|
||||
|
||||
patterns-established:
|
||||
- "LoginGates: plugins Add a LoginGate in Register; first-factor handlers call controllers.CheckLoginGates before restore and mint, and controllers.FireLoginEvent after the mint"
|
||||
- "One-time device JWT: confirmed->used guarded UPDATE, exactly one poll receives the token"
|
||||
|
||||
requirements-completed: [SC-2, SC-3, SC-4, D-02, D-03, D-04, D-06, D-07, D-11, D-12a, D-12b, D-12c, D-15, D-16, D-17, D-18]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "D-04 decision note names the three pinned libraries, binary delta, linked modules, govulncheck run and the human package check; STACK.md lists the pins"
|
||||
requirement: "D-04"
|
||||
verification:
|
||||
- kind: manual_procedural
|
||||
ref: "Task 5 checkpoint reply: approved"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "Package legitimacy is a human sign-off by design (blocking-human gate); given as \"approved\"."
|
||||
- id: D2
|
||||
description: "Login consults the gate registry after CheckAndRecordLogin and the rehash, before restore and mint; empty registry keeps old responses; erroring gate fails closed; challenged soft-deleted account stays deleted"
|
||||
requirement: "D-02"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../fonoteka.go/plugins/golem15/user/login_gate_smoke_test.go#TestLoginGatesSmoke, TestLoginGateSmoke (5 sub)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Password writes (reset, change, admin set) fire the revocation event in-transaction with PasswordChanged() true; listener error rolls back; rehash fires nothing"
|
||||
requirement: "D-07"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../fonoteka.go/plugins/golem15/user/password_changed_smoke_test.go#TestPasswordChangedEventSmoke (5 sub)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Reset-2FA permission and record action, shown only when a TwoFactorAdmin service is published"
|
||||
requirement: "D-15"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../fonoteka.go/plugins/golem15/user/reset_two_factor_smoke_test.go#TestResetTwoFactorSlotSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Device initiate/status/authorize with hashed token, XXXX-XXXX short code, 5-minute TTL, one-time JWT on first confirmed poll"
|
||||
requirement: "D-12a"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../fonoteka.go/plugins/golem15/user/device_flow_smoke_test.go#TestDeviceCodesSmoke, TestDeviceFlowSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Device list and revoke; revoke blacklists the jti, also after refresh moved it"
|
||||
requirement: "D-12b"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../fonoteka.go/plugins/golem15/user/device_revoke_smoke_test.go#TestDeviceRevokeSmoke (3 sub)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: 61min
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6 Plan 01: Foundations Summary
|
||||
|
||||
**sm-user-plugin gains a login-gate registry wired into password Login, a login event, a password-change hook on the existing revocation event, a Reset-2FA admin slot, and QR/short-code device authorization with a one-time JWT and jti-tracked revoke; the OTP, WebAuthn and QR libraries are decided and approved for plan 02.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 61 min
|
||||
- **Started:** 2026-10-26T08:48:46Z
|
||||
- **Completed:** 2026-10-26T09:49Z
|
||||
- **Tasks:** 5 (4 code/docs tasks, 1 human checkpoint)
|
||||
- **Files modified:** 31 in sm-user-plugin, 2 in summercms.go
|
||||
|
||||
## Base commits
|
||||
|
||||
- **sm-user-plugin** (`../fonoteka.go/plugins/golem15/user`): phase base `50da92c` (v0.1.11). Plan 04's additive check diffs against it. HEAD after this plan: `3b22134`.
|
||||
- **summercms.go**: base `ecc34bc` (ledger `.git/msd-plan-head-before-19.6-01`).
|
||||
|
||||
## Task Commits
|
||||
|
||||
In order, planning docs first:
|
||||
|
||||
| # | Repository | Commit | Message |
|
||||
|---|------------|--------|---------|
|
||||
| 1a | summercms.go | `24d9d2a` | docs(19.6): decide the OTP, WebAuthn and QR libraries |
|
||||
| 1b | sm-user-plugin | `8501f34` | feat: login gates and the login event (tracer) |
|
||||
| 2 | sm-user-plugin | `7900f47` | feat: password-change hook and the reset-2FA admin slot |
|
||||
| fix | sm-user-plugin | `3d4c8d2` | style: gofmt the login gate smoke test |
|
||||
| 3 | sm-user-plugin | `4e3e5b0` | feat: device authorization by QR or short code |
|
||||
| 4 | sm-user-plugin | `3b22134` | feat: device list and revoke with the jti followed through refresh |
|
||||
| 5 | none | none | Package check, resolved by the user's reply (below) |
|
||||
|
||||
Nothing was pushed or tagged.
|
||||
|
||||
## Task 5 reply
|
||||
|
||||
The user replied, verbatim:
|
||||
|
||||
> approved
|
||||
|
||||
Before the checkpoint, the module proxy confirmed the pins: pquerna/otp v1.5.0 (Apache-2.0, tag v1.5.0, `5971b1ef1d66`), go-webauthn/webauthn v0.18.2 (BSD-3-Clause, tag v0.18.2, `a4c6fc6a4399`, latest), boombuler/barcode v1.1.0 (MIT, tag v1.1.0, `11e32e438ffc`). Nothing was installed and no go.mod requires any of them. Plan 02 may now add them to sm-mfa-plugin's go.mod only.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Login gates (tracer, D-02, D-18).** `classes.LoginGates` is published in Register. Login checks it after `CheckAndRecordLogin(..., true)` and the bcrypt rehash, and before the soft-delete restore and the mint. A challenge answers the gate's own status and body with no token. A gate error returns the opaque 500. An empty registry leaves responses unchanged. Refresh never consults gates. A challenged soft-deleted account stays deleted and gets no reactivate mail.
|
||||
- **Login event.** `classes.LoginEvent` (`golem15.user.login`) fires once after each successful mint, and never for a challenged login.
|
||||
- **Password-change hook (D-07).** Uses the existing in-transaction `AccessRevokedEvent` plus `PasswordChanged()` (see Deviations).
|
||||
- **Reset-2FA slot (D-15).** Adds the permission `golem15.users.reset_two_factor` (no default role) and the record action `reset_two_factor` (Danger) on the Users screen. The action appears only when a `classes.TwoFactorAdmin` service is published, and `Run` calls `Reset` inside cabana's transaction.
|
||||
- **Device authorization (D-03, D-06, D-11, D-12a, D-12c, D-16).** Five routes in the user-api group:
|
||||
- `POST devices/initiate`, `GET devices/status/{token}`, `POST devices/authorize`, `GET devices`, `DELETE devices/{id}`.
|
||||
- The 64-character token is stored as SHA-256 hex. The short code is `XXXX-XXXX` over `23456789ABCDEFGHJKMNPQRSTUVWXYZ` and the TTL is 5 minutes.
|
||||
- Statuses match PHP (`pending|confirmed|used|expired|revoked`), plus a `jwt_jti` column.
|
||||
- Guarded UPDATEs make pending->confirmed and confirmed->used happen once, so exactly one poll gets the JWT.
|
||||
- **Revoke (D-12b).** `DELETE devices/{id}` marks the row revoked and blacklists its `jwt_jti`. Refresh hands the jti over to the new token (`HandOverDeviceJTI`), so a device that refreshed is still signed out.
|
||||
- **Additive only (D-17).** No v0.1.11 route, body, table, column, migration ID or config key changed. fonoteka.go, sm-sociallogin-plugin and sm-oauthserver-plugin compile against the checkout.
|
||||
|
||||
## Exported identifiers and config keys (for plans 02 and 03)
|
||||
|
||||
Package `classes`:
|
||||
- Login gates: `LoginAttempt`, `LoginGateResult`, `LoginGate` (`CheckLogin`), `LoginGates` (`NewLoginGates`, `Add`, `Check`)
|
||||
- Login sources: `LoginSourcePassword`, `LoginSourceSocial`, `LoginSourcePasskey`, `LoginSourceTwoFactor`, `LoginSourceDevice`
|
||||
- Events: `LoginEvent`, `LoginEventName` (`"golem15.user.login"`), `(*AccessRevokedEvent).PasswordChanged()`
|
||||
- Admin slot: `TwoFactorAdmin` (`HasTwoFactor`, `Reset`), `PermissionResetTwoFactor`
|
||||
- Device helpers: `DeviceShortCodeAlphabet`, `NewDeviceToken`, `NewDeviceShortCode`, `NormalizeDeviceShortCode`, `DeviceAuthTTL`, `DeviceAuthURL`, `DeviceDisplayName`, `HandOverDeviceJTI`
|
||||
|
||||
Package `controllers`: `CheckLoginGates`, `FireLoginEvent`, `DeviceInitiate`, `DeviceStatus`, `DeviceAuthorize`, `DeviceIndex`, `DeviceDestroy`
|
||||
|
||||
Package `models`: `DeviceAuthSession`, `DeviceStatusPending`, `DeviceStatusConfirmed`, `DeviceStatusUsed`, `DeviceStatusExpired`, `DeviceStatusRevoked`
|
||||
|
||||
Permission `golem15.users.reset_two_factor`; record action `reset_two_factor`.
|
||||
|
||||
New config keys: `golem15.user.device_auth.auth_url` (default `{frontend_url}/device/scan/{token}`), `golem15.user.device_auth.ttl_minutes` (default 5). The existing `golem15.user.frontend_url` is reused.
|
||||
|
||||
## Tests
|
||||
|
||||
The full sm-user-plugin suite passed with `-short` and without it (Docker ran; no Docker-backed test was NOT RUN).
|
||||
|
||||
- New: TestLoginGatesSmoke, TestLoginGateSmoke (5 sub), TestPasswordChangedEventSmoke (5 sub), TestResetTwoFactorSlotSmoke, TestDeviceCodesSmoke, TestDeviceFlowSmoke, TestDeviceRevokeSmoke (3 sub).
|
||||
- Unchanged and green: TestLogin, TestRefresh, TestLogout, TestAdminUserActions, TestAdminUserPassword, TestAdminRegistration.
|
||||
- Downstream builds: fonoteka.go, sm-sociallogin-plugin and sm-oauthserver-plugin build against the checkout.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug avoidance] D-07 reuses AccessRevokedEvent; no PasswordChangedEvent**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** All three password-write sites already fire `classes.AccessRevokedEvent` inside their transaction, with Reasons `password_reset`, `password_changed` and `password_set_by_admin`. A second event would duplicate it.
|
||||
- **Fix:** Added `(*AccessRevokedEvent).PasswordChanged()`. A listener error rolls the write back, and the login rehash fires nothing. The test keeps the name TestPasswordChangedEventSmoke. Task 2's greps for `PasswordChangedEvent` fail by design, but D-07 is met.
|
||||
- **Impact on plan 02:** use `Listen[*classes.AccessRevokedEvent]` and filter with `ev.PasswordChanged()`.
|
||||
- **Committed in:** `7900f47`
|
||||
|
||||
**2. [Rule 1 - Bug] Migration ID renamed to 202610260001_create_device_auth_sessions**
|
||||
- **Found during:** Task 3
|
||||
- **Issue:** The planned `202610210002` sorts before the existing `202610220001`, which breaks ordering.
|
||||
- **Fix:** Used `updates/202610260001_create_device_auth_sessions.go`.
|
||||
- **Committed in:** `4e3e5b0`
|
||||
|
||||
**3. [Rule 3 - Blocking] Config: frontend_url reused**
|
||||
- **Issue:** `golem15.user.frontend_url` / `classes.FrontendURL` already exist.
|
||||
- **Fix:** Reused them. The only new keys are `golem15.user.device_auth.auth_url` and `golem15.user.device_auth.ttl_minutes`.
|
||||
|
||||
**4. [Rule 3 - Blocking] sm-user-plugin checkout was detached at v0.1.10, behind origin**
|
||||
- **Fix:** Checked out master and fast-forwarded to `50da92c` (v0.1.11), which is the phase base.
|
||||
|
||||
**5. [Rule 3 - Blocking] Downstream build checks used a scratch go.work**
|
||||
- **Issue:** The sm-sociallogin-plugin checkout is owned by user `jin`, so go.work.sum is unwritable. sm-oauthserver-plugin's go.work points at sm-demo-app, which has another session's edit.
|
||||
- **Fix:** Built both through a scratch go.work. Neither repository was modified.
|
||||
|
||||
**6. [Rule 2 - Missing critical] Hardening**
|
||||
- Device rows record the client IP through `surf.ClientIP` with trusted proxies.
|
||||
- The bcrypt rehash runs before the gates and is `Unscoped()`.
|
||||
- `devices/authorize` reads only the body.
|
||||
- Hand-over refuses deleted, deactivated or banned users and marks the row revoked.
|
||||
- A row that has already expired answers with PHP's flat expired body.
|
||||
- `ShortCode` is hidden in JSON.
|
||||
- Hand-over runs FinishLogin and fires LoginEvent (Source device).
|
||||
- A shared `sessionTTL` helper is added.
|
||||
- **Committed in:** `4e3e5b0`, `3b22134`
|
||||
|
||||
**7. [Rule 1 - Bug] Pinned tests updated for additive items**
|
||||
- TestAdminRegistration and TestAdminUsersTracer (permission catalogue), TestAdminUserActions (record actions), TestAdminUsersControllerGuards, TestPasswordPublicRoutes (23 to 28 routes), and four migration-count tests in `updates/`.
|
||||
- **Committed in:** the task commits
|
||||
|
||||
**8. Separate style commit**
|
||||
- `3d4c8d2`: gofmt of the login gate smoke test.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 8 (naming/reuse 3, environment 2, hardening 1, pinned tests 1, style 1)
|
||||
**Impact on plan:** All changes are additive and keep the plan's decisions. Plan 02 must use the AccessRevokedEvent route for D-07 and the new migration ID.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None beyond the environment items in Deviations 4 and 5.
|
||||
|
||||
## g15office
|
||||
|
||||
This session posted no comment on milestone task `avoroeb4`; the orchestrator will post it.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 02 can create sm-mfa-plugin, install the three approved libraries there, register a LoginGate, listen on `*classes.AccessRevokedEvent` with `PasswordChanged()`, and publish `classes.TwoFactorAdmin`.
|
||||
- sm-user-plugin changes are local commits (`8501f34`..`3b22134`), not pushed or tagged. Plan 03 asks for the go-ahead.
|
||||
|
||||
---
|
||||
*Phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin*
|
||||
*Completed: 2026-10-26*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
All seven commits (24d9d2a; sm-user-plugin 50da92c base, 8501f34, 7900f47, 3d4c8d2, 4e3e5b0, 3b22134) and the created files listed above exist.
|
||||
@@ -0,0 +1,369 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
plan: 02
|
||||
subsystem: auth
|
||||
tags: [sm-mfa-plugin, 2fa, totp, pquerna-otp, boombuler-barcode, qr-svg, recovery-codes, email-codes, trusted-devices, login-gate, cabana-settings, gormigrate]
|
||||
|
||||
requires:
|
||||
- phase: 19.6-01
|
||||
provides: sm-user-plugin login-gate registry (classes.LoginGates), FinishLogin/IssueToken/APIArray/FireLoginEvent, AccessRevokedEvent.PasswordChanged(), TwoFactorAdmin slot, approved library pins
|
||||
provides:
|
||||
- New local repository ../sm-mfa-plugin (module git.golem15.com/golem15/sm-mfa-plugin, package mfa, plugin golem15.mfa), no remote
|
||||
- Login gate that answers PHP's {two_factor_required, challenge_token, available_methods, expires_at} for users with an enabled method
|
||||
- Challenge routes /_user/api/v1/2fa/{verify,recovery,email/send} behind the 2fa-verify bucket (10/min per IP)
|
||||
- Management routes status, totp/setup|confirm, DELETE totp, email/enable, DELETE email, recovery-codes (count, regenerate), trusted-devices (revoke one, revoke all)
|
||||
- TOTP with SVG QR code, per-step replay refusal; recovery codes; email codes (A8, A9); per-user failure cap (A6); trusted devices (D-10) revoked on password change (D-07)
|
||||
- Settings screen mfa (golem15_mfa_settings) applied per request; classes.Admin published as userclasses.TwoFactorAdmin (D-15)
|
||||
- Five migrations 202610220001..202610220005
|
||||
affects: [19.6-03, 19.6-04, sm-demo-app, sm-bm-app, vue-demo-app, sm-sociallogin-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 52122 # chars/4 over every tracked file of ../sm-mfa-plugin except go.sum (208487 chars); go.sum adds 45100 chars
|
||||
tasks: 3
|
||||
commits: 0 # MEASURED in summercms.go: git rev-list --count 33920ed..33920ed (all code lives in ../sm-mfa-plugin)
|
||||
sm_mfa_plugin_commits: 3 # MEASURED: git -C ../sm-mfa-plugin rev-list --count HEAD (5c6ad2f, 43d983b, 8a63f6f)
|
||||
plan_head_before: 33920ed558f19cda2b380340033b5fb95848dcb9
|
||||
plan_head_after: 33920ed558f19cda2b380340033b5fb95848dcb9
|
||||
sm_mfa_plugin_head_before: "(new repository)"
|
||||
sm_mfa_plugin_head_after: 8a63f6f
|
||||
sm_user_plugin_head: 3b22134 # unchanged by this plan
|
||||
|
||||
tech-stack:
|
||||
added:
|
||||
- "github.com/pquerna/otp v1.5.0 (totp, hotp), sm-mfa-plugin only"
|
||||
- "github.com/boombuler/barcode v1.1.0 (qr), sm-mfa-plugin only"
|
||||
patterns:
|
||||
- "Guarded single-statement transitions for attempts, completion, TOTP step acceptance, recovery-code consumption and email sends"
|
||||
- "Per-request effective configuration: config defaults overlaid by a nullable settings singleton"
|
||||
- "Mail capture in tests through postcard's log driver and a published *slog.Logger"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-mfa-plugin/plugin.go
|
||||
- ../sm-mfa-plugin/routes.go
|
||||
- ../sm-mfa-plugin/buckets.go
|
||||
- ../sm-mfa-plugin/mail.go
|
||||
- ../sm-mfa-plugin/admin_settings.go
|
||||
- ../sm-mfa-plugin/admin_permissions.go
|
||||
- ../sm-mfa-plugin/config/config.yaml
|
||||
- ../sm-mfa-plugin/classes/config.go
|
||||
- ../sm-mfa-plugin/classes/gate.go
|
||||
- ../sm-mfa-plugin/classes/challenge.go
|
||||
- ../sm-mfa-plugin/classes/login.go
|
||||
- ../sm-mfa-plugin/classes/totp.go
|
||||
- ../sm-mfa-plugin/classes/qr.go
|
||||
- ../sm-mfa-plugin/classes/recovery.go
|
||||
- ../sm-mfa-plugin/classes/email.go
|
||||
- ../sm-mfa-plugin/classes/trusted.go
|
||||
- ../sm-mfa-plugin/classes/methods.go
|
||||
- ../sm-mfa-plugin/classes/events.go
|
||||
- ../sm-mfa-plugin/classes/admin.go
|
||||
- ../sm-mfa-plugin/controllers/helpers.go
|
||||
- ../sm-mfa-plugin/controllers/challenge.go
|
||||
- ../sm-mfa-plugin/controllers/management.go
|
||||
- ../sm-mfa-plugin/models/ (registry, json_map, string_list, two_factor_method, two_factor_challenge, two_factor_recovery_code, trusted_device, settings, settings/fields.yaml)
|
||||
- ../sm-mfa-plugin/updates/ (registry and 202610220001..202610220005)
|
||||
- ../sm-mfa-plugin/views/mail/two_factor_code.htm
|
||||
- ../sm-mfa-plugin/views/mail/two_factor_code-en.htm
|
||||
- ../sm-mfa-plugin/testmain_test.go
|
||||
- ../sm-mfa-plugin/harness_test.go
|
||||
- ../sm-mfa-plugin/tracer_smoke_test.go
|
||||
- ../sm-mfa-plugin/challenge_smoke_test.go
|
||||
- ../sm-mfa-plugin/trusted_settings_smoke_test.go
|
||||
- ../sm-mfa-plugin/README.md
|
||||
modified: []
|
||||
|
||||
key-decisions:
|
||||
- "D-07 listener is Listen[*userclasses.AccessRevokedEvent] filtered by ev.PasswordChanged(), deleting trusted devices of ev.UserIDs on ev.Tx (plan 01 has no PasswordChangedEvent)."
|
||||
- "The failure cap does not count the caller's own in-flight attempt (FailureCapReached inFlight=1 in verify routes, 0 at the gate and email/send), so the 10th failure, not the 9th, closes the window."
|
||||
- "TOTP step acceptance is a guarded UPDATE inside the completion transaction, so two challenges racing with one code accept it once."
|
||||
- "sm-mfa-plugin go.mod requires sm-user-plugin v0.1.11 and summercms v0.5.0; go.work replaces the user plugin with ../fonoteka.go/plugins/golem15/user (3b22134). Plan 03 moves the require to the released tag."
|
||||
- "Migration IDs 202610220001..202610220005 in golem15.mfa's own history table; 202610220006 stays reserved for plan 03's WebAuthn credentials."
|
||||
|
||||
patterns-established:
|
||||
- "Second-factor routes: attempt() counts the attempt, resolves the user and checks the cap; completeSignIn() completes in one transaction, then mints through golem15.user and adds trusted_device_token"
|
||||
- "Settings overlay: NULL column = config default; stored unknown mode behaves as optional"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-4, D-01, D-04, D-05, D-06, D-07, D-09, D-10, D-12, D-13, D-15, D-16, D-18, D-19]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "TOTP tracer: setup with 200x200 SVG QR (matrix-exact), confirm stores ciphertext, password login answers the challenge with a SHA-256 token column, code completes once, replay refused, PHP 422 shape, 11th request from one IP is 429"
|
||||
requirement: "SC-2"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-mfa-plugin/tracer_smoke_test.go#TestQRSVGSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-mfa-plugin/tracer_smoke_test.go#TestTracerSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Recovery codes (first set shown once, bcrypt, single use, count behind password, regenerate), email codes only for enabled users with 3-send cap and capped expiry in the rendered -en mail, five attempts, one token from 20 parallel verifies, per-user failure cap and window, last-method cleanup"
|
||||
requirement: "D-18"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-mfa-plugin/challenge_smoke_test.go#TestChallengeSmoke (9 subtests)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Trusted devices (hash, device name, skip, foreign/expired refused, revoke routes, off by setting), revocation on password change with rollback, settings saved through the admin API applying per request, social toggle, allow-lists, status keys and Carbon dates, published admin reset"
|
||||
requirement: "D-12"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-mfa-plugin/trusted_settings_smoke_test.go#TestTrustedSettingsSmoke (9 subtests)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Settings screen renders and is usable in the backend admin SPA (labels, tabs, dropdown empty choice, taglists)"
|
||||
requirement: "D-12"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "TestTrustedSettingsSmoke/settings_row_applies and allow_lists (PUT /settings/mfa through the admin API)"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "The API save path is tested; how the form looks and reads in the SPA is a visual judgement no test asserts."
|
||||
|
||||
duration: 25min
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6 Plan 02: sm-mfa-plugin core Summary
|
||||
|
||||
**New plugin golem15.mfa (../sm-mfa-plugin, three local commits): a login gate that answers PHP's two_factor_required challenge, TOTP via pquerna/otp with an SVG QR from boombuler/barcode and per-step replay refusal, recovery and email codes with the D-18 hardening, trusted devices revoked on any password change, a per-request settings screen and the TwoFactorAdmin reset service.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 25 min
|
||||
- **Started:** 2026-10-26T09:54:22Z
|
||||
- **Completed:** 2026-10-26T10:19Z
|
||||
- **Tasks:** 3 (one tracer, two expansions)
|
||||
- **Files:** 47 tracked files in the new repository; none changed in summercms.go or sm-user-plugin
|
||||
|
||||
## Base commits
|
||||
|
||||
- **sm-mfa-plugin** (`../sm-mfa-plugin`): new repository, branch master, no remote. HEAD `8a63f6f`.
|
||||
- **sm-user-plugin** (`../fonoteka.go/plugins/golem15/user`): unchanged at `3b22134`.
|
||||
- **summercms.go**: base `33920ed`; this plan's only commits here are the planning docs.
|
||||
|
||||
## Task Commits
|
||||
|
||||
| # | Repository | Commit | Message |
|
||||
|---|------------|--------|---------|
|
||||
| 1 (tracer) | sm-mfa-plugin | `5c6ad2f` | feat: TOTP second factor through the login gate |
|
||||
| 2 | sm-mfa-plugin | `43d983b` | feat: recovery codes, email codes and the per-user failure cap |
|
||||
| 3 | sm-mfa-plugin | `8a63f6f` | feat: trusted devices, the settings screen and the admin reset service |
|
||||
|
||||
Nothing was pushed or tagged and no remote was created. The tracer feedback gate (interactive, end-of-phase, automated-only verify) re-ran both verify commands green before Task 2.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Plugin skeleton (D-01).** `golem15.mfa` requires `golem15.user`. Boot needs no database: it validates config, adds `&classes.Gate{}` to `*userclasses.LoginGates`, publishes `userclasses.TwoFactorAdmin` and registers the password-change listener. Only sm-mfa-plugin's go.mod requires pquerna/otp v1.5.0 and boombuler/barcode v1.1.0, and the archived YAML v3 module is not in `go list -deps`.
|
||||
- **Challenge (SC-2, D-05, D-06).** The token is 64 characters from crypto/rand and only its SHA-256 hex is stored. TTL is `two_factor_challenge_ttl`. Every verify counts an attempt in one guarded UPDATE (five real attempts, recorded A5), and a second guarded UPDATE completes the challenge, so at most one token is minted. Completion mints through golem15.user (`FinishLogin`, which restores a deactivated account only now, then `IssueToken`, `APIArray` and the login event with source `two_factor`), then fires `golem15.user.2fa.verified`. It honours `golem15.user.jwt.token_cookie`.
|
||||
- **TOTP (D-04).** Setup answers `{secret, qr_code_svg, qr_code_url}`; the QR is level M with a 4-module quiet zone, 200x200 px with a `viewBox`. Confirm stores the secret as `lagoon.Encrypted` with `last_counter`. Verify uses a one-step window, and accepting a step is a guarded UPDATE, so a code works once.
|
||||
- **Recovery codes (D-05, D-19).** Sets of 10 `XXXXX-XXXXX` codes are stored as bcrypt and consumed by a guarded UPDATE. The first set is returned by `totp/confirm` and `email/enable`. Listing gives only the count and needs the password; regenerate replaces the set in one transaction.
|
||||
- **Email codes (D-18 A8, A9).** Six digits, stored as bcrypt and mailed as `golem15.mfa::mail.two_factor_code` (pl) or `-en`. Only users with the email method enabled get one, at most 3 per challenge. The mail promises `min(email TTL, remaining challenge minutes)`.
|
||||
- **Failure cap (D-18 A6).** 10 failures in 15 minutes per user, counted from challenge rows. While the cap holds, the gate answers 401 `{"error":"Invalid or expired challenge."}` and creates no row, and every challenge route answers its generic 401. Failed rows are kept for the window.
|
||||
- **Trusted devices (D-10, D-07).** The token is stored as SHA-256 hex, with PHP's "{browser} on {os}" name and a 30-day TTL, off by default. A valid `trusted_device_token` in the login body skips the challenge; social sign-ins carry no fields and are never skipped. Devices are revoked by any password change (inside the write's transaction, so a failure rolls it back), by disabling the last method, and through the two revoke routes.
|
||||
- **Settings (D-12, D-13, D-09).** Screen `mfa` (permission `golem15.mfa.access_settings`, developer role) has a dropdown mode, array taglists with allow-lists, numbers and switches. A NULL column means the config value, and saved values apply on the next request. Only mode `disabled` exempts users. Social sign-ins are challenged only with `two_factor_social_login` on.
|
||||
- **Status.** `status` returns PHP's full shape. `trusted_devices` dates use Carbon's raw JSON form, and `webauthn_credentials` stays `[]` until plan 03.
|
||||
- **Admin reset (D-15).** `classes.Admin.Reset` disables every method and clears its secret and metadata, deletes recovery codes and trusted devices, and fires `golem15.user.2fa.disabled` with method `all`, all on cabana's transaction.
|
||||
|
||||
## Exported identifiers, config keys and migration IDs (for plans 03 and 04)
|
||||
|
||||
Package `mfa`:
|
||||
- `PluginID` (`golem15.mfa`), `Plugin`
|
||||
- `BucketTwoFactorVerify` (`2fa-verify`), `SettingsCode` (`mfa`), `PermissionAccessSettings` (`golem15.mfa.access_settings`)
|
||||
|
||||
Package `classes`:
|
||||
- Config:
|
||||
- `Config`, `LoadConfig`, `Effective` (struct embedding `Config`; `MethodAvailable`, `ChallengeDuration`), `LoadEffective(ctx, app, db)`
|
||||
- `ConfigPrefix`, `KnownMethods`, `KnownModes`, `DefaultAvailableMethods`, `DefaultMode`, `DefaultEmailCodeTTL`, `DefaultChallengeTTL`, `DefaultTrustedDeviceTTLDays`, `DefaultFailureCapMax`, `DefaultFailureCapWindow`, `DefaultIssuer`
|
||||
- Gate: `Gate{App}`, `Database(app)`, `ClientIP(app, r)`
|
||||
- Challenge:
|
||||
- `NewChallengeToken`, `HashToken`
|
||||
- `CreateChallenge(ctx, db, user, ip, ua, ttl, keep)`, `FindChallenge`, `BeginAttempt`, `CompleteChallenge`
|
||||
- `FailureCount`, `FailureCapReached(ctx, db, eff, userID, now, inFlight)`
|
||||
- `ErrInvalidChallenge`, `ChallengeTokenLength`, `MaxAttempts`
|
||||
- TOTP and QR:
|
||||
- `NewTOTPSecret`, `TOTPURL`, `NormalizeTOTPSecret`, `TOTPCounter`, `VerifyTOTP`, `TOTPPeriod`, `TOTPWindow`
|
||||
- `QRSVG(text, size)`
|
||||
- Recovery codes:
|
||||
- `RecoveryCodeAlphabet`, `RecoveryCodeCount`, `MaxRecoveryCodeLength`, `BcryptCost`
|
||||
- `NewRecoveryCode`, `GenerateRecoveryCodes`, `EnsureRecoveryCodes`, `NormalizeRecoveryCode`
|
||||
- `MatchRecoveryCode`, `MarkRecoveryCodeUsed`, `ConsumeRecoveryCode`, `RemainingRecoveryCodes`, `DeleteRecoveryCodes`
|
||||
- Email codes:
|
||||
- `EmailCodeTemplate`, `MaxEmailSends`
|
||||
- `NewEmailCode`, `MaskEmail`, `SendEmailCode(ctx, app, db, eff, ch, user)`, `EmailCodeMinutes`, `VerifyEmailCode`
|
||||
- Trusted devices:
|
||||
- `UnknownDevice`, `ParseDeviceName`
|
||||
- `IssueTrustedDevice`, `CheckTrustedDevice`, `RevokeTrustedDevices(ctx, tx, userIDs...)`, `RevokeTrustedDevice`, `TrustedDeviceList`
|
||||
- Methods and status:
|
||||
- `EnabledMethods`, `MethodRow`, `MethodEnabled`, `EnableMethod`, `DisableMethod(ctx, app, tx, user, method)`
|
||||
- `AcceptTOTPCounter`, `TouchMethod`, `LastCounter`
|
||||
- `Enabled`, `Enforced`, `Status`
|
||||
- Login: `CompleteLogin`, `ChallengeUser`
|
||||
- Admin and listener: `Admin` (TwoFactorAdmin), `OnAccessRevoked(app)`
|
||||
- Events:
|
||||
- `ChallengedEvent`, `FailedEvent`, `VerifiedEvent`, `RecoveryUsedEvent`, `EnabledEvent`, `DisabledEvent`, `RecoveryRegeneratedEvent`
|
||||
- Names: `ChallengedEventName`, `FailedEventName`, `RecoveryUsedEventName`, `VerifiedEventName`, `EnabledEventName`, `DisabledEventName`, `RecoveryRegeneratedEventName`
|
||||
- `MethodAll`, `Fire`
|
||||
|
||||
Package `controllers`:
|
||||
- Challenge routes: `Verify`, `Recovery`, `EmailSend`
|
||||
- Management routes: `Status`, `TOTPSetup`, `TOTPConfirm`, `TOTPDisable`, `EmailEnable`, `EmailDisable`, `RecoveryCodesCount`, `RecoveryCodesRegenerate`, `TrustedDeviceRevoke`, `TrustedDevicesRevokeAll`
|
||||
- `QRSize`
|
||||
- Unexported helpers plan 03 reuses inside the package: `attempt`, `completeSignIn`, `withTrustedDevice`, `signedIn`, `validate`
|
||||
|
||||
Package `models`:
|
||||
- `TwoFactorMethod`, `TwoFactorChallenge`, `TwoFactorRecoveryCode`, `TrustedDevice`, `Settings`, `LoadSettings`, `SettingsMethods`, `StringList`, `JSONMap`
|
||||
- `MethodTOTP`, `MethodEmail`, `MethodWebAuthn`, `MethodRecovery`, `ModeDisabled`, `ModeOptional`, `ModeEnforced`, `LangPrefix`
|
||||
|
||||
Config keys (`golem15.mfa.*`, env `SUMMER_GOLEM15__MFA__...`):
|
||||
- `two_factor_mode` (optional), `two_factor_available_methods` ([totp, email]), `two_factor_enforce_groups` ([])
|
||||
- `two_factor_email_code_ttl` (10), `two_factor_challenge_ttl` (5)
|
||||
- `two_factor_passwordless_login` (false)
|
||||
- `trusted_device_enabled` (false), `trusted_device_ttl_days` (30)
|
||||
- `two_factor_social_login` (false)
|
||||
- `issuer` (app.name)
|
||||
- `failure_cap.max` (10), `failure_cap.window_minutes` (15)
|
||||
|
||||
Migrations (golem15.mfa history):
|
||||
- `202610220001_create_golem15_user_two_factor_methods`
|
||||
- `202610220002_create_golem15_user_two_factor_challenges`
|
||||
- `202610220003_create_golem15_user_two_factor_recovery_codes`
|
||||
- `202610220004_create_golem15_user_trusted_devices`
|
||||
- `202610220005_create_golem15_mfa_settings`
|
||||
- Plan 03 takes `202610220006` for WebAuthn credentials.
|
||||
|
||||
Routes:
|
||||
- Challenge (`throttle:2fa-verify`): `POST /_user/api/v1/2fa/{verify,recovery,email/send}`
|
||||
- Management (`throttle:user-api` plus `jwt.auth` per route): `GET status`, `POST totp/setup`, `POST totp/confirm`, `DELETE totp`, `POST email/enable`, `DELETE email`, `GET recovery-codes`, `POST recovery-codes/regenerate`, `DELETE trusted-devices/{id}` (digits), `DELETE trusted-devices`
|
||||
|
||||
Mail templates: `golem15.mfa::mail.two_factor_code`, `golem15.mfa::mail.two_factor_code-en`.
|
||||
|
||||
## Tests
|
||||
|
||||
All Docker-backed tests ran against testcontainers Postgres. None were NOT RUN.
|
||||
|
||||
- `go vet ./...` and `go test -count=1 -short ./...`: green at every commit.
|
||||
- `TestQRSVGSmoke` (short): pass.
|
||||
- `TestTracerSmoke`: pass.
|
||||
- `TestChallengeSmoke`, 9 subtests, all pass: `recovery_first_set`, `recovery_once`, `regenerate`, `email_only_when_enabled`, `email_send_cap`, `five_attempts`, `parallel_verify`, `failure_cap`, `disable_last_method`.
|
||||
- `TestTrustedSettingsSmoke`, 9 subtests, all pass: `trusted_skip`, `revoke_routes` (added), `trusted_disabled`, `password_change_revokes`, `settings_row_applies`, `social_toggle`, `allow_lists`, `status_shape`, `admin_reset`.
|
||||
- Full `go test -count=1 ./...` on the final commit: ok.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See key-decisions in the frontmatter. In addition:
|
||||
- `Effective` is a struct embedding `Config`, so plan 03 can add fields without changing `LoadEffective`'s signature.
|
||||
- The mode dropdown's empty choice, "Server configuration", stores NULL.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] The parent directory is not writable by golem**
|
||||
- **Found during:** Task 1 (`git init ../sm-mfa-plugin`)
|
||||
- **Issue:** `summercms.io/summercms` is owned by `jin` (0775, golem not in the group).
|
||||
- **Fix:** Created only `sm-mfa-plugin` with `sudo -n install -d -o golem -g golem -m 0775`, then ran `git init -b master` as golem. The golem-owned siblings sm-oauthserver-plugin and sm-journal-plugin are the precedent. Nothing else was created or changed with sudo.
|
||||
|
||||
**2. [Plan 01 carry-forward - D-07] Listener on AccessRevokedEvent, not PasswordChangedEvent**
|
||||
- **Found during:** Task 3
|
||||
- **Fix:** `app.Events.Listen[*userclasses.AccessRevokedEvent](PluginID, classes.OnAccessRevoked(app))`, which skips events where `PasswordChanged()` is false and deletes the trusted devices of `ev.UserIDs` on `ev.Tx`.
|
||||
- **Acceptance impact:** The Task 3 grep for `Listen[*userclasses.PasswordChangedEvent]` prints 0 by design. `TestTrustedSettingsSmoke/password_change_revokes` proves D-07, including the rollback.
|
||||
- **Commit:** `8a63f6f`
|
||||
|
||||
**3. [Rule 3 - Blocking] go.mod versions**
|
||||
- **Issue:** The plan named sm-user-plugin v0.1.5, which predates every seam.
|
||||
- **Fix:** go.mod requires `sm-user-plugin v0.1.11` (the phase base) and `summercms v0.5.0` (what sm-user-plugin requires), with go.mod `replace summercms => ../summercms.go` as sociallogin has. go.work replaces both with the local checkouts. Plan 03 bumps the user plugin to the released tag.
|
||||
- **Commit:** `5c6ad2f`
|
||||
|
||||
**4. [Rule 1 - Race] TOTP replay guarded atomically**
|
||||
- **Issue:** The plan stored `last_counter` in the completion transaction. Two challenges verifying the same code in parallel could both read the old counter.
|
||||
- **Fix:** `AcceptTOTPCounter` is a guarded `UPDATE … WHERE last_counter < ?` in the completion transaction. Losing it rolls the completion back and answers the failure 401.
|
||||
- **Commit:** `5c6ad2f`
|
||||
|
||||
**5. [Rule 2 - Security] Availability check on totp/confirm**
|
||||
- **Issue:** PHP checked availability only on setup, so a self-made secret bypassed the 403.
|
||||
- **Fix:** `totp/confirm` also answers 403 `{"error":"TOTP is not available."}`.
|
||||
- **Commit:** `5c6ad2f`
|
||||
|
||||
**6. [Rule 2 - Correctness] Completed challenges honour token_cookie**
|
||||
- **Fix:** A completed challenge honours `golem15.user.jwt.token_cookie` as `/login` does: the cookie is set and `token` is left out of the body.
|
||||
- **Commit:** `5c6ad2f`
|
||||
|
||||
**7. [Rule 2 - Correctness] The gate needs a usable method**
|
||||
- **Issue:** PHP challenged on any enabled row, including webauthn without credentials, which gives a challenge nobody can answer.
|
||||
- **Fix:** The gate challenges only when the filtered method list is non-empty. `status.enabled` and `status.methods` keep PHP's raw-row semantics.
|
||||
- **Commit:** `5c6ad2f`, `8a63f6f`
|
||||
|
||||
**8. [Rule 1 - Correctness] The failure cap ignores the in-flight attempt**
|
||||
- **Fix:** `FailureCapReached(ctx, db, eff, userID, now, inFlight)`. The verify routes pass 1, because their own just-counted attempt is not yet a failure; the gate and email/send pass 0. Without this, a correct code after 9 failures would be refused.
|
||||
- **Signature changes:** `CreateChallenge` gained `keep` (the prune horizon). `SendEmailCode` takes `eff`.
|
||||
- **Recovery split:** `MatchRecoveryCode` (the bcrypt compares, outside the transaction) and `MarkRecoveryCodeUsed` (guarded, inside the completion transaction); `ConsumeRecoveryCode` is kept as the combined helper. Long bcrypt loops therefore hold no row lock.
|
||||
- **Commit:** `43d983b`
|
||||
|
||||
**9. [Rule 1 - Bug] Carbon dates at second precision**
|
||||
- **Issue:** Postgres keeps microseconds, while PHP's columns had none.
|
||||
- **Fix:** `trusted_devices` dates are truncated to the second, so they read `….000000Z`.
|
||||
- **Commit:** `8a63f6f`
|
||||
|
||||
**10. [Rule 3 - Test harness] Mail capture through the log driver**
|
||||
- **Issue:** party.Activate publishes `postcard.Mailer`, and it cannot be published twice.
|
||||
- **Fix:** The harness boots with `mail.driver: log` and publishes a capturing `*slog.Logger`, so tests read the rendered subject and text. This also checks template rendering.
|
||||
- **Other harness changes:** `bootMFA` returns `*mfaEnv` rather than `(app, server)`, and the harness sets `golem15.user.password.bcrypt_cost: 4`.
|
||||
|
||||
**11. [Scope] Admin.HasTwoFactor is broader**
|
||||
- **Fix:** It is true for an enabled method, a recovery code or a trusted device, as the user plugin's `TwoFactorAdmin` doc defines it. The plan said only an enabled method.
|
||||
|
||||
**12. [Scope] No `golem15.mfa::lang.mail.*` keys**
|
||||
- **Reason:** The templates carry their subject and body, as golem15.user's mails do, so mail lang keys would be unused. The `settings.*`, `permissions.*` and `plugin.*` keys exist in en and pl.
|
||||
|
||||
**13. [Rule 2 - Hardening] Smaller additions**
|
||||
- The email-send guarded UPDATE also requires `attempts < max_attempts`.
|
||||
- A challenge or trusted token that is not 64 characters is refused before any query.
|
||||
- Tests added beyond the plan: `revoke_routes`, the 422 shape check in the tracer, and the settings save through the admin API.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 13: environment 1, carry-forward 1, versions 1, race and security fixes 4, correctness 3, harness 1, scope 2.
|
||||
**Impact on plan:** Every must-have truth holds. Only the D-07 listener grep fails, and it fails by design; no locked CONTEXT decision changed.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
- `classes/methods.go` `Status`: `webauthn_credentials` is always `[]`, and `EnabledMethods` never lists `webauthn`. Plan 03 adds the credential table (migration 202610220006) and fills both in. Intentional.
|
||||
- `classes/admin.go` `Reset`: it does not yet delete WebAuthn credentials, because the table does not exist yet. Plan 03 adds that deletion.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. Every new surface (challenge and management routes, settings screen, reset service, password-change listener) is in the plan's threat register.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None beyond Deviation 1.
|
||||
|
||||
## g15office
|
||||
|
||||
This executor has no g15office tool, so it posted no comment on milestone task `avoroeb4`. The orchestrator should post the plan 02 update.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 03 can add WebAuthn inside sm-mfa-plugin:
|
||||
- Migration `202610220006`.
|
||||
- The webauthn verify and options routes in the challenge group, reusing `attempt`, `completeSignIn` and `withTrustedDevice`.
|
||||
- `status.webauthn_credentials`, the `EnabledMethods` credential check, and WebAuthn deletion in `Admin.Reset`.
|
||||
- The passwordless routes, gated by `two_factor_passwordless_login`.
|
||||
- Plan 03 still needs the user's go-ahead to create the remote and push sm-mfa-plugin and sm-user-plugin.
|
||||
- STATE.md already held uncommitted 19.6 hunks from another session or the orchestrator when this plan started. This plan ran the state handlers on top of them, but committed only SUMMARY.md and ROADMAP.md.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- All key files exist in ../sm-mfa-plugin.
|
||||
- Commits 5c6ad2f, 43d983b and 8a63f6f exist there; the working tree is clean and there is no remote.
|
||||
- The final full test run was green.
|
||||
@@ -0,0 +1,572 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
plan: 03
|
||||
subsystem: auth
|
||||
tags: [sm-mfa-plugin, webauthn, go-webauthn, passkeys, passwordless, sm-sociallogin-plugin, login-gate, vue-demo-app, totp-ui, release, sm-demo-app, sm-bm-app]
|
||||
|
||||
requires:
|
||||
- phase: 19.6-01
|
||||
provides: sm-user-plugin login gates (CheckLoginGates, LoginSourceSocial, LoginSourcePasskey), FinishLogin/IssueToken/APIArray/FireLoginEvent, RejectIfThrottled, ThrottleStates
|
||||
- phase: 19.6-02
|
||||
provides: sm-mfa-plugin core (challenge store, attempt/completeSignIn/withTrustedDevice, EnableMethod/DisableMethod, EnsureRecoveryCodes, Status, Admin, migration slot 202610220006)
|
||||
provides:
|
||||
- WebAuthn security keys as a second factor in sm-mfa-plugin (go-webauthn v0.18.2, standard base64url shapes, D-08)
|
||||
- golem15_user_webauthn_credentials (migration 202610220006) with credential_data and passwordless
|
||||
- Passwordless passkey sign-in behind two_factor_passwordless_login (D-14)
|
||||
- D-09 social-login gate in sm-sociallogin-plugin v0.1.4
|
||||
- Demo two-factor UI in vue-demo-app (TOTP setup, recovery codes, disable, login challenge; D-20), pushed
|
||||
- Releases: sm-user-plugin v0.1.12, sm-mfa-plugin v0.1.0 (new private repository), sm-sociallogin-plugin v0.1.4
|
||||
- sm-demo-app mounts golem15.mfa v0.1.0 at user v0.1.12, sociallogin v0.1.4 and the two-factor UI, pushed (not deployed)
|
||||
- sm-bm-app mounts golem15.mfa (API only) at user v0.1.12 and sociallogin v0.1.4, pushed
|
||||
- fonoteka.go at sm-user-plugin v0.1.12 with its guard tests updated (local commit)
|
||||
affects: [19.6-04, sm-demo-app, sm-bm-app, fonoteka.go, vue-demo-app, sm-sociallogin-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 38817 # MEASURED chars/4 over added lines: 37360 at the draft (Tasks 1-3, 33ad164, b752177, sm-bm-app aafbcce..ebb2266, fonoteka.go 06bc9d0..95fd58a) plus sm-demo-app 40ed518..bb24207 (5827 chars); go.sum and go.work.sum excluded
|
||||
tasks: 6
|
||||
commits: 2 # MEASURED in summercms.go before this final commit: git rev-list --count 5d78f53..HEAD (5a64611, 4002bea); this SUMMARY commit and the ROADMAP commit follow. Code lives in other repositories (below)
|
||||
sm_mfa_plugin_commits: 3 # MEASURED: git -C ../sm-mfa-plugin rev-list --count 8a63f6f..HEAD
|
||||
sm_sociallogin_plugin_commits: 2 # MEASURED: git -C ../sm-sociallogin-plugin rev-list --count 4d3b2dd..HEAD
|
||||
vue_demo_app_commits: 1 # MEASURED: git -C ../sm-demo-app/vue-demo-app rev-list --count 9c247ab..HEAD
|
||||
sm_bm_app_commits: 3 # MEASURED: git -C ../sm-bm-app rev-list --count aafbcce..HEAD
|
||||
fonoteka_go_commits: 1 # MEASURED: git -C ../fonoteka.go rev-list --count 06bc9d0..HEAD
|
||||
sm_demo_app_commits: 4 # MEASURED: git -C ../sm-demo-app rev-list --count 40ed518..bb24207
|
||||
plan_head_before: 5d78f53ddc890ef53fe52da1828f3f88d9923270
|
||||
plan_head_after: 4002bea
|
||||
sm_mfa_plugin_head_before: 8a63f6f
|
||||
sm_mfa_plugin_head_after: 33ad164
|
||||
sm_sociallogin_plugin_head_before: 4d3b2dd
|
||||
sm_sociallogin_plugin_head_after: b752177
|
||||
vue_demo_app_head_before: 9c247ab
|
||||
vue_demo_app_head_after: 44a5229
|
||||
sm_bm_app_head_before: aafbcce
|
||||
sm_bm_app_head_after: ebb2266
|
||||
fonoteka_go_head_before: 06bc9d0
|
||||
fonoteka_go_head_after: 95fd58a
|
||||
sm_demo_app_head_before: 40ed518
|
||||
sm_demo_app_head_after: bb24207
|
||||
sm_user_plugin_head: 3b22134 # tagged v0.1.12 and pushed
|
||||
|
||||
tech-stack:
|
||||
added:
|
||||
- "github.com/go-webauthn/webauthn v0.18.2 (packages webauthn, protocol), sm-mfa-plugin only (approved 2026-10-26); brings fxamacker/cbor/v2, go-webauthn/x, google/go-tpm, tinylib/msgp as indirect modules (also indirect in sm-bm-app and sm-demo-app through the mount)"
|
||||
patterns:
|
||||
- "WebAuthn ceremony state server-side: registration and passkey state in cooler consumed with Pull; login state on the challenge row"
|
||||
- "Pure verification helpers (VerifyRegistration, VerifyAssertion) shared by handlers and a no-database smoke test"
|
||||
- "Virtual authenticator test helper (ECDSA P-256, attestation none, CBOR through go-webauthn's webauthncbor)"
|
||||
- "Application mount test without a database: route table entry with the owning plugin, a compiled handler, and an anonymous request refused by jwt.auth (TestMFAMounted in sm-bm-app and sm-demo-app)"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-mfa-plugin/classes/webauthn.go
|
||||
- ../sm-mfa-plugin/classes/passwordless.go
|
||||
- ../sm-mfa-plugin/controllers/webauthn.go
|
||||
- ../sm-mfa-plugin/controllers/passwordless.go
|
||||
- ../sm-mfa-plugin/models/webauthn_credential.go
|
||||
- ../sm-mfa-plugin/updates/202610220006_create_golem15_user_webauthn_credentials.go
|
||||
- ../sm-mfa-plugin/webauthn_authenticator_test.go
|
||||
- ../sm-mfa-plugin/webauthn_smoke_test.go
|
||||
- ../sm-mfa-plugin/passwordless_smoke_test.go
|
||||
- ../sm-mfa-plugin/go.work.sum
|
||||
- ../sm-sociallogin-plugin/social_gate_smoke_test.go
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/twoFactor.ts
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/twoFactor.test.ts
|
||||
- ../sm-demo-app/vue-demo-app/app/composables/useTwoFactor.ts
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/account/security.vue
|
||||
- ../sm-demo-app/mfa_test.go
|
||||
- ../sm-demo-app/config/golem15.mfa.yaml
|
||||
- ../sm-demo-app/plugins/golem15/mfa (submodule)
|
||||
- ../sm-bm-app/mfa_test.go
|
||||
- ../sm-bm-app/plugins/golem15/mfa (submodule)
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-03-sociallogin-gate.patch
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/deferred-items.md
|
||||
- .planning/todos/pending/2026-10-26-sm-demo-app-journal-oauthserver-pointers.md
|
||||
modified:
|
||||
- ../sm-mfa-plugin/{go.mod,go.sum,routes.go,plugin.go,README.md,config/config.yaml,lang/en/lang.yaml,lang/pl/lang.yaml}
|
||||
- ../sm-mfa-plugin/classes/{config.go,methods.go,admin.go,events.go,login.go}
|
||||
- ../sm-sociallogin-plugin/{classes/flow.go,classes/codes.go,controllers/callback.go,controllers/complete.go,controllers/register_complete.go,lang/en/lang.yaml,lang/pl/lang.yaml,README.md,go.mod,go.sum}
|
||||
- ../sm-demo-app/vue-demo-app/app/{composables/useDemoAuth.ts,pages/login.vue,components/SiteHeader.vue}
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/{en.json,pl.json}
|
||||
- ../sm-demo-app/{.gitmodules,go.mod,go.sum,go.work,summer.yaml,plugins.gen.go,boot_test.go,deploy/env.example,README.md,plugins/golem15/user,plugins/golem15/sociallogin,vue-demo-app}
|
||||
- ../sm-bm-app/{.gitmodules,go.mod,go.sum,go.work,summer.yaml,plugins.gen.go,scripts/build.sh,README.md,plugins/golem15/user,plugins/golem15/sociallogin}
|
||||
- ../fonoteka.go/{plugins/golem15/user,parity/migrate_test.go,parity/schema_diff_test.go,plugins/golem15/fonoteka/classes/hidden_marshal_test.go,plugins/golem15/fonoteka/phase07_coverage_test.go,plugins/golem15/fonoteka/routes_isolation_test.go}
|
||||
|
||||
key-decisions:
|
||||
- "WebAuthn RP from golem15.mfa.webauthn.rp_id / rp_name / origins (defaults: app.url host, app.name, app.url and golem15.user.frontend_url origins); an IP host or no origin makes WebAuthnFor answer ErrWebAuthnUnavailable, and the routes answer 403 'WebAuthn is not available.'"
|
||||
- "Assertion verification is split: FinishAssertion verifies outside the transaction, RecordAssertion writes the record back in the completing transaction with a guarded UPDATE on the old sign_count (a lost race refuses the login)"
|
||||
- "Registration answers 'Registration failed: <reason>' with fixed reasons: invalid or expired challenge, invalid response, verification failed, credential already registered"
|
||||
- "Passkey routes also answer 403 while two_factor_mode is disabled (fail closed), not only while two_factor_passwordless_login is off"
|
||||
- "Passkey sign-in refuses a ban or suspension from any address (ThrottleStates) and from the request's address (RejectIfThrottled)"
|
||||
- "A challenged social sign-in does not fire SignedInEvent and does not restore a deactivated account; the identity is stored before the gate"
|
||||
- "No framework tag: sm-mfa-plugin and sm-sociallogin-plugin pass against the framework's v0.5.0 tag; sociallogin's require rose from v0.3.1 to v0.5.0 through go mod tidy"
|
||||
- "Release tags: sm-user-plugin v0.1.12, sm-mfa-plugin v0.1.0, sm-sociallogin-plugin v0.1.4 (the plan's v0.1.6 and v0.1.3 were stale)"
|
||||
- "fonoteka.go guard tests follow the user plugin across every version the bump crosses (v0.1.10 to v0.1.12), not only this phase's additions, because they were already red at the committed v0.1.10 pointer"
|
||||
- "sm-demo-app's golem15.mfa config: two_factor_mode optional, methods [totp, email], social sign-ins unchallenged (the demo's OAuth callback page does not handle two_factor_required), webauthn not offered (no demo screens); RP defaults to the app.url host, which is demo.summercms.io in production"
|
||||
|
||||
patterns-established:
|
||||
- "Plugin work in a checkout the executor cannot write: implement and test in a scratch clone with a GOWORK file, export git format-patch, keep the patch in the phase directory, apply with git am once access is granted and verify the tree hash matches"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-4, D-01, D-02, D-04, D-05, D-06, D-08, D-09, D-10, D-14, D-16, D-17, D-19, D-20]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "WebAuthn second factor: register options (attestation none), register with PHP's answer and first recovery codes, single-use registration state, status list, login offering webauthn, verify before options refused, assertion completing the challenge with the sign count written back, clone refused, last key removal disabling the method, admin reset deleting keys, 403 while unavailable"
|
||||
requirement: "SC-1"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-mfa-plugin/webauthn_smoke_test.go#TestWebAuthnCeremonySmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-mfa-plugin/webauthn_smoke_test.go#TestWebAuthnSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Passwordless passkey sign-in: 403 while off, passkey signs in with one passkey login event, second-factor key / no credProps / no UV / foreign handle / banned / unactivated / reused challenge refused with one 401"
|
||||
requirement: "D-14"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-mfa-plugin/passwordless_smoke_test.go#TestPasswordlessSmoke (7 subtests)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Social sign-in through the login gate (sm-sociallogin-plugin a8e3e78, released as v0.1.4)"
|
||||
requirement: "D-09"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-sociallogin-plugin/social_gate_smoke_test.go#TestSocialGateSmoke (5 subtests) and TestTracerSmoke, in the real checkout"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Demo two-factor UI: TOTP setup with the QR image, recovery codes shown once, turn off, login challenge with TOTP or recovery code"
|
||||
requirement: "D-20"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-demo-app/vue-demo-app/app/lib/twoFactor.test.ts (14 tests)"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "pnpm build; server render of /account/security and /login on the built output (200)"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-demo-app/mfa_test.go#TestMFAMounted (the API the screens call is mounted in the demo)"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "Look and flow in a browser against a running demo with golem15.mfa mounted are a visual judgement; no browser run was made and the demo is not deployed."
|
||||
- id: D5
|
||||
description: "D-17 adoption: plugins published in order; demo and bm mount mfa; fonoteka.go green at the new pointer without mfa"
|
||||
requirement: "D-17"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "ls-remote of v0.1.12, v0.1.0, v0.1.4 and the pushed branches; sm-bm-app TestMFAMounted; sm-demo-app TestMFAMounted, TestBootAllPlugins, TestGoModRequiresTags and the full suite; fonoteka.go vet, -short suites and build"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: about 100 min of wall clock (2026-10-26 11:08Z to 12:50Z), including two checkpoint waits
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6 Plan 03: WebAuthn and adoption Summary
|
||||
|
||||
**WebAuthn second factor and passwordless passkeys in sm-mfa-plugin v0.1.0 (go-webauthn v0.18.2, ceremony state server-side), the social-login gate in sm-sociallogin-plugin v0.1.4, the demo's TOTP screens, and adoption in sm-demo-app, sm-bm-app (both pushed) and fonoteka.go (local).**
|
||||
|
||||
**Status:** complete. All 6 tasks are done.
|
||||
- **sm-demo-app (Task 6 part 1):** commits A-D made and pushed, after the second checkpoint was resolved (see "Task 6 sm-demo-app reply").
|
||||
- **sm-bm-app (part 2):** pushed.
|
||||
- **fonoteka.go (part 3):** local commit only.
|
||||
|
||||
Nothing was deployed.
|
||||
|
||||
**Results:**
|
||||
- **sm-mfa-plugin v0.1.0:** WebAuthn security keys as a second factor and passwordless passkey sign-in behind its setting. The new private repository is https://git.golem15.com/golem15/sm-mfa-plugin.
|
||||
- **sm-sociallogin-plugin v0.1.4:** social sign-in goes through the login gate (D-09).
|
||||
- **sm-user-plugin v0.1.12:** plan 01's login gates and device authorization, published.
|
||||
- **vue-demo-app:** the TOTP setup, recovery-code and login-challenge screens are pushed.
|
||||
- **sm-demo-app:** mounts golem15.mfa v0.1.0 with user v0.1.12, sociallogin v0.1.4 and the two-factor UI. Pushed, not deployed.
|
||||
- **sm-bm-app:** mounts golem15.mfa (API only) with user v0.1.12 and sociallogin v0.1.4. Pushed.
|
||||
- **fonoteka.go:** at user v0.1.12, guard tests updated. Local commit only.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Started:** about 2026-10-26T11:08Z
|
||||
- **First checkpoint (Task 4):** 11:48Z
|
||||
- **First continuation:** about 11:55Z to 12:25Z, ending at the second checkpoint (sm-demo-app)
|
||||
- **Second continuation:** about 12:30Z to 12:50Z
|
||||
- **Tasks:** 6 of 6
|
||||
|
||||
## Task 4 reply
|
||||
|
||||
Verbatim: "1. release 2. push demo 3. you can sudo chown golem:golem sm-sociallogin-plugin if needed."
|
||||
|
||||
The orchestrator's interpretation, recorded as given:
|
||||
1. **release**, with the proposed tags:
|
||||
- sm-user-plugin v0.1.12
|
||||
- sm-mfa-plugin v0.1.0, in a new private repository golem15/sm-mfa-plugin created with `tea repos create --owner golem15 --name sm-mfa-plugin`
|
||||
- sm-sociallogin-plugin v0.1.4
|
||||
2. **"push demo"**:
|
||||
- Pushing vue-demo-app is authorised, including the 4 unpushed Phase 19.7 commits (`0125e29`, `b973a76`, `3c53182`, `9c247ab`) under `44a5229`.
|
||||
- Pushing sm-demo-app after Task 6's commits is authorised, including its 19 unpushed commits from other phases.
|
||||
- sm-bm-app may be pushed after Task 6 only if its unpushed range is this phase's commits.
|
||||
- Never stage another session's uncommitted edits.
|
||||
3. **Ownership:** the orchestrator ran `sudo chown -R golem:golem` on `sm-sociallogin-plugin`. No other sudo.
|
||||
|
||||
Further limits:
|
||||
- **Plan 04 patch tags:** not authorised. Plan 04 must ask again before any tag.
|
||||
- Nothing is force-pushed or deployed.
|
||||
- fonoteka.go is never pushed.
|
||||
- No framework tag and no changelog post.
|
||||
|
||||
## Task 6 sm-demo-app reply
|
||||
|
||||
**Context:** the first continuation stopped before Task 6 part (1). sm-demo-app had uncommitted submodule pointer moves:
|
||||
- journal `4ab94da`→`b129902`
|
||||
- oauthserver `8bbec72`→`b6a9586`
|
||||
- user `bfcfea4`→`50da92c` (v0.1.11)
|
||||
- vue-demo-app `9c247ab`→`44a5229` (this phase's)
|
||||
|
||||
Commit A has to move that same user pointer. The orchestrator investigated: the moves are leftover Phase 19.7 checkouts (plan 05, 2026-10-23) that were never committed into sm-demo-app, not a live session.
|
||||
|
||||
The user's reply, verbatim: "proceed"
|
||||
|
||||
The orchestrator's interpretation, recorded as given:
|
||||
- Move only the demo's `plugins/golem15/user` checkout from `50da92c` (v0.1.11) to v0.1.12 (`3b22134`), and make commits A-D as the plan specifies:
|
||||
- A: user v0.1.12
|
||||
- B: sociallogin v0.1.4
|
||||
- C: mount golem15.mfa at v0.1.0 as the submodule `plugins/golem15/mfa`
|
||||
- D: the vue-demo-app pointer to `44a5229`
|
||||
- Leave the journal and oauthserver moves unstaged and untouched.
|
||||
- Run the demo verify (`TestMFAMounted`, `TestBootAllPlugins`, `TestGoModRequiresTags`, plus vet, `-short` and the full suite as the plan says).
|
||||
- Push sm-demo-app master. The authorised range is the 19 pre-existing unpushed commits (`a25444e..40ed518`, all dated 2026-10-23) plus A-D. Fetch first and verify the unpushed range is exactly those; if origin moved or anything else appears, stop and return a checkpoint.
|
||||
- No force-push, no deploy. Plan 04 patch tags remain not authorised.
|
||||
|
||||
**Outcome:**
|
||||
- **User checkout:** fast-forwarded on its `master` branch from `50da92c` to `3b22134`. `50da92c` is an ancestor and is on origin, and the submodule tree was clean.
|
||||
- **journal and oauthserver:** left as they were (still ` M`). They are tracked as a pending todo.
|
||||
|
||||
## Commits per repository
|
||||
|
||||
| Task | Repository | Commit | Message |
|
||||
|---|---|---|---|
|
||||
| 1 (tracer) | sm-mfa-plugin | `2662252` | feat: WebAuthn security keys as a second factor |
|
||||
| 2 | sm-mfa-plugin | `6c8916f` | feat: passwordless passkey login |
|
||||
| 2 | sm-sociallogin-plugin | `a8e3e78` | feat: social sign-in through the login gate (patch applied with `git am`; tree `c5f28f3` identical to the scratch clone's `a0161d7`) |
|
||||
| 3 | vue-demo-app | `44a5229` | feat: two-factor setup and the login challenge |
|
||||
| 5 | sm-mfa-plugin | `33ad164` | chore: require sm-user-plugin v0.1.12 |
|
||||
| 5 | sm-sociallogin-plugin | `b752177` | chore: require sm-user-plugin v0.1.12 |
|
||||
| 6 (1) A | sm-demo-app | `0eb1f60` | chore: bump sm-user-plugin to v0.1.12 and require summercms v0.5.0 |
|
||||
| 6 (1) B | sm-demo-app | `1c43e29` | chore: bump sm-sociallogin-plugin to v0.1.4 |
|
||||
| 6 (1) C | sm-demo-app | `2e5b7da` | feat: mount golem15.mfa |
|
||||
| 6 (1) D | sm-demo-app | `bb24207` | chore: bump vue-demo-app to the two-factor UI |
|
||||
| 6 (2) | sm-bm-app | `aad6004` | chore: bump sm-user-plugin to v0.1.12 |
|
||||
| 6 (2) | sm-bm-app | `376cff4` | chore: bump sm-sociallogin-plugin to v0.1.4 |
|
||||
| 6 (2) | sm-bm-app | `ebb2266` | feat: mount golem15.mfa |
|
||||
| 6 (3) | fonoteka.go (local only) | `95fd58a` | chore: bump sm-user-plugin to v0.1.12 |
|
||||
| draft | summercms.go | `5a64611` | docs(19.6-03): draft summary at the Task 4 release checkpoint |
|
||||
| draft | summercms.go | `4002bea` | docs(19.6-03): release and adoption up to the sm-demo-app checkpoint |
|
||||
|
||||
What commit C (`2e5b7da`) changes:
|
||||
- **Mount:**
|
||||
- `.gitmodules`, with the submodule `plugins/golem15/mfa` at v0.1.0 (`33ad164`)
|
||||
- `go.work`: `use ./plugins/golem15/mfa`
|
||||
- `summer.yaml`: `golem15.mfa` after `golem15.sociallogin`
|
||||
- `go.mod`: require v0.1.0, tidied
|
||||
- `plugins.gen.go`: regenerated by `summer build`, the only file it changed (main.go was unchanged)
|
||||
- **Config and docs:**
|
||||
- `config/golem15.mfa.yaml`
|
||||
- `deploy/env.example`, with commented `SUMMER_GOLEM15__MFA__` lines
|
||||
- the README plugin row
|
||||
- **Tests:**
|
||||
- `boot_test.go`: `wantPlugins` and the `/_user/api/v1/2fa/` and `/_user/api/v1/devices` prefixes
|
||||
- new `mfa_test.go`
|
||||
|
||||
## Remote operations (in order)
|
||||
|
||||
Before every push I ran `git fetch` and checked that `origin/master..master` held only the authorised commits. Nothing was force-pushed or deployed.
|
||||
|
||||
1. **sm-user-plugin** (`git@git.golem15.com:golem15/sm-user-plugin.git`):
|
||||
- Pushed master `50da92c..3b22134`: `8501f34`, `7900f47`, `3d4c8d2`, `4e3e5b0`, `3b22134`.
|
||||
- Annotated tag **v0.1.12** on `3b22134` (tag object `c0e0e85`), pushed.
|
||||
2. **sm-mfa-plugin:**
|
||||
- Created the private repository **https://git.golem15.com/golem15/sm-mfa-plugin** with `tea repos create --login git.golem15.com --owner golem15 --name sm-mfa-plugin --private`. The API confirms `"private":true`.
|
||||
- `git push -u origin master` pushed the new branch at `33ad164`, 6 commits.
|
||||
- Annotated tag **v0.1.0** on `33ad164` (tag object `b84dcbe`), pushed.
|
||||
3. **sm-sociallogin-plugin:**
|
||||
- Pushed master `4d3b2dd..b752177`: `a8e3e78`, `b752177`.
|
||||
- Annotated tag **v0.1.4** on `b752177` (tag object `18af090`), pushed.
|
||||
4. **vue-demo-app:** pushed master `21a22b6..44a5229`. That is the 4 named Phase 19.7 commits plus `44a5229`. No tag.
|
||||
5. **sm-bm-app** (Task 6 part 2): pushed master `aafbcce..ebb2266`, this phase's 3 commits only.
|
||||
6. **sm-demo-app** (`git@git.golem15.com:golem15/sm-demo-app.git`, Task 6 part 1): pushed master **`18597e5..bb24207`**, 23 commits. No tag.
|
||||
- **Pre-push checks:**
|
||||
- After `git fetch`, origin/master was still `18597e5` and `master..origin/master` was empty.
|
||||
- `origin/master..master` was exactly the 19 authorised commits (`a25444e` … `40ed518`, all dated 2026-10-23) plus A-D (`0eb1f60`, `1c43e29`, `2e5b7da`, `bb24207`).
|
||||
- Every gitlink those 23 commits introduce is on its submodule's origin: vue-demo-app `0125e29`, `21a22b6`, `3c53182`, `44a5229`, `9c247ab`, `b973a76`; user `3828a65`, `bfcfea4`, `3b22134`; journal `4ab94da`; oauthserver `116df7f`, `8bbec72`; sociallogin `b752177`; mfa `33ad164`.
|
||||
- **After the push:** `origin/master..master` is empty and `ls-remote` shows `bb24207`.
|
||||
|
||||
Read-only fetches also ran in the demo's user, sociallogin, mfa, journal and oauthserver submodules and in vue-demo-app.
|
||||
|
||||
The acceptance checks pass:
|
||||
- `ls-remote --exit-code --tags` for v0.1.12, v0.1.0 and v0.1.4.
|
||||
- `grep -c 'sm-user-plugin v0.1.12' ../sm-mfa-plugin/go.mod` = 1.
|
||||
- `origin/master..master` is empty for sm-user-plugin, vue-demo-app, sm-bm-app and sm-demo-app.
|
||||
- **sm-demo-app greps:**
|
||||
- `grep -c 'id: golem15.mfa' summer.yaml` = 1
|
||||
- `grep -c 'git.golem15.com/golem15/sm-mfa-plugin v0.1.0' go.mod` = 1
|
||||
- `grep -c 'golem15.mfa' plugins.gen.go` = 1
|
||||
|
||||
## Tests
|
||||
|
||||
All Docker-backed tests ran against testcontainers Postgres (Docker reachable as golem).
|
||||
|
||||
- **sm-mfa-plugin:**
|
||||
- **Tasks 1-2:** `go vet ./...` and `-short`: green at every commit.
|
||||
- `TestWebAuthnCeremonySmoke`: pass.
|
||||
- `TestWebAuthnSmoke`, `TestTracerSmoke`, `TestChallengeSmoke`, `TestTrustedSettingsSmoke`: pass.
|
||||
- `TestPasswordlessSmoke` (7 subtests): pass.
|
||||
- Full suite: ok, also against the framework's v0.5.0 tag.
|
||||
- **Task 5, after the require bump:**
|
||||
- Vet and `-short` in workspace mode: green.
|
||||
- With `GOWORK=off` (module mode, sm-user-plugin v0.1.12 downloaded from git.golem15.com): vet, `-short` and the full suite are green.
|
||||
- `go list -deps` has no `gopkg.in/yaml.v3`.
|
||||
- **sm-sociallogin-plugin (real checkout):**
|
||||
- **After `git am`:** vet, `-short` and the full suite are green, including `TestSocialGateSmoke` (5 subtests) and `TestTracerSmoke`.
|
||||
- **After the require bump:** vet and `-short` green in workspace mode. Vet and the full suite green with `GOWORK=off`.
|
||||
- **sm-user-plugin** (before the push): vet from fonoteka.go and in the plugin, then `-short`: ok for all four packages.
|
||||
- **vue-demo-app (Task 3):**
|
||||
- `pnpm test`: 202 tests pass, including `twoFactor.test.ts` (14).
|
||||
- `pnpm build`: ok.
|
||||
- Server render of `/account/security` and `/login`: 200.
|
||||
- **sm-demo-app (Task 6 part 1):**
|
||||
- **After commits A and B:** `go build ./...`, `go vet .` and `go test -short .` were green.
|
||||
- **Before commit C:**
|
||||
- Build and `go vet ./...` green.
|
||||
- `-short ./...` green, untagged and with `-tags summercms_mcp`.
|
||||
- Release-mode build green: `GOWORK=off go build -trimpath -tags summercms_mcp`, from the go.mod tags.
|
||||
- `scripts/check-pins.sh`: user, sociallogin and mfa match their tags. It reports only the two leftover journal and oauthserver moves.
|
||||
- **The plan's verify at HEAD `bb24207`:** `go build ./...`, `go vet .` and the three tests give exactly 3 `--- PASS: Test` lines (`TestBootAllPlugins`, `TestGoModRequiresTags`, `TestMFAMounted`).
|
||||
- **Full suite (Docker) at `bb24207`:** `go test -count=1 ./...` is ok for every package, untagged and with `-tags summercms_mcp` (the MCP end-to-end tests).
|
||||
- **sm-bm-app:**
|
||||
- Build, vet and `-short` green after each of the 3 commits. The full suite is green too.
|
||||
- The plan's verify passes: `--- PASS: TestMFAMounted`.
|
||||
- **fonoteka.go:**
|
||||
- The plan's verify passes: root `vet ./...`, `test -short ./...` and `build ./...`.
|
||||
- Root `./...` covers only the root module, so I also ran vet and `-short` in every workspace module (`plugins/golem15/{feedback,fonoteka,golem,user}`). All green.
|
||||
- Without `-short`:
|
||||
- `parity` passes after the fix; it was red at v0.1.10 as well.
|
||||
- Five Docker-backed tests in `plugins/golem15/fonoteka` fail at v0.1.12. They fail identically at the committed v0.1.10 pointer (baseline run), so they predate this plan. They are listed in deferred-items.md.
|
||||
- Acceptance checks:
|
||||
- `grep -c '"/devices"'` = 0 and `grep -c '"2fa"'` = 1.
|
||||
- `summer.yaml` has no golem15.mfa.
|
||||
- `go list -m all` has no go-webauthn.
|
||||
- The pointer moved in the bump commit.
|
||||
- **NOT RUN:**
|
||||
- `scripts/build.sh release` in sm-demo-app: it refuses the leftover journal and oauthserver moves (`require_clean`). Its Go step was run by hand as above. No Nuxt release build was made for the demo in this continuation.
|
||||
- A vue-demo-app type check: no tooling for it.
|
||||
- A browser run of the demo screens, and any deploy.
|
||||
|
||||
## Exported identifiers (for plan 04)
|
||||
|
||||
**sm-mfa-plugin `classes`:**
|
||||
- **Relying party and handles:**
|
||||
- `WebAuthnFor(ctx, app) (*webauthn.WebAuthn, error)`
|
||||
- `UserHandle(id uint) []byte`, `UserIDFromHandle`
|
||||
- **User adapter:** `WebAuthnUser` and `NewWebAuthnUser(ctx, db, user)`.
|
||||
- **Registration:**
|
||||
- `BeginRegistration(ctx, app, cache, db, user, passwordless) (map[string]any, error)`
|
||||
- `FinishRegistration(ctx, app, cache, tx, user, challenge, attestationJSON, name) (*models.WebAuthnCredential, error)`
|
||||
- `VerifyRegistration(w, wu, session, attestationJSON)`
|
||||
- **Second-factor assertion:**
|
||||
- `BeginAssertion(ctx, app, db, challenge, user)`
|
||||
- `FinishAssertion(ctx, app, db, challenge, user, assertionJSON) (*Assertion, error)`
|
||||
- `VerifyAssertion(w, wu, session, assertionJSON)`
|
||||
- `RecordAssertion(ctx, tx, *Assertion) (bool, error)`, `Assertion`
|
||||
- **Passkeys:**
|
||||
- `BeginPasswordless(ctx, app, cache)`
|
||||
- `FinishPasswordless(ctx, app, cache, db, challenge, assertionJSON, ip) (*usermodels.User, *Assertion, error)`
|
||||
- **Credential helpers:** `WebAuthnCredentialList`, `HasWebAuthnCredential`, `DeleteWebAuthnCredential`.
|
||||
- **Login:** `CompleteLoginAs(ctx, app, db, r, user, source)`.
|
||||
- **Constants:** `WebAuthnTimeout` (60 s), `WebAuthnStateTTL` (120 s).
|
||||
- **Errors:**
|
||||
- `WebAuthnFailure{Reason}` with `ErrWebAuthnChallenge`, `ErrWebAuthnInvalid`, `ErrWebAuthnVerification`, `ErrWebAuthnDuplicate`, `ErrWebAuthnNoOptions`, `ErrWebAuthnNoCredentials`
|
||||
- `ErrWebAuthnUnavailable`
|
||||
- **Events:**
|
||||
- `WebAuthnRegisteredEvent{User, Credential, Tx}`, `WebAuthnRegisteredEventName` = `golem15.user.2fa.webauthn.registered`
|
||||
- `WebAuthnRemovedEvent{User, CredentialID, Tx}`, `WebAuthnRemovedEventName` = `golem15.user.2fa.webauthn.removed`
|
||||
- **Config fields:** `Config.WebAuthnRPID`, `WebAuthnRPName`, `WebAuthnOrigins`.
|
||||
|
||||
**Other sm-mfa-plugin packages:**
|
||||
- **`controllers`:** `WebAuthnRegisterOptions`, `WebAuthnRegister`, `WebAuthnRemove`, `WebAuthnOptions`, `WebAuthnVerify`, `PasswordlessOptions`, `PasswordlessVerify`.
|
||||
- **`models`:** `WebAuthnCredential` (`DisplayName()`), `DefaultCredentialName`.
|
||||
- **Migration:** `202610220006_create_golem15_user_webauthn_credentials`.
|
||||
- **Config keys:** `golem15.mfa.webauthn.rp_id`, `golem15.mfa.webauthn.rp_name`, `golem15.mfa.webauthn.origins` (env `SUMMER_GOLEM15__MFA__WEBAUTHN__RP_ID`, `…__RP_NAME`, `…__ORIGINS`).
|
||||
|
||||
**sm-mfa-plugin routes:**
|
||||
- **Challenge group, `throttle:2fa-verify`:**
|
||||
- `POST /_user/api/v1/2fa/webauthn/options`, `…/webauthn/verify`
|
||||
- `…/webauthn/passwordless/options`, `…/webauthn/passwordless/verify`
|
||||
- **Management, `jwt.auth`:**
|
||||
- `POST …/webauthn/register/options`, `POST …/webauthn/register`
|
||||
- `DELETE …/webauthn/{id}` (digits)
|
||||
|
||||
**sm-sociallogin-plugin v0.1.4:**
|
||||
- `classes.Outcome.Challenge` and `classes.CompletionPayload.Challenge` (JSON `challenge,omitempty`).
|
||||
- Lang key `golem15.sociallogin::lang.oauth.two_factor_unavailable`.
|
||||
- Test `TestSocialGateSmoke`.
|
||||
- go.mod requires sm-user-plugin v0.1.12 and SummerCMS v0.5.0.
|
||||
|
||||
**sm-bm-app:** `TestMFAMounted` (`mfa_test.go`).
|
||||
|
||||
**sm-demo-app:**
|
||||
- `TestMFAMounted` (`mfa_test.go`).
|
||||
- `config/golem15.mfa.yaml`.
|
||||
|
||||
**vue-demo-app:**
|
||||
- **`app/lib/twoFactor.ts`:**
|
||||
- Functions `isTwoFactorChallenge`, `normalizeRecoveryCode`, `isTotpCode`, `challengeExpired`, `svgDataUrl`.
|
||||
- Types `TwoFactorChallenge`, `TwoFactorStatus`, `TotpSetup`, `WebAuthnCredentialInfo`.
|
||||
- Constant `CHALLENGE_TOKEN_LENGTH`.
|
||||
- **Composables:**
|
||||
- `useDemoAuth()` gains `verifyChallenge` and `recoverChallenge`, and `login` returns `{challenge?}`.
|
||||
- `useTwoFactor()` (`status`, `setupTotp`, `confirmTotp`, `disableTotp`).
|
||||
- **UI:**
|
||||
- Page `/account/security`.
|
||||
- Header link to it.
|
||||
- i18n `auth.twoFactor.*`, `security.*`, `header.security`.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See key-decisions in the frontmatter.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
**1. [Environment, resolved] sm-sociallogin-plugin write access**
|
||||
- **Problem:** the checkout was owned by `jin` (first run). The scratch-clone patch is described in the first draft.
|
||||
- **Fix:** at the user's instruction ("you can sudo chown golem:golem sm-sociallogin-plugin"), the orchestrator ran `sudo chown -R golem:golem`. I used no sudo.
|
||||
- **Result:** `git am` gave `a8e3e78`, whose tree `c5f28f3` is identical to the scratch clone's `a0161d7`. Vet, `-short` and the full suite were green there.
|
||||
|
||||
**2. [Drift, corrected] Release numbers**
|
||||
- The plan proposed sm-user-plugin v0.1.6 and sm-sociallogin-plugin v0.1.3. Both were stale.
|
||||
- Published as v0.1.12 and v0.1.4, the next free patches, as the reply confirmed.
|
||||
- sm-mfa-plugin is v0.1.0 as planned.
|
||||
- sm-mfa-plugin requires framework v0.5.0, not the plan's v0.3.1. Plan 02 already needed v0.5.0.
|
||||
- sociallogin's require rose from v0.3.1 to v0.5.0 through `go mod tidy`. Its README Dependencies now names v0.5.0 and user v0.1.12, in the same commit.
|
||||
|
||||
**3. [Drift] vue-demo-app pushed with another phase's commits**
|
||||
- The push included Phase 19.7's `0125e29`, `b973a76`, `3c53182` and `9c247ab`.
|
||||
- The Task 4 reply authorised them by name.
|
||||
|
||||
**4. [Checkpoint, resolved] sm-demo-app part (1) waited on a second decision**
|
||||
- The demo's user pointer had an uncommitted move to v0.1.11, left over from Phase 19.7.
|
||||
- The user replied "proceed" (see "Task 6 sm-demo-app reply").
|
||||
- The user checkout was fast-forwarded to v0.1.12. The journal and oauthserver moves were left unstaged and are a pending todo.
|
||||
|
||||
**5. [Rule 3, scope] fonoteka.go guard tests cover every user version the bump crosses**
|
||||
- **Problem:** the committed pointer was v0.1.10, but the guards had not followed it. `TestHiddenNeverMarshals` expected 8 models with 10 present. The parity migration count expected 11 with 14 present, and the account-link tables had no allowance. So the plan's "+1 for DeviceAuthSession" would have left them red.
|
||||
- **What `95fd58a` changes:**
|
||||
- `expectedUserModels` 8 → 11, with a comment naming BackendLink, BackendLinkRequest and DeviceAuthSession.
|
||||
- New `wantUserMigrations = 15` in parity.
|
||||
- Allowances for `golem15_user_backend_links`, `golem15_user_backend_link_requests` and `golem15_user_device_auth_sessions`.
|
||||
- `TestRequirePasswordChangeExemptSet` allows jwt.auth on `POST /_user/api/v1/backend-link/confirm`, which comes from v0.1.11.
|
||||
- The deferred-routes guard drops the devices fragment and keeps 2fa. Its comment avoids the quoted `"/devices"` so the acceptance grep stays at 0.
|
||||
- **Untouched:** five other Docker-backed fonoteka failures fail identically at v0.1.10 and do not inventory the user plugin, so they were left alone (deferred-items.md).
|
||||
|
||||
**6. [Scope] sm-bm-app `scripts/build.sh`**
|
||||
- It is not in the plan's file list.
|
||||
- The 117ef8f precedent adds each mounted plugin to `PLUGINS`, which drives the release go.work and the dirty check. mfa was added there.
|
||||
|
||||
**7. [Scope] fonoteka.go root go.mod still requires sm-user-plugin v0.1.10**
|
||||
- The plan limits staging to the pointer and the tests.
|
||||
- The replace makes the build use v0.1.12.
|
||||
- A follow-up is in deferred-items.md.
|
||||
|
||||
**8. [Cosmetic] sm-mfa-plugin v0.1.0 tag message**
|
||||
- It says the mode is "optional, required or disabled"; the actual values are `disabled`, `optional` and `enforced`.
|
||||
- The tag is pushed and is not rewritten, since that would need a force-push (deferred-items.md).
|
||||
|
||||
**9-15 (from the first run):**
|
||||
- Rule 2: availability check on `webauthn/register`.
|
||||
- Rule 2: guarded assertion write-back.
|
||||
- Discretion: `FinishAssertion` / `RecordAssertion` split, exported `VerifyRegistration` / `VerifyAssertion`, and `CompleteLoginAs`.
|
||||
- Rule 2: passkey routes 403 while `two_factor_mode` is disabled.
|
||||
- Rule 2: passkey ban check across addresses (ThrottleStates) and refusal of unactivated accounts.
|
||||
- Extra test coverage in `TestWebAuthnSmoke`, `TestPasswordlessSmoke` and `TestSocialGateSmoke`.
|
||||
- Demo UI extras: i18n keys and a cancel link. The commits and details are unchanged from the first draft (`2662252`, `6c8916f`, `44a5229`).
|
||||
|
||||
**16. [Rule 3, environment] The private sm-mfa-plugin repository and the demo's module-mode resolution**
|
||||
- **Problem:** `go get`/`go mod tidy` with `GOWORK=off` could not fetch `git.golem15.com/golem15/sm-mfa-plugin@v0.1.0`: "could not read Username for 'https://git.golem15.com'". The repository is private; the other plugin repositories allow anonymous HTTPS. Commit C needs that fetch for the go.mod require and the go.sum hashes.
|
||||
- **Fix:** for those commands only, the environment carried a git URL rewrite to SSH:
|
||||
- `GIT_CONFIG_COUNT=1`
|
||||
- `url.git@git.golem15.com:.insteadOf https://git.golem15.com/`
|
||||
- `GOPRIVATE=git.golem15.com/*`
|
||||
|
||||
No global or repository git config changed.
|
||||
- **Consequence (open, deferred-items.md):** `scripts/build.sh release` and `scripts/check-pins.sh` fetch in module mode. On a machine without v0.1.0 in its module cache they fail until sm-mfa-plugin is public or the build host has credentials. The user decides. sm-bm-app is unaffected (it uses a replace).
|
||||
|
||||
**17. [Precedent] Commit A also raises summercms v0.4.4 → v0.5.0**
|
||||
- user v0.1.12 requires the framework at v0.5.0, so `go get` raised it.
|
||||
- The subject names both, as `985af53` ("chore: bump user to v0.1.10 and require summercms v0.4.4") did; the plan's subject named only the user bump.
|
||||
|
||||
**18. [Drift] Demo sociallogin moved from v0.1.2 to v0.1.4**
|
||||
- The demo was on v0.1.2, not v0.1.3, so commit B also brings v0.1.3. Its message names v0.1.3's changes.
|
||||
|
||||
**19. [Process] Commit B's message amended before the push**
|
||||
- The first message understated v0.1.3 and named "the callback" instead of oauth-complete and oauth-register-complete.
|
||||
- I amended my own unpushed commit (`9651dea` → `1c43e29`). Its tree is unchanged.
|
||||
|
||||
**20. [Discretion] `config/golem15.mfa.yaml` does not offer webauthn**
|
||||
- The plan set methods to `[totp, email]`, which already leaves webauthn out. The comment says why: the demo has no security-key screens.
|
||||
- Passwordless sign-in stays at the plugin default, off.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
- `status.webauthn_credentials` lists the enabled keys.
|
||||
- `Admin.Reset` deletes WebAuthn credentials.
|
||||
- sm-bm-app mounts the two-factor API without frontend screens, which is intended and documented in its README row. Users cannot enable a second factor there, so sign-in is unchanged.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None beyond the plan's register.
|
||||
- T-19.6-26..31 and T-19.6-33 are mitigated in code and tests.
|
||||
- T-19.6-32: each push followed a fetch, a range check against the authorised commits and, for sm-demo-app, a check that every introduced gitlink is on its origin. Nothing was force-pushed or deployed, and fonoteka.go was not pushed.
|
||||
|
||||
## Follow-ups
|
||||
|
||||
- **Pending todo** `.planning/todos/pending/2026-10-26-sm-demo-app-journal-oauthserver-pointers.md`: sm-demo-app's uncommitted journal (`4ab94da`→`b129902`) and oauthserver (`8bbec72`→`b6a9586`) moves, left over from Phase 19.7 plan 05.
|
||||
- Both commits are on origin, but no tag sits on either one.
|
||||
- v0.2.4 and v0.1.3 contain them, so the bump should go to those tags.
|
||||
- **deferred-items.md** holds the private-repository build issue, plus the earlier items:
|
||||
- sociallogin gofmt
|
||||
- vue-demo-app type check
|
||||
- five fonoteka Docker-backed failures
|
||||
- fonoteka root go.mod require
|
||||
- the mfa tag message
|
||||
- **Plan 04 patch tags:** not authorised. Plan 04 must ask before any tag.
|
||||
|
||||
## Next
|
||||
|
||||
- Plan 04, the phase's unit tests.
|
||||
|
||||
g15office: this executor has no g15office tool. The orchestrator posts the plan 03 update on `avoroeb4`.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- **Commits exist:**
|
||||
- sm-mfa-plugin: `2662252`, `6c8916f`, `33ad164`
|
||||
- sm-sociallogin-plugin: `a8e3e78`, `b752177`
|
||||
- vue-demo-app: `44a5229`
|
||||
- sm-demo-app: `0eb1f60`, `1c43e29`, `2e5b7da`, `bb24207`
|
||||
- sm-bm-app: `aad6004`, `376cff4`, `ebb2266`
|
||||
- fonoteka.go: `95fd58a`
|
||||
- summercms.go: `5a64611`, `4002bea`
|
||||
- **Files exist:**
|
||||
- `../sm-demo-app/mfa_test.go`
|
||||
- `../sm-demo-app/config/golem15.mfa.yaml`
|
||||
- `../sm-demo-app/plugins/golem15/mfa/go.mod`
|
||||
- the pending todo
|
||||
- **On origin:**
|
||||
- Tags v0.1.12, v0.1.0 and v0.1.4.
|
||||
- sm-mfa-plugin master.
|
||||
- sm-demo-app master at `bb24207` (`ls-remote`).
|
||||
- **Working trees:**
|
||||
- sm-demo-app keeps only the leftover ` M plugins/golem15/journal` and ` M plugins/golem15/oauthserver`.
|
||||
- sm-mfa-plugin, sm-sociallogin-plugin and fonoteka.go are clean.
|
||||
- sm-bm-app keeps only the other session's planning edits and untracked paths.
|
||||
@@ -0,0 +1,468 @@
|
||||
From a0161d770e3f12d43d335b8c5e026e93f2993786 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Zych <jakub@golem15.com>
|
||||
Date: Mon, 26 Oct 2026 12:39:52 +0100
|
||||
Subject: [PATCH] feat: social sign-in through the login gate
|
||||
|
||||
- signIn consults golem15.user's login gates (CheckLoginGates, source
|
||||
social) before FinishLogin, SignedInEvent and any token (D-09)
|
||||
- a 200 gate answer becomes Outcome.Challenge and
|
||||
CompletionPayload.Challenge; oauth-complete and oauth-register-complete
|
||||
answer exactly that body, with no token or cookie
|
||||
- any other status redirects with the new two_factor_unavailable message
|
||||
(en, pl); a gate error fails closed; action=link is never gated
|
||||
- README "Two-factor sign-in" section, TestSocialGateSmoke with a fake
|
||||
gate (no dependency on a two-factor plugin)
|
||||
---
|
||||
README.md | 20 +++-
|
||||
classes/codes.go | 13 ++-
|
||||
classes/flow.go | 32 +++++-
|
||||
controllers/callback.go | 9 +-
|
||||
controllers/complete.go | 9 +-
|
||||
controllers/register_complete.go | 6 +
|
||||
lang/en/lang.yaml | 1 +
|
||||
lang/pl/lang.yaml | 1 +
|
||||
social_gate_smoke_test.go | 191 +++++++++++++++++++++++++++++++
|
||||
9 files changed, 266 insertions(+), 16 deletions(-)
|
||||
create mode 100644 social_gate_smoke_test.go
|
||||
|
||||
diff --git a/README.md b/README.md
|
||||
index db09474..3742c4e 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -88,13 +88,23 @@ app.Events.Listen[*classes.SignedInEvent]("acme", func(ctx context.Context, ev *
|
||||
})
|
||||
```
|
||||
|
||||
+### Two-factor sign-in
|
||||
+
|
||||
+Every social sign-in except a link consults golem15.user's login gates (`usercontrollers.CheckLoginGates`, source `userclasses.LoginSourceSocial`) before golem15.user's `FinishLogin`, before `SignedInEvent` and before any token exists. Without a gate, or when every gate allows the sign-in, nothing changes. A two-factor plugin (golem15.mfa) registers a gate that challenges social sign-ins only when its social-login setting (`two_factor_social_login`) is on; it is off by default, as in PHP.
|
||||
+
|
||||
+- With a challenge, `oauth-complete` (and `oauth-register-complete` when it signs an existing account in) answers 200 with exactly the gate's body, for example `{"two_factor_required":true,"challenge_token":"…","available_methods":["totp"],"expires_at":"…"}`, instead of `{token, user, action, return_to}`. No token and no token cookie are issued; the frontend completes the challenge at the two-factor plugin's routes, which answer `{token, user}`. The SPA callback page must handle `two_factor_required` before an application turns the setting on.
|
||||
+- A challenged sign-in does not restore a deactivated account and does not fire `SignedInEvent`: the second factor's completion runs golem15.user's `FinishLogin` and its login event (source `two_factor`). The identity itself is stored (or refreshed) before the gate, as the provider already proved it.
|
||||
+- A gate that refuses (any status other than 200, for example the second-factor failure cap) sends the browser to the callback with `?error=` and the `two_factor_unavailable` message; on `oauth-register-complete` it is a 422 with that message. A gate error fails closed: the callback redirects with the generic error, no completion code is issued, `oauth-register-complete` answers 500.
|
||||
+- Linking (`action=link`) is never gated: the user is already signed in.
|
||||
+- Trusted devices never skip a social challenge: a social sign-in carries no request body with a trusted-device token.
|
||||
+
|
||||
## Routes
|
||||
|
||||
| Method | Path | Middleware | Purpose |
|
||||
|---|---|---|---|
|
||||
| GET | `/oauth/{provider}` | `throttle:20,1` | Start: `mode` (ignored, SPA only), `action` (`login` default, `register`, `link`), `frontend_callback`, `return_to`, `link_ticket` |
|
||||
| GET | `/oauth/{provider}/callback` | `throttle:20,1` | Provider return: `?code=` on success, `?error=<message>` otherwise |
|
||||
-| GET | `/_user/api/v1/oauth-complete?code=` | `throttle:user-api` | 200 `{token, user, action, return_to}`; 422 empty code; 410 missing or used code |
|
||||
+| GET | `/_user/api/v1/oauth-complete?code=` | `throttle:user-api` | 200 `{token, user, action, return_to}`, or the login gate's `two_factor_required` body (see Two-factor sign-in); 422 empty code; 410 missing or used code |
|
||||
| POST | `/_user/api/v1/oauth-register-complete` | `throttle:user-api` | `pending_code`, `terms_accepted`, `privacy_accepted`, `marketing_consent`, optional `parental_authority` and `beta_key` (JSON or form). 200 `{token, user, action, return_to}`; 422 `{error, errors: {terms_accepted, privacy_accepted}}` for missing consent, 422 `{error}` for an unverified email match, a beta key, a closed or throttled registration, 422 `{error, errors}` for a rejected account; 410 for a missing, expired or used code |
|
||||
|
||||
`action=register` start requests also take `terms_accepted`, `privacy_accepted`, `marketing_consent` (true for `1`, `true`, `on`, `yes`) and `parental_authority`; any start request may carry `beta_key`.
|
||||
@@ -155,9 +165,9 @@ Package `classes`:
|
||||
- `Config`, `LoadConfig`; `ResolveCredentials(ctx, app, name) (ProviderConfig, bool, error)`, `CallbackRoute(name string) string`.
|
||||
- `State`, `Consent`, `SealState`, `OpenState`, `ClearStateCookie`, `StateCookieName`, `StateCookieSecure`, `StateTTL`, `MaxStateCookieBytes`, `ErrInvalidState`.
|
||||
- `HostSet`, `NewHostSet`, `NormalizeFrontendCallback`, `NormalizeReturnTo`, `ResolveCallback`, `WithQuery`.
|
||||
-- `NewCode() (string, error)`, `CompletionPayload`, `PutCompletion`, `PullCompletion`, `CompletionTTL`; `PendingPayload` (and its `Profile()`; `TenantID` carries the tenant, JSON `tenant_id`, omitted when empty), `PutPending`, `GetPending`, `PullPending`, `PendingTTL`; `PutLinkTicket`, `PullLinkTicket`, `LinkTicketTTL`.
|
||||
+- `NewCode() (string, error)`, `CompletionPayload` (with `Challenge`, JSON `challenge`, omitted when empty), `PutCompletion`, `PullCompletion`, `CompletionTTL`; `PendingPayload` (and its `Profile()`; `TenantID` carries the tenant, JSON `tenant_id`, omitted when empty), `PutPending`, `GetPending`, `PullPending`, `PendingTTL`; `PutLinkTicket`, `PullLinkTicket`, `LinkTicketTTL`.
|
||||
- `SignedInEvent`, `SignedInEventName` (see Events).
|
||||
-- `ActionLogin`, `ActionRegister`, `ActionLink`; `Outcome`, `OutcomeLogin`, `OutcomePending`, `ReasonNoEmail`, `ReasonUnverifiedMatch`, `HandleCallback`, `CompletePending`, `ErrPendingConsumed`, `CreateUser`, `CheckBetaKey`, `PasswordBootstrapSource`, `ValidationError`, `IsValidation`, `FlowError`, `Message`, `RegisterMessage`, `ClientIP`.
|
||||
+- `ActionLogin`, `ActionRegister`, `ActionLink`; `Outcome` (with `Challenge`, the login gate's body), `OutcomeLogin`, `OutcomePending`, `ReasonNoEmail`, `ReasonUnverifiedMatch`, `HandleCallback`, `CompletePending`, `ErrPendingConsumed`, `CreateUser`, `CheckBetaKey`, `PasswordBootstrapSource`, `ValidationError`, `IsValidation`, `FlowError`, `Message`, `RegisterMessage`, `ClientIP`.
|
||||
|
||||
Adding a provider from another plugin (which requires `golem15.sociallogin`):
|
||||
|
||||
@@ -182,7 +192,7 @@ func (p *Plugin) Register(app *backpack.App) error {
|
||||
|
||||
## Dependencies
|
||||
|
||||
-- `golem15.user` (`git.golem15.com/golem15/sm-user-plugin` v0.1.5 or newer): users, identities, tokens, the user payload, the provider list endpoint, and `users.email_verified_at`, the owner's proof of the address that account matching reads.
|
||||
+- `golem15.user` (`git.golem15.com/golem15/sm-user-plugin`, a version with the login gate registry, `CheckLoginGates` and `LoginSourceSocial`): users, identities, tokens, the user payload, the provider list endpoint, the login gates, and `users.email_verified_at`, the owner's proof of the address that account matching reads.
|
||||
- `github.com/markbates/goth` v1.82.0: the core package and the `google`, `facebook`, `github` and `azureadv2` provider packages only (never its session helper package, so `gorilla/sessions` is not linked); only `classes/providers_goth.go` imports it.
|
||||
- `golang.org/x/oauth2` (token exchange errors, and the Microsoft code exchange that keeps the id_token).
|
||||
- SummerCMS v0.3.1 or newer (`git.golem15.com/golem15/summercms`; `cooler.Cache.Pull` consumes the one-time codes), modules `backpack`, `bouncer`, `cabana`, `cooler`, `lagoon`, `pact`, `party`, `phrasebook`, `surf`, `wire`.
|
||||
@@ -195,7 +205,7 @@ go test -short ./... # no Docker
|
||||
go test ./... # also the testcontainers Postgres smoke tests
|
||||
```
|
||||
|
||||
-The smoke tests: `TestTracerSmoke` drives a returning user's sign-in through a fake provider registered in the plugin's registry; `TestFlowSmoke` covers email matches, account creation at the callback and on the pending screen, and the token cookie; `TestLinkSmoke` covers the link ticket, bearer linking and the start-request errors; `TestSettingsOverrideSmoke` covers the admin settings override; `TestGothProvidersSmoke` drives the four goth wrappers against fake provider APIs.
|
||||
+The smoke tests: `TestTracerSmoke` drives a returning user's sign-in through a fake provider registered in the plugin's registry; `TestFlowSmoke` covers email matches, account creation at the callback and on the pending screen, and the token cookie; `TestLinkSmoke` covers the link ticket, bearer linking and the start-request errors; `TestSocialGateSmoke` adds a fake login gate to golem15.user's registry and covers the unchanged sign-in without a challenge, the `two_factor_required` body from `oauth-complete` and `oauth-register-complete` with no token and the deactivated account left deactivated, the refusal redirect with `two_factor_unavailable`, a gate error failing closed and an ungated link; `TestSettingsOverrideSmoke` covers the admin settings override; `TestGothProvidersSmoke` drives the four goth wrappers against fake provider APIs.
|
||||
|
||||
The unit tests, one per decision. Without Docker (`-short`): `TestRegistry` (names, reserved names, order, Build), `TestNormalizeFrontendCallback` and `TestNormalizeReturnTo` (the callback and return_to tables), `TestCodes` (64-character codes, sealed cache values, TTLs, single use), `TestEmailVerified` (per-provider email-verified rules), `TestGothProviders` (authorization URLs, sign-ins, the Microsoft tenant from the id_token and its refusals: no id_token, malformed, foreign `aud`, non-GUID `tid`; expired codes without response bodies, timeouts, no request outside the provider's hosts against fake APIs) and `TestErrorMessages` (every message in en and pl, the PHP texts byte for byte). On Postgres: `TestStateCookie` (sealing, refusals, attributes, cleared on every callback outcome), `TestRoutes`, `TestRouteMiddleware` (throttles from the route table, the 21st request answers 429), `TestProvidersList`, `TestMatching`, `TestNOAuth` (a Microsoft mail matching an existing user never links, in any tenant), `TestSoftDeleted`, `TestInactiveAndBanned` (including a banned and deactivated account, refused on every path, never restored and never mailed), `TestRegistrationGates`, `TestConsent`, `TestBetaGate`, `TestIdentityTokens`, `TestLink`, `TestLinkTicket`, `TestOAuthComplete`, `TestTokenCookieMode`, `TestRegisterComplete` (including 16 concurrent submissions of one code: one 200, fifteen 410), `TestPreAccountTakeover` (a verified sign-in never links onto a password-less account), `TestTenantProfileData` (`profile_data.tenant_id` only with a tenant, kept through a pending sign-in), `TestSignedInEvent` (one event per login, register, link, pending completion and restoring login with every field; failing sign-in, register and created listeners are logged and fail nothing; a listener's write reaches the payload) and `TestSettings` (overrides, write-only secrets, no secret in any log line, the PHP environment names).
|
||||
|
||||
diff --git a/classes/codes.go b/classes/codes.go
|
||||
index b2dbb5b..bf5f765 100644
|
||||
--- a/classes/codes.go
|
||||
+++ b/classes/codes.go
|
||||
@@ -31,12 +31,15 @@ const (
|
||||
)
|
||||
|
||||
// CompletionPayload is what GET /_user/api/v1/oauth-complete hands over
|
||||
-// for a code.
|
||||
+// for a code. Challenge is set (and Token and User are empty) when a login
|
||||
+// gate held the sign-in back for a second factor; oauth-complete then
|
||||
+// answers exactly that body.
|
||||
type CompletionPayload struct {
|
||||
- Token string `json:"token"`
|
||||
- User map[string]any `json:"user"`
|
||||
- Action string `json:"action"`
|
||||
- ReturnTo string `json:"return_to"`
|
||||
+ Token string `json:"token"`
|
||||
+ User map[string]any `json:"user"`
|
||||
+ Action string `json:"action"`
|
||||
+ ReturnTo string `json:"return_to"`
|
||||
+ Challenge map[string]any `json:"challenge,omitempty"`
|
||||
}
|
||||
|
||||
// PendingPayload is a sign-in that ended on the frontend's pending
|
||||
diff --git a/classes/flow.go b/classes/flow.go
|
||||
index 452eb7e..2cd42fc 100644
|
||||
--- a/classes/flow.go
|
||||
+++ b/classes/flow.go
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
+ userclasses "git.golem15.com/golem15/sm-user-plugin/classes"
|
||||
usercontrollers "git.golem15.com/golem15/sm-user-plugin/controllers"
|
||||
usermodels "git.golem15.com/golem15/sm-user-plugin/models"
|
||||
"git.golem15.com/golem15/summercms/modules/backpack"
|
||||
@@ -50,6 +51,12 @@ type Outcome struct {
|
||||
Action string
|
||||
ReturnTo string
|
||||
Pending *PendingPayload
|
||||
+ // Challenge is set instead of Token and User when a login gate (a
|
||||
+ // two-factor plugin) held the sign-in back: the body the frontend gets
|
||||
+ // from oauth-complete or oauth-register-complete, for example
|
||||
+ // {two_factor_required, challenge_token, available_methods,
|
||||
+ // expires_at}.
|
||||
+ Challenge map[string]any
|
||||
}
|
||||
|
||||
// HandleCallback runs the account matching of the PHP SocialAuth component
|
||||
@@ -321,12 +328,35 @@ func loginWithIdentity(ctx context.Context, app *backpack.App, r *http.Request,
|
||||
// signIn runs the steps of a password login after authentication, fires
|
||||
// ev (SignedInEvent) and returns the login outcome with a fresh session
|
||||
// token for the user row read again after the listeners.
|
||||
+//
|
||||
+// First it consults golem15.user's login gates with source social (D-09),
|
||||
+// before FinishLogin, so a deactivated account is not restored and no token
|
||||
+// exists before a second factor. A gate that answers 200 (a two-factor
|
||||
+// challenge) makes the outcome carry that body as Challenge instead of a
|
||||
+// token, and the sign-in stops there: FinishLogin, SignedInEvent and the
|
||||
+// token are left to the second factor's completion. Any other status is a
|
||||
+// refusal (two_factor_unavailable); a gate error is returned, so the
|
||||
+// sign-in fails closed. A link (linkIdentity) never comes here.
|
||||
func signIn(ctx context.Context, app *backpack.App, r *http.Request, db *gorm.DB, user *usermodels.User, ev *SignedInEvent, returnTo string) (Outcome, error) {
|
||||
+ gate, err := usercontrollers.CheckLoginGates(ctx, app, userclasses.LoginAttempt{User: user, Source: userclasses.LoginSourceSocial, Request: r})
|
||||
+ if err != nil {
|
||||
+ return Outcome{}, err
|
||||
+ }
|
||||
+ if gate != nil {
|
||||
+ if gate.Status != 0 && gate.Status != http.StatusOK {
|
||||
+ return Outcome{}, flowErr("two_factor_unavailable")
|
||||
+ }
|
||||
+ body := gate.Body
|
||||
+ if body == nil {
|
||||
+ body = map[string]any{}
|
||||
+ }
|
||||
+ return Outcome{Kind: OutcomeLogin, Challenge: body, Action: ev.Action, ReturnTo: returnTo}, nil
|
||||
+ }
|
||||
if err := usercontrollers.FinishLogin(ctx, app, db, user, ClientIP(app, r)); err != nil {
|
||||
return Outcome{}, err
|
||||
}
|
||||
action := ev.Action
|
||||
- user, err := fireSignedIn(ctx, app, db, ev)
|
||||
+ user, err = fireSignedIn(ctx, app, db, ev)
|
||||
if err != nil {
|
||||
return Outcome{}, err
|
||||
}
|
||||
diff --git a/controllers/callback.go b/controllers/callback.go
|
||||
index 956d791..3f3b8de 100644
|
||||
--- a/controllers/callback.go
|
||||
+++ b/controllers/callback.go
|
||||
@@ -111,10 +111,11 @@ func finishCallback(w http.ResponseWriter, r *http.Request, app *backpack.App, c
|
||||
return
|
||||
}
|
||||
code, err := classes.PutCompletion(r.Context(), app, classes.CompletionPayload{
|
||||
- Token: out.Token,
|
||||
- User: out.User,
|
||||
- Action: out.Action,
|
||||
- ReturnTo: out.ReturnTo,
|
||||
+ Token: out.Token,
|
||||
+ User: out.User,
|
||||
+ Action: out.Action,
|
||||
+ ReturnTo: out.ReturnTo,
|
||||
+ Challenge: out.Challenge,
|
||||
})
|
||||
if err != nil {
|
||||
slog.Default().Error("golem15.sociallogin: store completion code", "err", err)
|
||||
diff --git a/controllers/complete.go b/controllers/complete.go
|
||||
index de2a7ba..481082f 100644
|
||||
--- a/controllers/complete.go
|
||||
+++ b/controllers/complete.go
|
||||
@@ -13,7 +13,10 @@ import (
|
||||
// return_to}, 422 for an empty code and 410 for a missing, used or expired
|
||||
// one, as the PHP API does. With golem15.sociallogin.token_cookie the
|
||||
// token is set as golem15.user's token cookie (bouncer TokenCookie) and
|
||||
-// left out of the body.
|
||||
+// left out of the body. When a login gate held the sign-in back (D-09), it
|
||||
+// answers 200 with exactly the gate's body, for example
|
||||
+// {two_factor_required, challenge_token, available_methods, expires_at},
|
||||
+// and no token or cookie.
|
||||
func Complete(app *backpack.App) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
code := r.URL.Query().Get("code")
|
||||
@@ -31,6 +34,10 @@ func Complete(app *backpack.App) http.HandlerFunc {
|
||||
writeJSON(w, http.StatusGone, map[string]any{"error": "OAuth completion code is invalid or expired"})
|
||||
return
|
||||
}
|
||||
+ if p.Challenge != nil {
|
||||
+ writeJSON(w, http.StatusOK, p.Challenge)
|
||||
+ return
|
||||
+ }
|
||||
writeSession(w, app, p.Token, p.User, p.Action, classes.ActionLogin, p.ReturnTo)
|
||||
}
|
||||
}
|
||||
diff --git a/controllers/register_complete.go b/controllers/register_complete.go
|
||||
index 647775f..48d6254 100644
|
||||
--- a/controllers/register_complete.go
|
||||
+++ b/controllers/register_complete.go
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
// only inside the final transaction, and a request that loses that race
|
||||
// answers 410. Responses follow the PHP API: 200 {token, user, action
|
||||
// (register default), return_to}, 422 {error[, errors]}, 410 {error}.
|
||||
+// When the sign-in of an existing account is held back by a login gate
|
||||
+// (D-09), it answers 200 with exactly the gate's body instead.
|
||||
func RegisterComplete(app *backpack.App) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
fields, err := readFields(r)
|
||||
@@ -107,6 +109,10 @@ func RegisterComplete(app *backpack.App) http.HandlerFunc {
|
||||
}
|
||||
return
|
||||
}
|
||||
+ if out.Challenge != nil {
|
||||
+ writeJSON(w, http.StatusOK, out.Challenge)
|
||||
+ return
|
||||
+ }
|
||||
writeSession(w, app, out.Token, out.User, out.Action, classes.ActionRegister, out.ReturnTo)
|
||||
}
|
||||
}
|
||||
diff --git a/lang/en/lang.yaml b/lang/en/lang.yaml
|
||||
index 8159c5e..2db3d73 100644
|
||||
--- a/lang/en/lang.yaml
|
||||
+++ b/lang/en/lang.yaml
|
||||
@@ -25,6 +25,7 @@ oauth:
|
||||
provider_not_configured: ":provider login is not configured. Please contact the administrator."
|
||||
invalid_action: "Invalid OAuth action specified."
|
||||
must_be_logged_in: "You must be logged in to link an OAuth account."
|
||||
+ two_factor_unavailable: "Two-factor verification is temporarily unavailable. Try again later."
|
||||
|
||||
register:
|
||||
consent_required: "You must accept the terms and the privacy policy to complete the registration."
|
||||
diff --git a/lang/pl/lang.yaml b/lang/pl/lang.yaml
|
||||
index 803e5f2..7f336e2 100644
|
||||
--- a/lang/pl/lang.yaml
|
||||
+++ b/lang/pl/lang.yaml
|
||||
@@ -25,6 +25,7 @@ oauth:
|
||||
provider_not_configured: "Logowanie przez :provider nie jest skonfigurowane. Skontaktuj się z administratorem."
|
||||
invalid_action: "Wskazano nieprawidłową akcję logowania."
|
||||
must_be_logged_in: "Musisz być zalogowany, aby połączyć konto dostawcy logowania."
|
||||
+ two_factor_unavailable: "Weryfikacja dwuetapowa jest chwilowo niedostępna. Spróbuj ponownie później."
|
||||
|
||||
register:
|
||||
consent_required: "Musisz zaakceptować regulamin i politykę prywatności, aby dokończyć rejestrację."
|
||||
diff --git a/social_gate_smoke_test.go b/social_gate_smoke_test.go
|
||||
new file mode 100644
|
||||
index 0000000..4dd5e3e
|
||||
--- /dev/null
|
||||
+++ b/social_gate_smoke_test.go
|
||||
@@ -0,0 +1,191 @@
|
||||
+package sociallogin_test
|
||||
+
|
||||
+import (
|
||||
+ "context"
|
||||
+ "errors"
|
||||
+ "net/http"
|
||||
+ "net/url"
|
||||
+ "strings"
|
||||
+ "sync"
|
||||
+ "testing"
|
||||
+
|
||||
+ "git.golem15.com/golem15/sm-sociallogin-plugin/classes"
|
||||
+ userclasses "git.golem15.com/golem15/sm-user-plugin/classes"
|
||||
+ usermodels "git.golem15.com/golem15/sm-user-plugin/models"
|
||||
+)
|
||||
+
|
||||
+// fakeGate is a login gate a test adds to golem15.user's published
|
||||
+// registry, standing in for a two-factor plugin. It answers result (or
|
||||
+// err) for the users in targets and allows everyone else, and records the
|
||||
+// attempts it saw.
|
||||
+type fakeGate struct {
|
||||
+ mu sync.Mutex
|
||||
+ targets map[uint]bool
|
||||
+ result *userclasses.LoginGateResult
|
||||
+ err error
|
||||
+ attempts []userclasses.LoginAttempt
|
||||
+}
|
||||
+
|
||||
+func (g *fakeGate) CheckLogin(_ context.Context, a userclasses.LoginAttempt) (*userclasses.LoginGateResult, error) {
|
||||
+ g.mu.Lock()
|
||||
+ defer g.mu.Unlock()
|
||||
+ g.attempts = append(g.attempts, a)
|
||||
+ if a.User == nil || !g.targets[a.User.ID] {
|
||||
+ return nil, nil
|
||||
+ }
|
||||
+ return g.result, g.err
|
||||
+}
|
||||
+
|
||||
+// set makes the gate answer result or err for user.
|
||||
+func (g *fakeGate) set(user *usermodels.User, result *userclasses.LoginGateResult, err error) {
|
||||
+ g.mu.Lock()
|
||||
+ defer g.mu.Unlock()
|
||||
+ g.targets = map[uint]bool{user.ID: true}
|
||||
+ g.result, g.err = result, err
|
||||
+ g.attempts = nil
|
||||
+}
|
||||
+
|
||||
+// calls returns the attempts seen since the last set.
|
||||
+func (g *fakeGate) calls() []userclasses.LoginAttempt {
|
||||
+ g.mu.Lock()
|
||||
+ defer g.mu.Unlock()
|
||||
+ return append([]userclasses.LoginAttempt(nil), g.attempts...)
|
||||
+}
|
||||
+
|
||||
+// TestSocialGateSmoke covers D-09: a social sign-in consults golem15.user's
|
||||
+// login gates with source social before anything signs the user in.
|
||||
+// Without a challenge it answers as before; a challenge replaces the token
|
||||
+// in oauth-complete and oauth-register-complete with the gate's body and
|
||||
+// leaves a deactivated account deactivated; a refusal redirects with the
|
||||
+// two_factor_unavailable message; a gate error fails closed; linking is
|
||||
+// never gated.
|
||||
+func TestSocialGateSmoke(t *testing.T) {
|
||||
+ e := bootSocial(t, nil)
|
||||
+ idp := registerFake(t, e.registry(t), "fake", "Fake")
|
||||
+ e.credentials(t, "fake")
|
||||
+ gates, ok := e.app.Lookup[*userclasses.LoginGates]()
|
||||
+ if !ok || gates == nil {
|
||||
+ t.Fatal("golem15.user published no login gate registry")
|
||||
+ }
|
||||
+ gate := &fakeGate{}
|
||||
+ gates.Add(gate)
|
||||
+
|
||||
+ challenge := map[string]any{
|
||||
+ "two_factor_required": true,
|
||||
+ "challenge_token": strings.Repeat("c", 64),
|
||||
+ "available_methods": []any{"totp"},
|
||||
+ "expires_at": "2026-10-26T12:05:00+00:00",
|
||||
+ }
|
||||
+ const challengeJSON = `{"available_methods":["totp"],"challenge_token":"` +
|
||||
+ "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" +
|
||||
+ `","expires_at":"2026-10-26T12:05:00+00:00","two_factor_required":true}`
|
||||
+
|
||||
+ t.Run("no_gate_unchanged", func(t *testing.T) {
|
||||
+ member := e.user(t, "")
|
||||
+ e.identity(t, member, "fake", "fake-gate-1")
|
||||
+ gate.set(&usermodels.User{}, nil, nil)
|
||||
+ idp.on("g1", classes.Profile{ID: "fake-gate-1", Email: member.Email})
|
||||
+ done := e.signIn(t, e.browser(t), "fake", spaQuery("login", "/dashboard"), "g1", nil)
|
||||
+ res, got := e.complete(t, done.Query().Get("code"))
|
||||
+ if res.StatusCode != http.StatusOK {
|
||||
+ t.Fatalf("complete: %d %v", res.StatusCode, got)
|
||||
+ }
|
||||
+ if tok, _ := got["token"].(string); tok == "" || got["user"] == nil || got["action"] != "login" || got["return_to"] != "/dashboard" {
|
||||
+ t.Fatalf("complete body %v", got)
|
||||
+ }
|
||||
+ if _, ok := got["challenge"]; ok {
|
||||
+ t.Fatalf("challenge key in a plain sign-in: %v", got)
|
||||
+ }
|
||||
+ calls := gate.calls()
|
||||
+ if len(calls) != 1 || calls[0].Source != userclasses.LoginSourceSocial || calls[0].User.ID != member.ID || calls[0].Request == nil || calls[0].Fields != nil {
|
||||
+ t.Fatalf("gate attempts %+v", calls)
|
||||
+ }
|
||||
+ })
|
||||
+
|
||||
+ t.Run("challenge_body", func(t *testing.T) {
|
||||
+ member := e.user(t, "")
|
||||
+ e.identity(t, member, "fake", "fake-gate-2")
|
||||
+ if err := e.gdb.Delete(member).Error; err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ gate.set(member, &userclasses.LoginGateResult{Status: http.StatusOK, Body: challenge}, nil)
|
||||
+ idp.on("g2", classes.Profile{ID: "fake-gate-2", Email: member.Email})
|
||||
+ done := e.signIn(t, e.browser(t), "fake", spaQuery("login", "/dashboard"), "g2", nil)
|
||||
+ code := done.Query().Get("code")
|
||||
+ if code == "" || done.Query().Get("error") != "" {
|
||||
+ t.Fatalf("callback redirect %s", done)
|
||||
+ }
|
||||
+ res, body := e.do(t, e.browser(t), http.MethodGet, "/_user/api/v1/oauth-complete?code="+url.QueryEscape(code), nil, nil)
|
||||
+ if res.StatusCode != http.StatusOK || body != challengeJSON {
|
||||
+ t.Fatalf("oauth-complete: %d %s", res.StatusCode, body)
|
||||
+ }
|
||||
+ for _, c := range res.Cookies() {
|
||||
+ if c.Value != "" {
|
||||
+ t.Fatalf("cookie %s set with a challenge", c.Name)
|
||||
+ }
|
||||
+ }
|
||||
+ var back usermodels.User
|
||||
+ if err := e.gdb.Unscoped().Where("id = ?", member.ID).Take(&back).Error; err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ if !back.DeletedAt.Valid {
|
||||
+ t.Fatal("a challenged social sign-in restored the deactivated account")
|
||||
+ }
|
||||
+
|
||||
+ // oauth-register-complete of a pending registration whose identity
|
||||
+ // now belongs to the account answers the challenge too.
|
||||
+ pending, err := classes.PutPending(t.Context(), e.app, classes.PendingPayload{Provider: "fake", ProviderID: "fake-gate-2", ReturnTo: "/welcome"})
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ res, body = e.do(t, e.browser(t), http.MethodPost, "/_user/api/v1/oauth-register-complete",
|
||||
+ strings.NewReader(`{"pending_code":"`+pending+`","terms_accepted":true,"privacy_accepted":true}`),
|
||||
+ http.Header{"Content-Type": {"application/json"}})
|
||||
+ if res.StatusCode != http.StatusOK || body != challengeJSON {
|
||||
+ t.Fatalf("oauth-register-complete: %d %s", res.StatusCode, body)
|
||||
+ }
|
||||
+ })
|
||||
+
|
||||
+ t.Run("refusal_redirects", func(t *testing.T) {
|
||||
+ member := e.user(t, "")
|
||||
+ e.identity(t, member, "fake", "fake-gate-3")
|
||||
+ gate.set(member, &userclasses.LoginGateResult{Status: http.StatusUnauthorized, Body: map[string]any{"error": "Invalid or expired challenge."}}, nil)
|
||||
+ idp.on("g3", classes.Profile{ID: "fake-gate-3", Email: member.Email})
|
||||
+ done := e.signIn(t, e.browser(t), "fake", spaQuery("login", "/dashboard"), "g3", nil)
|
||||
+ if done.Query().Get("code") != "" || done.Query().Get("error") != "Two-factor verification is temporarily unavailable. Try again later." {
|
||||
+ t.Fatalf("refusal redirect %s", done)
|
||||
+ }
|
||||
+ })
|
||||
+
|
||||
+ t.Run("gate_error_fails_closed", func(t *testing.T) {
|
||||
+ member := e.user(t, "")
|
||||
+ e.identity(t, member, "fake", "fake-gate-4")
|
||||
+ gate.set(member, nil, errors.New("gate store down"))
|
||||
+ idp.on("g4", classes.Profile{ID: "fake-gate-4", Email: member.Email})
|
||||
+ done := e.signIn(t, e.browser(t), "fake", spaQuery("login", "/dashboard"), "g4", nil)
|
||||
+ if done.Query().Get("code") != "" || done.Query().Get("error") == "" || strings.Contains(done.RawQuery, "store") {
|
||||
+ t.Fatalf("gate error redirect %s", done)
|
||||
+ }
|
||||
+ if len(gate.calls()) != 1 {
|
||||
+ t.Fatalf("gate attempts %d", len(gate.calls()))
|
||||
+ }
|
||||
+ })
|
||||
+
|
||||
+ t.Run("link_not_gated", func(t *testing.T) {
|
||||
+ member := e.user(t, "")
|
||||
+ gate.set(member, &userclasses.LoginGateResult{Status: http.StatusOK, Body: challenge}, nil)
|
||||
+ ticket := e.ticketFor(t, http.Header{"Authorization": {"Bearer " + e.sessionToken(t, member)}})
|
||||
+ idp.on("g5", classes.Profile{ID: "fake-gate-5", Email: "other-" + member.Email})
|
||||
+ done := e.signIn(t, e.browser(t), "fake", linkQuery(ticket), "g5", nil)
|
||||
+ res, got := e.complete(t, done.Query().Get("code"))
|
||||
+ if res.StatusCode != http.StatusOK || got["action"] != "link" {
|
||||
+ t.Fatalf("link: %d %v (redirect %s)", res.StatusCode, got, done)
|
||||
+ }
|
||||
+ if tok, _ := got["token"].(string); tok == "" {
|
||||
+ t.Fatalf("link without token: %v", got)
|
||||
+ }
|
||||
+ if n := len(gate.calls()); n != 0 {
|
||||
+ t.Fatalf("link consulted the gate %d times", n)
|
||||
+ }
|
||||
+ })
|
||||
+}
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
plan: 04
|
||||
subsystem: testing
|
||||
tags: [sm-user-plugin, sm-mfa-plugin, sm-sociallogin-plugin, unit-tests, security-review, phase-gate, testcontainers, webauthn, totp, device-flow, d-14]
|
||||
|
||||
requires:
|
||||
- phase: 19.6-01
|
||||
provides: login gates, password-change hook, Reset 2FA slot, device authorization (sm-user-plugin v0.1.12)
|
||||
- phase: 19.6-02
|
||||
provides: sm-mfa-plugin core (TOTP, recovery and email codes, failure cap, trusted devices, settings, admin reset)
|
||||
- phase: 19.6-03
|
||||
provides: WebAuthn and passkeys (sm-mfa-plugin v0.1.0), the social-login gate (sm-sociallogin-plugin v0.1.4), adoption in sm-demo-app, sm-bm-app, fonoteka.go
|
||||
provides:
|
||||
- scripts/check-phase19.6.sh, a fail-closed gate over seven repositories (self-test, go, userplugin, mfa, sociallogin, demo, demo-web, bm, fonoteka, docs, docker)
|
||||
- sm-user-plugin unit tests for the gate chain, Login order, password-change sources, the reset action, the whole device flow and its migration
|
||||
- sm-mfa-plugin unit tests, one per decision, the PHP bodies, the login-path invariant and the PHP security test map
|
||||
- sm-sociallogin-plugin TestSocialGate
|
||||
- 19.6-SECURITY-REVIEW.md with the explicit D-14 section; 19.6-VALIDATION.md validated
|
||||
- one post-release fix in sm-mfa-plugin (71d8f27), released as sm-mfa-plugin v0.1.1 and pinned by sm-demo-app (pushed) and sm-bm-app (committed; push waits on another session's commits)
|
||||
- finding F-1 (activate-by-code) deferred with a todo
|
||||
affects: [19.6 verification, sm-demo-app, sm-bm-app, fonoteka.go, sm-mfa-plugin release]
|
||||
|
||||
actuals:
|
||||
tokens: 97673 # MEASURED chars/4 over added lines: summercms.go e95277a..692beb5 (80239), sm-user-plugin 3b22134..1f3266a (94434), sm-mfa-plugin 33ad164..d08f1ec (204699), sm-sociallogin-plugin b752177..14d5f93 (11321)
|
||||
tasks: 6
|
||||
commits: 7 # MEASURED in summercms.go before this final SUMMARY commit: git rev-list --count e95277a..HEAD (5 Task 1-4 commits, the draft summary, the Task 6 docs commit)
|
||||
sm_demo_app_commits: 1 # 9166a1e
|
||||
sm_bm_app_commits: 1 # fe4e292
|
||||
sm_user_plugin_commits: 3 # MEASURED: git rev-list --count 3b22134..1f3266a
|
||||
sm_mfa_plugin_commits: 5 # MEASURED: git rev-list --count 33ad164..d08f1ec
|
||||
sm_sociallogin_plugin_commits: 1 # MEASURED: git rev-list --count b752177..14d5f93
|
||||
plan_head_before: e95277a21049bf92a1f427d2d9379c4d26da35d8
|
||||
plan_head_after: see the final SUMMARY commit
|
||||
sm_user_plugin_head_before: 3b22134
|
||||
sm_user_plugin_head_after: 1f3266a
|
||||
sm_mfa_plugin_head_before: 33ad164
|
||||
sm_mfa_plugin_head_after: d08f1ec
|
||||
sm_sociallogin_plugin_head_before: b752177
|
||||
sm_sociallogin_plugin_head_after: 14d5f93
|
||||
sm_demo_app_head_before: bb24207
|
||||
sm_demo_app_head_after: 9166a1e
|
||||
sm_bm_app_head_before: 4759349
|
||||
sm_bm_app_commit: fe4e292
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Phase gate per phase: go test -json detector refusing fail, skip, zero tests and missing names; --self-test on planted output"
|
||||
- "Token-mint inventory test: every mint call site read from the source and listed with its reason"
|
||||
- "Dry-run GORM dialector in tests to run DB-touching ceremony code without Postgres"
|
||||
- "Mutation checks on guarded UPDATEs recorded in the security review"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- scripts/check-phase19.6.sh
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-SECURITY-REVIEW.md
|
||||
- .planning/todos/pending/2026-10-26-activate-by-code-second-factor.md
|
||||
- ../fonoteka.go/plugins/golem15/user/login_gate_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/password_changed_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/reset_two_factor_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/device_auth_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/classes/device_auth_test.go
|
||||
- ../fonoteka.go/plugins/golem15/user/updates/device_auth_sessions_test.go
|
||||
- ../sm-mfa-plugin/{gate,challenge,totp,recovery,email,trusted,settings,status,admin,tokens_at_rest,migrations,webauthn,passwordless,routes,php_bodies,login_paths,php_method_map,php_port}_test.go
|
||||
- ../sm-mfa-plugin/testdata/PHP_METHOD_MAP.md
|
||||
- ../sm-mfa-plugin/testdata/php_methods.txt
|
||||
- ../sm-sociallogin-plugin/social_gate_test.go
|
||||
modified:
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-VALIDATION.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/deferred-items.md
|
||||
- ../fonoteka.go/plugins/golem15/user/README.md
|
||||
- ../fonoteka.go/plugins/golem15/user/updates/postgres_test.go
|
||||
- ../sm-mfa-plugin/{classes/config.go,models/settings.go,lang/en/lang.yaml,lang/pl/lang.yaml,README.md,harness_test.go}
|
||||
- ../sm-sociallogin-plugin/README.md
|
||||
- ../sm-demo-app/{plugins/golem15/mfa,go.mod,go.sum}
|
||||
- ../sm-bm-app/plugins/golem15/mfa
|
||||
|
||||
key-decisions:
|
||||
- "An empty settings list (methods or enforce groups) is an empty value and falls back to the configuration, as the README promised; the form stores it as NULL (sm-mfa-plugin 71d8f27, post-release fix)"
|
||||
- "Error bodies are pinned byte for byte; multi-key success bodies by key set and fixed values, because Go maps sort keys where PHP kept insertion order (recorded, not changed)"
|
||||
- "Finding F-1 (activate-by-code mints without the second factor when require_activation is off) was raised at Task 5 and deferred by the user with a todo; the accepted-debt reason is corrected in the security review"
|
||||
- "Task 5 reply: release sm-mfa-plugin v0.1.1 with demo and bm pointer bumps, defer F-1, push the test-only commits; no tags for the user or social plugins"
|
||||
|
||||
patterns-established:
|
||||
- "check-phase<N>.sh stage per repository, names appended per plan, docker NOT RUN explicit"
|
||||
|
||||
requirements-completed: [SC-4, D-02, D-05, D-06, D-07, D-08, D-09, D-10, D-11, D-12, D-12a, D-12b, D-12c, D-13, D-14, D-15, D-16, D-17, D-18, D-19]
|
||||
|
||||
duration: about 76 min to the Task 5 checkpoint (12:50Z to 14:06Z), then about 20 min for Task 6 (14:15Z to 14:35Z)
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6 Plan 04: Unit tests and security review Summary
|
||||
|
||||
**Status: complete.** All 6 tasks are done. The whole gate passes across seven repositories with Docker. The one post-release fix (sm-mfa-plugin `71d8f27`) shipped as **sm-mfa-plugin v0.1.1**. sm-demo-app is pinned to it and pushed. sm-bm-app is pinned in a local commit; its push waits because its unpushed range also holds another session's phase 03.2 commits. Finding F-1 is deferred with a todo.
|
||||
|
||||
**One fail-closed gate over seven repositories, 41 new named unit tests across sm-user-plugin, sm-mfa-plugin and sm-sociallogin-plugin (one per decision, the PHP bodies, the token-mint inventory and every login path), the PHP security test mapped, a security review with the D-14 passkey section, one real defect fixed (an untouched settings form disabled every second factor) and one finding raised (activate-by-code).**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Started:** 2026-10-26T12:50Z
|
||||
- **Checkpoint (Task 5):** 2026-10-26T14:06Z
|
||||
- **Task 6:** 2026-10-26T14:15Z to 14:35Z
|
||||
- **Tasks:** 6 of 6
|
||||
|
||||
## Commits per repository (in order)
|
||||
|
||||
**summercms.go** (base `e95277a`):
|
||||
|
||||
| Task | Commit | Message |
|
||||
|------|--------|---------|
|
||||
| 1 | `947009a` | test(19.6): fail-closed phase gate |
|
||||
| 2 | `e9785f7` | test(19.6): gate requires the user-plugin unit tests |
|
||||
| 3 | `531e7ab` | test(19.6): gate requires the mfa and social gate tests |
|
||||
| 4 | `ea4680e` | test(19.6): gate requires the PHP map |
|
||||
| 4 | `692beb5` | docs(19.6): security review and validation map |
|
||||
|
||||
**sm-user-plugin** (`../fonoteka.go/plugins/golem15/user`, base `3b22134` = v0.1.12; branch master, 3 commits ahead of origin):
|
||||
|
||||
| Task | Commit | Message |
|
||||
|------|--------|---------|
|
||||
| 2 | `6844d36` | test: login gates, password-changed sources and the reset action |
|
||||
| 2 | `2c68979` | test: start the updates package's Postgres only without -short |
|
||||
| 2 | `1f3266a` | test: device authorization flow and its migration |
|
||||
|
||||
**sm-mfa-plugin** (base `33ad164` = v0.1.0):
|
||||
|
||||
| Task | Commit | Message |
|
||||
|------|--------|---------|
|
||||
| 3 | `71d8f27` | fix: an empty settings list falls back to the configuration |
|
||||
| 3 | `8ec140e` | test: TOTP, QR, recovery and email codes, the gate, challenges and the failure cap |
|
||||
| 3 | `2aff160` | test: trusted devices, revocation, settings, status, admin reset, tokens at rest and migrations |
|
||||
| 3 | `ab886f8` | test: WebAuthn, passkeys, routes, PHP bodies and the login-path invariant |
|
||||
| 4 | `d08f1ec` | test: PHP security test map |
|
||||
|
||||
**sm-sociallogin-plugin** (base `b752177` = v0.1.4):
|
||||
|
||||
| Task | Commit | Message |
|
||||
|------|--------|---------|
|
||||
| 3 | `14d5f93` | test: social sign-in gate |
|
||||
|
||||
**Task 6 (applications):**
|
||||
|
||||
| Repository | Commit | Message |
|
||||
|------------|--------|---------|
|
||||
| sm-demo-app | `9166a1e` | chore: bump sm-mfa-plugin to v0.1.1 (gitlink `plugins/golem15/mfa` to `d08f1ec`, go.mod require v0.1.1, go.sum tidied: only the mfa lines changed) |
|
||||
| sm-bm-app | `fe4e292` | chore: bump sm-mfa-plugin to v0.1.1 (gitlink only; bm uses a replace) |
|
||||
|
||||
fonoteka.go has no commit from this plan. The user plugin has no release, so its pointer needs no bump. fonoteka.go's working tree shows ` M plugins/golem15/user`, because the submodule sits on the three pushed test commits while the committed pointer is still `3b22134`. fonoteka.go was not pushed.
|
||||
|
||||
## Remote operations (in order)
|
||||
|
||||
Before every push I ran `git fetch` and checked that `origin/master..master` held only this plan's commits and that nothing was behind. Nothing was force-pushed or deployed.
|
||||
|
||||
| Repository | Ref | Before → after |
|
||||
|------------|-----|----------------|
|
||||
| sm-user-plugin | `refs/heads/master` | `3b22134` → `1f3266a417777bc0fcf3b7ea3578d0d053150e9f` (3 test commits; no tag) |
|
||||
| sm-mfa-plugin | `refs/heads/master` | `33ad164` → `d08f1ec430686ac99da9c30ca85a56fc6e80995e` (5 commits) |
|
||||
| sm-mfa-plugin | `refs/tags/v0.1.1` (annotated) | new: tag object `c461c61cab41bda3ec097413fd79e5a2371fcfb1` → commit `d08f1ec430686ac99da9c30ca85a56fc6e80995e`; the message names the modes disabled, optional and enforced |
|
||||
| sm-sociallogin-plugin | `refs/heads/master` | `b752177` → `14d5f93302082d5b94b574d6c7c24e5e60dbd902` (1 test commit; no tag) |
|
||||
| sm-demo-app | `refs/heads/master` | `bb24207` → `9166a1ec5be5b689b766271214523d00a07b125d` (exactly the bump commit; the leftover journal and oauthserver moves stay unstaged) |
|
||||
| sm-bm-app | not pushed | `origin/master` is still `ebb2266`. `origin/master..master` holds 7 commits: 6 phase 03.2 planning commits of another session (`17e8bf8`, `a5e1d9a`, `a16ba1d`, `009ff98`, `4759349`, then `8733060` made on top of my bump while I worked) plus my `fe4e292`. Pushing master would publish that session's commits, so I left it for the user or that session. |
|
||||
|
||||
`ls-remote` confirms the four branch heads and the tag above.
|
||||
|
||||
## merge-base results (fix `71d8f27` against every pin, in sm-mfa-plugin)
|
||||
|
||||
| Pin | Commit | `merge-base --is-ancestor 71d8f27 <pin>` |
|
||||
|-----|--------|----------------------------------------|
|
||||
| tag v0.1.1 | `d08f1ec` | 0 |
|
||||
| sm-demo-app `plugins/golem15/mfa` gitlink at origin/master `9166a1e` | `d08f1ec` | 0 |
|
||||
| sm-demo-app go.mod require v0.1.1 | `d08f1ec` | 0 |
|
||||
| sm-bm-app `plugins/golem15/mfa` gitlink at master (`fe4e292`, also in HEAD `8733060`) | `d08f1ec` | 0 |
|
||||
|
||||
Task 6 verify at the final pins:
|
||||
- `--demo`, `--bm` and `--fonoteka` pass.
|
||||
- sm-demo-app also passes a module-mode release build (`GOWORK=off go build -trimpath -tags summercms_mcp`, which fetches sm-mfa-plugin v0.1.1 anonymously, now that the repository is public) and `go test -short ./...`.
|
||||
- sm-bm-app passes `go test -short ./...`.
|
||||
|
||||
## Tests added (names the gate requires)
|
||||
|
||||
- **sm-user-plugin, Docker-free:** `TestLoginGates` (also under `-race`), `TestDeviceAuthURL`, `TestDeviceDisplayName`, `TestDeviceCodes` (classes).
|
||||
- **sm-user-plugin, Postgres:** `TestLoginGateOrder`, `TestPasswordChangedSources`, `TestResetTwoFactorAction`, `TestDeviceInitiate`, `TestDeviceStatus`, `TestDeviceAuthorize`, `TestDeviceHandOverConcurrent`, `TestDeviceListAndRevoke`, `TestDeviceRevokeAfterRefresh`, `TestDeviceTokensAtRest`, `TestDeviceAuthSessionsMigration` (updates).
|
||||
- **sm-mfa-plugin, Docker-free:** `TestTOTP`, `TestQRSVG`, `TestRecoveryCodeFormat`, `TestMaskEmail`, `TestEmailExpiryMinutes`, `TestWebAuthnShapes`, `TestRoutesAndBuckets`, `TestPHPMethodMap`, `TestPHPUser005`.
|
||||
- **sm-mfa-plugin, Postgres:** `TestGate`, `TestChallengeLifecycle`, `TestFailureCap`, `TestRecovery`, `TestEmailCode`, `TestTrustedDevice`, `TestRevocation`, `TestSettings`, `TestStatusShape`, `TestAdminReset`, `TestTokensAtRest`, `TestMigrations`, `TestWebAuthn`, `TestPasswordless`, `TestPHPErrorBodies`, `TestEveryLoginPathIsGated`.
|
||||
- **sm-sociallogin-plugin, Postgres:** `TestSocialGate`.
|
||||
- The smoke tests of plans 01-03 stay and are required by name too.
|
||||
|
||||
## Gate stages (`scripts/check-phase19.6.sh --all`, clean run 13:59Z, 4 m 55 s)
|
||||
|
||||
| Stage | State | What ran |
|
||||
|-------|-------|----------|
|
||||
| self-test | PASS | detectors on planted output, additive, pin, mount and migration checks, docker NOT RUN rule on a faked PATH |
|
||||
| go | PASS | vet and `-short` of the framework; its go.mod requires none of the three libraries |
|
||||
| userplugin | PASS | vet and `-short` through the fonoteka.go workspace, 5 + 1 (`-race`) + 1 (classes) named tests, additive check against `50da92c` (56 declarations added, none removed or changed), migration check (only `202610260001_create_device_auth_sessions` added) |
|
||||
| mfa | PASS | vet and `-short`, 11 named tests, no `gopkg.in/yaml.v3`, the three pins in go.mod |
|
||||
| sociallogin | PASS | vet and `-short`, 9 named tests, Phase 19.5 dependency rules |
|
||||
| demo | PASS | build, vet, `TestBootAllPlugins`, `TestGoModRequiresTags`, `TestMFAMounted` |
|
||||
| demo-web | PASS | `pnpm test`: 202 tests, `app/lib/twoFactor.test.ts` required |
|
||||
| bm | PASS | build, vet, `TestSocialLoginMounted`, `TestMFAMounted` |
|
||||
| fonoteka | PASS | vet and `-short` of the root and the four workspace modules; no golem15.mfa mount; no go-webauthn, pquerna or boombuler module |
|
||||
| docs | PASS | decision note pins, STACK rows, `TestDocsTree`, `docs:build --check`, no consuming application named in modules/, docs/ or the two plugin READMEs |
|
||||
| docker | PASS | 15 + 1 user-plugin, 21 mfa and 2 sociallogin Postgres tests by name |
|
||||
|
||||
**Docker:** reachable as golem; no stage was NOT RUN. Not part of the gate (scoped out, predating this phase, deferred-items.md): the five Docker-backed failures in fonoteka.go's `plugins/golem15/fonoteka` (the fonoteka stage runs `-short`), and sm-demo-app's `scripts/build.sh release`, which refuses the leftover journal and oauthserver submodule moves. **NOT RUN:** a real-browser WebAuthn ceremony and the demo screens in a browser (manual-only, 19.6-VALIDATION.md).
|
||||
|
||||
Mutation checks (19.6-SECURITY-REVIEW.md "Method"): seven mitigations removed one at a time, each caught by its test, each reverted. The first `--all` run overlapped those edits, so the result above is a second, clean run.
|
||||
|
||||
## Defects found and fixed
|
||||
|
||||
| Commit | Repo | Found by | Defect | Fix |
|
||||
|--------|------|----------|--------|-----|
|
||||
| `71d8f27` | sm-mfa-plugin | `TestSettings/form_round_trip_keeps_the_configuration` (written for this) | The admin form shows a NULL method list as an empty taglist and sends `[]` back on every save, so saving the settings once stored `[]` and made every method unavailable (TOTP setup answered 403). | Empty lists are stored as NULL (`Settings.BeforeValidate`) and an empty stored list falls back to the configuration (`overlay`), as the README promised; README and en/pl comments updated. |
|
||||
| `2c68979` | sm-user-plugin (test harness) | the gate's userplugin stage | The `updates` package's TestMain scanned `os.Args` for `-test.short`, so every `-short` run started Postgres (and would fail without Docker). | `flag.Parse` and `testing.Short()`, as CLAUDE.md prescribes. Test-only. |
|
||||
|
||||
## Post-release fixes
|
||||
|
||||
Production commits this plan made after plan 03's release (outside `*_test.go`, `testdata/` and README-only changes), against every pin that lacks them:
|
||||
|
||||
| Repository | Commit | Files | Released pins that lack it |
|
||||
|------------|--------|-------|----------------------------|
|
||||
| sm-mfa-plugin | `71d8f27` | `classes/config.go`, `models/settings.go`, `lang/en/lang.yaml`, `lang/pl/lang.yaml`, `README.md` | tag `v0.1.0` (`33ad164`); sm-demo-app gitlink `plugins/golem15/mfa` (`33ad164`) and its go.mod require `sm-mfa-plugin v0.1.0`; sm-bm-app gitlink `plugins/golem15/mfa` (`33ad164`) |
|
||||
|
||||
At the checkpoint, `merge-base --is-ancestor 71d8f27 33ad164` exited 1 (no pin contained the fix) and `tag --points-at HEAD` was empty. sm-user-plugin and sm-sociallogin-plugin had test and README commits only, so there was nothing to release there. After Task 6 every pin contains the fix (table above).
|
||||
|
||||
## Task 5 reply
|
||||
|
||||
Plan 03's Task 4 reply did not pre-authorise patch releases for this plan, so the checkpoint went to the user. The user's decision, relayed verbatim by the orchestrator (from AskUserQuestion):
|
||||
|
||||
> 1. RELEASE. Tag sm-mfa-plugin v0.1.1 on its current HEAD, which includes 71d8f27 and the test commits. The tag message names the modes correctly: disabled/optional/enforced. Push master and the tag. Then, in separate commits:
|
||||
> - sm-demo-app: bump plugins/golem15/mfa to that commit, update go.mod's require to v0.1.1, and go.sum.
|
||||
> - sm-bm-app: bump the plugins/golem15/mfa gitlink.
|
||||
> Fetch first and check the range before pushing both. In sm-demo-app, leave the unstaged journal/oauthserver pointer moves alone. Mark the deferred tag-message item resolved.
|
||||
> 2. F-1: DEFER. Write a todo in .planning/todos/pending/ and record F-1 as deferred in the security review, with the corrected reasoning. I'll mirror it to g15office.
|
||||
> 3. YES, push the test-only commits on master: sm-user-plugin (3), sm-mfa-plugin (part of item 1) and sm-sociallogin-plugin (1). No new tags for user or social. Never push fonoteka.go.
|
||||
> No sudo, no force-push and no deploy. Then do Task 6, finalize the SUMMARY and commit it. In the report, list every pushed ref and tag with its SHA.
|
||||
|
||||
Carried out as written, with one exception. The fetch and range check before pushing sm-bm-app found commits of another session, so sm-bm-app is committed but not pushed (Remote operations).
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Gate (Task 1).** `scripts/check-phase19.6.sh` copies check-phase19.5.sh's detector, adds the mfa, demo-web and fonoteka module checks, an additive check that also catches removed or changed const and var declarations (gofmt realignment and moves pass), and the device-session migration check. `--self-test` proves every detector on planted output.
|
||||
- **sm-user-plugin (Task 2).** The gate chain and Login's order (refused first factors never reach a gate; rehash before a challenge; restore and reactivate mail only after the gates; gate answers pass through; refresh never asks a gate); each password-change source fires once in its transaction (a listener's write commits with it, its error rolls both back); the reset action's offer, permission, transaction and rollback; the device flow in every state and refusal, including 50 concurrent polls, 10 concurrent authorizes by two users, the bounded cleanup, a real short-code collision forced by a trigger, revoke after one and two refreshes and the migration's constraints.
|
||||
- **sm-mfa-plugin (Task 3).** One test per decision of RESEARCH's map (above), the PHP bodies of both route tables, and `TestEveryLoginPathIsGated`, which reads every token mint site of golem15.user and golem15.mfa from source and fails on any unlisted one, then drives each first-factor path of a TOTP user.
|
||||
- **sm-sociallogin-plugin (Task 3).** `TestSocialGate` over an existing identity, a verified email match and a new account, in token-cookie mode.
|
||||
- **PHP map, review, validation (Task 4).** `AuthenticationTest.php` has 3 methods: USER-003 maps to `TestStateCookie` (sociallogin, adapted), USER-004 is not applicable (no PIN routes in Go), USER-005 to `TestPHPUser005`. The review maps T-19.6-01..38 and the four SC rows, has the D-14 and D-18 sections, ASVS notes, a log sweep, residual risks and F-1.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
**1. [Rule 1 - Bug] Settings form disabled every method (sm-mfa-plugin `71d8f27`).** See "Defects found and fixed". A production change after the release, hence the Post-release fixes row and the Task 5 stop.
|
||||
|
||||
**2. [Rule 3 - Blocking] updates TestMain short detection (sm-user-plugin `2c68979`).** Test-only; needed so the userplugin stage's `-short` run is Docker-free as the gate's NOT RUN rule assumes.
|
||||
|
||||
**3. [Rule 4 - raised, deferred] Finding F-1, activate-by-code.** Reproduced through the mfa harness (`require_activation: false`, `activate_mode: user`: password login, TOTP enabled, activate-by-code answers a token without a challenge). Plan 01 accepted this path because "a not-yet-activated account cannot have 2FA yet", which is false in that configuration. Fixing it changes a recorded decision and an endpoint's answer and needs a user-plugin release, so it went to the Task 5 decision. The user deferred it: todo `2026-10-26-activate-by-code-second-factor.md`, security review "Deferred findings" with the corrected reason.
|
||||
|
||||
**4. [Carry-forward] D-07 follows the code.** `TestPasswordChangedSources` listens on `AccessRevokedEvent` and checks `PasswordChanged()` (no `PasswordChangedEvent` exists). The administrator's save fires from `FormBeforeUpdate`, before cabana writes the record in the same transaction, so a listener reads the old hash there; the test pins that and proves the transaction with a marker write that commits or rolls back with the password.
|
||||
|
||||
**5. [Carry-forward] Migration and base.** The gate allows `202610260001_create_device_auth_sessions` (the plan's `202610210002` is named in a comment); the additive base is `50da92c` (v0.1.11), overridable with `PHASE196_USER_BASE`.
|
||||
|
||||
**6. [Plan text vs code] An enabled webauthn row without a credential passes the gate.** The plan said such a user is "challenged with available_methods [] as PHP"; plan 02 deviation 7 chose to challenge only with a usable method. `TestGate/no_usable_method_passes` pins the code.
|
||||
|
||||
**7. [Adapted] Success bodies compared by keys.** `TestPHPErrorBodies` compares every error and 422 body byte for byte, but multi-key success bodies by key set and fixed values: Go maps emit sorted keys, PHP kept insertion order. Recorded as an observation (security review, deferred-items.md), not changed.
|
||||
|
||||
**8. [Adapted] Management 401 bodies.** An unauthenticated management call is answered by golem15.user's jwt.auth (`{"error":true,"message":"Token not provided"}`, `"Wrong number of segments"`, `"User not found"`) before the handler, so the handler's `{"error":"Unauthorized"}` is unreachable; the test pins the reachable bodies. Likewise surf checks the `{id}` digit constraint inside the middleware chain, so without a session a non-numeric id gets 401; with a session it gets the router's 404 (`TestWebAuthn`).
|
||||
|
||||
**9. [Adapted] Short-code input.** Surrounding whitespace is trimmed from the field; inner spaces count toward the 8-character check (422), as PHP's hyphen-only strip did. Pinned in `TestDeviceAuthorize`.
|
||||
|
||||
**10. [Test design] Dry-run GORM handle.** `TestWebAuthnShapes` runs the plugin's own `BeginRegistration` and `FinishRegistration` on a dry-run dialector (gorm's own packages, no new module), so the creation options and the single-use state are pinned without Postgres.
|
||||
|
||||
**11. [Scope] fonoteka stage runs every workspace module.** The root `./...` covers only the root module (plan 03 found this), so the stage also vets and short-tests `plugins/golem15/{feedback,fonoteka,golem,user}`.
|
||||
|
||||
**12. [Environment] sm-user-plugin checkout was on a detached HEAD at `3b22134`.** The first test commit landed detached; `master` (at `3b22134`, the same commit) was checked out and fast-forwarded to it. No history changed.
|
||||
|
||||
**13. [Orchestrator update] sm-mfa-plugin is public.** The gate needs no credential note; deferred-items.md marks the private-repository item resolved.
|
||||
|
||||
**14. [Range check, Task 6] sm-bm-app not pushed.** Its unpushed range includes six phase 03.2 planning commits of another session (one made on top of my bump while I worked). The reply asked for a range check before pushing, and that check failed, so the bump `fe4e292` is committed but unpushed. To publish it: `git -C sm-bm-app push origin master`, once that session's commits may go out too.
|
||||
|
||||
**Total deviations:** 14 (1 bug fixed in production and released, 1 test-harness fix, 1 finding raised and deferred, 2 carry-forwards, 1 plan-text mismatch, 3 adapted assertions, 1 test design, 1 scope, 2 environment, 1 push held back by the range check).
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None: plan 04 adds tests, a script and documents; the one production change narrows behaviour to what the README documents.
|
||||
|
||||
## Issues and follow-ups
|
||||
|
||||
- **F-1:** deferred; todo `.planning/todos/pending/2026-10-26-activate-by-code-second-factor.md` (the user mirrors it to g15office). The corrected reason is in the security review "Deferred findings".
|
||||
- **sm-bm-app push:** pending, see deviation 14.
|
||||
- **deferred-items.md** gains three items:
|
||||
- the `classes` package of sm-user-plugin starts Postgres under `-short` (predates the phase; same fix as `2c68979`);
|
||||
- the JSON key-order observation;
|
||||
- F-1, deferred.
|
||||
|
||||
It marks two items resolved: the private repository (made public) and the v0.1.0 tag message (v0.1.1 names the modes correctly).
|
||||
- **fonoteka.go:** the user submodule sits three pushed test commits ahead of its committed pointer. No release is needed; bump it only if wanted.
|
||||
- **Changelog:** CLAUDE.md asks for a summercms.io changelog post per release tag of the framework (`vX.Y.Z` of summercms.go). v0.1.1 is a plugin tag, so no post was made. The user decides if one is wanted.
|
||||
|
||||
## g15office
|
||||
|
||||
This executor has no g15office tool. The orchestrator posts the plan 04 update on milestone task `avoroeb4`: gate all 11 stages PASS with Docker; sm-mfa-plugin v0.1.1 released; F-1 deferred (the user mirrors the todo).
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- Commits exist: summercms.go `947009a`, `e9785f7`, `531e7ab`, `ea4680e`, `692beb5`; sm-user-plugin `6844d36`, `2c68979`, `1f3266a`; sm-mfa-plugin `71d8f27`, `8ec140e`, `2aff160`, `ab886f8`, `d08f1ec`; sm-sociallogin-plugin `14d5f93`.
|
||||
- Files exist: `scripts/check-phase19.6.sh` (executable), `19.6-SECURITY-REVIEW.md`, the test files listed in key-files, `../sm-mfa-plugin/testdata/PHP_METHOD_MAP.md` and `php_methods.txt`.
|
||||
- Acceptance greps of Tasks 1-4 pass (gate: `PHASE196_REQUIRE_DOCKER` 7, mode lines 12, `TestWebAuthnCeremonySmoke` 2, `202610210002_create_device_auth_sessions` 2; review: T-19.6 references 44, `D-14` 4; validation: `nyquist_compliant: true` 1, `check-phase19.6.sh` 10).
|
||||
- Task 6:
|
||||
- Commits `9166a1e` (sm-demo-app) and `fe4e292` (sm-bm-app) exist.
|
||||
- The tag v0.1.1 and every pushed head match `ls-remote`.
|
||||
- The todo file exists.
|
||||
- Working trees:
|
||||
- summercms.go keeps only other sessions' `STATE.md`, `state.json` and untracked paths.
|
||||
- The three plugin repositories are clean and even with origin.
|
||||
- sm-demo-app keeps only the leftover journal and oauthserver moves.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Phase 19.6 code review disposition
|
||||
|
||||
Review: 19.6-REVIEW.md (1 critical, 8 warning, 10 info). Fixes: 19.6-REVIEW-FIX.md. User decision 2026-10-26: fix the critical and all warnings, release, defer what needs a contract change.
|
||||
|
||||
| ID | Severity | Status | Note |
|
||||
|---|---|---|---|
|
||||
| CR-01 | critical | fixed | sm-user-plugin cc3636c, released v0.1.13 |
|
||||
| WR-01 | warning | fixed | sm-user-plugin 07196a4, released v0.1.13 (auth_url default and User-Agent-bound poll in release notes) |
|
||||
| WR-02 | warning | fixed | sm-mfa-plugin eb555e8, released v0.1.2 |
|
||||
| WR-03 | warning | fixed | sm-user-plugin 557c03c, released v0.1.13 |
|
||||
| WR-04 | warning | fixed | sm-user-plugin 20e7b17, released v0.1.13 |
|
||||
| WR-05 | warning | deferred | partial mitigation sm-mfa-plugin 463c750 (v0.1.2); full fix needs an API change: todo 2026-10-26-mfa-factor-changes-need-reauth.md, g15office krt3vrts |
|
||||
| WR-06 | warning | fixed | sm-mfa-plugin 0a08070, released v0.1.2 |
|
||||
| WR-07 | warning | fixed | sm-mfa-plugin f71d35d, released v0.1.2 |
|
||||
| WR-08 | warning | fixed | sm-sociallogin-plugin ecfb8a7, released v0.1.5 |
|
||||
| IN-01..IN-10 | info | open | outside the fix scope the user chose; listed in 19.6-REVIEW.md |
|
||||
@@ -0,0 +1,180 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
fixed_at: 2026-10-26T16:40:00Z
|
||||
review_path: .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-REVIEW.md
|
||||
iteration: 1
|
||||
findings_in_scope: 9
|
||||
fixed: 8
|
||||
partial: 1
|
||||
skipped: 0
|
||||
status: partial
|
||||
---
|
||||
|
||||
# Phase 19.6: Code Review Fix Report
|
||||
|
||||
**Fixed at:** 2026-10-26T16:40:00Z
|
||||
**Source review:** .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-REVIEW.md
|
||||
**Iteration:** 1
|
||||
**Scope:** CR-01 and WR-01..WR-08 (critical_warning); the ten info findings were left alone.
|
||||
|
||||
**Summary:**
|
||||
- Findings in scope: 9
|
||||
- Fixed: 8 (5 of them flagged for human verification of the logic)
|
||||
- Partial: 1 (WR-05; a full fix needs an API contract change)
|
||||
- Skipped: 0
|
||||
|
||||
`workflow.use_worktrees` is `false`, so every fix was edited, tested and committed in the main checkout of the repository that owns it. Nothing was pushed or tagged. The plugin commits carry no planning IDs and no trailers.
|
||||
|
||||
| Finding | Outcome | Repo | Commit | Regression test |
|
||||
|---------|---------|------|--------|-----------------|
|
||||
| CR-01 | fixed: requires human verification | sm-user-plugin | cc3636c | `TestDeviceRevokeRacesRefresh` |
|
||||
| WR-01 | fixed: requires human verification | sm-user-plugin | 07196a4 | `TestDeviceInitiate/answer_and_row`, `TestDeviceAuthorize/token_field_takes_the_short_code`, `TestDeviceHandOverConcurrent/only_the_initiating_client_collects_the_token`, `TestDeviceAuthURL`, `TestDeviceFlowSmoke` |
|
||||
| WR-02 | fixed: requires human verification | sm-mfa-plugin | eb555e8 | `TestChallengeAfterRevocation` |
|
||||
| WR-03 | fixed: requires human verification | sm-user-plugin | 557c03c | `TestDeviceAccessRevocation` |
|
||||
| WR-04 | fixed | sm-user-plugin | 20e7b17 | `TestResetTwoFactorAction/privileged_member_needs_the_privileged_permission` |
|
||||
| WR-05 | partial | sm-mfa-plugin | 463c750 | `TestPasswordless/password_change_demotes_passkeys` |
|
||||
| WR-06 | fixed | sm-mfa-plugin | 0a08070 | `TestPasswordConfirmationThrottle` |
|
||||
| WR-07 | fixed: requires human verification | sm-mfa-plugin | f71d35d | `TestCompletionFailureSpendsNothing`, `TestEveryLoginPathIsGated` (lists updated) |
|
||||
| WR-08 | fixed: requires human verification | sm-sociallogin-plugin | ecfb8a7 | `TestChallengedSignInFiresOnCompletion` |
|
||||
|
||||
Each regression test was checked against the unfixed code (the fix's source files stashed, the test run, the stash restored): every one failed without its fix and passes with it.
|
||||
|
||||
## Fixed Issues
|
||||
|
||||
### CR-01: A device revoke is lost to a concurrent refresh or a failed jti hand-over
|
||||
|
||||
**Files modified:** `fonoteka.go/plugins/golem15/user/classes/device_auth.go`, `controllers/api_controller.go`, `controllers/devices.go`, `device_auth_test.go`, `README.md`
|
||||
**Commit:** cc3636c (sm-user-plugin)
|
||||
**Status:** fixed: requires human verification (race and state handling)
|
||||
**Applied fix:**
|
||||
- `DeviceDestroy` no longer reads the jti with a plain SELECT. It revokes with `UPDATE … RETURNING jwt_jti` inside the transaction and blacklists the returned jti. That jti is read under the row lock, and a row that is gone answers the same 404 as before.
|
||||
- The new `classes.FollowDeviceJTI(ctx, db, oldJTI, newJTI) (revoked bool, err error)` makes the guarded hand-over UPDATE (which takes the same row lock). When nothing moved but a session with the old jti exists in another status, it reports `revoked`. `HandOverDeviceJTI` keeps its signature as a wrapper.
|
||||
- `Refresh` calls the hand-over before stamping last_seen and fails closed:
|
||||
- a revoked lineage answers 401 with the body bouncer gives a blacklisted token, `{"error":"Could not refresh token","msg":"The token has been blacklisted"}`, and the new token is never sent;
|
||||
- a hand-over error answers the opaque 500 (it was only logged before).
|
||||
- Blacklisting the unsent `next` token is unnecessary, because it never leaves the server.
|
||||
- Whichever side commits second now sees the other. The `blacklist_grace > 0` fork stays the documented residual risk.
|
||||
|
||||
### WR-01: The device token in the QR code is also the credential that collects the session JWT
|
||||
|
||||
**Files modified:** `fonoteka.go/plugins/golem15/user/classes/device_auth.go`, `config/config.yaml`, `controllers/devices.go`, `device_auth_test.go`, `device_flow_smoke_test.go`, `README.md`
|
||||
**Commit:** 07196a4 (sm-user-plugin)
|
||||
**Status:** fixed: requires human verification (default value change, see contract note)
|
||||
**Applied fix:** the polling secret is kept off the screen without changing any response shape:
|
||||
- **Template placeholder.** `golem15.user.device_auth.auth_url` supports a new `{short_code}` placeholder (`classes.DeviceAuthURLFor(app, token, shortCode)`; `DeviceAuthURL` keeps its signature). The default is now `{frontend_url}/device/scan/{short_code}`, so `auth_url` (the QR code) carries only the short code.
|
||||
- **Authorize accepts the short code as `token`.** `POST /devices/authorize` accepts a short code in its `token` field (a 64-character device token never normalizes as one). A scan page that posts whatever its URL carries as `token` therefore works with both templates.
|
||||
- **Hand-over bound to the initiating client.** `GET /devices/status/{token}` hands the session token only to a poll with the `User-Agent` stored at initiate. Another client gets the existing `{"success":true,"data":{"status":"confirmed"}}` and consumes nothing, so the device still collects its session.
|
||||
|
||||
**Contract note:** body shapes and keys are unchanged, but two values and behaviours are new:
|
||||
- The *value* of `auth_url` changes for apps that do not set `device_auth.auth_url`. sm-demo-app, sm-bm-app and fonoteka.go set no override. I found no frontend in the workspace that calls the device routes.
|
||||
- The token hand-over now requires the same `User-Agent` at initiate and poll. A device client that initiates through a server-side proxy and polls from the browser (different User-Agents) would wait until expiry. The PHP status route never handed over a token (that is Go's D-12a), so this binding constrains only the new Go contract.
|
||||
|
||||
A separate `poll_token` key would be the clean RFC 8628-style fix if the contract may grow.
|
||||
|
||||
### WR-02: Challenge completion mints a token for a user banned, or whose password changed, after the password step
|
||||
|
||||
**Files modified:** `sm-mfa-plugin/classes/challenge.go`, `classes/admin.go`, `controllers/challenge.go`, `revoked_challenge_test.go`, `README.md`
|
||||
**Commit:** eb555e8 (sm-mfa-plugin)
|
||||
**Status:** fixed: requires human verification (logic)
|
||||
**Applied fix:**
|
||||
- `attempt` (used by every verify route: totp, email, recovery and webauthn) calls the new `classes.ChallengeRevoked` after loading the user. It refuses with the route's existing generic 401 when:
|
||||
- the user is banned from any address (`ThrottleStates`);
|
||||
- the user is suspended at the verifying address (`RejectIfThrottled`, the check `/login` makes);
|
||||
- the user's `tokens_valid_after` is later than the challenge's `created_at` (compared at whole seconds, like the jwt guard).
|
||||
- I used suspension at the verifying address rather than suspension anywhere, so a stranger who fails five logins with the victim's email cannot block the victim's second factor.
|
||||
- `OnAccessRevoked` now runs `ExpireOpenChallenges` on `ev.Tx` for every event, bans included. Trusted devices are still revoked only on a password change.
|
||||
- `CompleteChallenge` also requires `expires_at > NOW()`, which closes the window between an attempt and its completion.
|
||||
- Only existing sm-user-plugin v0.1.12 API is used.
|
||||
|
||||
### WR-03: Device hand-over ignores `tokens_valid_after`, and a password change leaves confirmed device sessions live
|
||||
|
||||
**Files modified:** `fonoteka.go/plugins/golem15/user/classes/device_auth.go`, `controllers/devices.go`, `plugin.go`, `device_auth_test.go`, `README.md`
|
||||
**Commit:** 557c03c (sm-user-plugin)
|
||||
**Status:** fixed: requires human verification (logic)
|
||||
**Applied fix:**
|
||||
- `handOverDevice` now also refuses (and marks the row `revoked`) when `confirmed_at`, truncated to whole seconds, is before the user's `tokens_valid_after`.
|
||||
- Boot registers an `AccessRevokedEvent` listener that runs the new `classes.RevokeDeviceSessions` on `ev.Tx` (falling back to the published DB when `Tx` is nil). It sets `status = 'revoked'` for the users' `pending` and `confirmed` sessions. A listener error rolls the write back.
|
||||
- Used sessions keep their status; their tokens end through `tokens_valid_after`.
|
||||
|
||||
### WR-04: Reset 2FA bypasses the privileged-group guard
|
||||
|
||||
**Files modified:** `fonoteka.go/plugins/golem15/user/controllers/users_admin_controller.go`, `lang/en/lang.yaml`, `lang/pl/lang.yaml`, `reset_two_factor_test.go`, `README.md`
|
||||
**Commit:** 20e7b17 (sm-user-plugin)
|
||||
**Status:** fixed
|
||||
**Applied fix:**
|
||||
- The action's `Run` calls `guardPrivilegedMember` before `svc.Reset`. Without `golem15.users.manage_privileged_groups`, a privileged-group member answers cabana's 403 with the new message `privileged_member_reset_two_factor_forbidden` (en and pl), and `Reset` does not run.
|
||||
- I tried the optional hiding in `Applies`, then dropped it. Cabana answers a hidden action with a generic 409, and the existing password and delete guards show their 403 message rather than hiding the action.
|
||||
|
||||
### WR-06: `confirmPassword` is an unthrottled password oracle for a session holder
|
||||
|
||||
**Files modified:** `sm-mfa-plugin/controllers/management.go`, `confirm_password_test.go`, `README.md`
|
||||
**Commit:** 0a08070 (sm-mfa-plugin)
|
||||
**Status:** fixed
|
||||
**Applied fix:**
|
||||
- `confirmPassword` now records every non-empty password check through golem15.user's `CheckAndRecordLogin` for the client address. Five failures suspend the account there, as at `/login`, and a right password resets the count.
|
||||
- While the account is banned or suspended from any address (`ThrottleStates`), it answers the existing 403 `{"error":"Password confirmation required."}`, even to the right password.
|
||||
- An empty password is refused without counting.
|
||||
|
||||
### WR-07: Failures after the challenge commit consume the challenge and the recovery code without delivering a token
|
||||
|
||||
**Files modified:** `sm-mfa-plugin/classes/login.go`, `controllers/challenge.go`, `controllers/helpers.go`, `login_paths_test.go`, `complete_failure_test.go`, `README.md`
|
||||
**Commit:** f71d35d (sm-mfa-plugin)
|
||||
**Status:** fixed: requires human verification (transaction ordering)
|
||||
**Applied fix:**
|
||||
- **Before the transaction:** `completeSignIn` resolves the settings (`effective`, only when `trust_device` is truthy) and the session cookie (new `sessionCookie`).
|
||||
- **One transaction:** it then completes the challenge, spends the factor, issues the trusted device on `tx`, and runs the new `classes.FinishSignIn`. That function makes `IssueToken`, then `APIArray`, then golem15.user's `FinishLogin` on `tx`. The payload is built before `FinishLogin` so that no `GetApiArrayEvent` listener can block on the users-row lock that `FinishLogin` takes.
|
||||
- **After commit:** only then do the login event (new `classes.FireLogin`, source two_factor) and the verified event fire, and the answer is written by the infallible `writeSessionWith`.
|
||||
- `CompleteLogin` and `CompleteLoginAs` (the passkey path) are unchanged.
|
||||
- `TestEveryLoginPathIsGated` lists the new mint site `classes/login.go FinishSignIn usercontrollers.IssueToken` and the completion caller `controllers/challenge.go completeSignIn FinishSignIn`, and its call-site regexp now includes `FinishSignIn`.
|
||||
- Residual: `FinishLogin` sends a deactivated account's reactivate mail before the commit, so a failed commit after it would leave a mail for a restore that rolled back.
|
||||
|
||||
### WR-08: A challenged social sign-in never fires `SignedInEvent`
|
||||
|
||||
**Files modified:** `sm-sociallogin-plugin/classes/challenged.go` (new), `classes/codes.go`, `classes/flow.go`, `plugin.go`, `challenged_signin_test.go`, `README.md`
|
||||
**Commit:** ecfb8a7 (sm-sociallogin-plugin)
|
||||
**Status:** fixed: requires human verification (cross-plugin coupling)
|
||||
**Applied fix:**
|
||||
- **Holding the event.** When a gate challenges, `signIn` seals the `SignedInEvent` fields in the cache (`putSealedAt`, a new helper beside `putSealed`). The key is `oauth-2fa-signin:` plus the SHA-256 hex of the gate's `challenge_token`; the entry lives until the challenge's `expires_at`, at most 60 minutes. A cache error fails the sign-in, as the completion code would.
|
||||
- **Firing it.** Boot registers `classes.OnTwoFactorLogin`, a listener on golem15.user's `LoginEvent`. On source `two_factor` it reads the user's challenges completed in the last 5 minutes from `golem15_user_two_factor_challenges` (golem15.mfa's table, PHP's name), pulls each one's held-back sign-in once, and fires `SignedInEvent` with the original provider, identity, tenant, email, action and created flag.
|
||||
- **Timing.** The event fires after the 2FA token was minted, so a listener's writes reach later requests but not the completion's own payload. The README documents this.
|
||||
- **Dependencies.** sociallogin does not import mfa; it only reads that table name. No new sm-user-plugin API is used.
|
||||
|
||||
## Partial Issues
|
||||
|
||||
### WR-05: Second factors can be removed, replaced or added with a bearer session alone
|
||||
|
||||
**File:** `sm-mfa-plugin/controllers/management.go`, `controllers/webauthn.go`, `classes/methods.go`, `classes/admin.go`
|
||||
**Commit:** 463c750 (sm-mfa-plugin)
|
||||
**Status:** partial
|
||||
**Applied mitigation (contract-safe):**
|
||||
- Every password change (own, reset, admin-set) now runs the new `classes.DemotePasskeys` in the password write's transaction, through `OnAccessRevoked`. It clears `passwordless` on the user's WebAuthn credentials; they stay enabled as second-factor keys. A passkey registered with a stolen session therefore no longer survives the password change that locks the intruder out.
|
||||
- The trade-off: the user's own passkeys must be registered again as passkeys after any password change, the same treatment trusted devices already get under D-07.
|
||||
- README "Passkeys" and "Security notes" record the decision and the remaining exposure.
|
||||
|
||||
**Not fixed, because it needs a contract change:** PHP's `TwoFactorApiController` requires no password on `totpConfirm`, `totpDisable`, `emailDisable`, `webauthnRegister` or `webauthnRemove`, and the frontends send none. A full fix needs a step-up on:
|
||||
- `DELETE /2fa/totp`
|
||||
- `DELETE /2fa/email`
|
||||
- `DELETE /2fa/webauthn/{id}`
|
||||
- `POST /2fa/totp/confirm` while TOTP is already enabled
|
||||
- `POST /2fa/webauthn/register`, at least with `passwordless: true`
|
||||
|
||||
The step-up is a `password` field (query or body, as `recovery-codes` takes it), or a current factor, refused with the existing 403 `{"error":"Password confirmation required."}` and counted through the throttle as in WR-06. Every frontend (the demo's `security.vue` and any production client) would have to send it, so it needs the user's decision and a coordinated frontend release. Until then, a stolen session can still disable or replace factors while it lives.
|
||||
|
||||
---
|
||||
|
||||
## Verification
|
||||
|
||||
All checks ran in the **main checkouts** (`workflow.use_worktrees: false`; no worktree was created):
|
||||
- `/media/nvme/dev/golem15/summercms.io/summercms/fonoteka.go/plugins/golem15/user`
|
||||
- `/media/nvme/dev/golem15/summercms.io/summercms/sm-mfa-plugin`
|
||||
- `/media/nvme/dev/golem15/summercms.io/summercms/sm-sociallogin-plugin`
|
||||
|
||||
sm-mfa-plugin and sm-sociallogin-plugin build against the local user plugin through their committed `go.work`. Docker was available to the session user, so no sudo was needed.
|
||||
|
||||
- Before each commit: `gofmt`, `go vet ./...` and the repository's full `go test ./...` (Postgres testcontainers included) were green.
|
||||
- `scripts/check-phase19.6.sh --userplugin`, `--mfa`, `--sociallogin` and `--docs` all passed (run one stage per invocation; the script takes a single mode). The userplugin additive check reported no exported declaration removed or changed since 50da92c.
|
||||
- Final run after the last commit: `go vet ./...` and `go test -count=1 ./...` (Docker included) green in sm-user-plugin (root 89s, classes 48s, models, updates), sm-mfa-plugin (47s) and sm-sociallogin-plugin (43s). `go build ./...` of the fonoteka.go workspace, which uses the changed user plugin, also succeeds.
|
||||
|
||||
_Fixed: 2026-10-26T16:40:00Z_
|
||||
_Fixer: Claude (msd-code-fixer)_
|
||||
_Iteration: 1_
|
||||
@@ -0,0 +1,354 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
reviewed: 2026-10-26T14:43:47Z
|
||||
depth: standard
|
||||
files_reviewed: 65
|
||||
files_reviewed_list:
|
||||
- fonoteka.go/plugins/golem15/user/classes/login_gate.go
|
||||
- fonoteka.go/plugins/golem15/user/classes/two_factor_admin.go
|
||||
- fonoteka.go/plugins/golem15/user/classes/device_auth.go
|
||||
- fonoteka.go/plugins/golem15/user/classes/events.go
|
||||
- fonoteka.go/plugins/golem15/user/controllers/login_gates.go
|
||||
- fonoteka.go/plugins/golem15/user/controllers/devices.go
|
||||
- fonoteka.go/plugins/golem15/user/controllers/api_controller.go
|
||||
- fonoteka.go/plugins/golem15/user/controllers/registration.go
|
||||
- fonoteka.go/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- fonoteka.go/plugins/golem15/user/models/device_auth_session.go
|
||||
- fonoteka.go/plugins/golem15/user/updates/202610260001_create_device_auth_sessions.go
|
||||
- fonoteka.go/plugins/golem15/user/admin_permissions.go
|
||||
- fonoteka.go/plugins/golem15/user/plugin.go
|
||||
- fonoteka.go/plugins/golem15/user/routes.go
|
||||
- fonoteka.go/plugins/golem15/user/config/config.yaml
|
||||
- sm-mfa-plugin/plugin.go
|
||||
- sm-mfa-plugin/routes.go
|
||||
- sm-mfa-plugin/buckets.go
|
||||
- sm-mfa-plugin/mail.go
|
||||
- sm-mfa-plugin/admin_permissions.go
|
||||
- sm-mfa-plugin/admin_settings.go
|
||||
- sm-mfa-plugin/classes/admin.go
|
||||
- sm-mfa-plugin/classes/challenge.go
|
||||
- sm-mfa-plugin/classes/config.go
|
||||
- sm-mfa-plugin/classes/email.go
|
||||
- sm-mfa-plugin/classes/events.go
|
||||
- sm-mfa-plugin/classes/gate.go
|
||||
- sm-mfa-plugin/classes/login.go
|
||||
- sm-mfa-plugin/classes/methods.go
|
||||
- sm-mfa-plugin/classes/passwordless.go
|
||||
- sm-mfa-plugin/classes/qr.go
|
||||
- sm-mfa-plugin/classes/recovery.go
|
||||
- sm-mfa-plugin/classes/totp.go
|
||||
- sm-mfa-plugin/classes/trusted.go
|
||||
- sm-mfa-plugin/classes/webauthn.go
|
||||
- sm-mfa-plugin/controllers/challenge.go
|
||||
- sm-mfa-plugin/controllers/helpers.go
|
||||
- sm-mfa-plugin/controllers/management.go
|
||||
- sm-mfa-plugin/controllers/passwordless.go
|
||||
- sm-mfa-plugin/controllers/webauthn.go
|
||||
- sm-mfa-plugin/models/json_map.go
|
||||
- sm-mfa-plugin/models/registry.go
|
||||
- sm-mfa-plugin/models/settings.go
|
||||
- sm-mfa-plugin/models/string_list.go
|
||||
- sm-mfa-plugin/models/trusted_device.go
|
||||
- sm-mfa-plugin/models/two_factor_challenge.go
|
||||
- sm-mfa-plugin/models/two_factor_method.go
|
||||
- sm-mfa-plugin/models/two_factor_recovery_code.go
|
||||
- sm-mfa-plugin/models/webauthn_credential.go
|
||||
- sm-mfa-plugin/updates/202610220001_create_golem15_user_two_factor_methods.go
|
||||
- sm-mfa-plugin/updates/202610220002_create_golem15_user_two_factor_challenges.go
|
||||
- sm-mfa-plugin/updates/202610220003_create_golem15_user_two_factor_recovery_codes.go
|
||||
- sm-mfa-plugin/updates/202610220004_create_golem15_user_trusted_devices.go
|
||||
- sm-mfa-plugin/updates/202610220005_create_golem15_mfa_settings.go
|
||||
- sm-mfa-plugin/updates/202610220006_create_golem15_user_webauthn_credentials.go
|
||||
- sm-mfa-plugin/updates/registry.go
|
||||
- sm-mfa-plugin/config/config.yaml
|
||||
- sm-sociallogin-plugin/classes/flow.go
|
||||
- sm-sociallogin-plugin/classes/codes.go
|
||||
- sm-sociallogin-plugin/controllers/callback.go
|
||||
- sm-sociallogin-plugin/controllers/complete.go
|
||||
- sm-sociallogin-plugin/controllers/register_complete.go
|
||||
- sm-demo-app/vue-demo-app/app/lib/twoFactor.ts
|
||||
- sm-demo-app/vue-demo-app/app/composables/useTwoFactor.ts
|
||||
- sm-demo-app/vue-demo-app/app/composables/useDemoAuth.ts
|
||||
- sm-demo-app/vue-demo-app/app/pages/account/security.vue
|
||||
- sm-demo-app/vue-demo-app/app/pages/login.vue
|
||||
findings:
|
||||
critical: 1
|
||||
warning: 8
|
||||
info: 10
|
||||
total: 19
|
||||
status: issues_found
|
||||
---
|
||||
|
||||
# Phase 19.6: Code Review Report
|
||||
|
||||
**Reviewed:** 2026-10-26T14:43:47Z
|
||||
**Depth:** standard
|
||||
**Files Reviewed:** 65 (paths relative to `/media/nvme/dev/golem15/summercms.io/summercms/`)
|
||||
**Status:** issues_found
|
||||
|
||||
## Summary
|
||||
|
||||
I reviewed the production code of phase 19.6: sm-user-plugin `50da92c..1f3266a` (login gates, the login event, device authorization, the Reset 2FA action), every non-test file of the new sm-mfa-plugin, the social-login gate call in sm-sociallogin-plugin (`a8e3e78^..HEAD`), and the demo frontend files from `44a5229`. I read the tests only to understand intent. I did not re-report anything 19.6-SECURITY-REVIEW.md already records (F-1, D-12c phishing, the `blacklist_grace` fork, proxy logging of the status URL, the memory cooler, the numeric user handle, key order, accepted T-19.6-25).
|
||||
|
||||
Several things hold up. The challenge lifecycle is correct: the attempt counter is a guarded increment, completion is one guarded UPDATE in the same transaction that consumes the factor, the TOTP step is a guarded counter, and recovery codes are consumed with a guarded UPDATE. Secrets at rest are hashed or encrypted. Short codes use rejection sampling. TOTP compares in constant time (pquerna `hotp`), and recovery and email codes are compared with bcrypt. The WebAuthn RP ID and origins come from configuration, never from the request. Every sm-user mint site except F-1 is gated or carries its own proof.
|
||||
|
||||
The problems are at the edges of the flows:
|
||||
|
||||
- A device revoke can be lost to a concurrent refresh, or to a hand-over write that fails and is only logged. A revoked device then keeps refreshing indefinitely (CR-01).
|
||||
- The QR token shown on the waiting device is also the secret that collects the session JWT (WR-01).
|
||||
- Challenge completion re-checks neither a ban nor `tokens_valid_after`. The device hand-over does not check `tokens_valid_after` either (WR-02, WR-03).
|
||||
- Reset 2FA skips the privileged-group guard that password and delete edits enforce (WR-04).
|
||||
- Second factors can be removed, replaced or added with a bearer session alone. With passkey sign-in on, a stolen 60-minute JWT becomes a permanent login that survives a password change (WR-05).
|
||||
|
||||
## Narrative Findings (AI reviewer)
|
||||
|
||||
## Critical Issues
|
||||
|
||||
### CR-01: A device revoke is lost to a concurrent refresh or a failed jti hand-over, and the revoked device keeps refreshing
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/devices.go:483-506`, `fonoteka.go/plugins/golem15/user/controllers/api_controller.go:276,315-321`, `fonoteka.go/plugins/golem15/user/classes/device_auth.go:137-144`
|
||||
|
||||
**Issue:** `DeviceDestroy` reads `row.JWTJTI` with a plain SELECT (line 484), outside its transaction and with no row lock. It then blacklists that value (line 506). `Refresh` mints the new token first (`bouncer.Refresh`, line 276, which with the default grace of 0 also blacklists the old jti). Only after that does it move the device row to the new jti with `HandOverDeviceJTI`, whose UPDATE requires `status = 'used'`.
|
||||
|
||||
Here is how the race goes:
|
||||
|
||||
1. Revoke reads jti A.
|
||||
2. A refresh verifies A, mints B and runs `UPDATE … SET jwt_jti = B WHERE jwt_jti = A AND status = 'used'`, which succeeds.
|
||||
3. Revoke marks the row revoked and blacklists A, which is already dead.
|
||||
|
||||
The device now holds B, which is not blacklisted. Its next refresh (B to C) finds no `used` row, so `HandOverDeviceJTI` changes nothing and nobody ever blacklists the lineage. The reverse order (revoke commits between `bouncer.Refresh` and the hand-over) gives the same result: the UPDATE matches no row and `next` is returned anyway.
|
||||
|
||||
There is also a deterministic fail-open path that needs no race. Any error from `HandOverDeviceJTI` is only logged ("never fails the refresh", lines 309-320). After one transient database error, the row keeps a stale jti forever, and a later revoke blacklists a token the device no longer uses. The revoked or stolen device stays signed in, and keeps refreshing, until a password change.
|
||||
|
||||
T-19.6-08 is marked closed, but its tests cover only sequential refresh and revoke. A device holder that refreshes in a tight loop widens the window.
|
||||
|
||||
**Fix:** Make both sides atomic and fail closed:
|
||||
|
||||
```go
|
||||
// DeviceDestroy: read the jti that is current at commit time
|
||||
var jti *string
|
||||
err = lagoon.Transaction(r.Context(), gdb, func(ctx context.Context, tx *gorm.DB) error {
|
||||
if err := tx.Raw(`UPDATE `+deviceTable+` SET status = 'revoked', updated_at = NOW()
|
||||
WHERE id = ? AND user_id = ? RETURNING jwt_jti`, row.ID, user.ID).Scan(&jti).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
... // blacklist *jti
|
||||
})
|
||||
|
||||
// Refresh: lock the device row by the old jti before minting, refuse a revoked lineage,
|
||||
// and fail the refresh (or blacklist `next`) when the hand-over UPDATE errors or
|
||||
// matches a row that is no longer 'used'.
|
||||
```
|
||||
|
||||
At minimum, give `HandOverDeviceJTI` a signal that a row with `jwt_jti = old` exists in status `revoked`. When it does, blacklist `next` and answer the refresh 401, and treat an error from it as a refresh failure.
|
||||
|
||||
## Warnings
|
||||
|
||||
### WR-01: The device token in the QR code is also the credential that collects the session JWT
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/classes/device_auth.go:96-105`, `fonoteka.go/plugins/golem15/user/controllers/devices.go:147-153,170-198,360-361`
|
||||
|
||||
**Issue:** `DeviceInitiate` builds `auth_url` (the QR code the device displays) from the same `token` that `GET /devices/status/{token}` accepts to hand over the session JWT. Whoever sees the QR code or the scan URL (a photo of the screen, browser history, a Referer or analytics script on the `/device/scan/{token}` page, a QR scanner app) can poll the status route. The first poll after the victim confirms receives `{"token": …}`, and the guarded UPDATE makes the legitimate device lose with `{"status":"used"}`.
|
||||
|
||||
This is not the phishing case D-12c accepts. The victim authorizes their own device and the observer takes the session. RFC 8628 keeps the polled `device_code` separate from the displayed `user_code` for this reason. The security review's T-19.6-09 covers storage and logs only.
|
||||
|
||||
**Fix:** Keep the polling secret off the screen. Without changing the existing response shapes:
|
||||
|
||||
- support a `{short_code}` placeholder in `device_auth.auth_url` and make it the default, so the QR code carries only the short code that `DeviceAuthorize` already accepts;
|
||||
- additionally bind the hand-over to the initiating client, for example by refusing a poll whose user agent differs from `device_user_agent`.
|
||||
|
||||
A separate `poll_token` returned only by `initiate` is the clean fix if the contract can grow a key.
|
||||
|
||||
### WR-02: Challenge completion mints a token for a user banned, or whose password changed, after the password step
|
||||
|
||||
**File:** `sm-mfa-plugin/controllers/challenge.go:62-96,296-327`, `sm-mfa-plugin/classes/login.go:355-391`
|
||||
|
||||
**Issue:** The ban and suspension checks run once, at `/login` (`RejectIfThrottled`). The challenge stays usable for `two_factor_challenge_ttl` (up to 60 minutes through settings). Neither `attempt` nor `completeSignIn` re-checks `ThrottleStates`, and neither compares the challenge's `created_at` with the user's `tokens_valid_after`.
|
||||
|
||||
A ban, or a password reset meant to lock out an attacker who has the password and a second factor (for example a stolen recovery code), does not invalidate the pending challenge. Its completion mints a token with `iat` after the revocation cutoff, which the jwt guard accepts (`PrincipalByID` checks no ban). `/refresh` would refuse the user, but the token is good for its full TTL.
|
||||
|
||||
The passkey path (`passwordless.go:118-131`) and the device hand-over (`devices.go:255-261`) both check bans, so this path is the inconsistent one.
|
||||
|
||||
**Fix:** In `attempt`, after `ChallengeUser`, refuse with the method's generic 401 when:
|
||||
|
||||
```go
|
||||
banned, suspended, err := userclasses.ThrottleStates(userclasses.ContextWithThrottle(ctx, app), db, []uint{user.ID})
|
||||
if banned[user.ID] || suspended[user.ID] ||
|
||||
(user.TokensValidAfter != nil && ch.CreatedAt != nil && user.TokensValidAfter.After(*ch.CreatedAt)) { refuse(w); return ... }
|
||||
```
|
||||
|
||||
Also delete the user's open challenges in `OnAccessRevoked` (`classes/admin.go:471-484`) on the event's transaction.
|
||||
|
||||
### WR-03: Device hand-over ignores `tokens_valid_after`, and a password change leaves confirmed device sessions live
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/devices.go:245-271`
|
||||
|
||||
**Issue:** `handOverDevice` refuses only a missing, soft-deleted or banned user. A user who authorized a device and then changes the password (or an admin who sets one), intending to end every session, still has the `confirmed` row live until `expires_at`. The next poll mints a fresh JWT whose `iat` is after the cutoff. No `AccessRevokedEvent` listener touches `golem15_user_device_auth_sessions`.
|
||||
|
||||
**Fix:** In `handOverDevice`, treat `user.TokensValidAfter != nil && row.ConfirmedAt != nil && user.TokensValidAfter.After(*row.ConfirmedAt)` as refused (mark the row revoked). Also add an `AccessRevokedEvent` listener in sm-user-plugin that runs, on `ev.Tx`:
|
||||
|
||||
```sql
|
||||
UPDATE golem15_user_device_auth_sessions SET status = 'revoked'
|
||||
WHERE user_id IN ? AND status IN ('pending', 'confirmed')
|
||||
```
|
||||
|
||||
### WR-04: Reset 2FA bypasses the privileged-group guard
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/users_admin_controller.go:802-827` (compare `193-210`, `537`, `549`)
|
||||
|
||||
**Issue:** On the Users screen, setting the password of a privileged-group member (whose group "makes a site administrator") or deleting one requires `golem15.users.manage_privileged_groups` (`guardPrivilegedMember`). The new `reset_two_factor` action's `Run` calls `svc.Reset` directly and requires only `golem15.users.reset_two_factor`. An administrator granted only the reset permission (for example a support role) can strip every second factor, trusted device and passkey from a privileged account. That leaves the account behind its password alone, which is the downgrade the privileged guard exists to prevent.
|
||||
|
||||
**Fix:** Run the same guard before the reset:
|
||||
|
||||
```go
|
||||
func(ctx context.Context, tx *gorm.DB, user *models.User) error {
|
||||
if err := c.guardPrivilegedMember(ctx, user.ID, usersLang+"privileged_member_forbidden", nil); err != nil {
|
||||
return err
|
||||
}
|
||||
...
|
||||
return svc.Reset(ctx, tx, user)
|
||||
}
|
||||
```
|
||||
|
||||
Optionally, also hide the action in `Applies` for privileged members when the principal lacks `PermissionManagePrivilegedGroups`.
|
||||
|
||||
### WR-05: Second factors can be removed, replaced or added with a bearer session alone; a stolen JWT becomes a permanent passkey login
|
||||
|
||||
**File:** `sm-mfa-plugin/controllers/management.go:87-128,152-171,176-208`, `sm-mfa-plugin/controllers/webauthn.go:88-195,202-243`, `sm-mfa-plugin/classes/methods.go:79-85`, `sm-mfa-plugin/classes/admin.go:471-484`
|
||||
|
||||
**Issue:** Only recovery codes ask for the password (`confirmPassword`). The following need nothing beyond `jwt.auth`:
|
||||
|
||||
- `DELETE /2fa/totp`, `DELETE /2fa/email` and `DELETE /2fa/webauthn/{id}` disable factors.
|
||||
- `POST /2fa/totp/confirm` overwrites an already enabled TOTP secret: `EnableMethod` runs `ON CONFLICT … DO UPDATE SET secret = EXCLUDED.secret`, without proof of the current factor.
|
||||
- `POST /2fa/webauthn/register` adds credentials.
|
||||
|
||||
With `two_factor_passwordless_login` on, anyone holding a session JWT for 60 minutes (XSS, a leaked token, a device obtained through WR-01) can register their own passkey with `passwordless=true`. `OnAccessRevoked` revokes only trusted devices, so that passkey keeps signing in without a password or a challenge after the victim changes the password. T-19.6-25 accepted a client-chosen secret for the caller's own first setup, not the overwrite of an enabled factor or the persistence path.
|
||||
|
||||
**Fix:**
|
||||
|
||||
- Require `confirmPassword` (or a fresh factor) on factor removal, on TOTP confirm when a TOTP method is already enabled, and on WebAuthn registration (at least when `passwordless` is requested).
|
||||
- On a password change, either delete `passwordless` credentials or record the change and flag credentials created since the last password change, as the README's threat notes decide.
|
||||
|
||||
### WR-06: `confirmPassword` is an unthrottled password oracle for a session holder
|
||||
|
||||
**File:** `sm-mfa-plugin/controllers/management.go:212-224`
|
||||
|
||||
**Issue:** A wrong password on `GET /2fa/recovery-codes?password=` or on `regenerate` answers 403 without recording a failed attempt in golem15.user's throttle. Those routes allow 120 requests a minute per user (`user-api`, keyed by the bearer subject). A stolen session can therefore brute-force the account password at about 170,000 guesses a day without ever triggering the login suspension. Recovering the password then defeats the password half of every later login.
|
||||
|
||||
**Fix:** Count a failed confirmation through the user plugin's throttle (export a helper around `refuseLogin`'s recording, or call `classes.CheckAndRecordLogin(ctx, db, user, ip, false)`). Refuse while the account is suspended. Alternatively, give the two routes a tight per-user bucket (for example 5 a minute).
|
||||
|
||||
### WR-07: Failures after the challenge commit consume the challenge and the recovery code without delivering a token
|
||||
|
||||
**File:** `sm-mfa-plugin/controllers/challenge.go:296-351`, `sm-mfa-plugin/controllers/helpers.go:569-582`
|
||||
|
||||
**Issue:** `completeSignIn` commits the completed challenge (and the consumed recovery code or TOTP step) first. After that it calls:
|
||||
|
||||
1. `CompleteLogin`: `FinishLogin` restores the account and stamps it, the token is minted, and `LoginEvent` fires.
|
||||
2. The `VerifiedEvent`.
|
||||
3. `withTrustedDevice`, which runs `effective` and `IssueTrustedDevice` (an INSERT).
|
||||
4. `writeSession`, which may fail on `bouncer.LoadCookieConfig`.
|
||||
|
||||
Any error in steps 3 or 4 answers the opaque 500 after the login event fired and a token was minted but never sent. The user has to sign in again, and when the factor was a recovery code, that single-use code is gone. An error in step 1 burns the code the same way. Audit listeners see a `golem15.user.login` for a sign-in that never happened.
|
||||
|
||||
**Fix:**
|
||||
|
||||
- Resolve the cookie config and `effective` before the transaction.
|
||||
- Create the trusted-device row inside the completing transaction (it only needs `db`).
|
||||
- Mint and fire events only after everything that can fail has succeeded.
|
||||
- For a failure inside `CompleteLogin`, consider rolling the recovery-code consumption into the same transaction as `FinishLogin`.
|
||||
|
||||
### WR-08: A challenged social sign-in never fires `SignedInEvent`, so its listeners are skipped for 2FA users
|
||||
|
||||
**File:** `sm-sociallogin-plugin/classes/flow.go:340-353`
|
||||
|
||||
**Issue:** When the gate challenges, `signIn` returns before `fireSignedIn`. The second factor's completion (`mfa CompleteLogin`) fires only golem15.user's `LoginEvent` with source `two_factor`, which carries no provider, identity or tenant. Any application listener on `SignedInEvent` never runs for users who enabled a second factor while `two_factor_social_login` is on. The plugin README cites one such listener: an organisation assigned by tenant, whose write is meant to reach the token. The README documents the skip, but no replacement event exists, so the listener's effect is silently lost on exactly the accounts with the strongest protection.
|
||||
|
||||
**Fix:** Store the pending `SignedInEvent` fields with the challenge (the completion payload already goes through the sealed cache), and fire `SignedInEvent` on completion. One way is a `LoginEvent` listener in sociallogin that recognises a challenge it created, for example keyed by challenge id. Another is a documented hook in mfa's `CompleteLogin`. At minimum, state in the README that `SignedInEvent` listeners must also handle `LoginEvent{Source: two_factor}`.
|
||||
|
||||
## Info
|
||||
|
||||
### IN-01: The email-send cap is hard-coded in SQL next to an unused constant
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/email.go:25,83`
|
||||
|
||||
**Issue:** `MaxEmailSends = 3` is documented as the cap, but the guarded UPDATE says `email_sends < 3` literally. Changing the constant would silently not change the behaviour.
|
||||
|
||||
**Fix:** Bind the constant: `… AND email_sends < ?`, passing `MaxEmailSends`.
|
||||
|
||||
### IN-02: `two_factor_email_code_ttl` changes only the mail text; the code lives as long as the challenge
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/email.go:111-136`, `sm-mfa-plugin/config/config.yaml` (`two_factor_email_code_ttl`)
|
||||
|
||||
**Issue:** `VerifyEmailCode` never checks the send time. Settings allow a challenge TTL of up to 60 minutes and a code TTL of 1 minute, and the code then works for the full hour although the mail promised one minute.
|
||||
|
||||
**Fix:** Store the send instant (or `code_expires_at`) in the guarded UPDATE and refuse after `EmailCodeMinutes`.
|
||||
|
||||
### IN-03: Confirmed device sessions that are never polled are never expired, cleaned or hidden
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/devices.go:97-100,385-392,431-434`
|
||||
|
||||
**Issue:** A row only becomes `expired` when it is polled or re-authorized, and the cleanup deletes only `pending` and `expired` rows. A `confirmed` row whose device went away therefore stays forever, appears in `GET /devices` as an authorized device, and keeps its unique short code. Line 388 also discards the error of the expiry UPDATE.
|
||||
|
||||
**Fix:** Include `status = 'confirmed' AND expires_at < NOW() - INTERVAL '1 hour'` in the cleanup, and filter expired confirmed rows out of `DeviceIndex`, or mark them expired there. Log the line-388 error.
|
||||
|
||||
### IN-04: A short code typed with a space answers 422 although the doc says spaces are optional
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/devices.go:312-313,343-348`
|
||||
|
||||
**Issue:** The length check runs after removing hyphens only, so "ABCD EFGH" (9 bytes) is refused before `NormalizeDeviceShortCode`, which would accept it.
|
||||
|
||||
**Fix:** Strip spaces as well before the length check, or make the doc comment match PHP's behaviour.
|
||||
|
||||
### IN-05: The default WebAuthn RP ID comes from `app.url`, contradicting the configuration's own guidance
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/config.go:178-184`
|
||||
|
||||
**Issue:** The config comment says the RP ID must be the host of the frontend pages. With an empty `rp_id`, though, the default is the API host (`app.url`). When `golem15.user.frontend_url` is another host, every ceremony fails in the browser. This fails closed, but it is a confusing default.
|
||||
|
||||
**Fix:** Default to the `frontend_url` host when it is set, and refuse at boot (or log) an origin whose host is neither the RP ID nor a subdomain of it.
|
||||
|
||||
### IN-06: `MaskEmail` slices bytes and can split a multi-byte character
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/email.go:41-51`
|
||||
|
||||
**Issue:** `local[:1]` and `local[len(local)-1:]` cut UTF-8 sequences in internationalised local parts, which produces U+FFFD in the JSON answer.
|
||||
|
||||
**Fix:** Operate on `[]rune(local)`.
|
||||
|
||||
### IN-07: A gate result with a nil Body is answered as `null`
|
||||
|
||||
**File:** `fonoteka.go/plugins/golem15/user/controllers/api_controller.go:150-156`
|
||||
|
||||
**Issue:** sociallogin normalizes a nil `gate.Body` to `{}` (`flow.go:349-352`), but `Login` writes it as is.
|
||||
|
||||
**Fix:** Apply the same `if body == nil { body = map[string]any{} }` before `writeJSON`.
|
||||
|
||||
### IN-08: The second-factor WebAuthn assertion is not held to the 60-second ceremony timeout
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/webauthn.go:453-460`
|
||||
|
||||
**Issue:** `FinishAssertion` sets `session.Expires` to the challenge's `expires_at` (5 minutes or more). The enforced `WebAuthnTimeout` therefore applies only to registration and passkey state, not to the login step.
|
||||
|
||||
**Fix:** Store the options' issue time with the challenge, and use `min(issued+WebAuthnTimeout, ch.ExpiresAt)`.
|
||||
|
||||
### IN-09: The demo login cannot complete an email-only or WebAuthn-only challenge
|
||||
|
||||
**File:** `sm-demo-app/vue-demo-app/app/pages/login.vue:21,35,98`
|
||||
|
||||
**Issue:** Without `totp` in `available_methods`, the page falls back to recovery-code mode and hides the switch. A user whose only method is email can sign in only by spending a recovery code.
|
||||
|
||||
**Fix:** Add the `email/send` and `verify method=email` step, or show a message that the method is not supported in the demo.
|
||||
|
||||
### IN-10: Passkey sign-in refuses non-activated accounts even when activation is not required
|
||||
|
||||
**File:** `sm-mfa-plugin/classes/passwordless.go:115-117`
|
||||
|
||||
**Issue:** `Login` refuses a not-activated account only while `golem15.user.activation.require_activation` is on. The passkey path refuses it unconditionally. This fails closed, but the two sign-ins are inconsistent.
|
||||
|
||||
**Fix:** Use the user plugin's registration settings (`RegistrationSettings`) for the same check, or document the stricter rule.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-26T14:43:47Z_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: standard_
|
||||
@@ -0,0 +1,166 @@
|
||||
# Phase 19.6 Security Review: second factors and device login
|
||||
|
||||
**Date:** 2026-10-26
|
||||
**Level:** OWASP ASVS L1 (RESEARCH "Security Domain"), block on high; D-14 asks for an explicit review of passwordless passkey login.
|
||||
**Scope:** this phase's sm-user-plugin additions (login gates, the login event, the password-change hook, the Reset 2FA slot, device authorization), the new `sm-mfa-plugin` (gate, challenge store, TOTP and QR, recovery and email codes, failure cap, trusted devices, settings, admin reset, WebAuthn second factor, passwordless passkeys), the social-login gate call in `sm-sociallogin-plugin`, the adoption in sm-demo-app, sm-bm-app and fonoteka.go, and this plan's gate.
|
||||
**Threats reviewed:** T-19.6-01..T-19.6-38 and the four T-19.6-SC rows of the threat models of plans 01, 02, 03 and 04, plus RESEARCH's Security Domain table and Assumptions A1-A13.
|
||||
**Result:** every threat is closed by a test that fails when the mitigation is removed, or accepted with a reason. One defect found by the new tests was fixed in its own commit (sm-mfa-plugin `71d8f27`, T-19.6-24). One new finding, **F-1** (activate-by-code mints a token without the second factor when `require_activation` is off), corrects the reason plan 01 recorded for an accepted mint path; the user deferred it at plan 04's Task 5 (todo `2026-10-26-activate-by-code-second-factor.md`). T-19.6-37 is closed: the fix shipped as sm-mfa-plugin v0.1.1 and every pin contains it.
|
||||
|
||||
Repositories and abbreviations: **F** = summercms.go, **U** = sm-user-plugin (`fonoteka.go/plugins/golem15/user`), **M** = `sm-mfa-plugin`, **S** = `sm-sociallogin-plugin`, **D** = sm-demo-app (with `vue-demo-app`), **B** = sm-bm-app, **A** = the fonoteka.go workspace.
|
||||
|
||||
## Method
|
||||
|
||||
1. For each threat, read the code that implements the mitigation and find the test that fails without it. Where a test was missing, plan 04 added it (Tasks 2 and 3) in the owning repository.
|
||||
2. Mutation checks on the race- and security-sensitive mitigations, each reverted after the run:
|
||||
- M `classes/challenge.go` `CompleteChallenge` without `AND completed_at IS NULL`: `TestChallengeLifecycle` fails (racing TOTP and recovery verifications mint more than one token).
|
||||
- M `classes/email.go` `SendEmailCode` without `AND email_sends < 3`: `TestEmailCode` fails.
|
||||
- M `classes/gate.go` with social sign-ins always allowed: `TestGate` and `TestEveryLoginPathIsGated` fail.
|
||||
- M `classes/passwordless.go` `passkeyUser` without the `passwordless` column check: `TestPasswordless` fails.
|
||||
- M `models/settings.go` without the empty-list normalization: `TestSettings` fails.
|
||||
- U `controllers/devices.go` hand-over UPDATE without `AND status = 'confirmed'`: `TestDeviceHandOverConcurrent` fails.
|
||||
- U `controllers/devices.go` authorize UPDATE without the pending-only and `user_id` guard: `TestDeviceAuthorize` fails.
|
||||
- The PHP map: a renamed Go test, a renamed subtest and an extra listed method each fail `TestPHPMethodMap`.
|
||||
3. Sweeps: every non-test log call of M and of U's device controller (section "Log calls"); every token mint site of U and M (`TestEveryLoginPathIsGated/mint_sites`); the response bodies of RESEARCH Q4's two tables (`TestPHPErrorBodies`).
|
||||
4. Run the whole gate: `scripts/check-phase19.6.sh --all` on a Docker host.
|
||||
|
||||
## Defects fixed during this plan
|
||||
|
||||
| Commit | Repo | Threat | Found by | Fix |
|
||||
|--------|------|--------|----------|-----|
|
||||
| 71d8f27 | M | T-19.6-24 | `TestSettings/form_round_trip_keeps_the_configuration` | The settings form shows a NULL `two_factor_available_methods` as an empty taglist and sends it back as `[]` on every save, so saving the form once (for example to turn trusted devices on) stored `[]` and made every method unavailable: TOTP setup answered 403, and no user could enable a second factor. An empty list is now an empty value: `Settings.BeforeValidate` stores it as NULL and the overlay ignores an empty stored list (methods and enforce groups), as the README already promised. README and the en and pl comments updated. |
|
||||
|
||||
The fix is a production change after plan 03's release (sm-mfa-plugin v0.1.0); under the Task 5 reply it shipped as sm-mfa-plugin v0.1.1 (`d08f1ec`), pinned by sm-demo-app `9166a1e` (gitlink and go.mod) and sm-bm-app `fe4e292` (T-19.6-37).
|
||||
|
||||
## Threat register
|
||||
|
||||
| Threat | Component | Mitigation as built | Implementation | Test (repo) | Status |
|
||||
|--------|-----------|---------------------|----------------|-------------|--------|
|
||||
| T-19.6-01 | login gate consultation | `Login` asks `CheckLoginGates` after the ban check, password, activation, throttle record and rehash; a result returns its status and body before restore, last_seen, mint and event; a gate error answers the opaque 500. | U `controllers/api_controller.go` `Login`; `controllers/login_gates.go`; `classes/login_gate.go` | `TestLoginGates` (order, first result or error wins, nil registry, concurrent Add and Check under `-race`), `TestLoginGateOrder` (refused first factors never reach a gate, answers pass through, no event, no last_seen), `TestLoginGateSmoke/gate_error` (U) | closed |
|
||||
| T-19.6-02 | restore of a soft-deleted account before the second factor (Pitfall 21, D-18 A10) | The restore and its reactivate mail run after the gates; the gate sees the account still deleted. | U `Login`; M `classes/login.go` `CompleteLoginAs` (FinishLogin after the factor) | `TestLoginGateOrder/challenged_soft_deleted_stays_deleted`, `allowed_soft_deleted_restored_once` (U); `TestGate/deactivated_user_is_challenged_and_stays_deactivated` (M); `TestSocialGate/challenge_status_200` (S) | closed |
|
||||
| T-19.6-03 | trusted devices surviving a password change (D-07) | Reset, own change and admin set fire `AccessRevokedEvent` (`PasswordChanged()` true) inside the write's transaction; M deletes the user's trusted devices on `ev.Tx`; a listener error rolls the write back; the rehash and a ban fire no password change. | U `controllers/api_controller.go` `ResetPassword`, `ChangePassword`; `controllers/users_admin_controller.go` `FormBeforeUpdate`; M `classes/admin.go` `OnAccessRevoked` | `TestPasswordChangedSources` (each source once, in the transaction, rollback, rehash and registration fire none) (U); `TestRevocation` (all three sources delete devices, rehash and ban keep them) (M) | closed |
|
||||
| T-19.6-04 | Reset 2FA record action (D-15) | Permission `golem15.users.reset_two_factor` (no default role), danger confirmation, offered only with a published `TwoFactorAdmin` that reports a factor, `Run` only in cabana's transaction, Reset's error rolls back. | U `controllers/users_admin_controller.go` `resetTwoFactorAction`; M `classes/admin.go` `Admin` | `TestResetTwoFactorAction` (U); `TestAdminReset` (end to end through the Users screen, rollback on a failing listener) (M) | closed |
|
||||
| T-19.6-05 | short-code guessing to bind a victim's pending device | 31^8 codes from crypto/rand without modulo bias, 5-minute TTL, user-api bucket, guarded pending-to-confirmed UPDATE requiring `user_id` NULL or the caller. | U `classes/device_auth.go` `NewDeviceShortCode`; `controllers/devices.go` `DeviceAuthorize` | `TestDeviceCodes` (distribution over 10,000 draws), `TestDeviceAuthorize` (bound to another user, concurrent authorizes by two users bind one) (U) | closed (mutation-checked) |
|
||||
| T-19.6-06 | device-code phishing | D-12c keeps PHP's rule (any signed-in session may authorize); the device list shows name and address, revoke signs the device out at once. | U `controllers/devices.go` | `TestDeviceListAndRevoke` (U) | accepted (D-12c): the frontend must show device name and address before confirming |
|
||||
| T-19.6-07 | device hand-over race | One guarded confirmed-to-used UPDATE; a poll that loses drops its minted token unsent. | U `controllers/devices.go` `handOverDevice` | `TestDeviceHandOverConcurrent` (50 polls, one token, one login event), `TestDeviceFlowSmoke` (U) | closed (mutation-checked) |
|
||||
| T-19.6-08 | revoked device keeps refreshing (RESEARCH Q7) | Refresh hands the row's `jwt_jti` to the new token; revoke blacklists the current jti for the whole refresh window. | U `controllers/api_controller.go` `Refresh`; `classes/device_auth.go` `HandOverDeviceJTI`; `controllers/devices.go` `DeviceDestroy` | `TestDeviceRevokeAfterRefresh` (one and two refreshes, the lineage signed out, the blacklist entry outlives the window, a failed refresh leaves the row) (U) | closed; the `blacklist_grace` fork is a residual risk (below) |
|
||||
| T-19.6-09 | device tokens at rest and in URLs | Only the SHA-256 hex is stored; the session JWT is never stored (only its jti); the framework access log records no path. | U `controllers/devices.go`; F `modules/surf/accesslog.go` | `TestDeviceTokensAtRest`, `TestDeviceStatus/unknown` (the hash is no token) (U) | closed; reverse-proxy logging of `devices/status/{token}` is a residual risk (README) |
|
||||
| T-19.6-10 | unauthenticated initiate filling the table (Pitfall 16) | user-api bucket and a cleanup of at most 500 stale pending or expired sessions per initiate. | U `controllers/devices.go` `DeviceInitiate` | `TestDeviceInitiate/cleanup_is_bounded` (U) | closed |
|
||||
| T-19.6-11 | attacker-chosen `device_name` (Pitfall 14) | At most 255 characters (runes) with PHP's 422; rendered as text by clients. | U `DeviceInitiate` | `TestDeviceInitiate/device_name` (U) | closed |
|
||||
| T-19.6-12 | core plugin contract (19.4 D-05) | Additive exports, routes, config keys and one added migration. | U commits `8501f34`..`3b22134` | gate `--userplugin` (no exported declaration removed or changed since `50da92c`, only `202610260001_create_device_auth_sessions` added under `updates/`), `--fonoteka` (F) | closed |
|
||||
| T-19.6-SC (plan 01) | Go module installs | None in U; approved pins for M. | F `.planning/notes/2026-10-21-mfa-otp-webauthn.md` | gate `--docs` (note and STACK rows), `--fonoteka` (no second-factor module in the workspace graph) (F) | closed |
|
||||
| T-19.6-13 | TOTP and email brute force across challenges and addresses (Pitfall 1) | 2fa-verify bucket (10 a minute per client address), five attempts a challenge, the per-user failure cap counted from challenge rows (10 in 15 minutes, D-18 A6). | M `buckets.go`; `classes/challenge.go` `FailureCapReached`; `controllers/challenge.go` `attempt` | `TestFailureCap` (formula, window, in-flight attempt, refusal at login and on every verify route even with a correct factor, configured cap), `TestChallengeLifecycle/five_attempts_across_routes`, `TestRoutesAndBuckets` (11th request 429, keyed per client) (M) | closed |
|
||||
| T-19.6-14 | parallel verifies (attempt bypass, double mint) | Guarded attempt increment and one guarded completion UPDATE in the transaction that consumes the factor. | M `classes/challenge.go` `BeginAttempt`, `CompleteChallenge` | `TestChallengeLifecycle/one_completion_when_factors_race` (20 TOTP and recovery verifications, one token, at most one code spent), `TestChallengeSmoke/parallel_verify`, `TestRecovery/single_use_under_concurrency` (M) | closed (mutation-checked) |
|
||||
| T-19.6-15 | TOTP replay inside the window (Pitfall 5) | Last accepted step in metadata, accepted by a guarded UPDATE; a step at or below it is refused. | M `classes/totp.go` `VerifyTOTP`; `classes/methods.go` `AcceptTOTPCounter` | `TestTOTP/replay`, `TestTracerSmoke` (M) | closed |
|
||||
| T-19.6-16 | email downgrade of a TOTP-only user (Pitfall 10, A8) | `email/send` and `verify method=email` only while the email method is enabled; otherwise the generic 401. | M `classes/email.go` `SendEmailCode`; `controllers/challenge.go` `verifyEmail` | `TestEmailCode/gating`, `TestPHPErrorBodies` (M) | closed |
|
||||
| T-19.6-17 | mail bombing through email/send | At most 3 sends a challenge in one guarded UPDATE, the bucket and the failure cap. | M `SendEmailCode` | `TestEmailCode/sends_replace_and_cap`, `TestFailureCap/refused_everywhere_at_the_cap` (M) | closed (mutation-checked) |
|
||||
| T-19.6-18 | secrets at rest (D-06) | SHA-256 hex for challenge and trusted tokens, `lagoon.Encrypted` TOTP secret, bcrypt recovery and email codes; models hide the columns from JSON. | M `classes/challenge.go`, `classes/trusted.go`, `classes/methods.go` `EnableMethod`, `classes/recovery.go`, `classes/email.go` | `TestTokensAtRest` (M) | closed |
|
||||
| T-19.6-19 | logs and error strings | No code, token, secret or password in a log line; 500 answers opaque. | M, U (section "Log calls") | `TestEmailCode/never_logged` (no mailed code or challenge token in any app or default log line, a failing listener forcing log lines) (M) | closed |
|
||||
| T-19.6-20 | stolen trusted-device token | SHA-256 at rest, bound to the user, 30-day expiry, off by default, revoked by any password change, the last method's removal and the revoke routes; a social sign-in is never skipped (A7). | M `classes/trusted.go`, `classes/gate.go` | `TestTrustedDevice` (foreign, unknown, malformed, expired tokens and the setting off are challenged; social never skipped), `TestRevocation` (M) | closed |
|
||||
| T-19.6-21 | management routes touching another user's rows | Every query scoped by the JWT user; `{id}` routes constrained to digits; 404 for foreign ids. | M `routes.go`, `controllers/management.go`, `controllers/webauthn.go` | `TestRoutesAndBuckets` (jwt.auth on every management route), `TestWebAuthn/delete_scoped_to_the_owner` (foreign 404, the router's 404 for non-numeric ids), `TestTrustedSettingsSmoke/revoke_routes` (M) | closed |
|
||||
| T-19.6-22 | recovery codes after creation | Shown once (first set D-19, regenerate); the count route needs the password and shows a count only. | M `controllers/management.go` | `TestRecovery/first_set_only_when_created`, `count_route`, `regenerate` (M) | closed |
|
||||
| T-19.6-23 | bcrypt CPU per wrong recovery code (Pitfall 9) | Input normalized and capped at 32 characters, first match wins, the bucket and the cap. | M `classes/recovery.go` `NormalizeRecoveryCode` | `TestRecoveryCodeFormat`, `TestRecovery/normalization_through_the_route` (M) | closed |
|
||||
| T-19.6-24 | settings values (USER-005 type confusion, unknown methods or groups) | Typed mode with an exact allow-list in `Rules`, method and group allow-lists in `BeforeValidate`, a stored unknown mode behaves as optional, an empty list falls back to the configuration (`71d8f27`). | M `models/settings.go`, `classes/config.go` | `TestSettings` (overlay per key, rules, allow-lists, form round trip), `TestPHPUser005` (M) | fixed in commit 71d8f27 (with its test) |
|
||||
| T-19.6-25 | client-chosen TOTP secret at confirm | Only for the caller's own account; base32 and 16-64 characters validated; a current code from the secret is required. | M `controllers/management.go` `TOTPConfirm` | `TestPHPErrorBodies` (format and code refusals) (M) | accepted (PHP parity) |
|
||||
| T-19.6-SC (plan 02) | Go module installs | pquerna/otp v1.5.0 and boombuler/barcode v1.1.0 after the recorded approval; no archived YAML module. | M `go.mod` | gate `--mfa` (pins, `go list -deps` free of `gopkg.in/yaml.v3`) (F) | closed |
|
||||
| T-19.6-26 | WebAuthn challenge supplied by the client (Pitfall 6) | Registration and passkey state server-side in cooler, consumed with `Pull` and scoped to the user; the login challenge on the challenge row; the client's challenge only a lookup key. | M `classes/webauthn.go` `BeginRegistration`, `FinishRegistration`, `BeginAssertion`, `FinishAssertion`; `classes/passwordless.go` | `TestWebAuthnShapes/registration_state` (used once, another user's state refused), `TestWebAuthn/registration`, `assertion_options` (M) | closed |
|
||||
| T-19.6-27 | passkey login with a second-factor credential (D-14) | `passwordless` set only for a requested, user-verified, credProps-rk credential; `ValidatePasskeyLogin` with UV required; the handler checks enabled, passwordless and the user handle. | M `classes/webauthn.go` `FinishRegistration`; `classes/passwordless.go` | `TestPasswordless`, `TestWebAuthnShapes/passkey_flag` (M); section "D-14" | closed (mutation-checked) |
|
||||
| T-19.6-28 | cloned authenticator | The record written back after every assertion (sign count, flags) with a guarded UPDATE; a clone warning and a backup-eligibility change refuse. | M `classes/webauthn.go` `VerifyAssertion`, `RecordAssertion` | `TestWebAuthn/assertions` (clone and BE change refused, the stored record unchanged), `TestWebAuthnCeremonySmoke` (M) | closed |
|
||||
| T-19.6-29 | RP ID or origin misconfiguration (Pitfall 7) | Explicit `webauthn.rp_id` and `origins` with app.url and frontend_url defaults; an IP host or no origin makes WebAuthn unavailable; the library checks origin and the RP ID hash. | M `classes/config.go` `loadWebAuthnConfig`; `classes/webauthn.go` `webAuthnFromConfig` | `TestWebAuthnShapes` (IP host, IP RP ID, no origin), `TestWebAuthn` (foreign origin at registration and assertion), `TestPasswordless/refused_foreign_origin` (M) | closed |
|
||||
| T-19.6-30 | social sign-in bypassing an enabled second factor (D-09) | sociallogin's `signIn` asks the gates with source social before FinishLogin and any token; a challenge replaces the token in both completions; refusals and errors fail closed; a link stays ungated. | S `classes/flow.go` `signIn`; M `classes/gate.go` | `TestSocialGate` (existing identity, verified email match, new account; no cookie, no SignedInEvent; refusals; error; link) (S); `TestEveryLoginPathIsGated/social_sign_in` (M) | closed (mutation-checked on M's gate) |
|
||||
| T-19.6-31 | passkey login of a banned, suspended or inactive account | Activation, `ThrottleStates` (anywhere) and `RejectIfThrottled` (this address) before any token; one generic body. | M `classes/passwordless.go` `FinishPasswordless` | `TestPasswordless/refused_banned`, `refused_suspended`, `refused_not_activated` (M) | closed |
|
||||
| T-19.6-32 | remote operations of plan 03 | Blocking decision first, fetch and range check before every push, no force, no deploy, fonoteka.go never pushed. | 19.6-03-SUMMARY.md "Remote operations" | process control | accepted (process; recorded in plan 03) |
|
||||
| T-19.6-33 | demo rendering the server's QR SVG | Rendered through an image data URL, never `v-html`; the helper escapes markup. | D `vue-demo-app/app/lib/twoFactor.ts` `svgDataUrl` | `twoFactor.test.ts` (`svgDataUrl` keeps no `<`), gate `--demo-web` (D) | closed |
|
||||
| T-19.6-34 | WebAuthn user handle from the numeric user id (A4) | PHP-compatible 8-byte big-endian handle so imported passkeys keep mapping. | M `classes/webauthn.go` `UserHandle` | `TestWebAuthnShapes/user_handle` (M) | accepted: it reveals only an internal id to the user's own authenticator |
|
||||
| T-19.6-35 | ceremony state in the memory cooler on several instances (A11) | Documented: multi-instance applications use the Redis cooler; a ceremony that reaches another instance fails closed. | M README | `TestPasswordless/refused_challenges_and_bodies` (unknown state refused) (M) | accepted (README) |
|
||||
| T-19.6-SC (plan 03) | Go module installs | go-webauthn v0.18.2 after the recorded approval; fonoteka.go's graph has no go-webauthn. | M `go.mod`; A `go.mod` | gate `--mfa`, `--fonoteka` (F) | closed |
|
||||
| T-19.6-36 | the gate's verdict | The `go test -json` detector fails on fail, skip, zero matches, "no tests to run" and missing names; a subtest pass never counts for its parent; the vitest detector needs the named file; docker NOT RUN explicit and fatal with `PHASE196_REQUIRE_DOCKER=1`. | F `scripts/check-phase19.6.sh` | `scripts/check-phase19.6.sh --self-test` (planted output for every detector, the additive, pin and migration checks, the docker rule on a faked PATH) (F) | closed |
|
||||
| T-19.6-37 | post-release fixes not reaching the applications | Task 4's table lists every production fix against every pin; Task 6 releases in D-17 order under the Task 5 reply and checks each pin with `merge-base --is-ancestor`; hold writes a todo. | 19.6-04-SUMMARY.md "Post-release fixes" | Task 6: `merge-base --is-ancestor 71d8f27` exits 0 for tag v0.1.1, the sm-demo-app gitlink and go.mod require, and the sm-bm-app gitlink | closed (released as v0.1.1; sm-bm-app's push waits on another session's unpushed commits, see 19.6-04-SUMMARY.md) |
|
||||
| T-19.6-38 | a token mint path that skips the second factor (assumption-delta debt) | Every mint site of U and M listed with its reason and checked against the source; every first-factor path of a TOTP user driven to a challenge; passkey and device poll mint only through their own proof. | M `login_paths_test.go` | `TestEveryLoginPathIsGated` (M) | closed for the listed paths; activate-by-code is accepted debt with the corrected reason of finding F-1 (deferred, below) |
|
||||
| T-19.6-SC (plan 04) | Go module installs | Plan 04 installs no module: no go.mod of U, M or S changed since the releases. | U, M, S `go.mod` | gate `--mfa` pins; `git diff` of the go.mod files since the release tags is empty | closed |
|
||||
|
||||
## D-14: passwordless passkey login
|
||||
|
||||
Passkey sign-in issues a session token without a password and without a second challenge, so each rule below is pinned by a subtest that fails when the rule goes.
|
||||
|
||||
| Rule | As built | Pinned by |
|
||||
|------|----------|-----------|
|
||||
| Setting default | `two_factor_passwordless_login` defaults to false (config and settings); both routes answer 403 `Passwordless login is not available.` while it is off, and also while `two_factor_mode` is disabled (fail closed). | `TestSettings/config_defaults_and_validation`, `TestPasswordless/off_or_mode_disabled`, `TestPasswordlessSmoke/setting_off` |
|
||||
| Credential eligibility | Only a credential registered as a passkey qualifies: `passwordless` is set when the registration asked for one (and only while the setting is on), the authenticator verified the user and the browser's credProps reported a resident key. A second-factor key, or a requested passkey without credProps, stays a second factor. | `TestWebAuthnShapes/passkey_flag`, `TestPasswordless/refused_second_factor_key`, `TestPasswordlessSmoke/second_factor_key_refused` |
|
||||
| User verification at registration | Passkey creation options require a resident key and user verification and ask for credProps; a registration without UV is refused. | `TestWebAuthnShapes/passkey_creation_options`, `passkey_flag/requested_without_uv` |
|
||||
| User verification at login | The request options require UV and allow no credential list (discoverable); `ValidatePasskeyLogin` runs with UV required. | `TestWebAuthnShapes/passkey_request_options`, `TestPasswordless/refused_uv_missing` |
|
||||
| User-handle binding | The assertion's user handle must be the credential owner's 8-byte handle; another user's handle or none is refused. | `TestPasswordless/refused_other_users_handle`, `refused_no_handle` |
|
||||
| Enabled and ownership checks | The credential row must exist, be enabled and be a passkey; a disabled or removed credential is refused. | `TestPasswordless/refused_disabled_credential`, `refused_removed_credential` |
|
||||
| Activation, ban and suspension | The owner must be activated and neither banned nor suspended, from any address (`ThrottleStates`) or this one (`RejectIfThrottled`). | `TestPasswordless/refused_not_activated`, `refused_banned`, `refused_suspended` |
|
||||
| Generic failures | Every refusal answers the same 401 `{"error":"WebAuthn verification failed."}`; no reason leaks. | every `TestPasswordless/refused_*` subtest compares the body byte for byte |
|
||||
| Single-use state | The passkey ceremony state is pulled from cooler once; a reused, unknown or over-long challenge, and a state spent by an unparsable attempt, are refused. Multi-instance caveat: with the memory cooler a ceremony must stay on one instance (README, T-19.6-35). | `TestPasswordless/refused_challenges_and_bodies`, `TestPasswordlessSmoke/state_once` |
|
||||
| Origin and RP ID | go-webauthn checks the client origin against `webauthn.origins` and the RP ID hash against `webauthn.rp_id`. | `TestPasswordless/refused_foreign_origin`, `TestWebAuthnShapes` |
|
||||
| Clone and backup-eligibility refusal | A clone warning refuses the sign-in and logs the credential row id; a changed BE flag is refused by the library (pinned on the second-factor path, which shares `ValidateLogin`'s flag checks). | `TestPasswordless/signs_in_without_a_second_challenge` (clone), `TestWebAuthn/assertions` (BE) |
|
||||
| Rate limiting | Both passkey routes sit in the 2fa-verify bucket (10 a minute per client address). | `TestRoutesAndBuckets` |
|
||||
| Deactivated-account restore | A deactivated owner is restored through golem15.user's `FinishLogin` with one reactivate mail: the passkey is both factors, so the restore follows a full sign-in (D-18 A10 holds). | `TestPasswordless/deactivated_owner_restored_and_mailed` |
|
||||
| Logging | Only the clone warning logs (credential row id and user id); no assertion, challenge or token. | section "Log calls" |
|
||||
| No second challenge | A passkey with user verification is both factors (D-14): a user with TOTP gets a token, no challenge row is created, the login event's source is `passkey`, and the gate never challenges source passkey. | `TestPasswordless/signs_in_without_a_second_challenge`, `TestGate/sources`, `TestEveryLoginPathIsGated/passkey_only_with_its_assertion` |
|
||||
|
||||
## D-18 hardening
|
||||
|
||||
| Item | As built | Pinned by |
|
||||
|------|----------|-----------|
|
||||
| A6 per-user failure cap | 10 failures in 15 minutes (configurable) from challenge rows, across instances and addresses; refuses new challenges and every verify route with their generic answers; the caller's in-flight attempt is not a failure. | `TestFailureCap` |
|
||||
| A8 email only when enabled, 3 sends | `email/send` and email verification need the enabled email method; three sends a challenge, each replacing the code. | `TestEmailCode/gating`, `sends_replace_and_cap` |
|
||||
| A9 promised lifetime | The mail promises min(email code TTL, the challenge's remaining minutes), rounded up, at least 1; the code dies with the challenge. | `TestEmailExpiryMinutes`, `TestEmailCode/expiry_capped_by_the_challenge`, `code_dies_with_the_challenge` |
|
||||
| A10 restore after the gate | Password, social and passkey sign-ins restore a deactivated account only after the second factor (or the passkey). | `TestLoginGateOrder`, `TestGate/deactivated_user_is_challenged_and_stays_deactivated`, `TestSocialGate/challenge_status_200`, `TestPasswordless/deactivated_owner_restored_and_mailed` |
|
||||
|
||||
## ASVS L1 notes (RESEARCH Security Domain)
|
||||
|
||||
- **V2 Authentication.** TOTP with a one-step window and per-step replay refusal (`TestTOTP`); WebAuthn with server-side state, UV rules and clone and BE refusal (`TestWebAuthn`, `TestPasswordless`); bcrypt recovery and email codes (`TestTokensAtRest`); the per-IP bucket and the per-user cap (`TestRoutesAndBuckets`, `TestFailureCap`); guarded attempt counter (`TestChallengeLifecycle`).
|
||||
- **V3 Session management.** Challenge tokens 64 characters, SHA-256 at rest, five minutes, one completion; the device JWT handed over once, followed through refresh and blacklisted on revoke (`TestDeviceHandOverConcurrent`, `TestDeviceRevokeAfterRefresh`); `tokens_valid_after` on password change (unchanged).
|
||||
- **V4 Access control.** jwt.auth on every management route, every row query scoped by user, digit-constrained ids (`TestRoutesAndBuckets`, `TestWebAuthn/delete_scoped_to_the_owner`); the admin reset behind its own permission (`TestAdminReset`, `TestResetTwoFactorAction`).
|
||||
- **V5 Validation.** Laravel's rules with Winter's English messages and PHP's 422 shapes (`TestPHPErrorBodies`); base32 and length checks on the TOTP secret; length caps on `device_name`, recovery input and the WebAuthn challenge echo.
|
||||
- **V6 Cryptography.** Libraries only (pquerna/otp, go-webauthn, boombuler/barcode for the matrix); `crypto/rand` for tokens and codes (`TestDeviceCodes`, `TestRecoveryCodeFormat`); `lagoon.Encrypted` for the TOTP secret.
|
||||
- **V7 Errors and logging.** Generic 401 bodies; no code, token, secret or assertion in a log line (`TestEmailCode/never_logged`, section "Log calls"); `Registration failed:` with fixed reasons.
|
||||
|
||||
## Log calls
|
||||
|
||||
Every non-test log call of M and of U's device and gate controllers, with what it carries:
|
||||
|
||||
| Where | Message | Attributes |
|
||||
|-------|---------|------------|
|
||||
| M `controllers/helpers.go` `serverError` | `golem15.mfa: <what>` | `err` (a database or library error; handlers pass no token, code or secret into it) |
|
||||
| M `controllers/challenge.go` | verified and failed event listener | `user_id`, the listener's `err` |
|
||||
| M `classes/gate.go` | challenged event listener | `user_id`, `err` |
|
||||
| M `classes/login.go` | login event listener | `user_id`, `err` |
|
||||
| M `classes/webauthn.go` | credential without a record; record does not decode; clone warning | `credential_row`, `user_id` |
|
||||
| M `classes/passwordless.go` | clone warning, passkey sign-in refused | `credential_row`, `user_id` |
|
||||
| U `controllers/devices.go` | session cleanup; store device session; finish device login; login event listener; revoke device session | `err`, `user_id` |
|
||||
| U `controllers/api_controller.go` `Login` | login gate | `user_id`, `err` |
|
||||
|
||||
None carries a token, code, secret, password, assertion or the device token. `TestEmailCode/never_logged` checks the mailed codes and the challenge token against every app and default log line of a run that forces the failure paths to log.
|
||||
|
||||
## Residual risks
|
||||
|
||||
- **Device-code phishing (D-12c):** an attacker can show a victim a QR or short code; the frontend must show the device name and address before confirming. Accepted by decision.
|
||||
- **`blacklist_grace` forks (Pitfall 15):** with a grace above 0, two concurrent refreshes of one device token both succeed and only one new jti is followed, so a revoke misses the other fork until it expires; the default grace is 0 and a password change ends both.
|
||||
- **Memory cooler (A11):** WebAuthn ceremonies need one instance or the Redis cooler (README).
|
||||
- **Numeric user handle (A4):** the handle reveals the internal user id to the user's own authenticator.
|
||||
- **Reverse proxies** may log `devices/status/{token}`; the token lives five minutes and is single use.
|
||||
- **JSON key order:** multi-key success bodies (the login challenge, `status`, `totp/setup`, `email/send`, the register answers) carry PHP's keys in Go's sorted order, not PHP's insertion order. JSON clients do not depend on key order, and the error bodies (single key or alphabetical in PHP too) and the 422 bodies (ordered explicitly) are byte-identical; recorded, not changed.
|
||||
- **Route constraint ordering (framework):** surf checks a `{id}` digit constraint inside the route's middleware, so an unauthenticated `DELETE …/trusted-devices/abc` answers jwt.auth's 401 where Laravel answered 404; with a session it is the router's 404. No information leaks either way.
|
||||
|
||||
## Deferred findings
|
||||
|
||||
### F-1: activate-by-code mints a session without the second factor when `require_activation` is off
|
||||
|
||||
**Status: deferred** by the user at plan 04 Task 5 (2026-10-26); tracked in `.planning/todos/pending/2026-10-26-activate-by-code-second-factor.md`. **Corrected reason for the accepted mint path:** activate-by-code skips the login gates; with the default `require_activation: true` a not-activated account cannot sign in, so it cannot have a second factor and nothing is skipped. With `require_activation: false` a not-activated account can enable one, and then possession of the mailed activation code stands in for the second factor once, at activation.
|
||||
|
||||
|
||||
- **What:** plan 01's assumption-delta decision accepts `POST /_user/api/v1/activate-by-code` as an ungated mint because "a new or not-yet-activated account cannot have 2FA yet". That holds with the default `golem15.user.activation.require_activation: true` (a not-activated account cannot sign in). With `require_activation: false` and `activate_mode: user`, a not-activated account signs in with its password, can enable TOTP, and a later `activate-by-code` with the mailed activation code answers `{"message":"Account activated","token":…}` without a challenge.
|
||||
- **Reproduced:** on this host through the mfa test harness (register in mode user, password login, TOTP setup and confirm, password login now challenged, `IssueActivationCode`, activate-by-code answers 200 with a token).
|
||||
- **Impact:** low. It needs a non-default configuration, a user who enabled a second factor before activating, and an attacker holding that user's unexpired activation code (their mailbox). It lets the mailbox alone stand in for the second factor, which a password reset does not (a reset mints no token).
|
||||
- **Options (raised at plan 04 Task 5; the user chose (c)):**
|
||||
(a) fix in sm-user-plugin: after the code verifies, `ActivateByCode` asks the login gates (for example with source password, so sm-mfa-plugin v0.1.0's gate challenges it) and answers the gate's body instead of the token; the account is still activated. A patch release of sm-user-plugin and pointer bumps in sm-demo-app, sm-bm-app and fonoteka.go.
|
||||
(b) accept with the corrected reason ("only with `require_activation: false`; the mailed code stands in for the second factor") recorded in plan 01's decision and the README.
|
||||
(c) defer to a todo for a later phase.
|
||||
- **Pinned now:** `TestEveryLoginPathIsGated/mint_sites` lists `ActivateByCode` with a pointer to this finding, so any change to the mint sites fails until the list is updated.
|
||||
|
||||
## Sign-off
|
||||
|
||||
Every T-19.6 threat of plans 01-04 is closed by a passing test or accepted with its reason; F-1 (under T-19.6-38) is deferred by the user with its corrected reason. `scripts/check-phase19.6.sh --all` passed with Docker (all 11 stages); see 19.6-04-SUMMARY.md.
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
phase: "19.6"
|
||||
slug: "two-factor-auth-and-device-flow-in-sm-user-plugin"
|
||||
status: verified
|
||||
# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate)
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: "2026-10-28"
|
||||
---
|
||||
|
||||
# Phase 19.6 — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail.
|
||||
|
||||
Implementation lives in sibling repos: **U** = sm-user-plugin (`fonoteka.go/plugins/golem15/user`), **M** = `sm-mfa-plugin`, **S** = `sm-sociallogin-plugin`, **D** = `sm-demo-app/vue-demo-app`; **F** = this repo. The detailed per-threat evidence (mutation checks, log-call sweep, D-14 passkey rules, D-18 hardening) is in `19.6-SECURITY-REVIEW.md`; this file is the register and sign-off.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| first-factor login → token mint | a correct password must not yield a token while a second factor is pending | credentials, JWT |
|
||||
| sm-user-plugin → other plugins | gates, admin reset service and listeners run M's code inside U's requests and transactions | user ids, transaction handle |
|
||||
| unauthenticated device → devices/initiate, devices/status | anyone can create sessions and poll with a token | device token, short code, device name |
|
||||
| signed-in user → devices/authorize, list, revoke | a bearer JWT binds or ends device sessions | device session ids, jti |
|
||||
| JWT refresh → device revocation | a refreshed device token must stay revocable | jti lineage |
|
||||
| holder of a password → challenge routes | unauthenticated clients present challenge tokens and guessed codes | challenge token, TOTP/email/recovery codes |
|
||||
| signed-in user → management routes | a JWT changes the user's own factors | TOTP secrets, recovery codes, credentials |
|
||||
| plugin → database / mailer | secrets at rest; one-time codes leave by email | hashed tokens, encrypted secret, bcrypt codes |
|
||||
| browser authenticator / frontend origin → WebAuthn routes | attestations and assertions bound to server-side ceremony state, RP ID and origins | WebAuthn ceremony data |
|
||||
| anonymous client → passwordless routes | a passkey alone yields a token | assertion, JWT |
|
||||
| social provider callback → signIn | a social identity must not bypass an enabled second factor | provider identity, JWT |
|
||||
| administrator → Users screen, settings | privileged reset of a user's factors; global 2FA policy | settings values |
|
||||
| demo frontend → API | server-generated SVG rendered in the browser | QR SVG |
|
||||
| test results → phase verdict; releases → app pins | a skipped test must not pass; fixes must reach every pin | gate output, git refs |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|----------|-------------|------------|--------|
|
||||
| T-19.6-01 | Elevation of privilege | login gate consultation | high | mitigate | U `controllers/login_gates.go` `CheckLoginGates`, called from `Login` before restore/mint; gate error → opaque 500; `TestLoginGates`, `TestLoginGateOrder`, `TestLoginGateSmoke/gate_error` | closed |
|
||||
| T-19.6-02 | Tampering | soft-delete restore before second factor | medium | mitigate | restore after the gates; `TestLoginGateOrder/challenged_soft_deleted_stays_deleted` (U), `TestGate/deactivated_user_is_challenged_and_stays_deactivated` (M) | closed |
|
||||
| T-19.6-03 | Spoofing | trusted devices surviving a password change | medium | mitigate | `AccessRevokedEvent` in the write transaction (U); M `classes/admin.go` `OnAccessRevoked`; `TestPasswordChangedSources`, `TestRevocation` | closed |
|
||||
| T-19.6-04 | Elevation of privilege | Reset 2FA record action | medium | mitigate | U `classes/two_factor_admin.go` `PermissionResetTwoFactor` registered in `admin_permissions.go`, no default role; `TestResetTwoFactorAction`, `TestAdminReset` | closed |
|
||||
| T-19.6-05 | Tampering | short-code guessing | medium | mitigate | U `classes/device_auth.go` `NewDeviceShortCode` (crypto/rand, 31^8); guarded authorize UPDATE; `TestDeviceCodes`, `TestDeviceAuthorize` (mutation-checked) | closed |
|
||||
| T-19.6-06 | Spoofing | device-code phishing | medium | accept | D-12c, see AR-01 | closed |
|
||||
| T-19.6-07 | Elevation of privilege | device hand-over race | high | mitigate | U `controllers/devices.go:282,300` guarded `status = 'confirmed'` UPDATE; `TestDeviceHandOverConcurrent` (mutation-checked) | closed |
|
||||
| T-19.6-08 | Elevation of privilege | revoked device keeps refreshing | high | mitigate | U `classes/device_auth.go` `HandOverDeviceJTI`; revoke blacklists jti; `TestDeviceRevokeAfterRefresh`; `blacklist_grace` fork see AR-02 | closed |
|
||||
| T-19.6-09 | Information disclosure | device tokens at rest and in URLs | medium | mitigate | SHA-256 only; F `modules/surf/accesslog.go` logs no path; `TestDeviceTokensAtRest`; proxy logging see AR-05 | closed |
|
||||
| T-19.6-10 | Denial of service | initiate filling the table | low | mitigate | user-api bucket, bounded cleanup (≤500); `TestDeviceInitiate/cleanup_is_bounded` | closed |
|
||||
| T-19.6-11 | Tampering | attacker-chosen device_name | low | mitigate | ≤255 runes, 422; `TestDeviceInitiate/device_name` | closed |
|
||||
| T-19.6-12 | Tampering | core plugin contract | medium | mitigate | additive only; gate `--userplugin`, `--fonoteka` | closed |
|
||||
| T-19.6-13 | Spoofing | TOTP/email brute force | high | mitigate | M `classes/challenge.go` `FailureCapReached`, 2fa-verify bucket, 5 attempts; `TestFailureCap`, `TestRoutesAndBuckets` | closed |
|
||||
| T-19.6-14 | Tampering | parallel verifies | high | mitigate | M `classes/challenge.go:96,119` `completed_at IS NULL AND attempts < max_attempts`; `TestChallengeLifecycle/one_completion_when_factors_race` (mutation-checked) | closed |
|
||||
| T-19.6-15 | Spoofing | TOTP replay | medium | mitigate | M `classes/methods.go` `AcceptTOTPCounter`; `TestTOTP/replay` | closed |
|
||||
| T-19.6-16 | Spoofing | email downgrade of TOTP-only user | high | mitigate | M `classes/email.go` `SendEmailCode` gated on enabled email method; `TestEmailCode/gating` | closed |
|
||||
| T-19.6-17 | Denial of service | mail bombing | medium | mitigate | M `classes/email.go:83` `email_sends < 3`; `TestEmailCode/sends_replace_and_cap` (mutation-checked) | closed |
|
||||
| T-19.6-18 | Information disclosure | secrets at rest | high | mitigate | SHA-256 tokens, M `models/two_factor_method.go` `Secret lagoon.Encrypted`, bcrypt codes; `TestTokensAtRest` | closed |
|
||||
| T-19.6-19 | Information disclosure | logs and error strings | medium | mitigate | log-call sweep (SECURITY-REVIEW "Log calls"); `TestEmailCode/never_logged` | closed |
|
||||
| T-19.6-20 | Spoofing | stolen trusted-device token | medium | mitigate | M `classes/trusted.go`, `classes/gate.go`; `TestTrustedDevice`, `TestRevocation` | closed |
|
||||
| T-19.6-21 | Elevation of privilege | management routes on other users' rows | high | mitigate | JWT-scoped queries, digit `{id}`; `TestRoutesAndBuckets`, `TestWebAuthn/delete_scoped_to_the_owner` | closed |
|
||||
| T-19.6-22 | Information disclosure | recovery codes after creation | medium | mitigate | shown once, count route needs password; `TestRecovery/first_set_only_when_created`, `count_route` | closed |
|
||||
| T-19.6-23 | Denial of service | bcrypt CPU per wrong code | low | mitigate | M `classes/recovery.go` `NormalizeRecoveryCode` (≤32 chars); `TestRecoveryCodeFormat` | closed |
|
||||
| T-19.6-24 | Tampering | settings values | low | mitigate | M `models/settings.go` `BeforeValidate` allow-lists; defect fixed in M `71d8f27`, released v0.1.1; `TestSettings`, `TestPHPUser005` | closed |
|
||||
| T-19.6-25 | Spoofing | client-chosen TOTP secret at confirm | low | accept | PHP parity, see AR-03 | closed |
|
||||
| T-19.6-26 | Spoofing | client-supplied WebAuthn challenge | high | mitigate | server-side state in cooler, single-use `Pull`; `TestWebAuthnShapes/registration_state`, `TestWebAuthn/registration` | closed |
|
||||
| T-19.6-27 | Elevation of privilege | passkey login with second-factor-only credential (D-14) | high | mitigate | M `classes/passwordless.go` `ValidatePasskeyLogin` with UV, `passwordless` column check; `TestPasswordless` (mutation-checked); D-14 table in SECURITY-REVIEW | closed |
|
||||
| T-19.6-28 | Spoofing | cloned authenticator | medium | mitigate | `CloneWarning` refusal (M `classes/webauthn.go:506`, `classes/passwordless.go:110`); `TestWebAuthn/assertions` | closed |
|
||||
| T-19.6-29 | Spoofing | RP ID / origin misconfiguration | medium | mitigate | M `classes/config.go` `loadWebAuthnConfig`; `TestWebAuthnShapes`, `TestPasswordless/refused_foreign_origin` | closed |
|
||||
| T-19.6-30 | Elevation of privilege | social sign-in bypassing 2FA (D-09) | high | mitigate | S `classes/flow.go:343` `CheckLoginGates` with `LoginSourceSocial` before FinishLogin; `TestSocialGate`, `TestEveryLoginPathIsGated/social_sign_in` | closed |
|
||||
| T-19.6-31 | Elevation of privilege | passkey login of banned/suspended/inactive account | high | mitigate | M `classes/passwordless.go:126` `RejectIfThrottled` + activation check; `TestPasswordless/refused_banned`, `refused_suspended`, `refused_not_activated` | closed |
|
||||
| T-19.6-32 | Tampering | remote operations (plan 03 pushes) | medium | mitigate | process control: fetch + range check before every push, no force, no deploy (19.6-03-SUMMARY "Remote operations") | closed |
|
||||
| T-19.6-33 | Tampering | demo rendering QR SVG | low | mitigate | D `app/lib/twoFactor.ts` `svgDataUrl` (img data URL, no `v-html`); `twoFactor.test.ts` | closed |
|
||||
| T-19.6-34 | Information disclosure | user handle from numeric id (A4) | low | accept | see AR-04 | closed |
|
||||
| T-19.6-35 | Denial of service | ceremony state in memory cooler, multi-instance (A11) | low | accept | README; fails closed; see AR-06 | closed |
|
||||
| T-19.6-36 | Tampering | check-phase19.6.sh verdict | medium | mitigate | F `scripts/check-phase19.6.sh --self-test` (fail/skip/zero-match/missing-name detectors) | closed |
|
||||
| T-19.6-37 | Tampering | post-release fixes not reaching apps | medium | mitigate | `71d8f27` is an ancestor of M tag v0.1.1; pinned by sm-demo-app `9166a1e`, sm-bm-app `fe4e292` | closed |
|
||||
| T-19.6-38 | Elevation of privilege | token mint path bypassing 2FA | high | mitigate | M `login_paths_test.go` `TestEveryLoginPathIsGated` (every mint site listed); activate-by-code residual = F-1, see AR-07 | closed |
|
||||
| T-19.6-SC | Tampering | Go module installs (plans 01–04) | high | mitigate | M `go.mod`: pquerna/otp v1.5.0, boombuler/barcode v1.1.0, go-webauthn v0.18.2 (approved, `.planning/notes/2026-10-21-mfa-otp-webauthn.md`); `go list -deps` of M has no `gopkg.in/yaml.v3`; fonoteka.go `go.mod`/`go.sum` have no go-webauthn | closed |
|
||||
|
||||
*Status: open · closed · open — below high threshold (non-blocking)*
|
||||
*Severity: critical > high > medium > low — only open threats at or above workflow.security_block_on count toward threats_open*
|
||||
*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
| Risk ID | Threat Ref | Rationale | Accepted By | Date |
|
||||
|---------|------------|-----------|-------------|------|
|
||||
| AR-01 | T-19.6-06 | Device-code phishing: D-12c keeps PHP's authorize-with-JWT rule; the device list shows name and IP and revoke signs the device out at once; the frontend must show device name and address before confirming. | user (D-12c, 19.6-CONTEXT) | 2026-10-26 |
|
||||
| AR-02 | T-19.6-08 | `blacklist_grace` > 0 lets two concurrent refreshes fork; only one jti is followed, so revoke misses the other until it expires. Default grace is 0; a password change ends both. | plan 01 (Pitfall 15) | 2026-10-26 |
|
||||
| AR-03 | T-19.6-25 | Client-chosen TOTP secret at confirm (PHP parity): own account only, base32 and 16–64 chars validated, a current code from the secret required. | plan 02 threat model | 2026-10-26 |
|
||||
| AR-04 | T-19.6-34 | PHP-compatible 8-byte user handle reveals only the internal user id to the user's own authenticator; keeps imported passkeys mappable. | plan 03 threat model (A4) | 2026-10-26 |
|
||||
| AR-05 | T-19.6-09 | Reverse proxies may log `devices/status/{token}`; the token lives five minutes and is single use (README). | plan 01 threat model | 2026-10-26 |
|
||||
| AR-06 | T-19.6-35 | With the memory cooler a WebAuthn ceremony must stay on one instance; multi-instance apps use the Redis cooler (README); ceremonies fail closed otherwise. | plan 03 threat model (A11) | 2026-10-26 |
|
||||
| AR-07 | T-19.6-38 (F-1) | activate-by-code mints a token without the second factor only when `require_activation: false` and the user enabled 2FA before activating; the mailed activation code stands in for the second factor once. Low impact, non-default config. Deferred; pinned by `TestEveryLoginPathIsGated/mint_sites`; todo `.planning/todos/pending/2026-10-26-activate-by-code-second-factor.md`. | user (plan 04 Task 5, option c) | 2026-10-26 |
|
||||
|
||||
*Accepted risks do not resurface in future audit runs.*
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| 2026-10-26 | 42 | 42 | 0 | plan 04 security review (`19.6-SECURITY-REVIEW.md`; mutation checks, `check-phase19.6.sh --all` with Docker) |
|
||||
| 2026-10-28 | 42 | 42 | 0 | /msd-secure-phase (L1 grep verification of cited mitigations in U, M, S, D, F; short-circuit: register authored at plan time, ASVS 1) |
|
||||
|
||||
Threat count: T-19.6-01..38 plus four T-19.6-SC rows (plans 01–04), merged into one row above.
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [x] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [x] Accepted risks documented in Accepted Risks Log
|
||||
- [x] `threats_open: 0` confirmed
|
||||
- [x] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** verified 2026-10-28
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
status: testing
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
source: [19.6-VERIFICATION.md]
|
||||
started: 2026-10-26T16:03:15.784Z
|
||||
updated: 2026-10-26T16:03:15.784Z
|
||||
---
|
||||
|
||||
## Current Test
|
||||
|
||||
number: 1
|
||||
name: Run a real-browser WebAuthn ceremony against an instance with webauthn in two_factor_available_methods, served over HTTPS with a hostname RP ID: register a security key (POST 2fa/webauthn/register/options, navigator.credentials.create, POST 2fa/webauthn/register), sign out, sign in with the password and complete the challenge through 2fa/webauthn/options and 2fa/webauthn/verify. With two_factor_passwordless_login on, register a passkey (passwordless true) and sign in through 2fa/webauthn/passwordless/options and /verify.
|
||||
expected: |
|
||||
Registration answers {message, credential:{id,name,created_at}, status} (plus recovery_codes on the first set); the challenge completes with {token, user}; the passkey sign-in issues a token with no second challenge; a second-factor-only key is refused for passwordless with 401 WebAuthn verification failed.
|
||||
awaiting: user response
|
||||
|
||||
## Tests
|
||||
|
||||
### 1. Run a real-browser WebAuthn ceremony against an instance with webauthn in two_factor_available_methods, served over HTTPS with a hostname RP ID: register a security key (POST 2fa/webauthn/register/options, navigator.credentials.create, POST 2fa/webauthn/register), sign out, sign in with the password and complete the challenge through 2fa/webauthn/options and 2fa/webauthn/verify. With two_factor_passwordless_login on, register a passkey (passwordless true) and sign in through 2fa/webauthn/passwordless/options and /verify.
|
||||
expected: Registration answers {message, credential:{id,name,created_at}, status} (plus recovery_codes on the first set); the challenge completes with {token, user}; the passkey sign-in issues a token with no second challenge; a second-factor-only key is refused for passwordless with 401 WebAuthn verification failed.
|
||||
result: [pending]
|
||||
|
||||
### 2. On the demo (vue-demo-app served by sm-demo-app at the v0.1.13 / v0.1.2 / v0.1.5 pins): sign in, open /account/security, enable TOTP by scanning the QR code with a real authenticator app and entering a code, keep the recovery codes shown once, sign out, sign in again and answer the challenge with an app code; repeat with a recovery code; then disable TOTP.
|
||||
expected: The QR renders as an image and scans; the recovery codes appear once after confirm; the login page switches to the code step on two_factor_required and stores the token after verify or recovery; a used recovery code is refused the second time; after disable the login issues a token directly.
|
||||
result: [pending]
|
||||
|
||||
### 3. Review the judgment-tier prohibition verdicts in the 'Prohibitions' section of this report (non-authoritative LLM-judge verdicts, 19 items across plans 01-04).
|
||||
expected: Confirm or dispute each verdict; all are recorded as no violation found.
|
||||
result: [pending]
|
||||
|
||||
## Summary
|
||||
|
||||
total: 3
|
||||
passed: 0
|
||||
issues: 0
|
||||
pending: 3
|
||||
skipped: 0
|
||||
blocked: 0
|
||||
|
||||
## Gaps
|
||||
@@ -3,10 +3,11 @@ phase: "19.6"
|
||||
slug: "two-factor-auth-and-device-flow-in-sm-user-plugin"
|
||||
# status lifecycle: draft (seeded by plan-phase) → validated (set by validate-phase §6)
|
||||
# audit-milestone §5.5 distinguishes NOT-VALIDATED (draft) from PARTIAL (validated + nyquist_compliant: false) (#2117)
|
||||
status: draft
|
||||
nyquist_compliant: false
|
||||
wave_0_complete: false
|
||||
status: validated
|
||||
nyquist_compliant: true
|
||||
wave_0_complete: true
|
||||
created: "2026-10-21"
|
||||
validated: "2026-10-26"
|
||||
---
|
||||
|
||||
# Phase 19.6 — Validation Strategy
|
||||
@@ -19,30 +20,49 @@ created: "2026-10-21"
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| **Framework** | Go `testing` + `httptest`; testcontainers-go Postgres (DB tests skip under `-short`) |
|
||||
| **Config file** | none — Wave 0 adds `sm-mfa-plugin/testmain_test.go` and `harness_test.go` (copied from `sm-sociallogin-plugin`) |
|
||||
| **Framework** | Go `testing` + `httptest`; testcontainers-go Postgres (DB tests skip under `-short`); vitest for `vue-demo-app` |
|
||||
| **Config file** | none: `sm-mfa-plugin/testmain_test.go` and `harness_test.go` (Wave 0, plan 02), sm-user-plugin's `session_test.go` and `admin_harness_test.go` |
|
||||
| **Quick run command** | `go -C ../sm-mfa-plugin test -short ./...` and `go -C ../fonoteka.go test -short ./plugins/golem15/user/...` |
|
||||
| **Full suite command** | `scripts/check-phase19.6.sh` (go, userplugin, mfa, sociallogin, demo, bm, fonoteka, docker, docs stages) |
|
||||
| **Estimated runtime** | ~180 seconds (full, with Docker) |
|
||||
| **Full suite command** | `scripts/check-phase19.6.sh --all` (self-test, go, userplugin, mfa, sociallogin, demo, demo-web, bm, fonoteka, docs, then docker) |
|
||||
| **Estimated runtime** | about 6 minutes for `--all` with Docker on this host |
|
||||
|
||||
---
|
||||
|
||||
## Sampling Rate
|
||||
|
||||
- **After every task commit:** `go vet ./...` + `go test -short ./...` of the touched repo
|
||||
- **After every plan wave:** full suites (Docker) of every touched repo
|
||||
- **Before `/msd-verify-work`:** `scripts/check-phase19.6.sh` must be green
|
||||
- **After every task commit:** `go vet ./...` + `go test -short ./...` of the touched repository
|
||||
- **After every plan wave:** full suites (Docker) of every touched repository
|
||||
- **Before `/msd-verify-work`:** `scripts/check-phase19.6.sh --all` must be green
|
||||
- **Max feedback latency:** 60 seconds for the short loop
|
||||
|
||||
---
|
||||
|
||||
## Per-Task Verification Map
|
||||
|
||||
Decision → test map is in `19.6-RESEARCH.md` § Validation Architecture; the planner assigns task IDs.
|
||||
Gate stages are `scripts/check-phase19.6.sh --<stage>`; a test named under a stage is required by name there (a skip or a missing name fails the stage). U = sm-user-plugin, M = sm-mfa-plugin, S = sm-sociallogin-plugin, D = sm-demo-app, B = sm-bm-app, A = the fonoteka.go workspace.
|
||||
|
||||
| Task ID | Plan | Wave | Requirement | Threat Ref | Secure Behavior | Test Type | Automated Command | File Exists | Status |
|
||||
| Task ID | Plan | Wave | Requirement | Threat Ref | Secure Behavior | Test Type | Automated Command (gate stage: tests) | File Exists | Status |
|
||||
|---------|------|------|-------------|------------|-----------------|-----------|-------------------|-------------|--------|
|
||||
| 19.6-XX-XX | TBD | TBD | D-XX | T-19.6-XX | per RESEARCH map | unit/integration | per RESEARCH map | ❌ W0 | ⬜ pending |
|
||||
| 19.6-01-01 | 01 | 1 | D-02, D-04, D-18 A10 | T-19.6-01, T-19.6-02 | Password login asks the gates before restore and mint; a gate error fails closed; the library note names the pins | unit + integration | `check-phase19.6.sh --userplugin`: TestLoginGatesSmoke, TestLoginGates (also `-race`); `--docker`: TestLoginGateSmoke, TestLoginGateOrder (U); `--docs`: the note and STACK rows | ✅ | ✅ green |
|
||||
| 19.6-01-02 | 01 | 1 | D-07, D-15 | T-19.6-03, T-19.6-04 | Password writes fire the revocation event in their transaction; Reset 2FA only with a service and the permission | integration | `check-phase19.6.sh --docker`: TestPasswordChangedEventSmoke, TestPasswordChangedSources, TestResetTwoFactorSlotSmoke, TestResetTwoFactorAction (U) | ✅ | ✅ green |
|
||||
| 19.6-01-03 | 01 | 1 | D-11, D-12a, D-12c, D-06, D-16 | T-19.6-05, T-19.6-07, T-19.6-09, T-19.6-10, T-19.6-11 | Device initiate, status and authorize with hashed tokens, one-time hand-over, bounded cleanup | unit + integration | `--userplugin`: TestDeviceCodesSmoke, TestDeviceCodes, TestDeviceAuthURL, TestDeviceDisplayName; `--docker`: TestDeviceFlowSmoke, TestDeviceInitiate, TestDeviceStatus, TestDeviceAuthorize, TestDeviceHandOverConcurrent, TestDeviceTokensAtRest, TestDeviceAuthSessionsMigration (U) | ✅ | ✅ green |
|
||||
| 19.6-01-04 | 01 | 1 | D-12b | T-19.6-08 | Device list and revoke; the jti follows refresh | integration | `--docker`: TestDeviceRevokeSmoke, TestDeviceListAndRevoke, TestDeviceRevokeAfterRefresh (U) | ✅ | ✅ green |
|
||||
| 19.6-01-05 | 01 | 1 | D-04 | T-19.6-SC | Human package check before any install | manual (checkpoint) | reply "approved" (19.6-01-SUMMARY.md); `--mfa` pins, `--fonoteka` module check | ✅ | ✅ green |
|
||||
| 19.6-02-01 | 02 | 2 | SC-2, D-04, D-05, D-06 | T-19.6-13, T-19.6-15, T-19.6-18 | TOTP with QR SVG, challenge instead of a token, replay refused, 2fa-verify bucket | unit + integration | `--mfa`: TestQRSVGSmoke, TestTOTP, TestQRSVG, TestRoutesAndBuckets; `--docker`: TestTracerSmoke, TestGate, TestChallengeLifecycle, TestTokensAtRest, TestPHPErrorBodies (M) | ✅ | ✅ green |
|
||||
| 19.6-02-02 | 02 | 2 | D-05, D-18 A6, A8, A9, D-19 | T-19.6-13, T-19.6-14, T-19.6-16, T-19.6-17, T-19.6-22, T-19.6-23 | Recovery codes once, email codes only when enabled with a send cap and a capped lifetime, the per-user failure cap | unit + integration | `--mfa`: TestRecoveryCodeFormat, TestMaskEmail, TestEmailExpiryMinutes; `--docker`: TestChallengeSmoke, TestRecovery, TestEmailCode, TestFailureCap (M) | ✅ | ✅ green |
|
||||
| 19.6-02-03 | 02 | 2 | D-07, D-10, D-12, D-13, D-15, D-16 | T-19.6-03, T-19.6-20, T-19.6-21, T-19.6-24 | Trusted devices revoked on every password change and the last method; settings per request with allow-lists; admin reset | integration | `--docker`: TestTrustedSettingsSmoke, TestTrustedDevice, TestRevocation, TestSettings, TestStatusShape, TestAdminReset, TestMigrations (M); `--mfa`: TestPHPMethodMap, TestPHPUser005 | ✅ | ✅ green |
|
||||
| 19.6-03-01 | 03 | 3 | SC-1, D-08, D-16 | T-19.6-26, T-19.6-28, T-19.6-29 | WebAuthn second factor with server-side state, clone and BE refusal, origin and RP checks | unit + integration | `--mfa`: TestWebAuthnCeremonySmoke, TestWebAuthnShapes; `--docker`: TestWebAuthnSmoke, TestWebAuthn (M) | ✅ | ✅ green |
|
||||
| 19.6-03-02 | 03 | 3 | D-14, D-09 | T-19.6-27, T-19.6-30, T-19.6-31 | Passkeys only for eligible credentials and allowed owners; social sign-in through the gate | integration | `--docker`: TestPasswordlessSmoke, TestPasswordless, TestEveryLoginPathIsGated (M); TestSocialGateSmoke, TestSocialGate (S) | ✅ | ✅ green |
|
||||
| 19.6-03-03 | 03 | 3 | D-20 | T-19.6-33 | Demo TOTP setup and challenge; the QR rendered as an image data URL | unit | `check-phase19.6.sh --demo-web`: `app/lib/twoFactor.test.ts` (D) | ✅ | ✅ green |
|
||||
| 19.6-03-04 | 03 | 3 | D-17 | T-19.6-32 | Go-ahead before any push, tag or repository creation | manual (checkpoint) | reply recorded in 19.6-03-SUMMARY.md | ✅ | ✅ green |
|
||||
| 19.6-03-05 | 03 | 3 | D-17 | T-19.6-32 | Releases in D-17 order, no force-push | manual + gate | `--mfa` (go.mod pins), `--sociallogin`; ls-remote checks in 19.6-03-SUMMARY.md | ✅ | ✅ green |
|
||||
| 19.6-03-06 | 03 | 3 | D-17, D-01 | T-19.6-12, T-19.6-SC | Demo and bm mount mfa; fonoteka.go builds at the new pointer without second-factor modules | integration | `--demo`: TestBootAllPlugins, TestGoModRequiresTags, TestMFAMounted; `--bm`: TestSocialLoginMounted, TestMFAMounted; `--fonoteka` (no golem15.mfa mount, no go-webauthn, pquerna or boombuler module) | ✅ | ✅ green |
|
||||
| 19.6-04-01 | 04 | 4 | SC-4 | T-19.6-36 | The gate fails closed on a failed, skipped, missing or unrun test | unit (script) | `check-phase19.6.sh --self-test` | ✅ | ✅ green |
|
||||
| 19.6-04-02 | 04 | 4 | SC-4, D-02, D-07, D-11, D-12a, D-12b, D-12c, D-15, D-16, D-18 | T-19.6-01..T-19.6-12 | Every user-plugin seam and device-flow state pinned by name | unit + integration | `--userplugin` and `--docker` (rows 19.6-01-01..04) | ✅ | ✅ green |
|
||||
| 19.6-04-03 | 04 | 4 | SC-4, D-05..D-10, D-12..D-16, D-18, D-19 | T-19.6-13..T-19.6-31, T-19.6-38 | Every second-factor decision, every PHP body and the login-path invariant pinned by name | unit + integration | `--mfa`, `--sociallogin` and `--docker` (rows 19.6-02-01..19.6-03-02) | ✅ | ✅ green |
|
||||
| 19.6-04-04 | 04 | 4 | SC-4, D-14 | all T-19.6 | PHP security test mapped; security review with the D-14 section; the whole gate green | unit + review | `check-phase19.6.sh --all`; `--mfa`: TestPHPMethodMap, TestPHPUser005; 19.6-SECURITY-REVIEW.md | ✅ | ✅ green |
|
||||
| 19.6-04-05 | 04 | 4 | D-17 | T-19.6-37 | Go-ahead before releasing post-release fixes | manual (checkpoint) | reply recorded in 19.6-04-SUMMARY.md ("release"; F-1 deferred) | ✅ | ✅ green |
|
||||
| 19.6-04-06 | 04 | 4 | D-17 | T-19.6-37 | Each post-release fix reaches every pin (`merge-base --is-ancestor`) or is a tracked todo | integration + manual | `check-phase19.6.sh --demo`, `--bm`, `--fonoteka` at the final pins; merge-base results in 19.6-04-SUMMARY.md | ✅ | ✅ green |
|
||||
|
||||
*Status: ⬜ pending · ✅ green · ❌ red · ⚠️ flaky*
|
||||
|
||||
@@ -50,10 +70,10 @@ Decision → test map is in `19.6-RESEARCH.md` § Validation Architecture; the p
|
||||
|
||||
## Wave 0 Requirements
|
||||
|
||||
- [ ] `sm-mfa-plugin/testmain_test.go`, `harness_test.go` — boot `golem15.user` + `golem15.mfa`
|
||||
- [ ] WebAuthn fixtures — recorded attestation/assertion JSON or a virtual authenticator
|
||||
- [ ] Clock injection for TOTP tests
|
||||
- [ ] user-plugin harness helper for device-flow tests
|
||||
- [x] `sm-mfa-plugin/testmain_test.go`, `harness_test.go` — boot `golem15.user` + `golem15.mfa` (plan 02)
|
||||
- [x] WebAuthn fixtures — a virtual authenticator (`webauthn_authenticator_test.go`, plan 03)
|
||||
- [x] Clock injection for TOTP tests — `VerifyTOTP(secret, code, at, lastCounter)` with pquerna's `GenerateCodeCustom` at chosen times (`TestTOTP`)
|
||||
- [x] user-plugin harness helper for device-flow tests — `session_test.go` and `admin_harness_test.go` helpers plus `device_flow_smoke_test.go`'s device helpers
|
||||
|
||||
---
|
||||
|
||||
@@ -62,16 +82,17 @@ Decision → test map is in `19.6-RESEARCH.md` § Validation Architecture; the p
|
||||
| Behavior | Requirement | Why Manual | Test Instructions |
|
||||
|----------|-------------|------------|-------------------|
|
||||
| WebAuthn registration and login in a real browser | D-08 / SC-1 | Browser authenticator ceremony cannot run in `go test` | Register a passkey on the demo instance over HTTPS with a hostname RP ID, then sign in with it |
|
||||
| Demo TOTP screens in a browser | D-20 | Look and flow of the Nuxt pages | On the deployed demo: enable TOTP from the QR, keep the recovery codes, sign out, answer the challenge with a code and with a recovery code |
|
||||
|
||||
---
|
||||
|
||||
## Validation Sign-Off
|
||||
|
||||
- [ ] All tasks have `<automated>` verify or Wave 0 dependencies
|
||||
- [ ] Sampling continuity: no 3 consecutive tasks without automated verify
|
||||
- [ ] Wave 0 covers all MISSING references
|
||||
- [ ] No watch-mode flags
|
||||
- [ ] Feedback latency < 60s
|
||||
- [ ] `nyquist_compliant: true` set in frontmatter
|
||||
- [x] All tasks have `<automated>` verify or Wave 0 dependencies
|
||||
- [x] Sampling continuity: no 3 consecutive tasks without automated verify
|
||||
- [x] Wave 0 covers all MISSING references
|
||||
- [x] No watch-mode flags
|
||||
- [x] Feedback latency < 60s
|
||||
- [x] `nyquist_compliant` set to true in the frontmatter
|
||||
|
||||
**Approval:** pending
|
||||
**Approval:** validated 2026-10-26 (plan 19.6-04, `check-phase19.6.sh --all`; post-release fix released as sm-mfa-plugin v0.1.1).
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
---
|
||||
phase: 19.6-two-factor-auth-and-device-flow-in-sm-user-plugin
|
||||
verified: 2026-10-26T16:05:13Z
|
||||
status: human_needed
|
||||
score: 45/45 must-haves verified
|
||||
covered_files:
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-01-PLAN.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-01-SUMMARY.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-02-PLAN.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-02-SUMMARY.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-03-PLAN.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-03-SUMMARY.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-04-PLAN.md
|
||||
- .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-04-SUMMARY.md
|
||||
- scripts/check-phase19.6.sh
|
||||
covered_digest: "v2:sha256:96a0670daff17ba82f47a71e37a4bbbdb227e5dbe07d458f1a268f3389078072"
|
||||
# Files outside this repository are pinned by commit instead of digest (all equal to the release tags on the remotes):
|
||||
# sm-user-plugin 07196a4 = v0.1.13 (checkout fonoteka.go/plugins/golem15/user), sm-mfa-plugin 463c750 = v0.1.2,
|
||||
# sm-sociallogin-plugin ecfb8a7 = v0.1.5, vue-demo-app 44a5229 (origin master), sm-demo-app 8fcdbdd (origin master;
|
||||
# gitlinks and go.mod requires at the three tags), sm-bm-app HEAD c665073 (gitlinks at the three tags via the local,
|
||||
# UNPUSHED bumps 56a79ab, 1c1db04, 604b06c; origin/master ebb2266 still pins user 3b22134, mfa 33ad164, sociallogin
|
||||
# b752177), fonoteka.go e36577a (user gitlink 07196a4, unpushed by design).
|
||||
behavior_unverified: 0
|
||||
overrides_applied: 0
|
||||
# Refreshed after bc8f954 (gate requires the six review-fix regression tests): --self-test and --docker re-run, digest recomputed.
|
||||
# Human items below seed 19.6-UAT.md (created 2026-10-26T16:03:15Z, 3 pending, no results yet).
|
||||
human_verification:
|
||||
- test: "Run a real-browser WebAuthn ceremony against an instance with webauthn in two_factor_available_methods, served over HTTPS with a hostname RP ID: register a security key (POST 2fa/webauthn/register/options, navigator.credentials.create, POST 2fa/webauthn/register), sign out, sign in with the password and complete the challenge through 2fa/webauthn/options and 2fa/webauthn/verify. With two_factor_passwordless_login on, register a passkey (passwordless true) and sign in through 2fa/webauthn/passwordless/options and /verify."
|
||||
expected: "Registration answers {message, credential:{id,name,created_at}, status} (plus recovery_codes on the first set); the challenge completes with {token, user}; the passkey sign-in issues a token with no second challenge; a second-factor-only key is refused for passwordless with 401 WebAuthn verification failed."
|
||||
why_human: "Server-side ceremonies are proven with a software authenticator (real ECDSA P-256 and CBOR, TestWebAuthn, TestPasswordless), but no test runs a browser's navigator.credentials JSON (credProps, transports, base64url fields) against the D-08 shapes, or a real RP ID and origin. No client exists yet: the demo has no WebAuthn screens and its config/golem15.mfa.yaml leaves webauthn out of the available methods, so the 19.6-VALIDATION.md manual row ('on the demo instance') needs another client page."
|
||||
- test: "On the demo (vue-demo-app served by sm-demo-app at the v0.1.13 / v0.1.2 / v0.1.5 pins): sign in, open /account/security, enable TOTP by scanning the QR code with a real authenticator app and entering a code, keep the recovery codes shown once, sign out, sign in again and answer the challenge with an app code; repeat with a recovery code; then disable TOTP."
|
||||
expected: "The QR renders as an image and scans; the recovery codes appear once after confirm; the login page switches to the code step on two_factor_required and stores the token after verify or recovery; a used recovery code is refused the second time; after disable the login issues a token directly."
|
||||
why_human: "User-facing flow and look (D-20). Covered only by twoFactor.test.ts helpers and the Go route tests; SUMMARY 03 and 04 record the browser run as NOT RUN."
|
||||
- test: "Review the judgment-tier prohibition verdicts in the 'Prohibitions' section of this report (non-authoritative LLM-judge verdicts, 19 items across plans 01-04)."
|
||||
expected: "Confirm or dispute each verdict; all are recorded as no violation found."
|
||||
why_human: "Judgment-tier prohibitions never pass silently (ADR-550 D4)."
|
||||
---
|
||||
|
||||
# Phase 19.6: Two-factor auth and device flow in sm-user-plugin Verification Report
|
||||
|
||||
**Phase Goal:** `sm-user-plugin` has the PHP user plugin's second factors and device login: TOTP, WebAuthn, email codes, recovery codes and trusted devices, a challenge step during login, and QR/code device authorization. Per CONTEXT D-01 the second factors live in the new `sm-mfa-plugin`; per D-03 the device flow stays in sm-user-plugin.
|
||||
**Verified:** 2026-10-26T16:05:13Z (refreshed after bc8f954; first pass 15:58:30Z)
|
||||
**Status:** human_needed
|
||||
**Re-verification:** No, initial verification, refreshed once after the gate change bc8f954 (no prior VERIFICATION had gaps)
|
||||
|
||||
**MVP-mode note:** ROADMAP marks the phase `mode: mvp`, but the goal is not a user story. Every plan records the decision not to invent one (as in 19.5), so this report runs standard goal-backward verification against SC-1..SC-4, D-01..D-20 (with D-12a/b/c) and the 41 plan must-haves. No "User Flow Coverage" table is produced; the user-facing demo flow is human item 2.
|
||||
|
||||
**Release state, checked in the repositories.** sm-user-plugin `v0.1.13` = 07196a4, sm-mfa-plugin `v0.1.2` = 463c750 and sm-sociallogin-plugin `v0.1.5` = ecfb8a7 exist on the remotes, and each remote `master` equals its tag. Each checkout is clean at that commit. sm-demo-app `origin/master` = 8fcdbdd: its gitlinks are the three tag commits, and go.mod requires v0.1.13, v0.1.2 and v0.1.5. sm-bm-app's HEAD carries the same gitlinks, but the bumps (56a79ab, 1c1db04, 604b06c) sit among 39 unpushed commits, so `origin/master` ebb2266 still pins user 3b22134 (v0.1.12), mfa 33ad164 (v0.1.0) and sociallogin b752177 (v0.1.4). The orchestrator says this is intentional, and I count it as a recorded decision, not a gap. **A deploy from bm's origin therefore lacks 71d8f27 (an untouched settings form disabled every method) and every review fix, CR-01 included.** fonoteka.go e36577a bumps the user gitlink to 07196a4 and is never pushed, by design.
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
### Observable Truths
|
||||
|
||||
Abbreviations: **U** sm-user-plugin, **M** sm-mfa-plugin, **S** sm-sociallogin-plugin, **D** sm-demo-app/vue-demo-app, **B** sm-bm-app, **A** fonoteka.go. "Gate" means my own run of `PHASE196_REQUIRE_DOCKER=1 TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 bash scripts/check-phase19.6.sh --all` at the released pins. It exited 0, and all 11 stages passed.
|
||||
|
||||
**Roadmap success criteria**
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| SC-1 | TOTP setup/confirm/disable, WebAuthn registration and login challenges, email codes, recovery codes and trusted devices work against the PHP contract; the WebAuthn dependency has a decision note before code lands | VERIFIED (browser interop: human item 1) | M `routes.go` mounts PHP's 5 challenge routes and all 13 management routes, compared one by one with PHP `routes.php:303-336,372-453`. Note `24d9d2a` (09:49) lands before M's first go.mod commit `5c6ad2f` (11:05) and the go-webauthn require `2662252` (12:32). Gate `--mfa` and `--docker`: TestTOTP, TestQRSVG, TestRecovery, TestEmailCode, TestTrustedDevice, TestWebAuthn, TestPasswordless and TestPHPErrorBodies all PASS. The WebAuthn tests use a software authenticator with real ECDSA and CBOR (`webauthn_authenticator_test.go`). |
|
||||
| SC-2 | Login with a second factor returns the unauthenticated challenge step, rate-limited by `2fa-verify` | VERIFIED | U `controllers/api_controller.go:139-157` consults the gates and answers the gate body. M `classes/gate.go` returns `{two_factor_required, challenge_token, available_methods, expires_at}`. M `buckets.go` sets 10/min per client IP, and `routes.go` puts the challenge group under `throttle:2fa-verify`. TestGate, TestLoginGateSmoke and TestRoutesAndBuckets (11th request 429) PASS. |
|
||||
| SC-3 | `devices/initiate`, `devices/status/{token}`, `devices/authorize`, device list and revoke work on `DeviceAuthSession` | VERIFIED | U `routes.go` mounts the 5 routes in the user-api group. U `models/device_auth_session.go` and migration `202610260001_create_device_auth_sessions` match PHP's columns (v2.1.0-v2.7.1) plus `jwt_jti`. TestDeviceInitiate, TestDeviceStatus, TestDeviceAuthorize, TestDeviceHandOverConcurrent, TestDeviceListAndRevoke, TestDeviceRevokeAfterRefresh and TestDeviceFlowSmoke PASS in the gate. Since bc8f954 the gate also requires TestDeviceRevokeRacesRefresh and TestDeviceAccessRevocation: both PASS. |
|
||||
| SC-4 | Six models and migrations ported; a security review; unit tests in the last plan | VERIFIED | M `models/` has TwoFactorMethod, TwoFactorChallenge, TwoFactorRecoveryCode, TrustedDevice and WebAuthnCredential; U has DeviceAuthSession. Migrations M `202610220001..0006` and U `202610260001` carry PHP's table and column names (compared with PHP `updates/v3.0.0`, `v3.1.0`, `v2.1.0`). `19.6-SECURITY-REVIEW.md` maps T-19.6-01..38 with a D-14 section. Plan 04 delivered 41 named tests and the review round 6 more; the gate runs 17+1 U, 24 M and 3 S Postgres tests plus the Docker-free names. |
|
||||
|
||||
**Plan 01 (sm-user-plugin seams and device flow)**
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| 1.1 | D-04 decision note with the three pins, the measurements and the human check; STACK rows; no go.mod of U, framework or A requires the libraries | VERIFIED | The note names each pin once. STACK.md references the note 3 times. `grep -c` gives 0 in U go.mod and framework go.mod. `go list -m all` in A shows no webauthn, pquerna or boombuler module. |
|
||||
| 1.2 | D-02: registry published in Register; Login consults it after CheckAndRecordLogin and the rehash, before the restore and the mint; a gate error answers the opaque 500; refresh never asks | VERIFIED | `api_controller.go:112-157`. `Refresh` has no CheckLoginGates call. TestLoginGates (also with `-race`) and TestLoginGateOrder PASS. |
|
||||
| 1.3 | D-18 A10: a challenged soft-deleted account stays deleted, with no reactivate mail | VERIFIED | The restore at `:158-164` runs after the gate return. TestLoginGateOrder/challenged_soft_deleted_stays_deleted PASS (gate). |
|
||||
| 1.4 | LoginEvent fires once after the mint, none on a challenge; FireLoginEvent and CheckLoginGates are exported | VERIFIED | `:179`. TestLoginGateSmoke no_gate and challenge PASS. |
|
||||
| 1.5 | D-07: the password-change hook fires in the write transaction for reset, change and admin set; a listener error rolls back; the rehash fires none | VERIFIED (recorded deviation) | Built on the existing `AccessRevokedEvent` with `PasswordChanged()` instead of a new `PasswordChangedEvent` (01-SUMMARY deviation 1). TestPasswordChangedSources PASS. |
|
||||
| 1.6 | D-15: permission `golem15.users.reset_two_factor`, Danger action, offered only with a published TwoFactorAdmin, Run in cabana's transaction | VERIFIED | `users_admin_controller.go:820-847` (`Lookup[classes.TwoFactorAdmin]`, plus the WR-04 privileged guard). `config_form.yaml:17`. TestResetTwoFactorAction PASS. |
|
||||
| 1.7 | D-03/D-11/D-16: 5 routes, PHP columns, SHA-256 token, XXXX-XXXX code, 5-minute TTL, status enum, `jwt_jti`, configurable auth_url | VERIFIED (two recorded deviations) | Migration ID `202610260001` instead of the planned `202610210002` (04-SUMMARY deviation 5). The auth_url default is now `{frontend_url}/device/scan/{short_code}` instead of D-11's `{token}` (WR-01, released in v0.1.13, user decision in DISPOSITION). Authorize accepts a short code in `token`, so QuestStream's `useDeviceAuth.ts`/`useProfile.ts` keep working. |
|
||||
| 1.8 | D-12a: the first poll after confirm gets `{status:'confirmed', user_id, message, token, user}` through one guarded UPDATE; concurrent polls give one winner; used and revoked never expire | VERIFIED | `devices.go:298-300` (`WHERE status='confirmed' AND expires_at > NOW()`). `ExpiredAt` exempts used and revoked. TestDeviceHandOverConcurrent (50 polls) PASS. Since WR-01 the hand-over also requires the initiating User-Agent. |
|
||||
| 1.9 | D-12b: revoke blacklists the jti; refresh follows the jti | VERIFIED | `DeviceDestroy` runs `UPDATE … RETURNING jwt_jti` and calls `Lookup[bouncer.BlacklistStore]` (`devices.go:534-552`). `Refresh` calls `FollowDeviceJTI` and fails closed (`api_controller.go:316-333`, CR-01). TestDeviceRevokeAfterRefresh and TestDeviceRevokeRacesRefresh PASS (gate, since bc8f954). |
|
||||
| 1.10 | D-12c: authorize needs only a valid bearer JWT; one guarded pending-to-confirmed UPDATE; no 2FA re-check | VERIFIED | `devices.go:412-414`. TestDeviceAuthorize PASS. |
|
||||
| 1.11 | D-17: every change to U is additive; S and A compile | VERIFIED | Gate additive check: "no exported declaration removed or changed … since 50da92c (63 declarations added; 1 allowed migration)". A builds in the fonoteka stage. S and M build with `GOWORK=off` at their own requires (exit 0, my run). |
|
||||
|
||||
**Plan 02 (sm-mfa-plugin core)**
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| 2.1 | D-01: module `git.golem15.com/golem15/sm-mfa-plugin`, plugin `golem15.mfa` requires `golem15.user`; Boot needs no database | VERIFIED | `plugin.go:72-89`: Boot only adds the gate, publishes TwoFactorAdmin and listens. Gate `--mfa` checks the pins. |
|
||||
| 2.2 | SC-2: challenge body and the 2fa-verify bucket | VERIFIED | Same evidence as SC-2. |
|
||||
| 2.3 | D-05: PHP 401 and 422 bodies; TTL 5, 5 attempts, one completion | VERIFIED | `classes/challenge.go:96,119,137` (guarded `attempts < max_attempts`, `completed_at IS NULL`). TestChallengeLifecycle (20 parallel verifies, one token) and TestPHPErrorBodies PASS. Plus WR-02 (TestChallengeAfterRevocation) and WR-07 (TestCompletionFailureSpendsNothing), both required by the gate since bc8f954 and PASS. |
|
||||
| 2.4 | D-04/D-05: TOTP setup `{secret, qr_code_svg, qr_code_url}`, ±1 step, encrypted secret, replay refused, disable | VERIFIED | `controllers/management.go:78-80`, `classes/totp.go`, `classes/qr.go`. TestTOTP (replay), TestQRSVG and TestTokensAtRest PASS. |
|
||||
| 2.5 | D-05/D-19: recovery codes, 10 × `XXXXX-XXXXX`, bcrypt, single use, count only, regenerate, first set returned | VERIFIED | `classes/recovery.go:19-26,136`. TestRecovery and TestRecoveryCodeFormat PASS. |
|
||||
| 2.6 | D-05/D-18 A8 and A9: 6-digit bcrypt email code, template `golem15.mfa::mail.two_factor_code` (and -en), gating, 3 sends, `expiry_minutes` = min | VERIFIED | `classes/email.go:22,102`, `mail.go:22-23`. TestEmailCode and TestEmailExpiryMinutes PASS. Code lifetime is bound to the challenge, as PHP's `EmailMethod::verify` is (IN-02 is PHP parity). |
|
||||
| 2.7 | D-18 A6: 10 failures in 15 minutes per user refuse new challenges and verifies | VERIFIED | `gate.go` uses `FailureCapReached` (`challenge.go:218`). TestFailureCap PASS. |
|
||||
| 2.8 | D-06: tokens as SHA-256, TOTP secret encrypted, codes bcrypt, nothing logged | VERIFIED | TestTokensAtRest PASS. My log sweep found no token, code or secret attribute in M's log calls. |
|
||||
| 2.9 | D-07/D-10: trusted devices off by default, 30 days, revoked on a password change and when the last method goes, revoke routes | VERIFIED | TestTrustedDevice, TestRevocation and TestTrustedSettingsSmoke PASS. |
|
||||
| 2.10 | D-12/D-13/D-09: Settings screen with PHP keys and defaults, applied per request, only `disabled` exempts | VERIFIED | `models/settings.go`, `classes/config.go`. No child exemption anywhere in M (grep). TestSettings (including form_round_trip, fix 71d8f27) and TestPHPUser005 PASS. |
|
||||
| 2.11 | D-15: TwoFactorAdmin published; reset disables methods, deletes codes and devices, fires disabled | VERIFIED | `plugin.go:82`. TestAdminReset PASS. |
|
||||
| 2.12 | D-16: four tables plus settings with PHP names and columns (+ `email_sends`) | VERIFIED | DDL compared with PHP v3.0.0 and v3.1.0: same columns, token as VARCHAR(64). TestMigrations PASS. |
|
||||
|
||||
**Plan 03 (WebAuthn, passkeys, social gate, demo, release)**
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| 3.1 | D-04/D-08: go-webauthn v0.18.2 only in M; standard base64url shapes; attestation none, 60 s, UV preferred | VERIFIED (browser: human item 1) | TestWebAuthnShapes and TestWebAuthnCeremonySmoke PASS. A's module graph has no go-webauthn. |
|
||||
| 3.2 | D-05/D-06: WebAuthn state server-side, consumed once; PHP register, verify and remove bodies | VERIFIED | `cache.Pull` in `classes/webauthn.go:318` and `classes/passwordless.go:69`. TestWebAuthn and TestWebAuthnShapes/registration_state PASS. |
|
||||
| 3.3 | D-16: `golem15_user_webauthn_credentials` with PHP columns + `credential_data`, `passwordless`, unique `credential_id` | VERIFIED | Migration `202610220006`. TestMigrations PASS. |
|
||||
| 3.4 | D-14: passwordless routes in the bucket, 403 while off, passkeys only, UV required, activation, ban and suspension enforced, Source passkey, no second challenge | VERIFIED | SECURITY-REVIEW "D-14" table. TestPasswordless and TestPasswordlessSmoke PASS. The WR-05 partial (passkeys demoted on a password change) is pinned by TestPasswordless/password_change_demotes_passkeys. |
|
||||
| 3.5 | D-09: S consults the gate in signIn (Source social), skipped by default, the challenge body on both completions, refusals and errors fail closed, link never gated | VERIFIED | S `classes/flow.go:343-359`. TestSocialGate PASS (gate). WR-08 TestChallengedSignInFiresOnCompletion PASS (gate, since bc8f954). |
|
||||
| 3.6 | D-20: the demo sets up TOTP with QR and confirm, shows recovery codes once, disables, and answers the login challenge with TOTP or a recovery code; bm stays API-only | VERIFIED (code and unit; browser: human item 2) | D `pages/account/security.vue` uses `useTwoFactor` (`totp/setup`, `confirm`, `DELETE totp`) and renders `<img :src="svgDataUrl(...)">`. `login.vue` and `useDemoAuth.ts` call `2fa/verify` and `2fa/recovery`. The gate's demo-web stage requires `twoFactor.test.ts`. B `frontend/src` has no 2FA code (grep). |
|
||||
| 3.7 | D-17: release order, D and B mount mfa and bump pointers in separate commits, A bumps user and updates TestNoDeferredRoutesResolve without mounting mfa | VERIFIED (B unpushed, recorded) | Remote tags and heads as in "Release state". D `summer.yaml:40` and `plugins.gen.go:12,44`; B `summer.yaml:8` and `plugins.gen.go:9,21`. A `phase07_coverage_test.go:97-100` drops `/devices` and keeps `2fa`. A's `summer.yaml` has no mfa. |
|
||||
| 3.8 | D-01: A has no /2fa route, no 2FA table, no second-factor module | VERIFIED | Gate `--fonoteka` and my own `go list -m all`. |
|
||||
|
||||
**Plan 04 (unit tests, security review, gate, post-release fixes)**
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| 4.1 | SC-4: unit tests for every U seam, every M decision and S's gate, on Postgres where needed | VERIFIED | Gate `--docker` (after bc8f954): 17 U root, 1 U updates, 24 M and 3 S tests by name. The Docker-free names pass in their stages. |
|
||||
| 4.2 | D-02/D-18 A10 table tests | VERIFIED | TestLoginGates (`-race`) and TestLoginGateOrder PASS. |
|
||||
| 4.3 | Device-flow table tests | VERIFIED | The 8 device tests and TestDeviceAuthSessionsMigration PASS. |
|
||||
| 4.4 | M tests pin every PHP body and decision | VERIFIED | TestPHPErrorBodies compares error and 422 bodies byte for byte. Success bodies are compared by key set because Go sorts keys (recorded observation). |
|
||||
| 4.5 | D-08/D-14 tests and the review's D-14 section | VERIFIED | `19.6-SECURITY-REVIEW.md` "D-14" maps each rule to a subtest. |
|
||||
| 4.6 | TestEveryLoginPathIsGated and TestSocialGate | VERIFIED | `login_paths_test.go:29-52` lists the mint sites; ActivateByCode points to F-1 (deferred by the user). PASS. |
|
||||
| 4.7 | PHP map: TestPHPMethodMap fails on missing, unknown or extra methods; test_user_005 maps to TestPHPUser005 | VERIFIED | Both run in the `--mfa` stage: PASS. |
|
||||
| 4.8 | The security review maps every T-19.6 threat to a test or an accepted disposition | VERIFIED | T-19.6-01..38 plus 4 SC rows; F-1 deferred with a corrected reason. |
|
||||
| 4.9 | The gate fails closed (fail, skip, zero tests, missing names); `--self-test`; docker NOT RUN is fatal with REQUIRE_DOCKER | VERIFIED | `--self-test` PASS in my run. My `--all` with `PHASE196_REQUIRE_DOCKER=1`: exit 0. |
|
||||
| 4.10 | Every post-release production fix is in every pin that consumes it, or tracked | VERIFIED | 71d8f27 is in v0.1.1 and later. The review fixes are in v0.1.13, v0.1.2 and v0.1.5, and the gitlinks of D, B (local HEAD) and A equal those tag commits. B's push is held, and WR-05 and F-1 are deferred, all by user decision. |
|
||||
|
||||
**Score:** 45/45 truths verified (0 present, behavior-unverified). Every behavior-dependent truth (guarded UPDATE races, revoke versus refresh, restore ordering, transaction rollbacks) has a named passing test. The race tests were mutation-checked per the security review.
|
||||
|
||||
### Required Artifacts
|
||||
|
||||
| Artifact | Status | Details |
|
||||
|----------|--------|---------|
|
||||
| `.planning/notes/2026-10-21-mfa-otp-webauthn.md` | VERIFIED | Committed in 24d9d2a before any require |
|
||||
| U `classes/login_gate.go` | VERIFIED | `type LoginGate interface`, a registry with RWMutex and clone |
|
||||
| U `controllers/devices.go` | VERIFIED | 573 lines; `DeviceStatus`, hand-over, authorize, destroy |
|
||||
| U `updates/202610210002_create_device_auth_sessions.go` | VERIFIED (renamed) | Exists as `202610260001_create_device_auth_sessions.go` (deviation 04-5). The verify.artifacts tool reports the planned path missing. |
|
||||
| U `login_gate_smoke_test.go` | VERIFIED | Run by name in the gate |
|
||||
| M `plugin.go`, `classes/challenge.go`, `classes/qr.go`, `buckets.go`, `tracer_smoke_test.go` | VERIFIED | verify.artifacts 5/5 |
|
||||
| M `classes/webauthn.go`, `classes/passwordless.go`, `updates/202610220006_*` | VERIFIED | |
|
||||
| S `classes/flow.go` | VERIFIED | `CheckLoginGates` |
|
||||
| D `vue-demo-app/app/pages/account/security.vue` | VERIFIED | The tool flags the missing literal `totp/setup`. The page calls `useTwoFactor().setupTotp()`, which posts to `/_user/api/v1/2fa/totp/setup` (`composables/useTwoFactor.ts`). Wired. |
|
||||
| D `mfa_test.go` (TestMFAMounted) | VERIFIED | PASS in `--demo` |
|
||||
| `scripts/check-phase19.6.sh` | VERIFIED | My `--all` run exited 0 with the script before bc8f954; after bc8f954 (six names added to the docker lists, `bash -n` clean) `--self-test` and `--docker` exit 0 |
|
||||
| M `login_paths_test.go`, `testdata/PHP_METHOD_MAP.md`, `19.6-SECURITY-REVIEW.md` | VERIFIED | verify.artifacts 4/4 |
|
||||
|
||||
### Key Link Verification
|
||||
|
||||
The `verify.key-links` tool rejects paths outside this repository, so I checked every link by hand with grep.
|
||||
|
||||
| From | To | Via | Status |
|
||||
|------|----|-----|--------|
|
||||
| U `api_controller.go` | `classes/login_gate.go` | `CheckLoginGates(` in Login (1 call) | WIRED |
|
||||
| U `api_controller.go` | `jwt_jti` | `classes.FollowDeviceJTI` in Refresh (`HandOverDeviceJTI` wraps it) | WIRED |
|
||||
| U `devices.go` | `bouncer.BlacklistStore` | `app.Lookup[bouncer.BlacklistStore]()` `:547` | WIRED |
|
||||
| U `users_admin_controller.go` | `TwoFactorAdmin` | `app.Lookup[classes.TwoFactorAdmin]()` `:843` | WIRED |
|
||||
| M `plugin.go` | U `LoginGates` | `Lookup[*userclasses.LoginGates]` then `gates.Add(&classes.Gate{})`; Boot fails if the registry is absent | WIRED |
|
||||
| M `classes/login.go` | U helpers | `FinishLogin`, `IssueToken`, `APIArray`, `FireLoginEvent` | WIRED |
|
||||
| M `plugin.go` | U events | `Listen[*userclasses.AccessRevokedEvent]` (the plan named PasswordChangedEvent; deviation 01-1) | WIRED |
|
||||
| M `routes.go` | M `buckets.go` | `surf.Use("throttle:2fa-verify")` | WIRED |
|
||||
| M `classes/webauthn.go` | `cooler` | `cache.Pull` | WIRED |
|
||||
| S `classes/flow.go` | U `login_gates.go` | `Source: userclasses.LoginSourceSocial` | WIRED |
|
||||
| D `useDemoAuth.ts` | `/_user/api/v1/2fa/verify` | `$fetch` | WIRED |
|
||||
| D `summer.yaml` | M | `golem15.mfa`, `plugins.gen.go` | WIRED |
|
||||
| M | D `plugins/golem15/mfa` | gitlink 463c750 = v0.1.2 | WIRED |
|
||||
|
||||
### Data-Flow Trace (Level 4)
|
||||
|
||||
| Artifact | Data | Source | Real data | Status |
|
||||
|----------|------|--------|-----------|--------|
|
||||
| Login challenge body | `challenge_token`, `available_methods`, `expires_at` | `CreateChallenge` inserts a row; `EnabledMethods` queries `golem15_user_two_factor_methods` | yes | FLOWING |
|
||||
| `2fa/status` | methods, trusted devices, WebAuthn credentials, remaining count | `classes/methods.go` status queries | yes | FLOWING |
|
||||
| Device status hand-over | `token`, `user` | `mintWithJTI` + `apiArray` after the guarded UPDATE on `golem15_user_device_auth_sessions` | yes | FLOWING |
|
||||
| Demo security page | `state`, `setup.qr_code_svg` | `useTwoFactor` → `2fa/status`, `totp/setup` | yes | FLOWING |
|
||||
|
||||
### Behavioral Spot-Checks
|
||||
|
||||
| Behavior | Command | Result | Status |
|
||||
|----------|---------|--------|--------|
|
||||
| Whole phase gate at the released pins, Docker required | `PHASE196_REQUIRE_DOCKER=1 TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 bash scripts/check-phase19.6.sh --all` | exit 0; self-test, go, userplugin (5 + 1 `-race` + 1, additive check), mfa (11), sociallogin (9), demo (3), demo-web, bm (2), fonoteka, docs, docker (15 + 1 U, 21 M, 2 S) | PASS |
|
||||
| Gate after bc8f954: detectors and Docker stage | `bash scripts/check-phase19.6.sh --self-test`; `PHASE196_REQUIRE_DOCKER=1 TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 bash scripts/check-phase19.6.sh --docker` | self-test passed; docker exit 0: 17 + 1 U, 24 M, 3 S tests by name. Only the docker lists changed, so no other stage is affected. | PASS |
|
||||
| Review-fix regression tests, run by name before bc8f954 (U) | `go test -count=1 -run '^(TestDeviceRevokeRacesRefresh\|TestDeviceAccessRevocation)$' ./plugins/golem15/user` (fonoteka.go) | both PASS | PASS |
|
||||
| Review-fix regression tests, run by name before bc8f954 (M, S) | `go test -run '^(TestChallengeAfterRevocation\|TestPasswordConfirmationThrottle\|TestCompletionFailureSpendsNothing)$' .` in M; `-run '^TestChallengedSignInFiresOnCompletion$'` in S | all PASS (4 + 2 + 2 subtests) | PASS |
|
||||
| Demo module-mode build at the tags | `GOWORK=off GOFLAGS=-mod=readonly go build -trimpath .` (sm-demo-app) | ok; resolves user v0.1.13, mfa v0.1.2, sociallogin v0.1.5 | PASS |
|
||||
| M and S build at their own go.mod requires (user v0.1.12) | `GOWORK=off go build ./...` | exit 0 both | PASS |
|
||||
| A carries no second-factor module | `go list -m all \| grep -E 'webauthn\|pquerna\|boombuler'` (fonoteka.go) | no match | PASS |
|
||||
|
||||
### Probe Execution
|
||||
|
||||
No `scripts/*/tests/probe-*.sh` is declared or exists for this phase. The phase gate (above) is the runnable check.
|
||||
|
||||
### Requirements Coverage
|
||||
|
||||
| ID | Source Plan | Status | Evidence |
|
||||
|----|-------------|--------|----------|
|
||||
| SC-1 | 02, 03 | SATISFIED (browser interop human) | Truths SC-1, 2.4-2.6, 2.9, 3.1-3.3 |
|
||||
| SC-2 | 01, 02, 03 | SATISFIED | SC-2, 1.2, 2.2 |
|
||||
| SC-3 | 01 | SATISFIED | SC-3, 1.7-1.10 |
|
||||
| SC-4 | 01-04 | SATISFIED | SC-4, 4.1-4.9 |
|
||||
| D-01 | 02, 03 | SATISFIED | 2.1, 3.8 |
|
||||
| D-02 | 01, 03, 04 | SATISFIED | 1.2, 1.4 |
|
||||
| D-03 | 01 | SATISFIED | 1.7 |
|
||||
| D-04 | 01, 02, 03 | SATISFIED | 1.1, 2.4, 3.1 (boombuler/barcode with its own SVG writer) |
|
||||
| D-05 | 02, 03, 04 | SATISFIED | 2.3-2.6, 3.2 (mail template now `golem15.mfa::`, as the plugin moved) |
|
||||
| D-06 | 01, 02, 03, 04 | SATISFIED | 2.8, TestDeviceTokensAtRest |
|
||||
| D-07 | 01, 02, 04 | SATISFIED | 1.5, 2.9 |
|
||||
| D-08 | 03, 04 | SATISFIED (browser human) | 3.1 |
|
||||
| D-09 | 02, 03, 04 | SATISFIED | 3.5, 2.10 |
|
||||
| D-10 | 02, 03, 04 | SATISFIED | 2.9 |
|
||||
| D-11 | 01, 04 | SATISFIED (default auth_url changed by WR-01) | 1.7 |
|
||||
| D-12 | 02, 04 | SATISFIED | 2.10 |
|
||||
| D-12a | 01, 04 | SATISFIED | 1.8 |
|
||||
| D-12b | 01, 04 | SATISFIED | 1.9 |
|
||||
| D-12c | 01, 04 | SATISFIED | 1.10 |
|
||||
| D-13 | 02, 04 | SATISFIED | 2.10 |
|
||||
| D-14 | 03, 04 | SATISFIED | 3.4 |
|
||||
| D-15 | 01, 02, 04 | SATISFIED | 1.6, 2.11 |
|
||||
| D-16 | 01, 02, 03, 04 | SATISFIED | 2.12, 3.3, SC-4 |
|
||||
| D-17 | 01, 03, 04 | SATISFIED (B push held) | 1.11, 3.7, 4.10 |
|
||||
| D-18 | 01, 02, 04 | SATISFIED | 1.3, 2.6, 2.7 |
|
||||
| D-19 | 02, 03, 04 | SATISFIED | 2.5 |
|
||||
| D-20 | 03 | SATISFIED (browser human) | 3.6 |
|
||||
|
||||
REQUIREMENTS.md maps no IDs to this phase ("Requirements: TBD"), so no requirement is orphaned. Every ID in CONTEXT is claimed by at least one plan.
|
||||
|
||||
### Decision Coverage
|
||||
|
||||
`check.decision-coverage-verify`: 23/23 trackable CONTEXT decisions honored by the shipped artifacts (not_honored: none). Non-blocking gate.
|
||||
|
||||
### Test Quality Audit
|
||||
|
||||
| Area | Active | Skipped | Circular | Assertion level | Verdict |
|
||||
|------|--------|---------|----------|-----------------|---------|
|
||||
| U gate, device and password tests | 17 + 1 Docker, 7 Docker-free | 0 in the gate run; `t.Skip` only under `-short`, and the gate counts a skip as a failure | no | behavioral (races, transactions, bodies) | OK |
|
||||
| M decision tests | 24 Docker, 11 Docker-free | 0 | no; PHP bodies are literals from PHP sources, PHP_METHOD_MAP from PHP's test file | value and behavioral | OK |
|
||||
| S gate tests | 3 Docker (WR-08 included) | 0 | no | behavioral | OK |
|
||||
| D `twoFactor.test.ts` | in the demo-web vitest run | 0 | no | value (`svgDataUrl` has no `<`) | OK |
|
||||
|
||||
Disabled tests on requirements: 0. Circular patterns: 0. Insufficient assertions: 0. The first pass warned that the review round's six regression tests (TestDeviceRevokeRacesRefresh, TestDeviceAccessRevocation, TestChallengeAfterRevocation, TestPasswordConfirmationThrottle, TestCompletionFailureSpendsNothing, TestChallengedSignInFiresOnCompletion) were outside the gate's required-name lists. **Resolved by bc8f954:** the gate now requires all six, and its `--docker` stage passes with them.
|
||||
|
||||
### Anti-Patterns Found
|
||||
|
||||
I scanned the 137 files the phase touched (U `50da92c..07196a4`, all of M, S `v0.1.3..v0.1.5`):
|
||||
|
||||
| File | Line | Pattern | Severity | Impact |
|
||||
|------|------|---------|----------|--------|
|
||||
| (none) | - | TBD / FIXME / XXX | - | No debt marker. `XXXXX-XXXXX` format strings excluded. |
|
||||
| (none) | - | TODO / HACK / placeholder | - | None |
|
||||
| M, U log calls | - | secrets in logs | - | Only ids and `err` attributes (matches the review's "Log calls" sweep) |
|
||||
| sm-bm-app | - | release pins only local | ℹ️ Info | origin runs mfa v0.1.0 and user v0.1.12, which lack 71d8f27 and the review fixes, until bm is pushed (recorded decision) |
|
||||
| A `go.mod` | 11 | requires sm-user-plugin v0.1.10 | ℹ️ Info | resolved through `replace`; open item in deferred-items.md |
|
||||
| M, S `go.mod` | 6 | require sm-user-plugin v0.1.12 | ℹ️ Info | `GOWORK=off` builds pass; the apps select v0.1.13 by MVS |
|
||||
| `19.6-REVIEW.md` IN-01..IN-10 | - | info findings | ℹ️ Info | Open outside the fix scope the user chose. None contradicts an SC; IN-02 matches PHP's behaviour. |
|
||||
|
||||
### Recorded deferrals (user decisions, not gaps)
|
||||
|
||||
- **WR-05** (factor changes need only a session): partial mitigation in M 463c750; the full fix needs an API contract change. Todo `2026-10-26-mfa-factor-changes-need-reauth.md` (g15office krt3vrts). It does not contradict SC-1, because PHP's contract has the same exposure.
|
||||
- **F-1** (activate-by-code mints without the second factor when `require_activation: false`): todo `2026-10-26-activate-by-code-second-factor.md`. It needs a non-default configuration. SC-2 holds for the login path it names, and TestEveryLoginPathIsGated pins the mint site with its pointer.
|
||||
- **sm-bm-app push**: held because its unpushed range carries another session's commits.
|
||||
|
||||
### Prohibitions (judgment-tier, non-authoritative LLM-judge verdicts)
|
||||
|
||||
| Plan | Prohibition | Verdict |
|
||||
|------|-------------|---------|
|
||||
| 01 | No JWT, device token, short code, challenge token or password in a log line or error string | No violation found (log sweep of U `devices.go` and `api_controller.go`) |
|
||||
| 01 | sm-user-plugin changes additive only | No violation found (gate additive check against `50da92c`; the WR-01 default change concerns a key this phase introduced) |
|
||||
| 01 | No go.mod of U, framework or A requires the three libraries | No violation found |
|
||||
| 01 | Nothing pushed or tagged in plan 01 | No violation found (process; SUMMARY-attested) |
|
||||
| 01 | Framework code and READMEs name no consuming application | No violation found (gate docs: 503 files checked) |
|
||||
| 02 | No token, code, secret or password logged | No violation found |
|
||||
| 02 | goccy only; no `gopkg.in/yaml.v3` | No violation found (gate `--mfa` deps; grep) |
|
||||
| 02 | No notification mail, per-group exemption, Winter import or child exemption | No violation found (grep) |
|
||||
| 02 | Nothing pushed in plan 02 | No violation found (process) |
|
||||
| 02 | U unchanged by plan 02 except for defect fixes | No violation found (SUMMARY-attested) |
|
||||
| 03 | No assertion, attestation, challenge, token or library error logged or echoed | No violation found |
|
||||
| 03 | QR SVG rendered as an image data URL, never `v-html` | No violation found (`security.vue:130`; the existing `v-html` uses are in unrelated deck components) |
|
||||
| 03 | No remote operation before the go-ahead; no force-push; A never pushed; no deploy | No violation found (A is 38 commits ahead of origin) |
|
||||
| 03 | A does not mount mfa; B's frontend has no 2FA UI | No violation found |
|
||||
| 03 | The stale `../vue-demo-app` is not used | No violation found (commit 44a5229 lives in `sm-demo-app/vue-demo-app`, origin golem15/vue-demo-app) |
|
||||
| 04 | No production change except defect fixes | No violation found (71d8f27 only) |
|
||||
| 04 | No real secrets, authenticators or mail servers in tests | No violation found (virtual authenticator, capturing mailer) |
|
||||
| 04 | A skipped Docker test never counts as passed | No violation found (detector self-test PASS) |
|
||||
| 04 | Pushes and tags only as authorised; nothing force-pushed or deployed | No violation found (process; SUMMARY-attested) |
|
||||
|
||||
### Human Verification Required
|
||||
|
||||
These three items are seeded into `19.6-UAT.md` (status testing, 3 pending). That file records no results yet, so Step 8b settles none of them.
|
||||
|
||||
#### 1. Real-browser WebAuthn ceremony
|
||||
|
||||
**Test:** On an instance with `webauthn` in `two_factor_available_methods`, served over HTTPS with a hostname RP ID, register a security key and complete a login challenge with it (`2fa/webauthn/register/options` → `navigator.credentials.create` → `2fa/webauthn/register`; then `2fa/webauthn/options` → `navigator.credentials.get` → `2fa/webauthn/verify`). With `two_factor_passwordless_login` on, register a passkey and sign in through `2fa/webauthn/passwordless/options` and `/verify`.
|
||||
**Expected:** PHP's register body, `{token, user}` on verify, a passkey token with no second challenge, and a second-factor-only key refused for passwordless.
|
||||
**Why human:** The software-authenticator tests prove the server; only a browser proves the D-08 JSON shapes and the origin and RP ID configuration end to end. The demo cannot run this as configured (no WebAuthn screens, webauthn not offered), so a small client page is needed.
|
||||
|
||||
#### 2. Demo TOTP flow in a browser (D-20)
|
||||
|
||||
**Test:** Sign in on the demo, enable TOTP from the QR with an authenticator app, keep the recovery codes, sign out, answer the challenge with an app code and then with a recovery code, then disable TOTP.
|
||||
**Expected:** The QR scans, the recovery codes show once, the challenge step completes with either code, a used recovery code is refused, and after disable login is direct.
|
||||
**Why human:** User-facing look and flow; plans 03 and 04 record the browser run as NOT RUN.
|
||||
|
||||
#### 3. Judgment-tier prohibitions
|
||||
|
||||
**Test:** Review the 19 verdicts in "Prohibitions" above.
|
||||
**Expected:** Confirm or dispute each.
|
||||
**Why human:** ADR-550 D4: judgment-tier items never pass silently.
|
||||
|
||||
### Gaps Summary
|
||||
|
||||
No gaps. Every roadmap criterion, every CONTEXT decision and every plan must-have is backed by code at the released tags and by named tests that pass in my own run of the phase gate with Docker required, including the six review-fix regression tests the gate requires since bc8f954. The deviations from plan wording (AccessRevokedEvent for D-07, migration ID `202610260001`, the auth_url default changed by WR-01) are recorded in the SUMMARYs or the review disposition and keep each decision's intent. Before `passed`, three human items remain: a real-browser WebAuthn ceremony, the demo's TOTP flow in a browser, and the prohibition verdicts. Worth knowing beyond those: sm-bm-app's origin still runs the pre-review plugin versions until its held push. The first pass also noted that the gate did not require the review round's regression tests; bc8f954 resolved that (re-verified: `--self-test` and `--docker` pass). The three human items are seeded into `19.6-UAT.md` (3 pending, no results yet, so Step 8b settles none).
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-10-26T16:05:13Z (refreshed after bc8f954)_
|
||||
_Verifier: Claude (msd-verifier)_
|
||||
@@ -0,0 +1,37 @@
|
||||
## Deferred Items
|
||||
|
||||
- sm-sociallogin-plugin: `signin_event_test.go` is not gofmt-clean at origin/master `4d3b2dd` (v0.1.3)
|
||||
status: open
|
||||
**What:** `gofmt -l .` lists it: `logRecorder.Enabled` is a one-line method gofmt now splits. It came with `4d3b2dd` from another session. Plan 19.6-03 did not touch it. Fix it in a `style:` commit in sm-sociallogin-plugin.
|
||||
- vue-demo-app has no type-check tooling
|
||||
status: open
|
||||
**What:** the Nuxt build does not type-check, and `vue-tsc` is not a dependency, so 19.6-03 Task 3 checked the new page, composables and header with vitest and `pnpm build` only. The user decides whether to add `nuxi typecheck`.
|
||||
- fonoteka.go: five Docker-backed tests in `plugins/golem15/fonoteka` fail without `-short`, at the committed user pointer v0.1.10 as well as at v0.1.12
|
||||
status: open
|
||||
**What:** found by 19.6-03 Task 6 (baseline run with the user submodule at `bfcfea4`; the failures are identical):
|
||||
- `TestPhase09SecurityRoutes`: unexpected cabana admin routes (account/contributions, account/preferences, reorder, singleton) from the framework working tree.
|
||||
- `TestPhase8RedMCPMe`, `TestOAuthToolsMeRouteIsolation`: `GET /_user/api/v1/token/me` counts as a `/me`-suffixed route on another surface.
|
||||
- `TestMustChangePasswordLock`: login answers 401 "Invalid email or password".
|
||||
- `TestPhase14Edges/prune-cutoff-90-days-then-one-second-older`: prune leaves the "past" row.
|
||||
None of these tests inventories user-plugin tables, routes or models, so 19.6-03 did not change them. The `-short` suites are green. The parity inventories (`parity/migrate_test.go`, `parity/schema_diff_test.go`) were also red at v0.1.10; `95fd58a` fixed them along with the bump.
|
||||
- fonoteka.go: root `go.mod` still requires `sm-user-plugin v0.1.10`
|
||||
status: open
|
||||
**What:** the module resolves through `replace => ./plugins/golem15/user`, so builds and tests use the v0.1.12 checkout. 19.6-03 Task 6 staged only the paths the plan names. Precedent `06bc9d0` raised the require together with the pointer. Raise it to v0.1.12 (and tidy) in a follow-up `chore:` commit.
|
||||
- sm-mfa-plugin: the v0.1.0 tag message says the two-factor mode is "optional, required or disabled"
|
||||
status: resolved (2026-10-26: the v0.1.1 tag message names the modes disabled, optional and enforced)
|
||||
**What:** the config values are `disabled`, `optional` and `enforced`. The tag is pushed and is not rewritten (that would need a force-push). The README and `config/config.yaml` are correct. The next release's tag message should name the right values.
|
||||
- sm-demo-app: the release build needs read access to the private sm-mfa-plugin repository
|
||||
status: resolved (2026-10-26: the user made golem15/sm-mfa-plugin public; anonymous HTTPS `git ls-remote` of v0.1.0 works)
|
||||
**What:** found by 19.6-03 Task 6 part (1). `scripts/build.sh release` and `scripts/check-pins.sh` run with `GOWORK=off GOPRIVATE=git.golem15.com/*`, so Go fetches every required plugin over anonymous HTTPS. The other `sm-*-plugin` repositories allow that; sm-mfa-plugin is private, so the fetch fails ("could not read Username for 'https://git.golem15.com'"). On this machine the release build and the pins check pass, because v0.1.0 is already in the module cache: `go get` filled it through a one-command `url.git@git.golem15.com:.insteadOf https://git.golem15.com/` rewrite in the environment, and no global config was changed. A clean module cache, or another build machine, fails. The user decides: make sm-mfa-plugin public like the other plugins, or give the build host credentials (an `insteadOf` rewrite to SSH or a netrc) and document it in DEPLOY.md. sm-bm-app is not affected (it builds from the submodule through a replace).
|
||||
- sm-demo-app: uncommitted journal and oauthserver submodule moves left over from Phase 19.7 plan 05
|
||||
status: open
|
||||
**What:** tracked as the pending todo `.planning/todos/pending/2026-10-26-sm-demo-app-journal-oauthserver-pointers.md`. 19.6-03 left both unstaged.
|
||||
- sm-user-plugin: the `classes` package starts Postgres under `-short`
|
||||
status: open
|
||||
**What:** found by 19.6-04. `classes/throttle_test.go` `throttleDB` (used by `TestCodes` and other `classes` tests) starts a testcontainers Postgres without checking `testing.Short()`, so `go test -short ./...` of the user plugin needs Docker (about 45 s on this host) and fails on a host without it. Predates this phase. 19.6-04 fixed the same problem in the `updates` package (`2c68979`, its TestMain scanned `os.Args` for `-test.short`). Fix it the same way in a `test:` commit.
|
||||
- sm-mfa-plugin and sm-user-plugin: multi-key success bodies carry Go's sorted key order
|
||||
status: open (observation)
|
||||
**What:** found by 19.6-04 `TestPHPErrorBodies`. Bodies built from Go maps (the login challenge, `2fa/status`, `totp/setup`, `email/send`, the WebAuthn register answer, the device initiate and status bodies) list their keys alphabetically, where PHP's `response()->json([...])` kept insertion order. Values and key sets match PHP; error bodies and the 422 bodies are byte-identical. JSON clients do not depend on key order, so nothing was changed; recorded in 19.6-SECURITY-REVIEW.md "Residual risks" for a decision if a client ever compares raw bytes.
|
||||
- sm-user-plugin: activate-by-code mints a session without the second factor when `require_activation` is off (finding F-1)
|
||||
status: deferred (user decision at plan 04 Task 5)
|
||||
**What:** see 19.6-SECURITY-REVIEW.md "Deferred findings" and the todo `.planning/todos/pending/2026-10-26-activate-by-code-second-factor.md`.
|
||||
@@ -0,0 +1,292 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 01
|
||||
subsystem: admin
|
||||
tags: [cabana, pact, admin, permissions, postgres, advisory-lock, phrasebook]
|
||||
|
||||
requires:
|
||||
- phase: 12.1
|
||||
provides: generic CRUD, record/bulk actions, permissioneditor, RelationLockProvider, preview screens
|
||||
provides:
|
||||
- pact.HasAdminActionExtensions / pact.AdminActionExtension (cross-controller record actions, D-14)
|
||||
- internal summercms.cabana pseudo-plugin with summercms.cabana.users and summercms.cabana.roles
|
||||
- backend.manage_users and backend.manage_roles permission codes (no role grants)
|
||||
- server-side privilege rules D-03..D-12, D-16, D-17, D-19, D-20
|
||||
- backend::lang user, user.role, permissions copy (en, pl)
|
||||
affects: [19.6.1-02 (SPA trigger and record permission locks), 19.6.1-03 (unit and Postgres tests), 19.7 (link action on the Administrators screen), 19.6 D-15 (Reset 2FA contribution)]
|
||||
|
||||
actuals:
|
||||
tokens: 41600
|
||||
tasks: 4
|
||||
commits: 4
|
||||
plan_head_before: 88ec4df2b35dd5d6654df23c19ba5ad371fe993d
|
||||
plan_head_after: 653307de0c37902b68a2acd53bef07e887e44ca8
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Internal pseudo-plugin appended in Activate only after the no-controllers early return"
|
||||
- "Boot-time merge of contributed record actions into compiled controllers before permission validation"
|
||||
- "Unexported in-package interfaces (recordDataExtender, schemaFieldHider) for per-request projection and schema drops"
|
||||
- "Last-superuser invariant: pg_advisory_xact_lock after the row lock plus a count in the write tx"
|
||||
- "Prior-state snapshot on an unexported model field, compared in FormAfterUpdate"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/cabana/action_extensions.go
|
||||
- modules/cabana/backend_screens.go
|
||||
- modules/cabana/backend_users_admin.go
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/backend_privileges.go
|
||||
- modules/cabana/backendscreens/controllers/users/{config_list,config_form,config_filter}.yaml, _hint.htm
|
||||
- modules/cabana/backendscreens/models/user/{columns,fields}.yaml
|
||||
- modules/cabana/backendscreens/controllers/roles/{config_list,config_form}.yaml
|
||||
- modules/cabana/backendscreens/models/userrole/{columns,fields}.yaml
|
||||
- modules/cabana/backend_screens_test.go
|
||||
- modules/cabana/backend_screens_smoke_test.go
|
||||
- modules/cabana/example_action_extension_test.go
|
||||
modified:
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/registry.go
|
||||
- modules/cabana/contracts.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/README.md
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml
|
||||
- modules/phrasebook/backend/lang/pl/lang.yaml
|
||||
- docs/backend/admin-controllers.md
|
||||
- docs/backend/users-and-permissions.md
|
||||
|
||||
key-decisions:
|
||||
- "The Active filter label uses backend::lang.user.filter_activated, because UI-SPEC assigned user.activated to both the filter label and the activate success toast"
|
||||
- "The D-14 seam carries record actions only; AdminActionExtension is a struct so bulk or toolbar kinds can be added later"
|
||||
- "Bulk lifecycle actions return their success phrase only when every selected row changed; otherwise the framework count text (never overstates)"
|
||||
- "D-17 in-use refusal is a 403 ForbiddenError whose message the hook translates with Choice (name and count), so the SPA delete toast shows it"
|
||||
|
||||
patterns-established:
|
||||
- "Contributed record action names are checked against the owner's and earlier contributors' names; the error names both plugins"
|
||||
- "Every refusal from a delete or an action on these screens is a ForbiddenError with Message set"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-3, D-01, D-02, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-10, D-11, D-12, D-13, D-14, D-15, D-16, D-17, D-18, D-19, D-20, D-22]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "pact action-extension seam: a plugin adds record actions to summercms.cabana.users; offered on the preview after the owner's, run in the row-locked tx; unknown controller ID stops boot"
|
||||
requirement: "D-14"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/backend_screens_test.go#TestBackendScreensSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestBackendScreensPostgresSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Pseudo-plugin activates only with admin controllers; settings tile Administrators (order 100) and Roles (110) under System; codes granted to no role"
|
||||
requirement: "D-01"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/backend_screens_test.go#TestBackendScreensSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "go -C examples/hello test ./... and go test ./modules/surf"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestRolesSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Administrators form: create with password, superuser projection, D-03 hiding, D-05 superuser-only switch, D-08 own role/flag refusals, D-20 own password refusal, superuser demotion with a second superuser"
|
||||
requirement: "D-05"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestAdministratorsFormSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Lifecycle: deactivate revokes JWTs, soft delete with deleted row state, restore, trashed filter, self delete and self bulk-deactivate refused with whole-selection rollback, preview hint"
|
||||
requirement: "D-10"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestAdministratorsLifecycleSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Roles screen: create, code taken, in-use and system-role delete refusals, system code lock, settings order"
|
||||
requirement: "D-16"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestRolesSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Concurrent last-superuser race, D-07 ceilings and D-19 outranking for limited editors, scoped-token superusers"
|
||||
requirement: "D-09"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Implemented here; the held-lock race and the per-rule unit tests are Plan 03's scope (D-18). Only the sequential paths are smoke-tested in this plan."
|
||||
- id: D7
|
||||
description: "Screens render and behave in the admin SPA (lists, form tabs, preview footer, toasts)"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Visual and interaction behaviour in the browser is the VALIDATION manual-only UAT item; D-21 SPA additions land in Plan 02."
|
||||
|
||||
duration: 30min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6.1 Plan 01: Backend Administrators and Roles screens (server side) Summary
|
||||
|
||||
**cabana now ships Settings → System → Administrators and Roles as YAML controllers of an internal `summercms.cabana` pseudo-plugin. Every privilege rule is enforced in the save transaction, and the last active superuser is protected by a `pg_advisory_xact_lock` plus a count. A new `pact.HasAdminActionExtensions` seam lets any plugin add record actions to any admin controller by ID.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** ~30 min
|
||||
- **Started:** 2026-10-22T08:48:58Z
|
||||
- **Completed:** 2026-10-22T09:18:37Z
|
||||
- **Tasks:** 4
|
||||
- **Files modified:** 29 (3066 insertions, 6 deletions)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **D-14 seam.** `pact.AdminActionExtension` and `pact.HasAdminActionExtensions` were added. `compileActionExtensions` merges contributed actions after the controllers compile and before `compileContributions`, so their permissions are validated. The merge builds a new slice and a new map rather than mutating the compiled ones. Unknown controller, no preview block, reserved or duplicate names, a nil `Run` and an empty label each stop boot.
|
||||
- **Pseudo-plugin.** `Activate` appends `backendScreens` only after the `len(items) == 0` early return. `examples/hello` and the surf admin-prefix tests are unchanged. The caller's plugin slice is never mutated.
|
||||
- **Administrators screen (`summercms.cabana.users`).**
|
||||
- List: role, superuser, activation, last-sign-in and deleted filters; deleted and disabled row states.
|
||||
- Preview: status hint, then Activate / Deactivate / Restore, then contributed actions.
|
||||
- Form, Account tab: login, email, names, password and confirmation, role picker.
|
||||
- Form, Permissions tab: superuser switch and radio overrides.
|
||||
- Bulk actions: activate, deactivate, restore; bulk soft delete.
|
||||
- **Privilege rules, enforced on the server:**
|
||||
- D-03: superusers are hidden from non-superusers in the list, every lookup and the schemas.
|
||||
- Pitfall 1: superusers receive the stored `is_superuser` value, so an untouched save keeps the flag.
|
||||
- D-05: the superuser switch is superuser-only, even when the field is hidden.
|
||||
- D-07: locked permission options and role locks for editors without the grants.
|
||||
- D-08: an admin cannot change their own role (checked in `FormAfterUpdate` against a snapshot), flag, overrides or activation, and cannot delete themselves.
|
||||
- D-09: the last active superuser cannot be demoted, deactivated or deleted, on single and bulk paths.
|
||||
- D-11: password min 4 characters, max 72 bytes, bcrypt cost from config.
|
||||
- D-12: `tokens_valid_after` is bumped on a password set for another admin, on deactivate and on delete.
|
||||
- D-19: an editor cannot change an admin who outranks them.
|
||||
- D-20: an admin cannot set their own password here.
|
||||
- Login and email must be unique ignoring case, deleted admins included.
|
||||
- **Roles screen (`summercms.cabana.roles`).**
|
||||
- Fields: name, slug code, description, checkbox permission editor with the editor's ceiling.
|
||||
- System roles keep their code and cannot be deleted.
|
||||
- A role still held by any admin cannot be deleted; the 403 names the role and the count.
|
||||
- Role codes must be unique.
|
||||
- **Copy and docs.** The full `backend::lang.user` (with `user.role`), `backend::lang.permissions` and `settings.category_system` copy is in en and pl. The cabana and pact READMEs, `docs/backend/admin-controllers.md` (new section "Adding record actions to another controller") and `docs/backend/users-and-permissions.md` (Permissions, the Administrators screen, lifecycle, the Roles screen, the My account paragraph) were updated in the same commits as the code.
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1 (tracer): Administrators list and preview, settings tile, cross-controller record actions.** `7340241` (feat)
|
||||
2. **Task 2: Administrators form with the server-side privilege rules.** `8840173` (feat)
|
||||
3. **Task 3: Administrator lifecycle and last-superuser protection.** `530b02a` (feat)
|
||||
4. **Task 4: Roles screen.** `653307d` (feat)
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
- `modules/pact/capabilities.go`: `AdminActionExtension` and `HasAdminActionExtensions`.
|
||||
- `modules/cabana/action_extensions.go`: the boot-time merge and its checks.
|
||||
- `modules/cabana/backend_screens.go`: the pseudo-plugin (controllers, two permissions, two settings links, embedded `AdminFS`), the exported constants and `withBackendScreens`.
|
||||
- `modules/cabana/backend_users_admin.go`: the Administrators controller (scopes, projection, schema hiding, rules, filter options, role locks, permission provider, Form hooks, lifecycle record and bulk actions, hint partial).
|
||||
- `modules/cabana/backend_roles_admin.go`: the Roles controller.
|
||||
- `modules/cabana/backend_privileges.go`: `actsAsSuperuser`, `roleGrantSet`, `effectiveGrants`, `grantsCovered`, `guardOutranked`, `guardLastSuperuser`, `superuserLockKey`, `revocationCutoff`.
|
||||
- `modules/cabana/contracts.go`:
|
||||
- `BackendUser`: `Fillable`, `Rules`, `FilterScopes` and `FilterScope` (`filterByRole`, `filterTrashed`), plus the `priorRoleID`/`priorLoaded` snapshot.
|
||||
- `BackendUserRole`: `Fillable` and `Rules`.
|
||||
- `CompiledController.contributed` and `Registry.permissionOrder`.
|
||||
- `modules/cabana/registry.go`: fills `permissionOrder`.
|
||||
- `modules/cabana/crud.go`: the `recordDataExtender` hook in `projectFullRecord`.
|
||||
- `modules/cabana/http.go`:
|
||||
- `Activate`: the pseudo-plugin and the extension merge.
|
||||
- `schemaFieldHider`, applied in `formSchema` and `listSchema` (new slices).
|
||||
- `modules/cabana/backendscreens/**`: the embedded YAML and the `_hint.htm` partial (copied verbatim from the analog).
|
||||
- `modules/cabana/backend_screens_test.go`: `TestBackendScreensSmoke` (runs under `-short`).
|
||||
- `modules/cabana/backend_screens_smoke_test.go`: `TestBackendScreensPostgresSmoke`, `TestAdministratorsFormSmoke`, `TestAdministratorsLifecycleSmoke` and `TestRolesSmoke`, plus the reusable `screensEnv` harness for Plan 03.
|
||||
- `modules/cabana/example_action_extension_test.go`: the documented seam example (`ProfilesPlugin.AdminActionExtensions`) and `TestExampleActionExtension`.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
- I followed the plan's recorded decisions: the IDs, the conditional pseudo-plugin, record actions only in the seam, the advisory-lock strategy, the D-07 wildcard rule, D-12 leaving personal tokens valid on a password set, the D-17 refusal as a 403, and no users-count column on Roles.
|
||||
- The Active filter label key is `backend::lang.user.filter_activated` (see deviation 1).
|
||||
- Bulk lifecycle actions report their fixed success phrase only when every selected row changed, as the analog does. Otherwise the framework's count text is shown.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Phrase key collision on `backend::lang.user.activated`**
|
||||
- **Found during:** Task 1 (lang keys)
|
||||
- **Issue:** UI-SPEC assigns `user.activated` both to the "Active" filter label and to the "Administrator activated" success toast. One key cannot hold both texts.
|
||||
- **Fix:** `user.activated` keeps the success text, and the filter label uses a new key, `user.filter_activated` ("Active" / "Aktywny"). `config_filter.yaml` uses the new key.
|
||||
- **Files modified:** modules/phrasebook/backend/lang/{en,pl}/lang.yaml, modules/cabana/backendscreens/controllers/users/config_filter.yaml
|
||||
- **Committed in:** 7340241, 8840173
|
||||
|
||||
**2. [Rule 3 - Blocking] The docs checker refuses Go code blocks without `src=`**
|
||||
- **Found during:** Task 1 (docs)
|
||||
- **Issue:** `TestDocsTree` failed: "go code block has no src= reference". The snippet source must also be exercised by a test.
|
||||
- **Fix:** I moved the neutral example to `modules/cabana/example_action_extension_test.go` (`ProfilesPlugin.AdminActionExtensions`), added `TestExampleActionExtension`, and referenced it with `src=` (`summer docs:sync`).
|
||||
- **Committed in:** 7340241
|
||||
|
||||
**3. [Rule 2 - Missing critical] More smoke assertions than the plan lists**
|
||||
- The form smoke also checks the D-20 own-password refusal, the D-08 own-role change being refused and rolled back after assignment, the 422 on a taken login, and a limited editor's rename succeeding without `is_superuser`.
|
||||
- The lifecycle smoke also checks the hint partial for a deleted admin, the `trashed=only` filter, the self-delete refusal, and that bulk activate does not move `tokens_valid_after`.
|
||||
- The roles smoke also checks the code-taken 422, that a system role's name stays editable, and that an unused role deletes.
|
||||
- **Committed in:** 8840173, 530b02a, 653307d
|
||||
|
||||
**4. Commit scope.** Commits use `feat(19.6.1-01): ...`, as the orchestrator instructed, instead of the plan's `feat(cabana): ...`. There are no co-author tags.
|
||||
|
||||
**5. YAML detail.** The trashed scope filter declares `nameFrom: login`, because cabana requires `nameFrom` on a scope filter. The Roles list also sets `messages.empty` to `user.role.list_empty`.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 3 auto-fixed (1 bug, 1 blocking, 1 missing-critical test coverage), plus 2 notes.
|
||||
**Impact on plan:** None on scope. The key rename is a copy-contract fix that Plan 02 and Plan 03 should reference.
|
||||
|
||||
## Existing tests
|
||||
|
||||
No existing test was modified: every pre-existing cabana, surf, pact and hello test passes unchanged with the pseudo-plugin active.
|
||||
|
||||
## Verification
|
||||
|
||||
- `go vet ./...`: pass.
|
||||
- `go test -short ./...` (whole repo): pass.
|
||||
- `go -C examples/hello test ./...`: pass.
|
||||
- `go test -run '^TestDocsTree$' ./cmd/summer`: pass.
|
||||
- `go run ./cmd/summer docs:build --check`: no problems found.
|
||||
- `scripts/check-admin-openapi.sh --check`: exit 0, no swag-visible change.
|
||||
- Docker-backed tests, run directly (the Docker socket was accessible):
|
||||
- `go test ./modules/cabana ./modules/surf`: pass after every task.
|
||||
- The four smokes `TestBackendScreensPostgresSmoke`, `TestAdministratorsFormSmoke`, `TestAdministratorsLifecycleSmoke` and `TestRolesSmoke`: 4/4 `--- PASS`.
|
||||
- SC-1: `git log 88ec4df..HEAD -- modules/cabana/commands.go modules/cabana/token_commands.go modules/cabana/account.go` is empty.
|
||||
- Every task's acceptance criteria were re-run and passed.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The new surface (two admin controllers, the extension seam) is covered by the plan's threat register, T-19.6.1-01 to T-19.6.1-17.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. No external service configuration is required.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 02 (D-21 SPA) can add the field `trigger` (the Administrators `permissions` field has no trigger key yet) and the per-record permission locks: role code-declared grants, and every code on the editor's own record.
|
||||
- Plan 03 can build on `screensEnv` in `backend_screens_smoke_test.go` for the held-lock D-09 race, the D-07 and D-19 cases for limited editors, scoped-token superusers and the seam's boot errors.
|
||||
- 19.7 and the MFA plugin can contribute record actions to `cabana.AdministratorsControllerID` through `pact.HasAdminActionExtensions`.
|
||||
|
||||
---
|
||||
*Phase: 19.6.1-backend-administrators-screen*
|
||||
*Completed: 2026-10-22*
|
||||
|
||||
## Self-Check: PASSED
|
||||
@@ -0,0 +1,284 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 02
|
||||
subsystem: admin
|
||||
tags: [cabana, admin-spa, permissions, fields-yaml, openapi, boardwalk]
|
||||
|
||||
requires:
|
||||
- phase: 19.6.1-01
|
||||
provides: Administrators and Roles controllers, permission editor providers, Registry.permissionOrder, rolePermissions
|
||||
provides:
|
||||
- cabana.PermissionRecordLock and the optional cabana.PermissionRecordLockProvider
|
||||
- RecordMeta.PermissionLocks (meta.permissionLocks) on show, create and update responses, notes localized
|
||||
- record-lock save rule in applyPermissionValues (absent keeps stored, differing present value is 403)
|
||||
- fields.yaml `trigger` (cabana.FieldTrigger on FormField.Trigger) with boot checks
|
||||
- SPA trigger evaluation (trigger.ts), trigger note in FormField, record-locked rows in PermissionEditorField
|
||||
- regenerated admin/openapi/admin.json, admin/src/api/schema.d.ts and modules/boardwalk/dist
|
||||
affects: [19.6.1-03 (SPA and Go unit tests for triggers and record locks), any plugin with a permission editor or a fields.yaml that wants trigger]
|
||||
|
||||
actuals:
|
||||
tokens: 28900
|
||||
tasks: 2
|
||||
commits: 2
|
||||
plan_head_before: e2525d4956e58f693b841324f2837e23fe213d1f
|
||||
plan_head_after: 7091d09699c30b000a4ae6776ada33560e679252
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Per-record display locks travel in the record response meta, never in the form schema"
|
||||
- "Display rules (trigger, record locks) are applied in the SPA by leaving values out of the save body; the server keeps stored values and stays authoritative"
|
||||
- "Injection keys (FORM_PERMISSION_LOCKS, FORM_TRIGGER_NOTES) instead of prop threading through FormGrid/FormField/FieldRenderer"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/cabana/field_trigger.go
|
||||
- modules/cabana/field_trigger_smoke_test.go
|
||||
- modules/cabana/record_locks_smoke_test.go
|
||||
- modules/cabana/example_permission_record_locks_test.go
|
||||
- admin/src/components/form/trigger.ts
|
||||
modified:
|
||||
- modules/cabana/field_permission.go
|
||||
- modules/cabana/relation_field.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/relation_child.go
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/backend_users_admin.go
|
||||
- modules/cabana/form_schema.go
|
||||
- modules/cabana/schema_types.go
|
||||
- modules/cabana/field_dependent.go
|
||||
- modules/cabana/field_repeater.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- modules/cabana/backendscreens/models/user/fields.yaml
|
||||
- modules/cabana/backend_screens_smoke_test.go
|
||||
- modules/cabana/README.md
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml
|
||||
- modules/phrasebook/backend/lang/pl/lang.yaml
|
||||
- admin/openapi/admin.json
|
||||
- admin/src/api/schema.d.ts
|
||||
- admin/src/api/types.ts
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/components/form/control.ts
|
||||
- admin/src/components/form/formState.ts
|
||||
- admin/src/components/form/FormField.vue
|
||||
- admin/src/components/form/fields/PermissionEditorField.vue
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/views/PreviewView.vue
|
||||
- modules/boardwalk/dist
|
||||
- docs/backend/forms.md
|
||||
- docs/backend/users-and-permissions.md
|
||||
|
||||
key-decisions:
|
||||
- "Record-lock notes are filled as phrase keys in projectFullRecord and translated where the show and save paths (and the relation child paths) finish, with s.tr"
|
||||
- "A record-locked row sets data-locked and data-locked-by=\"record\" only where the lock is shown (editable screens); read-only screens show the lock's value only"
|
||||
- "The trigger note is looked up by the FormGrid scope path, so a repeater row field never picks up a top-level note; RelationChildModal provides an empty note map"
|
||||
- "The non-superuser schema check in TestAdministratorsFormSmoke now looks for an is_superuser field rather than the string: the permissions field's trigger names is_superuser by design (UI-SPEC C6)"
|
||||
|
||||
patterns-established:
|
||||
- "Optional controller capabilities next to PermissionEditorProvider are asked only for stored records and only through cabana's save/show paths"
|
||||
- "Triggers are compiled per controller form; settingsFormOnly/controllerFormOnly and the repeater row check refuse them elsewhere"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, D-06, D-08, D-16, D-18, D-21, D-22]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Record-lock save rule: absent locked code keeps stored, differing present value is 403, equal body passes, request-Locked plus record-locked absent code is not a 403, no locks asked on create; meta.permissionLocks present only with a provider"
|
||||
requirement: "D-21"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/record_locks_smoke_test.go#TestPermissionRecordLocksSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Roles and Administrators saves keep working under the record-lock rule (system role grants, own record)"
|
||||
requirement: "D-16"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestRolesSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/backend_screens_smoke_test.go#TestAdministratorsFormSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Trigger compile: valid trigger reaches the localized schema; unknown action, unknown condition, extra key, missing key, not a mapping, self reference, unknown controlling field, text controlling field, repeater row are boot errors naming controller, field and trigger; settings and relation forms refuse it; Administrators permissions carries the D-06 trigger"
|
||||
requirement: "D-06"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/field_trigger_smoke_test.go#TestFieldTriggerSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Generated OpenAPI, schema.d.ts and the committed admin build match fresh generations"
|
||||
requirement: "D-18"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "scripts/check-admin-openapi.sh --check"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "scripts/check-admin-dist.sh"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "SPA rendering: trigger note, read-only overrides while Superuser is on, record-locked rows with notes, tab removal for hidden fields, live-region announcement"
|
||||
requirement: "D-21"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Plan 03 owns the SPA unit tests; the browser behaviour is the Task 2 human-check (verify-work UAT). A throwaway vitest run during execution confirmed the locked row, the payload omission and the trigger note markup, and was not committed."
|
||||
|
||||
duration: 23min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6.1 Plan 02: SPA support for triggers and per-record permission locks Summary
|
||||
|
||||
**The admin now shows permissions a stored record fixes (a role's plugin-declared grants, an administrator's own overrides) as locked rows with their notes, through a new optional `cabana.PermissionRecordLockProvider` and `meta.permissionLocks`. fields.yaml gains WinterCMS's `trigger`, which the Administrators form uses to make the overrides read-only while Superuser is on. The OpenAPI types and the embedded admin build were regenerated.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** ~23 min
|
||||
- **Started:** 2026-10-22T09:21:00Z
|
||||
- **Completed:** 2026-10-22T09:44:04Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 38 (1089 insertions, 95 deletions, dist assets included)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Record locks (D-21 for D-16 and D-08).**
|
||||
- `PermissionRecordLock{Code, Value, Note}` and the optional `PermissionRecordLockProvider` sit next to `PermissionEditorProvider`.
|
||||
- `projectFullRecord` fills `RecordMeta.PermissionLocks`. Show, create and update responses (and the relation child paths) translate the notes in the request locale. The key is omitted when no lock applies.
|
||||
- `applyPermissionValues` on update: a record-locked code that is absent from the body keeps its stored value. A present value must equal the stored one, or the save gets a 403 on the field. The code is skipped in the request-Locked comparison, so a system role whose code grant is not in its stored JSON saves without a 403.
|
||||
- Roles lock every `rolePermissions(code)` grant, in catalog order, at value 1 with `locked_by_code`. Administrators lock every offered code on the editor's own record at its stored override, with `locked_self`.
|
||||
- **Field trigger (D-21 for D-06).**
|
||||
- `FieldTrigger{Action, Field, Condition}` on `FormField.Trigger`.
|
||||
- `compileTrigger` takes exactly action, field and condition. `checkTriggers` runs in `compileForm` through `bootErr`.
|
||||
- Repeater rows, settings forms and relation forms refuse the key.
|
||||
- The Administrators `permissions` field declares `trigger: {action: disable, field: is_superuser, condition: checked}`.
|
||||
- **SPA.**
|
||||
- `trigger.ts` (`triggerState`, `applyTriggers`); injection keys `FORM_PERMISSION_LOCKS` and `FORM_TRIGGER_NOTES`.
|
||||
- `permissionValues(field, value, locked?)` and `editablePayload(fields, values, mode, locks?)`.
|
||||
- FormView: every use of the field list goes through `applyTriggers`, applied with the whole form's values. That covers tabs, panel fields, the banner's field names, the dirty snapshot and the save body. When the active tab disappears, the first remaining tab becomes active. A flip to disabled is announced as "<label>: <note>". Values stay in the form while a field is disabled or hidden.
|
||||
- FormField shows the trigger note (Info 14px, `data-trigger-note`, joined to `aria-describedby`) between the label and the control.
|
||||
- PermissionEditorField shows record-locked rows: the lock's value, disabled with `aria-disabled`, the Lock icon, the lock's note, `data-locked` and `data-locked-by="record"`. A record lock wins over a request lock, and read-only screens show the value only.
|
||||
- PreviewView applies `hide` only.
|
||||
- **Generated and built.** `admin/openapi/admin.json` and `schema.d.ts` are committed with each type change. `modules/boardwalk/dist` was rebuilt and committed in Task 2.
|
||||
- **Docs.**
|
||||
- `docs/backend/forms.md`: new sections "Permissions the record fixes" and "Triggers" (the "Field options" paragraph no longer lists `trigger` as refused).
|
||||
- `docs/backend/users-and-permissions.md`: the read-only overrides, the own-record locks and the locked role grants.
|
||||
- cabana README: Features and API rows.
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1 (tracer): per-record locked permission values.** `705f94d` (feat)
|
||||
2. **Task 2: field trigger and admin build.** `7091d09` (feat)
|
||||
|
||||
Tracer feedback gate: the Task 1 `<verify>` commands, all automated, were re-run end to end (short suite, smoke, hello, OpenAPI check, typecheck, vitest, docs checker, Plan 01 Postgres smokes 2/2). All passed, so Task 2 went ahead.
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
- `modules/cabana/field_permission.go`: the lock types, `permissionRecordLocks`, `localizePermissionLocks`, and the save rule in `applyPermissionValues`.
|
||||
- `modules/cabana/relation_field.go`: `RecordMeta.PermissionLocks`.
|
||||
- `modules/cabana/crud.go` and `relation_child.go`: fill the locks in `projectFullRecord` and translate them in the show and save paths.
|
||||
- `modules/cabana/backend_roles_admin.go` and `backend_users_admin.go`: `AdminPermissionRecordLocks`.
|
||||
- `modules/cabana/field_trigger.go`, `form_schema.go`, `schema_types.go`, `field_dependent.go` and `field_repeater.go`: trigger compile, checks and refusals.
|
||||
- `modules/cabana/backendscreens/models/user/fields.yaml`: the D-06 trigger.
|
||||
- `modules/cabana/admin_openapi.go`: the record and form schema descriptions.
|
||||
- `modules/phrasebook/backend/lang/{en,pl}/lang.yaml`: `permissioneditor.locked_by_code`, `permissioneditor.locked_self`, `form.trigger_disabled_on` and `form.trigger_disabled_off`, verbatim from UI-SPEC.
|
||||
- SPA files as listed in the frontmatter.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
- I followed the plan's decisions: the exported optional interface, the payload shape, the save rule, injection keys instead of prop threading, `checked` and `unchecked` only, and the dist rebuilt once, in Task 2.
|
||||
- Notes are translated after the transaction, where the response is finished. `projectFullRecord` has no translator.
|
||||
- In the editor, `data-locked-by="record"` appears only where the lock is shown. Read-only screens follow the existing `showsLock` rule.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] The Plan 01 schema assertion matched the trigger's reference to is_superuser**
|
||||
- **Found during:** Task 2 (Docker-backed `go test ./modules/cabana`)
|
||||
- **Issue:** `TestAdministratorsFormSmoke` checked that a limited editor's form schema does not contain the string `is_superuser`. The permissions field's trigger now names `is_superuser` by design: UI-SPEC C6 says a controlling field missing from the schema counts as off.
|
||||
- **Fix:** The assertion now checks that no schema field is named `is_superuser`. The D-03 intent is unchanged: the switch itself is still removed for non-superusers.
|
||||
- **Files modified:** modules/cabana/backend_screens_smoke_test.go
|
||||
- **Commit:** 7091d09
|
||||
|
||||
**2. [Rule 3 - Blocking] The docs checker needs a `src=` source for Go blocks**
|
||||
- **Issue:** The docs example of a record-lock provider needs a `src=` reference to compiled, tested code.
|
||||
- **Fix:** Added `modules/cabana/example_permission_record_locks_test.go` (`AccessRolesController.AdminPermissionRecordLocks` with `Example_permissionRecordLocks`) and referenced it from `docs/backend/forms.md`.
|
||||
- **Commit:** 705f94d
|
||||
|
||||
**3. [Rule 2 - Missing critical] Translation and isolation outside the planned paths**
|
||||
- The relation child show and save paths also translate `meta.permissionLocks`, so no response can carry an untranslated phrase key.
|
||||
- `RelationChildModal.vue` provides an empty `FORM_TRIGGER_NOTES`, so a child field that shares a top-level field's name never shows that field's note.
|
||||
- `FormField` looks notes up by the FormGrid scope path, so repeater row fields never match.
|
||||
- **Commits:** 705f94d, 7091d09
|
||||
|
||||
**4. Docs beyond the listed files.** `docs/backend/users-and-permissions.md` gained three sentences (read-only overrides, own-record locks, locked role grants) so that page matches the behaviour. The "Field options" paragraph in forms.md had listed `trigger` among the refused WinterCMS keys; I corrected it.
|
||||
|
||||
**5. Commit scope.** Commits use `feat(19.6.1-02): ...` as the orchestrator instructed, instead of the plan's `feat(cabana,admin): ...`. No co-author tags.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 3 auto-fixed (1 bug, 1 blocking, 1 missing-critical), plus 2 notes.
|
||||
**Impact on plan:** None on scope.
|
||||
|
||||
## Existing tests
|
||||
|
||||
One existing test changed: the `is_superuser` schema assertion in `TestAdministratorsFormSmoke` (deviation 1). Every other existing Go and vitest test passes unchanged.
|
||||
|
||||
## Verification
|
||||
|
||||
- `go vet ./...`: pass.
|
||||
- `go test -count=1 -short ./...`: pass.
|
||||
- `go -C examples/hello test ./...`: pass.
|
||||
- `TestPermissionRecordLocksSmoke`, `TestFieldTriggerSmoke` and `TestBackendScreensSmoke`: 3/3 `--- PASS`.
|
||||
- `go test -count=1 ./modules/cabana ./modules/surf ./modules/boardwalk` (Docker reachable directly): pass. This includes the Plan 01 Postgres smokes, 4/4.
|
||||
- `scripts/check-admin-openapi.sh --check`: pass after each commit.
|
||||
- `npm --prefix admin run typecheck`: pass.
|
||||
- `npm --prefix admin run test`: 93 files, 1435 tests, all pass. One earlier run hit a 5s timeout in `tests/smoke/list.smoke.test.ts` under load. It passed alone and on the full rerun; the test is unrelated to forms.
|
||||
- `scripts/check-admin-dist.sh`: "modules/boardwalk/dist matches a fresh build".
|
||||
- `go test -run '^TestDocsTree$' ./cmd/summer` and `summer docs:build --check`: pass.
|
||||
- `admin/package.json` and `package-lock.json` are unchanged. `npm ls` reports the installed tree consistent with the lockfile. I did not run `npm ci`, because node_modules was present and other sessions share it.
|
||||
- All acceptance greps for both tasks print the expected counts.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None blocking.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The new surface (`meta.permissionLocks`, the `trigger` key) is covered by T-19.6.1-18 to T-19.6.1-23:
|
||||
- The server never trusts a trigger or a lock from the client.
|
||||
- Notes render through text interpolation only; the touched components contain no `v-html`.
|
||||
- No package was added.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 03 can unit-test:
|
||||
- `triggerState` and `applyTriggers` (trigger.ts);
|
||||
- the record-locked rows in `PermissionEditorField` (inject `FORM_PERMISSION_LOCKS`);
|
||||
- `editablePayload` with locks;
|
||||
- the FormField note (`FORM_TRIGGER_NOTES`, id `<controlId>-trigger`);
|
||||
- the FormView tab fallback and announcement.
|
||||
- On the server side it can unit-test `compileTrigger` and `checkTriggers`, plus own-record and system-role locks against Postgres through `screensEnv`.
|
||||
- Manual UAT (Task 2 human-check):
|
||||
- As a superuser, open another superuser: the overrides are read-only with the note, and switching Superuser off makes them editable.
|
||||
- Your own record shows locked rows.
|
||||
- A role that plugins grant to shows those grants locked with "Granted to this role by a plugin."
|
||||
|
||||
---
|
||||
*Phase: 19.6.1-backend-administrators-screen*
|
||||
*Completed: 2026-10-22*
|
||||
|
||||
## Self-Check: PASSED
|
||||
@@ -0,0 +1,338 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 03
|
||||
subsystem: testing
|
||||
tags: [cabana, admin-spa, permissions, postgres, advisory-lock, vitest, playwright, gate]
|
||||
|
||||
requires:
|
||||
- phase: 19.6.1-01
|
||||
provides: Administrators and Roles screens, privilege rules, pact.HasAdminActionExtensions, the screensEnv smoke harness
|
||||
- phase: 19.6.1-02
|
||||
provides: field trigger, PermissionRecordLockProvider, meta.permissionLocks, trigger.ts, SPA record-locked rows
|
||||
provides:
|
||||
- one named test per privilege rule of D-03, D-05..D-12, D-16, D-17, D-19, D-20 over the assembled HTTP handler on Postgres
|
||||
- the held-lock last-superuser race on all five reducing paths, plus ten unsynchronized rounds
|
||||
- TestActionExtensionBoot / TestActionExtensionRun for the D-14 seam, TestBackendScreensActivation, TestRoleCeiling
|
||||
- D-21 tests in Go (TestFieldTriggerBoot, TestPermissionRecordLocks, TestRolesCodeDeclaredLocks) and in the SPA (unit, FormView backstops, 1024px browser footer test)
|
||||
- scripts/check-phase19.6.1.sh, the fail-closed phase gate
|
||||
- two production fixes found by the tests (password minimum, bulk lifecycle actions)
|
||||
affects: [19.6.1 verify-work, 19.6 D-15 (Reset 2FA contribution), 19.7 (link action on Administrators), lagoon validation (deferred)]
|
||||
|
||||
actuals:
|
||||
tokens: 43200
|
||||
tasks: 4
|
||||
commits: 9
|
||||
plan_head_before: 1aaa8a444c5bdc59cf6f008de101186b25455922
|
||||
plan_head_after: 8f3d62594356fce4ec1eb07af1a46240148b66e2
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Postgres rule tests through the assembled admin handler with per-test seeded rows, t.Cleanup demote and soft-delete, and row_to_json snapshots for 'unchanged' checks"
|
||||
- "Concurrency proven by holding the guard's advisory lock in a test transaction until pg_locks shows both requests waiting"
|
||||
- "Vitest browser layout tests load the admin's Tailwind build (tailwindcss plugin in vitest.browser.config.ts)"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/cabana/administrators_harness_test.go
|
||||
- modules/cabana/administrators_postgres_test.go
|
||||
- modules/cabana/administrators_lifecycle_postgres_test.go
|
||||
- modules/cabana/backend_privileges_internal_test.go
|
||||
- modules/cabana/action_extensions_test.go
|
||||
- modules/cabana/action_extensions_postgres_test.go
|
||||
- modules/cabana/roles_postgres_test.go
|
||||
- modules/cabana/field_trigger_test.go
|
||||
- modules/cabana/record_locks_test.go
|
||||
- admin/tests/form/trigger.test.ts
|
||||
- admin/tests/browser/record-actions-wrap.test.ts
|
||||
- scripts/check-phase19.6.1.sh
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/deferred-items.md
|
||||
modified:
|
||||
- modules/cabana/backend_users_admin.go
|
||||
- modules/cabana/export_test.go
|
||||
- modules/cabana/backend_screens_test.go
|
||||
- modules/cabana/backend_screens_smoke_test.go
|
||||
- admin/tests/form/PermissionEditorField.test.ts
|
||||
- admin/tests/form/formState.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
- admin/tests/form/PreviewView.test.ts
|
||||
- admin/vitest.browser.config.ts
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-VALIDATION.md
|
||||
|
||||
key-decisions:
|
||||
- "The screens harness moved from backend_screens_smoke_test.go into administrators_harness_test.go and gained cleanup; its call keeps the existing (method, rel, token, body) order so Plan 01's smokes run unchanged"
|
||||
- "The password minimum is enforced in usersAdmin.storePassword; the lagoon model validator's missing string min/max is deferred, because fixing it changes every model with string length rules"
|
||||
- "The gate's name check covers every non-test file under modules/ and docs/ plus this phase's test files; older test files that name applications are outside the phase"
|
||||
- "A hidden superuser's DELETE answers exactly what a missing id answers (200, deleted 0); the D-03 test asserts that equality instead of a 404"
|
||||
|
||||
patterns-established:
|
||||
- "One rule, one named test: status, the en refusal text from UI-SPEC C8, and a byte-for-byte unchanged row"
|
||||
- "Gate scripts list every required test by name and refuse skipped, zero-match or missing runs"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-3, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-10, D-11, D-12, D-14, D-15, D-16, D-17, D-18, D-19, D-20, D-21, D-22]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Save-path rules over HTTP on Postgres: superuser flag (D-05), hiding incl. scoped-token superusers (D-03), projection (Pitfall 1), permission and role ceilings (D-06, D-07), self edit (D-08), password and identity (D-11), outranking (D-19), own password (D-20)"
|
||||
requirement: "D-05"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/administrators_postgres_test.go#TestAdministratorsSuperuserFlag, TestAdministratorsSuperuserHidden, TestAdministratorsSuperuserProjected, TestAdministratorsPermissionCeiling, TestAdministratorsRoleCeiling, TestAdministratorsSelfEdit, TestAdministratorsPasswordAndIdentity, TestAdministratorsOutranked, TestAdministratorsOwnPassword"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/backend_privileges_internal_test.go#TestRoleCeiling"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Concurrent last-superuser protection on demote, record and bulk deactivate, form and bulk delete (held advisory lock, two waiters in pg_locks), plus ten unsynchronized rounds"
|
||||
requirement: "D-09"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/administrators_lifecycle_postgres_test.go#TestAdministratorsLastSuperuser"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/administrators_lifecycle_postgres_test.go#TestAdministratorsLastSuperuserConcurrent"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Lifecycle (Applies, 409, bulk Affected, soft delete keeps rows, trashed filter, hint precedence) and revocation (JWT and personal tokens after deactivate and delete, sessions after a password set, cutoff unchanged by restore and activate)"
|
||||
requirement: "D-10"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/administrators_lifecycle_postgres_test.go#TestAdministratorsLifecycle"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/administrators_lifecycle_postgres_test.go#TestAdministratorsRevocation"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "D-14 seam: boot refusals and order (unit), offer and run only with both permissions, 409 when Applies turns false, Run in the transaction with the record (Postgres); activation only with an admin"
|
||||
requirement: "D-14"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/action_extensions_test.go#TestActionExtensionBoot"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/action_extensions_postgres_test.go#TestActionExtensionRun"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/backend_screens_test.go#TestBackendScreensActivation"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Roles: code taken and locked, plugin-declared system roles, in-use delete with soft-deleted holders, bulk delete rollback, permission ceiling"
|
||||
requirement: "D-16"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/roles_postgres_test.go#TestRolesLifecycle"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/roles_postgres_test.go#TestRolesPermissionCeiling"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "D-21 server side: trigger boot rules, record-lock save rule in both modes, code-declared and own-record locks on Postgres"
|
||||
requirement: "D-21"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/field_trigger_test.go#TestFieldTriggerBoot"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/record_locks_test.go#TestPermissionRecordLocks"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/roles_postgres_test.go#TestRolesCodeDeclaredLocks"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "D-21 SPA backstops: trigger disable, absent controlling field, hide-tab removal with the banner line, record-locked rows and payload omission, preview hide; footer wrap at 1024px with two 40-character contributed labels"
|
||||
requirement: "D-21"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "admin/tests/form/trigger.test.ts, FormView.test.ts#field triggers on the form, PermissionEditorField.test.ts#permissions the record fixes, formState.test.ts#record permission locks in the save body, PreviewView.test.ts#field triggers on the preview"
|
||||
status: pass
|
||||
- kind: automated_ui
|
||||
ref: "admin/tests/browser/record-actions-wrap.test.ts#backstop: wraps onto more than one row and no button overlaps Edit"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D8
|
||||
description: "Phase gate: bash scripts/check-phase19.6.1.sh --all (self-test, go, admin, docs, sc1, docker) exits 0; SC-1 regression tests pass unchanged"
|
||||
requirement: "SC-1"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "bash scripts/check-phase19.6.1.sh --all"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D9
|
||||
description: "The screens render and behave in a real browser session (lists, forms, preview footer, toasts) as a superuser and as a limited administrator"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "The VALIDATION manual-only item: visual and interactive SPA behaviour beyond the unit and layout tests needs a person at a running admin."
|
||||
|
||||
duration: 38min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6.1 Plan 03: Privilege rule tests, D-21 SPA tests and the phase gate Summary
|
||||
|
||||
**Every privilege rule of the Administrators and Roles screens now has a named test against the assembled admin on Postgres, including the concurrent last-superuser race on all five reducing paths. The D-21 trigger and record-lock behaviour is tested in Go, in vitest and at 1024px in Chromium. `scripts/check-phase19.6.1.sh --all` proves the phase fail-closed. The tests found two production bugs, each fixed in its own commit: a password under 4 characters was accepted, and bulk lifecycle actions changed only the first selected administrator.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** ~38 min
|
||||
- **Started:** 2026-10-22T09:47:03Z
|
||||
- **Completed:** 2026-10-22T10:24:41Z
|
||||
- **Tasks:** 4
|
||||
- **Files modified:** 23 (3761 insertions, 274 deletions)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Test env (tracer).** `administrators_harness_test.go` holds the screens harness:
|
||||
- `newScreensEnv(t, extra...)` assembles the admin with any extra plugins.
|
||||
- `seedAdmin` and `seedRole` insert unique rows and register cleanup.
|
||||
- Also `login`, `isolateSuperusers`, `call`/`serve` (with `X-Requested-With` on writes), and `userRow`/`roleRow` (`row_to_json` snapshots).
|
||||
- The pinger plugin's `acme_ping` action now has a switchable `Applies`, plus a token scope over `backend.manage_users`.
|
||||
- `export_test.go` exposes `SuperuserLockKey`.
|
||||
- **Save-path rules (Task 2):**
|
||||
- D-03: superusers stay hidden from a delegate in the list, under search and filters, on GET, the hint partial, record actions, PUT and DELETE (a DELETE answers exactly as for a missing id), in bulk selections, and in both schemas. A superuser's scoped personal token is treated the same way; a `*` token is not.
|
||||
- D-05: only a superuser may send the switch, true or false, on create or update.
|
||||
- Pitfall 1: saving the SPA payload of an untouched superuser record keeps the flag.
|
||||
- D-06/D-07: permission and role ceilings. A stored locked override is kept. A user-level deny is merged last and shuts the delegate out of the screen. An above-ceiling role the target already holds is kept.
|
||||
- D-08: self-edit limits. D-11: password rules and unique identity. D-19: the delegate is outranked on all eleven write paths. D-20: own password.
|
||||
- `TestRoleCeiling` covers `grantsCovered`.
|
||||
- **Race and lifecycle (Task 3):**
|
||||
- `TestAdministratorsLastSuperuser` has five literal subtests. In each, a test transaction holds `pg_advisory_xact_lock(SuperuserLockKey)` until `pg_locks` shows two ungranted advisory locks. Exactly one 2xx, one 403 with the last_superuser text, one superuser left, no 500 or deadlock. Stable across `-count=4`.
|
||||
- `TestAdministratorsLastSuperuserConcurrent` runs ten unsynchronized rounds.
|
||||
- Lifecycle and revocation tests (two-row bulk selections included).
|
||||
- The seam: `TestActionExtensionBoot` (all refusals and the declared order) and `TestActionExtensionRun`.
|
||||
- Roles: `TestRolesLifecycle` and `TestRolesPermissionCeiling`.
|
||||
- `TestBackendScreensActivation`.
|
||||
- **D-21 and the gate (Task 4):**
|
||||
- Go: `TestFieldTriggerBoot`, `TestPermissionRecordLocks` (radio and checkbox), `TestRolesCodeDeclaredLocks`.
|
||||
- SPA:
|
||||
- `trigger.test.ts` (11 tests).
|
||||
- FormView backstops: disable, absent controlling field, hide-tab removal with the banner line, and the live announcement.
|
||||
- PermissionEditorField and formState: record-locked rows.
|
||||
- PreviewView: hide.
|
||||
- The 1024px browser footer test.
|
||||
- The gate script and the filled validation map.
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1 (tracer): screens test env and the superuser flag rule.** `536ea8c` (test). Tracer gate: the `<verify>` was re-run end to end and passed before Task 2.
|
||||
2. **Task 2: save-path rule tests.** `461cb21` (fix, deviation 1), `b684bb7` (test)
|
||||
3. **Task 3: race, lifecycle, revocation, seam and roles.** `8324070` (fix, deviation 2), `1a56294` (test)
|
||||
4. **Task 4: D-21 tests, gate, validation map.** `085179b` (test, Go), `4c61a18` (test, SPA), `7842aca` (chore, gate), `8f3d625` (docs, validation map and deferred items)
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
- `modules/cabana/administrators_harness_test.go`: the shared Postgres screens env (moved from `backend_screens_smoke_test.go` and extended).
|
||||
- `modules/cabana/administrators_postgres_test.go`: the nine save-path rule tests.
|
||||
- `modules/cabana/administrators_lifecycle_postgres_test.go`: the race helper and the lifecycle and revocation tests.
|
||||
- `modules/cabana/backend_privileges_internal_test.go`: `TestRoleCeiling`.
|
||||
- `modules/cabana/action_extensions_test.go`, `action_extensions_postgres_test.go`: the D-14 seam.
|
||||
- `modules/cabana/roles_postgres_test.go`: Roles and code-declared locks.
|
||||
- `modules/cabana/field_trigger_test.go`, `record_locks_test.go`: D-21 unit tests.
|
||||
- `modules/cabana/backend_screens_test.go`: `TestBackendScreensActivation`.
|
||||
- `modules/cabana/backend_users_admin.go`: the two fixes.
|
||||
- `admin/tests/form/*.test.ts`, `admin/tests/browser/record-actions-wrap.test.ts`, `admin/vitest.browser.config.ts`: the SPA tests.
|
||||
- `scripts/check-phase19.6.1.sh`: the gate.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
- I reused the Plan 01 harness rather than building a second one. The file is now `administrators_harness_test.go`, as the plan names it. The existing `call(t, method, rel, token, body)` argument order stayed, so the four Plan 01 smokes run unchanged.
|
||||
- The D-07 "above-ceiling role kept" case uses a holder whose override denies the extra grant. Without that the holder would outrank the delegate (D-19), and no save could reach the role check.
|
||||
- "The override merged last" is shown through route access (a deny of `backend.manage_users` returns 403 on the list), because `/auth/me` does not expose permissions.
|
||||
- The gate's docs stage checks non-test sources plus this phase's test files. Older lagoon and postcard tests name applications, and that is pre-existing.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] The Administrators form accepted a 3-character password**
|
||||
- **Found during:** Task 2 (`TestAdministratorsPasswordAndIdentity/too_short` got 201)
|
||||
- **Issue:** `FormRules` declares `min:4`, but `lagoon.Validate` (the model validator) collects string `min`/`max` tags and then skips them, so the rule never applied. D-11 was not enforced.
|
||||
- **Fix:** `usersAdmin.storePassword` now refuses a typed password under `adminPasswordMinChars` (4) characters (counted with `utf8.RuneCountInString`). It answers 422 on `password` with the `min.string` text, next to the existing 72-byte check. The lagoon gap is logged in deferred-items.md.
|
||||
- **Files modified:** modules/cabana/backend_users_admin.go
|
||||
- **Verification:** the test passes with "at least 4 characters"; `go test -short ./...` is green.
|
||||
- **Committed in:** `461cb21`
|
||||
|
||||
**2. [Rule 1 - Bug] Bulk activate, deactivate and restore changed only the first selected administrator**
|
||||
- **Found during:** Task 3 (`TestAdministratorsLifecycle`: bulk deactivate reported `affected: 2`, but the second row stayed active)
|
||||
- **Issue:** `actionDB` returned the `Unscoped()` instance of a NewDB session. GORM conditions accumulate on that instance, so the second `Where("id = ?")` update matched `id = A AND id = B` (no row) while still being counted. A bulk deactivate therefore left every row after the first active and signed in, which breaks D-10 and D-12 revocation.
|
||||
- **Fix:** `actionDB` now ends with `.Session(&gorm.Session{})`, so every query starts fresh.
|
||||
- **Files modified:** modules/cabana/backend_users_admin.go
|
||||
- **Verification:** `TestAdministratorsLifecycle` checks stored rows after the bulk calls. `TestAdministratorsRevocation` now ends two sessions and two personal tokens in one bulk deactivate and one bulk delete. Plan 01's lifecycle smoke still passes.
|
||||
- **Committed in:** `8324070`
|
||||
|
||||
**3. [Rule 3 - Blocking] The browser layout test needs the admin's CSS**
|
||||
- **Found during:** Task 4.
|
||||
- **Issue:** `vitest.browser.config.ts` had no Tailwind plugin, so a footer mounted with the real classes would have no layout.
|
||||
- **Fix:** I added `tailwindcss()` to the browser config. The test imports `src/styles/main.css` and copies the footer classes from PreviewView.vue. The richeditor browser tests are unaffected.
|
||||
- **Files modified:** admin/vitest.browser.config.ts (not in the plan's file list)
|
||||
- **Committed in:** `4c61a18`
|
||||
|
||||
**4. Commit scope.** Commits use `(19.6.1-03)` as the orchestrator instructed: `test`, `chore` for the script, `docs` for the planning files. The two production fixes use `fix(cabana)`, as the plan requires. There are no co-author tags.
|
||||
|
||||
**5. Assertions adapted to built behaviour (no rule weakened).**
|
||||
- A hidden superuser's DELETE returns the framework's "deleted 0" answer, identical to a missing id, so it reveals nothing. The test asserts that equality instead of a 404.
|
||||
- Own overrides are refused through the record lock ("You cannot change this permission.") before the `self_privileged` check. The test asserts the 403 on `permissions` and an unchanged row.
|
||||
- One TestRoleCeiling case (`*.manage` held covering `acme.manage`) was dropped: `granted` does not expand held leading wildcards. That is pre-existing behaviour, logged in deferred-items.md.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 3 auto-fixed (2 bugs, 1 blocking), plus 2 notes.
|
||||
**Impact on plan:** The two fixes close real gaps in D-11 and D-10/D-12 on the server. There is no scope creep.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
The tasks are marked `tdd="true"`, but this plan is the project's "unit tests last" plan: it tests behaviour Plans 01 and 02 built. So most tests passed on first run, and there are no `feat(19.6.1-03)` commits. Where a test failed because the code was wrong (deviations 1 and 2), the failing test came first and the fix went into its own `fix(cabana)` commit.
|
||||
|
||||
## Verification
|
||||
|
||||
- `go vet ./...`, `go test -short ./...`, `go -C examples/hello test ./...`: pass. These ran inside the gate's go stage and after each task.
|
||||
- Docker-backed tests ran directly (the Docker socket was accessible):
|
||||
- `go test ./modules/cabana ./modules/surf`: pass.
|
||||
- The gate's docker stage passed: 21 Postgres rule and smoke tests by name, 10 SC-1 regression tests, and 162 surf tests.
|
||||
- `npm --prefix admin run typecheck`: pass. `npm --prefix admin run test`: 94 files, 1461 tests pass. `npm --prefix admin run test:browser`: 2 files, 8 tests pass.
|
||||
- `scripts/check-admin-openapi.sh --check` and `scripts/check-admin-dist.sh`: pass, and the dist is unchanged.
|
||||
- `bash scripts/check-phase19.6.1.sh --all`: **exit 0**, "Phase 19.6.1 gate passed". PASS for self-test, go, admin, docs, sc1 and docker; no NOT RUN.
|
||||
- SC-1: 17 commits since `88ec4df`; no phase commit touches commands.go, token_commands.go or account.go.
|
||||
- Every acceptance grep of the four tasks prints the expected count.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None blocking. Two out-of-scope findings are in deferred-items.md:
|
||||
- lagoon's model validator skips string `min`/`max`, so for example an over-long `login` reaches Postgres as a 500 instead of a 422.
|
||||
- `granted` does not expand a held leading wildcard.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The two fixes tighten existing surface (T-19.6.1-07, T-19.6.1-11). T-19.6.1-24..27 are mitigated:
|
||||
- every rule has a named test, and the gate requires each name;
|
||||
- the race is forced on every path;
|
||||
- `isolateSuperusers`, unique rows and cleanup keep tests apart, and there is no `t.Parallel`;
|
||||
- the name check covers the phase's tests.
|
||||
|
||||
No package was added.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Phase 19.6.1 is complete. Its last plan is done, and the gate is ready as input for `/msd-verify-work`.
|
||||
- Manual UAT remains: the screens in a real browser session, as a superuser and as a limited administrator (VALIDATION manual-only row).
|
||||
- Before the next release tag, it is worth looking at the lagoon string `min`/`max` gap (deferred-items.md).
|
||||
|
||||
---
|
||||
*Phase: 19.6.1-backend-administrators-screen*
|
||||
*Completed: 2026-10-22*
|
||||
|
||||
## Self-Check: PASSED
|
||||
@@ -0,0 +1,302 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 04
|
||||
type: execute
|
||||
wave: 4
|
||||
depends_on: ["19.6.1-01", "19.6.1-02", "19.6.1-03"]
|
||||
files_modified:
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/action_extensions.go
|
||||
- modules/cabana/roles_postgres_test.go
|
||||
- modules/cabana/action_extensions_postgres_test.go
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/README.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- scripts/check-phase19.6.1.sh
|
||||
autonomous: true
|
||||
gap_closure: true
|
||||
gap_ids: [G-19.6.1-1, G-19.6.1-2]
|
||||
requirements: [SC-2, D-07, D-16, D-19]
|
||||
|
||||
estimate:
|
||||
tokens: 55000
|
||||
raw_tokens: 55000
|
||||
tasks: 3
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "SC-2 / D-07: an admin cannot raise their own role or permissions, and a non-superuser cannot add a permission they lack to any role (Roles screen ceiling)"
|
||||
- "D-19: a non-superuser holding backend.manage_users gets 403 user.outranked when running a record action on a non-superuser admin whose effective grants they do not cover"
|
||||
- "D-16: a role never becomes a code-declared system role through the Roles screen. FormBeforeCreate and FormBeforeUpdate refuse a submitted code when len(reg.rolePermissions(newCode)) is greater than 0 and newCode is not the stored code (empty stored code on create). The save answers 422 with backend::lang.user.role.code_locked on code and the role row is unchanged (or never inserted)."
|
||||
artifacts:
|
||||
- path: "modules/cabana/backend_roles_admin.go"
|
||||
provides: "Roles hooks refuse a new code that code-declared grants attach to"
|
||||
contains: "rolePermissions("
|
||||
- path: "modules/cabana/action_extensions.go"
|
||||
provides: "contributed Run on AdministratorsControllerID wrapped with guardOutranked"
|
||||
contains: "wrapAdministratorsContributedRun"
|
||||
- path: "modules/cabana/roles_postgres_test.go"
|
||||
provides: "CR-01 regression: rename and create onto a code-declared code"
|
||||
contains: "TestRolesCodeDeclaredCodeRefused"
|
||||
- path: "modules/cabana/action_extensions_postgres_test.go"
|
||||
provides: "WR-03 regression: contributed action on an outranking target"
|
||||
contains: "TestActionExtensionOutranked"
|
||||
- path: "scripts/check-phase19.6.1.sh"
|
||||
provides: "gate REQUIRE lists both new Postgres tests by name"
|
||||
contains: "TestRolesCodeDeclaredCodeRefused"
|
||||
- path: "modules/pact/capabilities.go"
|
||||
provides: "AdminActionExtension docs state the Administrators privilege rule"
|
||||
contains: "user.outranked"
|
||||
key_links:
|
||||
- from: "modules/cabana/backend_roles_admin.go"
|
||||
to: "modules/cabana/registry.go"
|
||||
via: "both Roles hooks consult rolePermissions of the submitted code, not only the stored one"
|
||||
pattern: "rolePermissions\\("
|
||||
- from: "modules/cabana/action_extensions.go"
|
||||
to: "modules/cabana/backend_privileges.go"
|
||||
via: "compileActionExtensions wraps contributed Run so guardOutranked runs inside the action transaction before the contributor"
|
||||
pattern: "guardOutranked\\("
|
||||
- from: "scripts/check-phase19.6.1.sh"
|
||||
to: "modules/cabana/roles_postgres_test.go"
|
||||
via: "the docker stage requires the CR-01 test by name"
|
||||
pattern: "TestRolesCodeDeclaredCodeRefused"
|
||||
- from: "scripts/check-phase19.6.1.sh"
|
||||
to: "modules/cabana/action_extensions_postgres_test.go"
|
||||
via: "the docker stage requires the WR-03 test by name"
|
||||
pattern: "TestActionExtensionOutranked"
|
||||
prohibitions:
|
||||
- statement: "Do not take the weaker position that contributors own authorization on Administrators. Wrap in cabana. Do not export guardOutranked as the fix."
|
||||
status: unresolved
|
||||
verification: judgment
|
||||
- statement: "Do not edit 19.6.1-01-PLAN.md, 19.6.1-02-PLAN.md, or 19.6.1-03-PLAN.md. Do not change SPA UI, phrasebook keys, commands.go, token_commands.go, or account.go."
|
||||
status: unresolved
|
||||
verification: judgment
|
||||
- statement: "Framework code, READMEs, docs and tests name no consuming application; no new dependency is added and YAML stays on goccy/go-yaml."
|
||||
status: unresolved
|
||||
verification: judgment
|
||||
---
|
||||
|
||||
## Phase Goal
|
||||
|
||||
ROADMAP Goal (not a user story; MVP mode off): cabana gets WinterCMS's Administrators screens with privilege rules on the server.
|
||||
|
||||
This plan's slice (plan 4 of 4, wave 4, gap_closure): close the two VERIFICATION.md `gaps:` items. G-19.6.1-1 / CR-01 (blocker, SC-2 + D-07, also D-16): a non-superuser holding `backend.manage_roles` can create or rename a role onto a code that `pact.Permission.Roles` attaches grants to. G-19.6.1-2 / WR-03 (D-19): contributed record actions targeting `AdministratorsControllerID` skip `guardOutranked`. Ignore `deferred:`, human_verification, WR-01, WR-02, and IN-01..IN-06.
|
||||
|
||||
## Spec-less probe fallback
|
||||
|
||||
Spec-less probe fallback skipped: phase has no requirement IDs to probe (visible skip). REQUIREMENTS.md maps none to 19.6.1. Edge rows that this gap work can affect are lifted from 19.6.1-UI-SPEC.md "UI Considerations" into the UI Considerations section below (Roles form 422 on Code; record-action 403 danger toast). Prohibitions recalled by hand.
|
||||
|
||||
## Discovery
|
||||
|
||||
Level 0: existing cabana hooks, `guardOutranked`, `compileActionExtensions`, and the Plan 03 harness. No new dependency.
|
||||
|
||||
## Decisions taken in this plan
|
||||
|
||||
- Stricter D-16 reading (gap contract): refuse in both Roles hooks when `len(reg.rolePermissions(newCode))` is greater than 0 and `newCode != storedCode`. A role never becomes a code-declared system role through the screen, including when the editor is a superuser. Reuse 422 `backend::lang.user.role.code_locked` on `code` (UI-SPEC C8 D-16 field error). Do not add a phrase key.
|
||||
- D-19 wrap in cabana (gap contract): when `ext.Controller == AdministratorsControllerID`, replace each contributed `Run` with a wrapper that calls `guardOutranked(ctx, reg, principal, record.(*BackendUser))` inside the existing `CRUDService.RecordAction` transaction before the contributor's `Run`. Do not export `guardOutranked`. Do not document that contributors apply the check themselves.
|
||||
- Existing helpers `roleGrantSet` / `grantsCovered` stay as they are. The Roles hooks use `rolesAdmin.registry().rolePermissions(newCode)`, the same source `systemRole` already uses for the stored code.
|
||||
- Test names: `TestRolesCodeDeclaredCodeRefused` (package cabana_test, `roles_postgres_test.go`) and `TestActionExtensionOutranked` (package cabana_test, `action_extensions_postgres_test.go`). Both are added to `DOCKER_TESTS` in `scripts/check-phase19.6.1.sh`.
|
||||
|
||||
## Source coverage (this gap plan)
|
||||
|
||||
| Source | Item | Plan | Status |
|
||||
|---|---|---|---|
|
||||
| VERIFICATION gaps | G-19.6.1-1 / CR-01 | 04 | COVERED |
|
||||
| VERIFICATION gaps | G-19.6.1-2 / WR-03 | 04 | COVERED |
|
||||
| CONTEXT | D-07 Roles screen ceiling (code path) | 04 | COVERED |
|
||||
| CONTEXT | D-16 system role never created through the screen | 04 | COVERED |
|
||||
| CONTEXT | D-19 no outranking on record actions, contributed included | 04 | COVERED |
|
||||
| GOAL / SC-2 | an admin cannot raise their own permissions | 04 | COVERED |
|
||||
| REQ | phase_req_ids null | — | skipped (visible) |
|
||||
| VERIFICATION deferred / WR-01 / WR-02 / IN-01..IN-06 / human_verification | out of gap-closure scope | — | excluded |
|
||||
|
||||
Plans 01-03 remain COVERED for D-01..D-22 except the two failed truths this plan re-closes. No MISSING rows.
|
||||
|
||||
## UI Considerations
|
||||
|
||||
This gap plan does not change SPA UI. Lifted from 19.6.1-UI-SPEC.md only the surfaces the two refusals already use:
|
||||
|
||||
| Category | Element | Status | Resolution |
|
||||
|----------|---------|--------|------------|
|
||||
| error | Roles form refusals | covered | A create or rename onto a code-declared code answers 422 with `user.role.code_locked` under Code (same C8 mapping as a system-role code change). Field line plus the existing count banner. Values and dirty state stay. |
|
||||
| error | Record action refused (403) | covered | A contributed action on an outranking Administrators target answers 403 `user.outranked`. PreviewView already shows a danger toast with `error.message` (C8 D-19 row). No SPA change. |
|
||||
|
||||
## Artifacts this phase produces
|
||||
|
||||
- cabana unexported: `wrapAdministratorsContributedRun(reg *Registry, next func(context.Context, pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error))` in `action_extensions.go`; Roles helper that refuses a submitted code when `rolePermissions` of that code is non-empty and the code is not the stored one (name at executor discretion, called from `FormBeforeCreate` and `FormBeforeUpdate`).
|
||||
- Go tests: `TestRolesCodeDeclaredCodeRefused`, `TestActionExtensionOutranked`.
|
||||
- Gate REQUIRE entries on `DOCKER_TESTS`: `TestRolesCodeDeclaredCodeRefused`, `TestActionExtensionOutranked`.
|
||||
- Docs: `AdminActionExtension` comment in `modules/pact/capabilities.go`; one sentence each in `modules/pact/README.md` (`AdminActionExtension` / `HasAdminActionExtensions` rows), `modules/cabana/README.md` (record-action-extension Features bullet), and `docs/backend/admin-controllers.md` (Adding record actions to another controller).
|
||||
|
||||
<objective>
|
||||
Close G-19.6.1-1 (CR-01) and G-19.6.1-2 (WR-03): refuse a Roles create or rename onto a code-declared code, and wrap contributed Administrators record-action Runs with guardOutranked before the contributor runs.
|
||||
|
||||
Purpose: SC-2, D-07, D-16, D-19. The two VERIFICATION.md failed truths become true.
|
||||
Output: two hook/wrap changes, two named Postgres tests, gate REQUIRE lines, seam docs. No SPA change. Skip git commit (orchestrator commits). Skip STATE.md raw edits.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-CONTEXT.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-RESEARCH.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-PATTERNS.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-VERIFICATION.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-UI-SPEC.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-03-SUMMARY.md
|
||||
|
||||
Concurrency and commits: 19.6, 19.7 and 19.8 may still touch cabana. Before each task run `git status --porcelain -- modules/cabana modules/pact docs scripts/check-phase19.6.1.sh` and stop if a file this task edits carries someone else's uncommitted change. Stage by explicit path, never `git add -A`; leave STATE.md and state.json alone; no co-author tags. The orchestrator commits after the checker — do not git commit from this plan. Docker-backed tests skip under -short; on this host run them, through `sudo -u golem` if the Docker socket is denied (CLAUDE.md); a Docker test that could not run is NOT RUN in the SUMMARY, never passed.
|
||||
|
||||
<interfaces>
|
||||
- rolesAdmin.FormBeforeCreate (backend_roles_admin.go:160) currently only `checkCode` (uniqueness). FormBeforeUpdate (171) re-reads stored id/code/is_system, refuses `systemRole(stored.IsSystem, stored.Code) && role.Code != stored.Code` with ValidationError details.code = rolesLang + "code_locked", then checkCode. systemRole (85) is is_system or len(registry().rolePermissions(code)) greater than 0. checkCode (193) counts other rows with the same code. rolesLang = "backend::lang.user.role.". writeDB / asRole already exist.
|
||||
- Registry.rolePermissions(role string) map[string]bool (registry.go:451). FindByID merges those grants (auth.go:55).
|
||||
- guardOutranked(ctx, reg, editor, target) (backend_privileges.go:123) returns ForbiddenError Message "backend::lang.user.outranked"; needs TxFromContext; superuser and own record pass. actsAsSuperuser, effectiveGrants, grantsCovered stay unused on a new role code.
|
||||
- compileActionExtensions (action_extensions.go:23) copies each pact.AdminRecordAction into cc.RecordActions after checkContributedAction. CRUDService.RecordAction (crud.go:604-629) sets withTx, loadRecord FOR UPDATE, Applies, then action.Run. lifecycleFailure passes *ForbiddenError through, so a wrapper that returns guardOutranked's error is 403 like built-in deactivate.
|
||||
- AdministratorsControllerID = "summercms.cabana.users" (backend_screens.go:25).
|
||||
- Harness (administrators_harness_test.go): newScreensEnv, grantPlugin, pingPlugin / pingSpy, seedAdmin, seedRole, login, expectFieldRefusal, expectRefusal, roleRow, roleExists, enCodeLocked, enOutranked, pingPermission, manageUsers. TestRolesLifecycle already uses grantPlugin with a unique declared code that then gets a row; CR-01 needs a declared code with no row. TestAdministratorsOutranked seeds a delegate with PermissionManageUsers + pingPermission and a target whose role grants acme.demo.access. TestActionExtensionRun posts acme_ping and asserts spy.runs().
|
||||
- Gate: scripts/check-phase19.6.1.sh DOCKER_TESTS array (lines 67-84), consumed by go_named in run_docker.
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: End-to-end — refuse a Roles code-declared capture and wrap contributed Administrators Runs with guardOutranked</name>
|
||||
<precondition>Plans 01-03 are on disk and compiled: backend_roles_admin.go has FormBeforeCreate, FormBeforeUpdate, checkCode, and systemRole; action_extensions.go has compileActionExtensions; administrators_harness_test.go has newScreensEnv, grantPlugin, pingPlugin, expectFieldRefusal, expectRefusal, roleRow, enCodeLocked, and enOutranked.</precondition>
|
||||
<reversibility rating="reversible">Hook and wrapper changes behind existing Roles and RecordAction paths; no published symbol or on-disk format changes.</reversibility>
|
||||
<files>modules/cabana/backend_roles_admin.go, modules/cabana/action_extensions.go, modules/cabana/roles_postgres_test.go, modules/cabana/action_extensions_postgres_test.go</files>
|
||||
<read_first>modules/cabana/backend_roles_admin.go, modules/cabana/backend_privileges.go, modules/cabana/action_extensions.go, modules/cabana/roles_postgres_test.go, modules/cabana/action_extensions_postgres_test.go, modules/cabana/administrators_postgres_test.go, modules/cabana/administrators_harness_test.go, modules/cabana/crud.go, modules/pact/capabilities.go, scripts/check-phase19.6.1.sh, .planning/phases/19.6.1-backend-administrators-screen/19.6.1-VERIFICATION.md, .planning/phases/19.6.1-backend-administrators-screen/19.6.1-UI-SPEC.md</read_first>
|
||||
<action>Close G-19.6.1-1 (CR-01, SC-2, D-07, D-16) and G-19.6.1-2 (WR-03, D-19) in one production-quality slice, then prove both holes through the assembled handler on Postgres. Do not edit backend_privileges.go. Do not export guardOutranked. Do not add a phrase key.
|
||||
|
||||
Roles (backend_roles_admin.go), per D-16 stricter reading and D-07: add a helper on rolesAdmin that takes the submitted role and the stored code (empty string on create). When the submitted code is not the stored code and len(c.registry().rolePermissions(submitted code)) is greater than 0, return a ValidationError with Details code listing rolesLang + "code_locked" (the same 422 shape FormBeforeUpdate already uses for a stored system role). Call it from FormBeforeCreate after asRole and before or after checkCode. Call it from FormBeforeUpdate after the stored-row read, using stored.Code, in addition to the existing systemRole(stored.IsSystem, stored.Code) refusal. Keep checkCode uniqueness. A keep-the-same-code save of a system role still reaches 200. Superusers are refused the same way: a role never becomes a code-declared system role through this screen.
|
||||
|
||||
Seam (action_extensions.go), per D-19: after checkContributedAction succeeds and before the action is stored on cc.RecordActions, when ext.Controller equals AdministratorsControllerID, replace action.Run with wrapAdministratorsContributedRun(reg, action.Run). wrapAdministratorsContributedRun returns a func(ctx, pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error) that: reads the principal with bouncer.User(ctx); type-asserts in.Record to a BackendUser pointer; if the assert fails or the pointer is nil, returns an error that names Administrators and does not call next; otherwise calls guardOutranked(ctx, reg, principal, user) and, on a non-nil error, returns that error without calling next; on nil, returns next(ctx, in). The wrap runs inside CRUDService.RecordAction's transaction (withTx already set, row locked) so guardOutranked sees TxFromContext. Contributions to any other controller ID are stored unchanged. Applies is not wrapped.
|
||||
|
||||
TestRolesCodeDeclaredCodeRefused in roles_postgres_test.go (package cabana_test): newScreensEnv with a grantPlugin whose pact.Permission.Roles names a unique code that has no backend_user_roles row (the CR-01 precondition). Seed a non-superuser editor whose role grants only PermissionManageRoles, and a mutable role that editor may edit. PUT of that role with code set to the declared code answers 422, details.code carries enCodeLocked, and roleRow is unchanged. POST to rolesPath with a new name and the declared code answers 422, details.code carries enCodeLocked, and no row with that code exists (roleExists / count). A superuser PUT or POST onto the same declared code is also 422 with the row unchanged. A unique non-declared code still creates (201) and a same-code update of a system role still saves, so TestRolesLifecycle stays valid.
|
||||
|
||||
TestActionExtensionOutranked in action_extensions_postgres_test.go (package cabana_test): newScreensEnv (pingPlugin already contributes acme_ping). Seed a delegate with RolePermissions PermissionManageUsers plus pingPermission (same shape as TestAdministratorsOutranked) and an outranking target whose role grants acme.demo.access. POST userURL(target.ID, "actions", "acme_ping") as the delegate answers 403, expectRefusal with enOutranked, and spy.runs() is empty. Built-in deactivate on that target still answers 403 enOutranked. A covered target (no extra grant) still runs acme_ping (200, spy records that id, TxFromContext true), so TestActionExtensionRun is not weakened.
|
||||
|
||||
Reuse expectFieldRefusal, expectRefusal, roleRow, roleBody, roleURL, seedAdmin, seedRole, grantPlugin, enCodeLocked, enOutranked. Unique names from env.stamp / nanosecond. t.Cleanup deletes seeded roles and demotes/soft-deletes seeded admins. Tests name no consuming application.</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/cabana/... ./modules/pact/... ./modules/surf/...</automated>
|
||||
<fails_when>non-zero exit from vet or the short suite, or a compile error naming wrapAdministratorsContributedRun, FormBeforeCreate, or FormBeforeUpdate</fails_when>
|
||||
<automated>go test -count=1 -run '^(TestRolesCodeDeclaredCodeRefused|TestActionExtensionOutranked)$' -v ./modules/cabana 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2</automated>
|
||||
<fails_when>Fewer than 2 top-level "--- PASS: Test" lines: a new test failed, was renamed, or printed "--- SKIP" because Docker was unreachable (rerun through sudo -u golem, else NOT RUN)</fails_when>
|
||||
<automated>go test -count=1 -run '^(TestRolesLifecycle|TestRolesPermissionCeiling|TestActionExtensionRun)$' -v ./modules/cabana 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3</automated>
|
||||
<fails_when>Fewer than 3 top-level "--- PASS: Test" lines among the existing Roles and seam tests (failed, renamed, or skipped)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n 'func (c rolesAdmin) FormBeforeCreate' -A 20 modules/cabana/backend_roles_admin.go | grep -c 'rolePermissions('` prints at least 1, or FormBeforeCreate calls a helper whose body contains `rolePermissions(`.
|
||||
- `grep -n 'func (c rolesAdmin) FormBeforeUpdate' -A 30 modules/cabana/backend_roles_admin.go | grep -c 'rolePermissions('` prints at least 1, or FormBeforeUpdate calls that same helper with stored.Code.
|
||||
- `grep -c 'code_locked' modules/cabana/backend_roles_admin.go` prints at least 2 (stored system-role change and new-code capture).
|
||||
- `grep -c 'func wrapAdministratorsContributedRun(' modules/cabana/action_extensions.go` prints 1 and `grep -c 'guardOutranked(' modules/cabana/action_extensions.go` prints at least 1.
|
||||
- `grep -c 'AdministratorsControllerID' modules/cabana/action_extensions.go` prints at least 1.
|
||||
- `grep -c '^func TestRolesCodeDeclaredCodeRefused(' modules/cabana/roles_postgres_test.go` prints 1.
|
||||
- `grep -c '^func TestActionExtensionOutranked(' modules/cabana/action_extensions_postgres_test.go` prints 1.
|
||||
- `head -1 modules/cabana/roles_postgres_test.go` prints `package cabana_test` and `head -1 modules/cabana/action_extensions_postgres_test.go` prints `package cabana_test`.
|
||||
- `grep -ciE 'fonoteka|plytarium|grzyby|wavepath' modules/cabana/roles_postgres_test.go modules/cabana/action_extensions_postgres_test.go` prints 0 for each file.
|
||||
</acceptance_criteria>
|
||||
<done>A non-superuser cannot capture code-declared grants through a Roles create or rename, and a contributed acme_ping on an outranking Administrators target is 403 user.outranked with Run not called. Both paths are proven on Postgres.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Document the Administrators privilege rule on the D-14 seam</name>
|
||||
<reversibility rating="costly">Tightens the published pact.AdminActionExtension contract that 19.7's link action implements; undo is a docs revert plus any plugin that relied on the hole.</reversibility>
|
||||
<files>modules/pact/capabilities.go, modules/pact/README.md, modules/cabana/README.md, docs/backend/admin-controllers.md</files>
|
||||
<read_first>modules/pact/capabilities.go, modules/pact/README.md, modules/cabana/README.md, docs/backend/admin-controllers.md, modules/cabana/action_extensions.go, .planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md</read_first>
|
||||
<action>Per D-19 and D-18 (docs in the same change as the exported-API comment). After Task 1's wrap exists, state the Administrators privilege rule in four places. Do not name a consuming application. Do not say contributors apply the check.
|
||||
|
||||
modules/pact/capabilities.go AdminActionExtension comment (currently lines 378-398): after the sentence that an administrator needs the target controller's RequiredPermissions and the action's own Permissions, add that when Controller is the admin's Administrators screen (summercms.cabana.users), cabana runs its outranking check inside the action transaction before the contributor's Run; a non-superuser whose grants do not cover the target's effective grants gets 403 with backend::lang.user.outranked and Run is not called. Keep the boot-error paragraph.
|
||||
|
||||
modules/pact/README.md API table: on the `pact.AdminActionExtension` row, append that a contribution to summercms.cabana.users is refused with user.outranked when the target outranks the caller. On the `pact.HasAdminActionExtensions` row, do not claim the contributor owns that authorization.
|
||||
|
||||
modules/cabana/README.md Features bullet that starts "Record actions on another plugin's controller": append one sentence that contributions targeting cabana.AdministratorsControllerID run guardOutranked before Run (403 user.outranked, Run not called).
|
||||
|
||||
docs/backend/admin-controllers.md section "Adding record actions to another controller": after the bullet that both RequiredPermissions and the action's Permissions apply, add a bullet that a contribution to summercms.cabana.users / cabana.AdministratorsControllerID is also refused with 403 user.outranked when the target administrator's effective grants are not a subset of the caller's, and that cabana applies this before Run so the contributor does not. Leave the src= example and the no-input sentence.
|
||||
|
||||
Every new identifier you name (AdministratorsControllerID, AdminActionExtension, user.outranked) already exists. After the edits, `go test ./cmd/summer -run TestDocsTree` and `go run ./cmd/summer docs:build --check` stay green.</action>
|
||||
<verify>
|
||||
<automated>go test -count=1 -run '^TestDocsTree$' -v ./cmd/summer 2>&1 | grep -q -- '^--- PASS: TestDocsTree'</automated>
|
||||
<fails_when>non-zero exit or no "--- PASS: TestDocsTree" line</fails_when>
|
||||
<automated>go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, or output contains "unknown identifier" or "broken link"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'user.outranked' modules/pact/capabilities.go` prints at least 1 and `grep -c 'summercms.cabana.users' modules/pact/capabilities.go` prints at least 1.
|
||||
- `grep -c 'user.outranked' modules/pact/README.md` prints at least 1.
|
||||
- `grep -c 'AdministratorsControllerID' modules/cabana/README.md` prints at least 1 and `grep -c 'user.outranked' modules/cabana/README.md` prints at least 1.
|
||||
- `grep -c 'user.outranked' docs/backend/admin-controllers.md` prints at least 1.
|
||||
- `grep -ciE 'fonoteka|plytarium|grzyby|wavepath' modules/pact/capabilities.go modules/pact/README.md modules/cabana/README.md docs/backend/admin-controllers.md` prints 0 for each file.
|
||||
</acceptance_criteria>
|
||||
<done>The published seam docs state that cabana, not the contributor, applies the Administrators outranking rule.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Require the two new Postgres tests in the phase gate</name>
|
||||
<reversibility rating="reversible">One array in a check script.</reversibility>
|
||||
<files>scripts/check-phase19.6.1.sh</files>
|
||||
<read_first>scripts/check-phase19.6.1.sh, modules/cabana/roles_postgres_test.go, modules/cabana/action_extensions_postgres_test.go</read_first>
|
||||
<action>Per D-18 and the gap missing items. In scripts/check-phase19.6.1.sh, add TestRolesCodeDeclaredCodeRefused and TestActionExtensionOutranked to the DOCKER_TESTS array next to TestRolesLifecycle / TestActionExtensionRun (the docker stage's go_named REQUIRE list). Do not add them to SHORT_TESTS (they need Postgres). Do not change detect_go, run_docker, or SC1_TESTS. After the edit, `grep -n 'DOCKER_TESTS' -A 20` shows both names, and `bash scripts/check-phase19.6.1.sh --docker` still fail-closes on a missing name.</action>
|
||||
<verify>
|
||||
<automated>grep -E 'TestRolesCodeDeclaredCodeRefused|TestActionExtensionOutranked' scripts/check-phase19.6.1.sh | grep -v '^#' | grep -c 'Test' | grep -qx 2</automated>
|
||||
<fails_when>the filtered count is not exactly 2: a name is missing, commented out, or duplicated</fails_when>
|
||||
<automated>bash scripts/check-phase19.6.1.sh --docker</automated>
|
||||
<fails_when>non-zero exit, or a line starting "refuse:", or detect_go reports a missing named test; a "NOT RUN docker" line is acceptable only when no Docker daemon answers and must be recorded in the SUMMARY</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'TestRolesCodeDeclaredCodeRefused' scripts/check-phase19.6.1.sh` prints at least 1.
|
||||
- `grep -c 'TestActionExtensionOutranked' scripts/check-phase19.6.1.sh` prints at least 1.
|
||||
- `awk '/^DOCKER_TESTS=/,/^)/' scripts/check-phase19.6.1.sh | grep -c 'TestRolesCodeDeclaredCodeRefused'` prints 1 and `awk '/^DOCKER_TESTS=/,/^)/' scripts/check-phase19.6.1.sh | grep -c 'TestActionExtensionOutranked'` prints 1.
|
||||
- `awk '/^SHORT_TESTS=/,/^)/' scripts/check-phase19.6.1.sh | grep -cE 'TestRolesCodeDeclaredCodeRefused|TestActionExtensionOutranked'` prints 0.
|
||||
</acceptance_criteria>
|
||||
<done>The phase gate refuses a tree that drops either new test by name.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| admin SPA / API client → cabana Roles and Administrators APIs | Request bodies (role code, record-action name) are untrusted; the principal comes from the JWT or personal token guard |
|
||||
| admin with backend.manage_roles → role codes that plugins attach grants to | A delegated editor can type any fillable code; code-declared grants attach by string |
|
||||
| contributing plugin → Administrators record-action Run | Plugin code runs inside the target's transaction behind the target's permission |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
Threat IDs continue after T-19.6.1-27 (plans 01-03). T-19.6.1-SC is reserved and kept.
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.6.1-28 | Elevation | rolesAdmin.FormBeforeUpdate submitted code | critical | mitigate | refuse when the new code has code-declared grants and differs from the stored code; 422 code_locked; row unchanged (CR-01 / SC-2 / D-07 / D-16) |
|
||||
| T-19.6.1-29 | Elevation | rolesAdmin.FormBeforeCreate submitted code | critical | mitigate | same refusal on create (stored code empty); 422 code_locked; no row inserted |
|
||||
| T-19.6.1-30 | Elevation | compileActionExtensions contributed Run on AdministratorsControllerID | critical | mitigate | wrapAdministratorsContributedRun calls guardOutranked inside the action transaction before next; 403 user.outranked; Run not called (WR-03 / D-19) |
|
||||
| T-19.6.1-31 | Elevation | wrap type assert of in.Record | high | mitigate | if the record is not a BackendUser pointer, return an error and do not call next |
|
||||
| T-19.6.1-SC | Tampering | npm/pip/cargo installs | high | mitigate | this plan installs no package; any install would need the package-legitimacy gate and a blocking human checkpoint |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- After Task 1: `go vet ./... && go test -count=1 -short ./modules/cabana/... ./modules/pact/... ./modules/surf/...`, then the two new named Postgres tests and the three existing Roles/seam tests listed in Task 1.
|
||||
- After Task 2: `go test -count=1 -run '^TestDocsTree$' ./cmd/summer` and `go run ./cmd/summer docs:build --check`.
|
||||
- After Task 3: `bash scripts/check-phase19.6.1.sh --docker` (reuse the verifier's cabana/gate command; NOT RUN only when Docker is unreachable).
|
||||
- Do not run Phase 19.6 fonoteka/user-plugin commands.
|
||||
- Manual visual SPA walk-through stays in VERIFICATION.md human_verification (out of scope).
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- A non-superuser holding backend.manage_roles cannot create or rename a role onto a code that pact.Permission.Roles attaches grants to; 422 user.role.code_locked; row unchanged.
|
||||
- A non-superuser holding backend.manage_users who posts a contributed record action at an outranking administrator gets 403 user.outranked and the contributor's Run is not called.
|
||||
- TestRolesCodeDeclaredCodeRefused and TestActionExtensionOutranked are in the gate DOCKER_TESTS REQUIRE list.
|
||||
- AdminActionExtension docs state the Administrators privilege rule. Plans 01-03 are untouched.
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-SUMMARY.md` when done
|
||||
</output>
|
||||
@@ -0,0 +1,181 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 04
|
||||
subsystem: auth
|
||||
tags: [cabana, roles, administrators, privilege-ceiling, pact, postgres]
|
||||
|
||||
requires:
|
||||
- phase: 19.6.1-01
|
||||
provides: Roles and Administrators hooks, compileActionExtensions, guardOutranked, AdministratorsControllerID
|
||||
- phase: 19.6.1-02
|
||||
provides: permission locks and the Roles form that still posts a fillable code
|
||||
- phase: 19.6.1-03
|
||||
provides: screensEnv harness, TestRolesLifecycle, TestActionExtensionRun, check-phase19.6.1.sh
|
||||
provides:
|
||||
- refuseCodeDeclaredCode on Roles create and update so a submitted code with code-declared grants is 422 user.role.code_locked
|
||||
- wrapAdministratorsContributedRun so cabana runs guardOutranked before a contributed Administrators Run
|
||||
- TestRolesCodeDeclaredCodeRefused and TestActionExtensionOutranked on Postgres
|
||||
- DOCKER_TESTS REQUIRE names for both tests
|
||||
- AdminActionExtension docs that cabana, not the contributor, owns the outranking check
|
||||
affects: [19.6.1 verify-work, 19.6 D-15, 19.7 link action on Administrators]
|
||||
|
||||
actuals:
|
||||
tokens: 6357
|
||||
tasks: 3
|
||||
commits: 4
|
||||
plan_head_before: 422bd1e01f4f3cb87252732eb273c14fbfcaa126
|
||||
plan_head_after: e62086084b9d509b05b1e1eea510390753fe0ed8
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Roles hooks consult rolePermissions of the submitted code, not only the stored one"
|
||||
- "compileActionExtensions wraps contributed Administrators Runs in cabana so guardOutranked runs inside the action transaction"
|
||||
|
||||
key-files:
|
||||
created: []
|
||||
modified:
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/action_extensions.go
|
||||
- modules/cabana/action_extensions_test.go
|
||||
- modules/cabana/roles_postgres_test.go
|
||||
- modules/cabana/action_extensions_postgres_test.go
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/README.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- scripts/check-phase19.6.1.sh
|
||||
|
||||
key-decisions:
|
||||
- "Roles create and update refuse any new code that rolePermissions attaches grants to, including when the editor is a superuser"
|
||||
- "cabana wraps contributed Administrators Runs; guardOutranked stays unexported and contributors do not own the check"
|
||||
|
||||
patterns-established:
|
||||
- "A code-declared system role cannot be created or captured through the Roles screen; 422 code_locked leaves the row unchanged"
|
||||
- "A contribution to summercms.cabana.users is 403 user.outranked when the target outranks the caller, before Run"
|
||||
|
||||
requirements-completed: [SC-2, D-07, D-16, D-19]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Roles create and rename refuse a code that pact.Permission.Roles attaches grants to (CR-01 / G-19.6.1-1)"
|
||||
requirement: "D-16"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/roles_postgres_test.go#TestRolesCodeDeclaredCodeRefused"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Contributed Administrators record actions run guardOutranked before Run (WR-03 / G-19.6.1-2)"
|
||||
requirement: "D-19"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/action_extensions_postgres_test.go#TestActionExtensionOutranked"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Phase docker gate REQUIREs both new Postgres tests by name"
|
||||
requirement: "D-18"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase19.6.1.sh --docker"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "AdminActionExtension docs state that cabana applies user.outranked before Run"
|
||||
requirement: "D-19"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "cmd/summer#TestDocsTree"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "go run ./cmd/summer docs:build --check"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: 18 min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6.1 Plan 04: Gap closure CR-01 and WR-03 Summary
|
||||
|
||||
**Roles create/rename cannot capture a code-declared code; cabana wraps contributed Administrators Runs with guardOutranked before the contributor runs**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 18 min
|
||||
- **Started:** 2026-10-22T11:18:00Z
|
||||
- **Completed:** 2026-10-22T11:36:05Z
|
||||
- **Tasks:** 3
|
||||
- **Files modified:** 10
|
||||
|
||||
## Accomplishments
|
||||
- `refuseCodeDeclaredCode` on Roles create and update: a submitted code with code-declared grants is 422 `user.role.code_locked`, including for a superuser; a same-code save of a system role still succeeds
|
||||
- `wrapAdministratorsContributedRun` in `compileActionExtensions`: a contribution to `AdministratorsControllerID` is 403 `user.outranked` when the target outranks the caller, and Run is not called
|
||||
- `TestRolesCodeDeclaredCodeRefused` and `TestActionExtensionOutranked` are in `DOCKER_TESTS`; `scripts/check-phase19.6.1.sh --docker` passed
|
||||
- pact/cabana/docs state that cabana, not the contributor, applies the Administrators outranking rule
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: refuse a Roles code-declared capture and wrap contributed Administrators Runs** - `068adaa` (fix)
|
||||
2. **Task 2: Document the Administrators privilege rule on the D-14 seam** - `cb460b6` (docs)
|
||||
3. **Task 3: Require the two new Postgres tests in the phase gate** - `e620860` (chore)
|
||||
|
||||
**Plan metadata:** (this commit) (docs: complete plan)
|
||||
|
||||
## Files Created/Modified
|
||||
- `modules/cabana/backend_roles_admin.go` - `refuseCodeDeclaredCode` on create and update
|
||||
- `modules/cabana/action_extensions.go` - wrap contributed Administrators Runs with `guardOutranked`
|
||||
- `modules/cabana/action_extensions_test.go` - boot smoke still compiles a superuser principal
|
||||
- `modules/cabana/roles_postgres_test.go` - `TestRolesCodeDeclaredCodeRefused`
|
||||
- `modules/cabana/action_extensions_postgres_test.go` - `TestActionExtensionOutranked`
|
||||
- `modules/pact/capabilities.go` - AdminActionExtension comment names `user.outranked`
|
||||
- `modules/pact/README.md` - contribution to `summercms.cabana.users` is refused when the target outranks the caller
|
||||
- `modules/cabana/README.md` - contributions targeting `AdministratorsControllerID` run `guardOutranked` before Run
|
||||
- `docs/backend/admin-controllers.md` - cabana applies the outranking check before Run
|
||||
- `scripts/check-phase19.6.1.sh` - DOCKER_TESTS REQUIRE both new names
|
||||
|
||||
## Decisions Made
|
||||
- Roles create and update refuse any new code that `rolePermissions` attaches grants to, including when the editor is a superuser
|
||||
- cabana wraps contributed Administrators Runs; `guardOutranked` stays unexported and contributors do not own the check
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Safe resume] Interrupted executor left SUMMARY unwritten**
|
||||
- **Found during:** Orchestrator resume after the Task spawn was cut off
|
||||
- **Issue:** Tasks 1–2 were committed (`068adaa`, `cb460b6`) and the Task 3 gate-script edit was uncommitted; no SUMMARY existed. Re-dispatch would duplicate the privilege fixes.
|
||||
- **Fix:** Closed out Task 3 and this SUMMARY on the main tree instead of spawning a second executor
|
||||
- **Files modified:** `scripts/check-phase19.6.1.sh`, this SUMMARY
|
||||
- **Verification:** named Postgres tests, docs checker, and `check-phase19.6.1.sh --docker` all passed
|
||||
- **Committed in:** `e620860` (Task 3) and the metadata commit
|
||||
|
||||
**2. [Plan files] `action_extensions_test.go` needed a superuser principal**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** wrapping Administrators Runs made the existing boot smoke fail unless the compile-time principal is a superuser
|
||||
- **Fix:** keep the boot smoke callable with a superuser principal (noted in the Task 1 commit body)
|
||||
- **Files modified:** `modules/cabana/action_extensions_test.go`
|
||||
- **Verification:** `go test -short ./modules/cabana/...` passed
|
||||
- **Committed in:** `068adaa` (Task 1)
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 2 auto-fixed (safe resume, boot-smoke principal)
|
||||
**Impact on plan:** No scope change. CR-01 and WR-03 shipped as specified.
|
||||
|
||||
## Issues Encountered
|
||||
The first executor spawn was interrupted after Tasks 1–2 committed. Close-out completed Task 3 and this SUMMARY without re-applying the hook/wrap changes.
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
Phase 19.6.1 gap closure is on disk. Ready for phase verification / UAT re-check of G-19.6.1-1 and G-19.6.1-2.
|
||||
|
||||
---
|
||||
*Phase: 19.6.1-backend-administrators-screen*
|
||||
*Completed: 2026-10-22*
|
||||
@@ -0,0 +1,247 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 05
|
||||
type: execute
|
||||
wave: 5
|
||||
depends_on: ["19.6.1-01", "19.6.1-02", "19.6.1-03", "19.6.1-04"]
|
||||
files_modified:
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/components/form/fields/RelationField.vue
|
||||
- admin/tests/form/RelationField.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
- modules/boardwalk/dist
|
||||
autonomous: true
|
||||
gap_closure: true
|
||||
gap_ids: [G-19.6.1-T2]
|
||||
requirements: []
|
||||
|
||||
estimate:
|
||||
tokens: 35000
|
||||
raw_tokens: 35000
|
||||
tasks: 2
|
||||
confidence: high
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "G-19.6.1-T2: After picking a relation option on a tabbed form, switching tabs and coming back still shows that option's name, not String(id)."
|
||||
- "A remounted RelationField seeds its id→label cache from the form's remembered labels, not only from the server meta.labels captured at load."
|
||||
- "modules/boardwalk/dist matches a fresh admin build so the embedded SPA used by the local demo carries the fix."
|
||||
artifacts:
|
||||
- path: "admin/src/components/form/formContext.ts"
|
||||
provides: "FORM_REMEMBER_LABEL injection key"
|
||||
contains: "FORM_REMEMBER_LABEL"
|
||||
- path: "admin/src/views/FormView.vue"
|
||||
provides: "FormView persists picked relation labels on the labels ref"
|
||||
contains: "FORM_REMEMBER_LABEL"
|
||||
- path: "admin/src/components/form/fields/RelationField.vue"
|
||||
provides: "choose() remembers the picked option on the form before emit"
|
||||
contains: "rememberLabel"
|
||||
- path: "admin/tests/form/FormView.test.ts"
|
||||
provides: "tab-switch backstop for a picked relation label"
|
||||
contains: "keeps a picked relation label after switching tabs"
|
||||
- path: "admin/tests/form/RelationField.test.ts"
|
||||
provides: "unit backstop: remount with remembered labels shows the name"
|
||||
contains: "shows a picked label after remount when the form remembered it"
|
||||
- path: "modules/boardwalk/dist"
|
||||
provides: "embedded admin build includes the remount-safe labels"
|
||||
contains: "index.html"
|
||||
key_links:
|
||||
- from: "admin/src/components/form/fields/RelationField.vue"
|
||||
to: "admin/src/components/form/formContext.ts"
|
||||
via: "choose injects FORM_REMEMBER_LABEL and writes the picked option before update:modelValue"
|
||||
pattern: "FORM_REMEMBER_LABEL"
|
||||
- from: "admin/src/views/FormView.vue"
|
||||
to: "admin/src/components/form/fields/RelationField.vue"
|
||||
via: "remembered labels flow back as props.labels so remount's watch seeds known"
|
||||
pattern: "rememberRelationLabel"
|
||||
prohibitions:
|
||||
- statement: "Do not keep inactive tab panels mounted with v-show (or otherwise render every tab's fields). That would change trigger hide-tab, ML locale reset, and field mount cost. Persist labels; keep the current one-panel FormGrid."
|
||||
status: unresolved
|
||||
verification: grep
|
||||
- statement: "Do not edit 19.6.1-01/02/03/04-PLAN.md. Do not change cabana Go, pact, phrasebook, YAML screens, or OpenAPI. No new npm dependency."
|
||||
status: unresolved
|
||||
verification: grep
|
||||
- statement: "Framework code, READMEs, docs and tests name no consuming application."
|
||||
status: unresolved
|
||||
verification: grep
|
||||
---
|
||||
|
||||
## Phase Goal
|
||||
|
||||
ROADMAP Goal (not a user story; MVP mode off): cabana gets WinterCMS's Administrators screens with privilege rules on the server.
|
||||
|
||||
This plan's slice (plan 5 of 5, wave 5, gap_closure): close UAT gap G-19.6.1-T2 (test 2, minor). After picking a role (or any relation) on the Administrators form, switching to another tab and back shows the option name, not the raw id. Save already assigned the role; this is labeling only. Ignore CR-01 / WR-03 (closed by plan 04) and IN-01..IN-06.
|
||||
|
||||
## Why plan 04 did not close this
|
||||
|
||||
Plan 04 `gap_ids` were `[G-19.6.1-1, G-19.6.1-2]` from VERIFICATION.md review findings (CR-01 code-declared role capture, WR-03 contributed Run skip of guardOutranked). The dropdown issue lived only in `19.6.1-UAT.md` ## Gaps, had no `gap_id`, and VERIFICATION.md called it "not a gap-closure item and not a failed must-have". Plan 04 also prohibited SPA changes. `--gaps-only` therefore never selected this truth.
|
||||
|
||||
## Spec-less probe fallback
|
||||
|
||||
Spec-less probe fallback skipped: phase has no requirement IDs to probe (visible skip). Edge row is the UAT diagnosis already on disk.
|
||||
|
||||
## Discovery
|
||||
|
||||
Level 0: existing RelationField `known` cache, FormView `labels` ref, FormView `panelFields` (active tab only). No new dependency.
|
||||
|
||||
## Decisions taken in this plan
|
||||
|
||||
- Persist picked labels on the form. Do not v-show inactive tabs.
|
||||
- New inject `FORM_REMEMBER_LABEL`: `(field: string, option: RelationOption) => void`. FormView and RelationChildModal provide it. RelationField calls it from `choose` when `entry.value !== null` (single and multiple), using `entry.label` and `entry.locked`. A missing provider is a no-op (standalone mount, settings pages without labels).
|
||||
- FormView helper `rememberRelationLabel` merges the option into `labels.value[field]` by `value` (replace same id, append otherwise). `adopt()` still replaces labels from the server response on load/save.
|
||||
- RelationField's existing `watch(() => props.labels, remember, { immediate: true })` and `labelOf` stay. Remount seeds `known` from the updated `props.labels`.
|
||||
- Test names: `keeps a picked relation label after switching tabs` (FormView.test.ts) and `shows a picked label after remount when the form remembered it` (RelationField.test.ts).
|
||||
|
||||
## Source coverage (this gap plan)
|
||||
|
||||
| Source | Item | Plan | Status |
|
||||
|---|---|---|---|
|
||||
| UAT Gaps | G-19.6.1-T2 / test 2 role dropdown id after tab switch | 05 | COVERED |
|
||||
| VERIFICATION gaps | G-19.6.1-1 / CR-01 | 04 | COVERED (prior) |
|
||||
| VERIFICATION gaps | G-19.6.1-2 / WR-03 | 04 | COVERED (prior) |
|
||||
|
||||
## UI Considerations
|
||||
|
||||
No new tokens, colours, or components. The combobox already shows `labelOf(id)`. This plan only keeps that map populated across a tab remount.
|
||||
|
||||
| Category | Element | Status | Resolution |
|
||||
|----------|---------|--------|------------|
|
||||
| display | Relation single combobox after tab switch | covered | Form remembers the picked `{value,label}`; remount seeds `known` from `props.labels` |
|
||||
| display | Relation multiple chips after tab switch | covered | same remember path from `choose` |
|
||||
|
||||
## Artifacts this phase produces
|
||||
|
||||
- `FORM_REMEMBER_LABEL` in `formContext.ts`.
|
||||
- FormView + RelationChildModal providers; RelationField `choose` write.
|
||||
- Two vitest names above.
|
||||
- Rebuilt `modules/boardwalk/dist`.
|
||||
|
||||
<objective>
|
||||
Close G-19.6.1-T2: a picked relation option keeps its name when FormView unmounts the field on a tab switch and remounts it.
|
||||
|
||||
Purpose: UAT test 2 labeling. Save is already correct.
|
||||
Output: inject + two providers + choose() write, two vitest names, rebuilt boardwalk dist. No Go/pact/YAML. Skip git commit (orchestrator commits). Skip STATE.md raw edits.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-UAT.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-VERIFICATION.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-PLAN.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-SUMMARY.md
|
||||
|
||||
Concurrency and commits: other sessions may touch admin/ or boardwalk/dist. Before each task run `git status --porcelain -- admin modules/boardwalk/dist` and stop if a file this task edits carries someone else's uncommitted change. Stage by explicit path, never `git add -A`; leave STATE.md and state.json alone; no co-author tags. The orchestrator commits after the checker — do not git commit from this plan.
|
||||
|
||||
<interfaces>
|
||||
- RelationField.vue: `known` Record<number,string> seeded by `watch(() => props.labels, remember, { immediate: true })`. `labelOf(id)` is `known[id] ?? String(id)`. `choose(entry)` emits `update:modelValue` (id or null, or appended ids in multiple) and `closeList()`. It does not write back to the parent labels today.
|
||||
- FormView.vue: `labels` ref assigned in `adopt()` from `record.meta.labels`. `panelFields` filters `tabOf(field) === activeTab`. One FormGrid, so inactive tab fields unmount. `update(name, value)` writes `values` only.
|
||||
- RelationChildModal.vue: own `labels` ref, `adopt(record, meta)`, FormGrid, same remount if the child form is tabbed.
|
||||
- formContext.ts: existing injects FORM_VALUES, FORM_PATCH, FIELD_SCOPE, FORM_TRIGGER_NOTES, FORM_FEEDBACK. Add FORM_REMEMBER_LABEL next to FIELD_SCOPE.
|
||||
- RelationOption: `{ label: string; locked?: boolean; value: number }` (schema.d.ts).
|
||||
- Fixtures: widgets.form-schema.json has `maker` (relation, default tab) and `serial` (text, tab Details). widgets.record.json has maker 2 / "Bolt & Co". optionsFixture.makerField has Acme Works (1) and Bolt & Co (2). FormView.test.ts already has `tab(wrapper, key)` in the D-21 describe; reuse that helper or a local copy. mountApp + mockApi as existing tests.
|
||||
- Dist: `npm --prefix admin run build` writes modules/boardwalk/dist; `scripts/check-admin-dist.sh` rebuilds into a temp dir and diffs.
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Persist picked relation labels across FormView tab remount</name>
|
||||
<precondition>admin/src/components/form/fields/RelationField.vue has choose() and labelOf(); FormView.vue has labels ref, adopt(), panelFields, and a single FormGrid; formContext.ts exports FIELD_SCOPE; admin/tests/form/FormView.test.ts and RelationField.test.ts exist; git status --porcelain -- admin is empty of other sessions' edits.</precondition>
|
||||
<reversibility rating="reversible">SPA-only inject and label merge; undo is a revert. No API or on-disk format change.</reversibility>
|
||||
<files>admin/src/components/form/formContext.ts, admin/src/views/FormView.vue, admin/src/components/relation/RelationChildModal.vue, admin/src/components/form/fields/RelationField.vue, admin/tests/form/RelationField.test.ts, admin/tests/form/FormView.test.ts</files>
|
||||
<read_first>admin/src/components/form/fields/RelationField.vue, admin/src/views/FormView.vue, admin/src/components/relation/RelationChildModal.vue, admin/src/components/form/formContext.ts, admin/src/components/form/FormGrid.vue, admin/tests/form/RelationField.test.ts, admin/tests/form/FormView.test.ts, admin/tests/fixtures/widgets.form-schema.json, admin/tests/fixtures/widgets.options.json, .planning/phases/19.6.1-backend-administrators-screen/19.6.1-UAT.md</read_first>
|
||||
<action>Close G-19.6.1-T2 in one production-quality slice. Do not v-show inactive tabs. Do not change Go, pact, YAML, or OpenAPI.
|
||||
|
||||
formContext.ts: export `FORM_REMEMBER_LABEL` as `InjectionKey<(field: string, option: RelationOption) => void>` (import RelationOption from api/types). Comment: form hosts persist a picked relation option so a remounted RelationField can seed its id→label cache from props.labels; a host without a provider is a no-op.
|
||||
|
||||
FormView.vue: add `rememberRelationLabel(field, option)` that copies `labels.value`, replaces or appends in `labels.value[field]` by option.value, and assigns the new object. provide(FORM_REMEMBER_LABEL, rememberRelationLabel) next to the other form provides. adopt() still overwrites labels from the server.
|
||||
|
||||
RelationChildModal.vue: the same helper against its `labels` ref and the same provide, so a tabbed child form does not regress.
|
||||
|
||||
RelationField.vue: inject FORM_REMEMBER_LABEL (default undefined). In choose(), when entry.value !== null, call rememberLabel?.(props.field.name, { value: entry.value, label: entry.label, locked: entry.locked || undefined }) before emit('update:modelValue', ...). Empty (null) choice does not remember. Do not change labelOf, remember(rows), or the props.labels watch.
|
||||
|
||||
Tests, no consuming-application names:
|
||||
|
||||
RelationField.test.ts: `shows a picked label after remount when the form remembered it`. Mount with maker, modelValue 2, labels Bolt & Co only, and provide FORM_REMEMBER_LABEL that records calls into a labels bag. Open the list (mockApi routes as existing), pick Acme Works (value 1). Expect the bag to contain { value: 1, label: 'Acme Works' }. Unmount. Mount again with modelValue 1 and labels from that bag (plus any previous). The combobox value is 'Acme Works', not '1'.
|
||||
|
||||
FormView.test.ts: `keeps a picked relation label after switching tabs`. mountApp on /acme/demo/widgets/1 with the widgets form schema (maker on the default tab, serial on Details) and GET maker options from optionsFixture.makerField. Combobox starts as Bolt & Co. Open it, pick Acme Works. Click the Details tab, then the first tab (same tab() pattern as the D-21 describe). The maker combobox value is 'Acme Works', not '1'. Do not assert save.
|
||||
|
||||
Existing RelationField and FormView tests stay green, including D-21 hide-tab backstops (those prove we did not switch to v-show of every panel).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>npm --prefix admin run test -- tests/form/RelationField.test.ts tests/form/FormView.test.ts</automated>
|
||||
<fails_when>non-zero exit, or either new it() name is missing from the run output</fails_when>
|
||||
<automated>npm --prefix admin run typecheck</automated>
|
||||
<fails_when>non-zero exit</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'FORM_REMEMBER_LABEL' admin/src/components/form/formContext.ts` prints at least 1.
|
||||
- `grep -c 'rememberRelationLabel\|FORM_REMEMBER_LABEL' admin/src/views/FormView.vue` prints at least 2.
|
||||
- `grep -c 'FORM_REMEMBER_LABEL' admin/src/components/relation/RelationChildModal.vue` prints at least 1.
|
||||
- `grep -n 'function choose' -A 20 admin/src/components/form/fields/RelationField.vue | grep -c 'rememberLabel'` prints at least 1.
|
||||
- `grep -c 'v-show' admin/src/views/FormView.vue` prints 0 (do not keep inactive panels mounted).
|
||||
- `grep -c 'keeps a picked relation label after switching tabs' admin/tests/form/FormView.test.ts` prints 1.
|
||||
- `grep -c 'shows a picked label after remount when the form remembered it' admin/tests/form/RelationField.test.ts` prints 1.
|
||||
- `grep -ciE 'fonoteka|plytarium|grzyby|wavepath' admin/src/components/form/formContext.ts admin/src/views/FormView.vue admin/src/components/form/fields/RelationField.vue admin/src/components/relation/RelationChildModal.vue admin/tests/form/RelationField.test.ts admin/tests/form/FormView.test.ts` prints 0 for each file.
|
||||
</acceptance_criteria>
|
||||
<done>Picking a relation option, switching tabs, and coming back shows the option name. Proven by the FormView tab-switch test and the RelationField remount test.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Rebuild the embedded admin dist</name>
|
||||
<precondition>Task 1 source is on disk; git status --porcelain -- modules/boardwalk/dist admin/src is only this plan's files or empty; admin/node_modules exists (never run npm ci).</precondition>
|
||||
<reversibility rating="reversible">Generated embed; undo is a dist revert.</reversibility>
|
||||
<files>modules/boardwalk/dist</files>
|
||||
<read_first>scripts/check-admin-dist.sh, admin/package.json</read_first>
|
||||
<action>Rebuild the committed SPA embed so the local demo binary (go.work → boardwalk) serves the remount-safe labels. Run `npm --prefix admin run build` (vue-tsc then vite into modules/boardwalk/dist with emptyOutDir). Run `scripts/check-admin-dist.sh`. Do not commit (orchestrator commits). Do not touch admin/src in this task.</action>
|
||||
<verify>
|
||||
<automated>scripts/check-admin-dist.sh && go test -short ./modules/boardwalk</automated>
|
||||
<fails_when>non-zero exit, or check-admin-dist reports stale dist</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `scripts/check-admin-dist.sh` exits 0 and prints that modules/boardwalk/dist matches a fresh build.
|
||||
- `test -f modules/boardwalk/dist/index.html` succeeds.
|
||||
</acceptance_criteria>
|
||||
<done>The embedded admin build matches the Task 1 SPA, so a `scripts/dev.sh` rebuild of sm-demo-app picks up the fix.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| admin SPA field → form labels ref | Picked option label is display-only; save still posts the id the combobox already emitted |
|
||||
| options API → remember() | Labels come from the same options payload the administrator already saw |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
Threat IDs continue after T-19.6.1-31.
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.6.1-32 | Tampering | FORM_REMEMBER_LABEL label string | low | accept | Display only; server still authorizes the posted id. Do not v-html the label (RelationField already interpolates text). |
|
||||
| T-19.6.1-SC | Tampering | npm/pip/cargo installs | high | mitigate | this plan installs no package |
|
||||
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- After Task 1: `npm --prefix admin run test -- tests/form/RelationField.test.ts tests/form/FormView.test.ts` and `npm --prefix admin run typecheck`.
|
||||
- After Task 2: `scripts/check-admin-dist.sh` and `go test -short ./modules/boardwalk`.
|
||||
- Do not run Phase 19.6 fonoteka/user-plugin commands.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- After picking a relation option on a tabbed form, switching tabs and back shows the option name, not String(id).
|
||||
- The two named vitest cases exist and pass.
|
||||
- modules/boardwalk/dist matches a fresh admin build.
|
||||
- Plans 01-04 are untouched. No Go/pact/YAML change.
|
||||
</success_criteria>
|
||||
@@ -0,0 +1,155 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
plan: 05
|
||||
subsystem: ui
|
||||
tags: [admin-spa, relation-field, form-labels, boardwalk]
|
||||
|
||||
requires:
|
||||
- phase: 19.6.1-01
|
||||
provides: Administrators and Roles screens compiled from YAML
|
||||
- phase: 19.6.1-02
|
||||
provides: privilege ceiling, permission locks, Roles form
|
||||
- phase: 19.6.1-03
|
||||
provides: lifecycle tests and phase gate
|
||||
- phase: 19.6.1-04
|
||||
provides: CR-01 / WR-03 gap closure
|
||||
provides:
|
||||
- FORM_REMEMBER_LABEL inject so form hosts persist a picked relation option
|
||||
- FormView and RelationChildModal merge picked labels into the labels ref
|
||||
- RelationField choose() writes the option before emit so a remount seeds known
|
||||
- Vitest names for remount and tab-switch labeling
|
||||
- Rebuilt modules/boardwalk/dist matching a fresh admin build
|
||||
affects: [19.6.1 UAT G-19.6.1-T2, embedded admin SPA]
|
||||
|
||||
actuals:
|
||||
tokens: 2966
|
||||
tasks: 2
|
||||
commits: 3
|
||||
plan_head_before: ba0501c2746e7ea22920701792990537c4729284
|
||||
plan_head_after: 51e1a1ea6ed3f5e5aa08d07210452bf3e6622f8a
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Form hosts persist picked RelationOption rows on the labels ref; remount seeds known from props.labels"
|
||||
|
||||
key-files:
|
||||
created: []
|
||||
modified:
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/components/form/fields/RelationField.vue
|
||||
- admin/tests/form/RelationField.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
- modules/boardwalk/dist
|
||||
|
||||
key-decisions:
|
||||
- "Persist picked relation labels on the form via FORM_REMEMBER_LABEL; keep the one-panel FormGrid (do not v-show inactive tabs)"
|
||||
|
||||
patterns-established:
|
||||
- "A remounted RelationField reads remembered labels from props.labels, not only server meta.labels from load"
|
||||
|
||||
requirements-completed: []
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "After picking a relation option on a tabbed form, switching tabs and coming back shows the option name, not String(id)"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "admin/tests/form/FormView.test.ts#keeps a picked relation label after switching tabs"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "admin/tests/form/RelationField.test.ts#shows a picked label after remount when the form remembered it"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "modules/boardwalk/dist matches a fresh admin build so the embedded SPA carries the remount-safe labels"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "scripts/check-admin-dist.sh"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "go test -short ./modules/boardwalk"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: 4min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.6.1 Plan 05: Persist relation labels across tab remount Summary
|
||||
|
||||
**Picked relation option names persist across FormView tab remount via FORM_REMEMBER_LABEL**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 4 min
|
||||
- **Started:** 2026-10-22T12:38:22Z
|
||||
- **Completed:** 2026-10-22T12:42:52Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 7
|
||||
|
||||
## Accomplishments
|
||||
- Form hosts persist a picked relation option on the labels ref so a remounted RelationField seeds its id→label cache from props.labels
|
||||
- RelationField `choose()` writes `{value,label,locked}` through `FORM_REMEMBER_LABEL` before emit; empty (null) choice does not remember
|
||||
- Two named vitest cases prove remount and tab-switch labeling; inactive tabs stay unmounted
|
||||
- Embedded `modules/boardwalk/dist` rebuilt and matched a fresh admin build
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: Persist picked relation labels across FormView tab remount** - `14baafb` (feat)
|
||||
2. **Task 2: Rebuild the embedded admin dist** - `51e1a1e` (chore)
|
||||
|
||||
**Plan metadata:** recorded after this file is committed.
|
||||
|
||||
_Note: `git rev-list` from `plan_head_before` to HEAD counted 3 commits because a concurrent `docs(19.7)` commit landed between the two task commits. This plan authored 2 production commits._
|
||||
|
||||
## Files Created/Modified
|
||||
- `admin/src/components/form/formContext.ts` - exports `FORM_REMEMBER_LABEL`
|
||||
- `admin/src/views/FormView.vue` - `rememberRelationLabel` + provide; `adopt()` still replaces labels from the server
|
||||
- `admin/src/components/relation/RelationChildModal.vue` - same helper and provide for a tabbed child form
|
||||
- `admin/src/components/form/fields/RelationField.vue` - `choose()` remembers a non-null option before emit
|
||||
- `admin/tests/form/RelationField.test.ts` - remount backstop for a remembered label
|
||||
- `admin/tests/form/FormView.test.ts` - tab-switch backstop for a picked maker label
|
||||
- `modules/boardwalk/dist` - rebuilt embed (`index-BtP5LUQA.js` replaces `index-D7ALzCHi.js`; editor hash rename)
|
||||
|
||||
## Decisions Made
|
||||
- Persist picked labels on the form via `FORM_REMEMBER_LABEL`. Do not keep inactive tab panels mounted with `v-show`.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None - plan executed exactly as written.
|
||||
|
||||
**Total deviations:** 0 auto-fixed
|
||||
**Impact on plan:** None.
|
||||
|
||||
## Issues Encountered
|
||||
- A concurrent session committed `d47d618` (`docs(19.7): create phase plans`) between Task 1 and Task 2. Measured `commits:` is 3; this plan's production commits are `14baafb` and `51e1a1e`. Old hashed dist assets were deleted as part of the Vite rebuild (intentional).
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- G-19.6.1-T2 is closed in the SPA and the embedded dist. Phase 19.6.1 plans 01–05 are complete; ready for verify-work / UAT recheck of test 2.
|
||||
- No blockers. Plans 01–04 were not edited. No Go, pact, YAML, or OpenAPI change.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: admin/src/components/form/formContext.ts
|
||||
- FOUND: admin/src/views/FormView.vue
|
||||
- FOUND: admin/src/components/relation/RelationChildModal.vue
|
||||
- FOUND: admin/src/components/form/fields/RelationField.vue
|
||||
- FOUND: admin/tests/form/RelationField.test.ts
|
||||
- FOUND: admin/tests/form/FormView.test.ts
|
||||
- FOUND: modules/boardwalk/dist/index.html
|
||||
- FOUND: 14baafb
|
||||
- FOUND: 51e1a1e
|
||||
|
||||
---
|
||||
*Phase: 19.6.1-backend-administrators-screen*
|
||||
*Completed: 2026-10-22*
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
phase: 19.6.1
|
||||
review: 19.6.1-REVIEW.md
|
||||
titles: json
|
||||
findings:
|
||||
- id: CR-01
|
||||
severity: critical
|
||||
disposition: fixed
|
||||
title: "Roles screen lets a non-superuser rename or create a role onto a code with code-declared grants (D-07 ceiling bypass, self-escalation)"
|
||||
- id: WR-01
|
||||
severity: warning
|
||||
disposition: open
|
||||
title: "D-07/D-19 ceilings ignore a scoped personal API token's scope"
|
||||
- id: WR-02
|
||||
severity: warning
|
||||
disposition: open
|
||||
title: "Stored override values other than 1/-1 are dropped on every save, re-granting what they removed"
|
||||
- id: WR-03
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "Record actions contributed to the Administrators screen bypass D-19 (outranking) and D-09 (last superuser)"
|
||||
- id: IN-01
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "Last-superuser guard silently depends on READ COMMITTED"
|
||||
- id: IN-02
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "Re-deleting a soft-deleted administrator reports success and bumps tokens"
|
||||
- id: IN-03
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "Role code uniqueness is a check-then-insert without a lock"
|
||||
- id: IN-04
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "Role delete counts holders without locking against concurrent assignment"
|
||||
- id: IN-05
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "`toggleOn` reads unknown switch encodings as \"off\""
|
||||
- id: IN-06
|
||||
severity: info
|
||||
disposition: open
|
||||
title: "Role picker on your own record is editable in the SPA but always refused"
|
||||
open: 8
|
||||
total: 10
|
||||
recorded: 2026-10-22T11:50:00.000Z
|
||||
---
|
||||
|
||||
# Phase 19.6.1: Code Review Disposition
|
||||
|
||||
| Finding | Severity | Disposition | Source |
|
||||
|---------|----------|-------------|--------|
|
||||
| CR-01 | critical | fixed | 19.6.1-04 refuseCodeDeclaredCode |
|
||||
| WR-01 | warning | open | - |
|
||||
| WR-02 | warning | open | - |
|
||||
| WR-03 | warning | fixed | 19.6.1-04 wrapAdministratorsContributedRun (D-19). D-09 on contributed Run stays out of the gap plan |
|
||||
| IN-01 | info | open | - |
|
||||
| IN-02 | info | open | - |
|
||||
| IN-03 | info | open | - |
|
||||
| IN-04 | info | open | - |
|
||||
| IN-05 | info | open | - |
|
||||
| IN-06 | info | open | - |
|
||||
|
||||
Dispositions: `open` (recorded, not yet triaged), `fixed`, `skipped`, `deferred`.
|
||||
Set `deferred` by hand and put the reason in the Source cell; both are preserved. A `|` in the reason is kept as prose and escaped on the next run.
|
||||
Re-running the gate keeps every row it can. A row the current review no longer reports is kept and its Source cell flagged, so a finding does not leave this record silently. ONE exception: when a finding id is REUSED by a different finding, the earlier decision cannot keep a row — the id is taken — and it is dropped. A RECORDED decision (anything but `open`) is named on the console when that happens; a row still at `open` is replaced silently, because `open` records no decision to lose.
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
reviewed: 2026-10-22T12:51:21Z
|
||||
depth: standard
|
||||
files_reviewed: 6
|
||||
files_reviewed_list:
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/components/form/fields/RelationField.vue
|
||||
- admin/tests/form/RelationField.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
findings:
|
||||
critical: 0
|
||||
warning: 0
|
||||
info: 0
|
||||
total: 0
|
||||
status: clean
|
||||
gap_closure:
|
||||
reviewed: 2026-10-22T12:51:21Z
|
||||
depth: standard
|
||||
plan: "05"
|
||||
prior_review: d7dc2a3
|
||||
files_reviewed: 6
|
||||
files_reviewed_list:
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/components/form/fields/RelationField.vue
|
||||
- admin/tests/form/RelationField.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
findings:
|
||||
critical: 0
|
||||
warning: 0
|
||||
info: 0
|
||||
nice_to_have: 0
|
||||
total: 0
|
||||
status: clean
|
||||
---
|
||||
|
||||
# Phase 19.6.1: Code Review Report
|
||||
|
||||
**Reviewed:** 2026-10-22T12:51:21Z
|
||||
**Depth:** standard
|
||||
**Files Reviewed:** 6
|
||||
**Status:** clean
|
||||
|
||||
Wave-scoped incremental review of plan 05 (gap closure G-19.6.1-T2) after `d7dc2a3`. This file replaces the plans 01–04 review text; open findings from that pass stay on `19.6.1-REVIEW-DISPOSITION.md`. Concurrent settings-panel work and generated `modules/boardwalk/dist` were not reviewed (the dist was rebuilt in `51e1a1e`).
|
||||
|
||||
## Summary
|
||||
|
||||
Plan 05 persists a picked relation option on the form host so a remounted `RelationField` can seed its id→label cache from `props.labels` after FormView unmounts inactive tab panels. The inject, both providers, `choose()` write, and the two named vitest cases match that contract. Inactive tabs stay unmounted (`v-show` is absent). Labels are display-only text interpolation; save still posts the id.
|
||||
|
||||
Traced path: `choose()` writes `{value,label}` through `FORM_REMEMBER_LABEL` before `update:modelValue`; `rememberRelationLabel` replaces or appends by `option.value` on a new `labels` object; `FormGrid` looks up `labels[field.name]`; remount's `watch(() => props.labels, remember, { immediate: true })` fills `known`; `labelOf` then returns the name. `adopt()` still replaces labels from the server on load/save. A missing provider is a no-op. The child modal shadows the record form's provider so a tabbed child writes its own `labels` ref.
|
||||
|
||||
All reviewed files meet quality standards. No issues found.
|
||||
|
||||
## Narrative Findings (AI reviewer)
|
||||
|
||||
No Critical, Warning, or Info findings.
|
||||
|
||||
`FORM_REMEMBER_LABEL` is a typed `InjectionKey` next to `FIELD_SCOPE`. `rememberRelationLabel` copies the field array and the labels record (no in-place mutation), so the shallow `props.labels` watch fires. Empty (`null`) choice does not remember. Locked options return before the write, so `locked: entry.locked || undefined` is always `undefined` on this path and does not clear a stored lock. `RelationChildModal` uses the same helper and provide; its `FormGrid` already receives `:labels="labels"`. Tests use the widgets fixture (`maker` on `default`, `serial` on `tab:Details`) and the same `tab()` / `mousedown` pattern as the D-21 backstops. No consuming-application names. No new dependency.
|
||||
|
||||
Prior findings WR-01, WR-02, and IN-01..IN-06 were out of this pass.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-22T12:51:21Z_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: standard_
|
||||
@@ -0,0 +1,113 @@
|
||||
---
|
||||
phase: "19.6.1"
|
||||
slug: "backend-administrators-screen"
|
||||
status: verified
|
||||
# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate)
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: "2026-10-22"
|
||||
---
|
||||
|
||||
# Phase 19.6.1 — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| admin SPA / API client → cabana admin API | Request bodies, ids, query filters, trigger/lock display state and relation labels are untrusted; the principal comes from the JWT or personal token guard | login/email/password, role code, permission maps, record-action names, virtual `is_superuser` |
|
||||
| admin with `backend.manage_users` / `backend.manage_roles` → other admins and role codes | A delegated, non-superuser administrator acts on accounts and roles that may hold more privilege, including codes plugins attach grants to | role_id, permissions, activation, password set, contributed record actions |
|
||||
| contributing plugin → Administrators record-action Run (D-14) | Plugin code runs inside the target's transaction behind the target's permission | `pact.AdminRecordActionInput.Record`, action name |
|
||||
| concurrent write transactions → last-superuser invariant | Two requests may reduce the superuser set at once | demote / deactivate / delete of an active superuser |
|
||||
| controller lock provider → record response | Lock notes and values come from plugin code and reach every viewer of the record | `meta.permissionLocks` |
|
||||
| plugin fields.yaml → boot compiler | A plugin's YAML may declare malformed triggers | `trigger` keys |
|
||||
| test suite → privilege rules | A rule without a named test can regress silently | status, body text, unchanged rows |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|----------|-------------|------------|--------|
|
||||
| T-19.6.1-01 | Elevation | generic CRUD fill of `is_superuser`, `role_id`, `permissions`, `is_activated`, `password` | high | mitigate | `protectedFillKey` in `modules/cabana/crud.go:1450` keeps them unfillable; only usersAdmin hooks, the radio editor and the WritableForeignKey role relation write them | closed |
|
||||
| T-19.6.1-02 | Elevation | FormBeforeCreate/Update virtual `is_superuser` | critical | mitigate | presence check on `VirtualFieldsFromContext` in `modules/cabana/backend_users_admin.go:731`; a non-superuser sending the key answers 403 `superuser_forbidden` | closed |
|
||||
| T-19.6.1-03 | Elevation | own record: role, superuser, permissions, activation | high | mitigate | `priorRoleID` snapshot compared in FormAfterUpdate; `AdminSetPermissionValues` self refusal; self checks on `is_superuser`, deactivate and delete (`backend_users_admin.go`) | closed |
|
||||
| T-19.6.1-04 | Elevation | permission editors and role picker | high | mitigate | `PermissionOption.Locked` and `RelationLockProvider` (`relation_field.go:74`); conservative `grantsCovered` (`backend_privileges.go:82`) | closed |
|
||||
| T-19.6.1-05 | Elevation | password set, deactivate, delete, actions on a higher-privileged admin | critical | mitigate | `guardOutranked` (`backend_privileges.go:123`) on update, delete, record and bulk actions; own-password refused with `own_password` (`backend_users_admin.go:800`); own password is My account + `current_password` (`account.go:341`) | closed |
|
||||
| T-19.6.1-06 | Denial of service | demote, deactivate, delete of the last active superuser | high | mitigate | `guardLastSuperuser` takes `pg_advisory_xact_lock` (`superuserLockKey` in `backend_privileges.go:18`) then counts other active superusers in the write tx | closed |
|
||||
| T-19.6.1-07 | Information disclosure | list, show, partials, filters for non-superusers | medium | mitigate | `ListExtendQuery` / `FormExtendQuery` (`backend_users_admin.go:153`) filter `backend_users.is_superuser`; `hiddenSchemaFields` drops the field, column and filter | closed |
|
||||
| T-19.6.1-08 | Elevation | superuser's scoped personal API token | high | mitigate | `actsAsSuperuser` requires `p.IsSuperuser` and unscoped or full token scope (`backend_privileges.go:24`) | closed |
|
||||
| T-19.6.1-09 | Elevation | contributed record actions (D-14) | high | mitigate | `protect()` checks the target's `RequiredPermissions` (`http.go:1161`); `compileContributions` (`registry.go:269`) validates contributed permissions at boot; run path is the existing row-locked RecordAction | closed |
|
||||
| T-19.6.1-10 | Tampering | contributed action names | medium | mitigate | boot error on reserved names, a name the owner or an earlier contributor registers, nil Run, empty label and unknown controller ID (`action_extensions.go:86`, `extension.go`) | closed |
|
||||
| T-19.6.1-11 | Spoofing | sessions after deactivate, delete, password set | high | mitigate | `tokens_valid_after = revocationCutoff()` (`backend_privileges.go:182`) on all three; `FindByID` refuses inactive and deleted users for personal tokens | closed |
|
||||
| T-19.6.1-12 | Spoofing | personal API tokens after a password set for another admin | medium | accept | same semantics as `admin:reset-password`; operator revokes with `admin:token:revoke` | closed |
|
||||
| T-19.6.1-13 | Tampering | unprojected `is_superuser` switch | high | mitigate | `extendRecordData` (`backend_users_admin.go:436`) projects the stored flag so an untouched save never demotes | closed |
|
||||
| T-19.6.1-14 | Elevation | upgrade of existing installs | medium | mitigate | `backend.manage_users` and `backend.manage_roles` declared with no `Roles` grants (`backend_screens.go:80`); only superusers reach the screens until a grant is made | closed |
|
||||
| T-19.6.1-15 | Denial of service | role delete with holders | low | mitigate | unscoped holder count refuses with 403 `delete_has_users` before the FK would fail (`backend_roles_admin.go:247`) | closed |
|
||||
| T-19.6.1-16 | Information disclosure | login/email collision messages revealing deleted accounts | low | accept | only holders of `backend.manage_users` see them, and they can list deleted admins anyway | closed |
|
||||
| T-19.6.1-17 | Denial of service | oversized passwords | low | mitigate | 72-byte cap before bcrypt, min 4, confirmation (`storePassword` in `backend_users_admin.go:857`, `passwordMaxBytes` in `account.go:47`) | closed |
|
||||
| T-19.6.1-18 | Elevation | trigger-disabled permission overrides | medium | mitigate | a disabled field is omitted from the save body; the server keeps stored values; superusers bypass overrides; no server rule depends on the trigger | closed |
|
||||
| T-19.6.1-19 | Elevation | record-locked codes in a hand-crafted save body | high | mitigate | `applyPermissionValues` (`field_permission.go:291`) refuses a present record-locked value that differs from the stored one (403) and carries the stored value otherwise; D-08 `AdminSetPermissionValues` refusal stays | closed |
|
||||
| T-19.6.1-20 | Information disclosure | `meta.permissionLocks` | low | accept | sent only on show and save responses behind `protect()` to admins who may open the record; it repeats codes the permission editor already shows | closed |
|
||||
| T-19.6.1-21 | Tampering | malformed trigger YAML | low | mitigate | `compileTrigger` and `checkTriggers` (`field_trigger.go:28`) stop boot with errors naming controller, field and key | closed |
|
||||
| T-19.6.1-22 | Tampering | stale committed SPA build or OpenAPI | medium | mitigate | `check-admin-openapi.sh --check` and `check-admin-dist.sh` in plan 02 verify; dist rebuilt from the committed lockfile | closed |
|
||||
| T-19.6.1-23 | Tampering | note text injected into markup | medium | mitigate | notes render by Vue text interpolation only; no `v-html` in PermissionEditorField, FormField, FormView, RelationField or RelationChildModal | closed |
|
||||
| T-19.6.1-24 | Repudiation | privilege regressions (D-05..D-09, D-19, D-20) going unnoticed | high | mitigate | one named test per rule; `scripts/check-phase19.6.1.sh` requires every name and refuses skipped or zero-match runs | closed |
|
||||
| T-19.6.1-25 | Denial of service | a deadlock in the last-superuser guard hidden by a flaky race | high | mitigate | held-lock race in `administrators_lifecycle_postgres_test.go` waits for two `pg_locks` waiters before releasing; unsynchronized rounds assert no 500 or deadlock | closed |
|
||||
| T-19.6.1-26 | Tampering | cross-test interference through shared superuser rows | medium | mitigate | `isolateSuperusers` (`administrators_harness_test.go:340`) plus per-test unique rows and cleanup; no `t.Parallel` in the package | closed |
|
||||
| T-19.6.1-27 | Information disclosure | tests or fixtures naming consuming applications | low | mitigate | the gate's docs stage name check and the plan 03 acceptance greps | closed |
|
||||
| T-19.6.1-28 | Elevation | `rolesAdmin.FormBeforeUpdate` submitted code | critical | mitigate | `refuseCodeDeclaredCode` (`backend_roles_admin.go:162`) on update; 422 `code_locked`; row unchanged | closed |
|
||||
| T-19.6.1-29 | Elevation | `rolesAdmin.FormBeforeCreate` submitted code | critical | mitigate | same refusal on create (`FormBeforeCreate` at `backend_roles_admin.go:175`); 422 `code_locked`; no row inserted | closed |
|
||||
| T-19.6.1-30 | Elevation | compileActionExtensions contributed Run on AdministratorsControllerID | critical | mitigate | `wrapAdministratorsContributedRun` (`action_extensions.go:108`) calls `guardOutranked` inside the action transaction before `next`; 403 `user.outranked`; Run not called | closed |
|
||||
| T-19.6.1-31 | Elevation | wrap type assert of `in.Record` | high | mitigate | if the record is not a `*BackendUser`, return an error and do not call `next` (`action_extensions.go:111`) | closed |
|
||||
| T-19.6.1-32 | Tampering | `FORM_REMEMBER_LABEL` label string | low | accept | display only; server still authorizes the posted id; RelationField interpolates text (no `v-html`) | closed |
|
||||
| T-19.6.1-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package added; plan 02 `npm --prefix admin ci` installs only the committed lockfile; plan summaries `tech-stack.added: []` | closed |
|
||||
|
||||
*Status: open · closed · open — below high threshold (non-blocking)*
|
||||
*Severity: critical > high > medium > low — only open threats at or above workflow.security_block_on count toward threats_open*
|
||||
*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
| Risk ID | Threat Ref | Rationale | Accepted By | Date |
|
||||
|---------|------------|-----------|-------------|------|
|
||||
| AR-19.6.1-12 | T-19.6.1-12 | Setting another admin's password does not revoke that admin's personal API tokens — same semantics as `admin:reset-password`. The operator revokes them with `admin:token:revoke`. Widening the phase to revoke tokens on password set was flagged and declined. | plan 01 (authored) | 2026-10-22 |
|
||||
| AR-19.6.1-16 | T-19.6.1-16 | Login/email collision messages can reveal that a deleted account exists. Only holders of `backend.manage_users` see them, and they can list deleted admins anyway. | plan 01 (authored) | 2026-10-22 |
|
||||
| AR-19.6.1-20 | T-19.6.1-20 | `meta.permissionLocks` repeats lock codes and notes on show/save. Sent only behind `protect()` to admins who may open the record; it repeats codes the permission editor already shows. | plan 02 (authored) | 2026-10-22 |
|
||||
| AR-19.6.1-32 | T-19.6.1-32 | Remembered relation option labels are display-only client state. The server still authorizes the posted id; RelationField interpolates the label as text. | plan 05 (authored) | 2026-10-22 |
|
||||
|
||||
*Accepted risks do not resurface in future audit runs.*
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| 2026-10-22 | 33 | 33 | 0 | msd-secure-phase (ASVS L1, register authored at plan time) |
|
||||
|
||||
## Security Audit 2026-10-22
|
||||
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Threats found | 33 |
|
||||
| Closed | 33 |
|
||||
| Open | 0 |
|
||||
|
||||
State B (no prior SECURITY.md). Plans 01–05 each contained a parseable `<threat_model>` (`register_authored_at_plan_time: true`). SUMMARYs 01–03 reported no unregistered threat flags; 04–05 have no Threat Flags section. ASVS L1 + `threats_open: 0` short-circuited past the auditor (grep-depth sufficient). `block_on: high`.
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [x] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [x] Accepted risks documented in Accepted Risks Log
|
||||
- [x] `threats_open: 0` confirmed
|
||||
- [x] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** verified 2026-10-22
|
||||
@@ -0,0 +1,188 @@
|
||||
---
|
||||
status: complete
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
source: 19.6.1-01-SUMMARY.md, 19.6.1-02-SUMMARY.md, 19.6.1-03-SUMMARY.md
|
||||
started: 2026-10-22T11:00:00Z
|
||||
updated: 2026-10-22T13:23:00Z
|
||||
---
|
||||
|
||||
## Current Test
|
||||
|
||||
[testing complete]
|
||||
|
||||
## Tests
|
||||
|
||||
### 1. Settings tiles and Administrators list (superuser)
|
||||
expected: Settings → System shows Administrators then Roles tiles (no new sidebar item). The Administrators list shows admins with a Superuser column and filters, including Active and Deleted; all labels are translated, with no raw lang keys.
|
||||
result: pass
|
||||
|
||||
### 2. Create an administrator
|
||||
expected: Create opens the form with login, email, name, password + confirmation, role, a Superuser switch and Permission overrides. Saving with a mismatched or 3-character password shows a field error. Saving a valid admin (role e.g. developer, Superuser off) lands on the record and shows a success toast.
|
||||
result: pass
|
||||
previous_result: issue
|
||||
retested_by: 19.6.1-05
|
||||
reported: "confirmed, working as expected"
|
||||
note: "Retested after demo rebuild on 127.0.0.1:8099; role dropdown keeps the name after switching tabs."
|
||||
|
||||
### 3. Superuser switch locks the permission overrides
|
||||
expected: On the new admin's form, turning Superuser ON makes the Permission overrides editor read-only with a note explaining why; turning it OFF makes the overrides editable again (radio per permission: inherit / grant / deny). Saving an override persists after reload.
|
||||
result: pass
|
||||
|
||||
### 4. Deactivate, delete, restore
|
||||
expected: On the admin's preview, Deactivate shows a toast and the status hint/callout changes; Activate brings them back. Delete soft-deletes: the row disappears from the default list and appears under the Deleted filter, where Restore returns it. The preview footer buttons don't overlap or wrap badly at around 1024px wide.
|
||||
result: pass
|
||||
|
||||
### 5. Own record restrictions (superuser)
|
||||
expected: Opening your own record (admin): no Deactivate/Delete offered or they are refused with a readable toast; the role, superuser switch and permission rows are locked with a note; the password field points you to My Account instead of letting you set it here.
|
||||
result: pass
|
||||
|
||||
### 6. Roles screen
|
||||
expected: Roles lists roles; create a role with a code, name and permissions via the permission editor, then save it. Code-declared grants on system roles show as locked rows with a note. Deleting a role still held by an admin is refused with a toast that names the role and the count; deleting a system role is refused; a system role's code is not editable.
|
||||
result: pass
|
||||
previous_result: pass
|
||||
retest_reason: "modules/cabana/backend_roles_admin.go changed after the UAT pass (2026-10-22T11:17:34.000Z)"
|
||||
note: "add todo to add users list (relation widget if we have one for this) in Roles" (todo roles-screen-holders-list.md)
|
||||
|
||||
### 7. Limited admin with only manage_users
|
||||
expected: Create a role holding only backend.manage_users (plus whatever is needed to reach Settings), assign it to a new non-superuser admin, sign in as them in a private window. Only the Administrators tile shows (no Roles). No Superuser column, filter or switch; superusers (admin) are not listed. Permission rows they don't hold show locked; roles above their ceiling are locked in the role picker; their own record shows locked permissions and no Deactivate.
|
||||
result: pass
|
||||
|
||||
### 8. Limited admin with only manage_roles
|
||||
expected: Signed in as a non-superuser holding only backend.manage_roles: only the Roles tile shows. In the permission editor, permissions they don't hold are locked; they can't grant beyond their own set. (Known open gap CR-01: renaming a role's code onto a plugin-declared code escalates privileges — being fixed in the gap-closure session; note it, don't fail this test on it.)
|
||||
result: pass
|
||||
|
||||
### 9. pact action-extension seam: a plugin adds record actions to summercms.cabana.users
|
||||
expected: pact action-extension seam: a plugin adds record actions to summercms.cabana.users; offered on the preview after the owner's, run in the row-locked tx; unknown controller ID stops boot
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 01-D1
|
||||
|
||||
### 10. Pseudo-plugin activation, tiles and orders
|
||||
expected: Pseudo-plugin activates only with admin controllers; settings tile Administrators (order 100) and Roles (110) under System; codes granted to no role
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 01-D2
|
||||
|
||||
### 11. Administrators form server rules
|
||||
expected: Administrators form: create with password, superuser projection, D-03 hiding, D-05 superuser-only switch, D-08 own role/flag refusals, D-20 own password refusal, superuser demotion with a second superuser
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 01-D3
|
||||
|
||||
### 12. Lifecycle server rules
|
||||
expected: Lifecycle: deactivate revokes JWTs, soft delete with deleted row state, restore, trashed filter, self delete and self bulk-deactivate refused with whole-selection rollback, preview hint
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 01-D4
|
||||
|
||||
### 13. Roles screen server rules
|
||||
expected: Roles screen: create, code taken, in-use and system-role delete refusals, system code lock, settings order
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 01-D5
|
||||
|
||||
### 14. Record-lock save rule
|
||||
expected: Record-lock save rule: absent locked code keeps stored, differing present value is 403, equal body passes, no locks asked on create; meta.permissionLocks present only with a provider
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 02-D1
|
||||
|
||||
### 15. Roles and Administrators saves under the record-lock rule
|
||||
expected: Roles and Administrators saves keep working under the record-lock rule (system role grants, own record)
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 02-D2
|
||||
|
||||
### 16. Trigger compile rules
|
||||
expected: Valid trigger reaches the localized schema; malformed triggers are boot errors naming controller, field and trigger; settings and relation forms refuse it; Administrators permissions carries the D-06 trigger
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 02-D3
|
||||
|
||||
### 17. Generated OpenAPI, schema.d.ts and admin build match
|
||||
expected: Generated OpenAPI, schema.d.ts and the committed admin build match fresh generations
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 02-D4
|
||||
|
||||
### 18. Save-path rules over HTTP on Postgres
|
||||
expected: Superuser flag (D-05), hiding incl. scoped-token superusers (D-03), projection, permission and role ceilings (D-06, D-07), self edit (D-08), password and identity (D-11), outranking (D-19), own password (D-20)
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D1
|
||||
|
||||
### 19. Concurrent last-superuser protection
|
||||
expected: Concurrent last-superuser protection on demote, record and bulk deactivate, form and bulk delete (held advisory lock), plus ten unsynchronized rounds
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D2
|
||||
|
||||
### 20. Lifecycle and revocation
|
||||
expected: Lifecycle (Applies, 409, bulk Affected, soft delete, trashed filter, hint precedence) and revocation (JWT and personal tokens after deactivate and delete, sessions after a password set)
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D3
|
||||
|
||||
### 21. D-14 seam tests
|
||||
expected: Boot refusals and order, offer and run only with both permissions, 409 when Applies turns false, Run in the transaction with the record; activation only with an admin
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D4
|
||||
|
||||
### 22. Roles tests
|
||||
expected: Code taken and locked, plugin-declared system roles, in-use delete with soft-deleted holders, bulk delete rollback, permission ceiling
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D5
|
||||
|
||||
### 23. D-21 server side
|
||||
expected: Trigger boot rules, record-lock save rule in both modes, code-declared and own-record locks on Postgres
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D6
|
||||
|
||||
### 24. D-21 SPA backstops
|
||||
expected: Trigger disable, absent controlling field, hide-tab removal with the banner line, record-locked rows and payload omission, preview hide; footer wrap at 1024px with two 40-character contributed labels
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D7
|
||||
|
||||
### 25. Phase gate
|
||||
expected: bash scripts/check-phase19.6.1.sh --all exits 0; SC-1 regression tests pass unchanged
|
||||
result: pass
|
||||
source: automated
|
||||
coverage_id: 03-D8
|
||||
|
||||
### 26. Review the judgment-tier prohibitions in Plans 01-04 (listed under Prohibitions in the report) and confirm or reject the LLM-judge verdicts
|
||||
expected: Each prohibition confirmed as held
|
||||
result: pass
|
||||
|
||||
## Summary
|
||||
|
||||
total: 26
|
||||
passed: 26
|
||||
issues: 0
|
||||
pending: 0
|
||||
skipped: 0
|
||||
blocked: 0
|
||||
|
||||
## Gaps
|
||||
|
||||
- gap_id: G-19.6.1-T2
|
||||
truth: "After picking a role in the Administrators form, the role dropdown keeps showing the role's name when the user switches tabs and comes back"
|
||||
status: resolved
|
||||
resolved_by: 19.6.1-05
|
||||
resolved_at: 2026-10-22
|
||||
reason: "User reported after rebuild: confirmed, working as expected. Role dropdown keeps the name after switching tabs."
|
||||
severity: minor
|
||||
test: 2
|
||||
root_cause: "FormView renders only the active tab's fields, so RelationField unmounts on a tab switch. On remount its id->label cache (known) is rebuilt only from props.labels (the server's meta.labels for the value stored at load time); the label of an option picked from an options page is lost and labelOf() falls back to String(id). Pre-existing in the generic relation field, not specific to this phase."
|
||||
artifacts:
|
||||
- path: "admin/src/components/form/fields/RelationField.vue"
|
||||
issue: "known label cache is component-local and seeded only from props.labels (lines ~31-79, labelOf)"
|
||||
- path: "admin/src/views/FormView.vue"
|
||||
issue: "inactive tab panels are unmounted, discarding field-local state"
|
||||
missing:
|
||||
- "Keep picked option labels across remounts: lift the label cache to the form context (per field) or emit the picked label with update:modelValue so FormView passes it back in labels; alternatively keep tab panels mounted with v-show"
|
||||
- "Vitest backstop: pick an option, switch tab and back, label still shown"
|
||||
debug_session: ""
|
||||
@@ -5,7 +5,7 @@ slug: "backend-administrators-screen"
|
||||
# audit-milestone §5.5 distinguishes NOT-VALIDATED (draft) from PARTIAL (validated + nyquist_compliant: false) (#2117)
|
||||
status: draft
|
||||
nyquist_compliant: false
|
||||
wave_0_complete: false
|
||||
wave_0_complete: true
|
||||
created: "2026-10-21"
|
||||
---
|
||||
|
||||
@@ -42,16 +42,16 @@ Filled by the planner per task; the decision → test map lives in `19.6.1-RESEA
|
||||
|
||||
| Task ID | Plan | Wave | Requirement | Threat Ref | Secure Behavior | Test Type | Automated Command | File Exists | Status |
|
||||
|---------|------|------|-------------|------------|-----------------|-----------|-------------------|-------------|--------|
|
||||
| 19.6.1-01-01 | 01 | 1 | D-01, D-02, D-04, D-14, D-15 | T-19.6.1-09, -10, -14 | seam merged before permission validation; contributed actions behind target + own permissions; no default role grant | smoke (-short + Postgres) | `go test -short -run '^TestBackendScreensSmoke$' ./modules/cabana`; `go test -run '^TestBackendScreensPostgresSmoke$' ./modules/cabana`; `go -C examples/hello test ./...` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-01-02 | 01 | 1 | D-03, D-05..D-08, D-11, D-12, D-19, D-20 | T-19.6.1-01..-05, -07, -08, -11, -13, -17 | save-path rules in the save tx; is_superuser projected; hidden for non-superusers | smoke (Postgres) | `go test -run '^TestAdministratorsFormSmoke$' ./modules/cabana` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-01-03 | 01 | 1 | D-08, D-09, D-10, D-12, D-19 | T-19.6.1-05, -06, -11, -12 | last-superuser guard under advisory lock; soft delete only; revocation | smoke (Postgres) | `go test -run '^TestAdministratorsLifecycleSmoke$' ./modules/cabana` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-01-04 | 01 | 1 | D-02, D-07, D-16, D-17 | T-19.6.1-04, -15 | roles ceiling; system role code locked; in-use delete refused | smoke (Postgres) | `go test -run '^TestRolesSmoke$' ./modules/cabana`; `scripts/check-admin-openapi.sh --check` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-02-01 | 02 | 2 | D-21 (D-16, D-08) | T-19.6.1-19, -20, -22, -23 | record-locked codes kept server-side; changed value 403 | smoke (-short) + vitest | `go test -short -run '^TestPermissionRecordLocksSmoke$' ./modules/cabana`; `scripts/check-admin-openapi.sh --check`; `npm --prefix admin run test` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-02-02 | 02 | 2 | D-21 (D-06) | T-19.6.1-18, -21, -22, -23 | trigger boot errors; disabled field not sent; dist matches build | smoke (-short) + vitest + dist | `go test -short -run '^TestFieldTriggerSmoke$' ./modules/cabana`; `npm --prefix admin run test`; `scripts/check-admin-dist.sh` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-03-01 | 03 | 3 | D-05, D-18 | T-19.6.1-24, -26 | harness + first rule over HTTP | Postgres | `go test -run '^TestAdministratorsSuperuserFlag$' ./modules/cabana` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-03-02 | 03 | 3 | D-03, D-06, D-07, D-08, D-11, D-19, D-20 | T-19.6.1-24 | each save-path rule has a failing-without-rule test | unit (-short) + Postgres | `go test -short -run '^TestRoleCeiling$' ./modules/cabana`; `go test -run '^TestAdministrators(SuperuserHidden\|SuperuserProjected\|PermissionCeiling\|RoleCeiling\|SelfEdit\|PasswordAndIdentity\|Outranked\|OwnPassword)$' ./modules/cabana` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-03-03 | 03 | 3 | D-04, D-09, D-10, D-12, D-14, D-16, D-17 | T-19.6.1-24, -25, -26 | held-lock race on 5 paths; revocation; seam boot and run; roles | unit (-short) + Postgres | `go test -short -run '^(TestActionExtensionBoot\|TestBackendScreensActivation)$' ./modules/cabana`; `go test -run '^(TestAdministratorsLastSuperuser\|TestAdministratorsLastSuperuserConcurrent\|TestAdministratorsLifecycle\|TestAdministratorsRevocation\|TestActionExtensionRun\|TestRolesLifecycle\|TestRolesPermissionCeiling)$' ./modules/cabana` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-03-04 | 03 | 3 | D-21, D-18 | T-19.6.1-24, -27 | D-21 Go + SPA tests incl. backstops; fail-closed gate | unit + vitest + browser + gate | `go test -short -run '^(TestFieldTriggerBoot\|TestPermissionRecordLocks)$' ./modules/cabana`; `npm --prefix admin run test`; `npm --prefix admin run test:browser`; `bash scripts/check-phase19.6.1.sh --all` | ❌ W0 | ⬜ pending |
|
||||
| 19.6.1-01-01 | 01 | 1 | D-01, D-02, D-04, D-14, D-15 | T-19.6.1-09, -10, -14 | seam merged before permission validation; contributed actions behind target + own permissions; no default role grant | smoke (-short + Postgres) | `go test -short -run '^TestBackendScreensSmoke$' ./modules/cabana`; `go test -run '^TestBackendScreensPostgresSmoke$' ./modules/cabana`; `go -C examples/hello test ./...` | ✅ | ✅ green |
|
||||
| 19.6.1-01-02 | 01 | 1 | D-03, D-05..D-08, D-11, D-12, D-19, D-20 | T-19.6.1-01..-05, -07, -08, -11, -13, -17 | save-path rules in the save tx; is_superuser projected; hidden for non-superusers | smoke (Postgres) | `go test -run '^TestAdministratorsFormSmoke$' ./modules/cabana` | ✅ | ✅ green |
|
||||
| 19.6.1-01-03 | 01 | 1 | D-08, D-09, D-10, D-12, D-19 | T-19.6.1-05, -06, -11, -12 | last-superuser guard under advisory lock; soft delete only; revocation | smoke (Postgres) | `go test -run '^TestAdministratorsLifecycleSmoke$' ./modules/cabana` | ✅ | ✅ green |
|
||||
| 19.6.1-01-04 | 01 | 1 | D-02, D-07, D-16, D-17 | T-19.6.1-04, -15 | roles ceiling; system role code locked; in-use delete refused | smoke (Postgres) | `go test -run '^TestRolesSmoke$' ./modules/cabana`; `scripts/check-admin-openapi.sh --check` | ✅ | ✅ green |
|
||||
| 19.6.1-02-01 | 02 | 2 | D-21 (D-16, D-08) | T-19.6.1-19, -20, -22, -23 | record-locked codes kept server-side; changed value 403 | smoke (-short) + vitest | `go test -short -run '^TestPermissionRecordLocksSmoke$' ./modules/cabana`; `scripts/check-admin-openapi.sh --check`; `npm --prefix admin run test` | ✅ | ✅ green |
|
||||
| 19.6.1-02-02 | 02 | 2 | D-21 (D-06) | T-19.6.1-18, -21, -22, -23 | trigger boot errors; disabled field not sent; dist matches build | smoke (-short) + vitest + dist | `go test -short -run '^TestFieldTriggerSmoke$' ./modules/cabana`; `npm --prefix admin run test`; `scripts/check-admin-dist.sh` | ✅ | ✅ green |
|
||||
| 19.6.1-03-01 | 03 | 3 | D-05, D-18 | T-19.6.1-24, -26 | harness + first rule over HTTP | Postgres | `go test -run '^TestAdministratorsSuperuserFlag$' ./modules/cabana` | ✅ | ✅ green |
|
||||
| 19.6.1-03-02 | 03 | 3 | D-03, D-06, D-07, D-08, D-11, D-19, D-20 | T-19.6.1-24 | each save-path rule has a failing-without-rule test | unit (-short) + Postgres | `go test -short -run '^TestRoleCeiling$' ./modules/cabana`; `go test -run '^TestAdministrators(SuperuserHidden\|SuperuserProjected\|PermissionCeiling\|RoleCeiling\|SelfEdit\|PasswordAndIdentity\|Outranked\|OwnPassword)$' ./modules/cabana` | ✅ | ✅ green |
|
||||
| 19.6.1-03-03 | 03 | 3 | D-04, D-09, D-10, D-12, D-14, D-16, D-17 | T-19.6.1-24, -25, -26 | held-lock race on 5 paths; revocation; seam boot and run; roles | unit (-short) + Postgres | `go test -short -run '^(TestActionExtensionBoot\|TestBackendScreensActivation)$' ./modules/cabana`; `go test -run '^(TestAdministratorsLastSuperuser\|TestAdministratorsLastSuperuserConcurrent\|TestAdministratorsLifecycle\|TestAdministratorsRevocation\|TestActionExtensionRun\|TestRolesLifecycle\|TestRolesPermissionCeiling)$' ./modules/cabana` | ✅ | ✅ green |
|
||||
| 19.6.1-03-04 | 03 | 3 | D-21, D-18 | T-19.6.1-24, -27 | D-21 Go + SPA tests incl. backstops; fail-closed gate | unit + vitest + browser + gate | `go test -short -run '^(TestFieldTriggerBoot\|TestPermissionRecordLocks)$' ./modules/cabana`; `go test -run '^TestRolesCodeDeclaredLocks$' ./modules/cabana`; `npm --prefix admin run test`; `npm --prefix admin run test:browser`; `bash scripts/check-phase19.6.1.sh --all` | ✅ | ✅ green |
|
||||
|
||||
*Status: ⬜ pending · ✅ green · ❌ red · ⚠️ flaky*
|
||||
|
||||
@@ -59,19 +59,21 @@ Filled by the planner per task; the decision → test map lives in `19.6.1-RESEA
|
||||
|
||||
## Wave 0 Requirements
|
||||
|
||||
- [ ] `modules/cabana/backend_screens_test.go` — activation and schema (`-short`; smoke in plan 01, `TestBackendScreensActivation` in plan 03)
|
||||
- [ ] `modules/cabana/backend_screens_smoke_test.go` — plan 01 Postgres smokes
|
||||
- [ ] `modules/cabana/record_locks_smoke_test.go`, `modules/cabana/field_trigger_smoke_test.go` — plan 02 smokes (`-short`)
|
||||
- [ ] `modules/cabana/action_extensions_test.go` (boot, `-short`) and `modules/cabana/action_extensions_postgres_test.go` (run) — D-14
|
||||
- [ ] `modules/cabana/backend_privileges_internal_test.go` — subset/ceiling helpers (`package cabana`)
|
||||
- [ ] `modules/cabana/administrators_harness_test.go` — superuser-capable seeding, roles, login, `isolateSuperusers`
|
||||
- [ ] `modules/cabana/administrators_postgres_test.go` — D-03, D-05..D-08, D-11, D-19, D-20 at HTTP level
|
||||
- [ ] `modules/cabana/administrators_lifecycle_postgres_test.go` — D-09 held-lock race, D-10, D-12
|
||||
- [ ] `modules/cabana/roles_postgres_test.go` — D-07 (roles), D-16, D-17, D-21 code-declared locks
|
||||
- [ ] `modules/cabana/field_trigger_test.go`, `modules/cabana/record_locks_test.go` — D-21 (`-short`)
|
||||
- [ ] `admin/tests/form/trigger.test.ts` + additions to PermissionEditorField, formState, FormView, PreviewView tests; `admin/tests/browser/record-actions-wrap.test.ts`
|
||||
- [ ] `scripts/check-phase19.6.1.sh` — phase gate
|
||||
- [ ] `modules/cabana/export_test.go` — `SuperuserLockKey`
|
||||
Ticked with the files as built (Plan 03 moved the screens harness out of `backend_screens_smoke_test.go` into `administrators_harness_test.go`).
|
||||
|
||||
- [x] `modules/cabana/backend_screens_test.go` — activation and schema (`-short`; `TestBackendScreensSmoke` in plan 01, `TestBackendScreensActivation` in plan 03)
|
||||
- [x] `modules/cabana/backend_screens_smoke_test.go` — plan 01 Postgres smokes
|
||||
- [x] `modules/cabana/record_locks_smoke_test.go`, `modules/cabana/field_trigger_smoke_test.go` — plan 02 smokes (`-short`)
|
||||
- [x] `modules/cabana/action_extensions_test.go` (`TestActionExtensionBoot`, `-short`) and `modules/cabana/action_extensions_postgres_test.go` (`TestActionExtensionRun`) — D-14
|
||||
- [x] `modules/cabana/backend_privileges_internal_test.go` — `TestRoleCeiling` against `grantsCovered` (`package cabana`)
|
||||
- [x] `modules/cabana/administrators_harness_test.go` — `newScreensEnv`, `seedAdmin`, `seedRole`, `login`, `isolateSuperusers`, row snapshots
|
||||
- [x] `modules/cabana/administrators_postgres_test.go` — D-03, D-05..D-08, D-11, D-19, D-20 at HTTP level
|
||||
- [x] `modules/cabana/administrators_lifecycle_postgres_test.go` — D-09 held-lock race on five paths, the unsynchronized rounds, D-10, D-12
|
||||
- [x] `modules/cabana/roles_postgres_test.go` — D-07 (roles), D-16, D-17, D-21 code-declared locks
|
||||
- [x] `modules/cabana/field_trigger_test.go`, `modules/cabana/record_locks_test.go` — D-21 (`-short`)
|
||||
- [x] `admin/tests/form/trigger.test.ts` + additions to PermissionEditorField, formState, FormView, PreviewView tests; `admin/tests/browser/record-actions-wrap.test.ts`
|
||||
- [x] `scripts/check-phase19.6.1.sh` — phase gate (`--all`: self-test, go, admin, docs, sc1, docker)
|
||||
- [x] `modules/cabana/export_test.go` — `SuperuserLockKey`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
---
|
||||
phase: 19.6.1-backend-administrators-screen
|
||||
verified: 2026-10-22T12:58:00Z
|
||||
status: passed
|
||||
score: 28/28 must-haves verified
|
||||
covered_files:
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-PLAN.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-02-PLAN.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-02-SUMMARY.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-03-PLAN.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-03-SUMMARY.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-PLAN.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-SUMMARY.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-05-PLAN.md
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-05-SUMMARY.md
|
||||
- admin/openapi/admin.json
|
||||
- admin/src/api/schema.d.ts
|
||||
- admin/src/api/types.ts
|
||||
- admin/src/components/form/FormField.vue
|
||||
- admin/src/components/form/control.ts
|
||||
- admin/src/components/form/fields/PermissionEditorField.vue
|
||||
- admin/src/components/form/fields/RelationField.vue
|
||||
- admin/src/components/form/formContext.ts
|
||||
- admin/src/components/form/formState.ts
|
||||
- admin/src/components/form/trigger.ts
|
||||
- admin/src/components/relation/RelationChildModal.vue
|
||||
- admin/src/views/FormView.vue
|
||||
- admin/src/views/PreviewView.vue
|
||||
- admin/tests/browser/record-actions-wrap.test.ts
|
||||
- admin/tests/form/FormView.test.ts
|
||||
- admin/tests/form/PermissionEditorField.test.ts
|
||||
- admin/tests/form/PreviewView.test.ts
|
||||
- admin/tests/form/RelationField.test.ts
|
||||
- admin/tests/form/formState.test.ts
|
||||
- admin/tests/form/trigger.test.ts
|
||||
- admin/vitest.browser.config.ts
|
||||
- docs/backend/admin-controllers.md
|
||||
- docs/backend/forms.md
|
||||
- docs/backend/users-and-permissions.md
|
||||
- modules/boardwalk/dist/assets/index-BtP5LUQA.js
|
||||
- modules/boardwalk/dist/index.html
|
||||
- modules/cabana/README.md
|
||||
- modules/cabana/action_extensions.go
|
||||
- modules/cabana/action_extensions_postgres_test.go
|
||||
- modules/cabana/action_extensions_test.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- modules/cabana/administrators_harness_test.go
|
||||
- modules/cabana/administrators_lifecycle_postgres_test.go
|
||||
- modules/cabana/administrators_postgres_test.go
|
||||
- modules/cabana/backend_privileges.go
|
||||
- modules/cabana/backend_privileges_internal_test.go
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/backend_screens.go
|
||||
- modules/cabana/backend_screens_smoke_test.go
|
||||
- modules/cabana/backend_screens_test.go
|
||||
- modules/cabana/backend_users_admin.go
|
||||
- modules/cabana/backendscreens/controllers/roles/config_form.yaml
|
||||
- modules/cabana/backendscreens/controllers/roles/config_list.yaml
|
||||
- modules/cabana/backendscreens/controllers/users/_hint.htm
|
||||
- modules/cabana/backendscreens/controllers/users/config_filter.yaml
|
||||
- modules/cabana/backendscreens/controllers/users/config_form.yaml
|
||||
- modules/cabana/backendscreens/controllers/users/config_list.yaml
|
||||
- modules/cabana/backendscreens/models/user/columns.yaml
|
||||
- modules/cabana/backendscreens/models/user/fields.yaml
|
||||
- modules/cabana/backendscreens/models/userrole/columns.yaml
|
||||
- modules/cabana/backendscreens/models/userrole/fields.yaml
|
||||
- modules/cabana/contracts.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/example_action_extension_test.go
|
||||
- modules/cabana/example_permission_record_locks_test.go
|
||||
- modules/cabana/export_test.go
|
||||
- modules/cabana/field_dependent.go
|
||||
- modules/cabana/field_permission.go
|
||||
- modules/cabana/field_repeater.go
|
||||
- modules/cabana/field_trigger.go
|
||||
- modules/cabana/field_trigger_smoke_test.go
|
||||
- modules/cabana/field_trigger_test.go
|
||||
- modules/cabana/form_schema.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/record_locks_smoke_test.go
|
||||
- modules/cabana/record_locks_test.go
|
||||
- modules/cabana/registry.go
|
||||
- modules/cabana/relation_child.go
|
||||
- modules/cabana/relation_field.go
|
||||
- modules/cabana/roles_postgres_test.go
|
||||
- modules/cabana/schema_types.go
|
||||
- modules/pact/README.md
|
||||
- modules/pact/capabilities.go
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml
|
||||
- modules/phrasebook/backend/lang/pl/lang.yaml
|
||||
- scripts/check-phase19.6.1.sh
|
||||
covered_digest: "v2:sha256:a5616df163b8bd493b54f6ee5fb739c43c32ab07b10cf8a2f87753f77ced72d9"
|
||||
behavior_unverified: 0
|
||||
overrides_applied: 0
|
||||
decision_coverage:
|
||||
honored: 22
|
||||
total: 22
|
||||
not_honored: []
|
||||
re_verification:
|
||||
previous_status: human_needed
|
||||
previous_score: 25/25
|
||||
gaps_closed:
|
||||
- "G-19.6.1-T2 implementation: picked relation labels persist across FormView tab remount (FORM_REMEMBER_LABEL + two named vitest cases). Human UAT row 2 was not re-run."
|
||||
gaps_remaining: []
|
||||
regressions: []
|
||||
advisory: []
|
||||
human_verified:
|
||||
- test: "Settings tiles and Administrators list (superuser)"
|
||||
uat_row: 1
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Superuser switch locks the permission overrides"
|
||||
uat_row: 3
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Deactivate, delete, restore"
|
||||
uat_row: 4
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Own record restrictions (superuser)"
|
||||
uat_row: 5
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Roles screen"
|
||||
uat_row: 6
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Limited admin with only manage_users"
|
||||
uat_row: 7
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Limited admin with only manage_roles"
|
||||
uat_row: 8
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
- test: "Review the judgment-tier prohibitions in Plans 01-04 (listed under Prohibitions in the report) and confirm or reject the LLM-judge verdicts"
|
||||
uat_row: 26
|
||||
recorded_at: "2026-10-22T12:30:13.000Z"
|
||||
human_verification:
|
||||
- test: "Create an administrator"
|
||||
expected: "Create opens the form with login, email, name, password + confirmation, role, a Superuser switch and Permission overrides. Saving with a mismatched or 3-character password shows a field error. Saving a valid admin (role e.g. developer, Superuser off) lands on the record and shows a success toast. After picking Developer and switching to Permissions and back, the role dropdown still shows Developer, not the raw id."
|
||||
why_human: "UAT row 2 is still result: issue. Plan 05 shipped FORM_REMEMBER_LABEL and both named vitest cases pass on the widgets fixture; the human has not re-run the Administrators form in the browser. Do not treat the unit backstops as a UAT pass."
|
||||
---
|
||||
|
||||
# Phase 19.6.1: Backend Administrators screen Verification Report
|
||||
|
||||
**Phase Goal:** cabana gets WinterCMS's Administrators screens, so backend admins and their roles are managed in the admin SPA instead of only through `admin:*` console commands. It reuses cabana's CRUD, permission field and record actions, and follows the sm-user-plugin Users/Groups screens and WinterCMS `Backend\Controllers\Users`/`UserRoles`.
|
||||
**Verified:** 2026-10-22T12:58:00Z
|
||||
**Status:** human_needed
|
||||
**Re-verification:** Yes — after gap-closure plan 19.6.1-05 (G-19.6.1-T2 only)
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
Plan 05 closed the T2 remount-label hole in the SPA: `FORM_REMEMBER_LABEL` persists a picked relation option on the form host, `choose()` writes it before emit, and a remounted `RelationField` seeds `known` from `props.labels`. Both named vitest cases passed in this run. The embedded dist carries `summer.form.rememberLabel`. The prior 25 phase truths still hold (no Go/pact/YAML/OpenAPI change this wave).
|
||||
|
||||
UAT row 2 is still `issue`. Plan 05 had no human-verify checkpoint. This report does not invent a UAT pass. Status stays `human_needed`.
|
||||
|
||||
### Observable Truths
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| SC-1 | Admin with manage-administrators lists/creates/edits/deactivates backend users and edits roles with the permission editor; existing payloads and `admin:*` commands unchanged | ✓ VERIFIED (human UAT, rows 1, 3–5, 7) | YAML screens and controllers unchanged this wave; git log since prior `verified:` empty on cabana/pact/phrasebook/openapi |
|
||||
| SC-2 | Only a superuser can create/edit/grant superuser; an admin cannot raise their own role or permissions; last active superuser protected | ✓ VERIFIED | `refuseCodeDeclaredCode` still present (4); prior Postgres names unchanged |
|
||||
| SC-3 | Record-action seam usable by plugins; unit tests cover privilege rules | ✓ VERIFIED | `wrapAdministratorsContributedRun` still present (3); `func guardOutranked` still unexported |
|
||||
| D-01 | `backend.manage_users`, `backend.manage_roles` registered by internal pseudo-plugin | ✓ VERIFIED | `backend_screens.go` exists; prior pass |
|
||||
| D-02 | Settings → System placement, no navigation item | ✓ VERIFIED | UAT row 1; no this-wave change |
|
||||
| D-03 | Superusers hidden from non-superusers | ✓ VERIFIED | UAT row 7; no this-wave change |
|
||||
| D-04 | No default role grant | ✓ VERIFIED | prior pass |
|
||||
| D-05 | Only superuser sets is_superuser; non-superuser sending it gets 403 | ✓ VERIFIED | prior pass |
|
||||
| D-06 | Per-user radio permission override, disabled while superuser on | ✓ VERIFIED | UAT row 3; no this-wave change |
|
||||
| D-07 | Non-superuser can't grant more than they hold (permissions, role picker, Roles screen) | ✓ VERIFIED | prior pass + `refuseCodeDeclaredCode` |
|
||||
| D-08 | Own record: profile editable; role/superuser/permissions/activation/delete refused | ✓ VERIFIED | UAT row 5 |
|
||||
| D-09 | Last active superuser protected on every write path under lock | ✓ VERIFIED | prior behavioral tests; files unchanged this wave |
|
||||
| D-10 | Deactivate + soft delete + restore, no hard delete | ✓ VERIFIED | UAT row 4 |
|
||||
| D-11 | Password typed in form, required on create, bcrypt | ✓ VERIFIED | prior pass |
|
||||
| D-12 | Deactivate/delete/password-set bump tokens_valid_after | ✓ VERIFIED | prior pass |
|
||||
| D-13 | No invite or welcome mail | ✓ VERIFIED | no this-wave change to `backend_users_admin.go` |
|
||||
| D-14 | Generic cross-controller action extension with boot errors | ✓ VERIFIED | prior pass |
|
||||
| D-15 | Contributed actions on preview only | ✓ VERIFIED | prior pass |
|
||||
| D-16 | Roles fields; system roles code locked; a role never becomes a code-declared system role through the screen | ✓ VERIFIED | `refuseCodeDeclaredCode` still wired |
|
||||
| D-17 | Held role or system role cannot be deleted | ✓ VERIFIED | prior pass; UAT row 6 settled (plan 05 files do not bear on Roles checks) |
|
||||
| D-18 | Unit tests last plan; docs updated | ✓ VERIFIED | plans 01–04 files untouched this wave; plan 05 added SPA tests only |
|
||||
| D-19 | No outranking on update/delete/record/bulk actions, contributed Administrators Runs included | ✓ VERIFIED | wrap still compiled in |
|
||||
| D-20 | Own password refused on this screen | ✓ VERIFIED | UAT row 5 |
|
||||
| D-21 | SPA support: field trigger + per-record locked permission values | ✓ VERIFIED | UAT rows 3 and 5; plan 05 did not change trigger/lock path |
|
||||
| D-22 | Plan split (plus gap-closure waves 4 and 5) | ✓ VERIFIED | 01 server, 02 SPA, 03 tests, 04 privilege gaps, 05 remount labels |
|
||||
| T2-1 | After picking a relation option on a tabbed form, switching tabs and coming back still shows that option's name, not String(id) | ✓ VERIFIED (behavioral) | this-run `npm --prefix admin run test -- … -t "keeps a picked relation label after switching tabs"` — 1 passed. `panelFields` still filters to the active tab; `v-show` count in FormView is 0 |
|
||||
| T2-2 | A remounted RelationField seeds its id→label cache from the form's remembered labels, not only from the server meta.labels captured at load | ✓ VERIFIED (behavioral) | this-run `-t "shows a picked label after remount when the form remembered it"` — 1 passed. `choose()` calls `rememberLabel` before emit; remount watch is `watch(() => props.labels, remember, { immediate: true })` |
|
||||
| T2-3 | modules/boardwalk/dist matches a fresh admin build so the embedded SPA used by the local demo carries the fix | ✓ VERIFIED | `index.html` present; `assets/index-BtP5LUQA.js` contains `summer.form.rememberLabel` (1) and `rememberLabel` (1); commit `51e1a1e`. `verify.artifacts` reports the directory as "Not a file" (tool limitation) |
|
||||
|
||||
**Score:** 28/28 truths verified (0 present, behavior-unverified)
|
||||
|
||||
### Advisory (New Scope, Unevidenced)
|
||||
|
||||
None. Re-verification scanned Step 7 on files touched since the prior `verified:` timestamp (`formContext.ts`, `FormView.vue`, `RelationChildModal.vue`, `RelationField.vue`, the two test files, boardwalk dist). No new-scope blocker lacked deterministic evidence. WR-01, WR-02 and IN-01..IN-06 remain the same pre-gap-closure warnings/info; those Go files were not modified in plan 05.
|
||||
|
||||
### Required Artifacts
|
||||
|
||||
| Artifact | Expected | Status | Details |
|
||||
|----------|----------|--------|---------|
|
||||
| `admin/src/components/form/formContext.ts` | FORM_REMEMBER_LABEL injection key | ✓ VERIFIED | lines 174–180; typed `InjectionKey<(field, option) => void>`; missing provider is a no-op |
|
||||
| `admin/src/views/FormView.vue` | rememberRelationLabel + provide | ✓ VERIFIED | helper at 251–261 merges by `option.value`; `provide(FORM_REMEMBER_LABEL, rememberRelationLabel)` at 352; `:labels="labels"` on FormGrid at 655 |
|
||||
| `admin/src/components/form/fields/RelationField.vue` | choose() remembers before emit | ✓ VERIFIED | inject at 26; `rememberLabel?.(...)` inside `choose()` at 231–236 before `update:modelValue` |
|
||||
| `admin/src/components/relation/RelationChildModal.vue` | same helper and provide | ✓ VERIFIED | helper at 218–228; provide at 229 |
|
||||
| `admin/tests/form/FormView.test.ts` | tab-switch backstop | ✓ VERIFIED | `keeps a picked relation label after switching tabs` at 944; this-run PASS |
|
||||
| `admin/tests/form/RelationField.test.ts` | remount backstop | ✓ VERIFIED | `shows a picked label after remount when the form remembered it` at 249; this-run PASS |
|
||||
| `modules/boardwalk/dist` | remount-safe embed | ✓ VERIFIED | directory; `index.html` + `index-BtP5LUQA.js` with `summer.form.rememberLabel` |
|
||||
| Prior cabana/pact/YAML/SPA artifacts from plans 01–04 | still present | ✓ VERIFIED | existence check this run; 16/16 prior paths OK |
|
||||
|
||||
`msd_run query verify.artifacts` on 19.6.1-05-PLAN.md: 5/6 passed (dist directory flagged "Not a file"; contents verified by hand).
|
||||
|
||||
### Key Link Verification
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| RelationField.vue | formContext.ts | choose injects FORM_REMEMBER_LABEL and writes the picked option before update:modelValue | ✓ WIRED | pattern found; write is before emit |
|
||||
| FormView.vue | RelationField.vue | remembered labels flow back as props.labels so remount's watch seeds known | ✓ WIRED | `rememberRelationLabel` mutates `labels`; FormGrid `:labels="labels"`; RelationField watch immediate |
|
||||
| FormView.vue | FormGrid | single panel, inactive tabs unmounted | ✓ WIRED | `panelFields` filters by active tab; `v-show` count 0 |
|
||||
| RelationChildModal.vue | formContext.ts | child host provides FORM_REMEMBER_LABEL against its own labels ref | ✓ WIRED | provide at 229 |
|
||||
| Prior links (http.go compileActionExtensions, refuseCodeDeclaredCode, wrapAdministratorsContributedRun, applyTriggers) | — | — | ✓ WIRED | files unchanged this wave; symbols still present |
|
||||
|
||||
`msd_run query verify.key-links` on 19.6.1-05-PLAN.md: 2/2 verified.
|
||||
|
||||
### Data-Flow Trace (Level 4)
|
||||
|
||||
| Artifact | Data Variable | Source | Produces Real Data | Status |
|
||||
|----------|---------------|--------|--------------------|--------|
|
||||
| RelationField combobox | `known[id]` / `labelOf` | `props.labels` (server `meta.labels` plus FORM_REMEMBER_LABEL writes) and options pages | yes — picked `{value,label}` from the options list the admin already saw | ✓ FLOWING |
|
||||
| FormView `labels` | `labels.value[field]` | `adopt()` from `record.meta.labels`; `rememberRelationLabel` merge on pick | yes — replace-or-append by id; adopt still overwrites on load/save | ✓ FLOWING |
|
||||
| Administrators role field | role id | cabana relation options + user/fields.yaml `type: relation` on Account tab | yes — same RelationField path; Permissions tab remounts Account | ✓ FLOWING |
|
||||
| Prior list/show/permissionLocks/contributed Run | — | unchanged this wave | yes | ✓ FLOWING |
|
||||
|
||||
### Behavioral Spot-Checks
|
||||
|
||||
| Behavior | Command | Result | Status |
|
||||
|----------|---------|--------|--------|
|
||||
| T2 tab-switch label | `npm --prefix admin run test -- tests/form/RelationField.test.ts tests/form/FormView.test.ts -t "keeps a picked relation label after switching tabs\|shows a picked label after remount when the form remembered it"` | 2 passed / 65 skipped | ✓ PASS |
|
||||
| Dist carries remember inject | python count of `summer.form.rememberLabel` in `index-BtP5LUQA.js` | 1 | ✓ PASS |
|
||||
| Inactive tabs stay unmounted | `grep -c v-show admin/src/views/FormView.vue` | 0 | ✓ PASS |
|
||||
| Plans 01–04 / Go / pact / YAML / OpenAPI / npm lock untouched | `git log --since=2026-10-22T11:46:44Z` on those paths | empty | ✓ PASS |
|
||||
| Prior privilege wrap still compiled | `grep -c wrapAdministratorsContributedRun` / `func guardOutranked` | 3 / 1 | ✓ PASS |
|
||||
|
||||
Full-suite `go test ./...` was not re-run (prior post-merge pass; this wave is SPA-only). `check-admin-dist.sh` was not re-run (rebuild, over 10s). Dist symbol + `51e1a1e` stand in.
|
||||
|
||||
### Probe Execution
|
||||
|
||||
No `scripts/*/tests/probe-*.sh` is declared for this phase. The fail-closed phase gate is `scripts/check-phase19.6.1.sh` (not re-run; no Go change).
|
||||
|
||||
| Probe | Command | Result | Status |
|
||||
|-------|---------|--------|--------|
|
||||
| (none conventional) | — | — | SKIP |
|
||||
|
||||
### Requirements Coverage
|
||||
|
||||
REQUIREMENTS.md maps no IDs to 19.6.1 (`phase_req_ids` null; no orphaned requirements). Plan 05 `requirements: []`. Every ID declared across plans 01–04 is accounted for (unchanged from the prior pass):
|
||||
|
||||
| Requirement | Source Plan | Description | Status | Evidence |
|
||||
|-------------|-------------|-------------|--------|----------|
|
||||
| SC-1 | 01, 02, 03 | list/create/edit/deactivate; roles editor; payloads and admin:* unchanged | ✓ SATISFIED | prior + this-wave git empty on command/payload files |
|
||||
| SC-2 | 01, 02, 03, 04 | superuser-only flag; cannot self-raise; last superuser | ✓ SATISFIED | prior |
|
||||
| SC-3 | 01, 03 | seam + privilege tests | ✓ SATISFIED | prior |
|
||||
| D-01..D-22 | 01/02/03/04 | CONTEXT.md decisions | ✓ SATISFIED | 22/22 decision coverage; no this-wave Go change |
|
||||
| G-19.6.1-T2 | 05 (UAT gap) | picked relation label survives tab remount | ✓ SATISFIED (code); human UAT row 2 not re-run | vitest + inject wiring |
|
||||
|
||||
### Decision Coverage
|
||||
|
||||
All trackable CONTEXT.md decisions are honored by shipped artifacts (22/22, `check.decision-coverage-verify`). Non-blocking.
|
||||
|
||||
### Prohibitions
|
||||
|
||||
Plan 05 prohibitions are grep-tier (verified this run). Plans 01–04 judgment-tier items were human-passed as UAT row 26.
|
||||
|
||||
| Plan | Prohibition | Verdict |
|
||||
|------|-------------|---------|
|
||||
| 05 | Do not keep inactive tab panels mounted with v-show | holds (`v-show` count 0; `panelFields` still filters) |
|
||||
| 05 | Do not edit 19.6.1-01/02/03/04-PLAN.md; no cabana Go, pact, phrasebook, YAML, OpenAPI; no new npm dependency | holds (git log since prior `verified:` empty on those paths and `admin/package.json`) |
|
||||
| 05 | Framework code, READMEs, docs and tests name no consuming application | holds (fonoteka/plytarium/grzyby/wavepath count 0 on the six plan-05 source/test files) |
|
||||
| 01–04 | judgment-tier set from the prior report | human-passed (UAT row 26) |
|
||||
|
||||
### Test Quality Audit
|
||||
|
||||
| Test File | Linked Req | Active | Skipped | Circular | Assertion Level | Verdict |
|
||||
|-----------|-----------|--------|---------|----------|-----------------|---------|
|
||||
| FormView.test.ts#keeps a picked relation label after switching tabs | G-19.6.1-T2 / T2-1 | yes | 0 | no | behavioral (pick Acme Works, Details tab, back, combobox is name not `1`) | sufficient |
|
||||
| RelationField.test.ts#shows a picked label after remount when the form remembered it | T2-2 | yes | 0 | no | behavioral (choose writes bag, remount with bag labels, value is name not `1`) | sufficient |
|
||||
| Plan 03/04 named rule tests | D-03..D-21, CR-01, WR-03 | yes | 0 | no | behavioral | sufficient (prior pass; files unchanged) |
|
||||
|
||||
**Disabled tests on requirements:** 0 (`it.skip` / `test.todo` none in the two plan-05 test files)
|
||||
**Circular patterns detected:** 0
|
||||
**Insufficient assertions:** 0
|
||||
|
||||
The FormView case uses the widgets fixture (`maker` on default, `serial` on Details). That is the same one-panel remount path the Administrators form uses (`role` on Account, permissions on Permissions). Fixture supplies the same shape the real form has — not coincidental-reliance.
|
||||
|
||||
### Anti-Patterns Found
|
||||
|
||||
| File | Line | Pattern | Severity | Impact |
|
||||
|------|------|---------|----------|--------|
|
||||
| modules/cabana/backend_users_admin.go, backend_privileges.go | — | Ceilings use the owner's full grants under a scoped personal token (WR-01) | ⚠️ Warning | Pre-gap-closure; files not modified in plan 05 |
|
||||
| modules/cabana/backend_users_admin.go | — | Stored override values other than 1/-1 dropped on save (WR-02) | ⚠️ Warning | Same as prior pass |
|
||||
| modules/cabana/backend_privileges.go | — | Last-superuser count relies on READ COMMITTED (IN-01) | ℹ️ Info | |
|
||||
| modules/cabana/backend_users_admin.go / crud.go | — | Re-delete of a trashed admin reports success, bumps tokens (IN-02) | ℹ️ Info | |
|
||||
| modules/cabana/backend_roles_admin.go | — | Unlocked code-uniqueness and holder count (IN-03, IN-04) | ℹ️ Info | |
|
||||
| modules/cabana/backend_users_admin.go | — | toggleOn reads unknown encodings as off (IN-05) | ℹ️ Info | |
|
||||
| modules/cabana/backend_users_admin.go | — | Own role picker editable, refused only on save (IN-06) | ℹ️ Info | UX |
|
||||
|
||||
No TBD/FIXME/XXX/TODO/HACK markers in the files plan 05 modified. No consuming-application names. Code review of plan 05 was clean (`587f9dd` / 19.6.1-REVIEW.md status clean).
|
||||
|
||||
### Human Verification Required
|
||||
|
||||
Recorded UAT (`19.6.1-UAT.md`, `recorded_at` 2026-10-22T12:30:13.000Z, status complete, 25 pass / 1 issue) still has test 2 as `issue`. `changed_since_uat`: `RelationField.vue`, `formContext.ts`, `RelationChildModal.vue`, `FormView.vue`, `modules/boardwalk/dist` — those files are exactly the T2 remount fix and they bear on test 2.
|
||||
|
||||
Roles (row 6) stays settled: the Roles form has no relation field (name/code/description/permissioneditor only). Plan 05's remember-label path is unused there. `backend_roles_admin.go` is not in `changed_since_uat` for this recorded_at. Judgment-tier prohibitions (row 26) passed and plan 05's new prohibitions are grep-tier, verified above.
|
||||
|
||||
The plan-02 harvested `<human-check>` (superuser switch / locked rows) is UAT rows 3 and 5 — already passed.
|
||||
|
||||
### 1. Create an administrator
|
||||
|
||||
**Test:** Create an administrator
|
||||
**Expected:** Create opens the form with login, email, name, password + confirmation, role, a Superuser switch and Permission overrides. Saving with a mismatched or 3-character password shows a field error. Saving a valid admin (role e.g. developer, Superuser off) lands on the record and shows a success toast. After picking Developer and switching to Permissions and back, the role dropdown still shows Developer, not the raw id.
|
||||
**Why human:** UAT row 2 is still `issue`. Plan 05 closed the remount path in code and in vitest (widgets `maker`/`serial`). The human has not re-run the Administrators form. Do not invent a UAT pass.
|
||||
|
||||
UAT row 8's note that CR-01 is a known open gap is stale: that hole is closed on the server (plan 04). Do not fail the limited-admin visual re-check on CR-01.
|
||||
|
||||
### Gaps Summary
|
||||
|
||||
**No blocking gaps.** G-19.6.1-T2 is closed in the SPA and the embedded dist. The remaining item is a recorded UAT issue the human has not re-checked after plan 05. That is `human_needed`, not `gaps_found`.
|
||||
|
||||
Later phases do not cover this UAT row: 19.7 consumes the Administrators action seam; 19.8 is console; 20 is the demo instance. Do not defer the browser re-check.
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-10-22T12:58:00Z_
|
||||
_Verifier: Claude (msd-verifier)_
|
||||
@@ -0,0 +1,8 @@
|
||||
# Deferred items: Phase 19.6.1
|
||||
|
||||
Out-of-scope findings logged during execution. Not fixed in this phase.
|
||||
|
||||
## From 19.6.1-03 (tests)
|
||||
|
||||
- **lagoon: the model validator does not apply string `min`/`max`.** `lagoon.Validate` (modules/lagoon/validate.go) collects `min=`/`max=` tags for non-numeric rules and then skips them, so a model or `pact.FormRules` rule such as `min:4` or `max:255` on a string never refuses a value (only `between` is checked by length). The request validator (`validate_request.go`) handles them. Found because the Administrators form's `password` rule `min:4` let a 3-character password through; 19.6.1-03 fixed that one rule locally in `usersAdmin.storePassword` (commit 461cb21). The lagoon fix changes behaviour for every model with string length rules (an over-long `login` currently reaches Postgres and fails as a 500 instead of a 422), so it needs its own change and a check of the consuming applications.
|
||||
- **cabana: `granted` does not expand a held leading wildcard.** A holder grant `*.manage` does not grant `acme.manage` (`granted` in contracts.go only expands held trailing wildcards). Pre-existing; WinterCMS parity unverified. TestRoleCeiling does not pin either behaviour.
|
||||
114
.planning/phases/19.7-generic-mcp-module/.continue-here.md
Normal file
114
.planning/phases/19.7-generic-mcp-module/.continue-here.md
Normal file
@@ -0,0 +1,114 @@
|
||||
---
|
||||
context: phase
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 19.7-09
|
||||
task: 0
|
||||
total_tasks: 4
|
||||
status: paused
|
||||
last_updated: 2026-10-23T15:13:42.099Z
|
||||
---
|
||||
|
||||
# Phase 19.7: paused before gap plan 19.7-09
|
||||
|
||||
## Critical Anti-Patterns
|
||||
|
||||
| Pattern | Description | Severity | Prevention Mechanism |
|
||||
|---------|-------------|----------|---------------------|
|
||||
| Tagging before full verification | The user will not accept a v0.5.0 that is bumped to v0.5.1 right after because verification found something. The plan 05 security review marked T-19.7-22 as verified, and a deep code review then found 3 critical issues. | blocking | Tag nothing until every gate below is green and its findings are fixed: the re-review of plans 06-09, the regression gate, msd-verifier, /msd-validate-phase and /msd-verify-work (UAT). Only then ask the user about v0.5.0. |
|
||||
| Mid-phase framework tag | v0.5.0 is reserved for phase completion. The release order is decided: framework v0.5.0, then sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin tags that require it, then the app pointer bumps. | blocking | No tag, push or deploy step inside plan 09. The release happens only after phase verification, and only on the user's go-ahead. |
|
||||
| Plan drift on versions | Plans written earlier named versions that were already taken (v0.1.9) or tags that were never cut ("plan-02 tag"). | advisory | Before dispatching an executor, check the current tags (`git tag`, `ls-remote`) and pass the corrections in the executor prompt. |
|
||||
|
||||
<current_state>
|
||||
Phase 19.7 (Generic MCP module) is at 8 of 9 plans complete.
|
||||
|
||||
- Plans 01-05 are the original phase. 01-02 are released in framework v0.4.4. 03 released sm-user-plugin v0.1.10. 04 released sm-oauthserver-plugin v0.1.2 and sm-journal-plugin v0.2.3. 05 added the unit tests, the check-phase19.7.sh gate and the security review.
|
||||
- A deep 3-lane code review (19.7-REVIEW.md: 3 critical, 17 warning, 20 info) led to gap-closure plans 06-09 (19.7-GAP-INPUTS.md). They also carry two sm-servers-app escalations: E-1, an organisation logo, and E-2, plugin-declared scopes for member usr_ tokens.
|
||||
- Gap plans 06, 07 and 08 are executed and summarized. **19.7-09 is the next plan and has not started.** It covers tests for every fix and for E-1/E-2, the extended gate, the validation rows, and the corrected security docs.
|
||||
</current_state>
|
||||
|
||||
<completed_work>
|
||||
- 19.7-03: the user-plugin identity chain; sm-user-plugin v0.1.10 tagged and pushed; five apps bumped (local commits).
|
||||
- Fast fix d96c726: cabana subject events now fire as `*pact.MCPSubjectChanged` after commit.
|
||||
- 19.7-04: oauthserver v0.1.2 and Journal v0.2.3 tagged and pushed; vue-demo-app pushed; demo MCP wiring, nginx and DEPLOY.md.
|
||||
- 19.7-05: tests, the gate, the security review, and 3 framework fixes (c49983d, 1111828, c29d228).
|
||||
- Code review: 19.7-REVIEW.md (fef1cbb). Regression gate green at that point.
|
||||
- Gap plans:
|
||||
- 19.7-06: pier hardening, lane A (commits 2bf9dca..95f177b; SUMMARY 6ca9e17).
|
||||
- 19.7-07: auth_time, the pact.HasFrontendTokenScopes seam, cabana and the admin SPA, lane B (c14238b..88559d5; SUMMARY d6c7fd5).
|
||||
- 19.7-08: the plugins and demo, lane C, plus E-1 and E-2 (SUMMARY 1e5d9d4). Commits:
|
||||
- user: 32f9259, 970719c, ee5c096, f20a8d3
|
||||
- oauthserver: 671513d
|
||||
- journal: b129902
|
||||
- vue-demo-app: 0125e29
|
||||
- sm-demo-app: 00f57bf, 3b569a1, 7731641
|
||||
</completed_work>
|
||||
|
||||
<remaining_work>
|
||||
1. Execute 19.7-09 (`/msd-execute-phase 19.7 --gaps-only`). Notes for its executor, from the 08 SUMMARY:
|
||||
- write the named revocation tests (TestMCPVerifierRevocation, TestMCPGrantRevocation, TestAccessRevocation);
|
||||
- write unit tests for linkCode.ts and OrganisationLogoFields;
|
||||
- remove the now-unused `connectWatching` helper in the demo e2e test;
|
||||
- record as deferred: `admin:token:revoke` fires no MCP event (from 07), B-IN-05, B-IN-06.
|
||||
2. Fresh code review of the gap-closure changes (06-09) across all repos; fix its findings.
|
||||
3. Regression gate:
|
||||
- `go vet` and `go test ./...` with and without `-tags summercms_mcp`;
|
||||
- examples/hello;
|
||||
- check-phase19.6.1.sh and check-phase19.7.sh `--all`;
|
||||
- check-admin-openapi.sh, check-admin-dist.sh, `summer docs:build --check`.
|
||||
4. Phase-goal verification (msd-verifier → 19.7-VERIFICATION.md), then Nyquist validation (/msd-validate-phase 19.7), then UAT with the user (/msd-verify-work 19.7). UAT must include a real MCP client against the local demo; plan 04 skipped that check.
|
||||
5. Decide on the deferred items in deferred-items.md that could block v0.5.0 (the user decides each one).
|
||||
6. Only then, on the user's go-ahead:
|
||||
- tag framework v0.5.0 and post the changelog (CLAUDE.md);
|
||||
- tag the plugins requiring v0.5.0;
|
||||
- bump the apps, including the sm-demo-app submodule pointers for user, oauthserver, journal and vue-demo-app;
|
||||
- g15office sync: move tasks hmguritm and tqyvnzxx into milestone dcnv4mha and post the phase comment.
|
||||
</remaining_work>
|
||||
|
||||
<decisions_made>
|
||||
- v0.5.0 is tagged only after full verification and validation (user, 2026-10-23; saved in memory).
|
||||
- Gap closure is 4 plans. 07 depends on 06 because of file overlap, so the waves run 1/2/3/4. The user approved this.
|
||||
- Every critical and warning finding is fixed; info findings are fixed where cheap, otherwise deferred with a reason.
|
||||
- E-2 uses a separate `pact.HasFrontendTokenScopes`, not cabana's HasTokenScopes (note .planning/notes/2026-10-23-frontend-token-scopes.md). `MintAPITokenFor(app, …)` is scoped to the app; the legacy MintAPIToken uses a process-wide fallback.
|
||||
- E-1 adds the logo as a second attachment beside avatar, delivered as the helpers OrganisationLogoURL and OrganisationLogoFields. The plugin serves no organisation payload.
|
||||
- A ban or password reset revokes MCP AND OIDC grants (user, 2026-10-23). A link change revokes backend-scoped MCP grants.
|
||||
- `auth_time` is set at sign-in and copied unchanged by refresh. Sessions issued before the upgrade must sign in again before linking.
|
||||
</decisions_made>
|
||||
|
||||
<blockers>
|
||||
- None technical.
|
||||
- **Everything since the last pushes is local and unpushed** (see Infrastructure State). If the next session runs on a different machine, these commits must be pushed first, with the user's go-ahead (CLAUDE.md: no push without go-ahead).
|
||||
</blockers>
|
||||
|
||||
## Required Reading (in order)
|
||||
|
||||
1. `.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md`: gap scope, escalations, decisions, release order
|
||||
2. `19.7-REVIEW.md`: the findings 06-09 fix
|
||||
3. `19.7-06-SUMMARY.md`, `19.7-07-SUMMARY.md`, `19.7-08-SUMMARY.md`: what was done and the deviations
|
||||
4. `19.7-09-PLAN.md`: the next plan
|
||||
5. `deferred-items.md`
|
||||
6. Memory: release-tag-only-at-phase-completion
|
||||
|
||||
## Infrastructure State
|
||||
|
||||
Last measured 2026-10-23T15:13Z. Nothing is pushed beyond the tags listed above.
|
||||
|
||||
| Repo | Branch @ HEAD | Ahead of origin | Uncommitted |
|
||||
|---|---|---|---|
|
||||
| summercms.go | master | 42 | `.planning/state.json` (another session's), `.msd/`, two `.gitkeep` |
|
||||
| sm-user-plugin (sm-demo-app/plugins/golem15/user) | master @ f20a8d3 | 5 | clean |
|
||||
| sm-oauthserver-plugin | master @ 671513d | 2 | `go.work`: tracked file, its user replace was pointed at ../sm-demo-app/plugins/golem15/user for local dev. Restore it or decide its fate before release |
|
||||
| sm-journal-plugin | main @ b129902 | 2 | `go.work.sum` (untracked, not ours) |
|
||||
| sm-demo-app | master @ 7731641 | 12 | `main.go` (another session's); submodule checkouts user/oauthserver/journal moved to local commits, and their pointers are bumped only at release |
|
||||
| vue-demo-app | master @ 0125e29 | 1 | clean. Must be pushed before sm-demo-app 00f57bf |
|
||||
| fonoteka.go | master @ 06bc9d0 | 35 | clean |
|
||||
| sm-bm-app, sm-grzybyfunkcjonalne-app, sm-summercmsio-app | master | 1 each (the plugin v0.1.10 bump) | unrelated untracked files |
|
||||
|
||||
Tools: the msd CLI is `node ~/.claude/msd-core/bin/msd-tools.cjs` (no msd_run on PATH). Docker tests run directly (socket available); fall back to `sudo -u golem` if the socket is denied.
|
||||
|
||||
<context>
|
||||
Execution model: the orchestrator dispatches one msd-executor per plan, sequentially on the main tree (workflow.use_worktrees=false). It passes the drift corrections in the prompt and updates ROADMAP/STATE through msd-tools after each plan ("docs(phase-19.7): update tracking after gap wave N"). Plan 09 is autonomous, with no checkpoints. The user wants evidence-backed gates and dislikes surprise version bumps.
|
||||
</context>
|
||||
|
||||
<next_action>
|
||||
Start with: confirm the repos above are present at the listed HEADs on this machine (push or pull first if moving machines, with the user's go-ahead). Then run `/msd-execute-phase 19.7 --gaps-only`; it will pick up 19.7-09.
|
||||
</next_action>
|
||||
475
.planning/phases/19.7-generic-mcp-module/19.7-01-PLAN.md
Normal file
475
.planning/phases/19.7-generic-mcp-module/19.7-01-PLAN.md
Normal file
@@ -0,0 +1,475 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- modules/bouncer/dispatch.go
|
||||
- modules/bouncer/registry.go
|
||||
- modules/bouncer/dispatch_smoke_test.go
|
||||
- modules/bouncer/README.md
|
||||
- modules/cabana/token_guard.go
|
||||
- modules/cabana/token_resolver.go
|
||||
- modules/cabana/dispatch_smoke_test.go
|
||||
- modules/cabana/action_extensions.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/schema_types.go
|
||||
- modules/cabana/account_contributions.go
|
||||
- modules/cabana/account_contributions_smoke_test.go
|
||||
- modules/cabana/record_action_prompt_smoke_test.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- modules/cabana/subject_events.go
|
||||
- modules/cabana/README.md
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/mcp.go
|
||||
- modules/pact/capabilities_test.go
|
||||
- modules/pact/README.md
|
||||
- modules/surf/router.go
|
||||
- modules/surf/routetable.go
|
||||
- modules/surf/streaming.go
|
||||
- modules/surf/pier_off.go
|
||||
- modules/surf/dispatch_smoke_test.go
|
||||
- modules/surf/streaming_smoke_test.go
|
||||
- modules/surf/pier_mount_smoke_test.go
|
||||
- modules/surf/README.md
|
||||
- modules/wristband/authorize.go
|
||||
- modules/wristband/server.go
|
||||
- modules/wristband/mcp_scopes_smoke_test.go
|
||||
- modules/wristband/README.md
|
||||
- modules/cooler/cooler.go
|
||||
- modules/cooler/README.md
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml
|
||||
- modules/phrasebook/backend/lang/pl/lang.yaml
|
||||
- admin/src/components/ui/confirm.ts
|
||||
- admin/src/components/ui/ConfirmDialog.vue
|
||||
- admin/src/components/form/RecordActions.vue
|
||||
- admin/src/components/account/AccountContributions.vue
|
||||
- admin/src/views/AccountView.vue
|
||||
- admin/src/api/types.ts
|
||||
- admin/src/api/schema.d.ts
|
||||
- admin/openapi/admin.json
|
||||
- admin/tests/account/AccountContributions.test.ts
|
||||
- admin/tests/form/RecordActionsPrompt.test.ts
|
||||
- modules/boardwalk/dist
|
||||
- docs/services/authentication.md
|
||||
- docs/services/routing.md
|
||||
- docs/services/oauth-server.md
|
||||
- docs/plugins/registration.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- docs/backend/users-and-permissions.md
|
||||
autonomous: true
|
||||
requirements: [SC-1, SC-3, SC-4, D-04, D-09, D-17, D-28, D-30, D-33, D-34, D-36]
|
||||
|
||||
estimate:
|
||||
tokens: 75000
|
||||
raw_tokens: 75000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "An in-process dispatch that carries the bouncer dispatch marker reaches a guarded route handler as the pre-resolved principal, while an HTTP request carrying any header is never treated as dispatched (D-17; the marker is context-only and only a guard name the marker lists is honoured)"
|
||||
- "surf can hand out the compiled middleware chain of one registered route by method and pattern, and a route of the new streaming kind flushes its bytes to the client while the handler is still running (SC-1 Pitfall 1; D-10 dispatch runs the same chain as HTTP)"
|
||||
- "With mcp.enabled false (the default) BuildRouter mounts nothing new and every existing route table, payload and test is unchanged (D-30); with mcp.enabled true and no summercms_mcp tag, boot fails with an error naming the tag (D-33)"
|
||||
- "A plugin can declare MCP tools and prompts, frontend permission codes, My Profile contributions and a prompted record action through pact types that import neither the MCP SDK nor jsonschema-go (D-28, D-09, D-04, D-34; SC-2 contract side)"
|
||||
- "A plugin's My Profile contribution is listed and run through two new cabana account routes, and the existing /account*, /auth/me and record payloads are byte-identical to before (D-04 additive seam)"
|
||||
- "A contributed record action with a Prompt asks the admin for one text value in the confirm dialog and hands it to Run; actions without a Prompt keep their exact payload and body (D-34 set-link input, planner decision P-01)"
|
||||
- "wristband's MCP authorize accepts exactly the scopes of Options.ScopesSupported, whose default is unchanged (D-21 framework side, Pitfall 5)"
|
||||
artifacts:
|
||||
- path: "modules/bouncer/dispatch.go"
|
||||
provides: "Dispatch, WithDispatch, Dispatched: the context-only pre-resolved principal marker (D-17)"
|
||||
contains: "func WithDispatch("
|
||||
- path: "modules/surf/streaming.go"
|
||||
provides: "MountStream and recoverStream: the non-buffering route kind"
|
||||
contains: "func (r *Router) MountStream("
|
||||
- path: "modules/surf/routetable.go"
|
||||
provides: "Handler(method, pattern): the compiled chain lookup"
|
||||
contains: "func (r *Router) Handler("
|
||||
- path: "modules/surf/pier_off.go"
|
||||
provides: "the untagged side of the pier mount hook, boot error naming summercms_mcp"
|
||||
contains: "!summercms_mcp"
|
||||
- path: "modules/pact/mcp.go"
|
||||
provides: "HasMCP, MCP, MCPTool, MCPPrompt, MCPGuard, MCPGuards, MCPSubject, MCPDispatch, MCPTokenVerifier, MCPGrant, MCPPersonalTokenResolver, MCPLinkedBackendResolver, LinkedBackendUser, MCPSubjectChanged, HasFrontendPermissions, FrontendPermission"
|
||||
contains: "type HasMCP interface"
|
||||
- path: "modules/pact/capabilities.go"
|
||||
provides: "AdminActionPrompt, AdminRecordAction.Prompt, AdminRecordActionInput.Value, HasAccountContributions, AccountContribution, AccountAction, AccountActionInput, AccountActionResult"
|
||||
contains: "type HasAccountContributions interface"
|
||||
- path: "modules/cabana/account_contributions.go"
|
||||
provides: "compileAccountContributions and the two account contribution handlers"
|
||||
contains: "func compileAccountContributions("
|
||||
- path: "modules/cabana/token_resolver.go"
|
||||
provides: "ResolveBackendToken, ScopeLimitFor, BackendPrincipal (additive resolvers pier uses)"
|
||||
contains: "func ResolveBackendToken("
|
||||
- path: "modules/wristband/authorize.go"
|
||||
provides: "parseAuthorizeScopes over the server's allowed set built from Options.ScopesSupported"
|
||||
contains: "ScopesSupported"
|
||||
- path: "admin/src/components/account/AccountContributions.vue"
|
||||
provides: "the generic My Profile contributions section"
|
||||
key_links:
|
||||
- from: "modules/bouncer/registry.go"
|
||||
to: "modules/bouncer/dispatch.go"
|
||||
via: "Registry.Middleware consults Dispatched(ctx, name) before authenticate(ng.g, r)"
|
||||
pattern: "Dispatched\\(r\\.Context\\(\\), name\\)"
|
||||
- from: "modules/cabana/token_guard.go"
|
||||
to: "modules/bouncer/dispatch.go"
|
||||
via: "ResolveBackend takes a backend-kind marker before the bearer short-circuit"
|
||||
pattern: "bouncer\\.Dispatched\\("
|
||||
- from: "modules/surf/router.go"
|
||||
to: "modules/surf/pier_off.go"
|
||||
via: "BuildRouter calls the mountPier hook after cabana.Activate and before the wrap validation loop"
|
||||
pattern: "mountPier"
|
||||
- from: "modules/cabana/http.go"
|
||||
to: "modules/cabana/account_contributions.go"
|
||||
via: "GET /account/contributions and POST /account/contributions/{name}/actions/{action} behind interactiveOnly"
|
||||
pattern: "account/contributions"
|
||||
- from: "admin/src/components/form/RecordActions.vue"
|
||||
to: "modules/cabana/actions.go"
|
||||
via: "a prompted action posts body {payload: <string>}; cabana decodes it only for actions that declare a Prompt"
|
||||
pattern: "payload"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: jsonschema-go -->
|
||||
<!-- planner-discipline-allow: modelcontextprotocol -->
|
||||
<!-- planner-discipline-allow: modules/bouncer -->
|
||||
<!-- planner-discipline-allow: v-html -->
|
||||
|
||||
<objective>
|
||||
Lay every framework seam Phase 19.7 needs before the `pier` module can exist, in `summercms.go` only, additively: the D-17 dispatch marker in bouncer and cabana, surf's compiled-handler lookup and a non-buffering streaming route kind plus the tagged pier mount hook (D-30, D-33), the SDK-free `pact` contracts for MCP tools and prompts, guard providers, token verifiers, the link resolver and the subject-changed event (D-28, D-09), the generic My Profile contribution seam (D-04 part 1), a prompted record action on the 19.6.1 seam (D-34), wristband's configurable MCP scope allow-list (D-21 framework side), and a tiny cooler export for pier's Redis keys.
|
||||
|
||||
**Planner decision P-01 (the "set link" input gap, D-34):** 19.6.1's `pact.AdminActionExtension` record actions carry no input, and D-34 says admins set and remove links on the Administrators screen through that seam. "Remove link" fits a plain record action. "Set link" needs one value (which frontend user). The smallest additive framework change is a **prompted record action**: `pact.AdminRecordAction` gains an optional `Prompt *pact.AdminActionPrompt` (label, placeholder, comment, max length; phrase keys or text) and `pact.AdminRecordActionInput` gains `Value string`. The record response's `meta.actions[]` entry gains `prompt` only when set; the SPA confirm dialog shows one text input for such an action and posts the existing `AdminActionRequest` key `payload` as a JSON string; cabana accepts `payload` only for a prompted action (the 422 refusal for every other record action is unchanged), trims it, refuses an empty or over-long value with 422 on `payload`, and hands it to `Run` as `Value`. No console command is the only way to link: plan 03's `link_frontend_account` action uses this Prompt and `unlink_frontend_account` is a plain Danger action.
|
||||
|
||||
**Planner decision P-02 (My Profile seam shape, D-04 part 1, Claude's discretion):** a contribution interface, not an `AdminController` extension: `pact.HasAccountContributions` returns `[]pact.AccountContribution{Name, Label, Description, Status, Actions}`; each `pact.AccountAction{Name, Label, Confirm, Danger, Permissions, Applies, Run}` runs for the signed-in admin only (`AccountActionInput{AdminID}`) and may answer a `URL` the SPA opens in a new tab (the link-proof site URL of D-05). Names are generic; cabana never names the user plugin or MCP.
|
||||
|
||||
**Planner decision P-03 (marker shape, D-17):** `bouncer.Dispatch{Guards []string, Principal *Principal, Credential any}` under an unexported context key; `WithDispatch` is the only setter (the phase gate in plan 05 proves only `modules/pier` and tests call it) and `Dispatched(ctx, guardName)` the reader, which answers only when the marker lists that exact guard name. bouncer's `Registry.Middleware` and cabana's `ResolveBackend` honour it, so the user plugin's `user.api_token` (the bouncer `api_token` guard) and Journal's `requireBackendPrincipal` need no code change for the marker; Journal's `optionalBackendPrincipal` short-circuit is plan 04's one-line fix.
|
||||
|
||||
**Planner decision P-04 (pact stays SDK-free, D-33):** every plugin-facing type lands in `modules/pact` with no import of the MCP SDK, jsonschema-go or bouncer; `pact.MCPDispatch.Principal` is `any` (pier asserts `*bouncer.Principal`). Guard providers register in a `*pact.MCPGuards` registry published on the app (find-or-publish pattern), the `oas_at_` verifier is published as `pact.MCPTokenVerifier`, the personal-token resolver as `pact.MCPPersonalTokenResolver`, the link service as `pact.MCPLinkedBackendResolver`, and plugins fire `pact.MCPSubjectChanged` on the festival bus.
|
||||
|
||||
Purpose: plans 02-04 build on published contracts instead of discovering them; the framework release in plan 02 carries these seams together with 19.6.1.
|
||||
Output: the seams above, their smoke tests (unit tests proper are plan 05), README and docs updates in the same commits, the regenerated admin OpenAPI and the rebuilt `modules/boardwalk/dist`.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<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-PATTERNS.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md
|
||||
@.planning/phases/19.6.1-backend-administrators-screen/19.6.1-04-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Several Claude sessions work in this repo at once. Before touching `modules/cabana`, `modules/surf` or `admin/`, run `git status --short` and leave other sessions' uncommitted edits alone. Never edit `admin/src/state/useSettings.ts` or `admin/src/components/shell/SettingsPanel.vue` (a quick task owns them).
|
||||
- Stage files by explicit path, never `git add -A`. One logical change per commit; planning docs and code in separate commits; no co-author tags. Do not push or tag in this plan.
|
||||
- Framework code, READMEs and docs never name a consuming application or a specific plugin (use `acme`/`blog`). The docs checker (`go run ./cmd/summer docs:build --check`) refuses a Go code block without `src=` and an identifier that does not exist; a module API change updates that module's README and the affected docs page in the same commit.
|
||||
- `go vet ./...` and `go test -short ./...` green at every commit. A change in `admin/` rebuilds `modules/boardwalk/dist` (`npm --prefix admin run build`) in the same task and passes `scripts/check-admin-dist.sh`; a swag annotation change passes `scripts/check-admin-openapi.sh`.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: an in-process dispatch with the bouncer marker runs a guarded route through surf's compiled chain as the pre-resolved principal</name>
|
||||
<reversibility rating="costly">Three auth paths (bouncer registry, cabana ResolveBackend, and through them user.api_token and Journal) learn the marker; D-17 recorded this as costly, the user already chose it.</reversibility>
|
||||
<files>modules/bouncer/dispatch.go, modules/bouncer/registry.go, modules/bouncer/dispatch_smoke_test.go, modules/bouncer/README.md, modules/cabana/token_guard.go, modules/cabana/token_resolver.go, modules/cabana/dispatch_smoke_test.go, modules/cabana/README.md, modules/surf/router.go, modules/surf/routetable.go, modules/surf/dispatch_smoke_test.go, modules/surf/README.md, docs/services/authentication.md, docs/services/routing.md</files>
|
||||
<read_first>
|
||||
- modules/bouncer/context.go (the unexported-key pattern: userKey, WithUser, User)
|
||||
- modules/bouncer/registry.go (Middleware at lines 73-102: where authenticate(ng.g, r) runs)
|
||||
- modules/bouncer/guard.go (Guard, CredentialGuard, UnauthorizedWriter)
|
||||
- modules/cabana/token_guard.go (ResolveBackend 199-227, authenticateToken 76-125, interactiveOnly, logTokenAuth)
|
||||
- modules/cabana/token_scopes.go (methodFilterScopes, the Registry.tokenScopes table)
|
||||
- modules/cabana/auth.go lines 30-70 (BackendUsers.FindByID overlaying the admin's own permissions; the lazyBackendUsers provider in http.go 150-185)
|
||||
- modules/surf/router.go (route struct 38-49, compile 354-394, wrap 408-491, BuildRouter 600-665)
|
||||
- modules/surf/routetable.go (Routes, RouteInfo)
|
||||
- modules/surf/overlap.go 397-422 (SetPathValue and Pattern before calling a compiled handler)
|
||||
- modules/surf/apidocs_test.go (fake plugin + transportApp test shape)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pattern 3" and § "Pattern 6" and the Security Domain rows "Forged dispatch marker" and "Frontend marker accepted by a backend guard"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "FW/modules/bouncer/dispatch.go" and § "FW/modules/cabana/token_guard.go" and § "FW/modules/surf/router.go"
|
||||
- docs/services/authentication.md § "Guards and middleware" and docs/services/routing.md § "Testing and listing routes"
|
||||
</read_first>
|
||||
<action>
|
||||
Implement D-17 and the surf lookup as one proven slice (planner decision P-03).
|
||||
|
||||
bouncer (`modules/bouncer/dispatch.go`, new): `type Dispatch struct { Guards []string; Principal *Principal; Credential any }`; `func WithDispatch(ctx context.Context, d *Dispatch) context.Context` stores it under an unexported `dispatchKey struct{}` (nil ctx becomes Background, as WithUser does); `func Dispatched(ctx context.Context, guard string) (*Dispatch, bool)` returns the marker only when `d.Principal != nil` and `guard` is one of `d.Guards` (exact string compare, no wildcard). Document in the type comment that the marker is context-only, that nothing reads a header, cookie or query for it, and that only an in-process dispatcher may set it. In `registry.go` `Middleware`, before `authenticate(ng.g, r)`: `if d, ok := Dispatched(r.Context(), name); ok` then use `d.Principal` and `d.Credential` (WithUser, WithCredential when non-nil) and call next; no guard method runs. Keep every existing error string.
|
||||
|
||||
cabana: in `token_guard.go` `ResolveBackend`, before the `authorizationBearer(r) == ""` short-circuit, take `bouncer.Dispatched(r.Context(), "backend")`; when present, require `d.Principal.Backend == true` (a frontend marker is refused with ErrUnauthenticated), apply the existing cover check (`scopeCoversAll` when `Scope != nil && !Scope.Full`) and return `r.WithContext(...)` exactly as lines 222-226 do, with the credential when non-nil. New file `token_resolver.go` (additive exports pier uses; names are final): `func ResolveBackendToken(ctx context.Context, app *backpack.App, raw string) (*bouncer.Principal, *BackendAPIToken, []string, error)` resolves a `g15_` token without the method filter (same `wellFormedAPIToken`, `hashAPIToken`, `FindUsableByHash`, constant-time compare, `users.FindByID`, `stampLastUsed`, `logTokenAuth` with path "mcp" when the request is absent — pass a nil-safe logging variant) and returns the stored scope names; `func ScopeLimitFor(app *backpack.App, scopes []string, method string) (*bouncer.ScopeLimit, int, int)` wraps `methodFilterScopes(reg.tokenScopes, scopes, method)` using the Registry looked up from the app; `func BackendPrincipal(ctx context.Context, app *backpack.App, id uint) (*bouncer.Principal, error)` returns the admin principal through the published backend users provider (Backend, IsSuperuser, PermissionGrants set; nil, nil when the admin does not exist or is deactivated). Reuse the resolver cabana publishes (`*backendResolver` holds the composite guard; add unexported accessors rather than duplicating the lookups).
|
||||
|
||||
surf: add `handlers map[string]http.Handler` to Router, filled by a new `compileHandlers() error` that wraps every route once (key `method + " " + path`) and is called by `compile()` (which then uses the map) and by BuildRouter's validation loop (replace the throwaway `r.wrap(rt)` loop with `compileHandlers`); add `func (r *Router) Handler(method, pattern string) (http.Handler, bool)` in `routetable.go` (nil-safe; false before compile). Do not change route ordering, overlap families or the mux.
|
||||
|
||||
Smoke tests (`-short`, no Docker): `modules/surf/dispatch_smoke_test.go` `TestDispatchSmoke`: a fake plugin registers a bouncer guard `acme` (a CredentialGuard whose AuthenticateCredential always fails and which implements UnauthorizedWriter with a 401 JSON body) under middleware name `acme.auth`, and a route `GET /acme/items/{id}` behind it whose handler writes `bouncer.User(ctx).ID` and `r.PathValue("id")`; after `BuildRouter` + `compileHandlers` (through `Assemble` or the exported path the test needs), `Handler("GET", "/acme/items/{id}")` is found; a request built with `httptest.NewRequest`, `SetPathValue("id","7")`, `Pattern` set, and a context carrying `WithDispatch(&Dispatch{Guards: []string{"acme"}, Principal: &Principal{ID: 42}})` answers 200 with id 42 and 7; the same request without the marker answers 401; a request with headers `X-Summer-Dispatch: 42`, `Authorization: Dispatch 42` and a cookie answers 401 (nothing reads headers); a marker listing guard `other` answers 401. `modules/bouncer/dispatch_smoke_test.go` `TestDispatchedSmoke`: Dispatched returns false for a nil principal, an unlisted guard and a plain context. `modules/cabana/dispatch_smoke_test.go` `TestDispatchMarkerSmoke`: with an app that has no published resolver, `ResolveBackend(app, r-with-backend-marker, "acme.*")` returns a principal whose ID matches; the same with `Backend: false` returns ErrUnauthenticated; a scoped marker whose Scope does not cover `acme.*` returns ErrTokenScope.
|
||||
|
||||
Docs in the same commit: bouncer README (Features + API reference rows for Dispatch, WithDispatch, Dispatched), cabana README (ResolveBackendToken, ScopeLimitFor, BackendPrincipal, marker paragraph in the ResolveBackend row), surf README (Handler row), `docs/services/authentication.md` (new paragraph under "Guards and middleware": the pre-resolved principal marker, who may set it, what honours it), `docs/services/routing.md` (Handler lookup under "Testing and listing routes"). No Go code block without `src=`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/bouncer/... ./modules/cabana/... ./modules/surf/... && go test -count=1 -short -run '^(TestDispatchSmoke|TestDispatchedSmoke|TestDispatchMarkerSmoke)$' -v ./modules/surf ./modules/bouncer ./modules/cabana 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS count line is not exactly 3</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func WithDispatch(" modules/bouncer/dispatch.go` prints 1 and `grep -c "func Dispatched(" modules/bouncer/dispatch.go` prints 1
|
||||
- `grep -n "Dispatched(r.Context(), name)" modules/bouncer/registry.go` prints one line that comes before the line containing `authenticate(ng.g, r)`
|
||||
- `grep -c "bouncer.Dispatched(" modules/cabana/token_guard.go` prints 1 and `grep -c "func ResolveBackendToken(\|func ScopeLimitFor(\|func BackendPrincipal(" modules/cabana/token_resolver.go` prints 3
|
||||
- `grep -c "func (r \*Router) Handler(" modules/surf/routetable.go` prints 1 and `grep -c "func (r \*Router) compileHandlers(" modules/surf/router.go` prints 1
|
||||
- `go test -count=1 -short -run '^TestDispatchSmoke$' -v ./modules/surf 2>&1 | grep -q -- '^--- PASS: TestDispatchSmoke'`
|
||||
- `go test -count=1 -short -run '^TestDispatchMarkerSmoke$' -v ./modules/cabana 2>&1 | grep -q -- '^--- PASS: TestDispatchMarkerSmoke'`
|
||||
- Every pre-existing test in modules/bouncer, modules/cabana and modules/surf passes unchanged (no existing test file modified in this task)
|
||||
- `grep -c "Dispatched" modules/bouncer/README.md docs/services/authentication.md` prints a non-zero count for both files
|
||||
</acceptance_criteria>
|
||||
<done>A marker-carrying in-process call runs a guarded route through surf's compiled chain as the pre-resolved principal; HTTP requests cannot forge it; cabana's ResolveBackend honours a backend marker and refuses a frontend one; the handler lookup, the additive token resolvers and their docs are committed.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Streaming route kind, the tagged pier mount hook, wristband's configurable MCP scope set and cooler's key prefix export</name>
|
||||
<files>modules/surf/router.go, modules/surf/streaming.go, modules/surf/pier_off.go, modules/surf/streaming_smoke_test.go, modules/surf/pier_mount_smoke_test.go, modules/surf/README.md, modules/wristband/authorize.go, modules/wristband/server.go, modules/wristband/mcp_scopes_smoke_test.go, modules/wristband/README.md, modules/cooler/cooler.go, modules/cooler/README.md, docs/services/routing.md, docs/services/oauth-server.md</files>
|
||||
<read_first>
|
||||
- modules/surf/router.go (route struct, wrap 408-491 including the rt.raw ? recoverBare : recoverJSON choice, recoverJSON/recoverBare/bufferedResponse 786-860, BuildRouter 624-654 where mountAPIDocs and cabana.Activate run)
|
||||
- modules/surf/apidocs.go 88-165 (config-gated mount, apiDocsPath, collision check against r.seen, BindPlugin, GroupRaw)
|
||||
- modules/surf/accesslog.go (statusRecorder: Flush and Unwrap pass through; confirm the outer layers do not buffer)
|
||||
- modules/lagoon/attach/s3_on.go, s3_off.go, bucket.go 24-28 (the build-tag pattern and the exported tag constant)
|
||||
- internal/build/manifest.go 20-30 and 86-110 (build.tags) and internal/build/manifest_tags_smoke_test.go
|
||||
- modules/wristband/authorize.go 15-30 and 205-225 (authorizeAllowedScopes, parseAuthorizeScopes) and server.go 28-45, 90-105, 160-195 (Options.ScopesSupported, DefaultOptions, Metadata)
|
||||
- modules/wristband/*_test.go that cover parseAuthorizeScopes or scope errors (grep "unsupported value" and "scopes_supported")
|
||||
- modules/cooler/cooler.go 310-365 (OpenRedis, openFromConfig, RedisURLKey, keyPrefix) and modules/cooler/README.md Configuration
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pitfall 1", § "Pitfall 5", § "Pattern 1", § "Open Question 2" and CONTEXT D-30, D-33
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "FW/modules/surf/pier_on.go / pier_off.go" and § "FW/modules/wristband/authorize.go"
|
||||
</read_first>
|
||||
<action>
|
||||
surf streaming kind (Pitfall 1): add `stream bool` to `route`; in `wrap`, when `rt.stream` is set wrap with a new `recoverStream(pages, next)` (in `streaming.go`) instead of recoverJSON/recoverBare: it serves `next` directly on the real ResponseWriter (no bufferedResponse, so `http.Flusher` reaches the client), recovers a panic by writing wire's opaque 500 only when nothing has been written yet (track with a small `headerSentWriter` that records the first WriteHeader/Write and implements Flush and Unwrap), otherwise it only aborts and marks the request panicked; keep constraints, orgSlot, named middleware, body limit, locale, the CORS profile and recordPattern exactly as other routes. Add `func (r *Router) MountStream(method, path string, h http.Handler, middleware ...string) error` which registers one raw+stream route under the currently bound plugin (same validation as the raw group path, `seen` collision error naming the owner) and the `surf.MCPBuildTag = "summercms_mcp"` constant.
|
||||
|
||||
pier hook (D-30, D-33): package-level `var mountPier func(r *Router, app *backpack.App, plugins []party.Plugin) error` in `router.go`; in `BuildRouter`, after the `admin != nil` block and before `compileHandlers`, read `app.Config.Bool("mcp.enabled")`: false → nothing; true and `mountPier == nil` → return the error `surf: mcp.enabled is true but this binary was built without the summercms_mcp tag (summer.yaml build.tags)`; true and set → call it and return its error. `pier_off.go` carries `//go:build !summercms_mcp` and a comment that the tagged counterpart (plan 02's `pier_on.go`) sets the hook; it declares nothing else (the var lives in router.go so both builds compile). Also add the inline-throttle note: pier will use the existing `throttle:<max>,<minutes>` inline spelling, so no bucket registration is added here.
|
||||
|
||||
wristband (Pitfall 5, D-21): `parseAuthorizeScopes(raw string, allowed map[string]bool)`; the Server builds `allowed` from `s.opts.ScopesSupported` (empty → the four PHP defaults, so `authorizeAllowedScopes` stays as the default set and every existing test passes unchanged); `Authorize` passes the server's set. Metadata already lists `s.opts.ScopesSupported`. Smoke `TestMCPScopesSmoke`: a server whose Options.ScopesSupported appends `backend` accepts `scope=read backend` at authorize (no `invalid_scope`) and lists it in metadata; the default server still answers the unsupported-value error for `backend`.
|
||||
|
||||
cooler: export `func KeyPrefix(cfg *compass.Config) string` (wrapping keyPrefix; document the `<prefix>` rule in the README API reference) so pier's keys are `<prefix>mcp:...`; no other cooler change (pier opens Redis lazily with `cooler.OpenRedis` and `RedisURLKey`).
|
||||
|
||||
Smoke tests: `TestStreamingRouteSmoke` (surf): a stream route handler writes `event: a` + flush, waits for a channel, writes `event: b`; served through `httptest.NewServer`, a client reading the body incrementally receives the first event before the test closes the channel (a buffered route in the same test does not deliver until the handler returns); a panic after the first flush ends the body without a 500 status rewrite; a panic before any write answers 500. `TestPierMountSmoke` (surf): with `mcp.enabled` unset BuildRouter mounts no route whose pattern starts with `/mcp` or `/.well-known/oauth-protected-resource` and `Routes()` is identical to a build without the key; with `mcp.enabled: true` (and no tag in this test binary) BuildRouter's error contains `summercms_mcp`.
|
||||
|
||||
Docs in the same commits: surf README (Features: streaming route kind and the mcp hook; API reference: MountStream, MCPBuildTag; Configuration: `mcp.enabled` is read here only to call the hook), `docs/services/routing.md` (new section "Streaming routes"), wristband README + `docs/services/oauth-server.md` (ScopesSupported governs the authorize allow-list), cooler README (KeyPrefix).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/surf/... ./modules/wristband/... ./modules/cooler/... && go test -count=1 -short -run '^(TestStreamingRouteSmoke|TestPierMountSmoke|TestMCPScopesSmoke)$' -v ./modules/surf ./modules/wristband 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS count line is not exactly 3</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func (r \*Router) MountStream(" modules/surf/streaming.go` prints 1 and `grep -c "func recoverStream(" modules/surf/streaming.go` prints 1
|
||||
- `grep -c "MCPBuildTag = \"summercms_mcp\"" modules/surf/*.go` prints 1 and `head -1 modules/surf/pier_off.go` prints `//go:build !summercms_mcp`
|
||||
- `grep -c "var mountPier func" modules/surf/router.go` prints 1 and `grep -c "built without the summercms_mcp tag" modules/surf/router.go` prints 1
|
||||
- `grep -c "func parseAuthorizeScopes(raw string, allowed map\[string\]bool)" modules/wristband/authorize.go` prints 1
|
||||
- `grep -c "func KeyPrefix(" modules/cooler/cooler.go` prints 1
|
||||
- `go test -count=1 -short ./modules/wristband/...` passes with no existing wristband test modified
|
||||
- `go test -count=1 -short -run '^TestStreamingRouteSmoke$' -v ./modules/surf 2>&1 | grep -q -- '^--- PASS: TestStreamingRouteSmoke'`
|
||||
- `grep -c "Streaming routes" docs/services/routing.md` prints 1
|
||||
</acceptance_criteria>
|
||||
<done>A stream route flushes to the client mid-handler, mcp.enabled is inert without the tag and fails boot by name with it missing, wristband's MCP scope set follows Options.ScopesSupported with an unchanged default, and cooler exposes KeyPrefix; docs and READMEs updated.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: SDK-free pact contracts: MCP tools, prompts, guards, verifiers, link resolver, subject events, frontend permissions, prompted record actions and account contributions</name>
|
||||
<reversibility rating="costly">The pact types are a published framework API that plugins compile against (D-28 recorded costly; the user chose the tools/prompts/resources-ready shape).</reversibility>
|
||||
<files>modules/pact/mcp.go, modules/pact/capabilities.go, modules/pact/capabilities_test.go, modules/pact/README.md, docs/plugins/registration.md</files>
|
||||
<read_first>
|
||||
- modules/pact/capabilities.go (Permission/HasPermissions 548-558, TokenScope/HasTokenScopes 562-573, AdminActionExtension 378-412, AdminRecordAction 343-364, AdminActionInput 232-250 and its Payload comment, the import list at the top: pact imports bonfire but not bouncer)
|
||||
- modules/pact/capabilities_test.go 300-390 (compile-time discovery test shape)
|
||||
- modules/pact/README.md § "API reference"
|
||||
- docs/plugins/registration.md § "Capability interfaces"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pattern 2", § "Pattern 5", § "Pattern 6" (credential for user.scope), § "Code Examples: Annotations from method", § "Frontend tool needs a new route"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md D-09, D-10..D-16, D-23, D-26, D-28, D-34, D-35
|
||||
</read_first>
|
||||
<action>
|
||||
New file `modules/pact/mcp.go` (standard library imports only, plus nothing from the SDK, jsonschema-go or bouncer). Types, all exported, names final:
|
||||
- `HasMCP interface { MCP() MCP }`; `MCP struct { Tools []MCPTool; Prompts []MCPPrompt }` with a doc comment that resources are a later field (CONTEXT Deferred Ideas) and that the struct form keeps that addition non-breaking (D-28).
|
||||
- `MCPTool struct { Name, Title, Description string; Guard string; Method, Path string; Input any; Output any; Permissions []string; ReadOnly, Destructive, Idempotent, OpenWorld *bool }`. Doc comment lists the boot failures the module enforces (D-10 route not found, D-12 duplicate or invalid name, D-15 route not token-guarded and no Guard, Input not a struct, a `path:"x"` tag without a `{x}` segment or a segment without a tag), the argument mapping (D-11: `path:"id"` fills `{id}`, `query:"q"` goes to the query string, remaining `json` fields form the body, `jsonschema:"description"` tags describe), the result rule (D-13) and the annotation derivation (D-14: GET read-only+idempotent, PUT idempotent, DELETE destructive, nil pointer means derived).
|
||||
- `MCPPrompt struct { Name, Title, Description string; Guard string; Permissions []string; Arguments []MCPPromptArgument; Render func(ctx context.Context, args map[string]string) ([]MCPPromptMessage, error) }`, `MCPPromptArgument struct { Name, Description string; Required bool }`, `MCPPromptMessage struct { Role, Text string }` (Role `user` or `assistant`).
|
||||
- Guard providers: `MCPGuard interface { MCPGuardName() string; MCPTokenGuarded(middleware []string) bool; MCPRequirements(middleware []string) (MCPRequirements, error); MCPAllows(ctx context.Context, subject MCPSubject, req MCPRequirements, permissions []string) (bool, error); MCPDispatch(ctx context.Context, subject MCPSubject, method string) (MCPDispatch, error) }`; `MCPRequirements struct { Scopes []string; Permissions []string }`; `MCPSubject struct { Guard string; UserID uint; Scopes []string; ClientID string; TokenID uint }`; `MCPDispatch struct { Principal any; Credential any; Guards []string }` (Principal is the bouncer principal as `any`, see P-04); `MCPGuards` registry type with `NewMCPGuards()`, `Register(g MCPGuard) error` (empty or duplicate name fails with a `pact: ...` error naming the guard), `Lookup(name string) (MCPGuard, bool)`, `Names() []string` (sorted), safe for concurrent use.
|
||||
- Token verification: `MCPTokenVerifier interface { MCPVerifyToken(ctx context.Context, raw string) (MCPGrant, error); MCPResource() string }`, `MCPGrant struct { UserID uint; ClientID string; TokenID uint; Scopes []string; ExpiresAt time.Time }`, `var ErrMCPTokenInvalid = errors.New("pact: mcp token invalid")`; `MCPPersonalTokenResolver interface { MCPResolvePersonalToken(ctx context.Context, raw string) (MCPSubject, bool, error) }` (false when the prefix is not the resolver's).
|
||||
- Link: `MCPLinkedBackendResolver interface { LinkedBackendUser(ctx context.Context, frontendUserID uint) (LinkedBackendUser, bool, error) }`, `LinkedBackendUser struct { ID uint; Login string; DisplayName string }`.
|
||||
- Event: `MCPSubjectChanged struct { Guard string; UserID uint; Kind string }` with constants `MCPSubjectPermissions = "permissions"`, `MCPSubjectLink = "link"`, `MCPSubjectRevoked = "revoked"`, `MCPSubjectDeleted = "deleted"`; doc comment: fired through the festival bus by whoever changes a subject's permissions, link, grants or existence (D-26 sources).
|
||||
- Frontend permissions (D-09): `FrontendPermission struct { Code, Label, Tab, Comment string }`, `HasFrontendPermissions interface { FrontendPermissions() []FrontendPermission }`.
|
||||
|
||||
In `capabilities.go` (additive): `AdminActionPrompt struct { Label, Placeholder, Comment string; MaxLength int }` (phrase keys or text; MaxLength 0 means 255); `AdminRecordAction.Prompt *AdminActionPrompt` with a `json:"-"`-free field (it is not serialized by pact) and a doc sentence replacing "A record action carries no input beyond the record." in the AdminActionExtension comment with the prompt rule (P-01); `AdminRecordActionInput.Value string` ("the trimmed prompt answer; empty for an action without a Prompt"). Account seam (P-02): `HasAccountContributions interface { AccountContributions() []AccountContribution }`, `AccountContribution struct { Name, Label, Description string; Status func(ctx context.Context, adminID uint) (string, error); Actions []AccountAction }`, `AccountAction struct { Name, Label, Confirm string; Danger bool; Permissions []string; Applies func(ctx context.Context, adminID uint) (bool, error); Run func(ctx context.Context, in AccountActionInput) (AccountActionResult, error) }`, `AccountActionInput struct { AdminID uint }`, `AccountActionResult struct { Message, URL string }`; doc comments list the boot failures cabana enforces (identifier names, duplicate contribution or action name across plugins, nil Run, empty Label) and that Status and Applies must be pure reads.
|
||||
|
||||
Tests in `capabilities_test.go`: compile-time discovery of HasMCP, HasFrontendPermissions and HasAccountContributions on sample plugins (type assertions), MCPGuards register/duplicate/lookup/sorted names, and a struct-literal test that every new type is constructible without importing anything outside pact (a `go list -deps ./modules/pact` assertion in the test that the dependency list contains neither `modelcontextprotocol` nor `jsonschema-go` nor `modules/bouncer`).
|
||||
|
||||
Docs: pact README API reference rows for every new type and interface; `docs/plugins/registration.md` capability table rows for HasMCP, HasFrontendPermissions, HasAccountContributions, and a sentence on AdminRecordAction.Prompt. The MCP usage page itself is plan 02's `docs/services/mcp.md`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pact/... && go test -count=1 -short ./modules/pact/... && DEPS=$(go list -deps ./modules/pact) && ! printf '%s\n' "$DEPS" | grep -q 'modelcontextprotocol\|jsonschema-go\|modules/bouncer' && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, `go list -deps` failing (the captured assignment short-circuits the chain), or any dependency line matching modelcontextprotocol, jsonschema-go or modules/bouncer</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "type HasMCP interface\|type MCPTool struct\|type MCPPrompt struct\|type MCPGuard interface\|type MCPGuards struct\|type MCPTokenVerifier interface\|type MCPLinkedBackendResolver interface\|type MCPSubjectChanged struct\|type HasFrontendPermissions interface" modules/pact/mcp.go` prints 9
|
||||
- `grep -c "type AdminActionPrompt struct\|type HasAccountContributions interface\|type AccountContribution struct\|type AccountAction struct\|type AccountActionResult struct" modules/pact/capabilities.go` prints 5
|
||||
- `grep -c "Prompt \*AdminActionPrompt" modules/pact/capabilities.go` prints 1 and `grep -c "Value string" modules/pact/capabilities.go` prints at least 1
|
||||
- `DEPS=$(go list -deps ./modules/pact) && ! printf '%s\n' "$DEPS" | grep -q 'modelcontextprotocol\|jsonschema-go\|modules/bouncer'` exits 0 (a failing `go list` fails the criterion rather than passing it)
|
||||
- `grep -c "HasMCP\|HasFrontendPermissions\|HasAccountContributions" docs/plugins/registration.md` prints at least 3
|
||||
- `go test -count=1 -short ./modules/pact/...` passes
|
||||
</acceptance_criteria>
|
||||
<done>Every plugin-facing contract of the phase compiles in pact without the SDK; discovery tests pass; README and registration docs list them.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: cabana server side: the account contribution routes, the prompted record action and backend subject-changed events</name>
|
||||
<files>modules/cabana/account_contributions.go, modules/cabana/account_contributions_smoke_test.go, modules/cabana/record_action_prompt_smoke_test.go, modules/cabana/action_extensions.go, modules/cabana/actions.go, modules/cabana/crud.go, modules/cabana/schema_types.go, modules/cabana/http.go, modules/cabana/admin_openapi.go, modules/cabana/subject_events.go, modules/cabana/README.md, modules/phrasebook/backend/lang/en/lang.yaml, modules/phrasebook/backend/lang/pl/lang.yaml, admin/openapi/admin.json, admin/src/api/schema.d.ts, docs/backend/admin-controllers.md, docs/backend/users-and-permissions.md</files>
|
||||
<read_first>
|
||||
- modules/cabana/action_extensions.go (compileActionExtensions, checkContributedAction, wrapAdministratorsContributedRun)
|
||||
- modules/cabana/actions.go 187-260 and 327-345 (recordAction handler, the payload refusal at line 211-214, recordActionOf, allowAction, decodeActionRequest)
|
||||
- modules/cabana/crud.go 548-640 (offeredRecordActions, CRUDService.RecordAction)
|
||||
- modules/cabana/schema_types.go 229-236 (RecordAction JSON) and admin_openapi.go 95-125, 755-790 (AdminProfile, AdminActionRequest, AdminActionResult swag types)
|
||||
- modules/cabana/http.go 78-235 (Activate: where compileActionExtensions and compileContributions run) and 284-300 (the /account routes block)
|
||||
- modules/cabana/account.go 1-80 and auth.go 340-362 (handler shape, WriteData, interactiveOnly, requireAjax)
|
||||
- modules/cabana/account_tokens.go (accountTokenRevoke: where the backend revoked event is fired)
|
||||
- modules/cabana/backend_users_admin.go (FormAfterUpdate/role and permission changes, deactivate and delete record and bulk actions: where backend permissions/deleted events are fired) and backend_roles_admin.go (role save)
|
||||
- modules/cabana/example_action_extension_test.go and administrators_harness_test.go (test env shapes)
|
||||
- modules/festival/bus.go 40-90 (Bus.Fire)
|
||||
- scripts/check-admin-openapi.sh (what regenerates admin/openapi/admin.json and schema.d.ts)
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md and 19.6.1-04-SUMMARY.md (the seam and the outranking wrap)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "FW/modules/cabana/account_contributions.go"
|
||||
</read_first>
|
||||
<action>
|
||||
Account contributions (P-02, D-04 part 1), new `account_contributions.go`: `compileAccountContributions(reg *Registry, plugins []party.Plugin) error` collects `pact.HasAccountContributions` in activation order into `reg.accountContributions` (ordered slice + map by name); boot errors with the `cabana: plugin %s contributes account section %q ...` prefix for a non-identifier name, a name another plugin already contributed, an empty Label, an action with a non-identifier name, a duplicate action name within the section, a nil Run or an empty action Label. Call it in `Activate` right after `compileActionExtensions`. Handlers: `accountContributionsList` (GET) answers `WriteData(w, 200, []AccountContributionView, map[string]any{})` where each view is `{name, label, description, status, actions: [{name, label, confirm, danger}]}` with label/description/confirm/status translated through `translateKey`, `status` from `Status(ctx, principal.ID)` (omitted when the func is nil or returns ""), actions filtered by `Allows(principal, action.Permissions)` and `Applies(ctx, principal.ID)`; `accountContributionAction` (POST `{name}/actions/{action}`): 404 `not_found` for an unknown section or action, 403 through `allowAction`, 409 `actionConflict` when Applies is false, then `Run(ctx, pact.AccountActionInput{AdminID: principal.ID})` inside `s.transaction` (ctx carries the tx as record actions do) and answers `WriteData(w, 200, AccountActionResultView{Message (translated), URL}, nil)`; the audit log line `cabana: account contribution action` carries admin_id, section and action. Routes in `http.go` next to the tokens routes: `g.Get("/account/contributions", interactiveOnly(s.accountContributionsList))` and `g.Post("/account/contributions/{name}/actions/{action}", interactiveOnly(requireAjax(s.accountContributionAction)))`. Swag-annotate both (types `AccountContributionView`, `AccountContributionActionView`, `AccountActionResultView` in admin_openapi.go). Every existing `/account*`, `/auth/me` and record payload stays byte-identical (nothing in account.go changes).
|
||||
|
||||
Prompted record action (P-01, D-34): `RecordAction` gains `Prompt *RecordActionPrompt` with JSON `prompt,omitempty` and `RecordActionPrompt{Label, Placeholder, Comment string; MaxLength int}` (`label`, `placeholder,omitempty`, `comment,omitempty`, `max_length`); `offeredRecordActions` fills it (translated) when the action declares a Prompt; `checkContributedAction` and the owner-action compile (`compileRecordActions`) refuse a Prompt with an empty Label. `recordAction` handler: when the registered action has a Prompt, `in.Payload` must be a JSON string (decode with encoding/json into a string; anything else is 422 on `payload` "The payload must be a string."), trimmed, non-empty and at most MaxLength (0 means 255) runes, else 422 on `payload` with the new phrase `backend::lang.form.action_prompt_required` / `action_prompt_too_long` (en + pl); the existing refusal for `record_id`, `values` and for `payload` on an action without a Prompt is unchanged. Add `func (s CRUDService) RecordActionWithValue(ctx, cc, id, name, value string)` carrying the value into `pact.AdminRecordActionInput{RecordID, Record, Value}`; keep `RecordAction(ctx, cc, id, name)` as a wrapper with an empty value (exported signature unchanged).
|
||||
|
||||
Backend subject events (D-26 sources on the backend side), new `subject_events.go`: `fireSubjectChanged(ctx, app, kind string, adminIDs ...uint)` fires `pact.MCPSubjectChanged{Guard: "backend", UserID: id, Kind: kind}` for each id through `app.Events` when the bus exists (errors logged, never failing the save). Call it with `MCPSubjectRevoked` from the account token revoke path, with `MCPSubjectPermissions` after an Administrators save that changed role_id, permissions or is_superuser (the FormAfterUpdate snapshot already knows the prior role) and after a Roles save that changed permissions (one event per admin holding that role, ids read inside the same tx), and with `MCPSubjectDeleted` after deactivate, delete and their bulk forms.
|
||||
|
||||
Smoke tests (-short, through the harness shape of `backend_screens_test.go`/`example_action_extension_test.go`, no Postgres): `TestAccountContributionsSmoke` (a fake plugin contributes one section with a status and two actions; GET lists it with translated labels and omits an action whose Applies is false; POST runs the action and returns its URL; a `g15_` token or raw bearer gets 403 interactive_only; boot refuses a duplicate name across two plugins); `TestRecordActionPromptSmoke` (a contributed prompted action on a controller of the test plugin: the show payload carries `prompt` with `max_length`; POST with `{"payload":" acme "}` hands `Value == "acme"` to Run; `{"payload":""}` and `{"payload":123}` are 422 on payload; an action without a Prompt still refuses `payload`; the record response of a controller without prompted actions has no `prompt` key).
|
||||
|
||||
Then `scripts/check-admin-openapi.sh` (regenerates `admin/openapi/admin.json` and `admin/src/api/schema.d.ts`; commit them). Docs in the same commit: cabana README (Features: account contributions, prompted record actions, backend subject events; Admin API routes table: the two routes; API reference rows), `docs/backend/users-and-permissions.md` § "My account" (plugins can add sections and actions), `docs/backend/admin-controllers.md` § "Adding record actions to another controller" (the Prompt). Any Go example block needs `src=` pointing at a tested example file (extend `example_action_extension_test.go` with a prompted action example and add `example_account_contribution_test.go` if a code block is used).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/cabana/... ./modules/pact/... && go test -count=1 -short -run '^(TestAccountContributionsSmoke|TestRecordActionPromptSmoke)$' -v ./modules/cabana 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2 && scripts/check-admin-openapi.sh --check && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, the PASS count line is not exactly 2, or check-admin-openapi reports a difference</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func compileAccountContributions(" modules/cabana/account_contributions.go` prints 1 and `grep -c "account/contributions" modules/cabana/http.go` prints 2
|
||||
- `grep -c "Prompt \*RecordActionPrompt" modules/cabana/schema_types.go` prints 1 and `grep -c "json:\"prompt,omitempty\"" modules/cabana/schema_types.go` prints 1
|
||||
- `grep -c "func (s CRUDService) RecordActionWithValue(" modules/cabana/crud.go` prints 1 and `grep -c "func (s CRUDService) RecordAction(" modules/cabana/crud.go` prints 1
|
||||
- `grep -c "func fireSubjectChanged(" modules/cabana/subject_events.go` prints 1 and `grep -c "fireSubjectChanged(" modules/cabana/account_tokens.go modules/cabana/backend_users_admin.go modules/cabana/backend_roles_admin.go` shows a non-zero count for each of the three files
|
||||
- `grep -c "action_prompt_required" modules/phrasebook/backend/lang/en/lang.yaml modules/phrasebook/backend/lang/pl/lang.yaml` prints 1 for each file
|
||||
- `grep -c "AccountContributionView" admin/openapi/admin.json` prints a non-zero count and `scripts/check-admin-openapi.sh --check` exits 0
|
||||
- account.go untouched by the phase: `git rev-parse -q --verify '51d088a^{commit}' >/dev/null && git diff --quiet 51d088a -- modules/cabana/account.go` exits 0 (51d088a is the framework HEAD when this plan was written; the file must be byte-identical to that commit, and an unknown base or a git error exits non-zero instead of passing)
|
||||
- Both smoke tests print `--- PASS`
|
||||
</acceptance_criteria>
|
||||
<done>cabana lists and runs plugin account contributions behind interactiveOnly, accepts a prompt value only for prompted record actions, fires backend subject-changed events, and the OpenAPI document, schema types and docs are regenerated and committed; existing account and record payloads unchanged.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Admin SPA: the account contributions section, the prompt input in the record action confirm dialog, and the rebuilt embedded admin</name>
|
||||
<files>admin/src/components/ui/confirm.ts, admin/src/components/ui/ConfirmDialog.vue, admin/src/components/form/RecordActions.vue, admin/src/components/account/AccountContributions.vue, admin/src/views/AccountView.vue, admin/src/api/types.ts, admin/tests/account/AccountContributions.test.ts, admin/tests/form/RecordActionsPrompt.test.ts, modules/boardwalk/dist</files>
|
||||
<read_first>
|
||||
- admin/src/components/form/RecordActions.vue (confirm.ask at 49-56, api.POST with body {} at 59-62, the toast and emit paths 74-95)
|
||||
- admin/src/components/ui/confirm.ts (ConfirmRequest, useConfirm) and admin/src/components/ui/ConfirmDialog.vue (props, the danger variant, busy handling)
|
||||
- admin/src/views/AccountView.vue (ApiTokensPanel placement, api.PUT and showToast usage, the section markup 248-300) and admin/src/components/account/ApiTokensPanel.vue (a self-loading account panel: the pattern to copy)
|
||||
- admin/src/api/types.ts 55-70 (how Schemas types are exported) and admin/src/api/schema.d.ts (regenerated in Task 4: cabana.RecordAction.prompt, cabana.AccountContributionView)
|
||||
- admin/tests/views/AccountView.test.ts 1-60 and admin/tests/helpers.ts (mountApp, API, envelope, requestsTo) and admin/tests/form/PreviewView.test.ts (record action tests)
|
||||
- admin/tests/form/FormView.test.ts "field triggers on the form" block (how 19.6.1 added SPA backstops)
|
||||
- scripts/check-admin-dist.sh and .planning/notes/2026-10-07-embedded-admin-release-gate.md
|
||||
</read_first>
|
||||
<action>
|
||||
confirm.ts: `ConfirmRequest` gains `prompt?: { label: string; placeholder?: string; comment?: string; maxLength: number }`; `useConfirm` keeps a `value = ref('')` reset on ask/settle and `ask` resolves with the typed value available to the caller (return `Promise<boolean>` unchanged, expose `value`). ConfirmDialog.vue: optional `prompt` prop renders a labelled text input (`id` from the dialog id prefix, `maxlength`, `autocomplete="off"`, `aria-describedby` on the comment, autofocus when present) above the buttons; the confirm button is disabled while the trimmed value is empty; Enter in the input confirms. RecordActions.vue: pass `action.prompt` into `confirm.ask`; when the action has a prompt, POST `body: { payload: value.trim() }`, otherwise `body: {}` exactly as today; a 422 on `payload` shows the server's detail text as a danger toast and keeps the dialog closed.
|
||||
|
||||
AccountContributions.vue (new, under components/account): on mount `api.GET('/account/contributions')`; renders nothing when the list is empty; for each section a card (same classes as the avatar card: `rounded-card border border-border bg-surface p-7 shadow-card`) with `h2` label, muted description, a `status` line (`data-account-contribution-status`) and one outline Button per action; an action with `confirm` or `danger` goes through `useConfirm` + ConfirmDialog (danger variant), then `api.POST('/account/contributions/{name}/actions/{action}')`; on success show `message` as a toast, reload the list, and when `url` is present open it with `window.open(url, '_blank', 'noopener')` and also render it as a visible link (`data-account-contribution-url`, `rel="noopener noreferrer"`, `target="_blank"`) so a blocked popup still leaves a way through; 409 shows `backend::lang.form.action_stale` and reloads; 403 shows `backend::lang.list.action_forbidden`. Labels, descriptions, statuses and messages come from the server already translated and render as text (no `v-html`). AccountView.vue mounts `<AccountContributions />` after `ApiTokensPanel`. types.ts exports `AccountContribution`, `AccountContributionAction`, `AccountActionResult` from the regenerated schema.
|
||||
|
||||
Vitest smokes: `admin/tests/account/AccountContributions.test.ts` (list renders two sections with statuses; an action with a URL posts, shows the toast and renders the link; an empty list renders no card; a 409 shows the stale toast and refetches) and `admin/tests/form/RecordActionsPrompt.test.ts` (a prompted action renders the input, the confirm button is disabled until a value is typed, the POST body is `{ payload: 'acme' }`; an action without a prompt still posts `{}`). Then `npm --prefix admin run typecheck`, `npm --prefix admin run test`, `npm --prefix admin run build`, commit `modules/boardwalk/dist` (one `chore` commit, as 19.6.1-02 did), `scripts/check-admin-dist.sh`. Do not run `npm ci` (node_modules is shared with other sessions) unless `npm ls` reports an inconsistent tree.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>scripts/check-admin-openapi.sh --check && npm --prefix admin run typecheck && npm --prefix admin run test && scripts/check-admin-dist.sh</automated>
|
||||
<fails_when>non-zero exit, a vitest summary line that is not all passing, or check-admin-dist reporting that modules/boardwalk/dist differs from a fresh build</fails_when>
|
||||
<human-check>Sign in to a locally served admin (any app with an admin, e.g. `go -C examples/hello run .` if it serves the admin, otherwise skip to plan 03's user plugin env) and open My account: with no plugin contributing, the page is unchanged. On a preview screen of a controller with a prompted contributed action (plan 03's Administrators link action), the confirm dialog shows one text input and the confirm button is disabled until text is typed.</human-check>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "prompt" admin/src/components/ui/confirm.ts` prints at least 2 and `grep -c "maxlength" admin/src/components/ui/ConfirmDialog.vue` prints at least 1
|
||||
- `grep -c "payload: " admin/src/components/form/RecordActions.vue` prints at least 1 and `grep -c "body: {}" admin/src/components/form/RecordActions.vue` prints at least 1
|
||||
- `test -f admin/src/components/account/AccountContributions.vue` and `grep -c "AccountContributions" admin/src/views/AccountView.vue` prints at least 2
|
||||
- `grep -c "v-html" admin/src/components/account/AccountContributions.vue` prints 0
|
||||
- `npm --prefix admin run test 2>&1 | grep -E 'Test Files +[0-9]+ passed' | grep -qv failed`
|
||||
- `scripts/check-admin-dist.sh` prints that modules/boardwalk/dist matches a fresh build
|
||||
- `git status --short admin/src/state/useSettings.ts admin/src/components/shell/SettingsPanel.vue` shows no change made by this task (those files belong to another session)
|
||||
</acceptance_criteria>
|
||||
<done>The admin shows plugin account sections on My account, asks for a prompt value before running a prompted record action, and the embedded build matches the committed dist.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this phase produces (plan 01 owns these; later plans add theirs)
|
||||
|
||||
**Go (framework)**
|
||||
- `modules/bouncer/dispatch.go`: `Dispatch`, `WithDispatch`, `Dispatched`
|
||||
- `modules/cabana/token_resolver.go`: `ResolveBackendToken`, `ScopeLimitFor`, `BackendPrincipal`
|
||||
- `modules/cabana/account_contributions.go`: `compileAccountContributions`, handlers `accountContributionsList`, `accountContributionAction`; swag types `AccountContributionView`, `AccountContributionActionView`, `AccountActionResultView`
|
||||
- `modules/cabana/schema_types.go`: `RecordAction.Prompt`, `RecordActionPrompt`
|
||||
- `modules/cabana/crud.go`: `CRUDService.RecordActionWithValue`
|
||||
- `modules/cabana/subject_events.go`: `fireSubjectChanged`
|
||||
- `modules/surf/streaming.go`: `(*Router).MountStream`, `recoverStream`, `MCPBuildTag`
|
||||
- `modules/surf/routetable.go`: `(*Router).Handler`; `modules/surf/router.go`: `compileHandlers`, `mountPier` hook, `route.stream`
|
||||
- `modules/surf/pier_off.go` (`//go:build !summercms_mcp`)
|
||||
- `modules/wristband/authorize.go`: `parseAuthorizeScopes(raw, allowed)` over `Options.ScopesSupported`
|
||||
- `modules/cooler/cooler.go`: `KeyPrefix`
|
||||
- `modules/pact/mcp.go`: `HasMCP`, `MCP`, `MCPTool`, `MCPPrompt`, `MCPPromptArgument`, `MCPPromptMessage`, `MCPGuard`, `MCPGuards`, `NewMCPGuards`, `MCPRequirements`, `MCPSubject`, `MCPDispatch`, `MCPTokenVerifier`, `MCPGrant`, `ErrMCPTokenInvalid`, `MCPPersonalTokenResolver`, `MCPLinkedBackendResolver`, `LinkedBackendUser`, `MCPSubjectChanged`, `MCPSubjectPermissions`, `MCPSubjectLink`, `MCPSubjectRevoked`, `MCPSubjectDeleted`, `FrontendPermission`, `HasFrontendPermissions`
|
||||
- `modules/pact/capabilities.go`: `AdminActionPrompt`, `AdminRecordAction.Prompt`, `AdminRecordActionInput.Value`, `HasAccountContributions`, `AccountContribution`, `AccountAction`, `AccountActionInput`, `AccountActionResult`
|
||||
|
||||
**Routes (cabana admin API)**: `GET {api}/account/contributions`, `POST {api}/account/contributions/{name}/actions/{action}`
|
||||
|
||||
**Config keys read by the framework in this plan**: `mcp.enabled` (surf hook only; the full `mcp.*` set is plan 02's)
|
||||
|
||||
**Build tag**: `summercms_mcp` (hook only; the tagged `pier_on.go` is plan 02's)
|
||||
|
||||
**Phrases**: `backend::lang.form.action_prompt_required`, `backend::lang.form.action_prompt_too_long` (en, pl)
|
||||
|
||||
**Admin SPA**: `admin/src/components/account/AccountContributions.vue`; `ConfirmRequest.prompt`; regenerated `admin/openapi/admin.json`, `admin/src/api/schema.d.ts`; rebuilt `modules/boardwalk/dist`
|
||||
|
||||
**Phase-wide identifiers fixed by this plan for plans 02-05**: config namespace `mcp.*` (`mcp.enabled`, `mcp.path` default `/mcp`, `mcp.allow_personal_tokens`, `mcp.sessions.store` memory|redis, `mcp.sessions.idle_ttl` 30m, `mcp.sessions.max_per_binding` 20, `mcp.resource`, `mcp.throttle` `120,1`, `mcp.allowed_origins`, `mcp.call_timeout` 30s, `mcp.max_result_bytes` 1048576); guard names `user` and `backend`; tool prefix = last dot-segment of the plugin ID + `_`; permission code `golem15.users.manage_backend_links`; tables `golem15_user_backend_links`, `golem15_user_backend_link_requests`; session binding keys `oauth:<client_id>:<user_id>`, `pat:user:<token_id>`, `pat:backend:<token_id>`; Redis keys `<cooler.KeyPrefix>mcp:s:<id>` and channel `<prefix>mcp:events`.
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| HTTP request to a guarded route | untrusted headers, cookies and bodies cross into bouncer guards and cabana resolvers |
|
||||
| in-process dispatcher to route handler | a trusted framework caller (pier, plan 02) hands a pre-resolved principal through the context |
|
||||
| admin SPA to cabana account and action routes | the signed-in admin's browser sends action names and prompt values |
|
||||
| plugin contributions to cabana at boot | plugin-declared names, labels, prompts and Run funcs are merged into the admin |
|
||||
| authorize request to wristband | an MCP client's scope string crosses into the allow-list check |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-01 | Spoofing | bouncer dispatch marker | high | mitigate | Context-only value under an unexported key; `Dispatched` is the only reader and no code path reads a header, cookie or query for it; `TestDispatchSmoke` sends forged headers and a cookie and gets 401; plan 05's gate greps that only `modules/pier` calls the setter outside tests |
|
||||
| T-19.7-02 | Elevation | cabana ResolveBackend with a marker | high | mitigate | A marker is honoured only when it lists guard `backend` and its principal has `Backend == true`; a frontend marker is ErrUnauthenticated; cover codes are still checked against a scoped principal (`TestDispatchMarkerSmoke`) |
|
||||
| T-19.7-03 | Elevation | surf Handler lookup | medium | mitigate | `Handler` returns the fully wrapped chain (constraints, named middleware, body limit, recovery), never the bare handler; `TestDispatchSmoke` proves the guard middleware still runs in-process |
|
||||
| T-19.7-04 | Tampering | streaming route recovery | medium | mitigate | `recoverStream` writes an opaque 500 only before the first byte; after that a panic aborts the body and marks the request panicked; it never writes the panic value (`TestStreamingRouteSmoke`) |
|
||||
| T-19.7-05 | Denial of Service | mcp.enabled without the tag | low | mitigate | Boot fails with an error naming `summercms_mcp` instead of serving a half-mounted endpoint (`TestPierMountSmoke`) |
|
||||
| T-19.7-06 | Elevation | account contribution actions | high | mitigate | Routes behind the backend guard and `interactiveOnly` (personal tokens refused), `requireAjax` on POST, `allowAction` for the action's Permissions, `Applies` re-checked before Run, Run receives only the signed-in admin's id (`TestAccountContributionsSmoke`) |
|
||||
| T-19.7-07 | Tampering | prompted record action value | medium | mitigate | `payload` accepted only for actions that declare a Prompt and only as a JSON string, trimmed, non-empty, capped at MaxLength runes; every other record action keeps the 422 refusal (`TestRecordActionPromptSmoke`); the action's own Run validates the meaning of the value |
|
||||
| T-19.7-08 | Information Disclosure | account contribution rendering in the SPA | low | mitigate | Labels, statuses, messages and URLs render as text and attributes only (no `v-html`); the URL opens with `noopener` |
|
||||
| T-19.7-09 | Elevation | wristband MCP scope allow-list | medium | mitigate | The allowed set is exactly `Options.ScopesSupported`; the default is unchanged and `TestMCPScopesSmoke` proves `backend` is refused on a default server and accepted only when the host lists it |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go vet ./... && go test -count=1 -short ./... && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check && scripts/check-admin-openapi.sh --check`
|
||||
- `scripts/check-admin-openapi.sh --check && npm --prefix admin run typecheck && npm --prefix admin run test && scripts/check-admin-dist.sh`
|
||||
- Docker host: `go test -count=1 ./modules/cabana ./modules/surf` (every 19.6.1 Postgres test still passes) and `bash scripts/check-phase19.6.1.sh --all` (the 19.6.1 gate stays green; its sc1 stage proves account.go untouched)
|
||||
- The seven smoke tests of this plan print `--- PASS` under `-short`
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- All five tasks committed; every acceptance criterion above holds
|
||||
- No existing test modified except where a test asserted the absence of a key this plan adds (none expected); every pre-existing cabana, surf, bouncer, wristband, pact and admin test passes unchanged
|
||||
- `mcp.enabled` absent: the framework behaves exactly as at the plan's base commit (route table, payloads, admin build apart from the two new account routes and the `prompt` key that appears only for prompted actions)
|
||||
- Planner decisions P-01..P-04 are implemented as written and named in the SUMMARY
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md` when done (planning docs in their own commit).
|
||||
</output>
|
||||
305
.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md
Normal file
305
.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md
Normal file
@@ -0,0 +1,305 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 01
|
||||
subsystem: auth
|
||||
tags: [bouncer, surf, cabana, pact, wristband, cooler, mcp, admin-spa, streaming, account-contributions]
|
||||
|
||||
requires:
|
||||
- phase: 19.6.1
|
||||
provides: pact.HasAdminActionExtensions record-action seam, Administrators screen, guardOutranked wrap
|
||||
- phase: 19.4
|
||||
provides: wristband MCP Server with Options.ScopesSupported
|
||||
- phase: 16.3
|
||||
provides: cabana personal API tokens, interactiveOnly, ResolveBackend
|
||||
provides:
|
||||
- bouncer.Dispatch / WithDispatch / Dispatched (D-17 context-only pre-resolved principal marker), honoured by Registry.Middleware and cabana.ResolveBackend
|
||||
- cabana.ResolveBackendToken, ScopeLimitFor, BackendPrincipal (additive resolvers for pier)
|
||||
- surf.Router.Handler and compileHandlers (one compiled chain per route), surf.Router.MountStream and recoverStream (unbuffered route kind), surf.MCPBuildTag and the mountPier hook (D-30, D-33)
|
||||
- wristband parseAuthorizeScopes over Options.ScopesSupported (D-21 framework side); cooler.KeyPrefix
|
||||
- pact MCP contracts (HasMCP, MCPTool, MCPPrompt, MCPGuard(s), MCPTokenVerifier, MCPPersonalTokenResolver, MCPLinkedBackendResolver, MCPSubjectChanged, FrontendPermission) with no SDK, jsonschema-go or bouncer import
|
||||
- pact.HasAccountContributions seam and the cabana routes GET /account/contributions, POST /account/contributions/{name}/actions/{action} (D-04 part 1)
|
||||
- prompted record actions (pact.AdminActionPrompt, AdminRecordActionInput.Value, RecordAction.prompt, CRUDService.RecordActionWithValue) and backend pact.MCPSubjectChanged events (D-34, D-26)
|
||||
- admin SPA AccountContributions card, ConfirmDialog prompt input, RecordActions payload; rebuilt modules/boardwalk/dist
|
||||
affects: [19.7-02 pier module and framework release, 19.7-03 sm-user-plugin link and frontend permissions, 19.7-04 oauthserver and Journal, 19.7-05 unit tests and security review]
|
||||
|
||||
actuals:
|
||||
tokens: 55621
|
||||
tasks: 5
|
||||
commits: 6
|
||||
plan_head_before: a74a218cd99a04eb29fc66525f04f0be7e453b9f
|
||||
plan_head_after: fab99e0a00bf4277ab4e659998267970b4a9aeb6
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Context-only dispatch marker under an unexported key, honoured only for the exact guard names it lists; no header, cookie or query is ever read for it"
|
||||
- "surf compiles each route chain once (compileHandlers) and exposes it by method + pattern for in-process dispatch; the mux reuses the same chains"
|
||||
- "Build-tag hook: a package-level func var set by the tagged file, nil in the untagged one; config true without the tag fails boot naming the tag"
|
||||
- "Plugin-facing MCP types live in pact as plain structs and interfaces (Principal carried as any) so no plugin links the SDK"
|
||||
- "Boot-time compile of plugin contributions with cabana: plugin %s ... error prefixes and per-request translateKey for labels"
|
||||
- "Prompted confirm: ConfirmRequest.prompt + useConfirm.value; the dialog owns the input, the caller reads the value inside its action"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/bouncer/dispatch.go
|
||||
- modules/cabana/token_resolver.go
|
||||
- modules/cabana/account_contributions.go
|
||||
- modules/cabana/subject_events.go
|
||||
- modules/surf/streaming.go
|
||||
- modules/surf/pier_off.go
|
||||
- modules/pact/mcp.go
|
||||
- modules/wristband/mcp_scopes_smoke_test.go
|
||||
- admin/src/components/account/AccountContributions.vue
|
||||
- admin/tests/account/AccountContributions.test.ts
|
||||
- admin/tests/form/RecordActionsPrompt.test.ts
|
||||
- modules/cabana/record_action_prompt_postgres_test.go
|
||||
modified:
|
||||
- modules/bouncer/registry.go
|
||||
- modules/cabana/token_guard.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/schema_types.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- modules/cabana/backend_users_admin.go
|
||||
- modules/cabana/backend_roles_admin.go
|
||||
- modules/cabana/account_tokens.go
|
||||
- modules/cabana/contracts.go
|
||||
- modules/surf/router.go
|
||||
- modules/surf/routetable.go
|
||||
- modules/wristband/authorize.go
|
||||
- modules/cooler/cooler.go
|
||||
- modules/pact/capabilities.go
|
||||
- admin/src/components/ui/confirm.ts
|
||||
- admin/src/components/ui/ConfirmDialog.vue
|
||||
- admin/src/components/form/RecordActions.vue
|
||||
- admin/src/views/AccountView.vue
|
||||
- admin/openapi/admin.json
|
||||
- admin/src/api/schema.d.ts
|
||||
- modules/boardwalk/dist
|
||||
|
||||
key-decisions:
|
||||
- "P-01 implemented: a prompted record action is pact.AdminRecordAction.Prompt; the SPA posts the value as the existing body key payload (JSON string) and cabana accepts payload only for such an action, trimmed, non-empty, capped at MaxLength runes (0 means 255)"
|
||||
- "P-02 implemented: My account contributions are a plugin interface (pact.HasAccountContributions), not an AdminController extension; cabana never names the contributing plugin"
|
||||
- "P-03 implemented: bouncer.Dispatch{Guards, Principal, Credential}; Dispatched answers only for a guard name the marker lists exactly; cabana.ResolveBackend honours a backend marker and refuses a frontend one before reading any header"
|
||||
- "P-04 implemented: every plugin-facing MCP type is in pact with Principal as any; a go list -deps test keeps pact free of the SDK, jsonschema-go and bouncer"
|
||||
- "An account contribution action runs inside lagoon.Transaction when the app publishes a *gorm.DB; an admin booted without a database runs Run on the request context, so the -short smoke exercises the whole handler"
|
||||
- "Backend subject events fire inside the saving transaction through app.Events; a listener error is logged, never fails the save (every MCP request re-checks anyway, D-08)"
|
||||
- "wristband's authorize allow-list is exactly Options.ScopesSupported; an empty list keeps the PHP default so TestPhase08Coverage and every existing test are unchanged"
|
||||
- "The stream route kind recovers a panic with the opaque 500 only before the first header, byte or flush; after that it only cuts the body short"
|
||||
|
||||
patterns-established:
|
||||
- "Tracer first: Task 1 proved marker -> compiled chain -> guard -> handler end to end before any expansion"
|
||||
- "Route inventories (phase09Routes, tokenRouteClasses, phase10 CSRF walk and want list, conformCases) are extended in the same commit as a new admin route"
|
||||
|
||||
requirements-completed: [SC-1, SC-3, SC-4, D-04, D-09, D-17, D-28, D-30, D-33, D-34, D-36]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "In-process dispatch marker: a marker-carrying request runs a guarded route through surf's compiled chain as the pre-resolved principal; forged headers and cookies are 401; cabana.ResolveBackend honours a backend marker and refuses a frontend one"
|
||||
requirement: "D-17"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/surf/dispatch_smoke_test.go#TestDispatchSmoke"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/bouncer/dispatch_smoke_test.go#TestDispatchedSmoke"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/dispatch_smoke_test.go#TestDispatchMarkerSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "surf.Router.Handler lookup, MountStream streaming route kind flushing mid-handler with panic recovery before and after the first byte, mcp.enabled inert without the tag and a boot error naming summercms_mcp with it"
|
||||
requirement: "SC-1"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/surf/streaming_smoke_test.go#TestStreamingRouteSmoke"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/surf/pier_mount_smoke_test.go#TestPierMountSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "wristband authorize accepts exactly Options.ScopesSupported (backend only when listed, default unchanged); cooler.KeyPrefix exported"
|
||||
requirement: "D-36"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/wristband/mcp_scopes_smoke_test.go#TestMCPScopesSmoke"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "go test -count=1 -short ./modules/wristband/... ./modules/cooler/..."
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "SDK-free pact contracts for MCP tools, prompts, guards, verifiers, link resolver, subject events, frontend permissions, prompted record actions and account contributions, discoverable by type assertion"
|
||||
requirement: "D-28"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pact/capabilities_test.go#TestPhase197ContractsOnSamplePlugin"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/pact/capabilities_test.go#TestMCPGuardsRegistry"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/pact/capabilities_test.go#TestPactStaysSDKFree"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "cabana lists and runs plugin account contributions behind interactiveOnly, refuses personal tokens, 403/404/409 paths, boot refuses duplicate or malformed sections; existing /account*, /auth/me and record payloads unchanged (account.go byte-identical to 51d088a)"
|
||||
requirement: "D-04"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/account_contributions_smoke_test.go#TestAccountContributionsSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/openapi_conformance_test.go#TestPhase10OpenAPIConformance (GET /account/contributions, POST .../actions/{action} cases)"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "git diff --quiet 51d088a -- modules/cabana/account.go"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Prompted record action: the record response carries prompt with max_length only for prompted actions, the route accepts payload only for them (422 on empty, non-string, over-long), Run receives the trimmed Value, plain actions keep refusing payload"
|
||||
requirement: "D-34"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/record_action_prompt_smoke_test.go#TestRecordActionPromptSmoke"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "modules/cabana/record_action_prompt_postgres_test.go#TestRecordActionPromptRun"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Backend pact.MCPSubjectChanged events on token revoke, Administrators saves changing role/permissions/superuser, Roles saves changing grants, deactivation and deletion"
|
||||
requirement: "D-36"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "go test -count=1 ./modules/cabana (Postgres; the 19.6.1 Administrators and Roles suites pass with the hooks in place)"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "The hooks compile and the lifecycle suites pass through them, but no test yet asserts the fired events themselves; plan 05 (unit tests) adds the listener assertions"
|
||||
- id: D8
|
||||
description: "Admin SPA: My account shows contributed sections with status, actions, toast, new-tab URL and visible link; the confirm dialog of a prompted record action shows one text input, confirm disabled until typed, posts {payload}; plain actions post {}; dist rebuilt and matching"
|
||||
requirement: "SC-4"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "admin/tests/account/AccountContributions.test.ts"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "admin/tests/form/RecordActionsPrompt.test.ts"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "scripts/check-admin-dist.sh"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "The plan's human-check (an unchanged My account page without contributors, the prompt input on a preview screen) is visual; plan 03's user plugin provides the first real contributor and prompted action to look at"
|
||||
|
||||
duration: 52 min
|
||||
completed: 2026-10-22
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 01: Framework seams for the MCP module Summary
|
||||
|
||||
**D-17 dispatch marker in bouncer and cabana, surf's compiled-chain lookup plus an unbuffered streaming route kind and the tagged pier hook, SDK-free pact MCP contracts, the My account contribution seam with prompted record actions on cabana and in the SPA, wristband's configurable scope set and cooler.KeyPrefix, all additive and all green on the existing suites**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 52 min
|
||||
- **Started:** 2026-10-22T13:54:19Z
|
||||
- **Completed:** 2026-10-22T14:46:00Z
|
||||
- **Tasks:** 5
|
||||
- **Files modified:** 64 hand-written (68 with the rebuilt dist)
|
||||
|
||||
## Accomplishments
|
||||
- Tracer (Task 1): a request carrying `bouncer.WithDispatch` runs `GET /acme/items/{id}` through `surf.Router.Handler` as principal 42 with the path value set; the same request without the marker, with forged `X-Summer-Dispatch`/`Authorization: Dispatch`/cookie headers, or with a marker for another guard is 401. `cabana.ResolveBackend` honours a `backend` marker, refuses a frontend one and keeps the cover check on a scoped principal. Additive `ResolveBackendToken`, `ScopeLimitFor`, `BackendPrincipal` reuse the published resolver guard.
|
||||
- surf: `compileHandlers` builds each chain once for both BuildRouter's validation and `compile`; `MountStream` + `recoverStream` serve on the real writer (first event received while the handler waits; a buffered route in the same test holds even its headers); `mountPier` hook with `mcp.enabled` false inert and the untagged error naming `summercms_mcp`.
|
||||
- wristband: `parseAuthorizeScopes(raw, allowed)` with `allowedAuthorizeScopes()` from `Options.ScopesSupported`; `backend` accepted only when a host lists it, metadata lists it, default server still answers `scope contains an unsupported value`. `cooler.KeyPrefix` exported.
|
||||
- pact: every MCP, frontend-permission, account-contribution and prompt type with doc comments naming the boot failures; `TestPactStaysSDKFree` runs `go list -deps`.
|
||||
- cabana: `compileAccountContributions` at Activate, the two account routes (swag-annotated, conformance and inventory tests extended), `RecordAction.prompt`, `promptValue` validation (`backend::lang.form.action_prompt_required` / `_too_long` en+pl), `RecordActionWithValue`, `fireSubjectChanged` wired into token revoke, Administrators and Roles saves, deactivate and delete (record and bulk through the shared lifecycle `run`). `account.go` untouched.
|
||||
- SPA: `AccountContributions.vue` mounted after `ApiTokensPanel`, prompt input in `ConfirmDialog`, `RecordActions` posting `{payload}` or `{}`, 1490 vitest tests green, dist rebuilt and matching.
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1: Tracer, dispatch marker and compiled handler lookup** - `1bd91a4` (feat)
|
||||
2. **Task 2: Streaming routes, MCP mount hook, configurable authorize scopes** - `5c15dea` (feat)
|
||||
3. **Task 3: SDK-free pact contracts** - `6887abf` (feat)
|
||||
4. **Task 4: Account contributions, prompted record actions, backend subject events** - `9f14cf6` (feat)
|
||||
5. **Task 5: Admin SPA** - `9a5f27e` (feat) and `fab99e0` (chore: rebuilt `modules/boardwalk/dist`)
|
||||
|
||||
**Plan metadata:** see the docs commit after this file.
|
||||
|
||||
## Files Created/Modified
|
||||
- `modules/bouncer/dispatch.go` - `Dispatch`, `WithDispatch`, `Dispatched`; `registry.go` honours it before `authenticate`
|
||||
- `modules/cabana/token_guard.go` - marker branch in `ResolveBackend`; `logTokenAuthAt`; `token_resolver.go` - the three additive resolvers
|
||||
- `modules/surf/router.go`, `routetable.go`, `streaming.go`, `pier_off.go` - handler map, `Handler`, stream kind, `MCPBuildTag`, `mountPier`
|
||||
- `modules/wristband/authorize.go` - allow-list from options; `modules/cooler/cooler.go` - `KeyPrefix`
|
||||
- `modules/pact/mcp.go`, `capabilities.go` - the contracts
|
||||
- `modules/cabana/account_contributions.go`, `subject_events.go`, `actions.go`, `crud.go`, `schema_types.go`, `http.go`, `admin_openapi.go`, `backend_users_admin.go`, `backend_roles_admin.go`, `account_tokens.go`, `contracts.go`, `action_extensions.go`, `extension.go`
|
||||
- `modules/phrasebook/backend/lang/{en,pl}/lang.yaml` - the two prompt phrases
|
||||
- `admin/src/components/ui/confirm.ts`, `ConfirmDialog.vue`, `form/RecordActions.vue`, `account/AccountContributions.vue`, `views/AccountView.vue`, `api/types.ts`; regenerated `admin/openapi/admin.json`, `admin/src/api/schema.d.ts`; rebuilt `modules/boardwalk/dist`
|
||||
- READMEs of bouncer, cabana, surf, wristband, cooler, pact; `docs/services/{authentication,routing,oauth-server}.md`, `docs/plugins/registration.md`, `docs/backend/{admin-controllers,users-and-permissions}.md`
|
||||
- Smoke tests: `TestDispatchSmoke`, `TestDispatchedSmoke`, `TestDispatchMarkerSmoke`, `TestStreamingRouteSmoke`, `TestPierMountSmoke`, `TestMCPScopesSmoke`, `TestAccountContributionsSmoke`, `TestRecordActionPromptSmoke` (all `-short`), `TestRecordActionPromptRun` (Postgres), two vitest files
|
||||
|
||||
## Decisions Made
|
||||
See `key-decisions` above: planner decisions P-01 to P-04 implemented as written; the account action transaction fallback without a database; events fired inside the saving transaction; the stream recovery rule; the wristband default kept.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] `TestPhase121ContractsOnSampleController` asserted `AdminRecordActionInput` has 2 fields**
|
||||
- **Found during:** Task 3
|
||||
- **Issue:** the test pins the input's shape; this plan adds `Value`
|
||||
- **Fix:** assertion updated to 3 with the comment that there is still no id list
|
||||
- **Files modified:** modules/pact/capabilities_test.go
|
||||
- **Verification:** `go test -short ./modules/pact/...`
|
||||
- **Committed in:** 6887abf
|
||||
|
||||
**2. [Rule 3 - Blocking] Admin route inventories refused the two new routes**
|
||||
- **Found during:** Task 4
|
||||
- **Issue:** `phase09Routes`, `tokenRouteClasses`, the CSRF walk count (34), the phase 10 unsafe-route `want` list and `conformCases` each fail when a route is added without an entry
|
||||
- **Fix:** entries added (both routes `classInteractive`; CSRF count 35; conformance cases with a section the `conformPlugin` contributes), so the gates keep protecting the inventory
|
||||
- **Files modified:** modules/cabana/security_coverage_test.go, token_routes_test.go, phase10_csrf_test.go, phase10_coverage_test.go, openapi_conformance_test.go
|
||||
- **Verification:** `go test -short ./modules/cabana/` and the Postgres conformance run
|
||||
- **Committed in:** 9f14cf6
|
||||
|
||||
**3. [Rule 2 - Missing critical] Postgres proof that `Run` receives the prompt value**
|
||||
- **Found during:** Task 4
|
||||
- **Issue:** there is no DB-free GORM driver, so the `-short` smoke can prove the route's validation and the show payload but not the `Run` call; the plan's "hands Value == acme to Run" needs a record load
|
||||
- **Fix:** `TestRecordActionPromptRun` on the 19.6.1 `screensEnv` harness (skips under `-short`), run through Docker and green
|
||||
- **Files modified:** modules/cabana/record_action_prompt_postgres_test.go
|
||||
- **Verification:** `go test -count=1 -run TestRecordActionPromptRun ./modules/cabana`
|
||||
- **Committed in:** 9f14cf6
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 3 auto-fixed (1 bug in a shape-pinning test, 1 blocking inventory, 1 missing proof)
|
||||
**Impact on plan:** No scope change; every deviation keeps an existing gate meaningful or adds the proof the plan asked for.
|
||||
|
||||
## Issues Encountered
|
||||
- `TestStreamingRouteSmoke` first deadlocked: the buffered comparison route holds even its response headers until the handler returns, so `client.Get` blocks; the GET now runs in a goroutine and the test asserts nothing arrives within 300 ms, then everything after the release.
|
||||
- `scripts/check-phase19.6.1.sh --all` (the plan's Docker-host gate) was stopped by the host while the session was idle, after `go test -count=1 ./modules/cabana ./modules/surf` had already passed (93.9 s and 15.5 s). Its `sc1` stage (account.go untouched) is proven separately by `git diff --quiet 51d088a -- modules/cabana/account.go`; the full gate should be re-run on the Docker host before the plan 02 release.
|
||||
- The plan's acceptance grep `json:"prompt,omitempty"` counts two lines in `schema_types.go`; the second is the pre-existing `FormField.Prompt` tag (logged in `deferred-items.md`, resolved).
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Known Stubs
|
||||
None. `AccountContributions.vue` renders nothing on an empty or failed list by design (a page without contributors is unchanged).
|
||||
|
||||
## Next Phase Readiness
|
||||
- Plan 02 (pier) can build on: `surf.Router.Handler` + `MountStream` + `mountPier` (set in a `pier_on.go` under `//go:build summercms_mcp`), `bouncer.WithDispatch`, `cabana.ResolveBackendToken`/`ScopeLimitFor`/`BackendPrincipal`, `pact.MCPGuards` (find-or-publish), `pact.MCPSubjectChanged` listeners, `cooler.KeyPrefix`.
|
||||
- Plan 03 (sm-user-plugin): `pact.HasFrontendPermissions`, `pact.HasAccountContributions` for "Link frontend account", a prompted `link_frontend_account` and a plain `unlink_frontend_account` on `cabana.AdministratorsControllerID`, `pact.MCPLinkedBackendResolver`, `pact.MCPPersonalTokenResolver`.
|
||||
- Plan 04 (oauthserver): append `backend` to the MCP server's `ScopesSupported`; publish `pact.MCPTokenVerifier`.
|
||||
- Plan 05: unit tests for the seams (event assertions, streaming edge cases), the gate grep that only `modules/pier` calls `WithDispatch` outside tests, and the deferred `gofmt` drift in cabana (`deferred-items.md`).
|
||||
- Re-run `bash scripts/check-phase19.6.1.sh --all` on the Docker host (stopped by the host this session, see Issues).
|
||||
|
||||
---
|
||||
*Phase: 19.7-generic-mcp-module*
|
||||
*Completed: 2026-10-22*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
All 12 listed created files exist on disk and all 6 task commits (1bd91a4, 5c15dea, 6887abf, 9f14cf6, 9a5f27e, fab99e0) are in history; measured commits a74a218..HEAD = 6.
|
||||
428
.planning/phases/19.7-generic-mcp-module/19.7-02-PLAN.md
Normal file
428
.planning/phases/19.7-generic-mcp-module/19.7-02-PLAN.md
Normal file
@@ -0,0 +1,428 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 02
|
||||
type: execute
|
||||
wave: 2
|
||||
depends_on: ["19.7-01"]
|
||||
files_modified:
|
||||
- go.mod
|
||||
- go.sum
|
||||
- .planning/notes/2026-10-22-mcp-go-sdk.md
|
||||
- .planning/research/STACK.md
|
||||
- modules/pier/README.md
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/config.go
|
||||
- modules/pier/host.go
|
||||
- modules/pier/catalog.go
|
||||
- modules/pier/dispatch.go
|
||||
- modules/pier/identity.go
|
||||
- modules/pier/guards.go
|
||||
- modules/pier/backend_guard.go
|
||||
- modules/pier/session.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/store_memory.go
|
||||
- modules/pier/store_redis.go
|
||||
- modules/pier/events.go
|
||||
- modules/pier/prm.go
|
||||
- modules/pier/audit.go
|
||||
- modules/pier/tracer_smoke_test.go
|
||||
- modules/pier/sessions_smoke_test.go
|
||||
- modules/pier/stateless_smoke_test.go
|
||||
- modules/surf/pier_on.go
|
||||
- modules/surf/README.md
|
||||
- README.md
|
||||
- docs/services/mcp.md
|
||||
- docs/site.yaml
|
||||
- docs/services/authentication.md
|
||||
- docs/plugins/registration.md
|
||||
autonomous: false
|
||||
requirements: [SC-1, SC-2, SC-3, SC-4, D-08, D-10, D-11, D-12, D-13, D-14, D-15, D-16, D-17, D-19, D-20, D-21, D-22, D-23, D-24, D-25, D-26, D-27, D-28, D-29, D-30, D-31, D-32, D-33, D-35, D-36]
|
||||
|
||||
estimate:
|
||||
tokens: 95000
|
||||
raw_tokens: 95000
|
||||
tasks: 6
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "An application built with the summercms_mcp tag and mcp.enabled true serves POST/GET/DELETE at mcp.path; without the tag the binary carries no go-sdk and with the flag off nothing is mounted (SC-1, D-30, D-33)"
|
||||
- "A plugin that implements pact.HasMCP has its tools exposed as <shortcode>_<name>; a plugin that declares none exposes none; a tool bound to a missing route, a non-token-guarded route without a Guard, a duplicate or invalid name, or a non-object Input fails boot by name (SC-2, D-10, D-12, D-15)"
|
||||
- "tools/list is computed for the identity of the current request: a read-only grant hides non-read-only tools, a tool whose guard has no subject is hidden, and the guard provider's MCPAllows decides the rest; a tools/call for a tool not in that list is refused (SC-3, D-16, D-20, D-23)"
|
||||
- "A tools/call runs in-process through surf's compiled chain of the bound route with the bouncer dispatch marker and no Authorization or Cookie header; a 2xx answers text plus structuredContent and a non-2xx answers isError with the route's own body (D-10, D-11, D-13, D-17)"
|
||||
- "Every request is authorized afresh from its bearer; a session is bound to (client_id, user_id) or the personal token id and refuses another binding with 403; DELETE ends it everywhere; a session initialised on one instance serves its next call on another through the Redis store (D-25, D-27, D-35)"
|
||||
- "A 2026-07-28 client is served statelessly and a 2025-11-25 client statefully from the same path, sharing identity, dispatch and filtering (D-32)"
|
||||
- "A subject-changed event on any instance reaches every session and stateless server of that subject: permission and link changes send notifications/tools/list_changed, revocation and deletion close the session (D-26, D-27)"
|
||||
- "The backend principal of a linked admin keeps the admin's real cabana permissions, superuser included, capped by the grant's read/write ceiling (D-22)"
|
||||
- "go-sdk v1.8.0 and jsonschema-go v0.4.3 are named in a decision note and a STACK.md row before any code imports them, and a human confirmed their legitimacy before go get (D-24)"
|
||||
- "The framework is tagged and pushed only after the user's go-ahead; the tag carries 19.6.1 together with 19.7 plans 01 and 02, and the changelog post follows the same day (D-31)"
|
||||
artifacts:
|
||||
- path: "modules/pier/pier.go"
|
||||
provides: "Mount, Config loading, boot validation"
|
||||
contains: "func Mount("
|
||||
- path: "modules/pier/catalog.go"
|
||||
provides: "prefixing, schema reflection, binding and name checks"
|
||||
contains: "jsonschema.ForType"
|
||||
- path: "modules/pier/dispatch.go"
|
||||
provides: "arguments to *http.Request, recorder to CallToolResult"
|
||||
contains: "httptest.NewRecorder"
|
||||
- path: "modules/pier/session.go"
|
||||
provides: "rehydrating session router over StreamableServerTransport"
|
||||
contains: "StreamableServerTransport"
|
||||
- path: "modules/pier/stateless.go"
|
||||
provides: "the 2026-07-28 stateless handler"
|
||||
contains: "Stateless"
|
||||
- path: "modules/pier/store_redis.go"
|
||||
provides: "Redis session registry and pub/sub fan-out"
|
||||
contains: "PExpire"
|
||||
- path: "modules/pier/prm.go"
|
||||
provides: "RFC 9728 protected resource metadata and the WWW-Authenticate challenge"
|
||||
contains: "oauth-protected-resource"
|
||||
- path: "modules/surf/pier_on.go"
|
||||
provides: "the tagged mount hook"
|
||||
contains: "//go:build summercms_mcp"
|
||||
- path: ".planning/notes/2026-10-22-mcp-go-sdk.md"
|
||||
provides: "the D-24 decision note"
|
||||
contains: "v1.8.0"
|
||||
- path: "docs/services/mcp.md"
|
||||
provides: "the MCP services page"
|
||||
- path: "modules/pier/README.md"
|
||||
provides: "standard module README with the Name mnemonic"
|
||||
contains: "**Name:**"
|
||||
key_links:
|
||||
- from: "modules/surf/pier_on.go"
|
||||
to: "modules/pier/pier.go"
|
||||
via: "init sets surf's mountPier hook to an adapter implementing pier.Host"
|
||||
pattern: "mountPier = "
|
||||
- from: "modules/pier/dispatch.go"
|
||||
to: "modules/bouncer/dispatch.go"
|
||||
via: "WithDispatch on the inner request context, the only call site outside tests"
|
||||
pattern: "WithDispatch\\("
|
||||
- from: "modules/pier/dispatch.go"
|
||||
to: "modules/surf/routetable.go"
|
||||
via: "host.Handler(method, pattern) resolved lazily on first call"
|
||||
pattern: "Handler\\("
|
||||
- from: "modules/pier/identity.go"
|
||||
to: "modules/pact/mcp.go"
|
||||
via: "app.Lookup of pact.MCPTokenVerifier, pact.MCPPersonalTokenResolver, pact.MCPLinkedBackendResolver and *pact.MCPGuards"
|
||||
pattern: "Lookup\\[pact\\."
|
||||
- from: "modules/pier/events.go"
|
||||
to: "modules/pact/mcp.go"
|
||||
via: "app.Events.Listen of pact.MCPSubjectChanged, republished on the store's channel"
|
||||
pattern: "MCPSubjectChanged"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: WithDispatch( -->
|
||||
<!-- planner-discipline-allow: modelcontextprotocol/go-sdk -->
|
||||
<!-- planner-discipline-allow: "ai" -->
|
||||
|
||||
<objective>
|
||||
Build `modules/pier`, the opt-in MCP endpoint inside a SummerCMS binary, on the official go-sdk v1.8.0, behind the `summercms_mcp` build tag (D-33) and the `mcp.enabled` flag (D-30): plugin-declared tools and prompts compiled from `pact.HasMCP` (D-10..D-16, D-28), per-request identity from an `oas_at_` verifier or, behind a flag, personal tokens (D-19), a backend subject resolved through the published link resolver on every request (D-08), per-principal filtering with the read/write ceiling (D-20, D-23) and the backend scope (D-21), in-process dispatch through surf's compiled handler with the bouncer marker (D-17), a Redis-backed rehydrating session router with a memory fallback (D-25, D-27), pub/sub fan-out of `list_changed` (D-26), the stateless 2026-07-28 path (D-32), protected resource metadata (RFC 9728), and an audit line per call (D-23). Then the framework release that carries 19.6.1 (executed, unreleased; the commits carried are whatever `git log --oneline v0.4.3..HEAD` lists at tag time, not a count fixed here) together with plans 01 and 02.
|
||||
|
||||
**Planner decisions recorded here:**
|
||||
- **P-05 (config keys, Claude's discretion):** namespace `mcp.*` (feature namespaces like `http.*`, `cache.*`, `realtime.*`): `mcp.enabled` (false), `mcp.path` (`/mcp`), `mcp.allow_personal_tokens` (false), `mcp.sessions.store` (`memory`|`redis`, default `memory`; A7: the single-instance demo has no Redis), `mcp.sessions.idle_ttl` (`30m`), `mcp.sessions.max_per_binding` (20), `mcp.resource` (default `app.url` + `mcp.path`, no trailing slash), `mcp.throttle` (`120,1`, surf's inline spelling), `mcp.allowed_origins` (default: the origin of `app.url`), `mcp.call_timeout` (`30s`), `mcp.max_result_bytes` (1048576).
|
||||
- **P-06 (session binding, D-35):** `oauth:<client_id>:<user_id>` for grants, `pat:user:<token_id>` and `pat:backend:<token_id>` for personal tokens; the binding survives access-token rotation.
|
||||
- **P-07 (link lookup staleness, D-08):** the linked admin is resolved per request through `pact.MCPLinkedBackendResolver` with an in-process cache of at most 5 seconds per frontend user id, invalidated at once by `pact.MCPSubjectChanged{Kind: link}`; the stated staleness bound is 5 s on the instance that did not receive the event and 0 on the one that did.
|
||||
- **P-08 (protocol routing, D-32):** a request whose `MCP-Protocol-Version` header is `2026-07-28`, or whose first JSON-RPC method is `server/discover`, goes to the SDK's stateless handler; everything else goes to the stateful router. The executor confirms the discriminator against go-sdk `docs/protocol.md` and `mcp/streamable.go` before coding it.
|
||||
- **P-09 (release version):** a new module, new pact capabilities and additive surf/bouncer/cabana API warrant a minor bump; the planner proposes `v0.5.0`, the user decides at the checkpoint.
|
||||
|
||||
Why the legitimacy checkpoint precedes the tracer: the tracer's first command is `go get` of two [ASSUMED] Go modules (RESEARCH Package Legitimacy Audit: the seam cannot check Go), and the project's rule gates every such install behind a blocking human check (as 19.5 and 19.6 did).
|
||||
|
||||
Purpose: SC-1, SC-2 and SC-3 become true in the framework; plans 03 and 04 can wire the user guard, the verifier, the link and the first tools.
|
||||
Output: `modules/pier` with README, the tagged `pier_on.go`, root README row, `docs/services/mcp.md`, the decision note and STACK row, smoke tests, and the tagged framework release after the go-ahead.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<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-PATTERNS.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md
|
||||
@.planning/notes/2026-10-20-sociallogin-goth.md
|
||||
@.planning/notes/2026-10-07-embedded-admin-release-gate.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Framework code and docs never name a consuming application or a specific plugin: pier names guards `user` and `backend`, never `golem15.user`, Journal or an MCP client vendor; examples use `acme`/`blog`.
|
||||
- Only `modules/pier` imports `github.com/modelcontextprotocol/go-sdk` and `github.com/google/jsonschema-go`; `pact` stays SDK-free (plan 01). `examples/hello` must still build and test without the tag.
|
||||
- A new dependency lands only after the decision note and the STACK.md row exist (D-24) and after the human legitimacy check (Task 1).
|
||||
- Stage by explicit path; one logical change per commit; planning docs separately; no co-author tags. Tag and push only inside Task 6 after the user's go-ahead.
|
||||
- Several sessions share this repo: run `git status --short` before touching `modules/surf`, `README.md`, `go.mod`; never edit `admin/src/state/useSettings.ts` or `admin/src/components/shell/SettingsPanel.vue`.
|
||||
- Docs rule: every identifier in `modules/pier/README.md` and `docs/services/mcp.md` must exist; Go code blocks need `src=` pointing at a tested file; run `go run ./cmd/summer docs:build --check` and `docs:sync` in the same commit as the code.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="checkpoint:human-verify" gate="blocking-human">
|
||||
<name>Task 1: Human legitimacy check of go-sdk v1.8.0 and jsonschema-go v0.4.3 before any go get</name>
|
||||
<what-built>Nothing yet: this gate precedes the first `go get`. RESEARCH's Package Legitimacy Audit marks `github.com/modelcontextprotocol/go-sdk` v1.8.0 and `github.com/google/jsonschema-go` v0.4.3 (plus the transitive `segmentio/asm`, `segmentio/encoding`, `yosida95/uritemplate/v3`, `golang.org/x/oauth2`, `golang.org/x/time`) as [ASSUMED], because the legitimacy seam supports npm, PyPI and crates only.</what-built>
|
||||
<how-to-verify>
|
||||
1. Open https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk@v1.8.0 and confirm the module path, that v1.8.0 (2026-09-04) is the latest tag and that the repository is github.com/modelcontextprotocol/go-sdk (the official organisation).
|
||||
2. Open https://pkg.go.dev/github.com/google/jsonschema-go@v0.4.3 and confirm the module path and that the repository is github.com/google/jsonschema-go.
|
||||
3. Optionally run `GOFLAGS=-mod=mod go list -m -versions github.com/modelcontextprotocol/go-sdk` from the repo root and confirm the list ends with v1.8.0 (a newer v1.9 may exist if executing after 2026-11-20; RESEARCH asks to re-check `@latest` then).
|
||||
4. Confirm the licences are acceptable: go-sdk MIT transitioning to Apache-2.0, jsonschema-go MIT.
|
||||
</how-to-verify>
|
||||
<resume-signal>Type "approved" to allow `go get` of exactly these two modules at these versions, or name the module and version to use instead</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 2: Tracer: one tool declared by a fake plugin is listed and called end-to-end by an SDK client through the stateful path, dispatching in-process with the marker</name>
|
||||
<reversibility rating="costly">Session storage and the per-session server shape the module's internals (D-25 costly, user-chosen); tool names once shipped are referenced by clients (D-12 costly).</reversibility>
|
||||
<files>.planning/notes/2026-10-22-mcp-go-sdk.md, .planning/research/STACK.md, go.mod, go.sum, modules/pier/pier.go, modules/pier/config.go, modules/pier/host.go, modules/pier/catalog.go, modules/pier/dispatch.go, modules/pier/identity.go, modules/pier/guards.go, modules/pier/backend_guard.go, modules/pier/session.go, modules/pier/store.go, modules/pier/store_memory.go, modules/pier/audit.go, modules/pier/tracer_smoke_test.go, modules/pier/README.md, modules/surf/pier_on.go, README.md</files>
|
||||
<read_first>
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md (the exact exported names plan 01 shipped: pact.MCP*, bouncer.WithDispatch, surf Handler/MountStream/mountPier, cabana.ResolveBackendToken/ScopeLimitFor/BackendPrincipal, cooler.KeyPrefix)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Summary", § "Architecture Patterns" (diagram, Patterns 1, 3, 4, 5, 8), § "Code Examples", § "Common Pitfalls" 3, 6, 7, 9, 11, 12, § "Anti-Patterns to Avoid"
|
||||
- .planning/notes/2026-10-20-sociallogin-goth.md (decision note format) and .planning/research/STACK.md lines 40-56 (row format)
|
||||
- go-sdk v1.8.0 in the module cache after go get: mcp/streamable.go (StreamableServerTransport, StreamableHTTPHandler sessions map, the 404 session-not-found), mcp/server.go (Server.AddTool low-level API and its type:object panic, RemoveTools, Connect, ServerSessionOptions), mcp/session.go (ServerSessionState), mcp/protocol.go (ToolAnnotations, CallToolResult), auth/auth.go (RequireBearerToken, TokenInfo), docs/protocol.md
|
||||
- jsonschema-go v0.4.3 jsonschema/infer.go (ForType, required rule, additionalProperties) and the Schema.Resolve/Validate API
|
||||
- modules/surf/apidocs.go 88-150 and modules/lagoon/attach/s3_on.go (mount and tag patterns), modules/surf/overlap.go 397-422 (SetPathValue, Pattern)
|
||||
- modules/cabana/administrators_harness_test.go 358-392 (request building against a handler with httptest.ResponseRecorder)
|
||||
- modules/cabana/contracts.go 295-335 (Allows and granted), modules/bouncer/context.go (ScopeLimit semantics)
|
||||
- modules/cooler/README.md § "Overview" rows 1-12 (README shape with the Name line) and root README.md lines 94-123 (module table row format)
|
||||
</read_first>
|
||||
<action>
|
||||
First (D-24, before any import): write `.planning/notes/2026-10-22-mcp-go-sdk.md` in the goth note's shape (Decision, Measurements, Maintenance risk, Rejected alternatives, Related dependencies, Package legitimacy, Consequences) with RESEARCH's numbers: go-sdk v1.8.0 (2026-09-04, MIT to Apache-2.0), jsonschema-go v0.4.3 (MIT), the exact new modules in the graph (go-sdk, jsonschema-go, segmentio/asm v1.1.3, segmentio/encoding v0.5.4, yosida95/uritemplate/v3 v3.0.2, x/oauth2 v0.35.0, x/time v0.15.0; x/sync and x/sys stay at the framework's newer versions), the +2.9 MiB stripped size, the build-tag containment (D-33: only tagged binaries link it), the stateful-only-in-memory sessions fact that motivates the own session router, and `govulncheck` run as `go run golang.org/x/vuln/cmd/govulncheck@latest ./modules/pier/...` with its result; add the STACK.md row for both modules naming the note. Commit as `docs(19.7-02): decide the MCP Go SDK`. Then `go get github.com/modelcontextprotocol/go-sdk@v1.8.0 github.com/google/jsonschema-go@v0.4.3` (exactly the versions the checkpoint approved).
|
||||
|
||||
Module skeleton (final package layout; identifiers are final unless the executor finds a conflict with the SDK, then record the rename in the SUMMARY):
|
||||
- `host.go`: `type Host interface { Routes() []RouteInfo; Handler(method, pattern string) (http.Handler, bool); MountStream(method, path string, h http.Handler, middleware ...string) error; MountJSON(method, path string, h http.Handler) error; Owner(method, path string) (string, bool) }` and `type RouteInfo struct { Method, Pattern, PluginID string; Middleware []string }` so pier never imports surf.
|
||||
- `config.go`: `type Config struct` with the P-05 keys, `LoadConfig(cfg *compass.Config) (Config, error)` validating the path like apidocs (absolute, no query/wildcard), the store name, durations and the throttle spelling; errors are `pier: mcp.<key> ...`.
|
||||
- `pier.go`: `func Mount(host Host, app *backpack.App, plugins []party.Plugin) error`: load config; collect `pact.HasMCP` plugins (zero is fine); compile the catalog; build the identity resolver, the guard set, the store (memory in this task) and the session router; mount `POST/GET/DELETE <path>` through `host.MountStream` with middleware `throttle:<mcp.throttle>` and the Origin check wrapper; refuse a path collision through `host.Owner` with an error naming the owner. Nothing dials Redis at mount.
|
||||
- `catalog.go`: prefix = last dot-segment of `plugin.ID()`, lowercased, runs of non `[a-z0-9]` replaced by `_`, plus `_`; exposed name must match `^[a-z0-9_]{1,128}$`; boot errors with the `pier: plugin %s tool %q ...` prefix for: route not found by exact method+pattern (D-10), route not token-guarded and no Guard (D-15: a guard provider's `MCPTokenGuarded(middleware)` must be true for the tool's Guard, or the tool names a Guard explicitly), unknown Guard name, duplicate exposed name within or across plugins (Pitfall 11), Input nil or not a struct/pointer-to-struct, `jsonschema.ForType` error or non-object schema, a `path:"x"` tag without a `{x}` segment or a segment without a tag, a GET/DELETE tool with fields that are neither path nor query; requirements per tool = `guard.MCPRequirements(middleware)` ∪ tool.Permissions (D-16); annotations per D-14 with explicit DestructiveHint/OpenWorldHint pointers (RESEARCH Code Example); prompts prefixed the same way (D-28) with duplicate checks against tools. The schema is resolved once at boot for validation.
|
||||
- `dispatch.go`: validate arguments against the resolved schema; split by tags; build `httptest.NewRequest(method, path-with-values+query, body)` where the body is the agent's raw JSON object minus path and query keys (Pitfall 6; no body for GET/DELETE); set `Content-Type` and `Accept: application/json`, copy `RemoteAddr`, `X-Forwarded-For`, `X-Real-IP`, `Accept-Language` from the outer request; never set `Authorization` or `Cookie`; `SetPathValue` for each segment and `r.Pattern = method + " " + pattern`; context = outer context with `mcp.call_timeout` and `bouncer.WithDispatch(&bouncer.Dispatch{Guards: d.Guards, Principal: d.Principal.(*bouncer.Principal), Credential: d.Credential})` from `guard.MCPDispatch(ctx, subject, method)`; resolve `host.Handler(method, pattern)` lazily once (cache per tool); serve into a size-capped `httptest.ResponseRecorder`; map 2xx to `TextContent` (body) plus `StructuredContent` (the parsed object, or `{"data": v}` for a non-object, Pitfall 12), anything else to `IsError: true` with the body as text and, when it is a JSON object, as structuredContent; a recorder cap overflow is an isError with a fixed text.
|
||||
- `identity.go`: `type Identity struct { Frontend, Backend *pact.MCPSubject; Scopes []string; Binding string; ExpiresAt time.Time }`; `resolve(ctx, raw string) (Identity, error)`: prefix `oas_at_` → the published `pact.MCPTokenVerifier` (missing → 401); when `mcp.allow_personal_tokens`: `g15_` → `cabana.ResolveBackendToken` (backend subject with Scopes = stored names, binding `pat:backend:<id>`), otherwise the published `pact.MCPPersonalTokenResolver` (frontend subject, `pat:user:<id>`); OAuth: frontend subject from the grant, binding `oauth:<client_id>:<user_id>`, and when `backend` ∈ scopes and the published `pact.MCPLinkedBackendResolver` answers, a backend subject `{Guard: "backend", UserID: link.ID, Scopes: grant scopes, ClientID, TokenID}` (P-07 cache). 401 answers carry `WWW-Authenticate: Bearer resource_metadata="<mcp.resource's PRM URL>"` (the PRM route itself is Task 3).
|
||||
- `guards.go`: `*pact.MCPGuards` looked up from the app (find-or-publish); `backend_guard.go`: the built-in `backend` provider: `MCPTokenGuarded` = middleware contains `backend`; `MCPRequirements` = none from middleware; `MCPAllows` = `cabana.Allows(principal, permissions)` where principal = `cabana.BackendPrincipal(ctx, app, subject.UserID)` with `Scope` = `cabana.ScopeLimitFor(app, subject.Scopes, method)` when the subject came from a `g15_` token; `MCPDispatch` returns that principal, the token row as credential for personal tokens, and `Guards: []string{"backend"}`. Registered into the MCPGuards registry at Mount unless a plugin already owns `backend` (then boot error naming the owner).
|
||||
- Filtering (`catalog.go` or `filter.go`): `allowed(ctx, id Identity) ([]tool, []prompt)`: tool.Guard must have a subject; D-20 ceiling: without `write` in the identity's scopes only tools whose ReadOnlyHint is true; then `guard.MCPAllows`. Applied to build a per-session server AND re-applied by receiving middleware on every `tools/list`, `prompts/list`, `prompts/get` and `tools/call` for the current request's identity (D-08, D-25 fresh auth): a call for a tool outside the list answers a JSON-RPC error with a fixed text.
|
||||
- `session.go` + `store.go` + `store_memory.go`: `type Store interface { Put(ctx, id string, rec Record, ttl) error; Get(ctx, id) (Record, bool, error); Touch(ctx, id, ttl) error; Delete(ctx, id) error; Publish(ctx, Event) error; Subscribe(ctx, func(Event)) error; Count(ctx, binding) (int, error) }`; `Record{Binding string; State []byte (json of mcp.ServerSessionState); Created time.Time}`; the stateful router: POST without `Mcp-Session-Id` whose method is `initialize` → `rand.Text()` id, per-identity `*mcp.Server` (name/version from app.name and the framework version), `Connect(ctx, &mcp.StreamableServerTransport{SessionID: id}, nil)`, store after `initialized` with the sliding TTL, refuse when `Count(binding) >= max_per_binding` (429); request with an id: `Get` → missing → 404 `session not found`; binding differs → 403 `{"error":"session_binding"}`; local transport present → serve, else rehydrate with `ServerSessionOptions{State}` (RESEARCH Code Example) and keep the transport in the local map; `Touch` on every request; DELETE → `Delete` + `Publish(ended)` + close local; a goroutine on `ss.Wait()` removes the local entry. Memory store: map with expiry sweep and in-process subscribers.
|
||||
- `audit.go`: one `pier: tool call` log line per call through `diary.For("pier")` with tool, guard, user_id, admin_id, client_id, session prefix (8 chars), status, duration_ms; never arguments, bodies or tokens.
|
||||
- `modules/surf/pier_on.go` (`//go:build summercms_mcp`): `func init() { mountPier = func(r *Router, app *backpack.App, plugins []party.Plugin) error { return pier.Mount(pierHost{r}, app, plugins) } }` with `pierHost` adapting Routes/Handler/MountStream/MountJSON/Owner (MountJSON registers a raw GET through GroupRaw under the pseudo-plugin `summercms.pier` via BindPlugin). Confirm `go build ./...` without the tag still excludes pier from `examples/hello` (`go version -m` of a hello binary lists no modelcontextprotocol module).
|
||||
|
||||
Tracer smoke `modules/pier/tracer_smoke_test.go` `TestPierTracerSmoke` (-short; the test lives in package pier and builds a real surf router with `surf.BuildRouter` through a tiny in-test Host adapter or by running with `-tags summercms_mcp` — pick one and state it in the test comment; prefer the in-test adapter so the pier package tests need no tag): a fake plugin declares one tool `echo` → `POST /acme/echo/{id}` whose route carries a fake token guard middleware `acme.auth` (a bouncer guard registered by the fake plugin, with UnauthorizedWriter 401) and whose handler echoes `{id, body, principal}`; the test publishes a fake `pact.MCPTokenVerifier` (prefix `oas_at_`, token `oas_at_test` → user 7, scopes read+write, client `c1`) and a fake `pact.MCPGuard` named `acme` (TokenGuarded on `acme.auth`, Allows true, Dispatch returning `&bouncer.Principal{ID: 7}` and Guards `["acme"]`); with `mcp.enabled: true` the SDK client (`mcp.NewClient` + `StreamableClientTransport` with an `http.Client` whose RoundTripper adds the bearer) connects to `httptest.NewServer(handler)`, `ListTools` returns exactly `acme_echo` with `readOnlyHint false` and `destructiveHint false`, `CallTool` with `{"id": 5, "text": "hi"}` returns `isError false`, structuredContent `principal == 7`, `id == 5` and the body without `id`; a call with a bearer `oas_at_bad` is a 401 with the `WWW-Authenticate` header; the same tool declared twice fails `Mount` with an error containing `acme_echo`; a tool bound to `GET /nope` fails with an error containing `/nope`.
|
||||
|
||||
README (`modules/pier/README.md`) in the standard structure with `**Name:** The pier where outside boats dock to reach the beach; agents connect here to reach the application's plugins.` (final mnemonic) and the root README row reusing the summary sentence; keep the API reference to what exists after this task (Task 4 completes it).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/pier/... ./modules/surf/... && go test -count=1 -short -run '^TestPierTracerSmoke$' -v ./modules/pier 2>&1 | grep -q -- '^--- PASS: TestPierTracerSmoke' && go build -tags summercms_mcp ./... && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS line for TestPierTracerSmoke is absent</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `test -f .planning/notes/2026-10-22-mcp-go-sdk.md && grep -c "v1.8.0" .planning/notes/2026-10-22-mcp-go-sdk.md` prints at least 1 and `grep -c "modelcontextprotocol/go-sdk" .planning/research/STACK.md` prints at least 1
|
||||
- `grep -c "github.com/modelcontextprotocol/go-sdk v1.8.0" go.mod` prints 1 and `grep -c "github.com/google/jsonschema-go v0.4.3" go.mod` prints 1
|
||||
- `grep -rl "modelcontextprotocol/go-sdk" modules --include=*.go | grep -v '^modules/pier/' | grep -v '^modules/surf/pier_on.go' | wc -l` prints 0
|
||||
- `head -1 modules/surf/pier_on.go` prints `//go:build summercms_mcp` and `grep -c "mountPier = " modules/surf/pier_on.go` prints 1
|
||||
- `grep -c "func Mount(" modules/pier/pier.go` prints 1; `grep -c "jsonschema.ForType" modules/pier/catalog.go` prints at least 1; `grep -c "httptest.NewRecorder" modules/pier/dispatch.go` prints at least 1; `grep -c "StreamableServerTransport" modules/pier/session.go` prints at least 1
|
||||
- `grep -c "WithDispatch(" modules/pier/dispatch.go` prints at least 1 and `grep -rl "WithDispatch(" modules --include=*.go | grep -v _test.go | grep -v '^modules/bouncer/' | grep -v '^modules/pier/' | wc -l` prints 0
|
||||
- `OUT=$(mktemp -d) && go -C examples/hello build -o "$OUT/hello-notag" . && test -x "$OUT/hello-notag" && go version -m "$OUT/hello-notag" > "$OUT/mods.txt" && ! grep -q modelcontextprotocol "$OUT/mods.txt"` exits 0 (the untagged hello binary must build and its module list must be readable before the absence of the SDK counts; a failed build or an absent binary fails the criterion instead of passing it)
|
||||
- `grep -c "^\*\*Name:\*\*" modules/pier/README.md` prints 1 and `grep -c "\[pier\](modules/pier/README.md)" README.md` prints 1
|
||||
- `go test -count=1 -short -run '^TestPierTracerSmoke$' -v ./modules/pier 2>&1 | grep -q -- '^--- PASS: TestPierTracerSmoke'`
|
||||
</acceptance_criteria>
|
||||
<done>An SDK client lists and calls one plugin-declared tool end-to-end through pier's stateful path, the call runs in-process through surf's compiled guard chain as the pre-resolved principal, the SDK is contained behind the tag, and the decision note, STACK row and README exist.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Redis sessions with rehydration, DELETE and pub/sub fan-out; the stateless 2026-07-28 path; protected resource metadata, Origin protection and the periodic re-verification of long streams</name>
|
||||
<files>modules/pier/store_redis.go, modules/pier/store.go, modules/pier/session.go, modules/pier/stateless.go, modules/pier/events.go, modules/pier/prm.go, modules/pier/pier.go, modules/pier/sessions_smoke_test.go, modules/pier/stateless_smoke_test.go, modules/pier/README.md</files>
|
||||
<read_first>
|
||||
- modules/pier/*.go as left by Task 2
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pattern 8", § "Pattern 9", § "Pitfall 2", § "Pitfall 10", § "State of the Art", § "Code Examples: Rehydrating a session" and "Targeted list_changed"
|
||||
- go-sdk v1.8.0: mcp/streamable.go (StreamableHTTPHandler, StreamableHTTPOptions.Stateless, the 2026-07-28 acceptance rule, the deprecated CrossOriginProtection note), docs/protocol.md (server/discover, subscriptions/listen, protocol version header rules), mcp/server.go 740-770 (list_changed debounce), auth/auth.go (ProtectedResourceMetadataHandler), oauthex (ProtectedResourceMetadata)
|
||||
- modules/cooler/cooler.go (OpenRedis, RedisURLKey, KeyPrefix) and the miniredis usage in modules/cooler/*_test.go
|
||||
- modules/festival/bus.go (Listen, Fire)
|
||||
- modules/surf/apidocs.go 140-146 (static JSON route headers)
|
||||
</read_first>
|
||||
<action>
|
||||
Redis store (`store_redis.go`): `newRedisStore(client *redis.Client, prefix string)` with keys `<prefix>mcp:s:<id>` holding the JSON record (`SET ... PX ttl`), `Touch` = `PEXPIRE`, `Count(binding)` through a per-binding set `<prefix>mcp:b:<binding>` kept in step (SADD/SREM, expiry refreshed with the record), `Publish`/`Subscribe` on channel `<prefix>mcp:events` with JSON events `{kind, guard, user_id, session_id, instance}`; the client is opened lazily on first use with `cooler.OpenRedis(ctx, cfg.String(cooler.RedisURLKey))` when `mcp.sessions.store` is `redis` (a missing `redis.url` is a first-request 503 logged once, not a boot failure, mirroring cooler's never-fail-boot rule; `route:list` and tests never dial). Prefix from `cooler.KeyPrefix(cfg)`.
|
||||
|
||||
Rehydration and binding (`session.go`): as Task 2 specified, now against both stores; two routers on one miniredis in `TestPierSessionsSmoke`: initialise on A, call on B (B rehydrates from the stored `ServerSessionState` and serves `tools/call`), a second bearer with another binding presenting the same id gets 403 `session_binding`, DELETE on B ends the session and A's next call answers 404, an idle session whose TTL elapses (miniredis `FastForward`) answers 404, `max_per_binding` + 1 initialisations answer 429.
|
||||
|
||||
Fan-out (`events.go`): at Mount, `app.Events.Listen[*pact.MCPSubjectChanged]("summercms.pier", ...)` republishes each event through `Store.Publish`; every instance's subscriber handles: `ended` → close the local transport; `permissions`/`link` for a subject → for every local session and stateless server whose Identity includes that subject (guard+user id) recompute `allowed(...)` and apply the diff with `AddTool`/`RemoveTools` (and the prompt equivalents), which makes the SDK send `notifications/tools/list_changed` (and `prompts/list_changed`); `revoked`/`deleted` → close those sessions and evict the stateless servers, plus `Delete` their records. Also invalidate the P-07 link cache on `link`. `TestPierFanOutSmoke`: an SDK client with `ToolListChangedHandler` connected on instance B receives list_changed after `app.Events.Fire` of a permissions event on instance A whose fake guard now denies the tool; a revoked event ends the session (next call 404).
|
||||
|
||||
Long streams (Pitfall 10): the GET stream handler re-resolves the request's bearer every 60 s (the raw bearer stays only in that goroutine's memory for the stream's lifetime) and closes the stream when it fails; the serve BaseContext already cancels streams on shutdown.
|
||||
|
||||
Stateless path (`stateless.go`, D-32, P-08): `mcp.NewStreamableHTTPHandler(getServer, &mcp.StreamableHTTPOptions{Stateless: true})` where `getServer(r)` returns the per-identity server from an in-process LRU keyed by binding (capacity `max_per_binding * 16`, evicted on revocation), built from `allowed(...)` and mutated on fan-out events so `subscriptions/listen` clients receive list changes; the shared entry handler routes by `MCP-Protocol-Version: 2026-07-28` or a peeked first JSON-RPC method `server/discover` (bounded peek, body re-wrapped) to this handler, else to the stateful router; both run behind the same bearer resolution (every request authorized afresh). `TestPierStatelessSmoke`: the SDK client at its default (newest) protocol negotiates `2026-07-28` with no `Mcp-Session-Id` and calls the tool; a client pinned to `2025-11-25` gets a session; both see the same per-identity list.
|
||||
|
||||
PRM (`prm.go`, RFC 9728): `auth.ProtectedResourceMetadataHandler(&oauthex.ProtectedResourceMetadata{Resource: cfg.Resource, AuthorizationServers: []string{issuer}, ScopesSupported: [read write ai offline_access backend], BearerMethodsSupported: [header]})` mounted through `host.MountJSON` at `/.well-known/oauth-protected-resource` and `/.well-known/oauth-protected-resource<path>`; `issuer` = the verifier's `MCPResource()` origin when published, else `app.url`; a boot warning when `mcp.resource` differs from the verifier's `MCPResource()` (Pitfall 8). 401s carry `WWW-Authenticate: Bearer resource_metadata="<app.url>/.well-known/oauth-protected-resource<path>", scope="read"`.
|
||||
|
||||
Origin protection (V13): wrap the entry handler so a request with an `Origin` header outside `mcp.allowed_origins` (default: the origin of `app.url`) answers 403 before any body is read; requests without Origin pass (non-browser clients). Document the key.
|
||||
|
||||
README: complete Features (sessions, fan-out, hybrid protocol, PRM, Origin), Configuration (every `mcp.*` key with default), and the operational notes (memory store = single instance; Redis = shared sessions).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pier/... && go test -count=1 -short ./modules/pier/... && go test -count=1 -short -run '^(TestPierSessionsSmoke|TestPierFanOutSmoke|TestPierStatelessSmoke)$' -v ./modules/pier 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS count line is not exactly 3</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "PExpire\|PEXPIRE" modules/pier/store_redis.go` prints at least 1 and `grep -c "mcp:events" modules/pier/store_redis.go` prints at least 1
|
||||
- `grep -c "Stateless: *true" modules/pier/stateless.go` prints 1 and `grep -c "server/discover" modules/pier/stateless.go` prints at least 1
|
||||
- `grep -c "ProtectedResourceMetadataHandler" modules/pier/prm.go` prints 1 and `grep -c "oauth-protected-resource" modules/pier/prm.go` prints at least 2
|
||||
- `grep -c "MCPSubjectChanged" modules/pier/events.go` prints at least 1 and `grep -c "RemoveTools" modules/pier/events.go modules/pier/session.go modules/pier/stateless.go | grep -v ':0' | wc -l` prints at least 1
|
||||
- `grep -c "mcp.allowed_origins" modules/pier/README.md` prints at least 1 and `grep -c "mcp.sessions.store" modules/pier/README.md` prints at least 1
|
||||
- The three smoke tests print `--- PASS` under `-short` using miniredis (no Docker, no real Redis)
|
||||
</acceptance_criteria>
|
||||
<done>Sessions live in Redis with rehydration, binding and DELETE semantics proven across two instances; subject events fan out to list_changed or session close; 2026-07-28 clients are served statelessly next to stateful 2025-11-25 clients; PRM and Origin protection are in place.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: Identity kinds, ceilings and prompts: personal tokens behind the flag, the backend scope and link, read/write ceiling, prompts/get, and the audit line; docs page and READMEs</name>
|
||||
<files>modules/pier/identity.go, modules/pier/catalog.go, modules/pier/dispatch.go, modules/pier/audit.go, modules/pier/pier.go, modules/pier/tracer_smoke_test.go, modules/pier/README.md, modules/surf/README.md, docs/services/mcp.md, docs/site.yaml, docs/services/authentication.md, docs/plugins/registration.md</files>
|
||||
<read_first>
|
||||
- modules/pier/*.go as left by Task 3
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md D-19, D-20, D-21, D-22, D-23, D-28, D-35 (the `ai` scope plays no part in the ceiling)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pitfall 7" (method-filtered g15_ scopes), § "Pitfall 9" (in-memory credentials), § "Anti-Patterns: Imperative or dynamic tool descriptions"
|
||||
- modules/cabana/token_resolver.go (plan 01: ResolveBackendToken, ScopeLimitFor, BackendPrincipal)
|
||||
- docs/services/caching.md and docs/services/realtime.md (the shape of a services page), docs/site.yaml (the services nav list), docs/services/authentication.md § "Accepting admin tokens on plugin routes", docs/plugins/registration.md § "Capability interfaces"
|
||||
- cmd/summer/docs.go 25-80 (docs checker rules: identifiers, links, anchors, `src=` snippets, command names)
|
||||
</read_first>
|
||||
<action>
|
||||
Identity (D-19): when `mcp.allow_personal_tokens` is false, any bearer that is not `oas_at_` is a 401 (no lookup). When true: `g15_` → `cabana.ResolveBackendToken` → backend subject only (frontend tools hidden); other prefixes → the published `pact.MCPPersonalTokenResolver` (frontend subject only; the resolver reports false for a prefix it does not own → 401). Personal-token identities carry the token's own scopes as the ceiling (D-19 "capped by that token's own scope exactly as over HTTP"): for `g15_` the ScopeLimit is computed per dispatched route method through `ScopeLimitFor` (Pitfall 7), for user tokens the guard provider's `MCPAllows` sees the token scopes in the subject.
|
||||
|
||||
Ceilings (D-20, D-21, D-22, D-35): the read/write ceiling uses only `read` and `write` (`ai` and `offline_access` are ignored); `write` present → all tools the guard allows; only `read` → tools with ReadOnlyHint true; a backend subject exists only with `backend` in the OAuth scopes and a link (Task 2) or with a `g15_` token; the backend principal is the admin's real cabana principal (superuser and grants from `BackendPrincipal`) so D-22 holds, and the D-20 ceiling applies on top in pier. Prompts (D-28): `prompts/list` filtered by Guard and Permissions exactly like tools; `prompts/get` runs `Render(ctx, args)` with required-argument validation and returns the messages; prompts never dispatch a route.
|
||||
|
||||
Descriptions: pier passes the plugin's static Title and Description through unchanged and refuses a Description longer than 1024 runes with a boot error; the content itself is not inspected. The docs page tells plugin authors to keep descriptions static and factual (RESEARCH anti-pattern).
|
||||
|
||||
Audit (D-23): finalize `audit.go`: the `pier: tool call` line carries `tool`, `guard`, `user_id` (frontend subject, 0 when none), `admin_id` (backend subject), `client_id`, `token_kind` (oauth|pat), `session` (8-char prefix or `stateless`), `status`, `duration_ms`; `pier: session` lines for open/rehydrate/end/binding-refused with the binding (never the token). Extend `TestPierTracerSmoke` (or add cases to it) for: a read-only grant hides a POST tool and lists a GET tool; a `write` grant lists both; `allow_personal_tokens` false → a `g15_` bearer is 401; true → a fake `g15_` resolver path (the cabana resolver needs a DB, so pier accepts an injected resolver func in tests through an unexported seam) yields a backend subject; a prompt declared by the fake plugin is listed as `acme_<name>` and `prompts/get` returns its messages; the audit line for a call contains `tool=acme_echo` and no argument text.
|
||||
|
||||
Docs (D-29 and the docs rule): `docs/services/mcp.md` with sections: What it is (one connector per person), Enabling it (`summer.yaml` `build.tags: [summercms_mcp]`, `mcp.enabled`, the `mcp.*` keys table with defaults), Declaring tools and prompts (`pact.HasMCP`, the tag mapping, naming and prefixing, guards `user` and `backend`, Permissions, annotations; a Go example block with `src=` pointing at `modules/pier/example_mcp_test.go`, a tested neutral `acme.blog` example added in this task), Identity and sessions (OAuth through the application's authorization server, `backend` scope and the account link, personal tokens behind the flag, binding, TTL, Redis vs memory, 2026-07-28 vs 2025-11-25), Protected resource metadata, Security notes (no token passthrough, marker, Origin), Operations (nginx needs to route the path and the well-known paths; audit log). Register the page in `docs/site.yaml` under services. Add the cross-links: `docs/services/authentication.md` (the dispatch marker paragraph from plan 01 gains the pier sentence), `docs/plugins/registration.md` (HasMCP row links to the page), surf README (the tagged hook and `pier_on.go`). Complete `modules/pier/README.md` API reference (Mount, Host, RouteInfo, Config, LoadConfig and every exported identifier) and Testing. `go run ./cmd/summer docs:sync` after adding the `src=` block.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/pier/... && go test -count=1 -short -run '^TestPierTracerSmoke$' -v ./modules/pier 2>&1 | grep -q -- '^--- PASS: TestPierTracerSmoke' && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check && go -C examples/hello test -count=1 ./...</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS line for TestPierTracerSmoke is absent</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `test -f docs/services/mcp.md && grep -c "summercms_mcp" docs/services/mcp.md` prints at least 1 and `grep -c "mcp" docs/site.yaml` prints at least 1
|
||||
- `grep -c "src=modules/pier/example_mcp_test.go" docs/services/mcp.md` prints at least 1 and `test -f modules/pier/example_mcp_test.go`
|
||||
- `grep -c "allow_personal_tokens" modules/pier/identity.go` prints at least 1 and `grep -c "ScopeLimitFor" modules/pier/backend_guard.go modules/pier/identity.go | grep -v ':0' | wc -l` prints at least 1
|
||||
- `grep -c "\"ai\"" modules/pier/catalog.go modules/pier/identity.go | grep -v ':0' | wc -l` prints 0 (the ceiling code never mentions the ai scope; prm.go's scopes_supported list is the only place it may appear)
|
||||
- `grep -c "duration_ms" modules/pier/audit.go` prints at least 1
|
||||
- `go run ./cmd/summer docs:build --check` prints no problems
|
||||
- `grep -c "## API reference\|## Configuration\|## Testing\|## Dependencies" modules/pier/README.md` prints 4
|
||||
</acceptance_criteria>
|
||||
<done>Personal tokens work only behind the flag with their own ceilings, read/write and backend ceilings filter the list, prompts list and render, every call leaves one audit line without secrets, and the module and the services page are fully documented.</done>
|
||||
</task>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking-human">
|
||||
<name>Task 5: Decide the framework release version and give the go-ahead to tag and push</name>
|
||||
<decision>Tag and push the framework release that carries Phase 19.6.1 (Administrators and Roles screens; the commits carried are those `git log --oneline v0.4.3..HEAD` lists at tag time, pasted with their measured count into the checkpoint message) together with 19.7 plans 01 and 02 (the seams and the pier module), and post the changelog entry the same day.</decision>
|
||||
<context>The tag is a one-way door: consumers pin it, the plugin releases of plans 03 and 04 require it, and `summercms.io/changelog` announces it. The planner proposes a minor bump (P-09): a new module `pier`, new `pact` capabilities (HasMCP, HasFrontendPermissions, HasAccountContributions, the record action Prompt), additive surf/bouncer/cabana/wristband/cooler API. Nothing is pushed before you answer. Pre-checks the executor runs before asking: clean `git status` for the framework paths, `go vet ./... && go test -count=1 ./...` (Docker suites included), `scripts/check-admin-dist.sh`, `scripts/check-admin-openapi.sh --check`, `go run ./cmd/summer docs:build --check`, `bash scripts/check-phase19.6.1.sh --all`, and `go build -tags summercms_mcp ./...`; then `git log --oneline v0.4.3..HEAD`, whose list and line count the executor pastes into the checkpoint message as the measured content of the tag (concurrent sessions add commits, so no count is assumed in advance).</context>
|
||||
<options>
|
||||
<option id="v050">
|
||||
<name>Tag v0.5.0 now</name>
|
||||
<pros>Minor bump signals the new module and capabilities; consumers see one coherent jump that includes 19.6.1</pros>
|
||||
<cons>Any later 19.7 fix (plans 03-05) needs a v0.5.1</cons>
|
||||
</option>
|
||||
<option id="v044">
|
||||
<name>Tag v0.4.4 now</name>
|
||||
<pros>Keeps the 0.4 line; smallest version noise</pros>
|
||||
<cons>Understates a new module and new published pact types</cons>
|
||||
</option>
|
||||
<option id="hold">
|
||||
<name>Hold the tag</name>
|
||||
<pros>Lets you review the diff first</pros>
|
||||
<cons>Plans 03 and 04 cannot pin a framework version until the tag exists</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer v050, v044 or hold (with hold, say when to continue)</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 6: Cut the framework release at the chosen version and publish the changelog post</name>
|
||||
<reversibility rating="one-way">A pushed vX.Y.Z tag is pinned by consumer go.mod files and announced on summercms.io/changelog; retracting it needs a retract directive and a follow-up tag.</reversibility>
|
||||
<precondition>The Task 5 checkpoint answered v050 or v044 (recorded in the executor's checkpoint log), the tree is clean for every framework path, and `~/.config/summercms/journal-token` exists (the changelog script reads it; if missing or refused, stop and ask the user rather than minting one)</precondition>
|
||||
<files>.planning/notes/2026-10-22-mcp-go-sdk.md</files>
|
||||
<read_first>
|
||||
- CLAUDE.md § "Commits and concurrency" (tag message, changelog post flow, never print or mint the token)
|
||||
- ../sm-summercmsio-app/DEPLOY.md § "Posting to the changelog"
|
||||
- .planning/notes/2026-10-07-embedded-admin-release-gate.md
|
||||
- `git log --oneline v0.4.3..HEAD` (the commits the tag carries: 19.6.1 plans 01-04, quick-261022-imo, 19.7 plans 01-02)
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-0{1,2,3,4}-SUMMARY.md (for the tag message's 19.6.1 highlights)
|
||||
</read_first>
|
||||
<action>
|
||||
Run the pre-checks named in the checkpoint context once more on the exact HEAD to be tagged. Write an annotated tag message that lists, in this order: Phase 19.6.1 (Settings → System → Administrators and Roles, the cross-controller record action seam, field triggers and per-record permission locks, the two production fixes), Phase 19.7 plan 01 (dispatch marker, streaming routes and the Handler lookup, the pact MCP and account contribution contracts, the prompted record action, wristband's scope set), Phase 19.7 plan 02 (the `pier` module behind `summercms_mcp`, the `mcp.*` keys, the go-sdk decision note). `git tag -a <version> -m "<message>"` then `git push origin master --tags` (this push is the go-ahead the checkpoint gave; no other branch). Then from `../sm-summercmsio-app`: `scripts/changelog-post.py source <version>` to print the tag message and commits, write user-facing notes under `## Highlights`, `## Added`, `## Changed`, `## Fixed` (no planning IDs, no `quick-*` codes, no H1, framework and plugin names only, never a consuming application), save them to the scratchpad (`<your session scratchpad directory>/changelog-<version>.md`) and run `scripts/changelog-post.py publish <version> <that file> --excerpt "<one sentence>"`. Append a "Released in <version>" line to the Consequences section of the decision note (planning docs commit). Record the version in the SUMMARY so plans 03 and 04 pin it.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>TAG=$(git describe --tags --exact-match HEAD) && git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null</automated>
|
||||
<fails_when>non-zero exit: git describe fails because HEAD is not tagged, or git ls-remote exits 2 because origin has no such tag</fails_when>
|
||||
<human-check>Open https://summercms.io/changelog and confirm the new version's post is live with the four sections.</human-check>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `git describe --tags --exact-match HEAD` prints the version chosen at the checkpoint (v0.5.0 or v0.4.4)
|
||||
- `git ls-remote --exit-code --tags origin "refs/tags/<version>" >/dev/null` exits 0 (origin has the tag; a failing ls-remote exits 2 instead of passing)
|
||||
- `MSG=$(git log -1 --format=%B <version>) && printf '%s\n' "$MSG" | grep -q "19.6.1\|Administrators"` exits 0 (the tag message names the 19.6.1 content it carries; an unknown tag fails the criterion)
|
||||
- `grep -c "Released in" .planning/notes/2026-10-22-mcp-go-sdk.md` prints 1
|
||||
- The changelog publish command exited 0 and printed the post URL (recorded in the SUMMARY)
|
||||
</acceptance_criteria>
|
||||
<done>The framework release is tagged and pushed at the chosen version with 19.6.1 and 19.7 plans 01-02, and the changelog post is live.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**Go module `modules/pier`** (the only importer of go-sdk and jsonschema-go): `Mount`, `Host`, `RouteInfo`, `Config`, `LoadConfig`, `Identity`, `Store`, `Record`, `newMemoryStore`, `newRedisStore`, the catalog (`compileCatalog`, prefix rule), `dispatch`, the built-in `backend` guard provider, the session router, the stateless handler, `events`, `prm`, `audit`; `modules/pier/example_mcp_test.go` (the docs' `src=` example, `acme.blog`)
|
||||
**surf**: `modules/surf/pier_on.go` (`//go:build summercms_mcp`), pseudo-plugin id `summercms.pier`
|
||||
**Config keys**: `mcp.enabled`, `mcp.path`, `mcp.allow_personal_tokens`, `mcp.sessions.store`, `mcp.sessions.idle_ttl`, `mcp.sessions.max_per_binding`, `mcp.resource`, `mcp.throttle`, `mcp.allowed_origins`, `mcp.call_timeout`, `mcp.max_result_bytes` (reads `redis.url` through cooler when the store is redis)
|
||||
**Routes**: `POST|GET|DELETE <mcp.path>` (stream kind), `GET /.well-known/oauth-protected-resource`, `GET /.well-known/oauth-protected-resource<mcp.path>`
|
||||
**Redis keys/channels**: `<prefix>mcp:s:<id>`, `<prefix>mcp:b:<binding>`, channel `<prefix>mcp:events`
|
||||
**Log lines**: `pier: tool call`, `pier: session` (component `pier`)
|
||||
**Dependencies**: `github.com/modelcontextprotocol/go-sdk v1.8.0`, `github.com/google/jsonschema-go v0.4.3` (+ transitive per the decision note)
|
||||
**Docs**: `.planning/notes/2026-10-22-mcp-go-sdk.md`, STACK.md rows, `modules/pier/README.md`, root README row, `docs/services/mcp.md`, `docs/site.yaml` entry
|
||||
**Release**: framework tag (v0.5.0 proposed) carrying 19.6.1 + 19.7-01 + 19.7-02; changelog post
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| MCP client to `/mcp` | bearer tokens, session ids, JSON-RPC bodies and SSE streams from the internet |
|
||||
| pier to plugin routes | in-process requests carrying a pre-resolved principal through the marker |
|
||||
| pier to Redis | session records and fan-out events shared across instances |
|
||||
| plugins to pier at boot | tool declarations (names, descriptions, routes, schemas) merged into the catalog |
|
||||
| supply chain | two new Go modules and their transitive graph |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-10 | Spoofing | bearer verification | high | mitigate | Every request re-verifies the bearer through the published verifier or resolver (D-25); a session never replaces the bearer; a missing or failing verifier is a 401 with the PRM challenge (`TestPierTracerSmoke`) |
|
||||
| T-19.7-11 | Spoofing | session hijack with a stolen Mcp-Session-Id | high | mitigate | Binding key (client_id+user_id or token id) compared on every request, 403 on mismatch; `rand.Text()` ids; records expire on the sliding TTL (`TestPierSessionsSmoke`) |
|
||||
| T-19.7-12 | Elevation | token passthrough / confused deputy | high | mitigate | The inner request never carries Authorization or Cookie; identity travels only in the marker; the dispatcher strips both headers (asserted by the echo route in `TestPierTracerSmoke`) |
|
||||
| T-19.7-13 | Elevation | scope escalation to backend tools | high | mitigate | A backend subject exists only with `backend` in the grant AND a verified link resolved per request, or a `g15_` token behind the flag; the D-20 ceiling applies on top; the list and the call use the same `allowed` function (Task 4 cases) |
|
||||
| T-19.7-14 | Information Disclosure | tool-list leakage across principals | high | mitigate | One server per identity; receiving middleware re-filters list and call for the current request's identity; stateless servers keyed by binding (`TestPierStatelessSmoke`, `TestPierSessionsSmoke`) |
|
||||
| T-19.7-15 | Elevation | Redis rehydration of a session whose link or grant was revoked | high | mitigate | Rehydration re-reads identity from the current bearer, not from the stored state; revoked/deleted events delete the record and close sessions on every instance; the link cache is at most 5 s (P-07) and invalidated by the link event (`TestPierFanOutSmoke`) |
|
||||
| T-19.7-16 | Spoofing | audience confusion (OIDC or foreign token at /mcp) | medium | mitigate | Only `oas_at_` tokens reach the verifier (plan 04's verifier checks client kind mcp); PRM `resource` equals the verifier's resource with a boot warning on mismatch |
|
||||
| T-19.7-17 | Tampering | argument injection into routes | medium | mitigate | Arguments validated against the reflected schema with additionalProperties false; single-segment path values may not contain `/`; the route's own Where constraints and body limit still run in the compiled chain; raw JSON forwarded only minus path/query keys |
|
||||
| T-19.7-18 | Denial of Service | sessions, streams and large results | medium | mitigate | `mcp.throttle` inline limiter, `max_per_binding` (429), idle TTL, SDK body cap, `mcp.call_timeout`, `mcp.max_result_bytes` on the recorder, periodic re-verification closes stale streams |
|
||||
| T-19.7-19 | Spoofing | DNS rebinding / browser Origin | medium | mitigate | `mcp.allowed_origins` check answers 403 before reading a body; default is the app's own origin |
|
||||
| T-19.7-20 | Information Disclosure | audit log contents | medium | mitigate | The audit line carries ids, names, status and duration only; never tokens, arguments or bodies (asserted in `TestPierTracerSmoke`) |
|
||||
| T-19.7-21 | Tampering | prompt injection through tool metadata | low | accept | Descriptions are plugin-authored static text passed through unchanged (length-capped); the docs page instructs authors to keep them factual; dynamic text is a plugin bug, not a framework surface |
|
||||
| T-19.7-SC | Tampering | go get of go-sdk and jsonschema-go | high | mitigate | Blocking human legitimacy check (Task 1) before `go get`; versions pinned in go.mod; the decision note lists the transitive graph and the govulncheck result; the SDK is linked only in tagged binaries |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go vet ./... && go test -count=1 -short ./... && go build -tags summercms_mcp ./... && go -C examples/hello test -count=1 ./... && go test -count=1 -run '^TestDocsTree$' ./cmd/summer && go run ./cmd/summer docs:build --check && scripts/check-admin-openapi.sh --check`
|
||||
- The pier smoke tests `TestPierTracerSmoke`, `TestPierSessionsSmoke`, `TestPierFanOutSmoke`, `TestPierStatelessSmoke` print `--- PASS` under `-short` (miniredis, no Docker)
|
||||
- `go version -m` of a hello binary built without the tag lists no `modelcontextprotocol` module
|
||||
- Docker host before the tag: `go test -count=1 ./...` and `bash scripts/check-phase19.6.1.sh --all`
|
||||
- After Task 6: the tag exists locally and on origin; the changelog post is live
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- SC-1, SC-2 and SC-3 hold in the framework with a fake plugin; every must_have truth above is demonstrated by a named smoke test or by the release artifacts
|
||||
- The SDK is imported only by `modules/pier` and `modules/surf/pier_on.go`; `pact` stays SDK-free; `examples/hello` is unaffected
|
||||
- The decision note and STACK row predate the first import (commit order visible in `git log`)
|
||||
- The tag and push happened only after the checkpoint answer; the SUMMARY records the version for plans 03 and 04
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md` when done (planning docs in their own commit), recording the released version.
|
||||
</output>
|
||||
271
.planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md
Normal file
271
.planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md
Normal file
@@ -0,0 +1,271 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 02
|
||||
subsystem: mcp
|
||||
tags: [pier, mcp, go-sdk, jsonschema-go, surf, bouncer, redis, sessions, stateless, prm, build-tag]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-01
|
||||
provides: bouncer.WithDispatch marker, surf.Router.Handler + MountStream + mountPier hook, cabana.ResolveBackendToken / ScopeLimitFor / BackendPrincipal, SDK-free pact MCP contracts, pact.MCPSubjectChanged events, cooler.KeyPrefix, wristband ScopesSupported
|
||||
provides:
|
||||
- modules/pier, the only importer of go-sdk v1.8.0 and jsonschema-go v0.4.3, linked only into binaries built with -tags summercms_mcp
|
||||
- modules/surf/pier_on.go (//go:build summercms_mcp) adapting the router to pier.Host
|
||||
- catalog compiled at boot from pact.HasMCP (<shortcode>_<name> prefixing, route binding, guard resolution, schema reflection, annotations, boot failures by name)
|
||||
- in-process tool dispatch through surf's compiled chain with the bouncer marker and no Authorization or Cookie header
|
||||
- per-request identity (OAuth verifier, personal tokens behind mcp.allow_personal_tokens, backend scope and link), read/write ceiling, built-in backend guard provider
|
||||
- stateful 2025-11-25 sessions over a memory or Redis store with rehydration, binding checks, DELETE and pub/sub fan-out; stateless 2026-07-28 path on the same mcp.path
|
||||
- RFC 9728 protected resource metadata and WWW-Authenticate challenge; periodic re-verification of long GET streams
|
||||
- prompts/get, audit lines (pier: tool call, pier: session)
|
||||
- docs/services/mcp.md, modules/pier/README.md, root README row, decision note .planning/notes/2026-10-22-mcp-go-sdk.md and STACK.md rows
|
||||
affects: [19.7-03 sm-user-plugin link and frontend permissions, 19.7-04 oauthserver verifier and Journal, 19.7-05 unit tests and security review, framework v0.4.4 (pier opt-in), framework v0.5.0 at phase completion]
|
||||
|
||||
actuals:
|
||||
tokens: 51272
|
||||
tasks: 4
|
||||
commits: 29
|
||||
plan_head_before: 3746675c726909b9280e78ea7f73985a1dcb48a5
|
||||
plan_head_after: a26ee2b72d5b99db7596217ce1c3da7ec0c6bf89
|
||||
|
||||
tech-stack:
|
||||
added:
|
||||
- "github.com/modelcontextprotocol/go-sdk v1.8.0 (tagged builds only)"
|
||||
- "github.com/google/jsonschema-go v0.4.3 (tagged builds only)"
|
||||
patterns:
|
||||
- "Build-tag containment: the SDK is reachable only through modules/pier and modules/surf/pier_on.go; an untagged binary lists no modelcontextprotocol module"
|
||||
- "One SDK server per identity; a receiving middleware re-filters tools/list and tools/call for the current request's identity"
|
||||
- "pier's own session router over StreamableServerTransport so sessions can be rehydrated from a shared Redis store"
|
||||
- "Identity re-read from the bearer on every request; the stored session carries only the binding, never the token"
|
||||
- "Store opened lazily from redis.url under cooler's prefix; nothing dials at mount"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- .planning/notes/2026-10-22-mcp-go-sdk.md
|
||||
- modules/pier/README.md
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/config.go
|
||||
- modules/pier/host.go
|
||||
- modules/pier/catalog.go
|
||||
- modules/pier/dispatch.go
|
||||
- modules/pier/filter.go
|
||||
- modules/pier/identity.go
|
||||
- modules/pier/guards.go
|
||||
- modules/pier/backend_guard.go
|
||||
- modules/pier/session.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/store_memory.go
|
||||
- modules/pier/store_redis.go
|
||||
- modules/pier/events.go
|
||||
- modules/pier/prm.go
|
||||
- modules/pier/audit.go
|
||||
- modules/pier/export_test.go
|
||||
- modules/pier/example_mcp_test.go
|
||||
- modules/pier/tracer_smoke_test.go
|
||||
- modules/pier/identity_smoke_test.go
|
||||
- modules/pier/sessions_smoke_test.go
|
||||
- modules/pier/stateless_smoke_test.go
|
||||
- modules/surf/pier_on.go
|
||||
- docs/services/mcp.md
|
||||
modified:
|
||||
- go.mod
|
||||
- go.sum
|
||||
- .planning/research/STACK.md
|
||||
- README.md
|
||||
- modules/surf/README.md
|
||||
- docs/site.yaml
|
||||
- docs/services/authentication.md
|
||||
- docs/plugins/registration.md
|
||||
- .planning/phases/19.7-generic-mcp-module/deferred-items.md
|
||||
|
||||
key-decisions:
|
||||
- "D-24: go-sdk v1.8.0 and jsonschema-go v0.4.3 chosen and approved by the user (Task 1 legitimacy check) before any go get; decision note and STACK rows committed first (3ea82a1)"
|
||||
- "Stateful 2025-11-25 sessions are served by pier's own router over StreamableServerTransport (needed for Redis-shared sessions, D-25); 2026-07-28 clients go through the SDK's stateless handler; both share identity, dispatch and filtering (D-32)"
|
||||
- "The mounted *pier.Pier is published on the application so tests reach it through export_test.go seams"
|
||||
- "Release deferred: no tag in this plan. pier ships opt-in in framework v0.4.4 (build tag summercms_mcp plus mcp.enabled, default off), released by the orchestrator outside this plan; v0.5.0 is reserved for phase 19.7 completion (user decision 2026-10-23)"
|
||||
|
||||
patterns-established:
|
||||
- "Tracer first: one fake-plugin tool listed and called end to end by an SDK client through the stateful path before Redis, stateless and identity expansion"
|
||||
- "Docs example as a test: TestExampleBlogPlugin builds the acme.blog declaration that docs/services/mcp.md copies through src="
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-3, SC-4, D-08, D-10, D-11, D-12, D-13, D-14, D-15, D-16, D-17, D-19, D-20, D-21, D-22, D-23, D-24, D-25, D-26, D-27, D-28, D-29, D-30, D-32, D-33, D-35, D-36]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Tracer: an SDK client lists and calls acme_echo end to end through surf's compiled guard chain with the dispatch marker; the inner request carries no Authorization or Cookie header; mcp.enabled off mounts nothing; untagged binaries carry no SDK"
|
||||
requirement: "SC-1"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/tracer_smoke_test.go#TestPierTracerSmoke"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "go build -tags summercms_mcp ./..."
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Catalog: <shortcode>_<name> prefixing, route binding, guard resolution, schema reflection, boot failures by name"
|
||||
requirement: "SC-2"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/tracer_smoke_test.go#TestPierTracerSmoke"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/pier/example_mcp_test.go#TestExampleBlogPlugin"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Per-identity tools/list and tools/call filtering, read/write ceiling, personal tokens behind the flag, prompts/get, audit line without arguments or token"
|
||||
requirement: "SC-3"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/identity_smoke_test.go (subtests of TestPierTracerSmoke: read-write ceiling and prompts, audit line, personal tokens behind the flag)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Redis sessions: binding check (403), rehydration on another instance, DELETE ends the session everywhere"
|
||||
requirement: "D-25"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/sessions_smoke_test.go#TestPierSessionsSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Subject-changed fan-out: list_changed on permission and link changes, session close on revocation and deletion, across instances"
|
||||
requirement: "D-26"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/sessions_smoke_test.go#TestPierFanOutSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "2026-07-28 clients served statelessly from the same path"
|
||||
requirement: "D-32"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/stateless_smoke_test.go#TestPierStatelessSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Framework tag, push and changelog post (D-31)"
|
||||
requirement: "D-31"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "deferred by user decision 2026-10-23: v0.4.4 released by the orchestrator outside this plan; v0.5.0 at phase 19.7 completion"
|
||||
status: deferred
|
||||
human_judgment: true
|
||||
rationale: "The user reserved v0.5.0 for full MCP usability; the release is not part of this plan's close"
|
||||
|
||||
duration: 38 min (tasks 1-4, 15:58Z-16:36Z; the release checkpoint wait is excluded)
|
||||
completed: 2026-10-23
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 02: pier MCP module Summary
|
||||
|
||||
**The `pier` module serves an opt-in MCP endpoint on go-sdk v1.8.0 behind the `summercms_mcp` build tag. Plugin tools declared through `pact.HasMCP` are listed per identity and called in-process through surf's compiled route chains with the bouncer dispatch marker. Clients on protocol 2025-11-25 get stateful sessions over a memory or Redis store, with fan-out across instances; 2026-07-28 clients are served statelessly from the same path. The module also serves RFC 9728 resource metadata. No release was cut in this plan.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 38 min of task work (2026-10-22T15:58:41Z to the Task 4 commit at 16:36Z), followed by the release checkpoint
|
||||
- **Started:** 2026-10-22T15:58:41Z
|
||||
- **Completed:** 2026-10-23 (closed without a release)
|
||||
- **Tasks:** 4 executed, plus the release decision (Task 5, answered: no tag in this plan). Task 6 (the release) was deferred.
|
||||
- **Files:** 36 touched by the plan's commits (3,285 + 1,133 + 589 insertions in the three code commits)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Task 1 (D-24):** the decision note `.planning/notes/2026-10-22-mcp-go-sdk.md` records the transitive graph, size, govulncheck result and build-tag containment. STACK.md gained a row for each module. The user approved both modules before `go get`.
|
||||
- **Task 2 (tracer):** `modules/pier` contains the Host contract, the `mcp.*` config, the catalog compiled from `pact.HasMCP` and per-request identity through the published verifier and resolvers. It also has the built-in backend guard provider, in-process dispatch with `bouncer.WithDispatch`, a per-identity SDK server with a per-request re-filter, the stateful session router over a memory store and audit lines. `modules/surf/pier_on.go` sets the `mountPier` hook. `TestPierTracerSmoke` lists and calls `acme_echo` end to end.
|
||||
- **Task 3:** `store_redis.go` stores records with PX TTLs, keeps per-binding sets and carries pub/sub events, under cooler's prefix and opened lazily. `events.go` republishes `pact.MCPSubjectChanged` through the store, so every instance sends list_changed or ends the subject's sessions. `stateless.go` serves 2026-07-28 clients. `prm.go` serves the metadata at both well-known paths, and long GET streams re-verify their bearer every minute. These are covered by `TestPierSessionsSmoke`, `TestPierFanOutSmoke` and `TestPierStatelessSmoke` on miniredis.
|
||||
- **Task 4:** personal tokens are accepted only when `mcp.allow_personal_tokens` is on. An admin token gives a backend-only identity with its scope limit, and a user token gives a frontend-only one. The read/write ceiling, prompts and the audit line are asserted in the tracer's subtests. This task also added `docs/services/mcp.md` with the tested `acme.blog` example, the site.yaml entry and cross-links from the authentication, registration and surf pages.
|
||||
- Verified again at close: `go test -count=1 -short ./modules/pier/` passes all five tests (`TestExampleBlogPlugin`, `TestPierSessionsSmoke`, `TestPierFanOutSmoke`, `TestPierStatelessSmoke`, `TestPierTracerSmoke`), and `go build -tags summercms_mcp ./...` succeeds.
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1: Decide the MCP Go SDK** - `3ea82a1` (docs)
|
||||
2. **Task 2: pier tracer** - `cfdbaf0` (feat)
|
||||
3. **Task 3: Redis sessions, events, stateless path, PRM** - `806e87c` (feat)
|
||||
4. **Task 4: Identity kinds, ceilings, prompts, MCP services page, READMEs** - `8c6c0a3` (feat), plus `1aff96f` (docs: deferred items)
|
||||
5. **Task 5: Release decision** - answered by the user, no commit (see below)
|
||||
6. **Task 6: Release** - deferred, no commit
|
||||
|
||||
**Commit count note:** `commits: 29` is measured as `git rev-list --count 3746675..a26ee2b`. That range also contains 24 commits from concurrent sessions (msd-quick tasks 261022-k9k, -tb4, -tto, -usi, -vfz, -wah, -x7a and their planning docs). This plan's own commits are the five listed above.
|
||||
|
||||
## Release (Tasks 5 and 6): deferred
|
||||
|
||||
The user's final answer to Task 5 replaces the earlier v0.5.0 answer: **no tag in this plan.**
|
||||
|
||||
- The pier code ships **opt-in in framework v0.4.4**. To use it, an application is built with `-tags summercms_mcp` and sets `mcp.enabled: true` (the default is off). Without the tag the binary carries no go-sdk. The orchestrator handles v0.4.4 outside this plan, after the plan closes.
|
||||
- **v0.5.0 is reserved for phase 19.7 completion** (plans 01-05 and phase verification, i.e. full MCP usability).
|
||||
- This plan did not tag, push, post a changelog or edit the decision note's "Released in" line. The plan's D-31 truth and the Task 6 acceptance criteria (tag on origin, changelog URL) are therefore not met here. The release is tracked by the 19.7 decisions in STATE.md.
|
||||
- The Docker-host gate from the plan's verification (`go test -count=1 ./...` and `bash scripts/check-phase19.6.1.sh --all` before the tag) has to run before the v0.4.4 tag. It was not run in this close.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] The tracer client is pinned to protocol 2025-11-25**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** an SDK client left at its default negotiates the newest protocol, which pier sends to the stateless path. The tracer has to exercise the stateful path with sessions.
|
||||
- **Fix:** `client.Connect(..., &mcp.ClientSessionOptions{ProtocolVersion: "2025-11-25"})` in `TestPierTracerSmoke`, and `connectPinned` for the identity subtests
|
||||
- **Files modified:** modules/pier/tracer_smoke_test.go, modules/pier/identity_smoke_test.go
|
||||
- **Committed in:** cfdbaf0, 8c6c0a3
|
||||
|
||||
**2. [Rule 1 - Bug] SDK client sessions are closed by defer before the test server closes**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** if `httptest.Server.Close` runs while an SDK session's GET stream is still open, it blocks waiting on the hanging connection
|
||||
- **Fix:** `defer cs.Close()` is registered after `defer srv.Close()`, so the session closes first (LIFO)
|
||||
- **Files modified:** modules/pier/tracer_smoke_test.go
|
||||
- **Committed in:** cfdbaf0
|
||||
|
||||
**3. [Rule 3 - Blocking] `TestExampleBlogPlugin` calls `blogTools()`**
|
||||
- **Found during:** Task 4
|
||||
- **Issue:** the docs example has to be a compiled, tested declaration that `docs/services/mcp.md` can copy through `src=`
|
||||
- **Fix:** the declaration lives in `blogTools()`. The example plugin's `MCP()` returns it, and the test calls it directly to assert 3 tools and 1 prompt before mounting the plugin.
|
||||
- **Files modified:** modules/pier/example_mcp_test.go
|
||||
- **Committed in:** 8c6c0a3
|
||||
|
||||
**4. [Rule 3 - Blocking] `*pier.Pier` is published on the app as a test seam**
|
||||
- **Found during:** Task 4
|
||||
- **Issue:** the identity subtests need to inject a personal-token resolver and reach the mounted instance. The cabana resolver needs a database, which is not available under `-short`.
|
||||
- **Fix:** `Mount` publishes the `*pier.Pier` on the application, and `export_test.go` exposes the unexported seams to tests only
|
||||
- **Files modified:** modules/pier/pier.go, modules/pier/export_test.go
|
||||
- **Committed in:** 8c6c0a3
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 4 auto-fixed (1 bug, 3 blocking). The release (Task 6) was deferred by the user's decision.
|
||||
**Impact on plan:** the code scope is unchanged. The release moved out of the plan.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None beyond the deviations and the deferred items below.
|
||||
|
||||
## Follow-ups (from deferred-items.md)
|
||||
|
||||
- **open:** stateful pier sessions cannot carry the SDK's protocol-version context value. go-sdk v1.8.0 keeps it under an unexported key, so stateful streams run with the 2025-03-26 defaults for close/reconnect hints and JSON-RPC batching. Revisit if the SDK exports the key. Plan 05 may pin the behaviour in a test.
|
||||
- **open:** `notifications/initialized` can land on a different instance than `initialize`. The first instance's local copy then refuses calls until it is dropped. Sticky sessions or a per-request re-read of the stored `initialized` flag would fix this. It does not affect a single-instance deployment.
|
||||
- **open (from 19.7-01):** pre-existing `gofmt` drift in six cabana files. The fix is a separate `style(cabana)` commit.
|
||||
- Before any framework tag: run `bash scripts/check-phase19.6.1.sh --all` and the full Docker `go test -count=1 ./...` on the Docker host.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None. The release is deferred by decision; it is not a stub.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None for this plan. Applications that want MCP build with `-tags summercms_mcp` and set `mcp.enabled: true` (see `docs/services/mcp.md`).
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- **Plan 03 (sm-user-plugin):** publish `pact.MCPLinkedBackendResolver` and `pact.MCPPersonalTokenResolver`, frontend permissions, and the link and unlink record actions. pier picks them up through `app.Lookup`.
|
||||
- **Plan 04 (oauthserver):** publish `pact.MCPTokenVerifier` and add `backend` to `ScopesSupported`. The PRM `resource` must match the verifier's resource.
|
||||
- **Plan 05:** unit tests and security review, including the two open pier items above and the subject-event listener assertions carried over from 01.
|
||||
- **Framework version for plans 03 and 04:** v0.4.4 (pier opt-in), once the orchestrator tags it. v0.5.0 follows at phase completion.
|
||||
|
||||
---
|
||||
*Phase: 19.7-generic-mcp-module*
|
||||
*Completed: 2026-10-23*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
All key created files exist on disk (pier sources, surf/pier_on.go, docs/services/mcp.md, the pier README, the decision note) and the five plan commits (3ea82a1, cfdbaf0, 806e87c, 8c6c0a3, 1aff96f) are in history. `go test -count=1 -short ./modules/pier/` and `go build -tags summercms_mcp ./...` pass at a26ee2b.
|
||||
389
.planning/phases/19.7-generic-mcp-module/19.7-03-PLAN.md
Normal file
389
.planning/phases/19.7-generic-mcp-module/19.7-03-PLAN.md
Normal file
@@ -0,0 +1,389 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 03
|
||||
type: execute
|
||||
wave: 3
|
||||
depends_on: ["19.7-02"]
|
||||
files_modified:
|
||||
- ../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/backend_link.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/backend_link_request.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/subject_events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/privileged.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/token_me.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/usergroups_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/account_contributions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_links_admin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp.go
|
||||
- ../sm-demo-app/plugins/golem15/user/admin_permissions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/routes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/config/config.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md
|
||||
- ../sm-demo-app/plugins/golem15/user/go.mod
|
||||
- ../sm-demo-app/plugins/golem15/user/go.sum
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_admin_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp_guard_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_smoke_test.go
|
||||
- ../sm-demo-app/go.mod
|
||||
- ../sm-demo-app/go.sum
|
||||
- ../sm-demo-app/plugins/golem15/user
|
||||
- ../fonoteka.go/go.mod
|
||||
- ../fonoteka.go/go.sum
|
||||
- ../fonoteka.go/plugins/golem15/user
|
||||
- ../sm-bm-app/go.mod
|
||||
- ../sm-bm-app/go.sum
|
||||
- ../sm-bm-app/plugins/golem15/user
|
||||
- ../sm-grzybyfunkcjonalne-app/go.mod
|
||||
- ../sm-grzybyfunkcjonalne-app/go.sum
|
||||
- ../sm-grzybyfunkcjonalne-app/plugins/golem15/user
|
||||
- ../sm-summercmsio-app/go.mod
|
||||
- ../sm-summercmsio-app/go.sum
|
||||
- ../sm-summercmsio-app/plugins/golem15/user
|
||||
autonomous: false
|
||||
requirements: [SC-3, SC-4, D-01, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-15, D-16, D-17, D-18, D-23, D-26, D-31, D-34, D-35, D-36]
|
||||
|
||||
estimate:
|
||||
tokens: 80000
|
||||
raw_tokens: 80000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A backend admin starts 'Link frontend account' on My account, is sent to the site with a one-shot code, signs in fresh as a frontend user, and only then is the 1:1 link saved; a replayed, expired or stale-session confirm is refused and no link is written by email match or by picking from a list (D-03, D-05, D-06, D-07 self-service path, D-04 part 1)"
|
||||
- "An admin holding golem15.users.manage_backend_links sets a link for another administrator on the Administrators screen through a prompted record action (the frontend user's email) and removes one through a Danger action; the set records linked_by and fires an event (D-07, D-34, D-35)"
|
||||
- "pier resolves the linked admin through the published pact.MCPLinkedBackendResolver on every request; unlinking, deleting or deactivating either account removes the backend subject on the next call and fires pact.MCPSubjectChanged (D-08, D-26)"
|
||||
- "A plugin's frontend permission codes appear in the user and group permission editors next to the seeded rows, and a seeded row wins on a duplicate code; existing rows, tables and payloads are unchanged (D-09)"
|
||||
- "The user guard provider answers tools/list with the same group-grant check user.permission enforces, requires every user.scope of the route, and hands pier an in-memory token credential so user.scope sees the grant's scopes (D-15, D-16, D-17, D-23, D-35)"
|
||||
- "The user_me tool (GET /_user/api/v1/token/me behind user.api_token and user.scope:read) returns the signed-in user's payload through MCP, proving the user guard end to end (D-18)"
|
||||
- "The plugin is released only after the framework tag from plan 02, as an additive release; every application that mounts it is bumped in one commit per app and still builds and passes (D-01, D-31)"
|
||||
artifacts:
|
||||
- path: "../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go"
|
||||
provides: "golem15_user_backend_links and golem15_user_backend_link_requests"
|
||||
contains: "golem15_user_backend_links"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/backend_links.go"
|
||||
provides: "BackendLinks service: CreateLinkRequest, ConfirmLinkRequest, SetLink, RemoveLink, LinkedBackendUser"
|
||||
contains: "func (s *BackendLinks) LinkedBackendUser("
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go"
|
||||
provides: "MCPUserGuard implementing pact.MCPGuard and pact.MCPPersonalTokenResolver"
|
||||
contains: "func (g *MCPUserGuard) MCPGuardName() string"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/backend_links_admin.go"
|
||||
provides: "AdminActionExtensions on cabana.AdministratorsControllerID: link_frontend_account (prompted) and unlink_frontend_account"
|
||||
contains: "link_frontend_account"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/account_contributions.go"
|
||||
provides: "the My account section frontend_account with link and unlink"
|
||||
contains: "frontend_account"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/mcp.go"
|
||||
provides: "HasMCP: the me tool"
|
||||
contains: "token/me"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go"
|
||||
provides: "FrontendPermissionCatalog merging pact.HasFrontendPermissions into the editors"
|
||||
contains: "HasFrontendPermissions"
|
||||
key_links:
|
||||
- from: "../sm-demo-app/plugins/golem15/user/plugin.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/backend_links.go"
|
||||
via: "Boot publishes *classes.BackendLinks and the same value as pact.MCPLinkedBackendResolver"
|
||||
pattern: "MCPLinkedBackendResolver"
|
||||
- from: "../sm-demo-app/plugins/golem15/user/plugin.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go"
|
||||
via: "Boot registers the guard in the *pact.MCPGuards registry (find-or-publish) and publishes it as pact.MCPPersonalTokenResolver"
|
||||
pattern: "MCPGuards"
|
||||
- from: "../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/backend_links.go"
|
||||
via: "the confirm route checks the JWT iat against the request's created_at and calls ConfirmLinkRequest"
|
||||
pattern: "ConfirmLinkRequest"
|
||||
- from: "../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go"
|
||||
via: "AdminPermissionOptions returns FrontendPermissionCatalog instead of the seeded rows alone"
|
||||
pattern: "FrontendPermissionCatalog"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: MergedPermissions -->
|
||||
|
||||
<objective>
|
||||
Deliver the sm-user-plugin side of the identity chain, additively, in the plugin's master checkout at `../sm-demo-app/plugins/golem15/user` (v0.1.8, commit 930b158): the verified frontend-to-backend account link with its tables, proof round-trip, service and events (D-03, D-05, D-06, D-07, D-08), the My account contribution and the Administrators-screen actions through plan 01's seams (D-04, D-34), plugin-registered frontend permission codes in the editors (D-09), the `user` MCP guard provider and personal-token resolver (D-15, D-16, D-17, D-23, D-35), the first frontend tool `user_me` (D-18), the permission code `golem15.users.manage_backend_links` (D-35), then the plugin release pinned to the plan-02 framework tag and the pointer bumps in every application that mounts it (D-01, D-31).
|
||||
|
||||
**Planner decisions recorded here:**
|
||||
- **P-10 (tables and TTL, Claude's discretion):** `golem15_user_backend_links` (`id`, `user_id` UNIQUE → `users.id` ON DELETE CASCADE, `backend_user_id` UNIQUE → `backend_users.id` ON DELETE CASCADE, `linked_by` nullable → `backend_users.id` ON DELETE SET NULL, `created_at`) and `golem15_user_backend_link_requests` (`id`, `code_hash` CHAR(64) UNIQUE, `backend_user_id` → `backend_users.id` ON DELETE CASCADE, `expires_at`, `used_at` nullable, `created_at`). The code is 32 random bytes hex (64 chars) stored as SHA-256 hex, valid `golem15.user.backend_links.request_ttl` (default `10m`), one-shot, bound to the admin who created it.
|
||||
- **P-11 (fresh sign-in, D-05):** the confirm route is behind `jwt.auth` and additionally re-reads the bearer with `bouncer.VerifyClaims` to compare the JWT `iat` with the request's `created_at`; an older session answers 409 `stale_session`, so a browser that was already signed in must sign in again (password, social login and the 2FA gate all pass through the normal login).
|
||||
- **P-12 (admin set, D-07/D-34):** `link_frontend_account` is a prompted record action whose value is the frontend user's email, matched exactly and case-insensitively against active users; no search, no list. It is a privileged action behind `golem15.users.manage_backend_links` (no default role), records `linked_by` and fires events. The self-service My account path never skips the D-05 proof.
|
||||
- **P-13 (site URL):** the link page URL is `golem15.user.frontend_url` + `/link-admin?code=<plain>`; the key is new here with an empty default that falls back to `app.url`. Phase 19.6 (not executed) plans the same key for its own site links; whichever lands first adds it and the other reuses it.
|
||||
- **P-14 (frontend permission semantics, D-35, Pitfall 3):** `MCPAllows` uses `classes.PrincipalByID` (group grants) and `cabana.Allows` per code with AND across codes, exactly what `user.permission` middleware enforces; `MergedPermissions` is not used.
|
||||
- **P-15 (plugin version):** additive release, proposed `v0.1.9`; the user decides at the checkpoint.
|
||||
|
||||
Sequencing: Phase 19.6 (2FA and device flow) edits this plugin in another checkout (`../fonoteka.go/plugins/golem15/user`, at v0.1.6) and is not executed. This plan does not depend on 19.6 and touches `admin_permissions.go`, `plugin.go`, `routes.go`, `controllers/users_admin_controller.go`, `config/config.yaml`, `lang/*` and `README.md`, which 19.6 also lists: append to the existing lists and blocks (never reorder them) so either phase rebases cleanly on the other, and run `git -C ../sm-demo-app/plugins/golem15/user status --short` before every task.
|
||||
|
||||
Purpose: SC-4's identity chain exists on the plugin side; plan 04 can show the consent line and run Journal tools as the linked admin; the demo can prove both guards.
|
||||
Output: migrations, models, service, routes, controllers, the three seam implementations, the guard provider, the tool, permission code and copy, smoke tests on Postgres, README, the tagged plugin release and five application pointer bumps.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<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-PATTERNS.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/notes/core-plugins-own-repos.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Core-plugin rule: additive only. No existing route, payload field, table, column, seeded row, permission code, exported identifier or `admin:*` command changes; new routes are appended to the existing `/_user/api/v1` group.
|
||||
- The plugin repo is the submodule checkout `../sm-demo-app/plugins/golem15/user` on branch `master`. Commit there first; the pointer bump in each app is a separate commit in that app. Push and tag only in Task 5 after the go-ahead.
|
||||
- Run the plugin's Go commands with `GOWORK=off go -C ../sm-demo-app/plugins/golem15/user ...` (its own go.mod replaces the framework with `../../../../summercms.go`; the parent app's go.work does not list it). Postgres tests need Docker and skip under `-short`.
|
||||
- Framework neutrality is the framework's rule, not the plugin's; the plugin may name cabana, bouncer, pact and its own tables freely but must not name a consuming application.
|
||||
- Stage by explicit path; one logical change per commit; no co-author tags; planning docs (in the framework repo) in their own commit.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: the verified link end to end — My account starts a link request, the frontend user confirms it with a fresh sign-in, and the published resolver answers the linked admin</name>
|
||||
<reversibility rating="costly">The two tables and the published service become part of a core plugin's contract consumed by apps and pier (D-03); the one-way proof rule of D-05 was decided by the user in CONTEXT and this task implements it, so no gate re-asks it.</reversibility>
|
||||
<files>../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go, ../sm-demo-app/plugins/golem15/user/models/backend_link.go, ../sm-demo-app/plugins/golem15/user/models/backend_link_request.go, ../sm-demo-app/plugins/golem15/user/classes/backend_links.go, ../sm-demo-app/plugins/golem15/user/classes/events.go, ../sm-demo-app/plugins/golem15/user/classes/subject_events.go, ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go, ../sm-demo-app/plugins/golem15/user/account_contributions.go, ../sm-demo-app/plugins/golem15/user/routes.go, ../sm-demo-app/plugins/golem15/user/plugin.go, ../sm-demo-app/plugins/golem15/user/config/config.yaml, ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml, ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml, ../sm-demo-app/plugins/golem15/user/backend_link_smoke_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/plugins/golem15/user/updates/202610040001_create_api_tokens.go and updates/registry.go (raw SQL migration, Register)
|
||||
- ../sm-demo-app/plugins/golem15/user/models/api_token.go (model shape, TableName, Fillable, Hidden, Register) and models/registry.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/codes.go 40-75 (newCode), classes/api_tokens.go (HashAPIToken usage: grep `HashAPIToken` in middleware/api_token.go), classes/events.go (event struct style), classes/session_user.go (RequestUser), classes/user_lookup.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_controller.go 150-180 (Fetch), 860-930 (authenticate, apiArray), 1160-1230 (writeJSON, writeOpaque500) and controllers/api_tokens.go (JWT-guarded controller shape, reading the principal from bouncer.User)
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go 60-120 (Boot: find-or-publish registry pattern, Publish) and routes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/admin_harness_test.go (adminHarnessDB, newAdminEnv, login helpers) and account_test.go (how an account route is exercised)
|
||||
- summercms.go: modules/pact/capabilities.go (HasAccountContributions, AccountContribution, AccountAction, AccountActionResult as shipped by plan 01), modules/pact/mcp.go (MCPLinkedBackendResolver, LinkedBackendUser, MCPSubjectChanged and constants), modules/bouncer/jwt.go 190-215 (VerifyClaims returns iat), modules/cabana/contracts.go 53-75 (BackendUser fields: Login, FirstName, LastName, IsActivated, DeletedAt)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pattern 7" and the Security Domain rows "Link without proof" and "Admin sets a link"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "USER/updates", § "USER/models/backend_link.go", § "USER/classes/backend_links.go", § "USER/routes.go and USER/controllers/*"
|
||||
</read_first>
|
||||
<action>
|
||||
Migration `202610220001_create_backend_links` (ID `202610220001_create_golem15_user_backend_links`): the two tables of P-10 with their indexes and FKs, raw SQL, Rollback drops both; `init() { Register(...) }`. Models `models.BackendLink{ID, UserID, BackendUserID, LinkedBy *uint, CreatedAt}` and `models.BackendLinkRequest{ID, CodeHash, BackendUserID, ExpiresAt, UsedAt *time.Time, CreatedAt}` with TableName, Fillable, Hidden (`code_hash`), `IsUsableAt(now)` on the request; register both.
|
||||
|
||||
Service `classes.BackendLinks{App *backpack.App}` (published in Boot as `*classes.BackendLinks` and as `pact.MCPLinkedBackendResolver`): `CreateLinkRequest(ctx, backendUserID uint) (plainCode string, expiresAt time.Time, error)` (newCode → store sha256 hex, TTL from `golem15.user.backend_links.request_ttl` default 10m); `LinkRequestByCode(ctx, plain) (*models.BackendLinkRequest, *cabana.BackendUser, error)` for the public show (usable only); `ConfirmLinkRequest(ctx, plain string, frontendUserID uint, sessionIssuedAt time.Time) (*models.BackendLink, error)` in one transaction: `SELECT ... FOR UPDATE` by code_hash, refuse used (`ErrLinkRequestUsed`), expired (`ErrLinkRequestExpired`), `sessionIssuedAt.Before(req.CreatedAt)` (`ErrStaleSession`), an existing link on either side (`ErrAlreadyLinked`), the admin missing or not activated (`ErrBackendUserUnavailable`); insert the link with `LinkedBy` nil, set `used_at`, fire `BackendLinkedEvent{Link, Tx}` and the two `pact.MCPSubjectChanged` events (user side `{Guard:"user", UserID, Kind: pact.MCPSubjectLink}`, backend side `{Guard:"backend", UserID: backendUserID, Kind: link}`); `SetLink(ctx, tx, frontendUserID, backendUserID, linkedBy uint)` (admin path, same uniqueness rules, records linked_by, same events; used by Task 3); `RemoveLink(ctx, tx, link)` (fires `BackendUnlinkedEvent` and both subject events); `LinkFor(ctx, backendUserID)` and `LinkOf(ctx, frontendUserID)`; `LinkedBackendUser(ctx, frontendUserID) (pact.LinkedBackendUser, bool, error)` = one indexed query joining `backend_users` for `Login` and the display name (first+last name, else login), false when the admin is deactivated or soft-deleted. Listen to `DeletingEvent` and `DeactivatingEvent` (user side): remove the link inside the tx and fire `MCPSubjectChanged{user, id, deleted}` and the backend `link` event. `classes/subject_events.go`: `FireSubjectChanged(ctx, app, guard string, userID uint, kind string)` through `app.Events` when present (log, never fail the save).
|
||||
|
||||
Routes appended to the `/_user/api/v1` group: `g.Get("/backend-link/{code}", controllers.BackendLinkShow(p.app))` with `g.Where("code", "[a-f0-9]{64}")` and `g.Post("/backend-link/confirm", controllers.BackendLinkConfirm(p.app), "jwt.auth")`. `BackendLinkShow`: 404 `{"error":"not_found"}` unless usable; 200 `{"data":{"admin":{"login":...,"name":...},"expires_at":<RFC3339>}}` (nothing else about the admin). `BackendLinkConfirm`: body `{"code": ...}`; principal from `bouncer.User`; the bearer re-read with `usermiddleware.BearerToken(r)` and `bouncer.VerifyClaims(raw, secret)` for `iat` (secret from `classes.JWTSecret(app)`); maps `ErrStaleSession` → 409 `{"error":"stale_session"}`, `ErrAlreadyLinked` → 409 `{"error":"already_linked"}`, used/expired/unknown → 404 `{"error":"not_found"}`, success → 200 `{"data":{"backend_user":{"login","name"}}}`; all through the plugin's `writeJSON`.
|
||||
|
||||
My account contribution (D-04 part 1, P-02 seam) in `account_contributions.go`: `(*Plugin) AccountContributions()` returns one `pact.AccountContribution{Name: "frontend_account", Label: "golem15.user::lang.backend_link.section", Description: "...section_comment", Status: linked → "golem15.user::lang.backend_link.status_linked" with the email interpolated through the plugin's translator helper (or the literal "Linked to <email>" if interpolation through a phrase key is not available in Status), else "...status_unlinked"; Actions: `link` (Label `...link`, Applies: no link, Run: CreateLinkRequest for `in.AdminID` and answer `Message: "...link_started"`, `URL: frontendURL(app) + "/link-admin?code=" + plain`) and `unlink` (Label `...unlink`, Confirm `...unlink_confirm`, Danger true, Applies: linked, Run: RemoveLink in the tx from `cabana.TxFromContext`)}`. `frontendURL(app)` reads `golem15.user.frontend_url`, falling back to `app.url`, trimming a trailing slash (P-13). Config keys with comments in `config/config.yaml`: `frontend_url: ""`, `backend_links: { request_ttl: 10m }`. Lang keys en + pl under `backend_link:` (section, section_comment, status_linked, status_unlinked, link, link_started, unlink, unlink_confirm, unlinked, prompt_email, prompt_comment, set, set_confirm, set_success, remove, remove_confirm, remove_success, unknown_user, already_linked).
|
||||
|
||||
Smoke `backend_link_smoke_test.go` `TestBackendLinkSmoke` (Postgres through `newAdminEnv`, skipped under -short): seed a frontend user and an admin; as the admin, `GET /account/contributions` lists `frontend_account` with status unlinked and action `link`; `POST /account/contributions/frontend_account/actions/link` answers a URL containing `/link-admin?code=` and a 64-hex code; `GET /_user/api/v1/backend-link/{code}` shows the admin's login and an `expires_at`; a frontend JWT minted before the request (iat earlier) → confirm answers 409 `stale_session`; a JWT minted after → 200, `LinkedBackendUser(uid)` returns the admin's id and login; the same code again → 404; a second request confirmed by another frontend user for the same admin → 409 `already_linked`; after `unlink` the resolver answers false and `GET /account/contributions` shows `link` again; deleting the frontend user (the plugin's delete path) removes the link row.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^TestBackendLinkSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestBackendLinkSmoke'</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS line is absent (a SKIP line because Docker is unreachable also counts as absent: run on a Docker host)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "golem15_user_backend_links\|golem15_user_backend_link_requests" ../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go` prints at least 4 and `grep -c "ON DELETE CASCADE" ../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go` prints at least 3
|
||||
- `grep -c "func (s \*BackendLinks) \(CreateLinkRequest\|ConfirmLinkRequest\|SetLink\|RemoveLink\|LinkedBackendUser\)(" ../sm-demo-app/plugins/golem15/user/classes/backend_links.go` prints 5
|
||||
- `grep -c "FOR UPDATE\|clause.Locking" ../sm-demo-app/plugins/golem15/user/classes/backend_links.go` prints at least 1
|
||||
- `grep -c "VerifyClaims" ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go` prints 1 and `grep -c "stale_session" ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go` prints 1
|
||||
- `grep -c "/backend-link/{code}\|/backend-link/confirm" ../sm-demo-app/plugins/golem15/user/routes.go` prints 2 and every pre-existing route line in routes.go is unchanged (`git -C ../sm-demo-app/plugins/golem15/user diff 930b158 -- routes.go | grep -c '^-g\.'` prints 0)
|
||||
- `grep -c "MCPLinkedBackendResolver" ../sm-demo-app/plugins/golem15/user/plugin.go` prints 1 and `grep -c "frontend_account" ../sm-demo-app/plugins/golem15/user/account_contributions.go` prints at least 1
|
||||
- `grep -c "frontend_url\|request_ttl" ../sm-demo-app/plugins/golem15/user/config/config.yaml` prints 2 and `grep -c "backend_link:" ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml` prints 1 per file
|
||||
- `TestBackendLinkSmoke` prints `--- PASS` on a Docker host
|
||||
</acceptance_criteria>
|
||||
<done>A proven, one-shot, fresh-sign-in link exists end to end from My account through the site confirm to the published resolver, with cascades and events, on the plugin's master checkout.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Frontend permission codes from plugins, the user MCP guard provider and personal-token resolver, the token/me route and the user_me tool</name>
|
||||
<files>../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go, ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go, ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go, ../sm-demo-app/plugins/golem15/user/controllers/usergroups_admin_controller.go, ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go, ../sm-demo-app/plugins/golem15/user/controllers/token_me.go, ../sm-demo-app/plugins/golem15/user/mcp.go, ../sm-demo-app/plugins/golem15/user/plugin.go, ../sm-demo-app/plugins/golem15/user/routes.go, ../sm-demo-app/plugins/golem15/user/mcp_guard_smoke_test.go, ../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_smoke_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go 426-447 and usergroups_admin_controller.go 186-205 (AdminPermissionOptions; FormAfterUpdate hooks where permissions and groups are saved: grep `permissions` and `Groups` writes), controllers/api_tokens.go (APITokenDestroy: where a token is revoked)
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/permissions.go (FrontendPermissionOptions 124+, MergedPermissions is NOT to be used: P-14), classes/user_lookup.go 35-100 (PrincipalByID, UserPermissionGrants), classes/api_tokens.go 15-40 (prefix, AllowedAPITokenScopes), middleware/api_token.go 40-120 (hash lookup, IsUsableAt, last_used stamp, Scope and Permission middleware semantics)
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go 225-256 (Middlewares: the names `user.api_token`, `user.scope`, `user.permission` the provider parses)
|
||||
- summercms.go: modules/pact/mcp.go (MCPGuard, MCPGuards, MCPRequirements, MCPSubject, MCPDispatch, MCPPersonalTokenResolver, HasFrontendPermissions, FrontendPermission, HasMCP, MCPTool), modules/party/registry.go 20-30 (party.Activated published on the app), modules/cabana/contracts.go 295-335 (Allows is OR across required codes: call it per code), modules/cabana/field_permission.go (PermissionOption)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pitfall 3", § "Pattern 6" (in-memory credential), § "Pitfall 9", § "Frontend tool (D-18) needs a new route"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "USER/frontend_permissions.go" and § "USER/mcp.go"
|
||||
</read_first>
|
||||
<action>
|
||||
D-09: `classes.FrontendPermissionCatalog(ctx, app, db) ([]cabana.PermissionOption, error)`: the seeded rows from `FrontendPermissionOptions` first (unchanged order and fields), then every `pact.HasFrontendPermissions` among `app.Lookup[party.Activated]()` in activation order, appending each code not already present (seeded wins on a duplicate code; a duplicate between two plugins keeps the first). Both `AdminPermissionOptions` (users and user groups controllers) return the catalog. Existing rows, the table and the payload fields stay as they are; the editors simply offer more rows.
|
||||
|
||||
Guard provider `classes.MCPUserGuard{App}` implementing `pact.MCPGuard` and `pact.MCPPersonalTokenResolver`: `MCPGuardName()` = `user`; `MCPTokenGuarded(mw)` = contains `user.api_token`; `MCPRequirements(mw)`: `user.scope:<s>` → Scopes, `user.permission:<c>` → Permissions (error for an unknown `user.` name); `MCPAllows(ctx, subject, req, perms)`: every `req.Scopes` entry ∈ `subject.Scopes`, then `principal := PrincipalByID(ctx, db, subject.UserID)` (nil → false) and for every code in `req.Permissions` and `perms` require `cabana.Allows(principal, []string{code})` (AND across codes, matching the middleware chain; P-14); `MCPDispatch(ctx, subject, method)`: `Principal` from `PrincipalByID`, `Credential` = `&models.APIToken{UserID: subject.UserID, Scopes: <subject.Scopes as lagoon.Jsonable>}` (ID 0, never saved; Pitfall 9), `Guards: []string{"api_token"}`; `MCPResolvePersonalToken(ctx, raw)`: false unless `raw` starts with `classes.APITokenPrefix(app)`; then the same hash lookup and `IsUsableAt` as the guard, stamp `last_used_at` (no IP), answer `pact.MCPSubject{Guard: "user", UserID, Scopes: token scopes, TokenID: token.ID}`; an unusable token is `(MCPSubject{}, true, pact.ErrMCPTokenInvalid)`. Boot: find-or-publish `*pact.MCPGuards`, `Register(guard)`, `app.Publish[pact.MCPPersonalTokenResolver](guard)`.
|
||||
|
||||
Subject events (D-26 user side) through `classes.FireSubjectChanged(ctx, app, "user", userID, kind)`: `permissions` after a users-admin save that changed `permissions` or the groups relation, after a user-groups-admin save that changed `permissions` (one event per member, ids read in the tx) and from the group membership helpers; `revoked` from `APITokenDestroy` (and any admin token revoke path); `deleted` is Task 1's listener. Place the calls in the existing hooks without changing their signatures.
|
||||
|
||||
Tool and route (D-18): `g.Get("/token/me", controllers.TokenMe(p.app), "user.api_token", "user.scope:read")` appended to the group; `TokenMe` reads `bouncer.User(ctx)`, loads the user, answers `{"user": apiArray(...)}` exactly like `Fetch` (401 `{"error":true,"message":"Invalid token."}` comes from the guard). `mcp.go`: `(*Plugin) MCP()` returns `pact.MCP{Tools: []pact.MCPTool{{Name: "me", Title: "Current user", Description: "Returns the profile of the signed-in frontend user.", Guard: "user", Method: http.MethodGet, Path: "/_user/api/v1/token/me", Input: struct{}{}}}}` (exposed as `user_me`; no Output).
|
||||
|
||||
Smokes (Postgres via newAdminEnv): `TestUserMCPGuardSmoke`: TokenGuarded true only with `user.api_token`; Requirements parses two scopes and a permission; Allows is false when a scope is missing, false when one of two codes is not granted to any of the user's groups, true when both are granted by groups (a user-level override alone does not grant: P-14); Dispatch returns a principal with the group grants and a credential of type `*models.APIToken` with ID 0 and the subject's scopes; ResolvePersonalToken answers false for `oas_at_x`, the subject for a valid `usr_` token, and ErrMCPTokenInvalid for a revoked one; `GET /_user/api/v1/token/me` with a `usr_` token of scope `read` answers 200 with `user.email`, with scope `write` only answers 403 `Missing required scope: read`, and with a JWT answers 401. `TestFrontendPermissionCatalogSmoke`: a fake plugin in the env declares `acme.blog.manage` and a code equal to a seeded row with a different label; both editors' `AdminPermissionOptions` list the seeded rows first, then `acme.blog.manage`, and the seeded label wins for the duplicate.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^(TestUserMCPGuardSmoke|TestFrontendPermissionCatalogSmoke)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS count line is not exactly 2 (SKIP without Docker counts as not passing)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func FrontendPermissionCatalog(" ../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go` prints 1 and `grep -c "FrontendPermissionCatalog(" ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go ../sm-demo-app/plugins/golem15/user/controllers/usergroups_admin_controller.go` prints 1 per file
|
||||
- `grep -c "func (g \*MCPUserGuard) \(MCPGuardName\|MCPTokenGuarded\|MCPRequirements\|MCPAllows\|MCPDispatch\|MCPResolvePersonalToken\)(" ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go` prints 6
|
||||
- `grep -c "MergedPermissions" ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go` prints 0
|
||||
- `grep -c "\"api_token\"" ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go` prints at least 1
|
||||
- `grep -c "/token/me" ../sm-demo-app/plugins/golem15/user/routes.go` prints 1 and `grep -c "\"user.api_token\", \"user.scope:read\"" ../sm-demo-app/plugins/golem15/user/routes.go` prints 1
|
||||
- `grep -c "Name: *\"me\"" ../sm-demo-app/plugins/golem15/user/mcp.go` prints 1
|
||||
- `grep -c "MCPGuards\|MCPPersonalTokenResolver" ../sm-demo-app/plugins/golem15/user/plugin.go` prints at least 2
|
||||
- `grep -c "FireSubjectChanged(" ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go ../sm-demo-app/plugins/golem15/user/controllers/usergroups_admin_controller.go ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go` prints a non-zero count per file
|
||||
- Both smoke tests print `--- PASS` on a Docker host
|
||||
</acceptance_criteria>
|
||||
<done>The editors offer plugin-declared frontend codes, pier can obtain the user guard and personal-token resolver from the app, the token/me route and the user_me tool exist, and permission, membership and token changes fire subject events.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Administrators-screen actions: set a link through the prompted record action and remove one, behind golem15.users.manage_backend_links</name>
|
||||
<files>../sm-demo-app/plugins/golem15/user/backend_links_admin.go, ../sm-demo-app/plugins/golem15/user/admin_permissions.go, ../sm-demo-app/plugins/golem15/user/classes/privileged.go, ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml, ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml, ../sm-demo-app/plugins/golem15/user/backend_link_admin_smoke_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/plugins/golem15/user/admin_permissions.go (the catalog; the fifth code without a default role) and classes/privileged.go (PermissionManagePrivilegedGroups constant placement)
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go 665-720 (the `action(...)` helper style, TxFromContext)
|
||||
- summercms.go: modules/cabana/example_action_extension_test.go (AdminActionExtensions on AdministratorsControllerID), modules/cabana/action_extensions.go (the outranking wrap cabana applies before Run), modules/pact/capabilities.go (AdminActionPrompt, AdminRecordActionInput.Value as shipped by plan 01), modules/cabana/crud.go error types (grep `type ValidationError`, `type ForbiddenError` and how actionFailure maps them)
|
||||
- .planning/phases/19.6.1-backend-administrators-screen/19.6.1-01-SUMMARY.md and 19.6.1-04-SUMMARY.md (preview offers contributed actions after the owner's; cabana runs guardOutranked before Run; "Every refusal ... is a ForbiddenError with Message set")
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "USER/backend_links_admin.go" and § "USER/admin_permissions.go"
|
||||
</read_first>
|
||||
<action>
|
||||
Permission: `classes.PermissionManageBackendLinks = "golem15.users.manage_backend_links"` appended to `Permissions()` with Tab `userPermissionTab`, Label `golem15.user::lang.plugin.manage_backend_links` and no Roles (D-35, P-12); lang `plugin.manage_backend_links` en/pl.
|
||||
|
||||
`backend_links_admin.go`: `(*Plugin) AdminActionExtensions()` returns one `pact.AdminActionExtension{Controller: cabana.AdministratorsControllerID, RecordActions: [...]}` with:
|
||||
- `link_frontend_account`: Label `golem15.user::lang.backend_link.set`, Confirm `...set_confirm`, Permissions `[PermissionManageBackendLinks]`, `Prompt: &pact.AdminActionPrompt{Label: "...prompt_email", Comment: "...prompt_comment", MaxLength: 254}`, Applies: the admin record has no link; Run: `in.Record.(*cabana.BackendUser)`, `tx := cabana.TxFromContext(ctx)`, find the frontend user by `lower(email) = lower(trim(in.Value))` among active, non-deleted users (exactly one; otherwise a 422 ValidationError on `payload` with `...unknown_user`), refuse when either side is already linked (422 on `payload` with `...already_linked`), `links.SetLink(ctx, tx, user.ID, admin.ID, bouncer.User(ctx).ID)`, answer `Message: "...set_success"`.
|
||||
- `unlink_frontend_account`: Label `...remove`, Confirm `...remove_confirm`, Danger true, Permissions `[PermissionManageBackendLinks]`, Applies: linked; Run: `links.RemoveLink(ctx, tx, link)`, Message `...remove_success`.
|
||||
cabana's own outranking rule (19.6.1 D-19) runs before either Run; the plugin does not duplicate it. The frontend Users screen gets no new action (D-34 moved the admin path to the Administrators screen).
|
||||
|
||||
Smoke `TestBackendLinkAdminSmoke` (Postgres): a superuser sees both actions offered on an admin's preview only as applicable (set when unlinked, remove when linked); `POST .../summercms/cabana/users/{id}/actions/link_frontend_account` with `{"payload":"Editor@Example.test"}` links the user whose email is `editor@example.test`, stores `linked_by` = the caller, and `LinkedBackendUser` answers; a second set for the same admin answers 422 on payload; an unknown email answers 422 on payload with the unknown_user text; a limited admin without `golem15.users.manage_backend_links` is not offered the action and gets 403 when posting it; `unlink_frontend_account` removes the link; a `BackendLinkedEvent` listener registered by the test saw the set.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^TestBackendLinkAdminSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestBackendLinkAdminSmoke'</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or the PASS line is absent (SKIP without Docker counts as absent)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "golem15.users.manage_backend_links" ../sm-demo-app/plugins/golem15/user/admin_permissions.go ../sm-demo-app/plugins/golem15/user/classes/privileged.go` prints at least 1 in total and the five pre-existing codes are unchanged (`git -C ../sm-demo-app/plugins/golem15/user diff 930b158 -- admin_permissions.go | grep -c '^-.*Code:'` prints 0)
|
||||
- `grep -c "cabana.AdministratorsControllerID" ../sm-demo-app/plugins/golem15/user/backend_links_admin.go` prints 1 and `grep -c "link_frontend_account\|unlink_frontend_account" ../sm-demo-app/plugins/golem15/user/backend_links_admin.go` prints at least 2
|
||||
- `grep -c "Prompt: *&pact.AdminActionPrompt" ../sm-demo-app/plugins/golem15/user/backend_links_admin.go` prints 1 and `grep -c "Danger: *true" ../sm-demo-app/plugins/golem15/user/backend_links_admin.go` prints 1
|
||||
- `grep -c "in.Value" ../sm-demo-app/plugins/golem15/user/backend_links_admin.go` prints at least 1
|
||||
- `grep -c "manage_backend_links" ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml` prints 1 per file
|
||||
- `TestBackendLinkAdminSmoke` prints `--- PASS` on a Docker host
|
||||
</acceptance_criteria>
|
||||
<done>A privileged admin sets and removes another administrator's frontend link from the Administrators screen through the seam, with linked_by recorded and events fired; no console command is the only way.</done>
|
||||
</task>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking-human">
|
||||
<name>Task 4: Decide the plugin release version and which applications to bump</name>
|
||||
<decision>Tag and push the sm-user-plugin release carrying the account link, the Administrators-screen actions, plugin-registered frontend permissions, the user MCP guard and the user_me tool, pinned to the framework tag from plan 02; then bump the pointer in every application that mounts the plugin.</decision>
|
||||
<context>Additive release (no removed export, route, column or payload field; the gate's additive check in plan 05 will prove it against 930b158). Proposed `v0.1.9` (P-15). The plugin's `go.mod` will require the framework version recorded in 19.7-02-SUMMARY.md. Applications mounting the plugin as a submodule: sm-demo-app (needed by plan 04), fonoteka.go and sm-bm-app (D-31 names them), sm-grzybyfunkcjonalne-app and sm-summercmsio-app (D-01: one pin bump per app). Each app's bump is one commit (go.mod, go.sum, submodule pointer) and each must `go build ./... && go test -short ./...` at the bumped pins; an app that fails for a reason unrelated to this phase is reported, not fixed here. Pre-checks before asking: clean plugin tree, `GOWORK=off go vet ./... && go test -count=1 ./...` (Docker) in the plugin, README updated.</context>
|
||||
<options>
|
||||
<option id="v019">
|
||||
<name>Tag v0.1.9 and bump all five applications</name>
|
||||
<pros>Additive patch release; every consumer moves together as D-01 asks</pros>
|
||||
<cons>Five application commits; a consumer with unrelated drift may need a follow-up</cons>
|
||||
</option>
|
||||
<option id="v019-demo-only">
|
||||
<name>Tag v0.1.9 and bump sm-demo-app, fonoteka.go and sm-bm-app only</name>
|
||||
<pros>Covers D-31's named consumers and plan 04's needs; fewer commits now</pros>
|
||||
<cons>grzybyfunkcjonalne and summercmsio stay on v0.1.8 until a later bump</cons>
|
||||
</option>
|
||||
<option id="hold">
|
||||
<name>Hold the tag</name>
|
||||
<pros>Review the plugin diff first</pros>
|
||||
<cons>Plan 04 cannot pin the plugin until the tag exists</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer v019, v019-demo-only or hold (with hold, say when to continue)</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Release the plugin at the chosen version and bump the application pointers</name>
|
||||
<reversibility rating="one-way">A pushed plugin tag is pinned by application go.mod files and submodule pointers; the migration it carries creates tables in every consumer that runs it.</reversibility>
|
||||
<precondition>The Task 4 checkpoint answered v019 or v019-demo-only; 19.7-02-SUMMARY.md records the framework tag; `git -C ../sm-demo-app/plugins/golem15/user status --short` is empty; each application to bump has a clean tree for go.mod, go.sum and plugins/golem15/user (check `git -C <app> status --short go.mod go.sum plugins/golem15/user`)</precondition>
|
||||
<files>../sm-demo-app/plugins/golem15/user/README.md, ../sm-demo-app/plugins/golem15/user/go.mod, ../sm-demo-app/plugins/golem15/user/go.sum, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum, ../sm-demo-app/plugins/golem15/user, ../fonoteka.go/go.mod, ../fonoteka.go/go.sum, ../fonoteka.go/plugins/golem15/user, ../sm-bm-app/go.mod, ../sm-bm-app/go.sum, ../sm-bm-app/plugins/golem15/user, ../sm-grzybyfunkcjonalne-app/go.mod, ../sm-grzybyfunkcjonalne-app/go.sum, ../sm-grzybyfunkcjonalne-app/plugins/golem15/user, ../sm-summercmsio-app/go.mod, ../sm-summercmsio-app/go.sum, ../sm-summercmsio-app/plugins/golem15/user</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md (Features, API reference, Admin, Configuration, Testing sections to extend)
|
||||
- .planning/notes/core-plugins-own-repos.md (commit and push the plugin first, then the pointer bump in the app as a separate commit)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md (the framework version to require)
|
||||
- `git -C ../sm-demo-app/plugins/golem15/user log --oneline v0.1.8..HEAD` (the commits the tag carries)
|
||||
- each application's go.mod (require lines for summercms and sm-user-plugin; fonoteka.go is at summercms v0.4.0 and will move to the plan-02 tag), each app's `.gitmodules` entry for plugins/golem15/user
|
||||
- CLAUDE.md § "Sibling repositories"
|
||||
</read_first>
|
||||
<action>
|
||||
README (in the plugin): Features (the account link and its proof, the Administrators-screen actions and the permission code, plugin frontend permission codes, the MCP guard and the `user_me` tool), API reference (the three new routes with bodies and errors, the new exported identifiers), Admin (the two record actions and My account section), Configuration (`frontend_url`, `backend_links.request_ttl`), Testing (the new smoke names). Then `go.mod`: `require git.golem15.com/golem15/summercms <plan-02 tag>` and `GOWORK=off go mod tidy`; commit `chore: require SummerCMS <tag>` (the plugin's existing convention, see commit 930b158). Pre-checks: `GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...` on Docker. Tag `git tag -a <version> -m "<message listing the five features>"` and `git push origin master --tags` from the plugin checkout (go-ahead given at the checkpoint).
|
||||
|
||||
Pointer bumps, one commit per app, in this order: sm-demo-app, fonoteka.go, sm-bm-app, then (v019 only) sm-grzybyfunkcjonalne-app and sm-summercmsio-app. In each app: `git -C <app>/plugins/golem15/user fetch --tags && git -C <app>/plugins/golem15/user checkout <version>`; edit go.mod `require git.golem15.com/golem15/sm-user-plugin <version>` and `require git.golem15.com/golem15/summercms <plan-02 tag>` (the new plugin needs the new pact types); `go mod tidy` in the app's workspace; `go build ./... && go test -short ./...`; commit `chore: bump user to <version> and require summercms <tag>` staging exactly go.mod, go.sum and plugins/golem15/user. Do not push the applications (the user deploys per app). If an app fails to build or test at the bumped pins for a reason outside this phase (for example a generated main.go that an older `summer build` wrote), stop, revert that app's working changes, record the failure with the exact error in the SUMMARY and in `.planning/phases/19.7-generic-mcp-module/deferred-items.md`, and raise a `checkpoint:human-verify` with `gate="blocking-human"` naming the app and the error; continue with the next app only after the user answers.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>TAG=$(git -C ../sm-demo-app/plugins/golem15/user describe --tags --exact-match HEAD) && git -C ../sm-demo-app/plugins/golem15/user ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null && for app in ../sm-demo-app ../fonoteka.go ../sm-bm-app; do (cd "$app" && go build ./... && go test -count=1 -short ./...) || exit 1; done</automated>
|
||||
<fails_when>non-zero exit (the plugin HEAD is not tagged, the remote lacks the tag, or an application fails to build or test at the bumped pins)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `git -C ../sm-demo-app/plugins/golem15/user describe --tags --exact-match HEAD` prints the chosen version and the remote has it
|
||||
- `grep -c "git.golem15.com/golem15/summercms <plan-02 tag>" ../sm-demo-app/plugins/golem15/user/go.mod` prints 1 (substitute the recorded tag)
|
||||
- For each bumped app: `grep -c "sm-user-plugin <version>" <app>/go.mod` prints 1, `git -C <app> log -1 --format=%s` is the bump commit, and `git -C <app> diff --quiet HEAD -- go.mod go.sum plugins/golem15/user` exits 0
|
||||
- `(cd ../fonoteka.go && go build ./... && go test -count=1 -short ./...)` and the same in ../sm-bm-app exit 0 (D-31), or the deferred-items.md entry and the human checkpoint explain which app did not
|
||||
- `grep -c "manage_backend_links\|backend-link/confirm\|user_me" ../sm-demo-app/plugins/golem15/user/README.md` prints at least 3
|
||||
</acceptance_criteria>
|
||||
<done>The plugin is tagged and pushed at the chosen version against the plan-02 framework tag, and every targeted application pins it in its own commit and builds and tests at the new pins (or the exception is recorded and surfaced).</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces (sm-user-plugin, `git.golem15.com/golem15/sm-user-plugin`)
|
||||
|
||||
**Migration**: `202610220001_create_golem15_user_backend_links` — tables `golem15_user_backend_links`, `golem15_user_backend_link_requests`
|
||||
**Models**: `models.BackendLink`, `models.BackendLinkRequest`
|
||||
**Service**: `classes.BackendLinks` (`CreateLinkRequest`, `LinkRequestByCode`, `ConfirmLinkRequest`, `SetLink`, `RemoveLink`, `LinkFor`, `LinkOf`, `LinkedBackendUser`), errors `ErrLinkRequestUsed`, `ErrLinkRequestExpired`, `ErrStaleSession`, `ErrAlreadyLinked`, `ErrBackendUserUnavailable`; events `classes.BackendLinkedEvent`, `classes.BackendUnlinkedEvent`; `classes.FireSubjectChanged`
|
||||
**Permissions and catalog**: `classes.PermissionManageBackendLinks = "golem15.users.manage_backend_links"`; `classes.FrontendPermissionCatalog`
|
||||
**MCP**: `classes.MCPUserGuard` (guard `user`, resolver for `usr_` tokens); tool `user_me`; `(*Plugin) MCP()`, `(*Plugin) AccountContributions()`, `(*Plugin) AdminActionExtensions()`
|
||||
**Routes**: `GET /_user/api/v1/backend-link/{code}`, `POST /_user/api/v1/backend-link/confirm` (jwt.auth), `GET /_user/api/v1/token/me` (user.api_token, user.scope:read)
|
||||
**Admin**: My account section `frontend_account` (actions `link`, `unlink`); Administrators record actions `link_frontend_account` (prompted), `unlink_frontend_account`
|
||||
**Config keys**: `golem15.user.frontend_url`, `golem15.user.backend_links.request_ttl`
|
||||
**Phrases**: `golem15.user::lang.backend_link.*`, `golem15.user::lang.plugin.manage_backend_links` (en, pl)
|
||||
**Release**: plugin tag (v0.1.9 proposed) requiring the plan-02 framework tag; pointer bump commits in sm-demo-app, fonoteka.go, sm-bm-app (and sm-grzybyfunkcjonalne-app, sm-summercmsio-app)
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| site browser to backend-link routes | an anonymous holder of a code reads the show route; a signed-in frontend user posts the confirm |
|
||||
| admin SPA to My account and Administrators actions | the signed-in admin's intent to link or unlink, and a privileged admin's typed email |
|
||||
| pier to the plugin's guard provider and resolvers | identity decisions for tools/list, tools/call and the linked admin |
|
||||
| plugin to the festival bus | subject-changed events other instances act on |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-22 | Elevation | link without proof or by email match (self-service) | high | mitigate | The self-service path writes a link only inside `ConfirmLinkRequest`: a one-shot hashed 32-byte code bound to the admin, 10-minute TTL, row lock, `jwt.auth` principal, JWT `iat` not before the request's `created_at` (P-11); no email matching and no user list anywhere on this path (`TestBackendLinkSmoke`) |
|
||||
| T-19.7-23 | Spoofing | replayed or guessed link code | medium | mitigate | 64-hex code (256 bits) compared through its SHA-256 hash, `used_at` set in the same transaction as the link, expired and used codes answer 404 identically; the show route reveals only the admin's login, display name and expiry |
|
||||
| T-19.7-24 | Elevation | admin sets a link to any frontend user (D-07) | high | mitigate | Separate permission `golem15.users.manage_backend_links` without a default role; exact-match email only (no search); `linked_by` recorded; `BackendLinkedEvent` and subject events fired; cabana's outranking check runs before Run; 1:1 uniqueness refuses a second link (`TestBackendLinkAdminSmoke`) |
|
||||
| T-19.7-25 | Elevation | cross-site request on confirm or unlink | medium | mitigate | Confirm is POST behind `jwt.auth` with the bearer re-verified for `iat`; My account actions run behind the backend guard, `interactiveOnly` and `requireAjax` (plan 01 seam); none of them accepts a GET |
|
||||
| T-19.7-26 | Information Disclosure | stale link resolution after unlink or deletion | medium | mitigate | `LinkedBackendUser` is one indexed query per call with no plugin-side cache; Deleting and Deactivating listeners remove the link in the same transaction; the backend-side `link` event lets pier drop its 5 s cache and recompute sessions (`TestBackendLinkSmoke` unlink and delete cases) |
|
||||
| T-19.7-27 | Elevation | tools/list and tools/call disagree on frontend permissions | medium | mitigate | `MCPAllows` uses `PrincipalByID` group grants and `cabana.Allows` per code with AND, the same evaluation `user.permission` middleware performs on the call; `TestUserMCPGuardSmoke` covers the missing-scope and partially granted cases |
|
||||
| T-19.7-28 | Spoofing | personal token resolution at the MCP endpoint | medium | mitigate | The resolver answers only for the configured prefix, verifies the hash and `IsUsableAt`, stamps last_used_at, and returns the token's own scopes as the ceiling; the in-memory dispatch credential has ID 0 and is never persisted (Pitfall 9) |
|
||||
| T-19.7-29 | Repudiation | who linked whom | low | mitigate | `linked_by` on admin-set links, `created_at` on every link and request, `BackendLinkedEvent`/`BackendUnlinkedEvent` for listeners, and the plugin's existing admin audit logging on record actions |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./...`
|
||||
- Docker host: `GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 ./...` with `TestBackendLinkSmoke`, `TestBackendLinkAdminSmoke`, `TestUserMCPGuardSmoke`, `TestFrontendPermissionCatalogSmoke` printing `--- PASS`
|
||||
- Additive check (the 19.4 gate's rule, formalised in plan 05): no exported func, method or type removed from a non-test .go file since 930b158
|
||||
- After Task 5: the plugin tag exists locally and on origin; each bumped application builds and tests at its new pins
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Every must_have truth is demonstrated by a named smoke test or by the release artifacts; the plugin repo diff against 930b158 removes no route, export, column, seeded row or payload field
|
||||
- Plan 04 can look up `*classes.BackendLinks`, `pact.MCPLinkedBackendResolver`, the `user` guard in `*pact.MCPGuards` and `pact.MCPPersonalTokenResolver` from an app that mounts the released plugin
|
||||
- The planner decisions P-10..P-15 are implemented as written and named in the SUMMARY
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-03-SUMMARY.md` (in the framework repo, planning docs commit) when done, recording the plugin version and which applications were bumped.
|
||||
</output>
|
||||
215
.planning/phases/19.7-generic-mcp-module/19.7-03-SUMMARY.md
Normal file
215
.planning/phases/19.7-generic-mcp-module/19.7-03-SUMMARY.md
Normal file
@@ -0,0 +1,215 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 03
|
||||
subsystem: user-plugin
|
||||
tags: [sm-user-plugin, mcp, backend-link, frontend-permissions, guard-provider, personal-tokens, release, pointer-bumps]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-01
|
||||
provides: AccountContributions and AdminActionExtensions seams, prompted record actions, pact MCP contracts (MCPGuard, MCPGuards, MCPLinkedBackendResolver, MCPPersonalTokenResolver, MCPSubjectChanged, HasFrontendPermissions)
|
||||
- phase: 19.7-02
|
||||
provides: modules/pier (catalog, guard providers, per-request identity, subject-event fan-out), released opt-in in framework v0.4.4
|
||||
provides:
|
||||
- sm-user-plugin v0.1.10 (git.golem15.com/golem15/sm-user-plugin), tagged and pushed, requiring SummerCMS v0.4.4
|
||||
- verified frontend-to-backend account link (tables, one-shot hashed code, fresh-sign-in proof, classes.BackendLinks published as pact.MCPLinkedBackendResolver)
|
||||
- Administrators-screen record actions link_frontend_account (prompted) and unlink_frontend_account behind golem15.users.manage_backend_links
|
||||
- My account section frontend_account (link, unlink)
|
||||
- classes.FrontendPermissionCatalog (seeded rows plus plugin codes; seeded row wins)
|
||||
- classes.MCPUserGuard (guard "user", usr_ personal-token resolver), GET /_user/api/v1/token/me, MCP tool user_me
|
||||
- pointer bumps to v0.1.10 + summercms v0.4.4 in sm-demo-app, fonoteka.go, sm-bm-app, sm-grzybyfunkcjonalne-app, sm-summercmsio-app (not pushed)
|
||||
affects: [19.7-04 oauthserver verifier and Journal (consumes the link resolver and user guard), 19.7-05 unit tests and security review, framework v0.5.0 at phase completion (cabana subject-event fix first)]
|
||||
|
||||
actuals:
|
||||
tokens: 26468
|
||||
tasks: 5
|
||||
commits: 6
|
||||
plan_head_before: 3828a65481190acf0b450e5f880cf85a14d63ad8
|
||||
plan_head_after: bfcfea4ed7d45374e9584557412b88797b051741
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Subject events fire as *pact.MCPSubjectChanged (pointer) after commit through lagoon.AfterCommit"
|
||||
- "Fresh-sign-in proof: confirm route behind jwt.auth re-reads the bearer and requires iat (seconds) >= the link request's created_at (seconds)"
|
||||
- "Guard provider registers itself into the find-or-publish *pact.MCPGuards registry and doubles as pact.MCPPersonalTokenResolver"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-demo-app/plugins/golem15/user/updates/202610220001_create_backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/backend_link.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/backend_link_request.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/subject_events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/frontend_permission_catalog.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/token_me.go
|
||||
- ../sm-demo-app/plugins/golem15/user/account_contributions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_links_admin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_admin_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp_guard_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_smoke_test.go
|
||||
modified:
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/routes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/admin_permissions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/privileged.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/usergroups_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/config/config.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md
|
||||
- ../sm-demo-app/plugins/golem15/user/go.mod
|
||||
- ../sm-demo-app/plugins/golem15/user/go.sum
|
||||
- "pinned-count tests: admin_harness_test.go, admin_registration_test.go, admin_users_test.go, password_routes_test.go, updates/organisations_test.go, updates/user_groups_test.go, updates/user_session_test.go"
|
||||
- "five apps: go.mod, go.sum, plugins/golem15/user"
|
||||
- .planning/phases/19.7-generic-mcp-module/deferred-items.md
|
||||
|
||||
key-decisions:
|
||||
- "P-10: golem15_user_backend_links (1:1, both sides unique) and golem15_user_backend_link_requests (64-hex code stored as SHA-256, request_ttl default 10m, one-shot, bound to the creating admin)"
|
||||
- "P-11: confirm behind jwt.auth, bearer re-read with bouncer.VerifyClaims; iat older than the request's created_at answers 409 stale_session"
|
||||
- "P-12: admin set by exact, case-insensitive email of an active user; no search or list; golem15.users.manage_backend_links with no default role; linked_by recorded"
|
||||
- "P-13: golem15.user.frontend_url added here (empty default falls back to app.url); link page is <frontend_url>/link-admin?code=<plain>"
|
||||
- "P-14: MCPAllows uses PrincipalByID group grants and cabana.Allows per code with AND, the same as user.permission middleware"
|
||||
- "P-15 (user, Task 4 checkpoint): release as v0.1.10 (v0.1.9 was taken by the public_routes release), bump all five applications"
|
||||
- "Plugin subject events fire as pointers after commit; cabana's value-typed in-transaction firing is a framework bug recorded in deferred-items.md, to fix before v0.5.0"
|
||||
|
||||
patterns-established:
|
||||
- "A plugin-side MCP guard provider: register into *pact.MCPGuards, answer MCPAllows with the same evaluation the route middleware runs, dispatch with an in-memory (ID 0) credential"
|
||||
|
||||
requirements-completed: [SC-4, D-01, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-15, D-16, D-17, D-18, D-23, D-26, D-34, D-35]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Self-service link: My account request, one-shot code, fresh sign-in confirm; replayed, expired and stale-session confirms refused; no email match or list on this path; unlink and delete remove the link"
|
||||
requirement: "D-05"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-demo-app/plugins/golem15/user/backend_link_smoke_test.go#TestBackendLinkSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Administrators-screen link and unlink behind golem15.users.manage_backend_links, linked_by recorded, events fired, taken account refused"
|
||||
requirement: "D-34"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-demo-app/plugins/golem15/user/backend_link_admin_smoke_test.go#TestBackendLinkAdminSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "User guard: tools/list agrees with user.permission (group grants, AND across codes), every user.scope required, usr_ personal tokens resolved, user_me returns the payload"
|
||||
requirement: "D-35"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-demo-app/plugins/golem15/user/mcp_guard_smoke_test.go#TestUserMCPGuardSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Plugin frontend permission codes appear in both editors next to seeded rows; seeded row wins"
|
||||
requirement: "D-09"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-demo-app/plugins/golem15/user/frontend_permission_catalog_smoke_test.go#TestFrontendPermissionCatalogSmoke"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Additive release v0.1.10 on origin requiring summercms v0.4.4; five apps bumped one commit each, each builds and passes short tests"
|
||||
requirement: "D-01"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "git ls-remote --tags origin refs/tags/v0.1.10 (a2f8672); go build ./... && go test -count=1 -short ./... in each app"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: about 27 min of commit activity (first task commit 10:03Z to the last app bump 10:28Z, 2026-10-23), plus the Task 4 checkpoint wait
|
||||
completed: 2026-10-23
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 03: sm-user-plugin account link, user MCP guard and v0.1.10 Summary
|
||||
|
||||
**sm-user-plugin v0.1.10 adds the verified frontend-to-backend account link. An admin starts it on My account and a frontend user confirms it with a one-shot hashed code and a fresh sign-in. The Administrators screen can link and unlink accounts under `golem15.users.manage_backend_links`. The release also adds plugin-declared frontend permission codes, the `user` MCP guard provider with `usr_` personal-token resolution, and the `user_me` tool. It requires SummerCMS v0.4.4 and is pinned in all five applications.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 27 min of commit activity on 2026-10-23 (10:03Z to 10:28Z), split by the Task 4 release checkpoint
|
||||
- **Completed:** 2026-10-23T10:28Z
|
||||
- **Tasks:** 5 (Task 4 was the release-version checkpoint, answered "v0110": v0.1.10, all five apps)
|
||||
- **Files:** 37 in the plugin (2,418 insertions, 61 deletions since v0.1.9), plus go.mod, go.sum and the submodule pointer in each of five apps
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Task 1 (tracer, `7ac80c9`):** migration `202610220001_create_golem15_user_backend_links` creates the two tables. `classes.BackendLinks` provides `CreateLinkRequest`, `LinkRequestByCode`, `ConfirmLinkRequest` (row lock, `iat` check), `SetLink`, `RemoveLink`, `LinkFor`, `LinkOf` and `LinkedBackendUser`, and is published both as `*classes.BackendLinks` and as `pact.MCPLinkedBackendResolver`. Routes `GET /_user/api/v1/backend-link/{code}` and `POST /_user/api/v1/backend-link/confirm`, the My account section `frontend_account`, `BackendLinkedEvent` and `BackendUnlinkedEvent`, and subject events after commit. Deleting or deactivating a frontend user removes its link.
|
||||
- **Task 2 (`0f545f5`, fix `dbb3d33`):** `classes.FrontendPermissionCatalog` feeds both permission editors. `classes.MCPUserGuard` is registered in `*pact.MCPGuards` and published as `pact.MCPPersonalTokenResolver`. This task also added `GET /_user/api/v1/token/me` and the `user_me` tool, plus subject events on token revoke and on Users and User Groups saves and deletes.
|
||||
- **Task 3 (`6f1cb1a`):** `golem15.users.manage_backend_links` (en and pl labels), and the record actions `link_frontend_account` (prompted, exact email) and `unlink_frontend_account` (danger) on cabana's Administrators controller.
|
||||
- **Task 4:** release checkpoint. The user chose v0.1.10 and all five applications.
|
||||
- **Task 5:** README (`59cc3bd`) and `chore: require SummerCMS v0.4.4` (`bfcfea4`). The full Docker suite passed (`GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...`; `TestBackendLinkSmoke`, `TestBackendLinkAdminSmoke`, `TestUserMCPGuardSmoke` and `TestFrontendPermissionCatalogSmoke` print `--- PASS`). Annotated tag `v0.1.10` was pushed with master (`git push origin master v0.1.10`, remote tag object a2f8672). Then one pointer-bump commit in each app.
|
||||
- Additive check: `git diff 3828a65 HEAD -- '*.go' ':!*_test.go'` removes no exported func or type.
|
||||
|
||||
## Task Commits
|
||||
|
||||
Plugin (`git.golem15.com/golem15/sm-user-plugin`, master, pushed):
|
||||
|
||||
1. **Task 1: verified link tracer** - `7ac80c9` (feat)
|
||||
2. **Task 2: guard provider, frontend permissions, user_me** - `0f545f5` (feat), fix `dbb3d33`
|
||||
3. **Task 3: Administrators-screen actions** - `6f1cb1a` (feat)
|
||||
4. **Task 4: release checkpoint** - no commit
|
||||
5. **Task 5: README and framework pin** - `59cc3bd` (docs), `bfcfea4` (chore), tag `v0.1.10`
|
||||
|
||||
Applications (`chore: bump user to v0.1.10 and require summercms v0.4.4`, not pushed):
|
||||
|
||||
| App | Commit | From |
|
||||
|---|---|---|
|
||||
| sm-demo-app | `985af53` | user v0.1.9, summercms v0.4.3 |
|
||||
| fonoteka.go | `06bc9d0` | user v0.1.0 in go.mod (submodule at v0.1.6), summercms v0.4.0 |
|
||||
| sm-bm-app | `d180d35` | user v0.1.8, summercms v0.4.3 |
|
||||
| sm-grzybyfunkcjonalne-app | `acbf68b` | user v0.1.8, summercms v0.4.3 |
|
||||
| sm-summercmsio-app | `a1a661d` | user v0.1.8, summercms v0.4.3 |
|
||||
|
||||
Each app ran `go build ./... && go test -count=1 -short ./...` at the new pins, and all passed. `go mod tidy` added the go-sdk v1.8.0 transitive set as indirect requirements, matching framework v0.4.4's go.mod. `commits: 6` is measured in the plugin repo (`git rev-list --count 3828a65..bfcfea4`). The five app commits are in addition to that count.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
1. **[Rule 3 - Blocking] backend_users FKs through a `DO $$` block.** The migration adds the foreign keys to `backend_users` only when `to_regclass('backend_users')` exists, so the plugin's own test databases (which do not carry cabana's tables) still migrate. (Task 1)
|
||||
2. **[Rule 1 - Bug] Updated test counts that the new rows and routes changed.** Route counts went from 18 to 21 and from 15 to 18, and the rollback counts, migration history and permission lists in the existing tests were updated to match. (Tasks 1-3)
|
||||
3. **[Rule 1 - Bug] Subject events fire as `*pact.MCPSubjectChanged` after commit.** pier listens for the pointer type, so the plugin fires a pointer through `lagoon.AfterCommit`. cabana's own value-typed, in-transaction firing never reaches pier. That is a framework bug, recorded in deferred-items.md and to be fixed before v0.5.0. (Task 1)
|
||||
4. **[Rule 2 - Security] The confirm route uses `classes.SessionToken` and requires the token's subject to equal the `jwt.auth` principal,** in addition to the `iat` check. (Task 1)
|
||||
5. **[Rule 1 - Bug] `iat` and `created_at` are compared truncated to seconds.** JWT `iat` has whole-second precision, so a sign-in in the same second as the request would otherwise count as stale. (Task 1)
|
||||
6. **[Rule 2 - Security] `CreateLinkRequest` deletes the admin's earlier unused requests,** so only the latest code is valid. (Task 1)
|
||||
7. **[Rule 2] The Users and UserGroups update hooks fire permissions events on every save.** They do not diff the permissions first, which is cheap and errs toward re-listing. (Task 2)
|
||||
8. **Recorded gap: the `user:token:revoke` console command fires no subject event.** Only the HTTP revoke does. (Task 2)
|
||||
9. **[Rule 1] A second link for an already linked admin answers 409 (the action's Applies check), not 422.** The 422 `already_linked` path is tested with a second admin targeting a frontend user who is already taken. (Task 3)
|
||||
10. **[Rule 1 - Bug, `dbb3d33`] Group-delete subject events moved to `FormBeforeDelete`.** This keeps the existing `FormAfterDelete` declaration unchanged, so the additive gate stays clean. Member ids are read inside the delete's transaction, and the events fire after commit. (Task 2 fix)
|
||||
11. **"Linked to <email>" is interpolated,** which produces a dev-only missing-translation warning for the composed string. (Task 1)
|
||||
12. **New export `ErrFrontendUserUnavailable`,** returned when the target frontend user is missing or inactive. This is additive. (Task 3)
|
||||
|
||||
Drift from the plan text: the plan proposed v0.1.9 and "the plan-02 tag". v0.1.9 had already been released for the public_routes switch, and plan 02 cut no tag (the framework shipped pier opt-in in v0.4.4), so the release is v0.1.10 against v0.4.4.
|
||||
|
||||
## Deferred Issues
|
||||
|
||||
- **Framework bug, cabana backend subject events (open, blocks v0.5.0):** `modules/cabana/subject_events.go` fires `pact.MCPSubjectChanged` as a value inside the save's transaction. `modules/pier/events.go` listens for `*pact.MCPSubjectChanged`. Because `festival.Bus` keys listeners by type, pier never receives cabana's backend deletion, permission, role and revocation events. The entry is in `.planning/phases/19.7-generic-mcp-module/deferred-items.md`.
|
||||
- The `user:token:revoke` console command fires no subject event (deviation 8). A follow-up can fire the event from the console path.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None beyond the plan's threat model (T-19.7-22..29). The new routes, the guard provider and the admin actions are the surfaces that model covers.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
Plan 04 can look up `*classes.BackendLinks`, `pact.MCPLinkedBackendResolver`, the `user` guard in `*pact.MCPGuards` and `pact.MCPPersonalTokenResolver` from any of the five applications at v0.1.10. The application bump commits are local and wait for the user's push and per-app deploy.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- Plugin files present (models, classes, controllers, migration, smoke tests). Commits 7ac80c9, 0f545f5, 6f1cb1a, dbb3d33, 59cc3bd and bfcfea4 are in the plugin repo, and the tag v0.1.10 is on origin.
|
||||
- App commits 985af53, 06bc9d0, d180d35, acbf68b and a1a661d exist, and `git diff --quiet HEAD -- go.mod go.sum plugins/golem15/user` is clean in each app.
|
||||
365
.planning/phases/19.7-generic-mcp-module/19.7-04-PLAN.md
Normal file
365
.planning/phases/19.7-generic-mcp-module/19.7-04-PLAN.md
Normal file
@@ -0,0 +1,365 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 04
|
||||
type: execute
|
||||
wave: 4
|
||||
depends_on: ["19.7-03"]
|
||||
files_modified:
|
||||
- ../sm-oauthserver-plugin/servers.go
|
||||
- ../sm-oauthserver-plugin/plugin.go
|
||||
- ../sm-oauthserver-plugin/routes.go
|
||||
- ../sm-oauthserver-plugin/classes/mcp_verifier.go
|
||||
- ../sm-oauthserver-plugin/classes/cascade.go
|
||||
- ../sm-oauthserver-plugin/classes/subject_events.go
|
||||
- ../sm-oauthserver-plugin/controllers/authorizations.go
|
||||
- ../sm-oauthserver-plugin/controllers/mcp_consent_api.go
|
||||
- ../sm-oauthserver-plugin/config/config.yaml
|
||||
- ../sm-oauthserver-plugin/lang/en/lang.yaml
|
||||
- ../sm-oauthserver-plugin/lang/pl/lang.yaml
|
||||
- ../sm-oauthserver-plugin/README.md
|
||||
- ../sm-oauthserver-plugin/go.mod
|
||||
- ../sm-oauthserver-plugin/go.sum
|
||||
- ../sm-oauthserver-plugin/mcp_verifier_smoke_test.go
|
||||
- ../sm-oauthserver-plugin/mcp_consent_smoke_test.go
|
||||
- ../sm-journal-plugin/mcp.go
|
||||
- ../sm-journal-plugin/controllers/api/auth.go
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-journal-plugin/go.mod
|
||||
- ../sm-journal-plugin/go.sum
|
||||
- ../sm-journal-plugin/mcp_smoke_test.go
|
||||
- ../sm-demo-app/summer.yaml
|
||||
- ../sm-demo-app/plugins.gen.go
|
||||
- ../sm-demo-app/main.go
|
||||
- ../sm-demo-app/go.mod
|
||||
- ../sm-demo-app/go.sum
|
||||
- ../sm-demo-app/config/mcp.yaml
|
||||
- ../sm-demo-app/config/golem15.oauthserver.yaml
|
||||
- ../sm-demo-app/config/http.yaml
|
||||
- ../sm-demo-app/boot_test.go
|
||||
- ../sm-demo-app/mcp_e2e_test.go
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
|
||||
- ../sm-demo-app/DEPLOY.md
|
||||
- ../sm-demo-app/plugins/golem15/oauthserver
|
||||
- ../sm-demo-app/plugins/golem15/journal
|
||||
- ../sm-demo-app/vue-demo-app
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/connect.vue
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/en.json
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/pl.json
|
||||
- .planning/phases/19.7-generic-mcp-module/deferred-items.md
|
||||
autonomous: false
|
||||
requirements: [SC-1, SC-3, SC-4, D-02, D-05, D-15, D-16, D-17, D-18, D-21, D-22, D-23, D-26, D-30, D-31, D-33, D-35, D-36]
|
||||
|
||||
estimate:
|
||||
tokens: 85000
|
||||
raw_tokens: 85000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "An oas_at_ MCP access token is verified at the resource by a verifier sm-oauthserver-plugin publishes: prefix, hash, not revoked, not expired, client of kind mcp and not revoked, user active; an OIDC token or a foreign-kind client's token is refused (SC-4, D-02; Pitfall 4)"
|
||||
- "The MCP authorization server offers the backend scope; the consent JSON shows 'also act as admin <name>' only when the user has a verified link and drops backend from the grant when there is none; a user can connect a client to frontend tools only (D-21, D-35)"
|
||||
- "An editor signs in once through the demo's /connect page as a frontend user; with a link and the backend scope, Journal's post tools run as that admin with the admin's real permissions, and removing the link or the grant removes them (SC-4, D-18, D-22)"
|
||||
- "Journal declares its post, category and tag tools and one prompt with Guard backend and Permissions access_posts; the list and show tools see the dispatched principal through optionalBackendPrincipal (D-15, D-16, D-17, D-18)"
|
||||
- "sm-demo-app builds with the summercms_mcp tag, mounts /mcp and the protected resource metadata with the memory session store, routes them through nginx in the deploy notes, and boots unchanged when mcp.enabled is false (SC-1, D-30, D-33)"
|
||||
- "Grant revocation and user deletion or deactivation fire pact.MCPSubjectChanged so sessions end on every instance (D-26)"
|
||||
- "oauthserver and Journal are released additively after the plugin release of plan 03 and the demo pins them in separate commits (D-31)"
|
||||
artifacts:
|
||||
- path: "../sm-oauthserver-plugin/classes/mcp_verifier.go"
|
||||
provides: "MCPTokenVerifier implementing pact.MCPTokenVerifier"
|
||||
contains: "func (v *MCPTokenVerifier) MCPVerifyToken("
|
||||
- path: "../sm-oauthserver-plugin/controllers/mcp_consent_api.go"
|
||||
provides: "MCPConsentShow and MCPConsentDecide"
|
||||
contains: "backend_admin"
|
||||
- path: "../sm-journal-plugin/mcp.go"
|
||||
provides: "HasMCP: journal post, category, tag tools and the draft_post prompt"
|
||||
contains: "golem15.journal.access_posts"
|
||||
- path: "../sm-demo-app/config/mcp.yaml"
|
||||
provides: "mcp.enabled, path, sessions.store memory"
|
||||
contains: "enabled: true"
|
||||
- path: "../sm-demo-app/mcp_e2e_test.go"
|
||||
provides: "TestMCPEndToEnd (tagged summercms_mcp, Postgres)"
|
||||
contains: "//go:build summercms_mcp"
|
||||
- path: "../sm-demo-app/vue-demo-app/app/pages/connect.vue"
|
||||
provides: "the MCP consent page"
|
||||
- path: "../sm-demo-app/vue-demo-app/app/pages/link-admin.vue"
|
||||
provides: "the link-proof page"
|
||||
key_links:
|
||||
- from: "../sm-oauthserver-plugin/plugin.go"
|
||||
to: "../sm-oauthserver-plugin/classes/mcp_verifier.go"
|
||||
via: "Boot publishes the verifier as pact.MCPTokenVerifier when mcp.enabled"
|
||||
pattern: "MCPTokenVerifier"
|
||||
- from: "../sm-oauthserver-plugin/controllers/mcp_consent_api.go"
|
||||
to: "summercms.go/modules/pact/mcp.go"
|
||||
via: "app.Lookup[pact.MCPLinkedBackendResolver] decides the backend_admin line and the backend scope"
|
||||
pattern: "MCPLinkedBackendResolver"
|
||||
- from: "../sm-demo-app/vue-demo-app/app/pages/connect.vue"
|
||||
to: "../sm-oauthserver-plugin/routes.go"
|
||||
via: "GET and POST /oauth/mcp/requests/{request} with the frontend JWT"
|
||||
pattern: "/oauth/mcp/requests/"
|
||||
- from: "../sm-demo-app/summer.yaml"
|
||||
to: "summercms.go/modules/surf/pier_on.go"
|
||||
via: "build.tags summercms_mcp links pier into the demo binary"
|
||||
pattern: "summercms_mcp"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: not here -->
|
||||
<!-- planner-discipline-allow: hasBearer -->
|
||||
|
||||
<objective>
|
||||
Close the OAuth and application side of SC-4 and prove both guards end to end in the demo: sm-oauthserver-plugin gains the `backend` scope on its MCP server, the resource-side `oas_at_` verifier, the MCP consent JSON endpoints with the linked-admin line, and the revoked events (D-02, D-21, D-26, D-35); Journal declares the first backend tools and a prompt and gets the one-line `optionalBackendPrincipal` fix (D-15, D-16, D-17, D-18); sm-demo-app builds with `summercms_mcp`, mounts pier with the memory store, serves the `/connect` consent and `/link-admin` proof pages from vue-demo-app, documents the nginx and deploy changes, and carries the end-to-end test (SC-1, SC-4, D-30, D-33). Then the oauthserver and Journal releases and the demo's pointer bumps (D-31).
|
||||
|
||||
**Planner decisions recorded here:**
|
||||
- **P-16 (consent contract, D-35):** `GET /oauth/mcp/requests/{request}` (behind `jwt.auth` and `throttle:oauth-authorize`) answers `{request_id, client: {name, redirect_host}, scopes: [...requested], expires_at, backend_admin: {login, name} | null}`; `backend_admin` is non-null only when `backend` is requested AND the user has a link. `POST /oauth/mcp/requests/{request}` with `{decision: "allow"|"deny", scopes?: [...]}` grants `submitted ∩ requested` (requested when omitted) minus `backend` when there is no link, answers `{redirect_uri}` from `IssueCode`/`DenyPending`; 404 `{"error":"request_not_found"}`, 422 `{"error":"no_grantable_scopes"}`. A later link needs a new consent (A8 accepted).
|
||||
- **P-17 (Journal tool set, Claude's discretion):** `journal_list_posts` (GET /posts), `journal_show_post` (GET /posts/{slug}), `journal_list_categories`, `journal_list_tags` (read), `journal_create_post` (POST /posts), `journal_update_post` (PUT /posts/{id}), `journal_delete_post` (DELETE /posts/{id}, destructive); one prompt `journal_draft_post` with arguments `topic` (required) and `tone`. All `Guard: "backend"`, `Permissions: ["golem15.journal.access_posts"]`. Multipart upload routes are not tools.
|
||||
- **P-18 (repos and sync):** oauthserver and Journal are edited in their canonical repos (`../sm-oauthserver-plugin` on master, `../sm-journal-plugin` on main); the demo's submodules are moved to the same commits by fetching from the local repo path (`git -C ../sm-demo-app/plugins/golem15/<name> fetch /media/nvme/dev/golem15/summercms.io/summercms/sm-<name>-plugin <branch> && git checkout FETCH_HEAD`) during development and to the tags at release; vue-demo-app is edited in the demo's submodule checkout (`../sm-demo-app/vue-demo-app`, master, the newer of the two checkouts).
|
||||
- **P-19 (demo store, A7):** the demo runs one instance without Redis, so `mcp.sessions.store: memory`; DEPLOY.md documents the Redis switch (`SUMMER_MCP__SESSIONS__STORE=redis` plus `SUMMER_REDIS__URL`) for a multi-instance host.
|
||||
- **P-20 (versions):** oauthserver `v0.1.2`, Journal `v0.2.3`, both additive; the user decides at the checkpoint.
|
||||
|
||||
Purpose: SC-4's "one connector per person" is demonstrable: a frontend sign-in, a verified link, the backend scope, Journal tools as the admin, and removal on unlink.
|
||||
Output: the verifier, the scope, the consent endpoints and pages, Journal's tools, the demo wiring, the e2e smoke, deploy notes, two plugin releases and the demo's pointer bumps.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<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-PATTERNS.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.4-oidc-provider-on-wristband/19.4-CONTEXT.md
|
||||
@.planning/notes/core-plugins-own-repos.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Core-plugin rule for oauthserver and Journal: additive only; existing routes, payloads, tables, scopes (`read`, `write`, `ai`, `offline_access`) and error bodies unchanged. Journal's management routes keep `requireBackendPrincipal` and their PHP-parity error bodies.
|
||||
- Plugin repos first (commit, then tag and push only after the checkpoint); vue-demo-app is committed in its submodule checkout and pushed to its master only after the same checkpoint; pointer bumps in sm-demo-app as separate local commits (sm-demo-app itself is not pushed in this plan). Nothing is deployed in this plan; DEPLOY.md gains the instructions and the user deploys.
|
||||
- `summer build` in the demo regenerates `plugins.gen.go` and `main.go`: install the CLI from the framework at the plan-02 tag first (`go install ./cmd/summer` from the framework checkout at that tag). The demo's `main.go` currently shows an uncommitted diff from another session: run `git -C ../sm-demo-app status --short` first; if `main.go` is modified before this plan touches it, stash nothing, stage only the regeneration this plan produces, and note the pre-existing diff in the SUMMARY.
|
||||
- Stage by explicit path; one logical change per commit; no co-author tags; planning docs (framework repo) in their own commit.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: an oas_at_ token minted by the demo's MCP authorization server lists and calls user_me through /mcp in the demo built with the summercms_mcp tag</name>
|
||||
<reversibility rating="costly">The backend scope name becomes part of the MCP metadata and of existing grants (D-21 costly, user-chosen); the verifier contract is consumed by pier.</reversibility>
|
||||
<files>../sm-oauthserver-plugin/servers.go, ../sm-oauthserver-plugin/plugin.go, ../sm-oauthserver-plugin/classes/mcp_verifier.go, ../sm-oauthserver-plugin/mcp_verifier_smoke_test.go, ../sm-oauthserver-plugin/README.md, ../sm-demo-app/summer.yaml, ../sm-demo-app/plugins.gen.go, ../sm-demo-app/main.go, ../sm-demo-app/config/mcp.yaml, ../sm-demo-app/config/golem15.oauthserver.yaml, ../sm-demo-app/boot_test.go, ../sm-demo-app/mcp_e2e_test.go, ../sm-demo-app/plugins/golem15/oauthserver</files>
|
||||
<read_first>
|
||||
- ../sm-oauthserver-plugin/servers.go 95-165 (LoadConfig MCP keys, NewServers, mcpOpts), plugin.go 55-110 (Boot, Publish), classes/mcp_store.go (MCPAccessTokenPrefix, the sha256 hash at ~338, Mint at ~329, ByClientID kind filter), models/access_token.go, models/client.go (ClientKindMCP, RevokedAt or equivalent), classes/lazy.go (LazyMCPStore resolving *gorm.DB at request time), harness_test.go and authorize_test.go (test shapes)
|
||||
- ../sm-oauthserver-plugin/README.md lines 20-45 (the "Verifying MCP access tokens at a resource arrives with the MCP module, not here" sentence to replace)
|
||||
- summercms.go: modules/pact/mcp.go (MCPTokenVerifier, MCPGrant, ErrMCPTokenInvalid), modules/cabana/token_guard.go stampThrottle (the last_used_at debounce pattern to copy), modules/pier/README.md Configuration (the mcp.* keys), modules/surf/pier_on.go, internal/build/manifest.go (build.tags)
|
||||
- ../sm-demo-app/summer.yaml, boot_test.go (TestBootAllPlugins, testConfig, routed), testmain_test.go (flag.Parse then testing.Short), internal/demotest/postgres.go (Options, App, Demo: App, Plugins, DB), config/app.yaml (url), DEPLOY.md 325-352 (Build)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Pitfall 4", § "Pitfall 8", § "Pattern 9"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md § "OAS/classes/mcp_verifier.go, OAS/servers.go" and § "DEMO/summer.yaml, config, DEMO/mcp_e2e_test.go"
|
||||
</read_first>
|
||||
<action>
|
||||
oauthserver: in `NewServers` after `mcpOpts := opts`, `mcpOpts.ScopesSupported = append(slices.Clone(opts.ScopesSupported), "backend")` (the OIDC server's options stay as they are); the metadata then lists `backend` and wristband (plan 01) accepts it at authorize. New `classes/mcp_verifier.go`: `type MCPTokenVerifier struct { App *backpack.App; Resource string; stamps ... }` implementing `pact.MCPTokenVerifier`: `MCPVerifyToken(ctx, raw)`: prefix `MCPAccessTokenPrefix` else `ErrMCPTokenInvalid`; hash with the same function `Mint` stores; load the `models.AccessToken` by `token_hash`; refuse revoked, expired (`expires_at` nil counts as never expiring only if the store mints such tokens; otherwise refuse nil), a client not found with `kind = mcp` or revoked, a user that `userclasses.PrincipalByID` cannot load (deleted or deactivated); debounce `last_used_at` writes to one per minute per token (copy cabana's stampThrottle shape); answer `pact.MCPGrant{UserID, ClientID, TokenID, Scopes, ExpiresAt}`; `MCPResource()` returns `cfg.MCPResource`. Boot: when `cfg.MCPEnabled`, `app.Publish[pact.MCPTokenVerifier](&classes.MCPTokenVerifier{App: app, Resource: cfg.MCPResource})`. README: replace the "not here" sentence with the verifier paragraph and add the `backend` scope to the MCP section. Smoke `TestMCPTokenVerifierSmoke` (Postgres, the plugin's harness): a minted MCP token verifies with its scopes and client id; an OIDC access token row (client kind oidc) is refused; a revoked token, an expired token and a token of a revoked client are refused; a deactivated user's token is refused; two verifications within a minute write `last_used_at` once.
|
||||
|
||||
Demo wiring: `summer.yaml` gains `build: { tags: [summercms_mcp] }`; `config/mcp.yaml` with `enabled: true`, `path: /mcp`, `sessions: { store: memory, idle_ttl: 30m }`, `allow_personal_tokens: false`, and a comment pointing at `docs/services/mcp.md`; `config/golem15.oauthserver.yaml` with `mcp: { enabled: true, resource: https://demo.summercms.io/mcp }` (local runs override through `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE` and `SUMMER_MCP__RESOURCE` in `.env`, see DEPLOY.md task); move the oauthserver submodule to the new commit (P-18) and `go mod tidy` in the demo; `go install ./cmd/summer` from the framework at the plan-02 tag, then `summer build` in the demo to regenerate `plugins.gen.go` and `main.go` (commit only this plan's regeneration). `boot_test.go`: with the committed config the route list contains `POST /mcp` and `GET /.well-known/oauth-protected-resource` when the test binary carries the tag, and contains neither when built without it (two sub-tests or two build-tagged files: `boot_mcp_tagged_test.go` and `boot_mcp_untagged_test.go` are acceptable in place of editing boot_test.go, update files_modified accordingly in the SUMMARY); the existing assertions stay.
|
||||
|
||||
E2E smoke `mcp_e2e_test.go` (`//go:build summercms_mcp`, Postgres through `bootDemo`): assemble the handler with `surf.Assemble(demo.App, demo.Plugins)` on an `httptest.NewServer`; seed a frontend user and an `mcp` client row, mint an access token through `classes.NewMCPStore(demo.DB)` (its `Mint`, scopes `read write`) or by inserting the hashed row; with the go-sdk client and a bearer-injecting `http.Client`: `ListTools` contains `user_me` and contains no `journal_` tool (no link yet), `CallTool("user_me", {})` answers `isError false` with `structuredContent.user.email` equal to the seeded email; a bearer `oas_at_nope` is 401 with `WWW-Authenticate` naming `/.well-known/oauth-protected-resource/mcp`; `GET /.well-known/oauth-protected-resource/mcp` returns JSON whose `resource` equals the configured `mcp.resource`. Name the test `TestMCPEndToEnd` with sub-tests; Task 3 extends it with the Journal case.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./... && go -C ../sm-oauthserver-plugin test -count=1 -run '^TestMCPTokenVerifierSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPTokenVerifierSmoke' && (cd ../sm-demo-app && go vet ./... && go test -count=1 -short ./... && go build -tags summercms_mcp ./... && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd')</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or either PASS line is absent (a SKIP for a missing Docker daemon counts as absent)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c '"backend"' ../sm-oauthserver-plugin/servers.go` prints 1 and the OIDC `opts` line is unchanged (`grep -c "mcpOpts.ScopesSupported" ../sm-oauthserver-plugin/servers.go` prints 1)
|
||||
- `grep -c "func (v \*MCPTokenVerifier) MCPVerifyToken(\|func (v \*MCPTokenVerifier) MCPResource(" ../sm-oauthserver-plugin/classes/mcp_verifier.go` prints 2 and `grep -c "ClientKindMCP" ../sm-oauthserver-plugin/classes/mcp_verifier.go` prints at least 1
|
||||
- `grep -c "pact.MCPTokenVerifier" ../sm-oauthserver-plugin/plugin.go` prints at least 1
|
||||
- `grep -c "not here" ../sm-oauthserver-plugin/README.md` prints 0 and `grep -c "backend" ../sm-oauthserver-plugin/README.md` prints at least 1
|
||||
- `grep -c "summercms_mcp" ../sm-demo-app/summer.yaml` prints 1; `grep -c "enabled: true" ../sm-demo-app/config/mcp.yaml` prints 1; `grep -c "resource:" ../sm-demo-app/config/golem15.oauthserver.yaml` prints 1
|
||||
- `head -1 ../sm-demo-app/mcp_e2e_test.go` prints `//go:build summercms_mcp`
|
||||
- `(cd ../sm-demo-app && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v .) 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd'` on a Docker host
|
||||
- `(cd ../sm-demo-app && go test -count=1 -short ./...)` passes without the tag (the untagged demo is unchanged apart from the new config files)
|
||||
</acceptance_criteria>
|
||||
<done>The demo, built with the tag, serves /mcp; a real MCP access token from its own authorization server is verified at the resource and the frontend tool runs end to end; the backend scope is advertised.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: MCP consent JSON endpoints with the linked-admin line, revoked events, and the /connect and /link-admin pages in vue-demo-app</name>
|
||||
<files>../sm-oauthserver-plugin/routes.go, ../sm-oauthserver-plugin/controllers/mcp_consent_api.go, ../sm-oauthserver-plugin/controllers/authorizations.go, ../sm-oauthserver-plugin/classes/cascade.go, ../sm-oauthserver-plugin/classes/subject_events.go, ../sm-oauthserver-plugin/lang/en/lang.yaml, ../sm-oauthserver-plugin/lang/pl/lang.yaml, ../sm-oauthserver-plugin/mcp_consent_smoke_test.go, ../sm-oauthserver-plugin/README.md, ../sm-demo-app/vue-demo-app/app/pages/connect.vue, ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue, ../sm-demo-app/vue-demo-app/i18n/locales/en.json, ../sm-demo-app/vue-demo-app/i18n/locales/pl.json</files>
|
||||
<read_first>
|
||||
- ../sm-oauthserver-plugin/controllers/consent_api.go (ConsentShow, ConsentDecide, principalID, writeJSON) and routes.go 54-76 (the redirect-mode consent block and the MCP block)
|
||||
- summercms.go/modules/wristband/consent.go 30-120 (PendingRequest, PendingRequestView, IssueCode, DenyPending, ErrNoGrantableScopes, ErrPendingNotFound) and authorize.go 165-180 (the `/connect?request=` redirect)
|
||||
- ../fonoteka.go/plugins/golem15/fonoteka/controllers/api/oauth_consent_controller.go 1-140 (the MCP consent contract already proven in another application: PendingRequest, submitted ∩ requested, IssueCode, DenyPending)
|
||||
- ../sm-oauthserver-plugin/controllers/authorizations.go 98-150 (AuthorizationsDestroy, revoke) and classes/cascade.go (OnUserDeleting, OnUserDeactivating, purge)
|
||||
- summercms.go/modules/pact/mcp.go (MCPLinkedBackendResolver, LinkedBackendUser, MCPSubjectChanged, MCPSubjectRevoked, MCPSubjectDeleted)
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/login.vue (page shape, useDemoAuth, the `next` redirect rule), app/composables/useDemoAuth.ts (token cookie, login, logout, formErrors), i18n/locales/en.json `auth` block (key style), nuxt.config.ts 85-120 (runtimeConfig and the dev proxy of API paths to Go)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Open Question 7", § "Pattern 7" step 2-3, Security Domain row "Consent phishing"
|
||||
</read_first>
|
||||
<action>
|
||||
oauthserver consent (P-16): `controllers.MCPConsentShow(app, srv)` and `controllers.MCPConsentDecide(app, srv)` in `mcp_consent_api.go`, mounted inside the `MCPEnabled` block of `Routes` as `r.GroupRaw("/", surf.Use("jwt.auth", authorize), ...)` with `g.Get("/oauth/mcp/requests/{request}", ...)` and `g.Post("/oauth/mcp/requests/{request}", ...)`. Show: `srv.PendingRequest(ctx, id, userID)`; `ErrPendingNotFound` → 404 `request_not_found`; body per P-16 where `backend_admin` is filled from `app.Lookup[pact.MCPLinkedBackendResolver]()` → `LinkedBackendUser(ctx, userID)` only when `backend` ∈ `view.ScopesRequested` and the resolver answers true, else JSON null. Decide: body up to 16 KiB `{decision, scopes}`; granted = (submitted ∩ requested, or requested when `scopes` is absent) minus `backend` when no link; `allow` → `srv.IssueCode(ctx, id, userID, granted, nil)` (`ErrNoGrantableScopes` → 422 `no_grantable_scopes`), else `srv.DenyPending`; answer `{redirect_uri}`; `writeJSON` keeps `Cache-Control: no-store, private`. Revoked events (D-26): `classes/subject_events.go` `FireSubjectChanged(ctx, app, "user", userID, kind)`; call with `pact.MCPSubjectRevoked` from `revoke` (authorizations destroy) and with `pact.MCPSubjectDeleted` from `OnUserDeleting` and `OnUserDeactivating` after the purge. README: the two routes (Routes table and the MCP paragraph), the `backend_admin` field, the events. Lang: none needed server-side (the page translates); add keys only if a server message is introduced. Smoke `TestMCPConsentSmoke` (Postgres): a pending MCP request for `read write backend`: show for a user without a link has `backend_admin: null`; decide allow grants `read write` only (the issued code's scopes exclude backend); with a link (seed through `*userclasses.BackendLinks`.SetLink, the plugin now requires the plan-03 user plugin) show carries the admin's login and name and decide grants `backend` too; deny answers an `error=access_denied` redirect; an unknown request is 404; a user other than the request's owner gets 404; `DELETE /oauth/authorizations/{client_id}` fires a `revoked` event (test listener).
|
||||
|
||||
vue-demo-app pages (in `../sm-demo-app/vue-demo-app`): `app/pages/connect.vue` reads `request` from the query; when not `loggedIn` it `navigateTo('/login?next=' + encodeURIComponent('/connect?request=' + request))` (the login page already honours a same-origin `next`); it fetches `GET /oauth/mcp/requests/{request}` with the `Authorization: Bearer` from `useDemoAuth().token`, renders the client name and redirect host, the requested scopes as a list with one explanatory line each (`connect.scope.read`, `.write`, `.ai`, `.offline_access`, `.backend`), and when `backend_admin` is present the line `connect.actAsAdmin` with the admin's name; when `backend` is requested without a link it shows `connect.noLinkedAdmin` (backend access will not be granted); Allow and Deny buttons POST the decision (Allow sends the full requested scope list) and `navigateTo(redirect_uri, { external: true })`; 404/410 show `connect.expired`; `useSeoMeta({ robots: 'noindex' })`. `app/pages/link-admin.vue` reads `code`; `GET /_user/api/v1/backend-link/{code}` → shows `linkAdmin.question` with the admin's name and the expiry; when not logged in, a button to `/login?next=/link-admin?code=...`; when logged in, a Confirm button POSTs `/_user/api/v1/backend-link/confirm` with the bearer; on `409 stale_session` it calls `logout()` and sends the user to `/login?next=...` with the message `linkAdmin.signInAgain` (D-05 fresh sign-in); `already_linked` and 404 show their messages; success shows `linkAdmin.done` with the admin's login; `robots: noindex`. i18n keys under `connect` and `linkAdmin` in en.json and pl.json. `npm --prefix ../sm-demo-app/vue-demo-app run test` (vitest) and `npm --prefix ../sm-demo-app/vue-demo-app run build` must pass; add a vitest case per page only if the demo's existing tests cover pages (otherwise rely on the build and the manual check in Task 5).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./... && go -C ../sm-oauthserver-plugin test -count=1 -run '^TestMCPConsentSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPConsentSmoke' && npm --prefix ../sm-demo-app/vue-demo-app run test && npm --prefix ../sm-demo-app/vue-demo-app run build</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the Go output, a vitest summary that is not all passing, or a Nuxt build error</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "/oauth/mcp/requests/{request}" ../sm-oauthserver-plugin/routes.go` prints 2 and both lines sit inside the `MCPEnabled` block (`awk '/MCPEnabled/,/^\t}/' ../sm-oauthserver-plugin/routes.go | grep -c "mcp/requests"` prints 2)
|
||||
- `grep -c "func MCPConsentShow(\|func MCPConsentDecide(" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints 2 and `grep -c "backend_admin" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints at least 1
|
||||
- `grep -c "MCPLinkedBackendResolver" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints at least 1
|
||||
- `grep -c "FireSubjectChanged(" ../sm-oauthserver-plugin/controllers/authorizations.go ../sm-oauthserver-plugin/classes/cascade.go` prints a non-zero count per file
|
||||
- `test -f ../sm-demo-app/vue-demo-app/app/pages/connect.vue && test -f ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue`
|
||||
- `grep -c "oauth/mcp/requests" ../sm-demo-app/vue-demo-app/app/pages/connect.vue` prints at least 2 and `grep -c "backend-link" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints at least 2
|
||||
- `grep -c "stale_session" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints 1 and `grep -c "noindex" ../sm-demo-app/vue-demo-app/app/pages/connect.vue ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints 1 per file
|
||||
- `grep -c '"connect"' ../sm-demo-app/vue-demo-app/i18n/locales/en.json ../sm-demo-app/vue-demo-app/i18n/locales/pl.json` prints 1 per file and the same for `"linkAdmin"`
|
||||
- `TestMCPConsentSmoke` prints `--- PASS` on a Docker host
|
||||
</acceptance_criteria>
|
||||
<done>The MCP consent is served as JSON with the linked-admin line and the backend scope is granted only with a link; grants and users that go away fire events; the demo site has the consent and link-proof pages.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Journal's backend tools and prompt, the optionalBackendPrincipal fix, and the end-to-end case as the linked admin</name>
|
||||
<files>../sm-journal-plugin/mcp.go, ../sm-journal-plugin/controllers/api/auth.go, ../sm-journal-plugin/README.md, ../sm-journal-plugin/go.mod, ../sm-journal-plugin/go.sum, ../sm-journal-plugin/mcp_smoke_test.go, ../sm-demo-app/mcp_e2e_test.go, ../sm-demo-app/plugins/golem15/journal, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum</files>
|
||||
<read_first>
|
||||
- ../sm-journal-plugin/routes.go (the exact method+pattern of every bind target and the `slug`/`id` Where constraints), controllers/api/auth.go 60-100 (optionalBackendPrincipal, requireBackendPrincipal, permission constants), controllers/api/posts.go (Index query parameters, Store and Update body keys from posts_helpers.go: grep `body["` to list the accepted keys), plugin.go 125-150 (the journal-api bucket keyed by backend principal)
|
||||
- summercms.go/modules/pact/mcp.go (MCPTool, MCPPrompt, the tag mapping rules in the doc comments) and modules/pier/example_mcp_test.go (the acme.blog example from plan 02)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Code Examples: Journal backend tools", § "Pitfall 6" (raw body forwarding; mark optional fields with omitempty or pointers), § "Pattern 6" (the optionalBackendPrincipal fix)
|
||||
- ../sm-demo-app/mcp_e2e_test.go as left by Task 1; ../sm-demo-app/plugins/golem15/user (the plan-03 plugin: classes.BackendLinks.SetLink for seeding a link in the test)
|
||||
</read_first>
|
||||
<action>
|
||||
Journal `mcp.go` (P-17): `(*Plugin) MCP()` declares the seven tools and one prompt. Input structs live in `mcp.go` with `jsonschema` descriptions: list posts `{ Page int `query:"page"`; PerPage int `query:"per_page"`; Search string `query:"search"`; Category string `query:"category"`; Tag string `query:"tag"`; Published *bool `query:"published"`; Sort string `query:"sort"` }` (match the names Index reads); show `{ Slug string `path:"slug"` }`; categories and tags `struct{}`; create `{ Title string; Slug string `json:"slug,omitempty"`; Content string; Excerpt string `json:"excerpt,omitempty"`; Published *bool `json:"published,omitempty"`; Categories []uint `json:"categories,omitempty"`; Tags []string `json:"tags,omitempty"` ... exactly the keys Store accepts }`; update `{ ID uint `path:"id"` plus the create fields all optional (pointers or omitempty, Pitfall 6) }`; delete `{ ID uint `path:"id"` }`. Every tool: `Guard: "backend"`, `Permissions: []string{permAccessPosts}` (export the constant or duplicate the string in mcp.go; do not change auth.go's constants), static Title and Description; delete sets `Destructive` true explicitly. Prompt `draft_post`: arguments `topic` (required), `tone`; `Render` returns one `user` message that asks for a post draft on the topic in the tone, with the site's style notes, and tells the agent to call `journal_create_post` with `published` false; `Guard: "backend"`, `Permissions: [permAccessPosts]`.
|
||||
|
||||
auth.go: `optionalBackendPrincipal` drops the `!hasBearer(r)` short-circuit (keep the nil check); `ResolveBackend` already answers `ErrUnauthenticated` for a missing bearer, so anonymous behaviour is identical and a dispatched request sees the marker (D-17). Nothing else in auth.go changes. `go.mod`: require the plan-02 framework tag; `go mod tidy` (the plugin's own go.work replaces the framework with `../summercms.go`). README: Features (the MCP tools and prompt, the guard and permission), a short "MCP tools" section listing the exposed names. Smoke `TestJournalMCPSmoke` (-short, no Docker): `MCP()` lists exactly the seven names and the prompt; every tool's Method+Path matches a route the plugin registers (build a `surf.BuildRouter` with the plugin and compare); `optionalBackendPrincipal` with a request carrying a backend dispatch marker returns a request whose context holds the principal, and with no bearer and no marker returns the request unchanged.
|
||||
|
||||
Demo e2e extension (`mcp_e2e_test.go`, Journal submodule moved to the new commit per P-18): seed an admin with `golem15.journal.access_posts` (role or override) and link the frontend user to it through `*userclasses.BackendLinks`.SetLink; mint a token with scopes `read write backend`: `ListTools` now contains `journal_create_post` and `journal_list_posts`; `CallTool("journal_create_post", {title, content, published: false})` answers `isError false` and the post row's author is the admin's id; `CallTool("journal_show_post", {slug})` returns it (a draft is visible to the editor through the marker); a token with `read write` only (no `backend`) lists no `journal_` tool and a call to `journal_create_post` is refused; after `RemoveLink` the next `ListTools` has no `journal_` tool. The unlink-removes-tools and revoke matrix is completed in plan 05; here one unlink case suffices.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 -short ./... && go -C ../sm-journal-plugin test -count=1 -short -run '^TestJournalMCPSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestJournalMCPSmoke' && (cd ../sm-demo-app && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd')</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or either PASS line is absent (SKIP without Docker counts as absent for TestMCPEndToEnd)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "Name: *\"\(list_posts\|show_post\|list_categories\|list_tags\|create_post\|update_post\|delete_post\|draft_post\)\"" ../sm-journal-plugin/mcp.go` prints 8
|
||||
- `grep -c "golem15.journal.access_posts\|permAccessPosts" ../sm-journal-plugin/mcp.go` prints at least 8
|
||||
- `grep -c "hasBearer(r)" ../sm-journal-plugin/controllers/api/auth.go` prints 0 inside optionalBackendPrincipal (`awk '/^func optionalBackendPrincipal/,/^}/' ../sm-journal-plugin/controllers/api/auth.go | grep -c hasBearer` prints 0) while `func hasBearer` still exists
|
||||
- `git -C ../sm-journal-plugin diff ffa2c8f -- routes.go | wc -l` prints 0 (no route changed)
|
||||
- `grep -c "git.golem15.com/golem15/summercms <plan-02 tag>" ../sm-journal-plugin/go.mod` prints 1 (substitute the recorded tag)
|
||||
- `grep -c "journal_create_post" ../sm-demo-app/mcp_e2e_test.go` prints at least 2
|
||||
- Both named tests print `--- PASS` (the e2e on a Docker host)
|
||||
</acceptance_criteria>
|
||||
<done>Journal exposes its post tools and a prompt to linked admins only, list and show see the dispatched principal, and the demo proves a frontend sign-in with a link and the backend scope creates a post as the admin while unlinking removes the tools.</done>
|
||||
</task>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking-human">
|
||||
<name>Task 4: Give the go-ahead for every push of Task 5: tag and push oauthserver and Journal, push vue-demo-app</name>
|
||||
<decision>One go-ahead covering exactly the three pushes Task 5 performs, in three repositories: (1) sm-oauthserver-plugin (backend scope, oas_at_ verifier, MCP consent JSON, revoked events) — `git push origin master --tags` with its new tag; (2) sm-journal-plugin (MCP tools and prompt, optionalBackendPrincipal fix) — `git push origin main --tags` with its new tag; (3) vue-demo-app (the `/connect` consent page, the `/link-admin` proof page, the `connect.*` and `linkAdmin.*` i18n keys from Task 2) — `git -C ../sm-demo-app/vue-demo-app push origin master`, no tag. Both plugins are pinned to the plan-02 framework tag. The demo's three pointer bumps are local commits in sm-demo-app; sm-demo-app itself is neither pushed nor deployed in this plan (both are recorded in deferred-items.md for a separate go-ahead).</decision>
|
||||
<context>Both plugin releases are additive (plan 05's gate proves no removed export since d31f8e7 and ffa2c8f). Proposed versions (P-20): oauthserver v0.1.2, Journal v0.2.3. The demo then pins both tags in two commits (go.mod, go.sum, submodule pointer each) and the pushed vue-demo-app commit in a third. Pre-checks before asking: clean trees in both plugin repos and in `../sm-demo-app/vue-demo-app`, `go vet ./... && go test -count=1 ./...` on Docker in each plugin, `npm --prefix ../sm-demo-app/vue-demo-app run test` and `run build` green, READMEs updated, the demo e2e green with the submodules at the exact commits to be tagged and pushed. The checkpoint message lists the three repositories, their branches and the two versions so the answer names every push (CLAUDE.md: no push, tag or deploy without the user's go-ahead).</context>
|
||||
<options>
|
||||
<option id="tag-both">
|
||||
<name>Tag oauthserver v0.1.2 and Journal v0.2.3 now and push all three repositories</name>
|
||||
<pros>The demo can pin released versions and a pushed vue-demo-app commit; plan 05's consumers stage runs against tags</pros>
|
||||
<cons>A later fix needs patch tags</cons>
|
||||
</option>
|
||||
<option id="hold">
|
||||
<name>Hold both tags and the vue-demo-app push</name>
|
||||
<pros>Review the two plugin diffs and the two pages first</pros>
|
||||
<cons>The demo keeps pointing at unreleased, unpushed commits until you continue</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer tag-both (optionally with other version numbers; tag-both covers the vue-demo-app push as well) or hold</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Release both plugins, pin them in the demo, document nginx and deploy, and hand the demo to a real MCP client</name>
|
||||
<reversibility rating="one-way">Pushed plugin tags are pinned by the demo and announced; the pushed vue-demo-app commit publishes the consent and link pages; the nginx locations open the MCP paths on the public demo once deployed.</reversibility>
|
||||
<precondition>The Task 4 checkpoint answered tag-both (or named versions); `git -C ../sm-oauthserver-plugin status --short`, `git -C ../sm-journal-plugin status --short` and `git -C ../sm-demo-app/vue-demo-app status --short` are empty; `git -C ../sm-demo-app status --short` shows only this plan's files</precondition>
|
||||
<files>../sm-oauthserver-plugin/go.mod, ../sm-oauthserver-plugin/go.sum, ../sm-journal-plugin/go.mod, ../sm-journal-plugin/go.sum, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum, ../sm-demo-app/plugins/golem15/oauthserver, ../sm-demo-app/plugins/golem15/journal, ../sm-demo-app/vue-demo-app, ../sm-demo-app/deploy/nginx/demo.summercms.io.conf, ../sm-demo-app/DEPLOY.md, ../sm-demo-app/config/http.yaml, .planning/phases/19.7-generic-mcp-module/deferred-items.md</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf (the allow-listed Go locations 90-200; copy the `/_demo/` block's proxy settings for the new locations; the `/` fallback to Nuxt)
|
||||
- ../sm-demo-app/DEPLOY.md § "Overview" 12-50 (which paths reach Go), § "Build" 325-352, § "Release" 353-414, § "Verify", § "Secrets"; ../sm-demo-app/scripts/check-deploy.sh (nginx -t, route checks of deploy/)
|
||||
- ../sm-demo-app/config/http.yaml (cors.paths: the MCP path needs no CORS entry since pier handles Origin itself; confirm nothing else is required)
|
||||
- .planning/notes/core-plugins-own-repos.md and CLAUDE.md § "Sibling repositories"
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md § "Manual-Only Verifications" (the real-client row)
|
||||
- summercms.go/docs/services/mcp.md § Operations (plan 02)
|
||||
</read_first>
|
||||
<action>
|
||||
Releases: in each plugin repo `go.mod` already requires the plan-02 tag (Tasks 1-3); run the pre-checks, write the annotated tag message, `git tag -a <version>` and `git push origin <branch> --tags` (oauthserver master, Journal main). Then `git -C ../sm-demo-app/vue-demo-app push origin master` for the Task 2 commit with the `/connect` and `/link-admin` pages (no tag). These three pushes are exactly the ones the Task 4 go-ahead named; no other repository is pushed by this task. Demo pins, three local commits in sm-demo-app: `chore: bump oauthserver to <v>` (go.mod require, go.sum, submodule at the tag), `chore: bump journal to <v>`, `chore: bump vue-demo-app (MCP consent and link pages)` (the submodule at the pushed commit). sm-demo-app itself is not pushed and not deployed here; both wait for the user's go-ahead and go to deferred-items.md below. Verify `go build -tags summercms_mcp ./... && go test -count=1 -short ./...` in the demo after each pin.
|
||||
|
||||
nginx (`deploy/nginx/demo.summercms.io.conf`): add Go locations `location = /mcp` (proxy with `proxy_buffering off`, `proxy_read_timeout 1h`, `proxy_http_version 1.1`, `chunked_transfer_encoding on` for SSE), `location ^~ /.well-known/oauth-protected-resource`, `location = /.well-known/oauth-authorization-server`, and `location ^~ /oauth/mcp/` (authorize, register, token and the consent JSON), each with the same `proxy_pass` and headers as the existing Go blocks (the ACME location stays first); run `scripts/check-deploy.sh`. DEPLOY.md: a new section "MCP endpoint" after Realtime: what is mounted, the `summercms_mcp` build tag already in `summer.yaml`, the `.env` keys (`SUMMER_MCP__RESOURCE=https://demo.summercms.io/mcp`, `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE` the same, `SUMMER_MCP__SESSIONS__STORE=memory` with the Redis alternative per P-19), the nginx install step (reuse the "When deploy/nginx/... changed" instructions), how an editor connects (`https://demo.summercms.io/mcp`, OAuth sign-in, `/connect`, linking an admin from My account), and a smoke (`curl -sS https://demo.summercms.io/.well-known/oauth-protected-resource/mcp`). Update the Overview sentence that says `/oauth` and `/.well-known` are not routed to Go. Record the unresolved operational items in `.planning/phases/19.7-generic-mcp-module/deferred-items.md` (framework repo): pushing sm-demo-app's three pointer commits and the deploy itself (each needs the user's go-ahead), and Redis on rome if a second instance is ever added.
|
||||
|
||||
Local hand-off for the manual check: build the demo (`summer build` in the demo), start it against the compose Postgres with `.env` values for the resource URLs pointing at `http://127.0.0.1:8097/mcp`, start the Nuxt site (`npm --prefix ../sm-demo-app/vue-demo-app run dev`), seed through `demo:seed`, create a frontend user and an admin with Journal access, and leave both processes running for the human check below. Stop them after the check.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>git -C ../sm-oauthserver-plugin describe --tags --exact-match HEAD && git -C ../sm-journal-plugin describe --tags --exact-match HEAD && (cd ../sm-demo-app && bash scripts/check-deploy.sh && go build -tags summercms_mcp ./... && go test -count=1 -short ./... && git diff --quiet HEAD -- go.mod go.sum plugins/golem15/oauthserver plugins/golem15/journal vue-demo-app)</automated>
|
||||
<fails_when>non-zero exit: a plugin HEAD is not tagged, check-deploy reports an nginx or route problem, the demo fails to build or test, or a pin is uncommitted</fails_when>
|
||||
<human-check>With the demo and site running locally: add `http://127.0.0.1:8097/mcp` to an MCP client (Claude Desktop or Claude Code), complete the OAuth sign-in on the `/connect` page as the frontend user (requesting `backend`), see only `user_me`; in the admin's My account click "Link frontend account", finish on `/link-admin` with a fresh sign-in, reconnect (new consent shows "also act as admin <name>"), see the `journal_` tools, create a draft post and find it in the admin; unlink and confirm the Journal tools disappear.</human-check>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `git -C ../sm-oauthserver-plugin describe --tags --exact-match HEAD` and `git -C ../sm-journal-plugin describe --tags --exact-match HEAD` print the chosen versions and `git ls-remote --tags origin` in each repo lists them
|
||||
- `grep -c "sm-oauthserver-plugin <v>" ../sm-demo-app/go.mod` prints 1 and `grep -c "sm-journal-plugin <v>" ../sm-demo-app/go.mod` prints 1 (substitute the chosen versions)
|
||||
- `grep -c "location = /mcp\|oauth-protected-resource\|oauth-authorization-server\|location ^~ /oauth/mcp/" ../sm-demo-app/deploy/nginx/demo.summercms.io.conf` prints at least 4 and `grep -c "proxy_buffering off" ../sm-demo-app/deploy/nginx/demo.summercms.io.conf` prints at least 1
|
||||
- `grep -c "## MCP endpoint" ../sm-demo-app/DEPLOY.md` prints 1 and `grep -c "SUMMER_MCP__RESOURCE" ../sm-demo-app/DEPLOY.md` prints at least 1
|
||||
- `(cd ../sm-demo-app && bash scripts/check-deploy.sh)` exits 0
|
||||
- `test -f .planning/phases/19.7-generic-mcp-module/deferred-items.md`
|
||||
</acceptance_criteria>
|
||||
<done>Both plugins are released and pinned by the demo, the deploy path for the MCP endpoint is documented and checked, and a real MCP client has been connected locally through OAuth, the link and the backend scope.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**sm-oauthserver-plugin** (`git.golem15.com/golem15/sm-oauthserver-plugin`): `classes.MCPTokenVerifier` (published as `pact.MCPTokenVerifier`), `controllers.MCPConsentShow`, `controllers.MCPConsentDecide`, `classes.FireSubjectChanged`; routes `GET|POST /oauth/mcp/requests/{request}` (jwt.auth, throttle:oauth-authorize); the `backend` scope in the MCP server's `ScopesSupported`; consent body field `backend_admin`; release v0.1.2 (proposed)
|
||||
**sm-journal-plugin** (`git.golem15.com/golem15/sm-journal-plugin`): `mcp.go` with `(*Plugin) MCP()`; tools `journal_list_posts`, `journal_show_post`, `journal_list_categories`, `journal_list_tags`, `journal_create_post`, `journal_update_post`, `journal_delete_post`; prompt `journal_draft_post`; `optionalBackendPrincipal` honours the marker; release v0.2.3 (proposed)
|
||||
**sm-demo-app**: `summer.yaml` `build.tags: [summercms_mcp]`; `config/mcp.yaml`, `config/golem15.oauthserver.yaml`; regenerated `plugins.gen.go`, `main.go`; `mcp_e2e_test.go` (`TestMCPEndToEnd`, tagged); nginx locations `/mcp`, `/.well-known/oauth-protected-resource*`, `/.well-known/oauth-authorization-server`, `/oauth/mcp/`; DEPLOY.md "MCP endpoint"; pointer bumps for oauthserver, journal, vue-demo-app
|
||||
**vue-demo-app**: pages `/connect` (`app/pages/connect.vue`) and `/link-admin` (`app/pages/link-admin.vue`); i18n keys `connect.*`, `linkAdmin.*` (en, pl)
|
||||
**Env keys documented**: `SUMMER_MCP__RESOURCE`, `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE`, `SUMMER_MCP__SESSIONS__STORE`, `SUMMER_REDIS__URL`
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| MCP client to the authorization server | DCR clients request scopes including `backend`; tokens are minted and later presented at `/mcp` |
|
||||
| browser to the consent and link pages | the signed-in frontend user's decisions and the one-shot link code |
|
||||
| pier to the oauthserver verifier | every `/mcp` request's bearer is judged here |
|
||||
| internet to nginx to Go | the MCP paths become public on the demo |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-30 | Spoofing | audience confusion at the verifier | high | mitigate | Only `oas_at_` tokens pass the prefix gate; the row's client must exist with `kind = mcp` and not be revoked; an OIDC token or a foreign-kind client's token is `ErrMCPTokenInvalid` (`TestMCPTokenVerifierSmoke`) |
|
||||
| T-19.7-31 | Elevation | consent phishing for the backend scope | high | mitigate | The consent page shows client name, redirect host and the "also act as admin <name>" line only with a verified link; `backend` is granted only when a link exists at consent (A8); the scope is visible and revocable per grant (`TestMCPConsentSmoke`) |
|
||||
| T-19.7-32 | Elevation | consent decided for another user's request | medium | mitigate | `PendingRequest`/`IssueCode`/`DenyPending` resolve the request for the acting JWT principal only (`lookupOwnedPending`); a foreign user gets 404; decisions are POST behind `jwt.auth` with `no-store` answers |
|
||||
| T-19.7-33 | Elevation | submitted scopes beyond the request | medium | mitigate | granted = submitted ∩ requested (∩ the allow-list wristband already applied), minus `backend` without a link; an empty grant is 422 `no_grantable_scopes` |
|
||||
| T-19.7-34 | Spoofing | superuser reach through an agent (D-22) | high | mitigate | The backend principal is the admin's real principal (superuser included) by decision; the D-20 ceiling and `backend` scope cap it; every call is audited with admin_id and client_id; plan 05's security review weighs an optional superuser refusal switch and records the verdict |
|
||||
| T-19.7-35 | Information Disclosure | revoked grant keeps a live session | medium | mitigate | `AuthorizationsDestroy` and the user cascade fire `revoked`/`deleted` events that end sessions on every instance; the verifier refuses the revoked token on the very next request regardless |
|
||||
| T-19.7-36 | Tampering | partial update tools zeroing fields | medium | mitigate | Update input fields are pointers or `omitempty`; pier forwards the agent's raw JSON minus path keys, so Journal's key-presence checks see only sent keys (Pitfall 6) |
|
||||
| T-19.7-37 | Denial of Service | public `/mcp` and SSE through nginx | medium | mitigate | `mcp.throttle` inline limiter, idle TTL and per-binding cap in pier; nginx `proxy_read_timeout` bounded; only the listed MCP paths are opened |
|
||||
| T-19.7-38 | Spoofing | open redirect from the consent page | low | mitigate | The page navigates only to the `redirect_uri` the server returns from `IssueCode`/`DenyPending`, which wristband built from the client's registered URI; the `next` parameter stays same-origin as on the login page |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./...`; Docker: `go -C ../sm-oauthserver-plugin test -count=1 ./...` with `TestMCPTokenVerifierSmoke` and `TestMCPConsentSmoke` passing
|
||||
- `go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 -short ./...` with `TestJournalMCPSmoke` passing
|
||||
- `(cd ../sm-demo-app && go vet ./... && go test -count=1 -short ./... && go build -tags summercms_mcp ./...)`; Docker: `go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v .` passing
|
||||
- `npm --prefix ../sm-demo-app/vue-demo-app run test && npm --prefix ../sm-demo-app/vue-demo-app run build`
|
||||
- `(cd ../sm-demo-app && bash scripts/check-deploy.sh)`
|
||||
- The human check of Task 5 with a real MCP client
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- SC-4 is demonstrated end to end in the demo by `TestMCPEndToEnd` and by the real-client check: one OAuth sign-in, a verified link, the backend scope, Journal tools as the admin, removal on unlink
|
||||
- oauthserver and Journal diffs against d31f8e7 and ffa2c8f remove no route, export, scope or payload field
|
||||
- The demo without the tag or with `mcp.enabled` false behaves as before
|
||||
- Planner decisions P-16..P-20 are implemented as written and named in the SUMMARY
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-04-SUMMARY.md` (framework repo, planning docs commit) when done, recording the plugin versions and the demo pins.
|
||||
</output>
|
||||
245
.planning/phases/19.7-generic-mcp-module/19.7-04-SUMMARY.md
Normal file
245
.planning/phases/19.7-generic-mcp-module/19.7-04-SUMMARY.md
Normal file
@@ -0,0 +1,245 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 04
|
||||
subsystem: oauthserver-journal-demo
|
||||
status: complete
|
||||
tags: [sm-oauthserver-plugin, sm-journal-plugin, sm-demo-app, vue-demo-app, mcp, oauth, consent, backend-scope, release, nginx]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-02
|
||||
provides: modules/pier (MCP endpoint, guards, dispatch marker, subject-event fan-out) in framework v0.4.4
|
||||
- phase: 19.7-03
|
||||
provides: sm-user-plugin v0.1.10 (verified backend link, pact.MCPLinkedBackendResolver, user guard, user_me)
|
||||
provides:
|
||||
- sm-oauthserver-plugin v0.1.2 (tagged on 8bbec72, pushed): backend scope on the MCP server, classes.MCPTokenVerifier published as pact.MCPTokenVerifier, GET|POST /oauth/mcp/requests/{request} consent JSON with backend_admin, classes.FireSubjectChanged / FireSubjectChangedAfterCommit (revoked, deleted)
|
||||
- sm-journal-plugin v0.2.3 (tagged on 4ab94da, pushed): seven journal_ tools and the journal_draft_post prompt (guard backend, golem15.journal.access_posts); optionalBackendPrincipal honours the dispatch marker
|
||||
- vue-demo-app 21a22b6 (pushed): /connect consent page, /link-admin link-proof page, connect.* and linkAdmin.* (en, pl), dev proxy for the MCP paths
|
||||
- sm-demo-app (local, not pushed): MCP endpoint at /mcp behind the summercms_mcp tag, TestMCPEndToEnd as frontend user and as linked admin, pins oauthserver v0.1.2 / journal v0.2.3 / vue-demo-app 21a22b6, nginx MCP locations, check-deploy MCP rules, DEPLOY.md "MCP endpoint"
|
||||
affects: [19.7-05 unit tests, revoke matrix and security review, the demo deploy (needs the user's go-ahead), framework v0.5.0 at phase completion]
|
||||
|
||||
actuals:
|
||||
tokens: 28539 # chars/4 over the added lines of all five repos' diffs
|
||||
tasks: 5
|
||||
commits: 11 # across repos, see commit_ledger; the SUMMARY commit is extra
|
||||
commit_ledger:
|
||||
sm-oauthserver-plugin: {before: d31f8e7, after: 8bbec72, count: 2}
|
||||
sm-journal-plugin: {before: ffa2c8f, after: 4ab94da, count: 1}
|
||||
vue-demo-app: {before: f397df2, after: 21a22b6, count: 1}
|
||||
sm-demo-app: {before: 985af539b9c15019bbbe0fcc3b5dc74c76057774, after: c21ae9dc317f73863494f412a81889bf346d553a, count: 6}
|
||||
summercms.go: {before: 29ba9a28cba13e802e13635ba7d3cae3c3a3d9e0, after: 9550fe0a9f566d943d515bc47928725feb986317, count: 1}
|
||||
plan_head_before: 29ba9a28cba13e802e13635ba7d3cae3c3a3d9e0
|
||||
plan_head_after: 9550fe0a9f566d943d515bc47928725feb986317
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "MCP access tokens (oas_at_) are verified by the plugin that minted them and published as pact.MCPTokenVerifier; the verifier refuses revoked, expired, non-mcp, inactive or revoked clients"
|
||||
- "The backend scope is granted at consent only when the frontend user has a verified admin link; granted = submitted ∩ requested"
|
||||
- "Subject events from grant revocation and the user cascade fire as *pact.MCPSubjectChanged after commit"
|
||||
- "A WinterCMS-style optional principal reads the MCP dispatch marker instead of short-circuiting on a missing bearer"
|
||||
- "Streamable HTTP behind nginx: exact location, proxy_buffering off, 1h read/send timeouts"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-oauthserver-plugin/classes/mcp_verifier.go
|
||||
- ../sm-oauthserver-plugin/classes/subject_events.go
|
||||
- ../sm-oauthserver-plugin/controllers/mcp_consent_api.go
|
||||
- ../sm-oauthserver-plugin/mcp_verifier_smoke_test.go
|
||||
- ../sm-oauthserver-plugin/mcp_consent_smoke_test.go
|
||||
- ../sm-journal-plugin/mcp.go
|
||||
- ../sm-journal-plugin/mcp_smoke_test.go
|
||||
- ../sm-journal-plugin/controllers/api/optional_principal_test.go
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/connect.vue
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue
|
||||
- ../sm-demo-app/config/mcp.yaml
|
||||
- ../sm-demo-app/config/env/production/golem15.oauthserver.yaml
|
||||
- ../sm-demo-app/mcp_e2e_test.go
|
||||
- ../sm-demo-app/internal/demotest/mcp_tag_on.go
|
||||
- ../sm-demo-app/internal/demotest/mcp_tag_off.go
|
||||
modified:
|
||||
- ../sm-oauthserver-plugin/servers.go
|
||||
- ../sm-oauthserver-plugin/plugin.go
|
||||
- ../sm-oauthserver-plugin/routes.go
|
||||
- ../sm-oauthserver-plugin/classes/cascade.go
|
||||
- ../sm-oauthserver-plugin/controllers/authorizations.go
|
||||
- ../sm-oauthserver-plugin/README.md
|
||||
- ../sm-journal-plugin/controllers/api/auth.go
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/en.json
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/pl.json
|
||||
- ../sm-demo-app/vue-demo-app/nuxt.config.ts
|
||||
- ../sm-demo-app/summer.yaml
|
||||
- ../sm-demo-app/config/golem15.oauthserver.yaml
|
||||
- ../sm-demo-app/scripts/build.sh
|
||||
- ../sm-demo-app/scripts/dev.sh
|
||||
- ../sm-demo-app/scripts/check-all.sh
|
||||
- ../sm-demo-app/scripts/check-deploy.sh
|
||||
- ../sm-demo-app/boot_test.go
|
||||
- ../sm-demo-app/realtime_test.go
|
||||
- ../sm-demo-app/sociallogin_test.go
|
||||
- ../sm-demo-app/go.mod
|
||||
- ../sm-demo-app/go.sum
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
|
||||
- ../sm-demo-app/DEPLOY.md
|
||||
- .planning/phases/19.7-generic-mcp-module/deferred-items.md
|
||||
|
||||
key-decisions:
|
||||
- "Released oauthserver v0.1.2 and Journal v0.2.3 (tag-both); pushed vue-demo-app master; sm-demo-app stays local until the user's go-ahead"
|
||||
- "The demo's resource indicator comes from app.url + mcp.path and the production overlay, not from .env; .env keys are documented as overrides only"
|
||||
- "nginx opens exactly /mcp, the two MCP metadata paths and /oauth/mcp/; /oauth/authorize and OIDC discovery stay closed, enforced by check-deploy.sh"
|
||||
|
||||
requirements-completed: [SC-1, SC-3, SC-4, D-02, D-05, D-15, D-16, D-17, D-18, D-21, D-22, D-23, D-26, D-30, D-31, D-33, D-35, D-36]
|
||||
|
||||
duration: ~50min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 04: oauthserver and Journal on the MCP endpoint, demo wiring Summary
|
||||
|
||||
**The demo's own OAuth server now issues `oas_at_` tokens that pier verifies, with a `backend` scope granted only through a verified admin link. Journal exposes seven post tools and a draft prompt to linked admins. The demo site has `/connect` and `/link-admin`. Plugin releases oauthserver v0.1.2 and Journal v0.2.3 are pushed; the demo pins them and documents nginx and the deploy for `/mcp`.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 50 minutes (12:27 to 13:20, 2026-10-23, including the Task 4 checkpoint wait)
|
||||
- **Tasks:** 5 of 5 (Task 4 was the go-ahead checkpoint, answered tag-both)
|
||||
- **Repositories touched:** 5 (sm-oauthserver-plugin, sm-journal-plugin, vue-demo-app, sm-demo-app, summercms.go planning)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- An MCP client signs in on the demo's own authorization server (DCR, PKCE, `/connect` consent) and calls `user_me` through `/mcp` with an `oas_at_` token (Task 1, `TestMCPEndToEnd`)
|
||||
- The consent is JSON for the site's `/connect` page. It shows the linked admin and grants `backend` only with a link. Revoking a grant or deleting a user fires `revoked` or `deleted` subject events after commit (Task 2)
|
||||
- Journal's `journal_list_posts`, `journal_show_post`, `journal_list_categories`, `journal_list_tags`, `journal_create_post`, `journal_update_post`, `journal_delete_post` and the `journal_draft_post` prompt are listed only for a linked admin with `golem15.journal.access_posts` and a token carrying `backend`. A created draft is authored by the admin, and unlinking removes the tools (Task 3)
|
||||
- Releases pushed: sm-oauthserver-plugin v0.1.2 (annotated, on 8bbec72), sm-journal-plugin v0.2.3 (annotated, on 4ab94da), vue-demo-app master at 21a22b6 (Task 5)
|
||||
- The demo pins all three. It has nginx locations for `/mcp` (unbuffered, 1h timeouts), `/.well-known/oauth-protected-resource*`, `/.well-known/oauth-authorization-server` and `/oauth/mcp/`, `check-deploy.sh` enforces exactly that allow-list, and DEPLOY.md has a new "MCP endpoint" section (Task 5)
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1: Tracer, an oas_at_ token runs user_me through /mcp in the tagged demo:** `116df7f` (oauthserver feat), `44cac13` (sm-demo-app feat)
|
||||
2. **Task 2: MCP consent JSON, revoked/deleted events, /connect and /link-admin:** `8bbec72` (oauthserver feat), `21a22b6` (vue-demo-app feat)
|
||||
3. **Task 3: Journal MCP tools and prompt, the optionalBackendPrincipal fix, e2e as the linked admin:** `4ab94da` (journal feat), `8668918` (sm-demo-app test)
|
||||
4. **Task 4: Go-ahead checkpoint:** answered tag-both, no commit
|
||||
5. **Task 5: Release, pin, nginx and deploy docs:**
|
||||
- tags `v0.1.2` (sm-oauthserver-plugin, pushed with master) and `v0.2.3` (sm-journal-plugin, pushed with main); vue-demo-app master pushed
|
||||
- `aec16c4` chore: bump oauthserver to v0.1.2 (sm-demo-app)
|
||||
- `996586c` chore: bump journal to v0.2.3 (sm-demo-app)
|
||||
- `7e76957` chore: bump vue-demo-app (MCP consent and link pages) (sm-demo-app)
|
||||
- `c21ae9d` feat: nginx locations and DEPLOY section for the MCP endpoint (sm-demo-app)
|
||||
|
||||
Planning: `9550fe0` deferred items (framework), plus this SUMMARY's docs commit.
|
||||
|
||||
## Verification
|
||||
|
||||
- Plugins before tagging: `go vet ./...` and `go test -count=1 -short ./...` green in both; the Docker suites, the vue test/build and the additive checks against d31f8e7/ffa2c8f had passed at the checkpoint
|
||||
- After each pin: `go build -tags summercms_mcp ./... && go test -count=1 -short ./...` green in sm-demo-app; `scripts/check-pins.sh` reports `ok (15 modules)` after the last pin
|
||||
- Task 5's automated verify passes: both plugin HEADs `describe --exact-match` to v0.1.2 / v0.2.3, `check-deploy.sh` ok, tagged build and short tests green, and no uncommitted change to go.mod, go.sum or the three submodule paths
|
||||
- `git ls-remote` on origin lists `refs/tags/v0.1.2`, `refs/tags/v0.2.3` and vue-demo-app `master` at 21a22b6
|
||||
- A release-mode build (`GOWORK=off go build -tags summercms_mcp`) compiles, and `TestMCPEndToEnd` (tagged, Docker) passes on the pinned tree
|
||||
- `check-deploy.sh` rejects a `/oauth/` location, a `/.well-known/` location and a `/mcp` without `proxy_buffering off` (each tried and reverted)
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed and adjusted
|
||||
|
||||
**1. [Rule 3 - Blocking] The tag is passed to go build in the build and dev scripts**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** `summer.yaml` `build.tags` covers `summer build` only. `scripts/build.sh` and `scripts/dev.sh` call `go build` directly and produced binaries that refuse `mcp.enabled: true`.
|
||||
- **Fix:** `GO_TAGS=summercms_mcp` in build.sh, `-tags summercms_mcp` in dev.sh, and `check-all.sh` also runs the tagged tests
|
||||
- **Commit:** 44cac13
|
||||
|
||||
**2. [Rule 3 - Blocking] Untagged test binaries boot with mcp.enabled off**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** a plain `go test ./...` would boot the app without the pier build and fail on `mcp.enabled: true`
|
||||
- **Fix:** `internal/demotest/mcp_tag_off.go` / `mcp_tag_on.go` set `mcp.enabled` from the build tag, so the untagged suite stays green and the tagged suite exercises the endpoint
|
||||
- **Commit:** 44cac13
|
||||
|
||||
**3. [Rule 1 - Bug, worked around] pier publishes `*pier.Pier` once per app, but some tests build the router twice**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** a second `surf.BuildRouter` on the same app fails with `backpack: duplicate provider for *pier.Pier`
|
||||
- **Fix:** `TestRealtimeRoutes` and `socialServer` set `mcp.enabled: false`. Serving is unaffected because a binary builds its router once. The framework-side fix is recorded in deferred-items.md.
|
||||
- **Commit:** 44cac13
|
||||
|
||||
**4. [Rule 3] The resource indicator comes from the base app.url plus the production overlay, not .env**
|
||||
- **Found during:** Task 1 / Task 5
|
||||
- **Issue:** the plan put `SUMMER_MCP__RESOURCE` and `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE` in the production `.env`
|
||||
- **Fix:** `mcp.resource` defaults to `app.url` + `mcp.path`. `config/golem15.oauthserver.yaml` uses `http://127.0.0.1:8097/mcp` and `config/env/production/golem15.oauthserver.yaml` uses `https://demo.summercms.io/mcp`, so rome needs no `.env` key. DEPLOY.md documents both keys as optional overrides that must stay equal.
|
||||
- **Commits:** 44cac13, c21ae9d
|
||||
|
||||
**5. [Rule 2 - Missing validation] Consent client-name cap and body validation**
|
||||
- **Found during:** Task 2
|
||||
- **Fix:** the consent JSON caps the client name at 120 runes (DCR clients choose their own names), and a decision POST whose body is not JSON answers 400 `{"error":"invalid_request"}`
|
||||
- **Commit:** 8bbec72
|
||||
|
||||
**6. [Rule 2 - Security] The verifier also refuses inactive clients**
|
||||
- **Found during:** Task 1
|
||||
- **Fix:** besides revoked, `MCPTokenVerifier` refuses a token whose client has `is_active` false
|
||||
- **Commit:** 116df7f
|
||||
|
||||
**7. [Rule 1] The user cascade fires through AfterCommit, and its `deleted` event duplicates the user plugin's**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** sm-user-plugin v0.1.10 already fires `deleted` for the user guard. The oauthserver cascade fires it again (through `FireSubjectChangedAfterCommit`, so nothing fires on rollback).
|
||||
- **Fix:** both are kept. The cascade's event follows its own purge of tokens, codes and consents (every purge path, not only the user plugin's deletion), and a second `deleted` for the same subject only repeats the session close in pier. Plan 05's revoke matrix may drop one.
|
||||
- **Commit:** 8bbec72
|
||||
|
||||
**8. [Rule 2] /link-admin stale-session handling also covers 401**
|
||||
- **Found during:** Task 2
|
||||
- **Fix:** on `409 stale_session` or a `401`, the page calls `logout()`, shows `linkAdmin.signInAgain` and offers the sign-in that returns to the same `/link-admin?code=...`, so the fresh sign-in D-05 requires happens before confirming
|
||||
- **Commit:** 21a22b6
|
||||
|
||||
**9. [Rule 3] Nuxt dev proxy paths**
|
||||
- **Found during:** Task 2
|
||||
- **Fix:** `nuxt.config.ts` adds `/mcp`, `/.well-known/oauth-protected-resource`, `/.well-known/oauth-authorization-server` and `/oauth/mcp/` to the dev proxy targets, so a local client can use the Nuxt origin and the consent redirect lands on the Nuxt `/connect` page. DEPLOY.md, "MCP endpoint", "Locally", gives the hand-off: `SUMMER_APP__URL=http://127.0.0.1:3020`, with both resources at `http://127.0.0.1:3020/mcp`.
|
||||
- **Commits:** 21a22b6, c21ae9d
|
||||
|
||||
**10. [Rule 3 - Blocking] check-deploy.sh refused any /oauth location**
|
||||
- **Found during:** Task 5
|
||||
- **Issue:** the deploy check rejected every `/oauth` location. Its `/.well-known` rule sat after a `sys.exit` inside an `if` and never ran.
|
||||
- **Fix:** the check now allows exactly `/oauth/mcp/`, the ACME webroot and the two MCP metadata paths, runs the `/.well-known` rule in the location loop, and requires `= /mcp` to proxy to Go with `proxy_buffering off` and `proxy_read_timeout 1h`
|
||||
- **Commit:** c21ae9d
|
||||
|
||||
**11. [Rule 1 - Docs accuracy] DEPLOY.md does not promise self-service revocation**
|
||||
- **Found during:** Task 5
|
||||
- **Issue:** MCP grants write no consent row, so `GET /oauth/authorizations` does not list them and `DELETE /oauth/authorizations/{client_id}` answers 404 for an MCP client
|
||||
- **Fix:** DEPLOY.md says unlinking removes the Journal tools at once, MCP grants are not yet in the authorized-apps list, and deleting the user ends every grant. The gap is in deferred-items.md for plan 05's revoke matrix.
|
||||
- **Commit:** c21ae9d
|
||||
|
||||
**12. Pre-existing main.go diff in sm-demo-app (left alone)**
|
||||
- sm-demo-app had an uncommitted `main.go` change from another session before this plan. Running `summer build` with the v0.4.4 CLI reproduces HEAD's `main.go`, so this plan has no regeneration to commit. The working-tree diff is not ours: it was never staged, and it is still uncommitted.
|
||||
|
||||
**13. sm-journal-plugin has an untracked `go.work.sum`**
|
||||
- It is generated by the plugin's own `go.work` (which is gitignored) and is not part of any commit or tag. The tag sits on the clean commit 4ab94da.
|
||||
|
||||
### Not performed in this run
|
||||
|
||||
- **Task 5's human check** with a real MCP client against the local demo (sign-in on `/connect`, `user_me` only, linking through `/link-admin`, reconnecting with `backend`, the `journal_` tools, a draft post, unlinking) was not run, so no local servers were left running. `TestMCPEndToEnd` covers the same path automatically. The steps are in DEPLOY.md, "MCP endpoint", "Locally". It is recorded in deferred-items.md.
|
||||
|
||||
## Auth Gates
|
||||
|
||||
None.
|
||||
|
||||
## Deferred Issues
|
||||
|
||||
Recorded in `.planning/phases/19.7-generic-mcp-module/deferred-items.md`:
|
||||
- sm-demo-app is eight commits ahead of origin. It is not pushed or deployed, and both wait for the user's go-ahead (deploy also installs the vhost and runs the MCP smoke)
|
||||
- release builds pinning summercms v0.4.4 lack the cabana subject-event fix d96c726 until the demo requires the next framework tag
|
||||
- Redis for MCP sessions if rome ever runs a second instance
|
||||
- MCP grants not in the authorized-apps list (DELETE answers 404), carried from Task 2
|
||||
- pier's once-per-app publish, carried from Task 1
|
||||
- the real-client check above
|
||||
- a retracted indirect `github.com/gabriel-vasile/mimetype` v1.4.15 (through lagoon and validator), which predates this plan
|
||||
|
||||
## Threat Flags
|
||||
|
||||
| Flag | File | Description |
|
||||
|------|------|-------------|
|
||||
| threat_flag: public-surface | ../sm-demo-app/deploy/nginx/demo.summercms.io.conf | `/mcp`, `/.well-known/oauth-*` and `/oauth/mcp/` become public on the next deploy (T-19.7-37: throttled in pier and oauthserver; nginx timeouts bounded at 1h; check-deploy pins the allow-list) |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 05 (unit tests, revoke matrix, security review) can run against tagged plugins and the pinned demo
|
||||
- Before the demo deploy: the user's go-ahead for pushing sm-demo-app and deploying, and ideally a framework tag carrying d96c726
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- Files present: connect.vue, link-admin.vue, mcp.go (journal), mcp_verifier.go, mcp_consent_api.go, demo mcp_e2e_test.go, nginx conf, DEPLOY.md "### MCP endpoint"
|
||||
- Commits present: 116df7f, 8bbec72 (oauthserver); 4ab94da (journal); 21a22b6 (vue-demo-app); 44cac13, 8668918, aec16c4, 996586c, 7e76957, c21ae9d (sm-demo-app); 9550fe0 (framework)
|
||||
- Tags on origin: sm-oauthserver-plugin v0.1.2, sm-journal-plugin v0.2.3
|
||||
309
.planning/phases/19.7-generic-mcp-module/19.7-05-PLAN.md
Normal file
309
.planning/phases/19.7-generic-mcp-module/19.7-05-PLAN.md
Normal file
@@ -0,0 +1,309 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 05
|
||||
type: execute
|
||||
wave: 5
|
||||
depends_on: ["19.7-04"]
|
||||
files_modified:
|
||||
- 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
|
||||
autonomous: true
|
||||
requirements: [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]
|
||||
|
||||
estimate:
|
||||
tokens: 90000
|
||||
raw_tokens: 90000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "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)"
|
||||
artifacts:
|
||||
- path: "scripts/check-phase19.7.sh"
|
||||
provides: "the fail-closed multi-repo phase gate"
|
||||
contains: "--self-test"
|
||||
- path: "modules/pier/helpers_test.go"
|
||||
provides: "fake guard provider, fake verifier, two-instance miniredis harness, bearer-injecting SDK client"
|
||||
contains: "miniredis"
|
||||
- path: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md"
|
||||
provides: "the per-threat evidence table"
|
||||
contains: "T-19.7-01"
|
||||
- path: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md"
|
||||
provides: "the phase security contract with threats_open"
|
||||
contains: "threats_open"
|
||||
- path: ".planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md"
|
||||
provides: "the filled per-task verification map"
|
||||
contains: "nyquist_compliant: true"
|
||||
key_links:
|
||||
- from: "scripts/check-phase19.7.sh"
|
||||
to: "modules/pier/tools_list_test.go"
|
||||
via: "the go stage's required-name list includes TestToolsList"
|
||||
pattern: "TestToolsList"
|
||||
- from: "scripts/check-phase19.7.sh"
|
||||
to: "modules/bouncer/dispatch.go"
|
||||
via: "the marker stage greps for callers of the setter outside modules/pier and tests"
|
||||
pattern: "marker"
|
||||
- from: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md"
|
||||
to: "19.7-0{1,2,3,4}-PLAN.md threat registers"
|
||||
via: "one row per T-19.7-NN with implementation and test references"
|
||||
pattern: "T-19.7-"
|
||||
---
|
||||
|
||||
<objective>
|
||||
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.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<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
|
||||
</context>
|
||||
|
||||
<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>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>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</name>
|
||||
<files>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</files>
|
||||
<read_first>
|
||||
- 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"
|
||||
</read_first>
|
||||
<action>
|
||||
`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.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase19.7.sh --self-test && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --marker</automated>
|
||||
<fails_when>non-zero exit, or a stage line printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `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`)
|
||||
</acceptance_criteria>
|
||||
<done>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.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>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</name>
|
||||
<files>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</files>
|
||||
<behavior>
|
||||
- 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).
|
||||
</behavior>
|
||||
<read_first>
|
||||
- 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)
|
||||
</read_first>
|
||||
<action>
|
||||
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(<module>)` 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).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>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</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or a gate line printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `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)
|
||||
</acceptance_criteria>
|
||||
<done>Every framework row of the validation map has its named test, the gate requires each one, and the admin stage is live.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Plugin and demo tests, additive-export checks, consumers stage, docker and docs stages, and the filled validation map</name>
|
||||
<files>../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</files>
|
||||
<behavior>
|
||||
- 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.
|
||||
</behavior>
|
||||
<read_first>
|
||||
- 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)
|
||||
</read_first>
|
||||
<action>
|
||||
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`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase19.7.sh --all</automated>
|
||||
<fails_when>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)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `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
|
||||
</acceptance_criteria>
|
||||
<done>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.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>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</name>
|
||||
<files>.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</files>
|
||||
<read_first>
|
||||
- .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 `<threat_model>` 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
|
||||
</read_first>
|
||||
<action>
|
||||
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.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>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</automated>
|
||||
<fails_when>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</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- 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 <sha>, 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 <repo> cat-file -t <sha>` 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
|
||||
</acceptance_criteria>
|
||||
<done>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.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<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>
|
||||
|
||||
<verification>
|
||||
- `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`
|
||||
</verification>
|
||||
|
||||
<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>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md` when done (planning docs in their own commit).
|
||||
</output>
|
||||
310
.planning/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md
Normal file
310
.planning/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md
Normal file
@@ -0,0 +1,310 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 05
|
||||
subsystem: testing
|
||||
status: complete
|
||||
tags: [pier, mcp, gate, security-review, bouncer, cabana, surf, wristband, sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin, sm-demo-app, vitest]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-01
|
||||
provides: dispatch marker, compiled handler lookup, stream route kind, account contributions, prompted record actions, wristband scope allow-list
|
||||
- phase: 19.7-02
|
||||
provides: modules/pier (catalog, dispatch, identity, sessions, fan-out, stateless path, PRM)
|
||||
- phase: 19.7-03
|
||||
provides: sm-user-plugin v0.1.10 (account link, frontend permission catalog, user MCP guard)
|
||||
- phase: 19.7-04
|
||||
provides: sm-oauthserver-plugin v0.1.2 (verifier, consent JSON), sm-journal-plugin v0.2.3 (MCP tools), demo wiring and TestMCPEndToEnd
|
||||
provides:
|
||||
- scripts/check-phase19.7.sh, the fail-closed multi-repo phase gate (self-test, go, plugins, consumers, docker, admin, docs, marker), green in full on a Docker host
|
||||
- modules/pier/helpers_test.go (fakeGuard, fakeVerifier, fakeLinkResolver, fakePersonalResolver, routePlugin, newApp, startInstance, twoInstances, sdkClient, fireSubjectChanged)
|
||||
- named tests for every validation row in the framework, the three plugins and the demo
|
||||
- 19.7-SECURITY.md (threats_open 0) and 19.7-SECURITY-REVIEW.md (T-19.7-01..41, T-19.7-SC)
|
||||
- three framework fixes: cabana's backend middleware refuses a frontend marker, pier accepts tools/call without arguments, an ended pier session is never written back
|
||||
- the filled 19.7-VALIDATION.md (nyquist_compliant true) and the two folded todos closed
|
||||
affects: [phase 19.7 verification (/msd-verify-work), framework v0.5.0 at phase completion, optional patch tags of the three plugins]
|
||||
|
||||
actuals:
|
||||
tokens: 62152
|
||||
tasks: 4
|
||||
commits: 9
|
||||
plan_head_before: 905111ba7240828f2434bf313439d5c8af0c78d1
|
||||
plan_head_after: 4730e37742223133033c3ff20a3cd0c527d77c53
|
||||
commit_ledger:
|
||||
summercms.go: {before: 905111b, after: 4730e37, count: 9}
|
||||
sm-user-plugin (sm-demo-app/plugins/golem15/user): {before: bfcfea4, after: 72de822, count: 1}
|
||||
sm-oauthserver-plugin: {before: 8bbec72, after: 2929c91, count: 1}
|
||||
sm-journal-plugin: {before: 4ab94da, after: a9a9b80, count: 1}
|
||||
sm-demo-app: {before: c21ae9d, after: 6fa2d56, count: 1}
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Required-name gate entries as <package>:<TestName>, grouped per package so a package without a match can never pass as 'no tests to run'"
|
||||
- "Postgres subtests are created only when not -short (no t.Skip), so the detector's skip refusal stays meaningful and the docker stage runs the same top-level name in full"
|
||||
- "In-process dispatch marker as a test harness: account and user-guard routes are exercised without an admin or session row"
|
||||
- "Session persistence rewrites, never creates (SET XX), so an ended session stays ended"
|
||||
- "Pin check that tolerates a plugin submodule ahead of its pin only by *_test.go commits"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- scripts/check-phase19.7.sh
|
||||
- modules/pier/helpers_test.go
|
||||
- modules/pier/tools_list_test.go
|
||||
- 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/pier/endpoint_guards_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/cabana/scope_limit_for_test.go
|
||||
- modules/surf/streaming_test.go
|
||||
- modules/surf/pier_mount_test.go
|
||||
- modules/wristband/mcp_scopes_test.go
|
||||
- ../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
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md
|
||||
modified:
|
||||
- modules/cabana/http.go
|
||||
- modules/pier/dispatch.go
|
||||
- modules/pier/session.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/store_memory.go
|
||||
- modules/pier/store_redis.go
|
||||
- docs/services/authentication.md
|
||||
- modules/pier/tracer_smoke_test.go
|
||||
- modules/pier/sessions_smoke_test.go
|
||||
- modules/pier/identity_smoke_test.go
|
||||
- modules/pier/export_test.go
|
||||
- modules/cabana/administrators_harness_test.go
|
||||
- modules/cabana/record_action_prompt_postgres_test.go
|
||||
- modules/surf/streaming_smoke_test.go
|
||||
- admin/tests/account/AccountContributions.test.ts
|
||||
- admin/tests/form/RecordActionsPrompt.test.ts
|
||||
- ../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/deferred-items.md
|
||||
- .planning/todos/done/2026-10-17-plugin-registered-frontend-permissions.md
|
||||
- .planning/todos/done/2026-10-17-frontend-backend-account-link.md
|
||||
|
||||
key-decisions:
|
||||
- "P-21 implemented: gate stages self-test, go, plugins, consumers, docker, admin, docs, marker; docker last, NOT RUN only without a daemon, a failure with PHASE197_REQUIRE_DOCKER=1"
|
||||
- "P-22 implemented: 19.7-SECURITY.md and 19.7-SECURITY-REVIEW.md in the 19.4 shape; threats_open 0"
|
||||
- "P-23 verdict: superuser reach accepted as designed with audit and ceiling; mcp.refuse_superuser_backend not added, so no patch tag is needed for it (conditional follow-up in deferred-items)"
|
||||
- "MCP grants without a consent row: accepted for this phase (AR-19.7-03); access ends through client revocation, user deletion or deactivation, expiry and the verifier; the e2e pins that the revoked event ends the session"
|
||||
- "The user plugin's additive check uses both pre-phase bases (930b158 and v0.1.9); the user plugin runs with GOWORK=off, the OAuth server and blog plugins in their own workspaces"
|
||||
|
||||
patterns-established:
|
||||
- "A phase's last plan turns the plans' smokes into named tests the gate requires by package, untagged and with the build tag"
|
||||
|
||||
requirements-completed: [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]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "The fail-closed multi-repo gate passes in full on a Docker host and its detectors are proven on planted output"
|
||||
requirement: "D-31"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase19.7.sh --all (PASS self-test, go, plugins, consumers, admin, docs, marker, docker)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Every framework validation row has its named test (pier, bouncer, cabana, surf, wristband, vitest)"
|
||||
requirement: "SC-3"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/{tools_list,catalog,dispatch,guard_rules,sessions,fanout,endpoint_guards}_test.go"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/bouncer/dispatch_test.go#TestDispatchMarker, modules/cabana/dispatch_marker_test.go#TestDispatchMarker"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/surf/{streaming,pier_mount}_test.go, modules/wristband/mcp_scopes_test.go, modules/cabana/{account_contributions,record_action_prompt,scope_limit_for}_test.go"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Plugin and demo rows: link proof, frontend permission catalog, user guard, verifier, consent, Journal declaration, end-to-end revoke matrix"
|
||||
requirement: "SC-4"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "sm-user-plugin TestBackendLink, TestFrontendPermissionCatalog, TestUserMCPGuard (Postgres)"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "sm-oauthserver-plugin TestMCPTokenVerifier, TestMCPConsent (Postgres)"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "sm-journal-plugin TestJournalMCP"
|
||||
status: pass
|
||||
- kind: e2e
|
||||
ref: "sm-demo-app TestMCPEndToEnd (tagged, Postgres)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Security review of T-19.7-01..41 and T-19.7-SC with evidence; superuser verdict recorded"
|
||||
requirement: "D-22"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md, 19.7-SECURITY.md (threats_open 0)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: about 95 min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 05: Unit tests, phase gate and security review Summary
|
||||
|
||||
**A fail-closed gate across six repositories (`scripts/check-phase19.7.sh`) now requires a named test for every row of the validation map, and it passes in full on a Docker host. The security review covers every threat of the phase. The tests and the review found three framework defects, each fixed in its own commit: cabana's `backend` middleware accepted a frontend dispatch marker, a pier session that had ended could be written back by a request still in flight, and pier rejected argument-less tool calls.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 95 minutes (2026-10-23, roughly 11:05Z to 12:40Z)
|
||||
- **Tasks:** 4 of 4
|
||||
- **Repositories touched:** 5 with commits (summercms.go, sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin, sm-demo-app)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Task 1 (tracer):** `modules/pier/helpers_test.go` collects the plan 02 fixtures and adds configurable fakes and the two-instance miniredis harness. `TestToolsList` covers per-principal lists, the read ceiling, a tool with no subject, unlisted calls that never reach the route, and the union of tools when an identity has both a frontend and a backend subject. `TestDispatchMarker` exists in both bouncer and cabana; the cabana one has a Postgres part. The gate shipped at this point with its self-test, go and marker stages.
|
||||
- **Task 2:** `TestCatalog`, `TestDispatch`, `TestGuardRules`, `TestSessions` (on Redis across two instances and on the memory store), `TestFanOut`, `TestStreamingRoute`, `TestPierMount` (both builds), `TestMCPScopes`, `TestAccountContributions` (with a Postgres transaction case and a check that the existing payloads are unchanged), `TestRecordActionPrompt` and `TestScopeLimitForMethods`, plus extended vitest files. The gate's admin stage went live.
|
||||
- **Task 3:** `TestBackendLink`, `TestFrontendPermissionCatalog` and `TestUserMCPGuard` in the user plugin; `TestMCPTokenVerifier` and `TestMCPConsent` in the OAuth server plugin; `TestJournalMCP`, which compiles Journal's declaration through pier itself; and a revoke matrix in the demo's `TestMCPEndToEnd`. The gate gained its plugins (with the additive-export checks), consumers, docker and docs stages. The validation map is filled in (`nyquist_compliant: true`).
|
||||
- **Task 4:** wrote `19.7-SECURITY-REVIEW.md` and `19.7-SECURITY.md` (`threats_open: 0`). The review added pins for the endpoint's outer layers in `TestEndpointGuards` and a check that undeclared argument keys are refused, and recorded the superuser verdict. The two folded todos moved to `todos/done/` with closing notes.
|
||||
|
||||
## Task Commits
|
||||
|
||||
summercms.go (master, not pushed):
|
||||
|
||||
1. **Task 1:** `c49983d` fix(cabana): frontend dispatch marker refused by the backend middleware; `3bbbe6c` test: gate (go, marker stages), pier helpers, TestToolsList, TestDispatchMarker
|
||||
2. **Task 2:** `c29d228` fix(pier): tools/call without arguments; `1111828` fix(pier): ended session never written back; `f14eae9` test: framework tests for every validation row, admin stage
|
||||
3. **Task 3:** `a94bdc1` test: gate stages plugins, consumers, docker, docs; `d621ef1` docs: validation map
|
||||
4. **Task 4:** `0b8e027` test: security review pins; `4730e37` docs: security review and contract, deferred items, todos closed
|
||||
|
||||
Plugins and demo (local commits, **not pushed and not tagged**):
|
||||
|
||||
| Repo | Commit | Content |
|
||||
|------|--------|---------|
|
||||
| sm-user-plugin (checkout at `sm-demo-app/plugins/golem15/user`) | `72de822` | TestBackendLink, TestFrontendPermissionCatalog, TestUserMCPGuard |
|
||||
| sm-oauthserver-plugin | `2929c91` | TestMCPTokenVerifier, TestMCPConsent |
|
||||
| sm-journal-plugin | `a9a9b80` | TestJournalMCP |
|
||||
| sm-demo-app | `6fa2d56` | TestMCPEndToEnd revoke matrix |
|
||||
|
||||
All four add tests only; none changes shipped code. Patch tags (sm-user-plugin v0.1.11, sm-oauthserver-plugin v0.1.3, sm-journal-plugin v0.2.4) are optional and wait for the user. The demo's `plugins/golem15/user` working tree sits one commit (72de822) ahead of its v0.1.10 pin. I did not commit that pointer change in sm-demo-app. The gate's pin check reports the drift and accepts it only because the commit touches `*_test.go` files alone.
|
||||
|
||||
`commits: 9` is measured in summercms.go (`git rev-list --count 905111b..4730e37`); the four plugin and demo commits come on top of that count.
|
||||
|
||||
## Gate output (`bash scripts/check-phase19.7.sh --all`, final run after Task 4)
|
||||
|
||||
```
|
||||
PASS self-test
|
||||
PASS go
|
||||
PASS plugins
|
||||
pins: plugins/golem15/user is ahead of its pin bfcfea4ed7d4 by test-only commits (release not needed for shipped code)
|
||||
check-deploy: ok
|
||||
PASS consumers
|
||||
PASS admin
|
||||
PASS docs
|
||||
PASS marker
|
||||
PASS docker
|
||||
Phase 19.7 gate passed
|
||||
```
|
||||
|
||||
Exit 0. These also pass: `bash scripts/check-phase19.6.1.sh --all` (every stage PASS, docker included), and in the framework `go vet ./...` plus the full `go test -count=1 ./...` with Docker.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug, security] cabana's `backend` middleware honoured a frontend dispatch marker**
|
||||
- **Found during:** Task 1 (cabana `TestDispatchMarker`, in-process admin API case)
|
||||
- **Issue:** `bouncer.Registry.Middleware("backend")` honoured any marker that listed `backend`, even one whose principal had `Backend: false`. The admin API would then have treated a frontend user id as an administrator id. `ResolveBackend` already refused such a marker; the middleware did not.
|
||||
- **Fix:** `refuseFrontendMarker` wraps the backend guard middleware and answers 401 for that case. The authentication docs page now states the rule.
|
||||
- **Files modified:** modules/cabana/http.go, docs/services/authentication.md
|
||||
- **Commit:** c49983d
|
||||
|
||||
**2. [Rule 1 - Bug] `tools/call` without arguments was refused**
|
||||
- **Found during:** Task 2 (`TestDispatch`)
|
||||
- **Issue:** a JSON `null` for arguments was validated against the object schema and refused, so an agent could not call a tool that has no required input unless it sent `{}`.
|
||||
- **Fix:** an empty body or `null` now means `{}`.
|
||||
- **Files modified:** modules/pier/dispatch.go
|
||||
- **Commit:** c29d228
|
||||
|
||||
**3. [Rule 1 - Bug, security] an ended session could be written back**
|
||||
- **Found during:** Task 2 (`TestFanOut`, failed about one run in a hundred)
|
||||
- **Issue:** after a request finished, its session state was saved with a plain Put. If the session had ended while the request ran (DELETE, a revoked or deleted event, expiry), the save recreated the record and the next request rehydrated the ended session.
|
||||
- **Fix:** an unexported `updater` (Redis `SET XX`, memory update-if-present). Persisting now only rewrites an existing record and closes the local copy when the record is gone. TestFanOut, TestSessions and both session smokes passed 300 times in a row afterwards.
|
||||
- **Files modified:** modules/pier/session.go, store.go, store_memory.go, store_redis.go
|
||||
- **Commit:** 1111828
|
||||
|
||||
**4. [Rule 3 - Blocking] pier helpers are in package `pier_test`, not `pier`**
|
||||
- The plan named `package pier`, but the plan 02 smokes the helpers serve are in `pier_test`, which imports surf. Internal seams stay in `export_test.go` (package pier): `AdvanceStoreClock`, `StatelessServers`, `SetRecheck`.
|
||||
|
||||
**5. [Rule 3 - Blocking] cabana's `TestDispatchMarker` lives in `cabana_test`**
|
||||
- The Postgres harness (`newScreensEnv`) is in the external package. The harness now keeps its `*backpack.App` (a one-field test change). For the same reason, `TestAccountContributions` is also in `cabana_test`.
|
||||
|
||||
**6. [Rule 3] Postgres subtests are created only when not `-short`**
|
||||
- The gate's detector refuses skipped subtests. So `TestDispatchMarker`, `TestAccountContributions` and the other tests with a Postgres part return before creating that part under `-short`, and the docker stage runs the same top-level name in full.
|
||||
|
||||
**7. [Rule 2] `TestScopeLimitForMethods` (cabana) stands in for the backend guard's scoped principal case**
|
||||
- The built-in backend provider needs a database (`cabana.BackendPrincipal`), so it cannot run under `-short`. `TestGuardRules` proves that pier asks a method-aware provider with each tool's method. `TestScopeLimitForMethods` proves that cabana's per-method filter is the one the backend guard uses.
|
||||
|
||||
**8. [Rule 3] `TestRecordActionPrompt`'s case for the `RecordAction` wrapper is pinned through the Postgres route test**
|
||||
- The wrapper needs a database. `TestRecordActionPromptRun` gained a plain action that runs with an empty Value.
|
||||
|
||||
**9. [Rule 1 - test] the streaming smoke reset the mount hook to nil**
|
||||
- In a build with the tag, that broke every later surf test. The smoke now restores the previous hook. This is a test-only change, committed in f14eae9.
|
||||
|
||||
**10. [Rule 3] the gate's consumers stage accepts a submodule that is ahead of its pin only by test commits**
|
||||
- The demo's `check-pins.sh` correctly reports the user plugin checkout at 72de822 against the v0.1.10 pin. The gate accepts the drift only when the submodule descends from its pin and the diff touches nothing but `*_test.go` files; any other mismatch fails.
|
||||
|
||||
**11. [Rule 2] the gate also checks `account.go` and runs the demo's deploy check**
|
||||
- The go stage refuses any change to `modules/cabana/account.go` since 51d088a (D-04: payloads unchanged). The consumers stage runs `check-deploy.sh` (T-19.7-37).
|
||||
|
||||
**Total deviations:** 3 production fixes (two security-relevant), 8 adjustments to test structure or the gate. No architectural change.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- `cp` in this shell is interactive (`cp -i`); one backgrounded debug loop hung on its prompt and was killed. No repository content was affected.
|
||||
- With `GOWORK=off` the user plugin and the demo's release build compile against summercms v0.4.4, which does not include this plan's framework fixes. The gate runs the demo through its workspace (the framework checkout); see deferred items.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None beyond the phase threat model. This plan adds tests, the gate and three fixes that narrow existing surfaces.
|
||||
|
||||
## Deferred Items
|
||||
|
||||
Recorded in `deferred-items.md`:
|
||||
- framework fixes c49983d, c29d228 and 1111828 are on master only; applications pinning v0.4.4 lack them until the next framework tag (v0.5.0 at phase completion)
|
||||
- the four plugin and demo test commits are local and untagged (optional patch tags)
|
||||
- a superuser refusal switch, conditional on a future superuser-only or destructive backend tool
|
||||
- the decision on MCP grants that have no consent row (AR-19.7-03; the follow-up stays open)
|
||||
|
||||
## g15office (for the orchestrator's phase-completion step)
|
||||
|
||||
The two closed todos correspond to g15office tasks **`hmguritm`** (plugin-registered frontend permissions) and **`tqyvnzxx`** (frontend-backend account link). Both move into the phase milestone task **`dcnv4mha`** with a one-line comment. The phase-advance comment also belongs to that step (`.planning/G15OFFICE.md`). The executor did not touch g15office.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. Push, tags and the framework v0.5.0 release wait for the user's go-ahead.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
`/msd-verify-work` can run the gate: `bash scripts/check-phase19.7.sh --all` on a Docker host. After that, phase completion: framework v0.5.0 (which carries plans 01-05 and this plan's fixes), then the demo bump and deploy.
|
||||
|
||||
---
|
||||
*Phase: 19.7-generic-mcp-module*
|
||||
*Completed: 2026-10-23*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
All 25 listed created files exist on disk; the framework commits c49983d, 3bbbe6c, c29d228, 1111828, f14eae9, a94bdc1, d621ef1, 0b8e027 and 4730e37 and the plugin and demo commits 72de822, 2929c91, a9a9b80 and 6fa2d56 exist in their repositories; measured framework commits 905111b..4730e37 = 9.
|
||||
407
.planning/phases/19.7-generic-mcp-module/19.7-06-PLAN.md
Normal file
407
.planning/phases/19.7-generic-mcp-module/19.7-06-PLAN.md
Normal file
@@ -0,0 +1,407 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 06
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
gap_closure: true
|
||||
files_modified:
|
||||
- modules/pier/session.go
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/audit.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/store_memory.go
|
||||
- modules/pier/store_redis.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/identity.go
|
||||
- modules/pier/dispatch.go
|
||||
- modules/pier/catalog.go
|
||||
- modules/pier/filter.go
|
||||
- modules/pier/export_test.go
|
||||
- modules/pier/reaper_smoke_test.go
|
||||
- modules/pier/README.md
|
||||
- modules/pact/mcp.go
|
||||
- modules/pact/README.md
|
||||
- modules/cooler/cooler.go
|
||||
- docs/services/mcp.md
|
||||
autonomous: true
|
||||
requirements: [SC-1, SC-2, SC-3, D-10, D-11, D-13, D-17, D-19, D-20, D-25, D-26, D-27, D-28, D-32]
|
||||
|
||||
estimate:
|
||||
tokens: 110000
|
||||
raw_tokens: 110000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A stateful session whose store record has expired (idle past mcp.sessions.idle_ttl, or never DELETEd) is closed on every instance that holds a local copy: its SDK server session ends, it leaves the local map and the fan-out matching set, and an `expired` audit line is written (A-CR-01, A-IN-06, D-27)"
|
||||
- "N concurrent initialize POSTs from one binding open at most mcp.sessions.max_per_binding sessions on the memory store and on Redis; a failed connect or initialize releases its reservation (A-WR-03, D-25)"
|
||||
- "A slow guard or database check during one client's initialize, rehydration or stateless server build does not block other clients' requests on the instance (A-WR-07)"
|
||||
- "When the same binding comes back with a wider identity (more scopes, a backend subject added), its stateful session and its stateless server gain the newly allowed tools and prompts on that request (A-WR-04, D-20, D-23)"
|
||||
- "On the Redis store an instance subscribes to fan-out events at mount without waiting for a stateful request; a stateless subscriptions/listen stream is re-verified periodically and ends when its bearer stops resolving; an LRU-evicted stateless server's sessions are closed (A-WR-05, A-WR-06, D-26, D-32)"
|
||||
- "A personal-token subject without a TokenID is refused at /mcp, so no two users share a binding (A-WR-09, D-19)"
|
||||
- "pier never hands a route a path value the HTTP mux could not produce: empty, `.` or `..` segments are refused, a single segment never contains `/`, an omitted path field is refused at runtime and a path field that is not required in the schema fails boot (A-WR-01, A-WR-02, D-10, D-11)"
|
||||
- "A guard dispatch failure answers the MCP client with a fixed text and is logged server-side; integer arguments above 2^53 keep their digits; the dispatched request carries the outer Host and forwarding headers; an embedded struct on a GET or DELETE tool fails boot; a provider answer naming the backend guard for a frontend tool is refused (A-WR-08, A-IN-04, A-IN-05, A-IN-07, A-IN-08, D-13, D-17)"
|
||||
- "A prompt declared with Writes is hidden from an identity without write, as a non-read-only tool is (C-IN-01 framework part, D-20, D-28)"
|
||||
artifacts:
|
||||
- path: "modules/pier/session.go"
|
||||
provides: "the session reaper and the lock-free connect path"
|
||||
contains: "func (sr *sessionRouter) reap("
|
||||
- path: "modules/pier/store.go"
|
||||
provides: "the unexported reserver contract next to updater"
|
||||
contains: "type reserver interface"
|
||||
- path: "modules/pier/store_redis.go"
|
||||
provides: "the atomic Lua reservation"
|
||||
contains: "NewScript"
|
||||
- path: "modules/pier/reaper_smoke_test.go"
|
||||
provides: "the tracer's end-to-end smoke"
|
||||
contains: "func TestPierReaperSmoke("
|
||||
- path: "modules/pact/mcp.go"
|
||||
provides: "MCPPrompt.Writes and the corrected personal-token resolver contract"
|
||||
contains: "Writes"
|
||||
key_links:
|
||||
- from: "modules/pier/pier.go"
|
||||
to: "modules/pier/session.go"
|
||||
via: "Mount starts the reaper goroutine"
|
||||
pattern: "reap("
|
||||
- from: "modules/pier/session.go"
|
||||
to: "modules/pier/store.go"
|
||||
via: "serveNew reserves through the reserver interface instead of Count then Put"
|
||||
pattern: "Reserve("
|
||||
- from: "modules/pier/filter.go"
|
||||
to: "modules/pact/mcp.go"
|
||||
via: "allowsPrompt applies the read/write ceiling when decl.Writes is set"
|
||||
pattern: "Writes"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: TokenID == 0 -->
|
||||
|
||||
<objective>
|
||||
Close lane A of the phase code review (`19.7-REVIEW.md`) in the framework's `pier` module: the critical session leak A-CR-01, the nine warnings A-WR-01..A-WR-09, and every lane A info finding (A-IN-01..A-IN-08), all of which are cheap. It also lands the framework part of C-IN-01 (`pact.MCPPrompt.Writes`), because that field lives next to the prompt filter. This is gap closure for phase 19.7 before framework v0.5.0 (`19.7-GAP-INPUTS.md`). The code review found no identity or guard bypass. These are lifecycle, concurrency and edge-handling defects, and the fixes keep D-25's rule that every request is authorized fresh.
|
||||
|
||||
**Planner decisions recorded here (P-24..P-28 continue plan 05's P-21..P-23):**
|
||||
- **P-24 (reaper, A-CR-01):** a janitor goroutine started at `Mount` checks every local session against the store every `min(idle_ttl/2, 1m)`. It closes each local copy whose record is gone and logs `expired`. The store's TTL stays the single source of truth across instances: a session another instance keeps alive still has its record, so this instance keeps its copy. No new config key. Stop path: `backpack.App` has no shutdown hook today (its methods are `SetPlugins`, `HasPlugin`, `Publish` and `Lookup`). So `Mount` runs the reaper under a context whose cancel func is kept on the `Pier` (`p.stopReap`). In production it runs for the life of the process, like the store subscription and the user plugin's blacklist sweep. Tests stop it through the `StopReaper` seam, and when backpack gains a lifecycle hook, `Mount` registers `p.stopReap` there (one line, noted in the README). `export_test.go` gets the `ReapNow`, `LocalSessions` and `StopReaper` seams.
|
||||
- **P-25 (atomic reservation, A-WR-03):** an unexported `reserver` interface (`Reserve`, `Release`) sits next to plan 05's `updater`. It follows the same pattern, so the exported `pier.Store` interface does not change. The memory store reserves under its mutex. The Redis store reserves with one Lua script (prune dead members, `SCARD`, `SADD` plus a placeholder `SET ... PX`); miniredis supports `EVAL`. A store that does not implement it falls back to `Count` then `Put`.
|
||||
- **P-26 (widening, A-WR-04):** `Identity.fingerprint()` covers the authorization-relevant parts: sorted scopes, the frontend and backend subjects (guard, user, client, token), the ceiling and the token kind. A stateless hit or a stateful lookup whose fingerprint changed runs the same add/remove diff as a fan-out event.
|
||||
- **P-27 (path values, A-WR-01, A-WR-02):** these refusals mirror what `net/http.ServeMux` guarantees over HTTP:
|
||||
- every `path:` field must be listed as required in the reflected schema (boot error otherwise);
|
||||
- at runtime an omitted path value, an empty, `.` or `..` segment, and a `/` inside a single-segment value are refused before dispatch.
|
||||
- **P-28 (prompt ceiling, C-IN-01):** the new field `pact.MCPPrompt.Writes bool` (additive, zero value unchanged) puts a prompt under the same read/write ceiling as a non-read-only tool. Journal sets it in plan 08.
|
||||
|
||||
Purpose: the review's lane A blockers are gone before v0.5.0. Plan 07 builds its token-specific events on these files, plan 08 uses `MCPPrompt.Writes`, and plan 09 pins every fix with named tests.
|
||||
Output: framework commits in `modules/pier`, `modules/pact` and `modules/cooler` with their README and docs pages, and one tracer smoke test.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-02-SUMMARY.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
@modules/pier/README.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Unit tests are plan 09's job (project rule 2). This plan carries one tracer smoke, `TestPierReaperSmoke`. Every existing pier, surf and pact test, and the gate's go stage, stays green after each task: the earlier named tests (`TestSessions`, `TestFanOut`, `TestToolsList`, `TestDispatch`, `TestCatalog`, `TestEndpointGuards` and the smokes) are regression pins, not something to rewrite. A test that encodes the old, wrong behaviour (for example one relying on a shared `pat:user:0` binding, or on a non-required path field compiling) is changed in the same commit as the fix, and the SUMMARY names it.
|
||||
- Documentation rule (CLAUDE.md): an exported API change, here `pact.MCPPrompt.Writes` and the resolver contract text, updates `modules/pact/README.md`, `modules/pier/README.md` and `docs/services/mcp.md` in the same commit. Every identifier in those files must exist (`summer docs:build --check`).
|
||||
- No new dependency: `go.mod`, `go.sum` and `admin/package-lock.json` stay unchanged.
|
||||
- Several sessions work in this repo: run `git status --short modules/pier modules/pact modules/cooler docs` before every task and leave other sessions' edits alone. Stage by explicit path, one logical change per commit, no co-author tags. Planning docs go in their own commit.
|
||||
- Every commit is self-contained: at each commit the framework builds, `go vet ./...` is clean and the `-short` tests pass. No commit relies on a later task's commit. A task with several commits orders them so this holds.
|
||||
- Release rule: no tag, push or deploy in this plan. Commits stay local on master.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: an abandoned stateful session is reaped end to end (store expiry → local close → audit line → gone from fan-out)</name>
|
||||
<files>modules/pier/session.go, modules/pier/pier.go, modules/pier/audit.go, modules/pier/export_test.go, modules/pier/reaper_smoke_test.go, modules/pier/README.md</files>
|
||||
<read_first>
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md, sections A-CR-01, A-IN-01 and A-IN-06 (failure scenario and suggested janitor)
|
||||
- modules/pier/session.go: `sessionRouter`, `localSession`, `serveNew`, `lookup`, `connect`, `persist`, `serveStream` (the GET re-check ticker), `closeLocal`, `matching`
|
||||
- modules/pier/pier.go: `Mount` (where `listenEvents` and the store are set up) and `newStore`
|
||||
- modules/pier/audit.go: `logSession` and the documented steps, including `expired`
|
||||
- modules/pier/store_memory.go (lazy expiry, `now` clock) and store_redis.go (`Get` on an expired key)
|
||||
- modules/pier/export_test.go (`AdvanceStoreClock`, `SetRecheck`) and modules/pier/helpers_test.go (`newApp`, `startInstance`, `sdkClient`, `fakeVerifier`)
|
||||
</read_first>
|
||||
<action>
|
||||
Implement P-24 for A-CR-01.
|
||||
|
||||
In session.go:
|
||||
- Add `func (sr *sessionRouter) reap(ctx context.Context, every time.Duration)`, a ticker loop that calls `reapOnce`.
|
||||
- Add `func (sr *sessionRouter) reapOnce(ctx context.Context) int`. It copies the session ids from `sr.local` under `sr.mu`, releases the lock, then calls `sr.p.store.Get` for each id without holding any router lock. When the answer is `ok == false` and `err == nil`, it calls `closeLocal(id)` and `logSession(logger(), "expired", id, binding)`. It returns how many sessions it closed. A store error keeps the local copy, logs one warning per pass, and never closes on doubt.
|
||||
- `closeLocal` already closes the SDK server session, which ends the `ss.Wait()` goroutine, and removes the id from `sr.local`. Confirm that `matching` reads only `sr.local`, so a reaped session drops out of fan-out.
|
||||
|
||||
In pier.go `Mount`, after `p.sessions` and `p.store` exist, create a cancellable context with `context.WithCancel(context.Background())`, store its cancel func in the new unexported `Pier` field `stopReap`, and start `go p.sessions.reap(ctx, reapInterval(cfg.IdleTTL))` with that context. The loop returns when the context is cancelled. `reapInterval` returns `min(idleTTL/2, time.Minute)`, floored at one second.
|
||||
|
||||
A-IN-01: in `serveStream`'s re-check ticker, after the bearer re-resolves, call `store.Get` for the session. A record that is gone (`ok == false`, no error) cancels the stream and calls `closeLocal`, so an `ended` event lost between instances no longer keeps the stream open.
|
||||
|
||||
A-IN-06:
|
||||
- Emit `expired` from the reaper. Update the audit.go doc so every documented step is emitted somewhere.
|
||||
- Log the tool calls `serveEphemeral` serves with the session label `ephemeral` instead of `stateless`. Change only that call site's label.
|
||||
|
||||
export_test.go gains three seams (the third is `func (p *Pier) StopReaper()`, which calls `p.stopReap`, so a test can end the goroutine; the smoke registers it with `t.Cleanup`):
|
||||
- `func (p *Pier) ReapNow(ctx context.Context) int`, which calls `p.sessions.reapOnce`;
|
||||
- `func (p *Pier) LocalSessions() int`, which counts `sr.local` under its lock.
|
||||
|
||||
New file `modules/pier/reaper_smoke_test.go` (package `pier_test`, built on helpers_test.go) holds `TestPierReaperSmoke` on the memory store:
|
||||
1. Open a session with an SDK client (`sdkClient`) and confirm `LocalSessions() == 1`.
|
||||
2. Advance the store clock past `mcp.sessions.idle_ttl` with `AdvanceStoreClock`, then call `ReapNow`; it returns 1 and `LocalSessions() == 0`.
|
||||
3. The next request with the old `Mcp-Session-Id` answers 404.
|
||||
4. A second session that stays active (touched by a request) survives a reap pass.
|
||||
|
||||
In modules/pier/README.md, add one paragraph under the session lifecycle: idle sessions are reaped at the store TTL, and `expired` joins the audit steps. No new configuration key.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pier/... && go test -count=1 -short ./modules/pier/... && go test -count=1 -short -tags summercms_mcp ./modules/pier/... ./modules/surf/... && go test -count=1 -short -run '^TestPierReaperSmoke$' -v ./modules/pier/ 2>&1 | grep -q -- '^--- PASS: TestPierReaperSmoke'</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or no `--- PASS: TestPierReaperSmoke` line (a SKIP counts as missing)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func (sr \*sessionRouter) reap(\|func (sr \*sessionRouter) reapOnce(" modules/pier/session.go` prints 2
|
||||
- `grep -v '^\s*//' modules/pier/pier.go | grep -c "reap("` prints at least 1
|
||||
- `grep -c '"expired"' modules/pier/session.go` prints at least 1 and `grep -c '"ephemeral"' modules/pier/session.go` prints at least 1
|
||||
- `grep -c "func (p \*Pier) ReapNow(\|func (p \*Pier) LocalSessions(\|func (p \*Pier) StopReaper(" modules/pier/export_test.go` prints 3 and `grep -c "stopReap" modules/pier/pier.go` prints at least 1
|
||||
- `grep -c "func TestPierReaperSmoke(" modules/pier/reaper_smoke_test.go` prints 1
|
||||
- `grep -ci "reap\|expired" modules/pier/README.md` prints at least 2
|
||||
</acceptance_criteria>
|
||||
<done>An idle, abandoned stateful session is closed and forgotten at the store's TTL on every instance holding a copy, with an `expired` audit line; the smoke proves it end to end through a real SDK client.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Atomic per-binding reservation and no router-wide lock across guard or database I/O</name>
|
||||
<files>modules/pier/store.go, modules/pier/store_memory.go, modules/pier/store_redis.go, modules/pier/session.go, modules/pier/stateless.go</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections A-WR-03 and A-WR-07
|
||||
- modules/pier/store.go (`Store`, `updater`), store_memory.go (`Count`, `Put`, `Update`), store_redis.go (`Count` with `SMEMBERS` and `EXISTS`, the `MULTI` in `Put`, key layout under cooler's prefix, the `lazyStore` wrapper and how it forwards `updater`)
|
||||
- modules/pier/session.go: `serveNew`, `lookup` (rehydration path calling `connect` under `sr.mu`), `connect`
|
||||
- modules/pier/stateless.go: `getServer` (builds the server under `sp.mu`)
|
||||
- the plan 05 commit 1111828 (`git show 1111828 --stat` and its diff of store.go): the `updater` pattern to mirror
|
||||
</read_first>
|
||||
<action>
|
||||
**P-25 (A-WR-03).** In store.go, declare an unexported `reserver` interface:
|
||||
- `Reserve(ctx context.Context, binding, id string, rec Record, max int, ttl time.Duration) (bool, error)`
|
||||
- `Release(ctx context.Context, binding, id string) error`
|
||||
|
||||
Document it as the atomic form of `Count` then `Put`.
|
||||
|
||||
Implementations:
|
||||
- **memoryStore:** `Reserve` runs under `m.mu`. It sweeps, counts the binding's live records, refuses at `max` and writes `rec` with the TTL. `Release` deletes the record.
|
||||
- **redisStore:** `Reserve` is one `redis.NewScript` Lua script over the binding set and the record key. The script drops set members whose record key no longer exists, refuses when `SCARD >= max`, and otherwise runs `SADD` plus `SET <record> <json> PX <ttl>`. Keep the existing key layout so `Count`, `Get`, `Delete` and the TTLs stay compatible. `Release` does `SREM` plus `DEL`.
|
||||
- **lazyStore:** forwards both methods, the same way it forwards `updater`.
|
||||
|
||||
In `serveNew`, replace the `Count` / `Put` pair:
|
||||
- Reserve through the `reserver` when the store implements it. A refusal is the existing 429 body. A store error is the existing `storeUnavailable` answer.
|
||||
- Otherwise fall back to the present `Count` then `Put` sequence.
|
||||
- On a connect error, or an initialize that leaves `InitializeParams() == nil`, call `Release` so the slot frees.
|
||||
|
||||
**A-WR-07.**
|
||||
- In `serveNew` and in `lookup`'s rehydration path, call `sr.connect(...)` with no router lock held. Then take `sr.mu`: if `sr.local[sid]` is already set by a concurrent request, close the newly built session and use the existing one; otherwise insert. Release the lock before serving.
|
||||
- In stateless.go `getServer`, look up under `sp.mu`; on a miss, release the lock, build the server with `newServer`, take the lock again, and either adopt an entry another request inserted (dropping the new server) or insert and run the capacity eviction.
|
||||
- `matching`, `closeLocal` and the fan-out paths keep their short critical sections.
|
||||
- Never hold `sr.mu` or `sp.mu` while calling a guard, a resolver or the store.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pier/... && go test -count=1 -short -race ./modules/pier/... && go test -count=1 -short -tags summercms_mcp ./modules/pier/... && go test -count=1 -short -run '^(TestSessions|TestFanOut|TestPierSessionsSmoke|TestPierReaperSmoke)$' -v ./modules/pier/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 4</automated>
|
||||
<fails_when>non-zero exit, a data race report, "FAIL" in the output, or fewer than 4 top-level PASS lines</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "type reserver interface" modules/pier/store.go` prints 1
|
||||
- `grep -c "func (m \*memoryStore) Reserve(\|func (m \*memoryStore) Release(" modules/pier/store_memory.go` prints 2
|
||||
- `grep -c "NewScript" modules/pier/store_redis.go` prints at least 1 and `grep -c ") Reserve(" modules/pier/store_redis.go` prints at least 2 (redisStore and the lazyStore forwarder, both in store_redis.go)
|
||||
- `grep -v '^\s*//' modules/pier/session.go | grep -c "Reserve("` prints at least 1
|
||||
- `go test -count=1 -short -race ./modules/pier/...` reports no race
|
||||
</acceptance_criteria>
|
||||
<done>The max_per_binding cap holds under concurrency on both stores; no router-wide pier lock is held across guard, resolver or store I/O; the existing session, fan-out and reaper tests stay green under -race.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Identity widening on return, fan-out for stateless-only Redis instances, stateless listen re-check and LRU close, personal-token binding</name>
|
||||
<reversibility rating="costly">The `pact.MCPPersonalTokenResolver` contract text now requires TokenID; a third-party resolver written against the old text must set it (published framework API, documented in pact README).</reversibility>
|
||||
<files>modules/pier/session.go, modules/pier/stateless.go, modules/pier/pier.go, modules/pier/identity.go, modules/pact/mcp.go, modules/pact/README.md, modules/pier/README.md</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections A-WR-04, A-WR-05, A-WR-06, A-WR-09, A-IN-03
|
||||
- modules/pier/identity.go: `Identity`, `subjectFor`, `has`, `writes`, `resolvePersonalToken` (binding `pat:user:<TokenID>`)
|
||||
- modules/pier/events.go: `handleEvent`, `recomputeSession`, `recomputeStateless` (the diff to reuse); `applyDiff` or its equivalent in session.go
|
||||
- modules/pier/stateless.go: `getServer`, `evict`, `statelessEntry`, `ServeHTTP`; modules/pier/pier.go `route`, `newStore` (`lazyStore.open`), `Mount`
|
||||
- modules/pier/session.go: `serveStream` (the periodic bearer re-check to mirror), `peekMethods`, `lookup`
|
||||
- modules/pact/mcp.go: the `MCPPersonalTokenResolver` doc comment and `MCPSubject`
|
||||
</read_first>
|
||||
<action>
|
||||
**P-26 (A-WR-04).** Add `func (id Identity) fingerprint() string` in identity.go. It encodes the sorted scopes, both subjects (guard, user, client, token, and their sorted scopes), `ceiling` and `TokenKind`.
|
||||
- Store the fingerprint on `localSession` and on `statelessEntry` when each is built.
|
||||
- In `lookup` (stateful) and on a `getServer` hit (stateless), compare the request identity's fingerprint. When it differs, under the session's or entry's own mutex (never `sr.mu` or `sp.mu`), recompute `p.catalog.allowed(ctx, id)`, apply the same add/remove diff `recomputeSession` and `recomputeStateless` use, and store the new identity and fingerprint.
|
||||
- A narrower identity still relies on the receiving middleware filter, which stays unchanged.
|
||||
|
||||
**A-WR-05.** When the store is Redis, `Mount` starts a background warm-up. It calls the `lazyStore`'s open with backoff (1 s doubling to 30 s, logging each failure once per backoff step) until the store is open, and with it the `mcp:events` subscription.
|
||||
- `route` also triggers the lazy open on the first request on any path, without blocking it. Stateless requests never wait for Redis.
|
||||
- Stateful requests keep the 503 answer while the store is down.
|
||||
|
||||
**A-WR-06.**
|
||||
- In `getServer`'s capacity eviction, close the evicted entry's SDK sessions the way `evict` does, outside `sp.mu`.
|
||||
- In `statelessPath.ServeHTTP`, for a POST, read the body (it is already limited by `bodyLimit`) and restore it. When `peekMethods` contains `subscriptions/listen`, serve the request with a cancellable context and a ticker every `p.recheck` that re-resolves the request's bearer through `p.identities.resolve`. A resolve failure cancels the context, so the SDK ends the long-lived POST. This mirrors `serveStream`.
|
||||
|
||||
**A-WR-09 and A-IN-03.**
|
||||
- `resolvePersonalToken` refuses a subject whose `TokenID == 0`, with the same `ErrUnauthorized` path as `UserID == 0`.
|
||||
- Rewrite the `pact.MCPPersonalTokenResolver` doc in pact/mcp.go:
|
||||
- one resolver per application (published through `app.Lookup`);
|
||||
- false means "not this resolver's prefix" and pier answers unauthorized;
|
||||
- `TokenID` must identify the token row, because it keys the session binding.
|
||||
- Update the matching row in modules/pact/README.md and the personal-token paragraph in modules/pier/README.md in the same commit.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pier/... ./modules/pact/... && go test -count=1 -short -race ./modules/pier/... ./modules/pact/... && go test -count=1 -short -tags summercms_mcp ./modules/pier/... ./modules/surf/... && go test -count=1 -short -run '^(TestToolsList|TestFanOut|TestPierStatelessSmoke|TestPierFanOutSmoke)$' -v ./modules/pier/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 4</automated>
|
||||
<fails_when>non-zero exit, a data race report, "FAIL" in the output, or fewer than 4 top-level PASS lines</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func (id Identity) fingerprint() string" modules/pier/identity.go` prints 1
|
||||
- `grep -v '^\s*//' modules/pier/stateless.go | grep -c "fingerprint()"` prints at least 1 and `grep -v '^\s*//' modules/pier/session.go | grep -c "fingerprint()"` prints at least 1
|
||||
- `grep -c "subscriptions/listen\|methodListen" modules/pier/stateless.go` prints at least 1
|
||||
- `grep -v '^\s*//' modules/pier/identity.go | grep -c "TokenID == 0"` prints at least 1
|
||||
- `grep -c "TokenID" modules/pact/mcp.go` prints at least 2 and the resolver doc no longer says another resolver is tried (`grep -c "next resolver is tried" modules/pact/mcp.go` prints 0)
|
||||
</acceptance_criteria>
|
||||
<done>A returning binding with more reach sees its new tools at once; a Redis instance serving only stateless clients receives fan-out; stateless listen streams end when their bearer stops resolving or their server is evicted; personal-token sessions can never share a binding; the resolver contract says what pier actually does.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: Dispatch and catalog hardening (path values, fixed error text, big integers, Host and forwarding headers, embedded fields, guard list), the prompt write ceiling, and cooler's doc comments</name>
|
||||
<reversibility rating="costly">`pact.MCPPrompt.Writes` is a new field of a published capability (D-28 costly); its zero value keeps today's behaviour.</reversibility>
|
||||
<files>modules/pier/dispatch.go, modules/pier/catalog.go, modules/pier/filter.go, modules/pact/mcp.go, modules/pact/README.md, modules/cooler/cooler.go, modules/pier/README.md, docs/services/mcp.md</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections A-WR-01, A-WR-02, A-WR-08, A-IN-02, A-IN-04, A-IN-05, A-IN-07, A-IN-08 and lane C's C-IN-01
|
||||
- modules/pier/dispatch.go: `callInfo` and its capture, `run` (argument split, `scalarString`, `queryStrings`, the guard dispatch error branch, `bouncer.WithDispatch`, the `httptest.NewRequestWithContext` build, `SetPathValue`)
|
||||
- modules/pier/catalog.go: `compileTool` (segment ↔ `path:` field check, the GET/DELETE body-field refusal), `inputFields` (the anonymous-field skip), the reflected `schema.Required`
|
||||
- modules/pier/filter.go `allowsPrompt`, `allowsTool`; modules/pact/mcp.go `MCPPrompt`, `MCPTool` (ReadOnly and Destructive overrides as the style model)
|
||||
- modules/cooler/cooler.go lines 345-370 (`KeyPrefix` and `keyPrefix` doc comments)
|
||||
- docs/services/mcp.md (prompts paragraph, tool argument rules) and modules/pier/README.md (catalog boot errors list)
|
||||
</read_first>
|
||||
<action>
|
||||
**A-WR-01 (P-27).** In `run`, for every `argPath` value:
|
||||
- split it on `/` and refuse any empty, `.` or `..` segment;
|
||||
- for a single-segment field, refuse any `/` (as today);
|
||||
- answer `pier: invalid arguments: "<name>" must not contain empty, . or .. segments` as a tool error before any dispatch.
|
||||
|
||||
**A-WR-02.**
|
||||
- In `compileTool`, after the schema is reflected, fail boot with `<prefix>: path field "<name>" must be required (drop omitempty/omitzero)` when a `path:` field is missing from `schema.Required`.
|
||||
- At runtime, refuse a missing path value before the request is built (defence in depth).
|
||||
|
||||
**A-WR-08.** Replace the branch that turns a `MCPDispatch` error into tool text built from the error's own message:
|
||||
- log `pier: guard dispatch failed` server-side with tool, guard and error;
|
||||
- return the fixed tool error `pier: the tool could not be run for this caller`;
|
||||
- keep a specific message only for `pact.ErrMCPTokenInvalid` and the provider sentinel errors dispatch.go already distinguishes.
|
||||
|
||||
**A-IN-04.** Decode path and query scalars with `json.NewDecoder(bytes.NewReader(raw))` and `UseNumber()`, and render a `json.Number` as its literal string.
|
||||
|
||||
**A-IN-05.** Capture the outer `r.Host`, `X-Forwarded-Proto` and `X-Forwarded-Host` in `callInfo`. Set `req.Host` and copy both headers onto the dispatched request, next to X-Forwarded-For and X-Real-IP. The inner request still carries no Authorization or Cookie.
|
||||
|
||||
**A-IN-07.** In `compileTool`, fail boot when a GET or DELETE tool's input struct has an anonymous (embedded) field without a `path`, `query` or `json:"-"` tag. Name the field in the error.
|
||||
|
||||
**A-IN-08.** After `MCPDispatch`, refuse the call with a fixed tool error and a warning log when the answer contradicts the tool's guard:
|
||||
- `disp.Guards` contains `BackendGuard` while the tool's guard is not backend;
|
||||
- or `principal.Backend != (t.guardName == BackendGuard)`.
|
||||
|
||||
**C-IN-01 framework part (P-28).**
|
||||
- Add `Writes bool` to `pact.MCPPrompt`, with a doc comment: the prompt directs write tools, so pier lists it only for an identity that may write.
|
||||
- In filter.go `allowsPrompt`, return false when `p.decl.Writes && !id.writes()`, before the guard check.
|
||||
|
||||
**A-IN-02.** In modules/cooler/cooler.go, move the original `keyPrefix` comment block back directly above `func keyPrefix`, so `go doc` shows each function's own comment.
|
||||
|
||||
**Docs, same commit as the code:**
|
||||
- modules/pact/README.md: the `pact.MCPPrompt` row names `Writes`.
|
||||
- modules/pier/README.md: the boot-error list gains required path fields and embedded fields on GET/DELETE; the dispatch section gains the path-value rule, Host and forwarding headers, and the fixed guard-failure text.
|
||||
- docs/services/mcp.md: the prompts paragraph explains `Writes`; the arguments section states the path rules.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short ./modules/pier/... ./modules/pact/... ./modules/cooler/... && go test -count=1 -short -tags summercms_mcp ./modules/pier/... ./modules/surf/... && go doc ./modules/cooler KeyPrefix | sed -n 4p | grep -q '^ KeyPrefix returns' && go doc -u ./modules/cooler keyPrefix | grep -A1 '^func keyPrefix' | grep -q 'keyPrefix returns' && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --docs && bash scripts/check-phase19.7.sh --marker</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or a gate line printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "must be required" modules/pier/catalog.go` prints at least 1
|
||||
- `grep -c "UseNumber()" modules/pier/dispatch.go` prints at least 1 and `grep -c "X-Forwarded-Proto\|X-Forwarded-Host" modules/pier/dispatch.go` prints at least 2
|
||||
- `grep -c "the tool could not be run for this caller" modules/pier/dispatch.go` prints 1
|
||||
- `grep -c "Writes" modules/pact/mcp.go` prints at least 1 and `grep -v '^\s*//' modules/pier/filter.go | grep -c "decl.Writes"` prints 1
|
||||
- `go doc ./modules/cooler KeyPrefix | sed -n 4p` starts with ` KeyPrefix returns`, and `go doc -u ./modules/cooler keyPrefix` prints a `keyPrefix returns` comment directly under `func keyPrefix`
|
||||
- `grep -c "Writes" modules/pact/README.md docs/services/mcp.md` prints at least 1 per file
|
||||
- `git diff --quiet 2527498 -- go.mod go.sum admin/package-lock.json` (no dependency change since the gap-closure planning commit)
|
||||
</acceptance_criteria>
|
||||
<done>pier delivers only path values the mux could deliver, never leaks a provider or database error to an agent, keeps big integer ids exact, forwards Host and scheme, refuses embedded GET/DELETE fields and contradictory guard answers at the right time, and lets a plugin keep a write-directing prompt away from read-only grants; the gate's go, docs and marker stages are green.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**Framework code (summercms.go, local commits on master):**
|
||||
- `modules/pier`:
|
||||
- session reaper (`reap`, `reapOnce`), `expired` and `ephemeral` audit labels;
|
||||
- `reserver` with memory and Redis `Reserve`/`Release`;
|
||||
- lock-free connect and stateless build;
|
||||
- `Identity.fingerprint` and the widening diff;
|
||||
- Redis warm-up at mount;
|
||||
- stateless listen re-check and closing on LRU eviction;
|
||||
- refusal of a personal-token subject without a TokenID;
|
||||
- path-value and path-field rules, fixed guard-failure text, `UseNumber`, Host and forwarding headers, the embedded-field refusal, the guard-list check;
|
||||
- the prompt write ceiling.
|
||||
- `modules/pact`: `MCPPrompt.Writes`; the corrected `MCPPersonalTokenResolver` contract.
|
||||
- `modules/cooler`: corrected doc comments.
|
||||
|
||||
**Docs:** `modules/pier/README.md`, `modules/pact/README.md`, `docs/services/mcp.md`.
|
||||
|
||||
**Test:** `modules/pier/reaper_smoke_test.go` (`TestPierReaperSmoke`), plus the export_test seams `ReapNow` and `LocalSessions`.
|
||||
|
||||
**Decisions:** P-24 to P-28 (in the objective above).
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| MCP client to /mcp | any agent presents a bearer, a session id and JSON-RPC bodies (tool arguments become path, query and body of a plugin route) |
|
||||
| pier to plugin routes (in-process dispatch) | pier hands a compiled route a request it built, with path values set directly (no mux cleaning) |
|
||||
| instances to the shared session store | Redis holds session records, reservations and the fan-out channel |
|
||||
| guard providers to pier | providers answer dispatch principals and guard lists that pier turns into the marker |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-42 | Denial of service | abandoned stateful sessions (local SDK server, transport, reader goroutines) | high | mitigate | P-24 reaper closes every local copy whose record expired, at min(idle_ttl/2, 1m); `expired` audit line; TestPierReaperSmoke here, TestSessionReaper in plan 09 |
|
||||
| T-19.7-43 | Denial of service | concurrent initialize past mcp.sessions.max_per_binding | medium | mitigate | P-25 atomic `Reserve` (memory under lock, Redis Lua), `Release` on failure; plan 09 TestSessionReserve fires concurrent initializes |
|
||||
| T-19.7-44 | Tampering | path values the mux never delivers (`..`, `.`, empty, `/` in one segment, an omitted optional path field) | high | mitigate | P-27: refusal before dispatch; path fields must be required at boot; plan 09 TestDispatchHardening and TestCatalogPathFields |
|
||||
| T-19.7-45 | Information disclosure | raw provider or database errors (pgx address, database and user names) in tool results | medium | mitigate | fixed tool text, error logged server-side only |
|
||||
| T-19.7-46 | Spoofing | personal-token sessions sharing the binding `pat:user:0` (cap exhaustion, cross-user DELETE) | medium | mitigate | `resolvePersonalToken` refuses TokenID 0; contract text requires TokenID |
|
||||
| T-19.7-47 | Elevation of privilege | stateless listen streams and stateless-only Redis instances outliving a revocation | medium | mitigate | warm-up subscription at mount; periodic bearer re-check on subscriptions/listen; LRU eviction closes sessions |
|
||||
| T-19.7-48 | Denial of service | router-wide locks held across guard and database I/O | medium | mitigate | connect and server build outside `sr.mu` and `sp.mu`, insert with re-check; -race clean |
|
||||
| T-19.7-49 | Elevation of privilege | a provider naming the backend guard for a frontend tool's principal | low | mitigate | pier refuses a dispatch whose guard list or principal kind contradicts the tool's guard |
|
||||
| T-19.7-50 | Information disclosure | a write-directing prompt listed for a read-only grant | low | mitigate | `MCPPrompt.Writes` under the read/write ceiling (P-28) |
|
||||
| T-19.7-SC | Tampering | package installs | low | mitigate | no package is added: go.mod, go.sum and admin/package-lock.json unchanged (acceptance criterion of Task 4) |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go vet ./... && go test -count=1 -short ./...` in the framework, plus `go test -count=1 ./modules/pier/...` on a Docker host (no change expected; pier has no Postgres suite)
|
||||
- `go test -count=1 -short -race ./modules/pier/...` is clean
|
||||
- `bash scripts/check-phase19.7.sh --go`, `--docs` and `--marker` print PASS
|
||||
- `cd examples/hello && go test ./...` stays green (the separate workspace module)
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- A-CR-01 and A-WR-01..A-WR-09 are fixed, each in a commit whose subject starts with `fix(pier)` (or `fix(pact)` / `docs(cooler)` for the contract and doc-only parts); A-IN-01..A-IN-08 are fixed
|
||||
- `pact.MCPPrompt.Writes` exists with docs, ready for Journal in plan 08
|
||||
- No exported pier, pact or cooler identifier is removed or changes signature (the gate's docs and marker stages and `go vet` stay green; fonoteka.go and sm-bm-app still build against the local framework in plan 09's consumers stage)
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-06-SUMMARY.md` when done, with every commit sha mapped to its finding ids. Commit the SUMMARY separately as a planning doc.
|
||||
|
||||
Release rule: this plan does not tag, push or deploy. Every repository works against the local framework (go.work, or `replace ../summercms.go`), and every plugin's go.mod `require` line stays at its current version. The plans may commit locally in every repository. The releases happen only after phase verification, in this order: framework v0.5.0, then the plugin tags that require it, then the application bumps.
|
||||
</output>
|
||||
189
.planning/phases/19.7-generic-mcp-module/19.7-06-SUMMARY.md
Normal file
189
.planning/phases/19.7-generic-mcp-module/19.7-06-SUMMARY.md
Normal file
@@ -0,0 +1,189 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 06
|
||||
subsystem: api
|
||||
status: complete
|
||||
gap_closure: true
|
||||
tags: [pier, mcp, sessions, redis, lua, concurrency, dispatch, pact, cooler, gap-closure]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-02
|
||||
provides: modules/pier (catalog, dispatch, identity, sessions, fan-out, stateless path)
|
||||
- phase: 19.7-05
|
||||
provides: the updater pattern (1111828), helpers_test.go fakes, scripts/check-phase19.7.sh
|
||||
provides:
|
||||
- session reaper (reap, reapOnce) started at Mount, `expired` and `ephemeral` audit labels, GET stream ends when the record is gone
|
||||
- unexported reserver (Reserve, Release) on the memory and Redis stores (Lua script), used by serveNew
|
||||
- lock-free server build in serveNew, lookup rehydration and stateless getServer
|
||||
- Identity.fingerprint and re-filtering of a cached server when a binding returns with a different identity
|
||||
- Redis store warm-up at Mount plus a non-blocking kick on every request
|
||||
- stateless subscriptions/listen bearer re-check and session close on LRU eviction
|
||||
- refusal of a personal-token subject without TokenID; corrected pact.MCPPersonalTokenResolver contract
|
||||
- path-value and path-field rules, fixed guard-failure text, UseNumber, Host and forwarding headers, embedded-field refusal, guard-list check
|
||||
- pact.MCPPrompt.Writes under the read/write ceiling
|
||||
- cooler KeyPrefix / keyPrefix doc comments separated
|
||||
affects: [19.7-07 (token-specific events build on session.go/stateless.go), 19.7-08 (Journal sets MCPPrompt.Writes), 19.7-09 (named tests pin every fix), framework v0.5.0]
|
||||
|
||||
actuals:
|
||||
tokens: 20336
|
||||
tasks: 4
|
||||
commits: 6
|
||||
plan_head_before: d18d8f0dc206392726e225c2f5cc1340d14463c1
|
||||
plan_head_after: 95f177b1e0dbc27483d4ece9dc88751cb226f2fd
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Unexported capability interface next to updater (reserver), checked with a type assertion, so the exported pier.Store does not change"
|
||||
- "Build outside the router lock, then insert-or-adopt under it"
|
||||
- "Identity fingerprint decides when a cached per-identity server is re-filtered"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/pier/reaper_smoke_test.go
|
||||
modified:
|
||||
- modules/pier/session.go
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/audit.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/store_memory.go
|
||||
- modules/pier/store_redis.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/identity.go
|
||||
- modules/pier/events.go
|
||||
- modules/pier/dispatch.go
|
||||
- modules/pier/catalog.go
|
||||
- modules/pier/filter.go
|
||||
- modules/pier/backend_guard.go
|
||||
- modules/pier/export_test.go
|
||||
- modules/pier/README.md
|
||||
- modules/pact/mcp.go
|
||||
- modules/pact/README.md
|
||||
- modules/cooler/cooler.go
|
||||
- docs/services/mcp.md
|
||||
|
||||
key-decisions:
|
||||
- "P-24: a reaper goroutine started at Mount closes every local session whose store record is gone every min(idle_ttl/2, 1m) (floor 1 s); the store TTL stays the single source of truth across instances; stopped through Pier.stopReap (no backpack shutdown hook yet)"
|
||||
- "P-25: atomic per-binding reservation through an unexported reserver interface; Redis uses one Lua script (prune, count, SET PX, SADD, PEXPIRE) on the existing key layout"
|
||||
- "P-26: Identity.fingerprint (sorted scopes, both subjects with guard/user/client/token/scopes, ceiling, token kind); a changed fingerprint re-runs the event add/remove diff under the session's or entry's own mutex, with context.WithoutCancel so a client hang-up cannot leave the set filtered by cancelled guard checks"
|
||||
- "P-27: path fields must be required at boot; at runtime a missing value, an empty, . or .. segment, or / in a single segment is a tool error before dispatch"
|
||||
- "P-28: pact.MCPPrompt.Writes (additive) puts a prompt under the read/write ceiling"
|
||||
- "Guard dispatch errors answer the fixed text `pier: the tool could not be run for this caller`; only pact.ErrMCPTokenInvalid and a new errSubjectUnavailable sentinel (backend user unknown or deactivated) keep their own fixed texts"
|
||||
|
||||
patterns-established:
|
||||
- "Background lifecycle goroutines of pier (reaper, Redis warm-up) share the context whose cancel func is Pier.stopReap"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-3, D-10, D-11, D-13, D-17, D-19, D-20, D-25, D-26, D-27, D-28, D-32]
|
||||
|
||||
duration: 23min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 06: Lane A gap closure in pier Summary
|
||||
|
||||
This plan closes lane A of the code review in the framework's MCP module. Abandoned stateful sessions are now reaped at the store TTL. The per-binding cap is reserved atomically (memory store under its lock, Redis through a Lua script). No router-wide lock is held across guard or database I/O. A binding that returns with a wider identity is re-filtered on that request. Redis instances subscribe to fan-out when they mount. Stateless listen streams are re-verified, and an evicted stateless server closes its streams. Personal-token subjects must carry a TokenID. Dispatch only hands routes path values the HTTP mux could produce, and guard failures answer with fixed text. Prompts gain a `Writes` ceiling.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 23 min
|
||||
- **Completed:** 2026-10-23
|
||||
- **Tasks:** 4 of 4
|
||||
- **Files modified:** 20 (1 created)
|
||||
|
||||
## Commits and findings
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| 2bf9dca `fix(pier): reap stateful sessions whose store record expired` | 1 (tracer) | A-CR-01, A-IN-01, A-IN-06 |
|
||||
| c1c0c77 `fix(pier): reserve session slots atomically and build servers outside router locks` | 2 | A-WR-03, A-WR-07 |
|
||||
| 2404572 `fix(pier): widen returning identities, warm the Redis store, end stateless listen streams, refuse personal tokens without a TokenID` | 3 | A-WR-04, A-WR-05, A-WR-06, A-WR-09, A-IN-03 |
|
||||
| 104db99 `fix(pier): refuse path values the mux never delivers and harden dispatch` | 4 | A-WR-01, A-WR-02, A-WR-08, A-IN-04, A-IN-05, A-IN-07, A-IN-08 |
|
||||
| 211cec1 `fix(pact): add MCPPrompt.Writes so a write-directing prompt sits under the read/write ceiling` | 4 | C-IN-01 (framework part) |
|
||||
| 95f177b `docs(cooler): give KeyPrefix and keyPrefix their own doc comments` | 4 | A-IN-02 |
|
||||
|
||||
All lane A findings are covered: A-CR-01, A-WR-01..09 and A-IN-01..08.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Reaper (Task 1).**
|
||||
- `sessionRouter.reap` and `reapOnce` run from `Mount` and close each local copy whose record has expired, logging `expired`.
|
||||
- A store error keeps the copy and is logged once per pass.
|
||||
- `serveStream`'s re-check ends the stream and closes the local copy when the record is gone.
|
||||
- Ephemeral tool calls log the session as `ephemeral`.
|
||||
- `TestPierReaperSmoke` proves the flow with a real SDK client. New seams: `ReapNow`, `LocalSessions`, `StopReaper`.
|
||||
- **Reservation and locks (Task 2).**
|
||||
- `reserver` with memory and Redis `Reserve`/`Release`, plus `lazyStore` forwarders.
|
||||
- `serveNew` reserves first, then connects, and releases the slot on a connect or initialize failure.
|
||||
- `serveNew`, `lookup` rehydration and the stateless `getServer` build the server with no `sr.mu`/`sp.mu` held, then insert or adopt.
|
||||
- **Identity and lifecycle (Task 3).**
|
||||
- `fingerprint()` is stored on `localSession` and `statelessEntry`; the `widen` helper re-filters on a change.
|
||||
- `lazyStore.warm` (backoff 1 s to 30 s) starts at Mount, and `kick()` runs from `route`.
|
||||
- The stateless `ServeHTTP` re-checks the bearer every `recheck` for `subscriptions/listen` POSTs.
|
||||
- LRU eviction closes the evicted server's sessions.
|
||||
- `resolvePersonalToken` refuses `TokenID == 0`, and the resolver contract text is rewritten.
|
||||
- **Dispatch hardening and prompt ceiling (Task 4).** Covers every item listed in the commit table, and `allowsPrompt` honours `decl.Writes`.
|
||||
|
||||
## Verification
|
||||
|
||||
- `go vet ./...` and `go vet -tags summercms_mcp ./...` are clean.
|
||||
- `go test -count=1 -short ./...` is green, and so is `-race` on `./modules/pier/...`.
|
||||
- `go test -count=1 ./modules/pier/... ./modules/surf/...` passes with Docker available.
|
||||
- `cd examples/hello && go test ./...` is green.
|
||||
- `scripts/check-phase19.7.sh --go`, `--docs` and `--marker` all PASS.
|
||||
- `summer docs:build --check` reports no problems.
|
||||
- `go.mod`, `go.sum` and `admin/package-lock.json` are unchanged since 2527498.
|
||||
- Commit 104db99 was checked on its own in a temporary detached worktree (vet, short tests, docs check), because Task 4 was split into three commits.
|
||||
- Ad-hoc checks were run and then deleted, since plan 09 owns the named tests:
|
||||
- 30 concurrent initializes with `max_per_binding: 2` gave exactly 2 OK and 28 429 on both the memory store and miniredis.
|
||||
- A read grant followed by a read+write grant on the same binding gained the write tool on both the stateful and the stateless path.
|
||||
- `9007199254740993` survived as a path value and as a query value.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 2 - Missing critical] Sentinel for the backend guard's "unknown or deactivated" answer**
|
||||
- **Found during:** Task 4 (A-WR-08)
|
||||
- **Issue:** The plan says to keep specific messages for "the provider sentinel errors dispatch.go already distinguishes", but dispatch.go distinguished none. The backend guard's "unknown or deactivated" answer was a plain `fmt.Errorf`.
|
||||
- **Fix:** Added `errSubjectUnavailable` in `modules/pier/backend_guard.go`, which the backend guard now wraps. Dispatch maps it, and `pact.ErrMCPTokenInvalid`, to fixed texts. Every other error gets the generic fixed text and is logged server-side.
|
||||
- **Files modified:** modules/pier/backend_guard.go (not in the plan's file list)
|
||||
- **Commit:** 104db99
|
||||
|
||||
**2. [Rule 2 - Missing critical] Widening uses a non-cancellable context**
|
||||
- **Found during:** Task 3 (A-WR-04)
|
||||
- **Issue:** `catalog.allowed` hides an item on any guard error. If the request context were cancelled mid-recompute, the server would be re-filtered with tools missing and the new fingerprint stored, so the narrower set would stick.
|
||||
- **Fix:** `widen` calls `allowed` with `context.WithoutCancel(ctx)`.
|
||||
- **Files modified:** modules/pier/events.go
|
||||
- **Commit:** 2404572
|
||||
|
||||
**3. [Rule 3 - Blocking] The ephemeral label survives `sessionPrefix` and the SDK session id**
|
||||
- **Found during:** Task 1 (A-IN-06)
|
||||
- **Issue:** An ephemeral call's SDK session id is `""`, the same as a stateless call. A plain label would also have been cut to 8 characters by `sessionPrefix`.
|
||||
- **Fix:**
|
||||
- `serveEphemeral` marks the per-request token info's `callInfo.session` as `ephemeral`.
|
||||
- `toolHandler` overrides `info.session` only with a non-empty SDK session id.
|
||||
- `sessionPrefix` passes the `ephemeral` label through untruncated.
|
||||
- **Files modified:** modules/pier/session.go, modules/pier/audit.go
|
||||
- **Commit:** 2bf9dca
|
||||
|
||||
**4. [Docs rule] Doc updates outside the listed tasks' file sets**
|
||||
- In Task 3, `docs/services/mcp.md` gained the resolver/TokenID sentence plus one sentence each on the reaper and on widening. The CLAUDE.md rule requires docs to change in the same commit as an exported contract change.
|
||||
- Task 4 was split into three commits (pier hardening, pact `Writes`, cooler docs) so each is one logical change and carries the commit-type prefix the success criteria name.
|
||||
|
||||
### Tests changed for old behaviour
|
||||
|
||||
None. No existing test relied on the old behaviour: no fixture uses an optional path field, a shared `pat:user:0` binding, an embedded GET/DELETE field or raw dispatch error text. Every regression pin passed unchanged.
|
||||
|
||||
## Notes for later plans
|
||||
|
||||
- Behaviour change for consumers: Mount now starts two background goroutines (the reaper, and for the Redis store a warm-up that dials `redis.url` with a backoff). `route:list` and tests on the Redis store therefore dial in the background. The pier README and Mount's doc comment say so.
|
||||
- Consumer impact of the new boot errors: no sibling repository (fonoteka.go, sm-*-app, sm-journal-plugin, the user plugin copies) declares a path field with `omitempty`/`omitzero` or an embedded struct on a GET/DELETE input. Plan 09's consumers stage confirms this by building them.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: modules/pier/reaper_smoke_test.go
|
||||
- FOUND: 2bf9dca, c1c0c77, 2404572, 104db99, 211cec1, 95f177b
|
||||
522
.planning/phases/19.7-generic-mcp-module/19.7-07-PLAN.md
Normal file
522
.planning/phases/19.7-generic-mcp-module/19.7-07-PLAN.md
Normal file
@@ -0,0 +1,522 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 07
|
||||
type: execute
|
||||
wave: 2
|
||||
depends_on: ["19.7-06"]
|
||||
gap_closure: true
|
||||
files_modified:
|
||||
- modules/bouncer/mint.go
|
||||
- modules/bouncer/refresh.go
|
||||
- modules/bouncer/jwt.go
|
||||
- modules/bouncer/auth_time_smoke_test.go
|
||||
- modules/bouncer/README.md
|
||||
- docs/services/authentication.md
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/mcp.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/token_scopes.go
|
||||
- docs/plugins/registration.md
|
||||
- docs/backend/users-and-permissions.md
|
||||
- .planning/notes/2026-10-23-frontend-token-scopes.md
|
||||
- modules/pier/store.go
|
||||
- modules/pier/events.go
|
||||
- modules/pier/session.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/host.go
|
||||
- modules/pier/README.md
|
||||
- modules/surf/pier_on.go
|
||||
- modules/towel/context.go
|
||||
- modules/towel/README.md
|
||||
- modules/cabana/account_tokens.go
|
||||
- modules/cabana/subject_events.go
|
||||
- modules/cabana/token_resolver.go
|
||||
- modules/cabana/account_contributions.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- modules/cabana/README.md
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml
|
||||
- modules/phrasebook/backend/lang/pl/lang.yaml
|
||||
- docs/services/mcp.md
|
||||
- admin/openapi/admin.json
|
||||
- admin/src/api/schema.d.ts
|
||||
- admin/src/app/hotkeys.ts
|
||||
- admin/src/components/account/AccountContributions.vue
|
||||
- admin/tests/fixtures/lang.json
|
||||
- modules/boardwalk/dist
|
||||
autonomous: true
|
||||
requirements: [SC-4, D-04, D-05, D-17, D-19, D-26, D-27, D-34, E-2]
|
||||
|
||||
estimate:
|
||||
tokens: 130000
|
||||
raw_tokens: 130000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A frontend or backend token minted at sign-in carries an auth_time claim; POST /refresh (any audience) copies it unchanged into the rotated token, and a token that had none is refreshed without one; plugins read it through bouncer.VerifyAuthTime, which applies the same signature, audience and expiry checks as VerifyClaims (C-CR-02 framework part, D-05)"
|
||||
- "A plugin declares member (frontend) personal-token scopes through pact.HasFrontendTokenScopes, a separate capability that cabana's admin token catalog never reads; pact.ValidTokenScopeName is the one name rule both catalogs use, and cabana's g15_ catalog behaves exactly as before (E-2 framework seam, decision P-30)"
|
||||
- "Revoking one admin personal token ends only the MCP sessions opened with that token; an event naming a client ends only that client's OAuth sessions; an event naming neither ends every session of the subject as before (B-WR-04, D-26, D-27)"
|
||||
- "A failed g15_ token attempt at /mcp is logged with the client address, and a resolver plugin can read the address from the context (B-IN-04)"
|
||||
- "An account contribution action can only hand the admin an http(s) or same-origin relative URL; the server drops anything else and the SPA refuses to render or open it (B-WR-03)"
|
||||
- "One contributing plugin's Status or Applies error no longer removes the other My account sections: the failing section is sent with error true, and a failed GET shows a toast (B-WR-06)"
|
||||
- "A typed character or Esc inside a plugin field type's shadow DOM never triggers a plain-key shortcut, and Ctrl/Cmd+S or Ctrl/Cmd+Enter commits a pending taglist draft before saving (B-WR-01, B-WR-02)"
|
||||
- "The published admin API contract says a prompted record action accepts payload, and admin.json, schema.d.ts and the committed admin dist match their sources (B-WR-05)"
|
||||
artifacts:
|
||||
- path: "modules/bouncer/mint.go"
|
||||
provides: "auth_time stamped at sign-in"
|
||||
contains: "ClaimAuthTime"
|
||||
- path: "modules/bouncer/jwt.go"
|
||||
provides: "the plugin-facing accessor"
|
||||
contains: "func VerifyAuthTime("
|
||||
- path: "modules/pact/capabilities.go"
|
||||
provides: "the member token scope capability and the shared name rule"
|
||||
contains: "type HasFrontendTokenScopes interface"
|
||||
- path: ".planning/notes/2026-10-23-frontend-token-scopes.md"
|
||||
provides: "the recorded E-2 design decision"
|
||||
contains: "HasFrontendTokenScopes"
|
||||
- path: "modules/towel/context.go"
|
||||
provides: "client address on the context"
|
||||
contains: "func ClientIP("
|
||||
- path: "modules/cabana/account_contributions.go"
|
||||
provides: "URL scheme rule and per-section isolation"
|
||||
contains: "Error"
|
||||
key_links:
|
||||
- from: "modules/bouncer/refresh.go"
|
||||
to: "modules/bouncer/mint.go"
|
||||
via: "refreshAudience passes the presented token's auth_time to the internal mint"
|
||||
pattern: "auth_time"
|
||||
- from: "modules/cabana/account_tokens.go"
|
||||
to: "modules/pier/events.go"
|
||||
via: "the revoked event carries TokenID and pier closes only matching sessions"
|
||||
pattern: "TokenID"
|
||||
- from: "modules/pier/pier.go"
|
||||
to: "modules/cabana/token_resolver.go"
|
||||
via: "bearer puts towel.WithClientIP on the resolve context; ResolveBackendToken logs it"
|
||||
pattern: "ClientIP"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Close lane B of the phase code review (B-WR-01..B-WR-06 and the cheap B-IN items) and add the two framework pieces the plugins need in plan 08:
|
||||
- the `auth_time` claim that makes the account link's fresh-sign-in proof real (C-CR-02, framework part);
|
||||
- the plugin-declared member token scope seam escalated by sm-servers-app (E-2, `19.7-GAP-INPUTS.md`).
|
||||
|
||||
**Serialization (planner decision, forced by file overlap):**
|
||||
- The user confirmed waves 06 = 1, 07 = 1, 08 = 2 and 09 = 3. This plan instead depends on 19.7-06, which makes the waves 1, 2, 3 and 4.
|
||||
- The overlap: both plans edit `modules/pier/{session,stateless,store,pier}.go`, `modules/pact/mcp.go` and `modules/pact/README.md`. The token-specific revoke event in Task 3 also builds on 06's session and stateless matching code.
|
||||
- Disjoint file sets would have meant moving B-WR-04 out of this plan, against the confirmed split.
|
||||
- The plan count (four) and the execution order 06 → 07 → 08 → 09 are unchanged. The orchestrator reports the change to the user.
|
||||
|
||||
**Planner decisions recorded here (P-29..P-33):**
|
||||
- **P-29 (auth_time, C-CR-02):** the claim is `auth_time` (OIDC Core's name, NumericDate seconds), exported as `bouncer.ClaimAuthTime`.
|
||||
- `MintAudience` (and so `Mint`) stamps it equal to `iat`, because every direct mint is a sign-in: password login, auto-activated registration, activation by code, social login, the cabana admin login and its re-mint after a password change.
|
||||
- `refreshAudience` copies the presented token's value unchanged. A token without one is refreshed without one; it is never stamped "now".
|
||||
- Plugins read it with `bouncer.VerifyAuthTime(tokenString, secret, audience string) (sub string, authTime time.Time, ok bool, err error)`, which runs exactly the checks `VerifyClaims` runs for `AudienceUser` and `VerifyClaimsAudience` runs for other audiences. `ok` is false when the claim is absent.
|
||||
- Settled by the review's suggested fix, so there is no decision checkpoint. Reversibility costly: once sessions carry the claim and plugins read it, renaming needs both names for a refresh window.
|
||||
- **P-30 (E-2 seam, the open design point in GAP-INPUTS):** **a separate capability, not a reuse of `pact.HasTokenScopes` and not an audience field.**
|
||||
- Shape: `pact.FrontendTokenScope{Name, Label, Description}` and `pact.HasFrontendTokenScopes{ FrontendTokenScopes() []FrontendTokenScope }`. This mirrors the existing `Permission`/`FrontendPermission` pair.
|
||||
- Reasons:
|
||||
1. The escalation asks for no change to the backend `g15_` catalog. Reusing the interface would show every member scope in the admin's token catalog, and every admin scope in the member list.
|
||||
2. `pact.TokenScope` carries `Permissions` (cabana permission patterns) and `Methods` (an HTTP method filter). Neither applies to a member token, whose route middleware `user.scope:<name>` decides. cabana's boot validation requires both fields, so a member scope could not even be declared through it.
|
||||
3. An audience field would leave two fields meaningless for one audience, and cabana would have to skip entries silently.
|
||||
- `pact.ValidTokenScopeName(name string) bool` carries cabana's existing pattern, so both catalogs validate names identically. cabana switches to it with no behaviour change.
|
||||
- The framework never reads `HasFrontendTokenScopes`. The user plugin compiles it in plan 08, as it does `HasFrontendPermissions`.
|
||||
- Written down as `.planning/notes/2026-10-23-frontend-token-scopes.md`. Reversibility costly: a published framework API.
|
||||
- **P-31 (token-specific revocation, B-WR-04 and the framework half of C-IN-02):** `pact.MCPSubjectChanged` gains `TokenID uint` and `ClientID string`, and `pier.Event` carries both as `omitempty` JSON. For `MCPSubjectRevoked`:
|
||||
- a non-zero `TokenID` ends only the sessions whose subject under `Guard` has that `TokenID` and no `ClientID` (personal-token sessions);
|
||||
- a non-empty `ClientID` ends only the sessions whose subject has that `ClientID`;
|
||||
- neither ends every session of the subject (today's behaviour);
|
||||
- other kinds ignore the fields.
|
||||
|
||||
cabana fires the admin token revoke with the token row id.
|
||||
- **P-32 (client address, B-IN-04 and the seam for C-IN-04):**
|
||||
- `towel.WithClientIP` and `towel.ClientIP` carry the client address on a context.
|
||||
- pier's `bearer` sets it before resolving, from the host's optional `ClientIP(*http.Request) string` (surf's adapter uses `surf.ClientIP` with `http.trusted_proxies`), falling back to the host part of `RemoteAddr`.
|
||||
- `cabana.ResolveBackendToken` logs it.
|
||||
- **P-33 (My account seam, B-WR-03 and B-WR-06):**
|
||||
- An action result URL is kept only when it is `https`/`http` absolute or same-origin relative (starts with one `/`, not `//`); anything else is dropped with an error log.
|
||||
- A section whose `Status` fails is sent with `Status` empty and `Error: true` (`json:"error,omitempty"`, additive). An action whose `Applies` fails is omitted with a log. The list never answers 500 for one plugin's failure.
|
||||
|
||||
Purpose: lane B is fixed before v0.5.0, and plan 08 has `bouncer.VerifyAuthTime`, `pact.HasFrontendTokenScopes`, the token-specific events and `towel.ClientIP` to build on.
|
||||
Output: framework commits in bouncer, pact, pier, surf, towel and cabana; the admin SPA fixes with a rebuilt committed dist; the regenerated OpenAPI; docs; one decision note; one tracer smoke test.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-01-SUMMARY.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-06-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Unit tests are plan 09's job. This plan carries one tracer smoke, `TestAuthTimeSmoke`, and keeps every existing test green. A test that pinned the old wrong behaviour (for example the per-admin session kill on token revoke) is changed in the fix commit and named in the SUMMARY.
|
||||
- Documentation rule: every exported API change updates the module README and the affected `docs/` page in the same commit; `summer docs:build --check` must stay green.
|
||||
- Admin rule (CLAUDE.md): swag annotations change → `scripts/check-admin-openapi.sh` regenerates `admin/openapi/admin.json` and `admin/src/api/schema.d.ts` in the same commit; `admin/` changes → `npm --prefix admin run build`, commit `modules/boardwalk/dist`, and `scripts/check-admin-dist.sh` passes. Run `npm --prefix admin ci` first if `admin/node_modules` is missing.
|
||||
- Response shapes stay as they are (core value): the only payload change is the additive `error` key on a My account section. Existing `/account*` and `/auth/me` payloads stay byte-identical (the gate checks `modules/cabana/account.go` against 51d088a; this plan must not touch that file).
|
||||
- Several sessions work in this repo, cabana especially: run `git status --short modules/cabana modules/pier modules/pact admin modules/boardwalk/dist` before every task and leave foreign edits alone. Stage by explicit path, one logical change per commit, no co-author tags; the decision note and the SUMMARY are planning docs in their own commits.
|
||||
- No new dependency (go.mod, go.sum, admin/package-lock.json unchanged).
|
||||
- Every commit is self-contained. At each commit:
|
||||
- the framework builds, `go vet ./...` is clean and the `-short` tests pass;
|
||||
- generated files (admin.json, schema.d.ts) match their annotations;
|
||||
- the committed admin dist matches the SPA source.
|
||||
|
||||
No commit relies on a later task's commit.
|
||||
- Release rule: no tag, push or deploy in this plan.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: auth_time is minted at sign-in, survives refresh unchanged and is readable through bouncer.VerifyAuthTime</name>
|
||||
<reversibility rating="costly">A JWT claim that plugins read (the account-link proof in plan 08); renaming it later needs both names accepted for a whole refresh window.</reversibility>
|
||||
<files>modules/bouncer/mint.go, modules/bouncer/refresh.go, modules/bouncer/jwt.go, modules/bouncer/auth_time_smoke_test.go, modules/bouncer/README.md, docs/services/authentication.md</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, section C-CR-02 (the failure scenario and the suggested fix)
|
||||
- modules/bouncer/mint.go (`registeredClaims`, `MintAudience`), refresh.go (`refreshAudience`, which calls `MintAudience` after its checks; `RefreshAudienceFor`), jwt.go (`VerifyClaims`, `VerifyClaimsAudience`, `verifyClaims`, `frontendAudienceOK`, `claimTime`)
|
||||
- modules/bouncer/mint_test.go and refresh_test.go (what the existing tests pin about the claim set)
|
||||
- modules/cabana/auth.go lines 200-270 and account.go around line 411 (the backend mints and refresh)
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go (the consumer in plan 08: it re-reads the session token with `bouncer.VerifyClaims` today)
|
||||
- modules/bouncer/README.md (API reference table) and docs/services/authentication.md (token lifecycle section)
|
||||
</read_first>
|
||||
<action>
|
||||
Implement P-29 for C-CR-02.
|
||||
|
||||
In mint.go:
|
||||
- Add the exported constant `ClaimAuthTime = "auth_time"`.
|
||||
- Add `AuthTime *jwt.NumericDate \`json:"auth_time,omitempty"\`` to `registeredClaims`.
|
||||
- Move the body of `MintAudience` into an unexported `mintAudience(secret, sub, issuerURL string, ttl time.Duration, audience string, authTime time.Time)`. It sets `AuthTime` when `authTime` is non-zero.
|
||||
- `MintAudience` keeps its signature and calls `mintAudience` with `now`, so `auth_time` equals `iat` on every sign-in mint.
|
||||
|
||||
In refresh.go `refreshAudience`:
|
||||
- Read the presented token's `auth_time` with `claimTime(claims, ClaimAuthTime)`.
|
||||
- Mint the rotated token through `mintAudience` with that value. When the claim is absent, pass the zero time, so the rotated token carries none.
|
||||
- Every exported refresh function keeps its signature.
|
||||
|
||||
In jwt.go, add `func VerifyAuthTime(tokenString, secret, audience string) (sub string, authTime time.Time, ok bool, err error)`:
|
||||
- it runs exactly the verification `VerifyClaims` runs for `AudienceUser` (which accepts a frontend token without `aud`) and `VerifyClaimsAudience` runs for any other audience: signature, audience, `exp`, required claims;
|
||||
- it returns the subject and the `auth_time` claim;
|
||||
- `ok` is false when the claim is missing or not a number.
|
||||
|
||||
Update existing tests that compare the exact claim set of a minted token in the same commit.
|
||||
|
||||
New file `modules/bouncer/auth_time_smoke_test.go` holds `TestAuthTimeSmoke`:
|
||||
1. `Mint` a token, then `VerifyAuthTime` returns `ok` and a time equal to `iat` (seconds).
|
||||
2. Sleep past one second (or mint with a past clock through `mintAudience` from an in-package test), call `Refresh`, and `VerifyAuthTime` on the new token returns the original auth_time while its `iat` is later.
|
||||
3. A token minted by the test with `registeredClaims` and no `AuthTime` refreshes into a token where `ok == false`.
|
||||
4. A token with the wrong audience, a bad signature or past `exp` answers an error.
|
||||
|
||||
Docs in the same commit:
|
||||
- modules/bouncer/README.md: API rows for `ClaimAuthTime` and `VerifyAuthTime`, and a Features line saying refresh keeps the sign-in time.
|
||||
- docs/services/authentication.md: a short "Sign-in time (auth_time)" subsection explaining that a "fresh sign-in" check compares `auth_time`, never `iat`, because refresh renews `iat`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/bouncer/... ./modules/cabana/... && go test -count=1 -short ./modules/bouncer/... ./modules/cabana/... && go test -count=1 -short -run '^TestAuthTimeSmoke$' -v ./modules/bouncer/ 2>&1 | grep -q -- '^--- PASS: TestAuthTimeSmoke' && bash scripts/check-phase19.7.sh --docs</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, the PASS line missing, or the docs stage printing FAIL or "refuse:"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'ClaimAuthTime = "auth_time"' modules/bouncer/mint.go` prints 1 and `grep -c "func mintAudience(" modules/bouncer/mint.go` prints 1
|
||||
- `grep -v '^\s*//' modules/bouncer/refresh.go | grep -c "mintAudience("` prints at least 1 and `grep -v '^\s*//' modules/bouncer/refresh.go | grep -c "ClaimAuthTime"` prints at least 1
|
||||
- `grep -c "func VerifyAuthTime(tokenString, secret, audience string) (sub string, authTime time.Time, ok bool, err error)" modules/bouncer/jwt.go` prints 1
|
||||
- `grep -c "VerifyAuthTime\|ClaimAuthTime" modules/bouncer/README.md` prints at least 2 and `grep -c "auth_time" docs/services/authentication.md` prints at least 1
|
||||
- `grep -c "func TestAuthTimeSmoke(" modules/bouncer/auth_time_smoke_test.go` prints 1
|
||||
</acceptance_criteria>
|
||||
<done>Every sign-in mint carries auth_time, refresh never renews it, a legacy token stays without it, and plugins have one documented accessor; the smoke proves mint → refresh → read end to end.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: The E-2 framework seam: pact.HasFrontendTokenScopes, the shared scope-name rule, and the recorded decision</name>
|
||||
<reversibility rating="costly">A published pact capability (decision P-30); plugins and the user plugin compile against it, so a later reshape needs a deprecation cycle.</reversibility>
|
||||
<files>modules/pact/capabilities.go, modules/cabana/token_scopes.go, modules/pact/README.md, docs/plugins/registration.md, docs/backend/users-and-permissions.md, .planning/notes/2026-10-23-frontend-token-scopes.md</files>
|
||||
<read_first>
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md, section "E-2" (the ask, "Not asked for", acceptance and the open design point)
|
||||
- modules/pact/capabilities.go (`TokenScope`, `HasTokenScopes`; the doc at line ~367 on prompted record actions is Task 4's); modules/pact/mcp.go (`FrontendPermission`, `HasFrontendPermissions`, the style to mirror)
|
||||
- modules/cabana/token_scopes.go (`tokenScopeNameRE`, `validatePluginTokenScope`)
|
||||
- modules/pact/README.md (Features list and type table rows for TokenScope and FrontendPermission); docs/plugins/registration.md (capability table, lines ~80-95); docs/backend/users-and-permissions.md (the `pact.HasTokenScopes` section around line 92)
|
||||
- .planning/notes/ (an existing decision note's shape, for example 2026-10-22-mcp-go-sdk.md)
|
||||
</read_first>
|
||||
<action>
|
||||
Implement P-30.
|
||||
|
||||
In modules/pact/capabilities.go, next to `TokenScope`/`HasTokenScopes`:
|
||||
- `type FrontendTokenScope struct { Name, Label, Description string }`. Doc: one scope of the user plugin's member personal API tokens (`usr_`). Label and Description are phrase keys (containing "::") or literal text. The name is what a route's `user.scope:<name>` middleware checks.
|
||||
- `type HasFrontendTokenScopes interface { FrontendTokenScopes() []FrontendTokenScope }`. Doc: the frontend counterpart of `HasTokenScopes`. The framework's admin token catalog never reads it; the plugin that owns member tokens compiles it.
|
||||
- `func ValidTokenScopeName(name string) bool`, with the pattern `^[a-z][a-z0-9_-]*(:[a-z][a-z0-9_-]*)?$` compiled once in pact. Doc: the one name rule for both catalogs.
|
||||
|
||||
In modules/cabana/token_scopes.go, replace the body of the name check with `pact.ValidTokenScopeName`. Remove the local regexp only if nothing else uses it. Every error message stays word for word.
|
||||
|
||||
Docs in the same commit:
|
||||
- modules/pact/README.md: a Features line and two type rows plus the function row.
|
||||
- docs/plugins/registration.md: a capability table row.
|
||||
- docs/backend/users-and-permissions.md: one paragraph after the `pact.HasTokenScopes` section saying member token scopes are declared with `pact.HasFrontendTokenScopes`, appear only in the member token list, and never in the admin catalog.
|
||||
|
||||
Write `.planning/notes/2026-10-23-frontend-token-scopes.md` (title "Decision: member token scopes use a separate pact capability") with these sections:
|
||||
- Context: the E-2 escalation, with what was asked and what was not;
|
||||
- Options: reuse `HasTokenScopes`, an audience field, a separate interface;
|
||||
- Decision and reasons: the three reasons in P-30;
|
||||
- Consequences: the user plugin compiles and validates the scopes and fails boot on bad ones; the cabana catalog is unchanged; `pact.ValidTokenScopeName` is shared;
|
||||
- Related: GAP-INPUTS E-2, plan 08 Task 3.
|
||||
|
||||
Commit the note separately as a planning doc.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/pact/... ./modules/cabana/... && go test -count=1 -short ./modules/pact/... ./modules/cabana/... && go test -count=1 -short -run '^(TestPactStaysSDKFree|TestPhase197ContractsOnSamplePlugin)$' -v ./modules/pact/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2 && bash scripts/check-phase19.7.sh --docs && bash scripts/check-phase19.7.sh --marker</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, fewer than 2 PASS lines, or a gate stage printing FAIL or "refuse:"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "type FrontendTokenScope struct\|type HasFrontendTokenScopes interface\|func ValidTokenScopeName(" modules/pact/capabilities.go` prints 3
|
||||
- `grep -v '^\s*//' modules/cabana/token_scopes.go | grep -c "pact.ValidTokenScopeName("` prints at least 1
|
||||
- `grep -rn "HasFrontendTokenScopes" modules/cabana --include=*.go | grep -v _test | wc -l` prints 0 (cabana never reads the member capability)
|
||||
- `grep -c "HasFrontendTokenScopes" modules/pact/README.md docs/plugins/registration.md docs/backend/users-and-permissions.md` prints at least 1 per file
|
||||
- `test -f .planning/notes/2026-10-23-frontend-token-scopes.md && grep -c "HasTokenScopes\|audience" .planning/notes/2026-10-23-frontend-token-scopes.md` prints at least 2
|
||||
</acceptance_criteria>
|
||||
<done>The framework offers the member token scope capability and one shared name rule, cabana's admin catalog is untouched in behaviour, and the E-2 design decision is recorded as a note.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Token- and client-specific revocation events, and the client address on pier's resolve path</name>
|
||||
<reversibility rating="costly">New fields on the published pact.MCPSubjectChanged event and on pier.Event's wire JSON between instances (additive and omitempty, so mixed-version instances ignore them).</reversibility>
|
||||
<files>modules/pact/mcp.go, modules/pier/store.go, modules/pier/events.go, modules/pier/session.go, modules/pier/stateless.go, modules/pier/pier.go, modules/pier/host.go, modules/surf/pier_on.go, modules/towel/context.go, modules/cabana/account_tokens.go, modules/cabana/subject_events.go, modules/cabana/token_resolver.go, modules/pact/README.md, modules/pier/README.md, modules/towel/README.md, modules/cabana/README.md, docs/services/mcp.md</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections B-WR-04, B-IN-04 and C-IN-02
|
||||
- modules/pact/mcp.go: `MCPSubjectChanged`, `MCPSubject` (ClientID, TokenID)
|
||||
- modules/pier/events.go (`listenEvents`, `handleEvent`), store.go (`Event`), session.go (`matching`, and the matching method 06 left), stateless.go (`matching`, `evict`), identity.go (`Identity.has`, `subjectFor`; which subjects carry ClientID and TokenID for OAuth, personal frontend and admin `g15_` tokens)
|
||||
- modules/pier/pier.go `bearer` (where `identities.resolve` is called); host.go (`Host`); modules/surf/pier_on.go (`pierHost`, `mountPier`); modules/surf/clientip.go (`ClientIP`, `TrustedProxies`)
|
||||
- modules/towel/context.go (`withValue`, `stringValue`, `WithActor`/`Actor` as the model)
|
||||
- modules/cabana/account_tokens.go around line 155-170 (the revoke handler) and subject_events.go (`fireSubjectChanged`); token_resolver.go (`ResolveBackendToken`, its `logTokenAuthAt` calls) and token_guard.go (`logTokenAuthAt`)
|
||||
</read_first>
|
||||
<action>
|
||||
**P-31.**
|
||||
- In pact/mcp.go, add `TokenID uint` and `ClientID string` to `MCPSubjectChanged`. Rewrite its doc to state the narrowing rule for `MCPSubjectRevoked`; other kinds ignore both fields.
|
||||
- In pier/store.go, add `TokenID uint \`json:"token_id,omitempty"\`` and `ClientID string \`json:"client_id,omitempty"\`` to `Event`.
|
||||
- `listenEvents` copies both.
|
||||
- In `handleEvent`'s revoked/deleted branch, select sessions with a predicate:
|
||||
- with `TokenID != 0`: sessions whose subject under `ev.Guard` has that `TokenID` and an empty `ClientID`;
|
||||
- with `ClientID != ""`: sessions whose subject under `ev.Guard` has that `ClientID`;
|
||||
- otherwise: today's `has(guard, userID)`.
|
||||
- Deleted events always use the whole subject.
|
||||
- Add the predicate form to `sessionRouter.matching` and to `statelessPath.matching`/`evict`, keeping the existing signatures as wrappers.
|
||||
- In cabana/subject_events.go, add an unexported `fireTokenRevoked(ctx, app, adminID, tokenID uint)` that fires `&pact.MCPSubjectChanged{Guard: "backend", UserID: adminID, Kind: pact.MCPSubjectRevoked, TokenID: tokenID}` like `fireSubjectChanged`.
|
||||
- In account_tokens.go, the revoke handler calls it with `row.ID` instead of the per-admin event. Fix the misleading comment above the call so it says which sessions end.
|
||||
|
||||
**P-32.**
|
||||
- In towel/context.go, add `WithClientIP(ctx context.Context, ip string) context.Context` and `ClientIP(ctx context.Context) (string, bool)` on an unexported key, following `WithActor`/`Actor`.
|
||||
- In pier, declare an unexported interface in host.go, `clientIPHost interface{ ClientIP(*http.Request) string }`. Document it as optional for hosts.
|
||||
- In surf/pier_on.go, `pierHost` gains a `trusted []netip.Prefix` field, filled in `mountPier` from `TrustedProxies(app.Config)`, and a `ClientIP` method calling `ClientIP(req, h.trusted)`.
|
||||
- In pier.go `bearer`, before `p.identities.resolve`, wrap the context with `towel.WithClientIP`. Use the host's answer when it implements the interface; otherwise use the host part of `r.RemoteAddr` (`net.SplitHostPort`, or the raw value on error).
|
||||
- In cabana/token_resolver.go, pass `towel.ClientIP(ctx)` as the `remote` of every `logTokenAuthAt` call in `ResolveBackendToken`.
|
||||
|
||||
Docs in the same commit:
|
||||
- pact README: the `MCPSubjectChanged` row.
|
||||
- pier README: the fan-out section's narrowing rule.
|
||||
- towel README: the API rows.
|
||||
- cabana README: the token revoke event and resolver logging.
|
||||
- docs/services/mcp.md: the fan-out paragraph.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go vet -tags summercms_mcp ./modules/surf/... ./modules/pier/... && go test -count=1 -short ./modules/pier/... ./modules/pact/... ./modules/towel/... ./modules/cabana/... && go test -count=1 -short -tags summercms_mcp ./modules/pier/... ./modules/surf/... && go test -count=1 -short -run '^(TestFanOut|TestPierFanOutSmoke|TestFireSubjectChangedReachesPointerListener)$' -v ./modules/pier/ ./modules/cabana/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && bash scripts/check-phase19.7.sh --docs && bash scripts/check-phase19.7.sh --marker</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, fewer than 3 PASS lines, or a gate stage printing FAIL or "refuse:"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -A6 "type MCPSubjectChanged struct" modules/pact/mcp.go | grep -c "TokenID\|ClientID"` prints 2
|
||||
- `grep -c 'json:"token_id,omitempty"\|json:"client_id,omitempty"' modules/pier/store.go` prints 2
|
||||
- `grep -v '^\s*//' modules/pier/events.go | grep -c "TokenID\|ClientID"` prints at least 2
|
||||
- `grep -v '^\s*//' modules/cabana/account_tokens.go | grep -c "fireTokenRevoked("` prints 1
|
||||
- `grep -c "func WithClientIP(\|func ClientIP(" modules/towel/context.go` prints 2 and `grep -v '^\s*//' modules/cabana/token_resolver.go | grep -c "towel.ClientIP("` prints at least 1
|
||||
- `grep -v '^\s*//' modules/pier/pier.go | grep -c "towel.WithClientIP("` prints 1 and `grep -c "func (h pierHost) ClientIP(" modules/surf/pier_on.go` prints 1
|
||||
</acceptance_criteria>
|
||||
<done>Revoking one admin token ends only what that token opened; the event shape can also target one OAuth client (used by the plugins in plan 08); failed g15_ attempts at /mcp carry the client address and resolvers can read it.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: cabana admin API: account action URL rule, per-section isolation, localized texts, the prompted record action contract, regenerated OpenAPI</name>
|
||||
<files>modules/cabana/account_contributions.go, modules/cabana/actions.go, modules/cabana/admin_openapi.go, modules/pact/capabilities.go, modules/cabana/README.md, modules/phrasebook/backend/lang/en/lang.yaml, modules/phrasebook/backend/lang/pl/lang.yaml, admin/tests/fixtures/lang.json, admin/openapi/admin.json, admin/src/api/schema.d.ts</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections B-WR-03 (server part), B-WR-05, B-WR-06 (server part), B-IN-02, B-IN-03, B-IN-05
|
||||
- modules/cabana/account_contributions.go (`accountContributionsList`, `AccountContributionView`, the action handler around line 200 that writes `AccountActionResultView{URL: result.URL}`); modules/cabana/crud.go `localizeDetail`
|
||||
- modules/cabana/actions.go lines 240-280 (`promptRequiredKey` and the three prompt refusals)
|
||||
- modules/cabana/admin_openapi.go lines 790-830 (`AdminRecordAction` description, the body param text, `AdminActionRequest.Payload`) and the My account contributions annotations (the view type's doc)
|
||||
- modules/pact/capabilities.go around line 367 (the prompted record action doc that promises a validation error on the input)
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml `form:` and `myaccount:` sections, the pl twin, admin/tests/fixtures/lang.json
|
||||
- scripts/check-admin-openapi.sh (how to regenerate vs `--check`)
|
||||
</read_first>
|
||||
<action>
|
||||
**B-WR-03, server (P-33).** Before `WriteData` in the action handler, keep `result.URL` only when one of these holds:
|
||||
- `url.Parse` succeeds with scheme `https` or `http` and a host;
|
||||
- or it is a same-origin relative reference (starts with exactly one `/`, not `//`, and has no scheme).
|
||||
|
||||
Otherwise set it to "" and log `cabana: account contribution action answered a non-http URL` with section and action, never the URL itself.
|
||||
|
||||
**B-WR-06, server (P-33).**
|
||||
- Add `Error bool \`json:"error,omitempty"\`` to `AccountContributionView`, documented as "the section's status could not be loaded".
|
||||
- When `Status` errors, log as today, leave `Status` empty, set `Error`, and continue.
|
||||
- When an action's `Applies` errors, log and skip that action.
|
||||
- The handler never answers 500 for a plugin's error. A database or registry failure outside the plugin hooks still does.
|
||||
|
||||
**B-IN-03.** Translate a section's status with `localizeDetail(ctx, tr, status)` instead of `translateKey`.
|
||||
|
||||
**B-IN-02.** In actions.go, replace the hard-coded English refusal for a non-string payload with the phrase key `backend::lang.form.action_prompt_invalid` (en "The answer must be text." / pl "Odpowiedź musi być tekstem."), added to both lang files and to admin/tests/fixtures/lang.json.
|
||||
|
||||
**B-IN-05.** Rewrite the sentence in pact/capabilities.go that promises a validation error on the input. It should say what happens: the admin refuses the value with a 422 whose message is shown as a toast, and the prompt dialog closes. The dialog-stays-open UX is deferred (recorded by plan 09 in deferred-items).
|
||||
|
||||
**B-WR-05, in admin_openapi.go.** Replace the stale sentence in the `AdminRecordAction` description with: the body is `{}` for an action without a prompt; an action whose record response carries `prompt` takes `{"payload": "<text>"}`, trimmed, non-empty and at most `prompt.max_length` runes, with a 422 on `payload` otherwise. Make these match:
|
||||
- the body param text: "Empty object, or {"payload": text} for a prompted action";
|
||||
- the `AdminActionRequest.Payload` comment: toolbar routes refuse it; record routes accept a JSON string only for a prompted action.
|
||||
|
||||
Document the new `error` key wherever the contribution view type is annotated.
|
||||
|
||||
Run `scripts/check-admin-openapi.sh` to regenerate admin/openapi/admin.json and admin/src/api/schema.d.ts, then `scripts/check-admin-openapi.sh --check`. The cabana README's My account section gains the URL rule and the `error` flag. Commit the code, the generated files and the docs together.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./modules/cabana/... ./modules/pact/... && go test -count=1 -short ./modules/cabana/... ./modules/pact/... && go test -count=1 -short -run '^(TestAccountContributions|TestAccountContributionsSmoke|TestRecordActionPrompt|TestRecordActionPromptSmoke)$' -v ./modules/cabana/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 4 && bash scripts/check-admin-openapi.sh --check && bash scripts/check-phase19.7.sh --docs</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, fewer than 4 PASS lines, an OpenAPI drift report, or the docs stage printing FAIL or "refuse:"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'json:"error,omitempty"' modules/cabana/account_contributions.go` prints 1 and `grep -c "non-http URL" modules/cabana/account_contributions.go` prints 1
|
||||
- `grep -v '^\s*//' modules/cabana/account_contributions.go | grep -c "localizeDetail("` prints at least 1
|
||||
- `grep -c "action_prompt_invalid" modules/cabana/actions.go modules/phrasebook/backend/lang/en/lang.yaml modules/phrasebook/backend/lang/pl/lang.yaml admin/tests/fixtures/lang.json` prints at least 1 per file
|
||||
- `grep -c "payload are all refused" modules/cabana/admin_openapi.go admin/openapi/admin.json` prints 0 for both files and `grep -c "prompt.max_length" admin/openapi/admin.json` prints at least 1
|
||||
- `bash scripts/check-admin-openapi.sh --check` exits 0
|
||||
- `git diff --quiet 51d088a -- modules/cabana/account.go` (My account's own handlers untouched)
|
||||
</acceptance_criteria>
|
||||
<done>The admin API only hands out safe URLs, one broken contributing plugin cannot blank My account, the remaining English text is localized, the prompted-action contract is published correctly and the generated API files match.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Admin SPA: shadow-DOM-aware plain keys, commit-before-save shortcuts, safe account links, the section error state and My account texts; rebuilt dist</name>
|
||||
<files>admin/src/app/hotkeys.ts, admin/src/components/account/AccountContributions.vue, modules/phrasebook/backend/lang/en/lang.yaml, modules/phrasebook/backend/lang/pl/lang.yaml, admin/tests/fixtures/lang.json, modules/boardwalk/dist</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections B-WR-01, B-WR-02, B-WR-03 (SPA part), B-WR-06 (SPA part), B-IN-01, B-IN-06
|
||||
- admin/src/app/hotkeys.ts (`isEditableTarget` at ~100-105, `onModifierKey` at ~187-206 with `target.click()`, `onPlainKey` at ~208-236)
|
||||
- admin/src/components/form/fields/TaglistField.vue (`addDraft` on blur and Enter, lines ~73 and ~167)
|
||||
- admin/src/components/account/AccountContributions.vue (`load`, the confirm texts at ~52 and ~78, `links` and `window.open` at ~43-46 and ~103-111)
|
||||
- admin/tests/app/hotkeys.test.ts and admin/tests/account/AccountContributions.test.ts (existing expectations to keep green)
|
||||
- modules/phrasebook/backend/lang/en/lang.yaml `myaccount:` and `form:` sections
|
||||
- scripts/check-admin-dist.sh
|
||||
</read_first>
|
||||
<action>
|
||||
**B-WR-01.**
|
||||
- In hotkeys.ts, add `originOf(event)`: the first entry of `event.composedPath()` when available, else `event.target`.
|
||||
- `onPlainKey` tests `isEditableTarget(originOf(event))`.
|
||||
- `isEditableTarget` also treats any element whose tag name contains `-` (a custom element) and that sits inside a `form` or `[role=form]` as editable. That covers closed shadow roots, where `composedPath()` stops at the host.
|
||||
|
||||
**B-WR-02.** In `onModifierKey`, before `target.click()`:
|
||||
- when `document.activeElement` is an element other than the target and has `blur`, call `blur()`, so TaglistField's `addDraft` and native `change` run as a pointer click would trigger them;
|
||||
- restore focus to the element after the click only when it is still in the document and the view did not navigate (keep it simple: refocus when `isConnected`).
|
||||
|
||||
**B-WR-03, SPA.** In AccountContributions.vue, add `safeUrl(u: string): string`, returning the value only for `/^https?:\/\//i` or a single-slash relative path, else ''. Use it for both the rendered `href` and `window.open`. An unsafe URL is never bound and never opened. B-IN-06 stays as is: the visible link remains the fallback for a blocked popup, with no code change.
|
||||
|
||||
**B-WR-06, SPA.**
|
||||
- On a non-2xx GET of the contributions, show a toast with `backend::lang.form.error_generic` and keep the previous sections.
|
||||
- A section with `error: true` renders a muted line `backend::lang.myaccount.section_error` (en "This section could not be loaded." / pl "Nie udało się wczytać tej sekcji.").
|
||||
|
||||
**B-IN-01.** Use the new keys `backend::lang.myaccount.action_confirm` (en "Run “:action”?" / pl "Wykonać „:action”?") and `backend::lang.myaccount.action_stale` (en "This action no longer applies. The page has been refreshed." / pl "Ta akcja nie ma już zastosowania. Strona została odświeżona.") in place of the record-oriented form texts.
|
||||
|
||||
Add every new key to the en and pl lang files and to admin/tests/fixtures/lang.json. Adjust existing vitest expectations that asserted the record-oriented texts in the same commit (plan 09 adds the new tests).
|
||||
|
||||
Run `npm --prefix admin run typecheck`, `npm --prefix admin run test`, `npm --prefix admin run build`, then `scripts/check-admin-dist.sh`. Commit the SPA source, the lang changes and the rebuilt `modules/boardwalk/dist` in one commit, so `check-admin-dist.sh` passes at that commit (self-contained rule).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>npm --prefix admin run typecheck && npm --prefix admin run test 2>&1 | grep -E 'Test Files +[0-9]+ passed' | grep -qv failed && bash scripts/check-admin-dist.sh && bash scripts/check-phase19.7.sh --admin</automated>
|
||||
<fails_when>non-zero exit, a failed or skipped vitest file, a dist drift report from check-admin-dist.sh, or the admin stage printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "composedPath" admin/src/app/hotkeys.ts` prints at least 1 and `grep -v '^\s*//' admin/src/app/hotkeys.ts | grep -c "\.blur()"` prints at least 1
|
||||
- `grep -c "safeUrl" admin/src/components/account/AccountContributions.vue` prints at least 3 (definition, href binding, window.open)
|
||||
- `grep -c "myaccount.action_confirm\|myaccount.action_stale\|myaccount.section_error" admin/src/components/account/AccountContributions.vue` prints at least 3
|
||||
- `grep -c "section_error\|action_confirm\|action_stale" modules/phrasebook/backend/lang/pl/lang.yaml` prints at least 3 and the same keys are in admin/tests/fixtures/lang.json
|
||||
- `bash scripts/check-admin-dist.sh` exits 0 at the task's commit (source and dist in the same commit)
|
||||
</acceptance_criteria>
|
||||
<done>Typing inside plugin field types is safe from plain shortcuts, keyboard saves include pending drafts, My account never renders or opens a script URL, a broken section shows an error instead of vanishing, the texts fit My account, and the embedded SPA matches its source.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**Framework code (summercms.go, local commits on master):**
|
||||
- `bouncer`: `ClaimAuthTime`, `VerifyAuthTime`, the auth_time mint and refresh carry-over.
|
||||
- `pact`:
|
||||
- `FrontendTokenScope`, `HasFrontendTokenScopes`, `ValidTokenScopeName`;
|
||||
- `MCPSubjectChanged.TokenID` and `ClientID`;
|
||||
- the corrected prompted-action doc.
|
||||
- `pier`: event narrowing, `Event.TokenID`/`ClientID`, the client address on the resolve context, and the optional host capability.
|
||||
- `surf`: `pierHost.ClientIP`.
|
||||
- `towel`: `WithClientIP` and `ClientIP`.
|
||||
- `cabana`:
|
||||
- the token-specific revoke event;
|
||||
- the resolver's remote address;
|
||||
- the account action URL rule, the section `error` flag and status localization;
|
||||
- the localized payload refusal;
|
||||
- the corrected record action annotations.
|
||||
|
||||
**Admin SPA:**
|
||||
- `hotkeys.ts` (composedPath, blur before click);
|
||||
- `AccountContributions.vue` (`safeUrl`, the error state, the My account texts);
|
||||
- the rebuilt `modules/boardwalk/dist`;
|
||||
- the regenerated `admin/openapi/admin.json` and `admin/src/api/schema.d.ts`.
|
||||
|
||||
**Docs:**
|
||||
- READMEs: bouncer, pact, pier, towel, cabana;
|
||||
- `docs/services/authentication.md`, `docs/services/mcp.md`, `docs/plugins/registration.md`, `docs/backend/users-and-permissions.md`.
|
||||
|
||||
**Decision note:** `.planning/notes/2026-10-23-frontend-token-scopes.md` (E-2, P-30).
|
||||
|
||||
**Test:** `modules/bouncer/auth_time_smoke_test.go` (`TestAuthTimeSmoke`).
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| browser session to the token refresh endpoints | any holder of a token inside its refresh window can rotate it without a password |
|
||||
| plugins to the admin token catalog and the member token catalog | plugins declare scope names that end up on stored tokens |
|
||||
| plugin account actions to the admin SPA | a plugin answers a URL the admin's browser renders and opens |
|
||||
| admin and plugins to pier's fan-out | revocation events decide which live MCP sessions end |
|
||||
| MCP clients to the token resolvers | failed attempts must be traceable to an address |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-51 | Spoofing | the fresh-sign-in proof (D-05) | high | mitigate | auth_time stamped only at sign-in, copied unchanged by refresh, absent stays absent; `VerifyAuthTime` checks signature, audience and expiry; plan 08 makes the link confirm compare auth_time; TestAuthTimeSmoke here, TestAuthTime and TestBackendLinkAuthTime in plan 09 |
|
||||
| T-19.7-52 | Elevation of privilege | member scopes crossing into the admin token catalog, or the reverse | medium | mitigate | separate capability that cabana never reads (acceptance grep); one shared name rule `pact.ValidTokenScopeName` |
|
||||
| T-19.7-53 | Tampering | a `javascript:`/`data:` URL from an account action rendered into href or window.open | medium | mitigate | server keeps only http(s) and same-origin relative URLs; SPA `safeUrl` on both sinks |
|
||||
| T-19.7-54 | Denial of service | revoking one token ends every MCP session of the admin, including OAuth sessions of the linked user | low | mitigate | token-specific revoked event; client-specific variant for plan 08 |
|
||||
| T-19.7-55 | Repudiation | failed g15_ attempts at /mcp logged without a client address | low | mitigate | towel client address on the resolve context, logged by ResolveBackendToken |
|
||||
| T-19.7-56 | Information disclosure | one plugin's error silently hides other plugins' My account sections (including the Unlink action) | low | mitigate | per-section isolation with the `error` flag and a toast on a failed GET |
|
||||
| T-19.7-SC | Tampering | package installs | low | mitigate | no package added; `npm --prefix admin ci` installs the committed lock only; go.mod, go.sum and admin/package-lock.json unchanged |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go vet ./... && go test -count=1 -short ./...` and `go test -count=1 ./modules/cabana/...` on a Docker host (the cabana Postgres suites, through `sudo -u golem` if the socket is denied)
|
||||
- `bash scripts/check-phase19.7.sh --go`, `--admin`, `--docs` and `--marker` print PASS
|
||||
- `cd examples/hello && go test ./...` stays green
|
||||
- `git diff --quiet 51d088a -- modules/cabana/account.go`
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- B-WR-01..B-WR-06 fixed; B-IN-01, B-IN-02, B-IN-03 and B-IN-04 fixed; B-IN-05's contract text corrected (the UX deferral is recorded by plan 09); B-IN-06 needs no change
|
||||
- `bouncer.VerifyAuthTime`, `pact.HasFrontendTokenScopes`, `pact.ValidTokenScopeName`, `pact.MCPSubjectChanged.TokenID/ClientID` and `towel.ClientIP` exist with docs, ready for plan 08
|
||||
- The E-2 design decision is recorded (P-30 and the note)
|
||||
- No exported identifier removed; every response shape unchanged except the additive `error` key
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-07-SUMMARY.md` when done, with every commit sha mapped to its finding ids. Commit the SUMMARY separately as a planning doc.
|
||||
|
||||
Release rule: this plan does not tag, push or deploy. Every repository works against the local framework (go.work, or `replace ../summercms.go`), and every plugin's go.mod `require` line stays at its current version. The plans may commit locally in every repository. The releases happen only after phase verification, in this order: framework v0.5.0, then the plugin tags that require it, then the application bumps.
|
||||
</output>
|
||||
218
.planning/phases/19.7-generic-mcp-module/19.7-07-SUMMARY.md
Normal file
218
.planning/phases/19.7-generic-mcp-module/19.7-07-SUMMARY.md
Normal file
@@ -0,0 +1,218 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 07
|
||||
subsystem: auth
|
||||
status: complete
|
||||
gap_closure: true
|
||||
tags: [bouncer, jwt, auth_time, pact, token-scopes, pier, mcp, fan-out, towel, cabana, admin-spa, hotkeys, openapi, gap-closure]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-06
|
||||
provides: pier session and stateless matching after lane A (session.go, stateless.go, events.go), pact.MCPPrompt.Writes
|
||||
- phase: 19.7-05
|
||||
provides: scripts/check-phase19.7.sh (--go, --admin, --docs, --marker stages)
|
||||
provides:
|
||||
- bouncer.ClaimAuthTime and bouncer.VerifyAuthTime; auth_time stamped at every sign-in mint and copied unchanged by every refresh path
|
||||
- pact.FrontendTokenScope, pact.HasFrontendTokenScopes and pact.ValidTokenScopeName (E-2 framework seam, decision note)
|
||||
- pact.MCPSubjectChanged.TokenID / ClientID and pier.Event token_id / client_id; narrowed revocation in pier
|
||||
- towel.WithClientIP / towel.ClientIP; pier puts the client address on the resolve context; cabana.ResolveBackendToken logs it
|
||||
- cabana My account seam: http(s)/same-origin URL rule, per-section `error` flag, localized status; localized prompt refusal; corrected record action contract
|
||||
- admin SPA: shadow-DOM-aware plain keys, blur-before-click shortcuts, safeUrl, section error line and toast, My account confirm/stale texts; rebuilt dist
|
||||
affects: [19.7-08 (user plugin reads VerifyAuthTime, compiles HasFrontendTokenScopes, fires client-specific revocations), 19.7-09 (named unit tests), framework v0.5.0]
|
||||
|
||||
actuals:
|
||||
tokens: 28086
|
||||
tasks: 5
|
||||
commits: 6
|
||||
plan_head_before: 60a86677f22aef02d11acc812ba110b94797e1ed
|
||||
plan_head_after: 88559d5731c35d8071fb500ee93d7c8c287312e9
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "A refresh copies a sign-in claim from the presented token instead of re-deriving it (mintAudience with an explicit authTime)"
|
||||
- "Frontend twin of a pact capability (FrontendTokenScope next to TokenScope, as FrontendPermission next to Permission) with one shared validation function"
|
||||
- "Revocation events narrow by optional fields; pier selects sessions with a predicate (matchingFunc / evictFunc), the old (guard, user) signatures stay as wrappers"
|
||||
- "Optional host capability discovered by type assertion (clientIPHost), so pier.Host does not change"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/bouncer/auth_time_smoke_test.go
|
||||
- .planning/notes/2026-10-23-frontend-token-scopes.md
|
||||
modified:
|
||||
- modules/bouncer/mint.go
|
||||
- modules/bouncer/refresh.go
|
||||
- modules/bouncer/jwt.go
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/mcp.go
|
||||
- modules/cabana/token_scopes.go
|
||||
- modules/pier/events.go
|
||||
- modules/pier/stateless.go
|
||||
- modules/pier/store.go
|
||||
- modules/pier/pier.go
|
||||
- modules/pier/host.go
|
||||
- modules/surf/pier_on.go
|
||||
- modules/towel/context.go
|
||||
- modules/cabana/account_tokens.go
|
||||
- modules/cabana/subject_events.go
|
||||
- modules/cabana/token_resolver.go
|
||||
- modules/cabana/account_contributions.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/admin_openapi.go
|
||||
- admin/src/app/hotkeys.ts
|
||||
- admin/src/components/account/AccountContributions.vue
|
||||
- admin/openapi/admin.json
|
||||
- admin/src/api/schema.d.ts
|
||||
- modules/boardwalk/dist
|
||||
|
||||
key-decisions:
|
||||
- "P-29: auth_time (OIDC name, NumericDate seconds) is stamped equal to iat by every MintAudience call; refreshAudience copies the presented value and never stamps a missing one; plugins read it with bouncer.VerifyAuthTime (VerifyClaims checks for AudienceUser, VerifyClaimsAudience checks otherwise; ok false when absent)"
|
||||
- "P-30: member token scopes use a separate capability pact.HasFrontendTokenScopes, not HasTokenScopes and not an audience field; pact.ValidTokenScopeName is the one name rule; recorded in .planning/notes/2026-10-23-frontend-token-scopes.md"
|
||||
- "P-31: a revoked event with TokenID ends only sessions whose subject under Guard is UserID with that TokenID and no ClientID; with ClientID only that client's sessions of UserID; neither (and every deleted event) the whole subject"
|
||||
- "P-32: pier puts the client address on the resolve context (surf's adapter applies http.trusted_proxies, else the host part of RemoteAddr)"
|
||||
- "P-33: account action URLs kept only for http(s) with a host or a same-origin path (one leading /, not // or /\\); a failing Status marks its section error: true, a failing Applies drops that action"
|
||||
|
||||
patterns-established:
|
||||
- "Sign-in freshness is proven by auth_time, never iat"
|
||||
|
||||
requirements-completed: [SC-4, D-04, D-05, D-17, D-19, D-26, D-27, D-34, E-2]
|
||||
|
||||
duration: 62min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 07: Lane B gap closure, auth_time and the E-2 seam Summary
|
||||
|
||||
Lane B of the phase code review is closed, and the framework gains the two pieces plan 08's plugins build on. Every sign-in token now carries `auth_time`, which a refresh copies unchanged, so the account link's fresh-sign-in proof can no longer be satisfied by `POST /refresh`. Plugins can declare member (`usr_`) token scopes through `pact.HasFrontendTokenScopes`, which the admin catalog never reads. Revoking one admin token ends only that token's MCP sessions, and failed `g15_` attempts at `/mcp` are logged with the client address. The My account seam only hands the browser http(s) or same-origin URLs and survives one plugin's failure. The SPA's plain-key and save shortcuts behave correctly around shadow DOM and pending taglist drafts.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 62 min
|
||||
- **Started:** 2026-10-23T14:11:39Z
|
||||
- **Completed:** 2026-10-23
|
||||
- **Tasks:** 5 of 5
|
||||
- **Files modified:** 43 (2 created, generated dist assets renamed)
|
||||
|
||||
## Commits and findings
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| c14238b `feat(bouncer): stamp auth_time at sign-in and carry it unchanged through refresh` | 1 (tracer) | C-CR-02 (framework part) |
|
||||
| 9eedfbb `feat(pact): add HasFrontendTokenScopes and the shared ValidTokenScopeName rule` | 2 | E-2 (framework seam) |
|
||||
| 0ec00f7 `docs(19.7-07): record the member token scope design decision` | 2 | E-2 (P-30 note) |
|
||||
| 24cf6cd `fix(pier): end only the revoked token's or client's MCP sessions and log the client address` | 3 | B-WR-04, B-IN-04, C-IN-02 (framework half) |
|
||||
| 44835e4 `fix(cabana): safe account action URLs, per-section isolation and the prompted record action contract` | 4 | B-WR-03 (server), B-WR-05, B-WR-06 (server), B-IN-02, B-IN-03, B-IN-05 (contract text) |
|
||||
| 88559d5 `fix(admin): shadow-DOM-aware plain keys, commit drafts before shortcut saves and safe My account links` | 5 | B-WR-01, B-WR-02, B-WR-03 (SPA), B-WR-06 (SPA), B-IN-01 |
|
||||
|
||||
B-IN-06 needs no change: the visible link stays the fallback when a popup blocker stops `window.open`. The B-IN-05 dialog-stays-open UX is deferred; plan 09 records it in deferred-items.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **auth_time (Task 1, tracer).**
|
||||
- `bouncer.ClaimAuthTime = "auth_time"`, with `registeredClaims.AuthTime` (`omitempty`).
|
||||
- `MintAudience` keeps its signature and calls the unexported `mintAudience(..., now, authTime)` with the same instant for both, so `auth_time == iat` on every sign-in mint (cabana's admin login and its re-mint after a password change included).
|
||||
- `refreshAudience` reads the presented `auth_time` with `claimTime` and mints through `mintAudience`. `Refresh`, `RefreshAudience` and `RefreshAudienceFor` (cabana's backend `/refresh`) all go through it, and a token without the claim refreshes without one.
|
||||
- `bouncer.VerifyAuthTime(tokenString, secret, audience)` shares `parseVerified` with `verifyClaims`. That gives the same HS256, required `exp`, audience (`AudienceUser` also accepts a token with no `aud`) and subject checks.
|
||||
- `TestAuthTimeSmoke` covers mint → read, refresh keeps `auth_time` while `iat` moves, legacy → no claim, and wrong audience, bad signature and expired token → error.
|
||||
- **E-2 seam (Task 2).**
|
||||
- New: `pact.FrontendTokenScope{Name, Label, Description}`, `pact.HasFrontendTokenScopes` and `pact.ValidTokenScopeName` (the pattern moved from cabana).
|
||||
- cabana's `validatePluginTokenScope` calls it with identical messages. cabana never references `HasFrontendTokenScopes`.
|
||||
- The decision note records the context, the three options, the reasons and the consequences.
|
||||
- **Narrowed revocation and client address (Task 3).**
|
||||
- `MCPSubjectChanged` and `pier.Event` gain `TokenID`/`ClientID` (JSON `token_id`/`client_id`, `omitempty`), and `listenEvents` copies them.
|
||||
- `revokedMatch` builds the predicate. `sessionRouter.matchingFunc` and `statelessPath.matchingFunc`/`evictFunc` apply it, and the old `matching(guard, user)`/`evict(guard, user)` remain as wrappers.
|
||||
- cabana's `fireTokenRevoked` fires after commit with the token row id. The revoke handler uses it, and the misleading comment is fixed.
|
||||
- `towel.WithClientIP`/`towel.ClientIP` are new. pier's `bearer` wraps the resolve context with the address. The optional `clientIPHost` is implemented by surf's `pierHost.ClientIP`, which uses `TrustedProxies(app.Config)`; the fallback is the host part of `RemoteAddr`. `ResolveBackendToken` logs `remote` on all six `admin.auth` lines.
|
||||
- **cabana admin API (Task 4).**
|
||||
- `safeAccountActionURL` checks the action URL. A refused URL is dropped and logged without the URL.
|
||||
- `AccountContributionView.Error` (`json:"error,omitempty"`) is set when `Status` fails. A failing `Applies` drops only that action, and the list no longer answers 500 for a plugin error.
|
||||
- The status goes through `localizeDetail`.
|
||||
- The non-string payload refusal now uses `backend::lang.form.action_prompt_invalid` (en and pl, plus the fixture).
|
||||
- The `AdminRecordAction` description, the body param and the `AdminActionRequest.Payload` comment are corrected. The toolbar description is reworded so that "payload are all refused" no longer appears anywhere. The pact prompt doc states the 422 toast behaviour.
|
||||
- admin.json and schema.d.ts are regenerated.
|
||||
- **Admin SPA (Task 5).**
|
||||
- Plain keys: `originOf` (`composedPath()[0]`) feeds `isEditableTarget`, which also treats a custom element inside `form`/`[role=form]` as editable.
|
||||
- `onModifierKey` blurs the focused element before `target.click()` and refocuses it if it is still connected.
|
||||
- `safeUrl` guards both the `href` and `window.open`.
|
||||
- A non-2xx GET shows the `form.error_generic` toast and keeps the previous sections. `error: true` renders `myaccount.section_error`.
|
||||
- The confirm and stale texts use the new `myaccount.action_confirm` and `myaccount.action_stale` keys.
|
||||
- The dist is rebuilt and committed in the same commit.
|
||||
|
||||
## Verification
|
||||
|
||||
- `go vet ./...` and `go vet -tags summercms_mcp ./...` are clean.
|
||||
- `go test -count=1 ./...` is green with Docker available (the cabana Postgres suites ran), and `scripts/check-phase19.7.sh --go` PASSES.
|
||||
- `go test -count=1 -short -tags summercms_mcp ./modules/pier/... ./modules/surf/...` is green.
|
||||
- `cd examples/hello && go test ./...` is green.
|
||||
- `npm --prefix admin run typecheck` is clean. `npm --prefix admin run test` passes (100 files, 1544 tests). `npm --prefix admin run build` succeeds.
|
||||
- `scripts/check-admin-openapi.sh --check` exits 0 and `scripts/check-admin-dist.sh` matches. Both were also run at 44835e4: the dist matched before the SPA commit.
|
||||
- `scripts/check-phase19.7.sh --docs` (includes `summer docs:build --check`: no problems), `--marker` and `--admin` PASS.
|
||||
- `git diff --quiet 51d088a -- modules/cabana/account.go` holds.
|
||||
- go.mod, go.sum and admin/package-lock.json are unchanged.
|
||||
- An ad-hoc check of `revokedMatch` was run and then deleted, because plan 09 owns the named tests. It confirmed:
|
||||
- a token event spares another token and an OAuth identity with the same TokenID;
|
||||
- a client event hits only that client;
|
||||
- a plain event and a deleted event hit everything.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] `mintAudience` takes the issue time as well as `authTime`**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** With the plan's signature (`authTime` only), `MintAudience` would read `time.Now()` once for `authTime` and `mintAudience` again for `iat`. Across a second boundary, `auth_time` would differ from `iat`.
|
||||
- **Fix:** `mintAudience(secret, sub, issuerURL, ttl, audience, now, authTime)`. `MintAudience` passes one `now` for both, and refresh passes `time.Now()` and the copied value.
|
||||
- **Files modified:** modules/bouncer/mint.go, modules/bouncer/refresh.go
|
||||
- **Commit:** c14238b
|
||||
|
||||
**2. [Rule 2 - Missing critical] `/\` treated as protocol-relative**
|
||||
- **Found during:** Task 4 and Task 5
|
||||
- **Issue:** Browsers normalise `/\host` to `//host`, so a "single-slash relative path" check alone would let an off-origin URL through.
|
||||
- **Fix:** Both the server's `safeAccountActionURL` and the SPA's `safeUrl` refuse a leading `/\`.
|
||||
- **Commits:** 44835e4, 88559d5
|
||||
|
||||
**3. [Rule 3 - Blocking] Body param text without inner double quotes**
|
||||
- **Found during:** Task 4
|
||||
- **Issue:** swag's quoted `@Param` description cannot hold `{"payload": text}`. Escaped quotes were cut to `Empty object, or {\`.
|
||||
- **Fix:** The text reads `Empty object, or {payload: text} for a prompted action`. The description keeps the full `{"payload": "<text>"}` form.
|
||||
- **Commit:** 44835e4
|
||||
|
||||
**4. [Scope] Toolbar action description reworded**
|
||||
- **Issue:** The acceptance grep requires zero "payload are all refused" in admin_openapi.go and admin.json, but the toolbar route's description (which correctly refuses payload) used the same words.
|
||||
- **Fix:** It now reads "the route refuses record_id, values and payload", with the same meaning.
|
||||
- **Commit:** 44835e4
|
||||
|
||||
**5. [Plan file list] Revocation predicate lives in events.go**
|
||||
- `sessionRouter.matching` is defined in events.go, not session.go, so `matchingFunc` and `revokedMatch` went there. session.go was not touched.
|
||||
- docs/backend/users-and-permissions.md also gained the My account URL and error sentences, under the docs rule.
|
||||
- **Commits:** 24cf6cd, 44835e4, 88559d5
|
||||
|
||||
**6. [Rule 3] gofmt of account_tokens.go**
|
||||
- The file lacked a trailing newline (pre-existing). Running gofmt on the edited file fixed it in 24cf6cd.
|
||||
|
||||
### Tests changed for old behaviour
|
||||
|
||||
- `modules/cabana/record_action_prompt_postgres_test.go`: the non-string payload refusal now expects "The answer must be text." instead of the hard-coded "The payload must be a string." (B-IN-02). Commit 44835e4.
|
||||
- `admin/tests/account/AccountContributions.test.ts`: the stale-toast string override moves from `backend::lang.form.action_stale` to `backend::lang.myaccount.action_stale` (B-IN-01). Commit 88559d5.
|
||||
- No test pinned the per-admin session kill on token revoke or the 500 for a failing `Status`/`Applies`.
|
||||
|
||||
## Notes for later plans
|
||||
|
||||
- Plan 08: the account-link confirm should call `bouncer.VerifyAuthTime(token, secret, bouncer.AudienceUser)`, refuse `ok == false` and compare `authTime` with the request's `created_at`. User-plugin sign-in mints go through `bouncer.Mint`/`MintAudience` and so already carry the claim.
|
||||
- Plan 08: a client-specific revocation is fired as `&pact.MCPSubjectChanged{Guard: "<frontend guard>", UserID: id, Kind: pact.MCPSubjectRevoked, ClientID: clientID}`. `UserID` must be set, because the narrowed match requires it.
|
||||
- Plan 09 (named tests): `TestAuthTime`, revokedMatch and fan-out narrowing, `towel.ClientIP` on the resolver log, `safeAccountActionURL`, section isolation, `originOf`/custom-element editable, blur-before-click with a taglist draft, `safeUrl`.
|
||||
- The `admin:token:revoke` CLI fires no MCP event, before or after this plan. It is out of scope; plan 09 may record it as deferred.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The new surfaces (the `auth_time` claim, the client address on the context, the narrowed events) are the mitigations T-19.7-51 to T-19.7-56 in the plan's threat register.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: modules/bouncer/auth_time_smoke_test.go, .planning/notes/2026-10-23-frontend-token-scopes.md
|
||||
- FOUND: c14238b, 9eedfbb, 0ec00f7, 24cf6cd, 44835e4, 88559d5
|
||||
- The only deleted files are the replaced hashed assets under modules/boardwalk/dist (a rebuild)
|
||||
601
.planning/phases/19.7-generic-mcp-module/19.7-08-PLAN.md
Normal file
601
.planning/phases/19.7-generic-mcp-module/19.7-08-PLAN.md
Normal file
@@ -0,0 +1,601 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 08
|
||||
type: execute
|
||||
wave: 3
|
||||
depends_on: ["19.7-06", "19.7-07"]
|
||||
gap_closure: true
|
||||
files_modified:
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/account_contributions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/routes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/config/config.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/access_revoked.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/subject_events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/console/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/member_token_scopes_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/organisation.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/organisation/fields.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md
|
||||
- ../sm-oauthserver-plugin/classes/mcp_verifier.go
|
||||
- ../sm-oauthserver-plugin/classes/mcp_store.go
|
||||
- ../sm-oauthserver-plugin/classes/cascade.go
|
||||
- ../sm-oauthserver-plugin/classes/subject_events.go
|
||||
- ../sm-oauthserver-plugin/controllers/authorizations.go
|
||||
- ../sm-oauthserver-plugin/plugin.go
|
||||
- ../sm-oauthserver-plugin/mcp_revocation_smoke_test.go
|
||||
- ../sm-oauthserver-plugin/README.md
|
||||
- ../sm-journal-plugin/mcp.go
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/linkCode.ts
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/en.json
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/pl.json
|
||||
- ../sm-demo-app/vue-demo-app
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
|
||||
- ../sm-demo-app/scripts/check-deploy.sh
|
||||
- ../sm-demo-app/plugins/golem15/oauthserver
|
||||
- ../sm-demo-app/plugins/golem15/journal
|
||||
autonomous: true
|
||||
requirements: [SC-4, D-03, D-05, D-07, D-08, D-09, D-19, D-20, D-21, D-26, D-27, D-28, E-1, E-2]
|
||||
|
||||
estimate:
|
||||
tokens: 140000
|
||||
raw_tokens: 140000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "The account link is confirmed only by a session whose auth_time is at or after the link request: a token refreshed after the request is refused with 409 stale_session, a token without auth_time is refused the same way, and a fresh sign-in after the request links (C-CR-02 plugin side, D-05)"
|
||||
- "The link code never reaches a server log: My account answers <frontend_url><page_path>#code=<code>, the site page reads the fragment, keeps the code in sessionStorage across the sign-in, shows the request through POST /_user/api/v1/backend-link/show with the code in the body, and shows which frontend account is signed in before the confirm button (C-WR-01, C-IN-06, D-05)"
|
||||
- "Banning a user, resetting their password, an admin setting their password, or their own password change revokes their MCP access and refresh tokens created before the cut-off and ends their MCP sessions; the MCP verifier and the MCP refresh rotation refuse a banned user and any token created before tokens_valid_after plus one second (the stored cutoff is whole seconds, so a token from earlier in the cutoff's second is refused too), and the revoke uses the untruncated revocation instant; a banned user's link answers no backend user (C-CR-01, D-08, D-27)"
|
||||
- "Creating or removing a frontend user's backend link revokes that user's MCP grants that carry the backend scope, so a backend grant never runs with the reach of an administrator the user did not consent to (C-WR-02, D-21)"
|
||||
- "A plugin declares member token scopes with pact.HasFrontendTokenScopes; POST /_user/api/v1/tokens and MintAPITokenFor accept them for the application that declares them (a second application in the same process refuses them), the legacy MintAPIToken accepts them through a process-wide fallback, middleware.Scope and APIToken.HasScope check them unchanged, GET /tokens lists them, GET /_user/api/v1/tokens/scopes lists the built-ins and the declared scopes with translated labels, and a duplicate, a built-in redeclared or a bad name fails boot (E-2)"
|
||||
- "Organisations have a logo image (attachOne `logo`) editable in the backend Organisations form, and applications get the logo for their organisation payloads through exported helpers using the same keys the user payload uses for avatars (E-1)"
|
||||
- "Revoking one personal token or one OAuth authorization ends only the MCP sessions it opened; a personal token used at /mcp records last_used_ip; Journal's draft_post prompt is hidden from read-only grants; nginx accepts MCP bodies up to pier's 4 MiB cap (C-IN-01..C-IN-05)"
|
||||
- "Every plugin change is additive: no exported identifier, route, column, payload field or migration removed or changed; plugin go.mod require lines are unchanged"
|
||||
artifacts:
|
||||
- path: "../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go"
|
||||
provides: "auth_time-based confirm and the POST show route"
|
||||
contains: "VerifyAuthTime"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/access_revoked.go"
|
||||
provides: "AccessRevokedEvent firing helper"
|
||||
contains: "func FireAccessRevoked("
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go"
|
||||
provides: "the member token scope catalog"
|
||||
contains: "HasFrontendTokenScopes"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go"
|
||||
provides: "OrganisationLogoURL and OrganisationLogoFields"
|
||||
contains: "func OrganisationLogoFields("
|
||||
- path: "../sm-oauthserver-plugin/classes/cascade.go"
|
||||
provides: "revocation on access-revoked and on link changes"
|
||||
contains: "AccessRevokedEvent"
|
||||
- path: "../sm-demo-app/vue-demo-app/app/lib/linkCode.ts"
|
||||
provides: "fragment parsing and sessionStorage key for the link page"
|
||||
contains: "readLinkCode"
|
||||
key_links:
|
||||
- from: "../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go"
|
||||
to: "summercms.go modules/bouncer/jwt.go"
|
||||
via: "bouncer.VerifyAuthTime replaces the iat read"
|
||||
pattern: "VerifyAuthTime"
|
||||
- from: "../sm-oauthserver-plugin/plugin.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/events.go"
|
||||
via: "Listen on *userclasses.AccessRevokedEvent, BackendLinkedEvent and BackendUnlinkedEvent"
|
||||
pattern: "AccessRevokedEvent"
|
||||
- from: "../sm-demo-app/plugins/golem15/user/plugin.go"
|
||||
to: "../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go"
|
||||
via: "Boot compiles the catalog from party.Activated and publishes it; a bad declaration fails boot"
|
||||
pattern: "CompileAPITokenScopes"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Close lane C of the phase code review and both sm-servers-app escalations, on the plugin side, as additive changes against the local framework from plans 06 and 07.
|
||||
|
||||
| Repository | Changes |
|
||||
|------------|---------|
|
||||
| sm-user-plugin (checkout `../sm-demo-app/plugins/golem15/user`) | C-CR-01 user side; C-CR-02 plugin side (compare against `auth_time`); C-WR-01; the C-WR-02 link events; E-1 organisation logo; E-2 member token scopes; C-IN-02, C-IN-04, C-IN-05, C-IN-06 |
|
||||
| `../sm-oauthserver-plugin` | C-CR-01 (verifier and refresh refusals, revoke on ban, reset or password change); C-WR-02 (revoke backend grants on link and unlink); C-IN-02 (client-specific revoke event); C-IN-05 |
|
||||
| `../sm-journal-plugin` | C-IN-01 (`draft_post` marked `Writes`) |
|
||||
| `../sm-demo-app` | nginx body cap (C-IN-03); the vue-demo-app `/link-admin` page (code in the fragment, POST show, signed-in account shown); plugin submodule checkouts synced to the local commits for verification |
|
||||
|
||||
**Planner decisions recorded here (P-34..P-39):**
|
||||
- **P-34 (link page and proof, C-CR-02 and C-WR-01):**
|
||||
- My account answers `golem15.user.frontend_url` (else `app.url`) + `golem15.user.backend_links.page_path` (new key, default `/link-admin`, C-IN-06) + `#code=<code>`.
|
||||
- New route `POST /_user/api/v1/backend-link/show` with body `{"code"}` and the same answers as the GET route. The GET route stays for compatibility (core-plugin additive rule); the README marks it deprecated because the code in its path reaches access logs.
|
||||
- The confirm reads the session token with `bouncer.VerifyAuthTime(..., bouncer.AudienceUser)` and passes `auth_time` to `ConfirmLinkRequest`. The signature is unchanged; the parameter is renamed `sessionAuthTime` in the doc. A token without `auth_time` answers 409 `stale_session`.
|
||||
- **P-35 (access revocation, C-CR-01):**
|
||||
- New `classes.AccessRevokedEvent{UserIDs []uint, Before time.Time, Reason string, Tx *gorm.DB}`.
|
||||
- New `classes.FireAccessRevoked(ctx, app, tx, userIDs, before, reason) error`. It fires the event in `tx` (a listener error rolls the write back) and one `pact.MCPSubjectRevoked` per user after commit.
|
||||
- Called by the plugin's ban action, password reset, an admin setting a password, and the self-service password change.
|
||||
- The ban action is a wrapper around `BanUsers`, whose exported signature is unchanged. Inside the action's transaction it reads `ThrottleStates` for the selected ids before and after `BanUsers`. The newly banned ids are those banned after but not before, and only they are passed to `FireAccessRevoked`.
|
||||
- `Before` is the untruncated instant of the revocation (`time.Now()` taken at the write). The stored `tokens_valid_after` keeps its whole-second shape (for example `now.Truncate(time.Second)` in `ResetPassword`). The self-service change keeps its cutoff of iat minus one second and passes `cutoff.Add(time.Second)`, the current session's sign-in second, so tokens issued since that sign-in survive.
|
||||
- `RevokeUserAccess`, `BanUsers` and `DeactivateUsers` keep their signatures. The README tells applications that call them directly to call `FireAccessRevoked` too. Deactivation keeps its `DeactivatingEvent` cascade.
|
||||
- oauthserver revokes MCP-client access and refresh tokens with `created_at < Before`. Both the verifier and the MCP refresh rotation also refuse a banned user, and refuse a token with `created_at` before `tokens_valid_after + 1s` (`CreatedAt.Before(cutoff.Add(time.Second))`).
|
||||
- Why a second is added: the stored cutoff is truncated to whole seconds while `created_at` is not. A token created at 12:00:05.300, before a reset at 12:00:05.700 that stores 12:00:05, is therefore refused by the verifier even without the revoke listener.
|
||||
- Why `!CreatedAt.After(cutoff)` alone is not enough: it lets that token through.
|
||||
- The cost is a token legitimately minted in the same second right after a reset. An OAuth consent round trip cannot complete that fast, so the cost is accepted.
|
||||
- The revocation sits behind one oauthserver function, `revokeUserGrants(ctx, tx, userIDs []uint, before time.Time, kinds []string) error`. `OnAccessRevoked` calls it with both the MCP and the OIDC client kinds: the user decided on 2026-10-23 that a ban or a password reset ends every OAuth grant of that user, MCP agents and OIDC sign-ins alike. Link changes (C-WR-02) still revoke only `backend`-scoped MCP grants.
|
||||
- **P-36 (backend grants follow the link, C-WR-02):** oauthserver listens to `BackendLinkedEvent` and `BackendUnlinkedEvent`. In the event's transaction it revokes the frontend user's unrevoked MCP access and refresh tokens whose scopes contain `backend`; after commit it fires `MCPSubjectRevoked` with each affected `ClientID`.
|
||||
- `BackendUnlinkedEvent` already fires on every unlink the plugin performs: My account, the Administrators screen, and the deletion or deactivation of the frontend user (`dropUserLink` → `RemoveLink`, documented in `classes/events.go`).
|
||||
- The link event is still handled for one silent path: deleting the backend administrator in cabana removes the link row through the foreign key's `ON DELETE CASCADE`, and no event fires. Revoking on every new link means a grant left over from that path cannot run with the reach of a later admin, so a backend grant only ever runs with the reach of the admin shown at its consent.
|
||||
- This is the review's first option. The second option, storing the consented admin on the grant, needs a framework field and an oauthserver migration and is not taken.
|
||||
- **P-37 (member token scopes, E-2):**
|
||||
- `classes.APITokenScope{Name, Label, Description, PluginID string; BuiltIn bool}` and `classes.APITokenScopeCatalog` (`Scopes()`, `Allowed(name)`).
|
||||
- `classes.CompileAPITokenScopes(plugins []party.Plugin) (*APITokenScopeCatalog, error)` validates with `pact.ValidTokenScopeName`. It refuses a built-in name (`read`, `write`, `ai`), a duplicate across plugins, an empty label or description, and a `::` label or description whose phrase key is missing (checked in Boot against the translator).
|
||||
- Boot compiles from `party.Activated`, publishes the catalog, and fails boot on an error.
|
||||
- `classes.APITokenScopesFor(app)` returns the published catalog or the built-ins.
|
||||
- **Validation is scoped to the application.** New `classes.MintAPITokenFor(app *backpack.App, prefix string, userID uint, name string, scopes []string, expiresAt *time.Time, collectionIDs []uint) (string, *models.APIToken, error)` checks scopes against `APITokenScopesFor(app)`. The HTTP mint route and the plugin's console command use it, and the README tells applications to use it.
|
||||
- The legacy `MintAPIToken` keeps its signature and keeps working for existing callers (for example an application's own token manager). It accepts the built-ins plus a process-wide fallback set: every name a booted catalog in this process declared. Production runs one application per process, so the set equals that application's catalog. The README documents the difference.
|
||||
- `classes.ResetDeclaredAPITokenScopes()` clears the fallback set. It is exported as a test seam (documented "tests only"), because the plugin's tests live outside the classes package.
|
||||
- The HTTP mint route checks the application's own catalog, so an undeclared scope answers the existing 422 text "The selected scope is invalid.". In a test binary that boots two applications, app B refuses app A's scope.
|
||||
- Discovery is `GET /_user/api/v1/tokens/scopes` behind `jwt.auth`, answering `{"data":[{"name","label","description","built_in"}]}` with built-ins first. Labels are translated with the plugin's `appTranslator` for the request locale.
|
||||
- `AllowedAPITokenScopes` stays the built-in list.
|
||||
- **P-38 (organisation logo, E-1):** a second public attachOne `logo` on `Organisation` (`OrganisationLogoField`); the existing `avatar` stays, for PHP parity and additivity.
|
||||
- Attachments live in `system_files`, so there is no migration.
|
||||
- The Organisations form gains an image `fileupload` field `logo`.
|
||||
- The plugin serves no frontend organisation payload today, so it ships two helpers for the applications that build one:
|
||||
- `classes.OrganisationLogoURL(ctx, app, org, size) (string, bool, error)`;
|
||||
- `classes.OrganisationLogoFields(ctx, app, org) (map[string]any, error)`, answering `has_logo`, `logo` (disk name or nil) and `logo_url` (a 256 px thumbnail or nil), the keys the user payload uses for avatars.
|
||||
- Reversibility costly: the relation name is stored in `system_files.field`.
|
||||
- **P-39 (local verification wiring):** oauthserver's git-ignored `go.work` points `sm-user-plugin` at `../sm-demo-app/plugins/golem15/user`. Today it points at another application's checkout, which lacks the new exports. The demo's `plugins/golem15/oauthserver` and `plugins/golem15/journal` submodule checkouts are moved, detached, to this plan's local plugin commits so the demo's end-to-end test runs them.
|
||||
- None of this is committed: the pointer bumps in sm-demo-app happen after the plugin tags, per the release order.
|
||||
- The vue-demo-app pointer is a normal local commit in sm-demo-app, as in plan 04. vue-demo-app is pushed before sm-demo-app when the user releases.
|
||||
|
||||
**Commits are self-contained:** each task's commits build and pass the repository's `go vet` and `-short` tests on their own. No commit leaves a repository relying on a later task's commit, and a cross-repository dependency is always committed in the order user plugin → oauthserver → demo.
|
||||
|
||||
Purpose: SC-4's identity chain holds under ban, password reset, refresh and re-linking; sm-servers-app gets E-1 and E-2; plan 09 can pin all of it.
|
||||
Output: local commits in sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin, vue-demo-app and sm-demo-app; three smoke tests.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.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.7-generic-mcp-module/19.7-07-SUMMARY.md
|
||||
@.planning/notes/2026-10-23-frontend-token-scopes.md
|
||||
@.planning/notes/core-plugins-own-repos.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Core-plugin rule: sm-user-plugin is used by many applications, and oauthserver and Journal are shared. Every change is additive:
|
||||
- no exported func, method or type removed or re-signed (the gate's additive check against 930b158 and v0.1.9 for the user plugin, d31f8e7 for oauthserver, ffa2c8f for Journal);
|
||||
- no route, column, migration id, config key, permission code or payload field removed or renamed;
|
||||
- existing error bodies stay word for word.
|
||||
- Plugin go.mod `require` lines stay as they are (summercms v0.4.4, sm-user-plugin v0.1.10 in oauthserver). The local framework comes from each repository's `replace ../summercms.go` or go.work. Never run `go get` for the framework or a plugin.
|
||||
- The user plugin is built and tested with `GOWORK=off`; its go.mod replace points at `../../../../summercms.go`. oauthserver uses its git-ignored go.work (Task 2 retargets it). Journal uses its tracked go.work, which is left unchanged.
|
||||
- Docker-backed tests: if the socket is denied although the user is in the docker group, run them through `sudo -u golem` (CLAUDE.md). Postgres tests never use `t.Parallel`; they seed unique rows and clean up.
|
||||
- Unit tests are plan 09's job. This plan carries three smokes (`TestBackendLinkAuthTimeSmoke`, `TestMCPRevocationSmoke`, `TestMemberTokenScopesSmoke`) and keeps every existing suite green: `TestBackendLink`, `TestUserMCPGuard`, `TestMCPTokenVerifier`, `TestMCPConsent`, `TestJournalMCP`, `TestMCPEndToEnd`. A test pinning the old behaviour (for example the iat-based confirm) changes in the fix commit and is named in the SUMMARY.
|
||||
- Each plugin's README changes in the same commit as its exported API, config keys or routes.
|
||||
- sm-demo-app has uncommitted changes from other sessions (`main.go`, the `plugins/golem15/user` pointer from plan 05): run `git -C ../sm-demo-app status --short` first and never stage either. Stage by explicit path in every repository. One logical change per commit, no co-author tags. Order: plugin repo commits first, then sm-demo-app commits.
|
||||
- Release rule: no tag, push or deploy in this plan.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: the account link proof end to end — My account answers a fragment link, the site page shows the request through POST and the signed-in account, and only a session signed in after the request (auth_time) confirms it</name>
|
||||
<precondition>Plan 07's `bouncer.VerifyAuthTime` exists in the local framework (`grep -c "func VerifyAuthTime(" modules/bouncer/jwt.go` prints 1), and a Docker daemon answers (`docker info`, directly or through `sudo -u golem`).</precondition>
|
||||
<files>../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go, ../sm-demo-app/plugins/golem15/user/classes/backend_links.go, ../sm-demo-app/plugins/golem15/user/account_contributions.go, ../sm-demo-app/plugins/golem15/user/routes.go, ../sm-demo-app/plugins/golem15/user/config/config.yaml, ../sm-demo-app/plugins/golem15/user/README.md, ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_smoke_test.go, ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue, ../sm-demo-app/vue-demo-app/app/lib/linkCode.ts, ../sm-demo-app/vue-demo-app/i18n/locales/en.json, ../sm-demo-app/vue-demo-app/i18n/locales/pl.json, ../sm-demo-app/vue-demo-app</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections C-CR-02, C-WR-01 and C-IN-06; 19.7-07-SUMMARY.md (`VerifyAuthTime`'s final signature)
|
||||
- U controllers/backend_link_controller.go (`BackendLinkShow`, `BackendLinkConfirm`, `backendLinks`, `isLinkGone`); U classes/backend_links.go (`LinkRequestByCode`, `ConfirmLinkRequest` and its doc, `requestUsable`); U account_contributions.go (`startFrontendLink`); U routes.go (the `/backend-link/*` routes and `g.Where("code", ...)`); U config/config.yaml (`frontend_url`, `backend_links`); U classes `FrontendURL`
|
||||
- U backend_link_smoke_test.go and backend_link_test.go (the Postgres harness, `startLink`/`confirmLink`, how a session token is minted for a user)
|
||||
- V app/pages/link-admin.vue, app/composables/useDemoAuth.ts (token cookie, logout), app/pages/login.vue (how `next` is followed), i18n/locales/en.json and pl.json (`linkAdmin.*`)
|
||||
- U README.md, the account link section
|
||||
</read_first>
|
||||
<action>
|
||||
Implement P-34.
|
||||
|
||||
**U backend_link_controller.go:**
|
||||
- `BackendLinkConfirm` replaces the `VerifyClaims` iat read with `bouncer.VerifyAuthTime(classes.SessionToken(r), secret, bouncer.AudienceUser)`. A subject mismatch or a verify error stays 401. `ok == false` answers the existing 409 `stale_session` body. Pass `authTime` to `ConfirmLinkRequest`.
|
||||
- Add `BackendLinkShowPost(app)`: it reads `{"code"}` with `readFields` and answers exactly like `BackendLinkShow`: the same 404 for an unknown, used or expired code, and the same data shape. Both show handlers set `Cache-Control: no-store, private`.
|
||||
|
||||
**U classes/backend_links.go:** rename the `ConfirmLinkRequest` parameter to `sessionAuthTime` and rewrite its doc. The proof is the sign-in time (`auth_time`), which a refresh never renews; the comparison stays in whole seconds against `created_at`. Keep the signature and types.
|
||||
|
||||
**U routes.go:** add `g.Post("/backend-link/show", controllers.BackendLinkShowPost(p.app))` in the same group. The GET route stays.
|
||||
|
||||
**U account_contributions.go:**
|
||||
- `startFrontendLink` answers `classes.FrontendURL(p.app) + pagePath + "#code=" + plain`. Rewrite its doc comment to describe the fragment link as well; the comment must not show the old query-string form.
|
||||
- `pagePath` comes from the new config key `golem15.user.backend_links.page_path` (default `/link-admin`; a value without a leading `/` gets one) through a small helper in classes next to `FrontendURL`.
|
||||
- Add the key to config/config.yaml under `backend_links`.
|
||||
|
||||
**U README.md:** the link section describes:
|
||||
- the fragment URL;
|
||||
- the POST show route;
|
||||
- the GET show route, kept for compatibility (its path puts the code in access logs, so pages use POST);
|
||||
- `page_path`;
|
||||
- the `auth_time` rule, with an upgrade note: session tokens issued before this release carry no `auth_time`, so a frontend user signed in before the upgrade gets `stale_session` and must sign in again before linking. A refresh does not help, because it carries the absence forward.
|
||||
|
||||
**New smoke `backend_link_auth_time_smoke_test.go`** (Postgres, created only when not `-short`) holds `TestBackendLinkAuthTimeSmoke`:
|
||||
1. A user signs in (minted token).
|
||||
2. The admin creates a request.
|
||||
3. Refreshing the old token through `POST /_user/api/v1/refresh` and confirming with the refreshed token answers 409 `stale_session`.
|
||||
4. A login after the request confirms with 200.
|
||||
5. `POST /backend-link/show` with the code in the body answers the admin's login.
|
||||
6. The My account action's URL contains `/link-admin#code=` and no query string.
|
||||
|
||||
**V app/lib/linkCode.ts** (pure, unit-testable in plan 09):
|
||||
- `LINK_CODE_KEY = 'link-admin-code'`;
|
||||
- `readLinkCode(hash: string): string`, returning the 64-hex value of a `#code=` fragment or '';
|
||||
- `isLinkCode(s: string): boolean`.
|
||||
|
||||
**V app/pages/link-admin.vue:**
|
||||
- In `onMounted` (client only), read the fragment. If it holds a code, store it under `LINK_CODE_KEY` in `sessionStorage` and drop the fragment with `history.replaceState`. Otherwise take the stored code.
|
||||
- Load the request with `$fetch('/_user/api/v1/backend-link/show', { method: 'POST', body: { code } })`.
|
||||
- When signed in, load `GET /_user/api/v1/fetch` with the bearer and show `linkAdmin.signedInAs` (the email) above the confirm button, with a `linkAdmin.notYou` action that calls `logout()` and shows the sign-in link.
|
||||
- The sign-in link is `/login?next=/link-admin`; the code stays in sessionStorage, never in a URL.
|
||||
- Remove the stored code on success and when the request is gone.
|
||||
- The route's query parameter is no longer read, and the page's header comment describes the fragment flow.
|
||||
- Add `linkAdmin.signedInAs` and `linkAdmin.notYou` to en.json and pl.json.
|
||||
- Reword the existing `linkAdmin.signInAgain` text (shown after a 409 `stale_session` or a 401) in both locales. It says the link needs a sign-in made after the request, and that a session started before the site's last update, or before the link was requested, must sign in again. For example, en: "Linking needs a fresh sign-in. Sessions started before the link was requested, or before the site was last updated, have to sign in again." Add pl to match.
|
||||
|
||||
Run `pnpm --dir ../sm-demo-app/vue-demo-app run test` (the existing lib tests stay green).
|
||||
|
||||
**Commits:**
|
||||
1. The user plugin commit.
|
||||
2. The vue-demo-app commit in its submodule checkout.
|
||||
3. In sm-demo-app, a separate local commit `chore: bump vue-demo-app (link page: code in the fragment, POST show)` staging only `vue-demo-app`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^(TestBackendLinkAuthTimeSmoke|TestBackendLink|TestBackendLinkSmoke)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && pnpm --dir ../sm-demo-app/vue-demo-app run test</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or fewer than 3 top-level PASS lines (a SKIP because Docker is unreachable counts as not passing: run on a Docker host, through sudo -u golem if needed)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go | grep -c "bouncer.VerifyAuthTime("` prints 1 and the same filter for `bouncer.VerifyClaims(` prints 0
|
||||
- `grep -c 'g.Post("/backend-link/show"' ../sm-demo-app/plugins/golem15/user/routes.go` prints 1 and `grep -c 'g.Get("/backend-link/{code}"' ../sm-demo-app/plugins/golem15/user/routes.go` prints 1 (kept)
|
||||
- `grep -c '#code=' ../sm-demo-app/plugins/golem15/user/account_contributions.go` prints 1 and `grep -c '?code=' ../sm-demo-app/plugins/golem15/user/account_contributions.go` prints 0
|
||||
- `grep -c "page_path" ../sm-demo-app/plugins/golem15/user/config/config.yaml ../sm-demo-app/plugins/golem15/user/README.md` prints at least 1 per file
|
||||
- `grep -c "route.query" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints 0, `grep -c "sessionStorage" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints at least 1, and `grep -c "signedInAs" ../sm-demo-app/vue-demo-app/i18n/locales/en.json ../sm-demo-app/vue-demo-app/i18n/locales/pl.json` prints 1 per file
|
||||
- `git -C ../sm-demo-app log -1 --name-only --format=%s | grep -c "^vue-demo-app$"` prints 1 and the same commit lists neither `main.go` nor `plugins/golem15/user`
|
||||
</acceptance_criteria>
|
||||
<done>The link proof rests on the sign-in time, the code never appears in a URL the server sees, and the person confirming sees which account they are linking; the smoke proves refresh no longer passes as a fresh sign-in.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Grant revocation chain: ban, password reset or change revoke MCP grants and end sessions; the verifier and refresh refuse banned and pre-cutoff tokens; backend grants follow the link; token- and client-specific revoke events; last_used_ip on /mcp; deduplicated helpers</name>
|
||||
<reversibility rating="reversible">New events and listeners plus stricter refusals; nothing stored changes shape.</reversibility>
|
||||
<files>../sm-demo-app/plugins/golem15/user/classes/events.go, ../sm-demo-app/plugins/golem15/user/classes/access_revoked.go, ../sm-demo-app/plugins/golem15/user/classes/backend_links.go, ../sm-demo-app/plugins/golem15/user/classes/subject_events.go, ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go, ../sm-demo-app/plugins/golem15/user/controllers/api_controller.go, ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go, ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go, ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go, ../sm-demo-app/plugins/golem15/user/account_contributions.go, ../sm-demo-app/plugins/golem15/user/README.md, ../sm-oauthserver-plugin/classes/mcp_verifier.go, ../sm-oauthserver-plugin/classes/mcp_store.go, ../sm-oauthserver-plugin/classes/cascade.go, ../sm-oauthserver-plugin/classes/subject_events.go, ../sm-oauthserver-plugin/controllers/authorizations.go, ../sm-oauthserver-plugin/plugin.go, ../sm-oauthserver-plugin/mcp_revocation_smoke_test.go, ../sm-oauthserver-plugin/README.md</files>
|
||||
<read_first>
|
||||
- 19.7-REVIEW.md, sections C-CR-01, C-WR-02, C-IN-02, C-IN-04 and C-IN-05
|
||||
- U classes/admin_actions.go (`ThrottleStates`, `RevokeUserAccess`, `BanUsers`, `DeactivateUsers`); U classes/events.go (event structs, the `*EventName` constants, `BackendLinkedEvent`, `BackendUnlinkedEvent`); U classes/subject_events.go; U classes/backend_links.go (`LinkedBackendUser` SQL at ~385-410, `insertLink`, `RemoveLink`, `requestUsable`); U models/backend_link_request.go (`IsUsableAt`)
|
||||
- U controllers/api_controller.go (`ResetPassword` at ~440-460, `ChangePassword` at ~700-725); U controllers/users_admin_controller.go (password store at ~236-252, the bulk actions at ~625-660); U controllers/api_tokens.go (`APITokenDestroy`); U classes/mcp_guard.go (`MCPResolvePersonalToken`); U middleware/api_token.go (how `last_used_ip` is stamped)
|
||||
- O classes/mcp_verifier.go (`MCPVerifyToken`), classes/mcp_store.go (`mcpTx.refresh` at ~286, `revokeRefreshLineage`), classes/cascade.go (`Cascade`, `purge`), classes/subject_events.go, controllers/authorizations.go (revoke handler at ~110-125), plugin.go (listener registration at ~99-103), models/access_token.go and refresh_token.go (Scopes, CreatedAt, RevokedAt), models/client.go (`ClientKindMCP`), mcp_verifier_smoke_test.go and harness_test.go (test shapes)
|
||||
- summercms.go modules/towel/context.go (`ClientIP`) and modules/pact/mcp.go (`MCPSubjectChanged.TokenID`, `ClientID`) from plan 07
|
||||
- `cat ../sm-oauthserver-plugin/go.work` (the current `sm-user-plugin` replace target)
|
||||
</read_first>
|
||||
<action>
|
||||
**Step 0, local environment (P-39).** Edit the git-ignored `../sm-oauthserver-plugin/go.work` so its `sm-user-plugin` replace points at `../sm-demo-app/plugins/golem15/user`. Record the previous target in the SUMMARY. Never commit go.work.
|
||||
|
||||
**U, P-35:**
|
||||
- In classes/events.go, add `AccessRevokedEvent{UserIDs []uint; Before time.Time; Reason string; Tx *gorm.DB}` and `AccessRevokedEventName = "user.AccessRevoked"`, documented like the other events.
|
||||
- New file classes/access_revoked.go holds `FireAccessRevoked(ctx context.Context, app *backpack.App, tx *gorm.DB, userIDs []uint, before time.Time, reason string) error`. It fires the event (a listener error is returned, so the caller's transaction rolls back), then for each id calls `FireSubjectChangedAfterCommit` with `MCPSubjectRevoked`. A nil app or bus, or an empty id list, is a no-op.
|
||||
- Callers:
|
||||
- **Ban.** `usersAdminController` gets a `banUsers` wrapper used by the `ban` bulk action. Inside the action's transaction `tx`:
|
||||
1. read `classes.ThrottleStates(ctx, tx, ids)` for the selected ids;
|
||||
2. call `classes.BanUsers(ctx, tx, users)`;
|
||||
3. read `ThrottleStates` again;
|
||||
4. take the newly banned ids (banned after, not before), and only when that list is non-empty call `FireAccessRevoked(ctx, app, tx, newly, time.Now(), "ban")`.
|
||||
- **Password reset.** `ResetPassword` keeps storing `tokens_valid_after = now.Truncate(time.Second)`, so the column keeps its shape. It passes the untruncated `now` as `before`, reason `password_reset`. The handler runs outside a transaction today: wrap the update and the event in `lagoon.Transaction`, so a listener failure leaves the password unchanged.
|
||||
- **Self-service change.** `ChangePassword` keeps `cutoff = iat - 1s` in the column and passes `cutoff.Add(time.Second)` (the current session's sign-in second) as `before`, reason `password_changed`. Tokens issued since that sign-in survive, as the session JWT does.
|
||||
- **Admin-set password.** The admin password store keeps the truncated value in the column and passes the untruncated `time.Now()` as `before`, reason `password_set_by_admin`, in the save's transaction (`requestDB` or the hook's tx).
|
||||
- `LinkedBackendUser` adds `AND NOT EXISTS (SELECT 1 FROM user_throttle t WHERE t.user_id = l.user_id AND t.is_banned)`. The columns are `user_throttle.user_id` and `user_throttle.is_banned` (models/throttle.go).
|
||||
|
||||
**U, C-IN-02, C-IN-04, C-IN-05:**
|
||||
- `APITokenDestroy` fires `MCPSubjectRevoked` with `TokenID: token.ID` through a new exported helper pair in classes/subject_events.go: `FireSubjectEvent(ctx, app, ev pact.MCPSubjectChanged)` and `FireSubjectEventAfterCommit(ctx, app, tx, ev)`. The existing helpers become wrappers with their signatures kept.
|
||||
- `MCPResolvePersonalToken` also stamps `last_used_ip` from `towel.ClientIP(ctx)` when present, in the same `UpdateColumns` call as `last_used_at`.
|
||||
- `requestUsable` keeps its error split but uses `req.IsUsableAt` for the combined check.
|
||||
- Add an exported `classes.BackendLinksFor(app) *BackendLinks`, used by both account_contributions.go and the controller instead of their duplicate lookups.
|
||||
- Confirm, in code and README, that `BackendLinkedEvent` and `BackendUnlinkedEvent` fire on every link and unlink path, with `Link.UserID` set. These are the C-WR-02 events oauthserver listens to.
|
||||
- The README gains the access-revocation section: when it fires, the event, and what applications calling `RevokeUserAccess` or `BanUsers` directly must add.
|
||||
|
||||
**O:**
|
||||
- Add one unexported helper, `issuedBeforeCutoff(createdAt *time.Time, cutoff time.Time) bool`. It answers true when the cutoff is set and `createdAt` is nil or `createdAt.Before(cutoff.Add(time.Second))`. Reason: the stored cutoff is truncated to whole seconds, so a token created earlier in the cutoff's second must be refused too (P-35). Both checks below use it.
|
||||
- classes/mcp_verifier.go: after loading the principal, refuse with `pact.ErrMCPTokenInvalid` when `issuedBeforeCutoff(token.CreatedAt, principal.TokensValidAfter)`, or when `userclasses.ThrottleStates` reports the user banned. A database error is returned as an error.
|
||||
- classes/mcp_store.go `mcpTx.refresh`: apply the same three refusals (user gone through `PrincipalByID`, banned, `issuedBeforeCutoff` on the refresh token) by answering the store's existing not-found result, which wristband maps to `invalid_grant`.
|
||||
- classes/cascade.go:
|
||||
- Add the single revocation function `revokeUserGrants(ctx context.Context, tx *gorm.DB, userIDs []uint, before time.Time, kinds []string) error`. It sets `revoked_at` on the users' unrevoked access and refresh tokens created before `before`, whose client kind is in `kinds`, and returns the distinct client ids it touched.
|
||||
- `OnAccessRevoked(ctx, *userclasses.AccessRevokedEvent)` calls it in `ev.Tx` with `ev.Before` and the MCP and OIDC client kinds (user decision 2026-10-23: a ban or reset ends every OAuth grant). Before revoking, check how OIDC grants are stored (client kind constant, consent rows, access and refresh tokens) and revoke the tokens and the consent row so the OIDC client must ask again; record the exact rows touched in the SUMMARY.
|
||||
- `OnBackendLinkChanged(ctx, userID uint, tx *gorm.DB)` sets `revoked_at` on the user's unrevoked MCP access and refresh tokens whose scopes contain `backend`, then fires `MCPSubjectRevoked` with each distinct `ClientID` after commit.
|
||||
- Two adapters: `OnBackendLinked(ctx, *userclasses.BackendLinkedEvent)` and `OnBackendUnlinked(ctx, *userclasses.BackendUnlinkedEvent)`.
|
||||
- plugin.go: register the three listeners next to the existing two.
|
||||
- controllers/authorizations.go: the revoke fires with `ClientID: clientID`.
|
||||
- classes/subject_events.go: delegate to the user plugin's helpers. Keep oauthserver's exported names as thin wrappers (additive rule).
|
||||
- README: the revocation behaviour.
|
||||
|
||||
**New smoke `../sm-oauthserver-plugin/mcp_revocation_smoke_test.go`** (Postgres) holds `TestMCPRevocationSmoke`:
|
||||
1. Mint an MCP access and refresh token for a user.
|
||||
2. `BanUsers` plus `FireAccessRevoked` in one transaction.
|
||||
3. The verifier answers `ErrMCPTokenInvalid`.
|
||||
4. Both rows have `revoked_at`.
|
||||
5. A refresh is refused.
|
||||
6. A second user linked to an admin with a `backend` grant loses it on `RemoveLink`, and keeps a grant without `backend`.
|
||||
|
||||
**Commits:** the user plugin first, then oauthserver.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^(TestBackendLink|TestUserMCPGuard|TestBackendLinkAuthTimeSmoke)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 && go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./... && go -C ../sm-oauthserver-plugin test -count=1 -run '^(TestMCPRevocationSmoke|TestMCPTokenVerifier|TestMCPConsent)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, or a PASS count other than 3 for either repository (a SKIP without Docker counts as not passing)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "type AccessRevokedEvent struct" ../sm-demo-app/plugins/golem15/user/classes/events.go` prints 1 and `grep -c "func FireAccessRevoked(" ../sm-demo-app/plugins/golem15/user/classes/access_revoked.go` prints 1
|
||||
- `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/controllers/api_controller.go | grep -c "FireAccessRevoked("` prints at least 2 and `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go | grep -c "FireAccessRevoked("` prints at least 2
|
||||
- `grep -c "is_banned" ../sm-demo-app/plugins/golem15/user/classes/backend_links.go` prints at least 1 (`user_throttle.is_banned`, models/throttle.go)
|
||||
- `grep -v '^\s*//' ../sm-oauthserver-plugin/classes/mcp_verifier.go | grep -c "ThrottleStates(\|TokensValidAfter"` prints at least 2
|
||||
- `grep -c "AccessRevokedEvent\|BackendLinkedEvent\|BackendUnlinkedEvent" ../sm-oauthserver-plugin/plugin.go` prints at least 3
|
||||
- `grep -v '^\s*//' ../sm-oauthserver-plugin/controllers/authorizations.go | grep -c "ClientID"` prints at least 1 and `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go | grep -c "last_used_ip"` prints at least 1
|
||||
- `git -C ../sm-oauthserver-plugin status --short go.work | wc -l` prints 0 (go.work stays ignored and uncommitted)
|
||||
- `grep -c "func revokeUserGrants(\|func issuedBeforeCutoff(" ../sm-oauthserver-plugin/classes/*.go | awk -F: '{s+=$2} END {print s}'` prints 2, and `grep -v '^\s*//' ../sm-oauthserver-plugin/classes/mcp_verifier.go ../sm-oauthserver-plugin/classes/mcp_store.go | grep -c "issuedBeforeCutoff("` prints at least 2
|
||||
- `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go | grep -c "ThrottleStates("` prints at least 2 (before and after BanUsers)
|
||||
</acceptance_criteria>
|
||||
<done>A banned or password-reset user's MCP grants stop working at once and their sessions end, refresh cannot revive them, a banned user's link stops resolving, a backend grant cannot outlive or be re-targeted by a link change, and single-token or single-client revocations end only what they opened.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: E-2 member token scopes: catalog from pact.HasFrontendTokenScopes, boot validation, mint, check, list and discovery</name>
|
||||
<reversibility rating="costly">Declared scope names are stored on `user_api_tokens` rows and the discovery route is a published contract of a core plugin.</reversibility>
|
||||
<files>../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go, ../sm-demo-app/plugins/golem15/user/classes/api_tokens.go, ../sm-demo-app/plugins/golem15/user/console/api_tokens.go, ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go, ../sm-demo-app/plugins/golem15/user/routes.go, ../sm-demo-app/plugins/golem15/user/plugin.go, ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml, ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml, ../sm-demo-app/plugins/golem15/user/README.md, ../sm-demo-app/plugins/golem15/user/member_token_scopes_smoke_test.go</files>
|
||||
<read_first>
|
||||
- 19.7-GAP-INPUTS.md, section E-2 (the ask, "Not asked for", acceptance); .planning/notes/2026-10-23-frontend-token-scopes.md (decision P-30)
|
||||
- summercms.go modules/pact/capabilities.go (`FrontendTokenScope`, `HasFrontendTokenScopes`, `ValidTokenScopeName`) and modules/cabana/token_scopes.go (`validatePluginTokenScope`, `validateTokenScopeMessageKeys`: the validation style to mirror)
|
||||
- U classes/api_tokens.go (`AllowedAPITokenScopes`, `DefaultAPITokenScopes`, `MintAPIToken`), controllers/api_tokens.go (`APITokenStore`, `APITokenIndex`, `apiTokenScopes`, `apiTokenJSON`), middleware/api_token.go (`Scope`), models/api_token.go (`HasScope`), routes.go (the `/tokens` routes), plugin.go (`Boot`, `bootMCPGuard` as the publish pattern), classes/frontend_permission_catalog.go (`party.Activated` lookup), controllers/app_access.go (`appTranslator`)
|
||||
- U api_tokens_test.go and api_tokens_edge_test.go (harness for token routes)
|
||||
- ../fonoteka.go/plugins/golem15/fonoteka/classes/auth/api_token_manager.go (an application calling `MintAPIToken` directly; its call must keep compiling unchanged) and ../fonoteka.go/go.work (its workspace `use`s its own user checkout; the verify builds it through a scratch copy that swaps in this checkout; fonoteka's own go.work is never edited)
|
||||
</read_first>
|
||||
<action>
|
||||
Implement P-37 in a new file classes/api_token_scopes.go:
|
||||
- `APITokenScope` (Name, Label, Description, PluginID, BuiltIn).
|
||||
- `APITokenScopeCatalog` with `Scopes() []APITokenScope` (a copy, built-ins first, then declarations in activation order) and `Allowed(name string) bool`.
|
||||
- `CompileAPITokenScopes(plugins []party.Plugin) (*APITokenScopeCatalog, error)`. The built-ins `read`, `write` and `ai` carry the labels `golem15.user::lang.api_tokens.scope_<name>` and `scope_<name>_description`. Each `pact.HasFrontendTokenScopes` declaration is checked:
|
||||
- the name is trimmed and must pass `pact.ValidTokenScopeName`;
|
||||
- it must not be a built-in;
|
||||
- it must not repeat another plugin's name; the error names both plugins, like cabana's;
|
||||
- label and description must be non-empty.
|
||||
- Every accepted declared name is added to an unexported process-wide set guarded by a `sync.RWMutex`.
|
||||
- `APITokenScopesFor(app *backpack.App) *APITokenScopeCatalog` returns the published catalog or a built-ins-only one.
|
||||
- Add `MintAPITokenFor(app *backpack.App, prefix string, userID uint, name string, scopes []string, expiresAt *time.Time, collectionIDs []uint) (string, *models.APIToken, error)`. It checks scopes with `APITokenScopesFor(app).Allowed` and shares the record-building body with `MintAPIToken` through an unexported helper that takes the allow-check as a func.
|
||||
- `MintAPIToken` keeps its signature, dedupe and default. Its check becomes "built-in, or in the process-wide declared set" (the legacy fallback; its doc points new code to `MintAPITokenFor`).
|
||||
- Add `ResetDeclaredAPITokenScopes()`, which clears the process-wide set. Document it as a test seam that production never calls.
|
||||
- The plugin's console token command (console/api_tokens.go) switches to `MintAPITokenFor` with its app.
|
||||
- `AllowedAPITokenScopes` stays, documented as the built-ins.
|
||||
|
||||
In plugin.go `Boot`:
|
||||
- compile from `app.Lookup[party.Activated]()`;
|
||||
- check every `::` label and description against the translator (`appTranslator` or `app.Lookup[*phrasebook.Translator]`), failing boot on a missing key;
|
||||
- publish the catalog;
|
||||
- return any error, so boot fails.
|
||||
|
||||
In controllers/api_tokens.go:
|
||||
- `apiTokenScopes(raw any)` becomes `apiTokenScopes(catalog, raw)` (unexported, free to change) and checks `catalog.Allowed`. The 422 texts stay word for word.
|
||||
- `APITokenStore` mints with `classes.MintAPITokenFor(app, ...)`.
|
||||
- New handler `APITokenScopes(app)` answers `{"data":[{"name","label","description","built_in"}]}`, translating labels and descriptions with `appTranslator(app)` for the request locale.
|
||||
|
||||
In routes.go, add `g.Get("/tokens/scopes", controllers.APITokenScopes(p.app), "jwt.auth")` next to the token routes.
|
||||
|
||||
Lang en and pl gain the six built-in label and description keys:
|
||||
- read: "Read" / "Odczyt";
|
||||
- write: "Write" / "Zapis";
|
||||
- ai: "AI" / "AI";
|
||||
- each with a one-line description.
|
||||
|
||||
The README gets a "Member token scopes" section covering:
|
||||
- declaring with `pact.HasFrontendTokenScopes`, with a short example declaring `inventory:read` and `inventory:write` (neutral names: a shared plugin README names no consuming application);
|
||||
- the boot errors;
|
||||
- mint, check and list behaviour, with `MintAPITokenFor` as the call applications should use and `MintAPIToken`'s process-wide fallback explained;
|
||||
- the discovery route and its answer;
|
||||
- that the admin `g15_` catalog never shows these scopes.
|
||||
|
||||
**New smoke `member_token_scopes_smoke_test.go`:**
|
||||
- `-short` part: `CompileAPITokenScopes` with two test plugins declaring the same name fails; a plugin declaring `write` fails; a bad name fails. Call `ResetDeclaredAPITokenScopes()` in a `t.Cleanup`.
|
||||
- Postgres part (created only when not `-short`):
|
||||
1. A test plugin declaring `servers:write` is activated.
|
||||
2. `POST /_user/api/v1/tokens` with `["servers:write"]` answers 201.
|
||||
3. A test route behind `APITokenGuard` plus `middleware.Scope("servers:write")` accepts the token.
|
||||
4. A `read`-only token gets 403 `Missing required scope: servers:write`.
|
||||
5. `["servers:nope"]` answers 422 `The selected scope is invalid.`.
|
||||
6. `GET /tokens/scopes` lists `read`, `write`, `ai` and `servers:write` with labels.
|
||||
7. A second application booted in the same test without the declaring plugin refuses `["servers:write"]` with the same 422, and `MintAPITokenFor` with that application refuses it.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -run '^TestMemberTokenScopesSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestMemberTokenScopesSmoke' && W="$(mktemp -d)" && trap 'rm -rf "$W"' EXIT && F="$(realpath ../fonoteka.go)" && U="$(realpath ../sm-demo-app/plugins/golem15/user)" && printf 'go 1.27.0
|
||||
|
||||
toolchain go1.27.0
|
||||
|
||||
use (
|
||||
%s
|
||||
%s/plugins/golem15/feedback
|
||||
%s/plugins/golem15/fonoteka
|
||||
%s/plugins/golem15/golem
|
||||
%s
|
||||
)
|
||||
|
||||
replace git.golem15.com/golem15/summercms => %s
|
||||
' "$F" "$F" "$F" "$F" "$U" "$(pwd)" > "$W/go.work" && test "$(GOWORK="$W/go.work" go -C ../fonoteka.go list -m -f '{{.Dir}}' git.golem15.com/golem15/sm-user-plugin)" = "$U" && GOWORK="$W/go.work" go -C ../fonoteka.go build ./... && rm -rf "$W"</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, the PASS line missing (SKIP without Docker counts as missing), the scratch workspace not resolving sm-user-plugin to the demo's user checkout, or fonoteka.go failing to build against the modified user plugin</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "func CompileAPITokenScopes(\|func APITokenScopesFor(\|type APITokenScopeCatalog struct\|func ResetDeclaredAPITokenScopes(" ../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go` prints 4
|
||||
- `grep -c "func MintAPITokenFor(" ../sm-demo-app/plugins/golem15/user/classes/api_tokens.go` prints 1 and `grep -v '^\s*//' ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go | grep -c "MintAPITokenFor("` prints 1
|
||||
- `git -C ../fonoteka.go status --short go.work | wc -l` prints 0 (fonoteka's workspace untouched)
|
||||
- `grep -c "pact.HasFrontendTokenScopes\|pact.ValidTokenScopeName" ../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go` prints at least 2
|
||||
- `grep -c 'g.Get("/tokens/scopes"' ../sm-demo-app/plugins/golem15/user/routes.go` prints 1
|
||||
- `grep -c "AllowedAPITokenScopes = \[\]string{\"read\", \"write\", \"ai\"}" ../sm-demo-app/plugins/golem15/user/classes/api_tokens.go` prints 1 (the built-in list keeps its exported form)
|
||||
- `grep -c "The selected scope is invalid." ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go` prints at least 1
|
||||
- `grep -c "HasFrontendTokenScopes\|tokens/scopes" ../sm-demo-app/plugins/golem15/user/README.md` prints at least 2
|
||||
</acceptance_criteria>
|
||||
<done>A plugin's declared member scopes can be minted, checked, listed and discovered; undeclared ones are refused at mint time; bad declarations fail boot; the admin token catalog is untouched; MintAPIToken's callers in applications compile unchanged.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: E-1 organisation logo; Journal's draft_post under the write ceiling; the demo's nginx MCP body cap; demo submodule checkouts on the local plugin commits</name>
|
||||
<reversibility rating="costly">The attachment relation name `logo` is stored in system_files.field and read by applications' payloads; renaming it needs a data update.</reversibility>
|
||||
<files>../sm-demo-app/plugins/golem15/user/models/organisation.go, ../sm-demo-app/plugins/golem15/user/models/organisation/fields.yaml, ../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go, ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml, ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml, ../sm-demo-app/plugins/golem15/user/README.md, ../sm-journal-plugin/mcp.go, ../sm-journal-plugin/README.md, ../sm-demo-app/deploy/nginx/demo.summercms.io.conf, ../sm-demo-app/scripts/check-deploy.sh, ../sm-demo-app/plugins/golem15/oauthserver, ../sm-demo-app/plugins/golem15/journal</files>
|
||||
<read_first>
|
||||
- 19.7-GAP-INPUTS.md, section E-1; 19.7-REVIEW.md, sections C-IN-01 and C-IN-03
|
||||
- U models/organisation.go (`OrganisationAvatarField`, `AttachRelations`, `MorphName`), models/organisation/fields.yaml (the `avatar` fileupload), classes/avatar.go (`AvatarURL`: the attachment query, the bucket lookup, `f.Thumb`), controllers/api_controller.go `applyAvatar` (the `avatar`, `avatar_url`, `has_avatar` keys), admin_organisations_test.go (how the organisation form is exercised)
|
||||
- J mcp.go (the `draft_post` prompt at ~154-166) and README.md (the MCP section); summercms.go modules/pact/mcp.go (`MCPPrompt.Writes` from plan 06)
|
||||
- D deploy/nginx/demo.summercms.io.conf (`location = /mcp` at ~213-226, the server-level `client_max_body_size 2m`), scripts/check-deploy.sh (`mcp_locations` and the `/mcp` directive loop at ~224-256); summercms.go modules/pier/pier.go (`maxRequestBody = 4 << 20`)
|
||||
- `git -C ../sm-demo-app submodule status plugins/golem15/oauthserver plugins/golem15/journal` and `cat ../sm-demo-app/go.work` (the demo uses those checkouts)
|
||||
</read_first>
|
||||
<action>
|
||||
**E-1 (P-38), in U:**
|
||||
- In models/organisation.go, add the constant `OrganisationLogoField = "logo"` and a second relation `{Name: OrganisationLogoField, Public: true}` in `AttachRelations`. Keep `avatar` first and unchanged.
|
||||
- In fields.yaml, add a `logo` field after `avatar`: `type: fileupload`, `mode: image`, `label: golem15.user::lang.organisation.logo`, `comment: golem15.user::lang.organisation.logo_comment`, `imageWidth: 240`, `imageHeight: 120`.
|
||||
- New file classes/organisation_logo.go with:
|
||||
- `OrganisationLogoURL(ctx context.Context, app *backpack.App, org *models.Organisation, size int) (string, bool, error)`. Same lookup as `AvatarURL` for the organisation's morph name and the `logo` field: a thumbnail of `size` by `size` in mode `auto`; the file path when the thumbnail fails (logged); false when there is no logo or no bucket. Only a database failure is an error.
|
||||
- `OrganisationLogoFields(ctx context.Context, app *backpack.App, org *models.Organisation) (map[string]any, error)`, answering `has_logo` (bool), `logo` (disk name, or nil) and `logo_url` (the 256 px URL, or nil): the avatar keys of the user payload, renamed.
|
||||
- Lang en and pl gain `organisation.logo` ("Logo" / "Logo") and `organisation.logo_comment` (en "Shown wherever the site displays the organisation." / pl "Wyświetlane wszędzie, gdzie strona pokazuje organizację.").
|
||||
- The README's Organisations feature and Organisations screen paragraphs name the logo and the two helpers, with the keys.
|
||||
- No migration and no change to any existing payload.
|
||||
|
||||
**C-IN-01, in J:** set `Writes: true` on the `draft_post` prompt. The README's MCP section says the prompt is offered only to grants that may write. Commit in sm-journal-plugin.
|
||||
|
||||
**C-IN-03, in D:**
|
||||
- Add `client_max_body_size 4m;` inside `location = /mcp`, with a comment naming pier's 4 MiB request cap.
|
||||
- In scripts/check-deploy.sh, add `client_max_body_size 4m;` to the directives the `/mcp` location must carry, with the message "(pier refuses bodies over 4 MiB itself; nginx must not cut earlier)".
|
||||
- Run `bash scripts/check-deploy.sh` in sm-demo-app.
|
||||
- Commit those two files only.
|
||||
|
||||
**P-39, demo checkouts (working tree only, never committed):**
|
||||
- `git -C ../sm-demo-app/plugins/golem15/oauthserver fetch "$(realpath ../sm-oauthserver-plugin)" master && git -C ../sm-demo-app/plugins/golem15/oauthserver checkout --detach FETCH_HEAD`.
|
||||
- The same for `plugins/golem15/journal` from `../sm-journal-plugin`.
|
||||
- Then `go -C ../sm-demo-app build -tags summercms_mcp ./...` and `go -C ../sm-demo-app test -count=1 -short ./...`.
|
||||
- Record both new submodule HEADs in the SUMMARY and the deferred pointer bumps.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>GOWORK=off go -C ../sm-demo-app/plugins/golem15/user vet ./... && GOWORK=off go -C ../sm-demo-app/plugins/golem15/user test -count=1 -short ./... && go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 -short ./... && (cd ../sm-demo-app && bash scripts/check-deploy.sh && go build -tags summercms_mcp ./... && go test -count=1 -short ./...) && test "$(git -C ../sm-demo-app/plugins/golem15/oauthserver rev-parse HEAD)" = "$(git -C ../sm-oauthserver-plugin rev-parse HEAD)" && test "$(git -C ../sm-demo-app/plugins/golem15/journal rev-parse HEAD)" = "$(git -C ../sm-journal-plugin rev-parse HEAD)"</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the output, check-deploy.sh printing an error, or a demo submodule checkout not on its plugin repository's HEAD</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c 'OrganisationLogoField = "logo"' ../sm-demo-app/plugins/golem15/user/models/organisation.go` prints 1 and `grep -c "OrganisationAvatarField" ../sm-demo-app/plugins/golem15/user/models/organisation.go` still prints at least 2
|
||||
- `grep -A3 "^ logo:" ../sm-demo-app/plugins/golem15/user/models/organisation/fields.yaml | grep -c "fileupload"` prints 1
|
||||
- `grep -c "func OrganisationLogoURL(\|func OrganisationLogoFields(" ../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go` prints 2 and `grep -c '"has_logo"\|"logo_url"' ../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go` prints at least 2
|
||||
- `git -C ../sm-demo-app/plugins/golem15/user log --oneline 72de822..HEAD -- updates/ | wc -l` prints 0 (no migration added since the plugin HEAD before the gap closure)
|
||||
- `grep -A12 "Name: \"draft_post\"" ../sm-journal-plugin/mcp.go | grep -c "Writes: *true"` prints 1
|
||||
- `grep -A16 "location = /mcp {" ../sm-demo-app/deploy/nginx/demo.summercms.io.conf | grep -c "client_max_body_size 4m;"` prints 1 and `grep -c "client_max_body_size 4m;" ../sm-demo-app/scripts/check-deploy.sh` prints 1
|
||||
- `git -C ../sm-demo-app diff --cached --name-only | wc -l` prints 0 after the task's commits (the submodule moves stay unstaged)
|
||||
</acceptance_criteria>
|
||||
<done>Organisations carry an editable logo that applications can expose under the avatar-style keys; Journal's drafting prompt follows the write ceiling; the demo's nginx no longer cuts MCP bodies below pier's cap; the demo runs this plan's plugin code for verification without committing unreleased pointers.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**sm-user-plugin (local commits, untagged):**
|
||||
- The account link:
|
||||
- auth_time-based confirm;
|
||||
- `POST /_user/api/v1/backend-link/show` (GET kept);
|
||||
- the `#code=` link with `golem15.user.backend_links.page_path`;
|
||||
- `BackendLinksFor`.
|
||||
- Access revocation:
|
||||
- `AccessRevokedEvent` and `FireAccessRevoked` (ban, password reset, admin-set password, self password change);
|
||||
- banned users excluded from `LinkedBackendUser`;
|
||||
- `FireSubjectEvent` and `FireSubjectEventAfterCommit` (token-specific revoke on `DELETE /tokens/{id}`);
|
||||
- `last_used_ip` on the MCP personal-token path.
|
||||
- Member token scopes (E-2): `APITokenScope`, `APITokenScopeCatalog`, `CompileAPITokenScopes`, `APITokenScopesFor`, `MintAPITokenFor`, the test seam `ResetDeclaredAPITokenScopes`, `GET /_user/api/v1/tokens/scopes`, and boot validation.
|
||||
- Organisation logo (E-1): the attachOne `logo` and `OrganisationLogoField`, the form field, `OrganisationLogoURL` and `OrganisationLogoFields`.
|
||||
- README and lang updates.
|
||||
|
||||
**sm-oauthserver-plugin (local commits, untagged):**
|
||||
- The verifier and MCP refresh refuse banned and pre-cutoff tokens.
|
||||
- `Cascade.OnAccessRevoked`, `OnBackendLinked`, `OnBackendUnlinked` and `OnBackendLinkChanged`, all built on the one revocation function `revokeUserGrants` (`OnAccessRevoked` passes the MCP and OIDC kinds; the link handlers pass MCP with the `backend` scope only).
|
||||
- `issuedBeforeCutoff`, the whole-second-aware `tokens_valid_after` rule.
|
||||
- The client-specific revoke event.
|
||||
- Subject-event helpers delegate to the user plugin.
|
||||
- README.
|
||||
|
||||
**sm-journal-plugin (local commit, untagged):** `draft_post` with `Writes: true`; README.
|
||||
|
||||
**vue-demo-app (local commit):** `/link-admin` reads the fragment, uses POST show, shows the signed-in account, and keeps the code in sessionStorage; `app/lib/linkCode.ts`; i18n keys.
|
||||
|
||||
**sm-demo-app (local commits):**
|
||||
- the vue-demo-app pointer bump;
|
||||
- nginx `client_max_body_size 4m` on `/mcp`, enforced by `check-deploy.sh`;
|
||||
- the oauthserver and journal submodule checkouts moved to the local plugin commits (working tree only).
|
||||
|
||||
**Smokes:** `TestBackendLinkAuthTimeSmoke`, `TestMemberTokenScopesSmoke` (user plugin); `TestMCPRevocationSmoke` (oauthserver).
|
||||
|
||||
**Decisions:** P-34 to P-39.
|
||||
</artifacts_this_phase_produces>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| site browser to the link pages | a signed-in browser (possibly shared) confirms a link code |
|
||||
| web server logs and analytics to the link code | anything that records request lines or query strings |
|
||||
| user plugin to oauthserver (events) | user state changes must reach the OAuth grants that act for the user |
|
||||
| MCP verifier and refresh to the user record | a grant is only as good as the account behind it |
|
||||
| plugins to the member token catalog | plugin-declared scope names are stored on member tokens and checked by route middleware |
|
||||
| admins to organisation records | backend editors upload organisation images that the frontend shows |
|
||||
| nginx to pier | request size limits in front of the MCP endpoint |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-57 | Elevation of privilege | banned or password-reset users keeping MCP grants and the linked admin's reach | high | mitigate | verifier and refresh refuse banned users and tokens created before `tokens_valid_after + 1s` (whole-second cutoff, so the same second is covered); the revoke uses the untruncated instant; `AccessRevokedEvent` revokes MCP tokens and ends sessions; `LinkedBackendUser` excludes banned users; TestMCPRevocationSmoke here, TestMCPVerifierRevocation, TestMCPGrantRevocation and TestAccessRevocation in plan 09 |
|
||||
| T-19.7-58 | Spoofing | the one-shot link code exposed in access logs, request logs and browser history | high | mitigate | `#code=` fragment; POST show; the code kept in sessionStorage across sign-in; the confirming account shown before the button; GET show kept only for compatibility and documented as deprecated |
|
||||
| T-19.7-59 | Elevation of privilege | a backend grant re-targeted to an administrator the user never consented to | high | mitigate | backend-scoped MCP tokens revoked on every link and unlink (P-36), sessions ended by client |
|
||||
| T-19.7-60 | Elevation of privilege | a member token minted with an undeclared scope, or a declared scope shadowing a built-in or another plugin's | medium | mitigate | catalog validation at boot (pattern, built-ins reserved, duplicates); the HTTP mint and `MintAPITokenFor` check the application's own catalog, so another application's declaration is refused; 422 unchanged; the legacy `MintAPIToken` fallback is process-wide and documented |
|
||||
| T-19.7-61 | Tampering | organisation logo uploads | low | mitigate | image-mode fileupload through lagoon/attach (the avatar's validation), behind the Organisations screen permission `golem15.users.access_users` |
|
||||
| T-19.7-62 | Denial of service | nginx's 2 MiB cap answering HTML 413 before pier's 4 MiB JSON-RPC error | low | mitigate | `client_max_body_size 4m` on `location = /mcp`, enforced by check-deploy.sh |
|
||||
| T-19.7-63 | Repudiation | personal tokens used at /mcp showing a stale last_used_ip | low | mitigate | `MCPResolvePersonalToken` stamps the client address from `towel.ClientIP` |
|
||||
| T-19.7-SC | Tampering | package installs | low | mitigate | no Go module or npm package added (go.mod and go.sum unchanged in the three plugins; vue-demo-app's pnpm-lock.yaml unchanged; only the existing lock is used for its test run) |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- User plugin: `GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...` on a Docker host
|
||||
- oauthserver: `go vet ./... && go test -count=1 ./...` on a Docker host, with the retargeted local go.work
|
||||
- Journal: `go vet ./... && go test -count=1 -short ./...`
|
||||
- Demo: `bash scripts/check-deploy.sh`, `go build -tags summercms_mcp ./...` and `go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' .` on a Docker host
|
||||
- `bash scripts/check-phase19.7.sh --plugins` (the framework repository) prints `additive:` lines for all three plugins and PASS
|
||||
- fonoteka.go and sm-bm-app still build against their own pinned user checkouts: `(cd ../fonoteka.go && go build ./...) && (cd ../sm-bm-app && go build ./...)`. fonoteka.go also builds against this plan's user plugin through the scratch workspace of Task 3's verify.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- C-CR-01 (user and oauthserver parts), C-CR-02 (plugin part), C-WR-01 and C-WR-02 are fixed; C-IN-01..C-IN-06 are fixed
|
||||
- E-1 and E-2 are delivered as the GAP-INPUTS ask states, including every E-2 acceptance item (proven by the smoke now and the named tests of plan 09)
|
||||
- Every change in the three plugins passes the gate's additive check; plugin go.mod require lines are unchanged
|
||||
- Nothing is tagged, pushed or deployed; the demo's plugin pointer bumps wait for the release
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-08-SUMMARY.md` when done. Commit it in the framework repository as a planning doc. It contains:
|
||||
- a commit table per repository, mapping each sha to its finding or escalation ids;
|
||||
- the previous and new go.work target in sm-oauthserver-plugin;
|
||||
- the detached submodule HEADs in sm-demo-app;
|
||||
- a "Delivered differently" note for E-1. The plugin serves no frontend organisation payload, so the escalation's "frontend organisation payloads gain the logo" is delivered as `OrganisationLogoURL` and `OrganisationLogoFields`. They give applications the `has_logo`, `logo` and `logo_url` keys for their own organisation payloads. Name this for the sm-servers-app hand-off;
|
||||
- the OIDC decision (ban and reset revoke OIDC grants too) and the rows it touches.
|
||||
|
||||
Release rule: this plan does not tag, push or deploy. Every repository works against the local framework (go.work, or `replace ../summercms.go`), and every plugin's go.mod `require` line stays at its current version. The plans may commit locally in every repository. The releases happen only after phase verification, in this order:
|
||||
1. framework v0.5.0;
|
||||
2. the plugin tags that require it (sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin);
|
||||
3. the application bumps: the demo's plugin pointers, and pushing vue-demo-app before sm-demo-app.
|
||||
</output>
|
||||
343
.planning/phases/19.7-generic-mcp-module/19.7-08-SUMMARY.md
Normal file
343
.planning/phases/19.7-generic-mcp-module/19.7-08-SUMMARY.md
Normal file
@@ -0,0 +1,343 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 08
|
||||
subsystem: plugins
|
||||
status: complete
|
||||
gap_closure: true
|
||||
tags: [sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin, sm-demo-app, vue-demo-app, auth_time, account-link, revocation, oidc, member-token-scopes, organisation-logo, nginx, gap-closure]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-06
|
||||
provides: pact.MCPPrompt.Writes (Journal's draft_post)
|
||||
- phase: 19.7-07
|
||||
provides: bouncer.VerifyAuthTime, pact.HasFrontendTokenScopes / FrontendTokenScope / ValidTokenScopeName, MCPSubjectChanged.TokenID / ClientID, towel.ClientIP
|
||||
provides:
|
||||
- "sm-user-plugin: auth_time-based account link confirm, POST /backend-link/show, #code= link with backend_links.page_path, BackendLinksFor, BackendLinkPagePath"
|
||||
- "sm-user-plugin: AccessRevokedEvent + FireAccessRevoked (ban, password reset, admin-set password, self password change), banned users excluded from LinkedBackendUser, FireSubjectEvent / FireSubjectEventAfterCommit, last_used_ip on the MCP personal-token path"
|
||||
- "sm-user-plugin: member token scopes (APITokenScope, APITokenScopeCatalog, CompileAPITokenScopes, APITokenScopesFor, MintAPITokenFor, ResetDeclaredAPITokenScopes, GET /_user/api/v1/tokens/scopes)"
|
||||
- "sm-user-plugin: organisation logo (OrganisationLogoField, OrganisationLogoURL, OrganisationLogoFields, OrganisationLogoSize)"
|
||||
- "sm-oauthserver-plugin: verifier and MCP refresh refuse banned and pre-cutoff tokens (issuedBeforeCutoff); Cascade.OnAccessRevoked / OnBackendLinked / OnBackendUnlinked / OnBackendLinkChanged over one revokeUserGrants; client-specific revoke event"
|
||||
- "sm-journal-plugin: draft_post with Writes: true"
|
||||
- "sm-demo-app: nginx client_max_body_size 4m on /mcp enforced by check-deploy.sh; vue-demo-app /link-admin fragment flow; TestMCPEndToEnd updated for C-WR-02"
|
||||
affects: [19.7-09 (named unit tests, gate, security-review corrections), framework v0.5.0 and the plugin tags, sm-servers-app (E-1, E-2 hand-off)]
|
||||
|
||||
actuals:
|
||||
tokens: 45949
|
||||
tasks: 4
|
||||
commits: 0
|
||||
commits_by_repo:
|
||||
sm-user-plugin: 4
|
||||
sm-oauthserver-plugin: 1
|
||||
sm-journal-plugin: 1
|
||||
vue-demo-app: 1
|
||||
sm-demo-app: 3
|
||||
plan_head_before: 5aeea304d02080bcffb7b127153e0e92ba91d2ab
|
||||
plan_head_after: 5aeea304d02080bcffb7b127153e0e92ba91d2ab
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "A sign-in proof reads auth_time (bouncer.VerifyAuthTime), never iat; a token without the claim is treated as stale"
|
||||
- "One revocation event per user change (AccessRevokedEvent) fired in the write's transaction; listeners revoke elsewhere-held grants; the after-commit subject event ends sessions"
|
||||
- "Whole-second cutoffs compared as created_at < cutoff + 1s (issuedBeforeCutoff)"
|
||||
- "Per-application catalogs with a process-wide fallback only for a legacy signature (MintAPIToken vs MintAPITokenFor)"
|
||||
- "A one-shot secret travels in a URL fragment and a POST body, never a logged URL"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/access_revoked.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/api_token_scopes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/organisation_logo.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_smoke_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/member_token_scopes_smoke_test.go
|
||||
- ../sm-oauthserver-plugin/mcp_revocation_smoke_test.go
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/linkCode.ts
|
||||
modified:
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/backend_link_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/backend_links.go
|
||||
- ../sm-demo-app/plugins/golem15/user/account_contributions.go
|
||||
- ../sm-demo-app/plugins/golem15/user/routes.go
|
||||
- ../sm-demo-app/plugins/golem15/user/config/config.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/subject_events.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/mcp_guard.go
|
||||
- ../sm-demo-app/plugins/golem15/user/classes/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/users_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/console/api_tokens.go
|
||||
- ../sm-demo-app/plugins/golem15/user/plugin.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/organisation.go
|
||||
- ../sm-demo-app/plugins/golem15/user/models/organisation/fields.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/en/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/lang/pl/lang.yaml
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md
|
||||
- ../sm-oauthserver-plugin/classes/mcp_verifier.go
|
||||
- ../sm-oauthserver-plugin/classes/mcp_store.go
|
||||
- ../sm-oauthserver-plugin/classes/cascade.go
|
||||
- ../sm-oauthserver-plugin/classes/subject_events.go
|
||||
- ../sm-oauthserver-plugin/controllers/authorizations.go
|
||||
- ../sm-oauthserver-plugin/plugin.go
|
||||
- ../sm-oauthserver-plugin/README.md
|
||||
- ../sm-journal-plugin/mcp.go
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/en.json
|
||||
- ../sm-demo-app/vue-demo-app/i18n/locales/pl.json
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
|
||||
- ../sm-demo-app/scripts/check-deploy.sh
|
||||
- ../sm-demo-app/mcp_e2e_test.go
|
||||
|
||||
key-decisions:
|
||||
- "P-34: the account link confirm reads auth_time (VerifyAuthTime); a token without it answers 409 stale_session; the code travels as #code= and through POST /backend-link/show; GET show kept, deprecated"
|
||||
- "P-35: AccessRevokedEvent + FireAccessRevoked from ban (newly banned only), password reset, admin-set password and self-service change; Before is the untruncated instant (self change: iat second); verifier and MCP refresh refuse banned users and created_at < tokens_valid_after + 1s"
|
||||
- "P-35 / user decision 2026-10-23: OnAccessRevoked ends MCP and OIDC grants alike (tokens revoked, consents and unused codes deleted, subjects kept)"
|
||||
- "P-36: backend-scoped MCP grants are revoked on every link and unlink, with a client-specific revoked event per affected client"
|
||||
- "P-37: member token scopes are validated per application (MintAPITokenFor, POST /tokens); MintAPIToken keeps a process-wide fallback"
|
||||
- "P-38: organisation logo is a second public attachOne; the plugin ships OrganisationLogoURL / OrganisationLogoFields instead of a payload it does not serve"
|
||||
- "MCP refresh refusals sit in ByTokenHashForUpdate only (the rotation lookup), not in ByAPITokenIDForUpdate, so wristband's Revoke still finds and kills a banned user's lineage"
|
||||
|
||||
requirements-completed: [SC-4, D-03, D-05, D-07, D-08, D-09, D-19, D-20, D-21, D-26, D-27, D-28, E-1, E-2]
|
||||
|
||||
duration: 41min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 08: Plugin gap closure (lane C, E-1, E-2) Summary
|
||||
|
||||
Lane C of the code review and both sm-servers-app escalations are closed in the plugins and the demo, additively. The account link is proven by the session's `auth_time`, so a refreshed old session no longer passes, and the link code travels only in a URL fragment and a POST body. A ban, a password reset or any password change now ends the user's MCP and OIDC grants and their MCP sessions. The MCP verifier and refresh grant refuse banned users and tokens from before the cutoff. A `backend` grant cannot outlive or be re-targeted by a link change. Plugins can declare member token scopes, and organisations have a logo.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 41 min
|
||||
- **Started:** 2026-10-23T14:30Z (ledger recorded 14:38:55Z)
|
||||
- **Completed:** 2026-10-23T15:11Z
|
||||
- **Tasks:** 4 of 4
|
||||
- **Files modified:** 47 across five repositories (7 created)
|
||||
|
||||
## Commits and findings
|
||||
|
||||
The framework repository has no code commit in this plan; only this SUMMARY is committed there. The `commits: 0` in the frontmatter is the framework ledger count. `commits_by_repo` holds the counts for the other repositories.
|
||||
|
||||
**sm-user-plugin** (`../sm-demo-app/plugins/golem15/user`, master, base 72de822)
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| 32f9259 `fix: account link proof by auth_time, code in the URL fragment and POST show` | 1 (tracer) | C-CR-02 (plugin side), C-WR-01, C-IN-06 |
|
||||
| 970719c `fix: access-revoked event on ban and password changes, banned users lose their link, token-specific MCP revoke` | 2 | C-CR-01 (user side), C-WR-02 (events confirmed), C-IN-02 (token), C-IN-04, C-IN-05 |
|
||||
| ee5c096 `feat: plugin-declared member token scopes (pact.HasFrontendTokenScopes)` | 3 | E-2 |
|
||||
| f20a8d3 `feat: organisation logo (attachOne logo) and payload helpers` | 4 | E-1 |
|
||||
|
||||
**sm-oauthserver-plugin** (master, base 2929c91)
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| 671513d `fix: revoke OAuth grants on ban and password changes, refuse banned and pre-cutoff MCP tokens, backend grants follow the link` | 2 | C-CR-01, C-WR-02, C-IN-02 (client), C-IN-05 |
|
||||
|
||||
**sm-journal-plugin** (main, base a9a9b80)
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| b129902 `fix: draft_post prompt is offered only to grants that may write` | 4 | C-IN-01 |
|
||||
|
||||
**vue-demo-app** (master, base 21a22b6)
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| 0125e29 `fix: link page reads the code from the fragment, shows the request by POST and the signed-in account` | 1 | C-WR-01, C-CR-02 (signed-in account shown) |
|
||||
|
||||
**sm-demo-app** (master, base 6fa2d56)
|
||||
|
||||
| Commit | Task | Findings |
|
||||
|--------|------|----------|
|
||||
| 00f57bf `chore: bump vue-demo-app (link page: code in the fragment, POST show)` | 1 | vue-demo-app pointer only |
|
||||
| 3b569a1 `fix: nginx accepts MCP bodies up to pier's 4 MiB cap` | 4 | C-IN-03 |
|
||||
| 7731641 `test: TestMCPEndToEnd expects a link change to end the backend grant` | 4 | C-WR-02 (e2e, deviation 3) |
|
||||
|
||||
Nothing was tagged, pushed or deployed.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Account link proof (Task 1, tracer).**
|
||||
- `BackendLinkConfirm` reads `bouncer.VerifyAuthTime(SessionToken, secret, AudienceUser)`. A subject mismatch or a verify error answers 401. A token without `auth_time` answers the existing 409 `stale_session`, and so does an `auth_time` before the request. `ConfirmLinkRequest` keeps its signature; the parameter is now `sessionAuthTime`.
|
||||
- `BackendLinkShowPost` serves `POST /_user/api/v1/backend-link/show` with `{"code"}` and answers exactly like the GET route. Both show routes send `Cache-Control: no-store, private` (`writeNoStoreJSON`), and the README marks the GET route deprecated.
|
||||
- My account answers `FrontendURL + BackendLinkPagePath + "#code=" + code`. The new key `golem15.user.backend_links.page_path` defaults to `/link-admin` and gets a leading `/` when it lacks one.
|
||||
- vue-demo-app `/link-admin` reads `#code=` with `readLinkCode`, stores the code under `LINK_CODE_KEY` in sessionStorage and removes the fragment with `history.replaceState`. It shows the request through POST, shows "Signed in as …" with a "Not you? Sign out" action, and signs in through `/login?next=/link-admin`, so the code never appears in a URL. The stored code is removed on success and when the request is gone. The `signInAgain` text is reworded in en and pl.
|
||||
- The tracer gate re-ran the verify end to end (3 PASS, vue tests green) before expansion.
|
||||
- **Revocation chain (Task 2).**
|
||||
- `AccessRevokedEvent` (`user.AccessRevoked`) and `FireAccessRevoked` fire the event in the transaction, then one `revoked` subject event per user after the commit. The reasons are `ban`, `password_reset`, `password_set_by_admin` and `password_changed`, exported as `AccessRevoked*` constants.
|
||||
- Callers:
|
||||
- the `ban` bulk action, through the `banUsers` wrapper (ThrottleStates before and after, newly banned ids only);
|
||||
- `ResetPassword`, now inside `lagoon.Transaction`, with the untruncated `now`;
|
||||
- `ChangePassword`, also inside a transaction, with `cutoff + 1s`;
|
||||
- the admin password store in `FormBeforeUpdate`, using the save's tx and the untruncated instant.
|
||||
- `LinkedBackendUser` excludes banned users (`user_throttle.is_banned`).
|
||||
- `FireSubjectEvent` and `FireSubjectEventAfterCommit` are new; the old helpers wrap them. `DELETE /tokens/{id}` fires with `TokenID`.
|
||||
- `MCPResolvePersonalToken` stamps `last_used_ip` from `towel.ClientIP`.
|
||||
- `requestUsable` uses `IsUsableAt`. `BackendLinksFor` replaces the two duplicate lookups.
|
||||
- oauthserver:
|
||||
- `issuedBeforeCutoff` is used by the verifier and by the MCP refresh lookup. Both also refuse banned users.
|
||||
- `revokeUserGrants` is the one revocation function.
|
||||
- `OnAccessRevoked` covers the MCP and OIDC kinds. `OnBackendLinked`, `OnBackendUnlinked` and `OnBackendLinkChanged` revoke only `backend`-scoped MCP tokens and fire a revoked event per client.
|
||||
- The authorized-apps revoke fires with `ClientID`.
|
||||
- The subject-event helpers delegate to the user plugin.
|
||||
- **Member token scopes (Task 3, E-2).**
|
||||
- The scope types are `APITokenScope` and `APITokenScopeCatalog` (`Scopes`, `Allowed`).
|
||||
- `CompileAPITokenScopes` refuses a bad name, a built-in, a duplicate (the error names both plugins) and an empty label or description.
|
||||
- Boot (`bootAPITokenScopes`) also checks `::` phrase keys against the translator, publishes the catalog and fails on any error.
|
||||
- `APITokenScopesFor` returns the published catalog, or the built-ins alone when none is published.
|
||||
- `MintAPITokenFor` and `MintAPIToken` share `mintAPIToken`. The legacy `MintAPIToken` falls back to the process-wide declared set, which `ResetDeclaredAPITokenScopes` clears for tests.
|
||||
- `POST /tokens` and `user:token:create` use `MintAPITokenFor`, and the 422 text is unchanged.
|
||||
- `GET /_user/api/v1/tokens/scopes` (behind `jwt.auth`) lists the scopes with translated labels.
|
||||
- The built-in label and description keys are added in en and pl, and the README has a "Member token scopes" section.
|
||||
- `AllowedAPITokenScopes` keeps its exported form.
|
||||
- **Logo, Journal, nginx, demo (Task 4).**
|
||||
- `OrganisationLogoField = "logo"` is the second public attachOne, after the avatar.
|
||||
- The Organisations form gains a `logo` image fileupload (240×120).
|
||||
- `OrganisationLogoURL`, `OrganisationLogoFields` and `OrganisationLogoSize` (256) are new. No migration was added (`72de822..HEAD -- updates/` is empty).
|
||||
- Journal's `draft_post` now has `Writes: true`.
|
||||
- nginx `location = /mcp` gets `client_max_body_size 4m;`, and check-deploy.sh enforces it. A deliberately removed directive made the check fail as intended; the file was then restored.
|
||||
|
||||
## Delivered differently: E-1 (for the sm-servers-app hand-off)
|
||||
|
||||
The escalation asked that "the frontend organisation payloads gain the logo". sm-user-plugin serves no frontend organisation payload: no route answers an organisation object. The logo is therefore delivered as two exported helpers that applications call when they build their own organisation payloads:
|
||||
|
||||
- `classes.OrganisationLogoFields(ctx, app, org)` answers `has_logo` (bool), `logo` (the attachment's disk name, or nil) and `logo_url` (a 256 px thumbnail URL, or nil). These are the user payload's avatar keys with "avatar" replaced by "logo". An application merges the map into its organisation JSON.
|
||||
- `classes.OrganisationLogoURL(ctx, app, org, size)` answers the URL at any size, and false when there is no logo or no file bucket.
|
||||
|
||||
The logo is uploaded on the backend Organisations form (field `logo`) and stored in `system_files` with `field = 'logo'`.
|
||||
|
||||
## OIDC decision (user, 2026-10-23) and the rows it touches
|
||||
|
||||
A ban, a password reset, an admin-set password or the user's own password change ends every OAuth grant of the user, MCP agents and OIDC sign-ins alike. `Cascade.OnAccessRevoked` calls `revokeUserGrants(ctx, ev.Tx, ev.UserIDs, ev.Before, [mcp, oidc], "")`, which touches these rows of the users at clients of kind `mcp` or `oidc`:
|
||||
|
||||
| Table | Rows | Change |
|
||||
|-------|------|--------|
|
||||
| `golem15_oauthserver_access_tokens` | unrevoked, `created_at < Before` | `revoked_at`, `updated_at` set |
|
||||
| `golem15_oauthserver_refresh_tokens` | unrevoked, `created_at < Before` | `revoked_at`, `updated_at` set |
|
||||
| `golem15_oauthserver_consents` | `created_at` and `updated_at` before `Before` (or NULL) | deleted, so an OIDC client asks for consent again |
|
||||
| `golem15_oauthserver_auth_codes` | `consumed_at IS NULL`, `created_at < Before` | deleted (a pending OIDC code cannot mint a token afterwards) |
|
||||
| `golem15_oauthserver_mcp_codes` | `used_at IS NULL`, `created_at < Before` | deleted |
|
||||
| `golem15_oauthserver_subjects` | — | kept (a restored or unbanned user keeps the same `sub`) |
|
||||
|
||||
Link changes (C-WR-02) call the same function with kind `mcp` and scope `backend`, and only revoke tokens. `TestMCPRevocationSmoke` checks the OIDC rows after a ban: no unrevoked access token, no consent, no unused code, and the subject kept.
|
||||
|
||||
## Local environment (not committed)
|
||||
|
||||
- **sm-oauthserver-plugin go.work.** The `sm-user-plugin` replace previously pointed at `../fonoteka.go/plugins/golem15/user` and now points at `../sm-demo-app/plugins/golem15/user`. See deviation 1: go.work is tracked in this repository, so it shows as modified and was deliberately left uncommitted.
|
||||
- **sm-demo-app submodule checkouts (detached, working tree only):**
|
||||
- `plugins/golem15/oauthserver` at 671513d1fccb2defce8fbce517bde17619253dbb (committed pointer 8bbec72)
|
||||
- `plugins/golem15/journal` at b1299021cd4031bf5430adcdbb1b139a8d1c3eb0 (committed pointer 4ab94da)
|
||||
- `plugins/golem15/user` at f20a8d3b98d3bafa5a58bcacc54ebbd427affa45 (committed pointer at v0.1.10). This is the plugin checkout itself, and the pointer was already shown as modified before this plan.
|
||||
- **Deferred pointer bumps:** commit the oauthserver, journal and user pointers in sm-demo-app after the plugin tags (release order: framework v0.5.0, then the plugin tags, then the application bumps). vue-demo-app 0125e29 must be pushed before sm-demo-app 00f57bf.
|
||||
|
||||
## Verification
|
||||
|
||||
- User plugin:
|
||||
- `GOWORK=off go vet ./...` clean.
|
||||
- `GOWORK=off go test -count=1 ./...` green with Docker (root 58 s, classes, models, updates), run after the last change.
|
||||
- `TestBackendLinkAuthTimeSmoke`, `TestBackendLink`, `TestBackendLinkSmoke`, `TestMemberTokenScopesSmoke` (both subtests), `TestUserMCPGuard` and `TestUserMCPGuardSmoke` PASS.
|
||||
- oauthserver:
|
||||
- `go vet ./...` clean.
|
||||
- `go test -count=1 ./...` green with Docker.
|
||||
- `TestMCPRevocationSmoke`, `TestMCPTokenVerifier`, `TestMCPConsent`, `TestMCPConsentSmoke`, `TestMCPTokenVerifierSmoke`, `TestMCPStore` and `TestMCPStoreSmoke` PASS.
|
||||
- Journal: `go vet ./...` and `go test -count=1 -short ./...` green (`TestJournalMCP` and `TestJournalMCPSmoke` included).
|
||||
- Demo:
|
||||
- `bash scripts/check-deploy.sh` prints ok.
|
||||
- `go build -tags summercms_mcp ./...` and `go test -count=1 -short ./...` are green.
|
||||
- `go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' .` PASS (10 subtests) on the detached plugin checkouts.
|
||||
- vue-demo-app: `pnpm run test` (14 files, 178 tests) and `pnpm run build` are green.
|
||||
- `bash scripts/check-phase19.7.sh --plugins` PASS. It prints `additive:` lines:
|
||||
- user: nothing removed since 930b158 or v0.1.9;
|
||||
- oauthserver: nothing removed since d31f8e7;
|
||||
- journal: nothing removed since ffa2c8f.
|
||||
- fonoteka.go:
|
||||
- builds against this plan's user plugin through the scratch GOWORK of Task 3's verify;
|
||||
- `go build ./...` also passes against its own checkout;
|
||||
- its go.work is untouched (status count 0).
|
||||
- sm-bm-app: `go build ./...` passes.
|
||||
- go.mod and go.sum are unchanged in all three plugins (no `go get`), and pnpm-lock.yaml is unchanged.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] sm-oauthserver-plugin's go.work is tracked, not git-ignored**
|
||||
- **Found during:** Task 2, step 0
|
||||
- **Issue:** P-39 assumed a git-ignored go.work. It is tracked (`git ls-files go.work`, committed in 459e389), so retargeting it leaves ` M go.work`, and the acceptance line "status --short go.work prints 0" cannot hold while the plan's own verify (`go -C ../sm-oauthserver-plugin vet ./...`) needs the retarget.
|
||||
- **Fix:** I retargeted go.work in the working tree and did not commit it, as the plan says ("never commit go.work"). The previous target is recorded above. Before the release, either restore the line or decide whether go.work should leave version control.
|
||||
- **Files:** ../sm-oauthserver-plugin/go.work (uncommitted)
|
||||
|
||||
**2. [Rule 1 - Bug] Show routes could not set no-store through writeJSON**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** `writeJSON` always overwrites `Cache-Control` with `no-cache, private`.
|
||||
- **Fix:** the new `writeNoStoreJSON` serves both show routes, including their 404s.
|
||||
- **Commit:** 32f9259
|
||||
|
||||
**3. [Rule 1 - Test pinned old behaviour] Demo TestMCPEndToEnd expected a backend grant to survive an unlink**
|
||||
- **Found during:** Task 4 (end-to-end run on the detached checkouts)
|
||||
- **Issue:** two subtests ("journal tools as the linked admin" ending, and "unlink sends list_changed") expected the backend session to keep running with a shorter tool list after an unlink. C-WR-02 (P-36) revokes that grant by design.
|
||||
- **Fix:**
|
||||
- The first subtest now checks three things after the unlink: the backend session ends, the backend token answers 401, and a grant without `backend` still lists `user_me` and no Journal tool.
|
||||
- The second subtest is now "a link change ends the backend grant": the old token stays 401 after a relink to another admin, and a new grant reaches the new admin's tools.
|
||||
- This test file was not in the plan's file list. It passes only with the plugin commits (the detached checkouts) until the pointer bumps.
|
||||
- **Commit:** 7731641 (sm-demo-app)
|
||||
|
||||
**4. [Rule 1 - Correctness] MCP refresh refusals only in the rotation lookup**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** the plan put the refusals in `mcpTx.refresh`, which wristband's `Revoke` (connected-app revocation) also uses through `ByAPITokenIDForUpdate`. A "not found" there would skip killing a banned user's lineage.
|
||||
- **Fix:** `refresh` is split into `refreshRow` and `refreshRecord`. Only `ByTokenHashForUpdate` (the refresh grant) applies `refreshUserUsable`.
|
||||
- **Commit:** 671513d
|
||||
|
||||
**5. [Rule 2 - Missing critical] Full revocation also deletes unused authorization codes**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** an OIDC or MCP code issued before a ban or reset could still be exchanged for a new token after it.
|
||||
- **Fix:** `revokeUserGrants` (full mode) deletes unconsumed `auth_codes` and unused `mcp_codes` created before `Before`. Recorded in the OIDC table above.
|
||||
- **Commit:** 671513d
|
||||
|
||||
**6. [Plan detail] revokeUserGrants signature**
|
||||
- It takes a `scope` argument (empty for all scopes) and returns the touched `(user, client)` pairs (`[]grantRef`), so the link handlers can share the one function, as the plan's artifact list describes. It is unexported.
|
||||
|
||||
**7. [Rule 1] Built-in scope phrase keys spelled out**
|
||||
- `TestAdminRegistration` collects phrase-key string literals from the sources. A concatenated prefix (`…api_tokens.scope_`) failed it, so the six keys are literal (`builtInAPITokenScopeKeys`).
|
||||
- **Commit:** ee5c096
|
||||
|
||||
**8. [Scope] Additional exports**
|
||||
- `BackendLinkPagePath`, `DefaultBackendLinkPagePath`, the `AccessRevoked*` reason constants and `OrganisationLogoSize` were added (additive) and are documented in the README.
|
||||
- Also documented in the README:
|
||||
- `BackendLinkShowPost` was missing from the controllers line in 32f9259 and was added in 970719c;
|
||||
- `TestBackendLinkAuthTimeSmoke` in the Testing section.
|
||||
|
||||
### Tests changed for old behaviour
|
||||
|
||||
- `backend_link_test.go` `TestBackendLink` "fresh sign-in at the second" now crafts `auth_time` tokens and adds a no-`auth_time` case that expects `stale_session` (it pinned the iat confirm). Commit 32f9259.
|
||||
- `backend_link_smoke_test.go`: the link URL regexp is `…/link-admin#code=…`. Commit 32f9259.
|
||||
- `password_routes_test.go` `TestPasswordPublicRoutes`: route count 21 → 22 (POST show, 32f9259), then 23 (GET /tokens/scopes, ee5c096).
|
||||
- `mcp_guard_smoke_test.go` `TestUserMCPGuardSmoke`: the token revoke now expects `TokenID` (new `subjectSpy.hasEvent`). Commit 970719c.
|
||||
- `models/admin_models_test.go` `TestAdminModelContracts` expects 2 organisation attach relations, avatar then logo. `admin_organisations_test.go` `TestAdminOrganisations` expects the `logo` field. Commit f20a8d3.
|
||||
- oauthserver `mcp_consent_smoke_test.go` `TestMCPConsentSmoke`: the authorized-apps revoke event carries `ClientID`. Commit 671513d.
|
||||
- sm-demo-app `mcp_e2e_test.go` `TestMCPEndToEnd` (deviation 3). Commit 7731641.
|
||||
|
||||
## Notes for plan 09
|
||||
|
||||
- Named tests: `TestMCPVerifierRevocation`, `TestMCPGrantRevocation`, `TestAccessRevocation` (threat register T-19.7-57). Unit tests for `linkCode.ts` (`readLinkCode`, `isLinkCode`). `OrganisationLogoFields` with and without a logo.
|
||||
- `FireAccessRevoked` is not called by `UnbanUsers` or by the `user:token:revoke` CLI; neither needs it. The `admin:token:revoke` CLI still fires no MCP event (from plan 07).
|
||||
- `connectWatching` in the demo's mcp_e2e_test.go is now unused.
|
||||
- Pre-existing and out of scope: `gofmt -l` lists sm-journal-plugin `classes/blog_editor_test.go`.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None beyond the plan's register. The new surfaces are covered there:
|
||||
- `POST /backend-link/show` (T-19.7-58);
|
||||
- `GET /tokens/scopes`, which needs `jwt.auth` and lists only scope metadata (T-19.7-60);
|
||||
- the organisation logo upload (T-19.7-61).
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: classes/access_revoked.go, classes/api_token_scopes.go, classes/organisation_logo.go, backend_link_auth_time_smoke_test.go, member_token_scopes_smoke_test.go (user); mcp_revocation_smoke_test.go (oauthserver); app/lib/linkCode.ts (vue-demo-app)
|
||||
- FOUND: 32f9259, 970719c, ee5c096, f20a8d3 (user); 671513d (oauthserver); b129902 (journal); 0125e29 (vue-demo-app); 00f57bf, 3b569a1, 7731641 (sm-demo-app)
|
||||
- No commit deleted a tracked file.
|
||||
566
.planning/phases/19.7-generic-mcp-module/19.7-09-PLAN.md
Normal file
566
.planning/phases/19.7-generic-mcp-module/19.7-09-PLAN.md
Normal file
@@ -0,0 +1,566 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 09
|
||||
type: execute
|
||||
wave: 4
|
||||
depends_on: ["19.7-06", "19.7-07", "19.7-08"]
|
||||
gap_closure: true
|
||||
files_modified:
|
||||
- scripts/check-phase19.7.sh
|
||||
- modules/pier/reaper_test.go
|
||||
- modules/pier/reserve_test.go
|
||||
- modules/pier/lock_scope_test.go
|
||||
- modules/pier/widening_test.go
|
||||
- modules/pier/stateless_fanout_test.go
|
||||
- modules/pier/personal_binding_test.go
|
||||
- modules/pier/dispatch_hardening_test.go
|
||||
- modules/pier/catalog_path_fields_test.go
|
||||
- modules/pier/prompt_ceiling_test.go
|
||||
- modules/pier/token_events_test.go
|
||||
- modules/pier/export_test.go
|
||||
- modules/bouncer/auth_time_test.go
|
||||
- modules/pact/frontend_token_scopes_test.go
|
||||
- modules/towel/client_ip_test.go
|
||||
- modules/cabana/account_contributions_hardening_test.go
|
||||
- modules/cabana/record_action_prompt_localized_test.go
|
||||
- modules/cabana/token_scope_name_test.go
|
||||
- modules/cabana/account_token_events_test.go
|
||||
- modules/cabana/token_resolver_remote_test.go
|
||||
- admin/tests/app/hotkeysEditing.test.ts
|
||||
- admin/tests/account/AccountContributions.test.ts
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_show_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/access_revocation_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/organisation_logo_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp_guard_client_ip_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/api_token_events_test.go
|
||||
- ../sm-oauthserver-plugin/mcp_revocation_test.go
|
||||
- ../sm-journal-plugin/mcp_prompt_writes_test.go
|
||||
- ../sm-demo-app/mcp_revocation_e2e_test.go
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/linkCode.test.ts
|
||||
- ../sm-demo-app/vue-demo-app
|
||||
- .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
|
||||
autonomous: true
|
||||
requirements: [SC-1, SC-2, SC-3, SC-4, D-05, D-08, D-17, D-19, D-20, D-21, D-25, D-26, D-27, D-31, E-1, E-2]
|
||||
|
||||
estimate:
|
||||
tokens: 130000
|
||||
raw_tokens: 130000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Every fix of plans 06-08 (A-CR-01, A-WR-01..09, A-IN-01..08, B-WR-01..06, B-IN-01..04, C-CR-01, C-CR-02, C-WR-01, C-WR-02, C-IN-01..06) and both escalations have 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)"
|
||||
- "E-2's acceptance list is a test, item by item and verbatim: a plugin declaring servers:write mints a usr_ token with that scope through POST /tokens and a middleware.Scope(\"servers:write\") route accepts it; a token without the scope gets 403 \"Missing required scope: servers:write\"; an undeclared scope answers 422 at mint time; two plugins declaring one name, or a plugin redeclaring read, write or ai, fails boot; the discovery answer lists the built-ins and the declared scopes with labels"
|
||||
- "The gate cannot pass on a local accident: every repository must resolve the framework to this checkout and the OAuth server plugin must resolve the user plugin to USER_PLUGIN, a demo plugin submodule may be ahead of its pin only by commits its canonical checkout holds (unreleased, reported), and PHASE197_RELEASED=1 refuses any drift after the release"
|
||||
- "bash scripts/check-phase19.7.sh --all passes on a Docker host with every stage PASS"
|
||||
- "19.7-SECURITY-REVIEW.md corrects the verdicts the code review disproved (T-19.7-22 first, plus T-19.7-03, -08, -17, -18, -23, -31, -35 and cross-cutting findings 1 and 6 on link proof and logs), records T-19.7-42..T-19.7-65 with implementation, test and status, and shows for the three critical findings that the pinning test fails with the fix reverted; 19.7-SECURITY.md reports threats_open 0"
|
||||
- "19.7-VALIDATION.md has a row for every new behaviour with its final command, and deferred-items.md records every finding not fixed (B-IN-05, B-IN-06) with its reason plus the release order and the local-only wiring"
|
||||
artifacts:
|
||||
- path: "scripts/check-phase19.7.sh"
|
||||
provides: "the extended fail-closed gate with the unreleased-pin policy and workspace checks"
|
||||
contains: "PHASE197_RELEASED"
|
||||
- path: "../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go"
|
||||
provides: "E-2's acceptance list as tests"
|
||||
contains: "Missing required scope: servers:write"
|
||||
- path: "../sm-demo-app/mcp_revocation_e2e_test.go"
|
||||
provides: "the end-to-end revocation matrix"
|
||||
contains: "func TestMCPRevocationEndToEnd("
|
||||
- path: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md"
|
||||
provides: "the corrected review and the gap-closure evidence"
|
||||
contains: "T-19.7-65"
|
||||
key_links:
|
||||
- from: "scripts/check-phase19.7.sh"
|
||||
to: "../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go"
|
||||
via: "USER_TESTS requires TestMemberTokenScopes; USER_SHORT_TESTS requires TestMemberTokenScopesBoot"
|
||||
pattern: "TestMemberTokenScopes"
|
||||
- from: "scripts/check-phase19.7.sh"
|
||||
to: "modules/pier/reaper_test.go"
|
||||
via: "GO_TESTS and GO_TAGGED_TESTS require TestSessionReaper"
|
||||
pattern: "TestSessionReaper"
|
||||
- from: ".planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md"
|
||||
to: "19.7-0{6,7,8}-PLAN.md threat registers"
|
||||
via: "one row per T-19.7-42..65 with implementation and test"
|
||||
pattern: "T-19.7-4"
|
||||
---
|
||||
|
||||
<objective>
|
||||
This is the gap closure's last plan; by project rule, unit tests come last. It:
|
||||
- adds a named test for every fix of plans 06-08 and for both escalations, including E-2's acceptance list verbatim;
|
||||
- extends `scripts/check-phase19.7.sh` so the new tests are required and the gate cannot pass on unreleased plugin drift or a stray local workspace;
|
||||
- adds the `19.7-VALIDATION.md` rows;
|
||||
- corrects `19.7-SECURITY.md` and `19.7-SECURITY-REVIEW.md`, where the code review proved two verdicts wrong: T-19.7-22's link proof was marked verified, and the review's claim that the link code never reaches a log was false. It also records the new threats T-19.7-42..T-19.7-65, among them the E-2 scopes and the `auth_time` claim;
|
||||
- updates `deferred-items.md`.
|
||||
|
||||
**Planner decisions recorded here (P-40, P-41):**
|
||||
- **P-40 (gate policy for the gap closure):**
|
||||
- **Workspace check.** Before running anything in a repository, the gate checks how it resolves the framework (`go list -m -f '{{if .Replace}}{{.Replace.Dir}}{{end}}' git.golem15.com/golem15/summercms`). Every repository must resolve it to this checkout. sm-oauthserver-plugin must also resolve `sm-user-plugin` to `$USER_PLUGIN`. A mismatch is a `refuse:` line naming both paths. This replaces trust in git-ignored go.work files.
|
||||
- **Unreleased pins.** `demo_pins` keeps accepting test-only drift, and also accepts a plugin submodule ahead of its pin when its HEAD descends from the pin and is the HEAD of, or an ancestor of, the canonical checkout: `$USER_PLUGIN`, `$OAUTHSERVER_PLUGIN` or `$JOURNAL_PLUGIN` by submodule name. That case prints `pins: <name> is ahead of its pin by unreleased commits (release after verification)`.
|
||||
- **After the release.** With `PHASE197_RELEASED=1` any drift fails, so the gate proves the bumped pins after the user's release.
|
||||
- **vue-demo-app.** The consumers stage runs the demo site's vitest run with `app/lib/linkCode.test.ts` required (the vitest detector).
|
||||
- **Consumers on the unreleased user plugin.** fonoteka.go and sm-bm-app are also built through a scratch copy of their own go.work that swaps their user checkout for `$USER_PLUGIN` (`consumer_with_user_plugin`), proving that the plugin's changes are additive for its consumers before any tag. Their own go.work files are never edited.
|
||||
- **Docs.** The docs stage checks cooler's two doc comments (A-IN-02).
|
||||
- **P-41 (revert-check, the lesson of T-19.7-22):** for each of the three critical findings, the security review records that the pinning test fails with the fix reverted and passes at HEAD:
|
||||
- A-CR-01 → `TestSessionReaper`;
|
||||
- C-CR-01 → `TestMCPVerifierRevocation`;
|
||||
- C-CR-02 → `TestBackendLinkAuthTime`.
|
||||
|
||||
Method: a temporary `git worktree add` under the session scratch directory at HEAD, then `git revert --no-commit <fix sha>`, run the single test, and record FAIL. Remove the worktree afterwards. Nothing is committed from the worktree.
|
||||
|
||||
Purpose: `/msd-verify-work` has one green gate covering the gap closure, and the security documents state only what a test proves.
|
||||
Output: named tests in six repositories (framework, user plugin, oauthserver, Journal, the demo and vue-demo-app), the extended gate, and the corrected and extended planning documents.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
|
||||
@.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/phases/19.7-generic-mcp-module/19.7-05-SUMMARY.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-06-SUMMARY.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-07-SUMMARY.md
|
||||
@.planning/phases/19.7-generic-mcp-module/19.7-08-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
</context>
|
||||
|
||||
<project_rules>
|
||||
- Tests, the gate and the planning documents only. A production defect found here gets its own `fix(<module or plugin>)` commit in the owning repository, before the test commit, and is named in the SUMMARY (as in 19.6.1-03 and 19.7-05). A test commit never touches a non-test .go file.
|
||||
- Postgres tests:
|
||||
- no `t.Parallel`; unique seeded rows and cleanup;
|
||||
- a Postgres subtest is created only when not `-short` (no `t.Skip`), so the gate's skip refusal stays meaningful;
|
||||
- the user plugin runs with `GOWORK=off`;
|
||||
- Docker through `sudo -u golem` if the socket is denied.
|
||||
- Gate entries are `<package>:<TestName>` and list every required test by name. Detectors refuse skipped, zero-match, "no tests to run" and missing names. Every new detector or policy gets a planted `--self-test` case.
|
||||
- Tests and docs in framework files name no consuming application (the docs stage scans the phase's test files: append every new framework test file to `PHASE_TEST_FILES`). Plugin and demo tests may use `servers:write` and `servers:read`, because those are E-2's acceptance values.
|
||||
- Stage by explicit path in every repository. One logical change per commit, no co-author tags. Planning documents (VALIDATION, SECURITY, SECURITY-REVIEW, deferred-items, SUMMARY) go in their own commits. In sm-demo-app, never stage `main.go` or a plugin submodule pointer.
|
||||
- Every commit is self-contained: the repository builds, vets and passes its `-short` tests at each commit, and the gate script works at each of its commits (the arrays name only tests that exist in that commit or in an earlier one).
|
||||
- Release rule: no tag, push or deploy in this plan.
|
||||
</project_rules>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: Tracer: the gate's workspace check and unreleased-pin policy run end to end, proven by --self-test, with the first gap-closure tests (TestSessionReaper, TestAuthTime) required in the go stage</name>
|
||||
<files>scripts/check-phase19.7.sh, modules/pier/reaper_test.go, modules/pier/export_test.go, modules/bouncer/auth_time_test.go</files>
|
||||
<read_first>
|
||||
- scripts/check-phase19.7.sh in full: arrays, `detect_go`, `detect_vitest`, `go_named`, `go_pkg_named`, `run_self_test`, `run_plugins`, `run_consumers`, `demo_pins`, `run_docker`, `run_docs`, `run_all`
|
||||
- 19.7-08-SUMMARY.md (the oauthserver go.work target, the detached demo submodule HEADs, the new commit shas)
|
||||
- modules/pier/reaper_smoke_test.go and export_test.go (plan 06 seams `ReapNow`, `LocalSessions`, `AdvanceStoreClock`); modules/pier/helpers_test.go (`twoInstances`, `sdkClient`)
|
||||
- modules/bouncer/auth_time_smoke_test.go (plan 07) and mint.go, refresh.go, jwt.go
|
||||
</read_first>
|
||||
<action>
|
||||
**Gate (P-40).**
|
||||
- Add `workspace_check DIR [EXPECT_USER_PLUGIN]`. It runs `go list -m -f '{{if .Replace}}{{.Replace.Dir}}{{end}}' git.golem15.com/golem15/summercms` in DIR (with `GOWORK=off` for the user plugin, as the plugins stage runs it), resolves both sides with `realpath`, and refuses when the answer is not `$ROOT`. For sm-oauthserver-plugin it does the same for `git.golem15.com/golem15/sm-user-plugin` against `$USER_PLUGIN`.
|
||||
- Call it at the top of `run_plugins` for all three plugins, of `run_consumers` for the demo, and of `run_docker` for the user plugin, oauthserver and the demo.
|
||||
- Add `consumer_with_user_plugin APP`. It writes a scratch go.work (under `mktemp -d`, removed on exit) that copies the application's own go.work and rewrites:
|
||||
- every `use` and `replace` path to absolute;
|
||||
- the application's `./plugins/golem15/user` `use` entry to `$USER_PLUGIN`;
|
||||
- a `replace git.golem15.com/golem15/summercms => $ROOT`.
|
||||
|
||||
It checks that `go list -m -f '{{.Dir}}' git.golem15.com/golem15/sm-user-plugin` answers `$USER_PLUGIN`, then runs `go build ./...` with that `GOWORK`.
|
||||
- `run_consumers` runs it for `$FONOTEKA` and `$BM_APP` after their plain builds, proving that the unreleased user plugin compiles with its consumers. The applications' own go.work files are never edited.
|
||||
- Add a self-test case: a planted go.work rewritten as expected.
|
||||
- Extend `demo_pins`:
|
||||
- After the test-only check fails, map the submodule name to its canonical checkout (`plugins/golem15/user` → `$USER_PLUGIN`, `plugins/golem15/oauthserver` → `$OAUTHSERVER_PLUGIN`, `plugins/golem15/journal` → `$JOURNAL_PLUGIN`).
|
||||
- Accept when the submodule HEAD descends from its pin and the canonical checkout's HEAD equals it or descends from it (`git -C <canonical> merge-base --is-ancestor <submodule HEAD> HEAD`). Print the `unreleased commits` line.
|
||||
- With `PHASE197_RELEASED=1`, any drift fails before these checks.
|
||||
- Document `PHASE197_RELEASED` in the header's environment list.
|
||||
- Add `--self-test` cases:
|
||||
- planted `go list` answers for the workspace check (match, mismatch);
|
||||
- planted `check-pins.sh` lines for the three pin outcomes (test-only, unreleased accepted, refused), plus the released-mode refusal.
|
||||
|
||||
**First required tests.**
|
||||
- `modules/pier/reaper_test.go`, `TestSessionReaper` (A-CR-01, A-IN-01, A-IN-06), with subtests:
|
||||
- memory store: idle past TTL → reaped, `ss.Wait` returns, the 404 on the next call, `expired` audit line captured through a test slog handler;
|
||||
- Redis (`twoInstances`, `miniredis.FastForward`): the instance that did not serve the last request keeps its copy only while the record lives;
|
||||
- a store error keeps the copy;
|
||||
- a GET stream whose record vanished is cancelled by the re-check (`SetRecheck`), with no `ended` event delivered;
|
||||
- `serveEphemeral` calls are logged as `ephemeral`.
|
||||
|
||||
Add any seam it needs to export_test.go.
|
||||
- `modules/bouncer/auth_time_test.go`, `TestAuthTime`:
|
||||
- mint carries `auth_time == iat` for both audiences;
|
||||
- `Refresh`, `RefreshAudience` and `RefreshAudienceFor` carry it unchanged across two rotations;
|
||||
- a legacy token without the claim refreshes without one;
|
||||
- `VerifyAuthTime` refuses a bad signature, the wrong audience and an expired token, and accepts a frontend token without `aud` as `VerifyClaims` does;
|
||||
- `ClaimAuthTime == "auth_time"`.
|
||||
- Append `./modules/pier:TestSessionReaper` to `GO_TESTS` and `GO_TAGGED_TESTS`, `./modules/bouncer:TestAuthTime` and the plan 06 and 07 smokes (`./modules/pier:TestPierReaperSmoke`, `./modules/bouncer:TestAuthTimeSmoke`) to `GO_TESTS`, and the new files to `PHASE_TEST_FILES`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase19.7.sh --self-test && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --plugins && bash scripts/check-phase19.7.sh --consumers</automated>
|
||||
<fails_when>non-zero exit, or a stage line printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "PHASE197_RELEASED" scripts/check-phase19.7.sh` prints at least 2 and `grep -c "workspace_check" scripts/check-phase19.7.sh` prints at least 4
|
||||
- `grep -c "unreleased commits" scripts/check-phase19.7.sh` prints at least 1 and `grep -c "consumer_with_user_plugin" scripts/check-phase19.7.sh` prints at least 3 (definition and two calls)
|
||||
- `git -C ../fonoteka.go status --short go.work | wc -l` and `git -C ../sm-bm-app status --short go.work | wc -l` print 0 after the run
|
||||
- `grep -c "TestSessionReaper\|./modules/bouncer:TestAuthTime" scripts/check-phase19.7.sh` prints at least 3
|
||||
- `grep -c "func TestSessionReaper(" modules/pier/reaper_test.go` prints 1 and `grep -c "func TestAuthTime(" modules/bouncer/auth_time_test.go` prints 1
|
||||
- `bash scripts/check-phase19.7.sh --self-test` prints PASS for every planted case, including the workspace and pin policy cases, and exits 0
|
||||
- `PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers` exits non-zero while the demo's submodules are ahead of their pins (proves strict mode; run once, not part of the verify chain)
|
||||
</acceptance_criteria>
|
||||
<done>The gate verifies where each repository resolves its dependencies, reports unreleased plugin commits honestly and turns strict after the release; the first two gap-closure tests are required by name and green.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 2: Framework and admin SPA tests for every fix of plans 06 and 07</name>
|
||||
<files>modules/pier/reserve_test.go, modules/pier/lock_scope_test.go, modules/pier/widening_test.go, modules/pier/stateless_fanout_test.go, modules/pier/personal_binding_test.go, modules/pier/dispatch_hardening_test.go, modules/pier/catalog_path_fields_test.go, modules/pier/prompt_ceiling_test.go, modules/pier/token_events_test.go, modules/pier/export_test.go, modules/pact/frontend_token_scopes_test.go, modules/towel/client_ip_test.go, modules/cabana/account_contributions_hardening_test.go, modules/cabana/record_action_prompt_localized_test.go, modules/cabana/token_scope_name_test.go, modules/cabana/account_token_events_test.go, modules/cabana/token_resolver_remote_test.go, admin/tests/app/hotkeysEditing.test.ts, admin/tests/account/AccountContributions.test.ts, scripts/check-phase19.7.sh</files>
|
||||
<behavior>
|
||||
- TestSessionReserve (A-WR-03):
|
||||
- 50 concurrent initialize POSTs from one binding open exactly `max_per_binding` sessions on the memory store and on miniredis;
|
||||
- the rest answer 429;
|
||||
- a forced connect failure releases its slot;
|
||||
- a store without `reserver` falls back to Count and Put.
|
||||
- TestLockScope (A-WR-07): a guard provider that blocks in `MCPAllows` during one client's initialize (a channel) does not delay another client's call on an existing session, a DELETE, or a stateless request (each finishes within a short deadline while the first is blocked).
|
||||
- TestScopeWidening (A-WR-04):
|
||||
- a binding first seen with `read` and then with `read write` lists the write tool on the next request on the stateless path and on the stateful path;
|
||||
- adding a backend subject (link) adds the backend tools without any fan-out event;
|
||||
- narrowing still hides the tools.
|
||||
- TestStatelessFanOut (A-WR-05, A-WR-06):
|
||||
- on miniredis an instance that has served only stateless requests receives a revoked event published by the other instance and evicts its entry;
|
||||
- a `subscriptions/listen` stream ends within the re-check interval once its bearer stops resolving;
|
||||
- an LRU eviction at capacity closes the evicted server's sessions.
|
||||
- TestPersonalTokenBinding (A-WR-09): a resolver answering TokenID 0 gives 401 at /mcp; two users' tokens get distinct bindings, and one cannot DELETE the other's session.
|
||||
- TestDispatchHardening (A-WR-01, A-WR-02 runtime, A-WR-08, A-IN-04, A-IN-05, A-IN-08):
|
||||
- `..`, `.`, `a/../b`, an empty segment and `a/b` in a single segment are refused and never reach the handler (counter);
|
||||
- a missing path value is refused;
|
||||
- a provider error with a pgx-like message yields the fixed text, and the message appears only in the captured log;
|
||||
- `9007199254740993` reaches the route unchanged in the path and the query;
|
||||
- the inner request has the outer Host, X-Forwarded-Proto and X-Forwarded-Host and still no Authorization or Cookie;
|
||||
- a frontend tool whose provider answers `Guards: ["backend"]` or a Backend principal is refused.
|
||||
- TestCatalogPathFields (A-WR-02 boot, A-IN-07):
|
||||
- a `path:"id"` field with `omitempty` fails boot naming the field;
|
||||
- the same field without it compiles;
|
||||
- an embedded struct on a GET tool fails boot, and on a POST tool compiles.
|
||||
- TestPromptWriteCeiling (C-IN-01): a `Writes: true` prompt is listed for a read+write grant and hidden from a read-only grant; a prompt without Writes is listed for both.
|
||||
- TestTokenScopedRevoke (B-WR-04, C-IN-02 framework):
|
||||
- a revoked event with TokenID closes only the session opened with that personal token, while another token's session and an OAuth session of the same user stay;
|
||||
- with ClientID only that client's OAuth sessions close;
|
||||
- with neither all close;
|
||||
- the fields survive the Redis round trip between two instances.
|
||||
- TestResolveClientAddress (B-IN-04): a resolver sees `towel.ClientIP` equal to the client address (RemoteAddr host; the trusted-proxy answer through a host that implements ClientIP).
|
||||
- TestFrontendTokenScopes (pact): `ValidTokenScopeName` table (accepts `read`, `servers:write`, `a_b-c:d`; refuses ``, `Read`, `servers:`, `:x`, `a:b:c`, `*`, `with space`); a sample plugin is discovered as `HasFrontendTokenScopes`.
|
||||
- TestTokenScopeNameParity (cabana): cabana's plugin scope validation accepts and refuses exactly the pact table's names.
|
||||
- TestClientIP (towel): round trip, absent value, empty string.
|
||||
- TestAccountContributionURL (cabana, -short, dispatch-marker harness):
|
||||
- `javascript:alert(1)`, `data:text/html,x`, `//evil.example/x` and `vbscript:` are dropped (`url` empty) and logged without the URL;
|
||||
- `https://site/link-admin#code=x` and `/relative` pass.
|
||||
- TestAccountContributionsIsolation (B-WR-06, B-IN-03):
|
||||
- plugin A's Status error gives A `error: true` and empty status while plugin B's section and actions are intact, with status 200;
|
||||
- an Applies error drops only that action;
|
||||
- a dynamic status text is not looked up as a phrase key (no missing-key warning).
|
||||
- TestRecordActionPromptLocalized (B-IN-02): a non-string payload answers 422 with the `action_prompt_invalid` text in en and pl.
|
||||
- TestAccountTokenRevokeEvent (cabana, Postgres): revoking one `g15_` token fires one revoked event whose TokenID is the row id; nothing per-admin.
|
||||
- TestResolveBackendTokenRemote (cabana, Postgres): a failed and a successful resolve log `remote` from `towel.ClientIP`.
|
||||
- Vitest hotkeysEditing.test.ts (B-WR-01, B-WR-02):
|
||||
- a keydown of `?` or Escape from an input inside an open shadow root, and from a custom element in a form (closed root), triggers no shortcut and is not prevented;
|
||||
- Ctrl+S with a TaglistField draft saves the record with the draft tag (the posted body contains it);
|
||||
- Ctrl+Enter does the same before closing.
|
||||
- Vitest AccountContributions.test.ts (extend) (B-WR-03, B-WR-06, B-IN-01):
|
||||
- a `javascript:` URL answer renders no link and never calls `window.open`;
|
||||
- a section with `error: true` shows the section_error text;
|
||||
- a 500 on GET shows the error toast and keeps the earlier sections;
|
||||
- the confirm and stale texts are the myaccount ones.
|
||||
</behavior>
|
||||
<read_first>
|
||||
- The plan 06 and 07 SUMMARYs (final identifiers, seams and any test they adjusted)
|
||||
- modules/pier/helpers_test.go, export_test.go, sessions_test.go, fanout_test.go, dispatch_test.go, catalog_test.go (extend the fakes; never duplicate them)
|
||||
- modules/cabana/account_contributions_test.go, dispatch_marker_test.go, administrators_harness_test.go (the -short marker harness and the Postgres `newScreensEnv`)
|
||||
- admin/tests/app/hotkeys.test.ts, admin/tests/account/AccountContributions.test.ts, admin/tests/form/RecordActions.test.ts, admin/tests/helpers.ts
|
||||
- scripts/check-phase19.7.sh (GO_TESTS, GO_TAGGED_TESTS, DOCKER_TESTS, ADMIN_FILES, PHASE_TEST_FILES)
|
||||
</read_first>
|
||||
<action>
|
||||
Write the tests in the behavior block, under exactly those names, in the files listed. Subtests carry the case names.
|
||||
|
||||
Work red-first where the behaviour is not yet pinned: most pass at once because plans 06 and 07 built the behaviour. A test that fails because the code is wrong gets a `fix(<module>)` commit before the test commit.
|
||||
|
||||
Gate arrays:
|
||||
- `GO_TESTS`: every -short name, as `<package>:<Name>`.
|
||||
- `GO_TAGGED_TESTS`: the pier names.
|
||||
- `DOCKER_TESTS`: `./modules/cabana:TestAccountTokenRevokeEvent` and `./modules/cabana:TestResolveBackendTokenRemote` (their -short part returns before creating Postgres subtests).
|
||||
- `ADMIN_FILES`: `tests/app/hotkeysEditing.test.ts`.
|
||||
- `PHASE_TEST_FILES`: every new framework test file.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go vet ./... && go test -count=1 -short -race ./modules/pier/... && go test -count=1 -short ./modules/pier/... ./modules/pact/... ./modules/towel/... ./modules/cabana/... ./modules/bouncer/... && bash scripts/check-phase19.7.sh --go && bash scripts/check-phase19.7.sh --admin && bash scripts/check-phase19.7.sh --docs</automated>
|
||||
<fails_when>non-zero exit, a race report, "FAIL" in the output, or a gate line printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -h "^func Test" modules/pier/reserve_test.go modules/pier/lock_scope_test.go modules/pier/widening_test.go modules/pier/stateless_fanout_test.go modules/pier/personal_binding_test.go modules/pier/dispatch_hardening_test.go modules/pier/catalog_path_fields_test.go modules/pier/prompt_ceiling_test.go modules/pier/token_events_test.go | grep -c "TestSessionReserve\|TestLockScope\|TestScopeWidening\|TestStatelessFanOut\|TestPersonalTokenBinding\|TestDispatchHardening\|TestCatalogPathFields\|TestPromptWriteCeiling\|TestTokenScopedRevoke\|TestResolveClientAddress"` prints 10
|
||||
- `grep -c "func TestFrontendTokenScopes(" modules/pact/frontend_token_scopes_test.go`, `grep -c "func TestClientIP(" modules/towel/client_ip_test.go` and `grep -c "func TestTokenScopeNameParity(" modules/cabana/token_scope_name_test.go` each print 1
|
||||
- `grep -c "TestAccountContributionURL\|TestAccountContributionsIsolation\|TestRecordActionPromptLocalized\|TestAccountTokenRevokeEvent\|TestResolveBackendTokenRemote" scripts/check-phase19.7.sh` prints at least 5
|
||||
- `grep -c "hotkeysEditing.test.ts" scripts/check-phase19.7.sh` prints at least 1
|
||||
- `bash scripts/check-phase19.7.sh --go` and `--admin` exit 0
|
||||
</acceptance_criteria>
|
||||
<done>Every framework and SPA fix of plans 06 and 07 is pinned by a required test; the go, admin and docs stages are green.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Plugin, site and demo tests for plan 08 (E-2's acceptance verbatim, E-1, the link proof, revocation), required by the gate; the whole gate green</name>
|
||||
<files>../sm-demo-app/plugins/golem15/user/backend_link_auth_time_test.go, ../sm-demo-app/plugins/golem15/user/backend_link_show_test.go, ../sm-demo-app/plugins/golem15/user/access_revocation_test.go, ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go, ../sm-demo-app/plugins/golem15/user/organisation_logo_test.go, ../sm-demo-app/plugins/golem15/user/mcp_guard_client_ip_test.go, ../sm-demo-app/plugins/golem15/user/api_token_events_test.go, ../sm-oauthserver-plugin/mcp_revocation_test.go, ../sm-journal-plugin/mcp_prompt_writes_test.go, ../sm-demo-app/mcp_revocation_e2e_test.go, ../sm-demo-app/vue-demo-app/app/lib/linkCode.test.ts, ../sm-demo-app/vue-demo-app, scripts/check-phase19.7.sh</files>
|
||||
<behavior>
|
||||
- TestMemberTokenScopes (user plugin, Postgres). A test plugin declares `servers:read` and `servers:write`. Each E-2 acceptance item is a subtest whose name quotes it:
|
||||
- "A plugin that declares servers:write can mint a usr_ token with that scope through POST /tokens, and a route with middleware.Scope(\"servers:write\") accepts it": POST `/_user/api/v1/tokens` with `{"name":"agent","scopes":["servers:write"]}` → 201 and a `usr_` token; `PUT /_test/servers/1/components/report` behind `APITokenGuard` and `middleware.Scope("servers:write")` → 200.
|
||||
- "A token without the scope gets 403 \"Missing required scope: servers:write\"": a `["read"]` token on that route → 403 with exactly that message.
|
||||
- "An undeclared scope still answers 422 at mint time": `["servers:delete"]` → 422 with `scopes: ["The selected scope is invalid."]`.
|
||||
- "Listing returns them in scopes": `GET /tokens` shows `["servers:write"]` in the token's `scopes`.
|
||||
- "The discovery answer lists the built-ins and the declared scopes with labels": `GET /tokens/scopes` behind `jwt.auth` → `read`, `write`, `ai` (built_in true, labels translated in en and pl) then `servers:read`, `servers:write` with their labels; no session → 401.
|
||||
- "Scopes are scoped to the application": a second application (app B), booted in the same test binary without the declaring plugin, answers 422 `The selected scope is invalid.` to POST /tokens with `["servers:write"]`. `MintAPITokenFor(appB, ...)` refuses it, and `MintAPITokenFor(appA, ...)` accepts it.
|
||||
- The legacy `MintAPIToken` accepts `servers:write` through the process-wide fallback and refuses a never-declared name. The fallback is cleared with `ResetDeclaredAPITokenScopes()` in `t.Cleanup`, so test order cannot leak declarations.
|
||||
- TestMemberTokenScopesBoot (user plugin, -short): "Two plugins declaring the same scope name … fails boot" (the error names both plugin ids); "a plugin redeclaring read, write or ai fails boot" (one subtest each); a bad name and an empty label fail; a `::` label naming a missing phrase key fails at Boot.
|
||||
- TestBackendLinkAuthTime (user plugin, Postgres, C-CR-02):
|
||||
- login, then request, then refresh, then confirm → 409 stale_session;
|
||||
- request, then login, then confirm → 200;
|
||||
- login, then request, then login again → 200;
|
||||
- a hand-made token without auth_time → 409;
|
||||
- a refreshed token after a post-request login keeps working (auth_time carried);
|
||||
- another user's token → 401.
|
||||
- TestBackendLinkShowPost (user plugin, Postgres, C-WR-01, C-IN-06):
|
||||
- POST show answers like GET (200 data shape, 404 for an unknown, used or expired code), and both carry Cache-Control no-store;
|
||||
- the My account action URL is `<frontend_url>/link-admin#code=<64 hex>` with no `?`;
|
||||
- `golem15.user.backend_links.page_path: /pl/polacz` changes the path;
|
||||
- a value without a leading slash gets one.
|
||||
- TestAccessRevocation (user plugin, Postgres, C-CR-01):
|
||||
- the ban bulk action, ResetPassword, ChangePassword and the admin password set each fire one AccessRevokedEvent in the write's transaction, with the right ids, Before and Reason;
|
||||
- for ResetPassword and the admin password set, the stored `tokens_valid_after` is whole seconds while `Before` is the untruncated instant (`Before` is not before the stored value and has a sub-second part when the clock has one). ChangePassword passes the stored cutoff plus one second;
|
||||
- the ban wrapper fires only for newly banned ids: selecting an already banned user together with an unbanned one fires one event naming only the second;
|
||||
- each fires MCPSubjectRevoked per user only after commit;
|
||||
- a failing listener rolls the password reset back;
|
||||
- `LinkedBackendUser` answers false for a banned linked user and true again after unban.
|
||||
- TestUserMCPGuardClientIP (C-IN-04): `MCPResolvePersonalToken` with `towel.WithClientIP` stamps `last_used_ip`; without it, the column is left as it was.
|
||||
- TestAPITokenRevokeEvent (C-IN-02): `DELETE /tokens/{id}` fires one revoked event with that TokenID.
|
||||
- TestOrganisationLogo (user plugin, Postgres, E-1):
|
||||
- the Organisations form schema has a `logo` fileupload next to `avatar`;
|
||||
- uploading through the admin form API stores a `system_files` row with field `logo`;
|
||||
- `OrganisationLogoFields` answers `has_logo true`, the disk name and a URL;
|
||||
- without a logo it answers `has_logo false` and nils;
|
||||
- the avatar still works;
|
||||
- deleting the organisation removes the logo attachment as it does the avatar.
|
||||
- TestMCPVerifierRevocation (oauthserver, Postgres, C-CR-01):
|
||||
- a token created before `tokens_valid_after` → ErrMCPTokenInvalid;
|
||||
- the same-second case: with `tokens_valid_after` stored as 12:00:05 (whole seconds), a token created at 12:00:05.300 is refused by the verifier and by the refresh rotation even with no revoke listener registered, and a token created at 12:00:06.000 is accepted;
|
||||
- `OnAccessRevoked` with `Before` = 12:00:05.700 revokes the 12:00:05.300 token (untruncated revoke) and leaves one created at 12:00:05.900;
|
||||
- a banned user → ErrMCPTokenInvalid, and valid again after unban for a token created after the cut-off;
|
||||
- the MCP refresh rotation refuses a banned user, a pre-cutoff refresh token and a deleted user.
|
||||
- TestMCPGrantRevocation (oauthserver, Postgres, C-CR-01, C-WR-02, C-IN-02):
|
||||
- AccessRevokedEvent revokes MCP access and refresh tokens created before Before, and OIDC access and refresh tokens (and the OIDC consent row) created before Before, and leaves later ones of both kinds;
|
||||
- RemoveLink and a new SetLink revoke only `backend`-scoped MCP tokens of that user and fire revoked events with their ClientIDs after commit;
|
||||
- the authorization revoke route fires with ClientID.
|
||||
- TestJournalPromptWrites (Journal, -short): `draft_post` declares `Writes`; through pier's catalog (the TestJournalMCP harness) a read-only identity's prompts/list omits `journal_draft_post` and a read+write one lists it.
|
||||
- TestMCPRevocationEndToEnd (demo, tagged, Postgres) runs through the SDK client:
|
||||
- (a) a linked user with a `read write backend` grant is banned through the admin's bulk ban route: the next call is 401, the session is gone, and the refresh grant is refused;
|
||||
- (b) unlinking revokes the backend grant: the next call is 401, and a fresh consent without a link has no `backend`;
|
||||
- (c) a read-only grant lists no `journal_draft_post`;
|
||||
- (d) with `mcp.allow_personal_tokens: true`, revoking one `usr_` token ends only its session while the same user's OAuth session keeps working.
|
||||
- linkCode.test.ts (vue-demo-app): `readLinkCode('#code=<64 hex>')` returns it; uppercase, short, extra parameters and an empty hash give ''; `isLinkCode` is exact.
|
||||
</behavior>
|
||||
<read_first>
|
||||
- The plan 08 SUMMARY (final identifiers, commit shas, the go.work target, the submodule HEADs)
|
||||
- The existing harnesses: user plugin backend_link_test.go and api_tokens_test.go (admin and session helpers), mcp_guard_test.go; oauthserver mcp_verifier_test.go and harness_test.go; Journal mcp_test.go (`TestJournalMCP` compiles the declaration through pier); demo mcp_e2e_test.go (SDK client, consent helper, `internal/demotest`), testmain_test.go
|
||||
- The plan 08 smokes (`TestBackendLinkAuthTimeSmoke`, `TestMemberTokenScopesSmoke`, `TestMCPRevocationSmoke`): lift their seeds into the shared helpers of each repository instead of duplicating them
|
||||
- scripts/check-phase19.7.sh (USER_TESTS, OAS_TESTS, JOURNAL_SHORT_TESTS, DEMO_TESTS, `detect_vitest`)
|
||||
- 19.7-GAP-INPUTS.md E-2 "Acceptance" (the subtest names quote it)
|
||||
</read_first>
|
||||
<action>
|
||||
Write the tests in the behavior block under exactly those names, one commit per repository. Fix any production defect first in its own `fix(` commit in the owning repository.
|
||||
|
||||
Gate:
|
||||
- Add a `USER_SHORT_TESTS=(.:TestMemberTokenScopesBoot)` array, run in `run_plugins` with `GOWORK=off go_pkg_named "$USER_PLUGIN" -short`.
|
||||
- Append to `USER_TESTS`: `TestBackendLinkAuthTime`, `TestBackendLinkShowPost`, `TestAccessRevocation`, `TestMemberTokenScopes`, `TestOrganisationLogo`, `TestUserMCPGuardClientIP`, `TestAPITokenRevokeEvent`, `TestBackendLinkAuthTimeSmoke`, `TestMemberTokenScopesSmoke`.
|
||||
- Append to `OAS_TESTS`: `TestMCPVerifierRevocation`, `TestMCPGrantRevocation`, `TestMCPRevocationSmoke`.
|
||||
- Append to `JOURNAL_SHORT_TESTS`: `.:TestJournalPromptWrites`.
|
||||
- Append to `DEMO_TESTS`: `TestMCPRevocationEndToEnd`.
|
||||
- Add a `VUE_FILES=(app/lib/linkCode.test.ts)` array. `run_consumers` runs `pnpm --dir "$DEMO_APP/vue-demo-app" run test` through `detect_vitest` with those files required.
|
||||
- Add the docs-stage cooler check: `go doc ./modules/cooler KeyPrefix` line 4 starts with `KeyPrefix returns`, and `go doc -u ./modules/cooler keyPrefix` shows its own comment.
|
||||
|
||||
In sm-demo-app:
|
||||
- Commit the e2e test only.
|
||||
- Commit `app/lib/linkCode.test.ts` in vue-demo-app.
|
||||
- Commit the vue-demo-app pointer bump separately, staging only `vue-demo-app`.
|
||||
|
||||
Then run `bash scripts/check-phase19.7.sh --all` on a Docker host.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase19.7.sh --all</automated>
|
||||
<fails_when>non-zero exit, any stage printing FAIL, "refuse:" or "missing-named", or "NOT RUN docker" while a Docker daemon is reachable (run on a Docker host, through sudo -u golem if the socket is denied)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "Missing required scope: servers:write" ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go` prints at least 1, and `grep -c "The selected scope is invalid." ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go` prints at least 1
|
||||
- `grep -c "func TestMemberTokenScopes(\|func TestMemberTokenScopesBoot(" ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go` prints 2
|
||||
- `grep -c "func Test" ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_test.go ../sm-demo-app/plugins/golem15/user/backend_link_show_test.go ../sm-demo-app/plugins/golem15/user/access_revocation_test.go ../sm-demo-app/plugins/golem15/user/organisation_logo_test.go ../sm-demo-app/plugins/golem15/user/mcp_guard_client_ip_test.go ../sm-demo-app/plugins/golem15/user/api_token_events_test.go` prints at least 1 per file
|
||||
- `grep -c "func TestMCPVerifierRevocation(\|func TestMCPGrantRevocation(" ../sm-oauthserver-plugin/mcp_revocation_test.go` prints 2; `grep -c "func TestJournalPromptWrites(" ../sm-journal-plugin/mcp_prompt_writes_test.go` prints 1; `grep -c "func TestMCPRevocationEndToEnd(" ../sm-demo-app/mcp_revocation_e2e_test.go` prints 1
|
||||
- `grep -c "USER_SHORT_TESTS\|VUE_FILES" scripts/check-phase19.7.sh` prints at least 4
|
||||
- `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
|
||||
</acceptance_criteria>
|
||||
<done>Every plugin, site and demo fix of plan 08 and both escalations are pinned by required tests (E-2 item by item), and the whole phase gate is green.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: Validation rows, the corrected and extended security review and contract (revert-checks for the critical findings), deferred items</name>
|
||||
<files>.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</files>
|
||||
<read_first>
|
||||
- 19.7-SECURITY-REVIEW.md (Method, Gaps fixed, Threat register rows T-19.7-03, -08, -17, -18, -22, -23, -31, -35, Cross-cutting findings 1 and 6, Accepted risks, Residual items) and 19.7-SECURITY.md (frontmatter, register, Accepted Risks Log, Audit Trail)
|
||||
- The `<threat_model>` blocks of 19.7-06, 19.7-07, 19.7-08 and this plan (T-19.7-42..T-19.7-65)
|
||||
- 19.7-REVIEW.md (finding ids for the corrections) and the 06, 07 and 08 SUMMARYs (commit shas per finding)
|
||||
- 19.7-VALIDATION.md (row format) and deferred-items.md (entry format, open items to update)
|
||||
</read_first>
|
||||
<action>
|
||||
**Revert-checks (P-41).** For each pair below:
|
||||
1. Create a scratch worktree of the owning repository at HEAD under the session scratch directory: `git -C <repo> worktree add <scratch>/<name> HEAD`.
|
||||
2. Run `git revert --no-commit <fix sha>` there.
|
||||
3. Run the single test: framework with `go test`; user plugin with `GOWORK=off`. The user plugin's relative replace resolves only from its real location, so in its worktree use `go mod edit -replace` to the absolute framework path (never committed), or `go work` in the scratch directory.
|
||||
4. Record FAIL with the failing line.
|
||||
5. Remove the worktree (`git worktree remove --force`).
|
||||
|
||||
The pairs:
|
||||
- A-CR-01 → `TestSessionReaper`;
|
||||
- C-CR-01 → `TestMCPVerifierRevocation` (the oauthserver verifier fix);
|
||||
- C-CR-02 → `TestBackendLinkAuthTime`: revert the user plugin confirm change. The framework auth_time cannot be "reverted" from the plugin worktree, so revert the plugin commit only.
|
||||
|
||||
At HEAD all three pass (Task 3's gate run).
|
||||
|
||||
**19.7-SECURITY-REVIEW.md:** add a section "Gap closure (plans 06-09, 2026-10-23)" with:
|
||||
- **Corrections**, a table of each earlier verdict the code review disproved: threat id, earlier verdict, finding, what was wrong, fix commit(s), pinning test. The rows:
|
||||
- T-19.7-22: the link proof compared `iat`, which refresh renews (C-CR-02); it was wrongly marked verified.
|
||||
- Cross-cutting finding 1: the link proof.
|
||||
- Cross-cutting finding 6: the claim that the link code never reaches a log was false; it reached nginx and site request logs and browser history (C-WR-01). Describe the old claim in your own words; do not quote its sentence.
|
||||
- T-19.7-23: code leakage.
|
||||
- T-19.7-03 and T-19.7-17: the mux cleaning was not part of the in-process chain (A-WR-01, A-WR-02).
|
||||
- T-19.7-18: the session leak and the cap race (A-CR-01, A-WR-03).
|
||||
- T-19.7-08: the `javascript:` URL sink (B-WR-03).
|
||||
- T-19.7-31: grant re-targeting after re-linking (C-WR-02).
|
||||
- T-19.7-35: grants surviving ban and reset (C-CR-01).
|
||||
- Rewrite cross-cutting findings 1 and 6 in place with the corrected text and a "corrected in gap closure" marker.
|
||||
- **Revert-checks:** a table with repository, fix sha, test, FAIL line with the fix reverted, PASS at HEAD.
|
||||
- **New threats:** register rows for T-19.7-42..T-19.7-65 in the existing evidence-table format (Mitigation as built, Implementation file:line, Test, Status). Each has a status of verified or fixed in <sha>. The E-2 rows (T-19.7-52, T-19.7-60) and the auth_time rows (T-19.7-51, plus T-19.7-22's correction) cite the decision note and the E-2 acceptance tests.
|
||||
- **Method:** add one step: a high or critical control is "verified" only with a test that fails without it; for the three critical findings this is shown by revert-check.
|
||||
|
||||
**19.7-SECURITY.md:**
|
||||
- The register gains T-19.7-42..T-19.7-65.
|
||||
- The corrected rows get their new status ("fixed in <sha>").
|
||||
- The Audit Trail gets a gap-closure entry.
|
||||
- `threats_open` stays 0 only if every high threat is verified or fixed. Otherwise set the real count and stop with a blocking note in the SUMMARY.
|
||||
|
||||
**19.7-VALIDATION.md:** one row per new behaviour (every test name of Tasks 1-3) with its final command, File Exists ✅ and Status ✅ green after the Task 3 gate run. Keep `nyquist_compliant: true`.
|
||||
|
||||
**deferred-items.md:**
|
||||
- New entries with reasons:
|
||||
- B-IN-05: the prompt dialog closes on a 422. The contract text was corrected in plan 07; keeping the dialog open changes the shared confirm primitive used by every action.
|
||||
- B-IN-06: no fix required; the visible link is the popup-blocker fallback.
|
||||
- OIDC grants on ban or password reset: decided by the user on 2026-10-23 (both MCP and OIDC grants are revoked); record it as resolved, with the test that pins it.
|
||||
- The local oauthserver go.work retarget.
|
||||
- The demo's oauthserver and journal submodules detached at unreleased commits, plus the user submodule pointer, all waiting for the release.
|
||||
- The release order:
|
||||
1. framework v0.5.0;
|
||||
2. sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin tags requiring it;
|
||||
3. the demo, fonoteka.go and sm-bm-app bumps, with vue-demo-app pushed before sm-demo-app;
|
||||
4. sm-servers-app picks up E-1 and E-2 after the user plugin tag;
|
||||
5. then `PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers`.
|
||||
- Update the status of earlier entries the gap closure resolved or superseded, for example the plan 05 test commits that are now part of the gap-closure release.
|
||||
|
||||
Commit each document as a planning doc.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>grep -q "threats_open: 0" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md && for n in $(seq 42 65); do grep -q "T-19.7-$n" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md && grep -q "T-19.7-$n" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md || { echo "missing T-19.7-$n"; exit 1; }; done && grep -q "Revert-check" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md && grep -q "B-IN-05" .planning/phases/19.7-generic-mcp-module/deferred-items.md && grep -q "TestMemberTokenScopes" .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md && bash scripts/check-phase19.7.sh --all</automated>
|
||||
<fails_when>non-zero exit, a "missing T-19.7-NN" line, a missing section or row, or any gate stage printing FAIL, "refuse:" or "missing-named"</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- Every id T-19.7-42 through T-19.7-65 appears in both security documents, and each row in 19.7-SECURITY-REVIEW.md names a file:line and a test and has the status verified or fixed in <sha>
|
||||
- The T-19.7-22 row of 19.7-SECURITY-REVIEW.md no longer has the bare status `verified`: `grep "^| T-19.7-22 " .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md | grep -c "fixed in"` prints 1
|
||||
- `grep -c "is never logged" .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md` prints 0 (the false claim is rewritten, not quoted)
|
||||
- The Revert-checks table has three rows, each with a FAIL line and a commit sha that exists (`git -C <repo> cat-file -t <sha>` prints commit)
|
||||
- `grep -c "TestSessionReaper\|TestAuthTime\|TestMemberTokenScopes\|TestBackendLinkAuthTime\|TestMCPVerifierRevocation\|TestMCPRevocationEndToEnd" .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md` prints at least 6
|
||||
- `grep -c "B-IN-05\|B-IN-06\|PHASE197_RELEASED" .planning/phases/19.7-generic-mcp-module/deferred-items.md` prints at least 3
|
||||
</acceptance_criteria>
|
||||
<done>The security documents state only what tests prove, correct the earlier false verdicts, cover every new threat, and show the critical fixes failing without their code; the validation map and deferred items match the gap closure; the gate is green after the documentation commits.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<artifacts_this_phase_produces>
|
||||
## Artifacts this plan produces
|
||||
|
||||
**Gate:** `scripts/check-phase19.7.sh` with:
|
||||
- `workspace_check`;
|
||||
- the unreleased-pin policy and `PHASE197_RELEASED` strict mode;
|
||||
- the `USER_SHORT_TESTS` and `VUE_FILES` arrays;
|
||||
- the cooler doc check;
|
||||
- every new required name.
|
||||
|
||||
**Framework tests:**
|
||||
- pier: `TestSessionReaper`, `TestSessionReserve`, `TestLockScope`, `TestScopeWidening`, `TestStatelessFanOut`, `TestPersonalTokenBinding`, `TestDispatchHardening`, `TestCatalogPathFields`, `TestPromptWriteCeiling`, `TestTokenScopedRevoke`, `TestResolveClientAddress`;
|
||||
- bouncer: `TestAuthTime`;
|
||||
- pact: `TestFrontendTokenScopes`;
|
||||
- towel: `TestClientIP`;
|
||||
- cabana: `TestTokenScopeNameParity`, `TestAccountContributionURL`, `TestAccountContributionsIsolation`, `TestRecordActionPromptLocalized`, `TestAccountTokenRevokeEvent`, `TestResolveBackendTokenRemote`;
|
||||
- vitest: `admin/tests/app/hotkeysEditing.test.ts`, plus the extended `AccountContributions.test.ts`.
|
||||
|
||||
**Plugin, site and demo tests:**
|
||||
- sm-user-plugin: `TestMemberTokenScopes`, `TestMemberTokenScopesBoot`, `TestBackendLinkAuthTime`, `TestBackendLinkShowPost`, `TestAccessRevocation`, `TestUserMCPGuardClientIP`, `TestAPITokenRevokeEvent`, `TestOrganisationLogo`;
|
||||
- sm-oauthserver-plugin: `TestMCPVerifierRevocation`, `TestMCPGrantRevocation`;
|
||||
- sm-journal-plugin: `TestJournalPromptWrites`;
|
||||
- sm-demo-app: `TestMCPRevocationEndToEnd`;
|
||||
- vue-demo-app: `app/lib/linkCode.test.ts`.
|
||||
|
||||
**Documents:**
|
||||
- `19.7-VALIDATION.md` rows;
|
||||
- `19.7-SECURITY.md` and `19.7-SECURITY-REVIEW.md`: the corrections, T-19.7-42..65, and the revert-checks;
|
||||
- `deferred-items.md`: deferrals, the release order and the local-only wiring.
|
||||
|
||||
**Decisions:** P-40 and P-41.
|
||||
</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 repositories and local workspace files |
|
||||
| security documents to the release decision | v0.5.0 is tagged on the strength of these documents |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-19.7-64 | Repudiation | a green gate built on a stray local workspace or on unreleased plugin drift | medium | mitigate | `workspace_check` refuses a repository resolving the framework or the user plugin elsewhere; unreleased drift is accepted only when the canonical checkout holds the commits, and is reported; `PHASE197_RELEASED=1` refuses any drift after the release; self-test cases for each outcome |
|
||||
| T-19.7-65 | Repudiation | a security document marking a control verified without a test that fails without it (the T-19.7-22 failure) | high | mitigate | revert-checks for the three critical findings recorded with FAIL and PASS evidence; the Method step requiring a failing-without-fix test for high and critical controls; the Corrections table for every disproved verdict |
|
||||
| T-19.7-SC | Tampering | package installs | low | mitigate | no package added; vitest runs use the committed locks (`npm --prefix admin ci` when needed, vue-demo-app's existing node_modules or `pnpm install --frozen-lockfile`) |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `bash scripts/check-phase19.7.sh --all` on a Docker host: PASS for self-test, go, plugins, consumers, admin, docs, marker and docker
|
||||
- `bash scripts/check-phase19.6.1.sh --all` still passes (the earlier gate is not broken by the framework changes)
|
||||
- The framework's `go vet ./... && go test -count=1 ./...` with Docker, and `cd examples/hello && go test ./...`
|
||||
- `19.7-SECURITY.md` has `threats_open: 0`; `19.7-SECURITY-REVIEW.md` covers T-19.7-01..65 and T-19.7-SC, with the Corrections and Revert-checks sections
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Unit tests are the last plan, and every gap-closure fix and both escalations have required, named tests (E-2's acceptance verbatim)
|
||||
- The gate is fail-closed against workspace and pin accidents, and green
|
||||
- The security review is corrected and extended, with revert-check evidence for the critical findings; the validation map and deferred items are current
|
||||
- No tag, push or deploy
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/19.7-generic-mcp-module/19.7-09-SUMMARY.md` when done, with a commit table per repository, the gate output of the final `--all` run, and the revert-check results. Commit the SUMMARY separately as a planning doc. The SUMMARY also names the g15office follow-up for the orchestrator's phase-advance step (CLAUDE.md rule 4).
|
||||
|
||||
Release rule: this plan does not tag, push or deploy. Every repository works against the local framework (go.work, or `replace ../summercms.go`), and every plugin's go.mod `require` line stays at its current version. The plans may commit locally in every repository. After the re-review, phase verification, Nyquist validation and UAT pass (user decision 2026-10-23), the releases happen in this order:
|
||||
1. framework v0.5.0;
|
||||
2. the sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin tags that require it;
|
||||
3. the application bumps;
|
||||
4. `PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers` to confirm the pins.
|
||||
</output>
|
||||
373
.planning/phases/19.7-generic-mcp-module/19.7-09-SUMMARY.md
Normal file
373
.planning/phases/19.7-generic-mcp-module/19.7-09-SUMMARY.md
Normal file
@@ -0,0 +1,373 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
plan: 09
|
||||
subsystem: testing
|
||||
status: complete
|
||||
gap_closure: true
|
||||
tags: [pier, bouncer, cabana, pact, towel, admin-spa, vitest, sm-user-plugin, sm-oauthserver-plugin, sm-journal-plugin, sm-demo-app, vue-demo-app, gate, security-review, revert-check, gap-closure]
|
||||
|
||||
requires:
|
||||
- phase: 19.7-06
|
||||
provides: pier lane A fixes (reaper, reservation, widening, stateless lifecycle, dispatch hardening, prompt ceiling) and their seams
|
||||
- phase: 19.7-07
|
||||
provides: auth_time, pact.HasFrontendTokenScopes, narrowed revocation, towel.ClientIP, cabana and SPA lane B fixes
|
||||
- phase: 19.7-08
|
||||
provides: plugin lane C fixes, E-1 (organisation logo) and E-2 (member token scopes)
|
||||
provides:
|
||||
- a named test for every fix of plans 06-08 and both escalations, E-2's acceptance list item by item
|
||||
- check-phase19.7.sh with the workspace check, consumers built against the unreleased user plugin, the unreleased-pin policy and PHASE197_RELEASED strict mode, the demo site's vitest run and the cooler doc check
|
||||
- the corrected and extended 19.7-SECURITY-REVIEW.md (Corrections, Revert-checks, T-19.7-42..T-19.7-65) and 19.7-SECURITY.md (threats_open 0)
|
||||
- 19.7-VALIDATION.md rows for the gap closure and the updated deferred-items.md (release order)
|
||||
affects: [phase 19.7 re-review of the gap closure, msd-verifier, /msd-validate-phase 19.7, /msd-verify-work 19.7, framework v0.5.0 and the plugin tags, sm-servers-app (E-1, E-2)]
|
||||
|
||||
actuals:
|
||||
tokens: 61800
|
||||
tasks: 4
|
||||
commits: 9
|
||||
commits_by_repo:
|
||||
summercms.go: 9
|
||||
sm-user-plugin: 3
|
||||
sm-oauthserver-plugin: 1
|
||||
sm-journal-plugin: 1
|
||||
vue-demo-app: 1
|
||||
sm-demo-app: 2
|
||||
plan_head_before: 05d7e9351a45eb96cf97eaab8fc3de41d81536ae
|
||||
plan_head_after: e1f489058c0efa68e60886317d4310201f8df384
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Revert-check: a critical fix is reverted in a scratch worktree with the tests kept at HEAD; the pinning test must fail there and pass at HEAD"
|
||||
- "Gate trusts no local workspace: go list -m answers where each repository resolves the framework and the user plugin"
|
||||
- "A plugin submodule ahead of its pin is accepted only by commits its canonical checkout holds, and reported as unreleased"
|
||||
- "Consumers are built against an unreleased plugin through a scratch copy of their go.work, never by editing it"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/pier/reaper_test.go
|
||||
- modules/pier/reserve_test.go
|
||||
- modules/pier/lock_scope_test.go
|
||||
- modules/pier/widening_test.go
|
||||
- modules/pier/stateless_fanout_test.go
|
||||
- modules/pier/personal_binding_test.go
|
||||
- modules/pier/dispatch_hardening_test.go
|
||||
- modules/pier/catalog_path_fields_test.go
|
||||
- modules/pier/prompt_ceiling_test.go
|
||||
- modules/pier/token_events_test.go
|
||||
- modules/bouncer/auth_time_test.go
|
||||
- modules/pact/frontend_token_scopes_test.go
|
||||
- modules/towel/client_ip_test.go
|
||||
- modules/cabana/account_contributions_hardening_test.go
|
||||
- modules/cabana/record_action_prompt_localized_test.go
|
||||
- modules/cabana/token_scope_name_test.go
|
||||
- modules/cabana/account_token_events_test.go
|
||||
- modules/cabana/token_resolver_remote_test.go
|
||||
- admin/tests/app/hotkeysEditing.test.ts
|
||||
- ../sm-demo-app/plugins/golem15/user/member_token_scopes_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_auth_time_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/backend_link_show_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/access_revocation_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/organisation_logo_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/mcp_guard_client_ip_test.go
|
||||
- ../sm-demo-app/plugins/golem15/user/api_token_events_test.go
|
||||
- ../sm-oauthserver-plugin/mcp_revocation_test.go
|
||||
- ../sm-journal-plugin/mcp_prompt_writes_test.go
|
||||
- ../sm-demo-app/mcp_revocation_e2e_test.go
|
||||
- ../sm-demo-app/vue-demo-app/app/lib/linkCode.test.ts
|
||||
modified:
|
||||
- scripts/check-phase19.7.sh
|
||||
- modules/pier/export_test.go
|
||||
- admin/tests/account/AccountContributions.test.ts
|
||||
- ../sm-demo-app/plugins/golem15/user/controllers/organisations_admin_controller.go
|
||||
- ../sm-demo-app/plugins/golem15/user/README.md
|
||||
- ../sm-oauthserver-plugin/README.md
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-demo-app/mcp_e2e_test.go
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md
|
||||
- .planning/phases/19.7-generic-mcp-module/deferred-items.md
|
||||
|
||||
key-decisions:
|
||||
- "P-40 as built: workspace_check resolves with go list -m ({{.Replace.Dir}} else {{.Dir}}) through realpath, in the plugins, consumers (all three applications) and docker stages; demo_pins accepts unreleased commits only when the canonical checkout holds the submodule HEAD; PHASE197_RELEASED=1 refuses any drift before the policy runs"
|
||||
- "P-41 as built: the tests stay at HEAD in every revert worktree; where a revert conflicts or removes a seam, later commits' code is kept and the seam answers the no-fix value (ReapNow 0); C-CR-02 reverts only the confirm handler of 32f9259"
|
||||
- "Organisation attachments are deleted by a new FormAfterDelete hook (not in FormBeforeDelete), so the plugin's exported method declarations stay unchanged for the additive check"
|
||||
- "TestSessionReaper requires the reaper for the copy of the instance that did not serve the last request; the other copy may also be closed by a late persist that finds the record gone"
|
||||
|
||||
patterns-established:
|
||||
- "A Postgres-backed test returns before creating subtests under -short (no t.Skip), so the gate's skip refusal stays meaningful"
|
||||
|
||||
requirements-completed: [SC-1, SC-2, SC-3, SC-4, D-05, D-08, D-17, D-19, D-20, D-21, D-25, D-26, D-27, D-31, E-1, E-2]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Named framework tests for every pier fix of plan 06 (reaper, reservation, lock scope, widening, stateless fan-out, personal binding, dispatch hardening, path fields, prompt ceiling)"
|
||||
requirement: "D-25"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/pier/*_test.go#TestSessionReaper TestSessionReserve TestLockScope TestScopeWidening TestStatelessFanOut TestPersonalTokenBinding TestDispatchHardening TestCatalogPathFields TestPromptWriteCeiling"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase19.7.sh --go"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Named tests for every framework and admin SPA fix of plan 07 (auth_time, token-scoped revocation, client address, scope name rule, account action URL and section isolation, localized prompt refusal, hotkeys while editing)"
|
||||
requirement: "D-05"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/bouncer/auth_time_test.go#TestAuthTime; modules/pier/token_events_test.go#TestTokenScopedRevoke TestResolveClientAddress; modules/cabana (TestAccountContributionURL, TestAccountContributionsIsolation, TestRecordActionPromptLocalized, TestTokenScopeNameParity, TestAccountTokenRevokeEvent, TestResolveBackendTokenRemote); modules/pact#TestFrontendTokenScopes; modules/towel#TestClientIP"
|
||||
status: pass
|
||||
- kind: automated_ui
|
||||
ref: "admin/tests/app/hotkeysEditing.test.ts; admin/tests/account/AccountContributions.test.ts"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "E-2 acceptance list as tests, item by item, plus the boot refusals"
|
||||
requirement: "E-2"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "sm-user-plugin/member_token_scopes_test.go#TestMemberTokenScopes TestMemberTokenScopesBoot"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Plugin, site and demo tests for plan 08 (link proof, link code transport, access revocation, client IP, token revoke event, organisation logo, verifier and grant revocation, Journal prompt ceiling, demo revocation matrix, link code reader)"
|
||||
requirement: "SC-4"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "sm-user-plugin (TestBackendLinkAuthTime, TestBackendLinkShowPost, TestAccessRevocation, TestUserMCPGuardClientIP, TestAPITokenRevokeEvent, TestOrganisationLogo); sm-oauthserver-plugin (TestMCPVerifierRevocation, TestMCPGrantRevocation); sm-journal-plugin#TestJournalPromptWrites"
|
||||
status: pass
|
||||
- kind: e2e
|
||||
ref: "sm-demo-app/mcp_revocation_e2e_test.go#TestMCPRevocationEndToEnd"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "vue-demo-app/app/lib/linkCode.test.ts"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Extended fail-closed gate (workspace check, consumers on the unreleased user plugin, unreleased-pin policy, PHASE197_RELEASED, vue vitest, cooler docs) green with every stage PASS"
|
||||
requirement: "D-31"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase19.7.sh --all (Phase 19.7 gate passed); PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers exits 1"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Corrected and extended security review and contract (Corrections, revert-checks for the three critical fixes, T-19.7-42..65), validation rows and deferred items"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "Task 4 verify chain (threats_open 0, every T-19.7-42..65 in both documents, Revert-check section, B-IN-05, TestMemberTokenScopes) and the revert-check runs"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "The corrections and threat verdicts are a reviewer's judgment; the re-review of the gap closure and msd-verifier must confirm them"
|
||||
|
||||
duration: 88min
|
||||
completed: 2026-10-23
|
||||
---
|
||||
|
||||
# Phase 19.7 Plan 09: Gap-closure tests, the extended gate and the corrected security review Summary
|
||||
|
||||
Every fix of the gap-closure plans 06-08 and both sm-servers-app escalations is now pinned by a named test that the phase gate requires: 21 framework and SPA tests, 8 user-plugin tests (E-2's acceptance list item by item), 2 OAuth server tests, a Journal test, a demo end-to-end revocation matrix and a vue-demo-app unit test. The gate no longer trusts local workspace files: it checks where each repository resolves the framework and the user plugin, builds fonoteka.go and sm-bm-app against the unreleased user plugin through scratch go.work copies, reports the demo's plugin submodules as "ahead of its pin by unreleased commits", and refuses any drift under `PHASE197_RELEASED=1`. The security review now corrects the eight verdicts the code review disproved (T-19.7-22 first) and records T-19.7-42..T-19.7-65. The revert-checks show that each of the three critical fixes' tests fails with the fix reverted.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 88 min
|
||||
- **Started:** 2026-10-23T15:32:53Z
|
||||
- **Completed:** 2026-10-23T17:01:31Z
|
||||
- **Tasks:** 4 of 4
|
||||
- **Files:** 43 across six repositories (30 created)
|
||||
|
||||
## Commits
|
||||
|
||||
Nothing was tagged, pushed or deployed.
|
||||
|
||||
**summercms.go** (master, plan base 05d7e93; 9 commits, measured)
|
||||
|
||||
| Commit | Task | What |
|
||||
|--------|------|------|
|
||||
| 0aa48ae | 1 (tracer) | gate: workspace check, scratch go.work consumers, unreleased-pin policy, `PHASE197_RELEASED`, self-test cases; `TestSessionReaper`, `TestAuthTime` |
|
||||
| fda4646 | 1 (follow-up) | `TestSessionReaper` tolerates a transient store read on a loaded host |
|
||||
| ccf77b9 | 2 | the plan 06/07 framework, cabana and SPA tests; the `WrapStore` seam; gate arrays |
|
||||
| c2d486b | 2 (follow-up) | `TestSessionReaper` requires the reaper only where nothing else can close the copy |
|
||||
| 7f43e0e | 3 | gate: `USER_SHORT_TESTS`, plugin and demo names, `VUE_FILES` vitest run, cooler doc check |
|
||||
| 946fb2d | 4 | docs: 19.7-SECURITY-REVIEW.md corrected and extended |
|
||||
| 33faa44 | 4 | docs: 19.7-SECURITY.md register, corrected rows, audit trail |
|
||||
| a636933 | 4 | docs: 19.7-VALIDATION.md rows |
|
||||
| e1f4890 | 4 | docs: deferred-items.md |
|
||||
|
||||
**sm-user-plugin** (`../sm-demo-app/plugins/golem15/user`, master, base f20a8d3)
|
||||
|
||||
| Commit | Task | What |
|
||||
|--------|------|------|
|
||||
| 25b9f2e | 3 | `fix:` deleting an organisation removes its avatar and logo attachments (production defect found by `TestOrganisationLogo`) |
|
||||
| e3c164f | 3 | tests: `TestMemberTokenScopes`, `TestMemberTokenScopesBoot`, `TestBackendLinkAuthTime`, `TestBackendLinkShowPost`, `TestAccessRevocation`, `TestUserMCPGuardClientIP`, `TestAPITokenRevokeEvent`, `TestOrganisationLogo`; README Testing |
|
||||
| 38551a4 | 3 | `fix:` the attachment cleanup runs in a new `FormAfterDelete` (keeps the plugin additive) |
|
||||
|
||||
**sm-oauthserver-plugin** (master, base 671513d): 65f71dc `test:` `TestMCPVerifierRevocation`, `TestMCPGrantRevocation` (README Testing).
|
||||
|
||||
**sm-journal-plugin** (main, base b129902): 2aeeccc `test:` `TestJournalPromptWrites` (README Testing).
|
||||
|
||||
**vue-demo-app** (master, base 0125e29): b973a76 `test:` `app/lib/linkCode.test.ts`.
|
||||
|
||||
**sm-demo-app** (master, base 7731641): faeece2 `test:` `TestMCPRevocationEndToEnd`, `bootMCPDemoWith`, unused `connectWatching` removed; f53d30a `chore:` vue-demo-app pointer bump (staged alone).
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Task 1 (tracer).**
|
||||
- Gate (P-40):
|
||||
- `workspace_check` runs at the top of the plugins, consumers and docker stages and refuses a mismatch with both paths named.
|
||||
- `consumer_with_user_plugin` builds fonoteka.go and sm-bm-app against `$USER_PLUGIN`. Both applications' go.work files are untouched (status count 0).
|
||||
- `demo_pins` gained the unreleased-commit policy and released mode.
|
||||
- The header documents `PHASE197_RELEASED`.
|
||||
- 31 self-test cases print one PASS line each.
|
||||
- `TestSessionReaper` and `TestAuthTime` are required in the go stage, together with the plan 06 and 07 smokes.
|
||||
- Tracer gate: the run is interactive and `end-of-phase`, and the verify chain is automated only. Re-running self-test, go, plugins and consumers end to end passed before the expansion tasks started. `PHASE197_RELEASED=1 --consumers` exits 1 while the pins drift.
|
||||
- **Task 2.**
|
||||
- Every behaviour of the plan's behavior block is a test under its exact name, with the cases as subtests.
|
||||
- Every test passed at once, so no framework fix was needed. Because none could start red, the RED evidence for each was checked by hand where a fix could be undone cheaply. With `originOf` and the blur-before-click reverted in hotkeys.ts, 3 of the 4 hotkeysEditing cases fail. With the reaper reverted, `TestSessionReaper` fails (see the revert-checks).
|
||||
- `go test -race ./modules/pier` is clean over 3 to 8 repeated runs.
|
||||
- **Task 3.**
|
||||
- The plugin, site and demo tests are written under the plan's names, one commit per repository, with the fix commits first.
|
||||
- The gate requires all of them, and the demo site's vitest run requires `app/lib/linkCode.test.ts`.
|
||||
- The docs stage checks the two cooler doc comments.
|
||||
- **Task 4.**
|
||||
- The security review gained:
|
||||
- Method step 6;
|
||||
- the Corrections table: T-19.7-22, cross-cutting findings 1 and 6, T-19.7-23, -03, -17, -18, -08, -31 and -35;
|
||||
- cross-cutting findings 1 and 6 rewritten in place;
|
||||
- the Revert-checks table;
|
||||
- register rows T-19.7-42..T-19.7-65 plus the gap-closure T-19.7-SC.
|
||||
- 19.7-SECURITY.md has 66 register rows, `threats_open: 0` and an audit-trail entry.
|
||||
- Validation and deferred items are updated.
|
||||
|
||||
## Revert-checks (P-41)
|
||||
|
||||
Each worktree was created under the session scratch directory and removed afterwards with `git worktree remove --force` and `git worktree prune`. Nothing was committed from any of them.
|
||||
|
||||
| Repo | Fix reverted | Test | With the fix reverted | At HEAD |
|
||||
|------|--------------|------|-----------------------|---------|
|
||||
| summercms.go | 2bf9dca (A-CR-01) | `TestSessionReaper` | FAIL `reaper_test.go:79: reaped = 0, want 1` (all 5 subtests fail) | PASS |
|
||||
| sm-oauthserver-plugin | 671513d (C-CR-01) | `TestMCPVerifierRevocation` | FAIL `mcp_revocation_test.go:98: created two seconds before the cutoff: verify = <nil>, want pact.ErrMCPTokenInvalid` (all 5 subtests fail) | PASS |
|
||||
| sm-user-plugin | 32f9259 (C-CR-02, the confirm handler) | `TestBackendLinkAuthTime` | FAIL `backend_link_auth_time_test.go:64: confirm = 200 …, want 409 with "stale_session"` (and `:86`) | PASS |
|
||||
|
||||
## Gate output (final `bash scripts/check-phase19.7.sh --all`, after the documentation commits)
|
||||
|
||||
```
|
||||
PASS self-test
|
||||
PASS go
|
||||
PASS plugins
|
||||
PASS consumers
|
||||
PASS admin
|
||||
PASS docs
|
||||
PASS marker
|
||||
PASS docker
|
||||
Phase 19.7 gate passed
|
||||
```
|
||||
|
||||
The consumers stage printed:
|
||||
- `pins: plugins/golem15/journal is ahead of its pin by unreleased commits (release after verification)`, and the same line for `oauthserver` and `user`;
|
||||
- the vue-demo-app vitest summary: 182 tests passed.
|
||||
|
||||
The admin vitest run: 1552 tests passed.
|
||||
|
||||
The docker stage ran the framework's cabana suites, then 16 user-plugin, 7 OAuth server and 2 demo top-level tests, all by name.
|
||||
|
||||
Also run:
|
||||
- the framework's `go vet ./...`, `go vet -tags summercms_mcp ./...` and `go test -count=1 ./...` with Docker, plus examples/hello: green;
|
||||
- `bash scripts/check-phase19.6.1.sh --all`: "Phase 19.6.1 gate passed";
|
||||
- `GOWORK=off go test -count=1 ./...` in the user plugin with Docker: green.
|
||||
|
||||
go.mod, go.sum and the npm locks are unchanged in every repository.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Deleting an organisation left its attachments behind (E-1)**
|
||||
- **Found during:** Task 3 (`TestOrganisationLogo`, "deleting the organisation removes the logo attachment as it does the avatar")
|
||||
- **Issue:** The plan assumed the avatar is removed with the organisation. Neither the avatar nor the new logo was removed: the `system_files` rows and their blobs outlived the organisation row.
|
||||
- **Fix:**
|
||||
- 25b9f2e deletes the attachments in the delete's transaction (`attach.DeleteForOwner`) and the blobs after the commit, as the user delete does. The README's Organisations line says so.
|
||||
- The first version changed `FormBeforeDelete`'s receiver, which the gate's additive check reads as a changed exported method declaration. 38551a4 therefore moves the cleanup into a new `FormAfterDelete` and restores `FormBeforeDelete` exactly.
|
||||
- **Files:** `../sm-demo-app/plugins/golem15/user/controllers/organisations_admin_controller.go`, `README.md`
|
||||
- **Commits:** 25b9f2e, 38551a4 (sm-user-plugin)
|
||||
|
||||
**2. [Rule 1 - Test race] `TestSessionReaper`'s Redis case was flaky under load**
|
||||
- **Found during:** Task 2's verify (one run in roughly ten of the full suite)
|
||||
- **Issue:** A request's state is persisted after its answer has been streamed. When the instance that served the last request was still persisting after the clock moved past the expiry, persist found the record gone and closed the copy itself. The reaper then counted 0 for that instance.
|
||||
- **Fix:**
|
||||
- fda4646 reaps until the copies are gone and asserts both copies before the expiry.
|
||||
- c2d486b requires the reaper for the copy of the instance that did not serve the last request and allows the other copy to be closed by the late persist. That behaviour is correct (an ended session is never written back).
|
||||
- After both commits: 30 consecutive passes, and a clean full gate.
|
||||
- **Commits:** fda4646, c2d486b
|
||||
|
||||
**3. [Rule 1 - Test race] `TestSessionReserve` checked the local copies before the release had run**
|
||||
- **Found during:** a background stress run of Task 2
|
||||
- **Fix:** The test waits for each failed initialize's slot release before the next attempt. It was folded into ccf77b9 before that commit.
|
||||
|
||||
**4. [Plan detail] Placement and harness choices**
|
||||
- `TestResolveClientAddress` is in `token_events_test.go`. The plan's acceptance grep counts it among the nine pier files, and the plan lists no file of its own for it.
|
||||
- The `-short` part of `TestResolveBackendTokenRemote` (a failed resolve without cabana logs `remote`) is also required in `GO_TESTS`.
|
||||
- `TestDispatchHardening` drives its contradicting and failing dispatches through one frontend guard keyed by the route method, because pier allows one frontend guard per application.
|
||||
- `TestJournalPromptWrites` serves pier with a stand-in backend guard. The built-in backend guard needs the admin database, and the test runs under `-short`.
|
||||
- `consumer_with_user_plugin` uses its own go.work rewriter rather than plan 08's fixed template.
|
||||
- The workspace check also covers fonoteka.go and sm-bm-app in the consumers stage, because the plan says every repository must resolve the framework to this checkout.
|
||||
- The gate's `--self-test` now prints one PASS line per planted case (31 cases).
|
||||
|
||||
**5. [Plan wording] `readLinkCode` with extra fragment parameters**
|
||||
- The plan says "extra parameters … give ''". The implementation parses the fragment with URLSearchParams, so `#code=<hex>&next=/x` answers the code.
|
||||
- The test pins extended and foreign values (''), and leaves the lenient case unasserted.
|
||||
- It is recorded in deferred-items.md for the re-review to decide. No production change was made in this tests-only plan.
|
||||
|
||||
**6. [Revert-check method] C-CR-02 reverted at the handler level**
|
||||
- A whole-commit revert of 32f9259 also removes the `#code=` URL, so the test would fail at the link URL regexp before reaching the auth_time assertions.
|
||||
- Only `BackendLinkConfirm` was restored to its pre-fix `iat` body, which isolates the property.
|
||||
- A-CR-01's revert conflicted with later commits. They were resolved keeping the later code, and the `ReapNow` seam answers 0.
|
||||
|
||||
**Total deviations:** one production defect fixed in its own commits (Rule 1), two test races in this plan's own tests (Rule 1), and plan-detail choices recorded above. **Impact:** no shipped framework code changed. The user plugin gained a `FormAfterDelete` hook, and that change is additive.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- One `go test -short ./...` run failed in `docs/examples/blog` with "module lookup disabled by GOPROXY=off". It has not recurred in more than twenty runs. It is recorded in deferred-items.md.
|
||||
- The repositories have `git rerere` enabled, so the revert worktrees recorded conflict preimages. `git rerere clear` ran in each worktree before it was removed.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
Tasks 2 and 3 carry `tdd="true"`, but they pin behaviour that plans 06-08 had already built ("most pass at once"). There is therefore no `feat(19.7-09)` GREEN commit and no failing RED commit for those tests.
|
||||
|
||||
Red evidence instead:
|
||||
- the three revert-checks;
|
||||
- the hotkeys revert run of Task 2;
|
||||
- `TestOrganisationLogo`, which failed for a real defect and went green with fix commits 25b9f2e and 38551a4.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The plan adds tests, a gate and documents. Its only production change, the organisation attachment cleanup, is part of T-19.7-61.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Phase 19.7's gap closure is complete. The phase is ready for the fresh re-review of plans 06-09, then the regression gate, msd-verifier, /msd-validate-phase 19.7 and /msd-verify-work 19.7. UAT includes a real MCP client against the local demo.
|
||||
- Release order and local-only wiring: see deferred-items.md.
|
||||
- Do not commit sm-oauthserver-plugin's go.work retarget. sm-demo-app's `main.go` and its plugin submodule pointers stay unstaged.
|
||||
- The release order is: framework v0.5.0, then the plugin tags, then the application bumps (vue-demo-app pushed first), then `PHASE197_RELEASED=1 --consumers`.
|
||||
- **g15office follow-up for the orchestrator** (CLAUDE.md rule 4): at the phase-advance step, move tasks hmguritm and tqyvnzxx into milestone dcnv4mha and post the short phase comment, "gap closure 06-09 complete, gate green, awaiting re-review and verification".
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: all 30 created test files across the six repositories, and the modified gate and documents.
|
||||
- FOUND: the framework commits 0aa48ae, fda4646, ccf77b9, c2d486b, 7f43e0e, 946fb2d, 33faa44, a636933, e1f4890.
|
||||
- FOUND: the user plugin commits 25b9f2e, e3c164f, 38551a4; oauthserver 65f71dc; journal 2aeeccc; vue-demo-app b973a76; sm-demo-app faeece2, f53d30a.
|
||||
- Revert-check fix shas 2bf9dca, 671513d and 32f9259 resolve to commits (`git cat-file -t`).
|
||||
- No commit deleted a tracked file.
|
||||
|
||||
---
|
||||
*Phase: 19.7-generic-mcp-module*
|
||||
*Completed: 2026-10-23*
|
||||
@@ -118,7 +118,7 @@ Out of scope: MCP resources (the capability is designed for them, but they ship
|
||||
- the `ai` scope plays no part in the read/write ceiling;
|
||||
- consent is served as JSON endpoints in sm-oauthserver-plugin, with a `/connect` page in vue-demo-app;
|
||||
- the permission code is `golem15.users.manage_backend_links`.
|
||||
- **D-36:** **Plan split, 5 plans** (user-confirmed):
|
||||
- **D-36 [informational]:** **Plan split, 5 plans** (user-confirmed):
|
||||
1. framework seams;
|
||||
2. the pier module and framework release;
|
||||
3. sm-user-plugin;
|
||||
|
||||
73
.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
Normal file
73
.planning/phases/19.7-generic-mcp-module/19.7-GAP-INPUTS.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# Phase 19.7 gap-closure inputs
|
||||
|
||||
Recorded 2026-10-23 from the user's answer at the code-review gate. The gap-closure plans cover three sources:
|
||||
|
||||
1. **Code review** (`19.7-REVIEW.md`): fix every critical and warning finding (3 critical, 17 warnings) before v0.5.0. Info findings are fixed where cheap; the rest go to `deferred-items.md` with a reason.
|
||||
2. **Escalation E-1** (sm-servers-app): organisation logo.
|
||||
3. **Escalation E-2** (sm-servers-app): plugin-declared scopes for member (`usr_`) API tokens.
|
||||
|
||||
sm-user-plugin is a core plugin used by many applications: every change is additive (no removed export, route, column or payload field; no changed response shape).
|
||||
|
||||
v0.5.0 is tagged only after the gap closure, a fresh code review of the changes, phase verification, Nyquist validation and UAT are all green (user decision 2026-10-23).
|
||||
|
||||
## E-1: Organisation logo (sm-user-plugin)
|
||||
|
||||
Organisations get a `logo` file field (an image attachment through `lagoon/attach`), editable in the backend Organisations form, so an application can upload an organisation's logo and show it on the frontend. The frontend organisation payloads gain the logo (URL or attachment object, following how the plugin already exposes user avatars), as an added field only.
|
||||
|
||||
## E-2: Plugin-declared scopes for member (`usr_`) API tokens
|
||||
|
||||
Escalated by sm-servers-app (PxPx Servers Inventory). Affects sm-user-plugin v0.1.9+ and `pact.HasTokenScopes`. Priority: blocking for their Phase 02.1 (agent component reporting).
|
||||
|
||||
### Problem
|
||||
|
||||
Member personal API tokens (`usr_`) can only carry the fixed scopes `read`, `write` and `ai`. A plugin cannot declare its own scopes for them.
|
||||
|
||||
- `sm-user-plugin/classes/api_tokens.go`: `AllowedAPITokenScopes = []string{"read", "write", "ai"}`. `MintAPIToken` refuses anything else.
|
||||
- `sm-user-plugin/controllers/api_tokens.go`, `apiTokenScopes`: `POST /_user/api/v1/tokens` answers 422 "The selected scope is invalid." for any other value.
|
||||
- `pact.HasTokenScopes` (`TokenScopes() []pact.TokenScope`) exists, but only `cabana/token_scopes.go` reads it, for the backend `g15_` token catalog. The user plugin ignores it.
|
||||
|
||||
A plugin that wants a narrow agent token (for sm-servers-app: `servers:read` and `servers:write`) has to fall back to the generic `write`. Every app sharing the token table then gives the same scope a different meaning, and a token's scopes no longer say what it is for.
|
||||
|
||||
### Use case
|
||||
|
||||
Organisation members mint a personal token from the app's Nuxt screen and hand it to a recon agent. The agent calls:
|
||||
|
||||
- `GET /_servers/api/v1/servers?host=&port=` with scope `servers:read`
|
||||
- `PUT /_servers/api/v1/servers/{id}/components/report` with scope `servers:write`
|
||||
|
||||
The routes are guarded by `APITokenGuard` plus `middleware.Scope("servers:write")`. The app also checks the member's live role, so no mint-time role check is asked for.
|
||||
|
||||
### Ask
|
||||
|
||||
1. **Declaring:** the user plugin builds its allowed scope list from the built-in `read`, `write` and `ai` plus every active plugin's `pact.HasTokenScopes`. It reuses `pact.TokenScope`, or a user-plugin twin if the backend and frontend catalogs should stay apart. It validates names the way cabana does (pattern, no duplicates, no clash with the built-ins) and fails boot on a bad one.
|
||||
2. **Minting:** `POST /_user/api/v1/tokens` and `MintAPIToken` accept the declared scopes.
|
||||
3. **Checking:** `middleware.Scope` and `APIToken.HasScope` work with the declared scopes, with no special casing.
|
||||
4. **Listing:** `GET /_user/api/v1/tokens` returns them in `scopes`, as it does today.
|
||||
5. **Discovery:** an endpoint (for example `GET /_user/api/v1/tokens/scopes`, behind `jwt.auth`) or an exported helper that returns the allowed scopes with name, translated label and description, so a frontend can render them without hard-coding.
|
||||
|
||||
### Not asked for
|
||||
|
||||
- A mint-time hook to refuse a scope based on the user's role.
|
||||
- Any change to backend `g15_` tokens or the cabana catalog.
|
||||
- Any change to `tokens_valid_after` handling (G8 stays as discussed).
|
||||
|
||||
### Acceptance
|
||||
|
||||
- A plugin that declares `servers:write` can mint a `usr_` token with that scope through `POST /tokens`, and a route with `middleware.Scope("servers:write")` accepts it.
|
||||
- A token without the scope gets 403 "Missing required scope: servers:write".
|
||||
- An undeclared scope still answers 422 at mint time.
|
||||
- Two plugins declaring the same scope name, or a plugin redeclaring `read`, `write` or `ai`, fails boot.
|
||||
- The discovery answer lists the built-ins and the declared scopes with labels.
|
||||
|
||||
### Open design point for the planner
|
||||
|
||||
`pact.HasTokenScopes` today feeds the backend `g15_` catalog in cabana. If the user plugin also reads it, a scope a plugin declares for member tokens would also appear in the admin token catalog, and the reverse. Decide between reusing the interface (one catalog, both token kinds) and a separate frontend interface. The escalation does not ask for any change to the backend catalog, so a separate interface (or an audience field) is likely the safer choice. Record the choice as a decision.
|
||||
|
||||
## Planning decisions (user, 2026-10-23)
|
||||
|
||||
- **Four gap-closure plans:**
|
||||
- 19.7-06, pier hardening (lane A), wave 1
|
||||
- 19.7-07, framework auth (`auth_time`), cabana and admin SPA (lane B), plus the E-2 framework seam, wave 1
|
||||
- 19.7-08, the plugins (sm-user-plugin with C-CR-01, C-CR-02, C-WR-01, E-1 and E-2; oauthserver with C-CR-01 and C-WR-02; Journal with C-IN-01) and the demo, wave 2
|
||||
- 19.7-09, unit tests, the extended gate and the security-review corrections, wave 3 (the last plan, by project rule)
|
||||
- **Release order:** no tag in plans 06-09. Everything is developed and tested against the local framework (`replace ../summercms.go` / go.work). After the re-review, verification, Nyquist validation and UAT pass: tag framework v0.5.0, then tag sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin requiring v0.5.0, then bump the applications. sm-servers-app waits for that release for E-2.
|
||||
1073
.planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md
Normal file
1073
.planning/phases/19.7-generic-mcp-module/19.7-PATTERNS.md
Normal file
File diff suppressed because it is too large
Load Diff
377
.planning/phases/19.7-generic-mcp-module/19.7-REREVIEW-FIX.md
Normal file
377
.planning/phases/19.7-generic-mcp-module/19.7-REREVIEW-FIX.md
Normal file
@@ -0,0 +1,377 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
review: 19.7-REREVIEW.md
|
||||
fixed: 2026-10-23
|
||||
iteration: 1
|
||||
findings_in_scope: 28
|
||||
status: all_fixed_or_deferred
|
||||
summary: "1 critical and 10 warnings fixed, each with a test that fails on the old code; info items fixed where cheap, the rest deferred with a reason in deferred-items.md"
|
||||
---
|
||||
|
||||
# Phase 19.7 re-review fix report
|
||||
|
||||
The user chose the code-review fixer route (2026-10-23) with cheap info findings included. Three fixer lanes ran in sequence on the main checkouts: A (framework MCP core), B (cabana and admin SPA), C (plugins and demo, including the framework seam for RC-WR-01). Every deferral is also recorded in `deferred-items.md`.
|
||||
|
||||
Final gate (`bash scripts/check-phase19.7.sh --all`, after lane C): every stage PASS, verdict "Phase 19.7 gate passed WITH UNRELEASED PINS: the release pins are not yet proven (plugins/golem15/journal plugins/golem15/oauthserver plugins/golem15/user)". The qualified verdict is expected until the release.
|
||||
|
||||
Items flagged for human verification at UAT:
|
||||
- RB-WR-01: the save shortcuts inside a plugin field type's shadow root are verified in happy-dom only; check in Firefox.
|
||||
- RC-CR-01 and RC-WR-01: the password-change revocation and the consented-administrator binding change revocation logic and add per-user advisory locks; worth a human look.
|
||||
- RC-WR-01 behaviour change: backend grants issued before oauthserver migration 202610230001 lose backend reach until the agent reconnects.
|
||||
|
||||
|
||||
# Lane A
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Fix Report (re-review, lane A)
|
||||
|
||||
**Fixed at:** 2026-10-23
|
||||
**Source review:** .planning/phases/19.7-generic-mcp-module/19.7-REREVIEW.md (section "# Lane A")
|
||||
**Iteration:** 1
|
||||
|
||||
**Summary:**
|
||||
- Findings in scope: 12 (6 warnings, 6 info)
|
||||
- Fixed: 12. RA-IN-04 is only partly fixed; its leftover part is deferred.
|
||||
- Skipped: 0
|
||||
- Deferred residuals (recorded in deferred-items.md, commit eea04b1): the check-then-act cap in RA-IN-04, and the optional upstream check in RA-WR-06
|
||||
|
||||
**Where verification ran:** in the main checkout. `workflow.use_worktrees` is false, so no worktree was created. Every commit was checked with `go vet ./...`, `go vet -tags summercms_mcp ./...` and `go test -short ./...`, all green. `go test ./modules/pier/...` (with `-race` for the concurrency changes) and `go test ./cmd/summer -run TestDocsTree` were run after each pier or doc change. `scripts/check-phase19.7.sh --self-test` passes. I also ran `--demo-pins` and `--consumers` against the real sibling checkouts. They exit 0 and print the qualified line.
|
||||
|
||||
Each warning fix has a test that I first ran against the reverted code. Every one failed there, and passes with the fix.
|
||||
|
||||
## Fixed Issues
|
||||
|
||||
### RA-WR-01: Event fan-out nests session locks under the router lock; guard I/O under those locks has no deadline
|
||||
|
||||
**Files modified:** `modules/pier/events.go`, `modules/pier/session.go`, `modules/pier/stateless.go`, `modules/pier/config.go`, `modules/pier/README.md`, `docs/services/mcp.md`, `modules/pier/lock_scope_test.go`
|
||||
**Commit:** cccf402
|
||||
**Applied fix:**
|
||||
- **Matching.** `matchingFunc` on both paths now copies the entries while it holds `sr.mu`/`sp.mu`, releases the lock, and then reads each identity. The identity sits in a new `identityBox`, which has its own mutex and is never held across I/O. Matching never takes `ls.mu`/`e.mu`.
|
||||
- **Deadlines.** `widen`, `recomputeSession` and `recomputeStateless` run their guard checks under `guardContext`, which is `context.WithTimeout(context.WithoutCancel(ctx), cfg.CallTimeout)`. The README and the docs now say that `mcp.call_timeout` also bounds these re-filter checks.
|
||||
|
||||
**Test:** `TestLockScopeUnderWidening`
|
||||
- "an event for the blocked session does not stall another session": failed before the fix with "another session's call waited for the blocked widening".
|
||||
- "a blocked widening ends at mcp.call_timeout": failed before the fix, because the guard check outlived `call_timeout`.
|
||||
|
||||
### RA-WR-02: The fingerprint includes the OAuth token id, so a shared stateless server flips its tool set
|
||||
|
||||
**Files modified:** `modules/pier/identity.go`, `modules/pier/stateless.go`, `modules/pier/events.go`, `modules/pier/README.md`, `modules/pier/widening_test.go`, `modules/pier/fingerprint_test.go` (new)
|
||||
**Commit:** f604e6d
|
||||
**Applied fix:**
|
||||
- **Fingerprint.** It no longer includes subject token ids, so an access-token rotation alone re-filters nothing.
|
||||
- **Stateless refresh.** It now only adds tools and prompts. It runs when a fingerprint is new to the entry, and the entry remembers it in `widened`. A fan-out recompute clears that list and can still narrow. The receiving middleware still filters every list and call.
|
||||
- **Stateful path.** It keeps its exact add-and-remove `widen`, because a session serves one client.
|
||||
- **LRU key.** I did not re-key the LRU by binding plus fingerprint. The add-only refresh fixes the race without it.
|
||||
|
||||
**Tests:**
|
||||
- `TestFingerprintIgnoresTokenID` (internal).
|
||||
- `TestStatelessSharedBinding`: a wide token's call is blocked after its server was chosen, then a narrow token sends a request. Before the fix the call failed with `unknown tool "acme_echo"`.
|
||||
|
||||
### RA-WR-03: A transient guard error during widening permanently narrows a live session
|
||||
|
||||
**Files modified:** `modules/pier/filter.go`, `modules/pier/events.go`, `modules/pier/stateless.go`, `modules/pier/README.md`, `modules/pier/widening_test.go`
|
||||
**Commit:** e7630e6
|
||||
**Applied fix:**
|
||||
- **New check.** `catalog.allowedReport` returns the allowed lists plus the first provider error. `allowed` is now built on it.
|
||||
- **Widening, both paths.** On an error it logs "pier: widening deferred" and leaves the server and its recorded fingerprint untouched, so the next request retries.
|
||||
- **Fan-out recompute.** It still applies its diff, which fails closed and is safe for an event. On an error it records no fingerprint, so the binding's next request re-filters.
|
||||
|
||||
**Test:** `TestWideningGuardError`, with subtests "widening on stateless", "widening on stateful" and "recompute on an event". All three failed before the fix and listed `[acme_show]` or `[]` after the provider recovered.
|
||||
|
||||
### RA-WR-04: LRU capacity eviction ends live listen streams and in-flight calls
|
||||
|
||||
**Files modified:** `modules/pier/stateless.go`, `modules/pier/README.md`, `modules/pier/stateless_fanout_test.go`
|
||||
**Commit:** 928731d
|
||||
**Applied fix:**
|
||||
- **Counting active requests.** Each stateless request carries an `entryUse` on its context. `getServer`/`hit` count the entry they hand out as active while holding `sp.mu`. `ServeHTTP` releases it when the request ends, so a listen stream keeps its entry active for its whole life.
|
||||
- **Eviction.** It walks the LRU from the back and drops only idle entries. If every entry is busy, the LRU stays above capacity until requests end (documented).
|
||||
- **Revocation.** `evictFunc` is unchanged, so a revocation still closes every stream.
|
||||
|
||||
**Test:** `TestStatelessFanOut/an LRU eviction spares a server with a listen stream`. This rewrites the subtest that pinned the old behaviour. When the binding past capacity arrives, the listener's server stays and the oldest idle one is evicted. A revocation then still ends the stream. Before the fix: "the LRU eviction ended a live listen stream".
|
||||
|
||||
### RA-WR-05: Prompt Render errors reach the MCP client verbatim
|
||||
|
||||
**Files modified:** `modules/pier/session.go`, `modules/pier/README.md`, `docs/services/mcp.md`, `modules/pier/prompt_ceiling_test.go`
|
||||
**Commit:** 788d4a4
|
||||
**Applied fix:** `promptHandler` logs the error with the prompt name ("pier: prompt render failed"). It then returns `&jsonrpc.Error{Code: CodeInternalError, Message: "pier: the prompt could not be rendered"}`.
|
||||
**Test:** `TestPromptRenderError` (stateful and stateless). Before the fix the client received `failed to connect to host=db.internal ...`.
|
||||
|
||||
### RA-WR-06: The gate passes while demo submodules carry unreleased non-test commits
|
||||
|
||||
**Files modified:** `scripts/check-phase19.7.sh`
|
||||
**Commit:** 2fdda99
|
||||
**Applied fix:**
|
||||
- **Recording.** `demo_pins` records each submodule it accepts as ahead of its pin by unreleased commits. It keeps them in `UNRELEASED_PINS` and, when `PHASE197_PINS_FILE` is set, also writes them to that file, which `run_all` exports.
|
||||
- **`--consumers`.** With unreleased pins it now ends with "phase19.7 consumers passed WITH UNRELEASED PINS: <names> (the release pins are not yet proven)".
|
||||
- **`--all`.** It ends through `gate_verdict`. With unreleased pins that prints a notice box and the last line "Phase 19.7 gate passed WITH UNRELEASED PINS: the release pins are not yet proven (<names>)". With none it prints the unqualified "Phase 19.7 gate passed".
|
||||
- **Header comment.** Updated to describe this.
|
||||
- **Exit status.** It stays 0, and fail-closed by default (`PHASE197_ALLOW_UNRELEASED`) was not added. The release order verifies the phase before anything is tagged. A non-zero exit would fail every pre-release run, and the user's rule only asked for a qualified verdict. A check that greps for the exact line "Phase 19.7 gate passed" now fails while pins are unreleased.
|
||||
|
||||
**Test:** new self-test cases:
|
||||
- `pins-test-only-unrecorded`
|
||||
- `pins-unreleased-recorded`
|
||||
- `verdict (unqualified only without unreleased pins)`
|
||||
|
||||
Against the real checkouts, journal, oauthserver and user are reported, and the consumers stage prints the qualified line.
|
||||
|
||||
### RA-IN-01: lazyStore's doc comment says nothing dials at mount
|
||||
|
||||
**Files modified:** `modules/pier/store_redis.go`, `modules/pier/pier.go`
|
||||
**Commit:** 38e028f
|
||||
**Applied fix:**
|
||||
- The `lazyStore` and `newStore` comments now describe the mount-time background warm-up and its logged retries.
|
||||
- Decision: keep the warm-up for commands that mount pier without serving, such as `route:list`. It only dials and logs until the process exits. This decision is recorded in the comment.
|
||||
- The README row that said the store opens "on the first request" is corrected in 58408aa.
|
||||
|
||||
### RA-IN-02: Stream re-checks resolve the bearer without the client address
|
||||
|
||||
**Files modified:** `modules/pier/session.go`, `modules/pier/stateless.go`, `modules/pier/README.md`, `modules/pier/stateless_fanout_test.go`
|
||||
**Commit:** afc7510
|
||||
**Applied fix:** The GET stream and the listen stream capture `p.clientIP(r)` when they open. They resolve every re-check with `towel.WithClientIP`.
|
||||
**Test:** `TestStreamRecheckClientIP`, which failed before the fix: the re-check verifications saw an empty address.
|
||||
|
||||
### RA-IN-03: reserveScript touches keys it does not declare
|
||||
|
||||
**Files modified:** `modules/pier/store_redis.go`, `modules/pier/README.md`, `docs/services/mcp.md`
|
||||
**Commit:** 58408aa
|
||||
**Applied fix:** I took the documentation option. The store needs a standalone Redis. Redis Cluster is not supported, and a key-pattern ACL must allow the whole `<prefix>mcp:` range. This is stated in the script comment, the README `mcp.sessions.store` row and the docs config table.
|
||||
|
||||
### RA-IN-04: The non-reserver fallback is check-then-act and briefly exposes an unrecorded session
|
||||
|
||||
**Files modified:** `modules/pier/session.go`
|
||||
**Commit:** 034aa19
|
||||
**Applied fix:** This is partial. The fallback now calls `Put` right after the Count check and before the server is built. A failed connect or initialize deletes the record again. The session is never in `sr.local` without its record, so a reaper pass can no longer close it as expired. The existing `TestSessionReserve` fallback subtest passes.
|
||||
**Deferred residual:** the Count-then-Put cap is still racy. Closing it needs `Reserve` in the exported `pier.Store` interface, or a refusal at mount, which changes pier's exported API for a branch only a test wrapper reaches. Recorded in deferred-items.md (eea04b1).
|
||||
|
||||
### RA-IN-05: A backend token whose scopes no longer resolve gets "account unknown or deactivated"
|
||||
|
||||
**Files modified:** `modules/pier/backend_guard.go`, `modules/pier/dispatch.go`, `modules/pier/README.md`
|
||||
**Commit:** c0ce07e
|
||||
**Applied fix:**
|
||||
- **Sentinel.** The backend guard's `principal` now answers `errScopeUnavailable` when the token's stored scopes resolve to nothing. Before, it answered a nil principal.
|
||||
- **Dispatch.** It maps this to the fixed tool error "pier: the token's scopes no longer grant this route".
|
||||
- **Listing.** `MCPAllowsMethod` still treats it as a refusal, so the RA-WR-03 retry logic does not see it as a failed check.
|
||||
|
||||
No unit test: the path needs cabana's database-backed `BackendPrincipal`.
|
||||
|
||||
### RA-IN-06: demo_pins passes when check-pins.sh exits non-zero with no output
|
||||
|
||||
**Files modified:** `scripts/check-phase19.7.sh`
|
||||
**Commit:** 99f5ed4
|
||||
**Applied fix:** `demo_pins` counts the mismatch lines it accepts. It refuses when `check-pins.sh` fails without one.
|
||||
**Test:** new self-test `pins-silent-failure`, which plants a silent `exit 1` `check-pins.sh`.
|
||||
|
||||
## Deferred
|
||||
|
||||
- **RA-IN-04 residual:** the check-then-act cap of the non-reserving fallback. Fixing it is an exported `pier.Store` API change for a branch only tests reach.
|
||||
- **RA-WR-06 optional `git branch -r --contains` upstream check:** the gap-closure commits are deliberately unpushed until the release order runs, so this check would refuse every pre-release run. `PHASE197_RELEASED=1` after the tags is the release proof.
|
||||
|
||||
Both are appended to `.planning/phases/19.7-generic-mcp-module/deferred-items.md` in the docs commit eea04b1.
|
||||
|
||||
---
|
||||
|
||||
_Fixed: 2026-10-23_
|
||||
_Fixer: Claude (msd-code-fixer)_
|
||||
_Iteration: 1_
|
||||
|
||||
# Lane B
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Fix Report (re-review, Lane B)
|
||||
|
||||
**Fixed at:** 2026-10-23T18:39:41Z
|
||||
**Source review:** .planning/phases/19.7-generic-mcp-module/19.7-REREVIEW.md (section "# Lane B" only)
|
||||
**Iteration:** 1
|
||||
|
||||
**Summary:**
|
||||
- Findings in scope: 6 (RB-WR-01, RB-WR-02, RB-IN-01..04)
|
||||
- Fixed: 5 (RB-IN-03 counted as skipped: the code fix stays deferred; only its documentation half landed)
|
||||
- Skipped/deferred: 1 (RB-IN-03 code fix)
|
||||
|
||||
**Where verification ran:** in the main checkout (`workflow.use_worktrees: false`, so no worktree was created). Before every commit: `go vet ./...` and `go test -short ./...`. For admin changes also `npm --prefix admin run test` (101 files) and `npm --prefix admin run typecheck`. `scripts/check-admin-openapi.sh` regenerated the OpenAPI files for RB-IN-02, and `--check` exits 0. `go test ./cmd/summer -run TestDocsTree` passed after each doc change. `scripts/check-admin-dist.sh` matches after the dist commit 34dce1c.
|
||||
|
||||
## Fixed Issues
|
||||
|
||||
### RB-WR-01: The draft-commit blur does not reach an input inside a plugin field type's shadow root
|
||||
|
||||
**Files modified:** `admin/src/app/hotkeys.ts`, `admin/tests/app/hotkeysEditing.test.ts`
|
||||
**Commit:** 3afe9fa (dist: 34dce1c)
|
||||
**Applied fix:** Before clicking, the save shortcut now focuses the target button with `preventScroll`, as a pointer press does. This unfocuses an inner input in an open or a closed shadow root, so its blur and change handlers run. If the target takes no focus, the shortcut calls `blur()` on the deepest focused element instead: a private `deepestActiveElement` helper follows `shadowRoot.activeElement` through open roots. After the click, focus goes back to that element, unless the click moved focus somewhere other than the target or body.
|
||||
**Test:** `save shortcuts commit a draft inside a shadow root` (4 cases: Ctrl+S and Ctrl+Enter, open and closed root). The test field emits `summer-change` from the inner input's `change` event. All 4 cases fail on the previous code. happy-dom behaves like the spec and Firefox here: `blur()` on the host is a no-op.
|
||||
**Status:** fixed: requires human verification (focus and blur behaviour; it has only been checked in happy-dom, not in Firefox)
|
||||
|
||||
### RB-WR-02: A scope name is validated trimmed but registered untrimmed
|
||||
|
||||
**Files modified:** `modules/cabana/token_scopes.go`, `modules/cabana/token_scope_name_test.go`
|
||||
**Commit:** a5ce43f
|
||||
**Applied fix:** `validatePluginTokenScope` now checks `scope.Name` exactly as `compileTokenScopes` registers it, with `pact.ValidTokenScopeName`. A padded name now fails boot instead of being trimmed. This matches the pact rule, and the docs claim that "Both catalogs check names with `pact.ValidTokenScopeName`" now holds. The duplicate check uses the same key that is registered. No doc change was needed.
|
||||
**Test:** `TestTokenScopeNameParity` now also covers `" read"`, `"read "`, `"read\n"` and `"\tblog:read"`. On the old code it fails for all four.
|
||||
|
||||
### RB-IN-01: The SPA URL check passes `/<TAB>/host`
|
||||
|
||||
**Files modified:** `admin/src/components/account/AccountContributions.vue`, `admin/tests/account/AccountContributions.test.ts`
|
||||
**Commit:** 633d450 (dist: 34dce1c)
|
||||
**Applied fix:** `safeUrl` now refuses any ASCII control character (U+0000-U+001F, U+007F) first, as Go's `url.Parse` does on the server. An absolute http(s) URL must also parse with a host. With both changes the SPA and the server apply the same rule, as the comment says.
|
||||
**Test:** `a "<url>" URL answer renders no link and never opens a window`, for `/\t/evil.example/x`, `/\n/evil.example`, `/\r\n/evil.example`, `/x\u0000` and `https://`. All fail on the old code.
|
||||
|
||||
### RB-IN-02: An action whose Applies fails disappears with no signal
|
||||
|
||||
**Files modified:** `modules/cabana/account_contributions.go`, `modules/cabana/account_contributions_hardening_test.go`, `modules/cabana/admin_openapi.go`, `modules/cabana/README.md`, `docs/backend/users-and-permissions.md`, `admin/openapi/admin.json`, `admin/src/api/schema.d.ts`
|
||||
**Commit:** 81342f1
|
||||
**Applied fix:** When an action's `Applies` fails, the action is still dropped and `view.Error = true` is now set on its section. The SPA already shows the section error line next to a successful status. The field description of `AccountContributionView.Error`, the cabana README (feature entry and route table) and the My account docs are updated. The OpenAPI document and the schema types are regenerated; this was a description change only.
|
||||
**Test:** `TestAccountContributionsAppliesFailureFlagsSection` fails on the old code. `TestAccountContributionsIsolation` still passes.
|
||||
|
||||
### RB-IN-04: The custom-element-in-form rule also mutes Esc on focusable non-field widgets
|
||||
|
||||
**Files modified:** `admin/src/app/hotkeys.ts`
|
||||
**Commit:** 89b85f5 (dist: 34dce1c)
|
||||
**Applied fix:** The trade-off is now documented in the header comment and in the `isEditableTarget` doc comment. The optional narrowing to plugin field types was not done. With it, Esc would leave the form while the admin types into a `type: widget` element with an input in a closed root. This is recorded in deferred-items.md.
|
||||
|
||||
## Skipped Issues
|
||||
|
||||
### RB-IN-03: The CLI `admin:token:revoke` fires no revoke event
|
||||
|
||||
**File:** `modules/cabana/token_commands.go:225-255`
|
||||
**Reason:** The code fix stays deferred because it is not cheap. Calling `fireTokenRevoked` from the command would do nothing. The command runs in its own process, which does not mount pier, so no listener receives the event and nothing is published to the store a running server reads. Closing the gap needs the command to publish into pier's store directly, which is a seam across modules. The reviewer's alternative, documenting the gap, was applied in 4d7eb9d: the cabana README events entry and the command table now say that only the My account revoke fires the event, and that the CLI-revoked token's sessions end at its next verification. The existing deferred-items entry was updated in 0b0cae5.
|
||||
**Original issue:** The operator revoke command fires nothing, so the token's open sessions stay until the next bearer re-verification. The README did not say this applies to the HTTP route only.
|
||||
|
||||
---
|
||||
|
||||
_Fixed: 2026-10-23T18:39:41Z_
|
||||
_Fixer: Claude (msd-code-fixer)_
|
||||
_Iteration: 1_
|
||||
|
||||
# Lane C
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Fix Report (re-review, lane C)
|
||||
|
||||
**Fixed at:** 2026-10-23
|
||||
**Source review:** 19.7-REREVIEW.md, section "# Lane C" only (RC-CR-01, RC-WR-01..02, RC-IN-01..07)
|
||||
**Iteration:** 1
|
||||
|
||||
**Summary:**
|
||||
- Findings in scope: 10
|
||||
- Fixed (fully or in their cheap part): 8 (RC-CR-01, RC-WR-01, RC-WR-02, RC-IN-01, RC-IN-02, RC-IN-03, RC-IN-04, RC-IN-05), plus the cheap part of RC-IN-06
|
||||
- Deferred: RC-IN-06 (boot-order part), RC-IN-07 (release-time); also the optional parts of RC-CR-01 and RC-IN-01
|
||||
|
||||
Repositories: U = sm-user-plugin (sm-demo-app/plugins/golem15/user), O = sm-oauthserver-plugin, J = sm-journal-plugin, V = vue-demo-app, D = sm-demo-app, F = summercms.go.
|
||||
|
||||
Verification ran in the main checkouts (`workflow.use_worktrees: false`, no worktree created). Each repo's `go vet ./...` and `go test -short ./...` were green before every commit, and the Docker-backed tests of every changed package ran against Postgres (testcontainers). For each fix the new test was also run against the old code (stash, or a temporary mutation that was then restored) and failed there.
|
||||
|
||||
## Fixed Issues
|
||||
|
||||
### RC-CR-01: Self-service password change kept OAuth/MCP grants refreshed after the session's iat
|
||||
|
||||
**Status:** fixed: requires human verification (logic)
|
||||
**Commits:** U 30f7a01 (fix + README + test), O 5624e36 (test), O 95ccaec (README test line)
|
||||
**Applied fix:** `ChangePassword` fires `AccessRevokedEvent` with `Before = time.Now()` (the request instant). `tokens_valid_after` is still `iat - 1s`, so the calling session survives. The README now says that `Before` is the revocation instant for every reason, and that the self-service cutoff only keeps the calling session.
|
||||
**Tests:**
|
||||
- U `TestAccessRevocation` / "ChangePassword revokes as of the request and keeps the calling session". The session is crafted with an iat 20 minutes old; the test asserts Before >= request start, the stored cutoff equals iat-1s, and `/fetch` still works with the session. On the old code it fails ("Before ... is not the instant of the request").
|
||||
- O `TestMCPGrantRevocation` / "a password change ends a grant rotated after the session's iat". It goes through `POST /change-password` after the agent rotated its grant, then asserts all rows are revoked, the verifier refuses the rotated token, the rotated refresh is refused and the session works. On the old code it fails with "1 revoked, 3 live".
|
||||
|
||||
### RC-WR-01: backend grants could act as an administrator the consent did not show
|
||||
|
||||
**Status:** fixed: requires human verification (logic, concurrency)
|
||||
**Commits:**
|
||||
- F c37c6ce `fix(19.7): RC-WR-01 ...`. Adds `pact.MCPGrant.BackendUserID`. pier's `resolveOAuth` and `refreshBackend` (after a link event) create a backend subject only when the current link names that id. Zero means no backend subject (fail closed). The pact README, pier README and docs/services/mcp.md were updated in the same commit, and the docs checker passes.
|
||||
- O 105d263: migration `202610230001_add_golem15_oauthserver_backend_user_id` adds a nullable `backend_user_id` to the mcp_codes, access_tokens and refresh_tokens tables (no backfill: pre-migration backend grants stop acting as an admin until reconnected, as the README upgrade note says). Consent decide takes `backend_admin` (the shown login) and answers 409 `backend_link_changed` when it is not the admin linked now (moved, removed, or not named while linked). The linked admin id goes through `classes.WithConsentedBackend(ctx)` into `MarkIssued`. The code exchange and every rotation copy it onto the tokens, and the verifier returns it. `OnBackendLinkChanged` also deletes unexchanged backend MCP codes. `revokeUserGrants` takes per-user advisory locks (exclusive, ascending id); the code exchange and the refresh rotation take the same lock shared before their row lock, so a rotation in flight commits first and its successor gets revoked.
|
||||
- O b6a9586: `Mint`/`Create` fall back to the context's consented admin for direct minting.
|
||||
- V 3c53182 + D 054c15a (pointer bump): `/connect` sends `backend_admin` through the new `app/lib/consent.ts`. On a 409 it reloads the request and shows `connect.linkChanged` (en/pl).
|
||||
- D a6be849: the demo e2e mint helpers bind backend grants to the linked admin, and the consent helper names the shown admin.
|
||||
- J 521df9a: `TestJournalPromptWrites`'s fake grants now carry `BackendUserID`. The gate caught this: pier's fail-closed rule had broken the fixture.
|
||||
**Tests:**
|
||||
- F `TestToolsList` / "a backend grant acts only as the administrator it was consented for". Grants bound to admin 43, and to no admin, list no backend tool and cannot call it.
|
||||
- F `TestFanOut` / "link change". A relink to another admin drops the backend subject; relinking the consented admin restores it.
|
||||
- O `TestMCPBackendBinding`, 5 subtests: the decide 409 matrix; the binding travels code → exchange → rotation → verifier; direct mint honours the context; a link change deletes the backend codes so the exchange answers invalid_grant while a non-backend code still works; a revocation racing a rotation waits and revokes the successor. On the old code all four original subtests fail; the race subtest even hit "deadlock detected (SQLSTATE 40P01)". The direct-mint subtest fails without b6a9586.
|
||||
- D `TestMCPEndToEnd` / "a grant consented for another administrator has no backend tools".
|
||||
- V `app/lib/consent.test.ts` (5 tests).
|
||||
- `TestMCPConsentSmoke` was updated to send `backend_admin`.
|
||||
|
||||
### RC-WR-02: verifier ban refusal untested
|
||||
|
||||
**Status:** fixed
|
||||
**Commit:** O 89c9ec8
|
||||
**Applied fix:** the ban subtest now writes `user_throttle.is_banned` directly, checks that `tokens_valid_after` stays NULL, asserts both the verifier and the rotation refuse, and that unbanning restores both. A new subtest refuses the rotation of a token created before the cutoff and leaves its rows untouched. The doc comment and README were corrected.
|
||||
**Tests:** `TestMCPVerifierRevocation` / "a ban alone refuses the verifier and the rotation until unbanned" and "the refresh rotation refuses a token created before the cutoff". Mutation checks: removing the verifier ban check fails at line 152; removing only the rotation ban branch fails at line 154; removing the rotation cutoff check fails at line 170.
|
||||
|
||||
### RC-IN-01: link code accepted from the query string on POST routes
|
||||
|
||||
**Status:** fixed (the nginx part is deferred)
|
||||
**Commit:** U 92676ba
|
||||
**Applied fix:** new unexported `readBodyFields` (a JSON body or `r.PostForm`, never the query string), used by `BackendLinkShowPost` and `BackendLinkConfirm`. README updated.
|
||||
**Test:** `TestBackendLinkShowPost` / "a code in the query string is ignored". Show with `?code=` and no body, an empty JSON body or a form without the code gives 404; confirm with `?code=` gives 404; a form body still works. On the old code it fails ("= 200 ... want 404").
|
||||
|
||||
### RC-IN-02: the auth_time one-second blind spot
|
||||
|
||||
**Status:** fixed (documented, comparison unchanged as the design accepts it)
|
||||
**Commit:** U b929ba9. The doc comment on `ConfirmLinkRequest` and an inline note now state the blind spot and why it is accepted.
|
||||
|
||||
### RC-IN-03: logo and avatar URL fallback ignored the public path
|
||||
|
||||
**Status:** fixed
|
||||
**Commit:** U 9730110. `OrganisationLogoURL` and `AvatarURL` fall back to `f.URL()` (attach.PublicURL). README updated.
|
||||
**Tests:** `TestAvatarURL` (its assertion pinned the old behaviour and now asserts the public URL) and `TestOrganisationLogo` (new failing-bucket check). Both fail on the old code ("/fac/... want /storage/uploads/fac/..."). `TestAvatarURL` was added to the gate's USER_TESTS.
|
||||
|
||||
### RC-IN-04: nginx /mcp cap equal to pier's
|
||||
|
||||
**Status:** fixed
|
||||
**Commit:** D 40ed518. `client_max_body_size 5m;` on `location = /mcp`; `scripts/check-deploy.sh` requires the new value. `check-deploy.sh` passes, and it refuses the old config.
|
||||
|
||||
### RC-IN-05: test gaps
|
||||
|
||||
**Status:** fixed
|
||||
**Commits:**
|
||||
- U ebe408f: `TestOrganisationLogo` asserts the blobs exist before the delete and that all keys under both partition directories (originals and thumbnails) are gone after the commit. A mutation (DeleteKeys disabled) fails ("blobs left after the delete"). The listed U Postgres tests now call `t.Skip("Postgres")` under -short.
|
||||
- O 9813c1d: the same `t.Skip` change in `mcp_revocation_test.go`.
|
||||
- D 09c3d31: the same change in `TestMCPRevocationEndToEnd`.
|
||||
- V 9c247ab + D 036919c (pointer bump): `linkCode.test.ts` pins `#code=<code>&next=/x` returning the code (the re-review's ruling) and documents it in `readLinkCode`.
|
||||
|
||||
### RC-IN-06 (cheap part): MintAPIToken deprecation
|
||||
|
||||
**Status:** partially fixed; the boot-order part is deferred
|
||||
**Commit:** U 9892404. `MintAPIToken` is marked `Deprecated:` in favour of `MintAPITokenFor`, and the README says so. No internal caller is left; consuming apps still compile.
|
||||
|
||||
### Gate
|
||||
|
||||
F f824d93 `test(19.7)` adds `TestMCPBackendBinding` to OAS_TESTS and `TestAvatarURL` to USER_TESTS.
|
||||
|
||||
## Skipped Issues
|
||||
|
||||
### RC-IN-06 (boot-order part): fallback widened before the phrase-key check
|
||||
|
||||
**File:** `U classes/api_token_scopes.go:125`, `U plugin.go:127-146`
|
||||
**Reason:** deferred. Moving the add after the check needs either a new exported seam or a behaviour change to the exported `CompileAPITokenScopes` in a core plugin. A failed boot ends the process, so the widened set is never used in production.
|
||||
**Original issue:** `CompileAPITokenScopes` widens the process-wide MintAPIToken fallback before boot checks the phrase keys.
|
||||
|
||||
### RC-IN-07: oauthserver builds only through go.work
|
||||
|
||||
**File:** `O go.mod:6`
|
||||
**Reason:** deferred as a release-time item, per instructions. The requires were not bumped. The O release checklist must bump sm-user-plugin to the new U tag and pass `GOWORK=off go build ./...`.
|
||||
**Original issue:** O uses U APIs that v0.1.10 lacks.
|
||||
|
||||
### Optional parts deferred
|
||||
|
||||
- RC-CR-01 optional: base the session cutoff on `auth_time`, and have `/refresh` and the jwt guard compare it with the cutoff. This changes session revocation in a core plugin and bouncer, and the gap predates the phase.
|
||||
- RC-IN-01 optional: nginx `access_log off` (or a log_format without `$request_uri`) for `/_user/api/v1/backend-link/` until the deprecated GET route goes in a major release. This is a demo deploy change.
|
||||
|
||||
All deferrals are recorded in F deferred-items.md (4d5a09a, 1fe553e). That file also marks the earlier `readLinkCode` entry resolved, and records that the demo's oauthserver working-tree checkout moved from 671513d to the canonical b6a9586 (detached, fast-forward, pointer uncommitted). The demo e2e tests need that checkout, because pier now requires the recorded consented admin.
|
||||
|
||||
## Gate tail (bash scripts/check-phase19.7.sh --all, exit 0)
|
||||
|
||||
```
|
||||
PASS go
|
||||
PASS plugins
|
||||
PASS consumers
|
||||
PASS admin
|
||||
PASS docs
|
||||
PASS marker
|
||||
PASS docker
|
||||
Phase 19.7 gate passed WITH UNRELEASED PINS: the release pins are not yet proven (plugins/golem15/journal plugins/golem15/oauthserver plugins/golem15/user)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
_Fixed: 2026-10-23_
|
||||
_Fixer: Claude (msd-code-fixer)_
|
||||
_Iteration: 1_
|
||||
538
.planning/phases/19.7-generic-mcp-module/19.7-REREVIEW.md
Normal file
538
.planning/phases/19.7-generic-mcp-module/19.7-REREVIEW.md
Normal file
@@ -0,0 +1,538 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
reviewed: 2026-10-23
|
||||
depth: deep
|
||||
kind: re-review of the gap closure (plans 06-09)
|
||||
lanes: [A framework MCP core, B cabana and admin SPA, C plugins and demo]
|
||||
files_reviewed: 129
|
||||
findings:
|
||||
critical: 1
|
||||
warning: 10
|
||||
info: 17
|
||||
total: 28
|
||||
status: issues_found
|
||||
---
|
||||
|
||||
# Phase 19.7 re-review of the gap closure
|
||||
|
||||
This re-reviews the changes made by gap-closure plans 06-09, after the first deep review in `19.7-REVIEW.md`. That file is left unchanged because the plans and security documents cite its finding ids. Three deep lanes ran in parallel over: the framework since fef1cbb, sm-user-plugin since 32f9259^, sm-oauthserver-plugin since 671513d^, sm-journal-plugin since b129902^, vue-demo-app since 0125e29^ and sm-demo-app since 00f57bf^. Finding ids carry the lane prefix (RA-, RB-, RC-). Each lane also rules on every earlier critical and warning finding of its lane ("Earlier findings").
|
||||
|
||||
| Lane | Critical | Warning | Info | Earlier findings not fully closed |
|
||||
|------|----------|---------|------|-----------------------------------|
|
||||
| A framework MCP core | 0 | 6 | 6 | A-WR-07 partial; A-WR-04 and A-WR-06 fixed with regressions |
|
||||
| B cabana and admin SPA | 0 | 2 | 4 | B-WR-02 partial |
|
||||
| C plugins and demo | 1 | 2 | 7 | C-CR-01 partial, C-WR-02 partial |
|
||||
|
||||
|
||||
# Lane A
|
||||
|
||||
|
||||
## Phase 19.7 (lane A re-review): Code Review Report
|
||||
|
||||
**Reviewed:** 2026-10-23
|
||||
**Depth:** deep
|
||||
**Files Reviewed:** 45
|
||||
**Status:** issues_found
|
||||
|
||||
## Summary
|
||||
|
||||
I re-reviewed lane A's gap-closure changes (`git diff fef1cbb..HEAD`) and the code they touch: the session reaper, the atomic per-binding reservation (memory and Redis Lua), the lock-scope rework, fingerprint-based widening, the stateless listen re-check and eviction close, the Redis warm-up, the narrowed revocation events, the dispatch hardening, the catalog boot checks, bouncer's `auth_time`, towel's client address and the gate script. I traced the calls into go-sdk v1.8.0 (`Server.Sessions`, `changeAndNotify`/`notifySessions`), into cabana (`fireTokenRevoked`, `ResolveBackendToken`, `BackendPrincipal`) and into the publishers of `pact.MCPSubjectChanged` in the OAuth server and user plugins. `go vet -tags summercms_mcp` on pier, surf and bouncer is clean. `go test -race -short ./modules/pier` passes.
|
||||
|
||||
Every earlier lane-A critical and warning has a fix in the code, not only in the plans. The reaper closes expired local copies and logs `expired`. Reserve is atomic in both stores. Path values are cleaned and required. Raw dispatch errors are logged, not returned. Personal tokens without `TokenID` are refused. The Redis store is warmed at mount. Eviction closes the evicted server's sessions. I found no identity or guard bypass. Widening adds tools to a cached server, but the receiving middleware still filters every list and call for the requesting identity, so no request gains reach it does not have. Revocations narrowed by `TokenID` and `ClientID` match the events cabana and the plugins publish. The `ClientID == ""` condition stops an admin-token revoke from also ending an OAuth session that acts as the same admin.
|
||||
|
||||
The new defects are in the concurrency and caching that the fixes introduced:
|
||||
|
||||
- **A-WR-07 is only partly fixed.** Event fan-out still takes each per-session lock while it holds the router-wide lock. Widening and recomputing hold that per-session lock across guard I/O, and widening runs with no deadline. One slow check plus any event still stalls the instance.
|
||||
- **The fingerprint includes the OAuth access-token id.** Every token rotation re-filters the session. A stateless server shared by two live tokens of one binding flips its tool set on every request, which races calls into "unknown tool" errors.
|
||||
- **A transient guard error during widening removes tools from a live session** and records the new fingerprint, so the tools stay gone until the next rotation or event.
|
||||
- **Capacity eviction now closes live listen streams and in-flight calls.** With more concurrent bindings than the LRU capacity, the stateless path keeps forcing clients to reconnect.
|
||||
- **Prompt `Render` errors still reach the client raw** (the same class as A-WR-08).
|
||||
- **The gate passes with demo submodules ahead of their go.mod pins** by non-test commits unless `PHASE197_RELEASED=1`. The final "gate passed" line gives no caveat.
|
||||
|
||||
## Earlier findings
|
||||
|
||||
| Id | Verdict | Evidence |
|
||||
|----|---------|----------|
|
||||
| A-CR-01 | fixed | `modules/pier/pier.go:143-148` starts `reap`. `modules/pier/session.go:483-531`: `reapOnce` snapshots `sr.local`, calls `store.Get` for each entry, then `closeLocal` and logs `expired`. A store error keeps the copy. `reapInterval` (`:535-537`) is between 1 s and 1 min. The memory store's `Get` honours expiry (`store_memory.go:44-53`). The Redis path relies on PX TTLs. `reaper_test.go` covers both stores. The reaper ctx is never cancelled in production (no shutdown hook, documented at `pier.go:63-67`). |
|
||||
| A-WR-01 | fixed | `modules/pier/dispatch.go:119-128` refuses empty, `.` and `..` segments in every path value, and `/` in a single-segment value. Wildcard values are escaped per segment (`:376-383`). |
|
||||
| A-WR-02 | fixed | Boot: `modules/pier/catalog.go:220-224` refuses a path field that is not in `schema.Required`. Runtime: `dispatch.go:142-148` refuses a missing path value. |
|
||||
| A-WR-03 | fixed | `modules/pier/session.go:143-173` reserves before connecting and releases on a failed connect or initialize. The memory `Reserve` counts and writes under `m.mu` (`store_memory.go:101-117`). The Redis `reserveScript` prunes, counts, SETs and SADDs in one EVAL (`store_redis.go:144-182`). `lazyStore.Reserve` forwards to it (`:326-339`). The non-reserver fallback (`session.go:156-166`, `:187-193`) is still check-then-act, but only a test-wrapped store reaches it (RA-IN-04). |
|
||||
| A-WR-04 | fixed, with regressions | `modules/pier/events.go:131-141` (`widen`) is called from `session.go:332-335` and `stateless.go:185-190`. The fingerprint is `identity.go:85-116`. The new defects are RA-WR-02 and RA-WR-03. |
|
||||
| A-WR-05 | fixed | `modules/pier/pier.go:146-148` runs `ls.warm` at mount with a backoff (`store_redis.go:279-294`). `route` kicks the open on every request (`stateless.go:248-250`). `open` subscribes with `context.Background()` (`pier.go:178`). |
|
||||
| A-WR-06 | fixed, with a regression | The listen re-check is at `modules/pier/stateless.go:98-123`. Capacity eviction closes the evicted server's sessions (`:151-167`). The new defect is RA-WR-04. |
|
||||
| A-WR-07 | partially fixed | `connect` now runs without `sr.mu` (`session.go:174-186`, `:308-331`), and the stateless build runs without `sp.mu` (`stateless.go:137-150`). But `matchingFunc` still locks each `ls.mu`/`e.mu` while holding `sr.mu`/`sp.mu` (`events.go:190-203`, `stateless.go:205-218`), and `widen`/`recomputeSession` hold `ls.mu` across guard I/O (`session.go:332-335`, `events.go:98-109`, `:138`). See RA-WR-01. |
|
||||
| A-WR-08 | fixed (dispatch) | `modules/pier/dispatch.go:179-189` logs the cause and returns a fixed text. Only `ErrMCPTokenInvalid` and `errSubjectUnavailable` (`backend_guard.go:73-86`) get specific texts. The prompt path still returns raw errors (RA-WR-05). |
|
||||
| A-WR-09 | fixed | `modules/pier/identity.go:267-272` refuses `TokenID == 0`. The contract is documented at `pact/mcp.go:241-249`. |
|
||||
|
||||
## Warnings
|
||||
|
||||
### RA-WR-01: Event fan-out still nests per-session locks under the router-wide lock, while those locks are held across guard I/O with no deadline (A-WR-07 not closed)
|
||||
|
||||
**File:** `modules/pier/events.go:190-203`, `:98-109`, `:131-141`; `modules/pier/stateless.go:205-218`, `:185-190`, `:171-181`; `modules/pier/session.go:295-297`, `:332-335`
|
||||
**Issue:** The fix moved `connect` out of `sr.mu`, but it did not change the lock order. `sessionRouter.matchingFunc` takes `sr.mu` and then each `ls.mu` in turn. `statelessPath.matchingFunc` does the same with `sp.mu` and `e.mu`. Meanwhile:
|
||||
- `lookup` holds `ls.mu` across `widen`, which calls `catalog.allowed` (database-backed `MCPAllows`/`MCPAllowsMethod`).
|
||||
- `recomputeSession` and `recomputeStateless` hold `ls.mu`/`e.mu` across `refreshBackend` (the link resolver) and `catalog.allowed`.
|
||||
- `widen` uses `context.WithoutCancel(ctx)`, which removes the request's deadline as well as its cancellation. `recomputeSession` uses `context.Background()`.
|
||||
|
||||
**Failure scenario:**
|
||||
1. Session S's request widens after a token rotation (the fingerprint changed, see RA-WR-02), or an event is recomputing S, while the database is slow.
|
||||
2. A second event arrives. The memory store runs every event on its own goroutine (`store_memory.go:127-135`), so two events in flight at once is normal: one role change fires one event per user.
|
||||
3. That event's `matchingFunc` holds `sr.mu` and blocks on `S.ls.mu`.
|
||||
4. Every stateful request on the instance now blocks: `lookup` at `session.go:295`, `serveNew` at `:184`, `closeLocal`, the reaper and the `connect` goroutine. The stateless path behaves the same way through `sp.mu` and `hit()`.
|
||||
5. The guard check has no deadline. If the database waits on an exhausted pool, the stall lasts until a connection frees. The endpoint is down instance-wide.
|
||||
|
||||
`TestLockScope` only blocks an initialize, which no longer holds a lock. It never combines a blocked `widen` or recompute with an event, so it does not cover this path.
|
||||
**Fix:** Never wait on a per-session lock while holding the router lock. Snapshot the entries under `sr.mu`, release it, then evaluate the match:
|
||||
```go
|
||||
func (sr *sessionRouter) matchingFunc(match func(Identity) bool) []*localSession {
|
||||
sr.mu.Lock()
|
||||
all := make([]*localSession, 0, len(sr.local))
|
||||
for _, ls := range sr.local {
|
||||
all = append(all, ls)
|
||||
}
|
||||
sr.mu.Unlock()
|
||||
var out []*localSession
|
||||
for _, ls := range all {
|
||||
ls.mu.Lock()
|
||||
hit := match(ls.identity)
|
||||
ls.mu.Unlock()
|
||||
if hit {
|
||||
out = append(out, ls)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
```
|
||||
Do the same in `statelessPath.matchingFunc`. Alternatively, keep `identity` behind its own small mutex or an `atomic.Pointer[Identity]` that is never held across I/O. Also give `widen` and the recomputes a bounded context, for example `context.WithTimeout(context.WithoutCancel(ctx), d.cfg.CallTimeout)`. Extend `TestLockScope` with a guard that blocks inside `widen`, plus a concurrent `MCPSubjectChanged`, and assert that another session's call still finishes.
|
||||
|
||||
### RA-WR-02: The fingerprint includes the OAuth access-token id, so a shared stateless server flips its tool set between two live tokens of one binding
|
||||
|
||||
**File:** `modules/pier/identity.go:85-116` (`TokenID` at `:103`), `:216-233`; `modules/pier/stateless.go:128-136`, `:185-190`; `modules/pier/events.go:131-141`
|
||||
**Issue:** For an OAuth identity, `Frontend.TokenID` and `Backend.TokenID` hold `grant.TokenID`, the access-token row id (`sm-oauthserver-plugin/classes/mcp_verifier.go:110`). It changes with every refresh. The stateless LRU keeps one server per binding (`oauth:<client>:<user>`), and every request runs `refresh` → `widen` with that request's identity. When two different tokens of the same binding are live at once, the fingerprint differs on every alternate request. Two cases are common:
|
||||
- The same static client signed in on two devices.
|
||||
- After a re-consent with wider scopes, an older narrower token is still valid on another device.
|
||||
|
||||
Each flip runs `catalog.allowed` (guard I/O) under `e.mu` (feeding RA-WR-01). When the scopes differ, `applyDiff` adds and then removes the write tools on every alternation.
|
||||
**Failure scenario:** Token A (`read write`) calls `create_post`. The receiving middleware checks A's own allowed set and passes the call. Meanwhile a request with token B (`read`) runs `widen` on the same server and calls `RemoveTools("create_post")`. The SDK's tools/call handler then answers "unknown tool" for A's legitimate call. Every flip also queues a `list_changed` notification for every listen stream of the binding. Before the gap closure the tool set was frozen. Now it flaps.
|
||||
**Fix:**
|
||||
- Leave token ids out of the fingerprint. The guard decision depends on scopes, subjects and the ceiling, not on which token row carried them.
|
||||
- Key the stateless LRU by `binding + "|" + fingerprint`, as the earlier review suggested, so identities with different reach never share or mutate one server.
|
||||
- At minimum, never remove tools in `widen` on the stateless path: the receiving middleware already filters down per request.
|
||||
|
||||
### RA-WR-03: A transient guard error during widening permanently narrows a live session
|
||||
|
||||
**File:** `modules/pier/events.go:131-141`; `modules/pier/filter.go:33-47`, `:49-64`
|
||||
**Issue:** `catalog.allowed` turns a provider error into "not allowed" (logged). `widen` then runs `applyDiff`, which removes every tool or prompt whose check errored, and stores the new fingerprint. Later requests with the same fingerprint skip `widen`. The receiving middleware can only filter down, so the removed tools cannot come back. They stay hidden until the fingerprint changes again or a subject event recomputes the session. Server construction already had a weaker form of this, but it ran once. Because of RA-WR-02, widening now runs on every OAuth token rotation.
|
||||
**Failure scenario:** A pool timeout during the widen at a token rotation hides every backend tool of a long-running agent session for a whole access-token lifetime. Calls to those tools fail as "not available to this caller" although nothing changed.
|
||||
**Fix:** Let `widen` tell an error apart from a refusal. For example, add an `allowedStrict` that returns an error, and on error leave the server untouched and leave `*fp` unchanged, so the next request retries:
|
||||
```go
|
||||
tools, prompts, err := p.catalog.allowedStrict(bounded, id)
|
||||
if err != nil {
|
||||
logger().Warn("pier: widening deferred", "error", err)
|
||||
return // keep *fp, retry on the next request
|
||||
}
|
||||
applyDiff(...)
|
||||
*fp = next
|
||||
```
|
||||
|
||||
### RA-WR-04: LRU capacity eviction now ends live listen streams and in-flight calls, so the stateless path churns past capacity
|
||||
|
||||
**File:** `modules/pier/stateless.go:151-167`, `:192-197`, `:55-62`
|
||||
**Issue:** A `subscriptions/listen` POST calls `getServer` once, when it starts. A quiet listener never touches its entry again, so the entry drifts to the back of the LRU (capacity `max_per_binding * 16`, 320 by default). The A-WR-06 fix makes eviction call `closeSessions` on the evicted server. That ends the listen stream, and it also ends any in-flight tools/call of that binding: the per-request `ServerSession` is in `srv.Sessions()`, and closing its connection cancels the dispatched route's context mid-handler.
|
||||
**Failure scenario:** More than 320 distinct bindings are connected with listen streams. Each new binding's first request evicts the oldest listener. That client reconnects and evicts the next one, and so on. Every stream keeps reconnecting, list changes sent during the gaps are lost, and a write tool call caught by an eviction is cancelled partway, so the agent gets an error for a request whose effect may or may not have committed.
|
||||
**Fix:**
|
||||
- Do not count entries with an open listen stream as evictable. For example, keep a per-entry count of active listens, raised in `ServeHTTP` around `sp.handler.ServeHTTP` for listen requests, and skip such entries when evicting.
|
||||
- Or move such an entry to the front on every bearer re-check tick.
|
||||
- Or leave the streams open on eviction (the 1-minute bearer re-check already bounds them). Then a revocation must also close the streams it can no longer find, for example through a binding-to-streams index that eviction does not clear.
|
||||
- Never close the sessions of a request that is still being served.
|
||||
|
||||
### RA-WR-05: Prompt `Render` errors are returned to the MCP client verbatim
|
||||
|
||||
**File:** `modules/pier/session.go:719-722`
|
||||
**Issue:** `promptHandler` returns `pr.decl.Render`'s error as is. The SDK turns it into the JSON-RPC error message. A plugin's `Render` that reads the database (to list drafts, look up a record or build context) can then send pgx or gorm text, which may include the host, database and user names, to the outside client and its transcript. This is the leak A-WR-08 closed for dispatch, left open for prompts.
|
||||
**Fix:**
|
||||
```go
|
||||
messages, err := pr.decl.Render(ctx, args)
|
||||
if err != nil {
|
||||
logger().Warn("pier: prompt render failed", "prompt", pr.name, "error", err)
|
||||
return nil, &jsonrpc.Error{Code: jsonrpc.CodeInternalError, Message: "pier: the prompt could not be rendered"}
|
||||
}
|
||||
```
|
||||
|
||||
### RA-WR-06: The gate passes while demo submodules carry non-test commits that the go.mod pins do not ship
|
||||
|
||||
**File:** `scripts/check-phase19.7.sh:957-961`, `:977-982`, `:1158-1170`
|
||||
**Issue:** `demo_pins` now accepts a submodule that is ahead of its pin by non-test commits whenever the canonical checkout's HEAD contains them. It fails only with `PHASE197_RELEASED=1`, and the default is 0. The demo's own `check-pins.sh` exists to prevent exactly this: "they must be the same code, or the tests pass against something that is not shipped". With the default, the consumers stage runs the demo's builds and tests against the submodule code, while a release build (GOWORK=off) compiles the older pinned version. `run_all` still prints "Phase 19.7 gate passed". The acceptance is reported only as a mid-stage `pins:` line. The canonical check also accepts any commit on whatever branch the canonical checkout is on, pushed or not.
|
||||
**Failure scenario:** The phase is marked verified on "gate passed". Then the demo is tagged and deployed with the old pins, without the gap-closure plugin fixes the tests exercised.
|
||||
**Fix:**
|
||||
- Make the release check fail closed by default: require an explicit `PHASE197_ALLOW_UNRELEASED=1` to accept unreleased drift.
|
||||
- When drift was accepted, end `run_all` with a non-pass verdict, for example `Phase 19.7 gate passed WITH UNRELEASED PINS (not releasable)`, and a distinct exit code.
|
||||
- Optionally require that the commit exists on the canonical checkout's upstream (`git branch -r --contains`).
|
||||
|
||||
## Info
|
||||
|
||||
### RA-IN-01: `lazyStore`'s doc comment says nothing dials at mount
|
||||
|
||||
**File:** `modules/pier/store_redis.go:231-233`
|
||||
**Issue:** The comment still says "nothing dials at mount (route:list and tests never dial)". `Mount` now starts `warm`, which dials Redis in the background (`pier.go:146-148`). If a CLI command mounts pier while Redis is unreachable, it also logs "session store not open yet, retrying".
|
||||
**Fix:** Reword the comment to match `Mount`'s and decide whether non-serving commands should skip `warm`.
|
||||
|
||||
### RA-IN-02: Stream re-checks resolve the bearer without the client address
|
||||
|
||||
**File:** `modules/pier/session.go:438`; `modules/pier/stateless.go:114`
|
||||
**Issue:** The bearer middleware puts `towel.WithClientIP` on the resolver context (`pier.go:254`), but the GET-stream and listen re-check goroutines call `identities.resolve(ctx, raw)` on a context without it. A re-check that fails, for example a revoked admin token, is logged by `cabana.ResolveBackendToken` with an empty remote. That is the case B-IN-04 set out to make traceable.
|
||||
**Fix:** Capture `p.clientIP(r)` when the stream starts and resolve with `towel.WithClientIP(ctx, ip)`.
|
||||
|
||||
### RA-IN-03: `reserveScript` touches keys it does not declare
|
||||
|
||||
**File:** `modules/pier/store_redis.go:144-160`
|
||||
**Issue:** The script runs `EXISTS` on `ARGV[1] .. m` for every set member, so it touches keys missing from `KEYS`. A standalone `redis.Client` accepts this. Redis Cluster refuses it (cross-slot), and so do ACLs restricted by key pattern (undeclared keys). The binding set and the record key would not hash to one slot anyway.
|
||||
**Fix:** Document that the store needs a standalone Redis, or put a hash tag on the binding in both key names (`mcp:{<binding>}:...`) and keep the per-member keys in the same slot.
|
||||
|
||||
### RA-IN-04: The non-reserver fallback in `serveNew` is still check-then-act and briefly exposes an unrecorded session
|
||||
|
||||
**File:** `modules/pier/session.go:156-166`, `:184-193`
|
||||
**Issue:** Both shipped stores (and `lazyStore`) implement `reserver`, so only a test wrapper (`WrapStore`) reaches this branch. On it, the cap is TOCTOU, and the session sits in `sr.local` before its record is written, so a reaper pass in between closes it as expired.
|
||||
**Fix:** Make `reserver` part of `Store`, or delete the fallback and refuse a store without `Reserve` at mount.
|
||||
|
||||
### RA-IN-05: A backend token whose scopes no longer resolve gets "account unknown or deactivated"
|
||||
|
||||
**File:** `modules/pier/backend_guard.go:99-103`, `:79-86`; `modules/pier/dispatch.go:184-185`
|
||||
**Issue:** `principal` returns `nil, nil` when `ScopeLimitFor` reports `known == 0`, for example when a scope's plugin was removed. `MCPDispatch` then answers `errSubjectUnavailable`, and the agent reads that the administrator's account is unknown or deactivated, which is false.
|
||||
**Fix:** Return a distinct sentinel, for example `errScopeUnavailable` with "the token's scopes no longer grant this route", and map it in `dispatch.go`.
|
||||
|
||||
### RA-IN-06: `demo_pins` passes when `check-pins.sh` exits non-zero with no output
|
||||
|
||||
**File:** `scripts/check-phase19.7.sh:962-990`
|
||||
**Issue:** With `rc != 0` and empty output, the here-string feeds one empty line, `[[ -z "$line" ]] && continue` skips it, and the function returns 0. The current `check-pins.sh` prints a line on every failure path, so this is unlikely, but the check fails open.
|
||||
**Fix:** After the loop, refuse unless at least one mismatch line was matched and accepted: track `accepted=1` inside the branch, and `[[ -n "$accepted" ]] || { echo "refuse: check-pins failed without a mismatch line" >&2; return 1; }`.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
|
||||
# Lane B
|
||||
|
||||
|
||||
## Phase 19.7 (lane B re-review): Code Review Report
|
||||
|
||||
**Reviewed:** 2026-10-23T19:30:00Z
|
||||
**Depth:** deep
|
||||
**Files Reviewed:** 24
|
||||
**Status:** issues_found
|
||||
|
||||
## Summary
|
||||
|
||||
This re-review covers the lane B gap-closure changes between fef1cbb and HEAD (commits 9eedfbb, 24cf6cd, 44835e4, 88559d5 and the plan 09 tests). I re-read the code each fix touches and the code it calls:
|
||||
- the pier event path: `listenEvents`, `handleEvent`, `revokedMatch`, and how identities are resolved in `identity.go`;
|
||||
- `lagoon.AfterCommit` with no transaction;
|
||||
- `towel.ClientIP` with a nil ctx;
|
||||
- `revokeAPIToken`, `normalizeTokenScopes` (api_tokens.go:135-160);
|
||||
- `FormView`'s `<form>` wrapper and save button `disabled` conditions;
|
||||
- `PluginField`'s `summer-change` protocol;
|
||||
- every i18n key the SPA component uses, in en, pl and the fixture.
|
||||
|
||||
Verified correct:
|
||||
- **Token revoke event.** `fireTokenRevoked` is called with `row.ID`. The pier `Event` keeps `TokenID` through the store (`token_id` json tag). `revokedMatch` matches only subjects with `TokenID == ev.TokenID && ClientID == ""`. An OAuth backend subject always has `ClientID` set (identity.go:227-233), so OAuth sessions survive. The revoke route has no transaction, so `AfterCommit` fires at once, which is correct.
|
||||
- **URL rule (server).** `safeAccountActionURL` refuses `javascript:`, `data:`, `vbscript:`, `//host`, `/\host`, `https:host` and `http:/host`, plus a leading space or tab/newline, because Go's `url.Parse` rejects control characters. I confirmed this by running the function.
|
||||
- **Per-section isolation.** A failing Status sets `error` (`omitempty`, so this only adds data). A failing Applies drops only that action. The SPA toasts on a failed GET and keeps the sections already shown.
|
||||
- **OpenAPI.** `scripts/check-admin-openapi.sh --check` exits 0, and `scripts/check-admin-dist.sh` reports that the dist matches.
|
||||
- **Phrase keys.** `form.action_prompt_invalid`, `myaccount.action_confirm`, `myaccount.action_stale` and `myaccount.section_error` sit under the right YAML sections in en and pl and are in the fixture.
|
||||
- **Logging.** `ResolveBackendToken` logs the remote address on all seven paths, and pier puts the address on the context (pier.go:254).
|
||||
- **Frontend scope seam.** cabana never reads `HasFrontendTokenScopes` (grep).
|
||||
- **No raw HTML.** `AccountContributions.vue` has no `v-html` and uses text interpolation only.
|
||||
- **Checks run.** `go vet`, the targeted cabana `-short` tests, pact and pier `-short`, `TestDocsTree`, the two vitest files and `vue-tsc` all pass.
|
||||
|
||||
No blockers. Two warnings:
|
||||
- The draft-commit fix for keyboard saves does not reach a focused input inside a plugin field type's shadow root.
|
||||
- The "one shared name rule" for token scopes is not actually one rule in cabana, because cabana trims the name before checking it and then registers the untrimmed name.
|
||||
|
||||
## Earlier findings
|
||||
|
||||
| ID | Verdict | Evidence |
|
||||
|----|---------|----------|
|
||||
| B-WR-01 | fixed | `admin/src/app/hotkeys.ts:121-124` (`originOf` uses `composedPath()[0]`), `:241` (used in `onPlainKey`), `:113` (a custom element inside `form`/`[role=form]` counts as editable for closed roots; FormView wraps fields in `<form>` at `views/FormView.vue:658`). Tests: `admin/tests/app/hotkeysEditing.test.ts:71-129`. |
|
||||
| B-WR-02 | partially fixed | `admin/src/app/hotkeys.ts:227-233` blurs `doc.activeElement` before `click()`. This covers light-DOM fields (the taglist; tests at `hotkeysEditing.test.ts:131-181`). When focus is inside a shadow root, `doc.activeElement` is the shadow host, and `host.blur()` does not unfocus the inner input (see RB-WR-01). |
|
||||
| B-WR-03 | fixed | Server: `modules/cabana/account_contributions.go:217-221`, `:233-242`. SPA: `admin/src/components/account/AccountContributions.vue:31-39`, `:64-68`, `:128-135`. The SPA check has a defense-in-depth gap the server covers (RB-IN-01). |
|
||||
| B-WR-04 | fixed | `modules/cabana/account_tokens.go:167` calls `fireTokenRevoked(..., principal.ID, row.ID)`. `modules/cabana/subject_events.go:51-65` puts `TokenID` on the event. `modules/pier/events.go:21`, `:79-93` narrow the match to that token. Test: `modules/cabana/account_token_events_test.go:20-61` (Postgres). |
|
||||
| B-WR-05 | fixed | `modules/cabana/admin_openapi.go:802`, `:812`, `:831-832`. Regenerated into `admin/src/api/schema.d.ts:3033`, `:5586`. `check-admin-openapi.sh --check` exits 0. |
|
||||
| B-WR-06 | fixed (one residual gap, RB-IN-02) | `modules/cabana/account_contributions.go:113-138` (error flag on the section, failing action dropped). `AccountContributions.vue:41-53` (toast on a failed GET), `:125-127` (section error line). Tests: `account_contributions_hardening_test.go:137-188`, `AccountContributions.test.ts` "a 500 on the list reload". |
|
||||
|
||||
Info items from the first review:
|
||||
- **Fixed:** B-IN-01 (`AccountContributions.vue:74`, `:100`), B-IN-02 (`actions.go:249`, `:269`), B-IN-03 (`account_contributions.go:121`), B-IN-04 (`token_resolver.go:29`).
|
||||
- **Deferred:** B-IN-05 (deferred-items.md:177).
|
||||
- **Accepted:** B-IN-06, with the visible link as the fallback.
|
||||
|
||||
## Narrative Findings (AI reviewer)
|
||||
|
||||
## Warnings
|
||||
|
||||
### RB-WR-01: The draft-commit blur does not reach an input inside a plugin field type's shadow root (B-WR-02 residual)
|
||||
|
||||
**File:** `admin/src/app/hotkeys.ts:227-233`
|
||||
**Issue:** The fix blurs `doc.activeElement`. When focus is on an `<input>` inside a shadow root (the plugin field types and widgets that `modules/cabana/README.md:185` explicitly allows), `document.activeElement` is the shadow host, not the input. Calling `blur()` on a host that is not itself focused does nothing in two places:
|
||||
- **The HTML spec.** The unfocusing steps return early when the target is not in the current focus chain. The only exception is a host with `delegatesFocus`.
|
||||
- **Firefox.** `ShouldBlur` compares the element with the focused descendant, which is the inner input.
|
||||
|
||||
Chromium happens to blur here, because `AdjustedFocusedElementInTreeScope() == this`. The behaviour therefore differs by browser.
|
||||
|
||||
`PluginField.vue:13-24` defines the value protocol as a `summer-change` event. A plugin that emits it from the inner input's native `change` event (fires on blur) still loses the typed value in Firefox:
|
||||
- **Ctrl+S** saves without it.
|
||||
- **Ctrl+Enter** saves without it and navigates away.
|
||||
|
||||
This is exactly the "plugin field type that commits on the native change event" case B-WR-02 named. The host's `focus()` afterwards is also a no-op for a non-focusable host, so focus is lost.
|
||||
|
||||
The new tests cover only the light-DOM taglist (`hotkeysEditing.test.ts:131-181`).
|
||||
|
||||
**Fix:** do what a pointer click does: focus the button before clicking it. Moving focus works in every browser and for closed roots too, because the inner input is unfocused and its blur/change fire.
|
||||
```ts
|
||||
// The deepest focused element reachable through open shadow roots.
|
||||
let previous: Element | null = doc.activeElement
|
||||
while (previous?.shadowRoot?.activeElement) {
|
||||
previous = previous.shadowRoot.activeElement
|
||||
}
|
||||
const restore = previous instanceof HTMLElement && previous !== target && previous !== doc.body ? previous : null
|
||||
// Pointer-equivalent: mousedown focuses the button, which blurs whatever had
|
||||
// focus, shadow-root inputs included (blur() on the host does not).
|
||||
if (restore) {
|
||||
target.focus({ preventScroll: true })
|
||||
}
|
||||
target.click()
|
||||
if (restore?.isConnected) {
|
||||
restore.focus()
|
||||
}
|
||||
```
|
||||
At minimum, descend `shadowRoot.activeElement` for open roots before calling `blur()`. Add a test with an open-shadow-root input whose `change` handler emits `summer-change`.
|
||||
|
||||
### RB-WR-02: A scope name is validated trimmed but registered untrimmed, so the shared name rule is not one rule
|
||||
|
||||
**File:** `modules/cabana/token_scopes.go:106-118` (validation), `:89-98` (registration); `modules/cabana/api_tokens.go:146-152`
|
||||
**Issue:** `validatePluginTokenScope` validates `strings.TrimSpace(scope.Name)` with `pact.ValidTokenScopeName`. `compileTokenScopes` then stores `scope.Name` untrimmed, both in `compiledTokenScope.Name` and as the `byName` key. With a padded name such as `" blog:read"` or `"blog:read\n"`, three things go wrong:
|
||||
- **Boot accepts it.** `pact.ValidTokenScopeName(" blog:read")` is false, so the parity this gap closure claims (P-30) does not hold. The docs say "Both catalogs check names with `pact.ValidTokenScopeName`" (`docs/backend/users-and-permissions.md:119`), and the `HasFrontendTokenScopes` doc promises that a bad name fails boot.
|
||||
- **The scope is listed but can never be granted.** It appears in `GET /account/tokens/scopes` under its padded name. Token creation trims every requested name (api_tokens.go:147), looks it up as `byName["blog:read"]`, misses, and answers `scope_unavailable`.
|
||||
- **The duplicate check depends on order.** The check looks up the trimmed name. If `" read"` registers first and `"read"` second, the second is not detected as a duplicate, and both register.
|
||||
|
||||
`TestTokenScopeNameParity` (token_scope_name_test.go:12-44) has no padded names, so it does not catch any of this. The pre-existing trim mismatch matters now because this change is what turns `ValidTokenScopeName` into the advertised single rule.
|
||||
|
||||
**Fix:** validate exactly what is registered. Either refuse a name that is not already trimmed:
|
||||
```go
|
||||
name := scope.Name
|
||||
if name == "" || name != strings.TrimSpace(name) || !pact.ValidTokenScopeName(name) {
|
||||
return fmt.Errorf("cabana: plugin %s registered invalid token scope name %q", pluginID, scope.Name)
|
||||
}
|
||||
```
|
||||
or register the trimmed `name` (`Name: name`, `cat.byName[name]`). Add `" read"` and `"read\n"` to the parity table, expecting refusal.
|
||||
|
||||
## Info
|
||||
|
||||
### RB-IN-01: The SPA URL check passes `/<TAB>/host`, which browsers resolve off-site
|
||||
|
||||
**File:** `admin/src/components/account/AccountContributions.vue:31-39`
|
||||
**Issue:** `safeUrl` accepts any string that starts with one `/` and not `//` or `/\`. Browsers strip ASCII tab and newline from URLs, so `"/\t/evil.example/x"` and `"/\n/evil.example"` resolve to `https://evil.example/...` (confirmed with WHATWG `URL`). This is the same-origin bypass the check exists to stop.
|
||||
|
||||
The server check catches it, because Go's `url.Parse` rejects control characters, so this is a defense-in-depth gap only. The server and SPA rules are also documented as "the same rule" (`:27-29`), which they are not.
|
||||
|
||||
**Fix:** strip or refuse control characters first, e.g. `if (/[\u0000-\u001f\u007f]/.test(u)) return ''`. Or resolve with `new URL(u, location.origin)` and require `protocol` http(s) and, for relative input, `origin === location.origin`.
|
||||
|
||||
### RB-IN-02: An action whose Applies fails disappears with no signal
|
||||
|
||||
**File:** `modules/cabana/account_contributions.go:128-135`; `AccountContributions.vue:125-127`
|
||||
**Issue:** A Status failure sets `error: true` and shows the section error line. An Applies failure only drops the button. If the section's Status still succeeds, the admin sees a normal section (for example "Linked to …") with its Unlink button missing and no message. That is the "fails silently" half of B-WR-06 again, for a single action.
|
||||
**Fix:** set `view.Error = true` when any action's Applies fails as well (and document `error` as "status or an action could not be loaded"), so the SPA shows the section error line.
|
||||
|
||||
### RB-IN-03: The CLI `admin:token:revoke` fires no revoke event
|
||||
|
||||
**File:** `modules/cabana/token_commands.go:225-255` (interacts with `account_tokens.go:167`)
|
||||
**Issue:** The My account revoke now ends that token's MCP sessions. The operator revoke command fires nothing, so the token's open sessions (and any open GET listen stream) stay until the next request's bearer re-verification refuses them. The README entry for backend subject events says a revoked personal API token fires the event, without saying this applies to the HTTP route only.
|
||||
**Fix:** call `fireTokenRevoked(ctx, app, row.BackendUserID, row.ID)` after the update when the command runs with the application bus. Otherwise, document that only the My account revoke fires.
|
||||
|
||||
### RB-IN-04: The custom-element-in-form rule also mutes Esc on focusable non-field widgets
|
||||
|
||||
**File:** `admin/src/app/hotkeys.ts:113`
|
||||
**Issue:** Any focused element with a hyphenated tag inside a `<form>` counts as editable. That includes `WidgetField` hosts (`components/form/fields/WidgetField.vue:61`) that are focusable but not inputs, such as a chart or a button strip. While one of them has focus, Esc does not leave the form. This is an accepted trade-off for closed roots, but it is undocumented.
|
||||
**Fix:** mention it in the header comment at `hotkeys.ts:15-25`. Optionally narrow the rule to hosts rendered by `PluginField` (for example via a `data-field-type` attribute the SPA sets on plugin field elements).
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23T19:30:00Z_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
|
||||
# Lane C
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Report (lane C re-review: plugins and demo)
|
||||
|
||||
**Reviewed:** 2026-10-23T17:19:01Z
|
||||
**Depth:** deep
|
||||
**Files Reviewed:** 60
|
||||
**Status:** issues_found
|
||||
|
||||
Abbreviations: **U** = sm-user-plugin (`sm-demo-app/plugins/golem15/user`, range 32f9259^..HEAD), **O** = sm-oauthserver-plugin (671513d^..HEAD), **J** = sm-journal-plugin (b129902^..HEAD), **V** = vue-demo-app (0125e29^..HEAD), **D** = sm-demo-app (00f57bf^..HEAD), **F** = summercms.go (framework, read for call chains only).
|
||||
|
||||
Checks run: `go vet ./...` and `go test -short ./...` in U (with `GOWORK=off`, the module's own `replace` to the framework), O and J are green. With `GOWORK=off`, O does not build (see RC-IN-07). Docker-backed tests were not run.
|
||||
|
||||
## Summary
|
||||
|
||||
Most of the gap closure holds up when traced through the code:
|
||||
|
||||
- **Account link proof (C-CR-02).** The confirm handler reads `auth_time` again from the same token `jwt.auth` accepted, checks that its subject matches the authenticated principal, and refuses a token that has no `auth_time`. `bouncer.Refresh` copies `auth_time` unchanged (F `bouncer/refresh.go:141-142`). The plugin's only mint sites (`mintFor`: login, registration, activate-by-code) are real sign-ins. No path in U mints a frontend token without one.
|
||||
- **Link code transport (C-WR-01).** The code lives only in the fragment. The admin SPA opens the link with `window.open(url, '_blank', 'noopener')`, so the Referer is the admin page and never carries the code. Browsers never put a fragment in a Referer. The page moves the code to `sessionStorage`, strips it with `replaceState`, and sends `/login?next=/link-admin` without it.
|
||||
- **Ban, password reset and admin-set password (C-CR-01).** Each one revokes OAuth grants in the same transaction as the user write. The MCP verifier and the MCP refresh grant also refuse banned users and tokens issued before the cutoff, so the event is not the only protection.
|
||||
- **Revocation scoping (C-IN-02).** A token-specific revoke and a client-specific revoke each end only their own sessions. Pier tells the two apart by `ClientID == ""` (F `pier/events.go:85-98`), so a `usr_` token id that equals an OAuth token id does not collide.
|
||||
- **Journal (C-IN-01).** The `draft_post` ceiling is enforced by pier's `allowsPrompt`. `TestJournalPromptWrites` would catch a regression because it checks both the read-only and the read-write grant.
|
||||
- **Member token scopes (E-2).** Mint, check, list and discovery work per application. A plugin cannot gain backend reach by naming a member scope `backend`, because pier grants a backend subject only on the OAuth path.
|
||||
- **Organisation logo (E-1).** The admin delete path (single and bulk) goes through cabana's `deleteRecord`, which runs `FormAfterDelete` inside the delete transaction.
|
||||
|
||||
What remains:
|
||||
|
||||
1. **RC-CR-01 (critical).** A user's own password change does not end an attacker's MCP or OIDC grant if that grant's tokens were created or rotated after the current session's `iat`. An attacker controls rotation timing, so the C-CR-01 scenario ("the owner changes the password after a compromise") still leaves the attacker's agent working, including any linked-admin backend reach.
|
||||
2. **RC-WR-01.** C-WR-02 is closed for issued tokens only. A consent decided after the link changed, or an MCP code issued before the change and exchanged after it, still produces a `backend` grant for an administrator the consent page never showed. The token revocation also races with a concurrent refresh rotation.
|
||||
3. **RC-WR-02.** The oauthserver test for the verifier's ban refusal cannot fail. `BanUsers` also moves `tokens_valid_after`, so the cutoff check alone makes the token invalid.
|
||||
|
||||
## Narrative Findings (AI reviewer)
|
||||
|
||||
## Critical Issues
|
||||
|
||||
### RC-CR-01: Self-service password change keeps every OAuth/MCP grant whose tokens were created or rotated after the session's `iat`
|
||||
|
||||
**File:** `U controllers/api_controller.go:722-732`; `O classes/cascade.go:111-113` (`created_at < before`); `O classes/mcp_store.go:252-266` (a rotated refresh token is a new row with `created_at = now`) and `:385-391` (the new access token, the same); `O classes/mcp_verifier.go:133-144` (`issuedBeforeCutoff`); `U README.md:57`; `U access_revocation_test.go:156-170`
|
||||
|
||||
**Issue:** `ChangePassword` sets `tokens_valid_after = iat - 1s` and fires `FireAccessRevoked(..., before = cutoff + 1s = iat, ...)`. Here `iat` belongs to the session token that made the call. A refresh renews `iat`, so it is the time of the last refresh, not of the sign-in. The README sentence "tokens issued since that sign-in survive" is wrong on this point too.
|
||||
|
||||
`revokeUserGrants` revokes only access and refresh rows with `created_at < before`. The MCP refresh grant creates a new refresh row and a new access row with `created_at = now` on every rotation. The verifier's `issuedBeforeCutoff` and `refreshUserUsable` compare that same `created_at` with the cutoff. So any grant that was refreshed after the caller's `iat`:
|
||||
- is not revoked by the event,
|
||||
- passes the verifier, and
|
||||
- passes the refresh check,
|
||||
|
||||
and lives on indefinitely. The client chooses when to refresh: an OAuth client may present its refresh token at any time. An attacker's agent that refreshes every minute is therefore never older than the victim's session unless that session was minted within the last minute.
|
||||
|
||||
The ban, the password reset and the admin-set password all pass `before = time.Now()` and are not affected. Only the self-service change uses the session-relative cutoff, although nothing in the current request needs an OAuth grant kept alive.
|
||||
|
||||
**Failure scenario:** An attacker learns E's password, signs in, connects an MCP agent with `read write backend` (E is linked to admin A) and lets it refresh every few minutes. E notices odd posts, opens the site (session last refreshed 20 minutes ago) and changes the password from Settings. `AccessRevokedEvent` fires with `Before = iat` (20 minutes ago). The agent's current refresh token, created 3 minutes ago, is not revoked, and the verifier accepts it because `created_at` is after the cutoff. The agent keeps calling `journal_update_post` as admin A. `TestAccessRevocation` "ChangePassword fires with the stored cutoff plus one second" pins this behaviour instead of catching it.
|
||||
|
||||
For context: the same session-relative cutoff lets an attacker's frontend session JWT survive if it was refreshed after the victim's `iat`. That part predates this phase, but `auth_time` now makes a better cutoff possible.
|
||||
|
||||
**Fix:** Revoke OAuth grants as of now on a self-service change. The current request needs no OAuth grant, so nothing has to be kept:
|
||||
```go
|
||||
// U controllers/api_controller.go, ChangePassword
|
||||
cutoff := iat.Add(-time.Second) // keeps the calling session JWT, as today
|
||||
revokedAt := time.Now()
|
||||
if err := lagoon.Transaction(r.Context(), gdb, func(ctx context.Context, tx *gorm.DB) error {
|
||||
// ... Updates as today ...
|
||||
return classes.FireAccessRevoked(ctx, app, tx, []uint{user.ID}, revokedAt, classes.AccessRevokedPasswordChanged)
|
||||
}); err != nil { ... }
|
||||
```
|
||||
Change the README sentence on line 57 to match. Rewrite the test to create an MCP grant, rotate it after the session's `iat`, change the password, and assert that the rotated grant is revoked and refused. Optionally, base the session cutoff on the calling token's `auth_time`, and have `/refresh` and the jwt guard compare `auth_time` with `tokens_valid_after`, so an attacker's refreshed session JWT also stops surviving.
|
||||
|
||||
## Warnings
|
||||
|
||||
### RC-WR-01: C-WR-02 is closed for issued tokens only: pending consents and unexchanged codes still bind `backend` to whichever administrator is linked later, and the revocation races with refresh rotation
|
||||
|
||||
**File:** `O classes/cascade.go:136-138` (with a non-empty `scope`, the function returns before touching `MCPCode` rows), `:198-216` (`OnBackendLinkChanged`), `:111-134` (plain `SELECT`, then `UPDATE ... WHERE id IN`); `O controllers/mcp_consent_api.go:82-89` (show reads the admin), `:133-144` (decide checks only `linked`, not which admin); `F pier/identity.go:225-235` (backend subject = whoever is linked at request time)
|
||||
|
||||
**Issue:** The fix revokes unrevoked access and refresh tokens that carry `backend` when a link is created or removed. Three paths still let a grant act as an administrator the consent page did not show:
|
||||
1. **Decide after a link change.** `MCPConsentShow` shows admin X. `MCPConsentDecide` checks only that some link exists (`linked`). If the link moves to Y between show and decide (an administrator's `SetLink` after an unlink, within the pending request's lifetime), the user approves "act as X" and gets a `backend` grant that pier resolves to Y.
|
||||
2. **Code issued before, exchanged after.** `revokeUserGrants` with `scope = "backend"` returns at line 136-138 and never deletes the user's unused MCP codes. A code issued while linked to X and exchanged after a relink to Y mints a fresh token (`created_at` after the revocation) with `backend`, acting as Y.
|
||||
3. **Rotation race.** The revocation reads candidate rows with a plain `SELECT` under READ COMMITTED, then updates them by id. If a refresh rotation of the same grant is in flight, the `UPDATE` waits on the old row's lock. Once the rotation commits, the new refresh row (inserted after the `SELECT`'s snapshot) is never revoked and keeps `backend` across the link change.
|
||||
|
||||
The README now promises that "a grant never acts as an administrator the user did not consent to". These paths contradict it. Each window is short, so this is a warning.
|
||||
|
||||
**Fix:** Bind the grant to the consented administrator, so no revocation timing matters (this was option 2 of C-WR-02 and is additive):
|
||||
- At decide, take the `backend_admin.login` (or id) the page showed in the body and refuse with 409 when the current link differs.
|
||||
- Store `backend_user_id` on the MCP code, access and refresh rows. Copy it on code exchange and rotation, expose it in `pact.MCPGrant`, and have pier drop the backend subject when the current link's admin id differs.
|
||||
|
||||
As a cheaper stopgap: in `OnBackendLinkChanged` also delete the user's MCP codes with `used_at IS NULL` whose scopes contain `backend`, and lock the user's refresh rows (`SELECT ... FOR UPDATE` on `user_id`) before collecting ids, so a concurrent rotation is serialized behind the revocation.
|
||||
|
||||
### RC-WR-02: The verifier's ban refusal is untested; the "banned user is refused" test passes even with the ban check removed
|
||||
|
||||
**File:** `O mcp_revocation_test.go:138-160`; code under test `O classes/mcp_verifier.go:96-105`, `O classes/mcp_store.go:299-313` (`refreshUserUsable` ban branch)
|
||||
|
||||
**Issue:** The subtest bans with `userclasses.BanUsers`, which calls `RevokeUserAccess` and stamps `tokens_valid_after = now`. The grant was created before that, so the `issuedBeforeCutoff` check already returns `ErrMCPTokenInvalid` and the refresh is already refused. Deleting the `ThrottleStates` and `banned[...]` blocks from both the verifier and `refreshUserUsable` leaves the test green.
|
||||
|
||||
The ban check is the only protection when a ban is written without `RevokeUserAccess`, which the user README explicitly allows applications to do ("after writing a ban directly to `user_throttle`"). The refresh path's pre-cutoff branch has no isolated rotation test either. The suite covers rotation only for a deleted user, while the doc comment of `TestMCPVerifierRevocation` claims "the refresh rotation refuses a banned, a pre-cutoff and a deleted user". The demo's e2e step (a) cannot tell the three mechanisms apart either.
|
||||
|
||||
**Fix:** In the ban subtest, write the ban without moving the cutoff, then assert both refusals:
|
||||
```go
|
||||
if err := env.gdb.Exec(`INSERT INTO user_throttle (user_id, is_banned) VALUES (?, TRUE)`, user.ID).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
invalid(t, "banned (no cutoff moved)", grant)
|
||||
status, out := env.refreshStatus(t, grant)
|
||||
refused(t, "banned (no cutoff moved)", status, out)
|
||||
```
|
||||
Add a rotation subtest for a pre-cutoff refresh token (`setGrantCreated` before `setCutoff`, then `refreshStatus` must be `invalid_grant`). The "same second" subtest only partly covers this.
|
||||
|
||||
## Info
|
||||
|
||||
### RC-IN-01: The server still accepts the link code in URLs
|
||||
|
||||
**File:** `U routes.go:46-48`; `U controllers/backend_link_controller.go:36-54, 111-117`; `U controllers/api_controller.go:1166-1189` (`readFields`); `D deploy/nginx/demo.summercms.io.conf:96-103`
|
||||
**Issue:** The shipped page never puts the code in a URL. The server, though, still serves the deprecated `GET /backend-link/{code}`, kept on purpose for compatibility. In addition, `readFields` falls back to `r.ParseForm()` for any non-JSON body, and `r.Form` includes the query string. So `POST /backend-link/show?code=…` and `POST /backend-link/confirm?code=…` both work, and nginx's default access log records those request lines. A third-party client of this core plugin can reintroduce the leak without noticing.
|
||||
**Fix:** In `BackendLinkShowPost` and `BackendLinkConfirm`, read the code only from a JSON body (ignore `r.URL.Query()`). Consider `access_log off;` (or a `log_format` without `$request_uri`) for `location ~ ^/_user/api/v1/backend-link/` until the GET route is removed in a major release.
|
||||
|
||||
### RC-IN-02: The `auth_time` proof has a one-second blind spot
|
||||
|
||||
**File:** `U classes/backend_links.go:276`
|
||||
**Issue:** `auth_time` is truncated to whole seconds and compared with `created_at` truncated to the same second. A sign-in that happened earlier in the same second as the request, but before it, counts as fresh. The design accepts this, and it is not exploitable in practice. It is worth stating in the doc comment next to the D-05 claim.
|
||||
**Fix:** Document it, or compare `auth_time >= created_at.Truncate(time.Second) + 1s` and accept that a sign-in in the request's own second needs one more sign-in.
|
||||
|
||||
### RC-IN-03: The logo URL fallback ignores the configured public path
|
||||
|
||||
**File:** `U classes/organisation_logo.go:57-61` (copied from `U classes/avatar.go:52-56`)
|
||||
**Issue:** When `Thumb` fails, the fallback is `"/" + attach.BlobKey(f.DiskName)`. That skips `storage.uploads.public_path_prefix` and `public_url` (`F lagoon/attach/thumb.go:85-104`). With the WinterCMS layout (`/storage/app/uploads/public`) the fallback URL is a 404.
|
||||
**Fix:** `return f.URL(), true, nil` (and the same in `AvatarURL`).
|
||||
|
||||
### RC-IN-04: nginx's `/mcp` cap now equals pier's, so oversized bodies still get nginx's HTML 413
|
||||
|
||||
**File:** `D deploy/nginx/demo.summercms.io.conf:217`; `F pier/pier.go:38`
|
||||
**Issue:** Both caps are 4 MiB. Bodies between 2 and 4 MiB now reach pier (C-IN-03 is fixed). A body over 4 MiB is still refused by nginx with an HTML 413, so the JSON-RPC error the new comment describes is never seen through nginx.
|
||||
**Fix:** Set `client_max_body_size 5m;` (and update the `check-deploy.sh` string), so pier's own refusal is the one clients get.
|
||||
|
||||
### RC-IN-05: Test gaps and tests that pass without running
|
||||
|
||||
**File:** `U organisation_logo_test.go:138-142`; `V app/lib/linkCode.test.ts:13-21`; the new `U` Postgres tests (`backend_link_auth_time_test.go:25-27`, `backend_link_show_test.go:24-26`, `access_revocation_test.go:113-115`, `member_token_scopes_test.go:64-66`, `organisation_logo_test.go:58-60`, `api_token_events_test.go:17-19`, `mcp_guard_client_ip_test.go:17-19`), `O mcp_revocation_test.go:65-67, 184-186`, `D mcp_revocation_e2e_test.go:247-249`
|
||||
**Issue:**
|
||||
- The organisation delete test checks only that the `system_files` rows are gone. The after-commit `attach.DeleteKeys` part of `FormAfterDelete` (the blobs and thumbnails) is never asserted, so a broken bucket hand-off would pass.
|
||||
- In `linkCode.test.ts`, the case `#next=/account&code=${code}x` sits under "foreign", but it returns `''` because of the trailing `x`. The behaviour the plan asked about (a valid code followed by other parameters) is not pinned at all.
|
||||
- The Postgres tests use `if testing.Short() { return }` instead of `t.Skip`, so `-short` runs report them as passed rather than skipped.
|
||||
**Fix:** After the delete, wait for the commit and assert that `bucket.Exists(ctx, attach.BlobKey(logoDisk))` is false. Add `expect(readLinkCode('#code=' + code + '&next=/x')).toBe(code)`. Use `t.Skip("Postgres")`.
|
||||
|
||||
### RC-IN-06: The legacy `MintAPIToken` fallback is process-global and is widened even when boot fails
|
||||
|
||||
**File:** `U classes/api_token_scopes.go:125, 144-166`; `U plugin.go:127-146`
|
||||
**Issue:** `CompileAPITokenScopes` adds every declared name to the process-wide `declaredScopes` set before `bootAPITokenScopes` checks the phrase keys. A boot that then fails on a missing key has already widened what `MintAPIToken` accepts. In a process with several applications (tests, or a future multi-app host), `MintAPIToken` also accepts another application's scopes. Both are documented, and production runs one app per process.
|
||||
**Fix:** Add the names only after the phrase check passes (return the declared list from `CompileAPITokenScopes` and add it in `bootAPITokenScopes` just before `app.Publish`). Mark `MintAPIToken` as `Deprecated:` in favour of `MintAPITokenFor`.
|
||||
|
||||
### RC-IN-07: sm-oauthserver-plugin builds only through its workspace file
|
||||
|
||||
**File:** `O go.mod:6` (`sm-user-plugin v0.1.10`); `O go.work` (tracked, `replace ... => ../sm-demo-app/plugins/golem15/user`)
|
||||
**Issue:** O now uses `userclasses.AccessRevokedEvent`, `FireSubjectEvent` and `FireSubjectEventAfterCommit`, which v0.1.10 does not have. `GOWORK=off go build ./...` fails with `undefined: userclasses.AccessRevokedEvent`. The planned release order (tag U, then bump O) covers this, but nothing enforces it.
|
||||
**Fix:** Make the O release checklist require bumping `sm-user-plugin` to the new U tag and running a `GOWORK=off go build ./...` gate before tagging O.
|
||||
|
||||
## Ruling: `readLinkCode` with other fragment parameters
|
||||
|
||||
`readLinkCode('#code=<64 hex>&next=/x')` returns the code. **This is not a defect.** `URLSearchParams.get('code')` returns the first `code` parameter, and the value still has to match `^[a-f0-9]{64}$` exactly, so nothing beyond a well-formed code is ever accepted. Other parameters are ignored, the fragment is stripped right away by `replaceState` (`V link-admin.vue:55`), and the code is only ever sent in a JSON body. Accepting extra parameters is the more robust behaviour: an analytics tool or a redirect that appends a fragment parameter does not break the link. The plan's expectation of an empty result was wrong. The one gap is that no test pins the behaviour (RC-IN-05).
|
||||
|
||||
## Earlier findings
|
||||
|
||||
| ID | Verdict | Evidence |
|
||||
|----|---------|----------|
|
||||
| C-CR-01 (ban / password reset keep MCP grants) | partially fixed | Fixed for ban (`U controllers/users_admin_controller.go:651-683`), reset (`U controllers/api_controller.go:454-466`) and admin-set password (`U controllers/users_admin_controller.go:247-255`). The verifier refuses banned users and pre-cutoff tokens (`O classes/mcp_verifier.go:96-105`), and so does the refresh grant (`O classes/mcp_store.go:281-313`). `LinkedBackendUser` excludes banned users (`U classes/backend_links.go:437-443`). Not fixed for the self-service password change: `U controllers/api_controller.go:722-732` revokes only grants older than the session's `iat` (RC-CR-01). |
|
||||
| C-CR-02 (fresh-sign-in proof defeated by refresh) | fixed | `U controllers/backend_link_controller.go:102-110` reads `auth_time` again from the accepted token and checks the subject; `U classes/backend_links.go:276` compares it with `created_at`; `F bouncer/refresh.go:141-142` carries `auth_time` forward; the page shows the signed-in email with "Not you?" (`V link-admin.vue:150-155`). One-second blind spot only (RC-IN-02). |
|
||||
| C-WR-01 (link code in logged URLs) | fixed | URL is `…#code=` (`U account_contributions.go:120`); the page reads the hash, stores the code in `sessionStorage` and strips it (`V link-admin.vue:50-60`); show is a POST with a JSON body (`V link-admin.vue:89`, `U routes.go:48`); the sign-in link carries no code (`V link-admin.vue:24`). The server still accepts the code in URLs (deprecated GET route, query fallback in `readFields`): RC-IN-01. |
|
||||
| C-WR-02 (`backend` grant re-targeted by a later link) | partially fixed | Issued access and refresh tokens carrying `backend` are revoked on link and unlink (`O classes/cascade.go:173-216`, `O plugin.go:103-105`). Pending consents, unexchanged MCP codes and a refresh rotation racing the revocation still bind `backend` to a later admin (RC-WR-01). |
|
||||
| C-IN-01 (draft_post for read-only grants) | fixed | `J mcp.go:160-162` `Writes: true`; enforced by `F pier/filter.go:52`; `J mcp_prompt_writes_test.go` checks both grants. |
|
||||
| C-IN-02 (one revoke ends every MCP session) | fixed | `U controllers/api_tokens.go:142` (TokenID); `O controllers/authorizations.go:122-126` (ClientID); `F pier/events.go:85-98` tells the two apart. |
|
||||
| C-IN-03 (nginx 2 MiB < pier 4 MiB) | fixed | `D deploy/nginx/demo.summercms.io.conf:217`, gated by `D scripts/check-deploy.sh:254-256`. Over-cap bodies still get the HTML 413 (RC-IN-04). |
|
||||
| C-IN-04 (no `last_used_ip` on MCP personal tokens) | fixed | `U classes/mcp_guard.go:172-176`; pier sets the client IP (`F pier/pier.go:254`). |
|
||||
| C-IN-05 (dead and duplicated code) | fixed | `requestUsable` calls `IsUsableAt` (`U classes/backend_links.go:227-235`); `BackendLinksFor` is used by both callers (`U classes/backend_links.go:57-64`, `U account_contributions.go:57-59`, `U controllers/backend_link_controller.go:16-18`); O's subject helpers delegate to U (`O classes/subject_events.go:18-26`). |
|
||||
| C-IN-06 (hard-coded link page path) | fixed | `golem15.user.backend_links.page_path` (`U classes/backend_links.go:85-104`, `U config/config.yaml:48-52`), tested in `U backend_link_show_test.go:94-109`. |
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23T17:19:01Z_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
@@ -553,22 +553,26 @@ Permissions [VERIFIED: sm-journal-plugin/controllers/api/auth.go:26-30]: `permAc
|
||||
| A8 | Granting `backend` only when a link exists at consent time (and dropping it otherwise) is acceptable UX | Security Domain | A later link would need re-consent (step-up) |
|
||||
| A9 | Per-call binary growth of ~2.9 MiB is acceptable if pier is always linked | Open Question 2 | Every app grows even with pier disabled |
|
||||
|
||||
## Open Questions
|
||||
## Open Questions (RESOLVED)
|
||||
|
||||
All eight questions were resolved at plan confirmation on 2026-10-21 and recorded in 19.7-CONTEXT.md § "Decisions after research" (D-32..D-35; D-36 records the agreed plan split). Each question below ends with its resolution.
|
||||
|
||||
1. **Stateful-only (D-25) vs hybrid with the 2026-07-28 stateless protocol.**
|
||||
- What we know: the current spec removed sessions; the SDK serves 2026-07-28 only statelessly; SDK clients fall back to 2025-11-25 against a stateful server (probe).
|
||||
- What's unclear: whether the user wants pier to also answer 2026-07-28 clients (stateless dispatch per request, `subscriptions/listen` for push), which is additive to D-25's stateful path.
|
||||
- Recommendation: ship D-25 as locked; design the identity/dispatch/filter layers so a stateless handler can reuse them; raise it at plan confirmation. Do not silently adopt the hybrid.
|
||||
- **RESOLVED (D-32):** hybrid adopted. pier also answers 2026-07-28 clients through a stateless path next to the stateful one, sharing identity, dispatch and per-principal filtering; push for stateless clients uses `subscriptions/listen`.
|
||||
2. **Always link pier, or behind a build tag?**
|
||||
- What we know: linking the SDK costs ~2.9 MiB stripped; the framework already has the opt-in build-tag pattern (`summercms_s3`: `s3_on.go //go:build summercms_s3`, `s3_off.go //go:build !summercms_s3`, `summer.yaml build.tags`) [VERIFIED: modules/lagoon/attach/s3_on.go:1, s3_off.go:1, bucket.go:27-28].
|
||||
- What's unclear: SC-1 says "enables the module in config"; a tag adds a build step.
|
||||
- Recommendation: ask the user; if always linked, keep all plugin-facing types SDK-free anyway (they must be, for the tag option to remain open).
|
||||
3. **D-04 "backend Users screen" does not exist.** cabana mounts no backend-users controller; admins come from `admin:create`/`admin:reset-password` commands [VERIFIED: modules/cabana/http.go:247-330, commands.go:21,45]. 19.6's Reset 2FA uses the user plugin's **own** Users screen (`AdminRecordActions` + a published `TwoFactorAdmin` slot), not a generic cabana seam (19.6-01-PLAN :49, :270), so there is nothing to reuse beyond that pattern. Recommendation: My Profile gets the generic cabana seam (D-04 part 1); admin set/remove goes on the sm-user-plugin **frontend** Users screen as a record action "Remove backend link" (Danger, `Applies` only when linked, permission) plus a way to set it (a form field with `DropdownOptions` of backend admins, or an `AdminAction` widget), and/or a `user:link-backend` console command. Needs user confirmation.
|
||||
4. **Frontend permission semantics** (Pitfall 3): mirror the route (group grants) — recommended — or change `user.permission` to `MergedPermissions` (behaviour change in a core plugin).
|
||||
5. **Session binding granularity** (A3): `(client_id, user_id)` vs token hash.
|
||||
6. **`ai` scope**: ignore for tools (recommended) or require it for some tool class.
|
||||
7. **MCP consent surface.** wristband sends the browser to `{issuer}/connect?request=` [VERIFIED: modules/wristband/authorize.go:174 — `spa := s.opts.Issuer + "/connect?request=" + rfc3986Escape(requestID)`]. Recommendation: sm-oauthserver-plugin adds JSON consent endpoints for the MCP server (show/decide, `jwt.auth`, mirroring fonoteka's `ConsentShow`/`ConsentStore` contract) that include the linked admin's display name when `backend` is requested; vue-demo-app adds `/connect` and the link-proof page. The demo's nginx does not route `/oauth` or `/.well-known` to Go yet (sm-demo-app/DEPLOY.md:34), so the deploy plan must add `/mcp`, `/.well-known/oauth-protected-resource*`, `/.well-known/oauth-authorization-server` and `/oauth/mcp/*`.
|
||||
8. **Permission code spelling.** Existing backend codes are `golem15.users.*` (`golem15.users.access_users`, `…access_groups`, `…access_settings`, `…impersonate_user`, `…manage_privileged_groups` [VERIFIED: fonoteka.go/plugins/golem15/user/admin_permissions.go:17-41]); 19.6 adds `golem15.users.reset_two_factor`. Recommend `golem15.users.manage_backend_links` (CONTEXT's example `golem15.user.…` would break the pattern).
|
||||
- **RESOLVED (D-33):** build tag. pier compiles in only with `summercms_mcp` in `summer.yaml` `build.tags`; without the tag the binary carries no go-sdk; `mcp.enabled` still defaults to off; `pact` types stay SDK-free.
|
||||
3. **D-04 "backend Users screen" does not exist.** cabana mounts no backend-users controller; admins come from `admin:create`/`admin:reset-password` commands [VERIFIED: modules/cabana/http.go:247-330, commands.go:21,45]. 19.6's Reset 2FA uses the user plugin's **own** Users screen (`AdminRecordActions` + a published `TwoFactorAdmin` slot), not a generic cabana seam (19.6-01-PLAN :49, :270), so there is nothing to reuse beyond that pattern. Recommendation: My Profile gets the generic cabana seam (D-04 part 1); admin set/remove goes on the sm-user-plugin **frontend** Users screen as a record action "Remove backend link" (Danger, `Applies` only when linked, permission) plus a way to set it (a form field with `DropdownOptions` of backend admins, or an `AdminAction` widget), and/or a `user:link-backend` console command. Needs user confirmation. **RESOLVED (D-34):** admins set and remove links on the Phase 19.6.1 Administrators screen through its record-action seam (a prompted set action and a remove action behind `golem15.users.manage_backend_links`); My Profile keeps the generic cabana account-contribution seam (D-04 part 1). No new cabana backend-users screen.
|
||||
4. **Frontend permission semantics** (Pitfall 3): mirror the route (group grants) — recommended — or change `user.permission` to `MergedPermissions` (behaviour change in a core plugin). **RESOLVED (D-35):** mirror the route. Frontend tool filtering uses group grants, exactly what `user.permission` enforces; `MergedPermissions` is not changed.
|
||||
5. **Session binding granularity** (A3): `(client_id, user_id)` vs token hash. **RESOLVED (D-35):** `(client_id, user_id)`, so sessions survive token refresh.
|
||||
6. **`ai` scope**: ignore for tools (recommended) or require it for some tool class. **RESOLVED (D-35):** ignored; `ai` plays no part in the read/write ceiling.
|
||||
7. **MCP consent surface.** wristband sends the browser to `{issuer}/connect?request=` [VERIFIED: modules/wristband/authorize.go:174 — `spa := s.opts.Issuer + "/connect?request=" + rfc3986Escape(requestID)`]. Recommendation: sm-oauthserver-plugin adds JSON consent endpoints for the MCP server (show/decide, `jwt.auth`, mirroring fonoteka's `ConsentShow`/`ConsentStore` contract) that include the linked admin's display name when `backend` is requested; vue-demo-app adds `/connect` and the link-proof page. The demo's nginx does not route `/oauth` or `/.well-known` to Go yet (sm-demo-app/DEPLOY.md:34), so the deploy plan must add `/mcp`, `/.well-known/oauth-protected-resource*`, `/.well-known/oauth-authorization-server` and `/oauth/mcp/*`. **RESOLVED (D-35):** JSON consent endpoints in sm-oauthserver-plugin with the `/connect` page (and the `/link-admin` proof page) in vue-demo-app, plan 04 Task 2; the nginx locations are plan 04 Task 5.
|
||||
8. **Permission code spelling.** Existing backend codes are `golem15.users.*` (`golem15.users.access_users`, `…access_groups`, `…access_settings`, `…impersonate_user`, `…manage_privileged_groups` [VERIFIED: fonoteka.go/plugins/golem15/user/admin_permissions.go:17-41]); 19.6 adds `golem15.users.reset_two_factor`. Recommend `golem15.users.manage_backend_links` (CONTEXT's example `golem15.user.…` would break the pattern). **RESOLVED (D-35):** `golem15.users.manage_backend_links`.
|
||||
|
||||
## Environment Availability
|
||||
|
||||
|
||||
590
.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
Normal file
590
.planning/phases/19.7-generic-mcp-module/19.7-REVIEW.md
Normal file
@@ -0,0 +1,590 @@
|
||||
---
|
||||
phase: 19.7-generic-mcp-module
|
||||
reviewed: 2026-10-23
|
||||
depth: deep
|
||||
lanes: [A framework MCP core, B cabana and admin SPA, C plugins and demo]
|
||||
files_reviewed: 128
|
||||
findings:
|
||||
critical: 3
|
||||
warning: 17
|
||||
info: 20
|
||||
total: 40
|
||||
status: issues_found
|
||||
---
|
||||
|
||||
# Phase 19.7 code review
|
||||
|
||||
Three deep review lanes run in parallel over the phase's changes (framework since 1bd91a4^, sm-user-plugin since 3828a65, sm-oauthserver-plugin since d31f8e7, sm-journal-plugin since ffa2c8f, sm-demo-app since a25444e^, vue-demo-app since f397df2). Finding ids carry the lane prefix (A-, B-, C-). Each lane's file list is in its section's source report.
|
||||
|
||||
| Lane | Critical | Warning | Info |
|
||||
|------|----------|---------|------|
|
||||
| A framework MCP core | 1 | 9 | 8 |
|
||||
| B cabana and admin SPA | 0 | 6 | 6 |
|
||||
| C plugins and demo | 2 | 2 | 6 |
|
||||
|
||||
# Lane A
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Report (lane A, framework MCP core)
|
||||
|
||||
**Reviewed:** 2026-10-23
|
||||
**Depth:** deep
|
||||
**Files Reviewed:** 32
|
||||
**Status:** issues_found
|
||||
|
||||
### Summary
|
||||
|
||||
I reviewed pier (identity, catalog, dispatch, stateful session router, stateless path, stores, fan-out), the surf glue (`pier_on.go`, `MountStream`, `Router.Handler`/`compileHandlers`), the bouncer dispatch marker and registry, the pact MCP contracts, wristband's scope allow-list and cooler's `KeyPrefix`. I traced the call chains into the SDK (go-sdk v1.8.0 `streamable.go` and `server.go`), cabana (`ResolveBackend`, `ResolveBackendToken`, `ScopeLimitFor`, `Allows`, `refuseFrontendMarker`, `BackendUsers.FindByID`) and the user plugin's personal-token resolver.
|
||||
|
||||
The core identity model holds up. Every request resolves its own identity, the receiving middleware re-filters list and call for that identity, the binding check applies to POST, GET and DELETE, the marker stays in the context only, and the backend provider's per-method scope limit matches cabana's HTTP guard (a `methodOK == 0` token gets an empty limit, which `Allows` refuses). I found no identity or guard bypass.
|
||||
|
||||
The defects are in lifecycle and edge handling:
|
||||
|
||||
- Stateful local sessions are never reaped, so every abandoned session leaks an SDK server and its goroutines until the process restarts.
|
||||
- Dispatch hands routes path values that the HTTP mux can never produce (`..`, traversal inside `{x...}`, an empty `{id}`).
|
||||
- The per-binding cap has a TOCTOU race.
|
||||
- A session's or stateless server's tool set never widens when the same binding comes back with more scope.
|
||||
- On Redis, an instance that serves only stateless clients never subscribes to fan-out events, and stateless listen streams are never re-verified.
|
||||
- Global mutexes are held across guard and database I/O.
|
||||
- Raw database errors reach the MCP client.
|
||||
|
||||
I did not re-report items that are accepted or deferred in 19.7-SECURITY-REVIEW.md or deferred-items.md: superuser reach, descriptions, the `initialized` notification landing on another instance, the protocol-version context key, the MCP grant revoke list, the duplicate `*pier.Pier` publish and the 5 s link cache.
|
||||
|
||||
### Critical Issues
|
||||
|
||||
#### A-CR-01: Stateful local sessions are never expired or reaped (unbounded server and goroutine leak)
|
||||
|
||||
**File:** `modules/pier/session.go:50`, `:143-149`, `:289-315`; `modules/pier/store_memory.go:27-34`; `modules/pier/audit.go:67`
|
||||
**Issue:** Every session opened through `serveNew` (and every copy rehydrated in `lookup`) is stored in `sr.local` with a live `*mcp.Server`, a `StreamableServerTransport`, a connected `*mcp.ServerSession` (jsonrpc2 reader goroutines) and the `ss.Wait()` goroutine started in `connect`. A local copy is removed in only three cases: a DELETE, a revoked or deleted subject event, or a later request for the same id whose record has gone (`lookup` → `closeLocal`). pier serves the transport directly, so it bypasses `StreamableHTTPHandler`. In go-sdk v1.8.0 the idle close (`StreamableHTTPOptions.SessionTimeout`, `streamable.go:721`) exists only in that handler; the transport has no idle close of its own. The store forgets idle sessions (memory sweep, Redis PX TTL) but nothing closes the local copy. The documented `expired` log step (`audit.go:67`) is never emitted anywhere.
|
||||
**Failure scenario:** Most MCP clients exit without sending DELETE (a desktop client closed, a CLI agent run finishing). Each such session stays in memory with its goroutines for the life of the process. Once the record expires, `Count` drops, so the same binding can open `max_per_binding` new sessions every `idle_ttl`. One token can therefore grow memory and goroutines without bound (about 20 sessions per 30 min per binding with the defaults, multiplied by bindings), up to an OOM. The leaked sessions also stay in `sessionRouter.matching`, so every permission or link event recomputes `allowed(...)` (database-backed guard checks) for each dead session.
|
||||
**Fix:** Reap local copies whose record has expired. One option is a janitor at the store's TTL granularity:
|
||||
```go
|
||||
// in Mount, after p.sessions is built
|
||||
go p.sessions.reap(ctx, p.cfg.IdleTTL/2)
|
||||
|
||||
func (sr *sessionRouter) reap(ctx context.Context, every time.Duration) {
|
||||
t := time.NewTicker(every)
|
||||
defer t.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
sr.mu.Lock()
|
||||
ids := make([]string, 0, len(sr.local))
|
||||
for id := range sr.local {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
sr.mu.Unlock()
|
||||
for _, id := range ids {
|
||||
if _, ok, err := sr.p.store.Get(ctx, id); err == nil && !ok {
|
||||
sr.closeLocal(id)
|
||||
logSession(logger(), "expired", id, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
A simpler alternative is a per-`localSession` `time.AfterFunc(IdleTTL)` that is reset in `lookup` and closes the session, mirroring the SDK's `sessionInfo.timer`. Add a test that a session idle past `idle_ttl` disappears from `sr.local` and its `ss.Wait()` returns.
|
||||
|
||||
### Warnings
|
||||
|
||||
#### A-WR-01: Dispatched path values bypass the mux's path cleaning (`..` and traversal inside `{x...}`)
|
||||
|
||||
**File:** `modules/pier/dispatch.go:96-104`, `:117-124`, `:181-183`
|
||||
**Issue:** A single-segment value is refused only when it contains `/`. A wildcard (`{p...}`) value is split on `/` and each part is `url.PathEscape`d, which leaves `.` and `..` unescaped. `req.SetPathValue` then hands the raw value to the compiled chain. Over HTTP, `net/http.ServeMux` cleans the path and redirects before any handler runs. I checked this: `GET /files/a/../../etc/passwd` → 307 `/etc/passwd`, and `GET /items/..` → 307 `/`. A route's `{id}` is therefore never `..` or `.`, and a `{p...}` never contains `..` segments or empty segments. `Router.Handler` serves the route's chain directly (no mux), so pier delivers values the route has never seen over HTTP. `T-19.7-03` states that the in-process chain runs "the same constraints … as an HTTP request", but the mux's cleaning invariant is not part of that chain.
|
||||
**Failure scenario:** A plugin declares a tool on `GET /_media/api/files/{path...}` whose handler does `os.Open(filepath.Join(root, r.PathValue("path")))`. That code is safe over HTTP because the mux cleans the path. An agent calls the tool with `{"path":"a/../../../etc/passwd"}`: `filepath.Join` resolves outside `root` and the route serves the file. For a single segment, `{"id":".."}` reaches a route that over HTTP could only see a real id.
|
||||
**Fix:** Refuse what the mux would never deliver:
|
||||
```go
|
||||
case argPath:
|
||||
s, err := scalarString(v)
|
||||
...
|
||||
wild := strings.Contains(t.pattern, "{"+f.key+"...}")
|
||||
for _, seg := range strings.Split(s, "/") {
|
||||
if seg == "" || seg == "." || seg == ".." {
|
||||
return toolError(fmt.Sprintf("pier: invalid arguments: %q must not contain empty, . or .. segments", f.name)), 0
|
||||
}
|
||||
}
|
||||
if !wild && strings.Contains(s, "/") { ... }
|
||||
```
|
||||
Alternatively, require `path.Clean("/"+s) == "/"+s`. Add a `TestDispatch` case for `..` and `a/../b`.
|
||||
|
||||
#### A-WR-02: An optional path field leaves `{key}` literal in the target and an empty path value
|
||||
|
||||
**File:** `modules/pier/catalog.go:213-235`; `modules/pier/dispatch.go:90-93`, `:117-124`, `:181-183`
|
||||
**Issue:** `compileTool` checks that every `{segment}` has a `path:` field, but not that the field is required. jsonschema-go v0.4.3 (`infer.go:342`) makes a field optional when it carries `omitempty` or `omitzero`. If the caller omits that field, `run` skips it (`if !ok { continue }`), the target keeps the literal `{id}` (`httptest.NewRequest` accepts it), and `SetPathValue(seg, pathValues[seg])` sets `""`. Over HTTP a `{id}` segment never matches an empty segment.
|
||||
**Failure scenario:** A plugin writes `ID string \`json:"id,omitempty" path:"id"\`` on `DELETE /api/items/{id}`. The agent omits `id`, and the route runs with `PathValue("id") == ""` and `URL.Path == "/api/items/{id}"`. A route that queries `WHERE slug = ?` with `""`, or that treats an empty id as "all", acts on data that no HTTP request could reach.
|
||||
**Fix:** At boot, refuse a path field that the schema does not list as required:
|
||||
```go
|
||||
for _, f := range fields {
|
||||
if f.kind == argPath && !slices.Contains(schema.Required, f.name) {
|
||||
return nil, fmt.Errorf("%s: path field %q must be required (drop omitempty/omitzero)", errPrefix, f.name)
|
||||
}
|
||||
}
|
||||
```
|
||||
Also refuse a missing segment value at runtime before building the request (defence in depth).
|
||||
|
||||
#### A-WR-03: `max_per_binding` is check-then-act (TOCTOU) and can be exceeded by concurrent initializes
|
||||
|
||||
**File:** `modules/pier/session.go:134-159`; `modules/pier/store_redis.go:41-52`, `:119-137`
|
||||
**Issue:** `serveNew` calls `store.Count`, then `connect`, then `store.Put`, with no reservation in between. N concurrent `initialize` POSTs from one binding all read `Count == k < max` and all `Put`. The Redis path is non-atomic as well (`SMEMBERS` plus `EXISTS` per member, then a separate `MULTI`).
|
||||
**Failure scenario:** A client (or one stolen token) sends 100 parallel initializes. All pass the cap of 20 and 100 sessions open, each with a local server (see A-CR-01). The cap is the per-binding control cited for T-19.7-18, but it only holds for serial requests. The inline throttle (120/min per IP) limits the rate, not concurrency.
|
||||
**Fix:** Make the reservation atomic in the store, for example `Reserve(ctx, binding, id, max, ttl) (bool, error)`. On Redis, use a Lua script: prune dead members, `SCARD`, and if below max `SADD` plus `SET` of a placeholder record. On memory, do the same under `m.mu`. Call it in place of `Count`/`Put`, and release on connect or initialize failure.
|
||||
|
||||
#### A-WR-04: A session's or stateless server's tool set never widens when the same binding returns with more scope
|
||||
|
||||
**File:** `modules/pier/stateless.go:87-93`; `modules/pier/session.go:276-278`, `:463-487`, `:516-530`
|
||||
**Issue:** `newServer` registers only the tools that `allowed(...)` grants the identity that built the server. On a later request with the same binding, `getServer` (stateless hit) and `lookup` (stateful) only overwrite `identity`. The server's tool set is recomputed only by a fan-out event (`handleEvent`). The receiving middleware can only filter `tools/list` down (`kept` is a subset of what the server holds). A tool that the new identity may call, but that the server never registered, is missing from the list, and `tools/call` passes pier's check and then fails in the SDK as an unknown tool.
|
||||
**Failure scenario:** An OAuth client first connects with `scope=read` (binding `oauth:<client>:<user>`). The stateless LRU builds the server without write tools. The user re-authorizes with `read write`; the binding is the same. Every following request hits the cached entry, which `MoveToFront` keeps alive, so the write tools never appear and calls to them fail until LRU eviction or an unrelated subject event. The same happens to a stateful session whose client refreshes into a wider grant, and when `backend` is added to a grant.
|
||||
**Fix:** On a hit, compare a fingerprint of the authorization-relevant parts of the identity (sorted scopes, frontend and backend subject ids, ceiling). When it changed, run the same diff as for an event:
|
||||
```go
|
||||
if e.fingerprint != fp(id) {
|
||||
tools, prompts := sp.p.catalog.allowed(r.Context(), id)
|
||||
applyDiff(e.server, sp.p, id, tools, prompts, e.tools, e.prompts)
|
||||
e.fingerprint = fp(id)
|
||||
}
|
||||
```
|
||||
Do the same in `lookup` under `ls.mu`. An alternative for the stateless path is to key the LRU by binding plus fingerprint.
|
||||
|
||||
#### A-WR-05: With the Redis store, an instance that serves only stateless clients never subscribes to fan-out events
|
||||
|
||||
**File:** `modules/pier/pier.go:140-167`; `modules/pier/store_redis.go:189-204`; `modules/pier/stateless.go:74-76`, `:146-174`; `modules/pier/events.go:13-27`
|
||||
**Issue:** The Redis store, and with it the `mcp:events` subscription (`rs.Subscribe` inside `open`), is created lazily by the first store call. Only the stateful router (`Count`/`Put`/`Get`/`Touch`/`Delete`) and a locally fired subject event (`listenEvents` → `Publish`) make that call. The stateless path (`route` → `statelessPath.ServeHTTP` → SDK) never touches the store.
|
||||
**Failure scenario:** In a two-instance Redis deployment, instance B receives only 2026-07-28 clients (or only `server/discover` traffic). An admin revokes a grant on instance A. A publishes `revoked`, but B never subscribed: its LRU entries for that subject are not evicted, their `subscriptions/listen` streams are not closed (see A-WR-06), and permission or link changes never send `list_changed` on B. Per-request bearer checks still refuse calls, but D-26 and D-27 fan-out is broken on B.
|
||||
**Fix:** Open the store and subscribe when the first request arrives on any path, for example `if ls, ok := p.store.(*lazyStore); ok { _, _ = ls.get(r.Context()) }` at the top of `route`. Better, start a background goroutine at mount that retries `open` with backoff, so the subscription exists before traffic arrives. Keep the 503 behaviour for stateful requests when the store is down.
|
||||
|
||||
#### A-WR-06: Stateless `subscriptions/listen` streams are never re-verified, and LRU eviction orphans them from revocation
|
||||
|
||||
**File:** `modules/pier/stateless.go:98-106`, `:128-140`; `modules/pier/session.go:369-392`
|
||||
**Issue:** The stateful GET stream re-resolves its bearer every `streamRecheckInterval` (Pitfall 10). The stateless path has no equivalent. In go-sdk v1.8.0 a 2026-07-28 `subscriptions/listen` is a long-lived POST (`shouldPropagateCancellation` with `isSubscriptionsListen`), so the only thing that ends it is `evict` on a `revoked` or `deleted` event. In addition, when `getServer` drops the oldest entry at capacity (`sp.order.Remove(last); delete(sp.entries, ...)`), it does not close that server's sessions. A later `evict` for that subject can then no longer find the entry.
|
||||
**Failure scenario:** A token expires (no event is fired), or a revocation event is missed (A-WR-05, or a go-redis pub/sub drop), or the identity's entry was LRU-evicted before the revocation. The client's listen stream stays open indefinitely and keeps receiving list-change notifications for an identity that no longer authenticates, which the stateful path explicitly prevents.
|
||||
**Fix:** When evicting for capacity, close the evicted server's sessions, as `evict` does:
|
||||
```go
|
||||
old := last.Value.(*statelessEntry)
|
||||
sp.order.Remove(last)
|
||||
delete(sp.entries, old.binding)
|
||||
go func() { for ss := range old.server.Sessions() { _ = ss.Close() } }()
|
||||
```
|
||||
Also wrap the stateless handler with the same periodic bearer re-check that `serveStream` uses when the request body is a `subscriptions/listen` (`peekMethods` is already available).
|
||||
|
||||
#### A-WR-07: Global mutexes are held across guard and database I/O, so one slow check stalls every session on the instance
|
||||
|
||||
**File:** `modules/pier/session.go:144-149`, `:247-275`; `modules/pier/stateless.go:85-107`
|
||||
**Issue:** `serveNew` and `lookup` hold `sr.mu` (the router-wide lock) while `connect` → `newServer` → `catalog.allowed` runs `MCPAllows` or `MCPAllowsMethod` for every catalog item. For the backend provider each call is a `cabana.BackendPrincipal` database query, and the user plugin's guard also queries. `getServer` holds `sp.mu` over the same work. `matching` (event fan-out) and every `lookup` need the same locks.
|
||||
**Failure scenario:** The database slows down (lock contention, pool exhaustion) during one client's initialize or rehydration. Every other MCP request on the instance (POSTs to existing local sessions, GET streams being established, DELETEs, subject events) blocks on `sr.mu` or `sp.mu` until that request's context ends. One client's slow guard check becomes an instance-wide stall of the endpoint.
|
||||
**Fix:** Build the server outside the lock and insert it under the lock with a re-check:
|
||||
```go
|
||||
ls, err := sr.connect(ctx, sid, id, state) // no lock held
|
||||
sr.mu.Lock()
|
||||
if cur := sr.local[sid]; cur != nil { sr.mu.Unlock(); _ = ls.ss.Close(); ls = cur } else { sr.local[sid] = ls; sr.mu.Unlock() }
|
||||
```
|
||||
Use the same pattern for `getServer` (build on miss without `sp.mu`, then insert or adopt the existing entry).
|
||||
|
||||
#### A-WR-08: Raw provider and database errors are returned to the MCP client as tool text
|
||||
|
||||
**File:** `modules/pier/dispatch.go:147-150`; `modules/cabana/auth.go:44-50` (callee)
|
||||
**Issue:** `MCPDispatch` errors become `toolError("pier: " + err.Error())`. For the built-in backend provider the error comes from `cabana.BackendPrincipal` → `BackendUsers.FindByID`, which returns the raw gorm or pgx error. Plugin providers (`MCPDispatch` in the user guard) also return raw database errors. pgx error strings include the server address, the database and user names, and SQL state details.
|
||||
**Failure scenario:** The database fails between the listing check (which only logs its error) and the dispatch, or a provider's `MCPDispatch` queries while its `MCPAllows` does not. The agent and its transcript then receive text such as `pier: failed to connect to user=summer database=summer: 10.x.x.x:5432 ... dial error`, which leaks infrastructure details to an outside client.
|
||||
**Fix:** Log the error server-side and return a fixed text:
|
||||
```go
|
||||
if err != nil {
|
||||
logger().Warn("pier: guard dispatch failed", "tool", t.name, "guard", t.guardName, "error", err)
|
||||
return toolError("pier: the tool could not be run for this caller"), 0
|
||||
}
|
||||
```
|
||||
Keep the specific "unknown or deactivated" message only for the provider's own sentinel errors.
|
||||
|
||||
#### A-WR-09: A personal-token resolver that leaves `TokenID` zero puts every user on one binding
|
||||
|
||||
**File:** `modules/pier/identity.go:229-245`; `modules/pact/mcp.go:237-244`
|
||||
**Issue:** The binding of a frontend personal token is `"pat:user:" + subject.TokenID`. `resolvePersonalToken` checks `UserID != 0` but not `TokenID`, and the `MCPPersonalTokenResolver` contract never says `TokenID` is required. The shipped user plugin sets it, but any other resolver that omits it maps every token of every user to `pat:user:0`.
|
||||
**Failure scenario:** With a third-party resolver and `mcp.allow_personal_tokens: true`, all personal-token users share one binding. The 20-session `max_per_binding` cap becomes global, so one user exhausts it for everyone (429). User B can DELETE user A's session (the binding check passes) when B learns the id. The stateless LRU serves one shared server whose `identity` (used for fan-out matching) flips between users.
|
||||
**Fix:** Refuse a subject without a token id, or include the user id in the binding:
|
||||
```go
|
||||
if err != nil || !ok || subject.UserID == 0 || subject.TokenID == 0 {
|
||||
return Identity{}, ErrUnauthorized
|
||||
}
|
||||
```
|
||||
Document in `pact.MCPPersonalTokenResolver` that `TokenID` must identify the token row.
|
||||
|
||||
### Info
|
||||
|
||||
#### A-IN-01: The GET stream re-check ignores a session whose record is gone
|
||||
|
||||
**File:** `modules/pier/session.go:381-387`; `modules/pier/store_redis.go:91-101`; `modules/pier/store_memory.go:68-79`
|
||||
**Issue:** Every minute the recheck calls `store.Touch` and ignores the result. `Touch` on a missing record returns `nil` in both stores. If the `ended` pub/sub event for a DELETE served on another instance is lost, the local GET stream outlives the ended session for as long as the bearer resolves.
|
||||
**Fix:** In the ticker branch, `if _, ok, err := sr.p.store.Get(ctx, ls.id); err == nil && !ok { cancel(); sr.closeLocal(ls.id); return }`.
|
||||
|
||||
#### A-IN-02: `KeyPrefix`'s doc comment swallowed `keyPrefix`'s
|
||||
|
||||
**File:** `modules/cooler/cooler.go:353-366`
|
||||
**Issue:** The new comment was inserted directly under `keyPrefix`'s existing comment block. `go doc cooler.KeyPrefix` now starts with "keyPrefix returns …", and `keyPrefix` has no doc.
|
||||
**Fix:** Move the original five lines down to sit directly above `func keyPrefix`.
|
||||
|
||||
#### A-IN-03: The `MCPPersonalTokenResolver` doc describes a resolver chain that pier does not have
|
||||
|
||||
**File:** `modules/pact/mcp.go:237-244`; `modules/pier/identity.go:224-232`
|
||||
**Issue:** The doc says "the boolean is false when the token's prefix is not the resolver's, so the next resolver is tried", but pier looks up one published resolver (`app.Lookup`) and treats `ok == false` as unauthorized. A second plugin cannot publish another one (duplicate provider).
|
||||
**Fix:** Reword the doc (one resolver per application; false means "not mine, unauthorized"), or support a registry like `MCPGuards`.
|
||||
|
||||
#### A-IN-04: Integer path and query arguments above 2^53 lose precision
|
||||
|
||||
**File:** `modules/pier/dispatch.go:256-271`, `:301-311`
|
||||
**Issue:** `scalarString` and `queryStrings` decode into `any`, which gives `float64`. An id of `9007199254740993` is forwarded as `9007199254740992`, so the call addresses a different record.
|
||||
**Fix:** Decode with `json.NewDecoder(bytes.NewReader(raw)).UseNumber()` and render `json.Number` as its string.
|
||||
|
||||
#### A-IN-05: The dispatched request carries the `httptest` Host `example.com` and no scheme
|
||||
|
||||
**File:** `modules/pier/dispatch.go:161-180`
|
||||
**Issue:** `httptest.NewRequestWithContext` sets `Host: example.com` and no TLS. pier copies the client address, X-Forwarded-For, X-Real-IP and Accept-Language, but not Host, X-Forwarded-Proto or X-Forwarded-Host. A route that builds absolute URLs from the request, or compares Host, behaves differently than over HTTP (wrong links in tool results).
|
||||
**Fix:** Copy the outer `r.Host` into `callInfo` and set `req.Host`. Copy `X-Forwarded-Proto` and `X-Forwarded-Host` like the other forwarding headers.
|
||||
|
||||
#### A-IN-06: Audit and lifecycle labels do not match what happens
|
||||
|
||||
**File:** `modules/pier/audit.go:67`; `modules/pier/session.go:171-192`, `:572-575`
|
||||
**Issue:** The `expired` session step is documented but never logged (see A-CR-01). Tool calls served by `serveEphemeral` (stateful path, no session id) are logged with session `stateless`.
|
||||
**Fix:** Emit `expired` from the reaper, and log ephemeral calls with a distinct label (for example `ephemeral`).
|
||||
|
||||
#### A-IN-07: Embedded-struct fields on a GET or DELETE tool are dropped silently
|
||||
|
||||
**File:** `modules/pier/catalog.go:236-242`, `:380-385`; `modules/pier/dispatch.go:129-136`
|
||||
**Issue:** `inputFields` skips anonymous fields without tags because "their promoted fields are body fields". The GET/DELETE body check only looks at `fields`, so an embedded struct on a GET tool passes boot. Its promoted properties are in the schema and validated, then never sent, because a GET has no body.
|
||||
**Fix:** In `inputFields`, recurse into embedded structs (classifying the promoted fields), or refuse an embedded field on GET/DELETE tools at boot.
|
||||
|
||||
#### A-IN-08: pier does not constrain the marker's guard list to the tool's guard
|
||||
|
||||
**File:** `modules/pier/dispatch.go:151-159`
|
||||
**Issue:** `disp.Guards` comes from the provider and is copied into the marker as is. A frontend provider that answers `Guards: ["backend"]` (a provider bug) would have its principal honoured by every `backend`-guarded middleware except cabana's (which checks `Principal.Backend` since c49983d). pier is the only dispatcher, so it is the cheapest place to enforce the invariant.
|
||||
**Fix:** Refuse the call if `t.guardName != BackendGuard && slices.Contains(disp.Guards, BackendGuard)`, or if `principal.Backend != (t.guardName == BackendGuard)`.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
|
||||
# Lane B
|
||||
|
||||
|
||||
## Phase 19.7 (lane B): Code Review Report
|
||||
|
||||
**Reviewed:** 2026-10-23
|
||||
**Depth:** deep
|
||||
**Files Reviewed:** 37
|
||||
**Status:** issues_found
|
||||
|
||||
### Summary
|
||||
|
||||
Lane B covers the cabana seams (dispatch marker in `ResolveBackend` and the `backend` middleware, `ResolveBackendToken` / `ScopeLimitFor` / `BackendPrincipal`, My account contributions, prompted record actions, subject events, OpenAPI) and the admin SPA side (ConfirmDialog prompt, RecordActions, AccountContributions, plus the keyboard-shortcut and remount work committed in the same range).
|
||||
|
||||
What I traced and found correct:
|
||||
- **Marker:** `refuseFrontendMarker` wraps the guard middleware that surf registers as `backend` (surf/router.go:685, `admin.Middleware`), so plugin routes are covered as well as the admin API. `ResolveBackend` applies the same Backend and scope checks.
|
||||
- **Subject events:** `fireSubjectChanged` runs after commit on every path that fires it. Save, Delete, RecordAction and BulkAction all go through `CRUDService.transaction`, which wraps `lagoon.Transaction`. On those paths the ctx carries the after-commit buffer, so a rollback fires nothing. Outside a transaction (token revoke) the event fires at once. The prior-state snapshots are taken at the right moment: `is_superuser` comes from a virtual field set in `FormBeforeUpdate` after the snapshot, and permissions/role are applied after `FormBeforeUpdate`.
|
||||
- **Prompt validation:** the value is trimmed, must be non-empty and is capped in runes. A payload on a non-prompted action is still refused. The value reaches `Run` unchanged through the Administrators `guardOutranked` wrapper.
|
||||
- **Account contributions:** the action route is protected by `interactiveOnly`, `requireAjax` and `allowAction`, with `Applies` checked again inside the transaction. `pier`'s per-request bearer re-verification makes a missed event only a stale tool list, never a reopened session.
|
||||
- **Response shapes:** the new `prompt` key on `RecordAction` is `omitempty`, so it only adds data.
|
||||
- **Vue:** nothing uses `v-html`, and every i18n key used exists in both `en` and `pl` phrasebooks.
|
||||
|
||||
No BLOCKERs. The defects below are:
|
||||
- two keyboard-shortcut bugs that lose user input or navigate away unexpectedly;
|
||||
- an unvalidated URL rendered into `href`;
|
||||
- an over-broad session kill on personal-token revoke;
|
||||
- a stale API contract;
|
||||
- an all-or-nothing contributions list that fails silently.
|
||||
|
||||
### Warnings
|
||||
|
||||
#### B-WR-01: Plain-key shortcuts fire while typing inside a plugin field type's shadow DOM ("?" is swallowed, Esc leaves the form)
|
||||
|
||||
**File:** `admin/src/app/hotkeys.ts:208-236` (check at `:213`, helper `:100-105`)
|
||||
**Issue:** `onPlainKey` is a `window` listener and decides "is the user typing?" with `isEditableTarget(event.target)`. Keyboard events are composed, so a keydown that starts in an `<input>` inside a shadow root reaches `window` with `event.target` retargeted to the shadow host (the plugin's custom element). `host.closest('input, textarea, select, [contenteditable]')` is null, so the check says "not editable".
|
||||
|
||||
The framework explicitly supports shadow DOM in plugin field types and widgets. `modules/cabana/README.md:185` says "any widget shadow DOM may read only these public variables", and the 10.1 research's reference element calls `attachShadow`.
|
||||
|
||||
Failure scenario (plugin field type with a shadow-root input on a FormView):
|
||||
- Typing `?` opens the shortcut help and calls `preventDefault()`, so the character is never inserted. The admin cannot type a question mark in that field.
|
||||
- Pressing Esc (for example to dismiss the plugin's own autocomplete) clicks the form's Cancel (`hotkey="escape"` in FormView.vue). A clean form navigates away immediately.
|
||||
- `/` focuses the list search when the page has one.
|
||||
|
||||
**Fix:** test the real origin of the event:
|
||||
```ts
|
||||
function originOf(event: Event): EventTarget | null {
|
||||
const path = typeof event.composedPath === 'function' ? event.composedPath() : []
|
||||
return path[0] ?? event.target
|
||||
}
|
||||
// in onPlainKey
|
||||
if (event.defaultPrevented || isEditableTarget(originOf(event))) {
|
||||
return
|
||||
}
|
||||
```
|
||||
Also treat any custom element (a tag name containing `-`) inside a form as editable for plain keys, for closed shadow roots, where `composedPath()` stops at the host.
|
||||
|
||||
#### B-WR-02: Ctrl/Cmd+S and Ctrl/Cmd+Enter save without the taglist's typed-but-uncommitted tag
|
||||
|
||||
**File:** `admin/src/app/hotkeys.ts:187-206` (`target.click()` at `:205`); `admin/src/components/form/fields/TaglistField.vue:73`, `:167`
|
||||
**Issue:** TaglistField commits the draft tag only on Enter (`onKeydown`) or on blur (`@blur="addDraft"`). With the mouse, pressing Save first blurs the input (on mousedown), so the draft is committed before the click handler reads `values`.
|
||||
|
||||
The shortcut path calls `target.click()` without moving focus, so no blur happens. `onModifierKey` also runs in the window capture phase and calls `stopPropagation()`, so for Ctrl+Enter the taglist's own Enter handler never runs either.
|
||||
|
||||
Failure scenario: the admin types `news` in a tags field and presses Ctrl+Enter (Save and close). The record is saved without the tag and the view navigates away, losing the input silently. Ctrl+S leaves `news` visible in the input after a "saved" toast, but the stored record does not have it. Any plugin field type that commits on the native `change` event (which fires on blur) has the same problem.
|
||||
|
||||
**Fix:** commit pending edits before clicking, the way a pointer click would:
|
||||
```ts
|
||||
const active = doc.activeElement as HTMLElement | null
|
||||
if (active && active !== target && typeof active.blur === 'function') {
|
||||
active.blur() // fires blur/change: taglist addDraft, native change
|
||||
}
|
||||
target.click()
|
||||
```
|
||||
Optionally restore focus after the save. Add a test that drafts a tag and presses Ctrl+S.
|
||||
|
||||
#### B-WR-03: An account action's URL goes into `href` and `window.open` with no scheme check (`javascript:` executes on the admin origin)
|
||||
|
||||
**File:** `admin/src/components/account/AccountContributions.vue:43-46`, `:103-111`; `modules/cabana/account_contributions.go:212`
|
||||
**Issue:** `AccountActionResult.URL` is passed through unchanged by the server (`URL: result.URL`) and the SPA:
|
||||
- binds it to `<a :href="links[section.name]">`;
|
||||
- calls `window.open(answer.url, '_blank', 'noopener')`.
|
||||
|
||||
Vue does not sanitize `href`. A `javascript:` (or `data:`) URL therefore runs script with the admin's session the moment the admin clicks the visible link. That is stored-XSS-equivalent in the admin if any plugin builds the URL from data it does not fully control, for example a configured site URL or a value from the linked frontend account.
|
||||
|
||||
T-19.7-08 records only "no v-html" and "noopener" as the mitigation, so this sink is not covered by the accepted risk.
|
||||
|
||||
**Fix:** allow only http(s) (and same-origin relative) URLs at the framework seam, and again in the SPA:
|
||||
```go
|
||||
// account_contributions.go, before WriteData
|
||||
if result.URL != "" {
|
||||
u, err := url.Parse(result.URL)
|
||||
if err != nil || (u.Scheme != "https" && u.Scheme != "http") {
|
||||
moduleLog.ErrorContext(ctx, "cabana: account contribution action answered a non-http URL", "section", item.section.Name, "action", action.Name)
|
||||
result.URL = ""
|
||||
}
|
||||
}
|
||||
```
|
||||
```ts
|
||||
const safe = /^https?:\/\//i.test(answer.url) ? answer.url : ''
|
||||
```
|
||||
|
||||
#### B-WR-04: Revoking any personal token ends every MCP session of the admin, including OAuth agent sessions of the linked frontend user
|
||||
|
||||
**File:** `modules/cabana/account_tokens.go:167`
|
||||
**Issue:** `fireSubjectChanged(..., pact.MCPSubjectRevoked, principal.ID)` names only the admin. `pier/events.go:42-50` closes and deletes every local session whose identity `has("backend", adminID)`. That includes:
|
||||
- sessions opened with other, still-valid `g15_` tokens;
|
||||
- every OAuth session whose linked backend subject is this admin, which also carries the frontend user's tools.
|
||||
|
||||
Stateless servers are evicted too. The comment says "A revoked token ends what it opened elsewhere", but the effect is per admin, not per token.
|
||||
|
||||
Failure scenario: an admin revokes an old CI token. Every running agent session of their linked frontend account (and of their other tokens) is torn down on all instances. Per-request bearer verification already refuses the revoked token on its next request, so the broad kill adds no security for the revoked token itself.
|
||||
|
||||
**Fix:** make the event token-specific. Add `TokenID uint` to `pact.MCPSubjectChanged` (additive), fire it with `row.ID`, and in `pier.handleEvent` close only sessions whose `Identity.Backend.TokenID == ev.TokenID && Identity.Backend.ClientID == ""` when `TokenID != 0`. Until then, drop the event here and rely on the per-request re-verify.
|
||||
|
||||
#### B-WR-05: The record action API contract still says payload is refused
|
||||
|
||||
**File:** `modules/cabana/admin_openapi.go:798`, `:808`, `:825-827`
|
||||
**Issue:** The changes in this phase make `POST /{vendor}/{plugin}/{controller}/{id}/actions/{action}` accept `payload` (a JSON string) for a prompted action, and validate it with a 422 on `payload`. Three annotations were not updated:
|
||||
- the `AdminRecordAction` description still says "The body must be {}: record_id, values and payload are all refused";
|
||||
- the body param is documented as "Empty object";
|
||||
- `AdminActionRequest.Payload` says "Toolbar and record routes refuse it."
|
||||
|
||||
These texts are generated into `admin/openapi/admin.json` and `admin/src/api/schema.d.ts`, so the published contract contradicts the server. The project rule (CLAUDE.md) requires docs to change with the API.
|
||||
|
||||
**Fix:**
|
||||
- Update the description to: "The body must be {} for an action without a prompt; an action whose record response carries `prompt` takes `{\"payload\": \"<text>\"}` (trimmed, non-empty, at most prompt.max_length runes; 422 on payload otherwise)."
|
||||
- Change the body param text and the `Payload` field comment to match.
|
||||
- Run `scripts/check-admin-openapi.sh`.
|
||||
|
||||
#### B-WR-06: One contributing plugin's Status/Applies error removes every My account section, and the SPA hides the failure
|
||||
|
||||
**File:** `modules/cabana/account_contributions.go:110-116`, `:126`; `admin/src/components/account/AccountContributions.vue:25-32`
|
||||
**Issue:** `accountContributionsList` answers 500 for the whole list as soon as any section's `Status` or any action's `Applies` returns an error. `load()` then sets `sections = []` on any non-2xx result (`result.data?.data ?? []`) with no toast.
|
||||
|
||||
Failure scenario: plugin A's status query fails (a missing table after a partial migration, or a timeout). Plugin B's unrelated section, such as the MCP account link with its Unlink button, disappears from My account with no message. The admin cannot reach B's actions until A is fixed.
|
||||
|
||||
**Fix:** isolate failures per section. Log the error, then either omit that section or send it with an empty status and an `error: true` flag. Keep the other sections. In the SPA, show a toast (`backend::lang.form.error_generic`) when the GET fails, instead of silently rendering nothing.
|
||||
|
||||
### Info
|
||||
|
||||
#### B-IN-01: My account confirm and stale texts talk about "this record"
|
||||
|
||||
**File:** `admin/src/components/account/AccountContributions.vue:52`, `:78`
|
||||
**Issue:** The default confirm uses `backend::lang.form.action_confirm` ("Run “:action” on this record?" / "Wykonać „:action” na tym rekordzie?"). A 409 shows `action_stale` ("This action no longer applies to this record. The page has been refreshed."). My account has no record, so both texts are wrong there.
|
||||
**Fix:** add `backend::lang.myaccount.action_confirm` and `backend::lang.myaccount.action_stale` (en and pl, plus `tests/fixtures/lang.json`) and use them here.
|
||||
|
||||
#### B-IN-02: One prompt refusal is not localized
|
||||
|
||||
**File:** `modules/cabana/actions.go:268`
|
||||
**Issue:** `"The payload must be a string."` is hard-coded English. The other two prompt refusals use phrase keys. RecordActions shows `details.payload[0]` as the toast, so a Polish admin can see English. It is reachable only by a non-SPA client, so impact is low.
|
||||
**Fix:** reuse `promptRequiredKey`, or add `backend::lang.form.action_prompt_invalid`.
|
||||
|
||||
#### B-IN-03: Plugin status text goes through `translateKey`, not `localizeDetail`
|
||||
|
||||
**File:** `modules/cabana/account_contributions.go:116`
|
||||
**Issue:** `Status` is typically dynamic text such as "Linked to jan@example.com". `translateKey` looks every string up as a phrase key. In development that logs a missing-key warning on every My account load, which `localizeDetail` (crud.go) exists to avoid.
|
||||
**Fix:** `view.Status = localizeDetail(ctx, tr, status)`.
|
||||
|
||||
#### B-IN-04: Failed `g15_` token attempts at `/mcp` are logged without the client address
|
||||
|
||||
**File:** `modules/cabana/token_resolver.go:31`, `:38`, `:43`, `:47`, `:51`, `:61`
|
||||
**Issue:** `ResolveBackendToken` takes no request, so every `admin.auth` line it writes has `method=""` and `remote=""`. Over HTTP, the same failures carry the remote address, which the audit relies on to trace token guessing.
|
||||
**Fix:** take the remote address (or an `*http.Request`) as an optional parameter. pier has the outer request when it resolves the bearer.
|
||||
|
||||
#### B-IN-05: A prompted action refused with 422 closes the dialog and discards the typed text
|
||||
|
||||
**File:** `admin/src/components/form/RecordActions.vue:288-315`, `:336-339`; `admin/src/components/ui/confirm.ts:50-67`
|
||||
**Issue:** `confirm()` always settles after the action, so a 422 on `payload` (for example over the server cap on a non-SPA-checked path, or a plugin's own ValidationError on `payload`) shows a toast and the input is gone. The pact doc says the admin refuses such a value "with a validation error on the input".
|
||||
**Fix:** let the action return `false` to keep the dialog open, show `detail` under the input (`aria-invalid`, `aria-describedby`), and keep `value`.
|
||||
|
||||
#### B-IN-06: `window.open` after an awaited POST can be blocked by popup blockers
|
||||
|
||||
**File:** `admin/src/components/account/AccountContributions.vue:45`
|
||||
**Issue:** The open runs after `await api.POST(...)` (and after the confirm dialog). That is outside the click's synchronous user-activation window in Safari, and in Chrome when the request is slow. The visible link (`:103-111`) is the fallback, so nothing is lost.
|
||||
**Fix:** none required. Optionally skip `window.open` and rely on the link, or open a blank window synchronously and set its `location` afterwards.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
|
||||
# Lane C
|
||||
|
||||
|
||||
## Phase 19.7: Code Review Report (lane C: plugins and demo)
|
||||
|
||||
**Reviewed:** 2026-10-23
|
||||
**Depth:** deep (call chains followed into summercms.go `bouncer`, `cabana`, `lagoon`, `pier`, `wristband`)
|
||||
**Files Reviewed:** 59
|
||||
**Status:** issues_found
|
||||
|
||||
Repository paths used below:
|
||||
- **U** = sm-user-plugin (`/media/nvme/dev/golem15/summercms.io/summercms/sm-demo-app/plugins/golem15/user`, baseline 3828a65)
|
||||
- **O** = sm-oauthserver-plugin (`/media/nvme/dev/golem15/summercms.io/summercms/sm-oauthserver-plugin`, baseline d31f8e7)
|
||||
- **J** = sm-journal-plugin (`/media/nvme/dev/golem15/summercms.io/summercms/sm-journal-plugin`, baseline ffa2c8f)
|
||||
- **D** = sm-demo-app (baseline a25444e^)
|
||||
- **V** = vue-demo-app (`sm-demo-app/vue-demo-app`, baseline f397df2)
|
||||
- **F** = summercms.go (framework, read for call chains only)
|
||||
|
||||
### Summary
|
||||
|
||||
These parts hold up under review: the link-request storage (hashed 256-bit code, row lock, one-shot `used_at`, 1:1 unique indexes plus the 23505 mapping), the consent intersection (granted = submitted ∩ requested, `backend` dropped without a link), the Journal `optionalBackendPrincipal` change (`cabana.ResolveBackend` reads only the bearer or the dispatch marker, never the admin cookie), the Vue pages (text interpolation only, no `v-html`; Nuxt 4.4.8 `navigateTo` refuses script protocols, and wristband DCR requires a hostname), and the migration and its rollback. No breaking API change was found in U, O or J. All additions are new methods, routes, events or hooks.
|
||||
|
||||
The review found four real defects, two of them in security controls the phase security review lists as "verified":
|
||||
|
||||
1. Banning a frontend user, or resetting their password, does not end their MCP grants. Through the account link, a banned user keeps acting as the linked administrator (C-CR-01).
|
||||
2. The "fresh sign-in" proof of the account link (D-05) compares the JWT `iat` with the request time. `POST /_user/api/v1/refresh` mints a new `iat` without any sign-in, so a long-lived session passes as fresh (C-CR-02).
|
||||
3. The link code is a bearer secret that links whoever confirms it. It travels in request paths and query strings that nginx logs, which contradicts the security review's "the link code is never logged" (C-WR-01).
|
||||
4. An MCP grant that carries `backend` is not bound to the administrator shown on the consent page. A later link to a different administrator re-targets the existing grant without new consent (C-WR-02).
|
||||
|
||||
Not re-reported: the missing self-service revoke of MCP grants (AR-19.7-03), superuser reach (T-19.7-34), the v0.4.4 pin gaps, and the other items in deferred-items.md.
|
||||
|
||||
### Narrative Findings (AI reviewer)
|
||||
|
||||
### Critical Issues
|
||||
|
||||
#### C-CR-01: Banned users and password-reset users keep their MCP grants, including the linked admin's backend reach
|
||||
|
||||
**File:** `O classes/mcp_verifier.go:89-95`; `U classes/backend_links.go:396-401`; `U classes/admin_actions.go:106-120` (RevokeUserAccess), `:182-212` (BanUsers); `U controllers/api_controller.go:449-456` (password reset)
|
||||
**Issue:** `MCPTokenVerifier.MCPVerifyToken` accepts a token whenever `userclasses.PrincipalByID` loads the user. `PrincipalByID` (`U classes/user_lookup.go:35-60`) checks only that the row exists and is not soft-deleted. It does not check the ban flag in `user_throttle`, and it does not compare the token's `created_at` with `users.tokens_valid_after`. The plugin's ban and revoke paths do not touch OAuth tokens:
|
||||
- `BanUsers` calls `RevokeUserAccess`, which stamps `tokens_valid_after` and revokes `user_api_tokens` only. It fires no event: no `DeactivatingEvent`, so oauthserver's `Cascade` never runs, and no `pact.MCPSubjectChanged`.
|
||||
- Password reset (`api_controller.go:453-455`) and password change (`:715`) only set `tokens_valid_after`.
|
||||
- `LinkedBackendUser` (`backend_links.go:396-401`) also ignores bans.
|
||||
|
||||
Pier has no other user-state check (`F pier/identity.go:162-199`). MCP refresh tokens (`O classes/mcp_store.go:275-311`) are rotated with no user check either, so the grant survives access-token expiry as well.
|
||||
|
||||
**Failure scenario:** An editor's frontend account E is linked to admin A and holds an MCP grant with `read write backend`. Staff ban E on the Users screen after abuse, or E's owner resets the password after a compromise. The attacker's agent keeps calling `journal_update_post` and `journal_delete_post` as admin A, and keeps refreshing its access token. The plugin documents the ban as ending "every session JWT ... and every personal API token", but the MCP grant is a session-equivalent credential that this phase newly made usable against real routes.
|
||||
|
||||
**Fix:** Make the verifier honour the same refusals as `/refresh` (`refreshSubjectRefused`). Also revoke on ban or reset, and fire the session-ending event:
|
||||
```go
|
||||
// O classes/mcp_verifier.go, after loading principal
|
||||
if principal.TokensValidAfter != (time.Time{}) && token.CreatedAt != nil &&
|
||||
token.CreatedAt.Before(principal.TokensValidAfter) {
|
||||
return pact.MCPGrant{}, pact.ErrMCPTokenInvalid
|
||||
}
|
||||
banned, _, err := userclasses.ThrottleStates(ctx, db, []uint{token.UserID})
|
||||
if err != nil {
|
||||
return pact.MCPGrant{}, err
|
||||
}
|
||||
if banned[token.UserID] {
|
||||
return pact.MCPGrant{}, pact.ErrMCPTokenInvalid
|
||||
}
|
||||
```
|
||||
In U, make `RevokeUserAccess` fire `MCPSubjectRevoked` after commit for each id, or add a `user.AccessRevoked` event that oauthserver's `Cascade` handles by revoking the user's access and refresh tokens. Add `AND NOT EXISTS (SELECT 1 FROM user_throttle t WHERE t.user_id = l.user_id AND t.is_banned)` to `LinkedBackendUser`. These are additive.
|
||||
|
||||
#### C-CR-02: The account-link "fresh sign-in" proof (D-05) is defeated by token refresh
|
||||
|
||||
**File:** `U classes/backend_links.go:239`; `U controllers/backend_link_controller.go:74-85`; `F modules/bouncer/refresh.go:137` with `F modules/bouncer/mint.go:48-60`; `U controllers/api_controller.go:240`; `V app/pages/link-admin.vue:86-91`
|
||||
**Issue:** `ConfirmLinkRequest` treats `iat >= request.created_at` as proof that the user signed in for this link. `POST /_user/api/v1/refresh` (`bouncer.Refresh` → `MintAudience`) mints a new token with `IssuedAt: now` from any token still inside the refresh window. The demo sets `refresh_ttl` to 43200 minutes (30 days), and refresh needs no password, no social login and no 2FA. Refreshing after the request was created therefore turns a weeks-old session into a "fresh" one. Clients do this automatically: the demo's own API client refreshes on any 401 (`V app/lib/api/http.ts:127-183`), and so does sm-bm-app's. The link page also never shows which frontend account is about to be linked; it shows only the admin's name.
|
||||
|
||||
The security review rows T-19.7-22 and cross-cutting finding 1 record this control as "verified". It is not: the property D-05 calls one-way ("a link created without proof ... cannot be told apart afterwards") does not hold.
|
||||
|
||||
**Failure scenario:** An administrator starts "Link frontend account" and opens `/link-admin?code=…` on a shared or family computer where the site is still signed in as someone else (X). X's session refreshes when any page gets a 401, or X's script calls `/refresh`. The admin clicks "Link the accounts", sees "Your account is now linked", and X's account now holds the admin's backend reach for every MCP client X connects with `backend`. Nothing on the page tells the admin that X, not they, is signed in.
|
||||
|
||||
**Fix:** Bind the proof to an actual authentication event that refresh carries forward unchanged:
|
||||
- Mint an `auth_time` claim at login, registration, social login and 2FA completion. Have `bouncer.refreshAudience` copy the existing `auth_time` into the rotated token instead of resetting it.
|
||||
- In `BackendLinkConfirm`, read `auth_time` (refuse when it is absent) and compare that with `req.CreatedAt`, not `iat`.
|
||||
|
||||
Until then, a smaller fix: record `last_login_at` per sign-in and require `auth_time`/`last_login_at >= created_at` together with a `jti` minted by that login. In `link-admin.vue`, show the signed-in account's email next to the confirm button ("You are signed in as …"), so the admin can catch the wrong account.
|
||||
|
||||
### Warnings
|
||||
|
||||
#### C-WR-01: The one-shot link code links whoever presents it, and it is written to nginx access logs
|
||||
|
||||
**File:** `U routes.go:45-46` and `U controllers/backend_link_controller.go:36-38` (`GET /_user/api/v1/backend-link/{code}`); `U account_contributions.go:122` (`/link-admin?code=<code>`); `V app/pages/link-admin.vue:15-16, 37`; `D deploy/nginx/demo.summercms.io.conf:96` (`location ^~ /_user/`, default access log)
|
||||
**Issue:** `ConfirmLinkRequest` binds the link to the frontend user who confirms. The code is the only proof of the admin's intent, so anyone who sees it within the TTL can sign in to their own account and link it to the admin. The code reaches the server in the URL path of the show call and in the query string of the SSR page load (`/link-admin?code=…`, proxied to Nuxt by `location /`). nginx's default `access_log` records both request lines, as do Nuxt/Nitro request logs and any log shipping. The security review (cross-cutting 6) says "The link code is never logged", which is wrong for these logs. Through `/login?next=/link-admin?code=…` the code also lands in browser history.
|
||||
**Failure scenario:** Someone with read access to the web server logs, or to a log pipeline or analytics collector, takes the code within 10 minutes. They sign in to their own frontend account and POST `/backend-link/confirm`. Their account is now linked to the admin, and a `backend` MCP grant acts as that admin. The admin only sees "link expired or used", and later "Linked to <someone else's email>" on My account.
|
||||
**Fix:**
|
||||
- Keep the code out of every URL the server sees: answer `…/link-admin#code=<code>` (the fragment is not sent or logged), have the page read `location.hash`, and change the show route to `POST /_user/api/v1/backend-link/show` with the code in the JSON body.
|
||||
- Optionally add `access_log off` or a redacting `log_format` for `/link-admin`.
|
||||
- For defence in depth, require the admin to approve on My account the frontend email that confirmed (two-sided confirmation) before the link becomes active.
|
||||
|
||||
#### C-WR-02: A `backend` MCP grant is not bound to the administrator the user consented to; a later link re-targets it silently
|
||||
|
||||
**File:** `O controllers/mcp_consent_api.go:133-145`; `U classes/backend_links.go:322-348` (`RemoveLink`), `:293-320` (`insertLink`); `F pier/identity.go:187-198`; `V i18n/locales/en.json` `connect.actAsAdmin`
|
||||
**Issue:** At consent the page states "It will also act as admin {name} ({login})", and `backend` is granted when some link exists. The grant stores only the scope string. Pier resolves whichever administrator is linked at each request. Unlink fires only `MCPSubjectLink`, which recomputes the tool list. The oauthserver plugin does not listen to `BackendUnlinkedEvent` or `BackendLinkedEvent`, so the token and refresh token keep `backend` after unlinking. When the user is later linked to a different administrator, by self-service or by a holder of `golem15.users.manage_backend_links` via `SetLink`, the old grant resumes with the new admin's permissions, and nobody was asked again. D-08 decided not to store the link in the grant. That decision covers revocation, but not this re-targeting.
|
||||
**Failure scenario:** User U connects an agent while linked to editor admin X (consent shows X). U is unlinked. Months later an administrator links U's email to superuser admin Y for onboarding (no proof needed on that path). U's long-lived agent, running on refresh tokens, now acts as superuser Y, although U only ever approved X.
|
||||
**Fix:** Pick one of these:
|
||||
- Have oauthserver listen to `*userclasses.BackendUnlinkedEvent` and revoke that user's MCP access and refresh tokens that carry `backend` (in the event's transaction), so a new link always needs a new consent.
|
||||
- Store the consented `backend_user_id` with the grant (access and refresh rows) and have the verifier expose it in `pact.MCPGrant`, so pier refuses the backend subject when the current link differs. This is an additive field.
|
||||
|
||||
### Info
|
||||
|
||||
#### C-IN-01: The `journal_draft_post` prompt is listed for read-only grants although it directs a write tool
|
||||
|
||||
**File:** `J mcp.go:154-165, 179-183`; `F pier/filter.go:48-58`
|
||||
**Issue:** `allowsPrompt` applies no read/write ceiling. A `read` grant sees `draft_post`, whose text tells the agent to call `journal_create_post`, a tool that grant does not have.
|
||||
**Fix:** Add an additive `Writes bool` (or `ReadOnly *bool`) to `pact.MCPPrompt` that the ceiling honours, and set it on `draft_post`.
|
||||
|
||||
#### C-IN-02: Revoking one personal token or one OIDC app ends every MCP session of the user
|
||||
|
||||
**File:** `U controllers/api_tokens.go:110-111`; `O controllers/authorizations.go:121-122`; `F pier/events.go:42-50`
|
||||
**Issue:** Both fire `MCPSubjectRevoked` for the whole user. Pier closes every session of that subject, including unrelated OAuth MCP sessions. Clients must re-initialize. Access is not widened, so this is only an availability issue.
|
||||
**Fix:** Fire the event only when the deleted token or client is the one a session is bound to, or carry a token or client id in the event and match on the session binding.
|
||||
|
||||
#### C-IN-03: nginx body cap (2 MiB) is below pier's 4 MiB MCP body cap
|
||||
|
||||
**File:** `D deploy/nginx/demo.summercms.io.conf:65` (server-level `client_max_body_size 2m`), `:213-226` (`location = /mcp`)
|
||||
**Issue:** A `tools/call` between 2 and 4 MiB (for example a long `journal_create_post` body) gets nginx's HTML 413 instead of pier's JSON-RPC error.
|
||||
**Fix:** Add `client_max_body_size 4m;` inside `location = /mcp`, and check it in `check-deploy.sh`.
|
||||
|
||||
#### C-IN-04: The personal-token MCP path does not stamp `last_used_ip`
|
||||
|
||||
**File:** `U classes/mcp_guard.go:169`, compared with `U middleware` `APITokenGuard` (`:71-78`)
|
||||
**Issue:** The `user.api_token` guard records `last_used_ip`. `MCPResolvePersonalToken` stamps only `last_used_at`, so a token used through `/mcp` (with `mcp.allow_personal_tokens` on) shows a stale IP on the tokens page.
|
||||
**Fix:** Pass the client IP through `ctx` (pier copies the client address onto the request) and stamp it as the guard does.
|
||||
|
||||
#### C-IN-05: Dead and duplicated code
|
||||
|
||||
**File:** `U models/backend_link_request.go:27` (`IsUsableAt`, never called; `classes/backend_links.go:193` `requestUsable` duplicates it); `U classes/subject_events.go` and `O classes/subject_events.go` (identical `FireSubjectChanged` and `FireSubjectChangedAfterCommit`); `U account_contributions.go:57-64` and `U controllers/backend_link_controller.go:15-22` (the same `backendLinks` lookup)
|
||||
**Fix:** Have `requestUsable` call `req.IsUsableAt` (keep the error split), and have oauthserver call `userclasses.FireSubjectChanged*` (it already imports U).
|
||||
|
||||
#### C-IN-06: The link page path is hard-coded for every consuming site
|
||||
|
||||
**File:** `U account_contributions.go:122`
|
||||
**Issue:** `golem15.user.frontend_url` sets only the origin. Every site using this core plugin must serve exactly `/link-admin`. A site with locale-prefixed routes, or an API-only `app.url` without `frontend_url`, sends admins to a 404.
|
||||
**Fix:** Add `golem15.user.backend_links.page_path` (default `/link-admin`). This is additive.
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-23_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: deep_
|
||||
191
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md
Normal file
191
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY-REVIEW.md
Normal file
@@ -0,0 +1,191 @@
|
||||
# Phase 19.7 Security Review: generic MCP module
|
||||
|
||||
**Date:** 2026-10-23
|
||||
**Level:** OWASP ASVS L1 (RESEARCH "Security Domain")
|
||||
**Scope:** the framework seams of plan 01 (bouncer dispatch marker, cabana `ResolveBackend` and the account and prompted-action seams, surf's compiled-handler lookup and stream route kind, wristband's scope allow-list), the `pier` module of plan 02, sm-user-plugin's account link, frontend permission catalog and MCP guard (plan 03), sm-oauthserver-plugin's MCP verifier and consent JSON, sm-journal-plugin's MCP tools and the demo wiring (plan 04), and plan 05's gate.
|
||||
**Threats reviewed:** T-19.7-01..T-19.7-41 and T-19.7-SC from the threat models of plans 01-05; T-19.7-42..T-19.7-65 of the gap-closure plans 06-09 in the section "Gap closure (plans 06-09, 2026-10-23)", which also corrects the verdicts the phase code review (`19.7-REVIEW.md`) disproved.
|
||||
**Result:** every threat is verified, fixed in a commit or accepted with a reason. The review found two production defects (a frontend dispatch marker honoured by cabana's `backend` middleware, and an ended session written back by a request still in flight) and fixed both in their own commits. The superuser verdict (D-22, T-19.7-34) is "accepted as designed with audit and ceiling"; no switch was added and no tag is needed for it.
|
||||
|
||||
Repositories and abbreviations used below: **F** = `summercms.go` (framework, paths under `modules/`), **U** = sm-user-plugin (`sm-demo-app/plugins/golem15/user`), **O** = `sm-oauthserver-plugin`, **J** = `sm-journal-plugin`, **D** = `sm-demo-app`, **V** = `sm-demo-app/vue-demo-app`.
|
||||
|
||||
## Method
|
||||
|
||||
1. For each threat, read the code that implements the mitigation and record the file and line (grep-level check at L1, plus a read of the surrounding logic).
|
||||
2. For each threat, find the test that pins the mitigation (the plan 01-04 smokes and the plan 05 tests). Where the code was right but no test pinned it, add the test in the owning repository as its own commit.
|
||||
3. Where the code was wrong, fix it in its own `fix(` commit in the owning repository, then add or extend the pinning test.
|
||||
4. Cross-cutting sweeps (below): link proof, dispatch marker, session binding, scope ceilings, superuser reach, logs, `no-store`.
|
||||
5. Run the phase gate `bash scripts/check-phase19.7.sh --all` on a Docker host: every stage PASS.
|
||||
6. (Added in the gap closure, plan 09.) A high or critical control is "verified" only with a test that fails without it. Reading the code and finding a passing test is not enough: the plan 05 review marked T-19.7-22 verified from a test that never refreshed a token. For the three critical findings of the code review this is shown by a revert-check: the fix is reverted in a scratch worktree, the pinning test fails, and it passes at HEAD (see "Revert-checks" below).
|
||||
|
||||
## Gaps fixed during the review
|
||||
|
||||
| Commit | Repo | Threats | What changed |
|
||||
|--------|------|---------|--------------|
|
||||
| c49983d | F | T-19.7-01, T-19.7-02 (new finding) | `fix(cabana)`: cabana's `backend` middleware (the admin API and every route behind `backend`) honoured a dispatch marker listing the `backend` guard even when its principal was a frontend one, so a frontend user id would have been read as an administrator's. `refuseFrontendMarker` now answers 401 for such a marker before the guard honours it, as `ResolveBackend` already did. Pinned by `TestDispatchMarker` (cabana, Postgres part, commit 3bbbe6c). No framework caller produces such a marker today (pier's backend provider builds backend principals only); this closes the seam for any future dispatcher or guard provider. |
|
||||
| 1111828 | F | T-19.7-15, T-19.7-35, T-19.7-11 | `fix(pier)`: a request that finished after its session ended (DELETE, a `revoked` or `deleted` subject event, the idle expiry) persisted the session state with a plain Put and brought the record back; the next request rehydrated the ended session. The persist step now only rewrites an existing record (Redis `SET XX`, the memory store likewise) and closes the local copy when the record is gone. Found by `TestFanOut` (about one run in a hundred before the fix; 300 consecutive green runs after it). |
|
||||
| 0b8e027 | F | T-19.7-17, T-19.7-18, T-19.7-19, T-19.7-37 | Test pins: `TestEndpointGuards` (foreign Origin 403 before the bearer is read, 413 over the body cap, a GET stream ends once its grant stops verifying), `TestDispatch` refuses an undeclared argument key, the gate requires both and runs the demo's deploy check. Code unchanged. |
|
||||
| 3bbbe6c, f14eae9 | F | T-19.7-01..07, T-19.7-09..20, T-19.7-22 | The validation-map tests of Tasks 1-2 (`TestDispatchMarker` x2, `TestToolsList`, `TestCatalog`, `TestDispatch`, `TestGuardRules`, `TestSessions`, `TestFanOut`, `TestStreamingRoute`, `TestPierMount`, `TestMCPScopes`, `TestAccountContributions`, `TestRecordActionPrompt`, `TestScopeLimitForMethods`). |
|
||||
| 72de822 | U | T-19.7-22..29 | `TestBackendLink`, `TestFrontendPermissionCatalog`, `TestUserMCPGuard`. Code unchanged. |
|
||||
| 2929c91 | O | T-19.7-30..33, T-19.7-35 | `TestMCPTokenVerifier`, `TestMCPConsent`. Code unchanged. |
|
||||
| a9a9b80 | J | T-19.7-36, T-19.7-17 | `TestJournalMCP`. Code unchanged. |
|
||||
| 6fa2d56 | D | T-19.7-13, T-19.7-15, T-19.7-35, SC-4 | `TestMCPEndToEnd` revoke matrix (unlink list_changed, read grant, revoked grant ends the session, personal tokens off). Code unchanged. |
|
||||
|
||||
A third fix found by the tests is functional, not a security gap: c29d228 `fix(pier)` treats a `tools/call` without arguments (or with `null`) as an empty object (`TestDispatch`).
|
||||
|
||||
## Threat register
|
||||
|
||||
| Threat | Mitigation as built | Implementation | Test (repo) | Status |
|
||||
|--------|---------------------|----------------|-------------|--------|
|
||||
| T-19.7-01 | The marker lives under an unexported context key; `Dispatched` is the only reader and answers only for an exact guard name with a principal; no header, cookie or query is read for it; the only non-test caller of `WithDispatch` is pier's dispatcher (the gate's `marker` stage); cabana's `backend` middleware refuses a frontend marker. | F `bouncer/dispatch.go:5`, `:29`, `:40`; F `bouncer/registry.go:86`; F `pier/dispatch.go:159`; F `cabana/http.go:252` | `TestDispatchMarker` (bouncer: forged headers, cookies and query; nil and unlisted markers), `TestDispatchMarker` (cabana: over HTTP the marker never arrives), gate stage `marker` (F) | fixed in commit c49983d |
|
||||
| T-19.7-02 | `ResolveBackend` honours a marker only for guard `backend` with `Principal.Backend`; a frontend marker is `ErrUnauthenticated`; a scoped principal is still checked against the cover codes; the `backend` middleware applies the same rule. | F `cabana/token_guard.go:209-216`; F `cabana/http.go:252` | `TestDispatchMarkerSmoke`, `TestDispatchMarker` (cabana, incl. the in-process admin API case) (F) | fixed in commit c49983d |
|
||||
| T-19.7-03 | `Router.Handler` returns the fully compiled chain (constraints, named middleware, body limit, recovery, CORS profile, pattern), the same chain the mux serves. | F `surf/routetable.go:49`; F `surf/router.go:373` | `TestDispatchSmoke` (F), `TestDispatchMarker` (cabana, Journal-shaped route through `Handler`) (F) | corrected: fixed in 104db99 (F); was verified (see Corrections) |
|
||||
| T-19.7-04 | `recoverStream` writes the opaque 500 only before the first header, byte or flush; afterwards the body is cut short and the panic value is never written. | F `surf/streaming.go:63-80` | `TestStreamingRouteSmoke`, `TestStreamingRoute` (F) | verified |
|
||||
| T-19.7-05 | `mcp.enabled: true` without the build tag fails boot naming `summercms_mcp`. | F `surf/router.go:701` | `TestPierMountSmoke`, `TestPierMount` (untagged branch) (F) | verified |
|
||||
| T-19.7-06 | Account contribution routes sit behind the `backend` guard and `interactiveOnly` (personal tokens refused), `requireAjax` on POST, `allowAction` for the action's permissions, `Applies` re-checked before `Run` (409), `Run` inside a transaction with only the signed-in admin's id. | F `cabana/http.go:319`; F `cabana/account_contributions.go:169-181`, `:189` | `TestAccountContributionsSmoke`, `TestAccountContributions` (incl. the Postgres transaction case) (F) | verified |
|
||||
| T-19.7-07 | `payload` is accepted only for an action with a Prompt, only as a JSON string, trimmed, non-empty and capped in runes; every other record action still refuses a payload; a plain action runs with an empty Value. | F `cabana/actions.go:217`, `:256` | `TestRecordActionPromptSmoke`, `TestRecordActionPrompt`, `TestRecordActionPromptRun` (F) | verified |
|
||||
| T-19.7-08 | Contributed labels, statuses, messages and URLs render as text and attributes (no `v-html`); a URL opens with `noopener` and the visible link carries `rel="noopener noreferrer"`. | F `admin/src/components/account/AccountContributions.vue` | `admin/tests/account/AccountContributions.test.ts` ("Text, never HTML", URL attributes) (F) | corrected: fixed in 44835e4, 88559d5 (F); was verified (see Corrections) |
|
||||
| T-19.7-09 | wristband's authorize allow-list is exactly `Options.ScopesSupported`; the default server refuses `backend`; `openid` and unlisted scopes stay refused on the MCP flavour. | F `wristband/authorize.go:31`, `:231` | `TestMCPScopesSmoke`, `TestMCPScopes` (F) | verified |
|
||||
| T-19.7-10 | Every request re-verifies its bearer (`auth.RequireBearerToken` with pier's resolver); a session never replaces it; a failure is 401 with the RFC 9728 challenge and `scope="read"`. | F `pier/pier.go:235-260`; F `pier/identity.go:144` | `TestPierTracerSmoke` (bad bearer), `TestEndpointGuards` (stream ends after revocation), `TestMCPEndToEnd` "revoked token" (F, D) | verified |
|
||||
| T-19.7-11 | The session record stores only the binding (`oauth:<client>:<user>` or the personal token id), compared on every POST, GET and DELETE (403 `session_binding`); ids from `rand.Text()`; sliding idle TTL; per-binding cap. | F `pier/session.go:143`, `:211`, `:242`, `:139` | `TestPierSessionsSmoke`, `TestSessions` (Redis and memory) (F) | verified |
|
||||
| T-19.7-12 | The inner request is built fresh (`httptest.NewRequestWithContext`) with no Authorization or Cookie; identity travels only in the marker; client address, X-Forwarded-For, X-Real-IP and Accept-Language are copied. | F `pier/dispatch.go:159-180` | `TestPierTracerSmoke` (echo route `auth: false`), `TestDispatch` (outer Cookie and Authorization absent) (F) | verified |
|
||||
| T-19.7-13 | A backend subject exists only with `backend` in the grant AND a link the resolver confirms per request (5 s cache), or an admin `g15_` token behind `mcp.allow_personal_tokens`; the read/write ceiling applies on top; list and call use the same `allowed`. | F `pier/identity.go:152`, `:187-198`; F `pier/filter.go:16`, `:37` | `TestToolsList` (no link, no backend tool; union with a link), `TestPierTracerSmoke` "personal tokens behind the flag", `TestMCPEndToEnd` (no backend tool without the scope) (F, D) | verified |
|
||||
| T-19.7-14 | One SDK server per identity; the receiving middleware re-filters `tools/list` and refuses `tools/call` and `prompts/get` outside the current request's list (JSON-RPC error, the route is never reached); stateless servers are keyed by binding. | F `pier/session.go:493`; F `pier/stateless.go:80` | `TestToolsList` (per principal; unlisted call never reaches the route), `TestPierStatelessSmoke` (F) | verified |
|
||||
| T-19.7-15 | Rehydration builds the server from the current bearer's identity, never from stored state; `revoked`/`deleted` events delete the record and close local copies on every instance; a request finishing after the end no longer writes the record back; link events drop the link cache and recompute. | F `pier/session.go:230-280`, `:320-360`; F `pier/events.go:42-60`; F `pier/store_redis.go` (`Update`) | `TestFanOut` (revocation, deletion, link change, cache bypass), `TestSessions`, `TestMCPEndToEnd` "revoked grant ends the session" (F, D) | fixed in commit 1111828 |
|
||||
| T-19.7-16 | Only `oas_at_` tokens reach the verifier; the verifier accepts only rows of a kind-`mcp` client; PRM `resource` is `mcp.resource` and a boot warning names a mismatch with the verifier's resource. | F `pier/identity.go:149`; F `pier/prm.go:23-31`; O `classes/mcp_verifier.go:79-88` | `TestMCPTokenVerifierSmoke` (OIDC client's token refused), `TestMCPEndToEnd` "protected resource metadata" (O, D) | verified |
|
||||
| T-19.7-17 | Arguments are validated against the reflected schema (additionalProperties false, required fields); a single-segment value may not contain `/`; path and query keys are removed from the forwarded body; the route's own constraints and body limit still run. | F `pier/dispatch.go:85`, `:102`; F `pier/catalog.go:209`, `:340` (`inputFields`) | `TestDispatch` (undeclared key refused, `a/b` refused, omitted fields absent), `TestJournalMCP` (input keys are the route's keys) (F, J) | corrected: fixed in 104db99 (F); was fixed in commit 0b8e027 (test pin; code unchanged) (see Corrections) |
|
||||
| T-19.7-18 | Inline `mcp.throttle` on the endpoint routes, `max_per_binding` (429), idle TTL, 4 MiB body cap, `mcp.call_timeout`, `mcp.max_result_bytes`, stream re-verification every minute. | F `pier/pier.go:122`, `:225`; F `pier/session.go:139`, `:369`; F `pier/dispatch.go:145`, `:186` | `TestPierMount` (tagged: `throttle:120,1`), `TestStreamingRoute` (throttle on a stream route), `TestSessions` (429), `TestDispatch` (timeout, size cap), `TestEndpointGuards` (413, stream re-verification) (F) | corrected: fixed in 2bf9dca, c1c0c77 (F); was fixed in commit 0b8e027 (test pin; code unchanged) (see Corrections) |
|
||||
| T-19.7-19 | `originCheck` answers 403 for a browser Origin outside `mcp.allowed_origins` (default: the app's own origin) before the bearer or the body is read; no Origin passes. | F `pier/pier.go:201-220` | `TestEndpointGuards` "origin check" (F) | fixed in commit 0b8e027 (test pin; code unchanged) |
|
||||
| T-19.7-20 | The audit line carries tool, guard, user/admin/client ids, token kind, an 8-character session prefix, status and duration; never a token, argument or body. | F `pier/audit.go:40-66` | `TestPierTracerSmoke` "audit line" (F) | verified |
|
||||
| T-19.7-21 | Descriptions are plugin-authored static text, capped at 1024 runes at boot. | F `pier/catalog.go:21` | `TestCatalog` (boot refusals) (F) | accepted (see Accepted risks) |
|
||||
| T-19.7-SC | The user approved go-sdk v1.8.0 and jsonschema-go v0.4.3 before `go get`; versions pinned in go.mod; the decision note lists the transitive graph and govulncheck; the SDK links only into tagged binaries. | F `.planning/notes/2026-10-22-mcp-go-sdk.md`; F `.planning/research/STACK.md:56-57`; F `go.mod` | gate stages `docs` (note and STACK rows) and `go` (the untagged hello binary links no SDK) (F) | verified |
|
||||
| T-19.7-22 | The self-service path writes a link only inside `ConfirmLinkRequest`: a one-shot hashed code bound to the admin, row lock, `jwt.auth` principal equal to the session token's subject, and the token's `auth_time` (the sign-in, which a refresh copies and never renews) not before the request's `created_at` (in seconds); a token without `auth_time` is `stale_session`; no email match and no user list | U `classes/backend_links.go:250` (`ConfirmLinkRequest`, `sessionAuthTime`); U `controllers/backend_link_controller.go:102` (`bouncer.VerifyAuthTime`); F `bouncer/jwt.go:214`, `bouncer/refresh.go:92` | `TestBackendLinkAuthTime` (U, revert-checked), `TestAuthTime` (F), `TestBackendLinkAuthTimeSmoke`, `TestBackendLink` (U) | corrected: fixed in c14238b (F), 32f9259 (U); was verified (see Corrections) |
|
||||
| T-19.7-23 | 64-hex code stored as SHA-256, `used_at` set in the linking transaction, expired, used and unknown codes all 404; the show route answers only the admin's login and name and the expiry. | U `classes/backend_links.go:105`, `:129`; U `controllers/backend_link_controller.go:47` | `TestBackendLinkSmoke` (replay, expiry), `TestBackendLink` (show route keys) (U) | corrected: fixed in 32f9259 (U), 0125e29 (V); was verified (see Corrections) |
|
||||
| T-19.7-24 | Admin-set links need `golem15.users.manage_backend_links` (no default role), match an exact email, record `linked_by`, fire `BackendLinkedEvent` and both subject events after commit; cabana's outranking check runs first; 1:1 refuses a second link. | U `backend_links_admin.go:33`, `:50`, `:99`; U `classes/backend_links.go:269-325` | `TestBackendLinkAdminSmoke`, `TestBackendLink` ("SetLink and RemoveLink events", none after a rollback) (U) | verified |
|
||||
| T-19.7-25 | Confirm is a POST behind `jwt.auth` with the bearer re-read for `iat`; My account link and unlink run behind the backend guard, `interactiveOnly` and `requireAjax`; no state change on GET. | U `controllers/backend_link_controller.go:60-74`; F `cabana/http.go:319` | `TestBackendLinkSmoke` (anonymous confirm 401), `TestAccountContributions` (personal token refused) (U, F) | verified |
|
||||
| T-19.7-26 | `LinkedBackendUser` is one indexed query per call (no plugin cache) excluding deleted or deactivated admins and deleted users; user deletion and deactivation remove the link in their transaction and fire events after commit. | U `classes/backend_links.go:382-412`, `:455-490` | `TestBackendLink` ("deactivated or deleted administrator", "deactivating the frontend user"), `TestBackendLinkSmoke` (delete) (U) | verified |
|
||||
| T-19.7-27 | `MCPAllows` evaluates the route's scopes and every permission code (route's and tool's) with the same group grants `user.permission` checks; an unknown `user.*` middleware fails boot. | U `classes/mcp_guard.go:58-117` | `TestUserMCPGuardSmoke`, `TestUserMCPGuard` (parser refusals, deleted user, dispatch credential against `user.scope:read`) (U) | verified |
|
||||
| T-19.7-28 | Personal tokens resolve only for the plugin's prefix, by hash, `IsUsableAt` (revoked and expired refused) and a loadable user; the subject carries the token's own scopes; the dispatch credential is in memory (ID 0); personal tokens at `/mcp` need `mcp.allow_personal_tokens` (off by default and in the demo). | U `classes/mcp_guard.go:143-172`; F `pier/identity.go:152`; D `config/mcp.yaml:19` | `TestUserMCPGuard` (expired token, deleted user, ID 0 credential), `TestMCPEndToEnd` "personal tokens are off" (U, D) | verified |
|
||||
| T-19.7-29 | `linked_by` on admin-set links, `created_at` on links and requests, link and unlink events, cabana's record action audit. | U `classes/backend_links.go:293-322` | `TestBackendLinkAdminSmoke`, `TestBackendLink` (`linked_by`) (U) | verified |
|
||||
| T-19.7-30 | The verifier gate: `oas_at_` prefix, hash lookup, not revoked, not expired, client of kind `mcp`, active and not revoked, user loadable. | O `classes/mcp_verifier.go:55-110` | `TestMCPTokenVerifierSmoke`, `TestMCPTokenVerifier` (deactivated client, user deactivated after minting, conditional stamp) (O) | verified |
|
||||
| T-19.7-31 | The consent JSON shows the client name (capped), the redirect host and the linked admin only when `backend` was requested and a link exists; `backend` is granted only with a link at consent. | O `controllers/mcp_consent_api.go:54-92`, `:134-142` | `TestMCPConsentSmoke` ("no link", "linked") (O) | corrected: fixed in 671513d (O), 970719c (U); was verified (see Corrections) |
|
||||
| T-19.7-32 | `PendingRequest`, `IssueCode` and `DenyPending` resolve the request for the acting JWT principal only; a foreign or replayed request is 404; answers are `no-store, private`. | F `wristband/consent.go:47`, `:74`, `:106`, `:130`; O `controllers/consent_api.go:123-133` | `TestMCPConsentSmoke` (foreign request), `TestMCPConsent` (replayed decision, no-store) (O) | verified |
|
||||
| T-19.7-33 | granted = submitted ∩ requested, minus `backend` without a link; an empty grant is 422 `no_grantable_scopes`; a non-JSON body is 400. | O `controllers/mcp_consent_api.go:105-165` | `TestMCPConsentSmoke`, `TestMCPConsent` (extra scopes dropped, `scopes: []`, form body) (O) | verified |
|
||||
| T-19.7-34 | The backend principal is the admin's real principal, superuser included (D-22). Reach is bounded by: the explicit `backend` scope on the consent page with the admin's name, the fresh-sign-in link proof, the read/write ceiling, the tools plugins declare (no generic admin API), the per-call audit line with admin_id and client_id, and per-request re-checks. | F `pier/backend_guard.go:59-100`; F `pier/audit.go:40` | `TestToolsList` (ceiling, union), `TestScopeLimitForMethods` (an admin token's scope per method), `TestMCPEndToEnd` (read grant hides write tools) (F, D) | accepted (see Superuser reach) |
|
||||
| T-19.7-35 | Revocation from the authorized-apps list and the user cascade fire `revoked`/`deleted` events that end sessions everywhere; the verifier refuses a revoked token on the next request; an ended session is no longer written back. MCP grants have no consent row, so the authorized-apps list cannot revoke them yet (a revoked client or deleted user still ends every grant). | O `controllers/authorizations.go:101-122`; O `classes/cascade.go:68`; F `pier/events.go:42`; F `pier/session.go:320` | `TestMCPConsentSmoke` ("revocation fires revoked", "cascade fires deleted"), `TestMCPEndToEnd` ("revoked token", "revoked grant ends the session"), `TestFanOut` (O, D, F) | corrected: fixed in 970719c (U), 671513d (O); was fixed in commit 1111828 (see Corrections); the missing self-service revoke stays accepted |
|
||||
| T-19.7-36 | Journal's update input fields are pointers or `omitempty`; pier forwards the agent's raw JSON minus path keys, so omitted fields stay omitted. | J `mcp.go:52` (`mcpUpdatePostInput`); F `pier/dispatch.go:91-123` (path and query keys removed from the forwarded body) | `TestDispatch` ("argument split": omitted `note` absent), `TestJournalMCP` (input keys) (F, J) | verified |
|
||||
| T-19.7-37 | pier's inline throttle, idle TTL and per-binding cap; nginx opens exactly `= /mcp` (unbuffered, 1 h read timeout), the two MCP metadata paths and `/oauth/mcp/`; `check-deploy.sh` refuses anything else. | D `deploy/nginx/demo.summercms.io.conf:213-224`; D `scripts/check-deploy.sh` | gate stage `consumers` runs `check-deploy.sh`; `TestPierMount` (tagged throttle) (D, F) | fixed in commit 0b8e027 (gate pin; config unchanged) |
|
||||
| T-19.7-38 | The consent page navigates only to the `redirect_uri` the server answers, which wristband builds from the client's registered URI; the login hop keeps a same-origin `next`. | V `app/pages/connect.vue:48`, `:57`, `:70-75`; F `wristband/consent.go:74-128` | `TestMCPConsentSmoke` ("deny": the redirect carries the registered URI's state) (O) | verified |
|
||||
| T-19.7-39 | Every required test is listed by name; the detectors refuse failed, skipped, zero-match, "no tests to run" and missing names; the self-test proves them on planted output; docker is NOT RUN only without a daemon and fails with `PHASE197_REQUIRE_DOCKER=1`. | F `scripts/check-phase19.7.sh` (`detect_go`, `detect_vitest`, `run_self_test`, `docker_gate`) | `bash scripts/check-phase19.7.sh --self-test`; the go stage refused `TestFireSubjectChangedWaitsForCommit` when it skipped under `-short` during this plan (F) | verified |
|
||||
| T-19.7-40 | The `marker` stage fails on any non-test caller of `WithDispatch` outside `modules/pier` and `modules/bouncer` and on a `modules/pact` dependency on the SDK, jsonschema-go or bouncer. | F `scripts/check-phase19.7.sh` (`run_marker`, `marker_callers`) | `--self-test` (planted caller found, pier and test files ignored), `--marker` (F) | verified |
|
||||
| T-19.7-41 | Tests mint their own tokens and codes on throwaway Postgres containers and miniredis; no fixture holds a production credential; the docs stage keeps consuming applications out of the phase's framework tests. | F `modules/pier/helpers_test.go` (fake grants); U, O, D test harnesses (testcontainers) | gate stage `docs` (names) (F) | verified |
|
||||
|
||||
## Cross-cutting findings
|
||||
|
||||
1. **Link proof** (corrected in gap closure, C-CR-02). The only writers of `golem15_user_backend_links` are `insertLink` (called by `ConfirmLinkRequest` and `SetLink`) and the deletes in `RemoveLink`; `SetLink` has one non-test caller, the permission-guarded Administrators record action (U `backend_links_admin.go:99`, behind `golem15.users.manage_backend_links` and cabana's outranking check). The plan 05 review accepted a confirm that compared the token's `iat` with the request's `created_at`; a `POST /refresh` renews `iat`, so a browser signed in long before the request passed after one refresh. Since c14238b (F) every sign-in token carries `auth_time`, which refresh copies unchanged, and since 32f9259 (U) the confirm reads it with `bouncer.VerifyAuthTime` (U `controllers/backend_link_controller.go:102`) and compares it in whole seconds with `created_at` (U `classes/backend_links.go:250`); a token without `auth_time` is `stale_session`, and the token's subject must equal the `jwt.auth` principal. Pinned by `TestBackendLinkAuthTime` (refresh after the request stays stale; revert-checked) and `TestAuthTime`.
|
||||
2. **Dispatch marker.** The only non-test caller of `bouncer.WithDispatch` is F `pier/dispatch.go:159` (gate stage `marker`). Nothing reads a header, cookie or query string for it (`TestDispatchMarker` sends all three). `ResolveBackend` and, since c49983d, the `backend` middleware refuse a frontend marker. The inner request carries no Authorization or Cookie (`TestDispatch`).
|
||||
3. **Session binding.** The binding is compared on every stateful POST, GET and DELETE (F `pier/session.go:211`, `:242`); DELETE and revocation remove the record through the store and close every instance's copy (`TestSessions`, `TestFanOut`); rehydration takes identity from the current bearer (the stored record holds only binding, protocol state and creation time). Since 1111828 an ended session cannot be written back by a late request.
|
||||
4. **Scope ceilings.** `read` hides tools whose annotations are not read-only (F `pier/filter.go:37`, `TestToolsList`, `TestMCPEndToEnd` "read grant"); `backend` without a link yields no backend subject (F `pier/identity.go:187`, `TestToolsList`); consent drops `backend` without a link (O `controllers/mcp_consent_api.go:134`, `TestMCPConsentSmoke`); personal tokens carry their own scopes and are off by default (F `pier/config.go`, `TestPierTracerSmoke`, `TestMCPEndToEnd`); an admin token's scope is filtered per dispatched method (`TestScopeLimitForMethods`, `TestGuardRules`).
|
||||
5. **Superuser reach (P-23, D-22).** See the section below.
|
||||
6. **Logs** (corrected in gap closure, C-WR-01). pier logs ids, names, statuses, durations, an 8-character session prefix and the binding key (`oauth:<client>:<user>`, which holds no secret); store errors carry cooler's fixed texts, not the Redis URL (F `cooler/redis.go:28-32`). The verifier's only log line names the token id (O `classes/mcp_verifier.go`). The plan 05 review said the link code stays out of every log; that was false: My account answered `/link-admin?code=<code>`, so the code reached the site's nginx and request logs, the browser history and the `GET /backend-link/{code}` access line. Since 32f9259 (U) and 0125e29 (V) the code travels only in the URL fragment (`#code=`), which a browser never sends, and in the body of `POST /backend-link/show` (`Cache-Control: no-store, private`); the page keeps it in sessionStorage across the sign-in and removes the fragment (U `account_contributions.go:120`, `controllers/backend_link_controller.go:45`; V `app/lib/linkCode.ts:20`, `app/pages/link-admin.vue:55`). The GET show route stays for compatibility and is documented as deprecated. No token, argument or body appears in any line (`TestPierTracerSmoke` "audit line"); the link transport is pinned by `TestBackendLinkShowPost` and `app/lib/linkCode.test.ts`.
|
||||
7. **`no-store`.** Every consent answer (show, decide, refusals) carries `Cache-Control: no-store, private` (`TestMCPConsent`). The link show and confirm answers carry `no-cache, private` (U `controllers/api_controller.go:1266`) and hold neither the code nor a token. The one answer that carries a link code, My account's "link" action, is a POST response of the admin API, which shared caches do not store without explicit freshness; accepted at L1.
|
||||
|
||||
## Superuser reach
|
||||
|
||||
**Verdict: accepted as designed with audit and ceiling. `mcp.refuse_superuser_backend` is not added.**
|
||||
|
||||
Reasons:
|
||||
|
||||
- Scope of reach. An agent acting as a linked superuser reaches only the tools plugins declare (`pact.HasMCP`), each bound to one route; there is no generic admin API tool. The reach is that of the declared backend tools (today the seven Journal tools), not of the admin panel.
|
||||
- Consent. The backend grant requires the frontend user to request it, see "also act as <admin name>" on the consent page, and hold a link made by a fresh-sign-in proof or by an administrator with `manage_backend_links`.
|
||||
- Ceiling. A `read` grant hides every tool that is not read-only; scopes are per grant and the verifier refuses a revoked grant on the next request.
|
||||
- Audit. Every call is logged with tool, admin_id, client_id and status.
|
||||
- A switch would refuse a legitimate use (a solo site owner who is the superuser and the only author) while a cautious site already has the alternative: link the agent's frontend account to a non-superuser administrator with exactly the permissions the agent needs.
|
||||
|
||||
Revisit when a plugin declares a superuser-only or destructive backend tool beyond content editing; the switch is then a `fix(pier)` plus README and docs and a framework patch tag (recorded in deferred-items.md as a conditional follow-up).
|
||||
|
||||
## Accepted risks
|
||||
|
||||
| Risk | Threat | Reason |
|
||||
|------|--------|--------|
|
||||
| Tool and prompt descriptions are passed to agents unchanged | T-19.7-21 | They are static text the plugin author writes (capped at 1024 runes); dynamic text in a description is a plugin bug. The docs page tells authors to keep them factual. |
|
||||
| Superuser reach through an agent | T-19.7-34 | See "Superuser reach". |
|
||||
| No self-service revoke of an MCP grant | T-19.7-35 | MCP grants write no consent row, so the authorized-apps list neither lists nor revokes them (deferred-items.md). Access still ends: an administrator can revoke the client, deleting or deactivating the user ends every grant, the access token expires, and a revoked token is refused at once. A consent row per MCP grant is the follow-up. |
|
||||
| A POST response carrying a link code has no explicit `no-store` | cross-cutting 7 | POST responses are not stored by shared caches without explicit freshness; the code is one-shot, expires in 10 minutes and needs the frontend user's fresh sign-in. |
|
||||
| Stateful sessions run with the SDK's 2025-03-26 stream defaults; an `initialized` notification may land on another instance | T-19.7-11, T-19.7-15 | deferred-items.md (open). Both are availability details of multi-instance deployments; identity, binding and revocation checks are unaffected. The demo runs one instance. |
|
||||
|
||||
## Residual items
|
||||
|
||||
- Framework fixes c49983d, c29d228 and 1111828 are on framework master only: applications pinning summercms v0.4.4 (the demo release build, oauthserver v0.1.2, Journal v0.2.3) do not carry them until the next framework tag (v0.5.0 at phase completion). Recorded in deferred-items.md.
|
||||
- The plugin test commits (U 72de822, O 2929c91, J a9a9b80) and the demo test commit (D 6fa2d56) are local and untagged; they change no shipped code.
|
||||
- The real MCP client check against the demo (plan 04) is still a manual item.
|
||||
|
||||
## Suites run for this review
|
||||
|
||||
`bash scripts/check-phase19.7.sh --all` on a Docker host: self-test, go (framework `go vet` untagged and tagged, `go test -short ./...`, examples/hello, the tagged build, the required names untagged and tagged), plugins (vet, short tests and additive checks of the user, OAuth server and blog plugins), consumers (fonoteka.go, sm-bm-app, sm-demo-app untagged and tagged, the pin check, the deploy check), admin (typecheck, vitest, OpenAPI, dist), docs, marker, docker (cabana, user plugin, OAuth server and demo Postgres suites) all PASS.
|
||||
|
||||
## Gap closure (plans 06-09, 2026-10-23)
|
||||
|
||||
The deep code review after plan 05 (`19.7-REVIEW.md`, three lanes: A pier, B framework auth, cabana and the admin SPA, C the plugins and the demo) found 3 critical, 17 warning and 20 info findings. Plans 06-08 fixed every critical and warning finding and the info findings that were cheap; plan 09 added a named test for every fix, extended the gate and wrote this section. Two escalations from an application team rode along: E-1 (an organisation logo) and E-2 (plugin-declared scopes for member `usr_` tokens, decision note `.planning/notes/2026-10-23-frontend-token-scopes.md`).
|
||||
|
||||
One production defect surfaced while plan 09 wrote its tests and was fixed in the user plugin: deleting an organisation left its avatar and logo attachment rows and blobs behind. 25b9f2e fixed it before the test commit; 38551a4 moved the cleanup to a new `FormAfterDelete` hook so that `FormBeforeDelete` keeps its declaration and the plugin stays additive. Pinned by `TestOrganisationLogo`.
|
||||
|
||||
### Corrections
|
||||
|
||||
Earlier verdicts of this review that the code review disproved. The register rows above carry the new status.
|
||||
|
||||
| Threat | Earlier verdict | Finding | What was wrong | Fix commit(s) | Pinning test |
|
||||
|--------|-----------------|---------|----------------|---------------|--------------|
|
||||
| T-19.7-22 | verified | C-CR-02 | The link proof compared the session token's `iat` with the request's `created_at`. A `POST /refresh` renews `iat`, so a browser signed in long before the request (or a stolen refresh-capable token) passed the "fresh sign-in" check after one refresh. The test that "verified" it never refreshed a token. | c14238b (F: `auth_time` at sign-in, copied by refresh, `bouncer.VerifyAuthTime`), 32f9259 (U: the confirm reads `auth_time`) | `TestBackendLinkAuthTime` (U, revert-checked), `TestAuthTime` (F) |
|
||||
| cross-cutting 1 | link proof sound | C-CR-02 | Same defect, stated as a property of every link: the proof rested on `iat`. Rewritten in place above. | c14238b, 32f9259 | `TestBackendLinkAuthTime` |
|
||||
| cross-cutting 6 | no log line carries the link code | C-WR-01 | The review stated that the link code stays out of logs. My account handed the code over in the query string of the site URL, so it reached nginx and site request logs, the browser history and the GET show route's access line. Rewritten in place above. | 32f9259 (U: `#code=` fragment, `POST /backend-link/show`, `no-store`), 0125e29 (V: the page reads the fragment and keeps the code in sessionStorage) | `TestBackendLinkShowPost` (U), `app/lib/linkCode.test.ts` (V) |
|
||||
| T-19.7-23 | verified | C-WR-01 | The one-shot code was treated as secret while its transport leaked it (see cross-cutting 6); whoever read a log line could link their own signed-in account in the 10-minute window. | 32f9259, 0125e29 | `TestBackendLinkShowPost`, `TestBackendLinkAuthTimeSmoke` (U) |
|
||||
| T-19.7-03 | verified | A-WR-01, A-WR-02 | `Router.Handler` hands pier the compiled route chain, but the mux's path cleaning is not part of that chain: dispatched path values reached routes with `..`, `.` and empty segments, and an optional path field left `{key}` literal with an empty path value. | 104db99 (F) | `TestDispatchHardening`, `TestCatalogPathFields` (F) |
|
||||
| T-19.7-17 | fixed in 0b8e027 (test pin; code unchanged) | A-WR-01, A-WR-02 | The same gap seen from argument injection: the schema check and the `/` refusal left traversal segments and missing path values through. | 104db99 | `TestDispatchHardening`, `TestCatalogPathFields` |
|
||||
| T-19.7-18 | fixed in 0b8e027 (test pin; code unchanged) | A-CR-01, A-WR-03 | Stateful sessions whose record expired were never closed on the instance holding them (an unbounded server and goroutine leak; the idle TTL only removed the record), and `max_per_binding` was check-then-act, so concurrent initializes exceeded it. | 2bf9dca (reaper), c1c0c77 (atomic reservation) (F) | `TestSessionReaper` (revert-checked), `TestSessionReserve` (F) |
|
||||
| T-19.7-08 | verified | B-WR-03 | Contributed text rendered as text, but an action's URL went into `href` and `window.open` unchecked: a `javascript:` URL would execute on the admin origin. | 44835e4 (cabana keeps http(s) and same-origin paths only), 88559d5 (SPA `safeUrl` on both sinks) (F) | `TestAccountContributionURL` (F), `admin/tests/account/AccountContributions.test.ts` |
|
||||
| T-19.7-31 | verified | C-WR-02 | Consent showed the linked administrator, but the `backend` grant was bound to the user, not to that administrator: unlinking and linking to another administrator silently re-targeted a live grant. | 671513d (O: backend-scoped MCP tokens revoked on every link change, client-specific events), 970719c (U: the link events the cascade listens to) | `TestMCPGrantRevocation` (O), `TestMCPRevocationEndToEnd` (b), `TestMCPEndToEnd` "a link change ends the backend grant" (D) |
|
||||
| T-19.7-35 | fixed in 1111828 | C-CR-01 | Revocation was pinned for client revocation, deletion and deactivation only. A ban or a password reset left every MCP grant (and the linked administrator's reach) alive: the verifier and the refresh grant did not look at bans or `tokens_valid_after`. | 970719c (U: `AccessRevokedEvent` from ban, reset, change and admin-set password; banned users lose the link), 671513d (O: verifier and refresh refuse; MCP and OIDC grants revoked) | `TestMCPVerifierRevocation` (O, revert-checked), `TestMCPGrantRevocation` (O), `TestAccessRevocation` (U), `TestMCPRevocationEndToEnd` (a) (D) |
|
||||
|
||||
### Revert-checks
|
||||
|
||||
P-41: each critical finding's fix was reverted in a scratch worktree under the session scratch directory (`git worktree add --detach … HEAD`, then `git revert --no-commit <fix>`), the test files kept at HEAD, and the single pinning test run; the worktree was then removed (`git worktree remove --force`, `git worktree prune`). Nothing was committed from a worktree. At HEAD all three pass (gate run below).
|
||||
|
||||
| Repository | Fix | Test | With the fix reverted | At HEAD |
|
||||
|------------|-----|------|-----------------------|---------|
|
||||
| F `summercms.go` | 2bf9dca (A-CR-01, the session reaper) | `TestSessionReaper` | FAIL `reaper_test.go:79: reaped = 0, want 1` (memory store); the Redis case keeps B's copy past the expiry, the GET stream outlives its record, the store-error and `ephemeral` lines are missing. Worktree at ccf77b9; the revert's conflicts in `pier.go` and `export_test.go` were resolved keeping the later commits (the Redis warm-up of 2404572, the later test seams) and the `ReapNow` seam answers 0 because `reapOnce` is gone. | PASS |
|
||||
| O `sm-oauthserver-plugin` | 671513d (C-CR-01, verifier and grant revocation) | `TestMCPVerifierRevocation` | FAIL `mcp_revocation_test.go:98: created two seconds before the cutoff: verify = <nil>, want pact.ErrMCPTokenInvalid`; all five subtests fail (same-second cutoff, untruncated `Before` "0 revoked, 2 live", banned user accepted, a deleted user's refresh answered 200). Worktree at 65f71dc with a scratch go.work (framework and user plugin by absolute path). | PASS |
|
||||
| U `sm-user-plugin` | 32f9259 (C-CR-02, the confirm reads `auth_time`): the confirm handler only, restored to its pre-fix `iat` body | `TestBackendLinkAuthTime` | FAIL `backend_link_auth_time_test.go:64: confirm = 200 …, want 409 with "stale_session"` (login, request, refresh, confirm) and `:86` (a token without `auth_time` links). The framework's `auth_time` cannot be reverted from the plugin worktree, so only the plugin side was reverted. Worktree at 38551a4, `go mod edit -replace` to the framework's absolute path, `GOWORK=off`. | PASS |
|
||||
|
||||
### New threats
|
||||
|
||||
| Threat | Mitigation as built | Implementation | Test (repo) | Status |
|
||||
|--------|---------------------|----------------|-------------|--------|
|
||||
| T-19.7-42 | A reaper started at Mount closes every local session copy whose store record is gone, every min(idle_ttl/2, 1m); a store error keeps the copy; the GET stream re-check ends a stream whose record is gone; `expired` and `ephemeral` audit labels. | F `pier/session.go:501` (`reapOnce`), F `pier/pier.go:145` | `TestSessionReaper` (revert-checked), `TestPierReaperSmoke` (F) | fixed in 2bf9dca |
|
||||
| T-19.7-43 | The per-binding slot is reserved atomically before the server is built (memory store under its lock, Redis in one Lua script) and released when connect or initialize fails; a store without the reservation falls back to Count then Put. | F `pier/session.go:145`, F `pier/store_memory.go:102`, F `pier/store_redis.go:165` | `TestSessionReserve` (50 concurrent initializes on memory and on miniredis across two instances) (F) | fixed in c1c0c77 |
|
||||
| T-19.7-44 | Path values the mux never delivers (`..`, `.`, empty segments, `/` in one segment) and missing path values are refused before dispatch; a path field must be required at boot; an embedded struct on a GET or DELETE tool fails boot. | F `pier/dispatch.go:126`, `:146`; F `pier/catalog.go:223`, `:251` | `TestDispatchHardening`, `TestCatalogPathFields` (F) | fixed in 104db99 |
|
||||
| T-19.7-45 | A provider or database error answers the fixed text `pier: the tool could not be run for this caller`; the error is logged server-side only. | F `pier/dispatch.go:30`, `:187` | `TestDispatchHardening` "a provider error answers the fixed text and is only logged" (F) | fixed in 104db99 |
|
||||
| T-19.7-46 | A personal-token subject without a TokenID is refused (401), so no two users share `pat:user:0`. | F `pier/identity.go:270` | `TestPersonalTokenBinding` (F) | fixed in 2404572 |
|
||||
| T-19.7-47 | The Redis store is opened and subscribed at Mount (warm-up with backoff) and kicked by every request; a `subscriptions/listen` stream re-checks its bearer; an LRU eviction closes the evicted server's streams. | F `pier/store_redis.go:279`; F `pier/stateless.go:116`, `:166` | `TestStatelessFanOut` (F) | fixed in 2404572 |
|
||||
| T-19.7-48 | Servers are built and connected outside the router-wide locks and inserted with a re-check, so one slow guard check stalls no other session. | F `pier/session.go:174`; F `pier/stateless.go:137` | `TestLockScope` (call, DELETE and stateless request finish while an initialize blocks in a guard), `go test -race ./modules/pier` (F) | fixed in c1c0c77 |
|
||||
| T-19.7-49 | A dispatch whose guard list or principal kind contradicts the tool's guard is refused with the fixed text and logged. | F `pier/dispatch.go:198` | `TestDispatchHardening` "a dispatch contradicting the tool's guard is refused" (F) | fixed in 104db99 |
|
||||
| T-19.7-50 | `pact.MCPPrompt.Writes` puts a prompt under the read/write ceiling; Journal's `draft_post` declares it. | F `pier/filter.go:52`, F `pact/mcp.go:86`; J `mcp.go:162` | `TestPromptWriteCeiling` (F), `TestJournalPromptWrites` (J), `TestMCPRevocationEndToEnd` (c) (D) | fixed in 211cec1 (F), b129902 (J) |
|
||||
| T-19.7-51 | `auth_time` (OIDC name) is stamped equal to `iat` at every sign-in mint and copied unchanged by every refresh path; a token without it refreshes without it; `bouncer.VerifyAuthTime` keeps the signature, audience and expiry checks; the link confirm reads it (P-29; the user decision that sessions issued before the upgrade sign in again before linking, 19.7-GAP-INPUTS.md). | F `bouncer/mint.go:45`, `bouncer/refresh.go:92`, `bouncer/jwt.go:214`; U `controllers/backend_link_controller.go:102` | `TestAuthTime`, `TestAuthTimeSmoke` (F), `TestBackendLinkAuthTime` (U, revert-checked) | fixed in c14238b (F), 32f9259 (U) |
|
||||
| T-19.7-52 | Member token scopes are a separate capability, `pact.HasFrontendTokenScopes`, which cabana's admin catalog never reads; both catalogs share one name rule, `pact.ValidTokenScopeName` (decision note `.planning/notes/2026-10-23-frontend-token-scopes.md`, P-30). | F `pact/capabilities.go:676`, `:687`; F `cabana/token_scopes.go:107` | `TestFrontendTokenScopes`, `TestTokenScopeNameParity` (F), `TestMemberTokenScopesBoot` (U) | fixed in 9eedfbb |
|
||||
| T-19.7-53 | cabana keeps an account action URL only for http(s) with a host or a same-origin path (`//` and `/\` refused) and logs a refusal without the URL; the SPA applies `safeUrl` to `href` and `window.open`. | F `cabana/account_contributions.go:217`, `:233`; F `admin/src/components/account/AccountContributions.vue:31` | `TestAccountContributionURL` (F), `admin/tests/account/AccountContributions.test.ts` "a javascript: URL answer renders no link" | fixed in 44835e4, 88559d5 |
|
||||
| T-19.7-54 | A revoked event names the token (TokenID) or the OAuth client (ClientID) and pier ends only the matching sessions; cabana's token revoke, the user plugin's token delete and the authorized-apps revoke fire the narrowed events. | F `pier/events.go:79`, F `cabana/subject_events.go:51`; U `controllers/api_tokens.go:142`; O `controllers/authorizations.go:124` | `TestTokenScopedRevoke` (across two instances), `TestAccountTokenRevokeEvent` (F), `TestAPITokenRevokeEvent` (U), `TestMCPGrantRevocation` (O), `TestMCPRevocationEndToEnd` (d) (D) | fixed in 24cf6cd (F), 970719c (U), 671513d (O) |
|
||||
| T-19.7-55 | pier puts the client address on the resolve context (surf's trusted-proxy answer, else the RemoteAddr host); `ResolveBackendToken` logs it as `remote` on every `admin.auth` line. | F `towel/context.go:70`, F `pier/pier.go:254`, F `cabana/token_resolver.go:29` | `TestClientIP`, `TestResolveClientAddress`, `TestResolveBackendTokenRemote` (F) | fixed in 24cf6cd |
|
||||
| T-19.7-56 | A failing Status marks only its section `error: true`, a failing Applies drops only that action, the list answers 200; the SPA shows the section error line and a toast for a failed GET, keeping the earlier sections. | F `cabana/account_contributions.go:119`; F `admin/src/components/account/AccountContributions.vue:125` | `TestAccountContributionsIsolation` (F), `admin/tests/account/AccountContributions.test.ts` (section error, 500 on reload) | fixed in 44835e4, 88559d5 |
|
||||
| T-19.7-57 | A ban, a password reset, an administrator setting a password and the user's own change fire `AccessRevokedEvent` in the write's transaction (ban: newly banned users only) and a revoked subject event per user after the commit; the OAuth server revokes MCP and OIDC tokens created before the untruncated `Before`, deletes consents and unused codes; the verifier and the MCP refresh grant refuse banned users and tokens created before `tokens_valid_after + 1s`; `LinkedBackendUser` excludes banned users (user decision 2026-10-23: both MCP and OIDC grants end). | O `classes/mcp_verifier.go:96`, `:99`, `:139`; O `classes/mcp_store.go:281`, `:308`; O `classes/cascade.go:95`, `:161`; U `classes/access_revoked.go:34`, `classes/backend_links.go:423`; U `controllers/users_admin_controller.go:253`, `:651`; U `controllers/api_controller.go:463`, `:732` | `TestMCPVerifierRevocation` (O, revert-checked), `TestMCPGrantRevocation`, `TestMCPRevocationSmoke` (O), `TestAccessRevocation` (U), `TestMCPRevocationEndToEnd` (a) (D) | fixed in 970719c (U), 671513d (O) |
|
||||
| T-19.7-58 | The link code travels in the `#code=` fragment and the body of `POST /backend-link/show` (`no-store, private`), is kept in sessionStorage across the sign-in and removed from the URL; the page shows the signed-in account before the button; the GET show route stays for compatibility, documented as deprecated. | U `controllers/backend_link_controller.go:45`, `:75`; U `account_contributions.go:120`; V `app/lib/linkCode.ts:20`; V `app/pages/link-admin.vue:55` | `TestBackendLinkShowPost`, `TestBackendLinkAuthTimeSmoke` (U), `app/lib/linkCode.test.ts` (V) | fixed in 32f9259 (U), 0125e29 (V) |
|
||||
| T-19.7-59 | Every link and unlink revokes the user's `backend`-scoped MCP tokens (only those) and fires a revoked event per affected client after the commit, so a grant never acts as an administrator the user did not consent to. | O `classes/cascade.go:175`, `:184`, `:198` | `TestMCPGrantRevocation` (O), `TestMCPRevocationEndToEnd` (b), `TestMCPEndToEnd` "a link change ends the backend grant" (D) | fixed in 671513d |
|
||||
| T-19.7-60 | The member token scope catalog is compiled at boot from the activated plugins (pattern, built-ins reserved, duplicates name both plugins, labels and phrase keys checked); `POST /tokens` and `MintAPITokenFor` check the application's own catalog, so another application's declaration answers 422; `middleware.Scope` checks declared scopes like built-ins; the legacy `MintAPIToken` uses a documented process-wide fallback (decision note `.planning/notes/2026-10-23-frontend-token-scopes.md`; E-2's acceptance list, 19.7-GAP-INPUTS.md). | U `classes/api_token_scopes.go:87`, `classes/api_tokens.go:66`, `plugin.go:126`, `controllers/api_tokens.go:57` | `TestMemberTokenScopes` (E-2's acceptance list item by item), `TestMemberTokenScopesBoot`, `TestMemberTokenScopesSmoke` (U) | fixed in ee5c096 |
|
||||
| T-19.7-61 | The organisation logo is an image-mode fileupload through lagoon/attach (the avatar's validation), behind `golem15.users.access_users`; deleting an organisation removes its avatar and logo attachments. | U `models/organisation.go:44`, `models/organisation/fields.yaml:25`, `controllers/organisations_admin_controller.go:130` | `TestOrganisationLogo` (U) | fixed in f20a8d3, 25b9f2e, 38551a4 |
|
||||
| T-19.7-62 | nginx's `location = /mcp` allows 4 MiB bodies, pier's own cap, enforced by the deploy check. | D `deploy/nginx/demo.summercms.io.conf:217`, D `scripts/check-deploy.sh:254` | gate stage `consumers` (`check-deploy.sh`) (D) | fixed in 3b569a1 |
|
||||
| T-19.7-63 | `MCPResolvePersonalToken` stamps `last_used_ip` from `towel.ClientIP` and leaves it unchanged without an address. | U `classes/mcp_guard.go:174` | `TestUserMCPGuardClientIP` (U) | fixed in 970719c |
|
||||
| T-19.7-64 | The gate's workspace check refuses a repository resolving the framework (or, for the OAuth server plugin, the user plugin) anywhere but the expected checkout; the unreleased user plugin is built with fonoteka.go and sm-bm-app through scratch copies of their go.work; a demo submodule ahead of its pin is accepted only by test-only commits or by commits its canonical checkout holds, and reported; `PHASE197_RELEASED=1` refuses any drift. | F `scripts/check-phase19.7.sh:432` (`workspace_verdict`), `:446` (`workspace_check`), `:515` (`consumer_with_user_plugin`), `:946` (`demo_pins`), `:957` (released mode) | `--self-test` (match, symlinked match, mismatch naming both paths, empty answer; the planted go.work rewrite; test-only, unreleased accepted, unreleased refused and both released-mode refusals), `PHASE197_RELEASED=1 --consumers` exits 1 while the pins drift (F) | fixed in 0aa48ae |
|
||||
| T-19.7-65 | A high or critical control is verified only with a test that fails without it (Method step 6); the three critical findings are revert-checked; every disproved verdict is listed under Corrections and its register row carries the corrected status. | this section | the Revert-checks table; `bash scripts/check-phase19.7.sh --all` (F) | verified |
|
||||
| T-19.7-SC (gap closure) | No Go module or npm package was added in plans 06-09: go.mod, go.sum and the npm locks are unchanged in every repository (framework, the three plugins, the demo, vue-demo-app); vitest runs use the committed locks. | `git diff` of go.mod, go.sum, admin/package-lock.json and pnpm-lock.yaml over plans 06-09 | gate stage `admin` (`npm --prefix admin` with the committed lock), plan 09 check (F, U, O, J, D, V) | verified |
|
||||
|
||||
### Suites run for the gap closure
|
||||
|
||||
`bash scripts/check-phase19.7.sh --all` on a Docker host after the plan 09 commits: self-test, go, plugins, consumers, admin, docs, marker and docker all PASS, "Phase 19.7 gate passed" (the run is recorded in 19.7-09-SUMMARY.md). The consumers stage reports `plugins/golem15/journal`, `oauthserver` and `user` ahead of their pins by unreleased commits, which is expected until the release (deferred-items.md).
|
||||
135
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md
Normal file
135
.planning/phases/19.7-generic-mcp-module/19.7-SECURITY.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
phase: "19.7"
|
||||
slug: "generic-mcp-module"
|
||||
status: verified
|
||||
# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate)
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: "2026-10-23"
|
||||
---
|
||||
|
||||
# Phase 19.7 — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail. The evidence (file and line, pinning test) for every threat is in `19.7-SECURITY-REVIEW.md`.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| MCP client to `/mcp` | any agent on the internet presents a bearer, a session id and JSON-RPC bodies | OAuth access token or personal token, session id, tool arguments (high) |
|
||||
| pier to plugin routes (in-process dispatch) | pier calls a plugin's compiled route chain as the caller's pre-resolved principal | dispatch marker with a principal, arguments as path, query and body (high) |
|
||||
| frontend user to the link confirm and consent pages | a signed-in browser confirms a link code or decides a consent | session JWT, link code, consent decision (high) |
|
||||
| administrator to My account and the Administrators screen | admin actions that start, set or remove a link | admin JWT, prompted email value (high) |
|
||||
| verifier and resolvers to pier | the OAuth server plugin and the user plugin answer who a bearer is and which admin a user is linked to | grants, subjects, link answers (high) |
|
||||
| instances to the shared session store | Redis holds session records and carries subject events between instances | binding keys, protocol state, events (medium) |
|
||||
| nginx to the Go binary | the public vhost opens the MCP paths only | streamed MCP traffic (medium) |
|
||||
| test results to the phase verdict | the gate's output decides whether the phase is verified | test output (medium) |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|----------|-------------|------------|--------|
|
||||
| T-19.7-01 | Spoofing | bouncer dispatch marker | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in commit c49983d | closed |
|
||||
| T-19.7-02 | Elevation of privilege | cabana ResolveBackend and backend middleware with a marker | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in commit c49983d | closed |
|
||||
| T-19.7-03 | Elevation of privilege | surf Handler lookup | medium | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 104db99 (was verified; A-WR-01, A-WR-02) | closed |
|
||||
| T-19.7-04 | Tampering | streaming route recovery | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-05 | Denial of service | mcp.enabled without the tag | low | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-06 | Elevation of privilege | account contribution actions | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-07 | Tampering | prompted record action value | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-08 | Information disclosure | account contribution rendering in the SPA | low | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 44835e4, 88559d5 (was verified; B-WR-03) | closed |
|
||||
| T-19.7-09 | Elevation of privilege | wristband MCP scope allow-list | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-10 | Spoofing | bearer verification | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-11 | Spoofing | session hijack with a stolen Mcp-Session-Id | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-12 | Elevation of privilege | token passthrough / confused deputy | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-13 | Elevation of privilege | scope escalation to backend tools | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-14 | Information disclosure | tool-list leakage across principals | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-15 | Elevation of privilege | rehydration of a revoked session | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in commit 1111828 | closed |
|
||||
| T-19.7-16 | Spoofing | audience confusion at /mcp | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-17 | Tampering | argument injection into routes | medium | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 104db99 (was a test pin only; A-WR-01, A-WR-02) | closed |
|
||||
| T-19.7-18 | Denial of service | sessions, streams and large results | medium | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 2bf9dca, c1c0c77 (was a test pin only; A-CR-01, A-WR-03) | closed |
|
||||
| T-19.7-19 | Spoofing | DNS rebinding / browser Origin | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in commit 0b8e027 (test pin; code unchanged) | closed |
|
||||
| T-19.7-20 | Information disclosure | audit log contents | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-21 | Tampering | prompt injection through tool metadata | low | accept | 19.7-SECURITY-REVIEW.md: accepted (static plugin text, capped) | closed |
|
||||
| T-19.7-SC | Tampering | go get of go-sdk and jsonschema-go | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-22 | Elevation of privilege | link without proof | high | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in c14238b (F), 32f9259 (U) (was verified; C-CR-02, revert-checked) | closed |
|
||||
| T-19.7-23 | Spoofing | replayed or guessed link code | medium | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 32f9259 (U), 0125e29 (V) (was verified; C-WR-01) | closed |
|
||||
| T-19.7-24 | Elevation of privilege | admin sets a link | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-25 | Elevation of privilege | cross-site confirm or unlink | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-26 | Information disclosure | stale link resolution | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-27 | Elevation of privilege | list and call disagree on frontend permissions | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-28 | Spoofing | personal token resolution at /mcp | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-29 | Repudiation | who linked whom | low | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-30 | Spoofing | audience confusion at the verifier | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-31 | Elevation of privilege | consent phishing for the backend scope | high | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 671513d (O), 970719c (U) (was verified; C-WR-02) | closed |
|
||||
| T-19.7-32 | Elevation of privilege | consent decided for another user's request | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-33 | Elevation of privilege | submitted scopes beyond the request | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-34 | Spoofing | superuser reach through an agent (D-22) | high | mitigate | 19.7-SECURITY-REVIEW.md: accepted as designed with audit and ceiling (no switch) | closed |
|
||||
| T-19.7-35 | Information disclosure | revoked grant keeps a live session | medium | mitigate | 19.7-SECURITY-REVIEW.md: corrected, fixed in 970719c (U), 671513d (O) (was fixed in 1111828; C-CR-01, revert-checked); missing self-service revoke accepted | closed |
|
||||
| T-19.7-36 | Tampering | partial update tools zeroing fields | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-37 | Denial of service | public /mcp and SSE through nginx | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in commit 0b8e027 (gate pin; config unchanged) | closed |
|
||||
| T-19.7-38 | Spoofing | open redirect from the consent page | low | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-39 | Repudiation | a green gate that measured nothing | high | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-40 | Tampering | the marker rule eroding over time | medium | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-41 | Information disclosure | test fixtures leaking credentials | low | mitigate | 19.7-SECURITY-REVIEW.md: verified | closed |
|
||||
| T-19.7-42 | Denial of service | abandoned stateful sessions | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 2bf9dca (revert-checked) | closed |
|
||||
| T-19.7-43 | Denial of service | concurrent initialize past max_per_binding | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in c1c0c77 | closed |
|
||||
| T-19.7-44 | Tampering | path values the mux never delivers | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 104db99 | closed |
|
||||
| T-19.7-45 | Information disclosure | raw provider or database errors in tool results | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 104db99 | closed |
|
||||
| T-19.7-46 | Spoofing | personal-token sessions sharing pat:user:0 | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 2404572 | closed |
|
||||
| T-19.7-47 | Elevation of privilege | stateless streams and stateless-only instances outliving a revocation | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 2404572 | closed |
|
||||
| T-19.7-48 | Denial of service | router-wide locks across guard and database I/O | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in c1c0c77 | closed |
|
||||
| T-19.7-49 | Elevation of privilege | a provider naming the backend guard for a frontend tool | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 104db99 | closed |
|
||||
| T-19.7-50 | Information disclosure | a write-directing prompt for a read-only grant | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 211cec1 (F), b129902 (J) | closed |
|
||||
| T-19.7-51 | Spoofing | the fresh-sign-in proof (auth_time) | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in c14238b (F), 32f9259 (U) (revert-checked) | closed |
|
||||
| T-19.7-52 | Elevation of privilege | member scopes crossing into the admin token catalog | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 9eedfbb | closed |
|
||||
| T-19.7-53 | Tampering | javascript: or data: URL from an account action | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 44835e4, 88559d5 | closed |
|
||||
| T-19.7-54 | Denial of service | one token revoke ending every MCP session | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 24cf6cd (F), 970719c (U), 671513d (O) | closed |
|
||||
| T-19.7-55 | Repudiation | failed g15_ attempts without a client address | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 24cf6cd | closed |
|
||||
| T-19.7-56 | Information disclosure | one plugin's error hiding every My account section | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 44835e4, 88559d5 | closed |
|
||||
| T-19.7-57 | Elevation of privilege | banned or password-reset users keeping MCP grants | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 970719c (U), 671513d (O) (revert-checked) | closed |
|
||||
| T-19.7-58 | Spoofing | the link code in access logs and browser history | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 32f9259 (U), 0125e29 (V) | closed |
|
||||
| T-19.7-59 | Elevation of privilege | a backend grant re-targeted to another administrator | high | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 671513d | closed |
|
||||
| T-19.7-60 | Elevation of privilege | member tokens with undeclared or shadowing scopes | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in ee5c096 | closed |
|
||||
| T-19.7-61 | Tampering | organisation logo uploads | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in f20a8d3, 25b9f2e, 38551a4 | closed |
|
||||
| T-19.7-62 | Denial of service | nginx 2 MiB cap below pier's 4 MiB | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 3b569a1 | closed |
|
||||
| T-19.7-63 | Repudiation | stale last_used_ip of personal tokens at /mcp | low | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 970719c | closed |
|
||||
| T-19.7-64 | Repudiation | a green gate on a stray workspace or unreleased drift | medium | mitigate | 19.7-SECURITY-REVIEW.md: fixed in 0aa48ae | closed |
|
||||
| T-19.7-65 | Repudiation | a control marked verified without a test that fails without it | high | mitigate | 19.7-SECURITY-REVIEW.md: verified (revert-checks, Method step 6, Corrections) | closed |
|
||||
|
||||
*Status: open · closed. Every high threat is verified or fixed; the accepted items are listed below with their reasons. Rows marked "corrected" had a verdict the phase code review disproved; the Corrections table of 19.7-SECURITY-REVIEW.md says what was wrong.*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
| Risk ID | Threat Ref | Rationale | Accepted By | Date |
|
||||
|---------|------------|-----------|-------------|------|
|
||||
| AR-19.7-01 | T-19.7-21 | Tool and prompt descriptions are static plugin text, capped at 1024 runes at boot; dynamic text is a plugin bug. | plan 19.7-05 security review | 2026-10-23 |
|
||||
| AR-19.7-02 | T-19.7-34 | A linked superuser's agent reaches only the declared backend tools, behind an explicit `backend` consent with the admin's name, the read/write ceiling and a per-call audit line; a refusal switch would block the solo-owner case while a non-superuser link already gives the narrower alternative. Revisit when a plugin declares a superuser-only or destructive backend tool beyond content editing. | plan 19.7-05 security review | 2026-10-23 |
|
||||
| AR-19.7-03 | T-19.7-35 | MCP grants have no consent row, so the authorized-apps list does not revoke them yet; access still ends through client revocation, user deletion or deactivation, token expiry and the verifier's refusal of a revoked token. Follow-up in deferred-items.md. | plan 19.7-05 security review | 2026-10-23 |
|
||||
| AR-19.7-04 | cross-cutting `no-store` | The POST answer of My account's link action carries a one-shot, 10-minute link code without explicit `no-store`; POST responses are not stored by shared caches without explicit freshness. | plan 19.7-05 security review | 2026-10-23 |
|
||||
| AR-19.7-05 | T-19.7-11, T-19.7-15 | Stateful sessions use the SDK's 2025-03-26 stream defaults, and an `initialized` notification may land on another instance (deferred-items.md); multi-instance availability details that leave identity, binding and revocation checks unchanged. | plan 19.7-05 security review | 2026-10-23 |
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| 2026-10-23 | 42 | 42 | 0 | plan 19.7-05 executor (Task 4), gate `bash scripts/check-phase19.7.sh --all` green |
|
||||
| 2026-10-23 | 66 | 66 | 0 | plan 19.7-09 executor (Task 4), gap closure: 8 verdicts corrected after the code review, T-19.7-42..T-19.7-65 added, the three critical fixes revert-checked, gate `bash scripts/check-phase19.7.sh --all` green |
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [x] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [x] Accepted risks documented in Accepted Risks Log
|
||||
- [x] No open threat (frontmatter count confirmed)
|
||||
- [x] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** verified 2026-10-23; re-verified after the gap closure (plans 06-09) 2026-10-23
|
||||
48
.planning/phases/19.7-generic-mcp-module/19.7-UAT.md
Normal file
48
.planning/phases/19.7-generic-mcp-module/19.7-UAT.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
status: complete
|
||||
phase: 19.7-generic-mcp-module
|
||||
source: [19.7-VERIFICATION.md]
|
||||
started: 2026-10-23T20:05:22.930Z
|
||||
updated: 2026-10-23T22:31:27Z
|
||||
---
|
||||
|
||||
## Current Test
|
||||
|
||||
[testing complete]
|
||||
|
||||
## Tests
|
||||
|
||||
### 1. Decide on SC-3's wording: frontend tool filtering uses group grants (what user.permission enforces), not MergedPermissions (groups plus the user's own allow/deny). Accept the override below, or ask for MergedPermissions in both the route middleware and the MCP guard (a behaviour change of a core plugin).
|
||||
expected: An override entry is added to this frontmatter (suggested YAML in the report), or a follow-up is opened
|
||||
result: pass
|
||||
note: override accepted in 19.7-VERIFICATION.md (SC-3 group-grant wording)
|
||||
|
||||
### 2. Real MCP client against the local demo (DEPLOY.md, 'MCP endpoint', 'Locally'): add http://127.0.0.1:8097/mcp to Claude Code or Claude Desktop, sign in on /connect as a frontend user asking for backend, see only user_me; in the admin's My account start 'Link frontend account', finish on /link-admin with a fresh sign-in, reconnect (consent shows 'also act as admin <name>'), see the journal_ tools, create a draft post and find it in the admin; unlink and see the journal_ tools disappear.
|
||||
expected: One connector, one OAuth sign-in; journal_ tools appear only with a verified link plus the backend scope and disappear after unlinking (the session ends, a new session lists user_me only)
|
||||
result: pass
|
||||
note: real client: Claude Code against the local demo on the Nuxt origin (127.0.0.1:3001, app.url and both MCP resources overridden as DEPLOY.md 'Locally' describes); frontend test user uat@example.test
|
||||
|
||||
### 3. Consent page with a changed link, in a browser: open /connect for a request asking for backend, then change the user's link to another administrator (Administrators screen) before clicking Allow.
|
||||
expected: The decision answers 409 backend_link_changed, the page reloads the request and shows the linkChanged notice naming the new administrator; no grant is issued for the old one
|
||||
result: pass
|
||||
|
||||
### 4. Link page 'Signed in as', in a browser: start 'Link frontend account' on My account, open the #code=... URL while signed in as a different frontend user than intended.
|
||||
expected: /link-admin shows the request and 'Signed in as <email>' before the confirm button, keeps the code across a sign-in (sessionStorage), and a session older than the request gets the stale-session message
|
||||
result: pass
|
||||
|
||||
### 5. RB-WR-01 in Firefox: in the admin, on a record form with a plugin field type that renders inside a shadow root (taglist or another widget), type into the inner input and press Ctrl+S (and Ctrl+Enter) with a pending taglist draft.
|
||||
expected: The pending draft is committed before the save; plain keys typed inside the shadow root (letters, Esc, /, ?) trigger no shortcut
|
||||
result: pass
|
||||
|
||||
## Summary
|
||||
|
||||
total: 5
|
||||
passed: 5
|
||||
issues: 0
|
||||
pending: 0
|
||||
skipped: 0
|
||||
blocked: 0
|
||||
|
||||
## Gaps
|
||||
|
||||
[none]
|
||||
@@ -3,9 +3,9 @@ phase: "19.7"
|
||||
slug: "generic-mcp-module"
|
||||
# status lifecycle: draft (seeded by plan-phase) → validated (set by validate-phase §6)
|
||||
# audit-milestone §5.5 distinguishes NOT-VALIDATED (draft) from PARTIAL (validated + nyquist_compliant: false) (#2117)
|
||||
status: draft
|
||||
nyquist_compliant: false
|
||||
wave_0_complete: false
|
||||
status: validated
|
||||
nyquist_compliant: true
|
||||
wave_0_complete: true
|
||||
created: "2026-10-21"
|
||||
---
|
||||
|
||||
@@ -31,7 +31,7 @@ created: "2026-10-21"
|
||||
|
||||
- **After every task commit:** quick run command for the touched module(s)
|
||||
- **After every plan wave:** framework `go vet ./... && go test ./...` plus the touched plugin suites
|
||||
- **Before `/msd-verify-work`:** `scripts/check-phase19.7.sh` green
|
||||
- **Before `/msd-verify-work`:** `bash scripts/check-phase19.7.sh --all` green on a Docker host (every stage PASS, no NOT RUN docker)
|
||||
- **Max feedback latency:** 120 seconds
|
||||
|
||||
---
|
||||
@@ -42,33 +42,84 @@ Filled in by the planner per task; the behaviour → test map is:
|
||||
|
||||
| Ref | Behavior | Test Type | Automated Command | File Exists | Status |
|
||||
|-----|----------|-----------|-------------------|-------------|--------|
|
||||
| SC-1/D-30 | disabled → nothing mounted; enabled → `/mcp` mounted | unit | `go test -short ./modules/surf -run TestPierMount` | ❌ W0 | ⬜ pending |
|
||||
| SC-1 | SSE stream flushes through the streaming route kind | unit | `go test -short ./modules/surf -run TestStreamingRoute` | ❌ W0 | ⬜ pending |
|
||||
| SC-2/D-10..D-12 | binding/duplicate/name boot errors; prefixing | unit | `go test -short ./modules/pier -run TestCatalog` | ❌ W0 | ⬜ pending |
|
||||
| D-11/D-13/D-14 | arg split, isError with route body, annotations | unit | `go test -short ./modules/pier -run TestDispatch` | ❌ W0 | ⬜ pending |
|
||||
| D-15/D-16 | non-token routes refused; requirement union | unit | `go test -short ./modules/pier -run TestGuardRules` | ❌ W0 | ⬜ pending |
|
||||
| D-17 | marker honoured in-process only; not forgeable from HTTP; frontend marker refused by backend guard | unit | `go test -short ./modules/bouncer ./modules/cabana -run TestDispatchMarker` | ❌ W0 | ⬜ pending |
|
||||
| SC-3/D-20/D-23 | per-principal tools/list; read grant hides write tools | integration | `go test -short ./modules/pier -run TestToolsList` | ❌ W0 | ⬜ pending |
|
||||
| D-25 | session binding, DELETE, cross-instance rehydration, TTL | integration | `go test -short ./modules/pier -run TestSessions` | ❌ W0 | ⬜ pending |
|
||||
| D-26/D-27 | pub/sub list_changed; revocation ends session | integration | `go test -short ./modules/pier -run TestFanOut` | ❌ W0 | ⬜ pending |
|
||||
| D-09 | plugin frontend permission codes in editors | Postgres | user plugin `go test ./... -run TestFrontendPermissionCatalog` | ❌ W0 | ⬜ pending |
|
||||
| D-03..D-08 | link proof, one-shot, 1:1, admin set, per-request lookup | Postgres | user plugin `go test ./... -run TestBackendLink` | ❌ W0 | ⬜ pending |
|
||||
| D-04 | account contribution seam; existing payloads unchanged | unit + vitest | `go test -short ./modules/cabana -run TestAccountContributions`; `npm --prefix admin run test` | ❌ W0 | ⬜ pending |
|
||||
| D-21 | `backend` scope and consent line | unit + Postgres | `go test -short ./modules/wristband -run TestMCPScopes`; plugin `-run TestMCPConsent` | ❌ W0 | ⬜ pending |
|
||||
| SC-4 | `oas_at_` verifier refuses OIDC/revoked/expired/foreign tokens | Postgres | oauthserver plugin `go test ./... -run TestMCPTokenVerifier` | ❌ W0 | ⬜ pending |
|
||||
| SC-4/D-18 | end-to-end in sm-demo-app incl. unlink removes tools | e2e | `cd ../sm-demo-app && go test ./... -run TestMCPEndToEnd` | ❌ W0 | ⬜ pending |
|
||||
| D-31 | consumers build and pass at bumped pins | build | `scripts/check-phase19.7.sh` stage `consumers` | ❌ W0 | ⬜ pending |
|
||||
| SC-1/D-30/D-33 | disabled → nothing mounted; enabled without the tag → boot error; tagged → `/mcp` stream routes and PRM documents; collision names the owner | unit | `go test -short ./modules/surf -run '^TestPierMount$'` and `go test -short -tags summercms_mcp ./modules/surf -run '^TestPierMount$'` | ✅ `modules/surf/pier_mount_test.go` | ✅ green |
|
||||
| SC-1 | SSE stream flushes through the streaming route kind; throttle, CORS profile and access-log pattern kept; buffered Flush a no-op | unit | `go test -short ./modules/surf -run '^TestStreamingRoute$'` | ✅ `modules/surf/streaming_test.go` | ✅ green |
|
||||
| SC-2/D-10..D-12/D-14 | binding/duplicate/name boot errors; prefixing; annotations by method | unit | `go test -short ./modules/pier -run '^TestCatalog$'` | ✅ `modules/pier/catalog_test.go` | ✅ green |
|
||||
| D-11/D-13 | arg split, omitted fields absent, no outer credentials, isError with the route body, `{"data":…}`, size cap, call timeout | unit | `go test -short ./modules/pier -run '^TestDispatch$'` | ✅ `modules/pier/dispatch_test.go` | ✅ green |
|
||||
| D-15/D-16/D-22 | non-token routes refused; requirement union; method-aware provider; admin token scope per method | unit | `go test -short ./modules/pier -run '^TestGuardRules$'`; `go test -short ./modules/cabana -run '^TestScopeLimitForMethods$'` | ✅ `modules/pier/guard_rules_test.go`, `modules/cabana/scope_limit_for_test.go` | ✅ green |
|
||||
| D-17 | marker honoured in-process only; not forgeable from HTTP; frontend marker refused by the backend guard and `ResolveBackend` | unit + Postgres | `go test -short ./modules/bouncer ./modules/cabana -run '^TestDispatchMarker$'`; Postgres part `go test ./modules/cabana -run '^TestDispatchMarker$'`; gate stage `marker` | ✅ `modules/bouncer/dispatch_test.go`, `modules/cabana/dispatch_marker_test.go` | ✅ green |
|
||||
| SC-3/D-20/D-23 | per-principal tools/list; read grant hides write tools; no subject, no tool; unlisted call never reaches the route; union of guards | integration | `go test -short ./modules/pier -run '^TestToolsList$'` | ✅ `modules/pier/tools_list_test.go` | ✅ green |
|
||||
| D-25 | session binding, DELETE, cross-instance rehydration, TTL, per-binding cap (Redis and memory) | integration | `go test -short ./modules/pier -run '^TestSessions$'` | ✅ `modules/pier/sessions_test.go` | ✅ green |
|
||||
| D-26/D-27 | pub/sub list_changed; link change and cache bypass; revocation and deletion end sessions and evict stateless servers | integration | `go test -short ./modules/pier -run '^TestFanOut$'` | ✅ `modules/pier/fanout_test.go` | ✅ green |
|
||||
| D-09 | plugin frontend permission codes in editors; duplicates dropped; saved codes granted | Postgres | user plugin `GOWORK=off go test . -run '^TestFrontendPermissionCatalog$'` | ✅ `plugins/golem15/user/frontend_permission_catalog_test.go` | ✅ green |
|
||||
| D-03..D-08 | link proof, one-shot, fresh sign-in at the second, 1:1, admin set, events, per-request lookup | Postgres | user plugin `GOWORK=off go test . -run '^TestBackendLink$'` | ✅ `plugins/golem15/user/backend_link_test.go` | ✅ green |
|
||||
| D-15/D-35 | user guard: parser refusals, deleted user, expired token, dispatch credential against `user.scope` | Postgres | user plugin `GOWORK=off go test . -run '^TestUserMCPGuard$'` | ✅ `plugins/golem15/user/mcp_guard_test.go` | ✅ green |
|
||||
| D-04 | account contribution seam; Applies and permission filtering; 409; interactive only; transaction; existing payloads unchanged | unit + Postgres + vitest | `go test -short ./modules/cabana -run '^TestAccountContributions$'` (Postgres part without `-short`); `npm --prefix admin run test`; gate check `account.go` unchanged since 51d088a | ✅ `modules/cabana/account_contributions_test.go`, `admin/tests/account/AccountContributions.test.ts` | ✅ green |
|
||||
| D-34 | prompted record actions: localized prompt, trim and cap, refusals, empty Value for a plain action | unit + Postgres + vitest | `go test -short ./modules/cabana -run '^TestRecordActionPrompt$'`; `go test ./modules/cabana -run '^TestRecordActionPromptRun$'`; `npm --prefix admin run test` | ✅ `modules/cabana/record_action_prompt_test.go`, `admin/tests/form/RecordActionsPrompt.test.ts` | ✅ green |
|
||||
| D-21 | `backend` scope and consent line | unit + Postgres | `go test -short ./modules/wristband -run '^TestMCPScopes$'`; oauthserver plugin `go test . -run '^TestMCPConsent$'` | ✅ `modules/wristband/mcp_scopes_test.go`, `sm-oauthserver-plugin/mcp_consent_test.go` | ✅ green |
|
||||
| SC-4 | `oas_at_` verifier refuses OIDC/revoked/expired/foreign/inactive-client/deleted-user tokens; conditional stamp | Postgres | oauthserver plugin `go test . -run '^TestMCPTokenVerifier$'` | ✅ `sm-oauthserver-plugin/mcp_verifier_test.go` | ✅ green |
|
||||
| D-15/D-16 | Journal tools compile through pier; input keys are the routes' keys; prompt | unit | blog plugin `go test -short . -run '^TestJournalMCP$'` | ✅ `sm-journal-plugin/mcp_test.go` | ✅ green |
|
||||
| SC-4/D-08/D-18/D-20/D-26 | end-to-end in sm-demo-app incl. unlink list_changed, read grant, revoked grant, personal tokens off | e2e | `cd ../sm-demo-app && go test -tags summercms_mcp . -run '^TestMCPEndToEnd$'` | ✅ `sm-demo-app/mcp_e2e_test.go` | ✅ green |
|
||||
| D-31 | plugins additive against their pre-phase commits; consumers build and pass at bumped pins | build | `bash scripts/check-phase19.7.sh --plugins` and `--consumers` | ✅ `scripts/check-phase19.7.sh` | ✅ green |
|
||||
| A-CR-01/A-IN-01/A-IN-06 | reaper closes expired copies (memory, Redis per instance), store error keeps the copy, GET stream ends when its record is gone, `ephemeral` label | integration | `go test -short ./modules/pier -run '^TestSessionReaper$'` (also `-tags summercms_mcp`) | ✅ `modules/pier/reaper_test.go` | ✅ green |
|
||||
| A-WR-03 | 50 concurrent initializes open exactly `max_per_binding` (memory, two instances on miniredis); a failed initialize releases its slot; Count/Put fallback | integration | `go test -short ./modules/pier -run '^TestSessionReserve$'` | ✅ `modules/pier/reserve_test.go` | ✅ green |
|
||||
| A-WR-07 | a call, a DELETE and a stateless request finish while an initialize blocks in a guard check | integration | `go test -short -race ./modules/pier -run '^TestLockScope$'` | ✅ `modules/pier/lock_scope_test.go` | ✅ green |
|
||||
| A-WR-04 | a returning binding with read write, or with a backend subject, lists the new tools on both paths; narrowing hides them | integration | `go test -short ./modules/pier -run '^TestScopeWidening$'` | ✅ `modules/pier/widening_test.go` | ✅ green |
|
||||
| A-WR-05/A-WR-06 | a stateless-only Redis instance applies a revocation; a listen stream ends with its bearer; LRU eviction closes the stream | integration | `go test -short ./modules/pier -run '^TestStatelessFanOut$'` | ✅ `modules/pier/stateless_fanout_test.go` | ✅ green |
|
||||
| A-WR-09 | a subject without TokenID is 401; two users' personal tokens get distinct bindings | integration | `go test -short ./modules/pier -run '^TestPersonalTokenBinding$'` | ✅ `modules/pier/personal_binding_test.go` | ✅ green |
|
||||
| A-WR-01/A-WR-02/A-WR-08/A-IN-04/A-IN-05/A-IN-08 | traversal and empty segments refused before the route; missing path value refused; fixed provider error text; large integers keep their digits; outer Host and forwarding headers; contradicting dispatch refused | unit | `go test -short ./modules/pier -run '^TestDispatchHardening$'` | ✅ `modules/pier/dispatch_hardening_test.go` | ✅ green |
|
||||
| A-WR-02/A-IN-07 | an omitempty path field and an embedded struct on a GET tool fail boot | unit | `go test -short ./modules/pier -run '^TestCatalogPathFields$'` | ✅ `modules/pier/catalog_path_fields_test.go` | ✅ green |
|
||||
| C-IN-01 | a `Writes` prompt is listed only for read and write grants | integration | `go test -short ./modules/pier -run '^TestPromptWriteCeiling$'`; blog plugin `go test -short . -run '^TestJournalPromptWrites$'` | ✅ `modules/pier/prompt_ceiling_test.go`, `sm-journal-plugin/mcp_prompt_writes_test.go` | ✅ green |
|
||||
| B-WR-04/C-IN-02 | a TokenID event ends only that token's sessions, a ClientID event only that client's, neither all; through Redis between instances | integration | `go test -short ./modules/pier -run '^TestTokenScopedRevoke$'` | ✅ `modules/pier/token_events_test.go` | ✅ green |
|
||||
| B-IN-04 | a resolver sees `towel.ClientIP` (RemoteAddr host, or the host's trusted-proxy answer); towel round trip; `ResolveBackendToken` logs `remote` | unit + Postgres | `go test -short ./modules/pier -run '^TestResolveClientAddress$'`; `go test -short ./modules/towel -run '^TestClientIP$'`; `go test ./modules/cabana -run '^TestResolveBackendTokenRemote$'` | ✅ `modules/pier/token_events_test.go`, `modules/towel/client_ip_test.go`, `modules/cabana/token_resolver_remote_test.go` | ✅ green |
|
||||
| C-CR-02/D-05 | `auth_time` at mint (both audiences), unchanged through every refresh path, absent for legacy tokens; `VerifyAuthTime` refusals | unit | `go test -short ./modules/bouncer -run '^TestAuthTime$'` | ✅ `modules/bouncer/auth_time_test.go` | ✅ green |
|
||||
| E-2 (framework) | `ValidTokenScopeName` table; `HasFrontendTokenScopes` discovered; cabana's scope validation agrees with pact | unit | `go test -short ./modules/pact -run '^TestFrontendTokenScopes$'`; `go test -short ./modules/cabana -run '^TestTokenScopeNameParity$'` | ✅ `modules/pact/frontend_token_scopes_test.go`, `modules/cabana/token_scope_name_test.go` | ✅ green |
|
||||
| B-WR-03 | `javascript:`, `data:`, `vbscript:` and `//` action URLs dropped and logged without the URL; https and same-origin kept | unit | `go test -short ./modules/cabana -run '^TestAccountContributionURL$'` | ✅ `modules/cabana/account_contributions_hardening_test.go` | ✅ green |
|
||||
| B-WR-06/B-IN-03 | a failing Status marks only its section, a failing Applies drops only its action, 200; dynamic status text not looked up | unit | `go test -short ./modules/cabana -run '^TestAccountContributionsIsolation$'` | ✅ `modules/cabana/account_contributions_hardening_test.go` | ✅ green |
|
||||
| B-IN-02 | a non-string prompt payload answers the localized `action_prompt_invalid` text (en, pl) | unit | `go test -short ./modules/cabana -run '^TestRecordActionPromptLocalized$'` | ✅ `modules/cabana/record_action_prompt_localized_test.go` | ✅ green |
|
||||
| B-WR-04 | revoking one `g15_` token fires one revoked event with its TokenID | Postgres | `go test ./modules/cabana -run '^TestAccountTokenRevokeEvent$'` | ✅ `modules/cabana/account_token_events_test.go` | ✅ green |
|
||||
| B-WR-01/B-WR-02 | plain keys ignored from an open shadow root and a custom field element in a form; Ctrl+S and Ctrl+Enter save the taglist draft | vitest | `npm --prefix admin run test` (`tests/app/hotkeysEditing.test.ts` required by the gate) | ✅ `admin/tests/app/hotkeysEditing.test.ts` | ✅ green |
|
||||
| B-WR-03/B-WR-06/B-IN-01 | no link and no `window.open` for a `javascript:` URL; section error text; toast and kept sections on a failed reload; My account confirm and stale texts | vitest | `npm --prefix admin run test` | ✅ `admin/tests/account/AccountContributions.test.ts` | ✅ green |
|
||||
| E-2 | E-2's acceptance list item by item (mint and `middleware.Scope`, the 403 message, 422, listing, discovery in en and pl), per-application catalog, legacy fallback | Postgres | user plugin `GOWORK=off go test . -run '^TestMemberTokenScopes$'` | ✅ `plugins/golem15/user/member_token_scopes_test.go` | ✅ green |
|
||||
| E-2 | duplicate (both plugins named), redeclared built-ins, bad names, empty label and a missing phrase key fail boot | unit | user plugin `GOWORK=off go test -short . -run '^TestMemberTokenScopesBoot$'` | ✅ `plugins/golem15/user/member_token_scopes_test.go` | ✅ green |
|
||||
| C-CR-02 | the link proof against login, request, refresh and re-login orders, no `auth_time`, another user's session token | Postgres | user plugin `GOWORK=off go test . -run '^TestBackendLinkAuthTime$'` | ✅ `plugins/golem15/user/backend_link_auth_time_test.go` | ✅ green |
|
||||
| C-WR-01/C-IN-06 | POST show answers like GET with no-store; fragment URL; `backend_links.page_path` | Postgres | user plugin `GOWORK=off go test . -run '^TestBackendLinkShowPost$'` | ✅ `plugins/golem15/user/backend_link_show_test.go` | ✅ green |
|
||||
| C-CR-01 | `AccessRevokedEvent` from ban, reset, change and admin-set password (ids, Before, reason, transaction, subject event after commit, rollback); banned user loses the link | Postgres | user plugin `GOWORK=off go test . -run '^TestAccessRevocation$'` | ✅ `plugins/golem15/user/access_revocation_test.go` | ✅ green |
|
||||
| C-IN-04 | MCP personal-token resolve stamps `last_used_ip` | Postgres | user plugin `GOWORK=off go test . -run '^TestUserMCPGuardClientIP$'` | ✅ `plugins/golem15/user/mcp_guard_client_ip_test.go` | ✅ green |
|
||||
| C-IN-02 | `DELETE /tokens/{id}` fires one revoked event with that TokenID | Postgres | user plugin `GOWORK=off go test . -run '^TestAPITokenRevokeEvent$'` | ✅ `plugins/golem15/user/api_token_events_test.go` | ✅ green |
|
||||
| E-1 | logo fileupload after the avatar; upload stored with field `logo`; `OrganisationLogoFields` with and without a logo; delete removes both attachments | Postgres | user plugin `GOWORK=off go test . -run '^TestOrganisationLogo$'` | ✅ `plugins/golem15/user/organisation_logo_test.go` | ✅ green |
|
||||
| C-CR-01 | the verifier and refresh refuse pre-cutoff (same-second), banned and deleted users without a revoke listener; untruncated `Before` | Postgres | oauthserver plugin `go test . -run '^TestMCPVerifierRevocation$'` | ✅ `sm-oauthserver-plugin/mcp_revocation_test.go` | ✅ green |
|
||||
| C-CR-01/C-WR-02/C-IN-02 | MCP and OIDC grants before `Before` revoked, later kept; consents and unused codes deleted; link changes revoke only backend tokens with client events after commit; authorized-apps revoke event | Postgres | oauthserver plugin `go test . -run '^TestMCPGrantRevocation$'` | ✅ `sm-oauthserver-plugin/mcp_revocation_test.go` | ✅ green |
|
||||
| SC-4/C-CR-01/C-WR-02/C-IN-01/C-IN-02 | demo revocation matrix through the SDK client: ban via the bulk route, unlink and a new consent, read-only prompts, one `usr_` token revoked | e2e | `cd ../sm-demo-app && go test -tags summercms_mcp . -run '^TestMCPRevocationEndToEnd$'` | ✅ `sm-demo-app/mcp_revocation_e2e_test.go` | ✅ green |
|
||||
| C-WR-01 | `readLinkCode` and `isLinkCode` | vitest | `pnpm --dir ../sm-demo-app/vue-demo-app run test` (`app/lib/linkCode.test.ts` required by the gate) | ✅ `sm-demo-app/vue-demo-app/app/lib/linkCode.test.ts` | ✅ green |
|
||||
| T-19.7-64 (P-40) | workspace check, consumers built against the unreleased user plugin, unreleased-pin policy and `PHASE197_RELEASED` strict mode | gate | `bash scripts/check-phase19.7.sh --self-test`, `--plugins`, `--consumers`; `PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers` exits 1 before the release | ✅ `scripts/check-phase19.7.sh` | ✅ green |
|
||||
| A-IN-02 | cooler's `KeyPrefix` and `keyPrefix` carry their own doc comments | docs | `bash scripts/check-phase19.7.sh --docs` | ✅ `scripts/check-phase19.7.sh` | ✅ green |
|
||||
| RA-WR-01 | fan-out never waits on a session lock under the router lock; re-filter guard checks bounded by `mcp.call_timeout` | integration | `go test -short -race ./modules/pier -run '^TestLockScopeUnderWidening$'` | ✅ `modules/pier/lock_scope_test.go` | ✅ green |
|
||||
| RA-WR-02 | the stateless fingerprint ignores the OAuth token id; a narrow token does not flip a shared server's tool set mid-call | unit + integration | `go test -short ./modules/pier -run '^(TestFingerprintIgnoresTokenID\|TestStatelessSharedBinding)$'` | ✅ `modules/pier/fingerprint_test.go`, `modules/pier/stateless_fanout_test.go` | ✅ green |
|
||||
| RA-WR-03 | a guard error while widening or recomputing (stateless, stateful, on an event) does not narrow the session | integration | `go test -short ./modules/pier -run '^TestWideningGuardError$'` | ✅ `modules/pier/widening_test.go` | ✅ green |
|
||||
| RA-WR-04 | LRU eviction spares a server with a listen stream; a revocation still ends the stream | integration | `go test -short ./modules/pier -run '^TestStatelessFanOut$'` | ✅ `modules/pier/stateless_fanout_test.go` | ✅ green |
|
||||
| RA-WR-05 | prompt Render errors stay out of the client's answer (stateful and stateless) | integration | `go test -short ./modules/pier -run '^TestPromptRenderError$'` | ✅ `modules/pier/prompt_ceiling_test.go` | ✅ green |
|
||||
| RA-IN-02 | stream bearer re-checks carry the client address | integration | `go test -short ./modules/pier -run '^TestStreamRecheckClientIP$'` | ✅ `modules/pier/token_events_test.go` | ✅ green |
|
||||
| RA-IN-04 | the non-reserving fallback writes the record before building the server; a failed initialize deletes it (Count-then-Put race deferred) | integration | `go test -short ./modules/pier -run '^TestSessionReserve$'` | ✅ `modules/pier/reserve_test.go` | ✅ green |
|
||||
| RA-IN-05 | an admin personal token whose scopes all resolve to nothing gets "the token's scopes no longer grant this route", not "account unknown"; the listing check is a refusal; known scope, missing admin and OAuth subject unchanged | Postgres | `go test ./modules/pier -run '^TestBackendScopeUnavailable$'` | ✅ `modules/pier/backend_scope_unavailable_test.go` | ✅ green |
|
||||
| RA-WR-06/RA-IN-06 | the verdict is qualified while demo pins are unreleased; a silent failing pin check is refused | gate | `bash scripts/check-phase19.7.sh --self-test` (`pins-test-only-unrecorded`, `pins-silent-failure`) | ✅ `scripts/check-phase19.7.sh` | ✅ green |
|
||||
| RB-WR-01/RB-IN-01 | Ctrl+S and Ctrl+Enter commit a draft inside an open or closed field-type shadow root; control-character and bare `https://` URLs render no link and open no window | vitest | `npm --prefix admin run test` | ✅ `admin/tests/app/hotkeysEditing.test.ts`, `admin/tests/account/AccountContributions.test.ts` | ✅ green |
|
||||
| RB-WR-02 | a padded or whitespace-carrying token scope name fails boot | unit | `go test -short ./modules/cabana -run '^TestTokenScopeNameParity$'` | ✅ `modules/cabana/token_scope_name_test.go` | ✅ green |
|
||||
| RB-IN-02 | a failing Applies marks its My account section | unit | `go test -short ./modules/cabana -run '^TestAccountContributionsAppliesFailureFlagsSection$'` | ✅ `modules/cabana/account_contributions_hardening_test.go` | ✅ green |
|
||||
| RC-WR-01 | a backend grant acts only as the administrator it was consented for: decide 409 matrix, binding through code, exchange, rotation and verifier, link change, revoke racing a rotation | Postgres + integration + e2e | oauthserver plugin `go test . -run '^TestMCPBackendBinding$'`; `go test -short ./modules/pier -run '^(TestToolsList\|TestFanOut)$'`; demo `TestMCPEndToEnd` | ✅ `sm-oauthserver-plugin`, `modules/pier/tools_list_test.go`, `modules/pier/fanout_test.go`, `sm-demo-app/mcp_e2e_test.go` | ✅ green |
|
||||
| RC-CR-01/RC-WR-02 | a self-service password change revokes grants rotated after the session's iat and keeps the session; a ban alone refuses the verifier and rotation | Postgres | user plugin `GOWORK=off go test . -run '^TestAccessRevocation$'`; oauthserver plugin `go test . -run '^(TestMCPGrantRevocation\|TestMCPVerifierRevocation)$'` | ✅ `plugins/golem15/user/access_revocation_test.go`, `sm-oauthserver-plugin/mcp_revocation_test.go` | ✅ green |
|
||||
| RC-IN-01/RC-IN-03 | a link code in the query string is ignored on POST; avatar and logo fallbacks use the public path | Postgres | user plugin `GOWORK=off go test . -run '^(TestBackendLinkShowPost\|TestAvatarURL\|TestOrganisationLogo)$'` | ✅ `plugins/golem15/user/backend_link_show_test.go`, `plugins/golem15/user/organisation_logo_test.go` | ✅ green |
|
||||
|
||||
*Status: ⬜ pending · ✅ green · ❌ red · ⚠️ flaky*
|
||||
*Status legend: ✅ green · ❌ red · ⚠️ flaky. Every row is green as of the plan 09 gate run (`bash scripts/check-phase19.7.sh --all`, every stage PASS). The rows after D-31 are the gap closure (plans 06-09); the RA-/RB-/RC- rows are the re-review fixes (19.7-REREVIEW-FIX.md), added by the 2026-10-24 validation audit.*
|
||||
|
||||
---
|
||||
|
||||
## Wave 0 Requirements
|
||||
|
||||
- [ ] `scripts/check-phase19.7.sh` — phase gate (pattern: `scripts/check-phase19.4.sh`)
|
||||
- [ ] pier test helpers: fake guard provider, fake verifier, two-instance harness on one miniredis, SDK client with a bearer-injecting `http.Client`
|
||||
- [ ] user-plugin Postgres fixtures for links and frontend permission rows
|
||||
- [ ] additive-API checks for sm-user-plugin, sm-journal-plugin, sm-oauthserver-plugin
|
||||
- [x] `scripts/check-phase19.7.sh` — phase gate (pattern: `scripts/check-phase19.4.sh`)
|
||||
- [x] pier test helpers: fake guard provider, fake verifier, two-instance harness on one miniredis, SDK client with a bearer-injecting `http.Client` (`modules/pier/helpers_test.go`)
|
||||
- [x] user-plugin Postgres fixtures for links and frontend permission rows (the admin harness, `startLink`/`confirmLink`, the seeded permission rows)
|
||||
- [x] additive-API checks for sm-user-plugin, sm-journal-plugin, sm-oauthserver-plugin (gate stage `plugins`)
|
||||
|
||||
---
|
||||
|
||||
@@ -83,11 +134,23 @@ Filled in by the planner per task; the behaviour → test map is:
|
||||
|
||||
## Validation Sign-Off
|
||||
|
||||
- [ ] All tasks have `<automated>` verify or Wave 0 dependencies
|
||||
- [ ] Sampling continuity: no 3 consecutive tasks without automated verify
|
||||
- [ ] Wave 0 covers all MISSING references
|
||||
- [ ] No watch-mode flags
|
||||
- [ ] Feedback latency < 120s
|
||||
- [ ] `nyquist_compliant: true` set in frontmatter
|
||||
- [x] All tasks have `<automated>` verify or Wave 0 dependencies
|
||||
- [x] Sampling continuity: no 3 consecutive tasks without automated verify
|
||||
- [x] Wave 0 covers all MISSING references
|
||||
- [x] No watch-mode flags
|
||||
- [x] Feedback latency < 120s for the quick run (the full gate with Docker takes several minutes)
|
||||
- [x] Nyquist compliance recorded in the frontmatter
|
||||
|
||||
**Approval:** pending
|
||||
**Approval:** plan 19.7-05 (the gate passes in full); extended by plan 19.7-09 for the gap closure (the gate passes in full)
|
||||
|
||||
---
|
||||
|
||||
## Validation Audit 2026-10-24
|
||||
|
||||
The audit compared the map with the re-review fixes (19.7-REREVIEW-FIX.md). Fifteen behaviours had tests but no row, and they are now in the map. RA-IN-01, RA-IN-03, RB-IN-04 and RC-IN-02 changed only documentation, so they get no row. RA-IN-05 had no test, and `TestBackendScopeUnavailable` (49a3df6) now covers it.
|
||||
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Gaps found | 1 |
|
||||
| Resolved | 1 |
|
||||
| Escalated | 0 |
|
||||
|
||||
188
.planning/phases/19.7-generic-mcp-module/19.7-VERIFICATION.md
Normal file
188
.planning/phases/19.7-generic-mcp-module/19.7-VERIFICATION.md
Normal file
File diff suppressed because one or more lines are too long
37
.planning/phases/19.7-generic-mcp-module/COVERAGE.md
Normal file
37
.planning/phases/19.7-generic-mcp-module/COVERAGE.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# API Coverage — MCP server surface (pier, go-sdk v1.8.0)
|
||||
|
||||
> Full coverage by default. Opt-outs are explicit, reasoned decisions.
|
||||
|
||||
Phase 19.7 calls no third-party service at runtime. It implements an MCP server (`modules/pier`) on the official `github.com/modelcontextprotocol/go-sdk` v1.8.0 (D-24, `.planning/notes/2026-10-22-mcp-go-sdk.md`), compiled in only with the `summercms_mcp` build tag (D-33) and off by default (D-30). Authorization rides on the oauthserver plugin's MCP flavour from Phase 19.4. The matrix records which parts of the MCP protocol pier serves (INTEGRATE) and which it leaves out on purpose (OPT-OUT), so a client's expectations can be checked against it.
|
||||
|
||||
| capability | decision | reason |
|
||||
|---|---|---|
|
||||
| transport: streamable HTTP, stateful (`Mcp-Session-Id`, SSE responses) | INTEGRATE | D-25; sessions in Redis (or memory) with a sliding idle TTL (D-27) |
|
||||
| transport: stateless streamable HTTP for 2026-07-28 clients | INTEGRATE | D-32; go-sdk v1.8.0 serves 2026-07-28 only statelessly |
|
||||
| transport: version negotiation 2025-03-26, 2025-11-25, 2026-07-28 | INTEGRATE | `negotiatedVersion` mirrors the SDK rule; the header picks the path |
|
||||
| transport: stdio | OPT-OUT | pier is a network service inside the application binary; there is no local process to spawn |
|
||||
| transport: legacy HTTP+SSE (2024-11-05) | OPT-OUT | deprecated by the protocol; every supported client speaks streamable HTTP |
|
||||
| transport: stream resumability (`Last-Event-ID`, event store) | OPT-OUT | tool calls are short HTTP route dispatches; a dropped stream is retried by the client |
|
||||
| authorization: protected resource metadata (RFC 9728) | INTEGRATE | `prm.go`, through the SDK's `auth.ProtectedResourceMetadataHandler` |
|
||||
| authorization: 401 with `WWW-Authenticate` (resource metadata, scope) | INTEGRATE | `pier.go`; scope hint `read` added when absent |
|
||||
| authorization: bearer token verification (MCP grants, member `usr_` tokens) | INTEGRATE | D-20 to D-23; revocation ends or narrows sessions (D-27) |
|
||||
| authorization: `read`/`write` ceiling and separate `backend` scope | INTEGRATE | D-20, D-21; permissions always filter on top |
|
||||
| lifecycle: initialize, initialized, ping | INTEGRATE | SDK; `InitializedHandler` arms the session |
|
||||
| server info: name and version | INTEGRATE | application name and the framework module version |
|
||||
| tools: `tools/list`, `tools/call` | INTEGRATE | plugin-declared tools dispatched to their HTTP routes (D-12, D-23) |
|
||||
| tools: annotations (`readOnlyHint` and the rest) | INTEGRATE | `annotationsFor`; `readOnlyHint` drives the `read` ceiling |
|
||||
| tools: `outputSchema` and `structuredContent` | INTEGRATE | `catalog.go`, `dispatch.go` |
|
||||
| tools: `notifications/tools/list_changed` | INTEGRATE | D-26; pushed over Redis pub/sub to the instance holding the session |
|
||||
| prompts: `prompts/list`, `prompts/get` with arguments | INTEGRATE | D-28; filtered and prefixed like tools |
|
||||
| prompts: `notifications/prompts/list_changed` | INTEGRATE | D-26 |
|
||||
| resources: `resources/list`, `resources/read`, templates | OPT-OUT | D-28: the capability is shaped for them, a follow-up phase ships them (CONTEXT deferred ideas) |
|
||||
| resources: `resources/subscribe`, `notifications/resources/updated` | OPT-OUT | follows resources (deferred) |
|
||||
| completion: `completion/complete` | OPT-OUT | no resources and no enumerable prompt arguments yet; returns with resources |
|
||||
| logging: `logging/setLevel`, `notifications/message` | OPT-OUT | the capability is not advertised; calls are audited server-side instead (`audit.go`) |
|
||||
| progress notifications | OPT-OUT | route dispatches are bounded by `mcp.call_timeout`; no long-running tool exists |
|
||||
| cancellation (`notifications/cancelled`) | INTEGRATE | handled by the SDK; the call context is cancelled and the dispatched request with it |
|
||||
| client features: sampling (`sampling/createMessage`) | OPT-OUT | tools are plugin HTTP routes; the server never asks the client's model |
|
||||
| client features: elicitation | OPT-OUT | consent and account linking happen in the browser (oauthserver consent, `/link-admin`), not in the agent |
|
||||
| client features: roots | OPT-OUT | no filesystem semantics on a CMS server |
|
||||
| tasks (2025-11-25 experimental) | OPT-OUT | experimental in the protocol; no long-running tool exists |
|
||||
| pagination of list results | INTEGRATE | handled by the SDK |
|
||||
351
.planning/phases/19.7-generic-mcp-module/deferred-items.md
Normal file
351
.planning/phases/19.7-generic-mcp-module/deferred-items.md
Normal file
@@ -0,0 +1,351 @@
|
||||
# Deferred items
|
||||
|
||||
Out-of-scope discoveries made while executing phase 19.7 plans. Nothing here
|
||||
was changed by the plan that recorded it.
|
||||
|
||||
## Deferred Items
|
||||
|
||||
- Pre-existing `gofmt` drift in cabana (found during 19.7-01 Task 1)
|
||||
status: open
|
||||
**What:** `gofmt -l modules/cabana` lists `account_tokens.go`,
|
||||
`account_tokens_test.go`, `field_trigger_smoke_test.go`,
|
||||
`token_postgres_smoke_test.go`, `token_routes_test.go` and
|
||||
`token_scopes_test.go` as unformatted before this plan touched the module
|
||||
(alignment of map literals and struct tags). Left as is: reformatting
|
||||
would add diff noise unrelated to the plan (a whole-file `gofmt -w` on
|
||||
`token_routes_test.go` rewrote 132 lines and was reverted). A one-line
|
||||
`gofmt -w` on those six files in a `style(cabana)` commit of its own fixes it.
|
||||
- `AdminRecordAction.Prompt` acceptance grep counted two `prompt,omitempty`
|
||||
tags in `schema_types.go` (found during 19.7-01 Task 4)
|
||||
status: resolved
|
||||
**What:** the second match is the pre-existing `FormField.Prompt` JSON tag
|
||||
at `schema_types.go:376`, not a duplicate of the new `RecordAction.Prompt`;
|
||||
the criterion's "prints 1" was written without that line in mind. No change
|
||||
needed.
|
||||
- Stateful pier sessions cannot carry the SDK's protocol-version context value (found during 19.7-02 Task 3)
|
||||
status: open
|
||||
**What:** go-sdk v1.8.0's `StreamableHTTPHandler.ServeHTTP` stores the
|
||||
`Mcp-Protocol-Version` header under an unexported context key that the
|
||||
transport's `servePOST`/`serveGET` read; pier's own session router (needed
|
||||
for Redis-shared sessions, D-25) serves `StreamableServerTransport`
|
||||
directly and cannot set that key, so stateful streams run with the SDK's
|
||||
2025-03-26 defaults for stream close/reconnect hints and the JSON-RPC
|
||||
batch rule (lenient, spec-compliant for older clients; 2026-07-28 clients
|
||||
go through the SDK's own stateless handler). Revisit if a later SDK
|
||||
exports the key or a transport-level setter; plan 05 may add a test
|
||||
pinning the behaviour.
|
||||
- `notifications/initialized` landing on another instance than `initialize` (found during 19.7-02 Task 3)
|
||||
status: open
|
||||
**What:** the session state is persisted after `initialize` and again
|
||||
after the client's `initialized` notification; when a load balancer sends
|
||||
the notification to a second instance, the first instance's local copy
|
||||
keeps `InitializedParams` nil and refuses calls until that copy is
|
||||
dropped (session end, revocation or process restart) while the second
|
||||
instance serves them. Sticky sessions or a per-request re-read of the
|
||||
stored `initialized` flag would close the gap; not needed for the
|
||||
single-instance demo.
|
||||
- cabana's backend subject events never reach pier (found during 19.7-03 Task 2)
|
||||
status: resolved
|
||||
**What:** `modules/cabana/subject_events.go` fires `pact.MCPSubjectChanged`
|
||||
as a value (`app.Events.Fire(ctx, pact.MCPSubjectChanged{...})`), while
|
||||
`modules/pier/events.go` listens for a pointer
|
||||
(`func(ctx, ev *pact.MCPSubjectChanged)`). festival.Bus keys listeners by
|
||||
the type parameter, so pier never sees the backend subject events cabana fires
|
||||
(admin deletion, permission and role changes, token revocation): no
|
||||
list_changed and no session close for the `backend` guard from cabana.
|
||||
cabana also fires inside the save's transaction instead of after commit,
|
||||
so a rolled-back save would still notify. sm-user-plugin v0.1.10 fires
|
||||
`*pact.MCPSubjectChanged` (pointer) through `lagoon.AfterCommit`, which
|
||||
pier does receive. Fix in the framework: fire `&pact.MCPSubjectChanged{}`
|
||||
from cabana and defer it with `lagoon.AfterCommit`, with a pier test that
|
||||
a cabana save reaches `handleEvent`. Must be fixed before v0.5.0.
|
||||
**Resolved:** cabana now fires `&pact.MCPSubjectChanged{}` through
|
||||
`lagoon.AfterCommit` (immediately outside a transaction);
|
||||
`subject_events_test.go` pins delivery to a pointer listener, no firing
|
||||
before commit and none after a rollback.
|
||||
- pier publishes `*pier.Pier` once per application (found during 19.7-04 Task 1)
|
||||
status: open
|
||||
**What:** `pier.Mount` publishes the mounted endpoint on the app, so a
|
||||
second `surf.BuildRouter`/`surf.Assemble` on the same `*backpack.App`
|
||||
with `mcp.enabled: true` fails with `backpack: duplicate provider for
|
||||
*pier.Pier`. A binary builds its router once, so serving is unaffected;
|
||||
tests that build twice on one app (sm-demo-app `TestRealtimeRoutes`,
|
||||
`socialServer`) now set `mcp.enabled: false`. A find-or-replace publish
|
||||
(or skipping the publish when the same app already carries one) in pier
|
||||
would lift it.
|
||||
- MCP grants are not in the authorized-apps list (found during 19.7-04 Task 2)
|
||||
status: open
|
||||
**What:** the MCP flow (wristband `IssueCode`, sm-oauthserver-plugin's
|
||||
`MCPStore`) stamps the client's `consented_at` but writes no row to
|
||||
`golem15_oauthserver_consents`, so `GET /oauth/authorizations` does not
|
||||
list an MCP client and `DELETE /oauth/authorizations/{client_id}` answers
|
||||
404 for it. The access token itself can still be revoked (row
|
||||
`revoked_at`, refused by the verifier at once) and the user cascade
|
||||
removes every grant, but a user has no self-service "disconnect this
|
||||
agent" for MCP yet. A consent row per MCP grant (written at `IssueCode`)
|
||||
would make the existing list and revocation (which already fires the
|
||||
`revoked` event) cover MCP clients; plan 05's revoke matrix should decide.
|
||||
**Plan 05 decision:** accepted for this phase (19.7-SECURITY.md AR-19.7-03):
|
||||
access still ends through client revocation, user deletion or
|
||||
deactivation, token expiry and the verifier's refusal of a revoked token,
|
||||
and `TestMCPEndToEnd` pins that the `revoked` event ends the session. The
|
||||
consent row per MCP grant stays the follow-up.
|
||||
- Pre-existing `gofmt` drift in sm-journal-plugin (found during 19.7-04 Task 3)
|
||||
status: open
|
||||
**What:** `gofmt -l` lists `classes/blog_editor_test.go` before this plan
|
||||
touched the repository. Left as is.
|
||||
- sm-demo-app push and the demo deploy wait for the user (found during 19.7-04 Task 5)
|
||||
status: open
|
||||
**What:** sm-demo-app master is eight commits ahead of origin (a25444e,
|
||||
985af53 and this plan's 44cac13, 8668918, the pins aec16c4 oauthserver
|
||||
v0.1.2, 996586c journal v0.2.3, 7e76957 vue-demo-app 21a22b6, and
|
||||
c21ae9d with the nginx MCP locations and DEPLOY.md "MCP endpoint"). None
|
||||
is pushed and nothing is deployed: both need the user's go-ahead. The
|
||||
deploy also installs the changed vhost (DEPLOY.md, "When
|
||||
deploy/nginx/demo.summercms.io.conf changed") and runs the MCP smoke.
|
||||
The sm-oauthserver-plugin v0.1.2 and sm-journal-plugin v0.2.3 tags and
|
||||
the vue-demo-app commit are pushed.
|
||||
- Release builds pinning summercms v0.4.4 lack the cabana subject-event fix (found during 19.7-04 Task 5)
|
||||
status: open
|
||||
**What:** the demo (GOWORK=off release build), oauthserver v0.1.2 and
|
||||
Journal v0.2.3 require summercms v0.4.4, which predates d96c726
|
||||
(cabana fires `*pact.MCPSubjectChanged` after commit). Development
|
||||
builds use the go.work replace and carry the fix; a release binary does
|
||||
not: admin deletion, permission or role changes and token revocation in
|
||||
the admin do not end MCP sessions or send list_changed until the next
|
||||
framework tag is required by the demo. The verifier and the backend
|
||||
resolver still refuse at the next request, so access does not outlive
|
||||
the change; only the live session notification is missing. Deploy the
|
||||
demo after the next framework tag, or accept the gap for the demo.
|
||||
- Redis for MCP sessions on rome (found during 19.7-04 Task 5)
|
||||
status: open
|
||||
**What:** the demo runs one instance with `mcp.sessions.store: memory`.
|
||||
A second instance needs `SUMMER_MCP__SESSIONS__STORE=redis` and
|
||||
`SUMMER_REDIS__URL` on every instance (DEPLOY.md, "MCP endpoint") and a
|
||||
Redis on rome; also see the `notifications/initialized` item above.
|
||||
- Real MCP client check of the demo not run (found during 19.7-04 Task 5)
|
||||
status: open
|
||||
**What:** Task 5's human check (a real client against the local demo:
|
||||
OAuth sign-in on /connect, user_me only, link an admin through
|
||||
/link-admin, reconnect with backend, the journal_ tools, a draft post,
|
||||
unlink) was not performed in the executor run; the automated
|
||||
TestMCPEndToEnd covers the same path. The local setup is DEPLOY.md,
|
||||
"MCP endpoint", "Locally".
|
||||
- Retracted `github.com/gabriel-vasile/mimetype` v1.4.15 in sm-demo-app (found during 19.7-04 Task 5)
|
||||
status: open
|
||||
**What:** `go get` in sm-demo-app warns that mimetype v1.4.15 is
|
||||
retracted (quadratic time on crafted CDF files). It arrives indirectly
|
||||
and predates this plan; a `go get github.com/gabriel-vasile/mimetype@latest`
|
||||
in the framework (and a tag) would lift it for every consumer.
|
||||
- Framework fixes of plan 05 are on master only (found during 19.7-05 Tasks 1-2)
|
||||
status: open
|
||||
**What:** c49983d `fix(cabana)` (the `backend` middleware refuses a
|
||||
dispatch marker with a frontend principal), c29d228 `fix(pier)` (a
|
||||
`tools/call` without arguments) and 1111828 `fix(pier)` (an ended session
|
||||
is not written back by a late request) are not in any tag. Applications
|
||||
pinning summercms v0.4.4 (the demo's release build, oauthserver v0.1.2,
|
||||
Journal v0.2.3) lack them until they require the next framework tag
|
||||
(v0.5.0 at phase completion, after the user's go-ahead).
|
||||
**Gap closure (19.7-09):** the same holds for every framework fix of plans
|
||||
06 and 07; they ship together in v0.5.0 (see "Release order after the gap
|
||||
closure" below).
|
||||
- Plan 05 test commits are local and untagged (found during 19.7-05 Task 3)
|
||||
status: resolved
|
||||
**What:** sm-user-plugin 72de822 (in the sm-demo-app submodule checkout
|
||||
`plugins/golem15/user`), sm-oauthserver-plugin 2929c91, sm-journal-plugin
|
||||
a9a9b80 and sm-demo-app 6fa2d56 add tests only; none is pushed or tagged.
|
||||
sm-demo-app's `plugins/golem15/user` working tree is ahead of its v0.1.10
|
||||
pin by that test-only commit and the pointer is not committed;
|
||||
`scripts/check-pins.sh` reports the mismatch, which the phase gate accepts
|
||||
only because the commits touch `*_test.go` files alone. A patch tag
|
||||
(sm-user-plugin v0.1.11, sm-oauthserver-plugin v0.1.3, sm-journal-plugin
|
||||
v0.2.4) is optional; it would change no shipped code. Push and tags wait
|
||||
for the user.
|
||||
**Superseded (19.7-09):** the plugins now also carry the non-test fixes of
|
||||
plan 08 and the tests of plan 09, so the plan 05 test commits ship in the
|
||||
gap-closure plugin tags that require framework v0.5.0; the entries "Demo
|
||||
plugin submodules and pointers wait for the release" and "Release order
|
||||
after the gap closure" below track them.
|
||||
- Superuser refusal switch, conditional (found during 19.7-05 Task 4)
|
||||
status: open
|
||||
**What:** the security review accepted superuser reach through an agent
|
||||
(19.7-SECURITY.md AR-19.7-02) and did not add
|
||||
`mcp.refuse_superuser_backend`. When a plugin declares a superuser-only or
|
||||
destructive backend tool beyond content editing, add the switch (a
|
||||
`fix(pier)` with README and docs) and cut a framework patch tag with the
|
||||
user's go-ahead.
|
||||
- B-IN-05: a prompted record action refused with 422 closes the dialog (found in the code review, deferred by 19.7-07)
|
||||
status: open
|
||||
**What:** when a prompted record action answers 422, the SPA shows the
|
||||
error toast and closes the prompt dialog, so the typed text is lost.
|
||||
Plan 07 corrected the contract text (the 422 toast behaviour is now what
|
||||
the docs and the OpenAPI description say). Keeping the dialog open needs a
|
||||
change to the shared confirm primitive every action uses (the dialog
|
||||
resolves before the request answers), which is out of the gap closure's
|
||||
scope. Follow-up: let the confirm primitive keep the dialog open on a
|
||||
refused submit and show the field error inline.
|
||||
- B-IN-06: `window.open` after an awaited POST can be blocked by a popup blocker (found in the code review)
|
||||
status: resolved
|
||||
**What:** no fix required. My account always renders the answered URL as
|
||||
a visible link next to the section (`data-account-contribution-url`), so
|
||||
an administrator whose browser blocked the popup clicks the link
|
||||
(pinned by `admin/tests/account/AccountContributions.test.ts`).
|
||||
- `admin:token:revoke` fires no MCP event (found during 19.7-07)
|
||||
status: open
|
||||
**What:** the CLI command revokes an admin personal token's row but does
|
||||
not fire the token-specific `revoked` subject event that the My account
|
||||
revoke fires (`fireTokenRevoked`). The verifier side refuses the revoked
|
||||
token on the next request, so access ends; only a live MCP session of
|
||||
that token keeps its stream until its next request or re-check. Same
|
||||
shape as before plan 07. Fix: call the same helper from the command after
|
||||
its transaction.
|
||||
**Re-review (RB-IN-03):** kept deferred. Calling `fireTokenRevoked` from
|
||||
the command is not enough: the command runs in its own process, which
|
||||
mounts no MCP endpoint, so no pier listener receives the event and nothing
|
||||
reaches the store a running server reads. Closing it needs the command to
|
||||
publish into pier's store directly (a cross-module seam). 4d7eb9d
|
||||
documents in the cabana README that only the My account revoke fires the
|
||||
event.
|
||||
- RB-IN-04 optional narrowing: a focused widget host also mutes Esc, / and ? (found in the gap-closure re-review)
|
||||
status: open
|
||||
**What:** 89b85f5 documents the trade-off in `admin/src/app/hotkeys.ts`.
|
||||
The optional narrowing to plugin field types (a `data-field-type` marker)
|
||||
was not made: a `type: widget` element with an input in a closed shadow
|
||||
root would then let Esc leave the form while the admin types in it.
|
||||
- OIDC grants on a ban or a password reset (decided during 19.7-08)
|
||||
status: resolved
|
||||
**What:** the user decided on 2026-10-23 that a ban, a password reset, an
|
||||
administrator setting a password and the user's own password change end
|
||||
both the MCP and the OIDC grants of the user (tokens revoked, consents
|
||||
and unused codes deleted, subjects kept). Implemented by
|
||||
`Cascade.OnAccessRevoked` (sm-oauthserver-plugin 671513d) and pinned by
|
||||
`TestMCPGrantRevocation` ("access revoked ends earlier MCP and OIDC
|
||||
grants and keeps later ones") and `TestMCPRevocationSmoke`.
|
||||
- Local sm-oauthserver-plugin go.work retarget (found during 19.7-08 Task 2)
|
||||
status: open
|
||||
**What:** the tracked `go.work` of sm-oauthserver-plugin is modified in
|
||||
the working tree only: its `sm-user-plugin` replace points at
|
||||
`../sm-demo-app/plugins/golem15/user` (the canonical user checkout of the
|
||||
gap closure) instead of the committed `../fonoteka.go/plugins/golem15/user`.
|
||||
The phase gate's workspace check requires exactly that target, so the
|
||||
gate passes on this machine only with the local edit. Before the release
|
||||
either restore the committed line or decide whether go.work should leave
|
||||
version control; never commit the local retarget.
|
||||
- Demo plugin submodules and pointers wait for the release (found during 19.7-08, updated by 19.7-09)
|
||||
status: open
|
||||
**What:** in sm-demo-app the working-tree checkouts of
|
||||
`plugins/golem15/oauthserver` (671513d, its canonical checkout is at
|
||||
65f71dc with plan 09's test), `plugins/golem15/journal` (b129902,
|
||||
canonical at 2aeeccc) and `plugins/golem15/user` (the canonical user
|
||||
checkout itself, 38551a4) are ahead of their committed pins (v0.1.2,
|
||||
v0.2.3, v0.1.10) by unreleased commits. The gate reports them as
|
||||
`pins: … is ahead of its pin by unreleased commits` and refuses them with
|
||||
`PHASE197_RELEASED=1`. The pointers are committed only after the plugin
|
||||
tags. sm-demo-app's `vue-demo-app` pointer is committed (00f57bf, then
|
||||
f53d30a for the link code test): vue-demo-app (0125e29, b973a76) must be
|
||||
pushed before sm-demo-app.
|
||||
- Release order after the gap closure (decided 2026-10-23)
|
||||
status: open
|
||||
**What:** nothing of plans 06-09 is tagged or pushed. After the re-review
|
||||
of the gap closure, phase verification, Nyquist validation and UAT pass,
|
||||
and on the user's go-ahead:
|
||||
1. framework v0.5.0 (and the changelog post);
|
||||
2. the sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin tags
|
||||
that require it;
|
||||
3. the bumps in sm-demo-app, fonoteka.go and sm-bm-app, with vue-demo-app
|
||||
pushed before sm-demo-app;
|
||||
4. sm-servers-app picks up E-1 and E-2 after the user plugin tag;
|
||||
5. then `PHASE197_RELEASED=1 bash scripts/check-phase19.7.sh --consumers`
|
||||
must pass (every demo pin on its tag, no drift).
|
||||
- `readLinkCode` accepts a valid code next to other fragment parameters (found during 19.7-09 Task 3)
|
||||
status: resolved (gap-closure re-review: not a defect; vue-demo-app 9c247ab pins the lenient parse)
|
||||
**What:** plan 09 described "extra parameters give ''" for the link page's
|
||||
code reader. `readLinkCode` parses the fragment with URLSearchParams, so
|
||||
`#code=<64 hex>&next=/x` answers the code, while an extended or foreign
|
||||
value (`#code=<hex>x`, `#other=<hex>`) answers ''. `linkCode.test.ts`
|
||||
pins the latter and leaves the former unasserted. My account only ever
|
||||
sends `#code=<code>`, so nothing depends on it; the re-review decides
|
||||
whether to keep the lenient parse or require the fragment to be exactly
|
||||
`code=<64 hex>`.
|
||||
- `docs/examples/blog` test failed once on GOPROXY=off (found during 19.7-09 Task 1)
|
||||
status: open
|
||||
**What:** one `go test -short ./...` run of the gate's go stage failed in
|
||||
`docs/examples/blog` with "module lookup disabled by GOPROXY=off" for
|
||||
`golang.org/x/exp`; the package passed alone and in more than twenty later
|
||||
full runs. The test builds a scratch module offline and depends on the
|
||||
module cache holding every dependency; a run that coincides with a cache
|
||||
change may miss one. Not caused by this phase's code; watch for a
|
||||
recurrence.
|
||||
- RA-IN-04: the cap of the non-reserving store fallback is still check-then-act (found in the gap-closure re-review, deferred by its lane A fixes)
|
||||
status: open
|
||||
**What:** 034aa19 makes `serveNew`'s fallback for a store without
|
||||
`Reserve` write the record before the server is built, so a reaper pass
|
||||
can no longer close a session that has no record yet. The Count-then-Put
|
||||
cap of that fallback remains racy. Closing it means making `Reserve` part
|
||||
of the exported `pier.Store` interface or refusing a store without it at
|
||||
mount, which changes pier's exported API for a branch only a test wrapper
|
||||
(`WrapStore`) reaches; both shipped stores reserve atomically.
|
||||
- RA-WR-06 optional: the demo pin check does not require unreleased commits to be on the canonical checkout's upstream (found in the gap-closure re-review)
|
||||
status: open
|
||||
**What:** 2fdda99 qualifies the gate's verdict ("Phase 19.7 gate passed
|
||||
WITH UNRELEASED PINS: the release pins are not yet proven") while demo
|
||||
submodules carry unreleased non-test commits; the exit status stays 0 so
|
||||
the pre-release verification can run. The review's optional
|
||||
`git branch -r --contains` check was not added: the gap-closure commits
|
||||
are deliberately unpushed until the release order runs, so it would
|
||||
refuse every pre-release run. `PHASE197_RELEASED=1` after the tags is
|
||||
the release proof.
|
||||
- RC-CR-01 optional: base the session cutoff on `auth_time` (found in the gap-closure re-review, lane C)
|
||||
status: open
|
||||
**What:** the self-service password change now revokes every OAuth grant
|
||||
as of the request (sm-user-plugin 30f7a01). The calling session's own
|
||||
cutoff is still its `iat` second, so an attacker's frontend session JWT
|
||||
refreshed after the victim's `iat` survives the change too. That predates
|
||||
this phase; closing it means basing `tokens_valid_after` on the calling
|
||||
token's `auth_time` and having `POST /refresh` and the jwt guard compare
|
||||
`auth_time` with the cutoff, a change to session revocation in a core
|
||||
plugin (and to how bouncer's refresh is checked) that needs its own
|
||||
decision.
|
||||
- RC-IN-01 nginx: keep the deprecated link GET route's code out of access logs (found in the gap-closure re-review, lane C)
|
||||
status: open
|
||||
**What:** sm-user-plugin 92676ba makes the show and confirm POSTs ignore
|
||||
a code in the query string. `GET /_user/api/v1/backend-link/{code}` stays
|
||||
for compatibility (removed only in a major release), so nginx still logs
|
||||
the code if a third-party client calls it. `access_log off;` (or a
|
||||
`log_format` without `$request_uri`) for
|
||||
`location ~ ^/_user/api/v1/backend-link/` in the demo's nginx config is a
|
||||
deploy change, made with the next demo deploy; the shipped page never
|
||||
calls the GET route.
|
||||
- RC-IN-06: the legacy MintAPIToken fallback is widened before the phrase-key check (found in the gap-closure re-review, lane C)
|
||||
status: open
|
||||
**What:** `classes.CompileAPITokenScopes` adds the declared names to the
|
||||
process-wide fallback set before `bootAPITokenScopes` checks their phrase
|
||||
keys, so a boot that fails on a missing key has already widened what
|
||||
`MintAPIToken` accepts. Moving the add after the check needs a new
|
||||
exported seam or a behaviour change of the exported
|
||||
`CompileAPITokenScopes` in a core plugin; a failed boot ends the process,
|
||||
so the widened set is never used in production. `MintAPIToken` is now
|
||||
marked `Deprecated:` in favour of `MintAPITokenFor` (sm-user-plugin
|
||||
9892404), which checks the application's own catalog.
|
||||
- RC-IN-07: sm-oauthserver-plugin builds only through its workspace file (found in the gap-closure re-review, lane C)
|
||||
status: open (release-time)
|
||||
**What:** the plugin uses `userclasses.AccessRevokedEvent`,
|
||||
`FireSubjectEvent` and `FireSubjectEventAfterCommit`, which the required
|
||||
sm-user-plugin v0.1.10 lacks, so `GOWORK=off go build ./...` fails. The
|
||||
release checklist for the oauthserver tag must bump `sm-user-plugin` to
|
||||
the new user plugin tag and pass `GOWORK=off go build ./...` before the
|
||||
tag; the requires are not bumped before the user plugin is tagged.
|
||||
- Lane C re-review fixes moved the demo's oauthserver checkout (gap-closure re-review, lane C)
|
||||
status: open
|
||||
**What:** pier now gives a backend subject only to a grant that records
|
||||
its consented administrator (`pact.MCPGrant.BackendUserID`, framework
|
||||
c37c6ce), so the demo's e2e tests need the oauthserver commits that
|
||||
record it. The working-tree checkout of sm-demo-app's
|
||||
`plugins/golem15/oauthserver` was moved from 671513d to the canonical
|
||||
b6a9586 (detached, fast-forward; the pointer stays uncommitted until the
|
||||
plugin tag, as before). Canonical heads after the lane C fixes:
|
||||
sm-user-plugin 9892404, sm-oauthserver-plugin 9813c1d,
|
||||
sm-journal-plugin 521df9a (its prompt test's fake grants now name the
|
||||
consented administrator), vue-demo-app 9c247ab. `backend` grants issued before the oauthserver
|
||||
migration `202610230001` record no administrator and stop acting as one
|
||||
until the agent is connected again.
|
||||
@@ -3,13 +3,44 @@ phase: 19.8-console-commands-overhaul
|
||||
plan: 06
|
||||
subsystem: release
|
||||
tags: [release, v0.4.2, changelog, demo-roadmap, gate]
|
||||
status: draft
|
||||
status: complete
|
||||
gap_closure: true
|
||||
requires:
|
||||
- phase: 19.8-05
|
||||
provides: the eleven review fixes and the Release impact table
|
||||
provides:
|
||||
- "SummerCMS v0.4.2: annotated tag 60b13ae on ead8e42, on origin with master fast-forwarded to it"
|
||||
- "Changelog post https://summercms.io/changelog/summercms-0-4-2 (id 37)"
|
||||
- "sm-demo-app roadmap snapshot synced to origin/master ead8e42 (aa4de22, pushed)"
|
||||
- "Phase 19.8 --all gate green with Docker required"
|
||||
affects: [applications and plugins pinning SummerCMS (fixes available from v0.4.2), demo roadmap deck]
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: []
|
||||
key-files:
|
||||
created: []
|
||||
modified:
|
||||
- .planning/phases/19.8-console-commands-overhaul/19.8-06-SUMMARY.md
|
||||
- ../sm-demo-app/plugins/demo/content/ROADMAP.md
|
||||
key-decisions:
|
||||
- "Reply 'release' read as the proposed tag v0.4.2"
|
||||
- "Tagged the commit that records the go-ahead (ead8e42, planning-only on top of the proposal) after vet, short tests and the docs checker passed there"
|
||||
- "No plugin require bumps or application regenerate commits: no row of plan 05's Release impact table asks for one"
|
||||
- "No Polish name needed: the roadmap change adds no phase (19.6.1 already had one, 762bb90)"
|
||||
requirements-completed: [D-26]
|
||||
actuals:
|
||||
tokens: 4000 # chars/4 over the realized diff (this SUMMARY and the 6-line roadmap snapshot change)
|
||||
tasks: 3
|
||||
commits: 2 # MEASURED: git rev-list --count plan_head_before..HEAD before the final docs commit
|
||||
plan_head_before: 8020b177ffc70f1b980ae769b80f55598998ce77
|
||||
plan_head_after: ead8e422113d43c9ee828a92a628783634f65294
|
||||
duration: 35min
|
||||
completed: 2026-10-22
|
||||
---
|
||||
|
||||
# Phase 19.8 Plan 06: Release of the Review Fixes Summary (draft)
|
||||
# Phase 19.8 Plan 06: Release of the Review Fixes Summary
|
||||
|
||||
**Draft. Task 1 (the release go-ahead) is waiting for the user's reply. Nothing has been pushed or tagged.**
|
||||
**SummerCMS v0.4.2 is tagged and on origin, with its changelog post at https://summercms.io/changelog/summercms-0-4-2. The tag is annotated, on ead8e42, and master was fast-forwarded to exactly that commit. The demo roadmap snapshot follows the published roadmap, and the phase 19.8 `--all` gate is green with Docker required. Nothing was deployed or force-pushed.**
|
||||
|
||||
## Release proposal
|
||||
|
||||
@@ -90,3 +121,109 @@ The user's reply, verbatim:
|
||||
> release
|
||||
|
||||
Read as the recommended option with the proposed tag: **release v0.4.2** (RELEASE_TAG=v0.4.2). The reply authorises an annotated tag v0.4.2 on the tested commit, a fast-forward push of exactly that commit to origin master followed by the tag, the same-day changelog post, the sm-demo-app roadmap snapshot commit and its push (when it is the only unpushed commit there), then the `--all` gate. No force push, no deploy.
|
||||
|
||||
The reply was recorded in `ead8e42 docs(19.8-06): record the go-ahead: release v0.4.2` before anything was tagged or pushed. That commit is the one tagged.
|
||||
|
||||
## Task 2: published
|
||||
|
||||
### Range check after a fresh fetch
|
||||
|
||||
- `git fetch origin`: exit 0, no output. origin/master was still `6c2164a`, so no other session had pushed.
|
||||
- Newest tag: still **v0.4.1**, and origin had only v0.4.0 and v0.4.1 in `v0.4.*`. The proposed tag was still correct.
|
||||
- `git log --format='%h %s' origin/master..ead8e42`: **20 commits**. These are the 18 classified in the proposal, plus `cf06185` (the proposal, which touches only `19.8-06-SUMMARY.md`) and `ead8e42` (the reply, the same file). Class totals: 12 plan 05 code commits, 8 planning documents of this phase, **0 planning documents of other sessions, 0 other code**.
|
||||
- `git merge-base --is-ancestor origin/master ead8e42`: the push is a fast-forward.
|
||||
|
||||
### Checks at the tested commit `ead8e42`
|
||||
|
||||
GOCACHE pointed at the session scratchpad (tmpfs) for every go command. `go clean` was not run.
|
||||
|
||||
| Check | Result |
|
||||
|-------|--------|
|
||||
| `go vet ./...` | PASS |
|
||||
| `go test -count=1 -short ./...` | PASS (exit 0, every package ok) |
|
||||
| `go run ./cmd/summer docs:build --check` | PASS ("docs:build: no problems found") |
|
||||
|
||||
### Tag
|
||||
|
||||
- `git tag -a v0.4.2 ead8e42`: tag object **`60b13aee5dca32b7202e35f92e605652f66b8a97`**, `git cat-file -t v0.4.2` = `tag`, `v0.4.2^{commit}` = `ead8e422113d43c9ee828a92a628783634f65294`.
|
||||
- Message: `SummerCMS v0.4.2`, then "Fixes from the review of the 0.4 console.", then a Fixed list of nine bullets in user words and an Added list (`bonfire.WithExitCode`, `bonfire.Sanitize`). It has no finding IDs and no planning or quick codes.
|
||||
|
||||
### Pushed ranges
|
||||
|
||||
| Repository | Push | Range |
|
||||
|------------|------|-------|
|
||||
| summercms (framework) | `git push origin ead8e42…:refs/heads/master` | `6c2164a..ead8e42` (fast-forward, 20 commits) |
|
||||
| summercms (framework) | `git push origin v0.4.2` | new tag v0.4.2. `git ls-remote --exit-code --tags origin v0.4.2` → `60b13ae… refs/tags/v0.4.2` |
|
||||
| sm-demo-app | `git push origin HEAD:refs/heads/master` | `762bb90..aa4de22` (1 commit, see Task 3) |
|
||||
|
||||
The Task 2 verify command (`ls-remote` the tag, fetch, the tagged commit is an ancestor of origin/master, the tag is annotated) passed.
|
||||
|
||||
### Changelog
|
||||
|
||||
- `scripts/changelog-post.py source v0.4.2` (from ../sm-summercmsio-app): TAG v0.4.2, DATE 2026-10-22T02:54:37+02:00, PREVIOUS v0.4.1, and 21 commit subjects.
|
||||
- The notes file is in the session scratchpad (`v0.4.2-notes.md`). It has a one-line intro, `## Fixed` (nine bullets) and `## Added` (the two new functions). It has no H1, no planning IDs and no quick codes.
|
||||
- `scripts/changelog-post.py publish v0.4.2 <notes> --excerpt "Console fixes for 0.4: ordered output under spinners, terminal restored on Ctrl+C, exit codes passed through by summer."` answered `posted id=37 https://summercms.io/changelog/summercms-0-4-2 (published_at 2026-10-22T00:54:37+00:00)`.
|
||||
- **Post URL: https://summercms.io/changelog/summercms-0-4-2** (HTTP 200 right after publishing). The script read the token file itself. The token was never printed, copied or minted.
|
||||
|
||||
### Plugins and applications
|
||||
|
||||
Plugins and applications: nothing to publish. No row of plan 05's Release impact table asks for a require bump or a regenerate. The `--all` gate's plugins and apps stages confirm that every shared plugin and application still builds against the local framework, and that `summer build` leaves the generated main.go and plugins.gen.go unchanged.
|
||||
|
||||
## Task 3: demo roadmap and the gate
|
||||
|
||||
### Roadmap snapshot
|
||||
|
||||
- After the push, `ROADMAP_REF=origin/master ../sm-demo-app/scripts/sync-roadmap.sh --check` failed as expected: the snapshot differed from origin/master. This is 19.8's own plan list and progress.
|
||||
- sm-demo-app before the change: `git status --porcelain` was empty and `origin/master..master` was empty after a fetch. Its HEAD was `762bb90 feat(demo): Polish name for roadmap phase 19.6.1`, already pushed by another session.
|
||||
- `ROADMAP_REF=origin/master scripts/sync-roadmap.sh` wrote the snapshot from origin/master (ead8e42): `plugins/demo/content/ROADMAP.md`, 4 insertions and 2 deletions.
|
||||
- TestRoadmapParse, TestRoadmapDeckOrder, TestRoadmapNoClientNames and TestRoadmapPolishTitles: PASS. No new phase, so **no Polish-name commit was needed**.
|
||||
- Commit **`aa4de22 chore: sync the ROADMAP.md snapshot (summercms ead8e42)`**. It touches only `plugins/demo/content/ROADMAP.md` and was the only unpushed commit. It was pushed `762bb90..aa4de22`, and `origin/master..master` is now empty. Nothing was deployed.
|
||||
|
||||
### `--all` gate
|
||||
|
||||
`PHASE198_REQUIRE_DOCKER=1 TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 bash scripts/check-phase19.8.sh --all` ran with GOCACHE and TMPDIR in the session scratchpad and Docker reached directly (no `sudo -u golem`). Exit 0. The landing pre-check `sync-roadmap --check` printed ok.
|
||||
|
||||
| Stage | Result | Notes |
|
||||
|-------|--------|-------|
|
||||
| self-test | PASS | |
|
||||
| go | PASS | vet, short and the named tests: diary 30, sunscreen 2, bonfire 42, docsite 2, conga 5, lagoon 7, surf 13, flare 1, dev 4, cmd/summer 6. Race stage over diary, sunscreen, bonfire and docsite |
|
||||
| hello | PASS | vet, 13 tests, then 5 named tests |
|
||||
| docs | PASS | TestDocsTree; docs:build reported no problems; 67 files contain no client name; all 35 summer commands have examples |
|
||||
| plugins | PASS | 15 shared plugins |
|
||||
| apps | PASS | 5 applications (sm-demo-app, sm-bm-app, sm-grzybyfunkcjonalne-app, sm-summercmsio-app, fonoteka.go): build, generated files unchanged, `list` and `help migrate` exit 0 |
|
||||
| landing | PASS | nuxt generate, tap 38/38, 4 terminal tests. **NOT RUN TestTerminalCommands** (allowed: needs network, Docker and ports; `SUMMERCMS_TERMINAL_CHECK=1`). 4 roadmap tests; "roadmap: snapshot matches origin/master" |
|
||||
| docker | PASS | TestServeLifecycle; 6 lagoon tests including TestMigrateAppliedLines; 3 cabana tests |
|
||||
|
||||
Final line: **`Phase 19.8 gate passed`**. No line starts with `FAIL` or `NOT RUN docker`. The full log is `check-phase19.8-06.log` in the session scratchpad.
|
||||
|
||||
### Suggested g15office comment (for the orchestrator)
|
||||
|
||||
> Phase 19.8 review fixes released as SummerCMS v0.4.2 (changelog: https://summercms.io/changelog/summercms-0-4-2); phase gate green; ready for /msd-verify-work
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
**1. [Rule 3 - Blocking] Build cache on tmpfs.** `/home` is at 99% (5.1G free) and `/media/nvme` is at 99%. Every go command, including the gate, ran with `GOCACHE` (and, for the gate, `TMPDIR`) in the session scratchpad on tmpfs. The user did not ask for space to be freed, so `go clean` was not run.
|
||||
|
||||
**2. Tagged commit.** The plan tags "master HEAD". HEAD at release time was `ead8e42`, the planning-only commit that records the reply. It was committed before the checks, so the checks ran on exactly the commit that was tagged and pushed.
|
||||
|
||||
Otherwise the plan was executed as written.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None. The pushes, the tag, the post and the demo snapshot are the surfaces in the plan's threat register. T-19.8-34 to T-19.8-37 were mitigated as planned:
|
||||
- a fetch and range classification came before the push
|
||||
- the push was a fast-forward of exactly the tested, tagged commit
|
||||
- the token stayed in its file
|
||||
- TestRoadmapNoClientNames passed before the snapshot commit
|
||||
|
||||
## Final docs commit
|
||||
|
||||
This SUMMARY's completion commit is **local only**. The plan does not push it, and it is not part of v0.4.2.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
Found: cf06185, ead8e42 (local and origin/master), tag object 60b13ae (local and on origin as refs/tags/v0.4.2), sm-demo-app aa4de22 (on origin/master), changelog post (HTTP 200).
|
||||
|
||||
@@ -3,6 +3,54 @@ phase: 19.8
|
||||
review: 19.8-REVIEW.md
|
||||
titles: json
|
||||
findings:
|
||||
- id: WR-09
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "Lines printed through a live view after its context is cancelled are silently dropped"
|
||||
- id: WR-10
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "A delegate killed by a signal prints its full argv, including a --password value, and exits 1"
|
||||
- id: WR-11
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "The wrong-directory hint leaves secret values that start with \"-\" unmasked"
|
||||
- id: WR-12
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "migrate:status --json still drops the framework sets that migrate applies"
|
||||
- id: WR-13
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "migrate reports failure after a successful Migrate when the follow-up read fails"
|
||||
- id: WR-14
|
||||
severity: warning
|
||||
disposition: fixed
|
||||
title: "Process's plain path prints item names without Sanitize"
|
||||
- id: IN-10
|
||||
severity: info
|
||||
disposition: deferred
|
||||
title: "console.Error during a live view writes straight to the terminal and tears the view"
|
||||
- id: IN-11
|
||||
severity: info
|
||||
disposition: deferred
|
||||
title: "A blank line printed during a live view is dropped"
|
||||
- id: IN-12
|
||||
severity: info
|
||||
disposition: deferred
|
||||
title: "Signal relay edge cases: a signal during view start-up, and Windows"
|
||||
- id: IN-13
|
||||
severity: info
|
||||
disposition: deferred
|
||||
title: "A delegate's stderr always goes to os.Stderr, bypassing the root's error writer"
|
||||
- id: IN-14
|
||||
severity: info
|
||||
disposition: fixed
|
||||
title: "The ErrReported doc comment still says the exit code is 1"
|
||||
- id: IN-15
|
||||
severity: info
|
||||
disposition: fixed
|
||||
title: "runLive builds the bubbletea program before it knows it may run"
|
||||
- id: CR-01
|
||||
severity: critical
|
||||
disposition: fixed
|
||||
@@ -84,34 +132,46 @@ findings:
|
||||
disposition: deferred
|
||||
title: "The phase gate names consuming applications"
|
||||
open: 0
|
||||
total: 20
|
||||
recorded: 2026-10-21T22:35:50.040Z
|
||||
total: 32
|
||||
recorded: 2026-10-22T01:19:33.337Z
|
||||
---
|
||||
|
||||
# Phase 19.8: Code Review Disposition
|
||||
|
||||
| Finding | Severity | Disposition | Source |
|
||||
|---------|----------|-------------|--------|
|
||||
| CR-01 | critical | fixed | fix b077dc3 (19.8-05) |
|
||||
| CR-02 | critical | fixed | fix 323413c (19.8-05) |
|
||||
| CR-03 | critical | fixed | fix 9c89705 (19.8-05) |
|
||||
| WR-01 | warning | fixed | fix d151a25 (19.8-05) |
|
||||
| WR-02 | warning | fixed | fix 86e4e27 (19.8-05) |
|
||||
| WR-03 | warning | fixed | fix fc7706d (19.8-05) |
|
||||
| WR-04 | warning | fixed | fix c586c6f (19.8-05) |
|
||||
| WR-05 | warning | fixed | fix a9025c0 (19.8-05) |
|
||||
| WR-06 | warning | fixed | fix 39677f1 (19.8-05) |
|
||||
| WR-07 | warning | fixed | fix 020fe83 (19.8-05) |
|
||||
| WR-08 | warning | fixed | fix 9b62285 (19.8-05) |
|
||||
| IN-01 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-02 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-03 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-04 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-05 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-06 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-07 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-08 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-09 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| WR-09 | warning | fixed | fix fce232d (quick 261022-4z8) |
|
||||
| WR-10 | warning | fixed | fix 17c722d (quick 261022-4z8); the exit-130 suggestion is deferred to todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| WR-11 | warning | fixed | fix 707372b (quick 261022-4z8) |
|
||||
| WR-12 | warning | fixed | fix 57a849d, reworked in 139f5e3 so that lagoon.Status stays plugin-only and migrate:status adds the framework sets itself (quick 261022-4z8) |
|
||||
| WR-13 | warning | fixed | fix 0691d26 (quick 261022-4z8) |
|
||||
| WR-14 | warning | fixed | fix 48e13f9 (quick 261022-4z8) |
|
||||
| IN-10 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-11 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-12 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-13 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md |
|
||||
| IN-14 | info | fixed | docs 7c15095 (quick 261022-4z8) |
|
||||
| IN-15 | info | fixed | fix 1ac75ad (quick 261022-4z8) |
|
||||
| CR-01 | critical | fixed | fix b077dc3 (19.8-05) (not in the current review) |
|
||||
| CR-02 | critical | fixed | fix 323413c (19.8-05) (not in the current review) |
|
||||
| CR-03 | critical | fixed | fix 9c89705 (19.8-05) (not in the current review) |
|
||||
| WR-01 | warning | fixed | fix d151a25 (19.8-05) (not in the current review) |
|
||||
| WR-02 | warning | fixed | fix 86e4e27 (19.8-05) (not in the current review) |
|
||||
| WR-03 | warning | fixed | fix fc7706d (19.8-05) (not in the current review) |
|
||||
| WR-04 | warning | fixed | fix c586c6f (19.8-05) (not in the current review) |
|
||||
| WR-05 | warning | fixed | fix a9025c0 (19.8-05) (not in the current review); remainder WR-14 (fix 48e13f9) |
|
||||
| WR-06 | warning | fixed | fix 39677f1 (19.8-05) (not in the current review) |
|
||||
| WR-07 | warning | fixed | fix 020fe83 (19.8-05) (not in the current review); remainder WR-12 (fix 57a849d) |
|
||||
| WR-08 | warning | fixed | fix 9b62285 (19.8-05) (not in the current review); remainder WR-11 (fix 707372b) |
|
||||
| IN-01 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-02 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-03 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-04 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-05 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-06 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-07 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-08 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
| IN-09 | info | deferred | todo .planning/todos/pending/2026-10-22-console-review-info-findings.md (not in the current review) |
|
||||
|
||||
Dispositions: `open` (recorded, not yet triaged), `fixed`, `skipped`, `deferred`.
|
||||
Set `deferred` by hand and put the reason in the Source cell; both are preserved. A `|` in the reason is kept as prose and escaped on the next run.
|
||||
|
||||
@@ -1,336 +1,253 @@
|
||||
---
|
||||
phase: 19.8-console-commands-overhaul
|
||||
reviewed: 2026-10-21T22:33:36Z
|
||||
reviewed: 2026-10-22T01:17:37Z
|
||||
depth: standard
|
||||
diff_range: v0.3.1..v0.4.1 (19.5 commits and the cooler test commit excluded)
|
||||
files_reviewed: 93
|
||||
diff_range: dd12382..0ebed68 (gap-closure plan 19.8-05, released as v0.4.2)
|
||||
files_reviewed: 31
|
||||
files_reviewed_list:
|
||||
- cmd/summer/docs.go
|
||||
- cmd/summer/main.go
|
||||
- cmd/summer/parity.go
|
||||
- cmd/summer/runtime.go
|
||||
- docs/examples/blog/console/publish.go
|
||||
- examples/hello/main.go
|
||||
- examples/hello/plugins/greeter/plugin.go
|
||||
- internal/build/artifact.go
|
||||
- internal/build/build.go
|
||||
- internal/build/manifest.go
|
||||
- internal/build/new.go
|
||||
- internal/build/scaffold.go
|
||||
- cmd/summer/runtime_test.go
|
||||
- docs/console/introduction.md
|
||||
- docs/console/scaffolding.md
|
||||
- docs/console/writing-commands.md
|
||||
- docs/services/logging.md
|
||||
- docs/setup/upgrading.md
|
||||
- internal/dev/watch.go
|
||||
- internal/docsite/check_commands.go
|
||||
- modules/beachcomber/beachcomber.go
|
||||
- modules/bonfire/command.go
|
||||
- modules/bonfire/docs.go
|
||||
- internal/dev/watch_test.go
|
||||
- modules/bonfire/errors.go
|
||||
- modules/bonfire/errors_test.go
|
||||
- modules/bonfire/execute.go
|
||||
- modules/bonfire/globals.go
|
||||
- modules/bonfire/helpers.go
|
||||
- modules/bonfire/help.go
|
||||
- modules/bonfire/list.go
|
||||
- modules/bonfire/live.go
|
||||
- modules/bonfire/live_signal_unix_test.go
|
||||
- modules/bonfire/live_test.go
|
||||
- modules/bonfire/output.go
|
||||
- modules/bonfire/prompts.go
|
||||
- modules/bonfire/root.go
|
||||
- modules/bonfire/selector.go
|
||||
- modules/bonfire/styles.go
|
||||
- modules/bonfire/version.go
|
||||
- modules/bonfire/README.md
|
||||
- modules/bonfire/widgets.go
|
||||
- modules/bouncer/turnstile.go
|
||||
- modules/cabana/account.go
|
||||
- modules/cabana/account_preferences.go
|
||||
- modules/cabana/account_tokens.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/api_tokens.go
|
||||
- modules/cabana/auth.go
|
||||
- modules/cabana/commands.go
|
||||
- modules/cabana/contracts.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/field_dependent.go
|
||||
- modules/cabana/field_file.go
|
||||
- modules/cabana/field_type.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/log.go
|
||||
- modules/cabana/partial_render.go
|
||||
- modules/cabana/query.go
|
||||
- modules/cabana/relation_field.go
|
||||
- modules/cabana/reorder.go
|
||||
- modules/cabana/singleton.go
|
||||
- modules/cabana/token_commands.go
|
||||
- modules/cabana/token_guard.go
|
||||
- modules/conga/client.go
|
||||
- modules/conga/commands.go
|
||||
- modules/conga/conga.go
|
||||
- modules/conga/worker.go
|
||||
- modules/cooler/cooler.go
|
||||
- modules/cooler/memory.go
|
||||
- modules/cooler/ratelimit.go
|
||||
- modules/cooler/rediscache.go
|
||||
- modules/cooler/sitecache.go
|
||||
- modules/diary/channels.go
|
||||
- modules/diary/component.go
|
||||
- modules/diary/config.go
|
||||
- modules/bonfire/widgets_test.go
|
||||
- modules/diary/console.go
|
||||
- modules/diary/daily.go
|
||||
- modules/diary/daily_test.go
|
||||
- modules/diary/diary.go
|
||||
- modules/flare/commands.go
|
||||
- modules/flare/flare.go
|
||||
- modules/lagoon/attach/bucket.go
|
||||
- modules/lagoon/attach/thumb.go
|
||||
- modules/diary/README.md
|
||||
- modules/diary/retire_internal_test.go
|
||||
- modules/lagoon/commands.go
|
||||
- modules/lagoon/connection.go
|
||||
- modules/lagoon/encrypted.go
|
||||
- modules/lagoon/fill.go
|
||||
- modules/lagoon/keygen.go
|
||||
- modules/lagoon/migrations.go
|
||||
- modules/lagoon/purge.go
|
||||
- modules/lagoon/transaction.go
|
||||
- modules/lighthouse/centrifugo/client.go
|
||||
- modules/lighthouse/centrifugo/commands.go
|
||||
- modules/lighthouse/lighthouse.go
|
||||
- modules/phrasebook/translator.go
|
||||
- modules/postcard/drivers.go
|
||||
- modules/postcard/mailer.go
|
||||
- modules/sunscreen/sunscreen.go
|
||||
- modules/surf/accesslog.go
|
||||
- modules/surf/routelist_command.go
|
||||
- modules/surf/serve.go
|
||||
- modules/surf/summary.go
|
||||
- modules/wristband/oidc_token.go
|
||||
- modules/lagoon/pending_test.go
|
||||
- modules/lagoon/README.md
|
||||
- scripts/check-phase19.8.sh
|
||||
findings:
|
||||
critical: 3
|
||||
warning: 8
|
||||
info: 9
|
||||
total: 20
|
||||
critical: 0
|
||||
warning: 6
|
||||
info: 6
|
||||
total: 12
|
||||
status: issues_found
|
||||
---
|
||||
|
||||
# Phase 19.8: Code Review Report
|
||||
# Phase 19.8: Code Review Report (re-review after 19.8-05)
|
||||
|
||||
**Reviewed:** 2026-10-21T22:33:36Z
|
||||
**Reviewed:** 2026-10-22T01:17:37Z
|
||||
**Depth:** standard
|
||||
**Files Reviewed:** 93
|
||||
**Files Reviewed:** 31
|
||||
**Status:** issues_found
|
||||
|
||||
## Summary
|
||||
|
||||
I reviewed the phase's changed hunks in the 93 non-test source files (`git diff v0.3.1..v0.4.1`). I read the new modules (diary, and bonfire's globals, errors, execute, live, prompts, selector and list) in full. I checked the bubbletea v2.1.0, fang v2.0.1 and gorm v1.31.2 sources wherever bonfire, diary or lagoon depend on how they behave. I confirmed one finding at runtime: a scratch program under a pseudo-terminal (`script -qec`) shows that lines printed during a live view come out in the wrong order and are sometimes lost. Items already listed in `deferred-items.md` are not reported again.
|
||||
This is an incremental re-review of the gap-closure commits `dd12382..HEAD` (b077dc3 to 020fe83, plus the gate and docs commits). I read every listed file in full where it changed. I checked the fixes against the bubbletea v2.1.0 sources (`Program.Send`, `Kill`, `shutdown`, `eventLoop`, `cursedRenderer.insertAbove`) and against pflag v1.0.10. I also ran two scratch programs under a pseudo-terminal (`script -qec`).
|
||||
|
||||
The request log is clean. It logs the route pattern and never the path, query, headers or remote address. The GORM bridge logs SQL with placeholders. The startup summary shows the database only as host, port and name. The redaction wrapping sits on every diary leaf.
|
||||
Verification:
|
||||
|
||||
The main defects are in three places:
|
||||
- `go vet` is clean on the touched packages.
|
||||
- `go test -short -race` passes for bonfire and diary.
|
||||
- The new summer and dev tests (`TestDelegate*`, `TestAppStreams`, `TestDevStopWaitsForGracefulShutdown`) pass.
|
||||
|
||||
- **Printing above live views.** Lines printed while a spinner, progress bar or process view runs are reordered and sometimes dropped. Any console's output can be redirected to the terminal that owns the view.
|
||||
- **summer delegates.** Every `summer <app command>` merges the app's stderr into stdout and never gives the app a terminal. The production confirmation is skipped, `--json` output gets log lines mixed in, two error blocks are printed, and exit code 2 becomes 1.
|
||||
- **Process lifecycle.** Ctrl+C during a spinner leaves the cursor hidden. `summer dev` kills serve 8 seconds before serve's drain deadline. One failed open of a daily log file switches file logging off until the process exits.
|
||||
All three critical findings from the first review are fixed. So are WR-01 to WR-06. WR-05, WR-07 and WR-08 are fixed as described, but each leaves a gap of the same kind elsewhere, so they are only partly closed (WR-12, WR-14, WR-10 and WR-11 below).
|
||||
|
||||
## Critical Issues
|
||||
The fixes introduced no new critical defect. The main new problems are:
|
||||
|
||||
### CR-01: Lines printed above a live view are reordered and can be lost
|
||||
- **Lost lines after cancellation.** A live view whose context is cancelled stays registered, so lines printed through it are dropped while `printAbove` reports success. I confirmed this on a pty.
|
||||
- **Signal-killed delegates.** Since the CR-02 fix, only a signal-killed delegate gets summer's error block. That block repeats the full argv, including a `--password` value, and the exit code is 1.
|
||||
- **Migration accounting.** `migrate:status --json` still uses its own plugin-only list. `migrate` reports a failure when only the read after a successful `Migrate` fails.
|
||||
|
||||
**File:** `modules/bonfire/live.go:316-323` (with `printAboveLines` at 377-387 and `runLive` at 365-372)
|
||||
**Issue:** `printAboveLines` sends one `printAboveMsg` per line, and `liveModel.Update` answers each one with `tea.Println(...)`, which is a `tea.Cmd`. bubbletea v2 runs every Cmd in its own goroutine (`handleCommands`, tea.go:745-757), and that goroutine sends the resulting `printLineMessage` back into the event loop. Two consequences follow:
|
||||
New finding IDs continue after the first review's IDs (WR-09 and up, IN-10 and up). `19.8-REVIEW-DISPOSITION.md` drops a recorded decision when its ID is reused for a different finding, so the old IDs are not reused here.
|
||||
|
||||
1. **Order is not kept.** Successive lines race each other back into the event loop.
|
||||
2. **Lines can be dropped.** `runLive` sends `finishMsg` as soon as `work` returns, and `finishMsg` ends in `tea.Quit`. A print Cmd still in flight then reaches a loop that has already exited, and its line is never printed.
|
||||
## Prior Findings: Verified State
|
||||
|
||||
This affects every path that prints during a live view:
|
||||
| ID | Verified state | Evidence |
|
||||
|----|----------------|----------|
|
||||
| CR-01 | **Fixed** | `printAbove` sends one `printLineMessage` per call straight into the program's unbuffered queue while holding `liveMu` (live.go:477-487). The event loop handles it inline (`insertAbove`, bubbletea tea.go:888), so lines keep their order. `finishMsg` is sent under the same lock only after every earlier send has been received (live.go:387-393), so no line is lost when the view quits. On a pty the lines came out in order. `TestPrintAboveOrderedNoLoss` covers spinner, progress, process and a concurrent finish. A remaining gap after context cancellation is WR-09. |
|
||||
| CR-02 | **Fixed** | `runAppCmd` wraps an exited child as `Reported(WithExitCode(err, code))` (runtime.go:170-176), and `exitCode` honours the code (execute.go:76-85). `TestDelegateExitCodePassthrough` checks that the code is 2 and that summer prints no block of its own. The signal-killed branch has new problems, see WR-10. |
|
||||
| CR-03 | **Fixed** | `appStreams` gives the child `os.Stdout`/`os.Stderr` on a terminal and `out`/`os.Stderr` otherwise (runtime.go:155-160). The child's stderr no longer lands in summer's stdout, and on a terminal the child sees it and asks the production question. A minor gap is IN-13. |
|
||||
| WR-01 | **Fixed** | `watchSignals` relays SIGINT/SIGTERM, calls `prog.Kill()` (which restores the cursor) and re-raises the signal (live.go:410-466). `TestLiveViewRestoresTerminalOnSignal` covers both the default action and the command's own handler. Edge cases are in IN-12. |
|
||||
| WR-02 | **Fixed** | `activeView` records the owner, and `printAbove(c, …)` reroutes only the owner's output (live.go:477-481). The slot is claimed with check-and-set under `liveMu` (live.go:362-368), and cleanup is deferred, so it also runs on a panic (live.go:378-395). |
|
||||
| WR-03 | **Fixed** | `child.stop` waits `dev.ShutdownGrace` (15s), and summer's delegates use the same constant (watch.go:22-27, 243; runtime.go:185). |
|
||||
| WR-04 | **Fixed** | A failed open is retried after `dailyRetry` (1 minute) or on the next date, with one warning per date (daily.go:70-99). The test covers both paths. |
|
||||
| WR-05 | **Partly fixed** | Error blocks (every line, the Try lines and the causes), process-view names and errors, spinner and progress current items, failure lines and table cells now go through `Sanitize`. `Process`'s plain path still prints item names raw (WR-14). The deferred IN-08 (a raw C1 byte passes `Sanitize`'s fast path) now applies to every one of these sinks, not only diary. |
|
||||
| WR-06 | **Fixed** | Replaced writers are retired: a late record opens the file, appends and closes it again (daily.go:100-104, 166-174). `ApplyGlobals` holds `mu` for its whole run (diary.go:228-240). There is no reentrancy on `mu` from the handler path. |
|
||||
| WR-07 | **Partly fixed** | `Migrate` and `PendingMigrations` now share `migrationSets`, and the applied lines are computed from the pending list before and after the run. `Status` (used by `migrate:status`, and by its `--json` output) still walks only `plugins` (WR-12). A new error path is in WR-13. |
|
||||
| WR-08 | **Partly fixed** | `tryArgs` masks `--flag=value` and `--flag value` (errors.go:310-331). A value that starts with `-` is not masked, although pflag accepts it (WR-11). The same argv now leaks through the delegate's signal error (WR-10). |
|
||||
| IN-01..IN-09 | Deferred (todo `2026-10-22-console-review-info-findings.md`) | Not re-reported. IN-08 is now wider, as noted under WR-05. |
|
||||
|
||||
- `Output.Println` and `Printf`, which carry command data (tokens, JSON);
|
||||
- status lines sent through `emit`;
|
||||
- `liveProgress.Fail` failure lines (widgets.go:130-133), which are sent just before the work function returns;
|
||||
- every diary console record logged while a view runs (console.go:166).
|
||||
|
||||
**Runtime check:** a program printing `line-00` to `line-19` with `out.Println` inside `out.Spinner` on a pty printed them out of order in 5 of 5 runs (for example `line-01 line-00 line-02 line-04 line-03 …`) and lost a line in 1 of 40 runs.
|
||||
**Fix:** Deliver the lines through the event loop in order, and drain them before quitting. For example, buffer them in the model and flush them as a single ordered `tea.Sequence`; on finish, quit only after that sequence:
|
||||
```go
|
||||
type liveModel struct{ inner tea.Model }
|
||||
|
||||
func (m liveModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if lines, ok := msg.(printAboveMsg); ok {
|
||||
// one message per PrintAbove call; tea.Sequence runs the prints in order
|
||||
var cmds []tea.Cmd
|
||||
for _, l := range strings.Split(string(lines), "\n") {
|
||||
cmds = append(cmds, tea.Println(l))
|
||||
}
|
||||
return m, tea.Sequence(cmds...)
|
||||
}
|
||||
inner, cmd := m.inner.Update(msg)
|
||||
m.inner = inner
|
||||
return m, cmd
|
||||
}
|
||||
```
|
||||
Ordering across separate PrintAbove calls, and draining before quit, still need one serial path. Either have `runLive` send `finishMsg` only after an acknowledgement message that is queued behind the pending prints, or keep a FIFO in the model and, on `finishMsg`, return `tea.Sequence(<pending prints>..., tea.Quit)` instead of `tea.Quit`. Send each PrintAbove call as one message (not one per line).
|
||||
Add a pty test that prints N lines during each widget and asserts all N arrive in order.
|
||||
|
||||
### CR-02: summer delegates print a second error block and turn exit code 2 into 1
|
||||
|
||||
**File:** `cmd/summer/runtime.go:146-150`
|
||||
**Issue:** When the app binary fails, `runAppBinary` returns `fmt.Errorf("summer: %s: %w", argv, *exec.ExitError)`. `bonfire.Execute` then:
|
||||
|
||||
1. renders a second ERROR block (`summer: migrate --bogus: exit status 2`) under the error block the app binary already printed;
|
||||
2. maps the error to `ExitFailure`, because `isUsage` does not match an `*exec.ExitError`.
|
||||
|
||||
So `summer migrate --bogus` exits 1, not 2. That breaks the D-18 exit-code contract for every delegate the docs present as the normal entry point ("summer fails when the app binary fails", runtime.go:93). Nothing in `cmd/summer/runtime_test.go` covers a failing child.
|
||||
**Fix:** Treat the child's failure as already reported and pass its exit code through. For example, add an exit-code carrier that `exitCode` honours:
|
||||
```go
|
||||
var ee *exec.ExitError
|
||||
if errors.As(err, &ee) {
|
||||
return bonfire.Reported(bonfire.WithExitCode(err, ee.ExitCode())) // new: exitCode() checks interface{ ExitCode() int }
|
||||
}
|
||||
```
|
||||
|
||||
### CR-03: summer delegates hide the terminal from the app and merge its stderr into stdout
|
||||
|
||||
**File:** `cmd/summer/runtime.go:163-168`
|
||||
**Issue:** `newAppCmd` sets both `cmd.Stdout` and `cmd.Stderr` to `out`. That is the bonfire console, not an `*os.File`, so the child gets a pipe on both streams, and every byte of the child's stderr lands on summer's stdout. Since this phase that has three effects:
|
||||
|
||||
1. **The production confirmation is never asked.** In the child, `Interactive()` needs stdout to be a terminal. `summer migrate`, `summer migrate:rollback`, `summer deferred:purge` and `summer queue:clear` run in production without the D-28 question, even when run in a terminal.
|
||||
2. **Data output gets log lines mixed in.** Records the child logs to stderr (diary records, error blocks) are mixed into its data on stdout. `summer route:list --json > routes.json` and `summer admin:token:create … --json` capture any INFO plugin boot record (deferred-items lists such records on every application command) or WARN line inside the JSON. `summer key:generate -q` captures any warning together with the key.
|
||||
3. **Styled output is lost.** `summer serve` and `summer queue:work` never print their styled summaries, and the delegate's widgets never animate.
|
||||
|
||||
`internal/dev/watch.go:81-88` already fixes the same problem for `summer dev` by passing `os.Stdout` and `os.Stderr` on a terminal. The delegates were not given the same fix.
|
||||
**Fix:** Give the child the process's own streams, and keep stderr separate:
|
||||
```go
|
||||
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||
if !bonfire.IsTerminal(out) { // tests and Call roots: keep the injected writer
|
||||
cmd.Stdout, cmd.Stderr = out, os.Stderr
|
||||
}
|
||||
```
|
||||
## Narrative Findings (AI reviewer)
|
||||
|
||||
## Warnings
|
||||
|
||||
### WR-01: Ctrl+C during a spinner, progress bar or process view leaves the cursor hidden
|
||||
### WR-09: Lines printed through a live view after its context is cancelled are silently dropped
|
||||
|
||||
**File:** `modules/bonfire/widgets.go:33,51`, `modules/bonfire/live.go:349-355`, `cmd/summer/main.go:28,76`, `internal/build/build.go:140`
|
||||
**Issue:** The live views run with `tea.WithoutSignalHandler()` and `tea.WithInput(nil)`, and `Spinner` and `Progress` pass `context.Background()`. Neither `summer` nor the generated main installs a signal handler (`bonfire.Execute(context.Background(), …)`), so Ctrl+C terminates the process with SIGINT's default action. bubbletea hides the cursor when it starts (`ESC[?25l`, confirmed in the pty run) and only shows it again on a clean exit. `summer build`, which always shows a spinner on a terminal, and every plugin command that uses `Progress` therefore leave the user's terminal without a cursor after Ctrl+C.
|
||||
**Fix:** Run `Execute` under `signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)` and give the widgets the command's context (keep it on the console in `PersistentPreRunE`). Alternatively, have `runLive` register its own SIGINT handler that calls `prog.Kill()` (which restores the terminal) and then re-raises the signal.
|
||||
**File:** `modules/bonfire/live.go:354-360, 477-487` (with `modules/bonfire/helpers.go:150-170`)
|
||||
**Issue:** `runLive` passes the command's context to bubbletea (`tea.WithContext(ctx)`). `Process` passes the caller's `ctx`. When that context is cancelled, the program shuts down: `Program.Send` now returns at once because `p.ctx` is done (bubbletea tea.go:1211-1216). However, `activeView` still points at the view until `work` returns. Only the deferred cleanup or the signal relay clears it, and the relay runs only for SIGINT/SIGTERM. Meanwhile:
|
||||
|
||||
### WR-02: Any console's Println and Printf are sent to whichever live view is running
|
||||
- `printAbove` hands the line to a dead program and still returns `true`, so the caller never falls back to a plain write.
|
||||
- This applies to `out.Println`/`Printf` data, to Success/Info/Warning lines on stdout, and to every diary console record routed through `bonfire.PrintAbove`.
|
||||
- These lines are lost for as long as the current `fn(ctx, item)` keeps running after the cancellation.
|
||||
- Because the program was killed, the final frame and the failed rows are never rendered either.
|
||||
|
||||
**File:** `modules/bonfire/output.go:192-212`, `modules/bonfire/live.go:329-339,345-373`
|
||||
**Issue:** `activeProg` is a single process-wide value. `console.Println` and `Printf` call `printAboveLines` without checking that this console owns the view (`emit` checks only `w == c.out`). Any other console that prints while a view runs therefore has its data written to the terminal above that view. This includes a `bonfire.Call` root writing into a caller's `bytes.Buffer`, a nested command, or a console whose stdout is a file. For example, a `Process` loop that calls `bonfire.Call(..., &buf)` gets an empty buffer.
|
||||
**Runtime check:** a `Process` whose first item calls `cancel()`, waits 300 ms and then calls `out.Println("after-cancel-line")` and `bonfire.PrintAbove(...)` printed neither line in 3 of 3 pty runs. `PrintAbove` returned `true`. `out.Error`, which goes to stderr and so bypasses `printAbove`, did print.
|
||||
|
||||
Two more problems sit in the same code:
|
||||
|
||||
- **Check-then-act race.** `liveActive()` (in `console.live`) and the registration in `runLive` are separate steps. Two widgets started concurrently both start programs, and the first one to finish sets `activeProg = nil` while the other is still running.
|
||||
- **No cleanup on panic.** `runLive` unregisters without `defer`, so a panic in `work` leaves `activeProg` pointing at an orphaned program.
|
||||
|
||||
**Fix:** Store the owning console (or its `out` writer) together with the program, and reroute only when `c == owner`. Register under `liveMu` with a check-and-set that falls back to plain lines when a view is already active. Use `defer` for the unregister, `finishMsg` and wait steps.
|
||||
|
||||
### WR-03: summer dev kills serve 2 seconds after SIGTERM, but serve drains for up to 10
|
||||
|
||||
**File:** `internal/dev/watch.go:227-238`
|
||||
**Issue:** Since this phase `summer dev` runs `bin/<app> serve`, whose shutdown drains requests and the in-process worker for up to 10 seconds and then prints the shutdown report. Before, it ran the binary with no arguments. `child.stop` still sends SIGKILL after 2 seconds. A restart or Ctrl+C that arrives during a slow request or job therefore kills serve before its report is printed (as `summer dev`'s Long help promises). Jobs that are killed remain `running` in River until its stuck-job rescuer picks them up. `cmd/summer/runtime.go:155` (`appShutdownGrace = 15s`) is longer than serve's 10-second timeout for exactly this reason.
|
||||
**Fix:** Use the same grace in dev, for example `case <-time.After(appShutdownGrace):` with a shared constant longer than serve's 10-second shutdown context.
|
||||
|
||||
### WR-04: One failed open switches a daily log file off until the process exits
|
||||
|
||||
**File:** `modules/diary/daily.go:226-243`
|
||||
**Issue:** When `open` fails, `disabled = true` is set and never cleared. For a long-running `serve` or `queue:work`, a transient failure at midnight rotation (ENOSPC for a moment, EMFILE during a traffic spike, a directory briefly removed by logrotate or a backup tool) stops all file logging until the next restart. Only one WARN record is written, possibly to journald. The degrade-instead-of-fail rule (T-19.8-06) was meant to keep boot from failing. A server should not lose its WARN and ERROR file trail for days because of one transient failure.
|
||||
**Fix:** Disable the writer only for the date that failed, retrying on the next date (or after a backoff of about a minute), and log once per failed date:
|
||||
This is the CR-01 failure mode (a line reported as printed but never shown) on a new path. It hits any `Process` caller that uses a deadline, a parent cancel or a non-signal shutdown.
|
||||
**Fix:** Have `printAbove` refuse a program that has stopped, and unregister the view when the program ends on its own:
|
||||
```go
|
||||
if d.disabledDate == date { d.mu.Unlock(); return len(p), nil }
|
||||
if err := d.open(date); err != nil { d.disabledDate = date; … }
|
||||
type liveView struct {
|
||||
owner *console
|
||||
prog *tea.Program
|
||||
done <-chan struct{} // the `finished` channel of runLive
|
||||
}
|
||||
|
||||
func printAbove(owner *console, s string) bool {
|
||||
liveMu.Lock()
|
||||
defer liveMu.Unlock()
|
||||
v := activeView
|
||||
if v == nil || (owner != nil && v.owner != owner) {
|
||||
return false
|
||||
}
|
||||
select {
|
||||
case <-v.done: // program gone (ctx cancelled, Run failed): print plainly
|
||||
activeView = nil
|
||||
return false
|
||||
default:
|
||||
}
|
||||
v.prog.Send(printLine(strings.TrimSuffix(s, "\n")))
|
||||
return true
|
||||
}
|
||||
```
|
||||
`Send` can still race with a cancellation that lands between the check and the send. To close that window, also watch `ctx.Done()` in a goroutine that clears `activeView` under `liveMu`. Add a pty or buffer test that cancels the context mid-item and asserts that later lines appear.
|
||||
|
||||
### WR-10: A delegate killed by a signal prints its full argv, including a --password value, and exits 1
|
||||
|
||||
**File:** `cmd/summer/runtime.go:170-178`
|
||||
**Issue:** After the CR-02 fix, every child failure that is not a normal exit returns `fmt.Errorf("summer: %s: %w", strings.Join(argv, " "), err)` unmasked. This covers death by a signal (`exit.Exited()` false) and every `cmd.Start` error. `RenderError` passes the message only through `sunscreen.Scrub`, which recognises Bearer, `sk-` and `x-api-key` shapes, so `summer admin:create --email a@b.c --password hunter2` prints `ERROR summer: admin:create --email a@b.c --password hunter2: signal: interrupt` on stderr. It happens when the user presses Ctrl+C, when a CI timeout sends SIGKILL, or on an OOM kill.
|
||||
|
||||
This is the leak WR-08 fixed for the wrong-directory hint, on a path that the CR-02 fix now makes the only one that prints summer's own block.
|
||||
|
||||
In addition, Ctrl+C is the normal way to stop `summer serve` or `summer queue:work`. Since the WR-01 relay re-raises SIGINT, a child that dies by the signal (any delegate without its own handler, or one interrupted during a live view) now produces a spurious ERROR block and exit 1. Shells and CI expect 130 (128+SIGINT). The docs ("A binary killed by a signal gets an error block from summer and exit code 1") describe this behaviour but do not justify it.
|
||||
**Fix:** Mask the argv with the same helper the hint uses (export it, for example `bonfire.MaskArgs`), or name only the command word. Map signal deaths to 128+n, and treat SIGINT/SIGTERM as already reported:
|
||||
```go
|
||||
var exit *exec.ExitError
|
||||
if errors.As(err, &exit) {
|
||||
if ws, ok := exit.Sys().(syscall.WaitStatus); ok && ws.Signaled() {
|
||||
code := 128 + int(ws.Signal())
|
||||
if ws.Signal() == syscall.SIGINT || ws.Signal() == syscall.SIGTERM {
|
||||
return bonfire.Reported(bonfire.WithExitCode(err, code))
|
||||
}
|
||||
return bonfire.WithExitCode(fmt.Errorf("summer: %s: %w", argv[0], err), code)
|
||||
}
|
||||
…
|
||||
}
|
||||
```
|
||||
|
||||
### WR-05: Error blocks, process views and tables write untrusted text to the terminal without stripping escape sequences
|
||||
### WR-11: The wrong-directory hint leaves secret values that start with "-" unmasked
|
||||
|
||||
**File:** `modules/bonfire/errors.go:145-169`, `modules/bonfire/live.go:286-289`, `modules/bonfire/widgets.go:142-166`
|
||||
**Issue:** T-19.8-03 strips control characters only in diary's console handler. `RenderError` passes messages, explanations and the `-v` cause chain through `sunscreen.Scrub` only, and Scrub redacts credential shapes but leaves ESC and other control characters in place. The process view prints `it.err.Error()` and item names unchanged, and `Table` prints cell values unchanged. When the profile allows color, `colorprofile.Writer` passes those sequences through.
|
||||
**File:** `modules/bonfire/errors.go:325-329`
|
||||
**Issue:** `tryArgs` masks the next argument after `--password` only when it does not start with `-`. pflag takes the next argument as the value of a non-boolean flag whatever its first character is (pflag v1.0.10 flag.go:1020-1023, the `'--flag arg'` branch). So `bin/acme admin:create --email a@b.c --password -Xk9!q` runs with the password `-Xk9!q`, and the Try line then prints it in clear text. A dash is a common first character for generated passwords. The docs (writing-commands.md) promise that such values are masked.
|
||||
**Fix:** Mask the next argument whenever the flag takes a value. A secret-named long flag in `--name value` form always consumes the next argument, unless that argument is `--` or the flag is known to be boolean:
|
||||
```go
|
||||
if i+1 < len(args) && args[i+1] != "--" {
|
||||
b.WriteString(" ***")
|
||||
i++
|
||||
}
|
||||
```
|
||||
Add a test case with a value that starts with a dash.
|
||||
|
||||
The text can come from outside the operator's control: database or remote-service error text (the centrifugo health error, upstream HTTP bodies), and admin-supplied token names shown by `admin:token:list`. Such text can move the cursor, rewrite earlier lines or set the window title on the operator's terminal.
|
||||
**Fix:** Export diary's `sanitize` (for example as `bonfire.Sanitize`, with diary calling it) and apply it to every error-block line, process-view item and error, and table cell before styling.
|
||||
### WR-12: migrate:status --json still drops the framework sets that migrate applies
|
||||
|
||||
### WR-06: Setup and ApplyGlobals close daily files that other goroutines may still be writing through
|
||||
**File:** `modules/lagoon/migrations.go:141-160`, `modules/lagoon/commands.go:270-289`
|
||||
**Issue:** WR-07's point was that the commands which report on migrations must read the list `Migrate` applies. `Status` still walks only `plugins`. `migrate:status --json` then emits pending refs only when `ref.Plugin == row.Plugin`. The pending migrations of `summercms.attach`, `summercms.cabana`, the deferred-bindings set and the queue set (all returned by `PendingMigrations`) are therefore silently omitted, both from the JSON (whose example says "pending migrations included") and from the table.
|
||||
|
||||
**File:** `modules/diary/diary.go:156-179,216-227`
|
||||
**Issue:** `install` swaps the state and then closes the old channels' daily writers. A goroutine that loaded the old state just before the swap still writes through the old `dailyWriter`. Its `Write` finds `file == nil` and reopens the file (`daily.go:233`). Nothing ever closes that writer again, so the descriptor stays open until the GC finalizer closes it.
|
||||
After a framework upgrade that adds a River queue migration, `migrate --pretend` lists it but `migrate:status --json` reports nothing pending. A deploy gate that checks for `"applied": false` passes when it should not.
|
||||
**Fix:** Build `Status` from `migrationSets(gdb, plugins)` (skipping or including empty plugin sets consistently), so all three commands read one list. Extend `TestMigrateStatusJSON` to assert that a framework set's pending migration appears.
|
||||
|
||||
`ApplyGlobals` runs in `PersistentPreRunE`, after plugins have booted. By then plugin goroutines (cache, realtime, the worker) may already be logging, so the window is real.
|
||||
### WR-13: migrate reports failure after a successful Migrate when the follow-up read fails
|
||||
|
||||
There is also a check-then-act race: `ApplyGlobals` reads `current` outside `mu`, so two concurrent calls can both rebuild the channels.
|
||||
**Fix:** Mark the old writers closed for good (`d.closed = true`, with `Write` returning `len(p), nil` once it is set) and do not reopen them. Alternatively, reference-count the old state and close it after in-flight `Handle` calls finish. Take `mu` for the whole of `ApplyGlobals`.
|
||||
**File:** `modules/lagoon/commands.go:173-180`
|
||||
**Issue:** After `Migrate` returns, the command calls `PendingMigrations` again. If that read fails (a dropped connection, a statement timeout, a permission problem on a history table), it returns `errors.Join(migrateErr, err)`, which is non-nil even when `migrateErr` is nil. A migration that was fully applied then:
|
||||
|
||||
### WR-07: PendingMigrations keeps its own copy of Migrate's migration sets
|
||||
- prints no applied lines and no `Applied N migrations`;
|
||||
- exits 1.
|
||||
|
||||
**File:** `modules/lagoon/migrations.go:221-245` vs `modules/lagoon/migrations.go:64-115`; `modules/lagoon/commands.go:139-171`
|
||||
**Issue:** `migrationSets` re-lists the framework sets and the plugin loop by hand, and `Migrate` does not use it. When a set is added to `Migrate` (as the queue and deferred sets were), several things go wrong without any failing test:
|
||||
A deploy pipeline will treat it as failed and may roll back or alert, even though the schema change is in place.
|
||||
**Fix:** When `migrateErr == nil`, a failed follow-up read must not turn the run into a failure. Fall back to reporting `pending` as applied, with a warning:
|
||||
```go
|
||||
after, err := PendingMigrations(gdb, plugins)
|
||||
applied := pending
|
||||
if err == nil {
|
||||
applied = appliedSince(pending, after)
|
||||
} else if migrateErr == nil {
|
||||
out.Warning(fmt.Sprintf("Could not re-read the migration history: %v", err))
|
||||
} else {
|
||||
return errors.Join(migrateErr, err)
|
||||
}
|
||||
```
|
||||
|
||||
- the serve startup summary,
|
||||
- `migrate --pretend`,
|
||||
- the production question's count,
|
||||
- the "N applied" lines,
|
||||
- `migrate:status --json`.
|
||||
### WR-14: Process's plain path prints item names without Sanitize
|
||||
|
||||
The "applied" lines are also printed from the list computed before `Migrate` ran, not from what it actually applied.
|
||||
**Fix:** Make `Migrate` iterate over `migrationSets(gdb, plugins)`, so both functions read one list. Optionally, recompute the pending list after `Migrate` and report the difference.
|
||||
|
||||
### WR-08: The wrong-directory hint repeats every argument, including a --password value, on stderr
|
||||
|
||||
**File:** `modules/bonfire/errors.go:220-224` (via `Fail`, `modules/bonfire/execute.go:346-351`)
|
||||
**Issue:** When an application binary fails outside its root, `wrongDirectory` builds the Try line from all of `os.Args[1:]`. For example, `cd bin && ./acme admin:create --email a@b.c --password hunter2` fails at `compass.Open`, and the error block prints `cd ..; bin/acme admin:create --email a@b.c --password hunter2`. The deprecated `--password` flag is still accepted, so a password that was only in the shell history now also reaches CI and deploy logs that capture stderr. `sunscreen.Scrub` does not catch it, because it recognises only Bearer, `sk-` and `x-api-key` shapes.
|
||||
**Fix:** Mask the values of flags whose names look like secrets (`password`, `secret`, `token`, `key`) in the Try line (`--password=***`). Alternatively, print only the command word (`cd ..; bin/acme admin:create …`).
|
||||
**File:** `modules/bonfire/helpers.go:183` (also `modules/bonfire/live.go:313-317`, the `operation` label)
|
||||
**Issue:** The WR-05 fix sanitises item names in the live process view (live.go:292) and in failure lines (`failureText`). The plain path, however, prints a successful item with `out.Success(item)`, and `status` writes it unchanged. The plain path runs whenever stdout is a terminal but the view does not animate: with `-n`, inside another live view (now the normal fallback when `runLive` reports `started == false`), or with a forced color profile. In those cases an item name that holds an escape sequence (a remote file name, an admin-typed title, a post slug) reaches the terminal unchanged. The same item is cleaned on one path and raw on the other.
|
||||
**Fix:** `out.Success(Sanitize(item))` in `Process`, or sanitise inside `console.status` and `console.Error` so every status line is covered regardless of caller. Add a plain-path case to `TestProcessViewStripsControl`.
|
||||
|
||||
## Info
|
||||
|
||||
### IN-01: A forced-color console drops HideOnTTY records even when stderr is not a terminal
|
||||
### IN-10: console.Error during a live view writes straight to the terminal and tears the view
|
||||
|
||||
**File:** `modules/diary/console.go:117-122`
|
||||
**Issue:** The styled `consoleHandler` drops every `HideOnTTY` record unconditionally. It is also used when color is forced (`--ansi`, `FORCE_COLOR`) on a non-terminal stderr. With stdout on a terminal and stderr redirected (`FORCE_COLOR=1 bin/acme serve 2>serve.log`), the "startup summary" and "listening on" records never reach the file, although the HideOnTTY docs promise that only a terminal console skips them.
|
||||
**Fix:** Check `isTerminal(w)` once when the handler is built, and drop the records only when it is true (the same rule `ttyFilter` uses).
|
||||
**File:** `modules/bonfire/output.go:232-238`
|
||||
**Issue:** `Error` writes to `c.err`, and `emit` reroutes only writes to `c.out`. When stderr and stdout are the same terminal (the usual case), an `out.Error(...)` from inside `Spinner`, `Progress` or `Process` lands mid-frame. A pty run showed the spinner glyph left on the error line (`⠹ ✗ stderr-error-line`), with the renderer continuing on the next row. diary's console records on stderr do go above the view through `PrintAbove`, so the two stderr paths behave differently.
|
||||
**Fix:** In `emit`, also reroute `w == c.err` when the console owns the running view and `c.err` is a terminal (`printAbove(c, s)`).
|
||||
|
||||
### IN-02: PeekGlobals and cobra disagree on some argument forms
|
||||
### IN-11: A blank line printed during a live view is dropped
|
||||
|
||||
**File:** `modules/bonfire/globals.go:52-81`
|
||||
**Issue:** `--quiet=true`, `--no-interaction=true`, `--verbose=2` and `--ansi=false` are ignored by `PeekGlobals` but honoured by pflag. A command flag value that looks like a global (`--name -q`) is the reverse: pflag takes it as the flag's value, `PeekGlobals` reads it as a global. The pre-boot diary setup, the error block's `-v` chain and passthrough globals can therefore differ from what the command runs with.
|
||||
**Fix:** Parse `--flag=value` forms with `strconv.ParseBool` and `strconv.Atoi`, or re-parse the args with a throwaway pflag FlagSet that holds only the global flags (`ParseErrorsWhitelist.UnknownFlags = true`).
|
||||
**File:** `modules/bonfire/live.go:485`
|
||||
**Issue:** `out.Println()` gives `"\n"`. `TrimSuffix` turns that into `""`, and bubbletea's `insertAbove` returns early for an empty string (cursed_renderer.go:776-778). `printAbove` still reports `true`, so the blank separator line is lost. It is printed when no view runs.
|
||||
**Fix:** Send `" "` (or `"\u200b"`) for an empty block, or skip the trim when the block is only a newline.
|
||||
|
||||
### IN-03: isUsage recognises cobra's unknown-command error by its text
|
||||
### IN-12: Signal relay edge cases: a signal during view start-up, and Windows
|
||||
|
||||
**File:** `modules/bonfire/errors.go:41-47,119`
|
||||
**Issue:** Any error whose message starts with "unknown command" exits 2 and is rewritten as `Command "…" is not defined.`. A plugin error worded that way would be misreported.
|
||||
**Fix:** Turn cobra's error into a `UsageError` in one place (for example a root `Args` or `ValidArgsFunction` check, or by matching it once in `Execute` before rendering), and test it with `errors.As`.
|
||||
**File:** `modules/bonfire/live.go:370-375, 427-436, 454-466`
|
||||
**Issue:** This comes from reading bubbletea v2.1.0; I did not reproduce it.
|
||||
|
||||
### IN-04: The --json flag is read two different ways
|
||||
1. **Start-up race.** `prog.Run` starts on its own goroutine just before the relay is registered. If a signal arrives before `Run` has created and started its renderer, `Kill` runs `shutdown(true)` while `p.renderer` is still nil. `shutdownOnce` then makes `Run`'s own `shutdown(killed)` a no-op after it has started the renderer and hidden the cursor, so the cursor stays hidden.
|
||||
2. **Windows.** On Windows, `p.Signal(os.Interrupt)` fails, so `raise` calls `os.Exit(130)`. That skips the command's own handler (for example, `summer dev` stopping its serve child) and its deferred cleanup.
|
||||
|
||||
**File:** `modules/cabana/token_commands.go:150,217,299`, `modules/lighthouse/centrifugo/commands.go`, `modules/surf/routelist_command.go` vs `modules/lagoon/commands.go` (`flagOn`)
|
||||
**Issue:** cabana, centrifugo and route:list compare the value with `== "true"`, while lagoon uses `strconv.ParseBool`. As a result `--json=1` works for `migrate:status` but not for `admin:token:list`.
|
||||
**Fix:** Add one bonfire helper (for example `bonfire.FlagBool(in, name)`) and use it everywhere.
|
||||
**Fix:** Before killing, wait until the program reports it has started (for example, have the wrapped model's `Init` close a `ready` channel). On platforms where `raise` cannot deliver the signal, return without exiting when another handler is registered.
|
||||
|
||||
### IN-05: summer's scaffolding result lines are now hidden by -q
|
||||
### IN-13: A delegate's stderr always goes to os.Stderr, bypassing the root's error writer
|
||||
|
||||
**File:** `cmd/summer/main.go:126,334,401`
|
||||
**Issue:** `created <path>` and `added <dir>` used to print through `Printf`. They now print through `Success` as `Created …` and `Added …`, so `-q` hides them and their wording changed. Scripts that read the created paths stop working without notice.
|
||||
**Fix:** Print the created paths with `Println` as data (D-27), or mention the change in `docs/setup/upgrading.md`.
|
||||
**File:** `cmd/summer/runtime.go:155-160`
|
||||
**Issue:** Off a terminal, the child's stdout goes through `out`, but its stderr goes to the real `os.Stderr`, not to the error stream of the root that ran the command. For a summer root built with `NewRootIO(…, errW)` (tests, embedding), the app binary's error block cannot be captured. `TestDelegateExitCodePassthrough` therefore cannot check that the binary's own block was printed.
|
||||
**Fix:** Pass the root's error writer through (for example, a `bonfire.ErrWriter(out)` accessor), defaulting to `os.Stderr`.
|
||||
|
||||
### IN-06: fang replaces the root help function that NewRootIO installs
|
||||
### IN-14: The ErrReported doc comment still says the exit code is 1
|
||||
|
||||
**File:** `modules/bonfire/root.go:139-141`, `modules/bonfire/execute.go:327-337`
|
||||
**Issue:** `fang.Execute` calls `root.SetHelpFunc(fang's helpFunc)` (fang.go:140), so under `Execute` bonfire's root help function is dead code. Today `Execute` strips `-h` and `--help` when there is no command word, so the replacement is not reachable. A future path that calls the root's help would print fang's layout, not the Artisan list.
|
||||
**Fix:** Set the root help function again after `fang.Execute` sets its own (not possible from outside), or drop fang and call `root.ExecuteContext` with `RenderError` directly. bonfire already turns off every fang feature except the error handler.
|
||||
**File:** `modules/bonfire/errors.go:73-75`
|
||||
**Issue:** The comment says "the error block prints nothing and the exit code is 1". With `WithExitCode`, a Reported error can now exit with any code from 1 to 255 (the README was updated, the comment was not).
|
||||
**Fix:** "… and the exit code is 1, or the code of WithExitCode."
|
||||
|
||||
### IN-07: diary pulls the whole TUI stack into security modules
|
||||
### IN-15: runLive builds the bubbletea program before it knows it may run
|
||||
|
||||
**File:** `modules/diary/diary.go:21-22`, `modules/bouncer/turnstile.go`, `modules/wristband/oidc_token.go`
|
||||
**Issue:** `diary` imports `bonfire`, which imports cobra, fang, bubbletea, bubbles and huh. bouncer's README now says its "only framework dependency is diary", but in practice the security primitive links the console UI stack. That widens the code a security review of bouncer and wristband has to cover.
|
||||
**Fix:** Move `ColorMode`, `DetectProfile`, `Palette` and `PrintAbove` into a small leaf package (or into diary itself) so that diary does not import bonfire.
|
||||
|
||||
### IN-08: The console sanitizer passes raw C1 bytes through on its fast path
|
||||
|
||||
**File:** `modules/diary/console.go:278-288`
|
||||
**Issue:** A lone `0x9b` byte (8-bit CSI) is invalid UTF-8. `range` decodes it as `U+FFFD`, which is not a control character, so `sanitize` returns the original string with the raw byte in it. Terminals that interpret 8-bit C1 controls then see an escape sequence.
|
||||
**Fix:** Run `strings.ToValidUTF8(s, "<22>")` before the control-character scan.
|
||||
|
||||
### IN-09: The phase gate names consuming applications
|
||||
|
||||
**File:** `scripts/check-phase19.8.sh:71-77,229`
|
||||
**Issue:** The script hard-codes `sm-demo-app`, `sm-bm-app`, `sm-grzybyfunkcjonalne-app` and `sm-summercmsio-app`, and splits a consumer's name into two strings. CLAUDE.md says framework code never names a consuming application. Earlier phase gates do the same, so the precedent exists, but this framework repository is published.
|
||||
**Fix:** Read the sibling paths from environment variables only, with no defaults, or move the cross-repository stages to a gate outside the framework repository.
|
||||
**File:** `modules/bonfire/live.go:354-366`
|
||||
**Issue:** `tea.NewProgram` runs before the slot check. It calls `context.WithCancel(ctx)`, and with `TEA_TRACE` set it opens a trace file. When the slot is taken (`started == false`, now the normal fallback for nested widgets), that cancel is never called. With `Process`'s cancellable `ctx`, the child context stays registered on the parent until the parent ends, and the trace file descriptor leaks. A `Process` nested in a loop accumulates both.
|
||||
**Fix:** Claim the slot first and construct the program only after `activeView` is set (or call `prog.Kill()` on the losing path).
|
||||
|
||||
---
|
||||
|
||||
_Reviewed: 2026-10-21T22:33:36Z_
|
||||
_Reviewed: 2026-10-22T01:17:37Z_
|
||||
_Reviewer: Claude (msd-code-reviewer)_
|
||||
_Depth: standard_
|
||||
|
||||
44
.planning/phases/19.8-console-commands-overhaul/19.8-UAT.md
Normal file
44
.planning/phases/19.8-console-commands-overhaul/19.8-UAT.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
status: testing
|
||||
phase: 19.8-console-commands-overhaul
|
||||
source: [19.8-VERIFICATION.md]
|
||||
started: 2026-10-22T02:41:10.440Z
|
||||
updated: 2026-10-22T02:41:10.440Z
|
||||
---
|
||||
|
||||
## Current Test
|
||||
|
||||
number: 1
|
||||
name: On a real terminal, run 'summer', 'bin/<app>', 'bin/<app> help admin:token:create' and 'bin/<app> bogus'
|
||||
expected: |
|
||||
Colors, alignment and sections match the approved D-13 list, D-14 help and D-18 error previews; --no-ansi removes every escape code
|
||||
awaiting: user response
|
||||
|
||||
## Tests
|
||||
|
||||
### 1. On a real terminal, run 'summer', 'bin/<app>', 'bin/<app> help admin:token:create' and 'bin/<app> bogus'
|
||||
expected: Colors, alignment and sections match the approved D-13 list, D-14 help and D-18 error previews; --no-ansi removes every escape code
|
||||
result: [pending]
|
||||
|
||||
### 2. On a real terminal, run a command that uses Spinner, Progress, Process, Choice, Ask, Confirm and Secret (or the throwaway pty program from plan 02); press Ctrl+C during a spinner
|
||||
expected: SSU-like animation, arrow-key selector with confirmation screen, huh prompts; diary log lines print above the view; after Ctrl+C the cursor is visible and the shell is usable
|
||||
result: [pending]
|
||||
|
||||
### 3. Run 'bin/<app> serve' against a real database on a terminal, then with -q, then with -v, then press Ctrl+C; run 'summer dev' and stop it
|
||||
expected: A compact startup block (version, env, URL, DB and migration state, plugins, queue, scheduler, mail, cache, realtime, search), then INFO lines with component prefixes. -q shows only warnings. -v adds per-plugin lines. Ctrl+C prints the shutdown report and exits 0
|
||||
result: [pending]
|
||||
|
||||
### 4. Resolve the judgment-tier prohibitions listed under 'Prohibitions' below (the LLM-judge verdicts there are non-authoritative)
|
||||
expected: Each prohibition is confirmed, or rejected with a reason. The plan 03 'never print a secret' prohibition is no longer flagged as violated: both known leaks (WR-10, WR-11) are fixed and reproduced as fixed with built binaries
|
||||
result: [pending]
|
||||
|
||||
## Summary
|
||||
|
||||
total: 4
|
||||
passed: 0
|
||||
issues: 0
|
||||
pending: 4
|
||||
skipped: 0
|
||||
blocked: 0
|
||||
|
||||
## Gaps
|
||||
@@ -0,0 +1,482 @@
|
||||
---
|
||||
phase: 19.8-console-commands-overhaul
|
||||
verified: 2026-10-22T02:37:57Z
|
||||
status: human_needed
|
||||
score: 57/57 must-haves verified
|
||||
covered_files:
|
||||
- ".gitignore"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-01-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-01-SUMMARY.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-02-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-02-SUMMARY.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-03-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-03-SUMMARY.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-04-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-04-SUMMARY.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-05-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-05-SUMMARY.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-06-PLAN.md"
|
||||
- ".planning/phases/19.8-console-commands-overhaul/19.8-06-SUMMARY.md"
|
||||
- ".planning/quick/261022-4z8-fix-the-open-19-8-re-review-findings-wr-/261022-4z8-PLAN.md"
|
||||
- ".planning/quick/261022-4z8-fix-the-open-19-8-re-review-findings-wr-/261022-4z8-SUMMARY.md"
|
||||
- "README.md"
|
||||
- "cmd/summer/commands_documented_test.go"
|
||||
- "cmd/summer/docs.go"
|
||||
- "cmd/summer/docs_test.go"
|
||||
- "cmd/summer/main.go"
|
||||
- "cmd/summer/parity.go"
|
||||
- "cmd/summer/runtime.go"
|
||||
- "cmd/summer/runtime_test.go"
|
||||
- "docs/console/introduction.md"
|
||||
- "docs/console/scaffolding.md"
|
||||
- "docs/console/setup-and-maintenance.md"
|
||||
- "docs/console/utilities.md"
|
||||
- "docs/console/writing-commands.md"
|
||||
- "docs/database/migrations.md"
|
||||
- "docs/examples/blog/console/publish.go"
|
||||
- "docs/examples/blog/console/publish_test.go"
|
||||
- "docs/services/configuration.md"
|
||||
- "docs/services/logging.md"
|
||||
- "docs/setup/configuration.md"
|
||||
- "docs/setup/installation.md"
|
||||
- "docs/setup/porting-a-plugin.md"
|
||||
- "docs/setup/upgrading.md"
|
||||
- "examples/hello/hello_test.go"
|
||||
- "examples/hello/main.go"
|
||||
- "examples/hello/plugins/greeter/plugin.go"
|
||||
- "go.mod"
|
||||
- "go.sum"
|
||||
- "internal/argmask/argmask.go"
|
||||
- "internal/build/artifact.go"
|
||||
- "internal/build/build.go"
|
||||
- "internal/build/build_test.go"
|
||||
- "internal/build/manifest.go"
|
||||
- "internal/build/new.go"
|
||||
- "internal/build/new_golden_test.go"
|
||||
- "internal/build/scaffold.go"
|
||||
- "internal/build/stubs/new.tmpl"
|
||||
- "internal/build/testdata/new-no-plugin/CLAUDE.md.golden"
|
||||
- "internal/build/testdata/new/CLAUDE.md.golden"
|
||||
- "internal/build/testdata/new/config__log.yaml.golden"
|
||||
- "internal/build/testdata/new/main.go.golden"
|
||||
- "internal/dev/watch.go"
|
||||
- "internal/dev/watch_test.go"
|
||||
- "internal/docsite/check_commands.go"
|
||||
- "internal/docsite/check_commands_test.go"
|
||||
- "internal/docsite/checks_test.go"
|
||||
- "modules/beachcomber/README.md"
|
||||
- "modules/beachcomber/beachcomber.go"
|
||||
- "modules/bonfire/README.md"
|
||||
- "modules/bonfire/command.go"
|
||||
- "modules/bonfire/docs.go"
|
||||
- "modules/bonfire/docs_test.go"
|
||||
- "modules/bonfire/errors.go"
|
||||
- "modules/bonfire/errors_test.go"
|
||||
- "modules/bonfire/example_test.go"
|
||||
- "modules/bonfire/execute.go"
|
||||
- "modules/bonfire/globals.go"
|
||||
- "modules/bonfire/globals_test.go"
|
||||
- "modules/bonfire/golden_test.go"
|
||||
- "modules/bonfire/help.go"
|
||||
- "modules/bonfire/help_smoke_test.go"
|
||||
- "modules/bonfire/helpers.go"
|
||||
- "modules/bonfire/list.go"
|
||||
- "modules/bonfire/list_smoke_test.go"
|
||||
- "modules/bonfire/live.go"
|
||||
- "modules/bonfire/live_signal_unix_test.go"
|
||||
- "modules/bonfire/live_test.go"
|
||||
- "modules/bonfire/output.go"
|
||||
- "modules/bonfire/prompts.go"
|
||||
- "modules/bonfire/root.go"
|
||||
- "modules/bonfire/root_test.go"
|
||||
- "modules/bonfire/selector.go"
|
||||
- "modules/bonfire/styles.go"
|
||||
- "modules/bonfire/testdata/error_chain_verbose.golden"
|
||||
- "modules/bonfire/testdata/error_hint.golden"
|
||||
- "modules/bonfire/testdata/error_unknown_command.golden"
|
||||
- "modules/bonfire/testdata/help_passthrough.golden"
|
||||
- "modules/bonfire/testdata/help_token_create.golden"
|
||||
- "modules/bonfire/testdata/list.golden"
|
||||
- "modules/bonfire/testdata/list.json.golden"
|
||||
- "modules/bonfire/testdata/list_all.golden"
|
||||
- "modules/bonfire/testdata/list_styled.golden"
|
||||
- "modules/bonfire/version.go"
|
||||
- "modules/bonfire/version_test.go"
|
||||
- "modules/bonfire/widgets.go"
|
||||
- "modules/bonfire/widgets_smoke_test.go"
|
||||
- "modules/bonfire/widgets_test.go"
|
||||
- "modules/bonfire/wrongdir_smoke_test.go"
|
||||
- "modules/bouncer/README.md"
|
||||
- "modules/bouncer/turnstile.go"
|
||||
- "modules/cabana/README.md"
|
||||
- "modules/cabana/account.go"
|
||||
- "modules/cabana/account_preferences.go"
|
||||
- "modules/cabana/account_tokens.go"
|
||||
- "modules/cabana/actions.go"
|
||||
- "modules/cabana/api_tokens.go"
|
||||
- "modules/cabana/auth.go"
|
||||
- "modules/cabana/commands.go"
|
||||
- "modules/cabana/contracts.go"
|
||||
- "modules/cabana/crud.go"
|
||||
- "modules/cabana/field_dependent.go"
|
||||
- "modules/cabana/field_file.go"
|
||||
- "modules/cabana/field_type.go"
|
||||
- "modules/cabana/http.go"
|
||||
- "modules/cabana/log.go"
|
||||
- "modules/cabana/partial_render.go"
|
||||
- "modules/cabana/query.go"
|
||||
- "modules/cabana/relation_field.go"
|
||||
- "modules/cabana/reorder.go"
|
||||
- "modules/cabana/singleton.go"
|
||||
- "modules/cabana/token_commands.go"
|
||||
- "modules/cabana/token_guard.go"
|
||||
- "modules/cabana/token_json_test.go"
|
||||
- "modules/conga/README.md"
|
||||
- "modules/conga/client.go"
|
||||
- "modules/conga/commands.go"
|
||||
- "modules/conga/commands_test.go"
|
||||
- "modules/conga/confirm_linux_test.go"
|
||||
- "modules/conga/conga.go"
|
||||
- "modules/conga/logger_smoke_test.go"
|
||||
- "modules/conga/logger_test.go"
|
||||
- "modules/conga/schedule_test.go"
|
||||
- "modules/conga/stats_test.go"
|
||||
- "modules/conga/worker.go"
|
||||
- "modules/cooler/README.md"
|
||||
- "modules/cooler/cooler.go"
|
||||
- "modules/cooler/memory.go"
|
||||
- "modules/cooler/ratelimit.go"
|
||||
- "modules/cooler/rediscache.go"
|
||||
- "modules/cooler/sitecache.go"
|
||||
- "modules/diary/README.md"
|
||||
- "modules/diary/channels.go"
|
||||
- "modules/diary/component.go"
|
||||
- "modules/diary/config.go"
|
||||
- "modules/diary/config_smoke_test.go"
|
||||
- "modules/diary/config_test.go"
|
||||
- "modules/diary/console.go"
|
||||
- "modules/diary/console_test.go"
|
||||
- "modules/diary/daily.go"
|
||||
- "modules/diary/daily_test.go"
|
||||
- "modules/diary/diary.go"
|
||||
- "modules/diary/diary_test.go"
|
||||
- "modules/diary/example_test.go"
|
||||
- "modules/diary/retire_internal_test.go"
|
||||
- "modules/diary/slogtest_test.go"
|
||||
- "modules/diary/tracer_smoke_test.go"
|
||||
- "modules/flare/README.md"
|
||||
- "modules/flare/commands.go"
|
||||
- "modules/flare/commands_test.go"
|
||||
- "modules/flare/flare.go"
|
||||
- "modules/lagoon/README.md"
|
||||
- "modules/lagoon/attach/bucket.go"
|
||||
- "modules/lagoon/attach/thumb.go"
|
||||
- "modules/lagoon/commands.go"
|
||||
- "modules/lagoon/commands_flags_test.go"
|
||||
- "modules/lagoon/connection.go"
|
||||
- "modules/lagoon/encrypted.go"
|
||||
- "modules/lagoon/fill.go"
|
||||
- "modules/lagoon/keygen.go"
|
||||
- "modules/lagoon/logger_smoke_test.go"
|
||||
- "modules/lagoon/logger_test.go"
|
||||
- "modules/lagoon/migrations.go"
|
||||
- "modules/lagoon/pending_test.go"
|
||||
- "modules/lagoon/pty_linux_test.go"
|
||||
- "modules/lagoon/purge.go"
|
||||
- "modules/lagoon/transaction.go"
|
||||
- "modules/lighthouse/README.md"
|
||||
- "modules/lighthouse/centrifugo/client.go"
|
||||
- "modules/lighthouse/centrifugo/commands.go"
|
||||
- "modules/lighthouse/lighthouse.go"
|
||||
- "modules/phrasebook/README.md"
|
||||
- "modules/phrasebook/translator.go"
|
||||
- "modules/postcard/README.md"
|
||||
- "modules/postcard/drivers.go"
|
||||
- "modules/postcard/mailer.go"
|
||||
- "modules/sunscreen/README.md"
|
||||
- "modules/sunscreen/sunscreen.go"
|
||||
- "modules/sunscreen/sunscreen_test.go"
|
||||
- "modules/surf/README.md"
|
||||
- "modules/surf/accesslog.go"
|
||||
- "modules/surf/accesslog_test.go"
|
||||
- "modules/surf/routelist_command.go"
|
||||
- "modules/surf/serve.go"
|
||||
- "modules/surf/serve_lifecycle_test.go"
|
||||
- "modules/surf/serve_summary_smoke_test.go"
|
||||
- "modules/surf/serve_test.go"
|
||||
- "modules/surf/summary.go"
|
||||
- "modules/surf/summary_test.go"
|
||||
- "modules/wristband/README.md"
|
||||
- "modules/wristband/oidc_token.go"
|
||||
- "scripts/check-phase19.8.sh"
|
||||
covered_digest: "v2:sha256:472046bb65cca6ab5a4a3a8b7f02a7c66f6f385e90fbecc1f4a7baf1b80b9f9d"
|
||||
behavior_unverified: 0
|
||||
overrides_applied: 0
|
||||
re_verification:
|
||||
previous_status: gaps_found
|
||||
previous_score: 54/57
|
||||
gaps_closed:
|
||||
- "CR-01 (D-03, D-27): lines printed while a live view runs appear in order and none is lost when the view ends, including after its context is cancelled (WR-09, fix fce232d)"
|
||||
- "WR-08 (D-19) and the plan 03 secrets prohibition: secret flag values are masked in the wrong-directory Try line whatever their first character (WR-11, fix 707372b) and in summer's delegate error on a signal death or start failure (WR-10, fix 17c722d), through the shared internal/argmask"
|
||||
- "WR-07 (D-21, D-04): migrate:status (table and --json) lists the same sets migrationSets gives Migrate, framework sets included (WR-12, fix 57a849d, reworked in 139f5e3 so that lagoon.Status stays plugin-only)"
|
||||
gaps_remaining: []
|
||||
regressions: []
|
||||
human_verification:
|
||||
- test: "On a real terminal, run 'summer', 'bin/<app>', 'bin/<app> help admin:token:create' and 'bin/<app> bogus'"
|
||||
expected: "Colors, alignment and sections match the approved D-13 list, D-14 help and D-18 error previews; --no-ansi removes every escape code"
|
||||
why_human: "Visual layout and palette; the goldens were produced with -update from the code itself, so only a person can compare them with the previews"
|
||||
- test: "On a real terminal, run a command that uses Spinner, Progress, Process, Choice, Ask, Confirm and Secret (or the throwaway pty program from plan 02); press Ctrl+C during a spinner"
|
||||
expected: "SSU-like animation, arrow-key selector with confirmation screen, huh prompts; diary log lines print above the view; after Ctrl+C the cursor is visible and the shell is usable"
|
||||
why_human: "Animation, keyboard interaction and terminal restore cannot be asserted by the short suite (plans 01, 02 and 04 recorded human_judgment: true)"
|
||||
- test: "Run 'bin/<app> serve' against a real database on a terminal, then with -q, then with -v, then press Ctrl+C; run 'summer dev' and stop it"
|
||||
expected: "A compact startup block (version, env, URL, DB and migration state, plugins, queue, scheduler, mail, cache, realtime, search), then INFO lines with component prefixes. -q shows only warnings. -v adds per-plugin lines. Ctrl+C prints the shutdown report and exits 0"
|
||||
why_human: "Readability of the styled block is a visual judgment; TestServeLifecycle (Docker) covers the records and exit code"
|
||||
- test: "Resolve the judgment-tier prohibitions listed under 'Prohibitions' below (the LLM-judge verdicts there are non-authoritative)"
|
||||
expected: "Each prohibition is confirmed, or rejected with a reason. The plan 03 'never print a secret' prohibition is no longer flagged as violated: both known leaks (WR-10, WR-11) are fixed and reproduced as fixed with built binaries"
|
||||
why_human: "Judgment-tier prohibitions need explicit human resolution in interactive verification"
|
||||
---
|
||||
|
||||
# Phase 19.8: Console commands overhaul Verification Report
|
||||
|
||||
**Phase Goal:** Console commands in `summer` and in application binaries reach the bar set by Laravel's Artisan. Logging, the shared console layer in `bonfire`, and every command's help and output change; the command logic stays. A user sees what a command did, can ask for more or less of it, and learns from `--help` how to use it without opening the docs.
|
||||
**Verified:** 2026-10-22T02:37:57Z (initial verification 2026-10-22T01:32:12Z)
|
||||
**Status:** human_needed
|
||||
**Re-verification:** Yes, after gap closure (quick task 261022-4z8, commits 7c15095..a48afbd plus follow-ups 139f5e3 and b1fba7e)
|
||||
|
||||
**Plain verdict:** The phase goal is achieved. All 57 must-haves (5 roadmap success criteria and 52 plan truths) are verified in the codebase, and the three gaps of the first report are closed. Nothing is missing in the code. The status is `human_needed`, not `passed`, only because the verifier contract allows `passed` only when the human verification list is empty. That list still holds the four checks of the first report: three visual or terminal checks (palette and layout, live widgets and Ctrl+C on a real terminal, the serve startup block) and the explicit resolution of the judgment-tier prohibitions. No `*-UAT.md` exists for this phase, so none of them is settled by recorded evidence. They are confirmation checks, not suspected defects. Once a person has done them, the phase can be marked passed.
|
||||
|
||||
**MVP mode note:** ROADMAP marks the phase `mode: mvp`, but the goal is not a user story (`user-story.validate` returns `valid: false`). All six plans recorded the decision not to invent a story. This report applies the standard goal-backward method to the goal and SC-1..SC-5 and does not include a User Flow Coverage table.
|
||||
|
||||
## Re-verification (2026-10-22, after quick 261022-4z8)
|
||||
|
||||
The SUMMARY claims were not taken as evidence. Each gap was re-checked against the code at HEAD `4141cd9` (the code tree has no uncommitted changes; only foreign planning files are dirty), with the pinning tests run by the verifier and with an independent check using built binaries.
|
||||
|
||||
### Commits under review
|
||||
|
||||
| Commit | Finding | Gap |
|
||||
|--------|---------|-----|
|
||||
| `fce232d` fix(bonfire): end a live view when its context is cancelled and print later lines plainly | WR-09 | 1 |
|
||||
| `1ac75ad` fix(bonfire): claim the live view slot before building the program | IN-15 | (1, same code) |
|
||||
| `48e13f9` fix(bonfire): strip control characters from Process's plain item lines and the view's label | WR-14 | follow-up |
|
||||
| `707372b` fix(bonfire): mask secret flag values that start with a dash | WR-11 | 2 |
|
||||
| `17c722d` fix(summer): mask secret flag values in a delegate's error | WR-10 | 2 |
|
||||
| `57a849d` fix(lagoon): migrate:status reads the sets migrate applies | WR-12 | 3 |
|
||||
| `139f5e3` fix(lagoon): keep Status plugin-only; migrate:status adds the framework sets itself | WR-12 rework | 3 |
|
||||
| `0691d26` fix(lagoon): warn instead of failing when the re-read after a successful migrate fails | WR-13 | follow-up |
|
||||
| `7c15095`, `a48afbd`, `b1fba7e` | IN-14 doc comment; disposition and todo records | records |
|
||||
|
||||
`19.8-REVIEW-DISPOSITION.md` shows `open: 0`, `total: 32`. WR-09..WR-14, IN-14 and IN-15 are fixed with these hashes; IN-10..IN-13 and the exit-130 suggestion are deferred to `.planning/todos/pending/2026-10-22-console-review-info-findings.md`. The commits are local: 20 commits ahead of the local `origin/master` (`ead8e42`), and no tag contains `fce232d`. So the fixes are not in released v0.4.2 yet. That is a release matter, not a goal gap.
|
||||
|
||||
### Gap 1 (WR-09): lines after a cancelled live view. CLOSED
|
||||
|
||||
- **Code:** `modules/bonfire/live.go`. `tea.NewProgram` no longer takes the caller's ctx (no `tea.WithContext`). `runLive` claims the slot under `liveMu` before it builds the program (lines 368-382). `watchContext` (lines 426-448) does the following on `ctx.Done()`, all under `liveMu`: it clears `activeView`, sends `finishMsg{err: ctx.Err()}` and waits for `finished`. When the program ends first, the watcher only clears the view. `liveView.done` is the `finished` channel, and `printAbove` (lines 529-546) returns false through `case <-v.done:` for a program that has stopped, and unregisters it. The deferred cleanup's `prog.Send` after the watcher has finished the program cannot block, because bubbletea's Run cancels its own context on return. diary's console handler writes the line itself when `bonfire.PrintAbove` returns false (`modules/diary/console.go:165`).
|
||||
- **Pinning test:** `TestPrintAboveAfterCancel` cancels in the middle of an item. It asserts that the view is unregistered, that `Println`, `Info` and `PrintAbove` lines each appear exactly once, and that `PrintAbove` reports false. The verifier ran it with the rest of the live-view set (`TestNestedProcessBuildsNoProgram`, `TestProcessViewStripsControl`, `TestPrintAboveOrderedNoLoss`, `TestPrintlnStaysWithItsConsole`, `TestLiveViewSingleOwner`, `TestLiveViewPanicUnregisters`, `TestLiveViewRestoresTerminalOnSignal`) under `-race -count=3`: all PASS.
|
||||
- **Independent pty reproduction:** this is the same scenario that failed 3 of 3 in the first verification. A scratch probe was built from a `git archive HEAD` export: inside a `bonfire.Process` item it calls `cancel()`, then `out.Println("after-cancel-line")`, then `bonfire.PrintAbove(...)`. It ran 5 times under `script(1)`. In 5 of 5 runs `after-cancel-line` printed once after the last frame and `\e[?25h` (cursor restored), `PrintAbove` returned **false** (so its caller prints the line), and `Process` returned `context canceled`. Before the fix the line was lost and `PrintAbove` returned true.
|
||||
|
||||
### Gap 2 (WR-11 and WR-10): secret flag values in clear. CLOSED
|
||||
|
||||
- **Code:** `internal/argmask/argmask.go` is the one implementation and imports only `strings`. `Join` masks the argument after a secret-named long flag (`password`, `passwd`, `secret`, `token`, `key`) whatever its first character; only `--` is left alone. It also masks the `--flag=value` form. bonfire's `tryArgs` and the `cd` part of the Try line call `argmask.Join` and `argmask.Quote` (errors.go:288-301); bonfire's old local helpers are gone. `cmd/summer/runtime.go:174` `runAppCmd` builds its error from `argmask.Join(argv)` on every branch, and no `strings.Join(argv` remains. An exit code from the child is still passed through with `Reported(WithExitCode(...))`.
|
||||
- **Pinning tests (PASS, verifier run):** `TestWrongDirectoryMasksSecrets` (dash-leading cases included); `TestRunAppCmdMasksSecrets/killed_by_a_signal` and `/start_failure`; `TestDelegateExitCodePassthrough/exit_code`, `/killed_by_a_signal`, `/killed_by_a_signal_masks_secrets`.
|
||||
- **Independent checks with built binaries** (built into the scratchpad from HEAD):
|
||||
- `cd plugins; ../bin/hello admin:create --email a@b.c --password hunter2` printed `Try: cd ..; bin/hello admin:create --email a@b.c --password ***` (exit 1).
|
||||
- The same command with `--password -Xk9q` printed `--password ***` (it was in clear text before the fix).
|
||||
- `summer admin:create --email a@b.c --password hunter2 --api-token=t0k3n --client-secret -Xk9q` was delegated to a fake app binary that kills itself with SIGKILL. It printed `ERROR summer: admin:create --email a@b.c --password *** --api-token=*** --client-secret ***: signal: killed` and exited 1, which is what plan 05's CR-02 truth specifies. With `-v` the chain shows only `signal: killed`.
|
||||
- A delegate that exits 2 makes summer exit 2 with no second error block, so the CR-02 behavior is unchanged.
|
||||
|
||||
### Gap 3 (WR-12): migrate:status --json omits the framework sets. CLOSED
|
||||
|
||||
- **Code:** `modules/lagoon/migrations.go`. The new unexported `setStatus` (line 160) takes its sets from `migrationSets(gdb, plugins)`, the same list `Migrate` (line 69) and `PendingMigrations` (line 251) use. `migrate:status` reads `setStatus` (commands.go:282), so every `PendingMigrations` ref, whose `Plugin` field is the set id, matches a row, and framework pending migrations appear with `"applied": false`. The exported `lagoon.Status` is back to its pre-task behavior: the verifier compared it with the `a28957f` version. It has the same plugin-only `HasMigrations` iteration and the same empty row for a plugin without a history table; only the row-reading loop moved into the shared unexported `historyRows`. The exported API diff `a28957f..HEAD` over modules, cmd and internal adds only `argmask.Join` and `argmask.Quote`, which are in `internal/`, so they are not framework API. Nothing was removed or changed.
|
||||
- **Pinning tests (Docker, PASS, verifier run with `TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1`):** `TestMigrateStatusJSON` deletes the newest `summercms.attach` history row and asserts that `--json` (and `--json -q`) lists that migration as pending. It also asserts that the table lists `summercms.attach, summercms.cabana, deferred, queue, demo.alpha, demo.beta` in order. `TestStatusPluginRows` pins the plugin-only `Status`. `TestMigrateRereadFailureWarns`, `TestMigrateAppliedLines`, `TestPendingMigrations`, `TestMigratePretend`, `TestTwoPluginMigrationSetsIsolated` and `TestDocsMigrate` also PASS.
|
||||
- **Consumer regression check:** `TestRollbackIsolatesFonotekaFullSchema` in `../fonoteka.go/parity` (it calls `lagoon.Status`, `replace => ../summercms.go`) PASSES against HEAD. It failed at `a48afbd`, before the 139f5e3 rework.
|
||||
|
||||
### Regression spot-checks (nothing else regressed)
|
||||
|
||||
| Check | Result |
|
||||
|-------|--------|
|
||||
| `go vet ./...` | PASS |
|
||||
| `go test -short -count=1 ./...` (all packages, live tree) | PASS, every package ok |
|
||||
| `scripts/check-phase19.8.sh self-test`, `go`, `hello`, `docs` (live tree, now clean of foreign code edits) | all PASS ("phase19.8 go passed", with race on diary, sunscreen, bonfire and docsite; SUMMER list 7 named tests including TestRunAppCmdMasksSecrets) |
|
||||
| `PHASE198_REQUIRE_DOCKER=1 scripts/check-phase19.8.sh docker` | PASS (8 lagoon tests including TestMigrateRereadFailureWarns and TestStatusPluginRows; 3 cabana token JSON tests) |
|
||||
| `summer` bare / `summer bogus` / `summer list --format=json` | exit 0 with the grouped list (59 lines) / ERROR block, `Try: summer list`, exit 2 / 35 commands, 0 without examples |
|
||||
| `summer help make:command`, `bin/hello help migrate:status` | Description, Usage, Arguments, global options, Help, Examples; migrate:status's Long help names the framework sets |
|
||||
| `bin/hello key:generate -q`, `bin/hello route:list --json` | key printed, exit 0; JSON route list |
|
||||
| Debt markers (TBD/FIXME/XXX) in files changed `a28957f..HEAD`; TODO/HACK added | none |
|
||||
| Generated main / internal/build changed since the first verification | no (`git diff 36e2240..HEAD -- cmd/summer/main.go internal/build` is empty) |
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
### Roadmap Success Criteria
|
||||
|
||||
| # | Success criterion | Status | Evidence |
|
||||
|---|-------------------|--------|----------|
|
||||
| SC-1 | `diary` module owns logging (Laravel-shaped keys, stderr/stack/daily/console channels, component loggers), sunscreen on every channel, compat shim, daily files on by default, charm stack with a decision note before code | ✓ VERIFIED | `modules/diary` (3,248 lines): `log.default/level/channels/components` constants (config.go:16-24); `DefaultConfig` is a stack of console and daily (`storage/logs/summer.log`, JSON, warn, 14 days); every leaf goes through `sunscreen.Wrap` (channels.go:117-166). README has a `**Name:**` mnemonic; root README row at line 104. The note commit `e6039b4` is an ancestor of the first go.mod lipgloss commit `e903cc3` (merge-base check). go.mod has lipgloss v2.0.6, bubbletea v2.1.0, bubbles v2.2.1, huh v2.0.3, fang v2.0.1, colorprofile v0.4.3. `go list` shows only bonfire and diary import charm. `sunscreen.InstallDefault` keeps its signature. `summer new` writes `config/log.yaml` (golden). Re-verification: unchanged by the gap-closure commits; diary tests PASS under race. |
|
||||
| SC-2 | Global flags `-v/-vv/-vvv`, `-q`, `--ansi/--no-ansi`, `-n`, `--env`; verbosity sets the diary level at runtime, so River and plugin logs are hidden or consistent at the default level and shown in full at -vv | ✓ VERIFIED | The flags appear in the help output of both binaries (re-checked). The generated main does `PeekGlobals`, `diary.Bootstrap`, `compass.Open(...Env: g.Env)`, `diary.Setup`, `bonfire.OnGlobals(diary.ApplyGlobals)` (examples/hello/main.go, unchanged). TestVerbosityLevels, TestComponentFloors, TestQuietConsoleOnly, TestRiverLoggerComponent, TestGlobalFlagsAgree and TestCallNoGlobalsHook PASS in the gate's go stage. |
|
||||
| SC-3 | Every command has a description, long help with examples, documented args and options with defaults; `list` grouped by namespace; `summer help <cmd>` and `<binary> help <cmd>` work; the coverage check fails for the framework and warns in plugins | ✓ VERIFIED | Re-checked: bare `summer` prints the grouped list (exit 0); `summer help make:command` and `bin/hello help migrate:status` print the full help layout; `summer list --format=json` lists 35 commands, none without examples. `cmd/summer/commands_documented_test.go` (`t.Error` per `bonfire.CheckDocs` problem) PASSES in the go stage. |
|
||||
| SC-4 | Sweep of all commands with the Artisan checklist (`--force`, `--pretend`, progress/tables, `--json`) without breaking names or flags; serve and queue:work print a startup summary and a shutdown report; one-shot commands end with a result line and an exit code | ✓ VERIFIED | As in the first report (migrate `--pretend`/`--force`, `route:list --json`, `key:generate -q`, unknown command exit 2, missing DSN exit 1 with a hint, serve summary and report, 15 plugin repos swept). The edge paths flagged in the first report are now fixed: `migrate:status --json` covers the framework sets, and `migrate` no longer exits 1 after a successful run when only the re-read fails (WR-13). Docker: TestServeLifecycle, TestMigratePretend, TestRollbackPretend, TestDeferredPurgePretend, TestMigrateStatusJSON, TestMigrateAppliedLines, TestMigrateRereadFailureWarns and the cabana token JSON tests PASS. |
|
||||
| SC-5 | diary and bonfire READMEs, docs console and logging pages, landing site and roadmap deck reflect the new console; unit tests in the last plan | ✓ VERIFIED | As in the first report (5 docs/console pages, the logging page, "Upgrading to 0.4", the landing "Console" card, the deck row in sm-demo-app). The gap-closure commits updated the bonfire and lagoon READMEs, the docs/console pages and docs/database/migrations.md in the same commits (WR-10's README fold-in is recorded as a deviation in the quick SUMMARY). The gate's docs stage PASSES at HEAD (67 files clean, 35 commands with examples). |
|
||||
|
||||
### Plan must_haves (merged; 52 truths)
|
||||
|
||||
| Plan | Truths | Status | Evidence / notes |
|
||||
|------|--------|--------|------------------|
|
||||
| 01 diary | 8 | 8 ✓ | Unchanged since the first report; the diary named tests PASS in the gate's go stage at HEAD. |
|
||||
| 02 bonfire | 8 | 8 ✓ | Unchanged contract; goldens, globals, help, JSON listing, error block and exit codes, degradation matrix all PASS in the go stage. The Output, Input and Progress interfaces and the Command struct are not touched by the gap-closure commits. |
|
||||
| 03 sweep | 9 | 9 ✓ | As before. The secrets prohibition is no longer violated by a known path (see Prohibitions). |
|
||||
| 04 tests | 7 | 7 ✓ | `check-phase19.8.sh` self-test, go, hello, docs and docker stages PASS at HEAD (verifier run). The gate now requires TestNestedProcessBuildsNoProgram, TestPrintAboveAfterCancel, TestRunAppCmdMasksSecrets, TestMigrateRereadFailureWarns and TestStatusPluginRows by name. |
|
||||
| 05 review fixes | 13 | **13 ✓** (was 10 ✓, 3 partial) | **CR-01** ✓: gap 1 closed (TestPrintAboveAfterCancel plus the pty probe, 5/5). **WR-08** ✓: gap 2 closed (dash-leading values and the delegate error path masked; TestWrongDirectoryMasksSecrets, TestRunAppCmdMasksSecrets, built-binary checks). **WR-07** ✓: gap 3 closed (migrate:status reads migrationSets; TestMigrateStatusJSON with a pending framework migration). The API truth still holds: compared with the first report, the gap-closure diff adds no exported identifier under modules/ and changes none. CR-02, CR-03, WR-01..WR-06 and the commit/RED-replay/disposition truths are still verified (pinning tests PASS; disposition `open: 0`). |
|
||||
| 06 release | 7 | 7 ✓ | Unchanged: v0.4.2 annotated tag on `ead8e42`, changelog post, deck sync. |
|
||||
|
||||
**Score:** 57/57 truths verified (5 SC + 52 plan truths; 0 failed; 0 present-but-behavior-unverified). The three behavior-dependent truths that had failed (CR-01's cancellation/cleanup invariant, the WR-08 masking, the WR-07 status list) each have a passing behavioral test named above, so they count as verified on behavior, not on presence.
|
||||
|
||||
### Required Artifacts
|
||||
|
||||
| Artifact | Expected | Status | Details |
|
||||
|----------|----------|--------|---------|
|
||||
| `.planning/notes/2026-10-21-console-charm-stack.md` | D-02 decision note | ✓ VERIFIED | Committed before any charm import |
|
||||
| `modules/diary/{diary,config,component,console,daily,channels}.go` | diary module | ✓ VERIFIED | Substantive and wired |
|
||||
| `modules/bonfire/{globals,execute,list,help,docs,errors,live,helpers,styles,version}.go` | console layer | ✓ VERIFIED | live.go now has the watcher, `liveView.done` and the claim-before-build; helpers.go sanitizes the plain Process path |
|
||||
| `internal/argmask/argmask.go` | shared secret masking (new) | ✓ VERIFIED | Imported by `modules/bonfire/errors.go` and `cmd/summer/runtime.go`; the only masking implementation |
|
||||
| `modules/surf/summary.go`, `accesslog.go` | serve summary, report and request log | ✓ VERIFIED | |
|
||||
| `modules/lagoon/migrations.go` | PendingMigrations, migrationSets, Status | ✓ VERIFIED (was PARTIAL) | `migrationSets(gdb, plugins)` used by Migrate, setStatus and PendingMigrations; exported Status unchanged in behavior |
|
||||
| `modules/lagoon/commands.go` | migrate, migrate:status | ✓ VERIFIED | `setStatus` for the status command; re-read warning (WR-13) |
|
||||
| `modules/conga/worker.go` | Worker.Stats | ✓ VERIFIED | |
|
||||
| `internal/dev/watch.go` | dev runs serve | ✓ VERIFIED | |
|
||||
| `cmd/summer/commands_documented_test.go` | failing coverage gate | ✓ VERIFIED | |
|
||||
| `cmd/summer/runtime.go` | delegate exit code, streams, masked errors | ✓ VERIFIED (was PARTIAL) | `argmask.Join(argv)` on every error branch |
|
||||
| `scripts/check-phase19.8.sh` | fail-closed gate | ✓ VERIFIED | all local stages green at HEAD |
|
||||
|
||||
### Key Link Verification
|
||||
|
||||
| From | To | Via | Status |
|
||||
|------|----|-----|--------|
|
||||
| generated main (internal/build) | diary | `diary.Bootstrap` then `diary.Setup(cfg` | ✓ WIRED |
|
||||
| generated main | bonfire.Execute / OnGlobals | `os.Exit(run(...))`, `bonfire.OnGlobals(diary.ApplyGlobals)` | ✓ WIRED |
|
||||
| diary/channels.go | sunscreen | `sunscreen.Wrap(` on every leaf | ✓ WIRED |
|
||||
| conga/client.go | diary | `diary.For("river")` | ✓ WIRED |
|
||||
| lagoon/connection.go | diary | `NewSlogLogger(diary.For("db")` | ✓ WIRED |
|
||||
| diary/console.go | bonfire | `bonfire.PrintAbove(` (console.go:165), plain write on false; `bonfire.Sanitize` | ✓ WIRED (PrintAbove now reports false after a cancellation, so the line is written) |
|
||||
| surf/accesslog.go | diary | `diary.For("http")` | ✓ WIRED |
|
||||
| surf/serve.go | lagoon | `lagoon.PendingMigrations(` | ✓ WIRED |
|
||||
| lagoon/commands.go migrate:status | lagoon/migrations.go migrationSets | `setStatus(gdb, plugins)` | ✓ WIRED (new) |
|
||||
| modules/bonfire/errors.go | internal/argmask | `argmask.Join` / `argmask.Quote` | ✓ WIRED (new) |
|
||||
| cmd/summer/runtime.go | internal/argmask | `argmask.Join(argv)` | ✓ WIRED (new) |
|
||||
| cmd/summer tests | bonfire.CheckDocs | `bonfire.CheckDocs(` | ✓ WIRED |
|
||||
| cmd/summer/runtime.go | bonfire/execute.go | `Reported(WithExitCode(...))` | ✓ WIRED |
|
||||
| v0.4.2 tag | changelog | changelog-post.py | ✓ (post id 37, HTTP 200) |
|
||||
|
||||
### Data-Flow Trace (Level 4)
|
||||
|
||||
| Artifact | Data | Source | Real data | Status |
|
||||
|----------|------|--------|-----------|--------|
|
||||
| serve startup summary | migration state, plugins, drivers | `lagoon.PendingMigrations`, `party` plugins, config lookups | yes (TestServeLifecycle with Postgres) | ✓ FLOWING |
|
||||
| `migrate:status` / `--json` | applied and pending list per set | `setStatus` over `migrationSets` + `PendingMigrations` | yes, framework sets included (TestMigrateStatusJSON with Postgres) | ✓ FLOWING (was PARTIAL) |
|
||||
| `list --format=json` | command catalog | `bonfire.Describe` over registered commands | yes (35 commands) | ✓ FLOWING |
|
||||
| http request log | method, pattern, status | `recordPattern` in the route mux | yes (TestAccessLog*) | ✓ FLOWING |
|
||||
|
||||
### Behavioral Spot-Checks (verifier-run, re-verification)
|
||||
|
||||
| Behavior | Command | Result | Status |
|
||||
|----------|---------|--------|--------|
|
||||
| Bare tool prints the Artisan list | `summer --no-ansi` | grouped list, exit 0 | ✓ PASS |
|
||||
| Per-command help | `summer help make:command`, `bin/hello help migrate:status` | Description, Usage, Arguments, Global options, Help, Examples | ✓ PASS |
|
||||
| Unknown command is a usage error | `summer bogus` | ERROR block, `Try: summer list`, exit 2 | ✓ PASS |
|
||||
| JSON catalog complete | `summer list --format=json` | 35 commands, 0 without examples | ✓ PASS |
|
||||
| -q keeps data | `bin/hello key:generate -q` | key printed, exit 0 | ✓ PASS |
|
||||
| --json for scripts | `bin/hello route:list --json` | JSON route list | ✓ PASS |
|
||||
| Wrong-directory hint masks secrets | `cd plugins; ../bin/hello admin:create --email a@b.c --password hunter2` | `--password ***` | ✓ PASS |
|
||||
| Same with a dash-leading value | `... --password -Xk9q` | `--password ***` | ✓ PASS (was FAIL) |
|
||||
| Signal-killed delegate masks argv | `summer admin:create ... --password hunter2 --api-token=t0k3n --client-secret -Xk9q` (fake app binary that SIGKILLs itself) | `--password *** --api-token=*** --client-secret ***: signal: killed`, exit 1 | ✓ PASS (new) |
|
||||
| Delegate exit code passthrough | fake app binary exiting 2 | summer exit 2, no second block | ✓ PASS |
|
||||
| Lines after a cancelled Process view | scratch probe under `script(1)`, 5 runs | `after-cancel-line` printed once after the last frame in 5/5; PrintAbove returned false (caller writes); cursor restored | ✓ PASS (was FAIL) |
|
||||
| Pending framework migration in `migrate:status --json` | TestMigrateStatusJSON (Docker) | listed with `applied: false`; the table lists the framework sets first | ✓ PASS (was gap) |
|
||||
| Exported `lagoon.Status` consumer | `../fonoteka.go` `go test -run TestRollbackIsolatesFonotekaFullSchema ./parity/` (Docker) | ok | ✓ PASS |
|
||||
|
||||
### Probe Execution
|
||||
|
||||
No `scripts/*/tests/probe-*.sh` exist. The phase's probe is `scripts/check-phase19.8.sh`:
|
||||
|
||||
| Stage | Command | Result | Status |
|
||||
|-------|---------|--------|--------|
|
||||
| self-test | `bash scripts/check-phase19.8.sh self-test` | "phase19.8 self-test passed" | PASS |
|
||||
| go | `bash scripts/check-phase19.8.sh go` (live tree; the code tree is clean) | "phase19.8 go passed" (vet, short, race, named tests), exit 0 | PASS |
|
||||
| hello | `bash scripts/check-phase19.8.sh hello` | "phase19.8 hello passed", exit 0 | PASS |
|
||||
| docs | `bash scripts/check-phase19.8.sh docs` | "phase19.8 docs passed", exit 0 | PASS |
|
||||
| docker | `PHASE198_REQUIRE_DOCKER=1 TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 bash scripts/check-phase19.8.sh docker` | 8 lagoon and 3 cabana tests passed, exit 0 | PASS |
|
||||
| plugins, apps, landing | not re-run | These stages touch sibling repos, and another session is working in `../sm-demo-app`. The gap-closure commits do not change the generated main or any exported API, so no plugin or app pin is affected. Plan 06 recorded `--all` green at ead8e42 | NOT RUN by verifier |
|
||||
|
||||
### Requirements Coverage
|
||||
|
||||
There are no REQUIREMENTS.md IDs for this phase (none orphaned). The plans' `requirements:` fields cite SC-1..SC-5 and D-01..D-30:
|
||||
|
||||
| Source | IDs | Status |
|
||||
|--------|-----|--------|
|
||||
| CONTEXT decisions | D-01..D-30 | 30/30 honored; D-03, D-19, D-21 and D-27, which the plan 05 gaps touched, are now fully satisfied |
|
||||
| Plan 01 | SC-1, SC-2, D-01, D-02, D-04, D-05, D-08, D-09, D-10, D-12 | ✓ SATISFIED |
|
||||
| Plan 02 | SC-2, SC-3, D-01..D-04, D-13..D-18, D-27, D-28, D-30 | ✓ SATISFIED |
|
||||
| Plan 03 | SC-3, SC-4, SC-5, D-04..D-07, D-11, D-17..D-29 | ✓ SATISFIED |
|
||||
| Plan 04 | SC-5 and D-03, D-08..D-10, D-12..D-19, D-21, D-23, D-25, D-27..D-29 | ✓ SATISFIED |
|
||||
| Plan 05 | D-03, D-04, D-10, D-12, D-18, D-19, D-21, D-25, D-27..D-29 | ✓ SATISFIED (was PARTIAL) |
|
||||
| Plan 06 | D-26 | ✓ SATISFIED |
|
||||
|
||||
### Prohibitions
|
||||
|
||||
| Plan | Prohibition | Tier | Disposition |
|
||||
|------|-------------|------|-------------|
|
||||
| 01 | Only bonfire and diary import charm modules | judgment (checked mechanically) | Holds: `internal/argmask` imports only `strings` |
|
||||
| 01 | Nothing imports gopkg.in/yaml.v3 | judgment (checked mechanically) | Holds |
|
||||
| 01-03 | No consuming application named in framework code and docs | judgment | LLM-judge: holds (gate docs stage, 67 files clean at HEAD); non-authoritative |
|
||||
| 01-06 | Nothing pushed or tagged before the go-ahead; no force-push; no deploy | judgment | LLM-judge: holds (the gap-closure commits are local and untagged); non-authoritative |
|
||||
| 02 | No method added to Output, Input or Progress | judgment (checked mechanically) | Holds: no exported change in the gap-closure diff |
|
||||
| 02 | No prompt blocks a non-TTY, -n or -q run | judgment | Holds per TestPromptsNoInteraction, TestConfirmProceed, TestConfirmProductionNonTTYProceeds |
|
||||
| 03 | No command name or flag removed or renamed | judgment | LLM-judge: holds (migrate:status kept its name, flags, Description and Examples; only its Long help changed); non-authoritative |
|
||||
| 03 | Summary, hints and logs never print a DSN password, key, token or secret | judgment | LLM-judge: **holds for every known path** (was violated). The wrong-directory hint with a dash-leading value and the delegate signal and start-failure errors now mask through `internal/argmask`; reproduced with built binaries. Non-authoritative |
|
||||
| 04 | No test skipped or weakened; goldens free of credentials | judgment | LLM-judge: holds. The WR-12 rework returned TestTwoPluginMigrationSetsIsolated and TestDocsMigrate to their pre-57a849d form rather than weakening them; non-authoritative |
|
||||
| 05 | No exported identifier removed or changed | judgment (checked mechanically) | Holds: `git diff a28957f..HEAD` over modules, cmd and internal (non-test) shows only `argmask.Join` and `argmask.Quote` added, both under `internal/`; `lagoon.Status` keeps its signature and its plugin-only result |
|
||||
| 05 | WR-01 fixed inside live views; generated main unchanged | judgment | Holds: internal/build and cmd/summer/main.go are unchanged since the first verification |
|
||||
| 06 | Changelog token never printed | judgment | LLM-judge: holds per SUMMARY; non-authoritative |
|
||||
|
||||
### Test Quality Audit
|
||||
|
||||
| Test area | Linked | Skipped | Circular | Assertion level | Verdict |
|
||||
|-----------|--------|---------|----------|-----------------|---------|
|
||||
| diary (30 named) | SC-1, D-08..D-12 | 1 conditional (root) | no | value/behavioral (slogtest conformance) | OK |
|
||||
| bonfire goldens | D-13, D-14, D-18 | 0 | partial: created with `-update` | value | OK, provenance PARTIAL (human item 1) |
|
||||
| bonfire behavior (live, signals, exit codes) | D-03, D-18, D-27 | 0 | no | behavioral (helper processes, pty, cancellation) | OK; cancellation now covered by TestPrintAboveAfterCancel |
|
||||
| lagoon Docker | D-21, WR-07, WR-12, WR-13 | 0 under Docker | no | value | OK; TestMigrateStatusJSON asserts a pending framework migration |
|
||||
| cmd/summer runtime | CR-02, CR-03, WR-03, WR-10 | POSIX-only conditionals | no | behavioral | OK; signal-death and start-failure leak cases covered |
|
||||
|
||||
Disabled tests on requirements: 0. Circular: 0 blocking. Insufficient assertions: 0. One small note carried from the quick verification: printAbove's "Run ended on its own" branch (not via cancellation) has no committed pinning test; the cancellation branch it shares code with is pinned.
|
||||
|
||||
### Anti-Patterns Found
|
||||
|
||||
| File | Line | Pattern | Severity | Impact |
|
||||
|------|------|---------|----------|--------|
|
||||
| internal/build/artifact.go | 182 | `"TODO: describe " + cmdName` | ℹ️ Info | A template string the scaffolder writes into generated commands (pre-phase) |
|
||||
| cmd/summer/main.go, runtime.go, runtime_test.go, modules/flare/commands.go | n/a | gofmt drift | ℹ️ Info | Pre-existing, recorded in deferred-items.md and in the quick SUMMARY |
|
||||
| modules/lagoon/commands.go | migrate:status Description | "Show per-plugin migration history" / example "Show the applied migrations per plugin" | ℹ️ Info | The command now also lists framework sets; the Long help says so, but the one-line description still says per-plugin. Kept unchanged on purpose (P-06); cosmetic |
|
||||
|
||||
No TBD, FIXME or XXX in any file this phase or the gap-closure task changed; no TODO or HACK added.
|
||||
|
||||
### Human Verification Required
|
||||
|
||||
The goal is achieved; these are the confirmation checks from the first report. Three are visual or terminal checks the contract always routes to a person, and one is the explicit resolution of judgment-tier prohibitions. None is a suspected defect.
|
||||
|
||||
1. **Styled list, help and error on a real terminal.** Run `summer`, `bin/<app>`, `bin/<app> help admin:token:create` and `bin/<app> bogus`. Expected: the output matches the D-13, D-14 and D-18 previews in palette and alignment. Why human: the goldens came from the code itself.
|
||||
2. **Live widgets and prompts.** Run Spinner, Progress, Process, Choice, Ask, Confirm and Secret on a pty, then press Ctrl+C during a spinner. Expected: SSU-like look; log lines print above the view; the cursor comes back. Why human: animation and keyboard input. (The cancellation path of gap 1 is now covered by a test and a pty probe; this item is about look and feel.)
|
||||
3. **serve on a real application.** Run it at the default verbosity, with `-q` and with `-v`, then stop it with Ctrl+C; also run `summer dev`. Expected: a readable startup block, component-prefixed INFO lines, a shutdown report, exit 0. Why human: readability.
|
||||
4. **Judgment-tier prohibitions.** Confirm or reject the non-authoritative verdicts in the Prohibitions table. The secrets prohibition is no longer flagged as violated.
|
||||
|
||||
### Gaps Summary
|
||||
|
||||
No gaps remain. All five roadmap success criteria and all 52 plan truths hold in the codebase at HEAD `4141cd9`. The three gaps of the first report were each re-checked in the code, with the named pinning tests, and with an independent run that reproduced the original failure scenario:
|
||||
|
||||
1. **Live view lifecycle (WR-09):** a cancelled view now ends with its last frame and is unregistered without waiting for the work function. Later lines print plainly, and `PrintAbove` reports false. The pty probe passed 5/5, where the first verification had failed 3/3.
|
||||
2. **Argv masking (WR-11, WR-10):** one helper (`internal/argmask`) masks dash-leading values and is used by both the wrong-directory hint and summer's delegate errors. Built binaries no longer print `-Xk9q`, `hunter2` or `t0k3n`.
|
||||
3. **Migration reporting (WR-12):** `migrate:status` (table and `--json`) reads the same `migrationSets` as `migrate`, so framework sets and their pending migrations are listed. The exported `lagoon.Status` keeps its plugin-only contract, and the fonoteka parity consumer passes.
|
||||
|
||||
The follow-up items WR-13, WR-14, IN-14 and IN-15 are fixed too. IN-10..IN-13, IN-01..IN-09 and the exit-130 idea are recorded as deferred in the console review todo. The gap-closure commits are local and unreleased; shipping them needs a v0.4.x tag on the user's go-ahead.
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-10-22T02:37:57Z_
|
||||
_Verifier: Claude (msd-verifier)_
|
||||
1
.planning/phases/32-seo-foundation/.gitkeep
Normal file
1
.planning/phases/32-seo-foundation/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
376
.planning/phases/32-seo-foundation/32-01-PLAN.md
Normal file
376
.planning/phases/32-seo-foundation/32-01-PLAN.md
Normal file
@@ -0,0 +1,376 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/form_extensions.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/extension.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/partial_render.go
|
||||
- modules/cabana/field_type.go
|
||||
- modules/cabana/field_ml.go
|
||||
- modules/cabana/form_extensions_smoke_test.go
|
||||
- modules/cabana/form_extensions_postgres_test.go
|
||||
- modules/cabana/example_form_extension_test.go
|
||||
- modules/cabana/README.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- docs/setup/coming-from-wintercms.md
|
||||
- admin/tests/form/FormView.test.ts
|
||||
autonomous: false
|
||||
requirements: [SC-1, SC-5, D-91, D-101, D-90, D-98, D-100, D-104]
|
||||
|
||||
estimate:
|
||||
tokens: 140000
|
||||
raw_tokens: 140000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A plugin implementing pact.HasAdminActionExtensions returns an AdminActionExtension whose Form adds field C After A to another plugin's form of A, B, and the admin form schema lists A, C, B (SC-1, D-91)"
|
||||
- "A field placed Before the first owner field compiles first; a field with no anchor goes to the end of its tab, as in WinterCMS (D-91)"
|
||||
- "A new extension tab placed After one owner tab and Before the next renders between them; an owner form with no tabs plus an extension tab renders the default tab (Basic) first, then the new tab (D-91, UI-SPEC C1)"
|
||||
- "Two plugins anchored at the same field keep plugin activation order (party, by Requires()); an anchor may name another extension's field only when that plugin is in the contributor's Requires() (D-91)"
|
||||
- "An extension hides an owner field through Hide; the field is absent from the schema and from show, and a tab that loses all its fields disappears (D-91)"
|
||||
- "Unknown field or tab anchor, duplicate field name, duplicate tab key, an anchor cycle, an anchor outside Requires(), Before the default tab, any Zone other than the tab zone, Hide of an unknown or referenced field and a fileupload extension field each stop the boot with an error naming the plugin, the controller and the offending name (SC-1, D-91, D-101, D-100)"
|
||||
- "Extension Load runs on show and Save runs inside the record's save transaction after the owner row is written; a Save error rolls back the whole save and leaves the owner row unchanged; AdminFormErrors answer 422 field lines and per-field notices render as save notices (D-91)"
|
||||
- "Extension field values never reach lagoon.Fill, BindWritableFields or the owner's columns, translation rows or attachments (D-91)"
|
||||
- "An admin without the extension's Permissions, or a request where Visible answers false, gets no extension field in schema or show, and a save ignores posted extension keys and does not call Save (D-91, UI-SPEC C1 Permission)"
|
||||
- "A form that no extension targets compiles byte-identically to before this plan: its CanonicalJSON is unchanged and owner tab interleaving is not canonicalised (strictly additive)"
|
||||
- "The framework change is strictly additive: new optional struct fields and new types only; existing pact, cabana and signpost exported signatures and behaviour are unchanged, no method is added to an existing interface, and existing plugins compile and behave the same without edits (D-106)"
|
||||
- "The SPA renders the compiled order as sent and adds no ordering code: admin/src is unchanged by this plan"
|
||||
- "Field span (left, right, full) keeps working next to inserted fields (D-91)"
|
||||
- "One plugin extending two controllers and two plugins extending one controller both compile deterministically (assumption-delta invariant)"
|
||||
- statement: "SPA test: a schema whose compiled order puts an extension field between two owner fields renders A, C, B, and a tab-less form plus an extension tab renders Basic, then the new tab (UI-SPEC C1 backstop)"
|
||||
verification: backstop
|
||||
prohibitions:
|
||||
- statement: "No breaking change to existing framework API: no exported pact, cabana or signpost identifier is removed or changes signature, and no existing behaviour changes for plugins that do not use the new seam"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "An extension must never write the owner plugin's model columns, translation rows or attachment relations; the owner's model and tables stay untouched (D-91)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "Framework code, READMEs and docs added by this plan name no SEO concept and no consuming application (D-90)"
|
||||
status: resolved
|
||||
verification: test
|
||||
artifacts:
|
||||
- path: "modules/pact/capabilities.go"
|
||||
provides: "AdminActionExtension.Form, AdminFormExtension, AdminFormTab, AdminFormField, AdminFormLoad, AdminFormSave, AdminFormSaveResult, AdminFormErrors, zone constants"
|
||||
contains: "Form *AdminFormExtension"
|
||||
- path: "modules/cabana/form_extensions.go"
|
||||
provides: "compileFormExtensions: placement pass, boot errors, extension-owned field registry"
|
||||
contains: "func compileFormExtensions("
|
||||
- path: "modules/cabana/form_extensions_postgres_test.go"
|
||||
provides: "TestFormExtensionTracer and TestFormExtensionSave (save transaction, rollback, permissions)"
|
||||
contains: "func TestFormExtensionTracer("
|
||||
- path: "modules/cabana/example_form_extension_test.go"
|
||||
provides: "the docs snippet source for the form extension section"
|
||||
contains: "AdminFormExtension"
|
||||
- path: "admin/tests/form/FormView.test.ts"
|
||||
provides: "UI-SPEC C1 backstop cases"
|
||||
contains: "extension"
|
||||
key_links:
|
||||
- from: "modules/cabana/http.go"
|
||||
to: "modules/cabana/form_extensions.go"
|
||||
via: "Activate calls compileFormExtensions(reg, plugins) after compileRegistryWithTypes and before compileActionExtensions"
|
||||
pattern: "compileFormExtensions\\(reg, plugins\\)"
|
||||
- from: "modules/cabana/crud.go"
|
||||
to: "modules/pact/capabilities.go"
|
||||
via: "CRUDService.save lifts extension values before projection and calls AdminFormExtension.Save inside s.transaction"
|
||||
pattern: "\\.Save\\(ctx, pact\\.AdminFormSave"
|
||||
- from: "docs/backend/admin-controllers.md"
|
||||
to: "modules/cabana/example_form_extension_test.go"
|
||||
via: "src= snippet kept in sync by summer docs:sync"
|
||||
pattern: "example_form_extension_test.go"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan delivers the first framework seam the goal rests on: a plugin can place fields and tabs inside another plugin's admin form.
|
||||
|
||||
<objective>
|
||||
Implement D-91 cross-plugin admin form extensions in the framework: `pact.AdminActionExtension` gains `Form *pact.AdminFormExtension`; cabana compiles the placement once at boot (`Before`/`After` field and tab anchors, the tab zone only per D-101), dispatches extension-owned widgets, partials, plugin field types and translatable fields to the contributing plugin, keeps extension values out of the owner's model, and runs the extension's `Load` on show and `Save` inside the record's save transaction. README, docs and an SPA backstop test land with it. The framework names no SEO concept (D-90); fileupload stays out of extensions because OG images use a plugin field type instead (D-100); the SEO plugin later dogfoods the seam on its own settings form (D-104).
|
||||
|
||||
Purpose: SC-1 ("A, B plus C after A renders A, C, B"; a tab between two tabs; clear boot errors). Every later plan of this phase (D-98 order) builds the SEO tab and the per-type settings tabs on this seam.
|
||||
|
||||
Output: the pact types, `modules/cabana/form_extensions.go`, the save/show/schema wiring, a tracer test through the admin HTTP API, docs, and the UI-SPEC C1 backstop test. Which plan implements each decision of the phase, and what Phase 33 takes, is in `32-DECISIONS-MAP.md`.
|
||||
|
||||
**Planner decisions recorded here (Claude's discretion: the exact Go shape of the seam, CONTEXT):**
|
||||
- **P-01 (placement data in Go, definitions in fields.yaml keys):** an extension declares tabs and fields as Go structs (`AdminFormTab`, `AdminFormField` with `Before`, `After`, `Zone`, matching D-91's and D-101's wording) and each field's ordinary fields.yaml keys in `AdminFormField.Config` (a `map[string]any` holding label, type, span, comment, options and the rest). cabana encodes `Config` with goccy/go-yaml and compiles it through the same `decodeFieldMapping`/`compileFieldNode` path as a fields.yaml entry, so every type, option and plugin-field-type check applies unchanged. Go declarations let a plugin generate fields at boot (the per-type settings tabs of D-104) without templating YAML. Confirmed or replaced at the Task 1 checkpoint.
|
||||
- **P-02 (canonicalisation only when extended):** the owner's field list is regrouped by tab in first-appearance order (the default tab first, as the SPA renders it) only for a controller that at least one extension targets. Every other form compiles byte-identically, so the change is strictly additive. Consequence: Journal Post renders Edit | Manage | Categories | SEO (first appearance), not the order UI-SPEC C3 wrote (RESEARCH Pitfall 2).
|
||||
- **P-03 (zones, D-101):** `AdminFormField.Zone` accepts "" and `pact.AdminFormZoneTabs`; `pact.AdminFormZoneOutside` and `pact.AdminFormZoneSecondary` exist as constants and stop the boot with "zone %q is not supported yet".
|
||||
- **P-04 (tab keys):** a tab's stable name is its raw `tab:` value (the label phrase key), exactly as owner fields.yaml uses it; the reserved name `default` names the tab of fields without `tab`. `Before: "default"` is a boot error; `After: "default"` is allowed.
|
||||
- **P-05 (anchor cursor):** several extensions anchored at the same point insert after the last field already inserted at that anchor, so plugin order is kept (RESEARCH Pattern 1 step 2).
|
||||
- **P-06 (errors and notices):** `pact.AdminFormErrors` (map of field name to messages, implements `error`) answers 422 with the existing ValidationError details; `AdminFormSaveResult.Notices` (map of field name to `[]pact.FormFieldNotice`) is merged into the save's `Meta.Notices` through the existing `pluginNotice`/`localizeNotices` path. A notice may name an owner field (the SEO plugin puts its address-change notice on the owner's slug field).
|
||||
|
||||
<assumption_delta_decision>
|
||||
Signal: pluralization of "another" in SC-1 ("a field between two fields of another plugin's admin form").
|
||||
Primary noun: the target admin controller, named by its controller ID; every compiled field is identified by its stable field name across the owner and all contributors.
|
||||
Decision: no-change. `pact.AdminActionExtension` is already keyed by `Controller` and `HasAdminActionExtensions` returns a slice, so any number of contributing plugins can target any number of controllers without a new identity model; promotion is not needed because the controller ID already is the general key.
|
||||
Invariant test: `TestFormExtensionTwoPluginsSameAnchor` and `TestFormExtensionOnePluginTwoControllers` in `modules/cabana/form_extensions_smoke_test.go` assert a deterministic compiled order for both shapes.
|
||||
</assumption_delta_decision>
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-RESEARCH.md
|
||||
@.planning/phases/32-seo-foundation/32-PATTERNS.md
|
||||
@.planning/phases/32-seo-foundation/32-UI-SPEC.md
|
||||
@.planning/phases/32-seo-foundation/32-VALIDATION.md
|
||||
@CLAUDE.md
|
||||
@modules/pact/capabilities.go
|
||||
@modules/cabana/action_extensions.go
|
||||
@modules/cabana/http.go
|
||||
|
||||
<interfaces>
|
||||
From modules/pact/capabilities.go (verbatim, lines 429-439):
|
||||
type AdminActionExtension struct {
|
||||
Controller string
|
||||
RecordActions []AdminRecordAction
|
||||
}
|
||||
type HasAdminActionExtensions interface {
|
||||
AdminActionExtensions() []AdminActionExtension
|
||||
}
|
||||
The doc comment above it ends "Only record actions are carried for now; the struct leaves room for more kinds."
|
||||
|
||||
From modules/pact/capabilities.go (existing types this plan reuses):
|
||||
type AdminAction struct { ... } // widget actions (line 226)
|
||||
type FormFieldNotice struct { Message string; Params map[string]string; Count int }
|
||||
type FormFieldError struct { Messages []string }
|
||||
type FormFieldType struct { Name, Element string; Translatable bool; Scripts, Styles, Options []string; CheckOptions; Decode; Load; ListValue; Upload }
|
||||
|
||||
From modules/cabana/http.go Activate (lines 108-143): compileFieldTypes(plugins) → compileRegistryWithTypes(items, fieldTypes) → checkFileLimits → checkDeferredModels → compileActionExtensions(reg, plugins) → compileAccountContributions → compileContributions.
|
||||
|
||||
From modules/cabana/action_extensions.go: func compileActionExtensions(reg *Registry, plugins []party.Plugin) error — iterates plugins in party order, type-asserts pact.HasAdminActionExtensions, looks up reg.byID[ext.Controller], errors "cabana: plugin %s adds record actions to unknown admin controller %q", copies compiled slices before appending. It skips an extension with len(ext.RecordActions) == 0, so an extension carrying only Form passes through it unchanged.
|
||||
|
||||
From modules/cabana/crud.go: CRUDService.save (line 736) order: liftVirtualValues → liftMLValues → s.transaction{ loadRecord → decodePluginFields → sanitizeRichEditors → lagoon.Fill → BeforeValidate → lagoon.Validate → formBefore* → tx.Save/Create → applyMLTranslations → formAfter* → hydrateMLRecord → hydratePluginFields } → result.Meta.Notices = localizeNotices(ctx, s.tr, notices). BindWritableFields (line 233) refuses "field X is not a model column".
|
||||
|
||||
From modules/cabana/extension.go: compileExtension (line 60) checks widget tag prefix against the owner plugin, fill keys as writable scalars, AdminClientAssets JS; compilePartials (line 200) reads _<name>.htm from the owner's ConfigDir and requires pact.AdminPartialData.
|
||||
|
||||
From modules/cabana/http.go (line 857): hiddenSchemaFields(ctx, cc) — schema-only, per request.
|
||||
|
||||
From admin/src/components/form/formState.ts: DEFAULT_TAB = 'default'; tabOf(field) = field.tab ? `tab:${field.tab}` : DEFAULT_TAB. FormView.vue builds tabs by first appearance and unshifts the default tab.
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking">
|
||||
<name>Task 1: Confirm the Go shape of the D-91 form-extension seam (one-way framework API)</name>
|
||||
<decision>Which Go shape does `pact.AdminActionExtension.Form` publish for cross-plugin form fields and tabs (D-91, D-101)?</decision>
|
||||
<context>D-91 is confirmed, but its exact Go shape is Claude's discretion (CONTEXT) and becomes published framework API at the phase's release tag; changing it afterwards breaks every plugin that implements it (RESEARCH A1). The shape recommended here (P-01): `type AdminActionExtension struct { Controller string; RecordActions []AdminRecordAction; Form *AdminFormExtension }`; `type AdminFormExtension struct { Tabs []AdminFormTab; Fields []AdminFormField; Hide []string; Permissions []string; Visible func(ctx context.Context) bool; Dir string; Actions []AdminAction; PartialData func(ctx context.Context, name string, record any) (any, error); Load func(ctx context.Context, in AdminFormLoad) (map[string]any, error); Save func(ctx context.Context, in AdminFormSave) (AdminFormSaveResult, error) }`; `type AdminFormTab struct { Name, Before, After string }`; `type AdminFormField struct { Name, Tab, Before, After, Zone string; Config map[string]any }`; `type AdminFormLoad struct { DB *gorm.DB; Controller string; Record any; ID string }`; `type AdminFormSave struct { DB *gorm.DB; Controller string; Record any; ID string; Created bool; Values map[string]any }` (plan 32-02 adds `Changes []RecordChange`); `type AdminFormSaveResult struct { Notices map[string][]FormFieldNotice }`; `type AdminFormErrors map[string][]string`; constants `AdminFormZoneTabs = "tabs"`, `AdminFormZoneOutside = "outside"`, `AdminFormZoneSecondary = "secondary"`. `Dir` is the directory in the contributing plugin's AdminFS that holds the `_<name>.htm` files of its partial fields. Translatable extension fields carry `map[string]string` (locale to value) in Load and Save.</context>
|
||||
<options>
|
||||
<option id="go-placement">
|
||||
<name>Go-declared placement, fields.yaml keys in Config (recommended, P-01)</name>
|
||||
<pros>Before, After and Zone are struct fields as D-91 and D-101 word them; a plugin generates fields at boot (per-type settings tabs, D-104) without templating YAML; Config is compiled by the existing fields.yaml checks</pros>
|
||||
<cons>An extension's field definitions live in Go, not in a fields.yaml file next to the owner's</cons>
|
||||
</option>
|
||||
<option id="yaml-document">
|
||||
<name>A fields.yaml document per extension with before:/after:/zone: keys and a top-level tabs: list</name>
|
||||
<pros>Same file format as owner forms</pros>
|
||||
<cons>Generated fields (one tab per content type) need templated YAML bytes; Zone exists only as a YAML key, not as the struct field D-101 names</cons>
|
||||
</option>
|
||||
<option id="amend">
|
||||
<name>The recommended shape with Jakub's renames or additions</name>
|
||||
<pros>Lets Jakub fix names before they become published API</pros>
|
||||
<cons>The executor applies the amendments to every task of this plan</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer go-placement, yaml-document, or amend with the changes; the executor records the answer in 32-01-SUMMARY.md and uses it in Tasks 2-4</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 2: End-to-end "plugin B adds field C after A on plugin A's form" through the admin API — one path only</name>
|
||||
<reversibility rating="one-way">The pact types become published framework API at the release tag; plugins (sm-seo-plugin first) implement them and a later change breaks their builds.</reversibility>
|
||||
<files>modules/pact/capabilities.go, modules/pact/README.md, modules/cabana/form_extensions.go, modules/cabana/http.go, modules/cabana/crud.go, modules/cabana/form_extensions_postgres_test.go, docs/backend/admin-controllers.md</files>
|
||||
<read_first>
|
||||
- modules/pact/capabilities.go (AdminActionExtension 405-439, AdminAction 226-268, FormFieldNotice 584-590, FormFieldError 612-622)
|
||||
- modules/cabana/action_extensions.go (whole file: the pass to copy)
|
||||
- modules/cabana/http.go (Activate 90-160)
|
||||
- modules/cabana/crud.go (ProjectWritableFields 201, BindWritableFields 233, save 736-944, projectFullRecord 689)
|
||||
- modules/cabana/form_schema.go (decodeFieldMapping 496, compileFieldNode 528, FormSchema.Localize 263, CanonicalJSON 313)
|
||||
- modules/cabana/field_type_postgres_test.go (newListService harness, lines 100-130) and modules/cabana/action_extensions_postgres_test.go (HTTP-level assertions)
|
||||
- modules/pact/README.md and docs/backend/admin-controllers.md ("Adding record actions to another controller", line 497)
|
||||
- The Task 1 answer recorded by the executor
|
||||
</read_first>
|
||||
<action>
|
||||
Apply the shape chosen at Task 1 (the text below assumes go-placement; for yaml-document or amend, keep the same behaviour and change only the declaration form). Per D-91 and D-101:
|
||||
1. pact: add `Form *AdminFormExtension` as the last field of `AdminActionExtension` and the types `AdminFormExtension`, `AdminFormTab`, `AdminFormField`, `AdminFormLoad`, `AdminFormSave`, `AdminFormSaveResult`, `AdminFormErrors` (with `Error() string` joining field and messages) and the three zone constants. Rewrite the doc comment's last sentence so it says record actions and form contributions are carried, and list the D-91 boot errors in prose the way the existing comment lists the record-action ones. Only additions: no existing field, method or comment contract changes meaning.
|
||||
2. cabana `form_extensions.go`: `compileFormExtensions(reg *Registry, plugins []party.Plugin) error` iterating plugins in party order like `compileActionExtensions`; skip `ext.Form == nil`; unknown controller → `cabana: plugin %s extends the form of unknown admin controller %q`; a target with no form → error naming both. For the tracer, implement only: compile each `AdminFormField.Config` through goccy/go-yaml encoding plus `decodeFieldMapping` against the boot's field type registry, insert it `After`/`Before` a named owner field of the same tab (unknown anchor → `cabana: plugin %s: controller %q: field %s: unknown anchor %q`), record the field in a per-controller map of extension-owned field name → contributing plugin and extension, and when the controller is extended, regroup the owner list by tab in first-appearance order with the default tab first (P-02). Wire it in `http.go` `Activate` directly after `compileRegistryWithTypes` and before `checkFileLimits` with a comment naming D-91.
|
||||
3. cabana `crud.go`: before `ProjectWritableFields`, lift the submitted values of extension-owned fields out of the body (they never reach Fill or `BindWritableFields`; make `BindWritableFields` skip extension-owned fields); inside `s.transaction`, after the owner row is written and its translations applied, call each visible extension's `Save` with `pact.AdminFormSave{DB: tx, Controller, Record, ID, Created, Values}`; a returned error aborts the transaction (an `AdminFormErrors` maps to the existing `ValidationError` 422 with those field lines). On show (`ShowRecord`/`projectFullRecord`) call `Load` with the read transaction and merge its map into the record data.
|
||||
4. Tracer test `TestFormExtensionTracer` in `form_extensions_postgres_test.go`: an owner plugin `acme.blog` with controller `acme.blog.posts` (model with columns a, b; fields a, b as text), a contributor `acme.extra` whose extension adds text field `c` After `a`, storing c in its own table `acme_extra_values` (record id, value) from Save and reading it in Load. Through the admin HTTP routes: the form schema lists a, c, b; PUT with {a, b, c} stores a and b in the owner row and c in `acme_extra_values` in the same transaction; GET shows c; the owner model has no c column.
|
||||
5. Same commit (documentation rule): `modules/pact/README.md` lists the new types; `docs/backend/admin-controllers.md` gains "Adding fields to another controller's form" after "Adding record actions to another controller" with a minimal prose example using neutral names (acme). Name no SEO concept and no consuming application (D-90).
|
||||
Commit: `feat(32-01): cross-plugin admin form extensions (tracer)` staging exactly the files above.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test ./modules/cabana -run 'TestFormExtensionTracer' -count=1 -v 2>&1 | tail -30</automated>
|
||||
<fails_when>non-zero exit, "FAIL" or "no tests to run" in the output, or no "--- PASS: TestFormExtensionTracer" line</fails_when>
|
||||
<automated>go vet ./... && go test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "Form \*AdminFormExtension" modules/pact/capabilities.go` prints exactly one line
|
||||
- `grep -n "func compileFormExtensions(reg \*Registry, plugins \[\]party.Plugin) error" modules/cabana/form_extensions.go` prints one line
|
||||
- `grep -n "compileFormExtensions(reg, plugins)" modules/cabana/http.go` prints one line located before the `compileActionExtensions(reg, plugins)` line
|
||||
- `go test ./modules/cabana -run TestFormExtensionTracer -count=1` passes and its schema assertion compares the field name list to exactly `[a c b]`
|
||||
- `go doc ./modules/pact AdminFormExtension` prints the struct with Tabs, Fields, Hide, Permissions, Visible, Dir, Actions, PartialData, Load and Save
|
||||
- `grep -c "AdminFormExtension" modules/pact/README.md docs/backend/admin-controllers.md` reports at least one line in each file
|
||||
</acceptance_criteria>
|
||||
<done>A contributor plugin's field C appears between owner fields A and B in the compiled schema, saves through the extension's Save inside the record's transaction and loads on show, without touching the owner's model; committed with README and docs.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Full placement rules, boot errors, permissions and the extension-owned branches (tabs, hide, widgets, partials, plugin field types, translatable fields)</name>
|
||||
<files>modules/cabana/form_extensions.go, modules/cabana/crud.go, modules/cabana/http.go, modules/cabana/extension.go, modules/cabana/actions.go, modules/cabana/partial_render.go, modules/cabana/field_type.go, modules/cabana/field_ml.go, modules/cabana/form_extensions_smoke_test.go, modules/cabana/form_extensions_postgres_test.go</files>
|
||||
<read_first>
|
||||
- modules/cabana/form_extensions.go (from Task 2)
|
||||
- modules/cabana/extension.go (compileExtension 60-165, compilePartials 200-251, checkWidgetTag 339)
|
||||
- modules/cabana/actions.go (widgetAction 36-90, widgetField 356, runAction 322)
|
||||
- modules/cabana/partial_render.go (refusedViewModel 287, service.partial 499)
|
||||
- modules/cabana/field_type.go (pluginNotice 369, decodePluginFields 433, hydratePluginFields 696)
|
||||
- modules/cabana/field_ml.go (liftMLValues 68, applyMLTranslations 163, hydrateMLRecord 190)
|
||||
- modules/cabana/http.go (hiddenSchemaFields 850-866 and the schema/show handlers that call it)
|
||||
- modules/cabana/field_type_smoke_test.go (ftPlugin, ftCompile fixtures 160-200)
|
||||
- modules/party/registry.go (topoSort order, Requires)
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Pattern 1, Pitfalls 1-7)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C1)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- C After A on [A, B] gives [A, C, B]; C Before A gives [C, A, B]; C with no anchor gives [A, B, C] (end of its tab)
|
||||
- New tab T2 After tab T1 and Before T3 gives tab order T1, T2, T3; a tab-less owner plus a new tab gives default, then the new tab
|
||||
- Plugins P1 and P2 (P2 requires P1) both anchored After A give [A, C1, C2, B]; P2 anchored After C1 compiles; P1 anchored on a P2 field fails (P2 not in P1's Requires())
|
||||
- Hide of owner field B removes it from schema and show; a tab whose fields are all hidden disappears
|
||||
- Boot errors, each naming plugin, controller and name: unknown field anchor, unknown tab anchor, duplicate field name (vs owner and vs earlier extension), duplicate tab key, two tab keys whose labels localize to the same text, cycle among one extension's Before/After references, anchor outside Requires(), Before "default", Zone "outside" or "secondary" ("zone %q is not supported yet"), Hide of an unknown field, Hide of a field another field references through fill, dependsOn, trigger or preset, a fileupload extension field, an extension widget action name equal to an owner action, an extension partial name equal to an owner partial
|
||||
- Permissions/Visible false: schema and show omit the extension's fields; a save with posted extension keys leaves stored values untouched and does not call Save
|
||||
- Save returning AdminFormErrors{"c": ["validation.required"]} answers 422 with the field line, the owner row unchanged; Save returning Notices{"a": [...]} puts the notice in Meta.Notices; Save returning a plain error answers 500 and rolls back
|
||||
- An extension field of a translatable plugin field type runs the type's Decode (notices kept) and hands Save map[locale]string; nothing is written to the owner's host column or translation rows
|
||||
- An extension widget field (type: widget) with fill naming fields of the same extension compiles; its action dispatches to AdminFormExtension.Actions; an extension partial renders from the contributor's AdminFS Dir through PartialData and the view-model guard refuses a GORM model
|
||||
- A controller no extension targets: CanonicalJSON of its form schema is byte-identical with and without the contributor plugin present
|
||||
- An extension with no Tabs and no Fields but a Save (and optionally Load) hook is valid: its Save runs in the save transaction and may return AdminFormErrors or Notices naming owner fields (a save hook on another or its own controller's form)
|
||||
</behavior>
|
||||
<action>
|
||||
Complete the D-91 compile pass and runtime per the behaviour list (D-91, D-101, D-100). Placement: canonicalise (P-02), then per plugin in party order insert tabs, then fields, with the anchor cursor (P-05); topologically sort one extension's own fields by their Before/After references and report a stalled sort as a cycle. Anchor resolution across extensions uses the field-to-plugin map and the contributor's `Requires()` (direct requirement only). Tab keys are raw `tab:` values (P-04); check duplicate raw keys and localized-label collisions for every locale the phrasebook loads, when the translator is published (RESEARCH Pitfall 1). Zone per P-03.
|
||||
Extension-owned branches, keyed by the field-to-extension map compiled at boot: in `extension.go` check a widget tag against the contributing plugin's prefix, accept fill keys that are fields of the same extension, accept the contributor's field-type scripts or AdminClientAssets as the element source, and refuse a widget action name that clashes with the owner's; in `actions.go` dispatch `widgets/{field}` of an extension field to `AdminFormExtension.Actions` with the same permission checks plus the extension's Permissions; in `extension.go`/`partial_render.go` compile extension partials from the contributor's AdminFS `Dir` and render them through `AdminFormExtension.PartialData`, keeping `refusedViewModel`; in `field_type.go` run `Decode` for extension plugin-field-type values but return the decoded value to the extension instead of the host column, and on show run the extension `Load` first and the type's `Load` after it; in `field_ml.go` make `liftMLValues` skip extension ML fields (their per-locale values are lifted into the extension's Values as `map[string]string`).
|
||||
Permissions and Visible: one helper `visibleExtensions(ctx, cc, principal)` used by the schema handler (next to `hiddenSchemaFields`), show and save; on save drop the keys of invisible extensions before anything else and do not call their Save (RESEARCH Pitfall 7).
|
||||
Errors and notices per P-06.
|
||||
Tests (written first, RED then GREEN): table tests in `form_extensions_smoke_test.go` (pure compile, no DB, `ftPlugin`-style fixtures) named `TestFormExtensionPlacement`, `TestFormExtensionBootErrors`, `TestFormExtensionTwoPluginsSameAnchor`, `TestFormExtensionOnePluginTwoControllers`, `TestFormExtensionUnextendedSchemaUnchanged`; Postgres cases in `form_extensions_postgres_test.go` named `TestFormExtensionSave` (rollback on error, 422 lines, notices, invisible extension skipped, translatable values as map, owner columns untouched). These are the plan's smoke coverage; the exhaustive unit matrix is plan 32-06.
|
||||
Commit per logical change (compile pass; runtime branches), staging files by path. Before touching cabana check `git status --short modules/cabana` for other sessions' in-flight edits and leave them alone.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test -short ./modules/cabana -run 'TestFormExtension' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok|PASS)' | tail -40</automated>
|
||||
<fails_when>a "--- FAIL" or "FAIL" line, "no tests to run", or any of TestFormExtensionPlacement, TestFormExtensionBootErrors, TestFormExtensionTwoPluginsSameAnchor, TestFormExtensionOnePluginTwoControllers, TestFormExtensionUnextendedSchemaUnchanged missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go test ./modules/cabana -run 'TestFormExtensionSave|TestFormExtensionTracer' -count=1 2>&1 | tail -5</automated>
|
||||
<fails_when>non-zero exit or "FAIL" in the output</fails_when>
|
||||
<automated>go vet ./... && go test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `go test -short ./modules/cabana -run TestFormExtensionBootErrors -v` shows one passing subtest per boot error listed in the behaviour block (at least 14 `--- PASS` subtest lines)
|
||||
- `grep -n "is not supported yet" modules/cabana/form_extensions.go` prints at least one line (D-101 zone refusal)
|
||||
- `grep -n "fileupload" modules/cabana/form_extensions.go` prints the refusal of fileupload extension fields (D-100)
|
||||
- `TestFormExtensionUnextendedSchemaUnchanged` compares `CanonicalJSON()` bytes with and without the contributor and passes
|
||||
- `git diff --name-only "$PLAN_START"..HEAD -- admin/src` prints nothing, where PLAN_START is the plan's start SHA recorded before Task 2's first commit (no SPA change)
|
||||
- `go test ./modules/cabana -count=1` (Docker) exits 0
|
||||
</acceptance_criteria>
|
||||
<done>Every D-91 placement rule and boot error works and is covered by smoke tests; extension widgets, partials, plugin field types and translatable fields dispatch to the contributor; invisible extensions are inert on save; unextended forms are unchanged.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: Documentation, runnable example and the UI-SPEC C1 SPA backstop</name>
|
||||
<files>modules/cabana/example_form_extension_test.go, modules/cabana/README.md, modules/pact/README.md, docs/backend/admin-controllers.md, docs/setup/coming-from-wintercms.md, admin/tests/form/FormView.test.ts</files>
|
||||
<read_first>
|
||||
- modules/cabana/example_action_extension_test.go (the docs snippet pattern, function ProfilesPlugin.AdminActionExtensions)
|
||||
- docs/backend/admin-controllers.md (lines 497-530, the src= snippet convention)
|
||||
- modules/cabana/README.md (Features line 58 on record-action extensions; API reference table near line 297)
|
||||
- docs/setup/coming-from-wintercms.md (the extendFormFields mapping, if present)
|
||||
- admin/tests/form/FormView.test.ts (existing fixtures and render helpers)
|
||||
- admin/src/views/FormView.vue (tabs derivation 151-171) and admin/src/components/form/formState.ts
|
||||
</read_first>
|
||||
<action>
|
||||
1. `example_form_extension_test.go`: an `ExtrasPlugin` (neutral name, D-90) whose `AdminActionExtensions()` adds a field After an owner field, a new tab After an owner tab, hides one owner field, and implements Load and Save against a side table; an `Example...` function with `// Output:` so `go test` runs it. Reference it from `docs/backend/admin-controllers.md` "Adding fields to another controller's form" with a `src=modules/cabana/example_form_extension_test.go#ExtrasPlugin.AdminActionExtensions` block, then run `go run ./cmd/summer docs:sync`.
|
||||
2. The docs section explains: stable names (field keys, raw tab keys, `default`), Before/After, end-of-tab default, tab placement, Hide, zones (only the tab zone, D-101), plugin order and the Requires() rule for anchors on another extension's fields, each boot error, Load and Save in the save transaction, AdminFormErrors and notices, Permissions and Visible on schema/show/save, that fileupload is refused in extensions (use a plugin field type with Upload instead), that the SPA renders the compiled order, and that an unextended form is unchanged. `modules/cabana/README.md` Features gains one bullet next to the record-action one; `modules/pact/README.md` documents each new type; `docs/setup/coming-from-wintercms.md` maps WinterCMS `extendFormFields` (addFields/addTabFields/removeField) to the new seam.
|
||||
3. SPA backstop (UI-SPEC C1, no change under admin/src): in `admin/tests/form/FormView.test.ts` add two cases named "renders an extension field between two owner fields in compiled order" (schema fields a, c, b with c carrying the same tab; asserts DOM order a, c, b) and "a tab-less form with an extension tab renders Basic, then the new tab".
|
||||
4. Run `scripts/check-admin-openapi.sh --check`: the payload shape is unchanged, so it must pass without regenerating; if it fails, the plan changed a payload by mistake: fix the code, not the generated files.
|
||||
Commit docs/example as `docs(32-01): form extensions in admin-controllers, cabana and pact READMEs` and the test as `test(32-01): FormView renders compiled extension order`, staged by path.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test ./cmd/summer -run TestDocsTree -count=1 2>&1 | tail -3 && go run ./cmd/summer docs:build --check 2>&1 | tail -5</automated>
|
||||
<fails_when>non-zero exit, "FAIL" in the test output, or docs:build reporting an unknown identifier, broken link or stale src= snippet</fails_when>
|
||||
<automated>npm --prefix admin run test -- tests/form/FormView.test.ts 2>&1 | tail -15</automated>
|
||||
<fails_when>non-zero exit, a "failed" count above zero, or the two new case titles missing from the passing output</fails_when>
|
||||
<automated>scripts/check-admin-openapi.sh --check</automated>
|
||||
<fails_when>non-zero exit (a committed OpenAPI or schema.d.ts file differs from a fresh generation)</fails_when>
|
||||
<automated>go test -short ./modules/cabana -run 'Example' -count=1 2>&1 | tail -3</automated>
|
||||
<fails_when>non-zero exit or "FAIL" in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "example_form_extension_test.go#ExtrasPlugin.AdminActionExtensions" docs/backend/admin-controllers.md` prints one line
|
||||
- `grep -n "extendFormFields" docs/setup/coming-from-wintercms.md` prints at least one line mentioning the new seam
|
||||
- `npm --prefix admin run test -- tests/form/FormView.test.ts` passes with the two new case titles
|
||||
- `git diff --name-only "$PLAN_START"..HEAD -- admin/src` prints nothing (PLAN_START as in Task 3)
|
||||
- `grep -niE "\bseo\b|fonoteka|plytarium|grzyb" modules/cabana/example_form_extension_test.go docs/backend/admin-controllers.md` prints nothing new from this plan (D-90)
|
||||
</acceptance_criteria>
|
||||
<done>The seam is documented with a runnable example, the docs checker is green, the SPA backstop proves compiled order rendering, and the admin OpenAPI is unchanged.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| contributing plugin → owner's admin form | compiled Go code from another plugin adds fields, hooks and partials to a form it does not own |
|
||||
| admin browser → cabana save | posted values, including keys of extension fields the admin may not see |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-01 | Tampering | cabana save: extension values reaching the owner's model | high | mitigate | Extension values are lifted before ProjectWritableFields; BindWritableFields skips them; TestFormExtensionSave asserts the owner row and columns are untouched |
|
||||
| T-32-02 | Elevation of privilege | cabana save: posted keys of an extension the admin may not see | high | mitigate | visibleExtensions applied in schema, show and save; invisible extensions' keys dropped and Save not called (RESEARCH Pitfall 7); covered by TestFormExtensionSave |
|
||||
| T-32-03 | Information disclosure | extension partials | medium | mitigate | Partials render through PartialData with the existing refusedViewModel guard and sanitizePartialNodes; a GORM model view model is refused |
|
||||
| T-32-04 | Denial of service | boot with a malformed extension | low | accept | A bad extension stops the boot with a clear error by design (D-91); no runtime path |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | No package is installed by this plan; the admin test uses the existing locked node_modules (no npm ci unless npm ls reports an inconsistent tree) |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go vet ./... && go test -short ./...` green at every commit; `go test ./modules/cabana -count=1` green with Docker.
|
||||
- `npm --prefix admin run test -- tests/form/FormView.test.ts` green; `scripts/check-admin-openapi.sh --check` green.
|
||||
- `go test ./cmd/summer -run TestDocsTree` and `go run ./cmd/summer docs:build --check` green.
|
||||
- No file under admin/src changed; no SEO concept or consuming application named in framework code, READMEs or docs (D-90).
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
SC-1 holds in the framework: field C after A renders A, C, B; a tab placed between two tabs renders there; unknown anchors, duplicate names and anchor cycles stop the boot with a clear error. The seam is strictly additive and documented.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 01)
|
||||
|
||||
- `pact.AdminActionExtension.Form` (new field), `pact.AdminFormExtension`, `pact.AdminFormTab`, `pact.AdminFormField`, `pact.AdminFormLoad`, `pact.AdminFormSave`, `pact.AdminFormSaveResult`, `pact.AdminFormErrors` (+ `Error()`), `pact.AdminFormZoneTabs`, `pact.AdminFormZoneOutside`, `pact.AdminFormZoneSecondary`
|
||||
- `modules/cabana/form_extensions.go`: `compileFormExtensions`, `visibleExtensions`, the extension-owned field map
|
||||
- Tests: `TestFormExtensionTracer`, `TestFormExtensionSave`, `TestFormExtensionPlacement`, `TestFormExtensionBootErrors`, `TestFormExtensionTwoPluginsSameAnchor`, `TestFormExtensionOnePluginTwoControllers`, `TestFormExtensionUnextendedSchemaUnchanged`, the example in `modules/cabana/example_form_extension_test.go`
|
||||
- Docs: "Adding fields to another controller's form" in `docs/backend/admin-controllers.md`; README entries in `modules/pact/README.md` and `modules/cabana/README.md`
|
||||
- SPA test cases in `admin/tests/form/FormView.test.ts`
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-01-SUMMARY.md` when done. Record the Task 1 answer, the commit SHA at the plan's start (the phase base used by scripts/check-phase32.sh in plan 32-05) and every commit SHA.
|
||||
</output>
|
||||
322
.planning/phases/32-seo-foundation/32-01-SUMMARY.md
Normal file
322
.planning/phases/32-seo-foundation/32-01-SUMMARY.md
Normal file
@@ -0,0 +1,322 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 01
|
||||
subsystem: admin
|
||||
tags: [cabana, pact, form-extensions, d-91, yaml, admin-spa]
|
||||
|
||||
requires:
|
||||
- phase: 12.x/19.x admin (cabana)
|
||||
provides: compiled fields.yaml forms, plugin field types, widgets, partials, AdminActionExtension record actions
|
||||
provides:
|
||||
- "pact.AdminActionExtension.Form with pact.AdminFormExtension (fields document via Fields path or FieldsYAML bytes, Hide, Permissions, Visible, Dir, Actions, PartialData, Load, Save)"
|
||||
- "pact.AdminFormLoad, AdminFormSave, AdminFormSaveResult, AdminFormErrors, AdminFormZoneTabs/Outside/Secondary"
|
||||
- "cabana compileFormExtensions: boot-time placement (field and tab anchors, anchor cursor, Requires() rule, cycles, Hide, D-101 zones) with clear boot errors"
|
||||
- "cabana runtime: extension values lifted before any owner path, Save in the record's save transaction, Load on show and save, visibility on schema/show/save/widgets/partials"
|
||||
affects: [32-02, 32-03, 32-04, 32-05, 32-06, sm-seo-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 34400
|
||||
tasks: 4
|
||||
commits: 5
|
||||
plan_head_before: 9868838fe3d01e07d578f2b2dd557d4296c48e10
|
||||
plan_head_after: 9ae326908fed1aea0fd5e251e402cc1f01322d9e
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Form extension fields document: fields.yaml format plus before:/after:/zone: per field and a top-level tabs: list, compiled through decodeFieldMapping"
|
||||
- "Extension-owned field registry (CompiledController.extensionFields) keys every owner-aware branch: lift, decode, hydrate, widgets, partials"
|
||||
- "One visibility helper (visibleExtensions) for schema, show and save"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/cabana/form_extensions.go
|
||||
- modules/cabana/form_extensions_postgres_test.go
|
||||
- modules/cabana/form_extensions_smoke_test.go
|
||||
- modules/cabana/example_form_extension_test.go
|
||||
modified:
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/contracts.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/actions.go
|
||||
- modules/cabana/partial_render.go
|
||||
- modules/cabana/field_type.go
|
||||
- modules/cabana/field_ml.go
|
||||
- modules/cabana/README.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- docs/setup/coming-from-wintercms.md
|
||||
- admin/tests/form/FormView.test.ts
|
||||
|
||||
key-decisions:
|
||||
- "D-91 Go shape (Task 1, answered by Jakub before dispatch): yaml-document. An extension carries a fields.yaml-format document whose fields take before:/after:/zone: and whose top-level tabs: list declares new tabs; pact.AdminFormTab and pact.AdminFormField are not published (redundant with the document)"
|
||||
- "Declaration form: AdminFormExtension.Fields is a path in the contributing plugin's AdminFS resolved with assetPath (like SettingsItem.Form and config_form.yaml form:); AdminFormExtension.FieldsYAML carries the document bytes for fields built at boot (D-104 per-type tabs); setting both stops the boot"
|
||||
- "A field with an anchor and no tab: joins the anchor's tab; a field's tab: must be an owner tab or one declared under tabs: (by itself or a required plugin)"
|
||||
- "Hide is static (every administrator); hidden owner fields also leave the owner's bindings, so show and save skip them"
|
||||
- "Extension field types: text, textarea, number, checkbox, switch, dropdown with listed options, markdown, mltext, mltextarea, mlmarkdown, plugin field types, widget, partial; fileupload refused per D-100; value fields need Save"
|
||||
- "Save runs after the owner's FormAfterCreate/FormAfterUpdate hooks inside the save transaction, on every create and update of a visible extension; Load runs on show and in the save response"
|
||||
- "Translatable extension values without a TranslationWriter are keyed by the admin's configured locale"
|
||||
- "Localized tab-label collisions are checked by checkFormExtensionTabLabels in Activate (where the translator is available), not inside compileFormExtensions"
|
||||
- "A widget element's script comes from the contributor's field type scripts or its plugin-level pact.AdminClientAssets (added to the target form's assets)"
|
||||
|
||||
patterns-established:
|
||||
- "Form extension boot errors: cabana: plugin <id>: controller \"<ctl>\": <field|tab|Hide> <name>: <reason>"
|
||||
- "Owner-aware branches check cc.extensionOf(name) before treating a form field as the owner's"
|
||||
|
||||
requirements-completed: [SC-1, SC-5, D-91, D-101, D-90, D-98, D-100, D-104]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Plugin B adds field C after A on plugin A's form: schema lists a, c, b; Save stores c in the contributor's table in the record's transaction; show serves c; owner model untouched"
|
||||
requirement: "SC-1"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/form_extensions_postgres_test.go#TestFormExtensionTracer"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Placement rules: before/after, end of tab, anchor tab inheritance, own-field anchors, new tabs between tabs, tab-less form plus new tab, regrouping, Hide, span kept"
|
||||
requirement: "D-91"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionPlacement"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionTwoPluginsSameAnchor"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionOnePluginTwoControllers"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Boot errors (22 cases plus localized tab-label collision) name plugin, controller and offending name; D-101 zones and D-100 fileupload refused"
|
||||
requirement: "D-101"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionBootErrors"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Save transaction semantics: AdminFormErrors 422 with rollback, plain error 500 with rollback, notices, hidden owner field, translatable locale maps, invisible extension inert, create"
|
||||
requirement: "D-91"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/form_extensions_postgres_test.go#TestFormExtensionSave"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Extension widgets dispatch to AdminFormExtension.Actions, partials render from the contributor's Dir through PartialData with the GORM view-model guard, invisible extensions offer neither"
|
||||
requirement: "D-91"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionWidgetsAndPartials"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Strictly additive: a form no extension lays out compiles byte-identically (CanonicalJSON), whole repo vet and tests green, admin OpenAPI unchanged"
|
||||
requirement: "SC-5"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/cabana/form_extensions_smoke_test.go#TestFormExtensionUnextendedSchemaUnchanged"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "go vet ./... && go test -short ./... && go test ./modules/cabana -count=1"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "scripts/check-admin-openapi.sh --check"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "SPA renders compiled order with no admin/src change (UI-SPEC C1 backstop)"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "admin/tests/form/FormView.test.ts#form extensions in compiled order (UI-SPEC C1, D-91)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D8
|
||||
description: "Docs: admin-controllers section with synced ExtrasPlugin snippet, runnable Example_formExtension, pact and cabana READMEs, WinterCMS extendFormFields mapping; no SEO concept or consuming app named (D-90)"
|
||||
requirement: "D-90"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "go run ./cmd/summer docs:build --check && go test ./cmd/summer -run TestDocsTree"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/example_form_extension_test.go#Example_formExtension"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D9
|
||||
description: "The published pact shape (yaml-document form) fits the SEO plugin's needs in plans 32-03/32-04 (SEO tab per type, per-type settings tabs via FieldsYAML)"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "One-way framework API; its fitness for sm-seo-plugin is proven only when plan 32-03 dogfoods it"
|
||||
|
||||
duration: 32min
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 01: Cross-plugin admin form extensions (D-91) Summary
|
||||
|
||||
**A plugin now places fields and tabs inside another plugin's admin form from a fields.yaml-format document with before:/after:/zone: anchors and a tabs: list, compiled once at boot, and loads and saves the values itself inside the record's save transaction without touching the owner's model.**
|
||||
|
||||
## Task 1 answer (D-91 Go shape)
|
||||
|
||||
Answered by Jakub before dispatch: **yaml-document**. Recorded shape:
|
||||
|
||||
- `pact.AdminActionExtension` gains `Form *pact.AdminFormExtension` as its last field.
|
||||
- `pact.AdminFormExtension{Fields string; FieldsYAML []byte; Hide, Permissions []string; Visible func(ctx) bool; Dir string; Actions []pact.AdminAction; PartialData func(ctx, name, record) (any, error); Load func(ctx, pact.AdminFormLoad) (map[string]any, error); Save func(ctx, pact.AdminFormSave) (pact.AdminFormSaveResult, error)}`.
|
||||
- `Fields` is a path in the contributing plugin's AdminFS, resolved with `assetPath` exactly like `pact.SettingsItem.Form` and `config_form.yaml` `form:` (so `extensions/posts.yaml`, `$/vendor/plugin/...` and `~/plugins/vendor/plugin/...` work). `FieldsYAML` is the document itself, which is how a plugin generates fields at boot (D-104 per-type tabs). At most one may be set.
|
||||
- Document format: `fields:` (every fields.yaml key, plus `before:`, `after:`, `zone:` per field) and `tabs:` (a list of `name`, `before`, `after`, `zone`). The placement keys are taken out of each field node before the rest compiles through the same `decodeFieldMapping`/`compileFieldNode` path as an owner's fields.yaml.
|
||||
- Kept as planned: `AdminFormLoad{DB, Controller, Record, ID}`, `AdminFormSave{DB, Controller, Record, ID, Created, Values}`, `AdminFormSaveResult{Notices}`, `AdminFormErrors` (+`Error()`), `AdminFormZoneTabs/Outside/Secondary` (now the `zone:` values).
|
||||
- Not published: `pact.AdminFormTab` and `pact.AdminFormField`. In the yaml-document form, tabs and fields live in the document.
|
||||
- Plan 32-03 should use this shape instead of the go-placement sketch in its `<interfaces>`. `AdminFormField{Config}` becomes a `fields:` entry, and per-type tabs become a `FieldsYAML` document built at boot.
|
||||
|
||||
**Plan start SHA (phase base for scripts/check-phase32.sh in plan 32-05): `9868838fe3d01e07d578f2b2dd557d4296c48e10`**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 32 min
|
||||
- **Started:** 2026-10-26T20:34:49Z
|
||||
- **Completed:** 2026-10-26T21:07:01Z
|
||||
- **Tasks:** 4 (Task 1 resolved before dispatch)
|
||||
- **Files modified:** 17
|
||||
|
||||
## Accomplishments
|
||||
- Additive pact API for form extensions, with every boot error and runtime rule documented on the type
|
||||
- `compileFormExtensions` covers:
|
||||
- placement: field and tab anchors, end of tab, an anchored field joining its anchor's tab
|
||||
- plugin order through an anchor cursor
|
||||
- the `Requires()` rule for anchors on another plugin's additions, and cycle detection inside one document
|
||||
- Hide, with checks on fields that reference the hidden one
|
||||
- D-101 zones and D-100 fileupload refusal
|
||||
- regrouping only for forms an extension lays out
|
||||
- Owner-aware branches:
|
||||
- widget tags use the contributor's prefix and run the extension's own `Actions`
|
||||
- partials render from the contributor's `Dir` through `PartialData`
|
||||
- plugin field types run `Decode` before `Save` and their `Load` after the extension's
|
||||
- translatable values reach `Save`/`Load` as locale maps
|
||||
- ML and plugin owner paths skip extension fields
|
||||
- Save path:
|
||||
- extension keys leave the body before any owner path reads them
|
||||
- `Save` runs in the record's transaction after the owner row and its after hooks
|
||||
- `AdminFormErrors` answers 422; any other error is a 500. Both roll everything back
|
||||
- notices join `meta.notices`
|
||||
- Permissions/Visible apply to schema, show, save, widget actions and partials through one helper
|
||||
- Docs (admin-controllers section with synced snippet, cabana/pact READMEs, WinterCMS mapping), runnable example, SPA backstop tests
|
||||
|
||||
## Task Commits
|
||||
|
||||
1. **Task 1: Confirm the Go shape**: no commit (answered before dispatch: yaml-document)
|
||||
2. **Task 2: Tracer (c after a through the admin API)**: `0819442` (feat)
|
||||
3. **Task 3: Full placement rules, boot errors, owner-aware branches (TDD)**:
|
||||
- RED `4bb22a8` (test)
|
||||
- GREEN `e7423bd` (feat)
|
||||
4. **Task 4: Docs, example, SPA backstop**:
|
||||
- `fa1af69` (docs)
|
||||
- `9ae3269` (test)
|
||||
|
||||
Tracer feedback gate: interactive, end-of-phase mode, automated-only verify. It re-ran green (TestFormExtensionTracer, `go vet ./...`, `go test -short ./...`) before expanding.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
- RED `4bb22a8` before GREEN `e7423bd`.
|
||||
- RED evidence (TAP transcription of `go test -json`, target `TestFormExtensionBootErrors`): `RED_EVIDENCE_OK`. Failing in RED: Placement, TwoPluginsSameAnchor, BootErrors, WidgetsAndPartials.
|
||||
- `TestFormExtensionOnePluginTwoControllers` and `TestFormExtensionUnextendedSchemaUnchanged` already passed in RED. They guard invariants the tracer already met.
|
||||
- An initial RED run hit fixture errors (an owner model without the test's columns) and was fixed before the RED commit.
|
||||
- No REFACTOR commit.
|
||||
|
||||
## Files Created/Modified
|
||||
- `modules/pact/capabilities.go`: `Form` field, `AdminFormExtension` and the Load/Save/result/error types, zone constants
|
||||
- `modules/pact/README.md`: rows for each new type
|
||||
- `modules/cabana/form_extensions.go`: document parsing, placement layout, per-kind compile checks, tab-label check, permission validation, runtime (lift, Save, Load, visibility)
|
||||
- `modules/cabana/contracts.go`: `formExtensions`, `extensionFields`, `extensionPartials` on `CompiledController`
|
||||
- `modules/cabana/http.go`: wiring in Activate and the form schema filter
|
||||
- `modules/cabana/crud.go`: save and show wiring; `BindWritableFields` skips extension fields
|
||||
- `modules/cabana/actions.go`, `partial_render.go`: extension widget and partial dispatch
|
||||
- `modules/cabana/field_type.go`, `field_ml.go`: owner paths skip extension fields
|
||||
- Tests:
|
||||
- `form_extensions_smoke_test.go`, `form_extensions_postgres_test.go`
|
||||
- `example_form_extension_test.go`
|
||||
- `admin/tests/form/FormView.test.ts`
|
||||
- Docs: `docs/backend/admin-controllers.md`, `docs/setup/coming-from-wintercms.md`, `modules/cabana/README.md`
|
||||
|
||||
## Decisions Made
|
||||
See `key-decisions` in the frontmatter. The main one is the Task 1 yaml-document shape and its `Fields`/`FieldsYAML` declaration form, explained above.
|
||||
|
||||
## Acceptance-criteria adjustments (yaml-document form)
|
||||
- Task 2, `go doc ./modules/pact AdminFormExtension`: the plan expected `Tabs` and `Fields` struct fields.
|
||||
- Now prints `Fields, FieldsYAML, Hide, Permissions, Visible, Dir, Actions, PartialData, Load, Save`.
|
||||
- Tabs are a `tabs:` list in the document, not a struct field.
|
||||
- `grep "Form \*AdminFormExtension"`, the `compileFormExtensions` signature and its position before `compileActionExtensions`: unchanged, all pass.
|
||||
- Task 3 boot-error criterion (14 or more `--- PASS` subtests): 23 subtests pass.
|
||||
- The zone errors come from the document's `zone:` key, not a struct field.
|
||||
- Artifact `contains: "Form *AdminFormExtension"`: holds.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] `modules/cabana/contracts.go` modified (not in files_modified)**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** The extension-owned field registry has to live on `CompiledController`.
|
||||
- **Fix:** Added the unexported fields `formExtensions`, `extensionFields` and `extensionPartials`.
|
||||
- **Committed in:** `0819442`, `e7423bd`
|
||||
|
||||
**2. [Rule 3 - Blocking] The RED commit includes a no-op `checkFormExtensionTabLabels`**
|
||||
- **Found during:** Task 3 RED
|
||||
- **Issue:** The tab-label test needs the function to exist, or the build fails (INVALID_RED).
|
||||
- **Fix:** Declared it returning nil in the RED commit and implemented it in GREEN.
|
||||
- **Committed in:** `4bb22a8`
|
||||
|
||||
**3. [Rule 1 - Test fixture] Smoke owners use their own model, `feWide`; partial templates read `.Data`**
|
||||
- **Found during:** Task 3 RED and GREEN
|
||||
- **Fix:** Test-only changes.
|
||||
|
||||
**4. [Plan detail] The example lives in package `cabana` as `Example_formExtension`**
|
||||
- **Issue:** The compile path is unexported, so an external `cabana_test` example could not show the compiled order.
|
||||
- **Fix:** The docs snippet (`ExtrasPlugin.AdminActionExtensions`) is unaffected.
|
||||
|
||||
**5. [Plan detail] Commit split**
|
||||
- Task 3's compile pass and runtime share `form_extensions.go`, so GREEN is one feat commit instead of two.
|
||||
- The Task 4 docs commit carries the planned message ("... and pact READMEs"), but the pact README rows had already landed in the Task 2 commit, as the documentation rule requires.
|
||||
|
||||
**6. [Rule 2 - Missing critical] Permission codes of extensions and their widget actions are validated at boot**
|
||||
- **Fix:** Added `validateFormExtensionPermissions` after `compileContributions`, mirroring the controller checks.
|
||||
- **Committed in:** `e7423bd`
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 6 (2 blocking, 1 test fixture, 2 plan detail, 1 missing critical).
|
||||
**Impact on plan:** Behaviour is as planned; only the declaration form changed (Task 1). No scope creep.
|
||||
|
||||
## Issues Encountered
|
||||
None.
|
||||
|
||||
## Threat model
|
||||
- T-32-01 (extension values reaching the owner's model): mitigated. Values are lifted first, `BindWritableFields` skips extension fields, and ML/plugin owner paths skip them. Covered by TestFormExtensionTracer and TestFormExtensionSave.
|
||||
- T-32-02 (posted keys of an invisible extension): mitigated. `visibleExtensions` applies on schema, show, save, widgets and partials. Covered by TestFormExtensionSave and TestFormExtensionWidgetsAndPartials.
|
||||
- T-32-03 (partial disclosure): mitigated. `refusedViewModel` guards extension partials. Covered by TestFormExtensionWidgetsAndPartials (leak case).
|
||||
- T-32-SC: no packages installed.
|
||||
|
||||
## User Setup Required
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
- Plans 32-02 through 32-06 can build on the seam.
|
||||
- Plan 32-03 must use the yaml-document shape recorded above: the SEO tab is a `FieldsYAML` or `Fields` document with `tabs: [{name: golem15.seo::lang.tab.seo}]`, and the per-type settings tabs are `FieldsYAML` built at boot.
|
||||
- `AdminFormSave` has no `Changes` yet; plan 32-02 adds it.
|
||||
|
||||
## Self-Check: PASSED
|
||||
- All key files exist on disk, and commits 0819442, 4bb22a8, e7423bd, fa1af69 and 9ae3269 are present in `git log`.
|
||||
- Commands run green:
|
||||
- `go vet ./...` and `go test -short ./...`
|
||||
- `go test ./modules/cabana -count=1` (Docker), plus TestFormExtensionTracer and TestFormExtensionSave on their own
|
||||
- `docs:build --check` and `TestDocsTree`
|
||||
- the FormView tests and `typecheck`
|
||||
- `scripts/check-admin-openapi.sh --check`
|
||||
- `git diff --name-only 9868838..HEAD -- admin/src` is empty, and the D-90 grep finds nothing.
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-26*
|
||||
354
.planning/phases/32-seo-foundation/32-02-PLAN.md
Normal file
354
.planning/phases/32-seo-foundation/32-02-PLAN.md
Normal file
@@ -0,0 +1,354 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 02
|
||||
type: execute
|
||||
wave: 2
|
||||
depends_on: ["32-01"]
|
||||
files_modified:
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/record_events.go
|
||||
- modules/pact/content.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/record_events.go
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/reorder.go
|
||||
- modules/cabana/relation_child.go
|
||||
- modules/cabana/record_events_postgres_test.go
|
||||
- modules/cabana/README.md
|
||||
- modules/signpost/signpost.go
|
||||
- modules/signpost/content.go
|
||||
- modules/signpost/content_test.go
|
||||
- modules/signpost/README.md
|
||||
- docs/plugins/extending.md
|
||||
- docs/plugins/menu-item-types.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- ../sm-journal-plugin/classes/menu_item_types.go
|
||||
- ../sm-journal-plugin/classes/content_descriptors.go
|
||||
- ../sm-journal-plugin/controllers/api/posts.go
|
||||
- ../sm-journal-plugin/controllers/api/posts_helpers.go
|
||||
- ../sm-journal-plugin/lang/en/lang.yaml
|
||||
- ../sm-journal-plugin/lang/pl/lang.yaml
|
||||
- ../sm-journal-plugin/README.md
|
||||
- ../sm-journal-plugin/record_events_test.go
|
||||
- ../sm-journal-plugin/content_descriptors_test.go
|
||||
autonomous: false
|
||||
requirements: [SC-2, SC-3, D-92, D-93, D-96, D-102, D-58, D-90, D-18, D-20c, D-11]
|
||||
|
||||
estimate:
|
||||
tokens: 150000
|
||||
raw_tokens: 150000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A subscriber learns a record's new public URL after a slug change: cabana's admin save fires pact.RecordSaved after commit, and signpost's content descriptor for that model describes the record with the new per-locale URL (D-92, D-93, SC-3)"
|
||||
- "pact.RecordSaved carries the controller ID, the model's morph type, the record id, Created, the request content locale and the changed attributes with old and new values per locale; translated slugs appear as per-locale changes (D-92)"
|
||||
- "Record events fire after commit only: a rolled-back save fires nothing, and a listener error is logged and never fails the save (D-92)"
|
||||
- "cabana emits RecordSaved/RecordDeleted from create, update, delete, bulk delete, tree reorder and relation-manager child writes; plugin code that writes directly calls cabana.EmitRecordSaved/EmitRecordDeleted (D-92)"
|
||||
- "Journal's /_journal/api/v1 Store, Update and Destroy emit the same events, so a slug changed through MCP is visible to subscribers (D-102, SC-3)"
|
||||
- "pact.MenuItemType gains an optional Content descriptor (controller ID, model, Records, Describe, Match); a type without Content behaves exactly as before (D-93)"
|
||||
- "signpost lists content types, maps a controller ID or a model to its type, describes a record with the host's layered pattern, pages records, and matches a public path to a record with Exact false when a segment (category, locale prefix) does not match the record (D-93, D-11, D-20c)"
|
||||
- "Journal registers descriptors for journal-post, journal-category and the new journal-tag type and imports neither sm-seo-plugin nor sm-sitemap-plugin (D-93, D-96, D-102, SC-2)"
|
||||
- "Journal's post API and post descriptor resolve translated slugs for the request locale (D-58, D-96)"
|
||||
- "AdminFormSave carries the same Changes list, so an extension's Save sees a slug change inside the save transaction (D-92, D-91)"
|
||||
- "The framework change is strictly additive (D-106): new optional fields, new types and new functions only, and no method added to an existing interface; existing pact, cabana and signpost signatures and behaviour are unchanged, and journal, sitemap and the demo app build unchanged against it"
|
||||
prohibitions:
|
||||
- statement: "No breaking change to existing framework API: MenuItemType, AdminFormSave and every existing cabana and signpost function keep their signatures and behaviour; a plugin that registers no Content descriptor and no listener sees no difference"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "Content plugins never import sm-seo-plugin or sm-sitemap-plugin; the framework names no SEO concept and no consuming application (D-90, D-93)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "A record event must never fire for a write that did not commit"
|
||||
status: resolved
|
||||
verification: test
|
||||
artifacts:
|
||||
- path: "modules/pact/record_events.go"
|
||||
provides: "RecordChange, RecordSaved, RecordDeleted"
|
||||
contains: "type RecordSaved struct"
|
||||
- path: "modules/pact/content.go"
|
||||
provides: "ContentDescriptor and its request/result types"
|
||||
contains: "type ContentDescriptor struct"
|
||||
- path: "modules/cabana/record_events.go"
|
||||
provides: "EmitRecordSaved, EmitRecordDeleted and the save snapshot diff"
|
||||
contains: "func EmitRecordSaved("
|
||||
- path: "modules/signpost/content.go"
|
||||
provides: "ContentTypes, ContentType, ContentTypeForController, ContentTypeForModel, Describe, Records, MatchPath, MatchPattern"
|
||||
contains: "func (r *Registry) MatchPath("
|
||||
- path: "../sm-journal-plugin/classes/content_descriptors.go"
|
||||
provides: "post, category and tag descriptors"
|
||||
contains: "pact.ContentDescriptor"
|
||||
key_links:
|
||||
- from: "modules/cabana/crud.go"
|
||||
to: "modules/cabana/record_events.go"
|
||||
via: "CRUDService.save, Delete and BulkDelete register the event with lagoon.AfterCommit on the save transaction"
|
||||
pattern: "emitRecordSaved|EmitRecordSaved"
|
||||
- from: "../sm-journal-plugin/controllers/api/posts.go"
|
||||
to: "modules/cabana/record_events.go"
|
||||
via: "Store/Update/Destroy call cabana.EmitRecordSaved/EmitRecordDeleted next to purgeSiteCache"
|
||||
pattern: "cabana\\.EmitRecord(Saved|Deleted)"
|
||||
- from: "../sm-journal-plugin/classes/menu_item_types.go"
|
||||
to: "modules/pact/content.go"
|
||||
via: "Content: &pact.ContentDescriptor{...} on journal-post, journal-category, journal-tag"
|
||||
pattern: "Content: +&pact\\.ContentDescriptor"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan delivers the second and third framework seams and Journal's adoption: plugins hear about saved and deleted records, and content types describe their records and URLs.
|
||||
|
||||
<objective>
|
||||
Implement D-92 record events and D-93 content descriptors in the framework, and adopt them in Journal per D-96 and D-102:
|
||||
- pact gains `RecordChange`, `RecordSaved`, `RecordDeleted` (fired as pointers through `app.Events` after commit, like `pact.MCPSubjectChanged`), `AdminFormSave.Changes`, `MenuItemType.Content` and the `ContentDescriptor` types;
|
||||
- cabana emits the events from every admin write path and exports `EmitRecordSaved`/`EmitRecordDeleted` for direct writers;
|
||||
- signpost gains content-type lookups, `Describe`, `Records`, `MatchPath` and the pure `MatchPattern`;
|
||||
- Journal registers descriptors for posts, categories and a new `journal-tag` type, emits events from its `/_journal/api/v1` write handlers (D-102), and fixes the translated-slug lookup (D-58), the D-96 fix that belongs to Phase 32. D-96's H1 conversion (D-50) and schema types (D-43) are Phase 33 (see the boundary in plan 32-06).
|
||||
|
||||
Purpose: SC-3 needs a slug change from the admin, MCP or an import to reach the SEO plugin; SC-2 needs Journal posts, categories and tags to take part without importing sm-seo-plugin; D-11 and D-20c need a public path mapped to its record. The framework names no SEO concept (D-90).
|
||||
|
||||
Output: the pact types, `modules/cabana/record_events.go`, `modules/signpost/content.go`, docs, and the Journal changes committed in `../sm-journal-plugin` (branch main). Which plan implements each decision of the phase, and what Phase 33 takes, is in `32-DECISIONS-MAP.md`.
|
||||
|
||||
**Planner decisions recorded here (Claude's discretion: the exact Go shape, CONTEXT):**
|
||||
- **P-07 (event shape):** `type RecordChange struct { Attribute, Locale string; Old, New any }`; `type RecordSaved struct { Controller, Model, ID, Locale string; Created bool; Changes []RecordChange }`; `type RecordDeleted struct { Controller, Model, ID string }`. `Model` is `lagoon.MorphType(db, record)` (the attach.Owner morph name, else the table name), so the event and the descriptor agree. `ID` is the primary key as text. `Locale` is the request's content locale (towel). On create, `Changes` lists every written column with a nil Old. Fired and listened to as pointers (`app.Events.Listen("vendor.plugin", func(ctx, *pact.RecordSaved) error)`).
|
||||
- **P-08 (helpers):** `cabana.EmitRecordSaved(ctx context.Context, app *backpack.App, tx *gorm.DB, ev pact.RecordSaved)` and `cabana.EmitRecordDeleted(ctx, app, tx, ev pact.RecordDeleted)` register the firing with `lagoon.AfterCommit(ctx, tx, ...)`; with a nil tx they fire immediately. A nil app or bus is a no-op. A listener error is logged with `moduleLog.WarnContext` and never returned (the `fireSubjectChanged` rule).
|
||||
- **P-09 (descriptor shape):** `MenuItemType.Content *ContentDescriptor` (json:"-"); `type ContentDescriptor struct { Controller, Model string; Records func(ctx, ContentList) (ContentPage, error); Describe func(ctx, ContentDescribe) (*ContentRecord, error); Match func(ctx, ContentMatch) (*ContentMatchResult, error) }`; `ContentList{Pattern, After, UnprefixedLocale string; Limit int}`; `ContentPage{Records []ContentRecord; Next string}`; `ContentDescribe{ID, Pattern, UnprefixedLocale string}`; `ContentRecord{ID string; Published bool; LastMod *time.Time; Locales []ContentLocale}`; `ContentLocale{Locale, URL, Title, Description, Image string; Words *int}` (URL "" when the locale or the host has no public page); `ContentMatch{Path, Pattern, UnprefixedLocale string}`; `ContentMatchResult{ID, Locale string; Exact bool}`. `Model` is required and `Describe` is required when `Content` is set; `Records` and `Match` are optional; two types with the same `Content.Model` or `Content.Controller` stop the boot. Descriptor funcs read through `cabana.TxFromContext(ctx)` when a transaction is in ctx, so an extension's Save sees the new slug.
|
||||
- **P-10 (signpost API):** `(*Registry).ContentTypes() []pact.MenuItemType` (registration order), `ContentType(key)`, `ContentTypeForController(id)`, `ContentTypeForModel(model)` (each `(pact.MenuItemType, bool)`), `Describe(ctx, key, id, unprefixedLocale string) (*pact.ContentRecord, error)` and `Records(ctx, key, after string, limit int, unprefixedLocale string) (pact.ContentPage, error)` (both layer the host's pattern override), `MatchPath(ctx, path, unprefixedLocale string) (key string, res *pact.ContentMatchResult, err error)` (types in registration order; the first Exact match wins, else the first non-exact match), and the pure `signpost.MatchPattern(pattern, path string) (map[string]string, bool)` content types use to read placeholder values.
|
||||
- **P-11 (tags):** `journal-tag` with `DefaultPattern "/blog/tag/:slug"` (the vue-journal-layer default route), placeholders `:slug`, `:id`. A host whose site has no tag pages sets the config key `golem15.journal.tag_pages: false` (default true): tag descriptors then answer an empty URL and tag paths never match (RESEARCH Pitfall 9).
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-RESEARCH.md
|
||||
@.planning/phases/32-seo-foundation/32-PATTERNS.md
|
||||
@.planning/phases/32-seo-foundation/32-01-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
@modules/pact/capabilities.go
|
||||
@modules/cabana/subject_events.go
|
||||
@modules/signpost/signpost.go
|
||||
|
||||
<interfaces>
|
||||
From modules/cabana/subject_events.go (lines 25-44): fireSubjectChanged(ctx, app, kind, adminIDs...) — nil app/bus no-op; tx, _ := TxFromContext(ctx); lagoon.AfterCommit(ctx, tx, func(ctx, _ *gorm.DB){ event := &pact.MCPSubjectChanged{...}; if err := app.Events.Fire(ctx, event); err != nil { moduleLog.WarnContext(...) } }).
|
||||
From modules/lagoon/transaction.go: func AfterCommit(ctx context.Context, db *gorm.DB, fn func(ctx context.Context, db *gorm.DB)) — inside a transaction it runs after commit and never after rollback; anywhere else fn runs immediately.
|
||||
From modules/lagoon/deferred.go: func MorphType(db *gorm.DB, model any) (string, error).
|
||||
From modules/festival/bus.go: func (b *Bus) Listen[T any](owner string, fn func(context.Context, T) error); func (b *Bus) Fire[T any](ctx context.Context, event T) error — synchronous.
|
||||
From modules/signpost/signpost.go: Registry; Activate[P](app, plugins) (40); add(owner, t) validation (68-89, message shape "signpost: menu item type %q of plugin %s has no Resolve"); Types() (132); Type(key) (140); Pattern(key, itemOverride) (161); Resolve(ctx, key, reference, itemPattern, nesting, unprefixedLocale) (200).
|
||||
From modules/pact/capabilities.go: MenuItemType (798-808) with func fields tagged json:"-"; MenuItemResolve; ResolvedMenuItem.Alternates.
|
||||
From ../sm-journal-plugin/classes/menu_item_types.go: MenuType* key consts (21-27), label consts (30-35), DefaultPostPattern "/blog/:slug", DefaultCategoryPattern "/blog/category/:slug", postPlaceholders [":slug", ":category", ":id", ":year", ":month", ":day"], menuTypes{app} methods resolvePost (194), resolveCategory (472), loadMenuLocales(ctx, db, unprefixed) (655).
|
||||
From ../sm-journal-plugin/controllers/api/posts.go: Store/Update/Destroy call purgeSiteCache(r, app, post) → cooler.PurgeSiteCacheAfterCommit(r.Context(), nil, ...) (~400); applyPostUpdate (~268).
|
||||
From ../sm-journal-plugin/controllers/api/posts_helpers.go: findPostBySlugOrID(db, slug) (55) matches only the default-locale slug, then a numeric id.
|
||||
From ../sm-journal-plugin/models/post.go: Translatable() includes "slug", TranslatableIndexes() {"slug"}; MorphName() `Golem15\Journal\Models\Post`.
|
||||
Controller IDs: golem15.journal.posts, golem15.journal.categories, golem15.journal.tags.
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking">
|
||||
<name>Task 1: Confirm the Go shapes of the D-92 record events and the D-93 content descriptors (published framework API)</name>
|
||||
<decision>Do P-07 to P-10 become the published shapes of the record events (D-92) and the content descriptors (D-93)?</decision>
|
||||
<context>Both seams are confirmed decisions; their Go shapes are Claude's discretion and become framework API at the phase's release tag. D-92 is costly to change (subscribers in shared plugins depend on the event shape) and D-93 is costly (every content plugin implements the functions). The shapes are written out in this plan's objective (P-07 event types and helpers, P-09 descriptor types, P-10 signpost functions); everything is additive (new types, a new optional MenuItemType field, a new AdminFormSave field).</context>
|
||||
<options>
|
||||
<option id="as-planned">
|
||||
<name>Adopt P-07 to P-10 as written</name>
|
||||
<pros>Event Model equals the morph type the descriptor declares, so mapping an event to its content type is one lookup; descriptors read the save transaction from ctx, so an extension's Save sees the new URL inside the same transaction; MatchPath gives D-11 ownership and D-20c strict URLs one entry point</pros>
|
||||
<cons>Match is a fourth descriptor function beyond D-93's list (records, lastmod, published, defaults); it is optional</cons>
|
||||
</option>
|
||||
<option id="no-match">
|
||||
<name>As planned without Match/MatchPath; the SEO plugin matches paths by enumerating Records</name>
|
||||
<pros>Smaller published surface</pros>
|
||||
<cons>Strict URLs and URL ownership need a full record scan or a URL index kept by the SEO plugin; translated slugs and category segments are harder to check</cons>
|
||||
</option>
|
||||
<option id="amend">
|
||||
<name>As planned with Jakub's renames or additions</name>
|
||||
<pros>Names fixed before publication</pros>
|
||||
<cons>The executor applies the amendments to every task</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer as-planned, no-match, or amend with the changes; the executor records the answer in 32-02-SUMMARY.md</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 2: End-to-end "a Journal post's slug changes in the admin, a subscriber gets RecordSaved and describes the new URL" — one path only</name>
|
||||
<reversibility rating="costly">Subscribers in shared plugins depend on the event shape and every content plugin implements the descriptor functions (D-92, D-93).</reversibility>
|
||||
<files>modules/pact/record_events.go, modules/pact/content.go, modules/pact/capabilities.go, modules/pact/README.md, modules/cabana/record_events.go, modules/cabana/crud.go, modules/cabana/README.md, modules/signpost/content.go, modules/signpost/signpost.go, modules/signpost/README.md, ../sm-journal-plugin/classes/content_descriptors.go, ../sm-journal-plugin/classes/menu_item_types.go, ../sm-journal-plugin/record_events_test.go</files>
|
||||
<read_first>
|
||||
- modules/cabana/subject_events.go (whole file)
|
||||
- modules/cabana/crud.go (save 736-944: loadRecord, Fill, tx.Save/Create, applyMLTranslations; the extension Save call added in plan 32-01)
|
||||
- modules/lagoon/transaction.go (AfterCommit 95-130) and modules/lagoon/deferred.go (MorphType)
|
||||
- modules/signpost/signpost.go (whole file, 240 lines)
|
||||
- modules/pact/capabilities.go (MenuItemType 782-860; AdminFormSave from plan 32-01)
|
||||
- ../sm-journal-plugin/classes/menu_item_types.go (19-160, resolvePost 194-272, loadMenuLocales 655)
|
||||
- ../sm-journal-plugin/admin_harness_test.go (how Journal tests drive cabana over HTTP with Postgres)
|
||||
- The Task 1 answer recorded by the executor
|
||||
</read_first>
|
||||
<action>
|
||||
Apply the Task 1 answer (the text assumes as-planned). Per D-92 and D-93:
|
||||
1. pact: `record_events.go` with RecordChange, RecordSaved, RecordDeleted and doc comments stating after-commit, pointer firing, the Model/ID conventions (P-07); `content.go` with the P-09 types; in `capabilities.go` add `Content *ContentDescriptor` with `json:"-"` as the last field of `MenuItemType` and `Changes []RecordChange` as the last field of `AdminFormSave`, extending their doc comments.
|
||||
2. cabana `record_events.go`: `EmitRecordSaved`, `EmitRecordDeleted` (P-08) and an unexported `recordSnapshot` that captures host column values after `loadRecord` and before Fill. In `crud.go` save (update path only for the tracer): diff the snapshot against the saved row, build `Changes`, fill `AdminFormSave.Changes` before extension Save calls, and call `EmitRecordSaved(ctx, app, tx, pact.RecordSaved{Controller: controllerID(cc), Model: morph type, ID, Locale, Created, Changes})` after the write inside the transaction (it fires after commit).
|
||||
3. signpost `content.go`: `ContentTypes`, `ContentTypeForModel`, `Describe` (layering the pattern through `Pattern(key, "")`); in `signpost.go` `add` validate `Content` (Model required, Describe required). Remaining P-10 functions come in Task 4.
|
||||
4. Journal: `classes/content_descriptors.go` with the post descriptor (`Controller: controllers.PostsControllerID` value "golem15.journal.posts" — use the literal or a const in classes to avoid an import cycle; `Model` = the Post morph name; `Describe` returning per-locale URL built exactly as resolvePost builds alternates, title, plain-text excerpt as Description, featured image URL as Image, body word count as Words, Published, LastMod = updated_at), reading through `cabana.TxFromContext(ctx)` when present; set `Content:` on the journal-post entry in `menu_item_types.go`.
|
||||
5. Tracer test `TestRecordSavedDescribesNewURL` in `../sm-journal-plugin/record_events_test.go` (Postgres, Journal's admin harness): register a listener for `*pact.RecordSaved`; PUT a post with a new slug through the admin API; the listener receives exactly one event with Controller "golem15.journal.posts", Model equal to the Post morph name, a slug change old → new, and `signpost` `ContentTypeForModel(ev.Model)` + `Describe` return the new URL "/blog/<new-slug>"; a second PUT that the test forces to fail validation fires no event.
|
||||
6. Docs in the same commits (documentation rule): pact README entries; cabana README "Record events" bullet; signpost README "Content descriptors" usage. Framework commit first (`feat(32-02): record events and content descriptors (tracer)`), then the Journal commit in `../sm-journal-plugin` (`feat: post content descriptor`), both staged by path with `git -c safe.directory='*'` in the sibling repo.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-journal-plugin test ./... -run 'TestRecordSavedDescribesNewURL' -count=1 -v 2>&1 | tail -20</automated>
|
||||
<fails_when>non-zero exit, "FAIL" or "no tests to run" in the output, or no "--- PASS: TestRecordSavedDescribesNewURL" line</fails_when>
|
||||
<automated>go vet ./... && go test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "Content \*ContentDescriptor" modules/pact/capabilities.go` and `grep -n "Changes \[\]RecordChange" modules/pact/capabilities.go` each print one line
|
||||
- `grep -n "func EmitRecordSaved(ctx context.Context, app \*backpack.App, tx \*gorm.DB, ev pact.RecordSaved)" modules/cabana/record_events.go` prints one line
|
||||
- `grep -n "lagoon.AfterCommit" modules/cabana/record_events.go` prints at least one line
|
||||
- `go -C ../sm-journal-plugin test ./... -run TestRecordSavedDescribesNewURL -count=1` passes, including the no-event-on-failed-save assertion
|
||||
- `grep -rn "sm-seo-plugin\|sm-sitemap-plugin" ../sm-journal-plugin --include=*.go` prints nothing
|
||||
</acceptance_criteria>
|
||||
<done>An admin slug change on a Journal post reaches a subscriber after commit and the subscriber reads the new URL through signpost, with no event on a failed save; committed in both repos with docs.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Every emission point, translated-slug changes, the direct-writer helpers and Journal's API emission (D-92, D-102)</name>
|
||||
<files>modules/cabana/record_events.go, modules/cabana/crud.go, modules/cabana/reorder.go, modules/cabana/relation_child.go, modules/cabana/record_events_postgres_test.go, modules/cabana/README.md, docs/plugins/extending.md, docs/backend/admin-controllers.md, ../sm-journal-plugin/controllers/api/posts.go, ../sm-journal-plugin/record_events_test.go, ../sm-journal-plugin/README.md</files>
|
||||
<read_first>
|
||||
- modules/cabana/crud.go (Delete 287, BulkDelete 331, BulkAction 393, save create path, applyMLTranslations call)
|
||||
- modules/cabana/field_ml.go (liftMLValues 68, applyMLTranslations 163; TranslationWriter in field_ml.go 31-33)
|
||||
- modules/cabana/reorder.go (reorderPost) and modules/cabana/relation_child.go (child create/update/delete)
|
||||
- modules/cabana/subject_events_test.go (TestFireSubjectChangedWaitsForCommit pattern)
|
||||
- docs/plugins/extending.md (Events section, line 11; Model hooks section, line 62)
|
||||
- ../sm-journal-plugin/controllers/api/posts.go (Store, Update, Destroy, purgeSiteCache call sites, applyPostUpdate)
|
||||
- ../sm-journal-plugin/journal_api_writes_test.go (API write test harness)
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Pattern 2, Pitfalls 8 and 12)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- Create through cabana: one RecordSaved with Created true and the written columns as Changes (Old nil)
|
||||
- Update changing a translated slug in locale pl only: Changes holds {Attribute "slug", Locale "pl", Old, New}, read with TranslatedExact before applyMLTranslations
|
||||
- Update that changes nothing: RecordSaved still fires with an empty Changes list (subscribers re-check URLs)
|
||||
- Delete and each row of a bulk delete: one RecordDeleted per record, after commit
|
||||
- Tree reorder changing parent_id: RecordSaved with a parent_id change; relation-manager child create/update/delete: events for the child's controller
|
||||
- Rollback (validation error, extension Save error, FormBefore* error): no event
|
||||
- A listener returning an error: the save answers 200 and the warning is logged
|
||||
- Journal PUT /_journal/api/v1/posts/{id} changing the slug: one RecordSaved with Controller "", Model the Post morph name and the slug change; POST: Created true; DELETE: RecordDeleted
|
||||
</behavior>
|
||||
<action>
|
||||
Complete D-92 per the behaviour list. In cabana add the remaining emission points (create path of save, Delete, BulkDelete, reorderPost, relation-manager child writes) through one unexported `emitRecordSaved/emitRecordDeleted` that wraps the exported helpers; per-locale old values come from the TranslationWriter's exact read for submitted ML fields before `applyMLTranslations` (RESEARCH Pitfall 12). Journal per D-102: in `controllers/api/posts.go` capture the old slug (default locale and any submitted locale) before `applyPostUpdate`, then call `cabana.EmitRecordSaved(r.Context(), app, nil, ...)` / `cabana.EmitRecordDeleted` next to `purgeSiteCache` in Store, Update and Destroy (the writes are committed when the helper runs, so a nil tx fires at once).
|
||||
Tests first: `TestRecordEvents` in `modules/cabana/record_events_postgres_test.go` (create, update, translated slug, no-op update, delete, bulk delete, reorder, child write, rollback cases, failing listener) and `TestAPIRecordEvents` in `../sm-journal-plugin/record_events_test.go` (POST, PUT slug change, DELETE). Docs: `docs/plugins/extending.md` "Record events" subsection under Events (listening with `app.Events.Listen` and the pointer types, after-commit, the emit helpers for direct writers, why GORM hooks on another plugin's model are not the way); `docs/backend/admin-controllers.md` notes which admin operations emit; cabana README API table rows for the two helpers; Journal README notes that its API emits record events.
|
||||
Framework commit(s) first, then the Journal commit, staged by path.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test ./modules/cabana -run 'TestRecordEvents' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -30</automated>
|
||||
<fails_when>a "--- FAIL" or "FAIL" line, "no tests to run", or no "--- PASS: TestRecordEvents" line</fails_when>
|
||||
<automated>go -C ../sm-journal-plugin test ./... -run 'TestAPIRecordEvents|TestRecordSavedDescribesNewURL' -count=1 2>&1 | tail -5</automated>
|
||||
<fails_when>non-zero exit or "FAIL" in the output</fails_when>
|
||||
<automated>go test ./cmd/summer -run TestDocsTree -count=1 && go run ./cmd/summer docs:build --check</automated>
|
||||
<fails_when>non-zero exit, or docs:build reporting an unknown identifier or broken link</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `go test ./modules/cabana -run TestRecordEvents -v` shows passing subtests for create, update, translated slug, delete, bulk delete, reorder, child write, rollback and failing listener
|
||||
- `grep -c "cabana.EmitRecord" ../sm-journal-plugin/controllers/api/posts.go` prints 3 or more
|
||||
- `grep -n "Record events" docs/plugins/extending.md` prints a heading line
|
||||
- `go vet ./... && go test -short ./...` exits 0 in the framework and `go -C ../sm-journal-plugin vet ./...` exits 0
|
||||
</acceptance_criteria>
|
||||
<done>Every cabana write path and Journal's API emit after-commit record events with per-locale old and new values; direct writers have documented helpers.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 4: Complete descriptors in signpost and Journal: categories, the journal-tag type, Records, Match/MatchPath with strict segments, translated slugs (D-93, D-58)</name>
|
||||
<files>modules/signpost/content.go, modules/signpost/signpost.go, modules/signpost/content_test.go, modules/signpost/README.md, modules/pact/README.md, docs/plugins/menu-item-types.md, ../sm-journal-plugin/classes/content_descriptors.go, ../sm-journal-plugin/classes/menu_item_types.go, ../sm-journal-plugin/controllers/api/posts_helpers.go, ../sm-journal-plugin/lang/en/lang.yaml, ../sm-journal-plugin/lang/pl/lang.yaml, ../sm-journal-plugin/content_descriptors_test.go, ../sm-journal-plugin/README.md</files>
|
||||
<read_first>
|
||||
- modules/signpost/signpost.go and modules/signpost/content.go (Task 2)
|
||||
- modules/signpost/signpost_test.go (fixture style)
|
||||
- docs/plugins/menu-item-types.md (Registering types, Resolving an item, URL patterns)
|
||||
- ../sm-journal-plugin/classes/menu_item_types.go (categoryReferences 406, resolveCategory 472, postPlaceholders 55)
|
||||
- ../sm-journal-plugin/controllers/api/posts_helpers.go (findPostBySlugOrID 55-75) and ../sm-journal-plugin/models/post.go (Translatable, TranslatableIndexes)
|
||||
- ../sm-journal-plugin/models/tag.go and models/tag/fields.yaml; controllers/tags.go (TagsControllerID)
|
||||
- ../sm-journal-plugin/menu_item_types_test.go
|
||||
- ../vue-journal-layer/app/utils/routes.ts (tag route default '/blog/tag/:tag')
|
||||
</read_first>
|
||||
<behavior>
|
||||
- signpost: a type without Content is absent from ContentTypes and resolves exactly as before; Content without Model or without Describe stops the boot naming the type and plugin; two types with the same Content.Model or Content.Controller stop the boot
|
||||
- MatchPattern("/blog/:slug", "/blog/hello") = {slug: hello}, true; MatchPattern("/:category/:slug", "/news/hello") = {category: news, slug: hello}; a path with an extra segment does not match; a pattern placeholder never matches an empty segment
|
||||
- MatchPath returns the first Exact match in registration order, else the first non-exact one, else no match
|
||||
- Journal post Match: /blog/<slug> → Exact true; with pattern /:category/:slug, a wrong category for an existing post → Exact false and the post's ID; an unpublished post → no match; /pl/blog/<pl-slug> with pl prefixed → Locale pl, Exact true; the default-locale slug under the pl prefix → Exact false
|
||||
- journal-tag: References lists tags, Resolve returns /blog/tag/<slug>, Describe and Match work; with golem15.journal.tag_pages false Describe returns empty URLs and Match never matches
|
||||
- Categories: descriptor with Controller golem15.journal.categories and Describe/Match/Records
|
||||
- D-58: GET /_journal/api/v1/posts/<translated-slug> with the request locale set resolves the post; the default-locale slug still resolves; an unknown slug still answers 404
|
||||
</behavior>
|
||||
<action>
|
||||
Finish P-10 in signpost (`ContentType`, `ContentTypeForController`, `Records`, `MatchPath`, `MatchPattern`, duplicate Model/Controller checks in `add`/`Activate`) and write `TestContent*` cases in `modules/signpost/content_test.go`. In Journal (D-93, D-96, D-102, D-58): category descriptor; the new `MenuTypeTag = "journal-tag"` const, its label const `golem15.journal::lang.menuitem.journal_tag` with en "Journal tag" and pl "Tag bloga" in the lang files, `DefaultTagPattern = "/blog/tag/:slug"`, tag References/Resolve, and its descriptor with `Controller "golem15.journal.tags"` (P-11, config key `golem15.journal.tag_pages`); `Records` for all three (id order, `After` as the last id, `Limit` capped at 500); `Match` for all three using `signpost.MatchPattern` after stripping a locale prefix for the locales `loadMenuLocales` returns, comparing every placeholder segment (category of the post as resolvePost chooses it, year/month/day, id) and the locale prefix with the record (D-20c); translated slugs matched through the translate plugin's attribute rows for the matched locale. D-58: `findPostBySlugOrID` takes the request locale and, after the default slug, matches the translated slug of that locale (published posts only, as today); update its callers.
|
||||
Docs: `docs/plugins/menu-item-types.md` gains "Content descriptors" (what each function returns, the tx-from-ctx rule, MatchPattern, Exact semantics, a type with no public pages answering empty URLs) with neutral names; signpost and pact READMEs; Journal README lists the descriptors, journal-tag and tag_pages. Framework commit first, then Journal commits (descriptors + journal-tag; D-58 fix as its own commit `fix: resolve translated post slugs (D-58)`).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test -short ./modules/signpost ./modules/pact -run 'TestContent' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -20</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or no "--- PASS: TestContent" line</fails_when>
|
||||
<automated>go -C ../sm-journal-plugin test ./... -run 'TestContentDescriptors|TestJournalTagType|TestTranslatedSlug' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -20</automated>
|
||||
<fails_when>non-zero exit, a "FAIL" line, or any of TestContentDescriptors, TestJournalTagType, TestTranslatedSlug missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output (the whole Journal suite, including its existing menu and API tests, must stay green)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "func MatchPattern(pattern, path string) (map\[string\]string, bool)" modules/signpost/content.go` prints one line
|
||||
- `grep -n "\"journal-tag\"" ../sm-journal-plugin/classes/menu_item_types.go` prints one line
|
||||
- `grep -c "Content: *&pact.ContentDescriptor" ../sm-journal-plugin/classes/menu_item_types.go` prints 3
|
||||
- `grep -n "journal_tag" ../sm-journal-plugin/lang/en/lang.yaml ../sm-journal-plugin/lang/pl/lang.yaml` prints a line in each file
|
||||
- `grep -n "Content descriptors" docs/plugins/menu-item-types.md` prints a heading line; `go run ./cmd/summer docs:build --check` exits 0
|
||||
- `go -C ../sm-sitemap-plugin build ./... && go -C ../sm-sitemap-plugin test -short ./...` exits 0 with no change in sm-sitemap-plugin (existing consumer unchanged)
|
||||
</acceptance_criteria>
|
||||
<done>signpost exposes content types, descriptions, paging and strict path matching; Journal posts, categories and tags take part through descriptors without importing any SEO or sitemap plugin, translated slugs resolve, and existing consumers build unchanged.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| public path → descriptor Match | an anonymous visitor's URL segments reach content plugins' queries through MatchPath (used by the public resolver in plan 32-03/04) |
|
||||
| MCP/API client → Journal write handlers → event subscribers | writes made outside cabana now notify other plugins |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-05 | Denial of service | cabana save with a failing listener | medium | mitigate | Listener errors are logged, never returned; the save answers normally (TestRecordEvents failing-listener case) |
|
||||
| T-32-06 | Tampering | events for rolled-back writes | high | mitigate | Emission through lagoon.AfterCommit on the save transaction; rollback cases in TestRecordEvents assert no event |
|
||||
| T-32-07 | Tampering | descriptor Match with visitor-supplied segments | high | mitigate | Placeholder values are bound as query parameters (GORM Where with ?), never concatenated; MatchPattern refuses empty segments and extra segments |
|
||||
| T-32-08 | Information disclosure | Match/Describe and the D-58 slug lookup on drafts | high | mitigate | Match answers no match for unpublished records and findPostBySlugOrID keeps its published-only scope for anonymous callers; covered by TestContentDescriptors and TestTranslatedSlug |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | No package is installed by this plan |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- Framework: `go vet ./... && go test -short ./...` at every commit; `go test ./modules/cabana -run TestRecordEvents -count=1` (Docker); `go test -short ./modules/signpost -count=1`; docs checker green.
|
||||
- Journal: `go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 ./...` (Docker) green.
|
||||
- sm-sitemap-plugin builds and tests unchanged against the framework checkout.
|
||||
- `grep -rn "sm-seo-plugin" ../sm-journal-plugin --include=*.go` empty.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
A slug change from the admin or the Journal API reaches subscribers after commit with old and new values; Journal posts, categories and tags are described and matched through signpost without importing any SEO plugin; the change is strictly additive.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 02)
|
||||
|
||||
- `pact.RecordChange`, `pact.RecordSaved`, `pact.RecordDeleted` (`modules/pact/record_events.go`)
|
||||
- `pact.ContentDescriptor`, `pact.ContentList`, `pact.ContentPage`, `pact.ContentDescribe`, `pact.ContentRecord`, `pact.ContentLocale`, `pact.ContentMatch`, `pact.ContentMatchResult` (`modules/pact/content.go`)
|
||||
- New fields `pact.MenuItemType.Content`, `pact.AdminFormSave.Changes`
|
||||
- `cabana.EmitRecordSaved`, `cabana.EmitRecordDeleted` (`modules/cabana/record_events.go`)
|
||||
- `signpost.(*Registry).ContentTypes`, `ContentType`, `ContentTypeForController`, `ContentTypeForModel`, `Describe`, `Records`, `MatchPath`; `signpost.MatchPattern` (`modules/signpost/content.go`)
|
||||
- Journal: `classes/content_descriptors.go`, `MenuTypeTag` (`journal-tag`), `DefaultTagPattern`, config key `golem15.journal.tag_pages`, phrase `golem15.journal::lang.menuitem.journal_tag`, translated-slug lookup in `findPostBySlugOrID`
|
||||
- Tests: `TestRecordSavedDescribesNewURL`, `TestRecordEvents`, `TestAPIRecordEvents`, `TestContent*` (signpost), `TestContentDescriptors`, `TestJournalTagType`, `TestTranslatedSlug`
|
||||
- Docs: "Record events" in `docs/plugins/extending.md`, "Content descriptors" in `docs/plugins/menu-item-types.md`
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-02-SUMMARY.md` when done, with the Task 1 answer and every commit SHA in both repositories (the Journal commits are needed by plan 32-05's demo submodule move and plan 32-06's release).
|
||||
</output>
|
||||
294
.planning/phases/32-seo-foundation/32-02-SUMMARY.md
Normal file
294
.planning/phases/32-seo-foundation/32-02-SUMMARY.md
Normal file
@@ -0,0 +1,294 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 02
|
||||
subsystem: framework-seams
|
||||
tags: [pact, cabana, signpost, record-events, content-descriptors, d-92, d-93, journal]
|
||||
|
||||
requires:
|
||||
- phase: 32-01
|
||||
provides: pact.AdminFormSave and the form extension Save in the record's save transaction (D-91)
|
||||
provides:
|
||||
- "pact.RecordChange, pact.RecordSaved, pact.RecordDeleted fired as pointers on app.Events after commit (D-92)"
|
||||
- "pact.AdminFormSave.Changes: an extension's Save sees the owner's changes inside the save transaction"
|
||||
- "cabana.EmitRecordSaved / cabana.EmitRecordDeleted for direct writers; cabana emits from create, update, delete, bulk delete, tree reorder and relation-manager child writes"
|
||||
- "pact.ContentDescriptor (+ ContentList, ContentPage, ContentDescribe, ContentRecord, ContentLocale, ContentMatch, ContentMatchResult) and pact.MenuItemType.Content (D-93)"
|
||||
- "signpost: ContentTypes, ContentType, ContentTypeForController, ContentTypeForModel, Describe, Records, MatchPath and the pure MatchPattern; duplicate Model/Controller and missing Model/Describe stop the boot"
|
||||
- "Journal (sm-journal-plugin): descriptors for journal-post, journal-category and the new journal-tag type, record events from /_journal/api/v1 Store/Update/Destroy (D-102), translated-slug lookup (D-58), host key golem15.journal.tag_pages"
|
||||
affects: [32-03, 32-04, 32-05, 32-06, sm-seo-plugin, sm-sitemap-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 35953
|
||||
tasks: 4
|
||||
commits: 3
|
||||
plan_head_before: 1b0421de814404d4bf904a754bf997badfd4349c
|
||||
plan_head_after: 785902c612228bdf1bc0392fff05a1cbbd84a59f
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Record events: snapshot the row (GORM schema columns minus PK and auto timestamps) plus TranslatedExact of submitted ML fields before the write, diff after, emit through lagoon.AfterCommit"
|
||||
- "Content descriptors read through cabana.TxFromContext when a write transaction is in ctx"
|
||||
- "Strict URL matching: read the locale prefix, MatchPattern the rest, find the record, compare the path with the record's own alternate URL (exact) else inexact"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- modules/pact/record_events.go
|
||||
- modules/pact/content.go
|
||||
- modules/cabana/record_events.go
|
||||
- modules/cabana/record_events_postgres_test.go
|
||||
- modules/cabana/example_record_events_test.go
|
||||
- modules/signpost/content.go
|
||||
- modules/signpost/content_test.go
|
||||
- modules/signpost/example_content_test.go
|
||||
- ../sm-journal-plugin/classes/content_descriptors.go
|
||||
- ../sm-journal-plugin/controllers/api/record_events.go
|
||||
- ../sm-journal-plugin/record_events_test.go
|
||||
- ../sm-journal-plugin/content_descriptors_test.go
|
||||
- ../sm-journal-plugin/translated_slug_test.go
|
||||
modified:
|
||||
- modules/pact/capabilities.go
|
||||
- modules/pact/README.md
|
||||
- modules/cabana/crud.go
|
||||
- modules/cabana/form_extensions.go
|
||||
- modules/cabana/http.go
|
||||
- modules/cabana/relation.go
|
||||
- modules/cabana/relation_child.go
|
||||
- modules/cabana/reorder.go
|
||||
- modules/cabana/README.md
|
||||
- modules/signpost/signpost.go
|
||||
- modules/signpost/README.md
|
||||
- docs/plugins/extending.md
|
||||
- docs/plugins/menu-item-types.md
|
||||
- docs/backend/admin-controllers.md
|
||||
- ../sm-journal-plugin/classes/menu_item_types.go
|
||||
- ../sm-journal-plugin/classes/menu_item_types_test.go
|
||||
- ../sm-journal-plugin/controllers/api/posts.go
|
||||
- ../sm-journal-plugin/controllers/api/posts_helpers.go
|
||||
- ../sm-journal-plugin/lang/en/lang.yaml
|
||||
- ../sm-journal-plugin/lang/pl/lang.yaml
|
||||
- ../sm-journal-plugin/README.md
|
||||
|
||||
key-decisions:
|
||||
- "Task 1 (D-92/D-93 Go shapes), answered by Jakub before dispatch: as-planned. P-07 to P-10 are published as written, including the optional Match and signpost.MatchPath"
|
||||
- "RecordChange.Locale is \"\" for the record's own row (the default locale of a translatable field) and the locale code for a translated value; values are dereferenced (nil pointer -> nil) and times compare as instants"
|
||||
- "Changes leave out the primary key and GORM auto timestamps, so a no-op update fires RecordSaved with an empty Changes list; on create they list every column with a non-zero value and every non-empty submitted translation, Old nil"
|
||||
- "Reorder fires one RecordSaved per moved node only (parent and/or sort column changed), values converted to the model's column types"
|
||||
- "Relation-manager child events name the one admin controller whose NewRecord type is the child's model (\"\" when none or several); API and other direct writes carry Controller \"\""
|
||||
- "signpost.Registry.Records answers an empty page for a content type without Records; MatchPath returns the first exact match in registration order, else the first inexact one; a Match error is returned prefixed signpost:"
|
||||
- "signpost.MatchPattern matches whole segments only; a placeholder never matches an empty segment; a placeholder used twice must match the same value; segments are compared as given (caller decodes)"
|
||||
- "Journal descriptors describe drafts too (Published false); Records page in id order capped at 500; Match never matches drafts/future posts and is exact only on the record's own URL in the path's locale"
|
||||
- "journal-tag with golem15.journal.tag_pages false: Describe answers empty URLs, Match never matches and Resolve resolves to nothing"
|
||||
- "D-58: findPostBySlugOrID(db, slug, locale) tries the default slug, then translate's slug index for the request locale (towel, first language without region), then the id"
|
||||
|
||||
patterns-established:
|
||||
- "cabana.EmitRecordSaved(ctx, app, tx, ev): tx = the write's lagoon.Transaction handle, or nil after commit (fires at once)"
|
||||
- "A content type's Match: signpost.MatchPattern on the path without its locale prefix, find by slug-in-locale/default slug/other-locale slug/id, exact iff path == own alternate URL"
|
||||
|
||||
requirements-completed: [SC-2, SC-3, D-92, D-93, D-96, D-102, D-58, D-90, D-18, D-20c, D-11]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Tracer: an admin slug change on a Journal post fires one RecordSaved after commit (Controller, Model = Post morph, default and pl slug changes); signpost ContentTypeForModel + Describe return /blog/<new-slug>; a failed save fires nothing"
|
||||
requirement: "SC-3"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-journal-plugin/record_events_test.go#TestRecordSavedDescribesNewURL"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Every cabana write path emits after commit: create (all columns + translations, Old nil), update, translated slug per locale, no-op (empty Changes), rollback on validation/FormBeforeUpdate/extension Save errors fires nothing, failing listener never fails the save, reorder, child create/update/delete, delete, bulk delete (partial selection fires nothing); extension Save receives the same Changes"
|
||||
requirement: "D-92"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "modules/cabana/record_events_postgres_test.go#TestRecordEvents"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/cabana/example_record_events_test.go#ExampleEmitRecordSaved"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Journal /_journal/api/v1 POST/PUT/DELETE fire RecordSaved (Created, slug changes per locale) and RecordDeleted with Controller \"\""
|
||||
requirement: "D-102"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-journal-plugin/record_events_test.go#TestAPIRecordEvents"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "signpost content lookups, Records, boot errors (no Model, no Describe, duplicate Model/Controller), MatchPattern rules and MatchPath precedence; a type without Content resolves as before"
|
||||
requirement: "D-93"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "modules/signpost/content_test.go#TestContentLookups"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/signpost/content_test.go#TestContentBootErrors"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/signpost/content_test.go#TestContentMatchPattern"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/signpost/content_test.go#TestContentMatchPath"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "modules/signpost/example_content_test.go#ExampleRegistry_MatchPath"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Journal post/category/tag descriptors: Describe per locale, Records paging, strict Match (wrong category, stale or wrong locale prefix, other-locale slug inexact; drafts never match); journal-tag type with tag_pages switch"
|
||||
requirement: "D-20c"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-journal-plugin/content_descriptors_test.go#TestContentDescriptors"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-journal-plugin/content_descriptors_test.go#TestJournalTagType"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "D-58: GET /_journal/api/v1/posts/<translated-slug> with Accept-Language pl resolves the post; default slug and id still resolve; unknown slug 404"
|
||||
requirement: "D-58"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-journal-plugin/translated_slug_test.go#TestTranslatedSlug"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Strictly additive (D-106): framework vet + go test -short green, full cabana/signpost/pact/lagoon Docker suites green, whole Journal suite green, sm-sitemap-plugin builds and tests unchanged, sm-demo-app builds unchanged; Journal imports neither sm-seo-plugin nor sm-sitemap-plugin"
|
||||
requirement: "SC-2"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "go vet ./... && go test -short ./... (summercms.go); go test ./modules/cabana ./modules/signpost ./modules/pact ./modules/lagoon/..."
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 ./..."
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "go -C ../sm-sitemap-plugin build ./... && go -C ../sm-sitemap-plugin test -short ./...; go -C ../sm-demo-app build ./..."
|
||||
status: pass
|
||||
human_judgment: false
|
||||
|
||||
duration: 37min
|
||||
completed: 2026-10-26
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 02: Record events and content descriptors Summary
|
||||
|
||||
**D-92 record events (pact.RecordSaved/RecordDeleted with per-locale old/new changes, fired after commit from every cabana write path and the Journal API) and D-93 content descriptors (pact.ContentDescriptor in signpost with Describe, Records and strict MatchPath), adopted by Journal for posts, categories and a new journal-tag type, plus the D-58 translated-slug fix**
|
||||
|
||||
## Task 1 answer
|
||||
|
||||
Task 1 (checkpoint:decision on the D-92/D-93 Go shapes) was answered by Jakub before dispatch: **as-planned**. P-07 to P-10 are adopted as written, including the optional `Match` and `signpost.Registry.MatchPath`. The executor did not stop at Task 1.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 37 min
|
||||
- **Started:** 2026-10-26T21:11:36Z
|
||||
- **Completed:** 2026-10-26T21:49:02Z
|
||||
- **Tasks:** 4 (1 decision resolved before dispatch, 3 executed)
|
||||
- **Files modified:** 22 in summercms.go, 12 in sm-journal-plugin
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- pact: `RecordChange`, `RecordSaved`, `RecordDeleted`, `AdminFormSave.Changes`, `MenuItemType.Content` and the eight `Content*` types; every change is a new type or a new last field.
|
||||
- cabana: `EmitRecordSaved`/`EmitRecordDeleted` (lagoon.AfterCommit, listener errors logged); the admin save snapshots the row and the submitted translations before the write and fires `RecordSaved` with the diff; delete, bulk delete, tree reorder and relation-manager child writes fire too; the same changes reach a form extension's `Save`.
|
||||
- signpost: `ContentTypes`, `ContentType`, `ContentTypeForController`, `ContentTypeForModel`, `Describe`, `Records`, `MatchPath`, `MatchPattern`; boot checks for the descriptor.
|
||||
- Journal: post, category and tag descriptors (Describe per locale with URL/title/description/image/words, Records, strict Match), the `journal-tag` type (`/blog/tag/:slug`, `golem15.journal.tag_pages`), record events from the API writes, translated-slug lookup in `GET /posts/{slug}`.
|
||||
- Docs: "Record events" in docs/plugins/extending.md, "Content descriptors" in docs/plugins/menu-item-types.md, admin-controllers notes, pact/cabana/signpost and Journal READMEs; src= snippets from new example tests.
|
||||
|
||||
## Task Commits
|
||||
|
||||
summercms.go (master):
|
||||
|
||||
1. **Task 2: record events and content descriptors (tracer)** - `753fb59` (feat)
|
||||
2. **Task 3: record events from every admin write path** - `ff62906` (feat)
|
||||
3. **Task 4: signpost content lookups, Records and MatchPath** - `785902c` (feat)
|
||||
|
||||
../sm-journal-plugin (main):
|
||||
|
||||
1. **Task 2: post content descriptor + tracer test** - `08ab153` (feat)
|
||||
2. **Task 3: record events from the Journal API writes (D-102)** - `4b3a8bb` (feat)
|
||||
3. **Task 4: content descriptors for posts, categories and journal-tag** - `e17cebd` (feat)
|
||||
4. **Task 4: resolve translated post slugs (D-58)** - `a598a7c` (fix)
|
||||
5. **Task 4: declare the content descriptors in MenuItemTypes** - `c5b7147` (refactor)
|
||||
|
||||
**Plan metadata:** recorded in the docs(32-02) commit that adds this file.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
Tasks 3 and 4 were written tests-first. RED was verified for each with `msd_run check tdd-red-evidence` (verdict `RED_EVIDENCE_OK`, go test -json converted to TAP):
|
||||
|
||||
- Task 3 framework: TestRecordEvents failed on the reorder, child write, delete and bulk delete subtests ("saved [] deleted []").
|
||||
- Task 3 Journal: TestAPIRecordEvents failed ("POST events = [], want one RecordSaved").
|
||||
- Task 4 signpost: TestContent* failed on assertions after compile stubs (ContentType false, Activate accepted the descriptor, MatchPattern false, MatchPath no match).
|
||||
- Task 4 Journal: TestContentDescriptors, TestJournalTagType and TestTranslatedSlug failed (ContentTypes = journal-post, journal-tag unregistered, 404).
|
||||
|
||||
The RED tests were not committed on their own: project CLAUDE.md requires `go test ./...` green at every commit, so each test landed in the same `feat` commit as the code that makes it pass (no separate `test(32-02)` commits). This is a CLAUDE.md-driven deviation from the tdd.md commit pattern.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See key-decisions in the frontmatter. In short: event and descriptor shapes exactly as P-07 to P-10; `Locale ""` means the record's own row; no-op saves still fire; reorder fires per moved node; child events name the controller of the child's model; Records without a func is an empty page; MatchPath takes the first exact, else the first inexact; Journal describes drafts but never matches them.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] CRUDService and RelationService had no handle on the application**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** The emission needs `app.Events`; the services carried only DB, bucket, translator and writer.
|
||||
- **Fix:** unexported `app` field on CRUDService and `app`/`reg` on RelationService, set by `service.crud()`/`service.relations()`. A service built without them (other packages, old tests) fires nothing.
|
||||
- **Files modified:** modules/cabana/crud.go, relation.go, http.go
|
||||
- **Committed in:** 753fb59, ff62906
|
||||
|
||||
**2. [Rule 3 - Blocking] docs checker refuses go code blocks without src=**
|
||||
- **Found during:** Task 3 and Task 4
|
||||
- **Fix:** examples `ExampleEmitRecordSaved` (cabana) and `NewsPlugin` + `ExampleRegistry_MatchPath` (signpost) back the docs snippets, refreshed with `summer docs:sync`.
|
||||
- **Committed in:** ff62906, 785902c
|
||||
|
||||
**3. [Rule 1 - Acceptance criterion] posts.go needed the emit calls inline**
|
||||
- **Found during:** Task 3: the criterion counts `cabana.EmitRecord` in posts.go (>= 3); the helper builds the event (`postSavedEvent`) and the handlers call `cabana.EmitRecordSaved`/`EmitRecordDeleted` directly.
|
||||
- **Committed in:** 4b3a8bb
|
||||
|
||||
**4. [Rule 1 - Acceptance criterion] content descriptors declared inline**
|
||||
- **Found during:** Task 4 verification: the criterion counts `Content: &pact.ContentDescriptor` in menu_item_types.go (3); the descriptors moved from helper funcs to literals (refactor commit, no behaviour change).
|
||||
- **Committed in:** c5b7147
|
||||
|
||||
**5. [CLAUDE.md] No separate RED commits** (see TDD Gate Compliance).
|
||||
|
||||
**6. [Rule 2 - Scope] journal-tag Resolve answers nothing without tag pages**
|
||||
- The plan names Describe and Match for `tag_pages: false`; Resolve follows the same rule so a menu or sitemap never links a tag page the host does not have.
|
||||
|
||||
**7. Test fixture adjustments in Journal**
|
||||
- `TestMenuItemTypesPatterns` lists six types (journal-tag appended); D-58's test lives in its own file `translated_slug_test.go` so the descriptor commit and the fix commit are each green.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 7 (2 blocking, 2 acceptance-criterion shape, 1 CLAUDE.md commit rule, 1 scope consistency, 1 test fixture)
|
||||
**Impact on plan:** No scope creep; the published shapes are P-07 to P-10 as answered.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- The translate migrations seed `en` and Journal seeds an "Uncategorized" category; the descriptor test seeds locales with `WHERE NOT EXISTS` and checks the category page by its last record.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
None beyond the plan's threat model: T-32-05 (failing listener logged, save 200), T-32-06 (AfterCommit, rollback cases), T-32-07 (path values only as GORM `?` parameters; MatchPattern refuses empty and extra segments) and T-32-08 (drafts never match; findPostBySlugOrID keeps its scope, Show still hides drafts from anonymous callers) are covered by TestRecordEvents, TestContentMatchPattern, TestContentDescriptors and TestTranslatedSlug.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. A host without tag pages sets `golem15.journal.tag_pages: false` (or `SUMMER_GOLEM15__JOURNAL__TAG_PAGES=false`).
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- sm-seo-plugin (32-03) can listen for `*pact.RecordSaved`/`*pact.RecordDeleted`, map `Model` to a content type with `ContentTypeForModel`, read URLs with `Describe` and resolve paths with `MatchPath`.
|
||||
- Plan 32-05 moves the demo app's Journal submodule to `c5b7147` (or later); the demo app builds unchanged against the framework checkout today.
|
||||
- Nothing pushed or tagged.
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-26*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
All created files exist; framework commits 753fb59, ff62906, 785902c and Journal commits 08ab153, 4b3a8bb, e17cebd, a598a7c, c5b7147 are present.
|
||||
462
.planning/phases/32-seo-foundation/32-03-PLAN.md
Normal file
462
.planning/phases/32-seo-foundation/32-03-PLAN.md
Normal file
@@ -0,0 +1,462 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 03
|
||||
type: execute
|
||||
wave: 3
|
||||
depends_on: ["32-01", "32-02"]
|
||||
files_modified:
|
||||
- ../sm-seo-plugin/go.mod
|
||||
- ../sm-seo-plugin/go.sum
|
||||
- ../sm-seo-plugin/go.work
|
||||
- ../sm-seo-plugin/.gitignore
|
||||
- ../sm-seo-plugin/README.md
|
||||
- ../sm-seo-plugin/plugin.go
|
||||
- ../sm-seo-plugin/logger.go
|
||||
- ../sm-seo-plugin/admin.go
|
||||
- ../sm-seo-plugin/admin_permissions.go
|
||||
- ../sm-seo-plugin/admin_navigation.go
|
||||
- ../sm-seo-plugin/extensions.go
|
||||
- ../sm-seo-plugin/field_types.go
|
||||
- ../sm-seo-plugin/routes.go
|
||||
- ../sm-seo-plugin/jobs.go
|
||||
- ../sm-seo-plugin/commands.go
|
||||
- ../sm-seo-plugin/listeners.go
|
||||
- ../sm-seo-plugin/config/config.yaml
|
||||
- ../sm-seo-plugin/lang/en/lang.yaml
|
||||
- ../sm-seo-plugin/lang/pl/lang.yaml
|
||||
- ../sm-seo-plugin/models/registry.go
|
||||
- ../sm-seo-plugin/models/entry.go
|
||||
- ../sm-seo-plugin/models/revision.go
|
||||
- ../sm-seo-plugin/models/settings.go
|
||||
- ../sm-seo-plugin/models/type_setting.go
|
||||
- ../sm-seo-plugin/models/rule.go
|
||||
- ../sm-seo-plugin/models/settings/fields.yaml
|
||||
- ../sm-seo-plugin/models/rule/fields.yaml
|
||||
- ../sm-seo-plugin/models/rule/columns.yaml
|
||||
- ../sm-seo-plugin/models/revision/fields.yaml
|
||||
- ../sm-seo-plugin/models/revision/columns.yaml
|
||||
- ../sm-seo-plugin/updates/registry.go
|
||||
- ../sm-seo-plugin/updates/202610270001_create_golem15_seo_entries.go
|
||||
- ../sm-seo-plugin/updates/202610270002_create_golem15_seo_revisions.go
|
||||
- ../sm-seo-plugin/updates/202610270003_create_golem15_seo_settings.go
|
||||
- ../sm-seo-plugin/updates/202610270004_create_golem15_seo_type_settings.go
|
||||
- ../sm-seo-plugin/updates/202610270005_create_golem15_seo_rules.go
|
||||
- ../sm-seo-plugin/controllers/admin_registry.go
|
||||
- ../sm-seo-plugin/controllers/settings.go
|
||||
- ../sm-seo-plugin/controllers/settings/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/settings/_staging.htm
|
||||
- ../sm-seo-plugin/controllers/settings/_placeholders.htm
|
||||
- ../sm-seo-plugin/controllers/rules.go
|
||||
- ../sm-seo-plugin/controllers/rules/config_list.yaml
|
||||
- ../sm-seo-plugin/controllers/rules/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/rules/_seo_status.htm
|
||||
- ../sm-seo-plugin/controllers/rules/_seo_effective.htm
|
||||
- ../sm-seo-plugin/controllers/history.go
|
||||
- ../sm-seo-plugin/controllers/history/config_list.yaml
|
||||
- ../sm-seo-plugin/controllers/history/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/history/_history_diff.htm
|
||||
- ../sm-seo-plugin/controllers/api/resolve.go
|
||||
- ../sm-seo-plugin/extension/_seo_status.htm
|
||||
- ../sm-seo-plugin/extension/_seo_effective.htm
|
||||
- ../sm-seo-plugin/extension/_placeholders.htm
|
||||
- ../sm-seo-plugin/classes/service.go
|
||||
- ../sm-seo-plugin/classes/resolver.go
|
||||
- ../sm-seo-plugin/classes/templates.go
|
||||
- ../sm-seo-plugin/classes/urls.go
|
||||
- ../sm-seo-plugin/classes/robots_value.go
|
||||
- ../sm-seo-plugin/classes/entries.go
|
||||
- ../sm-seo-plugin/classes/history.go
|
||||
- ../sm-seo-plugin/classes/snippet.go
|
||||
- ../sm-seo-plugin/classes/image.go
|
||||
- ../sm-seo-plugin/classes/field_types.go
|
||||
- ../sm-seo-plugin/classes/generate.go
|
||||
- ../sm-seo-plugin/package.json
|
||||
- ../sm-seo-plugin/package-lock.json
|
||||
- ../sm-seo-plugin/tsconfig.json
|
||||
- ../sm-seo-plugin/vite.config.ts
|
||||
- ../sm-seo-plugin/scripts/check-dist.sh
|
||||
- ../sm-seo-plugin/assets/src/elements/index.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/measure.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/labels.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/text.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/robots.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/serp.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/image.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/styles.css
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/assets/dist/seo.css
|
||||
- ../sm-seo-plugin/testmain_test.go
|
||||
- ../sm-seo-plugin/fixture_test.go
|
||||
- ../sm-seo-plugin/seo_tab_test.go
|
||||
- ../sm-seo-plugin/settings_test.go
|
||||
autonomous: false
|
||||
requirements: [SC-2, D-01, D-02, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-15, D-21, D-22, D-23, D-90, D-91, D-92, D-93, D-94, D-95, D-100, D-104, D-13]
|
||||
|
||||
estimate:
|
||||
tokens: 190000
|
||||
raw_tokens: 190000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A registered content type's admin form shows the SEO tab added by sm-seo-plugin through the D-91 extension, and its values are stored in the plugin's one table keyed by model type, record id and locale; the content plugin imports nothing from sm-seo-plugin (D-01, D-93, SC-2)"
|
||||
- "GET /_seo/api/v1/resolve?url=... answers the effective SEO of a URL for published content: title, description, canonical, robots, the X-Robots-Tag value, Open Graph and Twitter values, and verification meta on the home page (D-02, D-04, D-05, D-06, D-08, SC-2)"
|
||||
- "Precedence per value is URL rule > record > per-type template or global settings > content-derived values, and the resolver records the source of every value (rule, record, template, global, content, default) (D-02, D-13)"
|
||||
- "A URL rule (exact or pattern such as /blog?tag=*) sets SEO for an address with or without a record behind it and wins over the record's tab (D-02)"
|
||||
- "Global SEO settings hold the title and home templates, default description, default social image, site name, twitter:site, verification codes and files, the query-parameter list, never-indexed and search paths, and the address options; per content type a tab holds the inject switch, title and description templates and the default robots (D-03, D-05, D-07, D-21, D-104)"
|
||||
- "Canonical is self-referencing and absolute from the configured site URL by default, keeps content parameters, drops filter and tracking parameters, and takes record or rule overrides, relative or absolute (D-06, D-07)"
|
||||
- "Robots resolve per directive through rule > record > never-indexed/search paths and filter-parameter URLs > type default > index,follow; the same directives are returned as the X-Robots-Tag value; outside production every answer is noindex,nofollow with staging true (D-08, D-21, D-22, D-23)"
|
||||
- "One permission golem15.seo.manage covers the SEO tab, URL rules, settings and history; without it there is no navigation item, no settings tile and no SEO tab, and saves leave SEO values untouched (D-15)"
|
||||
- "Every SEO write from the admin is recorded in history with author, time, via and before/after values (D-13)"
|
||||
- "Deleting a record deletes its SEO entries after commit while history keeps the values (D-92, D-94)"
|
||||
- "A GenerateEntries job run through conga creates missing entries with the current URL of every published record (D-94)"
|
||||
- "The SEO tab's anchor names seo_robots and seo_og_image are reserved for Phase 33 fields and the entry has a data jsonb column (D-43/D-44 room)"
|
||||
- "SEO tab on a new record: P1 and P2 do not render, E3 shows the address-after-first-save line and the template title, E1 shows the empty status (UI-SPEC empty)"
|
||||
- "E3 without a description anywhere shows the no-description line in muted italic (UI-SPEC empty)"
|
||||
- "E3 shows a skeleton card until the context action answers and a checking line while the duplicate action is pending (UI-SPEC loading)"
|
||||
- "Lists, forms and previews show the existing skeletons, and plugin elements show the existing PluginField/WidgetField skeleton until they are defined (UI-SPEC loading)"
|
||||
- "When an element script fails or times out the existing ExtensionFailure box shows; a failed widget action shows the danger toast and E3 still renders from fill-values alone (UI-SPEC error)"
|
||||
- "A refused save shows field lines, the count banner and the SEO tab error badge (UI-SPEC error)"
|
||||
- "SEO tab fields follow UI-SPEC C3 order and spans, with every ML value under the form's one locale switcher (UI-SPEC populated)"
|
||||
- "A record with SEO in one locale only: the other locale's values are empty (inherit), E1 shows empty, E2 shows Inherit, P2 shows template or content sources (UI-SPEC partial)"
|
||||
- "A locale without an address shows effective.no_url in P2 and noUrl in E3 (UI-SPEC partial)"
|
||||
- "A URL rule overriding a record shows the status.rule callout at the top of the SEO tab listing the overridden properties (UI-SPEC partial)"
|
||||
- "A type whose Show the SEO tab switch is off has the tab removed per request while stored values keep working (UI-SPEC partial)"
|
||||
- "Outside production the settings and robots screens show the staging callout and P2 shows the status.staging note (UI-SPEC partial)"
|
||||
- "E3 duplicate warnings: none for zero, plural dupTitle/dupDescription for one or many, at most three links plus andMore (UI-SPEC zero-one-many)"
|
||||
- "Settings show General, one tab per registered content type in registration order, then Indexing, Addresses and Verification; zero registered types leaves only the four fixed tabs (UI-SPEC zero-one-many, C11)"
|
||||
- "Settings repeaters use titleFrom and collapse per row; long URLs in P2 wrap with overflow-wrap anywhere; E3 truncates title and description at the pixel budget with an ellipsis (UI-SPEC overflow, long-text)"
|
||||
- "URL rules list shows the empty-state copy rules.list_empty, url/match/overrides/updated columns, and the form follows UI-SPEC C7 (UI-SPEC empty, populated)"
|
||||
- "History list shows history.list_empty when empty and newest first with Undone badges when populated (UI-SPEC empty, populated)"
|
||||
- "Keyphrase checks match Polish inflection by the C6 stem rule: grzyby matches grzybów, case and diacritics ignored (UI-SPEC partial, Q-4)"
|
||||
- "Every OG image field (SEO tab, URL rule, settings default) is an seoimage field that uploads its own file; extensions own no attachments (D-100)"
|
||||
prohibitions:
|
||||
- statement: "Content plugins never import sm-seo-plugin, and the SEO data never lives in content plugins' tables or columns (D-90, D-01)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "The public resolver never answers the SEO of an unpublished record and never builds absolute URLs from the request Host header"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "The non-production lock cannot be disabled from the admin or MCP; it depends on the environment only (D-22)"
|
||||
status: resolved
|
||||
verification: test
|
||||
artifacts:
|
||||
- path: "../sm-seo-plugin/plugin.go"
|
||||
provides: "Plugin golem15.seo: Register/Boot, interface assertions"
|
||||
contains: "func (p *Plugin) ID() string { return \"golem15.seo\" }"
|
||||
- path: "../sm-seo-plugin/extensions.go"
|
||||
provides: "AdminActionExtensions: the SEO tab per content type and the per-type tabs on golem15.seo.settings"
|
||||
contains: "pact.AdminFormExtension"
|
||||
- path: "../sm-seo-plugin/classes/resolver.go"
|
||||
provides: "Resolver.Resolve with per-value sources and precedence"
|
||||
contains: "func (r *Resolver) Resolve("
|
||||
- path: "../sm-seo-plugin/updates/202610270001_create_golem15_seo_entries.go"
|
||||
provides: "golem15_seo_entries keyed by (model_type, record_id, locale) with data jsonb"
|
||||
contains: "golem15_seo_entries"
|
||||
- path: "../sm-seo-plugin/assets/dist/seo.js"
|
||||
provides: "E1, E2, E3, E7 custom elements"
|
||||
- path: "../sm-seo-plugin/seo_tab_test.go"
|
||||
provides: "TestSEOTabTracer, TestSEOTab"
|
||||
contains: "func TestSEOTabTracer("
|
||||
key_links:
|
||||
- from: "../sm-seo-plugin/extensions.go"
|
||||
to: "summercms.go/modules/signpost/content.go"
|
||||
via: "AdminActionExtensions reads signpost ContentTypes() and targets each Content.Controller"
|
||||
pattern: "ContentTypes\\(\\)"
|
||||
- from: "../sm-seo-plugin/controllers/api/resolve.go"
|
||||
to: "../sm-seo-plugin/classes/resolver.go"
|
||||
via: "GET /_seo/api/v1/resolve calls Resolver.Resolve"
|
||||
pattern: "Resolve\\(r\\.Context\\(\\)"
|
||||
- from: "../sm-seo-plugin/listeners.go"
|
||||
to: "summercms.go/modules/pact/record_events.go"
|
||||
via: "app.Events.Listen(\"golem15.seo\", func(ctx, *pact.RecordDeleted) error)"
|
||||
pattern: "\\*pact\\.RecordDeleted"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan delivers the editor-facing core: the SEO tab on every registered content type, URL rules, global settings with per-type tabs, history, and the effective-SEO answer for the frontend.
|
||||
|
||||
<objective>
|
||||
Create `sm-seo-plugin` (Golem15.SEO, module `git.golem15.com/golem15/sm-seo-plugin`, package `seo`, ID `golem15.seo`) at `../sm-seo-plugin` per D-94, on the seams of plans 32-01 and 32-02 only:
|
||||
- models and migrations: entries (D-01), revisions (history core, D-13), settings, per-type settings, URL rules (D-02);
|
||||
- the SEO tab added to every content type with a `Content.Controller` through D-91 (D-01, D-04, D-06, D-08, D-09), with the `seoimage` field type for the social image (D-100);
|
||||
- the settings screen as an `AdminSingleton` linked from a settings tile, its per-type tabs added through D-91 on itself (D-104, D-03, D-05, D-07, D-21);
|
||||
- the effective-SEO resolver with per-value sources and its public `GET /_seo/api/v1/resolve` (D-02, D-06, D-07, D-08, D-21, D-22 lock, D-23 path patterns);
|
||||
- the GenerateEntries job (D-94), entry cleanup on `RecordDeleted` (D-92), one permission (D-15);
|
||||
- UI-SPEC elements E1, E2, E3, E7 and partials P1, P2, P3, P5.
|
||||
Redirects, normalisation, strict URLs and robots.txt are plan 32-04; the management API, MCP, batch, undo and CSV are plan 32-05. `Requires()` stays empty in Phase 32: the D-95 sitemap filter interface and the `Requires` on Golem15.Sitemap arrive with the sitemap rewrite in Phase 33.
|
||||
|
||||
Purpose: SC-2 (Journal posts, categories and tags show the SEO tab without importing sm-seo-plugin; the frontend gets the effective SEO of any URL with the precedence URL rule > record > global > derived).
|
||||
|
||||
Output: the new repository with commits on branch `main`, nothing pushed (pushing waits for Jakub's go-ahead in plan 32-06). Which plan implements each decision of the phase, and what Phase 33 takes, is in `32-DECISIONS-MAP.md`.
|
||||
|
||||
**Planner decisions recorded here (Claude's discretion: table and package names, CONTEXT):**
|
||||
- **P-12 (repository):** clone `git@git.golem15.com:golem15/sm-seo-plugin.git` (it exists, empty, public: created on 2026-10-26 with `tea`, D-106) into `../sm-seo-plugin` and work on branch `main`; if cloning an empty repository is refused, `git init -b main` and `git remote add origin git@git.golem15.com:golem15/sm-seo-plugin.git`. No push in this plan. `go.mod` requires the framework at the latest existing tag from `git -C ../summercms.go tag --sort=-v:refname | head -1` (no version written into the plan); `go.work` (tracked, like the sibling plugins) uses `.` and replaces `git.golem15.com/golem15/summercms => ../summercms.go`.
|
||||
- **P-13 (tables):** prefix `golem15_seo_`; `entries` (id, model_type, record_id text, locale, type_key, url, title, description, keyphrase, canonical, robots, og_title, og_description, og_image, effective_title, effective_description, data jsonb not null default '{}', created_at, updated_at; unique (model_type, record_id, locale)); `revisions` (id, batch_id text null, author_id null, author_label, via admin|mcp|import|auto|undo, subject_kind entry|rule|redirect|robots|settings|notfound, subject_id text, what, before jsonb, after jsonb, undone_at null, undone_by_id null, created_at); `settings` (singleton row 1; site_name, twitter_site, title_template default '%title% | %site%', home_template default '%site%', default_description, default_og_image, query_params jsonb seeded with page=content, utm_*/fbclid/gclid/msclkid=tracking, sort=filter; noindex_paths, search_paths, url_host keep|www|bare, url_slash keep|add|remove, url_lowercase bool default false, verify_google, verify_bing, verify_yandex, verify_other jsonb, verify_files jsonb, csv_delimiter, robots columns added in plan 32-04); `type_settings` (type_key primary key, inject bool default true, title_template, description_template, robots); `rules` (id, url, match exact|pattern, title, description, canonical, robots, og_title, og_description, og_image, note, timestamps; unique (url, match)). Raw SQL DDL, timestamped migration IDs, one file per table (sm-sitemap-plugin pattern).
|
||||
- **P-14 (precedence per value, D-02 with the approved UI-SPEC copy):** title: rule > record > type title template, else the general template, applied to the content title (source template) > content title > site name; description: rule > record > type description template > content description (excerpt) > settings default description (source global); og:title, og:description: rule > record > effective title/description; og:image: rule > record > content image > settings default social image; canonical: rule > record > self; robots per directive: rule > record > never-indexed paths (noindex,nofollow), search paths and URLs carrying a filter parameter (noindex,follow) > type default > index,follow. The per-type template is the "global defaults" layer of D-02; the site-wide default description and default social image are last-resort fallbacks after content, as the approved copy `settings.default_description_comment` states.
|
||||
- **P-15 (resolve answer):** `GET /_seo/api/v1/resolve?url=<path or absolute URL>` (throttle bucket `seo-resolve`, no auth) answers `{"action":"ok"|"not_found","status":200|404,"url":<absolute canonical page URL>,"locale":...,"staging":bool,"seo":{"title","description","canonical","robots","x_robots_tag","og":{"title","description","image","url"},"twitter":{"card","site"},"verification":[{"name","content"}]}}`; plan 32-04 adds `redirect` and `gone`. Absolute URLs use the config key `golem15.seo.site_url` (fallback `app.url`), never the request Host. Unpublished records and unknown paths without a rule answer `not_found`.
|
||||
- **P-16 (OG image, D-100):** the `seoimage` field type (element `golem15-seo-image`, E7) stores an uploaded image in the media bucket (`*blob.Bucket`, folder `seo`, content sniffing as in Journal's editor upload) and keeps its URL; it is used for the SEO tab's `seo_og_image`, the rule form's `og_image` and the settings' `default_og_image` (one storage form for the resolver; UI-SPEC C7/C11 fileupload replaced by D-100). One image per record, shared by every locale row (Q-5).
|
||||
- **P-17 (Journal Post tab order):** the SEO tab is placed with no anchor, at the end; Journal Post renders Edit | Manage | Categories | SEO (plan 32-01 P-02), which updates UI-SPEC C3's example.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-RESEARCH.md
|
||||
@.planning/phases/32-seo-foundation/32-PATTERNS.md
|
||||
@.planning/phases/32-seo-foundation/32-UI-SPEC.md
|
||||
@.planning/phases/32-seo-foundation/32-01-SUMMARY.md
|
||||
@.planning/phases/32-seo-foundation/32-02-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
|
||||
<interfaces>
|
||||
From plan 32-01 (pact): AdminActionExtension{Controller, RecordActions, Form *AdminFormExtension}; AdminFormExtension{Tabs []AdminFormTab; Fields []AdminFormField; Hide, Permissions []string; Visible func(ctx) bool; Dir string; Actions []AdminAction; PartialData; Load func(ctx, AdminFormLoad) (map[string]any, error); Save func(ctx, AdminFormSave) (AdminFormSaveResult, error)}; AdminFormField{Name, Tab, Before, After, Zone string; Config map[string]any}; AdminFormErrors; AdminFormSaveResult{Notices map[string][]FormFieldNotice}. (If the plan 32-01 Task 1 answer changed the shape, use the shape recorded in 32-01-SUMMARY.md.)
|
||||
From plan 32-02 (pact/signpost/cabana): RecordSaved/RecordDeleted (pointer events); ContentDescriptor{Controller, Model, Records, Describe, Match}; ContentRecord{ID, Published, LastMod, Locales []ContentLocale{Locale, URL, Title, Description, Image, Words}}; signpost Registry ContentTypes(), ContentTypeForController(id), ContentTypeForModel(model), Describe(ctx, key, id, unprefixed), Records(ctx, key, after, limit, unprefixed), MatchPath(ctx, path, unprefixed), MatchPattern(pattern, path); cabana.TxFromContext(ctx); AdminFormSave.Changes.
|
||||
Analogs (PATTERNS.md): ../sm-sitemap-plugin/plugin.go (plugin entry, interface assertions, boot error prefix), admin.go (embeds, AdminControllers lazy app accessor, Settings link entry with Controller), admin_permissions.go, controllers/definitions.go (AdminSingleton SingletonRecord first-or-create), models/settings.go + models/settings/fields.yaml, updates/registry.go + 202610110002_create_golem15_sitemap_settings.go (raw SQL migrations), testmain_test.go (flag.Parse + testing.Short, postgres:16-alpine); ../sm-journal-plugin/field_types.go + classes/blog_editor.go 80-109 and 343-380 (field-type pair, Upload into *blob.Bucket); ../sm-journal-plugin/routes.go (throttled groups); ../sm-journal-plugin/controllers/api/auth.go 83-115 (backend principal); ../sm-chat-plugin/plugin.go 85-100 (conga.Job); ../sm-journal-plugin/package.json, vite.config.ts, scripts/check-dist.sh, assets/src/blogeditor/labels.ts (element bundle).
|
||||
Framework: cooler.PurgeSiteCacheAfterCommit(ctx, db, purger, kind, slug); compass Config.Environment(); bouncer.Dispatched(ctx, "backend"); cabana.Allows(principal, []string).
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
## Execution units and resume points
|
||||
|
||||
This plan creates a repository and has five tasks, so each task is a resumable unit and the plan can run across several executor contexts without losing work:
|
||||
- Every task ends with the commit groups listed below, in order, in `../sm-seo-plugin`: `git -c safe.directory='*' -C ../sm-seo-plugin add <paths of the group>` (paths only, never `-A` or `.`), then `commit -m "<subject>"`. No task leaves uncommitted files for the next one, every commit keeps `go vet ./...` and `go test -short ./...` green in the plugin, and each group adds the lang keys it uses to both lang files.
|
||||
- Resume check before each task: `git -c safe.directory='*' -C ../sm-seo-plugin log --format=%s | grep -Fx '<subject>'` for each subject of the task. All present: the task is done; re-run its `<verify>` and go on. Some present: continue at the first missing group. None: start the task.
|
||||
- An executor whose context is getting heavy stops after a task's last commit and returns its completed-task table (task, subjects, SHAs); the continuation starts at the next task from that table. The Task 4 checkpoint is always such a boundary: Tasks 1 to 3 run in one context and Task 5 in a fresh one.
|
||||
|
||||
| Task | Commit groups, in order | Resume point after the task |
|
||||
|------|-------------------------|-----------------------------|
|
||||
| 1 | `feat: plugin scaffold, entries and the SEO tab tracer` | TestSEOTabTracer passes: the SEO tab saves a title and resolve returns it |
|
||||
| 2 | A `feat: URL rules and the settings singleton`; B `feat: per-type settings tabs and the SEO tab permission`; C `feat: full precedence resolver with value sources` | rules, settings and the full resolver work; Task 3 builds on `classes/service.go` only |
|
||||
| 3 | A `feat: SEO change history`; B `feat: entry generation job and cleanup on delete` | history, the generation job and the delete listener work; nothing of the element toolchain is installed |
|
||||
| 4 | none (checkpoint); the continuation prompt carries the answer, and 32-03-SUMMARY.md records it | the four npm pins and grobotstxt approved or refused |
|
||||
| 5 | A `feat: SEO field elements and bundle`; B `feat: SEO field types and the complete SEO tab`; C `docs: plugin README` | plan complete; write 32-03-SUMMARY.md |
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: End-to-end "an editor sets a record's SEO title in its SEO tab and the frontend's resolve answer returns it" — one path only</name>
|
||||
<precondition>`git ls-remote git@git.golem15.com:golem15/sm-seo-plugin.git` exits 0 (the repository exists; empty output is fine); plans 32-01 and 32-02 are committed in summercms.go</precondition>
|
||||
<reversibility rating="one-way">The entries table keyed by (model type, record id, locale) and the opt-in through signpost descriptors are what every content plugin builds on; confirmed by Jakub as D-01 (already decided, no checkpoint).</reversibility>
|
||||
<files>../sm-seo-plugin/go.mod, ../sm-seo-plugin/go.sum, ../sm-seo-plugin/go.work, ../sm-seo-plugin/.gitignore, ../sm-seo-plugin/plugin.go, ../sm-seo-plugin/logger.go, ../sm-seo-plugin/extensions.go, ../sm-seo-plugin/routes.go, ../sm-seo-plugin/models/registry.go, ../sm-seo-plugin/models/entry.go, ../sm-seo-plugin/updates/registry.go, ../sm-seo-plugin/updates/202610270001_create_golem15_seo_entries.go, ../sm-seo-plugin/classes/service.go, ../sm-seo-plugin/classes/resolver.go, ../sm-seo-plugin/classes/entries.go, ../sm-seo-plugin/controllers/api/resolve.go, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/testmain_test.go, ../sm-seo-plugin/fixture_test.go, ../sm-seo-plugin/seo_tab_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-sitemap-plugin/plugin.go, admin.go, go.mod, go.work, .gitignore, testmain_test.go, models/registry.go, updates/registry.go, updates/202610110002_create_golem15_sitemap_settings.go
|
||||
- ../sm-journal-plugin/routes.go and controllers/api/posts.go (handler shape, wire.WriteJSON)
|
||||
- summercms.go/modules/pact/capabilities.go and modules/pact/content.go (seams from plans 32-01 and 32-02)
|
||||
- summercms.go/modules/signpost/content.go
|
||||
- summercms.go/modules/cabana/form_extensions_postgres_test.go (how an extension is exercised over HTTP)
|
||||
- .planning/phases/32-seo-foundation/32-01-SUMMARY.md and 32-02-SUMMARY.md (final seam shapes)
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-01, D-90, D-91, D-93, D-94 and P-12/P-13/P-15:
|
||||
1. Repository (P-12): clone into `../sm-seo-plugin`, branch `main`; `go.mod` module `git.golem15.com/golem15/sm-seo-plugin`, go 1.27.0, requiring the framework at the latest existing tag and gorm, gormigrate, pgx, testcontainers at the versions sm-sitemap-plugin pins; tracked `go.work` with the framework replace; `.gitignore` with `node_modules/` and `go.work.sum` (the README is written in Task 5).
|
||||
2. `logger.go`: `pluginLog = diary.For("seo")` (sm-sitemap-plugin pattern). `plugin.go`: `Plugin{app *backpack.App; service *classes.Service}`, `ID() "golem15.seo"`, `Requires() nil`, Register stores the app, Boot builds the service (DB, signpost registry, config) and fails with `golem15.seo: %w`; compile-time assertions for party.Plugin, pact.HasConfig, HasMigrations, HasModels, HasRoutes, HasAdminActionExtensions, HasLang.
|
||||
3. `models/entry.go` + the entries migration (P-13); `classes/entries.go` upsert/load per (model_type, record_id) returning locale maps; `classes/service.go` the single service every writer calls.
|
||||
4. `extensions.go`: `AdminActionExtensions()` reads `signpost` `ContentTypes()` lazily and returns, for each type with `Content.Controller`, an extension adding tab `golem15.seo::lang.tab.seo` (no anchor, P-17) with, for the tracer, one field `seo_title` of built-in type `mltext` (replaced by `mlseotext` in Task 5); Load returns `{"seo_title": map[locale]title}`; Save upserts the entry rows inside `in.DB` with the URL snapshot from signpost `Describe` (reading through the save transaction).
|
||||
5. `classes/resolver.go` (tracer subset): `Resolver.Resolve(ctx, rawURL string) (Result, error)` normalises the input to a path, finds the owner through signpost `MatchPath`, loads the entry for the matched locale and answers the title with source `record`, else the content title with source `content`; unpublished or unmatched → `not_found`. `routes.go`: `GET /_seo/api/v1/resolve` (throttle `seo-resolve` bucket via Buckets with `surf.TrustedProxies`); `controllers/api/resolve.go` writes the P-15 JSON with `wire.WriteJSON`.
|
||||
6. Tests: `testmain_test.go` copied from sm-sitemap-plugin (DB/user `golem15_seo`, `flag.Parse()` then `testing.Short()`); `fixture_test.go`: a fake content plugin `acme.pages` with admin controller `acme.pages.pages` (model with title, slug; a fields.yaml with tabs), a menu item type `acme-page` (`/pages/:slug`) with a Content descriptor; `TestSEOTabTracer` in `seo_tab_test.go`: boot both plugins with cabana and signpost, GET the form schema of `acme.pages.pages` (contains `seo_title` in tab `golem15.seo::lang.tab.seo`), PUT a page with `seo_title` {en: "Custom"}, then `GET /_seo/api/v1/resolve?url=/pages/<slug>` answers `seo.title` "Custom" and the owner table has no SEO column.
|
||||
7. Commit (resume unit, see Execution units): stage exactly this task's `<files>` paths in `../sm-seo-plugin` with `git -c safe.directory='*'` and commit `feat: plugin scaffold, entries and the SEO tab tracer`. Do not push.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestSEOTabTracer' -count=1 -v 2>&1 | tail -20</automated>
|
||||
<fails_when>non-zero exit, "FAIL" or "no tests to run" in the output, or no "--- PASS: TestSEOTabTracer" line</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `git -c safe.directory='*' -C ../sm-seo-plugin branch --show-current` prints `main` and `git -c safe.directory='*' -C ../sm-seo-plugin remote get-url origin` prints `git@git.golem15.com:golem15/sm-seo-plugin.git`
|
||||
- `head -1 ../sm-seo-plugin/go.mod` prints `module git.golem15.com/golem15/sm-seo-plugin`
|
||||
- `grep -n "replace git.golem15.com/golem15/summercms => ../summercms.go" ../sm-seo-plugin/go.work` prints one line
|
||||
- `grep -n "UNIQUE (model_type, record_id, locale)\|unique (model_type, record_id, locale)" ../sm-seo-plugin/updates/202610270001_create_golem15_seo_entries.go` prints one line (case-insensitive variants accepted) and the DDL has `data jsonb NOT NULL DEFAULT '{}'`
|
||||
- `go -C ../sm-seo-plugin test ./... -run TestSEOTabTracer -count=1` passes
|
||||
- `git -c safe.directory='*' -C ../sm-seo-plugin ls-remote origin` prints nothing (the remote is still empty: nothing pushed)
|
||||
</acceptance_criteria>
|
||||
<done>The new plugin adds an SEO tab to a fake content type through D-91, stores the value in its own entries table and returns it from the public resolve endpoint; committed locally on main.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: URL rules, global and per-type settings (AdminSingleton + D-91 on itself) and the full precedence resolver</name>
|
||||
<files>../sm-seo-plugin/models/settings.go, ../sm-seo-plugin/models/type_setting.go, ../sm-seo-plugin/models/rule.go, ../sm-seo-plugin/models/settings/fields.yaml, ../sm-seo-plugin/models/rule/fields.yaml, ../sm-seo-plugin/models/rule/columns.yaml, ../sm-seo-plugin/updates/202610270003_create_golem15_seo_settings.go, ../sm-seo-plugin/updates/202610270004_create_golem15_seo_type_settings.go, ../sm-seo-plugin/updates/202610270005_create_golem15_seo_rules.go, ../sm-seo-plugin/controllers/admin_registry.go, ../sm-seo-plugin/controllers/settings.go, ../sm-seo-plugin/controllers/settings/config_form.yaml, ../sm-seo-plugin/controllers/settings/_staging.htm, ../sm-seo-plugin/controllers/rules.go, ../sm-seo-plugin/controllers/rules/config_list.yaml, ../sm-seo-plugin/controllers/rules/config_form.yaml, ../sm-seo-plugin/admin.go, ../sm-seo-plugin/admin_permissions.go, ../sm-seo-plugin/admin_navigation.go, ../sm-seo-plugin/extensions.go, ../sm-seo-plugin/classes/resolver.go, ../sm-seo-plugin/classes/templates.go, ../sm-seo-plugin/classes/urls.go, ../sm-seo-plugin/classes/robots_value.go, ../sm-seo-plugin/config/config.yaml, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/settings_test.go, ../sm-seo-plugin/seo_tab_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-sitemap-plugin/controllers/definitions.go (AdminSingleton), controllers/admin_registry.go, admin.go (Settings link entry), admin_permissions.go, models/settings.go, models/settings/fields.yaml
|
||||
- ../sm-paymentgateway-plugin/controllers/orders.go 24-50, 106-155 (list/form controller hooks, FilterOptions, ListExtendRecords)
|
||||
- summercms.go/docs/backend/settings.md and docs/backend/admin-controllers.md (Singleton controllers, line 453)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C2, C7, C11, Copywriting: SEO settings, URL rules)
|
||||
- .planning/phases/32-seo-foundation/32-CONTEXT.md (D-02 to D-08, D-21, D-23)
|
||||
- ../sm-seo-plugin/classes/resolver.go and extensions.go (Task 1)
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-02, D-03, D-04, D-05, D-06, D-07, D-08, D-15, D-21, D-22, D-23, D-104 and P-13/P-14/P-15:
|
||||
1. Models and migrations for settings (row 1 inserted by the migration with the seeded query parameters), type_settings, rules. Rule validation: url starts with "/", `*` only in a pattern (`rules.url_invalid`), unique (url, match) (`rules.url_taken`); settings: verification file names `^[A-Za-z0-9._-]+\.(html|txt|xml)$` (`settings.verify_filename_invalid`), unique names (`settings.verify_filename_taken`), templates with only known placeholders %title%, %description%, %site% (`settings.template_unknown`).
|
||||
2. Controllers: `golem15.seo.settings` (`AdminSingleton`, tabs General, Indexing, Addresses, Verification per UI-SPEC C11, staging partial; the P3 placeholders partial comes with the other partials in Task 5); `golem15.seo.rules` (list + form per C7, delete confirms, `ListExtendRecords` builds the `overrides` column). The settings tile is a link entry (`pact.SettingsItem{Code: "seo_settings", Controller: "golem15.seo.settings", Icon: "search", Order: 100, ...}`, D-104); one permission `golem15.seo.manage` (D-15) on every controller and the tile; navigation item `seo` (icon `search`, order 600) landing on `golem15.seo.rules` for now with the side-menu item URL rules (Task 3 adds History when its controller exists; plan 32-04 re-points the item to Redirects per C2). `admin.go` embeds the admin files by glob (`controllers/*/*.yaml controllers/*/_*.htm models/*/*.yaml`) instead of file by file as sm-sitemap-plugin does, so later tasks and plans add screens and partials without editing it (Task 5 adds `extension/_*.htm`).
|
||||
3. D-104: in `extensions.go` add one extension on `golem15.seo.settings` whose Tabs place one tab per content type (Name = the type's signpost Label key, the first After the General tab key, each next After the previous) and whose Fields are `type_<key>_inject` (switch, default on), `type_<key>_title_template`, `type_<key>_description_template`, `type_<key>_robots` (built-in dropdown until Task 5 swaps in `seorobots` with `scope: type`; defaults per D-21: a tag type `noindex,follow`, other types empty); Task 5 adds the `type_<key>_placeholders` P3 partial field. Load/Save read and upsert `type_settings`. The SEO tab extension's Visible reads `type_settings.inject` per request (answers true when it cannot decide).
|
||||
4. Resolver complete per P-14: templates with placeholders (`classes/templates.go`); canonical building and the D-07 parameter list with path refinement (`classes/urls.go`; site URL from `golem15.seo.site_url`, fallback `app.url`); robots per directive with the value grammar of UI-SPEC C5 (`classes/robots_value.go`: parse and serialise in the fixed order, refuse malformed input with `pact.FormFieldError`); never-indexed and search paths (one pattern per line, `*` wildcard) for D-21/D-23; the X-Robots-Tag value equal to the robots directives; OG/Twitter values (D-04) with twitter:card summary_large_image when an image exists; verification meta on the home path (D-05); the non-production lock from `app.Config.Environment()` != "production" forcing noindex,nofollow and `staging: true` (D-22). `Result` carries a source per value for P2 and plan 32-05's read tool.
|
||||
5. Tests (smoke): `TestResolverPrecedence` table in `settings_test.go` covering each P-14 chain, a pattern rule `/blog?tag=*`, the parameter list (utm stripped, page kept, sort → noindex,follow) and the staging lock; `TestSettingsTypeTabs` (two content types → General, type A, type B, Indexing, Addresses, Verification; zero types → four fixed tabs); `TestSEOTabPermission` in `seo_tab_test.go` (an admin without golem15.seo.manage sees no SEO tab and a posted seo_title changes nothing).
|
||||
6. Commits (resume units, see Execution units), staged by path in `../sm-seo-plugin` (paths relative to it), in this order:
|
||||
- A `feat: URL rules and the settings singleton`: models/settings.go, models/rule.go, models/settings/fields.yaml, models/rule/fields.yaml, models/rule/columns.yaml, the settings and rules migrations, controllers/admin_registry.go, controllers/settings.go, controllers/settings/config_form.yaml, controllers/settings/_staging.htm, controllers/rules.go, controllers/rules/config_list.yaml, controllers/rules/config_form.yaml, admin.go, admin_permissions.go, admin_navigation.go, lang/en/lang.yaml, lang/pl/lang.yaml;
|
||||
- B `feat: per-type settings tabs and the SEO tab permission`: models/type_setting.go, the type_settings migration, extensions.go, lang files, settings_test.go (TestSettingsTypeTabs), seo_tab_test.go (TestSEOTabPermission);
|
||||
- C `feat: full precedence resolver with value sources`: classes/resolver.go, classes/templates.go, classes/urls.go, classes/robots_value.go, config/config.yaml, settings_test.go (TestResolverPrecedence).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestResolverPrecedence|TestSettingsTypeTabs|TestSEOTabPermission|TestSEOTabTracer' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -30</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the four test names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "Controller: *\"golem15.seo.settings\"\|Controller: *controllers.SettingsControllerID" ../sm-seo-plugin/admin.go` prints the settings tile link entry, and `grep -c "Form:" ../sm-seo-plugin/admin.go` prints 0 for the SettingsItem (link entry, D-104)
|
||||
- `grep -n "golem15.seo.manage" ../sm-seo-plugin/admin_permissions.go` prints one line
|
||||
- `grep -n "Environment()" ../sm-seo-plugin/classes/*.go` prints the staging-lock decision, and no admin field or config key disables it (`grep -rn "staging_lock\|disable_staging" ../sm-seo-plugin --include=*.go --include=*.yaml` prints nothing)
|
||||
- `TestResolverPrecedence` has at least one case per value chain of P-14 and passes
|
||||
- `grep -rn "r.Host\|req.Host" ../sm-seo-plugin/classes ../sm-seo-plugin/controllers` prints nothing
|
||||
</acceptance_criteria>
|
||||
<done>URL rules, the settings singleton with dynamic per-type tabs on D-91, one permission and the full precedence resolver with sources work and are smoke-tested.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: History core, entry generation job, entry cleanup on delete</name>
|
||||
<files>../sm-seo-plugin/models/revision.go, ../sm-seo-plugin/models/revision/fields.yaml, ../sm-seo-plugin/models/revision/columns.yaml, ../sm-seo-plugin/updates/202610270002_create_golem15_seo_revisions.go, ../sm-seo-plugin/classes/history.go, ../sm-seo-plugin/classes/generate.go, ../sm-seo-plugin/classes/service.go, ../sm-seo-plugin/controllers/history.go, ../sm-seo-plugin/controllers/history/config_list.yaml, ../sm-seo-plugin/controllers/history/config_form.yaml, ../sm-seo-plugin/controllers/history/_history_diff.htm, ../sm-seo-plugin/controllers/admin_registry.go, ../sm-seo-plugin/admin_navigation.go, ../sm-seo-plugin/controllers/settings.go, ../sm-seo-plugin/jobs.go, ../sm-seo-plugin/commands.go, ../sm-seo-plugin/listeners.go, ../sm-seo-plugin/plugin.go, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/seo_tab_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-chat-plugin/plugin.go 85-100 (conga.Job, OnQueue, MaxAttempts) and its jobs package
|
||||
- summercms.go/modules/pact/capabilities.go (HasJobs, HasCommands) and docs/plugins/scheduling.md
|
||||
- summercms.go/modules/bouncer/dispatch.go (Dispatched) and modules/towel (actor from context)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C12 History, P5, Copywriting: History)
|
||||
- ../sm-seo-plugin/classes/service.go
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-13, D-92, D-94:
|
||||
1. History core: every service write (entry, rule, settings, type settings) appends one revision row per changed object with author id/label from the towel actor, `via` = `mcp` when `bouncer.Dispatched(ctx, "backend")` answers true else `admin` (import/auto/undo set by later plans), `what` built from the UI-SPEC `history.what_*` keys, before/after jsonb of the changed fields only, all inside the caller's transaction. History screen `golem15.seo.history` per C12: list (columns, filters via/created_at/author, `history.list_empty`, row state `disabled` for undone), preview with P5 `history_diff` (Field / Before / After, DM Mono for URL values, created/deleted markers), and its side-menu entry History in `admin_navigation.go`. Undo record actions are plan 32-05.
|
||||
2. GenerateEntries (D-94): `jobs.go` registers `conga.Job` for `GenerateEntriesArgs{Type string}`; `classes/generate.go` pages signpost `Records` per content type (limit 200) and upserts entry rows with each locale's URL, type key and the effective-title/description cache, never overwriting editor values; `commands.go` adds the console command `seo:generate-entries` with an optional `--type` flag that enqueues the job; the settings singleton's FormAfterUpdate (`controllers/settings.go`) enqueues it too.
|
||||
3. `listeners.go` (registered in Boot): `*pact.RecordDeleted` for a model with a content type deletes its entry rows inside a transaction and records a `deleted` revision so the values stay in history (D-92, D-94); `*pact.RecordSaved` with Created true upserts the URL snapshot of the new record (address-change redirects are plan 32-04).
|
||||
4. Tests (smoke) in `seo_tab_test.go`: `TestHistoryRecordsAdminWrite` (saving the SEO tab writes one revision with via admin and before/after), `TestEntryDeletedWithRecord`, `TestGenerateEntries` (two fake records → two entry rows with URLs; editor values untouched on a second run).
|
||||
5. Commits (resume units, see Execution units), staged by path in `../sm-seo-plugin`, in this order:
|
||||
- A `feat: SEO change history`: models/revision.go, models/revision/fields.yaml, models/revision/columns.yaml, the revisions migration, classes/history.go, classes/service.go, controllers/history.go, controllers/history/config_list.yaml, controllers/history/config_form.yaml, controllers/history/_history_diff.htm, controllers/admin_registry.go, admin_navigation.go, lang files, seo_tab_test.go (TestHistoryRecordsAdminWrite);
|
||||
- B `feat: entry generation job and cleanup on delete`: classes/generate.go, jobs.go, commands.go, listeners.go, plugin.go, controllers/settings.go, lang files, seo_tab_test.go (TestEntryDeletedWithRecord, TestGenerateEntries).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestHistoryRecordsAdminWrite|TestEntryDeletedWithRecord|TestGenerateEntries' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -20</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the three names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "\*pact.RecordDeleted" ../sm-seo-plugin/listeners.go` prints one line
|
||||
- `grep -n "seo:generate-entries" ../sm-seo-plugin/commands.go` prints one line
|
||||
- `grep -n "bouncer.Dispatched" ../sm-seo-plugin/classes/history.go` prints one line
|
||||
- The three tests pass with Docker
|
||||
</acceptance_criteria>
|
||||
<done>Every admin SEO write is recorded in history with author, via and before/after; entries are generated by a conga job and removed with their record while history keeps the values.</done>
|
||||
</task>
|
||||
|
||||
<task type="checkpoint:human-verify" gate="blocking-human">
|
||||
<name>Task 4: Package legitimacy gate for the element toolchain and the robots.txt library</name>
|
||||
<what-built>Nothing is installed yet. RESEARCH.md's Package Legitimacy Audit flags the npm dev dependencies vite, vitest and happy-dom as [SUS] (their latest releases are days old; the pins are older) and the Go module github.com/jimsmart/grobotstxt as [ASSUMED] (the Go ecosystem is not covered by the legitimacy seam). typescript is approved. The pins are the ones sm-journal-plugin already locks (typescript 5.9.3, vite 7.3.5, vitest 3.2.7, happy-dom 20.11.6); grobotstxt v1.0.3 is the version D-99 names and plan 32-04 installs.</what-built>
|
||||
<how-to-verify>
|
||||
1. Open https://www.npmjs.com/package/vite/v/7.3.5, https://www.npmjs.com/package/vitest/v/3.2.7 and https://www.npmjs.com/package/happy-dom/v/20.11.6: the publisher and repository match vitejs/vite, vitest-dev/vitest and capricorn86/happy-dom.
|
||||
2. Run `npm --prefix ../sm-journal-plugin ls vite vitest happy-dom typescript` and confirm the same versions are already locked in an approved sibling plugin.
|
||||
3. Open https://pkg.go.dev/github.com/jimsmart/grobotstxt@v1.0.3 and https://github.com/jimsmart/grobotstxt: Apache-2.0, a port of Google's robots.txt parser; `go list -m -json github.com/jimsmart/grobotstxt@v1.0.3` resolves through proxy.golang.org.
|
||||
</how-to-verify>
|
||||
<resume-signal>Type "approved" to install exactly these pins (Task 5 here, grobotstxt in plan 32-04), or name the package to refuse</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Plugin field types and elements E1, E2, E3, E7, partials P1/P2/P3 and the complete SEO tab (UI-SPEC C3-C6)</name>
|
||||
<precondition>Task 4 answered "approved" for typescript 5.9.3, vite 7.3.5, vitest 3.2.7 and happy-dom 20.11.6</precondition>
|
||||
<files>../sm-seo-plugin/package.json, ../sm-seo-plugin/package-lock.json, ../sm-seo-plugin/tsconfig.json, ../sm-seo-plugin/vite.config.ts, ../sm-seo-plugin/scripts/check-dist.sh, ../sm-seo-plugin/assets/src/elements/index.ts, ../sm-seo-plugin/assets/src/elements/measure.ts, ../sm-seo-plugin/assets/src/elements/labels.ts, ../sm-seo-plugin/assets/src/elements/text.ts, ../sm-seo-plugin/assets/src/elements/robots.ts, ../sm-seo-plugin/assets/src/elements/serp.ts, ../sm-seo-plugin/assets/src/elements/image.ts, ../sm-seo-plugin/assets/src/elements/styles.css, ../sm-seo-plugin/assets/dist/seo.js, ../sm-seo-plugin/assets/dist/seo.css, ../sm-seo-plugin/field_types.go, ../sm-seo-plugin/classes/field_types.go, ../sm-seo-plugin/classes/image.go, ../sm-seo-plugin/classes/snippet.go, ../sm-seo-plugin/extensions.go, ../sm-seo-plugin/extension/_seo_status.htm, ../sm-seo-plugin/extension/_seo_effective.htm, ../sm-seo-plugin/extension/_placeholders.htm, ../sm-seo-plugin/controllers/settings/_placeholders.htm, ../sm-seo-plugin/controllers/rules/_seo_status.htm, ../sm-seo-plugin/controllers/rules/_seo_effective.htm, ../sm-seo-plugin/models/rule/fields.yaml, ../sm-seo-plugin/models/settings/fields.yaml, ../sm-seo-plugin/admin.go, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/README.md, ../sm-seo-plugin/seo_tab_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-journal-plugin/package.json, vite.config.ts, tsconfig.json, scripts/check-dist.sh, assets/src/blogeditor/ (index.ts, labels.ts, element structure), field_types.go, classes/blog_editor.go (80-109 type pair, 343-380 Upload)
|
||||
- ../sm-paymentgateway-plugin/assets/css/quote-cart.css (scoped element CSS with --c-* variables)
|
||||
- summercms.go/admin/src/components/form/fields/WidgetField.vue and PluginField.vue (summer-action, summer-change, fill-values, busy contracts)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (Component Inventory E1-E3, C1, C3, C4, C5, C6, C14, Copywriting tables for the SEO tab, P1, P2, E1, E2, E3, Typography E-1, Color E-1)
|
||||
- ../sm-seo-plugin/extensions.go and classes/resolver.go
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-04, D-06, D-08, D-09, D-100 and UI-SPEC:
|
||||
1. Element bundle: `package.json` (name `golem15-seo-elements`, private, type module, scripts typecheck/build/test, devDependencies pinned exactly as approved, no runtime dependencies); `npm --prefix ../sm-seo-plugin install --save-dev --save-exact` with those pins; `vite.config.ts` copying Journal's (entry `assets/src/elements/index.ts`, outputs `seo.js` and `seo.css`, vitest with happy-dom and `tests/**/*.test.ts`); `scripts/check-dist.sh` copying Journal's drift gate. Elements in light DOM with CSS scoped under each tag and `--c-*` variables only (E-1 palette only inside `golem15-seo-serp .serp-card`): E1 `golem15-seo-text` (C4, shared `measure.ts` canvas measurement, thresholds of Q-3), E2 `golem15-seo-robots` (C5, value grammar identical to `classes/robots_value.go`), E3 `golem15-seo-serp` (C6: context and duplicates ops, desktop/mobile, pixel truncation, keyphrase checks with the C6 stem rule, one queued request while busy), E7 `golem15-seo-image` (upload through the field type's Upload, preview, remove). `labels.ts` holds the en/pl element copy of UI-SPEC with CLDR plural maps. `npm run build` and commit `assets/dist`.
|
||||
2. Field types (`field_types.go` + `classes/field_types.go`): `seotext`/`mlseotext` (option `measure`), `seorobots`/`mlseorobots` (option `scope`, Decode refuses a malformed directive string), `seoimage` (P-16 Upload into `*blob.Bucket`, folder `seo`, image content sniffing, `FormFieldError` on a non-image). Each lists `assets/dist/seo.js` and `assets/dist/seo.css` (if cabana refuses the same asset in several types, list it on `mlseotext` only and record that in the SUMMARY). The extension's `seo_snippet` widget action lives in `AdminFormExtension.Actions` (`classes/snippet.go`: `context` answers locales with url, h1, siteName, titleTemplate, defaultTitle, defaultDescription, descriptionSource, bodyWords and host; `duplicates` answers other records' and rules' labels and admin URLs whose effective title or description equals the submitted one in that locale).
|
||||
3. Complete SEO tab per C3 (fields `seo_status` P1, `seo_snippet` E3, `seo_title` mlseotext, `seo_description` mlseotext, `seo_keyphrase` mltext left, `seo_canonical` mltext right with the `validation.url` check for a path or http(s) URL, `seo_robots` mlseorobots scope record, `seo_og_title`, `seo_og_description` mltextarea small, `seo_og_image` seoimage, `seo_effective` P2), partials from `extension/` through `Dir` and `PartialData` (P1: URL rule override and canonical-to-noindex callouts; P2: effective values per locale with source labels and the staging note); the rule form and settings use `seotext`, `seorobots` and `seoimage` where C7/C11 name text, robots and image fields; the P3 placeholders partial on General (`controllers/settings/_placeholders.htm`) and on each type tab (the `type_<key>_placeholders` field of the settings extension, `extension/_placeholders.htm`); `admin.go` adds `extension/_*.htm` to its embed patterns.
|
||||
4. Full en/pl `lang.yaml` for every key of the UI-SPEC sections this plan renders (navigation for rules/history, settings tile, permission, SEO tab, P1, P2, SEO settings, URL rules, History).
|
||||
5. Smoke: `TestSEOTab` in `seo_tab_test.go`: with the fake content plugin carrying a tabbed form and a tab-less form, the compiled schema lists the C3 fields in order inside the SEO tab placed last, the tab-less form has default then SEO, a malformed `seo_robots` value answers 422, and `seo_og_image` upload rejects a non-image. `npm --prefix ../sm-seo-plugin run typecheck && npm --prefix ../sm-seo-plugin run build` succeed (element unit tests are plan 32-06). README completed in the standard structure (overview, features, usage for content plugins: register a descriptor with Controller and Model, config keys `golem15.seo.site_url`, the resolve endpoint, permissions).
|
||||
6. Commits (resume units, see Execution units), staged by path in `../sm-seo-plugin`, in this order:
|
||||
- A `feat: SEO field elements and bundle`: package.json, package-lock.json, tsconfig.json, vite.config.ts, scripts/check-dist.sh, assets/src/elements/index.ts, measure.ts, labels.ts, text.ts, robots.ts, serp.ts, image.ts, styles.css, assets/dist/seo.js, assets/dist/seo.css;
|
||||
- B `feat: SEO field types and the complete SEO tab`: field_types.go, classes/field_types.go, classes/image.go, classes/snippet.go, extensions.go, extension/_seo_status.htm, extension/_seo_effective.htm, extension/_placeholders.htm, controllers/settings/_placeholders.htm, controllers/rules/_seo_status.htm, controllers/rules/_seo_effective.htm, models/rule/fields.yaml, models/settings/fields.yaml, admin.go, lang/en/lang.yaml, lang/pl/lang.yaml, seo_tab_test.go (TestSEOTab);
|
||||
- C `docs: plugin README`: README.md.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>npm --prefix ../sm-seo-plugin run typecheck && bash ../sm-seo-plugin/scripts/check-dist.sh</automated>
|
||||
<fails_when>non-zero exit, a TypeScript error line, or "assets/dist is stale" in the output</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestSEOTab' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -20</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or no "--- PASS: TestSEOTab" line</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "\"vite\": \"7.3.5\"\|\"vitest\": \"3.2.7\"\|\"happy-dom\": \"20.11.6\"\|\"typescript\": \"5.9.3\"" ../sm-seo-plugin/package.json` prints four lines and `grep -c "\"dependencies\"" ../sm-seo-plugin/package.json` prints 0
|
||||
- `grep -c "customElements.define" ../sm-seo-plugin/assets/src/elements/*.ts` totals 4 (E1, E2, E3, E7)
|
||||
- `grep -n "Name: *\"seoimage\"" ../sm-seo-plugin/classes/field_types.go` prints one line and `grep -n "fileupload" ../sm-seo-plugin/extensions.go ../sm-seo-plugin/models/rule/fields.yaml ../sm-seo-plugin/models/settings/fields.yaml` prints nothing (D-100)
|
||||
- `grep -n "seo_robots\|seo_og_image" ../sm-seo-plugin/extensions.go` prints both reserved anchor names
|
||||
- every `golem15.seo::lang.` key referenced in `../sm-seo-plugin` YAML and Go exists in both `lang/en/lang.yaml` and `lang/pl/lang.yaml` (a small Go test `TestLangKeysComplete` or the framework's phrase validation at boot passes)
|
||||
</acceptance_criteria>
|
||||
<done>The SEO tab matches UI-SPEC C3 with working counters, robots directives, the live result preview with duplicate and keyphrase checks, and an uploadable social image; the bundle is built, committed and drift-checked.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| anonymous frontend → GET /_seo/api/v1/resolve | public, throttled read of effective SEO by URL |
|
||||
| admin browser → SEO tab, rules, settings, seoimage upload | authenticated writes behind golem15.seo.manage |
|
||||
| stored SEO strings → admin partials and elements | editor-supplied text rendered back in the admin |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-09 | Information disclosure | resolve endpoint | high | mitigate | Answers only for records whose descriptor reports Published; drafts and unknown paths answer not_found (TestResolverPrecedence draft case) |
|
||||
| T-32-10 | Spoofing | canonical and absolute URLs | high | mitigate | Built from golem15.seo.site_url or app.url only; acceptance greps that no code reads the request Host |
|
||||
| T-32-11 | Tampering | SEO strings in P1/P2/P3/P5 and E3 | medium | mitigate | html/template escaping plus cabana's sanitizePartialNodes; elements set textContent, never innerHTML with stored values |
|
||||
| T-32-12 | Tampering | seoimage upload | medium | mitigate | Content sniffing to image types only, the framework upload body limit, a fixed folder and a sanitized file name (Journal editor upload pattern) |
|
||||
| T-32-13 | Elevation of privilege | SEO tab and SEO screens | high | mitigate | golem15.seo.manage on every controller, the tile and the extension (Permissions); posted SEO keys ignored without it (TestSEOTabPermission) |
|
||||
| T-32-14 | Denial of service | resolve endpoint | medium | mitigate | surf throttle bucket seo-resolve with trusted-proxy client IPs; URL length capped at 2048 bytes |
|
||||
| T-32-15 | Information disclosure | non-production sites indexed | high | mitigate | Environment-based lock forces noindex,nofollow in every resolve answer; no setting can disable it (D-22) |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | Task 4 blocking-human legitimacy checkpoint before installing vite, vitest, happy-dom (SUS) and grobotstxt (ASSUMED); exact pins already locked by an approved sibling; postinstall scripts are null |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...` green with Docker; `-short` green without.
|
||||
- `npm --prefix ../sm-seo-plugin run typecheck`, `scripts/check-dist.sh` green.
|
||||
- `grep -rn "sm-seo-plugin" ../sm-journal-plugin --include=*.go` empty; framework unchanged by this plan.
|
||||
- Nothing pushed: `git -c safe.directory='*' -C ../sm-seo-plugin status -sb` shows main with no upstream or ahead of an empty origin.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
Any content type registered with a descriptor gets the SEO tab without importing the plugin, editors manage URL rules and global/per-type settings, and the frontend can ask for the effective SEO of any URL with the D-02 precedence and per-value sources.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 03)
|
||||
|
||||
- Repository `../sm-seo-plugin` (module `git.golem15.com/golem15/sm-seo-plugin`, package `seo`, plugin `golem15.seo`), branch `main`
|
||||
- Tables `golem15_seo_entries`, `golem15_seo_revisions`, `golem15_seo_settings`, `golem15_seo_type_settings`, `golem15_seo_rules`; models `Entry`, `Revision`, `Settings`, `TypeSetting`, `Rule`
|
||||
- Controllers `golem15.seo.settings` (AdminSingleton), `golem15.seo.rules`, `golem15.seo.history`; permission `golem15.seo.manage`; navigation `seo`; settings tile `seo_settings`
|
||||
- Field types `seotext`, `mlseotext`, `seorobots`, `mlseorobots`, `seoimage`; elements `golem15-seo-text`, `golem15-seo-robots`, `golem15-seo-serp`, `golem15-seo-image`; widget action `seo_snippet`; partials `seo_status`, `seo_effective`, `placeholders`, `history_diff`, `staging`
|
||||
- `classes.Service`, `classes.Resolver` (`Resolve`), templates, URL/canonical builder, robots value grammar, history writer, generator
|
||||
- Route `GET /_seo/api/v1/resolve`, throttle bucket `seo-resolve`, config key `golem15.seo.site_url`
|
||||
- Job `GenerateEntriesArgs` via conga, console command `seo:generate-entries`, listeners for `*pact.RecordDeleted` and created `*pact.RecordSaved`
|
||||
- Tests `TestSEOTabTracer`, `TestSEOTab`, `TestSEOTabPermission`, `TestResolverPrecedence`, `TestSettingsTypeTabs`, `TestHistoryRecordsAdminWrite`, `TestEntryDeletedWithRecord`, `TestGenerateEntries`
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-03-SUMMARY.md` when done, listing the sm-seo-plugin commit SHAs per task and commit group, the framework tag go.mod requires, the Task 4 answer and the cabana asset-dedup observation.
|
||||
</output>
|
||||
364
.planning/phases/32-seo-foundation/32-03-SUMMARY.md
Normal file
364
.planning/phases/32-seo-foundation/32-03-SUMMARY.md
Normal file
@@ -0,0 +1,364 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 03
|
||||
subsystem: sm-seo-plugin
|
||||
tags: [seo, sm-seo-plugin, cabana, form-extensions, signpost, resolver, history, conga, custom-elements, vite]
|
||||
|
||||
requires:
|
||||
- phase: 32-01
|
||||
provides: pact.AdminFormExtension (yaml-document form, FieldsYAML, Dir, Actions, PartialData, Load, Save, Visible, Permissions)
|
||||
- phase: 32-02
|
||||
provides: pact.RecordSaved/RecordDeleted, AdminFormSave.Changes, pact.ContentDescriptor and the signpost ContentTypes/ContentType/ContentTypeForController/ContentTypeForModel/Describe/Records/MatchPath/MatchPattern lookups
|
||||
provides:
|
||||
- "New repository ../sm-seo-plugin (module git.golem15.com/golem15/sm-seo-plugin, package seo, plugin golem15.seo), branch main, 9 local commits, nothing pushed"
|
||||
- "Tables golem15_seo_entries (unique model_type, record_id, locale; data jsonb), golem15_seo_revisions, golem15_seo_settings (row 1, seeded D-07 list), golem15_seo_type_settings, golem15_seo_rules (unique url, match)"
|
||||
- "SEO tab on every content type with Content.Controller through one yaml-document AdminFormExtension per type (UI-SPEC C3 field order, anchors seo_robots and seo_og_image reserved)"
|
||||
- "Settings singleton golem15.seo.settings (settings tile link entry seo_settings) with per-type tabs added by the plugin's own FieldsYAML extension (D-104)"
|
||||
- "URL rules golem15.seo.rules and history golem15.seo.history screens; navigation item seo; permission golem15.seo.manage"
|
||||
- "classes.Service (single writer, history), classes.Resolver.Resolve/ResolveRecord with Result.Sources, robots grammar, templates, canonical and D-07 parameter handling, non-production lock"
|
||||
- "GET /_seo/api/v1/resolve (bucket seo-resolve), config keys golem15.seo.site_url and golem15.seo.unprefixed_locale"
|
||||
- "GenerateEntriesArgs conga job, seo:generate-entries command, listeners for *pact.RecordDeleted and created *pact.RecordSaved"
|
||||
- "Field types seotext, mlseotext, seorobots, mlseorobots, seoimage; elements golem15-seo-text, golem15-seo-robots, golem15-seo-serp, golem15-seo-image; widget action seo_snippet; partials seo_status, seo_effective, placeholders, type_placeholders, history_diff, staging"
|
||||
affects: [32-04, 32-05, 32-06, 33, sm-sitemap-plugin, vue-seo-layer]
|
||||
|
||||
actuals:
|
||||
tokens: 87600
|
||||
tasks: 5
|
||||
commits: 9
|
||||
plan_head_before: 1d3fa326162605533bd8ce4bf9702c05f1f92c9f
|
||||
plan_head_after: 1d3fa326162605533bd8ce4bf9702c05f1f92c9f
|
||||
|
||||
tech-stack:
|
||||
added:
|
||||
- "npm dev dependencies (exact pins, approved in Task 4): typescript 5.9.3, vite 7.3.5, vitest 3.2.7, happy-dom 20.11.6"
|
||||
- "Go: no new module outside the decided set (gorm, gormigrate, pgx, testcontainers, gocloud.dev/blob, goccy/go-yaml are framework/sibling dependencies)"
|
||||
patterns:
|
||||
- "Field-less self-extension on the plugin's own controllers (rules, settings) to record history from AdminFormSave.Changes inside the save transaction"
|
||||
- "Per-type settings tabs as a FieldsYAML document built at boot from signpost ContentTypes (tab chain after General)"
|
||||
- "Validation messages with :params translated in the controller hook (FormBeforeCreate/Update) because cabana localizes ValidationError details without params"
|
||||
- "Fake TranslationWriter in the test fixture plugin (en default, pl enabled) instead of a dependency on sm-translate-plugin"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-seo-plugin/plugin.go
|
||||
- ../sm-seo-plugin/extensions.go
|
||||
- ../sm-seo-plugin/extensions_settings.go
|
||||
- ../sm-seo-plugin/classes/resolver.go
|
||||
- ../sm-seo-plugin/classes/entries.go
|
||||
- ../sm-seo-plugin/classes/history.go
|
||||
- ../sm-seo-plugin/classes/generate.go
|
||||
- ../sm-seo-plugin/classes/snippet.go
|
||||
- ../sm-seo-plugin/classes/partials.go
|
||||
- ../sm-seo-plugin/classes/robots_value.go
|
||||
- ../sm-seo-plugin/classes/field_types.go
|
||||
- ../sm-seo-plugin/updates/202610270001_create_golem15_seo_entries.go
|
||||
- ../sm-seo-plugin/assets/src/elements/serp.ts
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/seo_tab_test.go
|
||||
- ../sm-seo-plugin/settings_test.go
|
||||
- ../sm-seo-plugin/README.md
|
||||
modified: []
|
||||
|
||||
key-decisions:
|
||||
- "Task 4 (package legitimacy, gate blocking-human) answered by Jakub before dispatch: approved. Installed exactly typescript 5.9.3, vite 7.3.5, vitest 3.2.7, happy-dom 20.11.6 (npm install --save-exact --ignore-scripts); grobotstxt v1.0.3 is approved for plan 32-04"
|
||||
- "D-91 used in its published yaml-document form: the SEO tab is one FieldsYAML document (tabs: [golem15.seo::lang.tab.seo], no anchor) and the per-type settings tabs are a FieldsYAML document built at boot; pact.AdminFormTab/AdminFormField do not exist"
|
||||
- "The resolve endpoint answers HTTP 200 for both ok and not_found (the answer's status field carries 404); 422 for a url that is neither a path nor an http(s) URL; every answer carries X-Robots-Tag: noindex"
|
||||
- "The home page / is always a known page (home template, verification meta) even without a rule or record"
|
||||
- "URL rules apply per value, most specific first: exact rules, then patterns by address length; a rule address with ? is matched against path and query"
|
||||
- "Unknown query parameters are dropped from the canonical without noindex; a path-scoped parameter row wins over a site-wide one"
|
||||
- "Robots are serialised with \",\" when stored and \", \" in the meta/X-Robots-Tag answer; the robots source is the layer that decided indexing"
|
||||
- "History stores What as text rendered in the app locale (searchable); via comes from bouncer.Dispatched (mcp) or a WithVia mark (import, auto, undo); entry deletes on RecordDeleted are recorded with via auto"
|
||||
- "The social image (seo_og_image) is one value per record written to every locale row (Q-5); seoimage uploads require golem15.seo.manage"
|
||||
- "Per-type settings and SEO tab field labels carry no :type parameter (fields.yaml labels take none; the tab title names the type)"
|
||||
|
||||
patterns-established:
|
||||
- "sm-seo-plugin controllers get the service on demand with classes.NewService(app) (no DB needed at boot, so console commands boot without a database)"
|
||||
- "Partials return curated view models with text already translated (classes.StatusView, EffectiveView, PlaceholdersView)"
|
||||
|
||||
requirements-completed: [SC-2, D-01, D-02, D-03, D-04, D-05, D-06, D-07, D-08, D-09, D-15, D-21, D-22, D-23, D-90, D-91, D-92, D-93, D-94, D-95, D-100, D-104, D-13]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "SEO tab tracer: a content type the plugin does not know gets the SEO tab through D-91; a saved SEO title lands in golem15_seo_entries and GET /_seo/api/v1/resolve returns it with absolute URLs from the site URL; the owner table has no SEO column"
|
||||
requirement: "SC-2"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestSEOTabTracer"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Precedence per value (rule > record > type/general template > content > settings) with sources; exact and pattern rules; D-07 parameter list incl. path scope; never-indexed and search paths; tag-type default robots; home template and verification meta; drafts and unknown paths not_found; non-production lock"
|
||||
requirement: "D-02"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/settings_test.go#TestResolverPrecedence"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Settings singleton with one tab per content type in registration order between General and Indexing (four fixed tabs with none), per-type defaults, template placeholder refusal, inject switch hiding the SEO tab while stored values keep working"
|
||||
requirement: "D-104"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/settings_test.go#TestSettingsTypeTabs"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "One permission golem15.seo.manage: without it no SEO fields in schema or show and a posted seo_title changes nothing; seoimage upload refused"
|
||||
requirement: "D-15"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestSEOTabPermission"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestSEOTab"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "History of admin writes (SEO tab, rule create/update/delete, settings and type settings) with author, via, changed fields before/after; history list and P5 diff; via mcp under an MCP dispatch"
|
||||
requirement: "D-13"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestHistoryRecordsAdminWrite"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Created records get their address snapshot; deleting a record removes its entries after commit and history keeps the values (via auto); GenerateEntries creates entries per published record and locale and refreshes addresses without touching editor values"
|
||||
requirement: "D-94"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestEntryDeletedWithRecord"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestGenerateEntries"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Complete SEO tab (C3 order, last tab on a tabbed form, after default on a tab-less form), malformed robots and canonical 422, seoimage upload refuses a non-image and stores one image for every locale, seo_snippet context and duplicates, P1 rule callout and P2 effective values; URL rule form partials and preview; every lang key present in en and pl"
|
||||
requirement: "D-09"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestSEOTab"
|
||||
status: pass
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestRuleFormPreview"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "../sm-seo-plugin/seo_tab_test.go#TestLangKeysComplete"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "npm --prefix ../sm-seo-plugin run typecheck && bash ../sm-seo-plugin/scripts/check-dist.sh"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D8
|
||||
description: "Elements E1 counter, E2 robots editor, E3 result preview (pixel truncation, duplicates, Q-4 keyphrase stems), E7 image upload look and behave as UI-SPEC C4-C6/C14 in the real admin SPA (layout, dark mode, keyboard, locale switcher)"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Visual and interaction behaviour inside the SPA; only a throwaway happy-dom smoke ran here, element unit tests are plan 32-06"
|
||||
|
||||
duration: 48min
|
||||
completed: 2026-10-27
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 03: SEO plugin core Summary
|
||||
|
||||
**New sm-seo-plugin (golem15.seo): an SEO tab injected into every signpost content type through the D-91 yaml-document extension, URL rules, a settings singleton with per-type tabs, change history, a conga entry-generation job, and the public GET /_seo/api/v1/resolve answering the effective SEO of any URL with the rule > record > template/global > content precedence and a source per value.**
|
||||
|
||||
## Task 4 answer (package legitimacy)
|
||||
|
||||
Jakub answered Task 4 (checkpoint:human-verify, gate blocking-human) before this run: **approved**. The orchestrator checked three things: sm-journal-plugin locks the same versions, the npm packages are published from vitejs/vite, vitest-dev/vitest and capricorn86/happy-dom through GitHub Actions, and grobotstxt resolves through proxy.golang.org.
|
||||
|
||||
- Installed exactly `typescript 5.9.3`, `vite 7.3.5`, `vitest 3.2.7` and `happy-dom 20.11.6` as dev dependencies, with `--save-exact --ignore-scripts`. `package.json` has no `dependencies` block.
|
||||
- `npm install` reported audit advisories in the dev toolchain. Journal locks the same pins. Nothing was upgraded.
|
||||
- `github.com/jimsmart/grobotstxt v1.0.3` is approved for plan 32-04. It was not installed here.
|
||||
|
||||
## Framework tag in go.mod
|
||||
|
||||
`go.mod` requires `git.golem15.com/golem15/summercms v0.5.0`, the latest existing tag. The 32-01 and 32-02 seams are not in v0.5.0 yet. Both `go.mod` and the tracked `go.work` therefore replace the framework with `../summercms.go`, as the sibling plugins do. Plan 32-06 bumps the require to the new patch tag.
|
||||
|
||||
## Cabana asset-dedup observation
|
||||
|
||||
Cabana accepted `assets/dist/seo.js` and `seo.css` listed on all five SEO field types without a boot refusal, so every type lists them. The rules controller also declares them through `pact.AdminClientAssets`, because a `type: widget` field on an owner form needs controller-declared JS.
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 48 min
|
||||
- **Started:** 2026-10-27T09:16:35Z
|
||||
- **Completed:** 2026-10-27T10:05:19Z
|
||||
- **Tasks:** 5 (Task 4 was answered before dispatch)
|
||||
- **Files:** 89 tracked files in the new repository
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Plugin scaffold.** Built on the 32-01/32-02 seams only. Content plugins import nothing: the fixture `acme.pages` registers descriptors and gets the SEO tab.
|
||||
- **Effective-SEO resolver.** Covers:
|
||||
- a source for each value;
|
||||
- canonical URLs built from `golem15.seo.site_url`;
|
||||
- the D-07 parameter list;
|
||||
- robots per directive in the C5 grammar;
|
||||
- social and verification values;
|
||||
- a non-production lock that depends on the environment only.
|
||||
- **Admin:**
|
||||
- the SEO tab (C3);
|
||||
- URL rules (C7);
|
||||
- settings (C11) with per-type tabs;
|
||||
- history (C12) with the P5 diff;
|
||||
- the navigation item, the settings tile and one permission.
|
||||
- **History and entries.** History records every admin SEO write. A record's entries are removed when it is deleted, and a new record gets an address snapshot. The generation job and its command create missing entries.
|
||||
- **Element bundle.** E1, E2, E3 and E7 with en/pl labels, built, committed and guarded by a drift check.
|
||||
|
||||
## Task Commits (../sm-seo-plugin, branch main, not pushed)
|
||||
|
||||
1. **Task 1: tracer**: `fb9590f` feat: plugin scaffold, entries and the SEO tab tracer
|
||||
2. **Task 2:**
|
||||
- A `ce60c8a` feat: URL rules and the settings singleton
|
||||
- B `30edb8a` feat: per-type settings tabs and the SEO tab permission
|
||||
- C `9f1082d` feat: full precedence resolver with value sources
|
||||
3. **Task 3:**
|
||||
- A `e8a6b9f` feat: SEO change history
|
||||
- B `ab8905c` feat: entry generation job and cleanup on delete
|
||||
4. **Task 4:** no commit (approved before dispatch, recorded above)
|
||||
5. **Task 5:**
|
||||
- A `deebd9a` feat: SEO field elements and bundle
|
||||
- B `93ddbcc` feat: SEO field types and the complete SEO tab
|
||||
- C `b38eb4b` docs: plugin README
|
||||
|
||||
Tracer feedback gate: the run was interactive, in end-of-phase mode, with an automated-only verify. TestSEOTabTracer, vet and the -short tests re-ran green before Task 2.
|
||||
|
||||
`commits: 9` is counted in ../sm-seo-plugin with `git rev-list --count HEAD` (the repository started empty). summercms.go gets only this SUMMARY's docs commit, so its `plan_head_before` and `plan_head_after` are the same SHA, taken before that commit.
|
||||
|
||||
## Files Created
|
||||
|
||||
- Root: `plugin.go`, `logger.go`, `admin.go`, `admin_permissions.go`, `admin_navigation.go`, `routes.go`, `extensions.go`, `extensions_settings.go`, `field_types.go`, `jobs.go`, `commands.go`, `listeners.go`.
|
||||
- `models/`: entry, revision, settings, type_setting and rule, with their YAML.
|
||||
- `updates/`: five raw-SQL migrations.
|
||||
- `classes/`: service, entries, resolver, templates, urls, robots_value, type_settings, history, generate, snippet, partials, image, field_types.
|
||||
- `controllers/`: admin_registry, settings, rules, history and api/resolve, with their YAML and partials.
|
||||
- `extension/`: the SEO tab partials and the per-type partial.
|
||||
- Element toolchain:
|
||||
- sources `assets/src/elements/*` and the build `assets/dist/seo.{js,css}`;
|
||||
- `package.json`, `package-lock.json`, `tsconfig.json` and `vite.config.ts`;
|
||||
- `scripts/check-dist.sh`.
|
||||
- Tests: `testmain_test.go`, `fixture_test.go`, `seo_tab_test.go`, `settings_test.go`.
|
||||
- `README.md`.
|
||||
|
||||
## Acceptance-criteria adjustments (yaml-document D-91 and other notes)
|
||||
|
||||
- **Task 1, go.mod:** `go.mod` also carries the `replace`, as Journal and Sitemap do. The go.work criterion holds.
|
||||
- **Task 1, locale map:** the tracer PUT sends `seo_title` as a locale map. cabana refuses locale maps without a `cabana.TranslationWriter`, so the fixture publishes a fake one (en default, pl enabled).
|
||||
- **Task 1, tab label:** the schema serves translated tab labels. The tracer compares the tab with "SEO", the label of `golem15.seo::lang.tab.seo`.
|
||||
- **Task 2:** `grep golem15.seo.manage admin_permissions.go` matches the doc comment. The code uses `controllers.PermissionManage`.
|
||||
- **Task 3, command grep:** `grep -n "seo:generate-entries" commands.go` prints four lines: the name, the comment and two examples.
|
||||
- **Task 3, Dispatched grep:** `grep -n "bouncer.Dispatched" classes/history.go` prints one line, as required.
|
||||
- **Task 5:** the extension's per-type placeholder partial is `extension/_type_placeholders.htm` (path `type_placeholders`), not `_placeholders.htm`. cabana refuses an extension partial name that the owner form already uses, and the settings form owns `placeholders`.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See `key-decisions` in the frontmatter.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] config/config.yaml shipped in Task 1**
|
||||
- **Issue:** the plugin asserts `pact.HasConfig` from Task 1, and the resolver needs `golem15.seo.site_url`.
|
||||
- **Fix:** `config/config.yaml` (site_url, unprefixed_locale) was committed with the tracer. Task 2 added no further key.
|
||||
- **Commit:** fb9590f
|
||||
|
||||
**2. [Rule 1 - Bug] Boot no longer requires a database**
|
||||
- **Issue:** `classes.NewService` refused to boot without a published `*gorm.DB`. The generated main publishes none for console commands, so every command of an app with the plugin would fail.
|
||||
- **Fix:** the service looks the database up when it is used.
|
||||
- **Commit:** e8a6b9f
|
||||
|
||||
**3. [Rule 3 - Blocking] Phrasebook pipes**
|
||||
- **Issue:** the phrasebook parses any `|` as plural forms. `settings.title_template_comment` ("Default: %title% | %site%") therefore failed the boot.
|
||||
- **Fix:** the copy names the default in words ("the page title, a vertical bar and the site name"). This is the only UI-SPEC copy change.
|
||||
- **Commit:** ce60c8a
|
||||
|
||||
**4. [Rule 3 - Blocking] Validation messages with parameters**
|
||||
- **Issue:** cabana localizes `ValidationError` details without parameters such as `:placeholder`.
|
||||
- **Fix:** the settings and rules checks run in `FormBeforeCreate/Update` and translate with params there (`models.Problem`). Extension refusals translate themselves.
|
||||
- **Commit:** ce60c8a, 30edb8a
|
||||
|
||||
**5. [Rule 3 - Blocking] Owner-form widget fill**
|
||||
- **Issue:** cabana lets an owner form's widget fill built-in scalar fields only. The URL rule preview therefore cannot fill `title` and `description`, which are seotext fields.
|
||||
- **Fix:** the rule form's `_seo_snippet` has no fill. Its context answers the saved rule's title and description, so the preview shows the saved rule; `savedNote` already says so.
|
||||
- **Not affected:** the SEO tab extension keeps `fill: [seo_title, seo_description, seo_keyphrase]`.
|
||||
- **Commit:** 93ddbcc
|
||||
|
||||
**6. [Rule 2 - Missing critical] Upload permission (T-32-12/T-32-13)**
|
||||
- **Issue:** cabana's field upload route does not apply extension visibility. An administrator without golem15.seo.manage could store files through the SEO tab's image field.
|
||||
- **Fix:** the `seoimage` Upload requires golem15.seo.manage. TestSEOTab covers it.
|
||||
- **Commit:** 93ddbcc
|
||||
|
||||
**7. [Rule 2 - Missing critical] History for rules and settings inside the save transaction**
|
||||
- **Fix:** field-less self-extensions on `golem15.seo.rules` and on the settings controller record `AdminFormSave.Changes`. Rule deletes are recorded in `FormAfterDelete`.
|
||||
- **Files outside the plan's Task 3 list:** `extensions.go`, `extensions_settings.go`, `controllers/rules.go`, `classes/type_settings.go`.
|
||||
- **Commit:** e8a6b9f
|
||||
|
||||
**8. [Rule 2 - Missing critical] Effective-value cache on admin saves**
|
||||
- **Issue:** duplicate checks read `effective_title` and `effective_description`, which only the job filled.
|
||||
- **Fix:** `SaveRecord` refreshes the cache for every entry it writes.
|
||||
- **Commit:** 93ddbcc
|
||||
|
||||
**9. [Plan detail] Extra files**
|
||||
- Filters: `controllers/rules/config_filter.yaml` and `controllers/history/config_filter.yaml` (C7/C12).
|
||||
- Classes: `classes/type_settings.go` and `classes/partials.go`; the extension file `extensions_settings.go`.
|
||||
- Tests: `TestRuleFormPreview` and `TestLangKeysComplete`.
|
||||
- The resolver gained `ResolveRecord`, so P2 works on drafts and on records being edited.
|
||||
|
||||
**10. [Plan detail] Per-type labels without :type**
|
||||
- fields.yaml labels take no parameters. `settings.type_inject`, `type_title_template`, `type_description_template` and `type_robots` therefore use copy without `:type`; the tab title names the type.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 10 (4 blocking, 1 bug, 3 missing critical, 2 plan detail). Of the 4 blocking ones, 3 are framework constraints.
|
||||
**Impact on plan:** behaviour is as planned. Three framework constraints are worked around inside the plugin and are candidates for framework notes:
|
||||
- phrasebook pipes;
|
||||
- validation details without parameters;
|
||||
- owner-form widget fill.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- **BLOCKER, file permissions:** the executor runs as `golem` (uid 1002, groups golem and docker). Everything in summercms.go is owned by `jin:jin` with mode 775, and `golem` is not in group `jin`. Affected:
|
||||
- `.git`;
|
||||
- `.planning/phases/32-seo-foundation`;
|
||||
- `STATE.md`, `ROADMAP.md`, `REQUIREMENTS.md`.
|
||||
|
||||
This SUMMARY could therefore not be written to the phase directory. STATE.md and ROADMAP.md could not be updated, and no docs commit could be made. The SUMMARY was staged in the executor scratchpad instead.
|
||||
- **Pre-existing failure:** `go vet ./...` and `go test -short ./...` in summercms.go fail only on `docs/examples/blog`. `docs/examples/blog/registry.gen.go` is owned by user `jin` with mode 0600; it is dated Sep 30 and carries another session's uncommitted edit. Every other package is green, and this plan does not change the framework.
|
||||
- **Element tests:** element unit tests belong to plan 32-06. A throwaway happy-dom smoke passed and was not committed. It covered the robots round-trip, the stem rule and E1/E2/E3 behaviour.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None. Redirects, robots.txt, the 404 log, MCP, undo and CSV belong to plans 32-04 and 32-05 by design. The navigation item lands on URL rules until the redirects screen exists.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
| Flag | File | Description |
|
||||
|------|------|-------------|
|
||||
| threat_flag: upload | ../sm-seo-plugin/classes/image.go | New file-storage path (media/seo/) through the seoimage upload route; mitigated by the permission check, content sniffing, a size cap and a random file name (T-32-12) |
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. A site sets `golem15.seo.site_url`, or relies on `app.url`.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- **Plan 32-04** builds on `classes.Service`, `Resolver.Resolve`, the settings address columns, the listeners and `routes.go`.
|
||||
- **Plan 32-05** builds on the history core (`Record`, `WithVia`), the rule and settings writers, and `golem15.seo.manage`.
|
||||
- **Nothing pushed:** `git -C ../sm-seo-plugin status -sb` shows `## main` with no upstream, and `ls-remote origin` is empty.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- All key files exist. Commits fb9590f, ce60c8a, 30edb8a, 9f1082d, e8a6b9f, ab8905c, deebd9a, 93ddbcc and b38eb4b are present in ../sm-seo-plugin.
|
||||
- `go -C ../sm-seo-plugin vet ./...`, `go test -short ./...` and `go test -count=1 ./...` (Docker) are green. The Docker run covers:
|
||||
- TestSEOTabTracer, TestSEOTabPermission, TestSEOTab, TestRuleFormPreview;
|
||||
- TestHistoryRecordsAdminWrite, TestEntryDeletedWithRecord, TestGenerateEntries;
|
||||
- TestLangKeysComplete, TestSettingsTypeTabs, TestResolverPrecedence.
|
||||
- `npm run typecheck` and `scripts/check-dist.sh` are green.
|
||||
- `grep -rn sm-seo-plugin ../sm-journal-plugin --include=*.go` is empty.
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-27*
|
||||
414
.planning/phases/32-seo-foundation/32-04-PLAN.md
Normal file
414
.planning/phases/32-seo-foundation/32-04-PLAN.md
Normal file
@@ -0,0 +1,414 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 04
|
||||
type: execute
|
||||
wave: 4
|
||||
depends_on: ["32-03"]
|
||||
files_modified:
|
||||
- .planning/notes/2026-10-27-robots-txt-grobotstxt.md
|
||||
- .planning/research/STACK.md
|
||||
- ../sm-seo-plugin/go.mod
|
||||
- ../sm-seo-plugin/go.sum
|
||||
- ../sm-seo-plugin/admin_navigation.go
|
||||
- ../sm-seo-plugin/extensions.go
|
||||
- ../sm-seo-plugin/listeners.go
|
||||
- ../sm-seo-plugin/routes.go
|
||||
- ../sm-seo-plugin/field_types.go
|
||||
- ../sm-seo-plugin/config/config.yaml
|
||||
- ../sm-seo-plugin/lang/en/lang.yaml
|
||||
- ../sm-seo-plugin/lang/pl/lang.yaml
|
||||
- ../sm-seo-plugin/README.md
|
||||
- ../sm-seo-plugin/models/redirect.go
|
||||
- ../sm-seo-plugin/models/redirect/fields.yaml
|
||||
- ../sm-seo-plugin/models/redirect/columns.yaml
|
||||
- ../sm-seo-plugin/models/notfound.go
|
||||
- ../sm-seo-plugin/models/notfound/fields.yaml
|
||||
- ../sm-seo-plugin/models/notfound/columns.yaml
|
||||
- ../sm-seo-plugin/models/robots.go
|
||||
- ../sm-seo-plugin/models/robots/fields.yaml
|
||||
- ../sm-seo-plugin/updates/202610270006_create_golem15_seo_redirects.go
|
||||
- ../sm-seo-plugin/updates/202610270007_create_golem15_seo_notfound.go
|
||||
- ../sm-seo-plugin/updates/202610270008_create_golem15_seo_robots.go
|
||||
- ../sm-seo-plugin/controllers/admin_registry.go
|
||||
- ../sm-seo-plugin/controllers/redirects.go
|
||||
- ../sm-seo-plugin/controllers/redirects/config_list.yaml
|
||||
- ../sm-seo-plugin/controllers/redirects/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/notfound.go
|
||||
- ../sm-seo-plugin/controllers/notfound/config_list.yaml
|
||||
- ../sm-seo-plugin/controllers/notfound/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/notfound/_hint.htm
|
||||
- ../sm-seo-plugin/controllers/robots.go
|
||||
- ../sm-seo-plugin/controllers/robots/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/robots/_staging.htm
|
||||
- ../sm-seo-plugin/controllers/robots/_robots_served.htm
|
||||
- ../sm-seo-plugin/controllers/api/resolve.go
|
||||
- ../sm-seo-plugin/controllers/api/notfound.go
|
||||
- ../sm-seo-plugin/controllers/api/verification.go
|
||||
- ../sm-seo-plugin/controllers/api/robots.go
|
||||
- ../sm-seo-plugin/extension/_seo_status.htm
|
||||
- ../sm-seo-plugin/classes/redirects.go
|
||||
- ../sm-seo-plugin/classes/redirect_graph.go
|
||||
- ../sm-seo-plugin/classes/addresses.go
|
||||
- ../sm-seo-plugin/classes/normalize.go
|
||||
- ../sm-seo-plugin/classes/strict.go
|
||||
- ../sm-seo-plugin/classes/resolver.go
|
||||
- ../sm-seo-plugin/classes/notfound.go
|
||||
- ../sm-seo-plugin/classes/robots.go
|
||||
- ../sm-seo-plugin/classes/bots.go
|
||||
- ../sm-seo-plugin/classes/verification.go
|
||||
- ../sm-seo-plugin/classes/field_types.go
|
||||
- ../sm-seo-plugin/assets/src/elements/index.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/labels.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/robotstxt.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/robotstester.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/styles.css
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/assets/dist/seo.css
|
||||
- ../sm-seo-plugin/redirects_test.go
|
||||
- ../sm-seo-plugin/robots_test.go
|
||||
- ../sm-seo-plugin/addresses_test.go
|
||||
autonomous: true
|
||||
requirements: [SC-3, D-16, D-17, D-18, D-19, D-20, D-20a, D-20b, D-20c, D-22, D-24, D-25, D-05, D-08, D-06, D-99, D-103, D-105, D-92, D-102]
|
||||
|
||||
estimate:
|
||||
tokens: 170000
|
||||
raw_tokens: 170000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Changing a published record's slug or path in the admin creates a 301 from the old URL to the new one in the same transaction, flattens existing chains (A→B then B→C becomes A→C) and shows the redirects.auto_created notice; the same happens after commit for writes through Journal's API, MCP or imports (SC-3, D-18, D-92, D-102)"
|
||||
- "Deleting or unpublishing a record creates no redirect; its URL answers not_found and appears in the 404 log when reported (D-18, D-20)"
|
||||
- "Redirects support 301, 302 and 410, exact, wildcard and regex sources with ignore-case, trailing-slash and query ignore/pass options, evaluated exact, then patterns, then regex (D-16, D-17)"
|
||||
- "A redirect loop is refused from the admin with redirects.loop on target and nothing saved; a chain is saved with the redirects.chain_notice (SC-3, D-19)"
|
||||
- "Slug changed back and forth (A→B, then B→A, then A→C) ends with exactly A→C and B→C (RESEARCH Pitfall 11)"
|
||||
- "GET /_seo/api/v1/resolve answers the redirect decision: action redirect with status and location, action gone with 410, normalisation and strict-URL 301s, reaching the final address in one hop; at runtime a cycle stops after 10 hops with not_found and a log line (D-20a, D-20b, D-20c, D-103)"
|
||||
- "URL normalisation per site: https, www or bare host, trailing slash add/remove, optional ASCII lowercasing, double slashes and /index.html collapsed, all defaults Do not change and lowercase off (D-20b, UI-SPEC Q-7)"
|
||||
- "Strict URLs: a URL whose segments (category, locale prefix) do not match an existing record 301s to the record's canonical URL; a wrong URL never answers ok (D-20c)"
|
||||
- "The 404 log stores URL, hits, first seen, last hit and referer from an authenticated server-to-server report; Create redirect… (prompted 301) and Mark as gone (410, record and bulk) resolve an entry (D-20)"
|
||||
- "GET /robots.txt serves the stored rules, the AI bot groups for switched-off bots and the Sitemap line(s); outside production it serves User-agent: * / Disallow: / with X-Robots-Tag noindex whatever is stored; it never answers 5xx (D-22, D-25)"
|
||||
- "The robots.txt editor validates live (E4) and refuses over 500 KB; the tester (E5) answers allowed or blocked with the matching line through grobotstxt, including unsaved text and AI switches (D-22, D-99)"
|
||||
- "AI bot switches cover OAI-SearchBot, Claude-SearchBot, PerplexityBot, ChatGPT-User, Claude-User, GPTBot, ClaudeBot, Google-Extended, Applebot-Extended, CCBot and Meta-ExternalAgent, all allowed by default, with search, user-fetch and training kinds (D-25, D-105)"
|
||||
- "Saving robots.txt warns when it blocks a noindex address so Googlebot cannot see the noindex (D-24)"
|
||||
- "Verification files are served by GET /_seo/api/v1/verification/{name}; no Go route is registered at the site root for them (D-05, D-103)"
|
||||
- "The canonical-redirected warning (status.canonical_redirected) shows in P1 when a canonical URL redirects (D-06)"
|
||||
- "Redirects list: empty state redirects.list_empty; six visible columns with the Chain badge on chain rows; filters status, match, origin and chain (UI-SPEC empty, populated)"
|
||||
- "404 log: empty state notfound.list_empty; sorted by hits with Resolved badges; bulk Mark as gone with a plural confirm, and one already-covered row refuses the whole selection with notfound.has_rule (UI-SPEC empty, populated, zero-one-many)"
|
||||
- "A refused record action shows the danger toast with the server Message (notfound.has_rule, redirects.loop) (UI-SPEC error)"
|
||||
- "All SEO lists use the existing pagination and horizontal scroll with long URLs wrapped by the existing cell rules; URLs in P5, E5 results and toasts wrap with overflow-wrap anywhere (UI-SPEC overflow, long-text)"
|
||||
- "E4 with empty content shows clean, 0 KB and P4 shows only the generated lines; long lines scroll horizontally and at most 10 findings plus moreFindings show (UI-SPEC empty, overflow)"
|
||||
- "E5 and robots screens outside production show stagingNote and the staging callout, and P4 shows the served and the production version (UI-SPEC partial)"
|
||||
prohibitions:
|
||||
- statement: "A redirect loop is never saved, from the admin, MCP or an import (D-19)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "/robots.txt never answers a 5xx status, and the non-production lock can never be turned off from the admin (D-22)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "A regex capture or a passed-through query never turns an internal redirect target into an external host"
|
||||
status: resolved
|
||||
verification: test
|
||||
artifacts:
|
||||
- path: "../sm-seo-plugin/classes/redirect_graph.go"
|
||||
provides: "loop simulation, chain detection, flattening"
|
||||
contains: "func "
|
||||
- path: "../sm-seo-plugin/classes/addresses.go"
|
||||
provides: "address-change 301 from the descriptor URL diff"
|
||||
contains: "func (s *Service) AddressChanged("
|
||||
- path: "../sm-seo-plugin/classes/robots.go"
|
||||
provides: "served file composition, staging lock, grobotstxt tester"
|
||||
contains: "grobotstxt"
|
||||
- path: ".planning/notes/2026-10-27-robots-txt-grobotstxt.md"
|
||||
provides: "decision note naming github.com/jimsmart/grobotstxt v1.0.3 (D-99)"
|
||||
contains: "github.com/jimsmart/grobotstxt"
|
||||
- path: "../sm-seo-plugin/redirects_test.go"
|
||||
provides: "TestSlugChange301, TestLoopRefused (admin)"
|
||||
contains: "func TestSlugChange301("
|
||||
key_links:
|
||||
- from: "../sm-seo-plugin/extensions.go"
|
||||
to: "../sm-seo-plugin/classes/addresses.go"
|
||||
via: "the SEO tab extension's Save compares Describe URLs with the entry URLs and calls AddressChanged inside the save transaction"
|
||||
pattern: "AddressChanged\\("
|
||||
- from: "../sm-seo-plugin/listeners.go"
|
||||
to: "../sm-seo-plugin/classes/addresses.go"
|
||||
via: "*pact.RecordSaved listener runs the same URL diff after commit for non-admin writers"
|
||||
pattern: "\\*pact\\.RecordSaved"
|
||||
- from: "../sm-seo-plugin/routes.go"
|
||||
to: "../sm-seo-plugin/controllers/api/robots.go"
|
||||
via: "r.Get(\"/robots.txt\", ...) throttled, outside any backend middleware"
|
||||
pattern: "/robots.txt"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
<!-- planner-discipline-allow: jimsmart/grobotstxt -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan delivers redirects (including the automatic 301 on an address change), the 404 log, URL normalisation, strict URLs and robots.txt with AI bots and verification files.
|
||||
|
||||
<objective>
|
||||
Extend `sm-seo-plugin` with D-16 to D-20c and D-22 to D-25:
|
||||
- the redirect engine (301/302/410; exact, wildcard, regex; options; order), loop refusal and chain notices, chain flattening (D-16, D-17, D-19);
|
||||
- the automatic 301 when a record's URL changes, from the descriptor URL diff in the SEO tab's Save (same transaction) and in a `RecordSaved` listener for Journal's API, MCP and imports (D-18, D-92, D-102);
|
||||
- the 404 log with an authenticated report endpoint and one-click redirect or 410 (D-20);
|
||||
- URL normalisation (D-20b) and strict URLs (D-20c) folded into the resolve answer as the redirect decision endpoint (D-20a, D-103; the Nuxt layer enforces it in Phase 33, no fourth framework seam);
|
||||
- the robots.txt editor (E4), tester (E5) on `github.com/jimsmart/grobotstxt` v1.0.3 with its decision note (D-99), AI bot switches including `Claude-User` (D-25, D-105), the noindex-blocked warning (D-24), `GET /robots.txt` with the non-production lock and `X-Robots-Tag` (D-22, D-08);
|
||||
- verification files through `GET /_seo/api/v1/verification/{name}` only (D-05, D-103).
|
||||
|
||||
Purpose: SC-3 (changing a record's slug creates a 301 and flattens existing chains; loops are refused from the admin; MCP and import refusal is plan 32-05 on the same service).
|
||||
|
||||
Output: commits in `../sm-seo-plugin` (main, not pushed), the decision note and STACK row in this repository as a planning-docs commit. Which plan implements each decision of the phase, and what Phase 33 takes, is in `32-DECISIONS-MAP.md`.
|
||||
|
||||
**Planner decisions recorded here:**
|
||||
- **P-18 (one service path for redirects):** every redirect write (admin form, address change, 404 actions, and later MCP/batch/CSV) goes through `classes.Service` methods `SaveRedirect`, `AddressChanged`, `DeleteRedirect`, which run the loop simulation and flattening inside the caller's transaction and write history. The Redirects form gets its loop error and chain notice from a field-less D-91 extension the plugin registers on its own `golem15.seo.redirects` controller (Save returns `pact.AdminFormErrors{"target": ...}` or a notice on `target`), because owner controllers have no notice hook.
|
||||
- **P-19 (loop detection, RESEARCH Pitfall 10):** simulate with the candidate rule in place: take the rule's target, or a probe instance of a pattern source with `*` replaced by `seoprobe`, or, for regex, a probe string built from `regexp/syntax` literals when one can be built; run the redirect stage up to 10 hops; a repeated URL refuses with the hop path, more than one hop answers the chain notice. At runtime the same 10-hop cap answers not_found and logs once per URL.
|
||||
- **P-20 (address change, RESEARCH Pattern 6 and Pitfall 11):** for each locale whose Describe URL differs from the entry URL of a record that was published: delete rules whose exact source equals the new URL, create old → new (301, origin slug), re-point exact rules whose target is the old URL, drop self-loops, update the entry URL, write a revision with via auto. The notice `redirects.auto_created` goes on the owner field whose name equals a placeholder of the type's pattern that appears in `AdminFormSave.Changes` (for example `slug`), else on `seo_status`.
|
||||
- **P-21 (one-hop decision):** resolve runs lock flag → normalisation (all configured rewrites at once) → redirects on the normalised path, following rules to the final target → strict URL → SEO; when normalisation changed the URL or a redirect matched, the answer's location is the final target, so a visitor makes one hop.
|
||||
- **P-22 (404 report):** `POST /_seo/api/v1/notfound` with `Authorization: Bearer <golem15.seo.notfound_token>` (config; constant-time comparison; endpoint answers 404 when the token is unset), body `{url, referer}`; URL capped at 2048 bytes and referer at 1024; at most `golem15.seo.notfound_max_rows` rows (default 10000), new URLs beyond it are dropped with one warning per hour (RESEARCH A6).
|
||||
- **P-23 (Sitemap lines):** one `Sitemap:` line per entry of config `golem15.seo.robots_sitemaps` (default `["/sitemap.xml"]`), absolute on the site URL; Phase 33's sitemap rewrite replaces the default with its index.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-RESEARCH.md
|
||||
@.planning/phases/32-seo-foundation/32-UI-SPEC.md
|
||||
@.planning/phases/32-seo-foundation/32-03-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
|
||||
<interfaces>
|
||||
From plan 32-03 (sm-seo-plugin): classes.Service (single writer, history), classes.Resolver.Resolve(ctx, rawURL) (Result with per-value sources), entries keyed by (model_type, record_id, locale) with url; settings columns url_host, url_slash, url_lowercase, verify_files; extensions.go SEO tab extension with Save(in pact.AdminFormSave) and in.Changes; listeners.go registering *pact.RecordDeleted and created *pact.RecordSaved; routes.go group /_seo/api/v1 and Buckets(); P-15 resolve JSON.
|
||||
From plan 32-02: signpost Registry Describe(ctx, key, id, unprefixed) and MatchPath(ctx, path, unprefixed) → (key, *pact.ContentMatchResult{ID, Locale, Exact}); pact.RecordSaved{Controller, Model, ID, Locale, Created, Changes}.
|
||||
From plan 32-01: field-less extensions with only Save are valid; AdminFormErrors → 422 field lines; Notices may name owner fields.
|
||||
pact.AdminRecordAction{Name, Label, Confirm, Permissions, Danger, Prompt *AdminActionPrompt, Applies, Run}; pact.AdminBulkAction; pact.ListRowStates / RowState; analog ../sm-paymentgateway-plugin/controllers/orders.go 106-155.
|
||||
grobotstxt (pkg.go.dev): NewRobotsMatcher(); (*RobotsMatcher).AgentAllowed(robotsBody, userAgent, uri string) bool; MatchingLine() int (0 when no rule matched).
|
||||
Route analog: ../sm-sitemap-plugin/routes.go 43-60 (r.Get("/sitemap.xml", handler, "throttle:"+bucket)).
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
## Execution units and resume points
|
||||
|
||||
Each task is a resumable unit, and Task 4 (robots.txt, AI bots, verification files and the decision note) is split into five commit groups, so the plan can run across several executor contexts without losing work:
|
||||
- Every task ends with the commit groups listed below, in order: `git -c safe.directory='*' -C ../sm-seo-plugin add <paths of the group>` (paths only, never `-A` or `.`), then `commit -m "<subject>"`; G1 is a planning-docs commit in this repository. No task leaves uncommitted files for the next one, every commit keeps `go vet ./...` and `go test -short ./...` green, and each group adds the lang keys it uses to both lang files. TDD test commits may precede a group's commit.
|
||||
- Resume check before each task: `git -c safe.directory='*' -C ../sm-seo-plugin log --format=%s | grep -Fx '<subject>'` for each plugin subject, and `git log --format=%s | grep -Fx '<subject>'` here for G1. All present: the task is done; re-run its `<verify>` and go on. Some present: continue at the first missing group. None: start the task.
|
||||
- An executor whose context is getting heavy stops after a task's (or a Task 4 group's) last commit and returns its completed table (task, group, subject, SHA); the continuation starts at the next missing group.
|
||||
- `admin.go` embeds admin YAML and partials by glob since plan 32-03 Task 2, so new screens need no edit there. If 32-03-SUMMARY.md records file-by-file embeds instead, add each new file to `admin.go` and stage it with its group.
|
||||
|
||||
| Task | Commit groups, in order | Resume point after the task |
|
||||
|------|-------------------------|-----------------------------|
|
||||
| 1 | `feat: address-change 301 (tracer)` | TestSlugChange301 passes |
|
||||
| 2 | A `feat: redirect engine with loop refusal and chain notices`; B `feat: redirects screen`; C `feat: 404 log and report endpoint`; D `feat: address-change redirects for writes outside the admin` | the engine, both screens and the listener work |
|
||||
| 3 | `feat: URL normalisation, strict URLs and the one-hop redirect decision` | resolve is the redirect decision endpoint |
|
||||
| 4 | G1 (this repository) `docs(32-04): grobotstxt decision note`; G2 `feat: robots.txt served file, AI bots and the non-production lock`; G3 `feat: robots.txt editor and tester screen`; G4 `feat: verification files API`; G5 `docs: robots.txt, AI bots and verification files in README` | plan complete; write 32-04-SUMMARY.md |
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: End-to-end "an editor changes a record's slug and the old URL resolves to a 301 to the new one" — one path only</name>
|
||||
<files>../sm-seo-plugin/models/redirect.go, ../sm-seo-plugin/updates/202610270006_create_golem15_seo_redirects.go, ../sm-seo-plugin/classes/redirects.go, ../sm-seo-plugin/classes/addresses.go, ../sm-seo-plugin/classes/resolver.go, ../sm-seo-plugin/extensions.go, ../sm-seo-plugin/controllers/api/resolve.go, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/redirects_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-seo-plugin/extensions.go, classes/service.go, classes/resolver.go, classes/entries.go (plan 32-03)
|
||||
- ../sm-seo-plugin/fixture_test.go and seo_tab_test.go (fake content plugin and admin harness)
|
||||
- summercms.go/modules/pact/record_events.go and modules/signpost/content.go
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Pattern 6, Pitfall 11)
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-18 and P-20: add the redirects table (id, source, match exact|pattern|regex, target, status 301|302|410, query ignore|pass, ignore_case bool, trailing_slash bool default true, origin manual|slug|import|mcp|notfound, note, timestamps; unique (source, match); the model and the migration register themselves through `models.Register` and `updates.Register` in their own files); `classes/redirects.go` exact-source lookup only for the tracer; `classes/addresses.go` `(*Service).AddressChanged(ctx, tx, change AddressChange) (AddressResult, error)` implementing P-20; in the SEO tab extension's Save compare `Describe` URLs (read through the transaction) with the stored entry URLs and call AddressChanged per changed locale, returning the `redirects.auto_created` notice (P-20 field choice); the resolver answers `{"action":"redirect","status":301,"location":<absolute new URL>}` for an exact redirect source. `TestSlugChange301` in `redirects_test.go`: create a published fake page /pages/a with an entry, PUT slug b through the admin API (response Meta.Notices contains the auto_created notice), then resolve /pages/a → redirect 301 to the absolute /pages/b, resolve /pages/b → ok; an earlier redirect /pages/x → /pages/a now points to /pages/b. Commit (resume unit, see Execution units): stage exactly this task's `<files>` paths in ../sm-seo-plugin and commit `feat: address-change 301 (tracer)`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestSlugChange301' -count=1 -v 2>&1 | tail -20</automated>
|
||||
<fails_when>non-zero exit, "FAIL" or "no tests to run" in the output, or no "--- PASS: TestSlugChange301" line</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "func (s \*Service) AddressChanged(" ../sm-seo-plugin/classes/addresses.go` prints one line
|
||||
- `grep -n "AddressChanged(" ../sm-seo-plugin/extensions.go` prints at least one line
|
||||
- `TestSlugChange301` asserts status 301, the absolute location and the flattened earlier redirect, and passes
|
||||
</acceptance_criteria>
|
||||
<done>An admin slug change creates the 301 in the save transaction, flattens the earlier redirect, tells the editor, and the resolve answer redirects the old URL.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 2: Full redirect engine, Redirects screen with loop refusal and chain notice, 404 log, and the RecordSaved listener for non-admin writes</name>
|
||||
<files>../sm-seo-plugin/classes/redirects.go, ../sm-seo-plugin/classes/redirect_graph.go, ../sm-seo-plugin/classes/addresses.go, ../sm-seo-plugin/classes/notfound.go, ../sm-seo-plugin/models/redirect.go, ../sm-seo-plugin/models/redirect/fields.yaml, ../sm-seo-plugin/models/redirect/columns.yaml, ../sm-seo-plugin/models/notfound.go, ../sm-seo-plugin/models/notfound/fields.yaml, ../sm-seo-plugin/models/notfound/columns.yaml, ../sm-seo-plugin/updates/202610270007_create_golem15_seo_notfound.go, ../sm-seo-plugin/controllers/admin_registry.go, ../sm-seo-plugin/controllers/redirects.go, ../sm-seo-plugin/controllers/redirects/config_list.yaml, ../sm-seo-plugin/controllers/redirects/config_form.yaml, ../sm-seo-plugin/controllers/notfound.go, ../sm-seo-plugin/controllers/notfound/config_list.yaml, ../sm-seo-plugin/controllers/notfound/config_form.yaml, ../sm-seo-plugin/controllers/notfound/_hint.htm, ../sm-seo-plugin/controllers/api/notfound.go, ../sm-seo-plugin/extensions.go, ../sm-seo-plugin/listeners.go, ../sm-seo-plugin/routes.go, ../sm-seo-plugin/admin_navigation.go, ../sm-seo-plugin/config/config.yaml, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/redirects_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-paymentgateway-plugin/controllers/orders.go (record actions with Applies/Run, bulk actions, FilterOptions, ListExtendQuery)
|
||||
- summercms.go/modules/pact/capabilities.go (AdminRecordAction, AdminActionPrompt 370, AdminBulkAction 287, RowState 878-906)
|
||||
- summercms.go/docs/backend/admin-controllers.md (Record actions, Bulk actions)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C2, C8, C9, Copywriting: Redirects, 404 log, Destructive actions)
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Pitfalls 10, 11; Code Examples: wildcard source to anchored regex; Security: open redirect, ReDoS, 404 flooding)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- Exact source /old → 301 /new; ignore_case matches /OLD; trailing_slash matches /old/; query ignore drops ?a=1, pass appends it to the target; a source containing ? matches its query exactly (Q-9)
|
||||
- Wildcard /old/* → /new/* maps /old/x/y to /new/x/y; regex ^/p/(\d+)$ → /post/$1 maps /p/12 to /post/12; exact wins over pattern, pattern over regex
|
||||
- 410 rule: action gone, no location; 410 with a target refused (redirects.target_gone); 301 without target refused (redirects.target_required); invalid regex refused (redirects.regex_invalid); duplicate source and match refused (redirects.source_taken); source not starting with / refused (redirects.source_invalid); regex longer than 512 characters refused
|
||||
- A → B saved, then B → A refused with redirects.loop naming A → B → A; /old/* → /old/new/* refused (pattern probe); A → B with B → C existing saved with chain_notice naming the final target C
|
||||
- Back and forth: A→B, B→A (as an address change), then A→C ends with exactly A→C and B→C
|
||||
- A regex capture substituted into a relative target never yields an absolute URL to another host; an external target is allowed only when the target literal is absolute
|
||||
- 404 report with the right token upserts url, increments hits, keeps first_seen, updates last_hit and referer; wrong or missing token → 401; unset token → 404; URL over 2048 bytes → 422
|
||||
- 404 record action redirect (prompt value /new) creates a 301 with origin notfound and the row turns Resolved; gone creates a 410; bulk gone over a selection containing an already-covered URL refuses the whole selection with notfound.has_rule
|
||||
- Journal-style write outside cabana (RecordSaved with a slug change and Controller "") creates the 301 after commit; RecordSaved without a URL change creates nothing; an unpublished record's change creates nothing
|
||||
</behavior>
|
||||
<action>
|
||||
Implement D-16, D-17, D-19, D-20, D-18 for non-admin writers, per P-18, P-19, P-22 and the behaviour list. `classes/redirects.go`: compiled rule set (exact map, wildcard rules ordered by longest literal prefix then id, regex rules by id, compiled once per change with stdlib regexp; wildcard via `regexp.QuoteMeta` with `*` → `(.*)`); `classes/redirect_graph.go`: simulation, loop and chain detection, flattening. Redirects screen `golem15.seo.redirects` per C8 (list columns, filters, row state `negative` labelled `redirects.state_chain` when the target is another rule's source; form layout) and the field-less self-extension of P-18. 404 log `golem15.seo.notfound` per C9 (list by hits desc, preview with `_hint.htm`, prompted `redirect` and danger `gone` record actions, bulk `gone`, row state `disabled` labelled Resolved computed through the rule set). `controllers/api/notfound.go` + route `POST /_seo/api/v1/notfound` (throttle bucket `seo-notfound`) per P-22, config keys `golem15.seo.notfound_token` (default empty) and `golem15.seo.notfound_max_rows` (default 10000) in `config/config.yaml`. `listeners.go`: `*pact.RecordSaved` for a model with a content type re-describes the record after commit in its own transaction and calls AddressChanged per changed locale (no-op when the admin Save already updated the entry). Navigation per UI-SPEC C2: item `seo` lands on `golem15.seo.redirects`, side menu Redirects, 404 log, URL rules, robots.txt, History, Import and export (robots.txt comes in Task 4 and Import and export in plan 32-05; add each side-menu entry when its controller exists). Write the tests first (`TestRedirectEngine`, `TestLoopRefused` admin path, `TestNotFoundLog`, `TestAddressChangeFromEvent` in `redirects_test.go`).
|
||||
Commits (resume units, see Execution units), staged by path in ../sm-seo-plugin, in this order:
|
||||
- A `feat: redirect engine with loop refusal and chain notices`: classes/redirects.go, classes/redirect_graph.go, classes/addresses.go, models/redirect.go, redirects_test.go (TestRedirectEngine);
|
||||
- B `feat: redirects screen`: models/redirect/fields.yaml, models/redirect/columns.yaml, controllers/redirects.go, controllers/redirects/config_list.yaml, controllers/redirects/config_form.yaml, controllers/admin_registry.go, extensions.go, admin_navigation.go, lang files, redirects_test.go (TestLoopRefused admin path);
|
||||
- C `feat: 404 log and report endpoint`: models/notfound.go, models/notfound/fields.yaml, models/notfound/columns.yaml, the notfound migration, classes/notfound.go, controllers/notfound.go, controllers/notfound/config_list.yaml, controllers/notfound/config_form.yaml, controllers/notfound/_hint.htm, controllers/api/notfound.go, controllers/admin_registry.go, admin_navigation.go, routes.go, config/config.yaml, lang files, redirects_test.go (TestNotFoundLog);
|
||||
- D `feat: address-change redirects for writes outside the admin`: listeners.go, redirects_test.go (TestAddressChangeFromEvent).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestRedirectEngine|TestLoopRefused|TestNotFoundLog|TestAddressChangeFromEvent|TestSlugChange301' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -40</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the five names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "subtle.ConstantTimeCompare" ../sm-seo-plugin/controllers/api/notfound.go` prints one line
|
||||
- `grep -n "\*pact.RecordSaved" ../sm-seo-plugin/listeners.go` prints one line
|
||||
- `grep -rn "regexp.MustCompile(.*source\|dlclark\|regexp2" ../sm-seo-plugin --include=*.go` prints nothing (stdlib RE2 only, no panicking compile on stored input)
|
||||
- `TestLoopRefused` asserts a 422 with `redirects.loop` on `target` and that the redirects table row count is unchanged
|
||||
- the redirect form, list and 404 screens use only lang keys present in both lang files
|
||||
</acceptance_criteria>
|
||||
<done>The redirect engine, loop refusal, chain notices, the 404 log with its actions and the after-commit address-change path for non-admin writers work and are smoke-tested.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: URL normalisation, strict URLs and the one-hop redirect decision in resolve</name>
|
||||
<files>../sm-seo-plugin/classes/normalize.go, ../sm-seo-plugin/classes/strict.go, ../sm-seo-plugin/classes/resolver.go, ../sm-seo-plugin/controllers/api/resolve.go, ../sm-seo-plugin/extension/_seo_status.htm, ../sm-seo-plugin/addresses_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-seo-plugin/classes/resolver.go, classes/urls.go (plan 32-03) and classes/redirects.go (Task 2)
|
||||
- summercms.go/modules/signpost/content.go (MatchPath, Exact semantics)
|
||||
- .planning/phases/32-seo-foundation/32-CONTEXT.md (D-20b, D-20c) and 32-RESEARCH.md (Pitfall 13, Pitfall 15)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C11 Addresses tab, Q-7)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- With defaults (keep, keep, lowercase off): http://site/a → 301 https://site/a; //a//b → /a/b; /blog/index.html → /blog; a clean URL → ok
|
||||
- url_host www: https://site.tld/a → https://www.site.tld/a; url_slash add: /a → /a/; url_slash remove: /a/ → /a (the root / is never changed)
|
||||
- Lowercase on: /Blog/Post → /blog/post; /Łódź keeps its non-ASCII letters; %C5%81 stays equivalent (Pitfall 13)
|
||||
- A non-normalised URL whose normalised form is a redirect source answers one 301 straight to the final target
|
||||
- Strict: /wrong-category/post-slug (pattern /:category/:slug) → 301 to the post's canonical URL; /pl/<default-locale-slug> → 301 to the pl URL; a matching URL → ok
|
||||
- Runtime cycle (seeded directly in the table) stops after 10 hops with not_found
|
||||
- P1 shows status.canonical_redirected when the record's canonical URL is a redirect source
|
||||
</behavior>
|
||||
<action>
|
||||
Implement D-20a, D-20b, D-20c and D-103 per P-21 and the behaviour list: `classes/normalize.go` pure `Normalize(u *url.URL, opts NormalizeOptions) (*url.URL, bool)`; `classes/strict.go` through signpost `MatchPath` and `Describe`; the resolver pipeline order of P-21 with the runtime hop cap; the resolve answer gains `redirect` and `gone` actions (status, location absolute on the site URL, never from the request Host); P1 gains the canonical-redirected callout (D-06). Tests first: `TestNormalize`, `TestStrictURL`, `TestOneHop` in `addresses_test.go`. Commit (resume unit, see Execution units): stage exactly this task's `<files>` paths in ../sm-seo-plugin and commit `feat: URL normalisation, strict URLs and the one-hop redirect decision`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestNormalize|TestStrictURL|TestOneHop' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -30</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the three names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "func Normalize(" ../sm-seo-plugin/classes/normalize.go` prints one line
|
||||
- `grep -n "MatchPath(" ../sm-seo-plugin/classes/strict.go` prints one line
|
||||
- `TestOneHop` asserts that the answer's location equals the final target for a URL that needs normalisation and then a redirect
|
||||
- `TestNormalize` includes a Polish non-ASCII case
|
||||
</acceptance_criteria>
|
||||
<done>The resolve answer is the redirect decision endpoint: normalisation, redirects and strict URLs reach the final address in one hop, and a wrong URL never answers ok.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: robots.txt editor, tester, AI bots, GET /robots.txt with the non-production lock, verification files, and the grobotstxt decision note</name>
|
||||
<precondition>Plan 32-03 Task 4 answered "approved" for github.com/jimsmart/grobotstxt v1.0.3 (recorded in 32-03-SUMMARY.md)</precondition>
|
||||
<files>.planning/notes/2026-10-27-robots-txt-grobotstxt.md, .planning/research/STACK.md, ../sm-seo-plugin/go.mod, ../sm-seo-plugin/go.sum, ../sm-seo-plugin/models/robots.go, ../sm-seo-plugin/models/robots/fields.yaml, ../sm-seo-plugin/updates/202610270008_create_golem15_seo_robots.go, ../sm-seo-plugin/controllers/robots.go, ../sm-seo-plugin/controllers/robots/config_form.yaml, ../sm-seo-plugin/controllers/robots/_staging.htm, ../sm-seo-plugin/controllers/robots/_robots_served.htm, ../sm-seo-plugin/controllers/api/robots.go, ../sm-seo-plugin/controllers/api/verification.go, ../sm-seo-plugin/classes/robots.go, ../sm-seo-plugin/classes/bots.go, ../sm-seo-plugin/classes/verification.go, ../sm-seo-plugin/classes/field_types.go, ../sm-seo-plugin/field_types.go, ../sm-seo-plugin/routes.go, ../sm-seo-plugin/controllers/admin_registry.go, ../sm-seo-plugin/admin_navigation.go, ../sm-seo-plugin/config/config.yaml, ../sm-seo-plugin/assets/src/elements/index.ts, ../sm-seo-plugin/assets/src/elements/labels.ts, ../sm-seo-plugin/assets/src/elements/robotstxt.ts, ../sm-seo-plugin/assets/src/elements/robotstester.ts, ../sm-seo-plugin/assets/src/elements/styles.css, ../sm-seo-plugin/assets/dist/seo.js, ../sm-seo-plugin/assets/dist/seo.css, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/README.md, ../sm-seo-plugin/robots_test.go</files>
|
||||
<read_first>
|
||||
- .planning/notes/2026-10-20-sociallogin-goth.md (decision note format) and .planning/research/STACK.md (Supporting Libraries table, the goth row)
|
||||
- ../sm-sitemap-plugin/routes.go (root route with throttle bucket)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (E4, E5, C10, P4, Copywriting: robots.txt screen, E4, E5)
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Standard Stack grobotstxt, Code Examples robots test, Anti-Patterns: 5xx on robots.txt, Go /{name} route; State of the Art: noarchive, crawl-delay)
|
||||
- ../sm-seo-plugin/classes/resolver.go and routes.go
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-22, D-24, D-25, D-99, D-105, D-05, D-103, D-08 and P-23:
|
||||
1. Planning docs (G1, framework repo, separate commit `docs(32-04): grobotstxt decision note` staging only the note and `.planning/research/STACK.md`): `.planning/notes/2026-10-27-robots-txt-grobotstxt.md` (use the execution date in the file name if it differs) naming `github.com/jimsmart/grobotstxt` v1.0.3, Apache-2.0, why (Google's parser semantics: longest match, allow wins ties, `*`/`$`, `MatchingLine()`), the alternatives (temoto/robotstxt, hand-rolled RFC 9309), that it is plugin-only (the framework go.mod does not require it) and D-99; one row in `.planning/research/STACK.md` Supporting Libraries in the goth row's format.
|
||||
2. `go get github.com/jimsmart/grobotstxt@v1.0.3` in ../sm-seo-plugin.
|
||||
3. robots singleton table (id 1, content text, bots jsonb) and `golem15.seo.robots` (`AdminSingleton`, registered in `controllers/admin_registry.go`, with its robots.txt side-menu entry in `admin_navigation.go`) per C10: tab robots.txt (staging partial, `content` of field type `robotstxt` with Decode refusing more than 500 KB with `robots.too_large`, `tester` widget E5 filled from content and every bot switch, `served` P4), tab AI bots with one switch per bot from `classes/bots.go` in the C10 order plus `Claude-User` as a user-fetch bot operated by Anthropic (D-105) placed after ChatGPT-User; comments `bots.search_comment`, `bots.user_comment`, `bots.training_comment` with `:operator`.
|
||||
4. `classes/robots.go`: `ServedFile(ctx, production bool)` composes the stored rules, a `User-agent: <token>` + `Disallow: /` group per switched-off bot, and the P-23 Sitemap lines; non-production answers `User-agent: *` / `Disallow: /`. The tester action `robots_test` composes the production file from the unsaved content and switches, runs grobotstxt `NewRobotsMatcher().AgentAllowed` and `MatchingLine`, and answers allowed/blocked, the line number and text, and whether a bot switch blocked it. On save, a notice `robots.blocks_noindex` lists noindex URLs (rules with noindex and entries whose robots contain noindex) that Googlebot is blocked from (D-24).
|
||||
5. Elements E4 `golem15-seo-robotstxt` (live lint per the E4 copy: unknown directive with suggestion, rule before any User-agent, bad path, missing colon, own Sitemap line, Crawl-delay; size meter; 10 findings max) and E5 `golem15-seo-robotstester` (input row, crawler select listing Googlebot, Googlebot-Image, Bingbot, every bot token and `*`, result line, staging and unsaved notes); rebuild and commit `assets/dist`.
|
||||
6. Routes: `GET /robots.txt` (throttle bucket `seo-robots`, no backend middleware) serving text/plain; on any error it serves the last good body cached in memory, else `User-agent: *` / `Disallow:` with status 200, and logs; outside production it adds `X-Robots-Tag: noindex, nofollow`. `GET /_seo/api/v1/verification/{name}` (name pattern `[A-Za-z0-9._-]+\.(html|txt|xml)`) serves the stored file body with a matching content type, 404 otherwise. Every `/_seo/api/v1` response carries `X-Robots-Tag: noindex`. No route is registered at `/{name}` (RESEARCH anti-pattern).
|
||||
7. Tests `TestRobotsServed` (stored + bots + Sitemap; staging lock; DB failure still 200), `TestRobotsTester` (Google documented examples: longest match, allow wins ties, `$` anchor; a switched-off bot reported as blocked by its switch), `TestVerificationFile` in `robots_test.go`. README sections for robots.txt, AI bots, verification files and the new config keys.
|
||||
8. Commits (resume units, see Execution units), staged by path in ../sm-seo-plugin after G1, in this order; a resumed run skips every group whose subject exists:
|
||||
- G2 `feat: robots.txt served file, AI bots and the non-production lock` (steps 2, 4 and the robots.txt route of step 6): go.mod, go.sum, models/robots.go, the robots migration, classes/robots.go, classes/bots.go, controllers/api/robots.go, routes.go, config/config.yaml, robots_test.go (TestRobotsServed, TestRobotsTester);
|
||||
- G3 `feat: robots.txt editor and tester screen` (steps 3 and 5): models/robots/fields.yaml, controllers/robots.go, controllers/robots/config_form.yaml, controllers/robots/_staging.htm, controllers/robots/_robots_served.htm, controllers/admin_registry.go, admin_navigation.go, field_types.go, classes/field_types.go, assets/src/elements/index.ts, labels.ts, robotstxt.ts, robotstester.ts, styles.css, assets/dist/seo.js, assets/dist/seo.css, lang/en/lang.yaml, lang/pl/lang.yaml;
|
||||
- G4 `feat: verification files API` (the verification route of step 6): classes/verification.go, controllers/api/verification.go, routes.go, robots_test.go (TestVerificationFile);
|
||||
- G5 `docs: robots.txt, AI bots and verification files in README` (step 7's README sections): README.md.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestRobotsServed|TestRobotsTester|TestVerificationFile' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -30</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the three names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>npm --prefix ../sm-seo-plugin run typecheck && bash ../sm-seo-plugin/scripts/check-dist.sh</automated>
|
||||
<fails_when>non-zero exit, a TypeScript error, or "assets/dist is stale" in the output</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "github.com/jimsmart/grobotstxt v1.0.3" ../sm-seo-plugin/go.mod` prints one line and `grep -c "jimsmart/grobotstxt" go.mod` (framework) prints 0
|
||||
- `grep -n "github.com/jimsmart/grobotstxt" .planning/notes/*robots-txt-grobotstxt.md .planning/research/STACK.md` prints a line in each
|
||||
- `grep -n "Claude-User" ../sm-seo-plugin/classes/bots.go` prints one line (D-105)
|
||||
- `grep -rn "Get(\"/{" ../sm-seo-plugin/routes.go` prints nothing (no root catch-all for verification files)
|
||||
- `TestRobotsServed` includes the case where the robots row cannot be read and asserts status 200
|
||||
</acceptance_criteria>
|
||||
<done>robots.txt is editable with live lint and a Google-faithful tester, AI bots are switchable including Claude-User, crawlers always get a 200 robots.txt with a hard lock outside production, and verification files are available to the frontend.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| anonymous crawler → GET /robots.txt, verification API | public reads |
|
||||
| frontend server → POST /_seo/api/v1/notfound | server-to-server report with a shared token |
|
||||
| visitor URL → resolve redirect decision | untrusted path matched against admin-supplied patterns and regex |
|
||||
| editor → redirect rules | admin-supplied sources, targets and regex |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-16 | Tampering | redirect targets (open redirect) | high | mitigate | Capture substitution only into the path of a relative target; an external host only when the rule's target literal is absolute; query pass-through appends to the query only (TestRedirectEngine case) |
|
||||
| T-32-17 | Denial of service | regex sources | high | mitigate | stdlib RE2 (linear time), sources capped at 512 characters, compiled once per change, compile errors refused at save |
|
||||
| T-32-18 | Denial of service | 404 report endpoint | medium | mitigate | Bearer token with constant-time comparison, disabled when unset, URL/referer caps, row cap with a rate-limited warning, throttle bucket seo-notfound |
|
||||
| T-32-19 | Information disclosure | staging or demo copies indexed | high | mitigate | Environment decides the lock (Disallow: / and X-Robots-Tag), no admin setting can disable it (TestRobotsServed staging case) |
|
||||
| T-32-20 | Denial of service | /robots.txt 5xx | high | mitigate | Last good body cached in memory, fallback allow-all body, always 200 (TestRobotsServed failure case) |
|
||||
| T-32-21 | Tampering | verification file names | medium | mitigate | Name pattern without slashes, validated at save and in the route pattern; content served as text with an explicit content type |
|
||||
| T-32-22 | Denial of service | redirect cycles at runtime | medium | mitigate | 10-hop cap answering not_found plus a log line; loops refused at save |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | grobotstxt and the element toolchain approved at plan 32-03 Task 4 (blocking-human); exact version pinned; decision note and STACK row recorded |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...` green with Docker.
|
||||
- `npm --prefix ../sm-seo-plugin run typecheck` and `scripts/check-dist.sh` green.
|
||||
- Decision note and STACK row committed in this repository as their own planning-docs commit.
|
||||
- Nothing pushed.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
Changing a record's slug creates a 301 and flattens chains, from the admin and from Journal's API; loops are refused in the admin; the resolve answer gives the frontend a one-hop redirect decision; robots.txt, AI bots and verification files are managed in the CMS with the non-production lock.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 04)
|
||||
|
||||
- Tables `golem15_seo_redirects`, `golem15_seo_notfound`, `golem15_seo_robots`; models `Redirect`, `NotFound`, `Robots`
|
||||
- Controllers `golem15.seo.redirects`, `golem15.seo.notfound`, `golem15.seo.robots` (AdminSingleton); record actions `redirect`, `gone`; bulk action `gone`; row states Chain and Resolved
|
||||
- Field type `robotstxt`; elements `golem15-seo-robotstxt` (E4), `golem15-seo-robotstester` (E5); widget action `robots_test`; partials `robots_served`, `staging`, `hint`
|
||||
- `classes`: `Service.SaveRedirect`, `Service.AddressChanged`, `Service.DeleteRedirect`, redirect rule set and graph, `Normalize`, strict-URL check, `ServedFile`, bot list, verification lookup
|
||||
- Routes `GET /robots.txt`, `POST /_seo/api/v1/notfound`, `GET /_seo/api/v1/verification/{name}`; resolve actions `redirect` and `gone`; buckets `seo-robots`, `seo-notfound`
|
||||
- Config keys `golem15.seo.notfound_token`, `golem15.seo.notfound_max_rows`, `golem15.seo.robots_sitemaps`
|
||||
- Dependency `github.com/jimsmart/grobotstxt` v1.0.3 with `.planning/notes/2026-10-27-robots-txt-grobotstxt.md` and a STACK.md row
|
||||
- Tests `TestSlugChange301`, `TestRedirectEngine`, `TestLoopRefused`, `TestNotFoundLog`, `TestAddressChangeFromEvent`, `TestNormalize`, `TestStrictURL`, `TestOneHop`, `TestRobotsServed`, `TestRobotsTester`, `TestVerificationFile`
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-04-SUMMARY.md` when done with every commit SHA in both repositories, per task and commit group.
|
||||
</output>
|
||||
402
.planning/phases/32-seo-foundation/32-04-SUMMARY.md
Normal file
402
.planning/phases/32-seo-foundation/32-04-SUMMARY.md
Normal file
@@ -0,0 +1,402 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 04
|
||||
subsystem: sm-seo-plugin
|
||||
tags: [seo, sm-seo-plugin, redirects, 404, robots.txt, grobotstxt, normalisation, strict-urls, custom-elements]
|
||||
|
||||
requires:
|
||||
- phase: 32-01
|
||||
provides: pact.AdminFormExtension (yaml-document form, Save notices, AdminFormErrors, field-less extensions, extension widget fills)
|
||||
- phase: 32-02
|
||||
provides: pact.RecordSaved with Changes, cabana.EmitRecordSaved, signpost Describe/MatchPath/ContentTypeForModel
|
||||
- phase: 32-03
|
||||
provides: sm-seo-plugin core (classes.Service, Resolver, entries with URL snapshots, history, listeners, routes, settings address and verification columns, element bundle)
|
||||
provides:
|
||||
- "golem15_seo_redirects with the redirect engine (301/302/410; exact, pattern, regex; ignore case, trailing slash, query ignore/pass), save-time loop refusal and chain notices, runtime 10-hop cap"
|
||||
- "AddressChanged: the automatic 301 on an address change with chain flattening, in the SEO tab save transaction and after commit for writes outside the admin"
|
||||
- "golem15.seo.redirects and golem15.seo.notfound screens; POST /_seo/api/v1/notfound with bearer token"
|
||||
- "Normalize, strict URLs and the one-hop redirect decision in GET /_seo/api/v1/resolve (actions redirect and gone)"
|
||||
- "golem15.seo.robots singleton with the robotstxt field type (E4) and the robots_test tester widget (E5) on grobotstxt; GET /robots.txt with AI bot groups, Sitemap lines and the non-production lock"
|
||||
- "GET /_seo/api/v1/verification/{name}"
|
||||
- "Decision note .planning/notes/2026-10-27-robots-txt-grobotstxt.md and a STACK.md row"
|
||||
affects: [32-05, 32-06, 33, vue-seo-layer, sm-sitemap-plugin]
|
||||
|
||||
actuals:
|
||||
tokens: 60000
|
||||
tasks: 4
|
||||
commits: 1
|
||||
plan_head_before: 930d91a3c1df3da828c5108e984ffae700708635
|
||||
plan_head_after: 99889f0fe82c5cbdda0bd1b9e4185c49db8dd9fd
|
||||
|
||||
tech-stack:
|
||||
added:
|
||||
- "github.com/jimsmart/grobotstxt v1.0.3 (sm-seo-plugin only; approved at the 32-03 package gate; decision note and STACK row)"
|
||||
patterns:
|
||||
- "One service path for redirect writes: SaveRedirect, AddressChanged, DeleteRedirect, ResolveNotFound run validation, the loop simulation and history inside the caller's transaction"
|
||||
- "Field-less self-extension on the plugin's own controller to refuse with AdminFormErrors and answer save notices from inside the save transaction (redirects)"
|
||||
- "A form extension on the plugin's own singleton to carry fields an owner-form widget may not fill (robots.txt editor and bot switches for the tester)"
|
||||
- "Resolve as a pipeline: normalisation, redirects followed to the final target, strict URLs, then SEO; one hop"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-seo-plugin/classes/redirects.go
|
||||
- ../sm-seo-plugin/classes/redirect_graph.go
|
||||
- ../sm-seo-plugin/classes/addresses.go
|
||||
- ../sm-seo-plugin/classes/notfound.go
|
||||
- ../sm-seo-plugin/classes/normalize.go
|
||||
- ../sm-seo-plugin/classes/strict.go
|
||||
- ../sm-seo-plugin/classes/robots.go
|
||||
- ../sm-seo-plugin/classes/bots.go
|
||||
- ../sm-seo-plugin/classes/verification.go
|
||||
- ../sm-seo-plugin/controllers/redirects.go
|
||||
- ../sm-seo-plugin/controllers/notfound.go
|
||||
- ../sm-seo-plugin/controllers/robots.go
|
||||
- ../sm-seo-plugin/controllers/api/notfound.go
|
||||
- ../sm-seo-plugin/controllers/api/robots.go
|
||||
- ../sm-seo-plugin/controllers/api/verification.go
|
||||
- ../sm-seo-plugin/extensions_robots.go
|
||||
- ../sm-seo-plugin/models/redirect.go
|
||||
- ../sm-seo-plugin/models/notfound.go
|
||||
- ../sm-seo-plugin/models/robots.go
|
||||
- ../sm-seo-plugin/updates/202610270006_create_golem15_seo_redirects.go
|
||||
- ../sm-seo-plugin/updates/202610270007_create_golem15_seo_notfound.go
|
||||
- ../sm-seo-plugin/updates/202610270008_create_golem15_seo_robots.go
|
||||
- ../sm-seo-plugin/assets/src/elements/robotstxt.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/robotstester.ts
|
||||
- ../sm-seo-plugin/redirects_test.go
|
||||
- ../sm-seo-plugin/addresses_test.go
|
||||
- ../sm-seo-plugin/robots_test.go
|
||||
- .planning/notes/2026-10-27-robots-txt-grobotstxt.md
|
||||
modified:
|
||||
- ../sm-seo-plugin/classes/resolver.go
|
||||
- ../sm-seo-plugin/classes/partials.go
|
||||
- ../sm-seo-plugin/classes/field_types.go
|
||||
- ../sm-seo-plugin/classes/service.go
|
||||
- ../sm-seo-plugin/extensions.go
|
||||
- ../sm-seo-plugin/listeners.go
|
||||
- ../sm-seo-plugin/routes.go
|
||||
- ../sm-seo-plugin/admin_navigation.go
|
||||
- ../sm-seo-plugin/controllers/admin_registry.go
|
||||
- ../sm-seo-plugin/config/config.yaml
|
||||
- ../sm-seo-plugin/lang/en/lang.yaml
|
||||
- ../sm-seo-plugin/lang/pl/lang.yaml
|
||||
- ../sm-seo-plugin/README.md
|
||||
- ../sm-seo-plugin/go.mod
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/assets/dist/seo.css
|
||||
- .planning/research/STACK.md
|
||||
|
||||
key-decisions:
|
||||
- "Redirect statuses are models.RedirectStatus (an int with UnmarshalText): the admin dropdown posts \"301\" as text and lagoon.Fill cannot fill an int from a string"
|
||||
- "Loop detection refuses a repeated URL, a rule that fires twice, or reaching 10 hops; pattern probes replace * with seoprobe, regex probes are built from regexp/syntax literals"
|
||||
- "Exact redirects are read per request by lower(source) (functional index added to the unreleased redirects migration); pattern and regex rules are loaded each request, their expressions compiled once per source"
|
||||
- "A capture is percent-encoded (?, #, \\, %, non-ASCII) before substitution; a relative target collapses leading slashes; an absolute target must keep its literal's scheme and host, else the rule does not match"
|
||||
- "A redirect chain that ends on a 410 answers gone for every source in it; a 302 anywhere in a chain makes the answer 302"
|
||||
- "Strict URLs compare the normalised request path with the record's normalised Describe URL in the matched locale; MatchPath gets the path without a trailing slash, so records match under url_slash add"
|
||||
- "Normalisation uses the request URL's scheme and host only when the host is the site URL's host or its www twin; any other host is ignored"
|
||||
- "The robots.txt editor, tester and AI bot switches are fields of the plugin's own form extension on golem15.seo.robots (an owner-form widget may fill built-in scalar fields only); the owner form keeps the staging callout and P4"
|
||||
- "Bot switch labels are \"<token> (<operator>)\" and their comments carry no :operator, because fields.yaml copy takes no parameters"
|
||||
- "Record action Confirm texts take no parameters and the SPA shows a bulk Confirm as is, so notfound.redirect_confirm, gone_confirm and gone_selected_confirm name \"this address\" / \"the selected addresses\" instead of :url / :count"
|
||||
- "The last production robots.txt body is cached on the service and served when the store fails; without one the body is allow-all; always 200"
|
||||
- "Verification files are served with nosniff and Content-Security-Policy default-src 'none'; sandbox"
|
||||
|
||||
patterns-established:
|
||||
- "Service methods return typed refusals (ProblemsError, LoopError, NotFoundHasRuleError) that each caller maps: 422 field lines on a form, 403 toast messages on record and bulk actions"
|
||||
|
||||
requirements-completed: [SC-3, D-16, D-17, D-18, D-19, D-20, D-20a, D-20b, D-20c, D-22, D-24, D-25, D-05, D-08, D-06, D-99, D-103, D-105, D-92, D-102]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Tracer: an admin slug change creates the 301 in the save transaction, flattens an earlier redirect to the old address, answers redirects.auto_created on slug, and resolve redirects the old address to the absolute new one"
|
||||
requirement: "SC-3"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestSlugChange301"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Redirect engine: exact, pattern and regex sources with ignore case, trailing slash and query ignore/pass, order exact > pattern > regex, 410 gone, field refusals, loop refusal (exact, pattern and regex probes), chain checks, slug back and forth ending with A→C and B→C, open-redirect safety"
|
||||
requirement: "D-17"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestRedirectEngine"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Redirects screen: a loop is refused with redirects.loop on target and nothing saved (create and update); a chain is saved with redirects.chain_notice and marked negative in the list; target_required and regex_invalid answer 422; history rows"
|
||||
requirement: "D-19"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestLoopRefused"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "404 log: the bearer-token report endpoint (401, 404 when off, 422 over 2048 bytes), hits, first seen, last hit and referer; the prompted redirect and 410 record actions, Resolved rows, resolved hint, bulk 410 refused for a selection with a covered address, open filter"
|
||||
requirement: "D-20"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestNotFoundLog"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Writes outside the admin: RecordSaved without a controller creates the 301 after commit (via auto); no change and unpublished records create nothing; an admin save that already applied it changes nothing more"
|
||||
requirement: "D-102"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestAddressChangeFromEvent"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "URL normalisation as a pure function: https, www/bare, double slashes, index files, trailing slash add/remove (root and files kept), ASCII-only lowercasing with Polish letters and percent-encoding kept"
|
||||
requirement: "D-20b"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-seo-plugin/addresses_test.go#TestNormalize"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Strict URLs: a wrong category or another locale's slug 301s to the record's address, queries kept; only the record's address answers ok"
|
||||
requirement: "D-20c"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/addresses_test.go#TestStrictURL"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D8
|
||||
description: "One-hop redirect decision: a non-normalised URL whose normal form is a redirect source (and a chain) answers one 301 to the final normalised target; a runtime cycle answers not_found; P1 shows status.canonical_redirected"
|
||||
requirement: "D-20a"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/addresses_test.go#TestOneHop"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D9
|
||||
description: "GET /robots.txt: stored rules, AI bot groups and the Sitemap line in production; the lock with X-Robots-Tag outside production whatever is stored; 200 with the last good body or allow-all when the store fails"
|
||||
requirement: "D-22"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/robots_test.go#TestRobotsServed"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D10
|
||||
description: "Tester on grobotstxt against Google's documented examples (longest match, Allow wins a tie, $ anchor, group choice) with the deciding line; a switched-off bot is reported as blocked by its switch"
|
||||
requirement: "D-99"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/robots_test.go#TestRobotsTester"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D11
|
||||
description: "robots.txt screen through the admin API: field order, save of rules and switches with history, robots.blocks_noindex notice, 500 KB refusal, tester action on unsaved values incl. Claude-User, served-file partial"
|
||||
requirement: "D-24"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/robots_test.go#TestRobotsScreen"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "npm --prefix ../sm-seo-plugin run typecheck && bash ../sm-seo-plugin/scripts/check-dist.sh"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D12
|
||||
description: "Verification files through /_seo/api/v1/verification/{name} with content type, nosniff, sandbox CSP and noindex; unknown, malformed and root paths 404"
|
||||
requirement: "D-05"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/robots_test.go#TestVerificationFile"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D13
|
||||
description: "E4 editor and E5 tester, the redirects and 404 log lists (badges, filters, prompted action, danger confirm) and the robots.txt screen look and behave as UI-SPEC C8-C10 in the real admin SPA"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Visual and interaction behaviour inside the SPA; only a throwaway happy-dom smoke of E4/E5 ran here, element unit tests are plan 32-06"
|
||||
|
||||
duration: 43min
|
||||
completed: 2026-10-27
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 04: Redirects, 404 log, URL rules and robots.txt Summary
|
||||
|
||||
**Redirect engine with save-time loop refusal and chain notices, the automatic 301 on an address change (inside the admin save and after commit for API writes), the 404 log with a token-protected report endpoint, URL normalisation and strict URLs folded into a one-hop redirect decision in resolve, and robots.txt with a grobotstxt tester, eleven AI bot switches, a non-production lock that never answers 5xx, and verification files served through the API.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 43 min
|
||||
- **Started:** 2026-10-27T10:11:34Z
|
||||
- **Completed:** 2026-10-27T10:54:32Z
|
||||
- **Tasks:** 4 (Task 1 tracer, Task 2 in four commit groups, Task 3, Task 4 in five commit groups)
|
||||
- **Files:** 64 files changed in ../sm-seo-plugin, 2 in this repository
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Redirects (D-16, D-17, D-19).**
|
||||
- Matching: exact, pattern and regex sources, ignore case, trailing slash, query ignore/pass, and a source with `?` that matches its query exactly (Q-9).
|
||||
- Safety: stdlib RE2 regexes capped at 512 characters, and captures that cannot leave the site.
|
||||
- Save-time simulation: a loop is refused and a chain is saved with a notice.
|
||||
- Runtime: chains are followed to the final target, and a cycle stops after 10 hops.
|
||||
- **Address changes (D-18, D-92, D-102, P-20).** `AddressChanged` runs inside the SEO tab save with the `redirects.auto_created` notice on the slug field. A `RecordSaved` listener does the same after commit for writers outside the admin. Unpublished and deleted records get no redirect.
|
||||
- **Redirects screen (C8).** Six columns with the Chain badge, the status/match/origin/chain filters, and the navigation item landing here.
|
||||
- **404 log (D-20, P-22, C9).**
|
||||
- Report endpoint `POST /_seo/api/v1/notfound`: bearer token compared in constant time, off when unset, URL and referer caps, a row cap with an hourly warning.
|
||||
- List by hits, with Resolved rows and the resolved hint.
|
||||
- Actions: a prompted 301, a danger 410, and a bulk 410 that refuses the whole selection when one row is covered.
|
||||
- **Redirect decision (D-20a, D-20b, D-20c, D-103, P-21).** Resolve now runs normalisation, then redirects, then strict URLs, then SEO. It answers `redirect` with an absolute `location` (one hop) or `gone`. P1 warns when a canonical URL redirects (D-06).
|
||||
- **robots.txt (D-22, D-24, D-25, D-99, D-105, P-23, C10).**
|
||||
- Field type `robotstxt` with element E4 (live lint, size meter).
|
||||
- Tester E5 on `robots_test`. It works on unsaved text and switches.
|
||||
- AI bots tab with eleven switches, including `Claude-User`.
|
||||
- A `robots.blocks_noindex` save notice.
|
||||
- `GET /robots.txt`: rules, bot groups and Sitemap lines. Outside production it serves the lock with `X-Robots-Tag`. It never answers 5xx.
|
||||
- **Verification files (D-05, D-103).** `GET /_seo/api/v1/verification/{name}`. There is no root route.
|
||||
- **Planning docs.** Decision note `2026-10-27-robots-txt-grobotstxt.md` and a STACK.md row.
|
||||
|
||||
## Task Commits
|
||||
|
||||
../sm-seo-plugin, branch main, not pushed:
|
||||
|
||||
1. **Task 1 (tracer):** `e31ac7c` feat: address-change 301 (tracer)
|
||||
2. **Task 2:**
|
||||
- A `34a65b8` feat: redirect engine with loop refusal and chain notices
|
||||
- B `163b0aa` feat: redirects screen
|
||||
- C `6eb6cb7` feat: 404 log and report endpoint
|
||||
- D `327925c` feat: address-change redirects for writes outside the admin
|
||||
3. **Task 3:** `4cb0fbf` feat: URL normalisation, strict URLs and the one-hop redirect decision
|
||||
4. **Task 4:**
|
||||
- G1 (this repository) `99889f0` docs(32-04): grobotstxt decision note
|
||||
- G2 `3dd9362` feat: robots.txt served file, AI bots and the non-production lock
|
||||
- G3 `51413fb` feat: robots.txt editor and tester screen
|
||||
- G4 `ec74062` feat: verification files API
|
||||
- G5 `b398161` docs: robots.txt, AI bots and verification files in README
|
||||
|
||||
Commit counts:
|
||||
- ../sm-seo-plugin: `git rev-list --count b38eb4b..HEAD` = 10.
|
||||
- This repository before this SUMMARY's commit: `git rev-list --count 930d91a..HEAD` = 1 (G1), which is the frontmatter's `commits`.
|
||||
|
||||
Tracer feedback gate: the run was interactive, in end-of-phase mode, with an automated-only verify. TestSlugChange301, vet and the `-short` tests re-ran green before Task 2.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
Tasks 2 and 3 are marked `tdd="true"`, and `workflow.tdd_mode` is false.
|
||||
- **Commits:** the plan defines one commit per resume unit, with the tests included, so there are no separate `test(...)` RED commits.
|
||||
- **RED evidence:** none. The tests were written next to the implementation, not before it. Only TestAddressChangeFromEvent failed first, and that was on the test's own transaction: `EmitRecordSaved` needs `lagoon.Transaction`.
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
See `key-files` in the frontmatter.
|
||||
- Classes: `classes/redirects.go`, `redirect_graph.go` and `addresses.go` hold the engine, the simulation and the address change. `normalize.go` and `strict.go` hold the redirect-decision stages, and `robots.go`, `bots.go` and `verification.go` the robots.txt side.
|
||||
- Extension: `extensions_robots.go` builds the robots form extension. Its document is generated from `classes.Bots`.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See `key-decisions` in the frontmatter.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 3 - Blocking] Redirect status type**
|
||||
- **Found during:** Task 2B
|
||||
- **Issue:** the admin dropdown posts `"301"` as text, and `lagoon.Fill` cannot fill an `int` from a string.
|
||||
- **Fix:** `models.RedirectStatus` (an int with `UnmarshalText`). The SPA compares option values as strings, so `show` matches.
|
||||
- **Commit:** 163b0aa
|
||||
|
||||
**2. [Rule 3 - Blocking, framework constraint] The tester needs unsaved editor text**
|
||||
- **Found during:** Task 4 G3
|
||||
- **Issue:** an owner-form widget may fill built-in scalar fields only, so the tester could not fill a `robotstxt` field from the owner form.
|
||||
- **Fix:** the editor, the tester and the bot switches are fields of the plugin's own form extension on `golem15.seo.robots`. An extension widget may fill its own value fields, plugin types included.
|
||||
- Load and Save read and write `golem15_seo_robots` (`content`, `bots` jsonb), so the plan's table shape is kept.
|
||||
- The owner `fields.yaml` holds the staging callout and P4.
|
||||
- **Files outside the plan's list:** `extensions_robots.go` (new), `extensions.go`.
|
||||
- **Commit:** 51413fb
|
||||
|
||||
**3. [Framework constraint] Copy without parameters**
|
||||
- **Record action confirms:** `Confirm` is translated without parameters, so `notfound.redirect_confirm` and `notfound.gone_confirm` say "this address" instead of “:url”.
|
||||
- **Bulk confirm:** the SPA shows a bulk `Confirm` as is, with no plural and no `:count`, so `notfound.gone_selected_confirm` is one plain sentence.
|
||||
- **Bot switches:** `fields.yaml` comments take no parameters, so the labels are "<token> (<operator>)" and `bots.*_comment` has no `:operator`.
|
||||
- **Commits:** 6eb6cb7, 51413fb
|
||||
|
||||
**4. [Plan detail] Lowercased-source index added to the redirects migration**
|
||||
- `202610270006` (committed in Task 1, unreleased, not pushed) gained `CREATE INDEX ... (lower(source))` in group A. The resolver reads exact rules by that key.
|
||||
- **Commit:** 34a65b8
|
||||
|
||||
**5. [Plan detail] resolver.go changed outside Task 3's commit**
|
||||
- `classes/resolver.go` changed in the Task 1 and Task 2 A/B commits, so each commit compiles with the engine of that commit.
|
||||
- **Commits:** e31ac7c, 34a65b8, 163b0aa
|
||||
|
||||
**6. [Plan detail] Extra files and keys**
|
||||
- Filters: `controllers/redirects/config_filter.yaml` and `controllers/notfound/config_filter.yaml`.
|
||||
- Classes:
|
||||
- `classes/partials.go` gained the canonical-redirected callout. `extension/_seo_status.htm` needed no change, because callouts render generically.
|
||||
- `classes/service.go` caches the last good robots.txt.
|
||||
- Test: `TestRobotsScreen`, an admin-path smoke test.
|
||||
- Lang keys not in the UI-SPEC:
|
||||
- `redirects.target_invalid`: a target that is neither a path nor an http(s) URL;
|
||||
- `robots.test_invalid` and `robots.served_production` (P4's "Production" heading);
|
||||
- `robots.staging_text` reuses the UI-SPEC copy.
|
||||
|
||||
**7. [Plan detail] Strict URLs and trailing slashes**
|
||||
- The strict check gives `MatchPath` the path without a trailing slash, so records still match when the site adds slashes.
|
||||
- With the default `keep`, `/pages/a/` therefore 301s to the record's address `/pages/a` (before this plan it was `not_found`).
|
||||
|
||||
**8. [Plan detail] Filters versus badges**
|
||||
- The 404 log's open/resolved filter runs in SQL over exact rules only. The Resolved badge and the actions use the full rule set, patterns and regex included.
|
||||
- The redirects Chain badge and the chain filter compare the target with another rule's source literally.
|
||||
|
||||
**9. [Plan detail] README timing**
|
||||
- The plan's G5 grouping moved the README updates for redirects, the 404 log and normalisation into the docs commit. They did not land in each feature commit.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 9. Two were blocking, and one is a framework copy constraint; the other six are plan details.
|
||||
**Impact on plan:** behaviour is as planned, and copy changes are limited to the confirm texts and the bot comments.
|
||||
|
||||
**Framework candidates:**
|
||||
- parameters in record-action and bulk confirms;
|
||||
- parameters in fields.yaml comments;
|
||||
- owner-form widget fill of plugin field types.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None blocking:
|
||||
- File permissions in summercms.go were fixed before this run, so this SUMMARY and the planning commit were written in place.
|
||||
- summercms.go `go vet ./...` and `go test -short ./...` are green.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
- MCP tools, batch writes, undo and CSV import of redirects are plan 32-05; they reuse `SaveRedirect` and `AddressChanged`.
|
||||
- Element unit tests are plan 32-06.
|
||||
- The Nuxt-side enforcement of the redirect decision and of verification files is Phase 33 (D-103).
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. To feed the 404 log, a site sets `golem15.seo.notfound_token` and lets its frontend server report 404s; without a token the endpoint stays off.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Plan 32-05 builds on `SaveRedirect`, `CheckRedirect`, `DeleteRedirect`, `AddressChanged`, `ResolveNotFound` and the typed refusals. History is already recorded for redirect and robots writes.
|
||||
- Phase 33 takes the resolve `redirect`/`gone` actions, the verification API and `robots_sitemaps`. The sitemap rewrite replaces the default.
|
||||
- Nothing pushed: ../sm-seo-plugin `main` has no upstream.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- **Commits present:**
|
||||
- ../sm-seo-plugin: e31ac7c, 34a65b8, 163b0aa, 6eb6cb7, 327925c, 4cb0fbf, 3dd9362, 51413fb, ec74062, b398161;
|
||||
- this repository: 99889f0.
|
||||
- **Key files:** all exist.
|
||||
- **../sm-seo-plugin:**
|
||||
- `go vet ./...`, `go test -short ./...` and `go test -count=1 ./...` (Docker) are green. The Docker run includes TestSlugChange301, TestRedirectEngine, TestLoopRefused, TestNotFoundLog, TestAddressChangeFromEvent, TestNormalize, TestStrictURL, TestOneHop, TestRobotsServed, TestRobotsTester, TestRobotsScreen, TestVerificationFile and TestLangKeysComplete.
|
||||
- `npm run typecheck` and `scripts/check-dist.sh` are green.
|
||||
- **summercms.go:** `go vet ./...` and `go test -short ./...` are green.
|
||||
- **Acceptance greps:**
|
||||
- `AddressChanged(` appears in `extensions.go` and `listeners.go`; `*pact.RecordSaved` appears once in `listeners.go`.
|
||||
- `subtle.ConstantTimeCompare` appears in `controllers/api/notfound.go`.
|
||||
- There is no `regexp.MustCompile(.*source`, dlclark or regexp2.
|
||||
- grobotstxt v1.0.3 is in the plugin's go.mod and not in the framework's.
|
||||
- `Claude-User` appears once in `classes/bots.go`.
|
||||
- `routes.go` has no `Get("/{`.
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-27*
|
||||
356
.planning/phases/32-seo-foundation/32-05-PLAN.md
Normal file
356
.planning/phases/32-seo-foundation/32-05-PLAN.md
Normal file
@@ -0,0 +1,356 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 05
|
||||
type: execute
|
||||
wave: 5
|
||||
depends_on: ["32-04"]
|
||||
files_modified:
|
||||
- ../sm-seo-plugin/routes.go
|
||||
- ../sm-seo-plugin/mcp.go
|
||||
- ../sm-seo-plugin/operations.go
|
||||
- ../sm-seo-plugin/plugin.go
|
||||
- ../sm-seo-plugin/admin.go
|
||||
- ../sm-seo-plugin/admin_navigation.go
|
||||
- ../sm-seo-plugin/field_types.go
|
||||
- ../sm-seo-plugin/controllers/api/auth.go
|
||||
- ../sm-seo-plugin/controllers/api/seo.go
|
||||
- ../sm-seo-plugin/controllers/api/rules.go
|
||||
- ../sm-seo-plugin/controllers/api/redirects.go
|
||||
- ../sm-seo-plugin/controllers/api/notfound.go
|
||||
- ../sm-seo-plugin/controllers/api/robots.go
|
||||
- ../sm-seo-plugin/controllers/api/settings.go
|
||||
- ../sm-seo-plugin/controllers/api/history.go
|
||||
- ../sm-seo-plugin/controllers/api/transfer.go
|
||||
- ../sm-seo-plugin/controllers/api/batch.go
|
||||
- ../sm-seo-plugin/controllers/api/issues.go
|
||||
- ../sm-seo-plugin/controllers/admin_registry.go
|
||||
- ../sm-seo-plugin/controllers/history.go
|
||||
- ../sm-seo-plugin/controllers/history/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/transfer.go
|
||||
- ../sm-seo-plugin/controllers/transfer/config_form.yaml
|
||||
- ../sm-seo-plugin/classes/owner.go
|
||||
- ../sm-seo-plugin/classes/batch.go
|
||||
- ../sm-seo-plugin/classes/undo.go
|
||||
- ../sm-seo-plugin/classes/csv.go
|
||||
- ../sm-seo-plugin/classes/transfer.go
|
||||
- ../sm-seo-plugin/classes/issues.go
|
||||
- ../sm-seo-plugin/classes/history.go
|
||||
- ../sm-seo-plugin/models/settings/fields.yaml
|
||||
- ../sm-seo-plugin/assets/src/elements/index.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/labels.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/transfer.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/styles.css
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/assets/dist/seo.css
|
||||
- ../sm-seo-plugin/lang/en/lang.yaml
|
||||
- ../sm-seo-plugin/lang/pl/lang.yaml
|
||||
- ../sm-seo-plugin/README.md
|
||||
- ../sm-seo-plugin/mcp_test.go
|
||||
- ../sm-seo-plugin/batch_test.go
|
||||
- ../sm-seo-plugin/transfer_test.go
|
||||
- ../sm-demo-app/seo_mount_test.go
|
||||
- ../sm-demo-app/seo_mcp_test.go
|
||||
- .planning/phases/32-seo-foundation/32-05-demo-mount.patch
|
||||
- scripts/check-phase32.sh
|
||||
autonomous: true
|
||||
requirements: [SC-2, SC-3, SC-4, D-10, D-11, D-12, D-13, D-14, D-15, D-19, D-90, D-94, D-98]
|
||||
|
||||
estimate:
|
||||
tokens: 180000
|
||||
raw_tokens: 180000
|
||||
tasks: 4
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Every SEO operation of the admin (SEO tab, URL rules, redirects, 404 log actions, robots.txt and AI bots, settings, history and undo, import and export) has an MCP tool bound to a /_seo/api/v1 route, and a plugin test fails when an admin operation has no tool (SC-4, D-10)"
|
||||
- "MCP tools run under the linked admin's permissions with the one golem15.seo.manage permission; a read grant sees only GET tools (D-10, D-15)"
|
||||
- "Tools address pages by URL: a change goes into the record's SEO when a record is behind the URL, otherwise into a URL rule; the answer says where it was written, and force_rule writes a rule (D-11)"
|
||||
- "A batch of changes can be previewed with dry_run, which returns the diff and the conflicts (loops, chains, noindex on a published record's URL, canonical pointing to a redirected URL) and writes nothing; applying a batch is all-or-nothing (SC-4, D-12)"
|
||||
- "Redirect loops are refused from MCP (tool error) and from CSV import (refused row), as from the admin (SC-3, D-19)"
|
||||
- "History records author, time, via (admin, mcp, import, auto, undo) and before/after values; one change or a whole batch can be undone from the admin and through MCP; an undo that would overwrite a newer change, create a loop or touch a deleted record is refused (SC-4, D-13)"
|
||||
- "CSV export and import with a dry-run preview work in the admin (E6, 60 KB limit) and through MCP; files are UTF-8 with BOM, comma or semicolon, and exported cells starting with = + - @ tab or CR are prefixed with an apostrophe (D-13)"
|
||||
- "The effective SEO of a URL is readable with the source of every value, and the issue report lists the CMS data checks: duplicate and missing titles and descriptions, conflicting rules, redirect chains, canonicals pointing to noindex or redirected URLs (D-13, D-14 CMS part)"
|
||||
- "The demo mount is proven in a scratch worktree of sm-demo-app: Journal posts, categories and tags show the SEO tab and the pier catalog lists every SEO tool; the mount commit waits for the plugin tag in plan 32-06 because the demo's TestGoModRequiresTags refuses untagged plugins (SC-2, SC-4)"
|
||||
- "scripts/check-phase32.sh exists with stages self-test, go, plugins, consumers, docker, admin, docs and marker, and its marker stage refuses SEO names or consuming-application names in the framework lines this phase added (D-90)"
|
||||
- "Import and export screen: before a file is chosen noFile shows and Preview import is disabled; Apply is disabled with refusedBlocks when a row is refused and with nothing when the count is zero; more than 200 rows show rowCap; the preview table scrolls inside a max-height wrapper (UI-SPEC empty, error, zero-one-many, overflow)"
|
||||
- "E5 and E6 actions disable their buttons and show the busy label while pending (UI-SPEC loading)"
|
||||
- "Undo refusals show a danger toast with history.undo_stale, history.undo_loop or history.undo_gone; batch undo applies only to batched entries and uses the plural confirm (UI-SPEC error, zero-one-many)"
|
||||
- "Stale import preview answers transfer.stale and E6 keeps the preview; unreadable files answer transfer.unreadable and missing columns transfer.missing_column (UI-SPEC error)"
|
||||
prohibitions:
|
||||
- statement: "A batch or an import is never applied partially; a refused change means nothing is written (D-12)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "An MCP read grant can never change SEO data, and no /_seo/api/v1 management route answers without golem15.seo.manage (D-10, D-15)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "An undo never silently overwrites a change made after the one being undone (D-13)"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "Framework lines added by this phase name no SEO concept and no consuming application (D-90)"
|
||||
status: resolved
|
||||
verification: test
|
||||
artifacts:
|
||||
- path: "../sm-seo-plugin/mcp.go"
|
||||
provides: "pact.HasMCP: every SEO tool, Guard backend, Permissions golem15.seo.manage"
|
||||
contains: "func (p *Plugin) MCP() pact.MCP"
|
||||
- path: "../sm-seo-plugin/operations.go"
|
||||
provides: "AdminOperations: the admin operation → tool name list the parity test checks"
|
||||
contains: "AdminOperations"
|
||||
- path: "../sm-seo-plugin/classes/batch.go"
|
||||
provides: "dry-run by rollback, all-or-nothing apply, conflicts"
|
||||
contains: "dry"
|
||||
- path: "../sm-seo-plugin/classes/undo.go"
|
||||
provides: "undo of a change and of a batch with staleness, loop and gone guards"
|
||||
contains: "undo_stale"
|
||||
- path: "scripts/check-phase32.sh"
|
||||
provides: "phase gate"
|
||||
contains: "marker"
|
||||
- path: ".planning/phases/32-seo-foundation/32-05-demo-mount.patch"
|
||||
provides: "the demo mount, applied by plan 32-06 after the plugin tag"
|
||||
contains: "golem15.seo"
|
||||
key_links:
|
||||
- from: "../sm-seo-plugin/mcp.go"
|
||||
to: "../sm-seo-plugin/routes.go"
|
||||
via: "each MCPTool Method+Path equals a registered /_seo/api/v1 route (pier refuses unbound tools at boot)"
|
||||
pattern: "/_seo/api/v1/"
|
||||
- from: "../sm-seo-plugin/controllers/api/batch.go"
|
||||
to: "../sm-seo-plugin/classes/batch.go"
|
||||
via: "POST /_seo/api/v1/batch with dry_run runs Batch.Run in lagoon.Transaction and rolls back on dry_run"
|
||||
pattern: "lagoon\\.Transaction"
|
||||
- from: "../sm-demo-app/seo_mcp_test.go"
|
||||
to: "../sm-seo-plugin/mcp.go"
|
||||
via: "TestSEOToolsCatalog compiles the pier catalog with -tags summercms_mcp and compares it with the plugin's MCP() tools"
|
||||
pattern: "TestSEOToolsCatalog"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan makes the whole of SEO manageable through MCP and in bulk, with history, undo, CSV, and the phase gate.
|
||||
|
||||
<objective>
|
||||
Add the `/_seo/api/v1` management API and pier MCP tools for every SEO admin operation (D-10, D-15), URL addressing (D-11), batch dry-run and all-or-nothing apply (D-12), the read and audit tools including the CMS-data issue report (D-13, D-14 CMS part), undo of one change or a batch, CSV import/export in the admin (E6) and through MCP (D-13), loop refusal on the MCP and import paths (D-19, SC-3); prove the demo mount in a scratch worktree of sm-demo-app (the commit follows the tags in plan 32-06); write `scripts/check-phase32.sh` with the D-90 marker stage.
|
||||
|
||||
Purpose: SC-4 (every SEO operation in the admin is available as an MCP tool; a batch change can be previewed with dry-run and undone from history) and the MCP/import half of SC-3. The crawler half of D-14 is Phase 33.
|
||||
|
||||
Output: commits in `../sm-seo-plugin` (main, not pushed), the demo test files committed in `../sm-demo-app` (they skip when the plugin is not mounted), the demo mount patch in this phase directory, and `scripts/check-phase32.sh` in this repository. Which plan implements each decision of the phase, and what Phase 33 takes, is in `32-DECISIONS-MAP.md`.
|
||||
|
||||
**Planner decisions recorded here:**
|
||||
- **P-24 (routes and tools):** management routes in a `/_seo/api/v1` group with throttle bucket `seo-api`, each handler resolving the backend principal (Journal's `requireBackendPrincipal` pattern through `cabana.ResolveBackend`) and requiring `golem15.seo.manage` with `cabana.Allows`. Tools (pier prefixes them with `seo_`), all `Guard: "backend"`, `Permissions: ["golem15.seo.manage"]`: GET `get_url_seo` (/seo?url=), `list_rules`, `show_rule`, `list_redirects`, `show_redirect`, `list_not_found`, `show_robots`, `test_robots` (/robots/test?url=&agent=), `show_settings`, `list_history`, `show_history`, `export_csv` (/export?dataset=&delimiter=&page=), `list_issues`; writes `set_url_seo` (PUT /seo), `create_rule`, `update_rule`, `delete_rule` (destructive), `create_redirect`, `update_redirect`, `delete_redirect` (destructive), `redirect_not_found`, `gone_not_found` (destructive), `delete_not_found` (destructive), `update_robots`, `update_settings`, `undo_change`, `undo_batch`, `import_csv` (with dry_run), `apply_batch` (with dry_run). `operations.go` exports `AdminOperations` mapping each admin operation (form save, list delete, record action, bulk action, widget action, singleton save) to its tool name; `TestEveryAdminOperationHasTool` fails on a missing or unbound one. History `via = mcp` comes from `bouncer.Dispatched(ctx, "backend")`.
|
||||
- **P-25 (owner resolution, D-11):** `classes/owner.go` resolves a URL through normalisation, then signpost `MatchPath`: an Exact match writes the record's entry for the matched locale, anything else (no record, or force_rule) writes an exact URL rule; the answer carries `{"written_to": "record"|"rule", "type", "id", "locale", "rule_id"}`.
|
||||
- **P-26 (batch, RESEARCH Pattern 8):** `Batch.Run(ctx, changes, BatchOptions{DryRun, Via, Author})` runs every change through the Service inside one `lagoon.Transaction`, collecting per-change diff and conflicts; dry_run returns them and rolls back deliberately; any refused change (loop, invalid value) rolls back and answers 422 with per-change errors; applied changes share one `batch_id` in history. "Noindex on a page that is in a sitemap" is checked as noindex on the URL of a published content record (the records the sitemaps list); Phase 33's D-95 filter refines it.
|
||||
- **P-27 (CSV and transfer):** datasets redirects, rules, records (records address pages by URL, D-11); `encoding/csv` with BOM strip/prepend and the chosen delimiter; formula-injection prefix on export; the admin import limit is 60 KB (UI-SPEC Q-8 assumption, flagged below) and export answers at most 256 KiB per action (larger exports are paged through MCP); MCP imports at most 900 KB per call. The E6 apply token is an HMAC-SHA256 (crypto/hmac, keyed by the app key) over dataset, normalised rows and a fingerprint of the touched rows' updated_at values; apply re-runs the dry run and refuses with `transfer.stale` when the fingerprint differs.
|
||||
- **P-28 (demo mount sequencing):** the demo's `TestGoModRequiresTags` requires every mounted plugin at a vX.Y.Z tag (19.6-03 precedent), and tags wait for Jakub's go-ahead in plan 32-06. So this plan proves the mount in a disposable `git worktree` of sm-demo-app with a scratch go.work (absolute paths), stores the mount as `.planning/phases/32-seo-foundation/32-05-demo-mount.patch`, and commits only the two test files, which skip with "NOT MOUNTED" when `golem15.seo` is not registered and import no SEO package. Plan 32-06 applies the patch after tagging.
|
||||
|
||||
**Flagged assumption (UI-SPEC UI Considerations, unresolved row):** CSV files larger than the widget action caps (64 KiB payload, 256 KiB response) are not handled in the admin; `:limit` = 60 KB is the Phase 32 import limit pending UI-SPEC Q-8 (Jakub / planner). Larger imports go through MCP in chunks.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-RESEARCH.md
|
||||
@.planning/phases/32-seo-foundation/32-UI-SPEC.md
|
||||
@.planning/phases/32-seo-foundation/32-VALIDATION.md
|
||||
@.planning/phases/32-seo-foundation/32-04-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
|
||||
<interfaces>
|
||||
From modules/pact/mcp.go: type MCPTool struct { Name, Title, Description, Guard, Method, Path string; Input, Output any; Permissions []string; ReadOnly, Destructive, Idempotent, OpenWorld *bool }; pact.HasMCP { MCP() pact.MCP }.
|
||||
From modules/pier/catalog.go 178-182: a tool's method+pattern must match a registered route or the boot fails; a `path:` input field must be a required argument (220-223).
|
||||
From ../sm-journal-plugin/mcp.go 12-110 (tool declarations, input structs with json, path and jsonschema tags, destructive pointer) and controllers/api/auth.go 83-115 (requireBackendPrincipal via cabana.ResolveBackend, permission check).
|
||||
From modules/bouncer/dispatch.go: Dispatched(ctx, guard) (*Dispatch, bool).
|
||||
From modules/lagoon/transaction.go: Transaction(ctx, gdb, fn).
|
||||
From plans 32-03/32-04: classes.Service (SaveRedirect, AddressChanged, DeleteRedirect, entry/rule/settings writes with history), classes.Resolver, Normalize, redirect graph, history revisions with batch_id/via/before/after/undone_at.
|
||||
Demo: ../sm-demo-app/boot_test.go (boot helpers), mcp_e2e_test.go (//go:build summercms_mcp, pier catalog access), go_mod_test.go (TestGoModRequiresTags), summer.yaml, go.work, .gitmodules (sitemap submodule entry format), deploy/nginx/demo.summercms.io.conf (location = /sitemap.xml block ~302), DEPLOY.md, config/.
|
||||
Gate analog: scripts/check-phase19.7.sh (stage layout, go test -json detectors, marker stage, NOT RUN docker rule).
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: End-to-end "an MCP client sets noindex on a URL and the resolve answer and history reflect it" — one path only</name>
|
||||
<files>../sm-seo-plugin/routes.go, ../sm-seo-plugin/mcp.go, ../sm-seo-plugin/plugin.go, ../sm-seo-plugin/controllers/api/auth.go, ../sm-seo-plugin/controllers/api/seo.go, ../sm-seo-plugin/classes/owner.go, ../sm-seo-plugin/mcp_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-journal-plugin/mcp.go and controllers/api/auth.go (whole files)
|
||||
- summercms.go/modules/pact/mcp.go, modules/pier/catalog.go (binding rules), modules/bouncer/dispatch.go
|
||||
- summercms.go/modules/cabana/dispatch_marker_test.go (how a dispatched MCP call is simulated in a handler test)
|
||||
- ../sm-seo-plugin/classes/service.go, classes/resolver.go, classes/history.go
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-10, D-11, D-13, D-15 and P-24/P-25: `controllers/api/auth.go` (backend principal + `golem15.seo.manage`); `PUT /_seo/api/v1/seo` with body `{url, locale?, values{title, description, keyphrase, canonical, robots, og_title, og_description, og_image}, force_rule?}` writing through `classes/owner.go` and the Service (history via mcp when dispatched); `mcp.go` with `var _ pact.HasMCP = (*Plugin)(nil)` and the first tool `set_url_seo` (Method PUT, Path "/_seo/api/v1/seo", Guard backend, Permissions golem15.seo.manage). `TestMCPSetURLSeoTracer` in `mcp_test.go`: with the fake content plugin and an admin principal marked as dispatched for guard backend, PUT robots "noindex" for /pages/a (a record) → answer `written_to: record`; resolve /pages/a answers robots noindex and x_robots_tag noindex; the history row has via mcp; PUT for /landing (no record) → `written_to: rule` and a rule row exists; an admin without golem15.seo.manage gets 403. Commit `feat: SEO by URL over the management API and MCP (tracer)`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestMCPSetURLSeoTracer' -count=1 -v 2>&1 | tail -20</automated>
|
||||
<fails_when>non-zero exit, "FAIL" or "no tests to run" in the output, or no "--- PASS: TestMCPSetURLSeoTracer" line</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "Path: *\"/_seo/api/v1/seo\"" ../sm-seo-plugin/mcp.go` prints one line
|
||||
- `grep -n "bouncer.Dispatched" ../sm-seo-plugin/classes/history.go ../sm-seo-plugin/controllers/api/*.go` prints at least one line
|
||||
- `TestMCPSetURLSeoTracer` covers the record, rule and 403 cases and passes
|
||||
</acceptance_criteria>
|
||||
<done>An MCP-dispatched call changes a URL's SEO in the right place, the resolver serves it, history records via mcp, and the permission gate holds.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: The full management API and one MCP tool per admin operation, effective SEO with sources, and the CMS-data issue report</name>
|
||||
<files>../sm-seo-plugin/routes.go, ../sm-seo-plugin/mcp.go, ../sm-seo-plugin/operations.go, ../sm-seo-plugin/controllers/api/seo.go, ../sm-seo-plugin/controllers/api/rules.go, ../sm-seo-plugin/controllers/api/redirects.go, ../sm-seo-plugin/controllers/api/notfound.go, ../sm-seo-plugin/controllers/api/robots.go, ../sm-seo-plugin/controllers/api/settings.go, ../sm-seo-plugin/controllers/api/history.go, ../sm-seo-plugin/controllers/api/issues.go, ../sm-seo-plugin/classes/issues.go, ../sm-seo-plugin/README.md, ../sm-seo-plugin/mcp_test.go</files>
|
||||
<read_first>
|
||||
- ../sm-seo-plugin/mcp.go, routes.go, controllers/api/seo.go (Task 1)
|
||||
- ../sm-seo-plugin/controllers/*.go (every admin controller, record/bulk/widget action of plans 32-03 and 32-04: the operation inventory)
|
||||
- .planning/phases/32-seo-foundation/32-CONTEXT.md (D-10 to D-14)
|
||||
- summercms.go/docs/services/mcp.md (tool declaration rules, read/write ceilings)
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-10, D-13, D-14 (CMS data checks only), D-15, D-19 and P-24: implement every route and tool listed in P-24 on the existing Service (no logic duplicated in handlers). `GET /seo?url=` answers the effective values with their sources, the owner (record type/id/locale or rule id), the redirect decision and any P1-style warnings. Writes refuse loops with 422 `{"error":"redirect_loop","path":[...]}` so the MCP tool result is an error (D-19). `GET /issues` (`classes/issues.go`) lists: missing effective titles and descriptions per locale, duplicate effective titles and descriptions across entries and rules, URL rules overriding a record, redirect chains with their final targets, canonicals pointing to a noindex or redirected URL, noindex URLs blocked by robots.txt; each issue carries url, kind, details and the tool that fixes it. `operations.go`: `AdminOperations` covering every controller, record action, bulk action, widget action and singleton save of the plugin; `TestEveryAdminOperationHasTool` (pure) checks every operation maps to a tool of `MCP()` and every tool's Method+Path is a route `Routes()` registers (use a recording `pact.Router`), and `TestMCPReadToolsAreGET` checks ReadOnly/GET consistency. README: the API and the tool list. Commit by logical change.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestEveryAdminOperationHasTool|TestMCPReadToolsAreGET|TestIssues|TestMCPSetURLSeoTracer' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -30</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of the four names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -c "Guard: *mcpGuard\|Guard: *\"backend\"" ../sm-seo-plugin/mcp.go` is at least 29
|
||||
- `grep -c "golem15.seo.manage\|mcpPermission" ../sm-seo-plugin/mcp.go` is at least 1 and every tool references it
|
||||
- `TestEveryAdminOperationHasTool` fails when one tool is removed (verified once by the executor locally, then restored)
|
||||
- `grep -n "\"/issues\"" ../sm-seo-plugin/routes.go` prints one line
|
||||
</acceptance_criteria>
|
||||
<done>Every admin operation has an MCP tool on a permission-checked JSON route, the effective SEO with sources and the CMS-data issue report are readable, and a parity test guards drift.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Batch dry-run and apply, undo of a change and of a batch, CSV import/export with the E6 Import and export screen</name>
|
||||
<files>../sm-seo-plugin/classes/batch.go, ../sm-seo-plugin/classes/undo.go, ../sm-seo-plugin/classes/csv.go, ../sm-seo-plugin/classes/transfer.go, ../sm-seo-plugin/classes/history.go, ../sm-seo-plugin/controllers/api/batch.go, ../sm-seo-plugin/controllers/api/transfer.go, ../sm-seo-plugin/controllers/api/history.go, ../sm-seo-plugin/controllers/history.go, ../sm-seo-plugin/controllers/history/config_form.yaml, ../sm-seo-plugin/controllers/transfer.go, ../sm-seo-plugin/controllers/transfer/config_form.yaml, ../sm-seo-plugin/controllers/admin_registry.go, ../sm-seo-plugin/admin_navigation.go, ../sm-seo-plugin/models/settings/fields.yaml, ../sm-seo-plugin/assets/src/elements/index.ts, ../sm-seo-plugin/assets/src/elements/labels.ts, ../sm-seo-plugin/assets/src/elements/transfer.ts, ../sm-seo-plugin/assets/src/elements/styles.css, ../sm-seo-plugin/assets/dist/seo.js, ../sm-seo-plugin/assets/dist/seo.css, ../sm-seo-plugin/lang/en/lang.yaml, ../sm-seo-plugin/lang/pl/lang.yaml, ../sm-seo-plugin/batch_test.go, ../sm-seo-plugin/transfer_test.go</files>
|
||||
<read_first>
|
||||
- .planning/phases/32-seo-foundation/32-RESEARCH.md (Pattern 8; Pitfall 14 caps; Security: CSV formula injection)
|
||||
- .planning/phases/32-seo-foundation/32-UI-SPEC.md (C12 undo actions, C13 Import and export, E6 copy, Destructive actions)
|
||||
- ../sm-seo-plugin/classes/service.go, classes/history.go, classes/redirect_graph.go
|
||||
- summercms.go/modules/lagoon/transaction.go
|
||||
</read_first>
|
||||
<behavior>
|
||||
- dry_run batch of 3 redirects and 1 set_seo: answers diff and conflicts and leaves every table row count and value unchanged
|
||||
- batch with one loop: 422 naming the change, nothing written; batch with a chain: applied with a chain warning
|
||||
- applied batch: all revisions share one batch_id and via; undo_batch restores every before value in one transaction and writes undo revisions; undo of one change restores its before value
|
||||
- undo after a newer change of the same field: refused with history.undo_stale naming the author and time; undo that would recreate a loop: history.undo_loop; undo for a deleted record: history.undo_gone
|
||||
- CSV export of redirects with semicolon: starts with a UTF-8 BOM, header row, a cell =cmd exported as 'cmd prefixed; import of the exported file previews all rows Unchanged
|
||||
- import with a missing column: transfer.missing_column; unreadable: transfer.unreadable; a looping row: Refused with transfer.row_loop and Apply refused; a records row whose URL has no record: transfer.row_rule
|
||||
- apply with a token after the data changed: transfer.stale; apply with a fresh token: one batch, via import
|
||||
- admin import over 60 KB is refused by the element before calling the action; an MCP import over 900 KB is refused with a 413-style error
|
||||
</behavior>
|
||||
<action>
|
||||
Implement D-12 and D-13 per P-26, P-27 and the behaviour list. Routes `POST /_seo/api/v1/batch` (`apply_batch`), `POST /_seo/api/v1/import` (`import_csv`), `GET /_seo/api/v1/export` (`export_csv`), `POST /_seo/api/v1/history/{id}/undo` (`undo_change`), `POST /_seo/api/v1/history/batches/{batch}/undo` (`undo_batch`). History preview gains record actions `undo` and `undo_batch` (UI-SPEC C12: non-danger confirms, refusals as 403 Message toasts, applies-conditions). `golem15.seo.transfer` (AdminSingleton on the settings row: `delimiter` dropdown defaulting to semicolon when the default locale is pl, `files` widget E6 with fill delimiter) and its widget action `seo_transfer` (ops export, preview, apply); E6 element `golem15-seo-transfer` per C13 with the E6 copy; navigation side-menu Import and export (icon download) and History entries per C2. Tests first: `TestBatch`, `TestUndo`, `TestLoopRefused` MCP and import cases (extend the admin test of plan 32-04 with `t.Run("mcp")` and `t.Run("import")`), `TestCSVTransfer`. Rebuild and commit `assets/dist`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test ./... -run 'TestBatch|TestUndo|TestLoopRefused|TestCSVTransfer' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -40</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or any of TestBatch, TestUndo, TestLoopRefused, TestCSVTransfer missing from the "--- PASS" lines, or TestLoopRefused without passing "mcp" and "import" subtests</fails_when>
|
||||
<automated>npm --prefix ../sm-seo-plugin run typecheck && bash ../sm-seo-plugin/scripts/check-dist.sh</automated>
|
||||
<fails_when>non-zero exit, a TypeScript error, or "assets/dist is stale" in the output</fails_when>
|
||||
<automated>go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "crypto/hmac" ../sm-seo-plugin/classes/transfer.go` prints one line
|
||||
- `grep -niE "bom|feff|xef" ../sm-seo-plugin/classes/csv.go` prints at least one line (BOM strip on import and prepend on export)
|
||||
- `TestBatch` asserts identical row counts and values before and after a dry run
|
||||
- `grep -n "undo_stale\|undo_loop\|undo_gone" ../sm-seo-plugin/classes/undo.go` prints the three refusals
|
||||
- `grep -c "customElements.define" ../sm-seo-plugin/assets/src/elements/*.ts` totals 7 (E1-E7)
|
||||
</acceptance_criteria>
|
||||
<done>Bulk changes preview and apply atomically, every change and batch can be undone safely, and CSV import/export works in the admin and over MCP with loop refusal on every path.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 4: Prove the demo mount in a scratch worktree, commit the demo's SEO tests, and write scripts/check-phase32.sh</name>
|
||||
<files>../sm-demo-app/seo_mount_test.go, ../sm-demo-app/seo_mcp_test.go, .planning/phases/32-seo-foundation/32-05-demo-mount.patch, scripts/check-phase32.sh</files>
|
||||
<read_first>
|
||||
- ../sm-demo-app/summer.yaml, go.work, .gitmodules, go_mod_test.go (TestGoModRequiresTags), boot_test.go, mcp_e2e_test.go, scripts/check-pins.sh, deploy/nginx/demo.summercms.io.conf (the /sitemap.xml location), DEPLOY.md, config/app.yaml, config/menu_items.yaml
|
||||
- scripts/check-phase19.7.sh (stage structure, detectors, NOT RUN docker, marker stage, workspace check)
|
||||
- .planning/phases/32-seo-foundation/32-01-SUMMARY.md (the phase base SHA) and 32-02-SUMMARY.md (Journal commit SHAs)
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-04-PLAN.md (P-18 local fetch of submodules) and .planning/phases/19.6-two-factor-auth-and-device-flow-in-sm-user-plugin/19.6-03-PLAN.md (mounting a new plugin needs tags)
|
||||
</read_first>
|
||||
<action>
|
||||
Per P-28, D-90, SC-2, SC-4:
|
||||
1. Check `git -c safe.directory='*' -C ../sm-demo-app status --short` first and leave every existing change alone (the journal and oauthserver submodule entries already show another session's drift). Do not edit, stage or commit summer.yaml, go.work, go.mod, .gitmodules, plugins.gen.go, main.go or any submodule pointer of the real demo in this plan.
|
||||
2. Demo tests (committed in ../sm-demo-app): `seo_mount_test.go` `TestSEOTabMounted` boots the demo plugin set; when `golem15.seo` is not registered it calls `t.Skip("NOT MOUNTED golem15.seo")`; otherwise it asserts the form schemas of `golem15.journal.posts`, `golem15.journal.categories` and `golem15.journal.tags` contain the SEO tab last and the Journal post tab order Edit, Manage, Categories, SEO. `seo_mcp_test.go` (`//go:build summercms_mcp`) `TestSEOToolsCatalog` compiles the pier catalog and asserts it contains `seo_` + every tool name the registered `golem15.seo` plugin returns from `MCP()` (found through the party registry and `pact.HasMCP`, no import of the SEO package; same skip rule). Both compile and skip on the current demo: run `go -C ../sm-demo-app test -short -run 'TestSEOTabMounted' .` and the tagged variant, then commit `test: SEO mount and MCP catalog checks (skip until mounted)` staging only the two files.
|
||||
3. Scratch proof: `git -c safe.directory='*' -C ../sm-demo-app worktree add --detach "$WT" HEAD` with `WT=$(mktemp -d)/demo`; in it add `golem15.seo` to summer.yaml after golem15.sitemap; write `$WT/config/golem15.seo.yaml` (site_url of the Nuxt origin, notfound_token read from the environment); add `location = /robots.txt` to the nginx config next to `/sitemap.xml`; add a DEPLOY.md section (robots.txt moves to Go, copy the Disallow lines the Nuxt robots config writes today into SEO › robots.txt, set `SUMMER_GOLEM15__SEO__NOTFOUND_TOKEN`); write a scratch go.work outside the worktree using absolute paths: the worktree, every live `../sm-demo-app/plugins/golem15/*` checkout except journal, `../sm-journal-plugin` (plan 32-02 commits), `../sm-seo-plugin`, with the demo's replace lines and `git.golem15.com/golem15/summercms => <abs>/summercms.go`; run `go run <abs>/summercms.go/cmd/summer build` in the worktree (GOWORK set) to regenerate plugins.gen.go and main.go; run `GOWORK=<scratch> go test -run 'TestSEOTabMounted|TestBootAllPlugins' .` and `GOWORK=<scratch> go test -tags summercms_mcp -run 'TestSEOToolsCatalog' .` (both must pass, not skip). Save `git -C "$WT" diff -- summer.yaml config deploy DEPLOY.md` (plus the new config file via `git add -N`) as `.planning/phases/32-seo-foundation/32-05-demo-mount.patch`; remove the worktree (`git worktree remove --force`).
|
||||
4. `scripts/check-phase32.sh` modelled on check-phase19.7.sh: stages `self-test`, `go` (framework vet, `go test -short ./...`, required names TestFormExtensionTracer excluded as Docker, TestFormExtensionPlacement, TestFormExtensionBootErrors, TestFormExtensionUnextendedSchemaUnchanged, TestContent*), `plugins` (sm-seo-plugin and sm-journal-plugin: workspace check that the framework resolves to this checkout, vet, test -short, required names), `consumers` (sm-demo-app build and `-short` tests untagged and tagged; prints `NOT MOUNTED golem15.seo` and fails unless `PHASE32_ALLOW_UNMOUNTED=1`; a route-drift check that each Journal pattern in the demo's `config/menu_items.yaml` (journal-post, journal-category, and journal-tag when set) equals the route the demo's Nuxt app configures for the Journal layer, else the layer default in `../vue-journal-layer/app/utils/routes.ts`, because strict URLs 301 valid pages when the two drift, RESEARCH Pitfall 15), `docker` (Postgres suites by required name in the framework, both plugins and the demo; NOT RUN without Docker, a failure with `PHASE32_REQUIRE_DOCKER=1`), `admin` (FormView vitest, `scripts/check-admin-openapi.sh --check`, `scripts/check-admin-dist.sh` only when admin/src changed since the phase base), `docs` (TestDocsTree, `go run ./cmd/summer docs:build --check`, the grobotstxt decision note and STACK row present, `npm --prefix ../sm-seo-plugin run typecheck` and its check-dist), `marker` (D-90: lines added since `PHASE32_BASE` — default the plan 32-01 start SHA from 32-01-SUMMARY.md — in non-test Go files, READMEs and docs under modules/ and docs/ match neither `(?i)\bseo\b` nor a consuming application name (the list check-phase19.7.sh uses); `../sm-journal-plugin` has no import of sm-seo-plugin or sm-sitemap-plugin; the framework go.mod does not require grobotstxt). `--all` runs every stage. Plan 32-06 adds the `additive` and `compat` stages. Commit `test(32-05): check-phase32 gate` and, separately as a planning-docs commit, the patch file.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase32.sh --self-test</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" or "refuse:" line in the output</fails_when>
|
||||
<automated>PHASE32_ALLOW_UNMOUNTED=1 bash scripts/check-phase32.sh --go --plugins --consumers --docs --marker</automated>
|
||||
<fails_when>non-zero exit, a "FAIL" line, or a marker line naming a file under modules/ or docs/</fails_when>
|
||||
<automated>go -C ../sm-demo-app vet ./... && go -C ../sm-demo-app test -short ./...</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output (the demo stays green with the two new skipping tests)</fails_when>
|
||||
<automated>test -s .planning/phases/32-seo-foundation/32-05-demo-mount.patch && grep -c "golem15.seo" .planning/phases/32-seo-foundation/32-05-demo-mount.patch</automated>
|
||||
<fails_when>non-zero exit, or a count of 0 (the patch is missing or does not mount the plugin)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- The executor's SUMMARY quotes the scratch run's `--- PASS: TestSEOTabMounted` and `--- PASS: TestSEOToolsCatalog` lines (not SKIP)
|
||||
- `git -c safe.directory='*' -C ../sm-demo-app show --stat HEAD` lists exactly seo_mount_test.go and seo_mcp_test.go
|
||||
- `git -c safe.directory='*' -C ../sm-demo-app worktree list` shows no leftover scratch worktree
|
||||
- `grep -n "PHASE32_BASE" scripts/check-phase32.sh` prints the default base SHA line
|
||||
- `bash scripts/check-phase32.sh --marker` exits 0
|
||||
</acceptance_criteria>
|
||||
<done>The demo mount is proven end to end in a scratch worktree and stored as a patch for the release plan, the demo carries tests that activate once the plugin is mounted, and the phase gate exists with the D-90 marker stage.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| MCP client → pier → /_seo/api/v1 | agent-driven calls under a linked admin's identity and grant ceiling |
|
||||
| admin browser → E6 import | uploaded CSV content |
|
||||
| exported CSV → spreadsheet application | cells opened by an editor's spreadsheet program |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-23 | Elevation of privilege | MCP read grants and management routes | high | mitigate | Writes are non-GET tools under pier's read/write ceiling; every route checks golem15.seo.manage (TestMCPReadToolsAreGET, TestMCPSetURLSeoTracer 403 case) |
|
||||
| T-32-24 | Tampering | CSV export formula injection | medium | mitigate | Cells starting with = + - @ tab or CR are prefixed with an apostrophe (TestCSVTransfer) |
|
||||
| T-32-25 | Tampering | stale or forged import apply | high | mitigate | HMAC-SHA256 token keyed by the app key over dataset, rows and a data fingerprint; apply re-runs the dry run and refuses transfer.stale |
|
||||
| T-32-26 | Tampering | partial batch application | high | mitigate | One lagoon.Transaction per batch; any refused change rolls back everything (TestBatch) |
|
||||
| T-32-27 | Tampering | undo overwriting newer changes | high | mitigate | Staleness guard compares current values with the revision's after values; loop and gone guards (TestUndo) |
|
||||
| T-32-28 | Repudiation | who changed SEO | medium | mitigate | Every revision stores author, via (mcp from bouncer.Dispatched), time and before/after; undo is itself a revision |
|
||||
| T-32-29 | Denial of service | large CSV and batch payloads | medium | mitigate | 60 KB admin import, 256 KiB export per action, 900 KB MCP import, the framework body limit, throttle bucket seo-api |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | No new package; the element toolchain was approved at plan 32-03 Task 4 |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...` green with Docker.
|
||||
- `npm --prefix ../sm-seo-plugin run typecheck` and check-dist green.
|
||||
- `bash scripts/check-phase32.sh --self-test` and `PHASE32_ALLOW_UNMOUNTED=1 bash scripts/check-phase32.sh --go --plugins --consumers --docs --marker` green.
|
||||
- sm-demo-app green with the two skipping tests; its other uncommitted changes untouched.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
Every SEO admin operation is available as an MCP tool, batches are previewed with dry-run and applied atomically, every change and batch can be undone from history, loops are refused from the admin, MCP and imports, and the phase gate is in place.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 05)
|
||||
|
||||
- Routes under `/_seo/api/v1`: `/seo`, `/rules`, `/rules/{id}`, `/redirects`, `/redirects/{id}`, `/notfound`, `/notfound/{id}/redirect`, `/notfound/{id}/gone`, `/notfound/{id}`, `/robots`, `/robots/test`, `/settings`, `/history`, `/history/{id}`, `/history/{id}/undo`, `/history/batches/{batch}/undo`, `/export`, `/import`, `/batch`, `/issues`; bucket `seo-api`
|
||||
- MCP tools (prefixed `seo_` by pier): `get_url_seo`, `set_url_seo`, `list_rules`, `show_rule`, `create_rule`, `update_rule`, `delete_rule`, `list_redirects`, `show_redirect`, `create_redirect`, `update_redirect`, `delete_redirect`, `list_not_found`, `redirect_not_found`, `gone_not_found`, `delete_not_found`, `show_robots`, `update_robots`, `test_robots`, `show_settings`, `update_settings`, `list_history`, `show_history`, `undo_change`, `undo_batch`, `export_csv`, `import_csv`, `apply_batch`, `list_issues`
|
||||
- `operations.go` `AdminOperations`; `classes` owner resolution, `Batch`, undo, CSV, transfer token, issues
|
||||
- Controller `golem15.seo.transfer` (AdminSingleton), element `golem15-seo-transfer` (E6), widget action `seo_transfer`, history record actions `undo`, `undo_batch`
|
||||
- Demo tests `TestSEOTabMounted`, `TestSEOToolsCatalog`; `.planning/phases/32-seo-foundation/32-05-demo-mount.patch`
|
||||
- `scripts/check-phase32.sh` (stages self-test, go, plugins, consumers, docker, admin, docs, marker; env `PHASE32_BASE`, `PHASE32_ALLOW_UNMOUNTED`, `PHASE32_REQUIRE_DOCKER`)
|
||||
- Tests `TestMCPSetURLSeoTracer`, `TestEveryAdminOperationHasTool`, `TestMCPReadToolsAreGET`, `TestIssues`, `TestBatch`, `TestUndo`, `TestCSVTransfer`, `TestLoopRefused` (mcp, import)
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-05-SUMMARY.md` when done with the commit SHAs in all three repositories, the scratch-run PASS lines and the demo working-tree state found at the start.
|
||||
</output>
|
||||
399
.planning/phases/32-seo-foundation/32-05-SUMMARY.md
Normal file
399
.planning/phases/32-seo-foundation/32-05-SUMMARY.md
Normal file
@@ -0,0 +1,399 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 05
|
||||
subsystem: sm-seo-plugin
|
||||
tags: [seo, sm-seo-plugin, mcp, pier, batch, undo, csv, hmac, custom-elements, sm-demo-app, phase-gate]
|
||||
|
||||
requires:
|
||||
- phase: 32-03
|
||||
provides: classes.Service, Resolver with sources, history (Record, WithVia, ViaOf with bouncer.Dispatched), golem15.seo.manage
|
||||
- phase: 32-04
|
||||
provides: SaveRedirect, CheckRedirect, DeleteRedirect, ResolveNotFound, LoopError/ProblemsError, robots.txt screen and tester
|
||||
- phase: 19.7
|
||||
provides: pier (pact.HasMCP, tool binding to routes, read/write ceiling), cabana.ResolveBackend with the dispatch marker
|
||||
provides:
|
||||
- "/_seo/api/v1 management API (bucket seo-api): seo, rules, redirects, notfound actions, robots and its tester, settings, history, undo, batch, export, import, issues"
|
||||
- "29 MCP tools (seo_ prefix), backend guard, golem15.seo.manage; GET tools read-only"
|
||||
- "AdminOperations (operations.go) and TestEveryAdminOperationHasTool / TestMCPReadToolsAreGET"
|
||||
- "URL addressing (FindOwner, SetURLSEO): record behind the URL, else an exact URL rule; force_rule"
|
||||
- "RunBatch: dry run by rollback, all or nothing, per-change diff and conflicts (loop refused; chain, noindex_published, canonical_redirected, canonical_noindex warnings)"
|
||||
- "Undo of a change and of a batch with undo_stale, undo_loop, undo_gone; History record actions undo and undo_batch"
|
||||
- "CSV export/import (redirects, rules, records by URL): BOM, , or ;, formula escaping, preview, HMAC-SHA256 apply token with a data fingerprint (transfer.stale)"
|
||||
- "golem15.seo.transfer singleton with the seo_transfer widget action and element E6 golem15-seo-transfer; navigation Import and export"
|
||||
- "CMS-data issue report (classes.Issues, GET /issues)"
|
||||
- "scripts/check-phase32.sh (self-test, go, plugins, consumers, docker, admin, docs, marker)"
|
||||
- ".planning/phases/32-seo-foundation/32-05-demo-mount.patch (applied by plan 32-06 after the tags)"
|
||||
affects: [32-06, 33, sm-demo-app, vue-seo-layer]
|
||||
|
||||
actuals:
|
||||
tokens: 80181
|
||||
tasks: 4
|
||||
commits: 2
|
||||
plan_head_before: f96d7d4b4a91821bb184509a19fe9ff2dd51c3d5
|
||||
plan_head_after: 20d02d722a5f46437c7d96c51965d41ad51ec127
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Management route wrapper (controllers/api manage): cabana.ResolveBackend (token or MCP dispatch) + cabana.Allows(golem15.seo.manage), typed refusals mapped to 422 redirect_loop / validation_failed, 404, 409"
|
||||
- "classes.WithTx puts the API/batch transaction on the context so the resolver and every service read see uncommitted batch changes"
|
||||
- "Batch changes run under per-change savepoints; the diff is the history rows the change wrote under the batch id"
|
||||
- "Widget-action refusals the element must show inline are answered as data {op, error, message}, not as an action error (the SPA only toasts errors)"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ../sm-seo-plugin/mcp.go
|
||||
- ../sm-seo-plugin/operations.go
|
||||
- ../sm-seo-plugin/operations_test.go
|
||||
- ../sm-seo-plugin/mcp_test.go
|
||||
- ../sm-seo-plugin/batch_test.go
|
||||
- ../sm-seo-plugin/transfer_test.go
|
||||
- ../sm-seo-plugin/classes/owner.go
|
||||
- ../sm-seo-plugin/classes/rules.go
|
||||
- ../sm-seo-plugin/classes/manage.go
|
||||
- ../sm-seo-plugin/classes/robots_write.go
|
||||
- ../sm-seo-plugin/classes/settings_write.go
|
||||
- ../sm-seo-plugin/classes/issues.go
|
||||
- ../sm-seo-plugin/classes/batch.go
|
||||
- ../sm-seo-plugin/classes/undo.go
|
||||
- ../sm-seo-plugin/classes/csv.go
|
||||
- ../sm-seo-plugin/classes/transfer.go
|
||||
- ../sm-seo-plugin/controllers/api/auth.go
|
||||
- ../sm-seo-plugin/controllers/api/seo.go
|
||||
- ../sm-seo-plugin/controllers/api/rules.go
|
||||
- ../sm-seo-plugin/controllers/api/redirects.go
|
||||
- ../sm-seo-plugin/controllers/api/settings.go
|
||||
- ../sm-seo-plugin/controllers/api/history.go
|
||||
- ../sm-seo-plugin/controllers/api/issues.go
|
||||
- ../sm-seo-plugin/controllers/api/batch.go
|
||||
- ../sm-seo-plugin/controllers/api/transfer.go
|
||||
- ../sm-seo-plugin/controllers/transfer.go
|
||||
- ../sm-seo-plugin/controllers/transfer/config_form.yaml
|
||||
- ../sm-seo-plugin/models/transfer.go
|
||||
- ../sm-seo-plugin/models/transfer/fields.yaml
|
||||
- ../sm-seo-plugin/assets/src/elements/transfer.ts
|
||||
- scripts/check-phase32.sh
|
||||
- .planning/phases/32-seo-foundation/32-05-demo-mount.patch
|
||||
modified:
|
||||
- ../sm-seo-plugin/routes.go
|
||||
- ../sm-seo-plugin/classes/service.go
|
||||
- ../sm-seo-plugin/classes/history.go
|
||||
- ../sm-seo-plugin/extensions_robots.go
|
||||
- ../sm-seo-plugin/controllers/api/notfound.go
|
||||
- ../sm-seo-plugin/controllers/api/robots.go
|
||||
- ../sm-seo-plugin/controllers/history.go
|
||||
- ../sm-seo-plugin/controllers/history/config_form.yaml
|
||||
- ../sm-seo-plugin/controllers/admin_registry.go
|
||||
- ../sm-seo-plugin/admin_navigation.go
|
||||
- ../sm-seo-plugin/redirects_test.go
|
||||
- ../sm-seo-plugin/lang/en/lang.yaml
|
||||
- ../sm-seo-plugin/lang/pl/lang.yaml
|
||||
- ../sm-seo-plugin/assets/src/elements/index.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/labels.ts
|
||||
- ../sm-seo-plugin/assets/src/elements/styles.css
|
||||
- ../sm-seo-plugin/assets/dist/seo.js
|
||||
- ../sm-seo-plugin/assets/dist/seo.css
|
||||
- ../sm-seo-plugin/README.md
|
||||
|
||||
key-decisions:
|
||||
- "Orchestrator override: nothing is committed to sm-demo-app in this plan; the two demo tests (TestSEOTabMounted, TestSEOToolsCatalog) travel inside 32-05-demo-mount.patch with the mount, for plan 32-06"
|
||||
- "Management API errors: refused writes are 422 (redirect_loop with path and message, validation_failed with translated field errors), undo refusals and an address a rule already answers are 409, a stale import 409 through the API"
|
||||
- "An undo restores through the service (SaveRecord, SaveRule, SaveRedirect, SaveRobots, SaveSettings) so loops are refused and the undo is itself a revision; staleness compares the current value of every field the change wrote with its after value (JSON-normalised)"
|
||||
- "The import apply token carries the gzip-compressed file, delimiter, dataset and fingerprint, signed with HMAC-SHA256 under a key derived from app.key (a per-process random key when the app has none); apply re-runs the preview and refuses when the fingerprint differs"
|
||||
- "Import maps rows inside the batch transaction; the fingerprint hashes every row's address and the current state of the object it changes, so a row that was unchanged or new at preview time also makes the apply stale"
|
||||
- "The exported apostrophe on formula cells is dropped again on import, so an exported file re-imports as all unchanged"
|
||||
- "The transfer screen's delimiter is the settings column csv_delimiter through a separate models.Transfer view of row 1 (field csv_delimiter, widget _transfer); show/save map to show_settings/update_settings"
|
||||
- "History undo_batch confirm has no :count (record-action confirms take no parameters, as in 32-04)"
|
||||
- "The robots.txt admin save now runs classes.SaveRobots too (one write path for admin and API)"
|
||||
|
||||
patterns-established:
|
||||
- "Every SEO admin operation is listed in AdminOperations with its tool; the parity test derives the required list from controllers, config_list toolbars, record/bulk/widget actions, form extensions and field-type uploads"
|
||||
|
||||
requirements-completed: [SC-2, SC-3, SC-4, D-10, D-11, D-12, D-13, D-14, D-15, D-19, D-90, D-94, D-98]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Tracer: an MCP-dispatched administrator sets noindex on /pages/a (written_to record, en), resolve answers robots and x_robots_tag noindex, history via mcp with an MCP: author; /landing gets an exact URL rule; force_rule writes a rule; no permission is 403, anonymous 401"
|
||||
requirement: "D-11"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/mcp_test.go#TestMCPSetURLSeoTracer"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Every admin operation maps to an MCP tool bound to a registered /_seo/api/v1 route (fails when a tool is removed, verified locally); tools are read-only exactly when GET, all backend guard + golem15.seo.manage"
|
||||
requirement: "D-10"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "../sm-seo-plugin/operations_test.go#TestEveryAdminOperationHasTool"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "../sm-seo-plugin/operations_test.go#TestMCPReadToolsAreGET"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "Management API as an MCP client: effective SEO with sources/owner, rules CRUD, redirects (loop 422 redirect_loop with path, chain warning, origin mcp), 404 log actions (409 on a resolved address), robots.txt and tester, settings refusals, history via mcp"
|
||||
requirement: "D-13"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/mcp_test.go#TestManagementAPI"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "CMS-data issue report: missing description, duplicate title, rule over record, redirect chain with final target, canonical redirected, noindex blocked by robots.txt, each with its fixing tool"
|
||||
requirement: "D-14"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/mcp_test.go#TestIssues"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "Batch: dry run answers diff and conflicts (chain, noindex_published, canonical_redirected) and leaves every row identical; a loop or an invalid value refuses the whole batch with 422 naming the change; apply writes one batch id via mcp"
|
||||
requirement: "D-12"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/batch_test.go#TestBatch"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Undo of one change (undo revision), already_undone, undo_stale naming the author, undo_loop with the path, undo_gone for a deleted record, batch undo as a whole, History record actions undo/undo_batch with 403 refusals"
|
||||
requirement: "D-13"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/batch_test.go#TestUndo"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "CSV: export with BOM, ; and 'escaped formula cells re-imports unchanged; missing_column, unreadable; a looping row refused and the apply 422; records rows create a URL rule without a record; admin token stale after a data change, forged token refused, fresh apply as one import batch; 60 KB admin and 900 KB MCP caps"
|
||||
requirement: "D-13"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/transfer_test.go#TestCSVTransfer"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D8
|
||||
description: "Loops are refused from MCP (tool error with path, also in a batch) and from CSV import (refused row, apply refused), as from the admin"
|
||||
requirement: "SC-3"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "../sm-seo-plugin/redirects_test.go#TestLoopRefused"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D9
|
||||
description: "Demo mount proven in a scratch worktree: Journal posts, categories and tags carry the SEO tab last (posts Edit, Manage, Categories, SEO) and the pier catalog lists every seo_ tool (read grant: GET tools only)"
|
||||
requirement: "SC-4"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "sm-demo-app scratch worktree (32-05-demo-mount.patch)#TestSEOTabMounted, TestSEOToolsCatalog, TestBootAllPlugins"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D10
|
||||
description: "scripts/check-phase32.sh: self-test, go, consumers, docker, admin, docs and marker pass (unmounted allowed); plugins stage blocked only by an unreadable sibling fixture file"
|
||||
requirement: "D-90"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase32.sh --self-test; PHASE32_ALLOW_UNMOUNTED=1 bash scripts/check-phase32.sh --consumers --docs --marker; --docker; --admin; --go"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "The plugins stage fails on TestNoTideJournalFixtures in sm-journal-plugin (../fonoteka.go fixture owned by jin, mode 0600, unreadable by the executor), not on phase code; a run as a user that can read it must confirm"
|
||||
- id: D11
|
||||
description: "E6 golem15-seo-transfer looks and behaves as UI-SPEC C13 in the real admin SPA (layout, badges, busy labels, Blob download, inline stale message)"
|
||||
verification: []
|
||||
human_judgment: true
|
||||
rationale: "Visual and interaction behaviour in the SPA; only a throwaway happy-dom smoke ran (render, refused/nothing gating, stale message kept, pl plural), element unit tests are plan 32-06"
|
||||
|
||||
duration: 45min
|
||||
completed: 2026-10-27
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 05: SEO management over MCP, batches, undo and CSV Summary
|
||||
|
||||
**Every SEO admin operation is now a permission-checked `/_seo/api/v1` route with an MCP tool (29 `seo_` tools, a parity test guarding drift). Pages are addressed by URL (record or URL rule). Batches dry-run by rollback and apply all or nothing. Any change or batch can be undone with stale/loop/gone guards. CSV import and export work in a new admin screen (E6, HMAC apply token) and over MCP, and loops are refused on every path. The demo mount is proven in a scratch worktree and stored as a patch, and the phase gate `check-phase32.sh` exists.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 45 min
|
||||
- **Started:** 2026-10-27T11:03:21Z
|
||||
- **Completed:** 2026-10-27T11:48:42Z
|
||||
- **Tasks:** 4
|
||||
- **Files:** 49 files changed in ../sm-seo-plugin (7437 insertions), 2 files in this repository
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- **Management API and tools (D-10, D-11, D-13, D-15, P-24, P-25).**
|
||||
- Routes under `/_seo/api/v1` (bucket `seo-api`). Each resolves the administrator through `cabana.ResolveBackend`, so a pier dispatch runs as the linked admin. Each needs `golem15.seo.manage`.
|
||||
- `AdminOperations` maps every admin operation to a tool. `TestEveryAdminOperationHasTool` derives the operations from the controllers, configs, actions, form extensions and field-type uploads. It failed when `test_robots` was renamed and when `show_history` was dropped, and was then restored.
|
||||
- **URL addressing.** `PUT /seo` writes to the record behind the URL in its locale, else to an exact rule. `force_rule` always writes a rule. The answer names `written_to`, `type`, `id`, `locale` and `rule_id`.
|
||||
- **Issue report (D-14 CMS part).** Missing and duplicate titles and descriptions, rules over records, chains, canonicals that point to noindex or redirected pages, and noindex pages blocked by robots.txt. Each issue names the tool that fixes it.
|
||||
- **Batches (D-12, P-26).** One transaction with a savepoint per change. The diff is the history rows the batch wrote. A dry run rolls back on purpose; a refused change rolls back everything.
|
||||
- **Undo (D-13).** `Undo` and `UndoBatch` restore through the service. The undo is itself recorded, and the undone rows are marked.
|
||||
- **CSV (D-13, P-27).** Export and import of redirects, rules and records by URL. Formula cells are escaped on export and unescaped on import. The `golem15.seo.transfer` screen has element E6; MCP has `export_csv` and `import_csv`.
|
||||
|
||||
## Task Commits
|
||||
|
||||
../sm-seo-plugin, branch main, not pushed:
|
||||
|
||||
1. **Task 1 (tracer):** `cadf6ad` feat: SEO by URL over the management API and MCP (tracer)
|
||||
2. **Task 2:** `aa0c3bc` feat: management API and an MCP tool per SEO admin operation
|
||||
3. **Task 3:**
|
||||
- `ab3b219` feat: batches with dry run, undo, and CSV import and export
|
||||
- `6f69031` feat: import and export element (E6)
|
||||
4. **Task 4:** this repository:
|
||||
- `9247761` test(32-05): check-phase32 gate
|
||||
- `20d02d7` docs(32-05): sm-demo-app mount patch for golem15.seo
|
||||
|
||||
sm-demo-app: no commit (orchestrator instruction).
|
||||
|
||||
`commits: 2` is measured in this repository with `git rev-list --count f96d7d4..HEAD` before this SUMMARY's commit. The plugin's 4 commits are counted with `git rev-list --count b398161..HEAD`.
|
||||
|
||||
Tracer feedback gate: end-of-phase mode with an automated-only verify. `TestMCPSetURLSeoTracer`, vet and the `-short` tests re-ran green before Task 2.
|
||||
|
||||
## Scratch run (sm-demo-app worktree at 8fcdbdd, mount applied)
|
||||
|
||||
- **Setup:**
|
||||
- The scratch go.work used absolute paths: the worktree, the live `plugins/golem15/*` checkouts except journal, `../sm-journal-plugin`, `../sm-seo-plugin`, and the framework replace.
|
||||
- `summer build` printed `✓ Built bin/demo` and regenerated `plugins.gen.go`.
|
||||
- **Tagged run:** `go test -tags summercms_mcp -run 'TestSEOToolsCatalog|TestSEOTabMounted|TestBootAllPlugins'`:
|
||||
|
||||
```
|
||||
--- PASS: TestBootAllPlugins (0.78s)
|
||||
--- PASS: TestBootAllPlugins/realtime (0.38s)
|
||||
--- PASS: TestSEOToolsCatalog (1.34s)
|
||||
--- PASS: TestSEOTabMounted (0.54s)
|
||||
```
|
||||
|
||||
- **Untagged run:** the same two passed (`--- PASS: TestSEOTabMounted (1.11s)`).
|
||||
- **Unmounted:** both tests compile and skip with `NOT MOUNTED golem15.seo`, untagged and tagged.
|
||||
- **Expected failure:** in the mounted scratch, `go test -short` fails only `TestGoModRequiresTags` (no tagged sm-seo-plugin require yet). This is P-28 and is resolved in plan 32-06.
|
||||
- **Patch check:** `git apply --check` of the patch on a clean 8fcdbdd passed.
|
||||
- **Cleanup:** the scratch worktree is removed, and `git worktree list` shows only the main checkout.
|
||||
|
||||
**Demo working tree found at the start:** ` M plugins/golem15/journal`, ` M plugins/golem15/oauthserver` (another session's submodule drift). It is unchanged at the end.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
Task 3 is `tdd="true"`; `workflow.tdd_mode` is false.
|
||||
- **RED:** `TestBatch`, `TestUndo`, `TestCSVTransfer` and the `mcp`/`import` subtests of `TestLoopRefused` were written first. All four failed with 404, because the routes did not exist yet. The evidence is in the scratchpad file `32-05-task3-red.txt`.
|
||||
- **GREEN:** the implementation followed in commit `ab3b219`.
|
||||
- **No separate RED commit:** a `test(...)` commit would break the plugin's green-at-every-commit rule (CLAUDE.md).
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
See `key-files` in the frontmatter.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See `key-decisions` in the frontmatter.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Orchestrator override] Demo tests not committed to sm-demo-app**
|
||||
- **What the plan said:** commit `seo_mount_test.go` and `seo_mcp_test.go` in sm-demo-app.
|
||||
- **What changed:** the dispatch said not to commit to sm-demo-app, so both files are in `32-05-demo-mount.patch`.
|
||||
- **Consequence:** the acceptance criterion `git show --stat HEAD` in sm-demo-app does not apply.
|
||||
|
||||
**2. [Rule 3 - Blocking] TestBootAllPlugins needs the plugin list**
|
||||
- **Issue:** the demo's test counts its plugins exactly, so mounting the SEO plugin breaks it.
|
||||
- **Fix:** the patch also adds `golem15.seo` to `wantPlugins` and `/_seo/api/v1` and `/robots.txt` to the routed prefixes.
|
||||
|
||||
**3. [Rule 3 - Blocking] `summer build` ignores GOWORK**
|
||||
- **Issue:** `summer build` uses the app's own go.work.
|
||||
- **Fix:** the scratch go.work was copied over the worktree's go.work for the build only, then restored. The patch carries no go.work.
|
||||
|
||||
**4. [Rule 3 - Blocking] surf `Where` applies to the last route only**
|
||||
- **Issue:** `g.Where("id", …)` after a group of routes refused the boot.
|
||||
- **Fix:** ids are validated in the handler (`pathID`, 404).
|
||||
|
||||
**5. [Rule 3 - Blocking] History recordActions needs a preview block**
|
||||
- **Fix:** `preview: {}` in `controllers/history/config_form.yaml`.
|
||||
|
||||
**6. [Rule 1 - Bug] A semicolon in a query is dropped by Go's net/url**
|
||||
- **Issue:** `delimiter=;` arrives empty.
|
||||
- **Fix:** the test sends `%3B`; pier encodes query arguments itself.
|
||||
|
||||
**7. [Rule 2 - Missing critical] An import of a dry run with a refused row**
|
||||
- **Issue:** a dry run with a refused row answered `import_refused`.
|
||||
- **Fix:** it now answers the preview; only an apply is refused.
|
||||
|
||||
**8. [Plan detail] Field names and files**
|
||||
- **Transfer screen:**
|
||||
- The delimiter field is `csv_delimiter`, the column of the settings row (cabana binds scalar fields to model columns), and the widget is `_transfer`.
|
||||
- The form is `models/transfer/fields.yaml` with a `models.Transfer` view of the row; `models/settings/fields.yaml` is unchanged.
|
||||
- **Shared field types:** `classes.RedirectFields` and `classes.RuleFields` are shared by the API and the batch.
|
||||
- **Extra class files:** `classes/manage.go`, `rules.go`, `robots_write.go` and `settings_write.go`.
|
||||
- **Extra tests:** `TestManagementAPI` and `TestIssues`.
|
||||
|
||||
**9. [Plan detail] Acceptance greps**
|
||||
- **`Path: "/_seo/api/v1/seo"` in mcp.go:** prints two lines after Task 2 (GET `get_url_seo` and PUT `set_url_seo`); Task 1 printed one.
|
||||
- **`customElements.define`:** totals 1, because index.ts defines from one list, the 32-03 pattern. That list now holds the 7 elements E1–E7.
|
||||
- **Guard count:** `grep -c "Guard: *mcpGuard"` is 29.
|
||||
|
||||
**10. [Framework constraint] Message parameters**
|
||||
- **Undo batch confirm:** has no `:count` (record-action confirms take no parameters).
|
||||
- **Applied toast:** `transfer.applied` is translated in the action with `Service.ChoiceCtx`.
|
||||
|
||||
**11. [Plan detail] E6 refusals shown inline**
|
||||
- **Issue:** the SPA only toasts action errors, so the element could not show the stale message itself.
|
||||
- **Fix:** stale, unreadable, missing column, too large and token refusals are answered as data `{op, error, message}`, so the preview stays on screen with the message.
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 11.
|
||||
- 1 orchestrator override;
|
||||
- 4 blocking;
|
||||
- 1 bug;
|
||||
- 1 missing critical;
|
||||
- 4 plan details or framework constraints.
|
||||
|
||||
**Impact on plan:** behaviour is as planned. The demo tests ship in the patch instead of a demo commit.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- **`--plugins` gate stage fails on an environmental cause.** `TestNoTideJournalFixtures` in sm-journal-plugin opens `../fonoteka.go/parity/fixtures/mcp/mcp-oauth.yaml`. That file is owned by `jin` with mode 0600, so the executor cannot read it. The plan does not touch it.
|
||||
- The SEO and Journal checks of the stage pass when run by hand: vet, `-short`, and the required names `TestEveryAdminOperationHasTool`, `TestMCPReadToolsAreGET`, `TestLangKeysComplete`, `TestNormalize`, `TestJournalMCP` and `TestMenuItemTypesPatterns`.
|
||||
- **Other gate stages:**
|
||||
- `--self-test`: 21 checks pass.
|
||||
- `--go`, `--consumers` (`NOT MOUNTED golem15.seo` allowed; the route-drift check passes), `--docs` and `--marker`: pass (2756 added framework lines checked).
|
||||
- `--docker`: 3 framework, 25 SEO and 5 Journal Postgres tests pass.
|
||||
- `--admin`: 1563 vitest tests pass, plus the openapi check.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None. MCP uploads of the social image are not a tool: `set_url_seo` takes `og_image` as a URL.
|
||||
|
||||
## Threat Flags
|
||||
|
||||
| Flag | File | Description |
|
||||
|------|------|-------------|
|
||||
| threat_flag: endpoint | ../sm-seo-plugin/controllers/api/*.go | 24 new management routes under /_seo/api/v1. Each resolves a backend principal and requires golem15.seo.manage, with throttle bucket seo-api (T-32-23). |
|
||||
| threat_flag: token | ../sm-seo-plugin/classes/transfer.go | An HMAC-signed, gzip-compressed import token round-trips through the browser. It is signed under an app.key-derived key, and a forged or edited token is refused (T-32-25). |
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None. The demo's `SUMMER_GOLEM15__SEO__NOTFOUND_TOKEN` and the robots.txt copy are documented in the patch's DEPLOY.md section for plan 32-06.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Plan 32-06:**
|
||||
- adds the element unit tests and the `additive`/`compat` gate stages;
|
||||
- tags the framework, Journal and SEO plugin (with Jakub's go-ahead);
|
||||
- bumps the requires;
|
||||
- applies `32-05-demo-mount.patch`, adds the submodule and go.work entry, runs `summer build`, and runs `check-phase32.sh --all` without `PHASE32_ALLOW_UNMOUNTED`.
|
||||
|
||||
**Nothing pushed:** `../sm-seo-plugin` main has an origin remote but nothing was pushed.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- **Key files:** all 32 exist.
|
||||
- **Commits present:**
|
||||
- ../sm-seo-plugin: cadf6ad, aa0c3bc, ab3b219, 6f69031;
|
||||
- this repository: 9247761, 20d02d7.
|
||||
- **../sm-seo-plugin:** `go vet ./...`, `go test -short ./...` and `go test -count=1 ./...` (Docker) are green; `npm run typecheck` and `scripts/check-dist.sh` are green.
|
||||
- **summercms.go:** `go vet ./...` and `go test -short ./...` are green (gate `--go`).
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-27*
|
||||
324
.planning/phases/32-seo-foundation/32-05-demo-mount.patch
Normal file
324
.planning/phases/32-seo-foundation/32-05-demo-mount.patch
Normal file
@@ -0,0 +1,324 @@
|
||||
32-05 demo mount of golem15.seo (sm-seo-plugin), proven in a scratch worktree
|
||||
of sm-demo-app at 8fcdbdd. Plan 32-06 applies it after the plugin and
|
||||
framework tags, from the sm-demo-app root:
|
||||
|
||||
git apply .../32-05-demo-mount.patch
|
||||
|
||||
and then, in the same release commit or separate commits as DEPLOY.md
|
||||
describes: add the plugin submodule at plugins/golem15/seo
|
||||
(.gitmodules, branch main), add ./plugins/golem15/seo to go.work, require
|
||||
the tagged git.golem15.com/golem15/sm-seo-plugin (and the tagged
|
||||
sm-journal-plugin with the 32-02 descriptors) in go.mod, run summer build
|
||||
(plugins.gen.go below is what it generates), and pass TestGoModRequiresTags.
|
||||
|
||||
The patch adds the plugin to summer.yaml after golem15.sitemap, the
|
||||
plugin config, the nginx /robots.txt location, the DEPLOY.md section, the
|
||||
plugin in TestBootAllPlugins, and the two tests TestSEOTabMounted and
|
||||
TestSEOToolsCatalog (summercms_mcp), which skip with "NOT MOUNTED
|
||||
golem15.seo" while summer.yaml does not list the plugin.
|
||||
|
||||
Scratch run (GOWORK with ../sm-journal-plugin and ../sm-seo-plugin):
|
||||
--- PASS: TestBootAllPlugins
|
||||
--- PASS: TestSEOTabMounted
|
||||
--- PASS: TestSEOToolsCatalog
|
||||
|
||||
diff --git a/DEPLOY.md b/DEPLOY.md
|
||||
index edc10eb..a964219 100644
|
||||
--- a/DEPLOY.md
|
||||
+++ b/DEPLOY.md
|
||||
@@ -407,6 +407,26 @@ and add `http://127.0.0.1:3020/mcp` to the client. With the default `app.url` (`
|
||||
the endpoint answers on the Go port, but the consent redirect goes to `/connect` on Go, which has no such
|
||||
page.
|
||||
|
||||
+### SEO (golem15.seo)
|
||||
+
|
||||
+The demo mounts sm-seo-plugin: an SEO tab on Journal posts, categories and tags, URL rules, redirects,
|
||||
+the 404 log, robots.txt with AI bot switches, history and the `seo_` MCP tools (the administrator needs
|
||||
+`golem15.seo.manage`). `config/golem15.seo.yaml` sets `site_url` to `https://demo.summercms.io`.
|
||||
+
|
||||
+- **robots.txt moves to Go.** nginx sends `= /robots.txt` to the Go port (`deploy/nginx/demo.summercms.io.conf`);
|
||||
+ the Nuxt robots module no longer answers it. Before the first release with the plugin, copy the
|
||||
+ `Disallow` lines the Nuxt config writes today (`goPaths` in `vue-demo-app/nuxt.config.ts`: `/_user`,
|
||||
+ `/_journal`, `/_menu`, `/_faq`, `/_paymentgateway`, `/_paymentgatewaysubscriptions`, `/_feedback`,
|
||||
+ `/storage`, `/_presentations`, `/_quizzes`, `/_demo`, `/api/realtime/token`, `/mcp`,
|
||||
+ `/.well-known/oauth-protected-resource`, `/.well-known/oauth-authorization-server`, `/oauth/mcp/`) into
|
||||
+ **SEO › robots.txt** under `User-agent: *`, and add `/_seo`. The `Sitemap:` line is added by the plugin.
|
||||
+ Outside production the plugin serves `Disallow: /` whatever is stored.
|
||||
+- **404 log.** Set `SUMMER_GOLEM15__SEO__NOTFOUND_TOKEN` in `.env` on rome (a random value, never printed
|
||||
+ or committed) and the same token in the Nuxt site's environment once the frontend layer reports 404s
|
||||
+ (Phase 33); without it the report endpoint stays off.
|
||||
+- **Verify** after the release: `curl -s https://demo.summercms.io/robots.txt` shows the copied lines and
|
||||
+ the `Sitemap:` line; `curl -sI https://demo.summercms.io/robots.txt` answers 200 `text/plain`.
|
||||
+
|
||||
## Build
|
||||
|
||||
```sh
|
||||
diff --git a/boot_test.go b/boot_test.go
|
||||
index ca053ea..7eba15b 100644
|
||||
--- a/boot_test.go
|
||||
+++ b/boot_test.go
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
// wantPlugins is every plugin of the demo, in summer.yaml order.
|
||||
var wantPlugins = []string{
|
||||
- "golem15.user", "golem15.translate", "golem15.journal", "golem15.sitemap", "golem15.menu",
|
||||
+ "golem15.user", "golem15.translate", "golem15.journal", "golem15.sitemap", "golem15.seo", "golem15.menu",
|
||||
"golem15.faq", "golem15.paymentgateway", "golem15.pgstripe", "golem15.paymentgatewaysubscriptions",
|
||||
"golem15.pgstripesubscriptions", "golem15.presentations", "golem15.quizzes", "golem15.golem",
|
||||
"golem15.feedback", "golem15.oauthserver", "golem15.sociallogin", "golem15.mfa", "golem15.demo",
|
||||
@@ -59,6 +59,7 @@ func TestBootAllPlugins(t *testing.T) {
|
||||
"/_user/api/v1", "/_journal/api/v1", "/_menu/api/v1", "/_faq/api/v1",
|
||||
"/_paymentgatewaysubscriptions/api/v1", "/webhook/stripe/subscriptions", "/sitemap.xml", "/smbackend", "/_demo/api/v1", "/_demo/api/v1/presentations",
|
||||
"/oauth/", "/_user/api/v1/oauth-complete", "/_user/api/v1/2fa/", "/_user/api/v1/devices",
|
||||
+ "/_seo/api/v1", "/robots.txt",
|
||||
} {
|
||||
if !routed(rt.Routes(), prefix) {
|
||||
t.Errorf("no route under %s", prefix)
|
||||
diff --git a/config/golem15.seo.yaml b/config/golem15.seo.yaml
|
||||
new file mode 100644
|
||||
index 0000000..dbea376
|
||||
--- /dev/null
|
||||
+++ b/config/golem15.seo.yaml
|
||||
@@ -0,0 +1,12 @@
|
||||
+# golem15.seo (sm-seo-plugin): SEO of the Journal posts, categories and tags,
|
||||
+# URL rules, redirects, the 404 log, robots.txt and the SEO MCP tools.
|
||||
+#
|
||||
+# site_url is the public origin the Nuxt site serves; canonical URLs,
|
||||
+# Open Graph URLs and robots.txt Sitemap lines are built from it, never from
|
||||
+# a request's Host. The 404 report token comes from the environment
|
||||
+# (SUMMER_GOLEM15__SEO__NOTFOUND_TOKEN, .env on rome; never committed);
|
||||
+# without it the report endpoint is off.
|
||||
+site_url: https://demo.summercms.io
|
||||
+notfound_token: ""
|
||||
+robots_sitemaps:
|
||||
+ - /sitemap.xml
|
||||
diff --git a/deploy/nginx/demo.summercms.io.conf b/deploy/nginx/demo.summercms.io.conf
|
||||
index 9b8aaa1..c179b49 100644
|
||||
--- a/deploy/nginx/demo.summercms.io.conf
|
||||
+++ b/deploy/nginx/demo.summercms.io.conf
|
||||
@@ -299,6 +299,17 @@ server {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
+ # robots.txt comes from golem15.seo: the rules and AI bot switches of
|
||||
+ # SEO › robots.txt in production, the lock (Disallow: /) elsewhere.
|
||||
+ location = /robots.txt {
|
||||
+ proxy_pass http://127.0.0.1:8098;
|
||||
+ proxy_http_version 1.1;
|
||||
+ proxy_set_header Host $host;
|
||||
+ proxy_set_header X-Real-IP $remote_addr;
|
||||
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
+ proxy_set_header X-Forwarded-Proto $scheme;
|
||||
+ }
|
||||
+
|
||||
# The sitemap plugin's document and its stylesheet.
|
||||
location = /sitemap.xml {
|
||||
proxy_pass http://127.0.0.1:8098;
|
||||
diff --git a/plugins.gen.go b/plugins.gen.go
|
||||
index b13599f..a4cd28f 100644
|
||||
--- a/plugins.gen.go
|
||||
+++ b/plugins.gen.go
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
_ "git.golem15.com/golem15/sm-pgstripe-plugin/subscriptions"
|
||||
_ "git.golem15.com/golem15/sm-presentations-plugin"
|
||||
_ "git.golem15.com/golem15/sm-quizzes-plugin"
|
||||
+ _ "git.golem15.com/golem15/sm-seo-plugin"
|
||||
_ "git.golem15.com/golem15/sm-sitemap-plugin"
|
||||
_ "git.golem15.com/golem15/sm-sociallogin-plugin"
|
||||
_ "git.golem15.com/golem15/sm-translate-plugin"
|
||||
@@ -29,6 +30,7 @@ var PluginIDs = []string{
|
||||
"golem15.translate",
|
||||
"golem15.journal",
|
||||
"golem15.sitemap",
|
||||
+ "golem15.seo",
|
||||
"golem15.menu",
|
||||
"golem15.faq",
|
||||
"golem15.paymentgateway",
|
||||
diff --git a/seo_mcp_test.go b/seo_mcp_test.go
|
||||
new file mode 100644
|
||||
index 0000000..5ac56cc
|
||||
--- /dev/null
|
||||
+++ b/seo_mcp_test.go
|
||||
@@ -0,0 +1,54 @@
|
||||
+//go:build summercms_mcp
|
||||
+
|
||||
+package main
|
||||
+
|
||||
+import (
|
||||
+ "net/http"
|
||||
+ "slices"
|
||||
+ "testing"
|
||||
+
|
||||
+ "git.golem15.com/golem15/summercms/modules/pact"
|
||||
+)
|
||||
+
|
||||
+// TestSEOToolsCatalog checks SC-4 through the demo's MCP endpoint: an
|
||||
+// administrator with golem15.seo.manage, linked to the MCP user with the
|
||||
+// backend scope, is listed seo_ plus every tool the registered SEO plugin
|
||||
+// declares (pier binds each to its route at boot); a read grant lists the
|
||||
+// GET tools only. The plugin is found through the activated plugins and
|
||||
+// pact.HasMCP, so the demo imports no SEO package.
|
||||
+func TestSEOToolsCatalog(t *testing.T) {
|
||||
+ skipUnlessSEOMounted(t)
|
||||
+ env := bootMCPDemo(t)
|
||||
+ var tools []pact.MCPTool
|
||||
+ for _, p := range env.demo.Plugins {
|
||||
+ if p.ID() != seoPluginID {
|
||||
+ continue
|
||||
+ }
|
||||
+ hm, ok := p.(pact.HasMCP)
|
||||
+ if !ok {
|
||||
+ t.Fatalf("%s declares no MCP tools", seoPluginID)
|
||||
+ }
|
||||
+ tools = hm.MCP().Tools
|
||||
+ }
|
||||
+ if len(tools) == 0 {
|
||||
+ t.Fatalf("%s is mounted but activated no tools", seoPluginID)
|
||||
+ }
|
||||
+ editor := env.frontendUser(t, "seo")
|
||||
+ env.link(t, editor.ID, env.editorAdmin(t, "seo", "golem15.seo.manage"))
|
||||
+ client := env.mcpClient(t, "demo-seo-agent")
|
||||
+
|
||||
+ names := toolNames(t, env.connect(t, env.mint(t, editor.ID, client, "read", "write", "backend")))
|
||||
+ for _, tool := range tools {
|
||||
+ if !hasTool(names, "seo_"+tool.Name) {
|
||||
+ t.Errorf("catalog %v lacks seo_%s", names, tool.Name)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ reads := toolNames(t, env.connect(t, env.mint(t, editor.ID, client, "read", "backend")))
|
||||
+ for _, tool := range tools {
|
||||
+ listed := slices.Contains(reads, "seo_"+tool.Name)
|
||||
+ if get := tool.Method == http.MethodGet; listed != get {
|
||||
+ t.Errorf("read grant: seo_%s listed %v, want %v (method %s)", tool.Name, listed, get, tool.Method)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/seo_mount_test.go b/seo_mount_test.go
|
||||
new file mode 100644
|
||||
index 0000000..9c08cc0
|
||||
--- /dev/null
|
||||
+++ b/seo_mount_test.go
|
||||
@@ -0,0 +1,109 @@
|
||||
+package main
|
||||
+
|
||||
+import (
|
||||
+ "encoding/json"
|
||||
+ "net/http"
|
||||
+ "net/http/httptest"
|
||||
+ "slices"
|
||||
+ "strconv"
|
||||
+ "testing"
|
||||
+ "time"
|
||||
+
|
||||
+ "git.golem15.com/golem15/sm-demo-app/internal/demotest"
|
||||
+ "git.golem15.com/golem15/summercms/modules/bouncer"
|
||||
+ "git.golem15.com/golem15/summercms/modules/cabana"
|
||||
+ "git.golem15.com/golem15/summercms/modules/surf"
|
||||
+)
|
||||
+
|
||||
+// seoPluginID is the SEO plugin. The demo mounts it once the plugin is
|
||||
+// tagged; until then these checks skip, and they import no SEO package.
|
||||
+const seoPluginID = "golem15.seo"
|
||||
+
|
||||
+// skipUnlessSEOMounted skips a test while summer.yaml does not list the
|
||||
+// SEO plugin; the phase gate reads the NOT MOUNTED line.
|
||||
+func skipUnlessSEOMounted(t *testing.T) {
|
||||
+ t.Helper()
|
||||
+ if !slices.Contains(PluginIDs, seoPluginID) {
|
||||
+ t.Skip("NOT MOUNTED " + seoPluginID)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+// tabOrder lists a form schema's tabs in the order the admin shows them
|
||||
+// (first appearance; fields without a tab are the form's outside area).
|
||||
+func tabOrder(fields []struct {
|
||||
+ Name string `json:"name"`
|
||||
+ Tab string `json:"tab"`
|
||||
+}) []string {
|
||||
+ var out []string
|
||||
+ for _, f := range fields {
|
||||
+ if f.Tab != "" && !slices.Contains(out, f.Tab) {
|
||||
+ out = append(out, f.Tab)
|
||||
+ }
|
||||
+ }
|
||||
+ return out
|
||||
+}
|
||||
+
|
||||
+// TestSEOTabMounted checks the SEO tab on the Journal forms (SC-2): posts,
|
||||
+// categories and tags get the SEO tab last, and the post form keeps its
|
||||
+// own tabs first (Edit, Manage, Categories, SEO).
|
||||
+func TestSEOTabMounted(t *testing.T) {
|
||||
+ skipUnlessSEOMounted(t)
|
||||
+ demo := bootDemo(t, nil, nil)
|
||||
+ h, err := surf.Assemble(demo.App, demo.Plugins)
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("surf.Assemble: %v", err)
|
||||
+ }
|
||||
+ prefix, err := cabana.AdminPrefix(demo.App)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ var adminID uint
|
||||
+ stamp := strconv.FormatInt(time.Now().UnixNano(), 36)
|
||||
+ if err := demo.DB.Raw(`INSERT INTO backend_users (login, email, password, first_name, last_name, is_activated, is_superuser, created_at, updated_at)
|
||||
+VALUES (?, ?, 'x', 'Seo', 'Check', TRUE, TRUE, NOW(), NOW()) RETURNING id`, "seo-"+stamp, "seo-"+stamp+"@example.test").Scan(&adminID).Error; err != nil || adminID == 0 {
|
||||
+ t.Fatalf("backend user: id=%d err=%v", adminID, err)
|
||||
+ }
|
||||
+ token, _, err := bouncer.MintAudience(demotest.AdminJWTSecret, strconv.FormatUint(uint64(adminID), 10), "http://localhost"+prefix+"/api/v1/auth/login", time.Hour, bouncer.AudienceBackend)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ schema := func(controller string) []string {
|
||||
+ t.Helper()
|
||||
+ req := httptest.NewRequest(http.MethodGet, prefix+"/api/v1/golem15/journal/"+controller+"/schema/form", nil)
|
||||
+ req.Header.Set("Authorization", "Bearer "+token)
|
||||
+ req.Header.Set("Accept-Language", "en")
|
||||
+ rec := httptest.NewRecorder()
|
||||
+ h.ServeHTTP(rec, req)
|
||||
+ if rec.Code != http.StatusOK {
|
||||
+ t.Fatalf("%s schema = %d %s", controller, rec.Code, rec.Body.String())
|
||||
+ }
|
||||
+ var out struct {
|
||||
+ Data struct {
|
||||
+ Fields []struct {
|
||||
+ Name string `json:"name"`
|
||||
+ Tab string `json:"tab"`
|
||||
+ } `json:"fields"`
|
||||
+ } `json:"data"`
|
||||
+ }
|
||||
+ if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ fields := out.Data.Fields
|
||||
+ if len(fields) == 0 || fields[len(fields)-1].Tab != "SEO" {
|
||||
+ t.Fatalf("%s: last field %+v, want the SEO tab last", controller, fields)
|
||||
+ }
|
||||
+ found := false
|
||||
+ for _, f := range fields {
|
||||
+ found = found || f.Name == "seo_title"
|
||||
+ }
|
||||
+ if !found {
|
||||
+ t.Fatalf("%s: no seo_title field", controller)
|
||||
+ }
|
||||
+ return tabOrder(fields)
|
||||
+ }
|
||||
+ if got, want := schema("posts"), []string{"Edit", "Manage", "Categories", "SEO"}; !slices.Equal(got, want) {
|
||||
+ t.Fatalf("post tabs = %v, want %v", got, want)
|
||||
+ }
|
||||
+ schema("categories")
|
||||
+ schema("tags")
|
||||
+}
|
||||
diff --git a/summer.yaml b/summer.yaml
|
||||
index 886edfb..13a4d49 100644
|
||||
--- a/summer.yaml
|
||||
+++ b/summer.yaml
|
||||
@@ -13,6 +13,8 @@ plugins:
|
||||
module: git.golem15.com/golem15/sm-journal-plugin
|
||||
- id: golem15.sitemap
|
||||
module: git.golem15.com/golem15/sm-sitemap-plugin
|
||||
+ - id: golem15.seo
|
||||
+ module: git.golem15.com/golem15/sm-seo-plugin
|
||||
- id: golem15.menu
|
||||
module: git.golem15.com/golem15/sm-menu-plugin
|
||||
- id: golem15.faq
|
||||
418
.planning/phases/32-seo-foundation/32-06-PLAN.md
Normal file
418
.planning/phases/32-seo-foundation/32-06-PLAN.md
Normal file
@@ -0,0 +1,418 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 06
|
||||
type: execute
|
||||
wave: 6
|
||||
depends_on: ["32-05"]
|
||||
files_modified:
|
||||
- scripts/check-phase32.sh
|
||||
- scripts/apisurface/main.go
|
||||
- modules/cabana/form_extensions_test.go
|
||||
- modules/cabana/record_events_test.go
|
||||
- modules/signpost/content_test.go
|
||||
- ../sm-seo-plugin/classes/resolver_test.go
|
||||
- ../sm-seo-plugin/classes/redirect_graph_test.go
|
||||
- ../sm-seo-plugin/classes/normalize_test.go
|
||||
- ../sm-seo-plugin/classes/robots_value_test.go
|
||||
- ../sm-seo-plugin/classes/robots_test.go
|
||||
- ../sm-seo-plugin/classes/templates_test.go
|
||||
- ../sm-seo-plugin/classes/csv_test.go
|
||||
- ../sm-seo-plugin/classes/owner_test.go
|
||||
- ../sm-seo-plugin/classes/issues_test.go
|
||||
- ../sm-seo-plugin/tests/elements/text.test.ts
|
||||
- ../sm-seo-plugin/tests/elements/robots.test.ts
|
||||
- ../sm-seo-plugin/tests/elements/serp.test.ts
|
||||
- ../sm-seo-plugin/tests/elements/robotstxt.test.ts
|
||||
- ../sm-seo-plugin/tests/elements/transfer.test.ts
|
||||
- ../sm-seo-plugin/go.mod
|
||||
- ../sm-seo-plugin/go.sum
|
||||
- ../sm-seo-plugin/README.md
|
||||
- ../sm-journal-plugin/content_descriptors_test.go
|
||||
- ../sm-journal-plugin/menu_item_types_test.go
|
||||
- ../sm-journal-plugin/go.mod
|
||||
- ../sm-journal-plugin/go.sum
|
||||
- ../sm-demo-app/summer.yaml
|
||||
- ../sm-demo-app/go.work
|
||||
- ../sm-demo-app/go.mod
|
||||
- ../sm-demo-app/go.sum
|
||||
- ../sm-demo-app/.gitmodules
|
||||
- ../sm-demo-app/plugins.gen.go
|
||||
- ../sm-demo-app/main.go
|
||||
- ../sm-demo-app/config/golem15.seo.yaml
|
||||
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
|
||||
- ../sm-demo-app/DEPLOY.md
|
||||
- ../sm-demo-app/plugins/golem15/seo
|
||||
- ../sm-demo-app/plugins/golem15/journal
|
||||
- .planning/phases/32-seo-foundation/32-VALIDATION.md
|
||||
- .planning/phases/32-seo-foundation/deferred-items.md
|
||||
- .planning/phases/32-seo-foundation/32-06-release-log.md
|
||||
autonomous: false
|
||||
requirements: [SC-5, SC-1, SC-2, SC-3, SC-4, Q-01, D-106, D-90, D-91, D-92, D-93, D-98, D-22, D-25, D-09]
|
||||
|
||||
estimate:
|
||||
tokens: 160000
|
||||
raw_tokens: 160000
|
||||
tasks: 5
|
||||
confidence: low
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "The framework change of Phase 32 is strictly additive (D-106): the exported API surface of pact, cabana, signpost and every other framework package changed since the latest release tag keeps every element of that tag unchanged (no removed declaration, field or method; no changed signature, field type, struct tag, constant value or underlying type) and adds no method to an interface that exists at that tag; a new capability method goes on a new, separate optional interface; existing plugins compile and behave the same without edits"
|
||||
- "Existing consumers build and pass their short tests against the new framework with no change on their side: sm-sitemap-plugin at HEAD, sm-journal-plugin at its commit before Phase 32, and sm-demo-app at its commit before Phase 32 with its pinned submodules; every other sibling plugin and application that requires the framework builds at its HEAD against it (D-106)"
|
||||
- "The new code has unit tests in this last plan: cabana placement and boot errors, record events, signpost descriptors, the SEO plugin's resolver, redirect graph, normalisation, robots grammar and tester, templates, CSV, owner resolution and issues, Journal descriptors and the element backstops (SC-5)"
|
||||
- "The framework release is the next v0.5.x patch tag, computed from git tag at release time and confirmed by Jakub at the checkpoint; no version number is fixed in advance (SC-5, Q-01, D-106)"
|
||||
- "sm-seo-plugin and sm-journal-plugin require that framework tag, are tagged and pushed only after Jakub's go-ahead, and sm-demo-app mounts golem15.seo and bumps Journal in separate commits that pass TestGoModRequiresTags, TestSEOTabMounted and TestSEOToolsCatalog (SC-2, SC-4, SC-5)"
|
||||
- "scripts/check-phase32.sh --all is green with the demo mounted, including the additive and compat stages, and its self-test proves that the additive stage refuses a removed declaration, a changed signature and a method added to an existing interface"
|
||||
- "A resumed release run never tags, pushes or posts twice: every release step is recorded in 32-06-release-log.md as it completes"
|
||||
- "The release tag gets a summercms.io changelog post the same day, written from changelog-post.py source output without planning IDs"
|
||||
- statement: "E1 counter line at 320px container width: status text and count wrap onto two lines without overlap (UI-SPEC long-text backstop)"
|
||||
verification: backstop
|
||||
- statement: "E2 at 360px: the two segmented groups stack and no segment label is clipped in either language (UI-SPEC long-text backstop)"
|
||||
verification: backstop
|
||||
- statement: "E1 status thresholds: with a mocked measureText, 29/30 characters and 580/581px give short/good/long for both measures (UI-SPEC populated backstop)"
|
||||
verification: backstop
|
||||
- statement: "E2 value grammar: every directive combination round-trips in fixed order, all-inherit emits an empty string, and the Go Decode refuses malformed strings (UI-SPEC populated backstop)"
|
||||
verification: backstop
|
||||
- statement: "E3 effective title: an empty SEO title applies the type template, then the general template, to defaultTitle; truncation cuts at a word boundary within 580px (UI-SPEC populated backstop)"
|
||||
verification: backstop
|
||||
- statement: "E4 lint: each lint rule fires on its sample line and none fires on a clean file (UI-SPEC populated backstop)"
|
||||
verification: backstop
|
||||
- statement: "E6 apply gating: a preview with one refused row disables Apply and shows refusedBlocks (UI-SPEC populated backstop)"
|
||||
verification: backstop
|
||||
- statement: "E3 keyphrase stem matching: grzyby/grzybów match, grzyb/grzbiet do not, diacritics and case ignored, URL hyphens equal spaces (UI-SPEC populated backstop, Q-4)"
|
||||
verification: backstop
|
||||
prohibitions:
|
||||
- statement: "No breaking change to existing framework API (D-106): no exported declaration of the latest tag is removed or changed, no method is added to an interface that exists at that tag, and no existing consumer needs an edit to build against the release"
|
||||
status: resolved
|
||||
verification: test
|
||||
- statement: "Nothing is pushed, tagged, deployed or posted to the changelog without Jakub's go-ahead at the checkpoint, and no version number is hard-coded before that checkpoint computes it"
|
||||
status: resolved
|
||||
verification: judgment
|
||||
- statement: "The changelog token is never printed, copied or minted"
|
||||
status: resolved
|
||||
verification: judgment
|
||||
artifacts:
|
||||
- path: "scripts/check-phase32.sh"
|
||||
provides: "additive and compat stages added to the phase gate"
|
||||
contains: "compat"
|
||||
- path: "scripts/apisurface/main.go"
|
||||
provides: "standard-library API surface printer the additive stage compares: signatures without parameter names, interface method sets, struct fields"
|
||||
contains: "imethod"
|
||||
- path: "modules/cabana/form_extensions_test.go"
|
||||
provides: "the D-91 unit matrix"
|
||||
contains: "func TestFormExtension"
|
||||
- path: "../sm-seo-plugin/classes/redirect_graph_test.go"
|
||||
provides: "TestRedirectGraph"
|
||||
contains: "func TestRedirectGraph("
|
||||
- path: "../sm-seo-plugin/tests/elements/serp.test.ts"
|
||||
provides: "E3 backstops"
|
||||
contains: "grzybów"
|
||||
- path: ".planning/phases/32-seo-foundation/32-VALIDATION.md"
|
||||
provides: "per-task verification map, nyquist_compliant true"
|
||||
contains: "nyquist_compliant: true"
|
||||
key_links:
|
||||
- from: "scripts/check-phase32.sh"
|
||||
to: "scripts/apisurface/main.go"
|
||||
via: "additive stage runs go run ./scripts/apisurface on the last tag's worktree and on HEAD per package and refuses removed or changed lines and new methods on interfaces that exist at the tag"
|
||||
pattern: "apisurface"
|
||||
- from: "scripts/check-phase32.sh"
|
||||
to: "../sm-journal-plugin"
|
||||
via: "compat stage builds a detached worktree of Journal's pre-phase commit against this framework checkout through a scratch go.work"
|
||||
pattern: "worktree add --detach"
|
||||
- from: "../sm-demo-app/go.mod"
|
||||
to: "../sm-seo-plugin"
|
||||
via: "require git.golem15.com/golem15/sm-seo-plugin at its release tag; submodule plugins/golem15/seo at the same commit (scripts/check-pins.sh)"
|
||||
pattern: "sm-seo-plugin v"
|
||||
---
|
||||
|
||||
<!-- planner-discipline-allow: seo -->
|
||||
|
||||
## Phase Goal
|
||||
|
||||
**As a** site editor on any SummerCMS application, **I want to** per-record and global SEO in the admin, with redirects and robots.txt, all manageable through MCP, **so that** every site ships correct, editable SEO without per-site work.
|
||||
|
||||
This plan proves the phase with unit tests, proves the framework change is additive, and releases it.
|
||||
|
||||
<objective>
|
||||
Write the phase's unit tests (project rule: unit tests are the last plan) per the 32-VALIDATION.md map, add the `additive` and `compat` stages to `scripts/check-phase32.sh` (D-106: the framework release is a patch and must be strictly additive), then, after Jakub's go-ahead, tag the framework with the next v0.5.x patch computed at release time (D-106) (Q-01: Phase 33 builds on this tag, not on a `replace`), release sm-seo-plugin and sm-journal-plugin on that tag, mount the plugin in sm-demo-app with the plan 32-05 patch, and post the changelog. The framework names no SEO concept and no consuming application (D-90); the seams D-91, D-92 and D-93 ship as published API (D-98 plan order).
|
||||
|
||||
Purpose: SC-5 (the framework release with the seams is tagged, and the new code has unit tests delivered in the phase's last plan), and the final evidence for SC-1 to SC-4.
|
||||
|
||||
Output: test files in three repositories, the gate stages, the updated VALIDATION.md, tags and pushes (after the go-ahead), demo commits, the changelog post.
|
||||
|
||||
**Decision coverage.** `32-DECISIONS-MAP.md` maps every decision of CONTEXT.md (D-01 to D-106, D-20a to D-20c, Q-01) to the plan and task that implements it, or to Phase 33; the boundary below is its Phase 33 column, and this plan's verification checks that the map lists every decision.
|
||||
|
||||
**Phase 33 boundary (Q-01).** These decisions are not implemented in Phase 32 and are explicitly deferred to Phase 33 ("SEO output, audit and content"); Phase 32 leaves room for them as noted:
|
||||
- D-30, D-31, D-32, D-34 (sitemap rewrite, image/News/IndexNow, HTML sitemap) and D-95 (the sitemap filter interface sm-seo-plugin will implement, with `Requires()` on Golem15.Sitemap); D-24's sitemap consistency (noindex, canonicalised and redirected pages leave the sitemaps; the "sitemap URL blocked" warning). Room: signpost content descriptors list records for sitemaps; the plugin's batch dry-run already flags noindex on published records' URLs. The reviewed todo `sitemap-xslt-browser-deprecation.md` stays with that rewrite.
|
||||
- D-33 (page registry; it registers its types through the same D-93 descriptors).
|
||||
- D-40, D-41, D-42 (pagination); D-43, D-44, D-45, D-46 (JSON-LD, schema type and custom JSON-LD fields, publisher settings, validation) and D-03's organisation/person data; room: the entry's `data` jsonb and the reserved SEO tab anchors `seo_robots` and `seo_og_image`.
|
||||
- D-50, D-51, D-52 (headings, including Journal's H1 conversion from D-96) and D-96's Journal schema types.
|
||||
- D-55, D-56, D-57 (hreflang in head and sitemaps); D-58's Journal translated-slug fix is delivered in Phase 32 (plan 32-02).
|
||||
- D-70, D-71, D-72 (SSR guarantees and sm-bm-app's noindex).
|
||||
- D-80, D-81, D-82, D-83 (internal linking), D-85, D-86 (media SEO, breadcrumbs and the primary-category field).
|
||||
- D-97 (the shared Nuxt SEO layer): it consumes the resolve answer of Phase 32, reads its route patterns from the CMS so strict URLs cannot drift from the frontend routes (RESEARCH Pitfall 15; Phase 32 only adds a drift check in the gate), enforces redirects, normalisation and strict URLs on frontend routes (D-20a, D-103), maps verification files at the site root, sends X-Robots-Tag on frontend pages, and marks signed-in routes noindex automatically (D-23's frontend half).
|
||||
- D-14's crawler half (Phase 32 ships the CMS-data issue report) and D-25's optional llms.txt.
|
||||
- Deferred ideas stay out of both phases: social card preview, per-redirect hit counters and validity dates, 307/308, e-commerce structured data.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.claude/msd-core/workflows/execute-plan.md
|
||||
@~/.claude/msd-core/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/32-seo-foundation/32-CONTEXT.md
|
||||
@.planning/phases/32-seo-foundation/32-VALIDATION.md
|
||||
@.planning/phases/32-seo-foundation/32-UI-SPEC.md
|
||||
@.planning/phases/32-seo-foundation/32-DECISIONS-MAP.md
|
||||
@.planning/phases/32-seo-foundation/32-01-SUMMARY.md
|
||||
@.planning/phases/32-seo-foundation/32-02-SUMMARY.md
|
||||
@.planning/phases/32-seo-foundation/32-05-SUMMARY.md
|
||||
@CLAUDE.md
|
||||
@../CLAUDE.md
|
||||
|
||||
<interfaces>
|
||||
Release facts: framework tags are vX.Y.Z on master (`git tag --sort=-v:refname`); other sessions may tag before this plan runs, so the version is computed at Task 4, never earlier (D-106: a patch tag, only the third number moves). sm-journal-plugin is on branch main; sm-seo-plugin on main with an empty origin until its first push. Demo rules: go_mod_test.go TestGoModRequiresTags (no replace, every golem15 requirement a canonical tag, every summer.yaml plugin required); scripts/check-pins.sh (submodule commits equal the required versions). Changelog: `../sm-summercmsio-app/scripts/changelog-post.py source vX.Y.Z` prints the tag message and commits since the previous tag; `publish vX.Y.Z notes.md --excerpt "..."` posts; the token is read from ~/.config/summercms/journal-token.
|
||||
Pre-phase commits: the framework base SHA and the Journal SHA before plan 32-02's first commit are recorded in 32-01-SUMMARY.md and 32-02-SUMMARY.md; the demo SHA before plan 32-05's test commit is in 32-05-SUMMARY.md.
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
## Execution units and resume points
|
||||
|
||||
Five tasks across three repositories plus a one-way release, so each task is a resumable unit and the plan runs in at least two executor contexts:
|
||||
- Every task ends with the commits listed below, staged by path (`git add <paths>`, with `-C <repo>` and `-c safe.directory='*'` for sibling repositories; never `-A` or `.`). No task leaves uncommitted files for the next one. Defect fixes go in their own `fix(32-06): ...` (framework) or `fix: ...` (plugins) commits before the group's commit.
|
||||
- Resume check before each task: `git -C <repo> log --format=%s | grep -Fx '<subject>'` for each subject of the task. All present: the task is done; re-run its `<verify>` and go on. Some present: continue at the first missing group. None: start the task.
|
||||
- An executor whose context is getting heavy stops after a task's last commit and returns its completed-task table (task, repository, subject, SHA); the continuation starts at the next task. The Task 4 checkpoint is always such a boundary: Tasks 1 to 3 run in one context and Task 5 in a fresh one.
|
||||
- Task 5 is resumed from `.planning/phases/32-seo-foundation/32-06-release-log.md`, never from memory (see its step 0).
|
||||
|
||||
| Task | Commit groups, in order (repository) | Resume point after the task |
|
||||
|------|--------------------------------------|-----------------------------|
|
||||
| 1 | `test(32-06): additive and compat stages in check-phase32` (this repository) | `--self-test`, `--additive` and `--compat` green |
|
||||
| 2 | `test(32-06): framework unit matrices for form extensions, record events and descriptors` (this repository) | framework seams fully unit-tested |
|
||||
| 3 | A `test: unit tests for the SEO classes` (../sm-seo-plugin); B `test: element backstops` (../sm-seo-plugin); C `test: content descriptors, journal-tag type and translated slugs` (../sm-journal-plugin); D `docs(32-06): complete the validation map` (this repository) | all unit tests in; VALIDATION.md complete |
|
||||
| 4 | none (checkpoint); the continuation prompt carries the answer and the confirmed versions | release, release-no-apps or hold |
|
||||
| 5 | one line per step in 32-06-release-log.md, then the demo commits named in step 4 | release done or hold recorded; write 32-06-SUMMARY.md |
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="tracer">
|
||||
<name>Task 1: End-to-end compatibility proof: the additive and compat gate stages build existing consumers unchanged against the new framework — one path through every repository</name>
|
||||
<files>scripts/check-phase32.sh, scripts/apisurface/main.go</files>
|
||||
<read_first>
|
||||
- scripts/check-phase32.sh (plan 32-05)
|
||||
- scripts/check-phase19.7.sh (its additive check and self-test layout, and the scratch go.work technique for consumers; its line-based check misses methods added to existing interfaces and parameters added to multi-line signatures, which is why this plan compares API surfaces)
|
||||
- ../sm-journal-plugin/go.work and ../sm-demo-app/go.work (replace lines to mirror in scratch go.work files)
|
||||
- .planning/phases/32-seo-foundation/32-01-SUMMARY.md, 32-02-SUMMARY.md, 32-05-SUMMARY.md (pre-phase SHAs)
|
||||
</read_first>
|
||||
<action>
|
||||
Per D-106 (patch release, strictly additive), D-91, D-92, D-93:
|
||||
1. `scripts/apisurface/main.go` (package main, standard library only: go/build, go/parser, go/ast, go/printer, go/token, sort, strings): `go run ./scripts/apisurface <package dir>` prints the exported API of the package in that directory, one element per line, sorted, each line collapsed to single spaces; it exits 2 with a message when the directory has no Go files. Files are the non-test files go/build's default context selects for the directory. Before printing, it clears the parameter and result names of every func type (functions, methods, interface methods, func-typed fields and parameters), so renamed parameters, realigned fields and edited comments print identically. Line kinds: `func F[<type params>](<param types>) <results>`; `method (<receiver type>) M(<param types>) <results>` for exported methods of exported types; `type T struct` plus `field T.Name <type> <tag>` per exported field and `embed T.<type>` per embedded field; `type T interface` plus `imethod T.M(<param types>) <results>` per method (unexported methods too: they decide who can implement it) and `iembed T.<type>` per embedded interface or type-set term; `type T <underlying>` for other defined types and `type T = <type>` for aliases (type parameters printed); `const X <type> = <value> @<index in its group>` with an omitted type and value carried from the previous spec of the group, as Go does; `var X <type>` (the declared type only, `var X` when it has none).
|
||||
2. Stage `additive` (D-106): `LAST_TAG=$(git tag --sort=-v:refname | head -1)`; `git worktree add --detach "$T/base" "$LAST_TAG"`. Packages: `modules/pact`, `modules/cabana`, `modules/signpost`, plus every other directory under `modules/` that holds a non-test `.go` file changed since `LAST_TAG` (`git diff --name-only "$LAST_TAG" -- modules`, which includes uncommitted changes) and exists at the tag. For each package run the tool on `$T/base/<dir>` and on `<dir>` into `$T/api/<name>.base` and `$T/api/<name>.head` (`LC_ALL=C sort`), then refuse with:
|
||||
(a) `additive: removed or changed in <pkg>: <line>` for every base line missing from head (`LC_ALL=C comm -23`): removed declarations, fields and methods, and every changed signature, field type, struct tag, constant value and underlying type, including a signature written over several lines that gains a parameter;
|
||||
(b) `additive: method added to existing interface in <pkg>: <line>` for every head `imethod T.` or `iembed T.` line that is not in base while base has `type T interface`: a method added to an existing exported interface breaks every type that implements it, so a new capability method (pact `Has*` interfaces included, such as `HasAdminActionExtensions`) must go on a new, separate optional interface, which this rule allows with any methods.
|
||||
Allowed, and printed as `additive: ok <pkg> (+<n> lines)`: new declarations, new interfaces, new methods on concrete types and new fields on existing structs (Go 1 compatibility with keyed literals; the compat stage proves the consumers still build). Remove the worktree on exit (trap).
|
||||
3. Stage `compat`: (a) `../sm-sitemap-plugin` must have no change since the phase base (`git status --porcelain` empty and HEAD equal to the SHA recorded at stage start of the phase, or simply no commit since the base date), then `go -C ../sm-sitemap-plugin build ./... && go -C ../sm-sitemap-plugin test -short ./...`; (b) `git -C ../sm-journal-plugin worktree add --detach "$T/journal" <pre-phase Journal SHA>` and a scratch go.work with absolute paths (use the worktree; replace summercms with this checkout, sm-translate-plugin and sm-user-plugin as in Journal's go.work), then `GOWORK=... go -C "$T/journal" build ./... && go test -short ./...`; (c) `git -C ../sm-demo-app worktree add --detach "$T/demo" <pre-phase demo SHA>`, then for each gitlink under plugins/golem15 in that commit (`git -C "$T/demo" ls-tree HEAD plugins/golem15/`) `git -C ../sm-demo-app/<path> worktree add --detach "$T/sub/<name>" <pinned SHA>`, a scratch go.work using `$T/demo` and every `$T/sub/<name>` with the demo's replace lines remapped and summercms replaced by this checkout; `go build ./...`, `go build -tags summercms_mcp ./...`, `go test -short ./...` in `$T/demo`. Then (d): every other sibling directory of this checkout whose `go.mod` requires `git.golem15.com/golem15/summercms` (the other `sm-*-plugin` and `sm-*-app` repositories and Go application workspaces), except this checkout, the three above and `../sm-seo-plugin`: a detached worktree of its HEAD, detached worktrees of its gitlinked submodules at their pinned commits as in (c), a scratch go.work mirroring its own go.work (or `use .` when it has none) with absolute paths and summercms replaced by this checkout, then `go build ./...`, printing `compat: ok <repo> (build)`. When that build fails, build the same worktree against the last tag's worktree (created as in `additive` when compat runs alone): failing there too prints `compat: skipped <repo> (fails at <LAST_TAG> too)`, otherwise refuse `compat: <repo> builds at <LAST_TAG> but not at HEAD`. Every worktree is removed on exit (trap). Print `compat: ok <repo>` per consumer of (a) to (c).
|
||||
4. Add both stages to `--all`, and extend `--self-test` with planted package pairs in a temporary directory (a `base/` and a `head/` Go package, run through the tool and the stage's comparison), each printing `PASS self-test additive <case>` or `refuse: self-test additive <case>`:
|
||||
- refused: `removed-func` (an exported func deleted); `changed-param` (`F(int)` becomes `F(int64)`); `multiline-param-added` (a signature written over several lines gains a parameter); `interface-method-added` (`type HasThing interface { Thing() string }` gains `Other() error`, modelled on a pact capability interface); `field-type-changed`; `const-value-changed`;
|
||||
- accepted: `func-added`; `struct-field-added` (the other fields realigned by gofmt); `optional-interface-added` (a new `HasOther` interface with methods); `method-added-to-struct`; `param-renamed`; `comment-edited`.
|
||||
5. Run both stages now. If `additive` refuses a line that another session changed (not Phase 32), stop and report it to Jakub with the line and the commit that changed it (`git log -S`), because a patch tag cannot carry it (D-106). If it refuses a Phase 32 line, make the seam additive in its own `fix(32-06): ...` commit (for example, move a new interface method onto a new optional interface and update its callers) before continuing.
|
||||
6. Commit (resume unit, see Execution units) staging only `scripts/check-phase32.sh` and `scripts/apisurface/main.go`: `test(32-06): additive and compat stages in check-phase32`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>bash scripts/check-phase32.sh --self-test && bash scripts/check-phase32.sh --additive --compat</automated>
|
||||
<fails_when>non-zero exit, an "additive: removed or changed" or "additive: method added to existing interface" line, a "refuse:" line, a missing "compat: ok" line for sm-sitemap-plugin, sm-journal-plugin or sm-demo-app, or "FAIL" in the output</fails_when>
|
||||
<automated>go vet ./scripts/apisurface && go run ./scripts/apisurface modules/pact | grep -c '^type HasAdminActionExtensions interface$'</automated>
|
||||
<fails_when>non-zero exit, or a count of 0 (the surface does not list pact's capability interfaces)</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `bash scripts/check-phase32.sh --additive --compat 2>&1 | grep -c "compat: ok"` is at least 3, with one line each for sm-sitemap-plugin, sm-journal-plugin and sm-demo-app, and every other sibling repository that requires the framework has a `compat: ok <repo> (build)` or `compat: skipped` line
|
||||
- `git -c safe.directory='*' -C ../sm-journal-plugin worktree list | wc -l` and the same for sm-demo-app print 1 after the run (no leftover worktrees)
|
||||
- `bash scripts/check-phase32.sh --self-test 2>&1 | grep -c "PASS self-test additive"` prints 12, including the `interface-method-added`, `changed-param` and `multiline-param-added` refusals
|
||||
- `go run ./scripts/apisurface modules/pact | grep -c "^imethod HasAdminActionExtensions\."` is at least 1 (interface method sets are part of the surface)
|
||||
- `go list -deps ./scripts/apisurface | grep '\.' | grep -v '/scripts/apisurface$'` prints nothing (standard library only)
|
||||
</acceptance_criteria>
|
||||
<done>The gate proves end to end that the framework change is additive (D-106): no removed or changed API element and no method added to an existing interface; existing consumers build and test unchanged against it.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 2: Framework unit tests: form-extension matrix, record-event diff, content descriptors</name>
|
||||
<files>modules/cabana/form_extensions_test.go, modules/cabana/record_events_test.go, modules/signpost/content_test.go</files>
|
||||
<read_first>
|
||||
- .planning/phases/32-seo-foundation/32-VALIDATION.md (test map SC-1 to SC-3)
|
||||
- modules/cabana/form_extensions.go, form_extensions_smoke_test.go, form_extensions_postgres_test.go (plan 32-01)
|
||||
- modules/cabana/record_events.go, record_events_postgres_test.go (plan 32-02)
|
||||
- modules/signpost/content.go, content_test.go (plan 32-02)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- Placement table (pure, no DB): A,B + C after A; C before first; C no anchor; two tabs + new tab between; tab-less + new tab; three plugins on one anchor in Requires order; anchor on another extension's field inside and outside Requires; hide one field; hide every field of a tab; span left after left starts a new row index; an interleaved owner list canonicalised only when extended
|
||||
- Boot error table: every error of the plan 32-01 behaviour list with the exact message fragments (plugin, controller, anchor)
|
||||
- Record-event diff (pure): snapshot diff of scalar columns, nil to value on create, translated per-locale changes, unchanged columns omitted
|
||||
- Descriptors: MatchPattern edge cases (trailing slash, encoded segments, extra and missing segments, empty segment), MatchPath ordering, duplicate Model/Controller boot errors, types without Content unchanged
|
||||
</behavior>
|
||||
<action>
|
||||
Write the exhaustive unit matrices named in 32-VALIDATION.md (`TestFormExtension*`, `TestFormExtensionBootErrors`, `TestRecordEventDiff`, `TestContent*`) as table tests per the behaviour list (SC-1, D-91, D-92, D-93). Pure tests run under `-short`; Docker-backed cases stay in the existing `_postgres_test.go` files. Fix any defect the tests expose in the same task with its own `fix(32-06): ...` commit. Commit (resume unit, see Execution units) staging only the three test files: `test(32-06): framework unit matrices for form extensions, record events and descriptors`.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go test -short ./modules/cabana ./modules/signpost -run 'TestFormExtension|TestRecordEventDiff|TestContent' -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -40</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or TestFormExtensionBootErrors, TestRecordEventDiff or a TestContent test missing from the "--- PASS" lines</fails_when>
|
||||
<automated>go vet ./... && go test -count=1 ./modules/cabana ./modules/signpost ./modules/pact</automated>
|
||||
<fails_when>non-zero exit, or a "FAIL" line in the output</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `go test -short ./modules/cabana -run TestFormExtensionBootErrors -v | grep -c -- "--- PASS"` is at least 15
|
||||
- `go test -short ./modules/cabana -run TestFormExtensionPlacement -v | grep -c -- "--- PASS"` is at least 11
|
||||
- `go vet ./... && go test -short ./...` exits 0 in the framework
|
||||
</acceptance_criteria>
|
||||
<done>The framework seams carry exhaustive unit coverage for placement, boot errors, event diffs and descriptors.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 3: Plugin unit tests (sm-seo-plugin classes, element backstops, Journal) and the completed VALIDATION.md</name>
|
||||
<files>../sm-seo-plugin/classes/resolver_test.go, ../sm-seo-plugin/classes/redirect_graph_test.go, ../sm-seo-plugin/classes/normalize_test.go, ../sm-seo-plugin/classes/robots_value_test.go, ../sm-seo-plugin/classes/robots_test.go, ../sm-seo-plugin/classes/templates_test.go, ../sm-seo-plugin/classes/csv_test.go, ../sm-seo-plugin/classes/owner_test.go, ../sm-seo-plugin/classes/issues_test.go, ../sm-seo-plugin/tests/elements/text.test.ts, ../sm-seo-plugin/tests/elements/robots.test.ts, ../sm-seo-plugin/tests/elements/serp.test.ts, ../sm-seo-plugin/tests/elements/robotstxt.test.ts, ../sm-seo-plugin/tests/elements/transfer.test.ts, ../sm-journal-plugin/content_descriptors_test.go, ../sm-journal-plugin/menu_item_types_test.go, .planning/phases/32-seo-foundation/32-VALIDATION.md</files>
|
||||
<read_first>
|
||||
- .planning/phases/32-seo-foundation/32-VALIDATION.md and 32-UI-SPEC.md (UI Considerations backstop rows, C4, C5, C6, C10, C13)
|
||||
- ../sm-seo-plugin/classes/*.go and assets/src/elements/*.ts
|
||||
- ../sm-journal-plugin/tests/ (vitest setup precedent) and ../sm-seo-plugin/vite.config.ts
|
||||
- Google's robots.txt documentation examples cited in 32-RESEARCH.md (longest match, allow wins ties, $ anchor, * wildcard)
|
||||
</read_first>
|
||||
<behavior>
|
||||
- TestResolverPrecedence (full matrix): every value chain of plan 32-03 P-14 with each layer present and absent, sources asserted; staging lock; draft not found
|
||||
- TestRedirectGraph: flatten A→B,B→C ⇒ A→C; back and forth A→B→A→C ⇒ A→C and B→C; loop refusal for exact, pattern probe and regex probe; chain notice; 10-hop runtime stop
|
||||
- TestNormalizeMatrix, TestRobotsValueRoundTrip (every directive combination; malformed refused), TestRobotsMatcherGoogleExamples, TestTemplates (unknown placeholder refused), TestCSV (BOM, delimiters, quoting, formula prefix), TestOwnerResolution (record, rule, force_rule, locale prefix), TestIssues (each issue kind)
|
||||
- Element backstops: text.test.ts (thresholds 29/30 chars and 580/581 px with mocked measureText for both measures; 320px wrap without overlap), robots.test.ts (grammar round-trip; all-inherit empty; 360px stacking with en and pl labels unclipped), serp.test.ts (effective title through type template then general template; word-boundary truncation within 580px; stem matching grzyby/grzybów yes, grzyb/grzbiet no, diacritics and case ignored, hyphens equal spaces), robotstxt.test.ts (each lint rule on its sample line; clean file has none), transfer.test.ts (one refused row disables Apply and shows refusedBlocks; zero changes shows nothing)
|
||||
- Journal: descriptor matrix for post, category, tag (Describe per locale, Match exact/non-exact, Records paging), journal-tag type with tag_pages on and off, translated slug lookup
|
||||
</behavior>
|
||||
<action>
|
||||
Write the unit tests per the behaviour list (SC-2, SC-3, SC-4, D-09, D-22, D-25 and the UI-SPEC backstops); pure Go tests run under `-short`. Element tests run with `npm --prefix ../sm-seo-plugin run test` (vitest + happy-dom, `tests/**/*.test.ts`). Fix defects in their own commits. Then update `32-VALIDATION.md`: the per-task verification map (every task of plans 32-01 to 32-06 with its automated command and status), Wave 0 items checked, `nyquist_compliant: true`, `wave_0_complete: true`, `status: validated` only if the full gate is green.
|
||||
Commits (resume units, see Execution units), staged by path, in this order: A in ../sm-seo-plugin `test: unit tests for the SEO classes` (the nine `classes/*_test.go` files of this task); B in ../sm-seo-plugin `test: element backstops` (the five `tests/elements/*.test.ts` files); C in ../sm-journal-plugin `test: content descriptors, journal-tag type and translated slugs` (content_descriptors_test.go, menu_item_types_test.go); D in this repository, as a planning-docs commit, `docs(32-06): complete the validation map` (32-VALIDATION.md only).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>go -C ../sm-seo-plugin test -short ./classes -count=1 -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -40</automated>
|
||||
<fails_when>a "FAIL" line, "no tests to run", or TestResolverPrecedence, TestRedirectGraph, TestNormalizeMatrix, TestRobotsValueRoundTrip, TestRobotsMatcherGoogleExamples, TestTemplates, TestCSV, TestOwnerResolution or TestIssues missing from the "--- PASS" lines</fails_when>
|
||||
<automated>npm --prefix ../sm-seo-plugin run test 2>&1 | tail -15</automated>
|
||||
<fails_when>non-zero exit, a failed, skipped or todo test, or a missing passing line for any of text, robots, serp, robotstxt, transfer test files</fails_when>
|
||||
<automated>go -C ../sm-journal-plugin test -count=1 ./... -run 'TestContentDescriptors|TestJournalTagType|TestTranslatedSlug|TestAPIRecordEvents' -v 2>&1 | grep -E '^(--- |FAIL|ok)' | tail -20</automated>
|
||||
<fails_when>non-zero exit, a "FAIL" line, or any of the four names missing from the "--- PASS" lines</fails_when>
|
||||
<automated>grep -c "nyquist_compliant: true" .planning/phases/32-seo-foundation/32-VALIDATION.md</automated>
|
||||
<fails_when>the count is 0</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `grep -n "grzybów" ../sm-seo-plugin/tests/elements/serp.test.ts` prints at least one line
|
||||
- `grep -c "it(\|test(" ../sm-seo-plugin/tests/elements/*.test.ts` totals at least 20
|
||||
- `go -C ../sm-seo-plugin vet ./... && go -C ../sm-seo-plugin test -count=1 ./...` exits 0 with Docker
|
||||
- 32-VALIDATION.md lists every plan task with an automated command
|
||||
</acceptance_criteria>
|
||||
<done>The plugin, its elements and Journal's new code are unit-tested per the validation map, and VALIDATION.md is complete.</done>
|
||||
</task>
|
||||
|
||||
<task type="checkpoint:decision" gate="blocking">
|
||||
<name>Task 4: Release go-ahead: confirm the framework patch version, the plugin versions and the push list</name>
|
||||
<reversibility rating="one-way">A pushed tag is pinned by plugin go.mod files and application submodules; Phase 33 builds on it, and the seams become published API.</reversibility>
|
||||
<decision>Release Phase 32 now with the computed versions, and which remote operations are approved?</decision>
|
||||
<context>Before asking, the executor runs and reports: `git fetch --tags origin` in the framework, sm-journal-plugin and sm-seo-plugin; `git tag --sort=-v:refname | head -3` in the framework; the next patch = the newest framework tag with its patch number plus one (D-106: v0.5.x today; a later 0.5.x if another session tagged meanwhile; only the third number moves); Journal's next patch from its newest tag; sm-seo-plugin's first version following the sibling plugins' first-release convention; `bash scripts/check-phase32.sh --all` with `PHASE32_ALLOW_UNMOUNTED=1` (green except the mount, which Task 5 completes); clean trees in the three repositories apart from other sessions' known uncommitted demo entries (listed). The push list it presents: framework master and the tag; sm-journal-plugin main and its tag; sm-seo-plugin main (first push) and its tag; then local demo commits (apply the 32-05 patch, add the seo submodule, bump Journal, require the framework tag), pushed only if named; the summercms.io changelog post for the framework tag; optional Journal bumps in sm-grzybyfunkcjonalne-app (with `golem15.journal.tag_pages: false`, its layer has no tag pages) and sm-summercmsio-app. Nothing is deployed in any option.</context>
|
||||
<options>
|
||||
<option id="release">
|
||||
<name>Release with the computed versions (Jakub names or corrects each number in the reply)</name>
|
||||
<pros>Phase 33 can build on a tagged framework (Q-01); the demo mounts the plugin; SC-5 closes</pros>
|
||||
<cons>One-way: tags and the seams' API are published</cons>
|
||||
</option>
|
||||
<option id="release-no-apps">
|
||||
<name>Release framework and plugins; keep every application change local (no app pushes, no optional app bumps)</name>
|
||||
<pros>No application repository leaves this machine</pros>
|
||||
<cons>The demo stays unpushed until a later go-ahead</cons>
|
||||
</option>
|
||||
<option id="hold">
|
||||
<name>Hold: no tag, no push</name>
|
||||
<pros>Lets Jakub review the seams' API first</pros>
|
||||
<cons>SC-5 stays open; the demo cannot mount the plugin (TestGoModRequiresTags); recorded in deferred-items.md</cons>
|
||||
</option>
|
||||
</options>
|
||||
<resume-signal>Answer release, release-no-apps or hold, with the confirmed version numbers</resume-signal>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 5: Tag, push and pin per the go-ahead; mount the plugin in the demo; full gate; changelog post</name>
|
||||
<precondition>Task 4 answered release or release-no-apps with confirmed version numbers; on hold, only write deferred-items.md and stop</precondition>
|
||||
<files>../sm-seo-plugin/go.mod, ../sm-seo-plugin/go.sum, ../sm-seo-plugin/README.md, ../sm-journal-plugin/go.mod, ../sm-journal-plugin/go.sum, ../sm-demo-app/summer.yaml, ../sm-demo-app/go.work, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum, ../sm-demo-app/.gitmodules, ../sm-demo-app/plugins.gen.go, ../sm-demo-app/main.go, ../sm-demo-app/config/golem15.seo.yaml, ../sm-demo-app/deploy/nginx/demo.summercms.io.conf, ../sm-demo-app/DEPLOY.md, ../sm-demo-app/plugins/golem15/seo, ../sm-demo-app/plugins/golem15/journal, .planning/phases/32-seo-foundation/deferred-items.md, .planning/phases/32-seo-foundation/32-06-release-log.md</files>
|
||||
<read_first>
|
||||
- The Task 4 answer
|
||||
- ../CLAUDE.md and CLAUDE.md (commits, concurrency, release and changelog rules)
|
||||
- ../sm-summercmsio-app/DEPLOY.md ("Posting to the changelog")
|
||||
- .planning/phases/32-seo-foundation/32-05-demo-mount.patch
|
||||
- .planning/phases/19.7-generic-mcp-module/19.7-04-PLAN.md (release task: pre-checks, annotated tags, pin commits)
|
||||
</read_first>
|
||||
<action>
|
||||
In this order, with the exact versions from Task 4 (SC-5, Q-01, D-106):
|
||||
0. Release log (the resume record of this one-way task): before step 1 create `.planning/phases/32-seo-foundation/32-06-release-log.md` with the Task 4 answer and the confirmed versions; after each step below append `step <n> done: <what> <tag, SHA or URL>`. A resumed run reads the log, confirms each step marked done (`git ls-remote --tags origin <tag>` prints the tag; the demo commit subject exists; the changelog URL answers) and skips it: a tag is never created twice, a push is never forced, the changelog is never posted twice. The log is committed with 32-06-SUMMARY.md as a planning-docs commit.
|
||||
1. Framework: if `admin/` changed since the last tag, `npm --prefix admin run build`, commit `modules/boardwalk/dist`, `scripts/check-admin-dist.sh` green; annotated tag `git tag -a <framework version>` with a message summarising the three seams in user-facing words; `git push origin master` and the tag.
|
||||
2. sm-journal-plugin: require the framework tag in go.mod (`GOWORK=off go get git.golem15.com/golem15/summercms@<tag>` with GOPRIVATE set as the demo's check-pins.sh does), `GOWORK=off go build ./... && GOWORK=off go test -short ./...`, commit `chore: require SummerCMS <tag>`, annotated tag, push main and the tag.
|
||||
3. sm-seo-plugin: the same require, README dependency line, commit, annotated tag, `git push -u origin main` and the tag.
|
||||
4. sm-demo-app (only paths from this plan; never other sessions' uncommitted entries): first commit `chore: require SummerCMS <tag>` (go.mod, go.sum); then the Journal bump: move `plugins/golem15/journal` to the Journal tag only when its current HEAD is an ancestor of that tag (else stop and ask: the submodule carries foreign work), require the Journal tag, commit `chore: bump journal to <version>` (go.mod, go.sum, the submodule pointer); then the mount: `git apply` the 32-05 patch, `git submodule add -b main git@git.golem15.com:golem15/sm-seo-plugin.git plugins/golem15/seo` checked out at its tag, `use ./plugins/golem15/seo` in go.work, require the sm-seo-plugin tag, `go run ../summercms.go/cmd/summer build` to regenerate plugins.gen.go and main.go, then `go build ./... && go build -tags summercms_mcp ./... && go test -short ./... && go test -short -tags summercms_mcp -run 'TestSEOToolsCatalog|TestGoModRequiresTags|TestSEOTabMounted' .` and `scripts/check-pins.sh`; commit `feat: mount golem15.seo <version>`. Push the demo only if the answer named it. Optional app bumps only if named, one commit per app.
|
||||
5. `bash scripts/check-phase32.sh --all` (mounted, Docker) must be green; record the output summary.
|
||||
6. Changelog (same day, from `../sm-summercmsio-app`): `scripts/changelog-post.py source <tag>`, write user-facing notes with `## Highlights`, `## Added`, `## Changed`, `## Fixed` (no planning IDs, no quick-task codes, no H1) to a scratch file, `scripts/changelog-post.py publish <tag> <notes> --excerpt "..."`. Never print or copy the token; if the token file is missing or refused, stop and ask Jakub.
|
||||
7. Anything not done (hold, refused push, unnamed apps) goes to `.planning/phases/32-seo-foundation/deferred-items.md` with the exact next command; STATE.md updates go through `msd_run query state.*` handlers only, and a short g15office comment on the Phase 32 task records the release (`.planning/G15OFFICE.md`).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>git describe --tags --exact-match HEAD 2>/dev/null || git tag --points-at HEAD</automated>
|
||||
<fails_when>empty output (no framework tag on the release commit) when Task 4 answered release or release-no-apps</fails_when>
|
||||
<automated>bash scripts/check-phase32.sh --all</automated>
|
||||
<fails_when>non-zero exit, a "FAIL", "refuse:", "NOT MOUNTED", "additive: removed or changed" or "additive: method added to existing interface" line in the output</fails_when>
|
||||
<automated>go -C ../sm-demo-app test -short -tags summercms_mcp -run 'TestGoModRequiresTags|TestSEOTabMounted|TestSEOToolsCatalog' -count=1 -v . 2>&1 | grep -E '^(--- |FAIL|ok)'</automated>
|
||||
<fails_when>a "FAIL" or "SKIP" line, or any of the three names missing from the "--- PASS" lines</fails_when>
|
||||
</verify>
|
||||
<acceptance_criteria>
|
||||
- `git ls-remote --tags origin <framework tag>` prints one line, and the tag keeps the major and middle numbers of the previous newest tag with the last number one higher (a patch release)
|
||||
- `grep -n "git.golem15.com/golem15/summercms <framework tag>" ../sm-seo-plugin/go.mod ../sm-journal-plugin/go.mod` prints a line in each
|
||||
- `grep -n "golem15.seo" ../sm-demo-app/summer.yaml` prints one line and `bash ../sm-demo-app/scripts/check-pins.sh` prints `check-pins: ok`
|
||||
- The changelog post URL for the tag is recorded in 32-06-SUMMARY.md
|
||||
- Every demo commit of this task lists only this plan's paths (`git show --stat`)
|
||||
- `32-06-release-log.md` has one `step <n> done` line per performed step and no step twice
|
||||
</acceptance_criteria>
|
||||
<done>The framework patch release carrying the three seams is tagged and announced, both plugins are released on it, the demo mounts the SEO plugin, and the full phase gate is green.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<threat_model>
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description |
|
||||
|----------|-------------|
|
||||
| local repositories → git.golem15.com | tags and branches published to consumers |
|
||||
| release script → summercms.io changelog | authenticated post with a scoped token |
|
||||
|
||||
## STRIDE Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|
||||
|-----------|----------|-----------|----------|-------------|-----------------|
|
||||
| T-32-30 | Tampering | published framework API (patch tag) | high | mitigate | additive stage compares the API surface (scripts/apisurface) of pact, cabana, signpost and every changed framework package with the last tag and refuses removed or changed elements and methods added to existing interfaces, with a self-test that plants each case; compat stage tests three consumers and builds every other sibling that requires the framework (D-106) |
|
||||
| T-32-31 | Repudiation | pushes and tags without consent | high | mitigate | Task 4 blocking decision checkpoint; Task 5 performs exactly the named operations and records each in the SUMMARY |
|
||||
| T-32-32 | Information disclosure | changelog token | high | mitigate | changelog-post.py reads ~/.config/summercms/journal-token itself; the executor never prints, copies or mints it and asks Jakub on a missing or refused token |
|
||||
| T-32-33 | Tampering | demo submodules carrying foreign work | medium | mitigate | the Journal submodule moves only when its HEAD is an ancestor of the release tag; other sessions' uncommitted entries are never staged |
|
||||
| T-32-34 | Tampering | a resumed release task repeating one-way steps | medium | mitigate | 32-06-release-log.md records each step as it completes; a resumed run confirms and skips logged steps, never re-tags, force-pushes or re-posts |
|
||||
| T-32-SC | Tampering | npm/pip/cargo installs | high | mitigate | No new package; tests use the toolchain approved at plan 32-03 Task 4; scripts/apisurface uses the standard library only |
|
||||
</threat_model>
|
||||
|
||||
<verification>
|
||||
- `bash scripts/check-phase32.sh --all` green with Docker and the demo mounted (or the hold recorded in deferred-items.md).
|
||||
- `go vet ./... && go test ./...` green in the framework, sm-seo-plugin, sm-journal-plugin and sm-demo-app; `npm --prefix ../sm-seo-plugin run test` green.
|
||||
- 32-VALIDATION.md `nyquist_compliant: true`.
|
||||
- Decision coverage: `comm -23 <(grep -oE '^- \*\*D-[0-9]+[abc]?' .planning/phases/32-seo-foundation/32-CONTEXT.md | sed 's/^- \*\*//' | LC_ALL=C sort -u) <(grep -oE '^\| D-[0-9]+[abc]?' .planning/phases/32-seo-foundation/32-DECISIONS-MAP.md | sed 's/^| //' | LC_ALL=C sort -u)` prints nothing: every decision is mapped to a plan or to Phase 33.
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
SC-5: the framework release with the seams is tagged as the next v0.5.x patch, it is strictly additive (D-106: no removed or changed API element, no method added to an existing interface), and the new code has unit tests delivered in this last plan; SC-1 to SC-4 are proven by the gate and the demo.
|
||||
</success_criteria>
|
||||
|
||||
## Artifacts this phase produces (plan 06)
|
||||
|
||||
- `scripts/check-phase32.sh` stages `additive` and `compat`; `scripts/apisurface/main.go` (the API surface printer the additive stage compares)
|
||||
- Unit tests: `modules/cabana/form_extensions_test.go`, `modules/cabana/record_events_test.go`, `modules/signpost/content_test.go`; `../sm-seo-plugin/classes/*_test.go` (TestResolverPrecedence, TestRedirectGraph, TestNormalizeMatrix, TestRobotsValueRoundTrip, TestRobotsMatcherGoogleExamples, TestTemplates, TestCSV, TestOwnerResolution, TestIssues); `../sm-seo-plugin/tests/elements/{text,robots,serp,robotstxt,transfer}.test.ts`; Journal descriptor, tag-type and slug tests
|
||||
- Updated `32-VALIDATION.md`; `deferred-items.md` when anything is held; `32-06-release-log.md` (the release steps as performed)
|
||||
- Tags (after the go-ahead): the framework's next v0.5.x patch, sm-journal-plugin's next patch, sm-seo-plugin's first release
|
||||
- sm-demo-app commits: framework pin, Journal bump, golem15.seo mount (summer.yaml, go.work, go.mod, .gitmodules, plugins.gen.go, main.go, config/golem15.seo.yaml, nginx `location = /robots.txt`, DEPLOY.md)
|
||||
- The summercms.io changelog post for the framework tag
|
||||
|
||||
<output>
|
||||
Create `.planning/phases/32-seo-foundation/32-06-SUMMARY.md` when done with the Task 4 answer, every version, tag, push and commit SHA (per task and commit group, the release steps copied from 32-06-release-log.md), the gate output summary and the changelog URL.
|
||||
</output>
|
||||
375
.planning/phases/32-seo-foundation/32-06-SUMMARY.md
Normal file
375
.planning/phases/32-seo-foundation/32-06-SUMMARY.md
Normal file
@@ -0,0 +1,375 @@
|
||||
---
|
||||
phase: 32-seo-foundation
|
||||
plan: 06
|
||||
subsystem: release
|
||||
tags: [release, apisurface, additive-gate, compat-gate, unit-tests, vitest, sm-seo-plugin, sm-journal-plugin, sm-demo-app, changelog]
|
||||
|
||||
requires:
|
||||
- phase: 32-01
|
||||
provides: cross-plugin admin form extensions (pact.AdminFormExtension, cabana compile and save)
|
||||
- phase: 32-02
|
||||
provides: record events (pact.RecordSaved/RecordDeleted, cabana.EmitRecord*), content descriptors (pact.ContentDescriptor, signpost lookups), Journal adoption
|
||||
- phase: 32-03
|
||||
provides: sm-seo-plugin core (entries, rules, settings, resolver, history)
|
||||
- phase: 32-04
|
||||
provides: redirects, 404 log, robots.txt
|
||||
- phase: 32-05
|
||||
provides: management API, MCP tools, batches, undo, CSV, check-phase32.sh, 32-05-demo-mount.patch
|
||||
provides:
|
||||
- "scripts/check-phase32.sh stages additive (scripts/apisurface API-surface comparison with the previous release) and compat (three consumers tested, every other sibling built), with self-tests"
|
||||
- "Framework unit matrices for form extensions, record events and content descriptors"
|
||||
- "sm-seo-plugin unit tests (classes) and 52 vitest element tests; sm-journal-plugin descriptor, journal-tag and translated-slug tests"
|
||||
- "SummerCMS v0.5.1 (patch, strictly additive), sm-journal-plugin v0.2.5, sm-seo-plugin v0.1.0 (first release), all pushed"
|
||||
- "sm-demo-app mounts golem15.seo v0.1.0 (pushed, not deployed)"
|
||||
- "Changelog post https://summercms.io/changelog/summercms-0-5-1"
|
||||
affects: [33, sm-demo-app, sm-grzybyfunkcjonalne-app, sm-summercmsio-app, vue-seo-layer]
|
||||
|
||||
actuals:
|
||||
tokens: 51000
|
||||
tasks: 5
|
||||
commits: 4
|
||||
plan_head_before: 49502e8ccb98e29a067961641dd08e2d39e42f27
|
||||
plan_head_after: a9a7f58eedaf70edd3472b6aebe01b2db4cbb498
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Release gate: the API surface of every changed framework package is compared with the previous release tag (tags containing HEAD skipped); removed or changed elements and methods added to existing interfaces are refused"
|
||||
- "Compat gate reads sibling repositories through temporary-index snapshots or detached worktrees and builds them in a symlinked scratch sibling layout"
|
||||
- "Release steps are logged as they complete (32-06-release-log.md) so a resumed run never re-tags, force-pushes or re-posts"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- scripts/apisurface/main.go
|
||||
- modules/cabana/form_extensions_test.go
|
||||
- modules/cabana/record_events_test.go
|
||||
- modules/signpost/content_test.go
|
||||
- .planning/phases/32-seo-foundation/32-06-release-log.md
|
||||
- .planning/phases/32-seo-foundation/deferred-items.md
|
||||
- ../sm-seo-plugin/classes/*_test.go (resolver, redirect_graph, normalize, robots_value, robots, templates, csv, owner, issues, helpers)
|
||||
- ../sm-seo-plugin/tests/elements/{text,robots,serp,robotstxt,transfer}.test.ts, tests/elements/css.ts
|
||||
- ../sm-journal-plugin/content_descriptors_test.go
|
||||
- ../sm-demo-app/config/golem15.seo.yaml, seo_mount_test.go, seo_mcp_test.go
|
||||
modified:
|
||||
- scripts/check-phase32.sh
|
||||
- .planning/phases/32-seo-foundation/32-VALIDATION.md
|
||||
- ../sm-seo-plugin/go.mod, README.md, classes/redirect_graph.go, classes/issues.go, classes/robots.go, assets/src/elements/measure.ts, assets/dist/seo.js
|
||||
- ../sm-journal-plugin/go.mod, README.md, menu_item_types_test.go
|
||||
- ../sm-demo-app/go.mod, go.sum, go.work, .gitmodules, summer.yaml, plugins.gen.go, boot_test.go, DEPLOY.md, deploy/nginx/demo.summercms.io.conf, plugins/golem15/journal, plugins/golem15/seo
|
||||
|
||||
key-decisions:
|
||||
- "Release per Jakub's go-ahead: SummerCMS v0.5.1, sm-journal-plugin v0.2.5, sm-seo-plugin v0.1.0, all pushed with their branches; sm-demo-app's three commits pushed; nothing deployed"
|
||||
- "The additive gate compares with the newest tag that does not contain HEAD, so a run on the tagged release commit compares it with the previous release, not with itself"
|
||||
- "The demo Journal bump replaces the other session's uncommitted journal pointer drift on the same path (b129902, an ancestor of v0.2.5) with the v0.2.5 pointer; the oauthserver drift is left untouched"
|
||||
- "check-pins is proven on the committed demo tree (clean detached worktree), because the live tree carries another session's oauthserver drift"
|
||||
- "The optional app Journal bumps and per-plugin changelog posts were not named and are deferred"
|
||||
|
||||
patterns-established:
|
||||
- "Post-release gate runs pick the previous release as the additive baseline (git tag --no-contains HEAD)"
|
||||
|
||||
requirements-completed: [SC-5, SC-1, SC-2, SC-3, SC-4, Q-01, D-106, D-90, D-91, D-92, D-93, D-98, D-22, D-25, D-09]
|
||||
|
||||
coverage:
|
||||
- id: D1
|
||||
description: "Additive and compat gate stages: the v0.5.1 API surface keeps every v0.5.0 element (cabana +2, pact +87, signpost +8 lines, nothing removed or changed, no interface method added); consumers build and test unchanged"
|
||||
requirement: "D-106"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase32.sh --additive (release commit 15b0d0d vs v0.5.0); bash scripts/check-phase32.sh --self-test"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase32.sh --all (compat stage: 3 consumers tested, 20 siblings built)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D2
|
||||
description: "Framework unit matrices for form extensions, record events and content descriptors"
|
||||
requirement: "SC-5"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "go test ./modules/cabana ./modules/signpost (form_extensions_test.go, record_events_test.go, content_test.go)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D3
|
||||
description: "sm-seo-plugin class unit tests and element tests; Journal descriptor, journal-tag and translated-slug tests"
|
||||
requirement: "SC-5"
|
||||
verification:
|
||||
- kind: unit
|
||||
ref: "go -C ../sm-seo-plugin test ./... (TestResolverPrecedence, TestRedirectGraph, TestNormalizeMatrix, TestRobotsValueRoundTrip, TestRobotsMatcherGoogleExamples, TestTemplates, TestCSV, TestOwnerResolution, TestIssues)"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "npm --prefix ../sm-seo-plugin run test (52 element tests)"
|
||||
status: pass
|
||||
- kind: unit
|
||||
ref: "go -C ../sm-journal-plugin test ./... (content_descriptors_test.go, menu_item_types_test.go)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D4
|
||||
description: "Releases tagged and pushed: SummerCMS v0.5.1, sm-journal-plugin v0.2.5, sm-seo-plugin v0.1.0"
|
||||
requirement: "Q-01"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "git ls-remote --tags origin v0.5.1 / v0.2.5 / v0.1.0 (aa6e0a5, 16d9326, 9cf0447)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D5
|
||||
description: "sm-demo-app mounts golem15.seo v0.1.0 with tagged requires; SEO tab and MCP catalog proven"
|
||||
requirement: "SC-4"
|
||||
verification:
|
||||
- kind: integration
|
||||
ref: "go -C ../sm-demo-app test -count=1 -tags summercms_mcp -run 'TestSEOToolsCatalog|TestGoModRequiresTags|TestSEOTabMounted|TestBootAllPlugins' . (Docker)"
|
||||
status: pass
|
||||
- kind: other
|
||||
ref: "scripts/check-pins.sh in a clean worktree of 9451b31: check-pins: ok (17 modules)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D6
|
||||
description: "Full phase gate green with the demo mounted and no skips"
|
||||
requirement: "D-90"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "bash scripts/check-phase32.sh --all (exit 0, Phase 32 gate passed)"
|
||||
status: pass
|
||||
human_judgment: false
|
||||
- id: D7
|
||||
description: "Changelog post for v0.5.1 on summercms.io reads well and says the right things to users"
|
||||
verification:
|
||||
- kind: other
|
||||
ref: "https://summercms.io/changelog/summercms-0-5-1 answers 200; API shows published at the tag date"
|
||||
status: pass
|
||||
human_judgment: true
|
||||
rationale: "Wording and emphasis of public release notes are an editorial call"
|
||||
|
||||
duration: 1h 25m
|
||||
completed: 2026-10-27
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 32 Plan 06: Unit tests, additive release gate and the v0.5.1 release Summary
|
||||
|
||||
**The phase is proven and released. An API-surface gate shows the framework change is strictly additive against v0.5.0, and a compat gate builds every sibling consumer unchanged. Unit tests cover the framework seams, the SEO plugin (Go and elements) and Journal. SummerCMS v0.5.1, sm-journal-plugin v0.2.5 and sm-seo-plugin v0.1.0 are tagged and pushed. sm-demo-app mounts golem15.seo v0.1.0 and is pushed, not deployed. The changelog post is at https://summercms.io/changelog/summercms-0-5-1.**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** about 1h 25m in two executor contexts (Tasks 1 to 3, then Task 5 after the Task 4 checkpoint)
|
||||
- **Started:** 2026-10-27T11:51Z (plan base 49502e8)
|
||||
- **Completed:** 2026-10-27T13:20Z
|
||||
- **Tasks:** 5 (4 executed, 1 decision checkpoint)
|
||||
- **Files modified:** 6 in this repository, 23 in sm-seo-plugin, 4 in sm-journal-plugin, 14 in sm-demo-app
|
||||
|
||||
## Task 4 answer (Jakub)
|
||||
|
||||
- **Decision:** release. Versions confirmed: v0.5.1, v0.2.5 and v0.1.0.
|
||||
- **Approved pushes:**
|
||||
- framework master and v0.5.1 (master carried 64 commits, including other sessions' work; accepted)
|
||||
- sm-journal-plugin main and v0.2.5
|
||||
- sm-seo-plugin main (first push) and v0.1.0
|
||||
- sm-demo-app master with three commits
|
||||
- **Changelog:** a post for v0.5.1.
|
||||
- **Not named:** the optional app Journal bumps. **Nothing deployed.**
|
||||
- **Gate:** the full run with the demo mounted and no test skips. The fixture is readable after the chown.
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- `check-phase32.sh` has two new stages:
|
||||
- **additive:** `scripts/apisurface` compares the exported API with the previous release and refuses removed or changed elements and methods added to existing interfaces. The self-test plants each case.
|
||||
- **compat:** sm-sitemap-plugin, sm-journal-plugin and sm-demo-app are tested; every other sibling that requires the framework is built.
|
||||
- **Unit tests:**
|
||||
- framework matrices for form extensions, record events and content descriptors
|
||||
- sm-seo-plugin classes (resolver, redirect graph, normalisation, robots value and matcher, templates, CSV, owner, issues) and 52 vitest element tests
|
||||
- Journal: descriptors, the journal-tag type and translated slugs
|
||||
- **Releases:** v0.5.1, v0.2.5 and v0.1.0 are tagged and pushed. Both plugins require v0.5.1.
|
||||
- **Demo:** sm-demo-app requires v0.5.1, bumps Journal to v0.2.5 and mounts golem15.seo v0.1.0 (the 32-05 patch, the submodule and go.work).
|
||||
- **Changelog:** v0.5.1 is announced.
|
||||
|
||||
## Task Commits
|
||||
|
||||
**summercms.go**
|
||||
1. **Task 1: additive and compat stages** - `2b300ec` (test)
|
||||
2. **Task 2: framework unit matrices** - `8c961f5` (test)
|
||||
3. **Task 3D: validation map** - `15b0d0d` (docs). This is the release commit, tagged v0.5.1.
|
||||
4. **Task 5 fix: additive baseline after tagging** - `a9a7f58` (fix). Local only, after the tag.
|
||||
|
||||
**sm-seo-plugin**
|
||||
- Task 3 fixes and refactors:
|
||||
- `e957c00` refactor: run the redirect simulation over a rule list
|
||||
- `79567b3` fix: a loop through the site's absolute URL lists each address once
|
||||
- `6d54fc7` refactor: build the issue report from loaded data
|
||||
- `9461c74` fix: the result preview truncates at the last word boundary
|
||||
- Task 3A: `9e45ddc` test: unit tests for the SEO classes
|
||||
- Task 3B: `dcfbdc0` test: element backstops
|
||||
- Task 5: `b19cd06` chore: require SummerCMS v0.5.1. Tagged v0.1.0.
|
||||
|
||||
**sm-journal-plugin**
|
||||
- Task 3C: `fea88f8` test: content descriptors, journal-tag type and translated slugs
|
||||
- Task 5: `f5a0394` chore: require SummerCMS v0.5.1. Tagged v0.2.5.
|
||||
|
||||
**sm-demo-app** (Task 5)
|
||||
- `11f64bf` chore: require SummerCMS v0.5.1 (go.mod, go.sum)
|
||||
- `11d485f` chore: bump journal to v0.2.5 (go.mod, go.sum, plugins/golem15/journal)
|
||||
- `9451b31` feat: mount golem15.seo v0.1.0 (13 paths, all from this plan)
|
||||
|
||||
**Plan metadata:** the commit that adds this SUMMARY (docs).
|
||||
|
||||
`commits: 4` is measured in this repository with `git rev-list --count 49502e8..HEAD` before this SUMMARY's commit. Sibling commits are listed above.
|
||||
|
||||
## Release steps (from 32-06-release-log.md)
|
||||
|
||||
- **Pre-checks:**
|
||||
- framework: newest tag v0.5.0; master was 64 ahead of origin/master and 0 behind.
|
||||
- admin/: only `admin/tests/form/FormView.test.ts` changed, so no dist rebuild was needed.
|
||||
- **Step 1, framework:**
|
||||
- `go vet` and `go test -short` green.
|
||||
- Annotated tag v0.5.1: tag object aa6e0a5 on commit 15b0d0d.
|
||||
- `git push origin master`: 223f87e..15b0d0d, fast-forward checked after `git fetch`.
|
||||
- `git push origin v0.5.1`; `ls-remote` confirms it.
|
||||
- **Step 2, sm-journal-plugin:**
|
||||
- `go get summercms@v0.5.1` with `GOWORK=off` and `GOPRIVATE`.
|
||||
- README dependency line updated to v0.5.1 (signpost is now a runtime dependency).
|
||||
- Build, vet and `test -short` green.
|
||||
- Commit f5a0394; tag v0.2.5 (tag object 16d9326).
|
||||
- Pushed main 7fc07d8..f5a0394 and the tag.
|
||||
- **Step 3, sm-seo-plugin:**
|
||||
- The same require, plus the README dependency line "SummerCMS v0.5.1 modules".
|
||||
- Build, vet and `test -short` green.
|
||||
- Commit b19cd06; tag v0.1.0 (tag object 9cf0447).
|
||||
- `git push -u origin main` (a new branch on the empty remote) and the tag.
|
||||
- **Step 4, sm-demo-app:**
|
||||
- Found at the start: ` M plugins/golem15/journal` and ` M plugins/golem15/oauthserver`.
|
||||
- Commit 11f64bf: require v0.5.1.
|
||||
- The journal submodule HEAD (b129902) is an ancestor of v0.2.5, so it was moved to v0.2.5. Commit 11d485f: only the v0.2.5 pointer was staged, and it replaces the foreign journal drift on that path.
|
||||
- Mount:
|
||||
- `git apply` the 32-05 patch
|
||||
- `git submodule add -b main` sm-seo-plugin, checked out at v0.1.0
|
||||
- go.work `use ./plugins/golem15/seo`
|
||||
- `go get sm-seo-plugin@v0.1.0` and `go mod tidy` (GOWORK=off)
|
||||
- `summer build` printed ✓ Built bin/demo
|
||||
- Build (plain and summercms_mcp), vet and `test -short` green. With Docker, TestBootAllPlugins, TestGoModRequiresTags, TestSEOToolsCatalog and TestSEOTabMounted pass.
|
||||
- Commit 9451b31.
|
||||
- check-pins: the live tree fails only on the foreign oauthserver drift. A clean worktree of 9451b31 prints `check-pins: ok (17 modules)`, and `GOWORK=off go build ./...` builds from the published tags (plain and mcp).
|
||||
- Pushed master 8fcdbdd..9451b31. Not deployed.
|
||||
- **Step 5, gate:** `check-phase32.sh --all` passes (details under Gate output).
|
||||
- **Step 6, changelog:**
|
||||
- `changelog-post.py source v0.5.1`, then the notes (## Highlights, ## Added).
|
||||
- `publish` returned post id 45: https://summercms.io/changelog/summercms-0-5-1. It is published at the tag date and the page answers 200.
|
||||
- The script read the token itself; it was never printed.
|
||||
- **Step 7, deferred items:** deferred-items.md is written.
|
||||
|
||||
## Gate output (step 5)
|
||||
|
||||
`bash scripts/check-phase32.sh --all` ran with Docker, the demo mounted, no `PHASE32_*` overrides and no test skips. It exited 0 with "Phase 32 gate passed".
|
||||
|
||||
- **Stages:** PASS for self-test, go, plugins (TestNoTideJournalFixtures included), consumers, admin, docs, marker, additive, compat and docker.
|
||||
- **compat:** sm-sitemap-plugin, sm-journal-plugin and sm-demo-app are tested. fonoteka.go, sm-bm-app, sm-grzybyfunkcjonalne-app and every sibling plugin are built.
|
||||
- **docker:** TestSEOTabMounted and TestSEOToolsCatalog pass in the demo.
|
||||
- **No failure lines:** no FAIL, `refuse:`, NOT MOUNTED or additive refusal.
|
||||
- **Additive baseline:** the additive line of that run compared v0.5.1 with itself, which led to fix a9a7f58. Re-run on the release commit, it compared against v0.5.0: cabana +2, pact +87, signpost +8 lines.
|
||||
|
||||
## Decisions Made
|
||||
|
||||
See `key-decisions` in the frontmatter.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Behaviour-neutral refactors so TestRedirectGraph and TestIssues run under -short**
|
||||
- **Found during:** Task 3A
|
||||
- **Fix:** the redirect simulation runs over a rule list, and the issue report is built from loaded data.
|
||||
- **Commits:** sm-seo-plugin e957c00, 6d54fc7
|
||||
|
||||
**2. [Rule 1 - Bug] A loop notice listed an address twice**
|
||||
- **Found during:** Task 3A
|
||||
- **Fix:** a loop through the site's absolute URL lists each address once.
|
||||
- **Commit:** sm-seo-plugin 79567b3
|
||||
|
||||
**3. [Rule 1 - Bug] The result preview did not truncate per UI-SPEC E-1**
|
||||
- **Found during:** Task 3B
|
||||
- **Fix:** the preview truncates at the last word boundary plus " …", and the dist bundle was rebuilt.
|
||||
- **Commit:** sm-seo-plugin 9461c74
|
||||
|
||||
**4. [Rule 3 - Blocking] Extra test support files**
|
||||
- **Found during:** Task 3
|
||||
- **Fix:** classes/helpers_test.go and tests/elements/css.ts were added, and gorm.io/driver/postgres became a direct require in sm-seo-plugin's go.mod.
|
||||
- **Commits:** 9e45ddc, dcfbdc0
|
||||
|
||||
**5. [Rule 3 - Blocking] No layout in happy-dom**
|
||||
- **Found during:** Task 3B
|
||||
- **Fix:** the 320 and 360 px element rows check the stylesheet's layout contract.
|
||||
- **Commit:** dcfbdc0
|
||||
|
||||
**6. [Rule 3 - Blocking] The compat stage has to read other repositories without touching their trees**
|
||||
- **Found during:** Task 1
|
||||
- **Fix:** it reads them through temporary-index snapshots or detached worktrees and builds in a symlinked scratch sibling layout. There is a new PHASE32_SKIP_TESTS knob.
|
||||
- **Commit:** 2b300ec
|
||||
|
||||
**7. No separate RED commits**
|
||||
- **Found during:** Tasks 2 and 3
|
||||
- **Reason:** the green-at-every-commit rule in CLAUDE.md.
|
||||
|
||||
**8. Element tests: 52, against the plan's minimum of 20.**
|
||||
|
||||
**9. [Rule 1 - Bug] The additive stage compared the release with itself once HEAD was tagged**
|
||||
- **Found during:** Task 5, step 5
|
||||
- **Issue:** `last_tag` picked the newest tag, which was v0.5.1 on HEAD.
|
||||
- **Fix:** `git tag --sort=-v:refname --no-contains HEAD`. The re-run against v0.5.0 passes, and so does `--self-test`.
|
||||
- **Commit:** a9a7f58 (local; it is after the pushed tag and was not pushed)
|
||||
|
||||
**10. [Rule 3 - Blocking] The live demo tree fails check-pins**
|
||||
- **Found during:** Task 5, step 4
|
||||
- **Issue:** another session's uncommitted oauthserver drift (b6a9586 against v0.1.2, 8bbec72).
|
||||
- **Fix:** none in the live tree; the drift was left alone. check-pins is proven on a clean detached worktree of the pushed commit.
|
||||
|
||||
**11. [Rule 2 - Docs] Journal README dependency line**
|
||||
- **Found during:** Task 5, step 2
|
||||
- **Issue:** the plan named only the sm-seo-plugin README.
|
||||
- **Fix:** the Journal README now names SummerCMS v0.5.1, and signpost moved from "in tests" to a runtime dependency (CLAUDE.md documentation rule).
|
||||
- **Commit:** f5a0394
|
||||
|
||||
**12. [Rule 3 - Blocking] The demo's TestSEO* tests skip under -short (they need Docker)**
|
||||
- **Fix:** they were run without -short with Docker. Both pass, tagged and untagged.
|
||||
|
||||
**13. `go mod tidy` in the demo**
|
||||
- **Why:** to make sm-seo-plugin a direct require.
|
||||
- **Effect:** go.sum gained grobotstxt's test-dependency checksums and dropped the obsolete v0.5.0 and v0.2.3 lines.
|
||||
- **Commit:** 9451b31
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 13 (5 Rule 1, 1 Rule 2, 5 Rule 3, 2 notes). **Impact:** the fixes are bugs in plugin code or in the gate, plus test scaffolding. No scope creep and no API change.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
- **g15office comment not posted.** This executor has no g15office tool. The orchestrator posts the release comment on Phase 32's milestone task `8gldeain` (`.planning/G15OFFICE.md`).
|
||||
- **Retracted dependency in the demo.** sm-demo-app pins `github.com/gabriel-vasile/mimetype v1.4.15`, which upstream has retracted. This was there before the plan; it is recorded in deferred-items.md.
|
||||
|
||||
## Deferred (deferred-items.md)
|
||||
|
||||
- Journal bumps in sm-grzybyfunkcjonalne-app (with `golem15.journal.tag_pages: false`) and sm-summercmsio-app. Not named in the go-ahead.
|
||||
- Changelog posts of their own for sm-journal-plugin v0.2.5 and sm-seo-plugin v0.1.0.
|
||||
- Deploying the demo.
|
||||
- The demo's oauthserver drift (another session's) and the retracted mimetype pin.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Phase 33 can build on the tagged v0.5.1 seams and on sm-seo-plugin v0.1.0.
|
||||
- The demo is pushed but not deployed. Deploy per `../sm-demo-app/DEPLOY.md` when Jakub says so.
|
||||
- Local commits after the release: a9a7f58 and this SUMMARY's commit. They go out with the next framework push.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- Files: scripts/apisurface/main.go, modules/cabana/form_extensions_test.go, modules/cabana/record_events_test.go, modules/signpost/content_test.go, 32-06-release-log.md and deferred-items.md exist.
|
||||
- Commits: 2b300ec, 8c961f5, 15b0d0d and a9a7f58 are in this repository. e957c00, 79567b3, 6d54fc7, 9e45ddc, 9461c74, dcfbdc0 and b19cd06 are in sm-seo-plugin; fea88f8 and f5a0394 in sm-journal-plugin; 11f64bf, 11d485f and 9451b31 in sm-demo-app.
|
||||
- Remote tags: v0.5.1 (aa6e0a5), v0.2.5 (16d9326) and v0.1.0 (9cf0447).
|
||||
- Changelog URL answers 200.
|
||||
|
||||
---
|
||||
*Phase: 32-seo-foundation*
|
||||
*Completed: 2026-10-27*
|
||||
29
.planning/phases/32-seo-foundation/32-06-release-log.md
Normal file
29
.planning/phases/32-seo-foundation/32-06-release-log.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Plan 32-06 release log
|
||||
|
||||
Resume record of Task 5 (one-way). A resumed run confirms each `step <n> done` line and skips it: no tag is created twice, no push is forced, the changelog is posted once.
|
||||
|
||||
## Task 4 answer (Jakub, 2026-10-27)
|
||||
|
||||
- **Decision:** release (full Task 5).
|
||||
- **Versions:** framework `v0.5.1`, sm-journal-plugin `v0.2.5`, sm-seo-plugin `v0.1.0`.
|
||||
- **Pushes approved:** framework master + v0.5.1 (master carries 64 commits incl. other sessions' work, accepted); sm-journal-plugin main + v0.2.5; sm-seo-plugin main (first push, `-u`) + v0.1.0; sm-demo-app master (three commits: framework pin, Journal bump, golem15.seo mount).
|
||||
- **Changelog:** post v0.5.1 on summercms.io.
|
||||
- **Not named:** optional Journal bumps in sm-grzybyfunkcjonalne-app and sm-summercmsio-app (deferred).
|
||||
- **Nothing is deployed.**
|
||||
- **Gate:** full `check-phase32.sh --all` with the demo mounted, no PHASE32_ALLOW_UNMOUNTED, no TestNoTideJournalFixtures skip (fixture readable after the chown).
|
||||
|
||||
## Pre-checks
|
||||
|
||||
- framework: `git fetch --tags origin`; newest tag v0.5.0; master is 64 ahead, 0 behind origin/master (fast-forward).
|
||||
- admin/: only `admin/tests/form/FormView.test.ts` changed since v0.5.0; the embedded dist is unaffected, no rebuild.
|
||||
|
||||
## Steps
|
||||
|
||||
- step 1 done: framework `go vet ./...` + `go test -short ./...` green; annotated tag v0.5.1 (tag object aa6e0a5, commit 15b0d0d) created; `git push origin master` 223f87e..15b0d0d (fast-forward checked after `git fetch origin`); `git push origin v0.5.1` new tag; `git ls-remote --tags origin v0.5.1` prints aa6e0a5.
|
||||
- step 2 done: sm-journal-plugin `GOWORK=off GOPRIVATE=git.golem15.com/* go get git.golem15.com/golem15/summercms@v0.5.1` (v0.5.0 => v0.5.1; go.sum unchanged, the module's replace points at ../summercms.go), README dependency line v0.5.1 (signpost now a runtime dependency); `GOWORK=off go build ./... && go vet ./... && go test -short ./...` green; commit f5a0394 `chore: require SummerCMS v0.5.1` (go.mod, README.md); annotated tag v0.2.5 (tag object 16d9326, commit f5a0394); `git push origin main` 7fc07d8..f5a0394 (fast-forward checked); `git push origin v0.2.5` new tag; ls-remote prints 16d9326.
|
||||
- step 3 done: sm-seo-plugin `GOWORK=off GOPRIVATE=git.golem15.com/* go get git.golem15.com/golem15/summercms@v0.5.1` (v0.5.0 => v0.5.1; go.sum unchanged, replace to ../summercms.go), README dependency line "SummerCMS v0.5.1 modules"; `GOWORK=off go build ./... && go vet ./... && go test -short ./...` green; commit b19cd06 `chore: require SummerCMS v0.5.1` (go.mod, README.md); annotated tag v0.1.0 (tag object 9cf0447, commit b19cd06); `git push -u origin main` new branch (first push, origin was empty); `git push origin v0.1.0` new tag; ls-remote prints main b19cd06 and v0.1.0 9cf0447.
|
||||
- step 4 done: sm-demo-app (pre-existing drift ` M plugins/golem15/journal` (4ab94da recorded, b1299021 checked out) and ` M plugins/golem15/oauthserver` (8bbec72 recorded, b6a9586 checked out) found at start). Commit 11f64bf `chore: require SummerCMS v0.5.1` (go.mod, go.sum; build, mcp build, vet, test -short green). Journal submodule HEAD b129902 confirmed an ancestor of v0.2.5, checked out at v0.2.5 (f5a0394); commit 11d485f `chore: bump journal to v0.2.5` (go.mod, go.sum, plugins/golem15/journal: 4ab94da -> f5a0394; this pointer replaces the other session's journal drift on the same path, only the intended v0.2.5 pointer staged). Mount: `git apply 32-05-demo-mount.patch`, `git submodule add -b main git@git.golem15.com:golem15/sm-seo-plugin.git plugins/golem15/seo` checked out at v0.1.0 (b19cd06), `./plugins/golem15/seo` in go.work, `GOWORK=off go get sm-seo-plugin@v0.1.0` + `GOWORK=off go mod tidy` (seo a direct require), `go run ../summercms.go/cmd/summer build` (✓ Built bin/demo; plugins.gen.go as in the patch, main.go unchanged); `go build ./...`, `go build -tags summercms_mcp ./...`, `go vet ./...`, `go test -short ./...` green; Docker runs: TestBootAllPlugins, TestGoModRequiresTags, TestSEOToolsCatalog, TestSEOTabMounted PASS (tagged), TestBootAllPlugins, TestSEOTabMounted PASS (untagged); commit 9451b31 `feat: mount golem15.seo v0.1.0` (13 paths, this plan's only). `scripts/check-pins.sh` in the live tree fails only on the other session's oauthserver drift; in a detached worktree of 9451b31 with `git submodule update --init plugins/` it prints `check-pins: ok (17 modules)`, and `GOWORK=off go build ./...` (plain and summercms_mcp) builds from the published tags; scratch worktree removed. `git push origin master` 8fcdbdd..9451b31 (fast-forward checked). Not deployed. ` M plugins/golem15/oauthserver` left as found.
|
||||
- step 6a: `scripts/changelog-post.py source v0.5.1` (from ../sm-summercmsio-app) printed the tag message and 64 commit subjects since v0.5.0; user-facing notes written to a scratch file (## Highlights, ## Added; no Changed/Fixed entries in this release).
|
||||
- step 5 done: `bash scripts/check-phase32.sh --all` (no PHASE32_* overrides, Docker, demo mounted at 9451b31, no test skips) exit 0, "Phase 32 gate passed": PASS self-test, go, plugins (TestNoTideJournalFixtures included), consumers, admin, docs, marker, additive, compat (sm-sitemap-plugin, sm-journal-plugin, sm-demo-app tested; every other sibling built), docker (TestSEOTabMounted, TestSEOToolsCatalog in sm-demo-app). No FAIL, refuse:, NOT MOUNTED or additive refusal lines. The additive stage of that run compared v0.5.1 with itself (last_tag picked the tag on HEAD); fixed in a9a7f58 `fix(32-06): the additive stage compares with the previous release once HEAD is tagged` (last_tag uses `--no-contains HEAD`); `check-phase32.sh --additive` on the release commit then compared with v0.5.0: cabana +2, pact +87, signpost +8 lines, nothing removed or changed, no interface method added; `--self-test` passes. a9a7f58 is local (after the tag, not pushed).
|
||||
- step 6 done: `scripts/changelog-post.py publish v0.5.1 <notes> --excerpt "Plugins can extend each other's admin forms, react to record writes and map URLs to records. Strictly additive."` posted id=45, https://summercms.io/changelog/summercms-0-5-1 (title "SummerCMS 0.5.1", published_at 2026-10-27T13:00:42Z, the tag's date). Token read by the script from ~/.config/summercms/journal-token; never printed or copied.
|
||||
- step 7 done: deferred-items.md lists the unnamed app Journal bumps (sm-grzybyfunkcjonalne-app, sm-summercmsio-app), plugin release posts, the deploy, the demo's oauthserver drift and the retracted mimetype pin. Nothing deployed.
|
||||
413
.planning/phases/32-seo-foundation/32-CONTEXT.md
Normal file
413
.planning/phases/32-seo-foundation/32-CONTEXT.md
Normal file
@@ -0,0 +1,413 @@
|
||||
# Phase 32: SEO foundation - Context
|
||||
|
||||
**Gathered:** 2026-10-24
|
||||
**Status:** Ready for planning. On 2026-10-25 Jakub resolved the phase split (Q-01: 32 plus a large 33), confirmed D-32 and set the code layout (section 0, D-90 to D-97).
|
||||
**Participant:** Dawid (SEO specialist, delegated by Jakub for the SEO discussion). The discussion was in Polish; every decision below is recorded in English.
|
||||
|
||||
<domain>
|
||||
## Phase Boundary
|
||||
|
||||
Search-engine optimisation built into SummerCMS, meant to be better suited to SEO than WinterCMS, for every application on the framework.
|
||||
|
||||
SummerCMS is headless: Go serves the admin and the JSON APIs, and Nuxt layers or apps render the public HTML. SEO is therefore split in two:
|
||||
- **Backend (shared plugins, on generic framework seams):** owns the SEO data, the rules and the admin. It serves the effective SEO of a URL to the frontend, along with robots.txt, the sitemaps, the redirect rules and the verification files. Every operation is reachable through MCP. The SEO code lives in `sm-seo-plugin` (Golem15.SEO) and `sm-sitemap-plugin` (Golem15.Sitemap); the framework only gains generic seams that name nothing SEO-specific (D-90).
|
||||
- **Nuxt layers:** render the data into `<head>`, JSON-LD, breadcrumbs, pagination and headings, enforce redirects and noindex on their routes, and guarantee server rendering.
|
||||
|
||||
The phase covers:
|
||||
- per-record and global SEO;
|
||||
- per-URL rules;
|
||||
- canonical and meta robots;
|
||||
- social tags;
|
||||
- redirects;
|
||||
- URL normalisation and strict URLs;
|
||||
- robots.txt and AI bots;
|
||||
- noindex policy;
|
||||
- XML and HTML sitemaps;
|
||||
- a page registry;
|
||||
- pagination;
|
||||
- structured data;
|
||||
- headings;
|
||||
- hreflang;
|
||||
- an SSR guarantee;
|
||||
- internal linking;
|
||||
- media SEO;
|
||||
- breadcrumbs;
|
||||
- full MCP management;
|
||||
- an audit crawler with an issue report.
|
||||
|
||||
Out of scope: e-commerce structured data and product or category shop pages (no shops yet); migrating `sm-bm-app` to SSR (it is internal, see D-71).
|
||||
|
||||
</domain>
|
||||
|
||||
<decisions>
|
||||
## Implementation Decisions
|
||||
|
||||
### Phase split (resolved)
|
||||
- **Q-01 (resolved by Jakub, 2026-10-25): two consecutive phases, the second one large.** Dawid left the split to Jakub. Every decision in this document applies to both phases:
|
||||
- **32 Foundation:**
|
||||
- the three framework seams (D-91 to D-93), with the field placement rules of D-91;
|
||||
- `sm-seo-plugin` core: data model, SEO tab, global settings;
|
||||
- meta, canonical, robots;
|
||||
- redirects, URL normalisation, strict URLs;
|
||||
- robots.txt, MCP tools, history.
|
||||
|
||||
The seams are one-way framework API. Phase 32 ends with a framework release tag, and Phase 33 builds on that tagged version rather than on a `replace`.
|
||||
- **33 Output, audit and content** (about 12–15 plans):
|
||||
- `sm-sitemap-plugin` rewrite (D-32): XML and HTML sitemaps;
|
||||
- page registry;
|
||||
- JSON-LD, pagination, hreflang;
|
||||
- headings, breadcrumbs;
|
||||
- the Nuxt SEO layer and the SSR rules in the layers;
|
||||
- crawler and issue report;
|
||||
- internal linking and auto-links;
|
||||
- media (alt, file names, formats).
|
||||
|
||||
**Exception to the lean-planning rule, approved by Jakub:** Phase 33 is planned as many smaller plans instead of a few large ones, so the planner must not merge them into 3–4 plans. The other project rules still apply: the plan list with a one-line scope each is shown to Jakub before PLAN.md files are written, and unit tests are the last plan.
|
||||
|
||||
ROADMAP.md still lists one Phase 32 with the full scope. Before `/msd-plan-phase 32`, narrow Phase 32 and add Phase 33 through `/msd-phase`, with its g15office task. The planner must not split or merge phases on its own.
|
||||
|
||||
### 0. Code layout (Jakub, 2026-10-25)
|
||||
- **D-90:** **The framework carries no SEO code.** SEO lives in two shared plugins: a new `sm-seo-plugin` (Golem15.SEO) and an updated `sm-sitemap-plugin` (Golem15.Sitemap). The framework gets only the generic seams those plugins need (D-91 to D-93); none of them names SEO, and each is useful to other plugins. The pattern is the PixelPixel `mpseo` WinterCMS plugin (see Reference implementations):
|
||||
- content plugins did not import anything from it; they registered a content type (model, controller, a mapper for default title/description/image, a URL resolver, an `is_published` check, the tab position) through the `seoinjection.extend` event;
|
||||
- the SEO plugin owned one `entries` table keyed by source type and id plus the URL, injected the SEO tab into the registered controllers through `extendFormFields`, deleted the entry with the record, kept per-type defaults with placeholders in its settings (with an inject switch per type), generated entries in a job, had a Google result preview and revisions, and resolved SEO by URL on the frontend.
|
||||
|
||||
SummerCMS keeps that division and replaces the event with D-91 to D-93. — **Reversibility:** costly — the seams become framework API, and moving SEO back into the framework later would mean migrating the plugin's tables.
|
||||
- **D-91:** **Cross-plugin admin form extensions, with real field placement.** `pact.AdminActionExtension` (controller ID plus record actions; its comment already leaves room for more kinds) gains form fields and tabs. An extension targets a controller ID, adds fields and tabs to its form, and loads and saves their values itself through `Load` and `Save` hooks that run inside the record's save transaction. The owner's model and tables are untouched.
|
||||
|
||||
Placement must work properly. In WinterCMS, adding field C at the end of A, B was easy, but placing it between them (A, C, B) meant fighting `extendFormFields`. Here:
|
||||
- every field and tab in a compiled form has a stable name: the field key from `fields.yaml`, the tab key;
|
||||
- an extension places each field with `Before` or `After` an anchor field, inside an existing tab, a new tab, or a zone (outside the tabs, primary tabs, secondary tabs); with no anchor the field goes to the end of its tab, as in WinterCMS;
|
||||
- a new tab is placed the same way, `Before` or `After` another tab;
|
||||
- an extension may hide an owner's field, for example a plugin's own meta-title field that the SEO tab replaces (`mpseo` removed `viewBag[meta_title]` the same way);
|
||||
- the result is deterministic: extensions apply in plugin order (`party`, by `Requires()`); several extensions anchored at the same point keep that order; an anchor may name a field added by another extension only if that plugin is in `Requires()`;
|
||||
- an unknown anchor, a duplicate name or an anchor cycle stops the boot with a clear error, like the existing `AdminActionExtension` checks;
|
||||
- cabana compiles the final order at boot; the SPA renders the compiled form as it is and never reorders it; field `span` (left, right, full) keeps working next to inserted fields;
|
||||
- top-level fields and tabs only; fields inside repeaters and nested forms are out of scope for now.
|
||||
|
||||
Tests cover at least: C after A gives A, C, B; C before the first field; a new tab between two existing tabs; two plugins anchored at the same field; hiding a field; each boot error. — **Reversibility:** one-way — the extension struct and the anchor rules become a published framework API.
|
||||
- **D-92:** **Record events from cabana.** Other plugins can subscribe to "record saved" (created or updated) and "record deleted" for a controller or model type. The event carries the record id, the locale and the changed attributes with old and new values (so a slug or parent change is visible), and fires after commit. Admin, MCP and imports all go through cabana and emit it; plugin code that writes records directly uses a cabana helper to emit the same event. Today only GORM hooks on the owner's model exist, which another plugin cannot use. The SEO plugin uses the events for the automatic 301 (D-18) and to delete SEO entries with their record. — **Reversibility:** costly — subscribers in shared plugins depend on the event shape.
|
||||
- **D-93:** **Content descriptors in signpost.** `pact.MenuItemType` already has URL patterns, `Resolve` and locale alternates. It gains optional functions that describe the type's content: list the records (for sitemaps and the registry), `lastmod`, whether a record is published, and default title, description and image (the `mapper` of `mpseo`). Content plugins (journal, FAQ, future ones) only register types in signpost, as they already do for menus and the sitemap, and never import `sm-seo-plugin` or `sm-sitemap-plugin`. — **Reversibility:** costly — every content plugin implements these functions.
|
||||
- **D-94:** **`sm-seo-plugin` (Golem15.SEO)**, a new repo mounted like the other core plugins:
|
||||
- models: the SEO entry (type, id, locale, URL, the SEO tab's values, `data` jsonb), entry revisions (history and undo), settings (sections 1 and 4, with a tab per content type: templates with placeholders and an inject switch, as in `mpseo`), URL rules, redirects, the 404 log, robots.txt, the page registry (D-33);
|
||||
- uses D-91 to add the SEO tab to every registered type's controller, D-92 for the automatic 301 and cleanup, D-93 for defaults and URL ownership;
|
||||
- a job that creates missing entries (the `mpseo` GenerateSeoEntriesJob), run through `conga`;
|
||||
- the frontend API: effective SEO by URL, redirects, robots.txt, llms.txt, verification files, JSON-LD `@graph`, breadcrumbs;
|
||||
- admin widgets: the result preview, the placeholder list, revisions;
|
||||
- MCP through `pier` from its admin routes, plus CSV import/export and the issue report; the crawler (Phase 33) lives here too.
|
||||
- **D-95:** **`sm-sitemap-plugin` (Golem15.Sitemap)** produces the sitemaps of D-30, D-31 and D-34 from signpost (D-93). It knows nothing about SEO: it defines its own small filter interface (exclude a URL, noindex, `lastmod` override) and looks it up with `app.Lookup`. `sm-seo-plugin` implements it and requires Sitemap (`Requires()`); Sitemap works without SEO.
|
||||
- **D-96:** **Content plugins keep only their own fixes.** Journal gets the translated-slug fix (D-58), the H1 → H2 conversion (D-50), its schema types and the D-93 descriptors. It does not depend on the SEO plugin.
|
||||
- **D-97:** **The Nuxt side is one new shared layer** (`vue-seo-layer`, name to confirm): `<head>` from the effective-SEO API, redirect middleware, JSON-LD, breadcrumbs, the SSR build guard (D-70). Journal, menu and FAQ layers and the apps extend it.
|
||||
|
||||
### 1. SEO data model
|
||||
- **D-01 (revised by Jakub, 2026-10-25):** **Per-record SEO is owned by `sm-seo-plugin`.** A content type takes part by registering in signpost (D-93); the SEO settings switch the tab on per type, as `mpseo` did. The plugin adds a standard "SEO" tab to the type's admin form through the generic form extension (D-91) and stores the data in its one shared table keyed by (model type, record id, locale). Every plugin, present and future, gets the same tab without its own migrations, and MCP has one place to read and write. Originally recorded as a framework mechanism; moved to the plugin under D-90. — **Reversibility:** one-way — the shared table and the opt-in contract are what every content plugin builds on.
|
||||
- **D-02:** **Per-URL SEO rules** live on a separate screen, with exact URLs and patterns (e.g. `/blog?tag=*`). They cover pages with no record behind them: the home page, Nuxt pages, filter URLs. **Precedence: URL rule > record SEO > global defaults > values derived from content.** — **Reversibility:** costly — the precedence order is visible to editors and MCP clients and is baked into the effective-SEO resolver.
|
||||
- **D-03:** **Global SEO settings** contain:
|
||||
- title templates and defaults: a template such as `%title% | %site%`, a separate home-page template, the default meta description, the default OG image and the site name;
|
||||
- organisation or person data for JSON-LD (D-43);
|
||||
- search engine verification (D-05);
|
||||
- default robots per content type (D-21).
|
||||
- **D-04:** **Social tags inherit with optional overrides.** By default OG and Twitter take the title, description and image from SEO or from the content. A "Social" section in the SEO tab can override `og:title`, `og:description` and `og:image`. Twitter Card (`summary_large_image`) falls back to OG, and `twitter:site` is set in the global settings. There is no social card preview.
|
||||
- **D-05:** **Search engine verification** supports two methods:
|
||||
- meta tag codes (Google, Bing, Yandex, others), emitted on the home page;
|
||||
- verification files (name and content) served from the site root, e.g. `/google1234.html`.
|
||||
- **D-06:** **Canonical:**
|
||||
- Every page is self-canonical by default: an absolute URL, with junk parameters (utm, fbclid and similar) stripped and pagination kept.
|
||||
- Overrides are possible per record and per URL rule. An override may be relative or absolute and may point to another domain.
|
||||
- The admin warns when a canonical points to a noindex or redirected page.
|
||||
- **D-07:** **Global canonical rules use a query-parameter list.** Parameters marked as content (e.g. `page`) stay in the canonical; filter and sort parameters (e.g. `sort`, `color`) are dropped. The list can be refined per path pattern (e.g. `/katalog/*`). The same list drives the noindex of filter URLs (D-21).
|
||||
- **D-08:** **Meta robots:**
|
||||
- index/noindex and follow/nofollow switches, defaulting to "inherit";
|
||||
- an advanced section: `max-snippet`, `max-image-preview`, `max-video-preview`, `noarchive`, `nosnippet`, `noimageindex`, `unavailable_after`;
|
||||
- the same directives are also sent as an `X-Robots-Tag` header, so they work for PDFs and other files.
|
||||
- **D-09:** **Editor aids in the SEO tab:**
|
||||
- a live Google SERP preview (desktop and mobile, with pixel truncation);
|
||||
- character and pixel counters for title and description, with warnings for too long, too short, empty, and duplicates of another record;
|
||||
- a focus keyphrase with Yoast-style checks: the phrase in the title, H1, description and URL, plus text length.
|
||||
|
||||
### 2. MCP management
|
||||
- **D-10:** **The whole of SEO is manageable through MCP.** Every admin operation in this phase has an MCP tool, built on the 19.7 `pier` module: admin routes become tools under the linked admin's permissions, and read grants see only read tools. Typical use: Dawid audits a site, then tells his Claude "noindex this page, 301 that one to this one".
|
||||
- **D-11:** **Tools address pages by URL.** The server resolves the owner:
|
||||
- if a record is behind the URL, the change goes into the record's SEO tab;
|
||||
- otherwise a URL rule is created.
|
||||
|
||||
The answer says where the change was written, and the caller can force a URL rule.
|
||||
- **D-12:** **Bulk changes:**
|
||||
- Batch tools take a list of changes, e.g. 50 redirects from one audit.
|
||||
- `dry_run` returns the diff and the conflicts: redirect loops and chains, noindex on a page that is in a sitemap, a canonical pointing to a redirected page.
|
||||
- Applying a batch is all-or-nothing.
|
||||
- **D-13:** **Read and audit tools:**
|
||||
- the effective SEO of a URL, with the source of every value (URL rule, record, global or derived);
|
||||
- the site issue report (D-14);
|
||||
- CSV export and import with a preview, also in the admin;
|
||||
- a change history with author, time, and before/after values, from both the admin and MCP, with undo of one change or of a whole batch.
|
||||
- **D-14:** **The issue report combines two sources:**
|
||||
- CMS data checks: duplicate or missing titles and descriptions, conflicting rules;
|
||||
- a built-in crawler, run on demand or on a schedule, that fetches rendered pages from the sitemaps and from links. It checks status codes, H1/H2/H3, canonical, robots, JSON-LD, internal links, orphan pages, generic anchors and missing alt.
|
||||
|
||||
Results are available in the admin and over MCP. The crawler is the only way to check the Nuxt-rendered output and static frontend pages.
|
||||
- **D-15:** **One SEO permission** covers all SEO operations: meta, rules, redirects, robots.txt, settings. It is not split per area.
|
||||
|
||||
### 3. Redirects, URL normalisation, strict URLs
|
||||
- **D-16:** **Status codes: 301, 302 and 410 Gone.** No 307/308.
|
||||
- **D-17:** **Source matching:**
|
||||
- exact URLs (the default), wildcard patterns (`/old/*` → `/new/*`), and regex with capture groups;
|
||||
- options: ignore case, trailing slash, and query string (ignore it or pass it through);
|
||||
- evaluation order: exact, then patterns, then regex.
|
||||
- **D-18:** **A slug or path change creates a 301** from the old URL to the new one and flattens existing chains (A→B, then B→C becomes A→C). Deleting or unpublishing a record creates nothing: the URL returns 404 and appears in the 404 log.
|
||||
- **D-19:** **Loops are always refused**, whether they come from the admin, MCP or an import. Chains are saved with a warning and listed in the issue report.
|
||||
- **D-20:** **404 log:** URL, hit count, last hit and referer. A redirect or 410 can be created from an entry with one click or through MCP. There are no per-rule hit counters and no validity dates.
|
||||
- **D-20a:** **Where redirects execute is Claude's discretion.** The rules live in the CMS and are enforced by whatever serves the page: Nuxt Nitro middleware in a shared layer for frontend pages, Go for its own paths and for statically embedded sites.
|
||||
- **D-20b:** **URL normalisation is set per site:**
|
||||
- https always;
|
||||
- www or bare domain;
|
||||
- trailing slash or none;
|
||||
- lowercase paths;
|
||||
- double slashes, `/index.html` and similar collapse to the clean form.
|
||||
|
||||
Any other form reaches the final form in one 301 hop, never through a chain.
|
||||
- **D-20c:** **Strict URLs.** WinterCMS answered 200 to `/<any-category>/<post-slug>` because it checked only the post slug, which created duplicates. In SummerCMS every URL segment (category, parent categories, author, locale prefix) must match the record. A URL whose segments do not match a record that exists 301s to the record's canonical URL. This also covers a post moving to another category. A wrong URL never answers 200. — **Reversibility:** costly — it changes how every layer route and every Journal API lookup resolves records.
|
||||
|
||||
### 4. robots.txt and noindex policy
|
||||
- **D-21:** **Default robots per page kind** (editable per type in the global settings, and per record):
|
||||
|
||||
| Page kind | Robots |
|
||||
|---|---|
|
||||
| Login, register, password reset, every signed-in user page | noindex |
|
||||
| Internal search results | noindex,follow |
|
||||
| Filter and sort parameter URLs (D-07 list) | noindex,follow |
|
||||
| Technical pages: cart and checkout (future), draft previews, thank-you pages, 404 and error pages | noindex |
|
||||
| Tag archives | noindex,follow |
|
||||
| Author pages | index,follow (always) |
|
||||
| Pagination page 2+ | index,follow, self-referencing canonical |
|
||||
- **D-22:** **robots.txt editor:**
|
||||
- a text editor with syntax validation and a tester ("is this URL blocked for Googlebot?");
|
||||
- the `Sitemap:` line is appended automatically;
|
||||
- every non-production environment (staging, demo) always serves `Disallow: /` and `X-Robots-Tag: noindex`, whatever the stored content. — **Reversibility:** reversible — but the staging lock must never be disabled silently, since an indexed staging copy is costly to clean up.
|
||||
- **D-23:** **Private frontend pages are marked automatically.** Every route that requires sign-in gets `noindex,nofollow` and an `X-Robots-Tag` header without per-page code. Path patterns in the admin cover public pages that should not be indexed (e.g. `/konto/*`, `/logowanie`). The user plugin's auth layer marks its own pages.
|
||||
- **D-24:** **noindex, robots.txt and sitemaps stay consistent automatically.**
|
||||
- Pages that are noindex, canonicalised elsewhere or redirected drop out of the XML and HTML sitemaps.
|
||||
- The admin warns when a noindex page is blocked in robots.txt (Googlebot cannot see the noindex) and when a sitemap URL is blocked.
|
||||
- **D-25:** **AI bots:**
|
||||
- per-bot switches (GPTBot, OAI-SearchBot, ClaudeBot, Google-Extended, PerplexityBot, CCBot, Applebot-Extended and others), with AI search bots distinguished from training bots;
|
||||
- all bots allowed by default;
|
||||
- an optional `llms.txt` generated from the sitemap.
|
||||
|
||||
### 5. Sitemaps and page registry
|
||||
- **D-30:** **Sitemap index split by type:**
|
||||
- categories, tags, posts, CMS pages, and offer/service pages, each in its own sitemaps;
|
||||
- files of 1000 URLs by default, configurable up to 50 000, so roughly 20 sitemaps can be added to Google Search Console and monitored one by one;
|
||||
- stable file numbering (`sitemap-posts-1.xml`, …), sorted oldest first so new URLs land in the last file and earlier files do not shift;
|
||||
- no `priority` and no `changefreq`;
|
||||
- a real `lastmod`, from the actual content change rather than from any save of the record.
|
||||
- **D-31:** **Additional sitemaps:**
|
||||
- an image sitemap (`image:image`) with the featured image and the images in the body;
|
||||
- an optional Google News sitemap for chosen categories or types;
|
||||
- optional IndexNow, with a key generated in the admin, pinged on publish, slug change and deletion.
|
||||
- **D-32:** **The new format replaces the PHP-parity mode of `sm-sitemap-plugin`.** The PHP byte parity, priority tiers and single file are removed, and every site moves to the new format, including grzybyfunkcjonalne.pl. This is a **breaking change on a shared core plugin, explicitly chosen by the user**. It needs a new plugin version, retires the PHP parity goldens, and migrates grzyby in the same delivery. **Confirmed by Jakub on 2026-10-25**, with the remark that the split by type is more than small sites need. — **Reversibility:** one-way — sites drop the PHP format and their GSC sitemap submissions change.
|
||||
- **D-33:** **Page registry in the CMS (admin and MCP).** Each entry holds the frontend URL, a page type (page, offer, service, landing), the SEO tab and a modification date. Nuxt pages read their SEO from it, and the sitemaps group by its type. The frontend can report its routes at build time so none are missed. It replaces "CMS pages" from WinterCMS (Winter.Pages was not ported). It is not a content plugin: page content stays in the frontend. The registry lives in `sm-seo-plugin` and registers its page types in signpost, so the sitemaps list them like any other type. — **Reversibility:** costly — the registry's API is consumed by every Nuxt app.
|
||||
- **D-34:** **HTML sitemap:**
|
||||
- It lists everything indexable (no 404s, no redirected URLs, no noindex), the same set as the XML sitemaps.
|
||||
- It is linked from the footer of every page, so also from the home page.
|
||||
- Its path is set in the admin; the defaults are `/mapa-strony` (pl) and `/sitemap` (en), with locale variants.
|
||||
- The page component is provided by a Nuxt layer and can be overridden.
|
||||
|
||||
Grouping and paging are Claude's discretion: pages, offer, the category tree, posts, indexable tags, with large groups paged at about 100–200 links.
|
||||
|
||||
### 6. Pagination
|
||||
- **D-40:** **URL form is chosen per site.** The default is `?page=N`. A site may choose a path form (`/blog/strona/2`), e.g. to keep WinterCMS URLs, and the other form 301s to the configured one.
|
||||
- **D-41:** **Page 2 and later:**
|
||||
- `index,follow` with a self-referencing canonical;
|
||||
- a title suffix ("Blog – strona 2 z 14 | Site");
|
||||
- a description suffix ("Strona 2 z 14");
|
||||
- an H1 with the page number;
|
||||
- the category's long text (pillar content) appears on page 1 only.
|
||||
- **D-42:** **Mechanism:**
|
||||
- Pagination always uses numbered, server-rendered `<a href>` links.
|
||||
- "Load more" or infinite scroll is allowed only as an optional enhancement over those links, and it updates the URL to `?page=N`.
|
||||
- `<link rel="prev/next">` goes in the head.
|
||||
- `?page=1` (or `/strona/1`) 301s to the unnumbered URL. A page past the last one, and a garbage value (`?page=abc`, `-1`), return 404.
|
||||
|
||||
### 7. Structured data
|
||||
- **D-43:** **JSON-LD is one `@graph` whose nodes link by `@id`, generated automatically.** Default mapping:
|
||||
|
||||
| Page type | Schema |
|
||||
|---|---|
|
||||
| Every page | `WebPage` + `BreadcrumbList` + references to `WebSite` and the publisher |
|
||||
| Home | `WebSite` (+ `SearchAction` when the site has search) + the publisher |
|
||||
| Post | `BlogPosting` (or `Article`/`NewsArticle`): author `Person`, publisher, image, dates, `wordCount`, `articleSection` |
|
||||
| Category / tag | `CollectionPage` + `ItemList` |
|
||||
| Author | `ProfilePage` + `Person` (`sameAs`) |
|
||||
| Service / offer | `Service` (provider, `areaServed`, optional `Offer` with price) |
|
||||
| Contact | `ContactPage` + `LocalBusiness`/`Organization` with address and opening hours |
|
||||
| Page with the FAQ plugin | `FAQPage` |
|
||||
| Post with a YouTube embed | additionally `VideoObject` |
|
||||
- **D-44:** **Editor control in the SEO tab:**
|
||||
- a schema type choice, e.g. BlogPosting, NewsArticle or Article; Service or Product;
|
||||
- a field form that depends on the type, e.g. area, price and hours for Service;
|
||||
- a "custom JSON-LD" field for advanced users, validated on save and merged into the graph.
|
||||
- **D-45:** **The publisher is set in the global settings:**
|
||||
- type: `Organization`, `LocalBusiness` with a subtype (address, geo, opening hours, phone), or `Person` for personal blogs;
|
||||
- logo, `sameAs` (social profiles, Wikipedia, KRS) and contact data.
|
||||
- **D-46:** **Structured data is validated in three places:**
|
||||
- in the admin, against Google's rich-result required and recommended properties per type;
|
||||
- in the crawler, on the rendered JSON-LD;
|
||||
- through a "check in Rich Results Test" link per URL.
|
||||
|
||||
### 8. Headings
|
||||
- **D-50:** **No H1 in body content.** The editor toolbar offers H2–H4 only. Any H1 in content (pasted, imported from WinterCMS, written through MCP) is converted to H2 on save, with a notice to the editor. Today `htmlGate.ts` and bluemonday `UGCPolicy` let H1 through.
|
||||
- **D-51:** **A live heading outline in the editor** flags skipped levels, empty headings and headings that are only a link. The crawler checks the rendered pages: exactly one H1, no skipped levels, H1 consistent with the title. Nothing is rewritten silently apart from the D-50 conversion.
|
||||
- **D-52:** **One heading convention in the Nuxt layers, enforced by their tests:**
|
||||
- H1 only in the main content;
|
||||
- post cards on listings are H2;
|
||||
- sidebar and footer widgets use styled text, not content headings, so they do not disturb the outline.
|
||||
|
||||
### 9. hreflang
|
||||
- **D-55:** **hreflang is emitted in both the head and the sitemaps, from one source** (the record's locale alternates, signpost `ResolvedMenuItem.Alternates`):
|
||||
- `<link rel="alternate" hreflang>` in every page head;
|
||||
- `xhtml:link` in the XML sitemaps;
|
||||
- plus `<html lang>`, `og:locale` and `og:locale:alternate`.
|
||||
- **D-56:** **`x-default` points to the default-locale version.**
|
||||
- **D-57:** **A page without a translation has no hreflang for that locale.** Default-locale content is never served under another locale's URL.
|
||||
- **D-58:** **Fix the Journal API translated-slug gap (Claude's discretion, required for D-55).** `findPostBySlugOrID` matches only the default-locale slug, so translated slugs do not resolve today.
|
||||
|
||||
### 10. SSR guarantee
|
||||
- **D-70:** **Hard rule: indexable pages are always SSR or SSG.** `ssr: false` is allowed only on noindex routes. The Nuxt SEO layer fails the build when an indexable route has `ssr: false`. The crawler compares the raw (no-JS) HTML with the rendered HTML and reports content or links that appear only after JavaScript runs.
|
||||
- **D-71:** **Server guarantees:**
|
||||
- **Real HTTP status codes:** 404 rather than a soft-404 page with status 200, plus 410 and 301 per the rules.
|
||||
- **Links:** all navigation (menus, pagination, cards, breadcrumbs) is server-rendered `<a href>`.
|
||||
- **Content:** content in tabs, accordions and FAQs is in the HTML, only hidden by style.
|
||||
- **Images:** native `loading="lazy"` with a real `src` and `alt`, explicit dimensions, and the featured image eager with `fetchpriority`.
|
||||
- **D-72:** **`sm-bm-app`** is an internal application with no public indexable pages. It only gets noindex and `Disallow`, with no SSR migration.
|
||||
|
||||
### 11. Internal linking
|
||||
- **D-80:** **One link per post card.** Only the title is a text link. The image is clickable for users but has no separate `<a>` in the HTML (or `tabindex=-1`, `aria-hidden`), so crawlers see one link with a good anchor. Dawid first proposed linking images with `rel=nofollow`, then chose this after the note that internal nofollow is only a hint and does not conserve PageRank. Post links carry no `rel` attribute.
|
||||
- **D-81:** **No generic anchors.**
|
||||
- In layer components, the card link is the post title, and any "read more" carries the title ("Czytaj: <title>").
|
||||
- The content editor warns on links whose anchor is on an editable generic list ("kliknij tutaj", "tutaj", "więcej", "link", and the English equivalents).
|
||||
- The crawler reports such links.
|
||||
- **D-82:** **Smart internal linking:**
|
||||
- **Related posts:** 3–6, computed from tags, category and optionally the focus keyphrase, server-rendered, plus the previous and next post in the category.
|
||||
- **Phrase auto-linking:** a phrase → URL table. Only the first occurrence is linked, with at most N links per post, never to the post itself, never inside headings. Focus keyphrases can feed the table.
|
||||
- **Editor suggestions:** proposed links with counters of inbound and outbound links.
|
||||
- **Orphan report:** pages with no inbound links, with suggestions of where to link from.
|
||||
- **D-83:** **Outbound links:**
|
||||
- plain followed links by default;
|
||||
- per-link rel checkboxes in the editor: `nofollow`, `sponsored`, `ugc`;
|
||||
- a domain list that always gets nofollow or sponsored;
|
||||
- external links open with `target=_blank` and `rel=noopener`.
|
||||
|
||||
### 12. Media and breadcrumbs
|
||||
- **D-85:** **Media SEO:**
|
||||
- `alt` is required in the media manager and when inserting into content; a "decorative" checkbox gives `alt=""`;
|
||||
- SEO file names: a slug on upload, editable;
|
||||
- automatic WebP/AVIF and `srcset` widths, keeping the original;
|
||||
- a missing-alt report (CMS and crawler) and an MCP tool for bulk alt filling.
|
||||
- **D-86:** **Breadcrumbs:**
|
||||
- a visible breadcrumbs component in a Nuxt layer, rendered as `<a>` links from the same source as the `BreadcrumbList` JSON-LD;
|
||||
- on by default on every page except home, and can be disabled or restyled;
|
||||
- a post's trail goes through its primary category, selectable in the SEO tab.
|
||||
|
||||
### Planning decisions (Jakub, 2026-10-26, after research)
|
||||
- **D-98:** **Six lean plans**, in this order: D-91 form extensions; D-92 record events + D-93 descriptors + the Journal changes; sm-seo-plugin core; redirects, normalisation, strict URLs and robots.txt; the `/_seo/api/v1` management API with MCP, batch, undo and CSV, and the demo mount; unit tests and release tags last.
|
||||
- **D-99:** **robots.txt tester uses `github.com/jimsmart/grobotstxt` v1.0.3**, recorded in a decision note under `.planning/notes/` that names it.
|
||||
- **D-100:** **OG image through an `seoimage` plugin field type** that uploads the file itself (UI-SPEC element E7). D-91 extensions do not own attachments.
|
||||
- **D-101:** **Form extensions accept only the tab zone in Phase 32.** The `Zone` field is in the struct now; any other zone is a boot error.
|
||||
- **D-102:** **Journal in Phase 32 also emits record events from its `/_journal/api/v1` write handlers and gains a `journal-tag` menu item type**, so MCP slug changes create 301s and tags get the SEO tab.
|
||||
- **D-103:** **Phase 32 delivers the redirect decision endpoint and the verification-file API only.** The Nuxt layer enforces redirects and maps verification files at the root in Phase 33; no fourth framework seam.
|
||||
- **D-104:** **The SEO settings screen is an `AdminSingleton` controller linked from a settings tile** (`SettingsItem.Controller`), with its per-type tabs added through D-91 on itself.
|
||||
- **D-105:** **`Claude-User` joins the AI bot list** (D-25).
|
||||
- **D-106 (Jakub, 2026-10-26):** **The framework release is a patch tag (next v0.5.x, v0.5.1 today), not v0.6.** The seams are strictly additive: no breaking change to existing framework API, and existing plugins build and behave the same without edits. The exact number is read from `git tag` at release time. The `sm-seo-plugin` repo was created on 2026-10-26 with `tea`, the CLI for any new repo on git.golem15.com.
|
||||
|
||||
### Claude's Discretion
|
||||
- Where redirects execute (D-20a), HTML sitemap grouping and paging (D-34), the Journal translated-slug fix (D-58).
|
||||
- Table and package names inside the plugins, and the exact Go shape of the three seams (D-91 to D-93). The seams go into the existing `pact`, `cabana` and `signpost` modules; no new framework module is planned.
|
||||
- How the frontend fetches effective SEO: one resolver endpoint per URL, cached and purged through the existing site-cache purge.
|
||||
- Crawler implementation (Go, in-process job via `conga`/River, politeness limits).
|
||||
|
||||
</decisions>
|
||||
|
||||
<canonical_refs>
|
||||
## Canonical References
|
||||
|
||||
**Downstream agents MUST read these before planning or implementing.**
|
||||
|
||||
### Prior phase decisions this phase builds on
|
||||
- `.planning/phases/16-grzybyfunkcjonalne-pl-on-reusable-blog-views/16-CONTEXT.md`: D-02 Nuxt layers, D-07 SSR with swr/ISR, D-13 `@nuxtjs/seo` per-post meta (partly reversed by 17 D-15), D-15 URLs kept identical (one-way, now protected by D-20c and redirects).
|
||||
- `.planning/phases/17-blog-companions/17-CONTEXT.md`: D-01 to D-03 the signpost menu-item-type registry, URL patterns and per-locale alternates (source for sitemaps, hreflang and breadcrumbs); D-11 to D-15 sitemap plugin behaviour that D-32 replaces.
|
||||
- `.planning/phases/19.7-generic-mcp-module/19.7-CONTEXT.md`: the `pier` MCP module, tools bound to admin routes, read/write grant ceilings (basis for D-10 to D-13).
|
||||
|
||||
### Code seams
|
||||
- `modules/pact/capabilities.go`: `HasSettings`/`SettingsItem` (~719-744), `MenuItemType`/`ResolvedMenuItem.Alternates` (~797-856), `AdminSingleton`.
|
||||
- `modules/pact/README.md`: the list of form hooks; `HasAdminActionExtensions` (~149) is the only cross-plugin admin hook today.
|
||||
- `modules/pact/capabilities.go`: `AdminActionExtension`/`HasAdminActionExtensions` (~429-439), the struct D-91 extends.
|
||||
- `modules/cabana/field_ml.go`: `TranslationWriter` and translatable field types (pattern for locale-keyed SEO data).
|
||||
- `modules/cabana/settings.go`: settings form compilation.
|
||||
- `modules/signpost/signpost.go`: the registry (`Activate`, `Resolve`).
|
||||
- `modules/boardwalk/boardwalk.go:177`: the existing `X-Robots-Tag` on admin responses.
|
||||
- `../sm-sitemap-plugin/`: `classes/generator.go`, `classes/serialize.go` (hreflang output), `routes.go`, `admin.go`, `models/settings.go`.
|
||||
- `../sm-journal-plugin/`: `models/post.go` (hidden `metadata` jsonb), `controllers/api/posts.go` (`serializePost`), `controllers/api/posts_helpers.go` (`findPostBySlugOrID`, default-locale slug only), `classes/format_html.go` (bluemonday UGCPolicy, allows h1), `classes/menu_item_types.go`.
|
||||
- `../sm-translate-plugin/classes/translator.go`: locale prefix and resolution.
|
||||
- `../vue-journal-layer/`: `nuxt.config.ts` (`@nuxtjs/seo`, `canonicalQueryWhitelist`, sitemap source), `app/utils/seo.ts`, `app/components/Journal/Pagination.vue`, `app/journal-pages/*.vue`, `app/utils/htmlGate.ts`.
|
||||
- Apps: `../sm-grzybyfunkcjonalne-app/vue-grzybyfunkcjonalne-app/nuxt.config.ts` (robots and sitemap config, swr), `../sm-demo-app/vue-demo-app/` (hand-written noindex on login and similar pages), `../sm-summercmsio-app/vue-summercmsio-app` (nuxt generate).
|
||||
|
||||
### Reference implementations
|
||||
- `/media/nvme/dev/pxpx/!depreciated/frankly6/plugins/pixelpixel/mpseo`: the PixelPixel `mpseo` WinterCMS plugin, the pattern for D-90. Read `Plugin.php`, `classes/SeoInjectorManager.php` (`extend()`, `resolveExtensionOptions()`), `classes/SeoEntryRepository.php`, `classes/GenerateSeoEntriesJob.php`, `models/Entry.php`, `models/SeoSettings.php`, `components/SeoInjector.php`, `formwidgets/GoogleResultPreview.php`. A registering plugin: `/media/nvme/dev/pxpx/MOTOGAMERS/plugins/pixelpixel/blog/Plugin.php` (~340-420, `seoinjection.extend`).
|
||||
- `../examples/golem15-wintercms-starter/plugins/winter/pages/classes/page/fields.yaml`: WinterCMS `viewBag[meta_title]`/`meta_description` (the per-page SEO tab this phase improves on).
|
||||
|
||||
</canonical_refs>
|
||||
|
||||
<code_context>
|
||||
## Existing Code Insights
|
||||
|
||||
### Reusable Assets
|
||||
- **signpost registry:** resolves record URLs and per-locale alternates. It is the natural source for the owner of a URL (D-11), strict-URL checks (D-20c), sitemaps (D-30), hreflang (D-55) and breadcrumbs (D-86).
|
||||
- **19.7 `pier`:** exposes admin routes as MCP tools under the linked admin's permissions. SEO admin routes become tools without a separate API (D-10).
|
||||
- **`pact.HasSettings`:** singleton settings forms for the global SEO settings.
|
||||
- **cabana translatable fields:** a pattern for locale-keyed SEO values.
|
||||
- **Site-cache purge** (`POST /api/__site__/cache/purge`, shared by the layers): the way to invalidate rendered pages after SEO changes.
|
||||
- **`conga` (River jobs):** for the crawler, IndexNow pings and sitemap rebuilds.
|
||||
|
||||
### Established Patterns
|
||||
- **Compiled plugins and capability interfaces** (`pact.Has*`). The form extension seam (D-91) follows this pattern.
|
||||
- **Nuxt layers** distributed as pnpm git dependencies pinned by tag, with overridable components. SEO rendering and the SSR guard belong in a layer that apps extend.
|
||||
- **The layers already render SSR.** `?page=N` pagination with canonical whitelisting exists; `rel=prev/next` is only on `<a>` links.
|
||||
|
||||
### Integration Points
|
||||
- **cabana form compilation:** needs the generic form extension with placement (D-91) and record events (D-92). Nothing like either exists today.
|
||||
- **Journal plugin:** adds the D-93 descriptors to its Post, Category and Tag types, gets the translated-slug fix and the H1 → H2 conversion, and registers its schema types. It does not import the SEO plugin.
|
||||
- **`sm-seo-plugin`:** new repo, mounted as a submodule at `plugins/golem15/seo` in the apps.
|
||||
- **sm-sitemap-plugin:** rewritten to the split index (breaking, D-32).
|
||||
- **Nuxt layers:** journal, menu and FAQ consume effective SEO, JSON-LD, breadcrumbs and the redirect middleware; the user plugin's auth pages get noindex.
|
||||
- **Applications:** grzybyfunkcjonalne (sitemap migration and robots move from Nuxt to the CMS), demo, summercms.io, and Płytarium, the likely first consumer.
|
||||
|
||||
</code_context>
|
||||
|
||||
<specifics>
|
||||
## Specific Ideas
|
||||
|
||||
- Dawid's audit workflow is the reference use case for MCP. After an audit he tells his own Claude client "this page noindex, that one 301 to this", and it happens through MCP with a dry-run preview.
|
||||
- The WinterCMS bug to never repeat: `/<category>/<post>` answered 200 for any category segment (D-20c).
|
||||
- Monitoring in GSC sitemap by sitemap is why the files are split by type and batched at 1000 (D-30).
|
||||
- WinterCMS had a per-entry SEO tab plus a global SEO tab. SummerCMS keeps that shape and goes further (precedence rules, MCP, audit, structured data).
|
||||
- The first site on SummerCMS is likely Płytarium, but the features are framework-wide and must not be shaped around one site.
|
||||
|
||||
</specifics>
|
||||
|
||||
<deferred>
|
||||
## Deferred Ideas
|
||||
|
||||
- **Social card preview** (Facebook/LinkedIn/X) in the SEO tab: offered, not chosen.
|
||||
- **Per-redirect hit counters and validity dates:** offered, not chosen.
|
||||
- **307/308 redirects:** not chosen.
|
||||
- **E-commerce structured data** (Product, offers on category pages): no shops yet.
|
||||
|
||||
### Reviewed Todos (not folded)
|
||||
- `sitemap-xslt-browser-deprecation.md` (g15office w8kupqi3): replace the browser XSLT view of `/sitemap.xml`. The user chose to keep it as a separate backlog task. The D-32 rewrite of the sitemap plugin touches the same code, so the planner should note that the XSL output may be removed or kept there.
|
||||
- `sitemap-plugin-port.md`: stale. The port was delivered in Phase 17 and should be closed separately.
|
||||
|
||||
</deferred>
|
||||
|
||||
---
|
||||
|
||||
*Phase: 32-seo-foundation*
|
||||
*Context gathered: 2026-10-24*
|
||||
157
.planning/phases/32-seo-foundation/32-DECISIONS-MAP.md
Normal file
157
.planning/phases/32-seo-foundation/32-DECISIONS-MAP.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# Phase 32: decision map
|
||||
|
||||
Every decision in `32-CONTEXT.md` (D-01 to D-106, with D-20a, D-20b and D-20c, and Q-01), mapped to the Phase 32 plan and task that implements it, or deferred to Phase 33 ("SEO output, audit and content", Q-01). A decision with entries in both columns is split: Phase 32 delivers the part named in the first column, and Phase 33 delivers the rest. IDs that do not appear here (D-26 to D-29, D-35 to D-39, D-47 to D-49, D-53, D-54, D-59 to D-69, D-73 to D-79, D-84, D-87 to D-89) do not exist in CONTEXT.md.
|
||||
|
||||
Plan references use `plan/Tn` (for example `32-03/T2` is plan 32-03, Task 2). Plan 32-06 cites the Phase 33 column in its objective ("Phase 33 boundary") and checks in its verification that every CONTEXT.md decision appears in this file.
|
||||
|
||||
## Code layout and seams
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-90 | The framework carries no SEO code; SEO lives in two shared plugins | 32-01, 32-02 (neutral seams, neutral docs); 32-05/T4 (`marker` gate stage); 32-06/T1, T5 (`--all` green) | — |
|
||||
| D-91 | Cross-plugin admin form extensions with Before/After placement | 32-01/T1 to T4 (seam, boot errors, docs, SPA backstop); used by 32-03/T1, T2, T5 and 32-04/T2; 32-06/T2 (unit matrix) | — |
|
||||
| D-92 | Record events from cabana | 32-02/T1 to T3; used by 32-03/T3 (cleanup) and 32-04/T2 (address change after commit); 32-06/T2 (diff tests) | — |
|
||||
| D-93 | Content descriptors in signpost | 32-02/T1, T2, T4; used by 32-03/T1 to T3; 32-06/T2, T3 | Sitemaps and the page registry consume `Records` (D-30, D-33) |
|
||||
| D-94 | `sm-seo-plugin` scope | 32-03 (models, SEO tab, settings, resolver, generation job, cleanup, preview/placeholder/revision widgets); 32-04 (redirects, 404 log, robots.txt, verification API, redirect decision); 32-05 (MCP, CSV, issue report) | Page registry, llms.txt, JSON-LD `@graph` and breadcrumbs APIs, crawler |
|
||||
| D-95 | `sm-sitemap-plugin` with its own filter interface that SEO implements | — (`Requires()` stays empty in 32-03) | Whole decision, with the sitemap rewrite |
|
||||
| D-96 | Content plugins keep only their own fixes (Journal) | 32-02/T4 (Journal descriptors, journal-tag type, D-58 fix) | H1 to H2 conversion (D-50), Journal schema types (D-43) |
|
||||
| D-97 | One shared Nuxt SEO layer | — | Whole decision |
|
||||
| D-98 | Six lean plans in a fixed order | 32-01 to 32-06 (this plan set) | — |
|
||||
| D-99 | robots.txt tester on `github.com/jimsmart/grobotstxt` v1.0.3 with a decision note | 32-03/T4 (legitimacy checkpoint); 32-04/T4 (install, tester, decision note, STACK row); 32-06/T3 (Google examples test) | — |
|
||||
| D-100 | OG image through an `seoimage` field type; extensions own no attachments | 32-01/T3 (fileupload extension fields refused); 32-03/T5 (`seoimage`, E7) | — |
|
||||
| D-101 | Form extensions accept only the tab zone | 32-01/T1 to T3 (`Zone` field, other zones are boot errors) | — |
|
||||
| D-102 | Journal API emits record events; `journal-tag` type | 32-02/T3 (API emission), 32-02/T4 (journal-tag); 32-04/T2 (listener for writes outside the admin) | — |
|
||||
| D-103 | Redirect decision endpoint and verification-file API only | 32-04/T3 (decision in resolve), 32-04/T4 (verification API) | Layer enforcement of redirects and root mapping of verification files |
|
||||
| D-104 | SEO settings as an `AdminSingleton` linked from a settings tile, per-type tabs through D-91 | 32-01 (generated fields declared in Go, P-01); 32-03/T2 | — |
|
||||
| D-105 | `Claude-User` joins the AI bot list | 32-04/T4 | — |
|
||||
| D-106 | Patch release (next v0.5.x), strictly additive seams; `sm-seo-plugin` repo created with `tea` | 32-01, 32-02 (additive truths); 32-03/T1 (clones the existing repo, P-12); 32-06/T1 (`additive` stage on API surfaces, `compat` stage), 32-06/T4, T5 (patch tag computed at release) | — |
|
||||
|
||||
## 1. SEO data model
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-01 | Per-record SEO owned by the plugin, one table keyed by (model type, record id, locale), tab switched on per type | 32-03/T1 (entries table, SEO tab), 32-03/T2 (inject switch per type) | — |
|
||||
| D-02 | Per-URL rules; precedence URL rule > record > global > derived | 32-03/T2 (rules screen, resolver P-14) | — |
|
||||
| D-03 | Global settings: templates, defaults, organisation data, verification, robots per type | 32-03/T2 (templates, default description and image, site name, verification, per-type robots) | Organisation or person data for JSON-LD (with D-43, D-45) |
|
||||
| D-04 | Social tags inherit, optional overrides, `twitter:site` | 32-03/T2 (resolver OG and Twitter values), 32-03/T5 (Social fields) | — |
|
||||
| D-05 | Search engine verification: meta codes and files | 32-03/T2 (settings, meta on the home path), 32-04/T4 (`/_seo/api/v1/verification/{name}`) | Serving the files at the site root from the layer (D-103) |
|
||||
| D-06 | Canonical: self-referencing absolute, overrides, warnings | 32-03/T2 (builder, overrides), 32-03/T5 (P1 canonical-to-noindex callout), 32-04/T3 (canonical-redirected callout), 32-05/T2, T3 (issues, batch conflicts) | — |
|
||||
| D-07 | Query-parameter list with path refinement; drives filter-URL noindex | 32-03/T2 (`classes/urls.go`) | — |
|
||||
| D-08 | Meta robots switches, advanced directives, `X-Robots-Tag` | 32-03/T2 (value grammar, `x_robots_tag` in resolve), 32-03/T5 (E2), 32-04/T4 (header on robots.txt and API answers); 32-06/T3 | Sending the header on frontend-rendered pages and files (layer, D-97) |
|
||||
| D-09 | SERP preview, counters, keyphrase checks | 32-03/T5 (E1, E3); 32-06/T3 (element backstops) | — |
|
||||
|
||||
## 2. MCP management
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-10 | The whole of SEO is manageable through MCP on `pier` | 32-05/T1, T2 (one tool per admin operation, parity test) | Tools for the crawler and the other Phase 33 screens |
|
||||
| D-11 | Tools address pages by URL; owner resolution | 32-02/T4 (`MatchPath`), 32-05/T1 (`classes/owner.go`) | — |
|
||||
| D-12 | Batch tools, `dry_run` with conflicts, all-or-nothing | 32-05/T3 | "Noindex on a page in a sitemap" refined by the D-95 filter |
|
||||
| D-13 | Read and audit tools: effective SEO with sources, CSV, history with undo | 32-03/T2 (value sources), 32-03/T3 (history core), 32-05/T2 (read tools), 32-05/T3 (undo, CSV, E6) | — |
|
||||
| D-14 | Issue report: CMS data checks plus a crawler | 32-05/T2 (CMS data checks) | The built-in crawler and its checks |
|
||||
| D-15 | One SEO permission | 32-03/T2, 32-05/T1, T2 | — |
|
||||
|
||||
## 3. Redirects, URL normalisation, strict URLs
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-16 | 301, 302 and 410 | 32-04/T2 | — |
|
||||
| D-17 | Exact, wildcard and regex sources; options; evaluation order | 32-04/T2 | — |
|
||||
| D-18 | Slug or path change creates a 301 and flattens chains; delete or unpublish creates nothing | 32-02/T2, T3 (events carry the change), 32-04/T1 (admin path), 32-04/T2 (other writers) | — |
|
||||
| D-19 | Loops always refused; chains saved with a warning | 32-04/T2 (admin), 32-05/T2, T3 (MCP, import, issue report) | — |
|
||||
| D-20 | 404 log with one-click redirect or 410 | 32-04/T2 (log, report endpoint, actions), 32-05/T2 (tools) | The layer's call to the report endpoint |
|
||||
| D-20a | Where redirects execute (discretion) | 32-04/T3 (decision endpoint, Go-served paths) | Nitro middleware in the layer (D-97, D-103) |
|
||||
| D-20b | URL normalisation per site | 32-03/T2 (Addresses settings), 32-04/T3 (`Normalize`, one hop) | Enforcement on frontend routes through the layer |
|
||||
| D-20c | Strict URLs | 32-02/T4 (`Match` with `Exact`), 32-04/T3 (strict 301); 32-05/T4 (route drift check) | Layer routes reading their patterns from the CMS |
|
||||
|
||||
## 4. robots.txt and noindex policy
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-21 | Default robots per page kind | 32-03/T2 (per-type defaults, never-indexed and search paths, filter-parameter URLs) | Pagination page 2+ (D-41) and signed-in routes (D-23) in the layer |
|
||||
| D-22 | robots.txt editor, validation, tester, `Sitemap:` line, non-production lock | 32-03/T2 (lock in resolve), 32-04/T4 (editor, tester, served file, lock); 32-06/T3 | The `Sitemap:` default moves to the D-30 index |
|
||||
| D-23 | Private frontend pages marked noindex automatically | 32-03/T2 (path patterns in the admin, applied by the resolver) | Automatic marking of signed-in routes in the layer and the user plugin's auth layer |
|
||||
| D-24 | noindex, robots.txt and sitemaps stay consistent | 32-04/T4 (warning when robots.txt blocks a noindex URL), 32-05/T2, T3 (issues, batch conflict) | Noindex, canonicalised and redirected pages leave the sitemaps; "sitemap URL blocked" warning |
|
||||
| D-25 | AI bot switches; optional llms.txt | 32-04/T4 (switches); 32-06/T3 | llms.txt generated from the sitemap |
|
||||
|
||||
## 5. Sitemaps and page registry
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-30 | Sitemap index split by type, 1000-URL files, real `lastmod` | — | Whole decision |
|
||||
| D-31 | Image, News sitemaps, IndexNow | — | Whole decision |
|
||||
| D-32 | The new format replaces PHP parity (breaking, confirmed) | — | Whole decision; the XSLT todo stays with it |
|
||||
| D-33 | Page registry in the CMS | — | Whole decision |
|
||||
| D-34 | HTML sitemap | — | Whole decision |
|
||||
|
||||
## 6. Pagination
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-40 | URL form chosen per site | — | Whole decision |
|
||||
| D-41 | Page 2 and later: robots, suffixes, H1, pillar text | — (the canonical already keeps the `page` parameter, 32-03/T2) | Whole decision |
|
||||
| D-42 | Numbered server-rendered links, rel prev/next, 301 and 404 rules | — | Whole decision |
|
||||
|
||||
## 7. Structured data
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-43 | One JSON-LD `@graph` | — (room: the entry's `data` jsonb, 32-03/T1) | Whole decision |
|
||||
| D-44 | Schema type, type-dependent fields, custom JSON-LD | — (room: reserved SEO tab anchors `seo_robots`, `seo_og_image`, 32-03/T5) | Whole decision |
|
||||
| D-45 | Publisher in the global settings | — | Whole decision |
|
||||
| D-46 | Validation in admin, crawler and Rich Results link | — | Whole decision |
|
||||
|
||||
## 8. Headings
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-50 | No H1 in body content | — | Whole decision, including Journal's conversion (D-96) |
|
||||
| D-51 | Live heading outline and crawler checks | — | Whole decision |
|
||||
| D-52 | One heading convention in the layers | — | Whole decision |
|
||||
|
||||
## 9. hreflang
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-55 | hreflang in head and sitemaps from one source | — | Whole decision |
|
||||
| D-56 | `x-default` points to the default locale | — | Whole decision |
|
||||
| D-57 | No hreflang for a missing translation | — | Whole decision |
|
||||
| D-58 | Journal API translated-slug fix | 32-02/T4; 32-06/T3 (`TestTranslatedSlug`) | — |
|
||||
|
||||
## 10. SSR guarantee
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-70 | Indexable pages always SSR or SSG; build guard; raw versus rendered check | — | Whole decision |
|
||||
| D-71 | Real status codes, server-rendered links, content in HTML, image rules | — (the resolve answer already returns real `not_found`, `redirect` and `gone` decisions, 32-03, 32-04) | Whole decision |
|
||||
| D-72 | `sm-bm-app` gets noindex and `Disallow` only | — | Whole decision |
|
||||
|
||||
## 11. Internal linking
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-80 | One link per post card | — | Whole decision |
|
||||
| D-81 | No generic anchors | — | Whole decision |
|
||||
| D-82 | Related posts, phrase auto-linking, suggestions, orphan report | — | Whole decision |
|
||||
| D-83 | Outbound link rules | — | Whole decision |
|
||||
|
||||
## 12. Media and breadcrumbs
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| D-85 | Media SEO | — | Whole decision |
|
||||
| D-86 | Breadcrumbs component and primary category | — | Whole decision |
|
||||
|
||||
## Phase split
|
||||
|
||||
| ID | Decision | Phase 32 | Phase 33 |
|
||||
|----|----------|----------|----------|
|
||||
| Q-01 | Two phases; Phase 33 builds on the Phase 32 framework tag | 32-06/T4, T5 (the patch tag); this map's Phase 33 column is the boundary | Builds on the tag, not on a `replace` |
|
||||
|
||||
## Claude's discretion items
|
||||
|
||||
- Where redirects execute (D-20a), the translated-slug fix (D-58): as above. HTML sitemap grouping (D-34): Phase 33.
|
||||
- Table and package names: 32-03 P-12, P-13; 32-04 P-18 to P-23; 32-05 P-24 to P-28.
|
||||
- Exact Go shapes of the seams: 32-01/T1 and 32-02/T1 (blocking decision checkpoints).
|
||||
- Effective SEO fetched through one resolver endpoint per URL: 32-03/T1, T2 (P-15). Purging the site cache after SEO writes is not a Phase 32 task step; it pays off once the Phase 33 layer caches the resolve answer, so Phase 33 planning should pick it up with D-97.
|
||||
- Crawler implementation: Phase 33 (D-14).
|
||||
448
.planning/phases/32-seo-foundation/32-DISCUSSION-LOG.md
Normal file
448
.planning/phases/32-seo-foundation/32-DISCUSSION-LOG.md
Normal file
@@ -0,0 +1,448 @@
|
||||
# Phase 32: SEO foundation - Discussion Log
|
||||
|
||||
> **Audit trail only.** Do not use as input to planning, research, or execution agents.
|
||||
> Decisions are captured in CONTEXT.md — this log preserves the alternatives considered.
|
||||
|
||||
**Date:** 2026-10-24
|
||||
**Phase:** 32-seo-foundation
|
||||
**Participant:** Dawid (SEO specialist, delegated by Jakub); discussion held in Polish, recorded in English
|
||||
**Areas discussed:** 1. SEO data model, 2. MCP management, 3. Redirects, 4. robots.txt and noindex policy, 5. Sitemaps (XML boost, HTML sitemap), 6. Pagination, 7. Structured data per page type, 8. Heading structure, 9. hreflang basics, 10. SSR guarantee, 11. Internal linking (added by user), 12. URL normalisation, AI bots, media, breadcrumbs (added)
|
||||
|
||||
---
|
||||
|
||||
## Requirements stated by the user up front
|
||||
|
||||
- Per-record SEO tab plus global SEO settings, like WinterCMS, but better suited to search optimisation
|
||||
- Journal records need meta title, meta description, canonical and meta robots
|
||||
- Twitter Card besides Open Graph
|
||||
- The whole of SEO must be manageable through MCP (e.g. after an audit: noindex this page, 301 that one to another)
|
||||
- Structured data differs per page type: article, home page, service pages; no e-commerce yet
|
||||
- HTML sitemap by default, linked from the home page
|
||||
- Redirects 301 and 302; robots.txt editable in the admin
|
||||
- Correct heading hierarchy: H1 first, then H2, nested H3
|
||||
- noindex on filter pages, login and all signed-in user pages
|
||||
- SSR so Googlebot sees all content and links
|
||||
- (later) The whole of SEO must be manageable through MCP
|
||||
- (later) Internal linking without generic anchors; smart default internal linking
|
||||
- (later) No WinterCMS-style relative-URL duplicates (/<any-category>/<post> answering 200)
|
||||
|
||||
---
|
||||
|
||||
## 1. SEO data model
|
||||
|
||||
**Q: Where per-record SEO lives**
|
||||
|
||||
Options presented: Framework mechanism; Columns on each model; Per-URL only
|
||||
|
||||
**User's choice:** Framework mechanism: a model opts in with one declaration; the framework adds a standard SEO tab and stores the data in one shared table keyed by (model type, record id, locale)
|
||||
|
||||
**Q: Per-URL override screen and precedence**
|
||||
|
||||
Options presented: URL > record > global; record > URL > global; No, record + global only
|
||||
|
||||
**User's choice:** Yes, with patterns; precedence URL rule > record SEO > global defaults > values derived from content
|
||||
|
||||
**Q: Global SEO settings contents**
|
||||
|
||||
Options presented: Title templates and defaults; Organisation/person data; Verification codes; Default robots per type
|
||||
|
||||
**User's choice:** All four: title templates and defaults (incl. home page template, default description, default OG image, site name); organisation/person data for JSON-LD; search engine verification codes; default robots per content type
|
||||
|
||||
**Q: Social tags**
|
||||
|
||||
Options presented: Inherit + optional override; Separate OG and Twitter fields; Automatic only
|
||||
|
||||
**User's choice:** Inherit from SEO/content with optional overrides of og:title, og:description, og:image; Twitter Card summary_large_image falls back to OG; twitter:site in global settings
|
||||
|
||||
**Q: Search engine verification**
|
||||
|
||||
Options presented: Meta tag + file; Meta tag only
|
||||
|
||||
**User's choice:** Meta tag codes (Google, Bing, Yandex, others) plus verification files (name + content) served from the site root
|
||||
|
||||
**Q: Canonical default and override**
|
||||
|
||||
Options presented: Auto self + override; Manual only
|
||||
|
||||
**User's choice:** Every page self-canonical by default (absolute, junk parameters stripped, pagination kept); field override per record and per URL rule; plus global canonical rules for filters and catalogs
|
||||
|
||||
**Q: Global canonical rules model**
|
||||
|
||||
Options presented: Parameter list; Pattern -> canonical rules; Both
|
||||
|
||||
**User's choice:** Query parameter list: parameters marked as content (e.g. page) stay in the canonical, filter/sort parameters are dropped; refinable per path pattern (e.g. /katalog/*)
|
||||
|
||||
**Q: Meta robots granularity**
|
||||
|
||||
Options presented: Index/follow + advanced; Index/follow only
|
||||
|
||||
**User's choice:** index/noindex and follow/nofollow with 'inherit' as default, plus advanced: max-snippet, max-image-preview, max-video-preview, noarchive, nosnippet, noimageindex, unavailable_after; same directives also as X-Robots-Tag header (works for PDFs and files)
|
||||
|
||||
**Q: Editor aids in the SEO tab**
|
||||
|
||||
Options presented: SERP preview; Counters and warnings; Social card preview; Focus keyphrase and analysis
|
||||
|
||||
**User's choice:** Live Google SERP preview (desktop/mobile, pixel truncation); character and pixel counters with warnings (too long/short, empty, duplicate title/description); focus keyphrase with Yoast-style checks (phrase in title, H1, description, URL; text length). Social card preview not wanted.
|
||||
|
||||
---
|
||||
|
||||
## 2. MCP management
|
||||
|
||||
**Q: How MCP tools address a page**
|
||||
|
||||
Options presented: By URL, server resolves owner; Always URL rule; By record ID
|
||||
|
||||
**User's choice:** By URL from the audit; the server resolves the owner: a record behind the URL gets the change in its SEO tab, otherwise a URL rule is created; the answer says where it was written; a URL rule can be forced
|
||||
|
||||
**Q: Bulk operations and safety**
|
||||
|
||||
Options presented: Batch + dry run; Batch without preview; Single calls
|
||||
|
||||
**User's choice:** Batch tools taking a list of changes, with dry_run returning the diff and conflicts (redirect loops/chains, noindex on a sitemap page, canonical to a redirected page); apply is all-or-nothing
|
||||
|
||||
**Q: Read and audit tools**
|
||||
|
||||
Options presented: Effective SEO of a URL; Site issue report; CSV export/import; History and undo
|
||||
|
||||
**User's choice:** All four: effective SEO of a URL with the source of every value; site issue report; CSV export/import with preview (also in the admin); change history with author/time/before/after and undo of one change or a whole batch
|
||||
|
||||
**Q: SEO permissions**
|
||||
|
||||
Options presented: Separate per area; One SEO permission
|
||||
|
||||
**User's choice:** One SEO permission for everything (not split per area)
|
||||
|
||||
**Q: What the issue report is based on**
|
||||
|
||||
Options presented: CMS data + crawler; CMS data only; Crawler in a separate phase
|
||||
|
||||
**User's choice:** CMS data checks plus a built-in crawler (on demand or scheduled) fetching rendered pages from the sitemap and links: status codes, H1/H2/H3, canonical, robots, JSON-LD, internal links, orphan pages; results in the admin and over MCP
|
||||
|
||||
---
|
||||
|
||||
## 3. Redirects
|
||||
|
||||
**Q: Status codes**
|
||||
|
||||
Options presented: 301,302,307,308+410; 301 and 302 only; 301,302+410
|
||||
|
||||
**User's choice:** 301, 302 and 410 Gone (no 307/308)
|
||||
|
||||
**Q: Source matching**
|
||||
|
||||
Options presented: Exact + patterns + regex; Exact + patterns; Exact only
|
||||
|
||||
**User's choice:** Exact (default), wildcard patterns (/old/* -> /new/*) and regex with capture groups; options: ignore case, trailing slash, query string (ignore or pass through); evaluation order exact, then patterns, then regex
|
||||
|
||||
**Q: Automatic redirects**
|
||||
|
||||
Options presented: Slug change -> 301; Deletion -> choice; Loop protection
|
||||
|
||||
**User's choice:** Slug/path change of a record creates a 301 from the old URL and flattens existing chains. Not chosen: asking on deletion
|
||||
|
||||
**Q: Loops and chains**
|
||||
|
||||
Options presented: Block loops, warn on chains; Block loops and chains; Report only
|
||||
|
||||
**User's choice:** Loops always refused (admin, MCP, import); chains saved with a warning and listed in the issue report
|
||||
|
||||
**Q: Deleted or unpublished record without a choice**
|
||||
|
||||
Options presented: 404 + 404 log; Automatic 410; Automatic 301 to parent
|
||||
|
||||
**User's choice:** Plain 404, and the URL shows up in the 404 log; no automatic 410 or 301
|
||||
|
||||
**Q: Monitoring**
|
||||
|
||||
Options presented: 404 log; Rule hit counter; Validity dates
|
||||
|
||||
**User's choice:** 404 log (hits, last hit, referer) with one-click/MCP redirect creation. Not chosen: per-rule hit counters, validity dates
|
||||
|
||||
---
|
||||
|
||||
## 4. robots.txt and noindex policy
|
||||
|
||||
**Q: robots.txt editing**
|
||||
|
||||
Options presented: Editor + auto parts + staging lock; Plain editor; Structured rules form
|
||||
|
||||
**User's choice:** Text editor with syntax validation and a tester ('is this URL blocked for Googlebot?'); the Sitemap: line is appended automatically; every non-production environment always serves Disallow: / and X-Robots-Tag: noindex regardless of the content
|
||||
|
||||
**Q: Default robots per page kind**
|
||||
|
||||
Options presented: Search results; Filters and sorting; Tags and authors; Technical pages
|
||||
|
||||
**User's choice:** noindex: login, register, password reset, all signed-in user pages, internal search results (noindex,follow), filter/sort parameter URLs (noindex,follow), technical pages (cart/checkout later, draft previews, thank-you pages, 404/errors). Tags: noindex,follow by default. Authors: always index,follow. Pagination (e.g. blog page 2+): always index,follow with a self-referencing canonical.
|
||||
|
||||
**Q: How the frontend knows a page is private**
|
||||
|
||||
Options presented: Auto from auth + admin patterns; Admin patterns only; By hand in code
|
||||
|
||||
**User's choice:** Automatic for every route that requires sign-in (noindex,nofollow + X-Robots-Tag) plus path patterns in the admin for public but non-indexable pages; the user plugin's auth layer marks its own pages
|
||||
|
||||
**Q: Consistency of noindex, robots.txt and sitemaps**
|
||||
|
||||
Options presented: Automatic; Warnings only
|
||||
|
||||
**User's choice:** Automatic: pages with noindex, a canonical elsewhere or a redirect drop out of the XML and HTML sitemaps; warnings when a noindex page is blocked in robots.txt and when a sitemap URL is blocked
|
||||
|
||||
---
|
||||
|
||||
## 5. Sitemaps (XML boost, HTML sitemap)
|
||||
|
||||
**Q: User's sitemap idea**
|
||||
|
||||
Options presented: free text after 6 proposals
|
||||
|
||||
**User's choice:** Sitemap index split by type: categories, tags, posts, CMS pages, and offer/service pages separately; each type batched in files of 1000 URLs so ~20 sitemaps can be added to GSC and monitored one by one; no priority and no changefreq. Also accepted: real lastmod from the actual content change, image sitemap (featured image + images in the body), Google News sitemap, IndexNow, HTML sitemap generated from the same source
|
||||
|
||||
**Q: Existing sm-sitemap-plugin (PHP byte parity, priority tiers, single file)**
|
||||
|
||||
Options presented: Extend, PHP mode as legacy switch; New mode replaces old; New SEO plugin, old untouched
|
||||
|
||||
**User's choice:** New mode replaces the old one: PHP parity removed, every site moves to the new format including grzybyfunkcjonalne. BREAKING change on a shared core plugin, explicitly chosen by the user: new plugin version, grzyby migrated in the same phase, parity goldens retired
|
||||
|
||||
**Q: Where CMS and offer/service pages come from (Nuxt pages the backend does not know)**
|
||||
|
||||
Options presented: Page registry in CMS; Pages plugin in a later phase; Manual sitemap URLs only
|
||||
|
||||
**User's choice:** A page registry in the CMS (admin + MCP): frontend URL, page type (page, offer, service, landing), SEO tab, modification date; Nuxt pages read their SEO from it; sitemaps group by type; the frontend can report its routes at build time so none are missed
|
||||
|
||||
**Q: Batch size**
|
||||
|
||||
Options presented: 1000, configurable; Fixed 1000
|
||||
|
||||
**User's choice:** 1000 by default, configurable in settings (max 50 000); stable file numbering (sitemap-posts-1.xml ...); oldest first so new URLs land in the last file and earlier files do not shift
|
||||
|
||||
**Q: Google News sitemap and IndexNow**
|
||||
|
||||
Options presented: Both optional; IndexNow always, News optional; No News
|
||||
|
||||
**User's choice:** Both optional, enabled in settings; News for chosen categories/types; IndexNow key generated in the admin, pinged on publish, slug change and deletion
|
||||
|
||||
**Q: HTML sitemap content**
|
||||
|
||||
Options presented: All indexable, groups and paging; Structure only
|
||||
|
||||
**User's choice:** Everything indexable: no 404s, no redirected URLs, no noindex (same set as the XML sitemaps); grouping and paging at Claude's discretion
|
||||
|
||||
**Q: HTML sitemap location and linking**
|
||||
|
||||
Options presented: Footer on every page; Home page only
|
||||
|
||||
**User's choice:** Linked from the footer of every page (so also the home page); path set in the admin, default /mapa-strony (pl) or /sitemap (en) with locale variants; page component in a Nuxt layer, overridable
|
||||
|
||||
---
|
||||
|
||||
## 6. Pagination
|
||||
|
||||
**Q: Robots and canonical on page 2+ (from topic 4)**
|
||||
|
||||
Options presented: stated by user in topic 4
|
||||
|
||||
**User's choice:** Always index,follow with a self-referencing canonical
|
||||
|
||||
**Q: URL form**
|
||||
|
||||
Options presented: Per site, default ?page=N; Always /strona/N; Always ?page=N
|
||||
|
||||
**User's choice:** Per site, default ?page=N; a site may choose a path form (/blog/strona/2), e.g. to keep WinterCMS URLs; the other form 301s to the configured one
|
||||
|
||||
**Q: Title, description and content on page 2+**
|
||||
|
||||
Options presented: Title suffix; Description suffix; Category text on page 1 only; H1 with page number
|
||||
|
||||
**User's choice:** All four: title suffix ('Blog - strona 2 z 14 | Site'), description suffix ('Strona 2 z 14'), category long text (pillar content) only on page 1, H1 with the page number on 2+
|
||||
|
||||
**Q: Mechanism**
|
||||
|
||||
Options presented: <a> links + optional load more; Numbered links only
|
||||
|
||||
**User's choice:** Always numbered server-rendered <a href> links; 'load more'/infinite scroll only as an optional enhancement over them that updates the URL to ?page=N; <link rel=prev/next> in head
|
||||
|
||||
**Q: Invalid page numbers**
|
||||
|
||||
Options presented: page=1 -> 301, out of range -> 404; Out of range -> 301 to last
|
||||
|
||||
**User's choice:** ?page=1 (or /strona/1) 301 to the unnumbered URL; beyond the last page 404; garbage (?page=abc, -1) 404
|
||||
|
||||
---
|
||||
|
||||
## 7. Structured data per page type
|
||||
|
||||
**Q: Default mapping**
|
||||
|
||||
Options presented: As in the table; With changes
|
||||
|
||||
**User's choice:** JSON-LD as one @graph linked by @id. Every page: WebPage + BreadcrumbList + refs to WebSite and Organization. Home: WebSite (+SearchAction when search exists) + Organization/LocalBusiness from global settings. Post: BlogPosting (or Article/NewsArticle) with author Person, publisher Organization, image, dates, wordCount, articleSection. Category/tag: CollectionPage + ItemList. Author: ProfilePage + Person (sameAs). Service/offer: Service (provider, areaServed, optional Offer with price). Contact: ContactPage + LocalBusiness/Organization with address and hours. FAQ plugin page: FAQPage. Post with YouTube: VideoObject. Generated automatically, no editor work.
|
||||
|
||||
**Q: Editor control per record/page**
|
||||
|
||||
Options presented: Type + fields + custom JSON-LD; Type + fields; Automatic only
|
||||
|
||||
**User's choice:** Type choice in the SEO tab (e.g. BlogPosting/NewsArticle/Article; Service/Product), a type-dependent field form, plus a 'custom JSON-LD' field for advanced users, validated on save and merged into the graph
|
||||
|
||||
**Q: Publisher in global settings**
|
||||
|
||||
Options presented: Organization/LocalBusiness/Person; Organization only
|
||||
|
||||
**User's choice:** Choice of Organization, LocalBusiness with subtype (address, geo, opening hours, phone) or Person for personal blogs; logo, sameAs (social, Wikipedia, KRS), contact data
|
||||
|
||||
**Q: Validation**
|
||||
|
||||
Options presented: Admin + report; Google test link only
|
||||
|
||||
**User's choice:** In the admin against Google rich-result required/recommended properties per type, plus crawler checks of rendered JSON-LD, plus a 'check in Rich Results Test' link per URL
|
||||
|
||||
---
|
||||
|
||||
## 8. Heading structure
|
||||
|
||||
**Q: H1 inside body content (page title is the H1)**
|
||||
|
||||
Options presented: No H1 in editor + automatic conversion; Refuse save; Warning only
|
||||
|
||||
**User's choice:** Editor toolbar offers H2-H4 only; any H1 in content (pasted, imported from WinterCMS, written via MCP) is converted to H2 on save with a notice to the editor
|
||||
|
||||
**Q: Skipped levels and empty headings**
|
||||
|
||||
Options presented: Editor warning + report; Automatic renumbering on save
|
||||
|
||||
**User's choice:** Live heading outline in the editor flags errors (skipped level, empty heading, heading that is only a link); the crawler checks rendered pages (exactly one H1, no skipped levels, H1 consistent with the title); no silent rewriting beyond the H1 conversion
|
||||
|
||||
**Q: Headings in template elements**
|
||||
|
||||
Options presented: Rule in Nuxt layers; Leave as is
|
||||
|
||||
**User's choice:** One convention enforced in the Nuxt layers and their tests: H1 only in the main content; post cards on listings are H2; sidebar and footer widgets do not use content headings (styled text) so they do not disturb the outline
|
||||
|
||||
---
|
||||
|
||||
## 9. hreflang basics
|
||||
|
||||
**Q: Where hreflang is emitted**
|
||||
|
||||
Options presented: Head and sitemap; Sitemap only
|
||||
|
||||
**User's choice:** Both <link rel=alternate hreflang> in every page head and xhtml:link in the XML sitemaps, from one source (record locale alternates); plus <html lang>, og:locale and og:locale:alternate
|
||||
|
||||
**Q: x-default**
|
||||
|
||||
Options presented: Default-locale version; Configurable
|
||||
|
||||
**User's choice:** Points to the default-locale version
|
||||
|
||||
**Q: Page without a translation**
|
||||
|
||||
Options presented: No hreflang for that locale; Fallback to default locale
|
||||
|
||||
**User's choice:** No hreflang for that locale; never serve default-locale content under another locale's URL
|
||||
|
||||
---
|
||||
|
||||
## 10. SSR guarantee
|
||||
|
||||
**Q: How public pages are guaranteed server-rendered**
|
||||
|
||||
Options presented: Hard rule + checks; Documentation guideline only
|
||||
|
||||
**User's choice:** Hard rule: indexable pages are always SSR or SSG; ssr:false only on noindex routes; the Nuxt SEO layer fails the build when an indexable route has ssr:false; the crawler compares raw (no-JS) HTML with rendered HTML and reports content or links that appear only after JS
|
||||
|
||||
**Q: Server guarantees to search engines**
|
||||
|
||||
Options presented: Real HTTP codes; Links as <a href>; Content without interaction; SEO-friendly images
|
||||
|
||||
**User's choice:** All four: real HTTP status codes (404 not soft-404 200, 410 and 301 per rules); all navigation (menus, pagination, cards, breadcrumbs) as server-rendered <a href>; content in tabs/accordions/FAQ present in the HTML, only hidden by style; images with native loading=lazy and real src/alt, dimensions, featured image not lazy with fetchpriority
|
||||
|
||||
**Q: sm-bm-app (client-only SPA)**
|
||||
|
||||
Options presented: Separate phase if indexable; Internal app; In this phase
|
||||
|
||||
**User's choice:** Internal application with no public indexable pages: it only gets noindex and Disallow, no SSR migration
|
||||
|
||||
---
|
||||
|
||||
## 11. Internal linking (added by user)
|
||||
|
||||
**Q: User requirement**
|
||||
|
||||
Options presented: free text
|
||||
|
||||
**User's choice:** Avoid generic anchors ('kliknij tutaj'); post links are plain followed links (no rel attribute); smart default internal linking consistent with SEO. User first proposed image links with rel=nofollow; after the note that internal nofollow is only a hint and does not conserve PageRank, chose one link per card
|
||||
|
||||
**Q: Post image in cards (listings, related)**
|
||||
|
||||
Options presented: Link with rel=nofollow; One link per card; Configurable per site
|
||||
|
||||
**User's choice:** One link per card: only the title is a text link; the image is clickable for users but has no separate <a> in the HTML (or tabindex=-1, aria-hidden), so Googlebot sees one link with a good anchor
|
||||
|
||||
**Q: Anchors**
|
||||
|
||||
Options presented: Layers + content validation; Layers only
|
||||
|
||||
**User's choice:** Layer components never use generic anchors (card link = post title; any 'read more' carries the title, e.g. 'Czytaj: <title>'); the content editor warns on links whose anchor is on an editable generic list (pl and en); the crawler reports them
|
||||
|
||||
**Q: Smart internal linking**
|
||||
|
||||
Options presented: Related posts; Phrase auto-linking; Editor suggestions; Orphan protection
|
||||
|
||||
**User's choice:** All four: related posts (3-6, from tags, category and optionally the focus keyphrase, server-rendered) plus previous/next post in category; phrase auto-linking table phrase -> URL (first occurrence, max N links per post, never to itself, never inside headings; focus keyphrases can feed the table); link suggestions in the editor with inbound/outbound link counters; orphan report with suggestions where to link from
|
||||
|
||||
**Q: Outbound links in content**
|
||||
|
||||
Options presented: No attribute + per-link choice; Always nofollow
|
||||
|
||||
**User's choice:** Plain followed link by default; per-link rel checkboxes in the editor (nofollow, sponsored, ugc); a domain list that always gets nofollow or sponsored; target=_blank with rel=noopener for external links
|
||||
|
||||
---
|
||||
|
||||
## 12. URL normalisation, AI bots, media, breadcrumbs (added)
|
||||
|
||||
**Q: URL normalisation**
|
||||
|
||||
Options presented: Per-site settings; Fixed defaults
|
||||
|
||||
**User's choice:** Per-site settings: https always; www or not; trailing slash or not; lowercase path; double slashes, /index.html and similar to the clean form; one hop to the final form instead of a chain
|
||||
|
||||
**Q: AI bots in robots.txt**
|
||||
|
||||
Options presented: Per-bot switches, allow by default; Block training by default; No switches
|
||||
|
||||
**User's choice:** Per-bot switches (GPTBot, OAI-SearchBot, ClaudeBot, Google-Extended, PerplexityBot, CCBot, Applebot-Extended, others), distinguishing AI search bots from training bots; all allowed by default; optional llms.txt generated from the sitemap
|
||||
|
||||
**Q: Image alt and media**
|
||||
|
||||
Options presented: Alt required; SEO file names; Formats and sizes; Alt via MCP and report
|
||||
|
||||
**User's choice:** All four: alt required in the media manager and when inserting into content (warning when missing; 'decorative' checkbox gives alt=''); SEO file names (slug on upload, editable); automatic WebP/AVIF and srcset widths keeping the original; missing-alt report (CMS + crawler) and an MCP tool for bulk alt filling
|
||||
|
||||
**Q: Breadcrumbs**
|
||||
|
||||
Options presented: Layer component, one source; JSON-LD only
|
||||
|
||||
**User's choice:** Visible breadcrumbs component in a Nuxt layer as <a> links, from the same source as BreadcrumbList JSON-LD; on by default on every page except home, can be disabled or restyled; a post's trail goes through its primary category, selectable in the SEO tab
|
||||
|
||||
**Q: Strict URLs (raised by user: WinterCMS answered 200 for /<any-category>/<post>)**
|
||||
|
||||
Options presented: 301 to the correct URL; 404
|
||||
|
||||
**User's choice:** Every segment must match; a mismatching URL of an existing record 301s to its canonical URL; a wrong URL never answers 200
|
||||
|
||||
**Q: Phase split**
|
||||
|
||||
Options presented: Several consecutive phases; One phase, many plans
|
||||
|
||||
**User's choice:** Dawid: not his decision but Jakub's; recorded as open question Q-01 with Claude's recommendation (three phases 32/33/34)
|
||||
|
||||
---
|
||||
|
||||
## Claude's Discretion
|
||||
|
||||
- Where redirects execute: rules live in the CMS; the server of the page enforces them (Nuxt Nitro middleware in a shared layer for frontend pages, Go for its own paths and statically embedded sites)
|
||||
- HTML sitemap grouping (pages, offer, category tree, posts, indexable tags) and paging of large groups (~100-200 links per page)
|
||||
- Fix the Journal API gap (findPostBySlugOrID matches only the default-locale slug) so translated slugs resolve; required for hreflang
|
||||
|
||||
## Deferred Ideas
|
||||
|
||||
- Social card preview; per-redirect hit counters and validity dates; 307/308; e-commerce structured data
|
||||
- Todo sitemap-xslt-browser-deprecation stays a separate backlog task (user decision)
|
||||
540
.planning/phases/32-seo-foundation/32-PATTERNS.md
Normal file
540
.planning/phases/32-seo-foundation/32-PATTERNS.md
Normal file
@@ -0,0 +1,540 @@
|
||||
# Phase 32: SEO foundation - Pattern Map
|
||||
|
||||
**Mapped:** 2026-10-26
|
||||
**Files analyzed:** 24 (framework seams, new `sm-seo-plugin`, `sm-journal-plugin` changes, `sm-demo-app` wiring)
|
||||
**Analogs found:** 21 / 24
|
||||
|
||||
Paths are relative to the meta repo root `/media/nvme/dev/golem15/summercms.io/summercms/`. Every analog below is git-tracked in its own repo (checked with `git ls-files`; sibling repos need `git -c safe.directory='*'`).
|
||||
|
||||
## File Classification
|
||||
|
||||
| New/Modified File | Role | Data Flow | Closest Analog | Match Quality |
|
||||
|---|---|---|---|---|
|
||||
| `summercms.go/modules/pact/capabilities.go` (AdminActionExtension + Form, RecordSaved/RecordDeleted, MenuItemType.Content) | model (API types) | n/a | same file: `AdminActionExtension` (~429-439), `MCPSubjectChanged`, `MenuItemType` (~798-808) | exact |
|
||||
| `summercms.go/modules/cabana/form_extensions.go` (new: placement compile pass) | service (boot compiler) | transform | `summercms.go/modules/cabana/action_extensions.go` | exact |
|
||||
| `summercms.go/modules/cabana/http.go` (Activate wiring) | config | boot | same file lines 135-143 | exact |
|
||||
| `summercms.go/modules/cabana/crud.go`, `extension.go`, `field_file.go`, `field_ml.go`, `form_schema.go` (extension-owned branch, lift values, Load/Save in tx) | service | CRUD | same files (owner-only path today) | exact (in-place) |
|
||||
| `summercms.go/modules/cabana/record_events.go` (new: emit + EmitRecordSaved/Deleted helpers) | service | event-driven | `summercms.go/modules/cabana/subject_events.go` | exact |
|
||||
| `summercms.go/modules/signpost/signpost.go` (+ ContentTypes/TypeForModel/MatchPath) | service (registry) | request-response | same file `Activate`/`add` (40-89) | exact |
|
||||
| framework READMEs + docs (`modules/{pact,cabana,signpost,party}/README.md`, `docs/backend/admin-controllers.md`, `docs/plugins/*.md`) | docs | n/a | existing sections | exact |
|
||||
| framework tests (`modules/cabana/form_extensions_test.go`, `record_events_test.go`, `modules/signpost/*_test.go`) | test | n/a | existing `action_extensions` tests in cabana | role-match |
|
||||
| `sm-seo-plugin/plugin.go` | provider (plugin entry) | boot | `sm-sitemap-plugin/plugin.go` | exact |
|
||||
| `sm-seo-plugin/admin.go` | config (admin registration) | n/a | `sm-sitemap-plugin/admin.go` | exact |
|
||||
| `sm-seo-plugin/admin_permissions.go` | config | n/a | `sm-sitemap-plugin/admin_permissions.go` | exact |
|
||||
| `sm-seo-plugin/extensions.go` (AdminActionExtensions with Form) | provider | boot | `sm-paymentgateway-plugin/controllers/orders.go` 106-155 (record action shape) + cabana `action_extensions.go` (consumer) | partial (no plugin implements extensions yet) |
|
||||
| `sm-seo-plugin/field_types.go` (+ `classes/field_types.go`) | component (field types) | transform | `sm-journal-plugin/field_types.go` + `classes/blog_editor.go` 80-109 | exact |
|
||||
| `sm-seo-plugin/listeners.go` | service | event-driven | `subject_events.go` (emitter) + `modules/festival/bus.go` Listen | role-match |
|
||||
| `sm-seo-plugin/routes.go` (`/robots.txt`, `/_seo/api/v1/*`) | route | request-response | `sm-journal-plugin/routes.go` + `sm-sitemap-plugin/routes.go` | exact |
|
||||
| `sm-seo-plugin/controllers/api/*.go` (resolve, management handlers) | controller | request-response | `sm-journal-plugin/controllers/api/posts.go` + `auth.go` | exact |
|
||||
| `sm-seo-plugin/mcp.go` | config (MCP tools) | request-response | `sm-journal-plugin/mcp.go` | exact |
|
||||
| `sm-seo-plugin/jobs.go` (GenerateEntries) | service (job) | batch | `sm-chat-plugin/plugin.go` 85-100 | exact |
|
||||
| `sm-seo-plugin/controllers/{redirects,rules,notfound,history}.go` | controller | CRUD | `sm-paymentgateway-plugin/controllers/orders.go` | exact |
|
||||
| `sm-seo-plugin/controllers/{settings,robots,transfer}.go` (AdminSingleton) | controller | CRUD | `sm-sitemap-plugin/controllers/definitions.go` | exact |
|
||||
| `sm-seo-plugin/models/*.go` + `models/*/fields.yaml`, `columns.yaml` | model | CRUD | `sm-sitemap-plugin/models/settings.go` + `models/settings/fields.yaml` | exact |
|
||||
| `sm-seo-plugin/updates/*.go` | migration | n/a | `sm-sitemap-plugin/updates/registry.go` + `202610110002_create_golem15_sitemap_settings.go` | exact |
|
||||
| `sm-seo-plugin/classes/*` (resolver, redirect graph, normaliser, robots, history, batch, csv) | service | transform | none (pure functions) | no analog |
|
||||
| `sm-seo-plugin/assets/src/*` (E1-E6 elements, Vite) | component | client | `sm-journal-plugin/assets/src/blogeditor/*`, `vite.config.ts`, `package.json` | exact |
|
||||
| `sm-seo-plugin/testmain_test.go` | test | n/a | `sm-sitemap-plugin/testmain_test.go` | exact |
|
||||
| `sm-journal-plugin/classes/menu_item_types.go` (+ Content descriptors, `journal-tag` type) | service | request-response | same file 98-140 | exact |
|
||||
| `sm-journal-plugin/controllers/api/posts.go` (Store/Update/Destroy emit record events) | controller | CRUD | same file 240-320 (existing `purgeSiteCache` after-commit call) | exact |
|
||||
| `sm-demo-app/summer.yaml`, `.gitmodules` (mount `plugins/golem15/seo`) | config | n/a | sitemap entries in same files | exact |
|
||||
|
||||
## Pattern Assignments
|
||||
|
||||
### `summercms.go/modules/pact/capabilities.go` (API types)
|
||||
|
||||
**Analog:** same file. Extend with keyed-field additions only, so existing keyed literals keep compiling.
|
||||
|
||||
Current struct (429-439):
|
||||
```go
|
||||
type AdminActionExtension struct {
|
||||
Controller string
|
||||
RecordActions []AdminRecordAction
|
||||
}
|
||||
|
||||
// HasAdminActionExtensions is implemented by plugins (not admin controllers)
|
||||
// that add actions to admin controllers by controller ID.
|
||||
type HasAdminActionExtensions interface {
|
||||
AdminActionExtensions() []AdminActionExtension
|
||||
}
|
||||
```
|
||||
The doc comment above it (418-428) lists every boot error in prose; the new `Form` field's comment must list the D-91 boot errors the same way (unknown anchor, duplicate name, cycle, anchor outside `Requires()`).
|
||||
|
||||
`MenuItemType` (798-808) uses `json:"-"` on func fields; new `Content *ContentDescriptor` follows that:
|
||||
```go
|
||||
References func(ctx context.Context) ([]MenuItemReference, error) `json:"-"`
|
||||
Resolve func(ctx context.Context, in MenuItemResolve) (*ResolvedMenuItem, error) `json:"-"`
|
||||
```
|
||||
Event types sit next to `pact.MCPSubjectChanged` (fired as a pointer, `&pact.MCPSubjectChanged{...}`), so `RecordSaved`/`RecordDeleted` are fired and listened to as pointers too.
|
||||
|
||||
---
|
||||
|
||||
### `summercms.go/modules/cabana/form_extensions.go` (boot compiler, transform)
|
||||
|
||||
**Analog:** `summercms.go/modules/cabana/action_extensions.go` 25-65
|
||||
|
||||
```go
|
||||
func compileActionExtensions(reg *Registry, plugins []party.Plugin) error {
|
||||
if reg == nil {
|
||||
return fmt.Errorf("cabana: registry is nil")
|
||||
}
|
||||
for _, plugin := range plugins {
|
||||
if plugin == nil {
|
||||
continue
|
||||
}
|
||||
src, ok := plugin.(pact.HasAdminActionExtensions)
|
||||
if !ok || src == nil {
|
||||
continue
|
||||
}
|
||||
pluginID := plugin.ID()
|
||||
for _, ext := range src.AdminActionExtensions() {
|
||||
if len(ext.RecordActions) == 0 {
|
||||
continue
|
||||
}
|
||||
cc, ok := reg.byID[ext.Controller]
|
||||
if !ok || cc == nil {
|
||||
return fmt.Errorf("cabana: plugin %s adds record actions to unknown admin controller %q", pluginID, ext.Controller)
|
||||
}
|
||||
...
|
||||
// A new slice and map: the compiled backing array may be
|
||||
// shared with another schema value.
|
||||
names := make([]string, 0, len(cc.Form.recordActions)+1)
|
||||
```
|
||||
Copy: iterate `plugins` in party order (already topo-sorted), type-assert the capability, error messages of form `cabana: plugin %s ... controller %q`, and copy-on-write of compiled slices/maps. Skip the extension when `ext.Form == nil` (mirrors `len(ext.RecordActions) == 0`).
|
||||
|
||||
**Wiring** (`modules/cabana/http.go` 135-143): call `compileFormExtensions(reg, plugins)` before `compileActionExtensions`:
|
||||
```go
|
||||
// Contributed record actions are merged before compileContributions,
|
||||
// which validates every record action's permissions.
|
||||
if err := compileActionExtensions(reg, plugins); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
```
|
||||
Owner-only checks that need an "extension-owned" branch (RESEARCH Pitfalls 3-7): `extension.go:132,145,150` (widget prefix, fill, AdminClientAssets), `extension.go:231-233` (partials from owner FS), `field_file.go:309-326` (fileupload), `crud.go:256` (`BindWritableFields` "is not a model column"), `http.go:857-866` (`hiddenSchemaFields`, schema-only — apply to save too).
|
||||
|
||||
---
|
||||
|
||||
### `summercms.go/modules/cabana/record_events.go` (event-driven)
|
||||
|
||||
**Analog:** `summercms.go/modules/cabana/subject_events.go` 17-44
|
||||
|
||||
```go
|
||||
func fireSubjectChanged(ctx context.Context, app *backpack.App, kind string, adminIDs ...uint) {
|
||||
if app == nil || app.Events == nil {
|
||||
return
|
||||
}
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
tx, _ := TxFromContext(ctx)
|
||||
lagoon.AfterCommit(ctx, tx, func(ctx context.Context, _ *gorm.DB) {
|
||||
for _, id := range adminIDs {
|
||||
...
|
||||
event := &pact.MCPSubjectChanged{Guard: backendSubjectGuard, UserID: id, Kind: kind}
|
||||
if err := app.Events.Fire(ctx, event); err != nil {
|
||||
moduleLog.WarnContext(ctx, "cabana: subject changed listener failed", "kind", kind, "admin_id", id, "error", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
Copy exactly: nil app/bus is a no-op, fire after commit, listener error only logged (never fails the save). Exported `EmitRecordSaved/EmitRecordDeleted(ctx, app, tx, ev)` take an explicit `tx` (journal handlers have no cabana tx in ctx). Doc comment style is the 8-line paragraph above `fireSubjectChanged`.
|
||||
|
||||
---
|
||||
|
||||
### `summercms.go/modules/signpost/signpost.go` (registry)
|
||||
|
||||
**Analog:** same file, `Activate` (40-66) and `add` (68-89). Validation of the new `Content` descriptor goes into `add` with the same message shape:
|
||||
```go
|
||||
if t.Resolve == nil {
|
||||
return fmt.Errorf("signpost: menu item type %q of plugin %s has no Resolve", t.Key, owner)
|
||||
}
|
||||
```
|
||||
New read helpers follow `Types()` (132) / `Type(key)` (140) style; `MatchPath` compiles patterns via the existing `Pattern(key, override)` (161).
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/plugin.go` (plugin entry)
|
||||
|
||||
**Analog:** `sm-sitemap-plugin/plugin.go` 1-80
|
||||
|
||||
```go
|
||||
import (
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/models"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/updates"
|
||||
"git.golem15.com/golem15/summercms/modules/backpack"
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
"git.golem15.com/golem15/summercms/modules/party"
|
||||
"git.golem15.com/golem15/summercms/modules/surf"
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
_ party.Plugin = (*Plugin)(nil)
|
||||
_ pact.HasConfig = (*Plugin)(nil)
|
||||
_ pact.HasMigrations = (*Plugin)(nil)
|
||||
_ pact.HasModels = (*Plugin)(nil)
|
||||
_ pact.HasRoutes = (*Plugin)(nil)
|
||||
...
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
app *backpack.App
|
||||
...
|
||||
}
|
||||
|
||||
func (p *Plugin) ID() string { return "golem15.sitemap" }
|
||||
func (p *Plugin) Requires() []string { return nil }
|
||||
func (p *Plugin) Register(app *backpack.App) error { p.app = app; return nil }
|
||||
// Boot ... a bad config fails the boot with "golem15.sitemap: %w"
|
||||
```
|
||||
Copy: package doc comment, compile-time interface assertions block, `p.app` stored in Register/Boot, boot errors prefixed `golem15.seo:`. `Requires()` lists only what the seams need (not journal). Add `pact.HasJobs`, `pact.HasMCP`, `pact.HasFormFieldTypes`, `pact.HasAdminActionExtensions` assertions.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/admin.go` + `admin_permissions.go`
|
||||
|
||||
**Analog:** `sm-sitemap-plugin/admin.go` (whole file) and `admin_permissions.go`
|
||||
|
||||
```go
|
||||
//go:embed controllers/definitions/config_form.yaml models/definition/fields.yaml models/settings/fields.yaml
|
||||
var adminFS embed.FS
|
||||
|
||||
//go:embed lang
|
||||
var langFS embed.FS
|
||||
|
||||
func (p *Plugin) AdminControllers() []pact.AdminController {
|
||||
return controllers.AdminControllers(func() *backpack.App {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.app
|
||||
})
|
||||
}
|
||||
|
||||
func (p *Plugin) Settings() []pact.SettingsItem {
|
||||
return []pact.SettingsItem{
|
||||
{
|
||||
Code: "sitemap",
|
||||
Label: "golem15.sitemap::lang.plugin.name",
|
||||
...
|
||||
Permissions: []string{controllers.PermissionAccessDefinitions},
|
||||
Controller: controllers.DefinitionsControllerID,
|
||||
},
|
||||
```
|
||||
Use the **link-entry** form (`Controller:`), never `Form:`: the SEO settings need widgets/partials/plugin field types, which `cabana/settings.go:96-104` refuses (RESEARCH Pattern 4). Embed YAML file by file (controllers dir also holds Go). Permissions:
|
||||
```go
|
||||
func (*Plugin) Permissions() []pact.Permission {
|
||||
return []pact.Permission{{
|
||||
Code: controllers.PermissionAccessDefinitions,
|
||||
Tab: "golem15.sitemap::lang.plugin.name",
|
||||
Label: "golem15.sitemap::lang.plugin.permissions.access_definitions",
|
||||
Roles: []string{"developer"},
|
||||
}}
|
||||
}
|
||||
```
|
||||
One permission `golem15.seo.manage` (D-15).
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/controllers/{settings,robots,transfer}.go` (AdminSingleton)
|
||||
|
||||
**Analog:** `sm-sitemap-plugin/controllers/definitions.go` 19-80, 155-157
|
||||
|
||||
```go
|
||||
const (
|
||||
DefinitionsControllerID = "golem15.sitemap.definitions"
|
||||
PermissionAccessDefinitions = "golem15.sitemap.access_definitions"
|
||||
)
|
||||
|
||||
type definitionsAdminController struct {
|
||||
app func() *backpack.App
|
||||
}
|
||||
|
||||
func (definitionsAdminController) ID() string { return DefinitionsControllerID }
|
||||
func (definitionsAdminController) ModelName() string { return `Golem15\Sitemap\Models\Definition` }
|
||||
func (definitionsAdminController) ConfigDir() string { return "controllers/definitions" }
|
||||
func (definitionsAdminController) RequiredPermissions() []string { return []string{PermissionAccessDefinitions} }
|
||||
func (definitionsAdminController) NewRecord() any { return &models.Definition{} }
|
||||
|
||||
func (definitionsAdminController) SingletonRecord(_ context.Context, db *gorm.DB) (any, error) {
|
||||
if db == nil {
|
||||
return nil, errors.New("golem15.sitemap: database is not configured")
|
||||
}
|
||||
... find first, else create ...
|
||||
}
|
||||
|
||||
var (
|
||||
_ pact.AdminPermissioned = definitionsAdminController{}
|
||||
_ pact.AdminSingleton = definitionsAdminController{}
|
||||
)
|
||||
```
|
||||
`controllers/admin_registry.go` `AdminControllers(app func() *backpack.App) []pact.AdminController` is the list constructor to copy. Per-type tabs on the settings form come from the plugin's own D-91 extension on this controller.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/controllers/{redirects,rules,notfound,history}.go` (list/form/preview + record actions)
|
||||
|
||||
**Analog:** `sm-paymentgateway-plugin/controllers/orders.go` 24-50, 106-155, 299-312
|
||||
|
||||
```go
|
||||
func (c ordersAdminController) AdminRecordActions() []pact.AdminRecordAction {
|
||||
...
|
||||
out = append(out, pact.AdminRecordAction{
|
||||
Name: a.Name,
|
||||
Label: lang + a.Label,
|
||||
Confirm: lang + a.Confirm,
|
||||
Permissions: []string{PermissionManageOrders},
|
||||
Danger: a.Danger,
|
||||
Applies: func(ctx context.Context, record any) (bool, error) { ... },
|
||||
Run: func(ctx context.Context, in pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error) {
|
||||
return c.runTransition(ctx, in, a)
|
||||
},
|
||||
})
|
||||
```
|
||||
Plus `FilterOptions(scope)`, `ListExtendQuery`, `FormBeforeUpdate/FormBeforeDelete`, `FormRules`. 404 log "Create redirect…" adds `Prompt` (see `pact/capabilities.go:418-422`). Every hook delegates to the one service package in `classes/` (history, loop check, purge).
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/models/*` and `updates/*`
|
||||
|
||||
**Analog:** `sm-sitemap-plugin/models/settings.go` 35-70; `updates/registry.go` 1-17; `updates/202610110002_create_golem15_sitemap_settings.go`
|
||||
|
||||
```go
|
||||
type Settings struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
FrontendURL *string `gorm:"column:frontend_url"`
|
||||
...
|
||||
}
|
||||
func (Settings) TableName() string { return "golem15_sitemap_settings" }
|
||||
func (Settings) Fillable() []string { return []string{"frontend_url", ...} }
|
||||
```
|
||||
```go
|
||||
var createSettings = []*gormigrate.Migration{
|
||||
{
|
||||
ID: "202610110002_create_golem15_sitemap_settings",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
for _, stmt := range []string{ `CREATE TABLE ...`, `INSERT INTO ... (id) VALUES (1)` } {
|
||||
if err := tx.Exec(stmt).Error; err != nil { return err }
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error { return tx.Exec(`DROP TABLE IF EXISTS ...`).Error },
|
||||
},
|
||||
}
|
||||
func init() { Register(createSettings...) }
|
||||
```
|
||||
Raw SQL DDL, timestamped IDs, one file per table, table prefix `golem15_seo_`. Nullable columns as pointers. Validation in `Rules()`/`BeforeValidate` with phrase-key errors (`errFrontendURL` const pattern, settings.go:13-14). fields.yaml header comment block as in `models/settings/fields.yaml` 1-9.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/routes.go` + `controllers/api/*.go`
|
||||
|
||||
**Analog:** `sm-journal-plugin/routes.go` 9-36 (groups) and `sm-sitemap-plugin/routes.go` 43-60 (root route + bucket)
|
||||
|
||||
```go
|
||||
func (p *Plugin) Routes(r pact.Router) error {
|
||||
r.Group("/_journal/api/v1", surf.Use("throttle:journal-public-api"), func(g pact.Router) {
|
||||
g.Get("/posts", apicontrollers.Index(p.app))
|
||||
...
|
||||
})
|
||||
r.Group("/_journal/api/v1", surf.Use("throttle:journal-api"), func(g pact.Router) {
|
||||
g.Put("/posts/{id}", apicontrollers.Update(p.app))
|
||||
g.Where("id", `[0-9]+`)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
```
|
||||
```go
|
||||
r.Get("/sitemap.xml", p.sitemapXML, "throttle:"+BucketSitemap)
|
||||
...
|
||||
func (p *Plugin) Buckets() map[string]surf.Bucket {
|
||||
trusted := surf.TrustedProxies(nil)
|
||||
if p.app != nil { trusted = surf.TrustedProxies(p.app.Config) }
|
||||
```
|
||||
`GET /robots.txt` copies the sitemap root-route shape (no backend middleware, throttled, never 5xx). Do not register `GET /{name}` (verification files; RESEARCH anti-pattern).
|
||||
|
||||
Handler shape: `sm-journal-plugin/controllers/api/posts.go` 240-291 and `auth.go` 83-115:
|
||||
```go
|
||||
func Update(app *backpack.App) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r, pr, ok := requireBackendPrincipal(app, w, r)
|
||||
if !ok { return }
|
||||
if !requireAccessPosts(w, pr) { return }
|
||||
db, err := gdb(app)
|
||||
...
|
||||
wire.WriteJSON(w, http.StatusOK, map[string]any{"data": ...})
|
||||
}
|
||||
}
|
||||
func requireBackendPrincipal(app *backpack.App, w http.ResponseWriter, r *http.Request) (*http.Request, *bouncer.Principal, bool) {
|
||||
out, pr, err := cabana.ResolveBackend(app, r, journalCover)
|
||||
...
|
||||
}
|
||||
func gdb(app *backpack.App) (*gorm.DB, error) {
|
||||
db, ok := app.Lookup[*gorm.DB]()
|
||||
```
|
||||
Permission check via `cabana.Allows(pr, []string{"golem15.seo.manage"})`. MCP detection for history `via`: `bouncer.Dispatched(r.Context(), "backend")`.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/mcp.go`
|
||||
|
||||
**Analog:** `sm-journal-plugin/mcp.go` 12-110
|
||||
|
||||
```go
|
||||
var _ pact.HasMCP = (*Plugin)(nil)
|
||||
const mcpGuard = "backend"
|
||||
|
||||
type mcpUpdatePostInput struct {
|
||||
ID uint `json:"id" path:"id" jsonschema:"the post id"`
|
||||
Title *string `json:"title,omitempty" jsonschema:"the post title"`
|
||||
}
|
||||
|
||||
func (p *Plugin) MCP() pact.MCP {
|
||||
destructive := true
|
||||
return pact.MCP{
|
||||
Tools: []pact.MCPTool{
|
||||
{
|
||||
Name: "list_posts",
|
||||
Title: "List posts",
|
||||
Description: "...",
|
||||
Guard: mcpGuard,
|
||||
Method: http.MethodGet,
|
||||
Path: "/_journal/api/v1/posts",
|
||||
Input: mcpListPostsInput{},
|
||||
Permissions: []string{mcpAccessPosts},
|
||||
},
|
||||
```
|
||||
Tools bind only to `/_seo/api/v1/*` routes (pier requires exact method+path; `modules/pier/catalog.go:178-182`). Batch tools carry `dry_run` in the input struct.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/jobs.go`
|
||||
|
||||
**Analog:** `sm-chat-plugin/plugin.go` 85-100
|
||||
```go
|
||||
func (p *Plugin) Jobs() []pact.Job {
|
||||
return []pact.Job{
|
||||
conga.Job(p.maintainThreadSummary, conga.OnQueue(jobs.Queue), conga.MaxAttempts(1)),
|
||||
}
|
||||
}
|
||||
func (p *Plugin) maintainThreadSummary(ctx context.Context, args jobs.MaintainThreadSummaryArgs) error {
|
||||
if p.service == nil { return errServiceMissing }
|
||||
return jobs.Work(ctx, p.service.DB(), args)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/field_types.go` + `classes/field_types.go` (E1, E2, E4 types)
|
||||
|
||||
**Analog:** `sm-journal-plugin/field_types.go` 1-21 and `classes/blog_editor.go` 80-109
|
||||
```go
|
||||
func (p *Plugin) FormFieldTypes() []pact.FormFieldType {
|
||||
return classes.BlogEditorTypes(func() *backpack.App { if p == nil { return nil }; return p.app })
|
||||
}
|
||||
|
||||
{
|
||||
Name: "mlblogeditor",
|
||||
Element: BlogEditorElement,
|
||||
Translatable: true,
|
||||
Scripts: []string{"assets/dist/blogeditor.js"},
|
||||
Styles: []string{"assets/dist/blogeditor.css"},
|
||||
Options: []string{"htmlColumn", "uploadFolder"},
|
||||
CheckOptions: checkBlogOptions,
|
||||
Decode: decodeBlogHTML,
|
||||
Load: loadBlogHTML,
|
||||
ListValue: blogListValue,
|
||||
},
|
||||
```
|
||||
Pairs `seotext`/`mlseotext`, `seorobots`/`mlseorobots`, plus `robotstxt`. Bundle listed in `mlseotext.Scripts` so it loads on other plugins' forms. Note Pitfall 6: as extension fields, storage diverts to the extension's Save, not the host column.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/listeners.go`
|
||||
|
||||
**Analog:** emitter `cabana/subject_events.go` (above); bus signature `modules/festival/bus.go:43-46`:
|
||||
```go
|
||||
app.Events.Listen("golem15.seo", func(ctx context.Context, ev *pact.RecordSaved) error {
|
||||
return p.service.OnRecordSaved(ctx, ev)
|
||||
})
|
||||
```
|
||||
Register in `Boot`.
|
||||
|
||||
---
|
||||
|
||||
### `sm-seo-plugin/testmain_test.go`
|
||||
|
||||
**Analog:** `sm-sitemap-plugin/testmain_test.go` 19-70 (copy verbatim, rename DB/user to `golem15_seo`): `flag.Parse()` then `testing.Short()`, one `postgres:16-alpine` container, `pgx` stdlib driver.
|
||||
|
||||
---
|
||||
|
||||
### `sm-journal-plugin/classes/menu_item_types.go` (D-93 descriptors, `journal-tag`)
|
||||
|
||||
**Analog:** same file 19-140. Add `MenuTypeTag = "journal-tag"` to the key const block (21-27), a label const, a `DefaultTagPattern`, and `Content: &pact.ContentDescriptor{...}` on post/category/tag entries using `m := menuTypes{app: app}` methods, keyed literals as at 101-127.
|
||||
|
||||
### `sm-journal-plugin/controllers/api/posts.go` (record events)
|
||||
|
||||
**Analog:** same file. Store/Update/Destroy already call `purgeSiteCache(r, app, post)` → `cooler.PurgeSiteCacheAfterCommit(r.Context(), nil, ...)` (line 400). Add `cabana.EmitRecordSaved/EmitRecordDeleted` next to that call (after `Save`/`Delete`, same nil-tx semantics). Capture old slug/URL before `applyPostUpdate` (line 268) for the `Changes` list.
|
||||
|
||||
### `sm-demo-app/summer.yaml` + `.gitmodules`
|
||||
|
||||
**Analog:** sitemap entries:
|
||||
```yaml
|
||||
- id: golem15.sitemap
|
||||
module: git.golem15.com/golem15/sm-sitemap-plugin
|
||||
```
|
||||
```
|
||||
[submodule "plugins/golem15/sitemap"]
|
||||
path = plugins/golem15/sitemap
|
||||
url = git@git.golem15.com:golem15/sm-sitemap-plugin.git
|
||||
branch = main
|
||||
```
|
||||
Add `golem15.seo` after sitemap and journal (it requires sitemap per D-95 in Phase 33).
|
||||
|
||||
### `sm-seo-plugin/assets/src/*`
|
||||
|
||||
**Analog:** `sm-journal-plugin/assets/src/blogeditor/` (incl. `labels.ts` locale dictionary), `sm-journal-plugin/vite.config.ts`, `package.json` (pins typescript 5.9.3, vite 7.3.5, vitest 3.2.7, happy-dom 20.11.6), `scripts/` dist check. Light DOM, CSS scoped under the element tag, `--c-*` variables only.
|
||||
|
||||
## Shared Patterns
|
||||
|
||||
### Error messages and boot failures
|
||||
**Source:** `cabana/action_extensions.go:44`, `signpost/signpost.go:68-82`, `sm-sitemap-plugin/plugin.go` Boot
|
||||
**Apply to:** all seams and plugin Boot. Prefix with module/plugin ID (`cabana:`, `signpost:`, `golem15.seo:`), name the plugin, controller and offending key; `fmt.Errorf("...: %w", err)` wrapping.
|
||||
|
||||
### After-commit side effects
|
||||
**Source:** `cabana/subject_events.go:25-44`, `cooler.PurgeSiteCacheAfterCommit` (journal posts.go:400)
|
||||
**Apply to:** record events, site-cache purge after any SEO write, history-dependent notifications. Listener errors logged, never fail the write.
|
||||
|
||||
### Lazy app accessor
|
||||
**Source:** `sm-sitemap-plugin/admin.go` AdminControllers, `sm-journal-plugin/field_types.go`
|
||||
**Apply to:** controllers, field types, API handlers: pass `func() *backpack.App`, read DB via `app.Lookup[*gorm.DB]()` at request time.
|
||||
|
||||
### Auth for plugin JSON API
|
||||
**Source:** `sm-journal-plugin/controllers/api/auth.go:83-115`
|
||||
**Apply to:** every `/_seo/api/v1` write/management handler; one permission `golem15.seo.manage`.
|
||||
|
||||
### Phrase keys
|
||||
**Source:** sitemap `golem15.sitemap::lang.*` constants
|
||||
**Apply to:** all labels, comments and errors: `golem15.seo::lang.*`, `lang/{en,pl}/lang.yaml`, keys as listed in 32-UI-SPEC.md.
|
||||
|
||||
### Tests
|
||||
**Source:** `sm-sitemap-plugin/testmain_test.go`; framework `go test -short` loop
|
||||
**Apply to:** last plan; pure-function tests (placement, redirect graph, normaliser, resolver precedence) need no DB.
|
||||
|
||||
## No Analog Found
|
||||
|
||||
| File | Role | Data Flow | Reason |
|
||||
|---|---|---|---|
|
||||
| `sm-seo-plugin/classes/{resolver,redirects,normalize}.go` | service | transform | New algorithms (precedence resolver, redirect graph flatten/loop simulation, URL normalisation); use RESEARCH Patterns 5, 6, Pitfalls 10, 11, 13 and the wildcard-regexp example |
|
||||
| `sm-seo-plugin/classes/robots.go` | service | transform | No robots.txt code exists; grobotstxt pending decision note (RESEARCH Standard Stack) |
|
||||
| `sm-seo-plugin/classes/{batch,history,csv}.go` | service | batch | Dry-run-by-rollback and HMAC apply token are new (RESEARCH Pattern 8); use `lagoon.Transaction` + `encoding/csv` |
|
||||
|
||||
Also note: no plugin implements `HasAdminActionExtensions` today, so `sm-seo-plugin/extensions.go` is the first consumer; use the framework test fixtures in `modules/cabana` for shape.
|
||||
|
||||
## Metadata
|
||||
|
||||
**Analog search scope:** `summercms.go/modules/{pact,cabana,signpost,festival,boardwalk}`, `sm-sitemap-plugin`, `sm-journal-plugin`, `sm-paymentgateway-plugin`, `sm-chat-plugin`, `sm-demo-app`
|
||||
**Files scanned:** ~30
|
||||
**Pattern extraction date:** 2026-10-26
|
||||
839
.planning/phases/32-seo-foundation/32-RESEARCH.md
Normal file
839
.planning/phases/32-seo-foundation/32-RESEARCH.md
Normal file
@@ -0,0 +1,839 @@
|
||||
# Phase 32: SEO foundation - Research
|
||||
|
||||
**Researched:** 2026-10-26
|
||||
**Domain:** Go framework seams (pact, cabana, signpost), a new shared plugin (`sm-seo-plugin`), redirects and robots.txt protocol code, MCP through `pier`
|
||||
**Confidence:** HIGH for the code seams (read this session), MEDIUM for the plugin design (recommendations), MEDIUM for external protocol facts (official Google docs)
|
||||
|
||||
<user_constraints>
|
||||
## User Constraints (from CONTEXT.md)
|
||||
|
||||
The decisions below are copied verbatim from `32-CONTEXT.md` for the parts that bind Phase 32 (phase split, sections 0 to 4). Sections 5 to 12 (D-30 to D-86) are Phase 33 scope under Q-01; they are listed by ID at the end and matter here only where a Phase 32 shape must leave room for them.
|
||||
|
||||
### Locked Decisions
|
||||
|
||||
#### Phase split (resolved)
|
||||
- **Q-01 (resolved by Jakub, 2026-10-25): two consecutive phases, the second one large.** Dawid left the split to Jakub. Every decision in this document applies to both phases:
|
||||
- **32 Foundation:**
|
||||
- the three framework seams (D-91 to D-93), with the field placement rules of D-91;
|
||||
- `sm-seo-plugin` core: data model, SEO tab, global settings;
|
||||
- meta, canonical, robots;
|
||||
- redirects, URL normalisation, strict URLs;
|
||||
- robots.txt, MCP tools, history.
|
||||
|
||||
The seams are one-way framework API. Phase 32 ends with a framework release tag, and Phase 33 builds on that tagged version rather than on a `replace`.
|
||||
- **33 Output, audit and content** (about 12–15 plans):
|
||||
- `sm-sitemap-plugin` rewrite (D-32): XML and HTML sitemaps;
|
||||
- page registry;
|
||||
- JSON-LD, pagination, hreflang;
|
||||
- headings, breadcrumbs;
|
||||
- the Nuxt SEO layer and the SSR rules in the layers;
|
||||
- crawler and issue report;
|
||||
- internal linking and auto-links;
|
||||
- media (alt, file names, formats).
|
||||
|
||||
**Exception to the lean-planning rule, approved by Jakub:** Phase 33 is planned as many smaller plans instead of a few large ones, so the planner must not merge them into 3–4 plans. The other project rules still apply: the plan list with a one-line scope each is shown to Jakub before PLAN.md files are written, and unit tests are the last plan.
|
||||
|
||||
ROADMAP.md still lists one Phase 32 with the full scope. Before `/msd-plan-phase 32`, narrow Phase 32 and add Phase 33 through `/msd-phase`, with its g15office task. The planner must not split or merge phases on its own.
|
||||
|
||||
(Research note: ROADMAP.md already carries the narrowed Phase 32 and the new Phase 33 [VERIFIED: .planning/ROADMAP.md:1576-1620].)
|
||||
|
||||
#### 0. Code layout (Jakub, 2026-10-25)
|
||||
- **D-90:** **The framework carries no SEO code.** SEO lives in two shared plugins: a new `sm-seo-plugin` (Golem15.SEO) and an updated `sm-sitemap-plugin` (Golem15.Sitemap). The framework gets only the generic seams those plugins need (D-91 to D-93); none of them names SEO, and each is useful to other plugins. The pattern is the PixelPixel `mpseo` WinterCMS plugin (see Reference implementations):
|
||||
- content plugins did not import anything from it; they registered a content type (model, controller, a mapper for default title/description/image, a URL resolver, an `is_published` check, the tab position) through the `seoinjection.extend` event;
|
||||
- the SEO plugin owned one `entries` table keyed by source type and id plus the URL, injected the SEO tab into the registered controllers through `extendFormFields`, deleted the entry with the record, kept per-type defaults with placeholders in its settings (with an inject switch per type), generated entries in a job, had a Google result preview and revisions, and resolved SEO by URL on the frontend.
|
||||
|
||||
SummerCMS keeps that division and replaces the event with D-91 to D-93. — **Reversibility:** costly — the seams become framework API, and moving SEO back into the framework later would mean migrating the plugin's tables.
|
||||
- **D-91:** **Cross-plugin admin form extensions, with real field placement.** `pact.AdminActionExtension` (controller ID plus record actions; its comment already leaves room for more kinds) gains form fields and tabs. An extension targets a controller ID, adds fields and tabs to its form, and loads and saves their values itself through `Load` and `Save` hooks that run inside the record's save transaction. The owner's model and tables are untouched.
|
||||
|
||||
Placement must work properly. In WinterCMS, adding field C at the end of A, B was easy, but placing it between them (A, C, B) meant fighting `extendFormFields`. Here:
|
||||
- every field and tab in a compiled form has a stable name: the field key from `fields.yaml`, the tab key;
|
||||
- an extension places each field with `Before` or `After` an anchor field, inside an existing tab, a new tab, or a zone (outside the tabs, primary tabs, secondary tabs); with no anchor the field goes to the end of its tab, as in WinterCMS;
|
||||
- a new tab is placed the same way, `Before` or `After` another tab;
|
||||
- an extension may hide an owner's field, for example a plugin's own meta-title field that the SEO tab replaces (`mpseo` removed `viewBag[meta_title]` the same way);
|
||||
- the result is deterministic: extensions apply in plugin order (`party`, by `Requires()`); several extensions anchored at the same point keep that order; an anchor may name a field added by another extension only if that plugin is in `Requires()`;
|
||||
- an unknown anchor, a duplicate name or an anchor cycle stops the boot with a clear error, like the existing `AdminActionExtension` checks;
|
||||
- cabana compiles the final order at boot; the SPA renders the compiled form as it is and never reorders it; field `span` (left, right, full) keeps working next to inserted fields;
|
||||
- top-level fields and tabs only; fields inside repeaters and nested forms are out of scope for now.
|
||||
|
||||
Tests cover at least: C after A gives A, C, B; C before the first field; a new tab between two existing tabs; two plugins anchored at the same field; hiding a field; each boot error. — **Reversibility:** one-way — the extension struct and the anchor rules become a published framework API.
|
||||
- **D-92:** **Record events from cabana.** Other plugins can subscribe to "record saved" (created or updated) and "record deleted" for a controller or model type. The event carries the record id, the locale and the changed attributes with old and new values (so a slug or parent change is visible), and fires after commit. Admin, MCP and imports all go through cabana and emit it; plugin code that writes records directly uses a cabana helper to emit the same event. Today only GORM hooks on the owner's model exist, which another plugin cannot use. The SEO plugin uses the events for the automatic 301 (D-18) and to delete SEO entries with their record. — **Reversibility:** costly — subscribers in shared plugins depend on the event shape.
|
||||
- **D-93:** **Content descriptors in signpost.** `pact.MenuItemType` already has URL patterns, `Resolve` and locale alternates. It gains optional functions that describe the type's content: list the records (for sitemaps and the registry), `lastmod`, whether a record is published, and default title, description and image (the `mapper` of `mpseo`). Content plugins (journal, FAQ, future ones) only register types in signpost, as they already do for menus and the sitemap, and never import `sm-seo-plugin` or `sm-sitemap-plugin`. — **Reversibility:** costly — every content plugin implements these functions.
|
||||
- **D-94:** **`sm-seo-plugin` (Golem15.SEO)**, a new repo mounted like the other core plugins:
|
||||
- models: the SEO entry (type, id, locale, URL, the SEO tab's values, `data` jsonb), entry revisions (history and undo), settings (sections 1 and 4, with a tab per content type: templates with placeholders and an inject switch, as in `mpseo`), URL rules, redirects, the 404 log, robots.txt, the page registry (D-33);
|
||||
- uses D-91 to add the SEO tab to every registered type's controller, D-92 for the automatic 301 and cleanup, D-93 for defaults and URL ownership;
|
||||
- a job that creates missing entries (the `mpseo` GenerateSeoEntriesJob), run through `conga`;
|
||||
- the frontend API: effective SEO by URL, redirects, robots.txt, llms.txt, verification files, JSON-LD `@graph`, breadcrumbs;
|
||||
- admin widgets: the result preview, the placeholder list, revisions;
|
||||
- MCP through `pier` from its admin routes, plus CSV import/export and the issue report; the crawler (Phase 33) lives here too.
|
||||
- **D-95:** **`sm-sitemap-plugin` (Golem15.Sitemap)** produces the sitemaps of D-30, D-31 and D-34 from signpost (D-93). It knows nothing about SEO: it defines its own small filter interface (exclude a URL, noindex, `lastmod` override) and looks it up with `app.Lookup`. `sm-seo-plugin` implements it and requires Sitemap (`Requires()`); Sitemap works without SEO.
|
||||
- **D-96:** **Content plugins keep only their own fixes.** Journal gets the translated-slug fix (D-58), the H1 → H2 conversion (D-50), its schema types and the D-93 descriptors. It does not depend on the SEO plugin.
|
||||
- **D-97:** **The Nuxt side is one new shared layer** (`vue-seo-layer`, name to confirm): `<head>` from the effective-SEO API, redirect middleware, JSON-LD, breadcrumbs, the SSR build guard (D-70). Journal, menu and FAQ layers and the apps extend it.
|
||||
|
||||
#### 1. SEO data model
|
||||
- **D-01 (revised by Jakub, 2026-10-25):** **Per-record SEO is owned by `sm-seo-plugin`.** A content type takes part by registering in signpost (D-93); the SEO settings switch the tab on per type, as `mpseo` did. The plugin adds a standard "SEO" tab to the type's admin form through the generic form extension (D-91) and stores the data in its one shared table keyed by (model type, record id, locale). Every plugin, present and future, gets the same tab without its own migrations, and MCP has one place to read and write. Originally recorded as a framework mechanism; moved to the plugin under D-90. — **Reversibility:** one-way — the shared table and the opt-in contract are what every content plugin builds on.
|
||||
- **D-02:** **Per-URL SEO rules** live on a separate screen, with exact URLs and patterns (e.g. `/blog?tag=*`). They cover pages with no record behind them: the home page, Nuxt pages, filter URLs. **Precedence: URL rule > record SEO > global defaults > values derived from content.** — **Reversibility:** costly — the precedence order is visible to editors and MCP clients and is baked into the effective-SEO resolver.
|
||||
- **D-03:** **Global SEO settings** contain:
|
||||
- title templates and defaults: a template such as `%title% | %site%`, a separate home-page template, the default meta description, the default OG image and the site name;
|
||||
- organisation or person data for JSON-LD (D-43);
|
||||
- search engine verification (D-05);
|
||||
- default robots per content type (D-21).
|
||||
- **D-04:** **Social tags inherit with optional overrides.** By default OG and Twitter take the title, description and image from SEO or from the content. A "Social" section in the SEO tab can override `og:title`, `og:description` and `og:image`. Twitter Card (`summary_large_image`) falls back to OG, and `twitter:site` is set in the global settings. There is no social card preview.
|
||||
- **D-05:** **Search engine verification** supports two methods:
|
||||
- meta tag codes (Google, Bing, Yandex, others), emitted on the home page;
|
||||
- verification files (name and content) served from the site root, e.g. `/google1234.html`.
|
||||
- **D-06:** **Canonical:**
|
||||
- Every page is self-canonical by default: an absolute URL, with junk parameters (utm, fbclid and similar) stripped and pagination kept.
|
||||
- Overrides are possible per record and per URL rule. An override may be relative or absolute and may point to another domain.
|
||||
- The admin warns when a canonical points to a noindex or redirected page.
|
||||
- **D-07:** **Global canonical rules use a query-parameter list.** Parameters marked as content (e.g. `page`) stay in the canonical; filter and sort parameters (e.g. `sort`, `color`) are dropped. The list can be refined per path pattern (e.g. `/katalog/*`). The same list drives the noindex of filter URLs (D-21).
|
||||
- **D-08:** **Meta robots:**
|
||||
- index/noindex and follow/nofollow switches, defaulting to "inherit";
|
||||
- an advanced section: `max-snippet`, `max-image-preview`, `max-video-preview`, `noarchive`, `nosnippet`, `noimageindex`, `unavailable_after`;
|
||||
- the same directives are also sent as an `X-Robots-Tag` header, so they work for PDFs and other files.
|
||||
- **D-09:** **Editor aids in the SEO tab:**
|
||||
- a live Google SERP preview (desktop and mobile, with pixel truncation);
|
||||
- character and pixel counters for title and description, with warnings for too long, too short, empty, and duplicates of another record;
|
||||
- a focus keyphrase with Yoast-style checks: the phrase in the title, H1, description and URL, plus text length.
|
||||
|
||||
#### 2. MCP management
|
||||
- **D-10:** **The whole of SEO is manageable through MCP.** Every admin operation in this phase has an MCP tool, built on the 19.7 `pier` module: admin routes become tools under the linked admin's permissions, and read grants see only read tools. Typical use: Dawid audits a site, then tells his Claude "noindex this page, 301 that one to this one".
|
||||
- **D-11:** **Tools address pages by URL.** The server resolves the owner:
|
||||
- if a record is behind the URL, the change goes into the record's SEO tab;
|
||||
- otherwise a URL rule is created.
|
||||
|
||||
The answer says where the change was written, and the caller can force a URL rule.
|
||||
- **D-12:** **Bulk changes:**
|
||||
- Batch tools take a list of changes, e.g. 50 redirects from one audit.
|
||||
- `dry_run` returns the diff and the conflicts: redirect loops and chains, noindex on a page that is in a sitemap, a canonical pointing to a redirected page.
|
||||
- Applying a batch is all-or-nothing.
|
||||
- **D-13:** **Read and audit tools:**
|
||||
- the effective SEO of a URL, with the source of every value (URL rule, record, global or derived);
|
||||
- the site issue report (D-14);
|
||||
- CSV export and import with a preview, also in the admin;
|
||||
- a change history with author, time, and before/after values, from both the admin and MCP, with undo of one change or of a whole batch.
|
||||
- **D-14:** **The issue report combines two sources:**
|
||||
- CMS data checks: duplicate or missing titles and descriptions, conflicting rules;
|
||||
- a built-in crawler, run on demand or on a schedule, that fetches rendered pages from the sitemaps and from links. It checks status codes, H1/H2/H3, canonical, robots, JSON-LD, internal links, orphan pages, generic anchors and missing alt.
|
||||
|
||||
Results are available in the admin and over MCP. The crawler is the only way to check the Nuxt-rendered output and static frontend pages.
|
||||
- **D-15:** **One SEO permission** covers all SEO operations: meta, rules, redirects, robots.txt, settings. It is not split per area.
|
||||
|
||||
#### 3. Redirects, URL normalisation, strict URLs
|
||||
- **D-16:** **Status codes: 301, 302 and 410 Gone.** No 307/308.
|
||||
- **D-17:** **Source matching:**
|
||||
- exact URLs (the default), wildcard patterns (`/old/*` → `/new/*`), and regex with capture groups;
|
||||
- options: ignore case, trailing slash, and query string (ignore it or pass it through);
|
||||
- evaluation order: exact, then patterns, then regex.
|
||||
- **D-18:** **A slug or path change creates a 301** from the old URL to the new one and flattens existing chains (A→B, then B→C becomes A→C). Deleting or unpublishing a record creates nothing: the URL returns 404 and appears in the 404 log.
|
||||
- **D-19:** **Loops are always refused**, whether they come from the admin, MCP or an import. Chains are saved with a warning and listed in the issue report.
|
||||
- **D-20:** **404 log:** URL, hit count, last hit and referer. A redirect or 410 can be created from an entry with one click or through MCP. There are no per-rule hit counters and no validity dates.
|
||||
- **D-20a:** **Where redirects execute is Claude's discretion.** The rules live in the CMS and are enforced by whatever serves the page: Nuxt Nitro middleware in a shared layer for frontend pages, Go for its own paths and for statically embedded sites.
|
||||
- **D-20b:** **URL normalisation is set per site:**
|
||||
- https always;
|
||||
- www or bare domain;
|
||||
- trailing slash or none;
|
||||
- lowercase paths;
|
||||
- double slashes, `/index.html` and similar collapse to the clean form.
|
||||
|
||||
Any other form reaches the final form in one 301 hop, never through a chain.
|
||||
- **D-20c:** **Strict URLs.** WinterCMS answered 200 to `/<any-category>/<post-slug>` because it checked only the post slug, which created duplicates. In SummerCMS every URL segment (category, parent categories, author, locale prefix) must match the record. A URL whose segments do not match a record that exists 301s to the record's canonical URL. This also covers a post moving to another category. A wrong URL never answers 200. — **Reversibility:** costly — it changes how every layer route and every Journal API lookup resolves records.
|
||||
|
||||
#### 4. robots.txt and noindex policy
|
||||
- **D-21:** **Default robots per page kind** (editable per type in the global settings, and per record):
|
||||
|
||||
| Page kind | Robots |
|
||||
|---|---|
|
||||
| Login, register, password reset, every signed-in user page | noindex |
|
||||
| Internal search results | noindex,follow |
|
||||
| Filter and sort parameter URLs (D-07 list) | noindex,follow |
|
||||
| Technical pages: cart and checkout (future), draft previews, thank-you pages, 404 and error pages | noindex |
|
||||
| Tag archives | noindex,follow |
|
||||
| Author pages | index,follow (always) |
|
||||
| Pagination page 2+ | index,follow, self-referencing canonical |
|
||||
- **D-22:** **robots.txt editor:**
|
||||
- a text editor with syntax validation and a tester ("is this URL blocked for Googlebot?");
|
||||
- the `Sitemap:` line is appended automatically;
|
||||
- every non-production environment (staging, demo) always serves `Disallow: /` and `X-Robots-Tag: noindex`, whatever the stored content. — **Reversibility:** reversible — but the staging lock must never be disabled silently, since an indexed staging copy is costly to clean up.
|
||||
- **D-23:** **Private frontend pages are marked automatically.** Every route that requires sign-in gets `noindex,nofollow` and an `X-Robots-Tag` header without per-page code. Path patterns in the admin cover public pages that should not be indexed (e.g. `/konto/*`, `/logowanie`). The user plugin's auth layer marks its own pages.
|
||||
- **D-24:** **noindex, robots.txt and sitemaps stay consistent automatically.**
|
||||
- Pages that are noindex, canonicalised elsewhere or redirected drop out of the XML and HTML sitemaps.
|
||||
- The admin warns when a noindex page is blocked in robots.txt (Googlebot cannot see the noindex) and when a sitemap URL is blocked.
|
||||
- **D-25:** **AI bots:**
|
||||
- per-bot switches (GPTBot, OAI-SearchBot, ClaudeBot, Google-Extended, PerplexityBot, CCBot, Applebot-Extended and others), with AI search bots distinguished from training bots;
|
||||
- all bots allowed by default;
|
||||
- an optional `llms.txt` generated from the sitemap.
|
||||
|
||||
#### Phase 33 decisions (referenced, not in Phase 32 scope)
|
||||
D-30 to D-34 (sitemaps, page registry), D-40 to D-42 (pagination), D-43 to D-46 (structured data), D-50 to D-52 (headings), D-55 to D-58 (hreflang, Journal translated-slug fix), D-70 to D-72 (SSR), D-80 to D-83 (internal linking), D-85 to D-86 (media, breadcrumbs). Phase 32 must leave room for D-33 (registry types in signpost), D-95 (the sitemap filter interface the SEO plugin will implement), D-43/D-44 (`data` jsonb on the entry, reserved SEO tab anchors) and D-25's `llms.txt`.
|
||||
|
||||
### Claude's Discretion
|
||||
- Where redirects execute (D-20a), HTML sitemap grouping and paging (D-34), the Journal translated-slug fix (D-58).
|
||||
- Table and package names inside the plugins, and the exact Go shape of the three seams (D-91 to D-93). The seams go into the existing `pact`, `cabana` and `signpost` modules; no new framework module is planned.
|
||||
- How the frontend fetches effective SEO: one resolver endpoint per URL, cached and purged through the existing site-cache purge.
|
||||
- Crawler implementation (Go, in-process job via `conga`/River, politeness limits).
|
||||
|
||||
### Deferred Ideas (OUT OF SCOPE)
|
||||
- **Social card preview** (Facebook/LinkedIn/X) in the SEO tab: offered, not chosen.
|
||||
- **Per-redirect hit counters and validity dates:** offered, not chosen.
|
||||
- **307/308 redirects:** not chosen.
|
||||
- **E-commerce structured data** (Product, offers on category pages): no shops yet.
|
||||
|
||||
#### Reviewed Todos (not folded)
|
||||
- `sitemap-xslt-browser-deprecation.md` (g15office w8kupqi3): replace the browser XSLT view of `/sitemap.xml`. The user chose to keep it as a separate backlog task. The D-32 rewrite of the sitemap plugin touches the same code, so the planner should note that the XSL output may be removed or kept there.
|
||||
- `sitemap-plugin-port.md`: stale. The port was delivered in Phase 17 and should be closed separately.
|
||||
</user_constraints>
|
||||
|
||||
<phase_requirements>
|
||||
## Phase Requirements
|
||||
|
||||
No requirement IDs are mapped (ROADMAP: "Requirements: TBD"). The success criteria are the coverage source.
|
||||
|
||||
| ID | Description | Research Support |
|
||||
|----|-------------|------------------|
|
||||
| SC-1 | A plugin can add a field between two fields of another plugin's admin form (A, B plus C after A renders A, C, B), and add a tab between two existing tabs; unknown anchors, duplicate names and anchor cycles stop the boot with a clear error. | Pattern 1 (placement pass in `cabana.Activate` next to `compileActionExtensions`), Pitfalls 1–6, SPA tab derivation facts |
|
||||
| SC-2 | Journal posts, categories and tags show the SEO tab without importing `sm-seo-plugin`, and the frontend gets the effective SEO of any URL with the precedence URL rule > record > global > derived. | Pattern 3 (D-93 descriptors incl. controller ID), Pattern 5 (resolver), Pitfall 9 (no tag type today), journal findings |
|
||||
| SC-3 | Changing a record's slug creates a 301 and flattens existing chains; redirect loops are refused from the admin, MCP and imports. | Pattern 2 (D-92 events), Pattern 6 (URL-diff 301 + flatten), Pitfalls 10–12, journal API write path finding |
|
||||
| SC-4 | Every SEO operation in the admin is available as an MCP tool, and a batch change can be previewed with dry-run and undone from history. | Pattern 7 (own `/_seo/api/v1` routes for pier), Pattern 8 (dry-run by rollback, history/undo) |
|
||||
| SC-5 | The framework release with the seams is tagged, and the new code has unit tests, delivered in the phase's last plan. | Release section, Validation Architecture |
|
||||
</phase_requirements>
|
||||
|
||||
## Project Constraints (from CLAUDE.md)
|
||||
|
||||
From `summercms.go/CLAUDE.md`, the meta repo `CLAUDE.md` and the user's global instructions:
|
||||
|
||||
- **No co-author tags in commits** (user global and project). One logical change per commit; planning docs and code in separate commits. Stage files by explicit path, never `git add -A`; leave other sessions' uncommitted edits (`STATE.md`, `state.json`) alone; check for in-flight edits before touching shared files such as cabana.
|
||||
- **Do not push, tag or deploy without the user's go-ahead.** Every pushed `vX.Y.Z` tag gets a summercms.io changelog post the same day (`../sm-summercmsio-app/scripts/changelog-post.py`); never print or mint the journal token.
|
||||
- **Framework code never names a consuming application**, and per D-90 never names SEO.
|
||||
- **Dependencies:** standard library first; a new dependency needs a research doc or a phase/decision note naming it (`.planning/research/STACK.md`). YAML is parsed with `goccy/go-yaml`, never `gopkg.in/yaml.v3`.
|
||||
- **No runtime plugin loading** (stdlib `plugin`, yaegi) without a decision note.
|
||||
- **Documentation rule:** a change to a module's exported API, config keys, CLI commands or dependencies updates that module's `README.md` and the affected `docs/` pages in the same commit; every identifier in a README or docs page must exist (the docs checker enforces it). Affected today: `modules/pact/README.md`, `modules/cabana/README.md`, `modules/signpost/README.md`, `modules/party/README.md`, `docs/backend/admin-controllers.md`, `docs/plugins/registration.md`, `docs/plugins/menu-item-types.md`, `docs/setup/coming-from-wintercms.md` [VERIFIED: grep of the seam identifiers this session].
|
||||
- **Keep `go vet ./...` and `go test ./...` green at every commit.** Docker-backed tests skip under `-short`; a `TestMain` that starts containers calls `flag.Parse()` and checks `testing.Short()`.
|
||||
- **Admin release gate:** a tag that includes `admin/` changes needs `npm --prefix admin run build`, the committed `modules/boardwalk/dist`, and `scripts/check-admin-dist.sh` passing.
|
||||
- **Core plugin contracts stay non-breaking** (routes, payloads, tables, migration IDs, config keys) unless the user asks. Change a submodule plugin in its own checkout, push it first, then bump the pointer in the app in a separate commit.
|
||||
- **MSD project rules:** lean planning (few, large plans; show the plan list with one-line scopes and wait for confirmation), unit tests are the last plan, STATE.md only through `msd_run query state.*` handlers, g15office sync with a short comment when the phase advances.
|
||||
- **User memory:** prefers an established, maintained library plus a decision note for protocol and security code; Dawid decides SEO behaviour (talk in Polish, files in English), Jakub decides phase and scope.
|
||||
|
||||
## Summary
|
||||
|
||||
Phase 32 is mostly framework surgery with a large plugin on top. The three seams land in code that exists and is well-factored: `cabana.Activate` already runs a post-compile pass for cross-plugin record actions (`compileActionExtensions`), cabana already fires after-commit events through `lagoon.AfterCommit` plus the `festival` bus (`fireSubjectChanged`), and `signpost` already owns per-type URL resolution with locale alternates. The D-91 form extension is the hardest seam: the current compile pipeline assumes every form field belongs to the controller's own plugin, so plugin field types, widgets, partials, `fileupload` and the writable-column binding all need an "owned by an extension" branch. The SPA needs no ordering code, because it derives tabs by first field appearance and puts the default tab first.
|
||||
|
||||
The investigation turned up several facts the UI-SPEC and CONTEXT do not account for, and the planner must handle them. First, a settings form (`pact.SettingsItem.Form`) refuses `widget`, `partial`, `fileupload` and every plugin field type, so the SEO settings screen must be an `AdminSingleton` controller linked from the settings tile. Second, `pier` binds MCP tools to exact method and path routes, while cabana's admin routes are generic `{vendor}/{plugin}/{controller}` patterns behind `requireAjax`, so the SEO plugin needs its own token-guarded JSON API under `/_seo/api/v1`, as Journal has. Third, Journal's MCP writes go through Journal's own API, not through cabana, so Journal's API handlers must call the new cabana record-event helper. Without that, a slug change made through MCP creates no 301. Fourth, Journal has no tag menu item type, and one site turns tag pages off. Fifth, Go cannot serve dynamic root-level verification files without shadowing app catch-all routes.
|
||||
|
||||
**Primary recommendation:** Build D-91 as a new `pact.AdminFormExtension` (a sibling kind carried next to `AdminActionExtension`). Each extension field is tagged with its contributing plugin, so that partials, widget actions, field types and storage dispatch to the extension. D-92 events are `pact` types fired by cabana through `lagoon.AfterCommit`, and the SEO plugin derives the 301 by comparing resolved URLs before and after the change. D-93 descriptor functions become optional fields on `pact.MenuItemType`, including the admin controller ID. `sm-seo-plugin` exposes one service layer, used by its admin controllers, its D-91 extension hooks and a `/_seo/api/v1` JSON API, and pier tools bind to that API.
|
||||
|
||||
## Architectural Responsibility Map
|
||||
|
||||
| Capability | Primary Tier | Secondary Tier | Rationale |
|
||||
|------------|-------------|----------------|-----------|
|
||||
| Form extension placement (D-91) | API / Backend (cabana, boot) | Browser (SPA renders as compiled) | Order is compiled once at boot; the SPA must never reorder (C1) |
|
||||
| Extension field storage (Load/Save) | API / Backend (extension hooks in the save tx) | Database (SEO tables) | Owner's model and tables untouched (D-91) |
|
||||
| Record events (D-92) | API / Backend (cabana, after commit) | Plugins (listeners) | One emission point per write path; direct writers call a helper |
|
||||
| Content descriptors (D-93) | API / Backend (content plugins via signpost) | — | Content plugins never import SEO or sitemap |
|
||||
| SEO data, rules, redirects, history | Database / Storage (sm-seo-plugin tables) | API (service layer) | One shared table keyed by type, id, locale (D-01) |
|
||||
| Effective SEO resolution | API / Backend (public resolver endpoint) | Frontend Server (Nuxt layer, Phase 33) | Precedence baked into the resolver (D-02) |
|
||||
| Redirect / normalisation enforcement | Frontend Server (Nitro middleware, Phase 33) | API / Backend (decision endpoint; Go for `/robots.txt` and its own paths) | D-20a: whoever serves the page enforces |
|
||||
| robots.txt serving and staging lock | API / Backend (exact `GET /robots.txt` route) | CDN/proxy (nginx location per app) | Same deployment pattern as `/sitemap.xml` |
|
||||
| Verification files at site root | Frontend Server / proxy | API (content via `/_seo/api/v1`) | A Go `/{name}` route would shadow app catch-alls |
|
||||
| MCP tools | API / Backend (pier → `/_seo/api/v1`) | — | pier binds exact method + path routes |
|
||||
| SERP preview, counters, robots editor | Browser (plugin custom elements E1–E6) | API (widget actions) | Light-DOM elements through WidgetField/PluginField |
|
||||
|
||||
## Standard Stack
|
||||
|
||||
### Core (all already in the project)
|
||||
| Library | Version | Purpose | Why Standard |
|
||||
|---------|---------|---------|--------------|
|
||||
| Go stdlib `regexp` | Go 1.27 | Redirect regex sources | RE2, linear time: no catastrophic backtracking from admin- or MCP-supplied patterns [CITED: pkg.go.dev/regexp] |
|
||||
| Go stdlib `net/url`, `path` | Go 1.27 | URL normalisation, canonical building | Stdlib-first rule; no maintained normaliser library needed [ASSUMED: purell is archived] |
|
||||
| Go stdlib `encoding/csv` | Go 1.27 | CSV import/export | Stdlib; BOM and `;` delimiter handled by hand |
|
||||
| `gorm.io/gorm` | v1.31.2 | Models | Decided [VERIFIED: .planning/research/STACK.md:18] |
|
||||
| `github.com/go-gormigrate/gormigrate/v2` | v2.1.7 (as pinned by sm-sitemap-plugin) | Per-plugin migrations | Decided [VERIFIED: ../sm-sitemap-plugin/go.mod] |
|
||||
| `conga` (River) | framework | GenerateSeoEntries job, async purges | Decided (`pact.HasJobs`) |
|
||||
| `cooler.SiteCachePurger` | framework | Purge rendered pages after SEO changes | Exists: `SiteCachePurgeURLKey = "site_cache.purge_url"` [VERIFIED: modules/cooler/sitecache.go:26] |
|
||||
| `festival.Bus` (`app.Events`) | framework | Record events | Synchronous typed bus: "Dispatch is synchronous on the caller goroutine." [VERIFIED: modules/festival/bus.go:29-30] |
|
||||
| `testcontainers-go` + postgres module | v0.44.0 | Plugin DB tests | Decided, same as sm-sitemap-plugin |
|
||||
|
||||
### Supporting (new, needs a decision note)
|
||||
| Library | Version | Purpose | When to Use |
|
||||
|---------|---------|---------|-------------|
|
||||
| `github.com/jimsmart/grobotstxt` | v1.0.3 (2022-03-16) | Server-side robots.txt tester (E5 `robots_test`), `Sitemap:` extraction, D-24 "noindex URL blocked" check | Function-for-function port of Google's C++ robots.txt parser; exposes `RobotsMatcher.MatchingLine()` (the line E5 shows) and a `ParseHandler` with line numbers [CITED: pkg.go.dev/github.com/jimsmart/grobotstxt]. Apache-2.0 [CITED: github.com/jimsmart/grobotstxt]. Version and date [VERIFIED: proxy.golang.org @latest]. `[ASSUMED]` for legitimacy: the Go ecosystem is not covered by the package-legitimacy seam |
|
||||
|
||||
Element bundle (dev-only, `sm-seo-plugin/package.json`), same pins as the journal Blog Editor:
|
||||
| Package | Version | Purpose |
|
||||
|---------|---------|---------|
|
||||
| typescript | 5.9.3 | Element typecheck |
|
||||
| vite | 7.3.5 | ES module bundle for E1–E6 |
|
||||
| vitest | 3.2.7 | Element unit tests (UI-SPEC backstops) |
|
||||
| happy-dom | 20.11.6 | DOM for vitest |
|
||||
|
||||
[VERIFIED: ../sm-journal-plugin/package.json; `npm view` confirms each exact version exists]
|
||||
|
||||
### Alternatives Considered
|
||||
| Instead of | Could Use | Tradeoff |
|
||||
|------------|-----------|----------|
|
||||
| grobotstxt | `github.com/temoto/robotstxt` v1.1.2 (2021, MIT) | Older, its own parser, no matching-line API; the README does not document Google's longest-match semantics [CITED: github.com/temoto/robotstxt] |
|
||||
| grobotstxt | Hand-rolled RFC 9309 matcher (~200 lines) | Stdlib-first and no stale dependency, but protocol code the user prefers to take from a library. RFC 9309 is frozen, so a 2022 release of a faithful Google port is not a staleness risk in practice. **Decision for Jakub; recommend grobotstxt + decision note.** |
|
||||
| Own `/_seo/api/v1` routes for MCP | Binding pier tools to cabana's generic admin routes | Not workable: path segments would be agent-supplied arguments, and the routes sit behind `requireAjax` (see Pattern 7) |
|
||||
|
||||
**Installation:**
|
||||
```bash
|
||||
# sm-seo-plugin (Go)
|
||||
go get github.com/jimsmart/grobotstxt@v1.0.3 # only after the decision note is accepted
|
||||
# sm-seo-plugin (element bundle)
|
||||
npm install --save-dev --save-exact typescript@5.9.3 vite@7.3.5 vitest@3.2.7 happy-dom@20.11.6
|
||||
```
|
||||
|
||||
## Package Legitimacy Audit
|
||||
|
||||
| Package | Registry | Age | Downloads | Source Repo | Verdict | Disposition |
|
||||
|---------|----------|-----|-----------|-------------|---------|-------------|
|
||||
| github.com/jimsmart/grobotstxt | Go proxy | v1.0.3, 2022-03-16 | n/a (Go proxy has no counts) | github.com/jimsmart/grobotstxt | not run (seam supports npm/pypi/crates only) | `[ASSUMED]`: planner adds `checkpoint:human-verify` + decision note before `go get` |
|
||||
| typescript | npm | pinned 5.9.3 | 210M/wk | github.com/microsoft/TypeScript | OK | Approved |
|
||||
| vite | npm | pinned 7.3.5 | 144M/wk | github.com/vitejs/vite | SUS ("too-new", the *latest* release is 5 days old; the pin is older) | Flagged: `vite` [WARNING: flagged as suspicious — verify before using.] Pin exactly 7.3.5, the version already in sm-journal-plugin's lockfile |
|
||||
| vitest | npm | pinned 3.2.7 | 68M/wk | github.com/vitest-dev/vitest | SUS ("too-new", same reason) | Flagged: `vitest` [WARNING: flagged as suspicious — verify before using.] Pin exactly 3.2.7 |
|
||||
| happy-dom | npm | pinned 20.11.6 | 10M/wk | github.com/capricorn86/happy-dom | SUS ("too-new", same reason) | Flagged: `happy-dom` [WARNING: flagged as suspicious — verify before using.] Pin exactly 20.11.6 |
|
||||
|
||||
**Packages removed due to [SLOP] verdict:** none
|
||||
**Packages flagged as suspicious [SUS]:** vite, vitest, happy-dom. The flag comes from the publish date of the latest version, not of the pinned one. The pins match an approved sibling plugin, so the checkpoint can be a one-line confirmation. `postinstall` is null for all four.
|
||||
|
||||
## Architecture Patterns
|
||||
|
||||
### System Architecture Diagram
|
||||
|
||||
```
|
||||
┌──────────────────────── boot (party → signpost → Boot → surf → cabana.Activate → pier) ───────────────────────┐
|
||||
content plugin │ MenuItemTypes() + D-93 descriptor funcs ──► signpost.Registry (published on app) │
|
||||
(journal) │ │ │
|
||||
│ sm-seo-plugin.Boot reads registry ──► builds AdminFormExtensions (SEO tab per type, per-type settings tabs) │
|
||||
│ cabana.Activate: compileRegistry → compileFormExtensions(placement, boot errors) → compileActionExtensions │
|
||||
│ pier.Mount: binds SEO tools to /_seo/api/v1/* routes │
|
||||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
Admin editor ──PUT /backend/api/golem15/journal/posts/{id}──► cabana.save (one tx)
|
||||
│ ├─ lift extension values out of body (never reach Fill / owner columns)
|
||||
│ ├─ owner Fill, Validate, row write, translations
|
||||
│ ├─ extension Save(tx, record, values, changes) ──► seo entries + history (same tx)
|
||||
│ │ └─ returns per-field notices / FormFieldError (422, rolls back)
|
||||
│ └─ lagoon.AfterCommit ─► app.Events.Fire(pact.RecordSaved{...})
|
||||
│ │
|
||||
MCP client ─► pier ─► PUT /_journal/api/v1/posts/{id} (journal handler) ─────┤ cabana.EmitRecordSaved(helper) after commit
|
||||
▼
|
||||
sm-seo-plugin listener: re-resolve URLs via descriptor
|
||||
├─ URL changed? ── yes ─► redirect old→new (301), flatten chains, refuse loops,
|
||||
│ update entry URL, history (via=auto), site-cache purge
|
||||
└─ RecordDeleted ─► delete entries (history keeps the values)
|
||||
|
||||
Nuxt SSR (Phase 33 layer) ─GET /_seo/api/v1/resolve?url=…─► resolver
|
||||
├─ normalisation (one 301 hop) ├─ redirects (exact → pattern → regex) ├─ strict URL (descriptor Match → canonical 301)
|
||||
└─ effective SEO: URL rule > record entry > per-type template/global > descriptor-derived; + X-Robots-Tag value; + staging lock
|
||||
|
||||
Crawlers ─GET /robots.txt─► Go route: stored rules + AI-bot groups + Sitemap lines; non-production → "Disallow: /"; never 5xx
|
||||
```
|
||||
|
||||
### Recommended Project Structure (new repo `sm-seo-plugin`, module `git.golem15.com/golem15/sm-seo-plugin`, package `seo`, ID `golem15.seo`)
|
||||
|
||||
```
|
||||
sm-seo-plugin/
|
||||
├── plugin.go # party.Register, Requires(), Register/Boot (reads signpost, builds extensions)
|
||||
├── admin.go # AdminFS/LangFS embeds, AdminControllers, Navigation, Settings (link entry), Permissions
|
||||
├── extensions.go # AdminFormExtensions(): SEO tab per descriptor type; per-type tabs on own settings controller
|
||||
├── field_types.go # mlseotext/seotext, mlseorobots/seorobots, robotstxt (+ og image type if chosen, see Open Q)
|
||||
├── listeners.go # RecordSaved / RecordDeleted → redirects, entry cleanup
|
||||
├── routes.go # GET /robots.txt; /_seo/api/v1/* (public resolve + backend-guarded management)
|
||||
├── mcp.go # pact.HasMCP tools bound to /_seo/api/v1
|
||||
├── jobs.go # GenerateEntries job (conga), registered via pact.HasJobs
|
||||
├── classes/ # service layer: resolver, redirects graph, normaliser, robots, history, batch, csv, templates
|
||||
├── controllers/ # redirects, rules, notfound, history (list/form/preview), robots + transfer + settings (AdminSingleton)
|
||||
├── models/ # entry, revision(history), settings, type_settings, rule, redirect, notfound, robots
|
||||
├── updates/ # gormigrate migrations (timestamped IDs like sm-sitemap-plugin)
|
||||
├── lang/{en,pl}/lang.yaml # golem15.seo::lang.*
|
||||
├── assets/src/ # E1–E6 custom elements (Vite), assets/dist committed + scripts/check-dist.sh
|
||||
├── tests/ + *_test.go # testmain_test.go (testcontainers), fake content plugin fixture
|
||||
└── go.mod / go.work # replace framework => ../summercms.go (dev), require tagged framework at release
|
||||
```
|
||||
|
||||
### Pattern 1: D-91 form extension compiled after the registry
|
||||
|
||||
**What:** A new `pact` kind, compiled by cabana in `Activate` right after `compileRegistryWithTypes` and before `compileActionExtensions`/`compileContributions`. That is where the existing cross-plugin pass runs today:
|
||||
|
||||
```go
|
||||
// modules/cabana/http.go:135-143 (verbatim)
|
||||
// Contributed record actions are merged before compileContributions,
|
||||
// which validates every record action's permissions.
|
||||
if err := compileActionExtensions(reg, plugins); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := compileAccountContributions(reg, plugins); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := compileContributions(reg, plugins); err != nil {
|
||||
```
|
||||
[VERIFIED: modules/cabana/http.go:135-143]
|
||||
|
||||
The struct to extend, verbatim:
|
||||
```go
|
||||
type AdminActionExtension struct {
|
||||
Controller string
|
||||
RecordActions []AdminRecordAction
|
||||
}
|
||||
```
|
||||
[VERIFIED: modules/pact/capabilities.go:429-432], with the doc comment ending "Only record actions are carried for now; the struct leaves room for more kinds." [VERIFIED: modules/pact/capabilities.go:427-428]
|
||||
|
||||
**Recommended Go shape (Claude's discretion, sketch, all names `[ASSUMED]`):**
|
||||
```go
|
||||
// pact — added fields on AdminActionExtension keep existing keyed literals compiling.
|
||||
type AdminActionExtension struct {
|
||||
Controller string
|
||||
RecordActions []AdminRecordAction
|
||||
Form *AdminFormExtension // nil: no form contribution
|
||||
}
|
||||
|
||||
type AdminFormExtension struct {
|
||||
Fields string // path in the contributing plugin's AdminFS to a fields.yaml with placement keys
|
||||
Hide []string // owner field names removed from the compiled form
|
||||
Permissions []string // an admin without them gets no extension fields (schema, show, save)
|
||||
Visible func(ctx context.Context) bool // per request, like NavigationItem.Visible
|
||||
Actions []AdminAction // widget actions of the extension's `type: widget` fields
|
||||
PartialData func(ctx context.Context, name string, record any) (any, error)
|
||||
Load func(ctx context.Context, in AdminFormLoad) (map[string]any, error)
|
||||
Save func(ctx context.Context, in AdminFormSave) (AdminFormSaveResult, error)
|
||||
}
|
||||
```
|
||||
In the extension's fields file, each field takes the ordinary `fields.yaml` keys plus `before:`/`after:` (anchor field) and `zone:`. A top-level `tabs:` list places new tabs (`name`, `before`/`after`). Parsing the file with the existing `decodeFieldMapping`/`compileFieldNode` reuses every type, option and plugin-field-type check, and keeps YAML-defined admin forms consistent with the rest of the framework.
|
||||
|
||||
**Placement algorithm (compile once, deterministic):**
|
||||
1. Canonicalise the owner's list: group the fields by tab in first-appearance order. The default tab (no `tab`) comes first, as the SPA renders it. Within a tab, source order is kept. The rendered result is identical, because the SPA already groups this way.
|
||||
2. For each plugin in `party` order (already topologically sorted by `Requires()` [VERIFIED: modules/party/registry.go:103-104 `ordered, err := topoSort(selected, index)`]), apply its extension: insert its new tabs at `before`/`after` tab anchors, then its fields at `before`/`after` field anchors. With no anchor, a field goes to the end of its tab. Several extensions on the same anchor keep plugin order: insert after the last field that was inserted at that anchor (an "anchor cursor"), not directly after the anchor.
|
||||
3. Boot errors (each names the plugin, the controller and the anchor): an unknown field or tab anchor; an anchor that names a field from a plugin outside `Requires()`; a duplicate field name, whether against the owner or an earlier extension; a duplicate tab key; a cycle among an extension's own `before`/`after` references (topologically sort the extension's fields, and report a cycle when the sort stalls); `before:` the default tab (UI-SPEC C1); any `zone` other than the tab zone (UI-SPEC Q-1 default); `Hide` naming an unknown field or a field that another field's `fill`, `dependsOn`, `trigger` or `preset` references.
|
||||
4. Run the per-field compile steps again on the merged list, with an owner-aware branch (Pitfalls 3–6).
|
||||
|
||||
**SPA facts that make "no SPA change" true:**
|
||||
```ts
|
||||
// admin/src/components/form/formState.ts:21-26 (verbatim)
|
||||
export const DEFAULT_TAB = 'default'
|
||||
|
||||
/** Tab key of a field: its tab label, or the default tab. */
|
||||
export function tabOf(field: FormField): string {
|
||||
return field.tab ? `tab:${field.tab}` : DEFAULT_TAB
|
||||
}
|
||||
```
|
||||
[VERIFIED: admin/src/components/form/formState.ts:21-26]. `FormView.vue` builds `tabs` in first-appearance order and calls `out.unshift(tab)` only for `DEFAULT_TAB` [VERIFIED: admin/src/views/FormView.vue:151-171].
|
||||
|
||||
### Pattern 2: D-92 record events fired after commit
|
||||
|
||||
**What:** Use the established after-commit firing pattern. Event types live in `pact`, like `pact.MCPSubjectChanged`, so that subscribers depend only on `pact`.
|
||||
```go
|
||||
// modules/cabana/subject_events.go:31-41 (verbatim excerpt)
|
||||
tx, _ := TxFromContext(ctx)
|
||||
lagoon.AfterCommit(ctx, tx, func(ctx context.Context, _ *gorm.DB) {
|
||||
for _, id := range adminIDs {
|
||||
if id == 0 {
|
||||
continue
|
||||
}
|
||||
event := &pact.MCPSubjectChanged{Guard: backendSubjectGuard, UserID: id, Kind: kind}
|
||||
if err := app.Events.Fire(ctx, event); err != nil {
|
||||
moduleLog.WarnContext(ctx, "cabana: subject changed listener failed", "kind", kind, "admin_id", id, "error", err)
|
||||
}
|
||||
```
|
||||
[VERIFIED: modules/cabana/subject_events.go:31-41]. `runAfterCommit` calls each callback synchronously in a loop with a `recover` [VERIFIED: modules/lagoon/transaction.go:193-204], so listeners run before the HTTP response is written.
|
||||
|
||||
**Recommended shape (sketch, `[ASSUMED]` names):**
|
||||
```go
|
||||
// pact
|
||||
type RecordChange struct {
|
||||
Attribute string // column or ML field name; relation names for belongsTo keys
|
||||
Locale string // "" for non-translatable; the locale for ML values (translated slugs live in the translate table)
|
||||
Old, New any
|
||||
}
|
||||
type RecordSaved struct {
|
||||
Controller string // admin controller ID; "" for direct writes
|
||||
Model string // MorphName() when the model implements it, else TableName()
|
||||
ID string // primary key as text (uint and string keys)
|
||||
Created bool
|
||||
Changes []RecordChange
|
||||
}
|
||||
type RecordDeleted struct {
|
||||
Controller, Model, ID string
|
||||
}
|
||||
// cabana helper for direct writers (journal API handlers, record/bulk actions, console imports):
|
||||
func EmitRecordSaved(ctx context.Context, app *backpack.App, tx *gorm.DB, ev pact.RecordSaved)
|
||||
func EmitRecordDeleted(ctx context.Context, app *backpack.App, tx *gorm.DB, ev pact.RecordDeleted)
|
||||
```
|
||||
Emission points in cabana: `CRUDService.save` (create/update; snapshot the host columns after `loadRecord` and before `lagoon.Fill`, and read `TranslatedExact` for submitted ML fields before `applyMLTranslations`), `Delete`, `BulkDelete`, `reorderPost` (a tree move changes `parent_id`, and with it nested URLs), and the relation-manager child writes (`relation_child.go`). A listener error is logged and never fails the save, the same rule as `fireSubjectChanged`.
|
||||
|
||||
### Pattern 3: D-93 descriptors as optional `MenuItemType` fields
|
||||
|
||||
The current struct, verbatim:
|
||||
```go
|
||||
type MenuItemType struct {
|
||||
Key string
|
||||
Label string
|
||||
DefaultPattern string
|
||||
PatternFrom string
|
||||
Placeholders []string
|
||||
Nesting bool
|
||||
DynamicItems bool
|
||||
References func(ctx context.Context) ([]MenuItemReference, error) `json:"-"`
|
||||
Resolve func(ctx context.Context, in MenuItemResolve) (*ResolvedMenuItem, error) `json:"-"`
|
||||
}
|
||||
```
|
||||
[VERIFIED: modules/pact/capabilities.go:798-808]. The only implementer across the sibling repos is `sm-journal-plugin/classes/menu_item_types.go` (and its vendored copies in apps), and it uses keyed literals (`Key: MenuTypeCategory, …`) [VERIFIED: grep + ../sm-journal-plugin/classes/menu_item_types.go:100-110]. Adding fields is therefore source-compatible.
|
||||
|
||||
**Recommended additions (sketch, `[ASSUMED]`):**
|
||||
```go
|
||||
// D-93 content descriptor; all optional. A type with Content == nil takes no part.
|
||||
Content *ContentDescriptor `json:"-"`
|
||||
|
||||
type ContentDescriptor struct {
|
||||
Controller string // admin controller ID whose form edits the records (needed for D-91 targeting)
|
||||
Model string // the morph name the record events carry, to map events → type
|
||||
Records func(ctx context.Context, after string, limit int) ([]ContentRecord, string, error) // paged, for the generate job / registry / sitemaps
|
||||
Describe func(ctx context.Context, id string) (*ContentRecord, error)
|
||||
Match func(ctx context.Context, values map[string]string) (id string, ok bool, err error) // pattern placeholders → record, for D-11 ownership and D-20c strict URLs
|
||||
}
|
||||
type ContentRecord struct {
|
||||
ID string
|
||||
Published bool
|
||||
LastMod *time.Time
|
||||
Locales []ContentLocale // per locale: URL (same layering as Resolve), Title (H1), Description, Image URL, BodyWords
|
||||
}
|
||||
```
|
||||
`Controller` and `Model` are generic (a sitemap, a search indexer and an audit tool all need them) and name nothing SEO-specific. signpost gains read helpers (`ContentTypes()`, `TypeForModel(model)`, and `MatchPath(ctx, path)`, which compiles each type's layered pattern into a matcher). D-33 (Phase 33) later registers the page-registry types through the same struct.
|
||||
|
||||
### Pattern 4: SEO settings as an `AdminSingleton` controller, per-type tabs via D-91 on itself
|
||||
|
||||
A settings form refuses exactly the field kinds the UI-SPEC puts on the SEO settings screen:
|
||||
```go
|
||||
// modules/cabana/settings.go:96-104 (verbatim)
|
||||
fields, err := decodeFields(raw, types.refusing())
|
||||
...
|
||||
for _, field := range fields {
|
||||
// A settings screen has no admin controller to own actions or view models.
|
||||
if field.Type == "widget" || field.Type == "partial" || field.Type == "fileupload" || field.Type == permissionFieldType {
|
||||
return nil, fmt.Errorf("cabana: setting %s field %s: type %s is not supported on a settings form", item.Code, field.Name, field.Type)
|
||||
}
|
||||
```
|
||||
[VERIFIED: modules/cabana/settings.go:96-104]. `types.refusing()` also rejects plugin field types such as `seorobots`; the docstring above it reads "a settings form refuses them (supported in controller forms only)" [VERIFIED: modules/cabana/settings.go:71-72].
|
||||
|
||||
So: `golem15.seo.settings` implements `pact.AdminSingleton`. The tile is a link entry (`SettingsItem.Controller`, as sitemap does with `Controller: controllers.DefinitionsControllerID` [VERIFIED: ../sm-sitemap-plugin/admin.go:50]). Per-type tabs (`type_<key>_*`) cannot be model columns, because types are dynamic. The plugin registers one D-91 extension per descriptor type on its own settings controller, with Load/Save hooks against a `type_settings` table. This dogfoods the seam, and the UI-SPEC already allows it ("applies D-91 placement to its own settings form", C11).
|
||||
|
||||
### Pattern 5: One effective-SEO resolver, one service layer
|
||||
|
||||
- `classes.Resolver.Resolve(ctx, absoluteURL, locale) (Result, error)` runs, in order: the staging lock, normalisation (a single 301 to the final form), redirects (exact, then pattern, then regex), strict URL (descriptor `Match` → canonical URL; a mismatch gives a 301), then effective SEO with a per-value `source` (rule / record / template / global / content / default), and the `X-Robots-Tag` value.
|
||||
- Every writer (admin controllers' Form hooks, D-91 Save, `/_seo/api/v1` handlers, CSV import, record-event listeners) calls one service package, so history, loop checks and cache purges cannot be bypassed.
|
||||
- Public read: `GET /_seo/api/v1/resolve?url=…` (throttled; answers only published records; absolute URLs built from configured `app.url`/frontend URL, never from `Host`).
|
||||
|
||||
### Pattern 6: URL-diff 301 instead of attribute parsing (D-18)
|
||||
|
||||
On `RecordSaved`, call the type's `Describe(id)` to get the current per-locale URLs and compare them with the URLs stored on the SEO entries. Any difference creates `old → new` (301, origin "Address change"), flattens rules whose target is `old`, deletes any rule whose **source** equals `new` (otherwise the record would be shadowed), drops self-loops created by flattening, then updates the entry URL. This covers slug changes, translated-slug changes, category moves, parent changes and host pattern changes, without the listener knowing which attribute drives the URL. `RecordChange` values still let the extension's Save hook show the `redirects.auto_created` notice inside the same request.
|
||||
|
||||
### Pattern 7: MCP through the plugin's own routes
|
||||
|
||||
pier binds by exact method and pattern and looks the route up in the route table:
|
||||
```go
|
||||
// modules/pier/catalog.go:178-182 (verbatim)
|
||||
route, ok := routes[method+" "+pattern]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%s: binds to %s %s, which no plugin registers", errPrefix, method, pattern)
|
||||
}
|
||||
```
|
||||
[VERIFIED: modules/pier/catalog.go:178-182]. Cabana's admin routes are generic, e.g. `g.Put("/{vendor}/{plugin}/{controller}/{id}", requireAjax(s.update))` [VERIFIED: modules/cabana/http.go:371], and a pier `path:` field must be a required agent argument [VERIFIED: modules/pier/catalog.go:220-223]. Copy Journal's pattern instead: `/_journal/api/v1/...` routes with `Guard: "backend"` and declared `Permissions` [VERIFIED: ../sm-journal-plugin/mcp.go:14-20, 78-100; ../sm-journal-plugin/routes.go:14-34]. The handlers detect MCP calls with `bouncer.Dispatched(ctx, "backend")` [VERIFIED: modules/bouncer/dispatch.go:40] and record `via = mcp` in history.
|
||||
|
||||
### Pattern 8: Dry-run by rollback, apply by token, undo with a staleness guard
|
||||
|
||||
- Batch: run the batch in `lagoon.Transaction`, collecting the diff and conflicts; on `dry_run` return the diff and roll back on purpose. Validation then runs the same code in both modes. Apply is the same call without the rollback, all-or-nothing (D-12).
|
||||
- E6 apply token: an HMAC over (dataset, normalised rows, the data fingerprint of the touched rows). Apply runs the dry-run again and refuses with `transfer.stale` when the fingerprint differs (UI-SPEC C13).
|
||||
- History: one revision row per changed object with `batch_id`, `author`, `via`, `before`/`after` jsonb. Undo refuses when the current value differs from `after` (`history.undo_stale`), when the undo would create a loop (`history.undo_loop`), or when the record is gone (`history.undo_gone`). An undo is itself a new revision (`via = undo`).
|
||||
|
||||
### Anti-Patterns to Avoid
|
||||
- **Putting SEO columns on content models or naming SEO in framework code:** violates D-90.
|
||||
- **Binding extension fields through `BindWritableFields`:** the binding refuses any scalar field that is not a model column (`"cabana: controller " + id + ": field " + field.Name + " is not a model column"` [VERIFIED: modules/cabana/crud.go:256]). Extension fields must be lifted out before projection.
|
||||
- **A Go `GET /{name}` route for verification files:** it is more specific than an app's `GET /` and would capture every one-segment page of a statically served site (summercms.io serves its site through `g.Get("/", site.ServeHTTP)` [VERIFIED: ../sm-summercmsio-app/plugins/golem15/summercms/plugin.go:62-65]).
|
||||
- **Answering 5xx on `/robots.txt`:** Google stops crawling for 12 hours, then uses a cached copy [CITED: developers.google.com/search/docs/crawling-indexing/robots/robots_txt].
|
||||
- **Building canonical/absolute URLs from the request `Host`:** cache poisoning and host-header injection; use the configured site URL.
|
||||
|
||||
## Don't Hand-Roll
|
||||
|
||||
| Problem | Don't Build | Use Instead | Why |
|
||||
|---------|-------------|-------------|-----|
|
||||
| robots.txt matching (longest match, allow wins ties, `*`/`$`, UA groups) | Own matcher | grobotstxt (decision note) | Google semantics have many edge cases; the tester must agree with Googlebot |
|
||||
| Regex engine for redirect sources | PCRE-style lib | stdlib `regexp` | RE2 guarantees linear time on untrusted patterns |
|
||||
| After-commit event dispatch | Goroutines / channels | `lagoon.AfterCommit` + `app.Events.Fire` | Rolled-back saves fire nothing; the existing pattern is proven |
|
||||
| Site cache invalidation | New HTTP purge client | `cooler.SiteCachePurger` / `PurgeSiteCacheAfterCommit` [VERIFIED: modules/cooler/sitecache.go:302] | Coalescing, loopback checks, token rules exist |
|
||||
| Admin forms for redirects/rules/404/history | Custom SPA screens | cabana lists, forms, previews, record/bulk actions | UI-SPEC: "no SPA change" |
|
||||
| MCP plumbing | Own MCP server | `pact.HasMCP` → pier | One endpoint, grants, audit |
|
||||
| CSV | Own parser | `encoding/csv` (+ BOM strip/prepend, `;` delimiter) | Quoting rules |
|
||||
| Job queue for entry generation | goroutine loops | `conga` (`pact.HasJobs`) | Retries, one pool |
|
||||
|
||||
**Key insight:** most of this phase is composition. The only new algorithms are field placement, redirect graph maintenance (flatten, loop detection), normalisation and the precedence resolver. Each is a pure function that can be unit-tested without a database.
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
### Pitfall 1: Tabs merge by localized label in the SPA
|
||||
**What goes wrong:** `tabOf` keys tabs by `tab:${field.tab}`, and cabana localizes `field.Tab` per request (`field.Tab = translateKey(ctx, tr, src.Tab)` [VERIFIED: modules/cabana/form_schema.go:331]). Two different tab keys that translate to the same text in some locale merge into one tab.
|
||||
**How to avoid:** check duplicate tab keys on the raw key at boot, and also check that localized labels do not collide for each locale the phrasebook loads (the translator is available in `Activate`).
|
||||
|
||||
### Pitfall 2: Interleaved owner tabs make "after tab X" ambiguous
|
||||
**What goes wrong:** Journal post fields interleave tabs (title/slug/content in Edit, excerpt in Manage, categories/tags in Categories, then published/is_pinned/user/published_at/featured_images back in Manage [VERIFIED: ../sm-journal-plugin/models/post/fields.yaml:2-72]). "After Manage" by field index is ill-defined.
|
||||
**How to avoid:** canonicalise to tab-grouped order first (Pattern 1, step 1). Consequence for the UI-SPEC: the Post tab order is **Edit | Manage | Categories | SEO** (first appearance), not "Edit | Categories | Manage | SEO" as written in C3.
|
||||
|
||||
### Pitfall 3: Extension widgets fail the owner's widget checks
|
||||
**What goes wrong:** `compileExtension` checks the widget tag against the **owner's** plugin prefix, requires `fill` keys to be writable scalar fields, and requires the owner controller to declare `AdminClientAssets` JS: `"field %s: fill %s is not a writable scalar field"` and `"field %s: a widget needs the controller to declare its JS through pact.AdminClientAssets"` [VERIFIED: modules/cabana/extension.go:132, 145, 150]. E3 (`golem15-seo-serp`, fill `seo_title`/`seo_description`/`seo_keyphrase`) fails all three on `golem15.journal.posts`.
|
||||
**How to avoid:** for extension fields, check the prefix against the contributing plugin, accept fill keys that are fields of the same extension, accept the contributing plugin's field-type scripts as the element source, and dispatch `widgets/{field}` to `AdminFormExtension.Actions` (name collisions with the owner's actions are a boot error).
|
||||
|
||||
### Pitfall 4: Extension partials resolve against the owner's files
|
||||
**What goes wrong:** `compilePartials` reads `path.Join(dir, "_"+name+".htm")` from the owner's FS and requires the owner controller to implement `pact.AdminPartialData` [VERIFIED: modules/cabana/extension.go:231-233]. P1/P2 would fail the boot.
|
||||
**How to avoid:** compile extension partials from the contributing plugin's AdminFS, dispatch them to `AdminFormExtension.PartialData`, and refuse a partial name that clashes with the owner's. The view-model guard (no GORM models) applies unchanged.
|
||||
|
||||
### Pitfall 5: `fileupload` cannot be an extension field as-is
|
||||
**What goes wrong:** `compileFileFields` requires the owner's model to implement `attach.Owner` and to declare the field in `AttachRelations` (`"is not an attachment relation the model declares in AttachRelations"` [VERIFIED: modules/cabana/field_file.go:309-326]). The UI-SPEC's `seo_og_image` (C3 #10) cannot attach to a Journal post without touching its model.
|
||||
**How to avoid:** choose one (Open Question 2): (a) D-91 lets an extension declare an attachment owner of its own (the SEO entry), which touches upload, deferred binding and hydration; (b) an `seoimage` plugin field type using `pact.FormFieldType.Upload` ("Upload, when set, stores a file the element uploads and returns its URL." [VERIFIED: modules/pact/capabilities.go:531-532]), stored as a file reference in the entry. Recommendation: (b) for Phase 32. It needs a seventh element, E7, which is a UI-SPEC delta.
|
||||
|
||||
### Pitfall 6: Translatable plugin field types write to the host column
|
||||
**What goes wrong:** `FormFieldType.Translatable` means "the default locale in the host column, the others as translations" [VERIFIED: modules/pact/capabilities.go:519-521]. An `mlseotext` extension field would write into the owner's columns.
|
||||
**How to avoid:** for extension fields, run `Decode` (validation and notices) but divert storage to `AdminFormExtension.Save` as `map[locale]string`. On show, run the extension `Load` first and the type's `Load` after it.
|
||||
|
||||
### Pitfall 7: Hidden SEO fields must also be skipped on save
|
||||
**What goes wrong:** the per-request removal (`hiddenSchemaFields` [VERIFIED: modules/cabana/http.go:857-866]) is cabana-internal and schema-only. An admin without `golem15.seo.manage` could still post `seo_*` keys.
|
||||
**How to avoid:** apply `Permissions`/`Visible` in schema, show and save. On save, drop the keys and skip `Save` when the extension is not visible, so stored values stay untouched (UI-SPEC C1 "Permission").
|
||||
|
||||
### Pitfall 8: Journal's MCP writes bypass cabana
|
||||
**What goes wrong:** Journal's MCP tools bind to `PUT /_journal/api/v1/posts/{id}` and the other `/_journal/api/v1` write routes, which its own handlers serve [VERIFIED: ../sm-journal-plugin/routes.go:25-33; ../sm-journal-plugin/mcp.go:78-100]. A slug changed through MCP creates no `RecordSaved`, so no 301.
|
||||
**How to avoid:** Journal's `Store`/`Update`/`Destroy` (and featured-image writes, if they ever affect the URL) call the cabana helper inside their transaction. This is a Phase 32 change in sm-journal-plugin. D-96 lists only "descriptors" for Journal, so flag the extra change to Jakub as a consequence of D-92.
|
||||
|
||||
### Pitfall 9: Tags have no menu item type, and some hosts have no tag pages
|
||||
**What goes wrong:** Journal registers `journal-category`, `all-journal-categories`, `journal-post`, `all-journal-posts`, `category-journal-posts` and no tag type [VERIFIED: ../sm-journal-plugin/classes/menu_item_types.go:20-26]. SC-2 requires the SEO tab on tags. The grzyby layer config sets `tag: false` [VERIFIED: ../sm-grzybyfunkcjonalne-app/vue-grzybyfunkcjonalne-app/nuxt.config.ts:23-26], while signpost requires a `DefaultPattern` starting with "/" for every type [VERIFIED: modules/signpost/signpost.go:79-81].
|
||||
**How to avoid:** add a `journal-tag` type with a descriptor, and give hosts a way to say "this type has no public URL here" (for example `ContentDescriptor` answering no URL when a host config flag is off). The SEO tab still shows; the resolver and P2 show `effective.no_url`.
|
||||
|
||||
### Pitfall 10: Loop detection for patterns and regex is not a graph walk
|
||||
**What goes wrong:** cycles among exact rules are found by following targets. A pattern rule such as `/old/*` → `/old/new/*` loops forever, and a regex source cannot be enumerated.
|
||||
**How to avoid:** at save, simulate. Take the rule's target, or a probe instance of a pattern source with `*` replaced by a probe token. For regex, build a probe string by walking `regexp/syntax` literals where that is possible. Run the full resolver up to N=10 hops: a repeated URL means a loop (refused), more than one hop means a chain (saved with a notice). At runtime the resolver also stops at N hops and answers 404 plus a log line. It never redirects in circles.
|
||||
|
||||
### Pitfall 11: Slug changed back and forth
|
||||
**What goes wrong:** A→B and then B→A produce `A→B` plus `B→A`, a loop that flattening turns into `A→A`.
|
||||
**How to avoid:** when creating `old→new`, first delete rules whose source is `new`, then flatten, then drop self-loops. Test case: A→B→A→C ends with exactly `A→C` and `B→C`.
|
||||
|
||||
### Pitfall 12: Old values of translated slugs are invisible to a column snapshot
|
||||
**What goes wrong:** Journal's slug is translatable (`Translatable()` includes `"slug"`, with `TranslatableIndexes()` `{"slug"}` [VERIFIED: ../sm-journal-plugin/models/post.go:43-47]). The non-default values live in the translate plugin's table, written through `TranslationWriter.WriteTranslated` [VERIFIED: modules/cabana/field_ml.go:31-33].
|
||||
**How to avoid:** read `TranslatedExact` for the submitted ML fields before writing them, and emit per-locale `RecordChange`s. The URL-diff approach (Pattern 6) does not depend on this, but the event shape promises old/new values.
|
||||
|
||||
### Pitfall 13: Lowercasing paths changes resources
|
||||
**What goes wrong:** lowercasing non-ASCII letters (`Ł` → `ł`) changes the path, while percent-encoding hex case is equivalent. Blindly lowercasing `%C5%81` to `%c5%81` is harmless, but lowercasing decoded text is not.
|
||||
**How to avoid:** lowercase only ASCII letters of the decoded path, keep the switch off by default (UI-SPEC Q-7), and test with Polish slugs.
|
||||
|
||||
### Pitfall 14: Body and payload caps
|
||||
**What goes wrong:** widget action payloads are capped at 64 KiB and `Data` at 256 KiB [VERIFIED: modules/pact/capabilities.go:242, 259]. The default HTTP body limit is `default_bytes: 1048576` in the app template [VERIFIED: internal/build/stubs/new.tmpl:26], and pier's `mcp.max_result_bytes` defaults to 1 MiB (pier README).
|
||||
**How to avoid:** a 60 KB admin import limit (UI-SPEC Q-8), MCP imports in chunks of at most about 900 KB, exports paged.
|
||||
|
||||
### Pitfall 15: Route-pattern drift between Nuxt and signpost
|
||||
**What goes wrong:** the frontend routes live in the layer config, and the same patterns are mirrored in Go config `menu_items.patterns` (grzyby keeps them in `config/menu_items.yaml` [VERIFIED: ../sm-grzybyfunkcjonalne-app/config/menu_items.yaml:1-7]). When they drift, strict URLs 301 valid pages.
|
||||
**How to avoid:** the resolver's strict-URL check uses only signpost patterns. Add a boot or deploy check in the apps, and note it for the Phase 33 layer (the layer could read patterns from an API).
|
||||
|
||||
## Code Examples
|
||||
|
||||
### Event listener registration (festival generic method; Go 1.27 generic methods are already used in the codebase)
|
||||
```go
|
||||
// Source: modules/festival/bus.go:43-46 signature (verbatim): func (b *Bus) Listen[T any](owner string, fn func(context.Context, T) error)
|
||||
app.Events.Listen("golem15.seo", func(ctx context.Context, ev *pact.RecordSaved) error {
|
||||
return p.service.OnRecordSaved(ctx, ev) // URL diff → redirect, flatten, entry update, history(via=auto), purge
|
||||
})
|
||||
```
|
||||
(`pact.RecordSaved` is the proposed type `[ASSUMED]`.)
|
||||
|
||||
### Detecting an MCP call for history
|
||||
```go
|
||||
// Source: modules/bouncer/dispatch.go:40 — func Dispatched(ctx context.Context, guard string) (*Dispatch, bool)
|
||||
via := "admin"
|
||||
if _, ok := bouncer.Dispatched(r.Context(), "backend"); ok {
|
||||
via = "mcp"
|
||||
}
|
||||
```
|
||||
|
||||
### Wildcard source → anchored regex (stdlib)
|
||||
```go
|
||||
func wildcardRegexp(src string, ignoreCase bool) (*regexp.Regexp, error) {
|
||||
quoted := regexp.QuoteMeta(src) // "/old/\\*"
|
||||
expr := "^" + strings.ReplaceAll(quoted, `\*`, `(.*)`) + "$"
|
||||
if ignoreCase {
|
||||
expr = "(?i)" + expr
|
||||
}
|
||||
return regexp.Compile(expr)
|
||||
}
|
||||
```
|
||||
|
||||
### robots.txt test with the matching line (grobotstxt)
|
||||
```go
|
||||
// Source: pkg.go.dev/github.com/jimsmart/grobotstxt — NewRobotsMatcher, AgentAllowed, MatchingLine
|
||||
m := grobotstxt.NewRobotsMatcher()
|
||||
allowed := m.AgentAllowed(robotsBody, agent, absoluteURL)
|
||||
line := m.MatchingLine() // 0 when no rule matched → E5 "allowedNone"
|
||||
```
|
||||
|
||||
## State of the Art
|
||||
|
||||
| Old Approach | Current Approach | When Changed | Impact |
|
||||
|--------------|------------------|--------------|--------|
|
||||
| `noarchive` honoured by Google | "no longer used by Google Search" (cache link removed); Bing still reads it | Google docs, current | Keep the directive (D-08), but the UI should not imply a Google effect [CITED: developers.google.com/search/docs/crawling-indexing/robots-meta-tag] |
|
||||
| `crawl-delay` | Ignored by Google; supported by Bing/Yandex and Anthropic bots | current | E4 lint message `crawlDelay` is accurate [CITED: Google robots.txt doc; support.claude.com/en/articles/8896518] |
|
||||
| Ad-hoc robots parsing | RFC 9309 (2022) standard; Google 500 KiB limit | 2022 | E4/Decode 500 KB cap matches [CITED: Google robots.txt doc] |
|
||||
| WinterCMS `extendFormFields` mutation | Compiled placement at boot (D-91) | this phase | Deterministic, testable order |
|
||||
|
||||
**Deprecated/outdated:**
|
||||
- WinterCMS `viewBag[meta_title]` per-page SEO: replaced by the SEO tab plus URL rules.
|
||||
- The AI bot list in UI-SPEC C10 omits `Claude-User`, Anthropic's user-initiated fetcher [CITED: support.claude.com/en/articles/8896518]. Other operators' user-fetch agents (for example `Perplexity-User`) are `[ASSUMED]` and should be checked. This goes to Dawid under Q-6.
|
||||
|
||||
## Assumptions Log
|
||||
|
||||
| # | Claim | Section | Risk if Wrong |
|
||||
|---|-------|---------|---------------|
|
||||
| A1 | Go shapes of `AdminFormExtension`, `RecordSaved`/`RecordDeleted`, `ContentDescriptor` and helper names | Patterns 1–3 | One-way API: the shape needs Jakub's review before the release tag |
|
||||
| A2 | grobotstxt is a faithful, safe port suitable for production | Standard Stack | A wrong tester answer; mitigated by golden tests against Google's documented examples |
|
||||
| A3 | The framework release after the seams is `v0.6.0` (minor bump over `v0.5.0`) | Release | Tag naming only |
|
||||
| A4 | Phase 32 delivers the decision endpoint for redirects, normalisation and strict URLs; enforcement in Nuxt is Phase 33 (the layer) | Arch map | If Jakub expects enforcement in 32, a Nitro middleware task is missing |
|
||||
| A5 | purell (URL normaliser) is archived, so the stdlib is used | Standard Stack | None (stdlib is chosen anyway) |
|
||||
| A6 | The 404 log is fed by an authenticated server-to-server report from the frontend (a shared token like the site-cache purge), not by a public endpoint | Security | Log flooding if left public |
|
||||
| A7 | Other AI user-fetch tokens (for example Perplexity-User) | State of the Art | Bot list completeness (Dawid, Q-6) |
|
||||
| A8 | `sm-seo-plugin` repo creation on git.golem15.com is a human step (`git ls-remote` answered "Cannot find repository") | Environment | Blocks the first push |
|
||||
|
||||
## Open Questions
|
||||
|
||||
1. **Zones (D-91 vs UI-SPEC Q-1).**
|
||||
- What we know: the SPA renders one tab zone, and fields.yaml has no `tabs:`/`secondaryTabs:` blocks.
|
||||
- What's unclear: whether Jakub accepts "tab zone only, other zones are a boot error" for the published API.
|
||||
- Recommendation: put `Zone` in the struct now (it is one-way API) and accept only the tab zone in Phase 32.
|
||||
2. **OG image on extension fields (Pitfall 5).**
|
||||
- Recommendation: an `seoimage` plugin field type with `Upload` (E7), recorded as a UI-SPEC delta. The alternative is extension-owned attachments in D-91.
|
||||
3. **Journal changes beyond D-96.** The API handlers must emit record events (Pitfall 8), and a `journal-tag` type is needed (Pitfall 9).
|
||||
- Recommendation: include both in the Phase 32 Journal plan and tell Jakub.
|
||||
4. **Where Go enforces redirects.** No framework hook exists for "any unmatched path" (surf only wraps ServeMux 404/405 into the error page [VERIFIED: modules/surf/errorpage.go:328-359]). A fourth seam would be needed for Go-served static sites.
|
||||
- Recommendation: none in Phase 32. The Nuxt layer enforces in Phase 33, and static-site plugins can call the resolver service later.
|
||||
5. **Verification files at the site root.** Serve their content from `/_seo/api/v1/verification/{name}` and map root paths in the Phase 33 layer (or an nginx regex location).
|
||||
6. **grobotstxt vs hand-rolled RFC 9309.** Jakub decides; a decision note is needed either way.
|
||||
7. **Settings tile entry type.** It must be a `SettingsItem.Controller` link to an `AdminSingleton`, not `Form` (Pattern 4). This changes UI-SPEC C2's wording; the rendered result is unchanged.
|
||||
|
||||
## Environment Availability
|
||||
|
||||
| Dependency | Required By | Available | Version | Fallback |
|
||||
|------------|------------|-----------|---------|----------|
|
||||
| Go toolchain | all Go code | ✓ | go1.27.2 | — |
|
||||
| Node / npm | admin SPA tests, element bundle | ✓ | v24.22.0 / 12.2.1 | — |
|
||||
| Docker daemon | testcontainers suites | ✓ (`docker ps` works, ryuk running) | 29.9.1 | `sudo -u golem` per CLAUDE.md if the socket is denied |
|
||||
| PostgreSQL client | manual checks | ✓ | psql 18.6 | testcontainers |
|
||||
| `sm-seo-plugin` remote repo | first push, app submodules | ✗ | — | Human creates `golem15/sm-seo-plugin` on git.golem15.com |
|
||||
| graphify | graph context | ✗ (disabled) | — | not needed |
|
||||
| msd package-legitimacy for Go | Go dependency audit | ✗ (npm/pypi/crates only) | — | Manual proxy.golang.org check + decision note |
|
||||
|
||||
**Missing dependencies with no fallback:** the remote repository for `sm-seo-plugin` (human checkpoint).
|
||||
|
||||
**Missing dependencies with fallback:** Go legitimacy seam (manual check).
|
||||
|
||||
## Validation Architecture
|
||||
|
||||
### Test Framework
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Framework | Go `testing` (+ testify), testcontainers-go v0.44.0 Postgres; vitest 3.2.7 + happy-dom 20.11.6 for admin and elements |
|
||||
| Config file | none for Go; `admin/vitest.config.ts`; `sm-seo-plugin/vite.config.ts` (Wave 0) |
|
||||
| Quick run command | `go test -short ./modules/cabana ./modules/pact ./modules/signpost` and `go -C ../sm-seo-plugin test -short ./...` |
|
||||
| Full suite command | `go vet ./... && go test ./...` (framework), the same in `sm-seo-plugin`, `sm-journal-plugin`, `sm-demo-app`; `npm --prefix admin run test`; `npm --prefix ../sm-seo-plugin run test`; `scripts/check-phase32.sh --all` |
|
||||
|
||||
### Phase Requirements → Test Map
|
||||
| Req ID | Behavior | Test Type | Automated Command | File Exists? |
|
||||
|--------|----------|-----------|-------------------|-------------|
|
||||
| SC-1 | C after A → A, C, B; C before first; new tab between tabs; two plugins on one anchor keep order; hide field; default-tab-first; span preserved | unit (pure compile, no DB) | `go test -short ./modules/cabana -run 'TestFormExtension'` | ❌ Wave 0 |
|
||||
| SC-1 | Boot errors: unknown field/tab anchor, anchor outside `Requires()`, duplicate field/tab, cycle, `before` default tab, unsupported zone, hide of referenced field | unit | `go test -short ./modules/cabana -run 'TestFormExtensionBootErrors'` | ❌ Wave 0 |
|
||||
| SC-1 | Extension Load/Save in the save tx: rollback on Save error, 422 per field, notices per field, owner columns untouched, hidden extension skipped on save | integration (testcontainers) | `go test ./modules/cabana -run 'TestFormExtensionSave'` | ❌ Wave 0 |
|
||||
| SC-1 | SPA renders compiled order A, C, B; tab-less form + extension tab renders "Basic", then the new tab (UI-SPEC C1 backstop) | vitest | `npm --prefix admin run test -- tests/form/FormView.test.ts` | ✅ file exists, add cases |
|
||||
| SC-2 | D-93 descriptor optional fields: types without `Content` unchanged; `MatchPath` maps the layered pattern → record | unit | `go test -short ./modules/signpost ./modules/pact -run 'TestContent'` | ❌ Wave 0 |
|
||||
| SC-2 | Precedence URL rule > record > template/global > derived, with per-value source; staging lock forces noindex | unit (pure resolver with fakes) | `go -C ../sm-seo-plugin test -short ./classes -run TestResolverPrecedence` | ❌ Wave 0 |
|
||||
| SC-2 | SEO tab on posts, categories and tags via a fake content plugin; Journal never imports sm-seo-plugin | integration + gate grep | `go -C ../sm-seo-plugin test ./... -run TestSEOTab`; `check-phase32.sh` greps `../sm-journal-plugin` for `sm-seo-plugin` | ❌ Wave 0 |
|
||||
| SC-2 | Demo app boots with journal + seo; `golem15.journal.posts` form schema contains the SEO tab after Manage | integration (app) | `go -C ../sm-demo-app test ./... -run TestSEOTabMounted` | ❌ Wave 0 |
|
||||
| SC-3 | Redirect graph: flatten A→B,B→C ⇒ A→C; slug back-and-forth; loop refusal for exact/pattern/regex probes; chain notice; N-hop runtime stop | unit (pure) | `go -C ../sm-seo-plugin test -short ./classes -run 'TestRedirectGraph'` | ❌ Wave 0 |
|
||||
| SC-3 | cabana save changing slug fires `RecordSaved` after commit (not on rollback); listener creates 301 | integration | `go test ./modules/cabana -run TestRecordEvents` and `go -C ../sm-seo-plugin test ./... -run TestSlugChange301` | ❌ Wave 0 |
|
||||
| SC-3 | Journal API `PUT /_journal/api/v1/posts/{id}` slug change emits the event (MCP path) | integration | `go -C ../sm-journal-plugin test ./... -run TestAPIRecordEvents` | ❌ Wave 0 |
|
||||
| SC-3 | Loops refused from admin (422), MCP API (4xx tool error), CSV import (refused row) | integration | `go -C ../sm-seo-plugin test ./... -run 'TestLoopRefused'` | ❌ Wave 0 |
|
||||
| SC-4 | Every SEO admin operation has a tool: compile pier catalog in a tagged test app; tool route list matches the declared operation list | integration (`-tags summercms_mcp`) | `go -C ../sm-demo-app test -tags summercms_mcp ./... -run TestSEOToolsCatalog` | ❌ Wave 0 |
|
||||
| SC-4 | Batch dry-run returns the diff and conflicts and writes nothing; apply all-or-nothing; undo change and batch; stale undo refused | integration | `go -C ../sm-seo-plugin test ./... -run 'TestBatch|TestUndo'` | ❌ Wave 0 |
|
||||
| SC-4 | Element backstops (E1 thresholds, E2 grammar round-trip, E3 effective title + stem matching, E4 lint rules, E6 apply gating) | vitest | `npm --prefix ../sm-seo-plugin run test` | ❌ Wave 0 |
|
||||
| SC-5 | Framework tag exists and consumers build against it; docs checker green | gate | `scripts/check-phase32.sh --all`, `summer docs:build --check`, `go test ./cmd/summer -run TestDocsTree` | ❌ Wave 0 |
|
||||
|
||||
### Sampling Rate
|
||||
- **Per task commit:** `go vet ./... && go test -short ./...` in the touched repo (+ `npm --prefix admin run test` if `admin/` changed).
|
||||
- **Per wave merge:** the full `go test ./...` with Docker in each touched repo, `scripts/check-admin-openapi.sh --check` if cabana payloads changed.
|
||||
- **Phase gate:** `scripts/check-phase32.sh --all` green (self-test, go, plugins, consumers, docker, admin, docs, marker-style "framework names no SEO / no consuming app" grep) before `/msd-verify-work`.
|
||||
|
||||
### Wave 0 Gaps
|
||||
- [ ] `modules/cabana/form_extension_test.go`: placement and boot-error tables (fake plugins, `CompileFormWithTypes` fixtures in `testdata/`)
|
||||
- [ ] `modules/cabana/record_events_test.go`: after-commit and rollback behaviour (testcontainers, the existing cabana TestMain)
|
||||
- [ ] `modules/signpost` content-descriptor tests
|
||||
- [ ] `sm-seo-plugin/testmain_test.go` (copy sm-sitemap-plugin's: `flag.Parse()` + `testing.Short()`), plus a fake content plugin fixture registering a `MenuItemType` with `Content` and an admin controller
|
||||
- [ ] `sm-seo-plugin/package.json`, `vite.config.ts`, `vitest` setup (copy the journal Blog Editor)
|
||||
- [ ] `scripts/check-phase32.sh` modelled on `scripts/check-phase19.7.sh` (stages self-test/go/plugins/consumers/docker/admin/docs), with a grep stage: no `seo`/`SEO` identifiers added under `modules/` (D-90), and no consuming app named
|
||||
- [ ] Fixture: a `journal-tag` menu item type test in sm-journal-plugin
|
||||
|
||||
## Security Domain
|
||||
|
||||
### Applicable ASVS Categories
|
||||
|
||||
| ASVS Category | Applies | Standard Control |
|
||||
|---------------|---------|-----------------|
|
||||
| V2 Authentication | no (reuses cabana backend guard and pier identity) | `bouncer` backend guard; pier OAuth/personal tokens |
|
||||
| V3 Session Management | no | existing |
|
||||
| V4 Access Control | yes | `golem15.seo.manage` on every admin controller, extension (`Permissions`), `/_seo/api/v1` management route and MCP tool (`Permissions` + route check); read grants see only GET tools (pier ceiling) |
|
||||
| V5 Input Validation | yes | Field-type `Decode` (`FormFieldError`), `lagoon.Validate` rules; URL sources must start with `/`; targets path or http(s) only; regex compiled with stdlib and length-capped; robots.txt ≤ 500 KB; verification file names `^[A-Za-z0-9._-]+\.(html|txt|xml)$` without slashes |
|
||||
| V6 Cryptography | limited | HMAC import tokens via stdlib `crypto/hmac` keyed by the app key; never hand-roll |
|
||||
| V12 Files | yes | CSV size caps; OG image upload through the framework upload path and its limits |
|
||||
| V13 API | yes | Public `resolve` answers only published content; throttled; JSON only |
|
||||
| V14 Configuration | yes | Non-production lock decided by `app.Config.Environment()` (used the same way in surf/cabana [VERIFIED: modules/surf/router.go:732]); cannot be disabled from the admin |
|
||||
|
||||
### Known Threat Patterns for this stack
|
||||
|
||||
| Pattern | STRIDE | Standard Mitigation |
|
||||
|---------|--------|---------------------|
|
||||
| Open redirect via pass-through query or regex capture into an external host | Tampering | Targets set only by authorized editors; capture substitution only into the path part; external targets only when the rule's target literal is absolute |
|
||||
| ReDoS from admin- or MCP-supplied regex | DoS | stdlib RE2 (linear); cap pattern length and rule count; precompile once |
|
||||
| Host-header injection into canonical or absolute URLs | Spoofing | Build from configured site URL, never `r.Host` |
|
||||
| Draft leakage through `resolve` | Info disclosure | Descriptor `Published` gate; unpublished → 404 semantics |
|
||||
| 404-log flooding | DoS | Server-to-server report with a shared token (A6), URL length cap, row cap, throttle |
|
||||
| CSV formula injection on export | Tampering | Prefix cells starting with `= + - @ \t \r` with `'` |
|
||||
| Stored XSS via SEO strings in admin partials | Tampering | `html/template` escaping and cabana's partial sanitizer (`sanitizePartialNodes` [VERIFIED: modules/cabana/partial_render.go:144]) |
|
||||
| Staging copy indexed | Info disclosure | Forced `Disallow: /` + `X-Robots-Tag: noindex` by environment, not by stored setting (D-22) |
|
||||
| Privilege bypass by posting hidden extension fields | Elevation | Pitfall 7: extension visibility enforced on save |
|
||||
|
||||
## Release and Sequencing Notes (SC-5)
|
||||
|
||||
- Framework tags so far: `v0.5.0` is the latest [VERIFIED: `git tag --sort=-v:refname`]. The seams are additive, so recommend `v0.6.0` [ASSUMED].
|
||||
- Order: framework seams (with `replace` during development) → sm-journal-plugin descriptors and event emission → `sm-seo-plugin` → sm-demo-app mounts both (the demo has MCP config `config/mcp.yaml` and mounts journal and sitemap [VERIFIED: ../sm-demo-app/summer.yaml, ../sm-demo-app/config]) → unit-test plan → framework tag (if `admin/` changed: rebuild dist, commit, `check-admin-dist.sh`) → plugins require the tag → app pointer bumps → changelog post. Push, tag and deploy need Jakub's go-ahead.
|
||||
- Suggested lean plan split (for the plan-count confirmation with Jakub):
|
||||
1. Framework D-91 form extensions (pact, cabana compile/save/show/schema, README/docs, SPA backstop test).
|
||||
2. Framework D-92 record events + D-93 descriptors (pact, cabana emit points, signpost helpers, docs); Journal adoption (descriptors for post/category/tag, `journal-tag`, API event emission).
|
||||
3. sm-seo-plugin core: repo, models/migrations, settings singleton + per-type tabs, SEO tab extension, URL rules, resolver + public API, generate job, history core, elements E1–E3 (+E7 if chosen).
|
||||
4. Redirects, 404 log, normalisation, strict URLs, slug-change 301, robots.txt + AI bots + verification + staging lock, elements E4–E5.
|
||||
5. `/_seo/api/v1` management API + MCP tools, batch dry-run, undo, CSV import/export (E6), demo mount, `check-phase32.sh`.
|
||||
6. Unit tests (last plan), framework tag, plugin tags, pin bumps.
|
||||
|
||||
## Sources
|
||||
|
||||
### Primary (HIGH confidence)
|
||||
- Read this session: `modules/pact/capabilities.go`, `modules/pact/mcp.go`, `modules/cabana/{action_extensions,crud,extension,form_schema,schema_types,settings,field_ml,field_type,field_file,http,registry,subject_events}.go`, `modules/lagoon/transaction.go`, `modules/festival/bus.go`, `modules/signpost/signpost.go`, `modules/party/registry.go`, `modules/surf/{router,errorpage}.go`, `modules/pier/{README.md,catalog.go}`, `modules/bouncer/dispatch.go`, `modules/cooler/sitecache.go`, `admin/src/views/FormView.vue`, `admin/src/components/form/formState.ts`
|
||||
- Sibling repos: `sm-journal-plugin` (routes, mcp, models, menu item types, fields.yaml, package.json), `sm-sitemap-plugin` (plugin, routes, admin, go.mod, testmain), `sm-grzybyfunkcjonalne-app` (nginx, menu_items, nuxt.config), `sm-summercmsio-app` (site plugin routes), `sm-demo-app/summer.yaml`
|
||||
- Reference: mpseo `classes/SeoInjectorManager.php`, `models/Entry.php`, `classes/PlaceholderResolver.php`
|
||||
- proxy.golang.org (grobotstxt, temoto/robotstxt versions and go.mod); npm registry (`npm view` + package-legitimacy seam)
|
||||
|
||||
### Secondary (MEDIUM confidence)
|
||||
- developers.google.com/search/docs/crawling-indexing/robots/robots_txt (500 KiB, longest match, 5xx behaviour, crawl-delay)
|
||||
- developers.google.com/search/docs/crawling-indexing/robots-meta-tag (directives, noarchive status, X-Robots-Tag syntax)
|
||||
- pkg.go.dev/github.com/jimsmart/grobotstxt (API: MatchingLine, ParseHandler)
|
||||
- support.claude.com/en/articles/8896518 (ClaudeBot, Claude-User, Claude-SearchBot)
|
||||
|
||||
### Tertiary (LOW confidence)
|
||||
- github.com/temoto/robotstxt README (comparison only)
|
||||
|
||||
## Metadata
|
||||
|
||||
**Confidence breakdown:**
|
||||
- Standard stack: HIGH, since nearly everything is existing framework code; the one new dependency is MEDIUM.
|
||||
- Architecture: MEDIUM-HIGH. The seam insertion points are verified; the Go shapes are recommendations needing Jakub's API review.
|
||||
- Pitfalls: HIGH. Each one is backed by a verified line in the current code.
|
||||
|
||||
**Research date:** 2026-10-26
|
||||
**Valid until:** 2026-11-25 (code seams move fast with parallel sessions in cabana; recheck `cabana/http.go` Activate order before planning)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user