-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: execute task bundles through shared adapter #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1124ab
c3b855a
910d125
391859e
5912410
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ gateway="${OPENSHELL_GATEWAY:-openshell}" | |
| allow_draft_reviews="${ALLOW_DRAFT_REVIEWS:-false}" | ||
| review_agent="${REVIEW_AGENT:-opencode}" | ||
| review_label="${REVIEW_LABEL:-stackrox-ai-review}" | ||
| codex_inference_provider="${CODEX_INFERENCE_PROVIDER:-openai-review}" | ||
| codex_inference_provider="${CODEX_INFERENCE_PROVIDER:-openai-inference}" | ||
| codex_model="${CODEX_MODEL:-gpt-5.6-luna}" | ||
| codex_workspace="${CODEX_WORKSPACE:-}" | ||
| case "$review_agent" in | ||
|
|
@@ -37,6 +37,8 @@ configured_target=false | |
| if [[ "$review_agent" == codex ]]; then | ||
| workspace="$codex_workspace" | ||
| sandbox_name="codex-$(openssl rand -hex 6)" | ||
| configured_target=true | ||
| github_provider=github-review | ||
| else | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| workspace="${OPENSHELL_WORKSPACE:-rev-$RANDOM-$$}" | ||
| sandbox_name="review-$(openssl rand -hex 6)" | ||
|
|
@@ -199,9 +201,8 @@ run_review() { | |
|
|
||
| ( | ||
| ulimit -f 2048 # Bound raw diagnostic output as well as runtime. | ||
| exec timeout -s TERM -k 35s 8m ./harness workflow apply "$workflow_file" \ | ||
| --gateway "$gateway" --workspace "$workspace" --output-dir "$REVIEW_DIR" \ | ||
| --result-file "$REVIEW_DIR/execution.json" | ||
| OPENSHELL_GATEWAY="$gateway" OPENSHELL_WORKSPACE="$workspace" \ | ||
| exec scripts/run-task.sh "$workflow_file" "$REVIEW_DIR" "$REVIEW_DIR/execution.json" | ||
| ) > "$REVIEW_DIR/agent.ndjson" 2> "$REVIEW_DIR/agent.stderr" & | ||
| apply_pid=$! | ||
| set +e | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| # Execute one trusted task bundle through the harness workflow runner. | ||||||
| set -euo pipefail | ||||||
| umask 077 | ||||||
| cd "$(dirname "$0")/.." | ||||||
|
|
||||||
| workflow_file="${1:?usage: run-task.sh WORKFLOW OUTPUT_DIR RESULT_FILE}" | ||||||
| output_dir="${2:?usage: run-task.sh WORKFLOW OUTPUT_DIR RESULT_FILE}" | ||||||
| result_file="${3:?usage: run-task.sh WORKFLOW OUTPUT_DIR RESULT_FILE}" | ||||||
|
|
||||||
| [[ "$output_dir" == /* && "$result_file" == /* ]] || { | ||||||
| echo "task output and result paths must be absolute" >&2 | ||||||
| exit 1 | ||||||
| } | ||||||
| [[ "$workflow_file" != /* && "$workflow_file" != *..* ]] || { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation for |
||||||
| echo "task workflow must be a trusted repository-relative path" >&2 | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| gateway="${OPENSHELL_GATEWAY:-openshell}" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Do not force a gateway when no environment target exists. When Proposed fix-gateway="${OPENSHELL_GATEWAY:-openshell}"
+gateway="${OPENSHELL_GATEWAY:-}"As per path instructions, preserve “flag > env > config target precedence.” 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||
| workspace="${OPENSHELL_WORKSPACE:-}" | ||||||
| task_timeout="${TASK_TIMEOUT:-8m}" | ||||||
| kill_after="${TASK_KILL_AFTER:-35s}" | ||||||
| [[ "$task_timeout" =~ ^[0-9]+[smh]$ && "$kill_after" =~ ^[0-9]+[smh]$ ]] || { | ||||||
| echo "TASK_TIMEOUT and TASK_KILL_AFTER must be durations such as 8m or 35s" >&2 | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| check_required_providers() { | ||||||
| local required="${TASK_PROVIDERS:-[]}" | ||||||
| mkdir -p "$output_dir" | ||||||
| if ! jq -e 'type == "array" and all(.[]; type == "string" and test("^[A-Za-z0-9][A-Za-z0-9_.-]{0,62}$"))' <<< "$required" >/dev/null; then | ||||||
| echo "TASK_PROVIDERS must be a JSON array of provider names" >&2 | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| local report="$output_dir/provider-check.json" | ||||||
| local provider | ||||||
| local provider_args=(--gateway "$gateway") | ||||||
| [[ -n "$workspace" ]] && provider_args+=(--workspace "$workspace") | ||||||
| if jq -e 'length == 0' <<< "$required" >/dev/null; then | ||||||
| jq -n --arg gateway "$gateway" --arg workspace "$workspace" \ | ||||||
| '{status:"skipped", gateway:$gateway, workspace:$workspace, providers:[]}' > "$report" | ||||||
| return | ||||||
| fi | ||||||
| while IFS= read -r provider; do | ||||||
| if ! timeout 60s openshell provider get "${provider_args[@]}" "$provider" >/dev/null 2>&1; then | ||||||
| jq -n --arg gateway "$gateway" --arg workspace "$workspace" --arg provider "$provider" \ | ||||||
| '{status:"failed", gateway:$gateway, workspace:$workspace, missing:[$provider]}' > "$report" | ||||||
| echo "required OpenShell provider is unavailable: $provider (gateway=$gateway workspace=${workspace:-default})" >&2 | ||||||
| exit 1 | ||||||
| fi | ||||||
| done < <(jq -r '.[]' <<< "$required") | ||||||
|
|
||||||
| jq -n --arg gateway "$gateway" --arg workspace "$workspace" --argjson providers "$required" \ | ||||||
| '{status:"available", gateway:$gateway, workspace:$workspace, providers:$providers}' > "$report" | ||||||
| } | ||||||
|
|
||||||
| check_required_providers | ||||||
|
|
||||||
| args=(workflow apply "$workflow_file" --output-dir "$output_dir" --result-file "$result_file") | ||||||
| [[ -n "$gateway" ]] && args+=(--gateway "$gateway") | ||||||
| [[ -n "$workspace" ]] && args+=(--workspace "$workspace") | ||||||
|
|
||||||
| exec timeout -s TERM -k "$kill_after" "$task_timeout" ./harness "${args[@]}" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 13663
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 27475
Use the effective provider in OpenCode preflight.
required-providersis a generic provider list, and the workflow forwards it toscripts/run-task.shfor OpenCode as well as Codex. On the non-configured OpenCode path,scripts/pr-review.shcreatesgithub-review-$RANDOM-$$. Therefore,required-providers: '["github-review"]'makes preflight check the fixed name, fail, and stop beforeworkflow apply. Normalize the list at the handoff to preflight sogithub-reviewresolves to the actualREVIEW_GITHUB_PROVIDER; retain checks for other declared providers.🤖 Prompt for AI Agents