@wrongstack/governance 0.320.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4285,7 +4285,14 @@ var SqliteVerificationLedger = class {
4285
4285
  "Verification lease was already consumed."
4286
4286
  );
4287
4287
  }
4288
- if (nowMs >= Date.parse(leaseRow.expires_at)) {
4288
+ const leaseExpiresAtMs = Date.parse(leaseRow.expires_at);
4289
+ if (!Number.isSafeInteger(leaseExpiresAtMs)) {
4290
+ return this.#finishConsumeFailure(
4291
+ "expired",
4292
+ "Verification lease expiry is unreadable; the lease is not honored."
4293
+ );
4294
+ }
4295
+ if (nowMs >= leaseExpiresAtMs) {
4289
4296
  return this.#finishConsumeFailure("expired", "Verification lease has expired.");
4290
4297
  }
4291
4298
  let run;
@@ -4338,8 +4345,10 @@ var SqliteVerificationLedger = class {
4338
4345
  const consumption = consumptionRow ? this.#consumptionFromRow(consumptionRow) : null;
4339
4346
  const nowMs = Date.parse(this.#now());
4340
4347
  if (!Number.isSafeInteger(nowMs)) throw new Error("Verification store clock is invalid.");
4348
+ const expiresAtMs = Date.parse(row.expires_at);
4349
+ const expired = !Number.isSafeInteger(expiresAtMs) || nowMs >= expiresAtMs;
4341
4350
  return deepFreeze2({
4342
- state: consumption ? "consumed" : nowMs >= Date.parse(row.expires_at) ? "expired" : "active",
4351
+ state: consumption ? "consumed" : expired ? "expired" : "active",
4343
4352
  lease: this.#leaseDescriptor(row),
4344
4353
  consumption
4345
4354
  });
@@ -4449,7 +4458,7 @@ function canonicalize2(value) {
4449
4458
  if (Array.isArray(value)) return value.map(canonicalize2);
4450
4459
  if (value && typeof value === "object") {
4451
4460
  return Object.fromEntries(
4452
- Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, entryValue]) => [key, canonicalize2(entryValue)])
4461
+ Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entryValue]) => [key, canonicalize2(entryValue)])
4453
4462
  );
4454
4463
  }
4455
4464
  return value;
@@ -2779,7 +2779,14 @@ var SqliteVerificationLedger = class {
2779
2779
  "Verification lease was already consumed."
2780
2780
  );
2781
2781
  }
2782
- if (nowMs >= Date.parse(leaseRow.expires_at)) {
2782
+ const leaseExpiresAtMs = Date.parse(leaseRow.expires_at);
2783
+ if (!Number.isSafeInteger(leaseExpiresAtMs)) {
2784
+ return this.#finishConsumeFailure(
2785
+ "expired",
2786
+ "Verification lease expiry is unreadable; the lease is not honored."
2787
+ );
2788
+ }
2789
+ if (nowMs >= leaseExpiresAtMs) {
2783
2790
  return this.#finishConsumeFailure("expired", "Verification lease has expired.");
2784
2791
  }
2785
2792
  let run2;
@@ -2832,8 +2839,10 @@ var SqliteVerificationLedger = class {
2832
2839
  const consumption = consumptionRow ? this.#consumptionFromRow(consumptionRow) : null;
2833
2840
  const nowMs = Date.parse(this.#now());
2834
2841
  if (!Number.isSafeInteger(nowMs)) throw new Error("Verification store clock is invalid.");
2842
+ const expiresAtMs = Date.parse(row.expires_at);
2843
+ const expired = !Number.isSafeInteger(expiresAtMs) || nowMs >= expiresAtMs;
2835
2844
  return deepFreeze2({
2836
- state: consumption ? "consumed" : nowMs >= Date.parse(row.expires_at) ? "expired" : "active",
2845
+ state: consumption ? "consumed" : expired ? "expired" : "active",
2837
2846
  lease: this.#leaseDescriptor(row),
2838
2847
  consumption
2839
2848
  });
@@ -2943,7 +2952,7 @@ function canonicalize2(value) {
2943
2952
  if (Array.isArray(value)) return value.map(canonicalize2);
2944
2953
  if (value && typeof value === "object") {
2945
2954
  return Object.fromEntries(
2946
- Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, entryValue]) => [key, canonicalize2(entryValue)])
2955
+ Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entryValue]) => [key, canonicalize2(entryValue)])
2947
2956
  );
2948
2957
  }
2949
2958
  return value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/governance",
3
- "version": "0.320.1",
3
+ "version": "1.0.0",
4
4
  "license": "MIT",
5
5
  "description": "Deterministic workflow contracts and transition policy for WrongStack orchestration.",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "README.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@wrongstack/persistence": "0.320.1"
30
+ "@wrongstack/persistence": "1.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^26.2.0",