Skip to content

[V2] Add build validation gate to catch pyproject.toml/package.json configuration errors early #298

Description

@frankbria

Problem

When an agent creates project scaffolding (pyproject.toml, package.json), configuration errors aren't detected until later gates (pytest, npm-test) fail. By then:

  1. The agent has written more code based on the broken foundation
  2. The error message is misleading ("pytest failed" when really build failed)
  3. The agent doesn't understand it's a config issue, not a code issue

Example from v2 CLI Testing

Agent created pyproject.toml with:

# Wrong TOML section name:
[tool.hatchling.build.targets.wheel]
packages = ["src/task_tracker"]

Should have been:

# Correct:
[tool.hatch.build.targets.wheel]
packages = ["src/task_tracker"]

This caused all subsequent tasks to fail with "hatchling.build.build_editable failed" but the agent couldn't diagnose the root cause.

Proposed Solutions

Option 1: Add a "build" gate

Add a new gate that explicitly validates the project can be built:

def _run_build(repo_path: Path, verbose: bool = False) -> GateCheck:
    """Verify project can be built/installed."""
    # For Python: uv sync --no-install-project or pip install -e . --dry-run
    # For Node: npm install --ignore-scripts

Run this gate immediately after pyproject.toml or package.json is created/modified.

Option 2: Better error parsing in existing gates

When uv run pytest fails due to build error, parse the output to detect:

  • "Failed to build" → Report as BUILD_FAILED, not TEST_FAILED
  • Provide actionable error message pointing to pyproject.toml

Option 3: Tech stack templates

When initializing with --detect or --tech-stack, provide the agent with proven pyproject.toml/package.json templates for that stack, reducing reliance on agent memory.

Acceptance Criteria

  • Build configuration errors are caught before code-writing continues
  • Error messages clearly indicate it's a configuration issue, not test failure
  • Agent receives actionable guidance on how to fix the configuration

Related

Labels

enhancement, quality-gates, agent-system

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions