create-flowdular 0.4.3 → 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 (130) hide show
  1. package/README.md +16 -10
  2. package/agent-template/.agents/skills/agent-tool-design/SKILL.md +1 -1
  3. package/agent-template/.agents/skills/auth-security-review/SKILL.md +2 -2
  4. package/agent-template/.agents/skills/bug-hunt/SKILL.md +1 -1
  5. package/agent-template/.agents/skills/database-adapter/SKILL.md +5 -5
  6. package/agent-template/.agents/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  7. package/agent-template/.agents/skills/deploy-operate/SKILL.md +1 -1
  8. package/agent-template/.agents/skills/migration-authoring/SKILL.md +4 -4
  9. package/agent-template/.agents/skills/module-new/SKILL.md +1 -1
  10. package/agent-template/.agents/skills/spec-interview/SKILL.md +20 -20
  11. package/agent-template/.agents/skills/test-hardening/SKILL.md +2 -2
  12. package/agent-template/.agents/skills/ux-design/SKILL.md +1 -1
  13. package/agent-template/.agents/skills/workflow-development/SKILL.md +95 -9
  14. package/agent-template/.ai/README.md +5 -3
  15. package/agent-template/.ai/agents/README.md +1 -1
  16. package/agent-template/.ai/agents/sandbox/agentic-engineer.md +1 -0
  17. package/agent-template/.ai/agents/sandbox/backend-engineer.md +1 -0
  18. package/agent-template/.ai/agents/sandbox/frontend-engineer.md +1 -0
  19. package/agent-template/.ai/blueprints/add-migration/README.md +1 -1
  20. package/agent-template/.ai/blueprints/add-migration/required-files.yaml +1 -1
  21. package/agent-template/.ai/blueprints/new-module/required-files.yaml +1 -1
  22. package/agent-template/.ai/examples/bad/client-imports-server/README.md +1 -1
  23. package/agent-template/.ai/examples/bad/missing-acl/README.md +1 -1
  24. package/agent-template/.ai/examples/bad/tenant-from-body/README.md +1 -1
  25. package/agent-template/.ai/guides/application-development.md +7 -5
  26. package/agent-template/.ai/platform-capabilities.md +9 -5
  27. package/agent-template/.ai/policies/capabilities.yaml +28 -12
  28. package/agent-template/.ai/policies/task-budgets.yaml +1 -1
  29. package/agent-template/.ai/rules/flowdular.md +3 -2
  30. package/agent-template/.ai/skills/README.md +1 -1
  31. package/agent-template/.ai/skills/agent-tool-design/SKILL.md +1 -1
  32. package/agent-template/.ai/skills/auth-security-review/SKILL.md +2 -2
  33. package/agent-template/.ai/skills/bug-hunt/SKILL.md +1 -1
  34. package/agent-template/.ai/skills/database-adapter/SKILL.md +5 -5
  35. package/agent-template/.ai/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  36. package/agent-template/.ai/skills/deploy-operate/SKILL.md +1 -1
  37. package/agent-template/.ai/skills/migration-authoring/SKILL.md +4 -4
  38. package/agent-template/.ai/skills/module-new/SKILL.md +1 -1
  39. package/agent-template/.ai/skills/spec-interview/SKILL.md +20 -20
  40. package/agent-template/.ai/skills/test-hardening/SKILL.md +2 -2
  41. package/agent-template/.ai/skills/ux-design/SKILL.md +1 -1
  42. package/agent-template/.ai/skills/workflow-development/SKILL.md +96 -10
  43. package/agent-template/.ai/subagents/module-executor.md +25 -0
  44. package/agent-template/.ai/subagents/reviewer.md +23 -0
  45. package/agent-template/.ai/subagents/spec-author.md +23 -0
  46. package/agent-template/.claude/agents/module-executor.md +22 -0
  47. package/agent-template/.claude/agents/reviewer.md +24 -0
  48. package/agent-template/.claude/agents/spec-author.md +20 -0
  49. package/agent-template/.claude/skills/agent-tool-design/SKILL.md +1 -1
  50. package/agent-template/.claude/skills/auth-security-review/SKILL.md +2 -2
  51. package/agent-template/.claude/skills/bug-hunt/SKILL.md +1 -1
  52. package/agent-template/.claude/skills/database-adapter/SKILL.md +5 -5
  53. package/agent-template/.claude/skills/database-adapter/references/first-run-and-matrix.md +2 -2
  54. package/agent-template/.claude/skills/deploy-operate/SKILL.md +1 -1
  55. package/agent-template/.claude/skills/migration-authoring/SKILL.md +4 -4
  56. package/agent-template/.claude/skills/module-new/SKILL.md +1 -1
  57. package/agent-template/.claude/skills/spec-interview/SKILL.md +20 -20
  58. package/agent-template/.claude/skills/test-hardening/SKILL.md +2 -2
  59. package/agent-template/.claude/skills/ux-design/SKILL.md +1 -1
  60. package/agent-template/.claude/skills/workflow-development/SKILL.md +95 -9
  61. package/agent-template/.codex/agents/module-executor.toml +17 -0
  62. package/agent-template/.codex/agents/reviewer.toml +14 -0
  63. package/agent-template/.codex/agents/spec-author.toml +15 -0
  64. package/agent-template/AGENTS.md +3 -2
  65. package/agent-template/CLAUDE.md +3 -2
  66. package/agent-template/docs/adr/0007-module-owned-agents.md +35 -1
  67. package/agent-template/docs/agent-contract.md +2 -2
  68. package/agent-template/docs/cli.md +24 -3
  69. package/agent-template/docs/configuration.md +59 -5
  70. package/agent-template/docs/database-adapters.md +20 -20
  71. package/agent-template/docs/design-system.md +3 -3
  72. package/agent-template/docs/getting-started.md +25 -32
  73. package/agent-template/docs/module-distribution.md +79 -86
  74. package/agent-template/docs/module-web-surfaces.md +9 -7
  75. package/agent-template/docs/modules.md +9 -1
  76. package/agent-template/docs/sandbox.md +117 -6
  77. package/agent-template/platform/scripts/build.mjs +7 -0
  78. package/agent-template/rulesync.jsonc +1 -1
  79. package/dist/bin.js +12 -6
  80. package/package.json +2 -2
  81. package/template/default/.env.example +10 -3
  82. package/template/default/.prettierignore +2 -0
  83. package/template/default/.vercelignore +8 -0
  84. package/template/default/README.md +26 -15
  85. package/template/default/_gitignore +3 -2
  86. package/template/default/infra/README.md +86 -65
  87. package/template/default/infra/docker/.env.example +66 -0
  88. package/template/default/infra/docker/Dockerfile +24 -10
  89. package/template/default/infra/docker/app-entrypoint.mjs +5 -0
  90. package/template/default/infra/docker/compose.yaml +105 -58
  91. package/template/default/infra/docker/database-urls.mjs +28 -0
  92. package/template/default/infra/docker/pitr.sh +177 -0
  93. package/template/default/infra/docker/postgres/10-roles.sh +16 -12
  94. package/template/default/infra/docker/start.mjs +402 -0
  95. package/template/default/infra/kubernetes/database-secret.example.yaml +3 -3
  96. package/template/default/infra/vercel/README.md +262 -0
  97. package/template/default/infra/vercel/build.mjs +214 -0
  98. package/template/default/infra/vercel/handler.mjs +100 -0
  99. package/template/default/modules/example/migrations/0001_example_core.up.sql +2 -2
  100. package/template/default/modules/example/module.json +1 -1
  101. package/template/default/modules/example/package.json +3 -3
  102. package/template/default/modules/example/spec/module.yaml +1 -1
  103. package/template/default/modules/example/src/services/migration.ts +2 -2
  104. package/template/default/modules/example/tests/module.test.ts +1 -1
  105. package/template/default/package.json +3 -2
  106. package/template/default/platform/index.html +7 -19
  107. package/template/default/platform/octane.config.ts +252 -156
  108. package/template/default/platform/package.json +5 -5
  109. package/template/default/platform/public/favicon.svg +1 -1
  110. package/template/default/platform/scripts/build.mjs +56 -0
  111. package/template/default/platform/scripts/dev.mjs +38 -0
  112. package/template/default/platform/src/App.tsrx +25 -1
  113. package/template/default/platform/src/generated/modules.server.ts +3 -0
  114. package/template/default/platform/src/server/database.ts +24 -0
  115. package/template/default/platform/src/server/runtime-role.ts +33 -0
  116. package/template/default/platform/src/server/setup/access.ts +160 -0
  117. package/template/default/platform/src/server/setup/adapters.ts +554 -0
  118. package/template/default/platform/src/server/setup/environment.ts +154 -0
  119. package/template/default/platform/src/server/setup/gate.ts +84 -0
  120. package/template/default/platform/src/server/setup/index.ts +181 -0
  121. package/template/default/platform/src/server/setup/modules.ts +123 -0
  122. package/template/default/platform/src/server/setup/page.ts +497 -0
  123. package/template/default/platform/src/server/setup/routes.ts +787 -0
  124. package/template/default/platform/src/server/setup/sanitize.ts +111 -0
  125. package/template/default/platform/src/server/setup/seed.ts +145 -0
  126. package/template/default/platform/src/server/setup/token.ts +79 -0
  127. package/template/default/platform/src/server/worker-tick.ts +193 -0
  128. package/template/default/platform/src/server/workspace-root.ts +16 -0
  129. package/template/default/render.yaml +70 -0
  130. package/template/default/vercel.json +5 -0
@@ -1,14 +1,13 @@
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
  roles:
8
7
  - agentic-engineer
9
8
  - frontend-engineer
10
9
  - module-executor
11
- when: A brief asks for a workflow, pipeline, canvas node, workflow action, or a module feature that starts a workflow.
10
+ when: A brief asks for a workflow, pipeline, canvas node, action-backed workflow template, or a module feature that starts a workflow.
12
11
  ---
13
12
 
14
13
  # Build and integrate an agentic workflow
@@ -18,18 +17,22 @@ pinned agent revisions, deterministic gates, schema validators, registered
18
17
  module actions, data mappings, and terminal output. It does not own schedules or
19
18
  webhook secrets. Those remain optional concerns of `automations.core`.
20
19
 
21
- Read `docs/adr/0006-agentic-workflows.md`, the approved
22
- `modules/workflows/spec/module.yaml`, and the contracts in
23
- `modules/workflows/src/domain/types.ts` before changing a workflow surface.
20
+ At the repository root, read `docs/adr/0006-agentic-workflows.md`, the approved
21
+ `modules/workflows/spec/module.yaml`, and the owning public contracts before
22
+ changing a workflow surface. In the Sandbox, read the approved active-module
23
+ specification and the relevant public contract under `reference/sdk` when it is
24
+ installed. A missing public contract is a core blocker, not a reason to invent
25
+ one or search beyond the session workspace.
24
26
 
25
27
  ## Pick the correct extension point
26
28
 
27
29
  - A workflow definition belongs in `workflows.core` and is edited through its
28
30
  API or canvas. Do not hardcode a tenant workflow in source.
29
31
  - A business operation that a workflow may call is a versioned agent action.
30
- Register it through the agents action catalog. If missing, implement it in a
31
- separate `agent-tool-design` phase with permission, input, output, timeout,
32
- idempotency and audit tests before returning to workflow integration.
32
+ Register one ordinary `AgentTool` with `context.agentTools`. Optional
33
+ `workflowTemplate` metadata makes that action a named palette choice through
34
+ `agents.actions.v2`; it creates no second handler or node kind. Use the
35
+ authoring recipe below when the action is part of this task.
33
36
  - A business module that starts a workflow resolves
34
37
  `workflows.execution.v1` from `context.capabilities`. It never imports a
35
38
  workflow repository or database.
@@ -39,6 +42,87 @@ Read `docs/adr/0006-agentic-workflows.md`, the approved
39
42
  - If the workflow module is absent, the capability registry returns `null`.
40
43
  Hide an optional feature or return a clear stable refusal.
41
44
 
45
+ ## Author a module-owned workflow node template
46
+
47
+ An action-backed template is module source, not graph source. The business
48
+ manager first records its stable action id, permission, named inputs and
49
+ validation rules, output, effect, replay behavior, and success and refusal
50
+ scenarios in the owning module's specification. In a Sandbox session, the
51
+ operator must approve the hash of that exact spec before implementation. A
52
+ later edit requires renewed approval. If any of these decisions are absent,
53
+ hand the spec delta to `business-manager`; do not infer a field, permission,
54
+ external effect, or idempotency rule from the brief.
55
+
56
+ Work inside the existing role boundaries:
57
+
58
+ 1. `backend-engineer` owns the tenant-bound service, code-level validator,
59
+ endpoint or CLI target, and durable target ledger for a mutation. Validation
60
+ runs before any write and returns a stable bounded refusal. A repeated
61
+ idempotency key returns its first result; the same key with different input
62
+ conflicts. Ask backend to supply a missing service rather than writing in
63
+ `src/services/**` or `src/api/**` from the agentic role.
64
+ 2. `agentic-engineer` defines the tool under `src/agent/**`, registers it once
65
+ from `createServerComposition` in `src/platform.ts`, and adds behavioral
66
+ tests. `defineApiAgentTool` or `defineCliAgentTool` carries the existing
67
+ public target. `agents.core` exposes the registered action through
68
+ `agents.actions.v2`; the business module does not register that capability
69
+ or access the workflow database.
70
+ 3. Give the tool a stable dotted id, positive `contractVersion`, required
71
+ permission, bounded input and output JSON Schemas, `risk: 'read'` or
72
+ `'workspace-write'`, `idempotency: 'required'`, cancellation policy, and
73
+ timeout. A workspace write also needs
74
+ `idempotencyProtection: 'target-ledger'` backed by the service's real ledger.
75
+ The handler receives trusted tenant, actor, permission snapshot,
76
+ idempotency key, and `AbortSignal` from `AgentToolContext`; none comes from
77
+ graph input. Its output must satisfy its declared schema.
78
+ 4. Add static `workflowTemplate: { label, description, effect }` on that same
79
+ tool. The label is at most 80 characters, the description at most 240, and
80
+ effect is `local` or `connector-egress`. Metadata contains no code,
81
+ credential, or tenant value. Invalid or duplicate metadata must fail
82
+ composition with a safe diagnostic. A workflow-eligible tool without the
83
+ metadata remains in the generic action editor.
84
+
85
+ The selected template becomes a normal `action` node with input, success, and
86
+ failure ports. It pins the action id, contract version, schemas, permissions,
87
+ risk, idempotency protection, timeout, cancellation, and effect. Changing any
88
+ of those or the handler's behavior requires a new action identity or contract
89
+ version. The current registry keeps one version per action id, so retain the
90
+ old id and register a distinct id when published graphs must keep running;
91
+ label and description may change without rebinding a published graph.
92
+
93
+ Graph bindings may never supply a raw secret. `writeOnly` and
94
+ `x-flowdular-secret` apply at every schema depth, including array items and
95
+ alternatives. A marked field cannot carry `default`, `const`, `enum`,
96
+ `example`, or `examples` data. A template requiring
97
+ a raw secret input is ineligible. Accept a nonsecret opaque reference and let
98
+ the owning module resolve a credential from its tenant-bound vault or a
99
+ declared capability. Never put secret values in fixtures, graph definitions,
100
+ events, audit, or error text.
101
+
102
+ For `connector-egress`, the consumer module declares `connectors.core` and
103
+ `connectors.calls.v1`, uses `caller: 'workflow'`, checks the instance's
104
+ `allowWorkflows` consent, and passes the stable workflow side-effect key to
105
+ the connector. Credentials remain in `connectors.core`. A replay-stable
106
+ output may contain the recorded call id and outcome, not a response body the
107
+ connector replay does not return. Propagate `CALL_OUTCOME_UNKNOWN` as a
108
+ terminal failure when the remote mutation may have happened but no call was
109
+ recorded; never send a second request just to rebuild output. A separate
110
+ provider contract with remote idempotency or readback is required before
111
+ retrying an uncertain mutation.
112
+
113
+ Prove the module behavior at its public service or action boundary: valid
114
+ input, structural and business validation refusal before mutation, missing
115
+ permission, foreign tenant, same-key replay, different-input conflict,
116
+ cancellation, and recovery around the target commit. Connector actions also
117
+ prove absent consent and `CALL_OUTCOME_UNKNOWN` with a recorded fixture. Run a
118
+ deterministic workflow simulation on invented, reviewed fixtures for success,
119
+ failure, and refusal edges. Assert semantic attempts and edge outcomes, not
120
+ real timestamps; simulation must never invoke the handler, connector, or
121
+ network. Inspect the named template and safe run trail in Sandbox preview,
122
+ then run scoped gates, exact-source `auto-review`, and host eject. The agent
123
+ cannot approve the spec, install code into the running server, or push a
124
+ repository from the Sandbox.
125
+
42
126
  ## Graph contract
43
127
 
44
128
  Version one is a bounded DAG. The graph contains:
@@ -47,9 +131,11 @@ Version one is a bounded DAG. The graph contains:
47
131
  - `agent`: calls one exact immutable agent revision and validates structured
48
132
  output.
49
133
  - `agent-decision`: produces one schema-valid `pass` or `fail` outcome.
134
+ - `typed-decision`: routes one bounded typed answer through `pass` or `fail`.
50
135
  - `gate`: evaluates the versioned allowlisted logic language.
51
136
  - `validator`: validates an envelope against a pinned JSON schema.
52
137
  - `action`: calls one exact registered action contract version.
138
+ - `human-approval`: waits for an `approvals.core` request to resolve.
53
139
  - `merge`: waits for all declared incoming paths.
54
140
  - `output`: settles the workflow with a typed result.
55
141
 
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: module-executor
3
+ targets: ['*']
4
+ description: >-
5
+ Implement one Flowdular blueprint end to end at the repository root: scaffold
6
+ from an approved spec, write the module, run the gates and join it to the
7
+ platform through the CLI. Use once a spec is approved and the change is ready
8
+ to be built.
9
+ claudecode:
10
+ model: inherit
11
+ ---
12
+
13
+ Your role prompt is `.ai/agents/module-executor.md`. Read it with the blueprint
14
+ under `.ai/blueprints/<id>/` and the one matching skill in
15
+ `.ai/skills/<name>/SKILL.md` before changing anything.
16
+
17
+ Implement only what the approved spec's acceptance scenarios describe, inside the
18
+ blueprint's `allowed-paths.yaml`. Join the platform through
19
+ `pnpm flowdular module enable <id> --apply` and `auth sync-scopes`; never edit
20
+ `flowdular.json`, `platform/package.json`, `platform/src/generated/**` or
21
+ `platform/octane.config.ts` by hand.
22
+
23
+ Run the module gates and `pnpm verify` yourself and report their exact commands
24
+ and results. Never waive a gate. End with `HANDOFF: reviewer - <what to review>`
25
+ or `HANDOFF: none - <blocker>`.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: reviewer
3
+ targets: ['*']
4
+ description: >-
5
+ Review a finished Flowdular change against its approved spec, the blueprint,
6
+ the invariants and the executable evidence, and report findings by severity.
7
+ Use as a separate phase before delivery or a pull request. Reports defects and
8
+ fixes nothing.
9
+ claudecode:
10
+ model: inherit
11
+ tools: ['Read', 'Grep', 'Glob', 'Bash']
12
+ ---
13
+
14
+ Your role prompt is `.ai/agents/reviewer.md` and the one task skill for this
15
+ phase is `.ai/skills/auto-review/SKILL.md`. Read both before reviewing.
16
+
17
+ You write no production code. Review the complete requested change, its
18
+ requirements, callers and tests; report concrete findings by severity with file,
19
+ line and failure scenario. Never waive missing or failing verification, and never
20
+ approve a change whose evidence you have not seen run.
21
+
22
+ End with `HANDOFF: module-executor - <findings to fix>` or
23
+ `HANDOFF: none - <review result and remaining verification>`.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: spec-author
3
+ targets: ['*']
4
+ description: >-
5
+ Turn a business request into a schema-valid Flowdular module specification at
6
+ the repository root. Use before any implementation, for a new module spec or a
7
+ change to an existing one. Writes only modules/<dir>/spec/module.yaml and never
8
+ approves it.
9
+ claudecode:
10
+ model: inherit
11
+ ---
12
+
13
+ Your role prompt is `.ai/agents/spec-author.md` and the one task skill for this
14
+ phase is `.ai/skills/spec-interview/SKILL.md`. Read both before writing.
15
+
16
+ You write only `modules/<dir>/spec/module.yaml`. Propose a platform default for
17
+ every decision and ask the user for what cannot be inferred; never guess a
18
+ business fact. Never set `status: approved`: approval is the user's, recorded by
19
+ the `spec-approval` skill.
20
+
21
+ `pnpm flowdular spec validate --all --json` must report the file valid before you
22
+ report. End with `HANDOFF: reviewer - spec ready for owner approval` or
23
+ `HANDOFF: none - <open question>`.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: module-executor
3
+ description: >-
4
+ Implement one Flowdular blueprint end to end at the repository root: scaffold
5
+ from an approved spec, write the module, run the gates and join it to the
6
+ platform through the CLI. Use once a spec is approved and the change is ready
7
+ to be built.
8
+ model: inherit
9
+ ---
10
+ Your role prompt is `.ai/agents/module-executor.md`. Read it with the blueprint
11
+ under `.ai/blueprints/<id>/` and the one matching skill in
12
+ `.ai/skills/<name>/SKILL.md` before changing anything.
13
+
14
+ Implement only what the approved spec's acceptance scenarios describe, inside the
15
+ blueprint's `allowed-paths.yaml`. Join the platform through
16
+ `pnpm flowdular module enable <id> --apply` and `auth sync-scopes`; never edit
17
+ `flowdular.json`, `platform/package.json`, `platform/src/generated/**` or
18
+ `platform/octane.config.ts` by hand.
19
+
20
+ Run the module gates and `pnpm verify` yourself and report their exact commands
21
+ and results. Never waive a gate. End with `HANDOFF: reviewer - <what to review>`
22
+ or `HANDOFF: none - <blocker>`.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: reviewer
3
+ description: >-
4
+ Review a finished Flowdular change against its approved spec, the blueprint,
5
+ the invariants and the executable evidence, and report findings by severity.
6
+ Use as a separate phase before delivery or a pull request. Reports defects and
7
+ fixes nothing.
8
+ model: inherit
9
+ tools:
10
+ - Read
11
+ - Grep
12
+ - Glob
13
+ - Bash
14
+ ---
15
+ Your role prompt is `.ai/agents/reviewer.md` and the one task skill for this
16
+ phase is `.ai/skills/auto-review/SKILL.md`. Read both before reviewing.
17
+
18
+ You write no production code. Review the complete requested change, its
19
+ requirements, callers and tests; report concrete findings by severity with file,
20
+ line and failure scenario. Never waive missing or failing verification, and never
21
+ approve a change whose evidence you have not seen run.
22
+
23
+ End with `HANDOFF: module-executor - <findings to fix>` or
24
+ `HANDOFF: none - <review result and remaining verification>`.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: spec-author
3
+ description: >-
4
+ Turn a business request into a schema-valid Flowdular module specification at
5
+ the repository root. Use before any implementation, for a new module spec or a
6
+ change to an existing one. Writes only modules/<dir>/spec/module.yaml and
7
+ never approves it.
8
+ model: inherit
9
+ ---
10
+ Your role prompt is `.ai/agents/spec-author.md` and the one task skill for this
11
+ phase is `.ai/skills/spec-interview/SKILL.md`. Read both before writing.
12
+
13
+ You write only `modules/<dir>/spec/module.yaml`. Propose a platform default for
14
+ every decision and ask the user for what cannot be inferred; never guess a
15
+ business fact. Never set `status: approved`: approval is the user's, recorded by
16
+ the `spec-approval` skill.
17
+
18
+ `pnpm flowdular spec validate --all --json` must report the file valid before you
19
+ report. End with `HANDOFF: reviewer - spec ready for owner approval` or
20
+ `HANDOFF: none - <open question>`.
@@ -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
 
@@ -74,7 +74,7 @@ Report each finding as: severity (`blocker`, `should-fix`, `taste`), claim, `fil
74
74
  ```text
75
75
  blocker Tenant id read from body modules/inventory/src/api/endpoints.ts:41
76
76
  A member of tenant A posts { tenantId: "B" } and creates a location in B.
77
- AGENTS.md 6. Fix: principalFromContext(octane)!.tenantId; drop the field.
77
+ AGENTS.md 4. Fix: principalFromContext(octane)!.tenantId; drop the field.
78
78
  ```
79
79
 
80
80
  ## 8. Known platform gaps to keep in mind (not module defects)
@@ -29,7 +29,7 @@ description: >-
29
29
  | View falls back to the dashboard | `ApplicationShell.tsrx` renders `overview` for a view id that no visible navigation or account menu entry reaches |
30
30
  | Icon renders as a grid | `glyph` or `Icon name` is not an `ICON_PATHS` key (`packages/ui/src/icons/Icon.tsrx` falls back to `modules`) |
31
31
  | Stale data after a change | each component owns a store instance (`useMemo(() => createXClientState(), [])`); check the `store.act` that should have written it. `store.commits(cb)` and `store.stats()` from `segment-state` show what was committed |
32
- | Schema error on start | `runModuleMigrations`: `CHECKSUM_MISMATCH` means applied SQL bytes changed; `PARTIAL_OBJECTS` means only part of a pending migration exists. Never delete or bypass the database to hide either condition; restore the shipped bytes or diagnose the partial schema |
32
+ | Schema error on start | `runDatabaseMigrations`: `CHECKSUM_MISMATCH` means applied SQL bytes changed; `PARTIAL_MIGRATION` means only part of a pending migration exists. Never delete or bypass the database to hide either condition; restore the shipped bytes or diagnose the partial schema |
33
33
 
34
34
  ## 2b. Reproduction snippets
35
35
 
@@ -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
 
@@ -23,26 +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
- | 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[]` |
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 | A named report is one provider on `reports.v1` returning tiles and series; a named list export is one `defineListExport`; named records are findable through `search.providers.v1`. None of the three has a specification key, so each needs a decision naming the screen or the `actions[]` entry that registers it | `actions[]`, `invariants` |
45
+ | Out of scope | Every item from the card's gap list the request touched, each with its business decision | `outOfScope[]`, `decisions[]` |
46
46
 
47
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.
48
48
 
@@ -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.
@@ -81,7 +81,7 @@ Read-only master-detail (runs, playground) keeps `ui-two-col` (+ `--wide-aside`)
81
81
  - `Alert`: `tone` danger (default), warning, info.
82
82
  - `Avatar`: `name`, `square` (organizations), `large`.
83
83
  - `Icon`: `name`, `size` (18 default, 16 in controls, 14 in `Button size="sm"`), `strokeWidth`.
84
- - `BrandMark`: `size`, `signature`, `tone`; brand moments only.
84
+ - `BrandMark`: `size`, `tone`; three bars with a copper accent bar, brand moments only.
85
85
 
86
86
  Icon keys (`ICON_PATHS`, `packages/ui/src/icons/Icon.tsrx`): `dashboard`, `parties`, `catalog`, `user`, `users`, `shield`, `code`, `modules`, `file-text`, `play`, `bot`, `flask`, `activity`, `plug`, `search`, `chevron-down`, `chevron-left`, `chevron-right`, `chevrons-up-down`, `sort`, `calendar`, `plus`, `panel-left`, `check`, `filter`, `download`, `more`, `external`, `alert`, `x`, `sign-out`, `refresh`, `help`, `info`, `key`, `settings`, `braces`, `copy`. An unknown name renders `modules` silently, so check the list.
87
87