agentsclimarketplace

Witness observer

Skill Tibsfox/gsd-skill-creator/examples/skills/orchestration/witness-observer

PMU observation pattern for agent health monitoring. Runs patrol loops, detects stalled agents, sends nudges, and escalates persistent failures to the mayor. Never modifies agent work or resolves conflicts.From its SKILL.md

Install
npx -y skills add Tibsfox/gsd-skill-creator --skill witness-observer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

7.8 KB, ~1.7k tokens by cl100k_base, as published. Nobody here has run it

Witness Observer

Per-rig observer that monitors polecat health and reports anomalies. The witness is the PMU (Performance Monitoring Unit) of the Gastown chipset -- it watches execution units for stalls, detects degraded performance, and raises alerts without interfering with computation. The witness is strictly read-only with respect to agent work. It observes and reports; it never modifies.

Activation Triggers

This skill activates when:

  • The agent is assigned to monitor a rig's worker agents
  • Multiple polecats are running and health monitoring is needed
  • Stall detection is required for long-running work items
  • The mayor needs a supervisory agent to watch active polecats

Core Capabilities

Patrol Loop

The witness runs a periodic patrol that checks all active agents in its rig for health indicators.

Patrol cycle:

SCAN            EVALUATE         ACT              WAIT
  |                |               |                |
  v                v               v                v
list agents -> check each  ->  nudge/escalate -> sleep interval
(active ones)   for stalls     if needed         (default 5 min)

Implementation:

const state = new StateManager({ stateDir: '.chipset/state/' });
const patrolInterval = 5 * 60 * 1000; // 5 minutes (configurable)
const stallThreshold = 30 * 60 * 1000; // 30 minutes (configurable)

async function patrol(): Promise<void> {
  // Get all agents that should be working
  const agents = await state.listAgents({ role: 'polecat' });
  const active = agents.filter(a => a.status === 'active');

  for (const agent of active) {
    const hook = await state.getHook(agent.id);
    if (!hook || hook.status !== 'active') continue;

    // Check last activity timestamp
    const lastActivity = new Date(hook.lastActivity).getTime();
    const elapsed = Date.now() - lastActivity;

    if (elapsed > stallThreshold) {
      await handleStall(agent, hook, elapsed);
    }
  }
}

Stall Detection

A stall is detected when an agent has hooked work but has not updated its activity timestamp within the threshold period (default 30 minutes).

Stall indicators:

IndicatorWhat It Means
Hook active, no activity for 30+ minAgent may be stuck, crashed, or idle
Agent status is 'active' but hook timestamp staleSession may have ended without cleanup
Multiple consecutive patrol cycles with no changePersistent stall, needs escalation

Stall classification:

type StallSeverity = 'warning' | 'alert' | 'critical';

function classifyStall(elapsed: number, nudgesSent: number): StallSeverity {
  if (nudgesSent >= 2) return 'critical';    // Nudged twice, still stalled
  if (elapsed > 60 * 60 * 1000) return 'alert';  // Over 1 hour
  return 'warning';                            // First detection
}

Nudge Protocol

When a stall is detected, the witness follows a graduated escalation protocol.

Step 1 -- Send nudge to stalled agent:

async function handleStall(
  agent: AgentIdentity,
  hook: HookState,
  elapsed: number
): Promise<void> {
  const severity = classifyStall(elapsed, getNudgeCount(agent.id));

  if (severity === 'warning') {
    // First nudge: ask agent if it's still working
    const nudge: AgentMessage = {
      from: witnessId,
      to: agent.id,
      channel: 'nudge',
      payload: `HEALTH_CHECK: no activity for ${Math.floor(elapsed / 60000)}m on ${hook.workItem?.beadId}`,
      timestamp: new Date().toISOString(),
      durable: false,
    };
    // Write nudge file
    recordNudge(agent.id);
    return;
  }

  if (severity === 'alert' || severity === 'critical') {
    // Escalate to mayor
    await escalateToMayor(agent, hook, severity, elapsed);
  }
}

Step 2 -- Wait for response (next patrol cycle):

If the agent responds to the nudge (updates its hook activity timestamp or sends mail), the stall is resolved. No further action needed.

Step 3 -- Escalate if unresolved:

async function escalateToMayor(
  agent: AgentIdentity,
  hook: HookState,
  severity: StallSeverity,
  elapsed: number
): Promise<void> {
  const escalation: AgentMessage = {
    from: witnessId,
    to: 'mayor',
    channel: 'mail',
    payload: `STALL_${severity.toUpperCase()}: ${agent.id} idle ${Math.floor(elapsed / 60000)}m on ${hook.workItem?.beadId}`,
    timestamp: new Date().toISOString(),
    durable: true,
  };
  // Write escalation to .chipset/state/mail/mayor/{timestamp}-{witnessId}.json
}

Health Reporting

The witness provides aggregate health summaries when queried by the mayor.

interface RigHealthReport {
  rigName: string;
  timestamp: string;
  totalAgents: number;
  activeAgents: number;
  stalledAgents: number;
  idleAgents: number;
  terminatedAgents: number;
  stalledDetails: Array<{
    agentId: string;
    beadId: string;
    stalledMinutes: number;
    nudgesSent: number;
  }>;
}

Communication Protocol

Messages the Witness SENDS

ChannelTargetPurposeDurability
nudgeStalled polecats"Are you still working?" health checkNon-durable
mailMayorStall alerts (warning, alert, critical)Durable
mailMayorHealth report summariesDurable

Messages the Witness RECEIVES

ChannelSourceContent
mailMayorInstructions (adjust thresholds, focus on specific agent)
mailPolecatsStatus responses to nudges

Error Handling

False Positive Stalls

If an agent is working but updates are slow (large commits, long test runs), the witness may detect a false positive. The nudge protocol handles this: the agent responds to the nudge, and the witness records the response as activity.

Witness Restart

If the witness itself restarts, it resumes patrol from scratch. It reads current agent and hook state from the filesystem -- there is no witness-specific state that needs recovery. The patrol loop is stateless between cycles.

Unresponsive Agent

If an agent does not respond to two nudges across two patrol cycles, the witness sends a critical escalation to the mayor. The mayor decides whether to terminate and replace the agent.

Boundary: What the Witness Does NOT Do

The witness NEVER:

  • Modifies agent work -- does not edit files, change branches, or alter code
  • Resolves conflicts -- conflict resolution is outside the observer's scope
  • Terminates agents -- only the mayor can terminate; the witness recommends
  • Reassigns work -- hook management belongs to the mayor
  • Changes agent status -- the witness reads status but does not write it (except its own)
  • Runs tests or builds -- the witness observes; it does not validate output quality

The witness is a sensor. It detects anomalies and reports them. It does not act on them.

Integration with Other Gastown Skills

SkillRelationship
mayor-coordinatorWitness reports stalls and health TO mayor
polecat-workerWitness monitors polecat health, sends nudges
refinery-mergeWitness can observe refinery queue depth and merge failures
beads-stateWitness reads state via StateManager (read-only)

References

  • references/gastown-origin.md -- How this pattern derives from Gastown's witness.go patrol
  • references/boundaries.md -- Read-only constraints and observation-only scope

What ships with it: 2 files

5.7 KB alongside SKILL.md

references/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.