[gh-aw] Harden the provider-health record's trust boundary with a host record job

Merged
DS
24d ago
+1668-83

This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.

Why we make these changes

This hardens the provider-health record's trust boundary for the Z.AI agentic workflows:

  • A new provider_health_record job runs after the agent job, including a failed one. It checks out the default-branch controller, reads the engine's terminal session.result from this run's agent artifact, and adds run-result.json to the provider-health artifact. Only its record step holds ZAI_API_KEY: gh-aw v1.2.1 allows no secret in post-steps, so this is a job, not a post-step.
  • A provider-scope incident (rejected credential, HTTP 401/403, or plan_limit) opens only when that job's own Z.ai check observes the failure. Otherwise the incident stays scoped to the workflow or task. Typed failures stay typed, and rate_limit is unchanged.
  • The monitor prefers the host record and falls back to the agent artifact, which never confirms a provider failure. It accepts records from same-repository runs only.
  • agentic_workflow_guard.py requires the record job in every Z.AI lock. All 12 locks are recompiled with gh-aw v1.2.1, main's compiler version.

New public surface

None. Every change is under .github/.

User-visible behavior

 .github/workflows/agent-provider-health.yml :: monitor
 └─ .github/scripts/agent_provider_health.py :: _monitor_command()
+   ├─ .github/scripts/agent_provider_health.py :: _host_run_result(provider-health/run-result.json)   # written by `record`
    ├─ .github/scripts/agent_provider_health.py :: parse_run_result(agent artifact)                     # fallback; never confirms
    └─ .github/scripts/agent_provider_health.py :: _scope_for(result)
-      └─ provider scope for authentication / 401 / 403 / plan_limit
+      └─ provider scope only if result.provider_confirmed (host Z.ai check); else workflow/task scope

Verification

What changes for existing users

Nothing. Only this repository's agentic workflows change.

PR decisions

2026-11-06 · host check confirms only what it observes

  • Decision: A credential failure is confirmed only by the host check's own HTTP 401 or 403; a plan limit only by exhausted quota. Unreadable quota confirms neither.
  • Why: The host step attests its own observation; unreadable quota already blocks the next gate and opens a quota_unknown incident there.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-06 · agent artifact fallback never confirms

  • Decision: The monitor prefers the host record and falls back to the agent artifact, which types the failure but never confirms a provider.
  • Why: Runs compiled before the host step keep typed failures typed instead of becoming untyped stage incidents.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-06 · scoped Bash checked in the shim, not by ShellToolset (dropped on 2026-11-08 below)

  • Decision: Scoped Bash(...) grants become token prefixes checked per pipeline/list segment in bash.scoped_bash; plain Bash keeps the unrestricted shell.
  • Why: ShellToolset.allowed_commands checks only the first token, so a scoped python3 grant would still allow any python3 command.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · pre-push review 1 of 3 at 797dbcf23e

  • Decision: remediated in e0cbda9fa7: guard requires always() on both host steps; inert record-step timeout dropped; unconfirmed reason true on both record sources; AGENTS.md fallback sentence fixed; past-state comment fixed; fixture labelled a subset; tests for invalid host records and command-less Bash grants
  • Why: 9 findings: 7 fixed; commit-history rewrite skipped (dispatch chose a follow-up commit; a merge commit sits on top); the CE Audit grant went to the manager (next entry).
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · Bash scopes taken as the source declares them (superseded below)

  • Decision: A scoped grant allows exactly the source's declared prefixes; narrowing Weekly CE Audit's git * grant is a workflow-source change, pending David's call.
  • Why: The ruling restored the scoped allowlist and kept plain Bash unchanged; changing a source's grant widens the PR.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · CE Audit git grant narrowed in a follow-up PR, not here

  • Decision: Manager: keep this PR as is; narrowing Weekly CE Audit's git * source grant gets its own follow-up PR.
  • Why: Narrowing it changes CE Audit's behavior, outside this fix.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · pre-push review 2 of 3 at 3735bb45ec

  • Decision: remediated in c357b3f693: guard rejects a negated always() on either host step; host record requires an integer version; tests for both. Dismissed: renaming the agent-written-result test.
  • Why: 3 findings: 2 fixed; the rename is dismissed because the maintainer's wording rule gives that test wording as permitted.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · pre-push review 3 of 3 at c357b3f693

  • Decision: remediated in 89f8eaebe1: guard compares each host step's if: with the exact always() && recheck-ready condition (whitespace-normalized, as the stop-step check does); negated-group rejection case added. Budget exhausted: no fourth review.
  • Why: 1 finding: the always() regex still accepted a parenthesised negation; exact-match follows the guard's own precedent.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · scoped Bash split by a quote-aware scanner (dropped on 2026-11-08 below)

  • Decision: _simple_commands follows the shell's quotes and backslashes to split at |, ||, && and ;, then shlex.split checks each command's words; $'...' strings are refused. Supersedes the shlex punctuation lexer.
  • Why: Macroscope: the lexer read a quoted lone operator as a separator and refused in-scope commands such as grep '|'.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · post-review push without a fourth local review

  • Decision: Pushed bb24b5eed5 with targeted checks only (shim tests, pyright, ruff); CI and douwebot review it.
  • Why: Pre-push budget is exhausted (3 of 3); the push skill continues with CI and hosted review after the third review.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · stopped on the second regression

  • Decision: Macroscope's git status; finding (empty command after a trailing ; fails the scope check) was the second regression; reported to the manager before fixing.
  • Why: Lifecycle rule: fix the first regression any review finds; on the second, stop and report.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · regression 2 fixed after the review budget

  • Decision: Manager: fix here. 87fc5f21d8 drops the empty segment a trailing ; leaves; empty operands after |, && and || stay refused. Pushed after targeted checks (shim tests, pyright, ruff); no fourth local review.
  • Why: Pre-push budget is spent (3 of 3); CI and douwebot review the push.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · no additional review surface

  • Decision: David chose none after the merge bar was met on 87fc5f21d8 (CI green, douwebot APPROVE, Macroscope APPROVE).
  • Why: Both hosted reviewers approved the exact head after three local reviews; hosted surfaces post publicly.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-07 · final metadata check

  • Decision: Kept: 'Call path' heading renamed 'User-visible behavior'; 'no additional review surface' mirrored. Skipped: rewording the title, the scoped-shell bullet and a test-link label to the exact settled phrases.
  • Why: The skipped corrections cite a maintainer wording rule, not the push skill, AGENTS.md or the template.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-08 · #10347 merged first; merge main and drop the shim Bash scoping

  • Decision: David chose #10347 first (merged as 351ebead42). This PR merges upstream/main, keeps its host provider-health record, drops the shim Bash scoping, and recompiles the locks with main's gh-aw v1.2.1.
  • Why: After #10347 no workflow runs the legacy shim; Weekly CE Audit declares a full shell; gh-aw v1.2.1 rejects bash command lists for the pydantic-ai engine.
  • Session: 4856ffbc-4e48-491c-995b-0b6f2b036e0a

2026-11-08 · host record reads the engine's session.result

  • Decision: The record reads /tmp/gh-aw/agent-session.jsonl (was agent-stdio.log); provider confirmation still comes only from the host's own Z.ai check.
  • Why: After #10347 the engine's provider-health metadata lives only in the parser-written session.result. Verified on real released-AWF output (run 42511053555): success and rate_limit sessions record with matching identity; a mismatched identity records none.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-08 · merge upstream/main (#10347, #12818)

  • Decision: 9f47d9e659 merges upstream/main taking main's locks; 137a0a01ac restores main's shim files.
  • Why: Applies the previous decision: the engine builds its own shell, so no workflow runs the shim's scoped Bash.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-08 · gh-aw v1.2.1 compile blocked

  • Decision: Locks not compiled or pushed: this session could not run the gh-aw v1.2.1 binary; only older versions were available.
  • Why: Locks must be built with main's gh-aw v1.2.1 (.github/workflows/AGENTS.md).
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-08 · pre-push gate on the merge-resolution delta

  • Decision: Non-exempt delta; the 3-review budget is spent, so no fourth budgeted review: push after targeted checks once the locks are recompiled; CI and douwebot review it.
  • Why: Push skill: budget exhaustion is one of the ways a pushed SHA can go un-reviewed.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · gh-aw v1.2.1 rejects secrets in post-steps (superseded below)

  • Decision: Design question to David: gh-aw v1.2.1 rejects ZAI_API_KEY in the record post-step, so no lock compiles. Options: a separate host job after agent (recommended), a monitor-side Z.ai check, or no provider scope from agent runs.
  • Why: Every secret-free option moves where the Z.ai confirmation runs.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · Z.ai confirmation moves to a separate host job

  • Decision: David chose a new provider_health_record job after agent: it holds ZAI_API_KEY, downloads the agent artifact, runs record with its own Z.ai check and uploads run-result.json into provider-health. What the record proves is unchanged; only where it runs moves. One extra job per run accepted.
  • Why: gh-aw v1.2.1 rejects secrets in post-steps ('secrets are not allowed in post-steps'); the alternatives gave the monitor's completion path the key or dropped agent-run provider scope.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · author-requested review at 2acc0d20d8 (outside the 3-review budget)

  • Decision: Strong-tier fresh reviewer, full branch. 3 findings, all fixed: the guard also rejects a secret in the record job's job-level env; .github/workflows/AGENTS.md keeps one owner for where ZAI_API_KEY may live; the fallback sentence lists its causes.
  • Why: Substantive redesign after two upstream merges; the push skill does not count a review the author asks for.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · record job stays behind gh-aw's detection gate

  • Decision: David accepted: provider_health_record runs only after clean threat detection (gh-aw v1.2.1, ADR-70997). When detection fails after the agent produced output, the record is skipped; that run opens a workflow or task incident, and the next gate check opens a provider incident if the provider is down.
  • Why: The detection-gate opt-out forbids artifact downloads; detection skips its model when the agent left no output or patch, which covers the usual first-request credential or quota failure.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · push of 43714d2 authorized after validation

  • Decision: David authorized pushing 43714d274b once the manager's validator cleared it.
  • Why: The pre-push review budget was spent; the author-requested review's findings were fixed, and the validator was the remaining gate.
  • Session: cfc70fa1-2941-4539-9100-ef5641f7de05

2026-11-09 · validator on 43714d274b: not cleared

  • Decision: Required before the push: merge upstream/main and recompile with gh-aw v1.2.1; the monitor accepts records from same-repository runs only; tighter guard checks on the record job; wording fixes.
  • Why: The manager's validator review is internal.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · lock count is 13, not 14

  • Decision: From 2acc0d20d8 on there are 13 Z.AI locks: #12930 removed attention triage. Earlier entries' '14 locks' counted main before that merge.
  • Why: The decisions log is append-only.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · merge upstream/main with #12893 and #12894

  • Decision: b21fa1b8bc merges upstream/main 58d5894b2c: all 13 locks conflicted. Took main's locks and recompiled with gh-aw v1.2.1; .github/workflows/AGENTS.md keeps this branch's provider-health-* row and main's provider-engine-config row.
  • Why: After #12893 detection runs on OpenCode and makes no Z.ai call.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · same-repository records only

  • Decision: The monitor accepts records from same-repository runs only, for pull_request_review completions as for pull_request. The Dependabot exclusion stays on pull_request.
  • Why: CI Review is the only Z.AI workflow triggered by pull_request_review; none is triggered by pull_request_review_comment.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · ready for delta validation at bafa96c1da

  • Decision: Local, not pushed: merge b21fa1b8bc and fixes bafa96c1da. CI's .github/scripts tests on Python 3.13, the guard check, pyright and pre-commit pass; two gh-aw v1.2.1 compiles are byte-identical; the guard's mutation checks pass.
  • Why: Commit locally; the validator reviews before the push.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · record step keeps its if; guard pins it exactly (superseded below)

  • Decision: The record step keeps if: steps.agent_artifact.outcome == 'success' && steps.health_artifact.outcome == 'success'. The guard requires that exact condition, binds both download ids to their artifacts, and allows only name, if, env and run on the step.
  • Why: The shipped step already carries this if: dropping it would change the source and every lock, while pinning it closes the disabled-step case with no runtime change. The manager decides at delta validation.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · manager: the record step keeps its exact if

  • Decision: Manager: keep the record step's if, pinned exactly by the guard, as committed in bafa96c1da.
  • Why: Manager: the if is what stops a record running without both artifacts.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · manager: guard scope boundary

  • Decision: The guard checks the record job's needs, condition, checkout, downloads, exact command, step condition and secrets, and stops there.
  • Why: Manager: the guard catches config drift in merged workflows; it is not the trust boundary, and pinning the whole job's shape would make it brittle.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · manager: fold in the stale threat-detection comment

  • Decision: shared/provider-health.md's pre-agent-steps comment now says a noop would still spend a threat-detection pass. Comment only; the locks were recompiled for the new frontmatter hash.
  • Why: Manager: #12893 merged; the comment now matches .github/workflows/AGENTS.md.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · validator cleared 974591020c; pushed

  • Decision: The manager's validator cleared 974591020c (clean merge on upstream/main 58d5894b2c, byte-identical gh-aw v1.2.1 compile, guard mutation checks, CI's .github/scripts tests on Python 3.13). Pushed under David's authorization.
  • Why: The validator was the remaining gate after the review budget.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · Macroscope r4515411240 (extra download step): skip, scope boundary

  • Decision: Manager's triage: skip, net-neutral. The guard does not count download steps beyond the two it requires.
  • Why: Every shipped record job has exactly two downloads, and the finding falls inside the guard scope boundary above.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · douwebot retry waits for PR Bots recovery

  • Decision: Manager: re-apply douwebot only after PR Bots recovers; the manager adds the label.
  • Why: Runs 42670813117 and 42671946136 on 974591020c ended without a review: GitHub did not create the publisher (first) or review (second) job.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · third douwebot run lost to GitHub Actions job creation

  • Decision: Run 42673427623 created only the review job, so no review was published. Recovery now requires three consecutive complete PR Bots runs.
  • Why: Most repository workflow runs failed the same way after about 18:10Z.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · #12960 merges first; retry douwebot after strict recovery

  • Decision: Manager: hold the douwebot retry until three consecutive complete PR Bots runs. #12960 should merge before this PR; if it merges first, merge main and recompile the 13 locks before the retry.
  • Why: #12960 regenerates the same 13 locks.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · push rule after merging #12960

  • Decision: Manager: if only the 13 locks conflict (take main's, byte-identical gh-aw v1.2.1 recompile, local checks pass), push directly. If the merge also resolves a source conflict, commit it, report, and wait for a short delta validation before the push.
  • Why: A lock-only merge plus recompile is mechanical, and douwebot and CI review the new head; a source conflict resolution is not exempt under the push skill.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · douwebot clean approval on 974591020c

  • Decision: Douwebot APPROVE (run 42693603099, engine claude) on 974591020c with no findings; Gate: clean douwebot approval passes; CI green.
  • Why: Fourth douwebot run, after PR Bots recovered; the first three were lost to GitHub Actions job creation.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · final metadata check

  • Decision: Kept: call-path nodes carry the file path; eight missing decision entries mirrored in log order; label internal added. Skipped: retitling the guard scope-boundary entry; adding gh-aw.
  • Why: The Macroscope reply cites the scope-boundary entry by its current title. No engine, runner, recorder or parser file changed, and sibling provider-health PRs #11048, #11051 and #11052 carry internal, not gh-aw.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-09 · merge-ready at 974591020c

  • Decision: CI green, douwebot clean APPROVE, Gate: clean douwebot approval passes, no unresolved threads. #12960 merges first; this PR then merges main and recompiles.
  • Why: Merge bar met on that head; David merges.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · conflicted, waiting on #12960

  • Decision: Manager: #12859 changed the Z.AI locks, so this PR conflicted with main. Merge main once, after #12960 merges, under the push rule above.
  • Why: #12960 regenerates the same locks; one merge after it avoids a second lock conflict.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · cluster:gh-aw label and [gh-aw] title prefix

  • Decision: David approved the gh-aw PR cluster (#12960, this PR, and a coming cache-miss fix). Keep cluster:gh-aw and the [gh-aw] prefix on every later title or label edit.
  • Why: A PR in a cluster keeps both its label and its prefix, never one without the other.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · merge upstream/main after #12960

  • Decision: 637b915109 merges upstream/main 3ccfec13f5 (#12960, #12859). The guard's module constants conflicted; both sets kept. #12859 removed UI Security Review, so there are 12 Z.AI locks; took main's and recompiled them with gh-aw v1.2.1.
  • Why: Push rule: a source conflict resolution waits for a delta validation. Two compiles are byte-identical, each lock's delta to main is unchanged apart from the frontmatter hash, and the guard check, CI's .github/scripts tests on Python 3.13, pyright and pre-commit pass.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · validator cleared 637b915109; pushed

  • Decision: The manager's validator cleared 637b915109 with no blocking defect: run_checks runs both check_engine_sys_path_order and check_provider_health_host_result, and all 12 locks have one provider_health_record job. Pushed, never force.
  • Why: The clearance is the gate the push rule sets for a source conflict resolution.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · CI green on 637b915109

  • Decision: CI run 42847510187 succeeded; every check except Gate: clean douwebot approval passed before the douwebot run.
  • Why: The manager adds the douwebot label after CI is green.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

2026-11-10 · douwebot clean approval on 637b915109

  • Decision: Douwebot APPROVE (run 42851911777, engine claude) on 637b915109 with no findings; Gate: clean douwebot approval passes; CI green.
  • Why: First douwebot run on the head that merges main after #12960; nothing to triage.
  • Session: 80a24561-c638-4bcc-a117-7353109b548e

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

Summary by cubic

Hardens the provider-health record's trust boundary so a provider-scope incident opens only when a host-side step confirms the failure, and drops the shim's scoped Bash work, now dead since the engine migration.

  • A new provider_health_record job runs after the agent job (gh-aw v1.2.1 allows no secrets in post-steps), reads the terminal result from the engine's agent-session.jsonl artifact, and writes run-result.json into the provider-health artifact; only its record step holds ZAI_API_KEY.
  • The monitor opens a provider incident only for a confirmed record; the agent-artifact fallback types failures but never confirms a provider. Host-confirmed outages still open provider incidents, typed failures stay typed, and rate_limit is unchanged.
  • The scoped Bash(...) grants are gone: workflows run the public pydantic-ai engine, which ignores --allowed-tools, so the shim and its tests match main.
  • The guard requires the host record steps in every Z.AI lock — an exact, whitespace-normalized always() condition, a non-negated if:, an integer record version, the exact record command after both downloads, and no secrets reference outside the record step — and the monitor triage accepts pull_request_review records from same-repository runs only. The locks are recompiled with gh-aw v1.2.1.

No public surface changes; everything is under .github/.