Repository navigation
op policy_trace
Tracing decisions about permissions (U6).
| Group | Databases |
| Edition | community — works without a licence |
| Capability |
schema — the feature that carries this operation; the licence matrix is on 15 · Editions and licensing
|
| MCP tool |
ragraf_policy_trace · read-only · idempotent · requires symbol
|
| CLI | ragraf -p <config> query policy_trace … |
The most expensive defect on the range (number 9 in the development report) was found only by testing under a real role: role employee received the rights approve, mark_paid, sign and archive, because a switch branch returned true for everyone holding a journal. No navigation measurement shows this, and the eye loses it inside a large switch.
- Collect every place where a rights decision returns permission, with the conditions.
- See the branches of explicit refusal and what happens when no condition matches:
denyis fail-closed,allowis the signature of a defect, because an unknown action then receives a right. - Find the call sites where the decision is applied.
- Read the limit: the trace is static and shows branches in the code, not the result for a particular user, whose roles come from a database the index does not have.
The call that produced the answer below, as a command line:
$ ragraf -p demo-corpus.yaml query policy_trace --name can_approve
The same call through MCP: ragraf_policy_trace(symbol=…).
The answer below was captured on the demo corpus, not written for the page:
{
"op": "policy_trace",
"index_rev": "rev-0002",
"capability": "degraded",
"provenance": "index",
"found": true,
"result": {
"symbol": "can_approve",
"path": "web/order_lib.php",
"lines": {
"start": 12,
"end": 24
},
"allows": [
{
"path": "web/order_lib.php",
"line": 16,
"case": "manager",
"returns": "true",
"text": "return true;"
},
{
"path": "web/order_lib.php",
"line": 18,
"case": "accountant",
"returns": "computed",
"text": "return $hasJournal;"
},
"... 1 more"
],
"denies": [
{
"path": "web/order_lib.php",
"line": 20,
"case": "viewer",
"returns": "false",
"text": "return false;"
}
],
"default_behavior": "allow",
"callers": [],
"body_read": true
},
"limits_count": 2
}The call succeeded. The answer is trimmed to two items per list and to the fields that carry no Russian prose: limits and the explanatory strings are counted in the footer below instead of being quoted.
| Name | Type | Default |
|---|---|---|
symbol |
str |
required |
action |
str | None |
None |
depth |
int |
3 |
limit |
int |
300 |
min_confidence |
float | None |
None |
Result keys visible in the code: action_filter, allows, body_read, callers, default_behavior, denies, lines, path, symbol.
The body also writes these fields into the answer envelope itself (extra): evidence, fail_closed, note, suggest, warning.
The envelope around the result is the same for every operation; how to read it: 04 · Operations reference.
| Step | What happens |
|---|---|
| Reads | none of the three stores directly — the answer comes through the engine the body calls, or from what the call is given |
| Calls |
evidence_mod.summarize, util.decode_text
|
| Guarded by | the index revision is read (current_rev), so every fact belongs to a named revision; a missing index is refused by name (_no_index) instead of raising |
| Writes |
evidence, fail_closed, note, suggest, warning into the answer envelope |
| Empty answer | yes, and names where to go instead: code, search
|
flowchart TD
Start[query policy_trace]
Rev{index revision}
NoIndex[refused: no index]
Call0[evidence_mod.summarize]
Call1[util.decode_text]
Found{found}
Empty[empty result + suggest: code search]
Out[envelope with result]
Start --> Rev
Rev -- none --> NoIndex
Rev -- rev-N --> Call0
Call0 --> Call1
Call1 --> Found
Found -- no --> Empty
Found -- yes --> Out
Every answer carries a limits field, and it is never empty when a boundary exists: that is where the limits of this particular call are named — which part of the corpus was not covered, which fact could not be confirmed, what the operation refused to guess.
The boundary of the whole Databases group is stated once, on the reference page. It is a sentence about the group, so it is not repeated here as if it were a sentence about policy_trace.
← previous in the group: write_check
→ next in the group: class_usage
The full table with all 87 operations · A–Z index · Databases
Where these fields come from: the parameters, their types and defaults are read from the signature op_policy_trace in src/ragraf/facade.py:7277 (line numbers as of 0.12.0); the MCP annotations from the tool registration; the edition from src/ragraf/edition_baseline.json; the guards, calls, stores, envelope fields and the diagram from the body of that same method. The example is a run of tools/build-op-examples.py on the demo corpus at revision rev-0002; fields whose value is Russian prose in this build (limits, explanatory strings) are counted, not quoted. Nothing else on this page is written by hand.
The reason and the tasks above are a translation of the docstring of op_policy_trace, src/ragraf/facade.py:7277, kept in tools/op-text.json next to the line it came from. That file is the only hand-written text in the pipeline; the gate tools/check-op-text.py checks that the line exists and that its text is English.