<!-- XE-13355 · [DAO] sessions._submitted leaves Anchor rows unwritten until worker.job_sessions, causing false anchor_overdue health degradation and unbounded rescans · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13355>. The page is the record; this is the same page for reading.*

XE-13355 · Bounty

# \[DAO\] sessions.\_submitted leaves Anchor rows unwritten until worker.job\_sessions, causing false anchor\_overdue health degradation and unbounded rescans

Closed · duplicate
—
[xe#500](https://github.com/xeprotocol/xe/issues/500)
filed 2026-11-12 05:49 UTC
by Khanhtnq

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   DAO harness

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-15 10:28 UTC

Told
:   2026-11-15 10:27 UTC

### Patches

None linked.

### History

- [259096](https://bounty.xe.network/log/259096) 2026-11-15 10:28 UTC github.state\_pushed
- [259093](https://bounty.xe.network/log/259093) 2026-11-15 10:28 UTC github.labels
- [258982](https://bounty.xe.network/log/258982) 2026-11-15 10:27 UTC reply.mirrored
- [258579](https://bounty.xe.network/log/258579) 2026-11-15 10:27 UTC proposal.adopted
- [258578](https://bounty.xe.network/log/258578) 2026-11-15 10:27 UTC reply.sent
- [258577](https://bounty.xe.network/log/258577) 2026-11-15 10:27 UTC ticket.status new → closed
- [257732](https://bounty.xe.network/log/257732) 2026-11-15 10:27 UTC proposal.adopted
- [257731](https://bounty.xe.network/log/257731) 2026-11-15 10:27 UTC ticket.facts
- [257730](https://bounty.xe.network/log/257730) 2026-11-15 10:27 UTC proposal.adopted
- [257729](https://bounty.xe.network/log/257729) 2026-11-15 10:27 UTC ticket.facts
- [257728](https://bounty.xe.network/log/257728) 2026-11-15 10:27 UTC proposal.adopted
- [257727](https://bounty.xe.network/log/257727) 2026-11-15 10:27 UTC ticket.facts area

[Full history](https://bounty.xe.network/log?ref=XE-13355) · [JSON](https://bounty.xe.network/v1/tickets/XE-13355) · [markdown](https://bounty.xe.network/XE-13355.md)

### Report

### Summary

In `dao/services/sessions.py`, `_ended` (`L502-506`) deletes an `Anchor` row inside the same transaction whenever an anchor session ends `failed` or `cancelled`. By contrast, `_submitted` (`L394-401`) — the single helper called by `submit` (`L426`), `_refused` (`L448`), `rebuild` (`L295`), and `cancel` (`L494`) whenever a session's block has landed on the state chain — sets `SigningSession.status = "submitted"`, `submitted_index`, and `submitted_hash` without updating `Anchor.statechain_index` or `Anchor.statechain_hash`.

This produces two concrete defects:

1. **False `anchor_overdue` health degradation and stale public anchor surfaces after API submission**:
   - Every member API path that lands an anchor block (`POST /v1/members/sessions/{sid}/sign`, `/rebuild`, `/cancel`) commits `SigningSession.status = "submitted"` while leaving `Anchor.statechain_index = None` and `Anchor.statechain_hash = ""`.
   - In `dao/worker.py:289-303` (`Worker.scheduler`), `"health"` is ordered **before** `"sessions"` in `job_table`. On any scheduler pass where both `job_health` and `job_sessions` are due after an overdue anchor has just been signed and submitted via the API (or when `GET /v1/health` / `dao health` runs before the next 120-second `job_sessions` tick, or while the worker is not yet caught up), `records.health` (`dao/services/records.py:282`) queries `latest_anchor(db, written=True)` (`Anchor.statechain_index.isnot(None)`), misses the already-landed anchor, sets `anchor_overdue = True` and `ok = False`, degrades 30-day uptime (`HealthCheck(ok=False)`), and appends a public `health.degraded` event to `EventLog`.
   - Over the same window, `GET /v1/legal/anchors`, `GET /v1/log/head`, and `/records` report `statechain_index: null` (`pending`) while `/members` already shows the anchor session `Written at state-chain #N`.
2. **Unbounded full-history anchor scan every 120 seconds in `worker.job_sessions`**:
   - To compensate for `_submitted` not updating `Anchor`, `dao/worker.py:195-197` runs `select(SigningSession).where(SigningSession.status == "submitted", SigningSession.kind == "anchor")` on every two-minute `job_sessions` pass with no `Anchor.statechain_index.is_(None)` filter, reloading every submitted anchor session since genesis and issuing `SELECT ... FROM anchors` \+ ORM updates for each one.

### Impact

Submitting an overdue anchor via the member API still triggers false `anchor_overdue` health failure, permanent `health.degraded` log entries, 30-day uptime loss when `job_health` runs ahead of `job_sessions`, temporary disagreement between `/members` and `/records` \+ `/v1/legal/anchors` \+ `/v1/log/head`, and an `O(total historical anchors)` database scan every 120 seconds.

### Thread

**Khanhtnq**2026-11-12 05:49 UTCgithub

Fix proposed in xeprotocol/dao#4.

**Joseph Denne**team2026-11-15 10:27 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-13355 and says what differs; it is read like any other.
