hub-self-apply-ineligible.mjs
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago
| 1 | /** |
| 2 | * SEC-SEAM-1 / S10 — operator-declared self-apply-ineligible subjects. |
| 3 | * |
| 4 | * Pure parser for `HUB_SELF_APPLY_INELIGIBLE_SUBS` (comma-separated exact `sub` values). |
| 5 | * Production wires the env through this parser once at module load into |
| 6 | * {@link SELF_APPLY_INELIGIBLE_SUBS}. Tier 7b exercises empty shapes via the pure |
| 7 | * parser directly — never by mutating `process.env` and reloading the module. |
| 8 | * |
| 9 | * @see docs/SEC-SEAM-1-SESSION-BOUND-IDENTITY-FREEZE.md S10 |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * Parse a raw env string into a Set of trimmed non-empty subject ids. |
| 14 | * Absent / empty / whitespace-and-comma-only inputs yield an empty Set |
| 15 | * (permissive — an unset variable must not disable the live notes tray). |
| 16 | * |
| 17 | * @param {string|undefined|null} raw |
| 18 | * @returns {Set<string>} |
| 19 | */ |
| 20 | export function parseSelfApplyIneligibleSubs(raw) { |
| 21 | if (raw == null) return new Set(); |
| 22 | const text = String(raw); |
| 23 | if (!text.trim()) return new Set(); |
| 24 | return new Set( |
| 25 | text |
| 26 | .split(',') |
| 27 | .map((s) => s.trim()) |
| 28 | .filter(Boolean) |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | /** Module-load Set from `HUB_SELF_APPLY_INELIGIBLE_SUBS` (ships empty under ratified D3). */ |
| 33 | export const SELF_APPLY_INELIGIBLE_SUBS = parseSelfApplyIneligibleSubs( |
| 34 | process.env.HUB_SELF_APPLY_INELIGIBLE_SUBS |
| 35 | ); |
| 36 | |
| 37 | /** |
| 38 | * Whether `sub` is on the operator-declared ineligible set (exact match after trim). |
| 39 | * @param {string|null|undefined} sub |
| 40 | * @returns {boolean} |
| 41 | */ |
| 42 | export function isSelfApplyIneligibleSub(sub) { |
| 43 | const s = typeof sub === 'string' ? sub.trim() : ''; |
| 44 | return s !== '' && SELF_APPLY_INELIGIBLE_SUBS.has(s); |
| 45 | } |
File History
1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago