Skip to content

perf(validation): run assurance gate DAG with bounded concurrency - #40

Open
cryptoxdog wants to merge 1 commit into
claude/fix-register-test-typesfrom
claude/unthrottle-validation-gates
Open

perf(validation): run assurance gate DAG with bounded concurrency#40
cryptoxdog wants to merge 1 commit into
claude/fix-register-test-typesfrom
claude/unthrottle-validation-gates

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Stacked PR — top of the stack

Stacked on #39 (register typecheck fix), which stacks on #38#37#36. Base is claude/fix-register-test-types; this PR's diff shows only the scheduler change. Retarget to main once the stack lands.

Problem

The assurance CLI (scripts/validation/cli.ts) executed its gate DAG in a strict serial for loop. Gates that only share an upstream dependency — typecheck, lint, test, manifest, claims all depend only on source — ran one-at-a-time even though they are independent, so the heavy test gate blocked everything after it and wall-clock was left on the table.

Solution

Add a pure, dependency-aware, bounded-concurrency scheduler (scripts/validation/core/gate-scheduler.ts) and run only gate.execute() concurrently. All evidence writing and the run report are assembled serially in gateOrder, so validation/runs/** output is byte-stable regardless of completion order. Dependency-blocked cascade semantics are unchanged.

  • Concurrency capped by VALIDATION_CONCURRENCY (default min(4, cpus), never unbounded).
  • VALIDATION_CONCURRENCY=1 reproduces the exact previous serial order — a built-in rollback lever.

Evidence

  • Performance (scripts/validation/bench-scheduler.ts): ci-profile wall-clock 2786ms → 1412ms (~1.97×, 49% reduction), stable across runs; 1412ms equals the DAG critical path, confirming full overlap of the independent gates.
  • Correctness: 9 new scheduler tests (dependency ordering, cap-never-exceeded, cascade-block, cap=1 serial-equivalence, rejection propagation); full suite vitest 158/158; eslint src/ clean; manifest current.
  • Full npm run typecheck gate is green on this branch (exit 0) since it stacks on Fix pre-existing typecheck failures in register tests (CLI-FND-002) #39.

Notes

Only gate.execute() is parallelized; the previous serial contract is a one-env-var fallback. command-runner.ts already spawned async, so this loop was the sole serializer. Produced via the unthrottle-cli-pr-pack skill (selected option CLI-OPT-001).


Generated by Claude Code

The assurance CLI awaited each gate in a strict serial loop, so gates that
share only an upstream dependency (typecheck, lint, test, manifest, claims all
depend only on 'source') ran one-at-a-time. Add a pure, dependency-aware,
bounded-concurrency scheduler (scripts/validation/core/gate-scheduler.ts) and
run only gate.execute() concurrently; evidence writing and the run report stay
serialized in gateOrder so validation/runs output is unchanged.

Concurrency is capped by VALIDATION_CONCURRENCY (default min(4, cpus), never
unbounded); VALIDATION_CONCURRENCY=1 reproduces the previous serial order.
Dependency-blocked semantics are preserved. Benchmark (bench-scheduler.ts):
ci-profile wall-clock 2786ms -> 1412ms (~1.97x). Adds 9 scheduler tests;
full suite vitest 158/158; manifest regenerated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SjcHn8jZErKo37ZJi6qybX
@sonarqubecloud

Copy link
Copy Markdown

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