create-flowdular 0.4.0 → 0.4.3

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 (32) hide show
  1. package/agent-template/.agents/skills/module-new/SKILL.md +20 -19
  2. package/agent-template/.agents/skills/module-update/SKILL.md +4 -2
  3. package/agent-template/.agents/skills/spec-interview/SKILL.md +21 -20
  4. package/agent-template/.agents/skills/ux-design/SKILL.md +23 -1
  5. package/agent-template/.ai/platform-capabilities.md +8 -4
  6. package/agent-template/.ai/policies/capabilities.yaml +1 -0
  7. package/agent-template/.ai/references/catalog/module.json +1 -1
  8. package/agent-template/.ai/references/catalog/package.json +2 -2
  9. package/agent-template/.ai/references/catalog/spec/module.yaml +1 -1
  10. package/agent-template/.ai/references/catalog/src/client/CatalogItemForm.tsrx +4 -4
  11. package/agent-template/.ai/references/catalog/src/client/CatalogView.tsrx +28 -27
  12. package/agent-template/.ai/references/catalog.provenance.json +8 -8
  13. package/agent-template/.ai/skills/module-new/SKILL.md +20 -19
  14. package/agent-template/.ai/skills/module-update/SKILL.md +4 -2
  15. package/agent-template/.ai/skills/spec-interview/SKILL.md +21 -20
  16. package/agent-template/.ai/skills/ux-design/SKILL.md +23 -1
  17. package/agent-template/.claude/skills/module-new/SKILL.md +20 -19
  18. package/agent-template/.claude/skills/module-update/SKILL.md +4 -2
  19. package/agent-template/.claude/skills/spec-interview/SKILL.md +21 -20
  20. package/agent-template/.claude/skills/ux-design/SKILL.md +23 -1
  21. package/agent-template/docs/cli.md +3 -0
  22. package/agent-template/docs/configuration.md +17 -0
  23. package/agent-template/docs/design-system.md +8 -1
  24. package/agent-template/docs/module-web-surfaces.md +31 -3
  25. package/package.json +1 -1
  26. package/template/default/modules/example/module.json +1 -1
  27. package/template/default/modules/example/package.json +1 -1
  28. package/template/default/modules/example/spec/module.yaml +1 -1
  29. package/template/default/package.json +1 -1
  30. package/template/default/platform/octane.config.ts +26 -2
  31. package/template/default/platform/package.json +1 -1
  32. package/template/default/platform/scripts/dev.mjs +16 -1
@@ -20,25 +20,26 @@ Every `acceptanceScenarios[]` entry maps to at least one test in `tests/`. A sce
20
20
 
21
21
  Each spec element maps to files:
22
22
 
23
- | Spec element | Files it produces |
24
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
- | `entities[]` | `src/domain/types.ts`, `migrations/000N_<module>_<name>.{up,down}.sql`, `src/services/migration.ts`, `src/services/{repository,database-repository}.ts` |
26
- | `entities[].fields[]` | the columns and row mapping above, the validation bounds in `src/api/endpoints.ts`, the form field and table cell in `src/client/*.tsrx` |
27
- | `fields[].unique: tenant` | a `(tenant_id, <field>)` unique index in the migration plus the stable conflict code in the service |
28
- | `entities[].states` | the status column, the transition guard in the service, the `Tag` tone in the view |
29
- | `screens[]` | `src/client/<Pascal>View.tsrx`, a `views` entry and a `navigation` entry in `src/client/contribution.tsrx`, `translations/*.json` |
30
- | `screens[].columns`/`filters` | the `TableColumn[]` outside the component, and the controls inside the `Filters` dropdown |
31
- | `screens[].navigationGroup` | the navigation entry's `group` |
32
- | `actions[]` | the service method with its error code, the `defineEndpoint` route, the fetch in `src/client/api.ts` |
33
- | `widgets[]` | a widget component plus a `widgets` entry with its `slot` in `src/client/contribution.tsrx` |
34
- | `settings[]` | `src/settings.ts` (`defineModuleSettings`) and `settings:` in `src/platform.ts` |
35
- | `agentTools[]` | `src/agent/tools.ts` and the `context.agentTools.register` call, as a separate `agent-tool-design` phase |
36
- | `research` | `src/research.ts`, `research-fixtures.json`, `requires` of the capabilities, the evidence attach where the `evidenceOwner` record is written |
37
- | `adapters[]` | `src/adapters/<name>.ts`, the port, the adapter registration, `adapters/<name>.recorded.json`, as a separate `integration-adapter` phase |
38
- | `templates[]` | `templates/<name>.md`, `templates` in `package.json` `files`, `src/templates.ts` registered through `documents.templates.v1` in `src/platform.ts` |
39
- | `permissions[]` | `src/acl/permissions.ts`, the endpoint `access.permission`, the client `scope` |
40
- | `acceptanceScenarios[]` | `tests/module.test.ts` and its siblings, at least one case each |
41
- | `outOfScope[]`, `decisions[]` | no code. Read them so you do not rebuild a decision or implement a deferred feature. |
23
+ | Spec element | Files it produces |
24
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `entities[]` | `src/domain/types.ts`, `migrations/000N_<module>_<name>.{up,down}.sql`, `src/services/migration.ts`, `src/services/{repository,database-repository}.ts` |
26
+ | `entities[].fields[]` | the columns and row mapping above, the validation bounds in `src/api/endpoints.ts`, the form field and table cell in `src/client/*.tsrx` |
27
+ | `fields[].unique: tenant` | a `(tenant_id, <field>)` unique index in the migration plus the stable conflict code in the service |
28
+ | `entities[].states` | the status column, the transition guard in the service, the `Tag` tone in the view |
29
+ | `screens[]` | `src/client/<Pascal>View.tsrx`, a `views` entry and a `navigation` entry in `src/client/contribution.tsrx`, `translations/*.json` |
30
+ | `design/<screen>.html` | the approved look of that screen: mirror its structure and keep its copy. Render it with `pnpm ui:preview <path>`; absent, design it first with `ux-design` |
31
+ | `screens[].columns`/`filters` | the `TableColumn[]` outside the component, and the controls inside the `Filters` dropdown |
32
+ | `screens[].navigationGroup` | the navigation entry's `group` |
33
+ | `actions[]` | the service method with its error code, the `defineEndpoint` route, the fetch in `src/client/api.ts` |
34
+ | `widgets[]` | a widget component plus a `widgets` entry with its `slot` in `src/client/contribution.tsrx` |
35
+ | `settings[]` | `src/settings.ts` (`defineModuleSettings`) and `settings:` in `src/platform.ts`; a `kind: flag` entry keeps `kind: 'flag'` there, so owners switch it on the Flags tab of Administration, Modules |
36
+ | `agentTools[]` | `src/agent/tools.ts` and the `context.agentTools.register` call, as a separate `agent-tool-design` phase |
37
+ | `research` | `src/research.ts`, `research-fixtures.json`, `requires` of the capabilities, the evidence attach where the `evidenceOwner` record is written |
38
+ | `adapters[]` | `src/adapters/<name>.ts`, the port, the adapter registration, `adapters/<name>.recorded.json`, as a separate `integration-adapter` phase |
39
+ | `templates[]` | `templates/<name>.md`, `templates` in `package.json` `files`, `src/templates.ts` registered through `documents.templates.v1` in `src/platform.ts` |
40
+ | `permissions[]` | `src/acl/permissions.ts`, the endpoint `access.permission`, the client `scope` |
41
+ | `acceptanceScenarios[]` | `tests/module.test.ts` and its siblings, at least one case each |
42
+ | `outOfScope[]`, `decisions[]` | no code. Read them so you do not rebuild a decision or implement a deferred feature. |
42
43
 
43
44
  A v1 spec stays valid and carries none of these arrays. Then the requirements are `invariants`, `permissions` and `acceptanceScenarios`, and everything the spec leaves open is still a question rather than a guess.
44
45
 
@@ -16,7 +16,7 @@ The spec-element to file mapping is the table in `module-new`; the change classe
16
16
 
17
17
  ## 1. Read first
18
18
 
19
- Read the whole module before changing it: `spec/module.yaml`, `src/index.ts`, `src/acl/permissions.ts`, `src/api/endpoints.ts`, `src/services/*`, `src/client/*`, `tests/`. Keep every exported name in `src/index.ts`, `src/server/index.ts` and `src/client/index.ts` stable: other modules import them (`modules/users` uses `AuthRuntime` from `@flowdular/sdk/modules/auth/server`), and the generated composition imports `createServerComposition` and `createClientContribution`.
19
+ Read the whole module before changing it: `spec/module.yaml`, `design/*.html` when the change touches a screen, `src/index.ts`, `src/acl/permissions.ts`, `src/api/endpoints.ts`, `src/services/*`, `src/client/*`, `tests/`. Keep every exported name in `src/index.ts`, `src/server/index.ts` and `src/client/index.ts` stable: other modules import them (`modules/users` uses `AuthRuntime` from `@flowdular/sdk/modules/auth/server`), and the generated composition imports `createServerComposition` and `createClientContribution`.
20
20
 
21
21
  Sandbox facts for an edit session (`packages/sandbox/src/server/sessions.ts`): the module is copied to `workspace/modules/<dir>` and a pristine copy to `base/modules/<dir>`; the diff shown to the operator and the eject plan compare the two. The workspace is a pnpm workspace of its own (declared dependencies install for real; a `package.json` change triggers a reinstall that counts as the `dependencies` gate). The business manager updates the spec before implementation. The operator approves the exact spec hash for every affected module; editing that spec, requesting changes, or adding another module reopens its approval gate. A sandbox specialist never writes `status: approved`; a host agent may invoke approval only after an explicit current user request through `spec-approval`. Delivery checks the recorded hash again.
22
22
 
@@ -55,9 +55,11 @@ New screen or widget:
55
55
  3. `src/client/index.ts`: re-export the view.
56
56
  4. Add user-facing copy to every declared `translations/*.json` bundle and resolve it with fully qualified `t()` keys. Navigation copy uses getters because contributions exist before bundles are registered.
57
57
 
58
+ New feature flag: a setting with `kind: 'flag'`, `type: 'boolean'`, `scope: 'tenant'` and a `defaultValue`. It reads like any other setting, `context.settings.get<boolean>(tenantId, '<module>.core', 'key')`, and appears on the Flags tab of Administration, Modules beside the module's other flags; a change is audited as `settings.flag.changed`. Declare it in the spec as `kind: flag` too, and state in an invariant what the module does while it is off. Before changing behaviour a workspace already relies on, removing a step, or adding an outward-facing or costly path, propose a flag and let the operator decide: ship the new path behind it, default off, and keep the old path working while it is off. A flag is on or off for one workspace; there is no percentage rollout and no targeting.
59
+
58
60
  New setting:
59
61
 
60
- 1. `src/settings.ts`: `export const X_MODULE_SETTINGS = defineModuleSettings({ moduleId: '<module>.core', settings: { key: { type: 'string' | 'number' | 'boolean', defaultValue, visibility: 'private' | 'shared', client: boolean, scope: 'tenant' | 'platform', labelKey, label, descriptionKey, description, min?, max?, enum?, secret? } } })` from `@flowdular/sdk/kernel` (`packages/kernel/src/module-settings.ts`; setting keys match `^[a-z][a-zA-Z0-9]*$`). `labelKey` and `descriptionKey` are fully qualified module translation keys present in every locale. Keep the English literals as compatibility fallbacks; values, ids and secrets are never translated.
62
+ 1. `src/settings.ts`: `export const X_MODULE_SETTINGS = defineModuleSettings({ moduleId: '<module>.core', settings: { key: { type: 'string' | 'number' | 'boolean', kind?: 'flag', defaultValue, visibility: 'private' | 'shared', client: boolean, scope: 'tenant' | 'platform', labelKey, label, descriptionKey, description, min?, max?, enum?, secret? } } })` from `@flowdular/sdk/kernel` (`packages/kernel/src/module-settings.ts`; setting keys match `^[a-z][a-zA-Z0-9]*$`). `labelKey` and `descriptionKey` are fully qualified module translation keys present in every locale. Keep the English literals as compatibility fallbacks; values, ids and secrets are never translated.
61
63
  2. `src/platform.ts`: return `settings: X_MODULE_SETTINGS` next to `routes`; the platform declares it at boot and Administration, Modules renders it in the module's drawer (`modules/system/src/client/ModuleSettingsSection.tsrx`, behind `system.settings.read` and `system.settings.manage`; the API is `GET /api/settings` and `POST /api/settings/update` in `modules/system/src/server/endpoints.ts`).
62
64
  3. Read it live where it is used: `context.settings.get<number>(tenantId, '<module>.core', 'key')` at request time, never cached at boot; pass `context.settings` into the runtime or service that needs it (`modules/agents/src/settings.ts`, `agentSettings`, shows the pattern with an environment fallback).
63
65
  4. `spec/module.yaml`: an invariant or scenario naming the setting and its bounds; `specVersion` bump. Cross-module reads of a setting need `visibility: 'shared'` and a declared dependency.
@@ -23,25 +23,26 @@ For an edit, also read the module's current `spec/module.yaml` and write the sma
23
23
 
24
24
  One pass, in this order. For each row, write the default from the card into the spec and record it as a `decisions[]` entry with `decidedBy: default`. Ask only where the answer is a business fact that no default can supply.
25
25
 
26
- | Decision | Default to propose | Lands in |
27
- | ---------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------- |
28
- | Actors | Owner manages, member reads | `permissions`, `invariants` |
29
- | Entities and fields | One primary entity; `name` required, `maxLength` 120; no field the request did not name | `entities[]` |
30
- | Uniqueness | The human-facing code is `unique: tenant`; everything else `none` | `entities[].fields[].unique` |
31
- | States and transitions | `active` and `archived`, every transition behind the manage permission | `entities[].states` |
32
- | Who sees what | Both permissions in the same navigation entry; the manage action hidden without the scope | `permissions`, `screens[]`, `invariants` |
33
- | What is denied | Unauthenticated 401, missing permission 403, cross-tenant read returns nothing | `acceptanceScenarios` |
34
- | Failure behaviour | A duplicate returns a stable conflict and changes nothing; bounds return 400 | `invariants`, `acceptanceScenarios` |
35
- | Cross-module reads | None. A read of another module goes through its public capability and a declared dependency | `dependencies`, `dataOwnership` |
36
- | Screens | One `list` screen with the entity's identifying columns | `screens[]` |
37
- | Widgets | None. A count belongs on `dashboard.metrics` only when the request asks for it | `widgets[]` |
38
- | Settings | None. A number the business may change later is `scope: tenant` with a stated default | `settings[]` |
39
- | Agent tools | None. A tool is a later phase and `risk` may only be `read` or `workspace-write` | `agentTools[]` |
40
- | Outside sources | None. A named public source is `research`, with the entity its findings attach to | `research` |
41
- | Other systems | None. A named system is one `source` adapter per record kind, run on demand | `adapters[]` |
42
- | Documents | None. A named document is one `templates[]` entry on the record it describes | `templates[]` |
43
- | Reports | None. There is no export, no PDF and no search; a report is a screen or it is out of scope | `outOfScope[]` |
44
- | Out of scope | Every item from the card's gap list the request touched, each with its business decision | `outOfScope[]`, `decisions[]` |
26
+ | Decision | Default to propose | Lands in |
27
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
28
+ | Actors | Owner manages, member reads | `permissions`, `invariants` |
29
+ | Entities and fields | One primary entity; `name` required, `maxLength` 120; no field the request did not name | `entities[]` |
30
+ | Uniqueness | The human-facing code is `unique: tenant`; everything else `none` | `entities[].fields[].unique` |
31
+ | States and transitions | `active` and `archived`, every transition behind the manage permission | `entities[].states` |
32
+ | Who sees what | Both permissions in the same navigation entry; the manage action hidden without the scope | `permissions`, `screens[]`, `invariants` |
33
+ | What is denied | Unauthenticated 401, missing permission 403, cross-tenant read returns nothing | `acceptanceScenarios` |
34
+ | Failure behaviour | A duplicate returns a stable conflict and changes nothing; bounds return 400 | `invariants`, `acceptanceScenarios` |
35
+ | Cross-module reads | None. A read of another module goes through its public capability and a declared dependency | `dependencies`, `dataOwnership` |
36
+ | Screens | One `list` screen with the entity's identifying columns | `screens[]` |
37
+ | Widgets | None. A count belongs on `dashboard.metrics` only when the request asks for it | `widgets[]` |
38
+ | Settings | None. A number the business may change later is `scope: tenant` with a stated default | `settings[]` |
39
+ | Feature flags | Ask for one whenever a change alters behaviour a workspace already relies on, or is hard to undo: `kind: flag`, boolean, `scope: tenant`, a stated default, and the behaviour named in an invariant | `settings[]` |
40
+ | Agent tools | None. A tool is a later phase and `risk` may only be `read` or `workspace-write` | `agentTools[]` |
41
+ | Outside sources | None. A named public source is `research`, with the entity its findings attach to | `research` |
42
+ | Other systems | None. A named system is one `source` adapter per record kind, run on demand | `adapters[]` |
43
+ | Documents | None. A named document is one `templates[]` entry on the record it describes | `templates[]` |
44
+ | Reports | None. There is no export, no PDF and no search; a report is a screen or it is out of scope | `outOfScope[]` |
45
+ | Out of scope | Every item from the card's gap list the request touched, each with its business decision | `outOfScope[]`, `decisions[]` |
45
46
 
46
47
  A default you propose is still a decision: it goes into `decisions[]` so the operator can see and overturn it, and so the next agent never re-derives it.
47
48
 
@@ -89,7 +90,7 @@ A number the case needs (a score, a premium, a price per square metre) is an `ac
89
90
  - `screens[]`: `{ id, kind: list|record|form|dashboard, entity?, title?, columns?, filters?, navigationGroup? }`. `navigationGroup` is one of the six values on the card.
90
91
  - `actions[]`: `{ id, entity?, permission, kind: create|update|delete|custom, risk, idempotent, description }`. `risk: external` is refused by the platform, so an action may not declare it.
91
92
  - `widgets[]`: `{ id, slot, entity?, description }`; `slot` is one of the four workspace slots.
92
- - `settings[]`: `{ key, type: string|integer|boolean|enum, scope: tenant|platform, default?, values?, description }`.
93
+ - `settings[]`: `{ key, type: string|integer|boolean|enum, scope: tenant|platform, kind?: setting|flag, default?, values?, description }`. A `flag` is boolean, `scope: tenant` and carries a default; owners switch it per workspace on the Flags tab of Administration, Modules, and every change is audited. Ask whether the new behaviour ships behind one: a change to something a workspace already does, an outward-facing action, a costly or slow path, or anything a business would want to turn off without a deployment. Say what the module does with the flag off, as an invariant.
93
94
  - `agentTools[]`: `{ id, permission, description, risk: read|workspace-write }`.
94
95
  - `outOfScope[]`: plain sentences, each naming the gap and the decision taken instead.
95
96
  - `decisions[]`: `{ id, question, answer, decidedBy: user|default }`; ids match `^[A-Z][A-Z0-9-]+$`, for example `D-UNIQUE-SKU`.
@@ -93,7 +93,28 @@ Layout `ui-view`, `ui-two-col` (+`--wide-aside`), `ui-grid-2`, `ui-kpi-grid`, `u
93
93
 
94
94
  User-facing copy lives in every declared `translations/*.json` bundle and is read with fully qualified `t()` keys. Eyebrow names the domain, title names the records, and description is one sentence. Table headers say what the value is. Buttons start with a verb. Loading text ends with `…`. Drawer footer states the constraint the user cannot see. Write natural copy in each locale, with no exclamation marks or database jargon.
95
95
 
96
- ## 7. Inspect the rendered screen
96
+ ## 7. Design the screen as a preview first
97
+
98
+ A design is a file, not a description: `modules/<dir>/design/<screen>.html`, beside the spec. It is markup only, dressed by the platform's own stylesheets, so it shows what the screen will look like before a component exists and long before the application boots. An implementation phase reads it the way it reads the spec.
99
+
100
+ ```bash
101
+ pnpm ui:preview modules/<dir>/design/<screen>.html --scaffold # the record recipe in all five states
102
+ pnpm ui:preview modules/<dir>/design/<screen>.html # renders it, prints a file:// address
103
+ pnpm ui:preview modules/<dir>/design/<screen>.html --shot .flowdular/ui-preview/<screen>.png
104
+ pnpm ui:preview modules/<dir>/design/<screen>.html --open # shows it to the person asking
105
+ ```
106
+
107
+ Rules that keep a preview honest:
108
+
109
+ - Markup only. No `<style>`, no CSS rule, no `<html>` or `<body>`; the command refuses a fragment that carries one. Every visual decision comes from `packages/ui`, which is what stops a preview from becoming a second source of truth.
110
+ - One `<section class="ui-view" data-state="...">` per state: `populated`, `loading`, `empty`, `error`, `denied`. The command labels each one, so a single page answers for all five.
111
+ - Real content. The longest realistic name, a real identifier, the copy the screen will actually carry. A preview of `Lorem ipsum` proves nothing about overflow or alignment.
112
+ - Only classes a stylesheet declares. `pnpm ui-classes:check` fails on a class nothing defines, in a preview and in a `.tsrx` alike, which is the one mistake that compiles, passes its tests and renders unstyled. A class a module needs and the design system lacks is declared in the module's own CSS, as rule 4 says.
113
+ - `--shot` writes a PNG, which is how an agent with no browser looks at its own work. `--open` opens the preview in the person's browser, which is how a design is shown for approval; a correction loop renders without it rather than throwing a window at whoever is at the keyboard.
114
+
115
+ Hand off the path, not a description. An implementation phase opens the preview, mirrors its structure with the components in section 4, and keeps the copy.
116
+
117
+ ## 8. Inspect the rendered screen
97
118
 
98
119
  A screen is not finished until it has been looked at. Typecheck and tests say nothing about overflow, alignment, a duplicate label or a column that collapses.
99
120
 
@@ -117,6 +138,7 @@ Check the drawer form in the same pass: one label per field, fields top-aligned,
117
138
 
118
139
  ## Pitfalls
119
140
 
141
+ - A preview that renders unstyled is a class nothing declares, not a broken harness; run `pnpm ui-classes:check`.
120
142
  - `Kpi value={items.length}` does not typecheck; use `String(items.length)`.
121
143
  - A `Tag` for a lifecycle state uses `success` for active and `neutral` for archived, with `dot`.
122
144
  - An `Icon` inside `Button size="sm"` is 14, not 18.
@@ -8,7 +8,11 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
8
8
 
9
9
  **Tenant identity.** Every request carries a principal resolved by `modules/auth`. `principalFromContext(octane)!.tenantId` is the only tenant authority; a tenant id from a body, query or header is a defect. Row-level security binds the same id inside the transaction.
10
10
 
11
- **Authorization.** `defineEndpoint` (`packages/server/src/endpoint.ts`) takes `id`, `path`, `methods`, `handler` and `access`. `access` is either `{ kind: 'public' }` or `{ kind: 'permission', permission }` with `resolveIdentity: endpointIdentityFromContext`. A protected endpoint answers 401 `UNAUTHENTICATED` without an identity and 403 `FORBIDDEN` without the permission. Permission ids match `^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$` and are declared in the spec `permissions`, in `src/acl/permissions.ts` and on the endpoint. CSRF and input bounds are not endpoint options: mutations call `sessionMutationDenial(octane, auth)` first (`modules/auth/src/server/session-security.ts`) and parse the body through `readJsonObject`, `requiredString`, `optionalString`, `requiredInteger` (`packages/server/src/http.ts`, 415 without JSON, 413 over 16 KB).
11
+ **Authorization.** `defineEndpoint` (`packages/server/src/endpoint.ts`) takes `id`, `path`, `methods`, `handler` and `access`. `access` is either `{ kind: 'public' }` or `{ kind: 'permission', permission }` with `resolveIdentity: endpointIdentityFromContext`. A protected endpoint answers 401 `UNAUTHENTICATED` without an identity and 403 `FORBIDDEN` without the permission. Permission ids match `^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$` and are declared in the spec `permissions`, in `src/acl/permissions.ts` and on the endpoint. CSRF and input bounds are not endpoint options: mutations call `sessionMutationDenial(octane, auth)` first (`modules/auth/src/server/session-security.ts`) and parse the body through `readJsonObject`, `requiredString`, `optionalString`, `requiredInteger` (`packages/server/src/http.ts`, 415 without JSON, 413 over 16 KB). That same guard is what admits a machine caller: it passes a browser session with a same origin and a valid CSRF token, or an API token the workspace issued with writes allowed, and answers 403 `TOKEN_MUTATION_DENIED` to a token issued without them. A mutation that shapes who may reach the workspace calls `browserSessionMutationDenial` instead, which refuses every token; auth.core's own routes are the ones that do.
12
+
13
+ **External API.** Every endpoint records itself in the process endpoint catalogue as it is defined (`packages/server/src/endpoint-catalog.ts`), so a module is described without declaring anything twice. `defineEndpoint` takes an optional `documentation` with `summary`, `description`, `parameters`, `body` and `responses`, validated at definition time and bounded (160-character summary, 32 parameters, 16 responses, 16 KB per JSON Schema); an endpoint that declares none is still described by its address, its methods and the permission it demands. `GET /api/openapi.json` (`platform/src/server/openapi.ts`) answers OpenAPI 3.1 built for the presented credential: it needs a browser session or an API token, and leaves out every operation whose permission the caller does not hold and every operation of a module inactive in its workspace. Each operation carries `x-flowdular-module`, `x-flowdular-permission` and `x-flowdular-token-write`. The Administration screen `system.core` API lists the same document. A module adds nothing to be included; it is in the document as soon as it composes.
14
+
15
+ **API tokens and cross-origin access.** A workspace owner issues a token in Administration, API tokens, with the scopes it may use, an optional expiry, whether it may write, and the browser origins it may be presented from (`modules/auth/src/server/token-endpoints.ts`). Its authority is the intersection of its recorded scopes with the live membership at every request. Writes are off unless the owner asked; a token that names no origin is refused from every browser origin and is meant for a server-side caller; a token that names some is refused from anywhere else with 403 `TOKEN_ORIGIN_DENIED`. A cross-origin preflight carries no credential, so `createCorsMiddleware` (`packages/server/src/cors.ts`, composed in `platform/octane.config.ts`) answers it from the union of the origins the deployment's live tokens declare, and never sends `access-control-allow-credentials`, so no cross-origin page can read an API response with the dashboard's session cookie. A token also carries the requests per minute it may spend, and one issued with none spends the platform setting `auth.core.apiTokenRateLimit` (default 600, 0 removes the ceiling); the request over it is answered 429 `TOKEN_RATE_LIMITED` with `retry-after`, every answer to a limited token carries `x-ratelimit-limit`, `-remaining` and `-reset`, and every request a token made, refused ones included, plus the refused subset, are counted as auth.core module metrics on `/api/metrics`. The window is a fixed minute per token in each process (`modules/auth/src/middleware/rate-limit.ts`), bounded to 4096 credentials, so it guards against one integration running away rather than accounting for usage. Nothing here is an environment variable; issuing or revoking a token, or changing the setting, takes effect live.
12
16
 
13
17
  **Record policies.** A permission answers who may act on a kind of record; a policy answers whether this record allows it. `definePolicy` (`packages/kernel/src/acl.ts`) declares `{ id, permission, evaluate }`, where `evaluate({ principal, permission, record, action })` returns `{ allowed: true }` or `{ allowed: false, reason, requiresApproval? }`; `requiresApproval.requirement` carries `roleKey`, `scope`, `decisions` and `expiresInDays`, and nothing more: resolving a role to people, collecting their decisions and keeping the receipt belong to `approvals.core`, described below. Policies are registered into a `createPolicyRegistry()` while the module composes, at most 256, one registration per id, and the registry is sealed before requests run. An endpoint calls `authorizeRecord(registry, principal, permission, record, action?)`, which checks the permission scope first and then the policies of that permission in registration order, answering the first denial. A permission with no policy is allowed by the scope alone, and a policy that throws denies. The platform does not hand a module a shared registry yet, so a module that wants record conditions today owns its registry inside its own composition.
14
18
 
@@ -22,7 +26,7 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
22
26
 
23
27
  **Module settings.** `defineModuleSettings` (`packages/kernel/src/module-settings.ts`) declares `{ moduleId, settings }`. A setting has `type: 'string' | 'number' | 'boolean'`, `defaultValue`, `visibility: 'private' | 'shared'`, `client: boolean`, and optionally `kind: 'flag'`, `scope: 'platform' | 'tenant'`, `secret`, `labelKey`, `descriptionKey`, `label`, `description`, `enum` (string type only), `min`, `max`, `pattern`, `multiline`. Keys match `^[a-z][a-zA-Z0-9]*$`. The allowed-values field is `enum`, not `values`. A `secret` setting can be neither `client: true` nor `visibility: 'shared'`. Values are read live with `context.settings.get(tenantId, moduleId, key)` and edited in Administration, Modules behind `system.settings.read` and `system.settings.manage` (`GET /api/settings`, `POST /api/settings/update`, `modules/system/src/server/endpoints.ts`). A read needs the tenant primed first (`await context.settings.prime(tenantId)`): the authenticated request path and the platform composition prime, a background path primes itself, and `set` is awaited.
24
28
 
25
- **Feature flags.** A flag is a module setting declared `kind: 'flag'`: a non-secret `boolean` with a `defaultValue`, a `label`, a `description` and `scope: 'tenant'`, which is the default and the only scope a flag may take; `defineModuleSettings` refuses anything else, a platform-scoped flag included. There is no flag store, no flag endpoint and no flag registry. A module reads one on the request path with the ordinary settings read, `context.settings.get<boolean>(tenantId, moduleId, key)`: a lookup of the declaration, a lookup of the cached per `(tenant, module)` value set under a key the read builds, the touch that keeps that entry at the head of the cache, the property read and one `typeof` check. No query of its own, and nothing beyond what any setting already costs: a declared `pattern` is compiled once with the declaration, never per read. There is deliberately no `context.flags`; the read is the settings read, and the module id is the one the module already knows. An override is per workspace behind `system.settings.manage` on the Flags tab of Administration, Modules, which groups every declared flag by its owning module and links the audit trail. Every change appends one `settings.flag.changed` auth audit event with the module, the key, the previous and next values and the actor (`settings.updated` stays the event for every other setting). No percentage rollout and no targeting: a flag is on or off for a workspace.
29
+ **Feature flags.** A flag is a module setting declared `kind: 'flag'`: a non-secret `boolean` with a `defaultValue`, a `label`, a `description` and `scope: 'tenant'`, which is the default and the only scope a flag may take; `defineModuleSettings` refuses anything else, a platform-scoped flag included. There is no flag store, no flag endpoint and no flag registry. A module reads one on the request path with the ordinary settings read, `context.settings.get<boolean>(tenantId, moduleId, key)`: a lookup of the declaration, a lookup of the cached per `(tenant, module)` value set under a key the read builds, the touch that keeps that entry at the head of the cache, the property read and one `typeof` check. No query of its own, and nothing beyond what any setting already costs: a declared `pattern` is compiled once with the declaration, never per read. There is deliberately no `context.flags`; the read is the settings read, and the module id is the one the module already knows. An override is per workspace behind `system.settings.manage` on the Flags tab of Administration, Modules, which groups every declared flag by its owning module and links the audit trail. Every change appends one `settings.flag.changed` auth audit event with the module, the key, the previous and next values and the actor (`settings.updated` stays the event for every other setting). No percentage rollout and no targeting: a flag is on or off for a workspace. A specification declares one as a `settings[]` entry with `kind: flag`, which `spec validate` holds to boolean, `scope: tenant` and a stated default; `research.core` ships the first one, `allowAgents`.
26
30
 
27
31
  **Module activation.** The composed module set is CLI-owned and baked at build; what an owner changes from Administration, Modules is per-workspace activation of the modules the application already composes. `system.core` keeps it in `system_module_activations` (a composed module without a row is active), lists it through `GET /api/system/modules` (every catalog row with `active`, `optional` and `dependents`) and `GET /api/system/modules/active` (the active composed ids, for any member holding `system.workspace.access`), and changes it through `POST /api/system/modules/activate` and `/api/system/modules/deactivate` behind `system.settings.manage` with CSRF first. `system.core`, `auth.core`, `users.core` and `profile.core` (`REQUIRED_MODULE_IDS` in `@flowdular/sdk/contracts`) are never deactivated; a module another active module depends on, through a declared module dependency or a required capability, is refused with 409 `MODULE_HAS_ACTIVE_DEPENDENTS` naming the dependents, a required one with 409 `MODULE_REQUIRED`, and activating a module whose dependency is inactive with 409 `MODULE_DEPENDENCY_INACTIVE`. Every change appends one `system.module.activated` or `system.module.deactivated` auth audit event. The state is one per-tenant snapshot memoised for 30 seconds and published as the public capability `system.modules.v1` (`isActive(tenantId, moduleId)`, `activeIds(tenantId)`, `modules/system/src/server/capability.ts`). Enforcement costs a module nothing: the generated composition binds every route to its module id (`bindModuleCompositions`, `packages/server/src/module-activation.ts`), `defineEndpoint` answers 403 `MODULE_INACTIVE` after the permission check for an endpoint of an inactive module in the principal's workspace (`EndpointIdentity.tenantId` comes from `endpointIdentityFromContext`), and the application shell reads the active ids before it renders and hides the navigation, views, widgets and command search of an inactive module (`contributionsForActiveModules`, `packages/client/src/shell/modules.ts`; a failed read shows everything). Not covered yet: the agent tools of an inactive module are still offered, because the harness registry has no per-tenant module hook.
28
32
 
@@ -56,13 +60,13 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
56
60
 
57
61
  **Translations.** The shipped locales are `en` and `pl`. A module keeps a flat bundle per locale in `translations/<locale>.json`, imports them in `src/client/contribution.tsrx` and returns `translations: { en, pl }`. Keys resolve fully qualified as `<first module segment>.<key>` through `t()`. A count is a plural family (`<key>.one`/`.other` in `en`, `<key>.one`/`.few`/`.many`/`.other` in `pl`) read as `t(key, { count })`. `flowdular module validate` reports `TRANSLATION_FILE_MISSING`, `TRANSLATION_PARSE_ERROR`, `TRANSLATION_KEYS_MISMATCH`, `TRANSLATION_PLURAL_INCOMPLETE` and `TRANSLATION_KEY_MISSING`.
58
62
 
59
- **Web surfaces.** A module may own public, server-rendered website pages separate from the authenticated shell (`packages/server/src/web.ts`). `defineWebSurface` declares `{ id, pages }` with at most 128 pages; a page has `id`, `path`, `entry`, optional `layout`, a `load` function and `access`, which is one of `{ kind: 'public' }`, `{ kind: 'authenticated' }` or `{ kind: 'permission', permission }`. The operator, not the module, mounts a surface at a tenant-scoped path; `setup`, `health`, `ready`, `assets`, `app`, `api`, `auth`, `sign-in`, `sign-up`, `forgot-password`, `reset-password` and `accept-invitation` are reserved.
63
+ **Web surfaces.** A module may own public, server-rendered website pages separate from the authenticated shell (`packages/server/src/web.ts`). `defineWebSurface` declares `{ id, pages }` with at most 128 pages; a page has `id`, `path`, `entry`, optional `layout`, a `load` function and `access`, which is one of `{ kind: 'public' }`, `{ kind: 'authenticated' }` or `{ kind: 'permission', permission }`. The operator, not the module, mounts a surface at a tenant-scoped path with `pnpm flowdular web mount <module id> <surface id> --path <path> --tenant <id> --apply`, which writes `flowdular.json` and regenerates the composition (`web list` and `web unmount <mount id>` are its siblings); `setup`, `health`, `ready`, `assets`, `app`, `api`, `auth`, `sign-in`, `sign-up`, `forgot-password`, `reset-password` and `accept-invitation` are reserved (`RESERVED_WEB_SEGMENTS` in `@flowdular/sdk/contracts`), and a mount naming a surface its module does not declare stops the composition rather than answering 404.
60
64
 
61
65
  **Public capabilities registry.** Cross-module access goes through `context.capabilities.register(id, value)` in the owning module and `context.capabilities.get<T>(id)` in the consumer (`packages/kernel/src/capability-registry.ts`). The owning module lists the id under `provides` in `module.json`; the consumer lists it under `requires` (`{ "id", "optional": true }` when it handles a null `get`). The composition gives each module a registry view that accepts only its declared ids, the kernel orders required providers first and refuses a missing provider, and the installer resolves a required capability to a release that provides it. A type import from the provider's package still needs the module and package dependency (`"range": "^0.11.0"`). A module never opens another module's database or imports its `src/` path.
62
66
 
63
67
  **Notifications.** `notifications.core` (optional, enabled by default) owns a per-member in-app inbox with preferences, per-tenant outbound webhook subscriptions signed with the inbound automations scheme, and e-mail delivery of inbox items, all three sharing one delivery ledger with bounded retry and a dead letter. A module publishes through the public capability `notifications.publish.v1` obtained lazily with `context.capabilities.get` and tolerates its absence; the input is `{ tenantId, kind, sourceModule, sourceRef, title, body?, recipients }` with the kinds `agent-run-completed`, `agent-run-failed`, `workflow-run-completed`, `workflow-run-failed`, `webhook-dead-letter` (`modules/notifications/src/domain/publish.ts`). A new kind is a `notifications.core` spec edit, not a publisher's decision. A publisher never chooses a channel: the member does, with the per-kind switch that decides whether an item exists at all and the `emailDelivery` switch (off by default) that also mails the items they receive, through the platform mail port and the address `auth.core` holds. `ToastHost` and `toasts` remain the in-screen confirmation for what the reader just did.
64
68
 
65
- **Mail.** A module sends through `context.mail` (`packages/server/src/mail/`) and never selects a transport, a relay or a provider SDK. `send({ to, subject, text, html?, locale?, headers? })` takes at most 16 recipients, a 200 character single-line subject, 64 KB of text, 256 KB of HTML and 16 extra headers whose names the envelope does not own; CR and LF are refused everywhere a header could be opened, so header injection is the port's problem and not each sender's. It rejects with a `MailError` carrying `MAIL_NOT_CONFIGURED` (no transport composed), `MAIL_MESSAGE_REJECTED` (a bound) or `MAIL_DELIVERY_FAILED` (the relay, whose words never travel with it); `mail.configured` is the flag a feature gates on instead of provoking a refusal. `renderMailTemplate({ subject, text, html? }, values)` fills `{{ name }}` holes in one pass and escapes every value for the HTML part. The deployment picks the adapter with `FD_MAIL_TRANSPORT`: `none` (refuses), `development` (an in-memory outbox of the last 100 messages, refused in production) or `smtp` (`FD_MAIL_SMTP_URL`, `FD_MAIL_FROM`; the retired `FD_AUTH_MAIL_*` names still work with a deprecation line). `auth.core` sends invitations, resets and confirmations through it, `notifications.core` mails inbox items; a module that wants to reach a person publishes a notification rather than composing mail of its own.
69
+ **Mail.** A module sends through `context.mail` (`packages/server/src/mail/`) and never selects a transport, a relay or a provider SDK. `send({ to, subject, text, html?, locale?, headers? })` takes at most 16 recipients, a 200 character single-line subject, 64 KB of text, 256 KB of HTML and 16 extra headers whose names the envelope does not own; CR and LF are refused everywhere a header could be opened, so header injection is the port's problem and not each sender's. It rejects with a `MailError` carrying `MAIL_NOT_CONFIGURED` (no transport composed), `MAIL_MESSAGE_REJECTED` (a bound) or `MAIL_DELIVERY_FAILED` (the relay, whose words never travel with it); `mail.configured` is the flag a feature gates on instead of provoking a refusal. `renderMailTemplate({ subject, text, html? }, values)` fills `{{ name }}` holes in one pass and escapes every value for the HTML part. The deployment picks the adapter with `FD_MAIL_TRANSPORT`: `none` (refuses), `development` (an in-memory outbox of the last 100 messages, refused in production) or `smtp` (`FD_MAIL_SMTP_URL`, `FD_MAIL_FROM`; the retired `FD_AUTH_MAIL_*` names still work with a deprecation line). An installation may instead store the relay in the platform-scoped `auth.core` settings `mailTransport`, `mailSmtpUrl` (secret), `mailFrom`, `mailRequireTls` and `mailRejectUnauthorized`; a stored transport of `none` or `smtp` wins over the environment for every sender and is resolved per message, while the default `environment` leaves `FD_MAIL_*` in effect and is the only way to reach the development adapter. `auth.core` sends invitations, resets and confirmations through it, `notifications.core` mails inbox items; a module that wants to reach a person publishes a notification rather than composing mail of its own.
66
70
 
67
71
  **Object storage.** A module writes files through `context.storage` (`packages/storage/src/index.ts`) and never sees an adapter, a bucket or a path. `put`, `get`, `delete`, `stat` and `readUrl` take `{ tenantId, moduleId, objectId }`; the key is `<tenantId>/<moduleId>/<objectId>` and the tenant id comes from the principal, never from the request, because no row-level security reaches an object store. Development and test use a local directory, a deployment uses an S3-compatible bucket (`FD_STORAGE_ADAPTER=local|s3`, `local` refused in production). Every object is encrypted with AES-256-GCM under `FD_STORAGE_ENCRYPTION_KEY` before it is written, with the key id and the metadata authenticated alongside it. An object is at most 25 MB (`FD_STORAGE_MAX_OBJECT_BYTES`) and must be one of PDF, PNG, JPEG, GIF, WebP, plain text, CSV, `.docx`, `.xlsx`, `.pptx`, `application/msword` or `application/vnd.ms-excel`, verified against the bytes; archives and executables are refused. A malware scanner is a deployment seam, so the stored verdict is `clean`, `infected` (refused) or `unscanned` (the default). `readUrl` returns `/api/storage/objects/<token>`, a signed platform route that expires in at most an hour and streams the decrypted body as an attachment, never a presigned URL to the ciphertext. Upload, metadata and the attachment table belong to `documents.core`, described next; a module never puts bytes of its own through `context.storage` when a document fits.
68
72
 
@@ -104,6 +104,7 @@ commandsWithoutDescriptor:
104
104
  - pnpm flowdular capability list|describe <id>|run <id>
105
105
  - pnpm flowdular blueprint list
106
106
  - pnpm flowdular module list
107
+ - pnpm flowdular web list
107
108
  - pnpm flowdular module sync [--apply]
108
109
  - pnpm flowdular module enable <id> [--apply] (with --apply also runs auth.scopes.sync; result field scopes, failure code MODULE_SCOPES_SYNC_FAILED)
109
110
  - pnpm flowdular module disable <id> [--apply]
@@ -3,7 +3,7 @@
3
3
  "schemaVersion": 1,
4
4
  "id": "catalog.core",
5
5
  "package": "@flowdular/module-catalog",
6
- "version": "0.8.1",
6
+ "version": "0.8.2",
7
7
  "profile": "full",
8
8
  "capabilities": ["api", "database", "client", "translations"],
9
9
  "platform": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowdular/module-catalog",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "octane": "0.1.51",
18
18
  "segment-state": "0.2.0",
19
- "@flowdular/sdk": "0.3.2"
19
+ "@flowdular/sdk": "0.4.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@tsrx/typescript-plugin": "0.3.120",
@@ -1,6 +1,6 @@
1
1
  schemaVersion: 1
2
2
  id: catalog.core
3
- specVersion: 0.8.1
3
+ specVersion: 0.8.2
4
4
  status: approved
5
5
  name: Product Catalog Core
6
6
  description: Provides tenant-scoped products and services with stable SKUs, units, prices, currencies, and lifecycle state.
@@ -48,7 +48,7 @@ export function CatalogItemForm(props: CatalogItemFormProps) @{
48
48
  value={name}
49
49
  onInput={(event) => setName(event.currentTarget.value)}
50
50
  minlength={2}
51
- maxlength={160}
51
+ maxLength={160}
52
52
  autoFocus
53
53
  required
54
54
  />
@@ -60,7 +60,7 @@ export function CatalogItemForm(props: CatalogItemFormProps) @{
60
60
  value={sku}
61
61
  onInput={(event) => setSku(event.currentTarget.value)}
62
62
  disabled={props.item !== null}
63
- maxlength={64}
63
+ maxLength={64}
64
64
  required
65
65
  />
66
66
  </FormField>
@@ -85,7 +85,7 @@ export function CatalogItemForm(props: CatalogItemFormProps) @{
85
85
  name="unit"
86
86
  value={unit}
87
87
  onInput={(event) => setUnit(event.currentTarget.value)}
88
- maxlength={24}
88
+ maxLength={24}
89
89
  required
90
90
  />
91
91
  </FormField>
@@ -114,7 +114,7 @@ export function CatalogItemForm(props: CatalogItemFormProps) @{
114
114
  value={currency}
115
115
  onInput={(event) => setCurrency(event.currentTarget.value)}
116
116
  minlength={3}
117
- maxlength={3}
117
+ maxLength={3}
118
118
  required
119
119
  />
120
120
  </FormField>
@@ -2,6 +2,11 @@ import { useEffect, useMemo } from 'octane';
2
2
  import {
3
3
  Alert,
4
4
  Button,
5
+ CellCode,
6
+ CellNumber,
7
+ CellStack,
8
+ CellTag,
9
+ CellTime,
5
10
  ConfirmDialog,
6
11
  Drawer,
7
12
  EmptyState,
@@ -13,7 +18,6 @@ import {
13
18
  SearchField,
14
19
  Select,
15
20
  TableCard,
16
- Tag,
17
21
  ToastHost,
18
22
  toasts,
19
23
  type TableColumn,
@@ -91,63 +95,60 @@ function price(minor: number, currency: string): string {
91
95
  }
92
96
  }
93
97
 
94
- function updatedAt(value: number): string {
95
- return new Intl.DateTimeFormat(activeLocale(), {
96
- dateStyle: 'medium',
97
- timeStyle: 'short',
98
- }).format(new Date(value));
99
- }
100
-
101
98
  function columns(): readonly TableColumn<CatalogItem>[] {
102
99
  return [
103
100
  {
104
101
  key: 'name',
105
102
  header: t('catalog.table.column.name'),
106
- width: '28%',
103
+ width: 'auto',
107
104
  value: (item) => item.name,
108
- cell: (item) => <span class="ui-cell">
109
- <b>{item.name}</b>
110
- <small>{item.unit}</small>
111
- </span>,
105
+ cell: (item) => <CellStack primary={item.name} secondary={item.unit} />,
112
106
  },
113
107
  {
114
108
  key: 'sku',
115
109
  header: t('catalog.table.column.sku'),
116
- width: '16%',
110
+ width: '160px',
111
+ priority: 2,
117
112
  value: (item) => item.sku,
118
- cell: (item) => <span class="ui-mono">{item.sku}</span>,
113
+ cell: (item) => <CellCode value={item.sku} />,
119
114
  },
120
115
  {
121
116
  key: 'kind',
122
117
  header: t('catalog.table.column.kind'),
123
- width: '12%',
118
+ width: '130px',
119
+ priority: 2,
124
120
  cell: (item) =>
125
- <Tag tone={item.kind === 'product' ? 'info' : 'neutral'}>{t(
126
- 'catalog.kind.' + item.kind,
127
- )}</Tag>,
121
+ <CellTag
122
+ tone={item.kind === 'product' ? 'info' : 'neutral'}
123
+ label={t('catalog.kind.' + item.kind)}
124
+ />,
128
125
  },
129
126
  {
130
127
  key: 'price',
131
128
  header: t('catalog.table.column.price'),
132
- width: '14%',
129
+ width: '140px',
133
130
  numeric: true,
134
- cell: (item) => price(item.basePriceMinor, item.currency),
131
+ cell: (item) =>
132
+ <CellNumber value={price(item.basePriceMinor, item.currency)} />,
135
133
  },
136
134
  {
137
135
  key: 'updatedAt',
138
136
  header: t('catalog.table.column.updated'),
139
- width: '18%',
137
+ width: '170px',
138
+ priority: 2,
140
139
  value: (item) => item.updatedAt,
141
- cell: (item) => updatedAt(item.updatedAt),
140
+ cell: (item) => <CellTime value={item.updatedAt} />,
142
141
  },
143
142
  {
144
143
  key: 'status',
145
144
  header: t('catalog.table.column.status'),
146
- width: '12%',
145
+ width: '130px',
147
146
  cell: (item) =>
148
- <Tag tone={item.status === 'active' ? 'success' : 'neutral'} dot>{t(
149
- 'catalog.status.' + item.status,
150
- )}</Tag>,
147
+ <CellTag
148
+ tone={item.status === 'active' ? 'success' : 'neutral'}
149
+ dot
150
+ label={t('catalog.status.' + item.status)}
151
+ />,
151
152
  },
152
153
  ];
153
154
  }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "id": "catalog.core",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "repository": "Flowdular/official-modules",
5
- "sourceCommit": "6565e2067b029264de98f59cfc9fa7eeb5645b54",
6
- "artifactSha256": "5c32abd8f6df0c1d3ec0f694d270de3b24ef2e62888454bc89564a67f59c7828",
5
+ "sourceCommit": "f38a67718c5a29aba5b5d37c0504430a3c7f565b",
6
+ "artifactSha256": "149808831d620ac0ebc50abb6b0fb2caef6bec66b5d7821c752ec811e5d9219f",
7
7
  "files": {
8
8
  "LICENSE": "155d722071bad9d0d832482e06fd5a47f7034389cb63aabcb39f4282aa3499fc",
9
9
  "migrations/0001_catalog_core.down.sql": "0962a1edf0bde959cd4facccf77bd5b634d6cc25f125a0c79a61770c8871093f",
@@ -17,16 +17,16 @@
17
17
  "migrations/0005_catalog_list_indexes.down.sql": "3dd547d738e75513abef502afc4bf9b51851ec9405b6b719c6134b897c5b1776",
18
18
  "migrations/0005_catalog_list_indexes.up.sql": "dc3ece30b93fba0c91be58f772d1ae421cfbba49439e8c72a06aead6720f5db5",
19
19
  "migrations/README.md": "2a15fd001713c2552a3c82b186246aa5fec136f43143cc2d9aa15bd491a09d41",
20
- "module.json": "a4ac79385b396842f96d6d190b615565d09a9ea7a4f761de589ee3312b0b8639",
21
- "package.json": "716dd452c7eaf14b5eeb80c1dba98e71c6f43ee33bd5fd03a2bf90801571d5f5",
22
- "spec/module.yaml": "6a2cf7d9df6d2cf5cf2ea6517a79faab7bf184fab917485811fbfaad5b31787b",
20
+ "module.json": "d2a98b70d60a433e1b3b6547352781048d562b996e3ee961f519d61ee1b623b9",
21
+ "package.json": "c23a99016f974d183189a05e4cfc4929788a46ae1ad65c623d66513e0880cdbd",
22
+ "spec/module.yaml": "992953d002574e83374c21e1ee7bef1d451c04b0180892856838d7c67404ce66",
23
23
  "src/acl/permissions.ts": "3375521a5a229736ffac5a948140ec347dc7a7e4fba80e778c0baaf9e0622590",
24
24
  "src/agent/tools.ts": "3403db7954906dc2c79227ba0420b5cb4bfb57063b7cfc285e6e556f16be9266",
25
25
  "src/api/endpoints.ts": "205ef36d058f246f99b77336e7246a23aaca611c696a1f6f09758f66e8a93a29",
26
26
  "src/api/list-cursor.ts": "dcb763edc0128a3aac95e9ca3c5158611a7f2c6a4c71484438c89b7f4d79bb0d",
27
27
  "src/client/CatalogHistoryDrawer.tsrx": "6cdba5249be81e70da703cb34c1a2210943ce5e5fb596ee77cf7952e2acf3ee3",
28
- "src/client/CatalogItemForm.tsrx": "7dafa4149975d9e7d5784c8a5391b5b64c2405991aaead713d94b61c41168c2c",
29
- "src/client/CatalogView.tsrx": "bc1e543690e07d52b51626832f36afe3fde87bf2dc45642324507df8384d7303",
28
+ "src/client/CatalogItemForm.tsrx": "d621ac2a513635a5e38ee44726c07926bf035ec5e0dddca487c462cc7913d040",
29
+ "src/client/CatalogView.tsrx": "2c3e49bb1e54b58d636de0ddbb6ece429acf6aeadb6a0515ab52fca3baabec21",
30
30
  "src/client/api.ts": "eaa55af81d26aa0190d19b3102c363c1ee25b2bdc05436446ac95dcde62aea75",
31
31
  "src/client/contribution.tsrx": "6cbf79e6188bdf24b9cec4a06ae621e03efd5d0c76ad72b28828eee9155ab893",
32
32
  "src/client/index.ts": "03eb0664cdafccb66cb25f2e1b07e6959c2dfa9bdbfffc3e7edf9b535ba4949a",
@@ -26,25 +26,26 @@ Every `acceptanceScenarios[]` entry maps to at least one test in `tests/`. A sce
26
26
 
27
27
  Each spec element maps to files:
28
28
 
29
- | Spec element | Files it produces |
30
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
31
- | `entities[]` | `src/domain/types.ts`, `migrations/000N_<module>_<name>.{up,down}.sql`, `src/services/migration.ts`, `src/services/{repository,database-repository}.ts` |
32
- | `entities[].fields[]` | the columns and row mapping above, the validation bounds in `src/api/endpoints.ts`, the form field and table cell in `src/client/*.tsrx` |
33
- | `fields[].unique: tenant` | a `(tenant_id, <field>)` unique index in the migration plus the stable conflict code in the service |
34
- | `entities[].states` | the status column, the transition guard in the service, the `Tag` tone in the view |
35
- | `screens[]` | `src/client/<Pascal>View.tsrx`, a `views` entry and a `navigation` entry in `src/client/contribution.tsrx`, `translations/*.json` |
36
- | `screens[].columns`/`filters` | the `TableColumn[]` outside the component, and the controls inside the `Filters` dropdown |
37
- | `screens[].navigationGroup` | the navigation entry's `group` |
38
- | `actions[]` | the service method with its error code, the `defineEndpoint` route, the fetch in `src/client/api.ts` |
39
- | `widgets[]` | a widget component plus a `widgets` entry with its `slot` in `src/client/contribution.tsrx` |
40
- | `settings[]` | `src/settings.ts` (`defineModuleSettings`) and `settings:` in `src/platform.ts` |
41
- | `agentTools[]` | `src/agent/tools.ts` and the `context.agentTools.register` call, as a separate `agent-tool-design` phase |
42
- | `research` | `src/research.ts`, `research-fixtures.json`, `requires` of the capabilities, the evidence attach where the `evidenceOwner` record is written |
43
- | `adapters[]` | `src/adapters/<name>.ts`, the port, the adapter registration, `adapters/<name>.recorded.json`, as a separate `integration-adapter` phase |
44
- | `templates[]` | `templates/<name>.md`, `templates` in `package.json` `files`, `src/templates.ts` registered through `documents.templates.v1` in `src/platform.ts` |
45
- | `permissions[]` | `src/acl/permissions.ts`, the endpoint `access.permission`, the client `scope` |
46
- | `acceptanceScenarios[]` | `tests/module.test.ts` and its siblings, at least one case each |
47
- | `outOfScope[]`, `decisions[]` | no code. Read them so you do not rebuild a decision or implement a deferred feature. |
29
+ | Spec element | Files it produces |
30
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31
+ | `entities[]` | `src/domain/types.ts`, `migrations/000N_<module>_<name>.{up,down}.sql`, `src/services/migration.ts`, `src/services/{repository,database-repository}.ts` |
32
+ | `entities[].fields[]` | the columns and row mapping above, the validation bounds in `src/api/endpoints.ts`, the form field and table cell in `src/client/*.tsrx` |
33
+ | `fields[].unique: tenant` | a `(tenant_id, <field>)` unique index in the migration plus the stable conflict code in the service |
34
+ | `entities[].states` | the status column, the transition guard in the service, the `Tag` tone in the view |
35
+ | `screens[]` | `src/client/<Pascal>View.tsrx`, a `views` entry and a `navigation` entry in `src/client/contribution.tsrx`, `translations/*.json` |
36
+ | `design/<screen>.html` | the approved look of that screen: mirror its structure and keep its copy. Render it with `pnpm ui:preview <path>`; absent, design it first with `ux-design` |
37
+ | `screens[].columns`/`filters` | the `TableColumn[]` outside the component, and the controls inside the `Filters` dropdown |
38
+ | `screens[].navigationGroup` | the navigation entry's `group` |
39
+ | `actions[]` | the service method with its error code, the `defineEndpoint` route, the fetch in `src/client/api.ts` |
40
+ | `widgets[]` | a widget component plus a `widgets` entry with its `slot` in `src/client/contribution.tsrx` |
41
+ | `settings[]` | `src/settings.ts` (`defineModuleSettings`) and `settings:` in `src/platform.ts`; a `kind: flag` entry keeps `kind: 'flag'` there, so owners switch it on the Flags tab of Administration, Modules |
42
+ | `agentTools[]` | `src/agent/tools.ts` and the `context.agentTools.register` call, as a separate `agent-tool-design` phase |
43
+ | `research` | `src/research.ts`, `research-fixtures.json`, `requires` of the capabilities, the evidence attach where the `evidenceOwner` record is written |
44
+ | `adapters[]` | `src/adapters/<name>.ts`, the port, the adapter registration, `adapters/<name>.recorded.json`, as a separate `integration-adapter` phase |
45
+ | `templates[]` | `templates/<name>.md`, `templates` in `package.json` `files`, `src/templates.ts` registered through `documents.templates.v1` in `src/platform.ts` |
46
+ | `permissions[]` | `src/acl/permissions.ts`, the endpoint `access.permission`, the client `scope` |
47
+ | `acceptanceScenarios[]` | `tests/module.test.ts` and its siblings, at least one case each |
48
+ | `outOfScope[]`, `decisions[]` | no code. Read them so you do not rebuild a decision or implement a deferred feature. |
48
49
 
49
50
  A v1 spec stays valid and carries none of these arrays. Then the requirements are `invariants`, `permissions` and `acceptanceScenarios`, and everything the spec leaves open is still a question rather than a guess.
50
51
 
@@ -23,7 +23,7 @@ The spec-element to file mapping is the table in `module-new`; the change classe
23
23
 
24
24
  ## 1. Read first
25
25
 
26
- Read the whole module before changing it: `spec/module.yaml`, `src/index.ts`, `src/acl/permissions.ts`, `src/api/endpoints.ts`, `src/services/*`, `src/client/*`, `tests/`. Keep every exported name in `src/index.ts`, `src/server/index.ts` and `src/client/index.ts` stable: other modules import them (`modules/users` uses `AuthRuntime` from `@flowdular/sdk/modules/auth/server`), and the generated composition imports `createServerComposition` and `createClientContribution`.
26
+ Read the whole module before changing it: `spec/module.yaml`, `design/*.html` when the change touches a screen, `src/index.ts`, `src/acl/permissions.ts`, `src/api/endpoints.ts`, `src/services/*`, `src/client/*`, `tests/`. Keep every exported name in `src/index.ts`, `src/server/index.ts` and `src/client/index.ts` stable: other modules import them (`modules/users` uses `AuthRuntime` from `@flowdular/sdk/modules/auth/server`), and the generated composition imports `createServerComposition` and `createClientContribution`.
27
27
 
28
28
  Sandbox facts for an edit session (`packages/sandbox/src/server/sessions.ts`): the module is copied to `workspace/modules/<dir>` and a pristine copy to `base/modules/<dir>`; the diff shown to the operator and the eject plan compare the two. The workspace is a pnpm workspace of its own (declared dependencies install for real; a `package.json` change triggers a reinstall that counts as the `dependencies` gate). The business manager updates the spec before implementation. The operator approves the exact spec hash for every affected module; editing that spec, requesting changes, or adding another module reopens its approval gate. A sandbox specialist never writes `status: approved`; a host agent may invoke approval only after an explicit current user request through `spec-approval`. Delivery checks the recorded hash again.
29
29
 
@@ -62,9 +62,11 @@ New screen or widget:
62
62
  3. `src/client/index.ts`: re-export the view.
63
63
  4. Add user-facing copy to every declared `translations/*.json` bundle and resolve it with fully qualified `t()` keys. Navigation copy uses getters because contributions exist before bundles are registered.
64
64
 
65
+ New feature flag: a setting with `kind: 'flag'`, `type: 'boolean'`, `scope: 'tenant'` and a `defaultValue`. It reads like any other setting, `context.settings.get<boolean>(tenantId, '<module>.core', 'key')`, and appears on the Flags tab of Administration, Modules beside the module's other flags; a change is audited as `settings.flag.changed`. Declare it in the spec as `kind: flag` too, and state in an invariant what the module does while it is off. Before changing behaviour a workspace already relies on, removing a step, or adding an outward-facing or costly path, propose a flag and let the operator decide: ship the new path behind it, default off, and keep the old path working while it is off. A flag is on or off for one workspace; there is no percentage rollout and no targeting.
66
+
65
67
  New setting:
66
68
 
67
- 1. `src/settings.ts`: `export const X_MODULE_SETTINGS = defineModuleSettings({ moduleId: '<module>.core', settings: { key: { type: 'string' | 'number' | 'boolean', defaultValue, visibility: 'private' | 'shared', client: boolean, scope: 'tenant' | 'platform', labelKey, label, descriptionKey, description, min?, max?, enum?, secret? } } })` from `@flowdular/sdk/kernel` (`packages/kernel/src/module-settings.ts`; setting keys match `^[a-z][a-zA-Z0-9]*$`). `labelKey` and `descriptionKey` are fully qualified module translation keys present in every locale. Keep the English literals as compatibility fallbacks; values, ids and secrets are never translated.
69
+ 1. `src/settings.ts`: `export const X_MODULE_SETTINGS = defineModuleSettings({ moduleId: '<module>.core', settings: { key: { type: 'string' | 'number' | 'boolean', kind?: 'flag', defaultValue, visibility: 'private' | 'shared', client: boolean, scope: 'tenant' | 'platform', labelKey, label, descriptionKey, description, min?, max?, enum?, secret? } } })` from `@flowdular/sdk/kernel` (`packages/kernel/src/module-settings.ts`; setting keys match `^[a-z][a-zA-Z0-9]*$`). `labelKey` and `descriptionKey` are fully qualified module translation keys present in every locale. Keep the English literals as compatibility fallbacks; values, ids and secrets are never translated.
68
70
  2. `src/platform.ts`: return `settings: X_MODULE_SETTINGS` next to `routes`; the platform declares it at boot and Administration, Modules renders it in the module's drawer (`modules/system/src/client/ModuleSettingsSection.tsrx`, behind `system.settings.read` and `system.settings.manage`; the API is `GET /api/settings` and `POST /api/settings/update` in `modules/system/src/server/endpoints.ts`).
69
71
  3. Read it live where it is used: `context.settings.get<number>(tenantId, '<module>.core', 'key')` at request time, never cached at boot; pass `context.settings` into the runtime or service that needs it (`modules/agents/src/settings.ts`, `agentSettings`, shows the pattern with an environment fallback).
70
72
  4. `spec/module.yaml`: an invariant or scenario naming the setting and its bounds; `specVersion` bump. Cross-module reads of a setting need `visibility: 'shared'` and a declared dependency.