feat(h5-session): Session Broker、run SSE replay 与 Finish 竞态修复
落地 H5 Session 架构 Patch 1–5(Broker 收口、Router decision、SSE taxonomy、goosed 边界检查), 并新增可选 MEMIND_RUN_STREAM_REPLAY run 事件回放与 H5 假交付 guard;修复 Finish 先于 agent-run gate 导致 UI 永久 loading 的竞态,接入 verify:h5-session-patches 回归脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
checkGoosedProxyBoundary,
|
||||
formatGoosedBoundaryViolations,
|
||||
GOOSED_DIRECT_ALLOWLIST,
|
||||
GOOSED_PROXY_ADAPTER_FILE,
|
||||
GOOSED_PROXY_GUARDED_FILES,
|
||||
} from '../goosed-proxy-boundary.mjs';
|
||||
|
||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const violations = checkGoosedProxyBoundary(rootDir);
|
||||
|
||||
if (violations.length > 0) {
|
||||
console.error('goosed proxy boundary check failed:\n');
|
||||
console.error(formatGoosedBoundaryViolations(violations));
|
||||
console.error('\nH5 chat must reach goosed only via tkmind-proxy.mjs.');
|
||||
console.error(`Allowlist: ${GOOSED_DIRECT_ALLOWLIST.join(', ')}`);
|
||||
console.error(`Guarded: ${GOOSED_PROXY_GUARDED_FILES.join(', ')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`goosed proxy boundary ok (adapter=${GOOSED_PROXY_ADAPTER_FILE}, allowlist=${GOOSED_DIRECT_ALLOWLIST.length}, guarded=${GOOSED_PROXY_GUARDED_FILES.length})`,
|
||||
);
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
const testFiles = [
|
||||
'session-broker.test.mjs',
|
||||
'agent-run-stream.test.mjs',
|
||||
'agent-run-routes.test.mjs',
|
||||
'agent-run-gateway.test.mjs',
|
||||
'sse-event-taxonomy.test.mjs',
|
||||
'goosed-proxy-boundary.test.mjs',
|
||||
'chat-agent-run-gate.test.mjs',
|
||||
'chat-finish-sync.test.mjs',
|
||||
'conversation-display.test.mjs',
|
||||
'mindspace-h5-html-finish-guard.test.mjs',
|
||||
];
|
||||
|
||||
function run(label, command, args) {
|
||||
const result = spawnSync(command, args, {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
console.error(`[verify:h5-session-patches] failed at ${label}`);
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
}
|
||||
|
||||
run('unit tests', process.execPath, ['--test', ...testFiles]);
|
||||
run('goosed proxy boundary', process.execPath, ['scripts/check-goosed-proxy-boundary.mjs']);
|
||||
run('mindspace publish guards', process.execPath, ['scripts/verify-mindspace-publish-guards.mjs']);
|
||||
|
||||
console.log('h5 session patch verification ok');
|
||||
@@ -18,6 +18,7 @@ function run(label, args) {
|
||||
run('MindSpace publish + chat finish unit tests', [
|
||||
'--test',
|
||||
'mindspace-public-finish-sync.test.mjs',
|
||||
'mindspace-h5-html-finish-guard.test.mjs',
|
||||
'conversation-display.test.mjs',
|
||||
'chat-finish-sync.test.mjs',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user