@cratis/pi 7.191.5 → 7.192.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.
- package/package/corpus/harnesses/copilot/instructions/application-anatomy.instructions.md +143 -0
- package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +3 -0
- package/package/corpus/rules/application-anatomy.md +142 -0
- package/package/corpus/rules/application-profile.md +1 -1
- package/package/corpus/rules/general.md +2 -2
- package/package/corpus/rules/vertical-slices.md +3 -0
- package/package/corpus/skills/cratis-application-growth/LICENSE +2 -0
- package/package/corpus/skills/cratis-application-growth/SKILL.md +124 -0
- package/package/corpus/skills/cratis-application-growth/references/rename-window.md +59 -0
- package/package/corpus/skills/cratis-application-growth/verification.json +14 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +2 -1
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +5 -0
- package/package/corpus/skills/cratis-arc-command/references/proxy-generation.md +18 -0
- package/package/corpus/skills/cratis-chronicle-configuration/references/client-options.md +1 -1
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/exceptions-logging-and-di.md +6 -1
- package/package/profile-catalog.json +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*.csproj,**/*.slnx,**/Directory.Build.props,**/Directory.Build.targets,**/Directory.Packages.props,**/package.json,**/tsconfig*.json"
|
|
3
|
+
profile: application
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*.csproj"
|
|
6
|
+
- "**/*.slnx"
|
|
7
|
+
- "**/Directory.Build.props"
|
|
8
|
+
- "**/Directory.Build.targets"
|
|
9
|
+
- "**/Directory.Packages.props"
|
|
10
|
+
- "**/package.json"
|
|
11
|
+
- "**/tsconfig*.json"
|
|
12
|
+
---
|
|
13
|
+
<!-- cratis-ai: generated Copilot instructions. Do not edit; rules/ is the source. -->
|
|
14
|
+
|
|
15
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
16
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
17
|
+
|
|
18
|
+
# Application anatomy for growing systems
|
|
19
|
+
|
|
20
|
+
> **Application profile.** This is how the source tree of an application built on Cratis is shaped as it grows. It does **not** apply inside a Cratis framework repository (see [framework.md](./framework.instructions.md)). What goes in one behavior folder is [vertical-slices.md](./vertical-slices.instructions.md); the procedure for a move or a rename is the **cratis-application-growth** skill.
|
|
21
|
+
|
|
22
|
+
Lines are **[convention]** (house default; the framework does not check it) unless tagged **[contract]** (Arc, Chronicle or Fundamentals behave this way). Conventions hold only when the repository's own architecture gates enforce them; see *Gates* below.
|
|
23
|
+
|
|
24
|
+
An application's anatomy is a **path, not a choice made once.** Start at the smallest stage the product needs and grow when a signal says so. Skipping a stage is fine; building a later stage's structure before its signal appears is not.
|
|
25
|
+
|
|
26
|
+
## Words used here
|
|
27
|
+
|
|
28
|
+
- **Module**: one business capability (for example Billing or Support) with its own backend, frontend and specs.
|
|
29
|
+
- **Host**: the one project that composes and runs everything. Nothing references it.
|
|
30
|
+
- **Platform project**: code several modules need, or that no module owns. It never names a module.
|
|
31
|
+
- **Engine**: a platform project that holds reusable behavior with its own events and read models (a rules engine, a work queue). Modules plug into it; it knows no module.
|
|
32
|
+
- **Contracts project** (`<Module>.Contracts`): what a module lets others use: public events, grain or service interfaces, and the concepts they carry. No logic.
|
|
33
|
+
- **Seam**: a file that lives in one project's folder but is compiled into another project (a `<Compile Include="../Other/**" />`). It hides a dependency the project graph would reject.
|
|
34
|
+
|
|
35
|
+
## The stages
|
|
36
|
+
|
|
37
|
+
| Stage | Shape | What it buys |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| **1. One project** | One backend project and one frontend package; behaviors are `<Feature>/<Slice>/` folders. | Least ceremony; one build; cohesive slices. |
|
|
40
|
+
| **2. Modules in one project** | Features grouped under named top-level folders (`<Module>/<Feature>/<Slice>/`), still one backend project. | Names the capability boundaries before paying for project boundaries. |
|
|
41
|
+
| **3. Module projects on a platform** | Each module is its own backend project and frontend package, composed by the host, on platform projects. | The compiler enforces boundaries: a module cannot use what it does not reference. |
|
|
42
|
+
| **4. Modules publish contracts** | A module others need exposes `<Module>.Contracts`. No module references another module's project. | Modules change and are owned independently. |
|
|
43
|
+
|
|
44
|
+
Separately deployed services are a further step; see **cratis-multi-service-architecture**.
|
|
45
|
+
|
|
46
|
+
## When to move up
|
|
47
|
+
|
|
48
|
+
Move when a signal is present *now*, not when it is imaginable:
|
|
49
|
+
|
|
50
|
+
- **1 → 2:** people name a group of features as a capability; features share vocabulary no other feature uses; navigation, settings or access group by capability.
|
|
51
|
+
- **2 → 3:** a module needs separate build, specs or ownership; code reaches into another module's internals and the folder rule alone is not holding; a capability is gated by entitlement or audience and must be provably absent for others.
|
|
52
|
+
- **3 → 4:** one module needs to ask another a question or react to its events. Add the contract at the first such need.
|
|
53
|
+
|
|
54
|
+
**Start at stage 2 or 3** when the shape is already known: several teams, clearly separate capabilities, entitlement or audience gating, or a product line that will gain modules. A prototype, a single-purpose service or one team with one capability starts at stage 1.
|
|
55
|
+
|
|
56
|
+
## The layers and what may reference what (stages 3 and 4)
|
|
57
|
+
|
|
58
|
+
| Layer | Examples | May reference |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| Host | `Core` or `Host` | everything below; composes modules, integrations and engines |
|
|
61
|
+
| Modules | `Billing`, `Support` | other modules' `.Contracts`, engines' `.Contracts`, platform, Infrastructure, Components |
|
|
62
|
+
| Integration providers | `Integration.GitHub` | the `Integration` base and module `.Contracts` (ports) only |
|
|
63
|
+
| Engines and platform | `Notifications`, `Search`, `Integration`, `Mcp` | other platform `.Contracts`, Infrastructure, Components |
|
|
64
|
+
| Contracts | `Billing.Contracts`, `Tenancy.Contracts` | Infrastructure and other contracts only |
|
|
65
|
+
| Foundations | `Infrastructure`, `Components` | framework packages only; no domain concept, no module |
|
|
66
|
+
|
|
67
|
+
**References point down only.** If code compiles only with a reference that points up or sideways, the code is in the wrong project or the dependency must become a contract.
|
|
68
|
+
|
|
69
|
+
## Invariants at every stage
|
|
70
|
+
|
|
71
|
+
1. **Vertical slices.** The slice (command, events, projection, component, specs) is the unit at every stage. A stage changes what *groups* slices, never what a slice is. Never split by artifact type.
|
|
72
|
+
2. **No `InternalsVisibleTo`, no seams.** Both make a project boundary a folder name and nothing else. Code that needs either belongs in a lower project, or its dependency becomes a contract.
|
|
73
|
+
3. **No catch-all project.** A project named for its position rather than its purpose (`Global`, `Shared`, `Common`, `Base`) grows until it depends on the modules that depend on it. Every platform project has one purpose that its name states; a stage-1 `Common/` folder of concepts is fine.
|
|
74
|
+
4. **Every folder under the source root is a project or package with a `README.md`.** No loose code folders, no umbrella folders. The README states only what the code shows (template below).
|
|
75
|
+
5. **Specs live with their code** and are left out of analyzers and Release output by one shared pattern; see [fast-feedback.md](./fast-feedback.instructions.md).
|
|
76
|
+
6. **Namespaces follow projects and folders:** `<Company>.<Product>.<Project>.<folder path>`, so a namespace tells which project owns a type. That is the end state; while code is moving, namespaces stay put (see the next section). Project folders carry no product prefix (`Source/Billing`, not `Source/MyProduct.Billing`); the prefix lives in the root namespace, set once in `Directory.Build.props`.
|
|
77
|
+
7. **A namespace or assembly name is an identity, not a label.** See the next section before renaming either.
|
|
78
|
+
8. **Access is declared, never derived from a name.** Authorization, audience and admin-only rules sit on the code (an attribute, a policy, an assembly marker), never on a namespace prefix or folder; otherwise a rename silently changes who may read what.
|
|
79
|
+
|
|
80
|
+
## What a rename changes **[contract]**
|
|
81
|
+
|
|
82
|
+
| Identity | Derived from | Can it be pinned? |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| Chronicle event type id | the type's **simple name** (namespace-independent) | yes: `[EventType("id")]` |
|
|
85
|
+
| Reactor, reducer and projection ids | the type's **full name** | yes: an explicit id on the attribute |
|
|
86
|
+
| Read model identifier | the type's **full name** | no: stored identifiers are rewritten, or the read model rebuilds |
|
|
87
|
+
| Arc model-bound command and query routes | the **namespace** (minus `SegmentsToSkipForRoute`) | no: every caller and proxy follows the new route |
|
|
88
|
+
| Generated proxy folders | the **namespace** (minus `CratisProxiesSegmentsToSkip`) | no |
|
|
89
|
+
| Stored grain state type names and job type names | full type names; job names are assembly-qualified | keep `AssemblyName` when a project is renamed; retire old names deliberately |
|
|
90
|
+
| Anything your code keys on a name | authorization prefixes, OpenAPI filters, build strip lists, settings keys | replace with explicit declarations first |
|
|
91
|
+
|
|
92
|
+
Consequences:
|
|
93
|
+
|
|
94
|
+
- **Moving a file is free; renaming its namespace is a migration.** While the structure moves, keep namespaces and assembly names, and record every folder whose namespace no longer matches in an allowlist that only shrinks. One exception: a job type that moves to another assembly changes its assembly-qualified stored name, so rewrite the stored names (or keep a type forwarder in the old assembly) in the same release.
|
|
95
|
+
- **Rename namespaces once, in one window**, with a repair that rewrites the stored identities (observer ids, read model identifiers, grain and job type names) before the new version starts. Without it every observer registers under a new id and replays from the first event: projections rebuild and reactors act on history again. Chronicle's `ArtifactIdentityDrift` setting reports likely renames; it does not repair them.
|
|
96
|
+
- **Event types:** an explicit id or an unchanged class name keeps the identity across any namespace change. Changing an event deliberately is **cratis-chronicle-event-type-migration**; removing a project removes its event types, which is also an event-store change.
|
|
97
|
+
|
|
98
|
+
## Module anatomy (stages 3 and 4)
|
|
99
|
+
|
|
100
|
+
- **One module declaration.** A single type (for example an `IModule` implementation) states the module's key, display name and **audience** (everyone, an entitled subset, internal). The key is an identity; keep it when the module's name changes.
|
|
101
|
+
- **One backend project and one frontend package** per module, plus `<Module>.Contracts` when others need it.
|
|
102
|
+
- **The module contributes its surfaces by convention:** routes, navigation, settings sections, tools for an MCP server, API endpoints, rule packs. The base that hosts a surface discovers contributions (through `IInstancesOf<>` or the equivalent) and never names a module; no central route table or menu list.
|
|
103
|
+
- **Audience and entitlement are enforced on the server** (commands and queries), not only by hiding navigation.
|
|
104
|
+
- **Ask through an interface, be told through an event.** A question or request is a grain or service interface in the owner's contracts; "tell me when" is a public event. A module never uses another module's commands, read models, reactors or internal concepts.
|
|
105
|
+
- **Ports for providers.** When a module needs something an external provider supplies, the module defines the port in its contracts and each provider project implements it. A module never names a provider; adding a provider is adding a project.
|
|
106
|
+
- **Frontend boundaries mirror the backend:** a package imports another module's package only through its public entry point (no deep paths), never in both directions, and the shared components package imports no module. Each backend project generates its proxies into its own package and maps referenced projects with `AssemblyToPackageMapping`, so a type is generated by its owner only.
|
|
107
|
+
- **Wiring is by convention:** the default `IFoo` → `Foo` binding and lifetime attributes. **[contract]** The convention binds only when the interface and its single implementation share a namespace, and it fills only service types nobody registered. An interface in `<Module>.Contracts` with its implementation in the module therefore needs an explicit (or generated) registration, applied after the explicit ones.
|
|
108
|
+
|
|
109
|
+
### README template
|
|
110
|
+
|
|
111
|
+
```markdown
|
|
112
|
+
# <Project or package>
|
|
113
|
+
|
|
114
|
+
<One paragraph: what it is for and who uses it.>
|
|
115
|
+
|
|
116
|
+
## Owns
|
|
117
|
+
- Namespaces and, for a module: its key and audience.
|
|
118
|
+
|
|
119
|
+
## Exposes
|
|
120
|
+
- Contracts, routes, settings sections and other contributions others may rely on.
|
|
121
|
+
|
|
122
|
+
## Depends on
|
|
123
|
+
- Project references and packages it imports, and why.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Gates
|
|
127
|
+
|
|
128
|
+
Prose does not hold a boundary; gates do. Write them as ordinary specs that read the project files and sources, so they run in the normal spec pass in seconds:
|
|
129
|
+
|
|
130
|
+
- no `InternalsVisibleTo` and no seam (no `Compile Include` reaching outside the project folder);
|
|
131
|
+
- only the host references a module project; nothing references the host;
|
|
132
|
+
- platform and Infrastructure name no module and no domain concept; a module names no integration provider;
|
|
133
|
+
- every source folder has a project or package and a `README.md`;
|
|
134
|
+
- namespace matches folder, except allowlisted entries;
|
|
135
|
+
- frontend: no two-way package imports, no deep imports past a package's entry point, the components package imports no module (an ESLint rule).
|
|
136
|
+
|
|
137
|
+
Each gate compares against a committed baseline that **only shrinks**. A change that removes coupling shrinks the baseline in the same commit; a change that grows it fails. Never raise a baseline to land a change. Count dependencies from project files or compiled assemblies, not `using` lines.
|
|
138
|
+
|
|
139
|
+
## See also
|
|
140
|
+
|
|
141
|
+
- **cratis-application-growth**: the procedure for each move and for the rename window.
|
|
142
|
+
- [vertical-slices.md](./vertical-slices.instructions.md), [application-profile.md](./application-profile.instructions.md), [react.md](./react.instructions.md), [components.md](./components.instructions.md).
|
|
143
|
+
- **cratis-multi-service-architecture**: when modules become separately deployed services.
|
|
@@ -24,7 +24,7 @@ profile: application
|
|
|
24
24
|
|
|
25
25
|
## Project Layout (Cratis Application convention)
|
|
26
26
|
|
|
27
|
-
The framework discovers commands and read models by attributes and static methods — **the folder shape is a convention, not a requirement.** The house default: the domain hierarchy lives directly under the app source root (**no top-level `Features/` wrapper**), cross-cutting concerns (`Common/` concepts, `Identity/`, shared components) at the top level, and one folder per behavior — `<Module>/<Feature>/<Slice>/` holding `<Slice>.cs`, the slice's `.tsx`, and its `when_*/` specs. **The slice is the invariant unit** — created, renamed, and deleted as one. Namespace mirrors the path under the source root, dropping any level that isn't present. The full tree and the split rules are in [vertical-slices.md](./vertical-slices.instructions.md).
|
|
27
|
+
The framework discovers commands and read models by attributes and static methods — **the folder shape is a convention, not a requirement.** The house default: the domain hierarchy lives directly under the app source root (**no top-level `Features/` wrapper**), cross-cutting concerns (`Common/` concepts, `Identity/`, shared components) at the top level, and one folder per behavior — `<Module>/<Feature>/<Slice>/` holding `<Slice>.cs`, the slice's `.tsx`, and its `when_*/` specs. **The slice is the invariant unit** — created, renamed, and deleted as one. Namespace mirrors the path under the source root, dropping any level that isn't present; once modules are their own projects it is `<Company>.<Product>.<Project>.<folder path>`, and renaming a namespace changes stored identities and routes (see [application-anatomy.md](./application-anatomy.instructions.md)). The full tree and the split rules are in [vertical-slices.md](./vertical-slices.instructions.md).
|
|
28
28
|
|
|
29
29
|
## Slice Types
|
|
30
30
|
|
|
@@ -15,6 +15,8 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
15
15
|
|
|
16
16
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](../../../rules/general.md).
|
|
17
17
|
|
|
18
|
+
**In an application split into module projects**, a slice lives in the module that owns its behavior and uses another module only through that module's `.Contracts` project (an interface to ask, a public event to be told), never its commands, read models or project. Never add `InternalsVisibleTo` or compile a file into another project to make it build; [application-anatomy.md](./application-anatomy.instructions.md) has the layers and why a namespace is an identity.
|
|
19
|
+
|
|
18
20
|
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.instructions.md).
|
|
19
21
|
|
|
20
22
|
## Technical stack
|
|
@@ -449,6 +451,7 @@ Frontend commands run through the Cratis dialogs — never a vendor or hand-roll
|
|
|
449
451
|
## See also
|
|
450
452
|
|
|
451
453
|
- [general.md](../../../rules/general.md) — layout, slice types, workflow, quality gates.
|
|
454
|
+
- [application-anatomy.md](./application-anatomy.instructions.md) — how the source tree grows from one project to modules and contracts; the slice stays the unit.
|
|
452
455
|
- [concepts.md](./concepts.instructions.md) — `ConceptAs<T>` / `EventSourceId<T>` full patterns.
|
|
453
456
|
- [reactors.md](./reactors.instructions.md) — reactor signatures and side-effect rules.
|
|
454
457
|
- [specs.md](./specs.instructions.md) — `CommandScenario` / `EventScenario` / `ReadModelScenario` / `ReactorScenario`.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*.csproj,**/*.slnx,**/Directory.Build.props,**/Directory.Build.targets,**/Directory.Packages.props,**/package.json,**/tsconfig*.json"
|
|
3
|
+
profile: application
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*.csproj"
|
|
6
|
+
- "**/*.slnx"
|
|
7
|
+
- "**/Directory.Build.props"
|
|
8
|
+
- "**/Directory.Build.targets"
|
|
9
|
+
- "**/Directory.Packages.props"
|
|
10
|
+
- "**/package.json"
|
|
11
|
+
- "**/tsconfig*.json"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
15
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
16
|
+
|
|
17
|
+
# Application anatomy for growing systems
|
|
18
|
+
|
|
19
|
+
> **Application profile.** This is how the source tree of an application built on Cratis is shaped as it grows. It does **not** apply inside a Cratis framework repository (see [framework.md](./framework.md)). What goes in one behavior folder is [vertical-slices.md](./vertical-slices.md); the procedure for a move or a rename is the **cratis-application-growth** skill.
|
|
20
|
+
|
|
21
|
+
Lines are **[convention]** (house default; the framework does not check it) unless tagged **[contract]** (Arc, Chronicle or Fundamentals behave this way). Conventions hold only when the repository's own architecture gates enforce them; see *Gates* below.
|
|
22
|
+
|
|
23
|
+
An application's anatomy is a **path, not a choice made once.** Start at the smallest stage the product needs and grow when a signal says so. Skipping a stage is fine; building a later stage's structure before its signal appears is not.
|
|
24
|
+
|
|
25
|
+
## Words used here
|
|
26
|
+
|
|
27
|
+
- **Module**: one business capability (for example Billing or Support) with its own backend, frontend and specs.
|
|
28
|
+
- **Host**: the one project that composes and runs everything. Nothing references it.
|
|
29
|
+
- **Platform project**: code several modules need, or that no module owns. It never names a module.
|
|
30
|
+
- **Engine**: a platform project that holds reusable behavior with its own events and read models (a rules engine, a work queue). Modules plug into it; it knows no module.
|
|
31
|
+
- **Contracts project** (`<Module>.Contracts`): what a module lets others use: public events, grain or service interfaces, and the concepts they carry. No logic.
|
|
32
|
+
- **Seam**: a file that lives in one project's folder but is compiled into another project (a `<Compile Include="../Other/**" />`). It hides a dependency the project graph would reject.
|
|
33
|
+
|
|
34
|
+
## The stages
|
|
35
|
+
|
|
36
|
+
| Stage | Shape | What it buys |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| **1. One project** | One backend project and one frontend package; behaviors are `<Feature>/<Slice>/` folders. | Least ceremony; one build; cohesive slices. |
|
|
39
|
+
| **2. Modules in one project** | Features grouped under named top-level folders (`<Module>/<Feature>/<Slice>/`), still one backend project. | Names the capability boundaries before paying for project boundaries. |
|
|
40
|
+
| **3. Module projects on a platform** | Each module is its own backend project and frontend package, composed by the host, on platform projects. | The compiler enforces boundaries: a module cannot use what it does not reference. |
|
|
41
|
+
| **4. Modules publish contracts** | A module others need exposes `<Module>.Contracts`. No module references another module's project. | Modules change and are owned independently. |
|
|
42
|
+
|
|
43
|
+
Separately deployed services are a further step; see **cratis-multi-service-architecture**.
|
|
44
|
+
|
|
45
|
+
## When to move up
|
|
46
|
+
|
|
47
|
+
Move when a signal is present *now*, not when it is imaginable:
|
|
48
|
+
|
|
49
|
+
- **1 → 2:** people name a group of features as a capability; features share vocabulary no other feature uses; navigation, settings or access group by capability.
|
|
50
|
+
- **2 → 3:** a module needs separate build, specs or ownership; code reaches into another module's internals and the folder rule alone is not holding; a capability is gated by entitlement or audience and must be provably absent for others.
|
|
51
|
+
- **3 → 4:** one module needs to ask another a question or react to its events. Add the contract at the first such need.
|
|
52
|
+
|
|
53
|
+
**Start at stage 2 or 3** when the shape is already known: several teams, clearly separate capabilities, entitlement or audience gating, or a product line that will gain modules. A prototype, a single-purpose service or one team with one capability starts at stage 1.
|
|
54
|
+
|
|
55
|
+
## The layers and what may reference what (stages 3 and 4)
|
|
56
|
+
|
|
57
|
+
| Layer | Examples | May reference |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| Host | `Core` or `Host` | everything below; composes modules, integrations and engines |
|
|
60
|
+
| Modules | `Billing`, `Support` | other modules' `.Contracts`, engines' `.Contracts`, platform, Infrastructure, Components |
|
|
61
|
+
| Integration providers | `Integration.GitHub` | the `Integration` base and module `.Contracts` (ports) only |
|
|
62
|
+
| Engines and platform | `Notifications`, `Search`, `Integration`, `Mcp` | other platform `.Contracts`, Infrastructure, Components |
|
|
63
|
+
| Contracts | `Billing.Contracts`, `Tenancy.Contracts` | Infrastructure and other contracts only |
|
|
64
|
+
| Foundations | `Infrastructure`, `Components` | framework packages only; no domain concept, no module |
|
|
65
|
+
|
|
66
|
+
**References point down only.** If code compiles only with a reference that points up or sideways, the code is in the wrong project or the dependency must become a contract.
|
|
67
|
+
|
|
68
|
+
## Invariants at every stage
|
|
69
|
+
|
|
70
|
+
1. **Vertical slices.** The slice (command, events, projection, component, specs) is the unit at every stage. A stage changes what *groups* slices, never what a slice is. Never split by artifact type.
|
|
71
|
+
2. **No `InternalsVisibleTo`, no seams.** Both make a project boundary a folder name and nothing else. Code that needs either belongs in a lower project, or its dependency becomes a contract.
|
|
72
|
+
3. **No catch-all project.** A project named for its position rather than its purpose (`Global`, `Shared`, `Common`, `Base`) grows until it depends on the modules that depend on it. Every platform project has one purpose that its name states; a stage-1 `Common/` folder of concepts is fine.
|
|
73
|
+
4. **Every folder under the source root is a project or package with a `README.md`.** No loose code folders, no umbrella folders. The README states only what the code shows (template below).
|
|
74
|
+
5. **Specs live with their code** and are left out of analyzers and Release output by one shared pattern; see [fast-feedback.md](./fast-feedback.md).
|
|
75
|
+
6. **Namespaces follow projects and folders:** `<Company>.<Product>.<Project>.<folder path>`, so a namespace tells which project owns a type. That is the end state; while code is moving, namespaces stay put (see the next section). Project folders carry no product prefix (`Source/Billing`, not `Source/MyProduct.Billing`); the prefix lives in the root namespace, set once in `Directory.Build.props`.
|
|
76
|
+
7. **A namespace or assembly name is an identity, not a label.** See the next section before renaming either.
|
|
77
|
+
8. **Access is declared, never derived from a name.** Authorization, audience and admin-only rules sit on the code (an attribute, a policy, an assembly marker), never on a namespace prefix or folder; otherwise a rename silently changes who may read what.
|
|
78
|
+
|
|
79
|
+
## What a rename changes **[contract]**
|
|
80
|
+
|
|
81
|
+
| Identity | Derived from | Can it be pinned? |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| Chronicle event type id | the type's **simple name** (namespace-independent) | yes: `[EventType("id")]` |
|
|
84
|
+
| Reactor, reducer and projection ids | the type's **full name** | yes: an explicit id on the attribute |
|
|
85
|
+
| Read model identifier | the type's **full name** | no: stored identifiers are rewritten, or the read model rebuilds |
|
|
86
|
+
| Arc model-bound command and query routes | the **namespace** (minus `SegmentsToSkipForRoute`) | no: every caller and proxy follows the new route |
|
|
87
|
+
| Generated proxy folders | the **namespace** (minus `CratisProxiesSegmentsToSkip`) | no |
|
|
88
|
+
| Stored grain state type names and job type names | full type names; job names are assembly-qualified | keep `AssemblyName` when a project is renamed; retire old names deliberately |
|
|
89
|
+
| Anything your code keys on a name | authorization prefixes, OpenAPI filters, build strip lists, settings keys | replace with explicit declarations first |
|
|
90
|
+
|
|
91
|
+
Consequences:
|
|
92
|
+
|
|
93
|
+
- **Moving a file is free; renaming its namespace is a migration.** While the structure moves, keep namespaces and assembly names, and record every folder whose namespace no longer matches in an allowlist that only shrinks. One exception: a job type that moves to another assembly changes its assembly-qualified stored name, so rewrite the stored names (or keep a type forwarder in the old assembly) in the same release.
|
|
94
|
+
- **Rename namespaces once, in one window**, with a repair that rewrites the stored identities (observer ids, read model identifiers, grain and job type names) before the new version starts. Without it every observer registers under a new id and replays from the first event: projections rebuild and reactors act on history again. Chronicle's `ArtifactIdentityDrift` setting reports likely renames; it does not repair them.
|
|
95
|
+
- **Event types:** an explicit id or an unchanged class name keeps the identity across any namespace change. Changing an event deliberately is **cratis-chronicle-event-type-migration**; removing a project removes its event types, which is also an event-store change.
|
|
96
|
+
|
|
97
|
+
## Module anatomy (stages 3 and 4)
|
|
98
|
+
|
|
99
|
+
- **One module declaration.** A single type (for example an `IModule` implementation) states the module's key, display name and **audience** (everyone, an entitled subset, internal). The key is an identity; keep it when the module's name changes.
|
|
100
|
+
- **One backend project and one frontend package** per module, plus `<Module>.Contracts` when others need it.
|
|
101
|
+
- **The module contributes its surfaces by convention:** routes, navigation, settings sections, tools for an MCP server, API endpoints, rule packs. The base that hosts a surface discovers contributions (through `IInstancesOf<>` or the equivalent) and never names a module; no central route table or menu list.
|
|
102
|
+
- **Audience and entitlement are enforced on the server** (commands and queries), not only by hiding navigation.
|
|
103
|
+
- **Ask through an interface, be told through an event.** A question or request is a grain or service interface in the owner's contracts; "tell me when" is a public event. A module never uses another module's commands, read models, reactors or internal concepts.
|
|
104
|
+
- **Ports for providers.** When a module needs something an external provider supplies, the module defines the port in its contracts and each provider project implements it. A module never names a provider; adding a provider is adding a project.
|
|
105
|
+
- **Frontend boundaries mirror the backend:** a package imports another module's package only through its public entry point (no deep paths), never in both directions, and the shared components package imports no module. Each backend project generates its proxies into its own package and maps referenced projects with `AssemblyToPackageMapping`, so a type is generated by its owner only.
|
|
106
|
+
- **Wiring is by convention:** the default `IFoo` → `Foo` binding and lifetime attributes. **[contract]** The convention binds only when the interface and its single implementation share a namespace, and it fills only service types nobody registered. An interface in `<Module>.Contracts` with its implementation in the module therefore needs an explicit (or generated) registration, applied after the explicit ones.
|
|
107
|
+
|
|
108
|
+
### README template
|
|
109
|
+
|
|
110
|
+
```markdown
|
|
111
|
+
# <Project or package>
|
|
112
|
+
|
|
113
|
+
<One paragraph: what it is for and who uses it.>
|
|
114
|
+
|
|
115
|
+
## Owns
|
|
116
|
+
- Namespaces and, for a module: its key and audience.
|
|
117
|
+
|
|
118
|
+
## Exposes
|
|
119
|
+
- Contracts, routes, settings sections and other contributions others may rely on.
|
|
120
|
+
|
|
121
|
+
## Depends on
|
|
122
|
+
- Project references and packages it imports, and why.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Gates
|
|
126
|
+
|
|
127
|
+
Prose does not hold a boundary; gates do. Write them as ordinary specs that read the project files and sources, so they run in the normal spec pass in seconds:
|
|
128
|
+
|
|
129
|
+
- no `InternalsVisibleTo` and no seam (no `Compile Include` reaching outside the project folder);
|
|
130
|
+
- only the host references a module project; nothing references the host;
|
|
131
|
+
- platform and Infrastructure name no module and no domain concept; a module names no integration provider;
|
|
132
|
+
- every source folder has a project or package and a `README.md`;
|
|
133
|
+
- namespace matches folder, except allowlisted entries;
|
|
134
|
+
- frontend: no two-way package imports, no deep imports past a package's entry point, the components package imports no module (an ESLint rule).
|
|
135
|
+
|
|
136
|
+
Each gate compares against a committed baseline that **only shrinks**. A change that removes coupling shrinks the baseline in the same commit; a change that grows it fails. Never raise a baseline to land a change. Count dependencies from project files or compiled assemblies, not `using` lines.
|
|
137
|
+
|
|
138
|
+
## See also
|
|
139
|
+
|
|
140
|
+
- **cratis-application-growth**: the procedure for each move and for the rename window.
|
|
141
|
+
- [vertical-slices.md](./vertical-slices.md), [application-profile.md](./application-profile.md), [react.md](./react.md), [components.md](./components.md).
|
|
142
|
+
- **cratis-multi-service-architecture**: when modules become separately deployed services.
|
|
@@ -23,7 +23,7 @@ profile: application
|
|
|
23
23
|
|
|
24
24
|
## Project Layout (Cratis Application convention)
|
|
25
25
|
|
|
26
|
-
The framework discovers commands and read models by attributes and static methods — **the folder shape is a convention, not a requirement.** The house default: the domain hierarchy lives directly under the app source root (**no top-level `Features/` wrapper**), cross-cutting concerns (`Common/` concepts, `Identity/`, shared components) at the top level, and one folder per behavior — `<Module>/<Feature>/<Slice>/` holding `<Slice>.cs`, the slice's `.tsx`, and its `when_*/` specs. **The slice is the invariant unit** — created, renamed, and deleted as one. Namespace mirrors the path under the source root, dropping any level that isn't present. The full tree and the split rules are in [vertical-slices.md](./vertical-slices.md).
|
|
26
|
+
The framework discovers commands and read models by attributes and static methods — **the folder shape is a convention, not a requirement.** The house default: the domain hierarchy lives directly under the app source root (**no top-level `Features/` wrapper**), cross-cutting concerns (`Common/` concepts, `Identity/`, shared components) at the top level, and one folder per behavior — `<Module>/<Feature>/<Slice>/` holding `<Slice>.cs`, the slice's `.tsx`, and its `when_*/` specs. **The slice is the invariant unit** — created, renamed, and deleted as one. Namespace mirrors the path under the source root, dropping any level that isn't present; once modules are their own projects it is `<Company>.<Product>.<Project>.<folder path>`, and renaming a namespace changes stored identities and routes (see [application-anatomy.md](./application-anatomy.md)). The full tree and the split rules are in [vertical-slices.md](./vertical-slices.md).
|
|
27
27
|
|
|
28
28
|
## Slice Types
|
|
29
29
|
|
|
@@ -35,7 +35,7 @@ When these instructions don't cover a situation, apply these values to make the
|
|
|
35
35
|
Every rule below is one of three kinds — know which, because they carry different weight:
|
|
36
36
|
|
|
37
37
|
- **Framework contract** — enforced by Arc/Chronicle source, analyzers, or runtime. Violating it breaks the build or behaves wrongly. (e.g. `[Command]` needs a public instance `Handle()`; model-bound queries are static methods on `[ReadModel]`; nullable event properties raise a Chronicle analyzer warning.)
|
|
38
|
-
- **Cratis Application convention** — the house default for maintainability and consistent generated code. The framework does **not** enforce it, but follow it for consistency. (e.g.
|
|
38
|
+
- **Cratis Application convention** — the house default for maintainability and consistent generated code. The framework does **not** enforce it, but follow it for consistency. (e.g. slice folder shape, declaration order.)
|
|
39
39
|
- **Product policy** — belongs in a downstream app's own `.cratis/ai/`, not this generic corpus. (e.g. specific roles, locales, design systems.)
|
|
40
40
|
|
|
41
41
|
Where a rule is convention rather than contract, this file says so. Do not claim "the framework requires this" for a convention.
|
|
@@ -126,7 +126,7 @@ Verify claims with build, spec, lint or observed-behavior signals, not confidenc
|
|
|
126
126
|
| --- | --- |
|
|
127
127
|
| Corpus profiles and configuration | `profiles.md` |
|
|
128
128
|
| **Contributing to a Cratis framework repo** (framework profile) | `framework.md`; creating a repository in the Cratis organization: `new-repository-intake.md` |
|
|
129
|
-
| Slice anatomy (commands, `Provide()`, validators, events, projections, read models, reactors, constraints, compliance, cross-slice) | `vertical-slices.md` |
|
|
129
|
+
| Slice anatomy (commands, `Provide()`, validators, events, projections, read models, reactors, constraints, compliance, cross-slice) | `vertical-slices.md`; modules, renames: `application-anatomy.md` |
|
|
130
130
|
| C# / TypeScript style and code-quality principles | `csharp.md`, `typescript.md`, `code-quality.md`, `code-quality.csharp.md`, `code-quality.typescript.md` |
|
|
131
131
|
| Kotlin / Java / Elixir style; Orleans grains; reactors; GitHub Actions workflows | `kotlin.md`, `java.md`, `elixir.md`, `orleans.md`, `reactors.md`, `github-actions.md` |
|
|
132
132
|
| Documentation structure, voice and examples | `documentation.md`, `documentation-structure-and-formatting.md`, `writing-cratis-docs.md`, `editing-cratis-docs.md`, `writing-correct-examples.md` |
|
|
@@ -14,6 +14,8 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
14
14
|
|
|
15
15
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](./general.md).
|
|
16
16
|
|
|
17
|
+
**In an application split into module projects**, a slice lives in the module that owns its behavior and uses another module only through that module's `.Contracts` project (an interface to ask, a public event to be told), never its commands, read models or project. Never add `InternalsVisibleTo` or compile a file into another project to make it build; [application-anatomy.md](./application-anatomy.md) has the layers and why a namespace is an identity.
|
|
18
|
+
|
|
17
19
|
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.md).
|
|
18
20
|
|
|
19
21
|
## Technical stack
|
|
@@ -448,6 +450,7 @@ Frontend commands run through the Cratis dialogs — never a vendor or hand-roll
|
|
|
448
450
|
## See also
|
|
449
451
|
|
|
450
452
|
- [general.md](./general.md) — layout, slice types, workflow, quality gates.
|
|
453
|
+
- [application-anatomy.md](./application-anatomy.md) — how the source tree grows from one project to modules and contracts; the slice stays the unit.
|
|
451
454
|
- [concepts.md](./concepts.md) — `ConceptAs<T>` / `EventSourceId<T>` full patterns.
|
|
452
455
|
- [reactors.md](./reactors.md) — reactor signatures and side-effect rules.
|
|
453
456
|
- [specs.md](./specs.md) — `CommandScenario` / `EventScenario` / `ReadModelScenario` / `ReactorScenario`.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cratis-application-growth
|
|
3
|
+
description: Use when a Cratis application's source tree must grow from one project into modules or module projects, untangle a catch-all project, rename namespaces after moves, or decide whether a new application starts modular. Not for service splits (cratis-multi-service-architecture) or one slice's contents.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
8
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
9
|
+
|
|
10
|
+
# Grow an application's anatomy
|
|
11
|
+
|
|
12
|
+
The stages, layers, invariants and identity table are the rule
|
|
13
|
+
[application-anatomy.md](../../rules/application-anatomy.md); read it first. This skill is the
|
|
14
|
+
procedure. The slice stays the unit throughout ([vertical-slices.md](../../rules/vertical-slices.md)).
|
|
15
|
+
|
|
16
|
+
The order is fixed: **decide, guard, move, untangle, rename, verify.** Each phase is done when its
|
|
17
|
+
check passes; do not start the next one before.
|
|
18
|
+
|
|
19
|
+
## 1. Decide
|
|
20
|
+
|
|
21
|
+
1. Name the current stage and the signal that justifies the next, in the rule's terms. No signal, no move.
|
|
22
|
+
2. A new application starts at stage 2 or 3 only for a rule-listed reason; otherwise stage 1.
|
|
23
|
+
3. Read the accepted decision records that describe the current structure. If the target contradicts one,
|
|
24
|
+
write the superseding record first (**cratis-engineering-decision-record**); a record binds until then.
|
|
25
|
+
4. Write down the target: the modules, the platform projects (each with one stated purpose), and
|
|
26
|
+
where every existing project goes.
|
|
27
|
+
|
|
28
|
+
Done when: the target is written and no accepted record contradicts it.
|
|
29
|
+
|
|
30
|
+
## 2. Guard before moving
|
|
31
|
+
|
|
32
|
+
1. Add the architecture gates from the rule's *Gates* section as specs, in a project of their own.
|
|
33
|
+
2. Record the current numbers as committed baselines: seams, `InternalsVisibleTo` grants, references between
|
|
34
|
+
modules, platform-to-module references, folders without project or README, namespace/folder
|
|
35
|
+
mismatches, frontend boundary violations.
|
|
36
|
+
3. Each gate fails when its baseline grows and asks for the baseline to shrink when coupling is removed.
|
|
37
|
+
|
|
38
|
+
Done when: the gates run in the normal spec pass and fail on a planted violation (add one grant, see red, remove it).
|
|
39
|
+
|
|
40
|
+
## 3. Move, and only move
|
|
41
|
+
|
|
42
|
+
Keep namespaces and assembly names while moving; moving a file changes no identity, a namespace change
|
|
43
|
+
does (rule, *What a rename changes*).
|
|
44
|
+
|
|
45
|
+
| Move | Steps (each a separate commit; build and run specs after each) |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| **1 → 2** | Create the module folder, `git mv` the related feature folders under it, add its `README.md`. |
|
|
48
|
+
| **2 → 3** | Create the module project and frontend package; `git mv` the module folder into them; reference only what the rule's layer table allows. Add the module declaration and register its routes, navigation and settings by convention. |
|
|
49
|
+
| **3 → 4** | At the first cross-module need, create `<Module>.Contracts` in the owning module and point the consumer at it. Replace the direct reference; never keep both. |
|
|
50
|
+
|
|
51
|
+
- `git mv` for files; no behavior change, rename or refactor in a move commit.
|
|
52
|
+
- When a project is renamed and stored names are assembly-qualified, keep its `AssemblyName`.
|
|
53
|
+
- A folder whose namespace no longer matches goes into the namespace allowlist until the rename window.
|
|
54
|
+
- Never add `InternalsVisibleTo` or a seam to make a move compile. A move that would need one waits
|
|
55
|
+
until step 4 has replaced the dependency.
|
|
56
|
+
- Large reshapes split into lanes: one worktree and branch per module or engine, each owning disjoint
|
|
57
|
+
folders, merged into one integration branch. Re-run every gate after each merge; when two lanes both
|
|
58
|
+
shrank a baseline, record the merged value, never the larger one.
|
|
59
|
+
|
|
60
|
+
Done when: build, specs and gates pass and every baseline is equal or smaller.
|
|
61
|
+
|
|
62
|
+
## 4. Untangle
|
|
63
|
+
|
|
64
|
+
For each dependency that points up or sideways, pick one fix:
|
|
65
|
+
|
|
66
|
+
| The dependency is | Fix |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| A question or request to another module | Grain or service interface in the owner's `.Contracts` |
|
|
69
|
+
| "Tell me when" | Public event in the owner's `.Contracts`; the consumer reacts |
|
|
70
|
+
| A module needing an external provider | Port in the module's `.Contracts`; each `Integration.<Provider>` project implements it |
|
|
71
|
+
| Platform code that knows a module | Discovery interface in the platform; the module implements it |
|
|
72
|
+
| Technical code with no domain | Move it to Infrastructure (or Components for UI) |
|
|
73
|
+
|
|
74
|
+
**Dissolving a catch-all project** (`Global`, `Shared`, `Common`): measure what other projects actually
|
|
75
|
+
import from it, folder by folder. Each cluster that several modules use becomes a platform project with
|
|
76
|
+
one purpose (shell and tenancy into the host or a `Tenancy.Contracts`, an engine into its own project
|
|
77
|
+
with contracts); everything else moves into the module that owns it. Delete the project when it is empty.
|
|
78
|
+
|
|
79
|
+
**Retiring a project that owns event types** removes those types: their stored events and registrations
|
|
80
|
+
need an event-store plan (**cratis-chronicle-event-type-migration**) before the project goes.
|
|
81
|
+
|
|
82
|
+
Done when: the seam baseline and the module-reference baseline reach zero.
|
|
83
|
+
|
|
84
|
+
## 5. Rename window
|
|
85
|
+
|
|
86
|
+
Rename namespaces to `<Company>.<Product>.<Project>.<folder path>` **once**, after the moves, as a
|
|
87
|
+
production rollout. Read [references/rename-window.md](references/rename-window.md) before starting it.
|
|
88
|
+
|
|
89
|
+
Done when: the namespace allowlist is empty and the stored-identity repair has passed its dry run and tests.
|
|
90
|
+
|
|
91
|
+
## 6. Verify
|
|
92
|
+
|
|
93
|
+
Run one phase at a time, each exiting 0 (use the repository's script names):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
dotnet build
|
|
97
|
+
dotnet test
|
|
98
|
+
yarn tsc --noEmit
|
|
99
|
+
yarn lint
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Then boot the host and drive it end to end (integration specs over HTTP, then a walk of every screen).
|
|
103
|
+
Unit specs construct types directly; they do not see DI registration order, routes, generated proxies or
|
|
104
|
+
name-scoped filters, which is where structural changes break. Say which phases were not run.
|
|
105
|
+
|
|
106
|
+
## Pitfalls
|
|
107
|
+
|
|
108
|
+
| Symptom | Cause | Fix |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| Observers replay from the start, side effects repeat | A namespace or type name changed an observer identity | Pin the id, or repair stored identities before starting the new version |
|
|
111
|
+
| `IFoo` not resolved, or the wrong implementation wins | Interface moved to `.Contracts`, so the same-namespace convention no longer binds; or extra bindings ran before explicit registrations | Register the pair explicitly; apply generated bindings once, after all explicit ones |
|
|
112
|
+
| 404 from the frontend or a script after a rename | Arc routes follow the namespace | Regenerate proxies; replace hard-coded routes; update reverse-proxy rewrites |
|
|
113
|
+
| A generated proxy lost members after a split | A project that only references a type emitted a copy over the owner's proxy | Generate each project into its own package; map referenced assemblies with `AssemblyToPackageMapping` (**cratis-arc-command**, proxy generation) |
|
|
114
|
+
| API docs, authorization or Release stripping silently stopped applying | Code keyed on a namespace or path | Replace name keys with explicit declarations or one shared pattern |
|
|
115
|
+
| Stored jobs fail to resume after a project rename or a move | Job type names are assembly-qualified | Keep `AssemblyName`; for a job type moved to another assembly, rewrite the stored names or leave a type forwarder |
|
|
116
|
+
| Module B does not compile without module A's internals | Hidden coupling | Contract or lower project; never `InternalsVisibleTo` |
|
|
117
|
+
| Gate baseline keeps growing | Moving and refactoring in one step | Split the commit; fix the dependency, not the baseline |
|
|
118
|
+
|
|
119
|
+
## Related
|
|
120
|
+
|
|
121
|
+
- **cratis-multi-service-architecture**: modules deployed as separate services.
|
|
122
|
+
- **cratis-chronicle-event-type-migration**: deliberate event identity or schema changes.
|
|
123
|
+
- **cratis-engineering-decision-record**: superseding the structure's accepted records.
|
|
124
|
+
- **cratis-application-slice-conformance**: a slice against its model after a move.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# The namespace rename window
|
|
5
|
+
|
|
6
|
+
A namespace rename is a change to stored identities, so it ships as one production rollout with a
|
|
7
|
+
repair, once, after the structural moves. The identity table is in
|
|
8
|
+
[application-anatomy.md](../../../rules/application-anatomy.md) (*What a rename changes*).
|
|
9
|
+
|
|
10
|
+
## 1. Prepare the code
|
|
11
|
+
|
|
12
|
+
1. **Replace name keys first, in their own commit:** authorization or audience rules keyed on a namespace
|
|
13
|
+
prefix become explicit markers (an attribute, an assembly-level marker, a policy); OpenAPI or filter
|
|
14
|
+
registrations scoped to one namespace take an explicit list; build steps that strip or include files by
|
|
15
|
+
path use one shared pattern. Add a spec that lists what each marker covers, so a later rename cannot
|
|
16
|
+
widen access unnoticed.
|
|
17
|
+
2. **Pin what can be pinned:** event types without an explicit id keep theirs while the class name stays.
|
|
18
|
+
Pin an observer id only when its stored state must survive and you will not repair it.
|
|
19
|
+
3. **Rename:** project folders lose the product prefix, every namespace becomes
|
|
20
|
+
`<Company>.<Product>.<Project>.<folder path>`, and `AssemblyName` stays unless the stored names are
|
|
21
|
+
repaired too. Set Arc's `SegmentsToSkipForRoute` (and `CratisProxiesSegmentsToSkip`) to the length of the
|
|
22
|
+
new prefix so routes and proxy folders do not grow it.
|
|
23
|
+
4. **Regenerate** every proxy, then search specs, scripts, documentation and reverse-proxy rewrites for
|
|
24
|
+
literal routes and compare each with the generated ones.
|
|
25
|
+
5. **Bindings:** interface/implementation pairs that no longer share a namespace get an explicit or
|
|
26
|
+
generated registration, applied after every explicit registration.
|
|
27
|
+
|
|
28
|
+
## 2. Build the repair
|
|
29
|
+
|
|
30
|
+
The repair renames stored identities from old full names to new ones before the new version starts:
|
|
31
|
+
|
|
32
|
+
| Stored identity | Typical location |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| Reactor, reducer and projection ids, observer state, failed partitions, replay state | the event store's system and per-namespace collections |
|
|
35
|
+
| Read model identifiers and definitions | the same collections; read model collections keep their names |
|
|
36
|
+
| Grain state type names | the Orleans storage |
|
|
37
|
+
| Job, job step and request type names | job storage |
|
|
38
|
+
|
|
39
|
+
Event types, events and read model content do not change.
|
|
40
|
+
|
|
41
|
+
The repair is a script with:
|
|
42
|
+
|
|
43
|
+
- a **mapping** generated from the old and new type catalogs, not typed by hand;
|
|
44
|
+
- a **test** that every changed identity maps to its new value and that pinned ids are untouched;
|
|
45
|
+
- a **dry run** that prints counts per collection, and a fuse that refuses to write above an expected count;
|
|
46
|
+
- **idempotence**: a second run changes nothing (prove it against a planted database);
|
|
47
|
+
- credentials read from an environment variable, never from the command line.
|
|
48
|
+
|
|
49
|
+
## 3. Run the window
|
|
50
|
+
|
|
51
|
+
1. Merge and publish the release; do not let it start against unrepaired storage.
|
|
52
|
+
2. Scale the application to zero, back up the affected collections, run the dry runs and compare their
|
|
53
|
+
counts with the expected ones.
|
|
54
|
+
3. Apply the repair, clear any cached registrations the event store kernel holds (restart it when it caches
|
|
55
|
+
them), then start the new version.
|
|
56
|
+
4. Check: no observer registered under a new id from position zero, no identity-drift warnings, every
|
|
57
|
+
screen loads, stored jobs resume.
|
|
58
|
+
|
|
59
|
+
Rollback is the backup plus the previous release; keep both until the checks pass.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": "cratis-application-growth",
|
|
3
|
+
"input": "Our single-project Cratis app has a Billing capability gated by entitlement, a second team, and a Shared project every feature depends on. Plan moving Billing into a module project and renaming namespaces afterwards without breaking stored identities.",
|
|
4
|
+
"fixtures": [],
|
|
5
|
+
"assertions": [
|
|
6
|
+
{ "kind": "skill-contains", "value": "No signal, no move." },
|
|
7
|
+
{ "kind": "skill-contains", "value": "decide, guard, move, untangle, rename, verify." },
|
|
8
|
+
{ "kind": "skill-contains", "value": "Never add `InternalsVisibleTo` or a seam" },
|
|
9
|
+
{ "kind": "skill-contains", "value": "`<Module>.Contracts`" },
|
|
10
|
+
{ "kind": "skill-contains", "value": "Dissolving a catch-all project" },
|
|
11
|
+
{ "kind": "skill-contains", "value": "references/rename-window.md" },
|
|
12
|
+
{ "kind": "skill-contains", "value": "Then boot the host and drive it end to end" }
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -137,7 +137,8 @@ Current behavior:
|
|
|
137
137
|
and queries with no explicit declaration, on both hosts, and ASP.NET's
|
|
138
138
|
`FallbackPolicy` covers HTTP endpoints and MVC actions. They are separate:
|
|
139
139
|
neither covers what the other does, and neither protects an explicitly anonymous
|
|
140
|
-
endpoint.
|
|
140
|
+
endpoint. A baseline never decides from a namespace or folder name
|
|
141
|
+
([authorization](references/authorization.md#baselines-two-separate-mechanisms)).
|
|
141
142
|
- **Direct calls bypass authorization.** Calling `Handle()` or a query method
|
|
142
143
|
directly skips authorization, validation and filters; only the pipeline and
|
|
143
144
|
mapped endpoints enforce them. Server-side callers still need a principal
|
|
@@ -281,6 +281,11 @@ public class MembersByDefault : IFallbackAuthorizationEvaluator
|
|
|
281
281
|
resource-dependent rules.
|
|
282
282
|
- `IAuthorizationAttributeEvaluator` reports only **explicit** declarations from
|
|
283
283
|
another attribute family; it never becomes a baseline.
|
|
284
|
+
- **Never decide from a name.** An evaluator or filter that grants or denies by
|
|
285
|
+
namespace prefix, folder or route segment changes who may call what the day
|
|
286
|
+
code moves or a namespace is renamed. Decide from a declaration on the type or
|
|
287
|
+
its assembly (an attribute, an assembly-level marker, a named policy), and keep
|
|
288
|
+
a spec that lists what each declaration covers.
|
|
284
289
|
|
|
285
290
|
**ASP.NET Core `FallbackPolicy`** covers HTTP endpoints and MVC actions without
|
|
286
291
|
authorization metadata. It does **not** supply Arc's pipeline baseline, and
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- Wiring
|
|
6
6
|
- MSBuild properties
|
|
7
|
+
- Several projects, several packages
|
|
7
8
|
- Route settings must match the host and the frontend
|
|
8
9
|
- Skipping generation
|
|
9
10
|
- What the generator extracts for client-side validation
|
|
@@ -86,6 +87,23 @@ inserted without configuration.
|
|
|
86
87
|
Item groups the target also forwards: `AssemblyToPackageMapping`,
|
|
87
88
|
`ExcludeType`, `ExcludeNamespace`, `NamespaceRoot`, and `TypeToTsType`.
|
|
88
89
|
|
|
90
|
+
## Several projects, several packages
|
|
91
|
+
|
|
92
|
+
The generator writes a TypeScript type for every type a project's commands and
|
|
93
|
+
queries use, **including types declared in referenced projects** (a contracts
|
|
94
|
+
project's concepts, another module's read model). Without a mapping, each
|
|
95
|
+
referencing project emits its own copy; when two projects write into the same
|
|
96
|
+
folder, the last writer wins and a partial copy can replace the owner's full
|
|
97
|
+
proxy.
|
|
98
|
+
|
|
99
|
+
- Give each backend project its own output root, inside its own frontend package.
|
|
100
|
+
- For every referenced project that has its own package, add
|
|
101
|
+
`<AssemblyToPackageMapping Include="billing" Assembly="<Assembly name>" Package="@<scope>/billing" />`
|
|
102
|
+
so its types are imported from that package instead of
|
|
103
|
+
regenerated. The owner generates a type; everyone else imports it.
|
|
104
|
+
- Routes and output folders follow the namespace, so a namespace rename changes
|
|
105
|
+
both; regenerate every package and search for literal routes afterwards.
|
|
106
|
+
|
|
89
107
|
## Route settings must match the host and the frontend
|
|
90
108
|
|
|
91
109
|
The route properties (`CratisProxiesApiPrefix`, `CratisProxiesSegmentsToSkip`,
|
|
@@ -28,7 +28,7 @@ event store name is required and has no default.
|
|
|
28
28
|
| `SkipCompatibilityCheck` | `false` | Connecting deliberately to a kernel version the client does not declare compatible. Leave on otherwise. |
|
|
29
29
|
| `UnitOfWorkLifecyclePolicy` | `Compatibility` | `Strict` to fail on units of work that are never completed. |
|
|
30
30
|
| `EventGenerationDelivery` | `Compatibility` | Opting into the newer event generation delivery behavior. |
|
|
31
|
-
| `ArtifactIdentityDrift` | `Warn` | `
|
|
31
|
+
| `ArtifactIdentityDrift` | `Warn` | `Fail` in CI or staging to stop registration on likely reactor or event type renames (values: `Warn`, `Fail`, `Ignore`). It detects drift; it does not repair stored identities. |
|
|
32
32
|
| `DefaultSinkTypeId` | MongoDB | Read models should default to another sink type. |
|
|
33
33
|
| `ClaimsBasedNamespaceResolverClaimType` | `tenant_id` | The identity provider carries the tenant in another claim. |
|
|
34
34
|
| `EnableEventTypeGenerationValidation` | `false` | Only a development kernel honors this; a production kernel always enforces migration-chain validation. |
|
|
@@ -81,7 +81,12 @@ registration is the exception, not the rule.
|
|
|
81
81
|
collaborators — that is the service-locator anti-pattern.
|
|
82
82
|
- Mark a singleton with the `[Singleton]` attribute rather than registering it
|
|
83
83
|
explicitly.
|
|
84
|
-
- A convention-based `IFoo → Foo` pair needs no registration.
|
|
84
|
+
- A convention-based `IFoo → Foo` pair needs no registration. The convention
|
|
85
|
+
binds only when `IFoo` and `Foo` share a namespace and `Foo` is the single
|
|
86
|
+
implementation, and it skips any service type already registered. An
|
|
87
|
+
interface in a contracts project with its implementation elsewhere is not
|
|
88
|
+
covered: register it explicitly, and apply any generated bindings after the
|
|
89
|
+
explicit registrations so they only fill gaps.
|
|
85
90
|
- Command and query `Handle()` parameters resolve from DI by type.
|
|
86
91
|
|
|
87
92
|
```csharp
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"cratis/specifications/typescript"
|
|
107
107
|
],
|
|
108
108
|
"availableTargets": [
|
|
109
|
+
"cratis-application-growth",
|
|
109
110
|
"cratis-observability"
|
|
110
111
|
],
|
|
111
112
|
"languages": [
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
"cratis/specifications/dotnet"
|
|
128
129
|
],
|
|
129
130
|
"availableTargets": [
|
|
131
|
+
"cratis-application-growth",
|
|
130
132
|
"cratis-observability"
|
|
131
133
|
],
|
|
132
134
|
"languages": [
|
|
@@ -142,6 +144,7 @@
|
|
|
142
144
|
"cratis/specifications/dotnet"
|
|
143
145
|
],
|
|
144
146
|
"availableTargets": [
|
|
147
|
+
"cratis-application-growth",
|
|
145
148
|
"cratis-observability"
|
|
146
149
|
],
|
|
147
150
|
"languages": [
|
|
@@ -158,6 +161,7 @@
|
|
|
158
161
|
"cratis/specifications/dotnet"
|
|
159
162
|
],
|
|
160
163
|
"availableTargets": [
|
|
164
|
+
"cratis-application-growth",
|
|
161
165
|
"cratis-observability"
|
|
162
166
|
],
|
|
163
167
|
"languages": [
|
|
@@ -178,6 +182,7 @@
|
|
|
178
182
|
"cratis/specifications/typescript"
|
|
179
183
|
],
|
|
180
184
|
"availableTargets": [
|
|
185
|
+
"cratis-application-growth",
|
|
181
186
|
"cratis-observability"
|
|
182
187
|
],
|
|
183
188
|
"languages": [
|
|
@@ -242,6 +247,7 @@
|
|
|
242
247
|
"cratis/specifications/typescript"
|
|
243
248
|
],
|
|
244
249
|
"availableTargets": [
|
|
250
|
+
"cratis-application-growth",
|
|
245
251
|
"cratis-observability"
|
|
246
252
|
],
|
|
247
253
|
"languages": [
|