Skip to content

Commit dd97b0d

Browse files
committed
chore(bootstrap): publishing metadata, required registry param, exports test, docs
Follow-up polish on the @workglow/bootstrap extraction. No correctness, security, or data-integrity change — the registration set and order are untouched. - Add the missing `license` field (Apache-2.0) and a LICENSE file. The package sets `publishConfig.access: "public"` and its sources carry SPDX Apache-2.0 headers, but npm would have listed it as unlicensed. (Note: no other workspace in this repo declares a `license` field either — a repo-wide sweep is worth doing separately.) - Align the version to 0.3.38. It was 0.3.37 while root and all 13 siblings were 0.3.38, so `bunset --patch --all` would have opened a permanent one-patch offset between bootstrap and everything that depends on it. - Make `registerAllDefaults(registry)` required again, as it was when the function was module-private. It mutates whichever container it is handed, and it is now exported three ways; a defaulted global turns "installed defaults on the wrong registry" from a compile error into silent behavior. This matches the repo convention of forcing callers to be explicit rather than defaulting. - `vitest.setup.ts` now calls `bootstrapWorkglow()` (equivalent with no logger option). It cannot pass `globalServiceRegistry` explicitly: `@workglow/util` does not resolve from the repo root under the isolated linker, and importing `packages/util/src` directly would load a second copy of the module and populate a different registry object than the tests read. - Add `packages/test/src/test/util/BootstrapPackageExports.test.ts`, covering the published contract: every `exports` leaf resolves to a file that exists, and the node entry point really exports the bootstrap API. Nothing in CI exercised the build output before, so a typo'd exports path or a build that emitted nothing would have shipped silently. - Add README (including the all-defaults dependency-weight tradeoff) and CHANGELOG, and document the package in .claude/CLAUDE.md so contributors add registrations here rather than in the now-inert re-export shim. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 37d71db commit dd97b0d

8 files changed

Lines changed: 461 additions & 5 deletions

File tree

.claude/CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dataset, tasks (KnowledgeBase, documents, chunks; utility
5151
5252
ai (AI task base classes, model registry, provider helpers)
5353
54+
bootstrap (installs every built-in default onto a service registry)
5455
providers/* (concrete provider implementations: anthropic, openai, gemini, ollama, ...)
5556
5657
test (integration tests across all packages)
@@ -230,6 +231,16 @@ chat-vs-prompt). Schema invariants (e.g. `TextGenerationTask` requires
230231

231232
Pre-built tasks: `InputTask`, `OutputTask`, `LambdaTask`, `DelayTask`, `FetchUrlTask`, `JavaScriptTask`, `JsonTask`, `MergeTask`, `SplitTask`, `ArrayTask`, MCP tasks, scalar/vector math tasks. Register all via `registerCommonTasks()`.
232233

234+
### `@workglow/bootstrap` — default registration
235+
236+
Nothing self-registers at import time, so a runtime has to install the defaults before any task runs. This package is that seam, and **the implementation lives here**`packages/workglow/src/bootstrap.ts` is now a pure `export * from "@workglow/bootstrap"` re-export shim. Add a new default registration in `packages/bootstrap/src/bootstrap/registerAllDefaults.ts`; editing the shim does nothing.
237+
238+
- `bootstrapWorkglow(opts?)` — installs defaults onto the global registry, idempotent. The normal application entry point.
239+
- `createOrchestrationContext(opts?)` — a fresh, disposable registry backed by its own container (tests, multi-tenant servers, embedded use).
240+
- `registerAllDefaults(registry)` — the 14 `register*Defaults` calls in dependency order. The registry parameter is **required**: the function mutates whichever container it is handed, so the target is stated at the call site rather than silently defaulting to the global one.
241+
242+
`vitest.setup.ts` calls `bootstrapWorkglow()` by source path — the isolated linker keeps workspace packages out of the repo root's `node_modules`, so neither `@workglow/bootstrap` nor `@workglow/util` resolves from there.
243+
233244
## Testing patterns
234245

235246
Tests live primarily in `packages/test/src/test/`. Both `bun test` and `vitest` are used.

packages/bootstrap/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
## 0.3.38
4+
5+
### Features
6+
7+
#### bootstrap
8+
9+
- Initial release. `registerAllDefaults`, `bootstrapWorkglow`, and
10+
`createOrchestrationContext` moved here from the `workglow` meta-package and
11+
from the test harness's private `bootstrapTestRegistry`, which had drifted
12+
into two copies of the same 14 registration calls.
13+
- `registerAllDefaults(registry)` takes a **required** registry. It mutates
14+
whichever container it is handed, so the target is always stated at the call
15+
site rather than defaulting to the global one.

packages/bootstrap/LICENSE

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by
13+
the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all
16+
other entities that control, are controlled by, or are under common
17+
control with that entity. For the purposes of this definition,
18+
"control" means (i) the power, direct or indirect, to cause the
19+
direction or management of such entity, whether by contract or
20+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+
outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity
24+
exercising permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation
28+
source, and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical
31+
transformation or translation of a Source form, including but
32+
not limited to compiled object code, generated documentation,
33+
and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based on (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and Derivative Works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to reproduce, prepare Derivative Works of,
70+
publicly display, publicly perform, sublicense, and distribute the
71+
Work and such Derivative Works in Source or Object form.
72+
73+
3. Grant of Patent License. Subject to the terms and conditions of
74+
this License, each Contributor hereby grants to You a perpetual,
75+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+
(except as stated in this section) patent license to make, have made,
77+
use, offer to sell, sell, import, and otherwise transfer the Work,
78+
where such license applies only to those patent claims licensable
79+
by such Contributor that are necessarily infringed by their
80+
Contribution(s) alone or by combination of their Contribution(s)
81+
with the Work to which such Contribution(s) was submitted. If You
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
105+
106+
(d) If the Work includes a "NOTICE" text file as part of its
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+
of the NOTICE file are for informational purposes only and
117+
do not modify the License. You may add Your own attribution
118+
notices within Derivative Works that You distribute, alongside
119+
or as an addendum to the NOTICE text from the Work, provided
120+
that such additional attribution notices cannot be construed
121+
as modifying the License.
122+
123+
You may add Your own copyright statement to Your modifications and
124+
may provide additional or different license terms and conditions
125+
for use, reproduction, or distribution of Your modifications, or
126+
for any such Derivative Works as a whole, provided Your use,
127+
reproduction, and distribution of the Work otherwise complies with
128+
the conditions stated in this License.
129+
130+
5. Submission of Contributions. Unless You explicitly state otherwise,
131+
any Contribution intentionally submitted for inclusion in the Work
132+
by You to the Licensor shall be under the terms and conditions of
133+
this License, without any additional terms or conditions.
134+
Notwithstanding the above, nothing herein shall supersede or modify
135+
the terms of any separate license agreement you may have executed
136+
with Licensor regarding such Contributions.
137+
138+
6. Trademarks. This License does not grant permission to use the trade
139+
names, trademarks, service marks, or product names of the Licensor,
140+
except as required for reasonable and customary use in describing the
141+
origin of the Work and reproducing the content of the NOTICE file.
142+
143+
7. Disclaimer of Warranty. Unless required by applicable law or
144+
agreed to in writing, Licensor provides the Work (and each
145+
Contributor provides its Contributions) on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+
implied, including, without limitation, any warranties or conditions
148+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+
PARTICULAR PURPOSE. You are solely responsible for determining the
150+
appropriateness of using or redistributing the Work and assume any
151+
risks associated with Your exercise of permissions under this License.
152+
153+
8. Limitation of Liability. In no event and under no legal theory,
154+
whether in tort (including negligence), contract, or otherwise,
155+
unless required by applicable law (such as deliberate and grossly
156+
negligent acts) or agreed to in writing, shall any Contributor be
157+
liable to You for damages, including any direct, indirect, special,
158+
incidental, or consequential damages of any character arising as a
159+
result of this License or out of the use or inability to use the
160+
Work (including but not limited to damages for loss of goodwill,
161+
work stoppage, computer failure or malfunction, or any and all
162+
other commercial damages or losses), even if such Contributor
163+
has been advised of the possibility of such damages.
164+
165+
9. Accepting Warranty or Additional Liability. While redistributing
166+
the Work or Derivative Works thereof, You may choose to offer,
167+
and charge a fee for, acceptance of support, warranty, indemnity,
168+
or other liability obligations and/or rights consistent with this
169+
License. However, in accepting such obligations, You may act only
170+
on Your own behalf and on Your sole responsibility, not on behalf
171+
of any other Contributor, and only if You agree to indemnify,
172+
defend, and hold each Contributor harmless for any liability
173+
incurred by, or claims asserted against, such Contributor by reason
174+
of your accepting any such warranty or additional liability.
175+
176+
END OF TERMS AND CONDITIONS
177+
178+
APPENDIX: How to apply the Apache License to your work.
179+
180+
To apply the Apache License to your work, attach the following
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182+
replaced with your own identifying information. (Don't include
183+
the brackets!) The text should be enclosed in the appropriate
184+
comment syntax for the file format. We also recommend that a
185+
file or class name and description of purpose be included on the
186+
same "printed page" as the copyright notice for easier
187+
identification within third-party archives.
188+
189+
Copyright 2025 Steven Roussey
190+
191+
Licensed under the Apache License, Version 2.0 (the "License");
192+
you may not use this file except in compliance with the License.
193+
You may obtain a copy of the License at
194+
195+
http://www.apache.org/licenses/LICENSE-2.0
196+
197+
Unless required by applicable law or agreed to in writing, software
198+
distributed under the License is distributed on an "AS IS" BASIS,
199+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200+
See the License for the specific language governing permissions and
201+
limitations under the License.

packages/bootstrap/README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# @workglow/bootstrap
2+
3+
Runtime bootstrap for Workglow: registers every built-in default onto a service registry.
4+
5+
Workglow does not self-register defaults at import time. Something has to install
6+
the logger, telemetry, worker-manager, credential, model, provider, knowledge-base,
7+
MCP, storage, task, and transform factories before any task runs — this package is
8+
that something, sitting below both the `workglow` meta-package and the test harness
9+
so neither has to own its own copy.
10+
11+
## Installation
12+
13+
```bash
14+
npm install @workglow/bootstrap
15+
# or
16+
bun add @workglow/bootstrap
17+
```
18+
19+
## Usage
20+
21+
### Global runtime
22+
23+
Call once at application startup, before running any task.
24+
25+
```typescript
26+
import { bootstrapWorkglow } from "@workglow/bootstrap";
27+
28+
bootstrapWorkglow();
29+
```
30+
31+
Pass a logger to replace the env-driven default:
32+
33+
```typescript
34+
import { bootstrapWorkglow } from "@workglow/bootstrap";
35+
import { TsLogLogger } from "workglow";
36+
37+
bootstrapWorkglow({ logger: new TsLogLogger() });
38+
```
39+
40+
`bootstrapWorkglow()` is idempotent — defaults register with `registerIfAbsent`,
41+
so an earlier explicit registration (a custom storage backend, say) is never
42+
overwritten, and repeat calls are harmless.
43+
44+
### Isolated context
45+
46+
For tests, multi-tenant servers, and embedded use: a fresh registry backed by its
47+
own container, disposable without touching global state.
48+
49+
```typescript
50+
import { createOrchestrationContext } from "@workglow/bootstrap";
51+
52+
const ctx = createOrchestrationContext();
53+
try {
54+
await task.run({ context: ctx });
55+
} finally {
56+
await ctx.dispose();
57+
}
58+
```
59+
60+
### Registering onto a registry you already have
61+
62+
```typescript
63+
import { registerAllDefaults } from "@workglow/bootstrap";
64+
import { globalServiceRegistry } from "@workglow/util";
65+
66+
registerAllDefaults(globalServiceRegistry);
67+
```
68+
69+
The registry parameter is **required**, deliberately. The function mutates
70+
whichever container it is handed, so which one that is belongs at the call site —
71+
a defaulted global would let a caller reach for an isolated context and silently
72+
mutate process-wide state instead. Prefer `bootstrapWorkglow()` or
73+
`createOrchestrationContext()`; reach for `registerAllDefaults` only when the
74+
registry is one you constructed yourself.
75+
76+
## Dependency weight
77+
78+
This package registers **all** defaults by design — that is the whole point of a
79+
single bootstrap seam, and splitting it into per-tier entry points would just move
80+
the drift problem it was extracted to solve. The cost is that it depends on
81+
`@workglow/ai`, `@workglow/knowledge-base`, and `@workglow/mcp`, and the last of
82+
those carries a hard runtime dependency on `@modelcontextprotocol/sdk`. A consumer
83+
that wants only, say, logger + task + storage defaults therefore installs the MCP
84+
SDK and the full AI layer for nothing.
85+
86+
If that weight matters, do not depend on this package. Call the individual
87+
`register*Defaults(registry)` functions directly from the packages you actually
88+
use — they are all exported, and `registerAllDefaults` is nothing more than the
89+
14 of them in dependency order:
90+
91+
```typescript
92+
import { registerTabularStorageDefaults } from "@workglow/storage";
93+
import { registerTaskDefaults } from "@workglow/task-graph";
94+
import { registerLoggerDefaults } from "@workglow/util";
95+
96+
registerLoggerDefaults(registry);
97+
registerTabularStorageDefaults(registry);
98+
registerTaskDefaults(registry);
99+
```
100+
101+
Order matters: the primitive containers (input resolvers/compactors, logger,
102+
telemetry, worker manager) must register before anything that stores into them.
103+
See `src/bootstrap/registerAllDefaults.ts` for the canonical ordering.
104+
105+
## Relationship to `workglow`
106+
107+
`packages/workglow/src/bootstrap.ts` is a pure re-export of this package, so
108+
`workglow/bootstrap` and the `workglow` root barrel keep exposing the same API.
109+
Add a new default registration **here**, not there.
110+
111+
## License
112+
113+
Apache 2.0 - See [LICENSE](./LICENSE) for details.

packages/bootstrap/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@workglow/bootstrap",
33
"type": "module",
4-
"version": "0.3.37",
4+
"version": "0.3.38",
5+
"license": "Apache-2.0",
56
"repository": {
67
"type": "git",
78
"url": "https://github.com/workglow-dev/libs.git",

packages/bootstrap/src/bootstrap/registerAllDefaults.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { registerMcpServerDefaults } from "@workglow/mcp/util";
1010
import { registerTabularStorageDefaults } from "@workglow/storage";
1111
import { registerTaskDefaults, registerTransformDefaults } from "@workglow/task-graph";
1212
import {
13-
globalServiceRegistry,
1413
registerCredentialDefaults,
1514
registerInputCompactorDefaults,
1615
registerInputResolverDefaults,
@@ -28,8 +27,13 @@ import { registerWorkerManagerDefaults } from "@workglow/util/worker";
2827
* Idempotent — safe to call multiple times. `registerIfAbsent` ensures
2928
* earlier explicit registrations (e.g. a custom storage backend) are not
3029
* overwritten.
30+
*
31+
* The registry is required, never defaulted: this mutates whichever container
32+
* it is handed, so the target is always stated at the call site. Pass
33+
* `globalServiceRegistry` explicitly for process-wide defaults, or
34+
* prefer `bootstrapWorkglow()` / `createOrchestrationContext()`.
3135
*/
32-
export function registerAllDefaults(registry: ServiceRegistry = globalServiceRegistry): void {
36+
export function registerAllDefaults(registry: ServiceRegistry): void {
3337
// Primitive containers first — resolvers/compactors are stored in maps
3438
// registered by these calls.
3539
registerInputResolverDefaults(registry);

0 commit comments

Comments
 (0)