Files
memind/docs/context-runtime-local-dev.md
T
john 257edb4917 feat(dev-tools): add shadow portal and dsh gateway local E2E scripts
Add events-only Context Runtime shadow portal verification to save LLM
tokens, wire Tool Gateway → dsh headless smoke, and document both flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-10 09:24:57 +08:00

3.4 KiB
Raw Blame History

Context Runtime 本地离线开发

不调用 LLM、不跑 phase3 live smoke。用户自测见文末清单。

一键离线验证

node scripts/run-context-runtime-offline.mjs
node scripts/run-goosed-v149-phase3-offline.mjs   # 含 v1.49 单测 + manifest drift

通过时应分别输出 CONTEXT_RUNTIME_OFFLINE_OKGOOSE_V149_PHASE3_OFFLINE_OK

推荐 shadow 配置(仅观测,不改行为)

写入 .env.local(或临时 export):

MEMIND_HEADROOM_MODE=shadow
MEMIND_CONTEXT_BUDGET_MODE=shadow
MEMIND_RECALL_FUSION_MODE=shadow
MEMIND_MCP_COMPACT_MODE=shadow
MEMIND_ZVEC_WORKSPACE_MODE=shadow
HEADROOM_OUTPUT_SHAPER=0

Bundle 常量见 context-runtime-profile.mjsCONTEXT_RUNTIME_SHADOW_ENV

离线事件形状预览

不启动 Portal 也可查看 gateway 将 emit 的 shadow 事件:

node -e "
import { simulateContextRuntimeShadowEvents } from './context-runtime-profile.mjs';
console.log(JSON.stringify(simulateContextRuntimeShadowEvents(), null, 2));
"

期望事件类型:

event_type 含义
headroom_context_observed headroom 路由/eligible 观测
context_budget_resolved 注入预算 dedupe/drop 计划
recall_fusion_resolved 多路 recall 融合统计

组件探针(可选)

# headroom proxy 已起且 MEMIND_HEADROOM_MODE!=off
node scripts/check-headroom-proxy-local.mjs

# .zvec-grep 已 index
node scripts/check-zvec-workspace-local.mjs

# MCP compactor shadow/active 逻辑
node scripts/check-mcp-compactor-local.mjs

# codebase-memory-mcp CLI + Memind 索引(见 docs/codebase-memory-mcp-local.md
node scripts/check-codebase-memory-mcp-local.mjs

# dsh CLI + dry-run launch plan(见 docs/dsh-executor-local.md,默认零 LLM
node scripts/check-dsh-executor-local.mjs

Shadow Portal E2E1 轮,省 token 默认只验事件)

Portal 需带 shadow 五件套(见上文)运行 pnpm dev

node scripts/run-context-runtime-shadow-portal-e2e.mjs
# 默认 CONTEXT_RUNTIME_SHADOW_EVENTS_ONLY=1:拿到 headroom/budget shadow 事件即停,不等 Goose 跑完
# 通过 → CONTEXT_RUNTIME_SHADOW_PORTAL_OK

recall_fusion_resolved 在 agent memory 关闭时可能缺失,脚本会 WARN 但不阻断。

用户自测清单(有 LLM 配额时)

  1. 确认 未设置 GOOSE_V149_ALLOW_REAL_LLM=1 除非你明确要跑 live smoke
  2. 应用 shadow env重启 Portalpnpm dev
  3. 发起 一轮普通 agent 对话(非 page-e2e
  4. 查 DB 事件:
SELECT event_type, data_json, created_at
FROM h5_agent_run_events
WHERE run_id = '<run_id>'
  AND event_type IN (
    'headroom_context_observed',
    'context_budget_resolved',
    'recall_fusion_resolved'
  )
ORDER BY created_at;
  1. 确认 mode=shadow聊天行为与 off 时一致
  2. 若要 active 晋升:逐项改 shadowactive,每次只改一个开关

禁止项

  • Agent 不得自动设置 GOOSE_V149_ALLOW_REAL_LLM=1 或循环跑 phase2/phase3
  • 预计超过 10k token 的 LLM 调用须用户明确同意(含 dsh headless / Goose smoke
  • 禁止 headroom wrap / headroom learn / HEADROOM_OUTPUT_SHAPER=1
  • 页面生成 / Page Data 轮次首期 排除 headroom active

相关文档