feat: add dynamic pipeline detection for team sessions v5 architecture

Backend:
- Fix readLegacyFiles to handle { name, prefix }[] role format
- Add roles backfill in getEffectiveTeamMeta when meta.json exists
- Ensure pipeline_stages and roles flow correctly to API response

Team Skills:
- Add pipeline metadata initialization to all 16 team skill coordinator roles
- Each skill now reports pipeline_stages and roles to meta.json at session init

Documentation:
- Update command references and component documentation
- Add numerical-analysis-workflow skill spec
- Sync zh/en translations for commands and components
This commit is contained in:
catlog22
2026-03-04 14:52:07 +08:00
parent b203ada9c5
commit f389e3e6dd
56 changed files with 2007 additions and 201 deletions

View File

@@ -0,0 +1,237 @@
# Analysis Dimensions for Numerical Computation
Defines the 18 analysis dimensions across 6 phases of the NADW workflow.
## Purpose
| Phase | Usage |
|-------|-------|
| Phase 1 (Decomposition) | Reference when assigning analysis_dimension to tasks |
| Phase 2 (Execution) | Agents use to understand their analysis focus |
| Phase 3 (Aggregation) | Organize findings by dimension |
---
## 1. Wave 1: Global Survey Dimensions
### 1.1 Domain Modeling (`domain_modeling`)
**Analyst Role**: Problem_Domain_Analyst
**Focus Areas**:
- Governing equations (PDEs, ODEs, integral equations)
- Physical domain and boundary conditions
- Conservation laws and constitutive relations
- Problem classification (elliptic, parabolic, hyperbolic)
- Dimensional analysis and non-dimensionalization
**Key Outputs**:
- Equation inventory with LaTeX notation
- Boundary condition catalog
- Problem classification matrix
- Physical parameter ranges
**Formula Types to Identify**:
$$\frac{\partial u}{\partial t} + \mathcal{L}u = f \quad \text{(general PDE form)}$$
$$u|_{\partial\Omega} = g \quad \text{(Dirichlet BC)}$$
$$\frac{\partial u}{\partial n}|_{\partial\Omega} = h \quad \text{(Neumann BC)}$$
### 1.2 Architecture Analysis (`architecture_analysis`)
**Analyst Role**: Software_Architect
**Focus Areas**:
- Module decomposition and dependency graph
- Data flow between computational stages
- I/O patterns (mesh input, solution output, checkpointing)
- Parallelism strategy (MPI, OpenMP, GPU)
- Build system and dependency management
**Key Outputs**:
- High-level component diagram
- Data flow diagram
- Technology stack inventory
- Parallelism strategy assessment
### 1.3 Validation Design (`validation_design`)
**Analyst Role**: Validation_Strategist
**Focus Areas**:
- Benchmark cases with known analytical solutions
- Manufactured solution methodology
- Grid convergence study design
- Key Performance Indicators (KPIs)
- Acceptance criteria definition
**Key Outputs**:
- Benchmark case catalog
- Validation methodology matrix
- KPI definitions with targets
- Acceptance test specifications
---
## 2. Wave 2: Theoretical Foundation Dimensions
### 2.1 Formula Derivation (`formula_derivation`)
**Analyst Role**: Mathematician
**Focus Areas**:
- Strong-to-weak form transformation
- Discretization schemes (FEM, FDM, FVM, spectral)
- Variational formulations
- Linearization techniques (Newton, Picard)
- Stabilization methods (SUPG, GLS, VMS)
**Key Formula Templates**:
$$\text{Weak form: } a(u,v) = l(v) \quad \forall v \in V_h$$
$$a(u,v) = \int_\Omega \nabla u \cdot \nabla v \, d\Omega$$
$$l(v) = \int_\Omega f v \, d\Omega + \int_{\Gamma_N} g v \, dS$$
### 2.2 Convergence Analysis (`convergence_analysis`)
**Analyst Role**: Convergence_Analyst
**Focus Areas**:
- A priori error estimates
- A posteriori error estimators
- Convergence order verification
- Lax equivalence theorem applicability
- CFL conditions for time-dependent problems
**Key Formula Templates**:
$$\|u - u_h\|_{L^2} \leq C h^{k+1} |u|_{H^{k+1}} \quad \text{(optimal L2 rate)}$$
$$\|u - u_h\|_{H^1} \leq C h^k |u|_{H^{k+1}} \quad \text{(optimal H1 rate)}$$
$$\Delta t \leq \frac{C h}{\|v\|_\infty} \quad \text{(CFL condition)}$$
### 2.3 Complexity Analysis (`complexity_analysis`)
**Analyst Role**: Complexity_Analyst
**Focus Areas**:
- Assembly operation counts
- Solver complexity (direct vs iterative)
- Preconditioner cost analysis
- Memory scaling with problem size
- Communication overhead in parallel settings
**Key Formula Templates**:
$$T_{assembly} = O(N_{elem} \cdot p^{2d}) \quad \text{(FEM assembly)}$$
$$T_{solve} = O(N^{3/2}) \quad \text{(2D direct)}, \quad O(N \log N) \quad \text{(multigrid)}$$
$$M_{storage} = O(nnz) \quad \text{(sparse storage)}$$
---
## 3. Wave 3: Algorithm Design Dimensions
### 3.1 Method Selection (`method_selection`)
**Analyst Role**: Algorithm_Designer
**Focus Areas**:
- Spatial discretization method selection
- Time integration scheme selection
- Linear/nonlinear solver selection
- Preconditioner selection
- Mesh generation strategy
**Decision Criteria**:
| Criterion | Weight | Metrics |
|-----------|--------|---------|
| Accuracy order | High | Convergence rate, error bounds |
| Stability | High | Unconditional vs conditional, CFL |
| Efficiency | Medium | FLOPS per DOF, memory per DOF |
| Parallelizability | Medium | Communication-to-computation ratio |
| Implementation complexity | Low | Lines of code, library availability |
### 3.2 Stability Analysis (`stability_analysis`)
**Analyst Role**: Stability_Analyst
**Focus Areas**:
- Von Neumann stability analysis
- Matrix condition numbers
- Amplification factors
- Inf-sup (LBB) stability for mixed methods
- Mesh-dependent stability bounds
**Key Formula Templates**:
$$\kappa(A) = \|A\| \cdot \|A^{-1}\| \quad \text{(condition number)}$$
$$|g(\xi)| \leq 1 \quad \forall \xi \quad \text{(von Neumann stability)}$$
$$\inf_{q_h \in Q_h} \sup_{v_h \in V_h} \frac{b(v_h, q_h)}{\|v_h\| \|q_h\|} \geq \beta > 0 \quad \text{(inf-sup)}$$
### 3.3 Performance Modeling (`performance_modeling`)
**Analyst Role**: Performance_Modeler
**Focus Areas**:
- Arithmetic intensity (FLOPS/byte)
- Roofline model analysis
- Strong/weak scaling prediction
- Memory bandwidth bottleneck identification
- Cache utilization estimates
**Key Formula Templates**:
$$AI = \frac{\text{FLOPS}}{\text{Bytes transferred}} \quad \text{(arithmetic intensity)}$$
$$P_{max} = \min(P_{peak}, AI \times BW_{mem}) \quad \text{(roofline bound)}$$
$$E_{parallel}(p) = \frac{T_1}{p \cdot T_p} \quad \text{(parallel efficiency)}$$
---
## 4. Wave 4: Module Implementation Dimensions
### 4.1 Implementation Analysis (`implementation_analysis`)
**Focus**: Algorithm-to-code mapping, implementation correctness, coding patterns
### 4.2 Data Structure Review (`data_structure_review`)
**Focus**: Sparse matrix formats (CSR/CSC/COO), mesh data structures, memory layout optimization
### 4.3 Interface Analysis (`interface_analysis`)
**Focus**: Module APIs, data contracts between components, error handling patterns
---
## 5. Wave 5: Local Function-Level Dimensions
### 5.1 Optimization (`optimization`)
**Focus**: Hotspot identification, vectorization opportunities, cache optimization, loop restructuring
### 5.2 Edge Case Analysis (`edge_case_analysis`)
**Focus**: Division by zero, matrix singularity, degenerate mesh elements, boundary layer singularities
### 5.3 Precision Audit (`precision_audit`)
**Focus**: Catastrophic cancellation, accumulation errors, mixed-precision opportunities, compensated algorithms
**Critical Patterns to Detect**:
| Pattern | Risk | Mitigation |
|---------|------|-----------|
| `a - b` where `a ≈ b` | Catastrophic cancellation | Reformulate or use higher precision |
| `sum += small_value` in loop | Accumulation error | Kahan summation |
| `1.0/x` where `x → 0` | Overflow/loss of significance | Guard with threshold |
| Mixed float32/float64 | Silent precision loss | Explicit type annotations |
---
## 6. Wave 6: Integration & QA Dimensions
### 6.1 Integration Testing (`integration_testing`)
**Focus**: End-to-end test design, regression suite, manufactured solutions verification
### 6.2 Benchmarking (`benchmarking`)
**Focus**: Actual vs predicted performance, scalability tests, profiling results
### 6.3 Quality Assurance (`quality_assurance`)
**Focus**: All-phase synthesis, risk matrix, improvement roadmap, final recommendations

View File

@@ -0,0 +1,214 @@
# Phase Topology — Diamond Deep Tree
Wave coordination patterns for the Numerical Analysis Diamond Workflow (NADW).
## Purpose
| Phase | Usage |
|-------|-------|
| Phase 1 (Decomposition) | Reference when assigning waves and dependencies |
| Phase 2 (Execution) | Context flow between waves |
| Phase 3 (Aggregation) | Structure the final report by topology |
---
## 1. Topology Overview
The NADW uses a **Staged Diamond** topology — six sequential waves, each with 3 parallel tracks. Context flows cumulatively from earlier waves to later ones.
```
Wave 1: [T1.1] [T1.2] [T1.3] Global Survey (3 parallel)
↓ Context P1
Wave 2: [T2.1] [T2.2] [T2.3] Theory (3 parallel)
↓ Context P1+P2
Wave 3: [T3.1] [T3.2] [T3.3] Algorithm (3 parallel)
↓ Context P1+P2+P3
Wave 4: [T4.1] [T4.2] [T4.3] Module (3 parallel)
↓ Context P1-P4
Wave 5: [T5.1] [T5.2] [T5.3] Local (3 parallel)
↓ Context P1-P5
Wave 6: [T6.1] [T6.2] [T6.3] Integration (3 parallel)
```
---
## 2. Wave Definitions
### Wave 1: Global Survey
| Property | Value |
|----------|-------|
| Phase Name | Global Survey |
| Track Count | 3 |
| Dependencies | None (entry wave) |
| Context Input | Project codebase only |
| Context Output | Governing equations, architecture map, validation KPIs |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Scope |
|----|------|-----------|-------|
| T1.1 | Problem_Domain_Analyst | domain_modeling | Full project |
| T1.2 | Software_Architect | architecture_analysis | Full project |
| T1.3 | Validation_Strategist | validation_design | Full project |
### Wave 2: Theoretical Foundations
| Property | Value |
|----------|-------|
| Phase Name | Theoretical Foundations |
| Track Count | 3 |
| Dependencies | Wave 1 |
| Context Input | Context Package P1 |
| Context Output | LaTeX formulas, convergence theorems, complexity bounds |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Deps | context_from |
|----|------|-----------|------|-------------|
| T2.1 | Mathematician | formula_derivation | T1.1 | T1.1 |
| T2.2 | Convergence_Analyst | convergence_analysis | T1.1 | T1.1 |
| T2.3 | Complexity_Analyst | complexity_analysis | T1.1;T1.2 | T1.1;T1.2 |
### Wave 3: Algorithm Design & Stability
| Property | Value |
|----------|-------|
| Phase Name | Algorithm Design |
| Track Count | 3 |
| Dependencies | Wave 2 |
| Context Input | Context Package P1+P2 |
| Context Output | Pseudocode, stability conditions, performance model |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Deps | context_from |
|----|------|-----------|------|-------------|
| T3.1 | Algorithm_Designer | method_selection | T2.1 | T2.1;T2.2;T2.3 |
| T3.2 | Stability_Analyst | stability_analysis | T2.1;T2.2 | T2.1;T2.2 |
| T3.3 | Performance_Modeler | performance_modeling | T2.3 | T1.2;T2.3 |
### Wave 4: Module Implementation
| Property | Value |
|----------|-------|
| Phase Name | Module Implementation |
| Track Count | 3 |
| Dependencies | Wave 3 |
| Context Input | Context Package P1-P3 |
| Context Output | Code-algorithm mapping, data structure decisions, API contracts |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Deps | context_from |
|----|------|-----------|------|-------------|
| T4.1 | Module_Implementer | implementation_analysis | T3.1 | T1.2;T3.1 |
| T4.2 | Data_Structure_Designer | data_structure_review | T3.1;T3.3 | T2.3;T3.1;T3.3 |
| T4.3 | Interface_Analyst | interface_analysis | T3.1 | T1.2;T3.1 |
### Wave 5: Local Function-Level
| Property | Value |
|----------|-------|
| Phase Name | Local Function-Level |
| Track Count | 3 |
| Dependencies | Wave 4 |
| Context Input | Context Package P1-P4 |
| Context Output | Optimization recommendations, edge case catalog, precision risk matrix |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Deps | context_from |
|----|------|-----------|------|-------------|
| T5.1 | Code_Optimizer | optimization | T4.1 | T3.3;T4.1 |
| T5.2 | Edge_Case_Analyst | edge_case_analysis | T4.1 | T1.1;T3.2;T4.1 |
| T5.3 | Precision_Auditor | precision_audit | T4.1;T4.2 | T3.2;T4.1;T4.2 |
### Wave 6: Integration & QA
| Property | Value |
|----------|-------|
| Phase Name | Integration & QA |
| Track Count | 3 |
| Dependencies | Wave 5 |
| Context Input | Context Package P1-P5 (ALL cumulative) |
| Context Output | Final test plan, benchmark report, QA assessment |
| Max Parallelism | 3 |
**Tracks**:
| ID | Role | Dimension | Deps | context_from |
|----|------|-----------|------|-------------|
| T6.1 | Integration_Tester | integration_testing | T5.1;T5.2 | T1.3;T5.1;T5.2 |
| T6.2 | Benchmark_Engineer | benchmarking | T5.1 | T1.3;T3.3;T5.1 |
| T6.3 | QA_Auditor | quality_assurance | T5.1;T5.2;T5.3 | T1.1;T2.1;T3.1;T4.1;T5.1;T5.2;T5.3 |
---
## 3. Context Flow Map
### Directed Context (prev_context column)
```
T1.1 ──► T2.1, T2.2, T2.3
T1.2 ──► T2.3, T3.3, T4.1, T4.3
T1.3 ──► T6.1, T6.2
T2.1 ──► T3.1, T3.2
T2.2 ──► T3.1, T3.2
T2.3 ──► T3.1, T3.3, T4.2
T3.1 ──► T4.1, T4.2, T4.3
T3.2 ──► T5.2, T5.3
T3.3 ──► T4.2, T5.1, T6.2
T4.1 ──► T5.1, T5.2, T5.3
T4.2 ──► T5.3
T5.1 ──► T6.1, T6.2
T5.2 ──► T6.1
T5.3 ──► T6.3
```
### Broadcast Context (discoveries.ndjson)
All agents read/append to the same discoveries.ndjson. Key discovery types flow across waves:
```
Wave 1: governing_equation, architecture_pattern ──► all subsequent waves
Wave 2: convergence_property ──► Wave 3-6
Wave 3: stability_issue, numerical_method ──► Wave 4-6
Wave 4: (implementation findings) ──► Wave 5-6
Wave 5: precision_risk, performance_bottleneck ──► Wave 6
```
---
## 4. Perspective Reuse Matrix
How each wave's output is reused by later waves:
| Source | P2 Reuse | P3 Reuse | P4 Reuse | P5 Reuse | P6 Reuse |
|--------|---------|---------|---------|---------|---------|
| **P1 Equations** | Formalize → LaTeX | Constrain methods | Code-eq mapping | Singularity sources | Correctness baseline |
| **P1 Architecture** | Constrain discretization | Parallel strategy | Module boundaries | Hotspot location | Integration scope |
| **P1 Validation** | - | Benchmark selection | Test criteria | Edge case sources | Final validation |
| **P2 Formulas** | - | Parameter constraints | Loop termination | Precision requirements | Theory verification |
| **P2 Convergence** | - | Mesh refinement | Iteration control | Error tolerance | Rate verification |
| **P2 Complexity** | - | Performance baseline | Data structure choice | Optimization targets | Perf comparison |
| **P3 Pseudocode** | - | - | Impl reference | Line-by-line audit | Regression baseline |
| **P3 Stability** | - | - | Precision selection | Cancellation detection | Numerical verification |
| **P3 Performance** | - | - | Memory layout | Vectorization targets | Benchmark targets |
| **P4 Modules** | - | - | - | Function-level focus | Module test plan |
| **P5 Optimization** | - | - | - | - | Performance tests |
| **P5 Edge Cases** | - | - | - | - | Regression tests |
| **P5 Precision** | - | - | - | - | Numerical tests |
---
## 5. Diamond Properties
| Property | Value |
|----------|-------|
| Total Waves | 6 |
| Total Tasks | 18 (3 per wave) |
| Max Parallelism per Wave | 3 |
| Widest Context Fan-in | T6.3 (receives from 7 tasks) |
| Deepest Dependency Chain | T1.1 → T2.1 → T3.1 → T4.1 → T5.1 → T6.1 (depth 6) |
| Context Accumulation | Cumulative (each wave adds to previous context) |
| Topology Type | Staged Parallel with Diamond convergence at Wave 6 |

View File

@@ -0,0 +1,173 @@
# Quality Standards for Numerical Analysis Workflow
Quality assessment criteria for NADW analysis reports.
## When to Use
| Phase | Usage | Section |
|-------|-------|---------|
| Phase 2 (Execution) | Guide agent analysis quality | All dimensions |
| Phase 3 (Aggregation) | Score generated reports | Quality Gates |
---
## Quality Dimensions
### 1. Mathematical Rigor (30%)
| Score | Criteria |
|-------|----------|
| 100% | All formulas correct, properly derived, LaTeX well-formatted, error bounds proven |
| 80% | Formulas correct, some derivation steps skipped, bounds stated without full proof |
| 60% | Key formulas present, some notation inconsistencies, bounds estimated |
| 40% | Formulas incomplete or contain errors |
| 0% | No mathematical content |
**Checklist**:
- [ ] Governing equations identified and written in LaTeX
- [ ] Weak forms correctly derived from strong forms
- [ ] Convergence order stated with conditions
- [ ] Error bounds provided (a priori or a posteriori)
- [ ] CFL/stability conditions explicitly stated
- [ ] Condition numbers estimated for key matrices
- [ ] Complexity bounds (time and space) determined
- [ ] LaTeX notation consistent throughout all documents
### 2. Code-Theory Mapping (25%)
| Score | Criteria |
|-------|----------|
| 100% | Every algorithm mapped to code with file:line references, data structures justified |
| 80% | Major algorithms mapped, most references accurate |
| 60% | Key mappings present, some code references missing |
| 40% | Superficial mapping, few code references |
| 0% | No code-theory connection |
**Checklist**:
- [ ] Each numerical method traced to implementing function/module
- [ ] Data structures justified against algorithm requirements
- [ ] Sparse matrix format matched to access patterns
- [ ] Time integration scheme identified in code
- [ ] Boundary condition implementation verified
- [ ] Solver configuration traced to convergence requirements
- [ ] Preconditioner choice justified
### 3. Numerical Quality Assessment (25%)
| Score | Criteria |
|-------|----------|
| 100% | Stability fully analyzed, precision risks cataloged, all edge cases covered |
| 80% | Stability assessed, major precision risks found, common edge cases covered |
| 60% | Basic stability check, some precision risks, incomplete edge cases |
| 40% | Superficial stability mention, few precision issues found |
| 0% | No numerical quality analysis |
**Checklist**:
- [ ] Condition numbers estimated for key operations
- [ ] Catastrophic cancellation risks identified with file:line
- [ ] Accumulation error potential assessed
- [ ] Float precision choices justified (float32 vs float64)
- [ ] Edge cases cataloged (singularities, degenerate inputs)
- [ ] Overflow/underflow risks identified
- [ ] Mixed-precision operations flagged
### 4. Cross-Phase Coherence (20%)
| Score | Criteria |
|-------|----------|
| 100% | All 6 phases connected, findings build on each other, no contradictions |
| 80% | Most phases connected, minor gaps in context propagation |
| 60% | Key connections present, some phases isolated |
| 40% | Limited cross-referencing between phases |
| 0% | Phases completely isolated |
**Checklist**:
- [ ] Wave 2 formulas reference Wave 1 governing equations
- [ ] Wave 3 algorithms justified by Wave 2 theory
- [ ] Wave 4 implementation verified against Wave 3 pseudocode
- [ ] Wave 5 optimization targets from Wave 3 performance model
- [ ] Wave 5 precision requirements from Wave 2/3 analysis
- [ ] Wave 6 test plan covers findings from all prior waves
- [ ] Wave 6 benchmarks compare against Wave 3 predictions
- [ ] No contradictory findings between phases
- [ ] Discoveries board used for cross-track sharing
---
## Quality Gates (Per-Wave)
| Wave | Phase | Gate Criteria | Required Tracks |
|------|-------|--------------|-----------------|
| 1 | Global Survey | Core model identified + architecture mapped + ≥1 KPI | 3/3 completed |
| 2 | Theory | Key formulas LaTeX'd + convergence stated + complexity determined | 3/3 completed |
| 3 | Algorithm | Pseudocode produced + stability assessed + performance predicted | ≥2/3 completed |
| 4 | Module | Code-algorithm mapping + data structures reviewed + APIs documented | ≥2/3 completed |
| 5 | Local | Hotspots identified + edge cases cataloged + precision risks flagged | ≥2/3 completed |
| 6 | Integration | Test plan complete + benchmarks planned + QA report synthesized | 3/3 completed |
---
## Overall Quality Gates
| Gate | Threshold | Action |
|------|-----------|--------|
| PASS | >= 80% across all dimensions | Report ready for delivery |
| REVIEW | 70-79% in any dimension | Flag dimension for improvement, user decides |
| FAIL | < 70% in any dimension | Block delivery, identify gaps, suggest re-analysis |
---
## Issue Classification
### Errors (Must Fix)
- Missing governing equation identification (Wave 1)
- LaTeX formulas with mathematical errors (Wave 2)
- Algorithm pseudocode that doesn't match convergence requirements (Wave 3)
- Code references to non-existent files/functions (Wave 4)
- Unidentified catastrophic cancellation in critical path (Wave 5)
- Test plan that doesn't cover identified stability issues (Wave 6)
- Contradictory findings between phases
- Missing context propagation (later phase ignores earlier findings)
### Warnings (Should Fix)
- Formulas without derivation steps
- Convergence bounds stated without proof or reference
- Missing edge case for known singularity
- Performance model without memory bandwidth consideration
- Data structure choice not justified
- Test plan without manufactured solution verification
- Benchmark without theoretical baseline comparison
### Notes (Nice to Have)
- Additional bibliography references
- Alternative algorithm comparisons
- Extended precision sensitivity analysis
- Scaling prediction beyond current problem size
- Code style or naming convention suggestions
---
## Severity Levels for Findings
| Severity | Definition | Example |
|----------|-----------|---------|
| **Critical** | Incorrect results or numerical failure | Wrong boundary condition → divergent solution |
| **High** | Significant accuracy or performance degradation | Condition number 10^15 → double precision insufficient |
| **Medium** | Suboptimal but functional | O(N^2) where O(N log N) is possible |
| **Low** | Minor improvement opportunity | Unnecessary array copy in non-critical path |
---
## Document Quality Metrics
| Metric | Target | Measurement |
|--------|--------|-------------|
| Formula coverage | ≥ 90% of core equations in LaTeX | Count identified vs documented |
| Code reference density | ≥ 1 file:line per finding | Count references per finding |
| Cross-phase references | ≥ 3 per document (Waves 3-6) | Count cross-references |
| Severity distribution | ≥ 1 per severity level | Count per level |
| Discovery board contributions | ≥ 2 per track | Count NDJSON entries per worker |
| Perspective package | Present in every document | Boolean per document |