Skip to content

Commit 905b696

Browse files
author
DavidQ
committed
Adds script safety hardening across Codex/deploy PowerShell automation by enforcing scripts/PS/deploy/ for deployment scripts, scripts/PS/codex/ for codex scripts, dry-run-first behavior, input/path validation, and Docker-compatible staging artifacts.
BUILD_PR_LEVEL_09_21_SCRIPT_VALIDATION_AND_SAFETY
1 parent ef2c9db commit 905b696

19 files changed

Lines changed: 296 additions & 75 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
- use scripts/PS/codex/ path
6-
- implement repo prep/update/clean scripts for website deployment
7-
- ensure safe, non-destructive defaults
5+
- enforce scripts/PS/deploy/ for deployment scripts
6+
- enforce scripts/PS/codex/ for codex scripts
7+
- add validation and safety checks to all scripts
8+
- add dry-run capability
9+
- ensure docker deployment compatibility
810
- enforce commit format:
9-
description starts first line (no leading CR)
11+
description starts first line
1012
PR name last line
1113
- update roadmap status only (no text changes except approved additions)

docs/dev/CODEX_PLAN_AND_API_KEY_SCRIPTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This repo includes a focused operator scripting surface in `scripts/PS/codex` fo
2020
Switch to Pay-as-you-go mode:
2121

2222
```powershell
23-
.\scripts\PS\codex\Switch-CodexPlanMode.ps1 -Mode payg
23+
.\scripts\PS\codex\Switch-CodexPlanMode.ps1 -Mode payg -DryRun
2424
```
2525

2626
Switch to Codex mode:
@@ -32,7 +32,7 @@ Switch to Codex mode:
3232
Set or update API key for current process only (safe for smoke checks):
3333

3434
```powershell
35-
.\scripts\PS\codex\Set-CodexApiKey.ps1 -ApiKey "sk-your-key" -Scope Process
35+
.\scripts\PS\codex\Set-CodexApiKey.ps1 -ApiKey "sk-your-key" -Scope Process -DryRun
3636
```
3737

3838
Set or update API key for current user profile:
@@ -44,7 +44,7 @@ Set or update API key for current user profile:
4444
Validate configured key state:
4545

4646
```powershell
47-
.\scripts\PS\codex\Validate-CodexApiKey.ps1 -EnvVarName OPENAI_API_KEY -RequireStateRecord
47+
.\scripts\PS\codex\Validate-CodexApiKey.ps1 -EnvVarName OPENAI_API_KEY -RequireStateRecord -DryRun
4848
```
4949

5050
Inspect current mode + metadata:
@@ -56,5 +56,6 @@ Inspect current mode + metadata:
5656
## Guardrails
5757
- Use `-Scope Process` for temporary sessions and script smoke checks.
5858
- Use `-Scope User` only when you intentionally want persistent user configuration.
59+
- Use `-DryRun` first for switch/set/validate/get scripts before applying persistent updates.
5960
- Validation checks local readiness and metadata consistency without printing raw secrets.
6061
- Keep the state file local to the repo; do not commit generated secret material.

docs/dev/CODEX_TEMPLATE_GAME_CREATION_SCRIPTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use `scripts/PS/codex/New-CodexTemplateGame.ps1` to create a new game scaffold f
77

88
## Example
99
```powershell
10-
.\scripts\PS\codex\New-CodexTemplateGame.ps1 -GameId "my-new-game" -DisplayName "My New Game"
10+
.\scripts\PS\codex\New-CodexTemplateGame.ps1 -GameId "my-new-game" -DisplayName "My New Game" -Apply
1111
```
1212

1313
## Generated Structure
@@ -23,4 +23,6 @@ Use `scripts/PS/codex/New-CodexTemplateGame.ps1` to create a new game scaffold f
2323
## Guardrails
2424
- Script normalizes `-GameId` to slug format for deterministic paths.
2525
- Script fails if the target game folder already exists.
26+
- Script defaults to dry-run output unless `-Apply` is provided.
27+
- `-DryRun` is supported explicitly for preview checks.
2628
- Script writes empty scaffold metadata only; no engine or gameplay files are altered.
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
# Codex Website Repo Deployment Scripting
22

3-
Use these scripts from `scripts/PS/codex/` to stage repo content for website deployment with safe defaults.
3+
Use these scripts from `scripts/PS/deploy/` to stage repo content for website deployment with safe defaults and Docker compatibility artifacts.
44

55
## Scripts
6-
- `scripts/PS/codex/Prep-WebsiteRepoDeployment.ps1`
7-
- `scripts/PS/codex/Update-WebsiteRepoDeployment.ps1`
8-
- `scripts/PS/codex/Clean-WebsiteRepoDeployment.ps1`
6+
- `scripts/PS/deploy/Prep-WebsiteRepoDeployment.ps1`
7+
- `scripts/PS/deploy/Update-WebsiteRepoDeployment.ps1`
8+
- `scripts/PS/deploy/Clean-WebsiteRepoDeployment.ps1`
99

1010
## Safety Defaults
11-
- All scripts default to preview-only mode.
11+
- All scripts default to dry-run mode.
1212
- No files are written or deleted unless `-Apply` is provided.
13+
- `-DryRun` is available explicitly on each script.
1314
- Clean operations are restricted to staging paths under `<repo>/tmp`.
1415

1516
## Typical Flow
16-
Prepare staging plan:
17+
Prepare staging plan and Docker artifacts:
1718

1819
```powershell
19-
.\scripts\PS\codex\Prep-WebsiteRepoDeployment.ps1 -Apply
20+
.\scripts\PS\deploy\Prep-WebsiteRepoDeployment.ps1 -Apply
2021
```
2122

2223
Update staged website content:
2324

2425
```powershell
25-
.\scripts\PS\codex\Update-WebsiteRepoDeployment.ps1 -Apply
26+
.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -Apply
2627
```
2728

2829
Clean staged site output only:
2930

3031
```powershell
31-
.\scripts\PS\codex\Clean-WebsiteRepoDeployment.ps1 -Apply
32+
.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -Apply
3233
```
3334

34-
Clean staged site output plus metadata files:
35+
Clean staged site output plus metadata and Docker files:
3536

3637
```powershell
37-
.\scripts\PS\codex\Clean-WebsiteRepoDeployment.ps1 -RemoveMetadata -Apply
38+
.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -RemoveMetadata -Apply
3839
```
3940

4041
## Outputs
@@ -43,3 +44,7 @@ Clean staged site output plus metadata files:
4344
- metadata root: `tmp/website-deploy/meta/`
4445
- `website-deploy-plan.json`
4546
- `website-deploy-last-update.json`
47+
- docker compatibility files in `tmp/website-deploy/`
48+
- `Dockerfile`
49+
- `docker-compose.yml`
50+
- `.dockerignore`

docs/dev/COMMIT_COMMENT.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Adds safe website deployment staging automation with prep/update/clean scripts under `scripts/PS/codex/`, preview-only defaults, and constrained clean behavior under `<repo>/tmp`.
1+
Adds script safety hardening across Codex/deploy PowerShell automation by enforcing `scripts/PS/deploy/` for deployment scripts, `scripts/PS/codex/` for codex scripts, dry-run-first behavior, input/path validation, and Docker-compatible staging artifacts.
22

3-
BUILD_PR_LEVEL_09_20_WEBSITE_REPO_PREP_SCRIPTING
3+
BUILD_PR_LEVEL_09_21_SCRIPT_VALIDATION_AND_SAFETY

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_PR_LEVEL_09_21_SCRIPT_VALIDATION_AND_SAFETY
1+
BUILD_PR_LEVEL_09_22_DEPLOYMENT_PIPELINE_INTEGRATION
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
Summary
2-
- Added website deployment scripting under `scripts/PS/codex/`:
2+
- Enforced script boundaries:
3+
- deployment scripts now live under `scripts/PS/deploy/`
4+
- codex scripts remain under `scripts/PS/codex/`
5+
- Added deployment safety/validation helpers in `scripts/PS/deploy/WebsiteRepoDeploymentCommon.ps1`.
6+
- Added/updated deployment scripts with dry-run and apply guards:
7+
- `scripts/PS/deploy/Prep-WebsiteRepoDeployment.ps1`
8+
- `scripts/PS/deploy/Update-WebsiteRepoDeployment.ps1`
9+
- `scripts/PS/deploy/Clean-WebsiteRepoDeployment.ps1`
10+
- Removed deployment script duplicates from `scripts/PS/codex/`:
311
- `Prep-WebsiteRepoDeployment.ps1`
412
- `Update-WebsiteRepoDeployment.ps1`
513
- `Clean-WebsiteRepoDeployment.ps1`
6-
- shared helper: `WebsiteRepoDeploymentCommon.ps1`
7-
- Implemented safe non-destructive defaults: scripts run in preview mode unless `-Apply` is provided.
8-
- Added deployment scripting usage/guardrails doc:
14+
- `WebsiteRepoDeploymentCommon.ps1`
15+
- Added Docker deployment compatibility artifacts to deploy flow (`Dockerfile`, `docker-compose.yml`, `.dockerignore` in staging root).
16+
- Hardened codex scripts with dry-run and validation where applicable:
17+
- `Switch-CodexPlanMode.ps1`
18+
- `Set-CodexApiKey.ps1`
19+
- `Validate-CodexApiKey.ps1`
20+
- `Get-CodexOperatorState.ps1`
21+
- `New-CodexTemplateGame.ps1`
22+
- Updated docs for new deploy path and script guardrails:
923
- `docs/dev/CODEX_WEBSITE_REPO_DEPLOYMENT_SCRIPTING.md`
10-
- Updated roadmap with status-only bracket change for the website prep/update/delete scripting lane.
11-
- Commit comment format is description on first line and PR name on last line.
24+
- `docs/dev/CODEX_TEMPLATE_GAME_CREATION_SCRIPTING.md`
25+
- `docs/dev/CODEX_PLAN_AND_API_KEY_SCRIPTING.md`
26+
- Updated roadmap with status-only bracket change.
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
Validation Checklist - BUILD_PR_LEVEL_09_20_WEBSITE_REPO_PREP_SCRIPTING
1+
Validation Checklist - BUILD_PR_LEVEL_09_21_SCRIPT_VALIDATION_AND_SAFETY
22

3-
[x] website deployment scripts added under `scripts/PS/codex/`
4-
[x] scripts default to preview mode unless `-Apply` is provided
5-
[x] clean script safety checks restrict deletes to staging paths under `<repo>/tmp`
3+
[x] deployment scripts moved/enforced to `scripts/PS/deploy/`
4+
[x] codex scripts remain/enforced under `scripts/PS/codex/`
5+
[x] validation and safety checks added to touched codex/deploy scripts
6+
[x] dry-run capability added to touched codex/deploy scripts
7+
[x] deploy flow writes Docker-compatible artifacts in staging
68
[x] focused PowerShell parse checks pass on touched scripts
7-
[x] focused prep/update/clean smoke checks pass
9+
[x] focused dry-run/apply smoke checks pass for deploy scripts
10+
[x] focused dry-run/apply smoke checks pass for touched codex scripts
811
[x] roadmap updated with status-only bracket changes
912
[x] commit format enforced: description first line, PR name last line

docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@
552552
- [x] smoke validation aligned to samples/tools/games
553553
- [ ] fixtures/helpers organization normalized
554554
- [.] move/refactor validation strategy documented
555-
- [ ] post-PR acceptance criteria consistently enforced
555+
- [.] post-PR acceptance criteria consistently enforced
556556

557557
---
558558

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# BUILD_PR — LEVEL 09_21 — SCRIPT VALIDATION AND SAFETY
2+
3+
## Objective
4+
Add validation, safety checks, and guardrails across all PowerShell scripting introduced so far.
5+
6+
## Key Updates
7+
- 09_20 deploy scripts must reside in: scripts/PS/deploy/
8+
- Target deployment: Docker-based web servers
9+
- Codex scripts remain in: scripts/PS/codex/
10+
- Commit format: description first line, no leading CR, PR name last
11+
12+
## Scope
13+
- validate all script inputs
14+
- add dry-run / safe execution modes
15+
- prevent destructive actions without confirmation
16+
- enforce correct script locations
17+
18+
## Out of Scope
19+
- no runtime changes
20+
- no tool UI changes
21+
22+
## Roadmap Instruction
23+
- Update roadmap status only
24+
- Maintain previously added roadmap items

0 commit comments

Comments
 (0)