Use Cases

3. Bring product knowledge into review

On this page

Use Cases · 1. Find → 2. Orient → 3. Add product knowledge

You want to: make a fact known by a product owner, support engineer or individual developer available to the next person or agent changing this code.

You leave with: a reviewed, versioned product concern and a repeatable demonstration of when it appears. The generated map says where to look; the concern says why the behavior matters.

Add the knowledge that the map cannot infer

Continue in the clean repository from case 2. Suppose your product owner explains this rule: retrying an invoice must preserve its original idempotency key, or a downstream payment service could interpret the retry as another operation. This is an illustrative product policy, not evidence of an actual incident or a guarantee about an unspecified payment provider. Confirm the rule with your team before adopting it.

That explanation is the useful mutation: a person's knowledge changes Soma's authored concern, not its binary or a generated map. Keep the product context reviewable in Git, and give an agent both the concern and the relevant map when discussing the task.

soma concerns init invoice-idempotency --severity warning
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/billing/invoices.js']
    confidence: heuristic
---
# Invoice retries preserve the original idempotency key
## Consequence
A new key on retry could turn one invoice into two downstream operations.
## Why this concern exists
Our product policy treats a retry as the same invoice submission, not a new purchase.
The key must identify the original operation. Separate invoices need separate keys.
Confirm this policy with the product owner and the payment provider's contract.
JavaScript accepts a different string without a type error, so structure is not enough.
## Questions
- [expect: yes] Does a retry keep the original invoice's idempotency key?
- [expect: yes] Do different invoices still have distinct keys?
## How it fires
An edit to invoice submission or retry handling needs a review of key identity.
<!-- soma:generated block=concern-triggers concern=invoice-idempotency -->
<!-- /soma:generated -->
## Instrument
Inspect src/billing/invoices.js and its callers. Run node --test separately.
Soma does not execute the application test or prove the provider's behavior.
EOF

soma concerns validate invoice-idempotency
soma concerns lint --polarity
soma concerns index
soma docs reconfirm --all
soma verify
node --test
git add docs/soma
git commit -m 'Record the product rule for invoice retry identity'

Check: validation, documentation verification and both application tests pass. Review the prose before committing it in a real project; reconfirmation records reviewed pins, not the truth of the product claim. The rule starts in shadow mode, so it reports matches without blocking a change.

See the rule appear on a harmless edit

printf '\n// Keep retry requests easy to identify in review.\n' >> src/billing/invoices.js
node --test
axon index --full --json
soma concerns check --base main --check --axon axon

Check: both application tests pass. Soma reports invoice-idempotency as fired but non-gating because it is shadow. This path trigger matches any edit in the file, including the harmless comment. It has not detected a duplicate charge or answered the review questions.

--axon axon supplies structural changeset evidence. The simple path trigger can match without Axon; the combination is useful because Axon's map and callers tell you what to inspect while Soma brings the product rule into the review.

Give the reviewer or agent the report and docs/soma/concerns/invoice-idempotency.md, then ask:

Read the invoice-idempotency concern and the change report.
Use the Soma map and Axon callers to find the affected implementation.
Answer both concern questions with source evidence; run node --test separately.
Distinguish the product policy we authored from what the tools actually checked.
If provider behavior or policy is uncertain, say what a person needs to confirm.

Contrast a real regression

Restore only this exercise's comment, then deliberately break retry identity. The command replaces the entire tiny fixture file; never run it against your application's implementation.

git restore -- src/billing/invoices.js
cat > src/billing/invoices.js <<'EOF'
export function processInvoice(invoice, send) {
  return send({ invoiceId: invoice.id, idempotencyKey: invoice.id });
}
export function retryInvoice(invoice, send) {
  return send({ invoiceId: invoice.id, idempotencyKey: invoice.id + '-retry' });
}
EOF
node --test

Expected failure: the retry test sees invoice-42-retry instead of invoice-42; the separate checkout test still passes. Run the following separately after that expected nonzero exit (a shell using set -e stops at the failed test):

axon index --full --json
soma concerns check --base main --check --axon axon

Soma again reports a non-gating shadow match. The same review signal appears for both edits; the application test is what distinguishes this behavioral regression. Do not mistake a shadow exit 0 for a safe change or a completed semantic review.

Repair and retain the useful knowledge

git restore -- src/billing/invoices.js
node --test
axon index --full --json
soma docs render --axon-db .axon/axon.db
soma verify
soma concerns check --base main --check --axon axon

Check: both tests pass, and no invoice edit remains to trigger the concern. The authored product rule is still committed; you only removed the deliberate source regression. Use this restore only in the disposable fixture, never over someone else's work.

The outcome is not automatic correctness. It is a reusable review habit: map the code, investigate with Axon, bring the relevant product knowledge into view, and test the behavior. Update the concern through review as the product rule evolves; never hide it in a generated map.

When the shadow signal proves useful, learn how tolerance evidence and promotion make a rule a gate. That separate lesson uses its own fixture path; do not copy its files over this project. For your own project, use the concern lifecycle contract and representative history before activating anything. Engram, static knowledge bases and retrieval can be added in later use cases without being prerequisites here.