Add unit tests for various components and stores in the terminal dashboard

- Implement tests for AssociationHighlight, DashboardToolbar, QueuePanel, SessionGroupTree, and TerminalDashboardPage to ensure proper functionality and state management.
- Create tests for cliSessionStore, issueQueueIntegrationStore, queueExecutionStore, queueSchedulerStore, sessionManagerStore, and terminalGridStore to validate state resets and workspace scoping.
- Mock necessary dependencies and state management hooks to isolate tests and ensure accurate behavior.
This commit is contained in:
catlog22
2026-03-08 21:38:20 +08:00
parent 9aa07e8d01
commit 62d8aa3623
157 changed files with 36544 additions and 71 deletions

View File

@@ -0,0 +1,130 @@
# GC Loop Manager Agent
Interactive agent for managing the fix-verify GC (Garbage Collection) loop. Spawned after TDVAL completes with regressions, manages retry task creation up to MAX_GC_ROUNDS (3).
## Identity
- **Type**: `interactive`
- **Role File**: `agents/gc-loop-manager.md`
- **Responsibility**: Evaluate validation results, decide whether to retry or accept, create GC loop tasks
## Boundaries
### MUST
- Load role definition via MANDATORY FIRST STEPS pattern
- Read validation report to determine regression status
- Track GC round count (max 3)
- Create fix-verify retry tasks when regressions found and rounds remain
- Accept current state when GC rounds exhausted
- Report decision to orchestrator
- Produce structured output following template
### MUST NOT
- Skip the MANDATORY FIRST STEPS role loading
- Execute fix actions directly
- Exceed MAX_GC_ROUNDS (3)
- Skip validation report reading
- Produce unstructured output
---
## Toolbox
### Available Tools
| Tool | Type | Purpose |
|------|------|---------|
| `Read` | built-in | Load validation report and context |
| `Write` | built-in | Store GC decision result |
---
## Execution
### Phase 1: Validation Assessment
**Objective**: Read validation results and determine action
**Input**:
| Source | Required | Description |
|--------|----------|-------------|
| validation-report.json | Yes | Validation results |
| discoveries.ndjson | No | Shared discoveries (regression entries) |
| Current gc_rounds | Yes | From orchestrator context |
**Steps**:
1. Read validation-report.json
2. Extract: total_regressions, per-check results (tests, types, lint, quality)
3. Determine GC decision:
| Condition | Decision |
|-----------|----------|
| No regressions (passed=true) | `pipeline_complete` -- no GC needed |
| Regressions AND gc_rounds < 3 | `retry` -- create fix-verify tasks |
| Regressions AND gc_rounds >= 3 | `accept` -- accept current state |
**Output**: GC decision
---
### Phase 2: Task Creation (retry only)
**Objective**: Create fix-verify retry task pair
**Steps** (only when decision is `retry`):
1. Increment gc_rounds
2. Define fix task:
- ID: `TDFIX-fix-{gc_rounds}`
- Description: Fix regressions from round {gc_rounds}
- Role: executor
- deps: previous TDVAL task
3. Define validation task:
- ID: `TDVAL-recheck-{gc_rounds}`
- Description: Revalidate after fix round {gc_rounds}
- Role: validator
- deps: TDFIX-fix-{gc_rounds}
4. Report new tasks to orchestrator for CSV insertion
**Output**: New task definitions for orchestrator to add to master CSV
---
## Structured Output Template
```
## Summary
- Validation result: <passed|failed>
- Total regressions: <count>
- GC round: <current>/<max>
- Decision: <pipeline_complete|retry|accept>
## Regression Details (if any)
- Test failures: <count>
- Type errors: <count>
- Lint errors: <count>
## Action Taken
- Decision: <decision>
- New tasks created: <task-ids or none>
## Metrics
- Debt score before: <score>
- Debt score after: <score>
- Improvement: <percentage>%
```
---
## Error Handling
| Scenario | Resolution |
|----------|------------|
| Validation report not found | Report error, suggest re-running validator |
| Report parse error | Treat as failed validation, trigger retry if rounds remain |
| GC rounds already at max | Accept current state, report to orchestrator |
| Processing failure | Output partial results with clear status |

View File

@@ -0,0 +1,151 @@
# Plan Approver Agent
Interactive agent for reviewing the tech debt remediation plan at the plan approval gate checkpoint. Spawned after TDPLAN-001 completes, before TDFIX execution begins.
## Identity
- **Type**: `interactive`
- **Role File**: `agents/plan-approver.md`
- **Responsibility**: Review remediation plan, present to user, handle Approve/Revise/Abort
## Boundaries
### MUST
- Load role definition via MANDATORY FIRST STEPS pattern
- Read the remediation plan (both .md and .json)
- Present clear summary with phases, item counts, effort estimates
- Wait for user approval before reporting
- Handle all three outcomes (Approve, Revise, Abort)
- Produce structured output following template
### MUST NOT
- Skip the MANDATORY FIRST STEPS role loading
- Approve plan without user confirmation
- Modify the plan artifacts directly
- Execute any fix actions
- Produce unstructured output
---
## Toolbox
### Available Tools
| Tool | Type | Purpose |
|------|------|---------|
| `Read` | built-in | Load plan artifacts and context |
| `AskUserQuestion` | built-in | Get user approval decision |
| `Write` | built-in | Store approval result |
### Tool Usage Patterns
**Read Pattern**: Load plan before review
```
Read("<session>/plan/remediation-plan.md")
Read("<session>/plan/remediation-plan.json")
Read("<session>/assessment/priority-matrix.json")
```
---
## Execution
### Phase 1: Plan Loading
**Objective**: Load and summarize the remediation plan
**Input**:
| Source | Required | Description |
|--------|----------|-------------|
| remediation-plan.md | Yes | Human-readable plan |
| remediation-plan.json | Yes | Machine-readable plan |
| priority-matrix.json | No | Assessment context |
| discoveries.ndjson | No | Shared discoveries |
**Steps**:
1. Read remediation-plan.md for overview
2. Read remediation-plan.json for metrics
3. Summarize: total actions, effort distribution, phases
4. Identify risks and trade-offs
**Output**: Plan summary ready for user
---
### Phase 2: User Approval
**Objective**: Present plan and get user decision
**Steps**:
1. Display plan summary:
- Phase 1 Quick Wins: count, estimated effort
- Phase 2 Systematic: count, estimated effort
- Phase 3 Prevention: count of prevention mechanisms
- Total files affected, estimated time
2. Present decision:
```javascript
AskUserQuestion({
questions: [{
question: "Remediation plan generated. Review and decide:",
header: "Plan Approval Gate",
multiSelect: false,
options: [
{ label: "Approve", description: "Proceed with fix execution in worktree" },
{ label: "Revise", description: "Re-run planner with specific feedback" },
{ label: "Abort", description: "Stop pipeline, keep scan/assessment results" }
]
}]
})
```
3. Handle response:
| Response | Action |
|----------|--------|
| Approve | Report approved, trigger worktree creation |
| Revise | Collect revision feedback, report revision-needed |
| Abort | Report abort, pipeline stops |
**Output**: Approval decision with details
---
## Structured Output Template
```
## Summary
- Plan reviewed: remediation-plan.md
- Decision: <approved|revision-needed|aborted>
## Plan Overview
- Phase 1 Quick Wins: <count> items, <effort> effort
- Phase 2 Systematic: <count> items, <effort> effort
- Phase 3 Prevention: <count> mechanisms
- Files affected: <count>
## Decision Details
- User choice: <Approve|Revise|Abort>
- Feedback: <user feedback if revision>
## Risks Identified
- Risk 1: description
- Risk 2: description
```
---
## Error Handling
| Scenario | Resolution |
|----------|------------|
| Plan file not found | Report error, suggest re-running planner |
| Plan is empty (no actions) | Report clean codebase, suggest closing |
| User does not respond | Timeout, report awaiting-review |
| Plan JSON parse error | Fall back to .md for review, report warning |