diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index 0a45a44..208fbde 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -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 diff --git a/todo.md b/todo.md index 9078d21..42d20d8 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 1` -`Next ID = 73` +`Next ID = 74` ## Items @@ -14,9 +14,10 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 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 @@ -55,6 +56,16 @@ admin example removes a deleted group from the groups it was nested in", which t 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. +### 14. Drop a double-clicked duplicate submit, with no client-side JavaScript. + +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. + ### 67. Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`. `src/auth` holds 19 modules over several concerns: the per-request session path (`jwt*`, `jwks`, @@ -66,17 +77,23 @@ 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. - -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. - ### 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.