Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: declare the scope-adherence failure codes in the leaf beside their labels (#7643)
[._.]/ Adam Eivy4caaec78f023
diff --git a/server/lib/scopeAdherenceReasons.js b/server/lib/scopeAdherenceReasons.jsindex 2d51398410..123bbb170e 100644--- a/server/lib/scopeAdherenceReasons.js+++ b/server/lib/scopeAdherenceReasons.js@@ -17,6 +17,23 @@* not answer has said nothing about the change.*/+/**+ * The codes `scoreAdherence` adds on top of the shared `JEV_FAILURE_CODES` and+ * the untrusted-content ones, which it forwards unchanged.+ *+ * Declared HERE, beside the labels, rather than in the service: the sibling+ * test asserts every code has a label, and importing the service to read them+ * would drag its whole closure into a leaf test file — the shape+ * `lib/importScoping.test.js` budgets against. The service imports this.+ */+export const SCOPE_ADHERENCE_FAILURE_CODES = Object.freeze([+ 'scope-adherence-disabled',+ 'scope-adherence-change-empty',+ 'scope-adherence-corpus-missing',+ 'scope-adherence-corpus-unreadable',+ 'scope-adherence-no-clause',+]);+export const SCOPE_ADHERENCE_REASONS = Object.freeze({// Reachable only in a race — the panel hides itself when the feature is off,// but the toggle can move between render and response.diff --git a/server/lib/scopeAdherenceReasons.test.js b/server/lib/scopeAdherenceReasons.test.jsindex a6b1931885..0b2b353c87 100644--- a/server/lib/scopeAdherenceReasons.test.js+++ b/server/lib/scopeAdherenceReasons.test.js@@ -1,17 +1,20 @@/*** Coverage for the scope-adherence failure labels.*- * `services/scopeAdherence.js` owns the CODES and the labels live beside them- * in `lib/scopeAdherenceReasons.js`, so there is nothing to keep in parity —- * the client re-exports this module rather than copying it. What still needs- * guarding is the vocabulary: a code the service can return with no label here+ * The codes and their labels live in ONE leaf, and the client re-exports it+ * rather than copying it, so there is no parity to assert. What still needs+ * guarding is the vocabulary: a code the service can return with no label* renders as the generic fallback with a fully green suite.+ *+ * The leaf also declares the codes so this test never has to import the+ * service — a lib test that drags a service closure is the shape+ * `lib/importScoping.test.js` budgets against, and it cost a CI round.*/import { describe, it, expect } from 'vitest';import { JEV_FAILURE_CODES } from './jev.js';-import { SCOPE_ADHERENCE_FAILURE_CODES } from '../services/scopeAdherence.js';import {+ SCOPE_ADHERENCE_FAILURE_CODES,SCOPE_ADHERENCE_REASONS,SCOPE_ADHERENCE_REASON_FALLBACK,scopeAdherenceReasonLabel,diff --git a/server/services/scopeAdherence.js b/server/services/scopeAdherence.jsindex 868c4b1964..2d9b109068 100644--- a/server/services/scopeAdherence.js+++ b/server/services/scopeAdherence.js@@ -45,23 +45,10 @@ import {SCOPE_ADHERENCE_TOP_K,selectCandidateClauses,} from '../lib/scopeAdherence.js';--/**- * The codes this service adds on top of the shared `JEV_FAILURE_CODES` and the- * untrusted-content ones, which it forwards unchanged.- *- * Load-bearing: `server/services/scopeAdherence.reasons.parity.test.js` asserts- * the client's operator-facing label map covers every one of them, so a code- * added here without a label fails rather than silently rendering as the- * generic fallback.- */-export const SCOPE_ADHERENCE_FAILURE_CODES = Object.freeze([- 'scope-adherence-disabled',- 'scope-adherence-change-empty',- 'scope-adherence-corpus-missing',- 'scope-adherence-corpus-unreadable',- 'scope-adherence-no-clause',-]);+// Re-exported, not re-declared: the codes live beside their operator-facing+// labels in a pure leaf, so the test that pairs them need not import this+// service's closure (`lib/importScoping.test.js`).+export { SCOPE_ADHERENCE_FAILURE_CODES } from '../lib/scopeAdherenceReasons.js';const failure = (code) => ({ ok: false, code });