@ryuenn3123/agentic-senior-core 4.4.0 → 5.2.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 (201) hide show
  1. package/.agents/plugins/agentic-senior-core/plugin.json +3 -0
  2. package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
  3. package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
  4. package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
  5. package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
  6. package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
  7. package/.agents/rules/agentic-senior-core.md +131 -0
  8. package/.claude-plugin/marketplace.json +17 -0
  9. package/.claude-plugin/plugin.json +17 -0
  10. package/.clinerules/agentic-senior-core.md +94 -0
  11. package/.codex-plugin/plugin.json +24 -0
  12. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  13. package/.devin-plugin/plugin.json +13 -0
  14. package/.github/copilot-instructions.md +94 -0
  15. package/.github/plugin/marketplace.json +20 -0
  16. package/.github/plugin/plugin.json +16 -0
  17. package/.kiro/steering/agentic-senior-core.md +94 -0
  18. package/.openclaw/skills/asc/SKILL.md +23 -0
  19. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  20. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  21. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  22. package/.windsurf/rules/agentic-senior-core.md +94 -0
  23. package/AGENTS.md +126 -127
  24. package/CONTRIBUTING.md +93 -63
  25. package/README.md +190 -110
  26. package/__init__.py +61 -0
  27. package/bin/agentic-senior-core.js +42 -41
  28. package/commands/asc-audit.md +1 -0
  29. package/commands/asc-audit.toml +2 -0
  30. package/commands/asc-help.md +9 -0
  31. package/commands/asc-help.toml +2 -0
  32. package/commands/asc-refactor.md +1 -0
  33. package/commands/asc-refactor.toml +2 -0
  34. package/commands/asc-review.md +1 -0
  35. package/commands/asc-review.toml +2 -0
  36. package/gemini-extension.json +10 -0
  37. package/hooks/copilot-hooks.json +21 -0
  38. package/hooks/hooks.json +31 -0
  39. package/hooks/session-start.js +36 -0
  40. package/hooks/subagent-start.js +38 -0
  41. package/lib/cli/commands/adapter.mjs +109 -0
  42. package/lib/cli/commands/clean.mjs +63 -0
  43. package/lib/cli/commands/status.mjs +94 -0
  44. package/package.json +43 -60
  45. package/plugin.yaml +16 -0
  46. package/scripts/uninstall.js +38 -0
  47. package/skills/asc/SKILL.md +16 -0
  48. package/skills/asc-audit/SKILL.md +28 -0
  49. package/skills/asc-refactor/SKILL.md +35 -0
  50. package/skills/asc-review/SKILL.md +54 -0
  51. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  52. package/.agent-context/prompts/bootstrap-design.md +0 -63
  53. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  54. package/.agent-context/prompts/init-project.md +0 -60
  55. package/.agent-context/prompts/refactor.md +0 -38
  56. package/.agent-context/prompts/review-code.md +0 -31
  57. package/.agent-context/review-checklists/architecture-review.md +0 -57
  58. package/.agent-context/review-checklists/pr-checklist.md +0 -134
  59. package/.agent-context/rules/api-docs.md +0 -24
  60. package/.agent-context/rules/api-versioning.md +0 -16
  61. package/.agent-context/rules/architecture.md +0 -38
  62. package/.agent-context/rules/background-jobs.md +0 -17
  63. package/.agent-context/rules/config-and-flags.md +0 -16
  64. package/.agent-context/rules/database-design.md +0 -18
  65. package/.agent-context/rules/docker-runtime.md +0 -17
  66. package/.agent-context/rules/error-handling.md +0 -16
  67. package/.agent-context/rules/event-driven.md +0 -16
  68. package/.agent-context/rules/frontend-architecture.md +0 -54
  69. package/.agent-context/rules/microservices.md +0 -16
  70. package/.agent-context/rules/migrations.md +0 -16
  71. package/.agent-context/rules/observability.md +0 -16
  72. package/.agent-context/rules/performance.md +0 -16
  73. package/.agent-context/rules/realtime.md +0 -16
  74. package/.agent-context/rules/resilience.md +0 -18
  75. package/.agent-context/rules/security.md +0 -18
  76. package/.agent-context/rules/testing.md +0 -16
  77. package/.agent-context/state/README.md +0 -25
  78. package/.agent-context/state/architecture-map.md +0 -40
  79. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  80. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  81. package/.agent-context/state/benchmark-thresholds.json +0 -10
  82. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  83. package/.agent-context/state/dependency-map.md +0 -41
  84. package/.agent-context/state/memory-adapter-contract.json +0 -52
  85. package/.agent-context/state/memory-schema-v1.json +0 -88
  86. package/GEMINI.md +0 -1
  87. package/benchmarks/README.md +0 -60
  88. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  89. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  90. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  91. package/lib/cli/adaptive-context/catalog.mjs +0 -394
  92. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  93. package/lib/cli/adaptive-context/implications.mjs +0 -44
  94. package/lib/cli/adaptive-context.mjs +0 -151
  95. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  96. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  97. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  98. package/lib/cli/backup.mjs +0 -210
  99. package/lib/cli/commands/context.mjs +0 -140
  100. package/lib/cli/commands/init/project-context.mjs +0 -60
  101. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  102. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  103. package/lib/cli/commands/init.mjs +0 -654
  104. package/lib/cli/commands/launch.mjs +0 -76
  105. package/lib/cli/commands/optimize.mjs +0 -284
  106. package/lib/cli/commands/rollback.mjs +0 -64
  107. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  108. package/lib/cli/commands/upgrade.mjs +0 -451
  109. package/lib/cli/compiler.mjs +0 -187
  110. package/lib/cli/constants.mjs +0 -136
  111. package/lib/cli/detector/constants.mjs +0 -135
  112. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  113. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  114. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  115. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  116. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  117. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  118. package/lib/cli/detector/design-evidence.mjs +0 -25
  119. package/lib/cli/detector/stack-detection.mjs +0 -243
  120. package/lib/cli/detector/ui-signals.mjs +0 -150
  121. package/lib/cli/detector/workspace-scan.mjs +0 -177
  122. package/lib/cli/detector.mjs +0 -23
  123. package/lib/cli/init-detection-flow.mjs +0 -48
  124. package/lib/cli/init-options.mjs +0 -237
  125. package/lib/cli/init-selection.mjs +0 -29
  126. package/lib/cli/memory-continuity.mjs +0 -537
  127. package/lib/cli/preflight.mjs +0 -76
  128. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  129. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  130. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  131. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  132. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  133. package/lib/cli/project-scaffolder.mjs +0 -29
  134. package/lib/cli/rollback.mjs +0 -66
  135. package/lib/cli/token-optimization.mjs +0 -401
  136. package/lib/cli/utils/filesystem.mjs +0 -81
  137. package/lib/cli/utils/managed-surface.mjs +0 -280
  138. package/lib/cli/utils/prompting.mjs +0 -44
  139. package/lib/cli/utils.mjs +0 -479
  140. package/mcp.json +0 -134
  141. package/scripts/adaptive-context/fixtures.mjs +0 -183
  142. package/scripts/adaptive-context-benchmark.mjs +0 -9
  143. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  144. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  145. package/scripts/benchmark-gate.mjs +0 -121
  146. package/scripts/benchmark-intelligence.mjs +0 -33
  147. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  148. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  149. package/scripts/bump-version.mjs +0 -103
  150. package/scripts/clean-local-artifacts.mjs +0 -78
  151. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  152. package/scripts/context-triggered-audit.mjs +0 -391
  153. package/scripts/detection-benchmark.mjs +0 -127
  154. package/scripts/docs-quality-drift-report.mjs +0 -358
  155. package/scripts/documentation-boundary-audit.mjs +0 -305
  156. package/scripts/explain-on-demand-audit.mjs +0 -427
  157. package/scripts/forbidden-content-check.mjs +0 -123
  158. package/scripts/frontend-usability-audit.mjs +0 -243
  159. package/scripts/generate-sbom.mjs +0 -61
  160. package/scripts/governance-weekly-report.mjs +0 -466
  161. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  162. package/scripts/llm-judge/constants.mjs +0 -66
  163. package/scripts/llm-judge/diff-collection.mjs +0 -74
  164. package/scripts/llm-judge/prompting.mjs +0 -78
  165. package/scripts/llm-judge/providers.mjs +0 -111
  166. package/scripts/llm-judge/verdict.mjs +0 -134
  167. package/scripts/llm-judge.mjs +0 -200
  168. package/scripts/memory-continuity-benchmark.mjs +0 -322
  169. package/scripts/quality-trend-report.mjs +0 -289
  170. package/scripts/release-gate/audit-checks.mjs +0 -441
  171. package/scripts/release-gate/constants.mjs +0 -53
  172. package/scripts/release-gate/runtime.mjs +0 -63
  173. package/scripts/release-gate/static-checks.mjs +0 -182
  174. package/scripts/release-gate.mjs +0 -42
  175. package/scripts/rules-guardian-audit.mjs +0 -580
  176. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  177. package/scripts/sync-thin-adapters.mjs +0 -72
  178. package/scripts/token-optimization-benchmark.mjs +0 -252
  179. package/scripts/ui-design-judge/constants.mjs +0 -13
  180. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  181. package/scripts/ui-design-judge/git-input.mjs +0 -134
  182. package/scripts/ui-design-judge/prompting.mjs +0 -52
  183. package/scripts/ui-design-judge/providers.mjs +0 -102
  184. package/scripts/ui-design-judge/reporting.mjs +0 -183
  185. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  186. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  187. package/scripts/ui-design-judge.mjs +0 -319
  188. package/scripts/ui-rubric-calibration.mjs +0 -35
  189. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  190. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  191. package/scripts/validate/audits/file-size.mjs +0 -158
  192. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  193. package/scripts/validate/audits/release-bundle.mjs +0 -135
  194. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  195. package/scripts/validate/config.mjs +0 -501
  196. package/scripts/validate/coverage-checks.mjs +0 -446
  197. package/scripts/validate/file-structure.mjs +0 -158
  198. package/scripts/validate/markdown-content.mjs +0 -109
  199. package/scripts/validate/project-metadata.mjs +0 -166
  200. package/scripts/validate/utils.mjs +0 -52
  201. package/scripts/validate.mjs +0 -267
@@ -1,319 +0,0 @@
1
- #!/usr/bin/env node
2
- // @ts-check
3
-
4
- /**
5
- * ui-design-judge.mjs
6
- *
7
- * Advisory-default UI design contract judge.
8
- *
9
- * Repo-internal workflow audit; no user-facing runtime modes.
10
- * Stays advisory when no provider is configured or no auto-fail signal is found.
11
- * reviewRubric.genericityAutoFail escalates named drift signals and forbidden
12
- * patterns into blocking findings and blocking required actions when provider
13
- * evidence is available.
14
- *
15
- * Validation anchors for repo governance:
16
- * - Do not reward generic SaaS defaults or popular template patterns.
17
- * - UI design judge only evaluates changed UI surfaces.
18
- * - Structured design execution summary was supplied to semantic review.
19
- * - designExecutionSignalCount
20
- * - designExecutionPolicy
21
- * - designExecutionHandoff
22
- * - handoffReady
23
- * - structuredInspectionAvailable
24
- */
25
-
26
- import { collectChangedFiles, collectPullRequestDiff, isUiRelevantFilePath } from './ui-design-judge/git-input.mjs';
27
- import { buildSystemPrompt, buildUserMessage } from './ui-design-judge/prompting.mjs';
28
- import { selectAvailableProvider } from './ui-design-judge/providers.mjs';
29
- import { calibrateGenericityAssessment } from './ui-design-judge/rubric-calibration.mjs';
30
- import {
31
- buildReport,
32
- emitMachineReadableReport,
33
- extractVerdictObject,
34
- normalizeFindings,
35
- normalizeGenericityAssessment,
36
- normalizeRubricBreakdown,
37
- } from './ui-design-judge/reporting.mjs';
38
- import { loadDesignGuide, loadDesignIntent, summarizeDesignExecutionPolicy, summarizeReviewRubric } from './ui-design-judge/design-execution-summary.mjs';
39
-
40
- function applyGenericityAutoFail({
41
- reviewRubricSummary,
42
- calibration,
43
- findings,
44
- notes,
45
- }) {
46
- const autoFailEnabled = reviewRubricSummary?.genericityAutoFail === true;
47
- const namedGenericityDetected = Array.isArray(calibration?.matchedGenericitySignals)
48
- && calibration.matchedGenericitySignals.length > 0;
49
- const forbiddenPatternDetected = Array.isArray(calibration?.matchedForbiddenPatterns)
50
- && calibration.matchedForbiddenPatterns.length > 0;
51
- const shouldAutoFail = autoFailEnabled
52
- && calibration?.calibratedStatus === 'generic'
53
- && (namedGenericityDetected || forbiddenPatternDetected);
54
-
55
- if (!shouldAutoFail) {
56
- return {
57
- findings,
58
- notes,
59
- autoFailTriggered: false,
60
- };
61
- }
62
-
63
- const normalizedFindings = Array.isArray(findings) ? findings.map((finding) => ({ ...finding })) : [];
64
- const updatedFindings = normalizedFindings.length > 0
65
- ? normalizedFindings.map((finding) => ({
66
- ...finding,
67
- blockingRecommended: true,
68
- }))
69
- : [
70
- {
71
- area: 'design-contract',
72
- severity: 'high',
73
- problem: 'The UI matches named genericity drift signals that the contract marks as auto-fail.',
74
- evidence: `Matched signals: ${[...(calibration.matchedGenericitySignals || []), ...(calibration.matchedForbiddenPatterns || [])].join(', ')}`,
75
- requiredAction: 'Rebuild the affected UI surfaces from the contract and remove the named generic patterns instead of polishing them.',
76
- blockingRecommended: true,
77
- },
78
- ];
79
-
80
- return {
81
- findings: updatedFindings,
82
- notes: [
83
- ...(Array.isArray(notes) ? notes : []),
84
- 'reviewRubric.genericityAutoFail triggered because named genericity drift signals or forbidden patterns were detected.',
85
- ],
86
- autoFailTriggered: true,
87
- };
88
- }
89
-
90
- async function main() {
91
- const changedFiles = collectChangedFiles();
92
- const changedUiFiles = changedFiles.filter(isUiRelevantFilePath);
93
- const rawDiff = collectPullRequestDiff();
94
- const designIntentContent = loadDesignIntent();
95
- const designGuideContent = loadDesignGuide();
96
-
97
- if (!designGuideContent.trim()) {
98
- emitMachineReadableReport(buildReport({
99
- skipped: true,
100
- skipReason: 'Design guide is missing or unreadable. Skipping UI design judge.',
101
- contractPresent: false,
102
- notes: ['docs/DESIGN.md is required for contract-aware UI judging.'],
103
- }));
104
- return;
105
- }
106
-
107
- if (changedUiFiles.length === 0) {
108
- emitMachineReadableReport(buildReport({
109
- skipped: true,
110
- skipReason: 'No UI-relevant changed files detected.',
111
- contractPresent: true,
112
- summary: {
113
- changedUiFileCount: 0,
114
- alignmentScore: null,
115
- driftCount: 0,
116
- blockingCandidateCount: 0,
117
- designExecutionSignalCount: 0,
118
- genericityStatus: 'unclear',
119
- },
120
- notes: ['UI design judge only evaluates changed UI surfaces.'],
121
- }));
122
- return;
123
- }
124
-
125
- const designExecutionSummary = summarizeDesignExecutionPolicy(designIntentContent || {});
126
- const reviewRubricSummary = summarizeReviewRubric(designIntentContent || {});
127
-
128
- const systemPrompt = buildSystemPrompt();
129
- const userMessage = buildUserMessage(
130
- designIntentContent,
131
- designGuideContent,
132
- rawDiff,
133
- changedUiFiles,
134
- designExecutionSummary
135
- );
136
-
137
- const selectedProvider = selectAvailableProvider();
138
- if (!selectedProvider) {
139
- const calibration = calibrateGenericityAssessment({
140
- reviewRubricSummary,
141
- designExecutionSummary,
142
- genericityAssessment: { status: 'unclear', reason: 'No provider review was run.' },
143
- rubricBreakdown: [],
144
- findings: [],
145
- notes: [],
146
- tasteVsFailureSeparated: null,
147
- });
148
-
149
- emitMachineReadableReport(buildReport({
150
- provider: 'none',
151
- contractPresent: true,
152
- summary: {
153
- changedUiFileCount: changedUiFiles.length,
154
- alignmentScore: null,
155
- driftCount: 0,
156
- blockingCandidateCount: 0,
157
- designExecutionSignalCount: designExecutionSummary.enabledCapabilities.length,
158
- structuredInspectionAvailable: designExecutionSummary.structuredInspectionAvailable,
159
- genericityStatus: calibration.calibratedStatus,
160
- },
161
- designExecution: designExecutionSummary,
162
- rubric: {
163
- expectedDimensions: reviewRubricSummary.dimensions.map((dimension) => dimension.key),
164
- breakdown: [],
165
- genericityAssessment: {
166
- status: 'unclear',
167
- reason: 'No provider review was run.',
168
- },
169
- tasteVsFailureSeparated: null,
170
- calibration,
171
- },
172
- semanticJudge: {
173
- attempted: false,
174
- skipped: true,
175
- skipReason: 'no-provider-configured',
176
- },
177
- notes: [
178
- 'No LLM provider configured. UI design judge skipped provider review and stayed advisory.',
179
- ...designExecutionSummary.notes,
180
- ],
181
- }));
182
- return;
183
- }
184
-
185
- let rawJudgeResponse;
186
- try {
187
- rawJudgeResponse = await selectedProvider.invokeProvider(systemPrompt, userMessage);
188
- } catch (providerError) {
189
- const calibration = calibrateGenericityAssessment({
190
- reviewRubricSummary,
191
- designExecutionSummary,
192
- genericityAssessment: { status: 'unclear', reason: 'Provider review failed before rubric scoring completed.' },
193
- rubricBreakdown: [],
194
- findings: [],
195
- notes: [],
196
- tasteVsFailureSeparated: null,
197
- });
198
-
199
- const providerErrorMessage = providerError instanceof Error
200
- ? providerError.message
201
- : 'Unknown provider error';
202
-
203
- emitMachineReadableReport(buildReport({
204
- provider: selectedProvider.providerName,
205
- contractPresent: true,
206
- providerError: true,
207
- summary: {
208
- changedUiFileCount: changedUiFiles.length,
209
- alignmentScore: null,
210
- driftCount: 0,
211
- blockingCandidateCount: 0,
212
- designExecutionSignalCount: designExecutionSummary.enabledCapabilities.length,
213
- structuredInspectionAvailable: designExecutionSummary.structuredInspectionAvailable,
214
- genericityStatus: calibration.calibratedStatus,
215
- },
216
- designExecution: designExecutionSummary,
217
- rubric: {
218
- expectedDimensions: reviewRubricSummary.dimensions.map((dimension) => dimension.key),
219
- breakdown: [],
220
- genericityAssessment: {
221
- status: 'unclear',
222
- reason: 'Provider review failed before rubric scoring completed.',
223
- },
224
- tasteVsFailureSeparated: null,
225
- calibration,
226
- },
227
- semanticJudge: {
228
- attempted: true,
229
- skipped: false,
230
- skipReason: null,
231
- },
232
- notes: [`Provider call failed: ${providerErrorMessage}`, ...designExecutionSummary.notes],
233
- passed: true,
234
- }));
235
- return;
236
- }
237
-
238
- const { verdict, malformed } = extractVerdictObject(rawJudgeResponse);
239
- const findings = normalizeFindings(verdict?.findings);
240
- const rubricBreakdown = normalizeRubricBreakdown(
241
- verdict?.rubricBreakdown,
242
- reviewRubricSummary.dimensions.map((dimension) => dimension.key)
243
- );
244
- const genericityAssessment = normalizeGenericityAssessment(verdict?.genericityAssessment);
245
- const tasteVsFailureSeparated = typeof verdict?.tasteVsFailureSeparated === 'boolean'
246
- ? verdict.tasteVsFailureSeparated
247
- : null;
248
- const alignmentScore = typeof verdict?.alignmentScore === 'number' ? verdict.alignmentScore : null;
249
- const notes = Array.isArray(verdict?.notes)
250
- ? verdict.notes.map((note) => String(note))
251
- : [];
252
- const calibration = calibrateGenericityAssessment({
253
- reviewRubricSummary,
254
- designExecutionSummary,
255
- genericityAssessment,
256
- rubricBreakdown,
257
- findings,
258
- notes,
259
- tasteVsFailureSeparated,
260
- });
261
- const autoFailResolution = applyGenericityAutoFail({
262
- reviewRubricSummary,
263
- calibration,
264
- findings,
265
- notes,
266
- });
267
- const resolvedFindings = autoFailResolution.findings;
268
- const resolvedNotes = autoFailResolution.notes;
269
- const blockingCandidateCount = resolvedFindings.filter((finding) => finding.blockingRecommended || finding.severity === 'high').length;
270
-
271
- emitMachineReadableReport(buildReport({
272
- provider: selectedProvider.providerName,
273
- contractPresent: true,
274
- mode: autoFailResolution.autoFailTriggered ? 'blocking-recommended' : 'advisory',
275
- advisoryOnly: !autoFailResolution.autoFailTriggered,
276
- passed: !autoFailResolution.autoFailTriggered,
277
- autoFailTriggered: autoFailResolution.autoFailTriggered,
278
- malformedVerdict: malformed,
279
- summary: {
280
- changedUiFileCount: changedUiFiles.length,
281
- alignmentScore,
282
- driftCount: resolvedFindings.length,
283
- blockingCandidateCount,
284
- designExecutionSignalCount: designExecutionSummary.enabledCapabilities.length,
285
- structuredInspectionAvailable: designExecutionSummary.structuredInspectionAvailable,
286
- genericityStatus: calibration.calibratedStatus,
287
- },
288
- designExecution: designExecutionSummary,
289
- rubric: {
290
- expectedDimensions: reviewRubricSummary.dimensions.map((dimension) => dimension.key),
291
- breakdown: rubricBreakdown,
292
- genericityAssessment,
293
- tasteVsFailureSeparated,
294
- calibration,
295
- },
296
- semanticJudge: {
297
- attempted: true,
298
- skipped: false,
299
- skipReason: null,
300
- },
301
- findings: resolvedFindings,
302
- notes: malformed
303
- ? ['LLM response was malformed. Advisory mode kept the audit non-blocking.', ...designExecutionSummary.notes]
304
- : [...resolvedNotes, ...calibration.notes, ...designExecutionSummary.notes],
305
- }));
306
- }
307
-
308
- main().catch((unexpectedError) => {
309
- const errorMessage = unexpectedError instanceof Error
310
- ? unexpectedError.message
311
- : 'Unknown unexpected error';
312
-
313
- emitMachineReadableReport(buildReport({
314
- provider: 'none',
315
- providerError: true,
316
- passed: true,
317
- notes: [`Unexpected ui-design-judge failure: ${errorMessage}`],
318
- }));
319
- });
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
- // @ts-check
3
-
4
- import { readFileSync } from 'node:fs';
5
- import { dirname, resolve } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- import { buildRubricCalibrationReport } from './ui-design-judge/rubric-calibration.mjs';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
11
- const GOLDSET_PATH = resolve(__dirname, 'ui-design-judge', 'rubric-goldset.json');
12
- const REPORT_NAME = 'ui-rubric-calibration';
13
-
14
- function loadGoldset() {
15
- return JSON.parse(readFileSync(GOLDSET_PATH, 'utf8'));
16
- }
17
-
18
- function main() {
19
- const goldset = loadGoldset();
20
- const report = buildRubricCalibrationReport({
21
- cases: goldset.cases,
22
- reviewRubricSummary: goldset.reviewRubric,
23
- });
24
- report.reportName = REPORT_NAME;
25
- // Keep the report surface explicit so static validation can detect the machine-readable payload contract.
26
- report.accuracyPercent = report.accuracyPercent;
27
-
28
- console.log(JSON.stringify(report, null, 2));
29
-
30
- if (!report.passed) {
31
- process.exitCode = 1;
32
- }
33
- }
34
-
35
- main();
@@ -1,230 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * audit-cache-layer-contract.mjs
4
- *
5
- * Phase 2 cache-layer integrity gate. Validates provider cache metadata,
6
- * fixture segmentation, and the emitted cache simulation JSON without calling
7
- * provider APIs.
8
- *
9
- * Boundary: this audit covers the TECHNICAL contract (provider matrix,
10
- * layer definitions, fixture segmentation, simulation result JSON shape).
11
- * For public-prose hygiene around caching saving figures see
12
- * audit-caching-scope-hygiene.mjs.
13
- */
14
-
15
- import { existsSync, readFileSync } from 'node:fs';
16
- import { dirname, join, resolve } from 'node:path';
17
- import { fileURLToPath } from 'node:url';
18
-
19
- import {
20
- CACHE_LAYER_DEFINITIONS,
21
- CACHE_LAYER_IDS,
22
- validateCacheLayerContract,
23
- } from '../../../benchmarks/token-usage/lib/cache-layer-contract.mjs';
24
- import {
25
- CACHE_MATRIX_VERIFIED_AT,
26
- PROVIDER_CACHE_MATRIX,
27
- listProviderCacheEntries,
28
- } from '../../../benchmarks/token-usage/lib/provider-cache-matrix.mjs';
29
- import {
30
- buildCacheLayeredScenarioPrompts,
31
- loadFixtures,
32
- } from '../../../benchmarks/token-usage/runners/_shared.mjs';
33
-
34
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
35
- const REPOSITORY_ROOT = resolve(dirname(SCRIPT_FILE_PATH), '../../..');
36
- const DEFAULT_RESULT_PATH = join(REPOSITORY_ROOT, 'benchmarks', 'results', 'cache-phase-2-2026-05-16.json');
37
- const ARGS = new Set(process.argv.slice(2));
38
- const JSON_ONLY = ARGS.has('--json');
39
-
40
- const REQUIRED_PROVIDER_KEYS = [
41
- 'provider',
42
- 'sourceUrl',
43
- 'sourceType',
44
- 'verifiedAt',
45
- 'cacheMode',
46
- 'minimumCacheableTokens',
47
- 'costModel',
48
- ];
49
-
50
- function addViolation(violations, kind, detail, context = {}) {
51
- violations.push({ kind, detail, ...context });
52
- }
53
-
54
- function validateProviderMatrix(violations) {
55
- for (const entry of listProviderCacheEntries()) {
56
- for (const key of REQUIRED_PROVIDER_KEYS) {
57
- if (!(key in entry)) {
58
- addViolation(violations, 'provider-metadata.missing-key', `${entry.provider} missing ${key}`, { provider: entry.provider });
59
- }
60
- }
61
-
62
- if (entry.sourceType === 'official-docs') {
63
- if (typeof entry.sourceUrl !== 'string' || !entry.sourceUrl.startsWith('https://')) {
64
- addViolation(violations, 'provider-metadata.invalid-source-url', `${entry.provider} official sourceUrl must be https`, { provider: entry.provider });
65
- }
66
- if (entry.verifiedAt !== CACHE_MATRIX_VERIFIED_AT) {
67
- addViolation(violations, 'provider-metadata.invalid-verified-at', `${entry.provider} verifiedAt must be ${CACHE_MATRIX_VERIFIED_AT}`, { provider: entry.provider });
68
- }
69
- }
70
-
71
- if (entry.provider === 'anthropic') {
72
- const ttlOptions = entry.costModel?.ttlOptions;
73
- if (ttlOptions?.['5m']?.writeMultiplier !== 1.25 || ttlOptions?.['5m']?.readMultiplier !== 0.1) {
74
- addViolation(violations, 'provider-metadata.anthropic-5m-multiplier', 'Anthropic 5m cache multipliers drifted');
75
- }
76
- if (ttlOptions?.['1h']?.writeMultiplier !== 2.0 || ttlOptions?.['1h']?.readMultiplier !== 0.1) {
77
- addViolation(violations, 'provider-metadata.anthropic-1h-multiplier', 'Anthropic 1h cache multipliers drifted');
78
- }
79
- }
80
-
81
- if (['openai', 'gemini'].includes(entry.provider) && entry.costModel?.accurate !== false) {
82
- addViolation(violations, 'provider-metadata.fake-universal-pricing', `${entry.provider} must not claim universal accurate pricing`, { provider: entry.provider });
83
- }
84
- }
85
- }
86
-
87
- function validateLayerDefinitions(violations) {
88
- const definitionIds = Object.keys(CACHE_LAYER_DEFINITIONS);
89
- const uniqueDefinitionIds = new Set(definitionIds);
90
- if (definitionIds.length !== uniqueDefinitionIds.size) {
91
- addViolation(violations, 'layer-definition.duplicate-id', 'Cache layer definition IDs must be unique');
92
- }
93
-
94
- const expectedIds = [
95
- CACHE_LAYER_IDS.STATIC_PREFIX,
96
- CACHE_LAYER_IDS.SEMI_STATIC_CONTEXT,
97
- CACHE_LAYER_IDS.DYNAMIC_SUFFIX,
98
- ];
99
- if (JSON.stringify(definitionIds) !== JSON.stringify(expectedIds)) {
100
- addViolation(violations, 'layer-definition.unexpected-order', `Expected ${expectedIds.join(', ')}, got ${definitionIds.join(', ')}`);
101
- }
102
- }
103
-
104
- function validateFixtureSegmentation(violations) {
105
- const fixtures = loadFixtures();
106
- let auditedScenarioCount = 0;
107
- for (const fixture of fixtures) {
108
- const layered = buildCacheLayeredScenarioPrompts(fixture);
109
- const scenarios = [
110
- { name: 'always_included', contract: layered.alwaysIncluded },
111
- { name: 'with_loaded_rules', contract: layered.withLoadedRules },
112
- ];
113
-
114
- for (const scenario of scenarios) {
115
- auditedScenarioCount += 1;
116
- try {
117
- validateCacheLayerContract(scenario.contract);
118
- } catch (error) {
119
- addViolation(violations, 'fixture-segmentation.invalid-contract', error.message, {
120
- fixture_id: fixture.id,
121
- scenario: scenario.name,
122
- });
123
- }
124
-
125
- const layerIds = scenario.contract.layers.map((layer) => layer.id);
126
- if (new Set(layerIds).size !== layerIds.length) {
127
- addViolation(violations, 'fixture-segmentation.duplicate-layer-id', 'Fixture contract contains duplicate layer IDs', {
128
- fixture_id: fixture.id,
129
- scenario: scenario.name,
130
- });
131
- }
132
-
133
- for (const layer of [
134
- scenario.contract.layer_1_static_prefix,
135
- scenario.contract.layer_2_semi_static_context,
136
- ]) {
137
- if (layer.content.includes(fixture.user_message)) {
138
- addViolation(violations, 'fixture-segmentation.dynamic-leak', `Fixture user message leaked into ${layer.id}`, {
139
- fixture_id: fixture.id,
140
- scenario: scenario.name,
141
- });
142
- }
143
- }
144
-
145
- if (scenario.contract.layer_3_dynamic_suffix.content.trim().length === 0) {
146
- addViolation(violations, 'fixture-segmentation.missing-dynamic-layer', 'Layer 3 dynamic suffix is empty', {
147
- fixture_id: fixture.id,
148
- scenario: scenario.name,
149
- });
150
- }
151
- }
152
- }
153
- return { fixtureCount: fixtures.length, auditedScenarioCount };
154
- }
155
-
156
- function validateSimulationResultJson(violations, resultPath = DEFAULT_RESULT_PATH) {
157
- if (!existsSync(resultPath)) {
158
- addViolation(violations, 'result-json.missing', `Missing cache simulation result: ${resultPath}`);
159
- return { resultPath, resultCount: 0 };
160
- }
161
-
162
- const parsed = JSON.parse(readFileSync(resultPath, 'utf8'));
163
- if (parsed.report_version !== '2.0.0') {
164
- addViolation(violations, 'result-json.schema-version', `Unexpected report_version ${parsed.report_version}`);
165
- }
166
- if (!Array.isArray(parsed.results) || parsed.results.length === 0) {
167
- addViolation(violations, 'result-json.results-empty', 'results must be a non-empty array');
168
- return { resultPath, resultCount: 0 };
169
- }
170
-
171
- const expectedResultCount = parsed.fixture_count * parsed.provider_count * parsed.scenario_count;
172
- if (parsed.results.length !== expectedResultCount) {
173
- addViolation(violations, 'result-json.result-count', `Expected ${expectedResultCount} rows, got ${parsed.results.length}`);
174
- }
175
-
176
- for (const result of parsed.results) {
177
- if (!result.token_counts || !result.economic_projection) {
178
- addViolation(violations, 'result-json.missing-separation', 'Result must separate token_counts and economic_projection', {
179
- fixture_id: result.fixture_id,
180
- provider: result.provider,
181
- scenario: result.scenario,
182
- });
183
- continue;
184
- }
185
- if (typeof result.token_counts.layer_3_dynamic_suffix !== 'number' || result.token_counts.layer_3_dynamic_suffix <= 0) {
186
- addViolation(violations, 'result-json.missing-layer-3-tokens', 'Layer 3 token count must be present and positive', {
187
- fixture_id: result.fixture_id,
188
- provider: result.provider,
189
- scenario: result.scenario,
190
- });
191
- }
192
- if (result.economic_projection.accurate === true && (!result.source?.sourceUrl || !result.source?.verifiedAt)) {
193
- addViolation(violations, 'result-json.accurate-without-source', 'Accurate projection requires official source metadata', {
194
- fixture_id: result.fixture_id,
195
- provider: result.provider,
196
- scenario: result.scenario,
197
- });
198
- }
199
- if (['openai', 'gemini'].includes(result.provider) && result.economic_projection.first_request_effective_tokens !== null) {
200
- addViolation(violations, 'result-json.fake-openai-gemini-savings', `${result.provider} must not emit exact savings without pricing metadata`, {
201
- fixture_id: result.fixture_id,
202
- scenario: result.scenario,
203
- });
204
- }
205
- }
206
-
207
- return { resultPath, resultCount: parsed.results.length };
208
- }
209
-
210
- export function runCacheLayerContractAudit({ resultPath = DEFAULT_RESULT_PATH } = {}) {
211
- const violations = [];
212
- validateProviderMatrix(violations);
213
- validateLayerDefinitions(violations);
214
- const segmentationStats = validateFixtureSegmentation(violations);
215
- const resultStats = validateSimulationResultJson(violations, resultPath);
216
-
217
- return {
218
- auditName: 'audit-cache-layer-contract',
219
- reportVersion: '1.0.0',
220
- generatedAt: new Date().toISOString(),
221
- providerCount: Object.keys(PROVIDER_CACHE_MATRIX).length,
222
- ...segmentationStats,
223
- ...resultStats,
224
- violationCount: violations.length,
225
- violations,
226
- passed: violations.length === 0,
227
- };
228
- }
229
-
230
-