Summary
The ISO 8601 timestamp validation regex ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z$ is duplicated across 5 test files. If Get-StandardTimestamp in CIHelpers.psm1 changes its output format, every copy must be updated in lockstep. Centralizing the pattern in CIHelpers eliminates this maintenance risk.
Origin: PR #1314 review discussion with @WilliamBerryiii about moving timestamp concerns into a CI helper.
Current Behavior
The same regex is hard-coded in each test file that validates timestamp output:
| File |
Line |
scripts/tests/lib/CIHelpers.Tests.ps1 |
28 |
scripts/tests/security/SecurityClasses.Tests.ps1 |
195 |
scripts/tests/security/SecurityHelpers.Tests.ps1 |
146 |
scripts/tests/linting/FrontmatterValidation.Tests.ps1 |
356 |
scripts/tests/linting/Invoke-YamlLint.Tests.ps1 |
415 |
Expected Behavior
CIHelpers exports a Get-StandardTimestampPattern function (or module-scoped variable) returning the canonical regex. All test files reference that single source of truth instead of duplicating the pattern.
Proposed Approach
- Add to
scripts/lib/Modules/CIHelpers.psm1:
function Get-StandardTimestampPattern {
[CmdletBinding()]
[OutputType([string])]
param()
return '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z$'
}
- Export
Get-StandardTimestampPattern in the Export-ModuleMember list.
- Replace all hard-coded regex occurrences in test files with
Get-StandardTimestampPattern.
- Add a unit test in
CIHelpers.Tests.ps1 verifying the pattern matches Get-StandardTimestamp output.
Files Requiring Changes
| File |
Change |
scripts/lib/Modules/CIHelpers.psm1 |
Add Get-StandardTimestampPattern function and export |
scripts/tests/lib/CIHelpers.Tests.ps1 |
Use new function; add pattern-matches-output test |
scripts/tests/security/SecurityClasses.Tests.ps1 |
Replace hard-coded regex |
scripts/tests/security/SecurityHelpers.Tests.ps1 |
Replace hard-coded regex |
scripts/tests/linting/FrontmatterValidation.Tests.ps1 |
Replace hard-coded regex |
scripts/tests/linting/Invoke-YamlLint.Tests.ps1 |
Replace hard-coded regex |
RPI Framework Starter Prompts
Phase 1: Research
Select Task Researcher from the agent picker, then send:
Research ISO 8601 timestamp regex centralization. Investigate: (1) Grep all files under scripts/ for the pattern \d{4}-\d{2}-\d{2}T to find every occurrence of the timestamp regex. (2) Confirm the exact regex used in each location and note any slight variations. (3) Verify Get-StandardTimestamp output format matches the regex. (4) Check whether any non-test files also hard-code the pattern.
Phase 2: Plan
Select Task Planner from the agent picker, then send:
Plan centralization of the ISO 8601 timestamp regex into CIHelpers.psm1. The plan should cover: (1) Adding Get-StandardTimestampPattern to CIHelpers. (2) Updating all test files to use the new function. (3) Adding a unit test verifying the pattern matches Get-StandardTimestamp output. (4) Validation: npm run test:ps, npm run lint:ps.
Phase 3: Implement
Select Task Implementor from the agent picker, then send:
Implement ISO 8601 timestamp regex centralization following the plan. Steps: (1) Add Get-StandardTimestampPattern function to CIHelpers.psm1 and export it. (2) Replace all hard-coded timestamp regex patterns in test files. (3) Add a unit test in CIHelpers.Tests.ps1. (4) Run npm run lint:ps and npm run test:ps.
Phase 4: Review
Select Task Reviewer from the agent picker, then send:
Review ISO 8601 timestamp regex centralization. Verify: (1) No hard-coded timestamp regexes remain in test files. (2) Get-StandardTimestampPattern output matches Get-StandardTimestamp output. (3) All Pester tests pass. (4) npm run lint:ps clean.
References
Summary
The ISO 8601 timestamp validation regex
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z$is duplicated across 5 test files. IfGet-StandardTimestampinCIHelpers.psm1changes its output format, every copy must be updated in lockstep. Centralizing the pattern in CIHelpers eliminates this maintenance risk.Origin: PR #1314 review discussion with @WilliamBerryiii about moving timestamp concerns into a CI helper.
Current Behavior
The same regex is hard-coded in each test file that validates timestamp output:
scripts/tests/lib/CIHelpers.Tests.ps1scripts/tests/security/SecurityClasses.Tests.ps1scripts/tests/security/SecurityHelpers.Tests.ps1scripts/tests/linting/FrontmatterValidation.Tests.ps1scripts/tests/linting/Invoke-YamlLint.Tests.ps1Expected Behavior
CIHelpers exports a
Get-StandardTimestampPatternfunction (or module-scoped variable) returning the canonical regex. All test files reference that single source of truth instead of duplicating the pattern.Proposed Approach
scripts/lib/Modules/CIHelpers.psm1:Get-StandardTimestampPatternin theExport-ModuleMemberlist.Get-StandardTimestampPattern.CIHelpers.Tests.ps1verifying the pattern matchesGet-StandardTimestampoutput.Files Requiring Changes
scripts/lib/Modules/CIHelpers.psm1Get-StandardTimestampPatternfunction and exportscripts/tests/lib/CIHelpers.Tests.ps1scripts/tests/security/SecurityClasses.Tests.ps1scripts/tests/security/SecurityHelpers.Tests.ps1scripts/tests/linting/FrontmatterValidation.Tests.ps1scripts/tests/linting/Invoke-YamlLint.Tests.ps1RPI Framework Starter Prompts
Phase 1: Research
Select Task Researcher from the agent picker, then send:
Phase 2: Plan
Select Task Planner from the agent picker, then send:
Phase 3: Implement
Select Task Implementor from the agent picker, then send:
Phase 4: Review
Select Task Reviewer from the agent picker, then send:
References
scripts/lib/Modules/CIHelpers.psm1— target module for the new function