refactor(signals): shared public-safe redaction module (#542) - #743
Conversation
Lift the private `isPublicSafeText` out of local-branch.ts into a shared `src/signals/redaction.ts` so every public surface (PR/issue comments, check annotations, notifications, badge, extension payloads, slop/advisory reasons) filters through one canonical regex instead of re-deriving its own and drifting. - New `src/signals/redaction.ts` exports `isPublicSafeText` + a reusable `PUBLIC_UNSAFE_PATTERN` constant. The pattern is byte-for-byte the same and intentionally NON-global, so `.test()` stays stateless. - local-branch.ts imports it; all 8 call sites unchanged. No behavior change — the existing local-branch redaction tests stay green. - Added test/unit/redaction.test.ts exercising the boundary directly (economic/identity signals + local paths rejected; clean text accepted; guards the non-global/stateless requirement). Closes #542.
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
gittensory · advisory review Reviewed 3 changed file(s) — two independent AI reviewers. Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · No blocking issues spotted. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
What
Closes #542. Lift the private
isPublicSafeTextout ofsrc/signals/local-branch.tsinto a sharedsrc/signals/redaction.ts, so every public surface (PR/issue comments, check annotations, notifications, badge, extension payloads, slop/advisory reasons) filters through one canonical regex instead of re-deriving its own and drifting.How
src/signals/redaction.tsexportsisPublicSafeText+ a reusablePUBLIC_UNSAFE_PATTERNconstant. The regex is byte-for-byte identical to the old in-file one and intentionally non-global, so.test()stays stateless (nolastIndexcarry-over).local-branch.tsimports it; its 8 call sites are unchanged. No behavior change — the existing local-branch redaction tests stay green.test/unit/redaction.test.tsexercises the boundary directly: economic/identity signals (reward/score/wallet/hotkey/coldkey/mnemonic/farming/payout/ranking/raw-trust/trust-score/reviewability) and local filesystem paths are rejected; clean text is accepted; and a guard asserts the pattern is non-global (stateless).Scope note
Per the issue, this updates the single importer (
local-branch.ts) with no call-site behavior change. Three service modules (pr-body-draft.ts,agent-action-explanation-card.ts,miner-dashboard-recommendations.ts) carry their own related — but not identical (gi-global, different alternations) — redaction patterns; consolidating those ontoPUBLIC_UNSAFE_PATTERNis deliberately left as follow-up to avoid a behavior change here.Verification
typecheck✅ ·test:coverage✅ (1849 passed; branches 97.04%, all metrics ≥97) ·git diff --check✅ ·ui:openapi:check✅