Repository navigation
fix(release): retain ACP load response semantics #18
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1162aa5
test(release): add ACP load compatibility guard
Microck 0bcdfd7
test(release): add ACP load compatibility tests
Microck c390870
fix(release): preserve response-bound ACP loading
Microck b6c110e
test(release): verify ACP load compatibility guard
Microck b3d655c
test(release): register load compatibility test separately
Microck 27a2295
test(release): follow node import conventions
Microck ec585c6
fix(release): make load guard idempotent
Microck 63e769c
test(release): verify load guard is idempotent
Microck 7c8c03d
fix(release): include ACP load helper in runtime copy
Microck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import * as NodeAssert from "node:assert/strict"; | ||
| import * as NodeTest from "node:test"; | ||
| import { normalizeLoadResponse } from "./personal-release-load.ts"; | ||
|
|
||
| const legacy = ` waitForSessionLoadReplayIdle, | ||
| const runLoadSessionWithReplayIdle = ( | ||
| const idleFiber = yield* waitForSessionLoadReplayIdle({ | ||
| gateRef: sessionLoadGateRef, | ||
| }).pipe(Effect.forkIn(runtimeScope)); | ||
| const loaded = yield* Effect.raceFirst( | ||
| acp.agent.loadSession(loadPayload), | ||
| Fiber.join(idleFiber), | ||
| ).pipe( | ||
| Effect.ensuring(Fiber.interrupt(idleFiber).pipe(Effect.ignore)), | ||
| detail: "session/load timed out waiting for RPC response or replay idle gap", | ||
| `; | ||
| NodeTest.test("restores response-bound session loading", () => { | ||
| const result = normalizeLoadResponse(legacy); | ||
| NodeAssert.match(result, /yield\* acp\.agent\.loadSession\(loadPayload\)\.pipe/); | ||
| NodeAssert.doesNotMatch(result, /Fiber\.join\(idleFiber\)|waitForSessionLoadReplayIdle/); | ||
| NodeAssert.match(result, /timed out waiting for RPC response"/); | ||
| NodeAssert.equal(normalizeLoadResponse(result), result); | ||
| }); | ||
| NodeTest.test("leaves already-correct runtime alone", () => { | ||
| const current = "const runLoadSession = () => acp.agent.loadSession(loadPayload);"; | ||
| NodeAssert.equal(normalizeLoadResponse(current), current); | ||
| }); | ||
| NodeTest.test("rejects unrecognized race shape", () => { | ||
| NodeAssert.throws(() => | ||
| normalizeLoadResponse(legacy.replace("Fiber.join(idleFiber)", "Fiber.join(otherFiber)")), | ||
| ); | ||
| NodeAssert.throws(() => | ||
| normalizeLoadResponse(legacy.replace("runLoadSessionWithReplayIdle", "runLoadSessionChanged")), | ||
| ); | ||
| NodeAssert.throws(() => | ||
| normalizeLoadResponse(legacy + "\nconst extra = waitForSessionLoadReplayIdle;"), | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Preserve the carried fix: replay silence is not a session/load response. | ||
| export function normalizeLoadResponse(source: string): string { | ||
| const marker = " const runLoadSessionWithReplayIdle = ("; | ||
| if (!source.includes(marker)) { | ||
| if ( | ||
| source.includes("waitForSessionLoadReplayIdle") || | ||
| source.includes("runLoadSessionWithReplayIdle") | ||
| ) | ||
| throw new Error("Unexpected ACP load compatibility shape"); | ||
| return source; | ||
| } | ||
| if (!source.includes("waitForSessionLoadReplayIdle")) { | ||
| const directLoad = " const loaded = yield* acp.agent.loadSession(loadPayload).pipe("; | ||
| if ( | ||
| source.split(directLoad).length === 2 && | ||
| !source.includes("Fiber.join(idleFiber)") && | ||
| !source.includes("RPC response or replay idle gap") | ||
| ) | ||
| return source; | ||
| throw new Error("Unexpected ACP load compatibility shape: missing idle helper"); | ||
| } | ||
| const before = ` const idleFiber = yield* waitForSessionLoadReplayIdle({ | ||
| gateRef: sessionLoadGateRef, | ||
| }).pipe(Effect.forkIn(runtimeScope)); | ||
| const loaded = yield* Effect.raceFirst( | ||
| acp.agent.loadSession(loadPayload), | ||
| Fiber.join(idleFiber), | ||
| ).pipe( | ||
| Effect.ensuring(Fiber.interrupt(idleFiber).pipe(Effect.ignore)),`; | ||
| const after = ` // Replay silence does not acknowledge session/load or its configuration. | ||
| const loaded = yield* acp.agent.loadSession(loadPayload).pipe(`; | ||
| const replacements: ReadonlyArray<readonly [string, string]> = [ | ||
| [" waitForSessionLoadReplayIdle,\n", ""], | ||
| [before, after], | ||
| [ | ||
| "session/load timed out waiting for RPC response or replay idle gap", | ||
| "session/load timed out waiting for RPC response", | ||
| ], | ||
| ]; | ||
| let result = source; | ||
| for (const [from, to] of replacements) { | ||
| if (result.split(from).length !== 2) | ||
| throw new Error(`Unexpected ACP load compatibility shape: ${from}`); | ||
| result = result.replace(from, to); | ||
| } | ||
| if (result.includes("waitForSessionLoadReplayIdle") || result.includes("Fiber.join(idleFiber)")) | ||
| throw new Error("Unexpected ACP load compatibility shape: residual idle race"); | ||
| return result; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.