Skip to content

test(settings): add policy compiler sanitizer fixtures - #336

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
Lobster-0429:feat/policy-sanitizer-fixtures
Jun 3, 2026
Merged

test(settings): add policy compiler sanitizer fixtures#336
JSONbored merged 2 commits into
JSONbored:mainfrom
Lobster-0429:feat/policy-sanitizer-fixtures

Conversation

@Lobster-0429

@Lobster-0429 Lobster-0429 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Implements test(settings): add policy compiler sanitizer fixtures #300: adds policy compiler sanitizer fixtures for the settings/roles/readiness system
  • Exports sanitizeRoleText via __controlPanelRolesInternals so the sanitizer can be unit-tested directly with adversarial inputs
  • Adds test/unit/policy-sanitizer.test.ts with 46 targeted fixture tests covering all five required areas

Closes: #300

Scope

  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck — clean
  • npm run test:coverage locally — 818 pass (1 skipped); pre-existing Windows failures confirmed on main before this branch; coverage stays above 97%
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • UI/MCP/worker checks not applicable — this PR is tests-only (one small export change + new test file)

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (not applicable)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (not applicable — no public API surface changed)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (not applicable)
  • Visible UI changes include screenshots or a short recording. (not applicable)
  • Public docs/changelogs are updated where needed. (not applicable)

Notes

Fixture coverage by category:

  • sanitizeRoleText path redaction — Unix /Users, /home, /tmp and Windows C:\Users paths are entirely consumed by the regex, leaving <redacted-path>; text surrounding paths is preserved
  • Token redactionghp_, github_pat_, gts_, glpat-, Bearer tokens each produce <redacted-token>; short strings below the 8-char minimum are left unchanged
  • 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) trigger a full <redacted> response
  • Contribution lanesonboarding.nextActions verified clean across needs_setup, ready (miner/maintainer), and operator states; adversarial repo names containing private terms are sanitized in role cards
  • Label guidanceappliedLabel, labelPolicy, and permission-warning text in settings-preview are verified private-term-free
  • Validation guidancecheckRun decisions, decidePublicSurface summaries, and config recommendation tradeoffs/reasons are verified private-term-free
  • Readiness warningsblockers and warnings verified clean for blocked/unregistered repos, strained intake, upstream drift, and no-label-pipeline states
  • Onboarding-pack inputspublicSafe: true enforced; buildGittensorConfigRecommendation privateOnly: true is verified; no user-facing wallet/hotkey/trust language in any serialized output

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 JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@dosubot dosubot Bot added the lgtm label Jun 3, 2026
@JSONbored
JSONbored merged commit cd7b44e into JSONbored:main Jun 3, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

test(settings): add policy compiler sanitizer fixtures

2 participants