Repository navigation
feat(policy): annotate policy-list with preset provenance #5797
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 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8694ce1
feat(policy): annotate policy-list with preset provenance
laitingsheng 11a099a
fix(policy): drop weather from Balanced tier and gate provenance by a…
laitingsheng 5d2088f
style(policy): apply biome formatting to provenance tests
laitingsheng 63be25f
fix(policy): suppress provenance tag for unverified policy-list rows
laitingsheng cb3d471
style(policy): address CodeRabbit nits (one-sentence-per-line, vi.hoi…
laitingsheng f7f348a
merge(policy): sync provenance branch with main
cv 50caee0
fix(policy): clarify unverified preset provenance
cv b73f3a9
fix(policy): validate balanced preset provenance
cv cdb78c1
test(policy): cover advisor edge cases
cv 7ab1425
test(policy): model custom preset shadowing
cv 564b94e
test(policy): modernize provenance mocks
cv e43b089
Merge remote-tracking branch 'origin/main' into feat/policy-preset-pr…
laitingsheng 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
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
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,14 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| export const HERMES_TOOL_GATEWAY_PRESET_NAME_LIST = [ | ||
| "nous-web", | ||
| "nous-image", | ||
| "nous-audio", | ||
| "nous-browser", | ||
| "nous-code", | ||
| ] as const; | ||
|
|
||
| export const HERMES_TOOL_GATEWAY_PRESET_NAMES = new Set<string>( | ||
| HERMES_TOOL_GATEWAY_PRESET_NAME_LIST, | ||
| ); |
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,136 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| interface FakeTierPreset { | ||
| name: string; | ||
| access: string; | ||
| } | ||
| interface FakeTier { | ||
| name: string; | ||
| label: string; | ||
| description: string; | ||
| presets: FakeTierPreset[]; | ||
| } | ||
|
|
||
| const TIER_FIXTURES: Record<string, FakeTier> = { | ||
| balanced: { | ||
| name: "balanced", | ||
| label: "Balanced", | ||
| description: "balanced fixture", | ||
| presets: [ | ||
| { name: "npm", access: "read-write" }, | ||
| { name: "pypi", access: "read-write" }, | ||
| { name: "huggingface", access: "read-write" }, | ||
| { name: "brew", access: "read-write" }, | ||
| { name: "brave", access: "read-write" }, | ||
| { name: "weather", access: "read" }, | ||
| ], | ||
| }, | ||
| open: { | ||
| name: "open", | ||
| label: "Open", | ||
| description: "open fixture", | ||
| presets: [ | ||
| { name: "npm", access: "read-write" }, | ||
| { name: "slack", access: "read-write" }, | ||
| { name: "weather", access: "read" }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| vi.mock("./tiers", () => ({ | ||
| getTier: (name: string): FakeTier | undefined => TIER_FIXTURES[name], | ||
| })); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| import { classifyPresetProvenance, formatPresetProvenanceTag } from "./preset-provenance"; | ||
|
|
||
| describe("classifyPresetProvenance", () => { | ||
| it("classifies tier-default presets as tier-sourced for that tier", () => { | ||
| expect(classifyPresetProvenance("npm", { tierName: "balanced" })).toEqual({ | ||
| source: "tier", | ||
| tier: "balanced", | ||
| }); | ||
| expect(classifyPresetProvenance("weather", { tierName: "balanced" })).toEqual({ | ||
| source: "tier", | ||
| tier: "balanced", | ||
| }); | ||
| }); | ||
|
|
||
| it("classifies tier-default presets under the Open tier too", () => { | ||
| expect(classifyPresetProvenance("slack", { tierName: "open" })).toEqual({ | ||
| source: "tier", | ||
| tier: "open", | ||
| }); | ||
| }); | ||
|
|
||
| it("classifies openclaw-pricing as agent-sourced for openclaw", () => { | ||
| expect( | ||
| classifyPresetProvenance("openclaw-pricing", { | ||
| tierName: "balanced", | ||
| agentName: "openclaw", | ||
| }), | ||
| ).toEqual({ source: "agent", agent: "openclaw" }); | ||
| }); | ||
|
|
||
| it("classifies openclaw-diagnostics-otel-local as openclaw-agent-sourced", () => { | ||
| expect( | ||
| classifyPresetProvenance("openclaw-diagnostics-otel-local", { | ||
| tierName: "balanced", | ||
| }), | ||
| ).toEqual({ source: "agent", agent: "openclaw" }); | ||
| }); | ||
|
|
||
| it("classifies nous-* gateway presets as hermes-agent-sourced", () => { | ||
| expect(classifyPresetProvenance("nous-web", { tierName: "open" })).toEqual({ | ||
| source: "agent", | ||
| agent: "hermes", | ||
| }); | ||
| expect(classifyPresetProvenance("nous-code", {})).toEqual({ | ||
| source: "agent", | ||
| agent: "hermes", | ||
| }); | ||
| }); | ||
|
|
||
| it("falls back to user-source for non-tier, non-agent presets", () => { | ||
| expect(classifyPresetProvenance("custom-private", { tierName: "balanced" })).toEqual({ | ||
| source: "user", | ||
| }); | ||
| }); | ||
|
|
||
| it("treats missing tier context as no tier match", () => { | ||
| expect(classifyPresetProvenance("npm", {})).toEqual({ source: "user" }); | ||
| expect(classifyPresetProvenance("npm", { tierName: null })).toEqual({ | ||
| source: "user", | ||
| }); | ||
| }); | ||
|
|
||
| it("normalises preset name casing", () => { | ||
| expect(classifyPresetProvenance("OPENCLAW-PRICING", { tierName: "balanced" })).toEqual({ | ||
| source: "agent", | ||
| agent: "openclaw", | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe("formatPresetProvenanceTag", () => { | ||
| it("renders the tier source as 'from <tier> tier'", () => { | ||
| expect(formatPresetProvenanceTag({ source: "tier", tier: "balanced" })).toBe( | ||
| "from balanced tier", | ||
| ); | ||
| }); | ||
|
|
||
| it("renders the agent source as 'from <agent> agent'", () => { | ||
| expect(formatPresetProvenanceTag({ source: "agent", agent: "openclaw" })).toBe( | ||
| "from openclaw agent", | ||
| ); | ||
| expect(formatPresetProvenanceTag({ source: "agent", agent: "hermes" })).toBe( | ||
| "from hermes agent", | ||
| ); | ||
| }); | ||
|
|
||
| it("renders the user source as 'user-added'", () => { | ||
| expect(formatPresetProvenanceTag({ source: "user" })).toBe("user-added"); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.