@ruvector/ruvllm-gpu-loop 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GPU-LOOP.md +232 -0
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +204 -2
- package/examples/gpu-loop.example.json +26 -0
- package/package.json +69 -4
- package/src/adapters-cli.mjs +23 -0
- package/src/adapters.mjs +91 -0
- package/src/cli.mjs +30 -0
- package/src/engine.mjs +238 -0
- package/src/fixture.mjs +38 -0
- package/src/gpu-host.mjs +47 -0
- package/src/gpu-loop-cli.mjs +67 -0
- package/src/gpu-loop.mjs +184 -0
- package/src/gpu-spool-adapter.mjs +80 -0
- package/src/vast-host-adapter.mjs +274 -0
package/GPU-LOOP.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Scheduled GPU job loop
|
|
2
|
+
|
|
3
|
+
Run a durable GPU job queue from the CLI, Claude Code or a Ruflo MCP host.
|
|
4
|
+
The scheduler can be developed and contract-tested without live ruOS/Vast.ai
|
|
5
|
+
access. A host adapter owns real provider calls and uses its existing ruOS
|
|
6
|
+
authentication to resolve **secret references**, never export credential values.
|
|
7
|
+
|
|
8
|
+
This release implements the schedule, durable state, reservations, host loader,
|
|
9
|
+
file handoff, MCP tools and a live [Vast.ai host adapter](src/vast-host-adapter.mjs)
|
|
10
|
+
([ADR 017](../../docs/adr/ADR-017-vast-host-adapter-and-live-paired-run.md)). That
|
|
11
|
+
adapter has run paired evaluations and a training job end to end on rented GPUs,
|
|
12
|
+
with local re-scoring and confirmed cleanup. It does not include a live ruOS
|
|
13
|
+
connector or invent a secrets-service endpoint. No GPU rental or model download is
|
|
14
|
+
started by installing the package. A zero-budget sample is disarmed.
|
|
15
|
+
|
|
16
|
+
## Operator configuration
|
|
17
|
+
|
|
18
|
+
Install the existing [integration](README.md), then prepare a private directory
|
|
19
|
+
and copy [gpu-loop.example.json](examples/gpu-loop.example.json) outside your
|
|
20
|
+
output directories. Keep the config owner-only (`chmod 600`); create its
|
|
21
|
+
`stateRoot` with mode 700. Use canonical absolute paths without symlinks.
|
|
22
|
+
|
|
23
|
+
Edit the example's paths, model pin, resource ID and `secretRef`. The example
|
|
24
|
+
secret alias and instance ID are placeholders, not discovered ruOS resources.
|
|
25
|
+
Keep `budgetUsd: 0` until a spending ceiling is explicitly chosen. Merely reading
|
|
26
|
+
status does not submit work. A zero-budget tick records a budget-limit failure
|
|
27
|
+
and never calls the provider. Use a new state directory for a new reviewed
|
|
28
|
+
configuration; state binds the config's exact byte digest.
|
|
29
|
+
|
|
30
|
+
Configuration fields:
|
|
31
|
+
|
|
32
|
+
| Field | Meaning |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `intervalSeconds` | Polling cadence, 1–86400 seconds; active deadlines and pending cleanup can become due sooner |
|
|
35
|
+
| `maxAttempts` | Maximum attempts per job, 1–10; retries require confirmed cleanup |
|
|
36
|
+
| `budgetUsd` | Total conservative admission budget in exact microdollars; zero disarms submissions |
|
|
37
|
+
| `jobs` | 1–128 fixed operator-approved jobs |
|
|
38
|
+
| `model` | Exact `repo` and 40-character model revision |
|
|
39
|
+
| `task` | `evaluate` or `train`; the host must implement that workload |
|
|
40
|
+
| `secretRef` | Opaque alias resolved only by the authenticated host |
|
|
41
|
+
| `resource` | Exactly one string `instanceId` or `offerId`; no automatic offer selection |
|
|
42
|
+
| `maxCostUsd` | Reserved cost ceiling for each attempt; never refunded automatically |
|
|
43
|
+
| `timeoutSeconds` | Per-attempt deadline, 1–86400 seconds |
|
|
44
|
+
| `experiment` | Optional absolute `configPath`/`planPath` for the host to execute using the native experiment workflow |
|
|
45
|
+
|
|
46
|
+
The schedule advances a finite queue. It does not reset succeeded jobs or start
|
|
47
|
+
unlimited training cycles. Another experiment cycle needs a new reviewed config
|
|
48
|
+
and state root. Reservations limit admitted work; they cannot impose a hard cap
|
|
49
|
+
on Vast billing. The host must separately enforce actual spend and worker runtime.
|
|
50
|
+
|
|
51
|
+
## Host adapter
|
|
52
|
+
|
|
53
|
+
The host module must be a canonical, owner-only `.mjs` file pinned by SHA256.
|
|
54
|
+
Its entire transitive dependency tree is trusted operator code. No provider effects
|
|
55
|
+
or secret logging may occur at import: all effects belong in the methods below.
|
|
56
|
+
This interface is supplied by RuVLLM; these names are not claimed ruOS API methods.
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
export async function submit({ job, idempotencyKey, signal }) {
|
|
60
|
+
// Resolve job.secretRef at the authenticated host. Submit OR find the exact
|
|
61
|
+
// existing job by idempotencyKey. Enforce timeout/cost before starting work.
|
|
62
|
+
// Return only a bounded provider run identifier, never credential material.
|
|
63
|
+
return { runId };
|
|
64
|
+
}
|
|
65
|
+
export async function inspect({ job, runId, idempotencyKey, signal }) {
|
|
66
|
+
// Read the real executor's structured evidence. Do not trust worker stdout.
|
|
67
|
+
return { status: 'running' }; // Or failed/completed with costUsd and completion.
|
|
68
|
+
}
|
|
69
|
+
export async function cleanup({ job, runId, signal }) {
|
|
70
|
+
// Stop/release only this job's allocation. Do not destroy a shared instance.
|
|
71
|
+
// Confirm absence/release through the provider before returning true.
|
|
72
|
+
return { released: false };
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The snippet is an interface illustration, not a runnable provider implementation.
|
|
77
|
+
Use the host's actual supported ruOS secrets and Vast execution routes. Honor
|
|
78
|
+
AbortSignal and implement idempotent submit/cleanup. A thrown/late/ambiguous submit
|
|
79
|
+
blocks automatic resubmission, since a provider may already have allocated a GPU.
|
|
80
|
+
|
|
81
|
+
A completed result needs this structured contract, derived by the trusted host:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"status": "completed",
|
|
86
|
+
"costUsd": 0.25,
|
|
87
|
+
"completion": {
|
|
88
|
+
"completionVersion": 1,
|
|
89
|
+
"completionVerified": true,
|
|
90
|
+
"status": "ok",
|
|
91
|
+
"exitCode": 0,
|
|
92
|
+
"assertionsVerified": true,
|
|
93
|
+
"evidenceComplete": true,
|
|
94
|
+
"truncated": false,
|
|
95
|
+
"jobId": "EXACT_JOB_ID",
|
|
96
|
+
"modelRepo": "Qwen/Qwen3.5-4B",
|
|
97
|
+
"modelRevision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
|
|
98
|
+
"runId": "EXACT_CURRENT_RUN_ID",
|
|
99
|
+
"idempotencyKey": "EXACT_CURRENT_ATTEMPT_KEY"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Boolean flags are structural checks, not cryptographic attestation. Bind evidence
|
|
105
|
+
to the actual run and retain raw measurements at the host. An old attempt's reply,
|
|
106
|
+
wrong model, missing assertions or unverified completion cannot mark a job
|
|
107
|
+
successful. Terminal success also requires explicit resource-release confirmation.
|
|
108
|
+
|
|
109
|
+
## Concrete file handoff
|
|
110
|
+
|
|
111
|
+
For a ruOS-side scheduled consumer, use the bundled
|
|
112
|
+
`src/gpu-spool-adapter.mjs`. Set `RUVLLM_GPU_SPOOL_ROOT` to an existing private
|
|
113
|
+
canonical directory. This adapter performs **no provider calls**; it hands work
|
|
114
|
+
to a host sharing that directory, or a securely synchronized copy of the files.
|
|
115
|
+
Transfer and remote authentication are separate host responsibilities.
|
|
116
|
+
|
|
117
|
+
For each persisted attempt key, files are:
|
|
118
|
+
|
|
119
|
+
| File | Writer and schema |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `KEY.request.json` | Scheduler: `ruvllm-gpu-spool-request/v1`, `runId`, `job`, credential-handling notice |
|
|
122
|
+
| `KEY.status.json` | Host: `ruvllm-gpu-spool-status/v1`, matching `runId`, status, optional cost/completion |
|
|
123
|
+
| `KEY.cleanup-request.json` | Scheduler: `ruvllm-gpu-spool-cleanup-request/v1`, `runId`, `jobId` |
|
|
124
|
+
| `KEY.cleanup.json` | Host: `ruvllm-gpu-spool-cleanup/v1`, matching `runId`, boolean `released` |
|
|
125
|
+
|
|
126
|
+
All files must be owner-only, regular, nonsymlink files of at most 64 KiB. The
|
|
127
|
+
host should publish replies atomically. Repeated identical requests are idempotent;
|
|
128
|
+
conflicting contents under the same key are rejected. No status reply means
|
|
129
|
+
pending/running, not success. Missing cleanup acknowledgement keeps cleanup
|
|
130
|
+
pending. The request's `secretRef` is an alias; no credential belongs in any file.
|
|
131
|
+
|
|
132
|
+
Example local bindings (operator paths, not secrets):
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
export RUVLLM_GPU_LOOP_CONFIG=/absolute/private/gpu-loop.json
|
|
136
|
+
export RUVLLM_GPU_SPOOL_ROOT=/absolute/private/gpu-spool
|
|
137
|
+
export RUVLLM_GPU_HOST_MODULE="$PWD/integrations/metaharness/src/gpu-spool-adapter.mjs"
|
|
138
|
+
chmod 600 "$RUVLLM_GPU_HOST_MODULE"
|
|
139
|
+
export RUVLLM_GPU_HOST_SHA256="$(shasum -a 256 "$RUVLLM_GPU_HOST_MODULE" | awk '{print $1}')"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Prepare the private spool/state directories and config before ticking. The
|
|
143
|
+
source module's chmod is needed after a normal Git checkout because host modules
|
|
144
|
+
are deliberately required to be owner-only. A custom trusted module can replace
|
|
145
|
+
the spool adapter; recalculate and review its pin after any code change.
|
|
146
|
+
|
|
147
|
+
## Vast.ai host adapter
|
|
148
|
+
|
|
149
|
+
`src/vast-host-adapter.mjs` is a real provider adapter (see
|
|
150
|
+
[ADR 017](../../docs/adr/ADR-017-vast-host-adapter-and-live-paired-run.md)). Set
|
|
151
|
+
`RUVLLM_VAST_HOST_CONFIG` to an owner-only `ruvllm-vast-host/v1` file:
|
|
152
|
+
|
|
153
|
+
| Field | Meaning |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| `apiBase` | `https://console.vast.ai` |
|
|
156
|
+
| `secrets` | `{ "<secretRef>": { "file": "/abs/owner-only/key" } }`; the key is sent only as a Bearer header |
|
|
157
|
+
| `image` | Container image pinned by digest |
|
|
158
|
+
| `repoUrl`, `commit`, `bundle` | Public checkout and exact commit the rental runs; frozen bundle name |
|
|
159
|
+
| `diskGb`, `armDeadlineSeconds` | Rental disk; per-arm worker deadline |
|
|
160
|
+
| `guardGraceSeconds` | Extra time after `timeoutSeconds` before the independent destroy timer fires |
|
|
161
|
+
| `resultsRoot`, `sshKey`, `repoRoot`, `python`, `node` | Absolute local paths for receipts, retrieval and local re-scoring |
|
|
162
|
+
|
|
163
|
+
Jobs must use `resource.offerId`. Submit refuses the offer when its hourly price
|
|
164
|
+
times `timeoutSeconds` exceeds `maxCostUsd`, labels the rental with the attempt's
|
|
165
|
+
idempotency key, and arms a `systemd-run --user` destroy timer. Inspect reports
|
|
166
|
+
accrued cost, pulls raw outputs when the remote run is done, and re-scores them
|
|
167
|
+
locally; only an identical report counts as verified completion. Cleanup returns
|
|
168
|
+
`released: true` only after the instance is absent from the account listing.
|
|
169
|
+
Receipts (`submission.json`, `progress.json`, `verification.json`,
|
|
170
|
+
`cleanup-ID.json`, `guard-ID.json`) contain no credential. Copy the module to a
|
|
171
|
+
private owner-only path and pin that copy's SHA256, as for any host module.
|
|
172
|
+
|
|
173
|
+
## CLI and loop schedule
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
node integrations/metaharness/src/gpu-loop-cli.mjs status --config "$RUVLLM_GPU_LOOP_CONFIG"
|
|
177
|
+
node integrations/metaharness/src/gpu-loop-cli.mjs tick \
|
|
178
|
+
--config "$RUVLLM_GPU_LOOP_CONFIG" \
|
|
179
|
+
--adapter "$RUVLLM_GPU_HOST_MODULE" --adapter-sha256 "$RUVLLM_GPU_HOST_SHA256"
|
|
180
|
+
node integrations/metaharness/src/gpu-loop-cli.mjs run \
|
|
181
|
+
--config "$RUVLLM_GPU_LOOP_CONFIG" \
|
|
182
|
+
--adapter "$RUVLLM_GPU_HOST_MODULE" --adapter-sha256 "$RUVLLM_GPU_HOST_SHA256" \
|
|
183
|
+
--max-ticks 60
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`run` defaults to one tick, caps the count at 10000, and waits until the next due
|
|
187
|
+
poll/deadline/cleanup step. SIGINT/SIGTERM stops between ticks; it does not erase
|
|
188
|
+
running work. State survives restarts. Alternatively, have the operator's existing
|
|
189
|
+
scheduler invoke `tick`; overlapping processes refuse the exclusive lock. A coarse
|
|
190
|
+
external interval can delay cleanup, so the host must always enforce its own
|
|
191
|
+
deadline. No cron entry or background process is installed automatically.
|
|
192
|
+
|
|
193
|
+
## Claude Code and Ruflo
|
|
194
|
+
|
|
195
|
+
Load [ruflo-metaharness](../../plugins/ruflo-metaharness/README.md) with the four
|
|
196
|
+
bindings above in its process environment. `gpu_loop_status` and `gpu_loop_tick`
|
|
197
|
+
take `{}` only. Configuration, host code and budget cannot come from tool args.
|
|
198
|
+
The `/ruflo-metaharness:gpu-loop` command checks status and advances a tick within
|
|
199
|
+
the operator's configured scope. Ruflo can use the same MCP server and bindings.
|
|
200
|
+
|
|
201
|
+
If the Claude host supports recurring `/loop`, it can repeatedly invoke this command:
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
/loop 1m /ruflo-metaharness:gpu-loop
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
That host-specific facility was not E2E-tested here. The durable scheduler still
|
|
208
|
+
enforces its own due time, budget, lock and submission state across host restarts.
|
|
209
|
+
Existing native experiment tools remain separate; no schedule grants activation.
|
|
210
|
+
|
|
211
|
+
## Reconciliation and validation
|
|
212
|
+
|
|
213
|
+
`blocked` means the submit outcome is uncertain. `cleanup` means resource release
|
|
214
|
+
has not yet been confirmed. Do not delete state or launch a replacement rental
|
|
215
|
+
to make either status disappear. Use the saved key/run ID to inspect the actual
|
|
216
|
+
host/provider, reconcile its resources, and only then repair state or prepare a
|
|
217
|
+
new reviewed cycle. A crash may leave `tick.lock`; it is never auto-broken.
|
|
218
|
+
|
|
219
|
+
Run the local scheduler/host/spool tests and all plugin wire tests through the
|
|
220
|
+
existing `npm test`/Node commands. Test adapters and host files are explicitly
|
|
221
|
+
mock contracts; no secrets, provider, model inference or GPU E2E is exercised.
|
|
222
|
+
The [ADR](../../docs/adr/ADR-015-scheduled-gpu-loop-and-host-secret-boundary.md)
|
|
223
|
+
records the state machine, failure paths and threat boundary.
|
|
224
|
+
|
|
225
|
+
Validation on 2026-11-03: **60 local tests passed**, with no failures or skips:
|
|
226
|
+
17 scheduler tests, 8 host/CLI tests, 3 spool tests (including the scheduled
|
|
227
|
+
handoff), 3 new GPU MCP wire tests, and the original 29 integration/plugin tests.
|
|
228
|
+
The long-interval deadline test uses a 60-second cadence and a one-second job
|
|
229
|
+
deadline and confirms cleanup becomes due without waiting the full cadence.
|
|
230
|
+
Repository integrity and unchanged native-source provenance checks also passed.
|
|
231
|
+
Live ruOS/Vast.ai, actual Claude `/loop`, secrets resolution and GPU inference/
|
|
232
|
+
training remain deliberately unrun. Existing CI test globs include these tests.
|
package/LICENSE
ADDED
|
@@ -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 2026 Alibaba Cloud
|
|
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.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
RuFlo Code Model
|
|
2
|
+
Copyright 2026 rUv and contributors
|
|
3
|
+
|
|
4
|
+
Original experiment code and synthetic tool traces are licensed under Apache 2.0.
|
|
5
|
+
Base model: Qwen/Qwen3.5-4B, Apache 2.0, owned by the Qwen team.
|
|
6
|
+
HumanEval data in data/external is MIT licensed; see HumanEval.LICENSE.
|
|
7
|
+
MLX LM, Transformers, PEFT, and Claude Code Router retain their respective licenses.
|
|
8
|
+
Claude Code is a separate proprietary client. No Claude model weights or private
|
|
9
|
+
Claude training data are included. This project is not endorsed by Anthropic.
|
package/README.md
CHANGED
|
@@ -1,3 +1,205 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MetaHarness weight experiments
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center"><img src="https://raw.githubusercontent.com/ruvnet/ruvllm/ruvllm-npm-v4.0.1/docs/assets/gpu-job-loop.svg" alt="The GPU job loop checks a spending ceiling, rents the offer and arms a destroy timer, runs the pinned job, pulls raw outputs, checks them locally, then destroys the rental and confirms it is gone." width="100%"></p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/ruvnet/ruvllm/ruvllm-npm-v4.0.1/docs/assets/heldout-results.svg" alt="Held-out results on 256 untouched tasks: tool passes 149, 176 and 192 of 192 for base, coding-4b and coding-4b-r2; arithmetic 62, 64 and 46 of 64. coding-4b is kept; coding-4b-r2 is rejected." width="100%"></p>
|
|
6
|
+
|
|
7
|
+
Published on npm as [`@ruvector/ruvllm-gpu-loop`](https://www.npmjs.com/package/@ruvector/ruvllm-gpu-loop).
|
|
8
|
+
The package ships the JavaScript controller, GPU loop and Vast.ai host adapter.
|
|
9
|
+
It does not ship the native `weight_evolution` binary, model weights or
|
|
10
|
+
adapters. Build the binary from this repository and pass its path with
|
|
11
|
+
`--binary`.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @ruvector/ruvllm-gpu-loop
|
|
15
|
+
npx ruvllm-gpu --help # bounded weight-edit experiments
|
|
16
|
+
npx ruvllm-gpu-loop status --config /abs/private/gpu-loop.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Package name: `@ruvector/ruvllm-gpu-loop`, not `@ruvector/ruvllm`
|
|
20
|
+
|
|
21
|
+
Versions 4.0.0 and 4.0.1 of this harness were published as `@ruvector/ruvllm`
|
|
22
|
+
by mistake. That name belongs to the RuVLLM inference runtime (GGUF inference,
|
|
23
|
+
TurboQuant KV cache, SONA, FlashAttention) built from
|
|
24
|
+
[`ruvnet/RuVector`](https://github.com/ruvnet/RuVector/tree/main/npm/packages/ruvllm),
|
|
25
|
+
and the 4.0.x upload replaced it for everyone. `@ruvector/ruvllm@4.1.0`
|
|
26
|
+
restores the runtime and depends on this package, so its GPU-loop subpaths keep
|
|
27
|
+
working:
|
|
28
|
+
|
|
29
|
+
| 4.0.x (`@ruvector/ruvllm`) | Now (`@ruvector/ruvllm-gpu-loop`) | Via `@ruvector/ruvllm@^4.1.0` |
|
|
30
|
+
| :--- | :--- | :--- |
|
|
31
|
+
| `import … from '@ruvector/ruvllm'` (`runExperiment`) | `import … from '@ruvector/ruvllm-gpu-loop'` | `@ruvector/ruvllm/engine` |
|
|
32
|
+
| `@ruvector/ruvllm/gpu-loop`, `/adapters`, `/gpu-host`, `/gpu-spool-adapter`, `/vast-host-adapter`, `/fixture` | same subpaths on `@ruvector/ruvllm-gpu-loop` | same subpaths |
|
|
33
|
+
| `npx ruvllm run …` / `npx ruvllm fixture …` | `npx ruvllm-gpu run …` / `npx ruvllm-gpu fixture …` | `npx ruvllm gpu run …` |
|
|
34
|
+
| `npx ruvllm-gpu-loop`, `npx ruvllm-adapters` | unchanged | unchanged |
|
|
35
|
+
|
|
36
|
+
A `prepublishOnly` guard (`scripts/check-package-name.mjs`) refuses to publish
|
|
37
|
+
this package under the runtime's name.
|
|
38
|
+
|
|
39
|
+
Run multiple bounded RuVLLM edits against one unchanged checkpoint, validate
|
|
40
|
+
supplied evaluations, package RVF evidence, restore every patched checkpoint,
|
|
41
|
+
and rank research-qualified candidates through MetaHarness. This controller
|
|
42
|
+
uses the actual Flywheel, Darwin and Weight-EFT packages pinned in
|
|
43
|
+
[package-lock.json](package-lock.json).
|
|
44
|
+
|
|
45
|
+
The runner does not perform inference, discover an effective weight edit, train
|
|
46
|
+
an adapter or activate a model. CPU fixtures exercise real file editing and
|
|
47
|
+
restoration with explicitly synthetic evaluation receipts. External evaluation
|
|
48
|
+
files remain caller-supplied evidence; hashes do not authenticate their origin.
|
|
49
|
+
|
|
50
|
+
## Install and run the CPU fixture
|
|
51
|
+
|
|
52
|
+
Requirements: Linux or macOS, Node 22+, Python 3.12+, a C linker, and Rust 1.97.1
|
|
53
|
+
as pinned by `native/rust-toolchain.toml`. Activate any locally installed Rust
|
|
54
|
+
toolchain before using Cargo. From the repository root:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
(cd integrations/metaharness && npm ci --ignore-scripts)
|
|
58
|
+
(cd native && cargo build --locked --release --bin weight_evolution)
|
|
59
|
+
python3 native/verify_source.py
|
|
60
|
+
node integrations/metaharness/src/cli.mjs fixture \
|
|
61
|
+
--dir "$PWD/runtime/metaharness-fixture" \
|
|
62
|
+
--binary "$PWD/native/target/release/weight_evolution"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Create the fixture's parent directory first (`mkdir -p runtime`). Its own directory
|
|
66
|
+
must not exist: exclusive creation prevents accidental replacement. For another
|
|
67
|
+
fixture use a new directory. The report should select `fixture-improvement`, leave
|
|
68
|
+
`unevaluated-control` unqualified, verify RVF and exact rollback for both, and
|
|
69
|
+
report `inferencePerformed: false`, `independentConfirmation: false` and
|
|
70
|
+
`productionActivation: false`. A selected synthetic candidate says nothing about
|
|
71
|
+
actual model accuracy.
|
|
72
|
+
|
|
73
|
+
## Configure real experiment inputs
|
|
74
|
+
|
|
75
|
+
Prepare reviewed source checkpoint, patch, policy and optional evaluation JSON
|
|
76
|
+
under explicit input roots. Native request/data contracts are described in the
|
|
77
|
+
[native guide](../../native/README.md). Patch generation remains model specific;
|
|
78
|
+
the controller does not guess useful tensor edits.
|
|
79
|
+
|
|
80
|
+
Run the project-local installer with paths you control:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
bash scripts/install-metaharness.sh \
|
|
84
|
+
--config-dir /absolute/private/operator-profile \
|
|
85
|
+
--read-root /absolute/checkpoints \
|
|
86
|
+
--read-root /absolute/experiment-inputs \
|
|
87
|
+
--policy /absolute/experiment-inputs/policy.json \
|
|
88
|
+
--output-root /absolute/private/experiment-outputs
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
It installs frozen npm dependencies without lifecycle scripts, builds the native
|
|
92
|
+
binary, verifies native provenance and runs its smoke fixture. It creates a
|
|
93
|
+
private runtime profile and Claude launcher without changing global settings.
|
|
94
|
+
Repeat `--read-root`/`--policy` for additional approved inputs. Existing profile
|
|
95
|
+
files are never replaced; use another directory for a new profile. Existing config
|
|
96
|
+
and output directories must be owner-only. `--configure-only` skips installation
|
|
97
|
+
and building but still checks native readiness.
|
|
98
|
+
|
|
99
|
+
Example plan inside an approved read root:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"schema": "ruvllm-experiment-plan/v1",
|
|
104
|
+
"evidenceMode": "external",
|
|
105
|
+
"source": "/absolute/checkpoints/source.safetensors",
|
|
106
|
+
"policy": "/absolute/experiment-inputs/policy.json",
|
|
107
|
+
"candidates": [
|
|
108
|
+
{
|
|
109
|
+
"id": "candidate-01",
|
|
110
|
+
"patch": "/absolute/experiment-inputs/patch.json",
|
|
111
|
+
"evaluation": "/absolute/experiment-inputs/evaluation.json"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
node integrations/metaharness/src/cli.mjs run \
|
|
119
|
+
--config /absolute/private/operator-profile/runtime.json \
|
|
120
|
+
--plan /absolute/experiment-inputs/plan.json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Omit `evaluation` to run mechanical checks without qualification. After an external
|
|
124
|
+
inference runner has evaluated a candidate, submit its hash-bound evaluation in a
|
|
125
|
+
new plan/run. Candidate checkpoint hashes are deterministic for the same patch;
|
|
126
|
+
new artifact paths do not relax identity checks. Paired baseline, protocol, suite,
|
|
127
|
+
runtime, precision and output-budget consistency remain the evaluator's responsibility.
|
|
128
|
+
|
|
129
|
+
Runs use new private `run-*` directories and preserve rejected candidates. Reports
|
|
130
|
+
bind config/plan/source/policy/binary/gate/patch/evaluation identities and record
|
|
131
|
+
rollback and RVF verification. Native rejection records a reason. Structural or
|
|
132
|
+
restoration failures abort; interrupted runs can leave artifacts. Reconcile those
|
|
133
|
+
directories before retrying; never erase failed evidence to manufacture success.
|
|
134
|
+
|
|
135
|
+
## Claude Code and Ruflo
|
|
136
|
+
|
|
137
|
+
Load [ruflo-metaharness](../../plugins/ruflo-metaharness/README.md) using the
|
|
138
|
+
generated `launch-claude.sh`, or set `RUVLLM_EXPERIMENT_CONFIG` and use Claude's
|
|
139
|
+
`--plugin-dir`. The `/ruflo-metaharness:weight-experiment` command and reviewer
|
|
140
|
+
agent guide the bounded workflow. Its single MCP tool accepts a plan path; the
|
|
141
|
+
model cannot override the operator configuration. The same stdio server can be
|
|
142
|
+
registered in a Ruflo project's MCP configuration. Portable wire tests exercise
|
|
143
|
+
the real engine; installed Claude/Ruflo client acceptance is separate.
|
|
144
|
+
|
|
145
|
+
## Scheduled GPU work
|
|
146
|
+
|
|
147
|
+
For scheduled GPU work, use the [durable GPU loop](GPU-LOOP.md). It supports
|
|
148
|
+
host-owned ruOS secret references, Vast job descriptors, persisted reservations,
|
|
149
|
+
deadline-aware polling and confirmed cleanup. Local contract tests require no
|
|
150
|
+
live provider. The bundled file handoff keeps requests pending for a trusted host.
|
|
151
|
+
|
|
152
|
+
## Weight-EFT data and plans
|
|
153
|
+
|
|
154
|
+
The data-only adapter CLI reads JSON stdin, with a 16 MiB bound:
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
node integrations/metaharness/src/adapters-cli.mjs export < reviewed-archive-input.json > export.json
|
|
158
|
+
node integrations/metaharness/src/adapters-cli.mjs training-plan < training-input.json > plan.json
|
|
159
|
+
node integrations/metaharness/src/adapters-cli.mjs select < measured-candidates.json > selection.json
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`export` takes `{archive, evalHoldout, maxTokens?}`. Archive entries follow the
|
|
163
|
+
pinned Weight-EFT `DarwinTrajectory` contract (`instance_id`, `model`, `tier`,
|
|
164
|
+
boolean `resolved`, `messages`, `model_patch`). All actual evaluation instance IDs
|
|
165
|
+
must be in `evalHoldout`. Output contains standard `sft`/`dpo` arrays, drop reports
|
|
166
|
+
and input hashes. Reward-hacking filtering stays enabled, overlength traces are
|
|
167
|
+
dropped, and tool calls are preserved. These filters cannot authenticate outcomes
|
|
168
|
+
or detect all semantic contamination.
|
|
169
|
+
|
|
170
|
+
`training-plan` takes `{base:{id,paramsB},sftPath,dpoPath,adapterPrefix}`. It emits
|
|
171
|
+
upstream plans plus `executionStatus: not_executed` and
|
|
172
|
+
`runnerCompatibility: adapter-required`. This repository has no upstream
|
|
173
|
+
`ruvllm microlora` executable. Its existing fixed CUDA/PEFT experiment runner is
|
|
174
|
+
not a configurable SFT/DPO trainer. No GPU, model download or paid job is started.
|
|
175
|
+
|
|
176
|
+
`select` takes `{baseline,candidates,envelope}` with entries
|
|
177
|
+
`{id,score,evidenceSha256}`. It replays finite, supplied scores through Darwin's
|
|
178
|
+
contrastive engine. It is development ranking with an immutable envelope and no
|
|
179
|
+
independent confirmation; it cannot authenticate caller-supplied evidence. The
|
|
180
|
+
native runner applies its stricter qualification first.
|
|
181
|
+
|
|
182
|
+
## Tests and benchmark
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
(cd integrations/metaharness && npm test)
|
|
186
|
+
node --test plugins/ruflo-metaharness/test/*.test.mjs
|
|
187
|
+
node integrations/metaharness/bench/run.mjs --iterations 7 --warmup 2 --candidates 2
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Tests require the built native binary. In restricted agent environments the Node
|
|
191
|
+
test runner, native child processes and package fetching may require the host's
|
|
192
|
+
supported execution permission. Verify actual subtest counts; a file-only runner
|
|
193
|
+
summary is insufficient evidence. Do not disable TLS/checksums or native checks.
|
|
194
|
+
|
|
195
|
+
The benchmark compares fresh versus reused Node processes on identical CPU
|
|
196
|
+
fixtures, retaining raw latency samples and implementation/binary/lock hashes.
|
|
197
|
+
The reused process matches the MCP server architecture. All native hashing,
|
|
198
|
+
patch validation and byte restoration remain enabled. See the
|
|
199
|
+
[benchmark report](../../docs/benchmarks/metaharness-cpu.md) for measured scope
|
|
200
|
+
and limits; no model-performance claim follows from orchestration speed.
|
|
201
|
+
|
|
202
|
+
Architecture and threat boundaries are recorded in
|
|
203
|
+
[ADR 012](../../docs/adr/ADR-012-metaharness-bounded-experiment-runner.md),
|
|
204
|
+
[ADR 013](../../docs/adr/ADR-013-training-and-development-selection.md) and
|
|
205
|
+
[ADR 014](../../docs/adr/ADR-014-claude-ruflo-integration.md).
|