• 验证 46 号文档 Phase 3 v2(CEO 心跳发现并派发子任务)时,触发 CEO 心跳
    直接撞上 401——company-heartbeat-service.js 的 _sendAgentChat 和
    heartbeat-service.js 的 _triggerHeartbeat 都在自环调用
    POST /api/agent/:agentId/chat(agent-chat.js 挂了 requireAuthOrInternal),
    但两处都没有带 INTERNAL_TOKEN_HEADER——company.js/task-settle.js 的同类
    自环调用早就在带,这两处漏了。
    
    失败只落一行 console.warn,界面上什么都看不出来,影响的不只是 CEO 心跳:
    两套心跳系统(per-agent 的 heartbeat-service 和公司级的
    company-heartbeat-service,含它驱动的 pipeline/schedule 触发)都受影响。
    
    按现成模式补上内部令牌头。全量单测 1189 passed(唯二失败与本次改动
    无关),修完真实验证 CEO 心跳能正常跑完整段推理会话。
    
    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01H85SS5hVC4u1PbVhjmrhH8
    yibo authored
     
    Browse File »

  • 28-followups §3.3。`PUT /api/agent/:agentId/heartbeat`(前端 Agent 详情页走的就是它)
    用 `getBodyDir(id)` = `bodyDir(parseAddress(id).agentId)` 把公司段丢掉,
    然后**整份重写本体 config.json**。
    
    两个后果,都不报错:
    ① 跨租户串写:co-a:ceo 改心跳,co-b:ceo 跟着变(同一份本体);
    ② 一旦该 (agent, 公司) 有了公司态文件,读侧优先取公司态 →
       **这个端点的写入对它变成静默无效**。界面收到 {success:true},
       实际在跑的还是旧值;GET /info 同理报的是本体缺省,不是在跑的那份。
       症状是「界面写 30 分钟、调度器按 15 分钟在跑」,两边都不报错。
    
    company.js 那三个端点在 28 号已经修好了,这个入口漏了 —— 同一个 bug 的第二扇门。
    
    ## 改
    
    读写都走 heartbeat-service 的 readHeartbeatConfig / writeHeartbeatConfig,
    与心跳挂载读的是同一个答案。入参校验归服务(intervalMinutes 直接进 setInterval,
    NaN / 0 / 负数会让定时器退化成每 tick 触发一次,而每次 tick 真起一轮 LLM),
    非法值在写盘前抛,端点翻成 400。
    
    顺带:404 闸门也改走服务的寻址。`cid:role` 里冒号后面是**角色名**,未必等于本体 id
    (company_agents 的映射)—— 拿角色名当本体 id 判存在性,凡是角色名 ≠ 本体 id 的
    都会被判成「agent 不存在」,而写侧其实找得到。**判 404 和写入必须问同一个问题。**
    
    ## 守卫
    
    heartbeat-company-scoped.test.js 补 3 例(放进同一个 describe 而不是另起一个:
    夹具共用,另起的话上面那个 afterAll 会先把 server 关掉,实测 ECONNREFUSED):
    · 写公司态、本体字节不动,且**写完立刻能从读侧读回来** —— 这条才是「静默无效」的精确形态;
    · GET /info 报的是在跑的那份,不是本体缺省;
    · 非法 intervalMinutes → 400 且旧值还在。
    反向验过:把端点退回旧写法,这 3 条立刻红。
    
    ## 记一条没修的
    
    GET /info 的 404 闸门仍是 `getBodyDir(id)`,对 `cid:role` 会直接 404 ——
    那是 /info 整体寻址的既有缺口(它还要按同一个目录读 identity / agent.md / cron),
    不在心跳这一条的范围内。测试里用裸 agent id 绕开,并在注释里写明别当成修过了。
    
    全量:138 文件 / 1292 测试全绿。
    
    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    yibo authored
     
    Browse File »

  • 设计见 docs/done/system-design/28-agent-registry-unification.md。
    
    改造前 Agent 本体散在三处(system/agents/ 11 个、system/templates/ 50 个、
    data/companies/{id}/agents/ 17 个),同一个 AgentScaffold 被三个 baseDir 实例化。
    后果是同一角色在 N 家公司下有 N 份互不相干的副本,模板更新不会同步;
    org-coder / org-planner 这类走 hireFromBaseMetaAgent 造出来的本体
    legacy_path 指回自己公司目录,永远无法被第二家公司复用。
    
    本次:
    - G1 单一注册表:system/templates/ 整体并入 system/agents/,base → _base。
      7 个同名 id 逐个裁决,被丢弃的一份归档到 docs/_archive/ 而非删除。
      source_kind(template/global_agent/company_hired) → origin(builtin/created)。
    - G2 运行态下沉:CLI 的 cwd 从本体根改为 system/agents/{aid}/{cid}/{taskId}/。
      memory / conversations 落公司态 {aid}/{cid}/,按公司隔离不串。
      sessionPool 的 key 含 (companyId, taskId),两家公司调同一 agent 不复用会话。
    - G2b 产物不下沉:交付物仍落 data/companies/{cid}/,system/agents/ 只留运行痕迹。
      写入边界按链路分叉——graph 节点走节点私有目录(被 indexNodeOutputs 索引),
      chat 走公司 workspace,同一提示词里不再出现两条互斥指令。
    - G3 公司只存引用:data/companies/{id}/agents/ 删除,新增 company_agents 关联表。
      不复用 org_graph_nodes——后者是执行流图,work 层本体被雇时不写它,天生覆盖不全。
    - G4 缺则创建:本体缺失时从 _base 复制骨架进 system/agents/{id}/,
      agent-creator 填 agent.md/soul.md 后才从 draft 转 active(哨兵判据,
      骨架未填时哨兵仍在,不许被 hire)。产物即刻是全系统可复用的本体。
    
    新增 server/services/agent-locator.js 收编原先散在 6 处的寻址逻辑。
    
    边界守卫(graph-engine)的豁免从「本体根上五个文件名」放宽为整棵 system/agents/:
    新本体的骨架本来就要进 git,gitignore 挡不住 ?? system/agents/{newId}/,
    旧判据会把一个真正成功的招聘节点判成 boundary_escape fail。
    
    存量迁移见 scripts/migrate-agent-registry.js(幂等,备份到 data/_migration-backup-*)。
    
    真 Claude CLI E2E 已验证:新建公司 → orggraph-planning 自动规划 →
    自动招聘 org-planner/org-coder/org-validator 三节点流水线;
    data/companies/{cid}/agents/ 不存在,company_agents 4 行,
    system_agents 56→56(零新建私有本体,纯复用),git status 零增量。
    
    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    yibo authored
     
    Browse File »

  • Layer 1 (P0): Per-agent session mutex
    - heartbeat-service.js: skip heartbeat if previous session still active (30min safety valve)
    - agent-chat.js: reject concurrent /chat requests for same agentId with different convId (429)
      Multi-turn conversations on same convId still work normally
    
    Layer 2 (P1): Advisory file lock utility
    - server/utils/file-lock.js: O_EXCL-based .lock file mechanism
      Auto-cleanup stale locks, graceful degradation on timeout
    
    Root cause: HeartbeatService creates new convId per heartbeat, spawning
    independent Claude CLI processes that concurrently write config.json and
    SKILL.md, causing rollbacks and FRAUDULENT scores.
    yibo authored
     
    Browse File »

  • Fixed 4 hidden bugs where path.join(DATA_ROOT, "system", ...) was used instead
    of direct path.resolve to root-level system/:
    
    - agent-chat.js: billing log scan (line 804) and agent list scan (line 909)
    - company-service.js: TEMPLATES_DIR and GLOBAL_AGENTS_DIR constants
    - heartbeat-service.js: system agents scan directory
    
    These were missed because they used path.join with a variable (DATA_ROOT)
    rather than the literal string "data/system" that sed caught.
    Yi Bo authored
     
    Browse File »
  • - Moved data/system/ → system/ (agents, templates, skills, data, workspace)
    - Updated all server route/service path references
    - Updated all script path references
    - Updated all documentation references
    - Restructured .gitignore for cleaner system/ vs data/ boundary
    
    system/ = platform-shared assets (system agents, template library)
    data/ = tenant-specific company instance data
    Yi Bo authored
     
    Browse File »

  • - System agents: 只保留 master (data/system/agents/master)
    - Templates: 所有可复用 agent 模板 (data/system/templates/)
    - Companies: 公司创建时自动部署 5 个元 Agent (innovator/hunter/digester/evolver/agent-creator)
    
    路径修复:
    - agent-chat.js: /list 扫描路径修正 (system/agents + companies/*/agents)
    - agent-manager.js: 动态 agent 查找路径修正
    - skill-config-loader.js: 修正 agents root
    - pipeline-service.js: pipelines 输出到 companies/{id}/pipelines/
    - billing.log: 移至 companies/{id}/logs/ 下
    
    Skills 标准化:
    - 所有 template agent 建立 .claude/skills/main_skill/SKILL.md
    - company-service._copyTemplate() 新增 .claude/ 目录复制
    - innovator SKILL.md v3.0: 移除旧 l3-hunt/l2-digest 命名
    - 清理重复 agent_creator, 统一为 agent-creator
    
    清理:
    - 移除 data/agents, data/workspace, data/logs, data/goals 旧目录
    - 清除所有未使用的 DATA_DIR 声明
    - 清除 template 中的 conversations/logs/memory 运行态数据
    yibo authored
     
    Browse File »


  • - Extracted HeartbeatService to periodically wake up agents flagged with 'heartbeat.enabled'
    - Sends a silent [SYSTEM HEARTBEAT] message to trigger self-checks (e.g. OKR state validation)
    - Automatically integrated service dispatch hook in server startup sequence
    - Configured qa-judge to run autonomous heartbeat every 10 min
    yibo authored
     
    Browse File »