Skip to content

Enforce injected environment access in generated Rust projects - #79

Merged
leynos merged 11 commits into
mainfrom
enforce-env-injection
Aug 2, 2026
Merged

Enforce injected environment access in generated Rust projects#79
leynos merged 11 commits into
mainfrom
enforce-env-injection

Conversation

@lodyai

@lodyai lodyai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch makes environment injection and assertion diagnostics enforceable
defaults in generated Rust projects. It denies direct process-environment
operations, strengthens Rust and Rustdoc lint policy, and ensures documentation
and doctest warnings fail the public gates.

The generated contributor guidance now requires injected environment readers,
rejects process-wide locking as a testing workaround, and reserves environment
configuration for isolated child processes.

Review walkthrough

Validation

  • make check-fmt: passed
  • make lint: passed
  • make typecheck: passed; 29 source files checked
  • make test: passed; 87 passed and 1 skipped
  • make spelling: passed
  • Focused generated lint-target suite: 7 passed, including both representative
    rejection cases
  • git diff --check origin/main...HEAD: passed

Notes

The template currently renders one package and no additional workspace member
manifests. Its package-local lint tables therefore cover the complete generated
workspace; future member manifests will still need to opt into workspace lints
or declare equivalent package-local levels.

References

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e74790ca-c021-4160-8b97-099847063d08

📥 Commits

Reviewing files that changed from the base of the PR and between 6596ab5 and 1c574fd.

📒 Files selected for processing (4)
  • docs/users-guide.md
  • template/AGENTS.md.jinja
  • template/docs/users-guide.md.jinja
  • tests/test_template/test_policy_guidance.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/whitaker (auto-detected)

Summary

  • Enforce injected environment access through mockable::Env and DefaultEnv.
  • Deny direct std::env operations, unsafe code, undocumented assertions, and Rustdoc violations.
  • Make Rust and Rustdoc warnings fail generated-project validation.
  • Restrict environment mutation to isolated assert_cmd child processes.
  • Replace ambient environment reads with compile-time Cargo metadata.
  • Add lint, Makefile, snapshot, compilation, rejection, and rendered-guidance coverage.
  • Update user and developer documentation with migration guidance.
  • Document the composition-root decision in ADR-005.
  • Maintain the related Rust project enhancements execplan.

Walkthrough

The template now enforces strict Rust and Rustdoc linting, injected environment access, warning-denied Makefile workflows, updated testing guidance, and contract tests for generated projects and documentation examples.

Changes

Template policy enforcement

Layer / File(s) Summary
Update development guidance
template/AGENTS.md.jinja
Generated guidance preserves completed execplans, requires assertion messages, refines error-handling guidance, expands testing guidance, and mandates injected environment access.
Document injected environment boundaries
template/docs/reliable-testing-in-rust-via-dependency-injection.md, docs/adr-005-injected-environment-boundary.md, docs/developers-guide.md, docs/users-guide.md, template/docs/users-guide.md.jinja
Documentation defines DefaultEnv, MockEnv, child-process configuration, prohibited process-wide environment mutation, lint policies, and migration steps.
Configure generated Rust tooling
template/Cargo.toml.jinja, template/clippy.toml, template/Makefile.jinja, template/tests/stub.rs.jinja
Generated projects deny selected Rust, Rustdoc, and Clippy violations, restrict direct std::env access, compose Rustdoc flags, and validate package metadata.
Validate generated contracts
tests/helpers/tooling_contracts/*, tests/test_template/*
Tests validate generated configuration, Makefile flags, snapshots, lint failures, policy text, package metadata, and compilation of documented examples.

Possibly related issues

Possibly related PRs

Suggested reviewers: leynos

Poem

Enforce strict flags in Rustdoc’s gate,
Inject environments into test state.
Compile snapshots and contracts in line,
Keep generated guidance consistent and fine.
Leave ambient process state outside.


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
User-Facing Documentation ⚠️ Warning The user guide clearly documents the new policy, but the breaking change has no n+1 migration document; the repository still only contains docs/migrations/0.2.0.md. Add the next minor migration document (for example, docs/migrations/0.3.0.md) and link it from README.md and docs/users-guide.md.
Unit Architecture ❓ Inconclusive Investigation is still in progress. Gather code and documentation evidence before deciding.
Architectural Complexity And Maintainability ❓ Inconclusive Investigation is still in progress; no verdict submitted yet. Gather repository evidence before deciding.
✅ Passed checks (17 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change by enforcing injected environment access in generated Rust projects.
Description check ✅ Passed The description directly covers the environment, lint, documentation, testing, and validation changes in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Overall) ✅ Passed Generated-project tests parse lint policy, reject assertion, environment, Rust and Rustdoc violations through make lint, compile the injection examples, and verify Makefile, snapshot, stub and gu...
Developer Documentation ✅ Passed The parent developer guide documents the new lint, Rustdoc, Makefile, doctest, and environment contracts; ADR-005 records the environment boundary and consequences.
Module-Level Documentation ✅ Passed Accept the check: every Python module has a leading purpose docstring, and the generated Rust test module has //! documentation explaining its role and deletion boundary.
Testing (Unit And Behavioural) ✅ Passed Rendered-project tests exercise make lint/test, rejection diagnostics, Rustdoc doctests, Whitaker fallback, and compiled documentation examples across flavours.
Testing (Property / Proof) ✅ Passed Retain the check: generated guidance recommends property tests for invariants, and Hypothesis exhaustively exercises the rendered Polonius configuration space; no new proof obligation appears.
Testing (Compile-Time / Ui) ✅ Passed Generated Rust compile-pass and compile-fail tests invoke Cargo gates and assert stable diagnostics; syrupy snapshots cover structured Makefile output with SHA redaction.
Domain Architecture ✅ Passed The PR changes template policy, linting, build gates, documentation, and tests; it adds no domain implementation and explicitly confines environment access to composition roots.
Observability ✅ Passed Pass this check: the PR changes templates, validation commands, documentation, and tests only; it adds no production runtime path, service boundary, logging, metrics, tracing, or alert behaviour.
Security And Privacy ✅ Passed The PR changes templates, documentation, and tests only; no secrets, authentication, permissions, or sensitive output were added. secret123 is a clearly fake MockEnv value.
Performance And Resource Use ✅ Passed The change adds only bounded documentation/configuration and fixed-case tests; no production loops, caches, blocking hot paths, or unbounded collections were introduced.
Concurrency And State ✅ Passed Pass: the diff adds no shared mutable state, locks, async tasks, or global caches; it confines DefaultEnv to composition roots, uses local MockEnv, and tests the environment policy.
Rust Compiler Lint Integrity ✅ Passed The only changed Rust source removes an ambient env read; scans found no new broad allowances, artificial anchors, or clone calls, and the existing #[expect] is narrow and linked to a tracked execp...
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enforce-env-injection

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR tightens lint and documentation enforcement for generated Rust projects, formalizes environment injection/testing policy in contributor guidance, updates Makefile contracts to treat Rustdoc warnings as errors, and adds tests that assert these policies are correctly rendered and enforced in generated projects.

File-Level Changes

Change Details Files
Strengthen generated Cargo manifest lint configuration for Rust, Rustdoc, and Clippy, including disallowed methods and assertion message requirements.
  • Add clippy disallowed_methods and missing_assert_message to the generated manifest lint table.
  • Enforce unknown_lints, renamed_and_removed_lints, unsafe_code, and missing_docs at strict levels in Rust lints.
  • Extend Rustdoc lints to deny malformed or incomplete documentation, including links, URLs, HTML tags, codeblock attributes, and backticks.
template/Cargo.toml.jinja
Define a Clippy disallowed-methods policy to forbid direct ambient environment access and mutation in generated Rust projects.
  • List all std::env read methods (var, var_os, vars, vars_os) as disallowed with guidance to inject an environment reader instead.
  • List std::env::set_var and std::env::remove_var as disallowed, directing tests to use stub environments.
  • Wire these disallowed methods into generated projects via clippy.toml.
template/clippy.toml
Tighten Makefile contracts so tests and docs treat warnings as errors and Rustdoc runs with docsrs configuration.
  • Set RUSTDOC_FLAGS to include --cfg docsrs and -D warnings by default.
  • Ensure doctests run with all features and respect BUILD_JOBS rather than workspace-wide test invocation.
  • Require the lint target to run cargo doc with RUSTDOCFLAGS applied, denying Rustdoc warnings.
template/Makefile.jinja
tests/helpers/tooling_contracts/makefile.py
Update the generated Rust test stub to avoid ambient environment reads and rely on compile-time Cargo metadata instead.
  • Replace std::env::var_os("CARGO_MANIFEST_DIR") usage with env!("CARGO_PKG_NAME") in the stub test.
  • Assert that the package name provided by Cargo is non-empty as the basic stub contract.
template/tests/stub.rs
Expand contributor guidance to codify environment injection requirements, error payload sizing, and testing strategies (snapshot and compile-time tests).
  • Clarify that completed execplans are historical and must not be retroactively updated.
  • Adjust error guidance to prefer small, focused error types with large payloads boxed and Arc reserved for shared ownership or cheap cloning.
  • Refine snapshot testing guidance for insta and add recommendations for trybuild compile-time behaviour tests.
  • Rewrite environment-related testing guidance to mandate injected environments, forbid process-wide locking as an escape hatch, and allow environment configuration only in isolated child processes.
template/AGENTS.md.jinja
Add tests that assert generated lint configuration and make-lint behaviour enforce environment injection and documentation contracts.
  • Introduce a helper to parse generated TOML files and use it to validate manifest and clippy lint tables.
  • Add a test that checks the generated manifest and clippy configuration for required clippy, rust, and rustdoc lint levels and disallowed std::env methods.
  • Add parameterized tests that inject representative Rust functions into the generated project and assert that make lint fails with the expected clippy lint names for missing assert messages and ambient environment reads.
tests/test_template/test_lint_targets.py
Update the generated snapshot fixture to reflect the new Makefile, manifest, and guidance changes in the rendered template.
  • Regenerate the snapshot of the rendered template to capture the new lint configuration, Makefile targets, and documentation/guidance text.
  • Ensure snapshot expectations align with the tightened lint and environment policies across the template.
tests/test_template/__snapshots__/test_snapshots.ambr

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@leynos
leynos marked this pull request as ready for review August 2, 2026 11:25

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 779e9bf1d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread template/Makefile.jinja Outdated
Comment thread template/AGENTS.md.jinja Outdated
Comment thread template/AGENTS.md.jinja Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@template/Makefile.jinja`:
- Line 41: Update the doctest command in the Makefile template to export
RUSTDOCFLAGS from RUSTDOC_FLAGS alongside the existing RUSTFLAGS assignment,
then update the related Makefile contract assertion and snapshot to require the
new command form.
- Line 16: Update the RUSTDOC_FLAGS assignment in the Makefile template to
always include --cfg docsrs and -D warnings while preserving any additional
inherited flags, rather than allowing an inherited value to replace the policy
flags.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d8b6f56-d01e-47cb-a467-196c9e6f6af5

📥 Commits

Reviewing files that changed from the base of the PR and between 09ad466 and 0bd800e.

📒 Files selected for processing (8)
  • template/AGENTS.md.jinja
  • template/Cargo.toml.jinja
  • template/Makefile.jinja
  • template/clippy.toml
  • template/tests/stub.rs
  • tests/helpers/tooling_contracts/makefile.py
  • tests/test_template/__snapshots__/test_snapshots.ambr
  • tests/test_template/test_lint_targets.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/whitaker (auto-detected)

Comment thread template/Makefile.jinja Outdated
Comment thread template/Makefile.jinja Outdated
@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

leynos and others added 7 commits August 2, 2026 15:53
Deny assertion messages without context and direct process-environment
operations in generated projects. Extend Rust and Rustdoc lint coverage and
run doctests and documentation builds with warnings denied.

Document environment injection as the required design, retain subprocess
isolation as the sole testing exemption, and protect the generated contracts
with focused rendering and lint-gate regressions.
Set `RUSTFLAGS` at target scope so the standard test runner and doctest
command inherit one shared value without affecting unrelated targets.
Use the `mockable` 0.3 `DefaultEnv`, `Env::string`, and expectation APIs
consistently across generated instructions and examples. Compile the actual
documented dependency, production, and test snippets to prevent API drift.

Describe subprocess isolation in terms of the generated application binary
instead of a project-specific executable name.
Avoid an unused API-key binding in the production snippet and make the
documentation regression enforce the same warning policy as CI.
Ensure inherited Rustdoc additions cannot replace the generated docsrs and
warning-denial policy. Pass the resulting flags to doctests as well as
documentation builds.
Require the generated Rustdoc flag composition to preserve optional Polonius
support alongside inherited flags. Format the replayed Python tests so the
rebased series passes the parent quality gates.
@lodyai
lodyai Bot force-pushed the enforce-env-injection branch from 04bbec0 to cb301ae Compare August 2, 2026 14:00
@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error Tests cover representative Clippy failures, generated config, Makefile text, and the mockable example, but no test asserts the new AGENTS guidance or exercises unsafe, missing-docs, and Rustdoc enf... Add rendered-content assertions for the new AGENTS rules and generated-project rejection tests for representative unsafe, missing-docs, and Rustdoc violations; keep the existing configuration checks.
User-Facing Documentation ⚠️ Warning The PR changes generated lint, Rustdoc, doctest, and environment behaviour, but neither users' guide documents the new policies; only the separate testing note does. Update docs/users-guide.md and template/docs/users-guide.md.jinja with the enforced policies, workflow effects, and migration steps for existing generated projects.
Developer Documentation ⚠️ Warning The PR changes generated lint/build contracts and enforces environment injection, but it does not update docs/developers-guide.md or add a design record/ADR for the new boundary. Update docs/developers-guide.md with the new lint, Rustdoc, doctest, and environment-injection requirements. Record the architectural decision in a suitable ADR or design document.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

Prove the rendered contributor guidance and every practical Rust and
Rustdoc rejection case through focused generated-project tests.

Document warning-fatal validation, environment injection, migration steps,
and the composition-root decision for maintainers and generated-project
users.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adr-005-injected-environment-boundary.md`:
- Around line 9-19: Rewrite the decision paragraph in the ADR for grammatical
clarity: separate the context, decision, and consequence into clear clauses; use
“decided to inject” and “reject direct” with parallel verb structure; preserve
the existing technical decisions and outcomes; and include the required
“Triage:” annotation for this Markdown grammar finding.

In `@docs/developers-guide.md`:
- Around line 28-37: Update the generated AGENTS.md command guidance in
template/AGENTS.md.jinja so make lint includes the warning-denied documentation
build before Clippy and Whitaker, matching the contract described in the
generated lint documentation. Preserve the existing validation commands and add
a rendered-output assertion if the command list is covered by tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 61d3a255-9016-448e-996b-3d2a6a186ae2

📥 Commits

Reviewing files that changed from the base of the PR and between cb301ae and 7259292.

📒 Files selected for processing (7)
  • docs/adr-005-injected-environment-boundary.md
  • docs/developers-guide.md
  • docs/users-guide.md
  • template/AGENTS.md.jinja
  • template/docs/users-guide.md.jinja
  • tests/test_template/test_lint_targets.py
  • tests/test_template/test_policy_guidance.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/whitaker (auto-detected)

Comment thread docs/adr-005-injected-environment-boundary.md Outdated
Comment thread docs/developers-guide.md
leynos added 2 commits August 2, 2026 20:12
Separate the environment boundary decision into parallel clauses with its
review triage. Document the complete generated lint command sequence and
prove the rendered guidance stays aligned with the Makefile contract.
Assert each new testing and maintenance rule in the rendered `AGENTS.md`.
Render the disposable Rust test stub with the selected package name so its
metadata check proves the generated project contract.
@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/users-guide.md`:
- Around line 91-93: Complete the environment migration guidance in
docs/users-guide.md lines 91-93 by adding actions for declaring the mockable
dependency, wiring the Env adapter at the composition root while retaining
DefaultEnv for production, and documenting contributor guidance; mirror the same
complete guidance in template/docs/users-guide.md.jinja lines 61-63 so generated
guides stay consistent.

In `@template/AGENTS.md.jinja`:
- Around line 171-179: Update the following `make test` guidance in
`template/AGENTS.md.jinja` to match the generated Makefile: document the
`$(CARGO) $(TEST_CMD)` command with its `cargo-nextest` fallback, warning-denial
`RUSTFLAGS`, and separate all-feature workspace doctests using `RUSTDOCFLAGS`,
replacing the stale `cargo test --workspace` command and description.

In `@tests/test_template/test_policy_guidance.py`:
- Around line 47-51: Parenthesize the adjacent multi-line string literals in the
test command list to satisfy ISC004, preserving the exact asserted Makefile
command text and the surrounding test structure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 801cf0d8-4b6a-4c36-8b4c-d0c47d85929f

📥 Commits

Reviewing files that changed from the base of the PR and between cb301ae and 6596ab5.

📒 Files selected for processing (8)
  • docs/adr-005-injected-environment-boundary.md
  • docs/developers-guide.md
  • docs/users-guide.md
  • template/AGENTS.md.jinja
  • template/docs/users-guide.md.jinja
  • template/tests/stub.rs.jinja
  • tests/test_template/test_lint_targets.py
  • tests/test_template/test_policy_guidance.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/whitaker (auto-detected)

Comment thread docs/users-guide.md Outdated
Comment thread template/AGENTS.md.jinja
Comment thread tests/test_template/test_policy_guidance.py Outdated
@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed check (1 error)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error Tests cover lint rejection and environment examples, but no test guards new execplan, Box/Arc, insta, or trybuild guidance; the stub only asserts a non-empty value and would pass with a constant. Add rendered-guidance assertions for every new AGENTS rule and assert the generated stub uses the expected package metadata, not merely any non-empty constant.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="leynos/agent-template-rust"
pr="79"

echo "=== PR checks ==="
gh pr view "$pr" --repo "$repo" --json url,headRefOid,statusCheckRollup \
  --jq '{url, headRefOid, checks: [.statusCheckRollup[] | {name, status, conclusion, detailsUrl}]}'

echo
echo "=== PR files relevant to the finding ==="
gh pr view "$pr" --repo "$repo" --json files \
  --jq '.files[].path' | rg '(^template/AGENTS\.md\.jinja$|^template/tests/stub\.rs\.jinja$|test_policy_guidance\.py$|test_compilation\.py$|test_lint_targets\.py$)' || true

echo
echo "=== Test and template outlines ==="
for path in \
  tests/test_template/test_policy_guidance.py \
  tests/test_template/test_compilation.py \
  template/AGENTS.md.jinja \
  template/tests/stub.rs.jinja
do
  if [ -f "$path" ]; then
    echo "--- $path ---"
    ast-grep outline "$path" --items all 2>/dev/null || true
  fi
done

echo
echo "=== Rendered-guidance and package-metadata assertions ==="
rg -n -i -C 4 \
  'AGENTS\.md|execplan|historical record|Box|Arc|insta|trybuild|CARGO_PKG_NAME|package_name|non.empty|nonempty' \
  tests/test_template/test_policy_guidance.py \
  tests/test_template/test_compilation.py \
  tests/test_template/test_lint_targets.py \
  template/AGENTS.md.jinja \
  template/tests/stub.rs.jinja 2>/dev/null || true

echo
echo "=== Relevant PR diff ==="
git diff --unified=12 "$(git merge-base origin/main HEAD)" HEAD -- \
  tests/test_template/test_policy_guidance.py \
  tests/test_template/test_compilation.py \
  template/AGENTS.md.jinja \
  template/tests/stub.rs.jinja

Length of output: 23856


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="leynos/agent-template-rust"
pr="79"

echo "=== Complete rendered-guidance test ==="
sed -n '1,140p' tests/test_template/test_policy_guidance.py

echo
echo "=== AGENTS patch from the GitHub PR API ==="
gh api --paginate "repos/${repo}/pulls/${pr}/files?per_page=100" \
  --jq '.[] | select(.filename == "template/AGENTS.md.jinja") | .patch'

echo
echo "=== Focused-test patch from the GitHub PR API ==="
gh api --paginate "repos/${repo}/pulls/${pr}/files?per_page=100" \
  --jq '.[] | select(.filename == "tests/test_template/test_policy_guidance.py") | .patch'

echo
echo "=== Stub patch from the GitHub PR API ==="
gh api --paginate "repos/${repo}/pulls/${pr}/files?per_page=100" \
  --jq '.[] | select(.filename == "template/tests/stub.rs.jinja") | .patch'

Length of output: 19293


@leynos The failed Testing (Overall) check is resolved.

The current PR head is 6596ab5daca8c49d37cc408500065bdbddfbf00d. Both required checks pass:

  • build-test: success
  • act-validation: success

tests/test_template/test_policy_guidance.py now renders AGENTS.md and asserts every new guidance area from this PR:

  • completed execplans remain historical records;
  • make lint documentation, Clippy, and Whitaker failure behaviour;
  • required custom assertion diagnostics;
  • injected environment access and subprocess-only environment configuration;
  • Box versus Arc error-payload guidance;
  • focused insta snapshot guidance; and
  • trybuild compile-pass and compile-fail guidance.

The same file also renders a project with package_name="metadata_stub_example". It requires the generated tests/stub.rs to contain:

assert_eq!(
    env!("CARGO_PKG_NAME"),
    "metadata_stub_example",

This prevents the stub from passing with an unrelated non-empty constant.

Do not create a follow-up issue. No further work is required for this finding.

You are interacting with an AI system.

Document the complete environment-injection migration and the generated
test runner contract. Guard the rendered commands and migration steps while
making adjacent command literals explicit for ISC004.
@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

Testing (Compile-Time / Ui) ⚠️ Warning Rust compile-time contracts are present, but no trybuild or equivalent UI fixture exists; tests only invoke cargo/make from Python and assert exit codes or diagnostic substrings. Add focused Rust trybuild compile-pass/compile-fail fixtures with reviewed diagnostics, or document and implement an equivalent Rust UI harness for the generated lint contracts.

@coderabbitai

This comment was marked as resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants