Reconcile agent coverage #343
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Reconcile agent coverage | |
| on: | |
| schedule: | |
| - cron: "*/5 * * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: policypool-agent-coverage-reconciler | |
| cancel-in-progress: false | |
| jobs: | |
| reconcile: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 3 | |
| steps: | |
| - name: Reconcile objective job states | |
| env: | |
| POLICYPOOL_OPERATOR_TOKEN: ${{ secrets.POLICYPOOL_OPERATOR_TOKEN }} | |
| run: | | |
| test -n "$POLICYPOOL_OPERATOR_TOKEN" | |
| curl --fail-with-body --silent --show-error \ | |
| --retry 3 \ | |
| --retry-all-errors \ | |
| --retry-delay 5 \ | |
| --request POST \ | |
| --header "Authorization: Bearer $POLICYPOOL_OPERATOR_TOKEN" \ | |
| https://policypool.vercel.app/api/reconcile-coverage | |
| - name: Reconcile direct A2MCP executions when enabled | |
| if: ${{ always() }} | |
| env: | |
| POLICYPOOL_OPERATOR_TOKEN: ${{ secrets.POLICYPOOL_OPERATOR_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| test -n "$POLICYPOOL_OPERATOR_TOKEN" | |
| discovery_file="$(mktemp)" | |
| trap 'rm -f "$discovery_file"' EXIT | |
| http_status="$(curl --silent --show-error \ | |
| --output "$discovery_file" \ | |
| --write-out "%{http_code}" \ | |
| --retry 3 \ | |
| --retry-all-errors \ | |
| --retry-delay 5 \ | |
| https://policypool.vercel.app/api/direct-a2mcp)" | |
| if [[ "$http_status" == "404" ]]; then | |
| echo "Direct A2MCP route is not deployed; reconciliation is disabled." | |
| exit 0 | |
| fi | |
| if [[ "$http_status" != "200" ]]; then | |
| echo "Direct A2MCP discovery returned unexpected HTTP $http_status." >&2 | |
| exit 1 | |
| fi | |
| enabled="$(python3 -c 'import json,sys; print("true" if json.load(sys.stdin).get("enabled") is True else "false")' <"$discovery_file")" | |
| if [[ "$enabled" != "true" ]]; then | |
| echo "Direct A2MCP reconciliation is disabled; no action required." | |
| exit 0 | |
| fi | |
| curl --fail-with-body --silent --show-error \ | |
| --retry 3 \ | |
| --retry-all-errors \ | |
| --retry-delay 5 \ | |
| --request POST \ | |
| --header "Authorization: Bearer $POLICYPOOL_OPERATOR_TOKEN" \ | |
| https://policypool.vercel.app/api/reconcile-direct-a2mcp |