Files
ss-tools/specs/035-agent-chat-context/traceability.md
busya ff60865183 feat(agent-chat): 035-agent-chat-context — контекст, guardrails, tools, database discovery
== User stories ==
US1: Контекст с дашборда/датасета → /agent с URL params
US2: Guardrails card — env badge, 7 risk tones, countdown, permission_denied
US3: Tools optimization — retry, timeout, summarise, RBAC + context affinity

== Backend ==
- _context.py (NEW): UIContext validation (7 checks)
- _tool_filter.py (NEW): RBAC + context affinity pipeline
- _confirmation.py: build_confirmation_contract_v2, permission_denied_payload
- tools.py: superset_list_databases, retry/summarise/timeout wrappers
- app.py: _inject_uicontext, _inject_env_id_into_tools, database
  prefetch в runtime context
- _persistence.py: prefetch_databases()
- agent_superset_explore.py: GET /databases endpoint
- _llm_async_http.py, _persistence.py: fix double /v1 в LLM URL
  (LM Studio Unexpected endpoint)

== Frontend ==
- AgentChatModel.svelte.ts: 5 atoms, 3 actions, countdown, context
- AgentChat.svelte: production banner, process steps, debug panel
- ConfirmationCard.svelte: 7 risk tones, permission_denied, countdown
- ToolCallCard.svelte: retrying/timeout/cancelled states
- StreamProcessor.svelte.ts: tool_retry, timeout, permission_denied
- TopNavbar: sparkles icon + Ассистент
- sidebarNavigation: AI section
- DashboardHeader, datasets/+page: contextual AI buttons
- Icon: sparkles, brain, cpu icons
- tailwind: assistant category colors
- i18n: en/ru nav keys

== Tests ==
- 159 backend agent tests (+16 US3: retry, timeout, summarise, contracts)
- 2544 frontend tests (+11 model + component tests)
- 15 JSON fixtures (10 API + 5 model)

== Specs ==
- specs/035-agent-chat-context/: spec, UX, plan, tasks, research,
  data-model, contracts, quickstart, traceability, fixtures, checklists

Closes #035
2026-07-04 22:47:17 +03:00

46 lines
3.0 KiB
Markdown

#region Traceability [C:3] [TYPE ADR] [SEMANTICS traceability,rtm,agent-chat]
@defgroup Trace Matrix v2 — Requirements → Model → API → Task → Test for 035-agent-chat-context.
## Traceability Matrix
| Story | Requirement | Model/Contract | API/SSE | Backend Task | Frontend Task | Test |
|-------|------------|----------------|---------|-------------|--------------|------|
| US1 | AGCTX-FR-001, FR-003 | AgentChat.Model | — | — | T010, T011, T012 | T007 |
| US1 | AGCTX-FR-002, FR-004 | AgentChat.Context.Inject, Validate | Gradio submit (uicontext at pos 6) | T005, T013, T014 | — | T008 |
| US1 | AGCTX-FR-005 | AgentChat.ToolFilter.Pipeline | — | T006 (build_tool_pipeline) | — | T009 |
| US1 | prod warning | AgentChat.Model | — | — | T015, T016 | T007 |
| US2 | AGGRD-FR-001, FR-002 | AgentChat.Confirmation.GuardV2 | confirm_required (extended) | T022 | T025, T026, T027 | T020, T021 |
| US2 | AGGRD-FR-003 | AgentChat.Confirmation.PermissionDenied | permission_denied (NEW) | T023, T024 | T028 | T020 |
| US2 | AGGRD-FR-004 | AgentChat.StreamProcessor | confirm_resolved (denied) | — | T029 | T021 |
| US3 | AGTL-FR-001, FR-005 | AgentChat.ToolFilter.InvocationGuard | permission_denied | T006, T024 | — | T009 |
| US3 | AGTL-FR-002 | AgentChat.Tools.Retry | tool_retry (NEW) | T037 | T040, T041 | T033, T036 |
| US3 | AGTL-FR-003 | AgentChat.Tools.Summarise | — | T038 | — | T034 |
| US3 | AGTL-FR-004 | AgentChat.Tools.Timeout | tool_timeout (extended) | T039 | T040, T041 | T035, T036 |
| US3 | AGTL-FR-006 (SHOULD) | AgentChat.EmbeddingRouter | — | post-MVP | — | — |
| SC-006 | AGCTX-FR-004 (validation) | AgentChat.Context.Validate | — | T005 | — | T008 |
## Impact Analysis
| If you change... | Contracts verify | Tests verify | Screens depend |
|-----------------|-----------------|-------------|----------------|
| agent_handler uicontext pos | AgentChat.LangGraph.Handler | T008 | AgentChat panel |
| _CONTEXT_TOOL_AFFINITY | AgentChat.ToolFilter.Pipeline | T009 | AgentChat panel |
| _TOOL_PERMISSIONS | AgentChat.ToolFilter.InvocationGuard | T020 | AgentChat panel |
| build_confirmation_contract_v2 | AgentChat.Confirmation.GuardV2 | T020, T021 | ConfirmationCard |
| yield_permission_denied | AgentChat.Confirmation.PermissionDenied | T020 | ConfirmationCard |
| _retry_read_tool | AgentChat.Tools.Retry | T033 | ToolCallCard |
| _execute_with_timeout | AgentChat.Tools.Timeout | T035 | ToolCallCard |
## Contract → Fixture Mapping
| Production Contract | Fixture |
|--------------------|---------|
| AgentChat.LangGraph.Handler | FX_AgentChat.Handler.* (3 fixtures) |
| AgentChat.Confirmation.GuardV2 | FX_AgentChat.Guard.* (4 fixtures) |
| AgentChat.ToolFilter.Pipeline | FX_AgentChat.Filter.* (3 fixtures) |
| AgentChat.Tools.Retry | FX_AgentChat.Retry.* (3 fixtures) |
| AgentChat.Model.SetContext | FX_AgentChat.SetContext.* (2 fixtures) |
| AgentChat.Context.Validate | FX_AgentChat.Validate.* (4 fixtures — valid, invalid_type, oversized, long_name) |
#endregion Traceability