Skip to content

fix(compliance): cache compliance storyboard lookups and stop test-stage hangs - #8507

Merged
bokelley merged 1 commit into
mainfrom
bokelley/fix-slow-tests
Oct 26, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/fix-slow-tests

Conversation

@bokelley

@bokelley bokelley commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Build Check on main kept going red, which blocked deploys (main had to be re-run by hand twice today), and the local pre-commit hook failed for the same reasons. Three causes, each fixed here.

1. getComplianceStoryboardById parses the entire bundle on every call

In @adcp/sdk, getComplianceStoryboardById iterates listAllComplianceStoryboards(), which reads and parses every storyboard YAML in the bundle to return one storyboard. That's about 1.3 s of CPU per call for the 3.3 bundle, measured. The server calls it on hot paths:

  • Hosted grading: deriveStoryboardStatuses and classifyRunStep, through pinnedStoryboard, cached only per result object. Every compliance run with a skipped step paid it.
  • storyboard-skip-details, v4-readiness, Addie member tools, services/storyboards.
  • Five registry API routes, each paying it per request.

This is what pushed compliance-validate-input-gates past its 10 s timeout under load: a synchronous test took 2.4 to 3.6 s alone and about 11 s in a loaded run.

Fix: server/src/compliance/storyboard-cache.ts parses each bundle once per process and looks storyboards up by ID afterwards. The key is the four fields that select a bundle (version, complianceDir, schemaRoot, hostedStableLineAlias). Bundles are immutable per version and directory. Lookups return a structuredClone, so callers can't mutate the cache, and a bundle that fails to load isn't cached. Every server call site uses it. The four tests that mocked the SDK function now mock the wrapper instead.

Result: the gate test's per-case time goes from 2.5 to 3.6 s to about 20 ms after the first parse.

2. A hung canonical stage burned the whole job

Canonical shard 2/4 hung until the 25-minute job timeout cancelled it, and cancelled jobs lose their logs. The four node --test scripts without --test-force-exit can hang on any leftover handle.

  • --test-force-exit on those four scripts, matching the rest of package.json. test:sdk-runner-capability-gates and test:release-workflow both pass with it.
  • scripts/run-test-stage-shard.mjs gets a per-stage watchdog: 15 minutes, overridable with TEST_STAGE_TIMEOUT_MS. A hung stage now fails by name before the job timeout, and stage timings are printed. The longest stage in a recent run took about 4 minutes, and shards finish in 16 minutes or less.

3. A cold-start budget

The first member-tools collection round-trip pays the SDK's one-time AJV schema compilation. A CPU profile shows addNames and compileSchema dominating: about 9 s alone and over 30 s under full-suite load; the other cases take about 150 ms. Its budget goes from 30 s to 90 s, with a comment explaining why. Speeding up that compilation, along with an SDK-level lookup cache, belongs upstream in @adcp/sdk.

Tests

  • New storyboard-cache.test.ts: one parse per bundle; unrelated run options share a bundle; clones are isolated; versions and directories stay apart; load errors aren't cached.
  • Compliance and Addie suites that touch the lookups (gates, authored-tool gates, member-tools, step diagnostics, forward specialism, storyboards, notices, effective run status, catalog-reporting presentation)
  • The full pre-commit hook passes without --no-verify. The tests/ stage shows 1,276/1,276 with both former timeouts passing; server unit shards 4,763 + 3,636 + 4,907; typecheck.
  • Watchdog checked with TEST_STAGE_TIMEOUT_MS=3000: the stage is stopped and named.

🤖 Generated with Claude Code


Open workspace in Conductor

…age hangs

- server/src/compliance/storyboard-cache.ts: the SDK's
  getComplianceStoryboardById parses every storyboard YAML in a bundle
  on each call (~1.3s CPU) to return one. Bundles are immutable per
  version/directory, so each is parsed once per process and looked up
  by ID; callers get clones. Used by hosted grading
  (deriveStoryboardStatuses / classifyRunStep), skip details, v4
  readiness, Addie member tools, the storyboards service, and five
  registry API routes, which each paid the full parse per request.
  This is what pushed compliance-validate-input-gates past its 10s
  timeout under load.
- Shard runner: a 15-minute per-stage watchdog (TEST_STAGE_TIMEOUT_MS)
  fails a hung stage by name with its logs, instead of the 25-minute
  job timeout cancelling the shard and discarding them; stage timings
  are printed.
- --test-force-exit on the four node --test scripts that lacked it, so a
  lingering handle cannot hang a canonical shard.
- member-tools collection round-trip: the first case pays the SDK's
  one-time JSON Schema compilation (~9s alone, >30s under full-suite
  load); budget 90s, documented.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ladon verdict: Approve

Approve.

Performance/CI PR: adds a process-wide cache over the SDK's getComplianceStoryboardById and a per-stage CI watchdog plus --test-force-exit. No protocol surface touched.

Checks performed:

  • No Critical/High/Medium findings from the reviewer.
  • Cache is fail-closed and correct: keyed on exactly the fields hostedComplianceOptions sets (version/complianceDir/schemaRoot/hostedStableLineAlias), load errors are not cached, lookups return structuredClone, and complianceDir resolves to immutable dist/compliance/<version>, so no invalidation is needed.
  • All server call sites swapped with matching mock updates.
  • No static/schemas/source/**, docs/reference/**, or dist/** edits — no schema↔docs coherence, oneOf discriminator, or artifact-immutability concern. No changeset is correct here (app/CI-only change).

Decision-table trace:

  • Row 1 (critical/high): none.
  • Row 2 (gated_paths): false.
  • Row 3 (deleted high-risk): no deletions; the high-risk matches are all (modified) with no findings.
  • Rows 4–6: no medium findings; no prior escalation.
  • Row 7: no no-auto-approve team match.
  • Row 8: fewer than three medium findings (zero).
  • Row 9: approve.

Note: high_risk is true only via (modified) files in server/src/addie/** and server/src/routes/**, but with no medium-or-higher finding on them, those modifications are presumed safe and do not warrant escalation.

@bokelley
bokelley merged commit 17ba026 into main Oct 26, 2026
61 checks passed
@bokelley
bokelley deleted the bokelley/fix-slow-tests branch October 26, 2026 16:28
bokelley added a commit that referenced this pull request Nov 14, 2026
…ut (#9000)

The fixture-unavailable case in compliance-validate-input-gates builds two
compliance results. On 3.2.x each one loads its pinned storyboard from the
hosted bundle without a cache (main has had one since #8507), so the case
takes 2.5-7 s on a CI runner. On the 3.2.11 release push (Build Check
43436688553) one variant hit 10,023 ms against the 10 s default, although
the tree was identical to the green Version Packages head.

Test-only; no changeset.

Co-authored-by: Claude Opus 5.5 <[email protected]>
KonstantinMirin pushed a commit to KonstantinMirin/adcp that referenced this pull request Nov 21, 2026
Brings the published 3.2.12 release records to main.

Resolved:
- package.json, package-lock.json, static/schemas/source/index.json: main's.
- static/compliance/published-versions.json: main's in this merge; the
  registration commit adds 3.1.34 and 3.2.12 after qualification.
- CHANGELOG.md: main's plus the 3.2.12 block (forward-merge-release-records.cjs changelog).
- dist/schemas/index.json, latest.json: 3.2.x's, regenerated in the next commit.
- docs/governance/campaign/audit-trail.mdx and tasks/sync_plans.mdx: main's.
  adcontextprotocol#8980 is the 3.2 backport of adcontextprotocol#8931, which main carries in full.
- tests/addie/compliance-validate-input-gates.test.ts: reverted to main's.
  adcontextprotocol#9000's 30 s timeout is 3.2.x-only; main caches the storyboard lookup (adcontextprotocol#8507).

adcontextprotocol#9128 (3.2.x backport of adcontextprotocol#8894) auto-merged with no net change: 3.2.x's
webhook-emission files equal main's.

Co-Authored-By: Claude Opus 5.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.

1 participant