Repository navigation
Promote dev to stable: socket transport diagnostics #2478
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 all commits
da66d03
9e8fb6c
8d77994
3c3aed5
fb86633
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| downloadAndVerifyTarball, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ensureCanonicalInstall, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| extractPgservePortFromStatus, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| extractPgserveSocketDirFromStatus, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchLatestManifest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formatVerifyBanner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isGenieProcessSnapshotLine, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -893,6 +894,41 @@ describe('Diagnostics schema (G5)', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(extractPgservePortFromStatus('not-json')).toBe(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('diagnostics derives pgserve socket dir from live pgserve runtime status json', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const liveStatus = JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installed: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: 'online', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port: 8432, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| socketDir: '/run/user/1000/pgserve', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime: { socketDir: '/run/user/1000/pgserve', port: 8432, live: true }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(extractPgserveSocketDirFromStatus(liveStatus)).toBe('/run/user/1000/pgserve'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('diagnostics derives pgserve port from live pgserve runtime status json', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const liveStatus = JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installed: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: 'online', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port: null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime: { port: 8432, live: true }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+909
to
+918
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. Add a conflict-case test for Current coverage only checks runtime fallback when top-level Suggested test addition+ test('diagnostics prefers runtime.port over stale top-level port when both are present', () => {
+ const liveStatus = JSON.stringify({
+ port: 15432,
+ runtime: { port: 8432, live: true },
+ });
+ expect(extractPgservePortFromStatus(liveStatus)).toBe('8432');
+ });As per coding guidelines: "Test edge cases and boundaries of every command, flag, and plugin contract". 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('serve status reports pgserve transport from resolver instead of stale active port', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const source = readFileSync(join(__dirname, '..', '..', 'term-commands', 'serve.ts'), 'utf-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fnStart = source.indexOf('async function printPgserveHealth'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(fnStart).toBeGreaterThan(-1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fnBody = source.slice(fnStart, source.indexOf('/**', fnStart + 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(fnBody).toContain('resolvePgserveTransport'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(fnBody).toContain("transport?.kind === 'unix'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(fnBody).not.toContain('isSocketMode()'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(fnBody).not.toContain('getActivePort()'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('NO_COLOR honored via colorEnabled() helper', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const source = readFileSync(join(__dirname, '..', 'update.ts'), 'utf-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(source).toContain('process.env.NO_COLOR'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1245,10 +1245,28 @@ export function isGenieProcessSnapshotLine(line: string): boolean { | |||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export function extractPgserveSocketDirFromStatus(output: string): string | null { | ||||||||||||||
| try { | ||||||||||||||
| const parsed = JSON.parse(output) as { | ||||||||||||||
| socketDir?: unknown; | ||||||||||||||
| runtime?: { socketDir?: unknown }; | ||||||||||||||
| }; | ||||||||||||||
| const rawSocketDir = parsed.runtime?.socketDir ?? parsed.socketDir; | ||||||||||||||
| if (typeof rawSocketDir === 'string' && rawSocketDir.trim()) return rawSocketDir.trim(); | ||||||||||||||
| } catch { | ||||||||||||||
| // best-effort diagnostics only; callers fall back to null. | ||||||||||||||
| } | ||||||||||||||
| return null; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export function extractPgservePortFromStatus(output: string): string | null { | ||||||||||||||
| try { | ||||||||||||||
| const parsed = JSON.parse(output) as { port?: unknown; instance?: { port?: unknown } }; | ||||||||||||||
| const rawPort = parsed.port ?? parsed.instance?.port; | ||||||||||||||
| const parsed = JSON.parse(output) as { | ||||||||||||||
| port?: unknown; | ||||||||||||||
| instance?: { port?: unknown }; | ||||||||||||||
| runtime?: { port?: unknown }; | ||||||||||||||
| }; | ||||||||||||||
| const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port; | ||||||||||||||
| if (typeof rawPort === 'number' && Number.isFinite(rawPort)) return String(rawPort); | ||||||||||||||
| if (typeof rawPort === 'string' && rawPort.trim()) return rawPort.trim(); | ||||||||||||||
|
Comment on lines
+1269
to
1271
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. Prefer Line 1269 currently prioritizes Suggested fix- const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port;
+ const rawPort = parsed.runtime?.port ?? parsed.port ?? parsed.instance?.port;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } catch { | ||||||||||||||
|
|
@@ -1287,7 +1305,9 @@ async function collectUpdateDiagnostics( | |||||||||||||
| const signals = summarizeJsonlSignals(schedulerLog); | ||||||||||||||
| const pgservePortFromFile = safeRead(join(GENIE_HOME, 'pgserve.port'), 200); | ||||||||||||||
| const pgserveStatusJson = (await runCommandSilent('pgserve', ['status', '--json'], undefined, 2000)).output.trim(); | ||||||||||||||
| const pgserveSocketDir = extractPgserveSocketDirFromStatus(pgserveStatusJson); | ||||||||||||||
| const pgservePort = pgservePortFromFile ?? extractPgservePortFromStatus(pgserveStatusJson); | ||||||||||||||
| const pgserveTransport = pgserveSocketDir ? 'unix-socket' : pgservePort ? 'tcp' : 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. The transport detection logic should account for the SOCKET_PORT_SENTINEL (value "0"), which indicates a Unix socket transport even if the socketDir wasn't explicitly extracted from the status JSON. Additionally, since pgservePort might contain trailing whitespace if read from the legacy port file, it's safer to trim it during the check.
Suggested change
References
|
||||||||||||||
|
|
||||||||||||||
| const diagnostics = { | ||||||||||||||
| schemaVersion: UPDATE_DIAGNOSTIC_SCHEMA_VERSION, | ||||||||||||||
|
|
@@ -1327,6 +1347,8 @@ async function collectUpdateDiagnostics( | |||||||||||||
| genieBinPrevious: GENIE_BIN_PREVIOUS, | ||||||||||||||
| logsDir, | ||||||||||||||
| servePid: safeRead(join(GENIE_HOME, 'serve.pid'), 200), | ||||||||||||||
| pgserveTransport, | ||||||||||||||
| pgserveSocketDir, | ||||||||||||||
|
Comment on lines
+1350
to
+1351
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. This change introduces new fields (pgserveTransport, pgserveSocketDir) to the diagnostics report. According to the internal guidelines, UPDATE_DIAGNOSTIC_SCHEMA_VERSION should be incremented for any additive change to the schema to allow consumers to correctly identify the available metadata. References
|
||||||||||||||
| pgservePort, | ||||||||||||||
| schedulerLog, | ||||||||||||||
| tuiCrashLog, | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update
binarySha256pins before merge.CI is failing with SHA drift, which means the pinned hashes in
package.jsonno longer match downloaded release assets. This release/version bump should include refreshedbinarySha256entries (or the asset set must be reverted to match current pins), otherwise release integrity checks stay red.🤖 Prompt for AI Agents