diff --git a/.github/workflows/sfl-pr-review.lock.yml b/.github/workflows/sfl-pr-review.lock.yml
index 82a39036..ccc0abc4 100644
--- a/.github/workflows/sfl-pr-review.lock.yml
+++ b/.github/workflows/sfl-pr-review.lock.yml
@@ -1,4 +1,4 @@
-# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"82a70afe8e07cef6c5c860f6c6dd63e9cd6cbb6119c7894c500b4056674eede6","body_hash":"0ccd95739631940071b8b74567ce761814fc9edd21b5b9fd3ac14645d4de9357","compiler_version":"v0.84.1","strict":true,"agent_id":"copilot","agent_model":"moonshotai/kimi-k3","engine_versions":{"copilot":"1.0.75"}}
+# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"c39a5f3d7739d25105b976e1030f657a025b2f6b5d1ce96158be26f73634dbc4","body_hash":"75571bbf45b79033b69819e4589f7eb33d401ae53c57ab858d702a0e59e084f8","compiler_version":"v0.84.1","strict":true,"agent_id":"copilot","agent_model":"moonshotai/kimi-k3","engine_versions":{"copilot":"1.0.75"}}
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN","OPENROUTER_API_KEY","SFL_APP_PRIVATE_KEY"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/create-github-app-token","sha":"bcd2ba49218906704ab6c1aa796996da409d3eb1","version":"bcd2ba49218906704ab6c1aa796996da409d3eb1"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"820762786026740c76f36085b0efc47a31fe5020","version":"v7.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"029204130cb73f6ba684e56428c7f3e9319b708c","version":"v0.84.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.43","digest":"sha256:04e2d1987a565000a8f114b89d806ae7a3864dd4f944be65275b28c93d8690e6","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.27.43@sha256:04e2d1987a565000a8f114b89d806ae7a3864dd4f944be65275b28c93d8690e6"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.43","digest":"sha256:d85f57975af5ea23af4996e41ed73fbc8f5b4a47402472bfe82e508f352cb0c1","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.43@sha256:d85f57975af5ea23af4996e41ed73fbc8f5b4a47402472bfe82e508f352cb0c1"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.43","digest":"sha256:26be5e0b8c8f4c41c8a59126b29bb5d80b07253597472ded2a16bdd75abcbf9d","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.27.43@sha256:26be5e0b8c8f4c41c8a59126b29bb5d80b07253597472ded2a16bdd75abcbf9d"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.7","digest":"sha256:7545220a9aca134b71e51193ee0eaf4c50756ebf8fbd25a63ae7556e62815c00","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.7@sha256:7545220a9aca134b71e51193ee0eaf4c50756ebf8fbd25a63ae7556e62815c00"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:a8082161d7dceda14b68f32eb39d0eaa96b825d07f5895b096afab9d9e0c7748","pinned_image":"ghcr.io/github/gh-aw-node@sha256:a8082161d7dceda14b68f32eb39d0eaa96b825d07f5895b096afab9d9e0c7748"},{"image":"ghcr.io/github/github-mcp-server:v1.8.0","digest":"sha256:d5a18c04b92714c309eb46a2305087e91a4dbd80420f6e462656699f95093520","pinned_image":"ghcr.io/github/github-mcp-server:v1.8.0@sha256:d5a18c04b92714c309eb46a2305087e91a4dbd80420f6e462656699f95093520"}]}
# This file was automatically generated by gh-aw (v0.84.1). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
#
@@ -86,8 +86,7 @@ jobs:
activation:
needs: pre_activation
if: >
- needs.pre_activation.outputs.activated == 'true' && ((github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id) &&
- (github.event_name == 'pull_request' && github.event.label.name == 'sfl-review'))
+ needs.pre_activation.outputs.activated == 'true' && (github.event_name == 'pull_request' && github.event.label.name == 'sfl-review')
runs-on: ubuntu-slim
permissions:
actions: read
@@ -305,20 +304,20 @@ jobs:
run: |
bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh"
{
- cat << 'GH_AW_PROMPT_503da790416b842c_EOF'
+ cat << 'GH_AW_PROMPT_f92ca49c1b3537f5_EOF'
- GH_AW_PROMPT_503da790416b842c_EOF
+ GH_AW_PROMPT_f92ca49c1b3537f5_EOF
cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md"
cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md"
cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md"
cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md"
- cat << 'GH_AW_PROMPT_503da790416b842c_EOF'
+ cat << 'GH_AW_PROMPT_f92ca49c1b3537f5_EOF'
- Tools: create_pull_request_review_comment(max:20), submit_pull_request_review, create_check_run, missing_tool, missing_data, noop
+ Tools: create_pull_request_review_comment(max:20), submit_pull_request_review, create_check_run, missing_tool, missing_data, noop, sfl_review_inventory
- GH_AW_PROMPT_503da790416b842c_EOF
+ GH_AW_PROMPT_f92ca49c1b3537f5_EOF
cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md"
- cat << 'GH_AW_PROMPT_503da790416b842c_EOF'
+ cat << 'GH_AW_PROMPT_f92ca49c1b3537f5_EOF'
The following GitHub context information is available for this workflow:
{{#if github.actor}}
@@ -347,12 +346,12 @@ jobs:
{{/if}}
- GH_AW_PROMPT_503da790416b842c_EOF
+ GH_AW_PROMPT_f92ca49c1b3537f5_EOF
cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md"
- cat << 'GH_AW_PROMPT_503da790416b842c_EOF'
+ cat << 'GH_AW_PROMPT_f92ca49c1b3537f5_EOF'
{{#runtime-import .github/workflows/sfl-pr-review.md}}
- GH_AW_PROMPT_503da790416b842c_EOF
+ GH_AW_PROMPT_f92ca49c1b3537f5_EOF
} > "$GH_AW_PROMPT"
- name: Interpolate variables and render templates
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
@@ -581,9 +580,9 @@ jobs:
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
mkdir -p /tmp/gh-aw/safeoutputs
mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
- cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_c4d5260f57f75b00_EOF'
- {"create_check_run":{"max":1,"name":"SFL Reviewer Approval"},"create_pull_request_review_comment":{"commit_id":"${{ github.event.pull_request.head.sha }}","max":20,"side":"RIGHT"},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"report_incomplete":{},"submit_pull_request_review":{"allowed_events":["APPROVE","REQUEST_CHANGES"],"commit_id":"${{ github.event.pull_request.head.sha }}","footer":"always","max":1,"supersede_older_reviews":true}}
- GH_AW_SAFE_OUTPUTS_CONFIG_c4d5260f57f75b00_EOF
+ cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_f958e5be36167e1f_EOF'
+ {"create_check_run":{"max":1,"name":"SFL Reviewer Approval"},"create_pull_request_review_comment":{"commit_id":"${{ github.event.pull_request.head.sha }}","max":20,"side":"RIGHT"},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"false"},"report_incomplete":{},"sfl_review_inventory":{"description":"Record the complete SFL finding inventory for deterministic verdict validation.","inputs":{"carried_critical":{"default":null,"description":"Unresolved Critical findings carried from earlier SFL runs.","required":true,"type":"number"},"carried_high":{"default":null,"description":"Unresolved High findings carried from earlier SFL runs.","required":true,"type":"number"},"carried_low":{"default":null,"description":"Unresolved Low findings carried from earlier SFL runs.","required":true,"type":"number"},"carried_medium":{"default":null,"description":"Unresolved Medium findings carried from earlier SFL runs.","required":true,"type":"number"},"head_sha":{"default":null,"description":"Triggering pull request head SHA.","required":true,"type":"string"},"new_critical":{"default":null,"description":"Newly identified Critical findings.","required":true,"type":"number"},"new_high":{"default":null,"description":"Newly identified High findings.","required":true,"type":"number"},"new_low":{"default":null,"description":"Newly identified Low findings.","required":true,"type":"number"},"new_medium":{"default":null,"description":"Newly identified Medium findings.","required":true,"type":"number"},"overflow":{"default":null,"description":"Newly identified findings omitted after the 20-comment cap.","required":true,"type":"number"}}},"submit_pull_request_review":{"allowed_events":["APPROVE","REQUEST_CHANGES"],"commit_id":"${{ github.event.pull_request.head.sha }}","footer":"always","max":1,"supersede_older_reviews":true}}
+ GH_AW_SAFE_OUTPUTS_CONFIG_f958e5be36167e1f_EOF
- name: Generate Safe Outputs Tools
env:
GH_AW_TOOLS_META_JSON: |
@@ -594,7 +593,70 @@ jobs:
"submit_pull_request_review": " CONSTRAINTS: Maximum 1 review(s) can be submitted."
},
"repo_params": {},
- "dynamic_tools": []
+ "dynamic_tools": [
+ {
+ "description": "Record the complete SFL finding inventory for deterministic verdict validation.",
+ "inputSchema": {
+ "additionalProperties": false,
+ "properties": {
+ "carried_critical": {
+ "description": "Unresolved Critical findings carried from earlier SFL runs.",
+ "type": "number"
+ },
+ "carried_high": {
+ "description": "Unresolved High findings carried from earlier SFL runs.",
+ "type": "number"
+ },
+ "carried_low": {
+ "description": "Unresolved Low findings carried from earlier SFL runs.",
+ "type": "number"
+ },
+ "carried_medium": {
+ "description": "Unresolved Medium findings carried from earlier SFL runs.",
+ "type": "number"
+ },
+ "head_sha": {
+ "description": "Triggering pull request head SHA.",
+ "type": "string"
+ },
+ "new_critical": {
+ "description": "Newly identified Critical findings.",
+ "type": "number"
+ },
+ "new_high": {
+ "description": "Newly identified High findings.",
+ "type": "number"
+ },
+ "new_low": {
+ "description": "Newly identified Low findings.",
+ "type": "number"
+ },
+ "new_medium": {
+ "description": "Newly identified Medium findings.",
+ "type": "number"
+ },
+ "overflow": {
+ "description": "Newly identified findings omitted after the 20-comment cap.",
+ "type": "number"
+ }
+ },
+ "required": [
+ "carried_critical",
+ "carried_high",
+ "carried_low",
+ "carried_medium",
+ "head_sha",
+ "new_critical",
+ "new_high",
+ "new_low",
+ "new_medium",
+ "overflow"
+ ],
+ "type": "object"
+ },
+ "name": "sfl_review_inventory"
+ }
+ ]
}
GH_AW_VALIDATION_JSON: |
{
@@ -1037,6 +1099,11 @@ jobs:
if [ ! -f /tmp/gh-aw/agent_output.json ]; then
echo '{"items":[]}' > /tmp/gh-aw/agent_output.json
fi
+ - if: always()
+ name: Require SFL review output
+ run: "node <<'NODE'\nconst fs = require('fs');\nconst path = '/tmp/gh-aw/agent_output.json';\nif (!fs.existsSync(path)) {\n throw new Error('SFL agent output file is missing');\n}\nconst output = JSON.parse(fs.readFileSync(path, 'utf8'));\nconst items = Array.isArray(output.items) ? output.items : [];\nconst hasInventory = items.some(\n (item) => item.type === 'sfl_review_inventory'\n);\nconst hasNoop = items.some((item) => item.type === 'noop');\nconst hasMissingSignal = items.some(\n (item) => item.type === 'missing_tool' || item.type === 'missing_data'\n);\nif (!hasInventory && !hasNoop && !hasMissingSignal) {\n throw new Error(\n 'SFL review emitted neither an inventory, noop, nor missing signal'\n );\n}\nNODE\n"
+ shell: bash
+
- name: Upload agent artifacts
if: always()
continue-on-error: true
@@ -1232,7 +1299,7 @@ jobs:
GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/sfl-pr-review.md"
GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }}
- GH_AW_NOOP_REPORT_AS_ISSUE: "true"
+ GH_AW_NOOP_REPORT_AS_ISSUE: "false"
GH_AW_AIC: ${{ needs.agent.outputs.aic }}
GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }}
GH_AW_AMBIENT_CONTEXT: ${{ needs.agent.outputs.ambient_context }}
@@ -1503,8 +1570,8 @@ jobs:
export GH_AW_NODE_BIN
export COPILOT_API_KEY="$COPILOT_DUMMY_BYOK"
(umask 177 && touch /tmp/gh-aw/threat-detection/detection.log)
- GH_AW_MAX_AI_CREDITS="${GH_AW_MAX_AI_CREDITS:-400}"
- printf '%s\n' "{\"\$schema\":\"https://github.com/github/gh-aw-firewall/releases/download/v0.27.43/awf-config.schema.json\",\"network\":{\"allowDomains\":[\"api.business.githubcopilot.com\",\"api.enterprise.githubcopilot.com\",\"api.github.com\",\"api.githubcopilot.com\",\"api.individual.githubcopilot.com\",\"github.com\",\"host.docker.internal\",\"openrouter.ai\",\"registry.npmjs.org\",\"telemetry.enterprise.githubcopilot.com\"]},\"apiProxy\":{\"enabled\":true,\"enableTokenSteering\":true,\"maxRuns\":500,\"maxAiCredits\":${GH_AW_MAX_AI_CREDITS},\"maxCacheMisses\":5,\"models\":{\"agent\":[\"sonnet-6x\",\"gpt-5.4\",\"gpt-5.5\",\"gpt-5.6\",\"gpt-5.3\",\"gemini-pro\",\"any\"],\"antigravity\":[\"copilot/antigravity*\",\"google/antigravity*\",\"gemini/antigravity*\"],\"any\":[\"copilot/*\",\"anthropic/*\",\"openai/*\",\"google/*\",\"gemini/*\"],\"auto\":[\"copilot/auto\",\"large\"],\"claude\":[\"agent\"],\"codex\":[\"agent\"],\"coding\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\",\"gpt-5-codex\",\"kimi\"],\"computer-use\":[\"copilot/*computer-use*\",\"google/*computer-use*\",\"gemini/*computer-use*\",\"openai/*computer-use*\"],\"copilot\":[\"agent\"],\"deep-research\":[\"copilot/deep-research*\",\"copilot/o3-deep-research*\",\"copilot/o4-mini-deep-research*\",\"google/deep-research*\",\"gemini/deep-research*\",\"openai/o3-deep-research*\",\"openai/o4-mini-deep-research*\"],\"fable\":[\"copilot/*fable*\",\"anthropic/*fable*\"],\"gemini\":[\"agent\"],\"gemini-3-flash\":[\"copilot/gemini-3*flash*\",\"google/gemini-3*flash*\",\"gemini/gemini-3*flash*\"],\"gemini-3-pro\":[\"copilot/gemini-3*pro*\",\"google/gemini-3*pro*\",\"google/nano-banana*\",\"gemini/gemini-3*pro*\"],\"gemini-3.1-flash\":[\"copilot/gemini-3.1*flash*\",\"google/gemini-3.1*flash*\",\"gemini/gemini-3.1*flash*\"],\"gemini-3.1-pro\":[\"copilot/gemini-3.1*pro*\",\"google/gemini-3.1*pro*\",\"gemini/gemini-3.1*pro*\"],\"gemini-3.5-flash\":[\"copilot/gemini-3.5*flash*\",\"google/gemini-3.5*flash*\",\"gemini/gemini-3.5*flash*\"],\"gemini-3.6-flash\":[\"copilot/gemini-3.6*flash*\",\"google/gemini-3.6*flash*\",\"gemini/gemini-3.6*flash*\"],\"gemini-flash\":[\"copilot/gemini-*flash*\",\"google/gemini-*flash*\",\"gemini/gemini-*flash*\"],\"gemini-flash-lite\":[\"copilot/gemini-*flash*lite*\",\"google/gemini-*flash*lite*\",\"gemini/gemini-*flash*lite*\"],\"gemini-omni\":[\"copilot/gemini-omni*\",\"google/gemini-omni*\",\"gemini/gemini-omni*\"],\"gemini-pro\":[\"copilot/gemini-*pro*\",\"google/gemini-*pro*\",\"gemini/gemini-*pro*\"],\"gemma\":[\"copilot/gemma*\",\"google/gemma*\",\"gemini/gemma*\"],\"gpt-5\":[\"copilot/gpt-5*\",\"openai/gpt-5*\"],\"gpt-5-codex\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\"],\"gpt-5-mini\":[\"copilot/gpt-5*mini*\",\"openai/gpt-5*mini*\"],\"gpt-5-nano\":[\"copilot/gpt-5*nano*\",\"openai/gpt-5*nano*\"],\"gpt-5-pro\":[\"copilot/gpt-5*pro*\",\"openai/gpt-5*pro*\"],\"gpt-5.1\":[\"copilot/gpt-5.1*\",\"openai/gpt-5.1*\"],\"gpt-5.2\":[\"copilot/gpt-5.2*\",\"openai/gpt-5.2*\"],\"gpt-5.3\":[\"copilot/gpt-5.3*\",\"openai/gpt-5.3*\"],\"gpt-5.4\":[\"copilot/gpt-5.4*\",\"openai/gpt-5.4*\"],\"gpt-5.5\":[\"copilot/gpt-5.5*\",\"openai/gpt-5.5*\"],\"gpt-5.6\":[\"copilot/gpt-5.6*\",\"openai/gpt-5.6*\"],\"grok\":[\"copilot/*grok*\",\"openai/*grok*\"],\"haiku\":[\"copilot/*haiku*\",\"anthropic/*haiku*\"],\"image-generation\":[\"copilot/gpt-image*\",\"openai/gpt-image*\",\"openai/chatgpt-image*\",\"copilot/gemini-*image*\",\"google/gemini-*image*\",\"gemini/gemini-*image*\",\"google/imagen*\"],\"kimi\":[\"copilot/kimi*\",\"openai/kimi*\"],\"kiwi\":[\"copilot/kiwi*\",\"openai/kiwi*\"],\"large\":[\"sonnet\",\"gpt-5-pro\",\"gpt-5\",\"gemini-pro\"],\"lyria\":[\"google/lyria*\",\"gemini/lyria*\",\"copilot/lyria*\"],\"mai-code\":[\"copilot/MAI-Code*\",\"copilot/mai-code*\",\"openai/MAI-Code*\"],\"mai-code-1-flash-picker\":[\"copilot/MAI-Code-1-Flash-picker*\",\"copilot/mai-code-1-flash-picker*\",\"openai/MAI-Code-1-Flash-picker*\"],\"mini\":[\"haiku\",\"gpt-5-mini\",\"gpt-5-nano\",\"gemini-flash-lite\"],\"nano-banana\":[\"copilot/nano-banana*\",\"google/nano-banana*\",\"gemini/nano-banana*\"],\"opus\":[\"copilot/*opus*\",\"anthropic/*opus*\"],\"opusplan\":[\"opus?effort=high\"],\"raptor-mini\":[\"copilot/raptor*\",\"openai/raptor*\"],\"reasoning\":[\"copilot/o1*\",\"copilot/o3*\",\"copilot/o4*\",\"openai/o1*\",\"openai/o3*\",\"openai/o4*\"],\"robotics\":[\"copilot/*robotics*\",\"google/*robotics*\",\"gemini/*robotics*\"],\"small\":[\"mini\"],\"small-agent\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash\"],\"sonnet\":[\"copilot/*sonnet*\",\"anthropic/*sonnet*\"],\"sonnet-6x\":[\"copilot/*sonnet-4.5*\",\"copilot/*sonnet-4.6*\",\"copilot/*sonnet-5*\",\"copilot/*sonnet-4-5-*\",\"anthropic/*sonnet-4-5-*\",\"copilot/*sonnet-4-6*\",\"anthropic/*sonnet-4-6*\",\"anthropic/*sonnet-5*\"],\"summarization\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash-lite\",\"mini\"],\"veo\":[\"google/veo*\",\"gemini/veo*\"],\"vision\":[\"copilot/gemini-*image*\",\"google/gemini-*image*\",\"gemini/gemini-*image*\",\"copilot/gemini-*flash*\",\"google/gemini-*flash*\",\"gemini/gemini-*flash*\"]}},\"container\":{\"imageTag\":\"0.27.43,squid=sha256:26be5e0b8c8f4c41c8a59126b29bb5d80b07253597472ded2a16bdd75abcbf9d,agent=sha256:04e2d1987a565000a8f114b89d806ae7a3864dd4f944be65275b28c93d8690e6,api-proxy=sha256:d85f57975af5ea23af4996e41ed73fbc8f5b4a47402472bfe82e508f352cb0c1,cli-proxy=sha256:65c45ea2967984d0024f3df61bc71335658a77ede96c8d9665da7a5f33a795ab\"},\"logging\":{\"proxyLogsDir\":\"/tmp/gh-aw/sandbox/firewall/logs\",\"auditDir\":\"/tmp/gh-aw/sandbox/firewall/audit\"}}" > "${RUNNER_TEMP}/gh-aw/awf-config.json"
+ # shellcheck disable=SC2016
+ printf '%s\n' '{"$schema":"https://github.com/github/gh-aw-firewall/releases/download/v0.27.43/awf-config.schema.json","network":{"allowDomains":["api.business.githubcopilot.com","api.enterprise.githubcopilot.com","api.github.com","api.githubcopilot.com","api.individual.githubcopilot.com","github.com","host.docker.internal","openrouter.ai","registry.npmjs.org","telemetry.enterprise.githubcopilot.com"]},"apiProxy":{"enabled":true,"maxRuns":500,"maxCacheMisses":5,"models":{"agent":["sonnet-6x","gpt-5.4","gpt-5.5","gpt-5.6","gpt-5.3","gemini-pro","any"],"antigravity":["copilot/antigravity*","google/antigravity*","gemini/antigravity*"],"any":["copilot/*","anthropic/*","openai/*","google/*","gemini/*"],"auto":["copilot/auto","large"],"claude":["agent"],"codex":["agent"],"coding":["copilot/gpt-5*codex*","openai/gpt-5*codex*","gpt-5-codex","kimi"],"computer-use":["copilot/*computer-use*","google/*computer-use*","gemini/*computer-use*","openai/*computer-use*"],"copilot":["agent"],"deep-research":["copilot/deep-research*","copilot/o3-deep-research*","copilot/o4-mini-deep-research*","google/deep-research*","gemini/deep-research*","openai/o3-deep-research*","openai/o4-mini-deep-research*"],"fable":["copilot/*fable*","anthropic/*fable*"],"gemini":["agent"],"gemini-3-flash":["copilot/gemini-3*flash*","google/gemini-3*flash*","gemini/gemini-3*flash*"],"gemini-3-pro":["copilot/gemini-3*pro*","google/gemini-3*pro*","google/nano-banana*","gemini/gemini-3*pro*"],"gemini-3.1-flash":["copilot/gemini-3.1*flash*","google/gemini-3.1*flash*","gemini/gemini-3.1*flash*"],"gemini-3.1-pro":["copilot/gemini-3.1*pro*","google/gemini-3.1*pro*","gemini/gemini-3.1*pro*"],"gemini-3.5-flash":["copilot/gemini-3.5*flash*","google/gemini-3.5*flash*","gemini/gemini-3.5*flash*"],"gemini-3.6-flash":["copilot/gemini-3.6*flash*","google/gemini-3.6*flash*","gemini/gemini-3.6*flash*"],"gemini-flash":["copilot/gemini-*flash*","google/gemini-*flash*","gemini/gemini-*flash*"],"gemini-flash-lite":["copilot/gemini-*flash*lite*","google/gemini-*flash*lite*","gemini/gemini-*flash*lite*"],"gemini-omni":["copilot/gemini-omni*","google/gemini-omni*","gemini/gemini-omni*"],"gemini-pro":["copilot/gemini-*pro*","google/gemini-*pro*","gemini/gemini-*pro*"],"gemma":["copilot/gemma*","google/gemma*","gemini/gemma*"],"gpt-5":["copilot/gpt-5*","openai/gpt-5*"],"gpt-5-codex":["copilot/gpt-5*codex*","openai/gpt-5*codex*"],"gpt-5-mini":["copilot/gpt-5*mini*","openai/gpt-5*mini*"],"gpt-5-nano":["copilot/gpt-5*nano*","openai/gpt-5*nano*"],"gpt-5-pro":["copilot/gpt-5*pro*","openai/gpt-5*pro*"],"gpt-5.1":["copilot/gpt-5.1*","openai/gpt-5.1*"],"gpt-5.2":["copilot/gpt-5.2*","openai/gpt-5.2*"],"gpt-5.3":["copilot/gpt-5.3*","openai/gpt-5.3*"],"gpt-5.4":["copilot/gpt-5.4*","openai/gpt-5.4*"],"gpt-5.5":["copilot/gpt-5.5*","openai/gpt-5.5*"],"gpt-5.6":["copilot/gpt-5.6*","openai/gpt-5.6*"],"grok":["copilot/*grok*","openai/*grok*"],"haiku":["copilot/*haiku*","anthropic/*haiku*"],"image-generation":["copilot/gpt-image*","openai/gpt-image*","openai/chatgpt-image*","copilot/gemini-*image*","google/gemini-*image*","gemini/gemini-*image*","google/imagen*"],"kimi":["copilot/kimi*","openai/kimi*"],"kiwi":["copilot/kiwi*","openai/kiwi*"],"large":["sonnet","gpt-5-pro","gpt-5","gemini-pro"],"lyria":["google/lyria*","gemini/lyria*","copilot/lyria*"],"mai-code":["copilot/MAI-Code*","copilot/mai-code*","openai/MAI-Code*"],"mai-code-1-flash-picker":["copilot/MAI-Code-1-Flash-picker*","copilot/mai-code-1-flash-picker*","openai/MAI-Code-1-Flash-picker*"],"mini":["haiku","gpt-5-mini","gpt-5-nano","gemini-flash-lite"],"nano-banana":["copilot/nano-banana*","google/nano-banana*","gemini/nano-banana*"],"opus":["copilot/*opus*","anthropic/*opus*"],"opusplan":["opus?effort=high"],"raptor-mini":["copilot/raptor*","openai/raptor*"],"reasoning":["copilot/o1*","copilot/o3*","copilot/o4*","openai/o1*","openai/o3*","openai/o4*"],"robotics":["copilot/*robotics*","google/*robotics*","gemini/*robotics*"],"small":["mini"],"small-agent":["haiku","gpt-5-mini","gemini-flash"],"sonnet":["copilot/*sonnet*","anthropic/*sonnet*"],"sonnet-6x":["copilot/*sonnet-4.5*","copilot/*sonnet-4.6*","copilot/*sonnet-5*","copilot/*sonnet-4-5-*","anthropic/*sonnet-4-5-*","copilot/*sonnet-4-6*","anthropic/*sonnet-4-6*","anthropic/*sonnet-5*"],"summarization":["haiku","gpt-5-mini","gemini-flash-lite","mini"],"veo":["google/veo*","gemini/veo*"],"vision":["copilot/gemini-*image*","google/gemini-*image*","gemini/gemini-*image*","copilot/gemini-*flash*","google/gemini-*flash*","gemini/gemini-*flash*"]}},"container":{"imageTag":"0.27.43,squid=sha256:26be5e0b8c8f4c41c8a59126b29bb5d80b07253597472ded2a16bdd75abcbf9d,agent=sha256:04e2d1987a565000a8f114b89d806ae7a3864dd4f944be65275b28c93d8690e6,api-proxy=sha256:d85f57975af5ea23af4996e41ed73fbc8f5b4a47402472bfe82e508f352cb0c1,cli-proxy=sha256:65c45ea2967984d0024f3df61bc71335658a77ede96c8d9665da7a5f33a795ab"},"logging":{"proxyLogsDir":"/tmp/gh-aw/sandbox/firewall/logs","auditDir":"/tmp/gh-aw/sandbox/firewall/audit"}}' > "${RUNNER_TEMP}/gh-aw/awf-config.json"
cp "${RUNNER_TEMP}/gh-aw/awf-config.json" /tmp/gh-aw/awf-config.json
export GH_AW_MODELS_JSON_PATH="/tmp/gh-aw/models.json"
GH_AW_DOCKER_HOST=""
@@ -1536,7 +1603,6 @@ jobs:
COPILOT_PROVIDER_TYPE: openai
COPILOT_PROVIDER_WIRE_API: responses
GH_AW_LLM_PROVIDER: github
- GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
GH_AW_PHASE: detection
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
@@ -1556,29 +1622,439 @@ jobs:
GIT_COMMITTER_NAME: github-actions[bot]
RUNNER_TEMP: ${{ runner.temp }}
TRACEPARENT: ${{ env.GITHUB_AW_OTEL_TRACE_ID != '' && env.GITHUB_AW_OTEL_PARENT_SPAN_ID != '' && format('00-{0}-{1}-01', env.GITHUB_AW_OTEL_TRACE_ID, env.GITHUB_AW_OTEL_PARENT_SPAN_ID) || '' }}
- - name: Generate SFL App token for final head verification
- id: sfl-final-head-token
+ - name: Mint SFL validation token
+ id: sfl-validation-token
if: always() && steps.detection_guard.outputs.run_detection == 'true'
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1
with:
client-id: ${{ vars.SFL_APP_CLIENT_ID }}
- owner: ${{ github.repository_owner }}
permission-pull-requests: read
private-key: ${{ secrets.SFL_APP_PRIVATE_KEY }}
- repositories: ${{ github.event.repository.name }}
- - name: Verify PR head before safe outputs
+ - name: Validate SFL review verdict
if: always() && steps.detection_guard.outputs.run_detection == 'true'
run: |
- live_head="$(gh api "repos/${REPOSITORY}/pulls/${PR_NUMBER}" --jq '.head.sha')"
- if [[ "$live_head" != "$EXPECTED_HEAD" ]]; then
- echo "::error::PR head changed from ${EXPECTED_HEAD} to ${live_head}; suppressing stale SFL outputs"
- exit 1
- fi
+ # SFL_VERDICT_VALIDATOR_START
+ node <<'NODE'
+ const fs = require('fs');
+ const { execFileSync } = require('child_process');
+
+ const outputPath =
+ process.env.SFL_AGENT_OUTPUT_PATH ||
+ '/tmp/gh-aw/threat-detection/agent_output.json';
+ const expectedHead = process.env.EXPECTED_HEAD_SHA || '';
+ const expectedRunId = process.env.EXPECTED_RUN_ID || '';
+ const fail = (message) => {
+ console.error(`SFL verdict validation failed: ${message}`);
+ process.exit(1);
+ };
+
+ if (!fs.existsSync(outputPath)) {
+ fail(`agent output is missing: ${outputPath}`);
+ }
+
+ const output = JSON.parse(fs.readFileSync(outputPath, 'utf8'));
+ const items = Array.isArray(output.items) ? output.items : [];
+ const noops = items.filter((item) => item.type === 'noop');
+ const triggeringRepo = String(process.env.GITHUB_REPOSITORY || '');
+ const triggeringPr = Number(process.env.PR_NUMBER);
+ const targetFields = [
+ 'pull_request_number',
+ 'pr_number',
+ 'pr',
+ 'pull_number',
+ ];
+ for (const item of items) {
+ if (item.repo && item.repo !== triggeringRepo) {
+ fail(`output target repo must be ${triggeringRepo}`);
+ }
+ for (const field of targetFields) {
+ if (
+ item[field] !== undefined &&
+ Number(item[field]) !== triggeringPr
+ ) {
+ fail(`output target ${field} must be ${triggeringPr}`);
+ }
+ }
+ }
+
+ const loadPrState = () => {
+ if (process.env.SFL_PR_STATE_PATH) {
+ return JSON.parse(
+ fs.readFileSync(process.env.SFL_PR_STATE_PATH, 'utf8')
+ );
+ }
+ const [owner, repo] = String(
+ process.env.GITHUB_REPOSITORY || ''
+ ).split('/');
+ const number = process.env.PR_NUMBER || '';
+ if (!owner || !repo || !number || !process.env.GH_TOKEN) {
+ fail('GitHub context for deterministic PR validation is incomplete');
+ }
+ const query = [
+ 'query($owner:String!,$repo:String!,$number:Int!,$after:String){',
+ 'repository(owner:$owner,name:$repo){',
+ 'pullRequest(number:$number){headRefOid reviewThreads(first:100,after:$after){',
+ 'nodes{isResolved comments(first:1){nodes{body author{login}}}} ',
+ 'pageInfo{hasNextPage endCursor}',
+ '}}}}',
+ ].join('');
+ const nodes = [];
+ let after = null;
+ let headRefOid = '';
+ try {
+ do {
+ const args = [
+ 'api',
+ 'graphql',
+ '-f',
+ `query=${query}`,
+ '-F',
+ `owner=${owner}`,
+ '-F',
+ `repo=${repo}`,
+ '-F',
+ `number=${number}`,
+ ];
+ if (after) {
+ args.push('-f', `after=${after}`);
+ }
+ const raw = execFileSync('gh', args, {
+ encoding: 'utf8',
+ env: process.env,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ });
+ const response = JSON.parse(raw);
+ if (
+ Array.isArray(response.errors) &&
+ response.errors.length > 0
+ ) {
+ fail(
+ `GitHub GraphQL returned errors: ` +
+ response.errors
+ .map((error) => error.message || 'unknown error')
+ .join('; ')
+ );
+ }
+ const pullRequest = response?.data?.repository?.pullRequest;
+ if (!pullRequest?.headRefOid) {
+ fail('GitHub returned no pull request state');
+ }
+ const reviewThreads = pullRequest.reviewThreads;
+ if (
+ !Array.isArray(reviewThreads?.nodes) ||
+ typeof reviewThreads?.pageInfo?.hasNextPage !== 'boolean' ||
+ (reviewThreads.pageInfo.hasNextPage &&
+ !reviewThreads.pageInfo.endCursor)
+ ) {
+ fail('GitHub returned incomplete review-thread data');
+ }
+ headRefOid = pullRequest.headRefOid;
+ nodes.push(...reviewThreads.nodes);
+ after = reviewThreads.pageInfo.hasNextPage
+ ? reviewThreads.pageInfo.endCursor
+ : null;
+ } while (after);
+ return { headRefOid, reviewThreads: { nodes } };
+ } catch (error) {
+ fail(`unable to query live pull request state: ${error.message}`);
+ }
+ };
+
+ const prState = loadPrState();
+ const liveHead = prState.headRefOid;
+ if (liveHead !== expectedHead) {
+ if (noops.length !== 1 || items.length !== 1) {
+ fail('head drift requires exactly one noop output');
+ }
+ console.log('SFL verdict validation passed: verified head drift');
+ process.exit(0);
+ }
+ if (noops.length > 0) {
+ fail('noop is forbidden while the pull request head is unchanged');
+ }
+
+ const allowedTypes = new Set([
+ 'sfl_review_inventory',
+ 'create_pull_request_review_comment',
+ 'submit_pull_request_review',
+ 'create_check_run',
+ 'missing_tool',
+ 'missing_data',
+ ]);
+ const unexpectedTypes = [
+ ...new Set(
+ items
+ .map((item) => item.type)
+ .filter((type) => !allowedTypes.has(type))
+ ),
+ ];
+ if (unexpectedTypes.length > 0) {
+ fail(
+ `unexpected safe output types: ${unexpectedTypes.join(', ')}`
+ );
+ }
+
+ const missingSignals = items.filter(
+ (item) => item.type === 'missing_tool' || item.type === 'missing_data'
+ );
+ if (missingSignals.length > 0) {
+ if (missingSignals.length !== 1 || items.length !== 1) {
+ fail('a missing signal must be the only safe output item');
+ }
+ console.log('SFL verdict validation passed: terminal missing signal');
+ process.exit(0);
+ }
+
+ const inventories = items.filter(
+ (item) => item.type === 'sfl_review_inventory'
+ );
+ if (inventories.length !== 1) {
+ fail('exactly one sfl_review_inventory output is required');
+ }
+
+ const inventory = inventories[0];
+ const countFields = [
+ 'new_critical',
+ 'new_high',
+ 'new_medium',
+ 'new_low',
+ 'carried_critical',
+ 'carried_high',
+ 'carried_medium',
+ 'carried_low',
+ 'overflow',
+ ];
+ for (const field of countFields) {
+ if (
+ !Number.isInteger(inventory[field]) ||
+ inventory[field] < 0
+ ) {
+ fail(`${field} must be a non-negative integer`);
+ }
+ }
+ if (!expectedHead || inventory.head_sha !== expectedHead) {
+ fail('inventory head_sha does not match the triggering PR head');
+ }
+
+ const severityOrder = ['critical', 'high', 'medium', 'low'];
+ const prefixes = {
+ critical: '**CRITICAL Finding**',
+ high: '**HIGH Finding**',
+ medium: '**MEDIUM Finding**',
+ low: '**LOW Finding**',
+ };
+ const comments = items.filter(
+ (item) => item.type === 'create_pull_request_review_comment'
+ );
+ const emitted = Object.fromEntries(
+ severityOrder.map((severity) => [severity, 0])
+ );
+ for (const comment of comments) {
+ const severity = severityOrder.find((candidate) =>
+ String(comment.body || '').startsWith(prefixes[candidate])
+ );
+ if (!severity) {
+ fail('every inline review comment must use an SFL severity prefix');
+ }
+ emitted[severity]++;
+ }
+
+ const newlyFound = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ inventory[`new_${severity}`],
+ ])
+ );
+ const carried = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ inventory[`carried_${severity}`],
+ ])
+ );
+ const actualCarried = Object.fromEntries(
+ severityOrder.map((severity) => [severity, 0])
+ );
+ for (const thread of prState.reviewThreads?.nodes || []) {
+ if (thread.isResolved) {
+ continue;
+ }
+ const firstComment = thread.comments?.nodes?.[0];
+ const author = String(firstComment?.author?.login || '');
+ if (author !== 'sfl-app[bot]') {
+ continue;
+ }
+ const severity = severityOrder.find((candidate) =>
+ String(firstComment?.body || '').startsWith(prefixes[candidate])
+ );
+ if (severity) {
+ actualCarried[severity]++;
+ }
+ }
+ for (const severity of severityOrder) {
+ if (carried[severity] !== actualCarried[severity]) {
+ fail(
+ `${severity} carried count must be ` +
+ `${actualCarried[severity]}, got ${carried[severity]}`
+ );
+ }
+ }
+ const newTotal = Object.values(newlyFound).reduce(
+ (sum, count) => sum + count,
+ 0
+ );
+ const expectedOverflow = Math.max(0, newTotal - 20);
+ if (inventory.overflow !== expectedOverflow) {
+ fail(
+ `overflow must be ${expectedOverflow}, got ${inventory.overflow}`
+ );
+ }
+
+ let remaining = Math.min(newTotal, 20);
+ const expectedEmitted = {};
+ for (const severity of severityOrder) {
+ expectedEmitted[severity] = Math.min(
+ newlyFound[severity],
+ remaining
+ );
+ remaining -= expectedEmitted[severity];
+ }
+ for (const severity of severityOrder) {
+ if (emitted[severity] !== expectedEmitted[severity]) {
+ fail(
+ `${severity} emitted count must be ` +
+ `${expectedEmitted[severity]}, got ${emitted[severity]}`
+ );
+ }
+ }
+
+ const reviews = items.filter(
+ (item) => item.type === 'submit_pull_request_review'
+ );
+ const checks = items.filter(
+ (item) => item.type === 'create_check_run'
+ );
+ if (reviews.length !== 1 || checks.length !== 1) {
+ fail('exactly one consolidated review and one check run are required');
+ }
+
+ const blockingFindings =
+ newlyFound.critical +
+ carried.critical +
+ newlyFound.high +
+ carried.high >
+ 0;
+ const blocking = blockingFindings || inventory.overflow > 0;
+ const expectedEvent = blocking ? 'REQUEST_CHANGES' : 'APPROVE';
+ const expectedConclusion = blocking ? 'failure' : 'success';
+ const expectedVerdict = blocking ? 'CHANGES_REQUESTED' : 'APPROVE';
+ const actualEvent = String(reviews[0].event || '').toUpperCase();
+ const actualConclusion = String(
+ checks[0].conclusion || ''
+ ).toLowerCase();
+
+ if (actualEvent !== expectedEvent) {
+ fail(
+ `review event must be ${expectedEvent}, got ${actualEvent || 'empty'}`
+ );
+ }
+ if (actualConclusion !== expectedConclusion) {
+ fail(
+ `check conclusion must be ${expectedConclusion}, got ` +
+ `${actualConclusion || 'empty'}`
+ );
+ }
+ if (checks[0].title !== 'SFL full-spectrum review complete') {
+ fail(
+ 'check title must be SFL full-spectrum review complete'
+ );
+ }
+
+ const totals = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ newlyFound[severity] + carried[severity],
+ ])
+ );
+ const reviewBody = String(reviews[0].body || '');
+ const reviewLines = reviewBody
+ .split(/\r?\n/)
+ .map((line) => line.trim());
+ const requireSingleReviewLine = (prefix, expected) => {
+ const matches = reviewLines.filter((line) =>
+ line.startsWith(prefix)
+ );
+ if (matches.length !== 1 || matches[0] !== expected) {
+ fail(`consolidated review must contain exactly: ${expected}`);
+ }
+ };
+ requireSingleReviewLine(
+ 'SFL run ID:',
+ `SFL run ID: ${expectedRunId}`
+ );
+ requireSingleReviewLine('Head SHA:', `Head SHA: ${expectedHead}`);
+ requireSingleReviewLine(
+ 'Verdict:',
+ `Verdict: ${expectedVerdict}`
+ );
+ if (!expectedRunId) {
+ fail('workflow run ID is unavailable');
+ }
+ const expectedRows = {
+ Critical: totals.critical,
+ High: totals.high,
+ Medium: totals.medium,
+ Low: totals.low,
+ Overflow: inventory.overflow,
+ };
+ for (const [label, expectedCount] of Object.entries(expectedRows)) {
+ const rowPattern = new RegExp(
+ `^\\|\\s*${label}\\s*\\|\\s*(\\d+)\\s*\\|$`
+ );
+ const matches = reviewLines
+ .map((line) => line.match(rowPattern))
+ .filter(Boolean);
+ if (
+ matches.length !== 1 ||
+ Number(matches[0][1]) !== expectedCount
+ ) {
+ fail(
+ `consolidated review must contain one ${label} row with ` +
+ `${expectedCount}`
+ );
+ }
+ }
+
+ const checkSummary = String(checks[0].summary || '');
+ const checkLines = checkSummary
+ .split(/\r?\n/)
+ .map((line) => line.trim())
+ .filter(Boolean);
+ const requiredCheckFragments = [
+ `Verdict: ${expectedVerdict}`,
+ `Head SHA: ${expectedHead}`,
+ `SFL run ID: ${expectedRunId}`,
+ `Critical: ${totals.critical}`,
+ `High: ${totals.high}`,
+ `Medium: ${totals.medium}`,
+ `Low: ${totals.low}`,
+ `Overflow: ${inventory.overflow}`,
+ ];
+ if (
+ JSON.stringify(checkLines) !==
+ JSON.stringify(requiredCheckFragments)
+ ) {
+ fail('check summary does not match the required exact shape');
+ }
+
+ console.log('SFL verdict validation passed');
+ // SFL_VERDICT_VALIDATOR_END
+ NODE
env:
- EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }}
- GH_TOKEN: ${{ steps.sfl-final-head-token.outputs.token }}
+ EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ EXPECTED_RUN_ID: ${{ github.run_id }}
+ GH_TOKEN: ${{ steps.sfl-validation-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- REPOSITORY: ${{ github.repository }}
+ shell: bash
- name: Parse threat detection token usage for step summary
id: parse_detection_token_usage
if: always()
@@ -1633,9 +2109,7 @@ jobs:
}
pre_activation:
- if: >
- (github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id) &&
- (github.event_name == 'pull_request' && github.event.label.name == 'sfl-review')
+ if: github.event_name == 'pull_request' && github.event.label.name == 'sfl-review'
runs-on: ubuntu-slim
env:
GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }}
@@ -1757,6 +2231,26 @@ jobs:
GH_HOST="${GITHUB_SERVER_URL#https://}"
GH_HOST="${GH_HOST#http://}"
echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV"
+ - name: Configure Safe Outputs Custom Scripts
+ run: |
+ cat > "${RUNNER_TEMP}/gh-aw/actions/safe_output_script_sfl_review_inventory.cjs" << 'GH_AW_SAFE_OUTPUT_SCRIPT_SFL_REVIEW_INVENTORY_1fc424916c2b1bb4_EOF'
+ // @ts-check
+ ///
+ // Auto-generated safe-output script handler: sfl-review-inventory
+
+ const { sanitizeContent } = require("./sanitize_content.cjs");
+
+ /** @type {import('./types/safe-output-script').SafeOutputScriptMain} */
+ async function main(config = {}) {
+ const { carried_critical, carried_high, carried_low, carried_medium, head_sha, new_critical, new_high, new_low, new_medium, overflow } = config;
+ return async function handleSflReviewInventory(item, resolvedTemporaryIds, temporaryIdMap) {
+ return { success: true };
+
+ };
+ }
+ module.exports = { main };
+
+ GH_AW_SAFE_OUTPUT_SCRIPT_SFL_REVIEW_INVENTORY_1fc424916c2b1bb4_EOF
- name: Process Safe Outputs
id: process_safe_outputs
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
@@ -1766,7 +2260,8 @@ jobs:
GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,github.com,host.docker.internal,openrouter.ai,raw.githubusercontent.com,registry.npmjs.org,telemetry.enterprise.githubcopilot.com"
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_API_URL: ${{ github.api_url }}
- GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_check_run\":{\"max\":1,\"name\":\"SFL Reviewer Approval\"},\"create_pull_request_review_comment\":{\"commit_id\":\"${{ github.event.pull_request.head.sha }}\",\"max\":20,\"side\":\"RIGHT\"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{},\"submit_pull_request_review\":{\"allowed_events\":[\"APPROVE\",\"REQUEST_CHANGES\"],\"commit_id\":\"${{ github.event.pull_request.head.sha }}\",\"footer\":\"always\",\"max\":1,\"supersede_older_reviews\":true}}"
+ GH_AW_SAFE_OUTPUT_SCRIPTS: "{\"sfl_review_inventory\":\"safe_output_script_sfl_review_inventory.cjs\"}"
+ GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_check_run\":{\"max\":1,\"name\":\"SFL Reviewer Approval\"},\"create_pull_request_review_comment\":{\"commit_id\":\"${{ github.event.pull_request.head.sha }}\",\"max\":20,\"side\":\"RIGHT\"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"report_incomplete\":{},\"submit_pull_request_review\":{\"allowed_events\":[\"APPROVE\",\"REQUEST_CHANGES\"],\"commit_id\":\"${{ github.event.pull_request.head.sha }}\",\"footer\":\"always\",\"max\":1,\"supersede_older_reviews\":true}}"
with:
github-token: ${{ steps.safe-outputs-app-token.outputs.token }}
script: |
diff --git a/.github/workflows/sfl-pr-review.md b/.github/workflows/sfl-pr-review.md
index f66bd8b5..41fe6119 100644
--- a/.github/workflows/sfl-pr-review.md
+++ b/.github/workflows/sfl-pr-review.md
@@ -6,22 +6,42 @@ description: |
consolidated review, and publishes the SFL Reviewer Approval check.
on:
- # Fork pull requests are intentionally unsupported. gh-aw's repository-ID
- # safety gate skips them before activation, so no review/check is produced
- # and the trigger label remains for a maintainer to remove.
label_command:
name: sfl-review
events: [pull_request]
remove_label: true
-if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.id == github.repository_id
-
permissions:
contents: read
pull-requests: read
+post-steps:
+ - name: Require SFL review output
+ if: always()
+ shell: bash
+ run: |
+ node <<'NODE'
+ const fs = require('fs');
+ const path = '/tmp/gh-aw/agent_output.json';
+ if (!fs.existsSync(path)) {
+ throw new Error('SFL agent output file is missing');
+ }
+ const output = JSON.parse(fs.readFileSync(path, 'utf8'));
+ const items = Array.isArray(output.items) ? output.items : [];
+ const hasInventory = items.some(
+ (item) => item.type === 'sfl_review_inventory'
+ );
+ const hasNoop = items.some((item) => item.type === 'noop');
+ const hasMissingSignal = items.some(
+ (item) => item.type === 'missing_tool' || item.type === 'missing_data'
+ );
+ if (!hasInventory && !hasNoop && !hasMissingSignal) {
+ throw new Error(
+ 'SFL review emitted neither an inventory, noop, nor missing signal'
+ );
+ }
+ NODE
+
models:
default-ai-credits-pricing:
input: 3
@@ -51,48 +71,509 @@ tools:
safe-outputs:
threat-detection:
+ enabled: true
+ max-ai-credits: -1
post-steps:
- - name: Generate SFL App token for final head verification
- id: sfl-final-head-token
+ - name: Mint SFL validation token
+ id: sfl-validation-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.SFL_APP_CLIENT_ID }}
private-key: ${{ secrets.SFL_APP_PRIVATE_KEY }}
- owner: ${{ github.repository_owner }}
- repositories: ${{ github.event.repository.name }}
permission-pull-requests: read
- - name: Verify PR head before safe outputs
+ - name: Validate SFL review verdict
env:
- GH_TOKEN: ${{ steps.sfl-final-head-token.outputs.token }}
- EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }}
+ EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ EXPECTED_RUN_ID: ${{ github.run_id }}
+ GH_TOKEN: ${{ steps.sfl-validation-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- REPOSITORY: ${{ github.repository }}
+ shell: bash
run: |
- live_head="$(gh api "repos/${REPOSITORY}/pulls/${PR_NUMBER}" --jq '.head.sha')"
- if [[ "$live_head" != "$EXPECTED_HEAD" ]]; then
- echo "::error::PR head changed from ${EXPECTED_HEAD} to ${live_head}; suppressing stale SFL outputs"
- exit 1
- fi
+ # SFL_VERDICT_VALIDATOR_START
+ node <<'NODE'
+ const fs = require('fs');
+ const { execFileSync } = require('child_process');
+
+ const outputPath =
+ process.env.SFL_AGENT_OUTPUT_PATH ||
+ '/tmp/gh-aw/threat-detection/agent_output.json';
+ const expectedHead = process.env.EXPECTED_HEAD_SHA || '';
+ const expectedRunId = process.env.EXPECTED_RUN_ID || '';
+ const fail = (message) => {
+ console.error(`SFL verdict validation failed: ${message}`);
+ process.exit(1);
+ };
+
+ if (!fs.existsSync(outputPath)) {
+ fail(`agent output is missing: ${outputPath}`);
+ }
+
+ const output = JSON.parse(fs.readFileSync(outputPath, 'utf8'));
+ const items = Array.isArray(output.items) ? output.items : [];
+ const noops = items.filter((item) => item.type === 'noop');
+ const triggeringRepo = String(process.env.GITHUB_REPOSITORY || '');
+ const triggeringPr = Number(process.env.PR_NUMBER);
+ const targetFields = [
+ 'pull_request_number',
+ 'pr_number',
+ 'pr',
+ 'pull_number',
+ ];
+ for (const item of items) {
+ if (item.repo && item.repo !== triggeringRepo) {
+ fail(`output target repo must be ${triggeringRepo}`);
+ }
+ for (const field of targetFields) {
+ if (
+ item[field] !== undefined &&
+ Number(item[field]) !== triggeringPr
+ ) {
+ fail(`output target ${field} must be ${triggeringPr}`);
+ }
+ }
+ }
+
+ const loadPrState = () => {
+ if (process.env.SFL_PR_STATE_PATH) {
+ return JSON.parse(
+ fs.readFileSync(process.env.SFL_PR_STATE_PATH, 'utf8')
+ );
+ }
+ const [owner, repo] = String(
+ process.env.GITHUB_REPOSITORY || ''
+ ).split('/');
+ const number = process.env.PR_NUMBER || '';
+ if (!owner || !repo || !number || !process.env.GH_TOKEN) {
+ fail('GitHub context for deterministic PR validation is incomplete');
+ }
+ const query = [
+ 'query($owner:String!,$repo:String!,$number:Int!,$after:String){',
+ 'repository(owner:$owner,name:$repo){',
+ 'pullRequest(number:$number){headRefOid reviewThreads(first:100,after:$after){',
+ 'nodes{isResolved comments(first:1){nodes{body author{login}}}} ',
+ 'pageInfo{hasNextPage endCursor}',
+ '}}}}',
+ ].join('');
+ const nodes = [];
+ let after = null;
+ let headRefOid = '';
+ try {
+ do {
+ const args = [
+ 'api',
+ 'graphql',
+ '-f',
+ `query=${query}`,
+ '-F',
+ `owner=${owner}`,
+ '-F',
+ `repo=${repo}`,
+ '-F',
+ `number=${number}`,
+ ];
+ if (after) {
+ args.push('-f', `after=${after}`);
+ }
+ const raw = execFileSync('gh', args, {
+ encoding: 'utf8',
+ env: process.env,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ });
+ const response = JSON.parse(raw);
+ if (
+ Array.isArray(response.errors) &&
+ response.errors.length > 0
+ ) {
+ fail(
+ `GitHub GraphQL returned errors: ` +
+ response.errors
+ .map((error) => error.message || 'unknown error')
+ .join('; ')
+ );
+ }
+ const pullRequest = response?.data?.repository?.pullRequest;
+ if (!pullRequest?.headRefOid) {
+ fail('GitHub returned no pull request state');
+ }
+ const reviewThreads = pullRequest.reviewThreads;
+ if (
+ !Array.isArray(reviewThreads?.nodes) ||
+ typeof reviewThreads?.pageInfo?.hasNextPage !== 'boolean' ||
+ (reviewThreads.pageInfo.hasNextPage &&
+ !reviewThreads.pageInfo.endCursor)
+ ) {
+ fail('GitHub returned incomplete review-thread data');
+ }
+ headRefOid = pullRequest.headRefOid;
+ nodes.push(...reviewThreads.nodes);
+ after = reviewThreads.pageInfo.hasNextPage
+ ? reviewThreads.pageInfo.endCursor
+ : null;
+ } while (after);
+ return { headRefOid, reviewThreads: { nodes } };
+ } catch (error) {
+ fail(`unable to query live pull request state: ${error.message}`);
+ }
+ };
+
+ const prState = loadPrState();
+ const liveHead = prState.headRefOid;
+ if (liveHead !== expectedHead) {
+ if (noops.length !== 1 || items.length !== 1) {
+ fail('head drift requires exactly one noop output');
+ }
+ console.log('SFL verdict validation passed: verified head drift');
+ process.exit(0);
+ }
+ if (noops.length > 0) {
+ fail('noop is forbidden while the pull request head is unchanged');
+ }
+
+ const allowedTypes = new Set([
+ 'sfl_review_inventory',
+ 'create_pull_request_review_comment',
+ 'submit_pull_request_review',
+ 'create_check_run',
+ 'missing_tool',
+ 'missing_data',
+ ]);
+ const unexpectedTypes = [
+ ...new Set(
+ items
+ .map((item) => item.type)
+ .filter((type) => !allowedTypes.has(type))
+ ),
+ ];
+ if (unexpectedTypes.length > 0) {
+ fail(
+ `unexpected safe output types: ${unexpectedTypes.join(', ')}`
+ );
+ }
+
+ const missingSignals = items.filter(
+ (item) => item.type === 'missing_tool' || item.type === 'missing_data'
+ );
+ if (missingSignals.length > 0) {
+ if (missingSignals.length !== 1 || items.length !== 1) {
+ fail('a missing signal must be the only safe output item');
+ }
+ console.log('SFL verdict validation passed: terminal missing signal');
+ process.exit(0);
+ }
+
+ const inventories = items.filter(
+ (item) => item.type === 'sfl_review_inventory'
+ );
+ if (inventories.length !== 1) {
+ fail('exactly one sfl_review_inventory output is required');
+ }
+
+ const inventory = inventories[0];
+ const countFields = [
+ 'new_critical',
+ 'new_high',
+ 'new_medium',
+ 'new_low',
+ 'carried_critical',
+ 'carried_high',
+ 'carried_medium',
+ 'carried_low',
+ 'overflow',
+ ];
+ for (const field of countFields) {
+ if (
+ !Number.isInteger(inventory[field]) ||
+ inventory[field] < 0
+ ) {
+ fail(`${field} must be a non-negative integer`);
+ }
+ }
+ if (!expectedHead || inventory.head_sha !== expectedHead) {
+ fail('inventory head_sha does not match the triggering PR head');
+ }
+
+ const severityOrder = ['critical', 'high', 'medium', 'low'];
+ const prefixes = {
+ critical: '**CRITICAL Finding**',
+ high: '**HIGH Finding**',
+ medium: '**MEDIUM Finding**',
+ low: '**LOW Finding**',
+ };
+ const comments = items.filter(
+ (item) => item.type === 'create_pull_request_review_comment'
+ );
+ const emitted = Object.fromEntries(
+ severityOrder.map((severity) => [severity, 0])
+ );
+ for (const comment of comments) {
+ const severity = severityOrder.find((candidate) =>
+ String(comment.body || '').startsWith(prefixes[candidate])
+ );
+ if (!severity) {
+ fail('every inline review comment must use an SFL severity prefix');
+ }
+ emitted[severity]++;
+ }
+
+ const newlyFound = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ inventory[`new_${severity}`],
+ ])
+ );
+ const carried = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ inventory[`carried_${severity}`],
+ ])
+ );
+ const actualCarried = Object.fromEntries(
+ severityOrder.map((severity) => [severity, 0])
+ );
+ for (const thread of prState.reviewThreads?.nodes || []) {
+ if (thread.isResolved) {
+ continue;
+ }
+ const firstComment = thread.comments?.nodes?.[0];
+ const author = String(firstComment?.author?.login || '');
+ if (author !== 'sfl-app[bot]') {
+ continue;
+ }
+ const severity = severityOrder.find((candidate) =>
+ String(firstComment?.body || '').startsWith(prefixes[candidate])
+ );
+ if (severity) {
+ actualCarried[severity]++;
+ }
+ }
+ for (const severity of severityOrder) {
+ if (carried[severity] !== actualCarried[severity]) {
+ fail(
+ `${severity} carried count must be ` +
+ `${actualCarried[severity]}, got ${carried[severity]}`
+ );
+ }
+ }
+ const newTotal = Object.values(newlyFound).reduce(
+ (sum, count) => sum + count,
+ 0
+ );
+ const expectedOverflow = Math.max(0, newTotal - 20);
+ if (inventory.overflow !== expectedOverflow) {
+ fail(
+ `overflow must be ${expectedOverflow}, got ${inventory.overflow}`
+ );
+ }
+
+ let remaining = Math.min(newTotal, 20);
+ const expectedEmitted = {};
+ for (const severity of severityOrder) {
+ expectedEmitted[severity] = Math.min(
+ newlyFound[severity],
+ remaining
+ );
+ remaining -= expectedEmitted[severity];
+ }
+ for (const severity of severityOrder) {
+ if (emitted[severity] !== expectedEmitted[severity]) {
+ fail(
+ `${severity} emitted count must be ` +
+ `${expectedEmitted[severity]}, got ${emitted[severity]}`
+ );
+ }
+ }
+
+ const reviews = items.filter(
+ (item) => item.type === 'submit_pull_request_review'
+ );
+ const checks = items.filter(
+ (item) => item.type === 'create_check_run'
+ );
+ if (reviews.length !== 1 || checks.length !== 1) {
+ fail('exactly one consolidated review and one check run are required');
+ }
+
+ const blockingFindings =
+ newlyFound.critical +
+ carried.critical +
+ newlyFound.high +
+ carried.high >
+ 0;
+ const blocking = blockingFindings || inventory.overflow > 0;
+ const expectedEvent = blocking ? 'REQUEST_CHANGES' : 'APPROVE';
+ const expectedConclusion = blocking ? 'failure' : 'success';
+ const expectedVerdict = blocking ? 'CHANGES_REQUESTED' : 'APPROVE';
+ const actualEvent = String(reviews[0].event || '').toUpperCase();
+ const actualConclusion = String(
+ checks[0].conclusion || ''
+ ).toLowerCase();
+
+ if (actualEvent !== expectedEvent) {
+ fail(
+ `review event must be ${expectedEvent}, got ${actualEvent || 'empty'}`
+ );
+ }
+ if (actualConclusion !== expectedConclusion) {
+ fail(
+ `check conclusion must be ${expectedConclusion}, got ` +
+ `${actualConclusion || 'empty'}`
+ );
+ }
+ if (checks[0].title !== 'SFL full-spectrum review complete') {
+ fail(
+ 'check title must be SFL full-spectrum review complete'
+ );
+ }
+
+ const totals = Object.fromEntries(
+ severityOrder.map((severity) => [
+ severity,
+ newlyFound[severity] + carried[severity],
+ ])
+ );
+ const reviewBody = String(reviews[0].body || '');
+ const reviewLines = reviewBody
+ .split(/\r?\n/)
+ .map((line) => line.trim());
+ const requireSingleReviewLine = (prefix, expected) => {
+ const matches = reviewLines.filter((line) =>
+ line.startsWith(prefix)
+ );
+ if (matches.length !== 1 || matches[0] !== expected) {
+ fail(`consolidated review must contain exactly: ${expected}`);
+ }
+ };
+ requireSingleReviewLine(
+ 'SFL run ID:',
+ `SFL run ID: ${expectedRunId}`
+ );
+ requireSingleReviewLine('Head SHA:', `Head SHA: ${expectedHead}`);
+ requireSingleReviewLine(
+ 'Verdict:',
+ `Verdict: ${expectedVerdict}`
+ );
+ if (!expectedRunId) {
+ fail('workflow run ID is unavailable');
+ }
+ const expectedRows = {
+ Critical: totals.critical,
+ High: totals.high,
+ Medium: totals.medium,
+ Low: totals.low,
+ Overflow: inventory.overflow,
+ };
+ for (const [label, expectedCount] of Object.entries(expectedRows)) {
+ const rowPattern = new RegExp(
+ `^\\|\\s*${label}\\s*\\|\\s*(\\d+)\\s*\\|$`
+ );
+ const matches = reviewLines
+ .map((line) => line.match(rowPattern))
+ .filter(Boolean);
+ if (
+ matches.length !== 1 ||
+ Number(matches[0][1]) !== expectedCount
+ ) {
+ fail(
+ `consolidated review must contain one ${label} row with ` +
+ `${expectedCount}`
+ );
+ }
+ }
+
+ const checkSummary = String(checks[0].summary || '');
+ const checkLines = checkSummary
+ .split(/\r?\n/)
+ .map((line) => line.trim())
+ .filter(Boolean);
+ const requiredCheckFragments = [
+ `Verdict: ${expectedVerdict}`,
+ `Head SHA: ${expectedHead}`,
+ `SFL run ID: ${expectedRunId}`,
+ `Critical: ${totals.critical}`,
+ `High: ${totals.high}`,
+ `Medium: ${totals.medium}`,
+ `Low: ${totals.low}`,
+ `Overflow: ${inventory.overflow}`,
+ ];
+ if (
+ JSON.stringify(checkLines) !==
+ JSON.stringify(requiredCheckFragments)
+ ) {
+ fail('check summary does not match the required exact shape');
+ }
+
+ console.log('SFL verdict validation passed');
+ // SFL_VERDICT_VALIDATOR_END
+ NODE
+ # Repository-owner-approved exception: shared SFL writes intentionally use
+ # sfl-app[bot] so the reviewer has consistent attribution across HemSoft repos.
github-app:
client-id: ${{ vars.SFL_APP_CLIENT_ID }}
private-key: ${{ secrets.SFL_APP_PRIVATE_KEY }}
+ scripts:
+ sfl-review-inventory:
+ description: Record the complete SFL finding inventory for deterministic verdict validation.
+ inputs:
+ head_sha:
+ description: Triggering pull request head SHA.
+ required: true
+ type: string
+ new_critical:
+ description: Newly identified Critical findings.
+ required: true
+ type: number
+ new_high:
+ description: Newly identified High findings.
+ required: true
+ type: number
+ new_medium:
+ description: Newly identified Medium findings.
+ required: true
+ type: number
+ new_low:
+ description: Newly identified Low findings.
+ required: true
+ type: number
+ carried_critical:
+ description: Unresolved Critical findings carried from earlier SFL runs.
+ required: true
+ type: number
+ carried_high:
+ description: Unresolved High findings carried from earlier SFL runs.
+ required: true
+ type: number
+ carried_medium:
+ description: Unresolved Medium findings carried from earlier SFL runs.
+ required: true
+ type: number
+ carried_low:
+ description: Unresolved Low findings carried from earlier SFL runs.
+ required: true
+ type: number
+ overflow:
+ description: Newly identified findings omitted after the 20-comment cap.
+ required: true
+ type: number
+ script: |
+ return { success: true };
create-pull-request-review-comment:
- commit-id: ${{ github.event.pull_request.head.sha }}
- side: RIGHT
max: 20
+ commit-id: ${{ github.event.pull_request.head.sha }}
submit-pull-request-review:
allowed-events: [APPROVE, REQUEST_CHANGES]
- commit-id: ${{ github.event.pull_request.head.sha }}
supersede-older-reviews: true
footer: always
+ commit-id: ${{ github.event.pull_request.head.sha }}
create-check-run:
max: 1
name: "SFL Reviewer Approval"
+ noop:
+ report-as-issue: false
---
-
@@ -128,14 +604,15 @@ must be `${{ github.event.pull_request.head.sha }}` and the SFL run ID is
Use the GitHub pull request tools to read the triggering PR, its changed files,
and the complete diff. Before creating comments, list existing review comments
-and unresolved threads on the current head. Re-evaluate every unresolved SFL
-finding against the current head. The finding set for this run is the union of
-new findings and still-applicable unresolved SFL findings. Do not duplicate an
-existing finding's inline comment, but keep that finding in the current run's
-severity counts and verdict. Exclude resolved findings and findings that are no
-longer applicable to the current head. An existing SFL finding is an unresolved
-inline review comment authored by the SFL reviewer whose body starts with one of
-the exact severity prefixes below.
+and unresolved threads from every SFL review run whose comment begins with an
+exact SFL severity prefix, so you do not repeat a finding and can carry
+unresolved findings into the current verdict.
+
+Immediately before producing any safe output, fetch the pull request again and
+compare its current head SHA with `${{ github.event.pull_request.head.sha }}`.
+If they differ, emit no review comments, review, or check run. Call `noop` with
+the stale-head reason and stop. The safe-output handlers pin review comments
+and the consolidated review to the triggering SHA as a second fail-closed guard.
## Required review passes
@@ -168,28 +645,9 @@ Classify every finding into exactly one severity:
Do not report style preferences, speculative concerns, or findings without
specific evidence from the changed code.
-## Current-head gate
-
-Immediately before producing any safe output, re-read the triggering pull
-request with the GitHub pull request tools. Compare its live head SHA with
-`${{ github.event.pull_request.head.sha }}`. Do not rely on an earlier PR read
-for this comparison.
-
-If the SHAs differ, do not create inline comments and do not submit a review.
-Call only `create_check_run` with conclusion `failure`, title
-`SFL review canceled: PR head changed`, and a summary containing the reviewed
-SHA, live SHA, run ID, and an instruction to reapply the `sfl-review` label.
-Then stop. This stale-head result takes precedence over the approval policy.
-
-The review and its inline comments are also infrastructure-pinned to
-`${{ github.event.pull_request.head.sha }}`. Never target a later commit. The
-approval check uses the triggering pull request event's head SHA, so a newer
-head must receive its own SFL run and check. A final fail-closed head comparison
-runs after threat detection and prevents stale safe outputs from being published.
-
For each finding, call `create_pull_request_review_comment` on the most precise
-changed line. Set `side` to `RIGHT` for an added or context line and `LEFT` for
-a deleted line. The comment body must begin with one of these exact prefixes:
+changed line. Set `side` to `LEFT` for a deleted line and `RIGHT` for an added
+or context line. The comment body must begin with one of these exact prefixes:
- `**CRITICAL Finding**`
- `**HIGH Finding**`
@@ -197,39 +655,54 @@ a deleted line. The comment body must begin with one of these exact prefixes:
- `**LOW Finding**`
After the prefix, state the defect, impact, evidence, and a concrete fix.
-Create exactly one inline thread per new finding. Do not create another thread
-for a still-applicable existing finding. If there are no new findings, create no
-inline comments.
+Create exactly one inline thread per finding. If there are no findings, create
+no inline comments.
+
+Build the complete finding inventory before emitting comments. At most 20
+inline comments can be published. If more than 20 findings exist, publish the
+20 highest-severity findings, report the overflow count in the consolidated
+review, and force `REQUEST_CHANGES` with a failing approval check. Never approve
+a review whose complete finding inventory exceeded the inline-comment limit.
+
+Before emitting the consolidated review or check, call
+`sfl_review_inventory` exactly once with the triggering head SHA; the complete
+new and carried counts for every severity; and the number of newly identified
+findings omitted by the 20-comment cap. The deterministic validation step
+checks this inventory against the emitted inline comments, review event, and
+check conclusion. Any mismatch blocks all safe outputs.
## Approval policy
-Count the complete current-run finding set by severity, including every
-still-applicable unresolved SFL finding even when its existing thread was not
-duplicated during this run.
+Count all newly identified findings plus unresolved SFL findings from earlier
+runs by severity. Do not duplicate an unresolved finding as a new inline
+comment, but carry it into the current counts and verdict until its GitHub
+review thread is resolved.
-- If any Critical or High finding exists, submit `REQUEST_CHANGES` and create
- the `SFL Reviewer Approval` check with conclusion `failure`.
-- If only Medium or Low findings exist, submit `APPROVE` and create the check
- with conclusion `success`.
+- If any Critical or High finding remains unresolved, or the complete finding
+ inventory exceeded 20 comments, submit `REQUEST_CHANGES` and create the
+ `SFL Reviewer Approval` check with conclusion `failure`.
+- If only Medium or Low findings exist and the complete finding inventory did
+ not exceed 20 comments, submit `APPROVE` and create the check with conclusion
+ `success`.
- If no findings exist, submit `APPROVE` and create the check with conclusion
`success`.
-Call `submit_pull_request_review` exactly once. Use this body and replace every
-`<...>` placeholder with the actual value:
+Submit exactly one consolidated review with this body:
```markdown
## SFL Full-Spectrum Review
SFL run ID: ${{ github.run_id }}
Head SHA: ${{ github.event.pull_request.head.sha }}
-Verdict:
+Verdict: APPROVE
| Severity | Count |
| --- | ---: |
-| Critical | |
-| High | |
-| Medium | |
-| Low | |
+| Critical | 0 |
+| High | 0 |
+| Medium | 0 |
+| Low | 0 |
+| Overflow | 0 |
### Review passes
@@ -242,13 +715,22 @@ Verdict:
Concise evidence-based summary of the review result.
```
-Use `Verdict: CHANGES_REQUESTED` when Critical or High findings exist.
+Replace the verdict and counts with the actual result. Use
+`Verdict: CHANGES_REQUESTED` when Critical or High findings exist or the
+complete finding inventory exceeded 20 comments.
-Call `create_check_run` exactly once for the check named
-`SFL Reviewer Approval` with:
+Create exactly one check run named `SFL Reviewer Approval` with:
- `title`: `SFL full-spectrum review complete`
-- `summary`: the verdict, head SHA, run ID, and severity counts
+- `summary`: exactly these lines with actual values:
+ - `Verdict: APPROVE`
+ - `Head SHA: ${{ github.event.pull_request.head.sha }}`
+ - `SFL run ID: ${{ github.run_id }}`
+ - `Critical: 0`
+ - `High: 0`
+ - `Medium: 0`
+ - `Low: 0`
+ - `Overflow: 0`
- `conclusion`: the approval-policy result above
Do not modify code, branches, pull request labels, or pull request metadata.
diff --git a/README.md b/README.md
index 3d5f7b99..32531451 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# gh-x
-[](https://github.com/HemSoft/set-it-free-loop)
+[](https://github.com/HemSoft/set-it-free-loop)
A GitHub CLI extension that supercharges `gh pr list` with a richer,
diff --git a/sfl.json b/sfl.json
index 4f9b88cb..a9a026fd 100644
--- a/sfl.json
+++ b/sfl.json
@@ -1,9 +1,9 @@
{
"version": "2.0.0",
- "deployedAt": "2026-08-02T03:45:00Z",
+ "deployedAt": "2026-08-03T06:10:10Z",
"tier": "review",
"source": "HemSoft/set-it-free-loop",
- "sourceSha": "78483bbf7edf0a4f8d3bf2f68e58678da36044ae",
+ "sourceSha": "e9c9c745c166bf04e48b34da95adb29a5d67c2ac",
"components": [
"governance",
"labels",