Compare commits

..

13 Commits

Author SHA1 Message Date
renovate-bot 7b5d686936 Update dependency lucide-static to v1.73.0
CI / full-gate (push) Successful in 4m26s
Mirror / github-mirror (push) Successful in 3s
Release / retag-image (push) Successful in 19s
Release / publish-overview (push) Successful in 4s
Release-Bump: minor
2026-11-17 04:18:56 +00:00
lilleman 5dba86fbc0 Predict touches for release 0.6.0 items
CI / full-gate (push) Successful in 4s
Mirror / github-mirror (push) Successful in 4s
2026-11-17 01:35:45 +01:00
lilleman a22de926e2 Finish item 72 in the plan
CI / full-gate (push) Successful in 3m33s
Mirror / github-mirror (push) Successful in 4s
2026-11-17 01:22:35 +01:00
lilleman 109b7b3215 Finish item 65 in the plan 2026-11-17 01:22:35 +01:00
lilleman 8ddbcec4b6 Answer stability round 2: 0 🔴, 1 🟡 (0 misread); kill the cycle mutant with a test, restore two spaces
CI / full-gate (push) Successful in 3m25s
2026-11-17 01:22:23 +01:00
lilleman b8ee23d9d5 Answer prose round 1: 0 🔴, 3 🟡 (0 misread); reword the header, test comments and changelog 2026-11-17 01:17:57 +01:00
lilleman 1e906a3d42 Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); notice and log an emptied group 2026-11-17 01:17:57 +01:00
lilleman f3500ff81d Answer stability round 1: 1 🔴, 2 🟡 (0 misread); empty a group once all its members are gone in a diamond, log the cascade, notice an emptied group 2026-11-17 01:17:57 +01:00
lilleman 37e7227dea Export KetoError from the plugin barrel, and delete a group's grants and parent memberships when its last member leaves
CI / full-gate (push) Failing after 54s
2026-11-17 01:04:16 +01:00
lilleman 852137982d Record the comprehension check: scoring run of PR 247, overall mean 7.13
CI / full-gate (push) Successful in 3m22s
Mirror / github-mirror (push) Successful in 3s
2026-11-17 00:56:14 +01:00
lilleman 7e8bdd9c39 Keep one shared Keto Resource namespace, document the <resource>:<row-id> object name, fix the README per-row example
CI / full-gate (push) Successful in 4m30s
2026-11-17 00:22:03 +01:00
renovate-bot be8f198b00 Update dependency @larvit/log to v2.6.1
CI / full-gate (push) Successful in 4m16s
Mirror / github-mirror (push) Successful in 3s
Release / retag-image (push) Successful in 18s
Release / publish-overview (push) Successful in 3s
Release-Bump: minor
2026-11-16 04:18:09 +00:00
renovate-bot e263344897 Update Playwright to v1.65.1
CI / full-gate (push) Successful in 5m59s
Mirror / github-mirror (push) Successful in 3s
2026-11-15 04:18:43 +00:00
21 changed files with 401 additions and 102 deletions
+1
View File
@@ -98,6 +98,7 @@ on; a review honours them.
- A permission name is always `<resource>:<action>`, enforced at discovery
- Permission names are authored in plugin code; only grants live in Keto
- A permission's `<resource>` is global, not plugin-scoped
- The `Resource` namespace is shared by all plugins, and an object is `<resource>:<row-id>`
- Declaring a permission stays optional
- `ADMIN_PERMISSIONS` defaults to empty, and an unusable value is dropped with a warning
- `actionForMethod` is plugin-local and stays out of `@plainpages/plugin-api`
+22 -2
View File
@@ -12,6 +12,12 @@ The host's contract version is now 0.5.0, so discovery refuses a plugin whose `a
`0.4.x`. Change the literal in each plugin's manifest when you upgrade, and add `assetHref` to any
`RequestContext` your tests build by hand: `assetHref: (href) => href`.
### `@plainpages/plugin-api` exports `KetoError`
A plugin that calls `ctx.system.keto` can tell a Keto failure from any other error with
`instanceof KetoError`, as it already can a `KratosError` or a `HydraError`. The error carries the HTTP
`status`. It adds to the plugin API, so an installed plugin needs no change.
### The core dashboard view is `dashboard`, not `index`
`views/index.ejs` is now `views/dashboard.ejs`. The `apiVersion` check can't see this: a plugin view
@@ -34,8 +40,15 @@ and answers with the error page. It used to leave some grants gone and the membe
Deleting a group now also removes it from every group it was a member of, in the same Keto
transaction as the rest. It used to stay listed there, so a group re-created with the same name was
back in every parent. A parent whose only member was the deleted group is left with no members, and
so no longer exists as a group.
back in every parent.
### The admin example removes a group's grants and parent memberships when its last member leaves
A group with no members no longer exists, and now neither do its grants or its memberships in other
groups. This holds when the last member is removed, and the group page then says so. It also holds
when deleting a group leaves its parent with no members, and so on up through each ancestor left
empty. A group re-created with the same name used to get the old group's permissions and parents back.
Groups already left empty by an earlier version keep theirs, and re-creating one still restores them.
### The admin example keeps a user's permissions section when it refuses a self-deactivate or self-delete
@@ -263,6 +276,13 @@ proxy in front of Plainpages can't store a signed-in page and serve it to the ne
whose page is the same for everyone can still set its own `cache-control` through
`RouteResult.headers`; assets are unchanged.
### A per-row Keto grant names its object `<resource>:<row-id>`
`Resource` is one namespace shared by every plugin, so a bare row id (`4471`) lets two plugins' rows
share one grant. Name the object `shift:4471`, with the same `<resource>` word as your permissions.
Nothing checks this. The README's per-row example now does, and checks the `edit` permit, not the
`editors` relation, so an owner passes.
## 0.4.0
**Breaking.** Set `apiVersion: "0.4.0"`. The app shell no longer bounds the content column, so a page
+11 -2
View File
@@ -249,7 +249,7 @@ Keto relation tuples: `Permission:<name>#granted@user:<id>`, or `@Group:<name>#m
| **User** | Kratos | who you are | `user:0198f2c1-…` |
| **Group** | Keto | who — a reusable set | `Group:support` |
| **Permission** | Keto | what you may do | `Permission:scheduling:read` |
| **Resource** | Keto | which specific row | `Resource:shift-4471` |
| **Resource** | Keto | which specific row | `Resource:shift:4471` |
Keto's whole model is one primitive — `namespace:object#relation@subject` — so those four
namespaces are *ours*, declared in `ory/keto/namespaces.keto.ts`; Keto resolves them, transitively
@@ -359,6 +359,15 @@ The `Resource` namespace covers what a coarse permission cannot express: *this*
*this* person. A `Resource` carries Keto `permits` (`view`, `edit`, `delete`, nesting as `owner` ⊇
`editor` ⊇ `viewer`) and never appears in the JWT.
> **Warning: name the object `<resource>:<row-id>`, never the bare row id.** `Resource` is one
> namespace shared by every plugin, and Keto stores the object as an opaque string. Two plugins that
> each have a row `4471` and both write `object: "4471"` share one grant: whoever may edit shift
> 4471 may edit invoice 4471. Prefix every object with the same `<resource>` word your permissions
> use (`shift:4471`, `invoice:4471`). Nothing checks this, at boot or at runtime. Check a *permit*
> (`view`, `edit`, `delete`), not a stored relation (`owners`, `editors`, `viewers`), so an owner
> passes an `edit` check. A plugin that needs relations `Resource` can't express adds its own class
> to `ory/keto/namespaces.keto.ts`.
**A per-row grant never widens a coarse gate** — the route's `permission` is checked before the
handler runs. Gate the route on something they hold, then narrow inside the handler:
@@ -366,7 +375,7 @@ handler runs. Gate the route on something they hold, then narrow inside the hand
{ method: "POST", path: "/shifts/:id", permission: READ, handler: editShift }
async function editShift(ctx) {
if (!(await check(keto, ctx, { namespace: "Resource", object: ctx.params.id, relation: "editors" })))
if (!(await check(keto, ctx, { namespace: "Resource", object: `shift:${ctx.params.id}`, relation: "edit" })))
throw new GuardError(403, "not an editor of this shift");
…
}
+36
View File
@@ -600,3 +600,39 @@ Inherited architect, would restructure first:
- Locality: `src/http/app.ts:202` `Host`: 19 fields, and a new request capability touches four files
- Shape, Self-sufficiency: `examples/plugins/auth-admin/admin-shared.ts:107` `FieldConfig`: the type for a core partial's option shape lives in an example plugin
- Locality: `src/auth/login.ts:48` `readPermissions`: a second copy of the Keto paging loop that nothing says the barrel boundary forces
## 2026-11-16T23:56:01Z, PR #247 at 7e8bdd9
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Junior A | 7.5 | 6.5 | 7 | 6.5 | 7 |
| Mid A | 8 | 7 | 7 | 7 | 7.5 |
| Maintainability senior | 7.5 | 6 | 7 | 7 | 7 |
| Inherited architect | 7 | 7 | 6.5 | 7 | 7 |
| Mean | 7.50 | 6.63 | 6.88 | 6.88 | 7.13 |
Junior A, hardest first:
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines of closures that refer to each other, `switchBase` reads `builtinRoutes` declared later
- Locality: `src/http/app.ts:263` `prepareRequest`: chrome is memoized lazily twice, and an untyped `shared` bag feeds `buildContext`
- Self-sufficiency: `src/auth/routes.ts:58` `flowFailure`: six branches keyed on Kratos statuses that nothing in the file explains
- Locality: `src/server.ts:25` `delete process.env["PLUGIN_DB_SECRET"]`: a load-bearing order rule in a top-level script
Mid A, hardest first:
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines, 20 option fields, route table and `switchBase` refer to each other
- Locality: `src/http/app.ts:263` `prepareRequest`: implicit stage order, three ways to get a context
- Self-sufficiency: `src/auth/routes.ts:58` `flowFailure`: the Kratos status meanings are unexplained
Maintainability senior, hardest first:
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines, a dozen closures calling each other
- Locality: `src/i18n/locale.ts:81` `chosenLocale`: recovers "was a locale requested" from `localeHref("/") === "/"`, so the name hides the mechanism
- Locality: `views/partials/data-table.ejs:74` include: EJS locals leak from page to partial, defended by explicit null options
- Self-sufficiency: `examples/plugins/auth-admin/admin-groups.ts:434` `groupsDelete`: its comment ends with a pointer to `todo.md`
Inherited architect, would restructure first:
- Navigation, Shape, Overall: `src/auth/bootstrap.ts:1` `src/auth`: 20 files over four concerns, and `bootstrap.ts` belongs to none of them
- Shape: `public/css/styles.css:81` dark and light palette mapping: the same token list written three times
- Locality: `src/http/app.ts:202` `Host`: restates the options and locals a third time, so a new capability touches several files
+12
View File
@@ -209,6 +209,18 @@ Hence `oauth2-clients`, not `clients`. Users are the host's, and plugins share t
that collision-freedom is a convention rather than structural; the alternative penalizes the
sharing case.
## The `Resource` namespace is shared by all plugins, and an object is `<resource>:<row-id>`
2026-11-17, the maintainer. Goal 7. Valid while no plugin needs a relation `Resource` can't express.
Ory's examples use one namespace per domain (`Shift`, `Document`). Splitting here would make an
operator edit `ory/keto/namespaces.keto.ts` for every plugin, so a drop-in stops being drop-in, and
a missing namespace fails on the first request rather than at boot. It also breaks the contract
(a minor) for a tier no shipped code uses. One namespace with the kind in the object follows the
`<resource>` rule above and `Permission:<resource>:<action>`. The cost is that nothing enforces
the prefix, so a bare row id lets two plugins share a grant; the README warns of it. A plugin that
needs its own relations adds a class to the OPL file, which already works. Revisit when one does.
## Declaring a permission stays optional
2026-08-05, the maintainer. Goal 7. Valid while plugins may share a permission.
+17
View File
@@ -581,3 +581,20 @@ Read most (opens and searches):
- `src/function-limits.test.ts` 2
- `AGENTS.md` 1
- `CHANGELOG.md` 1
## Reading cost, chunk f1bfd1c341a4, finished 2026-11-09T00:42:43Z
84281 new input tokens before the first commit.
Read most (opens and searches):
- `todo.md` 9
- `README.md` 5
- `examples/plugins/auth-admin/admin-groups.ts` 5
- `examples/plugins/auth-admin/admin-shared.ts` 5
- `src/auth/keto-client.ts` 5
- `AGENTS.md` 3
- `examples/plugins/auth-admin/admin-users.ts` 3
- `src/auth/hydra-admin.ts` 3
- `src/http/app-admin.test.ts` 3
- `CHANGELOG.md` 2
+1 -1
View File
@@ -1,6 +1,6 @@
# Playwright runner — browsers preinstalled, pinned to match @playwright/test in e2e-tests/.
# Built/run via e2e-tests/compose.visual.yml; targets the `web` service over the network.
FROM mcr.microsoft.com/playwright:v1.65.0-noble
FROM mcr.microsoft.com/playwright:v1.65.1-noble
WORKDIR /e2e-tests
+12 -12
View File
@@ -6,19 +6,19 @@
"": {
"name": "plainpages-e2e",
"devDependencies": {
"@playwright/test": "1.65.0",
"@playwright/test": "1.65.1",
"@types/node": "26.6.6",
"typescript": "7.0.2"
}
},
"node_modules/@playwright/test": {
"version": "1.65.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz",
"integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==",
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.65.0"
"playwright": "1.65.1"
},
"bin": {
"playwright": "cli.js"
@@ -378,13 +378,13 @@
}
},
"node_modules/playwright": {
"version": "1.65.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz",
"integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==",
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.65.0"
"playwright-core": "1.65.1"
},
"bin": {
"playwright": "cli.js"
@@ -394,9 +394,9 @@
}
},
"node_modules/playwright-core": {
"version": "1.65.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz",
"integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==",
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
+1 -1
View File
@@ -8,7 +8,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@playwright/test": "1.65.0",
"@playwright/test": "1.65.1",
"@types/node": "26.6.6",
"typescript": "7.0.2"
}
+55 -21
View File
@@ -1,8 +1,9 @@
// Groups admin screen: list / create / delete Keto groups and manage membership.
// A group is a Keto subject set `Group:<name>#members`; a member is a user or a nested group (see
// parseSubject). Writes go only to Keto (README "stateless"). Keto has no "create object" — a group
// exists exactly while it has ≥1 member, so create writes its first-member tuple and delete removes
// every tuple that makes it a group or puts it in another. Pure builders turn tuples + the request URL into view models; below them are thin
// parseSubject). Writes go only to Keto (README "stateless"). Keto has no "create object": a group
// exists exactly while it has ≥1 member, so create writes its first-member tuple, and removing the
// last member deletes the group (see `withEmptiedGroups`).
// Pure builders turn tuples + the request URL into view models; below them are thin
// per-route handlers (keyed on ctx.params) over a shared `withGroups` gate — admin-only, CSRF-guarded,
// each returning a RouteResult.
@@ -369,7 +370,7 @@ async function groupDetailPage({ ctx, keto, kratosAdmin }: GroupsDeps, name: str
// GET /auth-admin/groups/:name — the detail + membership page.
export const groupsDetail = withGroupName((deps, name) =>
groupDetailPage(deps, name, { notice: grantsNotice(deps.ctx.url, deps.ctx.t) ?? "" }));
groupDetailPage(deps, name, { notice: grantsNotice(deps.ctx.url, deps.ctx.t) ?? emptiedNotice(deps.ctx.url, deps.ctx.t) ?? "" }));
// POST /auth-admin/groups/:name/permissions — the submitted checkboxes are the desired set. Members hold
// a group's permissions transitively, so the change reaches them at their next login or re-mint —
@@ -419,26 +420,56 @@ export const groupsDeleteConfirm = withGroupName(async (deps, name) => {
}) }, view: "confirm" };
}, "write");
// POST /auth-admin/groups/:name/delete — one Keto transaction removes the group's member tuples,
// the tuples naming it as a member of a parent group, and the grants it holds, so a Keto failure
// leaves the group as it was.
const EMPTIED_NOTICE = "group-emptied"; // the `info-msg` that removing a group's last member redirects with
const emptiedNotice = (url: URL, t: Translate): string | undefined =>
url.searchParams.get("info-msg") === EMPTIED_NOTICE ? t("admin.groups.emptied") : undefined;
const tupleId = (t: RelationTuple): string => {
const subject = t.subject_set ? `${t.subject_set.namespace}:${t.subject_set.object}#${t.subject_set.relation}` : t.subject_id;
return `${t.namespace}:${t.object}#${t.relation}@${subject}`;
};
// A group exists only through its members. Once `removing` leaves one of `groups` with none, the
// grants on its name and its memberships in other groups must go too, or re-creating the name would
// restore them. Emptying a group can empty its parents, so the walk climbs from each emptied group to
// the groups it is in, and a group left with a member ends that branch. Returns every tuple to delete
// (`removing` and those) and the emptied groups. A member added by another admin between these reads
// and the transaction lands in a stripped group: Keto has no conditional write.
async function withEmptiedGroups(keto: KetoClient, removing: readonly RelationTuple[], groups: readonly string[]): Promise<{ delete: RelationTuple[]; emptied: string[] }> {
const doomed = new Map(removing.map((t) => [tupleId(t), t]));
const pending = [...groups];
const emptied = new Set<string>(); // also ends the walk on a nesting cycle
for (let group = pending.pop(); group !== undefined; group = pending.pop()) {
if (emptied.has(group)) continue;
const members = await pagedTuples(keto, { namespace: GROUP_NS, object: group, relation: MEMBERS });
if (members.some((m) => !doomed.has(tupleId(m)))) continue; // may be reached again, by a sibling emptied later
emptied.add(group);
const subject = groupSubject(group);
const grants = (await heldPermissions(keto, subject)).map((permission) => grantTuple(permission, subject));
const inParents = await pagedTuples(keto, { namespace: GROUP_NS, relation: MEMBERS, ...subject });
for (const t of [...grants, ...inParents]) doomed.set(tupleId(t), t);
pending.push(...inParents.map((t) => t.object));
}
return { delete: [...doomed.values()], emptied: [...emptied] };
}
// Logged with the groups that lost their grants, since the screen doesn't list them.
function logEmptied(deps: GroupsDeps, event: string, name: string, cascade: { delete: RelationTuple[]; emptied: string[] }): void {
const revoked = new Set(cascade.delete.filter((t) => t.namespace !== GROUP_NS).map((t) => t.object));
deps.ctx.log.info(event, { actor: deps.user.id, emptied: cascade.emptied.join(","), group: name, revoked: [...revoked].sort().join(",") });
}
// POST /auth-admin/groups/:name/delete — one Keto transaction removes the group's member tuples and
// everything `withEmptiedGroups` finds, so a Keto failure leaves the group as it was.
export const groupsDelete = withGroupName(async (deps, name) => {
const { ctx, keto, user } = deps;
const { ctx, keto } = deps;
await guardedForm(ctx); // CSRF-verify the POST
const lost = await lostOnDelete(deps, name);
if (lost.length > 0) return refuseSelfLockout(deps, name, "delete", lost);
// A Keto set exists only through its tuples, so leaving the grants or the parents' membership
// tuples behind would resurrect every permission and parent membership the moment someone
// re-created a group with the same name. A parent that had only this group as a member is left
// with none and so ceases to exist, as when its last member is removed by hand; its own grants
// and parent memberships stay (todo.md).
const subject = groupSubject(name);
const held = await heldPermissions(keto, subject);
const grants = held.map((permission) => grantTuple(permission, subject));
const members = await pagedTuples(keto, { namespace: GROUP_NS, object: name, relation: MEMBERS });
const inParents = await pagedTuples(keto, { namespace: GROUP_NS, relation: MEMBERS, ...subject });
await keto.transactTuples({ delete: [...grants, ...members, ...inParents], insert: [] });
ctx.log.info("admin: group deleted", { actor: user.id, group: name, revoked: held.join(",") });
const cascade = await withEmptiedGroups(keto, members, [name]);
await keto.transactTuples({ delete: cascade.delete, insert: [] });
logEmptied(deps, "admin: group deleted", name, cascade);
return { redirect: ADMIN_GROUPS_BASE };
});
@@ -452,6 +483,9 @@ export const groupsRemoveMember = withGroupName(async (deps, name) => {
const removesSelf = tuple.subject_set ? await isMember(keto, user.id, tuple.subject_set.object) : tuple.subject_id === `user:${user.id}`;
const lost = removesSelf ? await lostOnLeaving(deps, name) : [];
if (lost.length > 0) return refuseSelfLockout(deps, name, "remove", lost);
await keto.deleteTuple(tuple);
return { redirect: detailHref(name) };
const cascade = await withEmptiedGroups(keto, [tuple], [name]);
await keto.transactTuples({ delete: cascade.delete, insert: [] });
if (cascade.emptied.length === 0) return { redirect: detailHref(name) };
logEmptied(deps, "admin: last group member removed", name, cascade);
return { redirect: `${detailHref(name)}?info-msg=${EMPTIED_NOTICE}` };
});
@@ -71,6 +71,7 @@ const messages = {
"admin.groups.create": "Create group",
"admin.groups.delete": "Delete group",
"admin.groups.deleteMessage": "Delete group {{name}}? This can't be undone.",
"admin.groups.emptied": "That was the last member, so the group no longer exists and its permissions and parent groups are removed.",
"admin.groups.error.duplicate": "A group with that name already exists.",
"admin.groups.error.selfLockout": "This change would lock you out of {{permissions}}, which you hold through this group. Ask another administrator to make it.",
"admin.groups.field.name": "Group name",
@@ -71,6 +71,7 @@ const messages: AdminMessages = {
"admin.groups.create": "Skapa grupp",
"admin.groups.delete": "Radera grupp",
"admin.groups.deleteMessage": "Ta bort gruppen {{name}}? Det går inte att ångra.",
"admin.groups.emptied": "Det var den sista medlemmen, så gruppen finns inte längre och dess behörigheter och föräldragrupper är borttagna.",
"admin.groups.error.duplicate": "Det finns redan en grupp med det namnet.",
"admin.groups.error.selfLockout": "Ändringen skulle låsa ute dig från {{permissions}}, som du har genom den här gruppen. Be en annan administratör att göra den.",
"admin.groups.field.name": "Gruppnamn",
+2
View File
@@ -29,6 +29,8 @@ class Permission implements Namespace {
// A fine-grained, relationship-checked resource — README's third "may I?" tier, the rare
// live Keto check (e.g. sharing/delegation). Permits nest: owner ⊇ editor ⊇ viewer.
// Grants accept a user directly or any member of a group.
// Every plugin shares this namespace, so an object is `<resource>:<row-id>` (`shift:4471`):
// a bare row id lets two plugins' rows share one grant. Nothing enforces that.
class Resource implements Namespace {
related: {
owners: (User | SubjectSet<Group, "members">)[]
+8 -8
View File
@@ -6,9 +6,9 @@
"": {
"name": "plainpages",
"dependencies": {
"@larvit/log": "2.5.0",
"@larvit/log": "2.6.1",
"ejs": "7.0.2",
"lucide-static": "1.70.0",
"lucide-static": "1.73.0",
"postgres": "4.1.1"
},
"devDependencies": {
@@ -23,9 +23,9 @@
}
},
"node_modules/@larvit/log": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@larvit/log/-/log-2.5.0.tgz",
"integrity": "sha512-xky7OVFDw4Ftf60Syn0eKT47xSepbjcghiwIS5NCyawZc/TVR0YWnDrWubc1sO0/MC2m2j0HdxirsZj0APf05A==",
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/@larvit/log/-/log-2.6.1.tgz",
"integrity": "sha512-+AKHV37gxmB21G56bpzScVe5Em0jYr18vzEM42lAV17aNYy9SpZhUCzyqk0eE8HE4nbC51TTut1v+nDuzkQbKQ==",
"license": "MIT",
"engines": {
"node": ">=18"
@@ -421,9 +421,9 @@
}
},
"node_modules/lucide-static": {
"version": "1.70.0",
"resolved": "https://registry.npmjs.org/lucide-static/-/lucide-static-1.70.0.tgz",
"integrity": "sha512-A9UgY98g94IuHQY7rl7/AFwHX7T1qNpzryim+Kw5CGhdV2STobtBY+ib/Z44ohyqXEJB88gvXFAeJ87uOOHKLw==",
"version": "1.73.0",
"resolved": "https://registry.npmjs.org/lucide-static/-/lucide-static-1.73.0.tgz",
"integrity": "sha512-/FfzdRThAPnDVMk643pzENqYUnxudEON/fyOdh31ZiPiw/seE9VoYeIJPRDTCLDNtnF+5pK6CNwf6IkQMfrJ5w==",
"license": "ISC"
},
"node_modules/postgres": {
+2 -2
View File
@@ -16,9 +16,9 @@
"test": "node --test \"src/**/*.test.ts\" \"plugins/**/*.test.ts\" \"examples/**/*.test.ts\" \"registry-cleanup/**/*.test.ts\" \"release-tooling/**/*.test.ts\""
},
"dependencies": {
"@larvit/log": "2.5.0",
"@larvit/log": "2.6.1",
"ejs": "7.0.2",
"lucide-static": "1.70.0",
"lucide-static": "1.73.0",
"postgres": "4.1.1"
},
"devDependencies": {
+2 -1
View File
@@ -41,7 +41,8 @@ export function can(ctx: RequestContext, permission: string): boolean {
}
// Live Keto relationship check at the point of action. The subject is the current user;
// anonymous ⇒ false (fail-closed, no Keto call).
// anonymous ⇒ false (fail-closed, no Keto call). In the shared `Resource` namespace the object
// is `<resource>:<row-id>`, never a bare id (README → Fine-grained, per-row access).
export async function check(
keto: KetoClient,
ctx: RequestContext,
+106
View File
@@ -446,6 +446,112 @@ test("admin group delete: removes the group from every parent, so re-creating th
assert.deepEqual(tuples, [member("org", { subject_id: `user:${ada}` }), member("staff", { subject_id: "user:other" })]);
});
// Tuples a group keeps after it loses its last member would be restored by re-creating its name.
const ADA = randomUUID();
const groupTuple = (object: string, subject: Partial<RelationTuple>): RelationTuple => ({ namespace: "Group", object, relation: "members", ...subject } as RelationTuple);
const inGroup = (object: string) => ({ subject_set: { namespace: "Group", object, relation: "members" } });
const grantTo = (group: string, permission = "users:read"): RelationTuple => ({ namespace: "Permission", object: permission, relation: "granted", ...inGroup(group) });
const groupsAdminHarness = (t: TestContext, tuples: RelationTuple[]) => adminHarness(t, { keto: fakeKeto(tuples), kratosAdmin: stubAdmin({}) });
test("admin group delete: a parent left with no members loses its grants and memberships, all the way up", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("eng", { subject_id: `user:${ADA}` }),
groupTuple("org", inGroup("eng")), grantTo("org"),
groupTuple("company", inGroup("org")), grantTo("company", "users:write"),
groupTuple("everyone", inGroup("company")), groupTuple("everyone", { subject_id: "user:other" }), grantTo("everyone", "groups:read"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
assert.equal((await post("/auth-admin/groups/eng/delete", `_csrf=${token}`)).status, 303);
assert.deepEqual(tuples, [groupTuple("everyone", { subject_id: "user:other" }), grantTo("everyone", "groups:read")]);
});
test("admin group delete: a nesting cycle ends the cascade at a group that keeps a member", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("a", { subject_id: `user:${ADA}` }), groupTuple("a", inGroup("b")),
groupTuple("b", inGroup("a")), grantTo("b"),
groupTuple("c", inGroup("b")), groupTuple("c", { subject_id: "user:other" }), grantTo("c", "groups:read"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
assert.equal((await post("/auth-admin/groups/a/delete", `_csrf=${token}`)).status, 303);
assert.deepEqual(tuples, [groupTuple("c", { subject_id: "user:other" }), grantTo("c", "groups:read")]);
});
// The walk reaches `a` a second time, through the cycle, while `p` still waits: it must go on to `p`.
// Keto lists `p@b` before `a@b`, so `a` is popped before `p`.
test("admin group delete: a nesting cycle back to an emptied group doesn't end the cascade", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("a", { subject_id: `user:${ADA}` }), groupTuple("p", inGroup("b")), groupTuple("a", inGroup("b")),
groupTuple("b", inGroup("a")), grantTo("p"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
assert.equal((await post("/auth-admin/groups/a/delete", `_csrf=${token}`)).status, 303);
assert.deepEqual(tuples, []);
});
test("admin group delete: a diamond of nested groups empties the top once both its members are gone", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("eng", { subject_id: `user:${ADA}` }),
groupTuple("left", inGroup("eng")), groupTuple("right", inGroup("eng")),
groupTuple("top", inGroup("left")), groupTuple("top", inGroup("right")), grantTo("top"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
assert.equal((await post("/auth-admin/groups/eng/delete", `_csrf=${token}`)).status, 303);
assert.deepEqual(tuples, []);
});
test("admin group member removal: the last member leaving takes the group's grants and parent memberships with it", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("eng", { subject_id: `user:${ADA}` }), grantTo("eng"),
groupTuple("org", inGroup("eng")), groupTuple("org", { subject_id: "user:other" }),
groupTuple("solo", inGroup("org")), grantTo("solo", "users:write"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
const res = await post("/auth-admin/groups/eng/members/delete", `_csrf=${token}&member=user:${ADA}`);
assert.equal(res.headers.get("location"), "/auth-admin/groups/eng?info-msg=group-emptied");
assert.deepEqual(tuples, [groupTuple("org", { subject_id: "user:other" }), groupTuple("solo", inGroup("org")), grantTo("solo", "users:write")]);
});
test("admin group member removal: removing someone who isn't a member changes nothing", async (t) => {
const tuples: RelationTuple[] = [groupTuple("eng", { subject_id: `user:${ADA}` }), grantTo("eng")];
const { post, token } = await groupsAdminHarness(t, tuples);
const res = await post("/auth-admin/groups/eng/members/delete", `_csrf=${token}&member=user:${randomUUID()}`);
assert.equal(res.headers.get("location"), "/auth-admin/groups/eng");
assert.equal(tuples.length, 2);
});
test("admin group member removal: a group that keeps a member keeps its grants and parents", async (t) => {
const tuples: RelationTuple[] = [groupTuple("eng", { subject_id: `user:${ADA}` }), groupTuple("eng", { subject_id: "user:bob" }), grantTo("eng"), groupTuple("org", inGroup("eng"))];
const { post, token } = await groupsAdminHarness(t, tuples);
const res = await post("/auth-admin/groups/eng/members/delete", `_csrf=${token}&member=user:${ADA}`);
assert.equal(res.headers.get("location"), "/auth-admin/groups/eng");
assert.equal(tuples.length, 3);
});
test("admin group member removal: a parent that keeps another nested group keeps its grants", async (t) => {
const tuples: RelationTuple[] = [
groupTuple("eng", { subject_id: `user:${ADA}` }),
groupTuple("left", inGroup("eng")), groupTuple("right", { subject_id: "user:other" }),
groupTuple("top", inGroup("left")), groupTuple("top", inGroup("right")), grantTo("top"),
];
const { post, token } = await groupsAdminHarness(t, tuples);
await post("/auth-admin/groups/eng/members/delete", `_csrf=${token}&member=user:${ADA}`);
assert.deepEqual(tuples, [groupTuple("right", { subject_id: "user:other" }), groupTuple("top", inGroup("right")), grantTo("top")]);
});
test("admin group member removal: the group page shows the notice that the group is gone", async (t) => {
const { get } = await groupsAdminHarness(t, []);
assert.match(await (await get("/auth-admin/groups/eng?info-msg=group-emptied")).text(), /That was the last member/);
});
// A double-clicked Save posts twice from one page; the second post finds the first one's result.
// A save that changes nothing has nothing to refuse and nothing to revoke.
test("admin permission grants: a save that changes nothing is not refused for a stale page and leaves live tokens alone", async (t) => {
+2 -2
View File
@@ -268,14 +268,14 @@ test("session re-mint runs only for an expired token with all three Ory clients
});
test("guards map to responses: requireSession → /login, a failed can/check → 403, success runs the handler", async (t) => {
const keto = { check: async (tuple: { object: string }) => tuple.object === "open" } as unknown as Parameters<typeof check>[0];
const keto = { check: async (tuple: { object: string }) => tuple.object === "doc:open" } as unknown as Parameters<typeof check>[0];
const guarded: Plugin = {
apiVersion: "1.0.0",
id: "guarded",
routes: [
{ handler: (ctx) => ({ html: `hi ${requireSession(ctx).email}` }), method: "GET", path: "/me" },
{ handler: (ctx) => { if (!can(ctx, "admin")) throw new GuardError(403, "no"); return { html: "ok" }; }, method: "GET", path: "/admin-only" },
{ handler: async (ctx) => { if (!(await check(keto, ctx, { namespace: "Resource", object: ctx.params.id ?? "", relation: "view" }))) throw new GuardError(403, "no"); return { html: "seen" }; }, method: "GET", path: "/doc/:id" },
{ handler: async (ctx) => { if (!(await check(keto, ctx, { namespace: "Resource", object: `doc:${ctx.params.id ?? ""}`, relation: "view" }))) throw new GuardError(403, "no"); return { html: "seen" }; }, method: "GET", path: "/doc/:id" },
{ handler: () => ({ html: "gated" }), method: "GET", path: "/gated", permission: "secret:read" }, // declarative route gate
{ handler: () => ({ html: "mine" }), method: "GET", path: "/mine", session: true }, // declarative session gate
],
+7
View File
@@ -22,3 +22,10 @@ test("plugin-api re-exports the stable author value surface", () => {
assert.equal(api.safeUrl("javascript:alert(1)"), "#"); // the URL sanitiser for rendering untrusted hrefs
assert.equal(api.definePlugin({ apiVersion: "1.0.0" }).apiVersion, "1.0.0"); // identity helper works through the barrel
});
// A plugin matches a Keto failure with `instanceof`, so the barrel must export the class `ctx.system.keto` throws.
test("plugin-api re-exports the KetoError class the Keto client throws", async () => {
const { KetoError } = await import("../auth/keto-client.ts");
assert.equal(api.KetoError, KetoError);
});
+1
View File
@@ -46,6 +46,7 @@ export type { ExpandTree, KetoClient, RelationQuery, RelationTuple, SubjectSet }
export type { HydraAdmin, OAuth2Client } from "../auth/hydra-admin.ts";
export { KratosError } from "../auth/kratos-public.ts";
export { HydraError } from "../auth/hydra-admin.ts";
export { KetoError } from "../auth/keto-client.ts";
// Sanitise an untrusted URL (upstream/user data) before rendering it in an href/src — partials
// escape text but not URL schemes, so a `javascript:`/`data:` URL would be live XSS (see docs).
export { safeUrl } from "../http/safe-url.ts";
+101 -50
View File
@@ -6,18 +6,16 @@
`Bar = 1`
`Next ID = 73`
`Next ID = 74`
## Items
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 19 | 0.6.0 | | question | **Run the documented Docker commands on macOS and fix whatever misbehaves.** | 2 | 2 | 1 | 3 | 3 | 1 by 3 | 3.3 |
| 16 | 0.6.0 | | question | **Decide whether the single Keto `Resource` namespace splits into per-domain namespaces.** | 3 | 2 | 3 | 6 | 6 | 7 by 2 | 0.5 |
| 65 | 0.6.0 | | | **Export `KetoError` from `@plainpages/plugin-api`, so a plugin can tell a Keto failure apart with `instanceof`.** | 1 | 2 | 1 | 2 | 1 | 7 by 3, 1 by 1 | 6.7 |
| 72 | 0.6.0 | | | **Delete a group's grants and parent memberships when its last member leaves, by group delete or by removing the member, so re-creating the name restores none.** | 2 | 2 | 2 | 4 | 3 | 2 by 4 | 4.2 |
| 67 | 0.6.0 | | | **Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.** | 3 | 1 | 2 | 4 | 6 | code health by 4 | 4.0 |
| 14 | 0.6.0 | | | **Drop a double-clicked duplicate submit, with no client-side JavaScript.** | 4 | 2 | 3 | 7 | 7 | 2 by 7, 1 by 4 | 1.4 |
| 67 | 0.6.0 | | | **Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.** | 3 | 1 | 2 | 4 | 6 | code health by 4 | 1.0 |
| 19 | 0.7.0 | | question | **Run the documented Docker commands on macOS and fix whatever misbehaves.** | 2 | 2 | 1 | 3 | 3 | 1 by 3 | 3.3 |
| 73 | 0.7.0 | | owner | **Reach the comprehension floor: make the request pipeline in `src/http/app.ts` and the locale and EJS-locals plumbing readable one unit at a time, so every dimension mean reaches 7.0.** | 3 | 1 | 2 | 4 | 7 | code health by 7 | 0.9 |
## Renamed
@@ -26,45 +24,23 @@
## Details
### 19. Run the documented Docker commands on macOS and fix whatever misbehaves.
### 14. Drop a double-clicked duplicate submit, with no client-side JavaScript.
Needs a Mac. Two suspects, both from `--user "$(id -u):$(id -g)"`: a macOS `id -g` is `20`, which is
`dialout` inside the noble image, and Docker Desktop remaps bind-mount ownership in its VM.
A second identical POST is expected from a non-technical user, and today creates two
users, mints two recovery codes, or registers two OAuth2 clients. It must not break a legitimately
repeatable action. Sketch: a CSS-only affordance so the second click has nothing to hit, plus the
host recognising a duplicate (same session, route and payload within a short window), logging and
dropping it. Open: what identifies "the same submission" (a one-time token minted into each form
beats hashing the payload), the window, where the record lives given the host is stateless, and how
a plugin declares a route repeatable.
### 16. Decide whether the single Keto `Resource` namespace splits into per-domain namespaces.
Touches:
Ory's own examples model `Shift`, `Document` and so on. One global `Resource` bucket is the
project's "no catch-all names" rule applied to namespaces.
### 65. Export `KetoError` from `@plainpages/plugin-api`, so a plugin can tell a Keto failure apart with `instanceof`.
`src/plugin-host/plugin-api.ts` ~L47-48 exports `KratosError` and `HydraError`, but not `KetoError`
(`src/auth/keto-client.ts:43`), though `ctx.system.keto` throws it. The barrel is the contract
surface, so this adds to the plugin API: it ships in a minor, and `HOST_API_VERSION` must read
`0.6.0` when 0.6.0 is tagged (AGENTS.md → Rules). Adding is safe for installed plugins; removing it
later would take a major.
### 72. Delete a group's grants and parent memberships when its last member leaves, by group delete or by removing the member, so re-creating the name restores none.
In `examples/plugins/auth-admin/admin-groups.ts` a group exists exactly while it has a
`Group:<name>#members` tuple. Two paths empty a group but keep its other tuples, so re-creating the
name silently hands every new member the old permissions and parent memberships:
1. `groupsDelete` of a group that is a parent's only member: the parent ceases to exist but keeps
its `Permission:*#granted@Group:<parent>#members` grants and its memberships in grandparents.
2. `groupsRemoveMember` removing a group's last member, which today is a lone `deleteTuple`.
Fix both in one `transactTuples` with the removal: when the removal leaves a group with no members,
add its grants and the tuples naming it as a member of other groups to the delete. The cascade is
transitive: a grandparent emptied by its parent vanishing is the same bug one level up. The walk
stops at a group that keeps any member, so a nesting cycle (`groupsAddMember` refuses only a
self-nest) ends it. An emptied group grants nobody, so the cascade cannot change what
`lostToSelf` computes. Test it with nesting two levels deep and with a cycle.
When it ships, rewrite the comment at `groupsDelete` that points here, and the CHANGELOG entry "The
admin example removes a deleted group from the groups it was nested in", which then says a parent
left with no members no longer exists as a group. `lostToSelf`, in this file, is a place the seats
found hard; if the change touches it, make it easier to read.
- `src/http/app.ts`: `answerPluginRoute`, `answerBuiltinRoute`, `prepareRequest`, `requestCsrf`
- `src/plugin-host/plugin.ts`: `Route` (small)
- `src/auth/csrf.ts`
- `public/css/styles.css`: lines 323-340 (small)
- `README.md`: `### Routes & handlers`
### 67. Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.
@@ -77,12 +53,87 @@ name, and update the folder list in `docs/decisions.md` → "`src/` is grouped b
barrel, so only `src/plugin-host/plugin-api.ts`'s paths change for them. Update the README file
map. Make `src/auth` easier to navigate, a place the seats found hard.
### 14. Drop a double-clicked duplicate submit, with no client-side JavaScript.
Touches:
A second identical POST is expected from a non-technical user, and today creates two
users, mints two recovery codes, or registers two OAuth2 clients. It must not break a legitimately
repeatable action. Sketch: a CSS-only affordance so the second click has nothing to hit, plus the
host recognising a duplicate (same session, route and payload within a short window), logging and
dropping it. Open: what identifies "the same submission" (a one-time token minted into each form
beats hashing the payload), the window, where the record lives given the host is stateless, and how
a plugin declares a route repeatable.
- `src/auth/csrf.ts`
- `src/auth/csrf.test.ts`
- `src/auth/denylist.ts`
- `src/auth/denylist.test.ts`
- `src/auth/fetch-timeout.ts`
- `src/auth/fetch-timeout.test.ts`
- `src/auth/flow-view.ts`
- `src/auth/flow-view.test.ts`
- `src/auth/gate.ts`
- `src/auth/gate.test.ts`
- `src/auth/gen-jwks.ts`
- `src/auth/gen-jwks.test.ts`
- `src/auth/guards.ts`
- `src/auth/guards.test.ts`
- `src/auth/hydra-admin.ts`
- `src/auth/hydra-admin.test.ts`
- `src/auth/jwks.ts`
- `src/auth/jwks.test.ts`
- `src/auth/jwt-middleware.ts`
- `src/auth/jwt-middleware.test.ts`
- `src/auth/jwt.ts`
- `src/auth/jwt.test.ts`
- `src/auth/keto-client.ts`
- `src/auth/keto-client.test.ts`
- `src/auth/kratos-admin.ts`
- `src/auth/kratos-admin.test.ts`
- `src/auth/kratos-public.ts`
- `src/auth/kratos-public.test.ts`
- `src/auth/link-header.ts`
- `src/auth/link-header.test.ts`
- `src/auth/login.ts`
- `src/auth/login.test.ts`
- `src/auth/oauth-consent.ts`
- `src/auth/oauth-consent.test.ts`
- `src/auth/oauth-login.ts`
- `src/auth/oauth-login.test.ts`
- `src/auth/routes.ts`
- `src/auth/routes.test.ts`
- `src/auth/bootstrap.ts`: import lines (small)
- `src/auth/bootstrap.test.ts`: import lines (small)
- `src/plugin-host/plugin-api.ts`: the `../auth/` export lines (small)
- `src/plugin-host/plugin.ts`: the `Gate` import (small)
- `src/plugin-host/plugin.test.ts`: the `AUTH_FLOWS` import (small)
- `src/plugin-host/discovery.ts`: the `gate.ts` import (small)
- `src/plugin-host/system.ts`: the three client-type imports (small)
- `src/http/app.ts`: the `../auth/` import lines (small)
- `src/http/app.test.ts`: import lines (small)
- `src/http/app-admin.test.ts`: import lines (small)
- `src/http/app-auth.test.ts`: import lines (small)
- `src/http/app-i18n.test.ts`: import lines (small)
- `src/http/app-plugins.test.ts`: import lines (small)
- `src/http/builtin-route.ts`: the `Gate` import (small)
- `src/ui/chrome.ts`: the `gate.ts` import (small)
- `src/ui/nav.ts`: the `gate.ts` import (small)
- `src/test-tooling/app-harness.ts`: import lines (small)
- `src/server.ts`: the `./auth/` import lines (small)
- `src/function-limits.test.ts`: the `src/auth/` keys (small)
- `src/postgres.test.ts`: the `src/auth/bootstrap.ts` path (small, only if bootstrap's path changes)
- `README.md`: `## Project layout`, `## Users, groups & permissions` (small), `## Building blocks` (small), `### Instant revoke: the optional denylist` (small), `### OAuth2 provider (Hydra)` (small), `## JWT signing key & rotation` (small), `### Scheduled rotation` (small), `### Emergency rotation (key compromise)` (small)
- `package.json`: the `gen-jwks` script (small)
- `compose.yml`: the `src/auth/bootstrap.ts` comment and command (small)
### 19. Run the documented Docker commands on macOS and fix whatever misbehaves.
Needs a Mac. Two suspects, both from `--user "$(id -u):$(id -g)"`: a macOS `id -g` is `20`, which is
`dialout` inside the noble image, and Docker Desktop remaps bind-mount ownership in its VM.
### 73. Reach the comprehension floor: make the request pipeline in `src/http/app.ts` and the locale and EJS-locals plumbing readable one unit at a time, so every dimension mean reaches 7.0.
The scoring run on PR #247 at 7e8bdd9 gave means Navigation 7.50, Locality 6.63, Shape 6.88, Self-sufficiency 6.88, Overall 7.13. Locality is the lowest. Item 67 covers the `src/auth` folder, so this item leaves it out.
Places the seats named, to make easier to read:
- `src/http/app.ts:67` `createApp`: about 130 lines of closures that refer to each other, and `switchBase` reads `builtinRoutes`, which is declared later; all four seats named it.
- `src/http/app.ts:263` `prepareRequest` and `src/http/context.ts:97` `buildContext`: chrome is memoized lazily in both, and an untyped `shared` bag feeds the context, so a new context field touches about five declarations.
- `src/http/app.ts:202` `Host`: restates the options and locals a third time.
- `src/i18n/locale.ts:81` `chosenLocale`: recovers "was a locale requested" from `localeHref("/") === "/"`, so its name hides the mechanism.
- `views/partials/data-table.ejs:74`, `views/partials/menu.ejs:22` and `views/partials/filter-bar.ejs:26`: EJS locals leak into includes, defended by explicit null options.
- `src/server.ts:25` `delete process.env["PLUGIN_DB_SECRET"]`: a load-bearing order rule in a top-level script.
- `public/css/styles.css:81`: the dark and light token mapping is written three times.
- `src/auth/routes.ts:58` `flowFailure`: Kratos statuses that no comment in the file explains.
Aim: a reader of one unit should not need the other units open beside it. Re-run the scoring run when it ships.