@jskit-ai/agent-docs 0.1.318 → 0.1.320
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.
- package/guide/agent/app-setup/authentication.md +9 -4
- package/guide/agent/app-setup/multi-homing.md +24 -7
- package/guide/agent/framework/data-access.md +169 -14
- package/guide/agent/framework/typed-features.md +51 -9
- package/package.json +1 -1
- package/patterns/feature-package/example/booking-engine/package.json +1 -1
- package/patterns/minimal-foundation/example/package.json +4 -4
- package/patterns/shell-foundation/example/package.json +5 -5
- package/patterns/shell-foundation/example/packages/main/package.json +1 -1
- package/reference/autogen/KERNEL_MAP.md +4 -2
- package/reference/autogen/PATTERN_INDEX.md +38 -38
- package/reference/autogen/packages/auth-web.md +2 -0
- package/reference/autogen/packages/http-web.md +2 -0
- package/reference/autogen/packages/kernel.md +7 -4
- package/reference/autogen/packages/resource-runtime.md +6 -1
- package/skills/jskit/references/data-access.md +169 -14
- package/skills/jskit/references/heuristics/INDEX.md +2 -2
- package/skills/jskit/references/heuristics/live-actions.md +5 -0
- package/skills/jskit/references/heuristics/row-policies.md +3 -0
- package/skills/jskit/references/heuristics/server-search.md +1 -1
- package/skills/jskit/references/heuristics/typed-features.md +2 -0
- package/skills/jskit/references/multi-homing.md +24 -7
- package/skills/jskit/references/pattern-index.md +38 -38
- package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +4 -4
- package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +5 -5
- package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
- package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
- package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
- package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
- package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +4 -4
- package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
- package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
- package/skills/jskit/references/typed-features.md +51 -9
|
@@ -24,8 +24,9 @@ rule in [client features](client-features.md).
|
|
|
24
24
|
> so each call has exactly one visible destination for a reader and for the
|
|
25
25
|
> code map.
|
|
26
26
|
|
|
27
|
-
- A **capability** is a value a feature `provides`, `requires
|
|
28
|
-
(`optional`)
|
|
27
|
+
- A **capability** is a value a feature `provides`, `requires`, may use
|
|
28
|
+
(`optional`) or requires once every feature has booted (`late`), named by a
|
|
29
|
+
**token** such as `"feature.invoices"`.
|
|
29
30
|
- A **collaborator** is an object or function with behaviour that code calls:
|
|
30
31
|
a service, store, repository, runtime, router, publisher, catalogue, logger
|
|
31
32
|
or clock. Plain data (an input, a record, a list, an options bag) is not one.
|
|
@@ -42,8 +43,8 @@ it reports the call as exact instead of guessing from the method name.
|
|
|
42
43
|
### Feature files
|
|
43
44
|
|
|
44
45
|
**A `defineFeature` lives in `<Name>Feature.js`, its keys in one order, one
|
|
45
|
-
per line: `id, domain, owns, systemScope, requires, optional,
|
|
46
|
-
setup, actions, boot, shutdown`.** A `defineProvider` lives in `<Name>Provider.js`.
|
|
46
|
+
per line: `id, domain, owns, systemScope, requires, optional, late,
|
|
47
|
+
provides, setup, actions, boot, shutdown`.** A `defineProvider` lives in `<Name>Provider.js`.
|
|
47
48
|
|
|
48
49
|
- `setup` builds each provided value with a named `create<Name>` factory from
|
|
49
50
|
a module of its own, never inline. It returns exactly the keys `provides`
|
|
@@ -81,8 +82,8 @@ actions: ({ invoices }) => [{ id: "invoices.list", execute: () => invoices.list(
|
|
|
81
82
|
**A package's manifest, `jskit.capabilities` in its `package.json`, lists
|
|
82
83
|
exactly what its features provide, and every capability they require beyond
|
|
83
84
|
the kernel's own (`runtime.actions`, `runtime.events`, `runtime.http`,
|
|
84
|
-
`runtime.bootstrap`) and those the package provides itself.**
|
|
85
|
-
capabilities are not
|
|
85
|
+
`runtime.bootstrap`) and those the package provides itself.** Late
|
|
86
|
+
capabilities are required; optional ones are not. A requirement no feature has stays only when
|
|
86
87
|
the package needs it at install time, such as the database its migrations
|
|
87
88
|
need.
|
|
88
89
|
|
|
@@ -256,7 +257,8 @@ function createMailer({ env = process.env } = {}) {
|
|
|
256
257
|
- When the slot's supplier requires the slot's owner, the two form a cycle.
|
|
257
258
|
Split the part of the owner the supplier needs into its own feature. Until
|
|
258
259
|
then the setter stays, with a `cycle:` [exception comment](#exceptions), and
|
|
259
|
-
is cleared at shutdown.
|
|
260
|
+
is cleared at shutdown. A value with no default that the owner reads only
|
|
261
|
+
when called is no slot: it is a [late requirement](#late-requirements).
|
|
260
262
|
|
|
261
263
|
Why: a slot filled later makes a call's destination depend on what ran
|
|
262
264
|
before.
|
|
@@ -286,6 +288,46 @@ function setNumbering(next) {
|
|
|
286
288
|
}
|
|
287
289
|
```
|
|
288
290
|
|
|
291
|
+
### Late requirements
|
|
292
|
+
|
|
293
|
+
**A capability that closes a ring and is read only when called, such as by a
|
|
294
|
+
row policy, is `late`: the kernel resolves it once every feature has booted,
|
|
295
|
+
and code reads it from the capabilities object at call time, never in
|
|
296
|
+
`setup()` or `boot()`.**
|
|
297
|
+
|
|
298
|
+
- Split the ring first ([capability cycles](data-access.md#capability-cycles)).
|
|
299
|
+
A late requirement is for a ring a call-time read closes, after splitting
|
|
300
|
+
is not possible or not wanted.
|
|
301
|
+
- `late` maps local names to tokens, as `requires` does, with names no other
|
|
302
|
+
map of the feature uses. It never names a token the feature provides,
|
|
303
|
+
requires or takes as optional.
|
|
304
|
+
- It is required: when nothing provides it, start-up fails at the end of
|
|
305
|
+
boot, naming the feature and the token, and the package manifest lists it.
|
|
306
|
+
- A row policy reads it from `requires`
|
|
307
|
+
([data access](data-access.md#late-requirements)). A value
|
|
308
|
+
`setup()` builds receives the capabilities object, typed, and reads the
|
|
309
|
+
late name in its methods; `setup()` never destructures it. A read before
|
|
310
|
+
every feature has booted throws, naming the feature, the name and the token.
|
|
311
|
+
|
|
312
|
+
Why: the token is declared and the kernel resolves it once, so a call's
|
|
313
|
+
destination never depends on what ran before, as it does with a setter.
|
|
314
|
+
|
|
315
|
+
```js
|
|
316
|
+
// good: the token declared late; the factory reads it when a report runs
|
|
317
|
+
late: {
|
|
318
|
+
evidence: "evidence.files"
|
|
319
|
+
},
|
|
320
|
+
/** @param {{ resources: { auditEntries: import("@jskit-ai/resource-runtime/server/types").ResourceHandle }, evidence: import("@local/evidence/server/types").EvidenceFiles }} capabilities */
|
|
321
|
+
setup(capabilities) {
|
|
322
|
+
return { reports: createAuditReports({ capabilities }) };
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
// bad: destructured in setup, before every feature has booted; start-up fails
|
|
326
|
+
setup({ resources, evidence }) {
|
|
327
|
+
return { reports: createAuditReports({ entries: resources.auditEntries, evidence }) };
|
|
328
|
+
},
|
|
329
|
+
```
|
|
330
|
+
|
|
289
331
|
### Owned state
|
|
290
332
|
|
|
291
333
|
**A capability owns its state: built in `setup()`, started in `boot()`,
|
|
@@ -1156,7 +1198,7 @@ Why: the limits measure code a person reads; a table is scanned, not read.
|
|
|
1156
1198
|
an object that spans lines, braces once an `if` spans lines.** `eslint --fix`
|
|
1157
1199
|
applies it.
|
|
1158
1200
|
|
|
1159
|
-
- A returned frozen result and a `requires`, `optional` or `provides` map put
|
|
1201
|
+
- A returned frozen result and a `requires`, `optional`, `late` or `provides` map put
|
|
1160
1202
|
each property on its own line. A short leaf literal of at most three scalar
|
|
1161
1203
|
properties (`{ type: "string", required: true }`) may stay on one line.
|
|
1162
1204
|
- Long prose stays inline in its string or template; never split a sentence
|
|
@@ -1299,7 +1341,7 @@ Every finding ends with a link to the section of this page that explains it.
|
|
|
1299
1341
|
| `jskit/no-patched-error` | `Object.assign(new Error(…), { statusCode })`, or an error builder's result given its status afterwards | [One construction per error](#one-construction-per-error) |
|
|
1300
1342
|
| `jskit/no-test-only-export` | an export whose name says only tests use it (`…ForTests`, `__reset…`; `__testables` aside) | [No test-only exports](#no-test-only-exports) |
|
|
1301
1343
|
| `jskit/narrow-in-query` | `.filter()`, `.find()`, `.some()`, `.every()`, `.slice()`, a lone `.length` or a loop that skips with `continue`, over the rows a read in the same function answered and uses no other way | [Narrow in the query](#narrow-in-the-query) |
|
|
1302
|
-
| `jskit/one-property-per-line` | two properties on one line in a returned `Object.freeze({ … })` or a `requires` / `optional` / `provides` map (`eslint --fix` splits them) | [Formatter](#formatter) |
|
|
1344
|
+
| `jskit/one-property-per-line` | two properties on one line in a returned `Object.freeze({ … })` or a `requires` / `optional` / `late` / `provides` map (`eslint --fix` splits them) | [Formatter](#formatter) |
|
|
1303
1345
|
| `jskit/jsdoc-description-inside` | a `//` description directly above a `/** */` block | [Comments](#comments) |
|
|
1304
1346
|
| `jskit/allow-comment-form` | a `readable-check: allow` reason without a prefix from the table below, or one that cites tests or the state of a project | [Exceptions](#exceptions) |
|
|
1305
1347
|
| `max-lines`, `max-lines-per-function` | files over 750 lines, functions over 600 | [Size limits](#size-limits) |
|