Skip to content

fix(v6.50.3): anonymous relationship reads; hide comments UI for anonymous visitors (ADR-251) - #303

Merged
cgbarlow merged 1 commit into
mainfrom
fix/anonymous-relationships-comments
Sep 24, 2026
Merged

cgbarlow merged 1 commit into
mainfrom
fix/anonymous-relationships-comments

Conversation

@cgbarlow

Copy link
Copy Markdown
Owner

Problem

  • Relationship reads needed sign-in. GET /api/relationships and GET /api/relationships/{id} required sign-in, unlike element and diagram reads (ADR-123). So anonymous visitors and MCP sessions could see a model's elements but not how they connect, and ADR-249 had to carve these two tools out of the "reads work without sign-in" promise.
  • Comments error for anonymous visitors. Comments need sign-in to read or write, but the comments UI was still shown to anonymous visitors. Every anonymous diagram or element page ended in a "Failed to load comments" panel from the 401, and each page load spent an anonymous request learning that.

Product decisions (2026-09-24): listing relationships should not need signing in, and the anonymous comments error should be hidden.

Fix

Relationships

  • Both read routes now use get_optional_user, like element reads.
  • Writes are unchanged, and an invalid token still gets 401.
  • The sign-in carve-out is removed from the MCP server instructions (seed and fallback), the two tool descriptions, mcp/README.md and docs/api.md.
  • This supersedes ADR-249's rejected option (g); SPEC-249-A is annotated.

Comments

  • CommentsPanel only renders and fetches when signed in.
  • The diagram page hides all four Comments buttons for anonymous visitors (commentsAvailable = !isAnonymous()) and skips the comment-count request.
  • Comments themselves stay sign-in-only.

Tests

  • Backend:
    • New TestAnonymousReads covers anonymous list by element, anonymous list by set and type, and anonymous get-one. It also checks that an invalid token still gets 401 and that writes still get 401.
    • The seed-instructions assertion is inverted.
    • 4 tests failed before the fix; tests/test_relationships now has 46 passing.
  • Full backend suite: 2109 passed. The 15 failures also fail on main: test_search (11), Sparx .eap (2) and test_mnemos (2).
  • MCP: 276 passed. The 2 failures (inventory required-fields tests) also fail on main.
  • Frontend unit:
    • anonymousCommentsHidden.test.ts: 6 tests, which failed before the change and pass after.
    • Full vitest run: 1307 passed. The 7 failures also fail on main.
  • Frontend e2e: anonymous-readonly.spec.ts has a new test, "anonymous visitor sees no comments UI on a diagram". It checks there's no Comments button, no "Failed to load comments" text and no /comments request, and that the button returns after sign-in.
    • It failed against main's components and passes after the change. The whole spec (5 tests) passes, run against this branch's own backend and Vite dev server.
  • Surface-parity check is clean.

Rollout

No migration. The MCP server-instructions seed text changes, the same way #300 changed it. #302 (v6.50.2) and #301 (v6.51.0) are in flight, so whichever merges later needs a small CHANGELOG and version rebase. #301 may also touch the same server-instructions paragraph.

ADR: docs/adrs/ADR-251-Anonymous-Relationship-Reads-And-Hidden-Comments.md
Spec: docs/adrs/specs/SPEC-251-A-Anonymous-Relationship-Reads-And-Hidden-Comments.md

🤖 Generated with Claude Code

https://claude.ai/code/session_01EbTwcTX1wKVooS7oWd7cP9

…ymous visitors (ADR-251)

Product decisions (2026-09-24): listing relationships should not need
signing in, and anonymous visitors should not see the comments error.

Relationships:
- GET /api/relationships and GET /api/relationships/{id} now use
  get_optional_user, like element reads (ADR-123). Writes unchanged; a
  present-but-invalid token is still 401.
- Removes ADR-249's "relationship reads need sign-in" carve-out from the MCP
  server instructions (seed + fallback), the list_relationships /
  get_relationship descriptions, mcp/README.md and docs/api.md. Supersedes
  ADR-249 rejected option (g); SPEC-249-A annotated.

Comments:
- Comment reads need sign-in, so anonymous visitors always got a "Failed to
  load comments" panel (401). CommentsPanel now renders and fetches only
  when signed in; the diagram page gates all four Comments toggles on
  commentsAvailable = !isAnonymous() and skips the comment-count request.

Tests (TDD):
- backend TestAnonymousReads (anon list by element / set+type, get one;
  bad token still 401; writes still 401) + seed-text assertion inverted:
  4 red before, tests/test_relationships 46 passed after.
- mcp: sign-in assertions inverted; 276 passed, 2 failures pre-existing on
  main (inventory required-fields tests).
- frontend unit anonymousCommentsHidden.test.ts: 6 red before, green after.
- e2e anonymous-readonly.spec.ts "no comments UI on a diagram": failed on
  main's components (Comments button present), passes after; spec 5/5.
- Surface parity clean.

See docs/adrs/ADR-251-Anonymous-Relationship-Reads-And-Hidden-Comments.md and
docs/adrs/specs/SPEC-251-A-Anonymous-Relationship-Reads-And-Hidden-Comments.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EbTwcTX1wKVooS7oWd7cP9
@cgbarlow
cgbarlow force-pushed the fix/anonymous-relationships-comments branch from 10cd1ef to c0e7ce2 Compare September 24, 2026 01:25
@cgbarlow

Copy link
Copy Markdown
Owner Author

Rebased onto main after #302 merged. Only the version files and CHANGELOG conflicted: [6.50.3] now sits above [6.50.2], and the version stays 6.50.3. Rechecked after the rebase: tests/test_relationships, test_authz and test_batch gave 98 passed; the full backend suite gave 2122 passed, with only the same 15 failures main has; the frontend anonymous-comments tests gave 6 passed; and the surface-parity check is clean.

🤖 Generated with Claude Code

@cgbarlow
cgbarlow merged commit 1eca326 into main Sep 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant