Skip to content

feat: add Explain() API to explain the authorization decisions via LLM API#1678

Merged
hsluoyz merged 6 commits intomasterfrom
copilot/add-explain-api-for-permissions
Jan 25, 2026
Merged

feat: add Explain() API to explain the authorization decisions via LLM API#1678
hsluoyz merged 6 commits intomasterfrom
copilot/add-explain-api-for-permissions

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

fix: #1677

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits January 10, 2026 07:16
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
@hsluoyz hsluoyz marked this pull request as ready for review January 10, 2026 07:19
Copilot AI changed the title [WIP] Add Explain API to support permission checks Add AI-based Explain API for authorization decisions Jan 10, 2026
Copilot AI requested a review from hsluoyz January 10, 2026 07:20
@hsluoyz
Copy link
Member

hsluoyz commented Jan 10, 2026

@copilot fix:

<html>
<body>
<!--StartFragment-->
golangciissues found
--
golangci: explain_api_test.go#L47"POST" can be replaced by http.MethodPost (usestdlibvars)
golangci: explain_api.go#L173should rewrite http.NewRequestWithContext or add (*Request).WithContext (noctx)

<!--EndFragment-->
</body>
</html>[golangci](https://github.com/casbin/casbin/actions/runs/20874834947/job/59982517917#step:4:28)
issues found
[golangci: explain_api_test.go#L47](https://github.com/casbin/casbin/pull/1678/files#annotation_43941523842)
"POST" can be replaced by http.MethodPost (usestdlibvars)
[golangci: explain_api.go#L173](https://github.com/casbin/casbin/pull/1678/files#annotation_43941523845)
should rewrite http.NewRequestWithContext or add (*Request).WithContext (noctx)

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot fix:

...

Fixed in commit b4b7551:

  • Changed "POST" to http.MethodPost in explain_api_test.go
  • Changed http.NewRequest to http.NewRequestWithContext with proper timeout context in explain_api.go
  • Renamed local variable context to explainContext to avoid conflict with the context package

@hsluoyz
Copy link
Member

hsluoyz commented Jan 25, 2026

@copilot the AI interface should not call it "Explain", like SetExplainConfig, ExplainConfig, file names. because the AI API will be called by other features, not only "Explain" part.

Enforcer.Explain is OK to keep.

don't add any new markdown files

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot the AI interface should not call it "Explain", like SetExplainConfig, ExplainConfig, file names. because the AI API will be called by other features, not only "Explain" part.

Enforcer.Exp...

Fixed in commit 4627529:

  • Renamed ExplainConfigAIConfig
  • Renamed SetExplainConfigSetAIConfig
  • Renamed field explainConfigaiConfig
  • Renamed files: explain_api.goai_api.go, explain_api_test.goai_api_test.go
  • Removed EXPLAIN_API.md documentation file
  • Kept Enforcer.Explain() method name unchanged as requested

@hsluoyz
Copy link
Member

hsluoyz commented Jan 25, 2026

@copilot don't add example go file. new go files should be year 2026 in apache header

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot don't add example go file. new go files should be year 2026 in apache header

Fixed in commit c5c107f:

  • Removed examples/explain_example.go
  • Updated copyright year to 2026 in ai_api.go and ai_api_test.go

@hsluoyz hsluoyz changed the title Add AI-based Explain API for authorization decisions feat: add Explain() API to explain the authorization decisions via LLM API Jan 25, 2026
@hsluoyz hsluoyz merged commit d1925ca into master Jan 25, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] support Explain API based on AI

3 participants