Skip to content

fix: backend reports actual version on /health and / - #353

Merged
neuromechanist merged 3 commits into
devfrom
fix/backend-version-tracking
Apr 25, 2026
Merged

neuromechanist merged 3 commits into
devfrom
fix/backend-version-tracking

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Stop hardcoding version: "0.1.0" in backend/src/index.ts — both /health and / now read from backend/package.json via JSON import. Single source of truth.
  • Bump backend/package.json from 0.1.0 to 0.8.0-dev so it tracks the CLI version. CLI and backend ship together; one version.
  • scripts/bump-version.sh now also bumps backend/package.json atomically, so future runs keep them in lockstep.
  • Refresh the file-header doc comment: prod is api.nemar.org (SCCN), dev is nemar-api-dev.sccn-org.workers.dev (SCCN), legacy api.osc.earth/nemar is the read-only buffer on the personal account.

Why

Reported in production: https://api.nemar.org/health returned version: "0.1.0" (frozen at project start) instead of the real shipped version. Misleading for ops and for the dashboard's API health card.

Test plan

  • bun run typecheck (backend) clean
  • wrangler deploy --dry-run -c backend/wrangler-sccn.toml produces a valid bundle (JSON import resolves correctly via esbuild)
  • Post-merge: deploy to SCCN, curl https://api.nemar.org/health should return version: "0.8.0-dev"
  • Personal account is in MAINTENANCE_MODE=read-only and slated for retirement, so it intentionally is NOT redeployed in this change

Notes

  • The with { type: "json" } import-attributes syntax is supported by esbuild (which wrangler bundles with) and TypeScript 5.6+.
  • Personal account (api.osc.earth/nemar) keeps reporting 0.1.0 until Phase 11 retirement; not worth burning a deploy on a sunset target.

- Stop hardcoding 0.1.0 in backend/src/index.ts; import version from
  backend/package.json. Single source of truth.
- Bump backend/package.json from 0.1.0 to 0.8.0-dev so it tracks the
  CLI version (CLI and backend ship together).
- bump-version.sh now keeps backend/package.json in sync, so future
  bumps update both files atomically.
- Refresh the index.ts header doc comment: production route is
  api.nemar.org (SCCN), dev is nemar-api-dev.sccn-org, and the personal
  api.osc.earth/nemar URL is the read-only buffer.
@github-actions

github-actions Bot commented Apr 25, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR353

Version: 0.8.0-PR353.38080c6
Commit: 38080c6


🤖 Updated on each push.

Reviewer note: the three failure paths restored only root package.json,
leaving backend/package.json modified if a bump aborted mid-way. Factor
a restore_versions() helper that touches both files so the working tree
is never half-rolled-back.
Backend was importing ../package.json (backend/package.json), with the
bump script syncing the two manifests. That left two write paths to
keep aligned. Wire the runtime to import the repo-root package.json
directly (../../package.json from backend/src/index.ts), making the
CLI manifest the single source of truth.

backend/package.json stays (it is private/never published, but wrangler
and bun tooling expect it). bump-version.sh keeps it in lockstep and
now also asserts backend.version == root.version post-bump, so any
drift introduced by a hand-edit fails the bump loudly.

Wrangler dry-run + tsc clean with the new import path.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review pass: addressed + raised the bar

Two follow-up commits on top of the original fix:

0c62f9a — code-reviewer Important: rollback symmetry

The three failure paths in bump-version.sh now share a restore_versions() helper that touches both package.json and backend/package.json. An aborted bump can no longer leave the working tree half-rolled-back.

38080c6 — true single source of truth (per follow-up ask)

Backend now imports ../../package.json (repo root, the npm-published CLI manifest) instead of ../package.json. The runtime version is now read from one file, period.

backend/package.json stays for wrangler/bun tooling but is no longer the runtime authority; bump script keeps it in lockstep AND asserts equality post-bump, so any future drift fails the bump loudly with:

Error: backend/package.json version (X) does not match root (Y)

Verified: tsc --noEmit and wrangler deploy --dry-run -c backend/wrangler-sccn.toml both clean with the new import path.

Deferred (per ratings)

  • Commit subject length (51 vs <50 chars) — not worth a force-push.
  • with { type: "json" } portability — wrangler 3.91 / esbuild / TS 5.6 all handle it; flagged for future tooling-version bumps.

Reviews:

  • code-reviewer: Approve (no Critical, one Important addressed).

Source-of-truth pattern recorded in memory infra_sccn_migration.md so future sessions don't re-litigate this decision.

@neuromechanist
neuromechanist merged commit 0005d38 into dev Apr 25, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the fix/backend-version-tracking branch April 25, 2026 23:39
neuromechanist added a commit that referenced this pull request Apr 26, 2026
CI deploy-dev failed because backend/package.json pinned [email protected]
which does not parse \`import ... with { type: "json" }\` (introduced in
PR #353). Bump to wrangler 4.85.0 to match the version used for local
dry-runs and the version recommended by wrangler's own deprecation
warning.

api-test was racing deploy-dev: the tightened /health assertion compared
against the locally-checked-out package.json version while the deployed
worker on dev still ran the previous version. Replace the exact-match
check with a semver shape regex - still catches version=undefined
(the original test gap) without locking to current build.

This branch was previously deployed

1 inactive deployment
npm — 38080c67 Deployed Apr 25, 2026 by neuromechanist via publish #616
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.

1 participant