Skip to content

Commit 4780e58

Browse files
committed
feat(uat): enforce simulation blocking and add smart platform-specific defaults
1 parent 9ed474e commit 4780e58

File tree

4 files changed

+92
-75
lines changed

4 files changed

+92
-75
lines changed

.github/agents/uat-tester.agent.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Validate that generated markdown renders correctly in real-world PR environments
2828
### ✅ Always Do
2929
- Prefer `scripts/uat-run.sh` for end-to-end UAT (single stable command)
3030
- Use `scripts/uat-github.sh` and `scripts/uat-azdo.sh` for targeted operations / debugging
31+
- **Platform-specific artifacts are automatically selected if not specified:**
32+
- GitHub: `examples/comprehensive-demo/report.md` (standard diff format)
33+
- Azure DevOps: `examples/comprehensive-demo/report-inline-diff.md` (inline diff format, if available)
34+
- For simulations: use `artifacts/uat-simulation-*.md` (requires `UAT_SIMULATE=true`)
3135
- Before creating any PR, post the **exact Title and Description** in chat using the standard template (Problem / Change / Verification)
3236
- Post markdown as **PR comments** (not PR description)
3337
- Prefix comments with agent identifier (scripts do this automatically)
@@ -53,7 +57,7 @@ Validate that generated markdown renders correctly in real-world PR environments
5357
- Perform any verification beyond visual rendering in PRs
5458
- Run unrelated tasks while waiting for feedback
5559
- Use background polling (`nohup`, `&`) — poll in the foreground and act immediately on results
56-
- Bypass the UAT artifact guardrails (do not set `UAT_ALLOW_MINIMAL=1` for real UAT)
60+
- **Use simulation artifacts for real UAT** — scripts will reject them unless `UAT_SIMULATE=true` is explicitly set
5761

5862
## Response Style
5963

@@ -136,7 +140,9 @@ Save this to `artifacts/uat-minimal.md` (or `artifacts/uat-simulation-YYYY-MM-DD
136140
### Default Parameters
137141

138142
When not specified by the user, use these defaults:
139-
- **Artifact**: Prefer `artifacts/uat-minimal.md` if present; otherwise use the most recently modified `.md` file in `artifacts/`
143+
- **Artifact (GitHub)**: `examples/comprehensive-demo/report.md` (automatically selected by `uat-github.sh`)
144+
- **Artifact (Azure DevOps)**: `examples/comprehensive-demo/report-inline-diff.md` (automatically selected by `uat-azdo.sh`)
145+
- **For simulations**: Use `artifacts/uat-simulation-*.md` and set `UAT_SIMULATE=true` environment variable
140146
- **UAT Branch Name**: `uat/simulation-YYYY-MM-DD` where YYYY-MM-DD is today's date
141147
- **If branch already exists**: Append `-v2`, `-v3`, etc. to make it unique
142148

scripts/uat-azdo.sh

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
3030
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
3131
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
3232

33+
# Validate and set default artifact path
34+
# Args: $1=artifact path (or empty for default), $2=simulate flag, $3=force flag
35+
validate_artifact() {
36+
local artifact="${1:-}"
37+
local simulate="${2:-false}"
38+
local force="${3:-false}"
39+
40+
# Default to comprehensive demo with inline-diff format for Azure DevOps
41+
if [[ -z "$artifact" ]]; then
42+
# Azure DevOps requires inline-diff format for better rendering
43+
if [[ -f "examples/comprehensive-demo/report-inline-diff.md" ]]; then
44+
artifact="examples/comprehensive-demo/report-inline-diff.md"
45+
else
46+
# Fallback to standard format if inline-diff not available
47+
artifact="examples/comprehensive-demo/report.md"
48+
fi
49+
log_info "No artifact specified, using Azure DevOps default: $artifact"
50+
fi
51+
52+
# Check if artifact exists
53+
if [[ ! -f "$artifact" ]]; then
54+
log_error "Artifact not found: $artifact"
55+
exit 1
56+
fi
57+
58+
# Block simulation artifacts in real UAT runs
59+
if [[ "$artifact" =~ simulation ]] && [[ "$simulate" != "true" ]] && [[ "$force" != "true" ]]; then
60+
log_error "Simulation artifact detected: $artifact"
61+
log_error "Simulation artifacts should not be used for real UAT."
62+
log_error "Use --simulate flag for simulation mode, or --force to override."
63+
exit 1
64+
fi
65+
66+
log_info "✓ Using artifact: $artifact"
67+
echo "$artifact"
68+
}
69+
3370
cmd_setup() {
3471
log_info "Checking Azure CLI authentication..."
3572
if ! az account show >/dev/null 2>&1; then
@@ -51,22 +88,11 @@ cmd_setup() {
5188

5289
cmd_create() {
5390
local file="${1:-}"
54-
if [[ -z "$file" || ! -f "$file" ]]; then
55-
log_error "Usage: $0 create <markdown-file>"
56-
exit 1
57-
fi
58-
59-
# Guardrail: prevent accidental posting of minimal/simulation artifacts for real UAT.
60-
# Override by setting UAT_ALLOW_MINIMAL=1 (intended for simulate-uat).
61-
if [[ "${UAT_ALLOW_MINIMAL:-}" != "1" ]]; then
62-
if echo "$(basename "$file")" | grep -qiE '(minimal|simulation)'; then
63-
log_error "Refusing to use a minimal/simulation artifact for real UAT: $file"
64-
log_error "Use artifacts/comprehensive-demo.md (recommended), or set UAT_ALLOW_MINIMAL=1 to override."
65-
exit 1
66-
fi
67-
fi
91+
local simulate="${UAT_SIMULATE:-false}"
92+
local force="${UAT_FORCE:-false}"
6893

69-
log_info "Using artifact: $file"
94+
# Validate and potentially set default artifact
95+
file="$(validate_artifact "$file" "$simulate" "$force")"
7096

7197
local branch
7298
branch=$(git branch --show-current)

scripts/uat-github.sh

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,45 @@ log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
2020
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
2121
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
2222

23-
cmd_create() {
24-
local file="${1:-}"
25-
if [[ -z "$file" || ! -f "$file" ]]; then
26-
log_error "Usage: $0 create <markdown-file>"
23+
# Validate and set default artifact path
24+
# Args: $1=artifact path (or empty for default), $2=simulate flag, $3=force flag
25+
validate_artifact() {
26+
local artifact="${1:-}"
27+
local simulate="${2:-false}"
28+
local force="${3:-false}"
29+
30+
# Default to comprehensive demo if no artifact specified
31+
if [[ -z "$artifact" ]]; then
32+
artifact="examples/comprehensive-demo/report.md"
33+
log_info "No artifact specified, using GitHub default: $artifact"
34+
fi
35+
36+
# Check if artifact exists
37+
if [[ ! -f "$artifact" ]]; then
38+
log_error "Artifact not found: $artifact"
2739
exit 1
2840
fi
29-
30-
# Guardrail: prevent accidental posting of minimal/simulation artifacts for real UAT.
31-
# Override by setting UAT_ALLOW_MINIMAL=1 (intended for simulate-uat).
32-
if [[ "${UAT_ALLOW_MINIMAL:-}" != "1" ]]; then
33-
if echo "$(basename "$file")" | grep -qiE '(minimal|simulation)'; then
34-
log_error "Refusing to use a minimal/simulation artifact for real UAT: $file"
35-
log_error "Use artifacts/comprehensive-demo.md (recommended), or set UAT_ALLOW_MINIMAL=1 to override."
36-
exit 1
37-
fi
41+
42+
# Block simulation artifacts in real UAT runs
43+
if [[ "$artifact" =~ simulation ]] && [[ "$simulate" != "true" ]] && [[ "$force" != "true" ]]; then
44+
log_error "Simulation artifact detected: $artifact"
45+
log_error "Simulation artifacts should not be used for real UAT."
46+
log_error "Use --simulate flag for simulation mode, or --force to override."
47+
exit 1
3848
fi
3949

50+
log_info "✓ Using artifact: $artifact"
51+
echo "$artifact"
52+
}
53+
54+
cmd_create() {
55+
local file="${1:-}"
56+
local simulate="${UAT_SIMULATE:-false}"
57+
local force="${UAT_FORCE:-false}"
58+
59+
# Validate and potentially set default artifact
60+
file="$(validate_artifact "$file" "$simulate" "$force")"
61+
4062
local branch
4163
branch=$(git branch --show-current)
4264
local title="UAT: $(basename "$file" .md)"

scripts/uat-run.sh

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,18 @@ if [[ "$platform" != "both" && "$platform" != "github" && "$platform" != "azdo"
5555
die_usage
5656
fi
5757

58-
default_artifact="artifacts/comprehensive-demo.md"
59-
artifact_github="${UAT_ARTIFACT_GITHUB:-$default_artifact}"
60-
artifact_azdo="${UAT_ARTIFACT_AZDO:-$default_artifact}"
58+
# Smart defaults: Let individual scripts determine platform-specific defaults
59+
# unless explicitly overridden
60+
artifact_github="${UAT_ARTIFACT_GITHUB:-}"
61+
artifact_azdo="${UAT_ARTIFACT_AZDO:-}"
6162

6263
if [[ -n "$artifact_arg" ]]; then
6364
artifact_github="$artifact_arg"
6465
artifact_azdo="$artifact_arg"
6566
fi
6667

67-
if [[ "$platform" == "both" || "$platform" == "github" ]]; then
68-
if [[ ! -f "$artifact_github" ]]; then
69-
log_error "Artifact not found for GitHub: $artifact_github"
70-
exit 1
71-
fi
72-
fi
73-
74-
if [[ "$platform" == "both" || "$platform" == "azdo" ]]; then
75-
if [[ ! -f "$artifact_azdo" ]]; then
76-
log_error "Artifact not found for AzDO: $artifact_azdo"
77-
exit 1
78-
fi
79-
fi
68+
# Note: Artifact existence checks moved to individual scripts
69+
# which will also apply smart defaults if artifact is empty
8070

8171
original_branch="$(git branch --show-current)"
8272
if [[ "$original_branch" == "main" ]]; then
@@ -89,35 +79,8 @@ if [[ -n "$(git status --porcelain)" ]]; then
8979
exit 1
9080
fi
9181

92-
# Artifact guardrails: prevent accidental posting of minimal/simulation artifacts.
93-
# Override by setting UAT_ALLOW_MINIMAL=1 (intended for simulate-uat).
94-
if [[ "${UAT_ALLOW_MINIMAL:-}" != "1" ]]; then
95-
if [[ "$platform" == "both" || "$platform" == "github" ]]; then
96-
if echo "$(basename "$artifact_github")" | grep -qiE '(minimal|simulation)'; then
97-
log_error "Refusing to use a minimal/simulation artifact for real UAT: $artifact_github"
98-
log_error "Use $default_artifact (default), or set UAT_ALLOW_MINIMAL=1 to override."
99-
exit 1
100-
fi
101-
fi
102-
103-
if [[ "$platform" == "both" || "$platform" == "azdo" ]]; then
104-
if echo "$(basename "$artifact_azdo")" | grep -qiE '(minimal|simulation)'; then
105-
log_error "Refusing to use a minimal/simulation artifact for real UAT: $artifact_azdo"
106-
log_error "Use $default_artifact (default), or set UAT_ALLOW_MINIMAL=1 to override."
107-
exit 1
108-
fi
109-
fi
110-
fi
111-
112-
if [[ "$platform" == "both" ]]; then
113-
log_info "Using artifacts:"
114-
log_info " GitHub: $artifact_github"
115-
log_info " AzDO: $artifact_azdo"
116-
elif [[ "$platform" == "github" ]]; then
117-
log_info "Using artifact (GitHub): $artifact_github"
118-
else
119-
log_info "Using artifact (AzDO): $artifact_azdo"
120-
fi
82+
# Artifact validation is now handled by individual scripts (uat-github.sh / uat-azdo.sh)
83+
# which will enforce simulation blocking and apply platform-specific smart defaults
12184

12285
timestamp="$(date -u +%Y%m%d%H%M%S)"
12386
# Create a unique, safe UAT branch name.

0 commit comments

Comments
 (0)