test(settings): add policy compiler sanitizer fixtures - #336
Merged
JSONbored merged 2 commits intoJun 3, 2026
Conversation
Exposes sanitizeRoleText via __controlPanelRolesInternals and adds a
dedicated fixture file covering every sanitizer boundary in the settings
policy system.
- src/services/control-panel-roles.ts: export sanitizeRoleText (was
private) and export __controlPanelRolesInternals for test access.
- test/unit/policy-sanitizer.test.ts (new, 46 tests):
- sanitizeRoleText path redaction: /Users, /home, /tmp, C:\Users
- sanitizeRoleText token redaction: ghp_, github_pat_, gts_, glpat-,
Bearer — each verified to produce <redacted-token>
- sanitizeRoleText private term redaction: all 13 forbidden terms
(wallet, hotkey, coldkey, raw trust, trust score, payout, reward
estimate, farming, private reviewability, public score estimate,
seed phrase, mnemonic, private key) → <redacted>
- sanitizeRoleText truncation: >200 chars is clipped
- Contribution lanes: role card and onboarding.nextActions are
private-term-free across needs_setup, active, and operator states
- Label guidance: settings-preview appliedLabel, label policy in
registration-readiness, and permission warnings are clean
- Validation guidance: check-run decisions, decidePublicSurface
summaries, and config recommendation tradeoffs/reasons are clean
- Readiness warnings: blockers/warnings for blocked, strained,
drift, and no-label repos are clean
- Onboarding-pack inputs: full publicSafe summary and private-only
config recommendation contain no user-facing private terms
JSONbored
approved these changes
Jun 3, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@web-dev0521 this is a straightforward coverage improvement.
A few notes:
- The sanitizer fixture cases are useful because this surface affects public-safe policy output.
- The change stays test-focused and does not introduce behavior drift.
- The PR metadata is complete enough for review.
No code changes requested.
Validation expected:
- Keep the settings/unit suite green through merge.
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.
Summary
sanitizeRoleTextvia__controlPanelRolesInternalsso the sanitizer can be unit-tested directly with adversarial inputstest/unit/policy-sanitizer.test.tswith 46 targeted fixture tests covering all five required areasCloses: #300
Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typecheck— cleannpm run test:coveragelocally — 818 pass (1 skipped); pre-existing Windows failures confirmed onmainbefore this branch; coverage stays above 97%npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
Safety
Notes
Fixture coverage by category:
sanitizeRoleTextpath redaction — Unix/Users,/home,/tmpand WindowsC:\Userspaths are entirely consumed by the regex, leaving<redacted-path>; text surrounding paths is preservedghp_,github_pat_,gts_,glpat-, Bearer tokens each produce<redacted-token>; short strings below the 8-char minimum are left unchangedwallet,hotkey,coldkey,raw trust,trust score,payout,reward estimate,farming,private reviewability,public score estimate,seed phrase,mnemonic,private key) trigger a full<redacted>responseonboarding.nextActionsverified clean acrossneeds_setup,ready(miner/maintainer), andoperatorstates; adversarial repo names containing private terms are sanitized in role cardsappliedLabel,labelPolicy, and permission-warning text in settings-preview are verified private-term-freecheckRundecisions,decidePublicSurfacesummaries, and config recommendationtradeoffs/reasonsare verified private-term-freeblockersandwarningsverified clean for blocked/unregistered repos, strained intake, upstream drift, and no-label-pipeline statespublicSafe: trueenforced;buildGittensorConfigRecommendationprivateOnly: trueis verified; no user-facing wallet/hotkey/trust language in any serialized output