Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 217 additions & 0 deletions multiagent_inventory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Multiagent Feature Identification - Inventory (RMP)

This folder contains a static mock page plus implementation notes for adding the **Multiagent Feature Identification - Inventory** experience to the Risk Management Platform (RMP). The mock mirrors the existing RMP layout (red header, left sidebar, breadcrumb, filter bar, table, pagination, modals) and is ready to be wired to live APIs.

## Files
- `index.html` – static mock page with filter bar, paginated table, download actions, and feedback modal.
- `style.css` – styles matching the current RMP look-and-feel (red header, sidebar, card/table/pagination).
- `script.js` – vanilla JS with static data, filtering, sorting, pagination, and feedback submission demo.

Open the mock locally with any static server, for example:

```bash
cd multiagent_inventory
python -m http.server 8000
# then visit http://localhost:8000
```

---

## UI Component Breakdown (match existing RMP patterns)

- **Layout shell**: fixed red top header, left sidebar, main content with breadcrumb + page title. Sidebar adds a new menu entry under **Risk Application → Multiagent Inventory**.
- **Breadcrumb**: `Risk Application / Multiagent / Feature Inventory`.
- **Page title**: `Multiagent Feature Identification - Inventory` with optional badge (e.g., Preview/Beta).
- **Top-right actions**: `Download` (export filtered list), `New` (kept disabled/feature-gated by default).
- **Filter bar** (card header style):
1. Project ID (text, fuzzy)
2. Project Name (text, fuzzy)
3. Current Project Stage (select; dictionary-driven)
4. Note Generation Date (from/to date pickers)
5. Run Status (select: Draft/Generated/Failed/Archived)
- Buttons: **Search** (primary red), **Reset** (secondary)
- **Inventory table**:
1. Project ID (sortable)
2. Project Name (clickable → detail drawer/page)
3. Current Project Stage (sortable)
4. Note Generation Date (sortable)
5. Run Version (V1/V2/V3)
6. Generated By
7. Project Document (Download)
8. PD Review Report (Download)
9. Feedback (Add, View(count))
10. Actions (View Detail / Archive as needed)
- **Pagination**: default 50 rows/page; shows total and page jump input consistent with RMP.
- **Feedback modal**: prefilled readonly project + user fields; required team dropdown and comments; optional feedback type; Cancel/Submit with toast and refresh.
- **Permission cues**:
- `Multiagent_Admin`: full access, archive, view feedback
- `Multiagent_Reviewer`: can submit feedback and download files
- `Multiagent_ViewOnly`: hide/disable feedback submit and archive; view/download only
- Hide page/menu or show “No Access” when unauthorized.

---

## Backend Controller/Service Pseudocode

### List Runs
```pseudo
GET /api/multiagent/runs
authz: require role in {Admin, Reviewer, ViewOnly}
params: project_id?, project_name?, stage?, status?, note_generated_from?, note_generated_to?, page=1, page_size=50, sort_field?, sort_dir?
sql: SELECT ... FROM MA_RUN r
LEFT JOIN MA_FILE f_in ON r.input_doc_file_id = f_in.file_id
LEFT JOIN MA_FILE f_out ON r.output_report_file_id = f_out.file_id
WHERE matches(filters) AND not_deleted
ORDER BY sort_field sort_dir
LIMIT page_size OFFSET (page-1)*page_size
result: list + total_count
```

### Download File
```pseudo
GET /api/multiagent/files/{file_id}/download
authz: same roles; ensure caller can access project/run
lookup file metadata in MA_FILE; audit log
return streamed file or pre-signed URL from object storage
```

### Submit Feedback
```pseudo
POST /api/multiagent/runs/{run_id}/feedback { team_code, comment_text, feedback_type? }
authz: Admin or Reviewer (ViewOnly => 403)
validate: comment length 10-2000, team_code in dictionary
derive identity from session/token (do not trust body)
insert into MA_FEEDBACK (run_id, project_id, user_name, user_email, team_code, comment_text, feedback_type, created_at)
update aggregated feedback_count in MA_RUN (optional optimization)
audit log submission
return created feedback_id
```

### Optional Endpoints
- `GET /api/multiagent/runs/{run_id}/feedback` – list feedback for a run.
- `POST /api/multiagent/runs/{run_id}/archive` – Admin only; mark run_status = Archived and hide from default view.

Service considerations: dictionary cache for stage/team values, consistent error model, and S3/MinIO abstraction for object storage.

---

## SQL Table DDL (minimum)
```sql
CREATE TABLE MA_FILE (
file_id UUID PRIMARY KEY,
file_type VARCHAR(40) NOT NULL, -- InputDoc, OutputReport, Other
file_name_original TEXT NOT NULL,
storage_key TEXT NOT NULL, -- bucket/key or path
mime_type VARCHAR(120),
file_size BIGINT,
checksum_sha256 CHAR(64),
uploaded_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
uploaded_by VARCHAR(120)
);

CREATE TABLE MA_RUN (
run_id UUID PRIMARY KEY,
project_id VARCHAR(64) NOT NULL,
run_seq INT NOT NULL,
run_version_label VARCHAR(20) GENERATED ALWAYS AS (CONCAT('V', run_seq)) STORED,
run_status VARCHAR(32) NOT NULL,
note_generated_at TIMESTAMP,
triggered_by_user_email VARCHAR(120),
model_version VARCHAR(64),
input_doc_file_id UUID REFERENCES MA_FILE(file_id),
output_report_file_id UUID REFERENCES MA_FILE(file_id),
feedback_count INT DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE(project_id, run_seq)
);

CREATE TABLE MA_FEEDBACK (
feedback_id UUID PRIMARY KEY,
run_id UUID NOT NULL REFERENCES MA_RUN(run_id),
project_id VARCHAR(64) NOT NULL,
user_name VARCHAR(120) NOT NULL,
user_email VARCHAR(160) NOT NULL,
user_team_code VARCHAR(40) NOT NULL,
comment_text TEXT NOT NULL,
feedback_type VARCHAR(40),
status VARCHAR(32) DEFAULT 'Open',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
resolved_at TIMESTAMP,
resolved_by VARCHAR(160)
);

-- Suggested indexes
CREATE INDEX idx_ma_run_project ON MA_RUN(project_id, run_status, note_generated_at DESC);
CREATE INDEX idx_ma_feedback_run ON MA_FEEDBACK(run_id, created_at DESC);
```

---

## Example API Responses

**List runs** – `GET /api/multiagent/runs?page=1&page_size=2&status=Generated`
```json
{
"page": 1,
"page_size": 2,
"total": 5,
"items": [
{
"run_id": "run-1002",
"project_id": "PRJ-1001",
"project_name": "Green Infra Modernization",
"stage": "Monitoring",
"run_seq": 2,
"run_version_label": "V2",
"run_status": "Generated",
"note_generated_at": "2024-10-04T00:00:00Z",
"triggered_by_user_email": "melissa.chen@aiib.org",
"input_doc": { "file_id": "file-in-1002", "file_name": "Project_PRJ-1001_V2_InputDoc_20241004.docx" },
"output_report": { "file_id": "file-out-1002", "file_name": "Project_PRJ-1001_V2_PDReviewReport_20241004.pdf" },
"feedback_count": 1
},
{
"run_id": "run-1001",
"project_id": "PRJ-1001",
"project_name": "Green Infra Modernization",
"stage": "Due Diligence",
"run_seq": 1,
"run_version_label": "V1",
"run_status": "Generated",
"note_generated_at": "2024-07-18T00:00:00Z",
"triggered_by_user_email": "melissa.chen@aiib.org",
"input_doc": { "file_id": "file-in-1001", "file_name": "Project_PRJ-1001_V1_InputDoc_20240718.pdf" },
"output_report": { "file_id": "file-out-1001", "file_name": "Project_PRJ-1001_V1_PDReviewReport_20240718.pdf" },
"feedback_count": 2
}
]
}
```

**Submit feedback** – `POST /api/multiagent/runs/{run_id}/feedback`
```json
{
"feedback_id": "fb-24871c3b-3df4-4c58-8f05-6bc3e5a4c845",
"run_id": "run-1002",
"project_id": "PRJ-1001",
"user_name": "Natalie Reviewer",
"user_email": "natalie.reviewer@aiib.org",
"user_team_code": "RM",
"feedback_type": "Enhancement",
"comment_text": "Please include borrower concentration analysis in the next version.",
"created_at": "2025-02-06T12:04:31Z"
}
```

---

## Integration Notes
- Keep the **New** button feature-gated or disabled until run-creation flow is ready.
- Respect permission model for menu visibility and feedback submission enablement.
- Derive user identity from the session/token server-side; never trust client-sent name/email.
- File downloads should stream or provide pre-signed URLs; suggested naming:
- `Project_{ProjectID}_{RunVersion}_InputDoc_{YYYYMMDD}.pdf`
- `Project_{ProjectID}_{RunVersion}_PDReviewReport_{YYYYMMDD}.pdf`
- Consider adding audit logs for downloads and feedback submissions.

Loading