Skip to content

Fastlanes simpler workloops#1297

Merged
josephjclark merged 8 commits intofastlanesfrom
fastlanes-simpler-workloops
Mar 12, 2026
Merged

Fastlanes simpler workloops#1297
josephjclark merged 8 commits intofastlanesfrom
fastlanes-simpler-workloops

Conversation

@josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Mar 12, 2026

Simplifying the workloops implementation with the help of claude code.

The base branch is a bit too complex - too many moving parts - which makes it harder to think about.

Changes made:

  • Flattens the Workloop, WorkloopConfig and WorkloopHandle down into a single Workloop class. This manages its own state and removes the need for complex config and lookups. Way nicer!
  • Some test changes (the workloop tests really need to be serial, I think they're only passing through luck)
  • Tweaked CLI docs
  • Removed app.openClaims, which is now just spreading confusion yet is quite redundant

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Put required arguments first, optional args after
Since the Workloop inteface is just a static object, we should just create it at source in the parser. This removes some confusing typings and helps simplify the code. This miight enable a further refactor
@github-project-automation github-project-automation bot moved this to New Issues in Core Mar 12, 2026
A pretty big change that seriously simplifies the worklook handling. Each workloop is its own instance, created straight from the string config, which manages its own state
@josephjclark josephjclark changed the base branch from fastlanes to main March 12, 2026 15:53
@josephjclark josephjclark changed the base branch from main to fastlanes March 12, 2026 16:17
@josephjclark
Copy link
Collaborator Author

josephjclark commented Mar 12, 2026

that last commit has made integration tests go beserk. Bit concerned about this

Also seeing occasionally flaky fails on main actually - didI know about this? Right now I don't recall.

@josephjclark josephjclark merged commit cf6497f into fastlanes Mar 12, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from New Issues to Done in Core Mar 12, 2026
@josephjclark josephjclark deleted the fastlanes-simpler-workloops branch March 12, 2026 17:50
josephjclark pushed a commit that referenced this pull request Mar 13, 2026
* Add --queues CLI option for slot group configuration (#1288)

Introduce queue-aware slot allocation to support fast lanes. Workers can
now dedicate specific slots to specific queues via a new `--queues` flag
(e.g. `--queues "fast_lane:1 manual,*:4"`).

- Add parseQueues() with SlotGroup type and full validation
- Add --queues CLI option with WORKER_QUEUES env var support
- Enforce mutual exclusivity between --queues and --capacity
- Derive effectiveCapacity from slot groups in start.ts
- Add queues field to ClaimPayload in lexicon

* Review fixes: remove dead code, add TODO and duplicate queue warnings

- Remove unreachable ?? 5 fallback in start.ts (capacity always has default)
- Add TODO(#1289) for passing slotGroups to createWorker
- Warn on duplicate queue names within a preference chain
- Warn on identical queue configurations across slot groups
- Add test for WORKER_QUEUES + WORKER_CAPACITY env var mutual exclusivity

* Add changeset for queues CLI option

* Fix ws-worker build: make capacity non-optional in Args type

capacity always receives a default value via setArg, so the type
should reflect that rather than requiring a runtime fallback.

* Fix formatting for prettier

* Implement per-group workloops and queue-aware claiming (#1289)

Each slot group now gets its own independent workloop, tracks its own
active runs and capacity, and sends queue-scoped claims to Lightning.
The join payload includes a queues map so Lightning knows the slot
distribution. Default behavior (no --queues) is preserved with a single
manual,* group.

* Extract groupHasCapacity helper to consolidate repeated capacity checks

The pattern of computing pending claims and comparing against maxSlots
was duplicated 4 times across server.ts. Extracts it into a single
groupHasCapacity() function in parse-queues.ts with 5 unit tests.

* Consolidate redundant claim tests

Fold run-to-group tracking assertions into the existing execute test,
remove the redundant workloop-stop test (already covered), and drop
the now-covered todo.

* Fix formatting for prettier

* Fix CLI args ignored when invoked via pnpm start

pnpm v7+ passes the '--' separator through to process.argv, causing
yargs to treat all subsequent flags as positional arguments. Strip a
leading '--' before parsing so --queues and other flags work correctly
whether invoked via pnpm, npm, or directly.

* Add ES2021 lib to ws-worker tsconfig for Promise.any

The per-group workloops use Promise.any which requires ES2021 or later
in the TypeScript lib setting.

* Add JUnit XML test reporting for CircleCI Tests tab

Pipes AVA TAP output through tap-xunit to generate JUnit XML,
enabling test results to display in CircleCI's Tests UI.

* Fix tap-xunit not found by using npx

* Add per-package test:ci scripts for clean JUnit XML output

Each package now produces its own XML file instead of piping
combined pnpm -r output through tap-xunit, which was corrupted
by pnpm's interleaved logging.

* Fix "no tests found" warning in worker.test.ts

Remove redundant env var guard wrapping an already-skipped test.
AVA now sees the test as registered but skipped instead of finding
zero tests and emitting a warning that causes a non-zero exit.

* Refactor claim() to accept group as a standalone parameter

Move group from ClaimOptions to a required positional parameter,
making the function signature clearer about its dependencies.

* Rename slots/queues terminology to workloops and merge runtime types

- Rename --queues CLI option to --workloops (env: WORKER_WORKLOOPS)
- Change queue separator from comma to angle bracket (fast_lane>*:4)
- Rename SlotGroup → WorkloopConfig, maxSlots → capacity
- Merge RuntimeSlotGroup + Workloop into single Workloop interface
  with stub stop/isStopped that get overwritten by startWorkloop()
- Rename parse-queues.ts → parse-workloops.ts
- Update all imports, types, variable names, and tests

* Separate workloop parsing from runtime with WorkloopHandle pattern

Move Workloop, createWorkloop, and workloopHasCapacity out of
parse-workloops.ts (pure parsing) into api/workloop.ts (runtime).

startWorkloop now returns a WorkloopHandle { stop, isStopped } instead
of mutating the Workloop object. ServerApp stores handles in a
workloopHandles Map, keeping Workloop as pure state with no lifecycle
methods. Also fixes syntax error on claim.ts L81 and updates error
message expectations in tests.

* Fastlanes simpler workloops (#1297)
* remove app.openClaims, which is not useful anymore
josephjclark added a commit that referenced this pull request Mar 13, 2026
* cli: ensure --endpoint flag is respected in deploy

* fastlanes

* Add --queues CLI option for slot group configuration (#1288)

Introduce queue-aware slot allocation to support fast lanes. Workers can
now dedicate specific slots to specific queues via a new `--queues` flag
(e.g. `--queues "fast_lane:1 manual,*:4"`).

- Add parseQueues() with SlotGroup type and full validation
- Add --queues CLI option with WORKER_QUEUES env var support
- Enforce mutual exclusivity between --queues and --capacity
- Derive effectiveCapacity from slot groups in start.ts
- Add queues field to ClaimPayload in lexicon

* Review fixes: remove dead code, add TODO and duplicate queue warnings

- Remove unreachable ?? 5 fallback in start.ts (capacity always has default)
- Add TODO(#1289) for passing slotGroups to createWorker
- Warn on duplicate queue names within a preference chain
- Warn on identical queue configurations across slot groups
- Add test for WORKER_QUEUES + WORKER_CAPACITY env var mutual exclusivity

* Add changeset for queues CLI option

* Fix ws-worker build: make capacity non-optional in Args type

capacity always receives a default value via setArg, so the type
should reflect that rather than requiring a runtime fallback.

* Fix formatting for prettier

* Implement per-group workloops and queue-aware claiming (#1289)

Each slot group now gets its own independent workloop, tracks its own
active runs and capacity, and sends queue-scoped claims to Lightning.
The join payload includes a queues map so Lightning knows the slot
distribution. Default behavior (no --queues) is preserved with a single
manual,* group.

* Extract groupHasCapacity helper to consolidate repeated capacity checks

The pattern of computing pending claims and comparing against maxSlots
was duplicated 4 times across server.ts. Extracts it into a single
groupHasCapacity() function in parse-queues.ts with 5 unit tests.

* Consolidate redundant claim tests

Fold run-to-group tracking assertions into the existing execute test,
remove the redundant workloop-stop test (already covered), and drop
the now-covered todo.

* Fix formatting for prettier

* Fix CLI args ignored when invoked via pnpm start

pnpm v7+ passes the '--' separator through to process.argv, causing
yargs to treat all subsequent flags as positional arguments. Strip a
leading '--' before parsing so --queues and other flags work correctly
whether invoked via pnpm, npm, or directly.

* Add ES2021 lib to ws-worker tsconfig for Promise.any

The per-group workloops use Promise.any which requires ES2021 or later
in the TypeScript lib setting.

* Add JUnit XML test reporting for CircleCI Tests tab

Pipes AVA TAP output through tap-xunit to generate JUnit XML,
enabling test results to display in CircleCI's Tests UI.

* Fix tap-xunit not found by using npx

* Add per-package test:ci scripts for clean JUnit XML output

Each package now produces its own XML file instead of piping
combined pnpm -r output through tap-xunit, which was corrupted
by pnpm's interleaved logging.

* Fix "no tests found" warning in worker.test.ts

Remove redundant env var guard wrapping an already-skipped test.
AVA now sees the test as registered but skipped instead of finding
zero tests and emitting a warning that causes a non-zero exit.

* Refactor claim() to accept group as a standalone parameter

Move group from ClaimOptions to a required positional parameter,
making the function signature clearer about its dependencies.

* Rename slots/queues terminology to workloops and merge runtime types

- Rename --queues CLI option to --workloops (env: WORKER_WORKLOOPS)
- Change queue separator from comma to angle bracket (fast_lane>*:4)
- Rename SlotGroup → WorkloopConfig, maxSlots → capacity
- Merge RuntimeSlotGroup + Workloop into single Workloop interface
  with stub stop/isStopped that get overwritten by startWorkloop()
- Rename parse-queues.ts → parse-workloops.ts
- Update all imports, types, variable names, and tests

* Separate workloop parsing from runtime with WorkloopHandle pattern

Move Workloop, createWorkloop, and workloopHasCapacity out of
parse-workloops.ts (pure parsing) into api/workloop.ts (runtime).

startWorkloop now returns a WorkloopHandle { stop, isStopped } instead
of mutating the Workloop object. ServerApp stores handles in a
workloopHandles Map, keeping Workloop as pure state with no lifecycle
methods. Also fixes syntax error on claim.ts L81 and updates error
message expectations in tests.

* Fastlanes simpler workloops (#1297)
* remove app.openClaims, which is not useful anymore

* possible flaky test fix

* CLI: Fix issue when running deploy with no locally changed workflows (#1287)

* added a unit test for deploying a new project

* remove only

* enable mock lightning to load a project from yaml

* update tests

* failed attempt to repro

* fix issue where a project with no local diffs can wrongly report diffs on deploy]#

* fix types

* fix tests

* approve builds

* fix test

* remove dev log

* revert dev log

* fix lockfile

* tweak test code for stability

* another stability test tweak

* versions

---------

Co-authored-by: Stuart Corbishley <corbish@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant