Provision default component policy for SimEnv - #4841
Conversation
Greptile SummaryThis PR fixes a gap where
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to provisioning a curated allow list that already existed in the YAML template; no new classes are permitted beyond what production workspaces already allow. The fix is straightforward: a duplicated hardcoded list is centralized, and the SimEnv code path that was missing the provisioning step now mirrors the behavior of PoC and production provisioners. All four branching cases in _ensure_default_component_policy are covered by unit tests, the integration test validates end-to-end execution, and the provisioning template test confirms the rendered output matches the constant. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SimEnv.deploy job] --> B[_ensure_default_component_policy]
B --> C{resources.json\nexists?}
C -- Yes --> D[target = resources.json]
C -- No --> E[target = resources.json.default]
D --> F{target file\nexists?}
E --> F
F -- Yes --> G[json.load target_file]
G --> H{valid dict?}
H -- No --> I[raise ValueError\nfail-closed]
H -- Yes --> J{CLASS_ALLOW_LIST\nalready present?}
F -- No --> K[start with empty\nformat_version 2 dict]
K --> J
J -- Yes --> L[return\npreserve user policy]
J -- No --> M[inject DEFAULT_CLASS_ALLOW_LIST]
M --> N[write to target_file]
N --> O[job.simulator_run]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[SimEnv.deploy job] --> B[_ensure_default_component_policy]
B --> C{resources.json\nexists?}
C -- Yes --> D[target = resources.json]
C -- No --> E[target = resources.json.default]
D --> F{target file\nexists?}
E --> F
F -- Yes --> G[json.load target_file]
G --> H{valid dict?}
H -- No --> I[raise ValueError\nfail-closed]
H -- Yes --> J{CLASS_ALLOW_LIST\nalready present?}
F -- No --> K[start with empty\nformat_version 2 dict]
K --> J
J -- Yes --> L[return\npreserve user policy]
J -- No --> M[inject DEFAULT_CLASS_ALLOW_LIST]
M --> N[write to target_file]
N --> O[job.simulator_run]
Reviews (3): Last reviewed commit: "Merge branch 'main' into feat/simenv-com..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4841 +/- ##
==========================================
+ Coverage 56.39% 56.41% +0.02%
==========================================
Files 968 969 +1
Lines 92166 92192 +26
==========================================
+ Hits 51976 52014 +38
+ Misses 40190 40178 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Addressed the two Greptile test observations in 5b4de91:
Validation: |
### Description Cherry-pick of #4888 (merged to `2.8` as c3daf63) onto `main`, bringing the class allow-list migration controls forward: - support `"*"` in `class_allow_list` to allow all component classes, ignore remaining entries, and record an audit event - add `class_list_enforcement_mode` with `enforce` (default) and `warn` behavior - include the enforcement mode in provisioned client and server resource templates - use the curated built-in default allow list (with an audit event) when a site does not configure `class_allow_list` - unit coverage for wildcard, warn/enforce modes, site configuration filtering, and provisioning defaults **Conflict resolutions vs `main`** (which had diverged via #4841): - `master_template.yml`: kept main's `{~~class_allow_list~~}` placeholder (filled from `DEFAULT_CLASS_ALLOW_LIST` by the static file builder) and added only the new `class_list_enforcement_mode` line to both client and server resource blocks - `default_component_policy.py`: kept main's copy (identical list); updated its docstring since the authorizer now does use it as the implicit default - `static_file_builder_test.py`: kept main's `DEFAULT_CLASS_ALLOW_LIST`-based assertion instead of the PR's inline list; the new enforcement-mode assertion is included - `unsafe_component_detection.rst`: adopted the PR's default-with-audit semantics, keeping main's provisioning and `SimEnv` sentences Note: this intentionally changes main's #4841 behavior for unconfigured sites from "fail with an explicit setup error" to "use the curated built-in default and record an audit event", matching 2.8. Main's no-fallback tests were superseded by the PR's `test_uses_default_allow_list_*` tests. ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Quick tests passed locally by running `./runtest.sh`. - [x] In-line docstrings updated. - [x] Documentation updated. Validation: 155 passed, 1 skipped across all unit suites referencing the policy/authorizer; flake8 and black clean on changed files. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Peter Cnudde <pcnudde@nvidia.com>
Summary
class_allow_listand render it into server and client provisioning resourcesresources.jsonprewriteRoot cause
Non-BYOC jobs are checked by
ComponentPathAuthorizer, but SimEnv did not provision the standard component policy used by PoC and production workspaces. The standalone NumPy cross-site evaluation example therefore failed in simulation unless a test or user manually createdlocal/resources.json.Impact
The documented standalone pretrained NumPy cross-site evaluation command now succeeds unchanged in SimEnv. Custom/BYOC handling is unchanged, no broad package prefix is introduced, and existing user policies remain authoritative.