feat(skill): persist flattened tool sets #460

Merged
freemo merged 1 commits from feature/m4-skill-registry-db into master 2026-02-27 21:32:21 +00:00
Owner

Summary

Adds persistence support for flattened tool sets in the skill registry, enabling cached resolution of skill-to-tool mappings with hash-based invalidation.

Changes

Alembic Migration (m4_002_skill_flattened_tools)

  • Adds 5 new columns to skills table: flattened_tools_json, includes_json, capability_summary_json, yaml_text, flattening_hash
  • Adds uniqueness constraint on skill name (defence-in-depth on PK)
  • Uses batch_alter_table for SQLite compatibility

SkillModel Updates

  • 5 new SQLAlchemy Column definitions matching the migration
  • UniqueConstraint added to __table_args__

SkillRepository Extensions

  • update_flattened_tools() — persists all 5 cache fields
  • get_flattened_tools() — returns dict of cached fields
  • needs_refresh() — compares stored hash vs current hash
  • recompute_flattening_hash() — SHA-256 computation + storage
  • invalidate_cached_summaries() — nulls all cached fields
  • update() method now invalidates cached fields on mutation
  • All methods follow @database_retry + flush-don't-commit pattern with structlog logging

Documentation

  • Updated docs/reference/database_schema.md with skills table fields and mapping table

Tests

  • Behave: 6 scenarios in features/skill_registry_persistence.feature (all pass)
  • Robot: 2 smoke tests in robot/skill_registry_persistence_smoke.robot (all pass)
  • ASV: 3 benchmarks in benchmarks/skill_registry_persist_bench.py

Quality Gates

  • lint: PASS
  • typecheck: PASS (0 errors, 0 warnings)
  • unit_tests: PASS
  • integration_tests: PASS

Closes #166

## Summary Adds persistence support for flattened tool sets in the skill registry, enabling cached resolution of skill-to-tool mappings with hash-based invalidation. ## Changes ### Alembic Migration (`m4_002_skill_flattened_tools`) - Adds 5 new columns to `skills` table: `flattened_tools_json`, `includes_json`, `capability_summary_json`, `yaml_text`, `flattening_hash` - Adds uniqueness constraint on skill name (defence-in-depth on PK) - Uses `batch_alter_table` for SQLite compatibility ### SkillModel Updates - 5 new SQLAlchemy Column definitions matching the migration - UniqueConstraint added to `__table_args__` ### SkillRepository Extensions - `update_flattened_tools()` — persists all 5 cache fields - `get_flattened_tools()` — returns dict of cached fields - `needs_refresh()` — compares stored hash vs current hash - `recompute_flattening_hash()` — SHA-256 computation + storage - `invalidate_cached_summaries()` — nulls all cached fields - `update()` method now invalidates cached fields on mutation - All methods follow `@database_retry` + flush-don't-commit pattern with structlog logging ### Documentation - Updated `docs/reference/database_schema.md` with skills table fields and mapping table ### Tests - **Behave**: 6 scenarios in `features/skill_registry_persistence.feature` (all pass) - **Robot**: 2 smoke tests in `robot/skill_registry_persistence_smoke.robot` (all pass) - **ASV**: 3 benchmarks in `benchmarks/skill_registry_persist_bench.py` ## Quality Gates - lint: PASS - typecheck: PASS (0 errors, 0 warnings) - unit_tests: PASS - integration_tests: PASS Closes #166
freemo scheduled this pull request to auto merge when all checks succeed 2026-02-27 02:32:26 +00:00
freemo force-pushed feature/m4-skill-registry-db from 515e54991e to 60b2a075b1 2026-02-27 02:33:16 +00:00 Compare
freemo force-pushed feature/m4-skill-registry-db from 60b2a075b1 to 7235d46ade 2026-02-27 20:09:27 +00:00 Compare
freemo merged commit 7235d46ade into master 2026-02-27 21:32:21 +00:00
freemo deleted branch feature/m4-skill-registry-db 2026-02-27 21:32:21 +00:00
freemo added the
State
Completed
label 2026-03-04 00:58:44 +00:00
Sign in to join this conversation.
No Reviewers
No Label
State
Completed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#460