Skip to content

chore(scripts): diagnose-agent-comply-queue (escalation #329 follow-up)#4361

Merged
bokelley merged 1 commit intomainfrom
bokelley/requeue-evgeny-agent
May 11, 2026
Merged

chore(scripts): diagnose-agent-comply-queue (escalation #329 follow-up)#4361
bokelley merged 1 commit intomainfrom
bokelley/requeue-evgeny-agent

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Summary

One-off script that explains why a given agent URL isn't being picked up by the compliance-heartbeat queue.

Background

Escalation #329 — Evgeny's agent (https://adcp-signals-adaptor.evgeny-193.workers.dev/mcp) shows last_checked_at = 2026-05-04T09:42:55Z despite the worker being back online and compliance-heartbeat running multiple times in the 6+ hour window since. The public registry returns him as a valid agent, but no heartbeat tick is updating his row. Need to know whether he's:

  • (a) Filtered out by metadata (compliance_opt_out, monitoring_paused, or non-production lifecycle_stage)
  • (b) In the queue but behind a backlog of NULL last_checked_at agents
  • (c) Not in any of the three union sources (discovered_agents, agent_registry_metadata, member_profiles.agents) at all

Existing admin endpoints (/api/registry/agents/:url/monitoring/settings, /refresh) require WorkOS isWebUserAAOAdmin-style auth which the static ADMIN_API_KEY user identity can't satisfy.

What it does

Mirrors getAgentsDueForCheck SQL exactly so output matches heartbeat behavior:

  1. Union-source presence — which of the three source tables contain the URL
  2. Registry metadata filters — lifecycle_stage, compliance_opt_out, monitoring_paused, check_interval_hours
  3. Current agent_compliance_status row
  4. Row-number position in the due queue (10 agents per tick → estimated ticks until pickup)

--requeue flag clears last_checked_at to force pickup on the next heartbeat tick.

Usage

# Dev
npx tsx server/src/scripts/diagnose-agent-comply-queue.ts https://adcp-signals-adaptor.evgeny-193.workers.dev/mcp

# Prod
fly ssh console -a adcp-docs -C 'node /app/dist/scripts/diagnose-agent-comply-queue.js https://adcp-signals-adaptor.evgeny-193.workers.dev/mcp'

# Force pickup on next tick
fly ssh console -a adcp-docs -C 'node /app/dist/scripts/diagnose-agent-comply-queue.js https://adcp-signals-adaptor.evgeny-193.workers.dev/mcp --requeue'

🤖 Generated with Claude Code

One-off script that explains why a given agent URL isn't being picked up
by the compliance-heartbeat queue. Mirrors the getAgentsDueForCheck SQL
so the output matches what the heartbeat would see:

  1. Union-source presence — discovered_agents, agent_registry_metadata,
     member_profiles.agents (the three places the heartbeat reads from)
  2. Registry metadata filters — lifecycle_stage, compliance_opt_out,
     monitoring_paused, check_interval_hours
  3. Current agent_compliance_status row
  4. Position in the due queue (row_number with batch size 10/tick)

--requeue flag clears last_checked_at to force pickup on the next tick.

Background: escalation #329 — Evgeny's agent showed last_checked_at =
May 4 despite multiple heartbeat ticks running in the 6+ hour window
after the worker came back. Needed a way to distinguish (a) filtered
out, (b) queued behind NULL last_checked_at agents, (c) not in any
source table. Existing endpoints required workos admin auth that the
ADMIN_API_KEY user identity can't satisfy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 1bf945e into main May 11, 2026
13 checks passed
@bokelley bokelley deleted the bokelley/requeue-evgeny-agent branch May 11, 2026 07:15
bokelley added a commit that referenced this pull request May 11, 2026
…he fix

Runs comply() against an agent URL and prints what
deriveStoryboardStatuses would produce, without DB writes. Used to
validate the SDK-6.x scenario-key fix against real agents
(adcp-signals-adaptor.evgeny-193.workers.dev/mcp and
wonderstruck.sales-agent.scope3.com/mcp) before merging.

Will stay useful for future SDK upgrades that touch scenario emission
or storyboard-track aggregation — same pattern as the
diagnose-agent-comply-queue script from #4361.

Usage:
  npx tsx server/src/scripts/test-comply-storyboard-statuses.ts <agent-url> [<agent-url> ...]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bokelley added a commit that referenced this pull request May 11, 2026
…o keys (#4364)

* fix(compliance): rewrite deriveStoryboardStatuses for SDK 6.x scenario keys

The compliance heartbeat has been writing zero rows to
agent_storyboard_status since the SDK switched comply() to storyboard-
driven testing. The SDK emits one TestResult per phase of each storyboard,
keyed `<storyboard_id>/<phase_id>` in result.tracks[].scenarios[].scenario
(see @adcp/sdk compliance/storyboard-tracks.ts). The old implementation
walked the YAML's per-step `comply_scenario` field (bare names like
`signals_flow`, `capability_discovery`) and looked them up in the SDK's
scenario map. Every lookup missed → testedCount === 0 → every storyboard
skipped at the `continue` guard.

Effect across the registry:
  agent_storyboard_status total rows: 6  (across 4 agents)
  rows written by triggered_by='heartbeat': 0
  rows surviving were legacy bare-name keys from old manual runs

This silently broke the AAO Verified badge pipeline (no storyboard rows
→ deriveVerificationStatus has nothing to verify against) and every
agent's dashboard `storyboards_passing: 0 / N` was misleading: the
runner wasn't failing storyboards, the parser was dropping them.

Surfaced by escalation #329: Evgeny's agent was running 30/30 scenarios
clean but showing `degraded` because specialism_status.signal-owned read
'untested' from a never-populated agent_storyboard_status row.

Fix: read SDK output directly. Group scenarios by storyboard id, roll
per-step pass counts up from each phase's `steps` array, fall back to
phase-level counts when steps are absent. The `storyboardIds` override
is preserved for explicit-IDs callers that need an `untested` entry
when the runner didn't run a requested storyboard. The unused YAML
`comply_scenario` field is no longer load-bearing for status mapping
(the SDK already knows which storyboards it ran).

Tests: 9 cases covering all-pass, partial, all-fail, phase-only fallback,
legacy bare-name skip, empty input, and explicit-IDs untested gap.

Stack note: this is orthogonal to Emma's #4247 compliance-state
unification stack (#4250, #4263, #4264, #4268, #4274) which collapses
agent_test_history into agent_compliance_runs. Different files; rebases
cleanly in either order.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(scripts): test-comply-storyboard-statuses — local harness for the fix

Runs comply() against an agent URL and prints what
deriveStoryboardStatuses would produce, without DB writes. Used to
validate the SDK-6.x scenario-key fix against real agents
(adcp-signals-adaptor.evgeny-193.workers.dev/mcp and
wonderstruck.sales-agent.scope3.com/mcp) before merging.

Will stay useful for future SDK upgrades that touch scenario emission
or storyboard-track aggregation — same pattern as the
diagnose-agent-comply-queue script from #4361.

Usage:
  npx tsx server/src/scripts/test-comply-storyboard-statuses.ts <agent-url> [<agent-url> ...]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(compliance): code review nits — clarify steps doc, hoist explicit-ids check, add 3 edge tests

Addresses code-reviewer feedback on PR #4364:
- JSDoc on deriveStoryboardStatuses now calls out that steps_passed/total
  are not directly comparable across rows (some rows are real step counts,
  some are phase-level fallbacks when the SDK omits per-step data).
- Comment pinning the storyboard-id invariant (flat ids, no `/`) so the
  indexOf split stays correct as new storyboards land.
- Defensive `result.tracks ?? []` so a malformed result doesn't throw.
- Hoist `storyboardIds && length > 0` into a single `hasExplicitIds`
  const used at both the toEmit decision and the no-data fallback.
- Three new test cases:
  * same storyboard split across multiple tracks aggregates correctly
  * result.tracks absent → []
  * non-string scenario values (null, number) → skipped without throwing

12/12 vitest passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant