# Queue

> WelineFramework queue diagnostics and operations guide. Use when working on Weline\Queue, queue CLI commands, queue registration, queue_id/biz_key lookups, w_query('queue', ...) CRUD/stat queries, or failures involving queue:collect, queue:run, QueueInterface, and framework queue rows.

- **Type:** Skill
- **Install:** `agentstack add skill-aiweline-welineframework-queue`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Aiweline](https://agentstack.voostack.com/s/aiweline)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [Aiweline](https://github.com/Aiweline)
- **Source:** https://github.com/Aiweline/WelineFramework/tree/master/.codex/skills/queue

## Install

```sh
agentstack add skill-aiweline-welineframework-queue
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Queue

Use this skill for WelineFramework queue inspection, repair, and operation in this source repository. Prefer the framework query provider and queue CLI over direct database poking unless source-level diagnosis requires model internals.

## First Pass

1. Read the current queue source before assuming docs are current:
   - `app/code/Weline/Queue/extends/module/Weline_Framework/Query/QueueQueryProvider.php`
   - `app/code/Weline/Queue/Console/Queue/Collect.php`
   - `app/code/Weline/Queue/Console/Queue/Run.php`
   - `app/code/Weline/Queue/Console/Queue/Type/Listing.php`
   - `app/code/Weline/Queue/Model/Queue.php`
2. Use `w_query('queue', ...)` for runtime queue reads and business-level writes. Direct DB reads can miss framework casting, EAV/model behavior, event dispatching, and current query-provider semantics.
3. Preserve side-effect boundaries. `stats`, `get`, `getByBizKey`, `list`, `getTypeIdByClass`, and `queue:type:listing` are diagnostic. `create`, `update`, `delete`, `queue:collect`, and `queue:run` change state or execute work.
4. New cross-module consumers implement `Weline\Queue\Api\QueueConsumerInterface` and receive `QueueTaskContextInterface`. `Weline\Queue\QueueInterface` remains a runtime compatibility boundary for existing third-party consumers only.

## Queue CLI

Use these commands from the repository root.

```powershell
php bin/w queue:collect
```

Collect queue types from modules into `weline_queue_type`. Run this after adding or changing queue classes, or when `getTypeIdByClass` cannot resolve a class. The collector only registers instantiable classes that implement either the public `Weline\Queue\Api\QueueConsumerInterface` or the legacy `Weline\Queue\QueueInterface`; helper/static classes in a `Queue/` directory are not queue implementations.

```powershell
php bin/w queue:type:listing
php bin/w queue:type:listing ExampleQueue
php bin/w queue:type:listing Vendor_Module
```

List registered queue types. Extra arguments are search terms matched against name, module, and class.

```powershell
php bin/w queue:run --id=77
php bin/w queue:run --id=77 -f
php bin/w queue:run --id=77 --force
```

Run one queue item by `weline_queue.queue_id`.

Use `-f/--force` only when intentionally taking over or rebuilding the same queue item. Current behavior:

- If the same queue is marked `running`, force mode terminates the old same-ID process before continuing.
- It injects `_force_rebuild=1` into queue content when content is JSON.
- It clears previous `result` and `process` so new logs are readable.

Do not cite `queue:status` as a real command unless the current source contains a command class for it.

## w_query Examples

Bootstrap the app for ad hoc diagnostics:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue', 'stats'));"
```

Read one queue:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'get', ['queue_id' => 77]));"
```

Find latest queue by business key:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'getByBizKey', ['biz_key' => 'example:1']));"
```

List recent queues without dumping huge stream logs:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; $r=w_query('queue','list',['page_size'=>10]); foreach($r['items'] as $it){ $row=is_object($it)&&method_exists($it,'getData')?$it->getData():$it; echo json_encode(['queue_id'=>$row['queue_id']??null,'status'=>$row['status']??null,'module'=>$row['module']??null,'name'=>$row['name']??null,'biz_key'=>$row['biz_key']??null], JSON_UNESCAPED_UNICODE), PHP_EOL; }"
```

Filter by status or search text:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; $r=w_query('queue','list',['status'=>'error','q'=>'example','page_size'=>20]); foreach($r['items'] as $it){ $row=is_object($it)&&method_exists($it,'getData')?$it->getData():$it; echo ($row['queue_id']??'') . ' ' . ($row['status']??'') . ' ' . ($row['name']??'') . PHP_EOL; }"
```

Resolve a type id by class:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue','getTypeIdByClass',['class'=>'Vendor\\Module\\Queue\\ExampleQueue']));"
```

Create a queue through the provider:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','create',['class'=>'Vendor\\Module\\Queue\\ExampleQueue','name'=>'Example task','module'=>'Vendor_Module','content'=>['foo'=>'bar'],'biz_key'=>'example:1']));"
```

Update a safe subset of fields:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','update',['queue_id'=>77,'patch'=>['status'=>'pending','pid'=>0,'result'=>'','process'=>'']]));"
```

Delete only when intended:

```powershell
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','delete',['queue_id'=>77]));"
```

Use `force => true` only when the queue is running and deletion is explicitly intended.

## Provider Operations

`w_query('queue', OP, PARAMS)` currently supports:

- `get` / `load`: require `queue_id` or `id`; return one queue row or `null`.
- `getByBizKey`: require `biz_key`; return the latest matching row.
- `list`: filters include `page`, `page_size`, `module`, `status`, `type_id`, `queue_id`, `biz_key`, and `q`; returns `items` and `pagination`.
- `stats`: return counts for `all`, `pending`, `running`, `done`, `error`, and `stop`.
- `getTypeIdByClass`: resolve a public or legacy queue consumer class to `type_id`; if missing, it runs collection internally.
- `create`: require `name`, `module`, and either `type_id` or `class`; optional `content`, `status`, `auto`, `biz_key`.
- `update`: locate by `queue_id`/`id` or `biz_key`; pass `patch` or top-level fields. Safe patch fields include `name`, `module`, `status`, `content`, `result`, `process`, `biz_key`, `auto`, `finished`, `pid`, and `type_id`.
- `delete`: locate by `queue_id`/`id` or `biz_key`; running queues require `force`.

Valid statuses are `pending`, `running`, `done`, `error`, and `stop`.

## Validation

After queue registration or consumer-contract filtering changes:

```powershell
php -l app/code/Weline/Queue/Helper/Helper.php
php bin/w queue:collect
php bin/w queue:type:listing
```

After command behavior changes:

```powershell
php bin/w queue:run --help
php bin/w queue:collect --help
php bin/w queue:type:listing --help
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Aiweline](https://github.com/Aiweline)
- **Source:** [Aiweline/WelineFramework](https://github.com/Aiweline/WelineFramework)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-aiweline-welineframework-queue
- Seller: https://agentstack.voostack.com/s/aiweline
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
