open-index/open-npm huggingface dataset:
npm package: @fluxgpu/arch-validator
Description: Static analysis tool for validating FluxGPU hexagonal architecture constraints
Author: AnNingUI
Latest version: 5.3.0

# @fluxgpu/arch-validator

Static analysis tool for validating FluxGPU's architectural constraints.

## Overview

This package enforces the hexagonal architecture rules at build time:

- Domain packages cannot import from infrastructure
- Bridge layer can only depend on contracts
- Framework bindings follow proper dependency direction

## Installation

```bash
pnpm add -D @fluxgpu/arch-validator
```

## Usage

### CLI

```bash
# Validate architecture
npx flux-validate

# Or via pnpm script
pnpm validate:arch
```

### Programmatic

```typescript
import { validateArchitecture } from '@fluxgpu/arch-validator';

const result = validateArchitecture({
  domainPackages: ['packages/contracts', 'packages/core', 'packages/dsl'],
  bridgePackages: ['packages/protocol'],
  infraPackages: ['packages/engine', 'packages/host-browser'],
});

if (!result.valid) {
  console.error('Violations:', result.violations);
}
```

## Rules Enforced

| Rule | Description |
|------|-------------|
| Domain Isolation | `@fluxgpu/core`, `@fluxgpu/dsl` cannot import from engine/host |
| Contract Purity | `@fluxgpu/contracts` has zero dependencies |
| Bridge Independence | `@fluxgpu/protocol` only depends on contracts |
| Dependency Direction | Dependencies flow inward toward domain |

## Output

```
FluxGPU Architectural Constraint Validator

Validating domain packages:
  - packages/contracts
  - packages/core
  - packages/dsl

�?All architectural constraints validated successfully
```

## Integration

Add to your build pipeline:

```json
{
  "scripts": {
    "prebuild": "pnpm validate:arch",
    "build": "tsc -b"
  }
}
```
npm package: @fluxgpu/contracts
Description: Pure TypeScript interfaces and type definitions for FluxGPU - zero dependencies
Author: AnNingUI
Latest version: 5.3.0

# @fluxgpu/contracts

Pure TypeScript interfaces defining all ports for FluxGPU.

## Overview

This package contains zero-dependency type definitions that form the contract between all FluxGPU packages. It defines:

- Command buffer types and opcodes
- Resource identifiers and handles
- Error types and validation contracts
- Port interfaces for dependency inversion

## Installation

```bash
pnpm add @fluxgpu/contracts
```

## Usage

```typescript
import type { CommandBuffer, ResourceId, Opcode } from '@fluxgpu/contracts';
import { FluxError, ErrorCode } from '@fluxgpu/contracts';

// Create a command
const command: CommandBuffer = {
  id: 'cmd-001' as ResourceId,
  opcode: Opcode.CreateBuffer,
  payload: new Uint8Array([1, 2, 3]),
  dependencies: [],
};

// Handle errors
throw new FluxError(ErrorCode.InvalidResource, 'Buffer not found');
```

## Key Types

| Type | Description |
|------|-------------|
| `CommandBuffer` | Represents a GPU command with dependencies |
| `ResourceId` | Branded type for resource identification |
| `Opcode` | Enum of all supported GPU operations |
| `FluxError` | Typed error with error codes |

## Architecture Role

As the foundation of FluxGPU's hexagonal architecture, this package:

- Has **zero dependencies** (not even on other @flux packages)
- Defines **ports** that other packages implement
- Enables **dependency inversion** across the codebase
npm package: @fluxgpu/core
Description: Core domain logic for FluxGPU - graph orchestration, shadow state management, and validation
Author: AnNingUI
Latest version: 5.3.0

# @fluxgpu/core

Graph orchestration, shadow state management, and validation for FluxGPU.

## Overview

This package provides the core domain logic:

- **ShadowState**: CPU-side state tracking for GPU resources
- **Graph Orchestration**: Dependency resolution and command scheduling
- **Validation**: Resource lifecycle and state validation

## Installation

```bash
pnpm add @fluxgpu/core
```

## Usage

### Shadow State

```typescript
import { ShadowState } from '@fluxgpu/core';

const state = new ShadowState();

// Track buffer creation
state.createBuffer('buffer-1', { size: 1024, usage: 'storage' });

// Query state
const buffer = state.getBuffer('buffer-1');
console.log(buffer.size); // 1024

// Validate operations
state.validateWrite('buffer-1', 0, 512); // throws if invalid
```

## Architecture Role

Part of the **Domain Layer**, this package:

- Depends only on `@fluxgpu/contracts`
- Contains pure business logic with no platform dependencies
- Can be tested without any GPU or browser APIs
npm package: @fluxgpu/host-browser
Description: Browser runtime adapter for FluxGPU - Workers, DOM integration, and canvas management
Author: AnNingUI
Latest version: 5.3.0

# @fluxgpu/host-browser

Browser runtime adapter for FluxGPU.

## Overview

This package provides browser-specific implementations:

- **BrowserAdapter**: Main thread to Worker communication
- **DOM Integration**: Canvas and event handling
- **Resource Management**: Browser-specific resource lifecycle

## Installation

```bash
pnpm add @fluxgpu/host-browser
```

## Usage

### Browser Adapter

```typescript
import { BrowserAdapter } from '@fluxgpu/host-browser';

const adapter = new BrowserAdapter();

// Initialize with canvas
await adapter.initialize(canvas);

// Send commands to worker
adapter.send(command);

// Handle responses
adapter.onMessage((response) => {
  console.log('GPU response:', response);
});
```

## Architecture Role

Part of the **Infrastructure Layer**, this package:

- Implements browser-specific ports defined in `@fluxgpu/contracts`
- Manages Worker thread lifecycle
- Handles DOM events and canvas integration
npm package: @fluxgpu/protocol
Description: Platform-agnostic binary communication protocol for GPU command serialization
Author: AnNingUI
Latest version: 5.3.0

# @fluxgpu/protocol

Platform-agnostic binary communication protocol for FluxGPU.

## Overview

This package provides efficient serialization for GPU commands, enabling:

- Worker thread communication
- Network transmission
- Command recording and replay

## Installation

```bash
pnpm add @fluxgpu/protocol
```

## Usage

### Serialize Commands

```typescript
import { serializeCommand, deserializeCommand } from '@fluxgpu/protocol';
import type { CommandBuffer } from '@fluxgpu/contracts';
import { Opcode } from '@fluxgpu/contracts';

const command: CommandBuffer = {
  id: 'cmd-001',
  opcode: Opcode.CreateBuffer,
  payload: new Uint8Array([1, 2, 3, 4]),
  dependencies: [],
};

// Serialize to binary
const bytes = serializeCommand(command);

// Deserialize back
const restored = deserializeCommand(bytes);
```

### Batch Operations

```typescript
import { serializeBatch, deserializeBatch } from '@fluxgpu/protocol';

const commands = [command1, command2, command3];
const batch = serializeBatch(commands);
const restored = deserializeBatch(batch);
```

## Wire Format

Commands are serialized as:

```
┌──────────┬──────────┬──────────┬──────────┬──────────�?
�? Header  �? Opcode  �? ID Len  �?   ID    �?Payload  �?
�? 4 bytes �? 1 byte  �? 2 bytes �? N bytes �? M bytes �?
└──────────┴──────────┴──────────┴──────────┴──────────�?
```

## Architecture Role

Part of the **Bridge Layer**, this package:

- Enables communication between main thread and workers
- Provides platform-agnostic serialization
- Supports future network/IPC use cases