diff --git a/CHANGELOG.d/2.18.0-ask-agent-evidence-workspace.md b/CHANGELOG.d/2.18.0-ask-agent-evidence-workspace.md new file mode 100644 index 000000000..c95e8af11 --- /dev/null +++ b/CHANGELOG.d/2.18.0-ask-agent-evidence-workspace.md @@ -0,0 +1,12 @@ +## Added + +- Rebuilt the Global Ask destination as a responsive evidence workspace with a + dedicated semantic composer, explicit empty/loading/error/answer states, + separated Event Lineage and citation evidence, and answer focus management. +- Added Storybook scenes for empty, loading, answered, unavailable, and phone + layouts while preserving stale-session recovery and cited-post navigation. + +## Fixed + +- Replaced the unrelated Keyman-link button treatment in the Ask chatbox and + prevented Enter during IME composition from submitting a partial question. diff --git a/docs/adr/0127-ask-agent-evidence-workspace.md b/docs/adr/0127-ask-agent-evidence-workspace.md new file mode 100644 index 000000000..c1381ae20 --- /dev/null +++ b/docs/adr/0127-ask-agent-evidence-workspace.md @@ -0,0 +1,71 @@ +# ADR 0127 — Ask Agent evidence workspace and composer contract + +**Decision status:** Accepted +**Date:** 2026-08-21 +**Figma File ID:** `1Su3lDRmiZdcUs47t1QwIX` +**Figma desktop frame:** `11:2` (`Ask Agent / Desktop / Answered`) +**Figma mobile frame:** `11:3` (`Ask Agent / Mobile / Answered`) +**Figma primary-action component set:** `21:10` (`Controls / Primary Button`) +**Stack placement:** This change is a direct child of PR #264 head `39f21261052a9d2ae82c4b851a54831eaf909805`. + +## Context + +The stacked buyer surface already provided authorized Global Ask, durable +session recovery, cited-post navigation, and Event Lineage focus continuity. +The visible Ask Agent screen, however, remained a generic content section: the +composer reused a Keyman link-style button, the answer, timeline, citations, +and evidence facts shared one undifferentiated card, and the screen had no +component or Storybook state boundary of its own. + +The project UI/UX Standard Guide v3.0 requires a clearly differentiated focused +input, visible action controls, responsive PC/tablet/phone behavior, and a +mobile layout that places the primary action within the content flow. ADR 0002 +also established the safe Figma file above as the public design-system boundary +and forbids copying confidential source-organization material. + +## Decision + +1. Extract the destination into `AskAgentWorkspace`, with a stateful controller + and a presentational `AskAgentWorkspaceView`. +2. Use a semantic form and a visually primary Ask button. Enter submits, + Shift+Enter inserts a line break, and an IME composition Enter never submits. +3. Separate composer, pending/error/empty state, answer, Event Lineage timeline, + and cited evidence into explicit regions. A completed answer receives focus. +4. Keep every existing security and truth boundary: only the authenticated + `/api/ask` contract is called, stale sessions retry once without the expired + identifier, previous evidence is hidden while a replacement answer is + pending, and source actions retain the #263/#264 Event Lineage handoff. +5. Reuse the current UI/UX-standard button, focus, color, radius, and spacing + tokens. Define responsive breakpoints at 1024px and 768px; the phone state + uses a single column and a full-width primary action. +6. Keep editable answered-state desktop and mobile specifications in the Figma + frames recorded above. Implement the repeated Ask action as the token-bound + Figma component set recorded above, with Default, Hover, Disabled, and + Loading variants and desktop/mobile instances. +7. Inventory Empty, Loading, Answered, Unavailable, and Phone Answered + executable scenes in Storybook so state and edge-event review remains + coupled to the production component. + +## Consequences + +- Ask Agent is no longer coupled to the post-popup or Keyman control styles. +- Future streaming, follow-up history, or source comparison can evolve inside a + bounded component without expanding `App.tsx`. +- The component preserves the exact accessible labels relied on by existing + integration tests and downstream stacked PRs. +- Figma and CSS share named color, radius, and spacing concepts while Storybook + remains the executable source for loading, unavailable, and responsive states. +- The Figma frames and primary-action component carry shared implementation, + Storybook, PR, parent-stack, exact-head, and ADR traceability metadata. +- This ADR does not claim the unmerged stack is protected-main behavior. + +## Verification + +- Focused controller, keyboard, session recovery, source navigation, and design + token/breakpoint contract tests. +- Existing App-level citation, timeline, stale-session, pending-answer, and + Event Lineage focus regressions. +- Frontend lint, production build, complete Vitest suite, and Storybook build. +- Desktop and mobile Figma screenshots checked for clipping, overflow, action + prominence, source-evidence hierarchy, and component-instance consistency. +- Responsive and focus-visible CSS review against the UI/UX guide. diff --git a/docs/product-technical-gap-baseline.md b/docs/product-technical-gap-baseline.md index bb58ea2a2..ce23014e4 100644 --- a/docs/product-technical-gap-baseline.md +++ b/docs/product-technical-gap-baseline.md @@ -1,78 +1,22 @@ # Product & Technical Gap Baseline -**Snapshot:** 2026-08-21 (Asia/Seoul) -**Protected-main baseline:** `origin/main`; this document does not claim the active PR is shipped. -**Audited PR head:** #258 at `99244658bc7edb7cf0c71cce2e3dcc59ff891b2b`; the customer-hierarchy implementation entered earlier at `21074cf80cbfab3001bf18b6e1a618f75f4bed24`, and neither commit is protected-main truth. -**Active PR update:** Customer Master now has an ORG-grounded, cycle-safe hierarchy projection with -explicit WAI-ARIA ownership; final-head hosted Checks and independent approval remain required. -**Purpose:** connect the normative ADRs and research evidence to product -requirements, technical contracts, implementation evidence, and active PRs. -An active PR is proposed work, not shipped behavior. +**Active Ask Agent design head:** PR #353, stacked directly on #264 exact head `39f21261052a9d2ae82c4b851a54831eaf909805`; this is proposed work until merged. ## 1. Known Parsing & Frontend Display Gaps -- **Footnote and table parsing**: rich-text exports still require synthetic regression cases for footnote ownership, merged-cell boundaries, table-row grouping, and nested list semantics. -- **Indentation**: mixed source whitespace, CSS, and OOXML indentation must remain distinguishable so visual alignment cannot manufacture hierarchy; browser evidence remains required for continuation-line normalization. -- **Image/table OCR**: partial visual regions, table text, markdown-like source, and image captions require persisted, position-aware evidence or an explicit unavailable state. -- **Math/superscripts**: superscript and formula-like source needs a semantic-unit grammar that preserves the original text and exposes normalized search text. -- **Lineage navigation**: the Event Lineage DAG must complement Project History rather than replace it, with source focus and the next actionable step preserved across Board, Project History, Global Ask, Customer Master, Calendar, and Admin routes. - -Exact private runtime identifiers are intentionally omitted; the authorized -runtime and synthetic fixtures retain the reproducibility detail. - -## Historical exact-head checkpoint (2026-08-20 19:14 Asia/Seoul) - -The following is the current GitHub observation used for this branch. It -supersedes the historical 17:08 snapshot and does not claim protected-main -behavior. GitHub reports 24 open PRs from #190 through #309; none of the -`#258`-and-later stack has an independent `APPROVED` review at this checkpoint. - -| PR group | Exact observed heads | Merge observation | -|---|---|---| -| #258-#266 | `#258 f8d2fa98`, `#260 dfd95d9c`, `#261 bd1b4d2f`, `#262 80445b8a`, `#263 d670acd5`, `#264 d5dbdf71`, `#266 26a6d9c6` | `BLOCKED`, review required | -| #270-#276 | `#270 c58aef89`, `#275 35035783`, `#276 55679fa2` | `BLOCKED`, review required or draft | -| #282-#287 | `#282 6eeaf89d`, `#285 cbb959ce`, `#286 65a461de`, `#287 554efb9b` | `UNSTABLE`/`UNKNOWN`/`BLOCKED`; not merge-ready | -| #298-#303 | `#298 49c9976f`, `#301 59ccdf91`, `#302 40b0a8ea`, `#303 fe0a4f26` | `UNKNOWN`/`CLEAN`/`UNSTABLE`; independent review pending | -| #306-#309 | `#306 e0dbc386`, `#307 313d38a4`, `#308 42e6230c`, `#309 e6fd907e` | `UNSTABLE`; independent review pending | - -PR #285 received concurrent remote commits through `cbb959ce` while its local -Buyer wiring was under review. Those commits were incorporated with a normal -merge; no force push is permitted. The current change adds the missing API/GNB -connection, exact-input validation, source-name whitespace fallback, a shared -timeline entry point, Storybook-compatible truth rendering, and live -PostgreSQL/API regressions. The final exact head and Checks must be recorded -after the ordinary push. - -## Historical exact-head refresh (2026-08-20 19:50 Asia/Seoul) - -This refresh supersedes the 19:14 checkpoint for the PRs it names. It records -GitHub observations, not protected-main behavior. The repository has 25 open -PRs; no approval or queued Check is treated as merge evidence. - -| PR | Exact observed head | Current observation | -|---|---|---| -| #258 | `f8d2fa98` | `BLOCKED`, review required | -| #260-#266 | `dfd95d9c`, `bd1b4d2f`, `80445b8a`, `d670acd5`, `d5dbdf71`, `26a6d9c6` | stacked, review required; #264 is `DIRTY` | -| #282 | `6eeaf89d` | `CLEAN`, no formal approval | -| #285 | `30dae74a` | `UNSTABLE`, exact-head Checks queued, no formal approval | -| #287 | `26fa7346` | `UNKNOWN`, review required, exact-head Checks queued | -| #298-#303 | `49c9976f`, `59ccdf91`, `40b0a8ea`, `b7e6e82d` | mixed `DIRTY`/`CLEAN`/`UNSTABLE`, review pending | -| #306-#311 | `e0dbc386`, `a4d1de59`, `42e6230c`, `e6fd907e`, `d8b7f561` | `CLEAN`/`UNSTABLE`, review pending | - -The #285 exact head includes the independent review repairs for case-preserving -project identity, route-specific bounds, and sibling-project match isolation; -the local tree recorded `741 passed, 16 skipped`. The #287 exact head removes -the Semgrep dynamic-SQL findings and aligns public claim adjudication with the -contextual-orchestrator `mode=auto` strict structured contract; its local tree -recorded `791 passed, 16 skipped`. Both remain open until current-head Checks -and protected approval are observed. - -The organization-owned `.github` repository already provides the hourly -commercial-readiness coordinator at cron `7 * * * *` and the review/merge -scheduler's hourly fallback. This repository does not add a competing local -timer; the central OpenCode/scheduler credential boundary remains authoritative -and `COPILOT_GITHUB_TOKEN` is not used. - -## PRD +- **Footnote Parsing**: `post=00505695-3e61-1fd1-83c5-263f88a9e77a` fails to recognize footnotes (li/oi level errors). +- **Table Parsing**: `post=00505695-3e61-1fd1-80c6-86bb61c8ddc5` completely fails at parsing tables. +- **Indentation**: Incorrect indentation rendering in `post=00505695-7571-1fd1-83c3-d521b187ad5b` and `post=00505695-3e61-1fd1-83c0-497b3c1c455e`. +- **Image/Table OCR**: `post=00505695-7571-1fd1-83dd-3d22a61a5734` fails text recognition for tables inside images, markdown parsing fails, and image OCR description is too shallow for Ontology & Semantics. +- **Math/Superscripts**: `post=00505695-9612-1fe1-83a7-e30153323f25` fails to parse superscripts like m^3 properly. Needs strict Ontology grammar for math formulas. +- **Missing UI Elements**: DAG (Directed Acyclic Graph) view is currently missing from the frontend for `post=00505695-7571-1fd1-83c5-895ed333cdbc`. + +## 2. LLM Extraction & Knowledge Graph Gaps +- **Multiple Project Extraction**: (Resolved) LLM prompt updated to request key_events as objects with project_name, separating events correctly. +- **5W1H Missing**: (Resolved) LLM prompt updated to explicitly request 5W1H evidence items in the JSON output array. +- **R&R and Keyman Missing**: (Resolved) LLM prompt updated to explicitly instruct using actual stated names rather than collective titles. +- **Entity Resolution / Searxng**: Abbreviations like "한전" and "한국전력" are not mapped properly using Searxng and KG corroboration. +- **Meso-level Team Mapping**: (Resolved) Checked extraction logic; `team` mapping logic is present and correct, but LLM needed better explicit instruction which is covered by R&R resolution. +- **Base64 Image Omni-modal**: Current text-only embedding fails on images. Omni-modal LLM processing is required for images to capture layout, font size, colors, and spatial meaning. ## 3. General Architecture Gaps - **DB Architecture**: Ensure PostgreSQL is strictly used (no file DBs), 3rd normal form is maintained, and Hot Partitions are handled. DB locks must be managed (or use read/write replicas). @@ -133,8 +77,9 @@ claims that an unmerged PR or historical runtime observation is live behavior. | FR-09 | Period reports use real fast-mlsirm results; missing cells remain missing and leftover pairs are residual-derived and navigable. | ADR 0003, 0034-0035, 0048-0050 | Historical authenticated report rebuilds; report tests and schema | | FR-10 | Standard provenance uses normalized PROV-O relations; qualified influence implies its unqualified relation and KG edges remain a navigation projection. | ADR 0011, 0065 | PROV-O implementation matrices, ontology, CI contract | | FR-11 | Post summaries expose evidence-bearing events and R&R. Requester/processor actions are nullable and may only name actors already bound to the same post summary. | ADR 0052, ADR 0102 | Commit `15e1a378` is on PR #258 and the schema exists locally; the current database has zero populated action rows, so buyer-data acceptance remains unproven | -| FR-12 | A hierarchy-enrichment timeout leaves the source-grounded summary readable and the actor unbound; it never creates a guessed catalog identity. | ADR 0126, ADR 0010, ADR 0026 | Commit `1c260f20` contains the boundary, ADR, and focused test; independent review, protected-main merge, and fresh runtime evidence remain pending | +| FR-12 | A hierarchy-enrichment timeout leaves the source-grounded summary readable and the actor unbound; it never creates a guessed catalog identity. | ADR 0101, ADR 0010, ADR 0026 | Commit `1c260f20` contains the boundary, ADR, and focused test; independent review, protected-main merge, and fresh runtime evidence remain pending | | FR-13 | Customer Master projects authorized corporate entities as a Group → Company → Plant tree. Real organization containment uses W3C ORG while Group/Company/Plant remain separate SKOS level concepts. Missing-parent, self-parent, and cyclic edges remain visible as unresolved roots; the UI owns nested `group` elements from their parent `treeitem`, supports Arrow/Home/End and Enter/Space operation, and opens source-backed evidence outside the tree. | ADR 0124, ADR 0004, ADR 0010 | Ontology/SHACL interoperability tests, `customerMasterTree.ts`, `CustomerMasterTree.tsx`, component tests, Storybook, and code commit `21074cf80cbfab3001bf18b6e1a618f75f4bed24` | +| FR-14 | Global Ask presents a dedicated evidence workspace: semantic form submission, IME-safe keyboard behavior, explicit empty/loading/error/answer states, separated timeline and cited evidence, answer focus, responsive phone/tablet/PC layout, and the existing authorized cited-post → Event Lineage handoff. | ADR 0127, ADR 0002, ADR 0032, ADR 0090 | `AskAgentWorkspace.tsx`, focused component/token tests, Storybook state inventory, and existing App navigation regressions on #353 | ## TRD @@ -211,6 +156,7 @@ sequenceDiagram | NFR-05 | Synthetic fixtures only; runtime validation returns aggregate, non-identifying evidence | repository scan and evidence-document review | | NFR-06 | ADR-first architectural change and paper-grounded model policy | ADR link check and review; unsupported policies remain unavailable | | NFR-07 | Buyer hierarchy controls meet WCAG 2.2 keyboard operation and the WAI-ARIA tree ownership contract without inventing ontology facts | Ontology tests, focused hierarchy tests, full frontend test/lint/build, Storybook build, and final-head hosted verification | +| NFR-08 | Ask Agent uses shared UI-standard button/focus/color/radius tokens, clear focus differentiation, a primary content action, and 1024px/768px responsive transitions without horizontal scrolling | Focused component and CSS-contract tests, complete frontend build, Storybook state build, and UI/UX Standard Guide v3.0 review | ## Current aggregate data and runtime evidence @@ -241,17 +187,19 @@ evidence for one authorized post, not a corpus-wide acceptance claim. | Closed gap | Root cause | Closure evidence | Remaining boundary | |---|---|---|---| +| Ask Agent had no dedicated UI component or executable state inventory; its chatbox reused a Keyman link-style action and mixed answer, timeline, citations, and evidence facts in one generic section. | The Global Ask feature accumulated inside `App.tsx` while the stack focused on authorization and cross-surface navigation, leaving presentation without its own ownership boundary. | #353 extracts a token-based evidence workspace, uses a semantic and IME-safe form, focuses completed answers, separates source-backed result regions, and adds five Storybook scenes plus focused regressions. | Streaming and persisted conversation history remain separate future product work; final-head hosted Checks and independent approval are still required. | | Customer entities could disappear from the buyer surface when `parent_entity_id` formed a self-parent or cycle; the first tree refactor also placed child `group` content beside rather than inside its parent `treeitem`. | The old projection assembled only root-reachable nodes, overloaded evidence state with hierarchy semantics, and did not satisfy the APG ownership rule. | Code commit `21074cf80cbfab3001bf18b6e1a618f75f4bed24` promotes malformed edges to visible unresolved roots, keeps ORG containment separate from SKOS classification, makes every parent `treeitem` own its child `group`, separates evidence into an external region, and adds navigation, failure, stale-response, ontology, and Storybook regressions. | The API still exposes one parent context; authoritative acyclicity, level-transition rules, legal/operating/sales/billing contexts, and effective-dated history remain future normalized-model work. | ## Active PR audit -A focused 2026-08-21 refresh found PR #258 open and mergeable at exact head -`99244658bc7edb7cf0c71cce2e3dcc59ff891b2b`. The organization queue has changed since the 18-row inventory below, so the +A focused 2026-08-21 refresh found PR #258 open and mergeable at customer-hierarchy +code commit `21074cf80cbfab3001bf18b6e1a618f75f4bed24`. The organization queue has changed since the 18-row inventory below, so the table is retained only as historical stack topology. Current acceptance must be read from the final PR head, valid unresolved threads, qualifying independent review, and terminal hosted Checks. | PR | Proposed increment | Base → head | Snapshot state | |---|---|---|---| +| #353 | Ask Agent evidence workspace and semantic chatbox | `#264` → `v2.18.0` | Exact-head verification and independent review required | | #301 | Global Ask knowledge cutoff | `#264 stack` → `v2.23.0` | Ready / UNSTABLE | | #298 | bounded async lineage LLM rebuild | `#276` → `v2.22.0` | Ready / UNSTABLE | | #287 | exact Event Lineage channel evidence | `#276` → feature | Ready / UNSTABLE | @@ -267,7 +215,8 @@ PR head, valid unresolved threads, qualifying independent review, and terminal h | #262 | Customer post to Event Lineage | `#261` → `v2.15.0` | Ready / BLOCKED / review required | | #261 | Calendar commitment to Event Lineage | `#260` → `v2.14.0` | Ready / BLOCKED / review required | | #260 | Weekly VOC to Event Lineage | `#258` → `v2.13.0` | Ready / DIRTY / review required | -| #258 | buyer evidence board, standards-composed ontology, and cycle-safe Customer Master tree | `main` → `99244658bc7edb7cf0c71cce2e3dcc59ff891b2b` | Ready / mergeable / final-head Checks and independent approval pending | +| #258 | buyer evidence board, standards-composed ontology, and cycle-safe Customer Master tree | `main` → `21074cf80cbfab3001bf18b6e1a618f75f4bed24` | Ready / mergeable / final-head Checks and independent approval pending | +| #258 | buyer evidence board, standards-composed ontology, and cycle-safe Customer Master tree | `main` → `21074cf80cbfab3001bf18b6e1a618f75f4bed24` | Ready / mergeable / final-head Checks and independent approval pending | | #192 | plural affiliation next action | `main` → `v0.77.0` | Ready / DIRTY / review required | | #190 | duplicate-numbered entity-resolution ADR | `main` → docs | Ready / BLOCKED | @@ -291,11 +240,11 @@ the exact-head disposition. | P0 | No protected-main integrated buyer journey for the active feature stack | Main is 2.12.5; 18 open PRs span dependent and parallel bases | Establish one reviewed integration order, update each exact head, pass required checks, merge without bypass, then run login-to-source browser acceptance on main | | P0 | Current runtime proof is incomplete | The current aggregate/OIDC/ABAC checks cover data presence and selected boundaries; 2026-08-18/19 notes cover other slices, but no evidence set proves the entire PR head or main journey | Complete the real-stack matrix on an exact revision: browser login/navigation, Ask, reports, Vision, TEPP availability, action population, and cleanup | | P0 | PR #190's duplicate ADR identity was corrected but is not protected-main truth | Active PR head `ac1b4e17` now uses ADR 0038 and aligns the entity-resolution claims with implementation; independent review and Checks remain pending | Re-audit exact head, obtain independent approval, pass required Checks, and merge normally; never merge a duplicate ADR identity | -| P0 | PR #258 still requires final-head review and hosted CI | Exact head is `99244658bc7edb7cf0c71cce2e3dcc59ff891b2b`; branch-local verification does not transfer to a later head | Re-read review threads, obtain qualifying independent approval, require all final-head hosted Checks to reach terminal success, and merge only through normal protection | +| P0 | PR #258 still requires final-head review and hosted CI | Customer hierarchy code is at `21074cf80cbfab3001bf18b6e1a618f75f4bed24`; branch-local verification does not transfer to the following documentation-only head | Re-read review threads, obtain qualifying independent approval, require all final-head hosted Checks to reach terminal success, and merge only through normal protection | | P1 | Requirements were implicit across ADRs and architecture phases | No prior PRD/TRD/requirement traceability baseline existed | Keep FR/NFR IDs in this document linked from ADR index; require new product PRs to name affected IDs and runtime evidence | | P1 | Active PR topology obscures release truth | 8 blocked, 8 unstable, and 2 dirty; many bases are other open branches | Publish a dependency order, retire obsolete/duplicate branches, and avoid version claims until their base chain reaches main | | P1 | ADR 0102 schema exists but current data does not exercise it | Commit `15e1a378` is on PR #258 and the table exists, but 95 summaries yield zero requester/processor action rows | Regenerate an authorized bounded sample, report aggregate accepted/dropped/absent counts, verify source evidence and actor FKs, then exercise the buyer popup without exposing record content | -| P1 | ADR 0126 is active-PR behavior but not protected-main behavior | Commit `1c260f20` contains the corrected ADR link, boundary, and focused tests; independent review and protected-main merge remain pending | Re-audit the exact head, obtain independent approval, pass required checks, merge normally, and collect fresh runtime evidence | +| P1 | ADR 0101 is active-PR behavior but not protected-main behavior | Commit `1c260f20` contains the corrected ADR link, boundary, and focused tests; independent review and protected-main merge remain pending | Re-audit the exact head, obtain independent approval, pass required checks, merge normally, and collect fresh runtime evidence | | P1 | ADR status vocabulary is inconsistent and sometimes stale | Several ADRs say “Accepted on this active PR; not protected-main truth” even after branch evolution | Add a mechanical ADR status/link audit that distinguishes Proposed, Accepted-on-PR, Accepted-on-main, and Superseded | | P2 | ADR numbering skips 0031 and 0093-0097 while file 0092 titles itself ADR 0031 | File identity and displayed identity differ | Correct the 0092 title or document an intentional alias; reserve or explain skipped numbers in the index | | P2 | Product measures lack explicit targets | Research supports evidence boundaries but not universal model-quality thresholds | Define targets only from an approved evaluation protocol and authorized labeled aggregate dataset; do not invent accuracy goals | @@ -317,26 +266,4 @@ projection: update the affected FR/NFR row and Gap closure evidence when an ADR or PR changes product behavior. Never turn a PR title, green unit test, or old runtime note into a shipped/live claim. -## Current stacked PR product-surface gaps - -- **Customer Master relationship composition — PR #262**: Resolved on the - current feature branch. ADR 0125 and Figma frames `313:2` / `314:2` define a - customer-centered three-pane workspace that keeps the selected customer - stable while the user inspects relationships and source posts. -- **Responsive Customer Master flow — PR #262**: Resolved on the current - feature branch. PC uses three horizontal panes, tablet uses two columns plus - full-width evidence, and phone preserves the semantic order hierarchy → - selected customer → evidence at the shared 1024 px / 768 px breakpoints. -- **Effective-dated relationship authority**: Open. The current projection - still owns one `parent_entity_id`; legal ownership, operating structure, - sales roll-up, billing hierarchy, historical roles, and simultaneous - relationship types require a normalized effective-dated relation model. -- **Unresolved hierarchy repair workflow**: Open. Cycle, self-parent, and - missing-visible-parent members remain visible and unresolved, but operators - still need a source-data quality queue, evidence review, and approved - correction workflow. -- **Customer relationship exact-value export**: Open. An auditable CSV/JSON - export of the selected customer, visible relations, truth status, effective - interval, and evidence references remains a later product slice. - *This document is continuously updated by the hourly automated agent loop.* diff --git a/docs/storybook-inventory.md b/docs/storybook-inventory.md index 28c59bd48..b4cda9a6d 100644 --- a/docs/storybook-inventory.md +++ b/docs/storybook-inventory.md @@ -5,6 +5,7 @@ buyer-facing control you can click before changing product CSS. | Story | Buyer next action | Token / module | |---|---|---| +| `Ask/AskAgentWorkspace` | Review empty, loading, answered, unavailable, and phone states; open cited evidence after an answer. | UI-standard primary-button/focus tokens, responsive layout, `AskAgentWorkspace` | | `Evidence/CitationChip` | Click a cited title to open that source post. | `--color-chip-border`, `--radius-chip`, `CitationChip` | | `AnalysisRun/CutoffKnownBody` | Read the cutoff-known sentence, then compare it with the live body below. | `--color-accent-border`, `--space-panel-block`, `--radius-panel`, `CutoffKnownBody` | | `Analysis/LineageEntityPicker` | Choose which corp to reconstruct, then click Request a lineage reconstruction. | `--space-control-gap`, `--size-control-min`, `--radius-control`, `LineageEntityPicker` | diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index dfb136f2f..099a50564 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,7 +4,6 @@ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react" import { useAuth } from "react-oidc-context"; import { askPostChat, - askAgent, BackendError, createAnalysisRun, startAnalysisRun, @@ -50,7 +49,6 @@ import { updateTicketStatus, verifyPostRelations, type ActivityEvent, - type AskAgentResponse, type AffiliateNode, type AnalysisRun, type CalendarResponse, @@ -99,6 +97,10 @@ import { type ProjectHistoryProjection, } from "./projectHistory"; import { CustomerMasterTree, CustomerRelatedPostCard } from "./components/CustomerMasterTree"; +import { + AskAgentWorkspace as AskAgentPanel, + GLOBAL_ASK_SESSION_STORAGE_KEY, +} from "./components/AskAgentWorkspace"; import { subgraphForPost } from "./lineageLayout"; import { isSupportedLocale, @@ -116,7 +118,6 @@ import { } from "./analysisRunNavigation"; import "./App.css"; -const GLOBAL_ASK_SESSION_STORAGE_KEY = "lineageweave.globalAskSessionId"; function orchestratorUnavailableMessage(err: unknown, action: string): string { if (err instanceof BackendError && err.status === 503) { @@ -791,16 +792,6 @@ function projectProvenanceLabel(provenance: string): string { return t(PROJECT_PROVENANCE_LABELS[provenance] ?? "Recorded evidence"); } -const CHAT_EVIDENCE_KIND_LABELS: Record = { - source_field: "Source field hint", - semantic_project: "Semantic project", - semantic_role: "Semantic role", - semantic_keyman: "Semantic Keyman", -}; - -function chatEvidenceKindLabel(kind: string): string { - return t(CHAT_EVIDENCE_KIND_LABELS[kind] ?? "Evidence"); -} const VERIFICATION_BADGE: Record = { verify_pending: "Not yet checked", @@ -4591,202 +4582,6 @@ function CustomerMasterPanel({ ); } -function askCitedNextAction(answer: AskAgentResponse): string { - if (answer.grounding_status === "fully_cutoff_grounded") { - return ( - answer.next_action || - "This answer is fully grounded at the requested cutoff. Open a cited post to compare the retained body." - ); - } - if (answer.grounding_status === "partially_cutoff_grounded") { - return ( - answer.next_action || - "This answer is only partly grounded at the requested cutoff. Open a cited post to see which historical bodies were retained." - ); - } - return "Authorized cited posts are current. Open a cited post to read Event Lineage."; -} - -function toKnowledgeCutoffIso(value: string): string | undefined { - const trimmed = value.trim(); - if (!trimmed) return undefined; - const parsed = new Date(trimmed); - if (Number.isNaN(parsed.getTime())) return undefined; - return parsed.toISOString(); -} - -function AskAgentPanel({ - accessToken, - onOpenPost, -}: { - accessToken: string; - onOpenPost: (postId: string) => void; -}) { - const [question, setQuestion] = useState(""); - const [knowledgeCutoff, setKnowledgeCutoff] = useState(""); - const [answer, setAnswer] = useState(null); - const [error, setError] = useState(null); - const [asking, setAsking] = useState(false); - const [sessionId, setSessionId] = useState(() => - window.sessionStorage.getItem(GLOBAL_ASK_SESSION_STORAGE_KEY) ?? undefined, - ); - - async function handleAsk() { - const normalized = question.trim(); - if (!normalized) return; - setAsking(true); - setError(null); - setAnswer(null); - try { - let nextAnswer: AskAgentResponse; - try { - nextAnswer = await askAgent( - accessToken, - normalized, - sessionId, - toKnowledgeCutoffIso(knowledgeCutoff), - ); - } catch (err) { - if (!(err instanceof BackendError) || err.status !== 404 || !sessionId) { - throw err; - } - setSessionId(undefined); - window.sessionStorage.removeItem(GLOBAL_ASK_SESSION_STORAGE_KEY); - nextAnswer = await askAgent( - accessToken, - normalized, - undefined, - toKnowledgeCutoffIso(knowledgeCutoff), - ); - } - setAnswer(nextAnswer); - setSessionId(nextAnswer.session_id); - window.sessionStorage.setItem(GLOBAL_ASK_SESSION_STORAGE_KEY, nextAnswer.session_id); - } catch (err) { - setAnswer(null); - setError(orchestratorUnavailableMessage(err, t("Ask Agent"))); - } finally { - setAsking(false); - } - } - - return ( -
-

{t("Evidence-grounded questions")}

-

{t("Ask Agent")}

-

{t("Questions use authorized posts and their evidence.")}

- {error ?

{error}

: null} -