@ryuenn3123/agentic-senior-core 4.4.0 → 5.1.0

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 (196) hide show
  1. package/.agents/plugins/marketplace.json +21 -0
  2. package/.agents/rules/agentic-senior-core.md +126 -0
  3. package/.claude-plugin/marketplace.json +17 -0
  4. package/.claude-plugin/plugin.json +17 -0
  5. package/.clinerules/agentic-senior-core.md +94 -0
  6. package/.codex-plugin/plugin.json +24 -0
  7. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  8. package/.devin-plugin/plugin.json +13 -0
  9. package/.github/copilot-instructions.md +94 -0
  10. package/.github/plugin/marketplace.json +20 -0
  11. package/.github/plugin/plugin.json +16 -0
  12. package/.kiro/steering/agentic-senior-core.md +94 -0
  13. package/.openclaw/skills/asc/SKILL.md +23 -0
  14. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  15. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  16. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  17. package/.windsurf/rules/agentic-senior-core.md +94 -0
  18. package/AGENTS.md +126 -127
  19. package/CONTRIBUTING.md +93 -63
  20. package/README.md +160 -111
  21. package/__init__.py +61 -0
  22. package/bin/agentic-senior-core.js +42 -41
  23. package/commands/asc-audit.md +1 -0
  24. package/commands/asc-audit.toml +2 -0
  25. package/commands/asc-help.md +9 -0
  26. package/commands/asc-help.toml +2 -0
  27. package/commands/asc-refactor.md +1 -0
  28. package/commands/asc-refactor.toml +2 -0
  29. package/commands/asc-review.md +1 -0
  30. package/commands/asc-review.toml +2 -0
  31. package/gemini-extension.json +10 -0
  32. package/hooks/copilot-hooks.json +21 -0
  33. package/hooks/hooks.json +31 -0
  34. package/hooks/session-start.js +36 -0
  35. package/hooks/subagent-start.js +38 -0
  36. package/lib/cli/commands/adapter.mjs +109 -0
  37. package/lib/cli/commands/clean.mjs +63 -0
  38. package/lib/cli/commands/status.mjs +94 -0
  39. package/package.json +43 -60
  40. package/plugin.yaml +16 -0
  41. package/scripts/uninstall.js +38 -0
  42. package/skills/asc/SKILL.md +16 -0
  43. package/skills/asc-audit/SKILL.md +28 -0
  44. package/skills/asc-refactor/SKILL.md +35 -0
  45. package/skills/asc-review/SKILL.md +54 -0
  46. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  47. package/.agent-context/prompts/bootstrap-design.md +0 -63
  48. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  49. package/.agent-context/prompts/init-project.md +0 -60
  50. package/.agent-context/prompts/refactor.md +0 -38
  51. package/.agent-context/prompts/review-code.md +0 -31
  52. package/.agent-context/review-checklists/architecture-review.md +0 -57
  53. package/.agent-context/review-checklists/pr-checklist.md +0 -134
  54. package/.agent-context/rules/api-docs.md +0 -24
  55. package/.agent-context/rules/api-versioning.md +0 -16
  56. package/.agent-context/rules/architecture.md +0 -38
  57. package/.agent-context/rules/background-jobs.md +0 -17
  58. package/.agent-context/rules/config-and-flags.md +0 -16
  59. package/.agent-context/rules/database-design.md +0 -18
  60. package/.agent-context/rules/docker-runtime.md +0 -17
  61. package/.agent-context/rules/error-handling.md +0 -16
  62. package/.agent-context/rules/event-driven.md +0 -16
  63. package/.agent-context/rules/frontend-architecture.md +0 -54
  64. package/.agent-context/rules/microservices.md +0 -16
  65. package/.agent-context/rules/migrations.md +0 -16
  66. package/.agent-context/rules/observability.md +0 -16
  67. package/.agent-context/rules/performance.md +0 -16
  68. package/.agent-context/rules/realtime.md +0 -16
  69. package/.agent-context/rules/resilience.md +0 -18
  70. package/.agent-context/rules/security.md +0 -18
  71. package/.agent-context/rules/testing.md +0 -16
  72. package/.agent-context/state/README.md +0 -25
  73. package/.agent-context/state/architecture-map.md +0 -40
  74. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  75. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  76. package/.agent-context/state/benchmark-thresholds.json +0 -10
  77. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  78. package/.agent-context/state/dependency-map.md +0 -41
  79. package/.agent-context/state/memory-adapter-contract.json +0 -52
  80. package/.agent-context/state/memory-schema-v1.json +0 -88
  81. package/GEMINI.md +0 -1
  82. package/benchmarks/README.md +0 -60
  83. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  84. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  85. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  86. package/lib/cli/adaptive-context/catalog.mjs +0 -394
  87. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  88. package/lib/cli/adaptive-context/implications.mjs +0 -44
  89. package/lib/cli/adaptive-context.mjs +0 -151
  90. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  91. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  92. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  93. package/lib/cli/backup.mjs +0 -210
  94. package/lib/cli/commands/context.mjs +0 -140
  95. package/lib/cli/commands/init/project-context.mjs +0 -60
  96. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  97. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  98. package/lib/cli/commands/init.mjs +0 -654
  99. package/lib/cli/commands/launch.mjs +0 -76
  100. package/lib/cli/commands/optimize.mjs +0 -284
  101. package/lib/cli/commands/rollback.mjs +0 -64
  102. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  103. package/lib/cli/commands/upgrade.mjs +0 -451
  104. package/lib/cli/compiler.mjs +0 -187
  105. package/lib/cli/constants.mjs +0 -136
  106. package/lib/cli/detector/constants.mjs +0 -135
  107. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  108. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  109. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  110. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  111. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  112. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  113. package/lib/cli/detector/design-evidence.mjs +0 -25
  114. package/lib/cli/detector/stack-detection.mjs +0 -243
  115. package/lib/cli/detector/ui-signals.mjs +0 -150
  116. package/lib/cli/detector/workspace-scan.mjs +0 -177
  117. package/lib/cli/detector.mjs +0 -23
  118. package/lib/cli/init-detection-flow.mjs +0 -48
  119. package/lib/cli/init-options.mjs +0 -237
  120. package/lib/cli/init-selection.mjs +0 -29
  121. package/lib/cli/memory-continuity.mjs +0 -537
  122. package/lib/cli/preflight.mjs +0 -76
  123. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  124. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  125. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  126. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  127. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  128. package/lib/cli/project-scaffolder.mjs +0 -29
  129. package/lib/cli/rollback.mjs +0 -66
  130. package/lib/cli/token-optimization.mjs +0 -401
  131. package/lib/cli/utils/filesystem.mjs +0 -81
  132. package/lib/cli/utils/managed-surface.mjs +0 -280
  133. package/lib/cli/utils/prompting.mjs +0 -44
  134. package/lib/cli/utils.mjs +0 -479
  135. package/mcp.json +0 -134
  136. package/scripts/adaptive-context/fixtures.mjs +0 -183
  137. package/scripts/adaptive-context-benchmark.mjs +0 -9
  138. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  139. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  140. package/scripts/benchmark-gate.mjs +0 -121
  141. package/scripts/benchmark-intelligence.mjs +0 -33
  142. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  143. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  144. package/scripts/bump-version.mjs +0 -103
  145. package/scripts/clean-local-artifacts.mjs +0 -78
  146. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  147. package/scripts/context-triggered-audit.mjs +0 -391
  148. package/scripts/detection-benchmark.mjs +0 -127
  149. package/scripts/docs-quality-drift-report.mjs +0 -358
  150. package/scripts/documentation-boundary-audit.mjs +0 -305
  151. package/scripts/explain-on-demand-audit.mjs +0 -427
  152. package/scripts/forbidden-content-check.mjs +0 -123
  153. package/scripts/frontend-usability-audit.mjs +0 -243
  154. package/scripts/generate-sbom.mjs +0 -61
  155. package/scripts/governance-weekly-report.mjs +0 -466
  156. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  157. package/scripts/llm-judge/constants.mjs +0 -66
  158. package/scripts/llm-judge/diff-collection.mjs +0 -74
  159. package/scripts/llm-judge/prompting.mjs +0 -78
  160. package/scripts/llm-judge/providers.mjs +0 -111
  161. package/scripts/llm-judge/verdict.mjs +0 -134
  162. package/scripts/llm-judge.mjs +0 -200
  163. package/scripts/memory-continuity-benchmark.mjs +0 -322
  164. package/scripts/quality-trend-report.mjs +0 -289
  165. package/scripts/release-gate/audit-checks.mjs +0 -441
  166. package/scripts/release-gate/constants.mjs +0 -53
  167. package/scripts/release-gate/runtime.mjs +0 -63
  168. package/scripts/release-gate/static-checks.mjs +0 -182
  169. package/scripts/release-gate.mjs +0 -42
  170. package/scripts/rules-guardian-audit.mjs +0 -580
  171. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  172. package/scripts/sync-thin-adapters.mjs +0 -72
  173. package/scripts/token-optimization-benchmark.mjs +0 -252
  174. package/scripts/ui-design-judge/constants.mjs +0 -13
  175. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  176. package/scripts/ui-design-judge/git-input.mjs +0 -134
  177. package/scripts/ui-design-judge/prompting.mjs +0 -52
  178. package/scripts/ui-design-judge/providers.mjs +0 -102
  179. package/scripts/ui-design-judge/reporting.mjs +0 -183
  180. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  181. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  182. package/scripts/ui-design-judge.mjs +0 -319
  183. package/scripts/ui-rubric-calibration.mjs +0 -35
  184. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  185. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  186. package/scripts/validate/audits/file-size.mjs +0 -158
  187. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  188. package/scripts/validate/audits/release-bundle.mjs +0 -135
  189. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  190. package/scripts/validate/config.mjs +0 -501
  191. package/scripts/validate/coverage-checks.mjs +0 -446
  192. package/scripts/validate/file-structure.mjs +0 -158
  193. package/scripts/validate/markdown-content.mjs +0 -109
  194. package/scripts/validate/project-metadata.mjs +0 -166
  195. package/scripts/validate/utils.mjs +0 -52
  196. package/scripts/validate.mjs +0 -267
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * benchmark-gate.mjs
5
- *
6
- * Anti-regression gate for benchmark quality signals.
7
- * Fails when benchmark metrics drop below configured thresholds.
8
- */
9
-
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import { dirname, join, resolve } from 'node:path';
12
- import { fileURLToPath } from 'node:url';
13
- import { execFileSync } from 'node:child_process';
14
-
15
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
16
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
17
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
18
- const BENCHMARK_THRESHOLD_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-thresholds.json');
19
- const DETECTION_BENCHMARK_PATH = join(REPOSITORY_ROOT, 'scripts', 'detection-benchmark.mjs');
20
-
21
- function readThresholdConfiguration() {
22
- if (!existsSync(BENCHMARK_THRESHOLD_PATH)) {
23
- return {
24
- minimumTop1Accuracy: 0.9,
25
- maximumManualCorrectionRate: 0.12,
26
- maximumTop1AccuracyDrop: 0.02,
27
- maximumManualCorrectionIncrease: 0.03,
28
- previousReleaseBaseline: {
29
- top1Accuracy: 0.9167,
30
- manualCorrectionRate: 0.0833,
31
- },
32
- };
33
- }
34
-
35
- return JSON.parse(readFileSync(BENCHMARK_THRESHOLD_PATH, 'utf8'));
36
- }
37
-
38
- function runDetectionBenchmark() {
39
- const benchmarkRawOutput = execFileSync('node', [DETECTION_BENCHMARK_PATH], {
40
- cwd: REPOSITORY_ROOT,
41
- encoding: 'utf8',
42
- });
43
-
44
- return JSON.parse(benchmarkRawOutput);
45
- }
46
-
47
- function buildCheckResult(checkName, passed, details) {
48
- return {
49
- checkName,
50
- passed,
51
- details,
52
- };
53
- }
54
-
55
- function runBenchmarkGate() {
56
- const thresholdConfiguration = readThresholdConfiguration();
57
- const benchmarkResult = runDetectionBenchmark();
58
- const benchmarkChecks = [];
59
-
60
- const top1AccuracyPassed = benchmarkResult.top1Accuracy >= thresholdConfiguration.minimumTop1Accuracy;
61
- benchmarkChecks.push(
62
- buildCheckResult(
63
- 'minimum-top1-accuracy',
64
- top1AccuracyPassed,
65
- `top1Accuracy=${benchmarkResult.top1Accuracy} minimum=${thresholdConfiguration.minimumTop1Accuracy}`,
66
- ),
67
- );
68
-
69
- const manualCorrectionPassed = benchmarkResult.manualCorrectionRate <= thresholdConfiguration.maximumManualCorrectionRate;
70
- benchmarkChecks.push(
71
- buildCheckResult(
72
- 'maximum-manual-correction-rate',
73
- manualCorrectionPassed,
74
- `manualCorrectionRate=${benchmarkResult.manualCorrectionRate} maximum=${thresholdConfiguration.maximumManualCorrectionRate}`,
75
- ),
76
- );
77
-
78
- const previousReleaseBaseline = thresholdConfiguration.previousReleaseBaseline;
79
- if (previousReleaseBaseline && typeof previousReleaseBaseline === 'object') {
80
- const top1AccuracyDrop = Number((previousReleaseBaseline.top1Accuracy - benchmarkResult.top1Accuracy).toFixed(4));
81
- const manualCorrectionIncrease = Number((benchmarkResult.manualCorrectionRate - previousReleaseBaseline.manualCorrectionRate).toFixed(4));
82
-
83
- const top1AccuracyDropPassed = top1AccuracyDrop <= thresholdConfiguration.maximumTop1AccuracyDrop;
84
- benchmarkChecks.push(
85
- buildCheckResult(
86
- 'maximum-top1-accuracy-drop',
87
- top1AccuracyDropPassed,
88
- `drop=${top1AccuracyDrop} maximum=${thresholdConfiguration.maximumTop1AccuracyDrop}`,
89
- ),
90
- );
91
-
92
- const manualCorrectionIncreasePassed = manualCorrectionIncrease <= thresholdConfiguration.maximumManualCorrectionIncrease;
93
- benchmarkChecks.push(
94
- buildCheckResult(
95
- 'maximum-manual-correction-increase',
96
- manualCorrectionIncreasePassed,
97
- `increase=${manualCorrectionIncrease} maximum=${thresholdConfiguration.maximumManualCorrectionIncrease}`,
98
- ),
99
- );
100
- }
101
-
102
- const failedCheckCount = benchmarkChecks.filter((benchmarkCheck) => !benchmarkCheck.passed).length;
103
- const benchmarkGateReport = {
104
- generatedAt: new Date().toISOString(),
105
- gateName: 'benchmark-gate',
106
- passed: failedCheckCount === 0,
107
- failureCount: failedCheckCount,
108
- benchmarkResult: {
109
- fixtureCount: benchmarkResult.fixtureCount,
110
- top1Accuracy: benchmarkResult.top1Accuracy,
111
- manualCorrectionRate: benchmarkResult.manualCorrectionRate,
112
- },
113
- thresholds: thresholdConfiguration,
114
- results: benchmarkChecks,
115
- };
116
-
117
- console.log(JSON.stringify(benchmarkGateReport, null, 2));
118
- process.exit(benchmarkGateReport.passed ? 0 : 1);
119
- }
120
-
121
- runBenchmarkGate();
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * benchmark-intelligence.mjs
5
- *
6
- * Benchmark intelligence compatibility report.
7
- * Static external watchlists were retired to avoid stale or biasing research inputs.
8
- */
9
-
10
- function runIntelligenceValidation() {
11
- const validationResults = [
12
- {
13
- checkName: 'static-external-watchlist-retired',
14
- passed: true,
15
- details: 'Static external benchmark watchlists are retired; use live official docs and repo evidence for current claims.',
16
- },
17
- ];
18
- const intelligenceReport = {
19
- generatedAt: new Date().toISOString(),
20
- reportName: 'benchmark-intelligence',
21
- passed: true,
22
- failureCount: 0,
23
- reviewSlaDays: null,
24
- staticExternalWatchlistRetired: true,
25
- watchlist: [],
26
- results: validationResults,
27
- };
28
-
29
- console.log(JSON.stringify(intelligenceReport, null, 2));
30
- process.exit(intelligenceReport.passed ? 0 : 1);
31
- }
32
-
33
- runIntelligenceValidation();
@@ -1,379 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * benchmark-writer-judge-matrix.mjs
5
- *
6
- * V2.5.1 writer-judge architecture artifact.
7
- * Builds side-by-side comparison matrix using independently configured
8
- * writer and judge lanes with blind review tokens.
9
- */
10
-
11
- import { existsSync, readFileSync } from 'node:fs';
12
- import fs from 'node:fs/promises';
13
- import { spawnSync } from 'node:child_process';
14
- import { dirname, join, resolve } from 'node:path';
15
- import { fileURLToPath } from 'node:url';
16
-
17
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
18
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
19
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
20
- const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
21
- const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
22
-
23
- const CONFIG_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-writer-judge-config.json');
24
- const REPRO_PROFILE_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-reproducibility.json');
25
- const THRESHOLD_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-thresholds.json');
26
- const OUTPUT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-writer-judge-matrix.json');
27
-
28
- function readJsonOrNull(filePath) {
29
- if (!existsSync(filePath)) {
30
- return null;
31
- }
32
-
33
- try {
34
- return JSON.parse(readFileSync(filePath, 'utf8'));
35
- } catch {
36
- return null;
37
- }
38
- }
39
-
40
- function runJsonScript(scriptRelativePath, scriptArguments = []) {
41
- const absoluteScriptPath = join(REPOSITORY_ROOT, scriptRelativePath);
42
- const commandResult = spawnSync('node', [absoluteScriptPath, ...scriptArguments], {
43
- cwd: REPOSITORY_ROOT,
44
- encoding: 'utf8',
45
- maxBuffer: 1024 * 1024 * 10,
46
- });
47
-
48
- const stdoutContent = (commandResult.stdout || '').trim();
49
- const stderrContent = (commandResult.stderr || '').trim();
50
- const exitCode = typeof commandResult.status === 'number' ? commandResult.status : 1;
51
-
52
- if (!stdoutContent) {
53
- return {
54
- scriptPath: scriptRelativePath,
55
- exitCode,
56
- parsedReport: null,
57
- parseError: 'Script produced no stdout JSON payload',
58
- stderr: stderrContent,
59
- };
60
- }
61
-
62
- try {
63
- return {
64
- scriptPath: scriptRelativePath,
65
- exitCode,
66
- parsedReport: JSON.parse(stdoutContent),
67
- parseError: null,
68
- stderr: stderrContent,
69
- };
70
- } catch (jsonParseError) {
71
- const parseErrorMessage = jsonParseError instanceof Error ? jsonParseError.message : String(jsonParseError);
72
- return {
73
- scriptPath: scriptRelativePath,
74
- exitCode,
75
- parsedReport: null,
76
- parseError: parseErrorMessage,
77
- stderr: stderrContent,
78
- };
79
- }
80
- }
81
-
82
- function deterministicOffset(seed, maxMagnitude = 3) {
83
- let hash = 0;
84
- for (let index = 0; index < seed.length; index += 1) {
85
- hash = ((hash << 5) - hash) + seed.charCodeAt(index);
86
- hash |= 0;
87
- }
88
-
89
- const spread = (maxMagnitude * 2) + 1;
90
- const normalizedValue = Math.abs(hash) % spread;
91
- return normalizedValue - maxMagnitude;
92
- }
93
-
94
- function clamp(value, minimum, maximum) {
95
- return Math.min(Math.max(value, minimum), maximum);
96
- }
97
-
98
- function roundToTwo(value) {
99
- return Number(value.toFixed(2));
100
- }
101
-
102
- function buildDefaultConfig() {
103
- return {
104
- version: '1.0.0',
105
- phase: 'v2.5.1',
106
- blindReviewMode: true,
107
- writerLane: {
108
- models: [{ id: 'writer-default', provider: 'local', profile: 'balanced' }],
109
- weights: {
110
- quality: 40,
111
- efficiency: 20,
112
- reliability: 25,
113
- freshness: 15,
114
- },
115
- scenarioMultipliers: {
116
- planning: 1,
117
- refactor: 1,
118
- security: 1,
119
- delivery: 1,
120
- },
121
- },
122
- judgeLane: {
123
- models: [{ id: 'judge-default', provider: 'local', profile: 'audit' }],
124
- minimumCompositeScore: 75,
125
- leniencyWindow: 2,
126
- weights: {
127
- clarity: 35,
128
- correctness: 35,
129
- risk: 20,
130
- consistency: 10,
131
- },
132
- },
133
- };
134
- }
135
-
136
- function loadScenarios(reproducibilityProfile) {
137
- const defaultScenarios = [
138
- { id: 'planning', category: 'planning' },
139
- { id: 'refactor', category: 'refactor' },
140
- { id: 'security', category: 'security' },
141
- { id: 'delivery', category: 'delivery' },
142
- ];
143
-
144
- if (!Array.isArray(reproducibilityProfile?.scenarios) || reproducibilityProfile.scenarios.length === 0) {
145
- return defaultScenarios;
146
- }
147
-
148
- return reproducibilityProfile.scenarios.map((scenarioEntry) => ({
149
- id: scenarioEntry.id || 'unknown-scenario',
150
- category: scenarioEntry.category || 'planning',
151
- }));
152
- }
153
-
154
- function buildBaseSignals(detectionBenchmarkReport, tokenBenchmarkReport, benchmarkGateReport, benchmarkIntelligenceReport, thresholdConfiguration) {
155
- const top1Accuracy = Number(detectionBenchmarkReport?.top1Accuracy || 0);
156
- const manualCorrectionRate = Number(detectionBenchmarkReport?.manualCorrectionRate || 1);
157
-
158
- return {
159
- top1Accuracy,
160
- manualCorrectionRate,
161
- nativeSavingsPercent: Number(tokenBenchmarkReport?.summary?.averageNativeSavingsPercent || 0),
162
- benchmarkGatePassed: benchmarkGateReport?.passed === true,
163
- benchmarkGateFailureCount: Number(benchmarkGateReport?.failureCount || 0),
164
- intelligenceFailureCount: Number(benchmarkIntelligenceReport?.failureCount || 0),
165
- staticExternalWatchlistRetired: benchmarkIntelligenceReport?.staticExternalWatchlistRetired === true,
166
- top1AccuracyMet: top1Accuracy >= Number(thresholdConfiguration?.minimumTop1Accuracy || 0),
167
- manualCorrectionMet: manualCorrectionRate <= Number(thresholdConfiguration?.maximumManualCorrectionRate || 1),
168
- };
169
- }
170
-
171
- function buildWriterScenarioRun(writerModel, scenario, baseSignals, writerWeights, scenarioMultipliers) {
172
- const scenarioMultiplier = Number(scenarioMultipliers?.[scenario.category] || 1);
173
- const modelScenarioOffset = deterministicOffset(`${writerModel.id}:${scenario.id}`, 4);
174
-
175
- const qualityScore = clamp((baseSignals.top1Accuracy * 100 * scenarioMultiplier) + modelScenarioOffset, 0, 100);
176
- const efficiencyScore = clamp(baseSignals.nativeSavingsPercent + deterministicOffset(`${writerModel.id}:efficiency`, 3), 0, 100);
177
- const reliabilityScore = baseSignals.benchmarkGatePassed
178
- ? clamp(100 + deterministicOffset(`${writerModel.id}:reliability`, 2), 0, 100)
179
- : clamp(100 - (baseSignals.benchmarkGateFailureCount * 20), 0, 100);
180
- const freshnessScore = clamp(
181
- 100 - (baseSignals.intelligenceFailureCount * 15) + deterministicOffset(`${writerModel.id}:freshness`, 2),
182
- 0,
183
- 100
184
- );
185
-
186
- const weightedCompositeScore = (
187
- (qualityScore * Number(writerWeights.quality || 0))
188
- + (efficiencyScore * Number(writerWeights.efficiency || 0))
189
- + (reliabilityScore * Number(writerWeights.reliability || 0))
190
- + (freshnessScore * Number(writerWeights.freshness || 0))
191
- ) / 100;
192
-
193
- return {
194
- scenarioId: scenario.id,
195
- scenarioCategory: scenario.category,
196
- scoreBreakdown: {
197
- quality: roundToTwo(qualityScore),
198
- efficiency: roundToTwo(efficiencyScore),
199
- reliability: roundToTwo(reliabilityScore),
200
- freshness: roundToTwo(freshnessScore),
201
- },
202
- compositeScore: roundToTwo(weightedCompositeScore),
203
- top1AccuracyMet: baseSignals.top1AccuracyMet,
204
- manualCorrectionMet: baseSignals.manualCorrectionMet,
205
- };
206
- }
207
-
208
- function evaluateJudgeForScenario(writerScenarioRun, writerToken, judgeModel, judgeLaneConfig, blindReviewMode) {
209
- const judgeOffset = deterministicOffset(`${judgeModel.id}:${writerScenarioRun.scenarioId}:${writerToken}`, 2);
210
- const judgeCompositeScore = clamp(writerScenarioRun.compositeScore + judgeOffset, 0, 100);
211
- const minimumCompositeScore = Number(judgeLaneConfig.minimumCompositeScore || 75);
212
- const leniencyWindow = Number(judgeLaneConfig.leniencyWindow || 0);
213
-
214
- const meetsScoreThreshold = judgeCompositeScore >= (minimumCompositeScore - leniencyWindow);
215
- const meetsCoreSignals = writerScenarioRun.top1AccuracyMet && writerScenarioRun.manualCorrectionMet;
216
- const verdict = (meetsScoreThreshold && meetsCoreSignals) ? 'pass' : 'needs-improvement';
217
-
218
- return {
219
- scenarioId: writerScenarioRun.scenarioId,
220
- scenarioCategory: writerScenarioRun.scenarioCategory,
221
- writerToken,
222
- writerModelId: blindReviewMode ? null : writerToken,
223
- judgeModelId: judgeModel.id,
224
- blindPairId: `${writerScenarioRun.scenarioId}:${writerToken}:${judgeModel.id}`,
225
- writerCompositeScore: writerScenarioRun.compositeScore,
226
- judgeCompositeScore: roundToTwo(judgeCompositeScore),
227
- scoreThreshold: minimumCompositeScore,
228
- leniencyWindow,
229
- meetsScoreThreshold,
230
- meetsCoreSignals,
231
- verdict,
232
- };
233
- }
234
-
235
- function summarizeExecutions(executions) {
236
- return executions.map((executionResult) => ({
237
- scriptPath: executionResult.scriptPath,
238
- exitCode: executionResult.exitCode,
239
- parseError: executionResult.parseError,
240
- reportName: executionResult.parsedReport?.reportName || executionResult.parsedReport?.gateName || null,
241
- passed: typeof executionResult.parsedReport?.passed === 'boolean'
242
- ? executionResult.parsedReport.passed
243
- : null,
244
- }));
245
- }
246
-
247
- function buildWriterLaneRuns(writerModels, scenarios, baseSignals, writerLaneConfig) {
248
- return writerModels.map((writerModel, writerIndex) => {
249
- const writerToken = `W${writerIndex + 1}`;
250
- const scenarioRuns = scenarios.map((scenario) => buildWriterScenarioRun(
251
- writerModel,
252
- scenario,
253
- baseSignals,
254
- writerLaneConfig.weights || {},
255
- writerLaneConfig.scenarioMultipliers || {}
256
- ));
257
-
258
- const averageCompositeScore = scenarioRuns.length === 0
259
- ? 0
260
- : roundToTwo(scenarioRuns.reduce((sum, scenarioRun) => sum + scenarioRun.compositeScore, 0) / scenarioRuns.length);
261
-
262
- return {
263
- writerToken,
264
- writerModel,
265
- averageCompositeScore,
266
- scenarioRuns,
267
- };
268
- });
269
- }
270
-
271
- function buildJudgeLaneRuns(writerLaneRuns, judgeModels, judgeLaneConfig, blindReviewMode) {
272
- const matrixRows = [];
273
-
274
- for (const writerLaneRun of writerLaneRuns) {
275
- for (const writerScenarioRun of writerLaneRun.scenarioRuns) {
276
- for (const judgeModel of judgeModels) {
277
- matrixRows.push(
278
- evaluateJudgeForScenario(writerScenarioRun, writerLaneRun.writerToken, judgeModel, judgeLaneConfig, blindReviewMode)
279
- );
280
- }
281
- }
282
- }
283
-
284
- return matrixRows;
285
- }
286
-
287
- async function runWriterJudgeMatrix() {
288
- const writerJudgeConfig = readJsonOrNull(CONFIG_PATH) || buildDefaultConfig();
289
- const reproducibilityProfile = readJsonOrNull(REPRO_PROFILE_PATH) || { scenarios: [] };
290
- const thresholdConfiguration = readJsonOrNull(THRESHOLD_PATH) || {};
291
-
292
- const detectionBenchmarkExecution = runJsonScript('scripts/detection-benchmark.mjs');
293
- const tokenBenchmarkExecution = runJsonScript('scripts/token-optimization-benchmark.mjs', ['--stdout-only']);
294
- const benchmarkGateExecution = runJsonScript('scripts/benchmark-gate.mjs');
295
- const benchmarkIntelligenceExecution = runJsonScript('scripts/benchmark-intelligence.mjs');
296
-
297
- const executionSummaries = summarizeExecutions([
298
- detectionBenchmarkExecution,
299
- tokenBenchmarkExecution,
300
- benchmarkGateExecution,
301
- benchmarkIntelligenceExecution,
302
- ]);
303
-
304
- const executionFailureCount = executionSummaries.filter((executionSummary) => executionSummary.parseError).length;
305
- const scenarios = loadScenarios(reproducibilityProfile);
306
-
307
- const baseSignals = buildBaseSignals(
308
- detectionBenchmarkExecution.parsedReport,
309
- tokenBenchmarkExecution.parsedReport,
310
- benchmarkGateExecution.parsedReport,
311
- benchmarkIntelligenceExecution.parsedReport,
312
- thresholdConfiguration
313
- );
314
-
315
- const writerModels = Array.isArray(writerJudgeConfig?.writerLane?.models) && writerJudgeConfig.writerLane.models.length > 0
316
- ? writerJudgeConfig.writerLane.models
317
- : buildDefaultConfig().writerLane.models;
318
-
319
- const judgeModels = Array.isArray(writerJudgeConfig?.judgeLane?.models) && writerJudgeConfig.judgeLane.models.length > 0
320
- ? writerJudgeConfig.judgeLane.models
321
- : buildDefaultConfig().judgeLane.models;
322
-
323
- const writerLaneRuns = buildWriterLaneRuns(
324
- writerModels,
325
- scenarios,
326
- baseSignals,
327
- writerJudgeConfig.writerLane || buildDefaultConfig().writerLane
328
- );
329
-
330
- const comparisonMatrix = buildJudgeLaneRuns(
331
- writerLaneRuns,
332
- judgeModels,
333
- writerJudgeConfig.judgeLane || buildDefaultConfig().judgeLane,
334
- writerJudgeConfig.blindReviewMode !== false
335
- );
336
-
337
- const passCount = comparisonMatrix.filter((matrixRow) => matrixRow.verdict === 'pass').length;
338
- const passRatePercent = comparisonMatrix.length === 0
339
- ? 0
340
- : roundToTwo((passCount / comparisonMatrix.length) * 100);
341
-
342
- const writerJudgeReport = {
343
- generatedAt: new Date().toISOString(),
344
- reportName: 'benchmark-writer-judge-matrix',
345
- phase: 'v2.5.1',
346
- passed: executionFailureCount === 0,
347
- failureCount: executionFailureCount,
348
- methodology: {
349
- blindReviewMode: writerJudgeConfig.blindReviewMode !== false,
350
- writerLaneModelCount: writerModels.length,
351
- judgeLaneModelCount: judgeModels.length,
352
- scenarioCount: scenarios.length,
353
- writerWeights: writerJudgeConfig?.writerLane?.weights || null,
354
- judgeWeights: writerJudgeConfig?.judgeLane?.weights || null,
355
- },
356
- coreSignals: baseSignals,
357
- writerDirectory: writerLaneRuns.map((writerLaneRun) => ({
358
- writerToken: writerLaneRun.writerToken,
359
- writerModel: writerLaneRun.writerModel,
360
- averageCompositeScore: writerLaneRun.averageCompositeScore,
361
- })),
362
- comparisonMatrix,
363
- summary: {
364
- passCount,
365
- failCount: comparisonMatrix.length - passCount,
366
- passRatePercent,
367
- },
368
- executions: executionSummaries,
369
- };
370
-
371
- if (!isStdoutOnlyMode) {
372
- await fs.writeFile(OUTPUT_PATH, JSON.stringify(writerJudgeReport, null, 2) + '\n', 'utf8');
373
- }
374
-
375
- console.log(JSON.stringify(writerJudgeReport, null, 2));
376
- process.exit(writerJudgeReport.passed ? 0 : 1);
377
- }
378
-
379
- runWriterJudgeMatrix();