Merge branch 'v143/life' into release/v1.43.0

# Conflicts:
#	docs/api/openapi.yaml
#	src/__tests__/contract-stub-inventory.test.ts
#	tests/integration/sharing-manage-handler-matrix.test.ts
This commit is contained in:
Marc-André Bombeck committed 2026-10-16 03:39:40 +02:00
commit 4daad8f2fb
88 files changed
+8313 -1386

No files matched your search

+4 -14
View File
@@ -3,8 +3,8 @@
*
* v1.43 fixed its API contract before the features behind it were built: the
* routes exist, authenticate, gate and validate as documented, and answer
* `501 not_implemented` (`src/lib/http/not-implemented.ts`) until their
* feature lands. That is safe only while nothing reaches them, and nothing
* `501 not_implemented` until their feature lands (the helper was removed
* with the last stub; bring it back from history with the next one). That is safe only while nothing reaches them, and nothing
* should: every client path sits behind a `features` flag that stays `false`.
*
* This list is the debt register. A feature that lands removes its route here
@@ -23,20 +23,10 @@ import { walkSourceFiles } from "./helpers/source-files";
const API_ROOT = join(process.cwd(), "src", "app", "api");
/** Route file (under `src/app/api`) to the operations it still stubs. */
const CONTRACT_STUBS: Readonly<Record<string, readonly string[]>> = {
"anamnesis/audit-c/[id]/route.ts": ["anamnesis.audit_c.delete"],
"anamnesis/audit-c/route.ts": ["anamnesis.audit_c.create"],
"anamnesis/life-circumstances/ai-sections/route.ts": [
"anamnesis.life_circumstances.ai_sections.patch",
],
"anamnesis/life-circumstances/confirm/route.ts": [
"anamnesis.life_circumstances.confirm",
],
"anamnesis/life-circumstances/route.ts": ["anamnesis.life_circumstances.get"],
};
const CONTRACT_STUBS: Readonly<Record<string, readonly string[]>> = {};
/** The size of the register when it was written; see the header. */
const REGISTER_SIZE = 5;
const REGISTER_SIZE = 0;
function routeFiles(): string[] {
return walkSourceFiles(API_ROOT, { floor: 400, extensions: [".ts"] })
@@ -403,8 +403,23 @@ const REGISTRY: DestructiveEntry[] = [
confirm: ["DeleteButton"],
},
{
file: "components/records/health-profile-facts-manager.tsx",
destroys: "the current value of one effective-dated health-profile fact",
file: "components/records/life-circumstances-manager.tsx",
destroys:
"the current answer of one life-circumstance fact, when a section is saved with it set back to no answer",
recovery: "tombstoned-no-restore",
confirm: [],
unconfirmed: [
{
control:
"Save section with a field set back to no answer — life-circumstances-manager.tsx",
reason:
"Setting a question back to no answer and pressing Save is the deliberate act itself, made field by field inside a form the person is editing, with the old answer visible until they change it. The delete closes the answer's interval rather than erasing it, so the dated history keeps it, and answering again takes one select. A second dialog on top of an explicit form edit would make correcting an answer dearer than giving it.",
},
],
},
{
file: "components/records/audit-c-panel.tsx",
destroys: "one AUDIT-C entry from the alcohol history",
recovery: "tombstoned-no-restore",
confirm: ["ConfirmButton"],
},
+25 -3
View File
@@ -893,7 +893,15 @@ const DELEGABLE_ROUTES: Record<string, DelegableEntry> = {
},
"app/api/anamnesis/life-circumstances/route.ts": {
domain: "profile",
why: "The record's life circumstances (v1.43), the structured sibling of the facts above and under the same `profile` grant. Read-only: the section switches, confirmations and AUDIT-C are written through their own routes, none of them delegable.",
why: "The record's life circumstances (v1.43), the structured sibling of the facts above and under the same `profile` grant. Read-only: the section switches and confirmations are written through their own owner-only routes; AUDIT-C through the manage-level pair below.",
},
"app/api/anamnesis/audit-c/route.ts": {
domain: "profile",
why: "Recording an AUDIT-C (v1.43) into the record, the alcohol section of the life circumstances. Reached only through its MANAGE arm, the level allergies and family history are written at; the entry is scored on the server against the record's profile.",
},
"app/api/anamnesis/audit-c/[id]/route.ts": {
domain: "profile",
why: "Removing one AUDIT-C entry of the record, scoped `userId: user.id` and `instrument: AUDIT_C` in the guarded update, so a foreign id or a screener id is a 404. Reached only through its MANAGE arm.",
},
"app/api/profile/summary/route.ts": {
domain: "profile",
@@ -1630,6 +1638,16 @@ const DELEGABLE_MANAGE_ROUTES: Record<string, ManageEntry> = {
conditions: [],
why: "Recording an allergy. Reachable through the record's settings on a managed profile, dormant on an invited one, and argued as such.",
},
"app/api/anamnesis/audit-c/route.ts": {
domain: "profile",
conditions: ["C1"],
why: "Recording an AUDIT-C (v1.43) in the record a manager runs, like an allergy. C1: the 30-an-hour bucket keys on the actor. Arithmetic on three answers, no generation; the trail files the entry id and instrument, never the answers.",
},
"app/api/anamnesis/audit-c/[id]/route.ts": {
domain: "profile",
conditions: [],
why: "Removing an AUDIT-C entry is a soft delete (`deletedAt`), so the row stays to reconstruct and the delete needs no C3; it is the counterpart of the create beside it.",
},
"app/api/allergies/[id]/route.ts": {
domain: "profile",
conditions: ["C3", "C4"],
@@ -2142,8 +2160,12 @@ const ACTOR_ROUTES: Record<string, string> = {
* v1.43 -- a supplement's composition joins the record list and the manage
* literal: its PUT replaces the composition every taken dose counts with.
* 260 -> 262.
*
* v1.43 -- AUDIT-C's create and soft delete join the record list and the
* manage literal under `profile`, the level allergies are written at.
* 262 -> 266.
*/
const FROZEN_ENTRY_COUNT = 262;
const FROZEN_ENTRY_COUNT = 266;
/**
* The two surfaces that authenticate a Bearer token outside `requireAuth` —
@@ -2904,7 +2926,7 @@ describe("(g) the MANAGE route set is frozen", () => {
it("keeps the admitted mutation inventory complete and discoverable", () => {
expect(ADMITTED_MUTATING_HANDLERS.length).toBeGreaterThan(0);
expect(ADMITTED_MUTATING_HANDLERS.length).toBe(90);
expect(ADMITTED_MUTATING_HANDLERS.length).toBe(92);
const expected = ADMITTED_MUTATING_HANDLERS.map(
({ handlerModule, action, level }) =>
+11 -1
View File
@@ -508,7 +508,17 @@ const RESULT_SURFACES: ReadonlyArray<{
forbidsMarkers: true,
},
{
path: "src/components/records/health-profile-facts-manager.tsx",
path: "src/components/records/life-circumstances-manager.tsx",
through: /toastWrittenOutcome/,
forbidsMarkers: true,
},
{
path: "src/components/records/audit-c-panel.tsx",
through: /toastWrittenOutcome/,
forbidsMarkers: true,
},
{
path: "src/components/records/free-text-take-over.tsx",
through: /toastWrittenOutcome/,
forbidsMarkers: true,
},
+3 -1
View File
@@ -47,7 +47,6 @@ const REQUIRED_KEYS = [
"insights.healthScore.versionAndNoise",
"insights.healthScore.methodVersion",
"insights.healthScore.source",
"records.profileFacts.save",
"records.allergies.add",
"records.allergies.addFirst",
"records.family.add",
@@ -62,6 +61,9 @@ const OBSOLETE_KEYS = [
"insights.healthScore.composition",
"documents.detail.summary.regenerate",
"records.profileFacts.correct",
// v1.43 — the profile-facts card became the life-circumstances card, whose
// sections save on their own.
"records.profileFacts.save",
"settings.nightscoutPrivateHost",
"settings.nightscoutPrivateHostHelp",
] as const;
@@ -26,7 +26,7 @@ describe("sharing and handler inventories", () => {
});
it("keeps every admitted mutation uniquely addressable and fully controlled", () => {
expect(ADMITTED_MUTATING_HANDLERS).toHaveLength(90);
expect(ADMITTED_MUTATING_HANDLERS).toHaveLength(92);
expect(
new Set(
ADMITTED_MUTATING_HANDLERS.map(