cratis-screenplay-automations-and-translations
Model Screenplay Automation and Translate slices: when a reaction is warranted, todo-list work queues, produces versus invokes, the trusted actor behind caller-less invokes, termination, clock and trigger occurrences, outside facts via capture with correlation, dedup and enrich/ignore/infer, recovery ownership, and what once-only does not prove about external effects. Use when a model has or needs 'when X happens then ...', schedules, work queues, webhooks, API polls, message feeds or imported events. Not for: reaction, trigger or capture grammar (use `cratis-screenplay-captures-and-reactions`).
- License 许可
- MIT
- 所属仓库
- Cratis/Prologue
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cratis-screenplay-automations-and-translations
- license
- MIT
- description
- Model Screenplay Automation and Translate slices: when a reaction is warranted, todo-list work queues, produces versus invokes, the trusted actor behind caller-less invokes, termination, clock and trigger occurrences, outside facts via capture with correlation, dedup and enrich/ignore/infer, recovery ownership, and what once-only does not prove about external effects. Use when a model has or needs 'when X happens then ...', schedules, work queues, webhooks, API polls, message feeds or imported events. Not for: reaction, trigger or capture grammar (use `cratis-screenplay-captures-and-reactions`).
02 资源文件 18
- 资产文件assets/pending-certificates.play514 B
- 资产文件assets/retry-sweep.play533 B
- 许可证LICENSE2.3 KB
- 参考文档references/audit-format.md3.9 KB
- 参考文档references/automation-patterns.md11.9 KB
- 参考文档references/cases-to-specify.md7.4 KB
- 参考文档references/effects-and-idempotency.md7.1 KB
- 参考文档references/integration-contracts.md7.1 KB
- 参考文档references/integration-interview.md1.6 KB
- 参考文档references/neighbouring-skills.md865 B
- 参考文档references/product-sources.md771 B
- 参考文档references/provenance.md5.7 KB
- 参考文档references/public-events-and-direction.md9.4 KB
- 参考文档references/realization-and-gap-fill.md4.6 KB
- 参考文档references/todo-list-example.md9.6 KB
- 参考文档references/translate-example.md6.0 KB
- 参考文档references/translation-patterns.md6.9 KB
- 参考文档references/worked-integration.md7.5 KB
03 SKILL.md 正文
<!-- cratis-ai-managed: skills/cratis-screenplay-automations-and-translations/SKILL.md -->
Automations and translations
Purpose
Decide which work the system does on its own, which outside facts it accepts, and what that work
guarantees. Then write it as Automation and Translate slices that say truthfully what is
protected, what is only recorded, and who acts. Grammar depth is in
cratis-screenplay-captures-and-reactions; this skill owns the decisions.
Translation crosses an application boundary: private-to-private follow-up is
Automation, even if a reactor realizes it. Keep captures in Translate and reactions
to their local facts in separate Automation slices. Read
public events and direction when
choosing direction, folding events or specifying publication: it owns the ESM v9
forms, PLAY0616 and directionless Translate's PLAY0694 split boundary.
Requires Screenplay 4.176.0 or later (screenplay --version) for PLAY0694; older compilers leave that directionless shape unchecked.
One source events capture reads one origin (event store); split several origins.
Requires Screenplay 4.155.0 (screenplay --version) for PLAY0687; older tools leave it unchecked.
Model behavior first; code implements external calls, adapters, actors and refused
target scope. Follow cratis-screenplay-modeling-lifecycle for session discipline
and cratis-screenplay-toolchain for verdicts. Settle input, identity, effect and
pending-work contracts when changing each reaction/capture, not at final review.
Tool and realization facts (read before promising anything)
- V1, V3, V4 and target rendering are separate; name the compiler and never remove
a refused construct. Run
screenplay testor MCPrun-specificationsfor V4. - Read realization and gap-fill before promising Automation/Translate delivery (STAGE-ESM-024).
- Invokes have no caller without
runs as. Read captures-and-reactions invocation identity for the ESM v10 actor and role/authenticated versus claim/opaque admission.
Atomic production boundaries and source identity
Start new models with application-root reaction batches atomic (ESM v22 or later).
Each trigger occurrence's direct productions and each selected refusal branch are
separate all-or-none batches; invoked commands remain independent. Absence retains
legacy per-fact behavior even at later versions. Assert no failed-batch facts and
unchanged views, not only then error. Requires Stage 4.139.0 for v22 admission
(older: -016); atomic mode stays STAGE-ESM-043. Keep as gap-fill.
Read atomic batches and source mappings
when choosing these boundaries or mapping an invoked identifier from $eventSourceId
(or $eventContext.eventSourceId) instead of copying it into event payload.
Effect guarantees and recovery traps
| Guarantee | What it promises | What can show it |
|---|---|---|
| once-only fact | CertificateSent exists at most once for an enrolment |
constraint … unique event on the right stream + a violation spec |
| idempotent handling | asking again gives the caller the same outcome, no new effect | target behaviour (map "already has the event" to success where intended); the model shows a rejection |
| exactly-once external effect | the person receives one certificate, the card is charged once | nothing in the model; only the outside system's dedup or a reconciliation can |
A todo list + reaction + unique constraint proves the first. It does not prove the third: the send can succeed and the append fail (crash, lost reply, constraint race), and the retry sends again.
- A reaction cascade is not one transaction: earlier accepted facts stay when a later invoked
command rejects (Screenplay
reactions.md). Design each step to be retried on its own. - Read
references/effects-and-idempotency.mdwhen specifying redelivery,then no eventsor refusal disposition; execution is not external deduplication. - Replay and recovery redelivery are different. Chronicle
[OnceOnly]skips replays (rewind, redaction, revision) only, not ordinary catch-up, repeated same-source events or crash redelivery. Recovery runs the handler normally. It is not a per-source run limit or deduplication. A receipt keyed byReactorDelivery.Ididentifies the retry. Name both.
Capture data-protection traps
A field left out of map still passes through the capture's working record: omission is not
redaction. Check the append mappings and every resulting event property, and record whether
the target stores raw or last-seen source records and how they are minimized.
Personal data kept in events needs bare pii on its concept and a declared purpose
(see command-surface references/compliance.md); keep the marker
even when it blocks binding. Never record bearer tokens, magic links or signed URLs as facts
(a keyed hash or reference at most), and never put PII on the event-source id.
Product sources
Read references/product-sources.md when checking a claim against the Screenplay, Stage, Arc or Chronicle sources.
Requires Screenplay 4.125.0 or later (screenplay --version) for reaction runs as system role (ESM v10).
Requires Arc 20.56.0 or later for [ExecuteCommandsAsSystem].
Requires Arc 22.72.0 or later for a reactor that returns events and commands together; before it, a mixed return is not handled. Stage still refuses a reaction that both produces and invokes (STAGE-ESM-037), so a mixed reaction stays authorized gap-fill whatever the Arc release.
Requires Screenplay 4.105.0 or later (screenplay --version) for list queries (=> Item[]); before it a list query is refused with PLAY0268.
Requires Screenplay 4.124.0 or later (screenplay --version) for --check privilege (PLAY0652).
Read SKILL.md in cratis-screenplay-toolchain when selecting a tool; read the installed versions with screenplay --version and cratis --version. Reverify before claiming
another version behaves the same.
When / when not
- Use: "when X happens, then ...", schedules, retries, work queues, notifications, webhooks, APIs, files or message feeds, events imported from another context, legacy sync.
- Not for: reaction, trigger or CDL grammar (
cratis-screenplay-captures-and-reactions); stream identity and invariants (cratis-screenplay-streams-and-consistency); UI interactions such ason click(cratis-screenplay-ui-composition); hand-written reactors (cratis-chronicle-reactor).
Interview phase
Skip if the user already gave: every external system with its record types, a sanitized sample of each, and how each record finds our entity (the correlation strategy); and for automations, the occurrence, the effect and who acts. Cite existing answers instead of asking again. Missing correlation is the most common cause of failed integrations: surface it first.
Read integration interview prompts when sources, mapping, automation ownership or recovery are unsettled. Ask one group at a time; treat "unsure" as an open question.
Unattended: assume visibly. Record each assumption as a labelled open decision in STATE.md
(.ai-work/screenplay/<model-slug>/STATE.md), mark the dependent slice open, never write a mapping
or actor that nobody confirmed. Read references/worked-integration.md when you need a transcript-shaped example of the integration interview, correlation, translation rules, scenarios, and recovery output.
Procedure
- Inventory. List every reaction, trigger and external source/type in scope; read their
declarations, mappings, descriptions and specs. For integrations resolve only the unknowns
(
references/integration-contracts.md). - Is it an automation? Write four lines: occurrence (event, clock, application trigger), state
consulted, condition, effect. Always fires, consults nothing, cannot fail, touches nothing outside:
co-production, the command produces both facts. Otherwise continue (
references/automation-patterns.md; a process with waits, approvals, compensation or fan-out: its §10). - Queue or direct? A todo list (a read model whose membership is the pending work) when work can wait, retry, fail or need people. Name each opening and closing fact (result, cancellation, supersession), the work-item key and the recovery path. Direct reaction only for an immediate, internal, always-possible effect; say why no pending state is needed. A translation is not automatically infallible.
- Effect and actor.
produces <Fact>records a decided fact;invokes <Command>requests a decision. Keep its gate and declare the trusted role with reactionruns as system role "<Role>"(ESM v10). An undeclared actor remains caller-less. CLI/Stage realization is a separate gap; a returned-command reactor uses[ExecuteCommandsAsSystem("<role>")]and the matching policy. Never strip a gate or supplygiven calleras a fictional reaction identity. Arc supplies a system principal only to reactors marked[ExecuteCommandsAsSystem]; without it there is no principal and[Authorize]/[Roles]deny.runs ascovers returned or invoked commands, not imperative pipeline calls, reads, productions or causation. Run--check privilege --warnaserror(PLAY0652) for confused-deputy paths: every trigger-event producer must require all declared system roles. Ungated commands/captures/reaction productions warn; opaque gates are information, not proven safe. An OR alternative does not require a role. Clock/application triggers have no producer and are silent; still review trust. - Trace inputs. Every trigger value, command input, event property and destination needs a supported source; every filter a business reason. Gaps are questions, not invented mappings.
- Repetition and termination. Identify one logical work occurrence and what a retry is. Guard the
result fact with
constraint ... unique eventon the right stream only when once per source is the rule. Name what ends each chain and check cycles. Answer separately how the external effect avoids repeating and how replay differs from recovery redelivery (references/effects-and-idempotency.md). - Translate outside facts (
references/translation-patterns.md): enter only viacaptureor a translator reaction, in aTranslateslice; correlate first; keep the external fact distinct from ours; trace source fields and every required target field; decide dedup, ordering and recovery ownership. A reaction to a capture's local fact is a separate Automation, not a second job inside Translate. A worker after translation needs a distinct local decision, obligation or effect. - Specify and audit. Work through
references/cases-to-specify.mdper declaration and hand the named cases tocratis-screenplay-scenario-coverage. Produce the audit inreferences/audit-format.md.
Rules
Compiler contracts (diagnostics)
- No inline
produces eventin a reaction (PLAY0474); declare reaction-produced events in the slice. - Effects sit under a trigger;
description,whereand currentruns asare reaction-level; onewhereper reaction (PLAY0252); a trigger may not repeat (PLAY0253). - Clock triggers take no values (PLAY0450) and no
byon reads (PLAY0443).for each <View>is reserved, not available. - Capture
whencannot mixandandor(PLAY0089). A capture withoutkeydoes not bind. - For
source events,keyis a required property on everyfromevent (PLAY0700); specs supplygiven <Event>/when append <Event>, not capture records (PLAY0701). - First sight is
addedonly. Usewhen addedseparately for initial facts; seed record updates withgiven captureof the same key. Read captures-and-reactionsreferences/record-capture-specifications.mdfor the prerequisite and child/nested rules. - Current V1 warns on undeclared capture/removal events (PLAY0166); V3 remains a separate binder check.
- A trigger with
readsthatproducesdirectly fails binding: decide in a command. Command reads can protect withcommand reads protectedand admitted shapes (v25); trigger reads cannot. Stage 4.138.0 renders protected reads as Arc read protection (cratis rendergets it from the first CLI that bundles it; CLI 3.75.0 refuses them with STAGE-ESM-044); semantic execution is separate from generated-app protection. - An authorized command exercised in a spec without
given calleris PLAY0389 at binding. - A list query (
=> Item[]) binds (a snapshot list is not rendered,STAGE-ESM-010); a clock sweep that iterates items needs a code body the reference does not run (references/todo-list-example.md).
Modeling defaults (deviate with a recorded reason)
- A
produceswithoutforlands on the triggering fact's source; clock and trigger occurrences have none, so givefor(a carried value or a literal). whereguards every trigger of the reaction and must resolve from each trigger's values: give a clock sweep its own reaction.- Malformed or unmappable input becomes a recorded failure fact or dead-letter view, never a dropped
record. A fan-out records one outcome per item; partial success is failure at an effect boundary
(
cratis-engineering-effect-boundaries), never a batch "done" while members failed. - Infrastructure (logging, caching, retries, outbox plumbing) is never a Translate slice.
- Personal data kept in events needs
piion its concept; keep it even when it blocks binding or render. - Code bodies (
file, inline fences) document realization; no local engine runs them.
Review questions
- What stops this from running twice? Forever? When the external call times out?
- Who is the actor, and could an outsider reach the invoked command?
- What does a person see while the work is pending or failed?
- What happens if the outside fact arrives before ours, twice, out of order, or changed?
Gate
Not done until, for every affected reaction and capture, there is a line in the audit
(references/audit-format.md) with a location and a result of complete, open or blocked, and any
unreviewed scope is named. Open decisions and target requirements are in STATE.md. A missing required or
referenced queue opening or closing fact is an unresolved dependency, never skipped silently; a
direct effect states "not applicable: no queue" with its reason (per-chain questions in
references/audit-format.md).
Never report a verdict without the tool and version that produced it.
Verify
- V1 and V3 per
cratis-screenplay-toolchain, each with tool and version. When the bundled compiler stops before v6, report "V3 blocked: PLAY0268 (ESM v6)". Current admitted scenarios use standalonescreenplay test/MCP for V4; unsupported or unbound is not passed. - For each external source and type: its translation, or an explicit out-of-scope reason; check target-field completeness as well as source-field dispositions.
- One happy path is not coverage: cite the spec or the missing case for each branch, denial, competing claim and closing event.
- Every complete example compiles. Read
references/todo-list-example.mdwhen modeling a pending-work automation (its design-only excerpts insert intoassets/pending-certificates.playandassets/retry-sweep.play), andreferences/translate-example.mdwhen modeling capture plus translator reactions.
Route near misses
Read references/neighbouring-skills.md when the work is grammar, streams, specifications, rendering, legacy writes or hand-written reactors.
Lineage
Read references/provenance.md when checking sources, adaptations, attribution, or approaches deliberately not adopted.
04 同仓库更多 Skills
vectorization
Designs, implements, optimizes, and reviews SIMD code in .NET: vectorizing scalar loops with TensorPrimitives, Vector64, Vector128, Vector256, Vector512, or hardware intrinsics, and reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. Use when a .NET loop or SIMD routine is being written or reviewed. Not for performance work unrelated to SIMD.
target-authoring
Canonical patterns for writing custom MSBuild targets: DependsOnTargets versus BeforeTargets and AfterTargets, the Build-to-CoreBuild three-level pattern, and the XxxDependsOn chain-extension pattern. Use when diagnosing or fixing custom-target anti-patterns: Directory.Build.targets redefining SDK targets, targets that replace CompileDependsOn instead of extending it, Outputs versus Returns misuse that returns stale results, missing Inputs/Outputs causing needless rebuilds, or missing FileWrites registration. Not for incremental build tuning or general anti-pattern review (use the msbuild skill), or non-MSBuild build systems.
run-tests
Chooses and runs the repository-compatible .NET test command: classic, VSTest, bridged MTP, or native MTP syntax for MSTest, xUnit, NUnit, and TUnit. Use before running .NET tests or answering with a test command or flags: run the tests, one test, class, category, trait or target framework, combined filters, --filter-query, --no-build, --diag, TRX, coverage collection, crash or hang dumps, filter errors, or unrecognized options. Not for platform identification alone (use platform-detection), writing or debugging test code, interpreting a coverage report (use coverage-analysis), CI investigation, migration, or a persistent hot-reload loop.
profiling
Uses the free official .NET diagnostics CLI tools for profiling and runtime investigation in a repository: CPU, GC pressure, allocation growth, exception storms, lock contention, and slow code. Use when a .NET application needs performance or runtime profiling. Not for replacing realistic performance or load tests with ad-hoc tracing, production heap collection without a pause-risk plan, crash dumps (use dump-collect), or benchmark design (use microbenchmarking).
platform-detection
Identifies a .NET project's test platform, framework, command mode, and SDK-style versus classic project system, resolving global.json, project, packages.config, Directory.Build.props, and Directory.Packages.props precedence for MSTest, xUnit, NUnit, and TUnit. Use when asking "which test platform or framework?", "VSTest or MTP?", or "what runner does this project use?", including bridge settings, UseVSTest opt-outs, and conflicting VSTest/MTP configuration. Not for running or filtering tests, commands, flags, TRX, dumps, or test-command errors (use run-tests), or for hot-reload or migration requests.
orleans
Designs Microsoft Orleans systems from each primitive's purpose and failure model: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. Use when a task needs an Orleans design decision: inspect version and topology, choose the primitive, implement, and validate. Not for other actor stacks, batch processing, relational-only CRUD, or advice without an Orleans decision.