Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions .github/workflows/amber-issue-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ permissions:
contents: read
issues: write
pull-requests: write
checks: write

jobs:
# -- Issue: labeled ambient-code:auto-fix → fresh session prompt --
Expand Down Expand Up @@ -274,10 +275,45 @@ jobs:
wait: 'true'
timeout: '0'

- name: Post check run on PR
if: >-
always()
&& steps.context.outputs.is_fork != 'true'
&& steps.context.outputs.type == 'pr'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SESSION_NAME="${{ steps.fix-session.outputs.session-name || steps.fix-issue-session.outputs.session-name || steps.custom-session.outputs.session-name }}"
SESSION_URL="${{ steps.fix-session.outputs.session-url || steps.fix-issue-session.outputs.session-url || steps.custom-session.outputs.session-url }}"
SESSION_PHASE="${{ steps.fix-session.outputs.session-phase || steps.fix-issue-session.outputs.session-phase || steps.custom-session.outputs.session-phase }}"

if [ -z "$SESSION_NAME" ]; then
exit 0
fi

# Get PR head SHA
HEAD_SHA=$(gh pr view ${{ steps.context.outputs.number }} --repo "${{ github.repository }}" --json headRefOid --jq '.headRefOid')

# Map session phase to check conclusion
case "$SESSION_PHASE" in
Completed|Running) CONCLUSION="success" ;;
Error|Failed) CONCLUSION="failure" ;;
*) CONCLUSION="neutral" ;;
esac

gh api "repos/${{ github.repository }}/check-runs" \
-X POST \
-f "name=Amber Session" \
-f "head_sha=$HEAD_SHA" \
-f "status=completed" \
-f "conclusion=$CONCLUSION" \
-f "details_url=$SESSION_URL" \
-f "output[title]=Amber — ${{ steps.context.outputs.prompt_type }} prompt" \
-f "output[summary]=Session \`$SESSION_NAME\` (phase: $SESSION_PHASE)" || true
Comment on lines +304 to +312
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't hide check-run creation failures.

Line 312 turns any gh api rejection into a green step, so a bad payload/URL/permission regression will surface only as “the check never appeared.” If this must stay non-blocking, emit a warning with the API error instead of || true.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/amber-issue-handler.yml around lines 304 - 312, The gh api
call that creates the check-run (gh api "repos/${{ github.repository
}}/check-runs" -f ... output[summary]=...) currently swallows all errors via "||
true"; remove that blanket suppression and replace it with explicit error
handling so failures are not hidden — capture the gh api exit status and stderr,
and if it fails emit a visible warning that includes the API error/response (and
contextual fields like $HEAD_SHA, $SESSION_NAME, $SESSION_PHASE, $SESSION_URL)
while still allowing the step to continue if you truly want non-blocking
behavior.


- name: Session summary
if: always() && steps.context.outputs.is_fork != 'true'
run: |
# Get session name from whichever step ran (only one will have output)
SESSION_NAME="${{ steps.fix-session.outputs.session-name || steps.fix-issue-session.outputs.session-name || steps.custom-session.outputs.session-name }}"
SESSION_PHASE="${{ steps.fix-session.outputs.session-phase || steps.fix-issue-session.outputs.session-phase || steps.custom-session.outputs.session-phase }}"

Expand Down Expand Up @@ -369,6 +405,24 @@ jobs:
print(f" Failed to start session: {e}")
return False

def post_check_run(pr_number, session_name, status="in_progress"):
"""Post a check run on the PR linking to the Amber session."""
head_sha = gh("pr", "view", str(pr_number), "--repo", REPO, "--json", "headRefOid", "--jq", ".headRefOid")
if not head_sha:
return
api_url_base = API_URL.rstrip("/").replace("/api", "")
session_url = f"{api_url_base}/projects/{PROJECT}/sessions/{session_name}"
conclusion = "success" if status == "completed" else "neutral"
gh("api", f"repos/{REPO}/check-runs",
"-X", "POST",
"-f", "name=Amber Session",
"-f", f"head_sha={head_sha}",
"-f", "status=completed",
"-f", f"conclusion={conclusion}",
"-f", f"details_url={session_url}",
"-f", "output[title]=Amber — batch fix",
"-f", f"output[summary]=Session `{session_name}` triggered for PR #{pr_number}")

Comment on lines +408 to +425
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "amber-issue-handler.yml" | head -20

Repository: ambient-code/platform

Length of output: 108


🏁 Script executed:

wc -l ./.github/workflows/amber-issue-handler.yml

Repository: ambient-code/platform

Length of output: 112


🏁 Script executed:

sed -n '400,440p' ./.github/workflows/amber-issue-handler.yml

Repository: ambient-code/platform

Length of output: 2246


🏁 Script executed:

sed -n '440,480p' ./.github/workflows/amber-issue-handler.yml

Repository: ambient-code/platform

Length of output: 2365


🏁 Script executed:

sed -n '480,530p' ./.github/workflows/amber-issue-handler.yml

Repository: ambient-code/platform

Length of output: 2471


🏁 Script executed:

sed -n '530,558p' ./.github/workflows/amber-issue-handler.yml

Repository: ambient-code/platform

Length of output: 1552


Check runs posted to wrong commit; status hardcoded and parameter ignored.

create_session_api() returns immediately after queueing the session—it does not wait for Amber to process or push fixes. post_check_run() is then called on line 535 with the current headRefOid (line 410), posting a check run to the pre-fix commit. When Amber later pushes fixes, the check run remains pinned to the old SHA.

Additionally, line 420 hardcodes status=completed regardless of the status parameter (which defaults to in_progress), breaking the intended status reporting. The check run should be reposted after the session completes, with status/conclusion derived from the actual Amber session phase.

Applies to lines 408–425 and the call site at 533–535.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/amber-issue-handler.yml around lines 408 - 425,
post_check_run currently posts a check-run to the PR using the head_sha captured
once and hardcodes status=completed; update it to use the passed status
parameter (e.g., replace the "-f", "status=completed" arg with "-f",
f"status={status}") and only include the conclusion field when status ==
"completed" (compute conclusion as you already do, but don't force status to
completed). Also ensure the check-run for the final result is posted after Amber
finishes: in create_session_api, continue to queue the session but do not rely
on the earlier-captured head_sha for the final check-run—when the session
completes, call post_check_run again (or re-call gh api within post_check_run)
and re-fetch head_sha with gh("pr","view",...,"headRefOid") so the completion
check-run is attached to the updated commit SHA and uses the proper
status/conclusion derived from the Amber session phase.

def create_session_api(prompt, session_name="", model="claude-opus-4-6"):
"""Create a new session or send message to existing one."""

Expand Down Expand Up @@ -476,7 +530,9 @@ jobs:
5. Do not merge. Do not close. Do not force-push.
6. If fundamentally broken beyond repair, add a comment explaining and stop."""

create_session_api(prompt, session_name=session_id)
result_name = create_session_api(prompt, session_name=session_id)
if result_name:
post_check_run(number, result_name)

# Increment retry_count in frontmatter so circuit breaker advances
if fm:
Expand Down
Loading