Skip to content

A dispatched hosted workflow measures how many source worker copies one Loom process keeps served - #2196

Open
zlareb1 wants to merge 3 commits into
mainfrom
bench/mcp-source-worker-capacity
Open

zlareb1 wants to merge 3 commits into
mainfrom
bench/mcp-source-worker-capacity

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Related: #2165

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

None: a dispatched qualification workflow only.

Why

The source worker copy path keeps copies served only while each one's access is confirmed within knowledge_source_acl_stale_seconds. A process sends copies and checks one at a time within the mirrored phase, so the number of copies one deployment keeps served has a bound (the boundary page's Capacity paragraph), and nothing measures it yet. This workflow measures it on a free GitHub-hosted runner with owned synthetic upstreams, so the next change can be sized from numbers, not estimates. It measures; it gates nothing.

Scope and risk

  • Workflow: .github/workflows/mcp-source-worker-capacity.yml runs on workflow_dispatch only, on ubuntu-24.04, with a 90-minute limit and the same pinned action shas as ci.yml.

    • It starts ClickHouse and Postgres with dev/ci_start_*.sh, the fixture, and Loom from source with knowledge_source_worker_copies_enabled on. Loom's own sync worker is off, so the driver runs every pass.
    • It uploads the metrics JSON and the server, fixture and ClickHouse logs.
  • Fixture (bench/source_worker_copies_fixture.py), run in the source worker's own environment:

    • prepare writes keys and certificates, the worker config with a resource profile and a mapped-tool profile, the routes file, and one synthetic account per collection and profile.
    • serve runs the bundled worker's read and enrollment services behind an mTLS listener, the two synthetic MCP upstreams over TLS with configurable latency and fault kinds, and a loopback stats endpoint.
    • It assembles the worker's own services with an in-memory credential store and a direct listener, so Vault and the proxy are not measured. A credential-latency input stands in for the store.
  • Driver (bench/source_worker_copies.py):

    • Setup goes through the real operations: collection create, grant, worker profiles, approve, enroll, preview and register.
    • Session protection is declared only by the harness's own client, exactly as tests/integration/crawl_native_privacy.py does. No shipped client changes.
    • It runs run_sync() a fixed number of times in its own process and times each copy and check by wrapping the turn's exchange. A unit test pins both hooks so a rename fails loudly.
  • Metrics: schema loom.bench.source_worker_copies.v1, per pass and in total:

    • copy and check latency percentiles, and outcome counts;
    • copies confirmed, written and retired;
    • pass-bound marks, sources a pass did not reach, and whether the pass was cut;
    • per-turn seconds;
    • sources served, unserved or never listed, and lapses;
    • Loom-side overloaded and worker-side 429 counts;
    • setup op statuses and latency.

    The driver writes the whole document before setup, after setup and after every pass, so a stopped run keeps what it measured. A turn that raises is recorded as raised:<Type> and counts as reached, so sources_not_reached means only that the mirrored phase's time ran out first. It refuses runs whose passes times pass interval exceed 3600 s (the 75-minute step less a setup allowance). The run fails only on harness errors, which are recorded in the document, never on capacity figures.

  • LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDS is set to 60 although the server's own sync is off: the copy path's lapsing age reads it during every pass, so it shapes how a copy that keeps answering unsupported is retired. The workflow comment and the docs say so.

  • Docs: a "Source worker copy capacity" section in docs/benchmarks/running.md, an entry in bench/README.md, and one linking sentence in the boundary page's Capacity paragraph. No results are claimed.

What this harness could not do without a server change, for a later PR:

  • No operation or status exposes per-request latency, pass-bound marks or listing times, so the driver times the turn in its own process.
  • The bundled worker's entry point hard-codes its paths, credential store and socket, so the fixture assembles its services directly.
  • Worker 429s only appear when live reads compete for the worker's slots. This run sends none, so expect worker 429 counts near zero.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. Dispatch with, for example, gh workflow run mcp-source-worker-capacity.yml -f sources=200 -f resources=20. The inputs are listed in the docs section.
  • Rollback: reverting removes the workflow and its files.

Tests

  • tests/unit/test_bench_source_worker_copies.py (39 tests) covers the metrics schema, percentile math, input parsing and the run-length budget, the fault table, unreached sources counting as a cut pass, a raising turn counting as reached, an unexpected error keeping the finished passes, the document written after every pass, harness errors recorded in the document, and the two hooks the driver wraps.
  • Through the focused gate, together with test_public_copy.py and test_doc_links.py: 335 passed.
  • ruff format and ruff check on the new Python files, and the prose checker on the new doc section.
  • The fixture's prepare runs in the worker venv, and Loom's load_worker_routes loads its routes file. The upstream app answers each fault kind as expected when driven in-process.
  • The workflow itself has not run yet. It can only be dispatched once it is on the default branch, and the first dispatch is its end-to-end test.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the workflow, fixture, driver and tests. I set the scope (measure, do not gate; no shipped client declares session protection) and checked the setup path against the operations.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • No generated file is affected.
  • No migration.
  • No plugin-shipped file changed.
  • No frontend change.
  • Docs under docs/ describe the system as it now is.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off.

🤖 Generated with Claude Code


Note

Low Risk
Benchmark and CI-only additions with no production server or API wire changes; internal sync hooks are wrapped only inside the harness process.

Overview
Adds measurement-only CI for source worker copy capacity: how many owner-only worker copies a single Loom process can keep served under sync pass bounds.

A new manual-dispatch workflow (.github/workflows/mcp-source-worker-capacity.yml) boots ClickHouse, Postgres, Loom from the checkout (worker copies on, built-in sync off), a fixture that runs the bundled source worker plus two synthetic MCP upstreams, then bench/source_worker_copies.py. The driver registers sources via the real HTTP setup path, injects per-resource upstream faults after setup, and runs spaced run_sync() passes in-process while monkey-patching sync turn/exchange to record copy/check latency, pass cuts, listing lapses, and worker stats. Results land in source-worker-copies.json (loom.bench.source_worker_copies.v1); the run fails only on harness errors, not on capacity numbers. Docs (running.md, bench/README.md, architecture boundary) and unit tests for config, metrics shape, and the patch seams accompany the harness.

Reviewed by Cursor Bugbot for commit a18c1d3. Bugbot is set up for automated code reviews on this repo. Configure here.

…ne Loom process keeps served

The MCP source worker copy capacity workflow starts ClickHouse and Postgres, Loom
from the checkout with worker copies on, the bundled worker's read and enrollment
service and two owned synthetic MCP upstreams (resource and mapped tool) with set
latencies and per-resource faults. bench/source_worker_copies.py registers N
snapshot and selected_refresh sources of M resources each through the setup
operations, runs a fixed number of sync passes in its own process, and writes one
JSON file of fixed shape: per-copy and per-check latency, copies confirmed per
pass, listing lapses, pass bound marks and the worker's 429s. Only a harness error
fails the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 2:39am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 2:39am UTC

Request Review

@cursor cursor 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.

Stale Bugbot comment from a previous run.

LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED: "false"
LOOM_KNOWLEDGE_MIRRORED_SOURCES_ENABLED: "true"
LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED: "true"
LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDS: "60"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pass spacing ignores sync interval

Medium Severity

pass_interval is a workflow input and the driver spaces run_sync() with it, including back-to-back when it is 0. LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDS stays hardcoded at 60, and the copy turn uses that setting for how soon an unconfirmable copy would lapse before the next pass. A non-default spacing retires or keeps copies on a cadence the harness is not actually running, so served-copy and lapse figures no longer match the pass schedule.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8562ce. Configure here.

…its document through a stopped run

Every worker source is mirrored, so the pass result never records the mirrored
phase running out of time. The driver now counts the sources with no turn in a
pass (`sources_not_reached`, per pass and in total) and calls a pass cut when one
is left or a turn was cut. It writes the metrics document after every pass by
replacing the file whole, refuses passes times the pass interval beyond the
Measure step's budget less a setup allowance, records an HTTP failure or an
unreadable harness file as a harness error in the document instead of exiting
with a traceback, and reports per-turn time percentiles in place of turn
fields it never emitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f5fde3. Configure here.

Comment thread bench/source_worker_copies.py Resolved
Comment thread bench/source_worker_copies.py Resolved
…ts document through any failure

A turn the sync records as failed after it raised is now a recorded turn with the
status raised:<ExceptionName>, so it no longer counts as a source the pass ran
out of time before. Any failure of the run is recorded beside the passes already
finished instead of replacing them, and the document is written before and after
setup too. The running guide says what a pass bound mark means for each bound,
names the raised outcome and the ClickHouse log, wraps at the house width, and
says why the sync interval stays set though the server's sync is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
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