-
Notifications
You must be signed in to change notification settings - Fork 0
fix: invalidate stale reconciliation proof #75
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
10 commits
Select commit
Hold shift + click to select a range
c7d9464
fix: invalidate stale reconciliation proof
roodboi 4a079e5
fix: block active destination state writers
roodboi 654c705
fix: harden reconciliation recovery state
roodboi 33e6b53
fix: close reconciliation migration races
roodboi 6b5a29f
fix: preserve exclusive recovery ordering
roodboi 3253a80
fix: serialize stale recovery and migration guards
roodboi a95c96e
fix: preserve live legacy lock owners
roodboi 5b90056
fix: close reconciliation authority gaps
roodboi c452df0
fix: prevent stale proof resurrection
roodboi fce5cb2
perf: batch containment rechecks
roodboi 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
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,62 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import { chmod, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { delimiter, join } from "node:path"; | ||
| import { | ||
| processStartIdentity, | ||
| processStartIdentityMatches, | ||
| } from "./process-identity"; | ||
|
|
||
| test.skipIf(process.platform === "win32")( | ||
| "uses a timezone-invariant Unix process start identity", | ||
| async () => { | ||
| const fixture = await mkdtemp(join(tmpdir(), "fclt-process-identity-")); | ||
| const executableDir = join(fixture, "bin"); | ||
| const psPath = join(executableDir, "ps"); | ||
| await mkdir(executableDir); | ||
| await writeFile( | ||
| psPath, | ||
| `#!/bin/sh | ||
| case "$TZ" in | ||
| UTC) printf '%s\\n' 'Wed Jul 29 16:00:00 2026' ;; | ||
| America/Los_Angeles) printf '%s\\n' 'Wed Jul 29 09:00:00 2026' ;; | ||
| Asia/Tokyo) printf '%s\\n' 'Thu Jul 30 01:00:00 2026' ;; | ||
| *) printf '%s\\n' 'timezone was not fixed' ;; | ||
| esac | ||
| `, | ||
| "utf8" | ||
| ); | ||
| await chmod(psPath, 0o755); | ||
| try { | ||
| const identityFor = (timezone: string): string | undefined => | ||
| processStartIdentity(process.pid, { | ||
| environment: { | ||
| ...process.env, | ||
| PATH: `${executableDir}${delimiter}${process.env.PATH ?? ""}`, | ||
| TZ: timezone, | ||
| }, | ||
| }); | ||
|
|
||
| const expected = `${process.platform}:stable-v1:Wed Jul 29 16:00:00 2026`; | ||
| expect(identityFor("America/Los_Angeles")).toBe(expected); | ||
| expect(identityFor("Asia/Tokyo")).toBe(expected); | ||
| expect( | ||
| processStartIdentityMatches( | ||
| `${process.platform}:Wed Jul 29 12:00:00 2026`, | ||
| expected | ||
| ) | ||
| ).toBe(true); | ||
| expect( | ||
| processStartIdentityMatches( | ||
| `${process.platform}:stable-v1:Wed Jul 29 15:59:59 2026`, | ||
| expected | ||
| ) | ||
| ).toBe(false); | ||
| expect(processStartIdentityMatches("original-process", expected)).toBe( | ||
| false | ||
| ); | ||
| } finally { | ||
| await rm(fixture, { force: true, recursive: true }); | ||
| } | ||
| } | ||
| ); |
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,53 @@ | ||
| import { spawnSync } from "node:child_process"; | ||
|
|
||
| const STABLE_IDENTITY_VERSION = "stable-v1"; | ||
|
|
||
| export function processStartIdentity( | ||
| pid: number, | ||
| options: { environment?: NodeJS.ProcessEnv } = {} | ||
| ): string | undefined { | ||
| const environment = options.environment ?? process.env; | ||
| const result = | ||
| process.platform === "win32" | ||
| ? spawnSync( | ||
| "powershell.exe", | ||
| [ | ||
| "-NoProfile", | ||
| "-NonInteractive", | ||
| "-Command", | ||
| `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`, | ||
| ], | ||
| { encoding: "utf8", env: environment } | ||
| ) | ||
| : spawnSync("ps", ["-o", "lstart=", "-p", String(pid)], { | ||
| encoding: "utf8", | ||
| env: { | ||
| ...environment, | ||
| LC_ALL: "C", | ||
| TZ: "UTC", | ||
| }, | ||
| }); | ||
| if (result.status !== 0 || typeof result.stdout !== "string") { | ||
| return undefined; | ||
| } | ||
| const startedAt = result.stdout.trim(); | ||
| return startedAt | ||
| ? `${process.platform}:${STABLE_IDENTITY_VERSION}:${startedAt}` | ||
| : undefined; | ||
| } | ||
|
|
||
| export function processStartIdentityMatches( | ||
| recorded: string, | ||
| observed: string | ||
| ): boolean { | ||
| if (recorded === observed) { | ||
| return true; | ||
| } | ||
| const stablePrefix = `${process.platform}:${STABLE_IDENTITY_VERSION}:`; | ||
| const legacyPrefix = `${process.platform}:`; | ||
| return ( | ||
| observed.startsWith(stablePrefix) && | ||
| recorded.startsWith(legacyPrefix) && | ||
| !recorded.startsWith(stablePrefix) | ||
| ); | ||
| } | ||
Oops, something went wrong.
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.