chore(task): archive 07-08-complete-ops-ai-board
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{"file":".trellis/spec/backend/type-safety.md","reason":"Check backend AI aggregation and seed helper typing."}
|
||||
{"file":".trellis/spec/frontend/components.md","reason":"Check dashboard rendering remains Server Component and uses persisted data only."}
|
||||
{"file":".trellis/spec/shared/code-quality.md","reason":"Check focused tests, no dead code, no console logs, and no forbidden TypeScript patterns."}
|
||||
{"file":".trellis/spec/guides/pre-implementation-checklist.md","reason":"Check cross-layer dashboard data flow and permission gates."}
|
||||
@@ -0,0 +1,61 @@
|
||||
# Design
|
||||
|
||||
## Boundaries
|
||||
|
||||
This task is a completion pass over existing persisted modules. It does not add schema or a new AI provider path.
|
||||
|
||||
- Collaboration data remains owned by `modules/devices`, `modules/notices`, `modules/alerts`, and `modules/family`.
|
||||
- Dashboard data loading stays in the Server Component at `app/(app)/app/dashboard/page.tsx`.
|
||||
- Presentation stays in `modules/dashboard/components/DashboardHome.tsx`.
|
||||
- AI board aggregation belongs in `modules/ai/server/analysis.ts` because redaction depends on existing AI analysis scope rules.
|
||||
|
||||
## Data Flow
|
||||
|
||||
1. Dashboard page loads auth context and checks whether any visible dashboard section is permitted.
|
||||
2. It conditionally calls existing operations for core care/health/emergency and collaboration modules.
|
||||
3. It calls a new AI analysis listing function only when `ai:read` is present.
|
||||
4. The AI service lists organization-scoped `elder_ai_analyses`, joins elders for display names, and maps each row through `canViewAnalysisScopes`.
|
||||
5. The dashboard component receives only serializable data and renders queue cards/summary cards from that data.
|
||||
|
||||
## Seeding Strategy
|
||||
|
||||
Existing `seedDefaultWorkspaceData` exits early when core room/bed/elder/admission rows already exist. That protected existing workspaces, but it skipped collaboration seed records added later. Add a separate idempotent collaboration seeding helper that:
|
||||
|
||||
- reads existing rows by stable natural keys per table;
|
||||
- inserts only missing default rows;
|
||||
- resolves dependencies from existing or newly inserted rows;
|
||||
- never updates or deletes existing operator data;
|
||||
- runs both for fully new workspaces and for already-initialized workspaces.
|
||||
|
||||
Stable keys:
|
||||
|
||||
- devices: `code`
|
||||
- tickets: `title`
|
||||
- notices: `title`
|
||||
- alert rules: `name`
|
||||
- alert triggers: `title`
|
||||
- family contacts: `elderId + name`
|
||||
- family visits: `elderId + contactId + scheduled offset/status/notes` is not stable across reruns, so use `elderId + contactId + notes` for default records
|
||||
- family feedback: `elderId + contactId + content`
|
||||
|
||||
## Permission Model
|
||||
|
||||
- Dashboard visibility expands to collaboration and AI read permissions.
|
||||
- Collaboration sections call server operations only when their read permission is present.
|
||||
- AI board calls the aggregation function only with `ai:read`.
|
||||
- Redaction uses the existing `canViewAnalysisScopes` and `getPermissionForDataScope` rules, so a user may see that an analysis exists without seeing restricted result details.
|
||||
|
||||
## UI Shape
|
||||
|
||||
- Keep `DashboardHome` as a single Server-rendered component with small local helper render functions.
|
||||
- Add collaboration queue cards for device tickets, notices, alert triggers, and family items.
|
||||
- Add an AI analysis board card with risk/status badges, data scopes, created time, and a link back to the elder workspace.
|
||||
- Empty states must be honest: no generated counts or placeholder rows.
|
||||
|
||||
## Compatibility
|
||||
|
||||
No schema migration is required. The seeding helper is additive and only inserts missing default data.
|
||||
|
||||
## Rollback
|
||||
|
||||
Rollback is limited to the AI aggregation helper, dashboard props/rendering, dashboard page conditional loads, and the additive seed helper. Existing collaboration CRUD modules remain untouched unless tests expose a direct integration bug.
|
||||
@@ -0,0 +1,5 @@
|
||||
{"file":".trellis/spec/backend/type-safety.md","reason":"Backend service results, scope narrowing, and no non-null assertions."}
|
||||
{"file":".trellis/spec/frontend/components.md","reason":"Dashboard Server Component data loading, Kumo UI adapter use, and no fake operational data."}
|
||||
{"file":".trellis/spec/shared/typescript.md","reason":"Shared TypeScript constraints for exported types and discriminated unions."}
|
||||
{"file":".trellis/spec/shared/code-quality.md","reason":"No any, no non-null assertions, import ordering, and test expectations."}
|
||||
{"file":".trellis/spec/guides/pre-implementation-checklist.md","reason":"Cross-layer readiness checks before dashboard and seed changes."}
|
||||
@@ -0,0 +1,34 @@
|
||||
# Implementation Plan
|
||||
|
||||
## 1. Planning and Context
|
||||
|
||||
- [x] Read Trellis workflow context and relevant backend/frontend/shared specs.
|
||||
- [x] Inspect existing collaboration modules, dashboard page/component, AI analysis service, permissions, and seed data.
|
||||
- [x] Persist PRD, design, implementation plan, and curated spec manifests.
|
||||
|
||||
## 2. Seeding
|
||||
|
||||
- [x] Extract idempotent collaboration seed helper from the full-workspace seed path.
|
||||
- [x] Call the helper for both existing core workspaces and newly seeded workspaces.
|
||||
- [x] Preserve existing operator rows and insert only missing default records.
|
||||
|
||||
## 3. AI Analysis Board
|
||||
|
||||
- [x] Add an organization-scoped AI board listing function that joins elder names and redacts restricted analysis rows.
|
||||
- [x] Add serializable dashboard board item types.
|
||||
- [x] Keep existing elder-specific analysis APIs unchanged.
|
||||
|
||||
## 4. Dashboard Integration
|
||||
|
||||
- [x] Expand dashboard permission gate to collaboration and AI read permissions.
|
||||
- [x] Conditionally load devices, notices, alerts, family, and AI board data by permission.
|
||||
- [x] Render collaboration cards and AI analysis board from persisted data only.
|
||||
- [x] Preserve slug-aware links via `getWorkspaceHref`.
|
||||
|
||||
## 5. Verification
|
||||
|
||||
- [x] Add focused tests for collaboration seed idempotency and AI board redaction.
|
||||
- [x] Run focused tests covering changed code.
|
||||
- [x] Run `pnpm type-check`.
|
||||
- [x] Smoke-test the dashboard route when feasible via `pnpm build` route compilation.
|
||||
- [x] Add latency controls for AI provider timeout, token cap, retry count, and sanitized timeout failure history.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Complete operations modules and AI analysis board
|
||||
|
||||
## Goal
|
||||
|
||||
Finish the currently visible operations surface by making collaboration modules fully reachable from the workspace/dashboard and adding a real persisted AI analysis board that summarizes elder AI analysis history without fabricating data.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Keep the existing persisted collaboration modules for devices, notices, alerts, and family visible through permission-aware workspace navigation and dashboard entry points.
|
||||
- Seed collaboration-module records idempotently for already-initialized local/demo organizations without overwriting operator-created records.
|
||||
- Show an AI analysis board from persisted `elder_ai_analyses` rows, joined to elder names, with permission-aware redaction for unavailable data scopes.
|
||||
- Restrict AI board access to users with `ai:read`; never expose analysis content when underlying data-scope permissions are missing.
|
||||
- Preserve organization scoping for all data loads and route links, including slug-aware `/app/{organizationSlug}/...` links.
|
||||
- Reuse existing module server operations and UI adapters; do not add new dependencies or fake/static operational data.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [x] Existing collaboration modules remain data-backed and reachable from unscoped and organization-scoped workspace routes.
|
||||
- [x] Existing workspaces with core resident data but no collaboration data receive missing default devices, notices, alerts, and family records on seed rerun.
|
||||
- [x] The dashboard can be viewed by users with collaboration or AI read permissions, not only core care/facility permissions.
|
||||
- [x] The dashboard renders collaboration queues/metrics only from persisted server queries and hides unavailable sections by permission.
|
||||
- [x] The dashboard renders an AI analysis board sourced from persisted analysis history when `ai:read` is present.
|
||||
- [x] AI analysis board items redact result content when `canViewAnalysisScopes` denies one or more stored data scopes.
|
||||
- [x] Focused tests cover idempotent collaboration seeding and AI board redaction behavior.
|
||||
- [x] `pnpm type-check` and focused tests pass.
|
||||
- [x] Elder AI generation uses bounded provider timeout, token, and retry controls so slow providers fail with sanitized timeout history instead of hanging indefinitely.
|
||||
|
||||
## Notes
|
||||
|
||||
- Out of scope: background alert-rule execution, family portal/authentication, AI recommendation/business-action generation changes, and new database schema.
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id": "complete-ops-ai-board",
|
||||
"name": "complete-ops-ai-board",
|
||||
"title": "Complete operations modules and AI analysis board",
|
||||
"description": "",
|
||||
"status": "completed",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
"priority": "P2",
|
||||
"creator": "TalexDreamSoul",
|
||||
"assignee": "TalexDreamSoul",
|
||||
"createdAt": "2026-07-08",
|
||||
"completedAt": "2026-07-09",
|
||||
"branch": null,
|
||||
"base_branch": "main",
|
||||
"worktree_path": null,
|
||||
"commit": null,
|
||||
"pr_url": null,
|
||||
"subtasks": [],
|
||||
"children": [],
|
||||
"parent": null,
|
||||
"relatedFiles": [],
|
||||
"notes": "",
|
||||
"meta": {}
|
||||
}
|
||||
Reference in New Issue
Block a user