test: property-check env boolean parsing and policy key/tag contracts#601
test: property-check env boolean parsing and policy key/tag contracts#601ndycode wants to merge 3 commits into
Conversation
Four fast-check properties over the shared env parser and the account
policy identity helpers:
- parseBooleanEnv: the six documented literals parse under any casing
and whitespace padding; every other string (and undefined) returns
undefined, never a boolean - the contract that unified three
divergent local copies
- getAccountPolicyKey: always a sha256: handle that never leaks the
raw identity into the policy file key; accountId wins over email;
email matches case-insensitively; no identity degrades to the
shared unknown bucket
- normalizeAccountPolicyTag: outputs are idempotent fixpoints in the
[a-z0-9._-]{1,64} language, and null occurs exactly for inputs that
trim to nothing (disallowed runs are dashed, not dropped)
Validated at FAST_CHECK_NUM_RUNS=1000. Companion to the property
suites in #574/#575/#592-#600.
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 12 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
A defined but whitespace-only accountId defers to the email identity (the accountId?.trim() || chain); the existing branch assertions cover it once generated. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
parseBooleanEnvinlib/env-parsing.ts(the helper that unified three divergent local copies across config/refresh-lease/rotation) and the pure identity helpers inlib/account-policy.ts(getAccountPolicyKey,normalizeAccountPolicyTag).What Changed
New
test/property/env-policy-parsing.property.test.ts(4 properties):1/0,true/false,yes/no) parse under any casing and whitespace padding; this is exactly the agreement the consolidation was for.undefined, returnsundefined, never a boolean — preserving callers' nullish-coalescing fallbacks.getAccountPolicyKeyalways emits asha256:<64 hex>handle that never leaks the raw identity into the policy file key;accountIdwins over email; email matches case-insensitively; no identity degrades to the shared "unknown" bucket.[a-z0-9._-]{1,64}language, andnulloccurs exactly for inputs that trim to nothing (disallowed runs are replaced with a dash, not dropped — so non-empty garbage still yields a tag, a subtle corner now pinned).No SUT bugs found. Validated at
FAST_CHECK_NUM_RUNS=1000.Validation
npm test -- test/property/env-policy-parsing.property.test.ts test/env-parsing.test.ts test/account-policy.test.ts— 36/36 (new 4 + existing suites untouched)npm run typecheck(also via pre-commit hook)npx eslint test/property/env-policy-parsing.property.test.ts --max-warnings=0Docs and Governance Checklist
Risk and Rollback
test/property/suites.https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
adds a new property-based test file (
test/property/env-policy-parsing.property.test.ts) covering four fast-check invariants for two pure helpers:parseBooleanEnvand the account-policygetAccountPolicyKey/normalizeAccountPolicyTagutilities. no sut code is changed.undefined) returnsundefined.sha256:<hex>format, no identity leakage, accountId priority over email, email case-insensitivity, and the "unknown" fallback bucket.[a-z0-9._-]{1,64}character class, and the bidirectionalnull ↔ whitespace-only inputiff (both directions are now covered, addressing the prior review round).Confidence Score: 5/5
additive test-only change with no sut modifications; safe to merge.
the change is a single new test file exercising two pure, side-effect-free helpers. both issues flagged in the prior review round are resolved. the remaining observations are minor coverage gaps in the test itself and do not affect any production path.
no files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[env-policy-parsing.property.test.ts] --> B[parseBooleanEnv properties] A --> C[account policy key/tag properties] B --> B1["prop 1: recognized literals under any casing + padding"] B --> B2["prop 2: everything else returns undefined"] C --> C1["prop 3: stable sha256 handles, no identity leak"] C --> C2["prop 4: idempotent fixpoints or null (bidirectional)"] B1 --> SUT1[lib/env-parsing.ts :: parseBooleanEnv] B2 --> SUT1 C1 --> SUT2[lib/account-policy.ts :: getAccountPolicyKey] C2 --> SUT3[lib/account-policy.ts :: normalizeAccountPolicyTag]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: generate the whitespace-only accou..." | Re-trigger Greptile