A .NET 10 / C# 14 library for building event-driven business rule engines with JSON-based rule authoring.
These instructions apply to every task in this repository.
Work moves through PRD → issue → spec → implementation:
- PRD: a GitHub issue labelled
enhancementdescribing the feature (e.g. #1). - Phase issues: one issue per vertical slice, labelled
prd-phase, added to the PRD as a GitHub sub-issue (POST /repos/{owner}/{repo}/issues/{prd}/sub_issueswith the child's internalid, not its number). Ordering between issues uses GitHub "blocked by" links (.../issues/{n}/dependencies/blocked_bywithissue_id). Keep the plain-textParent PRD: #nand## Blocked bysections in issue bodies as well, so issues read correctly without the native links. - Spec: a design doc in
docs/specs/YYYY-MM-DD-<topic>-design.md, written before implementation. - Implementation: a branch and PR that closes the phase issue.
When the implementation diverges from the spec or the issue's acceptance criteria, record it before merging: add a ## Deviations section to the spec (what changed and why) and update the issue. Specs in docs/specs/ are the source of truth for design decisions.
- Never work directly on
main. Branch names follow release-please prefixes:feat/,fix/,refactor/,test/,chore/,docs/+ short description. - Use Conventional Commits — release-please derives versions and
the changelog from them. Use
feat!:or aBREAKING CHANGE:footer for breaking API changes (pre-1.0, breaking changes are acceptable but must be marked). - Keep commits small, focused, one logical change each. Prefer several commits over one large one.
- PRs target
main, use.github/PULL_REQUEST_TEMPLATE.md, and are squash-merged: the PR title becomes the single commit onmain, so it must be a Conventional Commit (feat!:if breaking). List breaking changes and their migration in the PR description.
dotnet build # entire solution (RuleLoom.slnx)
dotnet test # all tests
dotnet test --project tests/RuleLoom.Tests # unit tests
dotnet test --project tests/RuleLoom.Tests.Integration # integration tests
dotnet test --filter-class "RuleLoom.Tests.ScheduleCalculatorTests"
dotnet test --filter-method "*Resolve_Path*"
dotnet test --coverage --coverage-output-format cobertura --results-directory ./TestResultsTests use xunit v3 on Microsoft.Testing.Platform (opted in via global.json), not VSTest:
pass project paths with --project, and use xunit's --filter-class / --filter-method / --filter-query
(the VSTest --filter "FullyQualifiedName~..." syntax doesn't apply). Package versions live in
Directory.Packages.props (central package management); shared test settings in tests/Directory.Build.props.
Pass TestContext.Current.CancellationToken to methods that accept a token (analyzer xUnit1051).
CI (.github/workflows/ci.yml) runs restore, a Release build and tests (with TRX reports and Cobertura coverage
uploaded as artifacts) on every PR to main.
- Solution builds with no new warnings and all tests pass.
- Behavior changes have tests.
- No dead code, unused abstractions, or speculative extension points.
- Naming and structure match the surrounding code.
- Correctness
- Simplicity — no abstractions "just in case"; the simpler solution wins when in doubt
- Consistency with existing code
- Readability
- Extensibility — only when justified by a planned need
Evolve the existing code rather than rewriting it; don't refactor unrelated code in the same change.
| Project | Path | Role |
|---|---|---|
RuleLoom.Abstractions |
src/RuleLoom.Abstractions |
Contracts and models: what the engine runs (operators, actions, context providers), the Catalog and its registrations, action descriptors, the factory contracts. No dependencies outside RuleLoom.Schemas and .NET |
RuleLoom |
src/RuleLoom |
Default implementation: CatalogBuilder, engine, evaluator, operators, actions, direct factories, scheduling, validation, telemetry and logging (depends on Microsoft.Extensions.Logging.Abstractions) |
RuleLoom.Schemas |
src/RuleLoom.Schemas |
Descriptions: event schemas (EventSchema<T> classes), context schemas (ContextSchema<T>) and action parameters (ParametersSchema<T>), generated with System.Text.Json's JsonSchemaExporter, written/read as JSON Schema 2020-12 (x-ruleloom-*); the catalog document and store (CatalogDocument, ICatalogStore + InMemoryCatalogStore). No dependencies at all (not even Abstractions); producers and store packages use it without the engine; RuleLoom.Abstractions and RuleLoom reference it |
RuleLoom.Extensions.DependencyInjection |
src/RuleLoom.Extensions.DependencyInjection |
services.AddRuleLoom(r => r.AddCatalog(...).UseStore<T>()): the catalog (built at startup), engine, validator and factories |
RuleLoom.AspNetCore |
src/RuleLoom.AspNetCore |
app.MapRuleLoom(prefix): GET {prefix}/catalog and POST {prefix}/validate for authoring UIs; returns the route group; no storage |
RuleLoom.Tests |
tests/RuleLoom.Tests |
xUnit unit tests |
RuleLoom.Tests.Integration |
tests/RuleLoom.Tests.Integration |
xUnit end-to-end tests |
RuleLoom.Schemas.Tests |
tests/RuleLoom.Schemas.Tests |
xUnit tests of schema building and JSON |
RuleLoom.Extensions.DependencyInjection.Tests |
tests/RuleLoom.Extensions.DependencyInjection.Tests |
xUnit tests of DI registration (uses the real container) |
RuleLoom.AspNetCore.Tests |
tests/RuleLoom.AspNetCore.Tests |
xUnit tests of the endpoints over HTTP (Microsoft.AspNetCore.TestHost) |
RuleLoom.Samples.Console |
samples/RuleLoom.Samples.Console |
Usage sample: one web-shop scenario per file in Scenarios/ (dotnet run -- <n>), printed with Spectre.Console |
RuleLoom.Samples.AspNetCore |
samples/RuleLoom.Samples.AspNetCore |
Web sample: a shop API raising order events in-process, rules as JSON files, contexts, a subject loader, Quartz for scheduled actions, MapRuleLoom("/rules") and a demo page (wwwroot/index.html); folders by concern |
Namespaces follow folders: RuleLoom.Abstractions.{Action,Condition,Context,Rule,Scheduling,Values} and
RuleLoom.{Engine,Evaluators,Operators,Actions,Contexts,Scheduling,Validation} (there is no RuleLoom.Core);
Catalog (in RuleLoom.Abstractions) and CatalogBuilder (in RuleLoom) sit at the roots.
Versioning is from git tags via MinVer (Directory.Build.props); release-please creates the tags. Package metadata
is in src/Directory.Build.props (the package README is src/PACKAGE.md, the icon docs/assets/icon.png); when a
release PR merges, the publish job in release-please.yml packs, pushes to nuget.org (trusted publishing,
environment nuget) and attaches the packages to the GitHub release.
(RuleEvent, rules) → RuleEngineResult { Rules, HasFailures, ScheduledActions }
(the (eventType, current, previous, rules) overloads are a RuleEvent without envelope data)
→ rules with another EventType are not included
→ order by Priority descending (higher runs first); cancellation checked before each rule and action
→ per rule (RuleExecutionResult with RuleId, RuleName, Status, Error, ActionResults):
condition throws → Failed (Error set, no actions) condition false → NotMatched true → Matched
→ per action (ActionResult stamped with ActionName and ActionIndex by the engine):
action condition throws → Failed (only this action; later actions still run)
action condition false → Skipped
Schedule with Mode != Immediate → ScheduleCalculator → due ≥ now: Scheduled (executor NOT called; listed in
ScheduledActions as a keyed reference) / due < now: runs now, or
Skipped when overdue (RuleEngineOptions) / calculation error → Failed
action name not in the catalog → Failed
otherwise → IActionFactory.Create(registration).ExecuteAsync → its ActionResult
(factory or action exception / null result → Failed)
→ event types not in the catalog still run (the catalog describes; it doesn't gate execution)
ExecuteScheduledAsync(ScheduledAction, storedEvent, rules) → ActionResult (stamped with ActionName/ActionIndex)
→ rule by RuleId (and event type) missing → Skipped action at ActionIndex renamed or unscheduled → Skipped
→ overdue (now − ScheduledFor > OverdueGracePeriod, with SkipOverdueActions) → Skipped
→ the due context: with Subject(...).LoadedBy(p) the provider loads the subject (reference = identity resolved on the
stored event; null → Skipped; load error or unregistered loader → Failed): $current = subject now, $previous =
the stored event's previous, $event = the stored envelope; without a loader, the stored event
→ contexts prefetched fresh; rule condition false → Skipped / throws → Failed; action condition likewise
→ the rule's current action runs (same failure rules as above) → Executed
→ failures are reported in the result, never written to the console;
OperationCanceledException always propagates (partial results are discarded)
- Catalog (
Catalog, glossary inGLOSSARY.md, decisions indocs/adr/): the immutable vocabulary rules are written in: event schemas (keyed byEventKey(scope, eventType), both ignoring case; spec2026-11-29-scope-design.md), with the contexts they declare, context provider registrations (name, type, schema), operator instances and action registrations (name, type, label, description). Built byCatalogBuilder(Build(), orBuildAsync(ICatalogStore): code plus the store's event/context schemas, code wins, saved back with upserts); theCatalogconstructor enforces the invariants: broken links in code throw (duplicate names, unusable operator/action names, a declared context without a provider, aReferencedBypath that isn't a field), the same in stored entries becomeProblemsthat fail only the rules using them.TryGetEvent(EventKey),TryGetContextProvider/Operator/Action/Variable,TryGetContext(EventKey, name)(only declared contexts),ToDocument()/ToDocument(scope)/ToJson()for UIs and stores. A rule runs on an event whenEventKey(rule.Scope, rule.EventType)equals the event's; scopes are set per producer (SchemaCollection.UseScope,CatalogBuilder.UseScope) and carried byRuleEvent.Scope/ContextRequest.Scope. Registration is separate from invocation: the engine finds names in the catalog and asks anIActionFactory/IContextProviderFactorytoCreate(registration); factories never resolve names. - Conditions are trees of
ConditionNode:OperatorCondition(operator name + operands),PathOperand,ValueOperand. Built-in operators:eq,changed,and,or,not,gt,gte,lt,lte. - Names ignore case (
OrdinalIgnoreCase): operator names, action names, event types and property path segments (exact-case property match wins; ambiguous case-insensitive matches resolve tonull). Operator, action, provider or event names that differ only in case fail the catalog's build. String values stay case-sensitive. - Paths are parsed once by
RulePath(KindVariable/Context,Name,Property,InCurrentState()/InPreviousState(); variable paths hold an internalRuleVariable(CurrentVariable,PreviousVariable,EventVariable: a closed set that carries each variable's resolution, state links and fields, listed asCatalog.Variables); cached; the only place that knows the syntax: never split path strings elsewhere) and resolve viaPathResolver(compiled, cached expressions):"Price"= current,"$current.Price"/"$previous.Price"explicit; operators pick a state the same way (ctx.Resolve("$previous.Price")).$event.reads the envelope byRuleEvent's properties (EventPaths: resolved like any object, plus a key step for theMetadatadictionary; the validator describes the envelope from the type, so new properties need no list updates;nullwithout aRuleEvent; no state, so$previous.$event/changedon it are errors; metadata keys aren't checked). Other$names are reserved (the parser rejects them);current./previous.without$are plain property names. Missing properties and paths through anullresolve tonull; a throwing getter throwsInvalidOperationExceptionnaming the path (failing only what reads it). A cached entry compiles the longest prefix resolvable on declared types; the rest continues on the runtime value: JSON state (JsonElement/JsonNode, walked by the internalJsonPathWalker, leaves mapped tostring/bool/long/decimal/double, objects and arrays returned as JSON) or a more specific CLR type (properties declared asobject/interfaces/base types). APreviousState.FromChanges(current, changes)passed as the previous state is an overlay: paths are looked up in the JSONchanges(old values of changed fields) first, then incurrent.#paths are reserved for functions. - Event envelope (
RuleEventinRuleLoom.Abstractions; spec2026-10-29-rule-event-and-scheduled-actions-design.md):EventType,Current,Previous, plusScope,Tenant(opaque; part of scheduled-action keys andContextRequest.Tenant; spans only in telemetry; never in rule JSON),EventId,Subject,Source,OccurredAt,Metadata(app-defined).RuleEngine.ExecuteAsync(RuleEvent, rules);EvaluationContext.Event(fromnew EvaluationContext(ruleEvent, catalog, providers)) andContextRequest.Event.ToJson()/Parse(json): camelCase, state as JSON (JsonElementafter parsing), previous state aspreviousorchanges(PreviousState.FromChanges),occurredAtmust state its offset. Deduplication byEventIdis the app's. - Contexts:
@name.Pathreads related data the event's schema declares (Context("name"), loaded by the provider registered underLoadedBy(...)or elsename;CatalogBuilder.AddContextProvider<T>(name)). Undeclared contexts, and contexts on event types not in the catalog, fail the rules that use them. TheEvaluationContextresolves the declaredReferencedByon the current state and passes it asContextRequest.Reference(GetReference<T>(); null without one); providers are created per load by theIContextProviderFactory. The engine prefetches the contexts its rules use (conditions, action conditions, schedule reference paths,$pathparameters; collected byContextReferences) once per event, in parallel, into theEvaluationContextcache; actions useGetContextAsync(name). A failed load throwsContextLoadExceptionwhen resolved, failing only the rules that use it. Contexts have no previous state ($previous.@xis a parse error;changedon a context throws). - Actions are referenced in rules as
"action": "<name>"(ActionDefinition.Action), found in the catalog and created by anIActionFactory(DirectActionFactoryfor non-DI use: added instances by type, else a parameterless constructor). Names belong to the registration:ActionNames.GetDefaultName(type)gives[ActionName]or the class name minus anActionsuffix in kebab-case;AddAction<T>(name)overrides it. Built-in action:console-log(ConsoleLogAction, for development; not added by default). - DI (
AddRuleLoom): one sharedCatalogBuilderper service collection (AddCatalog(c => ...), callable repeatedly);UseStore<T>()(Scoped) /UseStore(instance). The catalog is built at startup by a hosted service (orserviceProvider.StartRuleLoomAsync()without a host) into an internal holder;Catalog,IActionFactory/IContextProviderFactory(ActivatorUtilities.GetServiceOrCreateInstance: registered services as registered, others created with scope dependencies and not disposed by the scope),RuleEngineandRuleValidatorare Scoped; resolving them before startup throws. - Observability (spec
2026-10-29-observability-design.md, guidedocs/guides/observability.md):ActivitySourceandMeternamedRuleLoomDiagnostics.Name("RuleLoom") in bothRuleLoom(EngineTelemetry:ruleloom.execute,ruleloom.execute_scheduled,ruleloom.actionspans, subject-loadruleloom.contextspans;ruleloom.rules/ruleloom.actionscounters; duration histograms) andRuleLoom.Abstractions(ContextTelemetry: context-load spans andruleloom.context.duration); rules are counts, not spans.ILogger(Microsoft.Extensions.Logging.Abstractions, only inRuleLoom): the engine's optionalILoggerFactory(passed byAddRuleLoom),[LoggerMessage]; Warning for failures, context load failures and overdue skips, Debug for outcomes (with subject and event id);StartRuleLoomAsynclogs the built catalog (Information) and its problems (Warning). Never write event state, context data or parameter values; the subject and event id only on spans and at Debug. - Authoring endpoints (
RuleLoom.AspNetCore,MapRuleLoom(prefix)inMicrosoft.AspNetCore.Builder):GET {prefix}/catalog(catalog.ToJson());POST {prefix}/validatetakes one rule or an array (ParseEach, thenRuleValidator) and returns aRuleValidationResponseper rule (indexfor arrays,id,parsed,isValid,errors,warnings; paths relative to the rule); malformed JSON or neither object nor array →400problem details. - Validation has two layers: the parser checks a rule's JSON shape (
RuleParseException), andRuleValidator(catalog).Validate(RuleLoom.Validation; oneRuleWalkerpass handing each node to smallRuleChecks) checks a rule against the catalog: event type not in the catalog, unknown operators/actions, operand counts, incomplete schedules, and paths (operands,$pathparameters, schedule reference paths) against the event's and contexts' schemas (SchemaPathCheck; operators get their operands' fields): unknown fields/contexts, undeclared or broken contexts, paths into lists →Errors; comparisons of built-in operators that can't match and contexts without a schema →Warnings(IsValidignores warnings). Typed actions' parameters are checked against their parameters schema (ParameterCheck, values as the JSON they're bound from): unknown or missing required parameters, values of the wrong type →Errors; a$pathwhose field can't be read as the parameter →Warnings; untyped actions aren't checked. When the event's subject has a loader with a schema, current-state paths read when a scheduled action is due (the rule's condition if it schedules anything, the scheduled action's condition and parameters; not reference paths) must be fields of the loaded subject too (SubjectPathCheck; reported only when the event has the field). Every problem comes with a JSONPath location. - Scheduling (
ScheduleMetadata):Immediate(default) /Delay(+offset) /Advance(−offset), in Seconds/Minutes/Hours (elapsed time) or Days (calendar days in the catalog's time zone, keeping the wall-clock time;TemporalRules.AddDays, lenient: skipped → forward, repeated → earlier), fromReferencePath(a date: the start of its day in the zone) or the injectedTimeProvider's UTC now;ScheduledForis UTC.ReferencePathvalues are read by the catalog'sTemporalRules(DateTime/DateTimeOffset, or strict ISO 8601 strings); an impossible wall-clock time fails the action, naming the reference path. RuleLoom computesScheduledFor; dispatching scheduled work is the consumer's responsibility.ScheduledAction(RuleId, ActionIndex, ActionName, ScheduledFor, Key)is a reference (the rule's current action runs when due), withToJson/Parse;Key={ruleId}:{actionIndex}:{subject}, prefixed{tenant}:when the event has one (CreateKey;\,:,;,=escaped),nullwithout a subject. The subject (SubjectIdentity) is the identity the event's schema declares (resolved on the current state; compositea=1;b=2in declared order, invariant values,nullif a part is), elseRuleEvent.Subject; computed only when an action is scheduled. Statuses:Executed,Scheduled,Skipped,Failed. A due time already in the past runs the action immediately.RuleEngineOptions(engine constructor, orAddRuleLoom(r => r.Configure(o => ...)), one shared instance kept with the catalog builder; the engine keeps the instance,options ?? new RuleEngineOptions(), so defaults live only in the options):SkipOverdueActions(off) skips actions later thanOverdueGracePeriod(0, not negative), both at processing and inExecuteScheduledAsync("overdue by 3 hours (grace period 30 minutes)"). The validator warns aboutAdvancewithout aReferencePathand rejectsamount≤ 0. - Value comparison:
ValueComparer(AreEqual,TryCompare) andValueConverter(TryConvert) inRuleLoom.Abstractions.Valuesare the single implementation of the comparison rules (numbers by value across types, enums by name or number, dates (DateOnly,yyyy-MM-ddtext) by day, date-times as moments incl. strict ISO 8601 strings, a date with a date-time by the date-time's calendar date in the time zone (ISO vs other text is incomparable), other strings ordinal, JSON objects/arrays by content viaDeepEquals;changedusesAreEqualtoo). Operators and other features must use them rather thanobject.Equalsor ad-hoc parsing. Both take aTemporalRules. - Time (ADR 0004, spec
2026-10-28-time-semantics-design.md):TemporalRules(public, sealed, immutable) is the only place that decides time-zone questions; never add UTC assumptions elsewhere. A catalog has one (CatalogBuilder.UseTimeZone("Europe/Sofia"), IANA id, UTC by default, unknown id fails the build;Catalog.TemporalRules,"timeZone"in the document; a stored document's zone is ignored);EvaluationContext.TemporalRulesis the catalog's (UTC without one), andOperatorContext.AreEqual/TryCompare,GetParameterAsync/GetParametersAsync(JSON binding with temporal converters) and schedules use it;GetParameter<T>without a context reads UTC. An offset wins; no offset (Unspecified, ISO text) is wall-clock time in the zone: skipped →InvalidTemporalValueException(named path or parameter; fails only that rule/action), repeated → the earlier occurrence;Localis the machine zone (skipped rejected, repeated as .NET converts). Dates are calendar days (TryGetDate:DateOnlyand date-only text only;GetDate(instant): its day in the zone;GetStartOfDay(date): lenient past a skipped midnight, and whatTryGetInstant/TryConvert<DateTimeOffset>give for a date when a moment is asked for). The validator reports date-time literals compared with date/date-time fields andDateTimeparameter values that the clocks skip in the catalog's zone (OperandValidationContext.TemporalRules). - Schemas (
RuleLoom.Schemas):class XSchema : EventSchema<TDto>configuresEvent(name)(required),Field(o => o.A.B)(Label/Description/Ignore) andContext(name)(a relation:ReferencedBy(o => o.Id)oro => new { o.A, o.B };LoadedBy(provider)), andSubject(o => o.Id)(or composite) with optional.LoadedBy(provider)(x-ruleloom-subjectwithx-ruleloom-identity/x-ruleloom-provider;EventSchemaDefinition.Subject=SubjectDefinition(Identity, Provider); not a@context; the catalog checks the provider is registered and the identity paths are fields, errors in code and problems when stored);Build(options)generates anEventSchemaDefinitionfrom howTDtois serialized (Web defaults unless options are given; numbers not typed as strings; null-oblivious types non-nullable), adds configured titles and descriptions (no automatic labels) andx-ruleloom-event/x-ruleloom-contexts(withx-ruleloom-referenced-by, andx-ruleloom-provideralways: theLoadedByprovider or the context's name, also filled in when reading a document without it).ToJson()/Parseround-trip; field names are JSON names. Context data is described by its type:class XSchema : ContextSchema<T>(constructor:Label/Description/Field(...)) builds aContextSchemaDefinitionunder the provider's name (x-ruleloom-context;IsManyfor collections); both inheritSchemaDefinition(Label,Description,Fields,ToJson). An action's parameters type is described byParametersSchema<T>(Parameter(...), used by typed descriptors) as aParametersSchemaDefinition(JSON Schema withrequired;ActionRegistration.Parameters,CatalogAction.Parameters,"parameters"in the document). Schemas describe data; descriptors (ActionDescriptor<TAction>,ActionDescriptor<TAction, TParameters>) describe code.CatalogBuilderfinds descriptions next to what they describe (the action's / provider's / data type's assembly, orAddFromAssemblyOf; public types only; two for one type fail the build), or takes them explicitly (AddAction<T, TDescriptor>,AddContextProvider<T, TSchema>).SchemaCollectiongathers event schema classes (assembly scan) into aCatalogDocumentholding only events, without the engine (producers).CatalogDocument(Events,Contexts,Operators,Actions,Problems; every section optional;ToJson/Parse) is the format of stores, UIs and later publishing;ICatalogStore(LoadAsync,SaveAsyncupserting per entry, never deleting,ReplaceScopeAsyncfor a producer's scope snapshot;InMemoryCatalogStore); the document hasFormatVersion(1). - JSON:
RuleJsonParser.Parse(json)/ParseMany(json)(all or nothing) /ParseEach(json)(rule by rule: aRuleParseResultper element with the rule or itsRuleParseException; malformed JSON or a non-array still throws); property names are case-insensitive, so a name repeated in one object (ignoring case, anywhere in the rule) is a parse error (JsonProperties, also used byRuleEvent.ParseandScheduledAction.Parse). The JSON shape is validated before deserialization (RuleJsonValidator); invalid rules throwRuleParseException(aJsonException) whosePathis the JSONPath of the problem (values of the wrong type found while deserializing too).Id,Name,EventTypeandConditionare required, and every condition root (rule or action) must be an operator. A parameter{ "$path": "..." }(its only key; ADR 0003) is parsed into aRulePathinActionDefinition.Parameters;$pathwith other keys, or inside a parameter's value, is a parse error; any other JSON is a value.
- Operator: implement
IConditionOperator— lowercaseName,MinOperands/MaxOperands(int.MaxValue= unlimited),bool Evaluate(OperatorContext ctx). Read operands viactx.GetValue(i)(value),ctx.Test(i)(condition, lazy; bool paths/values allowed),ctx.GetPath(i)(path string; parse withRulePath.Parse, resolve withctx.Resolve(path)); compare withctx.AreEqual/ctx.TryCompare. Unit-test operators withnew OperatorContext(condition, evaluationContext)(pass an evaluator only when operands are nested operators). Optionally overrideValidateOperands(OperandValidationContext)to check operands when rules are validated (GetPath,GetFieldwith schemas,Error/Warning); share the rules withEvaluate. The validator never names specific operators: put operator-specific checks on the operator (built-ins do:changed, the comparisons viaComparedOperands). - Action: implement
IAction<TParameters>—ExecuteAsync(TParameters, ActionDefinition, EvaluationContext, CancellationToken); a default interface member implementsIAction.ExecuteAsyncwithawait action.GetParametersAsync<TParameters>(context, ct)(paths resolved, loading their contexts if needed, e.g. for scheduled actions run outside the engine; then JSON binding withParametersSchemaDefinition.JsonOptions: names ignore case, enums by name, constructor parameters without a default andrequiredmembers required; a failure throwsInvalidOperationExceptionnaming the parameter, failing only that action). The catalog describes the parameters from the type; an action implementing two parameter types fails the build. Or implementIAction—ExecuteAsync(ActionDefinition, EvaluationContext, CancellationToken)— and read parameters withaction.GetParameterAsync<T>(name, context)(resolves a path) orGetParameter<T>(name)/TryGetParameter<T>(values only; plain CLR values, converted viaValueConverter); its parameters aren't described. Name it by its class (SendEmailAction→send-email) or[ActionName("...")]; returnActionResult.Success()orActionResult.Failed(...). - Action descriptor:
class XDescriptor : ActionDescriptor<XAction, XParameters>(constructor:Label,Description,Parameter(p => p.X)withLabel/Description/Ignore) orActionDescriptor<XAction>(no parameters), shipped next to the action. - Context provider: derive from
ContextProvider<TContext>/CollectionContextProvider<TItem>(typedLoadAsync; the type gives the schema, aContextSchema<T>adds labels and ignores) or implementIContextProvider(ValueTask<object?> GetAsync(ContextRequest, CancellationToken); no schema unless the store holds one); read the declared reference withrequest.GetReference<T>()or the subject withrequest.Resolve(path); return the context, a collection, ornull(not found). Actions read contexts withGetContextAsync<T>(name). - Factories: implement
IActionFactory/IContextProviderFactory(Create(registration)) to create instances another way (e.g. another container). - Catalog store: implement
ICatalogStore(inRuleLoom.Schemas);SaveAsyncmust upsert per entry and never delete;ReplaceScopeAsyncappliesCatalogScopeSnapshot.ApplyTo(stored, reassignOwner)atomically (the snapshot holds the semantics: added/changed byContentHash, missing →RemovedAt, one owningSourceper scope,ScopeOwnershipException). Removed events become catalog problems, not catalog events.
.editorconfig: 4 spaces for C#, 2 for JSON/YAML/XML/csproj, LF line endings.- File-scoped namespaces, nullable enabled, implicit usings.
varwhen the type is evident; collection expressions[]; primary constructors where they fit.- Seal classes that aren't designed for inheritance; expression-bodied members for simple members.
- XML doc comments on public API in
RuleLoom.Abstractions.
- xUnit;
[Fact]for single scenarios,[Theory]+[InlineData]for matrices. - Test names:
MethodName_Scenario_ExpectedOutcome. - Deterministic: fixed UTC timestamps via a fixed
TimeProvider(seeFixedTimeProviderinRuleEngineTests), neverDateTime.Now. - Test behavior through public contracts, not implementation details.
All documentation lives in docs/ (index: docs/README.md):
docs/roadmap.md— the single overview: done, next, backlog. Update it when an issue is created, closed, or re-scoped.docs/specs/— authoritative design specs (YYYY-MM-DD-<topic>-design.md), each with a Deviations section once implemented.docs/proposals/— designs not yet scheduled.docs/guides/— user-facing guides.GLOSSARY.md(repo root) — the domain language, one meaning per term;docs/adr/— short records of hard-to-reverse decisions. Use the glossary's terms in code, docs and issues.- Skills that write specs or plans elsewhere by default (e.g.
docs/superpowers/specs/,./plans/) must write todocs/specs/instead. CHANGELOG.mdis generated by release-please from the squash-merged PR titles. Never edit it in a feature PR; fix wording via the PR title, or adjust the release-please PR itself before it merges.