Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hasna/gateway",
"version": "0.1.7",
"version": "0.1.8",
"description": "Open-source AI model gateway core for one-key, multi-provider routing across Hasna apps and self-hosted deployments",
"type": "module",
"main": "dist/index.js",
Expand Down Expand Up @@ -46,7 +46,8 @@
"test": "bun test",
"contracts:validate": "contracts conformance fixtures/contracts",
"dev": "bun run src/cli/index.ts serve --config gateway.config.example.json",
"prepublishOnly": "bun run typecheck && bun run build && bun run test"
"verify:version-parity": "bun scripts/verify-version-parity.mjs",
"prepublishOnly": "bun run verify:version-parity && bun run typecheck && bun run build && bun run test"
},
"keywords": [
"ai",
Expand Down
25 changes: 25 additions & 0 deletions scripts/verify-version-parity.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bun
// Publish gate (todos a403124e): refuse to publish an artifact whose
// self-reported gatewayVersion disagrees with package.json. Release PR #25
// bumped package.json only, so the published 0.1.7 answers `gateway --version`
// with 0.1.6 — this exact skew, unchecked at publish time.
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";

const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
const source = readFileSync(join(root, "src", "version.ts"), "utf8");
const match = source.match(/gatewayVersion\s*=\s*"([^"]+)"/);

if (!match) {
console.error("VERSION_PARITY_FAILED: gatewayVersion not found in src/version.ts");
process.exit(1);
}
if (match[1] !== manifest.version) {
console.error(
`VERSION_PARITY_FAILED: src/version.ts gatewayVersion=${match[1]} != package.json version=${manifest.version}`,
);
process.exit(1);
}
console.log(`version parity ok: ${manifest.version}`);
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const gatewayVersion = "0.1.6";
export const gatewayVersion = "0.1.8";
23 changes: 23 additions & 0 deletions tests/version-parity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { gatewayVersion } from "../src/version";

const repositoryRoot = join(import.meta.dir, "..");

/**
* Regression for the 0.1.7 release skew (todos a403124e): release PR #25
* bumped package.json only, so main — and the published 0.1.7 artifact —
* self-report 0.1.6 from `gateway --version`. The constant and the manifest
* must never disagree: `--version` is the instrument the fleet's version-skew
* discipline reads after an install, and a lagging constant makes every
* installed-version verification report a false mismatch.
*/
describe("version parity", () => {
test("gatewayVersion matches package.json version", () => {
const manifest = JSON.parse(
readFileSync(join(repositoryRoot, "package.json"), "utf8"),
) as { version: string };
expect(gatewayVersion).toBe(manifest.version);
});
});
Loading