mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
fix(modules): switch the inbound-documents module off in code
The inbound-documents surface is withdrawn from this release and returns later with more depth. Park its module key (`inboundDocuments`) in a new `CODE_DISABLED_MODULE_KEYS` list so it is hard-off for every account ahead of both the operator-availability and the per-user opt-in layer. The gate short-circuits a code-disabled key to disabled, so the resolved module map reports it off everywhere: the nav entry stays born-gated and hidden, the `/documents` page redirects, and every `/api/documents/inbound/*` route returns the 403 module-disabled envelope. The Modules hub and the operator-availability panel drop the row, and the per-user PATCH surface refuses to write the key (a clean 422 instead of an inert preference). The whole implementation stays intact — routes, the inbound-documents view, the registry entry with its opt-in marker, the validation schemas, and the migration are all preserved. Re-enabling the module is a one-line removal from the list once the rebuild lands. Regenerate the OpenAPI contract: the module-preferences PATCH body no longer advertises the parked key.
This commit is contained in:
1 parent
4266203d3a
commit
7e83af5701
8 files changed
+152
-73
No files matched your search
@@ -20,6 +20,7 @@ import {
|
||||
} from "../operator-availability";
|
||||
import {
|
||||
isCoreDomain,
|
||||
isCodeDisabledModule,
|
||||
isModuleKey,
|
||||
isOptInModule,
|
||||
moduleDelegatesTo,
|
||||
@@ -373,14 +374,22 @@ describe("registry — opt-in marker", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveModuleEnabled — inboundDocuments module (opt-in, default-OFF)", () => {
|
||||
describe("resolveModuleEnabled — inboundDocuments module (disabled in code)", () => {
|
||||
// v1.25.3 — `inboundDocuments` is switched off in code pending a rebuild
|
||||
// (`CODE_DISABLED_MODULE_KEYS`). It is hard-off ahead of both the operator
|
||||
// and the per-user layer: no stored preference or availability blob can
|
||||
// re-surface it. The registry entry + `optIn` marker stay intact.
|
||||
it("is flagged as code-disabled in the registry", () => {
|
||||
expect(isCodeDisabledModule("inboundDocuments")).toBe(true);
|
||||
});
|
||||
|
||||
it("is OFF when no preference is recorded", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("inboundDocuments", inputs(), false, ALL_AVAILABLE),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("turns ON only on an explicit true (opt-in)", () => {
|
||||
it("stays OFF even when the user opted in (the in-code switch wins)", () => {
|
||||
expect(
|
||||
resolveModuleEnabled(
|
||||
"inboundDocuments",
|
||||
@@ -388,16 +397,16 @@ describe("resolveModuleEnabled — inboundDocuments module (opt-in, default-OFF)
|
||||
false,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(true);
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("operator-off short-circuits even when the user opted in", () => {
|
||||
it("stays OFF when the user opted in and the operator left it available", () => {
|
||||
expect(
|
||||
resolveModuleEnabled(
|
||||
"inboundDocuments",
|
||||
inputs({ modulePreferences: { inboundDocuments: true } }),
|
||||
false,
|
||||
operator({ inboundDocuments: false }),
|
||||
operator({ inboundDocuments: true }),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
} from "./operator-availability";
|
||||
import {
|
||||
MODULE_KEYS,
|
||||
isCodeDisabledModule,
|
||||
isOptInModule,
|
||||
moduleDelegatesTo,
|
||||
type ModuleKey,
|
||||
@@ -126,6 +127,14 @@ export function resolveModuleEnabled(
|
||||
assistantCoach: boolean,
|
||||
operatorAvailability: OperatorModuleAvailability,
|
||||
): boolean {
|
||||
// LAYER 0 — switched off in code pending a rebuild. Hard-off for every
|
||||
// account, ahead of both the operator and the per-user layer, so no
|
||||
// stored preference or availability blob can re-surface it. See
|
||||
// `CODE_DISABLED_MODULE_KEYS` in ./registry.
|
||||
if (isCodeDisabledModule(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// LAYER 1 — operator server-wide availability. An operator-disabled
|
||||
// module is off for everyone regardless of personal preference.
|
||||
if (operatorAvailability[key] === false) {
|
||||
|
||||
@@ -327,6 +327,37 @@ export function isModuleKey(key: string): key is ModuleKey {
|
||||
return MODULE_KEY_SET.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modules switched OFF in code, pending a holistic rebuild.
|
||||
*
|
||||
* A key listed here is hard-off for every account regardless of the
|
||||
* per-user opt-in or the operator-availability layer: the gate short-
|
||||
* circuits it to disabled (`resolveModuleEnabled`), the Modules hub and the
|
||||
* operator-availability panel drop its row, and the per-user PATCH surface
|
||||
* refuses to write it. The whole implementation (routes, components, schema,
|
||||
* migration) stays intact — re-enabling the module is a one-line removal
|
||||
* from this list once the rebuild lands.
|
||||
*
|
||||
* v1.25.3 — `inboundDocuments` is parked here: the inbound-documents surface
|
||||
* is withdrawn from this release and returns later with more depth. Its
|
||||
* registry entry, `optIn` marker, routes, view, and migration 0222 are all
|
||||
* preserved; only the user-reachable switches are removed.
|
||||
*/
|
||||
export const CODE_DISABLED_MODULE_KEYS = ["inboundDocuments"] as const;
|
||||
|
||||
const CODE_DISABLED_MODULE_SET: ReadonlySet<string> = new Set(
|
||||
CODE_DISABLED_MODULE_KEYS,
|
||||
);
|
||||
|
||||
/**
|
||||
* True for a module intentionally switched off in code pending a rebuild
|
||||
* (see `CODE_DISABLED_MODULE_KEYS`). Such a module is hard-off everywhere:
|
||||
* the gate never reports it enabled and the user-facing toggles drop it.
|
||||
*/
|
||||
export function isCodeDisabledModule(key: ModuleKey): boolean {
|
||||
return CODE_DISABLED_MODULE_SET.has(key);
|
||||
}
|
||||
|
||||
/** The two delegated keys, resolved by their existing source of truth. */
|
||||
export function moduleDelegatesTo(
|
||||
key: ModuleKey,
|
||||
|
||||
Reference in new issue
Block a user