Skip to content

feat: inline ci3 YAML annotations for test resource metadata#20934

Open
AztecBot wants to merge 8 commits intonextfrom
claudebox/e0ea2668aeb0d67c-1
Open

feat: inline ci3 YAML annotations for test resource metadata#20934
AztecBot wants to merge 8 commits intonextfrom
claudebox/e0ea2668aeb0d67c-1

Conversation

@AztecBot
Copy link
Collaborator

@AztecBot AztecBot commented Feb 27, 2026

Summary

  • Inline YAML annotations on test files declare CI resource metadata (isolation, CPU/memory, timeouts, env vars) instead of pattern-matching in bootstrap.sh
  • Set UV_THREADPOOL_SIZE per test based on sequencer count (~4 libuv threads per sequencer)
  • Scale LMDB MAX_READERS and AVM simulator concurrency with UV_THREADPOOL_SIZE
  • Precheck script validates all annotations at test_cmds time

Annotation format

First line of .test.ts files, parsed by yarn-project/scripts/parse_ci3_annotation.sh using yq:

// ci3: { isolate: true, cpus: 10, mem: "16g", timeout: "15m", uv_threadpool_size: 32 }

Prefix fields (ci3 infrastructure — colon-separated, used for docker isolation / scheduling):

  • isolate, cpus, mem, timeout, net, only_term_parent

Env vars (space-separated, passed to the test process):

  • uv_threadpool_size, log_level, bb_verbose, hardware_concurrency, etc.

Keys are lowercase YAML, uppercased on emit (e.g. cpus: 8CPUS=8).

163 annotated test files

Package Count Typical annotation
p2p 75 { isolate: true } or { isolate: true, uv_threadpool_size: 16 }
ethereum 21 { isolate: true }
end-to-end 25 { uv_threadpool_size: 16 } or { timeout: \"15m\" }
bb-prover 14 { cpus: 16, mem: \"16g\" }
aztec.js 6 { isolate: true }
ivc-integration 5 { isolate: true, net: true, cpus: 8 }
prover-node 6 { isolate: true }
prover-client 4 { isolate: true }
aztec-node 4 { isolate: true }
stdlib 1 { isolate: true }
bench 1 { isolate: true, cpus: 16, mem: \"32g\", timeout: 1200 }

Precheck

check_ci3_annotations.sh runs at test_cmds start and verifies:

  1. Tests in isolation-required packages have isolate: true
  2. All annotations are valid YAML (parsed by yq)

LMDB / AVM scaling

  • MAX_READERS = Math.max(16, UV_THREADPOOL_SIZE * 2) — each libuv thread needs a reader slot
  • AVM semaphore = Math.max(1, Math.floor(UV_THREADPOOL_SIZE / 2))

Test plan

  • Verify test_cmds output matches old behavior
  • Spot-check specific tests for correct ISOLATE, CPUS, MEM, UV_THREADPOOL_SIZE values
  • Run precheck: cd yarn-project && bash scripts/check_ci3_annotations.sh"

Tests that create multiple sequencer nodes need more libuv threads than
the default 8. Each sequencer needs ~4 threads. This sets per-test
UV_THREADPOOL_SIZE in test_cmds for both yarn-project unit tests and
end-to-end tests based on the number of nodes each test creates.

Also scales LMDB MAX_READERS with UV_THREADPOOL_SIZE since each libuv
thread accessing the database needs a reader slot.
@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Feb 27, 2026
e2e_epochs tests also create multiple validator nodes:
- epochs_first_slot (8 nodes) -> UV_THREADPOOL_SIZE=32
- epochs_invalidate_block (5 nodes) -> UV_THREADPOOL_SIZE=24
- epochs_mbps, epochs_simple, epochs_high_tps (3-4 nodes) -> UV_THREADPOOL_SIZE=16
Introduce a `// ci3: KEY=val` first-line comment annotation for test
files that declares CI resource requirements (ISOLATE, CPUS, MEM,
UV_THREADPOOL_SIZE, etc.) directly in the test file instead of via
pattern matching in bootstrap.sh.

- New helper: yarn-project/scripts/parse_ci3_annotation.sh
- yarn-project/bootstrap.sh test_cmds now reads annotations
- yarn-project/end-to-end/bootstrap.sh test_cmds now reads annotations
- 148 test files annotated with their CI metadata
@AztecBot AztecBot changed the title feat: set UV_THREADPOOL_SIZE per test based on sequencer count feat: inline ci3 test annotations and UV_THREADPOOL_SIZE scaling Feb 27, 2026
…ations

Changes:
- Switch annotation format from `// ci3: KEY=val` to XML syntax:
  `// <ci3:meta isolate cpus="10" mem="16g" uv_threadpool_size="32" />`
- Update parser (parse_ci3_annotation.sh) to handle XML attribute syntax
  with case-insensitive attribute names (uppercased on emit)
- Add missing ISOLATE annotations to 13 test files that were matched
  by the old `^aztec` regex pattern but weren't annotated:
  - aztec-node/ (4 files)
  - aztec.js/ (6 files)
  - p2p/ bench tests (3 files)
- Behavioral parity verified: all 161 annotated files match old
  bootstrap.sh pattern-matching behavior
- Rename annotation tag from ci3:meta to ci3: `// <ci3 isolate cpus="10" />`
- Add timeout="15m" annotation to e2e_block_building.test.ts, read by
  bootstrap.sh instead of hardcoding
- Add ci3 annotation to p2p_client.proposal_tx_collector.bench.test.ts
  documenting its bench_cmds resource settings (isolate cpus="16" mem="32g"
  timeout="1200")
- 163 total annotated test files
Add check_ci3_annotations.sh that verifies:
- Tests in isolation-required packages (p2p, ethereum, prover-node,
  aztec-node, aztec.js, prover-client/src/test, stdlib/src/l1-contracts,
  ivc-integration/src/chonk_browser) have '// <ci3 isolate ... />'
- All existing ci3 annotations use valid syntax ('// <ci3 ... />')

Runs automatically at the start of test_cmds in bootstrap.sh, failing
early if any test file is missing a required annotation or has a
malformed one.
@ludamad ludamad marked this pull request as ready for review February 27, 2026 13:49
Replace XML-style `// <ci3 isolate cpus="10" />` with inline YAML:
  `// ci3: { isolate: true, cpus: 10, mem: "16g" }`

- Parser now uses yq to parse YAML, avoiding shell quoting issues
  that caused `export: not a valid identifier` errors in
  source_test_params
- Precheck validates YAML syntax with yq instead of regex
- 163 test files converted
@AztecBot
Copy link
Collaborator Author

Code Review: Inline ci3 test annotations

Bugs Found

BUG 1 (Critical): ((errors++)) crashes script on first error

yarn-project/scripts/check_ci3_annotations.sh lines 45, 54, 69, 70

The script uses set -euo pipefail (line 9) and ((errors++)) (lines 45, 54, 69, 70). When errors is 0, the expression ((0++)) evaluates to 0 (falsy in bash arithmetic), which produces exit code 1. With set -e active, the script immediately exits on the first error encountered.

Consequences:

  • The script will never report more than one error
  • The summary message FAILED: N annotation error(s) found. (lines 77-78) is never printed
  • The script exits from the ((errors++)) line, not from the intentional exit 1 on line 79

Verified: Created a test file missing isolate annotation. Script printed one ERROR line then exited without printing the summary.

Fix: Replace ((errors++)) with errors=$((errors + 1)) on all 4 lines.


BUG 2 (Low): eval-unsafe output for values containing single quotes

yarn-project/scripts/parse_ci3_annotation.sh line 64

The output format echo "CI3_PREFIX='$CI3_PREFIX' CI3_ENV='$CI3_ENV'" uses single quotes to wrap values. If any yq-produced value contains a literal single quote, the eval in bootstrap.sh would break with a syntax error. Very unlikely in practice (CI config values won't contain single quotes), but a correctness issue.


BUG 3 (Low): PR description format mismatch

The PR description's "Annotation format" section shows XML format (// <ci3:meta isolate cpus="10" ... />), but the actual implementation uses YAML format (// ci3: { isolate: true, cpus: 10, ... }).


BUG 4 (Minor, pre-existing): Duplicate CPUS/MEM for prover-client testbench in CI_FULL mode

prover-client/src/test/proving_broker_testbench.test.ts has cpus: 10, mem: "16g" in its annotation. When CI_FULL=1, the code appends :CPUS=16:MEM=96g, creating duplicate prefix entries. This was also present in the old code.

Observations

  1. Potential future double-ISOLATE in e2e tests: The e2e prefix hardcodes ISOLATE=1. If a future e2e annotation adds isolate: true, prefix would get ISOLATE=1:ISOLATE=1. Currently no e2e test has this (verified).

  2. Silent failure on bad YAML: The parser outputs empty values on yq failure (exits 0). The precheck is supposed to catch bad YAML, but due to Bug 1 it would only report one error before crashing.

  3. No near-miss detection: Typos like //ci3: or // ci3:{ silently produce no annotation. No warning for near-misses.

  4. File count: PR says 161 annotated files, actual count is 163.

Verified Correct

  • Parser regex, yq parsing, boolean logic, PREFIX/ENV separation all correct
  • Output single-quoting prevents $() command injection
  • IFS='=' correctly handles values containing =
  • bootstrap.sh eval, NAME auto-addition, CI_FULL override all correct
  • e2e annotation loop correctly appends CI3_PREFIX and CI3_ENV
  • Glob exclusion correctly includes aztec-node and aztec.js
  • All 5 requested test files produce correct parser output
  • check_ci3_annotations.sh passes on current codebase

Full review details

((errors++)) when errors=0 evaluates to falsy (exit code 1), causing
immediate script termination under set -e. Only the first error would
be reported.
@AztecBot AztecBot changed the title feat: inline ci3 test annotations and UV_THREADPOOL_SIZE scaling feat: inline ci3 YAML annotations for test resource metadata Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants