RFC-20 Phase 2: Tag/Label + 查询 #22

Closed
opened 2026-05-30 05:36:17 +00:00 by xingyue · 0 comments
Owner

User Story

作为用户,我能给 variable 打 tag/label,用 :name 语义删除,按 scope/tag/label 组合筛选 variables。

前置条件

Phase 1 已完成,有可用的 var create/get 命令。

测试步骤

准备

  • Step 0: 创建测试 variables
    json-cas bootstrap
    json-cas schema put '{"type":"object","properties":{"name":{"type":"string"}}}'
    # → SCHEMA_HASH
    json-cas put <SCHEMA_HASH> '{"name":"a"}'  # → HASH_A
    json-cas put <SCHEMA_HASH> '{"name":"b"}'  # → HASH_B
    json-cas put <SCHEMA_HASH> '{"name":"c"}'  # → HASH_C
    
    json-cas var create --scope uwf/thread/ --value <HASH_A> --tag status:active --tag workflow:solve-issue
    # → VAR_1
    json-cas var create --scope uwf/thread/ --value <HASH_B> --tag status:completed
    # → VAR_2
    json-cas var create --scope uwf/workflow/ --value <HASH_C> --tag pinned
    # → VAR_3 (pinned 是 label)
    

Tag 操作

  • Step 1: 添加 tag

    json-cas var tag <VAR_1> priority:high
    json-cas var get <VAR_1>
    

    预期: tags 包含 status:active, workflow:solve-issue, priority:high

  • Step 2: tag 同 key 覆盖

    json-cas var tag <VAR_1> status:completed
    json-cas var get <VAR_1>
    

    预期: tags 中 status 变为 completed(替换 active)

  • Step 3: 删除 tag

    json-cas var tag <VAR_1> :status
    json-cas var get <VAR_1>
    

    预期: tags 中无 status key

Label 操作

  • Step 4: 添加 label

    json-cas var tag <VAR_1> archived
    json-cas var get <VAR_1>
    

    预期: labels 包含 archived

  • Step 5: 删除 label

    json-cas var tag <VAR_1> :archived
    json-cas var get <VAR_1>
    

    预期: labels 中无 archived

Tag/Label 同名互斥

  • Step 6: label 与已有 tag key 冲突

    json-cas var tag <VAR_1> workflow
    

    预期: error JSON,提示 workflow 已作为 tag key 存在

  • Step 7: tag 与已有 label 冲突

    json-cas var tag <VAR_3> pinned:true
    

    预期: error JSON,提示 pinned 已作为 label 存在

查询

  • Step 8: scope 精确匹配

    json-cas var list --scope uwf/thread/
    

    预期: 返回 VAR_1, VAR_2(不含 VAR_3)

  • Step 9: scope 前缀匹配

    json-cas var list --scope uwf/
    

    预期: 返回 VAR_1, VAR_2, VAR_3

  • Step 10: tag 过滤

    json-cas var list --tag status:completed
    

    预期: 返回 VAR_1(Step 2 已改为 completed)和 VAR_2

  • Step 11: label 过滤

    json-cas var list --tag pinned
    

    预期: 返回 VAR_3

  • Step 12: 组合查询

    json-cas var list --scope uwf/thread/ --tag status:completed
    

    预期: 仅返回 scope=uwf/thread/ 且 status=completed 的 variables

  • Step 13: list 输出格式
    预期: { "type": "<variable-list-schema-hash>", "value": [...] }

批量 tag

  • Step 14: 一次操作多个 tag/label
    json-cas var tag <VAR_2> priority:low archived :status
    json-cas var get <VAR_2>
    
    预期: 同时添加 tag priority:low、label archived、删除 tag status

验证完成标准

所有 checkbox 打勾
bun test 通过
bun run check 无 lint 错误

Ref: #20, #19

## User Story 作为用户,我能给 variable 打 tag/label,用 `:name` 语义删除,按 scope/tag/label 组合筛选 variables。 ## 前置条件 Phase 1 已完成,有可用的 `var create/get` 命令。 ## 测试步骤 ### 准备 - [ ] **Step 0: 创建测试 variables** ```bash json-cas bootstrap json-cas schema put '{"type":"object","properties":{"name":{"type":"string"}}}' # → SCHEMA_HASH json-cas put <SCHEMA_HASH> '{"name":"a"}' # → HASH_A json-cas put <SCHEMA_HASH> '{"name":"b"}' # → HASH_B json-cas put <SCHEMA_HASH> '{"name":"c"}' # → HASH_C json-cas var create --scope uwf/thread/ --value <HASH_A> --tag status:active --tag workflow:solve-issue # → VAR_1 json-cas var create --scope uwf/thread/ --value <HASH_B> --tag status:completed # → VAR_2 json-cas var create --scope uwf/workflow/ --value <HASH_C> --tag pinned # → VAR_3 (pinned 是 label) ``` ### Tag 操作 - [ ] **Step 1: 添加 tag** ```bash json-cas var tag <VAR_1> priority:high json-cas var get <VAR_1> ``` **预期:** tags 包含 `status:active`, `workflow:solve-issue`, `priority:high` - [ ] **Step 2: tag 同 key 覆盖** ```bash json-cas var tag <VAR_1> status:completed json-cas var get <VAR_1> ``` **预期:** tags 中 status 变为 `completed`(替换 active) - [ ] **Step 3: 删除 tag** ```bash json-cas var tag <VAR_1> :status json-cas var get <VAR_1> ``` **预期:** tags 中无 status key ### Label 操作 - [ ] **Step 4: 添加 label** ```bash json-cas var tag <VAR_1> archived json-cas var get <VAR_1> ``` **预期:** labels 包含 `archived` - [ ] **Step 5: 删除 label** ```bash json-cas var tag <VAR_1> :archived json-cas var get <VAR_1> ``` **预期:** labels 中无 `archived` ### Tag/Label 同名互斥 - [ ] **Step 6: label 与已有 tag key 冲突** ```bash json-cas var tag <VAR_1> workflow ``` **预期:** error JSON,提示 `workflow` 已作为 tag key 存在 - [ ] **Step 7: tag 与已有 label 冲突** ```bash json-cas var tag <VAR_3> pinned:true ``` **预期:** error JSON,提示 `pinned` 已作为 label 存在 ### 查询 - [ ] **Step 8: scope 精确匹配** ```bash json-cas var list --scope uwf/thread/ ``` **预期:** 返回 VAR_1, VAR_2(不含 VAR_3) - [ ] **Step 9: scope 前缀匹配** ```bash json-cas var list --scope uwf/ ``` **预期:** 返回 VAR_1, VAR_2, VAR_3 - [ ] **Step 10: tag 过滤** ```bash json-cas var list --tag status:completed ``` **预期:** 返回 VAR_1(Step 2 已改为 completed)和 VAR_2 - [ ] **Step 11: label 过滤** ```bash json-cas var list --tag pinned ``` **预期:** 返回 VAR_3 - [ ] **Step 12: 组合查询** ```bash json-cas var list --scope uwf/thread/ --tag status:completed ``` **预期:** 仅返回 scope=uwf/thread/ 且 status=completed 的 variables - [ ] **Step 13: list 输出格式** **预期:** `{ "type": "<variable-list-schema-hash>", "value": [...] }` ### 批量 tag - [ ] **Step 14: 一次操作多个 tag/label** ```bash json-cas var tag <VAR_2> priority:low archived :status json-cas var get <VAR_2> ``` **预期:** 同时添加 tag priority:low、label archived、删除 tag status ## 验证完成标准 ✅ 所有 checkbox 打勾 ✅ `bun test` 通过 ✅ `bun run check` 无 lint 错误 Ref: #20, #19
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#22