[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M758EB6QGN5W65TW9E58N034":3,"skill-same:01M758EB6QGN5W65TW9E58N034":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":42,"ownerHtmlUrl":43,"ownerBlogUrl":6,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M758EB6QGN5W65TW9E58N034","pgmq-consumer-patterns",null,"Use when fixing bus consumers or false-unreachable agents.","lukemcqueen\u002Fsteadfaste-fleet","lukemcqueen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F405240?v=4","01M757MHPAGRXTJAT46SKZP98R","Luke McQueen","01M757MHPZ573KP8DT9GB8SBQ7",4,"MIT","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fpgmq-consumer-patterns\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: pgmq-consumer-patterns\ndescription: \"Use when fixing bus consumers or false-unreachable agents.\"\nversion: 1.0.0\nauthor: Steadfaste Fleet\nmetadata:\n  hermes:\n    tags: [bus, pgmq, consumers, migration, health]\n    related_skills: [fleet-bus, agent-health-monitoring]\n---\n\n# PGMQ Consumer Patterns\n\nClass-level patterns for building and debugging PGMQ bus consumers, learned from\nthe inbox→PGMQ migration (2026-08). Applies to any queue where one process\ndrains and others need the data.\n\n## Pattern 1: The Drainer Must Persist — Consumers Read State, Not the Live Queue\n\n**Rule:** Any queue that one cron drains is invisible to other consumers. PGMQ\n`read` pops only `pending` messages; a consumer that runs *after* the drainer\nwill find the queue empty every time. Never have a second consumer race the\ndrainer on the live queue — especially an hourly consumer vs a 10-minute\ndrainer.\n\n**Correct design:**\n```\nproducer ──send──> queue ──drainer (every 10m)──> archive\n                            └── persist latest per key ──> state.json\nconsumer (hourly) ──reads state.json──> data\nconsumer fallback: bus_read(queue, vt=60) peek for not-yet-drained pings\n```\n\n**Example (health pings, fixed 2026-08-04, commit 87df0c73):**\n- `orch-clean-health-queue.py` drains `inbox_health_check` every 10m; while\n  archiving it persists each agent's latest vector+ts to\n  `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` and updates `last-seen.json`.\n- `orch-health-report.py` reads that state file; live `bus_read` is only a\n  fallback for pings the drainer hasn't caught yet.\n\n**Symptoms of violating this rule:** \"agent 🔴 unreachable despite healthy\npushes\", stale `last-seen.json` for days\u002Fweeks, queue depth near 0 at consumer\ntime.\n\n## Pattern 2: Transport-Migration Sweep — Silent-404 Consumers\n\n**Rule:** When a transport migrates (file inbox → PGMQ bus, HTTP → gRPC, etc.),\nthe old endpoint often disappears with no error to callers. Any consumer still\nhitting the retired surface gets a silent 404 → returns None → downstream\nfalse alarms. Docs and skills lag too.\n\n**Sweep checklist (grep the whole repo, not just the obvious dirs):**\n```\ngrep -rn \"api\u002Finbox\\|api\u002Fdelete\\|MOSES_INBOX_URL\\|moses-inbox.conf\" ops\u002F scripts\u002F skills\u002F docs\u002F\n```\nAlso grep for removed script names (e.g. `orch-team-health`) — docs reference\nthem long after deletion.\n\n**Verify claims against LIVE code before fixing:** the proposal said a skill was\nstale; confirmation required checking (a) the deployed bus server's route table\n(no `\u002Fapi\u002Finbox`), (b) the actual push script's endpoint, (c) which consumer\nstill called the old API, (d) whether the referenced poller was removed from the\nrepo (`git log --diff-filter=D`).\n\n## Pattern 3: Verify End-to-End, Not Just Unit\n\nAfter a consumer fix, prove the full path with real messages:\n1. Seed: `bus_send(\"inbox_health_check\", {\"from\": \"\u003Cagent>\", \"subject\": \"health\", \"body\": \"{...}\"})`\n2. Drain: run the drainer exactly as cron does (set `FLEET_REPO` and\n   `PYTHONPATH=ops\u002Fscripts` — direct `python3 path\u002Fto\u002Fscript.py` from another\n   cwd fails the `hermes_paths` import).\n3. Consume: run the report script; confirm the agent shows ✅.\n\n## Pattern 4: Alert-Stop ≠ Success — the Mirror-Race \u002F Consumer-Took-It Check\n\n**Rule:** A mirror\u002Fforwarder failure alert disappearing does NOT mean the peer\ndelivery succeeded. Any consumer that takes the same message off the source\nqueue makes the next mirror tick silent.\n\n**Verified example (2026-08-07, `orch-bus-forwarder-sync`):** the alert\n`⚠️ LOCAL→PEER: 1 failed • inbox_orchestrator\u002Fee8d75afb2` fired on 2 ticks for\na kustos PROPOSAL, then stopped — not because the peer received it, but\nbecause the backup orchestrator's `agent-message-handler` polls the shared\n`inbox_orchestrator` directly and archived the message from the source queue\n(`bus.archives.archived_by='esther'`, 3 min after enqueue). The mirror never\ndelivered it.\n\n**Correct diagnosis:**\n1. **Frequency across ALL ticks first** (`~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002F`):\n   one message alerting 2–3 ticks then silent = consumed or transient; the\n   same message alerting EVERY tick = persistent auth\u002FACL problem.\n2. **Find who really took it:** `bus.archive()` INSERTs into `bus.archives`\n   then DELETEs from `bus.messages` — archived rows persist with\n   `archived_at` + `archived_by`. `archived_by=esther` on `inbox_orchestrator`\n   = backup consumed directly, never mirrored. `bus.delete()` hard-purges with\n   zero trace; `bus.recover_timeouts()` never touches fresh pending\n   main-queue messages.\n3. **Hash-suffix alert IDs:** the forwarder's bullet is `queue\u002Fdkey[-10:]`,\n   dkey = `corr:\u003Ccorrelation_id>` or\n   `hash:\u003Csha256(json.dumps(body, sort_keys=True, default=str))[:32]>`. A hash\n   ID is computed at runtime and matches NOTHING in the DB — recompute it over\n   candidate archived bodies and compare the tail. Corr-based IDs ARE\n   searchable via the `correlation_id` column.\n4. **The alert omits the HTTP status** — a persistent per-queue 403 (peer-bus\n   ACL grant needed) and a transient 5xx\u002Ftimeout look identical from the alert\n   alone; the tick-frequency pattern is the discriminator.\n\nFull worked example (timeline, SQL queries, hash-recompute snippet):\n`references\u002Fforwarder-failure-diagnosis.md`.\n\n## Pitfalls\n\n- **Direct script runs mislead.** A no_agent cron gets `PYTHONPATH` from\n  `build_subprocess_env()`; a bare `python3 script.py` from a random cwd will\n  `ModuleNotFoundError: hermes_paths`. Reproduce the cron env\n  (`FLEET_REPO=~\u002Fsteadfaste-fleet PYTHONPATH=~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts`).\n- **A queue drained before the consumer runs is NOT proof of a dead producer.**\n  Check the drainer's persistence file before blaming the push side.\n- **Deployed copies of scripts\u002Fskills are copies.** Fix the repo source, deploy\n  via `fleet-update.sh`, then verify the deployed file (SOURCE header differs\n  from repo raw MD5 — hash comparison must strip the header).\n","# PGMQ Consumer Patterns\n\nClass-level patterns for building and debugging PGMQ bus consumers, learned from\nthe inbox→PGMQ migration (2026-08). Applies to any queue where one process\ndrains and others need the data.\n\n## Pattern 1: The Drainer Must Persist — Consumers Read State, Not the Live Queue\n\n**Rule:** Any queue that one cron drains is invisible to other consumers. PGMQ\n`read` pops only `pending` messages; a consumer that runs *after* the drainer\nwill find the queue empty every time. Never have a second consumer race the\ndrainer on the live queue — especially an hourly consumer vs a 10-minute\ndrainer.\n\n**Correct design:**\n```\nproducer ──send──> queue ──drainer (every 10m)──> archive\n                            └── persist latest per key ──> state.json\nconsumer (hourly) ──reads state.json──> data\nconsumer fallback: bus_read(queue, vt=60) peek for not-yet-drained pings\n```\n\n**Example (health pings, fixed 2026-08-04, commit 87df0c73):**\n- `orch-clean-health-queue.py` drains `inbox_health_check` every 10m; while\n  archiving it persists each agent's latest vector+ts to\n  `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` and updates `last-seen.json`.\n- `orch-health-report.py` reads that state file; live `bus_read` is only a\n  fallback for pings the drainer hasn't caught yet.\n\n**Symptoms of violating this rule:** \"agent 🔴 unreachable despite healthy\npushes\", stale `last-seen.json` for days\u002Fweeks, queue depth near 0 at consumer\ntime.\n\n## Pattern 2: Transport-Migration Sweep — Silent-404 Consumers\n\n**Rule:** When a transport migrates (file inbox → PGMQ bus, HTTP → gRPC, etc.),\nthe old endpoint often disappears with no error to callers. Any consumer still\nhitting the retired surface gets a silent 404 → returns None → downstream\nfalse alarms. Docs and skills lag too.\n\n**Sweep checklist (grep the whole repo, not just the obvious dirs):**\n```\ngrep -rn \"api\u002Finbox\\|api\u002Fdelete\\|MOSES_INBOX_URL\\|moses-inbox.conf\" ops\u002F scripts\u002F skills\u002F docs\u002F\n```\nAlso grep for removed script names (e.g. `orch-team-health`) — docs reference\nthem long after deletion.\n\n**Verify claims against LIVE code before fixing:** the proposal said a skill was\nstale; confirmation required checking (a) the deployed bus server's route table\n(no `\u002Fapi\u002Finbox`), (b) the actual push script's endpoint, (c) which consumer\nstill called the old API, (d) whether the referenced poller was removed from the\nrepo (`git log --diff-filter=D`).\n\n## Pattern 3: Verify End-to-End, Not Just Unit\n\nAfter a consumer fix, prove the full path with real messages:\n1. Seed: `bus_send(\"inbox_health_check\", {\"from\": \"\u003Cagent>\", \"subject\": \"health\", \"body\": \"{...}\"})`\n2. Drain: run the drainer exactly as cron does (set `FLEET_REPO` and\n   `PYTHONPATH=ops\u002Fscripts` — direct `python3 path\u002Fto\u002Fscript.py` from another\n   cwd fails the `hermes_paths` import).\n3. Consume: run the report script; confirm the agent shows ✅.\n\n## Pattern 4: Alert-Stop ≠ Success — the Mirror-Race \u002F Consumer-Took-It Check\n\n**Rule:** A mirror\u002Fforwarder failure alert disappearing does NOT mean the peer\ndelivery succeeded. Any consumer that takes the same message off the source\nqueue makes the next mirror tick silent.\n\n**Verified example (2026-08-07, `orch-bus-forwarder-sync`):** the alert\n`⚠️ LOCAL→PEER: 1 failed • inbox_orchestrator\u002Fee8d75afb2` fired on 2 ticks for\na kustos PROPOSAL, then stopped — not because the peer received it, but\nbecause the backup orchestrator's `agent-message-handler` polls the shared\n`inbox_orchestrator` directly and archived the message from the source queue\n(`bus.archives.archived_by='esther'`, 3 min after enqueue). The mirror never\ndelivered it.\n\n**Correct diagnosis:**\n1. **Frequency across ALL ticks first** (`~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002F`):\n   one message alerting 2–3 ticks then silent = consumed or transient; the\n   same message alerting EVERY tick = persistent auth\u002FACL problem.\n2. **Find who really took it:** `bus.archive()` INSERTs into `bus.archives`\n   then DELETEs from `bus.messages` — archived rows persist with\n   `archived_at` + `archived_by`. `archived_by=esther` on `inbox_orchestrator`\n   = backup consumed directly, never mirrored. `bus.delete()` hard-purges with\n   zero trace; `bus.recover_timeouts()` never touches fresh pending\n   main-queue messages.\n3. **Hash-suffix alert IDs:** the forwarder's bullet is `queue\u002Fdkey[-10:]`,\n   dkey = `corr:\u003Ccorrelation_id>` or\n   `hash:\u003Csha256(json.dumps(body, sort_keys=True, default=str))[:32]>`. A hash\n   ID is computed at runtime and matches NOTHING in the DB — recompute it over\n   candidate archived bodies and compare the tail. Corr-based IDs ARE\n   searchable via the `correlation_id` column.\n4. **The alert omits the HTTP status** — a persistent per-queue 403 (peer-bus\n   ACL grant needed) and a transient 5xx\u002Ftimeout look identical from the alert\n   alone; the tick-frequency pattern is the discriminator.\n\nFull worked example (timeline, SQL queries, hash-recompute snippet):\n`references\u002Fforwarder-failure-diagnosis.md`.\n\n## Pitfalls\n\n- **Direct script runs mislead.** A no_agent cron gets `PYTHONPATH` from\n  `build_subprocess_env()`; a bare `python3 script.py` from a random cwd will\n  `ModuleNotFoundError: hermes_paths`. Reproduce the cron env\n  (`FLEET_REPO=~\u002Fsteadfaste-fleet PYTHONPATH=~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts`).\n- **A queue drained before the consumer runs is NOT proof of a dead producer.**\n  Check the drainer's persistence file before blaming the push side.\n- **Deployed copies of scripts\u002Fskills are copies.** Fix the repo source, deploy\n  via `fleet-update.sh`, then verify the deployed file (SOURCE header differs\n  from repo raw MD5 — hash comparison must strip the header).\n",{"name":5,"author":24,"version":25,"metadata":26,"description":7},"Steadfaste Fleet","1.0.0",{"hermes":27},{"tags":28,"related_skills":34},[29,30,31,32,33],"bus","pgmq","consumers","migration","health",[35,36],"fleet-bus","agent-health-monitoring","main","9dc0e92c5fa81d4db5292b205716e8ea0c00d10e","skills\u002Fdevops\u002Fpgmq-consumer-patterns",1,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet","steadfaste.com","https:\u002F\u002Fgithub.com\u002Flukemcqueen","AI Architect | Building Hermes Cortex: governed multi-agent AI for autonomous software engineering | Enterprise Tech Consultant","2026-11-14 22:33:34",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add lukemcqueen\u002Fsteadfaste-fleet --skill pgmq-consumer-patterns",{"tool":52,"command":53},"bunx","bunx skills add lukemcqueen\u002Fsteadfaste-fleet --skill pgmq-consumer-patterns",{"tool":55,"command":56},"pnpm","pnpm dlx skills add lukemcqueen\u002Fsteadfaste-fleet --skill pgmq-consumer-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fpgmq-consumer-patterns\u002FSKILL.md",true,[60,66],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fforwarder-failure-diagnosis.md","REFERENCE","参考文档",3630,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fpgmq-consumer-patterns\u002Freferences\u002Fforwarder-failure-diagnosis.md",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Finbox-api-retirement-2026-08.md",4436,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fpgmq-consumer-patterns\u002Freferences\u002Finbox-api-retirement-2026-08.md",[71,79,86,93,100,107],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":78},"01M7DXY4G8NSVB59K8B6S2AQNP","macbook-linux-maintenance","Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fmacbook-linux-maintenance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":78},"01M7DXXYJCXFJ3TGB84ZQ8KFE6","governance-regression-triage","Triage a host's governance issues: what changed.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fgovernance-regression-triage\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":78},"01M7DXXSAP1G8FDRJAMXQGBBMK","enforcement-immutability","Use when enforcement files lose their immutable flag.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fenforcement-immutability\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":78},"01M78SSDQVRYX64Y16X32TC0NS","steadfaste-fleet-repo-deploy","Use when committing to the steadfaste-fleet repo.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-repo-deploy\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":78},"01M78SS928F3R2RJAYVW4E30CE","steadfaste-fleet-maintenance","Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-maintenance\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":78},"01M78SP1CHW0T0BWE5ZT6JBPX8","fleet-preflight","DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its \"Repo-Specific Pre-Flight\" section covers git search, Hermes boundary, and deployment verification.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Ffleet-preflight\u002FSKILL.md",[],[]]