@jskit-ai/agent-docs 0.1.332 → 0.1.334

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/guide/agent/app-setup/authentication.md +106 -8
  2. package/guide/agent/framework/crud-form-actions.md +18 -7
  3. package/guide/agent/framework/crud-operations.md +5 -0
  4. package/guide/agent/framework/data-access.md +61 -1
  5. package/guide/agent/framework/material-3.md +11 -4
  6. package/guide/agent/framework/quality-pass.md +8 -2
  7. package/guide/agent/framework/security-pass.md +3 -1
  8. package/package.json +1 -1
  9. package/patterns/minimal-foundation/example/package.json +2 -2
  10. package/patterns/shell-foundation/example/package.json +3 -3
  11. package/reference/autogen/PATTERN_INDEX.md +34 -34
  12. package/reference/autogen/packages/auth-core.md +13 -0
  13. package/reference/autogen/packages/auth-provider-local-core.md +40 -5
  14. package/reference/autogen/packages/auth-provider-local-db-core.md +15 -0
  15. package/reference/autogen/packages/auth-web.md +26 -0
  16. package/reference/autogen/packages/http-web.md +2 -0
  17. package/reference/autogen/packages/resource-runtime.md +1 -0
  18. package/reference/autogen/packages/shell-web.md +42 -0
  19. package/skills/jskit/references/crud-form-actions.md +18 -7
  20. package/skills/jskit/references/crud-operations.md +5 -0
  21. package/skills/jskit/references/data-access.md +61 -1
  22. package/skills/jskit/references/heuristics/client-requests.md +1 -1
  23. package/skills/jskit/references/heuristics/crud-authoring.md +3 -2
  24. package/skills/jskit/references/heuristics/live-actions.md +4 -1
  25. package/skills/jskit/references/heuristics/ui-contract.md +9 -1
  26. package/skills/jskit/references/material-3.md +11 -4
  27. package/skills/jskit/references/pattern-index.md +34 -34
  28. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +2 -2
  29. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +3 -3
  30. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +1 -1
  31. package/skills/jskit/references/patterns/auth/auth-surface/PATTERN.md +10 -8
  32. package/skills/jskit/references/patterns/auth/auth-surface/example/src/pages/auth/email-change.vue +17 -0
  33. package/skills/jskit/references/patterns/auth/auth-surface/example/src/views/auth/EmailChangeView.vue +12 -0
  34. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  35. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  36. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +2 -2
  37. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +1 -1
  38. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  39. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsNotificationsSection.vue +3 -1
  40. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsPreferencesSection.vue +3 -1
  41. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsProfileSection.vue +4 -1
  42. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +2 -2
  43. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +4 -4
  44. package/skills/jskit/references/quality-pass.md +8 -2
  45. package/skills/jskit/references/security-pass.md +3 -1
@@ -98,8 +98,8 @@ declares a `rateLimit`, which the kernel enforces for each client address. A
98
98
  request over it is refused with status 429, the code `kernel.http.rateLimited`
99
99
  (`params.count` is the seconds to wait) and a `Retry-After` header. The
100
100
  defaults, per minute: `login`, `register`, `registerConfirm`,
101
- `loginOtpRequest` and `loginOtpVerify` 10; `registerConfirmationResend` and
102
- `passwordForgot` 5;
101
+ `loginOtpRequest`, `loginOtpVerify` and `emailChangeConfirm` 10;
102
+ `registerConfirmationResend`, `passwordForgot` and `emailChange` 5;
103
103
  `oauthStart`, `oauthComplete`, `passSignIn`, `passwordRecovery` and `passwordReset` 20;
104
104
  `devLoginAs` 30. Change one in the application's server configuration;
105
105
  `false` removes it:
@@ -163,6 +163,21 @@ sign-in factor, and at least 8 when it is used with another factor; set
163
163
 
164
164
  The login page shows either refusal, translated, with the wait.
165
165
 
166
+ **Sign-in events (local auth).** Each sign-in and each refused one is an
167
+ event, for a page that lists an account's sign-ins or for an audit log:
168
+ `type` (`signedIn` or `failed`), `method` (`password`, `registration`,
169
+ `confirmation`, `recovery`, `pass`, or `provider` with `provider`, such as
170
+ `google`), a refusal's `reason` (`invalidCredentials`, `locked`,
171
+ `unconfirmed` or `disabled`), `userId` (the local account, "" when the email
172
+ names none), `email`, the request's `ip` and `userAgent`, and `at`; never a
173
+ password, secret or token. An application that keeps them installs the
174
+ `auth.local.sign-in-events` capability, a function given each event
175
+ (`AuthLocalSignInEvent` in `@jskit-ai/auth-provider-local-core/server/types`),
176
+ and stores them in a table of its own, with how long it keeps them. It is
177
+ called after the request has answered, so a refused sign-in takes the same
178
+ time whatever it does; when it fails, local auth logs the failure, and a
179
+ stopping server waits for it a while. Without one, local auth logs each event.
180
+
166
181
  ## Sign-in cookies and SameSite
167
182
 
168
183
  Local auth's cookies (access, refresh, recovery and OAuth attempt) and
@@ -452,8 +467,8 @@ error.
452
467
 
453
468
  | Capability | Methods |
454
469
  | --- | --- |
455
- | `auth.local.accounts` | `create(account, options)`, `findById(userId, options)`, `findByEmail(email, options)`, `updatePassword(userId, passwordRecord, options)`, `updateProfile(userId, { displayName }, options)`, `markEmailVerified(userId, options)` |
456
- | `auth.local.sessions` | `create(session, options)`, `update(sessionId, { purpose, expiresAt }, { ...options, onlyIf })`, `revoke(sessionId, options)`, `revokeForUser(userId, { ...options, exceptSessionId })`, `deleteExpired(now, options)` |
470
+ | `auth.local.accounts` | `create(account, options)`, `findById(userId, options)`, `findByEmail(email, options)`, `updatePassword(userId, passwordRecord, options)`, `updateProfile(userId, { displayName }, options)`, `markEmailVerified(userId, options)`, `disable(userId, { message }, options)`, `enable(userId, options)` |
471
+ | `auth.local.sessions` | `create(session, options)`, `update(sessionId, { purpose, expiresAt }, { ...options, onlyIf })`, `revoke(sessionId, options)`, `revokeForUser(userId, { ...options, exceptSessionId })`, `deleteExpired(now, options)`, `listForUser(userId, options)` |
457
472
  | `auth.local.recovery` | `create(token, options)`, `findByTokenHash(tokenHash, options)`, `consume(tokenId, options)`, `consumeForUser(userId, { ...options, idPrefix })` |
458
473
 
459
474
  `markEmailVerified` records that the account proved it owns its email address,
@@ -462,6 +477,40 @@ for example by using an emailed link, in the `email_verified_at` column (run
462
477
  `emailVerifiedAt` (empty until then). `deleteExpired` deletes the sessions that
463
478
  expired by `now` and answers how many.
464
479
 
480
+ `disable` stops an account signing in, for example while an application
481
+ suspends or closes it: every sign-in and every session of the account is
482
+ refused from its next request, until `enable`. `message`, at most 500
483
+ characters, is what the person is told when they sign in with the right
484
+ password, a linked provider or a one-time pass, such as `This account is
485
+ suspended until 14 Dec. We've emailed you why.`: status 403, the code
486
+ `auth.local.login.disabled`, and the message as the error's text, which the
487
+ sign-in page shows as written. Without a message the text is `This account is
488
+ disabled.`, translated like any other. A wrong password is an ordinary failed
489
+ sign-in, so only someone who could sign in learns that the account is
490
+ disabled. The message is kept in the `disabled_message` column (run
491
+ `npm run db:migrate`) until `enable` clears it. Both answer the account
492
+ (`disabled`, `disabledMessage`, "" when it has none), or null when there is no
493
+ such account, and refuse a missing id, as `disable` refuses a message that is
494
+ not text of at most 500 characters, with a `TypeError`. Neither signs the
495
+ account out: its sessions work again after `enable`, unless
496
+ `auth.local.sessions`' `revokeForUser` ended them.
497
+
498
+ Every session keeps where and when it was last seen: `ip` (the request's
499
+ address, Fastify's `request.ip`, so set `TRUSTED_PROXIES` behind a proxy),
500
+ `userAgent` (the browser's `User-Agent`, at most 512 characters) and
501
+ `lastSeenAt`. Signing in sets them from the sign-in's request, and a request
502
+ that finds the session more than five minutes after it was last seen sets them
503
+ again, so most requests write nothing; one that does not say where it comes
504
+ from keeps the address and browser. Each is "" when unknown, as for sessions
505
+ from before (run `npm run db:migrate` for the `ip`, `user_agent` and
506
+ `last_seen_at` columns). `listForUser` answers the account's sessions that are
507
+ neither revoked nor expired, the newest first, every one of them, and refuses
508
+ a missing id with a `TypeError`. For a person's own list, name the account
509
+ from the request's authentication, never from what the client sends:
510
+ `authenticateRequest(request)` answers `actor.providerUserId` and the
511
+ request's own `sessionId`, which the list can mark as this browser. End one
512
+ session with `revoke(sessionId)` once the list showed it is that account's.
513
+
465
514
  A recovery token's kind is the start of its id: local sign-in's password resets
466
515
  are `rec_…`, and an app's own kind (a sign-in link, say) takes a prefix of its
467
516
  own, such as `magic_…`. `consumeForUser` consumes the user's open tokens of the
@@ -589,7 +638,8 @@ page shows the reason:
589
638
  | `auth.pass.wrongResource` | 401 | For another resource. |
590
639
  | `auth.pass.expired` | 401 | Expired (30 seconds of clock difference are allowed). |
591
640
  | `auth.pass.replayed` | 401 | Already used, on this server or another sharing its store. |
592
- | `auth.pass.unmapped` | 403 | The mapping names no account, or a disabled one. |
641
+ | `auth.pass.unmapped` | 403 | The mapping names no account. |
642
+ | `auth.local.login.disabled` | 403 | The mapping names a disabled account; the reason is the account's message (see `disable` above). |
593
643
 
594
644
  Each pass signs in once. Local auth records each pass it accepts, by the hash
595
645
  of its id, until it could no longer be used anyway (30 seconds after it
@@ -740,6 +790,53 @@ or compatibility adapter.
740
790
  the completed password-reset flow before releasing the updated application.
741
791
  This change does not alter identity, session or recovery-token storage.
742
792
 
793
+ ## Email change (local auth)
794
+
795
+ A person changes their email by proving the new address: local auth sends it a
796
+ link, and only using the link changes the email.
797
+
798
+ - The signed-in person asks with their password: `POST /api/email-change`
799
+ with `{ email, password }` (the action `auth.emailChange.request`, the
800
+ service's `requestEmailChange(request, input)`). An account with no password
801
+ sets one first, through a password reset.
802
+ - The application asks for an account it chose, without a password:
803
+ `authService.requestEmailChangeForUser({ userId, email })`, for example an
804
+ operator's change for a person who lost their old address. Who may ask is the
805
+ application's decision, so it has no route; the application's own action
806
+ checks its caller first.
807
+ - The link opens `/auth/email-change?token=...`, the `auth.email-change` route,
808
+ whose page (`DefaultEmailChangeView` from `@jskit-ai/auth-web`) posts the
809
+ token to `POST /api/email-change/confirm` (`confirmEmailChange({ token })`),
810
+ public, since the link proves who uses it, and shows the new email. The
811
+ application adds the page as it adds the reset page, rendering the view in
812
+ `src/pages/auth/email-change.vue`.
813
+
814
+ The account keeps the new address as its waiting change until the link is
815
+ used; a newer request replaces it, so an earlier link stops working. A link
816
+ works for a day and once. Using it changes the email, ends the password resets
817
+ sent to the old address, and sends the old address a notice; the account's
818
+ sessions stay signed in and show the new email from their next request. Each
819
+ refusal has its code: `auth.local.emailChange.passwordInvalid` and `sameEmail`
820
+ (400), `emailTaken` (409, also when another account took the address after the
821
+ link was sent), `linkInvalid` (400: used, replaced, expired or altered) and
822
+ `accountNotFound` (404, the application's request for an id with no account).
823
+
824
+ The application sends the links and notices through the optional
825
+ `auth.local.email-change-sender` capability, an async function given
826
+ `{ type: "confirmation", email, currentEmail, confirmationUrl }` (to the new
827
+ address) or `{ type: "notice", email, newEmail }` (to the old one). It is wired
828
+ like the recovery sender above and sends as `APP_ENV` says, as it does:
829
+ production to each address, staging only to `STAGING_EMAIL_TO` (with
830
+ `originalEmail`), development and test to the log. It runs after the request
831
+ has answered, and a failure is logged with the address, never answered.
832
+ Without one, development and test log each link and notice, and a staging or
833
+ production server has no email change: `features.emailChange` is false and the
834
+ operations answer
835
+ `AUTH_OPERATION_UNSUPPORTED`. A sender needs `APP_PUBLIC_URL`, which its links
836
+ name. The database backend keeps the waiting change in
837
+ `auth_local_users.pending_email` (migration `auth_local_db_users_pending_email`)
838
+ and sets `email_verified_at` when the link is used.
839
+
743
840
  ## Google, Microsoft and GitHub sign-in with local auth
744
841
 
745
842
  Local auth signs people in through Google, Microsoft and GitHub when the
@@ -803,8 +900,8 @@ the `auth_local_identities` and `auth_local_oauth_attempts` tables.
803
900
  ## Browser boundary
804
901
 
805
902
  `@jskit-ai/auth-web` owns the normal auth views, guard runtime, sign-out flow,
806
- and auth-aware HTTP integration. `DefaultLoginView`, `DefaultResetPasswordView`
807
- and `DefaultSignOutView` fill the window themselves: a card on
903
+ and auth-aware HTTP integration. `DefaultLoginView`, `DefaultResetPasswordView`,
904
+ `DefaultEmailChangeView` and `DefaultSignOutView` fill the window themselves: a card on
808
905
  `surface-container` on wide windows, the whole screen on phones, and each
809
906
  screen's one `h1` ("Sign in", "Create your account", "Reset password", ...).
810
907
  Every app shows its identity there, so a person always sees which app they are
@@ -813,7 +910,8 @@ beside the card on wide windows (`primary-container`, its children from top to
813
910
  bottom) and a compact row above the card on phones. The slot gets `{ compact }`
814
911
  to choose what to show, and holds no heading. The `auth/auth-surface` pattern
815
912
  does this already: its pages render the app's view wrappers
816
- (`src/views/auth/LoginView.vue`, `ResetPasswordView.vue`, `SignOutView.vue`),
913
+ (`src/views/auth/LoginView.vue`, `ResetPasswordView.vue`, `EmailChangeView.vue`,
914
+ `SignOutView.vue`),
817
915
  and each fills the slot with `src/components/AppBrand.vue`, the app's name as
818
916
  `index.html`'s `<title>` spells it. Renaming the app renames both:
819
917
 
@@ -11,9 +11,15 @@ description: Customize shared CRUD form actions and local validation guidance.
11
11
  its default content. The slot exposes `screen`, `mode`, `formRuntime`,
12
12
  `formState`, `addEdit`, `saveLabel`, the resolved
13
13
  `cancelTo` route target, and `submit`. Custom actions call `submit()` and bind
14
- their disabled state to `addEdit.isSubmitDisabled`. Keyboard submission uses
15
- the same runtime. `addEdit.isSaving` stays true through the request and
16
- asynchronous `onSaveSuccess` callback; duplicate
14
+ their disabled state to `addEdit.isSubmitDisabled` and their pending state to
15
+ `addEdit.isSubmitPending` (the save, or the record's reload after it, is
16
+ running). `ShellPageAction` takes both and keeps keyboard focus while it is
17
+ pending; a plain button, when possible, takes
18
+ `v-pending="addEdit.isSubmitPending"` and
19
+ `:disabled="addEdit.isSubmitDisabled && !addEdit.isSubmitPending"`, since a
20
+ focused button that becomes disabled drops focus to the page body. Keyboard
21
+ submission uses the same runtime. `addEdit.isSaving` stays true through the
22
+ request and asynchronous `onSaveSuccess` callback; duplicate
17
23
  submissions remain blocked during both.
18
24
 
19
25
  `useAddEdit()` and the `addEdit` runtime exposed by `useCrudAddEdit()` and
@@ -42,9 +48,13 @@ Inside `CrudAddEditScreen`, alongside the existing `fields` slot:
42
48
  <template #actions="{ addEdit, submit, saveLabel, cancelTo }">
43
49
  <v-btn v-if="cancelTo" variant="outlined" :to="cancelTo">Cancel</v-btn>
44
50
  <div>
45
- <v-btn :disabled="addEdit.isSubmitDisabled" @click="submit">
46
- {{ addEdit.isSaving ? "Saving…" : saveLabel }}
47
- </v-btn>
51
+ <ShellPageAction
52
+ primary
53
+ :label="addEdit.isSaving ? 'Saving…' : saveLabel"
54
+ :disabled="addEdit.isSubmitDisabled"
55
+ :pending="addEdit.isSubmitPending"
56
+ @click="submit"
57
+ />
48
58
  <p v-if="addEdit.validationAttempted" aria-live="polite">
49
59
  {{ Object.values(addEdit.validationErrors).join(" ") }}
50
60
  </p>
@@ -58,7 +68,8 @@ to clear the successfully saved model, call `screen.addEdit.resetValidation()`,
58
68
  and prepare the next entry. This callback replaces default success navigation
59
69
  and invalidation; perform those there when needed. Clear the model only in
60
70
  `onSaveSuccess`: `submit()` also resolves after invalid or failed submissions.
61
- Guard action selection with `isSubmitDisabled` and restore the default action
71
+ Guard action selection with `isSubmitDisabled` (true while pending too) and
72
+ restore the default action
62
73
  after each attempt so keyboard submission uses normal Save. Track the clicked
63
74
  button separately to keep guidance beside it while fields are corrected.
64
75
 
@@ -83,6 +83,11 @@ always does. Do not add authentication or workspace machinery to
83
83
  make up for an unneeded `always` override. Server access and ownership
84
84
  remain authoritative.
85
85
 
86
+ A `user` or `workspace_user` table's rows reach only the signed-in user, on
87
+ every route, never a `userId` the request sends. Keep such a table's default
88
+ route visibility: a `workspace` route over a `workspace_user` table reaches the
89
+ member's own rows too, but announces their changes to the whole workspace.
90
+
86
91
  The Books source patterns show user ownership. For a public create/list
87
92
  resource, use them with this table resource and CRUD contract:
88
93
 
@@ -37,7 +37,7 @@ through its handle's calls, and every call takes the call's `options` last:
37
37
  | `queryAll({ filters, sort, include, take }, options)` | every matching row, or the first `take`, for jobs, id lists and one parent's rows |
38
38
  | `queryPages({ filters, sort, include }, options)` | every matching row, a page at a time, for work over many rows |
39
39
  | `get(id, params, options)` | one record |
40
- | `aggregate({ measures, groupBy, filters, sort, page }, options)` | totals, grouped by fields or date buckets |
40
+ | `aggregate({ measures, groupBy, filters, sort, page }, options)` | totals, grouped by fields or date buckets; with `lockMode` in a transaction, one row of totals whose rows stay locked ([Layer 4](#layer-4-locks)) |
41
41
  | `create(data, options)`, `findOrCreate({ id, ...data }, options)` | one record; a keyed one, created once |
42
42
  | `patch(id, changes, options)`, `delete(id, options)` | one record |
43
43
  | `createMany(rows, options)` | many records, or an upsert with `onConflict` |
@@ -110,6 +110,16 @@ migration, a seed) sets its own. Pass the call's `options` (its context and
110
110
  transaction) to every handle call; a call without a context throws instead of
111
111
  guessing.
112
112
 
113
+ The owner a call reaches comes from its context, never from its input. A
114
+ request's context names the workspace its route resolved and the signed-in
115
+ user, on every route: a `workspace` route reaches the signed-in member's own
116
+ rows of a `user` or `workspace_user` table, as a `workspace_user` route does,
117
+ and stamps that member on the rows it creates. An owner value in the input that
118
+ differs is refused, a signed-out request reaches none of those rows (a
119
+ `MissingScopeError`), and a job context names the user `forUser` or
120
+ `forWorkspaceUser` gave it. So application code never sets `scopeValues.userId`
121
+ (lint `jskit/no-hand-context` refuses it).
122
+
113
123
  ```js
114
124
  // shared/receivalResource.js: the table's facts, shared with the client
115
125
  const receivalResource = defineTableResource({
@@ -999,6 +1009,56 @@ const file = (input, options) => documents.withTransaction(options, async (txOpt
999
1009
  await memberships.patch(input.membershipId, { lastFiledAt: new Date() }, txOptions);
1000
1010
  ```
1001
1011
 
1012
+ A save that decides on a count or a sum of many rows (an account's open
1013
+ invoices stay within its credit limit, a member holds at most five leases)
1014
+ takes a locking aggregate: `aggregate({ measures, filters }, { ...txOptions,
1015
+ lockMode: "share" })` answers one row of totals from one statement, with the
1016
+ lock on the rows they read held until the transaction ends, however many rows
1017
+ match, none of them read into the application. Never `lockWhere` and a count:
1018
+ it reads every id into the application and refuses past 1,000. `"share"` lets
1019
+ other such checks read the rows at once; `"update"` or `"noKeyUpdate"` hold
1020
+ them exclusively. An update or a delete of a counted row waits until the
1021
+ transaction ends. A new matching row differs by database: on MySQL and MariaDB
1022
+ its insert waits too, since InnoDB locks the index range the read walked
1023
+ (under REPEATABLE READ, their default; READ COMMITTED locks no range), while
1024
+ PostgreSQL's `FOR SHARE` holds only rows that exist, so an insert goes on and
1025
+ the transaction's next statement counts it (json-rest-api reads PostgreSQL's
1026
+ totals again until no row joined them while it waited). Two saves that each
1027
+ total and then insert would both pass a limit there. So a limit that must keep
1028
+ new rows out on every database also locks the one row that governs the set
1029
+ (the account, the member's record) with `lock` and the default `"update"`, as
1030
+ every writer of the set does first: the saves take turns, and the aggregate
1031
+ holds the rows already there against a write that skips that row (a patch of
1032
+ an amount).
1033
+
1034
+ On MySQL and MariaDB a locking aggregate reads through the index `lockWhere`
1035
+ needs and locks the entries it reads there: a count of rows reads that index
1036
+ alone, so a write of a column it leaves out goes on, while a sum, a distinct
1037
+ count or a measure's `where` over another column locks each row it reads. With
1038
+ `lockMode`, `groupBy` or `page` is a `TypeError` (total each group as a
1039
+ measure with a `where`, `{ open: { count: "*", where: { status: "open" } } }`),
1040
+ a call outside a transaction throws `RestApiLockOutsideTransactionError`, and
1041
+ a filter on another table's field, or a row policy that joins another table,
1042
+ is refused as in `lockWhere`: test the other table in a subquery.
1043
+
1044
+ ```js
1045
+ // good: the account locked first, as every writer of its invoices does; one statement totals what it owes
1046
+ const issue = (input, options) => invoices.withTransaction(options, async (txOptions) => {
1047
+ const account = await accounts.lock(input.accountId, { ...txOptions, fields: ["creditLimit"] });
1048
+ const [{ owed }] = await invoices.aggregate(
1049
+ { measures: { owed: { sum: "amount" } }, filters: { accountId: input.accountId, status: "open" } },
1050
+ { ...txOptions, lockMode: "share" }
1051
+ );
1052
+ if ((owed ?? 0) + input.amount > account.creditLimit) {
1053
+ throw new ConflictError("invoices.overCreditLimit");
1054
+ }
1055
+ return invoices.create(input, txOptions);
1056
+ });
1057
+
1058
+ // bad: every open invoice's id read into the application to be counted, refused past 1,000
1059
+ const open = await invoices.lockWhere({ accountId, status: "open" }, { ...txOptions, lockMode: "share", fields: ["amount"] });
1060
+ ```
1061
+
1002
1062
  Locks stay on the owner's handle and its owner API. A `scopedQuery()` or
1003
1063
  `joinSource()` builder takes no lock, not even a shared one: PostgreSQL's `FOR
1004
1064
  SHARE OF` an alias would lock only that source's rows, but MariaDB has no `FOR
@@ -274,8 +274,9 @@ dialog, chip or FAB.
274
274
  (`@jskit-ai/shell-web/client/components/ShellPageActions`), each a
275
275
  `ShellPageAction` with `icon`, `label` (also its accessible name and compact
276
276
  tooltip), and `primary`, `to`, `replace`, `href` (with `download` for a
277
- file, such as a CSV export), `disabled`, `loading` or `color` (`error` for a
278
- destructive one); attributes such as `target` reach its button. On compact
277
+ file, such as a CSV export), `disabled`, `pending`, `loading` or `color`
278
+ (`error` for a destructive one); attributes such as `target` reach its
279
+ button. On compact
279
280
  widths the bar shows the single `primary` action (a form's Save) and puts
280
281
  the other actions, and the top-right items that don't fit beside the title,
281
282
  in its "More actions" menu, where `overflow` actions always are; medium and
@@ -346,7 +347,8 @@ dialog, chip or FAB.
346
347
  - **Dialogs:** plain `v-dialog` and `v-bottom-sheet`; JSKIT gives them their
347
348
  Material 3 shapes. A full-screen dialog (compact and medium) puts close, title
348
349
  and its confirm action in a top bar, never at the bottom where a snackbar
349
- covers them.
350
+ covers them. While one is open, `ShellLayout` makes the page behind it
351
+ inert: run axe on the whole page.
350
352
  - **Menus and badges:** a menu's list has `role="menu"` and its items
351
353
  `role="menuitem"`, with `aria-disabled` on unavailable ones; a badge has a
352
354
  `label` such as "3 batches". JSKIT draws a menu's list and a dialog's card;
@@ -367,7 +369,12 @@ dialog, chip or FAB.
367
369
  loading uses Material skeletons that reserve the final content geometry;
368
370
  never use a generic spinner or circular progress indicator, and never let
369
371
  content jump when data arrives. An action without a loading content region
370
- uses a stable disabled/pending label and shared feedback, not a spinner.
372
+ uses a stable pending label ("Saving…") and shared feedback, not a spinner.
373
+ - While a command runs, mark its button pending rather than `disabled` when
374
+ possible: `pending` on `ShellPageAction` and `ShellPrimaryAction`,
375
+ `v-pending` on other buttons. It keeps keyboard focus, reads as unavailable
376
+ and ignores a second press; a focused button that becomes `disabled` drops
377
+ focus to the page body. Keep `disabled` for an action that cannot run.
371
378
  - Keep failures at their semantic owner. A resource that cannot render uses a
372
379
  stable in-page error and retry state; field validation stays beside the
373
380
  field. A user-triggered command uses JSKIT's shared action
@@ -17,8 +17,8 @@ in a JSKIT app. The rules it applies are already in [Material 3](/guide/framewor
17
17
  ## States on every screen
18
18
 
19
19
  - **Loading:** Material skeletons with the geometry of the content they stand
20
- for, never a spinner; an action keeps a stable label while it runs and
21
- cannot be sent twice ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
20
+ for, never a spinner; an action keeps a stable label and its keyboard focus
21
+ while it runs, and cannot be sent twice ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
22
22
  Ordinary reads stop after 30 seconds, so a slow read ends in its error state.
23
23
  - **Empty:** a list's empty state carries an icon, a line saying what would be
24
24
  there and one action, such as New; with filters or a search applied it
@@ -60,6 +60,12 @@ in a JSKIT app. The rules it applies are already in [Material 3](/guide/framewor
60
60
  width.
61
61
  - **Double submit:** click Save twice quickly; the command's pending state
62
62
  must send one request.
63
+ - **Keyboard through a running command:** Tab to Save (or Send, "Load more",
64
+ a dialog's confirm), press Enter and answer the request late
65
+ (`page.route`). Focus should stay on the button while it runs, and move to
66
+ the field a refusal marks. Focus on the page body there usually means the
67
+ button was `disabled` while it ran; mark it pending instead when possible
68
+ ([Material 3 rules](/guide/framework/material-3#components-state-and-feedback)).
63
69
  - **Session and tabs:** sign out in another tab and come back; let the session
64
70
  expire mid-form. The auth guard sends the person to sign-in and back.
65
71
  - **Time:** dates follow [strict temporal values](/guide/framework/crud-operations#strict-temporal-values);
@@ -53,7 +53,9 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
53
53
  context built by hand skips that scope: search for each. Confirm every
54
54
  `public` table is meant to be read by anyone.
55
55
  - Who acts is `resolveActor(context)`; the workspace comes from the context
56
- only, never from the body or another input
56
+ only, and so does the user whose `user` or `workspace_user` rows a request
57
+ reaches (the signed-in user, on every route), never from the body or another
58
+ input
57
59
  ([Request context](/guide/framework/typed-features#request-context)). A row
58
60
  policy decides from `caller` and the server-resolved `context.workspace`,
59
61
  `context.membership` and `context.permissions`, never from request input.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.332",
3
+ "version": "0.1.334",
4
4
  "description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
5
5
  "type": "module",
6
6
  "files": [
@@ -35,7 +35,7 @@
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
37
  "@jskit-ai/kernel": "0.2.27",
38
- "@jskit-ai/material-web": "0.1.8",
38
+ "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
41
41
  "pino": "^10.3.1",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/config-eslint": "0.1.252",
53
- "@jskit-ai/jskit-catalog": "0.2.84",
53
+ "@jskit-ai/jskit-catalog": "0.2.86",
54
54
  "@playwright/test": "1.61.1",
55
55
  "@vitejs/plugin-vue": "^6.0.7",
56
56
  "eslint": "^10.8.0",
@@ -35,7 +35,7 @@
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
37
  "@jskit-ai/kernel": "0.2.27",
38
- "@jskit-ai/material-web": "0.1.8",
38
+ "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
41
41
  "pino": "^10.3.1",
@@ -45,13 +45,13 @@
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
47
  "@jskit-ai/http-runtime": "0.2.27",
48
- "@jskit-ai/shell-web": "0.2.38",
48
+ "@jskit-ai/shell-web": "0.2.40",
49
49
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
50
50
  "@vue/devtools-api": "^8.2.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@jskit-ai/config-eslint": "0.1.252",
54
- "@jskit-ai/jskit-catalog": "0.2.84",
54
+ "@jskit-ai/jskit-catalog": "0.2.86",
55
55
  "@playwright/test": "1.61.1",
56
56
  "@vitejs/plugin-vue": "^6.0.7",
57
57
  "eslint": "^10.8.0",