-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Summary
Five distinct timestamp formats exist across linting and security scripts with no shared utility function. This causes inconsistent log output that makes cross-script correlation unreliable. Add a Get-StandardTimestamp function to CIHelpers.psm1 returning ISO 8601 UTC format.
Current Behavior
Scripts use 5 different timestamp expressions:
Get-Date -Format "o"(local offset) — 4 scripts(Get-Date).ToUniversalTime().ToString("o")(UTC) — 2 scriptsGet-Date -Format 'yyyy-MM-dd HH:mm:ss'(no timezone) — SecurityHelpers'yyyy-MM-ddTHH:mm:ss.fffZ'(fake UTC) — SecurityClasses ComplianceReport[datetime]::UtcNow(raw .NET) — FrontmatterValidation
Expected Behavior
A single Get-StandardTimestamp function in CIHelpers.psm1 returns (Get-Date).ToUniversalTime().ToString("o") (ISO 8601 UTC). All scripts that generate timestamps use this function for consistency.
Root Cause
No shared timestamp utility was created when the scripts were developed independently. Each author chose their own format.
Files Requiring Changes
| File | Change |
|---|---|
scripts/lib/Modules/CIHelpers.psm1 |
Add Get-StandardTimestamp function |
scripts/tests/lib/CIHelpers.Tests.ps1 |
Add tests for Get-StandardTimestamp |
Fix Guidance
Add to CIHelpers.psm1:
function Get-StandardTimestamp {
<#
.SYNOPSIS
Returns the current UTC time in ISO 8601 format.
#>
[CmdletBinding()]
[OutputType([string])]
param()
return (Get-Date).ToUniversalTime().ToString("o")
}Export the function in the module's Export-ModuleMember or FunctionsToExport manifest.
Unit Testing and Code Coverage Requirements
Pester tests should verify:
- Returns a string
- String matches ISO 8601 pattern with
Zsuffix (UTC) - Consecutive calls return monotonically increasing timestamps
RPI Phase Testing Guidance:
- Research: Audit CIHelpers.psm1 export mechanism and existing test patterns.
- Plan: Design test cases for format validation and UTC verification.
- Implement: Add function and tests.
- Review: Confirm function is exported and tests pass.
RPI Framework Starter Prompts
Phase 1: Research
Select Task Researcher from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Research adding
Get-StandardTimestampto CIHelpers.psm1. Investigate: (1) Readscripts/lib/Modules/CIHelpers.psm1to understand the module structure, existing exported functions, and the export mechanism (Export-ModuleMember or manifest). (2) Audit all 5 timestamp formats currently in use — identify exact file paths and line numbers for each. (3) Checkscripts/tests/lib/CIHelpers.Tests.ps1for existing test patterns and mock conventions. (4) Determine whether the function should accept parameters (e.g.,-AsDateTimeto return a DateTime object instead of string) or be zero-parameter. (5) Review ISO 8601 format options —"o"round-trip format includes fractional seconds andZsuffix when UTC.
Phase 2: Plan
Select Task Planner from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Plan adding
Get-StandardTimestampto CIHelpers.psm1 using the research document. The plan should cover: (1) Adding the function with[CmdletBinding()],[OutputType([string])], and zero parameters. (2) Returning(Get-Date).ToUniversalTime().ToString("o"). (3) Exporting the function alongside existing exports. (4) Adding Pester tests for return type, ISO 8601 format match, and UTC suffix. (5) Validation:npm run test:ps,npm run lint:ps.
Phase 3: Implement
Select Task Implementor from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Implement
Get-StandardTimestampin CIHelpers.psm1 following the plan. Steps: (1) Add the function toscripts/lib/Modules/CIHelpers.psm1with comment-based help. (2) Ensure it is exported in the module's export mechanism. (3) Add tests toscripts/tests/lib/CIHelpers.Tests.ps1verifying: returns string, matches ISO 8601 pattern, ends withZ. (4) Runnpm run lint:psfor PSScriptAnalyzer. (5) Runnpm run test:psfor Pester.
Phase 4: Review
Select Task Reviewer from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Review
Get-StandardTimestampaddition to CIHelpers.psm1. Verify: (1) Function follows PowerShell conventions:[CmdletBinding()],[OutputType()], comment-based help. (2) Returns ISO 8601 UTC string with.ToString("o"). (3) Function is properly exported from the module. (4) Pester tests cover return type, format validation, and UTC verification. (5)npm run lint:pspasses. (6)npm run test:pspasses. (7) No other module functions were modified.
References
scripts/lib/Modules/CIHelpers.psm1— target modulescripts/tests/lib/CIHelpers.Tests.ps1— test file- Cross-cutting: This is a prerequisite for Issues 8-17 (per-script timestamp standardization)