[codex] Resolve issue batch except manual screenshots - #30
Conversation
Greptile SummaryThis PR resolves a batch of open issues by adding backup retention listing/pruning, Brave Beta/Nightly channel support, a policy-template version bump helper, Pester preset tests, CI PSScriptAnalyzer/Pester wiring, checksum generation, and supporting docs.
Confidence Score: 4/5Safe to merge after fixing the UTF-8-with-BOM write in Update-PolicyTemplateVersion.ps1. The core apply/backup/restore paths are unchanged and correct. The one defect is in the new maintainer helper: Set-Content -Encoding UTF8 silently writes a byte-order mark on Windows PowerShell 5.1, which would leave policies.json starting with \uFEFF after the first version bump run on WPS 5.1 — invalid JSON for any non-PowerShell consumer. All other additions — backup retention, channel support, Pester tests, CI version pinning, checksum generation — are correct and well-tested. scripts/Update-PolicyTemplateVersion.ps1 — the two Set-Content calls need a BOM-free UTF-8 encoding for WPS 5.1 compatibility. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Invoke-BraveDebloat.ps1] --> B{ListBackups or\nPruneBackups or\nKeepLatest?}
B -- Yes --> C[Invoke-BackupRetention]
C --> D[Get-BackupFiles\nFilter BraveDebloater-*.json\nSort by LastWriteTime DESC]
D --> E[Write-Step: list found backups]
C --> F{Prune requested?}
F -- OlderThanDays >= 0 --> G[Filter by cutoff date]
F -- KeepLatest >= 0 --> H[Select-Object -Skip N]
G & H --> I[Deduplicate remove list]
I --> J{remove.Count == 0?}
J -- Yes, prune requested --> K[Write-Step: nothing to remove]
J -- No --> L{DoApply?}
L -- Yes --> M[Remove-Item with try/catch\nWrite-Warning on failure]
L -- No --> N[Write-DryRun: Would remove...]
B -- No --> O{UndoFromBackup?}
O -- Yes --> P[Restore-RegistryBackup]
O -- No --> Q[Normal apply / dry-run flow]
R[Update-PolicyTemplateVersion.ps1] --> S[Read VERSION from zip\nvia PolicyTemplateVersion.ps1]
S --> T[Extract keys by name\nMAJOR.MINOR.BUILD.PATCH]
T --> U[Regex-replace policies.json\nand debloatable-validation.md]
%%{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[Invoke-BraveDebloat.ps1] --> B{ListBackups or\nPruneBackups or\nKeepLatest?}
B -- Yes --> C[Invoke-BackupRetention]
C --> D[Get-BackupFiles\nFilter BraveDebloater-*.json\nSort by LastWriteTime DESC]
D --> E[Write-Step: list found backups]
C --> F{Prune requested?}
F -- OlderThanDays >= 0 --> G[Filter by cutoff date]
F -- KeepLatest >= 0 --> H[Select-Object -Skip N]
G & H --> I[Deduplicate remove list]
I --> J{remove.Count == 0?}
J -- Yes, prune requested --> K[Write-Step: nothing to remove]
J -- No --> L{DoApply?}
L -- Yes --> M[Remove-Item with try/catch\nWrite-Warning on failure]
L -- No --> N[Write-DryRun: Would remove...]
B -- No --> O{UndoFromBackup?}
O -- Yes --> P[Restore-RegistryBackup]
O -- No --> Q[Normal apply / dry-run flow]
R[Update-PolicyTemplateVersion.ps1] --> S[Read VERSION from zip\nvia PolicyTemplateVersion.ps1]
S --> T[Extract keys by name\nMAJOR.MINOR.BUILD.PATCH]
T --> U[Regex-replace policies.json\nand debloatable-validation.md]
Reviews (2): Last reviewed commit: "Address backup and CI review comments" | Re-trigger Greptile |
|
@greptileai safe to merge? |
|
Yes, safe to merge. Here's the summary: All 4 review threads are resolved, and the current diff confirms the fixes are in place:
The PR is mergeable (clean state, no conflicts). All new functionality (backup retention, Beta/Nightly channel support, |
|
@greptileai thanks for ur hard work <3 |
|
Thanks! Happy to help keep the codebase clean. Let me know if anything else comes up during review. 🙂 |
Summary
Fixes #10
Fixes #11
Fixes #13
Fixes #15
Fixes #16
Fixes #17
Fixes #18
Fixes #19
Validation
pwsh -NoProfile -File scripts/Test-PolicyManifest.ps1pwsh -NoProfile -File scripts/Test-Behavior.ps1pwsh -NoProfile -File scripts/Test-LatestPolicyTemplates.ps1 -TemplateZipPath /tmp/brave-policy-templates.zippwsh -NoProfile -File scripts/Update-PolicyTemplateVersion.ps1 -TemplateZipPath /tmp/brave-policy-templates.ziptests/PresetResolution.Tests.ps1,scripts/New-ReleaseChecksums.ps1, andscripts/Update-PolicyTemplateVersion.ps1-ListBackupsand-Channel Nightly