Investigation Review Hub — Gap Analysis & Remediation Dashboard
Purpose
Generate a structured JSON deliverable for a legal investigation review by querying a shared Investigation Review Hub REST API, mapping its evidence (matters, subpoena categories, productions, custodian sources, documents, privilege-log entries, QC findings, retention events, and remediation actions) into a formal answer that conforms to a task-supplied JSON answer template.
When to Use
The task prompt asks you to use an Investigation Review Hub at a configurable base URL and requests a structured JSON output — typically a gap analysis, retention/preservation review, production-readiness assessment, remediation dashboard, or priority action plan tied to subpoena/request categories.
Operating Rules
1. Resolve the Environment
- Read
environment_access.md in the working directory if it exists. It provides:
base_url — the real hub base URL (overrides any <TASK_ENV_BASE_URL> placeholder in prompt text or payloads).
credentials.sql_endpoint_header and credentials.sql_endpoint_api_key — the header name and value for the read-only SQL query endpoint.
allowed_endpoints — the exact list of hub endpoints available for this task run.
runtime_notes — additional constraints (e.g., "use http://task-env:9017/ from inside the Docker agent container").
- Substitute
<TASK_ENV_BASE_URL> with the resolved base_url everywhere it appears.
- Use the credential header (
X-API-Key with the supplied key) on the POST /api/query endpoint only. Other endpoints may or may not require it — follow the task's explicit instructions.
2. Read All Task Inputs
Every train task provides three kinds of input files under input/:
| File |
Purpose |
prompt.txt |
Natural-language task description, matter identifier, deliverable type, and any special focus areas. |
payloads/answer_template.json |
The exact JSON schema your output must satisfy — top-level keys, field types, enum choices, ordering rules, and numeric precision. |
payloads/<context_file>.json |
Task-specific metadata: matter ID, client, category synopses, allowed/excluded sources, request type. May be named request_context.json, review_scope.json, or matter_context.json. |
Critical: The answer template is a schema, not a skeleton. It defines what you must produce, not what the answer is. Read every field description, enum list, and ordering rule.
3. Source of Record
- Only the Investigation Review Hub endpoints are the source of record for business evidence.
- Do not inspect, read, or use:
- Local environment source files
- Database files (
.db, .sqlite, etc.)
- Generated manifests or seed data
setup.sh, .env, or environment variable files
- Any task answer, evaluation, or hidden files
- Local payload files (
review_scope.json, etc.) provide context labels only (category titles, client name, request type). They do not supply counts, statuses, finding IDs, or metrics.
4. Hub Endpoint Inventory
The hub exposes these read-only endpoints (exact list confirmed by environment_access.md):
| Method |
Path |
Returns |
| GET |
/ |
Hub root / health |
| GET |
/api/schema |
Table/view/column definitions available via SQL query |
| GET |
/api/matters |
Matter metadata (matter ID, client, type, status, hold dates) |
| GET |
/api/subpoena-categories |
Request category codes, descriptions, response status per matter |
| GET |
/api/productions |
Rolling production records with document counts per category |
| GET |
/api/custodian-sources |
Custodian data sources, collection status, device types |
| GET |
/api/documents/search |
Document-level coding, privilege, and production metadata (supports query params) |
| GET |
/api/privilege-log |
Privilege log entries — logged vs. withheld vs. waived |
| GET |
/api/qc-findings |
QC review findings — miscodes, responsiveness errors, coding defects |
| GET |
/api/retention-events |
Retention events — policy destructions, auto-purges, post-hold losses, missing records |
| GET |
/api/remediation-actions |
Previously logged or recommended remediation actions |
| POST |
/api/query |
Read-only SQL queries against the hub's backing store |
Use the SQL endpoint sparingly — prefer the structured GET endpoints when they return the needed evidence directly.
5. Answer Template Conformance
Every answer template follows a consistent meta-schema. Obey these rules without exception:
Top-Level Keys
- Include exactly the keys listed in
required_top_level_keys (no extras, no omissions).
- Each key's type and structure are defined in
fields.<key> or schema.<key>.
Ordering Rules
- Lists must be sorted per
ordering_rules. Common patterns:
- Findings/risks/issues sorted by
finding_id / risk_id / issue_id / event_id / correction_id ascending.
- Category statuses/coverage sorted by
category_code ascending.
- Action plans sorted by
priority_rank or rank ascending (1 = highest).
- Category code lists within items sorted ascending.
- Source/reference ID lists within items sorted ascending.
- When in doubt, the ordering rule takes precedence over the natural order of hub records.
Enum Discipline
- Every string field typed as
enum:<set> or listed under enums must use only values from the declared set.
- Do not invent, approximate, or paraphrase enum values.
- If no enum value perfectly matches the evidence, pick the closest declared value — do not create a new one.
Numeric Precision
- All counts are whole integers (no decimals, no floats, no nulls).
- Use
0 when a count is not applicable (never omit the key, never use null).
- Where a count is described as "from selected incomplete-log blockers only" or similar qualifier, scope it exactly as described.
Stable Record IDs
- Every finding, risk, issue, source, event, or correction you anchor must use the exact stable record ID from the hub response (
id, source_id, event_id, finding_id, correction_id, etc.).
- Do not generate synthetic IDs, sequential numbers, or composite keys.
- When a finding references multiple hub records, list them all in
source_refs / record_refs / blocking_refs / issue_refs as appropriate.
6. Evidence-to-Finding Mapping
When converting raw hub evidence into template items:
Identify gaps: Compare what the subpoena categories request against what productions, custodian sources, and documents actually deliver. Look for:
- Categories with zero or under-scale productions.
- Custodian sources marked as
lost, not_collected, partial, or should_exist_missing.
- Documents coded responsive but not produced.
- Privilege-log entries that are withheld but unlogged (withheld count > logged count).
- QC findings flagging miscoded responsive documents.
- Retention events showing post-hold losses, auto-purges, or policy destructions.
Quantify each finding: Pull document counts, withheld/logged/unlogged counts, source counts, and volume numbers from the hub data. Every count in your output must be traceable to a specific hub record or aggregation of hub records.
Assign severity/risk: Match the gap magnitude and legal exposure to the template's severity/risk enum. Critical = certain regulatory impact or spoliation risk. High = material gap with uncertain remediation. Medium = partial gap with known remediation path. Low = minor, remediable, or policy-compliant pre-hold.
Link to categories: Every finding must list which request category codes it impacts (category_impacts, affected_categories, or category_impacts depending on template). Use the exact codes from the hub's subpoena categories.
Recommend actions: Match each finding to an action from the template's action_type enum. Escalation actions (disclose, waiver assessment) come before remediation actions (collect, recode, supplement log). Monitoring-only actions go last.
7. Metrics Construction
Metrics objects aggregate counts across all findings/events/sources. Rules:
- Read the required_keys list in the template's metrics definition — those exact keys must be present.
- Sum conservatively: When the template asks for "unlogged privilege docs," count every document where
withheld_count > logged_count in the privilege-log data.
- Count distinct categories: When the template asks for
categories_with_open_gaps or categories_with_open_risk, list the unique category codes, not a count of findings.
- Boolean readiness:
rolling_production_ready / production_ready is true only when zero categories have open material gaps or unresolved blockers.
- Box counts: Some templates have specific box-count metrics (
destroyed_lab_archive_box_count, destroyed_box_count). Pull these from retention-event volume data. If the destroyed source is measured in records not boxes and the template says "or 0 when the task's destroyed source is not measured in boxes," use 0.
8. Action Plan Construction
- Each action targets one or more hub record IDs (
target_refs) and impacts one or more category codes (category_impacts / affected_categories).
- Rank by operational priority: P0/P1 (rank 1,2) = blocking production or requiring immediate disclosure. P2 (rank 3,4,…) = remediation with known path. P3 (last) = monitor or no action.
- Assign
owner from the template's owner enum — match the owner to the action type (e.g., forensics for device collection, privilege_team for privilege-log supplements, outside_counsel for disclosures).
- When the template includes
due_days, estimate based on the urgency implied by the severity and production timeline.
9. Output Format
- Return one JSON object and no prose outside the JSON.
- The JSON must parse as valid JSON (double-quoted keys and strings, no trailing commas).
- Do not wrap the JSON in markdown code fences unless the task prompt explicitly permits it. Prefer raw JSON.
- All strings use the exact casing from hub data or template enums.
10. Verification Checklist (Before Returning)
Run this checklist against your output before delivering:
1---2name: self-attempt-02-573description: Investigation Review Hub — Gap Analysis & Remediation Dashboard4---5# Investigation Review Hub — Gap Analysis & Remediation Dashboard67## Purpose89Generate a structured JSON deliverable for a legal investigation review by querying a shared Investigation Review Hub REST API, mapping its evidence (matters, subpoena categories, productions, custodian sources, documents, privilege-log entries, QC findings, retention events, and remediation actions) into a formal answer that conforms to a task-supplied JSON answer template.1011## When to Use1213The task prompt asks you to use an Investigation Review Hub at a configurable base URL and requests a structured JSON output — typically a gap analysis, retention/preservation review, production-readiness assessment, remediation dashboard, or priority action plan tied to subpoena/request categories.1415---1617## Operating Rules1819### 1. Resolve the Environment2021- Read `environment_access.md` in the working directory if it exists. It provides:22 - `base_url` — the real hub base URL (overrides any `<TASK_ENV_BASE_URL>` placeholder in prompt text or payloads).23 - `credentials.sql_endpoint_header` and `credentials.sql_endpoint_api_key` — the header name and value for the read-only SQL query endpoint.24 - `allowed_endpoints` — the exact list of hub endpoints available for this task run.25 - `runtime_notes` — additional constraints (e.g., "use `http://task-env:9017/` from inside the Docker agent container").26- Substitute `<TASK_ENV_BASE_URL>` with the resolved `base_url` everywhere it appears.27- Use the credential header (`X-API-Key` with the supplied key) on the `POST /api/query` endpoint only. Other endpoints may or may not require it — follow the task's explicit instructions.2829### 2. Read All Task Inputs3031Every train task provides three kinds of input files under `input/`:3233| File | Purpose |34|---|---|35| `prompt.txt` | Natural-language task description, matter identifier, deliverable type, and any special focus areas. |36| `payloads/answer_template.json` | The exact JSON schema your output must satisfy — top-level keys, field types, enum choices, ordering rules, and numeric precision. |37| `payloads/<context_file>.json` | Task-specific metadata: matter ID, client, category synopses, allowed/excluded sources, request type. May be named `request_context.json`, `review_scope.json`, or `matter_context.json`. |3839**Critical**: The answer template is a *schema*, not a skeleton. It defines *what* you must produce, not *what the answer is*. Read every field description, enum list, and ordering rule.4041### 3. Source of Record4243- **Only** the Investigation Review Hub endpoints are the source of record for business evidence.44- **Do not** inspect, read, or use:45 - Local environment source files46 - Database files (`.db`, `.sqlite`, etc.)47 - Generated manifests or seed data48 - `setup.sh`, `.env`, or environment variable files49 - Any task answer, evaluation, or hidden files50- Local payload files (`review_scope.json`, etc.) provide **context labels only** (category titles, client name, request type). They do **not** supply counts, statuses, finding IDs, or metrics.5152### 4. Hub Endpoint Inventory5354The hub exposes these read-only endpoints (exact list confirmed by `environment_access.md`):5556| Method | Path | Returns |57|---|---|---|58| GET | `/` | Hub root / health |59| GET | `/api/schema` | Table/view/column definitions available via SQL query |60| GET | `/api/matters` | Matter metadata (matter ID, client, type, status, hold dates) |61| GET | `/api/subpoena-categories` | Request category codes, descriptions, response status per matter |62| GET | `/api/productions` | Rolling production records with document counts per category |63| GET | `/api/custodian-sources` | Custodian data sources, collection status, device types |64| GET | `/api/documents/search` | Document-level coding, privilege, and production metadata (supports query params) |65| GET | `/api/privilege-log` | Privilege log entries — logged vs. withheld vs. waived |66| GET | `/api/qc-findings` | QC review findings — miscodes, responsiveness errors, coding defects |67| GET | `/api/retention-events` | Retention events — policy destructions, auto-purges, post-hold losses, missing records |68| GET | `/api/remediation-actions` | Previously logged or recommended remediation actions |69| POST | `/api/query` | Read-only SQL queries against the hub's backing store |7071Use the SQL endpoint **sparingly** — prefer the structured GET endpoints when they return the needed evidence directly.7273### 5. Answer Template Conformance7475Every answer template follows a consistent meta-schema. Obey these rules without exception:7677#### Top-Level Keys78- Include **exactly** the keys listed in `required_top_level_keys` (no extras, no omissions).79- Each key's type and structure are defined in `fields.<key>` or `schema.<key>`.8081#### Ordering Rules82- Lists must be sorted per `ordering_rules`. Common patterns:83 - Findings/risks/issues sorted by `finding_id` / `risk_id` / `issue_id` / `event_id` / `correction_id` ascending.84 - Category statuses/coverage sorted by `category_code` ascending.85 - Action plans sorted by `priority_rank` or `rank` ascending (1 = highest).86 - Category code lists within items sorted ascending.87 - Source/reference ID lists within items sorted ascending.88- When in doubt, the ordering rule takes precedence over the natural order of hub records.8990#### Enum Discipline91- Every string field typed as `enum:<set>` or listed under `enums` must use **only** values from the declared set.92- Do not invent, approximate, or paraphrase enum values.93- If no enum value perfectly matches the evidence, pick the **closest** declared value — do not create a new one.9495#### Numeric Precision96- All counts are **whole integers** (no decimals, no floats, no nulls).97- Use `0` when a count is not applicable (never omit the key, never use `null`).98- Where a count is described as "from selected incomplete-log blockers only" or similar qualifier, scope it exactly as described.99100#### Stable Record IDs101- Every finding, risk, issue, source, event, or correction you anchor must use the **exact stable record ID** from the hub response (`id`, `source_id`, `event_id`, `finding_id`, `correction_id`, etc.).102- Do not generate synthetic IDs, sequential numbers, or composite keys.103- When a finding references multiple hub records, list them all in `source_refs` / `record_refs` / `blocking_refs` / `issue_refs` as appropriate.104105### 6. Evidence-to-Finding Mapping106107When converting raw hub evidence into template items:1081091. **Identify gaps**: Compare what the subpoena categories request against what productions, custodian sources, and documents actually deliver. Look for:110 - Categories with zero or under-scale productions.111 - Custodian sources marked as `lost`, `not_collected`, `partial`, or `should_exist_missing`.112 - Documents coded responsive but not produced.113 - Privilege-log entries that are withheld but unlogged (withheld count > logged count).114 - QC findings flagging miscoded responsive documents.115 - Retention events showing post-hold losses, auto-purges, or policy destructions.1161172. **Quantify each finding**: Pull document counts, withheld/logged/unlogged counts, source counts, and volume numbers from the hub data. Every count in your output must be traceable to a specific hub record or aggregation of hub records.1181193. **Assign severity/risk**: Match the gap magnitude and legal exposure to the template's severity/risk enum. Critical = certain regulatory impact or spoliation risk. High = material gap with uncertain remediation. Medium = partial gap with known remediation path. Low = minor, remediable, or policy-compliant pre-hold.1201214. **Link to categories**: Every finding must list which request category codes it impacts (`category_impacts`, `affected_categories`, or `category_impacts` depending on template). Use the exact codes from the hub's subpoena categories.1221235. **Recommend actions**: Match each finding to an action from the template's `action_type` enum. Escalation actions (disclose, waiver assessment) come before remediation actions (collect, recode, supplement log). Monitoring-only actions go last.124125### 7. Metrics Construction126127Metrics objects aggregate counts across all findings/events/sources. Rules:128129- **Read the required_keys list** in the template's metrics definition — those exact keys must be present.130- **Sum conservatively**: When the template asks for "unlogged privilege docs," count every document where `withheld_count > logged_count` in the privilege-log data.131- **Count distinct categories**: When the template asks for `categories_with_open_gaps` or `categories_with_open_risk`, list the unique category codes, not a count of findings.132- **Boolean readiness**: `rolling_production_ready` / `production_ready` is `true` only when **zero** categories have open material gaps or unresolved blockers.133- **Box counts**: Some templates have specific box-count metrics (`destroyed_lab_archive_box_count`, `destroyed_box_count`). Pull these from retention-event volume data. If the destroyed source is measured in records not boxes and the template says "or 0 when the task's destroyed source is not measured in boxes," use `0`.134135### 8. Action Plan Construction136137- Each action targets one or more hub record IDs (`target_refs`) and impacts one or more category codes (`category_impacts` / `affected_categories`).138- Rank by operational priority: P0/P1 (rank 1,2) = blocking production or requiring immediate disclosure. P2 (rank 3,4,…) = remediation with known path. P3 (last) = monitor or no action.139- Assign `owner` from the template's owner enum — match the owner to the action type (e.g., `forensics` for device collection, `privilege_team` for privilege-log supplements, `outside_counsel` for disclosures).140- When the template includes `due_days`, estimate based on the urgency implied by the severity and production timeline.141142### 9. Output Format143144- Return **one JSON object** and **no prose** outside the JSON.145- The JSON must parse as valid JSON (double-quoted keys and strings, no trailing commas).146- Do not wrap the JSON in markdown code fences unless the task prompt explicitly permits it. Prefer raw JSON.147- All strings use the exact casing from hub data or template enums.148149### 10. Verification Checklist (Before Returning)150151Run this checklist against your output before delivering:152153- [ ] Every key in `required_top_level_keys` is present; no extra top-level keys.154- [ ] Every list is sorted per `ordering_rules`.155- [ ] Every string field constrained by an enum uses only declared values.156- [ ] Every count is a whole integer (0 for not-applicable, never null or missing).157- [ ] Every finding/risk/issue ID is a real hub record ID, not synthetic.158- [ ] Every `source_refs` / `record_refs` / `blocking_refs` / `target_refs` list is sorted ascending.159- [ ] Every category code list within items is sorted ascending.160- [ ] Metrics sum correctly and match the enumerated findings.161- [ ] Priority ranks start at 1 and are contiguous.162- [ ] No prose, no markdown framing, no commentary outside the JSON object.