Skip to content

census: emit main_behind_origin signal — stale local checkout silently starves the daemon #188

Description

@robercano-ghbot

Why

The daemon runs every tick script from the LOCAL main checkout's working tree. When main falls behind origin — which happens whenever PRs merge via the GitHub UI instead of merge-ready's local_sync — the daemon executes stale code and reasons from stale state. This starved the loop from 2026-07-21 to 2026-07-24: local main sat behind while merged census improvements (and everything else) never took effect, and every tick quietly recorded action=none. The failure was invisible: main_dirty said no, ticks looked healthy, nothing pointed at staleness.

Proposal

  1. loop-census.sh: alongside main_dirty/main_head, emit main_behind_origin=<n|no> (commits behind, via git fetch origin main --quiet + rev-list --count main..origin/main — or, to keep census network-lean, compare against the fetch already implied by the gh calls / make the fetch conditional on a config knob).
  2. Cockpit: surface it on the loop-health panel (yellow at ≥1, like main_dirty).
  3. Optional follow-up (separate decision): a tick step that fast-forwards a CLEAN, on-main checkout automatically — extending merge-ready's local_sync to cover UI merges — so the signal is usually a no-op rather than a recurring chore.

Acceptance

  • Census emits the line; loop-census.test.sh covers behind/at-par fixtures (stub the git plumbing).
  • Cockpit shows the indicator.
  • docs/USAGE.md notes the UI-merge staleness trap.

Context: 2026-07-24 incident diagnosis (issue #187's corrected root cause), [[event-driven-pr-loop]] operational notes.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogFiled, not yet approved by the owner - the loop must NOT pick it upenhancementNew feature or requestmodule:harnessOrchestrator machinery under .claudepriority:mediumNormal queue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions