@cratis/pi 7.188.3 → 7.189.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/skills/cratis-arc-elixir/SKILL.md +3 -0
- package/package/corpus/skills/cratis-arc-elixir/references/availability.md +79 -0
- package/package/corpus/skills/cratis-arc-hosting/SKILL.md +3 -0
- package/package/corpus/skills/cratis-arc-hosting/references/availability.md +115 -0
- package/package/corpus/skills/cratis-arc-react-page/references/availability.md +10 -0
- package/package/corpus/skills/cratis-screenplay-availability/SKILL.md +51 -4
- package/package/corpus/skills/cratis-screenplay-availability/references/review-checks.md +4 -0
- package/package/corpus/skills/cratis-screenplay-availability/references/runtime-ownership.md +3 -3
- package/package/corpus/skills/cratis-screenplay-availability/verification.json +6 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +3140 -79
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
- package/package.json +1 -1
|
@@ -113,5 +113,8 @@ Phoenix and LiveView use the same application in process. Read
|
|
|
113
113
|
- **Organize by feature.** Backend, generated proxies and React page of a feature share a
|
|
114
114
|
folder. `layout: :colocated` generates that layout.
|
|
115
115
|
|
|
116
|
+
- **Availability is planned, not shipped.** Read [references/availability.md](references/availability.md) before
|
|
117
|
+
promising `not`, suspension or gates in Elixir.
|
|
118
|
+
|
|
116
119
|
See [references/pitfalls.md](references/pitfalls.md) for the full list, and
|
|
117
120
|
[references/product-sources.md](references/product-sources.md) for package facts.
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
# Availability in Arc for Elixir
|
|
5
|
+
|
|
6
|
+
Arc for Elixir ships availability (v1.3.0): the same model as Arc for .NET and Screenplay, in the same words.
|
|
7
|
+
Verify names against the package's `Documentation/availability.md`.
|
|
8
|
+
|
|
9
|
+
It is one gate and runs **first**, before binding, `Arc.Filter`, authorization and validation.
|
|
10
|
+
|
|
11
|
+
| Decision | Result |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Available | The request continues to authorization and validation. |
|
|
14
|
+
| Not available, or unknown | Not authorized, reason `NotAvailable`, HTTP `403`. |
|
|
15
|
+
| Suspended | Not authorized, reason `Suspended`, HTTP `403`. |
|
|
16
|
+
| The decision could not be made | Retryable error (`isRetryable` true), HTTP `503`; never a denial. |
|
|
17
|
+
|
|
18
|
+
## Configure and declare
|
|
19
|
+
|
|
20
|
+
```elixir
|
|
21
|
+
config :my_app, MyApp.Arc,
|
|
22
|
+
availability: [
|
|
23
|
+
definition: MyApp.Availability,
|
|
24
|
+
audience_source: MyApp.AudienceSource,
|
|
25
|
+
suspension_source: MyApp.SuspensionSource,
|
|
26
|
+
pubsub: MyApp.PubSub
|
|
27
|
+
]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```elixir
|
|
31
|
+
defmodule MyApp.Availability do
|
|
32
|
+
use Arc.Availability.Definition
|
|
33
|
+
|
|
34
|
+
audience "Plus", "Customers on the Plus package"
|
|
35
|
+
block "Paid", "Sold with Plus", for: ["Plus", "Admin"]
|
|
36
|
+
scope "MyApp.Fleet", with: "Paid"
|
|
37
|
+
value "vessel", MyApp.VesselValue
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
defmodule MyApp.Fleet.Vessels.DockVessel do
|
|
41
|
+
use Arc.Command
|
|
42
|
+
available for: ["Plus", "Admin"], not: "Preview", with: "Reported"
|
|
43
|
+
available when: Arc.Availability.Condition.equal("vessel.package", "Plus")
|
|
44
|
+
end
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- `for:` audience(s), one is enough; `not:` none may be held; `with:` a named block; `when:` a condition
|
|
48
|
+
(`Arc.Availability.Condition` data shared with other languages, or a module implementing the behaviour).
|
|
49
|
+
- On a read model `available` gates every query; `@query available: [...]` gates one query.
|
|
50
|
+
- Module, feature and slice come from `Arc.Descriptor.slice_location/2`.
|
|
51
|
+
- Conditions read `tenant`, `identity.user`, `arguments.<name>` (camelCase wire name) and `<name>.<path>` of a
|
|
52
|
+
provided value; tenant and identity always come from the server.
|
|
53
|
+
- Three values: available, unavailable, unknown. Only available opens a gate; an absent value is unknown for every
|
|
54
|
+
operator. `Arc.Availability.Engine` passes the shared conformance cases.
|
|
55
|
+
|
|
56
|
+
## Sources: audiences granted and withdrawn, parts suspended and resumed
|
|
57
|
+
|
|
58
|
+
- `Arc.Availability.AudienceSource`: `grants(subject)` returns the audience names held. Undeclared audiences never match.
|
|
59
|
+
- `Arc.Availability.SuspensionSource`: `suspended/0` returns paths (`"Fleet"`, `"Fleet/Vessels"`,
|
|
60
|
+
`"Fleet/Vessels/Dock"`, or a part's full name); suspension is decided before any gate.
|
|
61
|
+
- `Arc.Availability.Memory` serves specifications and samples (`grant/2`, `withdraw/2`, `suspend/1`, `resume/1`).
|
|
62
|
+
- Call `Arc.Availability.changed/1` when a source changes; open sessions decide again, on every node with `:pubsub`.
|
|
63
|
+
|
|
64
|
+
## Client
|
|
65
|
+
|
|
66
|
+
- `/.cratis/availability` is an observable query listing what is unavailable to the caller (name, module, feature,
|
|
67
|
+
slice, reason); `?part=<name>&arguments=<json>` asks about one part. A decision that cannot be made is a retryable error.
|
|
68
|
+
- Generated proxies carry `static readonly part` (part identity).
|
|
69
|
+
- LiveView: `<Arc.LiveView.Availability.available socket={@socket} version={@arc_availability} command={...}>`
|
|
70
|
+
hides a part (`Arc.LiveView.available?/3`). Hiding is presentation; the server still refuses.
|
|
71
|
+
- `Arc.Availability.Manifest.build/1`, `to_json/1`, `decode/1`, `decide/3` use the shared
|
|
72
|
+
`cratis-availability-manifest` (version 1).
|
|
73
|
+
|
|
74
|
+
## Rules
|
|
75
|
+
|
|
76
|
+
- Model availability in Screenplay (`cratis-screenplay-availability`); do not invent a second gating mechanism.
|
|
77
|
+
- Keep the vocabulary: audiences are granted and withdrawn; parts are suspended and resumed.
|
|
78
|
+
- Unknown is closed; failure to decide is a retryable error, never a denial.
|
|
79
|
+
- Compare the C# side in `cratis-arc-hosting` (`references/availability.md`).
|
|
@@ -59,6 +59,9 @@ comes from `ArcOptions.Hosting.ApplicationUrl`, not an argument to `UseCratisArc
|
|
|
59
59
|
Read [integrations and publish boundaries](references/integrations-and-publish.md)
|
|
60
60
|
when selecting storage, disabling MVC, adding generated JSON contracts, or
|
|
61
61
|
configuring the explorer.
|
|
62
|
+
Read [availability](references/availability.md) when gating, suspending or
|
|
63
|
+
asking availability of a module, feature, slice or part with
|
|
64
|
+
`arc.WithAvailability()`, typed audiences and `[AvailableFor<T>]`.
|
|
62
65
|
|
|
63
66
|
## Keep trust and discovery explicit
|
|
64
67
|
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
# Availability in a C# Arc host
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- Where the engine lives
|
|
9
|
+
- Declare with types
|
|
10
|
+
- Suspension
|
|
11
|
+
- Proxies and asking
|
|
12
|
+
- Manifest file and shared cases
|
|
13
|
+
- Pitfalls
|
|
14
|
+
|
|
15
|
+
Availability decides whether a part (module, feature, slice, command, read model) exists for a tenant, user or
|
|
16
|
+
system caller. It is decided before `authorize` and is not authorization. The Screenplay model side is the
|
|
17
|
+
`cratis-screenplay-availability` skill; this page is the C# side. Facts come from the Arc availability
|
|
18
|
+
documentation (`Documentation/backend/csharp/availability.md` and `availability-engine/`).
|
|
19
|
+
|
|
20
|
+
## Where the engine lives
|
|
21
|
+
|
|
22
|
+
- The engine is `Cratis.Arc.Availability`: gate expressions, evaluator, audiences, context values and the manifest.
|
|
23
|
+
It does not depend on ASP.NET and does not depend on `Cratis.Choreography`.
|
|
24
|
+
- `arc.WithAvailability()` registers the gates, the engine, an in-memory audience source by default and startup
|
|
25
|
+
validation that discovers gated parts and verifies the declared blocks once.
|
|
26
|
+
- `AddAvailability` registers the engine alone, for a host that is not a web application.
|
|
27
|
+
- `Cratis.Choreography.Availability` is an obsolete forwarder from Choreography 2.11.0. Move to the Arc types
|
|
28
|
+
(`Cratis.Arc.Availability`, `.Audiences`, `.Context`); `ChoreographyContextValueSource` is now
|
|
29
|
+
`AvailabilityContextValueSource`.
|
|
30
|
+
|
|
31
|
+
## Declare with types
|
|
32
|
+
|
|
33
|
+
What you write in C# is what a model can say; a typo is a compile error because nothing is named by a string.
|
|
34
|
+
|
|
35
|
+
| Screenplay | C# |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `audience Plus` | `public class Plus : Audience;` (summary is the description) |
|
|
38
|
+
| `availability DataQuality` | `public class DataQuality : AvailabilityBlock` with `Lines` |
|
|
39
|
+
| `for`, `with`, `not`, `when` | `For<T>()`, `With<T>()`, `Not<T>()`, `When` |
|
|
40
|
+
| `available for Plus` | `[AvailableFor<Plus>]` (up to three audiences; any opens the gate) |
|
|
41
|
+
| `available with DataQuality` | `[Available<DataQuality>]` |
|
|
42
|
+
| `available when <condition>` | `[AvailableWhen<HasPaidInvoice>]` |
|
|
43
|
+
| gate on a module, feature or slice | a type deriving from `AvailabilityScope` in its namespace |
|
|
44
|
+
| `provide vessel Vessel from query ...` | `[ProvideContext<Vessel>(...)]` |
|
|
45
|
+
|
|
46
|
+
```csharp
|
|
47
|
+
public class Plus : Audience;
|
|
48
|
+
|
|
49
|
+
public class DataQuality : AvailabilityBlock
|
|
50
|
+
{
|
|
51
|
+
protected override IReadOnlyList<AvailabilityTerm> Lines =>
|
|
52
|
+
[
|
|
53
|
+
For<Plus>(),
|
|
54
|
+
When.On<Vessel>(_ => _.HasReported).IsTrue()
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[Command]
|
|
59
|
+
[AvailableFor<Plus, Preview>]
|
|
60
|
+
public record ResetScore(VesselId Vessel);
|
|
61
|
+
|
|
62
|
+
[Available<DataQuality>]
|
|
63
|
+
public class Feature : AvailabilityScope;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- Every attribute is one line and every line must hold: `[AvailableFor<Plus>, AvailableFor<Preview>]` needs both.
|
|
67
|
+
For either, use `[AvailableFor<Plus, Preview>]` or a block.
|
|
68
|
+
- `For<T>()` and `With<T>()` combine with `&`, `|` and parentheses. `Not<T>()` applies to one audience and is
|
|
69
|
+
three-valued: an unknown audience keeps the gate closed. A `&` between different forms is separate lines;
|
|
70
|
+
a `|` between different forms or beneath `not` cannot be stated and the generator reports it.
|
|
71
|
+
- Conditions come in two forms. The restricted comparison (`When.On<Vessel>(_ => _.CommercialPackage).IsNot(Package.Basic)`,
|
|
72
|
+
with `Is`, `IsNot`, `IsTrue`, `In`, `NotIn`, `IsGreaterThan`, `IsAtLeast`, `IsLessThan`, `IsAtMost`) compiles to a
|
|
73
|
+
Screenplay `when`. An injectable `IAvailabilityCondition` class (`When.Condition<T>()` or `[AvailableWhen<T>]`) is
|
|
74
|
+
emitted as an opaque condition the model cannot read.
|
|
75
|
+
- Obsolete, with a migration table in the Arc docs: `[AvailableFor("name")]`, `[AvailableWith("name")]`, the
|
|
76
|
+
`AvailabilityExpression` factories, `GateNamespace`, `ContextValueCatalog.Declare` and `DeclaredAudiences`.
|
|
77
|
+
|
|
78
|
+
## Suspension
|
|
79
|
+
|
|
80
|
+
Any discovered module, feature, slice or part can be suspended for a tenant, a user or the system without declaring
|
|
81
|
+
anything. Audiences are **granted and withdrawn**; parts are **suspended and resumed**.
|
|
82
|
+
|
|
83
|
+
- Reason `Suspended` (`AvailabilityReason.Suspended`), distinct from `NotAvailable`; both are HTTP 403.
|
|
84
|
+
- Checked first: before gates and before `authorize`. Suspension wins over every grant; a suspended module or feature
|
|
85
|
+
suspends what is beneath it. The newest decision per level and path wins.
|
|
86
|
+
- `ISuspensionSource` (`GetDecisions`, `OnChanged`) is what a product implements, fed by the events `PartSuspended`
|
|
87
|
+
and `PartResumed` (never `TenantSuspended`). `InMemorySuspensionSource` is the default. A source that cannot
|
|
88
|
+
answer is a retryable failure (503), never a suspension.
|
|
89
|
+
- Part paths are the slice location joined with `/` (`Fleet/DataQuality/QualityScores`); `DiscoveredParts.Entries()`
|
|
90
|
+
and `AvailabilityManifest.Parts` list what an operator can suspend.
|
|
91
|
+
- `/.cratis/availability` lists refused parts with their `reason`; MCP tools of a suspended part are left out.
|
|
92
|
+
|
|
93
|
+
## Proxies and asking
|
|
94
|
+
|
|
95
|
+
- Regenerate the TypeScript proxies after updating: every command and query proxy (including model-bound read model
|
|
96
|
+
queries) declares `static part`. The gate stays on the server.
|
|
97
|
+
- `/.cratis/availability` accepts `part` and `arguments`, so a gate reading `arguments.vesselId` answers for one
|
|
98
|
+
vessel with the same gate that decides execution. In code: `IUnavailableParts.Get(PartQuestion)`.
|
|
99
|
+
- Frontend: see the [React availability reference](../../cratis-arc-react-page/references/availability.md).
|
|
100
|
+
|
|
101
|
+
## Manifest file and shared cases
|
|
102
|
+
|
|
103
|
+
- One JSON format, `cratis.availability.manifest.json`, `format` `cratis-availability-manifest`, `version` 1, with a
|
|
104
|
+
schema in `Specifications/availability` of the Arc repository. It is written by the engine (`ManifestFileBuilder`)
|
|
105
|
+
and by the proxy generator at build (set `CratisAvailabilityManifest` to a path), and decided by
|
|
106
|
+
`ManifestFileEvaluator`.
|
|
107
|
+
- `Specifications/availability/vectors` holds shared data-driven cases any Arc engine can run. Named conditions
|
|
108
|
+
(code) are listed in the file but cannot be evaluated from it.
|
|
109
|
+
|
|
110
|
+
## Pitfalls
|
|
111
|
+
|
|
112
|
+
- `AddArcAvailability` configured before `AddCratis()` was once discarded (gates lost, parts failed open); use
|
|
113
|
+
`arc.WithAvailability()` on a version that has the fix.
|
|
114
|
+
- Never use availability as authorization or the reverse; never model suspension in the Screenplay model.
|
|
115
|
+
- A decision failure is a retryable error, never `NotAvailable`.
|
|
@@ -48,6 +48,16 @@ import { AllAccounts } from './AllAccounts';
|
|
|
48
48
|
proxy class/instance. Strings match the full name; proxies match their slice
|
|
49
49
|
location. Missing slice metadata is not an authorization grant.
|
|
50
50
|
|
|
51
|
+
## Ask for one part and its data
|
|
52
|
+
|
|
53
|
+
Generated command and query proxies declare `static part` (regenerate the proxies after updating Arc), so a part is a
|
|
54
|
+
proxy rather than a string. `useIsAvailable(part, args?)` and `askAvailability(part, args)` from `@cratis/arc/availability`
|
|
55
|
+
ask the server for one part, with the arguments the gate reads (for example `{ vesselId }`), using the same gate that
|
|
56
|
+
decides execution. `RequireAvailable` takes `args` and a `suspended` slot beside `unavailable`.
|
|
57
|
+
|
|
58
|
+
`Suspended` (an operator suspended the part) is told apart from `NotAvailable`: `isSuspended(result)` and, on a
|
|
59
|
+
`CommandResult`, `isSuspended` and `onSuspended`. Both are refusals with HTTP 403; neither is a failure to decide.
|
|
60
|
+
|
|
51
61
|
## Navigation and decisions in code
|
|
52
62
|
|
|
53
63
|
`useAvailability()` returns the `Availability` decision: `isKnown`,
|
|
@@ -53,14 +53,57 @@ module Fleet
|
|
|
53
53
|
- `availability <Name>` is a reusable rule. Its `for`, `when` and `with` lines must all hold;
|
|
54
54
|
`with` builds on another availability. A `with` cycle is PLAY1137.
|
|
55
55
|
- `available for <audiences>`, `available when <condition>`, `available with <Availability>`.
|
|
56
|
-
`for` and `with` combine names with `and`, `or` and parentheses. A `when` is one condition with its own
|
|
56
|
+
`for` and `with` combine names with `and`, `or`, `not` and parentheses (see [`not`](#not-and-the-closing-pattern)). A `when` is one condition with its own
|
|
57
57
|
`and`/`or`. One line holds one form; to mix forms, name them in an `availability` and use `with`.
|
|
58
58
|
Several `available` lines on one construct all have to hold.
|
|
59
|
-
- A gate is allowed on a module, feature, slice, command, query and screen
|
|
59
|
+
- A gate is allowed on a module, feature, slice, command, query, screen, and on a screen `action` or `data`
|
|
60
|
+
element (see [screen elements](#screen-elements)). Gates AND down the
|
|
60
61
|
path from module to construct. Gate at the highest level that is true for everything beneath it.
|
|
61
62
|
- The runtime context carries `$context.audiences`, the union of the tenant's, user's and
|
|
62
63
|
system caller's audiences. Withdrawing a grant removes it from its own level only.
|
|
63
64
|
|
|
65
|
+
## `not` and the closing pattern
|
|
66
|
+
|
|
67
|
+
`not` is an audience term: `available for Plus and not Incident` and `available for not Incident`, also on the
|
|
68
|
+
`for` line of an `availability` block. `not` binds tighter than `and`, then `or`, and applies to **one audience name**.
|
|
69
|
+
|
|
70
|
+
- It is three-valued. `not` of an unknown audience is unknown, so the part stays closed (**unknown never opens a gate**).
|
|
71
|
+
A part is closed for a *granted* audience: grant an `Incident` audience to close it, withdraw the grant to reopen it.
|
|
72
|
+
Do not list every other audience to simulate a negation.
|
|
73
|
+
- `PLAY1171` (error): `not` on a group (`not (Plus)`), on another `not`, on nothing, or on an availability in
|
|
74
|
+
`available with` (`with not Open`).
|
|
75
|
+
- `PLAY1139` skips any gate that contains `not`, as it skips `when`: it depends on grants the model cannot see.
|
|
76
|
+
- A negated audience is ESM v58 (`"negated": true` on the audience requirement). A model without `not` keeps its earlier version.
|
|
77
|
+
|
|
78
|
+
## Screen elements
|
|
79
|
+
|
|
80
|
+
An element bound to a command or a query is offered only when the part is available and the caller is authorized.
|
|
81
|
+
That is **derived**; write nothing for it. The path is suspension first, then the module, feature, slice and construct
|
|
82
|
+
gates, then `authorize`.
|
|
83
|
+
|
|
84
|
+
- `available for | when | with` is allowed under a screen `action` (plain, not guarded) and a screen `data` directive,
|
|
85
|
+
one form per line. Elements with nothing bound (section, table, summary, component) take no gate.
|
|
86
|
+
- **An element gate can only narrow.** It is added to the derived path. `PLAY1172` (warning) reports a gate that can be on
|
|
87
|
+
while the bound part is not; narrow or remove it.
|
|
88
|
+
- Availability of an element is asked with the data the screen shows (for example the one vessel), not only the tenant and user.
|
|
89
|
+
- An element gate is ESM v59 (`"available"` on a screen `data` entry and `action`, written only when present).
|
|
90
|
+
- The reference evaluator reports everything available unless `SemanticScreenAvailability.Evaluate` is given a
|
|
91
|
+
`SemanticAvailabilityState` (audiences and suspended parts). A result carries a `Cause`: `NotAuthorized`,
|
|
92
|
+
`NotAvailable` or `Suspended`. `when` conditions stay undecided there. Specifications still run with everything available.
|
|
93
|
+
|
|
94
|
+
## Suspension
|
|
95
|
+
|
|
96
|
+
An operator can suspend any module, feature, slice or part (command, read model) for a tenant, a user or the system,
|
|
97
|
+
and resume it. **The model declares nothing for this**; do not add an audience or a flag to simulate it.
|
|
98
|
+
|
|
99
|
+
- The reason is `Suspended`, distinct from `NotAvailable` (same 403; clients tell them apart by reason).
|
|
100
|
+
- It is checked **first**, before gates (so before audiences and context values resolve) and before `authorize`.
|
|
101
|
+
A suspension at any level wins over every grant (deny wins); suspending a module or feature suspends what is beneath it.
|
|
102
|
+
- Levels are tenant, user and system; the newest decision per level and path wins, so a later resume ends an earlier
|
|
103
|
+
suspension at the same level only.
|
|
104
|
+
- **Two pairs of verbs, kept apart:** audiences are **granted and withdrawn**; parts are **suspended and resumed**.
|
|
105
|
+
The events are `PartSuspended` and `PartResumed`. Never name one `TenantSuspended`; that belongs to another product.
|
|
106
|
+
|
|
64
107
|
## Rules the language holds
|
|
65
108
|
|
|
66
109
|
- **Unknown never opens a gate.** A missing audience, a missing value, an unresolved condition or an
|
|
@@ -75,6 +118,7 @@ module Fleet
|
|
|
75
118
|
the tenant's and system's audiences, never a user's.
|
|
76
119
|
- **Persona `audience` lines are authoring only.** `audience Plus` under a `persona` tells the board, Studio
|
|
77
120
|
and docs which audiences the persona is in. It changes nothing at runtime and is not in the executable model.
|
|
121
|
+
- **Suspension is not a gate.** It is runtime state, never in the model and never in a specification.
|
|
78
122
|
- **Cross-slice warning (PLAY1139).** A screen action, form or reaction that `invokes` a command whose audiences
|
|
79
123
|
can be off while the invoker's are on can be refused as not available. Align the audiences, or accept and say
|
|
80
124
|
why. `when` conditions are opaque and skipped, never guessed.
|
|
@@ -136,7 +180,9 @@ Read [complete example](references/complete-example.md) for a model that compile
|
|
|
136
180
|
## Who owns what
|
|
137
181
|
|
|
138
182
|
Read [runtime ownership](references/runtime-ownership.md) when a request asks where a gate is enforced, how
|
|
139
|
-
audiences are granted, or whether application code can check one.
|
|
183
|
+
audiences are granted, how parts are suspended, or whether application code can check one. The engine lives in Arc
|
|
184
|
+
(`Cratis.Arc.Availability`); for the typed C# declaration, see the Arc hosting skill's
|
|
185
|
+
[availability reference](../cratis-arc-hosting/references/availability.md).
|
|
140
186
|
|
|
141
187
|
## Review checks
|
|
142
188
|
|
|
@@ -146,7 +192,8 @@ Read [review checks](references/review-checks.md) before accepting a model that
|
|
|
146
192
|
|
|
147
193
|
PLAY1119-1129 are `provide` (line shape, source, body, duplicates, reserved names, type override, query source, cycle).
|
|
148
194
|
PLAY1130-1141 are `audience`, `availability` and `available` (shape, duplicates, undeclared, cycle, unprovided value,
|
|
149
|
-
cross-slice invocation, gate tokens and parentheses).
|
|
195
|
+
cross-slice invocation, gate tokens and parentheses). PLAY1171 is a misplaced `not`; PLAY1172 is an element gate broader
|
|
196
|
+
than the bound part. The full table is in the toolchain
|
|
150
197
|
[diagnostics](../cratis-screenplay-toolchain/references/diagnostics.md).
|
|
151
198
|
Fix by changing the model: declare the audience, name the availability, provide the value or correct the key; never remove a
|
|
152
199
|
gate to silence a warning.
|
|
@@ -26,6 +26,10 @@ with the construct address and the change to ask for; do not edit the model in a
|
|
|
26
26
|
carries Chronicle's routing audience as a field.
|
|
27
27
|
8. **Entitlements.** A package already enforced by Box Office modules is not also modeled as an audience unless
|
|
28
28
|
the model deliberately reads a host value.
|
|
29
|
+
9. **`not` use.** Each `not` negates one audience name and a granted audience (such as `Incident`) is what closes the part;
|
|
30
|
+
PLAY1171 is an error. A list of every other audience instead of `not` is a smell. `not` of an unknown audience stays closed.
|
|
31
|
+
10. **Screen element gates.** A gate on a screen `action` or `data` only narrows the derived path of the bound part; PLAY1172 means it
|
|
32
|
+
is broader. Elements with nothing bound take no gate. Nothing models suspension (no audience, flag or command for it).
|
|
29
33
|
|
|
30
34
|
## Provided values
|
|
31
35
|
|
package/package/corpus/skills/cratis-screenplay-availability/references/runtime-ownership.md
CHANGED
|
@@ -9,9 +9,8 @@ writes enforcement code and an application never calls the pieces below.
|
|
|
9
9
|
| Piece | Owns |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| Screenplay | The language: `audience`, `availability`, `available`, `provide`, their diagnostics, and the reference evaluator (every gate available in specifications; opaque sources unsupported) |
|
|
12
|
-
|
|
|
13
|
-
| Showrunner GuestList | The audience contracts: public events that grant and withdraw an audience at tenant, user and system level, payload field `Audience`; the newest grant wins and a withdrawal removes only its own level |
|
|
14
|
-
| Arc | Enforcement at the command and query boundary, before authorization, refusing with `NotAvailable` |
|
|
12
|
+
| Arc (`Cratis.Arc.Availability`) | The engine and the enforcement. Evaluates an availability for a request: Available, Unavailable with a reason (`NotAvailable` or `Suspended`), or Unknown, which denies. A failure to decide is an error result, never a denial. Context values are resolved lazily, once per request. Enforces at the command and query boundary, before authorization. Needs no ASP.NET: `arc.WithAvailability()` for an Arc host, `AddAvailability` for any other. Choreography's availability is an obsolete forwarder to Arc's |
|
|
13
|
+
| Showrunner GuestList | The audience contracts: public events that grant and withdraw an audience at tenant, user and system level, payload field `Audience`; the newest grant wins and a withdrawal removes only its own level. Suspension decisions come from `PartSuspended` and `PartResumed` through Arc's `ISuspensionSource` |
|
|
15
14
|
| Stage | Renders and runs the admitted model with the engine; consumes it rather than owning it |
|
|
16
15
|
| Direct | Not called by an application. Box Office module entitlements stay separate and unchanged |
|
|
17
16
|
|
|
@@ -19,6 +18,7 @@ writes enforcement code and an application never calls the pieces below.
|
|
|
19
18
|
|
|
20
19
|
- The model declares audiences and never members. Do not add a membership event or a grant command to the
|
|
21
20
|
model to simulate GuestList; granting is the runtime's job.
|
|
21
|
+
- Do not model suspension: no audience, flag or command. Suspension is operator state, checked first, and wins over every grant.
|
|
22
22
|
- Chronicle's routing audience stays in event options and is never a field of an event.
|
|
23
23
|
- A union of audiences comes from tenant, user and system levels; a reaction sees the tenant's and system's only.
|
|
24
24
|
- Decide a hidden entry from `NotAvailable`, not from guessing the package in client code.
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
{ "kind": "skill-contains", "value": "PLAY1139" },
|
|
12
12
|
{ "kind": "skill-contains", "value": "$context.identity.claims.aud" },
|
|
13
13
|
{ "kind": "skill-contains", "value": "PLAY1124" },
|
|
14
|
+
{ "kind": "skill-contains", "value": "PLAY1171" },
|
|
15
|
+
{ "kind": "skill-contains", "value": "PLAY1172" },
|
|
16
|
+
{ "kind": "skill-contains", "value": "`PartSuspended` and `PartResumed`" },
|
|
17
|
+
{ "kind": "skill-contains", "value": "granted and withdrawn" },
|
|
18
|
+
{ "kind": "skill-contains", "value": "An element gate can only narrow" },
|
|
19
|
+
{ "kind": "skill-contains", "file": "references/runtime-ownership.md", "value": "Cratis.Arc.Availability" },
|
|
14
20
|
{ "kind": "skill-contains", "file": "references/runtime-ownership.md", "value": "Showrunner GuestList" },
|
|
15
21
|
{ "kind": "skill-contains", "file": "references/review-checks.md", "value": "A gate no persona can satisfy" },
|
|
16
22
|
{ "kind": "skill-contains", "file": "references/review-checks.md", "value": "A rule reading identity-derived values" }
|
|
@@ -155,7 +155,7 @@ P5 uses a fresh reviewer who authored nothing in scope; record reviewer/author m
|
|
|
155
155
|
|
|
156
156
|
## Availability and context pass
|
|
157
157
|
|
|
158
|
-
For a model with `available` or `provide`, check: a gate no persona can satisfy, unreferenced or undeclared audiences, a gate used as authorization (or the reverse), a `provide` whose key cannot be resolved for a command, a rule reading identity-derived values,
|
|
158
|
+
For a model with `available` or `provide`, check: a gate no persona can satisfy, unreferenced or undeclared audiences, a gate used as authorization (or the reverse), a `provide` whose key cannot be resolved for a command, a rule reading identity-derived values, specifications that depend on a gate, a `not` that is misplaced (PLAY1171) or replaces a granted audience with a list, and a screen element gate that is broader than its bound part (PLAY1172). Read [review checks](../cratis-screenplay-availability/references/review-checks.md).
|
|
159
159
|
|
|
160
160
|
## Rules
|
|
161
161
|
- Compiler contracts (defects when the mode needs them): V1 must pass with warnings
|
|
@@ -257,7 +257,9 @@ choosing a whole action list rather than one labeled command, use block-form
|
|
|
257
257
|
`when`/`otherwise` on click, double click, select or change:
|
|
258
258
|
[guarded interactions](../cratis-screenplay-ui-composition/references/guarded-interactions.md).
|
|
259
259
|
|
|
260
|
-
`available` and `provide`: `cratis-screenplay-availability`.
|
|
260
|
+
`available` and `provide`: `cratis-screenplay-availability`. A screen `action` or `data` bound to a command or query is offered only when the
|
|
261
|
+
bound part is available and the caller authorized; that is derived. An explicit `available` line under it (ESM v59) can only narrow
|
|
262
|
+
(PLAY1172 when broader); a section, table, summary or component takes none.
|
|
261
263
|
|
|
262
264
|
## How a bare name resolves
|
|
263
265
|
|
|
@@ -391,7 +391,9 @@ Requires Screenplay 6.26.0. Errors fix the line; warnings leave the gate closed,
|
|
|
391
391
|
| PLAY1137 | break the `with` cycle |
|
|
392
392
|
| PLAY1138 | W: provide the value at or above the gate, or change the condition |
|
|
393
393
|
| PLAY1139 | W: align the audiences of invoker and command, or accept the refusal; `when` is skipped, reactions are never gated |
|
|
394
|
-
| PLAY1140, PLAY1141 | an `available for`/`with` line holds names, `and`, `or` and balanced parentheses only |
|
|
394
|
+
| PLAY1140, PLAY1141 | an `available for`/`with` line holds names, `and`, `or`, `not` and balanced parentheses only |
|
|
395
|
+
| PLAY1171 | `not` applies to one audience name: not on a group, another `not`, nothing, or an availability in `with`; a negated audience is ESM v58; `PLAY1139` skips a gate containing `not` |
|
|
396
|
+
| PLAY1172 | W: a screen `action`/`data` gate is broader than the bound command or query; narrow it or remove it (element gates are ESM v59) |
|
|
395
397
|
|
|
396
398
|
See `../../cratis-screenplay-availability/SKILL.md`.
|
|
397
399
|
|