@vzn/vx-history 0.0.649 → 0.0.650

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/index.ts +13 -14
package/README.md CHANGED
@@ -19,7 +19,7 @@ import { vxHistory } from '@vzn/vx-history'
19
19
  export default { plugins: [vxHistory()] }
20
20
  ```
21
21
 
22
- `vxHistory({ window?, assume?, file?, url?, issuer?, repository?, headers?, resources?, memory?, reservations? })` learns from the last `window` invocations (default 20) through core's `LocalHistoryProvider` over the cache's own SQLite handle. With one worker and two chains of identical shape, the chain history says is slow starts first; with no history yet, the scheduler's structural order stands.
22
+ `vxHistory({ window?, assume?, file?, url?, issuer?, repository?, headers?, resources?, memory?, reservations? })` learns from the last `window` invocations (default 20) through core's `localHistory(cache)`, which reads the cache's index and returns rows; the plugin never touches cache.db. With one worker and two chains of identical shape, the chain history says is slow starts first; with no history yet, the scheduler's structural order stands.
23
23
 
24
24
  `assume` is for the run that has no history: a fresh CI runner. It names durations (task id → ms) for tasks the history has not seen, so a long leaf task — a docs build, a cross-compile — starts first instead of last:
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx-history",
3
- "version": "0.0.649",
3
+ "version": "0.0.650",
4
4
  "license": "MIT",
5
5
  "description": "History-based scheduling for vx — a `schedule` plugin that orders ready tasks by their expected remaining critical path, learned from the local run history.",
6
6
  "keywords": [
@@ -37,7 +37,7 @@
37
37
  "access": "public"
38
38
  },
39
39
  "peerDependencies": {
40
- "@vzn/vx": "^0.0.649"
40
+ "@vzn/vx": "^0.0.650"
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",
package/src/index.ts CHANGED
@@ -14,7 +14,8 @@
14
14
  import {
15
15
  currentBranch,
16
16
  definePlugin,
17
- LocalHistoryProvider,
17
+ type LocalHistory,
18
+ localHistory,
18
19
  machineMemoryBytes,
19
20
  Cache,
20
21
  type HistoryTable,
@@ -193,7 +194,7 @@ const readHistory = (
193
194
  branch: string | null,
194
195
  defs: ReadonlyMap<string, string>,
195
196
  ): Promise<ReadonlyMap<string, TaskResources>> =>
196
- new LocalHistoryProvider(cache.dbHandle(), windowOf(options), branch, defs).resourcesFor(ids)
197
+ localHistory(cache, { recent: windowOf(options), branch, defs }).resourcesFor(ids)
197
198
 
198
199
  /** What each task reserves: learned from the history unless `resources: false`, a declared reservation over either. */
199
200
  const reservationsFor = (
@@ -411,14 +412,13 @@ export function vxHistory(options: VxHistoryOptions = {}): VxPlugin {
411
412
  const ids: string[] = []
412
413
  for (const n of nodes.values()) if (n.config.exec?.command !== undefined) ids.push(n.id)
413
414
  let table: ReadonlyMap<string, TaskResources>
414
- let provider: LocalHistoryProvider
415
+ let provider: LocalHistory
415
416
  try {
416
- provider = new LocalHistoryProvider(
417
- ctx.localCache.dbHandle(),
418
- windowOf(options),
419
- ctx.branch,
417
+ provider = localHistory(ctx.localCache, {
418
+ recent: windowOf(options),
419
+ branch: ctx.branch,
420
420
  defs,
421
- )
421
+ })
422
422
  table = await provider.resourcesFor(ids)
423
423
  } catch (err) {
424
424
  // Failing open: a broken history read costs the ordering and the
@@ -849,13 +849,12 @@ async function historyCmd(
849
849
  // Each task's rows of its definition as it is now, as `schedule` reads
850
850
  // them: read with every definition's, a task whose command changed
851
851
  // showed the old command's peak and a reservation no run packs.
852
- table = await new LocalHistoryProvider(
853
- cache.dbHandle(),
854
- window,
855
- currentBranch(ctx.workspaceRoot),
852
+ table = await localHistory(cache, {
853
+ recent: window,
854
+ branch: currentBranch(ctx.workspaceRoot),
856
855
  // As a run reads them: a task whose command changed has no rows yet.
857
- taskDefinitions(tasks as TaskNode[]),
858
- ).loadFor(ids)
856
+ defs: taskDefinitions(tasks as TaskNode[]),
857
+ }).loadFor(ids)
859
858
  } finally {
860
859
  cache.close()
861
860
  }