Skip to content

fix(dashboard): apply the owner gate to session history, knowledge reads and task actions - #22838

Merged
iamwhatever merged 2 commits into
mainfrom
fix/owner-gate-dashboard
Oct 22, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
fix/owner-gate-dashboard

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Session history, knowledge-library reads and task actions on the dashboard answer the dashboard owner only.

A linked chat-channel session (Telegram, Teams or Webex allowlist link) reaches the dashboard with the same empty app claim as the owner's own session. The app-isolation checks on GET/DELETE /api/sessions/{key}, DELETE /api/sessions, the GET /api/knowledge/* reads and POST /api/tasks/{task_id} (plus /cancel) admit every such caller, so these routes were not limited to the owner.

Why it matters

Transcripts, the knowledge library and the owner's waiting runs are the owner's data. A non-owner linked session should not read, delete or act on them.

Not a goal

  • No change to app-token callers: they keep their existing app-isolation checks and manifest scope.
  • No change to internal-secret callers.
  • No new routes, settings or UI.

What changed (motivation → approach → change)

  • Non-owner dashboard sessions pass the app checks on these routes → add require_owner_for_dashboard_caller in dashboard/handlers/_shared_access.py, which gates only the dashboard-user class (empty app claim) and passes every other caller to the control that already governs it.
  • Session history: guard_owner_surface_routes (_shared_route_guards.py) gains a dashboard_owner_only flag, and sessions_parts/history_reads.py and sessions_parts/delete_routes.py set it. Every api_session* route in those two modules (list, search, detail, meta, archive list and read, delete, clear, clearable count) now runs the existing private-member check and then the owner check, before the handler. Other modules keep the plain guard.
  • Knowledge and tasks: call the helper before any read in each knowledge read route (knowledge_*.py) and in the two task action routes (tasks.py).
  • _require_knowledge_owner now delegates to it, so the library uses one rule for reads and writes.
  • Facade type-checking manifests list the new name; spec docs (knowledge.md, learn-cron-dashboard.md) describe the gate.

Backwards compatibility

Breaking: a non-owner dashboard session now gets 403 owner_only on these routes. Writer sweep on origin/main: the owner's own dashboard session, app tokens and internal-secret callers are unaffected.

Note: the owner signing in through their own channel link gets a token whose subject is the channel user, not owner_id, so that session is also refused here, as it already is on the existing owner-gated routes.

Reader: src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py:api_session_detail -- crew page -- owner session passes; test_dashboard_owner_gate_history_kb_tasks.py
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py:api_sessions -- crew page -- owner session passes; test_the_owner_passes_the_gate_on_every_history_read
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py:api_session_archive_read -- crew page -- owner session passes; test_the_owner_passes_the_gate_on_every_history_read
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/delete_routes.py:api_session_delete -- crew page -- owner session passes; test_dashboard_owner_gate_history_kb_tasks.py
Reader: src/kiro_crew/dashboard/handlers/knowledge_library.py:list_namespaces -- crew page -- owner session passes; test_dashboard_owner_gate_history_kb_tasks.py
Reader: src/kiro_crew/dashboard/handlers/tasks.py:api_task_action -- crew page -- owner session passes; app tokens unaffected; test_dashboard_owner_gate_history_kb_tasks.py

Tests

test/test_dashboard_owner_gate_history_kb_tasks.py (new): through the real token middleware and route table, a non-owner dashboard session is refused with 403 owner_only on every session history route, every knowledge read and both task actions; the owner passes; an app token keeps its 404 / own-transcript / manifest-scope answers. dashboard_owner_surface_guard is checked on all four caller classes (owner, non-owner dashboard, app token, internal caller). Existing knowledge, sessions, tasks and facade suites pass.

Manual verification

N/A — unit coverage exercises every gated route with each caller class.

Related Issues

N/A

Pattern harvest

Rule candidate: review-prompt
Pattern: "a dashboard route guarded only by an app-isolation check also needs the owner gate for empty-app-claim callers"

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 82485f0658c693aaf90e9494d682bc5415832ec3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 82485f0658c693aaf90e9494d682bc5415832ec3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change reuses the existing owner-gate pattern, the break is listed and accepted, and a revert undoes it cleanly.

Notes

  • The description never mentions the sessions_parts/summaries.py hunk (dashboard_owner_only=True on api_sessions_summarize). The summary panel route now also refuses non-owner sessions, but the Backwards compatibility section has no Reader line for it. Add one.
  • dashboard_owner_only=True covers every api_session* route in the module. A non-owner linked session now also loses access to its own transcript, not just the owner's. If non-owner sessions can chat in the dashboard (cli.md says they enter it), checking the session's owner against the caller would close the leak and keep that working.

[DESIGN-REVIEWED] 82485f0

Description read

[DESCRIPTION-READ] 1f51b49cbadd08bacebba140ac0c53e79ad9783880a19165910670e30ba76f6d

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 82485f0658c693aaf90e9494d682bc5415832ec3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The gate protects a named boundary: several people reach one gateway through channel allowlists. The new tests fail on base. One identical copy of the helper is still inline.

Notes

  • Item 6 — duplicate of the new helper's body: taskrunner.py:163 still runs if request.get("app") != "": return None / return await require_owner_dashboard_request(request, operation) inline. That is the same check _require_knowledge_owner had before this PR made it delegate. I grepped request.get("app") != "" and got 7 hits; that one matches the helper exactly, and the other 5 refuse or audit differently. Subtraction: delete the inline body in taskrunner.py and call require_owner_for_dashboard_caller.

What this change ships

Inventory (7 items) — 6 justified

Intent: let only the dashboard owner read or delete their chat history and knowledge library, and act on their waiting runs. FIX.

  1. Non-owner linked sessions get 403 owner_only on session list, search, detail, meta, archive, delete, clear and clearable count — justified
  2. Non-owner linked sessions get 403 on POST /api/sessions/summarize, before any transcript read or model call — undeclared: "What changed" names only two modules and says "Other modules keep the plain guard"
  3. Non-owner linked sessions get 403 on all 19 knowledge reads, export included — justified
  4. Non-owner linked sessions get 403 when answering or cancelling the owner's waiting task runs — justified
  5. New shared require_owner_for_dashboard_caller; the knowledge gate now delegates to it — justified
  6. taskrunner.py:163 keeps its own inline copy of the new helper's check — duplicate of _shared_access.require_owner_for_dashboard_caller
  7. New dashboard_owner_only flag on guard_owner_surface_routes (3 modules use it) — justified

[FIRST-PRINCIPLES-REVIEWED] 82485f0

Description read

[DESCRIPTION-READ] bd519d553e850031d4165599cf16b69724c640f535b03ec57b0539df0cabdc6b

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 82485f0658c693aaf90e9494d682bc5415832ec3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 82485f0

Verdict parsed from the review's SHA-scoped output markers for commit 82485f0658c693aaf90e9494d682bc5415832ec3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 82485f0658c693aaf90e9494d682bc5415832ec3: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 82485f0658c693aaf90e9494d682bc5415832ec3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 82485f0

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 82485f0658c693aaf90e9494d682bc5415832ec3: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 21, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 1e9d53486a552ab65e86bae4b802be08664a3add.

Requesting changes: one route that serves the same transcripts is still open.

The gate itself is right. require_owner_for_dashboard_caller applies the owner check only to a present, empty app claim, and the check underneath fails closed on an absent claim, an empty user or a non-owner subject. App and internal callers keep the controls they already had. I re-ran test_dashboard_owner_gate_history_kb_tasks.py (83 passed) and the related session, knowledge, tasks and facade suites (684 passed). Then I dropped each new gate one at a time: both dashboard_owner_only flags, both task gates, the helper and all 19 knowledge read gates. Each mutant turned a named test red.

Blocking: POST /api/sessions/summarize (sessions_parts/summaries.py). This route has the same app-only check this PR fixes. Its guard_owner_surface_routes(...) call at line 301 does not pass dashboard_owner_only=True (history_reads.py does, at line 595), so with an empty app claim has_log(key) is the only test. Through the real middleware and route table, with the model call stubbed, a non-owner dashboard session sent {"keys":["dashboard:owner-chat"]} and got 200 with a summary of the owner's transcript. It also spends the owner's model credit. First Principles item 2 flagged the same route and it has no reply yet.

The fix is one line, adding dashboard_owner_only=True to that call. Nothing in the website calls this route, and the MCP list_sessions leg uses the internal secret with no app claim, so it still passes. With that line added, the same probe returns 403 owner_only, and test_dashboard_sessions_summarize.py and test_member_memory_api.py still pass. Please add a refusal test next to the other history routes.

Non-blocking follow-ups:

  • GET /api/sessions/{id}/agents and /agents/{agent_id} (core.py, plain guard) return a session's subagent results to a non-owner dashboard session. They belong to the same family.
  • GET /api/tasks, /api/tasks/summary and /api/tasks/{id} stay open to non-owner sessions. That fits the "task actions" scope, but the module docstring could say so.
  • First Principles item 5: _require_knowledge_owner is now a pass-through and could be removed. Design note: consider making the dashboard owner check the default in guard_owner_surface_routes, so a new owner-data module can't forget the flag.
  • The branch conflicts with main in docs/system-specs/modules/learn-cron-dashboard.md and needs a rebase.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 21, 2026
@iamwhatever
iamwhatever force-pushed the fix/owner-gate-dashboard branch from 1e9d534 to 1dc9496 Compare October 21, 2026 23:37
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Thanks @buluoray. Addressed in 1dc9496 (rebased onto current main, conflict in learn-cron-dashboard.md resolved by keeping both edits):

  • sessions_parts/summaries.py: the module guard now passes dashboard_owner_only=True, same as history_reads.py. A non-owner dashboard session gets 403 owner_only before any transcript read or model call. The owner and the internal list_sessions caller are unchanged.
  • Added test_a_non_owner_dashboard_session_cannot_summarize_a_transcript (403, no model call) and test_the_owner_summarizes_a_transcript (200) next to the other history-route tests. Dropping the new flag turns the refusal test red.
  • test_dashboard_sessions_summarize.py and test_member_memory_api.py still pass. The spec line for the route now notes the guard.

require_owner_for_dashboard_caller is left as-is, per your note that the gate is right. The non-blocking items (subagent result routes, task read docstring, removing _require_knowledge_owner, owner check as the guard default) are left for a follow-up so this PR stays scoped.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 21, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 1dc9496. Approve.

My blocker is fixed: sessions_parts/summaries.py now passes dashboard_owner_only=True to guard_owner_surface_routes (line 307), so POST /api/sessions/summarize gets the same owner gate as the other history routes. The new commit adds test_a_non_owner_dashboard_session_cannot_summarize_a_transcript and test_the_owner_summarizes_a_transcript, which pin both sides. The branch is rebased onto current main, which also clears the docs conflict.

The one red check on this head is Real Adapter Contract Tests, the pi lane that is red on main itself and is fixed by #22951; it is unrelated to this change.

The non-blocking follow-ups from my earlier review still apply (/api/sessions/{id}/agents, the ungated task reads, _require_knowledge_owner as a pass-through).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 22, 2026
zejiangg added 2 commits October 22, 2026 06:14
…ads and task actions

GET and DELETE /api/sessions/{key} and DELETE /api/sessions, every
GET /api/knowledge/* read (the whole-library export included), and
POST /api/tasks/{task_id} and its /cancel sibling now answer the
dashboard owner only. A Telegram, Teams or Webex allowlist link holds the
same empty app claim as the owner's own session, and the app-isolation
checks on these routes admit every such caller, so a non-owner dashboard
session could read or delete any transcript, export the library, or feed
an answer into (or end) the owner's waiting run.

The new require_owner_for_dashboard_caller gates the dashboard-user class
only and is layered under the existing app checks: an app token keeps its
uniform 404, its own transcripts and its manifest scope, and an
internal-secret caller keeps its own door. _require_knowledge_owner now
delegates to it, so the library has one rule for reads and writes.
POST /api/sessions/summarize derives its reply from the owner's transcripts,
so it now uses the same dashboard_owner_only guard as the history reads. The
owner and the internal list_sessions caller are unchanged; a non-owner
dashboard session gets 403 owner_only before any read or model call.
@iamwhatever
iamwhatever force-pushed the fix/owner-gate-dashboard branch from 1dc9496 to 82485f0 Compare October 22, 2026 06:16
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 22, 2026
@github-actions github-actions Bot added the readiness: passed Eligible automated validation passed for the current revision label Oct 22, 2026
@iamwhatever
iamwhatever merged commit ac41ba0 into main Oct 22, 2026
105 checks passed
@iamwhatever
iamwhatever deleted the fix/owner-gate-dashboard branch October 22, 2026 07:19
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants