Soma · Configuration & integration
Author triggers and questions
Start with concerns init, then replace its generic text with a narrow invariant and inspectable enforcement points. Required front matter contains schemaVersion: 1, id, severity (critical, warning, question), applies_to (all, every client, or a feature key), added_by, nullable gate, and triggers. New templates also record born and state: shadow; optional tolerance is a rate in [0, 1], default 0.
Keep these required H2 sections in order: Consequence, Why this concern exists, Questions, How it fires, Instrument. Notes is optional. Leave the generated trigger block in How it fires to concerns index; explain the mechanism and concrete checks in authored prose.
Use exactly one H1 title, no text between it and Consequence, no duplicate sections or deeper headings, and nonempty Consequence/rationale. IDs are lowercase kebab-case, at most 64 characters, match <id>.md, and cannot be registry, recall or schema. Concern files are direct children of the concerns directory; subdirectories are not recursively loaded as entries. Symlinks anywhere under that directory are refused, not followed. Unknown front-matter and trigger properties fail validation.
The remaining optional front matter is feature_read: runtime (only with feature-specific applies_to) and census_reason: {rate, sha, last, date, text}. The latter records a human quarantine explanation: rate 0–100, SHA 7–40 lowercase hex, positive last, date YYYY-MM-DD, nonempty text. born accepts null or 7–64 lowercase hex. added_by is a required @handle; gate is null or a nonempty test identifier, not a command Soma executes. Known modules/features are checked against discovered configuration/roster where available. The full set of 12 accepted front-matter keys is the seven required keys above plus feature_read, census_reason, born, state, tolerance.
| Trigger family | Inputs and scope |
|---|---|
path |
paths: any changed matching path. |
diff_text |
paths, regex, optional within: added or removed diff lines; with within, only added lines inside a block that regex opens. |
enclosing_text |
paths, regex: text within a function modified by the diff, not just the changed lines. |
migration_table |
tables: named tables, or ['*'], in changed migrations. |
symbol |
pattern: changed structural symbol identity; requires structural delta evidence. |
touches_symbol |
patterns: a diff-touched symbol has a 1-hop outbound edge (call, reference, job dispatch) to a matched symbol, in any directory; requires structural delta evidence and .axon/axon.db. |
reaches |
surfaces and/or modules: downstream structural reach from the diff-touched symbols; requires structural delta evidence. |
Each trigger specifies confidence: proven, framework-inferred or heuristic. Label the actual instrument honestly: a broad text match is not proof merely because its confidence says proven. For example, this is only a trigger fragment, not a complete concern:
triggers:
- kind: diff_text
paths: ['src/invoices/**']
regex: 'retry|idempotency'
confidence: heuristic
Questions use one - bullet each. State the safe answer with exactly [expect: yes] or [expect: no], lowercase, first in the bullet, followed by whitespace and the question:
- [expect: yes] Does retrying an invoice preserve its original idempotency key?
Omitting the marker means yes. Marker-like [expect text in any other case, spacing or position is invalid, not ordinary question wording. Use concerns lint --polarity to find implicit defaults. Preserve a question's meaning rather than rewriting a genuinely negative safe answer to fit the default.
A question that only makes sense when the diff does something names that as its own yes/no question with [applies: <question>], after the polarity marker and before the question:
- [expect: yes] [applies: Does the diff add a database query in invoicing code?] Does every invoicing query it adds scope by tenant?
System 1 asks the applicability question in the same request and judges the main question only when the applicability score reaches the threshold. Without it, a conditional [expect: yes] question fails every diff that does not do what it is conditional on. Writing the question as a violation ([expect: no] Does the diff add an invoicing query without a tenant scope?) needs no [applies: ...]. [applies text in any other form or position is invalid.
Guard a symbol from any caller
A path glob only fires where you expected the code to live. To guard a model, trait or framework entry point wherever it is used, name it as the callee:
triggers:
- kind: touches_symbol
patterns:
- 'App\Module\Invoicing\Models\InvoiceLineItem*'
- 'Illuminate\Foundation\Bus\Dispatchable::dispatch'
confidence: proven
The concern fires when a function or method the hunks modify has an outbound edge to a matched symbol: a structural_edges row (calls, references, extends, ...) or an operational_edges dispatch or event, whose target is the boundary's handler. A pattern without :: also covers the type's members, so ...\InvoiceLineItem matches InvoiceLineItem::find; * matches zero or more characters, so a trailing * spans ::member, longer names and nothing at all (*InvoiceLineItem* matches the class node itself). A static call to an inherited ORM method (InvoiceLineItem::where(...)) is the class-level references edge Axon records to the model. A column reference (references_column, or references_missing_column for a column the schema lacks) also touches every model that maps_to_table the column's table, so $item->tax_total on an invoice_line_items row touches InvoiceLineItem. Only the symbols the diff touches contribute edges, scoped by recorded spans as for reaches, so an untouched sibling method's calls do not count. Edges are one hop, read from the current index, and only as complete as Axon's resolution: a call Axon did not resolve to a target is not seen. Without the index, touches_symbol is listed in notCertified.triggerKindsUnavailable and unevaluated.
Guard a pattern across the repository
A cross-cutting concern uses repo-wide paths and a within regex that names the block a match must be inside:
triggers:
- kind: diff_text # N+1: a query added inside a loop body or a collection callback
paths: ['src/**/*.php', 'app/**/*.php']
regex: '::(?:find|where|firstWhere)\(|->(?:first|get)\(|DB::table\('
within: '\b(?:foreach|for|while)\b|->(?:map|each|transform)\('
confidence: heuristic
- kind: diff_text # named arguments inside a dispatch call's argument list
paths: ['src/**/*.php', 'app/**/*.php']
regex: '(?:^|[(,])\s*[A-Za-z_][A-Za-z0-9_]*\s*:[^:]'
within: '::dispatch(?:Sync|Now|AfterResponse)?\('
confidence: heuristic
From each within match in the target file, the first bracket group is the header. When a { block follows it, the block is that body (a loop body, not the foreach (...) header, so a query evaluated once in the header does not fire); after a control header (foreach, for, while, if, elseif, switch), a : opens PHP's alternative syntax, whose body runs to the matching endforeach;/endfor;/endwhile;/endif;/endswitch; (nested bodies are counted), and a statement opens that single braceless statement up to its ; (foreach ($rows as $r) Model::find($r->id);); otherwise it is the header group itself (the arguments of ::dispatch(...), or the callback of ->map(function () { ... })). An added line fires when the last character of a regex match is inside such a block. Comments and string literals are ignored. Removed lines are not read, blocks are bracket- or keyword-delimited (Python indentation is not), and an unbalanced file is reported unevaluated as a parse error. The query regex above still matches eager-loaded or cached calls; it is a heuristic. Replay concerns tolerance on commits known to be clean before promoting one.
Triggers are alternatives: any matching trigger fires the concern; multiple paths and reach targets are alternatives too. Paths are repository-relative /-separated globs: * and ? stay within a segment, standalone ** spans segments, and {a,b} expands alternatives. Character classes, backslashes, absolute paths, ***, noncanonical .//../double slashes/trailing slash and duplicate paths are invalid. Regexes use Rust regex syntax, length 1–400 bytes, no controls or HTML-comment markers; only (?i) and (?:...) inline forms are accepted. Table names are lowercase letters/digits/underscore, or * alone. symbol.pattern and each touches_symbol.patterns entry are a qualified name with optional *, up to 300 bytes; within follows the regex rules; reach surfaces start surface: and name a kind/literal (not just surface:*), up to 200 bytes. Reach module names are literal alphanumeric/hyphen/underscore identifiers, not path globs. Nonempty arrays and per-kind allowed fields are enforced.