1111 *
1212 * A pre-lock server has no lock database, so the first upgraded process also
1313 * checks `server-runtime.json` and refuses while that recorded pid is live.
14+ * That compatibility check starts only after the old binary publishes its
15+ * runtime state; an unmodified old binary cannot participate in a lock that
16+ * did not exist when it shipped.
1417 */
1518import * as Data from "effect/Data" ;
1619import * as Crypto from "effect/Crypto" ;
@@ -50,6 +53,7 @@ export class ServerAlreadyRunningError extends Schema.TaggedErrorClass<ServerAlr
5053 holderPid : Schema . optional ( Schema . Int ) ,
5154 holderPort : Schema . optional ( Schema . Int ) ,
5255 holderStartedAt : Schema . optional ( Schema . String ) ,
56+ legacyRuntimeStatePath : Schema . optional ( Schema . String ) ,
5357 } ,
5458) {
5559 override get message ( ) : string {
@@ -59,7 +63,7 @@ export class ServerAlreadyRunningError extends Schema.TaggedErrorClass<ServerAlr
5963 : this . holderPort === undefined
6064 ? `pid ${ this . holderPid } `
6165 : `pid ${ this . holderPid } , listening on port ${ this . holderPort } ` ;
62- return [
66+ const common = [
6367 "Another T3 Code server is already using this data directory." ,
6468 "" ,
6569 ` data directory: ${ this . stateDir } ` ,
@@ -69,6 +73,17 @@ export class ServerAlreadyRunningError extends Schema.TaggedErrorClass<ServerAlr
6973 "Two servers sharing one data directory overwrite each other's state.sqlite" ,
7074 "and settings.json. Connect to the running server, stop it cleanly, or use" ,
7175 "a different --base-dir." ,
76+ ] ;
77+ if ( this . legacyRuntimeStatePath !== undefined ) {
78+ return [
79+ ...common ,
80+ "" ,
81+ `${ this . legacyRuntimeStatePath } is the compatibility guard for this older` ,
82+ "server. Do not remove it while the recorded process is live." ,
83+ ] . join ( "\n" ) ;
84+ }
85+ return [
86+ ...common ,
7287 "" ,
7388 `Ownership is released automatically when the process exits. ${ this . lockPath } ` ,
7489 "contains display metadata only; removing it does not release a live owner." ,
@@ -314,6 +329,7 @@ export const acquireServerSingleton = Effect.fn("serverSingleton.acquire")(funct
314329 holderPid : legacy . state . pid ,
315330 holderPort : legacy . state . port ,
316331 holderStartedAt : legacy . state . startedAt ,
332+ legacyRuntimeStatePath,
317333 } ) ,
318334 ) ,
319335 } ) ,
0 commit comments