@ryuenn3123/agentic-senior-core 2.5.14 → 2.5.15

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.
@@ -18,6 +18,7 @@ Use these checklists:
18
18
  5. Enforce documentation hard blockers on changed boundaries: public surface changes, API contract changes, and database structure changes must include synchronized documentation updates.
19
19
  6. Enforce context-triggered strict audits: review requests, PR-intent workflows, and major feature completion must run strict security and performance audits; small edits stay lightweight unless strict mode is explicitly forced.
20
20
  7. Enforce cross-session consistency guardian: session handoff must include active architecture contract summary, drift detection must warn before direction changes, and direction changes require explicit user confirmation.
21
+ 8. Enforce explain-on-demand state visibility: default responses must avoid unnecessary state-file internals, state internals are exposed only on explicit request, and diagnostic mode must explain relevant state decisions when needed.
21
22
 
22
23
  For EVERY violation found:
23
24
  - State the exact file and line
@@ -38,12 +38,22 @@ Release recommendation:
38
38
  - [ ] Breakpoint transitions preserve hierarchy, spacing rhythm, and action clarity.
39
39
  - [ ] Navigation and key CTA remain explicit across viewport sizes.
40
40
 
41
- ## 6. UX Narrative and Conversion Clarity
41
+ ## 6. Language and Content Consistency
42
+ - [ ] Content language is consistent across headline, body, CTA, and system messages for the same screen flow.
43
+ - [ ] Mixed-language output appears only when requested by user or product requirement.
44
+ - [ ] Terminology stays stable for repeated actions and labels.
45
+
46
+ ## 7. Text Contrast and Collision Safety
47
+ - [ ] Text-to-background contrast is checked for every semantic token pair used in UI.
48
+ - [ ] No text color clashes with gradients, images, or accent surfaces.
49
+ - [ ] Primary and secondary text remain readable in all supported breakpoints.
50
+
51
+ ## 8. UX Narrative and Conversion Clarity
42
52
  - [ ] First viewport communicates value proposition and primary action immediately.
43
53
  - [ ] Error, empty, and loading states provide clear next actions.
44
54
  - [ ] User journey avoids dead ends and hidden critical actions.
45
55
 
46
- ## 7. Template Diversity and Originality
56
+ ## 9. Template Diversity and Originality
47
57
  - [ ] Output is not a copy of a generic starter template or repeated AI layout pattern.
48
58
  - [ ] Layout composition shows intentional variation in structure and hierarchy.
49
59
  - [ ] Visual intent, interaction quality, and conversion clarity are all explicitly reviewed together.
@@ -6,6 +6,7 @@ Run this checklist before claiming frontend work is production-ready.
6
6
  - [ ] Typography scale is consistent and tokenized.
7
7
  - [ ] Color usage follows design tokens and avoids ad-hoc values.
8
8
  - [ ] Spacing and layout rhythm is coherent across pages.
9
+ - [ ] Language and terminology stay consistent across headline, body, and CTA for the same flow.
9
10
 
10
11
  ## 2. Responsiveness
11
12
  - [ ] Core pages are usable at mobile, tablet, and desktop breakpoints.
@@ -119,3 +119,8 @@ VERDICT: PASS / FAIL (X/Y items passed)
119
119
  - [ ] Session handoff includes active architecture contract summary
120
120
  - [ ] Drift detection warns before direction changes
121
121
  - [ ] Direction changes require explicit user confirmation
122
+
123
+ ### 13. Invisible State Management (Explain-on-Demand)
124
+ - [ ] Default responses avoid unnecessary state-file internals
125
+ - [ ] State internals are exposed only on explicit request
126
+ - [ ] Diagnostic mode can explain relevant state decisions when needed
@@ -23,6 +23,15 @@ These guardrails are mandatory to preserve architecture direction across session
23
23
  - Direction changes require explicit user confirmation before applying changes.
24
24
  - When confirmation is provided, record the rationale in session notes or PR context.
25
25
 
26
+ ## Invisible State Management with Explain-on-Demand
27
+
28
+ State internals must stay invisible by default.
29
+
30
+ - Default responses must avoid unnecessary state-file internals.
31
+ - State internals are exposed only on explicit user request.
32
+ - Diagnostic mode explains relevant state decisions when needed.
33
+ - Keep default explanations concise and outcome-first; show raw state details only in diagnostic mode.
34
+
26
35
  ## The Core Principle
27
36
 
28
37
  **Every layer has ONE job. Layer leaks are bugs — not "pragmatic shortcuts."**
@@ -16,6 +16,13 @@ Mandatory behavior when triggered:
16
16
  - score and review generated UI work against visual intent, interaction quality, and conversion clarity
17
17
  - reject template-only repetitive outputs and force a distinct layout direction
18
18
 
19
+ ## UI Consistency Guardrails (Mandatory)
20
+
21
+ - Content language must stay consistent per screen and flow unless user requests multilingual output.
22
+ - Text color must remain contrast-safe against its background; no color collisions.
23
+ - Layout must avoid overlap, clipped text, and misaligned key actions across breakpoints.
24
+ - Keep spacing and positioning token-driven so repeated outputs stay stable.
25
+
19
26
  ## 1. File Structure (Feature-Driven Design)
20
27
  Organize your application by feature domain, not by file type.
21
28
  - **BANNED:** Monolithic directories like `/components` (with 500 files), `/hooks`, `/api`.
@@ -1,5 +1,5 @@
1
1
  {
2
- "generatedAt": "2026-04-17T12:51:43.241Z",
2
+ "generatedAt": "2026-04-17T13:21:48.914Z",
3
3
  "reportName": "memory-continuity-benchmark",
4
4
  "schemaVersion": "1.0.0",
5
5
  "passed": true,
package/.cursorrules CHANGED
@@ -1,6 +1,6 @@
1
1
  # AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
2
2
 
3
- Generated by Agentic-Senior-Core CLI v2.5.14
3
+ Generated by Agentic-Senior-Core CLI v2.5.15
4
4
  Timestamp: 2026-04-15T00:14:51.184Z
5
5
  Selected profile: beginner
6
6
  Selected policy file: .agent-context/policies/llm-judge-threshold.json
package/.windsurfrules CHANGED
@@ -1,6 +1,6 @@
1
1
  # AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
2
2
 
3
- Generated by Agentic-Senior-Core CLI v2.5.14
3
+ Generated by Agentic-Senior-Core CLI v2.5.15
4
4
  Timestamp: 2026-04-15T00:14:51.184Z
5
5
  Selected profile: beginner
6
6
  Selected policy file: .agent-context/policies/llm-judge-threshold.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryuenn3123/agentic-senior-core",
3
- "version": "2.5.14",
3
+ "version": "2.5.15",
4
4
  "type": "module",
5
5
  "description": "Force your AI Agent to code like a Staff Engineer, not a Junior.",
6
6
  "bin": {
@@ -46,6 +46,7 @@
46
46
  "audit:documentation-boundary": "node ./scripts/documentation-boundary-audit.mjs",
47
47
  "audit:context-triggered": "node ./scripts/context-triggered-audit.mjs",
48
48
  "audit:rules-guardian": "node ./scripts/rules-guardian-audit.mjs",
49
+ "audit:explain-on-demand": "node ./scripts/explain-on-demand-audit.mjs",
49
50
  "gate:release": "node ./scripts/release-gate.mjs && node ./scripts/forbidden-content-check.mjs",
50
51
  "prepublishOnly": "npm run gate:release",
51
52
  "sbom:generate": "node ./scripts/generate-sbom.mjs",
@@ -0,0 +1,426 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * explain-on-demand-audit.mjs
5
+ *
6
+ * Enforces invisible state management defaults and explicit diagnostic
7
+ * visibility rules for state internals.
8
+ */
9
+
10
+ import { existsSync, readFileSync } from 'node:fs';
11
+ import { execFileSync } from 'node:child_process';
12
+ import { dirname, resolve } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = dirname(__filename);
17
+ const REPOSITORY_ROOT = resolve(__dirname, '..');
18
+
19
+ const ONBOARDING_REPORT_PATH = '.agent-context/state/onboarding-report.json';
20
+ const ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
21
+ const PR_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
22
+ const REVIEW_PROMPT_PATH = '.agent-context/prompts/review-code.md';
23
+
24
+ const DEFAULT_MODE = 'default';
25
+ const SUPPORTED_MODES = new Set([DEFAULT_MODE, 'diagnostic']);
26
+ const DEFAULT_WORKFLOW = 'standard';
27
+
28
+ const REQUIRED_ARCHITECTURE_RULE_SNIPPETS = [
29
+ '## Invisible State Management with Explain-on-Demand',
30
+ 'Default responses must avoid unnecessary state-file internals.',
31
+ 'State internals are exposed only on explicit user request.',
32
+ 'Diagnostic mode explains relevant state decisions when needed.',
33
+ ];
34
+
35
+ const REQUIRED_PR_CHECKLIST_SNIPPETS = [
36
+ 'Default responses avoid unnecessary state-file internals',
37
+ 'State internals are exposed only on explicit request',
38
+ 'Diagnostic mode can explain relevant state decisions when needed',
39
+ ];
40
+
41
+ const REQUIRED_REVIEW_PROMPT_SNIPPETS = [
42
+ 'Enforce explain-on-demand state visibility: default responses must avoid unnecessary state-file internals, state internals are exposed only on explicit request, and diagnostic mode must explain relevant state decisions when needed.',
43
+ ];
44
+
45
+ const INTERNAL_STATE_SIGNAL_PATTERNS = [
46
+ /\.agent-context\/state\//i,
47
+ /\bautoDetection\b/i,
48
+ /\brankedCandidates\b/i,
49
+ /\bconfidenceGap\b/i,
50
+ /\bschemaVersion\b/i,
51
+ ];
52
+
53
+ function pushResult(results, isPassed, checkName, details) {
54
+ results.push({
55
+ checkName,
56
+ passed: isPassed,
57
+ details,
58
+ });
59
+ }
60
+
61
+ function normalizeFilePath(filePath) {
62
+ return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
63
+ }
64
+
65
+ function parseGitFileList(rawOutput) {
66
+ if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
67
+ return [];
68
+ }
69
+
70
+ return rawOutput
71
+ .split(/\r?\n/)
72
+ .map((filePath) => filePath.trim())
73
+ .filter((filePath) => filePath.length > 0)
74
+ .map(normalizeFilePath);
75
+ }
76
+
77
+ function runGitFileQuery(commandArguments) {
78
+ try {
79
+ const rawOutput = execFileSync('git', commandArguments, {
80
+ cwd: REPOSITORY_ROOT,
81
+ encoding: 'utf8',
82
+ maxBuffer: 1024 * 1024,
83
+ });
84
+
85
+ return parseGitFileList(rawOutput);
86
+ } catch {
87
+ return [];
88
+ }
89
+ }
90
+
91
+ function uniqueSorted(filePaths) {
92
+ return Array.from(new Set(filePaths)).sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
93
+ }
94
+
95
+ function collectChangedFiles() {
96
+ const workingTreeFiles = runGitFileQuery(['diff', '--name-only']);
97
+ const stagedFiles = runGitFileQuery(['diff', '--name-only', '--cached']);
98
+ const workingScopeFiles = uniqueSorted([...workingTreeFiles, ...stagedFiles]);
99
+
100
+ if (workingScopeFiles.length > 0) {
101
+ return {
102
+ source: 'working-tree-and-index',
103
+ files: workingScopeFiles,
104
+ };
105
+ }
106
+
107
+ const latestCommitRangeFiles = runGitFileQuery(['diff', '--name-only', 'HEAD~1..HEAD']);
108
+ if (latestCommitRangeFiles.length > 0) {
109
+ return {
110
+ source: 'latest-commit-range',
111
+ files: uniqueSorted(latestCommitRangeFiles),
112
+ };
113
+ }
114
+
115
+ const headCommitFiles = runGitFileQuery(['show', '--pretty=format:', '--name-only', 'HEAD']);
116
+ if (headCommitFiles.length > 0) {
117
+ return {
118
+ source: 'head-commit',
119
+ files: uniqueSorted(headCommitFiles),
120
+ };
121
+ }
122
+
123
+ return {
124
+ source: 'none',
125
+ files: [],
126
+ };
127
+ }
128
+
129
+ function readText(relativeFilePath) {
130
+ const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
131
+ if (!existsSync(absolutePath)) {
132
+ return '';
133
+ }
134
+
135
+ return readFileSync(absolutePath, 'utf8');
136
+ }
137
+
138
+ function parseOnboardingReport(onboardingReportContent) {
139
+ if (typeof onboardingReportContent !== 'string' || onboardingReportContent.trim().length === 0) {
140
+ return null;
141
+ }
142
+
143
+ try {
144
+ return JSON.parse(onboardingReportContent);
145
+ } catch {
146
+ return null;
147
+ }
148
+ }
149
+
150
+ function parseCliArguments(argumentList) {
151
+ let mode = DEFAULT_MODE;
152
+ let workflow = DEFAULT_WORKFLOW;
153
+ let explicitStateRequest = false;
154
+
155
+ for (let argumentIndex = 0; argumentIndex < argumentList.length; argumentIndex += 1) {
156
+ const argumentValue = argumentList[argumentIndex];
157
+
158
+ if (argumentValue === '--state-debug') {
159
+ explicitStateRequest = true;
160
+ continue;
161
+ }
162
+
163
+ if (argumentValue === '--mode') {
164
+ const nextArgumentValue = argumentList[argumentIndex + 1];
165
+ if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
166
+ mode = nextArgumentValue;
167
+ argumentIndex += 1;
168
+ }
169
+ continue;
170
+ }
171
+
172
+ if (argumentValue.startsWith('--mode=')) {
173
+ mode = argumentValue.slice('--mode='.length);
174
+ continue;
175
+ }
176
+
177
+ if (argumentValue === '--workflow') {
178
+ const nextArgumentValue = argumentList[argumentIndex + 1];
179
+ if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
180
+ workflow = nextArgumentValue;
181
+ argumentIndex += 1;
182
+ }
183
+ continue;
184
+ }
185
+
186
+ if (argumentValue.startsWith('--workflow=')) {
187
+ workflow = argumentValue.slice('--workflow='.length);
188
+ }
189
+ }
190
+
191
+ const normalizedMode = String(mode || '').trim().toLowerCase();
192
+
193
+ return {
194
+ mode: SUPPORTED_MODES.has(normalizedMode) ? normalizedMode : DEFAULT_MODE,
195
+ workflow: String(workflow || '').trim().toLowerCase() || DEFAULT_WORKFLOW,
196
+ explicitStateRequest,
197
+ };
198
+ }
199
+
200
+ function assertSnippetCoverage(sourceLabel, sourcePath, requiredSnippets, failures, results) {
201
+ const sourceContent = readText(sourcePath);
202
+
203
+ if (!sourceContent) {
204
+ failures.push(`Missing ${sourceLabel} source: ${sourcePath}`);
205
+ pushResult(results, false, `${sourceLabel}-source-exists`, `Missing ${sourcePath}`);
206
+ return;
207
+ }
208
+
209
+ pushResult(results, true, `${sourceLabel}-source-exists`, `${sourcePath} is present`);
210
+
211
+ const missingSnippets = requiredSnippets.filter((requiredSnippet) => !sourceContent.includes(requiredSnippet));
212
+
213
+ if (missingSnippets.length > 0) {
214
+ failures.push(`Missing ${sourceLabel} snippets: ${missingSnippets.join(', ')}`);
215
+ pushResult(
216
+ results,
217
+ false,
218
+ `${sourceLabel}-source-coverage`,
219
+ `Missing snippets in ${sourcePath}: ${missingSnippets.join(', ')}`
220
+ );
221
+ return;
222
+ }
223
+
224
+ pushResult(results, true, `${sourceLabel}-source-coverage`, `${sourceLabel} snippets are complete`);
225
+ }
226
+
227
+ function buildDefaultResponseSummary(onboardingReport) {
228
+ const selectedStack = String(onboardingReport?.selectedStack || 'unknown-stack').trim() || 'unknown-stack';
229
+ const selectedBlueprint = String(onboardingReport?.selectedBlueprint || 'unknown-blueprint').trim() || 'unknown-blueprint';
230
+ const selectedProfile = String(onboardingReport?.selectedProfile || 'unknown-profile').trim() || 'unknown-profile';
231
+
232
+ return `Active setup summary: stack=${selectedStack}, blueprint=${selectedBlueprint}, profile=${selectedProfile}.`;
233
+ }
234
+
235
+ function detectInternalSignals(textValue) {
236
+ const normalizedText = String(textValue || '');
237
+ return INTERNAL_STATE_SIGNAL_PATTERNS.some((signalPattern) => signalPattern.test(normalizedText));
238
+ }
239
+
240
+ function buildDiagnosticDecisionSummaries(onboardingReport) {
241
+ const explanations = [];
242
+
243
+ const selectedStack = String(onboardingReport?.selectedStack || '').trim();
244
+ if (selectedStack) {
245
+ explanations.push(`Stack decision: selectedStack=${selectedStack}.`);
246
+ }
247
+
248
+ const selectedBlueprint = String(onboardingReport?.selectedBlueprint || '').trim();
249
+ if (selectedBlueprint) {
250
+ explanations.push(`Blueprint decision: selectedBlueprint=${selectedBlueprint}.`);
251
+ }
252
+
253
+ const selectedProfile = String(onboardingReport?.selectedProfile || '').trim();
254
+ if (selectedProfile) {
255
+ explanations.push(`Profile decision: selectedProfile=${selectedProfile}.`);
256
+ }
257
+
258
+ const detectionReasoning = String(onboardingReport?.autoDetection?.detectionReasoning || '').trim();
259
+ if (detectionReasoning) {
260
+ explanations.push(`Detection reasoning: ${detectionReasoning}`);
261
+ }
262
+
263
+ if (typeof onboardingReport?.ciGuardrailsEnabled === 'boolean') {
264
+ explanations.push(`CI guardrails decision: ciGuardrailsEnabled=${String(onboardingReport.ciGuardrailsEnabled)}.`);
265
+ }
266
+
267
+ return explanations;
268
+ }
269
+
270
+ function runAudit() {
271
+ const parsedArguments = parseCliArguments(process.argv.slice(2));
272
+ const changedScope = collectChangedFiles();
273
+ const changedFiles = changedScope.files;
274
+ const results = [];
275
+ const failures = [];
276
+ const warnings = [];
277
+
278
+ pushResult(results, true, 'context-workflow', `workflow=${parsedArguments.workflow}`);
279
+ pushResult(results, true, 'explain-mode', `mode=${parsedArguments.mode}`);
280
+ pushResult(
281
+ results,
282
+ true,
283
+ 'state-debug-explicit-request',
284
+ parsedArguments.explicitStateRequest
285
+ ? 'Explicit state diagnostic request received'
286
+ : 'No explicit state diagnostic request provided'
287
+ );
288
+
289
+ assertSnippetCoverage(
290
+ 'explain-on-demand-architecture-rule',
291
+ ARCHITECTURE_RULE_PATH,
292
+ REQUIRED_ARCHITECTURE_RULE_SNIPPETS,
293
+ failures,
294
+ results
295
+ );
296
+
297
+ assertSnippetCoverage(
298
+ 'explain-on-demand-pr-checklist',
299
+ PR_CHECKLIST_PATH,
300
+ REQUIRED_PR_CHECKLIST_SNIPPETS,
301
+ failures,
302
+ results
303
+ );
304
+
305
+ assertSnippetCoverage(
306
+ 'explain-on-demand-review-prompt',
307
+ REVIEW_PROMPT_PATH,
308
+ REQUIRED_REVIEW_PROMPT_SNIPPETS,
309
+ failures,
310
+ results
311
+ );
312
+
313
+ const onboardingReportContent = readText(ONBOARDING_REPORT_PATH);
314
+ const onboardingReport = parseOnboardingReport(onboardingReportContent);
315
+
316
+ if (!onboardingReportContent) {
317
+ failures.push(`Missing state source: ${ONBOARDING_REPORT_PATH}`);
318
+ pushResult(results, false, 'state-source', `Missing ${ONBOARDING_REPORT_PATH}`);
319
+ } else if (!onboardingReport) {
320
+ failures.push(`Invalid state source JSON: ${ONBOARDING_REPORT_PATH}`);
321
+ pushResult(results, false, 'state-source', `Cannot parse ${ONBOARDING_REPORT_PATH}`);
322
+ } else {
323
+ pushResult(results, true, 'state-source', `${ONBOARDING_REPORT_PATH} is present and valid`);
324
+ }
325
+
326
+ const defaultResponseSummary = buildDefaultResponseSummary(onboardingReport);
327
+ const defaultModeExposesStateInternals = detectInternalSignals(defaultResponseSummary);
328
+
329
+ if (defaultModeExposesStateInternals) {
330
+ failures.push('Default response exposes state internals');
331
+ pushResult(
332
+ results,
333
+ false,
334
+ 'default-response-invisible-state',
335
+ 'Default response leaks internal state details'
336
+ );
337
+ } else {
338
+ pushResult(
339
+ results,
340
+ true,
341
+ 'default-response-invisible-state',
342
+ 'Default response avoids unnecessary state-file internals'
343
+ );
344
+ }
345
+
346
+ const diagnosticDecisionSummaries = buildDiagnosticDecisionSummaries(onboardingReport);
347
+ const canExplainStateDecisions = diagnosticDecisionSummaries.length > 0;
348
+
349
+ if (parsedArguments.mode === 'diagnostic' && !parsedArguments.explicitStateRequest) {
350
+ failures.push('Diagnostic mode requested without explicit state request');
351
+ pushResult(
352
+ results,
353
+ false,
354
+ 'diagnostic-explicit-request-gate',
355
+ 'Diagnostic mode requires explicit request. Re-run with --state-debug when user asks for state-level details.'
356
+ );
357
+ } else {
358
+ pushResult(
359
+ results,
360
+ true,
361
+ 'diagnostic-explicit-request-gate',
362
+ parsedArguments.mode === 'diagnostic'
363
+ ? 'Diagnostic mode is explicitly requested and permitted'
364
+ : 'Diagnostic mode not requested; default hidden-state behavior applies'
365
+ );
366
+ }
367
+
368
+ if (!canExplainStateDecisions) {
369
+ failures.push('Diagnostic mode cannot explain relevant state decisions');
370
+ pushResult(
371
+ results,
372
+ false,
373
+ 'diagnostic-explain-state-decisions',
374
+ 'No state decision explanations available'
375
+ );
376
+ } else {
377
+ pushResult(
378
+ results,
379
+ true,
380
+ 'diagnostic-explain-state-decisions',
381
+ `Diagnostic mode can explain ${diagnosticDecisionSummaries.length} state decision points`
382
+ );
383
+ }
384
+
385
+ if (parsedArguments.mode === 'default' && parsedArguments.explicitStateRequest) {
386
+ warnings.push('Explicit state request was provided in default mode; internal state details remain hidden unless diagnostic mode is selected.');
387
+ }
388
+
389
+ const reportPayload = {
390
+ generatedAt: new Date().toISOString(),
391
+ auditName: 'explain-on-demand-audit',
392
+ workflow: parsedArguments.workflow,
393
+ mode: parsedArguments.mode,
394
+ source: changedScope.source,
395
+ changedFileCount: changedFiles.length,
396
+ changedFiles,
397
+ responsePolicy: {
398
+ defaultModeExposesStateInternals,
399
+ diagnosticRequiresExplicitRequest: true,
400
+ explicitStateRequestReceived: parsedArguments.explicitStateRequest,
401
+ },
402
+ defaultResponse: {
403
+ summary: defaultResponseSummary,
404
+ containsStateInternals: defaultModeExposesStateInternals,
405
+ },
406
+ diagnosticMode: {
407
+ requested: parsedArguments.mode === 'diagnostic',
408
+ allowed: parsedArguments.mode !== 'diagnostic' || parsedArguments.explicitStateRequest,
409
+ canExplainStateDecisions,
410
+ stateDecisionExplanations: parsedArguments.mode === 'diagnostic' && parsedArguments.explicitStateRequest
411
+ ? diagnosticDecisionSummaries
412
+ : [],
413
+ availableDecisionCount: diagnosticDecisionSummaries.length,
414
+ },
415
+ passed: failures.length === 0,
416
+ failureCount: failures.length,
417
+ failures,
418
+ warnings,
419
+ results,
420
+ };
421
+
422
+ console.log(JSON.stringify(reportPayload, null, 2));
423
+ process.exit(reportPayload.passed ? 0 : 1);
424
+ }
425
+
426
+ runAudit();
@@ -44,6 +44,8 @@ const REQUIRED_EXCELLENCE_RUBRIC_SNIPPETS = [
44
44
  'Typography Quality',
45
45
  'Color System Diversity and Contrast',
46
46
  'Interaction Choreography',
47
+ 'Language and Content Consistency',
48
+ 'Text Contrast and Collision Safety',
47
49
  'UX Narrative and Conversion Clarity',
48
50
  'Template Diversity and Originality',
49
51
  'Low-Diversity Template Output Policy',
@@ -55,6 +57,9 @@ const REQUIRED_FRONTEND_RULE_SNIPPETS = [
55
57
  'UI scope trigger signals',
56
58
  'visual intent, interaction quality, and conversion clarity',
57
59
  'template-only repetitive outputs',
60
+ 'UI Consistency Guardrails (Mandatory)',
61
+ 'Content language must stay consistent per screen and flow unless user requests multilingual output.',
62
+ 'Text color must remain contrast-safe against its background; no color collisions.',
58
63
  ];
59
64
 
60
65
  function assertFileExists(relativeFilePath, failures) {
@@ -33,6 +33,7 @@ const FRONTEND_AUDIT_SCRIPT_PATH = 'scripts/frontend-usability-audit.mjs';
33
33
  const DOCUMENTATION_BOUNDARY_AUDIT_SCRIPT_PATH = 'scripts/documentation-boundary-audit.mjs';
34
34
  const CONTEXT_TRIGGERED_AUDIT_SCRIPT_PATH = 'scripts/context-triggered-audit.mjs';
35
35
  const RULES_GUARDIAN_AUDIT_SCRIPT_PATH = 'scripts/rules-guardian-audit.mjs';
36
+ const EXPLAIN_ON_DEMAND_AUDIT_SCRIPT_PATH = 'scripts/explain-on-demand-audit.mjs';
36
37
  const BACKEND_ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
37
38
  const BACKEND_REVIEW_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
38
39
  const REFACTOR_PROMPT_PATH = '.agent-context/prompts/refactor.md';
@@ -63,6 +64,8 @@ const REQUIRED_FRONTEND_EXCELLENCE_RUBRIC_SNIPPETS = [
63
64
  'Typography Quality',
64
65
  'Color System Diversity and Contrast',
65
66
  'Interaction Choreography',
67
+ 'Language and Content Consistency',
68
+ 'Text Contrast and Collision Safety',
66
69
  'UX Narrative and Conversion Clarity',
67
70
  'Template Diversity and Originality',
68
71
  'Low-Diversity Template Output Policy',
@@ -509,6 +512,99 @@ function runReleaseGate() {
509
512
  }
510
513
  }
511
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
+
512
608
  const frontendParityChecklistContent = readText(FRONTEND_PARITY_CHECKLIST_PATH);
513
609
  if (!frontendParityChecklistContent) {
514
610
  pushResult(results, false, 'frontend-parity-checklist-exists', `Missing ${FRONTEND_PARITY_CHECKLIST_PATH}`);
@@ -174,6 +174,7 @@ async function validateRequiredFiles() {
174
174
  'scripts/documentation-boundary-audit.mjs',
175
175
  'scripts/context-triggered-audit.mjs',
176
176
  'scripts/rules-guardian-audit.mjs',
177
+ 'scripts/explain-on-demand-audit.mjs',
177
178
  'scripts/release-gate.mjs',
178
179
  'scripts/generate-sbom.mjs',
179
180
  'scripts/init-project.sh',