-
Notifications
You must be signed in to change notification settings - Fork 2
fix(plugin): plan-panel buffer + TCP server use-after-free (live-session reliability fixes) #232
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
Open
zajalist
wants to merge
16
commits into
main
Choose a base branch
from
fix/plan-panel-buffered-delivery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
17cb65b
fix(plugin): buffer pending plans so propose_plan survives lazy tab c…
zajalist be2b29f
fix(plugin): rename validator panel local Box to ActionBox (C4458 sha…
zajalist e39ef01
fix(plugin): wrap FSocket* in shared connection state to close use-af…
zajalist 31fdd88
fix(mcp): print build banner + warn loudly when dist is older than src
zajalist 93691ee
fix(mcp): always-on the Plan Mode meta-tools so agents do not need ha…
zajalist 060e38f
fix(mcp): register Plan Mode meta schemas so hayba_invoke can dispatc…
zajalist ad6b48a
fix(mcp+plugin): make actor_spawn accept mesh paths + python_run acce…
zajalist e8f1f8b
fix(plugin): keep TCP wire-facing signatures ABI-stable so Live Codin…
zajalist b2d35b9
fix(plugin+mcp): give actor_spawn / actor_transform snap_to_landscape…
zajalist 262f2fc
fix(mcp): include snap_to_landscape in server.tool() shape so MCP SDK…
zajalist 947ecb4
fix(plugin): defensive sanity checks in HaybaIdle::PollOnce so freed …
zajalist 13fcbc8
fix(plugin): SnapZToLandscape uses LineTraceMulti + ignores self so c…
zajalist b011655
fix(plugin+validator): serialize TCP commands + 2 new validator rules…
zajalist 696a198
fix(plugin): HandleProposePlan must check IsInGameThread() before Asy…
zajalist 1f777fd
refactor(plugin): single game-thread dispatcher eliminates AsyncTask …
zajalist 7ab593b
validator: rule for PCG-generate-overload (huge density + unbounded l…
zajalist 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
98 changes: 98 additions & 0 deletions
98
mcp-tools/hayba-mcp/scripts/check-no-raw-asynctask-gamethread.mjs
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,98 @@ | ||
| // CI lint: forbid raw `AsyncTask(ENamedThreads::GameThread, ...)` in plugin | ||
| // code, with an allowlist for the dispatcher implementation itself. | ||
| // | ||
| // The plugin must funnel all game-thread marshaling through | ||
| // HaybaThreading::ExecuteOnGameThread / RunOnGameThreadAndWait — those | ||
| // helpers use a FCoreDelegates::OnEndFrame-driven queue instead of UE's | ||
| // TaskGraph queue, which sidesteps the | ||
| // Assertion failed: ++Queue(QueueIndex).RecursionGuard == 1 | ||
| // TaskGraph.cpp:689 | ||
| // crash when a handler invoked via AsyncTask itself calls AsyncTask | ||
| // (re-entrant push). Two MCP sessions in May 2026 hit this; the fix is | ||
| // architectural (single dispatcher) and this lint keeps it from | ||
| // regressing. | ||
| // | ||
| // Allowlisted files (where raw AsyncTask is intentional): | ||
| // - HaybaMCPThreading.cpp — IS the dispatcher | ||
| // - HaybaMCPTcpServer.cpp — uses AsyncTask for the BACKGROUND worker pool | ||
| // (ENamedThreads::AnyBackgroundThreadNormalTask), | ||
| // never for GameThread | ||
|
|
||
| import { readdirSync, readFileSync, statSync } from 'node:fs'; | ||
| import { join, relative, sep } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { dirname } from 'node:path'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const PLUGIN_ROOT = join(__dirname, '..', '..', '..', 'unreal', 'HaybaMCPToolkit', 'Source'); | ||
|
|
||
| // Files allowed to call AsyncTask(GameThread) directly. Add new entries | ||
| // only with a documented reason in the file itself. | ||
| const ALLOWLIST = new Set([ | ||
| ['HaybaMCPToolkit', 'Private', 'HaybaMCPThreading.cpp'].join(sep), | ||
| ]); | ||
|
|
||
| const PATTERN = /AsyncTask\s*\(\s*ENamedThreads::GameThread/; | ||
|
|
||
| function walk(dir, hits) { | ||
| for (const entry of readdirSync(dir)) { | ||
| const full = join(dir, entry); | ||
| const st = statSync(full); | ||
| if (st.isDirectory()) { walk(full, hits); continue; } | ||
| if (!/\.(cpp|h)$/.test(entry)) continue; | ||
| const src = readFileSync(full, 'utf-8'); | ||
| const lines = src.split(/\r?\n/); | ||
| // Track whether we're inside a block comment across lines. | ||
| let inBlockComment = false; | ||
| for (let i = 0; i < lines.length; i++) { | ||
| const line = lines[i]; | ||
| const trimmed = line.trim(); | ||
| // Block comment handling — be conservative, may over-skip but | ||
| // that's safe (we don't want false positives flagging commentary). | ||
| if (inBlockComment) { | ||
| if (line.includes('*/')) inBlockComment = false; | ||
| continue; | ||
| } | ||
| if (/\/\*/.test(line) && !/\*\//.test(line)) { | ||
| inBlockComment = true; | ||
| continue; | ||
| } | ||
| // Single-line comments + Doxygen `*` continuation lines. | ||
| if (/^\s*\/\//.test(trimmed)) continue; | ||
| if (/^\s*\*/.test(trimmed)) continue; | ||
| if (PATTERN.test(line)) { | ||
| hits.push({ file: full, line: i + 1, text: trimmed }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const hits = []; | ||
| walk(PLUGIN_ROOT, hits); | ||
|
|
||
| const violations = hits.filter((h) => { | ||
| const rel = relative(PLUGIN_ROOT, h.file); | ||
| return !ALLOWLIST.has(rel); | ||
| }); | ||
|
|
||
| if (violations.length === 0) { | ||
| const allowlisted = hits.length; | ||
| console.log( | ||
| `[lint:no-raw-asynctask-gamethread] OK — ${allowlisted} raw AsyncTask(GameThread) call(s), all allowlisted.`, | ||
| ); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| console.error( | ||
| `[lint:no-raw-asynctask-gamethread] FAIL — ${violations.length} raw AsyncTask(GameThread) call(s) outside allowlist:`, | ||
| ); | ||
| for (const v of violations) { | ||
| console.error(` ${v.file}:${v.line}`); | ||
| console.error(` ${v.text}`); | ||
| } | ||
| console.error(''); | ||
| console.error(' Fix: call HaybaThreading::ExecuteOnGameThread(...) (fire-and-forget)'); | ||
| console.error(' or HaybaThreading::RunOnGameThreadAndWait(...) (blocking) instead.'); | ||
| console.error(' Raw AsyncTask(GameThread, ...) re-enters UE TaskGraph queue and crashes when'); | ||
| console.error(' the caller is already on the game thread (RecursionGuard assert).'); | ||
| process.exit(1); | ||
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
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
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.
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 the python-run snapshot expectation to match the new wrapper output.
wrapScriptForPrintRedirectnow emits directexec(_hayba_user_src, _hayba_user_globals), but the existing snapshot inmcp-tools/hayba-mcp/src/tools/python/python-run.test.tsstill expectsexec(compile(...)), so that test will drift/fail.✅ Suggested test expectation update
🤖 Prompt for AI Agents