Repository navigation
fix: a failed DPoP key load and a fresh maintenance read are no longer cached #15500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
db229f0
b16a2c4
079c244
3886397
ee90252
9e49fa8
cfdd70d
323113d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import { | |
| type ServerProviderModel, | ||
| } from "@t3tools/contracts"; | ||
| import { codexModelFamily } from "@t3tools/shared/model"; | ||
| import * as Cache from "effect/Cache"; | ||
| import * as Clock from "effect/Clock"; | ||
| import * as Context from "effect/Context"; | ||
| import * as Effect from "effect/Effect"; | ||
|
|
@@ -350,29 +351,33 @@ export const make = Effect.gen(function* () { | |
| let lastAttemptMs: number | null = null; | ||
| const refreshSemaphore = yield* Semaphore.make(1); | ||
|
|
||
| // `Effect.cached` makes concurrent first readers await the same disk load | ||
| // rather than racing a "loaded" flag. Only `refreshed` takes the fetch | ||
| // semaphore; `current` must never wait behind an in-flight network refresh. | ||
| const ensureDiskCacheLoaded = yield* Effect.cached( | ||
| Effect.gen(function* () { | ||
| const fromDisk = yield* fileSystem.readFileString(cachePath).pipe( | ||
| Effect.flatMap((raw) => decodeManifestCache(raw)), | ||
| Effect.catchCause(() => Effect.succeed(null)), | ||
| ); | ||
| if (fromDisk === null) return; | ||
| // The disk copy is the last-seen remote manifest, so it outranks the | ||
| // bundle even when stale, unless the bundle's own edit date is newer | ||
| // than the cached manifest's. Then the release carries data the cache | ||
| // has not seen and the cache is dropped so the next refresh replaces | ||
| // it. Comparing edit dates, not fetch time, keeps this independent of | ||
| // when the cache was written relative to the release. | ||
| if (manifestUpdatedAtMs(BUNDLED_MODEL_MANIFEST) > manifestUpdatedAtMs(fromDisk.manifest)) { | ||
| return; | ||
| } | ||
| manifest = fromDisk.manifest; | ||
| fetchedAtMs = fromDisk.fetchedAtMs; | ||
| }), | ||
| ); | ||
| // Concurrent first readers await the same disk load rather than racing a | ||
| // "loaded" flag, and an interrupted load is dropped so the next reader | ||
| // retries it. Only `refreshed` takes the fetch semaphore; `current` must | ||
| // never wait behind an in-flight network refresh. | ||
| const diskCacheLoad = yield* Cache.make({ | ||
| capacity: 1, | ||
| lookup: () => | ||
| Effect.gen(function* () { | ||
| const fromDisk = yield* fileSystem.readFileString(cachePath).pipe( | ||
| Effect.flatMap((raw) => decodeManifestCache(raw)), | ||
| Effect.catchCause(() => Effect.succeed(null)), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -eu
rg -n '"effect"\s*:' apps/server/package.json
fd -i 'lock' . -x rg -n -C 2 'effect' {} || trueRepository: pingdotgg/t3code Length of output: 41172 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- ModelManifest PR diff ---'
git diff --unified=45 f870c419fc21f7ee23c122e60fb94adb8bf73a40 079c2444c14f2bddbbc556679a8dd2963bef1930 -- apps/server/src/provider/ModelManifest.ts
printf '%s\n' '--- Current ModelManifest lookup ---'
nl -ba apps/server/src/provider/ModelManifest.ts | sed -n '300,390p'
printf '%s\n' '--- Effect patch configuration and candidates ---'
rg -n -F 'effect@4.0.0-rc.115' pnpm-workspace.yaml pnpm-lock.yaml
rg --files | rg '(^|/)(patches?|pnpm-workspace\.yaml)(/|$)|effect.*patch'Repository: pingdotgg/t3code Length of output: 36837 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Applied Effect patch ---'
nl -ba patches/effect@4.0.0-rc.115.patch
printf '%s\n' '--- Patch declaration and lock resolution ---'
nl -ba pnpm-workspace.yaml | sed -n '248,263p'
nl -ba pnpm-lock.yaml | sed -n '1,14p;100,110p;7434,7444p'Repository: pingdotgg/t3code Length of output: 22977 🌐 Web query:
💡 Result: 🌐 Web query:
💡 Result: 🌐 Web query:
💡 Result: 🌐 Web query:
💡 Result: 🌐 Web query:
💡 Result: 🌐 Web query:
💡 Result: 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import urllib.error
import urllib.request
base = "https://raw.githubusercontent.com/Effect-TS/effect/{ref}/packages/effect/src/Cache.ts"
refs = ["effect@4.0.0-rc.115", "effect@4.0.1"]
needles = ("awaiters", "lookupFiber", "interrupt", "onExit", "pending", "lookup:")
for ref in refs:
url = base.format(ref=ref.replace("@", "%40"))
print(f"--- {ref} Cache.ts ---")
try:
with urllib.request.urlopen(url, timeout=20) as response:
lines = response.read().decode().splitlines()
except (urllib.error.URLError, TimeoutError) as error:
print(f"FETCH_FAILED: {type(error).__name__}: {error}")
continue
matches = [i for i, line in enumerate(lines) if any(n in line for n in needles)]
if not matches:
print(f"Fetched {len(lines)} lines; no selected markers")
continue
spans = []
for i in matches:
start, end = max(0, i - 5), min(len(lines), i + 9)
if spans and start <= spans[-1][1]:
spans[-1] = (spans[-1][0], max(spans[-1][1], end))
else:
spans.append((start, end))
print(f"Fetched {len(lines)} lines; relevant excerpts:")
for start, end in spans:
for i in range(start, end):
print(f"{i + 1:5} {lines[i]}")
print()
PYRepository: pingdotgg/t3code Length of output: 41596 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import re
import urllib.request
base = "https://raw.githubusercontent.com/Effect-TS/effect/{ref}/packages/effect/src/{path}"
def fetch(ref, path):
url = base.format(ref=ref.replace("@", "%40"), path=path)
with urllib.request.urlopen(url, timeout=20) as response:
return response.read().decode().splitlines()
for ref in ("effect@4.0.0-rc.115", "effect@4.0.1"):
print(f"--- {ref} Cache.ts lookup and EntryImpl ---")
lines = fetch(ref, "Cache.ts")
for start, end in ((405, 495),):
for i in range(start - 1, min(end, len(lines))):
print(f"{i + 1:5} {lines[i]}")
print()
print("--- rc.115 Effect.ts catchCause declaration ---")
lines = fetch("effect@4.0.0-rc.115", "Effect.ts")
hits = [i for i, line in enumerate(lines) if re.search(r"export const catchCause\\b|export function catchCause\\b|catchCause\\s*=", line)]
print("matching declarations:", [i + 1 for i in hits])
for i in hits[:3]:
for j in range(max(0, i - 18), min(len(lines), i + 34)):
print(f"{j + 1:5} {lines[j]}")
print()
PYRepository: pingdotgg/t3code Length of output: 7491 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import urllib.request
url = "https://raw.githubusercontent.com/Effect-TS/effect/effect%404.0.0-rc.115/packages/effect/src/Effect.ts"
with urllib.request.urlopen(url, timeout=20) as response:
lines = response.read().decode().splitlines()
print("--- Effect.ts header ---")
for i, line in enumerate(lines[:100], 1):
print(f"{i:5} {line}")
hits = [i for i, line in enumerate(lines) if "catchCause" in line]
print("--- Effect.ts catchCause occurrences ---")
print("line numbers:", [i + 1 for i in hits])
for i in hits:
for j in range(max(0, i - 5), min(len(lines), i + 10)):
print(f"{j + 1:5} {lines[j]}")
print()
PYRepository: pingdotgg/t3code Length of output: 13382 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import urllib.request
base = "https://raw.githubusercontent.com/Effect-TS/effect/effect%404.0.0-rc.115/packages/effect/src/{path}"
for path in ("internal/effect.ts", "Effect.ts"):
with urllib.request.urlopen(base.format(path=path), timeout=20) as response:
lines = response.read().decode().splitlines()
print(f"--- {path} catchCause context ---")
hits = [i for i, line in enumerate(lines) if "catchCause" in line]
print("matches:", [i + 1 for i in hits])
for i in hits:
if path.endswith("Effect.ts") and not (3180 <= i + 1 <= 3270):
continue
for j in range(max(0, i - 8), min(len(lines), i + 24)):
print(f"{j + 1:5} {lines[j]}")
print()
PYRepository: pingdotgg/t3code Length of output: 22308 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import urllib.request
base = "https://raw.githubusercontent.com/Effect-TS/effect/effect%404.0.0-rc.115/packages/effect/src/{path}"
for path in ("internal/core.ts", "internal/fiberRuntime.ts"):
try:
with urllib.request.urlopen(base.format(path=path), timeout=20) as response:
lines = response.read().decode().splitlines()
except Exception as error:
print(f"--- {path}: FETCH_FAILED {type(error).__name__}: {error}")
continue
print(f"--- {path}: OnFailure and interruption evaluation ---")
hits = [i for i, line in enumerate(lines) if "OnFailure" in line]
print("OnFailure lines:", [i + 1 for i in hits])
spans = []
for i in hits:
start, end = max(0, i - 8), min(len(lines), i + 20)
if spans and start <= spans[-1][1]:
spans[-1] = (spans[-1][0], max(spans[-1][1], end))
else:
spans.append((start, end))
for start, end in spans:
for i in range(start, end):
print(f"{i + 1:5} {lines[i]}")
print()
PYRepository: pingdotgg/t3code Length of output: 318 🏁 Script executed: #!/bin/bash
set -eu
python3 <<'PY'
import urllib.request
url = "https://raw.githubusercontent.com/Effect-TS/effect/effect%404.0.0-rc.115/packages/effect/src/internal/effect.ts"
with urllib.request.urlopen(url, timeout=20) as response:
lines = response.read().decode().splitlines()
hits = [i for i, line in enumerate(lines) if "evaluateCont" in line]
print("evaluateCont lines:", [i + 1 for i in hits])
for i in hits:
for j in range(max(0, i - 10), min(len(lines), i + 48)):
print(f"{j + 1:5} {lines[j]}")
print()
PYRepository: pingdotgg/t3code Length of output: 9265 Upgrade Effect to preserve interrupted-load retries. The lockfile resolves the patched 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed this window exists. It is documented in the PR body. The fix is Effect-TS/effect#8719 in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would you like a follow-up issue for the Effect upgrade? ✏️ Learnings added
🧠 Learnings usedYou are interacting with an AI system. |
||
| ); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| if (fromDisk === null) return; | ||
| // The disk copy is the last-seen remote manifest, so it outranks the | ||
| // bundle even when stale, unless the bundle's own edit date is newer | ||
| // than the cached manifest's. Then the release carries data the cache | ||
| // has not seen and the cache is dropped so the next refresh replaces | ||
| // it. Comparing edit dates, not fetch time, keeps this independent of | ||
| // when the cache was written relative to the release. | ||
| if (manifestUpdatedAtMs(BUNDLED_MODEL_MANIFEST) > manifestUpdatedAtMs(fromDisk.manifest)) { | ||
| return; | ||
| } | ||
| manifest = fromDisk.manifest; | ||
| fetchedAtMs = fromDisk.fetchedAtMs; | ||
| }), | ||
| }); | ||
| const ensureDiskCacheLoaded = Cache.get(diskCacheLoad, undefined); | ||
|
|
||
| const refresh = Effect.fn("ModelManifest.refresh")(function* (force = false) { | ||
| yield* ensureDiskCacheLoaded; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.