Skip to content

fix(keepalive): add preflight secrets check before Codex call#107

Merged
stranske merged 3 commits intomainfrom
codex/issue-79
Dec 24, 2025
Merged

fix(keepalive): add preflight secrets check before Codex call#107
stranske merged 3 commits intomainfrom
codex/issue-79

Conversation

@stranske
Copy link
Copy Markdown
Owner

@stranske stranske commented Dec 24, 2025

Summary

Adds a preflight job to diagnose why the run-codex job is silently not appearing.

Problem

When the keepalive loop determines action=run, the Keepalive next task job should execute. Instead:

  • The job doesnt appear at all (not even as skipped)
  • needs.run-codex.result evaluates to failure
  • Explicitly passing secrets didnt help

Solution

Added a preflight job that:

  1. Runs in the agent-standard environment (where repository secrets should be accessible)
  2. Checks if CODEX_AUTH_JSON or WORKFLOWS_APP_ID is present
  3. Outputs secrets_ok flag
  4. run-codex job now depends on preflight succeeding

This will show in the logs whether secrets are accessible, helping diagnose if the issue is:

  • Secrets not available in workflow_run context
  • Something else with the reusable workflow call

Related

Automated Status Summary

Scope

  • Scope section missing from source issue.

Tasks

  • Restrict triggers:
  • do not run agent workflows on forked PRs
  • avoid pull_request_target unless absolutely necessary
  • Ensure prompts are repo-owned:
  • use prompt-file from .github/codex/prompts/
  • build a small “context appendix” file that includes sanitized task text
  • Add allowlists:
  • allow-users / allow-bots in codex-action config
  • only repo collaborators can trigger
  • Add denylist behaviors:
  • Codex should not edit .github/workflows/** unless a special environment-approved mode is enabled
  • Codex should not touch secrets or tokens (explicit instruction + sandbox limits)
  • Add logging + red flags:
  • if prompt contains “ignore previous”, HTML comments, base64 blobs, etc, stop and require human

Acceptance criteria

  • - Malicious-looking issue text does not get passed verbatim into Codex execution.
  • - Agent workflows only run for trusted actors and trusted events.

Head SHA: 58da3fb
Latest Runs: ✅ success — Gate
Required: gate: ✅ success

Workflow / Job Result Logs
Agents PR meta manager ❔ in progress View run
CI Autofix Loop ✅ success View run
Gate ✅ success View run
Health 40 Sweep ✅ success View run
Health 44 Gate Branch Protection ✅ success View run
Health 45 Agents Guard ✅ success View run
Health 50 Security Scan ✅ success View run
Maint 52 Validate Workflows ✅ success View run
PR 11 - Minimal invariant CI ✅ success View run
Selftest CI ✅ success View run

…e workflow

The silent skip of the run-codex job was caused by secrets: inherit not
properly passing secrets to the reusable workflow call. This changes to
explicitly passing the required secrets, which matches how
agents-autofix-loop.yml already does it.
The run-codex job was silently failing when calling the reusable workflow.
This adds a preflight job that:
1. Runs in the agent-standard environment (where secrets are accessible)
2. Verifies CODEX_AUTH_JSON or WORKFLOWS_APP_ID is present
3. Outputs a secrets_ok flag
4. Blocks run-codex if secrets aren't available

This will help diagnose whether the issue is secret availability vs
something else in the reusable workflow.
Copilot AI review requested due to automatic review settings December 24, 2025 12:46
@stranske stranske temporarily deployed to agent-high-privilege December 24, 2025 12:46 — with GitHub Actions Inactive
Copy link
Copy Markdown

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

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.

ℹ️ 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 +142 to +146
if [ "$HAS_CODEX_AUTH" = "true" ] || [ "$HAS_APP_ID" = "true" ]; then
echo "secrets_ok=true" >> $GITHUB_OUTPUT
else
echo "::error::Neither CODEX_AUTH_JSON nor WORKFLOWS_APP_ID is set. Cannot run Codex."
echo "secrets_ok=false" >> $GITHUB_OUTPUT
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 Secrets preflight passes without required Codex auth

The new preflight job returns secrets_ok=true when either CODEX_AUTH_JSON or WORKFLOWS_APP_ID is set. However, reusable-codex-run.yml always requires CODEX_AUTH_JSON (the Setup Codex auth step exits if it is empty), so runs where only the GitHub App credentials are available will still proceed to run-codex and then fail later. The preflight gate is supposed to block missing secrets, but with the current OR condition it provides a false green signal and doesn’t prevent the failing Codex invocation.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 24, 2025

Automated Status Summary

Head SHA: fc8f708
Latest Runs: ⏳ pending — Gate
Required contexts: Gate / gate, Health 45 Agents Guard / Enforce agents workflow protections
Required: core tests (3.11): ⏳ pending, core tests (3.12): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 77.97%
Baseline 0.00%
Delta +77.97%
Minimum 70.00%
Status ✅ Pass

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

  • Scope section missing from source issue.

Tasks

  • Restrict triggers:
  • do not run agent workflows on forked PRs
  • avoid pull_request_target unless absolutely necessary
  • Ensure prompts are repo-owned:
  • use prompt-file from .github/codex/prompts/
  • build a small “context appendix” file that includes sanitized task text
  • Add allowlists:
  • allow-users / allow-bots in codex-action config
  • only repo collaborators can trigger
  • Add denylist behaviors:
  • Codex should not edit .github/workflows/** unless a special environment-approved mode is enabled
  • Codex should not touch secrets or tokens (explicit instruction + sandbox limits)
  • Add logging + red flags:
  • if prompt contains “ignore previous”, HTML comments, base64 blobs, etc, stop and require human

Acceptance criteria

  • - Malicious-looking issue text does not get passed verbatim into Codex execution.
  • - Agent workflows only run for trusted actors and trusted events.

@stranske stranske temporarily deployed to agent-high-privilege December 24, 2025 12:48 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a preflight secrets verification job to diagnose why the run-codex job fails to appear in the keepalive workflow. The preflight job checks for the presence of required secrets (CODEX_AUTH_JSON or WORKFLOWS_APP_ID) and outputs a secrets_ok flag before the run-codex job executes.

Key Changes

  • Added a new preflight job that verifies secrets availability in the agent-standard environment
  • Modified run-codex job to depend on preflight and check its secrets_ok output
  • Changed from secrets: inherit to explicit secret passing for CODEX_AUTH_JSON, WORKFLOWS_APP_ID, and WORKFLOWS_APP_PRIVATE_KEY

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +173 to 174
- preflight
- run-codex
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The summary job now depends on the preflight job, but this dependency will cause the summary job to be skipped when the preflight job is skipped (i.e., when needs.evaluate.outputs.action != 'run'). This breaks the intended behavior where the summary should run regardless of whether the preflight job executes. The summary job has if: always() which should allow it to run in all scenarios to update the keepalive status, but the hard dependency on preflight will prevent execution when preflight is skipped.

Consider removing preflight from the needs list in the summary job, since the summary doesn't actually use any outputs from preflight and should run independently to report the final state.

Suggested change
- preflight
- run-codex

Copilot uses AI. Check for mistakes.
needs:
- evaluate
- preflight
if: needs.evaluate.outputs.action == 'run' && needs.preflight.outputs.secrets_ok == 'true'
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The condition checking secrets_ok == 'true' is redundant because the preflight job already exits with status 1 when secrets are not available. When preflight fails, needs.preflight.result would be 'failure', which would already prevent run-codex from executing due to the default behavior (jobs don't run when their dependencies fail unless you specify if: always() or check needs.X.result).

The current condition needs.preflight.outputs.secrets_ok == 'true' will never be false in practice because preflight will fail before setting secrets_ok to false makes any difference. Consider simplifying the condition to just needs.evaluate.outputs.action == 'run', or if you want to handle a failed preflight explicitly, check needs.preflight.result == 'success' instead.

Suggested change
if: needs.evaluate.outputs.action == 'run' && needs.preflight.outputs.secrets_ok == 'true'
if: needs.evaluate.outputs.action == 'run'

Copilot uses AI. Check for mistakes.
else
echo "::error::Neither CODEX_AUTH_JSON nor WORKFLOWS_APP_ID is set. Cannot run Codex."
echo "secrets_ok=false" >> "$GITHUB_OUTPUT"
exit 1
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The preflight job sets secrets_ok=false before exit 1, but this output won't be available to dependent jobs because GitHub Actions doesn't make outputs from failed jobs available. When a job fails (exit 1), its outputs are not propagated to needs.X.outputs in dependent jobs. This means the check in run-codex for needs.preflight.outputs.secrets_ok == 'true' won't work as intended - it will be empty/undefined rather than 'false'.

If you want to use the output value to control flow, the preflight job should succeed (exit 0) in both cases and let the run-codex job decide whether to proceed based on the secrets_ok output.

Suggested change
exit 1

Copilot uses AI. Check for mistakes.
@stranske stranske merged commit a623632 into main Dec 24, 2025
114 checks passed
@stranske stranske deleted the codex/issue-79 branch December 24, 2025 12:49
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