> For the complete documentation index, see [llms.txt](https://nytshift.gitbook.io/nytshift-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nytshift.gitbook.io/nytshift-docs/market-data-and-providers/market-history-degraded.md).

# Market history degraded

Use this runbook when `/api/market/history/health` returns `503`, a candle response reports degraded persistence, or the terminal shows a persisted-history notice.

1. Confirm `/api/market/health` separately. A venue outage can legitimately produce an aged persisted page; it does not mean the store is corrupt.
2. Inspect `/api/market/history/health`. Record only its reason code, schema and counts. Do not copy provider URLs or local filesystem paths into incident notes.
3. If the reason is configuration-related, stop NIGHTSHIFT, correct the bounded `MARKET_HISTORY_*` values in the local config and restart. Never relax the maximums to conceal a retention incident.
4. If the store is corrupt or requires an unsupported migration, stop the supervisor. Run `pnpm backup:list` and `pnpm backup:verify -- <backup-id>`; restore only a verified snapshot with `pnpm backup:restore -- <backup-id>`.
5. Restart, verify the history health endpoint, request one live Arcus and Hyperliquid candle page, then verify that provider responses report `historySource: provider`.
6. Rehearse an isolated upstream failure. The same market may return only previously verified persisted bars with `x-nightshift-history: persisted-degraded`, a stable provider reason and non-negative age. An unsupported market must still return `400` and no bars.

Never edit checkpoint JSON by hand, relabel persisted history as live, or delete the file while the supervisor is running. If no verified backup exists, preserve the corrupt file for analysis, move it only while stopped, and allow NIGHTSHIFT to rebuild history from live provider reads.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nytshift.gitbook.io/nytshift-docs/market-data-and-providers/market-history-degraded.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
