mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
style: satisfy v1.34.1 format gate
This commit is contained in:
1 parent
b0a94b3423
commit
75aa850eae
10 files changed
+71
-59
No files matched your search
@@ -25,7 +25,13 @@ const REQUIRED_FIELDS = [
|
||||
"Confidence",
|
||||
"Unresolved",
|
||||
];
|
||||
const ALLOWED_STATUS = new Set(["confirmed", "suspected", "blocked", "cleared", "refuted"]);
|
||||
const ALLOWED_STATUS = new Set([
|
||||
"confirmed",
|
||||
"suspected",
|
||||
"blocked",
|
||||
"cleared",
|
||||
"refuted",
|
||||
]);
|
||||
const ALLOWED_SEVERITY = new Set(["critical", "high", "medium", "low", "info"]);
|
||||
const ALLOWED_CONFIDENCE = new Set(["high", "medium", "low"]);
|
||||
const REQUIRED_SOURCES = ["research:", "correctness:", "live:", "performance:"];
|
||||
@@ -41,7 +47,10 @@ const PRIVACY_PATTERNS = [
|
||||
name: "email address",
|
||||
pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i,
|
||||
},
|
||||
{ name: "authorization credential", pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]+/i },
|
||||
{
|
||||
name: "authorization credential",
|
||||
pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]+/i,
|
||||
},
|
||||
{
|
||||
name: "secret assignment",
|
||||
pattern:
|
||||
@@ -90,7 +99,8 @@ try {
|
||||
}
|
||||
|
||||
for (const check of PRIVACY_PATTERNS) {
|
||||
if (check.pattern.test(source)) errors.push(`privacy-dangerous ${check.name} detected`);
|
||||
if (check.pattern.test(source))
|
||||
errors.push(`privacy-dangerous ${check.name} detected`);
|
||||
}
|
||||
|
||||
const headingPattern = /^## (AUD-\d{3}) — (.+)$/gm;
|
||||
@@ -149,7 +159,8 @@ for (let index = 0; index < headings.length; index += 1) {
|
||||
errors.push(`${id}: ${status} findings must set Unresolved to no`);
|
||||
}
|
||||
if (sourceField) {
|
||||
if (sourceRecords.has(sourceField)) errors.push(`${id}: duplicate Source record`);
|
||||
if (sourceRecords.has(sourceField))
|
||||
errors.push(`${id}: duplicate Source record`);
|
||||
sourceRecords.add(sourceField);
|
||||
}
|
||||
|
||||
@@ -164,7 +175,9 @@ for (let index = 0; index < records.length; index += 1) {
|
||||
}
|
||||
|
||||
for (const prefix of REQUIRED_SOURCES) {
|
||||
if (!records.some((record) => record.fields.get("Source")?.includes(prefix))) {
|
||||
if (
|
||||
!records.some((record) => record.fields.get("Source")?.includes(prefix))
|
||||
) {
|
||||
errors.push(`missing source family ${prefix}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ function fail(message) {
|
||||
}
|
||||
|
||||
if (!fixtureMode) {
|
||||
fail("refusing to run without --fixture; live and production probes are unsupported");
|
||||
fail(
|
||||
"refusing to run without --fixture; live and production probes are unsupported",
|
||||
);
|
||||
}
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
fail("refusing to run with NODE_ENV=production");
|
||||
@@ -43,7 +45,9 @@ if (!outputPath) {
|
||||
fail("--output <markdown-path> is required");
|
||||
}
|
||||
if (args.some((arg) => /^(--url|--host|--database|--token|--live)/.test(arg))) {
|
||||
fail("network, database, credential, and live-target arguments are unsupported");
|
||||
fail(
|
||||
"network, database, credential, and live-target arguments are unsupported",
|
||||
);
|
||||
}
|
||||
|
||||
const startedAt = performance.now();
|
||||
@@ -63,7 +67,9 @@ function seededNumber(index, salt) {
|
||||
}
|
||||
|
||||
function percentile(sorted, fraction) {
|
||||
return sorted[Math.min(sorted.length - 1, Math.ceil(sorted.length * fraction) - 1)];
|
||||
return sorted[
|
||||
Math.min(sorted.length - 1, Math.ceil(sorted.length * fraction) - 1)
|
||||
];
|
||||
}
|
||||
|
||||
function formatMs(value) {
|
||||
@@ -94,7 +100,10 @@ function benchmark(name, operation) {
|
||||
}
|
||||
const elapsed = warm.map((sample) => sample.elapsedMs).sort((a, b) => a - b);
|
||||
const heaps = warm.map((sample) => sample.heapDeltaBytes);
|
||||
const checksums = new Set([cold.result.checksum, ...warm.map((sample) => sample.result.checksum)]);
|
||||
const checksums = new Set([
|
||||
cold.result.checksum,
|
||||
...warm.map((sample) => sample.result.checksum),
|
||||
]);
|
||||
if (checksums.size !== 1) {
|
||||
throw new Error(`${name} fixture produced a non-deterministic checksum`);
|
||||
}
|
||||
@@ -213,7 +222,8 @@ function healthScoreFixture() {
|
||||
domainCounts[row.domain] += 1;
|
||||
}
|
||||
let checksum = 0;
|
||||
for (const row of dailyCanonical.values()) checksum = (checksum + row.value) >>> 0;
|
||||
for (const row of dailyCanonical.values())
|
||||
checksum = (checksum + row.value) >>> 0;
|
||||
for (let domain = 0; domain < domainTotals.length; domain += 1) {
|
||||
const normalized = Math.round(domainTotals[domain] / domainCounts[domain]);
|
||||
checksum = (checksum * 31 + normalized) >>> 0;
|
||||
|
||||
@@ -56,7 +56,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
if (parsed.data.method === "password") {
|
||||
proved = Boolean(
|
||||
user.passwordHash &&
|
||||
(await verifyPassword(user.passwordHash, parsed.data.password)),
|
||||
(await verifyPassword(user.passwordHash, parsed.data.password)),
|
||||
);
|
||||
} else if (parsed.data.method === "totp") {
|
||||
const result = await verifyMfaFactor(user, "totp", parsed.data.code);
|
||||
|
||||
@@ -53,8 +53,7 @@ vi.mock("@/lib/ai/coach/tools/inventory", () => ({
|
||||
buildCoachDataInventory: vi.fn(),
|
||||
}));
|
||||
vi.mock("@/lib/mcp/server", async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import("@/lib/mcp/server")>();
|
||||
const actual = await importOriginal<typeof import("@/lib/mcp/server")>();
|
||||
return {
|
||||
...actual,
|
||||
createMcpServer: (...args: Parameters<typeof actual.createMcpServer>) => {
|
||||
|
||||
@@ -106,10 +106,7 @@ export async function parseAppleHealthEcgCsv(input: {
|
||||
}
|
||||
const [key, value] = pair;
|
||||
if (!inSamples) {
|
||||
if (
|
||||
key.toLowerCase() === "lead" &&
|
||||
value.toLowerCase() === "voltage"
|
||||
) {
|
||||
if (key.toLowerCase() === "lead" && value.toLowerCase() === "voltage") {
|
||||
inSamples = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -629,9 +629,7 @@ describe("Mounjaro rolling weekly — canonical overdue band after day change",
|
||||
now: d("2026-07-29T10:00:00.000Z"),
|
||||
userTz: BERLIN,
|
||||
lastIntakeAt:
|
||||
status === "taken"
|
||||
? d("2026-07-28T06:10:00.000Z")
|
||||
: lastTaken,
|
||||
status === "taken" ? d("2026-07-28T06:10:00.000Z") : lastTaken,
|
||||
resolvedSlots: [
|
||||
identifiedMark(missedOccurrence, {
|
||||
scheduleId: "mounjaro-weekly",
|
||||
|
||||
@@ -367,22 +367,22 @@ describe("B5b — MCP health reads require an explicit read grant", () => {
|
||||
);
|
||||
|
||||
it.each([
|
||||
[
|
||||
"expired",
|
||||
{ expiresAt: new Date("2020-01-01T00:00:00.000Z") },
|
||||
],
|
||||
["expired", { expiresAt: new Date("2020-01-01T00:00:00.000Z") }],
|
||||
["revoked", { revoked: true }],
|
||||
])("denies an explicit but %s health:read credential", async (_label, state) => {
|
||||
const raw = await armExpiringToken(
|
||||
["health:read"],
|
||||
`mcp-${_label}`,
|
||||
state,
|
||||
);
|
||||
])(
|
||||
"denies an explicit but %s health:read credential",
|
||||
async (_label, state) => {
|
||||
const raw = await armExpiringToken(
|
||||
["health:read"],
|
||||
`mcp-${_label}`,
|
||||
state,
|
||||
);
|
||||
|
||||
const res = await postMcp(raw, "tools/list");
|
||||
const res = await postMcp(raw, "tools/list");
|
||||
|
||||
expect([401, 403]).toContain(res.status);
|
||||
});
|
||||
expect([401, 403]).toContain(res.status);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("B6 — a declared scope grants only what it names", () => {
|
||||
|
||||
@@ -209,9 +209,9 @@ describe("MCP OAuth refresh rotation (real PostgreSQL)", () => {
|
||||
responses.map((response) => response.json() as Promise<TokenBody>),
|
||||
);
|
||||
const returnedSuccessors = bodies.filter(
|
||||
(body): body is Required<
|
||||
Pick<TokenBody, "access_token" | "refresh_token">
|
||||
> =>
|
||||
(
|
||||
body,
|
||||
): body is Required<Pick<TokenBody, "access_token" | "refresh_token">> =>
|
||||
typeof body.access_token === "string" &&
|
||||
typeof body.refresh_token === "string",
|
||||
);
|
||||
|
||||
@@ -18,8 +18,7 @@ vi.mock("@/lib/rollups/medication-compliance-rollups", () => ({
|
||||
recomputeMedicationComplianceForEvent: vi.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
|
||||
const { dispatchNotification } =
|
||||
await import("@/lib/notifications/dispatcher");
|
||||
const { dispatchNotification } = await import("@/lib/notifications/dispatcher");
|
||||
const { handleReminderCheck } =
|
||||
await import("@/lib/jobs/reminder/medication-reminder-check");
|
||||
|
||||
|
||||
@@ -100,25 +100,21 @@ async function readConsumerOccurrence(
|
||||
const medication = raw as unknown as DueDerivationMedication;
|
||||
const listOccurrence = medication.nextDueAt ?? null;
|
||||
|
||||
const dashboard = await buildMedsTodayBlock(
|
||||
prisma,
|
||||
USER_ID,
|
||||
USER_TZ,
|
||||
NOW,
|
||||
);
|
||||
const dashboard = await buildMedsTodayBlock(prisma, USER_ID, USER_TZ, NOW);
|
||||
|
||||
// A prior-day rolling slot is outside today's clock window. The GLP-1
|
||||
// card therefore displays the server's canonical nextDueAt verbatim.
|
||||
const glp1Occurrence = resolveDisplayedSlotInstant({
|
||||
currentWindowStatus: {
|
||||
status: null,
|
||||
schedule: null,
|
||||
window: null,
|
||||
},
|
||||
nextDueAt: listOccurrence,
|
||||
now: NOW,
|
||||
timeZone: USER_TZ,
|
||||
})?.toISOString() ?? null;
|
||||
const glp1Occurrence =
|
||||
resolveDisplayedSlotInstant({
|
||||
currentWindowStatus: {
|
||||
status: null,
|
||||
schedule: null,
|
||||
window: null,
|
||||
},
|
||||
nextDueAt: listOccurrence,
|
||||
now: NOW,
|
||||
timeZone: USER_TZ,
|
||||
})?.toISOString() ?? null;
|
||||
|
||||
const takeAll = deriveDueMedications([medication], {
|
||||
now: NOW,
|
||||
@@ -144,8 +140,10 @@ async function readConsumerOccurrence(
|
||||
)?.overdue ?? false,
|
||||
},
|
||||
glp1Card: glp1Occurrence,
|
||||
takeAllDue: takeAll.find((entry) => entry.id === medicationId)
|
||||
?.scheduledFor?.toISOString() ?? null,
|
||||
takeAllDue:
|
||||
takeAll
|
||||
.find((entry) => entry.id === medicationId)
|
||||
?.scheduledFor?.toISOString() ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -178,9 +176,7 @@ describe("rolling weekly overdue occurrence — shared consumers", () => {
|
||||
medicationId,
|
||||
scheduledFor: OVERDUE_OCCURRENCE,
|
||||
takenAt:
|
||||
status === "taken"
|
||||
? new Date("2026-07-28T06:10:00.000Z")
|
||||
: null,
|
||||
status === "taken" ? new Date("2026-07-28T06:10:00.000Z") : null,
|
||||
skipped: status === "skipped",
|
||||
autoMissed: status === "autoMissed",
|
||||
source: "WEB",
|
||||
|
||||
Reference in new issue
Block a user