# STATUS CODES - NoName Platform
> **Version**: 2.0 (2026-06-20)
> **Rule**: CRY-07 - All entity states use these codes. No magic numbers in code.
> **Location**: `Y:\documents\source\STATUS_CODES.md` (LOCAL ONLY per OPS-09)
> **Source of Truth**: `Y:\5\var\www\shared\status_codes.php` - PHP `StatusCode` class
> **Format**: 4-digit codes, grouped by domain (first digit = domain)

---

## Code Format

All status codes are 4-digit integers. First digit identifies the domain:

| Prefix | Domain                 | Context                                 |
| ------ | ---------------------- | --------------------------------------- |
| `1xxx` | Users & Exclusions     | User accounts, self-exclusion requests  |
| `2xxx` | Orders & Commerce      | Order lifecycle                         |
| `3xxx` | Products & Visibility  | Catalog management                      |
| `4xxx` | Payments & Wallets     | Payment methods, transactions           |
| `5xxx` | Nodes & Infrastructure | Fleet status, commands, roles           |
| `6xxx` | Content & Analytics    | Inventory, storefront, visits, settings |
| `7xxx` | Security & Threats     | Threat levels, IP blocking, canary      |
| `8xxx` | Support & Email        | Tickets, urgency, email verification    |
| `9xxx` | Admin & RBAC           | Admin users, roles, security log        |

---

## 1xxx - USERS & EXCLUSIONS

### User Status
| Code | Constant          | Label      | Badge   | Tables  |
| ---- | ----------------- | ---------- | ------- | ------- |
| 1001 | `USER_ACTIVE`     | Active     | success | `users` |
| 1002 | `USER_SUSPENDED`  | Suspended  | warning | `users` |
| 1003 | `USER_BANNED`     | Banned     | danger  | `users` |
| 1004 | `USER_UNVERIFIED` | Unverified | default | `users` |
| 1005 | `USER_VERIFIED`   | Verified   | success | `users` |
| 1006 | `USER_DELETED`    | Deleted    | danger  | `users` |

### Exclusion Request Status
| Code | Constant          | Label      | Tables                    |
| ---- | ----------------- | ---------- | ------------------------- |
| 1010 | `EXCL_PENDING`    | Pending    | `self_exclusion_requests` |
| 1011 | `EXCL_PROCESSING` | Processing | `self_exclusion_requests` |
| 1012 | `EXCL_COMPLETED`  | Completed  | `self_exclusion_requests` |
| 1013 | `EXCL_REJECTED`   | Rejected   | `self_exclusion_requests` |

---

## 2xxx - ORDERS & COMMERCE

### Order Lifecycle
| Code | Constant           | Label      | Badge   | Category  | Terminal? |
| ---- | ------------------ | ---------- | ------- | --------- | --------- |
| 2001 | `ORDER_PENDING`    | Pending    | warning | active    | No        |
| 2002 | `ORDER_PAID`       | Paid       | success | active    | No        |
| 2003 | `ORDER_PROCESSING` | Processing | info    | active    | No        |
| 2004 | `ORDER_PACKED`     | Packed     | info    | active    | No        |
| 2005 | `ORDER_SHIPPED`    | Shipped    | info    | active    | No        |
| 2006 | `ORDER_DELIVERED`  | Delivered  | success | terminal  | Yes       |
| 2007 | `ORDER_CANCELLED`  | Cancelled  | danger  | terminal  | Yes       |
| 2008 | `ORDER_REFUNDED`   | Refunded   | danger  | terminal  | Yes       |
| 2009 | `ORDER_DISPUTED`   | Disputed   | danger  | exception | No        |
| 2010 | `ORDER_HOLD`       | Hold       | warning | exception | No        |

**Order Flow**: `2001->2002->2003->2004->2005->2006` (linear happy path)
Exception states `2007/2008/2009/2010` reachable from any active state.

---

## 3xxx - PRODUCTS & VISIBILITY

### Listing Status
| Code | Constant            | Label     | Badge   | Tables               |
| ---- | ------------------- | --------- | ------- | -------------------- |
| 3001 | `LISTING_DRAFT`     | Draft     | default | `products` (DEFAULT) |
| 3002 | `LISTING_ACTIVE`    | Active    | success | `products`           |
| 3003 | `LISTING_SOLD_OUT`  | Sold Out  | warning | `products`           |
| 3004 | `LISTING_PAUSED`    | Paused    | warning | `products`           |
| 3005 | `LISTING_SUSPENDED` | Suspended | danger  | `products`           |
| 3006 | `LISTING_DELETED`   | Deleted   | danger  | `products`           |

### Visibility Codes
| Code | Constant       | Label    | Tables                     |
| ---- | -------------- | -------- | -------------------------- |
| 3050 | `VIS_PUBLIC`   | Public   | `products.visibility_code` |
| 3051 | `VIS_PRIVATE`  | Private  | `products.visibility_code` |
| 3052 | `VIS_UNLISTED` | Unlisted | `products.visibility_code` |

---

## 4xxx - PAYMENTS & WALLETS

### Payment Methods
| Code | Constant        | Label      | Tables                                       |
| ---- | --------------- | ---------- | -------------------------------------------- |
| 4001 | `PAY_STRIPE`    | Stripe     | `payments`                                   |
| 4002 | `PAY_ETRANSFER` | E-Transfer | `payments`                                   |
| 4003 | `PAY_CRYPTO`    | Crypto     | `payments` - DEPRECATED (removed 2026-06-16) |
| 4004 | `PAY_CREDIT`    | Credit     | `payments`                                   |

### Transaction Status
| Code | Constant       | Label     | Tables                            |
| ---- | -------------- | --------- | --------------------------------- |
| 4010 | `TX_PENDING`   | Pending   | `wallet_transactions`, `payments` |
| 4011 | `TX_CONFIRMED` | Confirmed | `wallet_transactions`, `payments` |
| 4012 | `TX_FAILED`    | Failed    | `wallet_transactions`, `payments` |
| 4013 | `TX_REFUNDED`  | Refunded  | `wallet_transactions`, `payments` |

### Wallet Status
| Code | Constant          | Label         | Tables    |
| ---- | ----------------- | ------------- | --------- |
| 4020 | `WALLET_ACTIVE`   | Active        | `wallets` |
| 4021 | `WALLET_DISABLED` | Cold/Disabled | `wallets` |

### Crypto Currency Codes (minimum confirmations)
| Code | Currency  | Min Confirmations |
| ---- | --------- | ----------------- |
| 4030 | BTC       | 10                |
| 4031 | ETH       | 12                |
| 4032 | XMR/Other | 12                |

> Crypto codes 4030-4032 are DEPRECATED (removed 2026-06-16)

---

## 5xxx - NODES & INFRASTRUCTURE

### Node Status
| Code | Constant              | Label          | Badge   | Tables                                                         |
| ---- | --------------------- | -------------- | ------- | -------------------------------------------------------------- |
| 5001 | `NODE_ONLINE`         | Online         | success | `nodes` (DEFAULT), `categories`, `stores`, many `sec_*` tables |
| 5002 | `NODE_OFFLINE`        | Offline        | danger  | `nodes`                                                        |
| 5003 | `NODE_PROVISIONING`   | Provisioning   | warning | `nodes`                                                        |
| 5004 | `NODE_DECOMMISSIONED` | Decommissioned | default | `nodes`                                                        |
| 5005 | `NODE_MAINTENANCE`    | Maintenance    | -       | `nodes`                                                        |

> NOTE: `5001` is also used as a generic "active" DEFAULT for many non-node tables
> (categories, stores, orders, sec_* tables). This is technically an overloaded usage.

### Command Status
| Code | Constant        | Label           | Tables                                  |
| ---- | --------------- | --------------- | --------------------------------------- |
| 5000 | -               | Priority Normal | `node_commands.priority_code` (DEFAULT) |
| 5010 | `CMD_QUEUED`    | Queued          | `node_commands` (DEFAULT)               |
| 5011 | `CMD_APPROVED`  | Approved        | `node_commands`                         |
| 5012 | `CMD_EXECUTING` | Executing       | `node_commands`                         |
| 5013 | `CMD_COMPLETED` | Completed       | `node_commands`                         |
| 5014 | `CMD_FAILED`    | Failed          | `node_commands`                         |
| 5015 | `CMD_CANCELLED` | Cancelled       | `node_commands`                         |

### Node Role Codes
| Code | Constant                       | Label  | FleetOrchestrator Mapping |
| ---- | ------------------------------ | ------ | ------------------------- |
| 5050 | `ROLE_SHIELD`                  | Shield | `shield` -> 5050          |
| 5051 | `ROLE_PROXY`                   | Proxy  | `proxy` -> 5051           |
| 5052 | `ROLE_FILTER`                  | Filter | `filter` -> 5052          |
| 5053 | `ROLE_DNS`                     | DNS    | `dns` -> 5053             |
| 5054 | `ROLE_ORIGIN`                  | Origin | `origin` -> 5054          |
| 5055 | `ROLE_PAYMENT` / `ROLE_ENGINE` | Engine | `engine` -> 5055          |
| 5056 | `ROLE_EMAIL`                   | Email  | - (DECOMMISSIONED node)   |

**Critical roles**: [5050, 5051, 5052, 5054, 5055]

---

## 6xxx - CONTENT & ANALYTICS

### Content Status
| Code | Constant           | Label    | Badge   | Tables                                     |
| ---- | ------------------ | -------- | ------- | ------------------------------------------ |
| 6001 | `CONTENT_ACTIVE`   | Active   | success | `inventory`, `storefront_blocks` (DEFAULT) |
| 6002 | `CONTENT_HIDDEN`   | Hidden   | default | content tables                             |
| 6003 | `CONTENT_DELETED`  | Deleted  | danger  | content tables                             |
| 6004 | `CONTENT_DRAFT`    | Draft    | -       | content tables                             |
| 6005 | `CONTENT_APPROVED` | Approved | -       | content tables                             |
| 6006 | `CONTENT_REJECTED` | Rejected | -       | content tables                             |
| 6099 | `CONTENT_ARCHIVED` | Archived | -       | content tables                             |

### Visit/Analytics Status
| Code | Constant          | Label     | Tables    |
| ---- | ----------------- | --------- | --------- |
| 6010 | `VISIT_BOUNCE`    | Bounce    | analytics |
| 6011 | `VISIT_ENGAGED`   | Engaged   | analytics |
| 6012 | `VISIT_CONVERTED` | Converted | analytics |

### Campaign/Meta Status
| Code | Constant        | Label    | Tables              |
| ---- | --------------- | -------- | ------------------- |
| 6020 | `META_ACTIVE`   | Active   | marketing campaigns |
| 6021 | `META_PAUSED`   | Paused   | marketing campaigns |
| 6022 | `META_ARCHIVED` | Archived | marketing campaigns |

### Settings Status
| Code | Constant           | Label    | Tables   |
| ---- | ------------------ | -------- | -------- |
| 6030 | `SETTING_ENABLED`  | Enabled  | settings |
| 6031 | `SETTING_DISABLED` | Disabled | settings |

---

## 7xxx - SECURITY & THREATS

### Threat Levels
| Code | Constant          | Label    | Badge   | Tables          |
| ---- | ----------------- | -------- | ------- | --------------- |
| 7001 | `THREAT_LOW`      | Low      | info    | security tables |
| 7002 | `THREAT_MEDIUM`   | Medium   | warning | security tables |
| 7003 | `THREAT_HIGH`     | High     | danger  | security tables |
| 7004 | `THREAT_CRITICAL` | Critical | danger  | security tables |

### IP Block Status
| Code | Constant      | Label    | Tables                                 |
| ---- | ------------- | -------- | -------------------------------------- |
| 7010 | `IP_BLOCKED`  | Blocked  | `blacklist`, `payment_cards` (DEFAULT) |
| 7011 | `IP_RELEASED` | Released | `blacklist`                            |

### Canary Token Status
| Code | Constant          | Label    | Tables                |
| ---- | ----------------- | -------- | --------------------- |
| 7020 | `CANARY_ACTIVE`   | Active   | `sec_canary_triggers` |
| 7021 | `CANARY_DISABLED` | Disabled | `sec_canary_triggers` |

### Generic Default
| Code | Constant | Label           | Tables                                                                                                                                           |
| ---- | -------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 7000 | -        | Generic/Initial | `wallets`, `wallet_transactions`, `blacklist`, `sec_blacklist_nft`, `marketing_campaigns`, `marketing_links`, `mkt_social_nodes`, `social_posts` |

> NOTE: `7000` has NO constant defined in StatusCode class and NO label in $labels map.
> This is a documentation gap - consider adding `GENERIC_DEFAULT = 7000`.

---

## 8xxx - SUPPORT & EMAIL

### Support Ticket Status
| Code | Constant           | Label     | Badge   | Tables                                      |
| ---- | ------------------ | --------- | ------- | ------------------------------------------- |
| 8001 | `TICKET_OPEN`      | Open      | warning | `support_messages`, `email_queue` (DEFAULT) |
| 8002 | `TICKET_WAITING`   | Waiting   | default | `support_messages`                          |
| 8003 | `TICKET_ESCALATED` | Escalated | danger  | `support_messages`                          |
| 8004 | `TICKET_RESOLVED`  | Resolved  | success | `support_messages`                          |
| 8005 | `TICKET_CLOSED`    | Closed    | default | `support_messages`                          |

### Urgency Codes
| Code | Constant       | Label    | Tables          |
| ---- | -------------- | -------- | --------------- |
| 8010 | `URG_LOW`      | Low      | support urgency |
| 8011 | `URG_NORMAL`   | Normal   | support urgency |
| 8012 | `URG_HIGH`     | High     | support urgency |
| 8013 | `URG_CRITICAL` | Critical | support urgency |

### Maid Response Codes (Engine AI inference)
| Code | Constant        | Label         | Badge   | Tables            |
| ---- | --------------- | ------------- | ------- | ----------------- |
| 8020 | `MAID_DRAFT`    | Maid Draft    | warning | `support_replies` |
| 8021 | `MAID_APPROVED` | Maid Approved | success | `support_replies` |
| 8022 | `MAID_REJECTED` | Maid Rejected | danger  | `support_replies` |

### SQL-Only Status Codes (not in StatusCode class - GAP)
| Code | Label                           | Tables                      | Notes                    |
| ---- | ------------------------------- | --------------------------- | ------------------------ |
| 8101 | Email Verification Pending      | `email_verifications`       | DEFAULT, no PHP constant |
| 8201 | Self-Exclusion Pending          | `self_exclusion_requests`   | DEFAULT, no PHP constant |
| 8301 | Fulfillment Notification Queued | `fulfillment_notifications` | DEFAULT, no PHP constant |
| 8401 | Shipment Created                | `shipments`                 | DEFAULT, no PHP constant |

---

## 9xxx - ADMIN & RBAC

### Admin User Status
| Code | Constant         | Label    | Badge   | Tables                                         |
| ---- | ---------------- | -------- | ------- | ---------------------------------------------- |
| 9001 | `ADMIN_ACTIVE`   | Active   | success | `admin_users`, `sec_hash_mismatches` (DEFAULT) |
| 9002 | `ADMIN_DISABLED` | Disabled | danger  | `admin_users`                                  |

### Admin Role Codes (RBAC Tiers)
| Code | Constant         | Label    | Permission Level                       |
| ---- | ---------------- | -------- | -------------------------------------- |
| 9010 | `ADMIN_OWNER`    | Owner    | Full access - fleet, security, billing |
| 9011 | `ADMIN_ADMIN`    | Admin    | All operations except owner settings   |
| 9012 | `ADMIN_OPERATOR` | Operator | Orders, products, support              |
| 9013 | `ADMIN_VIEWER`   | Viewer   | Read-only dashboard access             |

### Security Response Status (SQL-only - GAP)
| Code | Label                     | Tables                       |
| ---- | ------------------------- | ---------------------------- |
| 9101 | Security Response Pending | `sec_response_log` (DEFAULT) |

---

## Event Category Codes (Separate System)

Used in the events/audit system, NOT in StatusCode class:

| Code | Constant       | Label    | Used In               |
| ---- | -------------- | -------- | --------------------- |
| 1    | `CAT_CREATE`   | create   | `sec_events.category` |
| 2    | `CAT_MODIFY`   | modify   | `sec_events.category` |
| 3    | `CAT_DELETE`   | delete   | `sec_events.category` |
| 4    | `CAT_VERIFY`   | verify   | `sec_events.category` |
| 5    | `CAT_READ`     | read     | `sec_events.category` |
| 6    | `CAT_AUTH`     | auth     | `sec_events.category` |
| 7    | `CAT_SYSTEM`   | system   | `sec_events.category` |
| 8    | `CAT_FLEET`    | fleet    | `sec_events.category` |
| 9    | `CAT_SECURITY` | security | `sec_events.category` |

---

## SQL DEFAULT -> Code Mapping

Quick reference for which DEFAULT values are used in `CREATE TABLE` statements:

| DEFAULT Value | Code Label           | Tables Using It                                                    |
| ------------- | -------------------- | ------------------------------------------------------------------ |
| 3001          | LISTING_DRAFT        | products                                                           |
| 5001          | NODE_ONLINE          | stores, categories, nodes, orders, all sec_* tables                |
| 5010          | CMD_QUEUED           | node_commands                                                      |
| 5000          | PRIORITY_NORMAL      | node_commands.priority_code                                        |
| 6001          | CONTENT_ACTIVE       | inventory, storefront_blocks                                       |
| 7000          | Generic Default      | wallets, wallet_transactions, blacklist, marketing_*, social_posts |
| 7010          | IP_BLOCKED           | payment_cards                                                      |
| 8001          | TICKET_OPEN          | support_messages, email_queue                                      |
| 8101          | Email Verify Pending | email_verifications                                                |
| 8201          | Exclusion Pending    | self_exclusion_requests                                            |
| 8301          | Fulfillment Queued   | fulfillment_notifications                                          |
| 8401          | Shipment Created     | shipments                                                          |
| 9001          | ADMIN_ACTIVE         | admin_users, sec_hash_mismatches                                   |
| 9101          | Response Pending     | sec_response_log                                                   |

---

## Known Gaps & TODOs

> [!WARNING]
> These issues should be addressed in the StatusCode PHP class:

1. **`7000` has no constant** - Define `GENERIC_DEFAULT = 7000` with label
2. **Codes 8101, 8201, 8301, 8401** - Add PHP constants for these SQL-only codes
3. **Code 9101** - Add PHP constant for security response status
4. **`5001` overloaded** - Used for 15+ tables as generic "active". Consider domain-specific defaults
5. **`products.visibility_code` defaults to 5001** - Should probably default to `3050` (VIS_PUBLIC)
6. **Missing badge definitions** - Codes 3050-3052, 4001-4013, 5005, 5010-5015, 8010-8013, 9010-9013 have labels but no badge colors

---

## Adding New Codes

1. Choose the correct domain prefix (1-9)
2. Check this file for the next available number in that range
3. Add the constant to `Y:\5\var\www\shared\status_codes.php`
4. Add the label to the `$labels` array
5. Add the badge color to the `$badges` array
6. Update this STATUS_CODES.md file
7. Per Rule **OPS-10**: If code uses an undocumented status, STOP and add it here first

