Skip to content

feat(status): separate process health from data health - #590

Open
Azintar wants to merge 6 commits into
Divinity-Labs:mainfrom
Azintar:fix/status-health-contract
Open

Azintar wants to merge 6 commits into
Divinity-Labs:mainfrom
Azintar:fix/status-health-contract

Conversation

@Azintar

@Azintar Azintar commented Oct 20, 2026

Copy link
Copy Markdown

Summary

Automates the README endpoint table generation using "openapi.yaml" as the single source of truth.

Changes

  • Added markers around the generated endpoint table in the README.
  • Integrated endpoint table generation into "openapi:gen".
  • Added a CI check to detect differences between generated and committed documentation.
  • Ensured the generated table stays synchronized with the OpenAPI specification.

Closes #275.

codebuff-team and others added 2 commits October 20, 2026 16:52
/status was excluded from the OpenAPI contract, so nothing described its
shape or which values mean unhealthy. Document the full response, report
process health and data health as separate fields (data fresh/stale/empty),
and make 503 the single paging condition when a network's ingester falls
behind STATUS_STALE_AFTER_SECONDS.

Co-Authored-By: Codebuff <noreply@codebuff.com>
Miracle656 added a commit that referenced this pull request Oct 22, 2026
  tsc --noEmit   clean
  vitest         106 files, 1232 passing (up from 102 / 1157)
  dropped-tests  none

Four of the eight screened in this group. The other four were held, and the
reason is worth stating because it keeps recurring: each one merges cleanly
and fails on its own.

  #590  72 type errors alone, including syntax errors in src/api/rest.ts and
        src/api/schemas.ts -- "Declaration or statement expected",
        "Expression expected". Not type mismatches; the file does not parse.
  #584  3 type errors alone
  #592  conflicts
  #595  conflicts

Merged together before screening, that group produced 68 failing test files
and syntax errors I first mistook for a bad three-way merge. They were not:
#590 carries them on its own branch. Screening each PR individually before
batching costs one typecheck per PR and saves an hour of bisection, which is
the lesson of the day.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not parse on its own branch. Merged alone against current main, tsc --noEmit gives 72 errors, and the first few are syntax rather than types:

src/api/rest.ts(140,9):    error TS1128: Declaration or statement expected
src/api/rest.ts(146,14):   error TS1005: ';' expected
src/api/rest.ts(152,5):    error TS1109: Expression expected
src/api/schemas.ts(32,2):  error TS1109: Expression expected

TS1128 and TS1109 mean the file cannot be read as TypeScript at all — a brace or bracket is unbalanced somewhere above line 140. The other 68 errors are almost certainly downstream of that; fix the syntax and most will go.

I would look for a conflict resolution that kept both sides of a block, or an editor save that lost a closing brace. src/api/rest.ts is the most-edited file in this repository right now — nearly every open PR touches it — so it is the easiest place for that to happen and the hardest place to notice.

Separating process health from data health is a genuinely useful distinction and I want it: "the process is up" and "the data is current" answer different questions, and conflating them is how a service looks healthy while serving stale prices. Please get npx tsc --noEmit clean locally and re-request.

@Azintar
Azintar requested a review from Miracle656 October 23, 2026 09:21
@DanbabaJr

Copy link
Copy Markdown

docs(readme): generate the endpoint table from openapi.yaml (#275)

Summary

Makes the README endpoint table something you regenerate rather than edit: npm run openapi:gen now rewrites it from openapi.yaml, and CI fails when the committed README differs from a fresh generation.

Most of the generator is already on main. #475 (#229) added scripts/generate-readme.ts, the <!-- ENDPOINTS:START --> / <!-- ENDPOINTS:END --> markers and tests/readme.test.ts. What #275 still needed was running the generator from openapi:gen and an explicit CI drift check. This PR adds those and changes nothing else.

Changes

  • package.json: openapi:gen now runs generate-openapi.ts and then generate-readme.ts. It also adds readme:check (tsx scripts/generate-readme.ts --check).
  • scripts/generate-readme.ts: adds a --check mode and an exported readmeIsCurrent(). In check mode it writes nothing. When the README has drifted it exits 1 with:
    README.md is out of date: its generated tables (endpoints from openapi.yaml, venues from src/ingest/venues) differ from a fresh generation.
    Run `npm run openapi:gen` and commit the result.
    
    Line endings are normalised the same way tests/readme.test.ts does it, so a CRLF checkout doesn't count as drift.
  • .github/workflows/ci.yml: one new step, npm run readme:check, next to the existing "Fail if the committed client is out of date" guard.
  • tests/readme.test.ts: one test. readmeIsCurrent passes on the committed README and fails once a row in the table is edited by hand.
  • README.md: one sentence under the table saying it is generated and how. The table itself is unchanged.
  • .changeset/readme-endpoint-table-in-openapi-gen.md: patch changeset.

Generated table vs. what was there

The generated table is byte-identical to the committed one: 40 rows, with GET and POST /graphql shown as one row.

  • Routes: none missing and none extra. All 41 public operations in openapi.yaml appear, and the README lists no route the spec lacks. Paths stay in Fastify :param form, so tests/rest-route.test.ts still matches them.

  • Descriptions: 9 rows use the spec's summary directly. The other 31 use editorial text and query-string examples from the ENDPOINT_METADATA map in scripts/generate-readme.ts, which docs: generate venue and endpoint tables from registry with drift test #475 added. For most of them the wording differs from the spec summaries. Two examples:

    • /status: "Indexer health" in the README, "Get API status and indexer state" in the spec.
    • /pools: "Active AMM pools being watched" in the README, "Get AMM liquidity pool reserves and spot prices" in the spec.

    I left that map alone to keep this PR to one change. Moving it into the spec (for example x-readme-example on each operation) would be a natural follow-up.

  • ENDPOINT_METADATA lists GET /usage/me and GET/POST /graphql twice each, with identical values, so the output is unaffected. I didn't touch it here.

Relation to #589

#589 also works on #275. It edits scripts/generate-openapi.ts and has the review feedback about {param} paths and the dropped query examples. This PR doesn't overlap with that change: it uses the generator already on main, which keeps :param paths and the curated examples, and only adds the openapi:gen wiring, readme:check and the CI step.

Earlier commits on this branch

This branch first carried a /status process-vs-data health change (3cbcbcd and two merges of main). That work is already on main through #533 (#273), and the conflict resolution here had broken src/api/rest.ts and src/api/schemas.ts. So I merged current main and reverted every status-health change (22ae9ff). Those files now match main, and the net diff against main is only the #275 work above. No force push; the history is intact.

Verification

  • npm ci fails on main itself because the lockfile is out of sync (Missing: @lukeed/ms@2.0.2 from lock file), so I used CI's npm install fallback without committing the lockfile.
  • npx tsc --noEmit: clean, 0 errors.
  • npm test (vitest), run in 4 shards: 135 files, 1604 tests passed, 1 skipped, 0 failed.
  • npm run openapi:gen run twice: no diff after either run.
  • npm run readme:check: exits 0 on a clean tree, exits 1 with the message above after a README row is edited by hand, and exits 0 again once it's restored.
  • git diff upstream/main --stat: 6 files, +48 / −4.

Closes #275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The README's endpoint table is maintained by hand

4 participants