← Back to Pull requests

Add tests to ensure specs and plans conform to validation #67

Open
codebot-robot opened this pull request with 152 lines diff across 1 files
View on GitHub
codebot-robot codebot-robot commented on May 05, 2026 22:17 UTC
Author

This PR adds tests to the root-level test/ directory to ensure that all specs and plans conform to validation. It uses the validators from the tool command.

Fixes #66

Diff: 152 lines (+152 / -0) across 1 files Reviewer: mtaufen Review duration: 308033m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.40) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 152 lines diff across 1 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.83 · 1 substantive comment(s)
0.83
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
84%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.301
Real PR Conversation Timeline
4 items
mtaufen mtaufen commented on code on May 05, 2026 22:24 UTC
Code Review
test/validation_test.go:1
@@ -0,0 +1,94 @@
+// Copyright 2026 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package test
+
+import (
+	"bytes"
+	"os"
+	"path/filepath"
+	"strings"
+	"testing"
+
+	planvalidate "github.com/ai-on-gke/ai-factory/tool/cmd/tool/plan/validate"
+	specvalidate "github.com/ai-on-gke/ai-factory/tool/cmd/tool/spec/validate"
+)
+
+func TestValidateSpecs(t *testing.T) {
+	specsDir := filepath.Join("..", "specs")
+	entries, err := os.ReadDir(specsDir)
+	if err != nil {
+		if os.IsNotExist(err) {
+			t.Skip("specs directory does not exist")
+		}
+		t.Fatalf("Failed to read specs directory: %v", err)
+	}
+
+	for _, entry := range entries {
+		if entry.IsDir() {
+			continue
+		}
+		if !strings.HasSuffix(entry.Name(), ".md") {
+			continue
+		}
+		if strings.EqualFold(entry.Name(), "readme.md") || strings.EqualFold(entry.Name(), "template.md") {
+			continue
+		}
+
+		specName := strings.TrimSuffix(entry.Name(), ".md")
+
+		t.Run(specName, func(t *testing.T) {
+			cmd := specvalidate.Cmd

import the validate packages from tool/pkg, not the commands

mtaufen mtaufen commented on May 05, 2026 22:37 UTC
Reviewer

Good point on factoring those things out of the commands! Let's also factor out the part that finds the project root, so the new tests can use that rather than assuming they're in tests/, and let's add options to tool plan validate and tool spec validate to check the entire plan/ or spec/ dir, so the iteration is also abstracted into the library.

mtaufen mtaufen commented on May 05, 2026 23:16 UTC
Reviewer

Since this was a lot of refactoring, add tests and run them to make sure that the tools still work.

Reviewers
Assignees
codebot-robot codebot-robot
Labels
risk: low confidence: 84.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 40.1% (MEDIUM) · Higher = larger blast radius
40.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 84.7% · Lower = rushed or shallow review
84.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 6.1% · Safe to merge
6.1%