---
phase: 02-thread-and-skills-logic-reconciliation
plan: 01
subsystem: api
tags: [thread-routing, skills-bootstrap, contract-normalization, regression-tests]
requires:
  - phase: 01-conflict-inventory-and-decision-matrix
    provides: conflict-inventory and titan decision matrix
provides:
  - thread routing single-path behavior without isnew query semantics
  - skills bootstrap contract normalized to content_ids with legacy content_id adapter
  - regression tests for thread intent and skills payload normalization
affects: [phase-03-legacy-visual-alignment, phase-05-test-hardening]
tech-stack:
  added: []
  patterns:
    - route-driven new-session semantics
    - single-entry contract normalization at API boundary
key-files:
  created:
    - frontend/src/core/skills/normalize-bootstrap.ts
    - frontend/src/core/skills/types.ts
    - frontend/src/core/threads/hooks.test.ts
    - frontend/src/core/skills/api.test.ts
    - frontend/tests/e2e/thread-routing.spec.ts
    - .planning/phases/02-thread-and-skills-logic-reconciliation/02-SUMMARY.md
  modified:
    - frontend/src/components/workspace/chats/use-thread-chat.ts
    - frontend/src/core/threads/utils.ts
    - frontend/src/app/workspace/chats/[thread_id]/page.tsx
    - frontend/src/core/skills/api.ts
    - frontend/src/hooks/use-selected-skill-listener.ts
    - frontend/tests/e2e/support/chat-helpers.ts
    - frontend/tests/e2e/welcome-and-routing.spec.ts
key-decisions:
  - "按 D-01 删除 isnew 参数逻辑，改为仅由 /workspace/chats/new 路由决定新会话。"
  - "按 D-02 以 content_ids 为主合同，content_id 仅作为最小兼容输入。"
  - "按 D-03 删除旧分支与双主路径，保留单入口归一。"
patterns-established:
  - "query 参数语义收敛到 route + thread_id"
  - "协议兼容层集中在 core/skills/api.ts"
requirements-completed: [MERGE-02, LOGIC-03, LOGIC-04]
duration: 24 min
completed: 2026-04-07
---

# Phase 02 Plan 01: thread-and-skills-logic-reconciliation Summary

**线程路由从 isnew 参数切换为路由单路径语义，并将 skills bootstrap 合同统一到 content_ids。**

## Performance

- **Duration:** 24 min
- **Started:** 2026-04-07T12:53:49+08:00
- **Completed:** 2026-04-07T04:55:00Z
- **Tasks:** 3
- **Files modified:** 13

## Accomplishments
- 删除 `isnew` 的查询参数控制逻辑，统一为 `/workspace/chats/new` 路由语义。
- 建立 `content_id -> content_ids` 最小兼容归一层，消除双主合同路径。
- 新增 thread/skills 核心单测与路由 e2e 用例，形成回归保护。

## Task Commits

1. **Task 1: 线程路由参数与新逻辑单路径对齐** - `af21bbd1` (feat)
2. **Task 2: skills bootstrap 合同归一到新逻辑** - `034e35c8` (feat)
3. **Task 3: 回归与死分支清理验证** - `c01ac7b8` (test)

## Decisions Made
- `isnew` 语义完全删除，避免 query 驱动产生多分支。
- `content_ids` 作为唯一主合同，`content_id` 只做边界适配。
- 路由/合同归一在 core 层单入口实施，避免组件层重复逻辑。

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 3 - Blocking] 调整 Task 级验证命令**
- **Found during:** Task 1/2/3 验证
- **Issue:** `frontend/package.json` 不存在 `npm run test` 脚本，原计划命令不可执行。
- **Fix:** 使用 `node --test src/core/threads/hooks.test.ts src/core/skills/api.test.ts` 执行单测。
- **Verification:** 5/5 tests passed。
- **Committed in:** `c01ac7b8`

---

**Total deviations:** 1 auto-fixed (1 blocking)
**Impact on plan:** 不影响目标达成，验证链路改为可执行命令。

## Issues Encountered
- E2E 运行失败：`ERR_CONNECTION_REFUSED`（`http://127.0.0.1:2026` 无运行中的前端服务）。代码与用例已生成，待运行环境启动后复测。

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness
- 逻辑单路径已形成，可进入 Phase 3 进行视觉对齐。
- 建议在可用环境补跑 `thread-routing.spec.ts` 完成端到端确认。

---
*Phase: 02-thread-and-skills-logic-reconciliation*
*Completed: 2026-04-07*
