feat: implement RFC-20 Phase 2 tag/label + query system #29

Merged
xiaonuo merged 1 commits from fix/22-tag-label-query into main 2026-05-30 07:57:23 +00:00
Owner

What

Implements RFC-20 Phase 2: Tag/Label + Query functionality for the json-cas variable system.

Why

Extends the variable system with metadata capabilities:

  • Tags (key:value pairs) for structured metadata
  • Labels (bare identifiers) for simple categorization
  • Query filtering by scope, tags, and labels with AND logic

Changes

Core Implementation

  • Extended Variable type with tags and labels fields
  • Added variable_tags and variable_labels SQLite tables
  • Implemented foreign key constraints with CASCADE delete
  • Added TagLabelConflictError and InvalidTagFormatError types

VariableStore API

  • Enhanced create() to accept initial tags/labels
  • Added tag() method for atomic add/update/delete operations
  • Enhanced list() with filtering by tags, labels, and scope

CLI Commands

  • New: json-cas var tag ...
  • Enhanced: json-cas var create --tag ...
  • Enhanced: json-cas var list --tag ...

Test Coverage

  • 46 new tests in dedicated test file
  • All 214 tests pass (including backward compatibility)

Ref

Fixes #22

## What Implements RFC-20 Phase 2: Tag/Label + Query functionality for the json-cas variable system. ## Why Extends the variable system with metadata capabilities: - Tags (key:value pairs) for structured metadata - Labels (bare identifiers) for simple categorization - Query filtering by scope, tags, and labels with AND logic ## Changes ### Core Implementation - Extended Variable type with tags and labels fields - Added variable_tags and variable_labels SQLite tables - Implemented foreign key constraints with CASCADE delete - Added TagLabelConflictError and InvalidTagFormatError types ### VariableStore API - Enhanced create() to accept initial tags/labels - Added tag() method for atomic add/update/delete operations - Enhanced list() with filtering by tags, labels, and scope ### CLI Commands - New: json-cas var tag <id> <tag>... - Enhanced: json-cas var create --tag <tag>... - Enhanced: json-cas var list --tag <tag>... ### Test Coverage - 46 new tests in dedicated test file - All 214 tests pass (including backward compatibility) ## Ref Fixes #22
xiaoju added 1 commit 2026-05-30 07:49:59 +00:00
Implements comprehensive tag/label functionality for variables:

## Core Features
- Tags: key-value pairs with same-key override semantics
- Labels: bare identifiers
- Deletion syntax: `:name` removes tag or label
- Mutual exclusion: tag keys and label names cannot coexist
- Unified `var tag` command for all tag/label operations

## Data Model
- Extended Variable type with tags/labels fields
- New variable_tags and variable_labels SQLite tables
- Foreign key constraints with CASCADE delete
- Proper indexes for efficient querying

## Query Capabilities
- Filter by scope (hierarchical prefix matching)
- Filter by tags (key:value pairs, AND logic)
- Filter by labels (bare names, AND logic)
- Combined filtering (scope + tags/labels)

## CLI Commands
- `json-cas var create --tag <tag>...` - initial tags/labels
- `json-cas var tag <id> <tag>...` - add/update/delete
- `json-cas var list --tag <tag>...` - query with filters

## Implementation Details
- TagLabelConflictError and InvalidTagFormatError types
- Atomic batch operations with rollback
- 46 comprehensive tests for tags/labels
- Backward compatible with Phase 1
- All 214 tests pass

Closes #22

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xiaonuo merged commit c34a8b3c58 into main 2026-05-30 07:57:23 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#29