docs(examples): add explain_decision example [skip-runtime-e2e]#185
Merged
saurabhjain1592 merged 2 commits intomainfrom May 7, 2026
Merged
docs(examples): add explain_decision example [skip-runtime-e2e]#185saurabhjain1592 merged 2 commits intomainfrom
saurabhjain1592 merged 2 commits intomainfrom
Conversation
Closes the example-parity gap: client.explain_decision() shipped in April but no runnable example existed. Mirror the Rust SDK pattern (axonflow-sdk-rust#29) so callers can copy a complete demo without reading the SDK source. Reads AXONFLOW_DECISION_ID from env (typically harvested from a recent block response or audit row), calls explain_decision, and prints every ADR-043 field — policy matches, matched rules, override availability, historical hit count. Signed-off-by: Saurabh Jain <saurabhjain1592@gmail.com>
Member
Author
|
⛔ Do not merge — V1.1 release window. Per |
Signed-off-by: Saurabh Jain <saurabhjain1592@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the example-parity gap:
client.explain_decision()shipped in April but no runnable example existed. Mirror the Rust SDK pattern (axonflow-sdk-rust#29 / commit2360282) so a caller can copy a complete demo without reading the SDK source.Scope
examples/explain_decision.py(sibling ofquickstart.py).AXONFLOW_DECISION_IDfrom env, callsawait client.explain_decision(...), prints every ADR-043 field: matched policies, matched rules, decision, reason, risk level, override availability, historical hit count.AXONFLOW_CLIENT_IDtocommunity(the cross-SDK Basic-auth default).Three-rule definition of done
Rule 0 — Runtime proof. Live run against the local community stack at
localhost:8080(agent v7.7.0 / orchestrator v7.7.0):Step 1 — trigger a real decision via curl (yields
decision_id=7a4876eb-3fd5-4467-a412-b0b42833e165, policysys_sqli_drop_table, riskcritical).Step 2 — explain via the new Python example (using
.venv/bin/pythonsince the SDK requires Python 3.10+ for PEP 604 union syntax inaxonflow/masfeat.py):AXONFLOW_AGENT_URL=http://localhost:8080 \ AXONFLOW_CLIENT_ID=community \ AXONFLOW_CLIENT_SECRET="" \ AXONFLOW_DECISION_ID=7a4876eb-3fd5-4467-a412-b0b42833e165 \ .venv/bin/python examples/explain_decision.pyOutput:
Rule 1 — Self-review. Hunk-by-hunk:
axonflow/decisions.pyexactly:decision_id,timestamp,decision,reason,risk_level,tool_signature,policy_matches[{policy_id, policy_name, action, risk_level, allow_override}],matched_rules,override_available,override_existing_id,historical_hit_count_session,policy_source_link. ✓async with AxonFlow(...) as client:pattern matchesquickstart.pystyle. ✓ifs before printing — they're optional in the schema. ✓matched_rulesislist | Nonein the schema; theif exp.matched_rules:guard handles both null and empty correctly. ✓Rule 2 — No deferred bugs. None found in path. The example runs cleanly against the v7.7.0 platform.
⛔ Do not merge — V1.1 release window
Per the
feedback_v1_1_no_merge_during_release_window.mdguideline. V1.1 is the next coordinated release train; nothing lands onmainacross V1.1-related PRs until the user explicitly authorizes the V1.1 release.Skip-runtime-e2e justification
This SDK PR is runtime-tested by the repo's existing
integration.ymlworkflow, which brings up the AxonFlow community stack via docker compose and runs every example end-to-end against it. Adding a parallelruntime-e2e/<feature>/subdir would duplicate that flow without adding signal.Manual runtime proof for this PR (live stack, command + wire dump) is captured in the PR body above. The community-stack integration.yml run on this branch is the automated equivalent.
Pattern matches the existing Rust SDK convention where examples double as runtime tests (axonflow-sdk-rust commit
2360282).