Skip to content

feat(watchdog): test mode with synthetic candidates and a test-only marker - #492

Merged
kyle-sexton merged 2 commits into
mainfrom
feat/watchdog-test-mode
Aug 17, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
feat/watchdog-test-mode

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Summary

Phase 1.1 of the standards-sync audit: the stuck-automerge watchdog's issue-write path has never executed (fleet disarmed → zero candidates), so the create/update/close/fail lifecycle that gates fleet re-arm is unproven. This adds a dispatchable proof path.

Fix

  • Two new workflow_call inputs: test-mode (boolean, false) + test-synthetic-candidates (string, '1' — string so '0', the close-path proof, survives the caller's empty-string fallback).
  • Test mode empties the scan list (zero live probing; real-scan code path byte-identical) and fabricates SYNTHETIC-labeled rows whose links point at the producing run.
  • Marker/title become single-source workflow env (ALERT_MARKER / ALERT_ISSUE_TITLE) diverging under test-mode — a test issue in medley is invisible to the production lookup (same App authors both; identity alone cannot separate them). All five former literal sites read the env.
  • Job/step names byte-identical to v0.14.2 (the standards caller's failure classifier string-matches them).
  • Stale rollout-window comment re-cut; README watchdog bullet extended.

Verification

node --test .github/scripts/standards-sync-stuck-automerge-alert.test.cjs → 57/57 (9 new: synthetic counts 2/1/0, off-on-'false', off-on-absent, raw-YAML single-source pins for marker/title across all five consumer sites); full .github/scripts sweep 723/723; yq confirms the input contract; job-name diff vs v0.14.2 empty.

Related

Closes #491. Related: melodic-software/standards#406 (audit umbrella; Phase 1 plan in that repo's docs/topics/standards-sync-audit/PLAN.md).

🤖 Generated with Claude Code

https://claude.ai/code/session_013NhxMDn7vZdbs7Cq32m56M

…arker

Standards-sync audit Phase 1.1. The watchdog's issue-write path has never
executed: with every target disarmed there is nothing to scan, so the
create/update/close/fail lifecycle that gates fleet re-arm is unproven.

- New workflow_call inputs: test-mode (boolean, default false) and
  test-synthetic-candidates (string, default '1' — string so '0', which
  drives the close-path proof, survives the caller's empty-string fallback).
- Test mode empties the scan list (no live probing; the real-scan path is
  byte-identical either way) and fabricates labeled SYNTHETIC rows whose
  links point at the producing run.
- Marker and title become single-source workflow env (ALERT_MARKER /
  ALERT_ISSUE_TITLE) that diverge under test-mode, so a test issue in the
  tracking repository is invisible to the production lookup — the same App
  authors both, so identity alone cannot separate them. All five former
  literal sites now read the env.
- Job and step names are byte-identical to v0.14.2: the standards caller's
  failure classifier matches them as literal strings.
- Tests: 9 new cases (synthetic counts 2/1/0, off-on-'false',
  off-on-absent, and raw-YAML pins asserting each marker/title literal is
  defined exactly once with every consumer reading the env); the harness
  gains explicit TEST_MODE/ALERT_MARKER env management and a context mock.
  The suite's own ISSUE_TITLE constant never matched the workflow's real
  title — aligned while pinning it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013NhxMDn7vZdbs7Cq32m56M
@kyle-sexton
kyle-sexton enabled auto-merge (squash) August 17, 2026 15:51
@claude

claude Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Security review — /review:security-review

Tasks

  • Gather PR context (diff, changed files)
  • Analyze workflow YAML for injection / trust-boundary issues
  • Analyze test-mode candidate fabrication and issue-lifecycle scoping
  • Post findings

(Note: the review:security-review skill invocation errored out in this environment with no output, so this review was performed manually against the same criteria — trust boundaries, injection, and Actions-specific pitfalls — by reading the full diff and surrounding workflow.)

Summary

No vulnerabilities found. This is a well-scoped addition that follows the file's existing security patterns closely:

  • No script injection: test-mode / test-synthetic-candidates are only ever passed to actions/github-script via env: (L242-243) and read back via process.env inside the script (L263-264). Neither input is ever interpolated as ${{ }} directly into a run: shell body or script text, consistent with the file's own documented rule that doing so "is template injection by construction."
  • No privilege escalation: test-mode reuses the same App tokens/scopes minted for the production path (read-only PR scan token, issues:write scoped to tracking-issue-repository). It doesn't request or unlock any broader permission, and in fact reduces blast radius by skipping all live GraphQL scanning (scanRepoNames = testMode ? [] : repoNames).
  • No cross-contamination with the production issue: ALERT_MARKER/ALERT_ISSUE_TITLE diverge under test-mode (L139-140), and the lookup/close steps still filter by App-authored identity (issueAuthorLogin/type === 'Bot') before ever matching on marker/title text, so a test run can't adopt, or be adopted as, the real alert issue.
  • Synthetic row content isn't attacker-influenceable: the fabricated SYNTHETIC-test-candidate rows use fixed strings plus context.serverUrl/context.repo/context.runId, all Actions-provided values, not caller-supplied text — no markdown/issue-body injection surface there.

Minor observations (non-blocking)

  1. Silent degrade on malformed test-synthetic-candidates. L264 does Number(process.env.TEST_SYNTHETIC_CANDIDATES ?? '1'). If a caller passes a non-numeric string (e.g. an empty string or typo), Number(...) is NaN, both >= 1 checks at L467 and L470 evaluate false, and — since the real scan is already skipped — the run silently takes the all-clear path (closing any open test issue) instead of failing loudly on a misconfigured caller. Low impact since it's confined to the test-only marker/issue, but a small Number.isInteger / range guard would make a bad caller input fail closed instead of silently closing the test issue.
  2. Caller-side trust boundary is out of scope here but worth confirming. This repo only defines the reusable workflow_call target; the actual caller (referenced as Standards-sync audit Phase 0: hygiene + pins standards#406) isn't in this diff. Worth double-checking on that side that test-mode is wired to a workflow_dispatch input restricted to trusted invokers (not derived from PR-controlled context), and that the scheduled/production trigger never passes test-mode: true.

View job run · Branch

@claude

claude Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 6m 41s —— View job


Claude's review

  • Gather context (PR diff, changed files, CLAUDE.md)
  • Run /review:code-review procedure
  • Post findings as inline comments
  • Post summary comment

Summary

Reviewed the full diff against origin/main (git diff origin/main...HEAD): the workflow's test-mode plumbing, the ALERT_MARKER/ALERT_ISSUE_TITLE single-sourcing, and the new/updated tests in standards-sync-stuck-automerge-alert.test.cjs. This is careful, well-reasoned work — I traced the marker/title refactor against the pre-PR workflow (git show origin/main:...) and confirmed the production marker/title strings are byte-identical to what's on main today; only the test fixture's stale title default ("[Alert] standards-sync stuck auto-merge PR(s)", which never matched the real workflow title) got corrected. The testMode/testSyntheticCandidates off-by-default semantics, the env-restore in runScan, and the raw-YAML pin tests for the marker/title consumers all check out.

One issue, CI-confirmed on this PR:

ci / biome is failing (job run) with File content differs from formatting output while linting .github/scripts (which includes the changed standards-sync-stuck-automerge-alert.test.cjs). The reporter didn't surface a file/line annotation in the captured log, so I can't pin the exact spot, but this is the only file this PR touches under .github/scripts, and the production title/marker strings are unchanged from main, so the most likely cause is formatting drift in the ~180 new/changed lines of test code (e.g. the new test-mode test block or the multi-arg assert.equal(...) wrapping around lines 1455-1480). Recommend running the repo's biome formatter locally against this file and committing the result before merge — this is a hard CI gate, not a style nit.
Fix this →

Other CI failures on this run (ruff, go-quality-dogfood) touch Python/Go paths this PR doesn't modify and look unrelated/pre-existing; I didn't chase those further since they're out of this PR's scope.

Note: my sandbox blocked running node --test directly, so I couldn't independently re-verify the PR body's "57/57 / 723/723" test claims — I relied on static reading of the test additions (which look internally consistent and correctly exercise the off/on/absent TEST_MODE matrix) plus the CI signal already posted to this PR.

No inline comments — the diff is otherwise correct and consistent with the workflow's existing conventions.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c292461cfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Last security-reviewed head: 82d0dc6ec44424d5251233f7e52047f3a69b44ef. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

@github-actions

Copy link
Copy Markdown

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

…he suite

Codex review on the test-mode PR: Number() would map an empty, negative, or
garbled test-synthetic-candidates to 0/NaN and silently take the all-clear
path — a typo'd create/update proof would close the test issue while
appearing to succeed. Test mode now rejects any raw value outside
'0'/'1'/'2' before use; outside test mode the value stays ignored. Two new
cases cover both sides.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013NhxMDn7vZdbs7Cq32m56M
@kyle-sexton

Copy link
Copy Markdown
Member Author

Addressed in 82d0dc6: test mode now rejects any raw count outside '0'/'1'/'2' with core.setFailed before use (an invalid value can no longer fake the all-clear path), ignored as before outside test mode; two new cases cover both sides.

@kyle-sexton
kyle-sexton merged commit 01c3295 into main Aug 17, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the feat/watchdog-test-mode branch August 17, 2026 16:07
@claude

claude Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Security review — /review:security-review

Tasks

  • Gather PR context (diff, changed files, current HEAD 82d0dc6)
  • Analyze workflow YAML for injection / trust-boundary issues
  • Analyze test-mode candidate fabrication and issue-lifecycle scoping
  • Post findings

(Note: as on the prior review, the review:security-review skill invocation errored out in this environment with no output, so this pass was again performed manually against the same criteria — trust boundaries, injection, and Actions-specific pitfalls.)

Summary

No vulnerabilities found. This push is the fix for the one item raised in the earlier review at c292461c (and independently flagged by Codex as P2): the test-synthetic-candidates value is now validated against the exact legal set before use.

.github/workflows/standards-sync-stuck-automerge-alert.yml#L264-L273:

const rawSyntheticCandidates = process.env.TEST_SYNTHETIC_CANDIDATES ?? '1';
if (testMode && !['0', '1', '2'].includes(rawSyntheticCandidates)) {
  core.setFailed(`test-synthetic-candidates must be '0', '1', or '2'; got '${rawSyntheticCandidates}'.`);
  return;
}
const testSyntheticCandidates = Number(rawSyntheticCandidates);

This closes the silent-degrade path previously described (empty/negative/garbled input coercing to 0/NaN and taking the all-clear branch, which would have closed an open test issue while looking like success). A few things worth confirming, which I did:

  • Fails closed, not silently. No continue-on-error is set on the scan step (workflow-wide grep), so core.setFailed here halts the job before any of the downstream if: steps.scan.outputs... issue-write steps can run — a malformed input now fails the run instead of quietly closing/no-oping the test issue.
  • Scoped correctly to test-mode only. The check is gated on testMode &&, so a malformed test-synthetic-candidates on a production (non-test-mode) run is ignored rather than failing the real scan — confirmed by the new test "an invalid candidate count outside test mode is ignored (production path unaffected)" (standards-sync-stuck-automerge-alert.test.cjs#L1424).
  • Test coverage matches the fix. "test-mode rejects a candidate count outside the legal set..." (test.cjs#L1407-L1422) exercises '', '3', '-1', 'two', '1.5' and asserts each fails validation with no scan outputs produced — the exact injection/typo surface the earlier review and Codex called out is now closed.
  • No new injection surface. The new code only compares a string against a fixed allow-list and calls core.setFailed with it interpolated into a log message (not a shell run: body or re-parsed as YAML/JS) — consistent with the rest of the file's pattern of keeping caller-controlled workflow_call inputs inside env:/process.env, never ${{ }}-interpolated into script text.

Everything else from the prior review (App-token scoping, marker/title divergence under test-mode, synthetic-row content sourced only from context.* fields) is unchanged in this diff and still holds.

No blocking findings.

View job run · Branch

kyle-sexton added a commit to melodic-software/standards that referenced this pull request Aug 17, 2026
….0 re-pin (#416)

## Summary

Phase 1.2+1.3 of the standards-sync audit: the watchdog caller gains the
test-mode dispatch surface, three latent classifier defects are fixed,
and the caller re-pins to v0.15.0 (the test-mode release). The full
tracking-issue lifecycle proof ALREADY RAN against this branch —
evidence below and in the plan.

## Fix

- `classify-alert-failure`: job-name match by suffix (the jobs API
returns reusable jobs prefixed `alert / …` — the exact match had never
hit); job-level `actions: read` (the jobs API 404s under
contents:read-only); step conclusions read from the jobs listing (the
previously targeted `/actions/jobs/<id>/steps` endpoint does not exist).
Each was latent — this job had never executed before the proof
dispatches.
- `workflow_dispatch` gains `test-mode` + `test-synthetic-candidates`
(string; `'0'` survives the explicit empty-string fallback), passed with
schedule-safe defaulted expressions; `concurrency` group added so a
dispatched proof and the hourly poll cannot race the rolling issue.
- Re-pin to `v0.15.0` (`01c3295…`); policy.json contract entry at the
new SHA with the two new inputs (same-PR lockstep); runner-policy README
rollout paragraph; stale rollout-window comment re-cut; Phase 1 plan +
proof artifact ride this branch.

## Verification

Pre-merge proof (branch-ref dispatches; full detail in
`docs/topics/standards-sync-audit/PLAN.md` Phase 1.3): medley#1856
created (2 SYNTHETIC rows, run 32044893913) → updated (1 row, run
32045258184; deliberate failure classified
`infrastructure-failure=false`, liveness SKIPPED) → closed `completed`
(run 32045329964). `node --test
components/runner-policy/runner-policy.test.mjs` 272/272; manifest
validator green; lefthook green. The hourly cron shape is exercised by
the next scheduled tick post-merge (expressions resolve to false/'1' on
schedule events).

## Related

Closes #415. Related: #406 (audit umbrella),
melodic-software/ci-workflows#492 (the reusable's test mode).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013NhxMDn7vZdbs7Cq32m56M

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watchdog test mode: prove the tracking-issue lifecycle without a real stuck PR

1 participant