LearnNewsExamplesServices
Frontmatter
id12571
titleHARNESS_PRESENCE is written only at bootstrap, never refreshed → targeted wakes go stale after 5min
stateClosed
labels
bugaiarchitecture
assigneesneo-opus-ada
createdAtJun 5, 2026, 12:03 PM
updatedAtJun 7, 2026, 7:18 PM
githubUrlhttps://github.com/neomjs/neo/issues/12571
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 5, 2026, 3:31 PM

HARNESS_PRESENCE is written only at bootstrap, never refreshed → targeted wakes go stale after 5min

Closed v13.0.0/archive-v13-0-0-chunk-16 bugaiarchitecture
neo-opus-ada
neo-opus-ada commented on Jun 5, 2026, 12:03 PM

Authored by @neo-opus-ada (Claude Opus 4.8). Surfaced during the #12536 / PR #12570 V-B-A.

Refs #12536, #12570, Epic #12416 (volatile HarnessPresence).

Context

PR #12570 (#12536) adds machine-agnostic wake subscriptionTemplates for the same-app Claude identities (@neo-opus-vega, @neo-opus-grace), enabling targeted (userDataDir-addressed) wake delivery. Tracing the delivery path end-to-end surfaced a separate, pre-existing robustness gap in the freshness overlay.

The Problem

HARNESS_PRESENCE.lastSeenAt is written only by WakeSubscriptionService.upsertHarnessPresence, which is called only from bootstrap() (the one-shot fire-and-forget auto-bootstrap at MC boot in Server.mjs, plus the manual manage_wake_subscription tool). resync() reads GraphLog deltas without writing presence; emitHeartbeatPulse() writes a GraphLog heartbeat_pulse entity (a wake to deliver), not a presence refresh. No periodic refresh exists.

Consequence: presence is set once at MC boot and never renewed. isHarnessPresenceFresh uses HARNESS_PRESENCE_STALE_AFTER_MS = 5 min, and the bridge daemon's assertFreshTargetPresence (daemon.mjs) fails closed for targeted addressTypes (addressType && instanceAddress) when presence is stale. So a userDataDir-addressed wake for vega / claude-opus is skipped ~5 min after MC boot — even though getInstancePid could still resolve the live pid from ps (the process is alive and findable; only the freshness overlay is stale).

Default-instance wakes (@neo-opus-ada, no addressType) bypass the freshness gate entirely (getDefaultInstancePid path), so they work indefinitely — which is why this gap was masked until same-app targeted delivery was wired up.

Architectural Reality

isHarnessPresenceFresh's docstring ("presence older than one heartbeat is not fresh enough") reads as if a periodic refresh was intended, but none is wired. The freshness gate and the live ps pid-resolution are partly redundant: for userDataDir, a successful getInstancePid already proves the process is alive.

Proposed Fix (decide in-ticket)

  1. Refresh presence on the heartbeat tick — have the idle-out / heartbeat path also re-upsert HARNESS_PRESENCE.lastSeenAt; or
  2. For userDataDir addressing, treat a live getInstancePid resolution as liveness and relax/skip the freshness gate (the ps lookup already proves liveness); or
  3. Periodic re-bootstrap.

Lean toward (1) or (2): (2) is the smallest change and removes a redundant gate for the case where liveness is independently provable.

Acceptance Criteria

  • A userDataDir-targeted wake for vega / claude-opus is delivered after the identity has been idle > 5 min (presence stays fresh, or the gate uses live-pid liveness for userDataDir).
  • Default-instance (@neo-opus-ada) delivery behavior is unchanged.
  • Fail-closed-on-genuinely-dead-instance is preserved (a stale presence with a dead pid must still refuse).
  • Unit coverage for the refreshed-presence / live-pid-liveness path.

Contract Ledger

Surface Producer Consumer Contract
HARNESS_PRESENCE.lastSeenAt WakeSubscriptionService bridge-daemon assertFreshTargetPresence Must be renewed within HARNESS_PRESENCE_STALE_AFTER_MS for targeted delivery to fire; today it is written once at bootstrap only.
getInstancePid({userDataDir}) liveness instanceResolver bridge-daemon targeted dispatch A non-null pid proves the instance is alive — candidate authoritative liveness signal for the userDataDir gate.

Out of Scope

  • The wake subscriptionTemplate itself (PR #12570).
  • resumeHarness per-identity instance addressing (moot for the loop post-#12570; correct fresh-spawn recovery for a genuine sunset).

Origin Session ID: c2800781-b204-4883-a52f-2979a560718b Retrieval Hint: "HARNESS_PRESENCE refresh stale targeted wake bootstrap-only freshness gate"

tobiu referenced in commit 930b6ae - "fix(wake): exempt userDataDir from HARNESS_PRESENCE freshness gate (#12571) (#12576) on Jun 5, 2026, 3:31 PM
tobiu closed this issue on Jun 5, 2026, 3:31 PM