Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The kit is upstream of both: it defines *what* a Specfuse spec must look like. T

## Status

**Incubating** (`v0.30.0`), Apache-2.0. Handbooks, samples, schemas, the `project-init` template, the bundled `hello-orders` example, the `specfuse-authoring` plugin (in the `specfuse/specfuse` marketplace), and the `specfuse authoring` CLI are all in place. Generator-side alignment items are tracked in [`compatibility.md`](compatibility.md#outstanding-generator-side-follow-ups).
**Incubating** (`v0.31.0`), Apache-2.0. Handbooks, samples, schemas, the `project-init` template, the bundled `hello-orders` example, the `specfuse-authoring` plugin (in the `specfuse/specfuse` marketplace), and the `specfuse authoring` CLI are all in place. Generator-side alignment items are tracked in [`compatibility.md`](compatibility.md#outstanding-generator-side-follow-ups).

The kit is distributed on PyPI as `specfuse-authoring` and hosted under [`Specfuse/authoring`](https://github.com/Specfuse/authoring). The code generator it drives is distributed separately as a pinned, checksum-verified release asset (see [`generator.lock`](generator.lock)); `specfuse authoring generate` resolves, verifies, and runs it on demand.

Expand Down
23 changes: 22 additions & 1 deletion compatibility.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/csharp-component-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ With a Test group, the generated tests derive from and call three hand-written t

The generated `TestSeed` (stable GUIDs and a pre-wired entity graph) and the `A.{Entity}()` builders point at each other; `EnsureFakeData()` is where you seed that graph into the test database. A bare `A.Order()` is not a self-contained row: it carries foreign keys to `TestSeed` ancestors, and a read through the generated query filters joins them.

From generator 0.22.0, also call `TestSeed.SeedSpareParents(context)` from `EnsureFakeData()`, beside the rows you already add. It seeds a spare parent row for each `uniqueBy` tuple made only of references (one gadget per owner), so the generated create test does not collide with the seeded child and answer 409. It is emitted on every `TestSeed`, empty when no tuple needs it, so the call can stay put. Without it, the create test answers 404 on the parent lookup.

Also from 0.22.0, the generated service unit tests assert what each emitted event carries and the exact set of events an update emits, including `x-trigger-when` transitions. A red service test after a regen means the service emits something other than what the spec implies, not a flaky test: fix the service, there is no opt-out. Events now carry the acting user: generated controllers and worker handler bases enter `EventActorScope`, so `EventEnvelope.UserId` is filled. Hand-written code that emits on behalf of a user outside those entry points (a hand-written endpoint, a hub, a background service) wraps the work in `using var _ = EventActorScope.Enter(userId);` with the domain user id.

## 5. Extending generated code

Never edit a file under `gen-src/`. A wrong generated file is fixed in the spec or in the generator, then regenerated; an edit disappears on the next run. The one exception, a tracked patch while a generator fix is pending, is §9.1. Four patterns cover everything else, all in `src/`, all in the generated type's own namespace.
Expand Down
45 changes: 45 additions & 0 deletions docs/generator-releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,51 @@ Newest first. An entry is **pending** until the kit release that pins it is publ
| **Tracked issues** | you were waiting on a fix |
| **Kit changes** | you want to know what moved in the handbooks, rules and tooling |

## 0.23.0 (with 0.22.0)

**Status: pending.** Pinned by kit `v0.31.0` (jar sha256 `b906ed3f…5ffacc6`; full record in [`compatibility.md`](https://github.com/specfuse/authoring/blob/main/compatibility.md) §59). Generator release dates: 0.22.0 on 2026-10-28, 0.23.0 on 2026-10-29.

The kit goes from **0.21.0 to 0.23.0**; everything below covers both releases.

### Before you regenerate

**Spec authors**

- **Kiosk sessions are admitted per operation (0.22.0, security fix).** Flagging `GET /messages/{messageId}` with `x-kiosk-session: true` used to admit `PATCH` and `DELETE` on the same path. Now only flagged operations are reachable: flag every operation the kiosk app calls. See [`Vendor_Extensions.md`](../handbooks/Vendor_Extensions.md) §3.3.
- **`AMBIGUOUS_LAYER_OWNER` (load failure, 0.23.0).** Two C# groups that emit the same layer (`domainProject`, `infrastructureProject` or `apiProject`) and share no `pillar` now stop the load. Give them distinct `pillar`s, or register the layer's project artifact on one group. See [`Project_File.md`](../handbooks/Project_File.md) §9.
- **Nested `emit.expect` leaves are checked (0.22.0).** A nested leaf naming no payload member is an `ARAZZO_CROSS_SPEC_ERROR`, and an unbindable runtime expression fails generation with `ARAZZO_MATCH_EXPRESSION_UNBOUND`. See [`Arazzo_Handbook.md`](../handbooks/Arazzo_Handbook.md).

**C# component repos**

- **Cross-group namespaces follow each group's `basePackage` (0.23.0).** A project whose `name` differs from its groups' root used to generate `using <name>.Domain…;` and fail to build; it now names the owning group's namespace. If you wrote `using <name>.<Layer>…;` by hand, change it. Nothing moves when `name` already equals the groups' root. See [`Project_File.md`](../handbooks/Project_File.md) §8.5.
- **Call `TestSeed.SeedSpareParents(context)` from `EnsureFakeData()` (0.22.0).** Without it, generated create tests for a reference-only `uniqueBy` answer 404. See [`csharp-component-guide.md`](csharp-component-guide.md) §4.4.
- **Generated service tests assert events (0.22.0).** They check what each event carries and the exact set an update emits. A red test after regen means the service emits the wrong thing: fix the service.
- **`[ScopesRequired]` needs `OperationId` (0.22.0).** In `scopes` mode the filter decides through `IOperationAuthorizer`; a hand-written `[ScopesRequired]` without a catalogued `OperationId` answers 403.
- **`IKioskSessionPolicy` gains two members (0.22.0).** Only a hand-written implementation has to add them.
- **Overrides with optional value-type parameters (0.23.0).** A `{Op}Core` or `manualMethod` delete override with an optional `int`/`Guid` parameter changes it to `int?`/`Guid?`.

### New in the spec

- **Named worker pools (0.22.0).** `workerPlacement.messages.genericHost` can be an object of pools, each its own Deployment. See [`Project_File.md`](../handbooks/Project_File.md) §17.1, and §17.2 for projects with several pillars.
- **`IOperationAuthorizer` (0.22.0).** `authorizationRuntime` emits a transport-neutral check, so a worker or agent tool gets the decision REST makes for an `operationId`.
- **Denial scenarios under `scopes` (0.22.0).** `ARAZZO_ACTOR_LACKS_SCOPE` skips a step asserting `$statusCode == 403`.
- **Nested `emit.expect` maps compile (0.22.0)** under `emitAssertions: strict`, and `$setup.outputs.*` leaves bind.

### Component repos

- Events now name their user: generated controllers and worker handler bases enter `EventActorScope`, so `EventEnvelope.UserId`, the outbox `UserId` and the Service Bus `userId` property are filled. Code emitting on a user's behalf elsewhere wraps it in `EventActorScope.Enter(userId)`.
- Worth knowing from the fixes: optional headers are nullable on controller actions (a GET without `If-None-Match` no longer answers 400); the outbox drainer tags `outbox.claimed` so empty runs can be dropped before export; a `null` in an Arazzo request body compiles; `WithForbiddenRole` no longer fails with "No data found" when there is no role registry.

### Tracked issues

None of the kit's tracked generator issues closed in this pair. Still open for the kit: FEAT-2026-0243 (one database per pillar, `workerPlacement.schedules` / `runtime`), which [`Project_File.md`](../handbooks/Project_File.md) §17.2 marks "next generator release".

### Kit changes

- `specfuse authoring generate` honours a project's own `.specfuse/generator.lock` (version + SHA-256), and `SPECFUSE_GENERATOR_JAR` runs a local jar as unpinned ([#169](https://github.com/specfuse/authoring/issues/169)).
- `generate-scenario-docs.sh` runs the Markdown groups your project file declares, instead of two fixed names ([#191](https://github.com/specfuse/authoring/issues/191)).
- Handbooks document the changes above; the C# component guide adds the new consumer steps. No Spectral change.

## 0.21.0 (with 0.20.0)

**Status: published.** Pinned by kit `v0.29.0` (released 2026-10-28) (jar sha256 `a78b5ea7…27f08a94`; full record in [`compatibility.md`](https://github.com/specfuse/authoring/blob/main/compatibility.md) §58). Generator release date: 2026-10-28.
Expand Down
10 changes: 5 additions & 5 deletions generator.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"kit_version": "0.30.0",
"kit_version": "0.31.0",
"min_java": 21,
"generator": {
"version": "0.21.0",
"asset": "specfuse-generator-0.21.0.jar",
"sha256": "a78b5ea74497f6c33e52191e8b84e50c1492b175e28aa6b153a52b7d27f08a94",
"version": "0.23.0",
"asset": "specfuse-generator-0.23.0.jar",
"sha256": "b906ed3f6bd8e6d657ff5e14d82cacb545ce46fc9674fb8d0d67551535ffacc6",
"release_repo": "Specfuse/generator-dist",
"release_tag": "v0.21.0"
"release_tag": "v0.23.0"
},
"_note": "Pin the kit<->generator contract here. On each generator release: set version/asset/sha256/release_tag, then publish a matching kit patch. sha256=PENDING means no generator is bundled yet; `specfuse authoring generate` will refuse with a clear message until a real jar is pinned."
}
4 changes: 3 additions & 1 deletion handbooks/Arazzo_Handbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ The role values are project-specific. The project declares its closed role set i

- it runs only under `authorization.mode: scopes` (`Project_File.md` §16); under the default `roles` it never runs;
- it compares grants: a `superuser: true` role and a step whose operation declares no `x-scopes` are skipped, and a role from a sequence-form registry grants nothing, so under `scopes` every step it takes on a scoped operation fails;
- it checks scopes, not membership. Membership is `ARAZZO_ACTOR_ROLE_NOT_PERMITTED` from generator `0.19.0`, in roles mode (above).
- it checks scopes, not membership. Membership is `ARAZZO_ACTOR_ROLE_NOT_PERMITTED` from generator `0.19.0`, in roles mode (above);
- from generator `0.22.0` it skips a step that asserts the refusal, `$statusCode == 403` (`clabonte/generator#3026`). Such a step runs as an under-granted actor on purpose, and the generated scope filter answers it with exactly that 403. Only 403 is exempt: a scope-lacking step asserting 401, 404 or 200 is still an ERROR. Through `0.21.0` deliberate denial scenarios under `scopes` reported one ERROR per denial step.

**It fires from generator `0.15.0`, and never at `0.14.0`** (`clabonte/generator#2418`). Through `0.14.0` it looked each step's `operationId` up by exact key, while the generator keys operations PascalCased, so every step found no operation and was skipped. Measured on a mapping-form copy of `hello-orders` under `mode: scopes`, with a `Customer` whose grants miss the scenario's `order.*` scopes: `0.14.0` reports only `OPERATION_ROLE_LACKS_SCOPE` on the operations; a build of generator main adds one `ARAZZO_ACTOR_LACKS_SCOPE` per step (three). On `0.14.0`, read `OPERATION_ROLE_LACKS_SCOPE` as the check that catches an under-granted actor.

Expand Down Expand Up @@ -644,6 +645,7 @@ steps:
**Whether the generated C# scenario test checks `emit` is a project setting.** By default (`functionalTests.emitAssertions: off`) each entry is a comment for the reviewer and nothing is asserted. Under `strict` (generator `0.21.0`, `Project_File.md` §18) each entry becomes an awaited wait for the event and the test fails when it is never published:

- `expect` is a subset match: only the declared keys are compared. Enum, `uuid`, decimal, `date` and `date-time` literals are typed, and `$steps` outputs bind to the step's own locals. An `emit` without `expect` matches on the event type alone.
- A nested map and the dotted spelling are the same from generator `0.22.0` (`clabonte/generator#3027`): `expect: { after: { punchType: clockIn } }` compares `after.punchType`, and a `$setup.outputs.*` leaf inside it binds to the setup state. Through `0.21.0` a nested map rendered one comparison against an anonymous type, which did not compile, and a `$setup` leaf stayed a string literal. `validate` resolves each nested leaf like a dotted key, so a nested leaf naming no member is an `ARAZZO_CROSS_SPEC_ERROR`. A runtime expression the predicate cannot bind (`$response.*`, `$statusCode`, `$message.*`, or one inside a list) fails generation with `ARAZZO_MATCH_EXPRESSION_UNBOUND`. The same applies to `x-async.await.match`.
- The wait scans the outbox, so an event an **earlier** step wrote also satisfies a later `emit` of the same type. Key `expect` on something only this step produces, typically one of its own outputs (`$steps.<thisStep>.outputs.<id>`), when an earlier step can publish the same event.
- `timeout` is the wait's limit, `PT10S` by default.

Expand Down
7 changes: 6 additions & 1 deletion handbooks/Project_File.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,8 @@ The `side` field is present only for hybrid entities.

**Type**: string. Format is language-specific — `HelloOrders.Domain` for C#, `hello_orders_contracts` for Python, `hello_orders_core` for Dart.

**C#: other groups reference a layer by its owner's `basePackage` (generator `0.23.0`, breaking).** When the Api group uses a domain type, it writes the namespace of the group that emits the Domain layer, not the project `name` plus `.Domain`. The same holds for `.Infrastructure`, `.Api` and `.Test`, and for `Assembly.Load` and `InternalsVisibleTo` targets. Through `0.22.0` a project with `name: Acme` and groups rooted at `Shop.*` generated `using Acme.Domain.Events;` and failed to build. A layer no group emits, the `Application` layer and `{name}DbContext` still use the project `name`. Nothing changes when `name` already equals the groups' root. In hand-written code, replace any `using <name>.<Layer>…;` that named the project root with the owning group's `basePackage`; a project that builds today has no such line. Two groups that emit the same layer must be told apart by `pillar`, or loading fails with `AMBIGUOUS_LAYER_OWNER` (§9).

### 8.6 `destination`

**Purpose**: Output directory for everything this group emits.
Expand Down Expand Up @@ -985,6 +987,7 @@ The project file fails to load when any of the following conditions hold. All er
| `UNKNOWN_PILLAR_FILTER` | `groups[].pillar` names a pillar `info.x-pillars` does not declare — or the registry is absent or empty. Raised at filter-application time, not at parse time. |
| `EMPTY_PILLAR_DOMAINS` | `groups[].pillar` names a pillar that owns zero domains. |
| `UNKNOWN_LANGUAGE` | `groups[].language` not registered. |
| `AMBIGUOUS_LAYER_OWNER` | **From generator `0.23.0`, breaking.** Two C# groups emit the same layer (both register `domainProject`, `infrastructureProject` or `apiProject`), share no `pillar` and differ in `basePackage`, so a group that reads the layer cannot tell which namespace to use. Raised before any destination is cleaned. Fix: give the groups distinct `pillar` values (a reading group takes the owner in its own pillar, else the one group without a `pillar`), or register the layer's project artifact on one group only (§8.13.2). |
| `UNKNOWN_AUTHORIZATION_MODE` | `authorization.mode` is neither `roles` nor `scopes` (§16). |
| `AUTHORIZATION_SHADOW_REQUIRES_SCOPES_MODE` | `authorization.shadow: true` with `mode` absent or `roles` (§16). |
| `UNKNOWN_ROLES_SHAPE` | `authorization.claims.rolesShape` is neither `name` nor `object` (§16). |
Expand Down Expand Up @@ -1075,7 +1078,7 @@ Three opt-in artifact ids, none in the lists above, which predate them. Each is

| Id | Languages | What it emits |
|---|---|---|
| `authorizationRuntime` | C#, TypeScript, Dart, Python | **C#** (API group): the whole gate in `{apiPackage}.Authorization` — `AuthorizedRole`, `RoleRequiredAttribute` / `RoleRequirement` / `RoleAuthorizationHandler` / `RoleAuthorizationFilter`, `ScopesRequiredAttribute` / `ScopeRequirement` / `ScopeAuthorizationHandler` / `ScopeAuthorizationFilter`, `PrincipalRole`, `IPrincipalReader` + `ClaimsPrincipalReader`, `IPrincipalPolicy` (allow-all default), `ITenantResourceCheck`, `IKioskSessionPolicy` + `KioskSessionPolicy`, `IGrantResolver`, `RoleGrants`, `ScopeCatalog`, `GrantMatcher`, and `AddSpecfuseAuthorization()`. **TypeScript, Dart, Python**: `RoleGrants`, `ScopeCatalog` and the grant matcher only (`grantCovers` / `hasGrant`, `grant_covers` / `has_grant`). |
| `authorizationRuntime` | C#, TypeScript, Dart, Python | **C#** (API group): the whole gate in `{apiPackage}.Authorization` — `AuthorizedRole`, `RoleRequiredAttribute` / `RoleRequirement` / `RoleAuthorizationHandler` / `RoleAuthorizationFilter`, `ScopesRequiredAttribute` / `ScopeRequirement` / `ScopeAuthorizationHandler` / `ScopeAuthorizationFilter`, `PrincipalRole`, `IPrincipalReader` + `ClaimsPrincipalReader`, `IPrincipalPolicy` (allow-all default), `ITenantResourceCheck`, `IKioskSessionPolicy` + `KioskSessionPolicy`, `IGrantResolver`, `RoleGrants`, `ScopeCatalog`, `GrantMatcher`, and `AddSpecfuseAuthorization()`. From generator `0.22.0` it also emits `IOperationAuthorizer` + `OperationAuthorizer`, `OperationInvocation` and `OperationAuthorizationCatalog`: a transport-neutral check that gives a caller with no `HttpContext` (a worker, an agent tool) the decision the REST scope path makes for an `operationId`, refusing an `operationId` the catalog does not list. **TypeScript, Dart, Python**: `RoleGrants`, `ScopeCatalog` and the grant matcher only (`grantCovers` / `hasGrant`, `grant_covers` / `has_grant`). |
| `authorizationConformanceTest` | C#, TypeScript, Dart, Python | **C#** (Test group): `AuthorizationConformanceTests`, `FakeTenantResourceCheck`, `RoleClaimsTestPrincipalFactory`, `AuthorizationTestSupport.ForbiddenRoles`. Registering it also moves the generated `WithForbiddenRole` theory onto `ForbiddenRoles`, derived as registry − listed − superuser − implicit with no role hierarchy. **TypeScript, Dart, Python**: one test per grant-matcher known-answer vector, the table every runtime is proved against so no two disagree on a wildcard. |
| `authorizationMatrix` | Markdown | See §11.5. |

Expand Down Expand Up @@ -1444,6 +1447,8 @@ All four fail `Project.Load`, like the codes under "Where it is checked" below,

**Switch only on a coherent registry.** `scopes` admits whichever roles' grants cover an operation's scopes, whatever its `x-roles` lists, so every `OPERATION_ROLE_UNLISTED` WARNING under `roles` is a role that `scopes` lets in. Read the `authorizationMatrix` artifact (§11.5) first, or run `shadow` in production before switching. From generator `0.15.0` the switch also checks every Arazzo actor against its role's grants (`ARAZZO_ACTOR_LACKS_SCOPE`, `Arazzo_Handbook.md` §4.6), and a sequence-form `info.x-roles` grants nothing: unmodified `hello-orders` passes `validate` under `scopes` on `0.14.0` and fails it with three of those ERRORs on a build of generator main. Move the registry to the mapping form first.

**Every `[ScopesRequired]` names its operation (generator `0.22.0`).** The generated attribute always carries `OperationId`, and in `scopes` and `scopes + shadow` mode `ScopeAuthorizationFilter` decides through `IOperationAuthorizer`, so REST and non-HTTP callers run one code path. A `[ScopesRequired]` with no `OperationId`, or one the catalog does not list, is refused with 403. A hand-written controller that uses the attribute must set `OperationId` to an operation of the spec. Roles mode is unchanged.

**The attribute is not the runtime.** `mode: scopes` changes the attribute on the controller whether or not the group registers `authorizationRuntime` — measured: without it, the controllers still carry `[ScopesRequired]` and import `{apiPackage}.Authorization`, which then has to supply that type. Register `authorizationRuntime` (§11.1), or own a hand-written `ScopesRequiredAttribute` in that namespace.

### `shadow`
Expand Down
Loading
Loading