Skip to content

feat: harden smart-test-pipeline execution and validation - #1973

Open
haseeb-heaven wants to merge 30 commits into
kunchenguid:mainfrom
haseeb-heaven:smart-test-pipeline
Open

feat: harden smart-test-pipeline execution and validation#1973
haseeb-heaven wants to merge 30 commits into
kunchenguid:mainfrom
haseeb-heaven:smart-test-pipeline

Conversation

@haseeb-heaven

@haseeb-heaven haseeb-heaven commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Harden smart-test-pipeline into a production-ready, guarded PR review and fix loop. The pipeline now treats pull-request code, review text, CI output, and model-agent actions as separate trust boundaries and stops safely when a required control cannot be verified.

Security and isolation

  • Added explicit CLI adapters for Pi, Claude Code, Codex CLI, and OpenCode.
  • Allowlisted only model-provider environment variables for fix agents; GitHub credentials, SSH keys, and unrelated host secrets are excluded.
  • Added disposable agent and validation sandboxes with network isolation for tests/lint and provider-scoped network requirements for agents.
  • Prevented agent writes to .git control data, refs, hooks, credentials, and the Git common directory.
  • Built validation snapshots from non-secret files and revalidated the real worktree after sandboxed execution.
  • Treat review comments and CI output as delimited untrusted data.

Correctness and reliability

  • Fixed sourced-library resolution using BASH_SOURCE[0].
  • Added complete scope accounting for committed, staged, unstaged, untracked, and agent-created changes.
  • Prevented out-of-scope files from being staged or committed.
  • Fed test, lint, and CI failures back into subsequent fix iterations, including CI-only failures.
  • Added explicit propagation for failed review waits, tests, lint, commits, pushes, and CI checks with terminal reports.
  • Added operator-config → built-in-default → CLI precedence.
  • Added unique run directories, per-PR locking, ancestry checks, and protection for unpushed commits.
  • Refused mutation of closed or merged pull requests.

Regression coverage

The focused suite covers malicious fork content, prompt-injected review comments, Git hook attacks, staged/untracked changes, agent-created commits, CI-only failures, failed commit/push/review waits, concurrent runs, config precedence, adapter invocation, dry-run behavior, and credential-free sandbox execution.

Validation

The no-mistakes review, focused tests, and documentation checks passed. Local ShellCheck parity was unavailable because ShellCheck 0.11.0 is not installed; this remains an environment warning for repository CI. No merge automation is included.

@haseeb-heaven haseeb-heaven changed the title feat(smart-test-pipeline): add hardened review pipeline skill feat: add hardened smart-test-pipeline skill Aug 8, 2026
@haseeb-heaven haseeb-heaven changed the title feat: add hardened smart-test-pipeline skill feat: added smart-test-pipeline skill Aug 8, 2026

@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: 4b61bc503a

ℹ️ 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 skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/lib/loop.sh
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread docs/documentation-audiences.json Outdated
@haseeb-heaven haseeb-heaven changed the title feat: added smart-test-pipeline skill feat: harden smart-test-pipeline execution and validation Aug 8, 2026

@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: 4f760bad53

ℹ️ 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 skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh
Comment thread skills/smart-test-pipeline/lib/sandbox.sh
Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/tests/test_pipeline.sh
Comment thread skills/smart-test-pipeline/lib/sandbox.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/lib/loop.sh

@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: 938b4978e7

ℹ️ 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 skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/lib/sandbox.sh
Comment thread skills/smart-test-pipeline/lib/validate.sh
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/lib/report.sh Outdated
Comment thread skills/smart-test-pipeline/lib/report.sh
Comment thread skills/smart-test-pipeline/lib/validate.sh
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/lib/reviews.sh Outdated

@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: 52f2014abd

ℹ️ 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 skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/lib/loop.sh
Comment thread skills/smart-test-pipeline/lib/loop.sh
Comment thread skills/smart-test-pipeline/README.md Outdated
Comment thread skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated

@haseeb-heaven haseeb-heaven left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Additional Codex review feedback: one distinct host-side Git hook issue verified against the current head. Existing review threads were checked and this is not covered by them.

Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated

@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: 88de634f41

ℹ️ 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 skills/smart-test-pipeline/lib/agent.sh Outdated
Comment thread skills/smart-test-pipeline/lib/loop.sh Outdated
Comment thread skills/smart-test-pipeline/lib/gh.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh
Comment thread skills/smart-test-pipeline/lib/sandbox.sh Outdated
Comment thread skills/smart-test-pipeline/lib/validate.sh
Comment thread skills/smart-test-pipeline/lib/agent.sh

@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: 5c56e9e894

ℹ️ 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 skills/smart-test-pipeline/lib/loop.sh
Comment thread skills/smart-test-pipeline/lib/loop.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh Outdated
Comment thread skills/smart-test-pipeline/run.sh
Comment thread skills/smart-test-pipeline/lib/validate.sh
Comment thread skills/smart-test-pipeline/run.sh
Comment thread skills/smart-test-pipeline/run.sh

@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: 6e4babc2c5

ℹ️ 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 on lines +17 to +20
agent_provider_env() {
# Provider secrets must never enter an agent-controlled subprocess.
printf '%s' ""
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass configured credentials to fix agents

Captain, when the selected CLI authenticates through the documented *_PROVIDER_ENV API-key settings, this function always returns an empty allowlist, while the agent is also launched with env -i and a fresh empty home directory. None of the settings in config.example.sh can therefore reach the model process, so the agent fails authentication after review bots have already been triggered; honor the selected provider allowlist while continuing to exclude GitHub and unrelated credentials.

Useful? React with 👍 / 👎.

Comment on lines +125 to +128
docker run --rm --user "$(id -u):$(id -g)" "$network_arg" "${docker_env[@]}" \
--read-only --tmpfs /tmp --mount "type=bind,src=$worktree,dst=$worktree" "${git_mount[@]}" \
--mount "type=bind,src=$home_dir,dst=$home_dir" --mount "type=bind,src=$temp_dir,dst=$temp_dir" \
-w "$worktree" "$image" bash -c 'exec "$@"' bash "${command[@]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set the mounted home and temp paths in Docker

When validation uses the advertised Docker backend, these mounts are never assigned to HOME or TMPDIR; the container commonly retains HOME=/root despite running as the host's non-root UID, and the root filesystem is read-only. Test and lint tools that create caches or configuration under home then fail even though writable per-stage directories were mounted, so pass HOME=$home_dir and TMPDIR=$temp_dir into the container.

Useful? React with 👍 / 👎.


# The final review is collected after the last fix pass. A clean response
# here is a valid success, not an iteration-limit failure.
local final_dir="$DATA_DIR/iterations/$MAX_ITERATIONS" final_findings final_findings_file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the post-limit review in a separate directory

When the final allowed fix pass succeeds, iterations/$MAX_ITERATIONS already contains that pass's findings and appended validation results. Reusing it here makes collect_findings overwrite findings.json, and the clean branch subsequently rewrites report.md, so the final report attributes the post-fix findings to the fix iteration and drops that iteration's test, lint, and CI results; store the terminal review separately or preserve the existing artifacts.

AGENTS.md reference: AGENTS.md:L37-L38

Useful? React with 👍 / 👎.

Comment on lines +153 to +154
elif jq -e '[.[] | select(.source == "github-ci" and (.path == "unknown" or .path == null))] | length > 0' "$findings_file" >/dev/null; then
allowed=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict unknown CI findings from authorizing every file

When a pushed iteration has failing CI but no unresolved review threads, ci_findings creates a github-ci finding whose path is unknown; this branch then marks every non-forbidden changed path as allowed, regardless of its relationship to the failure. The networked fixer can consequently modify and have the orchestrator commit unrelated production code or even .github/workflows/*, defeating the advertised scope boundary; require explicit affected paths or approved support patterns, and stop for manual triage when CI cannot identify one.

Useful? React with 👍 / 👎.

Comment on lines +43 to +47
(allow file-read* (subpath "/usr") (subpath "/bin") (subpath "/sbin") (subpath "/System") (subpath "/Library"))
(allow file-read* (subpath "$worktree"))
(allow file-read* (subpath "$agent_home"))
(allow file-read* (subpath "$temp_dir"))
(allow file-read* (subpath "$executable"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow the selected CLI's read-only runtime files

On the only provider-network-capable auto backend, a supported agent installed through Homebrew, npm, or another launcher commonly has an executable symlink under /opt/homebrew or /usr/local that loads an interpreter and package files elsewhere in that installation tree. This profile permits reading only the command path and system directories, so the CLI is denied its runtime files and exits before processing the brief even though preflight found it; resolve the launcher and expose only its required runtime/install tree read-only.

Useful? React with 👍 / 👎.

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.

1 participant