create-flowdular 0.5.1 → 0.6.0

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 (92) hide show
  1. package/README.md +8 -5
  2. package/agent-template/.agents/skills/agent-tool-design/SKILL.md +1 -1
  3. package/agent-template/.agents/skills/auth-security-review/SKILL.md +1 -1
  4. package/agent-template/.agents/skills/database-adapter/SKILL.md +5 -5
  5. package/agent-template/.agents/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  6. package/agent-template/.agents/skills/deploy-operate/SKILL.md +1 -1
  7. package/agent-template/.agents/skills/migration-authoring/SKILL.md +4 -4
  8. package/agent-template/.agents/skills/module-new/SKILL.md +1 -1
  9. package/agent-template/.agents/skills/test-hardening/SKILL.md +2 -2
  10. package/agent-template/.agents/skills/workflow-development/SKILL.md +95 -9
  11. package/agent-template/.ai/blueprints/add-migration/required-files.yaml +1 -1
  12. package/agent-template/.ai/blueprints/new-module/required-files.yaml +1 -1
  13. package/agent-template/.ai/platform-capabilities.md +7 -5
  14. package/agent-template/.ai/policies/capabilities.yaml +28 -12
  15. package/agent-template/.ai/skills/README.md +1 -1
  16. package/agent-template/.ai/skills/agent-tool-design/SKILL.md +1 -1
  17. package/agent-template/.ai/skills/auth-security-review/SKILL.md +1 -1
  18. package/agent-template/.ai/skills/database-adapter/SKILL.md +5 -5
  19. package/agent-template/.ai/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  20. package/agent-template/.ai/skills/deploy-operate/SKILL.md +1 -1
  21. package/agent-template/.ai/skills/migration-authoring/SKILL.md +4 -4
  22. package/agent-template/.ai/skills/module-new/SKILL.md +1 -1
  23. package/agent-template/.ai/skills/test-hardening/SKILL.md +2 -2
  24. package/agent-template/.ai/skills/workflow-development/SKILL.md +96 -10
  25. package/agent-template/.claude/skills/agent-tool-design/SKILL.md +1 -1
  26. package/agent-template/.claude/skills/auth-security-review/SKILL.md +1 -1
  27. package/agent-template/.claude/skills/database-adapter/SKILL.md +5 -5
  28. package/agent-template/.claude/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  29. package/agent-template/.claude/skills/deploy-operate/SKILL.md +1 -1
  30. package/agent-template/.claude/skills/migration-authoring/SKILL.md +4 -4
  31. package/agent-template/.claude/skills/module-new/SKILL.md +1 -1
  32. package/agent-template/.claude/skills/test-hardening/SKILL.md +2 -2
  33. package/agent-template/.claude/skills/workflow-development/SKILL.md +95 -9
  34. package/agent-template/docs/adr/0007-module-owned-agents.md +35 -1
  35. package/agent-template/docs/agent-contract.md +2 -2
  36. package/agent-template/docs/cli.md +24 -3
  37. package/agent-template/docs/configuration.md +32 -5
  38. package/agent-template/docs/database-adapters.md +20 -20
  39. package/agent-template/docs/design-system.md +1 -1
  40. package/agent-template/docs/getting-started.md +25 -32
  41. package/agent-template/docs/module-distribution.md +79 -86
  42. package/agent-template/docs/module-web-surfaces.md +9 -7
  43. package/agent-template/docs/modules.md +3 -1
  44. package/agent-template/platform/scripts/build.mjs +7 -0
  45. package/dist/bin.js +3 -6
  46. package/package.json +1 -1
  47. package/template/default/.env.example +3 -3
  48. package/template/default/.vercelignore +8 -0
  49. package/template/default/README.md +20 -11
  50. package/template/default/_gitignore +3 -2
  51. package/template/default/infra/README.md +86 -65
  52. package/template/default/infra/docker/.env.example +66 -0
  53. package/template/default/infra/docker/Dockerfile +24 -10
  54. package/template/default/infra/docker/app-entrypoint.mjs +5 -0
  55. package/template/default/infra/docker/compose.yaml +105 -58
  56. package/template/default/infra/docker/database-urls.mjs +28 -0
  57. package/template/default/infra/docker/pitr.sh +177 -0
  58. package/template/default/infra/docker/postgres/10-roles.sh +16 -12
  59. package/template/default/infra/docker/start.mjs +402 -0
  60. package/template/default/infra/kubernetes/database-secret.example.yaml +3 -3
  61. package/template/default/infra/vercel/README.md +262 -0
  62. package/template/default/infra/vercel/build.mjs +214 -0
  63. package/template/default/infra/vercel/handler.mjs +100 -0
  64. package/template/default/modules/example/migrations/0001_example_core.up.sql +2 -2
  65. package/template/default/modules/example/module.json +1 -1
  66. package/template/default/modules/example/package.json +3 -3
  67. package/template/default/modules/example/spec/module.yaml +1 -1
  68. package/template/default/modules/example/src/services/migration.ts +2 -2
  69. package/template/default/modules/example/tests/module.test.ts +1 -1
  70. package/template/default/package.json +2 -2
  71. package/template/default/platform/octane.config.ts +252 -156
  72. package/template/default/platform/package.json +5 -5
  73. package/template/default/platform/scripts/build.mjs +56 -0
  74. package/template/default/platform/scripts/dev.mjs +38 -0
  75. package/template/default/platform/src/generated/modules.server.ts +1 -0
  76. package/template/default/platform/src/server/database.ts +24 -0
  77. package/template/default/platform/src/server/runtime-role.ts +33 -0
  78. package/template/default/platform/src/server/setup/access.ts +160 -0
  79. package/template/default/platform/src/server/setup/adapters.ts +554 -0
  80. package/template/default/platform/src/server/setup/environment.ts +154 -0
  81. package/template/default/platform/src/server/setup/gate.ts +84 -0
  82. package/template/default/platform/src/server/setup/index.ts +181 -0
  83. package/template/default/platform/src/server/setup/modules.ts +123 -0
  84. package/template/default/platform/src/server/setup/page.ts +497 -0
  85. package/template/default/platform/src/server/setup/routes.ts +787 -0
  86. package/template/default/platform/src/server/setup/sanitize.ts +111 -0
  87. package/template/default/platform/src/server/setup/seed.ts +145 -0
  88. package/template/default/platform/src/server/setup/token.ts +79 -0
  89. package/template/default/platform/src/server/worker-tick.ts +193 -0
  90. package/template/default/platform/src/server/workspace-root.ts +16 -0
  91. package/template/default/render.yaml +70 -0
  92. package/template/default/vercel.json +5 -0
package/README.md CHANGED
@@ -17,16 +17,19 @@ npm create flowdular@latest my-app
17
17
  cd my-app
18
18
  ```
19
19
 
20
- For this new local application, initialize demo authentication and start the development server:
20
+ Start the development server:
21
21
 
22
22
  ```sh
23
- pnpm flowdular setup
24
23
  pnpm dev
25
24
  ```
26
25
 
27
- Open [localhost:4310](http://localhost:4310). `setup` opens an interactive wizard for a local demo, PostgreSQL settings or a configuration check. It asks before resetting the local demo database.
26
+ The browser opens the first-run setup automatically. If it cannot open, visit
27
+ [localhost:4310/setup](http://localhost:4310/setup). Enter the token printed in
28
+ the terminal, then create your workspace and owner account. Embedded PostgreSQL
29
+ is already configured. Restart `pnpm dev` when setup finishes, then sign in with
30
+ the owner account you chose.
28
31
 
29
- The starter enables all nine platform modules: system, authentication, users, profile, agents, automations, workflows, their integration, and sandbox access. Local demo setup grants their declared permissions to demo owners. The example module stays available as a starting point; business modules from Official Modules are optional downloads.
32
+ The starter enables all nine platform modules: system, authentication, users, profile, agents, automations, workflows, their integration, and sandbox access. First-run setup grants their declared permissions to the new owner. The example module stays available as a starting point. Module Studio can later connect a catalog, a pinned Git repository or local releases; Sandbox helps create your own modules.
30
33
 
31
34
  `npm create` launches the generator. The generated application uses **pnpm workspaces**. If pnpm is unavailable during installation, the generator invokes its pinned version through `npm exec`.
32
35
 
@@ -96,7 +99,7 @@ pnpm verify
96
99
  pnpm flowdular help
97
100
  ```
98
101
 
99
- Read the [module guide](https://github.com/Flowdular/flowdular/blob/main/docs/modules.md) to extend the application. Business modules from [Official Modules](https://github.com/Flowdular/official-modules) are installed as source through the CLI.
102
+ Read the [module guide](https://github.com/Flowdular/flowdular/blob/main/docs/modules.md) to extend the application and the [Module Studio guide](https://github.com/Flowdular/flowdular/blob/main/docs/module-distribution.md) to install reviewed module source.
100
103
 
101
104
  ## Packages and support
102
105
 
@@ -19,7 +19,7 @@ also ship a ready business agent through `defineAgent()`, read
19
19
  ## 1. The contract in code
20
20
 
21
21
  - Composition: `PlatformServerContext` (`modules/auth/src/server/composition.ts`) carries `agentTools: PlatformToolRegistry` (`register(tools)`, `list()`; `packages/kernel/src/tool-registry.ts`; a duplicate tool id throws at boot), `settings: ModuleSettingsRuntime`, and `capabilities: PlatformCapabilityRegistry` (`register(id, service)`, `get(id)`, `has(id)`; `packages/kernel/src/capability-registry.ts`). `platform/octane.config.ts` creates the registries, passes them to every module's `createServerComposition`, declares each `settings`, owns each `dispose`, then calls each `start`.
22
- - Ordering is a non-issue: `agents.core` (`modules/agents/src/platform.ts`) passes `tools: () => context.agentTools.list()` into `createAgentRuntime`, and the harness is built lazily in `start()`, which runs after every module has composed. Tools any module registers during its own compose are therefore visible, whatever the module order.
22
+ - Ordering is a non-issue: `agents.core` (`modules/agents/src/platform.ts`) passes `tools: () => context.agentTools.list()` into `createAgentRuntime`, and the harness is built when `agents.core` opens, on its first request, capability call or `startWorker()`, all of which run after every module has composed. Tools any module registers during its own compose are therefore visible, whatever the module order.
23
23
  - Helpers: import `defineApiAgentTool` from `@flowdular/sdk/harness/tool-adapters` and the types `AgentTool`, `AgentToolContext` from `@flowdular/sdk/harness/runtime`. Both subpaths are free of the Vercel AI SDK; only the harness root (`@flowdular/sdk/harness`) and `@flowdular/sdk/modules/agents/server` pull it. `defineApiAgentTool` returns a frozen `AgentTool { id, transport: 'api', target, description, requiredPermissions, inputSchema?, execute }`. `defineCliAgentTool({ id, capability: { id, risk }, ... })` wraps a CLI capability and throws at definition time for `external` or `destructive` risk.
24
24
  - Skills inside `agents.core` are tenant database records behind `agents.skills.*`, appended to agent instructions. They are unrelated to `.ai/skills/**`, which are files for coding agents.
25
25
  - A read tool's output can also become a resolvable `{{ variable }}` for variable-aware fields: the tool's `requiredPermissions` is the variable's scope mask. Register a source on `platformVariableRegistry(context.capabilities)`, require an explicit record binding, and invoke the tool with the trusted tenant, actor permission snapshot, and signal. See the `variables` skill for the complete refusal contract.
@@ -57,7 +57,7 @@ Recipe in `modules/auth/tests/endpoints.test.ts`: build the runtime with a `Data
57
57
 
58
58
  - 401 without a cookie or token.
59
59
  - 403 with a principal that lacks the permission.
60
- - Cross-tenant read returns an empty list (service level, on the suite's test provider under the non-bypass `coreloom_runtime` role).
60
+ - Cross-tenant read returns an empty list (service level, on the suite's test provider under the non-bypass `flowdular_runtime` role).
61
61
  - Mutation without `x-csrf-token` returns 403 `CSRF_REJECTED`; without `origin` returns 403.
62
62
  - Each validation bound returns 400 with its code.
63
63
 
@@ -88,12 +88,12 @@ PostgreSQL tenant-owned tables also use database-enforced isolation:
88
88
 
89
89
  - enable and force row-level security on the table;
90
90
  - define a policy whose `USING` and `WITH CHECK` clauses compare `tenant_id`
91
- with `current_setting('coreloom.tenant_id', true)`;
91
+ with `current_setting('flowdular.tenant_id', true)`;
92
92
  - run application traffic under a role that is neither a superuser nor granted
93
93
  `BYPASSRLS`;
94
94
  - use a separate migration role for DDL or policy ownership when required.
95
95
 
96
- The adapter sets `coreloom.tenant_id` with parameterized `set_config(..., true)`
96
+ The adapter sets `flowdular.tenant_id` with parameterized `set_config(..., true)`
97
97
  after `BEGIN` on the pinned connection. Never use an unpinned root query.
98
98
  Explicit tenant predicates remain required as defense in depth.
99
99
 
@@ -133,7 +133,7 @@ transactions without `tenantId`, fail with `TENANT_CONTEXT_REQUIRED`.
133
133
 
134
134
  Use `DatabaseMigration` and `runDatabaseMigrations` from `@flowdular/sdk/database`.
135
135
  Each migration has one immutable id and its PostgreSQL SQL. The ledger is
136
- `_coreloom_migrations_v2`, keyed by module namespace and migration id; its
136
+ `_flowdular_migrations_v2`, keyed by module namespace and migration id; its
137
137
  checksum covers that exact SQL.
138
138
 
139
139
  `inspectExisting(database)` is the only pre-ledger adoption proof. Use
@@ -157,8 +157,8 @@ constant. A migration-only task uses `migration-authoring` in a separate phase.
157
157
  ## 7. Tests run on a real PostgreSQL
158
158
 
159
159
  `createTestDatabaseProvider()` from `@flowdular/sdk/database-testing` gives a suite its
160
- own PostgreSQL in process by default, with the same `coreloom_runtime` and
161
- `coreloom_background` roles and the same forced row-level security a deployment
160
+ own PostgreSQL in process by default, with the same `flowdular_runtime` and
161
+ `flowdular_background` roles and the same forced row-level security a deployment
162
162
  enforces. There is no server to start and no second dialect to keep green, so
163
163
  the isolation assertions run on every turn rather than behind an environment
164
164
  flag. CI selects server PostgreSQL with `FD_TEST_DATABASE_ADAPTER=postgresql`
@@ -83,8 +83,8 @@ adapter change, sandbox eject, and deployment validation.
83
83
 
84
84
  Every turn runs against a real PostgreSQL, because the embedded one starts in
85
85
  process. The sandbox and the test suites use `createTestDatabaseProvider()` from
86
- `@flowdular/sdk/database-testing`, which brings the `coreloom_runtime` and
87
- `coreloom_background` roles and forced row-level security with it.
86
+ `@flowdular/sdk/database-testing`, which brings the `flowdular_runtime` and
87
+ `flowdular_background` roles and forced row-level security with it.
88
88
 
89
89
  A target run covers tenant A and B fixtures, operations without tenant context,
90
90
  forged cross-tenant inserts, direct row-security bypass probes, concurrent
@@ -48,7 +48,7 @@ Set `FD_TRUST_PROXY` behind a load balancer. `FD_DATABASE_BACKGROUND_URL` gives
48
48
 
49
49
  ## 3. Migrations at rollout
50
50
 
51
- Migrations are module-owned, numbered, immutable once applied, and verified by checksum against the `_coreloom_migrations_v2` ledger. The commands (`packages/cli/src/runner.ts`):
51
+ Migrations are module-owned, numbered, immutable once applied, and verified by checksum against the `_flowdular_migrations_v2` ledger. The commands (`packages/cli/src/runner.ts`):
52
52
 
53
53
  ```bash
54
54
  pnpm flowdular migration status [--module <id>] # what the ledger holds
@@ -26,7 +26,7 @@ Migration SQL is checked in and immutable after release:
26
26
  ## 2. What the v2 runner guarantees
27
27
 
28
28
  `runDatabaseMigrations(database, namespace, databaseMigrations)` uses the
29
- namespaced `_coreloom_migrations_v2` ledger. A row records namespace, migration
29
+ namespaced `_flowdular_migrations_v2` ledger. A row records namespace, migration
30
30
  id, dialect id, checksum, and applied time. The checksum covers the selected
31
31
  dialect's exact SQL.
32
32
 
@@ -76,14 +76,14 @@ Every PostgreSQL tenant table includes:
76
76
  ALTER TABLE inventory_locations ENABLE ROW LEVEL SECURITY;
77
77
  ALTER TABLE inventory_locations FORCE ROW LEVEL SECURITY;
78
78
  CREATE POLICY inventory_locations_tenant_policy ON inventory_locations
79
- USING (tenant_id = current_setting('coreloom.tenant_id', true))
80
- WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
79
+ USING (tenant_id = current_setting('flowdular.tenant_id', true))
80
+ WITH CHECK (tenant_id = current_setting('flowdular.tenant_id', true));
81
81
  ```
82
82
 
83
83
  The runtime role is not a superuser and has no `BYPASSRLS`. DDL and policy
84
84
  ownership use `purpose: 'migration'`. Runtime repository calls use
85
85
  `database.transaction(operation, { tenantId, access })`; the adapter sets
86
- transaction-local `coreloom.tenant_id` on the pinned connection. Queries still
86
+ transaction-local `flowdular.tenant_id` on the pinned connection. Queries still
87
87
  include `WHERE tenant_id = ...` as defense in depth.
88
88
 
89
89
  ## 6. Add one migration
@@ -142,7 +142,7 @@ export function createServerComposition(
142
142
 
143
143
  `PlatformServerContext` also carries `databases: DatabaseProvider`, `settings: ModuleSettingsRuntime`, `agentTools: PlatformToolRegistry`, `agentDefinitions: PlatformAgentRegistry`, and `capabilities: PlatformCapabilityRegistry`. The runtime shares one lazy database initialization, uses separate migration and runtime leases, and releases the runtime lease from `dispose()`; `prepare()` remains read-only. A composition may return module settings, lifecycle hooks, agent registrations, and typed cross-module capabilities as described in the focused skills.
144
144
 
145
- Schema: write PostgreSQL SQL in `migrations/0001_inventory_core.up.sql` and mirror it byte for byte in `databaseMigrations` as `sql: { postgresql: ... }` with an `inspectExisting` built from `postgresTenantTableState(...)`. Tenant tables enable and force row-level security with an `<table>_tenant_policy` whose `USING` and `WITH CHECK` compare `tenant_id` with `current_setting('coreloom.tenant_id', true)`; the runtime role has no superuser or `BYPASSRLS`. Repository operations use `database.transaction(..., { tenantId, access })` and retain explicit tenant predicates. Details in `migration-authoring` and `database-adapter`.
145
+ Schema: write PostgreSQL SQL in `migrations/0001_inventory_core.up.sql` and mirror it byte for byte in `databaseMigrations` as `sql: { postgresql: ... }` with an `inspectExisting` built from `postgresTenantTableState(...)`. Tenant tables enable and force row-level security with an `<table>_tenant_policy` whose `USING` and `WITH CHECK` compare `tenant_id` with `current_setting('flowdular.tenant_id', true)`; the runtime role has no superuser or `BYPASSRLS`. Repository operations use `database.transaction(..., { tenantId, access })` and retain explicit tenant predicates. Details in `migration-authoring` and `database-adapter`.
146
146
 
147
147
  Errors: `{ error: { code, message } }`; service errors `class XServiceError extends Error { constructor(readonly code: string, message: string, readonly status = 400) }`; a `failure(error)` helper routes them to `jsonResponse(..., error.status)` and everything else to `problemResponse(error, 'The <module> operation failed.')`.
148
148
 
@@ -15,7 +15,7 @@ description: >-
15
15
 
16
16
  ## 2. Repositories on an embedded PostgreSQL
17
17
 
18
- `createPgliteTestProvider()` from `@flowdular/sdk/database-testing` runs a real PostgreSQL inside the test process, with the same `coreloom_runtime` and `coreloom_background` roles and the same forced row-level security a deployment enforces. Booting it costs about two seconds, so a suite opens one provider per test file, migrates it once, and truncates the module's tables between cases; `.ai/references/catalog/tests/support/database.ts` is the shape (`createCatalogTestDatabase` hands out a lease per fixture, `closeCatalogTestDatabases` runs in `afterAll`). Build the service on top: `new CatalogService((await createCatalogTestDatabase()).repository)`. A database module also keeps `tests/migrations.test.ts` for SQL byte parity, fresh apply, safe pre-ledger adoption, and a clean second start. A module whose spec has no `database` capability gets a `MemoryXRepository` from the scaffold instead; a module with a database tests the database repository, never a hand-written fake, because the SQL, the ledger and the row-level security are what need testing.
18
+ `createPgliteTestProvider()` from `@flowdular/sdk/database-testing` runs a real PostgreSQL inside the test process, with the same `flowdular_runtime` and `flowdular_background` roles and the same forced row-level security a deployment enforces. Booting it costs about two seconds, so a suite opens one provider per test file, migrates it once, and truncates the module's tables between cases; `.ai/references/catalog/tests/support/database.ts` is the shape (`createCatalogTestDatabase` hands out a lease per fixture, `closeCatalogTestDatabases` runs in `afterAll`). Build the service on top: `new CatalogService((await createCatalogTestDatabase()).repository)`. A database module also keeps `tests/migrations.test.ts` for SQL byte parity, fresh apply, safe pre-ledger adoption, and a clean second start. A module whose spec has no `database` capability gets a `MemoryXRepository` from the scaffold instead; a module with a database tests the database repository, never a hand-written fake, because the SQL, the ledger and the row-level security are what need testing.
19
19
 
20
20
  ## 3. Route recipe (from `modules/auth/tests/endpoints.test.ts`)
21
21
 
@@ -55,7 +55,7 @@ The auth middleware must have set the principal for `endpointIdentityFromContext
55
55
  - 403 on a mutation without `x-csrf-token` (`CSRF_REJECTED`) and without `origin` (`ORIGIN_REQUIRED`).
56
56
  - 400 with the stable code for each validation bound (`INVALID_INPUT`, module codes such as `INVALID_ITEM_KIND`).
57
57
  - 409 for the tenant-scoped uniqueness rule, and success for the same key in another tenant.
58
- - Tenant isolation: rows created for `tenant-a` are invisible to `list('tenant-b')`. The provider hands the suite the non-bypass `coreloom_runtime` role, so this runs against real forced row-level security; also assert that a call without tenant context fails with `TENANT_CONTEXT_REQUIRED`.
58
+ - Tenant isolation: rows created for `tenant-a` are invisible to `list('tenant-b')`. The provider hands the suite the non-bypass `flowdular_runtime` role, so this runs against real forced row-level security; also assert that a call without tenant context fails with `TENANT_CONTEXT_REQUIRED`.
59
59
  - Identity: `moduleDefinition.manifest.id` equals the module id (keeps `module.json` and `src/index.ts` aligned). The scaffold writes this and the isolation case; everything else in this list is yours.
60
60
 
61
61
  Assert at the observation boundary: status code, `error.code`, returned record fields. Do not assert internal helper names, call order, or SQL text.
@@ -1,9 +1,8 @@
1
1
  ---
2
2
  name: workflow-development
3
3
  description: >-
4
- Build, publish, invoke, and test a workflows.core DAG through its typed graph
5
- and public execution capability without bypassing agent, action, tenant, or
6
- audit boundaries.
4
+ Author module-owned action templates, or build, publish, invoke, and test a
5
+ workflows.core DAG through its typed graph and public execution capability.
7
6
  ---
8
7
  # Build and integrate an agentic workflow
9
8
 
@@ -12,18 +11,22 @@ pinned agent revisions, deterministic gates, schema validators, registered
12
11
  module actions, data mappings, and terminal output. It does not own schedules or
13
12
  webhook secrets. Those remain optional concerns of `automations.core`.
14
13
 
15
- Read `docs/adr/0006-agentic-workflows.md`, the approved
16
- `modules/workflows/spec/module.yaml`, and the contracts in
17
- `modules/workflows/src/domain/types.ts` before changing a workflow surface.
14
+ At the repository root, read `docs/adr/0006-agentic-workflows.md`, the approved
15
+ `modules/workflows/spec/module.yaml`, and the owning public contracts before
16
+ changing a workflow surface. In the Sandbox, read the approved active-module
17
+ specification and the relevant public contract under `reference/sdk` when it is
18
+ installed. A missing public contract is a core blocker, not a reason to invent
19
+ one or search beyond the session workspace.
18
20
 
19
21
  ## Pick the correct extension point
20
22
 
21
23
  - A workflow definition belongs in `workflows.core` and is edited through its
22
24
  API or canvas. Do not hardcode a tenant workflow in source.
23
25
  - A business operation that a workflow may call is a versioned agent action.
24
- Register it through the agents action catalog. If missing, implement it in a
25
- separate `agent-tool-design` phase with permission, input, output, timeout,
26
- idempotency and audit tests before returning to workflow integration.
26
+ Register one ordinary `AgentTool` with `context.agentTools`. Optional
27
+ `workflowTemplate` metadata makes that action a named palette choice through
28
+ `agents.actions.v2`; it creates no second handler or node kind. Use the
29
+ authoring recipe below when the action is part of this task.
27
30
  - A business module that starts a workflow resolves
28
31
  `workflows.execution.v1` from `context.capabilities`. It never imports a
29
32
  workflow repository or database.
@@ -33,6 +36,87 @@ Read `docs/adr/0006-agentic-workflows.md`, the approved
33
36
  - If the workflow module is absent, the capability registry returns `null`.
34
37
  Hide an optional feature or return a clear stable refusal.
35
38
 
39
+ ## Author a module-owned workflow node template
40
+
41
+ An action-backed template is module source, not graph source. The business
42
+ manager first records its stable action id, permission, named inputs and
43
+ validation rules, output, effect, replay behavior, and success and refusal
44
+ scenarios in the owning module's specification. In a Sandbox session, the
45
+ operator must approve the hash of that exact spec before implementation. A
46
+ later edit requires renewed approval. If any of these decisions are absent,
47
+ hand the spec delta to `business-manager`; do not infer a field, permission,
48
+ external effect, or idempotency rule from the brief.
49
+
50
+ Work inside the existing role boundaries:
51
+
52
+ 1. `backend-engineer` owns the tenant-bound service, code-level validator,
53
+ endpoint or CLI target, and durable target ledger for a mutation. Validation
54
+ runs before any write and returns a stable bounded refusal. A repeated
55
+ idempotency key returns its first result; the same key with different input
56
+ conflicts. Ask backend to supply a missing service rather than writing in
57
+ `src/services/**` or `src/api/**` from the agentic role.
58
+ 2. `agentic-engineer` defines the tool under `src/agent/**`, registers it once
59
+ from `createServerComposition` in `src/platform.ts`, and adds behavioral
60
+ tests. `defineApiAgentTool` or `defineCliAgentTool` carries the existing
61
+ public target. `agents.core` exposes the registered action through
62
+ `agents.actions.v2`; the business module does not register that capability
63
+ or access the workflow database.
64
+ 3. Give the tool a stable dotted id, positive `contractVersion`, required
65
+ permission, bounded input and output JSON Schemas, `risk: 'read'` or
66
+ `'workspace-write'`, `idempotency: 'required'`, cancellation policy, and
67
+ timeout. A workspace write also needs
68
+ `idempotencyProtection: 'target-ledger'` backed by the service's real ledger.
69
+ The handler receives trusted tenant, actor, permission snapshot,
70
+ idempotency key, and `AbortSignal` from `AgentToolContext`; none comes from
71
+ graph input. Its output must satisfy its declared schema.
72
+ 4. Add static `workflowTemplate: { label, description, effect }` on that same
73
+ tool. The label is at most 80 characters, the description at most 240, and
74
+ effect is `local` or `connector-egress`. Metadata contains no code,
75
+ credential, or tenant value. Invalid or duplicate metadata must fail
76
+ composition with a safe diagnostic. A workflow-eligible tool without the
77
+ metadata remains in the generic action editor.
78
+
79
+ The selected template becomes a normal `action` node with input, success, and
80
+ failure ports. It pins the action id, contract version, schemas, permissions,
81
+ risk, idempotency protection, timeout, cancellation, and effect. Changing any
82
+ of those or the handler's behavior requires a new action identity or contract
83
+ version. The current registry keeps one version per action id, so retain the
84
+ old id and register a distinct id when published graphs must keep running;
85
+ label and description may change without rebinding a published graph.
86
+
87
+ Graph bindings may never supply a raw secret. `writeOnly` and
88
+ `x-flowdular-secret` apply at every schema depth, including array items and
89
+ alternatives. A marked field cannot carry `default`, `const`, `enum`,
90
+ `example`, or `examples` data. A template requiring
91
+ a raw secret input is ineligible. Accept a nonsecret opaque reference and let
92
+ the owning module resolve a credential from its tenant-bound vault or a
93
+ declared capability. Never put secret values in fixtures, graph definitions,
94
+ events, audit, or error text.
95
+
96
+ For `connector-egress`, the consumer module declares `connectors.core` and
97
+ `connectors.calls.v1`, uses `caller: 'workflow'`, checks the instance's
98
+ `allowWorkflows` consent, and passes the stable workflow side-effect key to
99
+ the connector. Credentials remain in `connectors.core`. A replay-stable
100
+ output may contain the recorded call id and outcome, not a response body the
101
+ connector replay does not return. Propagate `CALL_OUTCOME_UNKNOWN` as a
102
+ terminal failure when the remote mutation may have happened but no call was
103
+ recorded; never send a second request just to rebuild output. A separate
104
+ provider contract with remote idempotency or readback is required before
105
+ retrying an uncertain mutation.
106
+
107
+ Prove the module behavior at its public service or action boundary: valid
108
+ input, structural and business validation refusal before mutation, missing
109
+ permission, foreign tenant, same-key replay, different-input conflict,
110
+ cancellation, and recovery around the target commit. Connector actions also
111
+ prove absent consent and `CALL_OUTCOME_UNKNOWN` with a recorded fixture. Run a
112
+ deterministic workflow simulation on invented, reviewed fixtures for success,
113
+ failure, and refusal edges. Assert semantic attempts and edge outcomes, not
114
+ real timestamps; simulation must never invoke the handler, connector, or
115
+ network. Inspect the named template and safe run trail in Sandbox preview,
116
+ then run scoped gates, exact-source `auto-review`, and host eject. The agent
117
+ cannot approve the spec, install code into the running server, or push a
118
+ repository from the Sandbox.
119
+
36
120
  ## Graph contract
37
121
 
38
122
  Version one is a bounded DAG. The graph contains:
@@ -41,9 +125,11 @@ Version one is a bounded DAG. The graph contains:
41
125
  - `agent`: calls one exact immutable agent revision and validates structured
42
126
  output.
43
127
  - `agent-decision`: produces one schema-valid `pass` or `fail` outcome.
128
+ - `typed-decision`: routes one bounded typed answer through `pass` or `fail`.
44
129
  - `gate`: evaluates the versioned allowlisted logic language.
45
130
  - `validator`: validates an envelope against a pinned JSON schema.
46
131
  - `action`: calls one exact registered action contract version.
132
+ - `human-approval`: waits for an `approvals.core` request to resolve.
47
133
  - `merge`: waits for all declared incoming paths.
48
134
  - `output`: settles the workflow with a typed result.
49
135
 
@@ -11,7 +11,7 @@ rules:
11
11
  - PostgreSQL only; CREATE TABLE IF NOT EXISTS
12
12
  - tenant_id TEXT NOT NULL on tenant-owned tables
13
13
  - UNIQUE and indexes start with tenant_id, indexes end with id
14
- - a new tenant table enables and forces row-level security and adds a <table>_tenant_policy on current_setting('coreloom.tenant_id', true)
14
+ - a new tenant table enables and forces row-level security and adds a <table>_tenant_policy on current_setting('flowdular.tenant_id', true)
15
15
  - ALTER TABLE ADD COLUMN runs once through the ledger; inspectExisting detects an existing column
16
16
  - applied migration bytes are immutable; a change always gets a new number
17
17
  - inspectExisting returns complete only for every effect, absent only for none, partial for anything mixed
@@ -26,7 +26,7 @@ manifest:
26
26
  - ./server
27
27
  - ./platform
28
28
  src/platform.ts:
29
- - createServerComposition(context) returns routes, optional settings (defineModuleSettings), optional start() and optional dispose()
29
+ - createServerComposition(context) returns routes, optional settings (defineModuleSettings), optional start() for registration only, optional startWorker() that starts every poll loop and background worker, optional stop() and optional dispose()
30
30
  - context carries auth, settings (ModuleSettingsRuntime), agentTools (PlatformToolRegistry), agentDefinitions (PlatformAgentRegistry) and capabilities (PlatformCapabilityRegistry)
31
31
  conditional:
32
32
  api:
@@ -20,11 +20,11 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
20
20
 
21
21
  **List export.** A list endpoint that already pages with the keyset helpers becomes a CSV export by declaring one: `defineListExport({ id, label, permission, columns, page })` (`packages/server/src/export/`), where `id` is the owning module id plus the list key (`users.core.members`), `permission` is the one the list endpoint itself requires, `columns` is 1 to 64 `{ key, header, value(row) }` entries and `page(principal, cursor, limit)` is the paging the endpoint already implements. The declaration is type erased at definition time, so no row object leaves the module that produced it. A module registers its declarations while it composes, through the public capability `exports.lists.v1` (`context.capabilities.get<ExportLists>(EXPORT_LISTS_CAPABILITY)?.register(moduleId, […])`, `modules/exports`); the id must sit inside the registering module's namespace and the catalogue is sealed before the first request; the same capability answers `find(id)` with the registered declaration or null, for a module that pages a list itself under a principal holding the list's permission. `exports.core` owns the rest: `POST /api/exports/start` behind `exports.lists.manage` plus the list's own permission checked on the live principal, `GET /api/exports/jobs` and `/api/exports/jobs/:id` paged behind `exports.lists.read`, `GET /api/exports/lists` behind the same permission for the catalogue of registered lists (id, label, registering module and whether the asking principal holds that list's permission, never the permission id), which is what the Exports screen's start control offers to a reader holding `exports.lists.manage`, and `POST /api/exports/jobs/read-url` for a signed storage route minted per request, which re-checks the exported list's permission on the live principal so the file is never easier to read than the list. A poll loop on the job runner walks the pages under the requester's snapshot and writes RFC 4180 with a UTF-8 byte order mark to the storage port under `exports.core`. Neither bound truncates: over `maxRows` (default 100000) or `maxBytes` (default 50 MB, both platform settings, and the storage object ceiling of 25 MB applies underneath) the job fails with `EXPORT_ROWS_EXCEEDED` or `EXPORT_BYTES_EXCEEDED` and writes no file. A list that answers a next cursor answers at least one row with it and never the cursor it was given. Cells are written as the declaration answered them and are never rewritten, so a value beginning with `=`, `+`, `-` or `@` reaches the file as data and this module neither prefixes nor quotes it against a spreadsheet reading it as a formula; a module whose column can carry such a value neutralises it in its own `value(row)`. Jobs are held 30 days by the data class `exports.core.jobs`, whose sweep deletes the file with the row.
22
22
 
23
- **PostgreSQL with forced row-level security.** A module receives a `DatabaseProvider` as `context.databases` and acquires a lease per purpose (`runtime`, `migration`, `background`, `preview`, `test`); it never sees a DSN or a pool. Every statement runs inside `database.transaction(fn, { tenantId, access })` with `access: 'read' | 'write'`; a runtime lease without a `tenantId` throws `TENANT_CONTEXT_REQUIRED`. The adapter sets `coreloom.tenant_id` transaction-locally, and each tenant table must `ENABLE` and `FORCE ROW LEVEL SECURITY` with a `USING` and `WITH CHECK` policy against it. Migrations are numbered, immutable once applied, mirrored byte for byte in `databaseMigrations`, and recorded in the `_coreloom_migrations_v2` ledger by checksum. The runtime role holds neither `SUPERUSER` nor `BYPASSRLS`. (`packages/database/src/{contracts,postgresql,migrations,provider}.ts`.)
23
+ **PostgreSQL with forced row-level security.** A module receives a `DatabaseProvider` as `context.databases` and acquires a lease per purpose (`runtime`, `migration`, `background`, `preview`, `test`); it never sees a DSN or a pool. Every statement runs inside `database.transaction(fn, { tenantId, access })` with `access: 'read' | 'write'`; a runtime lease without a `tenantId` throws `TENANT_CONTEXT_REQUIRED`. The adapter sets `flowdular.tenant_id` transaction-locally, and each tenant table must `ENABLE` and `FORCE ROW LEVEL SECURITY` with a `USING` and `WITH CHECK` policy against it. Migrations are numbered, immutable once applied, mirrored byte for byte in `databaseMigrations`, and recorded in the `_flowdular_migrations_v2` ledger by checksum. The runtime role holds neither `SUPERUSER` nor `BYPASSRLS`. (`packages/database/src/{contracts,postgresql,migrations,provider}.ts`.)
24
24
 
25
- **Background work.** A module that polls its own routing table runs one loop per job through `createJobRunner` (`packages/server/src/jobs/`), taking `{ name, intervalMs, claim, perform, heartbeat?, heartbeatEveryMs?, staleAfterMs, backoff?, batchLimit?, logger, now?, onEvent? }`. The runner owns the loop and nothing else: the timer and its `unref`, the guard that keeps two passes from overlapping, at most `batchLimit` claims per pass, per-item isolation so one failing item never stops the pass, a renewal timer that calls `heartbeat` while `perform` runs and aborts its `AbortSignal` with the stable code `CLAIM_LOST` when the fence answers false, exponential `backoff` after a pass that raised and a reset by one that did not, and `start`, `tick`, `stop`, `quiesce` and `dispose`. It opens no database handle: the table, the routing read, the claim statement with its stale window, the renewal statement and every outcome recorded stay the module's own, `claim` answering null ends the pass, and a stage that observes the abort stops without settling anything. `onEvent` is a trace hook that costs nothing when nobody listens. A composition wires it as `start`, `stop: () => runner.quiesce()` and `dispose: () => runner.dispose()`; `import.core` is the first adopter and `packages/server/src/jobs/index.ts` carries the recipe for the rest.
25
+ **Background work.** A module that polls its own routing table runs one loop per job through `createJobRunner` (`packages/server/src/jobs/`), taking `{ name, intervalMs, claim, perform, heartbeat?, heartbeatEveryMs?, staleAfterMs, backoff?, batchLimit?, logger, now?, onEvent? }`. The runner owns the loop and nothing else: the timer and its `unref`, the guard that keeps two passes from overlapping, at most `batchLimit` claims per pass, per-item isolation so one failing item never stops the pass, a renewal timer that calls `heartbeat` while `perform` runs and aborts its `AbortSignal` with the stable code `CLAIM_LOST` when the fence answers false, exponential `backoff` after a pass that raised and a reset by one that did not, and `start`, `tick`, `stop`, `quiesce` and `dispose`. It opens no database handle: the table, the routing read, the claim statement with its stale window, the renewal statement and every outcome recorded stay the module's own, `claim` answering null ends the pass, and a stage that observes the abort stops without settling anything. `onEvent` is a trace hook that costs nothing when nobody listens. A composition starts it from `startWorker: () => runner.start()` and wires `stop: () => runner.quiesce()` and `dispose: () => runner.dispose()`. `start` is for registration only (sealing a registry, reading what other modules registered): the platform calls it in every process, and calls `startWorker` only where workers run, never with `FD_RUNTIME_ROLE=web`. A worker host may call `startWorker` and `stop` many times on one composition, so the loop restarts after a stop and a failed database open is not cached: the next `startWorker` opens again. `runner.wake()` runs a pass even on a stopped runner, so a request path that wakes the loop after it enqueues checks a flag set in `startWorker` and cleared in `stop` first (`workerActive` in `modules/adapters/src/server/runtime.ts`). `import.core` is the first adopter and `packages/server/src/jobs/index.ts` carries the recipe for the rest.
26
26
 
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.
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. A primed snapshot is at most 5 seconds behind a write another process made. Every write appends one row to auth.core's change log, which names the setting and never its value: `context.settings.changesAfter({ after, limit, moduleId?, key? })` pages it from an opaque cursor (`after: null` is the start, 1 to 500 changes a page, the newest change of every setting kept whatever its age) and answers `{ expired: true }` for a cursor past retention, whose holder reads from the start again; `prime(tenantId, { revision })` then reflects at least a revision read there. `onChange` fires only in the process that wrote, so work that must see every change or survive a crash follows the log instead, as `automations.core` does for the workspace time zone.
28
28
 
29
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`.
30
30
 
@@ -54,7 +54,9 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
54
54
 
55
55
  **Business agents.** `defineAgent` (`modules/agents/src/server/define-agent.ts`) declares `moduleId`, `key`, `definitionRevision`, `name`, `description`, `instructions`, `allowedTools` (at most 32, exact ids, no wildcards) and `limits` (`maxSteps` 1 to 32, `timeoutMs`, `temperature`, `maxOutputTokens`). Registered with `context.agentDefinitions.register(...)`. The definition owns behaviour and the maximum tool ceiling; provider, model, credentials, active state and the reduced enabled tools are tenant binding data.
56
56
 
57
- **Workflows.** `workflows.core` owns typed DAGs with exactly nine node kinds (`modules/workflows/src/domain/types.ts`): `input`, `agent`, `agent-decision`, `gate`, `validator`, `action`, `merge`, `output` and `human-approval`, which opens an approvals.core request with the run as subject, parks the run in `waiting-approval` and resumes on approval or fails it with `WORKFLOW_APPROVAL_REJECTED`, `WORKFLOW_APPROVAL_EXPIRED` or `WORKFLOW_APPROVAL_CANCELLED`; publishing such a node needs approvals.core present and the named role defined in the workspace. A module starts a run through the public `WORKFLOW_EXECUTION_CAPABILITY`; workflow trigger sources are `manual`, `module`, `schedule` and `webhook`.
57
+ **Workflows.** `workflows.core` owns typed DAGs with ten node kinds (`modules/workflows/src/domain/types.ts`): `input`, `agent`, `agent-decision`, `typed-decision`, `gate`, `validator`, `action`, `human-approval`, `merge` and `output`. A `human-approval` node opens an approvals.core request with the run as subject, parks the run in `waiting-approval` and resumes on approval or fails it with `WORKFLOW_APPROVAL_REJECTED`, `WORKFLOW_APPROVAL_EXPIRED` or `WORKFLOW_APPROVAL_CANCELLED`; publishing such a node needs approvals.core present and the named role defined in the workspace. A module starts a run through the public `WORKFLOW_EXECUTION_CAPABILITY`; workflow trigger sources are `manual`, `module`, `schedule` and `webhook`.
58
+
59
+ **Module-owned workflow templates.** A business module registers one ordinary versioned `AgentTool` through `context.agentTools` and may add static `workflowTemplate: { label, description, effect }` to present that action as a named palette choice. `agents.actions.v2` exposes the metadata and complete executable action descriptor from the same registry and ledger as `agents.actions.v1`; the older capability keeps its response shape. Selecting a template creates an ordinary `action` node pinned to the action id, contract version, schemas, permissions, risk, idempotency protection, timeout, cancellation and effect. The metadata has a label of at most 80 characters, description of at most 240, and effect `local` or `connector-egress`; it grants no permission and contains no code, credential or tenant value. The action requires bounded input and output JSON Schemas, read or workspace-write risk, required idempotency, and a code-level validator in the owning module. Writes require a durable target ledger. A template cannot require a raw input marked `writeOnly` or `x-flowdular-secret`; graph input uses a nonsecret opaque reference resolved by the module. Connector egress goes through `connectors.calls.v1` with `allowWorkflows` consent and a stable side-effect key. A replay exposes only its stable call id and outcome, and `CALL_OUTCOME_UNKNOWN` is terminal until a separate remote recovery contract exists. In Sandbox, a business manager updates the owning module's specification, the operator approves its exact hash, and backend and agentic specialists implement and test their owned files before host preview, review and eject. No new workflow node kind or workflow-node registry is involved.
58
60
 
59
61
  **Automations triggers.** Two mechanisms in `automations.core`. A schedule uses a cadence string in one of two forms (`modules/automations/src/domain/cadence.ts`): `every:N`, where `N` is whole minutes from 1 to 10080 and the unit is implicit, or `cron:<minute> <hour> <day of month> <month> <day of week>`, five fields with no seconds, at most 100 characters, each field `*`, a number, a three letter month or weekday name, a list, a range, or any of those with a step (`*/15`, `9-17/4`); both day fields restricted means either matches. A cron slot is a wall clock time in the workspace zone from the shared `system.core.timeZone` setting, stored in UTC; a wall time a daylight saving change removes is skipped and one that occurs twice fires at the first of the two. An expression the module cannot honour is refused at save with `INVALID_CADENCE`. Missed slots are skipped, never replayed. An inbound webhook posts to `POST /api/automations/triggers/:id/fire`, authenticated by an HMAC signature in `x-flowdular-signature` with `x-flowdular-timestamp` inside a 5 minute window and a 16 KB body cap, answering `202 { accepted, runId }`. Targets are pluggable through `automations.targets.v1`; the shipped kinds are `agent` and `workflow`.
60
62
 
@@ -70,7 +72,7 @@ Read this file before writing or implementing a spec. It replaces scanning `modu
70
72
 
71
73
  **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.
72
74
 
73
- **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.
75
+ **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 or a private Vercel Blob store (`FD_STORAGE_ADAPTER=local|s3|vercel-blob`, `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.
74
76
 
75
77
  **Connectors.** `connectors.core` (optional) is the governed way out to an external system; its egress policy is also the public capability `connectors.egress.v1` for a module that opens one public URL of its own (`modules/connectors/src/domain/egress.ts`). A module ships a connector definition through the public capability `connectors.definitions.v1` (`modules/connectors/src/domain/definitions.ts`): `register({ key, moduleId, label, authKinds, operations: [{ key, label, method, path, inputSchema, outputSchema }], defaultAllowedHosts, allowedPorts? })` (ports default to 443 only), and the platform ships `http-json`. An owner creates an instance behind `connectors.instances.manage` with a base URL, sealed credentials under `FD_CONNECTORS_SECRET_KEY`, a host allowlist and two consent flags, `allowWorkflows` and `allowAgents`, both off. A call goes through `connectors.calls.v1`: `call({ tenantId, instanceId, operation, input, caller: 'test' | 'workflow' | 'agent', callerRef? })`, which enforces status, consent for that caller kind, the egress policy (https, no private addresses, no redirects, timeout and size caps) and logs the call without any body, answering `retryAfterMs` from a 429 or 503 `Retry-After` header; `consented(tenantId, instanceId, caller)` answers admission alone. A module keeps its own instance of its own definition through `connectors.instances.v1` (`modules/connectors/src/domain/instances.ts`): `upsertModuleInstance({ tenantId, moduleId, key, definition, baseUrl, credentials?, allowedHosts, allowAgents, allowWorkflows, actor })` creates or updates the one instance per workspace, module and key (absent credentials keep the sealed one; a definition of another module answers `DEFINITION_FOREIGN`), and `describeModuleInstance({ tenantId, moduleId, key })` answers it with `hasCredentials` and never a credential. The agent tool `connectors.call` is declared `workspace-write` with the harness consent gate `connectors.instance-consent` (`AgentToolConsent` in `packages/harness/src/runtime.ts`), carries the full action contract (`idempotency: 'required'` backed by a per-call key ledger) so workflows may use it, has no HTTP route of its own, and dials only the addresses the egress policy verified, so the ceiling is raised per instance by the owner's consent, never by a declaration.
76
78
 
@@ -9,23 +9,38 @@ default: deny
9
9
 
10
10
  # packages/cli/src/capabilities.ts
11
11
  core:
12
+ deploy.start.local:
13
+ command: pnpm flowdular deploy start docker --apply
14
+ risk: process
15
+ supportsDryRun: true
16
+ effect: runs the existing Docker Compose launcher in the operator's terminal after checking its files and Docker Compose; the launcher creates local secrets on first start and opens setup
17
+ deploy.start.vercel:
18
+ command: pnpm flowdular deploy start vercel --apply
19
+ risk: process
20
+ supportsDryRun: true
21
+ effect: drives the signed-in Vercel CLI in the operator's terminal to link the project, provision Neon PostgreSQL and its runtime and background roles, upload the stable keys from a 0600 local backup through stdin, connect a private Blob store, deploy to Production and print a one-time setup token whose SHA-256 alone is stored in Vercel
22
+ module.source:
23
+ command: pnpm flowdular module source add <name> <location> [--apply]
24
+ risk: workspace-write
25
+ supportsDryRun: true
26
+ note: host-only source configuration; sandbox agents receive no network or Git access
27
+ module.plan:
28
+ command: pnpm flowdular module plan <id[@version]> --source <name> [--apply]
29
+ risk: workspace-write
30
+ supportsDryRun: true
31
+ note: saves exact source, release digests and impact without executing module code
32
+ module.apply:
33
+ command: pnpm flowdular module apply <plan-id> [--apply]
34
+ risk: workspace-write
35
+ supportsDryRun: true
36
+ note: host-only source installation; activation and database changes remain separate
12
37
  module.search:
13
38
  command: pnpm flowdular module search [query]
14
39
  risk: read
15
- note: host-only official HTTPS catalog lookup; does not grant sandbox network access
40
+ note: host-only configured source lookup; does not grant sandbox network access
16
41
  module.info:
17
42
  command: pnpm flowdular module info <id>
18
43
  risk: read
19
- module.install:
20
- command: pnpm flowdular module install <id[@version]> [--apply]
21
- risk: workspace-write
22
- supportsDryRun: true
23
- note: host-only source installation; no scripts, activation, permissions or database changes
24
- module.update:
25
- command: pnpm flowdular module update <id[@version]> [--apply]
26
- risk: workspace-write
27
- supportsDryRun: true
28
- note: rejects local edits, changed historical migrations and downgrades
29
44
  module.recover:
30
45
  command: pnpm flowdular module recover [--apply]
31
46
  risk: workspace-write
@@ -71,7 +86,7 @@ core:
71
86
  risk: process
72
87
  localOnly: true
73
88
  supportsDryRun: true
74
- effect: applies or adopts the outstanding migrations of one module against the configured PostgreSQL (embedded PGlite outside production) and writes the _coreloom_migrations_v2 ledger; without --apply it reports the plan and writes nothing
89
+ effect: applies or adopts the outstanding migrations of one module against the configured PostgreSQL (embedded PGlite outside production) and writes the _flowdular_migrations_v2 ledger; without --apply it reports the plan and writes nothing
75
90
  database.backup:
76
91
  command: pnpm flowdular database backup --output <dir> [--apply]
77
92
  risk: process
@@ -109,6 +124,7 @@ commandsWithoutDescriptor:
109
124
  - pnpm flowdular module enable <id> [--apply] (with --apply also runs auth.scopes.sync; result field scopes, failure code MODULE_SCOPES_SYNC_FAILED)
110
125
  - pnpm flowdular module disable <id> [--apply]
111
126
  - pnpm flowdular setup check
127
+ - pnpm flowdular deploy targets|plan <docker|kubernetes|render|vercel|cloudflare>
112
128
  - pnpm flowdular setup quick (alias of auth.greenfield.reset)
113
129
 
114
130
  # modules/*/src/cli/commands.json, loaded only for modules enabled in flowdular.json
@@ -23,7 +23,7 @@ Flowdular is an agentic foundation framework: the platform is the foundation, an
23
23
  | `business-agent-design` | Ship a module-owned business agent with an exact tool ceiling, tenant binding, revisions, and access tests. |
24
24
  | `integration-adapter` | Add a source or sink adapter for a named service: connector, port, mapping, recorded fixture, consent, call log. |
25
25
  | `variables` | Variable-aware fields and templates: the `{{ }}` contract, the scope mask, server-side resolution, adding a source. |
26
- | `workflow-development` | Build, publish, invoke, simulate, and test typed durable workflows and their module integration capability. |
26
+ | `workflow-development` | Build, publish, invoke, simulate, and test typed durable workflows, including module-owned custom node templates. |
27
27
  | `release-eject-pr` | Sandbox eject sequence, repository gates, branch and PR conventions, post-merge scope grant. |
28
28
  | `deploy-operate` | Container build, production env keys, migrations at rollout, health and readiness, backup and restore, rollback. |
29
29
 
@@ -24,7 +24,7 @@ also ship a ready business agent through `defineAgent()`, read
24
24
  ## 1. The contract in code
25
25
 
26
26
  - Composition: `PlatformServerContext` (`modules/auth/src/server/composition.ts`) carries `agentTools: PlatformToolRegistry` (`register(tools)`, `list()`; `packages/kernel/src/tool-registry.ts`; a duplicate tool id throws at boot), `settings: ModuleSettingsRuntime`, and `capabilities: PlatformCapabilityRegistry` (`register(id, service)`, `get(id)`, `has(id)`; `packages/kernel/src/capability-registry.ts`). `platform/octane.config.ts` creates the registries, passes them to every module's `createServerComposition`, declares each `settings`, owns each `dispose`, then calls each `start`.
27
- - Ordering is a non-issue: `agents.core` (`modules/agents/src/platform.ts`) passes `tools: () => context.agentTools.list()` into `createAgentRuntime`, and the harness is built lazily in `start()`, which runs after every module has composed. Tools any module registers during its own compose are therefore visible, whatever the module order.
27
+ - Ordering is a non-issue: `agents.core` (`modules/agents/src/platform.ts`) passes `tools: () => context.agentTools.list()` into `createAgentRuntime`, and the harness is built when `agents.core` opens, on its first request, capability call or `startWorker()`, all of which run after every module has composed. Tools any module registers during its own compose are therefore visible, whatever the module order.
28
28
  - Helpers: import `defineApiAgentTool` from `@flowdular/sdk/harness/tool-adapters` and the types `AgentTool`, `AgentToolContext` from `@flowdular/sdk/harness/runtime`. Both subpaths are free of the Vercel AI SDK; only the harness root (`@flowdular/sdk/harness`) and `@flowdular/sdk/modules/agents/server` pull it. `defineApiAgentTool` returns a frozen `AgentTool { id, transport: 'api', target, description, requiredPermissions, inputSchema?, execute }`. `defineCliAgentTool({ id, capability: { id, risk }, ... })` wraps a CLI capability and throws at definition time for `external` or `destructive` risk.
29
29
  - Skills inside `agents.core` are tenant database records behind `agents.skills.*`, appended to agent instructions. They are unrelated to `.ai/skills/**`, which are files for coding agents.
30
30
  - A read tool's output can also become a resolvable `{{ variable }}` for variable-aware fields: the tool's `requiredPermissions` is the variable's scope mask. Register a source on `platformVariableRegistry(context.capabilities)`, require an explicit record binding, and invoke the tool with the trusted tenant, actor permission snapshot, and signal. See the `variables` skill for the complete refusal contract.
@@ -63,7 +63,7 @@ Recipe in `modules/auth/tests/endpoints.test.ts`: build the runtime with a `Data
63
63
 
64
64
  - 401 without a cookie or token.
65
65
  - 403 with a principal that lacks the permission.
66
- - Cross-tenant read returns an empty list (service level, on the suite's test provider under the non-bypass `coreloom_runtime` role).
66
+ - Cross-tenant read returns an empty list (service level, on the suite's test provider under the non-bypass `flowdular_runtime` role).
67
67
  - Mutation without `x-csrf-token` returns 403 `CSRF_REJECTED`; without `origin` returns 403.
68
68
  - Each validation bound returns 400 with its code.
69
69
 
@@ -94,12 +94,12 @@ PostgreSQL tenant-owned tables also use database-enforced isolation:
94
94
 
95
95
  - enable and force row-level security on the table;
96
96
  - define a policy whose `USING` and `WITH CHECK` clauses compare `tenant_id`
97
- with `current_setting('coreloom.tenant_id', true)`;
97
+ with `current_setting('flowdular.tenant_id', true)`;
98
98
  - run application traffic under a role that is neither a superuser nor granted
99
99
  `BYPASSRLS`;
100
100
  - use a separate migration role for DDL or policy ownership when required.
101
101
 
102
- The adapter sets `coreloom.tenant_id` with parameterized `set_config(..., true)`
102
+ The adapter sets `flowdular.tenant_id` with parameterized `set_config(..., true)`
103
103
  after `BEGIN` on the pinned connection. Never use an unpinned root query.
104
104
  Explicit tenant predicates remain required as defense in depth.
105
105
 
@@ -139,7 +139,7 @@ transactions without `tenantId`, fail with `TENANT_CONTEXT_REQUIRED`.
139
139
 
140
140
  Use `DatabaseMigration` and `runDatabaseMigrations` from `@flowdular/sdk/database`.
141
141
  Each migration has one immutable id and its PostgreSQL SQL. The ledger is
142
- `_coreloom_migrations_v2`, keyed by module namespace and migration id; its
142
+ `_flowdular_migrations_v2`, keyed by module namespace and migration id; its
143
143
  checksum covers that exact SQL.
144
144
 
145
145
  `inspectExisting(database)` is the only pre-ledger adoption proof. Use
@@ -163,8 +163,8 @@ constant. A migration-only task uses `migration-authoring` in a separate phase.
163
163
  ## 7. Tests run on a real PostgreSQL
164
164
 
165
165
  `createTestDatabaseProvider()` from `@flowdular/sdk/database-testing` gives a suite its
166
- own PostgreSQL in process by default, with the same `coreloom_runtime` and
167
- `coreloom_background` roles and the same forced row-level security a deployment
166
+ own PostgreSQL in process by default, with the same `flowdular_runtime` and
167
+ `flowdular_background` roles and the same forced row-level security a deployment
168
168
  enforces. There is no server to start and no second dialect to keep green, so
169
169
  the isolation assertions run on every turn rather than behind an environment
170
170
  flag. CI selects server PostgreSQL with `FD_TEST_DATABASE_ADAPTER=postgresql`
@@ -83,8 +83,8 @@ adapter change, sandbox eject, and deployment validation.
83
83
 
84
84
  Every turn runs against a real PostgreSQL, because the embedded one starts in
85
85
  process. The sandbox and the test suites use `createTestDatabaseProvider()` from
86
- `@flowdular/sdk/database-testing`, which brings the `coreloom_runtime` and
87
- `coreloom_background` roles and forced row-level security with it.
86
+ `@flowdular/sdk/database-testing`, which brings the `flowdular_runtime` and
87
+ `flowdular_background` roles and forced row-level security with it.
88
88
 
89
89
  A target run covers tenant A and B fixtures, operations without tenant context,
90
90
  forged cross-tenant inserts, direct row-security bypass probes, concurrent
@@ -53,7 +53,7 @@ Set `FD_TRUST_PROXY` behind a load balancer. `FD_DATABASE_BACKGROUND_URL` gives
53
53
 
54
54
  ## 3. Migrations at rollout
55
55
 
56
- Migrations are module-owned, numbered, immutable once applied, and verified by checksum against the `_coreloom_migrations_v2` ledger. The commands (`packages/cli/src/runner.ts`):
56
+ Migrations are module-owned, numbered, immutable once applied, and verified by checksum against the `_flowdular_migrations_v2` ledger. The commands (`packages/cli/src/runner.ts`):
57
57
 
58
58
  ```bash
59
59
  pnpm flowdular migration status [--module <id>] # what the ledger holds
@@ -32,7 +32,7 @@ Migration SQL is checked in and immutable after release:
32
32
  ## 2. What the v2 runner guarantees
33
33
 
34
34
  `runDatabaseMigrations(database, namespace, databaseMigrations)` uses the
35
- namespaced `_coreloom_migrations_v2` ledger. A row records namespace, migration
35
+ namespaced `_flowdular_migrations_v2` ledger. A row records namespace, migration
36
36
  id, dialect id, checksum, and applied time. The checksum covers the selected
37
37
  dialect's exact SQL.
38
38
 
@@ -82,14 +82,14 @@ Every PostgreSQL tenant table includes:
82
82
  ALTER TABLE inventory_locations ENABLE ROW LEVEL SECURITY;
83
83
  ALTER TABLE inventory_locations FORCE ROW LEVEL SECURITY;
84
84
  CREATE POLICY inventory_locations_tenant_policy ON inventory_locations
85
- USING (tenant_id = current_setting('coreloom.tenant_id', true))
86
- WITH CHECK (tenant_id = current_setting('coreloom.tenant_id', true));
85
+ USING (tenant_id = current_setting('flowdular.tenant_id', true))
86
+ WITH CHECK (tenant_id = current_setting('flowdular.tenant_id', true));
87
87
  ```
88
88
 
89
89
  The runtime role is not a superuser and has no `BYPASSRLS`. DDL and policy
90
90
  ownership use `purpose: 'migration'`. Runtime repository calls use
91
91
  `database.transaction(operation, { tenantId, access })`; the adapter sets
92
- transaction-local `coreloom.tenant_id` on the pinned connection. Queries still
92
+ transaction-local `flowdular.tenant_id` on the pinned connection. Queries still
93
93
  include `WHERE tenant_id = ...` as defense in depth.
94
94
 
95
95
  ## 6. Add one migration