Policies overview
Softprobe Testing uses declarative YAML policies (apiVersion: softprobe.ai/v1), merged by metadata.priority and applied by sp-boot at runtime.
Separate how to run each phase from policy configuration:
| Phase | Operations | Policy config |
|---|---|---|
| 1 · Record | How to record | RecordingPolicy below |
| 2 · Replay | Replay and diff | MockPolicy, CompareRulePolicy below |
Field reference and full examples: Policy YAML guide · CLI policies index
CLI quick reference
sp policy recording validate -f recording.yaml --json
sp policy recording apply -f recording.yaml --json
sp policy mock apply -f mock.yaml --json
sp policy compare apply -f compare.yaml --jsonHigher metadata.priority wins on conflicts. Built-in priority-0 globals exist; use priority > 0 on app policies.
Lifecycle phases
| Phase | Kind | When to configure | CLI |
|---|---|---|---|
| 1 · Record | RecordingPolicy | Before traffic | sp policy recording |
| 2 · Replay | MockPolicy | Before sp replay run | sp policy mock |
| 2 · Replay | CompareRulePolicy | Before sp replay run | sp policy compare |
Full lifecycle: Getting started
RecordingPolicy
Phase 1 · Before traffic
Controls what the agent records: sampling, time window, operation include/exclude, serialize skip, record-time time mock.
- Sampling —
ratePerHundredSeconds(0= no record), optionalmachineCountLimit(omit = unlimited) - Time window —
daysOfWeek,from/to(agent JVM local timezone) - Operations —
excludeglobs; non-emptyincludeswitches to whitelist mode - Serialize skip —
serializeSkipby class and field names timeMock— fixjava.time.*at record time
Operational steps: How to record
YAML fields and examples: Policy YAML guide · RecordingPolicy
Notes
spec.sensitiveDatais not applied on the agent record path yet; usematchTolerancefor mock-key noise andSensitivePolicyfor view-time masking (see YAML guide).- Changing
operationsinclude/exclude updates replay schedule operation scope without a separate schedule edit.
sp policy recording validate -f my-recording.yaml --jsonMockPolicy
Phase 2 · Before replay
Controls whether dependencies are mocked at replay, mock-key tolerance, cross-app dependencies, and fallback when no mock matches.
mockByDefault— mock all deps by default (skipMockexceptions), or the inverse withforceMockCategory:operationGlob— e.g.HttpClient:/payment/**(not entry types likeServlet)matchTolerance— ignore volatile headers, query params, body pathsmultiServiceDependencies— mock downstream apps from the same sessionfallback—FAIL(default),PASS_THROUGH,RETURN_DEFAULT
Global defaults force-mock DynamicClass:SystemTime.** and RandomSource.**; user skipMock has no effect.
YAML fields and examples: Policy YAML guide · MockPolicy
CompareRulePolicy
Phase 2 · Before replay
Controls diff noise during replay comparison (not mock behavior).
excludePaths/includePaths— JSON Pointer (with globs)defaults.timeToleranceMsand CELvalidations— drop diffs by rule (including per-categoryrules)operationSpecs— per-entry-operation overlays (do not put operation names onselector)
YAML fields and examples: Policy YAML guide · CompareRulePolicy
Use sp replay diff after replay, then tighten policy rather than changing application code.
Dynamic classes (not RecordingPolicy)
Register methods in dynamic class configuration (dashboard/API), not in RecordingPolicy. Control replay mocking via MockPolicy UserDynamic / DynamicClass rules. See Policy YAML guide · Related configuration.
