@harness-engineering/cli 1.4.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/agents/personas/architecture-enforcer.yaml +1 -0
  2. package/dist/agents/personas/code-reviewer.yaml +43 -0
  3. package/dist/agents/personas/codebase-health-analyst.yaml +32 -0
  4. package/dist/agents/personas/documentation-maintainer.yaml +2 -0
  5. package/dist/agents/personas/entropy-cleaner.yaml +3 -0
  6. package/dist/agents/personas/graph-maintainer.yaml +27 -0
  7. package/dist/agents/personas/parallel-coordinator.yaml +29 -0
  8. package/dist/agents/personas/performance-guardian.yaml +26 -0
  9. package/dist/agents/personas/security-reviewer.yaml +35 -0
  10. package/dist/agents/personas/task-executor.yaml +41 -0
  11. package/dist/agents/skills/README.md +8 -0
  12. package/dist/agents/skills/claude-code/add-harness-component/SKILL.md +10 -0
  13. package/dist/agents/skills/claude-code/align-documentation/SKILL.md +19 -0
  14. package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +19 -0
  15. package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +8 -0
  16. package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +9 -0
  17. package/dist/agents/skills/claude-code/harness-architecture-advisor/SKILL.md +9 -0
  18. package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +494 -0
  19. package/dist/agents/skills/claude-code/harness-autopilot/skill.yaml +52 -0
  20. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +25 -0
  21. package/dist/agents/skills/claude-code/harness-debugging/SKILL.md +10 -0
  22. package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +150 -0
  23. package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +41 -0
  24. package/dist/agents/skills/claude-code/harness-execution/SKILL.md +19 -0
  25. package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +135 -0
  26. package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +44 -0
  27. package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +139 -0
  28. package/dist/agents/skills/claude-code/harness-impact-analysis/skill.yaml +44 -0
  29. package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +20 -6
  30. package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +154 -0
  31. package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +49 -0
  32. package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +10 -0
  33. package/dist/agents/skills/claude-code/harness-parallel-agents/SKILL.md +9 -0
  34. package/dist/agents/skills/claude-code/harness-perf/SKILL.md +231 -0
  35. package/dist/agents/skills/claude-code/harness-perf/skill.yaml +47 -0
  36. package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +236 -0
  37. package/dist/agents/skills/claude-code/harness-perf-tdd/skill.yaml +47 -0
  38. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +9 -0
  39. package/dist/agents/skills/claude-code/harness-pre-commit-review/SKILL.md +33 -2
  40. package/dist/agents/skills/claude-code/harness-refactoring/SKILL.md +19 -0
  41. package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +657 -0
  42. package/dist/agents/skills/claude-code/harness-release-readiness/skill.yaml +57 -0
  43. package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +206 -0
  44. package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +50 -0
  45. package/dist/agents/skills/claude-code/harness-security-scan/SKILL.md +102 -0
  46. package/dist/agents/skills/claude-code/harness-security-scan/skill.yaml +41 -0
  47. package/dist/agents/skills/claude-code/harness-state-management/SKILL.md +22 -8
  48. package/dist/agents/skills/claude-code/harness-tdd/SKILL.md +10 -0
  49. package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +131 -0
  50. package/dist/agents/skills/claude-code/harness-test-advisor/skill.yaml +44 -0
  51. package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +10 -0
  52. package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +9 -0
  53. package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +494 -0
  54. package/dist/agents/skills/gemini-cli/harness-autopilot/skill.yaml +52 -0
  55. package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +150 -0
  56. package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +41 -0
  57. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +135 -0
  58. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +44 -0
  59. package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +139 -0
  60. package/dist/agents/skills/gemini-cli/harness-impact-analysis/skill.yaml +44 -0
  61. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +154 -0
  62. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +49 -0
  63. package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +231 -0
  64. package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +47 -0
  65. package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +236 -0
  66. package/dist/agents/skills/gemini-cli/harness-perf-tdd/skill.yaml +47 -0
  67. package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +657 -0
  68. package/dist/agents/skills/gemini-cli/harness-release-readiness/skill.yaml +57 -0
  69. package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +50 -0
  70. package/dist/agents/skills/gemini-cli/harness-security-scan/SKILL.md +102 -0
  71. package/dist/agents/skills/gemini-cli/harness-security-scan/skill.yaml +41 -0
  72. package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +131 -0
  73. package/dist/agents/skills/gemini-cli/harness-test-advisor/skill.yaml +44 -0
  74. package/dist/agents/skills/tests/platform-parity.test.ts +131 -0
  75. package/dist/agents/skills/tests/schema.ts +2 -0
  76. package/dist/bin/harness.js +2 -2
  77. package/dist/{chunk-EFZOLZFB.js → chunk-ACMDUQJG.js} +4 -2
  78. package/dist/{chunk-C3J2HW4Y.js → chunk-O6NEKDYP.js} +2002 -487
  79. package/dist/{create-skill-4GKJZB5R.js → create-skill-NZDLMMR6.js} +1 -1
  80. package/dist/index.d.ts +265 -143
  81. package/dist/index.js +30 -4
  82. package/package.json +3 -2
@@ -0,0 +1,154 @@
1
+ # Harness Knowledge Mapper
2
+
3
+ > Auto-generate always-current knowledge maps from graph topology. Never stale because it's computed, not authored.
4
+
5
+ ## When to Use
6
+
7
+ - When AGENTS.md is outdated or doesn't exist — generate it from the graph
8
+ - After major refactoring — regenerate the knowledge map to reflect new structure
9
+ - On scheduled basis — keep documentation aligned with code
10
+ - When `on_commit` to main triggers fire
11
+ - NOT for validating existing AGENTS.md (use validate-context-engineering)
12
+ - NOT for fixing documentation drift (use align-documentation)
13
+
14
+ ## Prerequisites
15
+
16
+ A knowledge graph must exist at `.harness/graph/`. Run `harness scan` if no graph is available.
17
+ If the graph exists but code has changed since the last scan, re-run `harness scan` first — stale graph data leads to inaccurate results.
18
+
19
+ ## Process
20
+
21
+ ### Phase 1: SURVEY — Query Graph for Structure
22
+
23
+ 1. **Module hierarchy**: Query for module nodes and their `contains` edges to file nodes.
24
+
25
+ ```
26
+ query_graph(rootNodeIds=[all module nodes], includeTypes=["module", "file"], includeEdges=["contains"])
27
+ ```
28
+
29
+ 2. **Entry points**: Find file nodes with high out-degree but low in-degree (they initiate dependency chains).
30
+
31
+ ```
32
+ search_similar(query="main entry point index")
33
+ ```
34
+
35
+ 3. **Layer structure**: Query for layer nodes if defined.
36
+
37
+ 4. **Dependency flow**: For each module, trace outbound `imports` edges to other modules.
38
+
39
+ ```
40
+ get_relationships(nodeId=<module>, direction="outbound", depth=1)
41
+ ```
42
+
43
+ ### Phase 2: GENERATE — Build Knowledge Map
44
+
45
+ Generate markdown sections following AGENTS.md conventions:
46
+
47
+ 1. **Repository Structure**: Module hierarchy with brief descriptions derived from file contents and function names.
48
+
49
+ 2. **Key Entry Points**: Files identified as entry points with their purpose (inferred from exports and naming).
50
+
51
+ 3. **Module Dependencies**: For each module, list what it depends on and what depends on it. Format as a dependency table.
52
+
53
+ 4. **API Surface**: Public exports from each module, grouped by type (functions, classes, types).
54
+
55
+ 5. **Patterns and Conventions**: Detected patterns from graph structure (e.g., "all services follow Repository pattern", "tests co-located with source").
56
+
57
+ ### Phase 3: AUDIT — Identify Coverage Gaps
58
+
59
+ 1. **Undocumented modules**: Use `check_docs` to find code nodes without `documents` edges.
60
+
61
+ 2. **Missing descriptions**: Modules with no README or doc file.
62
+
63
+ 3. **Stale references**: If an existing AGENTS.md exists, compare its file references against the graph to find mentions of files that no longer exist.
64
+
65
+ ### Phase 4: OUTPUT — Write Knowledge Map
66
+
67
+ 1. **Default**: Write to AGENTS.md in project root.
68
+ 2. **Custom path**: Write to specified output path.
69
+ 3. **Diff mode**: If AGENTS.md exists, show what changed rather than overwriting.
70
+
71
+ ### Output
72
+
73
+ ```
74
+ ## Generated Knowledge Map
75
+
76
+ ### Repository Structure
77
+ - **packages/core/** — Core library: context assembly, entropy detection, constraints, feedback
78
+ - src/context/ — Token budget, filtering, doc coverage, knowledge map validation
79
+ - src/entropy/ — Drift detection, dead code analysis, pattern violations
80
+ - src/constraints/ — Layer validation, circular dependency detection, boundaries
81
+ - src/feedback/ — Self-review, peer review, diff analysis
82
+
83
+ - **packages/graph/** — Knowledge graph: store, query, ingest, search
84
+ - src/store/ — LokiJS-backed graph store, vector store, serialization
85
+ - src/query/ — ContextQL traversal, projection
86
+ - src/ingest/ — Code, git, knowledge, connector ingestion
87
+ - src/search/ — FusionLayer hybrid search
88
+
89
+ ### Entry Points
90
+ 1. packages/core/src/index.ts — Core library barrel export
91
+ 2. packages/graph/src/index.ts — Graph library barrel export
92
+ 3. packages/cli/src/index.ts — CLI entry point (Commander.js)
93
+ 4. packages/mcp-server/src/server.ts — MCP server registration
94
+
95
+ ### Coverage Gaps
96
+ - 3 modules have no documentation
97
+ - 5 files have no test coverage
98
+ ```
99
+
100
+ ### Graph Refresh
101
+
102
+ After generating documentation, refresh the graph so new `documents` edges reflect the updated docs:
103
+
104
+ ```
105
+ harness scan [path]
106
+ ```
107
+
108
+ This ensures subsequent graph queries (impact analysis, drift detection) include the newly generated documentation.
109
+
110
+ ## Harness Integration
111
+
112
+ - **`harness scan`** — Must run before this skill to ensure graph is current.
113
+ - **`harness validate`** — Run after acting on findings to verify project health.
114
+ - **Graph tools** — This skill uses `query_graph`, `get_relationships`, and `check_docs` MCP tools.
115
+
116
+ ## Success Criteria
117
+
118
+ - Knowledge map generated with all sections (structure, entry points, dependencies, API surface, patterns)
119
+ - Coverage gaps identified (undocumented modules, missing descriptions, stale references)
120
+ - Output written to AGENTS.md (or specified path) in proper markdown format
121
+ - Report follows the structured output format
122
+ - All findings are backed by graph query evidence, not heuristics
123
+
124
+ ## Examples
125
+
126
+ ### Example: Generating AGENTS.md from Graph
127
+
128
+ ```
129
+ Input: No AGENTS.md exists, graph is current after harness scan
130
+
131
+ 1. SURVEY — query_graph for module hierarchy: 4 packages found
132
+ search_similar for entry points: 4 identified
133
+ get_relationships for dependency flow per module
134
+ 2. GENERATE — Built 5 sections: structure, entry points,
135
+ dependencies, API surface, patterns
136
+ 3. AUDIT — check_docs found 3 undocumented modules,
137
+ 5 files with no test coverage
138
+ 4. OUTPUT — Wrote AGENTS.md to project root (new file)
139
+
140
+ Output:
141
+ AGENTS.md generated (142 lines)
142
+ Coverage gaps: 3 undocumented modules, 5 untested files
143
+ No stale references (fresh generation)
144
+ ```
145
+
146
+ ## Gates
147
+
148
+ - **No generation without graph.** If no graph exists, stop and instruct to run `harness scan`.
149
+ - **Never overwrite without confirmation.** If AGENTS.md exists, show the diff and ask before replacing.
150
+
151
+ ## Escalation
152
+
153
+ - **When >50% of modules are undocumented**: Flag as critical documentation debt.
154
+ - **When graph structure doesn't match directory structure**: The graph may be stale — recommend re-scanning.
@@ -0,0 +1,49 @@
1
+ name: harness-knowledge-mapper
2
+ version: "1.0.0"
3
+ description: Auto-generate always-current knowledge maps from graph topology
4
+ cognitive_mode: constructive-architect
5
+ triggers:
6
+ - manual
7
+ - on_commit
8
+ - scheduled
9
+ platforms:
10
+ - claude-code
11
+ - gemini-cli
12
+ tools:
13
+ - Bash
14
+ - Read
15
+ - Write
16
+ - Glob
17
+ - Grep
18
+ cli:
19
+ command: harness skill run harness-knowledge-mapper
20
+ args:
21
+ - name: path
22
+ description: Project root path
23
+ required: false
24
+ - name: output
25
+ description: Output file path (default AGENTS.md)
26
+ required: false
27
+ mcp:
28
+ tool: run_skill
29
+ input:
30
+ skill: harness-knowledge-mapper
31
+ path: string
32
+ type: rigid
33
+ phases:
34
+ - name: survey
35
+ description: Query graph for module structure and topology
36
+ required: true
37
+ - name: generate
38
+ description: Generate structured knowledge map from graph data
39
+ required: true
40
+ - name: audit
41
+ description: Identify undocumented modules and coverage gaps
42
+ required: true
43
+ - name: output
44
+ description: Write knowledge map to file
45
+ required: true
46
+ state:
47
+ persistent: false
48
+ files: []
49
+ depends_on: []
@@ -0,0 +1,231 @@
1
+ # Harness Perf
2
+
3
+ > Performance enforcement and benchmark management. Tier-based gates block commits and merges based on complexity, coupling, and runtime regression severity.
4
+
5
+ ## When to Use
6
+
7
+ - After code changes to verify performance hasn't degraded
8
+ - On PRs to enforce performance budgets
9
+ - For periodic performance audits
10
+ - NOT for initial development (use harness-tdd for that)
11
+ - NOT for brainstorming performance improvements (use harness-brainstorming)
12
+
13
+ ## Process
14
+
15
+ ### Iron Law
16
+
17
+ **No merge with Tier 1 performance violations. No commit with cyclomatic complexity exceeding the error threshold.**
18
+
19
+ Tier 1 violations are non-negotiable blockers. If a Tier 1 violation is detected, execution halts and the violation must be resolved before any further progress. Do not attempt workarounds.
20
+
21
+ ---
22
+
23
+ ### Phase 1: ANALYZE — Structural and Coupling Checks
24
+
25
+ 1. **Run structural checks.** Execute `harness check-perf --structural` to compute complexity metrics for all changed files:
26
+ - Cyclomatic complexity per function
27
+ - Nesting depth per function
28
+ - File length (lines of code)
29
+ - Parameter count per function
30
+
31
+ 2. **Run coupling checks.** Execute `harness check-perf --coupling` to compute coupling metrics:
32
+ - Fan-in and fan-out per module
33
+ - Afferent and efferent coupling
34
+ - Transitive dependency depth
35
+ - Circular dependency detection
36
+
37
+ 3. **Classify violations by tier:**
38
+ - **Tier 1 (error, block commit):** Cyclomatic complexity > 15, circular dependencies, hotspot in top 5%
39
+ - **Tier 2 (warning, block merge):** Complexity > 10, nesting > 4, fan-out > 10, size budget exceeded
40
+ - **Tier 3 (info, no gate):** File length > 300, fan-in > 20, transitive depth > 30
41
+
42
+ 4. **If Tier 1 violations found,** report them immediately and STOP. Do not proceed to benchmarks. The violations must be fixed first.
43
+
44
+ 5. **If no violations found,** proceed to Phase 2.
45
+
46
+ ---
47
+
48
+ ### Phase 2: BENCHMARK — Runtime Performance
49
+
50
+ This phase runs only when `.bench.ts` files exist in the project. If none are found, skip to Phase 3.
51
+
52
+ 1. **Check for benchmark files.** Scan the project for `*.bench.ts` files. If none exist, skip this phase entirely.
53
+
54
+ 2. **Verify clean working tree.** Run `git status --porcelain`. If there are uncommitted changes, STOP. Benchmarks on dirty trees produce unreliable results.
55
+
56
+ 3. **Run benchmarks.** Execute `harness perf bench` to run all benchmark suites.
57
+
58
+ 4. **Load baselines.** Read `.harness/perf/baselines.json` for previous benchmark results. If no baselines exist, treat this as a baseline-capture run.
59
+
60
+ 5. **Compare results against baselines** using the `RegressionDetector`:
61
+ - Calculate percentage change for each benchmark
62
+ - Apply noise margin (default: 3%) before flagging regressions
63
+ - Distinguish between critical-path and non-critical-path benchmarks
64
+
65
+ 6. **Resolve critical paths** via `CriticalPathResolver`:
66
+ - Check `@perf-critical` annotations in source files
67
+ - Check graph fan-in data (functions called by many consumers)
68
+ - Functions in the critical path set have stricter thresholds
69
+
70
+ 7. **Flag regressions by tier:**
71
+ - **Tier 1:** >5% regression on a critical path benchmark
72
+ - **Tier 2:** >10% regression on a non-critical-path benchmark
73
+ - **Tier 3:** >5% regression on a non-critical-path benchmark (within noise margin consideration)
74
+
75
+ 8. **If this is a baseline-capture run,** report results without regression comparison. Recommend running `harness perf baselines update` to persist.
76
+
77
+ ---
78
+
79
+ ### Phase 3: REPORT — Generate Performance Report
80
+
81
+ 1. **Format violations by tier.** Present Tier 1 violations first (most severe), then Tier 2, then Tier 3. Each violation entry includes:
82
+ - File path and function name
83
+ - Metric name and current value
84
+ - Threshold that was exceeded
85
+ - Tier classification and gate impact
86
+
87
+ 2. **Show hotspot scores** for top functions if knowledge graph data is available:
88
+ - Query the graph for functions with high churn + high fan-in
89
+ - Rank by composite hotspot score
90
+ - Flag any hotspots that also have performance violations
91
+
92
+ 3. **Show benchmark regression summary** if benchmarks ran:
93
+ - Table of benchmark name, baseline, current, delta percentage, tier
94
+ - Highlight critical-path benchmarks with a marker
95
+ - Show noise margin and whether the regression exceeds it
96
+
97
+ 4. **Recommend specific actions** for each Tier 1 and Tier 2 violation:
98
+ - For high complexity: suggest extract-method or strategy pattern refactoring
99
+ - For high coupling: suggest interface extraction or dependency inversion
100
+ - For benchmark regressions: suggest profiling the specific code path
101
+ - For size budget violations: suggest module decomposition
102
+
103
+ 5. **Output the report** in structured markdown format suitable for PR comments or CI output.
104
+
105
+ ---
106
+
107
+ ### Phase 4: ENFORCE — Apply Gate Decisions
108
+
109
+ 1. **Tier 1 violations present** — FAIL. Block commit and merge. List all Tier 1 violations with their locations and values. The developer must fix these before proceeding.
110
+
111
+ 2. **Tier 2 violations present, no Tier 1** — WARN. Allow commit but block merge until addressed. List all Tier 2 violations. These must be resolved before the PR can be merged.
112
+
113
+ 3. **Only Tier 3 or no violations** — PASS. Proceed normally. Log Tier 3 violations as informational notes.
114
+
115
+ 4. **Record gate decision** in `.harness/state.json` under a `perfGate` key:
116
+
117
+ ```json
118
+ {
119
+ "perfGate": {
120
+ "result": "pass|warn|fail",
121
+ "tier1Count": 0,
122
+ "tier2Count": 0,
123
+ "tier3Count": 0,
124
+ "timestamp": "ISO-8601"
125
+ }
126
+ }
127
+ ```
128
+
129
+ 5. **Exit with appropriate code:** 0 for pass, 1 for fail, 0 for warn (with warning output).
130
+
131
+ ---
132
+
133
+ ## Harness Integration
134
+
135
+ - **`harness check-perf`** — Primary command for all performance checks. Runs structural and coupling analysis.
136
+ - **`harness check-perf --structural`** — Run only structural complexity checks.
137
+ - **`harness check-perf --coupling`** — Run only coupling analysis.
138
+ - **`harness perf bench`** — Run benchmarks only. Requires clean working tree.
139
+ - **`harness perf baselines show`** — View current benchmark baselines.
140
+ - **`harness perf baselines update`** — Persist current benchmark results as new baselines.
141
+ - **`harness perf critical-paths`** — View the current critical path set and how it was determined.
142
+ - **`harness validate`** — Run after enforcement to verify overall project health.
143
+ - **`harness graph scan`** — Refresh knowledge graph for accurate hotspot scoring.
144
+
145
+ ## Tier Classification
146
+
147
+ | Tier | Severity | Gate | Examples |
148
+ | ---- | -------- | ------------ | --------------------------------------------------------------------------------------------------- |
149
+ | 1 | error | Block commit | Cyclomatic complexity > 15, >5% regression on critical path, hotspot in top 5%, circular dependency |
150
+ | 2 | warning | Block merge | Complexity > 10, nesting > 4, >10% regression elsewhere, fan-out > 10, size budget exceeded |
151
+ | 3 | info | None | File length > 300 lines, fan-in > 20, transitive depth > 30, >5% non-critical regression |
152
+
153
+ ## Success Criteria
154
+
155
+ - All Tier 1 violations are resolved before proceeding
156
+ - Performance report follows structured format with tier classification
157
+ - Benchmark regressions are compared against noise margin before flagging
158
+ - Gate decision is recorded in state
159
+ - `harness validate` passes after enforcement
160
+
161
+ ## Examples
162
+
163
+ ### Example: PR with High Complexity Function
164
+
165
+ ```
166
+ Phase 1: ANALYZE
167
+ harness check-perf --structural
168
+ Result: processOrderBatch() in src/orders/processor.ts has cyclomatic complexity 18 (Tier 1, threshold: 15)
169
+
170
+ Phase 2: BENCHMARK — skipped (Tier 1 violation found)
171
+
172
+ Phase 3: REPORT
173
+ TIER 1 VIOLATIONS (1):
174
+ - src/orders/processor.ts:processOrderBatch — complexity 18 > 15
175
+ Recommendation: Extract validation and transformation into separate functions
176
+
177
+ Phase 4: ENFORCE
178
+ Result: FAIL — 1 Tier 1 violation. Commit blocked.
179
+ ```
180
+
181
+ ### Example: Benchmark Regression on Critical Path
182
+
183
+ ```
184
+ Phase 1: ANALYZE — no structural violations
185
+
186
+ Phase 2: BENCHMARK
187
+ harness perf bench
188
+ Baseline: parseDocument 4.2ms, current: 4.8ms (+14.3%)
189
+ parseDocument is @perf-critical — Tier 1 threshold applies (>5%)
190
+
191
+ Phase 3: REPORT
192
+ TIER 1 VIOLATIONS (1):
193
+ - parseDocument: 14.3% regression on critical path (threshold: 5%)
194
+ Recommendation: Profile parseDocument to identify the regression source
195
+
196
+ Phase 4: ENFORCE
197
+ Result: FAIL — 1 Tier 1 violation. Merge blocked.
198
+ ```
199
+
200
+ ### Example: Clean PR with Minor Warnings
201
+
202
+ ```
203
+ Phase 1: ANALYZE
204
+ harness check-perf --structural --coupling
205
+ Result: src/utils/formatter.ts has 320 lines (Tier 3, threshold: 300)
206
+
207
+ Phase 2: BENCHMARK
208
+ harness perf bench — all within noise margin
209
+
210
+ Phase 3: REPORT
211
+ TIER 3 INFO (1):
212
+ - src/utils/formatter.ts: 320 lines > 300 line threshold
213
+ No Tier 1 or Tier 2 violations.
214
+
215
+ Phase 4: ENFORCE
216
+ Result: PASS — no blocking violations.
217
+ ```
218
+
219
+ ## Gates
220
+
221
+ - **No ignoring Tier 1 violations.** They must be fixed or the threshold must be reconfigured (with documented justification).
222
+ - **No running benchmarks with dirty working tree.** Uncommitted changes invalidate benchmark results.
223
+ - **No updating baselines without running benchmarks.** Baselines must come from fresh runs against committed code.
224
+ - **No suppressing violations without documentation.** If a threshold is relaxed, the rationale must be documented in the project configuration.
225
+
226
+ ## Escalation
227
+
228
+ - **When Tier 1 violations cannot be fixed within the current task:** Propose refactoring the function into smaller units, or raising the threshold with a documented justification. Do not silently skip the violation.
229
+ - **When benchmark results are noisy or inconsistent:** Increase warmup iterations, pin the runtime environment, or run benchmarks in isolation. Report the noise level so the developer can make an informed decision.
230
+ - **When critical path detection seems wrong:** Check `@perf-critical` annotations in source files and verify graph fan-in thresholds. The critical path set can be overridden in `.harness/perf/critical-paths.json`.
231
+ - **When a violation is a false positive:** Document it with a `// perf-ignore: <reason>` comment and add the exception to `.harness/perf/exceptions.json`.
@@ -0,0 +1,47 @@
1
+ name: harness-perf
2
+ version: "1.0.0"
3
+ description: Performance enforcement and benchmark management
4
+ cognitive_mode: meticulous-verifier
5
+ triggers:
6
+ - manual
7
+ - on_pr
8
+ platforms:
9
+ - claude-code
10
+ - gemini-cli
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Write
15
+ - Edit
16
+ - Glob
17
+ - Grep
18
+ cli:
19
+ command: harness skill run harness-perf
20
+ args:
21
+ - name: path
22
+ description: Project root path
23
+ required: false
24
+ mcp:
25
+ tool: run_skill
26
+ input:
27
+ skill: harness-perf
28
+ path: string
29
+ type: rigid
30
+ phases:
31
+ - name: analyze
32
+ description: Run structural complexity and coupling checks
33
+ required: true
34
+ - name: benchmark
35
+ description: Run benchmarks and detect regressions
36
+ required: false
37
+ - name: report
38
+ description: Generate perf report with violations and recommendations
39
+ required: true
40
+ - name: enforce
41
+ description: Apply tier-based gate decisions
42
+ required: true
43
+ state:
44
+ persistent: false
45
+ files: []
46
+ depends_on:
47
+ - harness-verify