First steps
2. Layer on one Soma rule
Learning path · 1. Axon → 2. Soma → 3. Activate a rule
Goal: make the invoice retry rule visible during a change. Continue in the clean cns-first-steps repository from lesson 1, with Axon installed and the application test passing.
1. Install Soma without adding services
Add just the second tool through the same tap (on a Linux server, use the release archive; see installation and access):
brew install ivannovak/cns/soma
After installation, check the binary:
soma --version
The remaining example was exercised with Soma 1.2.3 and Axon 1.6.4. There is still no model service, agent harness or memory database to configure. Remain in the example repository from lesson 1.
2. Initialize the project
soma init --curator '@maintainer'
soma concerns init invoice-idempotency --severity warning
The commands scaffold a concern template. A concern records a project rule, why it matters, a trigger that identifies edits needing review, and the questions a reviewer should answer.
Replace the generated docs/soma/concerns/invoice-idempotency.md with this complete example:
cat > docs/soma/concerns/invoice-idempotency.md <<'EOF'
---
schemaVersion: 1
id: invoice-idempotency
severity: warning
applies_to: all
added_by: '@maintainer'
state: shadow
gate: null
triggers:
- kind: path
paths: ['src/invoices.js']
confidence: heuristic
---
# Invoice retries preserve the original idempotency key
## Consequence
A new key on retry can turn one invoice into two downstream operations.
## Why this concern exists
JavaScript permits any string as the key; the type system does not enforce reuse.
## Questions
- [expect: yes] Does a retry use the same idempotency key as the first submission?
## How it fires
Any edit to the invoice implementation needs a review of key reuse.
<!-- soma:generated block=concern-triggers concern=invoice-idempotency -->
<!-- /soma:generated -->
## Instrument
Inspect src/invoices.js and run node --test. Soma does not run that test for you.
EOF
soma concerns validate invoice-idempotency
soma concerns lint --polarity
soma concerns index
soma docs reconfirm --all
soma verify
node --test
Expected: concern validation, explicit question polarity, documentation verification and the application test pass. Indexing fills the generated trigger table; do not hand-maintain that block. Reconfirmation records reviewed source pins where cited; it does not certify the truth of the prose. This first concern deliberately uses a simple file-path trigger, not a symbol anchor.
Commit the authored setup so later comparisons have an unambiguous base:
git add .gitignore soma.toml docs/soma
git commit -m 'Document the invoice retry rule in shadow mode'
Generated state under .soma/ stays local. The concern itself belongs in code review. This is a shadow rule: it can report matches, but it is not an enforced gate yet.
3. Make a harmless matching change
printf '\n// Keep retry requests easy to identify during review.\n' >> src/invoices.js
node --test
axon index --full --json
soma concerns check --base main --check --axon axon
Look for: invoice-idempotency in the matching concern report, marked as shadow/non-gating, while the test still passes. The file-path trigger fires on any edit to the file, including this harmless comment. That is a deliberate, easy-to-understand first trigger—not a claim that Soma found a bug.
The report ends with this distinction:
structural: pass
fired: 1
not gating: invoice-idempotency (shadow) (evaluated and reported; no effect on the exit code)
--axon axon supplies structural changeset evidence from the installed Axon executable. The path trigger can work without Axon, but this invocation shows how the two tools layer together. Read the report's evaluated and unavailable evidence rather than treating exit 0 as complete coverage. Do not add --systemone: this example is entirely local.
4. Return to the known starting point
git restore -- src/invoices.js
axon index --full --json
soma concerns check --base main --check --axon axon
node --test
Expected: with the example edit removed, no matching invoice edit remains. Restore only this lesson's disposable source edit, not arbitrary work in your real project.
What you have learned
Axon supplies code structure. Soma supplies a review rule that static structure alone cannot express. Your application test supplies an executable correctness assertion. None replaces the other two.
Next: evaluate and promote the rule before using it as a gate →. Do not simply edit state: active: promotion needs evidence, and a new rule cannot certify the same change that introduces it.