Skip to content

[purelock] Lock down simplifyDataSchemaNode with a pure-function test suite - #51167

Merged
pelikhan merged 1 commit into
mainfrom
purelock/simplify-data-schema-node-9f0f2358ad180181
Aug 7, 2026
Merged

[purelock] Lock down simplifyDataSchemaNode with a pure-function test suite#51167
pelikhan merged 1 commit into
mainfrom
purelock/simplify-data-schema-node-9f0f2358ad180181

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR is a test-only change that adds a comprehensive, pure-function test suite for simplifyDataSchemaNode in pkg/workflow/safe_outputs_data_schema_test.go. No production code is modified.

Key facts

  • Files changed: 1 (pkg/workflow/safe_outputs_data_schema_test.go)
  • Lines: ~456 added, 0 removed (purely additive)
  • New test: TestSimplifyDataSchemaNode — table-driven, t.Parallel() at top level and per subtest
  • Breaking changes: none
  • Production code changes: none

What is tested

The suite locks down the behavior of simplifyDataSchemaNode(raw any, path string, allowShorthand bool) (map[string]any, error):

  • String shorthand support (e.g. "string"{"type": "string"}) when allowShorthand is true
  • Error when shorthand is disallowed: "string shorthand is not allowed here"
  • Error for unsupported shorthand type: "unsupported type ..."
  • Error when raw input is neither an object nor a string: "expected an object schema"
  • Object schemas with numeric constraints (minimum/maximum passthrough)
  • Boolean type schema with no extra keywords
  • Unicode description/property names and paths (e.g. properties keyed 日本語, path ), verifying required field extraction and pass-through behavior
File-by-file detail
  • pkg/workflow/safe_outputs_data_schema_test.go (modified): Added TestSimplifyDataSchemaNode, a table-driven test covering string shorthand handling, object/array schema validation, numeric constraint passthrough, boolean types, unicode property names, and error paths for simplifyDataSchemaNode.

Purpose

Consistent with the PR title ("[purelock]"), this change locks down the existing pure-function behavior of simplifyDataSchemaNode with regression-guarding test coverage, without altering runtime logic.> Generated by PR Description Updater for #51167 · auto · 42.3 AIC · ⊞ 6.9K ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review August 7, 2026 19:15
Copilot AI balanced review requested due to automatic review settings August 7, 2026 19:15
@pelikhan
pelikhan merged commit 6ebe869 into main Aug 7, 2026
8 checks passed
@pelikhan
pelikhan deleted the purelock/simplify-data-schema-node-9f0f2358ad180181 branch August 7, 2026 19:15
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Security scanning failed for PR Code Quality Reviewer. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Security scanning failed for Matt Pocock Skills Reviewer. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Security scanning failed for Test Quality Sentinel. Review the logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ failed during design decision gate check.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds comprehensive table-driven tests for simplifyDataSchemaNode, covering normalization, validation, recursion, and error paths.

Changes:

  • Exercises schema shorthand and type inference.
  • Covers object, array, scalar, enum, and validation behavior.
  • Runs cases concurrently.
Show a summary per file
File Description
pkg/workflow/safe_outputs_data_schema_test.go Adds comprehensive unit coverage for schema simplification.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

},
},
{
name: "unicode description and property names pass through",

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test suite is thorough and well-structured. All cases use t.Parallel() correctly, error messages are checked precisely with assert.Contains, and the table covers the key invariants: type inference, enum validation, recursive normalization, additionalProperties defaulting, and shorthand expansion. No blocking issues.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16.4 AIC · ⊞ 5.5K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: No blocking issues

Test-only PR adding TestSimplifyDataSchemaNode (34 subtests) for the pure simplifyDataSchemaNode function. Ran the suite locally — all subtests pass, and test expectations match the actual implementation branches (shorthand handling, object/array/enum/required/additionalProperties validation, error messages).

Review notes
  • No production code changed; this is purely additive test coverage.
  • Table-driven structure with proper t.Parallel() usage on both parent and subtests.
  • Error message assertions use Contains, which is appropriately tolerant of message formatting while still verifying key content.
  • Coverage of edge cases (unicode property names, enum scalar validation, nested property/array error propagation, forced-required+sorted output) is thorough.

No correctness, performance, or maintainability concerns found in the diff.

🔎 Code quality review by PR Code Quality Reviewer · auto · 16.3 AIC · ⊞ 7.8K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd — approving with two minor suggestions.

📋 Key Themes & Highlights

Key Themes

  • Shorthand expansion check (line 196): the test verifies count and top-level fields but not individual expanded property schemas — a malformed child would silently pass.
  • int64 enum value (line 306): int64(2) is accepted by the implementation type switch, but JSON/YAML unmarshaling never produces int64. This could be testing a realistic but unreachable code path without explanation.

Positive Highlights

  • ✅ 34 parallel subtests — excellent isolation and fast feedback
  • ✅ Exhaustive error-path coverage: every wantErr case maps to a distinct error message
  • ✅ Unicode test is a nice touch for a parser that touches user-facing paths
  • assert.Nil(t, result) on error path is precise — catches the function contract
  • ✅ Table-driven structure is clean and easy to extend

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 34.6 AIC · ⊞ 7.1K
Comment /matt to run again

assert.Equal(t, []string{"score", "verdict"}, result["required"])
properties, ok := result["properties"].(map[string]any)
require.True(t, ok)
assert.Len(t, properties, 2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The shorthand-expansion check verifies the count and top-level fields but never inspects individual expanded property schemas — a malformed child would still pass.

💡 Suggested addition
scoreSchema, ok := properties["score"].(map[string]any)
require.True(t, ok)
assert.Equal(t, "number", scoreSchema["type"])

@copilot please address this.

path: "root",
allowShorthand: false,
check: func(t *testing.T, result map[string]any) {
assert.Equal(t, []any{"a", 1, 1.5, true, int64(2)}, result["enum"])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The enum test uses int64(2) as an enum value, but the implementation accepts int64 alongside int and float64. In practice, YAML/JSON unmarshalling never produces int64 — it produces float64 or int. If the production code path doesn't preserve int64, this assertion would silently be testing a dead path.

Consider replacing int64(2) with float64(2) (matching what JSON unmarshal produces) or adding a comment explaining why int64 is a legitimate value here.

@copilot please address this.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

Test Quality Score: 100/100 — Excellent

Analyzed 1 new test: 1 design test, 0 implementation tests, 0 violations.

📊 Metrics
Metric Value
Test functions analyzed 1 (TestSimplifyDataSchemaNode)
✅ Design 1 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 31 scenarios (16 error, 15 success paths)
Duplicate clusters 0
Test inflation N/A (test-only, no production changes)
🚨 Violations 0
✅ Test Classification

TestSimplifyDataSchemaNode (pkg/workflow/safe_outputs_data_schema_test.go:134–585)

  • Type: Table-driven, t.Parallel() at outer level and per-subtest

  • Classification: behavioral_contract, high_value, design_test

  • Coverage: 31 distinct scenarios:

    • String shorthand: supported/disallowed/unsupported type paths
    • Type validation: object, array, string, number, integer, boolean
    • Object schemas: property expansion, required field sorting, additionalProperties constraint
    • Array schemas: nested item type resolution
    • Validation: description (string only), enum (non-empty, scalars), constraints (minLength, maxLength, pattern, minimum, maximum)
    • Error paths: 16 scenarios with explicit error message assertions
    • Unicode support: property names and paths (e.g., 日本語, )
  • Assertions: 65 total (45 assert.*, 20 require.*)

  • Edge-case coverage: ✅ Excellent (error boundaries, type mismatches, empty collections, boundary conditions)

  • Verdict: ✅ Locks down pure-function contracts with regression-guarding precision. Each scenario verifies a specific invariant (type normalization, field sorting, validation rule), not implementation details.

Verdict

Approved. Score 100/100 (Excellent). 0% implementation tests (threshold: 30%). Pure-function test suite with comprehensive edge/error coverage and zero violations.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 33.8 AIC · ⊞ 7.7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). Excellent pure-function test suite with comprehensive edge/error coverage and zero violations.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.86.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants