@smthrs/journal 1.0.0-rc.12 → 1.0.0-rc.14

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.
@@ -19,7 +19,7 @@ CommonJS with TypeScript declarations. Its only runtime dependencies are
19
19
  Composing a journal layer imports from both of them by name, so install them as
20
20
  direct dependencies rather than relying on them being hoisted.
21
21
 
22
- `effect` is a peer dependency in the range `^4.0.4`. Install one `effect` in
22
+ `effect` is a peer dependency at exactly `4.0.5`. Install one `effect` in
23
23
  that range: two copies of `effect` in one program are two sets of service tags, so
24
24
  a journal layer built against one copy cannot be provided to a program holding
25
25
  the other, and the mismatch shows up as a missing service rather than as a
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@smthrs/journal",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.12",
4
+ "version": "1.0.0-rc.14",
5
5
  "license": "MIT",
6
6
  "smthrs": {
7
7
  "group": "engine"
@@ -226,18 +226,18 @@
226
226
  "tag": "next"
227
227
  },
228
228
  "dependencies": {
229
- "@smthrs/database": "1.0.0-rc.12"
229
+ "@smthrs/database": "1.0.0-rc.14"
230
230
  },
231
231
  "devDependencies": {
232
232
  "@effect/language-service": "0.87.2",
233
- "@effect/sql-sqlite-node": "4.0.4",
234
- "@effect/vitest": "4.0.4",
233
+ "@effect/sql-sqlite-node": "4.0.5",
234
+ "@effect/vitest": "4.0.5",
235
235
  "@eslint/js": "9.39.5",
236
- "@smthrs/flow": "1.0.0-rc.12",
236
+ "@smthrs/flow": "1.0.0-rc.14",
237
237
  "@types/node": "26.4.1",
238
238
  "@vitest/coverage-v8": "5.0.0",
239
239
  "dprint": "0.57.1",
240
- "effect": "4.0.4",
240
+ "effect": "4.0.5",
241
241
  "esbuild": "0.28.2",
242
242
  "eslint": "9.39.5",
243
243
  "eslint-import-resolver-typescript": "4.4.5",
@@ -251,7 +251,7 @@
251
251
  "fast-check": "4.9.0"
252
252
  },
253
253
  "peerDependencies": {
254
- "effect": "^4.0.4"
254
+ "effect": "4.0.5"
255
255
  },
256
256
  "scripts": {
257
257
  "lint": "eslint src examples --max-warnings=0 && dprint check",
package/src/Consensus.ts CHANGED
@@ -750,17 +750,29 @@ export const resourcePermit = <A, E, R>(
750
750
  while (true) {
751
751
  const admitted = yield* Effect.uninterruptible(Effect.gen(function*() {
752
752
  const nowMs = yield* Clock.currentTimeMillis
753
- let grant = yield* strategy.claim(key, owner, nowMs)
753
+ // A held resource needs a read, not a rejected write transaction on
754
+ // every poll. Leave the writer available for its owner's heartbeat.
755
+ const lease = yield* read()
756
+ let grant = lease?.owner === undefined && lease?.claim === undefined
757
+ ? yield* strategy.claim(key, owner, nowMs)
758
+ : rejected("owner_held")
754
759
  if (grant._tag === "Rejected") {
755
- const lease = yield* read()
756
760
  const held = lease?.claim === undefined
757
761
  ? lease?.owner
758
762
  : { id: lease.claim.id, heartbeatAtMs: lease.claim.claimedAtMs }
759
763
  if (
760
- held !== undefined && held.heartbeatAtMs < nowMs - staleAfterMs &&
764
+ held !== undefined &&
765
+ (held.heartbeatAtMs < nowMs - staleAfterMs ||
766
+ (lease?.claim === undefined && held.id.hostId === owner.hostId && held.id.pid !== owner.pid)) &&
761
767
  !(yield* isAlive(held.id, { claimant: owner, heartbeatAtMs: held.heartbeatAtMs, nowMs }))
762
768
  ) {
763
- const evidence = { expectedOwner: held.id, checkedAtMs: nowMs, kind: "lease-expired" as const }
769
+ const evidence: LivenessEvidence = {
770
+ expectedOwner: held.id,
771
+ checkedAtMs: nowMs,
772
+ kind: held.id.hostId === owner.hostId && held.id.pid !== owner.pid
773
+ ? "same-host-pid-dead"
774
+ : "lease-expired"
775
+ }
764
776
  if (lease?.claim !== undefined) {
765
777
  yield* strategy.recover(key, held.id, lease.claim.claimedAtMs, owner, nowMs, evidence)
766
778
  } else {
@@ -787,7 +799,9 @@ export const resourcePermit = <A, E, R>(
787
799
  const renewed = yield* strategy.reconfirm(key, owner, nowMs).pipe(Effect.timeout(heartbeatInterval))
788
800
  if (renewed._tag !== "Renewed") return yield* Effect.fail(fenceLost(key, owner))
789
801
  })),
790
- Effect.mapError(() => fenceLost(key, owner))
802
+ Effect.mapError((cause) =>
803
+ new ConsensusError({ code: "fence_lost", message: fenceLost(key, owner).message, cause })
804
+ )
791
805
  )
792
806
  )
793
807
  return acquire.pipe(
package/src/Redaction.ts CHANGED
@@ -803,10 +803,18 @@ export const defaultRules: ReadonlyArray<Rule> = [
803
803
  },
804
804
  {
805
805
  id: "basic-authorization",
806
- // Only the scheme's own spellings: a lowercase `basic` is a word or a
807
- // module (`module_utils.basic import`).
808
- pattern: /\b(?:Basic|BASIC)\s+[A-Za-z0-9+/]{4,}={0,2}/g,
809
- replace: "Basic [REDACTED_TOKEN]"
806
+ // HTTP schemes are case-insensitive. For prose spellings, require an
807
+ // encoded user:password pair so `a basic example` and module imports survive.
808
+ pattern: /\bbasic\s+[A-Za-z0-9+/]{4,}={0,2}/gi,
809
+ rewrite: (text) =>
810
+ text.replace(/\b(basic)\s+([A-Za-z0-9+/]{4,}={0,2})/gi, (match: string, scheme: string, token: string) => {
811
+ if (scheme === "Basic" || scheme === "BASIC") return "Basic [REDACTED_TOKEN]"
812
+ try {
813
+ return atob(token).includes(":") ? "Basic [REDACTED_TOKEN]" : match
814
+ } catch {
815
+ return match
816
+ }
817
+ })
810
818
  },
811
819
  {
812
820
  id: "jwt",