@shapeshift-labs/frontier-swarm 0.3.0 → 0.5.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/README.md CHANGED
@@ -36,7 +36,7 @@ The published Frontier package family is generated from one shared package catal
36
36
  - [`@shapeshift-labs/frontier-workflow`](https://www.npmjs.com/package/@shapeshift-labs/frontier-workflow): Serializable durable workflow/process manifests for Frontier apps, including steps, waits, approvals, timers, retries, expected patches, compensation, records, timelines, and registry graph output.
37
37
  - [`@shapeshift-labs/frontier-worker`](https://www.npmjs.com/package/@shapeshift-labs/frontier-worker): Serializable worker and edge task descriptors for Frontier apps, including queues, idempotency keys, retry and timeout policy, declared reads/writes/effects, snapshots, patch outputs, produced assets, execution records, logs, trace links, proof hashes, dedupe indexes, and registry graph output.
38
38
  - [`@shapeshift-labs/frontier-queue`](https://www.npmjs.com/package/@shapeshift-labs/frontier-queue): Serializable durable queue state, leases, retries, dedupe keys, patch-carrying jobs, dead-letter records, replay evidence, and queue inspection for Frontier apps.
39
- - [`@shapeshift-labs/frontier-swarm-codex`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm-codex): Node Codex CLI adapter for Frontier swarm plans, including prompt rendering, worktree and snapshot workspaces, Codex argument compatibility, JSONL capture, verification commands, pid-backed stop, collect buckets, merge bundles, and result artifacts.
39
+ - [`@shapeshift-labs/frontier-swarm-codex`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm-codex): Node Codex CLI adapter for Frontier swarm plans, including prompt rendering, worktree and snapshot workspaces, Codex argument compatibility, browser resource allocation, JSONL capture, verification commands, pid-backed stop, collect/apply workflows, merge indexes, queue overlays, merge bundles, and result artifacts.
40
40
  - [`@shapeshift-labs/frontier-kv`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv): Serializable in-memory key/value state for Frontier apps, including TTL, versioned compare-and-set, batched patch mutations, scans, watchers, snapshots, JSONL event evidence, and replay verification.
41
41
  - [`@shapeshift-labs/frontier-kv-locks`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-locks): Lease-style lock records on top of Frontier KV, including acquire, renew, release, fencing tokens, expiration, owner evidence, and replayable lock events.
42
42
  - [`@shapeshift-labs/frontier-kv-rate-limit`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-rate-limit): Patch-native rate limit buckets for Frontier KV, including fixed windows, sliding windows, token buckets, deterministic refill, consume evidence, and reset records.
@@ -248,8 +248,24 @@ The scale APIs are runtime-neutral and serializable:
248
248
  - `createSwarmReviewPlan` samples or requires reviewer assignments,
249
249
  - `createSwarmMergePlan` blocks jobs with failed checks, required reviews, ownership violations, or conflicting changed paths,
250
250
  - job results include merge-readiness classification: `discovery-only`, `patch-candidate`, `verified-patch`, `rejected`, or `blocked`,
251
- - `ownershipRegions` allow hot files to be split into semantic regions such as `content.docs.*` or `adminSettings.quota.*`; merge conflict detection prefers changed regions when workers report them,
251
+ - `ownershipRegions` allow hot files to be split into semantic regions such as `content.docs.*` or `adminSettings.quota.*`; merge conflict detection compares explicit changed regions when both sides report them and falls back to path conflicts when either side omits regions,
252
252
  - `createSwarmMergeBundle` builds a compact worker `merge.json` shape with touched owned files, patch path, evidence, verification, queue items satisfied, risk, and disposition,
253
+ - `createSwarmQueueOverlay` and `deriveSwarmQueueStatus` keep central queue files immutable while deriving status from worker result overlays,
254
+ - `createSwarmMergeIndex` records stale/patch status and region-aware conflicts so coordinators can review ready bundles before reading every worker directory,
255
+ - `checkSwarmRegionOwnership` makes semantic region ownership enforceable instead of only advisory,
256
+ - `createSwarmHotspotReport` highlights repeatedly touched files and suggests module/region splits for merge throughput,
257
+ - `createSwarmReviewerLanePlan` turns risky/conflicting merge bundles into reviewer-lane tasks,
258
+ - `createSwarmRunStoreShards` describes sharded event/result/checkpoint paths for large run stores,
259
+ - `createSwarmMergeAdmission` limits ready merges by count, touched paths/regions, and risk budget,
260
+ - `createSwarmPatchStackPlan` clusters compatible bundles into candidate patch stacks by lane, path, region, disposition, and risk so reviewers can evaluate batches instead of individual worker directories,
261
+ - `createSwarmContextPack` gives workers compact task context: relevant files, API maps, known failures, focused/oracle commands, expected evidence, exclusions, evidence schema, playbooks, and explicit dead ends to avoid,
262
+ - `createSwarmOracleCorpus` indexes deterministic reference artifacts such as traces, snapshots, classifications, expected outputs, or fixtures without assuming a project domain,
263
+ - `createSwarmReplayBundle`, `createSwarmParityOracle`, `createSwarmDivergenceReport`, `createSwarmObservabilityPoint`, `createSwarmWatchpointPlan`, and `createSwarmDebugHandoff` model the trace-to-debug workflow: replay finds the narrow window, watchpoints/debug handoff explain the state at that point,
264
+ - `createSwarmReferenceOraclePlan` and `createSwarmReferenceOracleResponse` describe reusable reference services for ports, migrations, parity checks, and cross-implementation comparisons,
265
+ - `createSwarmInstrumentationBudget`, `checkSwarmInstrumentationBudget`, and `createSwarmBottleneckReport` keep traces/logs useful without making instrumentation the bottleneck,
266
+ - `createSwarmEvidenceIndex` / `querySwarmEvidenceIndex` and `createSwarmBlackboard` / `querySwarmBlackboard` provide storage-neutral status surfaces for coordinator dashboards, accepted facts, known divergences, rejected theories, and active ownership,
267
+ - `createSwarmArtifactRoutingPlan`, `createSwarmSchedulerRecommendations`, `createSwarmFixtureCatalog`, `createSwarmProgressModel`, `createSwarmAutoReviewReport`, `createSwarmRebaseReport`, and `createSwarmUsageGovernor` cover the merge/review/scheduling tools needed to scale from feature swarms to larger migration and porting swarms,
268
+ - `createSwarmLanePlaybook` turns successful prior bundles into persistent lane-specific guidance with commands, hot paths, evidence patterns, and avoid-investigating notes,
253
269
  - `decomposeSwarmFeature` creates an initial task queue for feature work across lanes.
254
270
 
255
271
  ## Hierarchical Compute
@@ -273,13 +289,26 @@ That lets a parent swarm route implementation jobs to a deep model while evidenc
273
289
  - `createSwarmPlan`, `createSwarmRun`
274
290
  - `createSwarmSchedule`, `createSwarmLeases`
275
291
  - `createSwarmQueueSnapshot`, `createSwarmRunCheckpoint`
292
+ - `createSwarmQueueOverlay`, `deriveSwarmQueueStatus`
276
293
  - `createSwarmEventStream`, `createSwarmMailbox`, `routeSwarmEventToMailboxes`
277
294
  - `checkSwarmBudget`
278
295
  - `createSwarmArtifactIndex`
279
- - `createSwarmReviewPlan`, `createSwarmMergePlan`
296
+ - `createSwarmReviewPlan`, `createSwarmReviewerLanePlan`, `createSwarmMergePlan`
280
297
  - `createSwarmMergeBundle`
298
+ - `createSwarmMergeIndex`, `createSwarmMergeAdmission`
299
+ - `createSwarmHotspotReport`, `createSwarmRunStoreShards`
300
+ - `createSwarmPatchStackPlan`
301
+ - `createSwarmContextPack`, `createSwarmOracleCorpus`, `createSwarmLanePlaybook`
302
+ - `createSwarmReplayBundle`, `createSwarmParityOracle`, `createSwarmDivergenceReport`, `createSwarmObservabilityPoint`
303
+ - `createSwarmWatchpointPlan`, `createSwarmDebugHandoff`
304
+ - `createSwarmReferenceOraclePlan`, `createSwarmReferenceOracleResponse`
305
+ - `createSwarmInstrumentationBudget`, `checkSwarmInstrumentationBudget`, `createSwarmBottleneckReport`
306
+ - `createSwarmEvidenceIndex`, `querySwarmEvidenceIndex`, `createSwarmBlackboard`, `querySwarmBlackboard`
307
+ - `createSwarmArtifactRoutingPlan`, `createSwarmSchedulerRecommendations`
308
+ - `createSwarmFixtureCatalog`, `createSwarmProgressModel`, `createSwarmAutoReviewReport`, `createSwarmRebaseReport`
309
+ - `createSwarmUsageGovernor`, `checkSwarmUsageGovernor`
281
310
  - `classifySwarmMergeReadiness`, `classifySwarmMergeDisposition`
282
- - `resolveSwarmChangedRegions`
311
+ - `resolveSwarmChangedRegions`, `checkSwarmRegionOwnership`
283
312
  - `decomposeSwarmFeature`
284
313
  - `recordSwarmEvent`, `completeSwarmJob`
285
314
  - `resolveSwarmCompute`
@@ -295,7 +324,7 @@ Run the package-local benchmark:
295
324
  npm run bench
296
325
  ```
297
326
 
298
- The benchmark writes `benchmarks/results/frontier-swarm-package-bench-latest.json` when run from the monorepo. These are Frontier-only package measurements for plan creation, manifest validation, hierarchical compute resolution, ownership checks, scheduling/leases, queue snapshots, merge bundle creation, event routing, run checkpoints, JSONL, and proof hashing.
327
+ The benchmark writes `benchmarks/results/frontier-swarm-package-bench-latest.json` when run from the monorepo. These are Frontier-only package measurements for plan creation, manifest validation, hierarchical compute resolution, ownership checks, scheduling/leases, queue snapshots, queue overlays, merge bundles, merge indexes, merge admission, hotspot reports, context packs, oracle corpora, replay/debug/evidence helper creation, lane playbooks, patch stack plans, event routing, run checkpoints, JSONL, and proof hashing.
299
328
 
300
329
  ## Source Repository
301
330
 
@@ -4,12 +4,30 @@ import { performance } from 'node:perf_hooks';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import {
6
6
  checkSwarmOwnership,
7
+ createSwarmContextPack,
8
+ createSwarmHotspotReport,
9
+ createSwarmLanePlaybook,
10
+ createSwarmMergeAdmission,
7
11
  createSwarmManifest,
8
12
  createSwarmEventStream,
9
13
  createSwarmLeases,
10
14
  createSwarmMergeBundle,
15
+ createSwarmMergeIndex,
16
+ createSwarmOracleCorpus,
17
+ createSwarmPatchStackPlan,
18
+ createSwarmReplayBundle,
19
+ createSwarmParityOracle,
20
+ createSwarmDivergenceReport,
21
+ createSwarmWatchpointPlan,
22
+ createSwarmDebugHandoff,
23
+ createSwarmEvidenceIndex,
24
+ createSwarmBlackboard,
25
+ createSwarmBottleneckReport,
26
+ createSwarmFixtureCatalog,
27
+ createSwarmProgressModel,
11
28
  createSwarmPlan,
12
29
  createSwarmProof,
30
+ createSwarmQueueOverlay,
13
31
  createSwarmQueueSnapshot,
14
32
  createSwarmRun,
15
33
  createSwarmRunCheckpoint,
@@ -41,6 +59,8 @@ let cursor = 0;
41
59
  let schedule = createSwarmSchedule({ plan, maxReadyJobs: 128 });
42
60
  let leases = createSwarmLeases({ schedule, workerId: 'bench-worker', now: 1000, leaseMs: 60000, count: 16 });
43
61
  let eventStream = createSwarmEventStream({ runId: 'bench', root: 'agent-runs/bench/streams', lanes: manifest.lanes });
62
+ let bundles = makeBundles(plan, 32);
63
+ let mergeIndex = createSwarmMergeIndex({ bundles });
44
64
 
45
65
  const rows = [
46
66
  measure('create-plan-' + taskCount, 8, () => {
@@ -80,6 +100,74 @@ const rows = [
80
100
  },
81
101
  patchPath: 'agent-runs/bench/changes.patch'
82
102
  }).id.length),
103
+ measure('queue-overlay-' + taskCount, 16, () => createSwarmQueueOverlay({ bundles, generatedAt: 3000 + cursor++ }).summary.entryCount),
104
+ measure('merge-index-' + taskCount, 8, () => {
105
+ bundles = makeBundles(plan, 32);
106
+ mergeIndex = createSwarmMergeIndex({ bundles, generatedAt: 4000 + cursor++ });
107
+ return mergeIndex.summary.entryCount + mergeIndex.summary.conflictCount;
108
+ }),
109
+ measure('merge-admission-' + taskCount, 16, () => createSwarmMergeAdmission({ index: mergeIndex, maxReady: 8, maxChangedPaths: 16 }).summary.admittedCount),
110
+ measure('hotspot-report-' + taskCount, 16, () => createSwarmHotspotReport({ bundles, threshold: 3 }).summary.recommendationCount),
111
+ measure('context-pack-' + taskCount, 32, () => createSwarmContextPack({
112
+ job: plan.jobs[cursor % plan.jobs.length],
113
+ files: ['src/runtime/file.ts', 'test/runtime-smoke.mjs'],
114
+ apiMap: {
115
+ runtime: ['createRuntime', 'stepRuntime'],
116
+ tests: ['runtime smoke gate']
117
+ },
118
+ knownFailures: ['shared renderer gate is noisy on old snapshots'],
119
+ oracleCommands: [{ name: 'focused-gate', command: 'npm', args: ['test'], required: true }],
120
+ evidenceSchema: { type: 'object', required: ['ok', 'commands'] },
121
+ avoidInvestigating: ['unrelated route snapshots'],
122
+ playbookIds: ['runtime-playbook']
123
+ }).files.length),
124
+ measure('oracle-corpus-' + taskCount, 32, () => createSwarmOracleCorpus({
125
+ artifacts: [
126
+ { id: 'trace-runtime', path: 'oracles/runtime-trace.jsonl', kind: 'trace', tags: ['runtime', 'reference'], hash: 'fnv1a32:trace' },
127
+ { id: 'snapshot-routing', path: 'oracles/routing-snapshot.json', kind: 'snapshot', tags: ['routing', 'reference'] }
128
+ ]
129
+ }).summary.artifactCount),
130
+ measure('replay-debug-evidence-' + taskCount, 16, () => {
131
+ const replay = createSwarmReplayBundle({
132
+ commands: ['node replay.mjs'],
133
+ artifacts: [{ path: 'agent-runs/bench/trace.jsonl', kind: 'trace' }],
134
+ expectedEvidence: ['trace.jsonl']
135
+ });
136
+ const parity = createSwarmParityOracle({
137
+ comparators: [{ status: 'failed', expected: 1, actual: 2, operationIndex: cursor++ }]
138
+ });
139
+ const divergence = createSwarmDivergenceReport({
140
+ replayBundleIds: [replay.id],
141
+ observabilityPoints: [{ operationIndex: cursor, path: '/value' }],
142
+ expected: 1,
143
+ actual: 2
144
+ });
145
+ const watch = createSwarmWatchpointPlan({ watchpoints: [{ path: '/value', operator: 'changes' }] });
146
+ const handoff = createSwarmDebugHandoff({
147
+ replayBundleIds: [replay.id],
148
+ divergenceReportIds: [divergence.id],
149
+ watchpointPlanIds: [watch.id],
150
+ comparisons: parity.comparators
151
+ });
152
+ const evidence = createSwarmEvidenceIndex({ entries: [{ topic: 'bench', path: 'agent-runs/bench/evidence.json' }] });
153
+ const blackboard = createSwarmBlackboard({ entries: [{ topic: 'bench', text: 'divergence found', sourceIds: [divergence.id] }] });
154
+ const bottleneck = createSwarmBottleneckReport({ sources: [{ text: 'merge review bottleneck', changedPaths: ['src/runtime.ts'] }] });
155
+ const fixtures = createSwarmFixtureCatalog({ fixtures: [{ id: 'logged-in', tags: ['auth'] }] });
156
+ const progress = createSwarmProgressModel({ items: [{ id: 'bench', status: 'accepted' }] });
157
+ return handoff.commands.length + evidence.summary.entryCount + blackboard.summary.entryCount + bottleneck.summary.kindCount + fixtures.summary.fixtureCount + progress.summary.acceptedCount;
158
+ }),
159
+ measure('lane-playbook-' + taskCount, 16, () => createSwarmLanePlaybook({
160
+ lane: 'runtime',
161
+ successfulBundles: bundles,
162
+ notes: ['prefer narrow patches with focused evidence'],
163
+ commands: [{ name: 'runtime-smoke', command: 'npm', args: ['test'], required: true }],
164
+ avoidInvestigating: ['generated fixtures unless task owns them'],
165
+ evidencePatterns: ['evidence.json', 'commands.md']
166
+ }).successfulJobIds.length),
167
+ measure('patch-stack-plan-' + taskCount, 16, () => createSwarmPatchStackPlan({
168
+ index: mergeIndex,
169
+ maxStackSize: 8
170
+ }).summary.stackCount),
83
171
  measure('event-route-' + taskCount, 64, () => {
84
172
  eventStream = createSwarmEventStream({ runId: 'bench', root: 'agent-runs/bench/streams', lanes: manifest.lanes });
85
173
  return routeSwarmEventToMailboxes(eventStream, { type: 'agent.evidence', jobId: plan.jobs[cursor++ % plan.jobs.length].id, lane: 'runtime' }).length;
@@ -146,6 +234,25 @@ function makeTasks(count) {
146
234
  return tasks;
147
235
  }
148
236
 
237
+ function makeBundles(plan, count) {
238
+ const bundles = [];
239
+ for (let i = 0; i < Math.min(count, plan.jobs.length); i += 1) {
240
+ const job = plan.jobs[i];
241
+ bundles.push(createSwarmMergeBundle({
242
+ job,
243
+ result: {
244
+ jobId: job.id,
245
+ status: 'verified',
246
+ changedPaths: [job.task.targetRefs[0] ?? `src/runtime/file-${i}.ts`],
247
+ changedRegions: i % 2 === 0 ? [`region.${i}`] : [],
248
+ verification: [{ status: 0 }]
249
+ },
250
+ patchPath: `agent-runs/bench/${job.id}/changes.patch`
251
+ }));
252
+ }
253
+ return bundles;
254
+ }
255
+
149
256
  function measure(fixture, operationsPerRound, fn) {
150
257
  const samples = [];
151
258
  let checksum = 0;