harden sm-flow protocol and archive v4.0 validation runs
- Rewrite hard constraint #1: apply must read Committed OpenSpec files as the execution source of truth - Promote sub-skill invocation to hard constraint #6; remove fallbacks.md and all degradation paths - Add file existence verification at commit and archive exit gates - Require grill question pool, evidence-driven conclusions, and user-interview confirmations to be written to decisions.md - Record v4.0 validation retrospective in workflow.md: propose overreach, sub-skill pseudo-calling, spec omitting user behavior - Archive knowledge-index-sort OpenSpec and devflow entries from prior run
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
# knowledge-index-sort Design
|
||||
|
||||
## 架构摘要
|
||||
|
||||
排序功能集成到现有的 `applyFilters()` 函数中,形成完整的过滤→排序→渲染管道:
|
||||
|
||||
```
|
||||
用户操作(搜索/标签/年份/排序)
|
||||
↓
|
||||
applyFilters()
|
||||
├─ 年份过滤(year-filter)
|
||||
├─ 标签过滤(tag-badge.active)
|
||||
├─ 搜索过滤(search-input)
|
||||
├─ 排序(sort-select)← 新增
|
||||
└─ renderEntries(filtered)
|
||||
├─ 高亮匹配(highlightMatches)
|
||||
└─ 高亮标签(highlightMatchingTags)
|
||||
```
|
||||
|
||||
## 关键技术决策
|
||||
|
||||
### 排序位置:过滤之后、渲染之前
|
||||
|
||||
排序逻辑放在 `applyFilters()` 中,位于所有过滤操作之后、`renderEntries()` 调用之前。
|
||||
|
||||
- 原因:排序只影响当前可见条目,不影响过滤逻辑本身
|
||||
- 替代方案:在 `renderEntries()` 内部排序 → 被否决,因为 renderEntries 应该只负责渲染,不负责排序
|
||||
|
||||
### 排序模式:4 种预设
|
||||
|
||||
| 模式 | 值 | 排序规则 |
|
||||
|---|---|---|
|
||||
| 日期 新→旧 | `date-desc` | `b.date.localeCompare(a.date)`(默认) |
|
||||
| 日期 旧→新 | `date-asc` | `a.date.localeCompare(b.date)` |
|
||||
| 标签 多→少 | `tags-desc` | `b.tags.length - a.tags.length` |
|
||||
| 标签 少→多 | `tags-asc` | `a.tags.length - b.tags.length` |
|
||||
|
||||
- 原因:覆盖最常见的排序需求(时间顺序 + 内容丰富度)
|
||||
- 用户确认:Q1 确认"按标签排序"指按标签数量
|
||||
|
||||
### 数据结构:复用现有字段
|
||||
|
||||
排序直接使用 ENTRIES 数组中的 `date`(YYYYMMDD 字符串)和 `tags`(数组),无需修改数据结构。
|
||||
|
||||
- 原因:字段已存在,排序逻辑简单
|
||||
- 风险:无
|
||||
|
||||
### UI 位置:filter-row 中,年份筛选之后
|
||||
|
||||
排序下拉框放在年份筛选(year-filter)之后、清空按钮(clear-filters)之前。
|
||||
|
||||
- 原因:与现有控件保持一致的视觉层级
|
||||
- 替代方案:单独一行 → 被否决,增加垂直空间占用
|
||||
|
||||
## 模块地图
|
||||
|
||||
| 模块 | 职责 | 备注 |
|
||||
|---|---|---|
|
||||
| sort-select HTML | 排序 UI 控件 | 4 个 option |
|
||||
| bindSortSelect() | 绑定 change 事件 | 触发 applyFilters() |
|
||||
| applyFilters() 排序段 | 执行排序逻辑 | 过滤后、渲染前 |
|
||||
| clearFilters() | 重置排序为默认值 | `date-desc` |
|
||||
|
||||
## 架构审计
|
||||
|
||||
- **风险**:无跨模块依赖,纯前端改动
|
||||
- **缓解**:不适用
|
||||
Reference in New Issue
Block a user