name: Publish agent state rules # Maintainer-only publisher: dispatch main to next, soak, then promote identical bytes to stable. All jobs use the dispatched commit. Use GITHUB_TOKEN so release-policy accepts bot-authored prereleases; token-created releases do not trigger workflows until manual edits. on: workflow_dispatch: inputs: action: description: 'publish-next builds from main and publishes to next; promote-stable copies the next file to stable' required: true type: choice options: - publish-next - promote-stable bundled_only: description: 'publish-next: tell apps to fall back to the rules they shipped with; promote-stable then carries it to stable' required: false type: boolean default: false permissions: contents: read concurrency: group: agent-state-rules-publish cancel-in-progress: false jobs: gate: if: github.ref == 'refs/heads/main' && inputs.action == 'publish-next' runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: ./.github/actions/install-node-dependencies with: native-runtime: node - name: Run the rules gate (schema, regex safety, the bundle, every transcript replay) shell: bash run: | set -euo pipefail mapfile -t gate_files < <(git ls-files \ ':(glob)src/main/runtime/agent-state-rules/**/*.test.ts' \ ':(glob)src/main/runtime/readiness-census*.test.ts' \ ':(glob)src/main/runtime/*transcript.test.ts' \ ':(glob)src/main/runtime/*transcripts.test.ts' \ config/scripts/release/agent-state-rules/agent-state-rules-bundle.test.mjs) pnpm exec vitest run --config config/vitest.config.ts "${gate_files[@]}" publish-next: needs: gate runs-on: ubuntu-latest timeout-minutes: 10 environment: agent-state-rules permissions: contents: write steps: - uses: actions/checkout@v6 with: persist-credentials: false - name: Publish to next env: GH_TOKEN: ${{ github.token }} BUNDLED_ONLY: ${{ inputs.bundled_only }} shell: bash run: | set -euo pipefail flags=() [[ "$BUNDLED_ONLY" == "true" ]] && flags+=(--bundled-only) node config/scripts/release/agent-state-rules/agent-state-rules-bundle.mjs publish-next "${flags[@]}" promote-stable: if: github.ref == 'refs/heads/main' && inputs.action == 'promote-stable' runs-on: ubuntu-latest timeout-minutes: 10 environment: agent-state-rules permissions: contents: write steps: - uses: actions/checkout@v6 with: persist-credentials: false - name: Copy the next file to stable env: GH_TOKEN: ${{ github.token }} run: node config/scripts/release/agent-state-rules/agent-state-rules-bundle.mjs promote-stable