fix(agent-chat): streaming state leak, document parser magic bytes, HITL flow

### Bugfixes — Agent Chat 'Думаю' State Leak
- fix(agent-chat): loadHistory() now resets streamingState/idle + cancels stale
  submission — prevents 'Думаю' state leak across conversation switches
- fix(agent-chat): onDisconnected/onDisconnectedPermanent cascade to
  streamingState — prevents permanent hang on connection loss during stream
- fix(agent-chat):  guard on isLoadingHistory — prevents false commit
  of 'agent unavailable' fallback when switching conversations
- fix(agent-chat): remove race in _sendNow empty-response check vs Svelte
   microtask (duplicate logic removed,  handles correctly)
- fix(stream-processor): confirm_resolved now appends msg.text to partialText
  instead of dropping it

### Bugfixes — Backend PDF Upload
- fix(document-parser): _detect_format_by_magic() — reads file header magic
  bytes as fallback when Gradio loses filename
- fix(document-parser): improved name extraction — tries orig_name, path stem
- fix(document-parser): @RELATION AgentChatTypes -> AgentChat.Types

### HITL Flow & Agent Chat Improvements
- feat(agent): HITL resume confirm/deny with userId/userJwt/envId propagation
- feat(agent): confirm_required metadata fallback via aget_state() after
  'Event loop is closed' error during interrupt
- feat(agent): interrupt_before re-enabled via AGENT_CONFIRM_TOOLS env var
- feat(frontend): debug panel with connection/stream state monitoring
- feat(frontend): AgentChatModel constructor options + onBeforeSend callback
- feat(frontend): crypto.randomUUID() for local conversation ID on first send

### Backend Agent Refactoring
- refactor(agent): langgraph_setup — monkey-patch for PydanticSerializationError
- refactor(agent): tools.py — dual identity headers, expanded tool set
- refactor(agent): run.py — _find_free_port, Gradio server port fallback
- refactor(agent): app.py — file size validation, message truncation, HITL path

### Frontend
- feat(dashboard-hub): DashboardHubModel with filters, pagination, git actions
- feat(ui): DateRangeFilter component
- feat(i18n): new dashboard keys; cache tooltips fix
- fix(i18n): full run tooltips — cache is NOT ignored

### Semantic Protocol
- chore(agents): update all agents with canonical format
- chore(skills): sync semantics-core, semantics-contracts, molecular-cot-logging

### Housekeeping
- chore: remove stale semantic reports (10 files, Jan 2026)
- chore: update 033-gradio-agent-chat specs, contracts, UX, tasks, tests
- chore: add .agents/ directory (mirrors .opencode/ agent layouts)
- chore: update run.sh with DEV_MODE, port management
This commit is contained in:
2026-06-29 17:15:25 +03:00
parent 4fda63a8da
commit 12678c637b
115 changed files with 8948 additions and 1763 deletions

View File

@@ -49,11 +49,12 @@ Load and follow these skills (MANDATORY):
- Own your frontend tests and live verification instead of delegating them to separate test-only workers.
## Axiom MCP Tools
See `semantics-core` §VI for the canonical tool reference. For Svelte frontend work:
- `axiom_semantic_discovery search_contracts` / `read_outline` — component lookup and anchor verification
- `axiom_semantic_context local_context` — component + UX contracts + dependencies in one call
- `axiom_semantic_validation audit_belief_protocol` — verify UX contracts have @UX_STATE, @PRE, @POST
- `axiom_semantic_context workspace_health` — project health for refactoring plan
See `semantics-core` §VI for the canonical tool reference. Axiom MCP exposes 2 read-only tools (`search` and `audit`). For Svelte frontend work:
- `search` tool: `search_contracts` / `read_outline` / `local_context` / `workspace_health` / `rebuild`
- `audit` tool: `audit_belief_protocol` / `audit_contracts`
**Mutation (anchors, UX contracts, component metadata) uses `edit`** — Axiom MCP has NO mutation tools.
---
@@ -83,7 +84,7 @@ You do not own:
## Required Workflow
1. **Discover or create the Model first.** For any screen with cross-widget state:
- grep `@semantics.*<keyword>` across `frontend/src/` to find existing models
- Use `axiom_semantic_discovery search_contracts query="<keyword>" type="Model"` for structured search
- Use `search` tool with `operation="search_contracts" query="<keyword>"` for structured search
- If no model exists, create one: `#region ScreenNameModel [C:4] [TYPE Model] [SEMANTICS ...]` with mandatory `@BRIEF` and `@INVARIANT`
2. **Define types FIRST before implementing the model:**
- FSM state union type (e.g., `type ScreenState = "idle" | "loading" | "loaded" | "error"`)
@@ -269,12 +270,12 @@ npm run dev # Development server for browser validation
## Semantic Safety
Follow the canonical anti-corruption protocol in `semantics-contracts` §VIII. Key rules for Svelte:
- Before editing ANY file: `axiom_semantic_discovery read_outline`
- Before editing ANY file: `search` tool with `operation="read_outline"`
- Never: insert code between `<!-- #region -->` and first metadata; remove/move/duplicate `<!-- #endregion -->`; add `@COMPLEXITY N` or `@C N`; use raw Tailwind colors (`blue-600`, `gray-*`); use `export let`, `$:`, or `on:event`
- After editing: verify `read_outline` — all pairs must match
- Corrupted → rollback immediately
- Corrupted → rollback via `git checkout` immediately
- ONE file at a time; verify between files
- After feature completion: `axiom_semantic_index rebuild rebuild_mode="full"`
- After feature completion: `search` tool with `operation="rebuild" rebuild_mode="full"`
## Recursive Delegation
- For complex screens, you MAY spawn a separate `svelte-coder` for individual components.