Skip to content

Commit efef29d

Browse files
author
DavidQ
committed
BUILD PR: centralize readHostStatus/readHostSnapshot across exact engine batch.
1 parent d0fe1e0 commit efef29d

8 files changed

Lines changed: 122 additions & 34 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_44_TO_RESULT_DEBUG_COMMAND_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH.md exactly.
55
Edit only these files:
6-
- src/engine/debug/shared/debugCommandResultUtils.js (new file)
6+
- src/engine/debug/network/shared/hostReadUtils.js (new file)
77
- src/engine/debug/inspectors/commands/registerInspectorCommands.js
8-
- tools/dev/presets/debugPresetApplier.js
8+
- src/engine/debug/network/dashboard/registerDashboardCommands.js
99
Do not expand scope.
10-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_44_TO_RESULT_DEBUG_COMMAND_BATCH_delta.zip
10+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD PR: centralize toResult across exact debug-command batch.
1+
BUILD PR: centralize readHostStatus/readHostSnapshot across exact engine batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: run BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH after this batch.
1+
Next: run BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH after this batch.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Execution-grade batch for toResult using the exact duplicate-report file list.
1+
Execution-grade batch for host reader helpers using the exact duplicate-report file list.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH
2+
3+
## Purpose
4+
Centralize duplicated dashboard/inspector host reader helpers across the exact engine batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY these helpers:
8+
9+
- `readHostStatus(host)`
10+
- `readHostSnapshot(host)`
11+
12+
## Exact Files Allowed
13+
14+
### New shared file
15+
1. `src/engine/debug/network/shared/hostReadUtils.js`
16+
17+
### Consumer files
18+
2. `src/engine/debug/inspectors/commands/registerInspectorCommands.js`
19+
3. `src/engine/debug/network/dashboard/registerDashboardCommands.js`
20+
21+
Do not edit any other file.
22+
23+
## Source of Truth
24+
This exact scope comes from the provided duplicate report entries for:
25+
- `function readHostStatus(host)`
26+
- `function readHostSnapshot(host)`
27+
28+
Only the 2 listed consumer files are in scope.
29+
30+
## Exact Shared Helper Creation
31+
Create:
32+
33+
`src/engine/debug/network/shared/hostReadUtils.js`
34+
35+
Export exactly:
36+
- `readHostStatus`
37+
- `readHostSnapshot`
38+
39+
Implementation rules:
40+
- use ONE existing local implementation as source-of-truth for each helper
41+
- do NOT merge logic
42+
- do NOT generalize behavior
43+
- preserve signatures exactly:
44+
- `readHostStatus(host)`
45+
- `readHostSnapshot(host)`
46+
47+
## Exact Consumer Changes
48+
For each of the 2 listed consumer files:
49+
50+
If the file contains local function definitions matching:
51+
```js
52+
function readHostStatus(host)
53+
function readHostSnapshot(host)
54+
```
55+
then:
56+
- remove the local function definition(s)
57+
- import the helper(s) from the correct relative path to:
58+
- `src/engine/debug/network/shared/hostReadUtils.js`
59+
- if the file already imports from that module, add the needed helper(s) with the minimum safe edit
60+
- do not duplicate imports
61+
- do not touch unrelated helpers
62+
- do not change logic
63+
64+
If a listed file already imports and uses shared versions, leave it unchanged.
65+
66+
## Relative Import Rule
67+
Use the correct relative path from each consumer file to:
68+
69+
`src/engine/debug/network/shared/hostReadUtils.js`
70+
71+
Do not use aliases.
72+
Do not change `.js` extension usage.
73+
74+
## Hard Constraints
75+
- no files outside the 2 listed consumers plus the one new shared file
76+
- no repo-wide dashboard/inspector cleanup
77+
- no behavior changes
78+
- keep one PR purpose only
79+
80+
## Validation Checklist
81+
1. Confirm no more than the 3 listed files changed
82+
2. Confirm `src/engine/debug/network/shared/hostReadUtils.js` exists and exports:
83+
- `readHostStatus`
84+
- `readHostSnapshot`
85+
3. Confirm local function definitions no longer exist in changed listed consumer files
86+
4. Confirm changed consumer files import the helpers from the correct relative path to `src/engine/debug/network/shared/hostReadUtils.js`
87+
5. Confirm no unrelated files changed
88+
6. Confirm no behavior changes were made
89+
90+
## Non-Goals
91+
- no cleanup of other dashboard or inspector helpers
92+
- no cleanup outside the 2 listed consumer files
93+
- no refactor beyond this exact duplicate-removal batch

src/engine/debug/inspectors/commands/registerInspectorCommands.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ import {
1111
sanitizeText
1212
} from "../shared/inspectorUtils.js";
1313
import { toResult } from "../../shared/debugCommandResultUtils.js";
14-
15-
function readHostStatus(host) {
16-
return host && typeof host.getStatus === "function"
17-
? asObject(host.getStatus())
18-
: {};
19-
}
20-
21-
function readHostSnapshot(host) {
22-
return host && typeof host.getSnapshot === "function"
23-
? asObject(host.getSnapshot())
24-
: {};
25-
}
14+
import {
15+
readHostSnapshot,
16+
readHostStatus
17+
} from "../../network/shared/hostReadUtils.js";
2618

2719
export function createInspectorCommandPack(options = {}) {
2820
const source = asObject(options);

src/engine/debug/network/dashboard/registerDashboardCommands.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ registerDashboardCommands.js
88
import { asArray, asObject, sanitizeText } from "../shared/networkDebugUtils.js";
99
import { normalizeServerDashboardSnapshot } from "./serverDashboardProviders.js";
1010
import { listServerDashboardRefreshModes } from "./serverDashboardRefreshModes.js";
11+
import {
12+
readHostSnapshot,
13+
readHostStatus
14+
} from "../shared/hostReadUtils.js";
1115

1216
function toCommandResult(title, lines, code = "DASHBOARD_OK", status = "ready") {
1317
return {
@@ -18,20 +22,6 @@ function toCommandResult(title, lines, code = "DASHBOARD_OK", status = "ready")
1822
};
1923
}
2024

21-
function readHostStatus(host) {
22-
if (!host || typeof host.getStatus !== "function") {
23-
return {};
24-
}
25-
return asObject(host.getStatus());
26-
}
27-
28-
function readHostSnapshot(host) {
29-
if (!host || typeof host.getSnapshot !== "function") {
30-
return normalizeServerDashboardSnapshot({});
31-
}
32-
return normalizeServerDashboardSnapshot(host.getSnapshot());
33-
}
34-
3525
function formatStatusLines(status) {
3626
return [
3727
`running=${Boolean(status.running)}`,
@@ -132,7 +122,7 @@ export function createServerDashboardCommandPack(options = {}) {
132122
summary: "Show normalized dashboard snapshot summary.",
133123
usage: "dashboard.snapshot",
134124
handler() {
135-
const snapshot = readHostSnapshot(host);
125+
const snapshot = normalizeServerDashboardSnapshot(readHostSnapshot(host));
136126
const players = asArray(snapshot.players);
137127
const selectedRows = players.slice(0, 5).map((player) => {
138128
const row = asObject(player);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { asObject } from "../../inspectors/shared/inspectorUtils.js";
2+
3+
export function readHostStatus(host) {
4+
return host && typeof host.getStatus === "function"
5+
? asObject(host.getStatus())
6+
: {};
7+
}
8+
9+
export function readHostSnapshot(host) {
10+
return host && typeof host.getSnapshot === "function"
11+
? asObject(host.getSnapshot())
12+
: {};
13+
}

0 commit comments

Comments
 (0)