@ryuenn3123/agentic-senior-core 3.0.17 → 3.0.20

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 (85) hide show
  1. package/.agent-context/prompts/bootstrap-design.md +84 -94
  2. package/.agent-context/prompts/init-project.md +32 -100
  3. package/.agent-context/prompts/refactor.md +22 -44
  4. package/.agent-context/prompts/review-code.md +28 -52
  5. package/.agent-context/review-checklists/architecture-review.md +31 -62
  6. package/.agent-context/review-checklists/pr-checklist.md +74 -108
  7. package/.agent-context/rules/api-docs.md +18 -206
  8. package/.agent-context/rules/architecture.md +40 -207
  9. package/.agent-context/rules/database-design.md +10 -199
  10. package/.agent-context/rules/docker-runtime.md +5 -5
  11. package/.agent-context/rules/efficiency-vs-hype.md +11 -149
  12. package/.agent-context/rules/error-handling.md +9 -231
  13. package/.agent-context/rules/event-driven.md +17 -221
  14. package/.agent-context/rules/frontend-architecture.md +66 -119
  15. package/.agent-context/rules/git-workflow.md +1 -1
  16. package/.agent-context/rules/microservices.md +28 -161
  17. package/.agent-context/rules/naming-conv.md +8 -138
  18. package/.agent-context/rules/performance.md +9 -175
  19. package/.agent-context/rules/realtime.md +11 -44
  20. package/.agent-context/rules/security.md +11 -295
  21. package/.agent-context/rules/testing.md +9 -174
  22. package/.agent-context/state/benchmark-analysis.json +3 -3
  23. package/.agent-context/state/memory-continuity-benchmark.json +1 -1
  24. package/.agent-context/state/onboarding-report.json +71 -11
  25. package/.agents/workflows/init-project.md +7 -24
  26. package/.agents/workflows/refactor.md +7 -24
  27. package/.agents/workflows/review-code.md +7 -24
  28. package/.cursorrules +22 -21
  29. package/.gemini/instructions.md +2 -2
  30. package/.github/copilot-instructions.md +2 -2
  31. package/.instructions.md +112 -213
  32. package/.windsurfrules +22 -21
  33. package/AGENTS.md +4 -4
  34. package/CONTRIBUTING.md +13 -22
  35. package/README.md +6 -20
  36. package/lib/cli/commands/init.mjs +102 -148
  37. package/lib/cli/commands/launch.mjs +3 -3
  38. package/lib/cli/commands/optimize.mjs +14 -4
  39. package/lib/cli/commands/upgrade.mjs +25 -23
  40. package/lib/cli/compiler.mjs +96 -62
  41. package/lib/cli/constants.mjs +28 -136
  42. package/lib/cli/detector/design-evidence.mjs +189 -6
  43. package/lib/cli/detector.mjs +6 -7
  44. package/lib/cli/init-detection-flow.mjs +10 -93
  45. package/lib/cli/init-selection.mjs +2 -68
  46. package/lib/cli/project-scaffolder/constants.mjs +1 -1
  47. package/lib/cli/project-scaffolder/design-contract.mjs +438 -335
  48. package/lib/cli/project-scaffolder/discovery.mjs +36 -82
  49. package/lib/cli/project-scaffolder/prompt-builders.mjs +55 -63
  50. package/lib/cli/project-scaffolder/storage.mjs +0 -4
  51. package/lib/cli/token-optimization.mjs +1 -1
  52. package/lib/cli/utils.mjs +75 -9
  53. package/package.json +2 -2
  54. package/scripts/detection-benchmark.mjs +4 -15
  55. package/scripts/documentation-boundary-audit.mjs +9 -9
  56. package/scripts/explain-on-demand-audit.mjs +11 -11
  57. package/scripts/forbidden-content-check.mjs +9 -9
  58. package/scripts/frontend-usability-audit.mjs +57 -36
  59. package/scripts/llm-judge.mjs +1 -1
  60. package/scripts/mcp-server/constants.mjs +60 -0
  61. package/scripts/mcp-server/tool-registry.mjs +149 -0
  62. package/scripts/mcp-server/tools.mjs +446 -0
  63. package/scripts/mcp-server.mjs +23 -661
  64. package/scripts/release-gate/audit-checks.mjs +426 -0
  65. package/scripts/release-gate/constants.mjs +53 -0
  66. package/scripts/release-gate/runtime.mjs +63 -0
  67. package/scripts/release-gate/static-checks.mjs +182 -0
  68. package/scripts/release-gate.mjs +13 -794
  69. package/scripts/rules-guardian-audit.mjs +14 -13
  70. package/scripts/single-source-lazy-loading-audit.mjs +3 -3
  71. package/scripts/sync-thin-adapters.mjs +5 -5
  72. package/scripts/ui-design-judge/constants.mjs +24 -0
  73. package/scripts/ui-design-judge/design-execution-summary.mjs +259 -0
  74. package/scripts/ui-design-judge/git-input.mjs +131 -0
  75. package/scripts/ui-design-judge/prompting.mjs +73 -0
  76. package/scripts/ui-design-judge/providers.mjs +102 -0
  77. package/scripts/ui-design-judge/reporting.mjs +182 -0
  78. package/scripts/ui-design-judge/rubric-calibration.mjs +214 -0
  79. package/scripts/ui-design-judge/rubric-goldset.json +188 -0
  80. package/scripts/ui-design-judge.mjs +166 -771
  81. package/scripts/ui-rubric-calibration.mjs +35 -0
  82. package/scripts/validate/config.mjs +198 -55
  83. package/scripts/validate/coverage-checks.mjs +32 -7
  84. package/scripts/validate.mjs +8 -4
  85. package/lib/cli/architect.mjs +0 -431
@@ -3,808 +3,27 @@
3
3
  /**
4
4
  * release-gate.mjs
5
5
  *
6
- * Enterprise release gate for V1.8.
6
+ * Operations release gate for V1.8.
7
7
  * Produces machine-readable output for CI and fails fast on missing release evidence.
8
+ *
9
+ * Validation anchors kept here intentionally:
10
+ * - documentation-boundary-hard-rule
11
+ * - documentation-boundary-diagnostics-machine-readable
12
+ * - diagnostics.documentationBoundaryAudit
13
+ * - auto-docs-sync-scope-phase1
14
+ * - auto-docs-sync-rollout-metrics
15
+ * - ui-design-judge-structured-diagnostics
8
16
  */
9
17
 
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import { resolve, dirname } from 'node:path';
12
- import { fileURLToPath } from 'node:url';
13
- import { execFileSync } from 'node:child_process';
14
-
15
- const __filename = fileURLToPath(import.meta.url);
16
- const __dirname = dirname(__filename);
17
- const REPOSITORY_ROOT = resolve(__dirname, '..');
18
-
19
- const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
20
- const FRONTEND_AUDIT_SCRIPT_PATH = 'scripts/frontend-usability-audit.mjs';
21
- const UI_DESIGN_JUDGE_SCRIPT_PATH = 'scripts/ui-design-judge.mjs';
22
- const DOCUMENTATION_BOUNDARY_AUDIT_SCRIPT_PATH = 'scripts/documentation-boundary-audit.mjs';
23
- const CONTEXT_TRIGGERED_AUDIT_SCRIPT_PATH = 'scripts/context-triggered-audit.mjs';
24
- const RULES_GUARDIAN_AUDIT_SCRIPT_PATH = 'scripts/rules-guardian-audit.mjs';
25
- const EXPLAIN_ON_DEMAND_AUDIT_SCRIPT_PATH = 'scripts/explain-on-demand-audit.mjs';
26
- const SINGLE_SOURCE_LAZY_LOADING_AUDIT_SCRIPT_PATH = 'scripts/single-source-lazy-loading-audit.mjs';
27
- const BACKEND_ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
28
- const BACKEND_REVIEW_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
29
- const ARCHITECTURE_REVIEW_CHECKLIST_PATH = '.agent-context/review-checklists/architecture-review.md';
30
- const REFACTOR_PROMPT_PATH = '.agent-context/prompts/refactor.md';
31
- const REQUIRED_BACKEND_ARCHITECTURE_RULE_SNIPPETS = [
32
- 'No clever hacks.',
33
- 'No premature abstraction.',
34
- 'Readability over brevity.',
35
- 'backend and shared core modules',
36
- ];
37
- const REQUIRED_BACKEND_REVIEW_CHECKLIST_SNIPPETS = [
38
- 'No clever hacks in backend and shared core modules',
39
- 'No premature abstraction (base classes/util layers created only after repeated stable patterns)',
40
- 'Readability over brevity for maintainability',
41
- ];
42
- const REQUIRED_REFACTOR_PROMPT_SNIPPETS = [
43
- 'Enforce backend universal principles: no clever hacks, no premature abstraction, readability over brevity.',
44
- 'Prioritize maintainability over compressed one-liners.',
45
- ];
46
- const REQUIRED_ARCHITECTURE_REVIEW_CHECKLIST_SNIPPETS = [
47
- '## Backend Universal Principles',
48
- 'No clever hacks in backend and shared core modules',
49
- 'No premature abstraction',
50
- 'Readability over brevity',
51
- ];
52
- const BENCHMARK_GATE_SCRIPT_PATH = 'scripts/benchmark-gate.mjs';
53
- const AUTO_DOCS_SYNC_SCOPE_PHASE = 'phase-1';
54
- const AUTO_DOCS_SYNC_SCOPE_BOUNDARIES = [
55
- 'public-surface',
56
- 'api-contract',
57
- 'database-structure',
58
- ];
59
-
60
- function readText(relativeFilePath) {
61
- const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
62
- if (!existsSync(absolutePath)) {
63
- return '';
64
- }
65
-
66
- return readFileSync(absolutePath, 'utf8');
67
- }
68
-
69
- function pushResult(results, isPassed, checkName, details) {
70
- results.push({
71
- checkName,
72
- passed: isPassed,
73
- details,
74
- });
75
- }
76
-
77
- function parseMachineReadableReport(rawOutput) {
78
- if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
79
- return null;
80
- }
81
-
82
- try {
83
- return JSON.parse(rawOutput);
84
- } catch {
85
- return null;
86
- }
87
- }
88
-
89
- function runMachineReadableScript(scriptRelativePath, scriptArguments = []) {
90
- try {
91
- const rawOutput = execFileSync('node', [scriptRelativePath, ...scriptArguments], {
92
- cwd: REPOSITORY_ROOT,
93
- encoding: 'utf8',
94
- maxBuffer: 1024 * 1024,
95
- });
96
-
97
- return {
98
- report: parseMachineReadableReport(rawOutput),
99
- executionErrorMessage: null,
100
- };
101
- } catch (scriptExecutionError) {
102
- const rawOutput = scriptExecutionError && typeof scriptExecutionError === 'object' && 'stdout' in scriptExecutionError
103
- ? String(scriptExecutionError.stdout ?? '')
104
- : '';
105
- const parsedReport = parseMachineReadableReport(rawOutput);
106
- const executionErrorMessage = scriptExecutionError instanceof Error
107
- ? scriptExecutionError.message
108
- : 'Unknown execution error';
109
-
110
- return {
111
- report: parsedReport,
112
- executionErrorMessage,
113
- };
114
- }
115
- }
18
+ import { runAuditReleaseChecks } from './release-gate/audit-checks.mjs';
19
+ import { runStaticReleaseChecks } from './release-gate/static-checks.mjs';
116
20
 
117
21
  function runReleaseGate() {
118
22
  const results = [];
119
23
  const diagnostics = {};
120
- const packageJsonPath = 'package.json';
121
- const changelogPath = 'CHANGELOG.md';
122
- const roadmapPath = 'docs/roadmap.md';
123
-
124
- const packageJsonContent = readText(packageJsonPath);
125
- if (!packageJsonContent) {
126
- pushResult(results, false, 'package-json-exists', `Missing ${packageJsonPath}`);
127
- }
128
-
129
- let packageManifest = null;
130
- if (packageJsonContent) {
131
- try {
132
- packageManifest = JSON.parse(packageJsonContent);
133
- pushResult(results, true, 'package-json-parse', 'package.json is valid JSON');
134
- } catch (packageParseError) {
135
- const parseMessage = packageParseError instanceof Error ? packageParseError.message : 'Unknown parse error';
136
- pushResult(results, false, 'package-json-parse', `Cannot parse package.json: ${parseMessage}`);
137
- }
138
- }
139
-
140
- const releaseVersion = packageManifest?.version;
141
- if (!releaseVersion || !VERSION_PATTERN.test(releaseVersion)) {
142
- pushResult(results, false, 'version-semver', `Invalid package version: ${String(releaseVersion)}`);
143
- } else {
144
- pushResult(results, true, 'version-semver', `Version ${releaseVersion} matches x.y.z format`);
145
- }
146
-
147
- const changelogContent = readText(changelogPath);
148
- if (!changelogContent) {
149
- pushResult(results, false, 'changelog-exists', `Missing ${changelogPath}`);
150
- } else if (!releaseVersion) {
151
- pushResult(results, false, 'changelog-version-entry', 'Cannot check changelog because version is invalid');
152
- } else if (!changelogContent.includes(`## ${releaseVersion} - `)) {
153
- pushResult(results, false, 'changelog-version-entry', `Missing release header for ${releaseVersion} in CHANGELOG.md`);
154
- } else {
155
- pushResult(results, true, 'changelog-version-entry', `Found release header for ${releaseVersion}`);
156
- }
157
-
158
- const roadmapContent = readText(roadmapPath);
159
- if (!roadmapContent) {
160
- pushResult(results, false, 'roadmap-exists', `Missing ${roadmapPath}`);
161
- } else if (!roadmapContent.includes('V1.8')) {
162
- pushResult(results, false, 'roadmap-v18', 'Roadmap does not mention V1.8 release track');
163
- } else {
164
- pushResult(results, true, 'roadmap-v18', 'Roadmap includes V1.8 release track');
165
- }
166
-
167
- const requiredEnterpriseFiles = [
168
- '.agent-context/review-checklists/architecture-review.md',
169
- 'docs/v1.8-operations-playbook.md',
170
- '.github/workflows/release-gate.yml',
171
- '.github/workflows/sbom-compliance.yml',
172
- '.github/workflows/governance-weekly-report.yml',
173
- 'scripts/governance-weekly-report.mjs',
174
- ];
175
-
176
- for (const requiredEnterpriseFile of requiredEnterpriseFiles) {
177
- const absoluteRequiredPath = resolve(REPOSITORY_ROOT, requiredEnterpriseFile);
178
- if (!existsSync(absoluteRequiredPath)) {
179
- pushResult(results, false, 'required-enterprise-file', `Missing ${requiredEnterpriseFile}`);
180
- continue;
181
- }
182
-
183
- pushResult(results, true, 'required-enterprise-file', `${requiredEnterpriseFile} is present`);
184
- }
185
-
186
- pushResult(
187
- results,
188
- true,
189
- 'compatibility-manifest-coverage',
190
- 'Skill compatibility manifest gate has been retired in V3 purge mode'
191
- );
192
-
193
- const backendArchitectureRuleContent = readText(BACKEND_ARCHITECTURE_RULE_PATH);
194
- if (!backendArchitectureRuleContent) {
195
- pushResult(results, false, 'backend-universal-principles-rule-exists', `Missing ${BACKEND_ARCHITECTURE_RULE_PATH}`);
196
- } else {
197
- pushResult(results, true, 'backend-universal-principles-rule-exists', `${BACKEND_ARCHITECTURE_RULE_PATH} is present`);
198
-
199
- const missingBackendArchitectureRuleSnippets = REQUIRED_BACKEND_ARCHITECTURE_RULE_SNIPPETS.filter(
200
- (requiredSnippet) => !backendArchitectureRuleContent.includes(requiredSnippet)
201
- );
202
-
203
- if (missingBackendArchitectureRuleSnippets.length === 0) {
204
- pushResult(results, true, 'backend-universal-principles-rule-coverage', 'Backend universal rule snippets are complete');
205
- } else {
206
- pushResult(
207
- results,
208
- false,
209
- 'backend-universal-principles-rule-coverage',
210
- `Missing backend universal rule snippets: ${missingBackendArchitectureRuleSnippets.join(', ')}`
211
- );
212
- }
213
- }
214
-
215
- const backendReviewChecklistContent = readText(BACKEND_REVIEW_CHECKLIST_PATH);
216
- if (!backendReviewChecklistContent) {
217
- pushResult(results, false, 'backend-universal-principles-checklist-exists', `Missing ${BACKEND_REVIEW_CHECKLIST_PATH}`);
218
- } else {
219
- pushResult(results, true, 'backend-universal-principles-checklist-exists', `${BACKEND_REVIEW_CHECKLIST_PATH} is present`);
220
-
221
- const missingBackendChecklistSnippets = REQUIRED_BACKEND_REVIEW_CHECKLIST_SNIPPETS.filter(
222
- (requiredSnippet) => !backendReviewChecklistContent.includes(requiredSnippet)
223
- );
224
-
225
- if (missingBackendChecklistSnippets.length === 0) {
226
- pushResult(results, true, 'backend-universal-principles-checklist-coverage', 'Backend review checklist snippets are complete');
227
- } else {
228
- pushResult(
229
- results,
230
- false,
231
- 'backend-universal-principles-checklist-coverage',
232
- `Missing backend review checklist snippets: ${missingBackendChecklistSnippets.join(', ')}`
233
- );
234
- }
235
- }
236
-
237
- const refactorPromptContent = readText(REFACTOR_PROMPT_PATH);
238
- if (!refactorPromptContent) {
239
- pushResult(results, false, 'backend-universal-principles-refactor-guidance-exists', `Missing ${REFACTOR_PROMPT_PATH}`);
240
- } else {
241
- pushResult(results, true, 'backend-universal-principles-refactor-guidance-exists', `${REFACTOR_PROMPT_PATH} is present`);
242
-
243
- const missingRefactorPromptSnippets = REQUIRED_REFACTOR_PROMPT_SNIPPETS.filter(
244
- (requiredSnippet) => !refactorPromptContent.includes(requiredSnippet)
245
- );
246
-
247
- if (missingRefactorPromptSnippets.length === 0) {
248
- pushResult(results, true, 'backend-universal-principles-refactor-guidance-coverage', 'Backend refactor guidance snippets are complete');
249
- } else {
250
- pushResult(
251
- results,
252
- false,
253
- 'backend-universal-principles-refactor-guidance-coverage',
254
- `Missing backend refactor guidance snippets: ${missingRefactorPromptSnippets.join(', ')}`
255
- );
256
- }
257
- }
258
-
259
- const documentationBoundaryAuditExecution = runMachineReadableScript(DOCUMENTATION_BOUNDARY_AUDIT_SCRIPT_PATH);
260
- if (!documentationBoundaryAuditExecution.report) {
261
- const failureDetails = documentationBoundaryAuditExecution.executionErrorMessage
262
- ? `Documentation boundary audit execution failed before producing a machine-readable report: ${documentationBoundaryAuditExecution.executionErrorMessage}`
263
- : 'Documentation boundary audit did not produce machine-readable JSON output';
264
- pushResult(results, false, 'documentation-boundary-audit', failureDetails);
265
- } else {
266
- diagnostics.documentationBoundaryAudit = documentationBoundaryAuditExecution.report;
267
- pushResult(
268
- results,
269
- true,
270
- 'documentation-boundary-audit',
271
- `documentation-boundary-audit executed (passed=${documentationBoundaryAuditExecution.report.passed}, failures=${documentationBoundaryAuditExecution.report.failureCount})`
272
- );
273
-
274
- const hasMachineReadableBoundaryDiagnostics = typeof documentationBoundaryAuditExecution.report?.reportVersion === 'string'
275
- && Array.isArray(documentationBoundaryAuditExecution.report?.boundaryResults)
276
- && Array.isArray(documentationBoundaryAuditExecution.report?.violations)
277
- && documentationBoundaryAuditExecution.report.boundaryResults.every((boundaryResult) => (
278
- typeof boundaryResult?.boundaryName === 'string'
279
- && typeof boundaryResult?.requirement === 'string'
280
- && Array.isArray(boundaryResult?.expectedDocumentationPaths)
281
- && Array.isArray(boundaryResult?.suggestedActions)
282
- ));
283
-
284
- if (hasMachineReadableBoundaryDiagnostics) {
285
- pushResult(
286
- results,
287
- true,
288
- 'documentation-boundary-diagnostics-machine-readable',
289
- `Boundary diagnostics are machine-readable and actionable (reportVersion=${documentationBoundaryAuditExecution.report.reportVersion})`
290
- );
291
- } else {
292
- pushResult(
293
- results,
294
- false,
295
- 'documentation-boundary-diagnostics-machine-readable',
296
- 'Documentation boundary diagnostics are missing required machine-readable actionable fields'
297
- );
298
- }
299
-
300
- const reportScope = documentationBoundaryAuditExecution.report?.autoDocsSyncScope;
301
- const explicitBoundaries = Array.isArray(reportScope?.explicitBoundaries)
302
- ? reportScope.explicitBoundaries
303
- : [];
304
- const isPhaseOneScopeBounded = reportScope?.phase === AUTO_DOCS_SYNC_SCOPE_PHASE
305
- && reportScope?.bounded === true
306
- && AUTO_DOCS_SYNC_SCOPE_BOUNDARIES.every((boundaryName) => explicitBoundaries.includes(boundaryName));
307
-
308
- if (isPhaseOneScopeBounded) {
309
- pushResult(
310
- results,
311
- true,
312
- 'auto-docs-sync-scope-phase1',
313
- `Auto-doc sync scope is explicitly bounded to phase-1 boundaries (${explicitBoundaries.join(', ')})`
314
- );
315
- } else {
316
- pushResult(
317
- results,
318
- false,
319
- 'auto-docs-sync-scope-phase1',
320
- 'Auto-doc sync scope is missing explicit phase-1 boundary metadata'
321
- );
322
- }
323
-
324
- const rolloutMetrics = documentationBoundaryAuditExecution.report?.rolloutMetrics;
325
- const hasValidPrecision = typeof rolloutMetrics?.precision === 'number'
326
- && rolloutMetrics.precision >= 0
327
- && rolloutMetrics.precision <= 1;
328
- const hasValidRecall = typeof rolloutMetrics?.recall === 'number'
329
- && rolloutMetrics.recall >= 0
330
- && rolloutMetrics.recall <= 1;
331
- const hasTimestampedEvidence = typeof rolloutMetrics?.measuredAt === 'string'
332
- && rolloutMetrics.measuredAt.length > 0;
333
-
334
- if (hasValidPrecision && hasValidRecall && hasTimestampedEvidence) {
335
- pushResult(
336
- results,
337
- true,
338
- 'auto-docs-sync-rollout-metrics',
339
- `Auto-doc sync rollout metrics are present (precision=${rolloutMetrics.precision.toFixed(4)}, recall=${rolloutMetrics.recall.toFixed(4)})`
340
- );
341
- } else {
342
- pushResult(
343
- results,
344
- false,
345
- 'auto-docs-sync-rollout-metrics',
346
- 'Auto-doc sync rollout metrics are missing precision/recall or timestamped evidence'
347
- );
348
- }
349
-
350
- if (documentationBoundaryAuditExecution.report.passed === true) {
351
- pushResult(
352
- results,
353
- true,
354
- 'documentation-boundary-hard-rule',
355
- 'Documentation hard-rule passed for all triggered boundaries'
356
- );
357
- } else {
358
- const failedDocumentationBoundaries = Array.isArray(documentationBoundaryAuditExecution.report.violations)
359
- ? documentationBoundaryAuditExecution.report.violations.map((violation) => {
360
- const failureCode = violation?.diagnosticCode || 'BOUNDARY_DOCS_SYNC_REQUIRED';
361
- const changedFiles = Array.isArray(violation?.changedFiles) && violation.changedFiles.length > 0
362
- ? violation.changedFiles.join(', ')
363
- : 'unknown-changed-files';
364
- const suggestion = Array.isArray(violation?.suggestedActions) && violation.suggestedActions.length > 0
365
- ? violation.suggestedActions[0]
366
- : 'Update matching boundary documentation in the same scope.';
367
- return `${failureCode} (${violation?.boundaryName || 'unknown-boundary'}): ${changedFiles}. Action: ${suggestion}`;
368
- })
369
- : Array.isArray(documentationBoundaryAuditExecution.report.failures)
370
- ? documentationBoundaryAuditExecution.report.failures
371
- : [];
372
- const failureSummary = failedDocumentationBoundaries.length > 0
373
- ? failedDocumentationBoundaries.join('; ')
374
- : '';
375
- pushResult(
376
- results,
377
- false,
378
- 'documentation-boundary-hard-rule',
379
- `Documentation hard-rule failed: ${failureSummary || 'Documentation boundary audit failed without boundary failure details'}`
380
- );
381
- }
382
- }
383
-
384
- const contextTriggeredAuditExecution = runMachineReadableScript(
385
- CONTEXT_TRIGGERED_AUDIT_SCRIPT_PATH,
386
- ['--workflow', 'pr-preparation']
387
- );
388
- if (!contextTriggeredAuditExecution.report) {
389
- const failureDetails = contextTriggeredAuditExecution.executionErrorMessage
390
- ? `Context-triggered audit execution failed before producing a machine-readable report: ${contextTriggeredAuditExecution.executionErrorMessage}`
391
- : 'Context-triggered audit did not produce machine-readable JSON output';
392
- pushResult(results, false, 'context-triggered-audit', failureDetails);
393
- } else {
394
- diagnostics.contextTriggeredAudit = contextTriggeredAuditExecution.report;
395
- pushResult(
396
- results,
397
- true,
398
- 'context-triggered-audit',
399
- `context-triggered-audit executed (passed=${contextTriggeredAuditExecution.report.passed}, strict=${contextTriggeredAuditExecution.report.strictAuditMode}, failures=${contextTriggeredAuditExecution.report.failureCount})`
400
- );
401
-
402
- if (contextTriggeredAuditExecution.report.strictAuditMode === true) {
403
- pushResult(
404
- results,
405
- true,
406
- 'context-triggered-strict-mode-auto',
407
- `Strict audit mode activated automatically for workflow=${contextTriggeredAuditExecution.report.workflow}`
408
- );
409
- } else {
410
- pushResult(
411
- results,
412
- false,
413
- 'context-triggered-strict-mode-auto',
414
- `Strict audit mode was not activated for workflow=${contextTriggeredAuditExecution.report.workflow}`
415
- );
416
- }
417
-
418
- if (contextTriggeredAuditExecution.report.passed === true) {
419
- pushResult(
420
- results,
421
- true,
422
- 'context-triggered-security-performance-hard-rule',
423
- 'Context-triggered security and performance audit hard-rule passed'
424
- );
425
- } else {
426
- const failedAuditDetails = Array.isArray(contextTriggeredAuditExecution.report.failures)
427
- ? contextTriggeredAuditExecution.report.failures.join('; ')
428
- : 'Unknown context-triggered audit failures';
429
- pushResult(
430
- results,
431
- false,
432
- 'context-triggered-security-performance-hard-rule',
433
- `Context-triggered audit failed: ${failedAuditDetails}`
434
- );
435
- }
436
- }
437
-
438
- const rulesGuardianAuditExecution = runMachineReadableScript(
439
- RULES_GUARDIAN_AUDIT_SCRIPT_PATH,
440
- ['--workflow', 'pr-preparation']
441
- );
442
- if (!rulesGuardianAuditExecution.report) {
443
- const failureDetails = rulesGuardianAuditExecution.executionErrorMessage
444
- ? `Rules guardian audit execution failed before producing a machine-readable report: ${rulesGuardianAuditExecution.executionErrorMessage}`
445
- : 'Rules guardian audit did not produce machine-readable JSON output';
446
- pushResult(results, false, 'rules-guardian-audit', failureDetails);
447
- } else {
448
- diagnostics.rulesGuardianAudit = rulesGuardianAuditExecution.report;
449
- pushResult(
450
- results,
451
- true,
452
- 'rules-guardian-audit',
453
- `rules-guardian-audit executed (passed=${rulesGuardianAuditExecution.report.passed}, driftDetected=${rulesGuardianAuditExecution.report?.driftDetection?.driftDetected}, failures=${rulesGuardianAuditExecution.report.failureCount})`
454
- );
455
-
456
- const sessionHandoffSummary = rulesGuardianAuditExecution.report?.sessionHandoff?.contractSummary;
457
- const sessionHandoffIncluded = rulesGuardianAuditExecution.report?.sessionHandoff?.included === true
458
- && typeof sessionHandoffSummary === 'string'
459
- && sessionHandoffSummary.trim().length > 0;
460
-
461
- if (sessionHandoffIncluded) {
462
- pushResult(
463
- results,
464
- true,
465
- 'rules-guardian-session-handoff',
466
- 'Session handoff includes active architecture contract summary'
467
- );
468
- } else {
469
- pushResult(
470
- results,
471
- false,
472
- 'rules-guardian-session-handoff',
473
- 'Rules guardian report is missing session handoff architecture contract summary'
474
- );
475
- }
476
-
477
- const requiresExplicitConfirmation = rulesGuardianAuditExecution.report?.confirmationPolicy?.requiresExplicitUserConfirmation === true;
478
-
479
- if (requiresExplicitConfirmation) {
480
- pushResult(
481
- results,
482
- true,
483
- 'rules-guardian-confirmation-policy',
484
- 'Direction change policy requires explicit user confirmation'
485
- );
486
- } else {
487
- pushResult(
488
- results,
489
- false,
490
- 'rules-guardian-confirmation-policy',
491
- 'Rules guardian report does not enforce explicit user confirmation policy'
492
- );
493
- }
494
-
495
- if (rulesGuardianAuditExecution.report.passed === true) {
496
- pushResult(
497
- results,
498
- true,
499
- 'rules-guardian-drift-confirmation',
500
- 'Rules guardian drift detection and confirmation checks passed'
501
- );
502
- } else {
503
- const failedAuditDetails = Array.isArray(rulesGuardianAuditExecution.report.failures)
504
- ? rulesGuardianAuditExecution.report.failures.join('; ')
505
- : 'Unknown rules guardian audit failures';
506
- pushResult(
507
- results,
508
- false,
509
- 'rules-guardian-drift-confirmation',
510
- `Rules guardian audit failed: ${failedAuditDetails}`
511
- );
512
- }
513
- }
514
-
515
- const explainOnDemandAuditExecution = runMachineReadableScript(
516
- EXPLAIN_ON_DEMAND_AUDIT_SCRIPT_PATH,
517
- ['--mode', 'default', '--workflow', 'pr-preparation']
518
- );
519
- if (!explainOnDemandAuditExecution.report) {
520
- const failureDetails = explainOnDemandAuditExecution.executionErrorMessage
521
- ? `Explain-on-demand audit execution failed before producing a machine-readable report: ${explainOnDemandAuditExecution.executionErrorMessage}`
522
- : 'Explain-on-demand audit did not produce machine-readable JSON output';
523
- pushResult(results, false, 'explain-on-demand-audit', failureDetails);
524
- } else {
525
- diagnostics.explainOnDemandAudit = explainOnDemandAuditExecution.report;
526
- pushResult(
527
- results,
528
- true,
529
- 'explain-on-demand-audit',
530
- `explain-on-demand-audit executed (passed=${explainOnDemandAuditExecution.report.passed}, mode=${explainOnDemandAuditExecution.report.mode}, failures=${explainOnDemandAuditExecution.report.failureCount})`
531
- );
532
-
533
- const defaultHiddenStatePolicyPassed = explainOnDemandAuditExecution.report?.responsePolicy?.defaultModeExposesStateInternals === false
534
- && explainOnDemandAuditExecution.report?.defaultResponse?.containsStateInternals === false;
535
-
536
- if (defaultHiddenStatePolicyPassed) {
537
- pushResult(
538
- results,
539
- true,
540
- 'explain-on-demand-default-hidden-state',
541
- 'Default response mode hides unnecessary state-file internals'
542
- );
543
- } else {
544
- pushResult(
545
- results,
546
- false,
547
- 'explain-on-demand-default-hidden-state',
548
- 'Default response mode exposes state internals or visibility flags are inconsistent'
549
- );
550
- }
551
-
552
- const diagnosticExplicitRequestPolicyPassed = explainOnDemandAuditExecution.report?.responsePolicy?.diagnosticRequiresExplicitRequest === true;
553
-
554
- if (diagnosticExplicitRequestPolicyPassed) {
555
- pushResult(
556
- results,
557
- true,
558
- 'explain-on-demand-explicit-request-gate',
559
- 'State internals are gated behind explicit diagnostic request'
560
- );
561
- } else {
562
- pushResult(
563
- results,
564
- false,
565
- 'explain-on-demand-explicit-request-gate',
566
- 'Explain-on-demand policy does not require explicit diagnostic request'
567
- );
568
- }
569
-
570
- const diagnosticExplainabilityPassed = explainOnDemandAuditExecution.report?.diagnosticMode?.canExplainStateDecisions === true;
571
-
572
- if (diagnosticExplainabilityPassed) {
573
- pushResult(
574
- results,
575
- true,
576
- 'explain-on-demand-diagnostic-explainability',
577
- 'Diagnostic mode can explain relevant state decisions when requested'
578
- );
579
- } else {
580
- pushResult(
581
- results,
582
- false,
583
- 'explain-on-demand-diagnostic-explainability',
584
- 'Explain-on-demand audit cannot provide diagnostic state decision explanations'
585
- );
586
- }
587
-
588
- if (explainOnDemandAuditExecution.report.passed === true) {
589
- pushResult(
590
- results,
591
- true,
592
- 'explain-on-demand-hard-rule',
593
- 'Explain-on-demand hard-rule passed'
594
- );
595
- } else {
596
- const failedAuditDetails = Array.isArray(explainOnDemandAuditExecution.report.failures)
597
- ? explainOnDemandAuditExecution.report.failures.join('; ')
598
- : 'Unknown explain-on-demand audit failures';
599
- pushResult(
600
- results,
601
- false,
602
- 'explain-on-demand-hard-rule',
603
- `Explain-on-demand audit failed: ${failedAuditDetails}`
604
- );
605
- }
606
- }
607
-
608
- const singleSourceLazyLoadingAuditExecution = runMachineReadableScript(
609
- SINGLE_SOURCE_LAZY_LOADING_AUDIT_SCRIPT_PATH,
610
- ['--workflow', 'pr-preparation']
611
- );
612
- if (!singleSourceLazyLoadingAuditExecution.report) {
613
- const failureDetails = singleSourceLazyLoadingAuditExecution.executionErrorMessage
614
- ? `Single-source lazy-loading audit execution failed before producing a machine-readable report: ${singleSourceLazyLoadingAuditExecution.executionErrorMessage}`
615
- : 'Single-source lazy-loading audit did not produce machine-readable JSON output';
616
- pushResult(results, false, 'single-source-lazy-loading-audit', failureDetails);
617
- } else {
618
- diagnostics.singleSourceLazyLoadingAudit = singleSourceLazyLoadingAuditExecution.report;
619
- pushResult(
620
- results,
621
- true,
622
- 'single-source-lazy-loading-audit',
623
- `single-source-lazy-loading-audit executed (passed=${singleSourceLazyLoadingAuditExecution.report.passed}, failures=${singleSourceLazyLoadingAuditExecution.report.failureCount})`
624
- );
625
-
626
- if (singleSourceLazyLoadingAuditExecution.report?.canonicalSource?.enforced === true) {
627
- pushResult(
628
- results,
629
- true,
630
- 'canonical-rule-source-hard-rule',
631
- 'Canonical rule source is explicitly defined and enforced'
632
- );
633
- } else {
634
- pushResult(
635
- results,
636
- false,
637
- 'canonical-rule-source-hard-rule',
638
- 'Canonical rule source enforcement failed in single-source lazy-loading audit'
639
- );
640
- }
641
-
642
- if (singleSourceLazyLoadingAuditExecution.report?.lazyRuleLoading?.enforced === true) {
643
- pushResult(
644
- results,
645
- true,
646
- 'lazy-rule-loading-hard-rule',
647
- 'Language-specific guidance is loaded lazily by detected scope'
648
- );
649
- } else {
650
- pushResult(
651
- results,
652
- false,
653
- 'lazy-rule-loading-hard-rule',
654
- 'Lazy rule loading enforcement failed in single-source lazy-loading audit'
655
- );
656
- }
657
-
658
- if (singleSourceLazyLoadingAuditExecution.report?.duplicationPolicy?.noConflictingDuplicates === true) {
659
- pushResult(
660
- results,
661
- true,
662
- 'no-conflicting-duplicate-rule-instructions',
663
- 'No conflicting duplicate rule instructions detected in normal flow'
664
- );
665
- } else {
666
- pushResult(
667
- results,
668
- false,
669
- 'no-conflicting-duplicate-rule-instructions',
670
- 'Conflicting duplicate rule instructions detected by single-source lazy-loading audit'
671
- );
672
- }
673
- }
674
-
675
- const architectureReviewChecklistContent = readText(ARCHITECTURE_REVIEW_CHECKLIST_PATH);
676
- if (!architectureReviewChecklistContent) {
677
- pushResult(results, false, 'architecture-review-checklist-exists', `Missing ${ARCHITECTURE_REVIEW_CHECKLIST_PATH}`);
678
- } else {
679
- pushResult(results, true, 'architecture-review-checklist-exists', `${ARCHITECTURE_REVIEW_CHECKLIST_PATH} is present`);
680
-
681
- const missingArchitectureChecklistSnippets = REQUIRED_ARCHITECTURE_REVIEW_CHECKLIST_SNIPPETS.filter(
682
- (requiredSnippet) => !architectureReviewChecklistContent.includes(requiredSnippet)
683
- );
684
-
685
- if (missingArchitectureChecklistSnippets.length === 0) {
686
- pushResult(results, true, 'architecture-review-checklist-coverage', 'Architecture review checklist sections are complete');
687
- } else {
688
- pushResult(
689
- results,
690
- false,
691
- 'architecture-review-checklist-coverage',
692
- `Missing architecture review checklist sections: ${missingArchitectureChecklistSnippets.join(', ')}`
693
- );
694
- }
695
- }
696
-
697
- try {
698
- const frontendAuditRawOutput = execFileSync('node', [FRONTEND_AUDIT_SCRIPT_PATH], {
699
- cwd: REPOSITORY_ROOT,
700
- encoding: 'utf8',
701
- maxBuffer: 1024 * 1024,
702
- });
703
- const frontendAuditReport = JSON.parse(frontendAuditRawOutput);
704
-
705
- if (frontendAuditReport.passed === true) {
706
- pushResult(results, true, 'frontend-usability-audit', 'frontend-usability-audit report passed');
707
- } else {
708
- const failureDetails = Array.isArray(frontendAuditReport.failures)
709
- ? frontendAuditReport.failures.join('; ')
710
- : 'Unknown frontend audit failures';
711
- pushResult(results, false, 'frontend-usability-audit', `frontend-usability-audit reported failures: ${failureDetails}`);
712
- }
713
- } catch (frontendAuditError) {
714
- const frontendAuditErrorMessage = frontendAuditError instanceof Error
715
- ? frontendAuditError.message
716
- : 'Unknown frontend audit execution error';
717
- pushResult(results, false, 'frontend-usability-audit', `Failed to execute frontend usability audit: ${frontendAuditErrorMessage}`);
718
- }
719
-
720
- const uiDesignJudgeExecution = runMachineReadableScript(UI_DESIGN_JUDGE_SCRIPT_PATH);
721
- if (!uiDesignJudgeExecution.report) {
722
- const failureDetails = uiDesignJudgeExecution.executionErrorMessage
723
- ? `UI design judge execution failed before producing a machine-readable report: ${uiDesignJudgeExecution.executionErrorMessage}`
724
- : 'UI design judge did not produce machine-readable JSON output';
725
- pushResult(results, false, 'ui-design-judge-advisory', failureDetails);
726
- } else {
727
- diagnostics.uiDesignJudge = uiDesignJudgeExecution.report;
728
- pushResult(
729
- results,
730
- true,
731
- 'ui-design-judge-advisory',
732
- `ui-design-judge executed (passed=${uiDesignJudgeExecution.report.passed}, skipped=${uiDesignJudgeExecution.report.skipped}, mode=${uiDesignJudgeExecution.report.mode})`
733
- );
734
-
735
- if (uiDesignJudgeExecution.report.advisoryOnly === true) {
736
- pushResult(
737
- results,
738
- true,
739
- 'ui-design-judge-non-blocking-policy',
740
- 'UI design judge remains advisory by default and does not hard-block release gate'
741
- );
742
- } else {
743
- pushResult(
744
- results,
745
- false,
746
- 'ui-design-judge-non-blocking-policy',
747
- 'UI design judge unexpectedly ran in blocking mode during release gate'
748
- );
749
- }
750
-
751
- const hasHybridVisualQaDiagnostics = typeof uiDesignJudgeExecution.report?.summary?.meaningfulDiffViewportCount === 'number'
752
- && typeof uiDesignJudgeExecution.report?.deterministicVisual?.reportPresent === 'boolean'
753
- && Array.isArray(uiDesignJudgeExecution.report?.deterministicVisual?.requiredViewports)
754
- && typeof uiDesignJudgeExecution.report?.semanticJudge?.attempted === 'boolean'
755
- && typeof uiDesignJudgeExecution.report?.semanticJudge?.skipped === 'boolean';
756
-
757
- if (hasHybridVisualQaDiagnostics) {
758
- pushResult(
759
- results,
760
- true,
761
- 'ui-design-judge-hybrid-diagnostics',
762
- 'UI design judge reports deterministic visual QA summary and semantic-review state together'
763
- );
764
- } else {
765
- pushResult(
766
- results,
767
- false,
768
- 'ui-design-judge-hybrid-diagnostics',
769
- 'UI design judge is missing deterministic visual QA or semantic-review machine-readable fields'
770
- );
771
- }
772
- }
773
-
774
- const benchmarkGateExecution = runMachineReadableScript(BENCHMARK_GATE_SCRIPT_PATH);
775
- if (!benchmarkGateExecution.report) {
776
- const failureDetails = benchmarkGateExecution.executionErrorMessage
777
- ? `Benchmark gate execution failed before producing a machine-readable report: ${benchmarkGateExecution.executionErrorMessage}`
778
- : 'Benchmark gate did not produce machine-readable JSON output';
779
- pushResult(results, false, 'benchmark-threshold-gate', failureDetails);
780
- } else {
781
- diagnostics.benchmarkGate = benchmarkGateExecution.report;
782
- pushResult(
783
- results,
784
- true,
785
- 'benchmark-threshold-gate',
786
- `Benchmark threshold gate executed (passed=${benchmarkGateExecution.report.passed}, failures=${benchmarkGateExecution.report.failureCount})`
787
- );
788
24
 
789
- if (benchmarkGateExecution.report.passed === true) {
790
- pushResult(results, true, 'benchmark-regression-block', 'Benchmark thresholds are healthy; release remains eligible');
791
- } else {
792
- const failedBenchmarkChecks = Array.isArray(benchmarkGateExecution.report.results)
793
- ? benchmarkGateExecution.report.results
794
- .filter((benchmarkCheckResult) => !benchmarkCheckResult.passed)
795
- .map((benchmarkCheckResult) => `${benchmarkCheckResult.checkName}: ${benchmarkCheckResult.details}`)
796
- : [];
797
- const failureSummary = failedBenchmarkChecks.length > 0
798
- ? failedBenchmarkChecks.join('; ')
799
- : 'Benchmark gate failed but did not report individual failed checks';
800
- pushResult(
801
- results,
802
- false,
803
- 'benchmark-regression-block',
804
- `Benchmark threshold regression detected. ${failureSummary}`
805
- );
806
- }
807
- }
25
+ runStaticReleaseChecks(results, diagnostics);
26
+ runAuditReleaseChecks(results, diagnostics);
808
27
 
809
28
  const failureCount = results.filter((checkResult) => !checkResult.passed).length;
810
29
  const releaseGateReport = {