Skip to content

test(layout): reviewed PEP 723 scripts are allowed under scripts/ and the root scratch ban keeps its patterns #1872

Closed

Description

@dan-petty

Friction

test_no_stray_scripts_in_project_root fails on any root .py or .sh file and also asserts that scripts/ does not exist, so reviewed automation cannot live in a conventional place and lives inside the shipped package instead.

Evidence

  • tests/test_architectural_invariants.py:788-796 asserts (stray_files, (REPO_ROOT / "scripts").exists()) == ([], False).
  • .pre-commit-config.yaml:59 runs python3 -P src/devops_cli/core/code_metrics.py, a package module executed as a script by a hook; commands/ci.py (2,255 lines) is the CI orchestrator inside the wheel.
  • AGENTS.md:83 names <appDataDir>/brain/<conversation-id>/scratch/, a path of one vendor's agent.

Proposed remedy

  • Apply pair A24; change the test to forbid root-level scratch patterns and drop the scripts/ assertion; committed scripts under scripts/ carry PEP 723 metadata and pass the same Ruff and mypy gates.

What it deletes

  • One assertion.

Tests

  • The changed test; a negative control for a root tmp_x.py.

Dependencies

  • docs(agents): a convention yields to an open tool, and instructions with no check or with a contradiction are pruned

Acceptance criteria

  • scripts/ may exist; a root scratch script still fails.

Size: S.

Proposed design

Problem statement

The current test test_no_stray_scripts_in_project_root prevents the use of reviewed PEP 723 scripts in the scripts/ directory and incorrectly bans root-level scratch patterns. This forces automation to be placed inside shipped packages instead of conventional locations, creating friction for developers.

Acceptance criteria

  • Criterion 1: The scripts/ directory is allowed to exist and contain reviewed PEP 723 scripts.
    Verification: A pull request adding a script with PEP 723 metadata to the scripts/ directory passes the test.
  • Criterion 2: Root-level scratch patterns still fail the test as before.
    Verification: A root .py or .sh file named like tmp_x.py fails the test.

Key questions

  • What is the purpose of the current test assertion that forbids the existence of a 'scripts/' directory?: The assertion was added to enforce that no scripts are placed in the project root, but it also inadvertently blocks reviewed automation from living in a conventional place like scripts/. [sources: tests/test_architectural_invariants.py:788]
  • What are the implications of allowing scripts under the 'scripts/' directory?: Allowing scripts under scripts/ enables reviewed automation to live in a conventional location, which aligns with PEP 723 standards and improves developer experience. [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
  • Does the proposed remedy align with existing architectural invariants?: Yes, the proposed remedy applies pair A24 which changes the test to forbid root-level scratch patterns and drop the scripts/ assertion, ensuring that reviewed automation can be placed under scripts/ while maintaining the prohibition on stray scripts in the project root. [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    on Oct 22, 2026
  2. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/test. The candidate modifies a test and its associated assertions.
    • Priority: P2-Medium. The change affects test behavior and project structure, but is not critical to core functionality.
    • Value: Medium. Improves developer experience by allowing reviewed scripts in a conventional location.
    • Effort: Low. Only one assertion is removed and the test is adjusted accordingly.
  3. added this to the v0.2.39 milestone on Oct 22, 2026
  4. added
    status/in-progress
    on Oct 22, 2026
  5. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at ae8c2d9 (see proposed design in issue body).

  6. added a commit that references this issue on Oct 22, 2026
    3a27be9
  7. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1887, merged into release/v0.2.39 as 3a27be9.

    Cause: test_no_stray_scripts_in_project_root made two assertions. The project root holds no .py or .sh file, and the path scripts/ does not exist. The second assertion kept reviewed automation out of the usual place for it. The CI orchestrator and code_metrics.py, which a hook runs as a script, live inside the shipped package for this reason. A scripts/probe.py in the worktree made the old test fail with ([], True) == ([], False). The AGENTS.md rule also named <appDataDir>/brain/<conversation-id>/scratch/, which is a path of one vendor's agent.

    Change: The second assertion is deleted, so scripts/ may exist. The first assertion keeps its predicate: any .py or .sh file in the project root fails, so every scratch pattern of the rule (tmp*.py, scratch*.py, debug_*.py, test_*.py and *.sh) still fails there. The test now calls _stray_root_scripts(root), a helper with 3 lines, so two new tests can run it on a tmp_path root. The AGENTS.md bullet is now "Scratch Work Stays Untracked". It names the test, drops the vendor path, and allows a committed helper script in scripts/ as a PEP 723 file. The bullet claims only that Ruff checks the script. I did not copy the claim 'passes the same lint and type gate' from the plan, because it is false today. mypy --strict src and Bandit (targets src,tests in .bandit) do not read scripts/, and mypy fails with 'Cannot read file scripts' on a path that does not exist. So the bullet says that the pull…

    4 file(s) changed.

    How it was verified

    Check runs at d1a6626:

    • Prune PR DevContainer Images: pending
    • Audit Defect PR Hardening: skipping
    • devops-cli: pass
    • zizmor: pass
    • bandit: pass
    • CodeQL: pass
    • Service Image: skipping
    • Changed-Test Independence: pass
    • Analyze (actions): pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Static Analysis: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Check: pass
    • Analyze (python): pass
    • Dependency Freshness: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-1872-reviewed-scripts-directory.md:

    • A scripts/ directory with a helper in it is no stray script. test_a_reviewed_scripts_directory_is_no_stray_script checks it. The old test failed on such a tree. The real-tree test test_no_stray_scripts_in_project_root passes with a scripts/helper.py in the worktree.
    • A scratch script in the project root still fails. test_a_scratch_script_in_the_project_root_is_stray checks tmp_x.py, scratch_x.py, debug_x.py, test_x.py and x.sh. A tmp_x.py in the real project root made the real-tree test fail with ['tmp_x.py'] == [].
    • The AGENTS.md rule claims only what a check enforces. It stays within the 40,000-character cap, and tests/test_agents_md_claims.py passes.
    • ruff check, ruff format --check, mypy --strict src, deptry src and uv run devops docs check pass.
  8. added a commit that references this issue on Oct 23, 2026
    f209f6c
  9. removed
    status/in-progress
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/test

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions