-
Notifications
You must be signed in to change notification settings - Fork 0
fix: follow-up for PR #89 review comments #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package agentframework | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/Clyra-AI/wrkr/core/detect" | ||
| "github.com/Clyra-AI/wrkr/core/model" | ||
| ) | ||
|
|
||
| func TestDetect_DefaultsDeploymentGateFromHumanGate(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| root := t.TempDir() | ||
| configPath := ".wrkr/agents/langchain.yaml" | ||
| writeFile(t, root, configPath, `agents: | ||
| - name: release_agent | ||
| file: agents/release.py | ||
| auto_deploy: true | ||
| human_gate: true | ||
| `) | ||
|
|
||
| findings, err := Detect(context.Background(), detect.Scope{Org: "acme", Repo: "payments", Root: root}, DetectorConfig{ | ||
| DetectorID: "agentframework_langchain", | ||
| Framework: "langchain", | ||
| ConfigPath: configPath, | ||
| Format: "yaml", | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("detect: %v", err) | ||
| } | ||
| if len(findings) != 1 { | ||
| t.Fatalf("expected one finding, got %d", len(findings)) | ||
| } | ||
| if value := evidenceValue(findings[0], "deployment_gate"); value != "enforced" { | ||
| t.Fatalf("expected deployment_gate=enforced, got %q", value) | ||
| } | ||
| } | ||
|
|
||
| func TestDetect_UsesExplicitDeploymentGate(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| root := t.TempDir() | ||
| configPath := ".wrkr/agents/openai.yaml" | ||
| writeFile(t, root, configPath, `agents: | ||
| - name: release_agent | ||
| file: agents/release.py | ||
| auto_deploy: true | ||
| human_gate: false | ||
| deployment_gate: approved | ||
| `) | ||
|
|
||
| findings, err := Detect(context.Background(), detect.Scope{Org: "acme", Repo: "payments", Root: root}, DetectorConfig{ | ||
| DetectorID: "agentframework_openai", | ||
| Framework: "openai_agents", | ||
| ConfigPath: configPath, | ||
| Format: "yaml", | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("detect: %v", err) | ||
| } | ||
| if len(findings) != 1 { | ||
| t.Fatalf("expected one finding, got %d", len(findings)) | ||
| } | ||
| if value := evidenceValue(findings[0], "deployment_gate"); value != "approved" { | ||
| t.Fatalf("expected deployment_gate=approved, got %q", value) | ||
| } | ||
| } | ||
|
|
||
| func evidenceValue(finding model.Finding, key string) string { | ||
| target := strings.ToLower(strings.TrimSpace(key)) | ||
| for _, evidence := range finding.Evidence { | ||
| if strings.ToLower(strings.TrimSpace(evidence.Key)) == target { | ||
| return strings.TrimSpace(evidence.Value) | ||
| } | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| func writeFile(t *testing.T, root, rel, content string) { | ||
| t.Helper() | ||
| path := filepath.Join(root, filepath.FromSlash(rel)) | ||
| if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { | ||
| t.Fatalf("mkdir %s: %v", rel, err) | ||
| } | ||
| if err := os.WriteFile(path, []byte(content), 0o600); err != nil { | ||
| t.Fatalf("write %s: %v", rel, err) | ||
| } | ||
| } |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mergeAgentContextnow routes deployment artifacts throughdedupeSorted, which lowercases every token before returning it. For repos that use case-sensitive artifact names (for exampleDeploy.yml), this changes the recorded evidence path and can make the emitteddeployment_artifacts/deployment_evidence_keysno longer match real files, reducing auditability of the privilege map output.Useful? React with 👍 / 👎.