{
  "filename": "orders/queue.go",
  "rule": "- name: queue-acceptance-truthful\n  where: \"orders/queue.go\"\n  ensure: >-\n    If the job cannot be enqueued and the select default branch runs, QueueReceipt must return an overload failure, not a 202 queued response.",
  "corrected": "package orders\nimport \"github.com/gin-gonic/gin\"\n\ntype ReceiptJob struct { OrderID string; TenantID string }\n\nfunc QueueReceipt(jobs chan<- ReceiptJob) gin.HandlerFunc {\n    return func(c *gin.Context) {\n        tenant := c.GetString(\"tenant_id\")\n        if tenant == \"\" { c.AbortWithStatus(401); return }\n        job := ReceiptJob{OrderID:c.Param(\"id\"), TenantID:tenant}\n        select {\n        case jobs <- job:\n            c.JSON(202, gin.H{\"status\":\"queued\"})\n        default:\n            c.JSON(503, gin.H{\"error\":\"queue full\"})\n        }\n    }\n}\n",
  "broken": "package orders\nimport \"github.com/gin-gonic/gin\"\n\ntype ReceiptJob struct { OrderID string; TenantID string }\n\nfunc QueueReceipt(jobs chan<- ReceiptJob) gin.HandlerFunc {\n    return func(c *gin.Context) {\n        tenant := c.GetString(\"tenant_id\")\n        if tenant == \"\" { c.AbortWithStatus(401); return }\n        job := ReceiptJob{OrderID:c.Param(\"id\"), TenantID:tenant}\n        select {\n        case jobs <- job:\n            c.JSON(202, gin.H{\"status\":\"queued\"})\n        default:\n            c.JSON(202, gin.H{\"status\":\"queued\"})\n        }\n    }\n}\n",
  "regression": [
    "            c.JSON(503, gin.H{\"error\":\"queue full\"})",
    "            c.JSON(202, gin.H{\"status\":\"queued\"})"
  ],
  "test_scenarios": [
    [
      "Writable queue",
      "Job contains immutable id and tenant; 202"
    ],
    [
      "Full queue",
      "503, no false acceptance"
    ],
    [
      "Missing trusted tenant",
      "401, no job"
    ],
    [
      "Handler returns",
      "Worker never reads pooled Gin context"
    ]
  ],
  "test_source": null,
  "test_command": "go test ./orders -run TestQueueReceipt"
}